@annotorious/openseadragon 3.4.0 → 3.4.2

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,22 +1,22 @@
1
- (function(Zt,Ae){typeof exports=="object"&&typeof module<"u"?Ae(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Ae):(Zt=typeof globalThis<"u"?globalThis:Zt||self,Ae(Zt.AnnotoriousOSD={},Zt.OpenSeadragon))})(this,function(Zt,Ae){"use strict";var wI=Object.defineProperty;var AI=(Zt,Ae,li)=>Ae in Zt?wI(Zt,Ae,{enumerable:!0,configurable:!0,writable:!0,value:li}):Zt[Ae]=li;var Gt=(Zt,Ae,li)=>AI(Zt,typeof Ae!="symbol"?Ae+"":Ae,li);var li=Object.prototype.hasOwnProperty;function hi(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--&&hi(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(li.call(r,e)&&++i&&!li.call(t,e)||!(e in t)||!hi(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var Qo=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Qo||{});const me=[];for(let r=0;r<256;++r)me.push((r+256).toString(16).slice(1));function xg(r,t=0){return(me[r[t+0]]+me[r[t+1]]+me[r[t+2]]+me[r[t+3]]+"-"+me[r[t+4]]+me[r[t+5]]+"-"+me[r[t+6]]+me[r[t+7]]+"-"+me[r[t+8]]+me[r[t+9]]+"-"+me[r[t+10]]+me[r[t+11]]+me[r[t+12]]+me[r[t+13]]+me[r[t+14]]+me[r[t+15]]).toLowerCase()}let Jo;const bg=new Uint8Array(16);function Eg(){if(!Jo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Jo=crypto.getRandomValues.bind(crypto)}return Jo(bg)}const Tg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tu={randomUUID:Tg};function wg(r,t,e){var i;if(tu.randomUUID&&!r)return tu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Eg();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,xg(s)}const ta=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)}},Ag=(r,t,e,i)=>({id:wg(),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))},Cg=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Ig=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!hi(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Rg=(r,t)=>!hi(r.target,t.target),Mg=(r,t)=>{const e=Sg(r,t),i=Cg(r,t),s=Ig(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:Rg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var kr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(kr||{});const Og=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return Mg(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let Pg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const Ng=250,Lg=(r,t)=>{const e=Pg(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,y=performance.now();if(y-o>Ng)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=Og(i[_],m)}o=y}n=!1};r.observe(a,{origin:kr.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f),h=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:y}=i[s+1];h(f),c(m),p(y),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:y}=i[s];l(f),u(m),d(y),e.emit("undo",i[s]),s-=1}}}},Dg=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},p=(_,v)=>{const g=l.get(_);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},f=(_,v,g)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(A=>e.serialize(A)):e.serialize(v),w=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,w)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!hi(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:E})=>E===g.id)||g)};n.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 g=o.getAnnotation(v.id);g&&!hi(g,v)&&f("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(_.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!hi(E,x)&&f("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),..._.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(_=>{!u&&_?f("mouseEnterAnnotation",o.getAnnotation(_)):u&&!_?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&_&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(_))),u=_}),a==null||a.subscribe(_=>f("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=_.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(g||[]).forEach(x=>f("deleteAnnotation",x)),(_.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const w=h.find(A=>A.id===x.id)||x;h=h.map(A=>A.id===x.id?E:A),f("updateAnnotation",E,w)})},{origin:kr.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(x=>x.id)),g=(_.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(w=>w.id===x.id)||x))}},{origin:kr.REMOTE});const y=_=>v=>{const{updated:g}=v;_?(g||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:p,emit:f}},Bg=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Fg=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,kr.REMOTE):console.error(g)}else i.addAnnotation(ta(_),kr.REMOTE)},o=()=>s.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(),u=()=>{var _;const v=(((_=s.selected)==null?void 0:_.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(_,v=!0)=>fetch(_).then(g=>g.json()).then(g=>(p(g,v),g)),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),_}},p=(_,v=!0)=>{if(e){const g=e.parseAll||Bg(e),{parsed:x,failed:E}=g(_);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,kr.REMOTE)}else i.bulkAddAnnotations(_.map(ta),v,kr.REMOTE)},f=(_,v)=>{_?s.setSelected(_,v):s.clear()},m=_=>{s.clear(),s.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(ta(_)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:y}},Ug="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let kg=r=>crypto.getRandomValues(new Uint8Array(r)),Gg=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},Hg=(r,t=21)=>Gg(r,t|0,kg),$g=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ug[e[r]&63];return t};const Vg=()=>({isGuest:!0,id:Hg("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Xg=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],Yg=()=>{const r=[...Xg];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};$g();var Wg=Object.defineProperty,jg=(r,t,e)=>t in r?Wg(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ht=(r,t,e)=>jg(r,typeof t!="symbol"?t+"":t,e);function Pt(){}function ea(r,t){for(const e in t)r[e]=t[e];return r}function eu(r){return r()}function ru(){return Object.create(null)}function Ve(r){r.forEach(eu)}function zt(r){return typeof r=="function"}function le(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function zg(r){return Object.keys(r).length===0}function iu(r,...t){if(r==null){for(const i of t)i(void 0);return Pt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function ra(r,t,e){r.$$.on_destroy.push(iu(t,e))}function qg(r,t,e,i){if(r){const s=su(r,t,e,i);return r[0](s)}}function su(r,t,e,i){return r[1]&&i?ea(e.ctx.slice(),r[1](i(t))):e.ctx}function Kg(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Zg(r,t,e,i,s,n){if(s){const o=su(t,e,i,n);r.p(o,s)}}function Qg(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 nu(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function _n(r){return r??""}function St(r,t){r.appendChild(t)}function rt(r,t,e){r.insertBefore(t,e||null)}function et(r){r.parentNode&&r.parentNode.removeChild(r)}function ui(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function tt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ou(r){return document.createTextNode(r)}function Ne(){return ou(" ")}function Le(){return ou("")}function Lt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function b(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Jg(r){return Array.from(r.childNodes)}function Gr(r,t,e){r.classList.toggle(t,!!e)}function ty(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let As;function Ss(r){As=r}function au(){if(!As)throw new Error("Function called outside component initialization");return As}function Bi(r){au().$$.on_mount.push(r)}function ci(){const r=au();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=ty(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function De(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Fi=[],Cs=[];let Ui=[];const lu=[],hu=Promise.resolve();let ia=!1;function uu(){ia||(ia=!0,hu.then(cu))}function ey(){return uu(),hu}function sa(r){Ui.push(r)}const na=new Set;let ki=0;function cu(){if(ki!==0)return;const r=As;do{try{for(;ki<Fi.length;){const t=Fi[ki];ki++,Ss(t),ry(t.$$)}}catch(t){throw Fi.length=0,ki=0,t}for(Ss(null),Fi.length=0,ki=0;Cs.length;)Cs.pop()();for(let t=0;t<Ui.length;t+=1){const e=Ui[t];na.has(e)||(na.add(e),e())}Ui.length=0}while(Fi.length);for(;lu.length;)lu.pop()();ia=!1,na.clear(),Ss(r)}function ry(r){if(r.fragment!==null){r.update(),Ve(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(sa)}}function iy(r){const t=[],e=[];Ui.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ui=t}const vn=new Set;let di;function Ie(){di={r:0,c:[],p:di}}function Re(){di.r||Ve(di.c),di=di.p}function ct(r,t){r&&r.i&&(vn.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(vn.has(r))return;vn.add(r),di.c.push(()=>{vn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Be(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Se(r){r&&r.c()}function ge(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),sa(()=>{const n=r.$$.on_mount.map(eu).filter(zt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ve(n),r.$$.on_mount=[]}),s.forEach(sa)}function ye(r,t){const e=r.$$;e.fragment!==null&&(iy(e.after_update),Ve(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function sy(r,t){r.$$.dirty[0]===-1&&(Fi.push(r),uu(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Me(r,t,e,i,s,n,o=null,a=[-1]){const l=As;Ss(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Pt,not_equal:s,bound:ru(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:ru(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&sy(r,c)),d}):[],h.update(),u=!0,Ve(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=Jg(t.target);h.fragment&&h.fragment.l(c),c.forEach(et)}else h.fragment&&h.fragment.c();t.intro&&ct(r.$$.fragment),ge(r,t.target,t.anchor),cu()}Ss(l)}class Oe{constructor(){Ht(this,"$$"),Ht(this,"$$set")}$destroy(){ye(this,1),this.$destroy=Pt}$on(t,e){if(!zt(e))return Pt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!zg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const ny="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ny);var Et=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Et||{});const oa={},xn=(r,t)=>oa[r]=t,aa=r=>oa[r.type].area(r),oy=(r,t,e)=>oa[r.type].intersects(r,t,e),Xe=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},la=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)},ha=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},ay=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},ly={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};xn(Et.ELLIPSE,ly);const hy={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=la(s.points),a=n.reduce((l,h)=>l+la(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(ha(n.points,t,e)){let a=!1;for(const l of o)if(ha(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},uy=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Xe(t)},qe=r=>r.rings.map(t=>ay(t.points)).join(" ");xn(Et.MULTIPOLYGLON,hy);const cy={area:r=>{const t=r.geometry.points;return la(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return ha(i,t,e)}};xn(Et.POLYGON,cy);const dy={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};xn(Et.RECTANGLE,dy);const Ke=r=>bn(r.target),bn=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},fy=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,u,c]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,p,f,m]=[l,h,u,c].map(parseFloat);return{type:Et.RECTANGLE,geometry:{x:d,y:p,w:f,h:m,bounds:{minX:d,minY:t?p-m:p,maxX:d+f,maxY:t?p:p+m}}}},py=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},du="http://www.w3.org/2000/svg",fu=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},my=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${du}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},pu=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(du),i=t.lookupNamespaceURI(null);return e||i?fu(t).firstChild:fu(my(t)).firstChild},te=" ";function gy(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===k.CLOSE_PATH)t+="z";else if(i.type===k.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===k.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===k.MOVE_TO)t+=(i.relative?"m":"M")+i.x+te+i.y;else if(i.type===k.LINE_TO)t+=(i.relative?"l":"L")+i.x+te+i.y;else if(i.type===k.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+te+i.y1+te+i.x2+te+i.y2+te+i.x+te+i.y;else if(i.type===k.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+te+i.y2+te+i.x+te+i.y;else if(i.type===k.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+te+i.y1+te+i.x+te+i.y;else if(i.type===k.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+te+i.y;else if(i.type===k.ARC)t+=(i.relative?"a":"A")+i.rX+te+i.rY+te+i.xRot+te+ +i.lArcFlag+te+ +i.sweepFlag+te+i.x+te+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function ua([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Ze(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const Hr=Math.PI;function ca(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*Hr,[l,h]=ua([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),p=i*h/s*d,f=-s*l/i*d,m=ua([p,f],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-f)/s,(l-p)/i),r.phi2=Math.atan2((-h-f)/s,(-l-p)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*Hr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Hr),r.phi1*=180/Hr,r.phi2*=180/Hr}function mu(r,t,e){Ze(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const fi=Math.PI/180;function gu(r,t,e){return(1-e)*r+e*t}function yu(r,t,e,i){return r+Math.cos(i/180*Hr)*t+Math.sin(i/180*Hr)*e}function _u(r,t,e,i){const s=t-r,n=e-t,o=i-e,a=3*s+3*o-6*n,l=(n-s)*6,h=3*s;return Math.abs(a)<1e-6?Math.abs(l)<1e-6?[]:[-h/l]:yy(l/a,h/a,1e-6)}function vu(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function yy(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function _y(r,t,e){r.cX||ca(r,t,e);const i=r.xRot/180*Hr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:k.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,p)=>{const[f,m]=ua([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=gu(r.phi1,r.phi2,d/a),f=gu(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*fi/4),_=Math.cos(p*fi)-y*Math.sin(p*fi),v=Math.sin(p*fi)+y*Math.cos(p*fi),g=Math.cos(f*fi),x=Math.sin(f*fi),E=g+y*x,w=x-y*g,A=c(_,v),R=c(E,w),M=c(g,x),D={relative:r.relative,type:k.CURVE_TO,x:M[0],y:M[1],x1:A[0],y1:A[1],x2:R[0],y2:R[1]};r.relative&&(D.x1-=h,D.y1-=u,D.x2-=h,D.y2-=u,D.x-=h,D.y-=u),h=M[0],u=M[1],l[d]=D}return l}function da(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const l=i*n+s*o,h=i*i+s*s,u=n*n+o*o;return 0<=l&&l<=u&&h<=u}function vy(r,t=!0){if(r.length<2)return r;const e=ee.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===k.MOVE_TO&&s.length>0&&(t?i.push(...En(s)):i.unshift(...En(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...En(s)):i.unshift(...En(s))),i}function En(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===k.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:k.MOVE_TO,relative:!1,x:r[i].x,y:r[i].y}];for(let n=i;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case k.HORIZ_LINE_TO:s.push({type:k.HORIZ_LINE_TO,relative:!1,x:a.x});break;case k.VERT_LINE_TO:s.push({type:k.VERT_LINE_TO,relative:!1,y:a.y});break;case k.LINE_TO:case k.MOVE_TO:s.push({type:k.LINE_TO,relative:!1,x:a.x,y:a.y});break;case k.CURVE_TO:s.push({type:k.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case k.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case k.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case k.ARC:throw new Error("Unsupported command: A (arc)");case k.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:k.CLOSE_PATH}),s}function xy(r=1e13){Ze(r);function t(e){return Math.round(e*r)/r}return function(e){return"x1"in e&&typeof e.x1<"u"&&(e.x1=t(e.x1)),"y1"in e&&typeof e.y1<"u"&&(e.y1=t(e.y1)),"x2"in e&&typeof e.x2<"u"&&(e.x2=t(e.x2)),"y2"in e&&typeof e.y2<"u"&&(e.y2=t(e.y2)),"x"in e&&typeof e.x<"u"&&(e.x=t(e.x)),"y"in e&&typeof e.y<"u"&&(e.y=t(e.y)),"rX"in e&&typeof e.rX<"u"&&(e.rX=t(e.rX)),"rY"in e&&typeof e.rY<"u"&&(e.rY=t(e.rY)),e}}function xu(){return Qe((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function by(){return Qe((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function Ey(r=!0,t=!0,e=!0,i=!0){return Qe((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&k.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&k.HORIZ_LINE_TO&&(s.type=k.LINE_TO,s.y=s.relative?0:o),e&&s.type&k.VERT_LINE_TO&&(s.type=k.LINE_TO,s.x=s.relative?0:n),r&&s.type&k.CLOSE_PATH&&(s.type=k.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&k.ARC&&(s.rX===0||s.rY===0)&&(s.type=k.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&k.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];da(h,u,c)&&(s.type=k.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&k.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];da(h,u,d)&&da(h,c,d)&&(s.type=k.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function bu(){let r=NaN,t=NaN,e=NaN,i=NaN;return Qe((s,n,o)=>(s.type&k.SMOOTH_CURVE_TO&&(s.type=k.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&k.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&k.SMOOTH_QUAD_TO&&(s.type=k.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&k.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Eu(){let r=NaN,t=NaN;return Qe((e,i,s)=>{if(e.type&k.SMOOTH_QUAD_TO&&(e.type=k.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&k.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=k.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Qe(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&k.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&k.CLOSE_PATH&&(t=i,e=s),"x"in n&&typeof n.x<"u"&&(t=n.relative?t+n.x:n.x),"y"in n&&typeof n.y<"u"&&(e=n.relative?e+n.y:n.y),n.type&k.MOVE_TO&&(i=t,s=e),o}}function Ty(r=0){Ze(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Qe((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&k.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(k.CURVE_TO|k.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&k.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&k.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&k.LINE_COMMANDS||n.type&k.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&k.CURVE_TO||n.type&k.SMOOTH_CURVE_TO||n.type&k.QUAD_TO||n.type&k.SMOOTH_QUAD_TO){const f=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,p=isNaN(s)?typeof n.y1>"u"?p:n.relative?n.y:n.y1-a:s-a;const y=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,_=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(f)<=r&&u(m)<=r&&u(d)<=r&&u(p)<=r&&u(y)<=r&&u(_)<=r&&(c=!0)}return n.type&k.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function $r(r,t,e,i,s,n){return Ze(r,t,e,i,s,n),Qe((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),p=typeof o.x<"u"?o.x:d?0:a,f=typeof o.y<"u"?o.y:d?0:l;o.type&k.HORIZ_LINE_TO&&t!==0&&(o.type=k.LINE_TO,o.y=o.relative?0:l),o.type&k.VERT_LINE_TO&&e!==0&&(o.type=k.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+f*e+(d?0:s)),typeof o.y<"u"&&(o.y=p*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(_){return _*_}const y=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(y===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=k.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),E=1/m(o.rY),w=m(g)*x+m(v)*E,A=2*v*g*(x-E),R=m(v)*x+m(g)*E,M=w*i*i-A*t*i+R*t*t,D=A*(r*i+t*e)-2*(w*e*i+R*r*t),U=w*e*e-A*r*e+R*r*r,C=(Math.atan2(D,M-U)+Math.PI)%Math.PI/2,T=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(M*m(I)+D*T*I+U*m(T)),o.rY=Math.abs(y)/Math.sqrt(M*m(T)-D*T*I+U*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function wy(r,t=0,e=0){Ze(r,t,e);const i=Math.sin(r),s=Math.cos(r);return $r(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Ay(r,t=0){return Ze(r,t),$r(1,0,0,1,r,t)}function Sy(r,t=r){return Ze(r,t),$r(r,0,0,t,0,0)}function Cy(r){return Ze(r),$r(1,0,Math.tan(r),1,0,0)}function Iy(r){return Ze(r),$r(1,Math.tan(r),0,1,0,0)}function Ry(r=0){return Ze(r),$r(-1,0,0,1,r,0)}function My(r=0){return Ze(r),$r(1,0,0,-1,0,r)}function Oy(){return Qe((r,t,e)=>k.ARC===r.type?_y(r,r.relative?0:t,r.relative?0:e):r)}function Py(){return Qe((r,t,e)=>(r.relative&&(t=0,e=0),k.ARC===r.type&&ca(r,t,e),r))}function Tu(){return r=>({...r})}function Ny(){const r=Tu(),t=xu(),e=Eu(),i=bu(),s=Qe((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&k.DRAWING_COMMANDS&&(h(o),u(a)),l.type&k.HORIZ_LINE_TO&&h(l.x),l.type&k.VERT_LINE_TO&&u(l.y),l.type&k.LINE_TO&&(h(l.x),u(l.y)),l.type&k.CURVE_TO){h(l.x),u(l.y);const c=_u(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(vu(o,l.x1,l.x2,l.x,p));const d=_u(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(vu(a,l.y1,l.y2,l.y,p))}if(l.type&k.ARC){h(l.x),u(l.y),ca(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,p=Math.sin(c)*l.rX,f=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[y,_]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,w])=>{const A=Math.atan2(w,E)*180/Math.PI;return A<y?A+360:A},g=mu(f,-d,0).map(v);for(const E of g)E>y&&E<_&&h(yu(l.cX,d,f,E));const x=mu(m,-p,0).map(v);for(const E of x)E>y&&E<_&&u(yu(l.cY,p,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const ee={ROUND:xy,TO_ABS:xu,TO_REL:by,NORMALIZE_HVZ:Ey,NORMALIZE_ST:bu,QT_TO_C:Eu,INFO:Qe,SANITIZE:Ty,MATRIX:$r,ROTATE:wy,TRANSLATE:Ay,SCALE:Sy,SKEW_X:Cy,SKEW_Y:Iy,X_AXIS_SYMMETRY:Ry,Y_AXIS_SYMMETRY:My,A_TO_C:Oy,ANNOTATE_ARCS:Py,CLONE:Tu,CALCULATE_BOUNDS:Ny,REVERSE_PATH:vy};class wu{round(t){return this.transform(ee.ROUND(t))}toAbs(){return this.transform(ee.TO_ABS())}toRel(){return this.transform(ee.TO_REL())}normalizeHVZ(t,e,i){return this.transform(ee.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(ee.NORMALIZE_ST())}qtToC(){return this.transform(ee.QT_TO_C())}aToC(){return this.transform(ee.A_TO_C())}sanitize(t){return this.transform(ee.SANITIZE(t))}translate(t,e){return this.transform(ee.TRANSLATE(t,e))}scale(t,e){return this.transform(ee.SCALE(t,e))}rotate(t,e,i){return this.transform(ee.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(ee.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(ee.SKEW_X(t))}skewY(t){return this.transform(ee.SKEW_Y(t))}xSymmetry(t){return this.transform(ee.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(ee.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(ee.ANNOTATE_ARCS())}}const Ly=r=>r===" "||r===" "||r==="\r"||r===`
2
- `,Au=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class Dy extends wu{constructor(){super(),Ht(this,"curNumber",""),Ht(this,"curCommandType",-1),Ht(this,"curCommandRelative",!1),Ht(this,"canParseCommandOrComma",!0),Ht(this,"curNumberHasExp",!1),Ht(this,"curNumberHasExpDigits",!1),Ht(this,"curNumberHasDecimal",!1),Ht(this,"curArgs",[])}finish(t=[]){if(this.parse(" ",t),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t}parse(t,e=[]){const i=s=>{e.push(s),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let s=0;s<t.length;s++){const n=t[s],o=this.curCommandType===k.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=Au(n)&&(this.curNumber==="0"&&n==="0"||o);if(Au(n)&&!a){this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(n==="e"||n==="E"){this.curNumber+=n,this.curNumberHasExp=!0;continue}if((n==="-"||n==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=n;continue}if(n==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!o){this.curNumber+=n,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError(`Invalid number ending at ${s}`);if(this.curCommandType===k.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>l)throw new SyntaxError(`Expected positive number, got "${l}" at index "${s}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${s}"`)}this.curArgs.push(l),this.curArgs.length===By[this.curCommandType]&&(k.HORIZ_LINE_TO===this.curCommandType?i({type:k.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):k.VERT_LINE_TO===this.curCommandType?i({type:k.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===k.MOVE_TO||this.curCommandType===k.LINE_TO||this.curCommandType===k.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),k.MOVE_TO===this.curCommandType&&(this.curCommandType=k.LINE_TO)):this.curCommandType===k.CURVE_TO?i({type:k.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===k.SMOOTH_CURVE_TO?i({type:k.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===k.QUAD_TO?i({type:k.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===k.ARC&&i({type:k.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!Ly(n)){if(n===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(n==="+"||n==="-"||n==="."){this.curNumber=n,this.curNumberHasDecimal=n===".";continue}if(a){this.curNumber=n,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${s}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${n}" at index ${s}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,n==="z"||n==="Z"){e.push({type:k.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=k.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=k.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=k.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=k.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=k.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=k.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=k.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=k.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=k.ARC,this.curCommandRelative=n==="a";else throw new SyntaxError(`Unexpected character "${n}" at index ${s}.`)}}return e}transform(t){return Object.create(this,{parse:{value(e,i=[]){const s=Object.getPrototypeOf(this).parse.call(this,e);for(const n of s){const o=t(n);Array.isArray(o)?i.push(...o):i.push(o)}return i}}})}}const Ft=class Wh extends wu{constructor(t){super(),Ht(this,"commands"),typeof t=="string"?this.commands=Wh.parse(t):this.commands=t}encode(){return Wh.encode(this.commands)}getBounds(){const t=ee.CALCULATE_BOUNDS();return this.transform(t),t}transform(t){const e=[];for(const i of this.commands){const s=t(i);Array.isArray(s)?e.push(...s):e.push(s)}return this.commands=e,this}reverse(t=!0){return this.commands=ee.REVERSE_PATH(this.commands,t),this}static encode(t){return gy(t)}static parse(t){const e=new Dy,i=[];return e.parse(t,i),e.finish(i),i}};Ht(Ft,"CLOSE_PATH",1),Ht(Ft,"MOVE_TO",2),Ht(Ft,"HORIZ_LINE_TO",4),Ht(Ft,"VERT_LINE_TO",8),Ht(Ft,"LINE_TO",16),Ht(Ft,"CURVE_TO",32),Ht(Ft,"SMOOTH_CURVE_TO",64),Ht(Ft,"QUAD_TO",128),Ht(Ft,"SMOOTH_QUAD_TO",256),Ht(Ft,"ARC",512),Ht(Ft,"LINE_COMMANDS",Ft.LINE_TO|Ft.HORIZ_LINE_TO|Ft.VERT_LINE_TO),Ht(Ft,"DRAWING_COMMANDS",Ft.HORIZ_LINE_TO|Ft.VERT_LINE_TO|Ft.LINE_TO|Ft.CURVE_TO|Ft.SMOOTH_CURVE_TO|Ft.QUAD_TO|Ft.SMOOTH_QUAD_TO|Ft.ARC);let k=Ft;const By={[k.MOVE_TO]:2,[k.LINE_TO]:2,[k.HORIZ_LINE_TO]:1,[k.VERT_LINE_TO]:1,[k.CLOSE_PATH]:0,[k.QUAD_TO]:4,[k.SMOOTH_QUAD_TO]:2,[k.CURVE_TO]:6,[k.SMOOTH_CURVE_TO]:4,[k.ARC]:7},Fy=r=>{const t=new k(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case k.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case k.LINE_TO:i.push([n.x,n.y]);break;case k.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case k.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case k.CURVE_TO:case k.SMOOTH_CURVE_TO:case k.QUAD_TO:case k.SMOOTH_QUAD_TO:case k.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=Xe(e[0].points);return{rings:e,bounds:n}}},Uy=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:Et.POLYGON,geometry:{points:s,bounds:Xe(s)}}},ky=r=>{const t=pu(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:Et.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},Gy=r=>{const t=pu(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>Fy(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=Xe(i);return e.length===1&&e[0].rings.length===1?{type:Et.POLYGON,geometry:{points:i,bounds:s}}:{type:Et.MULTIPOLYGLON,geometry:{polygons:e,bounds:s}}},Hy=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Uy(t);if(t.includes("<path "))return Gy(t);if(t.includes("<ellipse "))return ky(t);throw"Unsupported SVG shape: "+t},$y=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${qe(t)}" />`).join("")}</g>`,Vy=r=>{let t;if(r.type===Et.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===Et.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}else if(r.type===Et.MULTIPOLYGLON){const e=r.geometry;t=`<svg>${$y(e)}</svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},_e=[];for(let r=0;r<256;++r)_e.push((r+256).toString(16).slice(1));function Xy(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 fa;const Yy=new Uint8Array(16);function Wy(){if(!fa){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");fa=crypto.getRandomValues.bind(crypto)}return fa(Yy)}const jy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Su={randomUUID:jy};function Cu(r,t,e){var i;if(Su.randomUUID&&!r)return Su.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Wy();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Xy(s)}var Iu=Object.prototype.hasOwnProperty;function Vr(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--&&Vr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Iu.call(r,e)&&++i&&!Iu.call(t,e)||!(e in t)||!Vr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function pa(){}function zy(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const Gi=[];function ma(r,t=pa){let e;const i=new Set;function s(a){if(zy(r,a)&&(r=a,e)){const l=!Gi.length;for(const h of i)h[1](),Gi.push(h,r);if(l){for(let h=0;h<Gi.length;h+=2)Gi[h][0](Gi[h+1]);Gi.length=0}}}function n(a){s(a(r))}function o(a,l=pa){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||pa),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const qy=r=>{const{subscribe:t,set:e}=ma();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var Ru=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(Ru||{});const Tn={selected:[]},Ky=(r,t,e)=>{const{subscribe:i,set:s}=ma(Tn);let n=t,o=Tn;i(f=>o=f);const a=()=>{Vr(o,Tn)||s(Tn)},l=()=>{var f;return((f=o.selected)==null?void 0:f.length)===0},h=f=>{if(l())return!1;const m=typeof f=="string"?f:f.id;return o.selected.some(y=>y.id===m)},u=(f,m)=>{let y;if(Array.isArray(f)){if(y=f.map(v=>r.getAnnotation(v)).filter(Boolean),y.length<f.length){console.warn("Invalid selection: "+f.filter(v=>!y.some(g=>g.id===v)));return}}else{const v=r.getAnnotation(f);if(!v){console.warn("Invalid selection: "+f);return}y=[v]}const _=y.reduce((v,g)=>{const x=Mu(g,n,e);return x==="EDIT"?[...v,{id:g.id,editable:!0}]:x==="SELECT"?[...v,{id:g.id}]:v},[]);s({selected:_,event:m})},c=(f,m)=>{const y=Array.isArray(f)?f:[f],_=y.map(v=>r.getAnnotation(v)).filter(v=>!!v);s({selected:_.map(v=>{const g=m===void 0?Mu(v,n,e)==="EDIT":m;return{id:v.id,editable:g}})}),_.length!==y.length&&console.warn("Invalid selection",f)},d=f=>{if(l())return!1;const{selected:m}=o;m.some(({id:y})=>f.includes(y))&&s({selected:m.filter(({id:y})=>!f.includes(y))})},p=f=>{n=f,c(o.selected.map(({id:m})=>m))};return r.observe(({changes:f})=>d((f.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:p,subscribe:i,userSelect:u}},Mu=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},ve=[];for(let r=0;r<256;++r)ve.push((r+256).toString(16).slice(1));function Zy(r,t=0){return(ve[r[t+0]]+ve[r[t+1]]+ve[r[t+2]]+ve[r[t+3]]+"-"+ve[r[t+4]]+ve[r[t+5]]+"-"+ve[r[t+6]]+ve[r[t+7]]+"-"+ve[r[t+8]]+ve[r[t+9]]+"-"+ve[r[t+10]]+ve[r[t+11]]+ve[r[t+12]]+ve[r[t+13]]+ve[r[t+14]]+ve[r[t+15]]).toLowerCase()}let ga;const Qy=new Uint8Array(16);function Jy(){if(!ga){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ga=crypto.getRandomValues.bind(crypto)}return ga(Qy)}const t_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ou={randomUUID:t_};function e_(r,t,e){var i;if(Ou.randomUUID&&!r)return Ou.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Jy();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Zy(s)}const ya=r=>{const t=e=>{const i={...e};return e.created&&typeof e.created=="string"&&(i.created=new Date(e.created)),e.updated&&typeof e.updated=="string"&&(i.updated=new Date(e.updated)),i};return{...r,bodies:(r.bodies||[]).map(t),target:t(r.target)}},r_=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},i_=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},s_=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Vr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),n_=(r,t)=>!Vr(r.target,t.target),Pu=(r,t)=>{const e=r_(r,t),i=i_(r,t),s=s_(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:n_(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Dt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Dt||{});const o_=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},a_=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return Pu(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},wn=r=>{const t=r.id===void 0?e_():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},l_=r=>r.id!==void 0,h_=()=>{const r=new Map,t=new Map,e=[],i=(C,T={})=>{e.push({onChange:C,options:T})},s=C=>{const T=e.findIndex(I=>I.onChange==C);T>-1&&e.splice(T,1)},n=(C,T)=>{const I={origin:C,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...r.values()]};e.forEach(N=>{o_(N,I)&&N.onChange(I)})},o=(C,T=Dt.LOCAL)=>{if(C.id&&r.get(C.id))throw Error(`Cannot add annotation ${C.id} - exists already`);{const I=wn(C);r.set(I.id,I),I.bodies.forEach(N=>t.set(N.id,I.id)),n(T,{created:[I]})}},a=(C,T)=>{const I=wn(typeof C=="string"?T:C),N=typeof C=="string"?C:C.id,O=N&&r.get(N);if(O){const L=Pu(O,I);return N===I.id?r.set(N,I):(r.delete(N),r.set(I.id,I)),O.bodies.forEach(F=>t.delete(F.id)),I.bodies.forEach(F=>t.set(F.id,I.id)),L}else console.warn(`Cannot update annotation ${N} - does not exist`)},l=(C,T=Dt.LOCAL,I=Dt.LOCAL)=>{const N=l_(T)?I:T,O=a(C,T);O&&n(N,{updated:[O]})},h=(C,T=Dt.LOCAL)=>{r.get(C.id)?l(C,T):o(C,T)},u=(C,T=Dt.LOCAL)=>{const I=C.reduce((N,O)=>{const L=a(O);return L?[...N,L]:N},[]);I.length>0&&n(T,{updated:I})},c=(C,T=Dt.LOCAL)=>{const I=C.map(wn),{toAdd:N,toUpdate:O}=I.reduce((F,V)=>r.get(V.id)?{...F,toUpdate:[...F.toUpdate,V]}:{...F,toAdd:[...F.toAdd,V]},{toAdd:[],toUpdate:[]}),L=O.map(F=>a(F,T)).filter(Boolean);N.forEach(F=>{r.set(F.id,F),F.bodies.forEach(V=>t.set(V.id,F.id))}),n(T,{created:N,updated:L})},d=(C,T=Dt.LOCAL)=>{const I=r.get(C.annotation);if(I){const N={...I,bodies:[...I.bodies,C]};r.set(I.id,N),t.set(C.id,N.id),n(T,{updated:[{oldValue:I,newValue:N,bodiesCreated:[C]}]})}else console.warn(`Attempt to add body to missing annotation: ${C.annotation}`)},p=()=>[...r.values()],f=(C=Dt.LOCAL)=>{const T=[...r.values()];r.clear(),t.clear(),n(C,{deleted:T})},m=(C,T=!0,I=Dt.LOCAL)=>{const N=C.map(wn);if(T){const O=[...r.values()];r.clear(),t.clear(),N.forEach(L=>{r.set(L.id,L),L.bodies.forEach(F=>t.set(F.id,L.id))}),n(I,{created:N,deleted:O})}else{const O=C.reduce((L,F)=>{const V=F.id&&r.get(F.id);return V?[...L,V]:L},[]);if(O.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${O.map(L=>L.id).join(", ")}`);N.forEach(L=>{r.set(L.id,L),L.bodies.forEach(F=>t.set(F.id,L.id))}),n(I,{created:N})}},y=C=>{const T=typeof C=="string"?C:C.id,I=r.get(T);if(I)return r.delete(T),I.bodies.forEach(N=>t.delete(N.id)),I;console.warn(`Attempt to delete missing annotation: ${T}`)},_=(C,T=Dt.LOCAL)=>{const I=y(C);I&&n(T,{deleted:[I]})},v=(C,T=Dt.LOCAL)=>{const I=C.reduce((N,O)=>{const L=y(O);return L?[...N,L]:N},[]);I.length>0&&n(T,{deleted:I})},g=C=>{const T=r.get(C.annotation);if(T){const I=T.bodies.find(N=>N.id===C.id);if(I){t.delete(I.id);const N={...T,bodies:T.bodies.filter(O=>O.id!==C.id)};return r.set(T.id,N),{oldValue:T,newValue:N,bodiesDeleted:[I]}}else console.warn(`Attempt to delete missing body ${C.id} from annotation ${C.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${C.annotation}`)},x=(C,T=Dt.LOCAL)=>{const I=g(C);I&&n(T,{updated:[I]})},E=(C,T=Dt.LOCAL)=>{const I=C.map(N=>g(N)).filter(Boolean);I.length>0&&n(T,{updated:I})},w=C=>{const T=r.get(C);return T?{...T}:void 0},A=C=>{const T=t.get(C);if(T){const I=w(T).bodies.find(N=>N.id===C);if(I)return I;console.error(`Store integrity error: body ${C} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${C}`)},R=(C,T)=>{if(C.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const I=r.get(C.annotation);if(I){const N=I.bodies.find(L=>L.id===C.id),O={...I,bodies:I.bodies.map(L=>L.id===N.id?T:L)};return r.set(I.id,O),N.id!==T.id&&(t.delete(N.id),t.set(T.id,O.id)),{oldValue:I,newValue:O,bodiesUpdated:[{oldBody:N,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${C.annotation}`)},M=(C,T,I=Dt.LOCAL)=>{const N=R(C,T);N&&n(I,{updated:[N]})},D=(C,T=Dt.LOCAL)=>{const I=C.map(N=>R({id:N.id,annotation:N.annotation},N)).filter(Boolean);n(T,{updated:I})},U=C=>{const T=r.get(C.annotation);if(T){const I={...T,target:{...T.target,...C}};return r.set(T.id,I),{oldValue:T,newValue:I,targetUpdated:{oldTarget:T.target,newTarget:C}}}else console.warn(`Attempt to update target on missing annotation: ${C.annotation}`)};return{addAnnotation:o,addBody:d,all:p,bulkAddAnnotations:m,bulkDeleteAnnotations:v,bulkDeleteBodies:E,bulkUpdateAnnotations:u,bulkUpdateBodies:D,bulkUpdateTargets:(C,T=Dt.LOCAL)=>{const I=C.map(N=>U(N)).filter(Boolean);I.length>0&&n(T,{updated:I})},bulkUpsertAnnotations:c,clear:f,deleteAnnotation:_,deleteBody:x,getAnnotation:w,getBody:A,observe:i,unobserve:s,updateAnnotation:l,updateBody:M,updateTarget:(C,T=Dt.LOCAL)=>{const I=U(C);I&&n(T,{updated:[I]})},upsertAnnotation:h}},u_=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let c_=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const d_=250,f_=(r,t)=>{const e=c_(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,y=performance.now();if(y-o>d_)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=a_(i[_],m)}o=y}n=!1};r.observe(a,{origin:Dt.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f),h=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:y}=i[s+1];h(f),c(m),p(y),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:y}=i[s];l(f),u(m),d(y),e.emit("undo",i[s]),s-=1}}}},p_=()=>{const{subscribe:r,set:t}=ma([]);return{subscribe:r,set:t}},m_=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(_,v)=>{l.has(_)?l.get(_).push(v):l.set(_,[v])},p=(_,v)=>{const g=l.get(_);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},f=(_,v,g)=>{l.has(_)&&setTimeout(()=>{l.get(_).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(A=>e.serialize(A)):e.serialize(v),w=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,w)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!Vr(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:x})=>x===g.id)||g)};n.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 g=o.getAnnotation(v.id);g&&!Vr(g,v)&&f("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(_.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!Vr(E,x)&&f("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),..._.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(_=>{!u&&_?f("mouseEnterAnnotation",o.getAnnotation(_)):u&&!_?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&_&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(_))),u=_}),a==null||a.subscribe(_=>f("viewportIntersect",_.map(v=>o.getAnnotation(v)))),o.observe(_=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=_.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(g||[]).forEach(x=>f("deleteAnnotation",x)),(_.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const w=h.find(A=>A.id===x.id)||x;h=h.map(A=>A.id===x.id?E:A),f("updateAnnotation",E,w)})},{origin:Dt.LOCAL}),o.observe(_=>{if(h){const v=new Set(h.map(x=>x.id)),g=(_.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(E=>E.id===x.id)||x))}},{origin:Dt.REMOTE});const y=_=>v=>{const{updated:g}=v;_?(g||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",y(!0)),t.on("redo",y(!1)),{on:d,off:p,emit:f}},g_=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),y_=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,Dt.REMOTE):console.error(g)}else i.addAnnotation(ya(_),Dt.REMOTE)},o=()=>s.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(),u=()=>{var _;const v=(((_=s.selected)==null?void 0:_.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(_,v=!0)=>fetch(_).then(g=>g.json()).then(g=>(p(g,v),g)),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),_}},p=(_,v=!0)=>{if(e){const g=e.parseAll||g_(e),{parsed:x,failed:E}=g(_);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,Dt.REMOTE)}else i.bulkAddAnnotations(_.map(ya),v,Dt.REMOTE)},f=(_,v)=>{_?s.setSelected(_,v):s.clear()},m=_=>{s.clear(),s.setUserSelectAction(_)},y=_=>{if(e){const v=e.parse(_).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(_.id);return i.updateAnnotation(ya(_)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:y}},__=(r,t,e)=>typeof t=="function"?t(r,e):t,v_=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},x_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let b_=r=>crypto.getRandomValues(new Uint8Array(r)),E_=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},T_=(r,t=21)=>E_(r,t|0,b_),w_=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=x_[e[r]&63];return t};const A_=()=>({isGuest:!0,id:T_("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),S_=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},Nu=r=>r?typeof r=="object"?{...r}:r:void 0,C_=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...u}=e;return{id:i||`temp-${S_(e)}`,annotation:t,type:s,purpose:n,value:o,creator:Nu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),I_=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});w_();const R_=(r,t={strict:!0,invertY:!1})=>({parse:e=>M_(e,t),serialize:e=>O_(e,r,t)}),M_=(r,t={strict:!0,invertY:!1})=>{const e=r.id||Cu(),{creator:i,created:s,modified:n,body:o,...a}=r,l=C_(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,c=typeof u=="string"||(u==null?void 0:u.type)==="FragmentSelector"?fy(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?Hy(u):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:Nu(i),updated:n?new Date(n):void 0,...typeof d=="string"?{}:d,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},O_=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==Et.RECTANGLE?py(i.geometry):Vy(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:I_(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u},_a=(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))},Hi=[];function P_(r,t=Pt){let e;const i=new Set;function s(a){if(le(r,a)&&(r=a,e)){const l=!Hi.length;for(const h of i)h[1](),Hi.push(h,r);if(l){for(let h=0;h<Hi.length;h+=2)Hi[h][0](Hi[h+1]);Hi.length=0}}}function n(a){s(a(r))}function o(a,l=Pt){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Pt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const N_=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},L_=(r,t)=>{N_(r,t);const{subscribe:e,set:i}=P_(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},Is=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},An=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},va=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,D_=r=>({}),Lu=r=>({grab:r[0]});function B_(r){let t,e,i,s;const n=r[8].default,o=qg(n,r,r[7],Lu);return{c(){t=tt("g"),o&&o.c(),b(t,"class","a9s-annotation selected")},m(a,l){rt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Lt(t,"pointerup",r[2]),Lt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Zg(o,n,a,a[7],e?Kg(n,a[7],l,D_):Qg(a[7]),Lu)},i(a){e||(ct(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&et(t),o&&o.d(a),i=!1,Ve(s)}}}function F_(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=ci();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const p=y=>_=>{if(u=y,h){const{left:v,top:g}=h.getBoundingClientRect(),x=_.clientX-v,E=_.clientY-g;c=l.elementToImage(x,E)}else{const{offsetX:v,offsetY:g}=_;c=l.elementToImage(v,g)}d=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=y=>{if(u){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),g=[_-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=y=>{y.target.releasePointerCapture(y.pointerId),u=void 0,d=o,n("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,s=y.$$scope)},[p,f,m,o,a,l,h,s,i]}class xa extends Oe{constructor(t){super(),Me(this,t,F_,B_,le,{shape:3,editor:4,transform:5,svgEl:6})}}function U_(r){let t,e,i,s,n,o,a,l,h=r[3]&&Du(r);return{c(){t=tt("g"),e=tt("circle"),h&&h.c(),s=tt("circle"),b(e,"class","a9s-handle-buffer svelte-19vpcvx"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[4]+6/r[2]),b(s,"class",n=_n(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-19vpcvx"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[4]),b(t,"class",o=_n(`a9s-handle ${r[7].class||""}`.trim())+" svelte-19vpcvx")},m(u,c){rt(u,t,c),St(t,e),h&&h.m(t,null),St(t,s),a||(l=[Lt(e,"pointerenter",r[8]),Lt(e,"pointerleave",r[9]),Lt(e,"pointerdown",r[10]),Lt(e,"pointerdown",r[5]),Lt(e,"pointerup",r[11]),Lt(e,"pointerup",r[6])],a=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&20&&i!==(i=u[4]+6/u[2])&&b(e,"r",i),u[3]?h?h.p(u,c):(h=Du(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=_n(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-19vpcvx")&&b(s,"class",n),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&16&&b(s,"r",u[4]),c&128&&o!==(o=_n(`a9s-handle ${u[7].class||""}`.trim())+" svelte-19vpcvx")&&b(t,"class",o)},d(u){u&&et(t),h&&h.d(),a=!1,Ve(l)}}}function k_(r){let t,e;return{c(){t=tt("circle"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",e=2*r[4])},m(i,s){rt(i,t,s)},p(i,s){s&1&&b(t,"cx",i[0]),s&2&&b(t,"cy",i[1]),s&16&&e!==(e=2*i[4])&&b(t,"r",e)},d(i){i&&et(t)}}}function Du(r){let t,e;return{c(){t=tt("circle"),b(t,"class","a9s-handle-selected svelte-19vpcvx"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",e=r[4]+6/r[2])},m(i,s){rt(i,t,s)},p(i,s){s&1&&b(t,"cx",i[0]),s&2&&b(t,"cy",i[1]),s&20&&e!==(e=i[4]+6/i[2])&&b(t,"r",e)},d(i){i&&et(t)}}}function G_(r){let t;function e(s,n){return va?k_:U_}let i=e()(r);return{c(){i.c(),t=Le()},m(s,n){i.m(s,n),rt(s,t,n)},p(s,[n]){i.p(s,n)},i:Pt,o:Pt,d(s){s&&et(t),i.d(s)}}}function H_(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t;const l=f=>{f.pointerType},h=()=>!1;function u(f){De.call(this,r,f)}function c(f){De.call(this,r,f)}function d(f){De.call(this,r,f)}function p(f){De.call(this,r,f)}return r.$$set=f=>{e(7,t=ea(ea({},t),nu(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"selected"in f&&e(3,a=f.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(4,i=4/o)},t=nu(t),[s,n,o,a,i,l,h,t,u,c,d,p]}class $i extends Oe{constructor(t){super(),Me(this,t,H_,G_,le,{x:0,y:1,scale:2,selected:3})}}function $_(r){let t,e,i,s,n,o,a;return{c(){t=tt("g"),e=tt("circle"),s=tt("circle"),n=tt("circle"),b(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=1.75*r[2]),b(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[2]),b(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),b(n,"cx",r[0]),b(n,"cy",r[1]),b(n,"r",r[2]),b(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){rt(l,t,h),St(t,e),St(t,s),St(t,n),o||(a=[Lt(e,"pointerdown",r[5]),Lt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&b(e,"cx",l[0]),h&2&&b(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&b(e,"r",i),h&1&&b(s,"cx",l[0]),h&2&&b(s,"cy",l[1]),h&4&&b(s,"r",l[2]),h&1&&b(n,"cx",l[0]),h&2&&b(n,"cy",l[1]),h&4&&b(n,"r",l[2])},d(l){l&&et(t),o=!1,Ve(a)}}}function V_(r){let t;return{c(){t=tt("circle"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",r[2])},m(e,i){rt(e,t,i)},p(e,i){i&1&&b(t,"cx",e[0]),i&2&&b(t,"cy",e[1]),i&4&&b(t,"r",e[2])},d(e){e&&et(t)}}}function X_(r){let t;function e(s,n){return va?V_:$_}let i=e()(r);return{c(){i.c(),t=Le()},m(s,n){i.m(s,n),rt(s,t,n)},p(s,[n]){i.p(s,n)},i:Pt,o:Pt,d(s){s&&et(t),i.d(s)}}}function Y_(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){De.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class W_ extends Oe{constructor(t){super(),Me(this,t,Y_,X_,le,{x:0,y:1,scale:4})}}function ba(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Bu(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Ea(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Ta(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Fu(r){let t,e,i,s;return{c(){t=tt("circle"),b(t,"cx",e=r[30][0]),b(t,"cy",i=r[30][1]),b(t,"r",s=Rs/r[3]),b(t,"class","svelte-1h2slbm")},m(n,o){rt(n,t,o)},p(n,o){o[0]&2176&&e!==(e=n[30][0])&&b(t,"cx",e),o[0]&2176&&i!==(i=n[30][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Rs/n[3])&&b(t,"r",s)},d(n){n&&et(t)}}}function Uu(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=tt("mask"),e=tt("rect"),a=tt("circle"),b(e,"x",i=r[10].x),b(e,"y",s=r[10].y),b(e,"width",n=r[10].w),b(e,"height",o=r[10].h),b(e,"class","svelte-1h2slbm"),b(a,"cx",l=r[30][0]),b(a,"cy",h=r[30][1]),b(a,"r",u=Rs/r[3]),b(a,"class","svelte-1h2slbm"),b(t,"id",`${r[20]}-inner`),b(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){rt(c,t,d),St(t,e),St(t,a)},p(c,d){d[0]&1024&&i!==(i=c[10].x)&&b(e,"x",i),d[0]&1024&&s!==(s=c[10].y)&&b(e,"y",s),d[0]&1024&&n!==(n=c[10].w)&&b(e,"width",n),d[0]&1024&&o!==(o=c[10].h)&&b(e,"height",o),d[0]&2176&&l!==(l=c[30][0])&&b(a,"cx",l),d[0]&2176&&h!==(h=c[30][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Rs/c[3])&&b(a,"r",u)},d(c){c&&et(t)}}}function ku(r){let t,e;return t=new $i({props:{class:"a9s-corner-handle",x:r[30][0],y:r[30][1],scale:r[3],selected:r[9].includes(r[32])}}),t.$on("pointerenter",r[12]),t.$on("pointerleave",r[13]),t.$on("pointerdown",r[16]),t.$on("pointerdown",function(){zt(r[29](`HANDLE-${r[32]}`))&&r[29](`HANDLE-${r[32]}`).apply(this,arguments)}),t.$on("pointerup",r[17](r[32])),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[30][0]),s[0]&32&&(n.y=r[30][1]),s[0]&8&&(n.scale=r[3]),s[0]&512&&(n.selected=r[9].includes(r[32])),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function Gu(r){let t,e;return t=new W_({props:{x:r[30][0],y:r[30][1],scale:r[3]}}),t.$on("pointerdown",function(){zt(r[19](r[7]))&&r[19](r[7]).apply(this,arguments)}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&2176&&(n.x=r[30][0]),s[0]&2176&&(n.y=r[30][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function j_(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,E,w=r[7]!==void 0&&!r[8]&&Fu(Ta(r)),A=r[7]!==void 0&&!r[8]&&Uu(Ea(r)),R=Be(r[5].points),M=[];for(let C=0;C<R.length;C+=1)M[C]=ku(Bu(r,R,C));const D=C=>mt(M[C],1,1,()=>{M[C]=null});let U=r[7]!==void 0&&!r[8]&&Gu(ba(r));return{c(){t=tt("defs"),e=tt("mask"),i=tt("rect"),l=tt("polygon"),w&&w.c(),A&&A.c(),u=Ne(),c=tt("polygon"),p=Ne(),f=tt("polygon"),y=Ne();for(let C=0;C<M.length;C+=1)M[C].c();_=Ne(),U&&U.c(),v=Le(),b(i,"x",s=r[10].x),b(i,"y",n=r[10].y),b(i,"width",o=r[10].w),b(i,"height",a=r[10].h),b(i,"class","svelte-1h2slbm"),b(l,"points",h=r[5].points.map(Hu).join(" ")),b(l,"class","svelte-1h2slbm"),b(e,"id",`${r[20]}-outer`),b(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[20]}-outer)`),b(c,"points",d=r[5].points.map($u).join(" ")),b(f,"class","a9s-inner a9s-shape-handle"),b(f,"mask",`url(#${r[20]}-inner)`),b(f,"style",r[1]),b(f,"points",m=r[5].points.map(Vu).join(" "))},m(C,T){rt(C,t,T),St(t,e),St(e,i),St(e,l),w&&w.m(e,null),A&&A.m(t,null),rt(C,u,T),rt(C,c,T),rt(C,p,T),rt(C,f,T),r[21](f),rt(C,y,T);for(let I=0;I<M.length;I+=1)M[I]&&M[I].m(C,T);rt(C,_,T),U&&U.m(C,T),rt(C,v,T),g=!0,x||(E=[Lt(c,"pointerup",r[15]),Lt(c,"pointerdown",function(){zt(r[29]("SHAPE"))&&r[29]("SHAPE").apply(this,arguments)}),Lt(f,"pointermove",r[14]),Lt(f,"pointerup",r[15]),Lt(f,"pointerdown",function(){zt(r[29]("SHAPE"))&&r[29]("SHAPE").apply(this,arguments)})],x=!0)},p(C,T){if(r=C,(!g||T[0]&1024&&s!==(s=r[10].x))&&b(i,"x",s),(!g||T[0]&1024&&n!==(n=r[10].y))&&b(i,"y",n),(!g||T[0]&1024&&o!==(o=r[10].w))&&b(i,"width",o),(!g||T[0]&1024&&a!==(a=r[10].h))&&b(i,"height",a),(!g||T[0]&32&&h!==(h=r[5].points.map(Hu).join(" ")))&&b(l,"points",h),r[7]!==void 0&&!r[8]?w?w.p(Ta(r),T):(w=Fu(Ta(r)),w.c(),w.m(e,null)):w&&(w.d(1),w=null),r[7]!==void 0&&!r[8]?A?A.p(Ea(r),T):(A=Uu(Ea(r)),A.c(),A.m(t,null)):A&&(A.d(1),A=null),(!g||T[0]&32&&d!==(d=r[5].points.map($u).join(" ")))&&b(c,"points",d),(!g||T[0]&2)&&b(f,"style",r[1]),(!g||T[0]&32&&m!==(m=r[5].points.map(Vu).join(" ")))&&b(f,"points",m),T[0]&537080360){R=Be(r[5].points);let I;for(I=0;I<R.length;I+=1){const N=Bu(r,R,I);M[I]?(M[I].p(N,T),ct(M[I],1)):(M[I]=ku(N),M[I].c(),ct(M[I],1),M[I].m(_.parentNode,_))}for(Ie(),I=R.length;I<M.length;I+=1)D(I);Re()}r[7]!==void 0&&!r[8]?U?(U.p(ba(r),T),T[0]&384&&ct(U,1)):(U=Gu(ba(r)),U.c(),ct(U,1),U.m(v.parentNode,v)):U&&(Ie(),mt(U,1,1,()=>{U=null}),Re())},i(C){if(!g){for(let T=0;T<R.length;T+=1)ct(M[T]);ct(U),g=!0}},o(C){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)mt(M[T]);mt(U),g=!1},d(C){C&&(et(t),et(u),et(c),et(p),et(f),et(y),et(_),et(v)),w&&w.d(),A&&A.d(),r[21](null),ui(M,C),U&&U.d(C),x=!1,Ve(E)}}}function z_(r){let t,e;return t=new xa({props:{shape:r[0],transform:r[2],editor:r[18],svgEl:r[4],$$slots:{default:[j_,({grab:i})=>({29:i}),({grab:i})=>[i?536870912:0]]},$$scope:{ctx:r}}}),t.$on("change",r[22]),t.$on("grab",r[23]),t.$on("release",r[24]),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&536874986|s[1]&4&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}const q_=250,K_=1e3,Z_=12,Rs=4.5,Hu=r=>r.join(","),$u=r=>r.join(","),Vu=r=>r.join(",");function Q_(r,t,e){let i,s,n;const o=ci();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p,f=!1,m,y=[];const _=()=>e(8,f=!0),v=()=>e(8,f=!1),g=O=>{if(y.length>0){e(7,p=void 0);return}const[L,F]=h.elementToImage(O.offsetX,O.offsetY),V=Y=>Math.pow(Y[0]-L,2)+Math.pow(Y[1]-F,2),P=i.points.reduce((Y,z)=>V(z)<V(Y)?z:Y),B=s.filter(Y=>Y.visible).reduce((Y,z)=>V(z.point)<V(Y.point)?z:Y),$=Math.pow(K_/u,2);V(P)<$||V(B.point)<$?e(7,p=s.indexOf(B)):e(7,p=void 0)},x=()=>{document.activeElement!==c&&c.focus()},E=()=>{e(9,y=[]),x()},w=O=>{e(8,f=!0),O.preventDefault(),O.stopPropagation(),m=performance.now()},A=O=>L=>{if(!m||performance.now()-m>q_)return;const F=y.includes(O);L.metaKey||L.ctrlKey||L.shiftKey?F?e(9,y=y.filter(V=>V!==O)):e(9,y=[...y,O]):F&&y.length>1?e(9,y=[O]):F?e(9,y=[]):e(9,y=[O]),x()},R=(O,L,F)=>{x();let V;const P=O.geometry;y.length>1?V=P.points.map(([$,Y],z)=>y.includes(z)?[$+F[0],Y+F[1]]:[$,Y]):L==="SHAPE"?V=P.points.map(([$,Y])=>[$+F[0],Y+F[1]]):V=P.points.map(([$,Y],z)=>L===`HANDLE-${z}`?[$+F[0],Y+F[1]]:[$,Y]);const B=Xe(V);return{...O,geometry:{points:V,bounds:B}}},M=O=>async L=>{L.stopPropagation();const F=[...i.points.slice(0,O+1),s[O].point,...i.points.slice(O+1)],V=Xe(F);o("change",{...a,geometry:{points:F,bounds:V}}),await ey();const P=[...document.querySelectorAll(".a9s-handle")][O+1];if(P!=null&&P.firstChild){const B=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});P.firstChild.dispatchEvent(B)}},D=()=>{if(i.points.length<4)return;const O=i.points.filter((F,V)=>!y.includes(V)),L=Xe(O);o("change",{...a,geometry:{points:O,bounds:L}}),e(9,y=[])};Bi(()=>{const O=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),D())};return c.addEventListener("pointermove",g),c.addEventListener("keydown",O),()=>{c.removeEventListener("pointermove",g),c.removeEventListener("keydown",O)}});const U=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function C(O){Cs[O?"unshift":"push"](()=>{d=O,e(6,d)})}function T(O){De.call(this,r,O)}function I(O){De.call(this,r,O)}function N(O){De.call(this,r,O)}return r.$$set=O=>{"shape"in O&&e(0,a=O.shape),"computedStyle"in O&&e(1,l=O.computedStyle),"transform"in O&&e(2,h=O.transform),"viewportScale"in O&&e(3,u=O.viewportScale),"svgEl"in O&&e(4,c=O.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(11,s=i.points.map((O,L)=>{const F=L===i.points.length-1?i.points[0]:i.points[L+1],V=(O[0]+F[0])/2,P=(O[1]+F[1])/2,B=Math.sqrt(Math.pow(F[0]-V,2)+Math.pow(F[1]-P,2))>Z_/u;return{point:[V,P],visible:B}})),r.$$.dirty[0]&40&&e(10,n=An(i.bounds,Rs/u))},[a,l,h,u,c,i,d,p,f,y,n,s,_,v,g,E,w,A,R,M,U,C,T,I,N]}class J_ extends Oe{constructor(t){super(),Me(this,t,Q_,z_,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function t0(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,E,w,A,R,M,D,U,C,T,I,N,O,L,F,V,P,B,$,Y,z,it,xt,Ct,q,wt,ft,gt,vt,It,Ot,pe,jt,J,ze,dn;return ft=new $i({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),ft.$on("pointerdown",function(){zt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new $i({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){zt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Ot=new $i({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Ot.$on("pointerdown",function(){zt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),jt=new $i({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),jt.$on("pointerdown",function(){zt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=tt("defs"),e=tt("mask"),i=tt("rect"),l=tt("rect"),p=Ne(),f=tt("rect"),g=Ne(),x=tt("rect"),M=Ne(),D=tt("rect"),I=Ne(),N=tt("rect"),V=Ne(),P=tt("rect"),z=Ne(),it=tt("rect"),wt=Ne(),Se(ft.$$.fragment),gt=Ne(),Se(vt.$$.fragment),It=Ne(),Se(Ot.$$.fragment),pe=Ne(),Se(jt.$$.fragment),b(i,"class","rect-mask-bg svelte-1njczvj"),b(i,"x",s=r[6].x),b(i,"y",n=r[6].y),b(i,"width",o=r[6].w),b(i,"height",a=r[6].h),b(l,"class","rect-mask-fg svelte-1njczvj"),b(l,"x",h=r[5].x),b(l,"y",u=r[5].y),b(l,"width",c=r[5].w),b(l,"height",d=r[5].h),b(e,"id",r[8]),b(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),b(f,"class","a9s-outer"),b(f,"mask",`url(#${r[8]})`),b(f,"x",m=r[5].x),b(f,"y",y=r[5].y),b(f,"width",_=r[5].w),b(f,"height",v=r[5].h),b(x,"class","a9s-inner a9s-shape-handle"),b(x,"style",r[1]),b(x,"x",E=r[5].x),b(x,"y",w=r[5].y),b(x,"width",A=r[5].w),b(x,"height",R=r[5].h),b(D,"class","a9s-edge-handle a9s-edge-handle-top"),b(D,"x",U=r[5].x),b(D,"y",C=r[5].y),b(D,"height",1),b(D,"width",T=r[5].w),b(N,"class","a9s-edge-handle a9s-edge-handle-right"),b(N,"x",O=r[5].x+r[5].w),b(N,"y",L=r[5].y),b(N,"height",F=r[5].h),b(N,"width",1),b(P,"class","a9s-edge-handle a9s-edge-handle-bottom"),b(P,"x",B=r[5].x),b(P,"y",$=r[5].y+r[5].h),b(P,"height",1),b(P,"width",Y=r[5].w),b(it,"class","a9s-edge-handle a9s-edge-handle-left"),b(it,"x",xt=r[5].x),b(it,"y",Ct=r[5].y),b(it,"height",q=r[5].h),b(it,"width",1)},m(W,G){rt(W,t,G),St(t,e),St(e,i),St(e,l),rt(W,p,G),rt(W,f,G),rt(W,g,G),rt(W,x,G),rt(W,M,G),rt(W,D,G),rt(W,I,G),rt(W,N,G),rt(W,V,G),rt(W,P,G),rt(W,z,G),rt(W,it,G),rt(W,wt,G),ge(ft,W,G),rt(W,gt,G),ge(vt,W,G),rt(W,It,G),ge(Ot,W,G),rt(W,pe,G),ge(jt,W,G),J=!0,ze||(dn=[Lt(f,"pointerdown",function(){zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Lt(x,"pointerdown",function(){zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Lt(D,"pointerdown",function(){zt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Lt(N,"pointerdown",function(){zt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Lt(P,"pointerdown",function(){zt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Lt(it,"pointerdown",function(){zt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],ze=!0)},p(W,G){r=W,(!J||G&64&&s!==(s=r[6].x))&&b(i,"x",s),(!J||G&64&&n!==(n=r[6].y))&&b(i,"y",n),(!J||G&64&&o!==(o=r[6].w))&&b(i,"width",o),(!J||G&64&&a!==(a=r[6].h))&&b(i,"height",a),(!J||G&32&&h!==(h=r[5].x))&&b(l,"x",h),(!J||G&32&&u!==(u=r[5].y))&&b(l,"y",u),(!J||G&32&&c!==(c=r[5].w))&&b(l,"width",c),(!J||G&32&&d!==(d=r[5].h))&&b(l,"height",d),(!J||G&32&&m!==(m=r[5].x))&&b(f,"x",m),(!J||G&32&&y!==(y=r[5].y))&&b(f,"y",y),(!J||G&32&&_!==(_=r[5].w))&&b(f,"width",_),(!J||G&32&&v!==(v=r[5].h))&&b(f,"height",v),(!J||G&2)&&b(x,"style",r[1]),(!J||G&32&&E!==(E=r[5].x))&&b(x,"x",E),(!J||G&32&&w!==(w=r[5].y))&&b(x,"y",w),(!J||G&32&&A!==(A=r[5].w))&&b(x,"width",A),(!J||G&32&&R!==(R=r[5].h))&&b(x,"height",R),(!J||G&32&&U!==(U=r[5].x))&&b(D,"x",U),(!J||G&32&&C!==(C=r[5].y))&&b(D,"y",C),(!J||G&32&&T!==(T=r[5].w))&&b(D,"width",T),(!J||G&32&&O!==(O=r[5].x+r[5].w))&&b(N,"x",O),(!J||G&32&&L!==(L=r[5].y))&&b(N,"y",L),(!J||G&32&&F!==(F=r[5].h))&&b(N,"height",F),(!J||G&32&&B!==(B=r[5].x))&&b(P,"x",B),(!J||G&32&&$!==($=r[5].y+r[5].h))&&b(P,"y",$),(!J||G&32&&Y!==(Y=r[5].w))&&b(P,"width",Y),(!J||G&32&&xt!==(xt=r[5].x))&&b(it,"x",xt),(!J||G&32&&Ct!==(Ct=r[5].y))&&b(it,"y",Ct),(!J||G&32&&q!==(q=r[5].h))&&b(it,"height",q);const Dr={};G&32&&(Dr.x=r[5].x),G&32&&(Dr.y=r[5].y),G&8&&(Dr.scale=r[3]),ft.$set(Dr);const Br={};G&32&&(Br.x=r[5].x+r[5].w),G&32&&(Br.y=r[5].y),G&8&&(Br.scale=r[3]),vt.$set(Br);const Fr={};G&32&&(Fr.x=r[5].x+r[5].w),G&32&&(Fr.y=r[5].y+r[5].h),G&8&&(Fr.scale=r[3]),Ot.$set(Fr);const Ur={};G&32&&(Ur.x=r[5].x),G&32&&(Ur.y=r[5].y+r[5].h),G&8&&(Ur.scale=r[3]),jt.$set(Ur)},i(W){J||(ct(ft.$$.fragment,W),ct(vt.$$.fragment,W),ct(Ot.$$.fragment,W),ct(jt.$$.fragment,W),J=!0)},o(W){mt(ft.$$.fragment,W),mt(vt.$$.fragment,W),mt(Ot.$$.fragment,W),mt(jt.$$.fragment,W),J=!1},d(W){W&&(et(t),et(p),et(f),et(g),et(x),et(M),et(D),et(I),et(N),et(V),et(P),et(z),et(it),et(wt),et(gt),et(It),et(pe)),ye(ft,W),ye(vt,W),ye(Ot,W),ye(jt,W),ze=!1,Ve(dn)}}}function e0(r){let t,e;return t=new xa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[t0,({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(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function r0(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,y,_)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,w]=[v.maxX,v.maxY];const[A,R]=_;if(y==="SHAPE")g+=A,E+=A,x+=R,w+=R;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{w+=R;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=A;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=A;break}}}const M=Math.min(g,E),D=Math.min(x,w),U=Math.abs(E-g),C=Math.abs(w-x);return{...m,geometry:{x:M,y:D,w:U,h:C,bounds:{minX:M,minY:D,maxX:M+U,maxY:D+C}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){De.call(this,r,m)}function p(m){De.call(this,r,m)}function f(m){De.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=An(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class i0 extends Oe{constructor(t){super(),Me(this,t,r0,e0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}function Xu(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function Yu(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function Wu(r,t,e){const i=r.slice();return i[19]=t[e],i[21]=e,i}function ju(r){let t,e;return t=new $i({props:{class:"a9s-corner-handle",x:r[19][0],y:r[19][1],scale:r[3]}}),t.$on("pointerdown",function(){zt(r[12](`HANDLE-${r[15]}-${r[18]}-${r[21]}`))&&r[12](`HANDLE-${r[15]}-${r[18]}-${r[21]}`).apply(this,arguments)}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){r=i;const n={};s&32&&(n.x=r[19][0]),s&32&&(n.y=r[19][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function zu(r){let t,e,i=Be(r[16].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=ju(Wu(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Le()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);rt(o,t,a),e=!0},p(o,a){if(a&4136){i=Be(o[16].points);let l;for(l=0;l<i.length;l+=1){const h=Wu(o,i,l);s[l]?(s[l].p(h,a),ct(s[l],1)):(s[l]=ju(h),s[l].c(),ct(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ct(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),ui(s,o)}}}function qu(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v=Be(r[13].rings),g=[];for(let E=0;E<v.length;E+=1)g[E]=zu(Yu(r,v,E));const x=E=>mt(g[E],1,1,()=>{g[E]=null});return{c(){t=tt("g"),e=tt("defs"),i=tt("mask"),s=tt("rect"),h=tt("path"),c=tt("path"),p=tt("path");for(let E=0;E<g.length;E+=1)g[E].c();b(s,"x",n=r[6].x),b(s,"y",o=r[6].y),b(s,"width",a=r[6].w),b(s,"height",l=r[6].h),b(s,"class","svelte-rfq8ys"),b(h,"d",u=qe(r[13])),b(h,"class","svelte-rfq8ys"),b(i,"id",`${r[8]}-${r[15]}`),b(i,"class","a9s-multipolygon-editor-mask svelte-rfq8ys"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[8]}-${r[15]})`),b(c,"fill-rule","evenodd"),b(c,"d",d=qe(r[13])),b(p,"class","a9s-inner"),b(p,"style",r[1]),b(p,"fill-rule","evenodd"),b(p,"d",f=qe(r[13]))},m(E,w){rt(E,t,w),St(t,e),St(e,i),St(i,s),St(i,h),St(t,c),St(t,p);for(let A=0;A<g.length;A+=1)g[A]&&g[A].m(t,null);m=!0,y||(_=[Lt(c,"pointerdown",function(){zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Lt(p,"pointerdown",function(){zt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)})],y=!0)},p(E,w){if(r=E,(!m||w&64&&n!==(n=r[6].x))&&b(s,"x",n),(!m||w&64&&o!==(o=r[6].y))&&b(s,"y",o),(!m||w&64&&a!==(a=r[6].w))&&b(s,"width",a),(!m||w&64&&l!==(l=r[6].h))&&b(s,"height",l),(!m||w&32&&u!==(u=qe(r[13])))&&b(h,"d",u),(!m||w&32&&d!==(d=qe(r[13])))&&b(c,"d",d),(!m||w&2)&&b(p,"style",r[1]),(!m||w&32&&f!==(f=qe(r[13])))&&b(p,"d",f),w&4136){v=Be(r[13].rings);let A;for(A=0;A<v.length;A+=1){const R=Yu(r,v,A);g[A]?(g[A].p(R,w),ct(g[A],1)):(g[A]=zu(R),g[A].c(),ct(g[A],1),g[A].m(t,null))}for(Ie(),A=v.length;A<g.length;A+=1)x(A);Re()}},i(E){if(!m){for(let w=0;w<v.length;w+=1)ct(g[w]);m=!0}},o(E){g=g.filter(Boolean);for(let w=0;w<g.length;w+=1)mt(g[w]);m=!1},d(E){E&&et(t),ui(g,E),y=!1,Ve(_)}}}function s0(r){let t,e,i=Be(r[5].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=qu(Xu(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Le()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);rt(o,t,a),e=!0},p(o,a){if(a&4458){i=Be(o[5].polygons);let l;for(l=0;l<i.length;l+=1){const h=Xu(o,i,l);s[l]?(s[l].p(h,a),ct(s[l],1)):(s[l]=qu(h),s[l].c(),ct(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ct(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),ui(s,o)}}}function n0(r){let t,e;return t=new xa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[s0,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("change",r[9]),t.$on("grab",r[10]),t.$on("release",r[11]),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&4198506&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function o0(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,y,_)=>{const v=m.geometry.polygons;let g;if(y==="SHAPE")g=v.map(x=>{const E=x.rings.map((A,R)=>({points:A.points.map((M,D)=>[M[0]+_[0],M[1]+_[1]])})),w=Xe(E[0].points);return{rings:E,bounds:w}});else{const[x,E,w,A]=y.split("-").map(R=>parseInt(R));g=v.map((R,M)=>{if(M===E){const D=R.rings.map((C,T)=>T===w?{points:C.points.map((I,N)=>N===A?[I[0]+_[0],I[1]+_[1]]:I)}:C),U=Xe(D[0].points);return{rings:D,bounds:U}}else return R})}return{...m,geometry:{polygons:g,bounds:uy(g)}}},c=`multipoly-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){De.call(this,r,m)}function p(m){De.call(this,r,m)}function f(m){De.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=An(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class a0 extends Oe{constructor(t){super(),Me(this,t,o0,n0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}const Ku=new Map([[Et.RECTANGLE,i0],[Et.POLYGON,J_],[Et.MULTIPOLYGLON,a0]]),Zu=r=>Ku.get(r.type),Qu=(r,t)=>Ku.set(r,t);function l0(r,t,e){let i;const s=ci();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return Bi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Is(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class h0 extends Oe{constructor(t){super(),Me(this,t,l0,null,le,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function u0(r,t,e){const i=ci();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return Bi(()=>{const u=n.closest("svg"),c=[],d=(p,f,m)=>{u==null||u.addEventListener(p,f,m),c.push(()=>u==null?void 0:u.removeEventListener(p,f,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",p=>i("create",p.detail)),()=>{c.forEach(p=>p()),h.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewportScale"in u&&e(4,l=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class c0 extends Oe{constructor(t){super(),Me(this,t,u0,null,le,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function Ju(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=tt("defs"),e=tt("mask"),i=tt("rect"),l=tt("rect"),h=tt("rect"),u=tt("rect"),b(i,"class","rect-mask-bg svelte-1a76qe7"),b(i,"x",s=r[1]-r[5]),b(i,"y",n=r[2]-r[5]),b(i,"width",o=r[3]+2*r[5]),b(i,"height",a=r[4]+2*r[5]),b(l,"class","rect-mask-fg svelte-1a76qe7"),b(l,"x",r[1]),b(l,"y",r[2]),b(l,"width",r[3]),b(l,"height",r[4]),b(e,"id",r[6]),b(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),b(h,"class","a9s-outer"),b(h,"mask",`url(#${r[6]})`),b(h,"x",r[1]),b(h,"y",r[2]),b(h,"width",r[3]),b(h,"height",r[4]),b(u,"class","a9s-inner"),b(u,"x",r[1]),b(u,"y",r[2]),b(u,"width",r[3]),b(u,"height",r[4])},m(c,d){rt(c,t,d),St(t,e),St(e,i),St(e,l),rt(c,h,d),rt(c,u,d)},p(c,d){d&34&&s!==(s=c[1]-c[5])&&b(i,"x",s),d&36&&n!==(n=c[2]-c[5])&&b(i,"y",n),d&40&&o!==(o=c[3]+2*c[5])&&b(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&b(i,"height",a),d&2&&b(l,"x",c[1]),d&4&&b(l,"y",c[2]),d&8&&b(l,"width",c[3]),d&16&&b(l,"height",c[4]),d&2&&b(h,"x",c[1]),d&4&&b(h,"y",c[2]),d&8&&b(h,"width",c[3]),d&16&&b(h,"height",c[4]),d&2&&b(u,"x",c[1]),d&4&&b(u,"y",c[2]),d&8&&b(u,"width",c[3]),d&16&&b(u,"height",c[4])},d(c){c&&(et(t),et(h),et(u))}}}function d0(r){let t,e=r[0]&&Ju(r);return{c(){t=tt("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=Ju(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Pt,o:Pt,d(i){i&&et(t),e&&e.d()}}}function f0(r,t,e){let i;const s=ci();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u,c,d,p,f,m;const y=E=>{const w=E;h=performance.now(),o==="drag"&&(e(0,u=a.elementToImage(w.offsetX,w.offsetY)),c=u,e(1,d=u[0]),e(2,p=u[1]),e(3,f=1),e(4,m=1))},_=E=>{const w=E;u&&(c=a.elementToImage(w.offsetX,w.offsetY),e(1,d=Math.min(c[0],u[0])),e(2,p=Math.min(c[1],u[1])),e(3,f=Math.abs(c[0]-u[0])),e(4,m=Math.abs(c[1]-u[1])))},v=E=>{const w=E,A=performance.now()-h;if(o==="click"){if(A>300)return;u?g():(e(0,u=a.elementToImage(w.offsetX,w.offsetY)),c=u,e(1,d=u[0]),e(2,p=u[1]),e(3,f=1),e(4,m=1))}else u&&(A>300||f*m>100?(w.stopPropagation(),g()):(e(0,u=void 0),c=void 0))},g=()=>{if(f*m>15){const E={type:Et.RECTANGLE,geometry:{bounds:{minX:d,minY:p,maxX:d+f,maxY:p+m},x:d,y:p,w:f,h:m}};s("create",E)}e(0,u=void 0),c=void 0};Bi(()=>{n("pointerdown",y),n("pointermove",_),n("pointerup",v,!0)});const x=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=E=>{"addEventListener"in E&&e(7,n=E.addEventListener),"drawingMode"in E&&e(8,o=E.drawingMode),"transform"in E&&e(9,a=E.transform),"viewportScale"in E&&e(10,l=E.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[u,d,p,f,m,i,x,n,o,a,l]}class p0 extends Oe{constructor(t){super(),Me(this,t,f0,d0,le,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function wa(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function tc(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=r[1]&&ec(r);return{c(){t=tt("defs"),e=tt("mask"),i=tt("rect"),l=tt("polygon"),u=tt("polygon"),d=tt("polygon"),m&&m.c(),f=Le(),b(i,"x",s=r[3].x),b(i,"y",n=r[3].y),b(i,"width",o=r[3].w),b(i,"height",a=r[3].h),b(i,"class","svelte-18wrg3t"),b(l,"points",h=r[19]),b(l,"class","svelte-18wrg3t"),b(e,"id",r[5]),b(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),b(u,"class","a9s-outer"),b(u,"mask",`url(#${r[5]})`),b(u,"points",c=r[19]),b(d,"class","a9s-inner"),b(d,"points",p=r[19])},m(y,_){rt(y,t,_),St(t,e),St(e,i),St(e,l),rt(y,u,_),rt(y,d,_),m&&m.m(y,_),rt(y,f,_)},p(y,_){_&8&&s!==(s=y[3].x)&&b(i,"x",s),_&8&&n!==(n=y[3].y)&&b(i,"y",n),_&8&&o!==(o=y[3].w)&&b(i,"width",o),_&8&&a!==(a=y[3].h)&&b(i,"height",a),_&4&&h!==(h=y[19])&&b(l,"points",h),_&4&&c!==(c=y[19])&&b(u,"points",c),_&4&&p!==(p=y[19])&&b(d,"points",p),y[1]?m?m.p(y,_):(m=ec(y),m.c(),m.m(f.parentNode,f)):m&&(m.d(1),m=null)},d(y){y&&(et(t),et(u),et(d),et(f)),m&&m.d(y)}}}function ec(r){let t,e,i;return{c(){t=tt("circle"),b(t,"class","a9s-handle svelte-18wrg3t"),b(t,"cx",e=r[0][0][0]),b(t,"cy",i=r[0][0][1]),b(t,"r",r[4])},m(s,n){rt(s,t,n)},p(s,n){n&1&&e!==(e=s[0][0][0])&&b(t,"cx",e),n&1&&i!==(i=s[0][0][1])&&b(t,"cy",i),n&16&&b(t,"r",s[4])},d(s){s&&et(t)}}}function m0(r){let t,e=r[3]&&tc(wa(r));return{c(){t=tt("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[3]?e?e.p(wa(i),s):(e=tc(wa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Pt,o:Pt,d(i){i&&et(t),e&&e.d()}}}const g0=20,y0=1500;function _0(r,t,e){let i,s,n;const o=ci();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:u=1}=t,c,d=[],p,f,m=!1;const y=w=>{const A=w,{timeStamp:R,offsetX:M,offsetY:D}=A;if(c={timeStamp:R,offsetX:M,offsetY:D},l==="drag"&&d.length===0){const U=h.elementToImage(A.offsetX,A.offsetY);d.push(U),e(10,p=U)}},_=w=>{const A=w;if(f&&clearTimeout(f),d.length>0){if(e(10,p=h.elementToImage(A.offsetX,A.offsetY)),d.length>2){const R=_a(p,d[0])*u;e(1,m=R<g0)}A.pointerType==="touch"&&(f=setTimeout(()=>{g()},y0))}},v=w=>{const A=w;if(f&&clearTimeout(f),l==="click"){const R=A.timeStamp-c.timeStamp,M=_a([c.offsetX,c.offsetY],[A.offsetX,A.offsetY]);if(R>300||M>15)return;if(m)x();else if(d.length===0){const D=h.elementToImage(A.offsetX,A.offsetY);d.push(D),e(10,p=D)}else d.push(p)}else{if(d.length===1&&_a(d[0],p)<=4){e(0,d=[]),e(10,p=void 0);return}A.stopImmediatePropagation(),m?x():d.push(p)}},g=()=>{if(!p)return;const w=d.slice(0,-1);if(w.length<3)return;const A={type:Et.POLYGON,geometry:{bounds:Xe(d),points:w}};aa(A)>4&&(e(0,d=[]),e(10,p=void 0),o("create",A))},x=()=>{const w={type:Et.POLYGON,geometry:{bounds:Xe(d),points:[...d]}};e(0,d=[]),e(10,p=void 0),o("create",w)};Bi(()=>{a("pointerdown",y,!0),a("pointermove",_),a("pointerup",v,!0),a("dblclick",g,!0)});const E=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=w=>{"addEventListener"in w&&e(6,a=w.addEventListener),"drawingMode"in w&&e(7,l=w.drawingMode),"transform"in w&&e(8,h=w.transform),"viewportScale"in w&&e(9,u=w.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/u),r.$$.dirty&1027&&e(2,s=p?m?d:[...d,p]:[]),r.$$.dirty&516&&e(3,n=s.length>0?An(Xe(s),2/u):void 0)},[d,m,s,n,i,E,a,l,h,u,p]}class v0 extends Oe{constructor(t){super(),Me(this,t,_0,m0,le,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const Aa=new Map([["rectangle",{tool:p0}],["polygon",{tool:v0}]]),Sn=()=>[...Aa.keys()],Cn=r=>Aa.get(r),rc=(r,t,e={})=>Aa.set(r,{tool:t,opts:e});function x0(r){let t,e,i,s,n;return{c(){t=tt("g"),e=tt("ellipse"),s=tt("ellipse"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"cx",r[2]),b(e,"cy",r[3]),b(e,"rx",r[4]),b(e,"ry",r[5]),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"cx",r[2]),b(s,"cy",r[3]),b(s,"rx",r[4]),b(s,"ry",r[5]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),St(t,e),St(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&et(t)}}}function b0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,o=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Is(s,o))},[s,i,a,l,h,u,n,o]}class E0 extends Oe{constructor(t){super(),Me(this,t,b0,x0,le,{annotation:0,geom:6,style:7})}}function ic(r,t,e){const i=r.slice();return i[5]=t[e],i}function sc(r){let t,e,i;return{c(){t=tt("path"),i=tt("path"),b(t,"class","a9s-outer"),b(t,"style",e=r[1]?"display:none;":void 0),b(t,"fill-rule","evenodd"),b(t,"d",qe(r[5])),b(i,"class","a9s-inner"),b(i,"style",r[1]),b(i,"fill-rule","evenodd"),b(i,"d",qe(r[5]))},m(s,n){rt(s,t,n),rt(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&b(t,"style",e),n&2&&b(i,"style",s[1])},d(s){s&&(et(t),et(i))}}}function T0(r){let t,e,i=Be(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=sc(ic(r,i,n));return{c(){t=tt("g");for(let n=0;n<s.length;n+=1)s[n].c();b(t,"class","a9s-annotation"),b(t,"data-id",e=r[0].id)},m(n,o){rt(n,t,o);for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(t,null)},p(n,[o]){if(o&6){i=Be(n[2]);let a;for(a=0;a<i.length;a+=1){const l=ic(n,i,a);s[a]?s[a].p(l,o):(s[a]=sc(l),s[a].c(),s[a].m(t,null))}for(;a<s.length;a+=1)s[a].d(1);s.length=i.length}o&1&&e!==(e=n[0].id)&&b(t,"data-id",e)},i:Pt,o:Pt,d(n){n&&et(t),ui(s,n)}}}function w0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{polygons:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Is(s,o))},[s,i,a,n,o]}class A0 extends Oe{constructor(t){super(),Me(this,t,w0,T0,le,{annotation:0,geom:3,style:4})}}function S0(r){let t,e,i,s,n;return{c(){t=tt("g"),e=tt("polygon"),s=tt("polygon"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"points",r[2].map(C0).join(" ")),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"points",r[2].map(I0).join(" ")),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),St(t,e),St(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&et(t)}}}const C0=r=>r.join(","),I0=r=>r.join(",");function R0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Is(s,o))},[s,i,a,n,o]}class M0 extends Oe{constructor(t){super(),Me(this,t,R0,S0,le,{annotation:0,geom:3,style:4})}}function O0(r){let t,e,i,s,n;return{c(){t=tt("g"),e=tt("rect"),s=tt("rect"),b(e,"class","a9s-outer"),b(e,"style",i=r[5]?"display:none;":void 0),b(e,"x",r[4]),b(e,"y",r[3]),b(e,"width",r[2]),b(e,"height",r[1]),b(s,"class","a9s-inner"),b(s,"style",r[5]),b(s,"x",r[4]),b(s,"y",r[3]),b(s,"width",r[2]),b(s,"height",r[1]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),St(t,e),St(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&b(e,"style",i),a&16&&b(e,"x",o[4]),a&8&&b(e,"y",o[3]),a&4&&b(e,"width",o[2]),a&2&&b(e,"height",o[1]),a&32&&b(s,"style",o[5]),a&16&&b(s,"x",o[4]),a&8&&b(s,"y",o[3]),a&4&&b(s,"width",o[2]),a&2&&b(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Pt,o:Pt,d(o){o&&et(t)}}}function P0(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Is(l,u)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,u]}class N0 extends Oe{constructor(t){super(),Me(this,t,P0,O0,le,{annotation:0,geom:6,style:7})}}const L0=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),D0=250,B0=(r,t)=>{const e=ci();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<D0){const{x:n,y:o}=nc(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},nc=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function oc(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function ac(r,t,e){const i=r.slice();return i[43]=t[e],i}function Sa(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function lc(r){let t=r[43],e,i,s=hc(r);return{c(){s.c(),e=Le()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&65536&&le(t,t=n[43])?(Ie(),mt(s,1,1,Pt),Re(),s=hc(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function F0(r){let t,e;return t=new A0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function U0(r){let t,e;return t=new M0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function k0(r){let t,e;return t=new N0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function G0(r){var t;let e,i;return e=new E0({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){Se(e.$$.fragment)},m(s,n){ge(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&65536&&(a.annotation=s[43]),n[0]&65536&&(a.geom=(o=s[46])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ct(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){ye(e,s)}}}function hc(r){let t,e,i,s;const n=[G0,k0,U0,F0],o=[];function a(l,h){var u,c,d,p;return((u=l[46])==null?void 0:u.type)===Et.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===Et.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===Et.POLYGON?2:((p=l[46])==null?void 0:p.type)===Et.MULTIPOLYGLON?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Le()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),mt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ct(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ct(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function uc(r){let t=Ke(r[43])&&!r[9](r[43]),e,i,s=t&&lc(Sa(r));return{c(){s&&s.c(),e=Le()},m(n,o){s&&s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=Ke(n[43])&&!n[9](n[43])),t?s?(s.p(Sa(n),o),o[0]&66048&&ct(s,1)):(s=lc(Sa(n)),s.c(),ct(s,1),s.m(e.parentNode,e)):s&&(Ie(),mt(s,1,1,()=>{s=null}),Re())},i(n){i||(ct(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s&&s.d(n)}}}function cc(r){let t,e,i,s;const n=[$0,H0],o=[];function a(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Le()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),mt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ct(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ct(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&et(i),~t&&o[t].d(l)}}}function H0(r){let t=`${r[2]}-${r[5]}`,e,i,s=dc(r);return{c(){s.c(),e=Le()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&36&&le(t,t=`${n[2]}-${n[5]}`)?(Ie(),mt(s,1,1,Pt),Re(),s=dc(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function $0(r){let t,e,i=Be(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=mc(oc(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Le()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);rt(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=Be(o[8]);let l;for(l=0;l<i.length;l+=1){const h=oc(o,i,l);s[l]?(s[l].p(h,a),ct(s[l],1)):(s[l]=mc(h),s[l].c(),ct(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ct(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&et(t),ui(s,o)}}}function dc(r){let t,e;return t=new c0({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function fc(r){let t=r[39].id,e,i,s=pc(r);return{c(){s.c(),e=Le()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&256&&le(t,t=n[39].id)?(Ie(),mt(s,1,1,Pt),Re(),s=pc(n),s.c(),ct(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ct(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&et(e),s.d(n)}}}function pc(r){let t,e;return t=new h0({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){zt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){Se(t.$$.fragment)},m(i,s){ge(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(ct(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){ye(t,i)}}}function mc(r){let t,e,i=r[40]&&fc(r);return{c(){i&&i.c(),t=Le()},m(s,n){i&&i.m(s,n),rt(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&ct(i,1)):(i=fc(s),i.c(),ct(i,1),i.m(t.parentNode,t)):i&&(Ie(),mt(i,1,1,()=>{i=null}),Re())},i(s){e||(ct(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&et(t),i&&i.d(s)}}}function V0(r){let t,e,i,s,n,o,a=Be(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=uc(ac(r,a,c));const h=c=>mt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&cc(r);return{c(){t=tt("svg"),e=tt("g");for(let c=0;c<l.length;c+=1)l[c].c();i=tt("g"),u&&u.c(),b(i,"class","drawing"),b(t,"role","application"),b(t,"tabindex",0),b(t,"class","a9s-annotationlayer"),Gr(t,"drawing",r[14]),Gr(t,"editing",r[8]),Gr(t,"hidden",!r[3]),Gr(t,"hover",r[15])},m(c,d){rt(c,t,d),St(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);St(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Lt(t,"pointerup",function(){zt(r[10])&&r[10].apply(this,arguments)}),Lt(t,"pointerdown",function(){zt(r[11])&&r[11].apply(this,arguments)}),Lt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=Be(r[16].filter(r[34]));let p;for(p=0;p<a.length;p+=1){const f=ac(r,a,p);l[p]?(l[p].p(f,d),ct(l[p],1)):(l[p]=uc(f),l[p].c(),ct(l[p],1),l[p].m(e,null))}for(Ie(),p=a.length;p<l.length;p+=1)h(p);Re()}r[6]?u?(u.p(r,d),d[0]&64&&ct(u,1)):(u=cc(r),u.c(),ct(u,1),u.m(i,null)):u&&(Ie(),mt(u,1,1,()=>{u=null}),Re()),(!s||d[0]&16384)&&Gr(t,"drawing",r[14]),(!s||d[0]&256)&&Gr(t,"editing",r[8]),(!s||d[0]&8)&&Gr(t,"hidden",!r[3]),(!s||d[0]&32768)&&Gr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)ct(l[d]);ct(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(u),s=!1},d(c){c&&et(t),ui(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,Ve(o)}}}function X0(r,t,e){let i,s,n,o,a,l,h,u,c,d,p,f=Pt,m=()=>(f(),f=iu(I,q=>e(17,p=q)),I);r.$$.on_destroy.push(()=>f());let{drawingEnabled:y}=t,{image:_}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:E=Sn()[0]}=t,{user:w}=t,{visible:A=!0}=t,R=0;const M=()=>e(5,R+=1),D=()=>E,U=()=>y;let C,T,I;Bi(()=>m(e(7,I=L_(_,T))));const{hover:N,selection:O,store:L}=g;ra(r,N,q=>e(15,u=q)),ra(r,O,q=>e(33,c=q)),ra(r,L,q=>e(16,d=q));let F,V;const P=q=>{F&&L.unobserve(F);const wt=q.filter(({editable:ft})=>ft).map(({id:ft})=>ft);wt.length>0?(e(8,V=wt.map(ft=>L.getAnnotation(ft)).filter(ft=>ft&&Ke(ft))),F=ft=>{const{updated:gt}=ft.changes;e(8,V=gt==null?void 0:gt.map(vt=>vt.newValue))},L.observe(F,{annotations:wt})):e(8,V=void 0)},B=q=>{const wt=Cu(),ft={id:wt,bodies:[],target:{annotation:wt,selector:q.detail,creator:w,created:new Date}};L.addAnnotation(ft),O.setSelected(ft.id)},$=q=>wt=>{var ft;const{target:gt}=q,vt=10*60*1e3,It=((ft=gt.creator)==null?void 0:ft.id)!==w.id||!gt.created||new Date().getTime()-gt.created.getTime()>vt;L.updateTarget({...gt,selector:wt.detail,created:It?gt.created:new Date,updated:It?new Date:void 0,updatedBy:It?w:void 0})},Y=q=>{const{x:wt,y:ft}=nc(q,T),gt=L.getAt(wt,ft);gt?u!==gt.id&&N.set(gt.id):N.set(void 0)},z=q=>Zu(q),it=q=>Ke(q);function xt(q){Cs[q?"unshift":"push"](()=>{C=q,e(6,C)})}function Ct(q){Cs[q?"unshift":"push"](()=>{T=q,e(4,T)})}return r.$$set=q=>{"drawingEnabled"in q&&e(0,y=q.drawingEnabled),"image"in q&&e(25,_=q.image),"preferredDrawingMode"in q&&e(26,v=q.preferredDrawingMode),"state"in q&&e(27,g=q.state),"style"in q&&e(1,x=q.style),"toolName"in q&&e(2,E=q.toolName),"user"in q&&e(28,w=q.user),"visible"in q&&e(3,A=q.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=Cn(E)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,E))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=L0(T)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=B0(T,L),a,(e(10,l),e(4,T))),r.$$.dirty[1]&4&&e(9,h=q=>c.selected.find(wt=>wt.id===q.id&&wt.editable)),r.$$.dirty[1]&4&&P(c.selected)},[y,x,E,A,T,R,C,I,V,h,l,a,o,n,i,u,d,p,N,O,L,B,$,Y,z,_,v,g,w,M,D,U,s,c,it,xt,Ct]}class Y0 extends Oe{constructor(t){super(),Me(this,t,X0,V0,le,{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 gc(r,t,e=0,i=r.length-1,s=W0){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),p=Math.max(e,Math.floor(t-h*c/l+d)),f=Math.min(i,Math.floor(t+(l-h)*c/l+d));gc(r,t,p,f,s)}const n=r[t];let o=e,a=i;for(Ms(r,e,t),s(r[i],n)>0&&Ms(r,e,i);o<a;){for(Ms(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?Ms(r,e,a):(a++,Ms(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Ms(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function W0(r,t){return r<t?-1:r>t?1:0}class j0{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(!Rn(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Rn(t,l)&&(e.leaf?i.push(a):Ia(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Rn(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Rn(t,o)){if(e.leaf||Ia(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Xi([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const u=z0(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Ia(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=Xi(t.slice(e,i+1)),Vi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=Xi([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));yc(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);yc(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const p=Math.min(d+l-1,c);a.children.push(this._build(t,d,p,s-1))}}return Vi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],u=Ca(h),c=Z0(t,h)-u;c<o?(o=c,n=u<n?u:n,a=h):c===o&&u<n&&(n=u,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),Ps(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=Xi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Vi(i,this.toBBox),Vi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Xi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Vi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Os(t,0,a,this.toBBox),h=Os(t,a,i,this.toBBox),u=Q0(l,h),c=Ca(l)+Ca(h);u<n?(n=u,s=a,o=c<o?c:o):u===n&&c<o&&(o=c,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:q0,n=t.leaf?this.compareMinY:K0,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Os(t,0,e,n),a=Os(t,i-e,i,n);let l=In(o)+In(a);for(let h=e;h<i-e;h++){const u=t.children[h];Ps(o,t.leaf?n(u):u),l+=In(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];Ps(a,t.leaf?n(u):u),l+=In(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Ps(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Vi(t[e],this.toBBox)}}function z0(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 Vi(r,t){Os(r,0,r.children.length,t,r)}function Os(r,t,e,i,s){s||(s=Xi(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];Ps(s,r.leaf?i(o):o)}return s}function Ps(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 q0(r,t){return r.minX-t.minX}function K0(r,t){return r.minY-t.minY}function Ca(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function In(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Z0(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 Q0(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Ia(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Rn(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Xi(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function yc(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;gc(r,o,t,e,s),n.push(t,o,o,e)}}const J0=()=>{const r=new j0,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!bn(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),t.set(o.annotation,c)},n=o=>{if(!bn(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)=>{const h=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(u=>u.target).filter(u=>u.selector.type===Et.RECTANGLE||oy(u.selector,o,a));return h.length>0?(h.sort((u,c)=>aa(u.selector)-aa(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(bn(u)){const{minX:c,minY:d,maxX:p,maxY:f}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:p,maxY:f,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},_c=r=>{const t=h_(),e=J0(),i=Ky(t,r.userSelectAction,r.adapter),s=qy(t),n=p_();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)=>{const h=e.getAt(o,a,l);if(l)return h.map(u=>t.getAnnotation(u.annotation)).filter(Boolean).filter(l)[0];{const u=h[0];return u?t.getAnnotation(u.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},tv=r=>{const t=_c(r);return{...t,store:u_(t.store)}},ev=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},vc=r=>{const t=ev(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},xc=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?vc(r):e),bc=(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}),Ec=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Tc=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Ec?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Ec?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},rv=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=bc(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:Ru.EDIT,theme:"light"}),s=tv(i),{selection:n,store:o}=s,a=f_(o,i.initialHistory),l=m_(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const u=Tc(a);let c=A_();xc(e,h,i.theme);const d=new Y0({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",C=>{const{originalEvent:T,annotation:I}=C.detail;I?n.userSelect(I.id,T):n.isEmpty()||n.clear()});const p=y_(s,a,i.adapter),f=()=>d.cancelDrawing(),m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},y=()=>d.getDrawingTool(),_=()=>c,v=()=>d.isDrawingEnabled(),g=(C,T,I)=>rc(C,T,I),x=(C,T)=>Qu(C,T),E=C=>{if(!Cn(C))throw`No drawing tool named ${C}`;d.$set({toolName:C})},w=C=>d.$set({drawingEnabled:C}),A=C=>{console.warn("Filter not implemented yet")},R=C=>d.$set({style:C}),M=C=>xc(e,h,C),D=C=>{c=C,d.$set({user:C})},U=C=>d.$set({visible:C});return{...p,cancelDrawing:f,destroy:m,getDrawingTool:y,getUser:_,isDrawingEnabled:v,listDrawingTools:Sn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:w,setDrawingTool:E,setFilter:A,setStyle:R,setTheme:M,setUser:D,setVisible:U,element:h,state:s}};function Qt(){}function Ra(r,t){for(const e in t)r[e]=t[e];return r}function wc(r){return r()}function Ac(){return Object.create(null)}function Je(r){r.forEach(wc)}function re(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function iv(r){return Object.keys(r).length===0}function sv(r,...t){if(r==null){for(const i of t)i(void 0);return Qt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Mn(r,t,e){r.$$.on_destroy.push(sv(t,e))}function Sc(r,t,e,i){if(r){const s=Cc(r,t,e,i);return r[0](s)}}function Cc(r,t,e,i){return r[1]&&i?Ra(e.ctx.slice(),r[1](i(t))):e.ctx}function Ic(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Rc(r,t,e,i,s,n){if(s){const o=Cc(t,e,i,n);r.p(o,s)}}function Mc(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 Oc(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function On(r){return r??""}const Pc=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Rt(r,t){r.appendChild(t)}function lt(r,t,e){r.insertBefore(t,e||null)}function ot(r){r.parentNode&&r.parentNode.removeChild(r)}function Xr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function ht(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ma(r){return document.createTextNode(r)}function Fe(){return Ma(" ")}function Ue(){return Ma("")}function $t(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function S(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function nv(r){return Array.from(r.childNodes)}function ov(r,t){t=""+t,r.data!==t&&(r.data=t)}function Pn(r,t,e){r.classList.toggle(t,!!e)}function av(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ns;function Ls(r){Ns=r}function Oa(){if(!Ns)throw new Error("Function called outside component initialization");return Ns}function Ds(r){Oa().$$.on_mount.push(r)}function lv(r){Oa().$$.on_destroy.push(r)}function Bs(){const r=Oa();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=av(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function ke(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Yi=[],Fs=[];let Wi=[];const Nc=[],Lc=Promise.resolve();let Pa=!1;function Dc(){Pa||(Pa=!0,Lc.then(Bc))}function hv(){return Dc(),Lc}function Na(r){Wi.push(r)}const La=new Set;let ji=0;function Bc(){if(ji!==0)return;const r=Ns;do{try{for(;ji<Yi.length;){const t=Yi[ji];ji++,Ls(t),uv(t.$$)}}catch(t){throw Yi.length=0,ji=0,t}for(Ls(null),Yi.length=0,ji=0;Fs.length;)Fs.pop()();for(let t=0;t<Wi.length;t+=1){const e=Wi[t];La.has(e)||(La.add(e),e())}Wi.length=0}while(Yi.length);for(;Nc.length;)Nc.pop()();Pa=!1,La.clear(),Ls(r)}function uv(r){if(r.fragment!==null){r.update(),Je(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Na)}}function cv(r){const t=[],e=[];Wi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Wi=t}const Nn=new Set;let pi;function xe(){pi={r:0,c:[],p:pi}}function be(){pi.r||Je(pi.c),pi=pi.p}function K(r,t){r&&r.i&&(Nn.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(Nn.has(r))return;Nn.add(r),pi.c.push(()=>{Nn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ce(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Vt(r){r&&r.c()}function Ut(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Na(()=>{const n=r.$$.on_mount.map(wc).filter(re);r.$$.on_destroy?r.$$.on_destroy.push(...n):Je(n),r.$$.on_mount=[]}),s.forEach(Na)}function kt(r,t){const e=r.$$;e.fragment!==null&&(cv(e.after_update),Je(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function dv(r,t){r.$$.dirty[0]===-1&&(Yi.push(r),Dc(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ie(r,t,e,i,s,n,o=null,a=[-1]){const l=Ns;Ls(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Qt,not_equal:s,bound:Ac(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Ac(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&dv(r,c)),d}):[],h.update(),u=!0,Je(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=nv(t.target);h.fragment&&h.fragment.l(c),c.forEach(ot)}else h.fragment&&h.fragment.c();t.intro&&K(r.$$.fragment),Ut(r,t.target,t.anchor),Bc()}Ls(l)}class se{constructor(){Gt(this,"$$");Gt(this,"$$set")}$destroy(){kt(this,1),this.$destroy=Qt}$on(t,e){if(!re(e))return Qt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!iv(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const fv="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(fv);var mi=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(mi||{}),Fc=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Fc||{}),Da=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Da||{}),pt=(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))(pt||{}),cr=(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))(cr||{}),X=(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))(X||{}),zi=(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))(zi||{}),dt=(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))(dt||{}),Z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(Z||{}),Ar=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Ar||{}),Yr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Yr||{}),dr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(dr||{}),Ge=(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))(Ge||{}),fr=(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))(fr||{}),Ba=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Ba||{}),Ye=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Ye||{}),he=(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))(he||{}),ne=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ne||{}),pr=(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))(pr||{});const Q={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 Fa=/iPhone/i,Uc=/iPod/i,kc=/iPad/i,Gc=/\biOS-universal(?:.+)Mac\b/i,Ua=/\bAndroid(?:.+)Mobile\b/i,Hc=/Android/i,qi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ln=/Silk/i,Sr=/Windows Phone/i,$c=/\bWindows(?:.+)ARM\b/i,Vc=/BlackBerry/i,Xc=/BB10/i,Yc=/Opera Mini/i,Wc=/\b(CriOS|Chrome)(?:.+)Mobile/i,jc=/Mobile(?:.+)Firefox\b/i,zc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function pv(r){return function(t){return t.test(r)}}function qc(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=pv(e),n={apple:{phone:s(Fa)&&!s(Sr),ipod:s(Uc),tablet:!s(Fa)&&(s(kc)||zc(t))&&!s(Sr),universal:s(Gc),device:(s(Fa)||s(Uc)||s(kc)||s(Gc)||zc(t))&&!s(Sr)},amazon:{phone:s(qi),tablet:!s(qi)&&s(Ln),device:s(qi)||s(Ln)},android:{phone:!s(Sr)&&s(qi)||!s(Sr)&&s(Ua),tablet:!s(Sr)&&!s(qi)&&!s(Ua)&&(s(Ln)||s(Hc)),device:!s(Sr)&&(s(qi)||s(Ln)||s(Ua)||s(Hc))||s(/\bokhttp\b/i)},windows:{phone:s(Sr),tablet:s($c),device:s(Sr)||s($c)},other:{blackberry:s(Vc),blackberry10:s(Xc),opera:s(Yc),firefox:s(jc),chrome:s(Wc),device:s(Vc)||s(Xc)||s(Yc)||s(jc)||s(Wc)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const mv=qc.default??qc,Cr=mv(globalThis.navigator);Q.RETINA_PREFIX=/@([0-9\.]+)x/,Q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Kc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function gv(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Zc={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||l,d),f=e?e+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},a.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d<p;d++)f[d]=c[d].fn;return f},a.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(h,u,c,d,p,f){var m=e?e+h:h;if(!this._events[m])return!1;var y=this._events[m],_=arguments.length,v,g;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,u),!0;case 3:return y.fn.call(y.context,u,c),!0;case 4:return y.fn.call(y.context,u,c,d),!0;case 5:return y.fn.call(y.context,u,c,d,p),!0;case 6:return y.fn.call(y.context,u,c,d,p,f),!0}for(g=1,v=new Array(_-1);g<_;g++)v[g-1]=arguments[g];y.fn.apply(y.context,v)}else{var x=y.length,E;for(g=0;g<x;g++)switch(y[g].once&&this.removeListener(h,y[g].fn,void 0,!0),_){case 1:y[g].fn.call(y[g].context);break;case 2:y[g].fn.call(y[g].context,u);break;case 3:y[g].fn.call(y[g].context,u,c);break;case 4:y[g].fn.call(y[g].context,u,c,d);break;default:if(!v)for(E=1,v=new Array(_-1);E<_;E++)v[E-1]=arguments[E];y[g].fn.apply(y[g].context,v)}}return!0},a.prototype.on=function(h,u,c){return n(this,h,u,c,!1)},a.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},a.prototype.removeListener=function(h,u,c,d){var p=e?e+h:h;if(!this._events[p])return this;if(!u)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===u&&(!d||f.once)&&(!c||f.context===c)&&o(this,p);else{for(var m=0,y=[],_=f.length;m<_;m++)(f[m].fn!==u||d&&!f[m].once||c&&f[m].context!==c)&&y.push(f[m]);y.length?this._events[p]=y.length===1?y[0]:y:o(this,p)}return this},a.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&o(this,u)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Zc);var yv=Zc.exports;const ks=Kc(yv);var ka={exports:{}};ka.exports=Dn,ka.exports.default=Dn;function Dn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Qc(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,u,c,d,p;if(i&&(n=Ev(r,t,n,e)),r.length>80*e){a=h=r[0],l=u=r[1];for(var f=e;f<s;f+=e)c=r[f],d=r[f+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-a,u-l),p=p!==0?32767/p:0}return Gs(n,o,e,a,l,p,0),o}function Qc(r,t,e,i,s){var n,o;if(s===$a(r,t,e,i)>0)for(n=t;n<e;n+=i)o=ed(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=ed(n,r[n],r[n+1],o);return o&&Bn(o,o.next)&&($s(o),o=o.next),o}function gi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Bn(e,e.next)||Xt(e.prev,e,e.next)===0)){if($s(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Gs(r,t,e,i,s,n,o){if(r){!o&&n&&Cv(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?vv(r,i,s,n):_v(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),$s(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=xv(gi(r),t,e),Gs(r,t,e,i,s,n,2)):o===2&&bv(r,t,e,i,s,n):Gs(gi(r),t,e,i,s,n,1);break}}}}function _v(r){var t=r.prev,e=r,i=r.next;if(Xt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Ki(s,a,n,l,o,h,f.x,f.y)&&Xt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function vv(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Xt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,y=u>c?u>d?u:d:c>d?c:d,_=Ga(p,f,t,e,i),v=Ga(m,y,t,e,i),g=r.prevZ,x=r.nextZ;g&&g.z>=_&&x&&x.z<=v;){if(g.x>=p&&g.x<=m&&g.y>=f&&g.y<=y&&g!==s&&g!==o&&Ki(a,u,l,c,h,d,g.x,g.y)&&Xt(g.prev,g,g.next)>=0||(g=g.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=y&&x!==s&&x!==o&&Ki(a,u,l,c,h,d,x.x,x.y)&&Xt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;g&&g.z>=_;){if(g.x>=p&&g.x<=m&&g.y>=f&&g.y<=y&&g!==s&&g!==o&&Ki(a,u,l,c,h,d,g.x,g.y)&&Xt(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=y&&x!==s&&x!==o&&Ki(a,u,l,c,h,d,x.x,x.y)&&Xt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function xv(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Bn(s,n)&&Jc(s,i,i.next,n)&&Hs(s,n)&&Hs(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),$s(i),$s(i.next),i=r=n),i=i.next}while(i!==r);return gi(i)}function bv(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Mv(o,a)){var l=td(o,a);o=gi(o,o.next),l=gi(l,l.next),Gs(o,t,e,i,s,n,0),Gs(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Ev(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=Qc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(Rv(h));for(s.sort(Tv),n=0;n<s.length;n++)e=wv(s[n],e);return e}function Tv(r,t){return r.x-t.x}function wv(r,t){var e=Av(r,t);if(!e)return t;var i=td(e,r);return gi(i,i.next),gi(e,e.next)}function Av(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&Ki(s<u?i:n,s,h,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Hs(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&Sv(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function Sv(r,t){return Xt(r.prev,r,t.prev)<0&&Xt(t.next,r,r.next)<0}function Cv(r,t,e,i){var s=r;do s.z===0&&(s.z=Ga(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Iv(s)}function Iv(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function Ga(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Rv(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 Ki(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Mv(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ov(r,t)&&(Hs(r,t)&&Hs(t,r)&&Pv(r,t)&&(Xt(r.prev,r,t.prev)||Xt(r,t.prev,t))||Bn(r,t)&&Xt(r.prev,r,r.next)>0&&Xt(t.prev,t,t.next)>0)}function Xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Bn(r,t){return r.x===t.x&&r.y===t.y}function Jc(r,t,e,i){var s=Un(Xt(r,t,e)),n=Un(Xt(r,t,i)),o=Un(Xt(e,i,r)),a=Un(Xt(e,i,t));return!!(s!==n&&o!==a||s===0&&Fn(r,e,t)||n===0&&Fn(r,i,t)||o===0&&Fn(e,r,i)||a===0&&Fn(e,t,i))}function Fn(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 Un(r){return r>0?1:r<0?-1:0}function Ov(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&&Jc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Hs(r,t){return Xt(r.prev,r,r.next)<0?Xt(r,t,r.next)>=0&&Xt(r,r.prev,t)>=0:Xt(r,t,r.prev)<0||Xt(r,r.next,t)<0}function Pv(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function td(r,t){var e=new Ha(r.i,r.x,r.y),i=new Ha(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function ed(r,t,e,i){var s=new Ha(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function $s(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}Dn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs($a(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,u=a<l-1?t[a+1]*e:r.length;o-=Math.abs($a(r,h,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,p=i[a+1]*e,f=i[a+2]*e;c+=Math.abs((r[d]-r[f])*(r[p+1]-r[d+1])-(r[d]-r[p])*(r[f+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function $a(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}Dn.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Nv=ka.exports;const Lv=Kc(Nv);var kn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */kn.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Us=="object"&&Us;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,p=72,f=128,m="-",y=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-h,E=Math.floor,w=String.fromCharCode,A;function R(P){throw new RangeError(g[P])}function M(P,B){for(var $=P.length,Y=[];$--;)Y[$]=B(P[$]);return Y}function D(P,B){var $=P.split("@"),Y="";$.length>1&&(Y=$[0]+"@",P=$[1]),P=P.replace(v,".");var z=P.split("."),it=M(z,B).join(".");return Y+it}function U(P){for(var B=[],$=0,Y=P.length,z,it;$<Y;)z=P.charCodeAt($++),z>=55296&&z<=56319&&$<Y?(it=P.charCodeAt($++),(it&64512)==56320?B.push(((z&1023)<<10)+(it&1023)+65536):(B.push(z),$--)):B.push(z);return B}function C(P){return M(P,function(B){var $="";return B>65535&&(B-=65536,$+=w(B>>>10&1023|55296),B=56320|B&1023),$+=w(B),$}).join("")}function T(P){return P-48<10?P-22:P-65<26?P-65:P-97<26?P-97:l}function I(P,B){return P+22+75*(P<26)-((B!=0)<<5)}function N(P,B,$){var Y=0;for(P=$?E(P/d):P>>1,P+=E(P/B);P>x*u>>1;Y+=l)P=E(P/x);return E(Y+(x+1)*P/(P+c))}function O(P){var B=[],$=P.length,Y,z=0,it=f,xt=p,Ct,q,wt,ft,gt,vt,It,Ot,pe;for(Ct=P.lastIndexOf(m),Ct<0&&(Ct=0),q=0;q<Ct;++q)P.charCodeAt(q)>=128&&R("not-basic"),B.push(P.charCodeAt(q));for(wt=Ct>0?Ct+1:0;wt<$;){for(ft=z,gt=1,vt=l;wt>=$&&R("invalid-input"),It=T(P.charCodeAt(wt++)),(It>=l||It>E((a-z)/gt))&&R("overflow"),z+=It*gt,Ot=vt<=xt?h:vt>=xt+u?u:vt-xt,!(It<Ot);vt+=l)pe=l-Ot,gt>E(a/pe)&&R("overflow"),gt*=pe;Y=B.length+1,xt=N(z-ft,Y,ft==0),E(z/Y)>a-it&&R("overflow"),it+=E(z/Y),z%=Y,B.splice(z++,0,it)}return C(B)}function L(P){var B,$,Y,z,it,xt,Ct,q,wt,ft,gt,vt=[],It,Ot,pe,jt;for(P=U(P),It=P.length,B=f,$=0,it=p,xt=0;xt<It;++xt)gt=P[xt],gt<128&&vt.push(w(gt));for(Y=z=vt.length,z&&vt.push(m);Y<It;){for(Ct=a,xt=0;xt<It;++xt)gt=P[xt],gt>=B&&gt<Ct&&(Ct=gt);for(Ot=Y+1,Ct-B>E((a-$)/Ot)&&R("overflow"),$+=(Ct-B)*Ot,B=Ct,xt=0;xt<It;++xt)if(gt=P[xt],gt<B&&++$>a&&R("overflow"),gt==B){for(q=$,wt=l;ft=wt<=it?h:wt>=it+u?u:wt-it,!(q<ft);wt+=l)jt=q-ft,pe=l-ft,vt.push(w(I(ft+jt%pe,0))),q=E(jt/pe);vt.push(w(I(q,0))),it=N($,Ot,Y==z),$=0,++Y}++$,++B}return vt.join("")}function F(P){return D(P,function(B){return y.test(B)?O(B.slice(4).toLowerCase()):B})}function V(P){return D(P,function(B){return _.test(B)?"xn--"+L(B):B})}if(o={version:"1.4.1",ucs2:{decode:U,encode:C},decode:O,encode:L,toASCII:V,toUnicode:F},i&&s)if(r.exports==i)s.exports=o;else for(A in o)o.hasOwnProperty(A)&&(i[A]=o[A]);else e.punycode=o})(Us)}(kn,kn.exports);var Dv=kn.exports,Zi=TypeError;const Bv=gv(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Va=typeof Map=="function"&&Map.prototype,Xa=Object.getOwnPropertyDescriptor&&Va?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Gn=Va&&Xa&&typeof Xa.get=="function"?Xa.get:null,rd=Va&&Map.prototype.forEach,Ya=typeof Set=="function"&&Set.prototype,Wa=Object.getOwnPropertyDescriptor&&Ya?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Hn=Ya&&Wa&&typeof Wa.get=="function"?Wa.get:null,id=Ya&&Set.prototype.forEach,Fv=typeof WeakMap=="function"&&WeakMap.prototype,Vs=Fv?WeakMap.prototype.has:null,Uv=typeof WeakSet=="function"&&WeakSet.prototype,Xs=Uv?WeakSet.prototype.has:null,kv=typeof WeakRef=="function"&&WeakRef.prototype,sd=kv?WeakRef.prototype.deref:null,Gv=Boolean.prototype.valueOf,Hv=Object.prototype.toString,$v=Function.prototype.toString,Vv=String.prototype.match,ja=String.prototype.slice,Wr=String.prototype.replace,Xv=String.prototype.toUpperCase,nd=String.prototype.toLowerCase,od=RegExp.prototype.test,ad=Array.prototype.concat,mr=Array.prototype.join,Yv=Array.prototype.slice,ld=Math.floor,za=typeof BigInt=="function"?BigInt.prototype.valueOf:null,qa=Object.getOwnPropertySymbols,Ka=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Qi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ys=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Qi||!0)?Symbol.toStringTag:null,hd=Object.prototype.propertyIsEnumerable,ud=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function cd(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||od.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-ld(-r):ld(r);if(i!==r){var s=String(i),n=ja.call(t,s.length+1);return Wr.call(s,e,"$&_")+"."+Wr.call(Wr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Wr.call(t,e,"$&_")}var Za=Bv,dd=Za.custom,fd=yd(dd)?dd:null,pd={__proto__:null,double:'"',single:"'"},Wv={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},$n=function r(t,e,i,s){var n=e||{};if(Ir(n,"quoteStyle")&&!Ir(pd,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ir(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Ir(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ir(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ir(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return vd(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?cd(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?cd(t,h):h}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return Qa(t)?"[Array]":"[Object]";var c=u1(n,i);if(typeof s>"u")s=[];else if(_d(s,t)>=0)return"[Circular]";function d(T,I,N){if(I&&(s=Yv.call(s),s.push(I)),N){var O={depth:n.depth};return Ir(n,"quoteStyle")&&(O.quoteStyle=n.quoteStyle),r(T,O,i+1,s)}return r(T,n,i+1,s)}if(typeof t=="function"&&!gd(t)){var p=e1(t),f=Vn(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+mr.call(f,", ")+" }":"")}if(yd(t)){var m=Qi?Wr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ka.call(t);return typeof t=="object"&&!Qi?Ws(m):m}if(a1(t)){for(var y="<"+nd.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)y+=" "+_[v].name+"="+md(jv(_[v].value),"double",n);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+nd.call(String(t.nodeName))+">",y}if(Qa(t)){if(t.length===0)return"[]";var g=Vn(t,d);return c&&!h1(g)?"["+tl(g,c)+"]":"[ "+mr.call(g,", ")+" ]"}if(qv(t)){var x=Vn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!hd.call(t,"cause")?"{ ["+String(t)+"] "+mr.call(ad.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+mr.call(x,", ")+" }"}if(typeof t=="object"&&o){if(fd&&typeof t[fd]=="function"&&Za)return Za(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(r1(t)){var E=[];return rd&&rd.call(t,function(T,I){E.push(d(I,t,!0)+" => "+d(T,t))}),xd("Map",Gn.call(t),E,c)}if(n1(t)){var w=[];return id&&id.call(t,function(T){w.push(d(T,t))}),xd("Set",Hn.call(t),w,c)}if(i1(t))return Ja("WeakMap");if(o1(t))return Ja("WeakSet");if(s1(t))return Ja("WeakRef");if(Zv(t))return Ws(d(Number(t)));if(Jv(t))return Ws(d(za.call(t)));if(Qv(t))return Ws(Gv.call(t));if(Kv(t))return Ws(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Us<"u"&&t===Us)return"{ [object globalThis] }";if(!zv(t)&&!gd(t)){var A=Vn(t,d),R=ud?ud(t)===Object.prototype:t instanceof Object||t.constructor===Object,M=t instanceof Object?"":"null prototype",D=!R&&Ys&&Object(t)===t&&Ys in t?ja.call(jr(t),8,-1):M?"Object":"",U=R||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",C=U+(D||M?"["+mr.call(ad.call([],D||[],M||[]),": ")+"] ":"");return A.length===0?C+"{}":c?C+"{"+tl(A,c)+"}":C+"{ "+mr.call(A,", ")+" }"}return String(t)};function md(r,t,e){var i=e.quoteStyle||t,s=pd[i];return s+r+s}function jv(r){return Wr.call(String(r),/"/g,"&quot;")}function yi(r){return!Ys||!(typeof r=="object"&&(Ys in r||typeof r[Ys]<"u"))}function Qa(r){return jr(r)==="[object Array]"&&yi(r)}function zv(r){return jr(r)==="[object Date]"&&yi(r)}function gd(r){return jr(r)==="[object RegExp]"&&yi(r)}function qv(r){return jr(r)==="[object Error]"&&yi(r)}function Kv(r){return jr(r)==="[object String]"&&yi(r)}function Zv(r){return jr(r)==="[object Number]"&&yi(r)}function Qv(r){return jr(r)==="[object Boolean]"&&yi(r)}function yd(r){if(Qi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Ka)return!1;try{return Ka.call(r),!0}catch{}return!1}function Jv(r){if(!r||typeof r!="object"||!za)return!1;try{return za.call(r),!0}catch{}return!1}var t1=Object.prototype.hasOwnProperty||function(r){return r in this};function Ir(r,t){return t1.call(r,t)}function jr(r){return Hv.call(r)}function e1(r){if(r.name)return r.name;var t=Vv.call($v.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function _d(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 r1(r){if(!Gn||!r||typeof r!="object")return!1;try{Gn.call(r);try{Hn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function i1(r){if(!Vs||!r||typeof r!="object")return!1;try{Vs.call(r,Vs);try{Xs.call(r,Xs)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function s1(r){if(!sd||!r||typeof r!="object")return!1;try{return sd.call(r),!0}catch{}return!1}function n1(r){if(!Hn||!r||typeof r!="object")return!1;try{Hn.call(r);try{Gn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function o1(r){if(!Xs||!r||typeof r!="object")return!1;try{Xs.call(r,Xs);try{Vs.call(r,Vs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function a1(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function vd(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return vd(ja.call(r,0,t.maxStringLength),t)+i}var s=Wv[t.quoteStyle||"single"];s.lastIndex=0;var n=Wr.call(Wr.call(r,s,"\\$1"),/[\x00-\x1f]/g,l1);return md(n,"single",t)}function l1(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":"")+Xv.call(t.toString(16))}function Ws(r){return"Object("+r+")"}function Ja(r){return r+" { ? }"}function xd(r,t,e,i){var s=i?tl(e,i):mr.call(e,", ");return r+" ("+t+") {"+s+"}"}function h1(r){for(var t=0;t<r.length;t++)if(_d(r[t],`
3
- `)>=0)return!1;return!0}function u1(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=mr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:mr.call(Array(t+1),e)}}function tl(r,t){if(r.length===0)return"";var e=`
4
- `+t.prev+t.base;return e+mr.call(r,","+e)+`
5
- `+t.prev}function Vn(r,t){var e=Qa(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=Ir(r,s)?t(r[s],r):""}var n=typeof qa=="function"?qa(r):[],o;if(Qi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)Ir(r,l)&&(e&&String(Number(l))===l&&l<r.length||Qi&&o["$"+l]instanceof Symbol||(od.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof qa=="function")for(var h=0;h<n.length;h++)hd.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var c1=$n,d1=Zi,Xn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},f1=function(r,t){if(r){var e=Xn(r,t);return e&&e.value}},p1=function(r,t,e){var i=Xn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},m1=function(r,t){return r?!!Xn(r,t):!1},g1=function(r,t){if(r)return Xn(r,t,!0)},y1=function(){var t,e={assert:function(i){if(!e.has(i))throw new d1("Side channel does not contain "+c1(i))},delete:function(i){var s=t&&t.next,n=g1(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return f1(t,i)},has:function(i){return m1(t,i)},set:function(i,s){t||(t={next:void 0}),p1(t,i,s)}};return e},bd=Object,_1=Error,v1=EvalError,x1=RangeError,b1=ReferenceError,E1=SyntaxError,T1=URIError,w1=Math.abs,A1=Math.floor,S1=Math.max,C1=Math.min,I1=Math.pow,R1=Math.round,M1=Number.isNaN||function(t){return t!==t},O1=M1,P1=function(t){return O1(t)||t===0?t:t<0?-1:1},N1=Object.getOwnPropertyDescriptor,Yn=N1;if(Yn)try{Yn([],"length")}catch{Yn=null}var Ed=Yn,Wn=Object.defineProperty||!1;if(Wn)try{Wn({},"a",{value:1})}catch{Wn=!1}var L1=Wn,el,Td;function D1(){return Td||(Td=1,el=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),el}var rl,wd;function B1(){if(wd)return rl;wd=1;var r=typeof Symbol<"u"&&Symbol,t=D1();return rl=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},rl}var il,Ad;function Sd(){return Ad||(Ad=1,il=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),il}var sl,Cd;function Id(){if(Cd)return sl;Cd=1;var r=bd;return sl=r.getPrototypeOf||null,sl}var nl,Rd;function F1(){if(Rd)return nl;Rd=1;var r="Function.prototype.bind called on incompatible ",t=Object.prototype.toString,e=Math.max,i="[object Function]",s=function(l,h){for(var u=[],c=0;c<l.length;c+=1)u[c]=l[c];for(var d=0;d<h.length;d+=1)u[d+l.length]=h[d];return u},n=function(l,h){for(var u=[],c=h,d=0;c<l.length;c+=1,d+=1)u[d]=l[c];return u},o=function(a,l){for(var h="",u=0;u<a.length;u+=1)h+=a[u],u+1<a.length&&(h+=l);return h};return nl=function(l){var h=this;if(typeof h!="function"||t.apply(h)!==i)throw new TypeError(r+h);for(var u=n(arguments,1),c,d=function(){if(this instanceof c){var _=h.apply(this,s(u,arguments));return Object(_)===_?_:this}return h.apply(l,s(u,arguments))},p=e(0,h.length-u.length),f=[],m=0;m<p;m++)f[m]="$"+m;if(c=Function("binder","return function ("+o(f,",")+"){ return binder.apply(this,arguments); }")(d),h.prototype){var y=function(){};y.prototype=h.prototype,c.prototype=new y,y.prototype=null}return c},nl}var ol,Md;function jn(){if(Md)return ol;Md=1;var r=F1();return ol=Function.prototype.bind||r,ol}var al,Od;function ll(){return Od||(Od=1,al=Function.prototype.call),al}var hl,Pd;function Nd(){return Pd||(Pd=1,hl=Function.prototype.apply),hl}var U1=typeof Reflect<"u"&&Reflect&&Reflect.apply,k1=jn(),G1=Nd(),H1=ll(),$1=U1,V1=$1||k1.call(H1,G1),X1=jn(),Y1=Zi,W1=ll(),j1=V1,Ld=function(t){if(t.length<1||typeof t[0]!="function")throw new Y1("a function is required");return j1(X1,W1,t)},ul,Dd;function z1(){if(Dd)return ul;Dd=1;var r=Ld,t=Ed,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return ul=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,ul}var cl,Bd;function q1(){if(Bd)return cl;Bd=1;var r=Sd(),t=Id(),e=z1();return cl=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,cl}var dl,Fd;function K1(){if(Fd)return dl;Fd=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=jn();return dl=e.call(r,t),dl}var Tt,Z1=bd,Q1=_1,J1=v1,tx=x1,ex=b1,Ji=E1,ts=Zi,rx=T1,ix=w1,sx=A1,nx=S1,ox=C1,ax=I1,lx=R1,hx=P1,Ud=Function,fl=function(r){try{return Ud('"use strict"; return ('+r+").constructor;")()}catch{}},js=Ed,ux=L1,pl=function(){throw new ts},cx=js?function(){try{return arguments.callee,pl}catch{try{return js(arguments,"callee").get}catch{return pl}}}():pl,es=B1()(),ce=q1(),dx=Id(),fx=Sd(),kd=Nd(),zs=ll(),rs={},px=typeof Uint8Array>"u"||!ce?Tt:ce(Uint8Array),_i={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?Tt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?Tt:ArrayBuffer,"%ArrayIteratorPrototype%":es&&ce?ce([][Symbol.iterator]()):Tt,"%AsyncFromSyncIteratorPrototype%":Tt,"%AsyncFunction%":rs,"%AsyncGenerator%":rs,"%AsyncGeneratorFunction%":rs,"%AsyncIteratorPrototype%":rs,"%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%":Q1,"%eval%":eval,"%EvalError%":J1,"%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%":Ud,"%GeneratorFunction%":rs,"%Int8Array%":typeof Int8Array>"u"?Tt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?Tt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?Tt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":es&&ce?ce(ce([][Symbol.iterator]())):Tt,"%JSON%":typeof JSON=="object"?JSON:Tt,"%Map%":typeof Map>"u"?Tt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!es||!ce?Tt:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Z1,"%Object.getOwnPropertyDescriptor%":js,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?Tt:Promise,"%Proxy%":typeof Proxy>"u"?Tt:Proxy,"%RangeError%":tx,"%ReferenceError%":ex,"%Reflect%":typeof Reflect>"u"?Tt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?Tt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!es||!ce?Tt:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?Tt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":es&&ce?ce(""[Symbol.iterator]()):Tt,"%Symbol%":es?Symbol:Tt,"%SyntaxError%":Ji,"%ThrowTypeError%":cx,"%TypedArray%":px,"%TypeError%":ts,"%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%":rx,"%WeakMap%":typeof WeakMap>"u"?Tt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?Tt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?Tt:WeakSet,"%Function.prototype.call%":zs,"%Function.prototype.apply%":kd,"%Object.defineProperty%":ux,"%Object.getPrototypeOf%":dx,"%Math.abs%":ix,"%Math.floor%":sx,"%Math.max%":nx,"%Math.min%":ox,"%Math.pow%":ax,"%Math.round%":lx,"%Math.sign%":hx,"%Reflect.getPrototypeOf%":fx};if(ce)try{null.error}catch(r){var mx=ce(ce(r));_i["%Error.prototype%"]=mx}var gx=function r(t){var e;if(t==="%AsyncFunction%")e=fl("async function () {}");else if(t==="%GeneratorFunction%")e=fl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=fl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&ce&&(e=ce(s.prototype))}return _i[t]=e,e},Gd={__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"]},qs=jn(),zn=K1(),yx=qs.call(zs,Array.prototype.concat),_x=qs.call(kd,Array.prototype.splice),Hd=qs.call(zs,String.prototype.replace),qn=qs.call(zs,String.prototype.slice),vx=qs.call(zs,RegExp.prototype.exec),xx=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,bx=/\\(\\)?/g,Ex=function(t){var e=qn(t,0,1),i=qn(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 s=[];return Hd(t,xx,function(n,o,a,l){s[s.length]=a?Hd(l,bx,"$1"):o||n}),s},Tx=function(t,e){var i=t,s;if(zn(Gd,i)&&(s=Gd[i],i="%"+s[0]+"%"),zn(_i,i)){var n=_i[i];if(n===rs&&(n=gx(i)),typeof n>"u"&&!e)throw new ts("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Ji("intrinsic "+t+" does not exist!")},ml=function(t,e){if(typeof t!="string"||t.length===0)throw new ts("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new ts('"allowMissing" argument must be a boolean');if(vx(/^%?[^%]*%?$/,t)===null)throw new Ji("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Ex(t),s=i.length>0?i[0]:"",n=Tx("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],_x(i,yx([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=qn(d,0,1),f=qn(d,-1);if((p==='"'||p==="'"||p==="`"||f==='"'||f==="'"||f==="`")&&p!==f)throw new Ji("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",zn(_i,o))a=_i[o];else if(a!=null){if(!(d in a)){if(!e)throw new ts("base intrinsic for "+t+" exists, but the property is not available.");return}if(js&&u+1>=i.length){var m=js(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=zn(a,d),a=a[d];c&&!l&&(_i[o]=a)}}return a},$d=ml,Vd=Ld,wx=Vd([$d("%String.prototype.indexOf%")]),Xd=function(t,e){var i=$d(t,!!e);return typeof i=="function"&&wx(t,".prototype.")>-1?Vd([i]):i},Ax=ml,Ks=Xd,Sx=$n,Cx=Zi,Yd=Ax("%Map%",!0),Ix=Ks("Map.prototype.get",!0),Rx=Ks("Map.prototype.set",!0),Mx=Ks("Map.prototype.has",!0),Ox=Ks("Map.prototype.delete",!0),Px=Ks("Map.prototype.size",!0),Wd=!!Yd&&function(){var t,e={assert:function(i){if(!e.has(i))throw new Cx("Side channel does not contain "+Sx(i))},delete:function(i){if(t){var s=Ox(t,i);return Px(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return Ix(t,i)},has:function(i){return t?Mx(t,i):!1},set:function(i,s){t||(t=new Yd),Rx(t,i,s)}};return e},Nx=ml,Kn=Xd,Lx=$n,Zn=Wd,Dx=Zi,is=Nx("%WeakMap%",!0),Bx=Kn("WeakMap.prototype.get",!0),Fx=Kn("WeakMap.prototype.set",!0),Ux=Kn("WeakMap.prototype.has",!0),kx=Kn("WeakMap.prototype.delete",!0),Gx=is?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new Dx("Side channel does not contain "+Lx(s))},delete:function(s){if(is&&s&&(typeof s=="object"||typeof s=="function")){if(t)return kx(t,s)}else if(Zn&&e)return e.delete(s);return!1},get:function(s){return is&&s&&(typeof s=="object"||typeof s=="function")&&t?Bx(t,s):e&&e.get(s)},has:function(s){return is&&s&&(typeof s=="object"||typeof s=="function")&&t?Ux(t,s):!!e&&e.has(s)},set:function(s,n){is&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new is),Fx(t,s,n)):Zn&&(e||(e=Zn()),e.set(s,n))}};return i}:Zn,Hx=Zi,$x=$n,Vx=y1,Xx=Wd,Yx=Gx,Wx=Yx||Xx||Vx,jx=function(){var t,e={assert:function(i){if(!e.has(i))throw new Hx("Side channel does not contain "+$x(i))},delete:function(i){return!!t&&t.delete(i)},get:function(i){return t&&t.get(i)},has:function(i){return!!t&&t.has(i)},set:function(i,s){t||(t=Wx()),t.set(i,s)}};return e},zx=String.prototype.replace,qx=/%20/g,gl={RFC1738:"RFC1738",RFC3986:"RFC3986"},yl={default:gl.RFC3986,formatters:{RFC1738:function(r){return zx.call(r,qx,"+")},RFC3986:function(r){return String(r)}},RFC1738:gl.RFC1738,RFC3986:gl.RFC3986},Kx=yl,_l=Object.prototype.hasOwnProperty,vi=Array.isArray,gr=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),Zx=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(vi(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},jd=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},Qx=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(vi(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!_l.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return vi(t)&&!vi(e)&&(s=jd(t,i)),vi(t)&&vi(e)?(e.forEach(function(n,o){if(_l.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return _l.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},Jx=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},tb=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}},vl=1024,eb=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=vl){for(var h=o.length>=vl?o.slice(l,l+vl):o,u=[],c=0;c<h.length;++c){var d=h.charCodeAt(c);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===Kx.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=gr[d];continue}if(d<2048){u[u.length]=gr[192|d>>6]+gr[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=gr[224|d>>12]+gr[128|d>>6&63]+gr[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=gr[240|d>>18]+gr[128|d>>12&63]+gr[128|d>>6&63]+gr[128|d&63]}a+=u.join("")}return a},rb=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],u=o[h];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:h}),i.push(u))}return Zx(e),t},ib=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},sb=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},nb=function(t,e){return[].concat(t,e)},ob=function(t,e){if(vi(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},zd={arrayToObject:jd,assign:Jx,combine:nb,compact:rb,decode:tb,encode:eb,isBuffer:sb,isRegExp:ib,maybeMap:ob,merge:Qx},qd=jx,Qn=zd,Zs=yl,ab=Object.prototype.hasOwnProperty,Kd={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},yr=Array.isArray,lb=Array.prototype.push,Zd=function(r,t){lb.apply(r,yr(t)?t:[t])},hb=Date.prototype.toISOString,Qd=Zs.default,ue={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Qn.encode,encodeValuesOnly:!1,filter:void 0,format:Qd,formatter:Zs.formatters[Qd],indices:!1,serializeDate:function(t){return hb.call(t)},skipNulls:!1,strictNullHandling:!1},ub=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},xl={},cb=function r(t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v){for(var g=t,x=v,E=0,w=!1;(x=x.get(xl))!==void 0&&!w;){var A=x.get(t);if(E+=1,typeof A<"u"){if(A===E)throw new RangeError("Cyclic object value");w=!0}typeof x.get(xl)>"u"&&(E=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=p(g):i==="comma"&&yr(g)&&(g=Qn.maybeMap(g,function(P){return P instanceof Date?p(P):P})),g===null){if(o)return h&&!y?h(e,ue.encoder,_,"key",f):e;g=""}if(ub(g)||Qn.isBuffer(g)){if(h){var R=y?e:h(e,ue.encoder,_,"key",f);return[m(R)+"="+m(h(g,ue.encoder,_,"value",f))]}return[m(e)+"="+m(String(g))]}var M=[];if(typeof g>"u")return M;var D;if(i==="comma"&&yr(g))y&&h&&(g=Qn.maybeMap(g,h)),D=[{value:g.length>0?g.join(",")||null:void 0}];else if(yr(u))D=u;else{var U=Object.keys(g);D=c?U.sort(c):U}var C=l?String(e).replace(/\./g,"%2E"):String(e),T=s&&yr(g)&&g.length===1?C+"[]":C;if(n&&yr(g)&&g.length===0)return T+"[]";for(var I=0;I<D.length;++I){var N=D[I],O=typeof N=="object"&&N&&typeof N.value<"u"?N.value:g[N];if(!(a&&O===null)){var L=d&&l?String(N).replace(/\./g,"%2E"):String(N),F=yr(g)?typeof i=="function"?i(T,L):T:T+(d?"."+L:"["+L+"]");v.set(t,E);var V=qd();V.set(xl,v),Zd(M,r(O,F,i,s,n,o,a,l,i==="comma"&&y&&yr(g)?null:h,u,c,d,p,f,m,y,_,V))}}return M},db=function(t){if(!t)return ue;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||ue.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=Zs.default;if(typeof t.format<"u"){if(!ab.call(Zs.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Zs.formatters[i],n=ue.filter;(typeof t.filter=="function"||yr(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in Kd?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=ue.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:ue.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ue.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ue.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ue.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?ue.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ue.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:ue.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:ue.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ue.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ue.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ue.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ue.strictNullHandling}},fb=function(r,t){var e=r,i=db(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):yr(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=Kd[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=qd(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||Zd(o,cb(d,c,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var p=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),p.length>0?f+p:""},xi=zd,bl=Object.prototype.hasOwnProperty,Jd=Array.isArray,Kt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:xi.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},pb=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},tf=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},mb="utf8=%26%2310003%3B",gb="utf8=%E2%9C%93",yb=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,e.throwOnLimitExceeded?n+1:n);if(e.throwOnLimitExceeded&&o.length>n)throw new RangeError("Parameter limit exceeded. Only "+n+" parameter"+(n===1?"":"s")+" allowed.");var a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===gb?h="utf-8":o[l]===mb&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,p,f;d===-1?(p=e.decoder(u,Kt.decoder,h,"key"),f=e.strictNullHandling?null:""):(p=e.decoder(u.slice(0,d),Kt.decoder,h,"key"),f=xi.maybeMap(tf(u.slice(d+1),e,Jd(i[p])?i[p].length:0),function(y){return e.decoder(y,Kt.decoder,h,"value")})),f&&e.interpretNumericEntities&&h==="iso-8859-1"&&(f=pb(String(f))),u.indexOf("[]=")>-1&&(f=Jd(f)?[f]:f);var m=bl.call(i,p);m&&e.duplicates==="combine"?i[p]=xi.combine(i[p],f):(!m||e.duplicates==="last")&&(i[p]=f)}return i},_b=function(r,t,e,i){var s=0;if(r.length>0&&r[r.length-1]==="[]"){var n=r.slice(0,-1).join("");s=Array.isArray(t)&&t[n]?t[n].length:0}for(var o=i?t:tf(t,e,s),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:xi.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var u=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,c=e.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(c,10);!e.parseArrays&&c===""?l={0:o}:!isNaN(d)&&h!==c&&String(d)===c&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):c!=="__proto__"&&(l[c]=o)}o=l}return o},vb=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,u=[];if(h){if(!i.plainObjects&&bl.call(Object.prototype,h)&&!i.allowPrototypes)return;u.push(h)}for(var c=0;i.depth>0&&(l=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&bl.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");u.push("["+n.slice(l.index)+"]")}return _b(u,e,i,s)}},xb=function(t){if(!t)return Kt;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"?Kt.charset:t.charset,i=typeof t.duplicates>"u"?Kt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Kt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Kt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Kt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Kt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Kt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Kt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Kt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Kt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Kt.decoder,delimiter:typeof t.delimiter=="string"||xi.isRegExp(t.delimiter)?t.delimiter:Kt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Kt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Kt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Kt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Kt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Kt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Kt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},bb=function(r,t){var e=xb(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?yb(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=vb(a,i[a],e,typeof r=="string");s=xi.merge(s,l,e)}return e.allowSparse===!0?s:xi.compact(s)},Eb=fb,Tb=bb,wb=yl,Ab={formats:wb,parse:Tb,stringify:Eb},Sb=Dv;function Rr(){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 Cb=/^([a-z0-9.+-]+:)/i,Ib=/:[0-9]*$/,Rb=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Mb=["<",">",'"',"`"," ","\r",`
6
- `," "],Ob=["{","}","|","\\","^","`"].concat(Mb),El=["'"].concat(Ob),ef=["%","/","?",";","#"].concat(El),rf=["/","?","#"],Pb=255,sf=/^[+a-z0-9A-Z_-]{0,63}$/,Nb=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Lb={javascript:!0,"javascript:":!0},Tl={javascript:!0,"javascript:":!0},ss={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},wl=Ab;function Db(r,t,e){if(r&&typeof r=="object"&&r instanceof Rr)return r;var i=new Rr;return i.parse(r,t,e),i}Rr.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=Rb.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=Cb.exec(a);if(h){h=h[0];var u=h.toLowerCase();this.protocol=u,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var c=a.substr(0,2)==="//";c&&!(h&&Tl[h])&&(a=a.substr(2),this.slashes=!0)}if(!Tl[h]&&(c||h&&!ss[h])){for(var d=-1,p=0;p<rf.length;p++){var f=a.indexOf(rf[p]);f!==-1&&(d===-1||f<d)&&(d=f)}var m,y;d===-1?y=a.lastIndexOf("@"):y=a.lastIndexOf("@",d),y!==-1&&(m=a.slice(0,y),a=a.slice(y+1),this.auth=decodeURIComponent(m)),d=-1;for(var p=0;p<ef.length;p++){var f=a.indexOf(ef[p]);f!==-1&&(d===-1||f<d)&&(d=f)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var _=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!_)for(var v=this.hostname.split(/\./),p=0,g=v.length;p<g;p++){var x=v[p];if(x&&!x.match(sf)){for(var E="",w=0,A=x.length;w<A;w++)x.charCodeAt(w)>127?E+="x":E+=x[w];if(!E.match(sf)){var R=v.slice(0,p),M=v.slice(p+1),D=x.match(Nb);D&&(R.push(D[1]),M.unshift(D[2])),M.length&&(a="/"+M.join(".")+a),this.hostname=R.join(".");break}}}this.hostname.length>Pb?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=Sb.toASCII(this.hostname));var U=this.port?":"+this.port:"",C=this.hostname||"";this.host=C+U,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Lb[u])for(var p=0,g=El.length;p<g;p++){var T=El[p];if(a.indexOf(T)!==-1){var I=encodeURIComponent(T);I===T&&(I=escape(T)),a=a.split(T).join(I)}}var N=a.indexOf("#");N!==-1&&(this.hash=a.substr(N),a=a.slice(0,N));var O=a.indexOf("?");if(O!==-1?(this.search=a.substr(O),this.query=a.substr(O+1),t&&(this.query=wl.parse(this.query)),a=a.slice(0,O)):t&&(this.search="",this.query={}),a&&(this.pathname=a),ss[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var U=this.pathname||"",L=this.search||"";this.path=U+L}return this.href=this.format(),this},Rr.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=wl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||ss[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i},Rr.prototype.resolve=function(r){return this.resolveObject(Db(r,!1,!0)).format()},Rr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Rr;t.parse(r,!1,!0),r=t}for(var e=new Rr,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return ss[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(!ss[r.protocol]){for(var h=Object.keys(r),u=0;u<h.length;u++){var c=h[u];e[c]=r[c]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Tl[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",p=e.search||"";e.path=d+p}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var f=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",y=m||f||e.host&&r.pathname,_=y,v=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!ss[e.protocol];if(x&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),y=y&&(g[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=g;else if(g.length)v||(v=[]),v.pop(),v=v.concat(g),e.search=r.search,e.query=r.query;else if(r.search!=null){if(x){e.host=v.shift(),e.hostname=e.host;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.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 w=v.slice(-1)[0],A=(e.host||r.host||v.length>1)&&(w==="."||w==="..")||w==="",R=0,M=v.length;M>=0;M--)w=v[M],w==="."?v.splice(M,1):w===".."?(v.splice(M,1),R++):R&&(v.splice(M,1),R--);if(!y&&!_)for(;R--;R)v.unshift("..");y&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),A&&v.join("/").substr(-1)!=="/"&&v.push("");var D=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=D?"":v.length?v.shift():"",e.host=e.hostname;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.shift(),e.host=e.hostname)}return y=y||e.host&&v.length,y&&!D&&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},Rr.prototype.parseHost=function(){var r=this.host,t=Ib.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 nf={};function bt(r,t,e=3){if(nf[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
1
+ (function(Zt,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],Se):(Zt=typeof globalThis<"u"?globalThis:Zt||self,Se(Zt.AnnotoriousOSD={},Zt.OpenSeadragon))})(this,function(Zt,Se){"use strict";var Q2=Object.defineProperty;var J2=(Zt,Se,di)=>Se in Zt?Q2(Zt,Se,{enumerable:!0,configurable:!0,writable:!0,value:di}):Zt[Se]=di;var $t=(Zt,Se,di)=>J2(Zt,typeof Se!="symbol"?Se+"":Se,di);var di=Object.prototype.hasOwnProperty;function fi(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--&&fi(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(di.call(r,e)&&++i&&!di.call(t,e)||!(e in t)||!fi(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var ra=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ra||{});const ve=[];for(let r=0;r<256;++r)ve.push((r+256).toString(16).slice(1));function Fg(r,t=0){return(ve[r[t+0]]+ve[r[t+1]]+ve[r[t+2]]+ve[r[t+3]]+"-"+ve[r[t+4]]+ve[r[t+5]]+"-"+ve[r[t+6]]+ve[r[t+7]]+"-"+ve[r[t+8]]+ve[r[t+9]]+"-"+ve[r[t+10]]+ve[r[t+11]]+ve[r[t+12]]+ve[r[t+13]]+ve[r[t+14]]+ve[r[t+15]]).toLowerCase()}let ia;const Ug=new Uint8Array(16);function kg(){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(Ug)}const Gg=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),hu={randomUUID:Gg};function Hg(r,t,e){var i;if(hu.randomUUID&&!r)return hu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??kg();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Fg(s)}const sa=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)}},$g=(r,t,e,i)=>({id:Hg(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),Xg=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Vg=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},zg=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!fi(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Yg=(r,t)=>!fi(r.target,t.target),jg=(r,t)=>{const e=Xg(r,t),i=Vg(r,t),s=zg(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:Yg(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Hr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Hr||{});const Wg=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return jg(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let qg=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const Kg=250,Zg=(r,t)=>{const e=qg(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,_=performance.now();if(_-o>Kg)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=Wg(i[y],m)}o=_}n=!1};r.observe(a,{origin:Hr.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f),h=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:_}=i[s+1];h(f),c(m),p(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:_}=i[s];l(f),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},Qg=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},p=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},f=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),M=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,M)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!fi(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:E})=>E===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!fi(g,v)&&f("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!fi(E,x)&&f("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?f("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>f("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(g||[]).forEach(x=>f("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const M=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?E:S),f("updateAnnotation",E,M)})},{origin:Hr.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(M=>M.id===x.id)||x))}},{origin:Hr.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:p,emit:f}},Jg=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),ty=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,Hr.REMOTE):console.error(g)}else i.addAnnotation(sa(y),Hr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(p(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},p=(y,v=!0)=>{if(e){const g=e.parseAll||Jg(e),{parsed:x,failed:E}=g(y);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,Hr.REMOTE)}else i.bulkAddAnnotations(y.map(sa),v,Hr.REMOTE)},f=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(sa(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},ey="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ry=r=>crypto.getRandomValues(new Uint8Array(r)),iy=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},sy=(r,t=21)=>iy(r,t|0,ry),ny=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=ey[e[r]&63];return t};const oy=()=>({isGuest:!0,id:sy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),ay=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],ly=()=>{const r=[...ay];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};ny();var hy=Object.defineProperty,uy=(r,t,e)=>t in r?hy(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xt=(r,t,e)=>uy(r,typeof t!="symbol"?t+"":t,e);function Dt(){}function na(r,t){for(const e in t)r[e]=t[e];return r}function uu(r){return r()}function cu(){return Object.create(null)}function $e(r){r.forEach(uu)}function Vt(r){return typeof r=="function"}function le(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function cy(r){return Object.keys(r).length===0}function du(r,...t){if(r==null){for(const i of t)i(void 0);return Dt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function oa(r,t,e){r.$$.on_destroy.push(du(t,e))}function dy(r,t,e,i){if(r){const s=fu(r,t,e,i);return r[0](s)}}function fu(r,t,e,i){return r[1]&&i?na(e.ctx.slice(),r[1](i(t))):e.ctx}function fy(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function py(r,t,e,i,s,n){if(s){const o=fu(t,e,i,n);r.p(o,s)}}function my(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 bn(r){return r??""}function Et(r,t){r.appendChild(t)}function it(r,t,e){r.insertBefore(t,e||null)}function rt(r){r.parentNode&&r.parentNode.removeChild(r)}function pi(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function K(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function mu(r){return document.createTextNode(r)}function Oe(){return mu(" ")}function Fe(){return mu("")}function Rt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function b(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function gy(r){return Array.from(r.childNodes)}function cr(r,t,e){r.classList.toggle(t,!!e)}function yy(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Ms;function Ps(r){Ms=r}function gu(){if(!Ms)throw new Error("Function called outside component initialization");return Ms}function mi(r){gu().$$.on_mount.push(r)}function $r(){const r=gu();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=yy(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ce(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Gi=[],En=[];let Hi=[];const yu=[],_u=Promise.resolve();let aa=!1;function vu(){aa||(aa=!0,_u.then(bu))}function xu(){return vu(),_u}function la(r){Hi.push(r)}const ha=new Set;let $i=0;function bu(){if($i!==0)return;const r=Ms;do{try{for(;$i<Gi.length;){const t=Gi[$i];$i++,Ps(t),_y(t.$$)}}catch(t){throw Gi.length=0,$i=0,t}for(Ps(null),Gi.length=0,$i=0;En.length;)En.pop()();for(let t=0;t<Hi.length;t+=1){const e=Hi[t];ha.has(e)||(ha.add(e),e())}Hi.length=0}while(Gi.length);for(;yu.length;)yu.pop()();aa=!1,ha.clear(),Ps(r)}function _y(r){if(r.fragment!==null){r.update(),$e(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(la)}}function vy(r){const t=[],e=[];Hi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Hi=t}const Tn=new Set;let gi;function Ie(){gi={r:0,c:[],p:gi}}function Re(){gi.r||$e(gi.c),gi=gi.p}function ot(r,t){r&&r.i&&(Tn.delete(r),r.i(t))}function mt(r,t,e,i){if(r&&r.o){if(Tn.has(r))return;Tn.add(r),gi.c.push(()=>{Tn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ue(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function xe(r){r&&r.c()}function ce(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),la(()=>{const n=r.$$.on_mount.map(uu).filter(Vt);r.$$.on_destroy?r.$$.on_destroy.push(...n):$e(n),r.$$.on_mount=[]}),s.forEach(la)}function de(r,t){const e=r.$$;e.fragment!==null&&(vy(e.after_update),$e(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function xy(r,t){r.$$.dirty[0]===-1&&(Gi.push(r),vu(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Ne(r,t,e,i,s,n,o=null,a=[-1]){const l=Ms;Ps(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Dt,not_equal:s,bound:cu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:cu(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&xy(r,c)),d}):[],h.update(),u=!0,$e(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=gy(t.target);h.fragment&&h.fragment.l(c),c.forEach(rt)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),ce(r,t.target,t.anchor),bu()}Ps(l)}class De{constructor(){Xt(this,"$$"),Xt(this,"$$set")}$destroy(){de(this,1),this.$destroy=Dt}$on(t,e){if(!Vt(e))return Dt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!cy(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const by="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(by);var At=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(At||{});const ua={},wn=(r,t)=>ua[r]=t,ca=r=>ua[r.type].area(r),Ey=(r,t,e)=>ua[r.type].intersects(r,t,e),ke=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},da=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)},fa=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},Ty=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},wy={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};wn(At.ELLIPSE,wy);const Ay={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=da(s.points),a=n.reduce((l,h)=>l+da(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(fa(n.points,t,e)){let a=!1;for(const l of o)if(fa(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},pa=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return ke(t)},Ke=r=>r.rings.map(t=>Ty(t.points)).join(" "),Sy=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]);wn(At.MULTIPOLYGLON,Ay);const Cy={area:r=>{const t=r.geometry.points;return da(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return fa(i,t,e)}};wn(At.POLYGON,Cy);const Iy={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};wn(At.RECTANGLE,Iy);const Ze=r=>An(r.target),An=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},Ry=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,u,c]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,p,f,m]=[l,h,u,c].map(parseFloat);return{type:At.RECTANGLE,geometry:{x:d,y:p,w:f,h:m,bounds:{minX:d,minY:t?p-m:p,maxX:d+f,maxY:t?p:p+m}}}},My=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Eu="http://www.w3.org/2000/svg",Tu=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Py=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Eu}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},wu=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Eu),i=t.lookupNamespaceURI(null);return e||i?Tu(t).firstChild:Tu(Py(t)).firstChild},ee=" ";function Oy(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===G.CLOSE_PATH)t+="z";else if(i.type===G.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===G.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===G.MOVE_TO)t+=(i.relative?"m":"M")+i.x+ee+i.y;else if(i.type===G.LINE_TO)t+=(i.relative?"l":"L")+i.x+ee+i.y;else if(i.type===G.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+ee+i.y1+ee+i.x2+ee+i.y2+ee+i.x+ee+i.y;else if(i.type===G.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+ee+i.y2+ee+i.x+ee+i.y;else if(i.type===G.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+ee+i.y1+ee+i.x+ee+i.y;else if(i.type===G.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+ee+i.y;else if(i.type===G.ARC)t+=(i.relative?"a":"A")+i.rX+ee+i.rY+ee+i.xRot+ee+ +i.lArcFlag+ee+ +i.sweepFlag+ee+i.x+ee+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function ma([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function Qe(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const Xr=Math.PI;function ga(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*Xr,[l,h]=ma([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),p=i*h/s*d,f=-s*l/i*d,m=ma([p,f],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-f)/s,(l-p)/i),r.phi2=Math.atan2((-h-f)/s,(-l-p)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*Xr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Xr),r.phi1*=180/Xr,r.phi2*=180/Xr}function Au(r,t,e){Qe(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const yi=Math.PI/180;function Su(r,t,e){return(1-e)*r+e*t}function Cu(r,t,e,i){return r+Math.cos(i/180*Xr)*t+Math.sin(i/180*Xr)*e}function Iu(r,t,e,i){const s=t-r,n=e-t,o=i-e,a=3*s+3*o-6*n,l=(n-s)*6,h=3*s;return Math.abs(a)<1e-6?Math.abs(l)<1e-6?[]:[-h/l]:Ny(l/a,h/a,1e-6)}function Ru(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function Ny(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function Dy(r,t,e){r.cX||ga(r,t,e);const i=r.xRot/180*Xr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:G.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,p)=>{const[f,m]=ma([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=Su(r.phi1,r.phi2,d/a),f=Su(r.phi1,r.phi2,(d+1)/a),m=f-p,_=4/3*Math.tan(m*yi/4),y=Math.cos(p*yi)-_*Math.sin(p*yi),v=Math.sin(p*yi)+_*Math.cos(p*yi),g=Math.cos(f*yi),x=Math.sin(f*yi),E=g+_*x,M=x-_*g,S=c(y,v),R=c(E,M),P=c(g,x),F={relative:r.relative,type:G.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:R[0],y2:R[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function ya(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const l=i*n+s*o,h=i*i+s*s,u=n*n+o*o;return 0<=l&&l<=u&&h<=u}function Ly(r,t=!0){if(r.length<2)return r;const e=re.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===G.MOVE_TO&&s.length>0&&(t?i.push(...Sn(s)):i.unshift(...Sn(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Sn(s)):i.unshift(...Sn(s))),i}function Sn(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===G.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:G.MOVE_TO,relative:!1,x:r[i].x,y:r[i].y}];for(let n=i;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case G.HORIZ_LINE_TO:s.push({type:G.HORIZ_LINE_TO,relative:!1,x:a.x});break;case G.VERT_LINE_TO:s.push({type:G.VERT_LINE_TO,relative:!1,y:a.y});break;case G.LINE_TO:case G.MOVE_TO:s.push({type:G.LINE_TO,relative:!1,x:a.x,y:a.y});break;case G.CURVE_TO:s.push({type:G.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case G.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case G.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case G.ARC:throw new Error("Unsupported command: A (arc)");case G.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:G.CLOSE_PATH}),s}function By(r=1e13){Qe(r);function t(e){return Math.round(e*r)/r}return function(e){return"x1"in e&&typeof e.x1<"u"&&(e.x1=t(e.x1)),"y1"in e&&typeof e.y1<"u"&&(e.y1=t(e.y1)),"x2"in e&&typeof e.x2<"u"&&(e.x2=t(e.x2)),"y2"in e&&typeof e.y2<"u"&&(e.y2=t(e.y2)),"x"in e&&typeof e.x<"u"&&(e.x=t(e.x)),"y"in e&&typeof e.y<"u"&&(e.y=t(e.y)),"rX"in e&&typeof e.rX<"u"&&(e.rX=t(e.rX)),"rY"in e&&typeof e.rY<"u"&&(e.rY=t(e.rY)),e}}function Mu(){return Je((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function Fy(){return Je((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function Uy(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&G.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&G.HORIZ_LINE_TO&&(s.type=G.LINE_TO,s.y=s.relative?0:o),e&&s.type&G.VERT_LINE_TO&&(s.type=G.LINE_TO,s.x=s.relative?0:n),r&&s.type&G.CLOSE_PATH&&(s.type=G.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&G.ARC&&(s.rX===0||s.rY===0)&&(s.type=G.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&G.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];ya(h,u,c)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&G.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];ya(h,u,d)&&ya(h,c,d)&&(s.type=G.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Pu(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&G.SMOOTH_CURVE_TO&&(s.type=G.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&G.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&G.SMOOTH_QUAD_TO&&(s.type=G.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&G.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Ou(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&G.SMOOTH_QUAD_TO&&(e.type=G.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&G.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=G.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function Je(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&G.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&G.CLOSE_PATH&&(t=i,e=s),"x"in n&&typeof n.x<"u"&&(t=n.relative?t+n.x:n.x),"y"in n&&typeof n.y<"u"&&(e=n.relative?e+n.y:n.y),n.type&G.MOVE_TO&&(i=t,s=e),o}}function ky(r=0){Qe(r);let t=NaN,e=NaN,i=NaN,s=NaN;return Je((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&G.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(G.CURVE_TO|G.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&G.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&G.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&G.LINE_COMMANDS||n.type&G.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&G.CURVE_TO||n.type&G.SMOOTH_CURVE_TO||n.type&G.QUAD_TO||n.type&G.SMOOTH_QUAD_TO){const f=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,p=isNaN(s)?typeof n.y1>"u"?p:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(f)<=r&&u(m)<=r&&u(d)<=r&&u(p)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&G.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Vr(r,t,e,i,s,n){return Qe(r,t,e,i,s,n),Je((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),p=typeof o.x<"u"?o.x:d?0:a,f=typeof o.y<"u"?o.y:d?0:l;o.type&G.HORIZ_LINE_TO&&t!==0&&(o.type=G.LINE_TO,o.y=o.relative?0:l),o.type&G.VERT_LINE_TO&&e!==0&&(o.type=G.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+f*e+(d?0:s)),typeof o.y<"u"&&(o.y=p*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=G.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),E=1/m(o.rY),M=m(g)*x+m(v)*E,S=2*v*g*(x-E),R=m(v)*x+m(g)*E,P=M*i*i-S*t*i+R*t*t,F=S*(r*i+t*e)-2*(M*e*i+R*r*t),k=M*e*e-S*r*e+R*r*r,I=(Math.atan2(F,P-k)+Math.PI)%Math.PI/2,A=Math.sin(I),T=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(T)+F*A*T+k*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*T+k*m(T)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function Gy(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Vr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Hy(r,t=0){return Qe(r,t),Vr(1,0,0,1,r,t)}function $y(r,t=r){return Qe(r,t),Vr(r,0,0,t,0,0)}function Xy(r){return Qe(r),Vr(1,0,Math.tan(r),1,0,0)}function Vy(r){return Qe(r),Vr(1,Math.tan(r),0,1,0,0)}function zy(r=0){return Qe(r),Vr(-1,0,0,1,r,0)}function Yy(r=0){return Qe(r),Vr(1,0,0,-1,0,r)}function jy(){return Je((r,t,e)=>G.ARC===r.type?Dy(r,r.relative?0:t,r.relative?0:e):r)}function Wy(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),G.ARC===r.type&&ga(r,t,e),r))}function Nu(){return r=>({...r})}function qy(){const r=Nu(),t=Mu(),e=Ou(),i=Pu(),s=Je((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&G.DRAWING_COMMANDS&&(h(o),u(a)),l.type&G.HORIZ_LINE_TO&&h(l.x),l.type&G.VERT_LINE_TO&&u(l.y),l.type&G.LINE_TO&&(h(l.x),u(l.y)),l.type&G.CURVE_TO){h(l.x),u(l.y);const c=Iu(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(Ru(o,l.x1,l.x2,l.x,p));const d=Iu(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(Ru(a,l.y1,l.y2,l.y,p))}if(l.type&G.ARC){h(l.x),u(l.y),ga(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,p=Math.sin(c)*l.rX,f=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,M])=>{const S=Math.atan2(M,E)*180/Math.PI;return S<_?S+360:S},g=Au(f,-d,0).map(v);for(const E of g)E>_&&E<y&&h(Cu(l.cX,d,f,E));const x=Au(m,-p,0).map(v);for(const E of x)E>_&&E<y&&u(Cu(l.cY,p,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const re={ROUND:By,TO_ABS:Mu,TO_REL:Fy,NORMALIZE_HVZ:Uy,NORMALIZE_ST:Pu,QT_TO_C:Ou,INFO:Je,SANITIZE:ky,MATRIX:Vr,ROTATE:Gy,TRANSLATE:Hy,SCALE:$y,SKEW_X:Xy,SKEW_Y:Vy,X_AXIS_SYMMETRY:zy,Y_AXIS_SYMMETRY:Yy,A_TO_C:jy,ANNOTATE_ARCS:Wy,CLONE:Nu,CALCULATE_BOUNDS:qy,REVERSE_PATH:Ly};class Du{round(t){return this.transform(re.ROUND(t))}toAbs(){return this.transform(re.TO_ABS())}toRel(){return this.transform(re.TO_REL())}normalizeHVZ(t,e,i){return this.transform(re.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(re.NORMALIZE_ST())}qtToC(){return this.transform(re.QT_TO_C())}aToC(){return this.transform(re.A_TO_C())}sanitize(t){return this.transform(re.SANITIZE(t))}translate(t,e){return this.transform(re.TRANSLATE(t,e))}scale(t,e){return this.transform(re.SCALE(t,e))}rotate(t,e,i){return this.transform(re.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(re.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(re.SKEW_X(t))}skewY(t){return this.transform(re.SKEW_Y(t))}xSymmetry(t){return this.transform(re.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(re.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(re.ANNOTATE_ARCS())}}const Ky=r=>r===" "||r===" "||r==="\r"||r===`
2
+ `,Lu=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class Zy extends Du{constructor(){super(),Xt(this,"curNumber",""),Xt(this,"curCommandType",-1),Xt(this,"curCommandRelative",!1),Xt(this,"canParseCommandOrComma",!0),Xt(this,"curNumberHasExp",!1),Xt(this,"curNumberHasExpDigits",!1),Xt(this,"curNumberHasDecimal",!1),Xt(this,"curArgs",[])}finish(t=[]){if(this.parse(" ",t),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t}parse(t,e=[]){const i=s=>{e.push(s),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let s=0;s<t.length;s++){const n=t[s],o=this.curCommandType===G.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=Lu(n)&&(this.curNumber==="0"&&n==="0"||o);if(Lu(n)&&!a){this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(n==="e"||n==="E"){this.curNumber+=n,this.curNumberHasExp=!0;continue}if((n==="-"||n==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=n;continue}if(n==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!o){this.curNumber+=n,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError(`Invalid number ending at ${s}`);if(this.curCommandType===G.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>l)throw new SyntaxError(`Expected positive number, got "${l}" at index "${s}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${s}"`)}this.curArgs.push(l),this.curArgs.length===Qy[this.curCommandType]&&(G.HORIZ_LINE_TO===this.curCommandType?i({type:G.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):G.VERT_LINE_TO===this.curCommandType?i({type:G.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===G.MOVE_TO||this.curCommandType===G.LINE_TO||this.curCommandType===G.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),G.MOVE_TO===this.curCommandType&&(this.curCommandType=G.LINE_TO)):this.curCommandType===G.CURVE_TO?i({type:G.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===G.SMOOTH_CURVE_TO?i({type:G.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.QUAD_TO?i({type:G.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===G.ARC&&i({type:G.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!Ky(n)){if(n===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(n==="+"||n==="-"||n==="."){this.curNumber=n,this.curNumberHasDecimal=n===".";continue}if(a){this.curNumber=n,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${s}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${n}" at index ${s}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,n==="z"||n==="Z"){e.push({type:G.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=G.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=G.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=G.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=G.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=G.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=G.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=G.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=G.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=G.ARC,this.curCommandRelative=n==="a";else throw new SyntaxError(`Unexpected character "${n}" at index ${s}.`)}}return e}transform(t){return Object.create(this,{parse:{value(e,i=[]){const s=Object.getPrototypeOf(this).parse.call(this,e);for(const n of s){const o=t(n);Array.isArray(o)?i.push(...o):i.push(o)}return i}}})}}const Gt=class eu extends Du{constructor(t){super(),Xt(this,"commands"),typeof t=="string"?this.commands=eu.parse(t):this.commands=t}encode(){return eu.encode(this.commands)}getBounds(){const t=re.CALCULATE_BOUNDS();return this.transform(t),t}transform(t){const e=[];for(const i of this.commands){const s=t(i);Array.isArray(s)?e.push(...s):e.push(s)}return this.commands=e,this}reverse(t=!0){return this.commands=re.REVERSE_PATH(this.commands,t),this}static encode(t){return Oy(t)}static parse(t){const e=new Zy,i=[];return e.parse(t,i),e.finish(i),i}};Xt(Gt,"CLOSE_PATH",1),Xt(Gt,"MOVE_TO",2),Xt(Gt,"HORIZ_LINE_TO",4),Xt(Gt,"VERT_LINE_TO",8),Xt(Gt,"LINE_TO",16),Xt(Gt,"CURVE_TO",32),Xt(Gt,"SMOOTH_CURVE_TO",64),Xt(Gt,"QUAD_TO",128),Xt(Gt,"SMOOTH_QUAD_TO",256),Xt(Gt,"ARC",512),Xt(Gt,"LINE_COMMANDS",Gt.LINE_TO|Gt.HORIZ_LINE_TO|Gt.VERT_LINE_TO),Xt(Gt,"DRAWING_COMMANDS",Gt.HORIZ_LINE_TO|Gt.VERT_LINE_TO|Gt.LINE_TO|Gt.CURVE_TO|Gt.SMOOTH_CURVE_TO|Gt.QUAD_TO|Gt.SMOOTH_QUAD_TO|Gt.ARC);let G=Gt;const Qy={[G.MOVE_TO]:2,[G.LINE_TO]:2,[G.HORIZ_LINE_TO]:1,[G.VERT_LINE_TO]:1,[G.CLOSE_PATH]:0,[G.QUAD_TO]:4,[G.SMOOTH_QUAD_TO]:2,[G.CURVE_TO]:6,[G.SMOOTH_CURVE_TO]:4,[G.ARC]:7},Jy=r=>{const t=new G(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case G.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case G.LINE_TO:i.push([n.x,n.y]);break;case G.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case G.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case G.CURVE_TO:case G.SMOOTH_CURVE_TO:case G.QUAD_TO:case G.SMOOTH_QUAD_TO:case G.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=ke(e[0].points);return{rings:e,bounds:n}}},t_=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:At.POLYGON,geometry:{points:s,bounds:ke(s)}}},e_=r=>{const t=wu(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:At.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},r_=r=>{const t=wu(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>Jy(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=ke(i);return e.length===1&&e[0].rings.length===1?{type:At.POLYGON,geometry:{points:i,bounds:s}}:{type:At.MULTIPOLYGLON,geometry:{polygons:e,bounds:s}}},i_=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return t_(t);if(t.includes("<path "))return r_(t);if(t.includes("<ellipse "))return e_(t);throw"Unsupported SVG shape: "+t},s_=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${Ke(t)}" />`).join("")}</g>`,n_=r=>{let t;if(r.type===At.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===At.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}else if(r.type===At.MULTIPOLYGLON){const e=r.geometry;t=`<svg>${s_(e)}</svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},be=[];for(let r=0;r<256;++r)be.push((r+256).toString(16).slice(1));function o_(r,t=0){return(be[r[t+0]]+be[r[t+1]]+be[r[t+2]]+be[r[t+3]]+"-"+be[r[t+4]]+be[r[t+5]]+"-"+be[r[t+6]]+be[r[t+7]]+"-"+be[r[t+8]]+be[r[t+9]]+"-"+be[r[t+10]]+be[r[t+11]]+be[r[t+12]]+be[r[t+13]]+be[r[t+14]]+be[r[t+15]]).toLowerCase()}let _a;const a_=new Uint8Array(16);function l_(){if(!_a){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");_a=crypto.getRandomValues.bind(crypto)}return _a(a_)}const h_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Bu={randomUUID:h_};function Fu(r,t,e){var i;if(Bu.randomUUID&&!r)return Bu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??l_();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,o_(s)}var Uu=Object.prototype.hasOwnProperty;function zr(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--&&zr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Uu.call(r,e)&&++i&&!Uu.call(t,e)||!(e in t)||!zr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function va(){}function u_(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const Xi=[];function xa(r,t=va){let e;const i=new Set;function s(a){if(u_(r,a)&&(r=a,e)){const l=!Xi.length;for(const h of i)h[1](),Xi.push(h,r);if(l){for(let h=0;h<Xi.length;h+=2)Xi[h][0](Xi[h+1]);Xi.length=0}}}function n(a){s(a(r))}function o(a,l=va){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||va),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const c_=r=>{const{subscribe:t,set:e}=xa();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var ku=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ku||{});const Cn={selected:[]},d_=(r,t,e)=>{const{subscribe:i,set:s}=xa(Cn);let n=t,o=Cn;i(f=>o=f);const a=()=>{zr(o,Cn)||s(Cn)},l=()=>{var f;return((f=o.selected)==null?void 0:f.length)===0},h=f=>{if(l())return!1;const m=typeof f=="string"?f:f.id;return o.selected.some(_=>_.id===m)},u=(f,m)=>{let _;if(Array.isArray(f)){if(_=f.map(v=>r.getAnnotation(v)).filter(Boolean),_.length<f.length){console.warn("Invalid selection: "+f.filter(v=>!_.some(g=>g.id===v)));return}}else{const v=r.getAnnotation(f);if(!v){console.warn("Invalid selection: "+f);return}_=[v]}const y=_.reduce((v,g)=>{const x=Gu(g,n,e);return x==="EDIT"?[...v,{id:g.id,editable:!0}]:x==="SELECT"?[...v,{id:g.id}]:v},[]);s({selected:y,event:m})},c=(f,m)=>{const _=Array.isArray(f)?f:[f],y=_.map(v=>r.getAnnotation(v)).filter(v=>!!v);s({selected:y.map(v=>{const g=m===void 0?Gu(v,n,e)==="EDIT":m;return{id:v.id,editable:g}})}),y.length!==_.length&&console.warn("Invalid selection",f)},d=f=>{if(l())return!1;const{selected:m}=o;m.some(({id:_})=>f.includes(_))&&s({selected:m.filter(({id:_})=>!f.includes(_))})},p=f=>{n=f,c(o.selected.map(({id:m})=>m))};return r.observe(({changes:f})=>d((f.deleted||[]).map(m=>m.id))),{get event(){return o?o.event:null},get selected(){return o?[...o.selected]:null},get userSelectAction(){return n},clear:a,isEmpty:l,isSelected:h,setSelected:c,setUserSelectAction:p,subscribe:i,userSelect:u}},Gu=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},Ee=[];for(let r=0;r<256;++r)Ee.push((r+256).toString(16).slice(1));function f_(r,t=0){return(Ee[r[t+0]]+Ee[r[t+1]]+Ee[r[t+2]]+Ee[r[t+3]]+"-"+Ee[r[t+4]]+Ee[r[t+5]]+"-"+Ee[r[t+6]]+Ee[r[t+7]]+"-"+Ee[r[t+8]]+Ee[r[t+9]]+"-"+Ee[r[t+10]]+Ee[r[t+11]]+Ee[r[t+12]]+Ee[r[t+13]]+Ee[r[t+14]]+Ee[r[t+15]]).toLowerCase()}let ba;const p_=new Uint8Array(16);function m_(){if(!ba){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ba=crypto.getRandomValues.bind(crypto)}return ba(p_)}const g_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Hu={randomUUID:g_};function y_(r,t,e){var i;if(Hu.randomUUID&&!r)return Hu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??m_();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,f_(s)}const Ea=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)}},__=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},v_=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},x_=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!zr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),b_=(r,t)=>!zr(r.target,t.target),$u=(r,t)=>{const e=__(r,t),i=v_(r,t),s=x_(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:b_(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Bt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Bt||{});const E_=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(r.options.origin?r.options.origin===n:n!=="SILENT"))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(u=>u.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},T_=(r,t)=>{const e=new Set((r.created||[]).map(c=>c.id)),i=new Set((r.updated||[]).map(({newValue:c})=>c.id)),s=new Set((t.created||[]).map(c=>c.id)),n=new Set((t.deleted||[]).map(c=>c.id)),o=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>e.has(c.id)||i.has(c.id)).map(({oldValue:c})=>c.id)),l=[...(r.created||[]).filter(c=>!n.has(c.id)).map(c=>o.has(c.id)?t.updated.find(({oldValue:d})=>d.id===c.id).newValue:c),...t.created||[]],h=[...(r.deleted||[]).filter(c=>!s.has(c.id)),...(t.deleted||[]).filter(c=>!e.has(c.id))],u=[...(r.updated||[]).filter(({newValue:c})=>!n.has(c.id)).map(c=>{const{oldValue:d,newValue:p}=c;if(o.has(p.id)){const f=t.updated.find(m=>m.oldValue.id===p.id).newValue;return $u(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},In=r=>{const t=r.id===void 0?y_():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},w_=r=>r.id!==void 0,A_=()=>{const r=new Map,t=new Map,e=[],i=(I,A={})=>{e.push({onChange:I,options:A})},s=I=>{const A=e.findIndex(T=>T.onChange==I);A>-1&&e.splice(A,1)},n=(I,A)=>{const T={origin:I,changes:{created:A.created||[],updated:A.updated||[],deleted:A.deleted||[]},state:[...r.values()]};e.forEach(C=>{E_(C,T)&&C.onChange(T)})},o=(I,A=Bt.LOCAL)=>{if(I.id&&r.get(I.id))throw Error(`Cannot add annotation ${I.id} - exists already`);{const T=In(I);r.set(T.id,T),T.bodies.forEach(C=>t.set(C.id,T.id)),n(A,{created:[T]})}},a=(I,A)=>{const T=In(typeof I=="string"?A:I),C=typeof I=="string"?I:I.id,L=C&&r.get(C);if(L){const N=$u(L,T);return C===T.id?r.set(C,T):(r.delete(C),r.set(T.id,T)),L.bodies.forEach(B=>t.delete(B.id)),T.bodies.forEach(B=>t.set(B.id,T.id)),N}else console.warn(`Cannot update annotation ${C} - does not exist`)},l=(I,A=Bt.LOCAL,T=Bt.LOCAL)=>{const C=w_(A)?T:A,L=a(I,A);L&&n(C,{updated:[L]})},h=(I,A=Bt.LOCAL)=>{r.get(I.id)?l(I,A):o(I,A)},u=(I,A=Bt.LOCAL)=>{const T=I.reduce((C,L)=>{const N=a(L);return N?[...C,N]:C},[]);T.length>0&&n(A,{updated:T})},c=(I,A=Bt.LOCAL)=>{const T=I.map(In),{toAdd:C,toUpdate:L}=T.reduce((B,X)=>r.get(X.id)?{...B,toUpdate:[...B.toUpdate,X]}:{...B,toAdd:[...B.toAdd,X]},{toAdd:[],toUpdate:[]}),N=L.map(B=>a(B,A)).filter(Boolean);C.forEach(B=>{r.set(B.id,B),B.bodies.forEach(X=>t.set(X.id,B.id))}),n(A,{created:C,updated:N})},d=(I,A=Bt.LOCAL)=>{const T=r.get(I.annotation);if(T){const C={...T,bodies:[...T.bodies,I]};r.set(T.id,C),t.set(I.id,C.id),n(A,{updated:[{oldValue:T,newValue:C,bodiesCreated:[I]}]})}else console.warn(`Attempt to add body to missing annotation: ${I.annotation}`)},p=()=>[...r.values()],f=(I=Bt.LOCAL)=>{const A=[...r.values()];r.clear(),t.clear(),n(I,{deleted:A})},m=(I,A=!0,T=Bt.LOCAL)=>{const C=I.map(In);if(A){const L=[...r.values()];r.clear(),t.clear(),C.forEach(N=>{r.set(N.id,N),N.bodies.forEach(B=>t.set(B.id,N.id))}),n(T,{created:C,deleted:L})}else{const L=I.reduce((N,B)=>{const X=B.id&&r.get(B.id);return X?[...N,X]:N},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(N=>N.id).join(", ")}`);C.forEach(N=>{r.set(N.id,N),N.bodies.forEach(B=>t.set(B.id,N.id))}),n(T,{created:C})}},_=I=>{const A=typeof I=="string"?I:I.id,T=r.get(A);if(T)return r.delete(A),T.bodies.forEach(C=>t.delete(C.id)),T;console.warn(`Attempt to delete missing annotation: ${A}`)},y=(I,A=Bt.LOCAL)=>{const T=_(I);T&&n(A,{deleted:[T]})},v=(I,A=Bt.LOCAL)=>{const T=I.reduce((C,L)=>{const N=_(L);return N?[...C,N]:C},[]);T.length>0&&n(A,{deleted:T})},g=I=>{const A=r.get(I.annotation);if(A){const T=A.bodies.find(C=>C.id===I.id);if(T){t.delete(T.id);const C={...A,bodies:A.bodies.filter(L=>L.id!==I.id)};return r.set(A.id,C),{oldValue:A,newValue:C,bodiesDeleted:[T]}}else console.warn(`Attempt to delete missing body ${I.id} from annotation ${I.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${I.annotation}`)},x=(I,A=Bt.LOCAL)=>{const T=g(I);T&&n(A,{updated:[T]})},E=(I,A=Bt.LOCAL)=>{const T=I.map(C=>g(C)).filter(Boolean);T.length>0&&n(A,{updated:T})},M=I=>{const A=r.get(I);return A?{...A}:void 0},S=I=>{const A=t.get(I);if(A){const T=M(A).bodies.find(C=>C.id===I);if(T)return T;console.error(`Store integrity error: body ${I} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${I}`)},R=(I,A)=>{if(I.annotation!==A.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const T=r.get(I.annotation);if(T){const C=T.bodies.find(N=>N.id===I.id),L={...T,bodies:T.bodies.map(N=>N.id===C.id?A:N)};return r.set(T.id,L),C.id!==A.id&&(t.delete(C.id),t.set(A.id,L.id)),{oldValue:T,newValue:L,bodiesUpdated:[{oldBody:C,newBody:A}]}}else console.warn(`Attempt to add body to missing annotation ${I.annotation}`)},P=(I,A,T=Bt.LOCAL)=>{const C=R(I,A);C&&n(T,{updated:[C]})},F=(I,A=Bt.LOCAL)=>{const T=I.map(C=>R({id:C.id,annotation:C.annotation},C)).filter(Boolean);n(A,{updated:T})},k=I=>{const A=r.get(I.annotation);if(A){const T={...A,target:{...A.target,...I}};return r.set(A.id,T),{oldValue:A,newValue:T,targetUpdated:{oldTarget:A.target,newTarget:I}}}else console.warn(`Attempt to update target on missing annotation: ${I.annotation}`)};return{addAnnotation:o,addBody:d,all:p,bulkAddAnnotations:m,bulkDeleteAnnotations:v,bulkDeleteBodies:E,bulkUpdateAnnotations:u,bulkUpdateBodies:F,bulkUpdateTargets:(I,A=Bt.LOCAL)=>{const T=I.map(C=>k(C)).filter(Boolean);T.length>0&&n(A,{updated:T})},bulkUpsertAnnotations:c,clear:f,deleteAnnotation:y,deleteBody:x,getAnnotation:M,getBody:S,observe:i,unobserve:s,updateAnnotation:l,updateBody:P,updateTarget:(I,A=Bt.LOCAL)=>{const T=k(I);T&&n(A,{updated:[T]})},upsertAnnotation:h}},S_=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let C_=()=>({emit(r,...t){for(let e=this.events[r]||[],i=0,s=e.length;i<s;i++)e[i](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const I_=250,R_=(r,t)=>{const e=C_(),i=(t==null?void 0:t.changes)||[];let s=t?t.pointer:-1,n=!1,o=0;const a=f=>{if(!n){const{changes:m}=f,_=performance.now();if(_-o>I_)i.splice(s+1),i.push(m),s=i.length-1;else{const y=i.length-1;i[y]=T_(i[y],m)}o=_}n=!1};r.observe(a,{origin:Bt.LOCAL});const l=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f),h=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),u=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({oldValue:m})=>m)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotations(f.map(({newValue:m})=>m)),d=f=>f&&f.length>0&&r.bulkAddAnnotations(f,!1),p=f=>f&&f.length>0&&r.bulkDeleteAnnotations(f);return{canRedo:()=>i.length-1>s,canUndo:()=>s>-1,destroy:()=>r.unobserve(a),getHistory:()=>({changes:[...i],pointer:s}),on:(f,m)=>e.on(f,m),redo:()=>{if(i.length-1>s){n=!0;const{created:f,updated:m,deleted:_}=i[s+1];h(f),c(m),p(_),e.emit("redo",i[s+1]),s+=1}},undo:()=>{if(s>-1){n=!0;const{created:f,updated:m,deleted:_}=i[s];l(f),u(m),d(_),e.emit("undo",i[s]),s-=1}}}},M_=()=>{const{subscribe:r,set:t}=xa([]);return{subscribe:r,set:t}},P_=(r,t,e,i)=>{const{hover:s,selection:n,store:o,viewport:a}=r,l=new Map;let h=[],u,c;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},p=(y,v)=>{const g=l.get(y);if(g){const x=g.indexOf(v);x!==-1&&g.splice(x,1)}},f=(y,v,g)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const E=Array.isArray(v)?v.map(S=>e.serialize(S)):e.serialize(v),M=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(E,M)}else x(v,g)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(E=>E.id===g.id);(!x||!zr(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:x})=>x===g.id)||g)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>o.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const g=o.getAnnotation(v.id);g&&!zr(g,v)&&f("updateAnnotation",g,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),g=new Set(y.map(({id:x})=>x));h.filter(x=>!g.has(x.id)).forEach(x=>{const E=o.getAnnotation(x.id);E&&!zr(E,x)&&f("updateAnnotation",E,x)}),h=[...h.filter(x=>g.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>o.getAnnotation(x))]}f("selectionChanged",h)}}),s.subscribe(y=>{!u&&y?f("mouseEnterAnnotation",o.getAnnotation(y)):u&&!y?f("mouseLeaveAnnotation",o.getAnnotation(u)):u&&y&&(f("mouseLeaveAnnotation",o.getAnnotation(u)),f("mouseEnterAnnotation",o.getAnnotation(y))),u=y}),a==null||a.subscribe(y=>f("viewportIntersect",y.map(v=>o.getAnnotation(v)))),o.observe(y=>{i&&(c&&clearTimeout(c),c=setTimeout(m,1e3));const{created:v,deleted:g}=y.changes;(v||[]).forEach(x=>f("createAnnotation",x)),(g||[]).forEach(x=>f("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:E})=>{const M=h.find(S=>S.id===x.id)||x;h=h.map(S=>S.id===x.id?E:S),f("updateAnnotation",E,M)})},{origin:Bt.LOCAL}),o.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),g=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);g.length>0&&(h=h.map(x=>g.find(E=>E.id===x.id)||x))}},{origin:Bt.REMOTE});const _=y=>v=>{const{updated:g}=v;y?(g||[]).forEach(x=>f("updateAnnotation",x.oldValue,x.newValue)):(g||[]).forEach(x=>f("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",_(!0)),t.on("redo",_(!1)),{on:d,off:p,emit:f}},O_=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),N_=(r,t,e)=>{const{store:i,selection:s}=r,n=y=>{if(e){const{parsed:v,error:g}=e.parse(y);v?i.addAnnotation(v,Bt.REMOTE):console.error(g)}else i.addAnnotation(Ea(y),Bt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=y=>{const v=i.getAnnotation(y);return e&&v?e.serialize(v):v},h=()=>e?i.all().map(e.serialize):i.all(),u=()=>{var y;const v=(((y=s.selected)==null?void 0:y.map(g=>g.id))||[]).map(g=>i.getAnnotation(g)).filter(Boolean);return e?v.map(e.serialize):v},c=(y,v=!0)=>fetch(y).then(g=>g.json()).then(g=>(p(g,v),g)),d=y=>{if(typeof y=="string"){const v=i.getAnnotation(y);if(i.deleteAnnotation(y),v)return e?e.serialize(v):v}else{const v=e?e.parse(y).parsed:y;if(v)return i.deleteAnnotation(v),y}},p=(y,v=!0)=>{if(e){const g=e.parseAll||O_(e),{parsed:x,failed:E}=g(y);E.length>0&&console.warn(`Discarded ${E.length} invalid annotations`,E),i.bulkAddAnnotations(x,v,Bt.REMOTE)}else i.bulkAddAnnotations(y.map(Ea),v,Bt.REMOTE)},f=(y,v)=>{y?s.setSelected(y,v):s.clear()},m=y=>{s.clear(),s.setUserSelectAction(y)},_=y=>{if(e){const v=e.parse(y).parsed,g=e.serialize(i.getAnnotation(v.id));return i.updateAnnotation(v),g}else{const v=i.getAnnotation(y.id);return i.updateAnnotation(Ea(y)),v}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getHistory:t.getHistory,getSelected:u,loadAnnotations:c,redo:t.redo,removeAnnotation:d,setAnnotations:p,setSelected:f,setUserSelectAction:m,undo:t.undo,updateAnnotation:_}},D_=(r,t,e)=>typeof t=="function"?t(r,e):t,L_=(r,t)=>typeof r!="function"&&typeof t!="function"?{...r||{},...t||{}}:(e,i)=>{const s=typeof r=="function"?r(e,i):r,n=typeof t=="function"?t(e,i):t;return{...s||{},...n||{}}},B_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let F_=r=>crypto.getRandomValues(new Uint8Array(r)),U_=(r,t,e)=>{let i=(2<<Math.log2(r.length-1))-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s|0;for(;l--;)if(o+=r[a[l]&i]||"",o.length>=n)return o}}},k_=(r,t=21)=>U_(r,t|0,F_),G_=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=B_[e[r]&63];return t};const H_=()=>({isGuest:!0,id:k_("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),$_=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},Xu=r=>r?typeof r=="object"?{...r}:r:void 0,X_=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,modified:l,creator:h,...u}=e;return{id:i||`temp-${$_(e)}`,annotation:t,type:s,purpose:n,value:o,creator:Xu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),V_=r=>r.map(t=>{var e;const{annotation:i,created:s,updated:n,...o}=t,a={...o,created:s==null?void 0:s.toISOString(),modified:n==null?void 0:n.toISOString()};return(e=a.id)!=null&&e.startsWith("temp-")&&delete a.id,a});G_();const z_=(r,t={strict:!0,invertY:!1})=>({parse:e=>Y_(e,t),serialize:e=>j_(e,r,t)}),Y_=(r,t={strict:!0,invertY:!1})=>{const e=r.id||Fu(),{creator:i,created:s,modified:n,body:o,...a}=r,l=X_(o||[],e),h=Array.isArray(r.target)?r.target[0]:r.target,u=typeof h=="string"?h:Array.isArray(h.selector)?h.selector[0]:h.selector,c=typeof u=="string"||(u==null?void 0:u.type)==="FragmentSelector"?Ry(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?i_(u):void 0,d=Array.isArray(a.target)?a.target[0]:a.targret;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:Xu(i),updated:n?new Date(n):void 0,...typeof d=="string"?{}:d,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},j_=(r,t,e={strict:!0,invertY:!1})=>{const{selector:i,creator:s,created:n,updated:o,updatedBy:a,...l}=r.target;let h;try{h=i.type==At.RECTANGLE?My(i.geometry):n_(i)}catch(c){if(e.strict)throw c;h=i}const u={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:V_(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,type:"SpecificResource",selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u},Ta=(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))},Vi=[];function W_(r,t=Dt){let e;const i=new Set;function s(a){if(le(r,a)&&(r=a,e)){const l=!Vi.length;for(const h of i)h[1](),Vi.push(h,r);if(l){for(let h=0;h<Vi.length;h+=2)Vi[h][0](Vi[h+1]);Vi.length=0}}}function n(a){s(a(r))}function o(a,l=Dt){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Dt),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const q_=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},K_=(r,t)=>{q_(r,t);const{subscribe:e,set:i}=W_(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},Os=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Rn=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Sr=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,Z_=r=>({}),Vu=r=>({grab:r[0]});function Q_(r){let t,e,i,s;const n=r[8].default,o=dy(n,r,r[7],Vu);return{c(){t=K("g"),o&&o.c(),b(t,"class","a9s-annotation selected")},m(a,l){it(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Rt(t,"pointerup",r[2]),Rt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&py(o,n,a,a[7],e?fy(n,a[7],l,Z_):my(a[7]),Vu)},i(a){e||(ot(o,a),e=!0)},o(a){mt(o,a),e=!1},d(a){a&&rt(t),o&&o.d(a),i=!1,$e(s)}}}function J_(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=$r();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const p=_=>y=>{if(u=_,h){const{left:v,top:g}=h.getBoundingClientRect(),x=y.clientX-v,E=y.clientY-g;c=l.elementToImage(x,E)}else{const{offsetX:v,offsetY:g}=y;c=l.elementToImage(v,g)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},f=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[p,f,m,o,a,l,h,s,i]}class wa extends De{constructor(t){super(),Ne(this,t,J_,Q_,le,{shape:3,editor:4,transform:5,svgEl:6})}}function t0(r){let t,e,i,s,n,o,a,l,h=r[3]&&zu(r);return{c(){t=K("g"),e=K("circle"),h&&h.c(),s=K("circle"),b(e,"class","a9s-handle-buffer svelte-160z737"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]+6/r[2]),b(s,"class",n=bn(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-160z737"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[5]),b(t,"class",o=bn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-160z737")},m(u,c){it(u,t,c),Et(t,e),h&&h.m(t,null),Et(t,s),a||(l=[Rt(e,"pointerenter",r[11]),Rt(e,"pointerleave",r[12]),Rt(e,"pointerdown",r[13]),Rt(e,"pointerdown",r[6]),Rt(e,"pointerup",r[14]),Rt(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&b(e,"r",i),u[3]?h?h.p(u,c):(h=zu(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=bn(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-160z737")&&b(s,"class",n),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&32&&b(s,"r",u[5]),c&256&&o!==(o=bn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-160z737")&&b(t,"class",o)},d(u){u&&rt(t),h&&h.d(),a=!1,$e(l)}}}function e0(r){let t,e,i,s,n,o,a,l,h;return{c(){t=K("g"),e=K("circle"),s=K("circle"),o=K("circle"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=r[5]*10),b(e,"class","a9s-touch-halo svelte-160z737"),cr(e,"touched",r[4]),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",n=r[5]+10/r[2]),b(s,"class","a9s-handle-buffer svelte-160z737"),b(o,"class","a9s-handle-dot svelte-160z737"),b(o,"cx",r[0]),b(o,"cy",r[1]),b(o,"r",a=r[5]+2/r[2]),b(t,"class","a9s-touch-handle")},m(u,c){it(u,t,c),Et(t,e),Et(t,s),Et(t,o),l||(h=[Rt(s,"pointerdown",r[9]),Rt(s,"pointerup",r[10]),Rt(s,"pointerdown",r[6]),Rt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&b(e,"cx",u[0]),c&2&&b(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&b(e,"r",i),c&16&&cr(e,"touched",u[4]),c&1&&b(s,"cx",u[0]),c&2&&b(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&b(s,"r",n),c&1&&b(o,"cx",u[0]),c&2&&b(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&b(o,"r",a)},d(u){u&&rt(t),l=!1,$e(h)}}}function zu(r){let t,e;return{c(){t=K("circle"),b(t,"class","a9s-handle-selected svelte-160z737"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",e=r[5]+8/r[2])},m(i,s){it(i,t,s)},p(i,s){s&1&&b(t,"cx",i[0]),s&2&&b(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&b(t,"r",e)},d(i){i&&rt(t)}}}function r0(r){let t;function e(s,n){return Sr?e0:t0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Dt,o:Dt,d(s){s&&rt(t),i.d(s)}}}function i0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Ce.call(this,r,y)}function d(y){Ce.call(this,r,y)}function p(y){Ce.call(this,r,y)}function f(y){Ce.call(this,r,y)}function m(y){Ce.call(this,r,y)}function _(y){Ce.call(this,r,y)}return r.$$set=y=>{e(8,t=na(na({},t),pu(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=pu(t),[s,n,o,a,l,i,h,u,t,c,d,p,f,m,_]}class zi extends De{constructor(t){super(),Ne(this,t,i0,r0,le,{x:0,y:1,scale:2,selected:3})}}function s0(r){let t,e,i,s,n,o,a;return{c(){t=K("g"),e=K("circle"),s=K("circle"),n=K("circle"),b(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),b(e,"cx",r[0]),b(e,"cy",r[1]),b(e,"r",i=1.75*r[2]),b(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),b(s,"cx",r[0]),b(s,"cy",r[1]),b(s,"r",r[2]),b(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),b(n,"cx",r[0]),b(n,"cy",r[1]),b(n,"r",r[2]),b(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){it(l,t,h),Et(t,e),Et(t,s),Et(t,n),o||(a=[Rt(e,"pointerdown",r[5]),Rt(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&b(e,"cx",l[0]),h&2&&b(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&b(e,"r",i),h&1&&b(s,"cx",l[0]),h&2&&b(s,"cy",l[1]),h&4&&b(s,"r",l[2]),h&1&&b(n,"cx",l[0]),h&2&&b(n,"cy",l[1]),h&4&&b(n,"r",l[2])},d(l){l&&rt(t),o=!1,$e(a)}}}function n0(r){let t;return{c(){t=K("circle"),b(t,"cx",r[0]),b(t,"cy",r[1]),b(t,"r",r[2])},m(e,i){it(e,t,i)},p(e,i){i&1&&b(t,"cx",e[0]),i&2&&b(t,"cy",e[1]),i&4&&b(t,"r",e[2])},d(e){e&&rt(t)}}}function o0(r){let t;function e(s,n){return Sr?n0:s0}let i=e()(r);return{c(){i.c(),t=Fe()},m(s,n){i.m(s,n),it(s,t,n)},p(s,[n]){i.p(s,n)},i:Dt,o:Dt,d(s){s&&rt(t),i.d(s)}}}function a0(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Ce.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class Yu extends De{constructor(t){super(),Ne(this,t,a0,o0,le,{x:0,y:1,scale:4})}}function Aa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function ju(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Sa(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Ca(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Wu(r){let t,e,i,s;return{c(){t=K("circle"),b(t,"cx",e=r[28][0]),b(t,"cy",i=r[28][1]),b(t,"r",s=Ns/r[3]),b(t,"class","svelte-1h2slbm")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Ns/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function qu(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("mask"),e=K("rect"),a=K("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1h2slbm"),b(a,"cx",l=r[28][0]),b(a,"cy",h=r[28][1]),b(a,"r",u=Ns/r[3]),b(a,"class","svelte-1h2slbm"),b(t,"id",`${r[19]}-inner`),b(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){it(c,t,d),Et(t,e),Et(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Ns/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function Ku(r){let t,e;return t=new zi({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(){Vt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Zu(r){let t,e;return t=new Yu({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function l0(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v,g,x,E,M=r[6]!==void 0&&!r[7]&&Wu(Ca(r)),S=r[6]!==void 0&&!r[7]&&qu(Sa(r)),R=Ue(r[5].points),P=[];for(let I=0;I<R.length;I+=1)P[I]=Ku(ju(r,R,I));const F=I=>mt(P[I],1,1,()=>{P[I]=null});let k=r[6]!==void 0&&!r[7]&&Zu(Aa(r));return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("polygon"),M&&M.c(),S&&S.c(),u=Oe(),c=K("polygon"),p=Oe(),f=K("polygon"),_=Oe();for(let I=0;I<P.length;I+=1)P[I].c();y=Oe(),k&&k.c(),v=Fe(),b(i,"x",s=r[9].x),b(i,"y",n=r[9].y),b(i,"width",o=r[9].w),b(i,"height",a=r[9].h),b(i,"class","svelte-1h2slbm"),b(l,"points",h=r[5].points.map(Qu).join(" ")),b(l,"class","svelte-1h2slbm"),b(e,"id",`${r[19]}-outer`),b(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[19]}-outer)`),b(c,"points",d=r[5].points.map(Ju).join(" ")),b(f,"class","a9s-inner a9s-shape-handle"),b(f,"mask",`url(#${r[19]}-inner)`),b(f,"style",r[1]),b(f,"points",m=r[5].points.map(tc).join(" "))},m(I,A){it(I,t,A),Et(t,e),Et(e,i),Et(e,l),M&&M.m(e,null),S&&S.m(t,null),it(I,u,A),it(I,c,A),it(I,p,A),it(I,f,A),it(I,_,A);for(let T=0;T<P.length;T+=1)P[T]&&P[T].m(I,A);it(I,y,A),k&&k.m(I,A),it(I,v,A),g=!0,x||(E=[Rt(c,"pointerup",r[14]),Rt(c,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Rt(f,"pointermove",r[13]),Rt(f,"pointerup",r[14]),Rt(f,"pointerdown",function(){Vt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&b(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&b(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&b(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&b(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(Qu).join(" ")))&&b(l,"points",h),r[6]!==void 0&&!r[7]?M?M.p(Ca(r),A):(M=Wu(Ca(r)),M.c(),M.m(e,null)):M&&(M.d(1),M=null),r[6]!==void 0&&!r[7]?S?S.p(Sa(r),A):(S=qu(Sa(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(Ju).join(" ")))&&b(c,"points",d),(!g||A[0]&2)&&b(f,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(tc).join(" ")))&&b(f,"points",m),A[0]&134322472){R=Ue(r[5].points);let T;for(T=0;T<R.length;T+=1){const C=ju(r,R,T);P[T]?(P[T].p(C,A),ot(P[T],1)):(P[T]=Ku(C),P[T].c(),ot(P[T],1),P[T].m(y.parentNode,y))}for(Ie(),T=R.length;T<P.length;T+=1)F(T);Re()}r[6]!==void 0&&!r[7]?k?(k.p(Aa(r),A),A[0]&192&&ot(k,1)):(k=Zu(Aa(r)),k.c(),ot(k,1),k.m(v.parentNode,v)):k&&(Ie(),mt(k,1,1,()=>{k=null}),Re())},i(I){if(!g){for(let A=0;A<R.length;A+=1)ot(P[A]);ot(k),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)mt(P[A]);mt(k),g=!1},d(I){I&&(rt(t),rt(u),rt(c),rt(p),rt(f),rt(_),rt(y),rt(v)),M&&M.d(),S&&S.d(),pi(P,I),k&&k.d(I),x=!1,$e(E)}}}function h0(r){let t,e;return t=new wa({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[l0,({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(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}const u0=250,c0=1e3,d0=12,Ns=4.5,Qu=r=>r.join(","),Ju=r=>r.join(","),tc=r=>r.join(",");function f0(r,t,e){let i,s,n;const o=$r();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p=!1,f,m=[];const _=()=>e(7,p=!0),y=()=>e(7,p=!1),v=T=>{if(m.length>0){e(6,d=void 0);return}const[C,L]=h.elementToImage(T.offsetX,T.offsetY),N=D=>Math.pow(D[0]-C,2)+Math.pow(D[1]-L,2),B=i.points.reduce((D,U)=>N(U)<N(D)?U:D),X=s.filter(D=>D.visible).reduce((D,U)=>N(U.point)<N(D.point)?U:D),O=Math.pow(c0/u,2);N(B)<O||N(X.point)<O?e(6,d=s.indexOf(X)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=T=>{e(7,p=!0),T.preventDefault(),T.stopPropagation(),f=performance.now()},M=T=>C=>{if(!f||Sr||performance.now()-f>u0)return;const L=m.includes(T);C.metaKey||C.ctrlKey||C.shiftKey?L?e(8,m=m.filter(N=>N!==T)):e(8,m=[...m,T]):L&&m.length>1?e(8,m=[T]):L?e(8,m=[]):e(8,m=[T]),g()},S=(T,C,L)=>{g();let N;const B=T.geometry;m.length>1?N=B.points.map(([O,D],U)=>m.includes(U)?[O+L[0],D+L[1]]:[O,D]):C==="SHAPE"?N=B.points.map(([O,D])=>[O+L[0],D+L[1]]):N=B.points.map(([O,D],U)=>C===`HANDLE-${U}`?[O+L[0],D+L[1]]:[O,D]);const X=ke(N);return{...T,geometry:{points:N,bounds:X}}},R=T=>async C=>{C.stopPropagation();const L=[...i.points.slice(0,T+1),s[T].point,...i.points.slice(T+1)],N=ke(L);o("change",{...a,geometry:{points:L,bounds:N}}),await xu();const B=[...document.querySelectorAll(".a9s-handle")][T+1];if(B!=null&&B.firstChild){const X=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(X)}},P=()=>{if(i.points.length<4)return;const T=i.points.filter((L,N)=>!m.includes(N)),C=ke(T);o("change",{...a,geometry:{points:T,bounds:C}}),e(8,m=[])};mi(()=>{if(Sr)return;const T=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",T),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",T)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function k(T){Ce.call(this,r,T)}function I(T){Ce.call(this,r,T)}function A(T){Ce.call(this,r,T)}return r.$$set=T=>{"shape"in T&&e(0,a=T.shape),"computedStyle"in T&&e(1,l=T.computedStyle),"transform"in T&&e(2,h=T.transform),"viewportScale"in T&&e(3,u=T.viewportScale),"svgEl"in T&&e(4,c=T.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Sr?[]:i.points.map((T,C)=>{const L=C===i.points.length-1?i.points[0]:i.points[C+1],N=(T[0]+L[0])/2,B=(T[1]+L[1])/2,X=Math.sqrt(Math.pow(L[0]-N,2)+Math.pow(L[1]-B,2))>d0/u;return{point:[N,B],visible:X}})),r.$$.dirty[0]&40&&e(9,n=Rn(i.bounds,Ns/u))},[a,l,h,u,c,i,d,p,m,n,s,_,y,v,x,E,M,S,R,F,k,I,A]}class p0 extends De{constructor(t){super(),Ne(this,t,f0,h0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function m0(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v,g,x,E,M,S,R,P,F,k,I,A,T,C,L,N,B,X,O,D,U,V,j,Q,yt,Tt,Y,bt,dt,pt,vt,Mt,Nt,_e,Wt,et,qe,mn;return dt=new zi({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),dt.$on("pointerdown",function(){Vt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new zi({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){Vt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Nt=new zi({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Nt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Wt=new zi({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Wt.$on("pointerdown",function(){Vt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("rect"),p=Oe(),f=K("rect"),g=Oe(),x=K("rect"),P=Oe(),F=K("rect"),T=Oe(),C=K("rect"),X=Oe(),O=K("rect"),j=Oe(),Q=K("rect"),bt=Oe(),xe(dt.$$.fragment),pt=Oe(),xe(vt.$$.fragment),Mt=Oe(),xe(Nt.$$.fragment),_e=Oe(),xe(Wt.$$.fragment),b(i,"class","rect-mask-bg svelte-1njczvj"),b(i,"x",s=r[6].x),b(i,"y",n=r[6].y),b(i,"width",o=r[6].w),b(i,"height",a=r[6].h),b(l,"class","rect-mask-fg svelte-1njczvj"),b(l,"x",h=r[5].x),b(l,"y",u=r[5].y),b(l,"width",c=r[5].w),b(l,"height",d=r[5].h),b(e,"id",r[8]),b(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),b(f,"class","a9s-outer"),b(f,"mask",`url(#${r[8]})`),b(f,"x",m=r[5].x),b(f,"y",_=r[5].y),b(f,"width",y=r[5].w),b(f,"height",v=r[5].h),b(x,"class","a9s-inner a9s-shape-handle"),b(x,"style",r[1]),b(x,"x",E=r[5].x),b(x,"y",M=r[5].y),b(x,"width",S=r[5].w),b(x,"height",R=r[5].h),b(F,"class","a9s-edge-handle a9s-edge-handle-top"),b(F,"x",k=r[5].x),b(F,"y",I=r[5].y),b(F,"height",1),b(F,"width",A=r[5].w),b(C,"class","a9s-edge-handle a9s-edge-handle-right"),b(C,"x",L=r[5].x+r[5].w),b(C,"y",N=r[5].y),b(C,"height",B=r[5].h),b(C,"width",1),b(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),b(O,"x",D=r[5].x),b(O,"y",U=r[5].y+r[5].h),b(O,"height",1),b(O,"width",V=r[5].w),b(Q,"class","a9s-edge-handle a9s-edge-handle-left"),b(Q,"x",yt=r[5].x),b(Q,"y",Tt=r[5].y),b(Q,"height",Y=r[5].h),b(Q,"width",1)},m(W,H){it(W,t,H),Et(t,e),Et(e,i),Et(e,l),it(W,p,H),it(W,f,H),it(W,g,H),it(W,x,H),it(W,P,H),it(W,F,H),it(W,T,H),it(W,C,H),it(W,X,H),it(W,O,H),it(W,j,H),it(W,Q,H),it(W,bt,H),ce(dt,W,H),it(W,pt,H),ce(vt,W,H),it(W,Mt,H),ce(Nt,W,H),it(W,_e,H),ce(Wt,W,H),et=!0,qe||(mn=[Rt(f,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(x,"pointerdown",function(){Vt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Rt(F,"pointerdown",function(){Vt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Rt(C,"pointerdown",function(){Vt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Rt(O,"pointerdown",function(){Vt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Rt(Q,"pointerdown",function(){Vt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],qe=!0)},p(W,H){r=W,(!et||H&64&&s!==(s=r[6].x))&&b(i,"x",s),(!et||H&64&&n!==(n=r[6].y))&&b(i,"y",n),(!et||H&64&&o!==(o=r[6].w))&&b(i,"width",o),(!et||H&64&&a!==(a=r[6].h))&&b(i,"height",a),(!et||H&32&&h!==(h=r[5].x))&&b(l,"x",h),(!et||H&32&&u!==(u=r[5].y))&&b(l,"y",u),(!et||H&32&&c!==(c=r[5].w))&&b(l,"width",c),(!et||H&32&&d!==(d=r[5].h))&&b(l,"height",d),(!et||H&32&&m!==(m=r[5].x))&&b(f,"x",m),(!et||H&32&&_!==(_=r[5].y))&&b(f,"y",_),(!et||H&32&&y!==(y=r[5].w))&&b(f,"width",y),(!et||H&32&&v!==(v=r[5].h))&&b(f,"height",v),(!et||H&2)&&b(x,"style",r[1]),(!et||H&32&&E!==(E=r[5].x))&&b(x,"x",E),(!et||H&32&&M!==(M=r[5].y))&&b(x,"y",M),(!et||H&32&&S!==(S=r[5].w))&&b(x,"width",S),(!et||H&32&&R!==(R=r[5].h))&&b(x,"height",R),(!et||H&32&&k!==(k=r[5].x))&&b(F,"x",k),(!et||H&32&&I!==(I=r[5].y))&&b(F,"y",I),(!et||H&32&&A!==(A=r[5].w))&&b(F,"width",A),(!et||H&32&&L!==(L=r[5].x+r[5].w))&&b(C,"x",L),(!et||H&32&&N!==(N=r[5].y))&&b(C,"y",N),(!et||H&32&&B!==(B=r[5].h))&&b(C,"height",B),(!et||H&32&&D!==(D=r[5].x))&&b(O,"x",D),(!et||H&32&&U!==(U=r[5].y+r[5].h))&&b(O,"y",U),(!et||H&32&&V!==(V=r[5].w))&&b(O,"width",V),(!et||H&32&&yt!==(yt=r[5].x))&&b(Q,"x",yt),(!et||H&32&&Tt!==(Tt=r[5].y))&&b(Q,"y",Tt),(!et||H&32&&Y!==(Y=r[5].h))&&b(Q,"height",Y);const Fr={};H&32&&(Fr.x=r[5].x),H&32&&(Fr.y=r[5].y),H&8&&(Fr.scale=r[3]),dt.$set(Fr);const Ur={};H&32&&(Ur.x=r[5].x+r[5].w),H&32&&(Ur.y=r[5].y),H&8&&(Ur.scale=r[3]),vt.$set(Ur);const kr={};H&32&&(kr.x=r[5].x+r[5].w),H&32&&(kr.y=r[5].y+r[5].h),H&8&&(kr.scale=r[3]),Nt.$set(kr);const Gr={};H&32&&(Gr.x=r[5].x),H&32&&(Gr.y=r[5].y+r[5].h),H&8&&(Gr.scale=r[3]),Wt.$set(Gr)},i(W){et||(ot(dt.$$.fragment,W),ot(vt.$$.fragment,W),ot(Nt.$$.fragment,W),ot(Wt.$$.fragment,W),et=!0)},o(W){mt(dt.$$.fragment,W),mt(vt.$$.fragment,W),mt(Nt.$$.fragment,W),mt(Wt.$$.fragment,W),et=!1},d(W){W&&(rt(t),rt(p),rt(f),rt(g),rt(x),rt(P),rt(F),rt(T),rt(C),rt(X),rt(O),rt(j),rt(Q),rt(bt),rt(pt),rt(Mt),rt(_e)),de(dt,W),de(vt,W),de(Nt,W),de(Wt,W),qe=!1,$e(mn)}}}function g0(r){let t,e;return t=new wa({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[m0,({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(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function y0(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,M]=[v.maxX,v.maxY];const[S,R]=y;if(_==="SHAPE")g+=S,E+=S,x+=R,M+=R;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{M+=R;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=S;break}}}const P=Math.min(g,E),F=Math.min(x,M),k=Math.abs(E-g),I=Math.abs(M-x);return{...m,geometry:{x:P,y:F,w:k,h:I,bounds:{minX:P,minY:F,maxX:P+k,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Ce.call(this,r,m)}function p(m){Ce.call(this,r,m)}function f(m){Ce.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=Rn(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class _0 extends De{constructor(t){super(),Ne(this,t,y0,g0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var ec=Object.prototype.hasOwnProperty;function Ia(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--&&Ia(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(ec.call(r,e)&&++i&&!ec.call(t,e)||!(e in t)||!Ia(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const v0=12,x0=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],p=(u[0]+d[0])/2,f=(u[1]+d[1])/2,m=Math.sqrt(Math.pow(d[0]-p,2)+Math.pow(d[1]-f,2))>v0/t;return{point:[p,f],visible:m,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function Ra(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function rc(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function ic(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function sc(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function Ma(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Pa(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function nc(r){let t,e,i,s;return{c(){t=K("circle"),b(t,"cx",e=r[29][0]),b(t,"cy",i=r[29][1]),b(t,"r",s=Ds/r[3]),b(t,"class","svelte-1vxo6dc")},m(n,o){it(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&b(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&b(t,"cy",i),o[0]&8&&s!==(s=Ds/n[3])&&b(t,"r",s)},d(n){n&&rt(t)}}}function oc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("mask"),e=K("rect"),a=K("circle"),b(e,"x",i=r[9].x),b(e,"y",s=r[9].y),b(e,"width",n=r[9].w),b(e,"height",o=r[9].h),b(e,"class","svelte-1vxo6dc"),b(a,"cx",l=r[29][0]),b(a,"cy",h=r[29][1]),b(a,"r",u=Ds/r[3]),b(a,"class","svelte-1vxo6dc"),b(t,"id",`${r[18]}-${r[32]}-inner`),b(t,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc")},m(c,d){it(c,t,d),Et(t,e),Et(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&b(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&b(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&b(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&b(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&b(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&b(a,"cy",h),d[0]&8&&u!==(u=Ds/c[3])&&b(a,"r",u)},d(c){c&&rt(t)}}}function ac(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new zi({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(){Vt(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(){xe(t.$$.fragment)},m(s,n){ce(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(ot(t.$$.fragment,s),e=!0)},o(s){mt(t.$$.fragment,s),e=!1},d(s){de(t,s)}}}function lc(r){let t,e,i=Ue(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=ac(sc(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Ue(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=sc(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=ac(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&rt(t),pi(s,o)}}}function hc(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v=r[6]!==void 0&&!r[7]&&nc(Pa(r)),g=r[6]!==void 0&&!r[7]&&oc(Ma(r)),x=Ue(r[30].rings),E=[];for(let S=0;S<x.length;S+=1)E[S]=lc(ic(r,x,S));const M=S=>mt(E[S],1,1,()=>{E[S]=null});return{c(){t=K("g"),e=K("defs"),i=K("mask"),s=K("rect"),h=K("path"),v&&v.c(),g&&g.c(),c=K("path"),p=K("path");for(let S=0;S<E.length;S+=1)E[S].c();b(s,"x",n=r[9].x),b(s,"y",o=r[9].y),b(s,"width",a=r[9].w),b(s,"height",l=r[9].h),b(s,"class","svelte-1vxo6dc"),b(h,"d",u=Ke(r[30])),b(h,"class","svelte-1vxo6dc"),b(i,"id",`${r[18]}-${r[32]}-outer`),b(i,"class","a9s-multipolygon-editor-mask svelte-1vxo6dc"),b(c,"class","a9s-outer"),b(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),b(c,"fill-rule","evenodd"),b(c,"d",d=Ke(r[30])),b(p,"class","a9s-inner"),b(p,"mask",`url(#${r[18]}-${r[32]}-inner)`),b(p,"style",r[1]),b(p,"fill-rule","evenodd"),b(p,"d",f=Ke(r[30]))},m(S,R){it(S,t,R),Et(t,e),Et(e,i),Et(i,s),Et(i,h),v&&v.m(i,null),g&&g.m(e,null),Et(t,c),Et(t,p);for(let P=0;P<E.length;P+=1)E[P]&&E[P].m(t,null);m=!0,_||(y=[Rt(c,"pointerup",r[13]),Rt(c,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Rt(p,"pointerup",r[13]),Rt(p,"pointerdown",function(){Vt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,R){if(r=S,(!m||R[0]&512&&n!==(n=r[9].x))&&b(s,"x",n),(!m||R[0]&512&&o!==(o=r[9].y))&&b(s,"y",o),(!m||R[0]&512&&a!==(a=r[9].w))&&b(s,"width",a),(!m||R[0]&512&&l!==(l=r[9].h))&&b(s,"height",l),(!m||R[0]&32&&u!==(u=Ke(r[30])))&&b(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(Pa(r),R):(v=nc(Pa(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(Ma(r),R):(g=oc(Ma(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||R[0]&32&&d!==(d=Ke(r[30])))&&b(c,"d",d),(!m||R[0]&2)&&b(p,"style",r[1]),(!m||R[0]&32&&f!==(f=Ke(r[30])))&&b(p,"d",f),R[0]&268491048){x=Ue(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=ic(r,x,P);E[P]?(E[P].p(F,R),ot(E[P],1)):(E[P]=lc(F),E[P].c(),ot(E[P],1),E[P].m(t,null))}for(Ie(),P=x.length;P<E.length;P+=1)M(P);Re()}},i(S){if(!m){for(let R=0;R<x.length;R+=1)ot(E[R]);m=!0}},o(S){E=E.filter(Boolean);for(let R=0;R<E.length;R+=1)mt(E[R]);m=!1},d(S){S&&rt(t),v&&v.d(),g&&g.d(),pi(E,S),_=!1,$e(y)}}}function uc(r){let t,e;return t=new Yu({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Vt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function b0(r){let t,e,i,s=Ue(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=hc(rc(r,s,l));const o=l=>mt(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&uc(Ra(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=Oe(),a&&a.c(),e=Fe()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);it(l,t,h),a&&a.m(l,h),it(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=Ue(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=rc(l,s,u);n[u]?(n[u].p(c,h),ot(n[u],1)):(n[u]=hc(c),n[u].c(),ot(n[u],1),n[u].m(t.parentNode,t))}for(Ie(),u=s.length;u<n.length;u+=1)o(u);Re()}l[6]!==void 0&&!l[7]?a?(a.p(Ra(l),h),h[0]&192&&ot(a,1)):(a=uc(Ra(l)),a.c(),ot(a,1),a.m(e.parentNode,e)):a&&(Ie(),mt(a,1,1,()=>{a=null}),Re())},i(l){if(!i){for(let h=0;h<s.length;h+=1)ot(n[h]);ot(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)mt(n[h]);mt(a),i=!1},d(l){l&&(rt(t),rt(e)),pi(n,l),a&&a.d(l)}}}function E0(r){let t,e;return t=new wa({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[b0,({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(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}const T0=250,w0=1e3,Ds=4.5;function A0(r,t,e){let i,s,n;const o=$r();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p=!1,f,m=[];const _=()=>e(7,p=!0),y=()=>e(7,p=!1),v=C=>{if(m.length>0){e(6,d=void 0);return}const[L,N]=h.elementToImage(C.offsetX,C.offsetY),B=U=>Math.pow(U[0]-L,2)+Math.pow(U[1]-N,2),X=Sy(i).reduce((U,V)=>B(V)<B(U)?V:U),O=s.filter(U=>U.visible).reduce((U,V)=>B(V.point)<B(U.point)?V:U),D=Math.pow(w0/u,2);B(X)<D||B(O.point)<D?e(6,d=s.indexOf(O)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=C=>{e(7,p=!0),C.preventDefault(),C.stopPropagation(),f=performance.now()},M=(C,L,N)=>B=>{if(!f||Sr||performance.now()-f>T0)return;const X=D=>D.polygon===C&&D.ring===L&&D.point===N,O=m.some(X);B.metaKey||B.ctrlKey||B.shiftKey?O?e(8,m=m.filter(D=>!X(D))):e(8,m=[...m,{polygon:C,ring:L,point:N}]):O&&m.length>1?e(8,m=[{polygon:C,ring:L,point:N}]):O?e(8,m=[]):e(8,m=[{polygon:C,ring:L,point:N}]),g()},S=(C,L,N)=>{g();const B=C.geometry.polygons;let X;if(L==="SHAPE")X=B.map(O=>{const D=O.rings.map((V,j)=>({points:V.points.map((Q,yt)=>[Q[0]+N[0],Q[1]+N[1]])})),U=ke(D[0].points);return{rings:D,bounds:U}});else{const[O,D,U,V]=L.split("-").map(j=>parseInt(j));X=B.map((j,Q)=>{if(Q===D){const yt=j.rings.map((Y,bt)=>bt===U?{points:Y.points.map((dt,pt)=>pt===V?[dt[0]+N[0],dt[1]+N[1]]:dt)}:Y),Tt=ke(yt[0].points);return{rings:yt,bounds:Tt}}else return j})}return{...C,geometry:{polygons:X,bounds:pa(X)}}},R=C=>async L=>{L.stopPropagation();const N=s[C],B=i.polygons.map((O,D)=>{if(D===N.elementIdx){const U=O.rings.map((j,Q)=>Q===N.ringIdx?{points:[...j.points.slice(0,N.pointIdx+1),N.point,...j.points.slice(N.pointIdx+1)]}:j),V=ke(U[0].points);return{rings:U,bounds:V}}else return O});o("change",{...a,geometry:{polygons:B,bounds:pa(B)}}),await xu();const X=[...document.querySelectorAll(".a9s-handle")][C+1];if(X!=null&&X.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});X.firstChild.dispatchEvent(O)}},P=()=>{const C=i.polygons.map((L,N)=>{if(m.some(B=>B.polygon===N)){const B=L.rings.map((O,D)=>m.some(U=>U.polygon===N&&U.ring===D)&&O.points.length>3?{points:O.points.filter((U,V)=>!m.some(j=>j.polygon===N&&j.ring===D&&j.point===V))}:O),X=ke(B[0].points);return{rings:B,bounds:X}}else return L});!Ia(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:pa(C)}}),e(8,m=[]))};mi(()=>{if(Sr)return;const C=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,k=(C,L,N,{polygon:B,ring:X,point:O})=>B===C&&X===L&&O===N;function I(C){Ce.call(this,r,C)}function A(C){Ce.call(this,r,C)}function T(C){Ce.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=Sr?[]:x0(i,u)),r.$$.dirty[0]&40&&e(9,n=Rn(i.bounds,Ds/u))},[a,l,h,u,c,i,d,p,m,n,s,_,y,x,E,M,S,R,F,k,I,A,T]}class S0 extends De{constructor(t){super(),Ne(this,t,A0,E0,le,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}const cc=new Map([[At.RECTANGLE,_0],[At.POLYGON,p0],[At.MULTIPOLYGLON,S0]]),dc=r=>cc.get(r.type),fc=(r,t)=>cc.set(r,t);function C0(r,t,e){let i;const s=$r();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return mi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=Os(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class I0 extends De{constructor(t){super(),Ne(this,t,C0,null,le,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function R0(r,t,e){const i=$r();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return mi(()=>{const u=n.closest("svg"),c=[],d=(p,f,m)=>{u==null||u.addEventListener(p,f,m),c.push(()=>u==null?void 0:u.removeEventListener(p,f,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",p=>i("create",p.detail)),()=>{c.forEach(p=>p()),h.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewportScale"in u&&e(4,l=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class M0 extends De{constructor(t){super(),Ne(this,t,R0,null,le,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function pc(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("rect"),h=K("rect"),u=K("rect"),b(i,"class","rect-mask-bg svelte-1a76qe7"),b(i,"x",s=r[1]-r[5]),b(i,"y",n=r[2]-r[5]),b(i,"width",o=r[3]+2*r[5]),b(i,"height",a=r[4]+2*r[5]),b(l,"class","rect-mask-fg svelte-1a76qe7"),b(l,"x",r[1]),b(l,"y",r[2]),b(l,"width",r[3]),b(l,"height",r[4]),b(e,"id",r[6]),b(e,"class","a9s-rubberband-rectangle-mask svelte-1a76qe7"),b(h,"class","a9s-outer"),b(h,"mask",`url(#${r[6]})`),b(h,"x",r[1]),b(h,"y",r[2]),b(h,"width",r[3]),b(h,"height",r[4]),b(u,"class","a9s-inner"),b(u,"x",r[1]),b(u,"y",r[2]),b(u,"width",r[3]),b(u,"height",r[4])},m(c,d){it(c,t,d),Et(t,e),Et(e,i),Et(e,l),it(c,h,d),it(c,u,d)},p(c,d){d&34&&s!==(s=c[1]-c[5])&&b(i,"x",s),d&36&&n!==(n=c[2]-c[5])&&b(i,"y",n),d&40&&o!==(o=c[3]+2*c[5])&&b(i,"width",o),d&48&&a!==(a=c[4]+2*c[5])&&b(i,"height",a),d&2&&b(l,"x",c[1]),d&4&&b(l,"y",c[2]),d&8&&b(l,"width",c[3]),d&16&&b(l,"height",c[4]),d&2&&b(h,"x",c[1]),d&4&&b(h,"y",c[2]),d&8&&b(h,"width",c[3]),d&16&&b(h,"height",c[4]),d&2&&b(u,"x",c[1]),d&4&&b(u,"y",c[2]),d&8&&b(u,"width",c[3]),d&16&&b(u,"height",c[4])},d(c){c&&(rt(t),rt(h),rt(u))}}}function P0(r){let t,e=r[0]&&pc(r);return{c(){t=K("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=pc(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Dt,o:Dt,d(i){i&&rt(t),e&&e.d()}}}function O0(r,t,e){let i;const s=$r();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u,c,d,p,f,m;const _=E=>{const M=E;h=performance.now(),o==="drag"&&(e(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,e(1,d=u[0]),e(2,p=u[1]),e(3,f=1),e(4,m=1))},y=E=>{const M=E;u&&(c=a.elementToImage(M.offsetX,M.offsetY),e(1,d=Math.min(c[0],u[0])),e(2,p=Math.min(c[1],u[1])),e(3,f=Math.abs(c[0]-u[0])),e(4,m=Math.abs(c[1]-u[1])))},v=E=>{const M=E,S=performance.now()-h;if(o==="click"){if(S>300)return;u?g():(e(0,u=a.elementToImage(M.offsetX,M.offsetY)),c=u,e(1,d=u[0]),e(2,p=u[1]),e(3,f=1),e(4,m=1))}else u&&(S>300||f*m>100?(M.stopPropagation(),g()):(e(0,u=void 0),c=void 0))},g=()=>{if(f*m>15){const E={type:At.RECTANGLE,geometry:{bounds:{minX:d,minY:p,maxX:d+f,maxY:p+m},x:d,y:p,w:f,h:m}};s("create",E)}e(0,u=void 0),c=void 0};mi(()=>{n("pointerdown",_),n("pointermove",y),n("pointerup",v,!0)});const x=`rect-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=E=>{"addEventListener"in E&&e(7,n=E.addEventListener),"drawingMode"in E&&e(8,o=E.drawingMode),"transform"in E&&e(9,a=E.transform),"viewportScale"in E&&e(10,l=E.viewportScale)},r.$$.update=()=>{r.$$.dirty&1024&&e(5,i=2/l)},[u,d,p,f,m,i,x,n,o,a,l]}class N0 extends De{constructor(t){super(),Ne(this,t,O0,P0,le,{addEventListener:7,drawingMode:8,transform:9,viewportScale:10})}}function Oa(r){const t=r.slice(),e=t[2].map(i=>i.join(",")).join(" ");return t[19]=e,t}function mc(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=r[1]&&gc(r);return{c(){t=K("defs"),e=K("mask"),i=K("rect"),l=K("polygon"),u=K("polygon"),d=K("polygon"),m&&m.c(),f=Fe(),b(i,"x",s=r[3].x),b(i,"y",n=r[3].y),b(i,"width",o=r[3].w),b(i,"height",a=r[3].h),b(i,"class","svelte-18wrg3t"),b(l,"points",h=r[19]),b(l,"class","svelte-18wrg3t"),b(e,"id",r[5]),b(e,"class","a9s-rubberband-polygon-mask svelte-18wrg3t"),b(u,"class","a9s-outer"),b(u,"mask",`url(#${r[5]})`),b(u,"points",c=r[19]),b(d,"class","a9s-inner"),b(d,"points",p=r[19])},m(_,y){it(_,t,y),Et(t,e),Et(e,i),Et(e,l),it(_,u,y),it(_,d,y),m&&m.m(_,y),it(_,f,y)},p(_,y){y&8&&s!==(s=_[3].x)&&b(i,"x",s),y&8&&n!==(n=_[3].y)&&b(i,"y",n),y&8&&o!==(o=_[3].w)&&b(i,"width",o),y&8&&a!==(a=_[3].h)&&b(i,"height",a),y&4&&h!==(h=_[19])&&b(l,"points",h),y&4&&c!==(c=_[19])&&b(u,"points",c),y&4&&p!==(p=_[19])&&b(d,"points",p),_[1]?m?m.p(_,y):(m=gc(_),m.c(),m.m(f.parentNode,f)):m&&(m.d(1),m=null)},d(_){_&&(rt(t),rt(u),rt(d),rt(f)),m&&m.d(_)}}}function gc(r){let t,e,i;return{c(){t=K("circle"),b(t,"class","a9s-handle svelte-18wrg3t"),b(t,"cx",e=r[0][0][0]),b(t,"cy",i=r[0][0][1]),b(t,"r",r[4])},m(s,n){it(s,t,n)},p(s,n){n&1&&e!==(e=s[0][0][0])&&b(t,"cx",e),n&1&&i!==(i=s[0][0][1])&&b(t,"cy",i),n&16&&b(t,"r",s[4])},d(s){s&&rt(t)}}}function D0(r){let t,e=r[3]&&mc(Oa(r));return{c(){t=K("g"),e&&e.c(),b(t,"class","a9s-annotation a9s-rubberband")},m(i,s){it(i,t,s),e&&e.m(t,null)},p(i,[s]){i[3]?e?e.p(Oa(i),s):(e=mc(Oa(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Dt,o:Dt,d(i){i&&rt(t),e&&e.d()}}}const L0=20,B0=1500;function F0(r,t,e){let i,s,n;const o=$r();let{addEventListener:a}=t,{drawingMode:l}=t,{transform:h}=t,{viewportScale:u=1}=t,c,d=[],p,f,m=!1;const _=M=>{const S=M,{timeStamp:R,offsetX:P,offsetY:F}=S;if(c={timeStamp:R,offsetX:P,offsetY:F},l==="drag"&&d.length===0){const k=h.elementToImage(S.offsetX,S.offsetY);d.push(k),e(10,p=k)}},y=M=>{const S=M;if(f&&clearTimeout(f),d.length>0){if(e(10,p=h.elementToImage(S.offsetX,S.offsetY)),d.length>2){const R=Ta(p,d[0])*u;e(1,m=R<L0)}S.pointerType==="touch"&&(f=setTimeout(()=>{g()},B0))}},v=M=>{const S=M;if(f&&clearTimeout(f),l==="click"){const R=S.timeStamp-c.timeStamp,P=Ta([c.offsetX,c.offsetY],[S.offsetX,S.offsetY]);if(R>300||P>15)return;if(m)x();else if(d.length===0){const F=h.elementToImage(S.offsetX,S.offsetY);d.push(F),e(10,p=F)}else d.push(p)}else{if(d.length===1&&Ta(d[0],p)<=4){e(0,d=[]),e(10,p=void 0);return}S.stopImmediatePropagation(),m?x():d.push(p)}},g=()=>{if(!p)return;const M=d.slice(0,-1);if(M.length<3)return;const S={type:At.POLYGON,geometry:{bounds:ke(d),points:M}};ca(S)>4&&(e(0,d=[]),e(10,p=void 0),o("create",S))},x=()=>{const M={type:At.POLYGON,geometry:{bounds:ke(d),points:[...d]}};e(0,d=[]),e(10,p=void 0),o("create",M)};mi(()=>{a("pointerdown",_,!0),a("pointermove",y),a("pointerup",v,!0),a("dblclick",g,!0)});const E=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;return r.$$set=M=>{"addEventListener"in M&&e(6,a=M.addEventListener),"drawingMode"in M&&e(7,l=M.drawingMode),"transform"in M&&e(8,h=M.transform),"viewportScale"in M&&e(9,u=M.viewportScale)},r.$$.update=()=>{r.$$.dirty&512&&e(4,i=4/u),r.$$.dirty&1027&&e(2,s=p?m?d:[...d,p]:[]),r.$$.dirty&516&&e(3,n=s.length>0?Rn(ke(s),2/u):void 0)},[d,m,s,n,i,E,a,l,h,u,p]}class U0 extends De{constructor(t){super(),Ne(this,t,F0,D0,le,{addEventListener:6,drawingMode:7,transform:8,viewportScale:9})}}const Na=new Map([["rectangle",{tool:N0}],["polygon",{tool:U0}]]),Mn=()=>[...Na.keys()],Pn=r=>Na.get(r),yc=(r,t,e={})=>Na.set(r,{tool:t,opts:e});function k0(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("ellipse"),s=K("ellipse"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"cx",r[2]),b(e,"cy",r[3]),b(e,"rx",r[4]),b(e,"ry",r[5]),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"cx",r[2]),b(s,"cy",r[3]),b(s,"rx",r[4]),b(s,"ry",r[5]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Et(t,e),Et(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}function G0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:u}=n;return r.$$set=c=>{"annotation"in c&&e(0,s=c.annotation),"geom"in c&&e(6,n=c.geom),"style"in c&&e(7,o=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Os(s,o))},[s,i,a,l,h,u,n,o]}class H0 extends De{constructor(t){super(),Ne(this,t,G0,k0,le,{annotation:0,geom:6,style:7})}}function _c(r,t,e){const i=r.slice();return i[5]=t[e],i}function vc(r){let t,e,i;return{c(){t=K("path"),i=K("path"),b(t,"class","a9s-outer"),b(t,"style",e=r[1]?"display:none;":void 0),b(t,"fill-rule","evenodd"),b(t,"d",Ke(r[5])),b(i,"class","a9s-inner"),b(i,"style",r[1]),b(i,"fill-rule","evenodd"),b(i,"d",Ke(r[5]))},m(s,n){it(s,t,n),it(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&b(t,"style",e),n&2&&b(i,"style",s[1])},d(s){s&&(rt(t),rt(i))}}}function $0(r){let t,e,i=Ue(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=vc(_c(r,i,n));return{c(){t=K("g");for(let n=0;n<s.length;n+=1)s[n].c();b(t,"class","a9s-annotation"),b(t,"data-id",e=r[0].id)},m(n,o){it(n,t,o);for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(t,null)},p(n,[o]){if(o&6){i=Ue(n[2]);let a;for(a=0;a<i.length;a+=1){const l=_c(n,i,a);s[a]?s[a].p(l,o):(s[a]=vc(l),s[a].c(),s[a].m(t,null))}for(;a<s.length;a+=1)s[a].d(1);s.length=i.length}o&1&&e!==(e=n[0].id)&&b(t,"data-id",e)},i:Dt,o:Dt,d(n){n&&rt(t),pi(s,n)}}}function X0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{polygons:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Os(s,o))},[s,i,a,n,o]}class V0 extends De{constructor(t){super(),Ne(this,t,X0,$0,le,{annotation:0,geom:3,style:4})}}function z0(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("polygon"),s=K("polygon"),b(e,"class","a9s-outer"),b(e,"style",i=r[1]?"display:none;":void 0),b(e,"points",r[2].map(Y0).join(" ")),b(s,"class","a9s-inner"),b(s,"style",r[1]),b(s,"points",r[2].map(j0).join(" ")),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Et(t,e),Et(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&b(e,"style",i),a&2&&b(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}const Y0=r=>r.join(","),j0=r=>r.join(",");function W0(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Os(s,o))},[s,i,a,n,o]}class q0 extends De{constructor(t){super(),Ne(this,t,W0,z0,le,{annotation:0,geom:3,style:4})}}function K0(r){let t,e,i,s,n;return{c(){t=K("g"),e=K("rect"),s=K("rect"),b(e,"class","a9s-outer"),b(e,"style",i=r[5]?"display:none;":void 0),b(e,"x",r[4]),b(e,"y",r[3]),b(e,"width",r[2]),b(e,"height",r[1]),b(s,"class","a9s-inner"),b(s,"style",r[5]),b(s,"x",r[4]),b(s,"y",r[3]),b(s,"width",r[2]),b(s,"height",r[1]),b(t,"class","a9s-annotation"),b(t,"data-id",n=r[0].id)},m(o,a){it(o,t,a),Et(t,e),Et(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&b(e,"style",i),a&16&&b(e,"x",o[4]),a&8&&b(e,"y",o[3]),a&4&&b(e,"width",o[2]),a&2&&b(e,"height",o[1]),a&32&&b(s,"style",o[5]),a&16&&b(s,"x",o[4]),a&8&&b(s,"y",o[3]),a&4&&b(s,"width",o[2]),a&2&&b(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&b(t,"data-id",n)},i:Dt,o:Dt,d(o){o&&rt(t)}}}function Z0(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:u}=t;return r.$$set=c=>{"annotation"in c&&e(0,l=c.annotation),"geom"in c&&e(6,h=c.geom),"style"in c&&e(7,u=c.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Os(l,u)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,u]}class Q0 extends De{constructor(t){super(),Ne(this,t,Z0,K0,le,{annotation:0,geom:6,style:7})}}const J0=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),tv=250,ev=(r,t)=>{const e=$r();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<tv){const{x:n,y:o}=xc(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},xc=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())};function bc(r,t,e){const i=r.slice();i[39]=t[e];const s=i[24](i[39].target.selector);return i[40]=s,i}function Ec(r,t,e){const i=r.slice();return i[43]=t[e],i}function Da(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function Tc(r){let t=r[43],e,i,s=wc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&65536&&le(t,t=n[43])?(Ie(),mt(s,1,1,Dt),Re(),s=wc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function rv(r){let t,e;return t=new V0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function iv(r){let t,e;return t=new q0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function sv(r){let t,e;return t=new Q0({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function nv(r){var t;let e,i;return e=new H0({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){xe(e.$$.fragment)},m(s,n){ce(e,s,n),i=!0},p(s,n){var o;const a={};n[0]&65536&&(a.annotation=s[43]),n[0]&65536&&(a.geom=(o=s[46])==null?void 0:o.geometry),n[0]&2&&(a.style=s[1]),e.$set(a)},i(s){i||(ot(e.$$.fragment,s),i=!0)},o(s){mt(e.$$.fragment,s),i=!1},d(s){de(e,s)}}}function wc(r){let t,e,i,s;const n=[nv,sv,iv,rv],o=[];function a(l,h){var u,c,d,p;return((u=l[46])==null?void 0:u.type)===At.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===At.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===At.POLYGON?2:((p=l[46])==null?void 0:p.type)===At.MULTIPOLYGLON?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),mt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function Ac(r){let t=Ze(r[43])&&!r[9](r[43]),e,i,s=t&&Tc(Da(r));return{c(){s&&s.c(),e=Fe()},m(n,o){s&&s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=Ze(n[43])&&!n[9](n[43])),t?s?(s.p(Da(n),o),o[0]&66048&&ot(s,1)):(s=Tc(Da(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(Ie(),mt(s,1,1,()=>{s=null}),Re())},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&rt(e),s&&s.d(n)}}}function Sc(r){let t,e,i,s;const n=[av,ov],o=[];function a(l,h){return l[8]?0:l[14]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Fe()},m(l,h){~t&&o[t].m(l,h),it(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(Ie(),mt(o[u],1,1,()=>{o[u]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){mt(e),s=!1},d(l){l&&rt(i),~t&&o[t].d(l)}}}function ov(r){let t=`${r[2]}-${r[5]}`,e,i,s=Cc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&36&&le(t,t=`${n[2]}-${n[5]}`)?(Ie(),mt(s,1,1,Dt),Re(),s=Cc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function av(r){let t,e,i=Ue(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Mc(bc(r,i,o));const n=o=>mt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Fe()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);it(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=Ue(o[8]);let l;for(l=0;l<i.length;l+=1){const h=bc(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=Mc(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Ie(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)mt(s[a]);e=!1},d(o){o&&rt(t),pi(s,o)}}}function Cc(r){let t,e;return t=new M0({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Ic(r){let t=r[39].id,e,i,s=Rc(r);return{c(){s.c(),e=Fe()},m(n,o){s.m(n,o),it(n,e,o),i=!0},p(n,o){o[0]&256&&le(t,t=n[39].id)?(Ie(),mt(s,1,1,Dt),Re(),s=Rc(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){mt(s),i=!1},d(n){n&&rt(e),s.d(n)}}}function Rc(r){let t,e;return t=new I0({props:{target:r[6],editor:r[24](r[39].target.selector),annotation:r[39],style:r[1],transform:r[12],viewportScale:r[17]}}),t.$on("change",function(){Vt(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){xe(t.$$.fragment)},m(i,s){ce(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){mt(t.$$.fragment,i),e=!1},d(i){de(t,i)}}}function Mc(r){let t,e,i=r[40]&&Ic(r);return{c(){i&&i.c(),t=Fe()},m(s,n){i&&i.m(s,n),it(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&ot(i,1)):(i=Ic(s),i.c(),ot(i,1),i.m(t.parentNode,t)):i&&(Ie(),mt(i,1,1,()=>{i=null}),Re())},i(s){e||(ot(i),e=!0)},o(s){mt(i),e=!1},d(s){s&&rt(t),i&&i.d(s)}}}function lv(r){let t,e,i,s,n,o,a=Ue(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=Ac(Ec(r,a,c));const h=c=>mt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&Sc(r);return{c(){t=K("svg"),e=K("g");for(let c=0;c<l.length;c+=1)l[c].c();i=K("g"),u&&u.c(),b(i,"class","drawing"),b(t,"role","application"),b(t,"tabindex",0),b(t,"class","a9s-annotationlayer"),cr(t,"drawing",r[14]),cr(t,"editing",r[8]),cr(t,"hidden",!r[3]),cr(t,"hover",r[15])},m(c,d){it(c,t,d),Et(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);Et(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Rt(t,"pointerup",function(){Vt(r[10])&&r[10].apply(this,arguments)}),Rt(t,"pointerdown",function(){Vt(r[11])&&r[11].apply(this,arguments)}),Rt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=Ue(r[16].filter(r[34]));let p;for(p=0;p<a.length;p+=1){const f=Ec(r,a,p);l[p]?(l[p].p(f,d),ot(l[p],1)):(l[p]=Ac(f),l[p].c(),ot(l[p],1),l[p].m(e,null))}for(Ie(),p=a.length;p<l.length;p+=1)h(p);Re()}r[6]?u?(u.p(r,d),d[0]&64&&ot(u,1)):(u=Sc(r),u.c(),ot(u,1),u.m(i,null)):u&&(Ie(),mt(u,1,1,()=>{u=null}),Re()),(!s||d[0]&16384)&&cr(t,"drawing",r[14]),(!s||d[0]&256)&&cr(t,"editing",r[8]),(!s||d[0]&8)&&cr(t,"hidden",!r[3]),(!s||d[0]&32768)&&cr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)mt(l[d]);mt(u),s=!1},d(c){c&&rt(t),pi(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,$e(o)}}}function hv(r,t,e){let i,s,n,o,a,l,h,u,c,d,p,f=Dt,m=()=>(f(),f=du(T,Y=>e(17,p=Y)),T);r.$$.on_destroy.push(()=>f());let{drawingEnabled:_}=t,{image:y}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:E=Mn()[0]}=t,{user:M}=t,{visible:S=!0}=t,R=0;const P=()=>e(5,R+=1),F=()=>E,k=()=>_;let I,A,T;mi(()=>m(e(7,T=K_(y,A))));const{hover:C,selection:L,store:N}=g;oa(r,C,Y=>e(15,u=Y)),oa(r,L,Y=>e(33,c=Y)),oa(r,N,Y=>e(16,d=Y));let B,X;const O=Y=>{B&&N.unobserve(B);const bt=Y.filter(({editable:dt})=>dt).map(({id:dt})=>dt);bt.length>0?(e(8,X=bt.map(dt=>N.getAnnotation(dt)).filter(dt=>dt&&Ze(dt))),B=dt=>{const{updated:pt}=dt.changes;e(8,X=pt==null?void 0:pt.map(vt=>vt.newValue))},N.observe(B,{annotations:bt})):e(8,X=void 0)},D=Y=>{const bt=Fu(),dt={id:bt,bodies:[],target:{annotation:bt,selector:Y.detail,creator:M,created:new Date}};N.addAnnotation(dt),L.setSelected(dt.id)},U=Y=>bt=>{var dt;const{target:pt}=Y,vt=10*60*1e3,Mt=((dt=pt.creator)==null?void 0:dt.id)!==M.id||!pt.created||new Date().getTime()-pt.created.getTime()>vt;N.updateTarget({...pt,selector:bt.detail,created:Mt?pt.created:new Date,updated:Mt?new Date:void 0,updatedBy:Mt?M:void 0})},V=Y=>{const{x:bt,y:dt}=xc(Y,A),pt=N.getAt(bt,dt);pt?u!==pt.id&&C.set(pt.id):C.set(void 0)},j=Y=>dc(Y),Q=Y=>Ze(Y);function yt(Y){En[Y?"unshift":"push"](()=>{I=Y,e(6,I)})}function Tt(Y){En[Y?"unshift":"push"](()=>{A=Y,e(4,A)})}return r.$$set=Y=>{"drawingEnabled"in Y&&e(0,_=Y.drawingEnabled),"image"in Y&&e(25,y=Y.image),"preferredDrawingMode"in Y&&e(26,v=Y.preferredDrawingMode),"state"in Y&&e(27,g=Y.state),"style"in Y&&e(1,x=Y.style),"toolName"in Y&&e(2,E=Y.toolName),"user"in Y&&e(28,M=Y.user),"visible"in Y&&e(3,S=Y.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=Pn(E)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,E))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=J0(A)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=ev(A,N),a,(e(10,l),e(4,A))),r.$$.dirty[1]&4&&e(9,h=Y=>c.selected.find(bt=>bt.id===Y.id&&bt.editable)),r.$$.dirty[1]&4&&O(c.selected)},[_,x,E,S,A,R,I,T,X,h,l,a,o,n,i,u,d,p,C,L,N,D,U,V,j,y,v,g,M,P,F,k,s,c,Q,yt,Tt]}class uv extends De{constructor(t){super(),Ne(this,t,hv,lv,le,{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 Pc(r,t,e=0,i=r.length-1,s=cv){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),p=Math.max(e,Math.floor(t-h*c/l+d)),f=Math.min(i,Math.floor(t+(l-h)*c/l+d));Pc(r,t,p,f,s)}const n=r[t];let o=e,a=i;for(Ls(r,e,t),s(r[i],n)>0&&Ls(r,e,i);o<a;){for(Ls(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?Ls(r,e,a):(a++,Ls(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Ls(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function cv(r,t){return r<t?-1:r>t?1:0}class dv{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(!Nn(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Nn(t,l)&&(e.leaf?i.push(a):Ba(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Nn(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Nn(t,o)){if(e.leaf||Ba(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ji([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const u=fv(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&Ba(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ji(t.slice(e,i+1)),Yi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ji([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Oc(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);Oc(t,u,c,l,this.compareMinY);for(let d=u;d<=c;d+=l){const p=Math.min(d+l-1,c);a.children.push(this._build(t,d,p,s-1))}}return Yi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],u=La(h),c=gv(t,h)-u;c<o?(o=c,n=u<n?u:n,a=h):c===o&&u<n&&(n=u,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),Fs(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ji(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Yi(i,this.toBBox),Yi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ji([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Yi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Bs(t,0,a,this.toBBox),h=Bs(t,a,i,this.toBBox),u=yv(l,h),c=La(l)+La(h);u<n?(n=u,s=a,o=c<o?c:o):u===n&&c<o&&(o=c,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:pv,n=t.leaf?this.compareMinY:mv,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Bs(t,0,e,n),a=Bs(t,i-e,i,n);let l=On(o)+On(a);for(let h=e;h<i-e;h++){const u=t.children[h];Fs(o,t.leaf?n(u):u),l+=On(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];Fs(a,t.leaf?n(u):u),l+=On(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Fs(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Yi(t[e],this.toBBox)}}function fv(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 Yi(r,t){Bs(r,0,r.children.length,t,r)}function Bs(r,t,e,i,s){s||(s=ji(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];Fs(s,r.leaf?i(o):o)}return s}function Fs(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 pv(r,t){return r.minX-t.minX}function mv(r,t){return r.minY-t.minY}function La(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function On(r){return r.maxX-r.minX+(r.maxY-r.minY)}function gv(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 yv(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Ba(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Nn(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ji(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Oc(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Pc(r,o,t,e,s),n.push(t,o,o,e)}}const _v=()=>{const r=new dv,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!An(o))return;const{minX:a,minY:l,maxX:h,maxY:u}=o.selector.geometry.bounds,c={minX:a,minY:l,maxX:h,maxY:u,target:o};r.insert(c),t.set(o.annotation,c)},n=o=>{if(!An(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)=>{const h=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(u=>u.target).filter(u=>u.selector.type===At.RECTANGLE||Ey(u.selector,o,a));return h.length>0?(h.sort((u,c)=>ca(u.selector)-ca(c.selector)),h):[]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(An(u)){const{minX:c,minY:d,maxX:p,maxY:f}=u.selector.geometry.bounds;return[...h,{minX:c,minY:d,maxX:p,maxY:f,target:u}]}else return h},[]);l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},Nc=r=>{const t=A_(),e=_v(),i=d_(t,r.userSelectAction,r.adapter),s=c_(t),n=M_();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)=>{const h=e.getAt(o,a,l);if(l)return h.map(u=>t.getAnnotation(u.annotation)).filter(Boolean).filter(l)[0];{const u=h[0];return u?t.getAnnotation(u.annotation):void 0}},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},vv=r=>{const t=Nc(r);return{...t,store:S_(t.store)}},xv=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Dc=r=>{const t=xv(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Lc=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Dc(r):e),Bc=(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}),Fc=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,Uc=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Fc?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Fc?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},bv=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Bc(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:ku.EDIT,theme:"light"}),s=vv(i),{selection:n,store:o}=s,a=R_(o,i.initialHistory),l=P_(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const u=Uc(a);let c=H_();Lc(e,h,i.theme);const d=new uv({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",I=>{const{originalEvent:A,annotation:T}=I.detail;T?n.userSelect(T.id,A):n.isEmpty()||n.clear()});const p=N_(s,a,i.adapter),f=()=>d.cancelDrawing(),m=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),u.destroy(),a.destroy()},_=()=>d.getDrawingTool(),y=()=>c,v=()=>d.isDrawingEnabled(),g=(I,A,T)=>yc(I,A,T),x=(I,A)=>fc(I,A),E=I=>{if(!Pn(I))throw`No drawing tool named ${I}`;d.$set({toolName:I})},M=I=>d.$set({drawingEnabled:I}),S=I=>{console.warn("Filter not implemented yet")},R=I=>d.$set({style:I}),P=I=>Lc(e,h,I),F=I=>{c=I,d.$set({user:I})},k=I=>d.$set({visible:I});return{...p,cancelDrawing:f,destroy:m,getDrawingTool:_,getUser:y,isDrawingEnabled:v,listDrawingTools:Mn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:M,setDrawingTool:E,setFilter:S,setStyle:R,setTheme:P,setUser:F,setVisible:k,element:h,state:s}};function Qt(){}function Fa(r,t){for(const e in t)r[e]=t[e];return r}function kc(r){return r()}function Gc(){return Object.create(null)}function ze(r){r.forEach(kc)}function Jt(r){return typeof r=="function"}function qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Ev(r){return Object.keys(r).length===0}function Tv(r,...t){if(r==null){for(const i of t)i(void 0);return Qt}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Dn(r,t,e){r.$$.on_destroy.push(Tv(t,e))}function Hc(r,t,e,i){if(r){const s=$c(r,t,e,i);return r[0](s)}}function $c(r,t,e,i){return r[1]&&i?Fa(e.ctx.slice(),r[1](i(t))):e.ctx}function Xc(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Vc(r,t,e,i,s,n){if(s){const o=$c(t,e,i,n);r.p(o,s)}}function zc(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 Yc(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Ln(r){return r??""}const jc=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ct(r,t){r.appendChild(t)}function at(r,t,e){r.insertBefore(t,e||null)}function nt(r){r.parentNode&&r.parentNode.removeChild(r)}function Yr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function st(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ua(r){return document.createTextNode(r)}function Le(){return Ua(" ")}function Ge(){return Ua("")}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 wv(r){return Array.from(r.childNodes)}function Av(r,t){t=""+t,r.data!==t&&(r.data=t)}function Wi(r,t,e){r.classList.toggle(t,!!e)}function Sv(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Us;function ks(r){Us=r}function ka(){if(!Us)throw new Error("Function called outside component initialization");return Us}function qi(r){ka().$$.on_mount.push(r)}function Cv(r){ka().$$.on_destroy.push(r)}function Ki(){const r=ka();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Sv(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Me(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Zi=[],Bn=[];let Qi=[];const Wc=[],qc=Promise.resolve();let Ga=!1;function Kc(){Ga||(Ga=!0,qc.then(Qc))}function Zc(){return Kc(),qc}function Ha(r){Qi.push(r)}const $a=new Set;let Ji=0;function Qc(){if(Ji!==0)return;const r=Us;do{try{for(;Ji<Zi.length;){const t=Zi[Ji];Ji++,ks(t),Iv(t.$$)}}catch(t){throw Zi.length=0,Ji=0,t}for(ks(null),Zi.length=0,Ji=0;Bn.length;)Bn.pop()();for(let t=0;t<Qi.length;t+=1){const e=Qi[t];$a.has(e)||($a.add(e),e())}Qi.length=0}while(Zi.length);for(;Wc.length;)Wc.pop()();Ga=!1,$a.clear(),ks(r)}function Iv(r){if(r.fragment!==null){r.update(),ze(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Ha)}}function Rv(r){const t=[],e=[];Qi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Qi=t}const Fn=new Set;let _i;function fe(){_i={r:0,c:[],p:_i}}function pe(){_i.r||ze(_i.c),_i=_i.p}function q(r,t){r&&r.i&&(Fn.delete(r),r.i(t))}function lt(r,t,e,i){if(r&&r.o){if(Fn.has(r))return;Fn.add(r),_i.c.push(()=>{Fn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Pe(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function Ht(r){r&&r.c()}function Ft(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Ha(()=>{const n=r.$$.on_mount.map(kc).filter(Jt);r.$$.on_destroy?r.$$.on_destroy.push(...n):ze(n),r.$$.on_mount=[]}),s.forEach(Ha)}function Ut(r,t){const e=r.$$;e.fragment!==null&&(Rv(e.after_update),ze(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Mv(r,t){r.$$.dirty[0]===-1&&(Zi.push(r),Kc(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ie(r,t,e,i,s,n,o=null,a=[-1]){const l=Us;ks(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Qt,not_equal:s,bound:Gc(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Gc(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&Mv(r,c)),d}):[],h.update(),u=!0,ze(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=wv(t.target);h.fragment&&h.fragment.l(c),c.forEach(nt)}else h.fragment&&h.fragment.c();t.intro&&q(r.$$.fragment),Ft(r,t.target,t.anchor),Qc()}ks(l)}class se{constructor(){$t(this,"$$");$t(this,"$$set")}$destroy(){Ut(this,1),this.$destroy=Qt}$on(t,e){if(!Jt(e))return Qt;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Ev(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Pv="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pv);var vi=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(vi||{}),Jc=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Jc||{}),Xa=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Xa||{}),gt=(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))(gt||{}),dr=(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))(dr||{}),z=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(z||{}),ts=(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))(ts||{}),ft=(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))(ft||{}),J=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(J||{}),Cr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(Cr||{}),jr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(jr||{}),fr=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(fr||{}),He=(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))(He||{}),pr=(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))(pr||{}),Va=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Va||{}),Ye=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Ye||{}),he=(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))(he||{}),ne=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(ne||{}),mr=(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))(mr||{});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 za=/iPhone/i,td=/iPod/i,ed=/iPad/i,rd=/\biOS-universal(?:.+)Mac\b/i,Ya=/\bAndroid(?:.+)Mobile\b/i,id=/Android/i,es=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Un=/Silk/i,Ir=/Windows Phone/i,sd=/\bWindows(?:.+)ARM\b/i,nd=/BlackBerry/i,od=/BB10/i,ad=/Opera Mini/i,ld=/\b(CriOS|Chrome)(?:.+)Mobile/i,hd=/Mobile(?:.+)Firefox\b/i,ud=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Ov(r){return function(t){return t.test(r)}}function cd(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=Ov(e),n={apple:{phone:s(za)&&!s(Ir),ipod:s(td),tablet:!s(za)&&(s(ed)||ud(t))&&!s(Ir),universal:s(rd),device:(s(za)||s(td)||s(ed)||s(rd)||ud(t))&&!s(Ir)},amazon:{phone:s(es),tablet:!s(es)&&s(Un),device:s(es)||s(Un)},android:{phone:!s(Ir)&&s(es)||!s(Ir)&&s(Ya),tablet:!s(Ir)&&!s(es)&&!s(Ya)&&(s(Un)||s(id)),device:!s(Ir)&&(s(es)||s(Un)||s(Ya)||s(id))||s(/\bokhttp\b/i)},windows:{phone:s(Ir),tablet:s(sd),device:s(Ir)||s(sd)},other:{blackberry:s(nd),blackberry10:s(od),opera:s(ad),firefox:s(hd),chrome:s(ld),device:s(nd)||s(od)||s(ad)||s(hd)||s(ld)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Nv=cd.default??cd,Rr=Nv(globalThis.navigator);tt.RETINA_PREFIX=/@([0-9\.]+)x/,tt.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dd(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Dv(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var fd={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,u){this.fn=l,this.context=h,this.once=u||!1}function n(l,h,u,c,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var p=new s(u,c||l,d),f=e?e+h:h;return l._events[f]?l._events[f].fn?l._events[f]=[l._events[f],p]:l._events[f].push(p):(l._events[f]=p,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],u,c;if(this._eventsCount===0)return h;for(c in u=this._events)t.call(u,c)&&h.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(u)):h},a.prototype.listeners=function(h){var u=e?e+h:h,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var d=0,p=c.length,f=new Array(p);d<p;d++)f[d]=c[d].fn;return f},a.prototype.listenerCount=function(h){var u=e?e+h:h,c=this._events[u];return c?c.fn?1:c.length:0},a.prototype.emit=function(h,u,c,d,p,f){var m=e?e+h:h;if(!this._events[m])return!1;var _=this._events[m],y=arguments.length,v,g;if(_.fn){switch(_.once&&this.removeListener(h,_.fn,void 0,!0),y){case 1:return _.fn.call(_.context),!0;case 2:return _.fn.call(_.context,u),!0;case 3:return _.fn.call(_.context,u,c),!0;case 4:return _.fn.call(_.context,u,c,d),!0;case 5:return _.fn.call(_.context,u,c,d,p),!0;case 6:return _.fn.call(_.context,u,c,d,p,f),!0}for(g=1,v=new Array(y-1);g<y;g++)v[g-1]=arguments[g];_.fn.apply(_.context,v)}else{var x=_.length,E;for(g=0;g<x;g++)switch(_[g].once&&this.removeListener(h,_[g].fn,void 0,!0),y){case 1:_[g].fn.call(_[g].context);break;case 2:_[g].fn.call(_[g].context,u);break;case 3:_[g].fn.call(_[g].context,u,c);break;case 4:_[g].fn.call(_[g].context,u,c,d);break;default:if(!v)for(E=1,v=new Array(y-1);E<y;E++)v[E-1]=arguments[E];_[g].fn.apply(_[g].context,v)}}return!0},a.prototype.on=function(h,u,c){return n(this,h,u,c,!1)},a.prototype.once=function(h,u,c){return n(this,h,u,c,!0)},a.prototype.removeListener=function(h,u,c,d){var p=e?e+h:h;if(!this._events[p])return this;if(!u)return o(this,p),this;var f=this._events[p];if(f.fn)f.fn===u&&(!d||f.once)&&(!c||f.context===c)&&o(this,p);else{for(var m=0,_=[],y=f.length;m<y;m++)(f[m].fn!==u||d&&!f[m].once||c&&f[m].context!==c)&&_.push(f[m]);_.length?this._events[p]=_.length===1?_[0]:_:o(this,p)}return this},a.prototype.removeAllListeners=function(h){var u;return h?(u=e?e+h:h,this._events[u]&&o(this,u)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(fd);var Lv=fd.exports;const Hs=dd(Lv);var ja={exports:{}};ja.exports=kn,ja.exports.default=kn;function kn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=pd(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,u,c,d,p;if(i&&(n=Gv(r,t,n,e)),r.length>80*e){a=h=r[0],l=u=r[1];for(var f=e;f<s;f+=e)c=r[f],d=r[f+1],c<a&&(a=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-a,u-l),p=p!==0?32767/p:0}return $s(n,o,e,a,l,p,0),o}function pd(r,t,e,i,s){var n,o;if(s===Ka(r,t,e,i)>0)for(n=t;n<e;n+=i)o=yd(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=yd(n,r[n],r[n+1],o);return o&&Gn(o,o.next)&&(Vs(o),o=o.next),o}function xi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Gn(e,e.next)||zt(e.prev,e,e.next)===0)){if(Vs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function $s(r,t,e,i,s,n,o){if(r){!o&&n&&zv(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?Fv(r,i,s,n):Bv(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Vs(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Uv(xi(r),t,e),$s(r,t,e,i,s,n,2)):o===2&&kv(r,t,e,i,s,n):$s(xi(r),t,e,i,s,n,1);break}}}}function Bv(r){var t=r.prev,e=r,i=r.next;if(zt(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,u=s<n?s<o?s:o:n<o?n:o,c=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,p=a>l?a>h?a:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&rs(s,a,n,l,o,h,f.x,f.y)&&zt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Fv(r,t,e,i){var s=r.prev,n=r,o=r.next;if(zt(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,u=s.y,c=n.y,d=o.y,p=a<l?a<h?a:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=a>l?a>h?a:h:l>h?l:h,_=u>c?u>d?u:d:c>d?c:d,y=Wa(p,f,t,e,i),v=Wa(m,_,t,e,i),g=r.prevZ,x=r.nextZ;g&&g.z>=y&&x&&x.z<=v;){if(g.x>=p&&g.x<=m&&g.y>=f&&g.y<=_&&g!==s&&g!==o&&rs(a,u,l,c,h,d,g.x,g.y)&&zt(g.prev,g,g.next)>=0||(g=g.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==s&&x!==o&&rs(a,u,l,c,h,d,x.x,x.y)&&zt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;g&&g.z>=y;){if(g.x>=p&&g.x<=m&&g.y>=f&&g.y<=_&&g!==s&&g!==o&&rs(a,u,l,c,h,d,g.x,g.y)&&zt(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;x&&x.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==s&&x!==o&&rs(a,u,l,c,h,d,x.x,x.y)&&zt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Uv(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Gn(s,n)&&md(s,i,i.next,n)&&Xs(s,n)&&Xs(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Vs(i),Vs(i.next),i=r=n),i=i.next}while(i!==r);return xi(i)}function kv(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Wv(o,a)){var l=gd(o,a);o=xi(o,o.next),l=xi(l,l.next),$s(o,t,e,i,s,n,0),$s(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Gv(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=pd(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(jv(h));for(s.sort(Hv),n=0;n<s.length;n++)e=$v(s[n],e);return e}function Hv(r,t){return r.x-t.x}function $v(r,t){var e=Xv(r,t);if(!e)return t;var i=gd(e,r);return xi(i,i.next),xi(e,e.next)}function Xv(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,u=o.y,c=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&rs(s<u?i:n,s,h,u,s<u?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Xs(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&Vv(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function Vv(r,t){return zt(r.prev,r,t.prev)<0&&zt(t.next,r,r.next)<0}function zv(r,t,e,i){var s=r;do s.z===0&&(s.z=Wa(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,Yv(s)}function Yv(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function Wa(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function jv(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 rs(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function Wv(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!qv(r,t)&&(Xs(r,t)&&Xs(t,r)&&Kv(r,t)&&(zt(r.prev,r,t.prev)||zt(r,t.prev,t))||Gn(r,t)&&zt(r.prev,r,r.next)>0&&zt(t.prev,t,t.next)>0)}function zt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Gn(r,t){return r.x===t.x&&r.y===t.y}function md(r,t,e,i){var s=$n(zt(r,t,e)),n=$n(zt(r,t,i)),o=$n(zt(e,i,r)),a=$n(zt(e,i,t));return!!(s!==n&&o!==a||s===0&&Hn(r,e,t)||n===0&&Hn(r,i,t)||o===0&&Hn(e,r,i)||a===0&&Hn(e,t,i))}function Hn(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 $n(r){return r>0?1:r<0?-1:0}function qv(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&&md(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Xs(r,t){return zt(r.prev,r,r.next)<0?zt(r,t,r.next)>=0&&zt(r,r.prev,t)>=0:zt(r,t,r.prev)<0||zt(r,r.next,t)<0}function Kv(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function gd(r,t){var e=new qa(r.i,r.x,r.y),i=new qa(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function yd(r,t,e,i){var s=new qa(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Vs(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 qa(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}kn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Ka(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,u=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Ka(r,h,u,e))}var c=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,p=i[a+1]*e,f=i[a+2]*e;c+=Math.abs((r[d]-r[f])*(r[p+1]-r[d+1])-(r[d]-r[p])*(r[f+1]-r[d+1]))}return o===0&&c===0?0:Math.abs((c-o)/o)};function Ka(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}kn.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var Zv=ja.exports;const Qv=dd(Zv);var Xn={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */Xn.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Gs=="object"&&Gs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,u=26,c=38,d=700,p=72,f=128,m="-",_=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,g={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-h,E=Math.floor,M=String.fromCharCode,S;function R(O){throw new RangeError(g[O])}function P(O,D){for(var U=O.length,V=[];U--;)V[U]=D(O[U]);return V}function F(O,D){var U=O.split("@"),V="";U.length>1&&(V=U[0]+"@",O=U[1]),O=O.replace(v,".");var j=O.split("."),Q=P(j,D).join(".");return V+Q}function k(O){for(var D=[],U=0,V=O.length,j,Q;U<V;)j=O.charCodeAt(U++),j>=55296&&j<=56319&&U<V?(Q=O.charCodeAt(U++),(Q&64512)==56320?D.push(((j&1023)<<10)+(Q&1023)+65536):(D.push(j),U--)):D.push(j);return D}function I(O){return P(O,function(D){var U="";return D>65535&&(D-=65536,U+=M(D>>>10&1023|55296),D=56320|D&1023),U+=M(D),U}).join("")}function A(O){return O-48<10?O-22:O-65<26?O-65:O-97<26?O-97:l}function T(O,D){return O+22+75*(O<26)-((D!=0)<<5)}function C(O,D,U){var V=0;for(O=U?E(O/d):O>>1,O+=E(O/D);O>x*u>>1;V+=l)O=E(O/x);return E(V+(x+1)*O/(O+c))}function L(O){var D=[],U=O.length,V,j=0,Q=f,yt=p,Tt,Y,bt,dt,pt,vt,Mt,Nt,_e;for(Tt=O.lastIndexOf(m),Tt<0&&(Tt=0),Y=0;Y<Tt;++Y)O.charCodeAt(Y)>=128&&R("not-basic"),D.push(O.charCodeAt(Y));for(bt=Tt>0?Tt+1:0;bt<U;){for(dt=j,pt=1,vt=l;bt>=U&&R("invalid-input"),Mt=A(O.charCodeAt(bt++)),(Mt>=l||Mt>E((a-j)/pt))&&R("overflow"),j+=Mt*pt,Nt=vt<=yt?h:vt>=yt+u?u:vt-yt,!(Mt<Nt);vt+=l)_e=l-Nt,pt>E(a/_e)&&R("overflow"),pt*=_e;V=D.length+1,yt=C(j-dt,V,dt==0),E(j/V)>a-Q&&R("overflow"),Q+=E(j/V),j%=V,D.splice(j++,0,Q)}return I(D)}function N(O){var D,U,V,j,Q,yt,Tt,Y,bt,dt,pt,vt=[],Mt,Nt,_e,Wt;for(O=k(O),Mt=O.length,D=f,U=0,Q=p,yt=0;yt<Mt;++yt)pt=O[yt],pt<128&&vt.push(M(pt));for(V=j=vt.length,j&&vt.push(m);V<Mt;){for(Tt=a,yt=0;yt<Mt;++yt)pt=O[yt],pt>=D&&pt<Tt&&(Tt=pt);for(Nt=V+1,Tt-D>E((a-U)/Nt)&&R("overflow"),U+=(Tt-D)*Nt,D=Tt,yt=0;yt<Mt;++yt)if(pt=O[yt],pt<D&&++U>a&&R("overflow"),pt==D){for(Y=U,bt=l;dt=bt<=Q?h:bt>=Q+u?u:bt-Q,!(Y<dt);bt+=l)Wt=Y-dt,_e=l-dt,vt.push(M(T(dt+Wt%_e,0))),Y=E(Wt/_e);vt.push(M(T(Y,0))),Q=C(U,Nt,V==j),U=0,++V}++U,++D}return vt.join("")}function B(O){return F(O,function(D){return _.test(D)?L(D.slice(4).toLowerCase()):D})}function X(O){return F(O,function(D){return y.test(D)?"xn--"+N(D):D})}if(o={version:"1.4.1",ucs2:{decode:k,encode:I},decode:L,encode:N,toASCII:X,toUnicode:B},i&&s)if(r.exports==i)s.exports=o;else for(S in o)o.hasOwnProperty(S)&&(i[S]=o[S]);else e.punycode=o})(Gs)}(Xn,Xn.exports);var Jv=Xn.exports,is=TypeError;const t1=Dv(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Za=typeof Map=="function"&&Map.prototype,Qa=Object.getOwnPropertyDescriptor&&Za?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Vn=Za&&Qa&&typeof Qa.get=="function"?Qa.get:null,_d=Za&&Map.prototype.forEach,Ja=typeof Set=="function"&&Set.prototype,tl=Object.getOwnPropertyDescriptor&&Ja?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,zn=Ja&&tl&&typeof tl.get=="function"?tl.get:null,vd=Ja&&Set.prototype.forEach,e1=typeof WeakMap=="function"&&WeakMap.prototype,zs=e1?WeakMap.prototype.has:null,r1=typeof WeakSet=="function"&&WeakSet.prototype,Ys=r1?WeakSet.prototype.has:null,i1=typeof WeakRef=="function"&&WeakRef.prototype,xd=i1?WeakRef.prototype.deref:null,s1=Boolean.prototype.valueOf,n1=Object.prototype.toString,o1=Function.prototype.toString,a1=String.prototype.match,el=String.prototype.slice,Wr=String.prototype.replace,l1=String.prototype.toUpperCase,bd=String.prototype.toLowerCase,Ed=RegExp.prototype.test,Td=Array.prototype.concat,gr=Array.prototype.join,h1=Array.prototype.slice,wd=Math.floor,rl=typeof BigInt=="function"?BigInt.prototype.valueOf:null,il=Object.getOwnPropertySymbols,sl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,ss=typeof Symbol=="function"&&typeof Symbol.iterator=="object",js=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===ss||!0)?Symbol.toStringTag:null,Ad=Object.prototype.propertyIsEnumerable,Sd=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Cd(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Ed.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-wd(-r):wd(r);if(i!==r){var s=String(i),n=el.call(t,s.length+1);return Wr.call(s,e,"$&_")+"."+Wr.call(Wr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Wr.call(t,e,"$&_")}var nl=t1,Id=nl.custom,Rd=Nd(Id)?Id:null,Md={__proto__:null,double:'"',single:"'"},u1={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Yn=function r(t,e,i,s){var n=e||{};if(Mr(n,"quoteStyle")&&!Mr(Md,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Mr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Mr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Mr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Mr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Ld(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Cd(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Cd(t,h):h}var u=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=u&&u>0&&typeof t=="object")return ol(t)?"[Array]":"[Object]";var c=I1(n,i);if(typeof s>"u")s=[];else if(Dd(s,t)>=0)return"[Circular]";function d(A,T,C){if(T&&(s=h1.call(s),s.push(T)),C){var L={depth:n.depth};return Mr(n,"quoteStyle")&&(L.quoteStyle=n.quoteStyle),r(A,L,i+1,s)}return r(A,n,i+1,s)}if(typeof t=="function"&&!Od(t)){var p=v1(t),f=jn(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+gr.call(f,", ")+" }":"")}if(Nd(t)){var m=ss?Wr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):sl.call(t);return typeof t=="object"&&!ss?Ws(m):m}if(A1(t)){for(var _="<"+bd.call(String(t.nodeName)),y=t.attributes||[],v=0;v<y.length;v++)_+=" "+y[v].name+"="+Pd(c1(y[v].value),"double",n);return _+=">",t.childNodes&&t.childNodes.length&&(_+="..."),_+="</"+bd.call(String(t.nodeName))+">",_}if(ol(t)){if(t.length===0)return"[]";var g=jn(t,d);return c&&!C1(g)?"["+ll(g,c)+"]":"[ "+gr.call(g,", ")+" ]"}if(f1(t)){var x=jn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Ad.call(t,"cause")?"{ ["+String(t)+"] "+gr.call(Td.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+gr.call(x,", ")+" }"}if(typeof t=="object"&&o){if(Rd&&typeof t[Rd]=="function"&&nl)return nl(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(x1(t)){var E=[];return _d&&_d.call(t,function(A,T){E.push(d(T,t,!0)+" => "+d(A,t))}),Bd("Map",Vn.call(t),E,c)}if(T1(t)){var M=[];return vd&&vd.call(t,function(A){M.push(d(A,t))}),Bd("Set",zn.call(t),M,c)}if(b1(t))return al("WeakMap");if(w1(t))return al("WeakSet");if(E1(t))return al("WeakRef");if(m1(t))return Ws(d(Number(t)));if(y1(t))return Ws(d(rl.call(t)));if(g1(t))return Ws(s1.call(t));if(p1(t))return Ws(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Gs<"u"&&t===Gs)return"{ [object globalThis] }";if(!d1(t)&&!Od(t)){var S=jn(t,d),R=Sd?Sd(t)===Object.prototype:t instanceof Object||t.constructor===Object,P=t instanceof Object?"":"null prototype",F=!R&&js&&Object(t)===t&&js in t?el.call(qr(t),8,-1):P?"Object":"",k=R||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",I=k+(F||P?"["+gr.call(Td.call([],F||[],P||[]),": ")+"] ":"");return S.length===0?I+"{}":c?I+"{"+ll(S,c)+"}":I+"{ "+gr.call(S,", ")+" }"}return String(t)};function Pd(r,t,e){var i=e.quoteStyle||t,s=Md[i];return s+r+s}function c1(r){return Wr.call(String(r),/"/g,"&quot;")}function bi(r){return!js||!(typeof r=="object"&&(js in r||typeof r[js]<"u"))}function ol(r){return qr(r)==="[object Array]"&&bi(r)}function d1(r){return qr(r)==="[object Date]"&&bi(r)}function Od(r){return qr(r)==="[object RegExp]"&&bi(r)}function f1(r){return qr(r)==="[object Error]"&&bi(r)}function p1(r){return qr(r)==="[object String]"&&bi(r)}function m1(r){return qr(r)==="[object Number]"&&bi(r)}function g1(r){return qr(r)==="[object Boolean]"&&bi(r)}function Nd(r){if(ss)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!sl)return!1;try{return sl.call(r),!0}catch{}return!1}function y1(r){if(!r||typeof r!="object"||!rl)return!1;try{return rl.call(r),!0}catch{}return!1}var _1=Object.prototype.hasOwnProperty||function(r){return r in this};function Mr(r,t){return _1.call(r,t)}function qr(r){return n1.call(r)}function v1(r){if(r.name)return r.name;var t=a1.call(o1.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Dd(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 x1(r){if(!Vn||!r||typeof r!="object")return!1;try{Vn.call(r);try{zn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function b1(r){if(!zs||!r||typeof r!="object")return!1;try{zs.call(r,zs);try{Ys.call(r,Ys)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function E1(r){if(!xd||!r||typeof r!="object")return!1;try{return xd.call(r),!0}catch{}return!1}function T1(r){if(!zn||!r||typeof r!="object")return!1;try{zn.call(r);try{Vn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function w1(r){if(!Ys||!r||typeof r!="object")return!1;try{Ys.call(r,Ys);try{zs.call(r,zs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function A1(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Ld(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Ld(el.call(r,0,t.maxStringLength),t)+i}var s=u1[t.quoteStyle||"single"];s.lastIndex=0;var n=Wr.call(Wr.call(r,s,"\\$1"),/[\x00-\x1f]/g,S1);return Pd(n,"single",t)}function S1(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":"")+l1.call(t.toString(16))}function Ws(r){return"Object("+r+")"}function al(r){return r+" { ? }"}function Bd(r,t,e,i){var s=i?ll(e,i):gr.call(e,", ");return r+" ("+t+") {"+s+"}"}function C1(r){for(var t=0;t<r.length;t++)if(Dd(r[t],`
3
+ `)>=0)return!1;return!0}function I1(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=gr.call(Array(r.indent+1)," ");else return null;return{base:e,prev:gr.call(Array(t+1),e)}}function ll(r,t){if(r.length===0)return"";var e=`
4
+ `+t.prev+t.base;return e+gr.call(r,","+e)+`
5
+ `+t.prev}function jn(r,t){var e=ol(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=Mr(r,s)?t(r[s],r):""}var n=typeof il=="function"?il(r):[],o;if(ss){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)Mr(r,l)&&(e&&String(Number(l))===l&&l<r.length||ss&&o["$"+l]instanceof Symbol||(Ed.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof il=="function")for(var h=0;h<n.length;h++)Ad.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var R1=Yn,M1=is,Wn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},P1=function(r,t){if(r){var e=Wn(r,t);return e&&e.value}},O1=function(r,t,e){var i=Wn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},N1=function(r,t){return r?!!Wn(r,t):!1},D1=function(r,t){if(r)return Wn(r,t,!0)},L1=function(){var t,e={assert:function(i){if(!e.has(i))throw new M1("Side channel does not contain "+R1(i))},delete:function(i){var s=t&&t.next,n=D1(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return P1(t,i)},has:function(i){return N1(t,i)},set:function(i,s){t||(t={next:void 0}),O1(t,i,s)}};return e},Fd=Object,B1=Error,F1=EvalError,U1=RangeError,k1=ReferenceError,G1=SyntaxError,H1=URIError,$1=Math.abs,X1=Math.floor,V1=Math.max,z1=Math.min,Y1=Math.pow,j1=Math.round,W1=Number.isNaN||function(t){return t!==t},q1=W1,K1=function(t){return q1(t)||t===0?t:t<0?-1:1},Z1=Object.getOwnPropertyDescriptor,qn=Z1;if(qn)try{qn([],"length")}catch{qn=null}var Ud=qn,Kn=Object.defineProperty||!1;if(Kn)try{Kn({},"a",{value:1})}catch{Kn=!1}var Q1=Kn,hl,kd;function J1(){return kd||(kd=1,hl=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(var n in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var o=Object.getOwnPropertySymbols(t);if(o.length!==1||o[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(t,e);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),hl}var ul,Gd;function tx(){if(Gd)return ul;Gd=1;var r=typeof Symbol<"u"&&Symbol,t=J1();return ul=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},ul}var cl,Hd;function $d(){return Hd||(Hd=1,cl=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),cl}var dl,Xd;function Vd(){if(Xd)return dl;Xd=1;var r=Fd;return dl=r.getPrototypeOf||null,dl}var ex="Function.prototype.bind called on incompatible ",rx=Object.prototype.toString,ix=Math.max,sx="[object Function]",zd=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},nx=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},ox=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},ax=function(t){var e=this;if(typeof e!="function"||rx.apply(e)!==sx)throw new TypeError(ex+e);for(var i=nx(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,zd(i,arguments));return Object(u)===u?u:this}return e.apply(t,zd(i,arguments))},o=ix(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+ox(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},lx=ax,Zn=Function.prototype.bind||lx,fl=Function.prototype.call,Yd=Function.prototype.apply,hx=typeof Reflect<"u"&&Reflect&&Reflect.apply,ux=Zn,cx=Yd,dx=fl,fx=hx,px=fx||ux.call(dx,cx),mx=Zn,gx=is,yx=fl,_x=px,jd=function(t){if(t.length<1||typeof t[0]!="function")throw new gx("a function is required");return _x(mx,yx,t)},pl,Wd;function vx(){if(Wd)return pl;Wd=1;var r=jd,t=Ud,e;try{e=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var i=!!e&&t&&t(Object.prototype,"__proto__"),s=Object,n=s.getPrototypeOf;return pl=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,pl}var ml,qd;function xx(){if(qd)return ml;qd=1;var r=$d(),t=Vd(),e=vx();return ml=r?function(s){return r(s)}:t?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return t(s)}:e?function(s){return e(s)}:null,ml}var gl,Kd;function bx(){if(Kd)return gl;Kd=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Zn;return gl=e.call(r,t),gl}var St,Ex=Fd,Tx=B1,wx=F1,Ax=U1,Sx=k1,ns=G1,os=is,Cx=H1,Ix=$1,Rx=X1,Mx=V1,Px=z1,Ox=Y1,Nx=j1,Dx=K1,Zd=Function,yl=function(r){try{return Zd('"use strict"; return ('+r+").constructor;")()}catch{}},qs=Ud,Lx=Q1,_l=function(){throw new os},Bx=qs?function(){try{return arguments.callee,_l}catch{try{return qs(arguments,"callee").get}catch{return _l}}}():_l,as=tx()(),me=xx(),Fx=Vd(),Ux=$d(),Qd=Yd,Ks=fl,ls={},kx=typeof Uint8Array>"u"||!me?St:me(Uint8Array),Ei={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?St:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?St:ArrayBuffer,"%ArrayIteratorPrototype%":as&&me?me([][Symbol.iterator]()):St,"%AsyncFromSyncIteratorPrototype%":St,"%AsyncFunction%":ls,"%AsyncGenerator%":ls,"%AsyncGeneratorFunction%":ls,"%AsyncIteratorPrototype%":ls,"%Atomics%":typeof Atomics>"u"?St:Atomics,"%BigInt%":typeof BigInt>"u"?St:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?St:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?St:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?St:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Tx,"%eval%":eval,"%EvalError%":wx,"%Float16Array%":typeof Float16Array>"u"?St:Float16Array,"%Float32Array%":typeof Float32Array>"u"?St:Float32Array,"%Float64Array%":typeof Float64Array>"u"?St:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?St:FinalizationRegistry,"%Function%":Zd,"%GeneratorFunction%":ls,"%Int8Array%":typeof Int8Array>"u"?St:Int8Array,"%Int16Array%":typeof Int16Array>"u"?St:Int16Array,"%Int32Array%":typeof Int32Array>"u"?St:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":as&&me?me(me([][Symbol.iterator]())):St,"%JSON%":typeof JSON=="object"?JSON:St,"%Map%":typeof Map>"u"?St:Map,"%MapIteratorPrototype%":typeof Map>"u"||!as||!me?St:me(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ex,"%Object.getOwnPropertyDescriptor%":qs,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?St:Promise,"%Proxy%":typeof Proxy>"u"?St:Proxy,"%RangeError%":Ax,"%ReferenceError%":Sx,"%Reflect%":typeof Reflect>"u"?St:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?St:Set,"%SetIteratorPrototype%":typeof Set>"u"||!as||!me?St:me(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?St:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":as&&me?me(""[Symbol.iterator]()):St,"%Symbol%":as?Symbol:St,"%SyntaxError%":ns,"%ThrowTypeError%":Bx,"%TypedArray%":kx,"%TypeError%":os,"%Uint8Array%":typeof Uint8Array>"u"?St:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?St:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?St:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?St:Uint32Array,"%URIError%":Cx,"%WeakMap%":typeof WeakMap>"u"?St:WeakMap,"%WeakRef%":typeof WeakRef>"u"?St:WeakRef,"%WeakSet%":typeof WeakSet>"u"?St:WeakSet,"%Function.prototype.call%":Ks,"%Function.prototype.apply%":Qd,"%Object.defineProperty%":Lx,"%Object.getPrototypeOf%":Fx,"%Math.abs%":Ix,"%Math.floor%":Rx,"%Math.max%":Mx,"%Math.min%":Px,"%Math.pow%":Ox,"%Math.round%":Nx,"%Math.sign%":Dx,"%Reflect.getPrototypeOf%":Ux};if(me)try{null.error}catch(r){var Gx=me(me(r));Ei["%Error.prototype%"]=Gx}var Hx=function r(t){var e;if(t==="%AsyncFunction%")e=yl("async function () {}");else if(t==="%GeneratorFunction%")e=yl("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=yl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&me&&(e=me(s.prototype))}return Ei[t]=e,e},Jd={__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"]},Zs=Zn,Qn=bx(),$x=Zs.call(Ks,Array.prototype.concat),Xx=Zs.call(Qd,Array.prototype.splice),tf=Zs.call(Ks,String.prototype.replace),Jn=Zs.call(Ks,String.prototype.slice),Vx=Zs.call(Ks,RegExp.prototype.exec),zx=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Yx=/\\(\\)?/g,jx=function(t){var e=Jn(t,0,1),i=Jn(t,-1);if(e==="%"&&i!=="%")throw new ns("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new ns("invalid intrinsic syntax, expected opening `%`");var s=[];return tf(t,zx,function(n,o,a,l){s[s.length]=a?tf(l,Yx,"$1"):o||n}),s},Wx=function(t,e){var i=t,s;if(Qn(Jd,i)&&(s=Jd[i],i="%"+s[0]+"%"),Qn(Ei,i)){var n=Ei[i];if(n===ls&&(n=Hx(i)),typeof n>"u"&&!e)throw new os("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new ns("intrinsic "+t+" does not exist!")},vl=function(t,e){if(typeof t!="string"||t.length===0)throw new os("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new os('"allowMissing" argument must be a boolean');if(Vx(/^%?[^%]*%?$/,t)===null)throw new ns("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=jx(t),s=i.length>0?i[0]:"",n=Wx("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],Xx(i,$x([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=Jn(d,0,1),f=Jn(d,-1);if((p==='"'||p==="'"||p==="`"||f==='"'||f==="'"||f==="`")&&p!==f)throw new ns("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",Qn(Ei,o))a=Ei[o];else if(a!=null){if(!(d in a)){if(!e)throw new os("base intrinsic for "+t+" exists, but the property is not available.");return}if(qs&&u+1>=i.length){var m=qs(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=Qn(a,d),a=a[d];c&&!l&&(Ei[o]=a)}}return a},ef=vl,rf=jd,qx=rf([ef("%String.prototype.indexOf%")]),sf=function(t,e){var i=ef(t,!!e);return typeof i=="function"&&qx(t,".prototype.")>-1?rf([i]):i},Kx=vl,Qs=sf,Zx=Yn,Qx=is,nf=Kx("%Map%",!0),Jx=Qs("Map.prototype.get",!0),tb=Qs("Map.prototype.set",!0),eb=Qs("Map.prototype.has",!0),rb=Qs("Map.prototype.delete",!0),ib=Qs("Map.prototype.size",!0),of=!!nf&&function(){var t,e={assert:function(i){if(!e.has(i))throw new Qx("Side channel does not contain "+Zx(i))},delete:function(i){if(t){var s=rb(t,i);return ib(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return Jx(t,i)},has:function(i){return t?eb(t,i):!1},set:function(i,s){t||(t=new nf),tb(t,i,s)}};return e},sb=vl,to=sf,nb=Yn,eo=of,ob=is,hs=sb("%WeakMap%",!0),ab=to("WeakMap.prototype.get",!0),lb=to("WeakMap.prototype.set",!0),hb=to("WeakMap.prototype.has",!0),ub=to("WeakMap.prototype.delete",!0),cb=hs?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new ob("Side channel does not contain "+nb(s))},delete:function(s){if(hs&&s&&(typeof s=="object"||typeof s=="function")){if(t)return ub(t,s)}else if(eo&&e)return e.delete(s);return!1},get:function(s){return hs&&s&&(typeof s=="object"||typeof s=="function")&&t?ab(t,s):e&&e.get(s)},has:function(s){return hs&&s&&(typeof s=="object"||typeof s=="function")&&t?hb(t,s):!!e&&e.has(s)},set:function(s,n){hs&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new hs),lb(t,s,n)):eo&&(e||(e=eo()),e.set(s,n))}};return i}:eo,db=is,fb=Yn,pb=L1,mb=of,gb=cb,yb=gb||mb||pb,_b=function(){var t,e={assert:function(i){if(!e.has(i))throw new db("Side channel does not contain "+fb(i))},delete:function(i){return!!t&&t.delete(i)},get:function(i){return t&&t.get(i)},has:function(i){return!!t&&t.has(i)},set:function(i,s){t||(t=yb()),t.set(i,s)}};return e},vb=String.prototype.replace,xb=/%20/g,xl={RFC1738:"RFC1738",RFC3986:"RFC3986"},bl={default:xl.RFC3986,formatters:{RFC1738:function(r){return vb.call(r,xb,"+")},RFC3986:function(r){return String(r)}},RFC1738:xl.RFC1738,RFC3986:xl.RFC3986},bb=bl,El=Object.prototype.hasOwnProperty,Ti=Array.isArray,yr=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),Eb=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Ti(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},af=function(t,e){for(var i=e&&e.plainObjects?{__proto__:null}:{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},Tb=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(Ti(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!El.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Ti(t)&&!Ti(e)&&(s=af(t,i)),Ti(t)&&Ti(e)?(e.forEach(function(n,o){if(El.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return El.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},wb=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},Ab=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}},Tl=1024,Sb=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;l+=Tl){for(var h=o.length>=Tl?o.slice(l,l+Tl):o,u=[],c=0;c<h.length;++c){var d=h.charCodeAt(c);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||n===bb.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=yr[d];continue}if(d<2048){u[u.length]=yr[192|d>>6]+yr[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=yr[224|d>>12]+yr[128|d>>6&63]+yr[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=yr[240|d>>18]+yr[128|d>>12&63]+yr[128|d>>6&63]+yr[128|d&63]}a+=u.join("")}return a},Cb=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],u=o[h];typeof u=="object"&&u!==null&&i.indexOf(u)===-1&&(e.push({obj:o,prop:h}),i.push(u))}return Eb(e),t},Ib=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},Rb=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},Mb=function(t,e){return[].concat(t,e)},Pb=function(t,e){if(Ti(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},lf={arrayToObject:af,assign:wb,combine:Mb,compact:Cb,decode:Ab,encode:Sb,isBuffer:Rb,isRegExp:Ib,maybeMap:Pb,merge:Tb},hf=_b,ro=lf,Js=bl,Ob=Object.prototype.hasOwnProperty,uf={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},_r=Array.isArray,Nb=Array.prototype.push,cf=function(r,t){Nb.apply(r,_r(t)?t:[t])},Db=Date.prototype.toISOString,df=Js.default,ue={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ro.encode,encodeValuesOnly:!1,filter:void 0,format:df,formatter:Js.formatters[df],indices:!1,serializeDate:function(t){return Db.call(t)},skipNulls:!1,strictNullHandling:!1},Lb=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},wl={},Bb=function r(t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v){for(var g=t,x=v,E=0,M=!1;(x=x.get(wl))!==void 0&&!M;){var S=x.get(t);if(E+=1,typeof S<"u"){if(S===E)throw new RangeError("Cyclic object value");M=!0}typeof x.get(wl)>"u"&&(E=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=p(g):i==="comma"&&_r(g)&&(g=ro.maybeMap(g,function(O){return O instanceof Date?p(O):O})),g===null){if(o)return h&&!_?h(e,ue.encoder,y,"key",f):e;g=""}if(Lb(g)||ro.isBuffer(g)){if(h){var R=_?e:h(e,ue.encoder,y,"key",f);return[m(R)+"="+m(h(g,ue.encoder,y,"value",f))]}return[m(e)+"="+m(String(g))]}var P=[];if(typeof g>"u")return P;var F;if(i==="comma"&&_r(g))_&&h&&(g=ro.maybeMap(g,h)),F=[{value:g.length>0?g.join(",")||null:void 0}];else if(_r(u))F=u;else{var k=Object.keys(g);F=c?k.sort(c):k}var I=l?String(e).replace(/\./g,"%2E"):String(e),A=s&&_r(g)&&g.length===1?I+"[]":I;if(n&&_r(g)&&g.length===0)return A+"[]";for(var T=0;T<F.length;++T){var C=F[T],L=typeof C=="object"&&C&&typeof C.value<"u"?C.value:g[C];if(!(a&&L===null)){var N=d&&l?String(C).replace(/\./g,"%2E"):String(C),B=_r(g)?typeof i=="function"?i(A,N):A:A+(d?"."+N:"["+N+"]");v.set(t,E);var X=hf();X.set(wl,v),cf(P,r(L,B,i,s,n,o,a,l,i==="comma"&&_&&_r(g)?null:h,u,c,d,p,f,m,_,y,X))}}return P},Fb=function(t){if(!t)return ue;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||ue.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=Js.default;if(typeof t.format<"u"){if(!Ob.call(Js.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Js.formatters[i],n=ue.filter;(typeof t.filter=="function"||_r(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in uf?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=ue.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:ue.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:ue.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:ue.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:ue.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?ue.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:ue.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:ue.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:ue.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:ue.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:ue.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:ue.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:ue.strictNullHandling}},Ub=function(r,t){var e=r,i=Fb(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):_r(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=uf[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=hf(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||cf(o,Bb(d,c,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var p=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),p.length>0?f+p:""},wi=lf,Al=Object.prototype.hasOwnProperty,ff=Array.isArray,Kt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:wi.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},kb=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},pf=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},Gb="utf8=%26%2310003%3B",Hb="utf8=%E2%9C%93",$b=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,e.throwOnLimitExceeded?n+1:n);if(e.throwOnLimitExceeded&&o.length>n)throw new RangeError("Parameter limit exceeded. Only "+n+" parameter"+(n===1?"":"s")+" allowed.");var a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===Hb?h="utf-8":o[l]===Gb&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,p,f;d===-1?(p=e.decoder(u,Kt.decoder,h,"key"),f=e.strictNullHandling?null:""):(p=e.decoder(u.slice(0,d),Kt.decoder,h,"key"),f=wi.maybeMap(pf(u.slice(d+1),e,ff(i[p])?i[p].length:0),function(_){return e.decoder(_,Kt.decoder,h,"value")})),f&&e.interpretNumericEntities&&h==="iso-8859-1"&&(f=kb(String(f))),u.indexOf("[]=")>-1&&(f=ff(f)?[f]:f);var m=Al.call(i,p);m&&e.duplicates==="combine"?i[p]=wi.combine(i[p],f):(!m||e.duplicates==="last")&&(i[p]=f)}return i},Xb=function(r,t,e,i){var s=0;if(r.length>0&&r[r.length-1]==="[]"){var n=r.slice(0,-1).join("");s=Array.isArray(t)&&t[n]?t[n].length:0}for(var o=i?t:pf(t,e,s),a=r.length-1;a>=0;--a){var l,h=r[a];if(h==="[]"&&e.parseArrays)l=e.allowEmptyArrays&&(o===""||e.strictNullHandling&&o===null)?[]:wi.combine([],o);else{l=e.plainObjects?{__proto__:null}:{};var u=h.charAt(0)==="["&&h.charAt(h.length-1)==="]"?h.slice(1,-1):h,c=e.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(c,10);!e.parseArrays&&c===""?l={0:o}:!isNaN(d)&&h!==c&&String(d)===c&&d>=0&&e.parseArrays&&d<=e.arrayLimit?(l=[],l[d]=o):c!=="__proto__"&&(l[c]=o)}o=l}return o},Vb=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,u=[];if(h){if(!i.plainObjects&&Al.call(Object.prototype,h)&&!i.allowPrototypes)return;u.push(h)}for(var c=0;i.depth>0&&(l=a.exec(n))!==null&&c<i.depth;){if(c+=1,!i.plainObjects&&Al.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;u.push(l[1])}if(l){if(i.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+i.depth+" and strictDepth is true");u.push("["+n.slice(l.index)+"]")}return Xb(u,e,i,s)}},zb=function(t){if(!t)return Kt;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"?Kt.charset:t.charset,i=typeof t.duplicates>"u"?Kt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Kt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Kt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Kt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Kt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Kt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Kt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Kt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Kt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Kt.decoder,delimiter:typeof t.delimiter=="string"||wi.isRegExp(t.delimiter)?t.delimiter:Kt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Kt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Kt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Kt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Kt.plainObjects,strictDepth:typeof t.strictDepth=="boolean"?!!t.strictDepth:Kt.strictDepth,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Kt.strictNullHandling,throwOnLimitExceeded:typeof t.throwOnLimitExceeded=="boolean"?t.throwOnLimitExceeded:!1}},Yb=function(r,t){var e=zb(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?$b(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=Vb(a,i[a],e,typeof r=="string");s=wi.merge(s,l,e)}return e.allowSparse===!0?s:wi.compact(s)},jb=Ub,Wb=Yb,qb=bl,Kb={formats:qb,parse:Wb,stringify:jb},Zb=Jv;function Pr(){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 Qb=/^([a-z0-9.+-]+:)/i,Jb=/:[0-9]*$/,tE=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,eE=["<",">",'"',"`"," ","\r",`
6
+ `," "],rE=["{","}","|","\\","^","`"].concat(eE),Sl=["'"].concat(rE),mf=["%","/","?",";","#"].concat(Sl),gf=["/","?","#"],iE=255,yf=/^[+a-z0-9A-Z_-]{0,63}$/,sE=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,nE={javascript:!0,"javascript:":!0},Cl={javascript:!0,"javascript:":!0},us={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},Il=Kb;function oE(r,t,e){if(r&&typeof r=="object"&&r instanceof Pr)return r;var i=new Pr;return i.parse(r,t,e),i}Pr.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=tE.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=Il.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=Qb.exec(a);if(h){h=h[0];var u=h.toLowerCase();this.protocol=u,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var c=a.substr(0,2)==="//";c&&!(h&&Cl[h])&&(a=a.substr(2),this.slashes=!0)}if(!Cl[h]&&(c||h&&!us[h])){for(var d=-1,p=0;p<gf.length;p++){var f=a.indexOf(gf[p]);f!==-1&&(d===-1||f<d)&&(d=f)}var m,_;d===-1?_=a.lastIndexOf("@"):_=a.lastIndexOf("@",d),_!==-1&&(m=a.slice(0,_),a=a.slice(_+1),this.auth=decodeURIComponent(m)),d=-1;for(var p=0;p<mf.length;p++){var f=a.indexOf(mf[p]);f!==-1&&(d===-1||f<d)&&(d=f)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var y=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!y)for(var v=this.hostname.split(/\./),p=0,g=v.length;p<g;p++){var x=v[p];if(x&&!x.match(yf)){for(var E="",M=0,S=x.length;M<S;M++)x.charCodeAt(M)>127?E+="x":E+=x[M];if(!E.match(yf)){var R=v.slice(0,p),P=v.slice(p+1),F=x.match(sE);F&&(R.push(F[1]),P.unshift(F[2])),P.length&&(a="/"+P.join(".")+a),this.hostname=R.join(".");break}}}this.hostname.length>iE?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=Zb.toASCII(this.hostname));var k=this.port?":"+this.port:"",I=this.hostname||"";this.host=I+k,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!nE[u])for(var p=0,g=Sl.length;p<g;p++){var A=Sl[p];if(a.indexOf(A)!==-1){var T=encodeURIComponent(A);T===A&&(T=escape(A)),a=a.split(A).join(T)}}var C=a.indexOf("#");C!==-1&&(this.hash=a.substr(C),a=a.slice(0,C));var L=a.indexOf("?");if(L!==-1?(this.search=a.substr(L),this.query=a.substr(L+1),t&&(this.query=Il.parse(this.query)),a=a.slice(0,L)):t&&(this.search="",this.query={}),a&&(this.pathname=a),us[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var k=this.pathname||"",N=this.search||"";this.path=k+N}return this.href=this.format(),this},Pr.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=Il.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||us[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i},Pr.prototype.resolve=function(r){return this.resolveObject(oE(r,!1,!0)).format()},Pr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Pr;t.parse(r,!1,!0),r=t}for(var e=new Pr,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return us[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(!us[r.protocol]){for(var h=Object.keys(r),u=0;u<h.length;u++){var c=h[u];e[c]=r[c]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!Cl[r.protocol]){for(var g=(r.pathname||"").split("/");g.length&&!(r.host=g.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),g[0]!==""&&g.unshift(""),g.length<2&&g.unshift(""),e.pathname=g.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",p=e.search||"";e.path=d+p}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var f=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",_=m||f||e.host&&r.pathname,y=_,v=e.pathname&&e.pathname.split("/")||[],g=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!us[e.protocol];if(x&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(g[0]===""?g[0]=r.host:g.unshift(r.host)),r.host=null),_=_&&(g[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=g;else if(g.length)v||(v=[]),v.pop(),v=v.concat(g),e.search=r.search,e.query=r.query;else if(r.search!=null){if(x){e.host=v.shift(),e.hostname=e.host;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.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 M=v.slice(-1)[0],S=(e.host||r.host||v.length>1)&&(M==="."||M==="..")||M==="",R=0,P=v.length;P>=0;P--)M=v[P],M==="."?v.splice(P,1):M===".."?(v.splice(P,1),R++):R&&(v.splice(P,1),R--);if(!_&&!y)for(;R--;R)v.unshift("..");_&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),S&&v.join("/").substr(-1)!=="/"&&v.push("");var F=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=F?"":v.length?v.shift():"",e.host=e.hostname;var E=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;E&&(e.auth=E.shift(),e.hostname=E.shift(),e.host=e.hostname)}return _=_||e.host&&v.length,_&&!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},Pr.prototype.parseHost=function(){var r=this.host,t=Jb.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 _f={};function wt(r,t,e=3){if(_f[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
7
7
  Deprecated since v${r}`):(i=i.split(`
8
8
  `).splice(e).join(`
9
9
  `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
10
10
  Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
11
- Deprecated since v${r}`),console.warn(i))),nf[t]=!0}function tr(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Qs(r){return r.split("?")[0].split("#")[0]}function Bb(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fb(r,t,e){return r.replace(new RegExp(Bb(t),"g"),e)}function Ub(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const de={toPosix(r){return Fb(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){tr(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(tr(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Qs(this.toPosix(t??Q.ADAPTER.getBaseUrl())),s=Qs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?de.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(tr(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=Ub(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return tr(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(tr(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(tr(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){tr(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){tr(r),t&&tr(t),r=Qs(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){tr(r),r=Qs(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){tr(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Qs(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,u=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Al;async function kb(){return Al??(Al=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return Ge.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 Ge.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?Ge.PMA:Ge.UNPACK})()),Al}let Sl;function Gb(){return typeof Sl>"u"&&(Sl=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:Q.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!Q.ADAPTER.getWebGLRenderingContext())return!1;const e=Q.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),Sl}var Hb={grad:.9,turn:360,rad:360/(2*Math.PI)},Mr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},fe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},We=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},of=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},af=function(r){return{r:We(r.r,0,255),g:We(r.g,0,255),b:We(r.b,0,255),a:We(r.a)}},Cl=function(r){return{r:fe(r.r),g:fe(r.g),b:fe(r.b),a:fe(r.a,3)}},$b=/^#([0-9a-f]{3,8})$/i,Jn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},lf=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},hf=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},uf=function(r){return{h:of(r.h),s:We(r.s,0,100),l:We(r.l,0,100),a:We(r.a)}},cf=function(r){return{h:fe(r.h),s:fe(r.s),l:fe(r.l),a:fe(r.a,3)}},df=function(r){return hf((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},Js=function(r){return{h:(t=lf(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},Vb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Xb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Il={string:[[function(r){var t=$b.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?fe(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?fe(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Yb.exec(r)||Wb.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:af({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=Vb.exec(r)||Xb.exec(r);if(!t)return null;var e,i,s=uf({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Hb[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return df(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Mr(t)&&Mr(e)&&Mr(i)?af({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Mr(t)||!Mr(e)||!Mr(i))return null;var o=uf({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return df(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Mr(t)||!Mr(e)||!Mr(i))return null;var o=function(a){return{h:of(a.h),s:We(a.s,0,100),v:We(a.v,0,100),a:We(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return hf(o)},"hsv"]]},ff=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]},jb=function(r){return typeof r=="string"?ff(r.trim(),Il.string):typeof r=="object"&&r!==null?ff(r,Il.object):[null,void 0]},Rl=function(r,t){var e=Js(r);return{h:e.h,s:We(e.s+100*t,0,100),l:e.l,a:e.a}},Ml=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},pf=function(r,t){var e=Js(r);return{h:e.h,s:e.s,l:We(e.l+100*t,0,100),a:e.a}},Ol=function(){function r(t){this.parsed=jb(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 fe(Ml(this.rgba),2)},r.prototype.isDark=function(){return Ml(this.rgba)<.5},r.prototype.isLight=function(){return Ml(this.rgba)>=.5},r.prototype.toHex=function(){return t=Cl(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?Jn(fe(255*n)):"","#"+Jn(e)+Jn(i)+Jn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Cl(this.rgba)},r.prototype.toRgbString=function(){return t=Cl(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return cf(Js(this.rgba))},r.prototype.toHslString=function(){return t=cf(Js(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=lf(this.rgba),{h:fe(t.h),s:fe(t.s),v:fe(t.v),a:fe(t.a,3)};var t},r.prototype.invert=function(){return _r({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),_r(Rl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),_r(Rl(this.rgba,-t))},r.prototype.grayscale=function(){return _r(Rl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),_r(pf(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),_r(pf(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"?_r({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):fe(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Js(this.rgba);return typeof t=="number"?_r({h:t,s:e.s,l:e.l,a:e.a}):fe(e.h)},r.prototype.isEqual=function(t){return this.toHex()===_r(t).toHex()},r}(),_r=function(r){return r instanceof Ol?r:new Ol(r)},mf=[],zb=function(r){r.forEach(function(t){mf.indexOf(t)<0&&(t(Ol,Il),mf.push(t))})};function qb(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var m=(a=u,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<c&&(c=m,d=f)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}zb([qb]);const ns=class jo{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 jo)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=jo.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=jo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=_r(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};ns.shared=new ns,ns.temp=new ns,ns.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Mt=ns;function Kb(r){return bt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Mt.shared.setValue(r).toHex()}function Zb(r){return bt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Mt.shared.setValue(r).toNumber()}function Qb(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[pt.NORMAL_NPM]=pt.NORMAL,r[pt.ADD_NPM]=pt.ADD,r[pt.SCREEN_NPM]=pt.SCREEN,t[pt.NORMAL]=pt.NORMAL_NPM,t[pt.ADD]=pt.ADD_NPM,t[pt.SCREEN]=pt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const gf=Qb();function yf(r,t){return gf[t?1:0][r]}function Jb(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function _f(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 to(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 vf(r){return!(r&r-1)&&!!r}function xf(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 os(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function zr(r){return r===0?0:r<0?-1:1}let tE=0;function bi(){return++tE}const Pl=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}};Pl.EMPTY=new Pl(0,0,0,0);let bf=Pl;const Ef={},vr=Object.create(null),qr=Object.create(null);class eE{constructor(t,e,i){this._canvas=Q.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||Q.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 Tf(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function wf(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function rE(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Tf(s,t,o);)++o;if(o===e)return bf.EMPTY;for(;Tf(s,t,l);)--l;for(;wf(s,t,n,o,l);)++n;for(;wf(s,t,a,o,l);)--a;return++a,++l,new bf(n,o,a,l)}function iE(r){const t=rE(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function sE(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 Or(r,t=1){var i;const e=(i=Q.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var j=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(j||{});const Nl=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},Af=(r,t)=>Nl(r).priority??t,st={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Nl).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Nl).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Af(n,e)-Af(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Ll{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 nE=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
12
- `);function oE(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
13
- else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function aE(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=nE.replace(/%forloop%/gi,oE(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const Dl=0,Bl=1,Fl=2,Ul=3,kl=4,Gl=5;class xr{constructor(){this.data=0,this.blendMode=pt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Dl)}set blend(t){!!(this.data&1<<Dl)!==t&&(this.data^=1<<Dl)}get offsets(){return!!(this.data&1<<Bl)}set offsets(t){!!(this.data&1<<Bl)!==t&&(this.data^=1<<Bl)}get culling(){return!!(this.data&1<<Fl)}set culling(t){!!(this.data&1<<Fl)!==t&&(this.data^=1<<Fl)}get depthTest(){return!!(this.data&1<<Ul)}set depthTest(t){!!(this.data&1<<Ul)!==t&&(this.data^=1<<Ul)}get depthMask(){return!!(this.data&1<<Gl)}set depthMask(t){!!(this.data&1<<Gl)!==t&&(this.data^=1<<Gl)}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!==pt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new xr;return t.depthTest=!1,t.blend=!0,t}}xr.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Hl=[];function Sf(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=Hl.length-1;i>=0;--i){const s=Hl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class er{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,o,a,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(er.prototype,{dispatch:{value:er.prototype.emit},run:{value:er.prototype.emit}});class tn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new er("setRealSize"),this.onUpdate=new er("update"),this.onError=new er("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 eo extends tn{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ge.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const lE={scaleMode:Ar.NEAREST,alphaMode:Ge.NPM},$l=class bs extends ks{constructor(t=null,e=null){super(),e=Object.assign({},bs.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=e;t&&!(t instanceof tn)&&(t=Sf(t,f),t.internal=!0),this.resolution=p||Q.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=bi(),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=vf(this.realWidth)&&vf(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 qr[this.cacheId],delete vr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),bs.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=Q.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${bi()}`}n=t._pixiId}let o=qr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new bs(t,e),o.cacheId=n,bs.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new eo(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=X.RGBA,a=dt.FLOAT):t instanceof Int32Array?(o=X.RGBA_INTEGER,a=dt.INT):t instanceof Uint32Array?(o=X.RGBA_INTEGER,a=dt.UNSIGNED_INT):t instanceof Int16Array?(o=X.RGBA_INTEGER,a=dt.SHORT):t instanceof Uint16Array?(o=X.RGBA_INTEGER,a=dt.UNSIGNED_SHORT):t instanceof Int8Array?(o=X.RGBA,a=dt.BYTE):(o=X.RGBA,a=dt.UNSIGNED_BYTE),n.internal=!0,new bs(n,Object.assign({},lE,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),qr[e]&&qr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),qr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=qr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete qr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete qr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};$l.defaultOptions={mipmap:dr.POW2,anisotropicLevel:0,scaleMode:Ar.LINEAR,wrapMode:Yr.CLAMP,alphaMode:Ge.UNPACK,target:zi.TEXTURE_2D,format:X.RGBA,type:dt.UNSIGNED_BYTE},$l._globalBatch=0;let yt=$l;class Vl{constructor(){this.texArray=null,this.blend=0,this.type=cr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let hE=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=hE++,this.disposeRunner=new er("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?pr.ELEMENT_ARRAY_BUFFER:pr.ARRAY_BUFFER}get index(){return this.type===pr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Jt(t)}}class ro{constructor(t,e=0,i=!1,s=dt.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new ro(t,e,i,s,n)}}const uE={Float32Array,Uint32Array,Int32Array,Uint8Array};function cE(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=_f(u);s[c]||(s[c]=new uE[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+a,f=d%h;o[p+f]=u[d]}a+=h}return new Float32Array(n)}const Cf={5126:4,5123:2,5121:1};let dE=0;const fE={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Kr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=dE++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new er("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Jt||(e instanceof Array&&(e=new Float32Array(e)),e=new Jt(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new ro(u,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Jt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Jt(t)),t.type=pr.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 s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Cf[n.type]/4),n.buffer=0}for(i.data=cE(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Kr;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 ro(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=pr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Kr,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new fE[_f(o.buffers[a].data)](s[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,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=pr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*Cf[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+h]+=a;a+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class If extends Kr{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,dt.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,dt.FLOAT).addAttribute("aColor",this._buffer,4,!0,dt.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,dt.FLOAT).addIndex(this._indexBuffer)}}const io=Math.PI*2,pE=180/Math.PI,mE=Math.PI/180;var Ee=(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))(Ee||{});class At{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new At(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}}At.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const so=[new At,new At,new At,new At];class _t{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Ee.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 _t(0,0,0,0)}clone(){return new _t(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 R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const M=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>M}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=so[0].set(t.left,t.top),l=so[1].set(t.left,t.bottom),h=so[2].set(t.right,t.top),u=so[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=s||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*i+p*n,m=d*s+p*n,y=d*i+p*o,_=d*s+p*o;if(Math.max(f,m,y,_)<=d*a.x+p*a.y||Math.min(f,m,y,_)>=d*u.x+p*u.y)return!1;const v=c*(a.y-h.y),g=c*(h.x-a.x),x=v*i+g*n,E=v*s+g*n,w=v*i+g*o,A=v*s+g*o;return!(Math.max(x,E,w,A)<=v*a.x+g*a.y||Math.min(x,E,w,A)>=v*u.x+g*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}_t.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class no{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Ee.CIRC}clone(){return new no(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new _t(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}no.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class oo{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Ee.ELIP}clone(){return new oo(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new _t(this.x-this.width,this.y-this.height,this.width,this.height)}}oo.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Ei{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Ee.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Ei(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(i=!i)}return i}}Ei.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class ao{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Ee.RREC}clone(){return new ao(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}ao.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Bt{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new At;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new At;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(io-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new Bt;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 Bt}static get TEMP_MATRIX(){return new Bt}}Bt.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 Ti=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],wi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ai=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Si=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xl=[],Rf=[],lo=Math.sign;function gE(){for(let r=0;r<16;r++){const t=[];Xl.push(t);for(let e=0;e<16;e++){const i=lo(Ti[r]*Ti[e]+Ai[r]*wi[e]),s=lo(wi[r]*Ti[e]+Si[r]*wi[e]),n=lo(Ti[r]*Ai[e]+Ai[r]*Si[e]),o=lo(wi[r]*Ai[e]+Si[r]*Si[e]);for(let a=0;a<16;a++)if(Ti[a]===i&&wi[a]===s&&Ai[a]===n&&Si[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Bt;t.set(Ti[r],wi[r],Ai[r],Si[r],0,0),Rf.push(t)}}gE();const Yt={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=>Ti[r],uY:r=>wi[r],vX:r=>Ai[r],vY:r=>Si[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Xl[r][t],sub:(r,t)=>Xl[r][Yt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Yt.S:Yt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Yt.E:Yt.W:t>0?r>0?Yt.SE:Yt.SW:r>0?Yt.NE:Yt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Rf[Yt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Pr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Pr(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))}}Pr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Yl=class{constructor(){this.worldTransform=new Bt,this.localTransform=new Bt,this.position=new Pr(this.onChange,this,0,0),this.scale=new Pr(this.onChange,this,1,1),this.pivot=new Pr(this.onChange,this,0,0),this.skew=new Pr(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())}};Yl.IDENTITY=new Yl;let Wl=Yl;Wl.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 yE=`varying vec2 vTextureCoord;
11
+ Deprecated since v${r}`),console.warn(i))),_f[t]=!0}function tr(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function tn(r){return r.split("?")[0].split("#")[0]}function aE(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lE(r,t,e){return r.replace(new RegExp(aE(t),"g"),e)}function hE(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const ge={toPosix(r){return lE(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){tr(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(tr(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=tn(this.toPosix(t??tt.ADAPTER.getBaseUrl())),s=tn(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?ge.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(tr(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=hE(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return tr(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(tr(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(tr(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){tr(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){tr(r),t&&tr(t),r=tn(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){tr(r),r=tn(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){tr(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=tn(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,u=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h:u!==1&&(u=1):n!==-1&&(u=-1)}return n===-1||a===-1||u===0||u===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let Rl;async function uE(){return Rl??(Rl=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return He.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 He.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?He.PMA:He.UNPACK})()),Rl}let Ml;function cE(){return typeof Ml>"u"&&(Ml=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 s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),Ml}var dE={grad:.9,turn:360,rad:360/(2*Math.PI)},Or=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ye=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},je=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},vf=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},xf=function(r){return{r:je(r.r,0,255),g:je(r.g,0,255),b:je(r.b,0,255),a:je(r.a)}},Pl=function(r){return{r:ye(r.r),g:ye(r.g),b:ye(r.b),a:ye(r.a,3)}},fE=/^#([0-9a-f]{3,8})$/i,io=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},bf=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},Ef=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},Tf=function(r){return{h:vf(r.h),s:je(r.s,0,100),l:je(r.l,0,100),a:je(r.a)}},wf=function(r){return{h:ye(r.h),s:ye(r.s),l:ye(r.l),a:ye(r.a,3)}},Af=function(r){return Ef((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},en=function(r){return{h:(t=bf(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},pE=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mE=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gE=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yE=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ol={string:[[function(r){var t=fE.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?ye(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?ye(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=gE.exec(r)||yE.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:xf({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=pE.exec(r)||mE.exec(r);if(!t)return null;var e,i,s=Tf({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(dE[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Af(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return Or(t)&&Or(e)&&Or(i)?xf({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!Or(t)||!Or(e)||!Or(i))return null;var o=Tf({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Af(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!Or(t)||!Or(e)||!Or(i))return null;var o=function(a){return{h:vf(a.h),s:je(a.s,0,100),v:je(a.v,0,100),a:je(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Ef(o)},"hsv"]]},Sf=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]},_E=function(r){return typeof r=="string"?Sf(r.trim(),Ol.string):typeof r=="object"&&r!==null?Sf(r,Ol.object):[null,void 0]},Nl=function(r,t){var e=en(r);return{h:e.h,s:je(e.s+100*t,0,100),l:e.l,a:e.a}},Dl=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Cf=function(r,t){var e=en(r);return{h:e.h,s:e.s,l:je(e.l+100*t,0,100),a:e.a}},Ll=function(){function r(t){this.parsed=_E(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 ye(Dl(this.rgba),2)},r.prototype.isDark=function(){return Dl(this.rgba)<.5},r.prototype.isLight=function(){return Dl(this.rgba)>=.5},r.prototype.toHex=function(){return t=Pl(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?io(ye(255*n)):"","#"+io(e)+io(i)+io(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return Pl(this.rgba)},r.prototype.toRgbString=function(){return t=Pl(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return wf(en(this.rgba))},r.prototype.toHslString=function(){return t=wf(en(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=bf(this.rgba),{h:ye(t.h),s:ye(t.s),v:ye(t.v),a:ye(t.a,3)};var t},r.prototype.invert=function(){return vr({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),vr(Nl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),vr(Nl(this.rgba,-t))},r.prototype.grayscale=function(){return vr(Nl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),vr(Cf(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),vr(Cf(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"?vr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ye(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=en(this.rgba);return typeof t=="number"?vr({h:t,s:e.s,l:e.l,a:e.a}):ye(e.h)},r.prototype.isEqual=function(t){return this.toHex()===vr(t).toHex()},r}(),vr=function(r){return r instanceof Ll?r:new Ll(r)},If=[],vE=function(r){r.forEach(function(t){If.indexOf(t)<0&&(t(Ll,Ol),If.push(t))})};function xE(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var u=this.toRgb(),c=1/0,d="black";if(!n.length)for(var p in e)n[p]=new r(e[p]).toRgb();for(var f in e){var m=(a=u,l=n[f],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<c&&(c=m,d=f)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}vE([xE]);const cs=class Zo{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 Zo)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Zo.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,this._components[3]*=n,this.refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this.refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,s=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,s,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Zo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=vr(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,this._components[3]=n,this.refreshInt();else throw new Error(`Unable to convert color ${t}`)}refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};cs.shared=new cs,cs.temp=new cs,cs.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Ot=cs;function bE(r){return wt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),Ot.shared.setValue(r).toHex()}function EE(r){return wt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),Ot.shared.setValue(r).toNumber()}function TE(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[gt.NORMAL_NPM]=gt.NORMAL,r[gt.ADD_NPM]=gt.ADD,r[gt.SCREEN_NPM]=gt.SCREEN,t[gt.NORMAL]=gt.NORMAL_NPM,t[gt.ADD]=gt.ADD_NPM,t[gt.SCREEN]=gt.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Rf=TE();function Mf(r,t){return Rf[t?1:0][r]}function wE(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function Pf(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 so(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 Of(r){return!(r&r-1)&&!!r}function Nf(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 ds(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function Kr(r){return r===0?0:r<0?-1:1}let AE=0;function Ai(){return++AE}const Bl=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}};Bl.EMPTY=new Bl(0,0,0,0);let Df=Bl;const Lf={},xr=Object.create(null),Zr=Object.create(null);class SE{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 Bf(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Ff(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function CE(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&Bf(s,t,o);)++o;if(o===e)return Df.EMPTY;for(;Bf(s,t,l);)--l;for(;Ff(s,t,n,o,l);)++n;for(;Ff(s,t,a,o,l);)--a;return++a,++l,new Df(n,o,a,l)}function IE(r){const t=CE(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function RE(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 Nr(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 Fl=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Uf=(r,t)=>Fl(r).priority??t,ht={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Fl).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(Fl).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>Uf(n,e)-Uf(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class Ul{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 ME=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
12
+ `);function PE(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
13
+ else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function OE(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=ME.replace(/%forloop%/gi,PE(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const kl=0,Gl=1,Hl=2,$l=3,Xl=4,Vl=5;class br{constructor(){this.data=0,this.blendMode=gt.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<kl)}set blend(t){!!(this.data&1<<kl)!==t&&(this.data^=1<<kl)}get offsets(){return!!(this.data&1<<Gl)}set offsets(t){!!(this.data&1<<Gl)!==t&&(this.data^=1<<Gl)}get culling(){return!!(this.data&1<<Hl)}set culling(t){!!(this.data&1<<Hl)!==t&&(this.data^=1<<Hl)}get depthTest(){return!!(this.data&1<<$l)}set depthTest(t){!!(this.data&1<<$l)!==t&&(this.data^=1<<$l)}get depthMask(){return!!(this.data&1<<Vl)}set depthMask(t){!!(this.data&1<<Vl)!==t&&(this.data^=1<<Vl)}get clockwiseFrontFace(){return!!(this.data&1<<Xl)}set clockwiseFrontFace(t){!!(this.data&1<<Xl)!==t&&(this.data^=1<<Xl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==gt.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new br;return t.depthTest=!1,t.blend=!0,t}}br.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const zl=[];function kf(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=zl.length-1;i>=0;--i){const s=zl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class er{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:u}=this;this._aliasCount++;for(let c=0,d=u.length;c<d;c++)u[c][h](t,e,i,s,n,o,a,l);return u===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(er.prototype,{dispatch:{value:er.prototype.emit},run:{value:er.prototype.emit}});class rn{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new er("setRealSize"),this.onUpdate=new er("update"),this.onError=new er("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 no extends rn{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===He.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const NE={scaleMode:Cr.NEAREST,alphaMode:He.NPM},Yl=class Ss extends Hs{constructor(t=null,e=null){super(),e=Object.assign({},Ss.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:u,type:c,target:d,resolution:p,resourceOptions:f}=e;t&&!(t instanceof rn)&&(t=kf(t,f),t.internal=!0),this.resolution=p||tt.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=u,this.type=c,this.target=d,this.alphaMode=i,this.uid=Ai(),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=Of(this.realWidth)&&Of(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 Zr[this.cacheId],delete xr[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ss.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 s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Ai()}`}n=t._pixiId}let o=Zr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Ss(t,e),o.cacheId=n,Ss.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new no(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=z.RGBA,a=ft.FLOAT):t instanceof Int32Array?(o=z.RGBA_INTEGER,a=ft.INT):t instanceof Uint32Array?(o=z.RGBA_INTEGER,a=ft.UNSIGNED_INT):t instanceof Int16Array?(o=z.RGBA_INTEGER,a=ft.SHORT):t instanceof Uint16Array?(o=z.RGBA_INTEGER,a=ft.UNSIGNED_SHORT):t instanceof Int8Array?(o=z.RGBA,a=ft.BYTE):(o=z.RGBA,a=ft.UNSIGNED_BYTE),n.internal=!0,new Ss(n,Object.assign({},NE,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Zr[e]&&Zr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Zr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Zr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Zr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Zr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Yl.defaultOptions={mipmap:fr.POW2,anisotropicLevel:0,scaleMode:Cr.LINEAR,wrapMode:jr.CLAMP,alphaMode:He.UNPACK,target:ts.TEXTURE_2D,format:z.RGBA,type:ft.UNSIGNED_BYTE},Yl._globalBatch=0;let _t=Yl;class jl{constructor(){this.texArray=null,this.blend=0,this.type=dr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let DE=0;class te{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=DE++,this.disposeRunner=new er("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?mr.ELEMENT_ARRAY_BUFFER:mr.ARRAY_BUFFER}get index(){return this.type===mr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new te(t)}}class oo{constructor(t,e=0,i=!1,s=ft.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new oo(t,e,i,s,n)}}const LE={Float32Array,Uint32Array,Int32Array,Uint8Array};function BE(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],u=r[l],c=Pf(u);s[c]||(s[c]=new LE[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+a,f=d%h;o[p+f]=u[d]}a+=h}return new Float32Array(n)}const Gf={5126:4,5123:2,5121:1};let FE=0;const UE={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class Qr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=FE++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new er("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof te||(e instanceof Array&&(e=new Float32Array(e)),e=new te(e));const h=t.split("|");if(h.length>1){for(let c=0;c<h.length;c++)this.addAttribute(h[c],e,i,s,n);return this}let u=this.buffers.indexOf(e);return u===-1&&(this.buffers.push(e),u=this.buffers.length-1),this.attributes[t]=new oo(u,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof te||(t instanceof Array&&(t=new Uint16Array(t)),t=new te(t)),t.type=mr.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 te;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*Gf[n.type]/4),n.buffer=0}for(i.data=BE(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new Qr;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new te(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new oo(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=mr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new Qr,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new UE[Pf(o.buffers[a].data)](s[a]),e.buffers[a]=new te(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=mr.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,u=0;for(let c=0;c<o.buffers.length;c++)if(o.buffers[c]!==o.indexBuffer){u=c;break}for(const c in o.attributes){const d=o.attributes[c];(d.buffer|0)===u&&(l+=d.size*Gf[d.type]/4)}for(let c=0;c<t.length;c++){const d=t[c].indexBuffer.data;for(let p=0;p<d.length;p++)e.indexBuffer.data[p+h]+=a;a+=t[c].buffers[u].data.length/l,h+=d.length}}return e}}class Hf extends Qr{constructor(t=!1){super(),this._buffer=new te(null,t,!1),this._indexBuffer=new te(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,ft.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,ft.FLOAT).addAttribute("aColor",this._buffer,4,!0,ft.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,ft.FLOAT).addIndex(this._indexBuffer)}}const ao=Math.PI*2,kE=180/Math.PI,GE=Math.PI/180;var Te=(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))(Te||{});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 lo=[new It,new It,new It,new It];class xt{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Te.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 xt(0,0,0,0)}clone(){return new xt(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 R=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=R)return!1;const P=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>P}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=lo[0].set(t.left,t.top),l=lo[1].set(t.left,t.bottom),h=lo[2].set(t.right,t.top),u=lo[3].set(t.right,t.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(c===0||(e.apply(a,a),e.apply(l,l),e.apply(h,h),e.apply(u,u),Math.max(a.x,l.x,h.x,u.x)<=i||Math.min(a.x,l.x,h.x,u.x)>=s||Math.max(a.y,l.y,h.y,u.y)<=n||Math.min(a.y,l.y,h.y,u.y)>=o))return!1;const d=c*(l.y-a.y),p=c*(a.x-l.x),f=d*i+p*n,m=d*s+p*n,_=d*i+p*o,y=d*s+p*o;if(Math.max(f,m,_,y)<=d*a.x+p*a.y||Math.min(f,m,_,y)>=d*u.x+p*u.y)return!1;const v=c*(a.y-h.y),g=c*(h.x-a.x),x=v*i+g*n,E=v*s+g*n,M=v*i+g*o,S=v*s+g*o;return!(Math.max(x,E,M,S)<=v*a.x+g*a.y||Math.min(x,E,M,S)>=v*u.x+g*u.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=n-s,this}}xt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class ho{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Te.CIRC}clone(){return new ho(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new xt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}ho.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class uo{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Te.ELIP}clone(){return new uo(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new xt(this.x-this.width,this.y-this.height,this.width,this.height)}}uo.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Si{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Te.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Si(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],u=this.points[o*2+1];l>e!=u>e&&t<(h-a)*((e-l)/(u-l))+a&&(i=!i)}return i}}Si.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class co{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Te.RREC}clone(){return new co(this.x,this.y,this.width,this.height,this.radius)}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}co.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,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new It;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new It;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(ao-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new 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 Ci=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ii=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Ri=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Mi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Wl=[],$f=[],fo=Math.sign;function HE(){for(let r=0;r<16;r++){const t=[];Wl.push(t);for(let e=0;e<16;e++){const i=fo(Ci[r]*Ci[e]+Ri[r]*Ii[e]),s=fo(Ii[r]*Ci[e]+Mi[r]*Ii[e]),n=fo(Ci[r]*Ri[e]+Ri[r]*Mi[e]),o=fo(Ii[r]*Ri[e]+Mi[r]*Mi[e]);for(let a=0;a<16;a++)if(Ci[a]===i&&Ii[a]===s&&Ri[a]===n&&Mi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new kt;t.set(Ci[r],Ii[r],Ri[r],Mi[r],0,0),$f.push(t)}}HE();const Yt={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=>Ci[r],uY:r=>Ii[r],vX:r=>Ri[r],vY:r=>Mi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Wl[r][t],sub:(r,t)=>Wl[r][Yt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Yt.S:Yt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Yt.E:Yt.W:t>0?r>0?Yt.SE:Yt.SW:r>0?Yt.NE:Yt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=$f[Yt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Dr{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new Dr(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))}}Dr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const ql=class{constructor(){this.worldTransform=new kt,this.localTransform=new kt,this.position=new Dr(this.onChange,this,0,0),this.scale=new Dr(this.onChange,this,1,1),this.pivot=new Dr(this.onChange,this,0,0),this.skew=new Dr(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())}};ql.IDENTITY=new ql;let Kl=ql;Kl.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 $E=`varying vec2 vTextureCoord;
14
14
 
15
15
  uniform sampler2D uSampler;
16
16
 
17
17
  void main(void){
18
18
  gl_FragColor *= texture2D(uSampler, vTextureCoord);
19
- }`,_E=`attribute vec2 aVertexPosition;
19
+ }`,XE=`attribute vec2 aVertexPosition;
20
20
  attribute vec2 aTextureCoord;
21
21
 
22
22
  uniform mat3 projectionMatrix;
@@ -27,7 +27,7 @@ void main(void){
27
27
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
28
28
  vTextureCoord = aTextureCoord;
29
29
  }
30
- `;function Mf(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 Of(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 as=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
30
+ `;function Xf(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 Vf(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 fs=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
31
31
  if(uv["${r}"] !== ud["${r}"].value)
32
32
  {
33
33
  ud["${r}"].value = uv["${r}"]
@@ -147,7 +147,7 @@ void main(void){
147
147
  cv[3] = v[3];
148
148
 
149
149
  gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
150
- }`}],vE={float:`
150
+ }`}],VE={float:`
151
151
  if (cv !== v)
152
152
  {
153
153
  cu.value = v;
@@ -283,7 +283,7 @@ void main(void){
283
283
  cu.value = v;
284
284
 
285
285
  gl.uniform1i(location, v);
286
- }`},xE={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 bE(r,t){var i;const e=[`
286
+ }`},zE={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 YE(r,t){var i;const e=[`
287
287
  var v = null;
288
288
  var cv = null;
289
289
  var cu = null;
@@ -293,18 +293,18 @@ void main(void){
293
293
  renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
294
294
  `):e.push(`
295
295
  renderer.shader.syncUniformGroup(uv.${s}, syncData);
296
- `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<as.length;l++)if(as[l].test(n,o)){e.push(as[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?vE:xE)[n.type].replace("location",`ud["${s}"].location`);e.push(`
296
+ `));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<fs.length;l++)if(fs[l].test(n,o)){e.push(fs[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?VE:zE)[n.type].replace("location",`ud["${s}"].location`);e.push(`
297
297
  cu = ud["${s}"];
298
298
  cv = cu.value;
299
299
  v = uv["${s}"];
300
300
  ${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
301
- `))}const Pf={};let ls=Pf;function EE(){if(ls===Pf||ls!=null&&ls.isContextLost()){const r=Q.ADAPTER.createCanvas();let t;Q.PREFER_ENV>=mi.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),ls=t}return ls}let ho;function TE(){if(!ho){ho=Ye.MEDIUM;const r=EE();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(ho=t.precision?Ye.HIGH:Ye.MEDIUM)}}return ho}function Nf(r,t){const e=r.getShaderSource(t).split(`
301
+ `))}const zf={};let ps=zf;function jE(){if(ps===zf||ps!=null&&ps.isContextLost()){const r=tt.ADAPTER.createCanvas();let t;tt.PREFER_ENV>=vi.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),ps=t}return ps}let po;function WE(){if(!po){po=Ye.MEDIUM;const r=jE();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(po=t.precision?Ye.HIGH:Ye.MEDIUM)}}return po}function Yf(r,t){const e=r.getShaderSource(t).split(`
302
302
  `).map((h,u)=>`${u}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(`
303
303
  `),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
304
- `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function wE(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Nf(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Nf(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const AE={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 Lf(r){return AE[r]}let uo=null;const Df={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 Bf(r,t){if(!uo){const e=Object.keys(Df);uo={};for(let i=0;i<e.length;++i){const s=e[i];uo[r[s]]=Df[s]}}return uo[t]}function Ff(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===Ye.HIGH&&e!==Ye.HIGH&&(i=Ye.MEDIUM),`precision ${i} float;
305
- ${r}`}else if(e!==Ye.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let en;function SE(){if(typeof en=="boolean")return en;try{en=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{en=!1}return en}let CE=0;const co={},zl=class Es{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=CE++,this.vertexSrc=t||Es.defaultVertexSrc,this.fragmentSrc=e||Es.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),co[i]?(co[i]++,i+=`-${co[i]}`):co[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
304
+ `);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function qE(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Yf(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Yf(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const KE={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 jf(r){return KE[r]}let mo=null;const Wf={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 qf(r,t){if(!mo){const e=Object.keys(Wf);mo={};for(let i=0;i<e.length;++i){const s=e[i];mo[r[s]]=Wf[s]}}return mo[t]}function Kf(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===Ye.HIGH&&e!==Ye.HIGH&&(i=Ye.MEDIUM),`precision ${i} float;
305
+ ${r}`}else if(e!==Ye.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let sn;function ZE(){if(typeof sn=="boolean")return sn;try{sn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{sn=!1}return sn}let QE=0;const go={},Ql=class Cs{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=QE++,this.vertexSrc=t||Cs.defaultVertexSrc,this.fragmentSrc=e||Cs.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),go[i]?(go[i]++,i+=`-${go[i]}`):go[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
306
306
  ${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
307
- ${this.fragmentSrc}`,this.vertexSrc=Ff(this.vertexSrc,Es.defaultVertexPrecision,Ye.HIGH),this.fragmentSrc=Ff(this.fragmentSrc,Es.defaultFragmentPrecision,TE())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return _E}static get defaultFragmentSrc(){return yE}static from(t,e,i){const s=t+e;let n=Ef[s];return n||(Ef[s]=n=new Es(t,e,i)),n}};zl.defaultVertexPrecision=Ye.HIGH,zl.defaultFragmentPrecision=Cr.apple.device?Ye.HIGH:Ye.MEDIUM;let Nr=zl,IE=0;class rr{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=IE++,this.static=!!e,this.ubo=!!i,t instanceof Jt?(this.buffer=t,this.buffer.type=pr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Jt(new Float32Array(1)),this.buffer.type=pr.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 rr(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 rr(t,e,i)}static uboFrom(t,e){return new rr(t,e??!0,!0)}}class br{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof rr?this.uniformGroup=e:this.uniformGroup=new rr(e):this.uniformGroup=new rr({}),this.disposeRunner=new er("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=Nr.from(t,e);return new br(s,i)}}class RE{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=rr.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Nr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Bt,default:this.defaultGroupCache[t]};return new br(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
307
+ ${this.fragmentSrc}`,this.vertexSrc=Kf(this.vertexSrc,Cs.defaultVertexPrecision,Ye.HIGH),this.fragmentSrc=Kf(this.fragmentSrc,Cs.defaultFragmentPrecision,WE())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return XE}static get defaultFragmentSrc(){return $E}static from(t,e,i){const s=t+e;let n=Lf[s];return n||(Lf[s]=n=new Cs(t,e,i)),n}};Ql.defaultVertexPrecision=Ye.HIGH,Ql.defaultFragmentPrecision=Rr.apple.device?Ye.HIGH:Ye.MEDIUM;let Lr=Ql,JE=0;class rr{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=JE++,this.static=!!e,this.ubo=!!i,t instanceof te?(this.buffer=t,this.buffer.type=mr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new te(new Float32Array(1)),this.buffer.type=mr.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 rr(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 rr(t,e,i)}static uboFrom(t,e){return new rr(t,e??!0,!0)}}class Er{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof rr?this.uniformGroup=e:this.uniformGroup=new rr(e):this.uniformGroup=new rr({}),this.disposeRunner=new er("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=Lr.from(t,e);return new Er(s,i)}}class tT{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=rr.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new Lr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:this.defaultGroupCache[t]};return new Er(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
308
308
  `,e+=`
309
309
  `;for(let i=0;i<t;i++)i>0&&(e+=`
310
310
  else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
@@ -312,7 +312,7 @@ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
312
312
  color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
313
313
  }`;return e+=`
314
314
  `,e+=`
315
- `,e}}class ql{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 ME(){return!Cr.apple.device}function OE(r){let t=!0;const e=Q.ADAPTER.getNavigator();if(Cr.tablet||Cr.phone){if(Cr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Cr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class fo{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var PE=`varying vec2 vTextureCoord;
315
+ `,e}}class Jl{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 eT(){return!Rr.apple.device}function rT(r){let t=!0;const e=tt.ADAPTER.getNavigator();if(Rr.tablet||Rr.phone){if(Rr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(Rr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class yo{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var iT=`varying vec2 vTextureCoord;
316
316
  varying vec4 vColor;
317
317
  varying float vTextureId;
318
318
  uniform sampler2D uSamplers[%count%];
@@ -322,7 +322,7 @@ void main(void){
322
322
  %forloop%
323
323
  gl_FragColor = color * vColor;
324
324
  }
325
- `,NE=`precision highp float;
325
+ `,sT=`precision highp float;
326
326
  attribute vec2 aVertexPosition;
327
327
  attribute vec2 aTextureCoord;
328
328
  attribute vec4 aColor;
@@ -343,14 +343,14 @@ void main(void){
343
343
  vTextureId = aTextureId;
344
344
  vColor = aColor * tint;
345
345
  }
346
- `;const rn=class ur extends fo{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=If,this.vertexSize=6,this.state=xr.for2d(),this.size=ur.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??OE(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??ME(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return bt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return NE}static get defaultFragmentTemplate(){return PE}setShaderGenerator({vertex:t=ur.defaultVertexSrc,fragment:e=ur.defaultFragmentTemplate}={}){this.shaderGenerator=new RE(t,e)}contextChange(){const t=this.renderer.gl;Q.PREFER_ENV===mi.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ur.defaultMaxTextures),this.maxTextures=aE(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}=ur,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Vl);for(;e.length<s;)e.push(new ql);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=ur._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++yt._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<n.length;c++)n[c]=null;yt._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=ur._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const f=s[p],m=f._texture.baseTexture,y=gf[m.alphaMode?1:0][f.blendMode];s[p]=null,e<p&&d.blend!==y&&(d.size=c-d.start,e=p,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(f,n,o,u,c),u+=f.vertexData.length/2*a,c+=f.indices.length,d.blend=y}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;ur.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=ur._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),ur.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=to(Math.ceil(t/8)),i=xf(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Ll(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=to(Math.ceil(t/12)),i=xf(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),f=Mt.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let m=0;m<c.length;m+=2)a[s++]=c[m],a[s++]=c[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=f,a[s++]=d;for(let m=0;m<u.length;m++)i[n++]=l+u[m]}};rn.defaultBatchSize=4096,rn.extension={name:"batch",type:j.RendererPlugin},rn._drawCallPool=[],rn._textureArrayPool=[];let Ci=rn;st.add(Ci);var LE=`varying vec2 vTextureCoord;
346
+ `;const nn=class ur extends yo{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Hf,this.vertexSize=6,this.state=br.for2d(),this.size=ur.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??rT(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??eT(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return wt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return sT}static get defaultFragmentTemplate(){return iT}setShaderGenerator({vertex:t=ur.defaultVertexSrc,fragment:e=ur.defaultFragmentTemplate}={}){this.shaderGenerator=new tT(t,e)}contextChange(){const t=this.renderer.gl;tt.PREFER_ENV===vi.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),ur.defaultMaxTextures),this.maxTextures=OE(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}=ur,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new jl);for(;e.length<s;)e.push(new Jl);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=ur._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++_t._globalBatch,l=0,h=i[0],u=0;s.copyBoundTextures(n,e);for(let c=0;c<this._bufferSize;++c){const d=t[c];t[c]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,c),u=c,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,u,this._bufferSize),++l,++a);for(let c=0;c<n.length;c++)n[c]=null;_t._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=ur._drawCallPool;let h=this._dcIndex,u=this._aIndex,c=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let p=e;p<i;++p){const f=s[p],m=f._texture.baseTexture,_=Rf[m.alphaMode?1:0][f.blendMode];s[p]=null,e<p&&d.blend!==_&&(d.size=c-d.start,e=p,d=l[++h],d.texArray=t,d.start=c),this.packInterleavedGeometry(f,n,o,u,c),u+=f.vertexData.length/2*a,c+=f.indices.length,d.blend=_}e<i&&(d.size=c-d.start,++h),this._dcIndex=h,this._aIndex=u,this._iIndex=c}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;ur.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=ur._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:u,blend:c}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=c,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,u*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),ur.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=so(Math.ceil(t/8)),i=Nf(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new Ul(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=so(Math.ceil(t/12)),i=Nf(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,u=t.indices,c=t.vertexData,d=t._texture.baseTexture._batchLocation,p=Math.min(t.worldAlpha,1),f=Ot.shared.setValue(t._tintRGB).toPremultiplied(p,t._texture.baseTexture.alphaMode>0);for(let m=0;m<c.length;m+=2)a[s++]=c[m],a[s++]=c[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=f,a[s++]=d;for(let m=0;m<u.length;m++)i[n++]=l+u[m]}};nn.defaultBatchSize=4096,nn.extension={name:"batch",type:Z.RendererPlugin},nn._drawCallPool=[],nn._textureArrayPool=[];let Pi=nn;ht.add(Pi);var nT=`varying vec2 vTextureCoord;
347
347
 
348
348
  uniform sampler2D uSampler;
349
349
 
350
350
  void main(void){
351
351
  gl_FragColor = texture2D(uSampler, vTextureCoord);
352
352
  }
353
- `,DE=`attribute vec2 aVertexPosition;
353
+ `,oT=`attribute vec2 aVertexPosition;
354
354
 
355
355
  uniform mat3 projectionMatrix;
356
356
 
@@ -376,7 +376,7 @@ void main(void)
376
376
  gl_Position = filterVertexPosition();
377
377
  vTextureCoord = filterTextureCoord();
378
378
  }
379
- `;const Kl=class fn extends br{constructor(t,e,i){const s=Nr.from(t||fn.defaultVertexSrc,e||fn.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=fn.defaultResolution,this.multisample=fn.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new xr}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return DE}static get defaultFragmentSrc(){return LE}};Kl.defaultResolution=1,Kl.defaultMultisample=ne.NONE;let Pe=Kl;class po{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Mt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}po.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},po.extension={type:[j.RendererSystem,j.CanvasRendererSystem],name:"background"},st.add(po);class Uf{constructor(t){this.renderer=t,this.emptyRenderer=new fo(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Uf.extension={type:j.RendererSystem,name:"batch"},st.add(Uf);let kf=0;class mo{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=kf++}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=kf++,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(Q.PREFER_ENV>=mi.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}mo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},mo.extension={type:j.RendererSystem,name:"context"},st.add(mo);class Zl{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 er("disposeFramebuffer"),this.multisample=ne.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new yt(null,{scaleMode:Ar.NEAREST,resolution:1,mipmap:dr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new yt(null,{scaleMode:Ar.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:dr.OFF,format:X.DEPTH_COMPONENT,type:dt.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Gf extends yt{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=ne.NONE),super(null,t),this.mipmap=dr.OFF,this.valid=!0,this._clear=new Mt([0,0,0,0]),this.framebuffer=new Zl(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 Lr extends tn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=sE(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ge.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Hf extends Lr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Lr.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??Q.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ge.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ql{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Yt.add(i,Yt.NW),this.x0=l+o*Yt.uX(i),this.y0=h+a*Yt.uY(i),i=Yt.add(i,2),this.x1=l+o*Yt.uX(i),this.y1=h+a*Yt.uY(i),i=Yt.add(i,2),this.x2=l+o*Yt.uX(i),this.y2=h+a*Yt.uY(i),i=Yt.add(i,2),this.x3=l+o*Yt.uX(i),this.y3=h+a*Yt.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ql.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 $f=new Ql;function go(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class nt extends ks{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new _t(0,0,1,1)),t instanceof nt&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=$f,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new At(o.x,o.y):new At(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&&vr[e.url]&&nt.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,nt.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new nt(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===$f&&(this._uvs=new Ql),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=Q.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof yt){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${bi()}`,yt.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${bi()}`}n=t._pixiId}let o=vr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof yt)?(e.resolution||(e.resolution=Or(t)),o=new nt(new yt(t,e)),o.baseTexture.cacheId=n,yt.addToCache(o.baseTexture,n),nt.addToCache(o,n)):!o&&t instanceof yt&&(o=new nt(t),nt.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=nt.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new nt(yt.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new yt(t,Object.assign({scaleMode:yt.defaultOptions.scaleMode,resolution:Or(e)},s)),{resource:o}=n;o instanceof Hf&&(o.url=e);const a=new nt(n);return i||(i=e),yt.addToCache(a.baseTexture,i),nt.addToCache(a,i),i!==e&&(yt.addToCache(a.baseTexture,e),nt.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),vr[e]&&vr[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),vr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=vr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete vr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)vr[t.textureCacheIds[e]]===t&&delete vr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return nt._EMPTY||(nt._EMPTY=new nt(new yt),go(nt._EMPTY),go(nt._EMPTY.baseTexture)),nt._EMPTY}static get WHITE(){if(!nt._WHITE){const t=Q.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),nt._WHITE=new nt(yt.from(t)),go(nt._WHITE),go(nt._WHITE.baseTexture)}return nt._WHITE}}class Ii extends nt{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Ii(new Gf(t))}}class Vf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=ne.NONE){const s=new Gf(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Ii(s)}getOptimalTexture(t,e,i=1,s=ne.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=to(t),e=to(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||ne.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Vf.SCREEN_KEY=-1;class BE extends Kr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Xf extends Kr{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,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class FE{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=ne.NONE,this.sourceFrame=new _t,this.destinationFrame=new _t,this.bindingSourceFrame=new _t,this.bindingDestinationFrame=new _t,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const yo=[new At,new At,new At,new At],Jl=new Bt;class Yf{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Vf,this.statePool=[],this.quad=new BE,this.quadUv=new Xf,this.tempRect=new _t,this.activeState={},this.globalUniforms=new rr({outputFrame:new _t,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new FE,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,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let y=1;y<e.length;y++){const _=e[y];h=Math.min(h,_.resolution||a),u=Math.min(u,_.multisample??l),c=this.useMaxPadding?Math.max(c,_.padding):c+_.padding,d=d&&_.autoFit,p=p||(_.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const f=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(Jl.copyFrom(i.projection.transform).invert(),f),d?(n.sourceFrame.fit(f),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(f)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,fr.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,fr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,fr.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=fr.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===fr.CLEAR||e===fr.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(cr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(cr.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(Bt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=ne.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||ne.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=yo[0],s=yo[1],n=yo[2],o=yo[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=u-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?Jl.copyFrom(n):Jl.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Yf.extension={type:j.RendererSystem,name:"filter"},st.add(Yf);class UE{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ne.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const kE=new _t;class Wf{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Zl(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 _t,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;Q.PREFER_ENV===mi.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=Da.COLOR|Da.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new UE(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=ne.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=ne.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new Zl(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=kE,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new _t}destroy(){this.renderer=null}}Wf.extension={type:j.RendererSystem,name:"framebuffer"},st.add(Wf);const th={5126:4,5123:2,5121:1};class jf{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;Q.PREFER_ENV===mi.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=t.buffers,d=t.attributes,p={},f={};for(const m in c)p[m]=0,f[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[m].buffer]+=d[m].size*th[d[m].type];for(const m in d){const y=d[m],_=y.size;y.stride===void 0&&(p[y.buffer]===_*th[y.type]?y.stride=0:y.stride=p[y.buffer]),y.start===void 0&&(y.start=f[y.buffer],f[y.buffer]+=_*th[y.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let m=0;m<c.length;m++){const y=c[m];o.bind(y),i&&y._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=u,h[l]=u,s.bindVertexArray(null),o.unbind(pr.ARRAY_BUFFER),u}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const p=e.attributeData[h].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}jf.extension={type:j.RendererSystem,name:"geometry"},st.add(jf);const zf=new Bt;class qf{constructor(t,e){this._texture=t,this.mapCoord=new Bt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(zf.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(zf));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 GE=`varying vec2 vMaskCoord;
379
+ `;const th=class gn extends Er{constructor(t,e,i){const s=Lr.from(t||gn.defaultVertexSrc,e||gn.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=gn.defaultResolution,this.multisample=gn.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new br}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return oT}static get defaultFragmentSrc(){return nT}};th.defaultResolution=1,th.defaultMultisample=ne.NONE;let Be=th;class _o{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new Ot(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}_o.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},_o.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"background"},ht.add(_o);class Zf{constructor(t){this.renderer=t,this.emptyRenderer=new yo(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const u=n[h],c=u._batchLocation;if(c>=0&&c<s&&e[c]===u){o[h]=c;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,u._batchLocation=l,e[l]=u;break}}}destroy(){this.renderer=null}}Zf.extension={type:Z.RendererSystem,name:"batch"},ht.add(Zf);let Qf=0;class vo{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=Qf++}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=Qf++,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>=vi.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}vo.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},vo.extension={type:Z.RendererSystem,name:"context"},ht.add(vo);class eh{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 er("disposeFramebuffer"),this.multisample=ne.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new _t(null,{scaleMode:Cr.NEAREST,resolution:1,mipmap:fr.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new _t(null,{scaleMode:Cr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:fr.OFF,format:z.DEPTH_COMPONENT,type:ft.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Jf extends _t{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=ne.NONE),super(null,t),this.mipmap=fr.OFF,this.valid=!0,this._clear=new Ot([0,0,0,0]),this.framebuffer=new eh(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class Br extends rn{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=RE(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===He.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class tp extends Br{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Br.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??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 s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===He.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class rh{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Yt.add(i,Yt.NW),this.x0=l+o*Yt.uX(i),this.y0=h+a*Yt.uY(i),i=Yt.add(i,2),this.x1=l+o*Yt.uX(i),this.y1=h+a*Yt.uY(i),i=Yt.add(i,2),this.x2=l+o*Yt.uX(i),this.y2=h+a*Yt.uY(i),i=Yt.add(i,2),this.x3=l+o*Yt.uX(i),this.y3=h+a*Yt.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}rh.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 ep=new rh;function xo(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class ut extends Hs{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new xt(0,0,1,1)),t instanceof ut&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=ep,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new 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&&xr[e.url]&&ut.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,ut.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new ut(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===ep&&(this._uvs=new rh),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=tt.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof _t){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Ai()}`,_t.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Ai()}`}n=t._pixiId}let o=xr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof _t)?(e.resolution||(e.resolution=Nr(t)),o=new ut(new _t(t,e)),o.baseTexture.cacheId=n,_t.addToCache(o.baseTexture,n),ut.addToCache(o,n)):!o&&t instanceof _t&&(o=new ut(t),ut.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=ut.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new ut(_t.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new _t(t,Object.assign({scaleMode:_t.defaultOptions.scaleMode,resolution:Nr(e)},s)),{resource:o}=n;o instanceof tp&&(o.url=e);const a=new ut(n);return i||(i=e),_t.addToCache(a.baseTexture,i),ut.addToCache(a,i),i!==e&&(_t.addToCache(a.baseTexture,e),ut.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),xr[e]&&xr[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),xr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=xr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete xr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)xr[t.textureCacheIds[e]]===t&&delete xr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,u=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${u}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return ut._EMPTY||(ut._EMPTY=new ut(new _t),xo(ut._EMPTY),xo(ut._EMPTY.baseTexture)),ut._EMPTY}static get WHITE(){if(!ut._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),ut._WHITE=new ut(_t.from(t)),xo(ut._WHITE),xo(ut._WHITE.baseTexture)}return ut._WHITE}}class Oi extends ut{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Oi(new Jf(t))}}class rp{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=ne.NONE){const s=new Jf(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Oi(s)}getOptimalTexture(t,e,i=1,s=ne.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=so(t),e=so(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||ne.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}rp.SCREEN_KEY=-1;class aT extends Qr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class ip extends Qr{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 te(this.vertices),this.uvBuffer=new te(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class lT{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=ne.NONE,this.sourceFrame=new xt,this.destinationFrame=new xt,this.bindingSourceFrame=new xt,this.bindingDestinationFrame=new xt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const bo=[new It,new It,new It,new It],ih=new kt;class sp{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new rp,this.statePool=[],this.quad=new aT,this.quadUv=new ip,this.tempRect=new xt,this.activeState={},this.globalUniforms=new rr({outputFrame:new xt,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new lT,o=i.renderTexture;let a,l;if(o.current){const _=o.current;a=_.resolution,l=_.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,u=e[0].multisample??l,c=e[0].padding,d=e[0].autoFit,p=e[0].legacy??!0;for(let _=1;_<e.length;_++){const y=e[_];h=Math.min(h,y.resolution||a),u=Math.min(u,y.multisample??l),c=this.useMaxPadding?Math.max(c,y.padding):c+y.padding,d=d&&y.autoFit,p=p||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=u,n.legacy=p,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(c);const f=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(ih.copyFrom(i.projection.transform).invert(),f),d?(n.sourceFrame.fit(f),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(f)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,u),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,pr.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,u=this.getOptimalFilterTexture(h.width,h.height,e.resolution);u.filterFrame=h.filterFrame;let c=0;for(c=0;c<i.length-1;++c){c===1&&e.multisample>1&&(u=this.getOptimalFilterTexture(h.width,h.height,e.resolution),u.filterFrame=h.filterFrame),i[c].apply(this,h,u,pr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,pr.BLEND,e),c>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(u)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=pr.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===pr.CLEAR||e===pr.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(dr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(dr.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(kt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=ne.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||ne.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=bo[0],s=bo[1],n=bo[2],o=bo[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),u=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=u-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?ih.copyFrom(n):ih.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}sp.extension={type:Z.RendererSystem,name:"filter"},ht.add(sp);class hT{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=ne.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const uT=new xt;class np{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new eh(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 xt,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===vi.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=Xa.COLOR|Xa.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new hT(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=ne.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=ne.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const u=s.colorTextures[0];if(!u)return;l.blitFramebuffer||(l.blitFramebuffer=new eh(s.width,s.height),l.blitFramebuffer.addColorTexture(0,u)),t=l.blitFramebuffer,t.colorTextures[0]!==u&&(t.colorTextures[0]=u,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=uT,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new xt}destroy(){this.renderer=null}}np.extension={type:Z.RendererSystem,name:"framebuffer"},ht.add(np);const sh={5126:4,5123:2,5121:1};class op{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===vi.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let u=h[l];if(u)return h[a.id]=u,u;const c=t.buffers,d=t.attributes,p={},f={};for(const m in c)p[m]=0,f[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),p[d[m].buffer]+=d[m].size*sh[d[m].type];for(const m in d){const _=d[m],y=_.size;_.stride===void 0&&(p[_.buffer]===y*sh[_.type]?_.stride=0:_.stride=p[_.buffer]),_.start===void 0&&(_.start=f[_.buffer],f[_.buffer]+=y*sh[_.type])}u=s.createVertexArray(),s.bindVertexArray(u);for(let m=0;m<c.length;m++){const _=c[m];o.bind(_),i&&_._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=u,h[l]=u,s.bindVertexArray(null),o.unbind(mr.ARRAY_BUFFER),u}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const u=a[h],c=o[u.buffer],d=c._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(c),l=d);const p=e.attributeData[h].location;if(i.enableVertexAttribArray(p),i.vertexAttribPointer(p,u.size,u.type||i.FLOAT,u.normalized,u.stride,u.start),u.instance)if(this.hasInstance)i.vertexAttribDivisor(p,u.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}op.extension={type:Z.RendererSystem,name:"geometry"},ht.add(op);const ap=new kt;class lp{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 s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(ap.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(ap));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 cT=`varying vec2 vMaskCoord;
380
380
  varying vec2 vTextureCoord;
381
381
 
382
382
  uniform sampler2D uSampler;
@@ -401,7 +401,7 @@ void main(void)
401
401
 
402
402
  gl_FragColor = original;
403
403
  }
404
- `,HE=`attribute vec2 aVertexPosition;
404
+ `,dT=`attribute vec2 aVertexPosition;
405
405
  attribute vec2 aTextureCoord;
406
406
 
407
407
  uniform mat3 projectionMatrix;
@@ -417,7 +417,7 @@ void main(void)
417
417
  vTextureCoord = aTextureCoord;
418
418
  vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
419
419
  }
420
- `;class $E extends Pe{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||HE,e||GE,i),this.maskSprite=s,this.maskMatrix=new Bt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new qf(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class VE{constructor(t=null){this.type=he.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Pe.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=he.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 Kf{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new VE;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==he.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case he.SCISSOR:this.renderer.scissor.push(i);break;case he.STENCIL:this.renderer.stencil.push(i);break;case he.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case he.COLOR:this.pushColorMask(i);break}i.type===he.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case he.SCISSOR:this.renderer.scissor.pop(e);break;case he.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case he.SPRITE:this.popSpriteMask(e);break;case he.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===he.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=he.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=he.SCISSOR:t.type=he.STENCIL:t.type=he.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new $E])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Kf.extension={type:j.RendererSystem,name:"mask"},st.add(Kf);class Zf{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Qf=new Bt,Jf=[],tp=class zo extends Zf{constructor(t){super(t),this.glConst=Q.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,Jf.pop()??new _t);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||zo.isMatrixRotated(e.worldTransform)||zo.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){zo.isMatrixRotated(n)||(n=n?Qf.copyFrom(n):Qf.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Jf.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)}};tp.extension={type:j.RendererSystem,name:"scissor"};let XE=tp;st.add(XE);class ep extends Zf{constructor(t){super(t),this.glConst=Q.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}ep.extension={type:j.RendererSystem,name:"stencil"},st.add(ep);class rp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return bt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return bt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return bt("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}}rp.extension={type:[j.RendererSystem,j.CanvasRendererSystem],name:"_plugin"},st.add(rp);class ip{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Bt,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}ip.extension={type:j.RendererSystem,name:"projection"},st.add(ip);const YE=new Wl,sp=new _t;class np{constructor(t){this.renderer=t,this._tempMatrix=new Bt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(sp))||t.getLocalBounds(sp,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Ii.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=YE,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}np.extension={type:[j.RendererSystem,j.CanvasRendererSystem],name:"textureGenerator"},st.add(np);const Ri=new _t,sn=new _t;class op{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new _t,this.destinationFrame=new _t,this.viewportFrame=new _t}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(Ri.width=t.frame.width,Ri.height=t.frame.height,e=Ri),i||(sn.x=t.frame.x,sn.y=t.frame.y,sn.width=e.width,sn.height=e.height,i=sn),o=n.framebuffer):(a=s.resolution,e||(Ri.width=s._view.screen.width,Ri.height=s._view.screen.height,e=Ri),i||(i=Ri,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=Mt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}op.extension={type:j.RendererSystem,name:"renderTexture"},st.add(op);class WE{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 jE(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=Bf(t,n.type),a={type:o,name:n.name,size:Lf(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function zE(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Bf(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Of(l,n.size)}}return e}function qE(r,t){var a;const e=Mf(r,r.VERTEX_SHADER,t.vertexSrc),i=Mf(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||wE(r,s,e,i),t.attributeData=jE(s,r),t.uniformData=zE(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:Of(h.type,h.size)}}return new WE(s,o)}function KE(r,t,e,i,s){e.buffer.update(s)}const ZE={float:`
420
+ `;class fT extends Be{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||dT,e||cT,i),this.maskSprite=s,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,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new lp(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class pT{constructor(t=null){this.type=he.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=Be.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=he.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 hp{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new pT;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==he.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case he.SCISSOR:this.renderer.scissor.push(i);break;case he.STENCIL:this.renderer.stencil.push(i);break;case he.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case he.COLOR:this.pushColorMask(i);break}i.type===he.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case he.SCISSOR:this.renderer.scissor.pop(e);break;case he.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case he.SPRITE:this.popSpriteMask(e);break;case he.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===he.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=he.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=he.SCISSOR:t.type=he.STENCIL:t.type=he.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new fT])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}hp.extension={type:Z.RendererSystem,name:"mask"},ht.add(hp);class up{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const cp=new kt,dp=[],fp=class Qo extends up{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:s}=this,n=s.renderTexture,o=i.getBounds(!0,dp.pop()??new xt);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Qo.isMatrixRotated(e.worldTransform)||Qo.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Qo.isMatrixRotated(n)||(n=n?cp.copyFrom(n):cp.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&dp.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)}};fp.extension={type:Z.RendererSystem,name:"scissor"};let mT=fp;ht.add(mT);class pp extends up{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,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}pp.extension={type:Z.RendererSystem,name:"stencil"},ht.add(pp);class mp{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return wt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return wt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return wt("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}}mp.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_plugin"},ht.add(mp);class gp{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,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}gp.extension={type:Z.RendererSystem,name:"projection"},ht.add(gp);const gT=new Kl,yp=new xt;class _p{constructor(t){this.renderer=t,this._tempMatrix=new kt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(yp))||t.getLocalBounds(yp,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Oi.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=gT,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}_p.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"textureGenerator"},ht.add(_p);const Ni=new xt,on=new xt;class vp{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new xt,this.destinationFrame=new xt,this.viewportFrame=new xt}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(Ni.width=t.frame.width,Ni.height=t.frame.height,e=Ni),i||(on.x=t.frame.x,on.y=t.frame.y,on.width=e.width,on.height=e.height,i=on),o=n.framebuffer):(a=s.resolution,e||(Ni.width=s._view.screen.width,Ni.height=s._view.screen.height,e=Ni),i||(i=Ni,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=Ot.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:u,height:c}=this.viewportFrame;l=Math.round(l),h=Math.round(h),u=Math.round(u),c=Math.round(c),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,u,c)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}vp.extension={type:Z.RendererSystem,name:"renderTexture"},ht.add(vp);class yT{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 _T(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=qf(t,n.type),a={type:o,name:n.name,size:jf(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function vT(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=qf(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Vf(l,n.size)}}return e}function xT(r,t){var a;const e=Xf(r,r.VERTEX_SHADER,t.vertexSrc),i=Xf(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||qE(r,s,e,i),t.attributeData=_T(s,r),t.uniformData=vT(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,u)=>h>u?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:Vf(h.type,h.size)}}return new yT(s,o)}function bT(r,t,e,i,s){e.buffer.update(s)}const ET={float:`
421
421
  data[offset] = v;
422
422
  `,vec2:`
423
423
  data[offset] = v[0];
@@ -455,7 +455,7 @@ void main(void)
455
455
  {
456
456
  data[offset + i] = v[i];
457
457
  }
458
- `},ap={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 QE(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=ap[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function JE(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function tT(r,t){if(!r.autoManage)return{size:0,syncFunc:KE};const e=JE(r.uniforms,t),{uboElements:i,size:s}=QE(e),n=[`
458
+ `},xp={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 TT(r){const t=r.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,i=0,s=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=xp[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,i%e!==0&&i<16){const a=i%e%16;i+=a,s+=a}i+e>16?(s=Math.ceil(s/16)*16,o.offset=s,s+=e,i=e):(o.offset=s,i+=e,s+=e)}return s=Math.ceil(s/16)*16,{uboElements:t,size:s}}function wT(r,t){const e=[];for(const i in r)t[i]&&e.push(t[i]);return e.sort((i,s)=>i.index-s.index),e}function AT(r,t){if(!r.autoManage)return{size:0,syncFunc:bT};const e=wT(r.uniforms,t),{uboElements:i,size:s}=TT(e),n=[`
459
459
  var v = null;
460
460
  var v2 = null;
461
461
  var cv = null;
@@ -463,7 +463,7 @@ void main(void)
463
463
  var gl = renderer.gl
464
464
  var index = 0;
465
465
  var data = buffer.data;
466
- `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<as.length;c++){const d=as[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,as[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Lf(a.data.type),d=Math.max(ap[a.data.type]/16,1),p=c/d,f=(4-p%4)%4;n.push(`
466
+ `];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let u=!1;for(let c=0;c<fs.length;c++){const d=fs[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,fs[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=jf(a.data.type),d=Math.max(xp[a.data.type]/16,1),p=c/d,f=(4-p%4)%4;n.push(`
467
467
  cv = ud.${h}.value;
468
468
  v = uv.${h};
469
469
  offset = ${a.offset/4};
@@ -479,7 +479,7 @@ void main(void)
479
479
  offset += ${f};
480
480
  }
481
481
 
482
- `)}else{const c=ZE[a.data.type];n.push(`
482
+ `)}else{const c=ET[a.data.type];n.push(`
483
483
  cv = ud.${h}.value;
484
484
  v = uv.${h};
485
485
  offset = ${a.offset/4};
@@ -487,7 +487,7 @@ void main(void)
487
487
  `)}}return n.push(`
488
488
  renderer.buffer.update(buffer);
489
489
  `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
490
- `))}}let eT=0;const _o={textureCount:0,uboCount:0};class lp{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=eT++}systemCheck(){if(!SE())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(_o.textureCount=0,_o.uboCount=0,this.syncUniformGroup(t.uniformGroup,_o)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=bE(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,_o,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=tT(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=qE(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}lp.extension={type:j.RendererSystem,name:"shader"},st.add(lp);class vo{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(){}}vo.defaultOptions={hello:!1},vo.extension={type:[j.RendererSystem,j.CanvasRendererSystem],name:"startup"},st.add(vo);function rT(r,t=[]){return t[pt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.ADD]=[r.ONE,r.ONE],t[pt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.NONE]=[0,0],t[pt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[pt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[pt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[pt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[pt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[pt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[pt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[pt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[pt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[pt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[pt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const iT=0,sT=1,nT=2,oT=3,aT=4,lT=5,hp=class jh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=pt.NONE,this._blendEq=!1,this.map=[],this.map[iT]=this.setBlend,this.map[sT]=this.setOffset,this.map[nT]=this.setCullFace,this.map[oT]=this.setDepthTest,this.map[aT]=this.setFrontFace,this.map[lT]=this.setDepthMask,this.checks=[],this.defaultState=new xr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=rT(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(jh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(jh.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}};hp.extension={type:j.RendererSystem,name:"state"};let hT=hp;st.add(hT);class uT extends ks{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new er(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const nn=class qo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=qo.defaultMaxIdle,this.checkCountMax=qo.defaultCheckCountMax,this.mode=qo.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Ba.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};nn.defaultMode=Ba.AUTO,nn.defaultMaxIdle=60*60,nn.defaultCheckCountMax=60*10,nn.extension={type:j.RendererSystem,name:"textureGC"};let Mi=nn;st.add(Mi);class eh{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=dt.UNSIGNED_BYTE,this.internalFormat=X.RGBA,this.samplerType=0}}function cT(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:Z.FLOAT,[r.RGBA]:Z.FLOAT,[r.ALPHA]:Z.FLOAT,[r.LUMINANCE]:Z.FLOAT,[r.LUMINANCE_ALPHA]:Z.FLOAT,[r.R8]:Z.FLOAT,[r.R8_SNORM]:Z.FLOAT,[r.RG8]:Z.FLOAT,[r.RG8_SNORM]:Z.FLOAT,[r.RGB8]:Z.FLOAT,[r.RGB8_SNORM]:Z.FLOAT,[r.RGB565]:Z.FLOAT,[r.RGBA4]:Z.FLOAT,[r.RGB5_A1]:Z.FLOAT,[r.RGBA8]:Z.FLOAT,[r.RGBA8_SNORM]:Z.FLOAT,[r.RGB10_A2]:Z.FLOAT,[r.RGB10_A2UI]:Z.FLOAT,[r.SRGB8]:Z.FLOAT,[r.SRGB8_ALPHA8]:Z.FLOAT,[r.R16F]:Z.FLOAT,[r.RG16F]:Z.FLOAT,[r.RGB16F]:Z.FLOAT,[r.RGBA16F]:Z.FLOAT,[r.R32F]:Z.FLOAT,[r.RG32F]:Z.FLOAT,[r.RGB32F]:Z.FLOAT,[r.RGBA32F]:Z.FLOAT,[r.R11F_G11F_B10F]:Z.FLOAT,[r.RGB9_E5]:Z.FLOAT,[r.R8I]:Z.INT,[r.R8UI]:Z.UINT,[r.R16I]:Z.INT,[r.R16UI]:Z.UINT,[r.R32I]:Z.INT,[r.R32UI]:Z.UINT,[r.RG8I]:Z.INT,[r.RG8UI]:Z.UINT,[r.RG16I]:Z.INT,[r.RG16UI]:Z.UINT,[r.RG32I]:Z.INT,[r.RG32UI]:Z.UINT,[r.RGB8I]:Z.INT,[r.RGB8UI]:Z.UINT,[r.RGB16I]:Z.INT,[r.RGB16UI]:Z.UINT,[r.RGB32I]:Z.INT,[r.RGB32UI]:Z.UINT,[r.RGBA8I]:Z.INT,[r.RGBA8UI]:Z.UINT,[r.RGBA16I]:Z.INT,[r.RGBA16UI]:Z.UINT,[r.RGBA32I]:Z.INT,[r.RGBA32UI]:Z.UINT,[r.DEPTH_COMPONENT16]:Z.FLOAT,[r.DEPTH_COMPONENT24]:Z.FLOAT,[r.DEPTH_COMPONENT32F]:Z.FLOAT,[r.DEPTH_STENCIL]:Z.FLOAT,[r.DEPTH24_STENCIL8]:Z.FLOAT,[r.DEPTH32F_STENCIL8]:Z.FLOAT}:t={[r.RGB]:Z.FLOAT,[r.RGBA]:Z.FLOAT,[r.ALPHA]:Z.FLOAT,[r.LUMINANCE]:Z.FLOAT,[r.LUMINANCE_ALPHA]:Z.FLOAT,[r.DEPTH_STENCIL]:Z.FLOAT},t}function dT(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[dt.UNSIGNED_BYTE]:{[X.RGBA]:r.RGBA8,[X.RGB]:r.RGB8,[X.RG]:r.RG8,[X.RED]:r.R8,[X.RGBA_INTEGER]:r.RGBA8UI,[X.RGB_INTEGER]:r.RGB8UI,[X.RG_INTEGER]:r.RG8UI,[X.RED_INTEGER]:r.R8UI,[X.ALPHA]:r.ALPHA,[X.LUMINANCE]:r.LUMINANCE,[X.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[dt.BYTE]:{[X.RGBA]:r.RGBA8_SNORM,[X.RGB]:r.RGB8_SNORM,[X.RG]:r.RG8_SNORM,[X.RED]:r.R8_SNORM,[X.RGBA_INTEGER]:r.RGBA8I,[X.RGB_INTEGER]:r.RGB8I,[X.RG_INTEGER]:r.RG8I,[X.RED_INTEGER]:r.R8I},[dt.UNSIGNED_SHORT]:{[X.RGBA_INTEGER]:r.RGBA16UI,[X.RGB_INTEGER]:r.RGB16UI,[X.RG_INTEGER]:r.RG16UI,[X.RED_INTEGER]:r.R16UI,[X.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[dt.SHORT]:{[X.RGBA_INTEGER]:r.RGBA16I,[X.RGB_INTEGER]:r.RGB16I,[X.RG_INTEGER]:r.RG16I,[X.RED_INTEGER]:r.R16I},[dt.UNSIGNED_INT]:{[X.RGBA_INTEGER]:r.RGBA32UI,[X.RGB_INTEGER]:r.RGB32UI,[X.RG_INTEGER]:r.RG32UI,[X.RED_INTEGER]:r.R32UI,[X.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[dt.INT]:{[X.RGBA_INTEGER]:r.RGBA32I,[X.RGB_INTEGER]:r.RGB32I,[X.RG_INTEGER]:r.RG32I,[X.RED_INTEGER]:r.R32I},[dt.FLOAT]:{[X.RGBA]:r.RGBA32F,[X.RGB]:r.RGB32F,[X.RG]:r.RG32F,[X.RED]:r.R32F,[X.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[dt.HALF_FLOAT]:{[X.RGBA]:r.RGBA16F,[X.RGB]:r.RGB16F,[X.RG]:r.RG16F,[X.RED]:r.R16F},[dt.UNSIGNED_SHORT_5_6_5]:{[X.RGB]:r.RGB565},[dt.UNSIGNED_SHORT_4_4_4_4]:{[X.RGBA]:r.RGBA4},[dt.UNSIGNED_SHORT_5_5_5_1]:{[X.RGBA]:r.RGB5_A1},[dt.UNSIGNED_INT_2_10_10_10_REV]:{[X.RGBA]:r.RGB10_A2,[X.RGBA_INTEGER]:r.RGB10_A2UI},[dt.UNSIGNED_INT_10F_11F_11F_REV]:{[X.RGB]:r.R11F_G11F_B10F},[dt.UNSIGNED_INT_5_9_9_9_REV]:{[X.RGB]:r.RGB9_E5},[dt.UNSIGNED_INT_24_8]:{[X.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[dt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[X.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[dt.UNSIGNED_BYTE]:{[X.RGBA]:r.RGBA,[X.RGB]:r.RGB,[X.ALPHA]:r.ALPHA,[X.LUMINANCE]:r.LUMINANCE,[X.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[dt.UNSIGNED_SHORT_5_6_5]:{[X.RGB]:r.RGB},[dt.UNSIGNED_SHORT_4_4_4_4]:{[X.RGBA]:r.RGBA},[dt.UNSIGNED_SHORT_5_5_5_1]:{[X.RGBA]:r.RGBA}},t}class up{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new yt,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=dT(t),this.samplerTypes=cT(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new eh(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 eh(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==Z.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new eh(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]??Z.FLOAT,this.webGLVersion===2&&t.type===dt.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==Z.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&os(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===dr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Yr.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!==dr.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===Ar.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Ar.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Ar.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Ar.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}up.extension={type:j.RendererSystem,name:"texture"},st.add(up);class cp{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}cp.extension={type:j.RendererSystem,name:"transformFeedback"},st.add(cp);class xo{constructor(t){this.renderer=t}init(t){this.screen=new _t(0,0,t.width,t.height),this.element=t.view||Q.ADAPTER.createCanvas(),this.resolution=t.resolution||Q.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}xo.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},xo.extension={type:[j.RendererSystem,j.CanvasRendererSystem],name:"_view"},st.add(xo),Q.PREFER_ENV=mi.WEBGL2,Q.STRICT_TEXTURE_CACHE=!1,Q.RENDER_OPTIONS={...mo.defaultOptions,...po.defaultOptions,...xo.defaultOptions,...vo.defaultOptions},Object.defineProperties(Q,{WRAP_MODE:{get(){return yt.defaultOptions.wrapMode},set(r){bt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),yt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return yt.defaultOptions.scaleMode},set(r){bt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),yt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return yt.defaultOptions.mipmap},set(r){bt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),yt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return yt.defaultOptions.anisotropicLevel},set(r){bt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),yt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return bt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Pe.defaultResolution},set(r){Pe.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return bt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Pe.defaultMultisample},set(r){Pe.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Ci.defaultMaxTextures},set(r){bt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ci.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Ci.defaultBatchSize},set(r){bt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ci.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ci.canUploadSameBuffer},set(r){bt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ci.canUploadSameBuffer=r}},GC_MODE:{get(){return Mi.defaultMode},set(r){bt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Mi.defaultMode=r}},GC_MAX_IDLE:{get(){return Mi.defaultMaxIdle},set(r){bt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Mi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Mi.defaultCheckCountMax},set(r){bt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Mi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Nr.defaultVertexPrecision},set(r){bt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Nr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Nr.defaultFragmentPrecision},set(r){bt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Nr.defaultFragmentPrecision=r}}});var Oi=(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))(Oi||{});class rh{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const dp=class $e{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 rh(null,null,1/0),this.deltaMS=1/$e.targetFPMS,this.elapsedMS=1/$e.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=Oi.NORMAL){return this._addListener(new rh(t,e,i))}addOnce(t,e,i=Oi.NORMAL){return this._addListener(new rh(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*$e.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,$e.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(!$e._shared){const t=$e._shared=new $e;t.autoStart=!0,t._protected=!0}return $e._shared}static get system(){if(!$e._system){const t=$e._system=new $e;t.autoStart=!0,t._protected=!0}return $e._system}};dp.targetFPMS=.06;let He=dp;Object.defineProperties(Q,{TARGET_FPMS:{get(){return He.targetFPMS},set(r){bt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),He.targetFPMS=r}}});class fp{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,Oi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?He.shared:new He,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}fp.extension=j.Application,st.add(fp);const pp=[];st.handleByList(j.Renderer,pp);function mp(r){for(const t of pp)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var fT=`attribute vec2 aVertexPosition;
490
+ `))}}let ST=0;const Eo={textureCount:0,uboCount:0};class bp{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=ST++}systemCheck(){if(!ZE())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Eo.textureCount=0,Eo.uboCount=0,this.syncUniformGroup(t.uniformGroup,Eo)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=YE(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Eo,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=AT(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=xT(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}bp.extension={type:Z.RendererSystem,name:"shader"},ht.add(bp);class To{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(){}}To.defaultOptions={hello:!1},To.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"startup"},ht.add(To);function CT(r,t=[]){return t[gt.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.ADD]=[r.ONE,r.ONE],t[gt.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.NONE]=[0,0],t[gt.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[gt.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[gt.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[gt.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[gt.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[gt.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[gt.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[gt.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[gt.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[gt.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[gt.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const IT=0,RT=1,MT=2,PT=3,OT=4,NT=5,Ep=class ru{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=gt.NONE,this._blendEq=!1,this.map=[],this.map[IT]=this.setBlend,this.map[RT]=this.setOffset,this.map[MT]=this.setCullFace,this.map[PT]=this.setDepthTest,this.map[OT]=this.setFrontFace,this.map[NT]=this.setDepthMask,this.checks=[],this.defaultState=new br,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=CT(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(ru.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(ru.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}};Ep.extension={type:Z.RendererSystem,name:"state"};let DT=Ep;ht.add(DT);class LT extends Hs{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new er(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const an=class Jo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Jo.defaultMaxIdle,this.checkCountMax=Jo.defaultCheckCountMax,this.mode=Jo.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Va.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};an.defaultMode=Va.AUTO,an.defaultMaxIdle=60*60,an.defaultCheckCountMax=60*10,an.extension={type:Z.RendererSystem,name:"textureGC"};let Di=an;ht.add(Di);class nh{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=ft.UNSIGNED_BYTE,this.internalFormat=z.RGBA,this.samplerType=0}}function BT(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 FT(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[ft.UNSIGNED_BYTE]:{[z.RGBA]:r.RGBA8,[z.RGB]:r.RGB8,[z.RG]:r.RG8,[z.RED]:r.R8,[z.RGBA_INTEGER]:r.RGBA8UI,[z.RGB_INTEGER]:r.RGB8UI,[z.RG_INTEGER]:r.RG8UI,[z.RED_INTEGER]:r.R8UI,[z.ALPHA]:r.ALPHA,[z.LUMINANCE]:r.LUMINANCE,[z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.BYTE]:{[z.RGBA]:r.RGBA8_SNORM,[z.RGB]:r.RGB8_SNORM,[z.RG]:r.RG8_SNORM,[z.RED]:r.R8_SNORM,[z.RGBA_INTEGER]:r.RGBA8I,[z.RGB_INTEGER]:r.RGB8I,[z.RG_INTEGER]:r.RG8I,[z.RED_INTEGER]:r.R8I},[ft.UNSIGNED_SHORT]:{[z.RGBA_INTEGER]:r.RGBA16UI,[z.RGB_INTEGER]:r.RGB16UI,[z.RG_INTEGER]:r.RG16UI,[z.RED_INTEGER]:r.R16UI,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[ft.SHORT]:{[z.RGBA_INTEGER]:r.RGBA16I,[z.RGB_INTEGER]:r.RGB16I,[z.RG_INTEGER]:r.RG16I,[z.RED_INTEGER]:r.R16I},[ft.UNSIGNED_INT]:{[z.RGBA_INTEGER]:r.RGBA32UI,[z.RGB_INTEGER]:r.RGB32UI,[z.RG_INTEGER]:r.RG32UI,[z.RED_INTEGER]:r.R32UI,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[ft.INT]:{[z.RGBA_INTEGER]:r.RGBA32I,[z.RGB_INTEGER]:r.RGB32I,[z.RG_INTEGER]:r.RG32I,[z.RED_INTEGER]:r.R32I},[ft.FLOAT]:{[z.RGBA]:r.RGBA32F,[z.RGB]:r.RGB32F,[z.RG]:r.RG32F,[z.RED]:r.R32F,[z.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[ft.HALF_FLOAT]:{[z.RGBA]:r.RGBA16F,[z.RGB]:r.RGB16F,[z.RG]:r.RG16F,[z.RED]:r.R16F},[ft.UNSIGNED_SHORT_5_6_5]:{[z.RGB]:r.RGB565},[ft.UNSIGNED_SHORT_4_4_4_4]:{[z.RGBA]:r.RGBA4},[ft.UNSIGNED_SHORT_5_5_5_1]:{[z.RGBA]:r.RGB5_A1},[ft.UNSIGNED_INT_2_10_10_10_REV]:{[z.RGBA]:r.RGB10_A2,[z.RGBA_INTEGER]:r.RGB10_A2UI},[ft.UNSIGNED_INT_10F_11F_11F_REV]:{[z.RGB]:r.R11F_G11F_B10F},[ft.UNSIGNED_INT_5_9_9_9_REV]:{[z.RGB]:r.RGB9_E5},[ft.UNSIGNED_INT_24_8]:{[z.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[ft.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[z.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[ft.UNSIGNED_BYTE]:{[z.RGBA]:r.RGBA,[z.RGB]:r.RGB,[z.ALPHA]:r.ALPHA,[z.LUMINANCE]:r.LUMINANCE,[z.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[ft.UNSIGNED_SHORT_5_6_5]:{[z.RGB]:r.RGB},[ft.UNSIGNED_SHORT_4_4_4_4]:{[z.RGBA]:r.RGBA},[ft.UNSIGNED_SHORT_5_5_5_1]:{[z.RGBA]:r.RGBA}},t}class Tp{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new _t,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=FT(t),this.samplerTypes=BT(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new nh(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 nh(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==J.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new nh(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===ft.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==J.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&ds(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===fr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=jr.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!==fr.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===Cr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===Cr.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===Cr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===Cr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Tp.extension={type:Z.RendererSystem,name:"texture"},ht.add(Tp);class wp{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}wp.extension={type:Z.RendererSystem,name:"transformFeedback"},ht.add(wp);class wo{constructor(t){this.renderer=t}init(t){this.screen=new xt(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,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}wo.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},wo.extension={type:[Z.RendererSystem,Z.CanvasRendererSystem],name:"_view"},ht.add(wo),tt.PREFER_ENV=vi.WEBGL2,tt.STRICT_TEXTURE_CACHE=!1,tt.RENDER_OPTIONS={...vo.defaultOptions,..._o.defaultOptions,...wo.defaultOptions,...To.defaultOptions},Object.defineProperties(tt,{WRAP_MODE:{get(){return _t.defaultOptions.wrapMode},set(r){wt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),_t.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return _t.defaultOptions.scaleMode},set(r){wt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),_t.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return _t.defaultOptions.mipmap},set(r){wt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),_t.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return _t.defaultOptions.anisotropicLevel},set(r){wt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),_t.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return wt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Be.defaultResolution},set(r){Be.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return wt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Be.defaultMultisample},set(r){Be.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Pi.defaultMaxTextures},set(r){wt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Pi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Pi.defaultBatchSize},set(r){wt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Pi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Pi.canUploadSameBuffer},set(r){wt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Pi.canUploadSameBuffer=r}},GC_MODE:{get(){return Di.defaultMode},set(r){wt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Di.defaultMode=r}},GC_MAX_IDLE:{get(){return Di.defaultMaxIdle},set(r){wt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Di.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Di.defaultCheckCountMax},set(r){wt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Di.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Lr.defaultVertexPrecision},set(r){wt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Lr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Lr.defaultFragmentPrecision},set(r){wt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Lr.defaultFragmentPrecision=r}}});var Li=(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))(Li||{});class oh{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));const e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Ap=class Ve{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 oh(null,null,1/0),this.deltaMS=1/Ve.targetFPMS,this.elapsedMS=1/Ve.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=Li.NORMAL){return this._addListener(new oh(t,e,i))}addOnce(t,e,i=Li.NORMAL){return this._addListener(new oh(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ve.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,Ve.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(!Ve._shared){const t=Ve._shared=new Ve;t.autoStart=!0,t._protected=!0}return Ve._shared}static get system(){if(!Ve._system){const t=Ve._system=new Ve;t.autoStart=!0,t._protected=!0}return Ve._system}};Ap.targetFPMS=.06;let Xe=Ap;Object.defineProperties(tt,{TARGET_FPMS:{get(){return Xe.targetFPMS},set(r){wt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Xe.targetFPMS=r}}});class Sp{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,Li.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Xe.shared:new Xe,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Sp.extension=Z.Application,ht.add(Sp);const Cp=[];ht.handleByList(Z.Renderer,Cp);function Ip(r){for(const t of Cp)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var UT=`attribute vec2 aVertexPosition;
491
491
  attribute vec2 aTextureCoord;
492
492
 
493
493
  uniform mat3 projectionMatrix;
@@ -498,7 +498,7 @@ void main(void)
498
498
  {
499
499
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
500
500
  vTextureCoord = aTextureCoord;
501
- }`,pT=`attribute vec2 aVertexPosition;
501
+ }`,kT=`attribute vec2 aVertexPosition;
502
502
 
503
503
  uniform mat3 projectionMatrix;
504
504
 
@@ -524,7 +524,7 @@ void main(void)
524
524
  gl_Position = filterVertexPosition();
525
525
  vTextureCoord = filterTextureCoord();
526
526
  }
527
- `;const mT=fT,gp=pT;class yp{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>=ne.HIGH?this.multisample=ne.HIGH:e>=ne.MEDIUM?this.multisample=ne.MEDIUM:e>=ne.LOW?this.multisample=ne.LOW:this.multisample=ne.NONE}destroy(){}}yp.extension={type:j.RendererSystem,name:"_multisample"},st.add(yp);class gT{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class _p{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new gT(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}_p.extension={type:j.RendererSystem,name:"buffer"},st.add(_p);class vp{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}vp.extension={type:j.RendererSystem,name:"objectRenderer"},st.add(vp);const bo=class zh extends uT{constructor(t){super(),this.type=Fc.WEBGL,t=Object.assign({},Q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new rr({projectionMatrix:new Bt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:zh.__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&&(bt("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=zh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Gb()}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 bt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return bt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return bt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return bt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){bt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return bt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){bt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return bt("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)}};bo.extension={type:j.Renderer,priority:1},bo.__plugins={},bo.__systems={};let ih=bo;st.handleByMap(j.RendererPlugin,ih.__plugins),st.handleByMap(j.RendererSystem,ih.__systems),st.add(ih);class xp extends tn{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new yt;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 tn?this.addResourceAt(t[i],i):this.addResourceAt(Sf(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 yT extends xp{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=zi.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class _T extends Lr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const bp=class pn extends xp{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==pn.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<pn.SIDES;a++)this.items[a].target=zi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=zi.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=zi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<pn.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===pn.SIDES}};bp.SIDES=6;let vT=bp;class hs extends Lr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=hs.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await Q.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ge.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return hs._EMPTY=hs._EMPTY??Q.ADAPTER.createCanvas(0,0),hs._EMPTY}}const sh=class Ko extends Lr{constructor(t,e){e=e||{},super(Q.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;Lr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${bi()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),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)}};sh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,sh.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let nh=sh;class xT extends Lr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const oh=class qh extends Lr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];Lr.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||qh.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=He.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&&(He.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||(He.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(He.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||qh.TYPES.includes(e)}};oh.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],oh.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ep=oh;Hl.push(hs,Hf,_T,Ep,xT,nh,eo,vT,yT);class Eo{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?_t.EMPTY:(t=t||new _t(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,u=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,y=o*e+l*i+u,_=a*e+h*i+c;d=y<d?y:d,p=_<p?_:p,f=y>f?y:f,m=_>m?_:m,y=o*s+l*i+u,_=a*s+h*i+c,d=y<d?y:d,p=_<p?_:p,f=y>f?y:f,m=_>m?_:m,y=o*e+l*n+u,_=a*e+h*n+c,d=y<d?y:d,p=_<p?_:p,f=y>f?y:f,m=_>m?_:m,y=o*s+l*n+u,_=a*s+h*n+c,d=y<d?y:d,p=_<p?_:p,f=y>f?y:f,m=_>m?_:m,this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],u=t[l+1];s=h<s?h:s,n=u<n?u:n,o=h>o?h:o,a=u>a?u:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,f=this.minY,m=this.maxX,y=this.maxY;for(let _=i;_<s;_+=2){const v=e[_],g=e[_+1],x=a*v+h*g+c,E=u*g+l*v+d;p=Math.min(p,x-n),m=Math.max(m,x+n),f=Math.min(f,E-o),y=Math.max(y,E+o)}this.minX=p,this.minY=f,this.maxX=m,this.maxY=y}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Wt extends ks{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Wl,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 Eo,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Wt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new _t),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new _t),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Eo);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new bT),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*pE}set angle(t){this.transform.rotation=t*mE}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 bT extends Wt{constructor(){super(...arguments),this.sortDirty=null}}Wt.prototype.displayObjectUpdateTransform=Wt.prototype.updateTransform;const ET=new Bt;function TT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Tp=class Kh extends Wt{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),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);os(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,os(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,os(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(TT),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==Kh.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=ET.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==he.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Tp.defaultSortableChildren=!1;let ir=Tp;ir.prototype.containerUpdateTransform=ir.prototype.updateTransform,Object.defineProperties(Q,{SORTABLE_CHILDREN:{get(){return ir.defaultSortableChildren},set(r){bt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),ir.defaultSortableChildren=r}}});const on=new At,wT=new Uint16Array([0,1,2,0,2,3]);class us extends ir{constructor(t){super(),this._anchor=new Pr(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=pt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||nt.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=wT,this.pluginName="batch",this.isSprite=!0,this._roundPixels=Q.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=zr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=zr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,f=0,m=0,y=0;if(u?(f=u.x-d._x*c.width,p=f+u.width,y=u.y-d._y*c.height,m=y+u.height):(f=-d._x*c.width,p=f+c.width,y=-d._y*c.height,m=y+c.height),h[0]=i*f+n*y+a,h[1]=o*y+s*f+l,h[2]=i*p+n*y+a,h[3]=o*y+s*p+l,h[4]=i*p+n*m+a,h[5]=o*m+s*p+l,h[6]=i*f+n*m+a,h[7]=o*m+s*f+l,this._roundPixels){const _=Q.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,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,f=-s._y*i.height,m=f+i.height;if(e[0]=o*d+l*f+u,e[1]=h*f+a*d+c,e[2]=o*p+l*f+u,e[3]=h*f+a*p+c,e[4]=o*p+l*m+u,e[5]=h*m+a*p+c,e[6]=o*d+l*m+u,e[7]=h*m+a*d+c,this._roundPixels){const y=Q.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 Eo),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 _t),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,on);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return on.x>=s&&on.x<s+e&&(n=-i*this.anchor.y,on.y>=n&&on.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof nt?t:nt.from(t,e);return new us(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=zr(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=zr(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||nt.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const wp=new Bt;Wt.prototype._cacheAsBitmap=!1,Wt.prototype._cacheData=null,Wt.prototype._cacheAsBitmapResolution=null,Wt.prototype._cacheAsBitmapMultisample=null;class AT{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(Wt.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 AT),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)}}}),Wt.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))},Wt.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new _t,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Ii.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${bi()}`;this._cacheData.textureCacheId=h,yt.addToCache(l.baseTexture,h),nt.addToCache(l,h);const u=this.transform.localTransform.copyTo(wp).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new us(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},Wt.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))},Wt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new _t,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Ii.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${bi()}`;this._cacheData.textureCacheId=a,yt.addToCache(o.baseTexture,a),nt.addToCache(o,a);const l=wp;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new us(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)},Wt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Wt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Wt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,yt.removeFromCache(this._cacheData.textureCacheId),nt.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Wt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Wt.prototype.name=null,ir.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Wt.prototype.getGlobalPosition=function(r=new At,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var ST=`varying vec2 vTextureCoord;
527
+ `;const GT=UT,Rp=kT;class Mp{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>=ne.HIGH?this.multisample=ne.HIGH:e>=ne.MEDIUM?this.multisample=ne.MEDIUM:e>=ne.LOW?this.multisample=ne.LOW:this.multisample=ne.NONE}destroy(){}}Mp.extension={type:Z.RendererSystem,name:"_multisample"},ht.add(Mp);class HT{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Pp{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new HT(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Pp.extension={type:Z.RendererSystem,name:"buffer"},ht.add(Pp);class Op{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Op.extension={type:Z.RendererSystem,name:"objectRenderer"},ht.add(Op);const Ao=class iu extends LT{constructor(t){super(),this.type=Jc.WEBGL,t=Object.assign({},tt.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new rr({projectionMatrix:new kt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:iu.__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&&(wt("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=iu.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:cE()}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 wt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return wt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return wt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return wt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){wt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return wt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){wt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return wt("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)}};Ao.extension={type:Z.Renderer,priority:1},Ao.__plugins={},Ao.__systems={};let ah=Ao;ht.handleByMap(Z.RendererPlugin,ah.__plugins),ht.handleByMap(Z.RendererSystem,ah.__systems),ht.add(ah);class Np extends rn{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new _t;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 rn?this.addResourceAt(t[i],i):this.addResourceAt(kf(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 $T extends Np{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ts.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class XT extends Br{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Dp=class yn extends Np{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==yn.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<yn.SIDES;a++)this.items[a].target=ts.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=ts.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=ts.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<yn.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===yn.SIDES}};Dp.SIDES=6;let VT=Dp;class ms extends Br{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=ms.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await tt.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===He.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return ms._EMPTY=ms._EMPTY??tt.ADAPTER.createCanvas(0,0),ms._EMPTY}}const lh=class ta extends Br{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)},ta.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;Br.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${Ai()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=ta.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"&&ta.SVG_XML.test(t)}};lh.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,lh.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let hh=lh;class zT extends Br{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const uh=class su extends Br{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];Br.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||su.MIME_TYPES[u]||`video/${u}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=Xe.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&&(Xe.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||(Xe.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Xe.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||su.TYPES.includes(e)}};uh.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],uh.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Lp=uh;zl.push(ms,tp,XT,Lp,zT,hh,no,VT,$T);class So{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?xt.EMPTY:(t=t||new xt(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,u=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,u),this.maxY=Math.max(this.maxY,u)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,u=t.tx,c=t.ty;let d=this.minX,p=this.minY,f=this.maxX,m=this.maxY,_=o*e+l*i+u,y=a*e+h*i+c;d=_<d?_:d,p=y<p?y:p,f=_>f?_:f,m=y>m?y:m,_=o*s+l*i+u,y=a*s+h*i+c,d=_<d?_:d,p=y<p?y:p,f=_>f?_:f,m=y>m?y:m,_=o*e+l*n+u,y=a*e+h*n+c,d=_<d?_:d,p=y<p?y:p,f=_>f?_:f,m=y>m?y:m,_=o*s+l*n+u,y=a*s+h*n+c,d=_<d?_:d,p=y<p?y:p,f=_>f?_:f,m=y>m?y:m,this.minX=d,this.minY=p,this.maxX=f,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],u=t[l+1];s=h<s?h:s,n=u<n?u:n,o=h>o?h:o,a=u>a?u:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,u=t.d,c=t.tx,d=t.ty;let p=this.minX,f=this.minY,m=this.maxX,_=this.maxY;for(let y=i;y<s;y+=2){const v=e[y],g=e[y+1],x=a*v+h*g+c,E=u*g+l*v+d;p=Math.min(p,x-n),m=Math.max(m,x+n),f=Math.min(f,E-o),_=Math.max(_,E+o)}this.minX=p,this.minY=f,this.maxX=m,this.maxY=_}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,u=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>u?o:u}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class jt extends Hs{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Kl,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 So,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(jt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new xt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new xt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new So);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new YT),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*kE}set angle(t){this.transform.rotation=t*GE}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 YT extends jt{constructor(){super(...arguments),this.sortDirty=null}}jt.prototype.displayObjectUpdateTransform=jt.prototype.updateTransform;const jT=new kt;function WT(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Bp=class nu extends jt{constructor(){super(),this.children=[],this.sortableChildren=nu.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);ds(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,ds(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,ds(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(WT),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==nu.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=jT.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==he.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};Bp.defaultSortableChildren=!1;let ir=Bp;ir.prototype.containerUpdateTransform=ir.prototype.updateTransform,Object.defineProperties(tt,{SORTABLE_CHILDREN:{get(){return ir.defaultSortableChildren},set(r){wt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),ir.defaultSortableChildren=r}}});const ln=new It,qT=new Uint16Array([0,1,2,0,2,3]);class gs extends ir{constructor(t){super(),this._anchor=new Dr(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 Ot(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=gt.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||ut.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=qT,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,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,u=t.trim,c=t.orig,d=this._anchor;let p=0,f=0,m=0,_=0;if(u?(f=u.x-d._x*c.width,p=f+u.width,_=u.y-d._y*c.height,m=_+u.height):(f=-d._x*c.width,p=f+c.width,_=-d._y*c.height,m=_+c.height),h[0]=i*f+n*_+a,h[1]=o*_+s*f+l,h[2]=i*p+n*_+a,h[3]=o*_+s*p+l,h[4]=i*p+n*m+a,h[5]=o*m+s*p+l,h[6]=i*f+n*m+a,h[7]=o*m+s*f+l,this._roundPixels){const y=tt.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*y)/y}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,u=n.tx,c=n.ty,d=-s._x*i.width,p=d+i.width,f=-s._y*i.height,m=f+i.height;if(e[0]=o*d+l*f+u,e[1]=h*f+a*d+c,e[2]=o*p+l*f+u,e[3]=h*f+a*p+c,e[4]=o*p+l*m+u,e[5]=h*m+a*p+c,e[6]=o*d+l*m+u,e[7]=h*m+a*d+c,this._roundPixels){const _=tt.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[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 So),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 xt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ln);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return ln.x>=s&&ln.x<s+e&&(n=-i*this.anchor.y,ln.y>=n&&ln.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof ut?t:ut.from(t,e);return new gs(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||ut.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Fp=new kt;jt.prototype._cacheAsBitmap=!1,jt.prototype._cacheData=null,jt.prototype._cacheAsBitmapResolution=null,jt.prototype._cacheAsBitmapMultisample=null;class KT{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(jt.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 KT),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)}}}),jt.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))},jt.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new xt,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Oi.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Ai()}`;this._cacheData.textureCacheId=h,_t.addToCache(l.baseTexture,h),ut.addToCache(l,h);const u=this.transform.localTransform.copyTo(Fp).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:u,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const c=new gs(l);c.transform.worldTransform=this.transform.worldTransform,c.anchor.x=-(e.x/e.width),c.anchor.y=-(e.y/e.height),c.alpha=t,c._bounds=this._bounds,this._cacheData.sprite=c,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=c.containsPoint.bind(c)},jt.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))},jt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new xt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Oi.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Ai()}`;this._cacheData.textureCacheId=a,_t.addToCache(o.baseTexture,a),ut.addToCache(o,a);const l=Fp;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new gs(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)},jt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},jt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},jt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,_t.removeFromCache(this._cacheData.textureCacheId),ut.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},jt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},jt.prototype.name=null,ir.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},jt.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 ZT=`varying vec2 vTextureCoord;
528
528
 
529
529
  uniform sampler2D uSampler;
530
530
  uniform float uAlpha;
@@ -533,9 +533,9 @@ void main(void)
533
533
  {
534
534
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
535
535
  }
536
- `;class CT extends Pe{constructor(t=1){super(mT,ST,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const IT={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]},RT=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
537
- `);function MT(r){const t=IT[r],e=t.length;let i=RT,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
538
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const OT=`
536
+ `;class QT extends Be{constructor(t=1){super(GT,ZT,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const JT={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]},tw=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
537
+ `);function ew(r){const t=JT[r],e=t.length;let i=tw,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
538
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const rw=`
539
539
  attribute vec2 aVertexPosition;
540
540
 
541
541
  uniform mat3 projectionMatrix;
@@ -565,8 +565,8 @@ void main(void)
565
565
 
566
566
  vec2 textureCoord = filterTextureCoord();
567
567
  %blur%
568
- }`;function PT(r,t){const e=Math.ceil(r/2);let i=OT,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
569
- `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class ah extends Pe{constructor(t,e=8,i=4,s=Pe.defaultResolution,n=5){const o=PT(n,t),a=MT(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,fr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,fr.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class NT extends Pe{constructor(t=8,e=4,i=Pe.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ah(!0,t,e,i,s),this.blurYFilter=new ah(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,fr.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var LT=`varying vec2 vTextureCoord;
568
+ }`;function iw(r,t){const e=Math.ceil(r/2);let i=rw,s="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<r;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),s+=a,s+=`
569
+ `}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class ch extends Be{constructor(t,e=8,i=4,s=Be.defaultResolution,n=5){const o=iw(n,t),a=ew(n);super(o,a),this.horizontal=t,this.resolution=s,this._quality=0,this.quality=i,this.blur=e}apply(t,e,i,s){if(i?this.horizontal?this.uniforms.strength=1/i.width*(i.width/e.width):this.uniforms.strength=1/i.height*(i.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,i,s);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,l=n;this.state.blend=!1,t.applyFilter(this,a,l,pr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,pr.BLIT),this.uniforms.uSampler=l;const u=l;l=a,a=u,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,l,i,s),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class sw extends Be{constructor(t=8,e=4,i=Be.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new ch(!0,t,e,i,s),this.blurYFilter=new ch(!1,t,e,i,s),this.resolution=i,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,i,s){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,pr.CLEAR),this.blurYFilter.apply(t,a,i,s),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,i,s):this.blurXFilter.apply(t,e,i,s)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var nw=`varying vec2 vTextureCoord;
570
570
  uniform sampler2D uSampler;
571
571
  uniform float m[20];
572
572
  uniform float uAlpha;
@@ -618,7 +618,7 @@ void main(void)
618
618
 
619
619
  gl_FragColor = vec4(rgb, result.a);
620
620
  }
621
- `;class lh extends Pe{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(gp,LT,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=Mt.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,u=o*(1-i)+a*s,c=o*(1-i)+a*s,d=i+o*(1-i),p=o*(1-i)-a*s,f=o*(1-i)-a*s,m=o*(1-i)+a*s,y=i+o*(1-i),_=[l,h,u,0,0,c,d,p,0,0,f,m,y,0,0,0,0,0,1,0];this._loadMatrix(_,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=Mt.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(s).toArray(),p=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(p,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}lh.prototype.grayscale=lh.prototype.greyscale;var DT=`varying vec2 vFilterCoord;
621
+ `;class dh extends Be{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(Rp,nw,t),this.alpha=1}_loadMatrix(t,e=!1){let i=t;e&&(this._multiply(i,this.uniforms.m,t),i=this._colorMatrix(i)),this.uniforms.m=i}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,s,n]=Ot.shared.setValue(t).toArray(),o=[i,0,0,0,0,0,s,0,0,0,0,0,n,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),s=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),l=i+(1-i)*o,h=o*(1-i)-a*s,u=o*(1-i)+a*s,c=o*(1-i)+a*s,d=i+o*(1-i),p=o*(1-i)-a*s,f=o*(1-i)-a*s,m=o*(1-i)+a*s,_=i+o*(1-i),y=[l,h,u,0,0,c,d,p,0,0,f,m,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,s=-.5*(i-1),n=[i,0,0,0,s,0,i,0,0,s,0,0,i,0,s,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const i=t*2/3+1,s=(i-1)*-.5,n=[i,s,s,0,0,s,i,s,0,0,s,s,i,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,s,n){t=t||.2,e=e||.15,i=i||16770432,s=s||3375104;const o=Ot.shared,[a,l,h]=o.setValue(i).toArray(),[u,c,d]=o.setValue(s).toArray(),p=[.3,.59,.11,0,0,a,l,h,t,0,u,c,d,e,0,a-u,l-c,h-d,0,0];this._loadMatrix(p,n)}night(t,e){t=t||.1;const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.uniforms.m}set matrix(t){this.uniforms.m=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}dh.prototype.grayscale=dh.prototype.greyscale;var ow=`varying vec2 vFilterCoord;
622
622
  varying vec2 vTextureCoord;
623
623
 
624
624
  uniform vec2 scale;
@@ -638,7 +638,7 @@ void main(void)
638
638
 
639
639
  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
640
640
  }
641
- `,BT=`attribute vec2 aVertexPosition;
641
+ `,aw=`attribute vec2 aVertexPosition;
642
642
 
643
643
  uniform mat3 projectionMatrix;
644
644
  uniform mat3 filterMatrix;
@@ -667,7 +667,7 @@ void main(void)
667
667
  vTextureCoord = filterTextureCoord();
668
668
  vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
669
669
  }
670
- `;class FT extends Pe{constructor(t,e){const i=new Bt;t.renderable=!1,super(BT,DT,{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 At(e,e)}apply(t,e,i,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var UT=`varying vec2 v_rgbNW;
670
+ `;class lw extends Be{constructor(t,e){const i=new kt;t.renderable=!1,super(aw,ow,{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,s){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,i,s)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var hw=`varying vec2 v_rgbNW;
671
671
  varying vec2 v_rgbNE;
672
672
  varying vec2 v_rgbSW;
673
673
  varying vec2 v_rgbSE;
@@ -788,7 +788,7 @@ void main() {
788
788
 
789
789
  gl_FragColor = color;
790
790
  }
791
- `,kT=`
791
+ `,uw=`
792
792
  attribute vec2 aVertexPosition;
793
793
 
794
794
  uniform mat3 projectionMatrix;
@@ -830,7 +830,7 @@ void main(void) {
830
830
 
831
831
  texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
832
832
  }
833
- `;class GT extends Pe{constructor(){super(kT,UT)}}var HT=`precision highp float;
833
+ `;class cw extends Be{constructor(){super(uw,hw)}}var dw=`precision highp float;
834
834
 
835
835
  varying vec2 vTextureCoord;
836
836
  varying vec4 vColor;
@@ -864,8 +864,8 @@ void main()
864
864
 
865
865
  gl_FragColor = color;
866
866
  }
867
- `;class $T extends Pe{constructor(t=.5,e=Math.random()){super(gp,HT,{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 Ap={AlphaFilter:CT,BlurFilter:NT,BlurFilterPass:ah,ColorMatrixFilter:lh,DisplacementFilter:FT,FXAAFilter:GT,NoiseFilter:$T};Object.entries(Ap).forEach(([r,t])=>{Object.defineProperty(Ap,r,{get(){return bt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class VT{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||(He.system.add(this.tickerUpdate,this,Oi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(He.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 Zr=new VT;class an{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=an.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new At,this.page=new At,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class To extends an{constructor(){super(...arguments),this.client=new At,this.movement=new At,this.offset=new At,this.global=new At,this.screen=new At}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,u,c,d,p,f,m){throw new Error("Method not implemented.")}}class sr extends To{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 cs extends To{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}cs.DOM_DELTA_PIXEL=0,cs.DOM_DELTA_LINE=1,cs.DOM_DELTA_PAGE=2;const XT=2048,YT=new At,hh=new At;class WT{constructor(t){this.dispatch=new ks,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Zr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,YT.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<XT&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Zr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Zr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,hh),!t.hitArea.contains(hh.x,hh.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof cs)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(sr);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(cs);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(sr);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 sr&&e instanceof sr&&(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 To&&e instanceof To&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const jT=1,zT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},uh=class Zh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new WT(null),Zr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new sr(null),this.rootWheelEvent=new cs(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Zh.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Zh._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Zr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,Zr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Zr.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;Zr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=jT),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=zT[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}};uh.extension={name:"events",type:[j.RendererSystem,j.CanvasRendererSystem]},uh.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let ch=uh;st.add(ch);function Sp(r){return r==="dynamic"||r==="static"}const qT={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??Sp(ch.defaultEventMode)},set interactive(r){bt("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=Sp(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof an))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}};Wt.mixin(qT);const KT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Wt.mixin(KT);const ZT=9,wo=100,QT=0,JT=0,Cp=2,Ip=1,tw=-1e3,ew=-1e3,rw=2;class Rp{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,(Cr.tablet||Cr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${wo}px`,e.style.height=`${wo}px`,e.style.position="absolute",e.style.top=`${QT}px`,e.style.left=`${JT}px`,e.style.zIndex=Cp.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=`${Ip}px`,t.style.height=`${Ip}px`,t.style.position="absolute",t.style.top=`${tw}px`,t.style.left=`${ew}px`,t.style.zIndex=rw.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(Cr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,u=n/a*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,os(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let f=p.hitArea;const m=p.worldTransform;p.hitArea?(c.style.left=`${(m.tx+f.x*m.a)*h}px`,c.style.top=`${(m.ty+f.y*m.d)*u}px`,c.style.width=`${f.width*m.a*h}px`,c.style.height=`${f.height*m.d*u}px`):(f=p.getBounds(),this.capHitArea(f),c.style.left=`${f.x*h}px`,c.style.top=`${f.y*u}px`,c.style.width=`${f.width*h}px`,c.style.height=`${f.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${wo}px`,e.style.height=`${wo}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Cp.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new an(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===ZT&&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}}Rp.extension={name:"accessibility",type:[j.RendererPlugin,j.CanvasRendererPlugin]},st.add(Rp);const Mp=class Qh{constructor(t){this.stage=new ir,t=Object.assign({forceCanvas:!1},t),this.renderer=mp(t),Qh._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=Qh._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Mp._plugins=[];let iw=Mp;st.handleByList(j.Application,iw._plugins);class Op{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Op.extension=j.Application,st.add(Op);const Pp={loader:j.LoadParser,resolver:j.ResolveParser,cache:j.CacheParser,detection:j.DetectionParser};st.handle(j.Asset,r=>{const t=r.ref;Object.entries(Pp).filter(([e])=>!!t[e]).forEach(([e,i])=>st.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Pp).filter(e=>!!t[e]).forEach(e=>st.remove(t[e]))});class sw{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 ds(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 Qr(r,t){const e=r.split("?")[0],i=de.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const nr=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),dh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Np(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Np(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function nw(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Np(r,s,0,e,i)}else i.push(r);return i}const Ao=r=>!Array.isArray(r);class ow{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=nr(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{const l=s?s[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof nt){const a=e;i.forEach(l=>{a.baseTexture!==nt.EMPTY.baseTexture&&yt.addToCache(a.baseTexture,l),nt.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 Pi=new ow;class aw{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Ao(t),o=nr(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=de.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
868
- ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=nr(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=de.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var or=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(or||{});const lw=".json",hw="application/json",uw={extension:{type:j.LoadParser,priority:or.Low},name:"loadJson",test(r){return ds(r,hw)||Qr(r,lw)},async load(r){return await(await Q.ADAPTER.fetch(r)).json()}};st.add(uw);const cw=".txt",dw="text/plain",fw={name:"loadTxt",extension:{type:j.LoadParser,priority:or.Low},test(r){return ds(r,dw)||Qr(r,cw)},async load(r){return await(await Q.ADAPTER.fetch(r)).text()}};st.add(fw);const pw=["normal","bold","100","200","300","400","500","600","700","800","900"],mw=[".ttf",".otf",".woff",".woff2"],gw=["font/ttf","font/otf","font/woff","font/woff2"],yw=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function _w(r){const t=de.extname(r),e=de.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(yw)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const vw=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function xw(r){return vw.test(r)?r:encodeURI(r)}const bw={extension:{type:j.LoadParser,priority:or.Low},name:"loadWebFont",test(r){return ds(r,gw)||Qr(r,mw)},async load(r,t){var i,s,n;const e=Q.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??_w(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>pw.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${xw(r)})`,{...h,weight:c});await d.load(),e.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>Q.ADAPTER.getFontFaceSet().delete(t))}};st.add(bw);const Ew=`(function() {
867
+ `;class fw extends Be{constructor(t=.5,e=Math.random()){super(Rp,dw,{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 Up={AlphaFilter:QT,BlurFilter:sw,BlurFilterPass:ch,ColorMatrixFilter:dh,DisplacementFilter:lw,FXAAFilter:cw,NoiseFilter:fw};Object.entries(Up).forEach(([r,t])=>{Object.defineProperty(Up,r,{get(){return wt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class pw{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||(Xe.system.add(this.tickerUpdate,this,Li.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Xe.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 Jr=new pw;class hn{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=hn.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,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class Co extends hn{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,s,n,o,a,l,h,u,c,d,p,f,m){throw new Error("Method not implemented.")}}class sr extends Co{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 ys extends Co{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}ys.DOM_DELTA_PIXEL=0,ys.DOM_DELTA_LINE=1,ys.DOM_DELTA_PAGE=2;const mw=2048,gw=new It,fh=new It;class yw{constructor(t){this.dispatch=new Hs,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){Jr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,gw.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<mw&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Jr.pauseUpdate=!1),t.interactiveChildren&&t.children){const u=t.children;for(let c=u.length-1;c>=0;c--){const d=u[c],p=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();(p.length>0||f)&&(f&&this._allInteractiveElements.push(t),p.push(t)),this._hitElements.length===0&&(this._hitElements=p),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Jr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const u=l[h],c=this.hitTestRecursive(u,this._isInteractive(e)?e:u.eventMode,i,s,n);if(c){if(c.length>0&&!c[c.length-1].parent)continue;const d=t.isInteractive();return(c.length>0||d)&&c.push(t),c}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,fh),!t.hitArea.contains(fh.x,fh.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const u=t.type==="mousemove"?"mouseout":"pointerout",c=this.createPointerEvent(t,u,n);if(this.dispatchEvent(c,"pointerout"),i&&this.dispatchEvent(c,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(c)}if(n!==e.target){const u=t.type==="mousemove"?"mouseover":"pointerover",c=this.clonePointerEvent(e,u);this.dispatchEvent(c,"pointerover"),i&&this.dispatchEvent(c,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(e,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==n&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),i&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(c)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof sr)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof ys)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(sr);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(ys);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(sr);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 sr&&e instanceof sr&&(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 Co&&e instanceof Co&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const _w=1,vw={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ph=class ou{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new yw(null),Jr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new sr(null),this.rootWheelEvent=new ys(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...ou.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,ou._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Jr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,Jr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Jr.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;Jr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=_w),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=vw[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}};ph.extension={name:"events",type:[Z.RendererSystem,Z.CanvasRendererSystem]},ph.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let mh=ph;ht.add(mh);function kp(r){return r==="dynamic"||r==="static"}const xw={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??kp(mh.defaultEventMode)},set interactive(r){wt("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??mh.defaultEventMode},set eventMode(r){this._internalInteractive=kp(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof hn))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}};jt.mixin(xw);const bw={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};jt.mixin(bw);const Ew=9,Io=100,Tw=0,ww=0,Gp=2,Hp=1,Aw=-1e3,Sw=-1e3,Cw=2;class $p{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,(Rr.tablet||Rr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Io}px`,e.style.height=`${Io}px`,e.style.position="absolute",e.style.top=`${Tw}px`,e.style.left=`${ww}px`,e.style.zIndex=Gp.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=`${Hp}px`,t.style.height=`${Hp}px`,t.style.position="absolute",t.style.top=`${Aw}px`,t.style.left=`${Sw}px`,t.style.zIndex=Cw.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(Rr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,u=n/a*l;let c=this.div;c.style.left=`${e}px`,c.style.top=`${i}px`,c.style.width=`${o}px`,c.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const p=this.children[d];if(p.renderId!==this.renderId)p._accessibleActive=!1,ds(this.children,d,1),this.div.removeChild(p._accessibleDiv),this.pool.push(p._accessibleDiv),p._accessibleDiv=null,d--;else{c=p._accessibleDiv;let f=p.hitArea;const m=p.worldTransform;p.hitArea?(c.style.left=`${(m.tx+f.x*m.a)*h}px`,c.style.top=`${(m.ty+f.y*m.d)*u}px`,c.style.width=`${f.width*m.a*h}px`,c.style.height=`${f.height*m.d*u}px`):(f=p.getBounds(),this.capHitArea(f),c.style.left=`${f.x*h}px`,c.style.top=`${f.y*u}px`,c.style.width=`${f.width*h}px`,c.style.height=`${f.height*u}px`,c.title!==p.accessibleTitle&&p.accessibleTitle!==null&&(c.title=p.accessibleTitle),c.getAttribute("aria-label")!==p.accessibleHint&&p.accessibleHint!==null&&c.setAttribute("aria-label",p.accessibleHint)),(p.accessibleTitle!==c.title||p.tabIndex!==c.tabIndex)&&(c.title=p.accessibleTitle,c.tabIndex=p.tabIndex,this.debug&&this.updateDebugHTML(c))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Io}px`,e.style.height=`${Io}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Gp.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new hn(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Ew&&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}}$p.extension={name:"accessibility",type:[Z.RendererPlugin,Z.CanvasRendererPlugin]},ht.add($p);const Xp=class au{constructor(t){this.stage=new ir,t=Object.assign({forceCanvas:!1},t),this.renderer=Ip(t),au._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=au._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Xp._plugins=[];let Iw=Xp;ht.handleByList(Z.Application,Iw._plugins);class Vp{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Vp.extension=Z.Application,ht.add(Vp);const zp={loader:Z.LoadParser,resolver:Z.ResolveParser,cache:Z.CacheParser,detection:Z.DetectionParser};ht.handle(Z.Asset,r=>{const t=r.ref;Object.entries(zp).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(zp).filter(e=>!!t[e]).forEach(e=>ht.remove(t[e]))});class Rw{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 _s(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 ti(r,t){const e=r.split("?")[0],i=ge.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const nr=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),gh=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Yp(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Yp(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function Mw(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Yp(r,s,0,e,i)}else i.push(r);return i}const Ro=r=>!Array.isArray(r);class Pw{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=nr(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{const l=s?s[a]:e;this._cache.has(a)&&this._cache.get(a)!==l&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof ut){const a=e;i.forEach(l=>{a.baseTexture!==ut.EMPTY.baseTexture&&_t.addToCache(a.baseTexture,l),ut.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 Pw;class Ow{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Ro(t),o=nr(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=ge.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[u]||(this.promiseCache[u]=this._getLoadPromiseAndParser(u,h)),s[h.src]=await this.promiseCache[u].promise,e&&e(++i/a)}catch(c){throw delete this.promiseCache[u],delete s[h.src],new Error(`[Loader.load] Failed to load ${u}.
868
+ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=nr(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=ge.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var or=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(or||{});const Nw=".json",Dw="application/json",Lw={extension:{type:Z.LoadParser,priority:or.Low},name:"loadJson",test(r){return _s(r,Dw)||ti(r,Nw)},async load(r){return await(await tt.ADAPTER.fetch(r)).json()}};ht.add(Lw);const Bw=".txt",Fw="text/plain",Uw={name:"loadTxt",extension:{type:Z.LoadParser,priority:or.Low},test(r){return _s(r,Fw)||ti(r,Bw)},async load(r){return await(await tt.ADAPTER.fetch(r)).text()}};ht.add(Uw);const kw=["normal","bold","100","200","300","400","500","600","700","800","900"],Gw=[".ttf",".otf",".woff",".woff2"],Hw=["font/ttf","font/otf","font/woff","font/woff2"],$w=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Xw(r){const t=ge.extname(r),e=ge.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match($w)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const Vw=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function zw(r){return Vw.test(r)?r:encodeURI(r)}const Yw={extension:{type:Z.LoadParser,priority:or.Low},name:"loadWebFont",test(r){return _s(r,Hw)||ti(r,Gw)},async load(r,t){var i,s,n;const e=tt.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??Xw(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>kw.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${zw(r)})`,{...h,weight:c});await d.load(),e.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>tt.ADAPTER.getFontFaceSet().delete(t))}};ht.add(Yw);const jw=`(function() {
869
869
  "use strict";
870
870
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
871
871
  async function checkImageBitmap() {
@@ -882,7 +882,7 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=nr
882
882
  self.postMessage(result);
883
883
  });
884
884
  })();
885
- `;let fs=null,fh=class{constructor(){fs||(fs=URL.createObjectURL(new Blob([Ew],{type:"application/javascript"}))),this.worker=new Worker(fs)}};fh.revokeObjectURL=function(){fs&&(URL.revokeObjectURL(fs),fs=null)};const Tw=`(function() {
885
+ `;let vs=null,yh=class{constructor(){vs||(vs=URL.createObjectURL(new Blob([jw],{type:"application/javascript"}))),this.worker=new Worker(vs)}};yh.revokeObjectURL=function(){vs&&(URL.revokeObjectURL(vs),vs=null)};const Ww=`(function() {
886
886
  "use strict";
887
887
  async function loadImageBitmap(url) {
888
888
  const response = await fetch(url);
@@ -908,8 +908,8 @@ ${c}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=nr
908
908
  }
909
909
  };
910
910
  })();
911
- `;let ps=null;class Lp{constructor(){ps||(ps=URL.createObjectURL(new Blob([Tw],{type:"application/javascript"}))),this.worker=new Worker(ps)}}Lp.revokeObjectURL=function(){ps&&(URL.revokeObjectURL(ps),ps=null)};let Dp=0,ph;class ww{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 fh;e.addEventListener("message",i=>{e.terminate(),fh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ph===void 0&&(ph=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<ph&&(this._createdWorkers++,t=new Lp().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Dp]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Dp++,id:i})}}const Bp=new ww;function ln(r,t,e){r.resource.internal=!0;const i=new nt(r),s=()=>{delete t.promiseCache[e],Pi.has(e)&&Pi.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const Aw=[".jpeg",".jpg",".png",".webp",".avif"],Sw=["image/jpeg","image/png","image/webp","image/avif"];async function Cw(r){const t=await Q.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const So={name:"loadTextures",extension:{type:j.LoadParser,priority:or.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ds(r,Sw)||Qr(r,Aw)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Bp.isImageBitmapSupported()?s=await Bp.loadImageBitmap(r):s=await Cw(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=Or(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new yt(s,n);return o.resource.src=r,ln(o,e,r)},unload(r){r.destroy(!0)}};st.add(So);const Iw=".svg",Rw="image/svg+xml",Mw={extension:{type:j.LoadParser,priority:or.High},name:"loadSVG",test(r){return ds(r,Rw)||Qr(r,Iw)},async testParse(r){return nh.test(r)},async parse(r,t,e){var n;const i=new nh(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new yt(i,{resolution:Or(r),...t==null?void 0:t.data});return s.resource.src=t.src,ln(s,e,t.src)},async load(r,t){return(await Q.ADAPTER.fetch(r)).text()},unload:So.unload};st.add(Mw);const Ow=[".mp4",".m4v",".webm",".ogv"],Pw=["video/mp4","video/webm","video/ogg"],Nw={name:"loadVideo",extension:{type:j.LoadParser,priority:or.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return ds(r,Pw)||Qr(r,Ow)},async load(r,t,e){var o;let i;const s=await(await Q.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new Ep(n,a);await l.load();const h=new yt(l,{alphaMode:await kb(),resolution:Or(r),...t==null?void 0:t.data});h.resource.src=r,i=ln(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};st.add(Nw);class Lw{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return nr(e||i||s||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>(a==null?void 0:a.src)??(a==null?void 0:a.srcs)??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(bt("7.2.0",`Assets.add now uses an object instead of individual parameters.
912
- Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},nr(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=nr(h||u).map(_=>typeof _=="string"?nw(_):Array.isArray(_)?_:[_]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const y=[];f.forEach(_=>{_.forEach(v=>{let g={};if(typeof v!="object"){g.src=v;for(let x=0;x<this._parsers.length;x++){const E=this._parsers[x];if(E.test(v)){g=E.parse(v);break}}}else c=v.data??c,d=v.format??d,p=v.loadParser??p,g={...g,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:c,format:d,loadParser:p}),y.push(g)})}),m.forEach(_=>{this._assetMap[_]=y})})}resolveBundle(t){const e=Ao(t);t=nr(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Ao(t);t=nr(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=de.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??de.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Dw{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Lw,this.loader=new aw,this.cache=Pi,this._backgroundLoader=new sw(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Ao(t),s=nr(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},u=o.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(p=>{n[c]=p})});return await Promise.all(u),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return Pi.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Pi.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[s[l]]=h,Pi.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=nr(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=nr(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{Pi.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return So.config.preferWorkers}set preferWorkers(t){bt("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 Co=new Dw;st.handleByList(j.LoadParser,Co.loader.parsers).handleByList(j.ResolveParser,Co.resolver.parsers).handleByList(j.CacheParser,Co.cache.parsers).handleByList(j.DetectionParser,Co.detections);const Bw={extension:j.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof nt),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};st.add(Bw);async function Fp(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 Fw={extension:{type:j.DetectionParser,priority:1},test:async()=>Fp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};st.add(Fw);const Uw={extension:{type:j.DetectionParser,priority:0},test:async()=>Fp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};st.add(Uw);const Up=["png","jpg","jpeg"],kw={extension:{type:j.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Up],remove:async r=>r.filter(t=>!Up.includes(t))};st.add(kw);const Gw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function mh(r){return Gw?!1:document.createElement("video").canPlayType(r)!==""}const Hw={extension:{type:j.DetectionParser,priority:0},test:async()=>mh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};st.add(Hw);const $w={extension:{type:j.DetectionParser,priority:0},test:async()=>mh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};st.add($w);const Vw={extension:{type:j.DetectionParser,priority:0},test:async()=>mh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};st.add(Vw);const Xw={extension:j.ResolveParser,test:So.test,parse:r=>{var t;return{resolution:parseFloat(((t=Q.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:de.extname(r).slice(1),src:r}}};st.add(Xw);var Te=(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))(Te||{});const Io={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 Er,ms;function kp(){ms={bptc:Er.getExtension("EXT_texture_compression_bptc"),astc:Er.getExtension("WEBGL_compressed_texture_astc"),etc:Er.getExtension("WEBGL_compressed_texture_etc"),s3tc:Er.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Er.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Er.getExtension("WEBGL_compressed_texture_pvrtc")||Er.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Er.getExtension("WEBGL_compressed_texture_etc1"),atc:Er.getExtension("WEBGL_compressed_texture_atc")}}const Yw={extension:{type:j.DetectionParser,priority:2},test:async()=>{const r=Q.ADAPTER.createCanvas().getContext("webgl");return r?(Er=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{ms||kp();const t=[];for(const e in ms)ms[e]&&t.push(e);return[...t,...r]},remove:async r=>(ms||kp(),r.filter(t=>!(t in ms)))};st.add(Yw);class Ww extends eo{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new Ll(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ll(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ni extends Ww{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Ni._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ni._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Ni._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,u=o,c=a,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Io[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,h,f)},h+=f,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Io[e];return l}}const gh=4,Ro=124,jw=32,Gp=20,zw=542327876,Mo={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},qw={FOURCC:2},Oo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},Kw=1,Zw=2,Qw=4,Jw=64,tA=512,eA=131072,rA=827611204,iA=861165636,sA=894720068,nA=808540228,oA=4,aA={[rA]:Te.COMPRESSED_RGBA_S3TC_DXT1_EXT,[iA]:Te.COMPRESSED_RGBA_S3TC_DXT3_EXT,[sA]:Te.COMPRESSED_RGBA_S3TC_DXT5_EXT},lA={70:Te.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:Te.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:Te.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:Te.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:Te.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:Te.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:Te.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:Te.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:Te.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:Te.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:Te.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:Te.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:Te.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function hA(r){const t=new Uint32Array(r);if(t[0]!==zw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Ro/Uint32Array.BYTES_PER_ELEMENT),i=e[Mo.HEIGHT],s=e[Mo.WIDTH],n=e[Mo.MIPMAP_COUNT],o=new Uint32Array(r,Mo.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,jw/Uint32Array.BYTES_PER_ELEMENT),a=o[Kw];if(a&Qw){const l=o[qw.FOURCC];if(l!==nA){const v=aA[l],g=gh+Ro,x=new Uint8Array(r,g);return[new Ni(x,{format:v,width:s,height:i,levels:n})]}const h=gh+Ro,u=new Uint32Array(t.buffer,h,Gp/Uint32Array.BYTES_PER_ELEMENT),c=u[Oo.DXGI_FORMAT],d=u[Oo.RESOURCE_DIMENSION],p=u[Oo.MISC_FLAG],f=u[Oo.ARRAY_SIZE],m=lA[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===oA)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,_=gh+Ro+Gp;if(f===1)y.push(new Uint8Array(r,_));else{const v=Io[m];let g=0,x=s,E=i;for(let A=0;A<n;A++){const R=Math.max(1,x+3&-4),M=Math.max(1,E+3&-4),D=R*M*v;g+=D,x=x>>>1,E=E>>>1}let w=_;for(let A=0;A<f;A++)y.push(new Uint8Array(r,w,g)),w+=g}return y.map(v=>new Ni(v,{format:m,width:s,height:i,levels:n}))}throw a&Jw?new Error("DDSParser does not support uncompressed texture data."):a&tA?new Error("DDSParser does not supported YUV uncompressed texture data."):a&eA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Zw?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 Hp=[171,75,84,88,32,49,49,187,13,10,26,10],uA=67305985,ar={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},yh=64,$p={[dt.UNSIGNED_BYTE]:1,[dt.UNSIGNED_SHORT]:2,[dt.INT]:4,[dt.UNSIGNED_INT]:4,[dt.FLOAT]:4,[dt.HALF_FLOAT]:8},cA={[X.RGBA]:4,[X.RGB]:3,[X.RG]:2,[X.RED]:1,[X.LUMINANCE]:1,[X.LUMINANCE_ALPHA]:2,[X.ALPHA]:1},dA={[dt.UNSIGNED_SHORT_4_4_4_4]:2,[dt.UNSIGNED_SHORT_5_5_5_1]:2,[dt.UNSIGNED_SHORT_5_6_5]:2};function fA(r,t,e=!1){const i=new DataView(t);if(!pA(r,i))return null;const s=i.getUint32(ar.ENDIANNESS,!0)===uA,n=i.getUint32(ar.GL_TYPE,s),o=i.getUint32(ar.GL_FORMAT,s),a=i.getUint32(ar.GL_INTERNAL_FORMAT,s),l=i.getUint32(ar.PIXEL_WIDTH,s),h=i.getUint32(ar.PIXEL_HEIGHT,s)||1,u=i.getUint32(ar.PIXEL_DEPTH,s)||1,c=i.getUint32(ar.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(ar.NUMBER_OF_FACES,s),p=i.getUint32(ar.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(ar.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,y=4,_=l+3&-4,v=h+3&-4,g=new Array(c);let x=l*h;n===0&&(x=_*v);let E;if(n!==0?$p[n]?E=$p[n]*cA[o]:E=dA[n]:E=Io[a],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const w=e?gA(i,f,s):null;let A=x*E,R=l,M=h,D=_,U=v,C=yh+f;for(let T=0;T<p;T++){const I=i.getUint32(C,s);let N=C+4;for(let O=0;O<c;O++){let L=g[O];L||(L=g[O]=new Array(p)),L[T]={levelID:T,levelWidth:p>1||n!==0?R:D,levelHeight:p>1||n!==0?M:U,levelBuffer:new Uint8Array(t,N,A)},N+=A}C+=I+4,C=C%4!==0?C+4-C%4:C,R=R>>1||1,M=M>>1||1,D=R+m-1&-4,U=M+y-1&-4,A=D*U*E}return n!==0?{uncompressed:g.map(T=>{let I=T[0].levelBuffer,N=!1;return n===dt.FLOAT?I=new Float32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4):n===dt.UNSIGNED_INT?(N=!0,I=new Uint32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)):n===dt.INT&&(N=!0,I=new Int32Array(T[0].levelBuffer.buffer,T[0].levelBuffer.byteOffset,T[0].levelBuffer.byteLength/4)),{resource:new eo(I,{width:T[0].levelWidth,height:T[0].levelHeight}),type:n,format:N?mA(o):o}}),kvData:w}:{compressed:g.map(T=>new Ni(null,{format:a,width:l,height:h,levels:p,levelBuffers:T})),kvData:w}}function pA(r,t){for(let e=0;e<Hp.length;e++)if(t.getUint8(e)!==Hp[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function mA(r){switch(r){case X.RGBA:return X.RGBA_INTEGER;case X.RGB:return X.RGB_INTEGER;case X.RG:return X.RG_INTEGER;case X.RED:return X.RED_INTEGER;default:return r}}function gA(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(yh+s,e),o=yh+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),u=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,u),s+=4+n+a}return i}const yA={extension:{type:j.LoadParser,priority:or.High},name:"loadDDS",test(r){return Qr(r,".dds")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),s=hA(i).map(n=>{const o=new yt(n,{mipmap:dr.OFF,alphaMode:Ge.NO_PREMULTIPLIED_ALPHA,resolution:Or(r),...t.data});return ln(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};st.add(yA);const _A={extension:{type:j.LoadParser,priority:or.High},name:"loadKTX",test(r){return Qr(r,".ktx")},async load(r,t,e){const i=await(await Q.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=fA(r,i),a=s??n,l={mipmap:dr.OFF,alphaMode:Ge.NO_PREMULTIPLIED_ALPHA,resolution:Or(r),...t.data},h=a.map(u=>{a===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new yt(c,l);return d.ktxKeyValueData=o,ln(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};st.add(_A);const vA=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],xA={extension:j.ResolveParser,test:r=>{const t=de.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(vA.includes(n))return{resolution:parseFloat(((i=Q.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=Q.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};st.add(xA);const Po=new _t,bA=4,Vp=class mn{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&mn._flipY(i,s,n),a&&mn._unpremultiplyAlpha(i);const l=new eE(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&mn._flipY(i,s,n),a&&mn._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Ii?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Po.width=e.width,Po.height=e.height,e=Po)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===X.RGBA,!l){i.renderTexture.bind(a);const p=a.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=Po,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(bA*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Vp.extension={name:"extract",type:j.RendererSystem};let EA=Vp;st.add(EA);const No={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Ee.CIRC){const f=r.shape;e=f.x,i=f.y,o=a=f.radius,s=n=0}else if(r.type===Ee.ELIP){const f=r.shape;e=f.x,i=f.y,o=f.width,a=f.height,s=n=0}else{const f=r.shape,m=f.width/2,y=f.height/2;e=f.x+m,i=f.y+y,o=a=Math.max(0,Math.min(f.radius,Math.min(m,y))),s=m-o,n=y-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let u=0,c=l*4+(s?2:0)+2,d=c,p=h;{const f=s+o,m=n,y=e+f,_=e-f,v=i+m;if(t[u++]=y,t[u++]=v,t[--c]=v,t[--c]=_,n){const g=i-m;t[d++]=_,t[d++]=g,t[--p]=g,t[--p]=y}}for(let f=1;f<l;f++){const m=Math.PI/2*(f/l),y=s+Math.cos(m)*o,_=n+Math.sin(m)*a,v=e+y,g=e-y,x=i+_,E=i-_;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=E,t[--p]=E,t[--p]=v}{const f=s,m=n+a,y=e+f,_=e-f,v=i+m,g=i-m;t[u++]=y,t[u++]=v,t[--p]=g,t[--p]=y,s&&(t[u++]=_,t[u++]=v,t[--p]=g,t[--p]=_)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Ee.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Xp(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Yp={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Xp(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];Xp(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=Lv(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},TA={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},wA={build(r){No.build(r)},triangulate(r,t){No.triangulate(r,t)}};var je=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(je||{}),Jr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Jr||{});const gs={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 Wp{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=l*l+h*h,f=u*u+c*c,m=l*u+h*c,y=n*Math.sqrt(p)/d,_=n*Math.sqrt(f)/d,v=y*m/p,g=_*m/f,x=y*c+_*h,E=y*u+_*l,w=h*(_+v),A=l*(_+v),R=c*(y+g),M=u*(y+g),D=Math.atan2(A-E,w-x),U=Math.atan2(M-E,R-x);return{cx:x+t,cy:E+e,radius:n,startAngle:D,endAngle:U,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=gs._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/io)*40),d=u/(c*2),p=d*2,f=Math.cos(d),m=Math.sin(d),y=c-1,_=y%1/y;for(let v=0;v<=y;++v){const g=v+_*v,x=d+o+p*g,E=Math.cos(x),w=-Math.sin(x);h.push((f*E+m*w)*n+i,(f*-w+m*E)*n+s)}}}class AA{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 _h{static curveLength(t,e,i,s,n,o,a,l){let h=0,u=0,c=0,d=0,p=0,f=0,m=0,y=0,_=0,v=0,g=0,x=t,E=e;for(let w=1;w<=10;++w)u=w/10,c=u*u,d=c*u,p=1-u,f=p*p,m=f*p,y=m*t+3*f*u*i+3*p*c*n+d*a,_=m*e+3*f*u*s+3*p*c*o+d*l,v=x-y,g=E-_,x=y,E=_,h+=Math.sqrt(v*v+g*g);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=gs._segmentsCount(_h.curveLength(l,h,t,e,i,s,n,o));let c=0,d=0,p=0,f=0,m=0;a.push(l,h);for(let y=1,_=0;y<=u;++y)_=y/u,c=1-_,d=c*c,p=d*c,f=_*_,m=f*_,a.push(p*l+3*d*_*t+3*c*f*i+m*n,p*h+3*d*_*e+3*c*f*s+m*o)}}function jp(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,p;o?(d=i,p=-e):(d=-i,p=e);const f=l+d,m=h+p,y=u+d,_=c+p;return a.push(f,m,y,_),2}function Li(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,f=Math.abs(p),m=Math.sqrt(l*l+h*h),y=(15*f*Math.sqrt(m)/Math.PI>>0)+1,_=p/y;if(d+=_,a){o.push(r,t,e,i);for(let v=1,g=d;v<y;v++,g+=_)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,g=d;v<y;v++,g+=_)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return y*2}function SA(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new At(i[0],i[1]),a=new At(i[i.length-2],i[i.length-1]),l=e.type!==Ee.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const L=(o.x+a.x)*.5,F=(a.y+o.y)*.5;i.unshift(L,F),i.push(L,F)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,f=n.width/2,m=f*f,y=n.miterLimit*n.miterLimit;let _=i[0],v=i[1],g=i[2],x=i[3],E=0,w=0,A=-(v-x),R=_-g,M=0,D=0,U=Math.sqrt(A*A+R*R);A/=U,R/=U,A*=f,R*=f;const C=n.alignment,T=(1-C)*2,I=C*2;l||(n.cap===Jr.ROUND?d+=Li(_-A*(T-I)*.5,v-R*(T-I)*.5,_-A*T,v-R*T,_+A*I,v+R*I,u,!0)+2:n.cap===Jr.SQUARE&&(d+=jp(_,v,A,R,T,I,!0,u))),u.push(_-A*T,v-R*T,_+A*I,v+R*I);for(let L=1;L<c-1;++L){_=i[(L-1)*2],v=i[(L-1)*2+1],g=i[L*2],x=i[L*2+1],E=i[(L+1)*2],w=i[(L+1)*2+1],A=-(v-x),R=_-g,U=Math.sqrt(A*A+R*R),A/=U,R/=U,A*=f,R*=f,M=-(x-w),D=g-E,U=Math.sqrt(M*M+D*D),M/=U,D/=U,M*=f,D*=f;const F=g-_,V=v-x,P=g-E,B=w-x,$=F*P+V*B,Y=V*P-B*F,z=Y<0;if(Math.abs(Y)<.001*Math.abs($)){u.push(g-A*T,x-R*T,g+A*I,x+R*I),$>=0&&(n.join===je.ROUND?d+=Li(g,x,g-A*T,x-R*T,g-M*T,x-D*T,u,!1)+4:d+=2,u.push(g-M*I,x-D*I,g+M*T,x+D*T));continue}const it=(-A+_)*(-R+x)-(-A+g)*(-R+v),xt=(-M+E)*(-D+x)-(-M+g)*(-D+w),Ct=(F*xt-P*it)/Y,q=(B*it-V*xt)/Y,wt=(Ct-g)*(Ct-g)+(q-x)*(q-x),ft=g+(Ct-g)*T,gt=x+(q-x)*T,vt=g-(Ct-g)*I,It=x-(q-x)*I,Ot=Math.min(F*F+V*V,P*P+B*B),pe=z?T:I,jt=Ot+pe*pe*m,J=wt<=jt;let ze=n.join;if(ze===je.MITER&&wt/m>y&&(ze=je.BEVEL),J)switch(ze){case je.MITER:{u.push(ft,gt,vt,It);break}case je.BEVEL:{z?u.push(ft,gt,g+A*I,x+R*I,ft,gt,g+M*I,x+D*I):u.push(g-A*T,x-R*T,vt,It,g-M*T,x-D*T,vt,It),d+=2;break}case je.ROUND:{z?(u.push(ft,gt,g+A*I,x+R*I),d+=Li(g,x,g+A*I,x+R*I,g+M*I,x+D*I,u,!0)+4,u.push(ft,gt,g+M*I,x+D*I)):(u.push(g-A*T,x-R*T,vt,It),d+=Li(g,x,g-A*T,x-R*T,g-M*T,x-D*T,u,!1)+4,u.push(g-M*T,x-D*T,vt,It));break}}else{switch(u.push(g-A*T,x-R*T,g+A*I,x+R*I),ze){case je.MITER:{z?u.push(vt,It,vt,It):u.push(ft,gt,ft,gt),d+=2;break}case je.ROUND:{z?d+=Li(g,x,g+A*I,x+R*I,g+M*I,x+D*I,u,!0)+2:d+=Li(g,x,g-A*T,x-R*T,g-M*T,x-D*T,u,!1)+2;break}}u.push(g-M*T,x-D*T,g+M*I,x+D*I),d+=2}}_=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],A=-(v-x),R=_-g,U=Math.sqrt(A*A+R*R),A/=U,R/=U,A*=f,R*=f,u.push(g-A*T,x-R*T,g+A*I,x+R*I),l||(n.cap===Jr.ROUND?d+=Li(g-A*(T-I)*.5,x-R*(T-I)*.5,g-A*T,x-R*T,g+A*I,x+R*I,u,!1)+2:n.cap===Jr.SQUARE&&(d+=jp(g,x,A,R,T,I,!1,u)));const N=t.indices,O=gs.epsilon*gs.epsilon;for(let L=p;L<d+p-2;++L)_=u[L*2],v=u[L*2+1],g=u[(L+1)*2],x=u[(L+1)*2+1],E=u[(L+2)*2],w=u[(L+2)*2+1],!(Math.abs(_*(x-w)+g*(w-v)+E*(v-x))<O)&&N.push(L,L+1,L+2)}function CA(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Ee.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,h)}function zp(r,t){r.lineStyle.native?CA(r,t):SA(r,t)}class vh{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,u=2*s-2*e,c=4*(a*a+l*l),d=4*(a*h+l*u),p=h*h+u*u,f=2*Math.sqrt(c+d+p),m=Math.sqrt(c),y=2*c*m,_=2*Math.sqrt(p),v=d/m;return(y*f+m*d*(f-_)+(4*p*c-d*d)*Math.log((2*m+v+f)/(v+_)))/(4*y)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=gs._segmentsCount(vh.curveLength(o,a,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(t-o)*d,u=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const xh={[Ee.POLY]:Yp,[Ee.CIRC]:No,[Ee.ELIP]:No,[Ee.RECT]:TA,[Ee.RREC]:wA},qp=[],Lo=[];class Do{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new Do(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 ys=new At,Kp=class gg extends If{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 Eo,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(),Lo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),qp.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new Do(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new Do(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,ys):ys.copyFrom(t),s.shape.contains(ys.x,ys.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(ys.x,ys.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],u=h.fillStyle,c=h.lineStyle;xh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const f=p.texture.baseTexture,m=this.indices.length,y=this.points.length/2;f.wrapMode=Yr.REPEAT,d===0?this.processFill(h):this.processLine(h);const _=this.points.length/2-y;_!==0&&(i&&!this._compareStyles(s,p)&&(i.end(m,y),i=null),i||(i=qp.pop()||new AA,i.begin(p,m,y),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,y,_,p.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<gg.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++yt._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Lo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Lo.pop();s||(s=new Vl,s.texArray=new ql),s.texArray.count=0,s.start=0,s.size=0,s.type=cr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=cr.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,f=d.style,m=f.texture.baseTexture;l!==!!f.native&&(l=!!f.native,h=l?cr.LINES:cr.TRIANGLES,o=null,n=p,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=Lo.pop(),s||(s=new Vl,s.texArray=new ql),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=Yr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,a=m._batchLocation,this.addColors(e,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}yt._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Yp.triangulate(t,this):xh[t.type].triangulate(t,this)}processLine(t){zp(t,this);for(let e=0;e<t.holes.length;e++)zp(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];xh[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=Mt.shared.setValue(e).toLittleEndianNumber(),a=Mt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const p=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=p}a++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,u=l.height/n.height;let c=l.x/l.width,d=l.y/l.height,p=Math.floor(t[i]+o),f=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)p=Math.min(p,Math.floor(t[m]+o)),f=Math.min(f,Math.floor(t[m+1]+o));c-=p,d-=f;for(let m=i;m<a;m+=2)t[m]=(t[m]+c)*h,t[m+1]=(t[m+1]+d)*u}};Kp.BATCHABLE_SIZE=100;let IA=Kp;class Bo{constructor(){this.color=16777215,this.alpha=1,this.texture=nt.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Bo;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=nt.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class bh extends Bo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Jr.BUTT,this.join=je.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=Jr.BUTT,this.join=je.MITER,this.miterLimit=10}}const Eh={},Th=class Zo extends ir{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 Bo,this._lineStyle=new bh,this._matrix=null,this._holeMode=!1,this.state=xr.for2d(),this._geometry=t||new IA,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Mt(16777215),this.blendMode=pt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Zo(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:nt.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Jr.BUTT,join:je.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 Ei,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Ei,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),vh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),_h.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=Wp.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=a;this.arc(l,h,u,c,d,p)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=io:o&&s<=n&&(s+=io),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return Wp.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:nt.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:nt.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new _t(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new ao(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new no(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new oo(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Ei(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Ee.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Mt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,Mt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Eh[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new Bt,default:rr.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Eh[i]=new br(a,o)}e=Eh[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,Zo._TEMP_POINT),this._geometry.containsPoint(Zo._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,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const p=h[d],f=h[d+1];u[c++]=i*p+n*f+a,u[c++]=o*f+s*p+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Th.curves=gs,Th._TEMP_POINT=new At;let hn=Th;class RA{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 At,Zp=new Ei,Qp=class yg extends ir{constructor(t,e,i,s=cr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||xr.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=Q.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===cr.TRIANGLES&&e.length<yg.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],f=e[d*2+1];c[d*2]=n*p+a*f+h,c[d*2+1]=o*p+l*f+u}if(this._roundPixels){const d=Q.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new RA(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=Zp.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,u=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[u],i[5]=e[u+1],Zp.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}};Qp.BATCHABLE_SIZE=100;let Jp=Qp;class MA extends Kr{constructor(t,e,i){super();const s=new Jt(t),n=new Jt(e,!0),o=new Jt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,dt.FLOAT).addAttribute("aTextureCoord",n,2,!1,dt.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var OA=`varying vec2 vTextureCoord;
911
+ `;let xs=null;class jp{constructor(){xs||(xs=URL.createObjectURL(new Blob([Ww],{type:"application/javascript"}))),this.worker=new Worker(xs)}}jp.revokeObjectURL=function(){xs&&(URL.revokeObjectURL(xs),xs=null)};let Wp=0,_h;class qw{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 yh;e.addEventListener("message",i=>{e.terminate(),yh.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){_h===void 0&&(_h=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<_h&&(this._createdWorkers++,t=new jp().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Wp]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Wp++,id:i})}}const qp=new qw;function un(r,t,e){r.resource.internal=!0;const i=new ut(r),s=()=>{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."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const Kw=[".jpeg",".jpg",".png",".webp",".avif"],Zw=["image/jpeg","image/png","image/webp","image/avif"];async function Qw(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 Mo={name:"loadTextures",extension:{type:Z.LoadParser,priority:or.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return _s(r,Zw)||ti(r,Kw)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await qp.isImageBitmapSupported()?s=await qp.loadImageBitmap(r):s=await Qw(r):s=await new Promise((l,h)=>{const u=new Image;u.crossOrigin=this.config.crossOrigin,u.src=r,u.complete?l(u):(u.onload=()=>l(u),u.onerror=c=>h(c))});const n={...t.data};n.resolution??(n.resolution=Nr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new _t(s,n);return o.resource.src=r,un(o,e,r)},unload(r){r.destroy(!0)}};ht.add(Mo);const Jw=".svg",tA="image/svg+xml",eA={extension:{type:Z.LoadParser,priority:or.High},name:"loadSVG",test(r){return _s(r,tA)||ti(r,Jw)},async testParse(r){return hh.test(r)},async parse(r,t,e){var n;const i=new hh(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new _t(i,{resolution:Nr(r),...t==null?void 0:t.data});return s.resource.src=t.src,un(s,e,t.src)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload:Mo.unload};ht.add(eA);const rA=[".mp4",".m4v",".webm",".ogv"],iA=["video/mp4","video/webm","video/ogg"],sA={name:"loadVideo",extension:{type:Z.LoadParser,priority:or.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return _s(r,iA)||ti(r,rA)},async load(r,t,e){var o;let i;const s=await(await tt.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new Lp(n,a);await l.load();const h=new _t(l,{alphaMode:await uE(),resolution:Nr(r),...t==null?void 0:t.data});h.resource.src=r,i=un(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};ht.add(sA);class nA{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,name:i,src:s,srcs:n}=t;return nr(e||i||s||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>(a==null?void 0:a.src)??(a==null?void 0:a.srcs)??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(wt("7.2.0",`Assets.add now uses an object instead of individual parameters.
912
+ Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},nr(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=nr(h||u).map(y=>typeof y=="string"?Mw(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const _=[];f.forEach(y=>{y.forEach(v=>{let g={};if(typeof v!="object"){g.src=v;for(let x=0;x<this._parsers.length;x++){const E=this._parsers[x];if(E.test(v)){g=E.parse(v);break}}}else c=v.data??c,d=v.format??d,p=v.loadParser??p,g={...g,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this.buildResolvedAsset(g,{aliases:m,data:c,format:d,loadParser:p}),_.push(g)})}),m.forEach(y=>{this._assetMap[y]=_})})}resolveBundle(t){const e=Ro(t);t=nr(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Ro(t);t=nr(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const u=n.filter(c=>c[l]?c[l]===h:!1);u.length&&(n=u)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=ge.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??ge.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class oA{constructor(){this._detections=[],this._initialized=!1,this.resolver=new nA,this.loader=new Ow,this.cache=Bi,this._backgroundLoader=new Rw(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Ro(t),s=nr(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},u=o.map(c=>{const d=s[c];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(p=>{n[c]=p})});return await Promise.all(u),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return 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),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],u=[a.src];a.alias&&u.push(...a.alias),o[s[l]]=h,Bi.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=nr(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=nr(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{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,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Mo.config.preferWorkers}set preferWorkers(t){wt("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 Po=new oA;ht.handleByList(Z.LoadParser,Po.loader.parsers).handleByList(Z.ResolveParser,Po.resolver.parsers).handleByList(Z.CacheParser,Po.cache.parsers).handleByList(Z.DetectionParser,Po.detections);const aA={extension:Z.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof ut),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};ht.add(aA);async function Kp(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 lA={extension:{type:Z.DetectionParser,priority:1},test:async()=>Kp("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};ht.add(lA);const hA={extension:{type:Z.DetectionParser,priority:0},test:async()=>Kp("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};ht.add(hA);const Zp=["png","jpg","jpeg"],uA={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(uA);const cA="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function vh(r){return cA?!1:document.createElement("video").canPlayType(r)!==""}const dA={extension:{type:Z.DetectionParser,priority:0},test:async()=>vh("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};ht.add(dA);const fA={extension:{type:Z.DetectionParser,priority:0},test:async()=>vh("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};ht.add(fA);const pA={extension:{type:Z.DetectionParser,priority:0},test:async()=>vh("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};ht.add(pA);const mA={extension:Z.ResolveParser,test:Mo.test,parse:r=>{var t;return{resolution:parseFloat(((t=tt.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:ge.extname(r).slice(1),src:r}}};ht.add(mA);var we=(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))(we||{});const Oo={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Tr,bs;function Qp(){bs={bptc:Tr.getExtension("EXT_texture_compression_bptc"),astc:Tr.getExtension("WEBGL_compressed_texture_astc"),etc:Tr.getExtension("WEBGL_compressed_texture_etc"),s3tc:Tr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Tr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Tr.getExtension("WEBGL_compressed_texture_pvrtc")||Tr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Tr.getExtension("WEBGL_compressed_texture_etc1"),atc:Tr.getExtension("WEBGL_compressed_texture_atc")}}const gA={extension:{type:Z.DetectionParser,priority:2},test:async()=>{const r=tt.ADAPTER.createCanvas().getContext("webgl");return r?(Tr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{bs||Qp();const t=[];for(const e in bs)bs[e]&&t.push(e);return[...t,...r]},remove:async r=>(bs||Qp(),r.filter(t=>!(t in bs)))};ht.add(gA);class yA extends no{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new Ul(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new Ul(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Fi extends yA{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=Fi._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Fi._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:u}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,u)}return!0}onBlobLoaded(){this._levelBuffers=Fi._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,u=o,c=a,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Oo[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?u:d,levelHeight:i>1?c:p,levelBuffer:new Uint8Array(t.buffer,h,f)},h+=f,u=u>>1||1,c=c>>1||1,d=u+s-1&~(s-1),p=c+n-1&~(n-1),f=d*p*Oo[e];return l}}const xh=4,No=124,_A=32,Jp=20,vA=542327876,Do={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},xA={FOURCC:2},Lo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},bA=1,EA=2,TA=4,wA=64,AA=512,SA=131072,CA=827611204,IA=861165636,RA=894720068,MA=808540228,PA=4,OA={[CA]:we.COMPRESSED_RGBA_S3TC_DXT1_EXT,[IA]:we.COMPRESSED_RGBA_S3TC_DXT3_EXT,[RA]:we.COMPRESSED_RGBA_S3TC_DXT5_EXT},NA={70:we.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:we.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:we.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:we.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:we.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:we.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:we.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:we.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:we.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:we.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:we.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:we.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:we.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function DA(r){const t=new Uint32Array(r);if(t[0]!==vA)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,No/Uint32Array.BYTES_PER_ELEMENT),i=e[Do.HEIGHT],s=e[Do.WIDTH],n=e[Do.MIPMAP_COUNT],o=new Uint32Array(r,Do.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,_A/Uint32Array.BYTES_PER_ELEMENT),a=o[bA];if(a&TA){const l=o[xA.FOURCC];if(l!==MA){const v=OA[l],g=xh+No,x=new Uint8Array(r,g);return[new Fi(x,{format:v,width:s,height:i,levels:n})]}const h=xh+No,u=new Uint32Array(t.buffer,h,Jp/Uint32Array.BYTES_PER_ELEMENT),c=u[Lo.DXGI_FORMAT],d=u[Lo.RESOURCE_DIMENSION],p=u[Lo.MISC_FLAG],f=u[Lo.ARRAY_SIZE],m=NA[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===PA)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const _=new Array,y=xh+No+Jp;if(f===1)_.push(new Uint8Array(r,y));else{const v=Oo[m];let g=0,x=s,E=i;for(let S=0;S<n;S++){const R=Math.max(1,x+3&-4),P=Math.max(1,E+3&-4),F=R*P*v;g+=F,x=x>>>1,E=E>>>1}let M=y;for(let S=0;S<f;S++)_.push(new Uint8Array(r,M,g)),M+=g}return _.map(v=>new Fi(v,{format:m,width:s,height:i,levels:n}))}throw a&wA?new Error("DDSParser does not support uncompressed texture data."):a&AA?new Error("DDSParser does not supported YUV uncompressed texture data."):a&SA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&EA?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 tm=[171,75,84,88,32,49,49,187,13,10,26,10],LA=67305985,ar={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},bh=64,em={[ft.UNSIGNED_BYTE]:1,[ft.UNSIGNED_SHORT]:2,[ft.INT]:4,[ft.UNSIGNED_INT]:4,[ft.FLOAT]:4,[ft.HALF_FLOAT]:8},BA={[z.RGBA]:4,[z.RGB]:3,[z.RG]:2,[z.RED]:1,[z.LUMINANCE]:1,[z.LUMINANCE_ALPHA]:2,[z.ALPHA]:1},FA={[ft.UNSIGNED_SHORT_4_4_4_4]:2,[ft.UNSIGNED_SHORT_5_5_5_1]:2,[ft.UNSIGNED_SHORT_5_6_5]:2};function UA(r,t,e=!1){const i=new DataView(t);if(!kA(r,i))return null;const s=i.getUint32(ar.ENDIANNESS,!0)===LA,n=i.getUint32(ar.GL_TYPE,s),o=i.getUint32(ar.GL_FORMAT,s),a=i.getUint32(ar.GL_INTERNAL_FORMAT,s),l=i.getUint32(ar.PIXEL_WIDTH,s),h=i.getUint32(ar.PIXEL_HEIGHT,s)||1,u=i.getUint32(ar.PIXEL_DEPTH,s)||1,c=i.getUint32(ar.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(ar.NUMBER_OF_FACES,s),p=i.getUint32(ar.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(ar.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||u!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(c!==1)throw new Error("WebGL does not support array textures");const m=4,_=4,y=l+3&-4,v=h+3&-4,g=new Array(c);let x=l*h;n===0&&(x=y*v);let E;if(n!==0?em[n]?E=em[n]*BA[o]:E=FA[n]:E=Oo[a],E===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const M=e?HA(i,f,s):null;let S=x*E,R=l,P=h,F=y,k=v,I=bh+f;for(let A=0;A<p;A++){const T=i.getUint32(I,s);let C=I+4;for(let L=0;L<c;L++){let N=g[L];N||(N=g[L]=new Array(p)),N[A]={levelID:A,levelWidth:p>1||n!==0?R:F,levelHeight:p>1||n!==0?P:k,levelBuffer:new Uint8Array(t,C,S)},C+=S}I+=T+4,I=I%4!==0?I+4-I%4:I,R=R>>1||1,P=P>>1||1,F=R+m-1&-4,k=P+_-1&-4,S=F*k*E}return n!==0?{uncompressed:g.map(A=>{let T=A[0].levelBuffer,C=!1;return n===ft.FLOAT?T=new Float32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4):n===ft.UNSIGNED_INT?(C=!0,T=new Uint32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)):n===ft.INT&&(C=!0,T=new Int32Array(A[0].levelBuffer.buffer,A[0].levelBuffer.byteOffset,A[0].levelBuffer.byteLength/4)),{resource:new no(T,{width:A[0].levelWidth,height:A[0].levelHeight}),type:n,format:C?GA(o):o}}),kvData:M}:{compressed:g.map(A=>new Fi(null,{format:a,width:l,height:h,levels:p,levelBuffers:A})),kvData:M}}function kA(r,t){for(let e=0;e<tm.length;e++)if(t.getUint8(e)!==tm[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function GA(r){switch(r){case z.RGBA:return z.RGBA_INTEGER;case z.RGB:return z.RGB_INTEGER;case z.RG:return z.RG_INTEGER;case z.RED:return z.RED_INTEGER;default:return r}}function HA(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(bh+s,e),o=bh+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),u=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,u),s+=4+n+a}return i}const $A={extension:{type:Z.LoadParser,priority:or.High},name:"loadDDS",test(r){return ti(r,".dds")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),s=DA(i).map(n=>{const o=new _t(n,{mipmap:fr.OFF,alphaMode:He.NO_PREMULTIPLIED_ALPHA,resolution:Nr(r),...t.data});return un(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};ht.add($A);const XA={extension:{type:Z.LoadParser,priority:or.High},name:"loadKTX",test(r){return ti(r,".ktx")},async load(r,t,e){const i=await(await tt.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=UA(r,i),a=s??n,l={mipmap:fr.OFF,alphaMode:He.NO_PREMULTIPLIED_ALPHA,resolution:Nr(r),...t.data},h=a.map(u=>{a===n&&Object.assign(l,{type:u.type,format:u.format});const c=u.resource??u,d=new _t(c,l);return d.ktxKeyValueData=o,un(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(XA);const VA=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],zA={extension:Z.ResolveParser,test:r=>{const t=ge.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(VA.includes(n))return{resolution:parseFloat(((i=tt.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=tt.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};ht.add(zA);const Bo=new xt,YA=4,rm=class _n{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&_n._flipY(i,s,n),a&&_n._unpremultiplyAlpha(i);const l=new SE(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&_n._flipY(i,s,n),a&&_n._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Oi?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Bo.width=e.width,Bo.height=e.height,e=Bo)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===z.RGBA,!l){i.renderTexture.bind(a);const p=a.framebuffer.glFramebuffers[i.CONTEXT_UID];p.blitFramebuffer&&i.framebuffer.bind(p.blitFramebuffer)}}else s=i.resolution,e||(e=Bo,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const u=Math.max(Math.round(e.width*s),1),c=Math.max(Math.round(e.height*s),1),d=new Uint8Array(YA*u*c);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),u,c,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:u,height:c,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};rm.extension={name:"extract",type:Z.RendererSystem};let jA=rm;ht.add(jA);const Fo={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Te.CIRC){const f=r.shape;e=f.x,i=f.y,o=a=f.radius,s=n=0}else if(r.type===Te.ELIP){const f=r.shape;e=f.x,i=f.y,o=f.width,a=f.height,s=n=0}else{const f=r.shape,m=f.width/2,_=f.height/2;e=f.x+m,i=f.y+_,o=a=Math.max(0,Math.min(f.radius,Math.min(m,_))),s=m-o,n=_-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let u=0,c=l*4+(s?2:0)+2,d=c,p=h;{const f=s+o,m=n,_=e+f,y=e-f,v=i+m;if(t[u++]=_,t[u++]=v,t[--c]=v,t[--c]=y,n){const g=i-m;t[d++]=y,t[d++]=g,t[--p]=g,t[--p]=_}}for(let f=1;f<l;f++){const m=Math.PI/2*(f/l),_=s+Math.cos(m)*o,y=n+Math.sin(m)*a,v=e+_,g=e-_,x=i+y,E=i-y;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=E,t[--p]=E,t[--p]=v}{const f=s,m=n+a,_=e+f,y=e-f,v=i+m,g=i-m;t[u++]=_,t[u++]=v,t[--p]=g,t[--p]=_,s&&(t[u++]=y,t[u++]=v,t[--p]=g,t[--p]=y)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Te.RREC){const u=r.shape;a=u.x,l=u.y}else{const u=r.shape;a=u.x+u.width/2,l=u.y+u.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let u=2;u<e.length;u+=2)i.push(e[u],e[u+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function im(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const sm={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){im(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];im(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=Qv(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},WA={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},qA={build(r){Fo.build(r)},triangulate(r,t){Fo.triangulate(r,t)}};var We=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(We||{}),ei=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(ei||{});const Es={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 nm{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,u=s-e,c=i-t,d=Math.abs(l*c-h*u);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const p=l*l+h*h,f=u*u+c*c,m=l*u+h*c,_=n*Math.sqrt(p)/d,y=n*Math.sqrt(f)/d,v=_*m/p,g=y*m/f,x=_*c+y*h,E=_*u+y*l,M=h*(y+v),S=l*(y+v),R=c*(_+g),P=u*(_+g),F=Math.atan2(S-E,M-x),k=Math.atan2(P-E,R-x);return{cx:x+t,cy:E+e,radius:n,startAngle:F,endAngle:k,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=Es._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/ao)*40),d=u/(c*2),p=d*2,f=Math.cos(d),m=Math.sin(d),_=c-1,y=_%1/_;for(let v=0;v<=_;++v){const g=v+y*v,x=d+o+p*g,E=Math.cos(x),M=-Math.sin(x);h.push((f*E+m*M)*n+i,(f*-M+m*E)*n+s)}}}class KA{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 Eh{static curveLength(t,e,i,s,n,o,a,l){let h=0,u=0,c=0,d=0,p=0,f=0,m=0,_=0,y=0,v=0,g=0,x=t,E=e;for(let M=1;M<=10;++M)u=M/10,c=u*u,d=c*u,p=1-u,f=p*p,m=f*p,_=m*t+3*f*u*i+3*p*c*n+d*a,y=m*e+3*f*u*s+3*p*c*o+d*l,v=x-_,g=E-y,x=_,E=y,h+=Math.sqrt(v*v+g*g);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const u=Es._segmentsCount(Eh.curveLength(l,h,t,e,i,s,n,o));let c=0,d=0,p=0,f=0,m=0;a.push(l,h);for(let _=1,y=0;_<=u;++_)y=_/u,c=1-y,d=c*c,p=d*c,f=y*y,m=f*y,a.push(p*l+3*d*y*t+3*c*f*i+m*n,p*h+3*d*y*e+3*c*f*s+m*o)}}function om(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,u=r+e*n,c=t+i*n;let d,p;o?(d=i,p=-e):(d=-i,p=e);const f=l+d,m=h+p,_=u+d,y=c+p;return a.push(f,m,_,y),2}function Ui(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let u=Math.atan2(l,h),c=Math.atan2(s-r,n-t);a&&u<c?u+=Math.PI*2:!a&&u>c&&(c+=Math.PI*2);let d=u;const p=c-u,f=Math.abs(p),m=Math.sqrt(l*l+h*h),_=(15*f*Math.sqrt(m)/Math.PI>>0)+1,y=p/_;if(d+=y,a){o.push(r,t,e,i);for(let v=1,g=d;v<_;v++,g+=y)o.push(r,t,r+Math.sin(g)*m,t+Math.cos(g)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,g=d;v<_;v++,g+=y)o.push(r+Math.sin(g)*m,t+Math.cos(g)*m,r,t);o.push(s,n,r,t)}return _*2}function ZA(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new It(i[0],i[1]),a=new It(i[i.length-2],i[i.length-1]),l=e.type!==Te.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const N=(o.x+a.x)*.5,B=(a.y+o.y)*.5;i.unshift(N,B),i.push(N,B)}const u=t.points,c=i.length/2;let d=i.length;const p=u.length/2,f=n.width/2,m=f*f,_=n.miterLimit*n.miterLimit;let y=i[0],v=i[1],g=i[2],x=i[3],E=0,M=0,S=-(v-x),R=y-g,P=0,F=0,k=Math.sqrt(S*S+R*R);S/=k,R/=k,S*=f,R*=f;const I=n.alignment,A=(1-I)*2,T=I*2;l||(n.cap===ei.ROUND?d+=Ui(y-S*(A-T)*.5,v-R*(A-T)*.5,y-S*A,v-R*A,y+S*T,v+R*T,u,!0)+2:n.cap===ei.SQUARE&&(d+=om(y,v,S,R,A,T,!0,u))),u.push(y-S*A,v-R*A,y+S*T,v+R*T);for(let N=1;N<c-1;++N){y=i[(N-1)*2],v=i[(N-1)*2+1],g=i[N*2],x=i[N*2+1],E=i[(N+1)*2],M=i[(N+1)*2+1],S=-(v-x),R=y-g,k=Math.sqrt(S*S+R*R),S/=k,R/=k,S*=f,R*=f,P=-(x-M),F=g-E,k=Math.sqrt(P*P+F*F),P/=k,F/=k,P*=f,F*=f;const B=g-y,X=v-x,O=g-E,D=M-x,U=B*O+X*D,V=X*O-D*B,j=V<0;if(Math.abs(V)<.001*Math.abs(U)){u.push(g-S*A,x-R*A,g+S*T,x+R*T),U>=0&&(n.join===We.ROUND?d+=Ui(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+4:d+=2,u.push(g-P*T,x-F*T,g+P*A,x+F*A));continue}const Q=(-S+y)*(-R+x)-(-S+g)*(-R+v),yt=(-P+E)*(-F+x)-(-P+g)*(-F+M),Tt=(B*yt-O*Q)/V,Y=(D*Q-X*yt)/V,bt=(Tt-g)*(Tt-g)+(Y-x)*(Y-x),dt=g+(Tt-g)*A,pt=x+(Y-x)*A,vt=g-(Tt-g)*T,Mt=x-(Y-x)*T,Nt=Math.min(B*B+X*X,O*O+D*D),_e=j?A:T,Wt=Nt+_e*_e*m,et=bt<=Wt;let qe=n.join;if(qe===We.MITER&&bt/m>_&&(qe=We.BEVEL),et)switch(qe){case We.MITER:{u.push(dt,pt,vt,Mt);break}case We.BEVEL:{j?u.push(dt,pt,g+S*T,x+R*T,dt,pt,g+P*T,x+F*T):u.push(g-S*A,x-R*A,vt,Mt,g-P*A,x-F*A,vt,Mt),d+=2;break}case We.ROUND:{j?(u.push(dt,pt,g+S*T,x+R*T),d+=Ui(g,x,g+S*T,x+R*T,g+P*T,x+F*T,u,!0)+4,u.push(dt,pt,g+P*T,x+F*T)):(u.push(g-S*A,x-R*A,vt,Mt),d+=Ui(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+4,u.push(g-P*A,x-F*A,vt,Mt));break}}else{switch(u.push(g-S*A,x-R*A,g+S*T,x+R*T),qe){case We.MITER:{j?u.push(vt,Mt,vt,Mt):u.push(dt,pt,dt,pt),d+=2;break}case We.ROUND:{j?d+=Ui(g,x,g+S*T,x+R*T,g+P*T,x+F*T,u,!0)+2:d+=Ui(g,x,g-S*A,x-R*A,g-P*A,x-F*A,u,!1)+2;break}}u.push(g-P*A,x-F*A,g+P*T,x+F*T),d+=2}}y=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],S=-(v-x),R=y-g,k=Math.sqrt(S*S+R*R),S/=k,R/=k,S*=f,R*=f,u.push(g-S*A,x-R*A,g+S*T,x+R*T),l||(n.cap===ei.ROUND?d+=Ui(g-S*(A-T)*.5,x-R*(A-T)*.5,g-S*A,x-R*A,g+S*T,x+R*T,u,!1)+2:n.cap===ei.SQUARE&&(d+=om(g,x,S,R,A,T,!1,u)));const C=t.indices,L=Es.epsilon*Es.epsilon;for(let N=p;N<d+p-2;++N)y=u[N*2],v=u[N*2+1],g=u[(N+1)*2],x=u[(N+1)*2+1],E=u[(N+2)*2],M=u[(N+2)*2+1],!(Math.abs(y*(x-M)+g*(M-v)+E*(v-x))<L)&&C.push(N,N+1,N+2)}function QA(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Te.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let u=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(u,u+1),u++;n&&a.push(u,h)}function am(r,t){r.lineStyle.native?QA(r,t):ZA(r,t)}class Th{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,u=2*s-2*e,c=4*(a*a+l*l),d=4*(a*h+l*u),p=h*h+u*u,f=2*Math.sqrt(c+d+p),m=Math.sqrt(c),_=2*c*m,y=2*Math.sqrt(p),v=d/m;return(_*f+m*d*(f-y)+(4*p*c-d*d)*Math.log((2*m+v+f)/(v+y)))/(4*_)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Es._segmentsCount(Th.curveLength(o,a,t,e,i,s));let h=0,u=0;for(let c=1;c<=l;++c){const d=c/l;h=o+(t-o)*d,u=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,u+(e+(s-e)*d-u)*d)}}}const wh={[Te.POLY]:sm,[Te.CIRC]:Fo,[Te.ELIP]:Fo,[Te.RECT]:WA,[Te.RREC]:qA},lm=[],Uo=[];class ko{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new ko(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 Ts=new It,hm=class Ng extends Hf{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 So,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(),Uo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),lm.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new ko(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new ko(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Ts):Ts.copyFrom(t),s.shape.contains(Ts.x,Ts.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Ts.x,Ts.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],u=h.fillStyle,c=h.lineStyle;wh[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(u.visible||c.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const p=d===0?u:c;if(!p.visible)continue;const f=p.texture.baseTexture,m=this.indices.length,_=this.points.length/2;f.wrapMode=jr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-_;y!==0&&(i&&!this._compareStyles(s,p)&&(i.end(m,_),i=null),i||(i=lm.pop()||new KA,i.begin(p,m,_),this.batches.push(i),s=p),this.addUvs(this.points,t,p.texture,_,y,p.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Ng.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++_t._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),Uo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Uo.pop();s||(s=new jl,s.texArray=new Jl),s.texArray.count=0,s.start=0,s.size=0,s.type=dr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=dr.TRIANGLES,u=0;this.drawCalls.push(s);for(let c=0;c<this.batches.length;c++){const d=this.batches[c],p=8,f=d.style,m=f.texture.baseTexture;l!==!!f.native&&(l=!!f.native,h=l?dr.LINES:dr.TRIANGLES,o=null,n=p,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=Uo.pop(),s||(s=new jl,s.texArray=new Jl),this.drawCalls.push(s)),s.start=u,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=jr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,u+=d.size,a=m._batchLocation,this.addColors(e,f.color,f.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}_t._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?sm.triangulate(t,this):wh[t.type].triangulate(t,this)}processLine(t){am(t,this);for(let e=0;e<t.holes.length;e++)am(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];wh[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=Ot.shared.setValue(e).toLittleEndianNumber(),a=Ot.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let c=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const p=o.a*c+o.c*d+o.tx;d=o.b*c+o.d*d+o.ty,c=p}a++,e.push(c/h.width,d/h.height)}const u=i.baseTexture;(h.width<u.width||h.height<u.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,u=l.height/n.height;let c=l.x/l.width,d=l.y/l.height,p=Math.floor(t[i]+o),f=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)p=Math.min(p,Math.floor(t[m]+o)),f=Math.min(f,Math.floor(t[m+1]+o));c-=p,d-=f;for(let m=i;m<a;m+=2)t[m]=(t[m]+c)*h,t[m+1]=(t[m+1]+d)*u}};hm.BATCHABLE_SIZE=100;let JA=hm;class Go{constructor(){this.color=16777215,this.alpha=1,this.texture=ut.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Go;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=ut.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class Ah extends Go{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=ei.BUTT,this.join=We.MITER,this.miterLimit=10}clone(){const t=new Ah;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=ei.BUTT,this.join=We.MITER,this.miterLimit=10}}const Sh={},Ch=class ea extends ir{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 Go,this._lineStyle=new Ah,this._matrix=null,this._holeMode=!1,this.state=br.for2d(),this._geometry=t||new JA,this._geometry.refCount++,this._transformID=-1,this._tintColor=new Ot(16777215),this.blendMode=gt.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new ea(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:ut.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:ei.BUTT,join:We.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 Si,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Si,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),Th.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),Eh.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=nm.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:u,startAngle:c,endAngle:d,anticlockwise:p}=a;this.arc(l,h,u,c,d,p)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=ao:o&&s<=n&&(s+=ao),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let u=this.currentPath?this.currentPath.points:null;if(u){const c=Math.abs(u[u.length-2]-a),d=Math.abs(u[u.length-1]-l);c<h&&d<h||u.push(a,l)}else this.moveTo(a,l),u=this.currentPath.points;return nm.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:ut.WHITE,color:t,alpha:e})}normalizeColor(t){const e=Ot.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:ut.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new xt(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new co(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new ho(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new uo(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Si(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Te.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),u={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:Ot.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=u}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,Ot.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!Sh[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new kt,default:rr.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;Sh[i]=new Er(a,o)}e=Sh[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,ea._TEMP_POINT),this._geometry.containsPoint(ea._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=Ot.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,u=this.vertexData;let c=0;for(let d=0;d<h.length;d+=2){const p=h[d],f=h[d+1];u[c++]=i*p+n*f+a,u[c++]=o*f+s*p+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};Ch.curves=Es,Ch._TEMP_POINT=new It;let cn=Ch;class tS{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 Ih=new It,um=new Si,cm=class Dg extends ir{constructor(t,e,i,s=dr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||br.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=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===dr.TRIANGLES&&e.length<Dg.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,u=s.ty,c=this.vertexData;for(let d=0;d<c.length/2;d++){const p=e[d*2],f=e[d*2+1];c[d*2]=n*p+a*f+h,c[d*2+1]=o*p+l*f+u}if(this._roundPixels){const d=tt.RESOLUTION;for(let p=0;p<c.length;++p)c[p]=Math.round(c[p]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new tS(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,Ih);const e=this.geometry.getBuffer("aVertexPosition").data,i=um.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,u=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[u],i[5]=e[u+1],um.contains(Ih.x,Ih.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}};cm.BATCHABLE_SIZE=100;let dm=cm;class eS extends Qr{constructor(t,e,i){super();const s=new te(t),n=new te(e,!0),o=new te(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,ft.FLOAT).addAttribute("aTextureCoord",n,2,!1,ft.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var rS=`varying vec2 vTextureCoord;
913
913
  uniform vec4 uColor;
914
914
 
915
915
  uniform sampler2D uSampler;
@@ -918,7 +918,7 @@ void main(void)
918
918
  {
919
919
  gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
920
920
  }
921
- `,PA=`attribute vec2 aVertexPosition;
921
+ `,iS=`attribute vec2 aVertexPosition;
922
922
  attribute vec2 aTextureCoord;
923
923
 
924
924
  uniform mat3 projectionMatrix;
@@ -933,7 +933,7 @@ void main(void)
933
933
 
934
934
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
935
935
  }
936
- `;class tm extends br{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Bt.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||Nr.from(PA,OA),i),this._colorDirty=!1,this.uvMatrix=new qf(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 em{constructor(t,e,i){this.geometry=new Kr,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||dt.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new Jt(Jb(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 s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new 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===dt.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===dt.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===dt.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===dt.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var NA=`varying vec2 vTextureCoord;
936
+ `;class fm extends Er{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||Lr.from(iS,rS),i),this._colorDirty=!1,this.uvMatrix=new lp(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new Ot(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;Ot.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class pm{constructor(t,e,i){this.geometry=new Qr,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||ft.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new te(wE(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 te(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new te(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===ft.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===ft.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===ft.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===ft.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var sS=`varying vec2 vTextureCoord;
937
937
  varying vec4 vColor;
938
938
 
939
939
  uniform sampler2D uSampler;
@@ -941,7 +941,7 @@ uniform sampler2D uSampler;
941
941
  void main(void){
942
942
  vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
943
943
  gl_FragColor = color;
944
- }`,LA=`attribute vec2 aVertexPosition;
944
+ }`,nS=`attribute vec2 aVertexPosition;
945
945
  attribute vec2 aTextureCoord;
946
946
  attribute vec4 aColor;
947
947
 
@@ -966,8 +966,8 @@ void main(void){
966
966
  vTextureCoord = aTextureCoord;
967
967
  vColor = aColor * uColor;
968
968
  }
969
- `;class rm extends fo{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Bt,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:dt.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=br.from(LA,NA,{}),this.state=xr.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=yf(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=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 p=0,f=0;p<o;p+=s,f+=1){let m=o-p;m>s&&(m=s),f>=a.length&&a.push(this._generateOneMoreBuffer(t));const y=a[f];y.uploadDynamic(e,p,m);const _=t._bufferUpdateIDs[f]||0;d=d||y._updateID<_,d&&(y._updateID=t._updateID,y.uploadStatic(e,p,m)),n.geometry.bind(y.geometry),u.drawElements(u.TRIANGLES,m*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new em(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new em(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],p=d._texture,f=d.scale.x,m=d.scale.y,y=p.trim,_=p.orig;y?(l=y.x-d.anchor.x*_.width,a=l+y.width,u=y.y-d.anchor.y*_.height,h=u+y.height):(a=_.width*(1-d.anchor.x),l=_.width*-d.anchor.x,h=_.height*(1-d.anchor.y),u=_.height*-d.anchor.y),s[o]=l*f,s[o+1]=u*m,s[o+n]=a*f,s[o+n+1]=u*m,s[o+n*2]=a*f,s[o+n*2+1]=h*m,s[o+n*3]=l*f,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=Mt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}rm.extension={name:"particle",type:j.RendererPlugin},st.add(rm);var Fo=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Fo||{});const Uo={willReadFrequently:!0},Tr=class at{static get experimentalLetterSpacingSupported(){let t=at._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.ADAPTER.getCanvasRenderingContext2D().prototype;t=at._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=at._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=at.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Uo);a.font=n;const l=(i?at.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const m=at._measureText(l[f],e.letterSpacing,a);h[f]=m,u=Math.max(u,m)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let p=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new at(t,e,c,p,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;at.experimentalLetterSpacingSupported&&(at.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(at.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=at._canvas){const s=i.getContext("2d",Uo);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=at.collapseSpaces(u),d=at.collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+h,m=at.tokenize(t);for(let y=0;y<m.length;y++){let _=m[y];if(at.isNewline(_)){if(!d){a+=at.addLine(o),p=!c,o="",n=0;continue}_=" "}if(c){const g=at.isBreakingSpace(_),x=at.isBreakingSpace(o[o.length-1]);if(g&&x)continue}const v=at.getFromCache(_,h,l,s);if(v>f)if(o!==""&&(a+=at.addLine(o),o="",n=0),at.canBreakWords(_,e.breakWords)){const g=at.wordWrapSplit(_);for(let x=0;x<g.length;x++){let E=g[x],w=E,A=1;for(;g[x+A];){const M=g[x+A];if(!at.canBreakChars(w,M,_,x,e.breakWords))E+=M;else break;w=M,A++}x+=A-1;const R=at.getFromCache(E,h,l,s);R+n>f&&(a+=at.addLine(o),p=!1,o="",n=0),o+=E,n+=R}}else{o.length>0&&(a+=at.addLine(o),o="",n=0);const g=y===m.length-1;a+=at.addLine(_,!g),p=!1,o="",n=0}else v+n>f&&(p=!1,a+=at.addLine(o),o="",n=0),(o.length>0||!at.isBreakingSpace(_)||p)&&(o+=_,n+=v)}return a+=at.addLine(o,!1),a}static addLine(t,e=!0){return t=at.trimRight(t),t=e?`${t}
970
- `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=at._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!at.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:at._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:at._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(at.isBreakingSpace(n,o)||at.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return at.graphemeSegmenter(t)}static measureFont(t){if(at._fonts[t])return at._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=at._canvas,s=at._context;s.font=t;const n=at.METRICS_STRING+at.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(at.BASELINE_SYMBOL).width);const l=Math.ceil(at.HEIGHT_MULTIPLIER*a);if(a=a*at.BASELINE_MULTIPLIER|0,o===0||l===0)return at._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,u=h.length,c=o*4;let d=0,p=0,f=!1;for(d=0;d<a;++d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p+=c;else break}for(e.ascent=a-d,p=u-c,f=!1,d=l;d>a;--d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,at._fonts[t]=e,e}static clearMetrics(t=""){t?delete at._fonts[t]:at._fonts={}}static get _canvas(){var t;if(!at.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Uo))!=null&&t.measureText)return at.__canvas=i,i;e=Q.ADAPTER.createCanvas()}catch{e=Q.ADAPTER.createCanvas()}e.width=e.height=10,at.__canvas=e}return at.__canvas}static get _context(){return at.__context||(at.__context=at._canvas.getContext("2d",Uo)),at.__context}};Tr.METRICS_STRING="|ÉqÅ",Tr.BASELINE_SYMBOL="M",Tr.BASELINE_MULTIPLIER=1.4,Tr.HEIGHT_MULTIPLIER=2,Tr.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]})(),Tr.experimentalLetterSpacing=!1,Tr._fonts={},Tr._newlines=[10,13],Tr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let ti=Tr;const DA=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],im=class gn{constructor(t){this.styleID=0,this.reset(),Sh(this,t,t)}clone(){const t={};return Sh(t,this,gn.defaultStyle),new gn(t)}reset(){Sh(this,gn.defaultStyle,gn.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=Ah(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=Ah(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){BA(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=Ah(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!DA.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};im.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Fo.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 ei=im;function Ah(r){const t=Mt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function BA(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 Sh(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const FA={texture:!0,children:!1,baseTexture:!0},sm=class Jh extends us{constructor(t,e,i){let s=!1;i||(i=Q.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=nt.from(i);n.orig=new _t,n.trim=new _t,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Jh.defaultResolution??Q.RESOLUTION,this._autoResolution=Jh.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 ti.experimentalLetterSpacing}static set experimentalLetterSpacing(t){bt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),ti.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=ti.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,u=s.maxLineWidth,c=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,p;const f=e.dropShadow?2:1;for(let m=0;m<f;++m){const y=e.dropShadow&&m===0,_=y?Math.ceil(Math.max(1,o)+e.padding*2):0,v=_*this._resolution;if(y){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,E=e.dropShadowBlur*this._resolution,w=e.dropShadowDistance*this._resolution;i.shadowColor=Mt.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=E,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*w,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*w+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let g=(l-c.fontSize)/2;l-c.fontSize<0&&(g=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,p=e.strokeThickness/2+x*l+c.ascent+g,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-h[x])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-_,!0),e.fill&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-_)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(ti.experimentalLetterSpacingSupported&&(ti.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=ti.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let p="";for(let f=c+1;f<l.length;++f)p+=l[f];u=this.context.measureText(p).width,a+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=iE(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Fo.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const f=i.lineHeight*(p-1)+d,m=i.lineHeight*p;let y=m;p>0&&f>m&&(y=(m+f)/2);const _=m+d,v=i.lineHeight*(p+1);let g=_;p+1<e.length&&v<_&&(g=(_+v)/2);const x=(g-y)/h;for(let E=0;E<u.length;E++){let w=0;typeof c[E]=="number"?w=c[E]:w=E/u.length;let A=Math.min(1,Math.max(0,y/h+w*x));A=Number(A.toFixed(5)),n.addColorStop(A,u[E])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let m;typeof c[f]=="number"?m=c[f]:m=p/d,n.addColorStop(m,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},FA,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=zr(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=zr(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 ei?this._style=t:this._style=new ei(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)}};sm.defaultAutoResolution=!0;let nm=sm;class UA{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function kA(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof nt){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function GA(r,t){if(r.baseTexture instanceof yt){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function HA(r,t){if(r._texture&&r._texture instanceof nt){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function $A(r,t){return t instanceof nm?(t.updateText(!0),!0):!1}function VA(r,t){if(t instanceof ei){const e=t.toFontString();return ti.measureFont(e),!0}return!1}function XA(r,t){if(r instanceof nm){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 YA(r,t){return r instanceof ei?(t.includes(r)||t.push(r),!0):!1}const om=class _g{constructor(t){this.limiter=new UA(_g.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(XA),this.registerFindHook(YA),this.registerFindHook(kA),this.registerFindHook(GA),this.registerFindHook(HA),this.registerUploadHook($A),this.registerUploadHook(VA)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,He.system.addOnce(this.tick,this,Oi.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)He.system.addOnce(this.tick,this,Oi.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 ir)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&He.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}};om.uploadsPerFrame=4;let Ch=om;Object.defineProperties(Q,{UPLOADS_PER_FRAME:{get(){return Ch.uploadsPerFrame},set(r){bt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ch.uploadsPerFrame=r}}});function am(r,t){return t instanceof yt?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function WA(r,t){if(!(t instanceof hn))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&am(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function jA(r,t){return r instanceof hn?(t.push(r),!0):!1}class lm extends Ch{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(jA),this.registerUploadHook(am),this.registerUploadHook(WA)}}lm.extension={name:"prepare",type:j.RendererSystem},st.add(lm);var zA=`#version 300 es
969
+ `;class mm extends yo{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:ft.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Er.from(nS,sS,{}),this.state=br.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=Mf(t.blendMode,h),n.state.set(this.state);const u=n.gl,c=t.worldTransform.copyTo(this.tempMatrix);c.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=c.toArray(!0),this.shader.uniforms.uColor=Ot.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let p=0,f=0;p<o;p+=s,f+=1){let m=o-p;m>s&&(m=s),f>=a.length&&a.push(this._generateOneMoreBuffer(t));const _=a[f];_.uploadDynamic(e,p,m);const y=t._bufferUpdateIDs[f]||0;d=d||_._updateID<y,d&&(_._updateID=t._updateID,_.uploadStatic(e,p,m)),n.geometry.bind(_.geometry),u.drawElements(u.TRIANGLES,m*6,u.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new pm(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new pm(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,u=0;for(let c=0;c<i;++c){const d=t[e+c],p=d._texture,f=d.scale.x,m=d.scale.y,_=p.trim,y=p.orig;_?(l=_.x-d.anchor.x*y.width,a=l+_.width,u=_.y-d.anchor.y*y.height,h=u+_.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),u=y.height*-d.anchor.y),s[o]=l*f,s[o+1]=u*m,s[o+n]=a*f,s[o+n+1]=u*m,s[o+n*2]=a*f,s[o+n*2+1]=h*m,s[o+n*3]=l*f,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=Ot.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}mm.extension={name:"particle",type:Z.RendererPlugin},ht.add(mm);var Ho=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(Ho||{});const $o={willReadFrequently:!0},wr=class ct{static get experimentalLetterSpacingSupported(){let t=ct._experimentalLetterSpacingSupported;if(t!==void 0){const e=tt.ADAPTER.getCanvasRenderingContext2D().prototype;t=ct._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=ct._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=ct.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",$o);a.font=n;const l=(i?ct.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let u=0;for(let f=0;f<l.length;f++){const m=ct._measureText(l[f],e.letterSpacing,a);h[f]=m,u=Math.max(u,m)}let c=u+e.strokeThickness;e.dropShadow&&(c+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let p=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(p+=e.dropShadowDistance),new ct(t,e,c,p,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;ct.experimentalLetterSpacingSupported&&(ct.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(ct.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=ct._canvas){const s=i.getContext("2d",$o);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=ct.collapseSpaces(u),d=ct.collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+h,m=ct.tokenize(t);for(let _=0;_<m.length;_++){let y=m[_];if(ct.isNewline(y)){if(!d){a+=ct.addLine(o),p=!c,o="",n=0;continue}y=" "}if(c){const g=ct.isBreakingSpace(y),x=ct.isBreakingSpace(o[o.length-1]);if(g&&x)continue}const v=ct.getFromCache(y,h,l,s);if(v>f)if(o!==""&&(a+=ct.addLine(o),o="",n=0),ct.canBreakWords(y,e.breakWords)){const g=ct.wordWrapSplit(y);for(let x=0;x<g.length;x++){let E=g[x],M=E,S=1;for(;g[x+S];){const P=g[x+S];if(!ct.canBreakChars(M,P,y,x,e.breakWords))E+=P;else break;M=P,S++}x+=S-1;const R=ct.getFromCache(E,h,l,s);R+n>f&&(a+=ct.addLine(o),p=!1,o="",n=0),o+=E,n+=R}}else{o.length>0&&(a+=ct.addLine(o),o="",n=0);const g=_===m.length-1;a+=ct.addLine(y,!g),p=!1,o="",n=0}else v+n>f&&(p=!1,a+=ct.addLine(o),o="",n=0),(o.length>0||!ct.isBreakingSpace(y)||p)&&(o+=y,n+=v)}return a+=ct.addLine(o,!1),a}static addLine(t,e=!0){return t=ct.trimRight(t),t=e?`${t}
970
+ `:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=ct._measureText(t,e,s)+e,i[t]=n),n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!ct.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:ct._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:ct._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(ct.isBreakingSpace(n,o)||ct.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return ct.graphemeSegmenter(t)}static measureFont(t){if(ct._fonts[t])return ct._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=ct._canvas,s=ct._context;s.font=t;const n=ct.METRICS_STRING+ct.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(ct.BASELINE_SYMBOL).width);const l=Math.ceil(ct.HEIGHT_MULTIPLIER*a);if(a=a*ct.BASELINE_MULTIPLIER|0,o===0||l===0)return ct._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,u=h.length,c=o*4;let d=0,p=0,f=!1;for(d=0;d<a;++d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p+=c;else break}for(e.ascent=a-d,p=u-c,f=!1,d=l;d>a;--d){for(let m=0;m<c;m+=4)if(h[p+m]!==255){f=!0;break}if(!f)p-=c;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,ct._fonts[t]=e,e}static clearMetrics(t=""){t?delete ct._fonts[t]:ct._fonts={}}static get _canvas(){var t;if(!ct.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",$o))!=null&&t.measureText)return ct.__canvas=i,i;e=tt.ADAPTER.createCanvas()}catch{e=tt.ADAPTER.createCanvas()}e.width=e.height=10,ct.__canvas=e}return ct.__canvas}static get _context(){return ct.__context||(ct.__context=ct._canvas.getContext("2d",$o)),ct.__context}};wr.METRICS_STRING="|ÉqÅ",wr.BASELINE_SYMBOL="M",wr.BASELINE_MULTIPLIER=1.4,wr.HEIGHT_MULTIPLIER=2,wr.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]})(),wr.experimentalLetterSpacing=!1,wr._fonts={},wr._newlines=[10,13],wr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let ri=wr;const oS=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],gm=class vn{constructor(t){this.styleID=0,this.reset(),Mh(this,t,t)}clone(){const t={};return Mh(t,this,vn.defaultStyle),new vn(t)}reset(){Mh(this,vn.defaultStyle,vn.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=Rh(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=Rh(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){aS(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=Rh(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!oS.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};gm.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:Ho.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 ii=gm;function Rh(r){const t=Ot.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function aS(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 Mh(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const lS={texture:!0,children:!1,baseTexture:!0},ym=class lu extends gs{constructor(t,e,i){let s=!1;i||(i=tt.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=ut.from(i);n.orig=new xt,n.trim=new xt,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=lu.defaultResolution??tt.RESOLUTION,this._autoResolution=lu.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 ri.experimentalLetterSpacing}static set experimentalLetterSpacing(t){wt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),ri.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=ri.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,u=s.maxLineWidth,c=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,p;const f=e.dropShadow?2:1;for(let m=0;m<f;++m){const _=e.dropShadow&&m===0,y=_?Math.ceil(Math.max(1,o)+e.padding*2):0,v=y*this._resolution;if(_){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,E=e.dropShadowBlur*this._resolution,M=e.dropShadowDistance*this._resolution;i.shadowColor=Ot.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=E,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*M,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*M+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let g=(l-c.fontSize)/2;l-c.fontSize<0&&(g=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,p=e.strokeThickness/2+x*l+c.ascent+g,e.align==="right"?d+=u-h[x]:e.align==="center"&&(d+=(u-h[x])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[x],d+e.padding,p+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(ri.experimentalLetterSpacingSupported&&(ri.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=ri.graphemeSegmenter(t);let h=this.context.measureText(t).width,u=0;for(let c=0;c<l.length;++c){const d=l[c];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let p="";for(let f=c+1;f<l.length;++f)p+=l[f];u=this.context.measureText(p).width,a+=h-u+n,h=u}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=IE(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,u=s.slice(),c=t.fillGradientStops.slice();if(!c.length){const d=u.length+1;for(let p=1;p<d;++p)c.push(p/d)}if(u.unshift(s[0]),c.unshift(0),u.push(s[s.length-1]),c.push(1),t.fillGradientType===Ho.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let p=0;p<e.length;p++){const f=i.lineHeight*(p-1)+d,m=i.lineHeight*p;let _=m;p>0&&f>m&&(_=(m+f)/2);const y=m+d,v=i.lineHeight*(p+1);let g=y;p+1<e.length&&v<y&&(g=(y+v)/2);const x=(g-_)/h;for(let E=0;E<u.length;E++){let M=0;typeof c[E]=="number"?M=c[E]:M=E/u.length;let S=Math.min(1,Math.max(0,_/h+M*x));S=Number(S.toFixed(5)),n.addColorStop(S,u[E])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let m;typeof c[f]=="number"?m=c[f]:m=p/d,n.addColorStop(m,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},lS,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 ii?this._style=t:this._style=new ii(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)}};ym.defaultAutoResolution=!0;let _m=ym;class hS{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function uS(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof ut){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function cS(r,t){if(r.baseTexture instanceof _t){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function dS(r,t){if(r._texture&&r._texture instanceof ut){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function fS(r,t){return t instanceof _m?(t.updateText(!0),!0):!1}function pS(r,t){if(t instanceof ii){const e=t.toFontString();return ri.measureFont(e),!0}return!1}function mS(r,t){if(r instanceof _m){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 gS(r,t){return r instanceof ii?(t.includes(r)||t.push(r),!0):!1}const vm=class Lg{constructor(t){this.limiter=new hS(Lg.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(mS),this.registerFindHook(gS),this.registerFindHook(uS),this.registerFindHook(cS),this.registerFindHook(dS),this.registerUploadHook(fS),this.registerUploadHook(pS)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Xe.system.addOnce(this.tick,this,Li.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)Xe.system.addOnce(this.tick,this,Li.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 ir)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Xe.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}};vm.uploadsPerFrame=4;let Ph=vm;Object.defineProperties(tt,{UPLOADS_PER_FRAME:{get(){return Ph.uploadsPerFrame},set(r){wt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),Ph.uploadsPerFrame=r}}});function xm(r,t){return t instanceof _t?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function yS(r,t){if(!(t instanceof cn))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&xm(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function _S(r,t){return r instanceof cn?(t.push(r),!0):!1}class bm extends Ph{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(_S),this.registerUploadHook(xm),this.registerUploadHook(yS)}}bm.extension={name:"prepare",type:Z.RendererSystem},ht.add(bm);var vS=`#version 300 es
971
971
  #define SHADER_NAME Tiling-Sprite-100
972
972
 
973
973
  precision lowp float;
@@ -993,7 +993,7 @@ void main(void)
993
993
 
994
994
  fragmentColor = texSample * uColor;
995
995
  }
996
- `,qA=`#version 300 es
996
+ `,xS=`#version 300 es
997
997
  #define SHADER_NAME Tiling-Sprite-300
998
998
 
999
999
  precision lowp float;
@@ -1013,7 +1013,7 @@ void main(void)
1013
1013
 
1014
1014
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1015
1015
  }
1016
- `,KA=`#version 100
1016
+ `,bS=`#version 100
1017
1017
  #ifdef GL_EXT_shader_texture_lod
1018
1018
  #extension GL_EXT_shader_texture_lod : enable
1019
1019
  #endif
@@ -1046,7 +1046,7 @@ void main(void)
1046
1046
 
1047
1047
  gl_FragColor = texSample * uColor;
1048
1048
  }
1049
- `,hm=`#version 100
1049
+ `,Em=`#version 100
1050
1050
  #define SHADER_NAME Tiling-Sprite-100
1051
1051
 
1052
1052
  precision lowp float;
@@ -1066,7 +1066,7 @@ void main(void)
1066
1066
 
1067
1067
  vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
1068
1068
  }
1069
- `,ZA=`#version 100
1069
+ `,ES=`#version 100
1070
1070
  #define SHADER_NAME Tiling-Sprite-Simple-100
1071
1071
 
1072
1072
  precision lowp float;
@@ -1081,7 +1081,7 @@ void main(void)
1081
1081
  vec4 texSample = texture2D(uSampler, vTextureCoord);
1082
1082
  gl_FragColor = texSample * uColor;
1083
1083
  }
1084
- `;const ko=new Bt;class um extends fo{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Xf,this.state=xr.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=br.from(hm,ZA,e),this.shader=t.context.webGLVersion>1?br.from(qA,zA,e):br.from(hm,KA,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==Yr.CLAMP:l.wrapMode===Yr.CLAMP&&(l.wrapMode=Yr.REPEAT));const p=d?this.simpleShader:this.shader,f=a.width,m=a.height,y=t._width,_=t._height;ko.set(u.a*f/y,u.b*f/_,u.c*m/y,u.d*m/_,u.tx/y,u.ty/_),ko.invert(),d?ko.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=ko.toArray(!0),p.uniforms.uColor=Mt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=a,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=yf(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}um.extension={name:"tilingSprite",type:j.RendererPlugin},st.add(um);const cm=class yn{constructor(t,e,i){this.linkedSheets=[],(t instanceof yt||t instanceof nt)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof nt?s:null,this.baseTexture=s instanceof yt?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=Or(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<=yn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=yn.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new _t(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new _t(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 _t(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new _t(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new nt(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),nt.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*yn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*yn.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=[]}};cm.BATCH_SIZE=1e3;let dm=cm;const QA=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function fm(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=de.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,fm([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const JA={extension:j.Asset,cache:{test:r=>r instanceof dm,getCacheableAssets:(r,t)=>fm(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&QA.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=Q.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:j.LoadParser,priority:or.Normal},async testParse(r,t){return de.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=de.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=dh(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new dm({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let m=o+f;(c=t.data)!=null&&c.ignoreMultiPack||(m=dh(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==f))})}return l},unload(r){r.destroy(!0)}}};st.add(JA);class Go{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Ho{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[c]=f}i[o].push(l)}const s=new Go;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class Ih{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 Go,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class Rh{static test(t){return typeof t=="string"&&t.includes("<font>")?Ih.test(Q.ADAPTER.parseXML(t)):!1}static parse(t){return Ih.parse(Q.ADAPTER.parseXML(t))}}const Mh=[Ho,Ih,Rh];function tS(r){for(let t=0;t<Mh.length;t++)if(Mh[t].test(r))return Mh[t];return null}function eS(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,u=r.width/i-l-h*2,c=r.height/i-l-h*2,d=o.slice(),p=e.fillGradientStops.slice();if(!p.length){const f=d.length+1;for(let m=1;m<f;++m)p.push(m/f)}if(d.unshift(o[0]),p.unshift(0),d.push(o[o.length-1]),p.push(1),e.fillGradientType===Fo.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,h,u/2,c+h);let f=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let y=0;y<s.length;y++){const _=n.lineHeight*y;for(let v=0;v<d.length;v++){let g=0;typeof p[v]=="number"?g=p[v]:g=v/d.length;const x=_/c+g*m;let E=Math.max(f,x);E=Math.min(E,1),a.addColorStop(E,d[v]),f=E}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let m=1;for(let y=0;y<d.length;y++){let _;typeof p[y]=="number"?_=p[y]:_=m/f,a.addColorStop(_,d[y]),m++}}return a}function rS(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=eS(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,p=o.dropShadowDistance*n;t.shadowColor=Mt.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,u+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function $o(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function pm(r){return Array.from?Array.from(r):r.split("")}function iS(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...pm(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const ri=class wr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Or(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];h[d]=e instanceof Array?e[c]:e[p],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=Ge.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=dr.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:f,y:m,width:y,height:_,xoffset:v,yoffset:g,xadvance:x}=t.char[c];f/=l,m/=l,y/=l,_/=l,v/=l,g/=l,x/=l;const E=new _t(f+h[p].frame.x/l,m+h[p].frame.y/l,y,_);this.chars[d]={xOffset:v,yOffset:g,xAdvance:x,kerning:{},texture:new nt(h[p].baseTexture,E),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Go)s=t;else{const o=tS(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof nt&&(e=[e]);const n=new wr(s,e,i);return wr.available[n.font]=n,n}static uninstall(t){const e=wr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete wr.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},wr.defaultOptions,i),u=iS(s),c=e instanceof ei?e:new ei(e),d=a,p=new Go;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let f=0,m=0,y,_,v,g=0;const x=[];for(let w=0;w<u.length;w++){y||(y=Q.ADAPTER.createCanvas(),y.width=a,y.height=l,_=y.getContext("2d"),v=new yt(y,{resolution:o,...h}),x.push(new nt(v)),p.page.push({id:x.length-1,file:""}));const A=u[w],R=ti.measureText(A,c,!1,y),M=R.width,D=Math.ceil(R.height),U=Math.ceil((c.fontStyle==="italic"?2:1)*M);if(m>=l-D*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--w,y=null,_=null,v=null,m=0,f=0,g=0;continue}if(g=Math.max(D+R.fontProperties.descent,g),U*o+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${A}')`);--w,m+=g*o,m=Math.ceil(m),f=0,g=0;continue}rS(y,_,R,f,m,o,c);const C=$o(R.text);p.char.push({id:C,page:x.length-1,x:f/o,y:m/o,width:U,height:D,xoffset:0,yoffset:0,xadvance:M-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(U+2*n)*o,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let w=0,A=u.length;w<A;w++){const R=u[w];for(let M=0;M<A;M++){const D=u[M],U=_.measureText(R).width,C=_.measureText(D).width,T=_.measureText(R+D).width-(U+C);T&&p.kerning.push({first:$o(R),second:$o(D),amount:T})}}const E=new wr(p,x,!0);return wr.available[t]!==void 0&&wr.uninstall(t),wr.available[t]=E,E}};ri.ALPHA=[["a","z"],["A","Z"]," "],ri.NUMERIC=[["0","9"]],ri.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],ri.ASCII=[[" ","~"]],ri.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:ri.ALPHANUMERIC},ri.available={};let ii=ri;var sS=`// Pixi texture info\r
1084
+ `;const Xo=new kt;class Tm extends yo{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new ip,this.state=br.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Er.from(Em,ES,e),this.shader=t.context.webGLVersion>1?Er.from(xS,vS,e):Er.from(Em,bS,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,u=t.tileTransform.localTransform,c=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==jr.CLAMP:l.wrapMode===jr.CLAMP&&(l.wrapMode=jr.REPEAT));const p=d?this.simpleShader:this.shader,f=a.width,m=a.height,_=t._width,y=t._height;Xo.set(u.a*f/_,u.b*f/y,u.c*m/_,u.d*m/y,u.tx/_,u.ty/y),Xo.invert(),d?Xo.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=Xo.toArray(!0),p.uniforms.uColor=Ot.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(p.uniforms.uColor),p.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),p.uniforms.uSampler=a,e.shader.bind(p),e.geometry.bind(i),this.state.blendMode=Mf(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Tm.extension={name:"tilingSprite",type:Z.RendererPlugin},ht.add(Tm);const wm=class xn{constructor(t,e,i){this.linkedSheets=[],(t instanceof _t||t instanceof ut)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof ut?s:null,this.baseTexture=s instanceof _t?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=Nr(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<=xn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=xn.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,u=new xt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new xt(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 xt(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new xt(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new ut(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),ut.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*xn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*xn.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=[]}};wm.BATCH_SIZE=1e3;let Am=wm;const TS=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Sm(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=ge.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,Sm([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const wS={extension:Z.Asset,cache:{test:r=>r instanceof Am,getCacheableAssets:(r,t)=>Sm(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&TS.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:or.Normal},async testParse(r,t){return ge.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var u,c;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=ge.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=gh(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new Am({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(u=r==null?void 0:r.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(h)){const d=[];for(const f of h){if(typeof f!="string")continue;let m=o+f;(c=t.data)!=null&&c.ignoreMultiPack||(m=gh(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const p=await Promise.all(d);l.linkedSheets=p,p.forEach(f=>{f.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==f))})}return l},unload(r){r.destroy(!0)}}};ht.add(wS);class Vo{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class zo{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const u=a[h].split("="),c=u[0],d=u[1].replace(/"/gm,""),p=parseFloat(d),f=isNaN(p)?d:p;l[c]=f}i[o].push(l)}const s=new Vo;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class Oh{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 Vo,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class Nh{static test(t){return typeof t=="string"&&t.includes("<font>")?Oh.test(tt.ADAPTER.parseXML(t)):!1}static parse(t){return Oh.parse(tt.ADAPTER.parseXML(t))}}const Dh=[zo,Oh,Nh];function AS(r){for(let t=0;t<Dh.length;t++)if(Dh[t].test(r))return Dh[t];return null}function SS(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,u=r.width/i-l-h*2,c=r.height/i-l-h*2,d=o.slice(),p=e.fillGradientStops.slice();if(!p.length){const f=d.length+1;for(let m=1;m<f;++m)p.push(m/f)}if(d.unshift(o[0]),p.unshift(0),d.push(o[o.length-1]),p.push(1),e.fillGradientType===Ho.LINEAR_VERTICAL){a=t.createLinearGradient(u/2,h,u/2,c+h);let f=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/c;for(let _=0;_<s.length;_++){const y=n.lineHeight*_;for(let v=0;v<d.length;v++){let g=0;typeof p[v]=="number"?g=p[v]:g=v/d.length;const x=y/c+g*m;let E=Math.max(f,x);E=Math.min(E,1),a.addColorStop(E,d[v]),f=E}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let m=1;for(let _=0;_<d.length;_++){let y;typeof p[_]=="number"?y=p[_]:y=m/f,a.addColorStop(y,d[_]),m++}}return a}function CS(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,u=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=SS(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const c=o.dropShadowColor,d=o.dropShadowBlur*n,p=o.dropShadowDistance*n;t.shadowColor=Ot.shared.setValue(c).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*p,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*p}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,u+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,u+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Yo(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function Cm(r){return Array.from?Array.from(r):r.split("")}function IS(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...Cm(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const si=class Ar{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Nr(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let c=0;c<t.page.length;c++){const{id:d,file:p}=t.page[c];h[d]=e instanceof Array?e[c]:e[p],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=He.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=fr.OFF)}for(let c=0;c<t.char.length;c++){const{id:d,page:p}=t.char[c];let{x:f,y:m,width:_,height:y,xoffset:v,yoffset:g,xadvance:x}=t.char[c];f/=l,m/=l,_/=l,y/=l,v/=l,g/=l,x/=l;const E=new xt(f+h[p].frame.x/l,m+h[p].frame.y/l,_,y);this.chars[d]={xOffset:v,yOffset:g,xAdvance:x,kerning:{},texture:new ut(h[p].baseTexture,E),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Vo)s=t;else{const o=AS(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof ut&&(e=[e]);const n=new Ar(s,e,i);return Ar.available[n.font]=n,n}static uninstall(t){const e=Ar.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete Ar.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},Ar.defaultOptions,i),u=IS(s),c=e instanceof ii?e:new ii(e),d=a,p=new Vo;p.info[0]={face:c.fontFamily,size:c.fontSize},p.common[0]={lineHeight:c.fontSize};let f=0,m=0,_,y,v,g=0;const x=[];for(let M=0;M<u.length;M++){_||(_=tt.ADAPTER.createCanvas(),_.width=a,_.height=l,y=_.getContext("2d"),v=new _t(_,{resolution:o,...h}),x.push(new ut(v)),p.page.push({id:x.length-1,file:""}));const S=u[M],R=ri.measureText(S,c,!1,_),P=R.width,F=Math.ceil(R.height),k=Math.ceil((c.fontStyle==="italic"?2:1)*P);if(m>=l-F*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--M,_=null,y=null,v=null,m=0,f=0,g=0;continue}if(g=Math.max(F+R.fontProperties.descent,g),k*o+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${S}')`);--M,m+=g*o,m=Math.ceil(m),f=0,g=0;continue}CS(_,y,R,f,m,o,c);const I=Yo(R.text);p.char.push({id:I,page:x.length-1,x:f/o,y:m/o,width:k,height:F,xoffset:0,yoffset:0,xadvance:P-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(k+2*n)*o,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let M=0,S=u.length;M<S;M++){const R=u[M];for(let P=0;P<S;P++){const F=u[P],k=y.measureText(R).width,I=y.measureText(F).width,A=y.measureText(R+F).width-(k+I);A&&p.kerning.push({first:Yo(R),second:Yo(F),amount:A})}}const E=new Ar(p,x,!0);return Ar.available[t]!==void 0&&Ar.uninstall(t),Ar.available[t]=E,E}};si.ALPHA=[["a","z"],["A","Z"]," "],si.NUMERIC=[["0","9"]],si.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],si.ASCII=[[" ","~"]],si.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:si.ALPHANUMERIC},si.available={};let ni=si;var RS=`// Pixi texture info\r
1085
1085
  varying vec2 vTextureCoord;\r
1086
1086
  uniform sampler2D uSampler;\r
1087
1087
  \r
@@ -1119,7 +1119,7 @@ void main(void) {\r
1119
1119
  // NPM Textures, NPM outputs\r
1120
1120
  gl_FragColor = vec4(uColor.rgb, coverage);\r
1121
1121
  }\r
1122
- `,nS=`// Mesh material default fragment\r
1122
+ `,MS=`// Mesh material default fragment\r
1123
1123
  attribute vec2 aVertexPosition;\r
1124
1124
  attribute vec2 aTextureCoord;\r
1125
1125
  \r
@@ -1135,16 +1135,16 @@ void main(void)\r
1135
1135
  \r
1136
1136
  vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
1137
1137
  }\r
1138
- `;const mm=[],gm=[],ym=[],oS=class vg extends ir{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},vg.styleDefaults,e);if(!ii.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Mt(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Pr(()=>{this.dirty=!0},this,0,0),this._roundPixels=Q.ROUND_PIXELS,this.dirty=!0,this._resolution=Q.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var U;const t=ii.available[this._fontName],e=this.fontSize,i=e/t.size,s=new At,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1139
- `)||" ",h=pm(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?mm:gm;let d=null,p=0,f=0,m=0,y=-1,_=0,v=0,g=0,x=0;for(let C=0;C<h.length;C++){const T=h[C],I=$o(T);if(/(?:\s)/.test(T)&&(y=C,_=p,x++),T==="\r"||T===`
1140
- `){o.push(p),a.push(-1),f=Math.max(f,p),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,x=0;continue}const N=t.chars[I];if(!N)continue;d&&N.kerning[d]&&(s.x+=N.kerning[d]);const O=ym.pop()||{texture:nt.EMPTY,line:0,charCode:0,prevSpaces:0,position:new At};O.texture=N.texture,O.line=m,O.charCode=I,O.position.x=Math.round(s.x+N.xOffset+this._letterSpacing/2),O.position.y=Math.round(s.y+N.yOffset),O.prevSpaces=x,n.push(O),p=O.position.x+Math.max(N.xAdvance-N.xOffset,N.texture.orig.width),s.x+=N.xAdvance+this._letterSpacing,g=Math.max(g,N.yOffset+N.texture.height),d=I,y!==-1&&u>0&&s.x>u&&(++v,os(n,1+y-v,1+C-y),C=y,y=-1,o.push(_),a.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,_),m++,s.x=0,s.y+=t.lineHeight,d=null,x=0)}const E=h[h.length-1];E!=="\r"&&E!==`
1141
- `&&(/(?:\s)/.test(E)&&(p=_),o.push(p),f=Math.max(f,p),a.push(-1));const w=[];for(let C=0;C<=m;C++){let T=0;this._align==="right"?T=f-o[C]:this._align==="center"?T=(f-o[C])/2:this._align==="justify"&&(T=a[C]<0?0:(f-o[C])/a[C]),w.push(T)}const A=n.length,R={},M=[],D=this._activePagesMeshData;c.push(...D);for(let C=0;C<A;C++){const T=n[C].texture,I=T.baseTexture.uid;if(!R[I]){let N=c.pop();if(!N){const L=new MA;let F,V;t.distanceFieldType==="none"?(F=new tm(nt.EMPTY),V=pt.NORMAL):(F=new tm(nt.EMPTY,{program:Nr.from(nS,sS),uniforms:{uFWidth:0}}),V=pt.NORMAL_NPM);const P=new Jp(L,F);P.blendMode=V,N={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:P,vertices:null,uvs:null,indices:null}}N.index=0,N.indexCount=0,N.vertexCount=0,N.uvsCount=0,N.total=0;const{_textureCache:O}=this;O[I]=O[I]||new nt(T.baseTexture),N.mesh.texture=O[I],N.mesh.tint=this._tintColor.value,M.push(N),R[I]=N}R[I].total++}for(let C=0;C<D.length;C++)M.includes(D[C])||this.removeChild(D[C].mesh);for(let C=0;C<M.length;C++)M[C].mesh.parent!==this&&this.addChild(M[C].mesh);this._activePagesMeshData=M;for(const C in R){const T=R[C],I=T.total;if(!(((U=T.indices)==null?void 0:U.length)>6*I)||T.vertices.length<Jp.BATCHABLE_SIZE*2)T.vertices=new Float32Array(4*2*I),T.uvs=new Float32Array(4*2*I),T.indices=new Uint16Array(6*I);else{const N=T.total,O=T.vertices;for(let L=N*4*2;L<O.length;L++)O[L]=0}T.mesh.size=6*I}for(let C=0;C<A;C++){const T=n[C];let I=T.position.x+w[T.line]*(this._align==="justify"?T.prevSpaces:1);this._roundPixels&&(I=Math.round(I));const N=I*i,O=T.position.y*i,L=T.texture,F=R[L.baseTexture.uid],V=L.frame,P=L._uvs,B=F.index++;F.indices[B*6+0]=0+B*4,F.indices[B*6+1]=1+B*4,F.indices[B*6+2]=2+B*4,F.indices[B*6+3]=0+B*4,F.indices[B*6+4]=2+B*4,F.indices[B*6+5]=3+B*4,F.vertices[B*8+0]=N,F.vertices[B*8+1]=O,F.vertices[B*8+2]=N+V.width*i,F.vertices[B*8+3]=O,F.vertices[B*8+4]=N+V.width*i,F.vertices[B*8+5]=O+V.height*i,F.vertices[B*8+6]=N,F.vertices[B*8+7]=O+V.height*i,F.uvs[B*8+0]=P.x0,F.uvs[B*8+1]=P.y0,F.uvs[B*8+2]=P.x1,F.uvs[B*8+3]=P.y1,F.uvs[B*8+4]=P.x2,F.uvs[B*8+5]=P.y2,F.uvs[B*8+6]=P.x3,F.uvs[B*8+7]=P.y3}this._textWidth=f*i,this._textHeight=(s.y+t.lineHeight)*i;for(const C in R){const T=R[C];if(this.anchor.x!==0||this.anchor.y!==0){let L=0;const F=this._textWidth*this.anchor.x,V=this._textHeight*this.anchor.y;for(let P=0;P<T.total;P++)T.vertices[L++]-=F,T.vertices[L++]-=V,T.vertices[L++]-=F,T.vertices[L++]-=V,T.vertices[L++]-=F,T.vertices[L++]-=V,T.vertices[L++]-=F,T.vertices[L++]-=V}this._maxLineHeight=g*i;const I=T.mesh.geometry.getBuffer("aVertexPosition"),N=T.mesh.geometry.getBuffer("aTextureCoord"),O=T.mesh.geometry.getIndex();I.data=T.vertices,N.data=T.uvs,O.data=T.indices,I.update(),N.update(),O.update()}for(let C=0;C<n.length;C++)ym.push(n[C]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=ii.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,p=t._view.resolution;for(const f of this._activePagesMeshData)f.mesh.shader.uniforms.uFWidth=c*e*d*p}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=ii.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(!ii.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??ii.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=ii.available[this._fontName].distanceFieldType==="none"?mm:gm;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=nt.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};oS.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const aS=[".xml",".fnt"],lS={extension:{type:j.LoadParser,priority:or.Normal},name:"loadBitmapFont",test(r){return aS.includes(de.extname(r).toLowerCase())},async testParse(r){return Ho.test(r)||Rh.test(r)},async parse(r,t,e){const i=Ho.test(r)?Ho.parse(r):Rh.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=de.join(de.dirname(s),u);c=dh(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return ii.install(i,l,!0)},async load(r,t){return(await Q.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};st.add(lS);const Oh=class Ts extends ei{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Ts(Object.keys(Ts.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 Ts.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Ts;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return Q.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:de.basename(t,de.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1138
+ `;const Im=[],Rm=[],Mm=[],PS=class Bg extends ir{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Bg.styleDefaults,e);if(!ni.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new Ot(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new Dr(()=>{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 k;const t=ni.available[this._fontName],e=this.fontSize,i=e/t.size,s=new It,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
1139
+ `)||" ",h=Cm(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?Im:Rm;let d=null,p=0,f=0,m=0,_=-1,y=0,v=0,g=0,x=0;for(let I=0;I<h.length;I++){const A=h[I],T=Yo(A);if(/(?:\s)/.test(A)&&(_=I,y=p,x++),A==="\r"||A===`
1140
+ `){o.push(p),a.push(-1),f=Math.max(f,p),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,x=0;continue}const C=t.chars[T];if(!C)continue;d&&C.kerning[d]&&(s.x+=C.kerning[d]);const L=Mm.pop()||{texture:ut.EMPTY,line:0,charCode:0,prevSpaces:0,position:new It};L.texture=C.texture,L.line=m,L.charCode=T,L.position.x=Math.round(s.x+C.xOffset+this._letterSpacing/2),L.position.y=Math.round(s.y+C.yOffset),L.prevSpaces=x,n.push(L),p=L.position.x+Math.max(C.xAdvance-C.xOffset,C.texture.orig.width),s.x+=C.xAdvance+this._letterSpacing,g=Math.max(g,C.yOffset+C.texture.height),d=T,_!==-1&&u>0&&s.x>u&&(++v,ds(n,1+_-v,1+I-_),I=_,_=-1,o.push(y),a.push(n.length>0?n[n.length-1].prevSpaces:0),f=Math.max(f,y),m++,s.x=0,s.y+=t.lineHeight,d=null,x=0)}const E=h[h.length-1];E!=="\r"&&E!==`
1141
+ `&&(/(?:\s)/.test(E)&&(p=y),o.push(p),f=Math.max(f,p),a.push(-1));const M=[];for(let I=0;I<=m;I++){let A=0;this._align==="right"?A=f-o[I]:this._align==="center"?A=(f-o[I])/2:this._align==="justify"&&(A=a[I]<0?0:(f-o[I])/a[I]),M.push(A)}const S=n.length,R={},P=[],F=this._activePagesMeshData;c.push(...F);for(let I=0;I<S;I++){const A=n[I].texture,T=A.baseTexture.uid;if(!R[T]){let C=c.pop();if(!C){const N=new eS;let B,X;t.distanceFieldType==="none"?(B=new fm(ut.EMPTY),X=gt.NORMAL):(B=new fm(ut.EMPTY,{program:Lr.from(MS,RS),uniforms:{uFWidth:0}}),X=gt.NORMAL_NPM);const O=new dm(N,B);O.blendMode=X,C={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:O,vertices:null,uvs:null,indices:null}}C.index=0,C.indexCount=0,C.vertexCount=0,C.uvsCount=0,C.total=0;const{_textureCache:L}=this;L[T]=L[T]||new ut(A.baseTexture),C.mesh.texture=L[T],C.mesh.tint=this._tintColor.value,P.push(C),R[T]=C}R[T].total++}for(let I=0;I<F.length;I++)P.includes(F[I])||this.removeChild(F[I].mesh);for(let I=0;I<P.length;I++)P[I].mesh.parent!==this&&this.addChild(P[I].mesh);this._activePagesMeshData=P;for(const I in R){const A=R[I],T=A.total;if(!(((k=A.indices)==null?void 0:k.length)>6*T)||A.vertices.length<dm.BATCHABLE_SIZE*2)A.vertices=new Float32Array(4*2*T),A.uvs=new Float32Array(4*2*T),A.indices=new Uint16Array(6*T);else{const C=A.total,L=A.vertices;for(let N=C*4*2;N<L.length;N++)L[N]=0}A.mesh.size=6*T}for(let I=0;I<S;I++){const A=n[I];let T=A.position.x+M[A.line]*(this._align==="justify"?A.prevSpaces:1);this._roundPixels&&(T=Math.round(T));const C=T*i,L=A.position.y*i,N=A.texture,B=R[N.baseTexture.uid],X=N.frame,O=N._uvs,D=B.index++;B.indices[D*6+0]=0+D*4,B.indices[D*6+1]=1+D*4,B.indices[D*6+2]=2+D*4,B.indices[D*6+3]=0+D*4,B.indices[D*6+4]=2+D*4,B.indices[D*6+5]=3+D*4,B.vertices[D*8+0]=C,B.vertices[D*8+1]=L,B.vertices[D*8+2]=C+X.width*i,B.vertices[D*8+3]=L,B.vertices[D*8+4]=C+X.width*i,B.vertices[D*8+5]=L+X.height*i,B.vertices[D*8+6]=C,B.vertices[D*8+7]=L+X.height*i,B.uvs[D*8+0]=O.x0,B.uvs[D*8+1]=O.y0,B.uvs[D*8+2]=O.x1,B.uvs[D*8+3]=O.y1,B.uvs[D*8+4]=O.x2,B.uvs[D*8+5]=O.y2,B.uvs[D*8+6]=O.x3,B.uvs[D*8+7]=O.y3}this._textWidth=f*i,this._textHeight=(s.y+t.lineHeight)*i;for(const I in R){const A=R[I];if(this.anchor.x!==0||this.anchor.y!==0){let N=0;const B=this._textWidth*this.anchor.x,X=this._textHeight*this.anchor.y;for(let O=0;O<A.total;O++)A.vertices[N++]-=B,A.vertices[N++]-=X,A.vertices[N++]-=B,A.vertices[N++]-=X,A.vertices[N++]-=B,A.vertices[N++]-=X,A.vertices[N++]-=B,A.vertices[N++]-=X}this._maxLineHeight=g*i;const T=A.mesh.geometry.getBuffer("aVertexPosition"),C=A.mesh.geometry.getBuffer("aTextureCoord"),L=A.mesh.geometry.getIndex();T.data=A.vertices,C.data=A.uvs,L.data=A.indices,T.update(),C.update(),L.update()}for(let I=0;I<n.length;I++)Mm.push(n[I]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=ni.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),u=Math.sqrt(a*a+l*l),c=(Math.abs(h)+Math.abs(u))/2,d=this.fontSize/s,p=t._view.resolution;for(const f of this._activePagesMeshData)f.mesh.shader.uniforms.uFWidth=c*e*d*p}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=ni.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(!ni.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??ni.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=ni.available[this._fontName].distanceFieldType==="none"?Im:Rm;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=ut.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};PS.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const OS=[".xml",".fnt"],NS={extension:{type:Z.LoadParser,priority:or.Normal},name:"loadBitmapFont",test(r){return OS.includes(ge.extname(r).toLowerCase())},async testParse(r){return zo.test(r)||Nh.test(r)},async parse(r,t,e){const i=zo.test(r)?zo.parse(r):Nh.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=ge.join(ge.dirname(s),u);c=gh(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return ni.install(i,l,!0)},async load(r,t){return(await tt.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};ht.add(NS);const Lh=class Is extends ii{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new Is(Object.keys(Is.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 Is.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=Is;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return tt.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:ge.basename(t,ge.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
1142
1142
  @font-face {
1143
1143
  font-family: "${e.family}";
1144
1144
  src: url('${e.dataSrc}');
1145
1145
  font-weight: ${e.weight};
1146
1146
  font-style: ${e.style};
1147
1147
  font-display: ${e.display};
1148
- }`,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=Zb(t)),typeof t=="number"?Kb(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Ts.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}=Q.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}};Oh.availableFonts={},Oh.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let Ph=Oh;const Vo=class ws extends us{constructor(t="",e={}){super(nt.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=nt.from(i,{scaleMode:Q.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new _t,s.trim=new _t,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=ws.defaultMaxWidth,this.maxHeight=ws.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=ws.defaultAutoResolution,this._resolution=ws.defaultResolution??Q.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},ws.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=zr(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=zr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof Ph?(this.ownsStyle=!1,this._style=t):t instanceof ei?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Ph.from(t)):(this.ownsStyle=!0,this._style=new Ph(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")}};Vo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Vo.defaultMaxWidth=2024,Vo.defaultMaxHeight=2024,Vo.defaultAutoResolution=!0;const hS=16777215,uS=.25,cS=16777215,dS=1,fS=1.5;let si=!1,un;const Nh=r=>{const t={tint:r!=null&&r.fill?new Mt(r.fill).toNumber():hS,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:uS},e={tint:r!=null&&r.stroke?new Mt(r.stroke).toNumber():cS,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:dS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?fS:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Xo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Nh(i),o=new hn;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new hn,l=n.lineWidth===1?1:n.lineWidth/un;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},pS=Xo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),mS=Xo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),gS=Xo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),yS=Xo((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),_m=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},vm=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=_m(r);(n!==un||!si)&&(si=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(si=n===un,f.width=p/n,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),un=n;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},_S=(r,t)=>{const e=new hn,i=mp({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;un=_m(r);const l=(g,x)=>{si=!1;const{selector:E}=g.target,w=typeof a=="function"?a(g,x):a;let A;E.type===Et.RECTANGLE?A=pS(e,E,w):E.type===Et.POLYGON?A=gS(e,E,w):E.type===Et.ELLIPSE?A=mS(e,E,w):E.type===Et.MULTIPOLYGLON?A=yS(e,E,w):console.warn(`Unsupported shape type: ${E.type}`),A&&s.set(g.id,{annotation:g,...A})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,E)=>{si=!1;const w=s.get(g.id);if(w&&(s.delete(g.id),w.fill.destroy(),w.stroke.destroy(),l(x,E),n.has(x.id))){const{fill:A,stroke:R}=s.get(x.id);e.removeChild(A),e.removeChild(R)}},c=(g,x)=>{const E=s.get(g);E&&(s.delete(g),E.fill.destroy(),E.stroke.destroy(),l(E.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},p=g=>{si=!1;const{children:x}=e;s.forEach(({fill:E,stroke:w,annotation:A})=>{const R=g?n.has(A.id)||g(A):!0;R&&!x.includes(E)?(e.addChild(E),e.addChild(w)):!R&&x.includes(E)&&(e.removeChild(E),e.removeChild(w))}),i.render(e)},f=g=>{const x=new Set(g.selected.map(A=>A.id)),E=g.selected.filter(({id:A})=>!n.has(A)),w=[...n].filter(A=>!x.has(A));E.forEach(({id:A,editable:R})=>{if(R){const M=s.get(A);M&&(e.removeChild(M.fill),e.removeChild(M.stroke))}else c(A,{selected:!0,hovered:A===o})}),w.forEach(A=>c(A,{hovered:A===o})),n=x,i.render(e)},m=g=>{o!==g&&(o&&!n.has(o)&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},y=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:E,stroke:w,strokeWidth:A},R)=>{A>1&&(si=!1);const M={selected:n.has(x.id),hovered:o===x.id},{fillStyle:D,strokeStyle:U}=Nh(g(x,M));E.tint=D.tint,E.alpha=D.alpha,w.tint=U.tint||16777215,w.alpha=U.alpha,s.set(x.id,{annotation:x,fill:E,stroke:w,strokeWidth:U.lineWidth})});else{const{fillStyle:x,strokeStyle:E}=Nh(g);E.lineWidth>1&&(si=!1),s.forEach(({annotation:w,fill:A,stroke:R,strokeWidth:M},D)=>{A.tint=x.tint,A.alpha=x.alpha,R.tint=E.tint||16777215,R.alpha=E.alpha,s.set(w.id,{annotation:w,fill:A,stroke:R,strokeWidth:E.lineWidth})})}a=g,i.render(e),vm(r,e,s,i)()},_=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:vm(r,e,s,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:m,setSelected:f,setStyle:y,setVisible:_,updateAnnotation:u}};function vS(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:p}=o;Mn(r,c,w=>e(11,i=w)),Mn(r,d,w=>e(8,s=w));const f=Bs();let m,y;const _=w=>{const A=new Ae.Point(w.x,w.y),{x:R,y:M}=l.viewport.pointFromPixel(A);return l.viewport.viewportToImageCoordinates(R,M)},v=w=>{const{x:A,y:R}=w.position;y={x:A,y:R}},g=w=>A=>{const{x:R,y:M}=_(new Ae.Point(A.offsetX,A.offsetY)),D=u.getAt(R,M,n);D?(w.classList.add("hover"),i!==D.id&&(c.set(D.id),m.setHovered(D.id))):(w.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=w=>{if(!y)return;const A=w.originalEvent,{x:R,y:M}=w.position,D=R-y.x,U=M-y.y;if(Math.sqrt(D*D+U*U)<5){const{x:T,y:I}=_(w.position),N=u.getAt(T,I,n);N?f("click",{originalEvent:A,annotation:N}):f("click",{originalEvent:A})}y=void 0};let E;return Ds(()=>{var N;const{offsetWidth:w,offsetHeight:A}=l.canvas,R=document.createElement("canvas");R.width=w,R.height=A,R.className="a9s-gl-canvas",(N=l.element.querySelector(".openseadragon-canvas"))==null||N.appendChild(R),e(7,m=_S(l,R));const M=g(R);R.addEventListener("pointermove",M);const D=new ResizeObserver(O=>{try{const{width:L,height:F}=O[0].contentRect;R.width=L,R.height=F,m.resize(L,F)}catch{console.warn("WebGL canvas already disposed")}});D.observe(R);const U=()=>{const O=l.viewport.getBounds();E=l.viewport.viewportToImageRectangle(O);const{x:L,y:F,width:V,height:P}=E,B=u.getIntersecting(L,F,V,P);p.set(B.map($=>$.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",U);const C=O=>O.filter(L=>Ke(L)),T=O=>Ke(O.oldValue)&&Ke(O.newValue),I=O=>{const{created:L,updated:F,deleted:V}=O.changes;if(C(L||[]).forEach(P=>m.addAnnotation(P)),C(V||[]).forEach(P=>m.removeAnnotation(P)),(F||[]).filter(P=>T(P)).forEach(({oldValue:P,newValue:B})=>m.updateAnnotation(P,B)),E){const{x:P,y:B,width:$,height:Y}=E,z=u.getIntersecting(P,B,$,Y);p.set(z.map(it=>it.id))}else p.set(u.all().map(P=>P.id));m.redraw()};return u.observe(I),()=>{var O;R.removeEventListener("pointermove",M),D.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",U),u.unobserve(I),m.destroy(),(O=R.parentNode)==null||O.removeChild(R)}}),r.$$set=w=>{"filter"in w&&e(2,n=w.filter),"state"in w&&e(3,o=w.state),"style"in w&&e(4,a=w.style),"viewer"in w&&e(5,l=w.viewer),"visible"in w&&e(6,h=w.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,n,o,a,l,h,m,s]}class xS extends se{constructor(t){super(),ie(this,t,vS,null,qt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const we=[];for(let r=0;r<256;++r)we.push((r+256).toString(16).slice(1));function bS(r,t=0){return(we[r[t+0]]+we[r[t+1]]+we[r[t+2]]+we[r[t+3]]+"-"+we[r[t+4]]+we[r[t+5]]+"-"+we[r[t+6]]+we[r[t+7]]+"-"+we[r[t+8]]+we[r[t+9]]+"-"+we[r[t+10]]+we[r[t+11]]+we[r[t+12]]+we[r[t+13]]+we[r[t+14]]+we[r[t+15]]).toLowerCase()}let Lh;const ES=new Uint8Array(16);function TS(){if(!Lh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Lh=crypto.getRandomValues.bind(crypto)}return Lh(ES)}const xm={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function wS(r,t,e){var s;if(xm.randomUUID&&!r)return xm.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??TS();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,bS(i)}var ni=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(ni||{});const Yo=(r,t)=>t,_s=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Dh=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)},Bh=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},AS=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},SS={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};Yo(ni.ELLIPSE,SS);const CS={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=Dh(s.points),a=n.reduce((l,h)=>l+Dh(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(Bh(n.points,t,e)){let a=!1;for(const l of o)if(Bh(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},IS=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return _s(t)},vs=r=>r.rings.map(e=>AS(e.points)).join(" ");Yo(ni.MULTIPOLYGLON,CS);const RS={area:r=>{const t=r.geometry.points;return Dh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Bh(i,t,e)}};Yo(ni.POLYGON,RS);const MS={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};Yo(ni.RECTANGLE,MS);const oe=" ";function OS(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===H.CLOSE_PATH)t+="z";else if(i.type===H.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===H.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===H.MOVE_TO)t+=(i.relative?"m":"M")+i.x+oe+i.y;else if(i.type===H.LINE_TO)t+=(i.relative?"l":"L")+i.x+oe+i.y;else if(i.type===H.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+oe+i.y1+oe+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===H.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===H.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+oe+i.y1+oe+i.x+oe+i.y;else if(i.type===H.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+oe+i.y;else if(i.type===H.ARC)t+=(i.relative?"a":"A")+i.rX+oe+i.rY+oe+i.xRot+oe+ +i.lArcFlag+oe+ +i.sweepFlag+oe+i.x+oe+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function Fh([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function lr(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const oi=Math.PI;function Uh(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*oi,[l,h]=Fh([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),p=i*h/s*d,f=-s*l/i*d,m=Fh([p,f],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-f)/s,(l-p)/i),r.phi2=Math.atan2((-h-f)/s,(-l-p)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*oi),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*oi),r.phi1*=180/oi,r.phi2*=180/oi}function bm(r,t,e){lr(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const Di=Math.PI/180;function Em(r,t,e){return(1-e)*r+e*t}function Tm(r,t,e,i){return r+Math.cos(i/180*oi)*t+Math.sin(i/180*oi)*e}function wm(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:PS(h/l,u/l,1e-6)}function Am(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function PS(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function NS(r,t,e){r.cX||Uh(r,t,e);const i=r.xRot/180*oi;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:H.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,p)=>{const[f,m]=Fh([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=Em(r.phi1,r.phi2,d/a),f=Em(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*Di/4),_=Math.cos(p*Di)-y*Math.sin(p*Di),v=Math.sin(p*Di)+y*Math.cos(p*Di),g=Math.cos(f*Di),x=Math.sin(f*Di),E=g+y*x,w=x-y*g,A=c(_,v),R=c(E,w),M=c(g,x),D={relative:r.relative,type:H.CURVE_TO,x:M[0],y:M[1],x1:A[0],y1:A[1],x2:R[0],y2:R[1]};r.relative&&(D.x1-=h,D.y1-=u,D.x2-=h,D.y2-=u,D.x-=h,D.y-=u),h=M[0],u=M[1],l[d]=D}return l}function kh(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function LS(r,t=!0){if(r.length<2)return r;const e=ae.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===H.MOVE_TO&&s.length>0&&(t?i.push(...Wo(s)):i.unshift(...Wo(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Wo(s)):i.unshift(...Wo(s))),i}function Wo(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===H.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:H.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case H.HORIZ_LINE_TO:i.push({type:H.HORIZ_LINE_TO,relative:!1,x:a.x});break;case H.VERT_LINE_TO:i.push({type:H.VERT_LINE_TO,relative:!1,y:a.y});break;case H.LINE_TO:case H.MOVE_TO:i.push({type:H.LINE_TO,relative:!1,x:a.x,y:a.y});break;case H.CURVE_TO:i.push({type:H.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case H.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case H.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case H.ARC:throw new Error("Unsupported command: A (arc)");case H.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:H.CLOSE_PATH}),i}function DS(r=1e13){lr(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function Sm(){return hr((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function BS(){return hr((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function FS(r=!0,t=!0,e=!0,i=!0){return hr((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&H.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&H.HORIZ_LINE_TO&&(s.type=H.LINE_TO,s.y=s.relative?0:o),e&&s.type&H.VERT_LINE_TO&&(s.type=H.LINE_TO,s.x=s.relative?0:n),r&&s.type&H.CLOSE_PATH&&(s.type=H.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&H.ARC&&(s.rX===0||s.rY===0)&&(s.type=H.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&H.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];kh(h,u,c)&&(s.type=H.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&H.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];kh(h,u,d)&&kh(h,c,d)&&(s.type=H.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Cm(){let r=NaN,t=NaN,e=NaN,i=NaN;return hr((s,n,o)=>(s.type&H.SMOOTH_CURVE_TO&&(s.type=H.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&H.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&H.SMOOTH_QUAD_TO&&(s.type=H.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&H.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Im(){let r=NaN,t=NaN;return hr((e,i,s)=>{if(e.type&H.SMOOTH_QUAD_TO&&(e.type=H.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&H.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=H.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function hr(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&H.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&H.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&H.MOVE_TO&&(i=t,s=e),a}}function US(r=0){lr(r);let t=NaN,e=NaN,i=NaN,s=NaN;return hr((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&H.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(H.CURVE_TO|H.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&H.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&H.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&H.LINE_COMMANDS||n.type&H.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&H.CURVE_TO||n.type&H.SMOOTH_CURVE_TO||n.type&H.QUAD_TO||n.type&H.SMOOTH_QUAD_TO){const f=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,p=isNaN(s)?typeof n.y1>"u"?p:n.relative?n.y:n.y1-a:s-a;const y=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,_=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(f)<=r&&u(m)<=r&&u(d)<=r&&u(p)<=r&&u(y)<=r&&u(_)<=r&&(c=!0)}return n.type&H.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function ai(r,t,e,i,s,n){return lr(r,t,e,i,s,n),hr((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),p=typeof o.x<"u"?o.x:d?0:a,f=typeof o.y<"u"?o.y:d?0:l;o.type&H.HORIZ_LINE_TO&&t!==0&&(o.type=H.LINE_TO,o.y=o.relative?0:l),o.type&H.VERT_LINE_TO&&e!==0&&(o.type=H.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+f*e+(d?0:s)),typeof o.y<"u"&&(o.y=p*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(_){return _*_}const y=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(y===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=H.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),E=1/m(o.rY),w=m(g)*x+m(v)*E,A=2*v*g*(x-E),R=m(v)*x+m(g)*E,M=w*i*i-A*t*i+R*t*t,D=A*(r*i+t*e)-2*(w*e*i+R*r*t),U=w*e*e-A*r*e+R*r*r,C=(Math.atan2(D,M-U)+Math.PI)%Math.PI/2,T=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(M*m(I)+D*T*I+U*m(T)),o.rY=Math.abs(y)/Math.sqrt(M*m(T)-D*T*I+U*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function kS(r,t=0,e=0){lr(r,t,e);const i=Math.sin(r),s=Math.cos(r);return ai(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function GS(r,t=0){return lr(r,t),ai(1,0,0,1,r,t)}function HS(r,t=r){return lr(r,t),ai(r,0,0,t,0,0)}function $S(r){return lr(r),ai(1,0,Math.tan(r),1,0,0)}function VS(r){return lr(r),ai(1,Math.tan(r),0,1,0,0)}function XS(r=0){return lr(r),ai(-1,0,0,1,r,0)}function YS(r=0){return lr(r),ai(1,0,0,-1,0,r)}function WS(){return hr((r,t,e)=>H.ARC===r.type?NS(r,r.relative?0:t,r.relative?0:e):r)}function jS(){return hr((r,t,e)=>(r.relative&&(t=0,e=0),H.ARC===r.type&&Uh(r,t,e),r))}function Rm(){return r=>({...r})}function zS(){const r=Rm(),t=Sm(),e=Im(),i=Cm(),s=hr((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&H.DRAWING_COMMANDS&&(h(o),u(a)),l.type&H.HORIZ_LINE_TO&&h(l.x),l.type&H.VERT_LINE_TO&&u(l.y),l.type&H.LINE_TO&&(h(l.x),u(l.y)),l.type&H.CURVE_TO){h(l.x),u(l.y);const c=wm(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(Am(o,l.x1,l.x2,l.x,p));const d=wm(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(Am(a,l.y1,l.y2,l.y,p))}if(l.type&H.ARC){h(l.x),u(l.y),Uh(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,p=Math.sin(c)*l.rX,f=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[y,_]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,w])=>{const R=Math.atan2(w,E)*180/Math.PI;return R<y?R+360:R},g=bm(f,-d,0).map(v);for(const E of g)E>y&&E<_&&h(Tm(l.cX,d,f,E));const x=bm(m,-p,0).map(v);for(const E of x)E>y&&E<_&&u(Tm(l.cY,p,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const ae={ROUND:DS,TO_ABS:Sm,TO_REL:BS,NORMALIZE_HVZ:FS,NORMALIZE_ST:Cm,QT_TO_C:Im,INFO:hr,SANITIZE:US,MATRIX:ai,ROTATE:kS,TRANSLATE:GS,SCALE:HS,SKEW_X:$S,SKEW_Y:VS,X_AXIS_SYMMETRY:XS,Y_AXIS_SYMMETRY:YS,A_TO_C:WS,ANNOTATE_ARCS:jS,CLONE:Rm,CALCULATE_BOUNDS:zS,REVERSE_PATH:LS};class Mm{round(t){return this.transform(ae.ROUND(t))}toAbs(){return this.transform(ae.TO_ABS())}toRel(){return this.transform(ae.TO_REL())}normalizeHVZ(t,e,i){return this.transform(ae.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(ae.NORMALIZE_ST())}qtToC(){return this.transform(ae.QT_TO_C())}aToC(){return this.transform(ae.A_TO_C())}sanitize(t){return this.transform(ae.SANITIZE(t))}translate(t,e){return this.transform(ae.TRANSLATE(t,e))}scale(t,e){return this.transform(ae.SCALE(t,e))}rotate(t,e,i){return this.transform(ae.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(ae.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(ae.SKEW_X(t))}skewY(t){return this.transform(ae.SKEW_Y(t))}xSymmetry(t){return this.transform(ae.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(ae.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(ae.ANNOTATE_ARCS())}}const qS=r=>r===" "||r===" "||r==="\r"||r===`
1149
- `,Om=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class KS extends Mm{constructor(){super();Gt(this,"curNumber","");Gt(this,"curCommandType",-1);Gt(this,"curCommandRelative",!1);Gt(this,"canParseCommandOrComma",!0);Gt(this,"curNumberHasExp",!1);Gt(this,"curNumberHasExpDigits",!1);Gt(this,"curNumberHasDecimal",!1);Gt(this,"curArgs",[])}finish(e=[]){if(this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e}parse(e,i=[]){const s=n=>{i.push(n),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let n=0;n<e.length;n++){const o=e[n],a=this.curCommandType===H.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=Om(o)&&(this.curNumber==="0"&&o==="0"||a);if(Om(o)&&!l){this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(o==="e"||o==="E"){this.curNumber+=o,this.curNumberHasExp=!0;continue}if((o==="-"||o==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=o;continue}if(o==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!a){this.curNumber+=o,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError(`Invalid number ending at ${n}`);if(this.curCommandType===H.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError(`Expected positive number, got "${h}" at index "${n}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${n}"`)}this.curArgs.push(h),this.curArgs.length===ZS[this.curCommandType]&&(H.HORIZ_LINE_TO===this.curCommandType?s({type:H.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):H.VERT_LINE_TO===this.curCommandType?s({type:H.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===H.MOVE_TO||this.curCommandType===H.LINE_TO||this.curCommandType===H.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),H.MOVE_TO===this.curCommandType&&(this.curCommandType=H.LINE_TO)):this.curCommandType===H.CURVE_TO?s({type:H.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===H.SMOOTH_CURVE_TO?s({type:H.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===H.QUAD_TO?s({type:H.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===H.ARC&&s({type:H.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!qS(o)){if(o===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(o==="+"||o==="-"||o==="."){this.curNumber=o,this.curNumberHasDecimal=o===".";continue}if(l){this.curNumber=o,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${n}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${o}" at index ${n}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,o==="z"||o==="Z"){i.push({type:H.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=H.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=H.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=H.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=H.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=H.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=H.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=H.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=H.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=H.ARC,this.curCommandRelative=o==="a";else throw new SyntaxError(`Unexpected character "${o}" at index ${n}.`)}}return i}transform(e){return Object.create(this,{parse:{value(s,n=[]){const o=Object.getPrototypeOf(this).parse.call(this,s);for(const a of o){const l=e(a);Array.isArray(l)?n.push(...l):n.push(l)}return n}}})}}const Nt=class Nt extends Mm{constructor(e){super();Gt(this,"commands");typeof e=="string"?this.commands=Nt.parse(e):this.commands=e}encode(){return Nt.encode(this.commands)}getBounds(){const e=ae.CALCULATE_BOUNDS();return this.transform(e),e}transform(e){const i=[];for(const s of this.commands){const n=e(s);Array.isArray(n)?i.push(...n):i.push(n)}return this.commands=i,this}reverse(e=!0){return this.commands=ae.REVERSE_PATH(this.commands,e),this}static encode(e){return OS(e)}static parse(e){const i=new KS,s=[];return i.parse(e,s),i.finish(s),s}};Gt(Nt,"CLOSE_PATH",1),Gt(Nt,"MOVE_TO",2),Gt(Nt,"HORIZ_LINE_TO",4),Gt(Nt,"VERT_LINE_TO",8),Gt(Nt,"LINE_TO",16),Gt(Nt,"CURVE_TO",32),Gt(Nt,"SMOOTH_CURVE_TO",64),Gt(Nt,"QUAD_TO",128),Gt(Nt,"SMOOTH_QUAD_TO",256),Gt(Nt,"ARC",512),Gt(Nt,"LINE_COMMANDS",Nt.LINE_TO|Nt.HORIZ_LINE_TO|Nt.VERT_LINE_TO),Gt(Nt,"DRAWING_COMMANDS",Nt.HORIZ_LINE_TO|Nt.VERT_LINE_TO|Nt.LINE_TO|Nt.CURVE_TO|Nt.SMOOTH_CURVE_TO|Nt.QUAD_TO|Nt.SMOOTH_QUAD_TO|Nt.ARC);let H=Nt;const ZS={[H.MOVE_TO]:2,[H.LINE_TO]:2,[H.HORIZ_LINE_TO]:1,[H.VERT_LINE_TO]:1,[H.CLOSE_PATH]:0,[H.QUAD_TO]:4,[H.SMOOTH_QUAD_TO]:2,[H.CURVE_TO]:6,[H.SMOOTH_CURVE_TO]:4,[H.ARC]:7},QS=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},Gh=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},Pm=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,JS=r=>({}),Nm=r=>({grab:r[0]});function tC(r){let t,e,i,s;const n=r[8].default,o=Sc(n,r,r[7],Nm);return{c(){t=ht("g"),o&&o.c(),S(t,"class","a9s-annotation selected")},m(a,l){lt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[$t(t,"pointerup",r[2]),$t(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Rc(o,n,a,a[7],e?Ic(n,a[7],l,JS):Mc(a[7]),Nm)},i(a){e||(K(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&&ot(t),o&&o.d(a),i=!1,Je(s)}}}function eC(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Bs();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const p=y=>_=>{if(u=y,h){const{left:g,top:x}=h.getBoundingClientRect(),E=_.clientX-g,w=_.clientY-x;c=l.elementToImage(E,w)}else{const{offsetX:g,offsetY:x}=_;c=l.elementToImage(g,x)}d=o,_.target.setPointerCapture(_.pointerId),n("grab",_)},f=y=>{if(u){const[_,v]=l.elementToImage(y.offsetX,y.offsetY),g=[_-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=y=>{y.target.releasePointerCapture(y.pointerId),u=void 0,d=o,n("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,s=y.$$scope)},[p,f,m,o,a,l,h,s,i]}class Hh extends se{constructor(t){super(),ie(this,t,eC,tC,qt,{shape:3,editor:4,transform:5,svgEl:6})}}function rC(r){let t,e,i,s,n,o,a,l,h=r[3]&&Lm(r);return{c(){t=ht("g"),e=ht("circle"),h&&h.c(),s=ht("circle"),S(e,"class","a9s-handle-buffer svelte-19vpcvx"),S(e,"cx",r[0]),S(e,"cy",r[1]),S(e,"r",i=r[4]+6/r[2]),S(s,"class",n=On(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-19vpcvx"),S(s,"cx",r[0]),S(s,"cy",r[1]),S(s,"r",r[4]),S(t,"class",o=On(`a9s-handle ${r[7].class||""}`.trim())+" svelte-19vpcvx")},m(u,c){lt(u,t,c),Rt(t,e),h&&h.m(t,null),Rt(t,s),a||(l=[$t(e,"pointerenter",r[8]),$t(e,"pointerleave",r[9]),$t(e,"pointerdown",r[10]),$t(e,"pointerdown",r[5]),$t(e,"pointerup",r[11]),$t(e,"pointerup",r[6])],a=!0)},p(u,c){c&1&&S(e,"cx",u[0]),c&2&&S(e,"cy",u[1]),c&20&&i!==(i=u[4]+6/u[2])&&S(e,"r",i),u[3]?h?h.p(u,c):(h=Lm(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=On(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-19vpcvx")&&S(s,"class",n),c&1&&S(s,"cx",u[0]),c&2&&S(s,"cy",u[1]),c&16&&S(s,"r",u[4]),c&128&&o!==(o=On(`a9s-handle ${u[7].class||""}`.trim())+" svelte-19vpcvx")&&S(t,"class",o)},d(u){u&&ot(t),h&&h.d(),a=!1,Je(l)}}}function iC(r){let t,e;return{c(){t=ht("circle"),S(t,"cx",r[0]),S(t,"cy",r[1]),S(t,"r",e=2*r[4])},m(i,s){lt(i,t,s)},p(i,s){s&1&&S(t,"cx",i[0]),s&2&&S(t,"cy",i[1]),s&16&&e!==(e=2*i[4])&&S(t,"r",e)},d(i){i&&ot(t)}}}function Lm(r){let t,e;return{c(){t=ht("circle"),S(t,"class","a9s-handle-selected svelte-19vpcvx"),S(t,"cx",r[0]),S(t,"cy",r[1]),S(t,"r",e=r[4]+6/r[2])},m(i,s){lt(i,t,s)},p(i,s){s&1&&S(t,"cx",i[0]),s&2&&S(t,"cy",i[1]),s&20&&e!==(e=i[4]+6/i[2])&&S(t,"r",e)},d(i){i&&ot(t)}}}function sC(r){let t;function e(n,o){return Pm?iC:rC}let s=e()(r);return{c(){s.c(),t=Ue()},m(n,o){s.m(n,o),lt(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&ot(t),s.d(n)}}}function nC(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t;const l=f=>{f.pointerType},h=()=>!1;function u(f){ke.call(this,r,f)}function c(f){ke.call(this,r,f)}function d(f){ke.call(this,r,f)}function p(f){ke.call(this,r,f)}return r.$$set=f=>{e(7,t=Ra(Ra({},t),Oc(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"selected"in f&&e(3,a=f.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(4,i=4/o)},t=Oc(t),[s,n,o,a,i,l,h,t,u,c,d,p]}class xs extends se{constructor(t){super(),ie(this,t,nC,sC,qt,{x:0,y:1,scale:2,selected:3})}}function oC(r){let t,e,i,s,n,o,a;return{c(){t=ht("g"),e=ht("circle"),s=ht("circle"),n=ht("circle"),S(e,"class","a9s-polygon-midpoint-buffer svelte-12ykj76"),S(e,"cx",r[0]),S(e,"cy",r[1]),S(e,"r",i=1.75*r[2]),S(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),S(s,"cx",r[0]),S(s,"cy",r[1]),S(s,"r",r[2]),S(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),S(n,"cx",r[0]),S(n,"cy",r[1]),S(n,"r",r[2]),S(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){lt(l,t,h),Rt(t,e),Rt(t,s),Rt(t,n),o||(a=[$t(e,"pointerdown",r[5]),$t(e,"pointerdown",r[3])],o=!0)},p(l,h){h&1&&S(e,"cx",l[0]),h&2&&S(e,"cy",l[1]),h&4&&i!==(i=1.75*l[2])&&S(e,"r",i),h&1&&S(s,"cx",l[0]),h&2&&S(s,"cy",l[1]),h&4&&S(s,"r",l[2]),h&1&&S(n,"cx",l[0]),h&2&&S(n,"cy",l[1]),h&4&&S(n,"r",l[2])},d(l){l&&ot(t),o=!1,Je(a)}}}function aC(r){let t;return{c(){t=ht("circle"),S(t,"cx",r[0]),S(t,"cy",r[1]),S(t,"r",r[2])},m(e,i){lt(e,t,i)},p(e,i){i&1&&S(t,"cx",e[0]),i&2&&S(t,"cy",e[1]),i&4&&S(t,"r",e[2])},d(e){e&&ot(t)}}}function lC(r){let t;function e(n,o){return Pm?aC:oC}let s=e()(r);return{c(){s.c(),t=Ue()},m(n,o){s.m(n,o),lt(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&ot(t),s.d(n)}}}function hC(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){ke.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class uC extends se{constructor(t){super(),ie(this,t,hC,lC,qt,{x:0,y:1,scale:4})}}function $h(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Dm(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function Vh(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Xh(r){const t=r.slice(),e=t[11][t[7]];return t[30]=e.point,t}function Bm(r){let t,e,i,s;return{c(){t=ht("circle"),S(t,"cx",e=r[30][0]),S(t,"cy",i=r[30][1]),S(t,"r",s=cn/r[3]),S(t,"class","svelte-1h2slbm")},m(n,o){lt(n,t,o)},p(n,o){o[0]&2176&&e!==(e=n[30][0])&&S(t,"cx",e),o[0]&2176&&i!==(i=n[30][1])&&S(t,"cy",i),o[0]&8&&s!==(s=cn/n[3])&&S(t,"r",s)},d(n){n&&ot(t)}}}function Fm(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=ht("mask"),e=ht("rect"),a=ht("circle"),S(e,"x",i=r[10].x),S(e,"y",s=r[10].y),S(e,"width",n=r[10].w),S(e,"height",o=r[10].h),S(e,"class","svelte-1h2slbm"),S(a,"cx",l=r[30][0]),S(a,"cy",h=r[30][1]),S(a,"r",u=cn/r[3]),S(a,"class","svelte-1h2slbm"),S(t,"id",`${r[20]}-inner`),S(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){lt(c,t,d),Rt(t,e),Rt(t,a)},p(c,d){d[0]&1024&&i!==(i=c[10].x)&&S(e,"x",i),d[0]&1024&&s!==(s=c[10].y)&&S(e,"y",s),d[0]&1024&&n!==(n=c[10].w)&&S(e,"width",n),d[0]&1024&&o!==(o=c[10].h)&&S(e,"height",o),d[0]&2176&&l!==(l=c[30][0])&&S(a,"cx",l),d[0]&2176&&h!==(h=c[30][1])&&S(a,"cy",h),d[0]&8&&u!==(u=cn/c[3])&&S(a,"r",u)},d(c){c&&ot(t)}}}function Um(r){let t,e;return t=new xs({props:{class:"a9s-corner-handle",x:r[30][0],y:r[30][1],scale:r[3],selected:r[9].includes(r[32])}}),t.$on("pointerenter",r[12]),t.$on("pointerleave",r[13]),t.$on("pointerdown",r[16]),t.$on("pointerdown",function(){re(r[29](`HANDLE-${r[32]}`))&&r[29](`HANDLE-${r[32]}`).apply(this,arguments)}),t.$on("pointerup",r[17](r[32])),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[30][0]),s[0]&32&&(n.y=r[30][1]),s[0]&8&&(n.scale=r[3]),s[0]&512&&(n.selected=r[9].includes(r[32])),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function km(r){let t,e;return t=new uC({props:{x:r[30][0],y:r[30][1],scale:r[3]}}),t.$on("pointerdown",function(){re(r[19](r[7]))&&r[19](r[7]).apply(this,arguments)}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&2176&&(n.x=r[30][0]),s[0]&2176&&(n.y=r[30][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function cC(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,E,w=r[7]!==void 0&&!r[8]&&Bm(Xh(r)),A=r[7]!==void 0&&!r[8]&&Fm(Vh(r)),R=Ce(r[5].points),M=[];for(let C=0;C<R.length;C+=1)M[C]=Um(Dm(r,R,C));const D=C=>ut(M[C],1,1,()=>{M[C]=null});let U=r[7]!==void 0&&!r[8]&&km($h(r));return{c(){t=ht("defs"),e=ht("mask"),i=ht("rect"),l=ht("polygon"),w&&w.c(),A&&A.c(),u=Fe(),c=ht("polygon"),p=Fe(),f=ht("polygon"),y=Fe();for(let C=0;C<M.length;C+=1)M[C].c();_=Fe(),U&&U.c(),v=Ue(),S(i,"x",s=r[10].x),S(i,"y",n=r[10].y),S(i,"width",o=r[10].w),S(i,"height",a=r[10].h),S(i,"class","svelte-1h2slbm"),S(l,"points",h=r[5].points.map(Gm).join(" ")),S(l,"class","svelte-1h2slbm"),S(e,"id",`${r[20]}-outer`),S(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),S(c,"class","a9s-outer"),S(c,"mask",`url(#${r[20]}-outer)`),S(c,"points",d=r[5].points.map(Hm).join(" ")),S(f,"class","a9s-inner a9s-shape-handle"),S(f,"mask",`url(#${r[20]}-inner)`),S(f,"style",r[1]),S(f,"points",m=r[5].points.map($m).join(" "))},m(C,T){lt(C,t,T),Rt(t,e),Rt(e,i),Rt(e,l),w&&w.m(e,null),A&&A.m(t,null),lt(C,u,T),lt(C,c,T),lt(C,p,T),lt(C,f,T),r[21](f),lt(C,y,T);for(let I=0;I<M.length;I+=1)M[I]&&M[I].m(C,T);lt(C,_,T),U&&U.m(C,T),lt(C,v,T),g=!0,x||(E=[$t(c,"pointerup",r[15]),$t(c,"pointerdown",function(){re(r[29]("SHAPE"))&&r[29]("SHAPE").apply(this,arguments)}),$t(f,"pointermove",r[14]),$t(f,"pointerup",r[15]),$t(f,"pointerdown",function(){re(r[29]("SHAPE"))&&r[29]("SHAPE").apply(this,arguments)})],x=!0)},p(C,T){if(r=C,(!g||T[0]&1024&&s!==(s=r[10].x))&&S(i,"x",s),(!g||T[0]&1024&&n!==(n=r[10].y))&&S(i,"y",n),(!g||T[0]&1024&&o!==(o=r[10].w))&&S(i,"width",o),(!g||T[0]&1024&&a!==(a=r[10].h))&&S(i,"height",a),(!g||T[0]&32&&h!==(h=r[5].points.map(Gm).join(" ")))&&S(l,"points",h),r[7]!==void 0&&!r[8]?w?w.p(Xh(r),T):(w=Bm(Xh(r)),w.c(),w.m(e,null)):w&&(w.d(1),w=null),r[7]!==void 0&&!r[8]?A?A.p(Vh(r),T):(A=Fm(Vh(r)),A.c(),A.m(t,null)):A&&(A.d(1),A=null),(!g||T[0]&32&&d!==(d=r[5].points.map(Hm).join(" ")))&&S(c,"points",d),(!g||T[0]&2)&&S(f,"style",r[1]),(!g||T[0]&32&&m!==(m=r[5].points.map($m).join(" ")))&&S(f,"points",m),T[0]&537080360){R=Ce(r[5].points);let I;for(I=0;I<R.length;I+=1){const N=Dm(r,R,I);M[I]?(M[I].p(N,T),K(M[I],1)):(M[I]=Um(N),M[I].c(),K(M[I],1),M[I].m(_.parentNode,_))}for(xe(),I=R.length;I<M.length;I+=1)D(I);be()}r[7]!==void 0&&!r[8]?U?(U.p($h(r),T),T[0]&384&&K(U,1)):(U=km($h(r)),U.c(),K(U,1),U.m(v.parentNode,v)):U&&(xe(),ut(U,1,1,()=>{U=null}),be())},i(C){if(!g){for(let T=0;T<R.length;T+=1)K(M[T]);K(U),g=!0}},o(C){M=M.filter(Boolean);for(let T=0;T<M.length;T+=1)ut(M[T]);ut(U),g=!1},d(C){C&&(ot(t),ot(u),ot(c),ot(p),ot(f),ot(y),ot(_),ot(v)),w&&w.d(),A&&A.d(),r[21](null),Xr(M,C),U&&U.d(C),x=!1,Je(E)}}}function dC(r){let t,e;return t=new Hh({props:{shape:r[0],transform:r[2],editor:r[18],svgEl:r[4],$$slots:{default:[cC,({grab:i})=>({29:i}),({grab:i})=>[i?536870912:0]]},$$scope:{ctx:r}}}),t.$on("change",r[22]),t.$on("grab",r[23]),t.$on("release",r[24]),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&536874986|s[1]&4&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}const fC=250,pC=1e3,mC=12,cn=4.5,Gm=r=>r.join(","),Hm=r=>r.join(","),$m=r=>r.join(",");function gC(r,t,e){let i,s,n;const o=Bs();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p,f=!1,m,y=[];const _=()=>e(8,f=!0),v=()=>e(8,f=!1),g=O=>{if(y.length>0){e(7,p=void 0);return}const[L,F]=h.elementToImage(O.offsetX,O.offsetY),V=z=>Math.pow(z[0]-L,2)+Math.pow(z[1]-F,2),P=i.points.reduce((z,it)=>V(it)<V(z)?it:z),B=s.filter(z=>z.visible).reduce((z,it)=>V(it.point)<V(z.point)?it:z),$=Math.pow(pC/u,2);V(P)<$||V(B.point)<$?e(7,p=s.indexOf(B)):e(7,p=void 0)},x=()=>{document.activeElement!==c&&c.focus()},E=()=>{e(9,y=[]),x()},w=O=>{e(8,f=!0),O.preventDefault(),O.stopPropagation(),m=performance.now()},A=O=>L=>{if(!m||performance.now()-m>fC)return;const F=y.includes(O);L.metaKey||L.ctrlKey||L.shiftKey?F?e(9,y=y.filter(V=>V!==O)):e(9,y=[...y,O]):F&&y.length>1?e(9,y=[O]):F?e(9,y=[]):e(9,y=[O]),x()},R=(O,L,F)=>{x();let V;const P=O.geometry;y.length>1?V=P.points.map(([$,Y],z)=>y.includes(z)?[$+F[0],Y+F[1]]:[$,Y]):L==="SHAPE"?V=P.points.map(([$,Y])=>[$+F[0],Y+F[1]]):V=P.points.map(([$,Y],z)=>L===`HANDLE-${z}`?[$+F[0],Y+F[1]]:[$,Y]);const B=_s(V);return{...O,geometry:{points:V,bounds:B}}},M=O=>async L=>{L.stopPropagation();const F=[...i.points.slice(0,O+1),s[O].point,...i.points.slice(O+1)],V=_s(F);o("change",{...a,geometry:{points:F,bounds:V}}),await hv();const P=[...document.querySelectorAll(".a9s-handle")][O+1];if(P!=null&&P.firstChild){const B=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});P.firstChild.dispatchEvent(B)}},D=()=>{if(i.points.length<4)return;const O=i.points.filter((F,V)=>!y.includes(V)),L=_s(O);o("change",{...a,geometry:{points:O,bounds:L}}),e(9,y=[])};Ds(()=>{const O=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),D())};return c.addEventListener("pointermove",g),c.addEventListener("keydown",O),()=>{c.removeEventListener("pointermove",g),c.removeEventListener("keydown",O)}});const U=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function C(O){Fs[O?"unshift":"push"](()=>{d=O,e(6,d)})}function T(O){ke.call(this,r,O)}function I(O){ke.call(this,r,O)}function N(O){ke.call(this,r,O)}return r.$$set=O=>{"shape"in O&&e(0,a=O.shape),"computedStyle"in O&&e(1,l=O.computedStyle),"transform"in O&&e(2,h=O.transform),"viewportScale"in O&&e(3,u=O.viewportScale),"svgEl"in O&&e(4,c=O.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(11,s=i.points.map((O,L)=>{const F=L===i.points.length-1?i.points[0]:i.points[L+1],V=(O[0]+F[0])/2,P=(O[1]+F[1])/2,$=Math.sqrt(Math.pow(F[0]-V,2)+Math.pow(F[1]-P,2))>mC/u;return{point:[V,P],visible:$}})),r.$$.dirty[0]&40&&e(10,n=Gh(i.bounds,cn/u))},[a,l,h,u,c,i,d,p,f,y,n,s,_,v,g,E,w,A,R,M,U,C,T,I,N]}class yC extends se{constructor(t){super(),ie(this,t,gC,dC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function _C(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,E,w,A,R,M,D,U,C,T,I,N,O,L,F,V,P,B,$,Y,z,it,xt,Ct,q,wt,ft,gt,vt,It,Ot,pe,jt,J,ze,dn;return ft=new xs({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),ft.$on("pointerdown",function(){re(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new xs({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){re(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Ot=new xs({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Ot.$on("pointerdown",function(){re(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),jt=new xs({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),jt.$on("pointerdown",function(){re(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=ht("defs"),e=ht("mask"),i=ht("rect"),l=ht("rect"),p=Fe(),f=ht("rect"),g=Fe(),x=ht("rect"),M=Fe(),D=ht("rect"),I=Fe(),N=ht("rect"),V=Fe(),P=ht("rect"),z=Fe(),it=ht("rect"),wt=Fe(),Vt(ft.$$.fragment),gt=Fe(),Vt(vt.$$.fragment),It=Fe(),Vt(Ot.$$.fragment),pe=Fe(),Vt(jt.$$.fragment),S(i,"class","rect-mask-bg svelte-1njczvj"),S(i,"x",s=r[6].x),S(i,"y",n=r[6].y),S(i,"width",o=r[6].w),S(i,"height",a=r[6].h),S(l,"class","rect-mask-fg svelte-1njczvj"),S(l,"x",h=r[5].x),S(l,"y",u=r[5].y),S(l,"width",c=r[5].w),S(l,"height",d=r[5].h),S(e,"id",r[8]),S(e,"class","a9s-rectangle-editor-mask svelte-1njczvj"),S(f,"class","a9s-outer"),S(f,"mask",`url(#${r[8]})`),S(f,"x",m=r[5].x),S(f,"y",y=r[5].y),S(f,"width",_=r[5].w),S(f,"height",v=r[5].h),S(x,"class","a9s-inner a9s-shape-handle"),S(x,"style",r[1]),S(x,"x",E=r[5].x),S(x,"y",w=r[5].y),S(x,"width",A=r[5].w),S(x,"height",R=r[5].h),S(D,"class","a9s-edge-handle a9s-edge-handle-top"),S(D,"x",U=r[5].x),S(D,"y",C=r[5].y),S(D,"height",1),S(D,"width",T=r[5].w),S(N,"class","a9s-edge-handle a9s-edge-handle-right"),S(N,"x",O=r[5].x+r[5].w),S(N,"y",L=r[5].y),S(N,"height",F=r[5].h),S(N,"width",1),S(P,"class","a9s-edge-handle a9s-edge-handle-bottom"),S(P,"x",B=r[5].x),S(P,"y",$=r[5].y+r[5].h),S(P,"height",1),S(P,"width",Y=r[5].w),S(it,"class","a9s-edge-handle a9s-edge-handle-left"),S(it,"x",xt=r[5].x),S(it,"y",Ct=r[5].y),S(it,"height",q=r[5].h),S(it,"width",1)},m(W,G){lt(W,t,G),Rt(t,e),Rt(e,i),Rt(e,l),lt(W,p,G),lt(W,f,G),lt(W,g,G),lt(W,x,G),lt(W,M,G),lt(W,D,G),lt(W,I,G),lt(W,N,G),lt(W,V,G),lt(W,P,G),lt(W,z,G),lt(W,it,G),lt(W,wt,G),Ut(ft,W,G),lt(W,gt,G),Ut(vt,W,G),lt(W,It,G),Ut(Ot,W,G),lt(W,pe,G),Ut(jt,W,G),J=!0,ze||(dn=[$t(f,"pointerdown",function(){re(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),$t(x,"pointerdown",function(){re(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),$t(D,"pointerdown",function(){re(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),$t(N,"pointerdown",function(){re(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),$t(P,"pointerdown",function(){re(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),$t(it,"pointerdown",function(){re(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],ze=!0)},p(W,G){r=W,(!J||G&64&&s!==(s=r[6].x))&&S(i,"x",s),(!J||G&64&&n!==(n=r[6].y))&&S(i,"y",n),(!J||G&64&&o!==(o=r[6].w))&&S(i,"width",o),(!J||G&64&&a!==(a=r[6].h))&&S(i,"height",a),(!J||G&32&&h!==(h=r[5].x))&&S(l,"x",h),(!J||G&32&&u!==(u=r[5].y))&&S(l,"y",u),(!J||G&32&&c!==(c=r[5].w))&&S(l,"width",c),(!J||G&32&&d!==(d=r[5].h))&&S(l,"height",d),(!J||G&32&&m!==(m=r[5].x))&&S(f,"x",m),(!J||G&32&&y!==(y=r[5].y))&&S(f,"y",y),(!J||G&32&&_!==(_=r[5].w))&&S(f,"width",_),(!J||G&32&&v!==(v=r[5].h))&&S(f,"height",v),(!J||G&2)&&S(x,"style",r[1]),(!J||G&32&&E!==(E=r[5].x))&&S(x,"x",E),(!J||G&32&&w!==(w=r[5].y))&&S(x,"y",w),(!J||G&32&&A!==(A=r[5].w))&&S(x,"width",A),(!J||G&32&&R!==(R=r[5].h))&&S(x,"height",R),(!J||G&32&&U!==(U=r[5].x))&&S(D,"x",U),(!J||G&32&&C!==(C=r[5].y))&&S(D,"y",C),(!J||G&32&&T!==(T=r[5].w))&&S(D,"width",T),(!J||G&32&&O!==(O=r[5].x+r[5].w))&&S(N,"x",O),(!J||G&32&&L!==(L=r[5].y))&&S(N,"y",L),(!J||G&32&&F!==(F=r[5].h))&&S(N,"height",F),(!J||G&32&&B!==(B=r[5].x))&&S(P,"x",B),(!J||G&32&&$!==($=r[5].y+r[5].h))&&S(P,"y",$),(!J||G&32&&Y!==(Y=r[5].w))&&S(P,"width",Y),(!J||G&32&&xt!==(xt=r[5].x))&&S(it,"x",xt),(!J||G&32&&Ct!==(Ct=r[5].y))&&S(it,"y",Ct),(!J||G&32&&q!==(q=r[5].h))&&S(it,"height",q);const Dr={};G&32&&(Dr.x=r[5].x),G&32&&(Dr.y=r[5].y),G&8&&(Dr.scale=r[3]),ft.$set(Dr);const Br={};G&32&&(Br.x=r[5].x+r[5].w),G&32&&(Br.y=r[5].y),G&8&&(Br.scale=r[3]),vt.$set(Br);const Fr={};G&32&&(Fr.x=r[5].x+r[5].w),G&32&&(Fr.y=r[5].y+r[5].h),G&8&&(Fr.scale=r[3]),Ot.$set(Fr);const Ur={};G&32&&(Ur.x=r[5].x),G&32&&(Ur.y=r[5].y+r[5].h),G&8&&(Ur.scale=r[3]),jt.$set(Ur)},i(W){J||(K(ft.$$.fragment,W),K(vt.$$.fragment,W),K(Ot.$$.fragment,W),K(jt.$$.fragment,W),J=!0)},o(W){ut(ft.$$.fragment,W),ut(vt.$$.fragment,W),ut(Ot.$$.fragment,W),ut(jt.$$.fragment,W),J=!1},d(W){W&&(ot(t),ot(p),ot(f),ot(g),ot(x),ot(M),ot(D),ot(I),ot(N),ot(V),ot(P),ot(z),ot(it),ot(wt),ot(gt),ot(It),ot(pe)),kt(ft,W),kt(vt,W),kt(Ot,W),kt(jt,W),ze=!1,Je(dn)}}}function vC(r){let t,e;return t=new Hh({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[_C,({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(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function xC(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,y,_)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,w]=[v.maxX,v.maxY];const[A,R]=_;if(y==="SHAPE")g+=A,E+=A,x+=R,w+=R;else{switch(y){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{w+=R;break}}switch(y){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=A;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=A;break}}}const M=Math.min(g,E),D=Math.min(x,w),U=Math.abs(E-g),C=Math.abs(w-x);return{...m,geometry:{x:M,y:D,w:U,h:C,bounds:{minX:M,minY:D,maxX:M+U,maxY:D+C}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){ke.call(this,r,m)}function p(m){ke.call(this,r,m)}function f(m){ke.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=Gh(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class bC extends se{constructor(t){super(),ie(this,t,xC,vC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}function Vm(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function Xm(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function Ym(r,t,e){const i=r.slice();return i[19]=t[e],i[21]=e,i}function Wm(r){let t,e;return t=new xs({props:{class:"a9s-corner-handle",x:r[19][0],y:r[19][1],scale:r[3]}}),t.$on("pointerdown",function(){re(r[12](`HANDLE-${r[15]}-${r[18]}-${r[21]}`))&&r[12](`HANDLE-${r[15]}-${r[18]}-${r[21]}`).apply(this,arguments)}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){r=i;const n={};s&32&&(n.x=r[19][0]),s&32&&(n.y=r[19][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function jm(r){let t,e,i=Ce(r[16].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=Wm(Ym(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ue()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a&4136){i=Ce(o[16].points);let l;for(l=0;l<i.length;l+=1){const h=Ym(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=Wm(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(xe(),l=i.length;l<s.length;l+=1)n(l);be()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ot(t),Xr(s,o)}}}function zm(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v=Ce(r[13].rings),g=[];for(let E=0;E<v.length;E+=1)g[E]=jm(Xm(r,v,E));const x=E=>ut(g[E],1,1,()=>{g[E]=null});return{c(){t=ht("g"),e=ht("defs"),i=ht("mask"),s=ht("rect"),h=ht("path"),c=ht("path"),p=ht("path");for(let E=0;E<g.length;E+=1)g[E].c();S(s,"x",n=r[6].x),S(s,"y",o=r[6].y),S(s,"width",a=r[6].w),S(s,"height",l=r[6].h),S(s,"class","svelte-rfq8ys"),S(h,"d",u=vs(r[13])),S(h,"class","svelte-rfq8ys"),S(i,"id",`${r[8]}-${r[15]}`),S(i,"class","a9s-multipolygon-editor-mask svelte-rfq8ys"),S(c,"class","a9s-outer"),S(c,"mask",`url(#${r[8]}-${r[15]})`),S(c,"fill-rule","evenodd"),S(c,"d",d=vs(r[13])),S(p,"class","a9s-inner"),S(p,"style",r[1]),S(p,"fill-rule","evenodd"),S(p,"d",f=vs(r[13]))},m(E,w){lt(E,t,w),Rt(t,e),Rt(e,i),Rt(i,s),Rt(i,h),Rt(t,c),Rt(t,p);for(let A=0;A<g.length;A+=1)g[A]&&g[A].m(t,null);m=!0,y||(_=[$t(c,"pointerdown",function(){re(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),$t(p,"pointerdown",function(){re(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)})],y=!0)},p(E,w){if(r=E,(!m||w&64&&n!==(n=r[6].x))&&S(s,"x",n),(!m||w&64&&o!==(o=r[6].y))&&S(s,"y",o),(!m||w&64&&a!==(a=r[6].w))&&S(s,"width",a),(!m||w&64&&l!==(l=r[6].h))&&S(s,"height",l),(!m||w&32&&u!==(u=vs(r[13])))&&S(h,"d",u),(!m||w&32&&d!==(d=vs(r[13])))&&S(c,"d",d),(!m||w&2)&&S(p,"style",r[1]),(!m||w&32&&f!==(f=vs(r[13])))&&S(p,"d",f),w&4136){v=Ce(r[13].rings);let A;for(A=0;A<v.length;A+=1){const R=Xm(r,v,A);g[A]?(g[A].p(R,w),K(g[A],1)):(g[A]=jm(R),g[A].c(),K(g[A],1),g[A].m(t,null))}for(xe(),A=v.length;A<g.length;A+=1)x(A);be()}},i(E){if(!m){for(let w=0;w<v.length;w+=1)K(g[w]);m=!0}},o(E){g=g.filter(Boolean);for(let w=0;w<g.length;w+=1)ut(g[w]);m=!1},d(E){E&&ot(t),Xr(g,E),y=!1,Je(_)}}}function EC(r){let t,e,i=Ce(r[5].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=zm(Vm(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ue()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a&4458){i=Ce(o[5].polygons);let l;for(l=0;l<i.length;l+=1){const h=Vm(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=zm(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(xe(),l=i.length;l<s.length;l+=1)n(l);be()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ot(t),Xr(s,o)}}}function TC(r){let t,e;return t=new Hh({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[EC,({grab:i})=>({12:i}),({grab:i})=>i?4096:0]},$$scope:{ctx:r}}}),t.$on("change",r[9]),t.$on("grab",r[10]),t.$on("release",r[11]),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&4198506&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function wC(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,y,_)=>{const v=m.geometry.polygons;let g;if(y==="SHAPE")g=v.map(x=>{const E=x.rings.map((A,R)=>({points:A.points.map((D,U)=>[D[0]+_[0],D[1]+_[1]])})),w=_s(E[0].points);return{rings:E,bounds:w}});else{const[x,E,w,A]=y.split("-").map(R=>parseInt(R));g=v.map((R,M)=>{if(M===E){const D=R.rings.map((C,T)=>T===w?{points:C.points.map((N,O)=>O===A?[N[0]+_[0],N[1]+_[1]]:N)}:C),U=_s(D[0].points);return{rings:D,bounds:U}}else return R})}return{...m,geometry:{polygons:g,bounds:IS(g)}}},c=`multipoly-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){ke.call(this,r,m)}function p(m){ke.call(this,r,m)}function f(m){ke.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=Gh(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class AC extends se{constructor(t){super(),ie(this,t,wC,TC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}ni.RECTANGLE,ni.POLYGON,ni.MULTIPOLYGLON;function SC(r,t,e){let i;const s=Bs();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return Ds(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=QS(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class CC extends se{constructor(t){super(),ie(this,t,SC,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const qm=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const n=(e.selected||[]).map(o=>o.id);return n.includes(r)?n.filter(o=>o!==r):[...n,r]}else return r},IC=r=>({transform:r&2,scale:r&1}),Km=r=>({transform:r[1],scale:r[0]});function RC(r){let t;const e=r[4].default,i=Sc(e,r,r[3],Km);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Rc(i,e,s,s[3],t?Ic(e,s[3],n,IC):Mc(s[3]),Km)},i(s){t||(K(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function MC(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Ae.Point(0,0),!0);c&&(d.x=h-d.x);const p=u*h/n.world.getContentFactor(),f=c?-p:p,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${f}, ${p}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return Ds(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class Yh extends se{constructor(t){super(),ie(this,t,MC,RC,qt,{viewer:2})}}function OC(r,t,e){const i=Bs();let{drawingMode:s}=t,{opts:n}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:u}=t,c;return Ds(()=>{const d=o.closest("svg"),p=[],f=(m,y,_)=>{if(d==null||d.addEventListener(m,y,_),p.push(()=>d==null?void 0:d.removeEventListener(m,y,_)),m==="pointerup"||m==="dblclick"){const v=x=>{const{originalEvent:E}=x;y(E)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,v),p.push(()=>h.removeHandler(g,v))}else if(m==="pointermove"){const v=g=>{const{originalEvent:x}=g;y(x)};h.addHandler("canvas-drag",v),p.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,c=new a({target:o,props:{addEventListener:f,drawingMode:s,opts:n,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",m=>i("create",m.detail)),()=>{p.forEach(m=>m()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,s=d.drawingMode),"opts"in d&&e(1,n=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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[s,n,o,a,l,h,u,c]}class PC extends se{constructor(t){super(),ie(this,t,OC,null,qt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}function Zm(r,t,e){const i=r.slice();i[35]=t[e];const s=i[16](i[35].target.selector);return i[36]=s,i}function NC(r){let t=`${r[2]}-${r[6]}`,e,i,s=Qm(r);return{c(){s.c(),e=Ue()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&68&&qt(t,t=`${n[2]}-${n[6]}`)?(xe(),ut(s,1,1,Qt),be(),s=Qm(n),s.c(),K(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(K(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function LC(r){let t,e,i=Ce(r[8].filter(r[26])),s=[];for(let o=0;o<i.length;o+=1)s[o]=eg(Zm(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ue()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a[0]&96642|a[1]&8){i=Ce(o[8].filter(o[26]));let l;for(l=0;l<i.length;l+=1){const h=Zm(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=eg(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(xe(),l=i.length;l<s.length;l+=1)n(l);be()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ot(t),Xr(s,o)}}}function Qm(r){let t,e;return t=new PC({props:{target:r[7],tool:r[9],drawingMode:r[4],transform:{elementToImage:r[11]},viewer:r[3],viewportScale:r[34],opts:r[5]}}),t.$on("create",r[15]),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s[0]&128&&(n.target=i[7]),s[0]&512&&(n.tool=i[9]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&8&&(n.viewportScale=i[34]),s[0]&32&&(n.opts=i[5]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function Jm(r){let t=r[35].id,e,i,s=tg(r);return{c(){s.c(),e=Ue()},m(n,o){s.m(n,o),lt(n,e,o),i=!0},p(n,o){o[0]&256&&qt(t,t=n[35].id)?(xe(),ut(s,1,1,Qt),be(),s=tg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(K(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ot(e),s.d(n)}}}function tg(r){let t,e;return t=new CC({props:{target:r[7],editor:r[16](r[35].target.selector),annotation:r[35],style:r[1],transform:{elementToImage:r[11]},viewportScale:r[34]}}),t.$on("grab",r[12]),t.$on("change",function(){re(r[14](r[35]))&&r[14](r[35]).apply(this,arguments)}),t.$on("release",r[13]),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&128&&(n.target=r[7]),s[0]&256&&(n.editor=r[16](r[35].target.selector)),s[0]&256&&(n.annotation=r[35]),s[0]&2&&(n.style=r[1]),s[1]&8&&(n.viewportScale=r[34]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function eg(r){let t,e,i=r[36]&&Jm(r);return{c(){i&&i.c(),t=Ue()},m(s,n){i&&i.m(s,n),lt(s,t,n),e=!0},p(s,n){s[36]?i?(i.p(s,n),n[0]&256&&K(i,1)):(i=Jm(s),i.c(),K(i,1),i.m(t.parentNode,t)):i&&(xe(),ut(i,1,1,()=>{i=null}),be())},i(s){e||(K(i),e=!0)},o(s){ut(i),e=!1},d(s){s&&ot(t),i&&i.d(s)}}}function DC(r){let t,e,i,s,n,o;const a=[LC,NC],l=[];function h(u,c){var d;return u[7]&&((d=u[8])==null?void 0:d.length)===1?0:u[7]&&u[9]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=ht("svg"),e=ht("g"),s&&s.c(),S(e,"transform",n=r[33]),S(e,"class","svelte-1k5cy2d"),S(t,"tabindex",0),S(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-1k5cy2d"),Pn(t,"drawing",r[0]),Pn(t,"editing",r[8])},m(u,c){lt(u,t,c),Rt(t,e),~i&&l[i].m(e,null),r[27](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(xe(),ut(l[d],1,1,()=>{l[d]=null}),be()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),K(s,1),s.m(e,null)):s=null),(!o||c[1]&4&&n!==(n=u[33]))&&S(e,"transform",n),(!o||c[0]&1)&&Pn(t,"drawing",u[0]),(!o||c[0]&256)&&Pn(t,"editing",u[8])},i(u){o||(K(s),o=!0)},o(u){ut(s),o=!1},d(u){u&&ot(t),~i&&l[i].d(),r[27](null)}}}function BC(r){let t,e;return t=new Yh({props:{viewer:r[3],$$slots:{default:[DC,({transform:i,scale:s})=>({33:i,34:s}),({transform:i,scale:s})=>[0,(i?4:0)|(s?8:0)]]},$$scope:{ctx:r}}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&1023|s[1]&268&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function FC(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:u}=t,{state:c}=t,{style:d=void 0}=t,{toolName:p=Sn()[0]}=t,{user:f}=t,{viewer:m}=t,y=0;const _=()=>e(6,y+=1),v=()=>p,g=()=>a;let x;const{store:E,selection:w,hover:A}=c;Mn(r,w,P=>e(25,o=P));let R,M,D;const U=P=>{E.unobserve(R);const B=P.filter(({editable:$})=>$).map(({id:$})=>$);B.length>0?(e(8,M=B.map($=>E.getAnnotation($))),R=$=>{const{updated:Y}=$.changes;e(8,M=(Y||[]).map(z=>z.newValue))},E.observe(R,{annotations:B}),m.forceRedraw()):e(8,M=void 0)},C=(P,B)=>{const{x:$,y:Y}=m.viewport.viewerElementToImageCoordinates(new Ae.Point(P,B));return[$,Y]},T=P=>{m.setMouseNavEnabled(!1),D=P.timeStamp},I=P=>{if(m.setMouseNavEnabled(!0),performance.now()-(D||0)<300){const{offsetX:$,offsetY:Y}=P.detail,[z,it]=C($,Y),xt=E.getAt(z,it);if(xt&&(!l||l(xt))&&!M.find(q=>q.id===xt.id)){A.set(xt.id);const q=qm(xt.id,P.detail,w,h);w.userSelect(q)}}},N=P=>B=>{var it;const{target:$}=P,Y=10*60*1e3,z=((it=$.creator)==null?void 0:it.id)!==f.id||!$.created||new Date().getTime()-$.created.getTime()>Y;E.updateTarget({...$,selector:B.detail,created:z?$.created:new Date,updated:z?new Date:void 0,updatedBy:z?f:void 0})},O=P=>{const B=wS(),$={id:B,bodies:[],target:{annotation:B,selector:P.detail,creator:f,created:new Date}};E.addAnnotation($),w.setSelected($.id),m.setMouseNavEnabled(!0)},L=P=>Zu(P),F=P=>Ke(P);function V(P){Fs[P?"unshift":"push"](()=>{x=P,e(7,x)})}return r.$$set=P=>{"drawingEnabled"in P&&e(0,a=P.drawingEnabled),"filter"in P&&e(17,l=P.filter),"multiSelect"in P&&e(18,h=P.multiSelect),"preferredDrawingMode"in P&&e(19,u=P.preferredDrawingMode),"state"in P&&e(20,c=P.state),"style"in P&&e(1,d=P.style),"toolName"in P&&e(2,p=P.toolName),"user"in P&&e(21,f=P.user),"viewer"in P&&e(3,m=P.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(9,{tool:i,opts:s}=Cn(p)||{tool:void 0,opts:void 0},i,(e(5,s),e(2,p))),r.$$.dirty[0]&524320&&e(4,n=(s==null?void 0:s.drawingMode)||u),r.$$.dirty[0]&25&&(a&&n==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&w.clear(),r.$$.dirty[0]&33554457&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&33554432&&U(o.selected)},[a,d,p,m,n,s,y,x,M,i,w,C,T,I,N,O,L,l,h,u,c,f,_,v,g,o,F,V]}class UC extends se{constructor(t){super(),ie(this,t,FC,BC,qt,{drawingEnabled:0,filter:17,multiSelect:18,preferredDrawingMode:19,state:20,style:1,toolName:2,user:21,viewer:3,cancelDrawing:22,getDrawingTool:23,isDrawingEnabled:24},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[22]}get getDrawingTool(){return this.$$.ctx[23]}get isDrawingEnabled(){return this.$$.ctx[24]}}function kC(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=ht("g"),e=ht("rect"),a=ht("text"),h=Ma(l),S(e,"class","a9s-presence-label-bg svelte-1rehw2p"),S(e,"x",r[0]),S(e,"y",i=r[1]-18/r[3]),S(e,"height",s=18/r[3]),S(e,"fill",n=r[2].appearance.color),S(e,"stroke",o=r[2].appearance.color),S(a,"font-size",u=12/r[3]),S(a,"x",c=r[0]+Math.round(5/r[3])),S(a,"y",d=r[1]-5/r[3]),S(a,"class","svelte-1rehw2p"),S(t,"class","a9s-presence-label")},m(p,f){lt(p,t,f),Rt(t,e),Rt(t,a),Rt(a,h),r[6](t)},p(p,[f]){f&1&&S(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&S(e,"y",i),f&8&&s!==(s=18/p[3])&&S(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&S(e,"fill",n),f&4&&o!==(o=p[2].appearance.color)&&S(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&ov(h,l),f&8&&u!==(u=12/p[3])&&S(a,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&S(a,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&S(a,"y",d)},i:Qt,o:Qt,d(p){p&&ot(t),r[6](null)}}}function GC(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function u(c){Fs[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class rg extends se{constructor(t){super(),ie(this,t,GC,kC,qt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function HC(r){let t,e,i,s,n,o;return e=new rg({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=ht("g"),Vt(e.$$.fragment),i=ht("polygon"),S(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),S(i,"stroke",s=r[0].appearance.color),S(i,"fill","transparent"),S(i,"points",n=r[2].points.map(ig).join(" ")),S(t,"class","a9s-presence-overlay")},m(a,l){lt(a,t,l),Ut(e,t,null),Rt(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&S(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(ig).join(" ")))&&S(i,"points",n)},i(a){o||(K(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&&ot(t),kt(e)}}}const ig=r=>r.join(",");function $C(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,p])=>{p<u[1]&&(u=[d,p])}),u};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class VC extends se{constructor(t){super(),ie(this,t,$C,HC,qt,{annotation:4,user:0,scale:1})}}function XC(r){let t,e,i,s,n,o,a,l,h;return e=new rg({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=ht("g"),Vt(e.$$.fragment),i=ht("rect"),S(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),S(i,"stroke",s=r[0].appearance.color),S(i,"fill","transparent"),S(i,"x",n=r[2].x),S(i,"y",o=r[2].y),S(i,"width",a=r[2].w),S(i,"height",l=r[2].h),S(t,"class","a9s-presence-overlay")},m(u,c){lt(u,t,c),Ut(e,t,null),Rt(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&S(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&S(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&S(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&S(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&S(i,"height",l)},i(u){h||(K(e.$$.fragment,u),h=!0)},o(u){ut(e.$$.fragment,u),h=!1},d(u){u&&ot(t),kt(e)}}}function YC(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class WC extends se{constructor(t){super(),ie(this,t,YC,XC,qt,{annotation:3,user:0,scale:1})}}const{Boolean:jC}=Pc;function sg(r,t,e){const i=r.slice();return i[8]=t[e],i}function ng(r){let t,e;return t=new Yh({props:{viewer:r[0],$$slots:{default:[KC,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function og(r){let t,e,i=Ce(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=ag(sg(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ue()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);lt(o,t,a),e=!0},p(o,a){if(a&132){i=Ce(o[2]);let l;for(l=0;l<i.length;l+=1){const h=sg(o,i,l);s[l]?(s[l].p(h,a),K(s[l],1)):(s[l]=ag(h),s[l].c(),K(s[l],1),s[l].m(t.parentNode,t))}for(xe(),l=i.length;l<s.length;l+=1)n(l);be()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)K(s[a]);e=!0}},o(o){s=s.filter(jC);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&&ot(t),Xr(s,o)}}}function zC(r){let t,e;return t=new VC({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function qC(r){let t,e;return t=new WC({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function ag(r){let t,e,i,s;const n=[qC,zC],o=[];function a(l,h){return l[8].annotation.target.selector.type===Et.RECTANGLE?0:l[8].annotation.target.selector.type===Et.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ue()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),ut(o[u],1,1,()=>{o[u]=null}),be()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),K(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(K(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function KC(r){let t,e,i,s,n=r[2].length>0&&og(r);return{c(){t=ht("svg"),e=ht("g"),n&&n.c(),S(e,"transform",i=r[6]),S(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){lt(o,t,a),Rt(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&K(n,1)):(n=og(o),n.c(),K(n,1),n.m(e,null)):n&&(xe(),ut(n,1,1,()=>{n=null}),be()),(!s||a&64&&i!==(i=o[6]))&&S(e,"transform",i)},i(o){s||(K(n),s=!0)},o(o){ut(n),s=!1},d(o){o&&ot(t),n&&n.d()}}}function ZC(r){let t=!!r[1],e,i,s=t&&ng(r);return{c(){s&&s.c(),e=Ue()},m(n,o){s&&s.m(n,o),lt(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&K(s,1)):(s=ng(n),s.c(),K(s,1),s.m(e.parentNode,e)):s&&(xe(),ut(s,1,1,()=>{s=null}),be())},i(n){i||(K(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ot(e),s&&s.d(n)}}}function QC(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:p}=c.changes,f=new Set((d||[]).map(y=>y.id)),m=o.filter(({annotation:y})=>!f.has(y.id)).map(y=>{const _=(p||[]).find(v=>v.oldValue.id===y.annotation.id);return _?{selectedBy:y.selectedBy,annotation:_.newValue}:y});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return lv(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class JC extends se{constructor(t){super(),ie(this,t,QC,ZC,qt,{store:3,viewer:0,provider:1})}}function tI(r){let t,e,i,s,n;return{c(){t=ht("rect"),S(t,"x",e=r[0].x),S(t,"y",i=r[0].y),S(t,"width",s=r[0].w),S(t,"height",n=r[0].h)},m(o,a){lt(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&S(t,"x",e),a&1&&i!==(i=o[0].y)&&S(t,"y",i),a&1&&s!==(s=o[0].w)&&S(t,"width",s),a&1&&n!==(n=o[0].h)&&S(t,"height",n)},i:Qt,o:Qt,d(o){o&&ot(t)}}}function eI(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class rI extends se{constructor(t){super(),ie(this,t,eI,tI,qt,{annotation:1})}}function iI(r){let t,e;return{c(){t=ht("polygon"),S(t,"points",e=r[0].points.map(lg).join(" "))},m(i,s){lt(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(lg).join(" "))&&S(t,"points",e)},i:Qt,o:Qt,d(i){i&&ot(t)}}}const lg=r=>r.join(",");function sI(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class nI extends se{constructor(t){super(),ie(this,t,sI,iI,qt,{annotation:1})}}function hg(r,t,e){const i=r.slice();return i[2]=t[e],i}function ug(r){let t,e;return{c(){t=ht("path"),e=ht("path"),S(t,"fill-rule","evenodd"),S(t,"d",qe(r[2])),S(e,"class","a9s-inner"),S(e,"fill-rule","evenodd"),S(e,"d",qe(r[2]))},m(i,s){lt(i,t,s),lt(i,e,s)},p:Qt,d(i){i&&(ot(t),ot(e))}}}function oI(r){let t,e=Ce(r[0]),i=[];for(let s=0;s<e.length;s+=1)i[s]=ug(hg(r,e,s));return{c(){t=ht("g");for(let s=0;s<i.length;s+=1)i[s].c()},m(s,n){lt(s,t,n);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(s,[n]){if(n&1){e=Ce(s[0]);let o;for(o=0;o<e.length;o+=1){const a=hg(s,e,o);i[o]?i[o].p(a,n):(i[o]=ug(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Qt,o:Qt,d(s){s&&ot(t),Xr(i,s)}}}function aI(r,t,e){let{annotation:i}=t;const{polygons:s}=i.target.selector.geometry;return r.$$set=n=>{"annotation"in n&&e(1,i=n.annotation)},[s,i]}class lI extends se{constructor(t){super(),ie(this,t,aI,oI,qt,{annotation:1})}}function hI(r){let t,e,i,s,n;return{c(){t=ht("ellipse"),S(t,"cx",e=r[0].cx),S(t,"cy",i=r[0].cy),S(t,"rx",s=r[0].rx),S(t,"ry",n=r[0].ry)},m(o,a){lt(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&S(t,"cx",e),a&1&&i!==(i=o[0].cy)&&S(t,"cy",i),a&1&&s!==(s=o[0].rx)&&S(t,"rx",s),a&1&&n!==(n=o[0].ry)&&S(t,"ry",n)},i:Qt,o:Qt,d(o){o&&ot(t)}}}function uI(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class cI extends se{constructor(t){super(),ie(this,t,uI,hI,qt,{annotation:1})}}const{Boolean:dI}=Pc;function cg(r,t,e){const i=r.slice();return i[10]=t[e],i}function dg(r){let t,e;return t=new Yh({props:{viewer:r[0],$$slots:{default:[yI,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&8710&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function fI(r){let t,e;return t=new cI({props:{annotation:r[10]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function pI(r){let t,e;return t=new lI({props:{annotation:r[10]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function mI(r){let t,e;return t=new nI({props:{annotation:r[10]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function gI(r){let t,e;return t=new rI({props:{annotation:r[10]}}),{c(){Vt(t.$$.fragment)},m(i,s){Ut(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(K(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){kt(t,i)}}}function fg(r){let t,e,i,s;const n=[gI,mI,pI,fI],o=[];function a(l,h){return l[10].target.selector.type===Et.RECTANGLE?0:l[10].target.selector.type===Et.POLYGON?1:l[10].target.selector.type===Et.MULTIPOLYGLON?2:l[10].target.selector.type===Et.ELLIPSE?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ue()},m(l,h){~t&&o[t].m(l,h),lt(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),ut(o[u],1,1,()=>{o[u]=null}),be()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),K(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(K(e),s=!0)},o(l){ut(e),s=!1},d(l){l&&ot(i),~t&&o[t].d(l)}}}function yI(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=Ce(r[1].filter(r[6])),y=[];for(let v=0;v<m.length;v+=1)y[v]=fg(cg(r,m,v));const _=v=>ut(y[v],1,1,()=>{y[v]=null});return{c(){var v,g,x,E;t=ht("svg"),e=ht("g"),i=ht("rect"),l=ht("rect");for(let w=0;w<y.length;w+=1)y[w].c();S(i,"class","a9s-union-bg svelte-1p8m4b9"),S(i,"x",s=(v=r[2])==null?void 0:v.minX),S(i,"y",n=(g=r[2])==null?void 0:g.minY),S(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),S(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),S(l,"class","a9s-union-fg svelte-1p8m4b9"),S(l,"x",h=(x=r[2])==null?void 0:x.minX),S(l,"y",u=(E=r[2])==null?void 0:E.minY),S(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),S(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),S(e,"transform",p=r[9]),S(t,"class","a9s-osd-selectionlayer svelte-1p8m4b9")},m(v,g){lt(v,t,g),Rt(t,e),Rt(e,i),Rt(e,l);for(let x=0;x<y.length;x+=1)y[x]&&y[x].m(e,null);f=!0},p(v,g){var x,E,w,A;if((!f||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&S(i,"x",s),(!f||g&4&&n!==(n=(E=v[2])==null?void 0:E.minY))&&S(i,"y",n),(!f||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&S(i,"width",o),(!f||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&S(i,"height",a),(!f||g&4&&h!==(h=(w=v[2])==null?void 0:w.minX))&&S(l,"x",h),(!f||g&4&&u!==(u=(A=v[2])==null?void 0:A.minY))&&S(l,"y",u),(!f||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&S(l,"width",c),(!f||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&S(l,"height",d),g&2){m=Ce(v[1].filter(v[6]));let R;for(R=0;R<m.length;R+=1){const M=cg(v,m,R);y[R]?(y[R].p(M,g),K(y[R],1)):(y[R]=fg(M),y[R].c(),K(y[R],1),y[R].m(e,null))}for(xe(),R=m.length;R<y.length;R+=1)_(R);be()}(!f||g&512&&p!==(p=v[9]))&&S(e,"transform",p)},i(v){if(!f){for(let g=0;g<m.length;g+=1)K(y[g]);f=!0}},o(v){y=y.filter(dI);for(let g=0;g<y.length;g+=1)ut(y[g]);f=!1},d(v){v&&ot(t),Xr(y,v)}}}function _I(r){let t=!!r[2],e,i,s=t&&dg(r);return{c(){s&&s.c(),e=Ue()},m(n,o){s&&s.m(n,o),lt(n,e,o),i=!0},p(n,[o]){o&4&&(t=!!n[2]),t?s?(s.p(n,o),o&4&&K(s,1)):(s=dg(n),s.c(),K(s,1),s.m(e.parentNode,e)):s&&(xe(),ut(s,1,1,()=>{s=null}),be())},i(n){i||(K(s),i=!0)},o(n){ut(s),i=!1},d(n){n&&ot(e),s&&s.d(n)}}}function vI(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;Mn(r,h,d=>e(5,n=d));const u=d=>{let p=-1/0,f=-1/0,m=1/0,y=1/0;for(let _ of d.filter(v=>Ke(v))){const{bounds:v}=_.target.selector.geometry;v.maxX>p&&(p=v.maxX),v.maxY>f&&(f=v.maxY),v.minX<m&&(m=v.minX),v.minY<y&&(y=v.minY)}return a.forceRedraw(),{maxX:p,maxY:f,minX:m,minY:y}},c=d=>Ke(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=n.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,s=i.length>1?u(i):void 0)},[a,i,s,h,o,n,c]}class xI extends se{constructor(t){super(),ie(this,t,vI,_I,qt,{state:4,viewer:0})}}const pg=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=vc(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},mg=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Ke(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:p,minY:f,maxX:m,maxY:y}=o.target.selector.geometry.bounds,_=m-p,v=y-f,g=p-d*_,x=f-h*v,E=_+(u+d)*_,w=v+(h+c)*v,A=r.viewport.imageToViewportRectangle(g,x,E,w);r.viewport[e](A,s.immediately)},bI=(r,t)=>mg(r,t,"fitBounds"),EI=(r,t)=>mg(r,t,"fitBoundsWithConstraints"),TI=(r,t={})=>{const e=bc(t,{drawingEnabled:!1,drawingMode:va?"drag":"click",userSelectAction:Qo.EDIT,theme:"light"}),i=_c(e),{hover:s,selection:n,store:o}=i,a=Lg(o,e.initialHistory),l=Dg(i,a,e.adapter,e.autoSave);let h=Vg(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=Tc(a,r.element),f=new xS({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new JC({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new UC({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}}),_=new xI({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",B=>{const{originalEvent:$,annotation:Y}=B.detail,z=it=>qm(it.id,$,n,e.multiSelect);d?n.isEmpty()&&Y&&n.userSelect(z(Y),$):Y&&!(c==="click"&&u)?n.userSelect(z(Y),$):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",B=>{if(s.current){const $=o.getAnnotation(s.current);l.emit("clickAnnotation",$,B)}}),pg(r,e.theme);const v=Fg(i,a,e.adapter),g=()=>y.cancelDrawing(),x=()=>{f.$destroy(),m.$destroy(),y.$destroy(),_.$destroy(),p.destroy(),a.destroy()},E=bI(r,o),w=EI(r,o),A=()=>y.getDrawingTool(),R=()=>h,M=()=>y.isDrawingEnabled(),D=(B,$,Y)=>rc(B,$,Y),U=(B,$)=>Qu(B,$),C=B=>{if(!Cn(B))throw`No drawing tool named ${B}`;y.$set({toolName:B})},T=B=>{u=B,y.$set({drawingEnabled:B})},I=B=>{f.$set({filter:B}),y.$set({filter:B})},N=B=>d=B,O=B=>{f.$set({style:B}),y.$set({style:B})},L=B=>m.$set({provider:B}),F=B=>pg(r,B),V=B=>{h=B,y.$set({user:B})},P=B=>f.$set({visible:B});return{...v,cancelDrawing:g,destroy:x,fitBounds:E,fitBoundsWithConstraints:w,getDrawingTool:A,getUser:R,isDrawingEnabled:M,listDrawingTools:Sn,on:l.on,off:l.off,registerDrawingTool:D,registerShapeEditor:U,setDrawingEnabled:T,setDrawingTool:C,setFilter:I,setModalSelect:N,setPresenceProvider:L,setStyle:O,setTheme:F,setUser:V,setVisible:P,state:i,viewer:r}};Zt.ShapeType=Et,Zt.UserSelectAction=Qo,Zt.W3CImageFormat=R_,Zt.chainStyles=v_,Zt.computeStyle=__,Zt.createBody=Ag,Zt.createImageAnnotator=rv,Zt.createOSDAnnotator=TI,Zt.defaultColorProvider=Yg,Object.defineProperty(Zt,Symbol.toStringTag,{value:"Module"})});
1148
+ }`,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=EE(t)),typeof t=="number"?bE(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Is.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}};Lh.availableFonts={},Lh.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 Bh=Lh;const jo=class Rs extends gs{constructor(t="",e={}){super(ut.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=ut.from(i,{scaleMode:tt.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new xt,s.trim=new xt,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),u=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Rs.defaultMaxWidth,this.maxHeight=Rs.defaultMaxHeight,this._domElement=h,this._styleElement=u,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(u),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Rs.defaultAutoResolution,this._resolution=Rs.defaultResolution??tt.RESOLUTION,this.text=t,this.style=e}measureText(t){var u,c;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(u=this._style)==null?void 0:u.toCSS(s)}),this._styleElement.textContent=(c=this._style)==null?void 0:c.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Rs.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=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 Bh?(this.ownsStyle=!1,this._style=t):t instanceof ii?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=Bh.from(t)):(this.ownsStyle=!0,this._style=new Bh(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;")}};jo.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},jo.defaultMaxWidth=2024,jo.defaultMaxHeight=2024,jo.defaultAutoResolution=!0;const DS=16777215,LS=.25,BS=16777215,FS=1,US=1.5;let oi=!1,dn;const Fh=r=>{const t={tint:r!=null&&r.fill?new Ot(r.fill).toNumber():DS,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 Ot(r==null?void 0:r.fill).alpha:LS},e={tint:r!=null&&r.stroke?new Ot(r.stroke).toNumber():BS,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 Ot(r==null?void 0:r.stroke).alpha:FS,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?US:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Wo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=Fh(i),o=new cn;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new cn,l=n.lineWidth===1?1:n.lineWidth/dn;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},kS=Wo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),GS=Wo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),HS=Wo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),$S=Wo((r,t)=>{const e=i=>i.points.reduce((s,n)=>[...s,...n],[]);r.geometry.polygons.forEach(i=>{const[s,...n]=i.rings;t.drawPolygon(e(s)),n.forEach(o=>{t.beginHole(),t.drawPolygon(e(o)),t.endHole()})})}),Pm=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},Om=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Pm(r);(n!==dn||!oi)&&(oi=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(oi=n===dn,f.width=p/n,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),dn=n;const o=r.viewport.getFlip();let a=Math.PI*r.viewport.getRotation(!0)/180;a<0&&(a+=2*Math.PI),a>2*Math.PI&&(a-=2*Math.PI);const l=o?r.viewport._containerInnerSize.x+s.x*n:-s.x*n,h=-s.y*n;let u,c;a>0&&a<=Math.PI/2?(u=s.height*n,c=0):a>Math.PI/2&&a<=Math.PI?(u=s.width*n,c=s.height*n):a>Math.PI&&a<=Math.PI*1.5?(u=0,c=s.width*n):(u=0,c=0),t.position.x=u+l*Math.cos(a)-h*Math.sin(a),t.position.y=c+l*Math.sin(a)+h*Math.cos(a),t.scale.set(o?-n:n,n),t.rotation=a,i.render(t)},XS=(r,t)=>{const e=new cn,i=Ip({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;dn=Pm(r);const l=(g,x)=>{oi=!1;const{selector:E}=g.target,M=typeof a=="function"?a(g,x):a;let S;E.type===At.RECTANGLE?S=kS(e,E,M):E.type===At.POLYGON?S=HS(e,E,M):E.type===At.ELLIPSE?S=GS(e,E,M):E.type===At.MULTIPOLYGLON?S=$S(e,E,M):console.warn(`Unsupported shape type: ${E.type}`),S&&s.set(g.id,{annotation:g,...S})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,E)=>{oi=!1;const M=s.get(g.id);if(M&&(s.delete(g.id),M.fill.destroy(),M.stroke.destroy(),l(x,E),n.has(x.id))){const{fill:S,stroke:R}=s.get(x.id);e.removeChild(S),e.removeChild(R)}},c=(g,x)=>{const E=s.get(g);E&&(s.delete(g),E.fill.destroy(),E.stroke.destroy(),l(E.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},p=g=>{oi=!1;const{children:x}=e;s.forEach(({fill:E,stroke:M,annotation:S})=>{const R=g?n.has(S.id)||g(S):!0;R&&!x.includes(E)?(e.addChild(E),e.addChild(M)):!R&&x.includes(E)&&(e.removeChild(E),e.removeChild(M))}),i.render(e)},f=g=>{const x=new Set(g.selected.map(S=>S.id)),E=g.selected.filter(({id:S})=>!n.has(S)),M=[...n].filter(S=>!x.has(S));E.forEach(({id:S,editable:R})=>{if(R){const P=s.get(S);P&&(e.removeChild(P.fill),e.removeChild(P.stroke))}else c(S,{selected:!0,hovered:S===o})}),M.forEach(S=>c(S,{hovered:S===o})),n=x,i.render(e)},m=g=>{o!==g&&(o&&!n.has(o)&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},_=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:E,stroke:M,strokeWidth:S},R)=>{S>1&&(oi=!1);const P={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:k}=Fh(g(x,P));E.tint=F.tint,E.alpha=F.alpha,M.tint=k.tint||16777215,M.alpha=k.alpha,s.set(x.id,{annotation:x,fill:E,stroke:M,strokeWidth:k.lineWidth})});else{const{fillStyle:x,strokeStyle:E}=Fh(g);E.lineWidth>1&&(oi=!1),s.forEach(({annotation:M,fill:S,stroke:R,strokeWidth:P},F)=>{S.tint=x.tint,S.alpha=x.alpha,R.tint=E.tint||16777215,R.alpha=E.alpha,s.set(M.id,{annotation:M,fill:S,stroke:R,strokeWidth:E.lineWidth})})}a=g,i.render(e),Om(r,e,s,i)()},y=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:Om(r,e,s,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:m,setSelected:f,setStyle:_,setVisible:y,updateAnnotation:u}};function VS(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:u,hover:c,selection:d,viewport:p}=o;Dn(r,c,M=>e(11,i=M)),Dn(r,d,M=>e(8,s=M));const f=Ki();let m,_;const y=M=>{const S=new Se.Point(M.x,M.y),{x:R,y:P}=l.viewport.pointFromPixel(S);return l.viewport.viewportToImageCoordinates(R,P)},v=M=>{const{x:S,y:R}=M.position;_={x:S,y:R}},g=M=>S=>{const{x:R,y:P}=y(new Se.Point(S.offsetX,S.offsetY)),F=u.getAt(R,P,n);F?(M.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(M.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=M=>{if(!_)return;const S=M.originalEvent,{x:R,y:P}=M.position,F=R-_.x,k=P-_.y;if(Math.sqrt(F*F+k*k)<5){const{x:A,y:T}=y(M.position),C=u.getAt(A,T,n);C?f("click",{originalEvent:S,annotation:C}):f("click",{originalEvent:S})}_=void 0};let E;return qi(()=>{var C;const{offsetWidth:M,offsetHeight:S}=l.canvas,R=document.createElement("canvas");R.width=M,R.height=S,R.className="a9s-gl-canvas",(C=l.element.querySelector(".openseadragon-canvas"))==null||C.appendChild(R),e(7,m=XS(l,R));const P=g(R);R.addEventListener("pointermove",P);const F=new ResizeObserver(L=>{try{const{width:N,height:B}=L[0].contentRect;R.width=N,R.height=B,m.resize(N,B)}catch{console.warn("WebGL canvas already disposed")}});F.observe(R);const k=()=>{const L=l.viewport.getBounds();E=l.viewport.viewportToImageRectangle(L);const{x:N,y:B,width:X,height:O}=E,D=u.getIntersecting(N,B,X,O);p.set(D.map(U=>U.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",k);const I=L=>L.filter(N=>Ze(N)),A=L=>Ze(L.oldValue)&&Ze(L.newValue),T=L=>{const{created:N,updated:B,deleted:X}=L.changes;if(I(N||[]).forEach(O=>m.addAnnotation(O)),I(X||[]).forEach(O=>m.removeAnnotation(O)),(B||[]).filter(O=>A(O)).forEach(({oldValue:O,newValue:D})=>m.updateAnnotation(O,D)),E){const{x:O,y:D,width:U,height:V}=E,j=u.getIntersecting(O,D,U,V);p.set(j.map(Q=>Q.id))}else p.set(u.all().map(O=>O.id));m.redraw()};return u.observe(T),()=>{var L;R.removeEventListener("pointermove",P),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",k),u.unobserve(T),m.destroy(),(L=R.parentNode)==null||L.removeChild(R)}}),r.$$set=M=>{"filter"in M&&e(2,n=M.filter),"state"in M&&e(3,o=M.state),"style"in M&&e(4,a=M.style),"viewer"in M&&e(5,l=M.viewer),"visible"in M&&e(6,h=M.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[c,d,n,o,a,l,h,m,s]}class zS extends se{constructor(t){super(),ie(this,t,VS,null,qt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const Ae=[];for(let r=0;r<256;++r)Ae.push((r+256).toString(16).slice(1));function YS(r,t=0){return(Ae[r[t+0]]+Ae[r[t+1]]+Ae[r[t+2]]+Ae[r[t+3]]+"-"+Ae[r[t+4]]+Ae[r[t+5]]+"-"+Ae[r[t+6]]+Ae[r[t+7]]+"-"+Ae[r[t+8]]+Ae[r[t+9]]+"-"+Ae[r[t+10]]+Ae[r[t+11]]+Ae[r[t+12]]+Ae[r[t+13]]+Ae[r[t+14]]+Ae[r[t+15]]).toLowerCase()}let Uh;const jS=new Uint8Array(16);function WS(){if(!Uh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Uh=crypto.getRandomValues.bind(crypto)}return Uh(jS)}const Nm={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qS(r,t,e){var s;if(Nm.randomUUID&&!r)return Nm.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??WS();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,YS(i)}var ai=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(ai||{});const qo=(r,t)=>t,li=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},kh=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)},Gh=(r,t,e)=>{let i=!1;for(let s=0,n=r.length-1;s<r.length;n=s++){const o=r[s][0],a=r[s][1],l=r[n][0],h=r[n][1];a>e!=h>e&&t<(l-o)*(e-a)/(h-a)+o&&(i=!i)}return i},KS=(r,t=!0)=>{let e="M ";return r.forEach(([i,s],n)=>{n===0?e+=`${i},${s}`:e+=` L ${i},${s}`}),t&&(e+=" Z"),e},ZS={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),u=t-i,c=e-s,d=l*u+h*c,p=h*u-l*c;return d*d/(n*n)+p*p/(o*o)<=1}};qo(ai.ELLIPSE,ZS);const QS={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=kh(s.points),a=n.reduce((l,h)=>l+kh(h.points),0);return e+o-a},0)},intersects:(r,t,e)=>{const{polygons:i}=r.geometry;for(const s of i){const[n,...o]=s.rings;if(Gh(n.points,t,e)){let a=!1;for(const l of o)if(Gh(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Hh=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return li(t)},ws=r=>r.rings.map(e=>KS(e.points)).join(" "),JS=r=>r.polygons.reduce((t,e)=>[...t,...e.rings.reduce((i,s)=>[...i,...s.points],[])],[]);qo(ai.MULTIPOLYGLON,QS);const tC={area:r=>{const t=r.geometry.points;return kh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Gh(i,t,e)}};qo(ai.POLYGON,tC);const eC={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};qo(ai.RECTANGLE,eC);const oe=" ";function rC(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===$.CLOSE_PATH)t+="z";else if(i.type===$.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===$.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===$.MOVE_TO)t+=(i.relative?"m":"M")+i.x+oe+i.y;else if(i.type===$.LINE_TO)t+=(i.relative?"l":"L")+i.x+oe+i.y;else if(i.type===$.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+oe+i.y1+oe+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===$.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+oe+i.y2+oe+i.x+oe+i.y;else if(i.type===$.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+oe+i.y1+oe+i.x+oe+i.y;else if(i.type===$.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+oe+i.y;else if(i.type===$.ARC)t+=(i.relative?"a":"A")+i.rX+oe+i.rY+oe+i.xRot+oe+ +i.lArcFlag+oe+ +i.sweepFlag+oe+i.x+oe+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function $h([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function lr(...r){for(let t=0;t<r.length;t++)if(typeof r[t]!="number")throw new Error(`assertNumbers arguments[${t}] is not a number. ${typeof r[t]} == typeof ${r[t]}`);return!0}const hi=Math.PI;function Xh(r,t,e){r.lArcFlag=r.lArcFlag===0?0:1,r.sweepFlag=r.sweepFlag===0?0:1;let{rX:i,rY:s}=r;const{x:n,y:o}=r;if(Math.abs(i)<1e-10||Math.abs(s)<1e-10){r.rX=0,r.rY=0,r.cX=(t+n)/2,r.cY=(e+o)/2,r.phi1=0,r.phi2=0;return}i=Math.abs(r.rX),s=Math.abs(r.rY);const a=r.xRot/180*hi,[l,h]=$h([(t-n)/2,(e-o)/2],-a),u=Math.pow(l,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(i*=Math.sqrt(u),s*=Math.sqrt(u)),r.rX=i,r.rY=s;const c=Math.pow(i,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),d=(r.lArcFlag!==r.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-c)/c)),p=i*h/s*d,f=-s*l/i*d,m=$h([p,f],a);r.cX=m[0]+(t+n)/2,r.cY=m[1]+(e+o)/2,r.phi1=Math.atan2((h-f)/s,(l-p)/i),r.phi2=Math.atan2((-h-f)/s,(-l-p)/i),r.sweepFlag===0&&r.phi2>r.phi1&&(r.phi2-=2*hi),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*hi),r.phi1*=180/hi,r.phi2*=180/hi}function Dm(r,t,e){lr(r,t,e);const i=r*r+t*t-e*e;if(0>i)return[];if(i===0)return[[r*e/(r*r+t*t),t*e/(r*r+t*t)]];const s=Math.sqrt(i);return[[(r*e+t*s)/(r*r+t*t),(t*e-r*s)/(r*r+t*t)],[(r*e-t*s)/(r*r+t*t),(t*e+r*s)/(r*r+t*t)]]}const ki=Math.PI/180;function Lm(r,t,e){return(1-e)*r+e*t}function Bm(r,t,e,i){return r+Math.cos(i/180*hi)*t+Math.sin(i/180*hi)*e}function Fm(r,t,e,i){const n=t-r,o=e-t,a=i-e,l=3*n+3*a-6*o,h=(o-n)*6,u=3*n;return Math.abs(l)<1e-6?Math.abs(h)<1e-6?[]:[-u/h]:iC(h/l,u/l,1e-6)}function Um(r,t,e,i,s){const n=1-s,o=n*n*n,a=3*n*n*s,l=3*n*s*s,h=s*s*s;return r*o+t*a+e*l+i*h}function iC(r,t,e=1e-6){const i=r*r/4-t;if(i<-e)return[];if(i<=e)return[-r/2];const s=Math.sqrt(i);return[-(r/2)-s,-(r/2)+s]}function sC(r,t,e){r.cX||Xh(r,t,e);const i=r.xRot/180*hi;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:$.CURVE_TO,x1:t+(r.x-t)/3,y1:e+(r.y-e)/3,x2:t+2*(r.x-t)/3,y2:e+2*(r.y-e)/3,x:r.x,y:r.y}];const s=Math.min(r.phi1,r.phi2),n=Math.max(r.phi1,r.phi2),o=n-s,a=Math.ceil(o/90),l=new Array(a);let h=t,u=e;const c=(d,p)=>{const[f,m]=$h([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=Lm(r.phi1,r.phi2,d/a),f=Lm(r.phi1,r.phi2,(d+1)/a),m=f-p,_=4/3*Math.tan(m*ki/4),y=Math.cos(p*ki)-_*Math.sin(p*ki),v=Math.sin(p*ki)+_*Math.cos(p*ki),g=Math.cos(f*ki),x=Math.sin(f*ki),E=g+_*x,M=x-_*g,S=c(y,v),R=c(E,M),P=c(g,x),F={relative:r.relative,type:$.CURVE_TO,x:P[0],y:P[1],x1:S[0],y1:S[1],x2:R[0],y2:R[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=P[0],u=P[1],l[d]=F}return l}function Vh(r,t,e){const i=t[0]-r[0],s=t[1]-r[1],n=e[0]-r[0],o=e[1]-r[1],a=i*o-s*n;if(!(Math.abs(a)<1e-10))return!1;const h=i*n+s*o,u=i*i+s*s,c=n*n+o*o;return 0<=h&&h<=c&&u<=c}function nC(r,t=!0){if(r.length<2)return r;const e=ae.INFO((n,o,a)=>({...n,x:n.x??o,y:n.y??a,relative:n.relative??!1})),i=[];let s=[];for(const n of r){const o=e(n);o.type===$.MOVE_TO&&s.length>0&&(t?i.push(...Ko(s)):i.unshift(...Ko(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Ko(s)):i.unshift(...Ko(s))),i}function Ko(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===$.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:$.MOVE_TO,relative:!1,x:r[e].x,y:r[e].y}];for(let n=e;n>0;n--){const o=r[n],a=r[n-1];if(o.relative)throw new Error("Relative command are not supported convert first with `toAbs()`");switch(o.type){case $.HORIZ_LINE_TO:i.push({type:$.HORIZ_LINE_TO,relative:!1,x:a.x});break;case $.VERT_LINE_TO:i.push({type:$.VERT_LINE_TO,relative:!1,y:a.y});break;case $.LINE_TO:case $.MOVE_TO:i.push({type:$.LINE_TO,relative:!1,x:a.x,y:a.y});break;case $.CURVE_TO:i.push({type:$.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case $.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case $.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case $.ARC:throw new Error("Unsupported command: A (arc)");case $.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:$.CLOSE_PATH}),i}function oC(r=1e13){lr(r);function t(e){return Math.round(e*r)/r}return function(i){return"x1"in i&&typeof i.x1<"u"&&(i.x1=t(i.x1)),"y1"in i&&typeof i.y1<"u"&&(i.y1=t(i.y1)),"x2"in i&&typeof i.x2<"u"&&(i.x2=t(i.x2)),"y2"in i&&typeof i.y2<"u"&&(i.y2=t(i.y2)),"x"in i&&typeof i.x<"u"&&(i.x=t(i.x)),"y"in i&&typeof i.y<"u"&&(i.y=t(i.y)),"rX"in i&&typeof i.rX<"u"&&(i.rX=t(i.rX)),"rY"in i&&typeof i.rY<"u"&&(i.rY=t(i.rY)),i}}function km(){return hr((r,t,e)=>(r.relative&&(typeof r.x1<"u"&&(r.x1+=t),typeof r.y1<"u"&&(r.y1+=e),typeof r.x2<"u"&&(r.x2+=t),typeof r.y2<"u"&&(r.y2+=e),typeof r.x<"u"&&(r.x+=t),typeof r.y<"u"&&(r.y+=e),r.relative=!1),r))}function aC(){return hr((r,t,e)=>(r.relative||(typeof r.x1<"u"&&(r.x1-=t),typeof r.y1<"u"&&(r.y1-=e),typeof r.x2<"u"&&(r.x2-=t),typeof r.y2<"u"&&(r.y2-=e),typeof r.x<"u"&&(r.x-=t),typeof r.y<"u"&&(r.y-=e),r.relative=!0),r))}function lC(r=!0,t=!0,e=!0,i=!0){return hr((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&$.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&$.HORIZ_LINE_TO&&(s.type=$.LINE_TO,s.y=s.relative?0:o),e&&s.type&$.VERT_LINE_TO&&(s.type=$.LINE_TO,s.x=s.relative?0:n),r&&s.type&$.CLOSE_PATH&&(s.type=$.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&$.ARC&&(s.rX===0||s.rY===0)&&(s.type=$.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&$.QUAD_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x,o+s.y]:[s.x,s.y];Vh(h,u,c)&&(s.type=$.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&$.CURVE_TO){const h=[n,o],u=s.relative?[n+s.x1,o+s.y1]:[s.x1,s.y1],c=s.relative?[n+s.x2,o+s.y2]:[s.x2,s.y2],d=s.relative?[n+s.x,o+s.y]:[s.x,s.y];Vh(h,u,d)&&Vh(h,c,d)&&(s.type=$.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Gm(){let r=NaN,t=NaN,e=NaN,i=NaN;return hr((s,n,o)=>(s.type&$.SMOOTH_CURVE_TO&&(s.type=$.CURVE_TO,r=isNaN(r)?n:r,t=isNaN(t)?o:t,s.x1=s.relative?n-r:2*n-r,s.y1=s.relative?o-t:2*o-t),s.type&$.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&$.SMOOTH_QUAD_TO&&(s.type=$.QUAD_TO,e=isNaN(e)?n:e,i=isNaN(i)?o:i,s.x1=s.relative?n-e:2*n-e,s.y1=s.relative?o-i:2*o-i),s.type&$.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Hm(){let r=NaN,t=NaN;return hr((e,i,s)=>{if(e.type&$.SMOOTH_QUAD_TO&&(e.type=$.QUAD_TO,r=isNaN(r)?i:r,t=isNaN(t)?s:t,e.x1=e.relative?i-r:2*i-r,e.y1=e.relative?s-t:2*s-t),e.type&$.QUAD_TO){r=e.relative?i+e.x1:e.x1,t=e.relative?s+e.y1:e.y1;const n=e.x1,o=e.y1;e.type=$.CURVE_TO,e.x1=((e.relative?0:i)+n*2)/3,e.y1=((e.relative?0:s)+o*2)/3,e.x2=(e.x+n*2)/3,e.y2=(e.y+o*2)/3}else r=NaN,t=NaN;return e})}function hr(r){let t=0,e=0,i=NaN,s=NaN;return function(o){if(isNaN(i)&&!(o.type&$.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&$.CLOSE_PATH&&(t=i,e=s),"x"in o&&typeof o.x<"u"&&(t=o.relative?t+o.x:o.x),"y"in o&&typeof o.y<"u"&&(e=o.relative?e+o.y:o.y),o.type&$.MOVE_TO&&(i=t,s=e),a}}function hC(r=0){lr(r);let t=NaN,e=NaN,i=NaN,s=NaN;return hr((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&$.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&($.CURVE_TO|$.SMOOTH_CURVE_TO)?(t=n.relative?o+n.x2:n.x2,e=n.relative?a+n.y2:n.y2):(t=NaN,e=NaN),n.type&$.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&$.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&$.LINE_COMMANDS||n.type&$.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&$.CURVE_TO||n.type&$.SMOOTH_CURVE_TO||n.type&$.QUAD_TO||n.type&$.SMOOTH_QUAD_TO){const f=typeof n.x>"u"?0:n.relative?n.x:n.x-o,m=typeof n.y>"u"?0:n.relative?n.y:n.y-a;d=isNaN(i)?typeof n.x1>"u"?d:n.relative?n.x:n.x1-o:i-o,p=isNaN(s)?typeof n.y1>"u"?p:n.relative?n.y:n.y1-a:s-a;const _=typeof n.x2>"u"?0:n.relative?n.x:n.x2-o,y=typeof n.y2>"u"?0:n.relative?n.y:n.y2-a;u(f)<=r&&u(m)<=r&&u(d)<=r&&u(p)<=r&&u(_)<=r&&u(y)<=r&&(c=!0)}return n.type&$.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function ui(r,t,e,i,s,n){return lr(r,t,e,i,s,n),hr((o,a,l,h)=>{const u=o.x1,c=o.x2,d=o.relative&&!isNaN(h),p=typeof o.x<"u"?o.x:d?0:a,f=typeof o.y<"u"?o.y:d?0:l;o.type&$.HORIZ_LINE_TO&&t!==0&&(o.type=$.LINE_TO,o.y=o.relative?0:l),o.type&$.VERT_LINE_TO&&e!==0&&(o.type=$.LINE_TO,o.x=o.relative?0:a),typeof o.x<"u"&&(o.x=o.x*r+f*e+(d?0:s)),typeof o.y<"u"&&(o.y=p*t+o.y*i+(d?0:n)),typeof o.x1<"u"&&(o.x1=o.x1*r+o.y1*e+(d?0:s)),typeof o.y1<"u"&&(o.y1=u*t+o.y1*i+(d?0:n)),typeof o.x2<"u"&&(o.x2=o.x2*r+o.y2*e+(d?0:s)),typeof o.y2<"u"&&(o.y2=c*t+o.y2*i+(d?0:n));function m(y){return y*y}const _=r*i-t*e;if(typeof o.xRot<"u"&&(r!==1||t!==0||e!==0||i!==1))if(_===0)delete o.rX,delete o.rY,delete o.xRot,delete o.lArcFlag,delete o.sweepFlag,o.type=$.LINE_TO;else{const y=o.xRot*Math.PI/180,v=Math.sin(y),g=Math.cos(y),x=1/m(o.rX),E=1/m(o.rY),M=m(g)*x+m(v)*E,S=2*v*g*(x-E),R=m(v)*x+m(g)*E,P=M*i*i-S*t*i+R*t*t,F=S*(r*i+t*e)-2*(M*e*i+R*r*t),k=M*e*e-S*r*e+R*r*r,I=(Math.atan2(F,P-k)+Math.PI)%Math.PI/2,A=Math.sin(I),T=Math.cos(I);o.rX=Math.abs(_)/Math.sqrt(P*m(T)+F*A*T+k*m(A)),o.rY=Math.abs(_)/Math.sqrt(P*m(A)-F*A*T+k*m(T)),o.xRot=I*180/Math.PI}return typeof o.sweepFlag<"u"&&0>_&&(o.sweepFlag=+!o.sweepFlag),o})}function uC(r,t=0,e=0){lr(r,t,e);const i=Math.sin(r),s=Math.cos(r);return ui(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function cC(r,t=0){return lr(r,t),ui(1,0,0,1,r,t)}function dC(r,t=r){return lr(r,t),ui(r,0,0,t,0,0)}function fC(r){return lr(r),ui(1,0,Math.tan(r),1,0,0)}function pC(r){return lr(r),ui(1,Math.tan(r),0,1,0,0)}function mC(r=0){return lr(r),ui(-1,0,0,1,r,0)}function gC(r=0){return lr(r),ui(1,0,0,-1,0,r)}function yC(){return hr((r,t,e)=>$.ARC===r.type?sC(r,r.relative?0:t,r.relative?0:e):r)}function _C(){return hr((r,t,e)=>(r.relative&&(t=0,e=0),$.ARC===r.type&&Xh(r,t,e),r))}function $m(){return r=>({...r})}function vC(){const r=$m(),t=km(),e=Hm(),i=Gm(),s=hr((n,o,a)=>{const l=i(e(t(r(n))));function h(c){c>s.maxX&&(s.maxX=c),c<s.minX&&(s.minX=c)}function u(c){c>s.maxY&&(s.maxY=c),c<s.minY&&(s.minY=c)}if(l.type&$.DRAWING_COMMANDS&&(h(o),u(a)),l.type&$.HORIZ_LINE_TO&&h(l.x),l.type&$.VERT_LINE_TO&&u(l.y),l.type&$.LINE_TO&&(h(l.x),u(l.y)),l.type&$.CURVE_TO){h(l.x),u(l.y);const c=Fm(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(Um(o,l.x1,l.x2,l.x,p));const d=Fm(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(Um(a,l.y1,l.y2,l.y,p))}if(l.type&$.ARC){h(l.x),u(l.y),Xh(l,o,a);const c=l.xRot/180*Math.PI,d=Math.cos(c)*l.rX,p=Math.sin(c)*l.rX,f=-Math.sin(c)*l.rY,m=Math.cos(c)*l.rY,[_,y]=l.phi1<l.phi2?[l.phi1,l.phi2]:-180>l.phi2?[l.phi2+360,l.phi1+360]:[l.phi2,l.phi1],v=([E,M])=>{const R=Math.atan2(M,E)*180/Math.PI;return R<_?R+360:R},g=Dm(f,-d,0).map(v);for(const E of g)E>_&&E<y&&h(Bm(l.cX,d,f,E));const x=Dm(m,-p,0).map(v);for(const E of x)E>_&&E<y&&u(Bm(l.cY,p,m,E))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const ae={ROUND:oC,TO_ABS:km,TO_REL:aC,NORMALIZE_HVZ:lC,NORMALIZE_ST:Gm,QT_TO_C:Hm,INFO:hr,SANITIZE:hC,MATRIX:ui,ROTATE:uC,TRANSLATE:cC,SCALE:dC,SKEW_X:fC,SKEW_Y:pC,X_AXIS_SYMMETRY:mC,Y_AXIS_SYMMETRY:gC,A_TO_C:yC,ANNOTATE_ARCS:_C,CLONE:$m,CALCULATE_BOUNDS:vC,REVERSE_PATH:nC};class Xm{round(t){return this.transform(ae.ROUND(t))}toAbs(){return this.transform(ae.TO_ABS())}toRel(){return this.transform(ae.TO_REL())}normalizeHVZ(t,e,i){return this.transform(ae.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(ae.NORMALIZE_ST())}qtToC(){return this.transform(ae.QT_TO_C())}aToC(){return this.transform(ae.A_TO_C())}sanitize(t){return this.transform(ae.SANITIZE(t))}translate(t,e){return this.transform(ae.TRANSLATE(t,e))}scale(t,e){return this.transform(ae.SCALE(t,e))}rotate(t,e,i){return this.transform(ae.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(ae.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(ae.SKEW_X(t))}skewY(t){return this.transform(ae.SKEW_Y(t))}xSymmetry(t){return this.transform(ae.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(ae.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(ae.ANNOTATE_ARCS())}}const xC=r=>r===" "||r===" "||r==="\r"||r===`
1149
+ `,Vm=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class bC extends Xm{constructor(){super();$t(this,"curNumber","");$t(this,"curCommandType",-1);$t(this,"curCommandRelative",!1);$t(this,"canParseCommandOrComma",!0);$t(this,"curNumberHasExp",!1);$t(this,"curNumberHasExpDigits",!1);$t(this,"curNumberHasDecimal",!1);$t(this,"curArgs",[])}finish(e=[]){if(this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e}parse(e,i=[]){const s=n=>{i.push(n),this.curArgs.length=0,this.canParseCommandOrComma=!0};for(let n=0;n<e.length;n++){const o=e[n],a=this.curCommandType===$.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=Vm(o)&&(this.curNumber==="0"&&o==="0"||a);if(Vm(o)&&!l){this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp;continue}if(o==="e"||o==="E"){this.curNumber+=o,this.curNumberHasExp=!0;continue}if((o==="-"||o==="+")&&this.curNumberHasExp&&!this.curNumberHasExpDigits){this.curNumber+=o;continue}if(o==="."&&!this.curNumberHasExp&&!this.curNumberHasDecimal&&!a){this.curNumber+=o,this.curNumberHasDecimal=!0;continue}if(this.curNumber&&this.curCommandType!==-1){const h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError(`Invalid number ending at ${n}`);if(this.curCommandType===$.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError(`Expected positive number, got "${h}" at index "${n}"`)}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError(`Expected a flag, got "${this.curNumber}" at index "${n}"`)}this.curArgs.push(h),this.curArgs.length===EC[this.curCommandType]&&($.HORIZ_LINE_TO===this.curCommandType?s({type:$.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):$.VERT_LINE_TO===this.curCommandType?s({type:$.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===$.MOVE_TO||this.curCommandType===$.LINE_TO||this.curCommandType===$.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),$.MOVE_TO===this.curCommandType&&(this.curCommandType=$.LINE_TO)):this.curCommandType===$.CURVE_TO?s({type:$.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===$.SMOOTH_CURVE_TO?s({type:$.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===$.QUAD_TO?s({type:$.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===$.ARC&&s({type:$.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!xC(o)){if(o===","&&this.canParseCommandOrComma){this.canParseCommandOrComma=!1;continue}if(o==="+"||o==="-"||o==="."){this.curNumber=o,this.curNumberHasDecimal=o===".";continue}if(l){this.curNumber=o,this.curNumberHasDecimal=!1;continue}if(this.curArgs.length!==0)throw new SyntaxError(`Unterminated command at index ${n}.`);if(!this.canParseCommandOrComma)throw new SyntaxError(`Unexpected character "${o}" at index ${n}. Command cannot follow comma`);if(this.canParseCommandOrComma=!1,o==="z"||o==="Z"){i.push({type:$.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=$.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=$.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=$.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=$.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=$.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=$.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=$.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=$.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=$.ARC,this.curCommandRelative=o==="a";else throw new SyntaxError(`Unexpected character "${o}" at index ${n}.`)}}return i}transform(e){return Object.create(this,{parse:{value(s,n=[]){const o=Object.getPrototypeOf(this).parse.call(this,s);for(const a of o){const l=e(a);Array.isArray(l)?n.push(...l):n.push(l)}return n}}})}}const Lt=class Lt extends Xm{constructor(e){super();$t(this,"commands");typeof e=="string"?this.commands=Lt.parse(e):this.commands=e}encode(){return Lt.encode(this.commands)}getBounds(){const e=ae.CALCULATE_BOUNDS();return this.transform(e),e}transform(e){const i=[];for(const s of this.commands){const n=e(s);Array.isArray(n)?i.push(...n):i.push(n)}return this.commands=i,this}reverse(e=!0){return this.commands=ae.REVERSE_PATH(this.commands,e),this}static encode(e){return rC(e)}static parse(e){const i=new bC,s=[];return i.parse(e,s),i.finish(s),s}};$t(Lt,"CLOSE_PATH",1),$t(Lt,"MOVE_TO",2),$t(Lt,"HORIZ_LINE_TO",4),$t(Lt,"VERT_LINE_TO",8),$t(Lt,"LINE_TO",16),$t(Lt,"CURVE_TO",32),$t(Lt,"SMOOTH_CURVE_TO",64),$t(Lt,"QUAD_TO",128),$t(Lt,"SMOOTH_QUAD_TO",256),$t(Lt,"ARC",512),$t(Lt,"LINE_COMMANDS",Lt.LINE_TO|Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO),$t(Lt,"DRAWING_COMMANDS",Lt.HORIZ_LINE_TO|Lt.VERT_LINE_TO|Lt.LINE_TO|Lt.CURVE_TO|Lt.SMOOTH_CURVE_TO|Lt.QUAD_TO|Lt.SMOOTH_QUAD_TO|Lt.ARC);let $=Lt;const EC={[$.MOVE_TO]:2,[$.LINE_TO]:2,[$.HORIZ_LINE_TO]:1,[$.VERT_LINE_TO]:1,[$.CLOSE_PATH]:0,[$.QUAD_TO]:4,[$.SMOOTH_QUAD_TO]:2,[$.CURVE_TO]:6,[$.SMOOTH_CURVE_TO]:4,[$.ARC]:7},TC=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}},zh=(r,t=0)=>{const{minX:e,minY:i,maxX:s,maxY:n}=r;return{x:e-t,y:i-t,w:s-e+2*t,h:n-i+2*t}},ci=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,wC=r=>({}),zm=r=>({grab:r[0]});function AC(r){let t,e,i,s;const n=r[8].default,o=Hc(n,r,r[7],zm);return{c(){t=st("g"),o&&o.c(),w(t,"class","a9s-annotation selected")},m(a,l){at(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Pt(t,"pointerup",r[2]),Pt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&128)&&Vc(o,n,a,a[7],e?Xc(n,a[7],l,wC):zc(a[7]),zm)},i(a){e||(q(o,a),e=!0)},o(a){lt(o,a),e=!1},d(a){a&&nt(t),o&&o.d(a),i=!1,ze(s)}}}function SC(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Ki();let{shape:o}=t,{editor:a}=t,{transform:l}=t,{svgEl:h}=t,u,c,d;const p=_=>y=>{if(u=_,h){const{left:g,top:x}=h.getBoundingClientRect(),E=y.clientX-g,M=y.clientY-x;c=l.elementToImage(E,M)}else{const{offsetX:g,offsetY:x}=y;c=l.elementToImage(g,x)}d=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},f=_=>{if(u){const[y,v]=l.elementToImage(_.offsetX,_.offsetY),g=[y-c[0],v-c[1]];e(3,o=a(d,u,g)),n("change",o)}},m=_=>{_.target.releasePointerCapture(_.pointerId),u=void 0,d=o,n("release",_)};return r.$$set=_=>{"shape"in _&&e(3,o=_.shape),"editor"in _&&e(4,a=_.editor),"transform"in _&&e(5,l=_.transform),"svgEl"in _&&e(6,h=_.svgEl),"$$scope"in _&&e(7,s=_.$$scope)},[p,f,m,o,a,l,h,s,i]}class Yh extends se{constructor(t){super(),ie(this,t,SC,AC,qt,{shape:3,editor:4,transform:5,svgEl:6})}}function CC(r){let t,e,i,s,n,o,a,l,h=r[3]&&Ym(r);return{c(){t=st("g"),e=st("circle"),h&&h.c(),s=st("circle"),w(e,"class","a9s-handle-buffer svelte-160z737"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]+6/r[2]),w(s,"class",n=Ln(`a9s-handle-dot${r[3]?" selected":""}`)+" svelte-160z737"),w(s,"cx",r[0]),w(s,"cy",r[1]),w(s,"r",r[5]),w(t,"class",o=Ln(`a9s-handle ${r[8].class||""}`.trim())+" svelte-160z737")},m(u,c){at(u,t,c),Ct(t,e),h&&h.m(t,null),Ct(t,s),a||(l=[Pt(e,"pointerenter",r[11]),Pt(e,"pointerleave",r[12]),Pt(e,"pointerdown",r[13]),Pt(e,"pointerdown",r[6]),Pt(e,"pointerup",r[14]),Pt(e,"pointerup",r[7])],a=!0)},p(u,c){c&1&&w(e,"cx",u[0]),c&2&&w(e,"cy",u[1]),c&36&&i!==(i=u[5]+6/u[2])&&w(e,"r",i),u[3]?h?h.p(u,c):(h=Ym(u),h.c(),h.m(t,s)):h&&(h.d(1),h=null),c&8&&n!==(n=Ln(`a9s-handle-dot${u[3]?" selected":""}`)+" svelte-160z737")&&w(s,"class",n),c&1&&w(s,"cx",u[0]),c&2&&w(s,"cy",u[1]),c&32&&w(s,"r",u[5]),c&256&&o!==(o=Ln(`a9s-handle ${u[8].class||""}`.trim())+" svelte-160z737")&&w(t,"class",o)},d(u){u&&nt(t),h&&h.d(),a=!1,ze(l)}}}function IC(r){let t,e,i,s,n,o,a,l,h;return{c(){t=st("g"),e=st("circle"),s=st("circle"),o=st("circle"),w(e,"cx",r[0]),w(e,"cy",r[1]),w(e,"r",i=r[5]*10),w(e,"class","a9s-touch-halo svelte-160z737"),Wi(e,"touched",r[4]),w(s,"cx",r[0]),w(s,"cy",r[1]),w(s,"r",n=r[5]+10/r[2]),w(s,"class","a9s-handle-buffer svelte-160z737"),w(o,"class","a9s-handle-dot svelte-160z737"),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(u,c){at(u,t,c),Ct(t,e),Ct(t,s),Ct(t,o),l||(h=[Pt(s,"pointerdown",r[9]),Pt(s,"pointerup",r[10]),Pt(s,"pointerdown",r[6]),Pt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&w(e,"cx",u[0]),c&2&&w(e,"cy",u[1]),c&32&&i!==(i=u[5]*10)&&w(e,"r",i),c&16&&Wi(e,"touched",u[4]),c&1&&w(s,"cx",u[0]),c&2&&w(s,"cy",u[1]),c&36&&n!==(n=u[5]+10/u[2])&&w(s,"r",n),c&1&&w(o,"cx",u[0]),c&2&&w(o,"cy",u[1]),c&36&&a!==(a=u[5]+2/u[2])&&w(o,"r",a)},d(u){u&&nt(t),l=!1,ze(h)}}}function Ym(r){let t,e;return{c(){t=st("circle"),w(t,"class","a9s-handle-selected svelte-160z737"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",e=r[5]+8/r[2])},m(i,s){at(i,t,s)},p(i,s){s&1&&w(t,"cx",i[0]),s&2&&w(t,"cy",i[1]),s&36&&e!==(e=i[5]+8/i[2])&&w(t,"r",e)},d(i){i&&nt(t)}}}function RC(r){let t;function e(n,o){return ci?IC:CC}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),at(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&nt(t),s.d(n)}}}function MC(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{selected:a=void 0}=t,l=!1;const h=y=>{y.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(y){Me.call(this,r,y)}function d(y){Me.call(this,r,y)}function p(y){Me.call(this,r,y)}function f(y){Me.call(this,r,y)}function m(y){Me.call(this,r,y)}function _(y){Me.call(this,r,y)}return r.$$set=y=>{e(8,t=Fa(Fa({},t),Yc(y))),"x"in y&&e(0,s=y.x),"y"in y&&e(1,n=y.y),"scale"in y&&e(2,o=y.scale),"selected"in y&&e(3,a=y.selected)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=4/o)},t=Yc(t),[s,n,o,a,l,i,h,u,t,c,d,p,f,m,_]}class As extends se{constructor(t){super(),ie(this,t,MC,RC,qt,{x:0,y:1,scale:2,selected:3})}}function PC(r){let t,e,i,s,n,o,a;return{c(){t=st("g"),e=st("circle"),s=st("circle"),n=st("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(s,"class","a9s-polygon-midpoint-outer svelte-12ykj76"),w(s,"cx",r[0]),w(s,"cy",r[1]),w(s,"r",r[2]),w(n,"class","a9s-polygon-midpoint-inner svelte-12ykj76"),w(n,"cx",r[0]),w(n,"cy",r[1]),w(n,"r",r[2]),w(t,"class","a9s-polygon-midpoint svelte-12ykj76")},m(l,h){at(l,t,h),Ct(t,e),Ct(t,s),Ct(t,n),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(s,"cx",l[0]),h&2&&w(s,"cy",l[1]),h&4&&w(s,"r",l[2]),h&1&&w(n,"cx",l[0]),h&2&&w(n,"cy",l[1]),h&4&&w(n,"r",l[2])},d(l){l&&nt(t),o=!1,ze(a)}}}function OC(r){let t;return{c(){t=st("circle"),w(t,"cx",r[0]),w(t,"cy",r[1]),w(t,"r",r[2])},m(e,i){at(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&&nt(t)}}}function NC(r){let t;function e(n,o){return ci?OC:PC}let s=e()(r);return{c(){s.c(),t=Ge()},m(n,o){s.m(n,o),at(n,t,o)},p(n,[o]){s.p(n,o)},i:Qt,o:Qt,d(n){n&&nt(t),s.d(n)}}}function DC(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t;const a=h=>{h.pointerType};function l(h){Me.call(this,r,h)}return r.$$set=h=>{"x"in h&&e(0,s=h.x),"y"in h&&e(1,n=h.y),"scale"in h&&e(4,o=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=4/o)},[s,n,i,a,o,l]}class jm extends se{constructor(t){super(),ie(this,t,DC,NC,qt,{x:0,y:1,scale:4})}}function jh(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function Wm(r,t,e){const i=r.slice();return i[28]=t[e],i[30]=e,i}function Wh(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function qh(r){const t=r.slice(),e=t[10][t[6]];return t[28]=e.point,t}function qm(r){let t,e,i,s;return{c(){t=st("circle"),w(t,"cx",e=r[28][0]),w(t,"cy",i=r[28][1]),w(t,"r",s=fn/r[3]),w(t,"class","svelte-1h2slbm")},m(n,o){at(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[28][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=n[28][1])&&w(t,"cy",i),o[0]&8&&s!==(s=fn/n[3])&&w(t,"r",s)},d(n){n&&nt(t)}}}function Km(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),w(e,"x",i=r[9].x),w(e,"y",s=r[9].y),w(e,"width",n=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",u=fn/r[3]),w(a,"class","svelte-1h2slbm"),w(t,"id",`${r[19]}-inner`),w(t,"class","a9s-polygon-editor-mask svelte-1h2slbm")},m(c,d){at(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&w(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&w(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&w(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=c[28][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=c[28][1])&&w(a,"cy",h),d[0]&8&&u!==(u=fn/c[3])&&w(a,"r",u)},d(c){c&&nt(t)}}}function Zm(r){let t,e;return t=new As({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(){Jt(r[27](`HANDLE-${r[30]}`))&&r[27](`HANDLE-${r[30]}`).apply(this,arguments)}),t.$on("pointerup",r[16](r[30])),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.x=r[28][0]),s[0]&32&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),s[0]&256&&(n.selected=r[8].includes(r[30])),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Qm(r){let t,e;return t=new jm({props:{x:r[28][0],y:r[28][1],scale:r[3]}}),t.$on("pointerdown",function(){Jt(r[18](r[6]))&&r[18](r[6]).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[28][0]),s[0]&1088&&(n.y=r[28][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function LC(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v,g,x,E,M=r[6]!==void 0&&!r[7]&&qm(qh(r)),S=r[6]!==void 0&&!r[7]&&Km(Wh(r)),R=Pe(r[5].points),P=[];for(let I=0;I<R.length;I+=1)P[I]=Zm(Wm(r,R,I));const F=I=>lt(P[I],1,1,()=>{P[I]=null});let k=r[6]!==void 0&&!r[7]&&Qm(jh(r));return{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("polygon"),M&&M.c(),S&&S.c(),u=Le(),c=st("polygon"),p=Le(),f=st("polygon"),_=Le();for(let I=0;I<P.length;I+=1)P[I].c();y=Le(),k&&k.c(),v=Ge(),w(i,"x",s=r[9].x),w(i,"y",n=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(Jm).join(" ")),w(l,"class","svelte-1h2slbm"),w(e,"id",`${r[19]}-outer`),w(e,"class","a9s-polygon-editor-mask svelte-1h2slbm"),w(c,"class","a9s-outer"),w(c,"mask",`url(#${r[19]}-outer)`),w(c,"points",d=r[5].points.map(tg).join(" ")),w(f,"class","a9s-inner a9s-shape-handle"),w(f,"mask",`url(#${r[19]}-inner)`),w(f,"style",r[1]),w(f,"points",m=r[5].points.map(eg).join(" "))},m(I,A){at(I,t,A),Ct(t,e),Ct(e,i),Ct(e,l),M&&M.m(e,null),S&&S.m(t,null),at(I,u,A),at(I,c,A),at(I,p,A),at(I,f,A),at(I,_,A);for(let T=0;T<P.length;T+=1)P[T]&&P[T].m(I,A);at(I,y,A),k&&k.m(I,A),at(I,v,A),g=!0,x||(E=[Pt(c,"pointerup",r[14]),Pt(c,"pointerdown",function(){Jt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)}),Pt(f,"pointermove",r[13]),Pt(f,"pointerup",r[14]),Pt(f,"pointerdown",function(){Jt(r[27]("SHAPE"))&&r[27]("SHAPE").apply(this,arguments)})],x=!0)},p(I,A){if(r=I,(!g||A[0]&512&&s!==(s=r[9].x))&&w(i,"x",s),(!g||A[0]&512&&n!==(n=r[9].y))&&w(i,"y",n),(!g||A[0]&512&&o!==(o=r[9].w))&&w(i,"width",o),(!g||A[0]&512&&a!==(a=r[9].h))&&w(i,"height",a),(!g||A[0]&32&&h!==(h=r[5].points.map(Jm).join(" ")))&&w(l,"points",h),r[6]!==void 0&&!r[7]?M?M.p(qh(r),A):(M=qm(qh(r)),M.c(),M.m(e,null)):M&&(M.d(1),M=null),r[6]!==void 0&&!r[7]?S?S.p(Wh(r),A):(S=Km(Wh(r)),S.c(),S.m(t,null)):S&&(S.d(1),S=null),(!g||A[0]&32&&d!==(d=r[5].points.map(tg).join(" ")))&&w(c,"points",d),(!g||A[0]&2)&&w(f,"style",r[1]),(!g||A[0]&32&&m!==(m=r[5].points.map(eg).join(" ")))&&w(f,"points",m),A[0]&134322472){R=Pe(r[5].points);let T;for(T=0;T<R.length;T+=1){const C=Wm(r,R,T);P[T]?(P[T].p(C,A),q(P[T],1)):(P[T]=Zm(C),P[T].c(),q(P[T],1),P[T].m(y.parentNode,y))}for(fe(),T=R.length;T<P.length;T+=1)F(T);pe()}r[6]!==void 0&&!r[7]?k?(k.p(jh(r),A),A[0]&192&&q(k,1)):(k=Qm(jh(r)),k.c(),q(k,1),k.m(v.parentNode,v)):k&&(fe(),lt(k,1,1,()=>{k=null}),pe())},i(I){if(!g){for(let A=0;A<R.length;A+=1)q(P[A]);q(k),g=!0}},o(I){P=P.filter(Boolean);for(let A=0;A<P.length;A+=1)lt(P[A]);lt(k),g=!1},d(I){I&&(nt(t),nt(u),nt(c),nt(p),nt(f),nt(_),nt(y),nt(v)),M&&M.d(),S&&S.d(),Yr(P,I),k&&k.d(I),x=!1,ze(E)}}}function BC(r){let t,e;return t=new Yh({props:{shape:r[0],transform:r[2],editor:r[17],svgEl:r[4],$$slots:{default:[LC,({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(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&134219754|s[1]&1&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}const FC=250,UC=1e3,kC=12,fn=4.5,Jm=r=>r.join(","),tg=r=>r.join(","),eg=r=>r.join(",");function GC(r,t,e){let i,s,n;const o=Ki();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p=!1,f,m=[];const _=()=>e(7,p=!0),y=()=>e(7,p=!1),v=T=>{if(m.length>0){e(6,d=void 0);return}const[C,L]=h.elementToImage(T.offsetX,T.offsetY),N=U=>Math.pow(U[0]-C,2)+Math.pow(U[1]-L,2),B=i.points.reduce((U,V)=>N(V)<N(U)?V:U),X=s.filter(U=>U.visible).reduce((U,V)=>N(V.point)<N(U.point)?V:U),O=Math.pow(UC/u,2);N(B)<O||N(X.point)<O?e(6,d=s.indexOf(X)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=T=>{e(7,p=!0),T.preventDefault(),T.stopPropagation(),f=performance.now()},M=T=>C=>{if(!f||ci||performance.now()-f>FC)return;const L=m.includes(T);C.metaKey||C.ctrlKey||C.shiftKey?L?e(8,m=m.filter(N=>N!==T)):e(8,m=[...m,T]):L&&m.length>1?e(8,m=[T]):L?e(8,m=[]):e(8,m=[T]),g()},S=(T,C,L)=>{g();let N;const B=T.geometry;m.length>1?N=B.points.map(([O,D],U)=>m.includes(U)?[O+L[0],D+L[1]]:[O,D]):C==="SHAPE"?N=B.points.map(([O,D])=>[O+L[0],D+L[1]]):N=B.points.map(([O,D],U)=>C===`HANDLE-${U}`?[O+L[0],D+L[1]]:[O,D]);const X=li(N);return{...T,geometry:{points:N,bounds:X}}},R=T=>async C=>{C.stopPropagation();const L=[...i.points.slice(0,T+1),s[T].point,...i.points.slice(T+1)],N=li(L);o("change",{...a,geometry:{points:L,bounds:N}}),await Zc();const B=[...document.querySelectorAll(".a9s-handle")][T+1];if(B!=null&&B.firstChild){const X=new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,clientX:C.clientX,clientY:C.clientY,pointerId:C.pointerId,pointerType:C.pointerType,isPrimary:C.isPrimary,buttons:C.buttons});B.firstChild.dispatchEvent(X)}},P=()=>{if(i.points.length<4)return;const T=i.points.filter((L,N)=>!m.includes(N)),C=li(T);o("change",{...a,geometry:{points:T,bounds:C}}),e(8,m=[])};qi(()=>{if(ci)return;const T=C=>{(C.key==="Delete"||C.key==="Backspace")&&(C.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",T),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",T)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`;function k(T){Me.call(this,r,T)}function I(T){Me.call(this,r,T)}function A(T){Me.call(this,r,T)}return r.$$set=T=>{"shape"in T&&e(0,a=T.shape),"computedStyle"in T&&e(1,l=T.computedStyle),"transform"in T&&e(2,h=T.transform),"viewportScale"in T&&e(3,u=T.viewportScale),"svgEl"in T&&e(4,c=T.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=ci?[]:i.points.map((T,C)=>{const L=C===i.points.length-1?i.points[0]:i.points[C+1],N=(T[0]+L[0])/2,B=(T[1]+L[1])/2,O=Math.sqrt(Math.pow(L[0]-N,2)+Math.pow(L[1]-B,2))>kC/u;return{point:[N,B],visible:O}})),r.$$.dirty[0]&40&&e(9,n=zh(i.bounds,fn/u))},[a,l,h,u,c,i,d,p,m,n,s,_,y,v,x,E,M,S,R,F,k,I,A]}class HC extends se{constructor(t){super(),ie(this,t,GC,BC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}function $C(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v,g,x,E,M,S,R,P,F,k,I,A,T,C,L,N,B,X,O,D,U,V,j,Q,yt,Tt,Y,bt,dt,pt,vt,Mt,Nt,_e,Wt,et,qe,mn;return dt=new As({props:{class:"a9s-corner-handle-topleft",x:r[5].x,y:r[5].y,scale:r[3]}}),dt.$on("pointerdown",function(){Jt(r[12]("TOP_LEFT"))&&r[12]("TOP_LEFT").apply(this,arguments)}),vt=new As({props:{class:"a9s-corner-handle-topright",x:r[5].x+r[5].w,y:r[5].y,scale:r[3]}}),vt.$on("pointerdown",function(){Jt(r[12]("TOP_RIGHT"))&&r[12]("TOP_RIGHT").apply(this,arguments)}),Nt=new As({props:{class:"a9s-corner-handle-bottomright",x:r[5].x+r[5].w,y:r[5].y+r[5].h,scale:r[3]}}),Nt.$on("pointerdown",function(){Jt(r[12]("BOTTOM_RIGHT"))&&r[12]("BOTTOM_RIGHT").apply(this,arguments)}),Wt=new As({props:{class:"a9s-corner-handle-bottomleft",x:r[5].x,y:r[5].y+r[5].h,scale:r[3]}}),Wt.$on("pointerdown",function(){Jt(r[12]("BOTTOM_LEFT"))&&r[12]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=st("defs"),e=st("mask"),i=st("rect"),l=st("rect"),p=Le(),f=st("rect"),g=Le(),x=st("rect"),P=Le(),F=st("rect"),T=Le(),C=st("rect"),X=Le(),O=st("rect"),j=Le(),Q=st("rect"),bt=Le(),Ht(dt.$$.fragment),pt=Le(),Ht(vt.$$.fragment),Mt=Le(),Ht(Nt.$$.fragment),_e=Le(),Ht(Wt.$$.fragment),w(i,"class","rect-mask-bg svelte-1njczvj"),w(i,"x",s=r[6].x),w(i,"y",n=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",u=r[5].y),w(l,"width",c=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(f,"class","a9s-outer"),w(f,"mask",`url(#${r[8]})`),w(f,"x",m=r[5].x),w(f,"y",_=r[5].y),w(f,"width",y=r[5].w),w(f,"height",v=r[5].h),w(x,"class","a9s-inner a9s-shape-handle"),w(x,"style",r[1]),w(x,"x",E=r[5].x),w(x,"y",M=r[5].y),w(x,"width",S=r[5].w),w(x,"height",R=r[5].h),w(F,"class","a9s-edge-handle a9s-edge-handle-top"),w(F,"x",k=r[5].x),w(F,"y",I=r[5].y),w(F,"height",1),w(F,"width",A=r[5].w),w(C,"class","a9s-edge-handle a9s-edge-handle-right"),w(C,"x",L=r[5].x+r[5].w),w(C,"y",N=r[5].y),w(C,"height",B=r[5].h),w(C,"width",1),w(O,"class","a9s-edge-handle a9s-edge-handle-bottom"),w(O,"x",D=r[5].x),w(O,"y",U=r[5].y+r[5].h),w(O,"height",1),w(O,"width",V=r[5].w),w(Q,"class","a9s-edge-handle a9s-edge-handle-left"),w(Q,"x",yt=r[5].x),w(Q,"y",Tt=r[5].y),w(Q,"height",Y=r[5].h),w(Q,"width",1)},m(W,H){at(W,t,H),Ct(t,e),Ct(e,i),Ct(e,l),at(W,p,H),at(W,f,H),at(W,g,H),at(W,x,H),at(W,P,H),at(W,F,H),at(W,T,H),at(W,C,H),at(W,X,H),at(W,O,H),at(W,j,H),at(W,Q,H),at(W,bt,H),Ft(dt,W,H),at(W,pt,H),Ft(vt,W,H),at(W,Mt,H),Ft(Nt,W,H),at(W,_e,H),Ft(Wt,W,H),et=!0,qe||(mn=[Pt(f,"pointerdown",function(){Jt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(x,"pointerdown",function(){Jt(r[12]("SHAPE"))&&r[12]("SHAPE").apply(this,arguments)}),Pt(F,"pointerdown",function(){Jt(r[12]("TOP"))&&r[12]("TOP").apply(this,arguments)}),Pt(C,"pointerdown",function(){Jt(r[12]("RIGHT"))&&r[12]("RIGHT").apply(this,arguments)}),Pt(O,"pointerdown",function(){Jt(r[12]("BOTTOM"))&&r[12]("BOTTOM").apply(this,arguments)}),Pt(Q,"pointerdown",function(){Jt(r[12]("LEFT"))&&r[12]("LEFT").apply(this,arguments)})],qe=!0)},p(W,H){r=W,(!et||H&64&&s!==(s=r[6].x))&&w(i,"x",s),(!et||H&64&&n!==(n=r[6].y))&&w(i,"y",n),(!et||H&64&&o!==(o=r[6].w))&&w(i,"width",o),(!et||H&64&&a!==(a=r[6].h))&&w(i,"height",a),(!et||H&32&&h!==(h=r[5].x))&&w(l,"x",h),(!et||H&32&&u!==(u=r[5].y))&&w(l,"y",u),(!et||H&32&&c!==(c=r[5].w))&&w(l,"width",c),(!et||H&32&&d!==(d=r[5].h))&&w(l,"height",d),(!et||H&32&&m!==(m=r[5].x))&&w(f,"x",m),(!et||H&32&&_!==(_=r[5].y))&&w(f,"y",_),(!et||H&32&&y!==(y=r[5].w))&&w(f,"width",y),(!et||H&32&&v!==(v=r[5].h))&&w(f,"height",v),(!et||H&2)&&w(x,"style",r[1]),(!et||H&32&&E!==(E=r[5].x))&&w(x,"x",E),(!et||H&32&&M!==(M=r[5].y))&&w(x,"y",M),(!et||H&32&&S!==(S=r[5].w))&&w(x,"width",S),(!et||H&32&&R!==(R=r[5].h))&&w(x,"height",R),(!et||H&32&&k!==(k=r[5].x))&&w(F,"x",k),(!et||H&32&&I!==(I=r[5].y))&&w(F,"y",I),(!et||H&32&&A!==(A=r[5].w))&&w(F,"width",A),(!et||H&32&&L!==(L=r[5].x+r[5].w))&&w(C,"x",L),(!et||H&32&&N!==(N=r[5].y))&&w(C,"y",N),(!et||H&32&&B!==(B=r[5].h))&&w(C,"height",B),(!et||H&32&&D!==(D=r[5].x))&&w(O,"x",D),(!et||H&32&&U!==(U=r[5].y+r[5].h))&&w(O,"y",U),(!et||H&32&&V!==(V=r[5].w))&&w(O,"width",V),(!et||H&32&&yt!==(yt=r[5].x))&&w(Q,"x",yt),(!et||H&32&&Tt!==(Tt=r[5].y))&&w(Q,"y",Tt),(!et||H&32&&Y!==(Y=r[5].h))&&w(Q,"height",Y);const Fr={};H&32&&(Fr.x=r[5].x),H&32&&(Fr.y=r[5].y),H&8&&(Fr.scale=r[3]),dt.$set(Fr);const Ur={};H&32&&(Ur.x=r[5].x+r[5].w),H&32&&(Ur.y=r[5].y),H&8&&(Ur.scale=r[3]),vt.$set(Ur);const kr={};H&32&&(kr.x=r[5].x+r[5].w),H&32&&(kr.y=r[5].y+r[5].h),H&8&&(kr.scale=r[3]),Nt.$set(kr);const Gr={};H&32&&(Gr.x=r[5].x),H&32&&(Gr.y=r[5].y+r[5].h),H&8&&(Gr.scale=r[3]),Wt.$set(Gr)},i(W){et||(q(dt.$$.fragment,W),q(vt.$$.fragment,W),q(Nt.$$.fragment,W),q(Wt.$$.fragment,W),et=!0)},o(W){lt(dt.$$.fragment,W),lt(vt.$$.fragment,W),lt(Nt.$$.fragment,W),lt(Wt.$$.fragment,W),et=!1},d(W){W&&(nt(t),nt(p),nt(f),nt(g),nt(x),nt(P),nt(F),nt(T),nt(C),nt(X),nt(O),nt(j),nt(Q),nt(bt),nt(pt),nt(Mt),nt(_e)),Ut(dt,W),Ut(vt,W),Ut(Nt,W),Ut(Wt,W),qe=!1,ze(mn)}}}function XC(r){let t,e;return t=new Yh({props:{shape:r[0],transform:r[2],editor:r[7],svgEl:r[4],$$slots:{default:[$C,({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(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&16&&(n.svgEl=i[4]),s&12394&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function VC(r,t,e){let i,s,{shape:n}=t,{computedStyle:o}=t,{transform:a}=t,{viewportScale:l=1}=t,{svgEl:h}=t;const u=(m,_,y)=>{const v=m.geometry.bounds;let[g,x]=[v.minX,v.minY],[E,M]=[v.maxX,v.maxY];const[S,R]=y;if(_==="SHAPE")g+=S,E+=S,x+=R,M+=R;else{switch(_){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{x+=R;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{M+=R;break}}switch(_){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=S;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{E+=S;break}}}const P=Math.min(g,E),F=Math.min(x,M),k=Math.abs(E-g),I=Math.abs(M-x);return{...m,geometry:{x:P,y:F,w:k,h:I,bounds:{minX:P,minY:F,maxX:P+k,maxY:F+I}}}},c=`rect-mask-${Math.random().toString(36).substring(2,12)}`;function d(m){Me.call(this,r,m)}function p(m){Me.call(this,r,m)}function f(m){Me.call(this,r,m)}return r.$$set=m=>{"shape"in m&&e(0,n=m.shape),"computedStyle"in m&&e(1,o=m.computedStyle),"transform"in m&&e(2,a=m.transform),"viewportScale"in m&&e(3,l=m.viewportScale),"svgEl"in m&&e(4,h=m.svgEl)},r.$$.update=()=>{r.$$.dirty&1&&e(5,i=n.geometry),r.$$.dirty&40&&e(6,s=zh(i.bounds,2/l))},[n,o,a,l,h,i,s,u,c,d,p,f]}class zC extends se{constructor(t){super(),ie(this,t,VC,XC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4})}}var rg=Object.prototype.hasOwnProperty;function Kh(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--&&Kh(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(rg.call(r,e)&&++i&&!rg.call(t,e)||!(e in t)||!Kh(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}const YC=12,jC=(r,t)=>r.polygons.reduce((e,i,s)=>{const n=i.rings.reduce((o,a,l)=>{const h=a.points.map((u,c)=>{const d=c===a.points.length-1?a.points[0]:a.points[c+1],p=(u[0]+d[0])/2,f=(u[1]+d[1])/2,_=Math.sqrt(Math.pow(d[0]-p,2)+Math.pow(d[1]-f,2))>YC/t;return{point:[p,f],visible:_,elementIdx:s,ringIdx:l,pointIdx:c}});return[...o,...h]},[]);return[...e,...n]},[]);function Zh(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function ig(r,t,e){const i=r.slice();return i[30]=t[e],i[32]=e,i}function sg(r,t,e){const i=r.slice();return i[33]=t[e],i[35]=e,i}function ng(r,t,e){const i=r.slice();return i[29]=t[e],i[37]=e,i}function Qh(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function Jh(r){const t=r.slice(),e=t[10][t[6]];return t[29]=e.point,t}function og(r){let t,e,i,s;return{c(){t=st("circle"),w(t,"cx",e=r[29][0]),w(t,"cy",i=r[29][1]),w(t,"r",s=pn/r[3]),w(t,"class","svelte-1vxo6dc")},m(n,o){at(n,t,o)},p(n,o){o[0]&1088&&e!==(e=n[29][0])&&w(t,"cx",e),o[0]&1088&&i!==(i=n[29][1])&&w(t,"cy",i),o[0]&8&&s!==(s=pn/n[3])&&w(t,"r",s)},d(n){n&&nt(t)}}}function ag(r){let t,e,i,s,n,o,a,l,h,u;return{c(){t=st("mask"),e=st("rect"),a=st("circle"),w(e,"x",i=r[9].x),w(e,"y",s=r[9].y),w(e,"width",n=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",u=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(c,d){at(c,t,d),Ct(t,e),Ct(t,a)},p(c,d){d[0]&512&&i!==(i=c[9].x)&&w(e,"x",i),d[0]&512&&s!==(s=c[9].y)&&w(e,"y",s),d[0]&512&&n!==(n=c[9].w)&&w(e,"width",n),d[0]&512&&o!==(o=c[9].h)&&w(e,"height",o),d[0]&1088&&l!==(l=c[29][0])&&w(a,"cx",l),d[0]&1088&&h!==(h=c[29][1])&&w(a,"cy",h),d[0]&8&&u!==(u=pn/c[3])&&w(a,"r",u)},d(c){c&&nt(t)}}}function lg(r){let t,e;function i(...s){return r[19](r[32],r[35],r[37],...s)}return t=new As({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(){Jt(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(){Ht(t.$$.fragment)},m(s,n){Ft(t,s,n),e=!0},p(s,n){r=s;const o={};n[0]&32&&(o.x=r[29][0]),n[0]&32&&(o.y=r[29][1]),n[0]&8&&(o.scale=r[3]),n[0]&256&&(o.selected=r[8].some(i)),t.$set(o)},i(s){e||(q(t.$$.fragment,s),e=!0)},o(s){lt(t.$$.fragment,s),e=!1},d(s){Ut(t,s)}}}function hg(r){let t,e,i=Pe(r[33].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=lg(ng(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a[0]&268491048){i=Pe(o[33].points);let l;for(l=0;l<i.length;l+=1){const h=ng(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=lg(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Yr(s,o)}}}function ug(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,_,y,v=r[6]!==void 0&&!r[7]&&og(Jh(r)),g=r[6]!==void 0&&!r[7]&&ag(Qh(r)),x=Pe(r[30].rings),E=[];for(let S=0;S<x.length;S+=1)E[S]=hg(sg(r,x,S));const M=S=>lt(E[S],1,1,()=>{E[S]=null});return{c(){t=st("g"),e=st("defs"),i=st("mask"),s=st("rect"),h=st("path"),v&&v.c(),g&&g.c(),c=st("path"),p=st("path");for(let S=0;S<E.length;S+=1)E[S].c();w(s,"x",n=r[9].x),w(s,"y",o=r[9].y),w(s,"width",a=r[9].w),w(s,"height",l=r[9].h),w(s,"class","svelte-1vxo6dc"),w(h,"d",u=ws(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(c,"class","a9s-outer"),w(c,"mask",`url(#${r[18]}-${r[32]}-outer)`),w(c,"fill-rule","evenodd"),w(c,"d",d=ws(r[30])),w(p,"class","a9s-inner"),w(p,"mask",`url(#${r[18]}-${r[32]}-inner)`),w(p,"style",r[1]),w(p,"fill-rule","evenodd"),w(p,"d",f=ws(r[30]))},m(S,R){at(S,t,R),Ct(t,e),Ct(e,i),Ct(i,s),Ct(i,h),v&&v.m(i,null),g&&g.m(e,null),Ct(t,c),Ct(t,p);for(let P=0;P<E.length;P+=1)E[P]&&E[P].m(t,null);m=!0,_||(y=[Pt(c,"pointerup",r[13]),Pt(c,"pointerdown",function(){Jt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)}),Pt(p,"pointerup",r[13]),Pt(p,"pointerdown",function(){Jt(r[28]("SHAPE"))&&r[28]("SHAPE").apply(this,arguments)})],_=!0)},p(S,R){if(r=S,(!m||R[0]&512&&n!==(n=r[9].x))&&w(s,"x",n),(!m||R[0]&512&&o!==(o=r[9].y))&&w(s,"y",o),(!m||R[0]&512&&a!==(a=r[9].w))&&w(s,"width",a),(!m||R[0]&512&&l!==(l=r[9].h))&&w(s,"height",l),(!m||R[0]&32&&u!==(u=ws(r[30])))&&w(h,"d",u),r[6]!==void 0&&!r[7]?v?v.p(Jh(r),R):(v=og(Jh(r)),v.c(),v.m(i,null)):v&&(v.d(1),v=null),r[6]!==void 0&&!r[7]?g?g.p(Qh(r),R):(g=ag(Qh(r)),g.c(),g.m(e,null)):g&&(g.d(1),g=null),(!m||R[0]&32&&d!==(d=ws(r[30])))&&w(c,"d",d),(!m||R[0]&2)&&w(p,"style",r[1]),(!m||R[0]&32&&f!==(f=ws(r[30])))&&w(p,"d",f),R[0]&268491048){x=Pe(r[30].rings);let P;for(P=0;P<x.length;P+=1){const F=sg(r,x,P);E[P]?(E[P].p(F,R),q(E[P],1)):(E[P]=hg(F),E[P].c(),q(E[P],1),E[P].m(t,null))}for(fe(),P=x.length;P<E.length;P+=1)M(P);pe()}},i(S){if(!m){for(let R=0;R<x.length;R+=1)q(E[R]);m=!0}},o(S){E=E.filter(Boolean);for(let R=0;R<E.length;R+=1)lt(E[R]);m=!1},d(S){S&&nt(t),v&&v.d(),g&&g.d(),Yr(E,S),_=!1,ze(y)}}}function cg(r){let t,e;return t=new jm({props:{x:r[29][0],y:r[29][1],scale:r[3]}}),t.$on("pointerdown",function(){Jt(r[17](r[6]))&&r[17](r[6]).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&1088&&(n.x=r[29][0]),s[0]&1088&&(n.y=r[29][1]),s[0]&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function WC(r){let t,e,i,s=Pe(r[5].polygons),n=[];for(let l=0;l<s.length;l+=1)n[l]=ug(ig(r,s,l));const o=l=>lt(n[l],1,1,()=>{n[l]=null});let a=r[6]!==void 0&&!r[7]&&cg(Zh(r));return{c(){for(let l=0;l<n.length;l+=1)n[l].c();t=Le(),a&&a.c(),e=Ge()},m(l,h){for(let u=0;u<n.length;u+=1)n[u]&&n[u].m(l,h);at(l,t,h),a&&a.m(l,h),at(l,e,h),i=!0},p(l,h){if(h[0]&268763114){s=Pe(l[5].polygons);let u;for(u=0;u<s.length;u+=1){const c=ig(l,s,u);n[u]?(n[u].p(c,h),q(n[u],1)):(n[u]=ug(c),n[u].c(),q(n[u],1),n[u].m(t.parentNode,t))}for(fe(),u=s.length;u<n.length;u+=1)o(u);pe()}l[6]!==void 0&&!l[7]?a?(a.p(Zh(l),h),h[0]&192&&q(a,1)):(a=cg(Zh(l)),a.c(),q(a,1),a.m(e.parentNode,e)):a&&(fe(),lt(a,1,1,()=>{a=null}),pe())},i(l){if(!i){for(let h=0;h<s.length;h+=1)q(n[h]);q(a),i=!0}},o(l){n=n.filter(Boolean);for(let h=0;h<n.length;h+=1)lt(n[h]);lt(a),i=!1},d(l){l&&(nt(t),nt(e)),Yr(n,l),a&&a.d(l)}}}function qC(r){let t,e;return t=new Yh({props:{shape:r[0],transform:r[2],editor:r[16],svgEl:r[4],$$slots:{default:[WC,({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(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&1&&(n.shape=i[0]),s[0]&4&&(n.transform=i[2]),s[0]&16&&(n.svgEl=i[4]),s[0]&268437482|s[1]&128&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}const KC=250,ZC=1e3,pn=4.5;function QC(r,t,e){let i,s,n;const o=Ki();let{shape:a}=t,{computedStyle:l}=t,{transform:h}=t,{viewportScale:u=1}=t,{svgEl:c}=t,d,p=!1,f,m=[];const _=()=>e(7,p=!0),y=()=>e(7,p=!1),v=C=>{if(m.length>0){e(6,d=void 0);return}const[L,N]=h.elementToImage(C.offsetX,C.offsetY),B=V=>Math.pow(V[0]-L,2)+Math.pow(V[1]-N,2),X=JS(i).reduce((V,j)=>B(j)<B(V)?j:V),O=s.filter(V=>V.visible).reduce((V,j)=>B(j.point)<B(V.point)?j:V),D=Math.pow(ZC/u,2);B(X)<D||B(O.point)<D?e(6,d=s.indexOf(O)):e(6,d=void 0)},g=()=>{document.activeElement!==c&&c.focus()},x=()=>{e(8,m=[]),g()},E=C=>{e(7,p=!0),C.preventDefault(),C.stopPropagation(),f=performance.now()},M=(C,L,N)=>B=>{if(!f||ci||performance.now()-f>KC)return;const X=D=>D.polygon===C&&D.ring===L&&D.point===N,O=m.some(X);B.metaKey||B.ctrlKey||B.shiftKey?O?e(8,m=m.filter(D=>!X(D))):e(8,m=[...m,{polygon:C,ring:L,point:N}]):O&&m.length>1?e(8,m=[{polygon:C,ring:L,point:N}]):O?e(8,m=[]):e(8,m=[{polygon:C,ring:L,point:N}]),g()},S=(C,L,N)=>{g();const B=C.geometry.polygons;let X;if(L==="SHAPE")X=B.map(O=>{const D=O.rings.map((V,j)=>({points:V.points.map((yt,Tt)=>[yt[0]+N[0],yt[1]+N[1]])})),U=li(D[0].points);return{rings:D,bounds:U}});else{const[O,D,U,V]=L.split("-").map(j=>parseInt(j));X=B.map((j,Q)=>{if(Q===D){const yt=j.rings.map((Y,bt)=>bt===U?{points:Y.points.map((pt,vt)=>vt===V?[pt[0]+N[0],pt[1]+N[1]]:pt)}:Y),Tt=li(yt[0].points);return{rings:yt,bounds:Tt}}else return j})}return{...C,geometry:{polygons:X,bounds:Hh(X)}}},R=C=>async L=>{L.stopPropagation();const N=s[C],B=i.polygons.map((O,D)=>{if(D===N.elementIdx){const U=O.rings.map((j,Q)=>Q===N.ringIdx?{points:[...j.points.slice(0,N.pointIdx+1),N.point,...j.points.slice(N.pointIdx+1)]}:j),V=li(U[0].points);return{rings:U,bounds:V}}else return O});o("change",{...a,geometry:{polygons:B,bounds:Hh(B)}}),await Zc();const X=[...document.querySelectorAll(".a9s-handle")][C+1];if(X!=null&&X.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});X.firstChild.dispatchEvent(O)}},P=()=>{const C=i.polygons.map((N,B)=>{if(m.some(O=>O.polygon===B)){const O=N.rings.map((U,V)=>m.some(Q=>Q.polygon===B&&Q.ring===V)&&U.points.length>3?{points:U.points.filter((yt,Tt)=>!m.some(Y=>Y.polygon===B&&Y.ring===V&&Y.point===Tt))}:U),D=li(O[0].points);return{rings:O,bounds:D}}else return N});!Kh(i.polygons,C)&&(o("change",{...a,geometry:{polygons:C,bounds:Hh(C)}}),e(8,m=[]))};qi(()=>{if(ci)return;const C=L=>{(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),P())};return c.addEventListener("pointermove",v),c.addEventListener("keydown",C),()=>{c.removeEventListener("pointermove",v),c.removeEventListener("keydown",C)}});const F=`polygon-mask-${Math.random().toString(36).substring(2,12)}`,k=(C,L,N,{polygon:B,ring:X,point:O})=>B===C&&X===L&&O===N;function I(C){Me.call(this,r,C)}function A(C){Me.call(this,r,C)}function T(C){Me.call(this,r,C)}return r.$$set=C=>{"shape"in C&&e(0,a=C.shape),"computedStyle"in C&&e(1,l=C.computedStyle),"transform"in C&&e(2,h=C.transform),"viewportScale"in C&&e(3,u=C.viewportScale),"svgEl"in C&&e(4,c=C.svgEl)},r.$$.update=()=>{r.$$.dirty[0]&1&&e(5,i=a.geometry),r.$$.dirty[0]&40&&e(10,s=ci?[]:jC(i,u)),r.$$.dirty[0]&40&&e(9,n=zh(i.bounds,pn/u))},[a,l,h,u,c,i,d,p,m,n,s,_,y,x,E,M,S,R,F,k,I,A,T]}class JC extends se{constructor(t){super(),ie(this,t,QC,qC,qt,{shape:0,computedStyle:1,transform:2,viewportScale:3,svgEl:4},null,[-1,-1])}}ai.RECTANGLE,ai.POLYGON,ai.MULTIPOLYGLON;function t2(r,t,e){let i;const s=Ki();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return qi(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u,svgEl:l.closest("svg")}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=TC(n,a)),r.$$.dirty&65&&n&&(c==null||c.$set({shape:n.target.selector})),r.$$.dirty&80&&c&&c.$set({transform:h}),r.$$.dirty&96&&c&&c.$set({viewportScale:u}),r.$$.dirty&192&&c&&i&&c.$set({computedStyle:i})},[n,o,a,l,h,u,c,i]}class e2 extends se{constructor(t){super(),ie(this,t,t2,null,qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const dg=(r,t,e,i)=>{if(!i)return r;if(t.shiftKey||t.ctrlKey||t.metaKey){const n=(e.selected||[]).map(o=>o.id);return n.includes(r)?n.filter(o=>o!==r):[...n,r]}else return r},r2=r=>({transform:r&2,scale:r&1}),fg=r=>({transform:r[1],scale:r[0]});function i2(r){let t;const e=r[4].default,i=Hc(e,r,r[3],fg);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Vc(i,e,s,s[3],t?Xc(e,s[3],n,r2):zc(s[3]),fg)},i(s){t||(q(i,s),t=!0)},o(s){lt(i,s),t=!1},d(s){i&&i.d(s)}}}function s2(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,u=n.viewport.getZoom(!0),c=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new Se.Point(0,0),!0);c&&(d.x=h-d.x);const p=u*h/n.world.getContentFactor(),f=c?-p:p,m=n.viewport.getRotation(!0);e(1,a=`translate(${d.x}, ${d.y}) scale(${f}, ${p}) rotate(${m})`),e(0,o=u*h/n.world.getContentFactor())};return qi(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class tu extends se{constructor(t){super(),ie(this,t,s2,i2,qt,{viewer:2})}}function n2(r,t,e){const i=Ki();let{drawingMode:s}=t,{opts:n}=t,{target:o}=t,{tool:a}=t,{transform:l}=t,{viewer:h}=t,{viewportScale:u}=t,c;return qi(()=>{const d=o.closest("svg"),p=[],f=(m,_,y)=>{if(d==null||d.addEventListener(m,_,y),p.push(()=>d==null?void 0:d.removeEventListener(m,_,y)),m==="pointerup"||m==="dblclick"){const v=x=>{const{originalEvent:E}=x;_(E)},g=m==="pointerup"?"canvas-click":"canvas-double-click";h.addHandler(g,v),p.push(()=>h.removeHandler(g,v))}else if(m==="pointermove"){const v=g=>{const{originalEvent:x}=g;_(x)};h.addHandler("canvas-drag",v),p.push(()=>h.removeHandler("canvas-drag",v))}};return e(7,c=new a({target:o,props:{addEventListener:f,drawingMode:s,opts:n,transform:l,viewportScale:u,svgEl:d}})),c.$on("create",m=>i("create",m.detail)),()=>{p.forEach(m=>m()),c.$destroy()}}),r.$$set=d=>{"drawingMode"in d&&e(0,s=d.drawingMode),"opts"in d&&e(1,n=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,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&144&&c&&c.$set({transform:l}),r.$$.dirty&192&&c&&c.$set({viewportScale:u})},[s,n,o,a,l,h,u,c]}class o2 extends se{constructor(t){super(),ie(this,t,n2,null,qt,{drawingMode:0,opts:1,target:2,tool:3,transform:4,viewer:5,viewportScale:6})}}function pg(r,t,e){const i=r.slice();i[35]=t[e];const s=i[16](i[35].target.selector);return i[36]=s,i}function a2(r){let t=`${r[2]}-${r[6]}`,e,i,s=mg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),at(n,e,o),i=!0},p(n,o){o[0]&68&&qt(t,t=`${n[2]}-${n[6]}`)?(fe(),lt(s,1,1,Qt),pe(),s=mg(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function l2(r){let t,e,i=Pe(r[8].filter(r[26])),s=[];for(let o=0;o<i.length;o+=1)s[o]=_g(pg(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a[0]&96642|a[1]&8){i=Pe(o[8].filter(o[26]));let l;for(l=0;l<i.length;l+=1){const h=pg(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=_g(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Yr(s,o)}}}function mg(r){let t,e;return t=new o2({props:{target:r[7],tool:r[9],drawingMode:r[4],transform:{elementToImage:r[11]},viewer:r[3],viewportScale:r[34],opts:r[5]}}),t.$on("create",r[15]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&128&&(n.target=i[7]),s[0]&512&&(n.tool=i[9]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&8&&(n.viewportScale=i[34]),s[0]&32&&(n.opts=i[5]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function gg(r){let t=r[35].id,e,i,s=yg(r);return{c(){s.c(),e=Ge()},m(n,o){s.m(n,o),at(n,e,o),i=!0},p(n,o){o[0]&256&&qt(t,t=n[35].id)?(fe(),lt(s,1,1,Qt),pe(),s=yg(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function yg(r){let t,e;return t=new e2({props:{target:r[7],editor:r[16](r[35].target.selector),annotation:r[35],style:r[1],transform:{elementToImage:r[11]},viewportScale:r[34]}}),t.$on("grab",r[12]),t.$on("change",function(){Jt(r[14](r[35]))&&r[14](r[35]).apply(this,arguments)}),t.$on("release",r[13]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&128&&(n.target=r[7]),s[0]&256&&(n.editor=r[16](r[35].target.selector)),s[0]&256&&(n.annotation=r[35]),s[0]&2&&(n.style=r[1]),s[1]&8&&(n.viewportScale=r[34]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function _g(r){let t,e,i=r[36]&&gg(r);return{c(){i&&i.c(),t=Ge()},m(s,n){i&&i.m(s,n),at(s,t,n),e=!0},p(s,n){s[36]?i?(i.p(s,n),n[0]&256&&q(i,1)):(i=gg(s),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(fe(),lt(i,1,1,()=>{i=null}),pe())},i(s){e||(q(i),e=!0)},o(s){lt(i),e=!1},d(s){s&&nt(t),i&&i.d(s)}}}function h2(r){let t,e,i,s,n,o;const a=[l2,a2],l=[];function h(u,c){var d;return u[7]&&((d=u[8])==null?void 0:d.length)===1?0:u[7]&&u[9]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=st("svg"),e=st("g"),s&&s.c(),w(e,"transform",n=r[33]),w(e,"class","svelte-1k5cy2d"),w(t,"tabindex",0),w(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-1k5cy2d"),Wi(t,"drawing",r[0]),Wi(t,"editing",r[8])},m(u,c){at(u,t,c),Ct(t,e),~i&&l[i].m(e,null),r[27](e),o=!0},p(u,c){let d=i;i=h(u),i===d?~i&&l[i].p(u,c):(s&&(fe(),lt(l[d],1,1,()=>{l[d]=null}),pe()),~i?(s=l[i],s?s.p(u,c):(s=l[i]=a[i](u),s.c()),q(s,1),s.m(e,null)):s=null),(!o||c[1]&4&&n!==(n=u[33]))&&w(e,"transform",n),(!o||c[0]&1)&&Wi(t,"drawing",u[0]),(!o||c[0]&256)&&Wi(t,"editing",u[8])},i(u){o||(q(s),o=!0)},o(u){lt(s),o=!1},d(u){u&&nt(t),~i&&l[i].d(),r[27](null)}}}function u2(r){let t,e;return t=new tu({props:{viewer:r[3],$$slots:{default:[h2,({transform:i,scale:s})=>({33:i,34:s}),({transform:i,scale:s})=>[0,(i?4:0)|(s?8:0)]]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&1023|s[1]&268&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function c2(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{multiSelect:h}=t,{preferredDrawingMode:u}=t,{state:c}=t,{style:d=void 0}=t,{toolName:p=Mn()[0]}=t,{user:f}=t,{viewer:m}=t,_=0;const y=()=>e(6,_+=1),v=()=>p,g=()=>a;let x;const{store:E,selection:M,hover:S}=c;Dn(r,M,O=>e(25,o=O));let R,P,F;const k=O=>{E.unobserve(R);const D=O.filter(({editable:U})=>U).map(({id:U})=>U);D.length>0?(e(8,P=D.map(U=>E.getAnnotation(U))),R=U=>{const{updated:V}=U.changes;e(8,P=(V||[]).map(j=>j.newValue))},E.observe(R,{annotations:D}),m.forceRedraw()):e(8,P=void 0)},I=(O,D)=>{const{x:U,y:V}=m.viewport.viewerElementToImageCoordinates(new Se.Point(O,D));return[U,V]},A=O=>{m.setMouseNavEnabled(!1),F=O.timeStamp},T=O=>{if(m.setMouseNavEnabled(!0),performance.now()-(F||0)<300){const{offsetX:U,offsetY:V}=O.detail,[j,Q]=I(U,V),yt=E.getAt(j,Q);if(yt&&(!l||l(yt))&&!P.find(Y=>Y.id===yt.id)){S.set(yt.id);const Y=dg(yt.id,O.detail,M,h);M.userSelect(Y)}}},C=O=>D=>{var Q;const{target:U}=O,V=10*60*1e3,j=((Q=U.creator)==null?void 0:Q.id)!==f.id||!U.created||new Date().getTime()-U.created.getTime()>V;E.updateTarget({...U,selector:D.detail,created:j?U.created:new Date,updated:j?new Date:void 0,updatedBy:j?f:void 0})},L=O=>{const D=qS(),U={id:D,bodies:[],target:{annotation:D,selector:O.detail,creator:f,created:new Date}};E.addAnnotation(U),M.setSelected(U.id),m.setMouseNavEnabled(!0)},N=O=>dc(O),B=O=>Ze(O);function X(O){Bn[O?"unshift":"push"](()=>{x=O,e(7,x)})}return r.$$set=O=>{"drawingEnabled"in O&&e(0,a=O.drawingEnabled),"filter"in O&&e(17,l=O.filter),"multiSelect"in O&&e(18,h=O.multiSelect),"preferredDrawingMode"in O&&e(19,u=O.preferredDrawingMode),"state"in O&&e(20,c=O.state),"style"in O&&e(1,d=O.style),"toolName"in O&&e(2,p=O.toolName),"user"in O&&e(21,f=O.user),"viewer"in O&&e(3,m=O.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(9,{tool:i,opts:s}=Pn(p)||{tool:void 0,opts:void 0},i,(e(5,s),e(2,p))),r.$$.dirty[0]&524320&&e(4,n=(s==null?void 0:s.drawingMode)||u),r.$$.dirty[0]&25&&(a&&n==="drag"?m.setMouseNavEnabled(!1):m.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&M.clear(),r.$$.dirty[0]&33554457&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&33554432&&k(o.selected)},[a,d,p,m,n,s,_,x,P,i,M,I,A,T,C,L,N,l,h,u,c,f,y,v,g,o,B,X]}class d2 extends se{constructor(t){super(),ie(this,t,c2,u2,qt,{drawingEnabled:0,filter:17,multiSelect:18,preferredDrawingMode:19,state:20,style:1,toolName:2,user:21,viewer:3,cancelDrawing:22,getDrawingTool:23,isDrawingEnabled:24},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[22]}get getDrawingTool(){return this.$$.ctx[23]}get isDrawingEnabled(){return this.$$.ctx[24]}}function f2(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=st("g"),e=st("rect"),a=st("text"),h=Ua(l),w(e,"class","a9s-presence-label-bg svelte-1rehw2p"),w(e,"x",r[0]),w(e,"y",i=r[1]-18/r[3]),w(e,"height",s=18/r[3]),w(e,"fill",n=r[2].appearance.color),w(e,"stroke",o=r[2].appearance.color),w(a,"font-size",u=12/r[3]),w(a,"x",c=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(p,f){at(p,t,f),Ct(t,e),Ct(t,a),Ct(a,h),r[6](t)},p(p,[f]){f&1&&w(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&w(e,"y",i),f&8&&s!==(s=18/p[3])&&w(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&w(e,"fill",n),f&4&&o!==(o=p[2].appearance.color)&&w(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&Av(h,l),f&8&&u!==(u=12/p[3])&&w(a,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&w(a,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&w(a,"y",d)},i:Qt,o:Qt,d(p){p&&nt(t),r[6](null)}}}function p2(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=c=>{const d=l.querySelector("text"),p=l.querySelector("rect"),f=d.getBBox().width+10/c;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${f/2}px)`),p.setAttribute("width",`${f}`)};function u(c){Bn[c?"unshift":"push"](()=>{l=c,e(4,l)})}return r.$$set=c=>{"x"in c&&e(0,i=c.x),"y"in c&&e(1,s=c.y),"user"in c&&e(2,n=c.user),"scale"in c&&e(3,o=c.scale),"hAlign"in c&&e(5,a=c.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,u]}class vg extends se{constructor(t){super(),ie(this,t,p2,f2,qt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function m2(r){let t,e,i,s,n,o;return e=new vg({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=st("g"),Ht(e.$$.fragment),i=st("polygon"),w(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),w(i,"stroke",s=r[0].appearance.color),w(i,"fill","transparent"),w(i,"points",n=r[2].points.map(xg).join(" ")),w(t,"class","a9s-presence-overlay")},m(a,l){at(a,t,l),Ft(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&&s!==(s=a[0].appearance.color))&&w(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(xg).join(" ")))&&w(i,"points",n)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){lt(e.$$.fragment,a),o=!1},d(a){a&&nt(t),Ut(e)}}}const xg=r=>r.join(",");function g2(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[u,...c]=h.points;return c.forEach(([d,p])=>{p<u[1]&&(u=[d,p])}),u};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class y2 extends se{constructor(t){super(),ie(this,t,g2,m2,qt,{annotation:4,user:0,scale:1})}}function _2(r){let t,e,i,s,n,o,a,l,h;return e=new vg({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=st("g"),Ht(e.$$.fragment),i=st("rect"),w(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),w(i,"stroke",s=r[0].appearance.color),w(i,"fill","transparent"),w(i,"x",n=r[2].x),w(i,"y",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(u,c){at(u,t,c),Ft(e,t,null),Ct(t,i),h=!0},p(u,[c]){const d={};c&2&&(d.scale=u[1]),c&1&&(d.user=u[0]),c&4&&(d.x=u[2].x),c&4&&(d.y=u[2].y),e.$set(d),(!h||c&1&&s!==(s=u[0].appearance.color))&&w(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&w(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&w(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&w(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&w(i,"height",l)},i(u){h||(q(e.$$.fragment,u),h=!0)},o(u){lt(e.$$.fragment,u),h=!1},d(u){u&&nt(t),Ut(e)}}}function v2(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class x2 extends se{constructor(t){super(),ie(this,t,v2,_2,qt,{annotation:3,user:0,scale:1})}}const{Boolean:b2}=jc;function bg(r,t,e){const i=r.slice();return i[8]=t[e],i}function Eg(r){let t,e;return t=new tu({props:{viewer:r[0],$$slots:{default:[w2,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Tg(r){let t,e,i=Pe(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=wg(bg(r,i,o));const n=o=>lt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ge()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);at(o,t,a),e=!0},p(o,a){if(a&132){i=Pe(o[2]);let l;for(l=0;l<i.length;l+=1){const h=bg(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=wg(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(fe(),l=i.length;l<s.length;l+=1)n(l);pe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(b2);for(let a=0;a<s.length;a+=1)lt(s[a]);e=!1},d(o){o&&nt(t),Yr(s,o)}}}function E2(r){let t,e;return t=new y2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function T2(r){let t,e;return t=new x2({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function wg(r){let t,e,i,s;const n=[T2,E2],o=[];function a(l,h){return l[8].annotation.target.selector.type===At.RECTANGLE?0:l[8].annotation.target.selector.type===At.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),at(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(fe(),lt(o[u],1,1,()=>{o[u]=null}),pe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(q(e),s=!0)},o(l){lt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function w2(r){let t,e,i,s,n=r[2].length>0&&Tg(r);return{c(){t=st("svg"),e=st("g"),n&&n.c(),w(e,"transform",i=r[6]),w(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){at(o,t,a),Ct(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&q(n,1)):(n=Tg(o),n.c(),q(n,1),n.m(e,null)):n&&(fe(),lt(n,1,1,()=>{n=null}),pe()),(!s||a&64&&i!==(i=o[6]))&&w(e,"transform",i)},i(o){s||(q(n),s=!0)},o(o){lt(n),s=!1},d(o){o&&nt(t),n&&n.d()}}}function A2(r){let t=!!r[1],e,i,s=t&&Eg(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),at(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&q(s,1)):(s=Eg(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(fe(),lt(s,1,1,()=>{s=null}),pe())},i(n){i||(q(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function S2(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,u)=>{e(2,o=[...o.filter(({selectedBy:c})=>c.presenceKey!==h.presenceKey),...(u||[]).map(c=>({annotation:i.getAnnotation(c),selectedBy:h}))].filter(({annotation:c})=>(c||console.warn("Selection event on unknown annotation"),!!c))),a&&i.unobserve(a),a=c=>{const{deleted:d,updated:p}=c.changes,f=new Set((d||[]).map(_=>_.id)),m=o.filter(({annotation:_})=>!f.has(_.id)).map(_=>{const y=(p||[]).find(v=>v.oldValue.id===_.annotation.id);return y?{selectedBy:_.selectedBy,annotation:y.newValue}:_});e(2,o=m)},i.observe(a,{annotations:o.map(c=>c.annotation.id)})};return Cv(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class C2 extends se{constructor(t){super(),ie(this,t,S2,A2,qt,{store:3,viewer:0,provider:1})}}function I2(r){let t,e,i,s,n;return{c(){t=st("rect"),w(t,"x",e=r[0].x),w(t,"y",i=r[0].y),w(t,"width",s=r[0].w),w(t,"height",n=r[0].h)},m(o,a){at(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&&s!==(s=o[0].w)&&w(t,"width",s),a&1&&n!==(n=o[0].h)&&w(t,"height",n)},i:Qt,o:Qt,d(o){o&&nt(t)}}}function R2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class M2 extends se{constructor(t){super(),ie(this,t,R2,I2,qt,{annotation:1})}}function P2(r){let t,e;return{c(){t=st("polygon"),w(t,"points",e=r[0].points.map(Ag).join(" "))},m(i,s){at(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(Ag).join(" "))&&w(t,"points",e)},i:Qt,o:Qt,d(i){i&&nt(t)}}}const Ag=r=>r.join(",");function O2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class N2 extends se{constructor(t){super(),ie(this,t,O2,P2,qt,{annotation:1})}}function Sg(r,t,e){const i=r.slice();return i[2]=t[e],i}function Cg(r){let t,e;return{c(){t=st("path"),e=st("path"),w(t,"fill-rule","evenodd"),w(t,"d",Ke(r[2])),w(e,"class","a9s-inner"),w(e,"fill-rule","evenodd"),w(e,"d",Ke(r[2]))},m(i,s){at(i,t,s),at(i,e,s)},p:Qt,d(i){i&&(nt(t),nt(e))}}}function D2(r){let t,e=Pe(r[0]),i=[];for(let s=0;s<e.length;s+=1)i[s]=Cg(Sg(r,e,s));return{c(){t=st("g");for(let s=0;s<i.length;s+=1)i[s].c()},m(s,n){at(s,t,n);for(let o=0;o<i.length;o+=1)i[o]&&i[o].m(t,null)},p(s,[n]){if(n&1){e=Pe(s[0]);let o;for(o=0;o<e.length;o+=1){const a=Sg(s,e,o);i[o]?i[o].p(a,n):(i[o]=Cg(a),i[o].c(),i[o].m(t,null))}for(;o<i.length;o+=1)i[o].d(1);i.length=e.length}},i:Qt,o:Qt,d(s){s&&nt(t),Yr(i,s)}}}function L2(r,t,e){let{annotation:i}=t;const{polygons:s}=i.target.selector.geometry;return r.$$set=n=>{"annotation"in n&&e(1,i=n.annotation)},[s,i]}class B2 extends se{constructor(t){super(),ie(this,t,L2,D2,qt,{annotation:1})}}function F2(r){let t,e,i,s,n;return{c(){t=st("ellipse"),w(t,"cx",e=r[0].cx),w(t,"cy",i=r[0].cy),w(t,"rx",s=r[0].rx),w(t,"ry",n=r[0].ry)},m(o,a){at(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&&s!==(s=o[0].rx)&&w(t,"rx",s),a&1&&n!==(n=o[0].ry)&&w(t,"ry",n)},i:Qt,o:Qt,d(o){o&&nt(t)}}}function U2(r,t,e){let i,{annotation:s}=t;return r.$$set=n=>{"annotation"in n&&e(1,s=n.annotation)},r.$$.update=()=>{r.$$.dirty&2&&e(0,i=s.target.selector.geometry)},[i,s]}class k2 extends se{constructor(t){super(),ie(this,t,U2,F2,qt,{annotation:1})}}const{Boolean:G2}=jc;function Ig(r,t,e){const i=r.slice();return i[10]=t[e],i}function Rg(r){let t,e;return t=new tu({props:{viewer:r[0],$$slots:{default:[z2,({transform:i})=>({9:i}),({transform:i})=>i?512:0]},$$scope:{ctx:r}}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&8710&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function H2(r){let t,e;return t=new k2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function $2(r){let t,e;return t=new B2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function X2(r){let t,e;return t=new N2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function V2(r){let t,e;return t=new M2({props:{annotation:r[10]}}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s&2&&(n.annotation=i[10]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){lt(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Mg(r){let t,e,i,s;const n=[V2,X2,$2,H2],o=[];function a(l,h){return l[10].target.selector.type===At.RECTANGLE?0:l[10].target.selector.type===At.POLYGON?1:l[10].target.selector.type===At.MULTIPOLYGLON?2:l[10].target.selector.type===At.ELLIPSE?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ge()},m(l,h){~t&&o[t].m(l,h),at(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(fe(),lt(o[u],1,1,()=>{o[u]=null}),pe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),q(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(q(e),s=!0)},o(l){lt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function z2(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=Pe(r[1].filter(r[6])),_=[];for(let v=0;v<m.length;v+=1)_[v]=Mg(Ig(r,m,v));const y=v=>lt(_[v],1,1,()=>{_[v]=null});return{c(){var v,g,x,E;t=st("svg"),e=st("g"),i=st("rect"),l=st("rect");for(let M=0;M<_.length;M+=1)_[M].c();w(i,"class","a9s-union-bg svelte-1p8m4b9"),w(i,"x",s=(v=r[2])==null?void 0:v.minX),w(i,"y",n=(g=r[2])==null?void 0:g.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-1p8m4b9"),w(l,"x",h=(x=r[2])==null?void 0:x.minX),w(l,"y",u=(E=r[2])==null?void 0:E.minY),w(l,"width",c=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",p=r[9]),w(t,"class","a9s-osd-selectionlayer svelte-1p8m4b9")},m(v,g){at(v,t,g),Ct(t,e),Ct(e,i),Ct(e,l);for(let x=0;x<_.length;x+=1)_[x]&&_[x].m(e,null);f=!0},p(v,g){var x,E,M,S;if((!f||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&w(i,"x",s),(!f||g&4&&n!==(n=(E=v[2])==null?void 0:E.minY))&&w(i,"y",n),(!f||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&w(i,"width",o),(!f||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&w(i,"height",a),(!f||g&4&&h!==(h=(M=v[2])==null?void 0:M.minX))&&w(l,"x",h),(!f||g&4&&u!==(u=(S=v[2])==null?void 0:S.minY))&&w(l,"y",u),(!f||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&w(l,"width",c),(!f||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&w(l,"height",d),g&2){m=Pe(v[1].filter(v[6]));let R;for(R=0;R<m.length;R+=1){const P=Ig(v,m,R);_[R]?(_[R].p(P,g),q(_[R],1)):(_[R]=Mg(P),_[R].c(),q(_[R],1),_[R].m(e,null))}for(fe(),R=m.length;R<_.length;R+=1)y(R);pe()}(!f||g&512&&p!==(p=v[9]))&&w(e,"transform",p)},i(v){if(!f){for(let g=0;g<m.length;g+=1)q(_[g]);f=!0}},o(v){_=_.filter(G2);for(let g=0;g<_.length;g+=1)lt(_[g]);f=!1},d(v){v&&nt(t),Yr(_,v)}}}function Y2(r){let t=!!r[2],e,i,s=t&&Rg(r);return{c(){s&&s.c(),e=Ge()},m(n,o){s&&s.m(n,o),at(n,e,o),i=!0},p(n,[o]){o&4&&(t=!!n[2]),t?s?(s.p(n,o),o&4&&q(s,1)):(s=Rg(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(fe(),lt(s,1,1,()=>{s=null}),pe())},i(n){i||(q(s),i=!0)},o(n){lt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function j2(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;Dn(r,h,d=>e(5,n=d));const u=d=>{let p=-1/0,f=-1/0,m=1/0,_=1/0;for(let y of d.filter(v=>Ze(v))){const{bounds:v}=y.target.selector.geometry;v.maxX>p&&(p=v.maxX),v.maxY>f&&(f=v.maxY),v.minX<m&&(m=v.minX),v.minY<_&&(_=v.minY)}return a.forceRedraw(),{maxX:p,maxY:f,minX:m,minY:_}},c=d=>Ze(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=n.selected.map(({id:d})=>l.getAnnotation(d))),r.$$.dirty&2&&e(2,s=i.length>1?u(i):void 0)},[a,i,s,h,o,n,c]}class W2 extends se{constructor(t){super(),ie(this,t,j2,Y2,qt,{state:4,viewer:0})}}const Pg=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Dc(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Og=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Ze(o))return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,u,c,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,u=u/a.width,c=c/a.height,d=d/a.width;const{minX:p,minY:f,maxX:m,maxY:_}=o.target.selector.geometry.bounds,y=m-p,v=_-f,g=p-d*y,x=f-h*v,E=y+(u+d)*y,M=v+(h+c)*v,S=r.viewport.imageToViewportRectangle(g,x,E,M);r.viewport[e](S,s.immediately)},q2=(r,t)=>Og(r,t,"fitBounds"),K2=(r,t)=>Og(r,t,"fitBoundsWithConstraints"),Z2=(r,t={})=>{const e=Bc(t,{drawingEnabled:!1,drawingMode:Sr?"drag":"click",userSelectAction:ra.EDIT,theme:"light"}),i=Nc(e),{hover:s,selection:n,store:o}=i,a=Zg(o,e.initialHistory),l=Qg(i,a,e.adapter,e.autoSave);let h=oy(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=Uc(a,r.element),f=new zS({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new C2({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),_=new d2({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!u,filter:void 0,multiSelect:e.multiSelect,preferredDrawingMode:c,state:i,style:e.style,user:h,viewer:r}}),y=new W2({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",D=>{const{originalEvent:U,annotation:V}=D.detail,j=Q=>dg(Q.id,U,n,e.multiSelect);d?n.isEmpty()&&V&&n.userSelect(j(V),U):V&&!(c==="click"&&u)?n.userSelect(j(V),U):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",D=>{if(s.current){const U=o.getAnnotation(s.current);l.emit("clickAnnotation",U,D)}}),Pg(r,e.theme);const v=ty(i,a,e.adapter),g=()=>_.cancelDrawing(),x=()=>{f.$destroy(),m.$destroy(),_.$destroy(),y.$destroy(),p.destroy(),a.destroy()},E=q2(r,o),M=K2(r,o),S=()=>_.getDrawingTool(),R=()=>h,P=()=>_.isDrawingEnabled(),F=(D,U,V)=>yc(D,U,V),k=(D,U)=>fc(D,U),I=D=>{if(!Pn(D))throw`No drawing tool named ${D}`;_.$set({toolName:D})},A=D=>{u=D,_.$set({drawingEnabled:D})},T=D=>{f.$set({filter:D}),_.$set({filter:D})},C=D=>d=D,L=D=>{f.$set({style:D}),_.$set({style:D})},N=D=>m.$set({provider:D}),B=D=>Pg(r,D),X=D=>{h=D,_.$set({user:D})},O=D=>f.$set({visible:D});return{...v,cancelDrawing:g,destroy:x,fitBounds:E,fitBoundsWithConstraints:M,getDrawingTool:S,getUser:R,isDrawingEnabled:P,listDrawingTools:Mn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:k,setDrawingEnabled:A,setDrawingTool:I,setFilter:T,setModalSelect:C,setPresenceProvider:N,setStyle:L,setTheme:B,setUser:X,setVisible:O,state:i,viewer:r}};Zt.ShapeType=At,Zt.UserSelectAction=ra,Zt.W3CImageFormat=z_,Zt.chainStyles=L_,Zt.computeStyle=D_,Zt.createBody=$g,Zt.createImageAnnotator=bv,Zt.createOSDAnnotator=Z2,Zt.defaultColorProvider=ly,Object.defineProperty(Zt,Symbol.toStringTag,{value:"Module"})});
1150
1150
  //# sourceMappingURL=annotorious-openseadragon.js.map