@annotorious/openseadragon 3.3.2 → 3.3.3
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(Gt,de){typeof exports=="object"&&typeof module<"u"?de(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],de):(Gt=typeof globalThis<"u"?globalThis:Gt||self,de(Gt.AnnotoriousOSD={},Gt.OpenSeadragon))})(this,function(Gt,de){"use strict";var RC=Object.defineProperty;var MC=(Gt,de,Zr)=>de in Gt?RC(Gt,de,{enumerable:!0,configurable:!0,writable:!0,value:Zr}):Gt[de]=Zr;var Pt=(Gt,de,Zr)=>MC(Gt,typeof de!="symbol"?de+"":de,Zr);var Zr=Object.prototype.hasOwnProperty;function Qr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Qr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Zr.call(r,e)&&++i&&!Zr.call(t,e)||!(e in t)||!Qr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var $o=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))($o||{});const oe=[];for(let r=0;r<256;++r)oe.push((r+256).toString(16).slice(1));function Dm(r,t=0){return(oe[r[t+0]]+oe[r[t+1]]+oe[r[t+2]]+oe[r[t+3]]+"-"+oe[r[t+4]]+oe[r[t+5]]+"-"+oe[r[t+6]]+oe[r[t+7]]+"-"+oe[r[t+8]]+oe[r[t+9]]+"-"+oe[r[t+10]]+oe[r[t+11]]+oe[r[t+12]]+oe[r[t+13]]+oe[r[t+14]]+oe[r[t+15]]).toLowerCase()}let Ho;const Lm=new Uint8Array(16);function Bm(){if(!Ho){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ho=crypto.getRandomValues.bind(crypto)}return Ho(Lm)}const Fm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Oh={randomUUID:Fm};function Um(r,t,e){var i;if(Oh.randomUUID&&!r)return Oh.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Bm();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,Dm(s)}const Vo=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)}},km=(r,t,e,i)=>({id:Um(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),Gm=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},$m=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Hm=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Qr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Vm=(r,t)=>!Qr(r.target,t.target),Xm=(r,t)=>{const e=Gm(r,t),i=$m(r,t),s=Hm(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:Vm(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Rr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Rr||{});const zm=(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 Xm(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let Wm=()=>({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 Ym=250,jm=(r,t)=>{const e=Wm(),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>Ym)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=zm(i[_],m)}o=y}n=!1};r.observe(a,{origin:Rr.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}}}},qm=(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 b=Array.isArray(v)?v.map(w=>e.serialize(w)):e.serialize(v),S=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(b,S)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(b=>b.id===g.id);(!x||!Qr(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:b})=>b===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&&!Qr(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 b=o.getAnnotation(x.id);b&&!Qr(b,x)&&f("updateAnnotation",b,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:b})=>{const S=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,S)})},{origin:Rr.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(S=>S.id===x.id)||x))}},{origin:Rr.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}},Km=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:[]}),Zm=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,Rr.REMOTE):console.error(g)}else i.addAnnotation(Vo(_),Rr.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||Km(e),{parsed:x,failed:b}=g(_);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotations(x,v,Rr.REMOTE)}else i.bulkAddAnnotations(_.map(Vo),v,Rr.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(Vo(_)),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}},Qm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Jm=r=>crypto.getRandomValues(new Uint8Array(r)),tg=(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}}},eg=(r,t=21)=>tg(r,t|0,Jm),rg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Qm[e[r]&63];return t};const ig=()=>({isGuest:!0,id:eg("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),sg=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],ng=()=>{const r=[...sg];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};rg();var og=Object.defineProperty,ag=(r,t,e)=>t in r?og(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ot=(r,t,e)=>ag(r,typeof t!="symbol"?t+"":t,e);function Ct(){}function Xo(r,t){for(const e in t)r[e]=t[e];return r}function Nh(r){return r()}function Dh(){return Object.create(null)}function Ue(r){r.forEach(Nh)}function $t(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function lg(r){return Object.keys(r).length===0}function Lh(r,...t){if(r==null){for(const i of t)i(void 0);return Ct}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function zo(r,t,e){r.$$.on_destroy.push(Lh(t,e))}function hg(r,t,e,i){if(r){const s=Bh(r,t,e,i);return r[0](s)}}function Bh(r,t,e,i){return r[1]&&i?Xo(e.ctx.slice(),r[1](i(t))):e.ctx}function ug(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 cg(r,t,e,i,s,n){if(s){const o=Bh(t,e,i,n);r.p(o,s)}}function dg(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Fh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function tn(r){return r??""}function Oe(r,t){r.appendChild(t)}function ot(r,t,e){r.insertBefore(t,e||null)}function nt(r){r.parentNode&&r.parentNode.removeChild(r)}function Jr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function mt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Uh(r){return document.createTextNode(r)}function ke(){return Uh(" ")}function Ie(){return Uh("")}function Bt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function A(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function fg(r){return Array.from(r.childNodes)}function Mr(r,t,e){r.classList.toggle(t,!!e)}function pg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let fs;function ps(r){fs=r}function kh(){if(!fs)throw new Error("Function called outside component initialization");return fs}function ms(r){kh().$$.on_mount.push(r)}function Si(){const r=kh();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=pg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ne(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Ci=[],en=[];let Ii=[];const Gh=[],mg=Promise.resolve();let Wo=!1;function gg(){Wo||(Wo=!0,mg.then($h))}function Yo(r){Ii.push(r)}const jo=new Set;let Ri=0;function $h(){if(Ri!==0)return;const r=fs;do{try{for(;Ri<Ci.length;){const t=Ci[Ri];Ri++,ps(t),yg(t.$$)}}catch(t){throw Ci.length=0,Ri=0,t}for(ps(null),Ci.length=0,Ri=0;en.length;)en.pop()();for(let t=0;t<Ii.length;t+=1){const e=Ii[t];jo.has(e)||(jo.add(e),e())}Ii.length=0}while(Ci.length);for(;Gh.length;)Gh.pop()();Wo=!1,jo.clear(),ps(r)}function yg(r){if(r.fragment!==null){r.update(),Ue(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Yo)}}function _g(r){const t=[],e=[];Ii.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ii=t}const rn=new Set;let ti;function xe(){ti={r:0,c:[],p:ti}}function be(){ti.r||Ue(ti.c),ti=ti.p}function it(r,t){r&&r.i&&(rn.delete(r),r.i(t))}function dt(r,t,e,i){if(r&&r.o){if(rn.has(r))return;rn.add(r),ti.c.push(()=>{rn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ee(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function _e(r){r&&r.c()}function fe(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Yo(()=>{const n=r.$$.on_mount.map(Nh).filter($t);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ue(n),r.$$.on_mount=[]}),s.forEach(Yo)}function pe(r,t){const e=r.$$;e.fragment!==null&&(_g(e.after_update),Ue(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function vg(r,t){r.$$.dirty[0]===-1&&(Ci.push(r),gg(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Te(r,t,e,i,s,n,o=null,a=[-1]){const l=fs;ps(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Ct,not_equal:s,bound:Dh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Dh(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let u=!1;if(h.ctx=e?e(r,t.props||{},(c,d,...p)=>{const f=p.length?p[0]:d;return h.ctx&&s(h.ctx[c],h.ctx[c]=f)&&(!h.skip_bound&&h.bound[c]&&h.bound[c](f),u&&vg(r,c)),d}):[],h.update(),u=!0,Ue(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=fg(t.target);h.fragment&&h.fragment.l(c),c.forEach(nt)}else h.fragment&&h.fragment.c();t.intro&&it(r.$$.fragment),fe(r,t.target,t.anchor),$h()}ps(l)}class we{constructor(){Ot(this,"$$"),Ot(this,"$$set")}$destroy(){pe(this,1),this.$destroy=Ct}$on(t,e){if(!$t(e))return Ct;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&&!lg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const xg="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(xg);var vt=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(vt||{});const qo={},sn=(r,t)=>qo[r]=t,Ko=r=>qo[r.type].area(r),bg=(r,t,e)=>qo[r.type].intersects(r,t,e),_r=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}},Zo=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)},Qo=(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},Eg=(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},Tg={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}};sn(vt.ELLIPSE,Tg);const wg={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=Zo(s.points),a=n.reduce((l,h)=>l+Zo(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(Qo(n.points,t,e)){let a=!1;for(const l of o)if(Qo(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Ag=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return _r(t)},ei=r=>r.rings.map(t=>Eg(t.points)).join(" ");sn(vt.MULTIPOLYGLON,wg);const Sg={area:r=>{const t=r.geometry.points;return Zo(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Qo(i,t,e)}};sn(vt.POLYGON,Sg);const Cg={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};sn(vt.RECTANGLE,Cg);const Ge=r=>nn(r.target),nn=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},Ig=(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:vt.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}}}},Rg=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}`}},Hh="http://www.w3.org/2000/svg",Vh=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},Mg=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Hh}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Xh=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Hh),i=t.lookupNamespaceURI(null);return e||i?Vh(t).firstChild:Vh(Mg(t)).firstChild},Xt=" ";function Pg(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===B.CLOSE_PATH)t+="z";else if(i.type===B.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===B.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===B.MOVE_TO)t+=(i.relative?"m":"M")+i.x+Xt+i.y;else if(i.type===B.LINE_TO)t+=(i.relative?"l":"L")+i.x+Xt+i.y;else if(i.type===B.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+Xt+i.y1+Xt+i.x2+Xt+i.y2+Xt+i.x+Xt+i.y;else if(i.type===B.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+Xt+i.y2+Xt+i.x+Xt+i.y;else if(i.type===B.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+Xt+i.y1+Xt+i.x+Xt+i.y;else if(i.type===B.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+Xt+i.y;else if(i.type===B.ARC)t+=(i.relative?"a":"A")+i.rX+Xt+i.rY+Xt+i.xRot+Xt+ +i.lArcFlag+Xt+ +i.sweepFlag+Xt+i.x+Xt+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function Jo([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function $e(...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 Pr=Math.PI;function ta(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*Pr,[l,h]=Jo([(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=Jo([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*Pr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Pr),r.phi1*=180/Pr,r.phi2*=180/Pr}function zh(r,t,e){$e(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 ri=Math.PI/180;function Wh(r,t,e){return(1-e)*r+e*t}function Yh(r,t,e,i){return r+Math.cos(i/180*Pr)*t+Math.sin(i/180*Pr)*e}function jh(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]:Og(l/a,h/a,1e-6)}function qh(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 Og(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 Ng(r,t,e){r.cX||ta(r,t,e);const i=r.xRot/180*Pr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:B.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]=Jo([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=Wh(r.phi1,r.phi2,d/a),f=Wh(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*ri/4),_=Math.cos(p*ri)-y*Math.sin(p*ri),v=Math.sin(p*ri)+y*Math.cos(p*ri),g=Math.cos(f*ri),x=Math.sin(f*ri),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:B.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function ea(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 Dg(r,t=!0){if(r.length<2)return r;const e=zt.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===B.MOVE_TO&&s.length>0&&(t?i.push(...on(s)):i.unshift(...on(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...on(s)):i.unshift(...on(s))),i}function on(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===B.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:B.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 B.HORIZ_LINE_TO:s.push({type:B.HORIZ_LINE_TO,relative:!1,x:a.x});break;case B.VERT_LINE_TO:s.push({type:B.VERT_LINE_TO,relative:!1,y:a.y});break;case B.LINE_TO:case B.MOVE_TO:s.push({type:B.LINE_TO,relative:!1,x:a.x,y:a.y});break;case B.CURVE_TO:s.push({type:B.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case B.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case B.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case B.ARC:throw new Error("Unsupported command: A (arc)");case B.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:B.CLOSE_PATH}),s}function Lg(r=1e13){$e(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 Kh(){return He((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 Bg(){return He((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 Fg(r=!0,t=!0,e=!0,i=!0){return He((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&B.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&B.HORIZ_LINE_TO&&(s.type=B.LINE_TO,s.y=s.relative?0:o),e&&s.type&B.VERT_LINE_TO&&(s.type=B.LINE_TO,s.x=s.relative?0:n),r&&s.type&B.CLOSE_PATH&&(s.type=B.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&B.ARC&&(s.rX===0||s.rY===0)&&(s.type=B.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&B.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];ea(h,u,c)&&(s.type=B.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&B.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];ea(h,u,d)&&ea(h,c,d)&&(s.type=B.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Zh(){let r=NaN,t=NaN,e=NaN,i=NaN;return He((s,n,o)=>(s.type&B.SMOOTH_CURVE_TO&&(s.type=B.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&B.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&B.SMOOTH_QUAD_TO&&(s.type=B.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&B.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Qh(){let r=NaN,t=NaN;return He((e,i,s)=>{if(e.type&B.SMOOTH_QUAD_TO&&(e.type=B.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&B.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=B.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 He(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&B.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&B.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&B.MOVE_TO&&(i=t,s=e),o}}function Ug(r=0){$e(r);let t=NaN,e=NaN,i=NaN,s=NaN;return He((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&B.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(B.CURVE_TO|B.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&B.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&B.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&B.LINE_COMMANDS||n.type&B.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&B.CURVE_TO||n.type&B.SMOOTH_CURVE_TO||n.type&B.QUAD_TO||n.type&B.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&B.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Or(r,t,e,i,s,n){return $e(r,t,e,i,s,n),He((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&B.HORIZ_LINE_TO&&t!==0&&(o.type=B.LINE_TO,o.y=o.relative?0:l),o.type&B.VERT_LINE_TO&&e!==0&&(o.type=B.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=B.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function kg(r,t=0,e=0){$e(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Or(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Gg(r,t=0){return $e(r,t),Or(1,0,0,1,r,t)}function $g(r,t=r){return $e(r,t),Or(r,0,0,t,0,0)}function Hg(r){return $e(r),Or(1,0,Math.tan(r),1,0,0)}function Vg(r){return $e(r),Or(1,Math.tan(r),0,1,0,0)}function Xg(r=0){return $e(r),Or(-1,0,0,1,r,0)}function zg(r=0){return $e(r),Or(1,0,0,-1,0,r)}function Wg(){return He((r,t,e)=>B.ARC===r.type?Ng(r,r.relative?0:t,r.relative?0:e):r)}function Yg(){return He((r,t,e)=>(r.relative&&(t=0,e=0),B.ARC===r.type&&ta(r,t,e),r))}function Jh(){return r=>({...r})}function jg(){const r=Jh(),t=Kh(),e=Qh(),i=Zh(),s=He((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&B.DRAWING_COMMANDS&&(h(o),u(a)),l.type&B.HORIZ_LINE_TO&&h(l.x),l.type&B.VERT_LINE_TO&&u(l.y),l.type&B.LINE_TO&&(h(l.x),u(l.y)),l.type&B.CURVE_TO){h(l.x),u(l.y);const c=jh(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(qh(o,l.x1,l.x2,l.x,p));const d=jh(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(qh(a,l.y1,l.y2,l.y,p))}if(l.type&B.ARC){h(l.x),u(l.y),ta(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=([b,S])=>{const w=Math.atan2(S,b)*180/Math.PI;return w<y?w+360:w},g=zh(f,-d,0).map(v);for(const b of g)b>y&&b<_&&h(Yh(l.cX,d,f,b));const x=zh(m,-p,0).map(v);for(const b of x)b>y&&b<_&&u(Yh(l.cY,p,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const zt={ROUND:Lg,TO_ABS:Kh,TO_REL:Bg,NORMALIZE_HVZ:Fg,NORMALIZE_ST:Zh,QT_TO_C:Qh,INFO:He,SANITIZE:Ug,MATRIX:Or,ROTATE:kg,TRANSLATE:Gg,SCALE:$g,SKEW_X:Hg,SKEW_Y:Vg,X_AXIS_SYMMETRY:Xg,Y_AXIS_SYMMETRY:zg,A_TO_C:Wg,ANNOTATE_ARCS:Yg,CLONE:Jh,CALCULATE_BOUNDS:jg,REVERSE_PATH:Dg};class tu{round(t){return this.transform(zt.ROUND(t))}toAbs(){return this.transform(zt.TO_ABS())}toRel(){return this.transform(zt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(zt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(zt.NORMALIZE_ST())}qtToC(){return this.transform(zt.QT_TO_C())}aToC(){return this.transform(zt.A_TO_C())}sanitize(t){return this.transform(zt.SANITIZE(t))}translate(t,e){return this.transform(zt.TRANSLATE(t,e))}scale(t,e){return this.transform(zt.SCALE(t,e))}rotate(t,e,i){return this.transform(zt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(zt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(zt.SKEW_X(t))}skewY(t){return this.transform(zt.SKEW_Y(t))}xSymmetry(t){return this.transform(zt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(zt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(zt.ANNOTATE_ARCS())}}const qg=r=>r===" "||r===" "||r==="\r"||r===`
|
|
2
|
-
`,eu=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class Kg extends tu{constructor(){super(),Ot(this,"curNumber",""),Ot(this,"curCommandType",-1),Ot(this,"curCommandRelative",!1),Ot(this,"canParseCommandOrComma",!0),Ot(this,"curNumberHasExp",!1),Ot(this,"curNumberHasExpDigits",!1),Ot(this,"curNumberHasDecimal",!1),Ot(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===B.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=eu(n)&&(this.curNumber==="0"&&n==="0"||o);if(eu(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===B.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===Zg[this.curCommandType]&&(B.HORIZ_LINE_TO===this.curCommandType?i({type:B.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):B.VERT_LINE_TO===this.curCommandType?i({type:B.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===B.MOVE_TO||this.curCommandType===B.LINE_TO||this.curCommandType===B.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),B.MOVE_TO===this.curCommandType&&(this.curCommandType=B.LINE_TO)):this.curCommandType===B.CURVE_TO?i({type:B.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===B.SMOOTH_CURVE_TO?i({type:B.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===B.QUAD_TO?i({type:B.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===B.ARC&&i({type:B.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(!qg(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:B.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=B.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=B.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=B.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=B.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=B.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=B.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=B.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=B.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=B.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 Mt=class wh extends tu{constructor(t){super(),Ot(this,"commands"),typeof t=="string"?this.commands=wh.parse(t):this.commands=t}encode(){return wh.encode(this.commands)}getBounds(){const t=zt.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=zt.REVERSE_PATH(this.commands,t),this}static encode(t){return Pg(t)}static parse(t){const e=new Kg,i=[];return e.parse(t,i),e.finish(i),i}};Ot(Mt,"CLOSE_PATH",1),Ot(Mt,"MOVE_TO",2),Ot(Mt,"HORIZ_LINE_TO",4),Ot(Mt,"VERT_LINE_TO",8),Ot(Mt,"LINE_TO",16),Ot(Mt,"CURVE_TO",32),Ot(Mt,"SMOOTH_CURVE_TO",64),Ot(Mt,"QUAD_TO",128),Ot(Mt,"SMOOTH_QUAD_TO",256),Ot(Mt,"ARC",512),Ot(Mt,"LINE_COMMANDS",Mt.LINE_TO|Mt.HORIZ_LINE_TO|Mt.VERT_LINE_TO),Ot(Mt,"DRAWING_COMMANDS",Mt.HORIZ_LINE_TO|Mt.VERT_LINE_TO|Mt.LINE_TO|Mt.CURVE_TO|Mt.SMOOTH_CURVE_TO|Mt.QUAD_TO|Mt.SMOOTH_QUAD_TO|Mt.ARC);let B=Mt;const Zg={[B.MOVE_TO]:2,[B.LINE_TO]:2,[B.HORIZ_LINE_TO]:1,[B.VERT_LINE_TO]:1,[B.CLOSE_PATH]:0,[B.QUAD_TO]:4,[B.SMOOTH_QUAD_TO]:2,[B.CURVE_TO]:6,[B.SMOOTH_CURVE_TO]:4,[B.ARC]:7},Qg=r=>{const t=new B(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case B.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case B.LINE_TO:i.push([n.x,n.y]);break;case B.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case B.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case B.CURVE_TO:case B.SMOOTH_CURVE_TO:case B.QUAD_TO:case B.SMOOTH_QUAD_TO:case B.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=_r(e[0].points);return{rings:e,bounds:n}}},Jg=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:vt.POLYGON,geometry:{points:s,bounds:_r(s)}}},ty=r=>{const t=Xh(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:vt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},ey=r=>{const t=Xh(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>Qg(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=_r(i);return e.length===1&&e[0].rings.length===1?{type:vt.POLYGON,geometry:{points:i,bounds:s}}:{type:vt.MULTIPOLYGLON,geometry:{polygons:e,bounds:s}}},ry=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Jg(t);if(t.includes("<path "))return ey(t);if(t.includes("<ellipse "))return ty(t);throw"Unsupported SVG shape: "+t},iy=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${ei(t)}" />`).join("")}</g>`,sy=r=>{let t;if(r.type===vt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===vt.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===vt.MULTIPOLYGLON){const e=r.geometry;t=`<svg>${iy(e)}</svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},ae=[];for(let r=0;r<256;++r)ae.push((r+256).toString(16).slice(1));function ny(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 ra;const oy=new Uint8Array(16);function ay(){if(!ra){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ra=crypto.getRandomValues.bind(crypto)}return ra(oy)}const ly=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ru={randomUUID:ly};function iu(r,t,e){var i;if(ru.randomUUID&&!r)return ru.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??ay();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,ny(s)}var su=Object.prototype.hasOwnProperty;function Nr(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--&&Nr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(su.call(r,e)&&++i&&!su.call(t,e)||!(e in t)||!Nr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function ia(){}function hy(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const Mi=[];function sa(r,t=ia){let e;const i=new Set;function s(a){if(hy(r,a)&&(r=a,e)){const l=!Mi.length;for(const h of i)h[1](),Mi.push(h,r);if(l){for(let h=0;h<Mi.length;h+=2)Mi[h][0](Mi[h+1]);Mi.length=0}}}function n(a){s(a(r))}function o(a,l=ia){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||ia),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const uy=r=>{const{subscribe:t,set:e}=sa();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 nu=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(nu||{});const an={selected:[]},cy=(r,t,e)=>{const{subscribe:i,set:s}=sa(an);let n=t,o=an;i(f=>o=f);const a=()=>{Nr(o,an)||s(an)},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=ou(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?ou(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}},ou=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},le=[];for(let r=0;r<256;++r)le.push((r+256).toString(16).slice(1));function dy(r,t=0){return(le[r[t+0]]+le[r[t+1]]+le[r[t+2]]+le[r[t+3]]+"-"+le[r[t+4]]+le[r[t+5]]+"-"+le[r[t+6]]+le[r[t+7]]+"-"+le[r[t+8]]+le[r[t+9]]+"-"+le[r[t+10]]+le[r[t+11]]+le[r[t+12]]+le[r[t+13]]+le[r[t+14]]+le[r[t+15]]).toLowerCase()}let na;const fy=new Uint8Array(16);function py(){if(!na){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");na=crypto.getRandomValues.bind(crypto)}return na(fy)}const my=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),au={randomUUID:my};function gy(r,t,e){var i;if(au.randomUUID&&!r)return au.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??py();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,dy(s)}const oa=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)}},yy=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},_y=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},vy=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Nr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),xy=(r,t)=>!Nr(r.target,t.target),lu=(r,t)=>{const e=yy(r,t),i=_y(r,t),s=vy(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:xy(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var It=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(It||{});const by=(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},Ey=(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 lu(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},ln=r=>{const t=r.id===void 0?gy():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},Ty=r=>r.id!==void 0,wy=()=>{const r=new Map,t=new Map,e=[],i=(C,E={})=>{e.push({onChange:C,options:E})},s=C=>{const E=e.findIndex(I=>I.onChange==C);E>-1&&e.splice(E,1)},n=(C,E)=>{const I={origin:C,changes:{created:E.created||[],updated:E.updated||[],deleted:E.deleted||[]},state:[...r.values()]};e.forEach(P=>{by(P,I)&&P.onChange(I)})},o=(C,E=It.LOCAL)=>{if(C.id&&r.get(C.id))throw Error(`Cannot add annotation ${C.id} - exists already`);{const I=ln(C);r.set(I.id,I),I.bodies.forEach(P=>t.set(P.id,I.id)),n(E,{created:[I]})}},a=(C,E)=>{const I=ln(typeof C=="string"?E:C),P=typeof C=="string"?C:C.id,$=P&&r.get(P);if($){const k=lu($,I);return P===I.id?r.set(P,I):(r.delete(P),r.set(I.id,I)),$.bodies.forEach(G=>t.delete(G.id)),I.bodies.forEach(G=>t.set(G.id,I.id)),k}else console.warn(`Cannot update annotation ${P} - does not exist`)},l=(C,E=It.LOCAL,I=It.LOCAL)=>{const P=Ty(E)?I:E,$=a(C,E);$&&n(P,{updated:[$]})},h=(C,E=It.LOCAL)=>{r.get(C.id)?l(C,E):o(C,E)},u=(C,E=It.LOCAL)=>{const I=C.reduce((P,$)=>{const k=a($);return k?[...P,k]:P},[]);I.length>0&&n(E,{updated:I})},c=(C,E=It.LOCAL)=>{const I=C.map(ln),{toAdd:P,toUpdate:$}=I.reduce((G,st)=>r.get(st.id)?{...G,toUpdate:[...G.toUpdate,st]}:{...G,toAdd:[...G.toAdd,st]},{toAdd:[],toUpdate:[]}),k=$.map(G=>a(G,E)).filter(Boolean);P.forEach(G=>{r.set(G.id,G),G.bodies.forEach(st=>t.set(st.id,G.id))}),n(E,{created:P,updated:k})},d=(C,E=It.LOCAL)=>{const I=r.get(C.annotation);if(I){const P={...I,bodies:[...I.bodies,C]};r.set(I.id,P),t.set(C.id,P.id),n(E,{updated:[{oldValue:I,newValue:P,bodiesCreated:[C]}]})}else console.warn(`Attempt to add body to missing annotation: ${C.annotation}`)},p=()=>[...r.values()],f=(C=It.LOCAL)=>{const E=[...r.values()];r.clear(),t.clear(),n(C,{deleted:E})},m=(C,E=!0,I=It.LOCAL)=>{const P=C.map(ln);if(E){const $=[...r.values()];r.clear(),t.clear(),P.forEach(k=>{r.set(k.id,k),k.bodies.forEach(G=>t.set(G.id,k.id))}),n(I,{created:P,deleted:$})}else{const $=C.reduce((k,G)=>{const st=G.id&&r.get(G.id);return st?[...k,st]:k},[]);if($.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${$.map(k=>k.id).join(", ")}`);P.forEach(k=>{r.set(k.id,k),k.bodies.forEach(G=>t.set(G.id,k.id))}),n(I,{created:P})}},y=C=>{const E=typeof C=="string"?C:C.id,I=r.get(E);if(I)return r.delete(E),I.bodies.forEach(P=>t.delete(P.id)),I;console.warn(`Attempt to delete missing annotation: ${E}`)},_=(C,E=It.LOCAL)=>{const I=y(C);I&&n(E,{deleted:[I]})},v=(C,E=It.LOCAL)=>{const I=C.reduce((P,$)=>{const k=y($);return k?[...P,k]:P},[]);I.length>0&&n(E,{deleted:I})},g=C=>{const E=r.get(C.annotation);if(E){const I=E.bodies.find(P=>P.id===C.id);if(I){t.delete(I.id);const P={...E,bodies:E.bodies.filter($=>$.id!==C.id)};return r.set(E.id,P),{oldValue:E,newValue:P,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,E=It.LOCAL)=>{const I=g(C);I&&n(E,{updated:[I]})},b=(C,E=It.LOCAL)=>{const I=C.map(P=>g(P)).filter(Boolean);I.length>0&&n(E,{updated:I})},S=C=>{const E=r.get(C);return E?{...E}:void 0},w=C=>{const E=t.get(C);if(E){const I=S(E).bodies.find(P=>P.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}`)},T=(C,E)=>{if(C.annotation!==E.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const I=r.get(C.annotation);if(I){const P=I.bodies.find(k=>k.id===C.id),$={...I,bodies:I.bodies.map(k=>k.id===P.id?E:k)};return r.set(I.id,$),P.id!==E.id&&(t.delete(P.id),t.set(E.id,$.id)),{oldValue:I,newValue:$,bodiesUpdated:[{oldBody:P,newBody:E}]}}else console.warn(`Attempt to add body to missing annotation ${C.annotation}`)},N=(C,E,I=It.LOCAL)=>{const P=T(C,E);P&&n(I,{updated:[P]})},F=(C,E=It.LOCAL)=>{const I=C.map(P=>T({id:P.id,annotation:P.annotation},P)).filter(Boolean);n(E,{updated:I})},z=C=>{const E=r.get(C.annotation);if(E){const I={...E,target:{...E.target,...C}};return r.set(E.id,I),{oldValue:E,newValue:I,targetUpdated:{oldTarget:E.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:b,bulkUpdateAnnotations:u,bulkUpdateBodies:F,bulkUpdateTargets:(C,E=It.LOCAL)=>{const I=C.map(P=>z(P)).filter(Boolean);I.length>0&&n(E,{updated:I})},bulkUpsertAnnotations:c,clear:f,deleteAnnotation:_,deleteBody:x,getAnnotation:S,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:N,updateTarget:(C,E=It.LOCAL)=>{const I=z(C);I&&n(E,{updated:[I]})},upsertAnnotation:h}},Ay=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let Sy=()=>({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 Cy=250,Iy=(r,t)=>{const e=Sy(),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>Cy)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=Ey(i[_],m)}o=y}n=!1};r.observe(a,{origin:It.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}}}},Ry=()=>{const{subscribe:r,set:t}=sa([]);return{subscribe:r,set:t}},My=(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 b=Array.isArray(v)?v.map(w=>e.serialize(w)):e.serialize(v),S=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(b,S)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(b=>b.id===g.id);(!x||!Nr(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&&!Nr(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 b=o.getAnnotation(x.id);b&&!Nr(b,x)&&f("updateAnnotation",b,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:b})=>{const S=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,S)})},{origin:It.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(b=>b.id===x.id)||x))}},{origin:It.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}},Py=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:[]}),Oy=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,It.REMOTE):console.error(g)}else i.addAnnotation(oa(_),It.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||Py(e),{parsed:x,failed:b}=g(_);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotations(x,v,It.REMOTE)}else i.bulkAddAnnotations(_.map(oa),v,It.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(oa(_)),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}},Ny=(r,t,e)=>typeof t=="function"?t(r,e):t,Dy=(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||{}}},Ly="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let By=r=>crypto.getRandomValues(new Uint8Array(r)),Fy=(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}}},Uy=(r,t=21)=>Fy(r,t|0,By),ky=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ly[e[r]&63];return t};const Gy=()=>({isGuest:!0,id:Uy("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),$y=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}`},hu=r=>r?typeof r=="object"?{...r}:r:void 0,Hy=(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-${$y(e)}`,annotation:t,type:s,purpose:n,value:o,creator:hu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),Vy=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});ky();const Xy=(r,t={strict:!0,invertY:!1})=>({parse:e=>zy(e,t),serialize:e=>Wy(e,r,t)}),zy=(r,t={strict:!0,invertY:!1})=>{const e=r.id||iu(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Hy(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"?Ig(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?ry(u):void 0;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:hu(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},Wy=(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==vt.RECTANGLE?Rg(i.geometry):sy(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:Vy(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u};function uu(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function cu(r){let t,e;return t=new Oi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){$t(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Yy(r){let t,e,i,s,n,o,a,l,h,u,c,d=Ee(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=cu(uu(r,d,m));const f=m=>dt(p[m],1,1,()=>{p[m]=null});return{c(){t=mt("polygon"),s=ke(),n=mt("polygon"),a=ke();for(let m=0;m<p.length;m+=1)p[m].c();l=Ie(),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"points",i=r[4].points.map(du).join(" ")),A(n,"class","a9s-inner a9s-shape-handle"),A(n,"style",r[1]),A(n,"points",o=r[4].points.map(fu).join(" "))},m(m,y){ot(m,t,y),ot(m,s,y),ot(m,n,y),ot(m,a,y);for(let _=0;_<p.length;_+=1)p[_]&&p[_].m(m,y);ot(m,l,y),h=!0,u||(c=[Bt(t,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(n,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,y){if(r=m,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(du).join(" ")))&&A(t,"points",i),(!h||y&2)&&A(n,"style",r[1]),(!h||y&16&&o!==(o=r[4].points.map(fu).join(" ")))&&A(n,"points",o),y&536){d=Ee(r[4].points);let _;for(_=0;_<d.length;_+=1){const v=uu(r,d,_);p[_]?(p[_].p(v,y),it(p[_],1)):(p[_]=cu(v),p[_].c(),it(p[_],1),p[_].m(l.parentNode,l))}for(xe(),_=d.length;_<p.length;_+=1)f(_);be()}},i(m){if(!h){for(let y=0;y<d.length;y+=1)it(p[y]);h=!0}},o(m){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)dt(p[y]);h=!1},d(m){m&&(nt(t),nt(s),nt(n),nt(a),nt(l)),Jr(p,m),u=!1,Ue(c)}}}function jy(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Yy,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}const du=r=>r.join(","),fu=r=>r.join(",");function qy(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const y=d.geometry;p==="SHAPE"?m=y.points.map(([v,g])=>[v+f[0],g+f[1]]):m=y.points.map(([v,g],x)=>p===`HANDLE-${x}`?[v+f[0],g+f[1]]:[v,g]);const _=_r(m);return{...d,geometry:{points:m,bounds:_}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class Ky extends we{constructor(t){super(),Te(this,t,qy,jy,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const aa=(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))},Pi=[];function Zy(r,t=Ct){let e;const i=new Set;function s(a){if(te(r,a)&&(r=a,e)){const l=!Pi.length;for(const h of i)h[1](),Pi.push(h,r);if(l){for(let h=0;h<Pi.length;h+=2)Pi[h][0](Pi[h+1]);Pi.length=0}}}function n(a){s(a(r))}function o(a,l=Ct){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Ct),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Qy=(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}`)},Jy=(r,t)=>{Qy(r,t);const{subscribe:e,set:i}=Zy(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}},pu=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function t_(r){let t,e,i,s,n,o;return{c(){t=mt("rect"),A(t,"class",e=tn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(t,"x",i=r[0]-r[5]/2),A(t,"y",s=r[1]-r[5]/2),A(t,"width",r[5]),A(t,"height",r[5])},m(a,l){ot(a,t,l),n||(o=Bt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=tn(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&A(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&A(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&A(t,"y",s),l&32&&A(t,"width",a[5]),l&32&&A(t,"height",a[5])},d(a){a&&nt(t),n=!1,o()}}}function e_(r){let t,e,i,s,n,o,a,l,h;return{c(){t=mt("g"),e=mt("circle"),s=mt("rect"),A(e,"cx",r[0]),A(e,"cy",r[1]),A(e,"r",i=r[3]/r[2]),A(e,"class","a9s-touch-halo svelte-1sgkh33"),Mr(e,"touched",r[4]),A(s,"class",n=tn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(s,"x",o=r[0]-r[5]/2),A(s,"y",a=r[1]-r[5]/2),A(s,"width",r[5]),A(s,"height",r[5]),A(t,"class","a9s-touch-handle")},m(u,c){ot(u,t,c),Oe(t,e),Oe(t,s),l||(h=[Bt(e,"pointerdown",r[10]),Bt(e,"pointerdown",r[6]),Bt(e,"pointerup",r[7]),Bt(s,"pointerdown",r[9]),Bt(s,"pointerdown",r[6]),Bt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&A(e,"cx",u[0]),c&2&&A(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&A(e,"r",i),c&16&&Mr(e,"touched",u[4]),c&256&&n!==(n=tn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&A(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&A(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&A(s,"y",a),c&32&&A(s,"width",u[5]),c&32&&A(s,"height",u[5])},d(u){u&&nt(t),l=!1,Ue(h)}}}function r_(r){let t;function e(s,n){return pu?e_:t_}let i=e()(r);return{c(){i.c(),t=Ie()},m(s,n){i.m(s,n),ot(s,t,n)},p(s,[n]){i.p(s,n)},i:Ct,o:Ct,d(s){s&&nt(t),i.d(s)}}}function i_(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){Ne.call(this,r,f)}function d(f){Ne.call(this,r,f)}function p(f){Ne.call(this,r,f)}return r.$$set=f=>{e(8,t=Xo(Xo({},t),Fh(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Fh(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class Oi extends we{constructor(t){super(),Te(this,t,i_,r_,te,{x:0,y:1,scale:2,radius:3})}}function s_(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,b,S,w,T,N,F,z,C,E,I,P,$,k,G,st,M,L,V,rt,Q,X,_t,St;return G=new Oi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),G.$on("pointerdown",function(){$t(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),M=new Oi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),M.$on("pointerdown",function(){$t(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),V=new Oi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),V.$on("pointerdown",function(){$t(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Oi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){$t(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=mt("rect"),a=ke(),l=mt("rect"),p=ke(),f=mt("rect"),v=ke(),g=mt("rect"),w=ke(),T=mt("rect"),C=ke(),E=mt("rect"),k=ke(),_e(G.$$.fragment),st=ke(),_e(M.$$.fragment),L=ke(),_e(V.$$.fragment),rt=ke(),_e(Q.$$.fragment),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"x",i=r[4].x),A(t,"y",s=r[4].y),A(t,"width",n=r[4].w),A(t,"height",o=r[4].h),A(l,"class","a9s-inner a9s-shape-handle"),A(l,"style",r[1]),A(l,"x",h=r[4].x),A(l,"y",u=r[4].y),A(l,"width",c=r[4].w),A(l,"height",d=r[4].h),A(f,"class","a9s-edge-handle a9s-edge-handle-top"),A(f,"x",m=r[4].x),A(f,"y",y=r[4].y),A(f,"height",1),A(f,"width",_=r[4].w),A(g,"class","a9s-edge-handle a9s-edge-handle-right"),A(g,"x",x=r[4].x+r[4].w),A(g,"y",b=r[4].y),A(g,"height",S=r[4].h),A(g,"width",1),A(T,"class","a9s-edge-handle a9s-edge-handle-bottom"),A(T,"x",N=r[4].x),A(T,"y",F=r[4].y+r[4].h),A(T,"height",1),A(T,"width",z=r[4].w),A(E,"class","a9s-edge-handle a9s-edge-handle-left"),A(E,"x",I=r[4].x),A(E,"y",P=r[4].y),A(E,"height",$=r[4].h),A(E,"width",1)},m(O,D){ot(O,t,D),ot(O,a,D),ot(O,l,D),ot(O,p,D),ot(O,f,D),ot(O,v,D),ot(O,g,D),ot(O,w,D),ot(O,T,D),ot(O,C,D),ot(O,E,D),ot(O,k,D),fe(G,O,D),ot(O,st,D),fe(M,O,D),ot(O,L,D),fe(V,O,D),ot(O,rt,D),fe(Q,O,D),X=!0,_t||(St=[Bt(t,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(l,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(f,"pointerdown",function(){$t(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Bt(g,"pointerdown",function(){$t(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Bt(T,"pointerdown",function(){$t(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Bt(E,"pointerdown",function(){$t(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(O,D){r=O,(!X||D&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!X||D&16&&i!==(i=r[4].x))&&A(t,"x",i),(!X||D&16&&s!==(s=r[4].y))&&A(t,"y",s),(!X||D&16&&n!==(n=r[4].w))&&A(t,"width",n),(!X||D&16&&o!==(o=r[4].h))&&A(t,"height",o),(!X||D&2)&&A(l,"style",r[1]),(!X||D&16&&h!==(h=r[4].x))&&A(l,"x",h),(!X||D&16&&u!==(u=r[4].y))&&A(l,"y",u),(!X||D&16&&c!==(c=r[4].w))&&A(l,"width",c),(!X||D&16&&d!==(d=r[4].h))&&A(l,"height",d),(!X||D&16&&m!==(m=r[4].x))&&A(f,"x",m),(!X||D&16&&y!==(y=r[4].y))&&A(f,"y",y),(!X||D&16&&_!==(_=r[4].w))&&A(f,"width",_),(!X||D&16&&x!==(x=r[4].x+r[4].w))&&A(g,"x",x),(!X||D&16&&b!==(b=r[4].y))&&A(g,"y",b),(!X||D&16&&S!==(S=r[4].h))&&A(g,"height",S),(!X||D&16&&N!==(N=r[4].x))&&A(T,"x",N),(!X||D&16&&F!==(F=r[4].y+r[4].h))&&A(T,"y",F),(!X||D&16&&z!==(z=r[4].w))&&A(T,"width",z),(!X||D&16&&I!==(I=r[4].x))&&A(E,"x",I),(!X||D&16&&P!==(P=r[4].y))&&A(E,"y",P),(!X||D&16&&$!==($=r[4].h))&&A(E,"height",$);const ut={};D&16&&(ut.x=r[4].x),D&16&&(ut.y=r[4].y),D&8&&(ut.scale=r[3]),G.$set(ut);const lt={};D&16&&(lt.x=r[4].x+r[4].w),D&16&&(lt.y=r[4].y),D&8&&(lt.scale=r[3]),M.$set(lt);const Et={};D&16&&(Et.x=r[4].x+r[4].w),D&16&&(Et.y=r[4].y+r[4].h),D&8&&(Et.scale=r[3]),V.$set(Et);const Tt={};D&16&&(Tt.x=r[4].x),D&16&&(Tt.y=r[4].y+r[4].h),D&8&&(Tt.scale=r[3]),Q.$set(Tt)},i(O){X||(it(G.$$.fragment,O),it(M.$$.fragment,O),it(V.$$.fragment,O),it(Q.$$.fragment,O),X=!0)},o(O){dt(G.$$.fragment,O),dt(M.$$.fragment,O),dt(V.$$.fragment,O),dt(Q.$$.fragment,O),X=!1},d(O){O&&(nt(t),nt(a),nt(l),nt(p),nt(f),nt(v),nt(g),nt(w),nt(T),nt(C),nt(E),nt(k),nt(st),nt(L),nt(rt)),pe(G,O),pe(M,O),pe(V,O),pe(Q,O),_t=!1,Ue(St)}}}function n_(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[s_,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function o_(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[y,_]=[m.minX,m.minY],[v,g]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,v+=x,_+=b,g+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{_+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const S=Math.min(y,v),w=Math.min(_,g),T=Math.abs(v-y),N=Math.abs(g-_);return{...d,geometry:{x:S,y:w,w:T,h:N,bounds:{minX:S,minY:w,maxX:S+T,maxY:w+N}}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class a_ extends we{constructor(t){super(),Te(this,t,o_,n_,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}function mu(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function gu(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 _u(r){let t,e;return t=new Oi({props:{x:r[16][0],y:r[16][1],scale:r[3]}}),t.$on("pointerdown",function(){$t(r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`))&&r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[16][0]),s&16&&(n.y=r[16][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function vu(r){let t,e,i=Ee(r[13].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=_u(yu(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&536){i=Ee(o[13].points);let l;for(l=0;l<i.length;l+=1){const h=yu(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=_u(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function xu(r){let t,e,i,s,n,o,a,l,h,u=Ee(r[10].rings),c=[];for(let p=0;p<u.length;p+=1)c[p]=vu(gu(r,u,p));const d=p=>dt(c[p],1,1,()=>{c[p]=null});return{c(){t=mt("g"),e=mt("path"),n=mt("path");for(let p=0;p<c.length;p+=1)c[p].c();A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"fill-rule","evenodd"),A(e,"d",s=ei(r[10])),A(n,"class","a9s-inner"),A(n,"style",r[1]),A(n,"fill-rule","evenodd"),A(n,"d",o=ei(r[10]))},m(p,f){ot(p,t,f),Oe(t,e),Oe(t,n);for(let m=0;m<c.length;m+=1)c[m]&&c[m].m(t,null);a=!0,l||(h=[Bt(e,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(n,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],l=!0)},p(p,f){if(r=p,(!a||f&2&&i!==(i=r[1]?"display:none;":void 0))&&A(e,"style",i),(!a||f&16&&s!==(s=ei(r[10])))&&A(e,"d",s),(!a||f&2)&&A(n,"style",r[1]),(!a||f&16&&o!==(o=ei(r[10])))&&A(n,"d",o),f&536){u=Ee(r[10].rings);let m;for(m=0;m<u.length;m+=1){const y=gu(r,u,m);c[m]?(c[m].p(y,f),it(c[m],1)):(c[m]=vu(y),c[m].c(),it(c[m],1),c[m].m(t,null))}for(xe(),m=u.length;m<c.length;m+=1)d(m);be()}},i(p){if(!a){for(let f=0;f<u.length;f+=1)it(c[f]);a=!0}},o(p){c=c.filter(Boolean);for(let f=0;f<c.length;f+=1)dt(c[f]);a=!1},d(p){p&&nt(t),Jr(c,p),l=!1,Ue(h)}}}function l_(r){let t,e,i=Ee(r[4].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=xu(mu(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&538){i=Ee(o[4].polygons);let l;for(l=0;l<i.length;l+=1){const h=mu(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=xu(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function h_(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[l_,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&524826&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function u_(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.polygons;let y;if(p==="SHAPE")y=m.map(_=>{const v=_.rings.map((x,b)=>({points:x.points.map((S,w)=>[S[0]+f[0],S[1]+f[1]])})),g=_r(v[0].points);return{rings:v,bounds:g}});else{const[_,v,g,x]=p.split("-").map(b=>parseInt(b));y=m.map((b,S)=>{if(S===v){const w=b.rings.map((N,F)=>F===g?{points:N.points.map((z,C)=>C===x?[z[0]+f[0],z[1]+f[1]]:z)}:N),T=_r(w[0].points);return{rings:w,bounds:T}}else return b})}return{...d,geometry:{polygons:y,bounds:Ag(y)}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class c_ extends we{constructor(t){super(),Te(this,t,u_,h_,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const bu=new Map([[vt.RECTANGLE,a_],[vt.POLYGON,Ky],[vt.MULTIPOLYGLON,c_]]),Eu=r=>bu.get(r.type),Tu=(r,t)=>bu.set(r,t),d_=r=>({}),wu=r=>({grab:r[0]});function f_(r){let t,e,i,s;const n=r[7].default,o=hg(n,r,r[6],wu);return{c(){t=mt("g"),o&&o.c(),A(t,"class","a9s-annotation selected")},m(a,l){ot(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Bt(t,"pointerup",r[2]),Bt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&cg(o,n,a,a[6],e?ug(n,a[6],l,d_):dg(a[6]),wu)},i(a){e||(it(o,a),e=!0)},o(a){dt(o,a),e=!1},d(a){a&&nt(t),o&&o.d(a),i=!1,Ue(s)}}}function p_(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Si();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>y=>{h=m,u=l.elementToImage(y.offsetX,y.offsetY),c=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=m=>{if(h){const[y,_]=l.elementToImage(m.offsetX,m.offsetY),v=[y-u[0],_-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class la extends we{constructor(t){super(),Te(this,t,p_,f_,te,{shape:3,editor:4,transform:5})}}const gs=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function m_(r,t,e){let i;const s=Si();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return ms(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=gs(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 g_ extends we{constructor(t){super(),Te(this,t,m_,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function y_(r,t,e){const i=Si();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return ms(()=>{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 __ extends we{constructor(t){super(),Te(this,t,y_,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function Au(r){let t,e;return{c(){t=mt("rect"),e=mt("rect"),A(t,"class","a9s-outer"),A(t,"x",r[1]),A(t,"y",r[2]),A(t,"width",r[3]),A(t,"height",r[4]),A(e,"class","a9s-inner"),A(e,"x",r[1]),A(e,"y",r[2]),A(e,"width",r[3]),A(e,"height",r[4])},m(i,s){ot(i,t,s),ot(i,e,s)},p(i,s){s&2&&A(t,"x",i[1]),s&4&&A(t,"y",i[2]),s&8&&A(t,"width",i[3]),s&16&&A(t,"height",i[4]),s&2&&A(e,"x",i[1]),s&4&&A(e,"y",i[2]),s&8&&A(e,"width",i[3]),s&16&&A(e,"height",i[4])},d(i){i&&(nt(t),nt(e))}}}function v_(r){let t,e=r[0]&&Au(r);return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){ot(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=Au(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Ct,o:Ct,d(i){i&&nt(t),e&&e.d()}}}function x_(r,t,e){const i=Si();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,u,c,d,p;const f=v=>{const g=v;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))},m=v=>{const g=v;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,u=Math.min(h[0],l[0])),e(2,c=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,p=Math.abs(h[1]-l[1])))},y=v=>{const g=v,x=performance.now()-a;if(n==="click"){if(x>300)return;l?_():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))}else l&&(x>300||d*p>100?(g.stopPropagation(),_()):(e(0,l=void 0),h=void 0))},_=()=>{if(d*p>15){const v={type:vt.RECTANGLE,geometry:{bounds:{minX:u,minY:c,maxX:u+d,maxY:c+p},x:u,y:c,w:d,h:p}};i("create",v)}e(0,l=void 0),h=void 0};return ms(()=>{s("pointerdown",f),s("pointermove",m),s("pointerup",y,!0)}),r.$$set=v=>{"addEventListener"in v&&e(5,s=v.addEventListener),"drawingMode"in v&&e(6,n=v.drawingMode),"transform"in v&&e(7,o=v.transform)},[l,u,c,d,p,s,n,o]}class b_ extends we{constructor(t){super(),Te(this,t,x_,v_,te,{addEventListener:5,drawingMode:6,transform:7})}}function ha(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function Su(r){let t,e,i,s,n,o=r[2]&&Cu(r);return{c(){t=mt("polygon"),i=mt("polygon"),o&&o.c(),n=Ie(),A(t,"class","a9s-outer"),A(t,"points",e=r[16]),A(i,"class","a9s-inner"),A(i,"points",s=r[16])},m(a,l){ot(a,t,l),ot(a,i,l),o&&o.m(a,l),ot(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&A(t,"points",e),l&7&&s!==(s=a[16])&&A(i,"points",s),a[2]?o?o.p(a,l):(o=Cu(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(nt(t),nt(i),nt(n)),o&&o.d(a)}}}function Cu(r){let t,e,i;return{c(){t=mt("rect"),A(t,"class","a9s-handle"),A(t,"x",e=r[0][0][0]-r[3]/2),A(t,"y",i=r[0][0][1]-r[3]/2),A(t,"height",r[3]),A(t,"width",r[3])},m(s,n){ot(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&A(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&A(t,"y",i),n&8&&A(t,"height",s[3]),n&8&&A(t,"width",s[3])},d(s){s&&nt(t)}}}function E_(r){let t,e=r[1]&&Su(ha(r));return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){ot(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(ha(i),s):(e=Su(ha(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Ct,o:Ct,d(i){i&&nt(t),e&&e.d()}}}const T_=20,w_=1500;function A_(r,t,e){let i;const s=Si();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u=[],c,d,p=!1;const f=g=>{const x=g,{timeStamp:b,offsetX:S,offsetY:w}=x;if(h={timeStamp:b,offsetX:S,offsetY:w},o==="drag"&&u.length===0){const T=a.elementToImage(x.offsetX,x.offsetY);u.push(T),e(1,c=T)}},m=g=>{const x=g;if(d&&clearTimeout(d),u.length>0){if(e(1,c=a.elementToImage(x.offsetX,x.offsetY)),u.length>2){const b=aa(c,u[0])*l;e(2,p=b<T_)}x.pointerType==="touch"&&(d=setTimeout(()=>{_()},w_))}},y=g=>{const x=g;if(d&&clearTimeout(d),o==="click"){const b=x.timeStamp-h.timeStamp,S=aa([h.offsetX,h.offsetY],[x.offsetX,x.offsetY]);if(b>300||S>15)return;if(p)v();else if(u.length===0){const w=a.elementToImage(x.offsetX,x.offsetY);u.push(w),e(1,c=w)}else u.push(c)}else{if(u.length===1&&aa(u[0],c)<=4){e(0,u=[]),e(1,c=void 0);return}x.stopImmediatePropagation(),p?v():u.push(c)}},_=()=>{if(!c)return;const g=u.slice(0,-1);if(g.length<3)return;const x={type:vt.POLYGON,geometry:{bounds:_r(u),points:g}};Ko(x)>4&&(e(0,u=[]),e(1,c=void 0),s("create",x))},v=()=>{const g={type:vt.POLYGON,geometry:{bounds:_r(u),points:[...u]}};e(0,u=[]),e(1,c=void 0),s("create",g)};return ms(()=>{n("pointerdown",f,!0),n("pointermove",m),n("pointerup",y,!0),n("dblclick",_,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[u,c,p,i,n,o,a,l]}class S_ extends we{constructor(t){super(),Te(this,t,A_,E_,te,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const ua=new Map([["rectangle",{tool:b_}],["polygon",{tool:S_}]]),hn=()=>[...ua.keys()],un=r=>ua.get(r),Iu=(r,t,e)=>ua.set(r,{tool:t,opts:e});function C_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("ellipse"),s=mt("ellipse"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"cx",r[2]),A(e,"cy",r[3]),A(e,"rx",r[4]),A(e,"ry",r[5]),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"cx",r[2]),A(s,"cy",r[3]),A(s,"rx",r[4]),A(s,"ry",r[5]),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}function I_(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=gs(s,o))},[s,i,a,l,h,u,n,o]}class R_ extends we{constructor(t){super(),Te(this,t,I_,C_,te,{annotation:0,geom:6,style:7})}}function Ru(r,t,e){const i=r.slice();return i[5]=t[e],i}function Mu(r){let t,e,i;return{c(){t=mt("path"),i=mt("path"),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"fill-rule","evenodd"),A(t,"d",ei(r[5])),A(i,"class","a9s-inner"),A(i,"style",r[1]),A(i,"fill-rule","evenodd"),A(i,"d",ei(r[5]))},m(s,n){ot(s,t,n),ot(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&A(t,"style",e),n&2&&A(i,"style",s[1])},d(s){s&&(nt(t),nt(i))}}}function M_(r){let t,e,i=Ee(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=Mu(Ru(r,i,n));return{c(){t=mt("g");for(let n=0;n<s.length;n+=1)s[n].c();A(t,"class","a9s-annotation"),A(t,"data-id",e=r[0].id)},m(n,o){ot(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=Ee(n[2]);let a;for(a=0;a<i.length;a+=1){const l=Ru(n,i,a);s[a]?s[a].p(l,o):(s[a]=Mu(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)&&A(t,"data-id",e)},i:Ct,o:Ct,d(n){n&&nt(t),Jr(s,n)}}}function P_(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=gs(s,o))},[s,i,a,n,o]}class O_ extends we{constructor(t){super(),Te(this,t,P_,M_,te,{annotation:0,geom:3,style:4})}}function N_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("polygon"),s=mt("polygon"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"points",r[2].map(D_).join(" ")),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"points",r[2].map(L_).join(" ")),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}const D_=r=>r.join(","),L_=r=>r.join(",");function B_(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=gs(s,o))},[s,i,a,n,o]}class F_ extends we{constructor(t){super(),Te(this,t,B_,N_,te,{annotation:0,geom:3,style:4})}}function U_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("rect"),s=mt("rect"),A(e,"class","a9s-outer"),A(e,"style",i=r[5]?"display:none;":void 0),A(e,"x",r[4]),A(e,"y",r[3]),A(e,"width",r[2]),A(e,"height",r[1]),A(s,"class","a9s-inner"),A(s,"style",r[5]),A(s,"x",r[4]),A(s,"y",r[3]),A(s,"width",r[2]),A(s,"height",r[1]),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&A(e,"style",i),a&16&&A(e,"x",o[4]),a&8&&A(e,"y",o[3]),a&4&&A(e,"width",o[2]),a&2&&A(e,"height",o[1]),a&32&&A(s,"style",o[5]),a&16&&A(s,"x",o[4]),a&8&&A(s,"y",o[3]),a&4&&A(s,"width",o[2]),a&2&&A(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}function k_(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=gs(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 G_ extends we{constructor(t){super(),Te(this,t,k_,U_,te,{annotation:0,geom:6,style:7})}}const $_=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]}}),H_=250,V_=(r,t)=>{const e=Si();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<H_){const{x:n,y:o}=Pu(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},Pu=(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 Ou(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 Nu(r,t,e){const i=r.slice();return i[43]=t[e],i}function ca(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function Du(r){let t=r[43],e,i,s=Lu(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&65536&&te(t,t=n[43])?(xe(),dt(s,1,1,Ct),be(),s=Lu(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function X_(r){let t,e;return t=new O_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function z_(r){let t,e;return t=new F_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function W_(r){let t,e;return t=new G_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Y_(r){var t;let e,i;return e=new R_({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){_e(e.$$.fragment)},m(s,n){fe(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||(it(e.$$.fragment,s),i=!0)},o(s){dt(e.$$.fragment,s),i=!1},d(s){pe(e,s)}}}function Lu(r){let t,e,i,s;const n=[Y_,W_,z_,X_],o=[];function a(l,h){var u,c,d,p;return((u=l[46])==null?void 0:u.type)===vt.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===vt.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===vt.POLYGON?2:((p=l[46])==null?void 0:p.type)===vt.MULTIPOLYGLON?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ie()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),dt(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()),it(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(it(e),s=!0)},o(l){dt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function Bu(r){let t=Ge(r[43])&&!r[9](r[43]),e,i,s=t&&Du(ca(r));return{c(){s&&s.c(),e=Ie()},m(n,o){s&&s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=Ge(n[43])&&!n[9](n[43])),t?s?(s.p(ca(n),o),o[0]&66048&&it(s,1)):(s=Du(ca(n)),s.c(),it(s,1),s.m(e.parentNode,e)):s&&(xe(),dt(s,1,1,()=>{s=null}),be())},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function Fu(r){let t,e,i,s;const n=[q_,j_],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=Ie()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),dt(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()),it(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(it(e),s=!0)},o(l){dt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function j_(r){let t=`${r[2]}-${r[5]}`,e,i,s=Uu(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&36&&te(t,t=`${n[2]}-${n[5]}`)?(xe(),dt(s,1,1,Ct),be(),s=Uu(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function q_(r){let t,e,i=Ee(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=$u(Ou(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=Ee(o[8]);let l;for(l=0;l<i.length;l+=1){const h=Ou(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=$u(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function Uu(r){let t,e;return t=new __({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function ku(r){let t=r[39].id,e,i,s=Gu(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&256&&te(t,t=n[39].id)?(xe(),dt(s,1,1,Ct),be(),s=Gu(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function Gu(r){let t,e;return t=new g_({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(){$t(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function $u(r){let t,e,i=r[40]&&ku(r);return{c(){i&&i.c(),t=Ie()},m(s,n){i&&i.m(s,n),ot(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&it(i,1)):(i=ku(s),i.c(),it(i,1),i.m(t.parentNode,t)):i&&(xe(),dt(i,1,1,()=>{i=null}),be())},i(s){e||(it(i),e=!0)},o(s){dt(i),e=!1},d(s){s&&nt(t),i&&i.d(s)}}}function K_(r){let t,e,i,s,n,o,a=Ee(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=Bu(Nu(r,a,c));const h=c=>dt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&Fu(r);return{c(){t=mt("svg"),e=mt("g");for(let c=0;c<l.length;c+=1)l[c].c();i=mt("g"),u&&u.c(),A(i,"class","drawing"),A(t,"class","a9s-annotationlayer"),Mr(t,"drawing",r[14]),Mr(t,"hidden",!r[3]),Mr(t,"hover",r[15])},m(c,d){ot(c,t,d),Oe(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);Oe(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Bt(t,"pointerup",function(){$t(r[10])&&r[10].apply(this,arguments)}),Bt(t,"pointerdown",function(){$t(r[11])&&r[11].apply(this,arguments)}),Bt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=Ee(r[16].filter(r[34]));let p;for(p=0;p<a.length;p+=1){const f=Nu(r,a,p);l[p]?(l[p].p(f,d),it(l[p],1)):(l[p]=Bu(f),l[p].c(),it(l[p],1),l[p].m(e,null))}for(xe(),p=a.length;p<l.length;p+=1)h(p);be()}r[6]?u?(u.p(r,d),d[0]&64&&it(u,1)):(u=Fu(r),u.c(),it(u,1),u.m(i,null)):u&&(xe(),dt(u,1,1,()=>{u=null}),be()),(!s||d[0]&16384)&&Mr(t,"drawing",r[14]),(!s||d[0]&8)&&Mr(t,"hidden",!r[3]),(!s||d[0]&32768)&&Mr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)it(l[d]);it(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)dt(l[d]);dt(u),s=!1},d(c){c&&nt(t),Jr(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,Ue(o)}}}function Z_(r,t,e){let i,s,n,o,a,l,h,u,c,d,p,f=Ct,m=()=>(f(),f=Lh(I,O=>e(17,p=O)),I);r.$$.on_destroy.push(()=>f());let{drawingEnabled:y}=t,{image:_}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:b=hn()[0]}=t,{user:S}=t,{visible:w=!0}=t,T=0;const N=()=>e(5,T+=1),F=()=>b,z=()=>y;let C,E,I;ms(()=>m(e(7,I=Jy(_,E))));const{hover:P,selection:$,store:k}=g;zo(r,P,O=>e(15,u=O)),zo(r,$,O=>e(33,c=O)),zo(r,k,O=>e(16,d=O));let G,st;const M=O=>{G&&k.unobserve(G);const D=O.filter(({editable:ut})=>ut).map(({id:ut})=>ut);D.length>0?(e(8,st=D.map(ut=>k.getAnnotation(ut)).filter(ut=>ut&&Ge(ut))),G=ut=>{const{updated:lt}=ut.changes;e(8,st=lt==null?void 0:lt.map(Et=>Et.newValue))},k.observe(G,{annotations:D})):e(8,st=void 0)},L=O=>{const D=iu(),ut={id:D,bodies:[],target:{annotation:D,selector:O.detail,creator:S,created:new Date}};k.addAnnotation(ut),$.setSelected(ut.id)},V=O=>D=>{var ut;const{target:lt}=O,Et=10*60*1e3,Tt=((ut=lt.creator)==null?void 0:ut.id)!==S.id||!lt.created||new Date().getTime()-lt.created.getTime()>Et;k.updateTarget({...lt,selector:D.detail,created:Tt?lt.created:new Date,updated:Tt?new Date:void 0,updatedBy:Tt?S:void 0})},rt=O=>{const{x:D,y:ut}=Pu(O,E),lt=k.getAt(D,ut);lt?u!==lt.id&&P.set(lt.id):P.set(void 0)},Q=O=>Eu(O),X=O=>Ge(O);function _t(O){en[O?"unshift":"push"](()=>{C=O,e(6,C)})}function St(O){en[O?"unshift":"push"](()=>{E=O,e(4,E)})}return r.$$set=O=>{"drawingEnabled"in O&&e(0,y=O.drawingEnabled),"image"in O&&e(25,_=O.image),"preferredDrawingMode"in O&&e(26,v=O.preferredDrawingMode),"state"in O&&e(27,g=O.state),"style"in O&&e(1,x=O.style),"toolName"in O&&e(2,b=O.toolName),"user"in O&&e(28,S=O.user),"visible"in O&&e(3,w=O.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=un(b)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,b))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=$_(E)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=V_(E,k),a,(e(10,l),e(4,E))),r.$$.dirty[1]&4&&e(9,h=O=>c.selected.find(D=>D.id===O.id&&D.editable)),r.$$.dirty[1]&4&&M(c.selected)},[y,x,b,w,E,T,C,I,st,h,l,a,o,n,i,u,d,p,P,$,k,L,V,rt,Q,_,v,g,S,N,F,z,s,c,X,_t,St]}class Q_ extends we{constructor(t){super(),Te(this,t,Z_,K_,te,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function Hu(r,t,e=0,i=r.length-1,s=J_){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1),p=Math.max(e,Math.floor(t-h*c/l+d)),f=Math.min(i,Math.floor(t+(l-h)*c/l+d));Hu(r,t,p,f,s)}const n=r[t];let o=e,a=i;for(ys(r,e,t),s(r[i],n)>0&&ys(r,e,i);o<a;){for(ys(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ys(r,e,a):(a++,ys(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ys(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function J_(r,t){return r<t?-1:r>t?1:0}class t0{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(!dn(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;dn(t,l)&&(e.leaf?i.push(a):fa(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!dn(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(dn(t,o)){if(e.leaf||fa(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=Di([]),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=e0(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&fa(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=Di(t.slice(e,i+1)),Ni(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=Di([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Vu(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);Vu(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 Ni(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=da(h),c=s0(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),vs(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=Di(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Ni(i,this.toBBox),Ni(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Di([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ni(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=_s(t,0,a,this.toBBox),h=_s(t,a,i,this.toBBox),u=n0(l,h),c=da(l)+da(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:r0,n=t.leaf?this.compareMinY:i0,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=_s(t,0,e,n),a=_s(t,i-e,i,n);let l=cn(o)+cn(a);for(let h=e;h<i-e;h++){const u=t.children[h];vs(o,t.leaf?n(u):u),l+=cn(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];vs(a,t.leaf?n(u):u),l+=cn(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)vs(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():Ni(t[e],this.toBBox)}}function e0(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 Ni(r,t){_s(r,0,r.children.length,t,r)}function _s(r,t,e,i,s){s||(s=Di(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];vs(s,r.leaf?i(o):o)}return s}function vs(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 r0(r,t){return r.minX-t.minX}function i0(r,t){return r.minY-t.minY}function da(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function cn(r){return r.maxX-r.minX+(r.maxY-r.minY)}function s0(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 n0(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 fa(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function dn(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Di(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Vu(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;Hu(r,o,t,e,s),n.push(t,o,o,e)}}const o0=()=>{const r=new t0,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!nn(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(!nn(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===vt.RECTANGLE||bg(h.selector,o,a));if(l.length>0)return l.sort((h,u)=>Ko(h.selector)-Ko(u.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(nn(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)}}},Xu=r=>{const t=wy(),e=o0(),i=cy(t,r.userSelectAction,r.adapter),s=uy(t),n=Ry();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},a0=r=>{const t=Xu(r);return{...t,store:Ay(t.store)}},l0=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},zu=r=>{const t=l0(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Wu=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?zu(r):e),Yu=(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}),ju=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,qu=(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=()=>{ju?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return ju?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},h0=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Yu(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:nu.EDIT,theme:"light"}),s=a0(i),{selection:n,store:o}=s,a=Iy(o,i.initialHistory),l=My(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=qu(a);let c=Gy();Wu(e,h,i.theme);const d=new Q_({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",C=>{const{originalEvent:E,annotation:I}=C.detail;I?n.userSelect(I.id,E):n.isEmpty()||n.clear()});const p=Oy(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,E,I)=>Iu(C,E,I),x=(C,E)=>Tu(C,E),b=C=>{if(!un(C))throw`No drawing tool named ${C}`;d.$set({toolName:C})},S=C=>d.$set({drawingEnabled:C}),w=C=>{console.warn("Filter not implemented yet")},T=C=>d.$set({style:C}),N=C=>Wu(e,h,C),F=C=>{c=C,d.$set({user:C})},z=C=>d.$set({visible:C});return{...p,cancelDrawing:f,destroy:m,getDrawingTool:y,getUser:_,isDrawingEnabled:v,listDrawingTools:hn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:S,setDrawingTool:b,setFilter:w,setStyle:T,setTheme:N,setUser:F,setVisible:z,element:h,state:s}};function me(){}function pa(r,t){for(const e in t)r[e]=t[e];return r}function Ku(r){return r()}function Zu(){return Object.create(null)}function er(r){r.forEach(Ku)}function Kt(r){return typeof r=="function"}function Wt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function u0(r){return Object.keys(r).length===0}function c0(r,...t){if(r==null){for(const i of t)i(void 0);return me}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function fn(r,t,e){r.$$.on_destroy.push(c0(t,e))}function Qu(r,t,e,i){if(r){const s=Ju(r,t,e,i);return r[0](s)}}function Ju(r,t,e,i){return r[1]&&i?pa(e.ctx.slice(),r[1](i(t))):e.ctx}function tc(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 ec(r,t,e,i,s,n){if(s){const o=Ju(t,e,i,n);r.p(o,s)}}function rc(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 ic(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function pn(r){return r??""}const sc=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ae(r,t){r.appendChild(t)}function ct(r,t,e){r.insertBefore(t,e||null)}function ht(r){r.parentNode&&r.parentNode.removeChild(r)}function ii(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function xt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ma(r){return document.createTextNode(r)}function Ve(){return ma(" ")}function Re(){return ma("")}function Zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function R(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function d0(r){return Array.from(r.childNodes)}function f0(r,t){t=""+t,r.data!==t&&(r.data=t)}function mn(r,t,e){r.classList.toggle(t,!!e)}function p0(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let xs;function bs(r){xs=r}function ga(){if(!xs)throw new Error("Function called outside component initialization");return xs}function gn(r){ga().$$.on_mount.push(r)}function m0(r){ga().$$.on_destroy.push(r)}function yn(){const r=ga();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=p0(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 Li=[],_n=[];let Bi=[];const nc=[],g0=Promise.resolve();let ya=!1;function y0(){ya||(ya=!0,g0.then(oc))}function _a(r){Bi.push(r)}const va=new Set;let Fi=0;function oc(){if(Fi!==0)return;const r=xs;do{try{for(;Fi<Li.length;){const t=Li[Fi];Fi++,bs(t),_0(t.$$)}}catch(t){throw Li.length=0,Fi=0,t}for(bs(null),Li.length=0,Fi=0;_n.length;)_n.pop()();for(let t=0;t<Bi.length;t+=1){const e=Bi[t];va.has(e)||(va.add(e),e())}Bi.length=0}while(Li.length);for(;nc.length;)nc.pop()();ya=!1,va.clear(),bs(r)}function _0(r){if(r.fragment!==null){r.update(),er(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(_a)}}function v0(r){const t=[],e=[];Bi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Bi=t}const vn=new Set;let si;function ge(){si={r:0,c:[],p:si}}function ye(){si.r||er(si.c),si=si.p}function q(r,t){r&&r.i&&(vn.delete(r),r.i(t))}function et(r,t,e,i){if(r&&r.o){if(vn.has(r))return;vn.add(r),si.c.push(()=>{vn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Se(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),_a(()=>{const n=r.$$.on_mount.map(Ku).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):er(n),r.$$.on_mount=[]}),s.forEach(_a)}function Ut(r,t){const e=r.$$;e.fragment!==null&&(v0(e.after_update),er(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function x0(r,t){r.$$.dirty[0]===-1&&(Li.push(r),y0(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ee(r,t,e,i,s,n,o=null,a=[-1]){const l=xs;bs(r);const h=r.$$={fragment:null,ctx:[],props:n,update:me,not_equal:s,bound:Zu(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Zu(),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&&x0(r,c)),d}):[],h.update(),u=!0,er(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=d0(t.target);h.fragment&&h.fragment.l(c),c.forEach(ht)}else h.fragment&&h.fragment.c();t.intro&&q(r.$$.fragment),Ft(r,t.target,t.anchor),oc()}bs(l)}class re{constructor(){Pt(this,"$$");Pt(this,"$$set")}$destroy(){Ut(this,1),this.$destroy=me}$on(t,e){if(!Kt(e))return me;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&&!u0(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const b0="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(b0);var ni=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(ni||{}),ac=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(ac||{}),xa=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(xa||{}),at=(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))(at||{}),rr=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(rr||{}),H=(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))(H||{}),Ui=(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))(Ui||{}),tt=(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))(tt||{}),Y=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(Y||{}),vr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(vr||{}),Dr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Dr||{}),ir=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(ir||{}),Ce=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(Ce||{}),sr=(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))(sr||{}),ba=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(ba||{}),Le=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Le||{}),Qt=(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))(Qt||{}),Yt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Yt||{}),nr=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(nr||{});const j={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 Ea=/iPhone/i,lc=/iPod/i,hc=/iPad/i,uc=/\biOS-universal(?:.+)Mac\b/i,Ta=/\bAndroid(?:.+)Mobile\b/i,cc=/Android/i,ki=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,xn=/Silk/i,xr=/Windows Phone/i,dc=/\bWindows(?:.+)ARM\b/i,fc=/BlackBerry/i,pc=/BB10/i,mc=/Opera Mini/i,gc=/\b(CriOS|Chrome)(?:.+)Mobile/i,yc=/Mobile(?:.+)Firefox\b/i,_c=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function E0(r){return function(t){return t.test(r)}}function vc(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=E0(e),n={apple:{phone:s(Ea)&&!s(xr),ipod:s(lc),tablet:!s(Ea)&&(s(hc)||_c(t))&&!s(xr),universal:s(uc),device:(s(Ea)||s(lc)||s(hc)||s(uc)||_c(t))&&!s(xr)},amazon:{phone:s(ki),tablet:!s(ki)&&s(xn),device:s(ki)||s(xn)},android:{phone:!s(xr)&&s(ki)||!s(xr)&&s(Ta),tablet:!s(xr)&&!s(ki)&&!s(Ta)&&(s(xn)||s(cc)),device:!s(xr)&&(s(ki)||s(xn)||s(Ta)||s(cc))||s(/\bokhttp\b/i)},windows:{phone:s(xr),tablet:s(dc),device:s(xr)||s(dc)},other:{blackberry:s(fc),blackberry10:s(pc),opera:s(mc),firefox:s(yc),chrome:s(gc),device:s(fc)||s(pc)||s(mc)||s(yc)||s(gc)},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 T0=vc.default??vc,br=T0(globalThis.navigator);j.RETINA_PREFIX=/@([0-9\.]+)x/,j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Es=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function w0(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 bc={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,b;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(b=1,v=new Array(_-1);b<_;b++)v[b-1]=arguments[b];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})(bc);var A0=bc.exports;const Ts=xc(A0);var wa={exports:{}};wa.exports=bn,wa.exports.default=bn;function bn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Ec(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=M0(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 ws(n,o,e,a,l,p,0),o}function Ec(r,t,e,i,s){var n,o;if(s===Ca(r,t,e,i)>0)for(n=t;n<e;n+=i)o=Ac(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=Ac(n,r[n],r[n+1],o);return o&&En(o,o.next)&&(Ss(o),o=o.next),o}function oi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(En(e,e.next)||Nt(e.prev,e,e.next)===0)){if(Ss(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ws(r,t,e,i,s,n,o){if(r){!o&&n&&L0(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?C0(r,i,s,n):S0(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Ss(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=I0(oi(r),t,e),ws(r,t,e,i,s,n,2)):o===2&&R0(r,t,e,i,s,n):ws(oi(r),t,e,i,s,n,1);break}}}}function S0(r){var t=r.prev,e=r,i=r.next;if(Nt(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&&Gi(s,a,n,l,o,h,f.x,f.y)&&Nt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function C0(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Nt(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,_=Aa(p,f,t,e,i),v=Aa(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&&Gi(a,u,l,c,h,d,g.x,g.y)&&Nt(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&&Gi(a,u,l,c,h,d,x.x,x.y)&&Nt(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&&Gi(a,u,l,c,h,d,g.x,g.y)&&Nt(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&&Gi(a,u,l,c,h,d,x.x,x.y)&&Nt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function I0(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!En(s,n)&&Tc(s,i,i.next,n)&&As(s,n)&&As(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Ss(i),Ss(i.next),i=r=n),i=i.next}while(i!==r);return oi(i)}function R0(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&U0(o,a)){var l=wc(o,a);o=oi(o,o.next),l=oi(l,l.next),ws(o,t,e,i,s,n,0),ws(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function M0(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=Ec(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(F0(h));for(s.sort(P0),n=0;n<s.length;n++)e=O0(s[n],e);return e}function P0(r,t){return r.x-t.x}function O0(r,t){var e=N0(r,t);if(!e)return t;var i=wc(e,r);return oi(i,i.next),oi(e,e.next)}function N0(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&&Gi(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),As(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&D0(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function D0(r,t){return Nt(r.prev,r,t.prev)<0&&Nt(t.next,r,r.next)<0}function L0(r,t,e,i){var s=r;do s.z===0&&(s.z=Aa(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,B0(s)}function B0(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 Aa(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 F0(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 Gi(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 U0(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!k0(r,t)&&(As(r,t)&&As(t,r)&&G0(r,t)&&(Nt(r.prev,r,t.prev)||Nt(r,t.prev,t))||En(r,t)&&Nt(r.prev,r,r.next)>0&&Nt(t.prev,t,t.next)>0)}function Nt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function En(r,t){return r.x===t.x&&r.y===t.y}function Tc(r,t,e,i){var s=wn(Nt(r,t,e)),n=wn(Nt(r,t,i)),o=wn(Nt(e,i,r)),a=wn(Nt(e,i,t));return!!(s!==n&&o!==a||s===0&&Tn(r,e,t)||n===0&&Tn(r,i,t)||o===0&&Tn(e,r,i)||a===0&&Tn(e,t,i))}function Tn(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 wn(r){return r>0?1:r<0?-1:0}function k0(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Tc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function As(r,t){return Nt(r.prev,r,r.next)<0?Nt(r,t,r.next)>=0&&Nt(r,r.prev,t)>=0:Nt(r,t,r.prev)<0||Nt(r,r.next,t)<0}function G0(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 wc(r,t){var e=new Sa(r.i,r.x,r.y),i=new Sa(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 Ac(r,t,e,i){var s=new Sa(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 Ss(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 Sa(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}bn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Ca(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(Ca(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 Ca(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}bn.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 $0=wa.exports;const H0=xc($0);var An={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */An.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Es=="object"&&Es;(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,b=Math.floor,S=String.fromCharCode,w;function T(M){throw new RangeError(g[M])}function N(M,L){for(var V=M.length,rt=[];V--;)rt[V]=L(M[V]);return rt}function F(M,L){var V=M.split("@"),rt="";V.length>1&&(rt=V[0]+"@",M=V[1]),M=M.replace(v,".");var Q=M.split("."),X=N(Q,L).join(".");return rt+X}function z(M){for(var L=[],V=0,rt=M.length,Q,X;V<rt;)Q=M.charCodeAt(V++),Q>=55296&&Q<=56319&&V<rt?(X=M.charCodeAt(V++),(X&64512)==56320?L.push(((Q&1023)<<10)+(X&1023)+65536):(L.push(Q),V--)):L.push(Q);return L}function C(M){return N(M,function(L){var V="";return L>65535&&(L-=65536,V+=S(L>>>10&1023|55296),L=56320|L&1023),V+=S(L),V}).join("")}function E(M){return M-48<10?M-22:M-65<26?M-65:M-97<26?M-97:l}function I(M,L){return M+22+75*(M<26)-((L!=0)<<5)}function P(M,L,V){var rt=0;for(M=V?b(M/d):M>>1,M+=b(M/L);M>x*u>>1;rt+=l)M=b(M/x);return b(rt+(x+1)*M/(M+c))}function $(M){var L=[],V=M.length,rt,Q=0,X=f,_t=p,St,O,D,ut,lt,Et,Tt,mr,gr;for(St=M.lastIndexOf(m),St<0&&(St=0),O=0;O<St;++O)M.charCodeAt(O)>=128&&T("not-basic"),L.push(M.charCodeAt(O));for(D=St>0?St+1:0;D<V;){for(ut=Q,lt=1,Et=l;D>=V&&T("invalid-input"),Tt=E(M.charCodeAt(D++)),(Tt>=l||Tt>b((a-Q)/lt))&&T("overflow"),Q+=Tt*lt,mr=Et<=_t?h:Et>=_t+u?u:Et-_t,!(Tt<mr);Et+=l)gr=l-mr,lt>b(a/gr)&&T("overflow"),lt*=gr;rt=L.length+1,_t=P(Q-ut,rt,ut==0),b(Q/rt)>a-X&&T("overflow"),X+=b(Q/rt),Q%=rt,L.splice(Q++,0,X)}return C(L)}function k(M){var L,V,rt,Q,X,_t,St,O,D,ut,lt,Et=[],Tt,mr,gr,js;for(M=z(M),Tt=M.length,L=f,V=0,X=p,_t=0;_t<Tt;++_t)lt=M[_t],lt<128&&Et.push(S(lt));for(rt=Q=Et.length,Q&&Et.push(m);rt<Tt;){for(St=a,_t=0;_t<Tt;++_t)lt=M[_t],lt>=L&<<St&&(St=lt);for(mr=rt+1,St-L>b((a-V)/mr)&&T("overflow"),V+=(St-L)*mr,L=St,_t=0;_t<Tt;++_t)if(lt=M[_t],lt<L&&++V>a&&T("overflow"),lt==L){for(O=V,D=l;ut=D<=X?h:D>=X+u?u:D-X,!(O<ut);D+=l)js=O-ut,gr=l-ut,Et.push(S(I(ut+js%gr,0))),O=b(js/gr);Et.push(S(I(O,0))),X=P(V,mr,rt==Q),V=0,++rt}++V,++L}return Et.join("")}function G(M){return F(M,function(L){return y.test(L)?$(L.slice(4).toLowerCase()):L})}function st(M){return F(M,function(L){return _.test(L)?"xn--"+k(L):L})}if(o={version:"1.4.1",ucs2:{decode:z,encode:C},decode:$,encode:k,toASCII:st,toUnicode:G},i&&s)if(r.exports==i)s.exports=o;else for(w in o)o.hasOwnProperty(w)&&(i[w]=o[w]);else e.punycode=o})(Es)}(An,An.exports);var V0=An.exports,$i=TypeError;const X0=w0(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ia=typeof Map=="function"&&Map.prototype,Ra=Object.getOwnPropertyDescriptor&&Ia?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Sn=Ia&&Ra&&typeof Ra.get=="function"?Ra.get:null,Sc=Ia&&Map.prototype.forEach,Ma=typeof Set=="function"&&Set.prototype,Pa=Object.getOwnPropertyDescriptor&&Ma?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Cn=Ma&&Pa&&typeof Pa.get=="function"?Pa.get:null,Cc=Ma&&Set.prototype.forEach,z0=typeof WeakMap=="function"&&WeakMap.prototype,Cs=z0?WeakMap.prototype.has:null,W0=typeof WeakSet=="function"&&WeakSet.prototype,Is=W0?WeakSet.prototype.has:null,Y0=typeof WeakRef=="function"&&WeakRef.prototype,Ic=Y0?WeakRef.prototype.deref:null,j0=Boolean.prototype.valueOf,q0=Object.prototype.toString,K0=Function.prototype.toString,Z0=String.prototype.match,Oa=String.prototype.slice,Lr=String.prototype.replace,Q0=String.prototype.toUpperCase,Rc=String.prototype.toLowerCase,Mc=RegExp.prototype.test,Pc=Array.prototype.concat,or=Array.prototype.join,J0=Array.prototype.slice,Oc=Math.floor,Na=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Da=Object.getOwnPropertySymbols,La=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Hi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Rs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Hi||!0)?Symbol.toStringTag:null,Nc=Object.prototype.propertyIsEnumerable,Dc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Lc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Mc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Oc(-r):Oc(r);if(i!==r){var s=String(i),n=Oa.call(t,s.length+1);return Lr.call(s,e,"$&_")+"."+Lr.call(Lr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Lr.call(t,e,"$&_")}var Ba=X0,Bc=Ba.custom,Fc=$c(Bc)?Bc:null,Uc={__proto__:null,double:'"',single:"'"},tv={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},In=function r(t,e,i,s){var n=e||{};if(Er(n,"quoteStyle")&&!Er(Uc,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Er(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=Er(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(Er(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(Er(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 Vc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Lc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Lc(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 Fa(t)?"[Array]":"[Object]";var c=_v(n,i);if(typeof s>"u")s=[];else if(Hc(s,t)>=0)return"[Circular]";function d(E,I,P){if(I&&(s=J0.call(s),s.push(I)),P){var $={depth:n.depth};return Er(n,"quoteStyle")&&($.quoteStyle=n.quoteStyle),r(E,$,i+1,s)}return r(E,n,i+1,s)}if(typeof t=="function"&&!Gc(t)){var p=hv(t),f=Rn(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+or.call(f,", ")+" }":"")}if($c(t)){var m=Hi?Lr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):La.call(t);return typeof t=="object"&&!Hi?Ms(m):m}if(mv(t)){for(var y="<"+Rc.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)y+=" "+_[v].name+"="+kc(ev(_[v].value),"double",n);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+Rc.call(String(t.nodeName))+">",y}if(Fa(t)){if(t.length===0)return"[]";var g=Rn(t,d);return c&&!yv(g)?"["+ka(g,c)+"]":"[ "+or.call(g,", ")+" ]"}if(iv(t)){var x=Rn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Nc.call(t,"cause")?"{ ["+String(t)+"] "+or.call(Pc.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+or.call(x,", ")+" }"}if(typeof t=="object"&&o){if(Fc&&typeof t[Fc]=="function"&&Ba)return Ba(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(uv(t)){var b=[];return Sc&&Sc.call(t,function(E,I){b.push(d(I,t,!0)+" => "+d(E,t))}),Xc("Map",Sn.call(t),b,c)}if(fv(t)){var S=[];return Cc&&Cc.call(t,function(E){S.push(d(E,t))}),Xc("Set",Cn.call(t),S,c)}if(cv(t))return Ua("WeakMap");if(pv(t))return Ua("WeakSet");if(dv(t))return Ua("WeakRef");if(nv(t))return Ms(d(Number(t)));if(av(t))return Ms(d(Na.call(t)));if(ov(t))return Ms(j0.call(t));if(sv(t))return Ms(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Es<"u"&&t===Es)return"{ [object globalThis] }";if(!rv(t)&&!Gc(t)){var w=Rn(t,d),T=Dc?Dc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",F=!T&&Rs&&Object(t)===t&&Rs in t?Oa.call(Br(t),8,-1):N?"Object":"",z=T||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",C=z+(F||N?"["+or.call(Pc.call([],F||[],N||[]),": ")+"] ":"");return w.length===0?C+"{}":c?C+"{"+ka(w,c)+"}":C+"{ "+or.call(w,", ")+" }"}return String(t)};function kc(r,t,e){var i=e.quoteStyle||t,s=Uc[i];return s+r+s}function ev(r){return Lr.call(String(r),/"/g,""")}function ai(r){return!Rs||!(typeof r=="object"&&(Rs in r||typeof r[Rs]<"u"))}function Fa(r){return Br(r)==="[object Array]"&&ai(r)}function rv(r){return Br(r)==="[object Date]"&&ai(r)}function Gc(r){return Br(r)==="[object RegExp]"&&ai(r)}function iv(r){return Br(r)==="[object Error]"&&ai(r)}function sv(r){return Br(r)==="[object String]"&&ai(r)}function nv(r){return Br(r)==="[object Number]"&&ai(r)}function ov(r){return Br(r)==="[object Boolean]"&&ai(r)}function $c(r){if(Hi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!La)return!1;try{return La.call(r),!0}catch{}return!1}function av(r){if(!r||typeof r!="object"||!Na)return!1;try{return Na.call(r),!0}catch{}return!1}var lv=Object.prototype.hasOwnProperty||function(r){return r in this};function Er(r,t){return lv.call(r,t)}function Br(r){return q0.call(r)}function hv(r){if(r.name)return r.name;var t=Z0.call(K0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Hc(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 uv(r){if(!Sn||!r||typeof r!="object")return!1;try{Sn.call(r);try{Cn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function cv(r){if(!Cs||!r||typeof r!="object")return!1;try{Cs.call(r,Cs);try{Is.call(r,Is)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function dv(r){if(!Ic||!r||typeof r!="object")return!1;try{return Ic.call(r),!0}catch{}return!1}function fv(r){if(!Cn||!r||typeof r!="object")return!1;try{Cn.call(r);try{Sn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function pv(r){if(!Is||!r||typeof r!="object")return!1;try{Is.call(r,Is);try{Cs.call(r,Cs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function mv(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Vc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Vc(Oa.call(r,0,t.maxStringLength),t)+i}var s=tv[t.quoteStyle||"single"];s.lastIndex=0;var n=Lr.call(Lr.call(r,s,"\\$1"),/[\x00-\x1f]/g,gv);return kc(n,"single",t)}function gv(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":"")+Q0.call(t.toString(16))}function Ms(r){return"Object("+r+")"}function Ua(r){return r+" { ? }"}function Xc(r,t,e,i){var s=i?ka(e,i):or.call(e,", ");return r+" ("+t+") {"+s+"}"}function yv(r){for(var t=0;t<r.length;t++)if(Hc(r[t],`
|
|
3
|
-
`)>=0)return!1;return!0}function
|
|
1
|
+
(function(Gt,de){typeof exports=="object"&&typeof module<"u"?de(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],de):(Gt=typeof globalThis<"u"?globalThis:Gt||self,de(Gt.AnnotoriousOSD={},Gt.OpenSeadragon))})(this,function(Gt,de){"use strict";var CC=Object.defineProperty;var IC=(Gt,de,Zr)=>de in Gt?CC(Gt,de,{enumerable:!0,configurable:!0,writable:!0,value:Zr}):Gt[de]=Zr;var Pt=(Gt,de,Zr)=>IC(Gt,typeof de!="symbol"?de+"":de,Zr);var Zr=Object.prototype.hasOwnProperty;function Qr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Qr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Zr.call(r,e)&&++i&&!Zr.call(t,e)||!(e in t)||!Qr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var $o=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))($o||{});const oe=[];for(let r=0;r<256;++r)oe.push((r+256).toString(16).slice(1));function Om(r,t=0){return(oe[r[t+0]]+oe[r[t+1]]+oe[r[t+2]]+oe[r[t+3]]+"-"+oe[r[t+4]]+oe[r[t+5]]+"-"+oe[r[t+6]]+oe[r[t+7]]+"-"+oe[r[t+8]]+oe[r[t+9]]+"-"+oe[r[t+10]]+oe[r[t+11]]+oe[r[t+12]]+oe[r[t+13]]+oe[r[t+14]]+oe[r[t+15]]).toLowerCase()}let Ho;const Nm=new Uint8Array(16);function Dm(){if(!Ho){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ho=crypto.getRandomValues.bind(crypto)}return Ho(Nm)}const Lm=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ph={randomUUID:Lm};function Bm(r,t,e){var i;if(Ph.randomUUID&&!r)return Ph.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??Dm();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Om(s)}const Vo=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)}},Fm=(r,t,e,i)=>({id:Bm(),annotation:typeof r=="string"?r:r.id,created:e||new Date,creator:i,...t}),Um=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},km=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Gm=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Qr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),$m=(r,t)=>!Qr(r.target,t.target),Hm=(r,t)=>{const e=Um(r,t),i=km(r,t),s=Gm(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:$m(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Rr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(Rr||{});const Vm=(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 Hm(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}};let Xm=()=>({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 zm=250,Wm=(r,t)=>{const e=Xm(),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>zm)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=Vm(i[_],m)}o=y}n=!1};r.observe(a,{origin:Rr.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}}}},Ym=(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 b=Array.isArray(v)?v.map(w=>e.serialize(w)):e.serialize(v),S=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(b,S)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(b=>b.id===g.id);(!x||!Qr(x,g))&&f("updateAnnotation",g,x)}),h=h.map(g=>v.find(({id:b})=>b===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&&!Qr(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 b=o.getAnnotation(x.id);b&&!Qr(b,x)&&f("updateAnnotation",b,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:b})=>{const S=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,S)})},{origin:Rr.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(S=>S.id===x.id)||x))}},{origin:Rr.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}},jm=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:[]}),qm=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,Rr.REMOTE):console.error(g)}else i.addAnnotation(Vo(_),Rr.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||jm(e),{parsed:x,failed:b}=g(_);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotations(x,v,Rr.REMOTE)}else i.bulkAddAnnotations(_.map(Vo),v,Rr.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(Vo(_)),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}},Km="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Zm=r=>crypto.getRandomValues(new Uint8Array(r)),Qm=(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}}},Jm=(r,t=21)=>Qm(r,t|0,Zm),tg=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Km[e[r]&63];return t};const eg=()=>({isGuest:!0,id:Jm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),rg=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],ig=()=>{const r=[...rg];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};tg();var sg=Object.defineProperty,ng=(r,t,e)=>t in r?sg(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ot=(r,t,e)=>ng(r,typeof t!="symbol"?t+"":t,e);function Ct(){}function Xo(r,t){for(const e in t)r[e]=t[e];return r}function Oh(r){return r()}function Nh(){return Object.create(null)}function Ue(r){r.forEach(Oh)}function $t(r){return typeof r=="function"}function te(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function og(r){return Object.keys(r).length===0}function Dh(r,...t){if(r==null){for(const i of t)i(void 0);return Ct}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function zo(r,t,e){r.$$.on_destroy.push(Dh(t,e))}function ag(r,t,e,i){if(r){const s=Lh(r,t,e,i);return r[0](s)}}function Lh(r,t,e,i){return r[1]&&i?Xo(e.ctx.slice(),r[1](i(t))):e.ctx}function lg(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 hg(r,t,e,i,s,n){if(s){const o=Lh(t,e,i,n);r.p(o,s)}}function ug(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 Bh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function tn(r){return r??""}function Oe(r,t){r.appendChild(t)}function ot(r,t,e){r.insertBefore(t,e||null)}function nt(r){r.parentNode&&r.parentNode.removeChild(r)}function Jr(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function mt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Fh(r){return document.createTextNode(r)}function ke(){return Fh(" ")}function Ie(){return Fh("")}function Bt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function A(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function cg(r){return Array.from(r.childNodes)}function Mr(r,t,e){r.classList.toggle(t,!!e)}function dg(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let fs;function ps(r){fs=r}function Uh(){if(!fs)throw new Error("Function called outside component initialization");return fs}function ms(r){Uh().$$.on_mount.push(r)}function Si(){const r=Uh();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=dg(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ne(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Ci=[],en=[];let Ii=[];const kh=[],fg=Promise.resolve();let Wo=!1;function pg(){Wo||(Wo=!0,fg.then(Gh))}function Yo(r){Ii.push(r)}const jo=new Set;let Ri=0;function Gh(){if(Ri!==0)return;const r=fs;do{try{for(;Ri<Ci.length;){const t=Ci[Ri];Ri++,ps(t),mg(t.$$)}}catch(t){throw Ci.length=0,Ri=0,t}for(ps(null),Ci.length=0,Ri=0;en.length;)en.pop()();for(let t=0;t<Ii.length;t+=1){const e=Ii[t];jo.has(e)||(jo.add(e),e())}Ii.length=0}while(Ci.length);for(;kh.length;)kh.pop()();Wo=!1,jo.clear(),ps(r)}function mg(r){if(r.fragment!==null){r.update(),Ue(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Yo)}}function gg(r){const t=[],e=[];Ii.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Ii=t}const rn=new Set;let ti;function xe(){ti={r:0,c:[],p:ti}}function be(){ti.r||Ue(ti.c),ti=ti.p}function it(r,t){r&&r.i&&(rn.delete(r),r.i(t))}function dt(r,t,e,i){if(r&&r.o){if(rn.has(r))return;rn.add(r),ti.c.push(()=>{rn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Ee(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function _e(r){r&&r.c()}function fe(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Yo(()=>{const n=r.$$.on_mount.map(Oh).filter($t);r.$$.on_destroy?r.$$.on_destroy.push(...n):Ue(n),r.$$.on_mount=[]}),s.forEach(Yo)}function pe(r,t){const e=r.$$;e.fragment!==null&&(gg(e.after_update),Ue(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function yg(r,t){r.$$.dirty[0]===-1&&(Ci.push(r),pg(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function Te(r,t,e,i,s,n,o=null,a=[-1]){const l=fs;ps(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Ct,not_equal:s,bound:Nh(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Nh(),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&&yg(r,c)),d}):[],h.update(),u=!0,Ue(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=cg(t.target);h.fragment&&h.fragment.l(c),c.forEach(nt)}else h.fragment&&h.fragment.c();t.intro&&it(r.$$.fragment),fe(r,t.target,t.anchor),Gh()}ps(l)}class we{constructor(){Ot(this,"$$"),Ot(this,"$$set")}$destroy(){pe(this,1),this.$destroy=Ct}$on(t,e){if(!$t(e))return Ct;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&&!og(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const _g="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(_g);var vt=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(vt||{});const qo={},sn=(r,t)=>qo[r]=t,Ko=r=>qo[r.type].area(r),vg=(r,t,e)=>qo[r.type].intersects(r,t,e),_r=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}},Zo=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)},Qo=(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},xg=(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},bg={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}};sn(vt.ELLIPSE,bg);const Eg={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=Zo(s.points),a=n.reduce((l,h)=>l+Zo(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(Qo(n.points,t,e)){let a=!1;for(const l of o)if(Qo(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},Tg=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return _r(t)},ei=r=>r.rings.map(t=>xg(t.points)).join(" ");sn(vt.MULTIPOLYGLON,Eg);const wg={area:r=>{const t=r.geometry.points;return Zo(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return Qo(i,t,e)}};sn(vt.POLYGON,wg);const Ag={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};sn(vt.RECTANGLE,Ag);const Ge=r=>nn(r.target),nn=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},Sg=(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:vt.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}}}},Cg=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}`}},$h="http://www.w3.org/2000/svg",Hh=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Ig=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${$h}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Vh=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix($h),i=t.lookupNamespaceURI(null);return e||i?Hh(t).firstChild:Hh(Ig(t)).firstChild},Xt=" ";function Rg(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===B.CLOSE_PATH)t+="z";else if(i.type===B.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===B.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===B.MOVE_TO)t+=(i.relative?"m":"M")+i.x+Xt+i.y;else if(i.type===B.LINE_TO)t+=(i.relative?"l":"L")+i.x+Xt+i.y;else if(i.type===B.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+Xt+i.y1+Xt+i.x2+Xt+i.y2+Xt+i.x+Xt+i.y;else if(i.type===B.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+Xt+i.y2+Xt+i.x+Xt+i.y;else if(i.type===B.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+Xt+i.y1+Xt+i.x+Xt+i.y;else if(i.type===B.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+Xt+i.y;else if(i.type===B.ARC)t+=(i.relative?"a":"A")+i.rX+Xt+i.rY+Xt+i.xRot+Xt+ +i.lArcFlag+Xt+ +i.sweepFlag+Xt+i.x+Xt+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function Jo([r,t],e){return[r*Math.cos(e)-t*Math.sin(e),r*Math.sin(e)+t*Math.cos(e)]}function $e(...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 Pr=Math.PI;function ta(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*Pr,[l,h]=Jo([(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=Jo([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*Pr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*Pr),r.phi1*=180/Pr,r.phi2*=180/Pr}function Xh(r,t,e){$e(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 ri=Math.PI/180;function zh(r,t,e){return(1-e)*r+e*t}function Wh(r,t,e,i){return r+Math.cos(i/180*Pr)*t+Math.sin(i/180*Pr)*e}function Yh(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]:Mg(l/a,h/a,1e-6)}function jh(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 Mg(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 Pg(r,t,e){r.cX||ta(r,t,e);const i=r.xRot/180*Pr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:B.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]=Jo([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=zh(r.phi1,r.phi2,d/a),f=zh(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*ri/4),_=Math.cos(p*ri)-y*Math.sin(p*ri),v=Math.sin(p*ri)+y*Math.cos(p*ri),g=Math.cos(f*ri),x=Math.sin(f*ri),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:B.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function ea(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 Og(r,t=!0){if(r.length<2)return r;const e=zt.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===B.MOVE_TO&&s.length>0&&(t?i.push(...on(s)):i.unshift(...on(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...on(s)):i.unshift(...on(s))),i}function on(r){var t;const e=((t=r[r.length-1])==null?void 0:t.type)===B.CLOSE_PATH,i=e?r.length-2:r.length-1,s=[{type:B.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 B.HORIZ_LINE_TO:s.push({type:B.HORIZ_LINE_TO,relative:!1,x:a.x});break;case B.VERT_LINE_TO:s.push({type:B.VERT_LINE_TO,relative:!1,y:a.y});break;case B.LINE_TO:case B.MOVE_TO:s.push({type:B.LINE_TO,relative:!1,x:a.x,y:a.y});break;case B.CURVE_TO:s.push({type:B.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case B.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case B.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case B.ARC:throw new Error("Unsupported command: A (arc)");case B.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return e&&s.push({type:B.CLOSE_PATH}),s}function Ng(r=1e13){$e(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 qh(){return He((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 Dg(){return He((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 Lg(r=!0,t=!0,e=!0,i=!0){return He((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&B.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&B.HORIZ_LINE_TO&&(s.type=B.LINE_TO,s.y=s.relative?0:o),e&&s.type&B.VERT_LINE_TO&&(s.type=B.LINE_TO,s.x=s.relative?0:n),r&&s.type&B.CLOSE_PATH&&(s.type=B.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&B.ARC&&(s.rX===0||s.rY===0)&&(s.type=B.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&B.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];ea(h,u,c)&&(s.type=B.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&B.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];ea(h,u,d)&&ea(h,c,d)&&(s.type=B.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Kh(){let r=NaN,t=NaN,e=NaN,i=NaN;return He((s,n,o)=>(s.type&B.SMOOTH_CURVE_TO&&(s.type=B.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&B.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&B.SMOOTH_QUAD_TO&&(s.type=B.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&B.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Zh(){let r=NaN,t=NaN;return He((e,i,s)=>{if(e.type&B.SMOOTH_QUAD_TO&&(e.type=B.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&B.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=B.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 He(r){let t=0,e=0,i=NaN,s=NaN;return function(n){if(isNaN(i)&&!(n.type&B.MOVE_TO))throw new Error("path must start with moveto");const o=r(n,t,e,i,s);return n.type&B.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&B.MOVE_TO&&(i=t,s=e),o}}function Bg(r=0){$e(r);let t=NaN,e=NaN,i=NaN,s=NaN;return He((n,o,a,l,h)=>{const u=Math.abs;let c=!1,d=0,p=0;if(n.type&B.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(B.CURVE_TO|B.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&B.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&B.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&B.LINE_COMMANDS||n.type&B.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&B.CURVE_TO||n.type&B.SMOOTH_CURVE_TO||n.type&B.QUAD_TO||n.type&B.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&B.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Or(r,t,e,i,s,n){return $e(r,t,e,i,s,n),He((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&B.HORIZ_LINE_TO&&t!==0&&(o.type=B.LINE_TO,o.y=o.relative?0:l),o.type&B.VERT_LINE_TO&&e!==0&&(o.type=B.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=B.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function Fg(r,t=0,e=0){$e(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Or(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function Ug(r,t=0){return $e(r,t),Or(1,0,0,1,r,t)}function kg(r,t=r){return $e(r,t),Or(r,0,0,t,0,0)}function Gg(r){return $e(r),Or(1,0,Math.tan(r),1,0,0)}function $g(r){return $e(r),Or(1,Math.tan(r),0,1,0,0)}function Hg(r=0){return $e(r),Or(-1,0,0,1,r,0)}function Vg(r=0){return $e(r),Or(1,0,0,-1,0,r)}function Xg(){return He((r,t,e)=>B.ARC===r.type?Pg(r,r.relative?0:t,r.relative?0:e):r)}function zg(){return He((r,t,e)=>(r.relative&&(t=0,e=0),B.ARC===r.type&&ta(r,t,e),r))}function Qh(){return r=>({...r})}function Wg(){const r=Qh(),t=qh(),e=Zh(),i=Kh(),s=He((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&B.DRAWING_COMMANDS&&(h(o),u(a)),l.type&B.HORIZ_LINE_TO&&h(l.x),l.type&B.VERT_LINE_TO&&u(l.y),l.type&B.LINE_TO&&(h(l.x),u(l.y)),l.type&B.CURVE_TO){h(l.x),u(l.y);const c=Yh(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(jh(o,l.x1,l.x2,l.x,p));const d=Yh(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(jh(a,l.y1,l.y2,l.y,p))}if(l.type&B.ARC){h(l.x),u(l.y),ta(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=([b,S])=>{const w=Math.atan2(S,b)*180/Math.PI;return w<y?w+360:w},g=Xh(f,-d,0).map(v);for(const b of g)b>y&&b<_&&h(Wh(l.cX,d,f,b));const x=Xh(m,-p,0).map(v);for(const b of x)b>y&&b<_&&u(Wh(l.cY,p,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const zt={ROUND:Ng,TO_ABS:qh,TO_REL:Dg,NORMALIZE_HVZ:Lg,NORMALIZE_ST:Kh,QT_TO_C:Zh,INFO:He,SANITIZE:Bg,MATRIX:Or,ROTATE:Fg,TRANSLATE:Ug,SCALE:kg,SKEW_X:Gg,SKEW_Y:$g,X_AXIS_SYMMETRY:Hg,Y_AXIS_SYMMETRY:Vg,A_TO_C:Xg,ANNOTATE_ARCS:zg,CLONE:Qh,CALCULATE_BOUNDS:Wg,REVERSE_PATH:Og};class Jh{round(t){return this.transform(zt.ROUND(t))}toAbs(){return this.transform(zt.TO_ABS())}toRel(){return this.transform(zt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(zt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(zt.NORMALIZE_ST())}qtToC(){return this.transform(zt.QT_TO_C())}aToC(){return this.transform(zt.A_TO_C())}sanitize(t){return this.transform(zt.SANITIZE(t))}translate(t,e){return this.transform(zt.TRANSLATE(t,e))}scale(t,e){return this.transform(zt.SCALE(t,e))}rotate(t,e,i){return this.transform(zt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(zt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(zt.SKEW_X(t))}skewY(t){return this.transform(zt.SKEW_Y(t))}xSymmetry(t){return this.transform(zt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(zt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(zt.ANNOTATE_ARCS())}}const Yg=r=>r===" "||r===" "||r==="\r"||r===`
|
|
2
|
+
`,tu=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class jg extends Jh{constructor(){super(),Ot(this,"curNumber",""),Ot(this,"curCommandType",-1),Ot(this,"curCommandRelative",!1),Ot(this,"canParseCommandOrComma",!0),Ot(this,"curNumberHasExp",!1),Ot(this,"curNumberHasExpDigits",!1),Ot(this,"curNumberHasDecimal",!1),Ot(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===B.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),a=tu(n)&&(this.curNumber==="0"&&n==="0"||o);if(tu(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===B.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===qg[this.curCommandType]&&(B.HORIZ_LINE_TO===this.curCommandType?i({type:B.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):B.VERT_LINE_TO===this.curCommandType?i({type:B.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===B.MOVE_TO||this.curCommandType===B.LINE_TO||this.curCommandType===B.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),B.MOVE_TO===this.curCommandType&&(this.curCommandType=B.LINE_TO)):this.curCommandType===B.CURVE_TO?i({type:B.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===B.SMOOTH_CURVE_TO?i({type:B.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===B.QUAD_TO?i({type:B.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===B.ARC&&i({type:B.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(!Yg(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:B.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(n==="h"||n==="H")this.curCommandType=B.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=B.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=B.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=B.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=B.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=B.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=B.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=B.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else if(n==="a"||n==="A")this.curCommandType=B.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 Mt=class Th extends Jh{constructor(t){super(),Ot(this,"commands"),typeof t=="string"?this.commands=Th.parse(t):this.commands=t}encode(){return Th.encode(this.commands)}getBounds(){const t=zt.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=zt.REVERSE_PATH(this.commands,t),this}static encode(t){return Rg(t)}static parse(t){const e=new jg,i=[];return e.parse(t,i),e.finish(i),i}};Ot(Mt,"CLOSE_PATH",1),Ot(Mt,"MOVE_TO",2),Ot(Mt,"HORIZ_LINE_TO",4),Ot(Mt,"VERT_LINE_TO",8),Ot(Mt,"LINE_TO",16),Ot(Mt,"CURVE_TO",32),Ot(Mt,"SMOOTH_CURVE_TO",64),Ot(Mt,"QUAD_TO",128),Ot(Mt,"SMOOTH_QUAD_TO",256),Ot(Mt,"ARC",512),Ot(Mt,"LINE_COMMANDS",Mt.LINE_TO|Mt.HORIZ_LINE_TO|Mt.VERT_LINE_TO),Ot(Mt,"DRAWING_COMMANDS",Mt.HORIZ_LINE_TO|Mt.VERT_LINE_TO|Mt.LINE_TO|Mt.CURVE_TO|Mt.SMOOTH_CURVE_TO|Mt.QUAD_TO|Mt.SMOOTH_QUAD_TO|Mt.ARC);let B=Mt;const qg={[B.MOVE_TO]:2,[B.LINE_TO]:2,[B.HORIZ_LINE_TO]:1,[B.VERT_LINE_TO]:1,[B.CLOSE_PATH]:0,[B.QUAD_TO]:4,[B.SMOOTH_QUAD_TO]:2,[B.CURVE_TO]:6,[B.SMOOTH_CURVE_TO]:4,[B.ARC]:7},Kg=r=>{const t=new B(r).toAbs().commands,e=[];let i=[],s=null;for(const n of t)switch(n.type){case B.MOVE_TO:i.length>0&&(e.push({points:i}),i=[]),s=[n.x,n.y],i.push(s);break;case B.LINE_TO:i.push([n.x,n.y]);break;case B.HORIZ_LINE_TO:const o=i[i.length-1][1];i.push([n.x,o]);break;case B.VERT_LINE_TO:const a=i[i.length-1][0];i.push([a,n.y]);break;case B.CURVE_TO:case B.SMOOTH_CURVE_TO:case B.QUAD_TO:case B.SMOOTH_QUAD_TO:case B.ARC:i.push([n.x,n.y]);break}if(i.length>2&&e.push({points:i}),e.length>0){const n=_r(e[0].points);return{rings:e,bounds:n}}},Zg=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:vt.POLYGON,geometry:{points:s,bounds:_r(s)}}},Qg=r=>{const t=Vh(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:vt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},Jg=r=>{const t=Vh(r),e=(t.nodeName==="path"?[t]:Array.from(t.querySelectorAll("path"))).map(n=>n.getAttribute("d")||"").map(n=>Kg(n)).filter(Boolean),i=e.reduce((n,o)=>[...n,...o.rings[0].points],[]),s=_r(i);return e.length===1&&e[0].rings.length===1?{type:vt.POLYGON,geometry:{points:i,bounds:s}}:{type:vt.MULTIPOLYGLON,geometry:{polygons:e,bounds:s}}},ty=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Zg(t);if(t.includes("<path "))return Jg(t);if(t.includes("<ellipse "))return Qg(t);throw"Unsupported SVG shape: "+t},ey=r=>`<g>${r.polygons.map(t=>`<path fill-rule="evenodd" d="${ei(t)}" />`).join("")}</g>`,ry=r=>{let t;if(r.type===vt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===vt.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===vt.MULTIPOLYGLON){const e=r.geometry;t=`<svg>${ey(e)}</svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`},ae=[];for(let r=0;r<256;++r)ae.push((r+256).toString(16).slice(1));function iy(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 ra;const sy=new Uint8Array(16);function ny(){if(!ra){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ra=crypto.getRandomValues.bind(crypto)}return ra(sy)}const oy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),eu={randomUUID:oy};function ru(r,t,e){var i;if(eu.randomUUID&&!r)return eu.randomUUID();r=r||{};const s=r.random??((i=r.rng)==null?void 0:i.call(r))??ny();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,iy(s)}var iu=Object.prototype.hasOwnProperty;function Nr(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--&&Nr(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)||!Nr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function ia(){}function ay(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const Mi=[];function sa(r,t=ia){let e;const i=new Set;function s(a){if(ay(r,a)&&(r=a,e)){const l=!Mi.length;for(const h of i)h[1](),Mi.push(h,r);if(l){for(let h=0;h<Mi.length;h+=2)Mi[h][0](Mi[h+1]);Mi.length=0}}}function n(a){s(a(r))}function o(a,l=ia){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||ia),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const ly=r=>{const{subscribe:t,set:e}=sa();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 su=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(su||{});const an={selected:[]},hy=(r,t,e)=>{const{subscribe:i,set:s}=sa(an);let n=t,o=an;i(f=>o=f);const a=()=>{Nr(o,an)||s(an)},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=nu(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?nu(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}},nu=(r,t,e)=>{const i=e?e.serialize(r):r;return typeof t=="function"?t(i):t||"EDIT"},le=[];for(let r=0;r<256;++r)le.push((r+256).toString(16).slice(1));function uy(r,t=0){return(le[r[t+0]]+le[r[t+1]]+le[r[t+2]]+le[r[t+3]]+"-"+le[r[t+4]]+le[r[t+5]]+"-"+le[r[t+6]]+le[r[t+7]]+"-"+le[r[t+8]]+le[r[t+9]]+"-"+le[r[t+10]]+le[r[t+11]]+le[r[t+12]]+le[r[t+13]]+le[r[t+14]]+le[r[t+15]]).toLowerCase()}let na;const cy=new Uint8Array(16);function dy(){if(!na){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");na=crypto.getRandomValues.bind(crypto)}return na(cy)}const fy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ou={randomUUID:fy};function py(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))??dy();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,uy(s)}const oa=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)}},my=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},gy=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},yy=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Nr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),_y=(r,t)=>!Nr(r.target,t.target),au=(r,t)=>{const e=my(r,t),i=gy(r,t),s=yy(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:_y(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var It=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r.SILENT="SILENT",r))(It||{});const vy=(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},xy=(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 au(d,f)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:l,deleted:h,updated:u}},ln=r=>{const t=r.id===void 0?py():r.id;return{...r,id:t,bodies:r.bodies===void 0?[]:r.bodies.map(e=>({...e,annotation:t})),target:{...r.target,annotation:t}}},by=r=>r.id!==void 0,Ey=()=>{const r=new Map,t=new Map,e=[],i=(C,E={})=>{e.push({onChange:C,options:E})},s=C=>{const E=e.findIndex(I=>I.onChange==C);E>-1&&e.splice(E,1)},n=(C,E)=>{const I={origin:C,changes:{created:E.created||[],updated:E.updated||[],deleted:E.deleted||[]},state:[...r.values()]};e.forEach(P=>{vy(P,I)&&P.onChange(I)})},o=(C,E=It.LOCAL)=>{if(C.id&&r.get(C.id))throw Error(`Cannot add annotation ${C.id} - exists already`);{const I=ln(C);r.set(I.id,I),I.bodies.forEach(P=>t.set(P.id,I.id)),n(E,{created:[I]})}},a=(C,E)=>{const I=ln(typeof C=="string"?E:C),P=typeof C=="string"?C:C.id,$=P&&r.get(P);if($){const k=au($,I);return P===I.id?r.set(P,I):(r.delete(P),r.set(I.id,I)),$.bodies.forEach(G=>t.delete(G.id)),I.bodies.forEach(G=>t.set(G.id,I.id)),k}else console.warn(`Cannot update annotation ${P} - does not exist`)},l=(C,E=It.LOCAL,I=It.LOCAL)=>{const P=by(E)?I:E,$=a(C,E);$&&n(P,{updated:[$]})},h=(C,E=It.LOCAL)=>{r.get(C.id)?l(C,E):o(C,E)},u=(C,E=It.LOCAL)=>{const I=C.reduce((P,$)=>{const k=a($);return k?[...P,k]:P},[]);I.length>0&&n(E,{updated:I})},c=(C,E=It.LOCAL)=>{const I=C.map(ln),{toAdd:P,toUpdate:$}=I.reduce((G,st)=>r.get(st.id)?{...G,toUpdate:[...G.toUpdate,st]}:{...G,toAdd:[...G.toAdd,st]},{toAdd:[],toUpdate:[]}),k=$.map(G=>a(G,E)).filter(Boolean);P.forEach(G=>{r.set(G.id,G),G.bodies.forEach(st=>t.set(st.id,G.id))}),n(E,{created:P,updated:k})},d=(C,E=It.LOCAL)=>{const I=r.get(C.annotation);if(I){const P={...I,bodies:[...I.bodies,C]};r.set(I.id,P),t.set(C.id,P.id),n(E,{updated:[{oldValue:I,newValue:P,bodiesCreated:[C]}]})}else console.warn(`Attempt to add body to missing annotation: ${C.annotation}`)},p=()=>[...r.values()],f=(C=It.LOCAL)=>{const E=[...r.values()];r.clear(),t.clear(),n(C,{deleted:E})},m=(C,E=!0,I=It.LOCAL)=>{const P=C.map(ln);if(E){const $=[...r.values()];r.clear(),t.clear(),P.forEach(k=>{r.set(k.id,k),k.bodies.forEach(G=>t.set(G.id,k.id))}),n(I,{created:P,deleted:$})}else{const $=C.reduce((k,G)=>{const st=G.id&&r.get(G.id);return st?[...k,st]:k},[]);if($.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${$.map(k=>k.id).join(", ")}`);P.forEach(k=>{r.set(k.id,k),k.bodies.forEach(G=>t.set(G.id,k.id))}),n(I,{created:P})}},y=C=>{const E=typeof C=="string"?C:C.id,I=r.get(E);if(I)return r.delete(E),I.bodies.forEach(P=>t.delete(P.id)),I;console.warn(`Attempt to delete missing annotation: ${E}`)},_=(C,E=It.LOCAL)=>{const I=y(C);I&&n(E,{deleted:[I]})},v=(C,E=It.LOCAL)=>{const I=C.reduce((P,$)=>{const k=y($);return k?[...P,k]:P},[]);I.length>0&&n(E,{deleted:I})},g=C=>{const E=r.get(C.annotation);if(E){const I=E.bodies.find(P=>P.id===C.id);if(I){t.delete(I.id);const P={...E,bodies:E.bodies.filter($=>$.id!==C.id)};return r.set(E.id,P),{oldValue:E,newValue:P,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,E=It.LOCAL)=>{const I=g(C);I&&n(E,{updated:[I]})},b=(C,E=It.LOCAL)=>{const I=C.map(P=>g(P)).filter(Boolean);I.length>0&&n(E,{updated:I})},S=C=>{const E=r.get(C);return E?{...E}:void 0},w=C=>{const E=t.get(C);if(E){const I=S(E).bodies.find(P=>P.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}`)},T=(C,E)=>{if(C.annotation!==E.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const I=r.get(C.annotation);if(I){const P=I.bodies.find(k=>k.id===C.id),$={...I,bodies:I.bodies.map(k=>k.id===P.id?E:k)};return r.set(I.id,$),P.id!==E.id&&(t.delete(P.id),t.set(E.id,$.id)),{oldValue:I,newValue:$,bodiesUpdated:[{oldBody:P,newBody:E}]}}else console.warn(`Attempt to add body to missing annotation ${C.annotation}`)},N=(C,E,I=It.LOCAL)=>{const P=T(C,E);P&&n(I,{updated:[P]})},F=(C,E=It.LOCAL)=>{const I=C.map(P=>T({id:P.id,annotation:P.annotation},P)).filter(Boolean);n(E,{updated:I})},z=C=>{const E=r.get(C.annotation);if(E){const I={...E,target:{...E.target,...C}};return r.set(E.id,I),{oldValue:E,newValue:I,targetUpdated:{oldTarget:E.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:b,bulkUpdateAnnotations:u,bulkUpdateBodies:F,bulkUpdateTargets:(C,E=It.LOCAL)=>{const I=C.map(P=>z(P)).filter(Boolean);I.length>0&&n(E,{updated:I})},bulkUpsertAnnotations:c,clear:f,deleteAnnotation:_,deleteBody:x,getAnnotation:S,getBody:w,observe:i,unobserve:s,updateAnnotation:l,updateBody:N,updateTarget:(C,E=It.LOCAL)=>{const I=z(C);I&&n(E,{updated:[I]})},upsertAnnotation:h}},Ty=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let wy=()=>({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 Ay=250,Sy=(r,t)=>{const e=wy(),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>Ay)i.splice(s+1),i.push(m),s=i.length-1;else{const _=i.length-1;i[_]=xy(i[_],m)}o=y}n=!1};r.observe(a,{origin:It.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}}}},Cy=()=>{const{subscribe:r,set:t}=sa([]);return{subscribe:r,set:t}},Iy=(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 b=Array.isArray(v)?v.map(w=>e.serialize(w)):e.serialize(v),S=g?g instanceof PointerEvent?g:e.serialize(g):void 0;x(b,S)}else x(v,g)})},1)},m=()=>{const{selected:_}=n,v=(_||[]).map(({id:g})=>o.getAnnotation(g));v.forEach(g=>{const x=h.find(b=>b.id===g.id);(!x||!Nr(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&&!Nr(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 b=o.getAnnotation(x.id);b&&!Nr(b,x)&&f("updateAnnotation",b,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:b})=>{const S=h.find(w=>w.id===x.id)||x;h=h.map(w=>w.id===x.id?b:w),f("updateAnnotation",b,S)})},{origin:It.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(b=>b.id===x.id)||x))}},{origin:It.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}},Ry=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:[]}),My=(r,t,e)=>{const{store:i,selection:s}=r,n=_=>{if(e){const{parsed:v,error:g}=e.parse(_);v?i.addAnnotation(v,It.REMOTE):console.error(g)}else i.addAnnotation(oa(_),It.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||Ry(e),{parsed:x,failed:b}=g(_);b.length>0&&console.warn(`Discarded ${b.length} invalid annotations`,b),i.bulkAddAnnotations(x,v,It.REMOTE)}else i.bulkAddAnnotations(_.map(oa),v,It.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(oa(_)),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}},Py=(r,t,e)=>typeof t=="function"?t(r,e):t,Oy=(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||{}}},Ny="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Dy=r=>crypto.getRandomValues(new Uint8Array(r)),Ly=(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}}},By=(r,t=21)=>Ly(r,t|0,Dy),Fy=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Ny[e[r]&63];return t};const Uy=()=>({isGuest:!0,id:By("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),ky=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}`},lu=r=>r?typeof r=="object"?{...r}:r:void 0,Gy=(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-${ky(e)}`,annotation:t,type:s,purpose:n,value:o,creator:lu(h),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),$y=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});Fy();const Hy=(r,t={strict:!0,invertY:!1})=>({parse:e=>Vy(e,t),serialize:e=>Xy(e,r,t)}),Vy=(r,t={strict:!0,invertY:!1})=>{const e=r.id||ru(),{creator:i,created:s,modified:n,body:o,...a}=r,l=Gy(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"?Sg(u,t.invertY):(u==null?void 0:u.type)==="SvgSelector"?ty(u):void 0;return c||!t.strict?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:lu(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:c||u}}}:{error:Error(`Invalid selector: ${JSON.stringify(u)}`)}},Xy=(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==vt.RECTANGLE?Cg(i.geometry):ry(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:$y(r.bodies),created:n==null?void 0:n.toISOString(),creator:s,modified:o==null?void 0:o.toISOString(),target:{...l,source:t,selector:h}};return delete u.bodies,"annotation"in u.target&&delete u.target.annotation,u};function hu(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function uu(r){let t,e;return t=new Oi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){$t(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function zy(r){let t,e,i,s,n,o,a,l,h,u,c,d=Ee(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=uu(hu(r,d,m));const f=m=>dt(p[m],1,1,()=>{p[m]=null});return{c(){t=mt("polygon"),s=ke(),n=mt("polygon"),a=ke();for(let m=0;m<p.length;m+=1)p[m].c();l=Ie(),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"points",i=r[4].points.map(cu).join(" ")),A(n,"class","a9s-inner a9s-shape-handle"),A(n,"style",r[1]),A(n,"points",o=r[4].points.map(du).join(" "))},m(m,y){ot(m,t,y),ot(m,s,y),ot(m,n,y),ot(m,a,y);for(let _=0;_<p.length;_+=1)p[_]&&p[_].m(m,y);ot(m,l,y),h=!0,u||(c=[Bt(t,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(n,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,y){if(r=m,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(cu).join(" ")))&&A(t,"points",i),(!h||y&2)&&A(n,"style",r[1]),(!h||y&16&&o!==(o=r[4].points.map(du).join(" ")))&&A(n,"points",o),y&536){d=Ee(r[4].points);let _;for(_=0;_<d.length;_+=1){const v=hu(r,d,_);p[_]?(p[_].p(v,y),it(p[_],1)):(p[_]=uu(v),p[_].c(),it(p[_],1),p[_].m(l.parentNode,l))}for(xe(),_=d.length;_<p.length;_+=1)f(_);be()}},i(m){if(!h){for(let y=0;y<d.length;y+=1)it(p[y]);h=!0}},o(m){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)dt(p[y]);h=!1},d(m){m&&(nt(t),nt(s),nt(n),nt(a),nt(l)),Jr(p,m),u=!1,Ue(c)}}}function Wy(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[zy,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}const cu=r=>r.join(","),du=r=>r.join(",");function Yy(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const y=d.geometry;p==="SHAPE"?m=y.points.map(([v,g])=>[v+f[0],g+f[1]]):m=y.points.map(([v,g],x)=>p===`HANDLE-${x}`?[v+f[0],g+f[1]]:[v,g]);const _=_r(m);return{...d,geometry:{points:m,bounds:_}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class jy extends we{constructor(t){super(),Te(this,t,Yy,Wy,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const aa=(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))},Pi=[];function qy(r,t=Ct){let e;const i=new Set;function s(a){if(te(r,a)&&(r=a,e)){const l=!Pi.length;for(const h of i)h[1](),Pi.push(h,r);if(l){for(let h=0;h<Pi.length;h+=2)Pi[h][0](Pi[h+1]);Pi.length=0}}}function n(a){s(a(r))}function o(a,l=Ct){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||Ct),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Ky=(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}`)},Zy=(r,t)=>{Ky(r,t);const{subscribe:e,set:i}=qy(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}},fu=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Qy(r){let t,e,i,s,n,o;return{c(){t=mt("rect"),A(t,"class",e=tn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(t,"x",i=r[0]-r[5]/2),A(t,"y",s=r[1]-r[5]/2),A(t,"width",r[5]),A(t,"height",r[5])},m(a,l){ot(a,t,l),n||(o=Bt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=tn(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&A(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&A(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&A(t,"y",s),l&32&&A(t,"width",a[5]),l&32&&A(t,"height",a[5])},d(a){a&&nt(t),n=!1,o()}}}function Jy(r){let t,e,i,s,n,o,a,l,h;return{c(){t=mt("g"),e=mt("circle"),s=mt("rect"),A(e,"cx",r[0]),A(e,"cy",r[1]),A(e,"r",i=r[3]/r[2]),A(e,"class","a9s-touch-halo svelte-1sgkh33"),Mr(e,"touched",r[4]),A(s,"class",n=tn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(s,"x",o=r[0]-r[5]/2),A(s,"y",a=r[1]-r[5]/2),A(s,"width",r[5]),A(s,"height",r[5]),A(t,"class","a9s-touch-handle")},m(u,c){ot(u,t,c),Oe(t,e),Oe(t,s),l||(h=[Bt(e,"pointerdown",r[10]),Bt(e,"pointerdown",r[6]),Bt(e,"pointerup",r[7]),Bt(s,"pointerdown",r[9]),Bt(s,"pointerdown",r[6]),Bt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&A(e,"cx",u[0]),c&2&&A(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&A(e,"r",i),c&16&&Mr(e,"touched",u[4]),c&256&&n!==(n=tn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&A(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&A(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&A(s,"y",a),c&32&&A(s,"width",u[5]),c&32&&A(s,"height",u[5])},d(u){u&&nt(t),l=!1,Ue(h)}}}function t_(r){let t;function e(s,n){return fu?Jy:Qy}let i=e()(r);return{c(){i.c(),t=Ie()},m(s,n){i.m(s,n),ot(s,t,n)},p(s,[n]){i.p(s,n)},i:Ct,o:Ct,d(s){s&&nt(t),i.d(s)}}}function e_(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){Ne.call(this,r,f)}function d(f){Ne.call(this,r,f)}function p(f){Ne.call(this,r,f)}return r.$$set=f=>{e(8,t=Xo(Xo({},t),Bh(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Bh(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class Oi extends we{constructor(t){super(),Te(this,t,e_,t_,te,{x:0,y:1,scale:2,radius:3})}}function r_(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,b,S,w,T,N,F,z,C,E,I,P,$,k,G,st,M,L,V,rt,Q,X,_t,St;return G=new Oi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),G.$on("pointerdown",function(){$t(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),M=new Oi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),M.$on("pointerdown",function(){$t(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),V=new Oi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),V.$on("pointerdown",function(){$t(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Oi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){$t(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=mt("rect"),a=ke(),l=mt("rect"),p=ke(),f=mt("rect"),v=ke(),g=mt("rect"),w=ke(),T=mt("rect"),C=ke(),E=mt("rect"),k=ke(),_e(G.$$.fragment),st=ke(),_e(M.$$.fragment),L=ke(),_e(V.$$.fragment),rt=ke(),_e(Q.$$.fragment),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"x",i=r[4].x),A(t,"y",s=r[4].y),A(t,"width",n=r[4].w),A(t,"height",o=r[4].h),A(l,"class","a9s-inner a9s-shape-handle"),A(l,"style",r[1]),A(l,"x",h=r[4].x),A(l,"y",u=r[4].y),A(l,"width",c=r[4].w),A(l,"height",d=r[4].h),A(f,"class","a9s-edge-handle a9s-edge-handle-top"),A(f,"x",m=r[4].x),A(f,"y",y=r[4].y),A(f,"height",1),A(f,"width",_=r[4].w),A(g,"class","a9s-edge-handle a9s-edge-handle-right"),A(g,"x",x=r[4].x+r[4].w),A(g,"y",b=r[4].y),A(g,"height",S=r[4].h),A(g,"width",1),A(T,"class","a9s-edge-handle a9s-edge-handle-bottom"),A(T,"x",N=r[4].x),A(T,"y",F=r[4].y+r[4].h),A(T,"height",1),A(T,"width",z=r[4].w),A(E,"class","a9s-edge-handle a9s-edge-handle-left"),A(E,"x",I=r[4].x),A(E,"y",P=r[4].y),A(E,"height",$=r[4].h),A(E,"width",1)},m(O,D){ot(O,t,D),ot(O,a,D),ot(O,l,D),ot(O,p,D),ot(O,f,D),ot(O,v,D),ot(O,g,D),ot(O,w,D),ot(O,T,D),ot(O,C,D),ot(O,E,D),ot(O,k,D),fe(G,O,D),ot(O,st,D),fe(M,O,D),ot(O,L,D),fe(V,O,D),ot(O,rt,D),fe(Q,O,D),X=!0,_t||(St=[Bt(t,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(l,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(f,"pointerdown",function(){$t(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Bt(g,"pointerdown",function(){$t(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Bt(T,"pointerdown",function(){$t(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Bt(E,"pointerdown",function(){$t(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(O,D){r=O,(!X||D&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!X||D&16&&i!==(i=r[4].x))&&A(t,"x",i),(!X||D&16&&s!==(s=r[4].y))&&A(t,"y",s),(!X||D&16&&n!==(n=r[4].w))&&A(t,"width",n),(!X||D&16&&o!==(o=r[4].h))&&A(t,"height",o),(!X||D&2)&&A(l,"style",r[1]),(!X||D&16&&h!==(h=r[4].x))&&A(l,"x",h),(!X||D&16&&u!==(u=r[4].y))&&A(l,"y",u),(!X||D&16&&c!==(c=r[4].w))&&A(l,"width",c),(!X||D&16&&d!==(d=r[4].h))&&A(l,"height",d),(!X||D&16&&m!==(m=r[4].x))&&A(f,"x",m),(!X||D&16&&y!==(y=r[4].y))&&A(f,"y",y),(!X||D&16&&_!==(_=r[4].w))&&A(f,"width",_),(!X||D&16&&x!==(x=r[4].x+r[4].w))&&A(g,"x",x),(!X||D&16&&b!==(b=r[4].y))&&A(g,"y",b),(!X||D&16&&S!==(S=r[4].h))&&A(g,"height",S),(!X||D&16&&N!==(N=r[4].x))&&A(T,"x",N),(!X||D&16&&F!==(F=r[4].y+r[4].h))&&A(T,"y",F),(!X||D&16&&z!==(z=r[4].w))&&A(T,"width",z),(!X||D&16&&I!==(I=r[4].x))&&A(E,"x",I),(!X||D&16&&P!==(P=r[4].y))&&A(E,"y",P),(!X||D&16&&$!==($=r[4].h))&&A(E,"height",$);const ut={};D&16&&(ut.x=r[4].x),D&16&&(ut.y=r[4].y),D&8&&(ut.scale=r[3]),G.$set(ut);const lt={};D&16&&(lt.x=r[4].x+r[4].w),D&16&&(lt.y=r[4].y),D&8&&(lt.scale=r[3]),M.$set(lt);const Et={};D&16&&(Et.x=r[4].x+r[4].w),D&16&&(Et.y=r[4].y+r[4].h),D&8&&(Et.scale=r[3]),V.$set(Et);const Tt={};D&16&&(Tt.x=r[4].x),D&16&&(Tt.y=r[4].y+r[4].h),D&8&&(Tt.scale=r[3]),Q.$set(Tt)},i(O){X||(it(G.$$.fragment,O),it(M.$$.fragment,O),it(V.$$.fragment,O),it(Q.$$.fragment,O),X=!0)},o(O){dt(G.$$.fragment,O),dt(M.$$.fragment,O),dt(V.$$.fragment,O),dt(Q.$$.fragment,O),X=!1},d(O){O&&(nt(t),nt(a),nt(l),nt(p),nt(f),nt(v),nt(g),nt(w),nt(T),nt(C),nt(E),nt(k),nt(st),nt(L),nt(rt)),pe(G,O),pe(M,O),pe(V,O),pe(Q,O),_t=!1,Ue(St)}}}function i_(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[r_,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function s_(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[y,_]=[m.minX,m.minY],[v,g]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,v+=x,_+=b,g+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{_+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const S=Math.min(y,v),w=Math.min(_,g),T=Math.abs(v-y),N=Math.abs(g-_);return{...d,geometry:{x:S,y:w,w:T,h:N,bounds:{minX:S,minY:w,maxX:S+T,maxY:w+N}}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class n_ extends we{constructor(t){super(),Te(this,t,s_,i_,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}function pu(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function mu(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function gu(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function yu(r){let t,e;return t=new Oi({props:{x:r[16][0],y:r[16][1],scale:r[3]}}),t.$on("pointerdown",function(){$t(r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`))&&r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[16][0]),s&16&&(n.y=r[16][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function _u(r){let t,e,i=Ee(r[13].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=yu(gu(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&536){i=Ee(o[13].points);let l;for(l=0;l<i.length;l+=1){const h=gu(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=yu(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function vu(r){let t,e,i,s,n,o,a,l,h,u=Ee(r[10].rings),c=[];for(let p=0;p<u.length;p+=1)c[p]=_u(mu(r,u,p));const d=p=>dt(c[p],1,1,()=>{c[p]=null});return{c(){t=mt("g"),e=mt("path"),n=mt("path");for(let p=0;p<c.length;p+=1)c[p].c();A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"fill-rule","evenodd"),A(e,"d",s=ei(r[10])),A(n,"class","a9s-inner"),A(n,"style",r[1]),A(n,"fill-rule","evenodd"),A(n,"d",o=ei(r[10]))},m(p,f){ot(p,t,f),Oe(t,e),Oe(t,n);for(let m=0;m<c.length;m+=1)c[m]&&c[m].m(t,null);a=!0,l||(h=[Bt(e,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Bt(n,"pointerdown",function(){$t(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],l=!0)},p(p,f){if(r=p,(!a||f&2&&i!==(i=r[1]?"display:none;":void 0))&&A(e,"style",i),(!a||f&16&&s!==(s=ei(r[10])))&&A(e,"d",s),(!a||f&2)&&A(n,"style",r[1]),(!a||f&16&&o!==(o=ei(r[10])))&&A(n,"d",o),f&536){u=Ee(r[10].rings);let m;for(m=0;m<u.length;m+=1){const y=mu(r,u,m);c[m]?(c[m].p(y,f),it(c[m],1)):(c[m]=_u(y),c[m].c(),it(c[m],1),c[m].m(t,null))}for(xe(),m=u.length;m<c.length;m+=1)d(m);be()}},i(p){if(!a){for(let f=0;f<u.length;f+=1)it(c[f]);a=!0}},o(p){c=c.filter(Boolean);for(let f=0;f<c.length;f+=1)dt(c[f]);a=!1},d(p){p&&nt(t),Jr(c,p),l=!1,Ue(h)}}}function o_(r){let t,e,i=Ee(r[4].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=vu(pu(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a&538){i=Ee(o[4].polygons);let l;for(l=0;l<i.length;l+=1){const h=pu(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=vu(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function a_(r){let t,e;return t=new la({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[o_,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&524826&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function l_(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.polygons;let y;if(p==="SHAPE")y=m.map(_=>{const v=_.rings.map((x,b)=>({points:x.points.map((S,w)=>[S[0]+f[0],S[1]+f[1]])})),g=_r(v[0].points);return{rings:v,bounds:g}});else{const[_,v,g,x]=p.split("-").map(b=>parseInt(b));y=m.map((b,S)=>{if(S===v){const w=b.rings.map((N,F)=>F===g?{points:N.points.map((z,C)=>C===x?[z[0]+f[0],z[1]+f[1]]:z)}:N),T=_r(w[0].points);return{rings:w,bounds:T}}else return b})}return{...d,geometry:{polygons:y,bounds:Tg(y)}}};function h(d){Ne.call(this,r,d)}function u(d){Ne.call(this,r,d)}function c(d){Ne.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class h_ extends we{constructor(t){super(),Te(this,t,l_,a_,te,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const xu=new Map([[vt.RECTANGLE,n_],[vt.POLYGON,jy],[vt.MULTIPOLYGLON,h_]]),bu=r=>xu.get(r.type),Eu=(r,t)=>xu.set(r,t),u_=r=>({}),Tu=r=>({grab:r[0]});function c_(r){let t,e,i,s;const n=r[7].default,o=ag(n,r,r[6],Tu);return{c(){t=mt("g"),o&&o.c(),A(t,"class","a9s-annotation selected")},m(a,l){ot(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Bt(t,"pointerup",r[2]),Bt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&hg(o,n,a,a[6],e?lg(n,a[6],l,u_):ug(a[6]),Tu)},i(a){e||(it(o,a),e=!0)},o(a){dt(o,a),e=!1},d(a){a&&nt(t),o&&o.d(a),i=!1,Ue(s)}}}function d_(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Si();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>y=>{h=m,u=l.elementToImage(y.offsetX,y.offsetY),c=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=m=>{if(h){const[y,_]=l.elementToImage(m.offsetX,m.offsetY),v=[y-u[0],_-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class la extends we{constructor(t){super(),Te(this,t,d_,c_,te,{shape:3,editor:4,transform:5})}}const gs=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function f_(r,t,e){let i;const s=Si();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return ms(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=gs(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 p_ extends we{constructor(t){super(),Te(this,t,f_,null,te,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function m_(r,t,e){const i=Si();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return ms(()=>{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 g_ extends we{constructor(t){super(),Te(this,t,m_,null,te,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function wu(r){let t,e;return{c(){t=mt("rect"),e=mt("rect"),A(t,"class","a9s-outer"),A(t,"x",r[1]),A(t,"y",r[2]),A(t,"width",r[3]),A(t,"height",r[4]),A(e,"class","a9s-inner"),A(e,"x",r[1]),A(e,"y",r[2]),A(e,"width",r[3]),A(e,"height",r[4])},m(i,s){ot(i,t,s),ot(i,e,s)},p(i,s){s&2&&A(t,"x",i[1]),s&4&&A(t,"y",i[2]),s&8&&A(t,"width",i[3]),s&16&&A(t,"height",i[4]),s&2&&A(e,"x",i[1]),s&4&&A(e,"y",i[2]),s&8&&A(e,"width",i[3]),s&16&&A(e,"height",i[4])},d(i){i&&(nt(t),nt(e))}}}function y_(r){let t,e=r[0]&&wu(r);return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){ot(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=wu(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Ct,o:Ct,d(i){i&&nt(t),e&&e.d()}}}function __(r,t,e){const i=Si();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,u,c,d,p;const f=v=>{const g=v;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))},m=v=>{const g=v;l&&(h=o.elementToImage(g.offsetX,g.offsetY),e(1,u=Math.min(h[0],l[0])),e(2,c=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,p=Math.abs(h[1]-l[1])))},y=v=>{const g=v,x=performance.now()-a;if(n==="click"){if(x>300)return;l?_():(e(0,l=o.elementToImage(g.offsetX,g.offsetY)),h=l,e(1,u=l[0]),e(2,c=l[1]),e(3,d=1),e(4,p=1))}else l&&(x>300||d*p>100?(g.stopPropagation(),_()):(e(0,l=void 0),h=void 0))},_=()=>{if(d*p>15){const v={type:vt.RECTANGLE,geometry:{bounds:{minX:u,minY:c,maxX:u+d,maxY:c+p},x:u,y:c,w:d,h:p}};i("create",v)}e(0,l=void 0),h=void 0};return ms(()=>{s("pointerdown",f),s("pointermove",m),s("pointerup",y,!0)}),r.$$set=v=>{"addEventListener"in v&&e(5,s=v.addEventListener),"drawingMode"in v&&e(6,n=v.drawingMode),"transform"in v&&e(7,o=v.transform)},[l,u,c,d,p,s,n,o]}class v_ extends we{constructor(t){super(),Te(this,t,__,y_,te,{addEventListener:5,drawingMode:6,transform:7})}}function ha(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function Au(r){let t,e,i,s,n,o=r[2]&&Su(r);return{c(){t=mt("polygon"),i=mt("polygon"),o&&o.c(),n=Ie(),A(t,"class","a9s-outer"),A(t,"points",e=r[16]),A(i,"class","a9s-inner"),A(i,"points",s=r[16])},m(a,l){ot(a,t,l),ot(a,i,l),o&&o.m(a,l),ot(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&A(t,"points",e),l&7&&s!==(s=a[16])&&A(i,"points",s),a[2]?o?o.p(a,l):(o=Su(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(nt(t),nt(i),nt(n)),o&&o.d(a)}}}function Su(r){let t,e,i;return{c(){t=mt("rect"),A(t,"class","a9s-handle"),A(t,"x",e=r[0][0][0]-r[3]/2),A(t,"y",i=r[0][0][1]-r[3]/2),A(t,"height",r[3]),A(t,"width",r[3])},m(s,n){ot(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&A(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&A(t,"y",i),n&8&&A(t,"height",s[3]),n&8&&A(t,"width",s[3])},d(s){s&&nt(t)}}}function x_(r){let t,e=r[1]&&Au(ha(r));return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){ot(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(ha(i),s):(e=Au(ha(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:Ct,o:Ct,d(i){i&&nt(t),e&&e.d()}}}const b_=20,E_=1500;function T_(r,t,e){let i;const s=Si();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,u=[],c,d,p=!1;const f=g=>{const x=g,{timeStamp:b,offsetX:S,offsetY:w}=x;if(h={timeStamp:b,offsetX:S,offsetY:w},o==="drag"&&u.length===0){const T=a.elementToImage(x.offsetX,x.offsetY);u.push(T),e(1,c=T)}},m=g=>{const x=g;if(d&&clearTimeout(d),u.length>0){if(e(1,c=a.elementToImage(x.offsetX,x.offsetY)),u.length>2){const b=aa(c,u[0])*l;e(2,p=b<b_)}x.pointerType==="touch"&&(d=setTimeout(()=>{_()},E_))}},y=g=>{const x=g;if(d&&clearTimeout(d),o==="click"){const b=x.timeStamp-h.timeStamp,S=aa([h.offsetX,h.offsetY],[x.offsetX,x.offsetY]);if(b>300||S>15)return;if(p)v();else if(u.length===0){const w=a.elementToImage(x.offsetX,x.offsetY);u.push(w),e(1,c=w)}else u.push(c)}else{if(u.length===1&&aa(u[0],c)<=4){e(0,u=[]),e(1,c=void 0);return}x.stopImmediatePropagation(),p?v():u.push(c)}},_=()=>{if(!c)return;const g=u.slice(0,-1);if(g.length<3)return;const x={type:vt.POLYGON,geometry:{bounds:_r(u),points:g}};Ko(x)>4&&(e(0,u=[]),e(1,c=void 0),s("create",x))},v=()=>{const g={type:vt.POLYGON,geometry:{bounds:_r(u),points:[...u]}};e(0,u=[]),e(1,c=void 0),s("create",g)};return ms(()=>{n("pointerdown",f,!0),n("pointermove",m),n("pointerup",y,!0),n("dblclick",_,!0)}),r.$$set=g=>{"addEventListener"in g&&e(4,n=g.addEventListener),"drawingMode"in g&&e(5,o=g.drawingMode),"transform"in g&&e(6,a=g.transform),"viewportScale"in g&&e(7,l=g.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[u,c,p,i,n,o,a,l]}class w_ extends we{constructor(t){super(),Te(this,t,T_,x_,te,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const ua=new Map([["rectangle",{tool:v_}],["polygon",{tool:w_}]]),hn=()=>[...ua.keys()],un=r=>ua.get(r),Cu=(r,t,e)=>ua.set(r,{tool:t,opts:e});function A_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("ellipse"),s=mt("ellipse"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"cx",r[2]),A(e,"cy",r[3]),A(e,"rx",r[4]),A(e,"ry",r[5]),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"cx",r[2]),A(s,"cy",r[3]),A(s,"rx",r[4]),A(s,"ry",r[5]),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}function S_(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=gs(s,o))},[s,i,a,l,h,u,n,o]}class C_ extends we{constructor(t){super(),Te(this,t,S_,A_,te,{annotation:0,geom:6,style:7})}}function Iu(r,t,e){const i=r.slice();return i[5]=t[e],i}function Ru(r){let t,e,i;return{c(){t=mt("path"),i=mt("path"),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"fill-rule","evenodd"),A(t,"d",ei(r[5])),A(i,"class","a9s-inner"),A(i,"style",r[1]),A(i,"fill-rule","evenodd"),A(i,"d",ei(r[5]))},m(s,n){ot(s,t,n),ot(s,i,n)},p(s,n){n&2&&e!==(e=s[1]?"display:none;":void 0)&&A(t,"style",e),n&2&&A(i,"style",s[1])},d(s){s&&(nt(t),nt(i))}}}function I_(r){let t,e,i=Ee(r[2]),s=[];for(let n=0;n<i.length;n+=1)s[n]=Ru(Iu(r,i,n));return{c(){t=mt("g");for(let n=0;n<s.length;n+=1)s[n].c();A(t,"class","a9s-annotation"),A(t,"data-id",e=r[0].id)},m(n,o){ot(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=Ee(n[2]);let a;for(a=0;a<i.length;a+=1){const l=Iu(n,i,a);s[a]?s[a].p(l,o):(s[a]=Ru(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)&&A(t,"data-id",e)},i:Ct,o:Ct,d(n){n&&nt(t),Jr(s,n)}}}function R_(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=gs(s,o))},[s,i,a,n,o]}class M_ extends we{constructor(t){super(),Te(this,t,R_,I_,te,{annotation:0,geom:3,style:4})}}function P_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("polygon"),s=mt("polygon"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"points",r[2].map(O_).join(" ")),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"points",r[2].map(N_).join(" ")),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}const O_=r=>r.join(","),N_=r=>r.join(",");function D_(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=gs(s,o))},[s,i,a,n,o]}class L_ extends we{constructor(t){super(),Te(this,t,D_,P_,te,{annotation:0,geom:3,style:4})}}function B_(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("rect"),s=mt("rect"),A(e,"class","a9s-outer"),A(e,"style",i=r[5]?"display:none;":void 0),A(e,"x",r[4]),A(e,"y",r[3]),A(e,"width",r[2]),A(e,"height",r[1]),A(s,"class","a9s-inner"),A(s,"style",r[5]),A(s,"x",r[4]),A(s,"y",r[3]),A(s,"width",r[2]),A(s,"height",r[1]),A(t,"class","a9s-annotation"),A(t,"data-id",n=r[0].id)},m(o,a){ot(o,t,a),Oe(t,e),Oe(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&A(e,"style",i),a&16&&A(e,"x",o[4]),a&8&&A(e,"y",o[3]),a&4&&A(e,"width",o[2]),a&2&&A(e,"height",o[1]),a&32&&A(s,"style",o[5]),a&16&&A(s,"x",o[4]),a&8&&A(s,"y",o[3]),a&4&&A(s,"width",o[2]),a&2&&A(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:Ct,o:Ct,d(o){o&&nt(t)}}}function F_(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=gs(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 U_ extends we{constructor(t){super(),Te(this,t,F_,B_,te,{annotation:0,geom:6,style:7})}}const k_=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]}}),G_=250,$_=(r,t)=>{const e=Si();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<G_){const{x:n,y:o}=Mu(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},Mu=(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 Pu(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 Ou(r,t,e){const i=r.slice();return i[43]=t[e],i}function ca(r){const t=r.slice(),e=t[43].target.selector;return t[46]=e,t}function Nu(r){let t=r[43],e,i,s=Du(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&65536&&te(t,t=n[43])?(xe(),dt(s,1,1,Ct),be(),s=Du(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function H_(r){let t,e;return t=new M_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function V_(r){let t,e;return t=new L_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function X_(r){let t,e;return t=new U_({props:{annotation:r[43],geom:r[46].geometry,style:r[1]}}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&65536&&(n.annotation=i[43]),s[0]&65536&&(n.geom=i[46].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function z_(r){var t;let e,i;return e=new C_({props:{annotation:r[43],geom:(t=r[46])==null?void 0:t.geometry,style:r[1]}}),{c(){_e(e.$$.fragment)},m(s,n){fe(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||(it(e.$$.fragment,s),i=!0)},o(s){dt(e.$$.fragment,s),i=!1},d(s){pe(e,s)}}}function Du(r){let t,e,i,s;const n=[z_,X_,V_,H_],o=[];function a(l,h){var u,c,d,p;return((u=l[46])==null?void 0:u.type)===vt.ELLIPSE?0:((c=l[46])==null?void 0:c.type)===vt.RECTANGLE?1:((d=l[46])==null?void 0:d.type)===vt.POLYGON?2:((p=l[46])==null?void 0:p.type)===vt.MULTIPOLYGLON?3:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ie()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),dt(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()),it(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(it(e),s=!0)},o(l){dt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function Lu(r){let t=Ge(r[43])&&!r[9](r[43]),e,i,s=t&&Nu(ca(r));return{c(){s&&s.c(),e=Ie()},m(n,o){s&&s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&66048&&(t=Ge(n[43])&&!n[9](n[43])),t?s?(s.p(ca(n),o),o[0]&66048&&it(s,1)):(s=Nu(ca(n)),s.c(),it(s,1),s.m(e.parentNode,e)):s&&(xe(),dt(s,1,1,()=>{s=null}),be())},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s&&s.d(n)}}}function Bu(r){let t,e,i,s;const n=[Y_,W_],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=Ie()},m(l,h){~t&&o[t].m(l,h),ot(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(xe(),dt(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()),it(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(it(e),s=!0)},o(l){dt(e),s=!1},d(l){l&&nt(i),~t&&o[t].d(l)}}}function W_(r){let t=`${r[2]}-${r[5]}`,e,i,s=Fu(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&36&&te(t,t=`${n[2]}-${n[5]}`)?(xe(),dt(s,1,1,Ct),be(),s=Fu(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function Y_(r){let t,e,i=Ee(r[8]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Gu(Pu(r,i,o));const n=o=>dt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ot(o,t,a),e=!0},p(o,a){if(a[0]&21107010){i=Ee(o[8]);let l;for(l=0;l<i.length;l+=1){const h=Pu(o,i,l);s[l]?(s[l].p(h,a),it(s[l],1)):(s[l]=Gu(h),s[l].c(),it(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)it(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)dt(s[a]);e=!1},d(o){o&&nt(t),Jr(s,o)}}}function Fu(r){let t,e;return t=new g_({props:{target:r[6],tool:r[14],drawingMode:r[13],transform:r[12],viewportScale:r[17]}}),t.$on("create",r[21]),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&16384&&(n.tool=i[14]),s[0]&8192&&(n.drawingMode=i[13]),s[0]&4096&&(n.transform=i[12]),s[0]&131072&&(n.viewportScale=i[17]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Uu(r){let t=r[39].id,e,i,s=ku(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),ot(n,e,o),i=!0},p(n,o){o[0]&256&&te(t,t=n[39].id)?(xe(),dt(s,1,1,Ct),be(),s=ku(n),s.c(),it(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(it(s),i=!0)},o(n){dt(s),i=!1},d(n){n&&nt(e),s.d(n)}}}function ku(r){let t,e;return t=new p_({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(){$t(r[22](r[39]))&&r[22](r[39]).apply(this,arguments)}),{c(){_e(t.$$.fragment)},m(i,s){fe(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&256&&(n.editor=r[24](r[39].target.selector)),s[0]&256&&(n.annotation=r[39]),s[0]&2&&(n.style=r[1]),s[0]&4096&&(n.transform=r[12]),s[0]&131072&&(n.viewportScale=r[17]),t.$set(n)},i(i){e||(it(t.$$.fragment,i),e=!0)},o(i){dt(t.$$.fragment,i),e=!1},d(i){pe(t,i)}}}function Gu(r){let t,e,i=r[40]&&Uu(r);return{c(){i&&i.c(),t=Ie()},m(s,n){i&&i.m(s,n),ot(s,t,n),e=!0},p(s,n){s[40]?i?(i.p(s,n),n[0]&256&&it(i,1)):(i=Uu(s),i.c(),it(i,1),i.m(t.parentNode,t)):i&&(xe(),dt(i,1,1,()=>{i=null}),be())},i(s){e||(it(i),e=!0)},o(s){dt(i),e=!1},d(s){s&&nt(t),i&&i.d(s)}}}function j_(r){let t,e,i,s,n,o,a=Ee(r[16].filter(r[34])),l=[];for(let c=0;c<a.length;c+=1)l[c]=Lu(Ou(r,a,c));const h=c=>dt(l[c],1,1,()=>{l[c]=null});let u=r[6]&&Bu(r);return{c(){t=mt("svg"),e=mt("g");for(let c=0;c<l.length;c+=1)l[c].c();i=mt("g"),u&&u.c(),A(i,"class","drawing"),A(t,"class","a9s-annotationlayer"),Mr(t,"drawing",r[14]),Mr(t,"hidden",!r[3]),Mr(t,"hover",r[15])},m(c,d){ot(c,t,d),Oe(t,e);for(let p=0;p<l.length;p+=1)l[p]&&l[p].m(e,null);Oe(t,i),u&&u.m(i,null),r[35](i),r[36](t),s=!0,n||(o=[Bt(t,"pointerup",function(){$t(r[10])&&r[10].apply(this,arguments)}),Bt(t,"pointerdown",function(){$t(r[11])&&r[11].apply(this,arguments)}),Bt(t,"pointermove",r[23])],n=!0)},p(c,d){if(r=c,d[0]&66050){a=Ee(r[16].filter(r[34]));let p;for(p=0;p<a.length;p+=1){const f=Ou(r,a,p);l[p]?(l[p].p(f,d),it(l[p],1)):(l[p]=Lu(f),l[p].c(),it(l[p],1),l[p].m(e,null))}for(xe(),p=a.length;p<l.length;p+=1)h(p);be()}r[6]?u?(u.p(r,d),d[0]&64&&it(u,1)):(u=Bu(r),u.c(),it(u,1),u.m(i,null)):u&&(xe(),dt(u,1,1,()=>{u=null}),be()),(!s||d[0]&16384)&&Mr(t,"drawing",r[14]),(!s||d[0]&8)&&Mr(t,"hidden",!r[3]),(!s||d[0]&32768)&&Mr(t,"hover",r[15])},i(c){if(!s){for(let d=0;d<a.length;d+=1)it(l[d]);it(u),s=!0}},o(c){l=l.filter(Boolean);for(let d=0;d<l.length;d+=1)dt(l[d]);dt(u),s=!1},d(c){c&&nt(t),Jr(l,c),u&&u.d(),r[35](null),r[36](null),n=!1,Ue(o)}}}function q_(r,t,e){let i,s,n,o,a,l,h,u,c,d,p,f=Ct,m=()=>(f(),f=Dh(I,O=>e(17,p=O)),I);r.$$.on_destroy.push(()=>f());let{drawingEnabled:y}=t,{image:_}=t,{preferredDrawingMode:v}=t,{state:g}=t,{style:x=void 0}=t,{toolName:b=hn()[0]}=t,{user:S}=t,{visible:w=!0}=t,T=0;const N=()=>e(5,T+=1),F=()=>b,z=()=>y;let C,E,I;ms(()=>m(e(7,I=Zy(_,E))));const{hover:P,selection:$,store:k}=g;zo(r,P,O=>e(15,u=O)),zo(r,$,O=>e(33,c=O)),zo(r,k,O=>e(16,d=O));let G,st;const M=O=>{G&&k.unobserve(G);const D=O.filter(({editable:ut})=>ut).map(({id:ut})=>ut);D.length>0?(e(8,st=D.map(ut=>k.getAnnotation(ut)).filter(ut=>ut&&Ge(ut))),G=ut=>{const{updated:lt}=ut.changes;e(8,st=lt==null?void 0:lt.map(Et=>Et.newValue))},k.observe(G,{annotations:D})):e(8,st=void 0)},L=O=>{const D=ru(),ut={id:D,bodies:[],target:{annotation:D,selector:O.detail,creator:S,created:new Date}};k.addAnnotation(ut),$.setSelected(ut.id)},V=O=>D=>{var ut;const{target:lt}=O,Et=10*60*1e3,Tt=((ut=lt.creator)==null?void 0:ut.id)!==S.id||!lt.created||new Date().getTime()-lt.created.getTime()>Et;k.updateTarget({...lt,selector:D.detail,created:Tt?lt.created:new Date,updated:Tt?new Date:void 0,updatedBy:Tt?S:void 0})},rt=O=>{const{x:D,y:ut}=Mu(O,E),lt=k.getAt(D,ut);lt?u!==lt.id&&P.set(lt.id):P.set(void 0)},Q=O=>bu(O),X=O=>Ge(O);function _t(O){en[O?"unshift":"push"](()=>{C=O,e(6,C)})}function St(O){en[O?"unshift":"push"](()=>{E=O,e(4,E)})}return r.$$set=O=>{"drawingEnabled"in O&&e(0,y=O.drawingEnabled),"image"in O&&e(25,_=O.image),"preferredDrawingMode"in O&&e(26,v=O.preferredDrawingMode),"state"in O&&e(27,g=O.state),"style"in O&&e(1,x=O.style),"toolName"in O&&e(2,b=O.toolName),"user"in O&&e(28,S=O.user),"visible"in O&&e(3,w=O.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(14,{tool:i,opts:s}=un(b)||{tool:void 0,opts:void 0},i,(e(32,s),e(2,b))),r.$$.dirty[0]&67108864|r.$$.dirty[1]&2&&e(13,n=(s==null?void 0:s.drawingMode)||v),r.$$.dirty[0]&16&&e(12,o=k_(E)),r.$$.dirty[0]&16&&e(11,{onPointerDown:a,onPointerUp:l}=$_(E,k),a,(e(10,l),e(4,E))),r.$$.dirty[1]&4&&e(9,h=O=>c.selected.find(D=>D.id===O.id&&D.editable)),r.$$.dirty[1]&4&&M(c.selected)},[y,x,b,w,E,T,C,I,st,h,l,a,o,n,i,u,d,p,P,$,k,L,V,rt,Q,_,v,g,S,N,F,z,s,c,X,_t,St]}class K_ extends we{constructor(t){super(),Te(this,t,q_,j_,te,{drawingEnabled:0,image:25,preferredDrawingMode:26,state:27,style:1,toolName:2,user:28,visible:3,cancelDrawing:29,getDrawingTool:30,isDrawingEnabled:31},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[29]}get getDrawingTool(){return this.$$.ctx[30]}get isDrawingEnabled(){return this.$$.ctx[31]}}function $u(r,t,e=0,i=r.length-1,s=Z_){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));$u(r,t,p,f,s)}const n=r[t];let o=e,a=i;for(ys(r,e,t),s(r[i],n)>0&&ys(r,e,i);o<a;){for(ys(r,o,a),o++,a--;s(r[o],n)<0;)o++;for(;s(r[a],n)>0;)a--}s(r[e],n)===0?ys(r,e,a):(a++,ys(r,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function ys(r,t,e){const i=r[t];r[t]=r[e],r[e]=i}function Z_(r,t){return r<t?-1:r>t?1:0}class Q_{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(!dn(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;dn(t,l)&&(e.leaf?i.push(a):fa(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!dn(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(dn(t,o)){if(e.leaf||fa(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=Di([]),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=J_(t,i.children,e);if(u!==-1)return i.children.splice(u,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&fa(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=Di(t.slice(e,i+1)),Ni(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=Di([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));Hu(t,e,i,h,this.compareMinX);for(let u=e;u<=i;u+=h){const c=Math.min(u+h-1,i);Hu(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 Ni(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=da(h),c=r0(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),vs(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=Di(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Ni(i,this.toBBox),Ni(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Di([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ni(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=_s(t,0,a,this.toBBox),h=_s(t,a,i,this.toBBox),u=i0(l,h),c=da(l)+da(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:t0,n=t.leaf?this.compareMinY:e0,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=_s(t,0,e,n),a=_s(t,i-e,i,n);let l=cn(o)+cn(a);for(let h=e;h<i-e;h++){const u=t.children[h];vs(o,t.leaf?n(u):u),l+=cn(o)}for(let h=i-e-1;h>=e;h--){const u=t.children[h];vs(a,t.leaf?n(u):u),l+=cn(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)vs(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():Ni(t[e],this.toBBox)}}function J_(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 Ni(r,t){_s(r,0,r.children.length,t,r)}function _s(r,t,e,i,s){s||(s=Di(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];vs(s,r.leaf?i(o):o)}return s}function vs(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 t0(r,t){return r.minX-t.minX}function e0(r,t){return r.minY-t.minY}function da(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function cn(r){return r.maxX-r.minX+(r.maxY-r.minY)}function r0(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 i0(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 fa(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function dn(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function Di(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Hu(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;$u(r,o,t,e,s),n.push(t,o,o,e)}}const s0=()=>{const r=new Q_,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{if(!nn(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(!nn(o))return;const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===vt.RECTANGLE||vg(h.selector,o,a));if(l.length>0)return l.sort((h,u)=>Ko(h.selector)-Ko(u.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(u=>u.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.reduce((h,u)=>{if(nn(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)}}},Vu=r=>{const t=Ey(),e=s0(),i=hy(t,r.userSelectAction,r.adapter),s=ly(t),n=Cy();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(u=>t.getAnnotation(u.annotation))},selection:i,hover:s,viewport:n}},n0=r=>{const t=Vu(r);return{...t,store:Ty(t.store)}},o0=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},Xu=r=>{const t=o0(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},zu=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Xu(r):e),Wu=(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}),Yu=typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1,ju=(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=()=>{Yu?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Yu?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},a0=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Wu(t,{drawingEnabled:!0,drawingMode:"drag",userSelectAction:su.EDIT,theme:"light"}),s=n0(i),{selection:n,store:o}=s,a=Sy(o,i.initialHistory),l=Iy(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=ju(a);let c=Uy();zu(e,h,i.theme);const d=new K_({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:c}});d.$on("click",C=>{const{originalEvent:E,annotation:I}=C.detail;I?n.userSelect(I.id,E):n.isEmpty()||n.clear()});const p=My(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,E,I)=>Cu(C,E,I),x=(C,E)=>Eu(C,E),b=C=>{if(!un(C))throw`No drawing tool named ${C}`;d.$set({toolName:C})},S=C=>d.$set({drawingEnabled:C}),w=C=>{console.warn("Filter not implemented yet")},T=C=>d.$set({style:C}),N=C=>zu(e,h,C),F=C=>{c=C,d.$set({user:C})},z=C=>d.$set({visible:C});return{...p,cancelDrawing:f,destroy:m,getDrawingTool:y,getUser:_,isDrawingEnabled:v,listDrawingTools:hn,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:x,setDrawingEnabled:S,setDrawingTool:b,setFilter:w,setStyle:T,setTheme:N,setUser:F,setVisible:z,element:h,state:s}};function me(){}function pa(r,t){for(const e in t)r[e]=t[e];return r}function qu(r){return r()}function Ku(){return Object.create(null)}function er(r){r.forEach(qu)}function Kt(r){return typeof r=="function"}function Wt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function l0(r){return Object.keys(r).length===0}function h0(r,...t){if(r==null){for(const i of t)i(void 0);return me}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function fn(r,t,e){r.$$.on_destroy.push(h0(t,e))}function Zu(r,t,e,i){if(r){const s=Qu(r,t,e,i);return r[0](s)}}function Qu(r,t,e,i){return r[1]&&i?pa(e.ctx.slice(),r[1](i(t))):e.ctx}function Ju(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 tc(r,t,e,i,s,n){if(s){const o=Qu(t,e,i,n);r.p(o,s)}}function ec(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 rc(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function pn(r){return r??""}const ic=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ae(r,t){r.appendChild(t)}function ct(r,t,e){r.insertBefore(t,e||null)}function ht(r){r.parentNode&&r.parentNode.removeChild(r)}function ii(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function xt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function ma(r){return document.createTextNode(r)}function Ve(){return ma(" ")}function Re(){return ma("")}function Zt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function R(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function u0(r){return Array.from(r.childNodes)}function c0(r,t){t=""+t,r.data!==t&&(r.data=t)}function mn(r,t,e){r.classList.toggle(t,!!e)}function d0(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let xs;function bs(r){xs=r}function ga(){if(!xs)throw new Error("Function called outside component initialization");return xs}function gn(r){ga().$$.on_mount.push(r)}function f0(r){ga().$$.on_destroy.push(r)}function yn(){const r=ga();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=d0(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 Li=[],_n=[];let Bi=[];const sc=[],p0=Promise.resolve();let ya=!1;function m0(){ya||(ya=!0,p0.then(nc))}function _a(r){Bi.push(r)}const va=new Set;let Fi=0;function nc(){if(Fi!==0)return;const r=xs;do{try{for(;Fi<Li.length;){const t=Li[Fi];Fi++,bs(t),g0(t.$$)}}catch(t){throw Li.length=0,Fi=0,t}for(bs(null),Li.length=0,Fi=0;_n.length;)_n.pop()();for(let t=0;t<Bi.length;t+=1){const e=Bi[t];va.has(e)||(va.add(e),e())}Bi.length=0}while(Li.length);for(;sc.length;)sc.pop()();ya=!1,va.clear(),bs(r)}function g0(r){if(r.fragment!==null){r.update(),er(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(_a)}}function y0(r){const t=[],e=[];Bi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Bi=t}const vn=new Set;let si;function ge(){si={r:0,c:[],p:si}}function ye(){si.r||er(si.c),si=si.p}function q(r,t){r&&r.i&&(vn.delete(r),r.i(t))}function et(r,t,e,i){if(r&&r.o){if(vn.has(r))return;vn.add(r),si.c.push(()=>{vn.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function Se(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),_a(()=>{const n=r.$$.on_mount.map(qu).filter(Kt);r.$$.on_destroy?r.$$.on_destroy.push(...n):er(n),r.$$.on_mount=[]}),s.forEach(_a)}function Ut(r,t){const e=r.$$;e.fragment!==null&&(y0(e.after_update),er(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function _0(r,t){r.$$.dirty[0]===-1&&(Li.push(r),m0(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ee(r,t,e,i,s,n,o=null,a=[-1]){const l=xs;bs(r);const h=r.$$={fragment:null,ctx:[],props:n,update:me,not_equal:s,bound:Ku(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Ku(),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&&_0(r,c)),d}):[],h.update(),u=!0,er(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const c=u0(t.target);h.fragment&&h.fragment.l(c),c.forEach(ht)}else h.fragment&&h.fragment.c();t.intro&&q(r.$$.fragment),Ft(r,t.target,t.anchor),nc()}bs(l)}class re{constructor(){Pt(this,"$$");Pt(this,"$$set")}$destroy(){Ut(this,1),this.$destroy=me}$on(t,e){if(!Kt(e))return me;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&&!l0(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const v0="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(v0);var ni=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(ni||{}),oc=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(oc||{}),xa=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(xa||{}),at=(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))(at||{}),rr=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(rr||{}),H=(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))(H||{}),Ui=(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))(Ui||{}),tt=(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))(tt||{}),Y=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(Y||{}),vr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(vr||{}),Dr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(Dr||{}),ir=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(ir||{}),Ce=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(Ce||{}),sr=(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))(sr||{}),ba=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(ba||{}),Le=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(Le||{}),Qt=(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))(Qt||{}),Yt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Yt||{}),nr=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(nr||{});const j={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 Ea=/iPhone/i,ac=/iPod/i,lc=/iPad/i,hc=/\biOS-universal(?:.+)Mac\b/i,Ta=/\bAndroid(?:.+)Mobile\b/i,uc=/Android/i,ki=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,xn=/Silk/i,xr=/Windows Phone/i,cc=/\bWindows(?:.+)ARM\b/i,dc=/BlackBerry/i,fc=/BB10/i,pc=/Opera Mini/i,mc=/\b(CriOS|Chrome)(?:.+)Mobile/i,gc=/Mobile(?:.+)Firefox\b/i,yc=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function x0(r){return function(t){return t.test(r)}}function _c(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=x0(e),n={apple:{phone:s(Ea)&&!s(xr),ipod:s(ac),tablet:!s(Ea)&&(s(lc)||yc(t))&&!s(xr),universal:s(hc),device:(s(Ea)||s(ac)||s(lc)||s(hc)||yc(t))&&!s(xr)},amazon:{phone:s(ki),tablet:!s(ki)&&s(xn),device:s(ki)||s(xn)},android:{phone:!s(xr)&&s(ki)||!s(xr)&&s(Ta),tablet:!s(xr)&&!s(ki)&&!s(Ta)&&(s(xn)||s(uc)),device:!s(xr)&&(s(ki)||s(xn)||s(Ta)||s(uc))||s(/\bokhttp\b/i)},windows:{phone:s(xr),tablet:s(cc),device:s(xr)||s(cc)},other:{blackberry:s(dc),blackberry10:s(fc),opera:s(pc),firefox:s(gc),chrome:s(mc),device:s(dc)||s(fc)||s(pc)||s(gc)||s(mc)},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 b0=_c.default??_c,br=b0(globalThis.navigator);j.RETINA_PREFIX=/@([0-9\.]+)x/,j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Es=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function E0(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 xc={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,b;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(b=1,v=new Array(_-1);b<_;b++)v[b-1]=arguments[b];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})(xc);var T0=xc.exports;const Ts=vc(T0);var wa={exports:{}};wa.exports=bn,wa.exports.default=bn;function bn(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=bc(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=I0(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 ws(n,o,e,a,l,p,0),o}function bc(r,t,e,i,s){var n,o;if(s===Ca(r,t,e,i)>0)for(n=t;n<e;n+=i)o=wc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=wc(n,r[n],r[n+1],o);return o&&En(o,o.next)&&(Ss(o),o=o.next),o}function oi(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(En(e,e.next)||Nt(e.prev,e,e.next)===0)){if(Ss(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ws(r,t,e,i,s,n,o){if(r){!o&&n&&N0(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?A0(r,i,s,n):w0(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Ss(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=S0(oi(r),t,e),ws(r,t,e,i,s,n,2)):o===2&&C0(r,t,e,i,s,n):ws(oi(r),t,e,i,s,n,1);break}}}}function w0(r){var t=r.prev,e=r,i=r.next;if(Nt(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&&Gi(s,a,n,l,o,h,f.x,f.y)&&Nt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function A0(r,t,e,i){var s=r.prev,n=r,o=r.next;if(Nt(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,_=Aa(p,f,t,e,i),v=Aa(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&&Gi(a,u,l,c,h,d,g.x,g.y)&&Nt(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&&Gi(a,u,l,c,h,d,x.x,x.y)&&Nt(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&&Gi(a,u,l,c,h,d,g.x,g.y)&&Nt(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&&Gi(a,u,l,c,h,d,x.x,x.y)&&Nt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function S0(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!En(s,n)&&Ec(s,i,i.next,n)&&As(s,n)&&As(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Ss(i),Ss(i.next),i=r=n),i=i.next}while(i!==r);return oi(i)}function C0(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&B0(o,a)){var l=Tc(o,a);o=oi(o,o.next),l=oi(l,l.next),ws(o,t,e,i,s,n,0),ws(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function I0(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=bc(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(L0(h));for(s.sort(R0),n=0;n<s.length;n++)e=M0(s[n],e);return e}function R0(r,t){return r.x-t.x}function M0(r,t){var e=P0(r,t);if(!e)return t;var i=Tc(e,r);return oi(i,i.next),oi(e,e.next)}function P0(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&&Gi(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),As(e,r)&&(d<c||d===c&&(e.x>o.x||e.x===o.x&&O0(o,e)))&&(o=e,c=d)),e=e.next;while(e!==l);return o}function O0(r,t){return Nt(r.prev,r,t.prev)<0&&Nt(t.next,r,r.next)<0}function N0(r,t,e,i){var s=r;do s.z===0&&(s.z=Aa(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,D0(s)}function D0(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 Aa(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 L0(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 Gi(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 B0(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!F0(r,t)&&(As(r,t)&&As(t,r)&&U0(r,t)&&(Nt(r.prev,r,t.prev)||Nt(r,t.prev,t))||En(r,t)&&Nt(r.prev,r,r.next)>0&&Nt(t.prev,t,t.next)>0)}function Nt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function En(r,t){return r.x===t.x&&r.y===t.y}function Ec(r,t,e,i){var s=wn(Nt(r,t,e)),n=wn(Nt(r,t,i)),o=wn(Nt(e,i,r)),a=wn(Nt(e,i,t));return!!(s!==n&&o!==a||s===0&&Tn(r,e,t)||n===0&&Tn(r,i,t)||o===0&&Tn(e,r,i)||a===0&&Tn(e,t,i))}function Tn(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 wn(r){return r>0?1:r<0?-1:0}function F0(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&&Ec(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function As(r,t){return Nt(r.prev,r,r.next)<0?Nt(r,t,r.next)>=0&&Nt(r,r.prev,t)>=0:Nt(r,t,r.prev)<0||Nt(r,r.next,t)<0}function U0(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 Tc(r,t){var e=new Sa(r.i,r.x,r.y),i=new Sa(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 wc(r,t,e,i){var s=new Sa(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 Ss(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 Sa(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}bn.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Ca(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(Ca(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 Ca(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}bn.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 k0=wa.exports;const G0=vc(k0);var An={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */An.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Es=="object"&&Es;(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,b=Math.floor,S=String.fromCharCode,w;function T(M){throw new RangeError(g[M])}function N(M,L){for(var V=M.length,rt=[];V--;)rt[V]=L(M[V]);return rt}function F(M,L){var V=M.split("@"),rt="";V.length>1&&(rt=V[0]+"@",M=V[1]),M=M.replace(v,".");var Q=M.split("."),X=N(Q,L).join(".");return rt+X}function z(M){for(var L=[],V=0,rt=M.length,Q,X;V<rt;)Q=M.charCodeAt(V++),Q>=55296&&Q<=56319&&V<rt?(X=M.charCodeAt(V++),(X&64512)==56320?L.push(((Q&1023)<<10)+(X&1023)+65536):(L.push(Q),V--)):L.push(Q);return L}function C(M){return N(M,function(L){var V="";return L>65535&&(L-=65536,V+=S(L>>>10&1023|55296),L=56320|L&1023),V+=S(L),V}).join("")}function E(M){return M-48<10?M-22:M-65<26?M-65:M-97<26?M-97:l}function I(M,L){return M+22+75*(M<26)-((L!=0)<<5)}function P(M,L,V){var rt=0;for(M=V?b(M/d):M>>1,M+=b(M/L);M>x*u>>1;rt+=l)M=b(M/x);return b(rt+(x+1)*M/(M+c))}function $(M){var L=[],V=M.length,rt,Q=0,X=f,_t=p,St,O,D,ut,lt,Et,Tt,mr,gr;for(St=M.lastIndexOf(m),St<0&&(St=0),O=0;O<St;++O)M.charCodeAt(O)>=128&&T("not-basic"),L.push(M.charCodeAt(O));for(D=St>0?St+1:0;D<V;){for(ut=Q,lt=1,Et=l;D>=V&&T("invalid-input"),Tt=E(M.charCodeAt(D++)),(Tt>=l||Tt>b((a-Q)/lt))&&T("overflow"),Q+=Tt*lt,mr=Et<=_t?h:Et>=_t+u?u:Et-_t,!(Tt<mr);Et+=l)gr=l-mr,lt>b(a/gr)&&T("overflow"),lt*=gr;rt=L.length+1,_t=P(Q-ut,rt,ut==0),b(Q/rt)>a-X&&T("overflow"),X+=b(Q/rt),Q%=rt,L.splice(Q++,0,X)}return C(L)}function k(M){var L,V,rt,Q,X,_t,St,O,D,ut,lt,Et=[],Tt,mr,gr,js;for(M=z(M),Tt=M.length,L=f,V=0,X=p,_t=0;_t<Tt;++_t)lt=M[_t],lt<128&&Et.push(S(lt));for(rt=Q=Et.length,Q&&Et.push(m);rt<Tt;){for(St=a,_t=0;_t<Tt;++_t)lt=M[_t],lt>=L&<<St&&(St=lt);for(mr=rt+1,St-L>b((a-V)/mr)&&T("overflow"),V+=(St-L)*mr,L=St,_t=0;_t<Tt;++_t)if(lt=M[_t],lt<L&&++V>a&&T("overflow"),lt==L){for(O=V,D=l;ut=D<=X?h:D>=X+u?u:D-X,!(O<ut);D+=l)js=O-ut,gr=l-ut,Et.push(S(I(ut+js%gr,0))),O=b(js/gr);Et.push(S(I(O,0))),X=P(V,mr,rt==Q),V=0,++rt}++V,++L}return Et.join("")}function G(M){return F(M,function(L){return y.test(L)?$(L.slice(4).toLowerCase()):L})}function st(M){return F(M,function(L){return _.test(L)?"xn--"+k(L):L})}if(o={version:"1.4.1",ucs2:{decode:z,encode:C},decode:$,encode:k,toASCII:st,toUnicode:G},i&&s)if(r.exports==i)s.exports=o;else for(w in o)o.hasOwnProperty(w)&&(i[w]=o[w]);else e.punycode=o})(Es)}(An,An.exports);var $0=An.exports,$i=TypeError;const H0=E0(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ia=typeof Map=="function"&&Map.prototype,Ra=Object.getOwnPropertyDescriptor&&Ia?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Sn=Ia&&Ra&&typeof Ra.get=="function"?Ra.get:null,Ac=Ia&&Map.prototype.forEach,Ma=typeof Set=="function"&&Set.prototype,Pa=Object.getOwnPropertyDescriptor&&Ma?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Cn=Ma&&Pa&&typeof Pa.get=="function"?Pa.get:null,Sc=Ma&&Set.prototype.forEach,V0=typeof WeakMap=="function"&&WeakMap.prototype,Cs=V0?WeakMap.prototype.has:null,X0=typeof WeakSet=="function"&&WeakSet.prototype,Is=X0?WeakSet.prototype.has:null,z0=typeof WeakRef=="function"&&WeakRef.prototype,Cc=z0?WeakRef.prototype.deref:null,W0=Boolean.prototype.valueOf,Y0=Object.prototype.toString,j0=Function.prototype.toString,q0=String.prototype.match,Oa=String.prototype.slice,Lr=String.prototype.replace,K0=String.prototype.toUpperCase,Ic=String.prototype.toLowerCase,Rc=RegExp.prototype.test,Mc=Array.prototype.concat,or=Array.prototype.join,Z0=Array.prototype.slice,Pc=Math.floor,Na=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Da=Object.getOwnPropertySymbols,La=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Hi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Rs=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Hi||!0)?Symbol.toStringTag:null,Oc=Object.prototype.propertyIsEnumerable,Nc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Dc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Rc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Pc(-r):Pc(r);if(i!==r){var s=String(i),n=Oa.call(t,s.length+1);return Lr.call(s,e,"$&_")+"."+Lr.call(Lr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Lr.call(t,e,"$&_")}var Ba=H0,Lc=Ba.custom,Bc=Gc(Lc)?Lc:null,Fc={__proto__:null,double:'"',single:"'"},Q0={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},In=function r(t,e,i,s){var n=e||{};if(Er(n,"quoteStyle")&&!Er(Fc,n.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Er(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=Er(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(Er(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(Er(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 Hc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Dc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Dc(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 Fa(t)?"[Array]":"[Object]";var c=gv(n,i);if(typeof s>"u")s=[];else if($c(s,t)>=0)return"[Circular]";function d(E,I,P){if(I&&(s=Z0.call(s),s.push(I)),P){var $={depth:n.depth};return Er(n,"quoteStyle")&&($.quoteStyle=n.quoteStyle),r(E,$,i+1,s)}return r(E,n,i+1,s)}if(typeof t=="function"&&!kc(t)){var p=av(t),f=Rn(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+or.call(f,", ")+" }":"")}if(Gc(t)){var m=Hi?Lr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):La.call(t);return typeof t=="object"&&!Hi?Ms(m):m}if(fv(t)){for(var y="<"+Ic.call(String(t.nodeName)),_=t.attributes||[],v=0;v<_.length;v++)y+=" "+_[v].name+"="+Uc(J0(_[v].value),"double",n);return y+=">",t.childNodes&&t.childNodes.length&&(y+="..."),y+="</"+Ic.call(String(t.nodeName))+">",y}if(Fa(t)){if(t.length===0)return"[]";var g=Rn(t,d);return c&&!mv(g)?"["+ka(g,c)+"]":"[ "+or.call(g,", ")+" ]"}if(ev(t)){var x=Rn(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Oc.call(t,"cause")?"{ ["+String(t)+"] "+or.call(Mc.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+or.call(x,", ")+" }"}if(typeof t=="object"&&o){if(Bc&&typeof t[Bc]=="function"&&Ba)return Ba(t,{depth:u-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(lv(t)){var b=[];return Ac&&Ac.call(t,function(E,I){b.push(d(I,t,!0)+" => "+d(E,t))}),Vc("Map",Sn.call(t),b,c)}if(cv(t)){var S=[];return Sc&&Sc.call(t,function(E){S.push(d(E,t))}),Vc("Set",Cn.call(t),S,c)}if(hv(t))return Ua("WeakMap");if(dv(t))return Ua("WeakSet");if(uv(t))return Ua("WeakRef");if(iv(t))return Ms(d(Number(t)));if(nv(t))return Ms(d(Na.call(t)));if(sv(t))return Ms(W0.call(t));if(rv(t))return Ms(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof Es<"u"&&t===Es)return"{ [object globalThis] }";if(!tv(t)&&!kc(t)){var w=Rn(t,d),T=Nc?Nc(t)===Object.prototype:t instanceof Object||t.constructor===Object,N=t instanceof Object?"":"null prototype",F=!T&&Rs&&Object(t)===t&&Rs in t?Oa.call(Br(t),8,-1):N?"Object":"",z=T||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",C=z+(F||N?"["+or.call(Mc.call([],F||[],N||[]),": ")+"] ":"");return w.length===0?C+"{}":c?C+"{"+ka(w,c)+"}":C+"{ "+or.call(w,", ")+" }"}return String(t)};function Uc(r,t,e){var i=e.quoteStyle||t,s=Fc[i];return s+r+s}function J0(r){return Lr.call(String(r),/"/g,""")}function ai(r){return!Rs||!(typeof r=="object"&&(Rs in r||typeof r[Rs]<"u"))}function Fa(r){return Br(r)==="[object Array]"&&ai(r)}function tv(r){return Br(r)==="[object Date]"&&ai(r)}function kc(r){return Br(r)==="[object RegExp]"&&ai(r)}function ev(r){return Br(r)==="[object Error]"&&ai(r)}function rv(r){return Br(r)==="[object String]"&&ai(r)}function iv(r){return Br(r)==="[object Number]"&&ai(r)}function sv(r){return Br(r)==="[object Boolean]"&&ai(r)}function Gc(r){if(Hi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!La)return!1;try{return La.call(r),!0}catch{}return!1}function nv(r){if(!r||typeof r!="object"||!Na)return!1;try{return Na.call(r),!0}catch{}return!1}var ov=Object.prototype.hasOwnProperty||function(r){return r in this};function Er(r,t){return ov.call(r,t)}function Br(r){return Y0.call(r)}function av(r){if(r.name)return r.name;var t=q0.call(j0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function $c(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 lv(r){if(!Sn||!r||typeof r!="object")return!1;try{Sn.call(r);try{Cn.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function hv(r){if(!Cs||!r||typeof r!="object")return!1;try{Cs.call(r,Cs);try{Is.call(r,Is)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function uv(r){if(!Cc||!r||typeof r!="object")return!1;try{return Cc.call(r),!0}catch{}return!1}function cv(r){if(!Cn||!r||typeof r!="object")return!1;try{Cn.call(r);try{Sn.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function dv(r){if(!Is||!r||typeof r!="object")return!1;try{Is.call(r,Is);try{Cs.call(r,Cs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function fv(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Hc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Hc(Oa.call(r,0,t.maxStringLength),t)+i}var s=Q0[t.quoteStyle||"single"];s.lastIndex=0;var n=Lr.call(Lr.call(r,s,"\\$1"),/[\x00-\x1f]/g,pv);return Uc(n,"single",t)}function pv(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":"")+K0.call(t.toString(16))}function Ms(r){return"Object("+r+")"}function Ua(r){return r+" { ? }"}function Vc(r,t,e,i){var s=i?ka(e,i):or.call(e,", ");return r+" ("+t+") {"+s+"}"}function mv(r){for(var t=0;t<r.length;t++)if($c(r[t],`
|
|
3
|
+
`)>=0)return!1;return!0}function gv(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=or.call(Array(r.indent+1)," ");else return null;return{base:e,prev:or.call(Array(t+1),e)}}function ka(r,t){if(r.length===0)return"";var e=`
|
|
4
4
|
`+t.prev+t.base;return e+or.call(r,","+e)+`
|
|
5
|
-
`+t.prev}function Rn(r,t){var e=Fa(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=Er(r,s)?t(r[s],r):""}var n=typeof Da=="function"?Da(r):[],o;if(Hi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)Er(r,l)&&(e&&String(Number(l))===l&&l<r.length||Hi&&o["$"+l]instanceof Symbol||(Mc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Da=="function")for(var h=0;h<n.length;h++)Nc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var vv=In,xv=$i,Mn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},bv=function(r,t){if(r){var e=Mn(r,t);return e&&e.value}},Ev=function(r,t,e){var i=Mn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},Tv=function(r,t){return r?!!Mn(r,t):!1},wv=function(r,t){if(r)return Mn(r,t,!0)},Av=function(){var t,e={assert:function(i){if(!e.has(i))throw new xv("Side channel does not contain "+vv(i))},delete:function(i){var s=t&&t.next,n=wv(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return bv(t,i)},has:function(i){return Tv(t,i)},set:function(i,s){t||(t={next:void 0}),Ev(t,i,s)}};return e},zc=Object,Sv=Error,Cv=EvalError,Iv=RangeError,Rv=ReferenceError,Mv=SyntaxError,Pv=URIError,Ov=Math.abs,Nv=Math.floor,Dv=Math.max,Lv=Math.min,Bv=Math.pow,Fv=Math.round,Uv=Number.isNaN||function(t){return t!==t},kv=Uv,Gv=function(t){return kv(t)||t===0?t:t<0?-1:1},$v=Object.getOwnPropertyDescriptor,Pn=$v;if(Pn)try{Pn([],"length")}catch{Pn=null}var Wc=Pn,On=Object.defineProperty||!1;if(On)try{On({},"a",{value:1})}catch{On=!1}var Hv=On,Ga,Yc;function Vv(){return Yc||(Yc=1,Ga=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}),Ga}var $a,jc;function Xv(){if(jc)return $a;jc=1;var r=typeof Symbol<"u"&&Symbol,t=Vv();return $a=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},$a}var Ha,qc;function Kc(){return qc||(qc=1,Ha=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Ha}var Va,Zc;function Qc(){if(Zc)return Va;Zc=1;var r=zc;return Va=r.getPrototypeOf||null,Va}var zv="Function.prototype.bind called on incompatible ",Wv=Object.prototype.toString,Yv=Math.max,jv="[object Function]",Jc=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},qv=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Kv=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},Zv=function(t){var e=this;if(typeof e!="function"||Wv.apply(e)!==jv)throw new TypeError(zv+e);for(var i=qv(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,Jc(i,arguments));return Object(u)===u?u:this}return e.apply(t,Jc(i,arguments))},o=Yv(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Kv(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},Qv=Zv,Nn=Function.prototype.bind||Qv,Xa=Function.prototype.call,za,td;function ed(){return td||(td=1,za=Function.prototype.apply),za}var Jv=typeof Reflect<"u"&&Reflect&&Reflect.apply,t1=Nn,e1=ed(),r1=Xa,i1=Jv,s1=i1||t1.call(r1,e1),n1=Nn,o1=$i,a1=Xa,l1=s1,rd=function(t){if(t.length<1||typeof t[0]!="function")throw new o1("a function is required");return l1(n1,a1,t)},Wa,id;function h1(){if(id)return Wa;id=1;var r=rd,t=Wc,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 Wa=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,Wa}var Ya,sd;function u1(){if(sd)return Ya;sd=1;var r=Kc(),t=Qc(),e=h1();return Ya=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,Ya}var ja,nd;function c1(){if(nd)return ja;nd=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Nn;return ja=e.call(r,t),ja}var yt,d1=zc,f1=Sv,p1=Cv,m1=Iv,g1=Rv,Vi=Mv,Xi=$i,y1=Pv,_1=Ov,v1=Nv,x1=Dv,b1=Lv,E1=Bv,T1=Fv,w1=Gv,od=Function,qa=function(r){try{return od('"use strict"; return ('+r+").constructor;")()}catch{}},Ps=Wc,A1=Hv,Ka=function(){throw new Xi},S1=Ps?function(){try{return arguments.callee,Ka}catch{try{return Ps(arguments,"callee").get}catch{return Ka}}}():Ka,zi=Xv()(),ie=u1(),C1=Qc(),I1=Kc(),ad=ed(),Os=Xa,Wi={},R1=typeof Uint8Array>"u"||!ie?yt:ie(Uint8Array),li={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?yt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?yt:ArrayBuffer,"%ArrayIteratorPrototype%":zi&&ie?ie([][Symbol.iterator]()):yt,"%AsyncFromSyncIteratorPrototype%":yt,"%AsyncFunction%":Wi,"%AsyncGenerator%":Wi,"%AsyncGeneratorFunction%":Wi,"%AsyncIteratorPrototype%":Wi,"%Atomics%":typeof Atomics>"u"?yt:Atomics,"%BigInt%":typeof BigInt>"u"?yt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?yt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?yt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?yt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":f1,"%eval%":eval,"%EvalError%":p1,"%Float16Array%":typeof Float16Array>"u"?yt:Float16Array,"%Float32Array%":typeof Float32Array>"u"?yt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?yt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?yt:FinalizationRegistry,"%Function%":od,"%GeneratorFunction%":Wi,"%Int8Array%":typeof Int8Array>"u"?yt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?yt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?yt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":zi&&ie?ie(ie([][Symbol.iterator]())):yt,"%JSON%":typeof JSON=="object"?JSON:yt,"%Map%":typeof Map>"u"?yt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!zi||!ie?yt:ie(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":d1,"%Object.getOwnPropertyDescriptor%":Ps,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?yt:Promise,"%Proxy%":typeof Proxy>"u"?yt:Proxy,"%RangeError%":m1,"%ReferenceError%":g1,"%Reflect%":typeof Reflect>"u"?yt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?yt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!zi||!ie?yt:ie(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?yt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":zi&&ie?ie(""[Symbol.iterator]()):yt,"%Symbol%":zi?Symbol:yt,"%SyntaxError%":Vi,"%ThrowTypeError%":S1,"%TypedArray%":R1,"%TypeError%":Xi,"%Uint8Array%":typeof Uint8Array>"u"?yt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?yt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?yt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?yt:Uint32Array,"%URIError%":y1,"%WeakMap%":typeof WeakMap>"u"?yt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?yt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?yt:WeakSet,"%Function.prototype.call%":Os,"%Function.prototype.apply%":ad,"%Object.defineProperty%":A1,"%Object.getPrototypeOf%":C1,"%Math.abs%":_1,"%Math.floor%":v1,"%Math.max%":x1,"%Math.min%":b1,"%Math.pow%":E1,"%Math.round%":T1,"%Math.sign%":w1,"%Reflect.getPrototypeOf%":I1};if(ie)try{null.error}catch(r){var M1=ie(ie(r));li["%Error.prototype%"]=M1}var P1=function r(t){var e;if(t==="%AsyncFunction%")e=qa("async function () {}");else if(t==="%GeneratorFunction%")e=qa("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=qa("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&ie&&(e=ie(s.prototype))}return li[t]=e,e},ld={__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"]},Ns=Nn,Dn=c1(),O1=Ns.call(Os,Array.prototype.concat),N1=Ns.call(ad,Array.prototype.splice),hd=Ns.call(Os,String.prototype.replace),Ln=Ns.call(Os,String.prototype.slice),D1=Ns.call(Os,RegExp.prototype.exec),L1=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,B1=/\\(\\)?/g,F1=function(t){var e=Ln(t,0,1),i=Ln(t,-1);if(e==="%"&&i!=="%")throw new Vi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Vi("invalid intrinsic syntax, expected opening `%`");var s=[];return hd(t,L1,function(n,o,a,l){s[s.length]=a?hd(l,B1,"$1"):o||n}),s},U1=function(t,e){var i=t,s;if(Dn(ld,i)&&(s=ld[i],i="%"+s[0]+"%"),Dn(li,i)){var n=li[i];if(n===Wi&&(n=P1(i)),typeof n>"u"&&!e)throw new Xi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Vi("intrinsic "+t+" does not exist!")},Za=function(t,e){if(typeof t!="string"||t.length===0)throw new Xi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Xi('"allowMissing" argument must be a boolean');if(D1(/^%?[^%]*%?$/,t)===null)throw new Vi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=F1(t),s=i.length>0?i[0]:"",n=U1("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],N1(i,O1([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=Ln(d,0,1),f=Ln(d,-1);if((p==='"'||p==="'"||p==="`"||f==='"'||f==="'"||f==="`")&&p!==f)throw new Vi("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",Dn(li,o))a=li[o];else if(a!=null){if(!(d in a)){if(!e)throw new Xi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Ps&&u+1>=i.length){var m=Ps(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=Dn(a,d),a=a[d];c&&!l&&(li[o]=a)}}return a},ud=Za,cd=rd,k1=cd([ud("%String.prototype.indexOf%")]),dd=function(t,e){var i=ud(t,!!e);return typeof i=="function"&&k1(t,".prototype.")>-1?cd([i]):i},G1=Za,Ds=dd,$1=In,H1=$i,fd=G1("%Map%",!0),V1=Ds("Map.prototype.get",!0),X1=Ds("Map.prototype.set",!0),z1=Ds("Map.prototype.has",!0),W1=Ds("Map.prototype.delete",!0),Y1=Ds("Map.prototype.size",!0),pd=!!fd&&function(){var t,e={assert:function(i){if(!e.has(i))throw new H1("Side channel does not contain "+$1(i))},delete:function(i){if(t){var s=W1(t,i);return Y1(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return V1(t,i)},has:function(i){return t?z1(t,i):!1},set:function(i,s){t||(t=new fd),X1(t,i,s)}};return e},j1=Za,Bn=dd,q1=In,Fn=pd,K1=$i,Yi=j1("%WeakMap%",!0),Z1=Bn("WeakMap.prototype.get",!0),Q1=Bn("WeakMap.prototype.set",!0),J1=Bn("WeakMap.prototype.has",!0),tx=Bn("WeakMap.prototype.delete",!0),ex=Yi?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new K1("Side channel does not contain "+q1(s))},delete:function(s){if(Yi&&s&&(typeof s=="object"||typeof s=="function")){if(t)return tx(t,s)}else if(Fn&&e)return e.delete(s);return!1},get:function(s){return Yi&&s&&(typeof s=="object"||typeof s=="function")&&t?Z1(t,s):e&&e.get(s)},has:function(s){return Yi&&s&&(typeof s=="object"||typeof s=="function")&&t?J1(t,s):!!e&&e.has(s)},set:function(s,n){Yi&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new Yi),Q1(t,s,n)):Fn&&(e||(e=Fn()),e.set(s,n))}};return i}:Fn,rx=$i,ix=In,sx=Av,nx=pd,ox=ex,ax=ox||nx||sx,lx=function(){var t,e={assert:function(i){if(!e.has(i))throw new rx("Side channel does not contain "+ix(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=ax()),t.set(i,s)}};return e},hx=String.prototype.replace,ux=/%20/g,Qa={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ja={default:Qa.RFC3986,formatters:{RFC1738:function(r){return hx.call(r,ux,"+")},RFC3986:function(r){return String(r)}},RFC1738:Qa.RFC1738,RFC3986:Qa.RFC3986},cx=Ja,tl=Object.prototype.hasOwnProperty,hi=Array.isArray,ar=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),dx=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(hi(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},md=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},fx=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(hi(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!tl.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 hi(t)&&!hi(e)&&(s=md(t,i)),hi(t)&&hi(e)?(e.forEach(function(n,o){if(tl.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 tl.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},px=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},mx=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}},el=1024,gx=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+=el){for(var h=o.length>=el?o.slice(l,l+el):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===cx.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=ar[d];continue}if(d<2048){u[u.length]=ar[192|d>>6]+ar[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=ar[224|d>>12]+ar[128|d>>6&63]+ar[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=ar[240|d>>18]+ar[128|d>>12&63]+ar[128|d>>6&63]+ar[128|d&63]}a+=u.join("")}return a},yx=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 dx(e),t},_x=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},vx=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},xx=function(t,e){return[].concat(t,e)},bx=function(t,e){if(hi(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},gd={arrayToObject:md,assign:px,combine:xx,compact:yx,decode:mx,encode:gx,isBuffer:vx,isRegExp:_x,maybeMap:bx,merge:fx},yd=lx,Un=gd,Ls=Ja,Ex=Object.prototype.hasOwnProperty,_d={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},lr=Array.isArray,Tx=Array.prototype.push,vd=function(r,t){Tx.apply(r,lr(t)?t:[t])},wx=Date.prototype.toISOString,xd=Ls.default,Jt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Un.encode,encodeValuesOnly:!1,filter:void 0,format:xd,formatter:Ls.formatters[xd],indices:!1,serializeDate:function(t){return wx.call(t)},skipNulls:!1,strictNullHandling:!1},Ax=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},rl={},Sx=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,b=0,S=!1;(x=x.get(rl))!==void 0&&!S;){var w=x.get(t);if(b+=1,typeof w<"u"){if(w===b)throw new RangeError("Cyclic object value");S=!0}typeof x.get(rl)>"u"&&(b=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=p(g):i==="comma"&&lr(g)&&(g=Un.maybeMap(g,function(M){return M instanceof Date?p(M):M})),g===null){if(o)return h&&!y?h(e,Jt.encoder,_,"key",f):e;g=""}if(Ax(g)||Un.isBuffer(g)){if(h){var T=y?e:h(e,Jt.encoder,_,"key",f);return[m(T)+"="+m(h(g,Jt.encoder,_,"value",f))]}return[m(e)+"="+m(String(g))]}var N=[];if(typeof g>"u")return N;var F;if(i==="comma"&&lr(g))y&&h&&(g=Un.maybeMap(g,h)),F=[{value:g.length>0?g.join(",")||null:void 0}];else if(lr(u))F=u;else{var z=Object.keys(g);F=c?z.sort(c):z}var C=l?String(e).replace(/\./g,"%2E"):String(e),E=s&&lr(g)&&g.length===1?C+"[]":C;if(n&&lr(g)&&g.length===0)return E+"[]";for(var I=0;I<F.length;++I){var P=F[I],$=typeof P=="object"&&P&&typeof P.value<"u"?P.value:g[P];if(!(a&&$===null)){var k=d&&l?String(P).replace(/\./g,"%2E"):String(P),G=lr(g)?typeof i=="function"?i(E,k):E:E+(d?"."+k:"["+k+"]");v.set(t,b);var st=yd();st.set(rl,v),vd(N,r($,G,i,s,n,o,a,l,i==="comma"&&y&&lr(g)?null:h,u,c,d,p,f,m,y,_,st))}}return N},Cx=function(t){if(!t)return Jt;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||Jt.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=Ls.default;if(typeof t.format<"u"){if(!Ex.call(Ls.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Ls.formatters[i],n=Jt.filter;(typeof t.filter=="function"||lr(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in _d?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Jt.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:Jt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Jt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Jt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Jt.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Jt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Jt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Jt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Jt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Jt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Jt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Jt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Jt.strictNullHandling}},Ix=function(r,t){var e=r,i=Cx(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):lr(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=_d[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=yd(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||vd(o,Sx(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:""},ui=gd,il=Object.prototype.hasOwnProperty,bd=Array.isArray,kt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:ui.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},Rx=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},Ed=function(r,t,e){if(r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1)return r.split(",");if(t.throwOnLimitExceeded&&e>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");return r},Mx="utf8=%26%2310003%3B",Px="utf8=%E2%9C%93",Ox=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]===Px?h="utf-8":o[l]===Mx&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var u=o[l],c=u.indexOf("]="),d=c===-1?u.indexOf("="):c+1,p,f;d===-1?(p=e.decoder(u,kt.decoder,h,"key"),f=e.strictNullHandling?null:""):(p=e.decoder(u.slice(0,d),kt.decoder,h,"key"),f=ui.maybeMap(Ed(u.slice(d+1),e,bd(i[p])?i[p].length:0),function(y){return e.decoder(y,kt.decoder,h,"value")})),f&&e.interpretNumericEntities&&h==="iso-8859-1"&&(f=Rx(String(f))),u.indexOf("[]=")>-1&&(f=bd(f)?[f]:f);var m=il.call(i,p);m&&e.duplicates==="combine"?i[p]=ui.combine(i[p],f):(!m||e.duplicates==="last")&&(i[p]=f)}return i},Nx=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:Ed(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)?[]:ui.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},Dx=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&&il.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&&il.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 Nx(u,e,i,s)}},Lx=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"||ui.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}},Bx=function(r,t){var e=Lx(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?Ox(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=Dx(a,i[a],e,typeof r=="string");s=ui.merge(s,l,e)}return e.allowSparse===!0?s:ui.compact(s)},Fx=Ix,Ux=Bx,kx=Ja,Gx={formats:kx,parse:Ux,stringify:Fx},$x=V0;function Tr(){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 Hx=/^([a-z0-9.+-]+:)/i,Vx=/:[0-9]*$/,Xx=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,zx=["<",">",'"',"`"," ","\r",`
|
|
6
|
-
`," "],
|
|
5
|
+
`+t.prev}function Rn(r,t){var e=Fa(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=Er(r,s)?t(r[s],r):""}var n=typeof Da=="function"?Da(r):[],o;if(Hi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)Er(r,l)&&(e&&String(Number(l))===l&&l<r.length||Hi&&o["$"+l]instanceof Symbol||(Rc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Da=="function")for(var h=0;h<n.length;h++)Oc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var yv=In,_v=$i,Mn=function(r,t,e){for(var i=r,s;(s=i.next)!=null;i=s)if(s.key===t)return i.next=s.next,e||(s.next=r.next,r.next=s),s},vv=function(r,t){if(r){var e=Mn(r,t);return e&&e.value}},xv=function(r,t,e){var i=Mn(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},bv=function(r,t){return r?!!Mn(r,t):!1},Ev=function(r,t){if(r)return Mn(r,t,!0)},Tv=function(){var t,e={assert:function(i){if(!e.has(i))throw new _v("Side channel does not contain "+yv(i))},delete:function(i){var s=t&&t.next,n=Ev(t,i);return n&&s&&s===n&&(t=void 0),!!n},get:function(i){return vv(t,i)},has:function(i){return bv(t,i)},set:function(i,s){t||(t={next:void 0}),xv(t,i,s)}};return e},Xc=Object,wv=Error,Av=EvalError,Sv=RangeError,Cv=ReferenceError,Iv=SyntaxError,Rv=URIError,Mv=Math.abs,Pv=Math.floor,Ov=Math.max,Nv=Math.min,Dv=Math.pow,Lv=Math.round,Bv=Number.isNaN||function(t){return t!==t},Fv=Bv,Uv=function(t){return Fv(t)||t===0?t:t<0?-1:1},kv=Object.getOwnPropertyDescriptor,Pn=kv;if(Pn)try{Pn([],"length")}catch{Pn=null}var zc=Pn,On=Object.defineProperty||!1;if(On)try{On({},"a",{value:1})}catch{On=!1}var Gv=On,Ga,Wc;function $v(){return Wc||(Wc=1,Ga=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}),Ga}var $a,Yc;function Hv(){if(Yc)return $a;Yc=1;var r=typeof Symbol<"u"&&Symbol,t=$v();return $a=function(){return typeof r!="function"||typeof Symbol!="function"||typeof r("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},$a}var Ha,jc;function qc(){return jc||(jc=1,Ha=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Ha}var Va,Kc;function Zc(){if(Kc)return Va;Kc=1;var r=Xc;return Va=r.getPrototypeOf||null,Va}var Vv="Function.prototype.bind called on incompatible ",Xv=Object.prototype.toString,zv=Math.max,Wv="[object Function]",Qc=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},Yv=function(t,e){for(var i=[],s=e,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},jv=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},qv=function(t){var e=this;if(typeof e!="function"||Xv.apply(e)!==Wv)throw new TypeError(Vv+e);for(var i=Yv(arguments,1),s,n=function(){if(this instanceof s){var u=e.apply(this,Qc(i,arguments));return Object(u)===u?u:this}return e.apply(t,Qc(i,arguments))},o=zv(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+jv(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},Kv=qv,Nn=Function.prototype.bind||Kv,Xa=Function.prototype.call,Jc=Function.prototype.apply,Zv=typeof Reflect<"u"&&Reflect&&Reflect.apply,Qv=Nn,Jv=Jc,t1=Xa,e1=Zv,r1=e1||Qv.call(t1,Jv),i1=Nn,s1=$i,n1=Xa,o1=r1,td=function(t){if(t.length<1||typeof t[0]!="function")throw new s1("a function is required");return o1(i1,n1,t)},za,ed;function a1(){if(ed)return za;ed=1;var r=td,t=zc,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 za=i&&typeof i.get=="function"?r([i.get]):typeof n=="function"?function(a){return n(a==null?a:s(a))}:!1,za}var Wa,rd;function l1(){if(rd)return Wa;rd=1;var r=qc(),t=Zc(),e=a1();return Wa=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,Wa}var Ya,id;function h1(){if(id)return Ya;id=1;var r=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=Nn;return Ya=e.call(r,t),Ya}var yt,u1=Xc,c1=wv,d1=Av,f1=Sv,p1=Cv,Vi=Iv,Xi=$i,m1=Rv,g1=Mv,y1=Pv,_1=Ov,v1=Nv,x1=Dv,b1=Lv,E1=Uv,sd=Function,ja=function(r){try{return sd('"use strict"; return ('+r+").constructor;")()}catch{}},Ps=zc,T1=Gv,qa=function(){throw new Xi},w1=Ps?function(){try{return arguments.callee,qa}catch{try{return Ps(arguments,"callee").get}catch{return qa}}}():qa,zi=Hv()(),ie=l1(),A1=Zc(),S1=qc(),nd=Jc,Os=Xa,Wi={},C1=typeof Uint8Array>"u"||!ie?yt:ie(Uint8Array),li={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?yt:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?yt:ArrayBuffer,"%ArrayIteratorPrototype%":zi&&ie?ie([][Symbol.iterator]()):yt,"%AsyncFromSyncIteratorPrototype%":yt,"%AsyncFunction%":Wi,"%AsyncGenerator%":Wi,"%AsyncGeneratorFunction%":Wi,"%AsyncIteratorPrototype%":Wi,"%Atomics%":typeof Atomics>"u"?yt:Atomics,"%BigInt%":typeof BigInt>"u"?yt:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?yt:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?yt:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?yt:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":c1,"%eval%":eval,"%EvalError%":d1,"%Float16Array%":typeof Float16Array>"u"?yt:Float16Array,"%Float32Array%":typeof Float32Array>"u"?yt:Float32Array,"%Float64Array%":typeof Float64Array>"u"?yt:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?yt:FinalizationRegistry,"%Function%":sd,"%GeneratorFunction%":Wi,"%Int8Array%":typeof Int8Array>"u"?yt:Int8Array,"%Int16Array%":typeof Int16Array>"u"?yt:Int16Array,"%Int32Array%":typeof Int32Array>"u"?yt:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":zi&&ie?ie(ie([][Symbol.iterator]())):yt,"%JSON%":typeof JSON=="object"?JSON:yt,"%Map%":typeof Map>"u"?yt:Map,"%MapIteratorPrototype%":typeof Map>"u"||!zi||!ie?yt:ie(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":u1,"%Object.getOwnPropertyDescriptor%":Ps,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?yt:Promise,"%Proxy%":typeof Proxy>"u"?yt:Proxy,"%RangeError%":f1,"%ReferenceError%":p1,"%Reflect%":typeof Reflect>"u"?yt:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?yt:Set,"%SetIteratorPrototype%":typeof Set>"u"||!zi||!ie?yt:ie(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?yt:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":zi&&ie?ie(""[Symbol.iterator]()):yt,"%Symbol%":zi?Symbol:yt,"%SyntaxError%":Vi,"%ThrowTypeError%":w1,"%TypedArray%":C1,"%TypeError%":Xi,"%Uint8Array%":typeof Uint8Array>"u"?yt:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?yt:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?yt:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?yt:Uint32Array,"%URIError%":m1,"%WeakMap%":typeof WeakMap>"u"?yt:WeakMap,"%WeakRef%":typeof WeakRef>"u"?yt:WeakRef,"%WeakSet%":typeof WeakSet>"u"?yt:WeakSet,"%Function.prototype.call%":Os,"%Function.prototype.apply%":nd,"%Object.defineProperty%":T1,"%Object.getPrototypeOf%":A1,"%Math.abs%":g1,"%Math.floor%":y1,"%Math.max%":_1,"%Math.min%":v1,"%Math.pow%":x1,"%Math.round%":b1,"%Math.sign%":E1,"%Reflect.getPrototypeOf%":S1};if(ie)try{null.error}catch(r){var I1=ie(ie(r));li["%Error.prototype%"]=I1}var R1=function r(t){var e;if(t==="%AsyncFunction%")e=ja("async function () {}");else if(t==="%GeneratorFunction%")e=ja("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=ja("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&ie&&(e=ie(s.prototype))}return li[t]=e,e},od={__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"]},Ns=Nn,Dn=h1(),M1=Ns.call(Os,Array.prototype.concat),P1=Ns.call(nd,Array.prototype.splice),ad=Ns.call(Os,String.prototype.replace),Ln=Ns.call(Os,String.prototype.slice),O1=Ns.call(Os,RegExp.prototype.exec),N1=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,D1=/\\(\\)?/g,L1=function(t){var e=Ln(t,0,1),i=Ln(t,-1);if(e==="%"&&i!=="%")throw new Vi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new Vi("invalid intrinsic syntax, expected opening `%`");var s=[];return ad(t,N1,function(n,o,a,l){s[s.length]=a?ad(l,D1,"$1"):o||n}),s},B1=function(t,e){var i=t,s;if(Dn(od,i)&&(s=od[i],i="%"+s[0]+"%"),Dn(li,i)){var n=li[i];if(n===Wi&&(n=R1(i)),typeof n>"u"&&!e)throw new Xi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new Vi("intrinsic "+t+" does not exist!")},Ka=function(t,e){if(typeof t!="string"||t.length===0)throw new Xi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new Xi('"allowMissing" argument must be a boolean');if(O1(/^%?[^%]*%?$/,t)===null)throw new Vi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=L1(t),s=i.length>0?i[0]:"",n=B1("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],P1(i,M1([0,1],h)));for(var u=1,c=!0;u<i.length;u+=1){var d=i[u],p=Ln(d,0,1),f=Ln(d,-1);if((p==='"'||p==="'"||p==="`"||f==='"'||f==="'"||f==="`")&&p!==f)throw new Vi("property names with quotes must have matching quotes");if((d==="constructor"||!c)&&(l=!0),s+="."+d,o="%"+s+"%",Dn(li,o))a=li[o];else if(a!=null){if(!(d in a)){if(!e)throw new Xi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Ps&&u+1>=i.length){var m=Ps(a,d);c=!!m,c&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else c=Dn(a,d),a=a[d];c&&!l&&(li[o]=a)}}return a},ld=Ka,hd=td,F1=hd([ld("%String.prototype.indexOf%")]),ud=function(t,e){var i=ld(t,!!e);return typeof i=="function"&&F1(t,".prototype.")>-1?hd([i]):i},U1=Ka,Ds=ud,k1=In,G1=$i,cd=U1("%Map%",!0),$1=Ds("Map.prototype.get",!0),H1=Ds("Map.prototype.set",!0),V1=Ds("Map.prototype.has",!0),X1=Ds("Map.prototype.delete",!0),z1=Ds("Map.prototype.size",!0),dd=!!cd&&function(){var t,e={assert:function(i){if(!e.has(i))throw new G1("Side channel does not contain "+k1(i))},delete:function(i){if(t){var s=X1(t,i);return z1(t)===0&&(t=void 0),s}return!1},get:function(i){if(t)return $1(t,i)},has:function(i){return t?V1(t,i):!1},set:function(i,s){t||(t=new cd),H1(t,i,s)}};return e},W1=Ka,Bn=ud,Y1=In,Fn=dd,j1=$i,Yi=W1("%WeakMap%",!0),q1=Bn("WeakMap.prototype.get",!0),K1=Bn("WeakMap.prototype.set",!0),Z1=Bn("WeakMap.prototype.has",!0),Q1=Bn("WeakMap.prototype.delete",!0),J1=Yi?function(){var t,e,i={assert:function(s){if(!i.has(s))throw new j1("Side channel does not contain "+Y1(s))},delete:function(s){if(Yi&&s&&(typeof s=="object"||typeof s=="function")){if(t)return Q1(t,s)}else if(Fn&&e)return e.delete(s);return!1},get:function(s){return Yi&&s&&(typeof s=="object"||typeof s=="function")&&t?q1(t,s):e&&e.get(s)},has:function(s){return Yi&&s&&(typeof s=="object"||typeof s=="function")&&t?Z1(t,s):!!e&&e.has(s)},set:function(s,n){Yi&&s&&(typeof s=="object"||typeof s=="function")?(t||(t=new Yi),K1(t,s,n)):Fn&&(e||(e=Fn()),e.set(s,n))}};return i}:Fn,tx=$i,ex=In,rx=Tv,ix=dd,sx=J1,nx=sx||ix||rx,ox=function(){var t,e={assert:function(i){if(!e.has(i))throw new tx("Side channel does not contain "+ex(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=nx()),t.set(i,s)}};return e},ax=String.prototype.replace,lx=/%20/g,Za={RFC1738:"RFC1738",RFC3986:"RFC3986"},Qa={default:Za.RFC3986,formatters:{RFC1738:function(r){return ax.call(r,lx,"+")},RFC3986:function(r){return String(r)}},RFC1738:Za.RFC1738,RFC3986:Za.RFC3986},hx=Qa,Ja=Object.prototype.hasOwnProperty,hi=Array.isArray,ar=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),ux=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(hi(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},fd=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},cx=function r(t,e,i){if(!e)return t;if(typeof e!="object"&&typeof e!="function"){if(hi(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!Ja.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 hi(t)&&!hi(e)&&(s=fd(t,i)),hi(t)&&hi(e)?(e.forEach(function(n,o){if(Ja.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 Ja.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},dx=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},fx=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},tl=1024,px=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===hx.RFC1738&&(d===40||d===41)){u[u.length]=h.charAt(c);continue}if(d<128){u[u.length]=ar[d];continue}if(d<2048){u[u.length]=ar[192|d>>6]+ar[128|d&63];continue}if(d<55296||d>=57344){u[u.length]=ar[224|d>>12]+ar[128|d>>6&63]+ar[128|d&63];continue}c+=1,d=65536+((d&1023)<<10|h.charCodeAt(c)&1023),u[u.length]=ar[240|d>>18]+ar[128|d>>12&63]+ar[128|d>>6&63]+ar[128|d&63]}a+=u.join("")}return a},mx=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 ux(e),t},gx=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},yx=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},_x=function(t,e){return[].concat(t,e)},vx=function(t,e){if(hi(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},pd={arrayToObject:fd,assign:dx,combine:_x,compact:mx,decode:fx,encode:px,isBuffer:yx,isRegExp:gx,maybeMap:vx,merge:cx},md=ox,Un=pd,Ls=Qa,xx=Object.prototype.hasOwnProperty,gd={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},lr=Array.isArray,bx=Array.prototype.push,yd=function(r,t){bx.apply(r,lr(t)?t:[t])},Ex=Date.prototype.toISOString,_d=Ls.default,Jt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Un.encode,encodeValuesOnly:!1,filter:void 0,format:_d,formatter:Ls.formatters[_d],indices:!1,serializeDate:function(t){return Ex.call(t)},skipNulls:!1,strictNullHandling:!1},Tx=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},el={},wx=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,b=0,S=!1;(x=x.get(el))!==void 0&&!S;){var w=x.get(t);if(b+=1,typeof w<"u"){if(w===b)throw new RangeError("Cyclic object value");S=!0}typeof x.get(el)>"u"&&(b=0)}if(typeof u=="function"?g=u(e,g):g instanceof Date?g=p(g):i==="comma"&&lr(g)&&(g=Un.maybeMap(g,function(M){return M instanceof Date?p(M):M})),g===null){if(o)return h&&!y?h(e,Jt.encoder,_,"key",f):e;g=""}if(Tx(g)||Un.isBuffer(g)){if(h){var T=y?e:h(e,Jt.encoder,_,"key",f);return[m(T)+"="+m(h(g,Jt.encoder,_,"value",f))]}return[m(e)+"="+m(String(g))]}var N=[];if(typeof g>"u")return N;var F;if(i==="comma"&&lr(g))y&&h&&(g=Un.maybeMap(g,h)),F=[{value:g.length>0?g.join(",")||null:void 0}];else if(lr(u))F=u;else{var z=Object.keys(g);F=c?z.sort(c):z}var C=l?String(e).replace(/\./g,"%2E"):String(e),E=s&&lr(g)&&g.length===1?C+"[]":C;if(n&&lr(g)&&g.length===0)return E+"[]";for(var I=0;I<F.length;++I){var P=F[I],$=typeof P=="object"&&P&&typeof P.value<"u"?P.value:g[P];if(!(a&&$===null)){var k=d&&l?String(P).replace(/\./g,"%2E"):String(P),G=lr(g)?typeof i=="function"?i(E,k):E:E+(d?"."+k:"["+k+"]");v.set(t,b);var st=md();st.set(el,v),yd(N,r($,G,i,s,n,o,a,l,i==="comma"&&y&&lr(g)?null:h,u,c,d,p,f,m,y,_,st))}}return N},Ax=function(t){if(!t)return Jt;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||Jt.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=Ls.default;if(typeof t.format<"u"){if(!xx.call(Ls.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=Ls.formatters[i],n=Jt.filter;(typeof t.filter=="function"||lr(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in gd?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Jt.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:Jt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Jt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Jt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Jt.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Jt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Jt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Jt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Jt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Jt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Jt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Jt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Jt.strictNullHandling}},Sx=function(r,t){var e=r,i=Ax(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):lr(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=gd[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=md(),u=0;u<s.length;++u){var c=s[u],d=e[c];i.skipNulls&&d===null||yd(o,wx(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:""},ui=pd,rl=Object.prototype.hasOwnProperty,vd=Array.isArray,kt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:ui.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},Cx=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},xd=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},Ix="utf8=%26%2310003%3B",Rx="utf8=%E2%9C%93",Mx=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]===Rx?h="utf-8":o[l]===Ix&&(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=ui.maybeMap(xd(u.slice(d+1),e,vd(i[p])?i[p].length:0),function(y){return e.decoder(y,kt.decoder,h,"value")})),f&&e.interpretNumericEntities&&h==="iso-8859-1"&&(f=Cx(String(f))),u.indexOf("[]=")>-1&&(f=vd(f)?[f]:f);var m=rl.call(i,p);m&&e.duplicates==="combine"?i[p]=ui.combine(i[p],f):(!m||e.duplicates==="last")&&(i[p]=f)}return i},Px=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:xd(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)?[]:ui.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},Ox=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&&rl.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&&rl.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 Px(u,e,i,s)}},Nx=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"||ui.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}},Dx=function(r,t){var e=Nx(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?{__proto__:null}:{};for(var i=typeof r=="string"?Mx(r,e):r,s=e.plainObjects?{__proto__:null}:{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=Ox(a,i[a],e,typeof r=="string");s=ui.merge(s,l,e)}return e.allowSparse===!0?s:ui.compact(s)},Lx=Sx,Bx=Dx,Fx=Qa,Ux={formats:Fx,parse:Bx,stringify:Lx},kx=$0;function Tr(){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 Gx=/^([a-z0-9.+-]+:)/i,$x=/:[0-9]*$/,Hx=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,Vx=["<",">",'"',"`"," ","\r",`
|
|
6
|
+
`," "],Xx=["{","}","|","\\","^","`"].concat(Vx),il=["'"].concat(Xx),bd=["%","/","?",";","#"].concat(il),Ed=["/","?","#"],zx=255,Td=/^[+a-z0-9A-Z_-]{0,63}$/,Wx=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Yx={javascript:!0,"javascript:":!0},sl={javascript:!0,"javascript:":!0},ji={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},nl=Ux;function jx(r,t,e){if(r&&typeof r=="object"&&r instanceof Tr)return r;var i=new Tr;return i.parse(r,t,e),i}Tr.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=Hx.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=nl.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=Gx.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&&sl[h])&&(a=a.substr(2),this.slashes=!0)}if(!sl[h]&&(c||h&&!ji[h])){for(var d=-1,p=0;p<Ed.length;p++){var f=a.indexOf(Ed[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<bd.length;p++){var f=a.indexOf(bd[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(Td)){for(var b="",S=0,w=x.length;S<w;S++)x.charCodeAt(S)>127?b+="x":b+=x[S];if(!b.match(Td)){var T=v.slice(0,p),N=v.slice(p+1),F=x.match(Wx);F&&(T.push(F[1]),N.unshift(F[2])),N.length&&(a="/"+N.join(".")+a),this.hostname=T.join(".");break}}}this.hostname.length>zx?this.hostname="":this.hostname=this.hostname.toLowerCase(),_||(this.hostname=kx.toASCII(this.hostname));var z=this.port?":"+this.port:"",C=this.hostname||"";this.host=C+z,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Yx[u])for(var p=0,g=il.length;p<g;p++){var E=il[p];if(a.indexOf(E)!==-1){var I=encodeURIComponent(E);I===E&&(I=escape(E)),a=a.split(E).join(I)}}var P=a.indexOf("#");P!==-1&&(this.hash=a.substr(P),a=a.slice(0,P));var $=a.indexOf("?");if($!==-1?(this.search=a.substr($),this.query=a.substr($+1),t&&(this.query=nl.parse(this.query)),a=a.slice(0,$)):t&&(this.search="",this.query={}),a&&(this.pathname=a),ji[u]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var z=this.pathname||"",k=this.search||"";this.path=z+k}return this.href=this.format(),this},Tr.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=nl.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||ji[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},Tr.prototype.resolve=function(r){return this.resolveObject(jx(r,!1,!0)).format()},Tr.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new Tr;t.parse(r,!1,!0),r=t}for(var e=new Tr,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 ji[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(!ji[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&&!sl[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&&!ji[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 b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.hostname=b.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!v.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var S=v.slice(-1)[0],w=(e.host||r.host||v.length>1)&&(S==="."||S==="..")||S==="",T=0,N=v.length;N>=0;N--)S=v[N],S==="."?v.splice(N,1):S===".."?(v.splice(N,1),T++):T&&(v.splice(N,1),T--);if(!y&&!_)for(;T--;T)v.unshift("..");y&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),w&&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 b=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;b&&(e.auth=b.shift(),e.hostname=b.shift(),e.host=e.hostname)}return y=y||e.host&&v.length,y&&!F&&v.unshift(""),v.length>0?e.pathname=v.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e},Tr.prototype.parseHost=function(){var r=this.host,t=$x.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 wd={};function gt(r,t,e=3){if(wd[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))),Sd[t]=!0}function Xe(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Bs(r){return r.split("?")[0].split("#")[0]}function Zx(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qx(r,t,e){return r.replace(new RegExp(Zx(t),"g"),e)}function Jx(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 se={toPosix(r){return Qx(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Xe(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Xe(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Bs(this.toPosix(t??j.ADAPTER.getBaseUrl())),s=Bs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?se.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Xe(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=Jx(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Xe(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(Xe(i),i.length>0)if(t===void 0)t=i;else{const 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(Xe(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){Xe(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Xe(r),t&&Xe(t),r=Bs(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){Xe(r),r=Bs(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){Xe(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Bs(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 tb(){return al??(al=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return Ce.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 Ce.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?Ce.PMA:Ce.UNPACK})()),al}let ll;function eb(){return typeof ll>"u"&&(ll=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!j.ADAPTER.getWebGLRenderingContext())return!1;const e=j.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}}()),ll}var rb={grad:.9,turn:360,rad:360/(2*Math.PI)},wr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ne=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Be=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Cd=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Id=function(r){return{r:Be(r.r,0,255),g:Be(r.g,0,255),b:Be(r.b,0,255),a:Be(r.a)}},hl=function(r){return{r:ne(r.r),g:ne(r.g),b:ne(r.b),a:ne(r.a,3)}},ib=/^#([0-9a-f]{3,8})$/i,kn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Rd=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}},Md=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}},Pd=function(r){return{h:Cd(r.h),s:Be(r.s,0,100),l:Be(r.l,0,100),a:Be(r.a)}},Od=function(r){return{h:ne(r.h),s:ne(r.s),l:ne(r.l),a:ne(r.a,3)}},Nd=function(r){return Md((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},Fs=function(r){return{h:(t=Rd(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},sb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ob=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ab=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ul={string:[[function(r){var t=ib.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?ne(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?ne(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=ob.exec(r)||ab.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Id({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=sb.exec(r)||nb.exec(r);if(!t)return null;var e,i,s=Pd({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(rb[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Nd(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 wr(t)&&wr(e)&&wr(i)?Id({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(!wr(t)||!wr(e)||!wr(i))return null;var o=Pd({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Nd(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!wr(t)||!wr(e)||!wr(i))return null;var o=function(a){return{h:Cd(a.h),s:Be(a.s,0,100),v:Be(a.v,0,100),a:Be(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Md(o)},"hsv"]]},Dd=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]},lb=function(r){return typeof r=="string"?Dd(r.trim(),ul.string):typeof r=="object"&&r!==null?Dd(r,ul.object):[null,void 0]},cl=function(r,t){var e=Fs(r);return{h:e.h,s:Be(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},Ld=function(r,t){var e=Fs(r);return{h:e.h,s:e.s,l:Be(e.l+100*t,0,100),a:e.a}},fl=function(){function r(t){this.parsed=lb(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 ne(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=hl(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?kn(ne(255*n)):"","#"+kn(e)+kn(i)+kn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return hl(this.rgba)},r.prototype.toRgbString=function(){return t=hl(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 Od(Fs(this.rgba))},r.prototype.toHslString=function(){return t=Od(Fs(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=Rd(this.rgba),{h:ne(t.h),s:ne(t.s),v:ne(t.v),a:ne(t.a,3)};var t},r.prototype.invert=function(){return hr({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),hr(cl(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),hr(cl(this.rgba,-t))},r.prototype.grayscale=function(){return hr(cl(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),hr(Ld(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),hr(Ld(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?hr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ne(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Fs(this.rgba);return typeof t=="number"?hr({h:t,s:e.s,l:e.l,a:e.a}):ne(e.h)},r.prototype.isEqual=function(t){return this.toHex()===hr(t).toHex()},r}(),hr=function(r){return r instanceof fl?r:new fl(r)},Bd=[],hb=function(r){r.forEach(function(t){Bd.indexOf(t)<0&&(t(fl,ul),Bd.push(t))})};function ub(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"])}hb([ub]);const qi=class Bo{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 Bo)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]=Bo.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=Bo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=hr(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)}};qi.shared=new qi,qi.temp=new qi,qi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let wt=qi;function cb(r){return gt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),wt.shared.setValue(r).toHex()}function db(r){return gt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),wt.shared.setValue(r).toNumber()}function fb(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[at.NORMAL_NPM]=at.NORMAL,r[at.ADD_NPM]=at.ADD,r[at.SCREEN_NPM]=at.SCREEN,t[at.NORMAL]=at.NORMAL_NPM,t[at.ADD]=at.ADD_NPM,t[at.SCREEN]=at.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Fd=fb();function Ud(r,t){return Fd[t?1:0][r]}function pb(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 kd(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 Gn(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 Gd(r){return!(r&r-1)&&!!r}function $d(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 Ki(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 Fr(r){return r===0?0:r<0?-1:1}let mb=0;function ci(){return++mb}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 Hd=pl;const Vd={},ur=Object.create(null),Ur=Object.create(null);class gb{constructor(t,e,i){this._canvas=j.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||j.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 Xd(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 zd(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 yb(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&&Xd(s,t,o);)++o;if(o===e)return Hd.EMPTY;for(;Xd(s,t,l);)--l;for(;zd(s,t,n,o,l);)++n;for(;zd(s,t,a,o,l);)--a;return++a,++l,new Hd(n,o,a,l)}function _b(r){const t=yb(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 vb(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 Ar(r,t=1){var i;const e=(i=j.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var W=(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))(W||{});const ml=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},Wd=(r,t)=>ml(r).priority??t,K={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(ml).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(ml).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)=>Wd(n,e)-Wd(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class gl{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 xb=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
12
|
-
`);function
|
|
13
|
-
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function Eb(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=xb.replace(/%forloop%/gi,bb(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const yl=0,_l=1,vl=2,xl=3,bl=4,El=5;class cr{constructor(){this.data=0,this.blendMode=at.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<yl)}set blend(t){!!(this.data&1<<yl)!==t&&(this.data^=1<<yl)}get offsets(){return!!(this.data&1<<_l)}set offsets(t){!!(this.data&1<<_l)!==t&&(this.data^=1<<_l)}get culling(){return!!(this.data&1<<vl)}set culling(t){!!(this.data&1<<vl)!==t&&(this.data^=1<<vl)}get depthTest(){return!!(this.data&1<<xl)}set depthTest(t){!!(this.data&1<<xl)!==t&&(this.data^=1<<xl)}get depthMask(){return!!(this.data&1<<El)}set depthMask(t){!!(this.data&1<<El)!==t&&(this.data^=1<<El)}get clockwiseFrontFace(){return!!(this.data&1<<bl)}set clockwiseFrontFace(t){!!(this.data&1<<bl)!==t&&(this.data^=1<<bl)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==at.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new cr;return t.depthTest=!1,t.blend=!0,t}}cr.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Tl=[];function Yd(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=Tl.length-1;i>=0;--i){const s=Tl[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ze{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,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(ze.prototype,{dispatch:{value:ze.prototype.emit},run:{value:ze.prototype.emit}});class Us{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ze("setRealSize"),this.onUpdate=new ze("update"),this.onError=new ze("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class $n extends Us{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ce.UNPACK);const n=e.realWidth,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 Tb={scaleMode:vr.NEAREST,alphaMode:Ce.NPM},wl=class hs extends Ts{constructor(t=null,e=null){super(),e=Object.assign({},hs.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 Us)&&(t=Yd(t,f),t.internal=!0),this.resolution=p||j.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=ci(),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=Gd(this.realWidth)&&Gd(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Ur[this.cacheId],delete ur[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),hs.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=j.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}_${ci()}`}n=t._pixiId}let o=Ur[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new hs(t,e),o.cacheId=n,hs.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new $n(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=H.RGBA,a=tt.FLOAT):t instanceof Int32Array?(o=H.RGBA_INTEGER,a=tt.INT):t instanceof Uint32Array?(o=H.RGBA_INTEGER,a=tt.UNSIGNED_INT):t instanceof Int16Array?(o=H.RGBA_INTEGER,a=tt.SHORT):t instanceof Uint16Array?(o=H.RGBA_INTEGER,a=tt.UNSIGNED_SHORT):t instanceof Int8Array?(o=H.RGBA,a=tt.BYTE):(o=H.RGBA,a=tt.UNSIGNED_BYTE),n.internal=!0,new hs(n,Object.assign({},Tb,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ur[e]&&Ur[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Ur[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ur[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ur[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Ur[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};wl.defaultOptions={mipmap:ir.POW2,anisotropicLevel:0,scaleMode:vr.LINEAR,wrapMode:Dr.CLAMP,alphaMode:Ce.UNPACK,target:Ui.TEXTURE_2D,format:H.RGBA,type:tt.UNSIGNED_BYTE},wl._globalBatch=0;let ft=wl;class Al{constructor(){this.texArray=null,this.blend=0,this.type=rr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let wb=0;class Vt{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=wb++,this.disposeRunner=new ze("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?nr.ELEMENT_ARRAY_BUFFER:nr.ARRAY_BUFFER}get index(){return this.type===nr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Vt(t)}}class Hn{constructor(t,e=0,i=!1,s=tt.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 Hn(t,e,i,s,n)}}const Ab={Float32Array,Uint32Array,Int32Array,Uint8Array};function Sb(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=kd(u);s[c]||(s[c]=new Ab[c](n)),o=s[c];for(let d=0;d<u.length;d++){const p=(d/h|0)*i+a,f=d%h;o[p+f]=u[d]}a+=h}return new Float32Array(n)}const jd={5126:4,5123:2,5121:1};let Cb=0;const Ib={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class kr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Cb++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ze("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 Vt||(e instanceof Array&&(e=new Float32Array(e)),e=new Vt(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 Hn(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 Vt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Vt(t)),t.type=nr.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Vt;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*jd[n.type]/4),n.buffer=0}for(i.data=Sb(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 Vt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Hn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=nr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new 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 Ib[kd(o.buffers[a].data)](s[a]),e.buffers[a]=new Vt(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=nr.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*jd[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 qd extends kr{constructor(t=!1){super(),this._buffer=new Vt(null,t,!1),this._indexBuffer=new Vt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,tt.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,tt.FLOAT).addAttribute("aColor",this._buffer,4,!0,tt.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,tt.FLOAT).addIndex(this._indexBuffer)}}const Vn=Math.PI*2,Rb=180/Math.PI,Mb=Math.PI/180;var he=(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))(he||{});class bt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new bt(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}}bt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Xn=[new bt,new bt,new bt,new bt];class pt{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=he.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new pt(0,0,0,0)}clone(){return new pt(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const T=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=T)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Xn[0].set(t.left,t.top),l=Xn[1].set(t.left,t.bottom),h=Xn[2].set(t.right,t.top),u=Xn[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,b=v*s+g*n,S=v*i+g*o,w=v*s+g*o;return!(Math.max(x,b,S,w)<=v*a.x+g*a.y||Math.min(x,b,S,w)>=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}}pt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class zn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=he.CIRC}clone(){return new zn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new pt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}zn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Wn{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=he.ELIP}clone(){return new Wn(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new pt(this.x-this.width,this.y-this.height,this.width,this.height)}}Wn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class di{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=he.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new di(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const 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}}di.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Yn{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=he.RREC}clone(){return new Yn(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}}Yn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Rt{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 bt;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 bt;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(Vn-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 Rt;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 Rt}static get TEMP_MATRIX(){return new Rt}}Rt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],gi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Sl=[],Kd=[],jn=Math.sign;function Pb(){for(let r=0;r<16;r++){const t=[];Sl.push(t);for(let e=0;e<16;e++){const i=jn(fi[r]*fi[e]+mi[r]*pi[e]),s=jn(pi[r]*fi[e]+gi[r]*pi[e]),n=jn(fi[r]*mi[e]+mi[r]*gi[e]),o=jn(pi[r]*mi[e]+gi[r]*gi[e]);for(let a=0;a<16;a++)if(fi[a]===i&&pi[a]===s&&mi[a]===n&&gi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Rt;t.set(fi[r],pi[r],mi[r],gi[r],0,0),Kd.push(t)}}Pb();const Dt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>fi[r],uY:r=>pi[r],vX:r=>mi[r],vY:r=>gi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Sl[r][t],sub:(r,t)=>Sl[r][Dt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Dt.S:Dt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Dt.E:Dt.W:t>0?r>0?Dt.SE:Dt.SW:r>0?Dt.NE:Dt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=Kd[Dt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Sr{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 Sr(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))}}Sr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Cl=class{constructor(){this.worldTransform=new Rt,this.localTransform=new Rt,this.position=new Sr(this.onChange,this,0,0),this.scale=new Sr(this.onChange,this,1,1),this.pivot=new Sr(this.onChange,this,0,0),this.skew=new Sr(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())}};Cl.IDENTITY=new Cl;let Il=Cl;Il.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 Ob=`varying vec2 vTextureCoord;
|
|
11
|
+
Deprecated since v${r}`),console.warn(i))),wd[t]=!0}function Xe(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Bs(r){return r.split("?")[0].split("#")[0]}function qx(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kx(r,t,e){return r.replace(new RegExp(qx(t),"g"),e)}function Zx(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 se={toPosix(r){return Kx(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){Xe(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(Xe(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=Bs(this.toPosix(t??j.ADAPTER.getBaseUrl())),s=Bs(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?se.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(Xe(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=Zx(r),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return Xe(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(Xe(i),i.length>0)if(t===void 0)t=i;else{const 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(Xe(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){Xe(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){Xe(r),t&&Xe(t),r=Bs(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){Xe(r),r=Bs(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){Xe(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=Bs(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 ol;async function Qx(){return ol??(ol=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return Ce.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 Ce.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?Ce.PMA:Ce.UNPACK})()),ol}let al;function Jx(){return typeof al>"u"&&(al=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:j.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!j.ADAPTER.getWebGLRenderingContext())return!1;const e=j.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}}()),al}var tb={grad:.9,turn:360,rad:360/(2*Math.PI)},wr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},ne=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Be=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Ad=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Sd=function(r){return{r:Be(r.r,0,255),g:Be(r.g,0,255),b:Be(r.b,0,255),a:Be(r.a)}},ll=function(r){return{r:ne(r.r),g:ne(r.g),b:ne(r.b),a:ne(r.a,3)}},eb=/^#([0-9a-f]{3,8})$/i,kn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Cd=function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:s}},Id=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}},Rd=function(r){return{h:Ad(r.h),s:Be(r.s,0,100),l:Be(r.l,0,100),a:Be(r.a)}},Md=function(r){return{h:ne(r.h),s:ne(r.s),l:ne(r.l),a:ne(r.a,3)}},Pd=function(r){return Id((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},Fs=function(r){return{h:(t=Cd(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},rb=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ib=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nb=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hl={string:[[function(r){var t=eb.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?ne(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?ne(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=sb.exec(r)||nb.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Sd({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=rb.exec(r)||ib.exec(r);if(!t)return null;var e,i,s=Rd({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(tb[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Pd(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 wr(t)&&wr(e)&&wr(i)?Sd({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(!wr(t)||!wr(e)||!wr(i))return null;var o=Rd({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Pd(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!wr(t)||!wr(e)||!wr(i))return null;var o=function(a){return{h:Ad(a.h),s:Be(a.s,0,100),v:Be(a.v,0,100),a:Be(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Id(o)},"hsv"]]},Od=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]},ob=function(r){return typeof r=="string"?Od(r.trim(),hl.string):typeof r=="object"&&r!==null?Od(r,hl.object):[null,void 0]},ul=function(r,t){var e=Fs(r);return{h:e.h,s:Be(e.s+100*t,0,100),l:e.l,a:e.a}},cl=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Nd=function(r,t){var e=Fs(r);return{h:e.h,s:e.s,l:Be(e.l+100*t,0,100),a:e.a}},dl=function(){function r(t){this.parsed=ob(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 ne(cl(this.rgba),2)},r.prototype.isDark=function(){return cl(this.rgba)<.5},r.prototype.isLight=function(){return cl(this.rgba)>=.5},r.prototype.toHex=function(){return t=ll(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?kn(ne(255*n)):"","#"+kn(e)+kn(i)+kn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return ll(this.rgba)},r.prototype.toRgbString=function(){return t=ll(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 Md(Fs(this.rgba))},r.prototype.toHslString=function(){return t=Md(Fs(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Cd(this.rgba),{h:ne(t.h),s:ne(t.s),v:ne(t.v),a:ne(t.a,3)};var t},r.prototype.invert=function(){return hr({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),hr(ul(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),hr(ul(this.rgba,-t))},r.prototype.grayscale=function(){return hr(ul(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),hr(Nd(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),hr(Nd(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?hr({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):ne(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=Fs(this.rgba);return typeof t=="number"?hr({h:t,s:e.s,l:e.l,a:e.a}):ne(e.h)},r.prototype.isEqual=function(t){return this.toHex()===hr(t).toHex()},r}(),hr=function(r){return r instanceof dl?r:new dl(r)},Dd=[],ab=function(r){r.forEach(function(t){Dd.indexOf(t)<0&&(t(dl,hl),Dd.push(t))})};function lb(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"])}ab([lb]);const qi=class Bo{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 Bo)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]=Bo.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=Bo.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=hr(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)}};qi.shared=new qi,qi.temp=new qi,qi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let wt=qi;function hb(r){return gt("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),wt.shared.setValue(r).toHex()}function ub(r){return gt("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),wt.shared.setValue(r).toNumber()}function cb(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[at.NORMAL_NPM]=at.NORMAL,r[at.ADD_NPM]=at.ADD,r[at.SCREEN_NPM]=at.SCREEN,t[at.NORMAL]=at.NORMAL_NPM,t[at.ADD]=at.ADD_NPM,t[at.SCREEN]=at.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const Ld=cb();function Bd(r,t){return Ld[t?1:0][r]}function db(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 Fd(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 Gn(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 Ud(r){return!(r&r-1)&&!!r}function kd(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 Ki(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 Fr(r){return r===0?0:r<0?-1:1}let fb=0;function ci(){return++fb}const fl=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}};fl.EMPTY=new fl(0,0,0,0);let Gd=fl;const $d={},ur=Object.create(null),Ur=Object.create(null);class pb{constructor(t,e,i){this._canvas=j.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||j.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function Hd(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function Vd(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 mb(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&&Hd(s,t,o);)++o;if(o===e)return Gd.EMPTY;for(;Hd(s,t,l);)--l;for(;Vd(s,t,n,o,l);)++n;for(;Vd(s,t,a,o,l);)--a;return++a,++l,new Gd(n,o,a,l)}function gb(r){const t=mb(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 yb(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 Ar(r,t=1){var i;const e=(i=j.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var W=(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))(W||{});const pl=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},Xd=(r,t)=>pl(r).priority??t,K={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(pl).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(pl).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)=>Xd(n,e)-Xd(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class ml{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 _b=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
12
|
+
`);function vb(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 xb(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=_b.replace(/%forloop%/gi,vb(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const gl=0,yl=1,_l=2,vl=3,xl=4,bl=5;class cr{constructor(){this.data=0,this.blendMode=at.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<gl)}set blend(t){!!(this.data&1<<gl)!==t&&(this.data^=1<<gl)}get offsets(){return!!(this.data&1<<yl)}set offsets(t){!!(this.data&1<<yl)!==t&&(this.data^=1<<yl)}get culling(){return!!(this.data&1<<_l)}set culling(t){!!(this.data&1<<_l)!==t&&(this.data^=1<<_l)}get depthTest(){return!!(this.data&1<<vl)}set depthTest(t){!!(this.data&1<<vl)!==t&&(this.data^=1<<vl)}get depthMask(){return!!(this.data&1<<bl)}set depthMask(t){!!(this.data&1<<bl)!==t&&(this.data^=1<<bl)}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!==at.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new cr;return t.depthTest=!1,t.blend=!0,t}}cr.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const El=[];function zd(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=El.length-1;i>=0;--i){const s=El[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class ze{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,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(ze.prototype,{dispatch:{value:ze.prototype.emit},run:{value:ze.prototype.emit}});class Us{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new ze("setRealSize"),this.onUpdate=new ze("update"),this.onError=new ze("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class $n extends Us{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===Ce.UNPACK);const n=e.realWidth,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 bb={scaleMode:vr.NEAREST,alphaMode:Ce.NPM},Tl=class hs extends Ts{constructor(t=null,e=null){super(),e=Object.assign({},hs.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 Us)&&(t=zd(t,f),t.internal=!0),this.resolution=p||j.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=ci(),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=Ud(this.realWidth)&&Ud(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Ur[this.cacheId],delete ur[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),hs.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=j.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}_${ci()}`}n=t._pixiId}let o=Ur[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new hs(t,e),o.cacheId=n,hs.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new $n(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=H.RGBA,a=tt.FLOAT):t instanceof Int32Array?(o=H.RGBA_INTEGER,a=tt.INT):t instanceof Uint32Array?(o=H.RGBA_INTEGER,a=tt.UNSIGNED_INT):t instanceof Int16Array?(o=H.RGBA_INTEGER,a=tt.SHORT):t instanceof Uint16Array?(o=H.RGBA_INTEGER,a=tt.UNSIGNED_SHORT):t instanceof Int8Array?(o=H.RGBA,a=tt.BYTE):(o=H.RGBA,a=tt.UNSIGNED_BYTE),n.internal=!0,new hs(n,Object.assign({},bb,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ur[e]&&Ur[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),Ur[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ur[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ur[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete Ur[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Tl.defaultOptions={mipmap:ir.POW2,anisotropicLevel:0,scaleMode:vr.LINEAR,wrapMode:Dr.CLAMP,alphaMode:Ce.UNPACK,target:Ui.TEXTURE_2D,format:H.RGBA,type:tt.UNSIGNED_BYTE},Tl._globalBatch=0;let ft=Tl;class wl{constructor(){this.texArray=null,this.blend=0,this.type=rr.TRIANGLES,this.start=0,this.size=0,this.data=null}}let Eb=0;class Vt{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=Eb++,this.disposeRunner=new ze("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?nr.ELEMENT_ARRAY_BUFFER:nr.ARRAY_BUFFER}get index(){return this.type===nr.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Vt(t)}}class Hn{constructor(t,e=0,i=!1,s=tt.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 Hn(t,e,i,s,n)}}const Tb={Float32Array,Uint32Array,Int32Array,Uint8Array};function wb(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=Fd(u);s[c]||(s[c]=new Tb[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 Wd={5126:4,5123:2,5121:1};let Ab=0;const Sb={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class kr{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=Ab++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new ze("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 Vt||(e instanceof Array&&(e=new Float32Array(e)),e=new Vt(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 Hn(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 Vt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Vt(t)),t.type=nr.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Vt;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*Wd[n.type]/4),n.buffer=0}for(i.data=wb(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 Vt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new Hn(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=nr.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new 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 Sb[Fd(o.buffers[a].data)](s[a]),e.buffers[a]=new Vt(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=nr.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*Wd[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 Yd extends kr{constructor(t=!1){super(),this._buffer=new Vt(null,t,!1),this._indexBuffer=new Vt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,tt.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,tt.FLOAT).addAttribute("aColor",this._buffer,4,!0,tt.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,tt.FLOAT).addIndex(this._indexBuffer)}}const Vn=Math.PI*2,Cb=180/Math.PI,Ib=Math.PI/180;var he=(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))(he||{});class bt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new bt(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}}bt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const Xn=[new bt,new bt,new bt,new bt];class pt{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=he.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new pt(0,0,0,0)}clone(){return new pt(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const T=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=T)return!1;const N=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>N}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=Xn[0].set(t.left,t.top),l=Xn[1].set(t.left,t.bottom),h=Xn[2].set(t.right,t.top),u=Xn[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,b=v*s+g*n,S=v*i+g*o,w=v*s+g*o;return!(Math.max(x,b,S,w)<=v*a.x+g*a.y||Math.min(x,b,S,w)>=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}}pt.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class zn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=he.CIRC}clone(){return new zn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new pt(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}zn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class Wn{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=he.ELIP}clone(){return new Wn(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new pt(this.x-this.width,this.y-this.height,this.width,this.height)}}Wn.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class di{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=he.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new di(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const 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}}di.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class Yn{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=he.RREC}clone(){return new Yn(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}}Yn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class Rt{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 bt;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 bt;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(Vn-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 Rt;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 Rt}static get TEMP_MATRIX(){return new Rt}}Rt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pi=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],gi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Al=[],jd=[],jn=Math.sign;function Rb(){for(let r=0;r<16;r++){const t=[];Al.push(t);for(let e=0;e<16;e++){const i=jn(fi[r]*fi[e]+mi[r]*pi[e]),s=jn(pi[r]*fi[e]+gi[r]*pi[e]),n=jn(fi[r]*mi[e]+mi[r]*gi[e]),o=jn(pi[r]*mi[e]+gi[r]*gi[e]);for(let a=0;a<16;a++)if(fi[a]===i&&pi[a]===s&&mi[a]===n&&gi[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new Rt;t.set(fi[r],pi[r],mi[r],gi[r],0,0),jd.push(t)}}Rb();const Dt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>fi[r],uY:r=>pi[r],vX:r=>mi[r],vY:r=>gi[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Al[r][t],sub:(r,t)=>Al[r][Dt.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Dt.S:Dt.N:Math.abs(t)*2<=Math.abs(r)?r>0?Dt.E:Dt.W:t>0?r>0?Dt.SE:Dt.SW:r>0?Dt.NE:Dt.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=jd[Dt.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class Sr{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 Sr(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))}}Sr.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Sl=class{constructor(){this.worldTransform=new Rt,this.localTransform=new Rt,this.position=new Sr(this.onChange,this,0,0),this.scale=new Sr(this.onChange,this,1,1),this.pivot=new Sr(this.onChange,this,0,0),this.skew=new Sr(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())}};Sl.IDENTITY=new Sl;let Cl=Sl;Cl.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 Mb=`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
|
-
}`,
|
|
19
|
+
}`,Pb=`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
|
|
30
|
+
`;function qd(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Il(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Kd(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 Il(2*t);case"bvec3":return Il(3*t);case"bvec4":return Il(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 Zi=[{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
|
-
}`}],
|
|
150
|
+
}`}],Ob={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
|
-
}`},
|
|
286
|
+
}`},Nb={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 Db(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<Zi.length;l++)if(Zi[l].test(n,o)){e.push(Zi[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?
|
|
296
|
+
`));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<Zi.length;l++)if(Zi[l].test(n,o)){e.push(Zi[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?Ob:Nb)[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
|
|
301
|
+
`))}const Zd={};let Qi=Zd;function Lb(){if(Qi===Zd||Qi!=null&&Qi.isContextLost()){const r=j.ADAPTER.createCanvas();let t;j.PREFER_ENV>=ni.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Qi=t}return Qi}let qn;function Bb(){if(!qn){qn=Le.MEDIUM;const r=Lb();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(qn=t.precision?Le.HIGH:Le.MEDIUM)}}return qn}function Qd(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
|
|
305
|
-
${r}`}else if(e!==Le.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ks;function
|
|
304
|
+
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Fb(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Qd(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Qd(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Ub={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 Jd(r){return Ub[r]}let Kn=null;const tf={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 ef(r,t){if(!Kn){const e=Object.keys(tf);Kn={};for(let i=0;i<e.length;++i){const s=e[i];Kn[r[s]]=tf[s]}}return Kn[t]}function rf(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===Le.HIGH&&e!==Le.HIGH&&(i=Le.MEDIUM),`precision ${i} float;
|
|
305
|
+
${r}`}else if(e!==Le.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let ks;function kb(){if(typeof ks=="boolean")return ks;try{ks=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{ks=!1}return ks}let Gb=0;const Zn={},Rl=class us{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Gb++,this.vertexSrc=t||us.defaultVertexSrc,this.fragmentSrc=e||us.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,"-"),Zn[i]?(Zn[i]++,i+=`-${Zn[i]}`):Zn[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
|
|
306
306
|
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
|
|
307
|
-
${this.fragmentSrc}`,this.vertexSrc=
|
|
307
|
+
${this.fragmentSrc}`,this.vertexSrc=rf(this.vertexSrc,us.defaultVertexPrecision,Le.HIGH),this.fragmentSrc=rf(this.fragmentSrc,us.defaultFragmentPrecision,Bb())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return Pb}static get defaultFragmentSrc(){return Mb}static from(t,e,i){const s=t+e;let n=$d[s];return n||($d[s]=n=new us(t,e,i)),n}};Rl.defaultVertexPrecision=Le.HIGH,Rl.defaultFragmentPrecision=br.apple.device?Le.HIGH:Le.MEDIUM;let Cr=Rl,$b=0;class We{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=$b++,this.static=!!e,this.ubo=!!i,t instanceof Vt?(this.buffer=t,this.buffer.type=nr.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Vt(new Float32Array(1)),this.buffer.type=nr.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new We(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 We(t,e,i)}static uboFrom(t,e){return new We(t,e??!0,!0)}}class dr{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof We?this.uniformGroup=e:this.uniformGroup=new We(e):this.uniformGroup=new We({}),this.disposeRunner=new ze("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=Cr.from(t,e);return new dr(s,i)}}class Hb{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]=We.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 Cr(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new Rt,default:this.defaultGroupCache[t]};return new dr(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
|
|
315
|
+
`,e}}class Ml{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 Vb(){return!br.apple.device}function Xb(r){let t=!0;const e=j.ADAPTER.getNavigator();if(br.tablet||br.phone){if(br.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(br.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class Qn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var zb=`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
|
-
`,
|
|
325
|
+
`,Wb=`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 Gs=class tr extends Qn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=
|
|
346
|
+
`;const Gs=class tr extends Qn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=Yd,this.vertexSize=6,this.state=cr.for2d(),this.size=tr.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??Xb(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Vb(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return gt("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Wb}static get defaultFragmentTemplate(){return zb}setShaderGenerator({vertex:t=tr.defaultVertexSrc,fragment:e=tr.defaultFragmentTemplate}={}){this.shaderGenerator=new Hb(t,e)}contextChange(){const t=this.renderer.gl;j.PREFER_ENV===ni.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),tr.defaultMaxTextures),this.maxTextures=xb(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}=tr,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new wl);for(;e.length<s;)e.push(new Ml);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=tr._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++ft._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;ft._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=tr._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=Ld[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;tr.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=tr._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),tr.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=Gn(Math.ceil(t/8)),i=kd(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 ml(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=Gn(Math.ceil(t/12)),i=kd(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=wt.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]}};Gs.defaultBatchSize=4096,Gs.extension={name:"batch",type:W.RendererPlugin},Gs._drawCallPool=[],Gs._textureArrayPool=[];let yi=Gs;K.add(yi);var Yb=`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
|
-
`,
|
|
353
|
+
`,jb=`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 Ol=class qs extends dr{constructor(t,e,i){const s=Cr.from(t||qs.defaultVertexSrc,e||qs.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=qs.defaultResolution,this.multisample=qs.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new cr}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 Kb}static get defaultFragmentSrc(){return qb}};Ol.defaultResolution=1,Ol.defaultMultisample=Yt.NONE;let ve=Ol;class Jn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new wt(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(){}}Jn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Jn.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"background"},K.add(Jn);class of{constructor(t){this.renderer=t,this.emptyRenderer=new Qn(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}}of.extension={type:W.RendererSystem,name:"batch"},K.add(of);let af=0;class to{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=af++}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=af++,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(j.PREFER_ENV>=ni.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")}}to.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},to.extension={type:W.RendererSystem,name:"context"},K.add(to);class Nl{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new ze("disposeFramebuffer"),this.multisample=Yt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new ft(null,{scaleMode:vr.NEAREST,resolution:1,mipmap:ir.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new ft(null,{scaleMode:vr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ir.OFF,format:H.DEPTH_COMPONENT,type:tt.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 lf extends ft{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=Yt.NONE),super(null,t),this.mipmap=ir.OFF,this.valid=!0,this._clear=new wt([0,0,0,0]),this.framebuffer=new Nl(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 Ir extends Us{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=vb(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===Ce.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 Ir{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Ir.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??j.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===Ce.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Dl{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Dt.add(i,Dt.NW),this.x0=l+o*Dt.uX(i),this.y0=h+a*Dt.uY(i),i=Dt.add(i,2),this.x1=l+o*Dt.uX(i),this.y1=h+a*Dt.uY(i),i=Dt.add(i,2),this.x2=l+o*Dt.uX(i),this.y2=h+a*Dt.uY(i),i=Dt.add(i,2),this.x3=l+o*Dt.uX(i),this.y3=h+a*Dt.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Dl.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const uf=new Dl;function eo(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Z extends Ts{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new pt(0,0,1,1)),t instanceof Z&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=uf,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 bt(o.x,o.y):new bt(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&&ur[e.url]&&Z.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,Z.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 Z(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===uf&&(this._uvs=new Dl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=j.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof ft){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${ci()}`,ft.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ci()}`}n=t._pixiId}let o=ur[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof ft)?(e.resolution||(e.resolution=Ar(t)),o=new Z(new ft(t,e)),o.baseTexture.cacheId=n,ft.addToCache(o.baseTexture,n),Z.addToCache(o,n)):!o&&t instanceof ft&&(o=new Z(t),Z.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=Z.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 Z(ft.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new ft(t,Object.assign({scaleMode:ft.defaultOptions.scaleMode,resolution:Ar(e)},s)),{resource:o}=n;o instanceof hf&&(o.url=e);const a=new Z(n);return i||(i=e),ft.addToCache(a.baseTexture,i),Z.addToCache(a,i),i!==e&&(ft.addToCache(a.baseTexture,e),Z.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),ur[e]&&ur[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),ur[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ur[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete ur[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)ur[t.textureCacheIds[e]]===t&&delete ur[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 Z._EMPTY||(Z._EMPTY=new Z(new ft),eo(Z._EMPTY),eo(Z._EMPTY.baseTexture)),Z._EMPTY}static get WHITE(){if(!Z._WHITE){const t=j.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Z._WHITE=new Z(ft.from(t)),eo(Z._WHITE),eo(Z._WHITE.baseTexture)}return Z._WHITE}}class _i extends Z{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 _i(new lf(t))}}class cf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Yt.NONE){const s=new lf(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new _i(s)}getOptimalTexture(t,e,i=1,s=Yt.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=Gn(t),e=Gn(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||Yt.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}}}cf.SCREEN_KEY=-1;class Zb extends kr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class df 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 Vt(this.vertices),this.uvBuffer=new Vt(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 Qb{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Yt.NONE,this.sourceFrame=new pt,this.destinationFrame=new pt,this.bindingSourceFrame=new pt,this.bindingDestinationFrame=new pt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ro=[new bt,new bt,new bt,new bt],Ll=new Rt;class ff{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new cf,this.statePool=[],this.quad=new Zb,this.quadUv=new df,this.tempRect=new pt,this.activeState={},this.globalUniforms=new We({outputFrame:new pt,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Qb,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(Ll.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,sr.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,sr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,sr.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=sr.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===sr.CLEAR||e===sr.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(rr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(rr.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(Rt.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=Yt.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||Yt.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=ro[0],s=ro[1],n=ro[2],o=ro[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?Ll.copyFrom(n):Ll.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)}}}ff.extension={type:W.RendererSystem,name:"filter"},K.add(ff);class Jb{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Yt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const tE=new pt;class pf{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Nl(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new pt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;j.PREFER_ENV===ni.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 Jb(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],u=h.parentTextureArray||h;this.renderer.texture.bind(u,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,u._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,u._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Yt.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=Yt.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 Nl(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=tE,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 pt}destroy(){this.renderer=null}}pf.extension={type:W.RendererSystem,name:"framebuffer"},K.add(pf);const Bl={5126:4,5123:2,5121:1};class mf{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;j.PREFER_ENV===ni.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*Bl[d[m].type];for(const m in d){const y=d[m],_=y.size;y.stride===void 0&&(p[y.buffer]===_*Bl[y.type]?y.stride=0:y.stride=p[y.buffer]),y.start===void 0&&(y.start=f[y.buffer],f[y.buffer]+=_*Bl[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(nr.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}}mf.extension={type:W.RendererSystem,name:"geometry"},K.add(mf);const gf=new Rt;class yf{constructor(t,e){this._texture=t,this.mapCoord=new Rt,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&&(gf.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(gf));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var eE=`varying vec2 vMaskCoord;
|
|
379
|
+
`;const Pl=class qs extends dr{constructor(t,e,i){const s=Cr.from(t||qs.defaultVertexSrc,e||qs.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=qs.defaultResolution,this.multisample=qs.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new cr}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 jb}static get defaultFragmentSrc(){return Yb}};Pl.defaultResolution=1,Pl.defaultMultisample=Yt.NONE;let ve=Pl;class Jn{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new wt(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(){}}Jn.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},Jn.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"background"},K.add(Jn);class sf{constructor(t){this.renderer=t,this.emptyRenderer=new Qn(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}}sf.extension={type:W.RendererSystem,name:"batch"},K.add(sf);let nf=0;class to{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=nf++}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=nf++,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(j.PREFER_ENV>=ni.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")}}to.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},to.extension={type:W.RendererSystem,name:"context"},K.add(to);class Ol{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new ze("disposeFramebuffer"),this.multisample=Yt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new ft(null,{scaleMode:vr.NEAREST,resolution:1,mipmap:ir.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new ft(null,{scaleMode:vr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:ir.OFF,format:H.DEPTH_COMPONENT,type:tt.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 of extends ft{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=Yt.NONE),super(null,t),this.mipmap=ir.OFF,this.valid=!0,this._clear=new wt([0,0,0,0]),this.framebuffer=new Ol(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 Ir extends Us{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=yb(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===Ce.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 af extends Ir{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;Ir.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??j.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===Ce.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const 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 Nl{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=Dt.add(i,Dt.NW),this.x0=l+o*Dt.uX(i),this.y0=h+a*Dt.uY(i),i=Dt.add(i,2),this.x1=l+o*Dt.uX(i),this.y1=h+a*Dt.uY(i),i=Dt.add(i,2),this.x2=l+o*Dt.uX(i),this.y2=h+a*Dt.uY(i),i=Dt.add(i,2),this.x3=l+o*Dt.uX(i),this.y3=h+a*Dt.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}}Nl.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 lf=new Nl;function eo(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Z extends Ts{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new pt(0,0,1,1)),t instanceof Z&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=lf,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 bt(o.x,o.y):new bt(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&&ur[e.url]&&Z.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,Z.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 Z(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===lf&&(this._uvs=new Nl),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=j.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof ft){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${ci()}`,ft.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${ci()}`}n=t._pixiId}let o=ur[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof ft)?(e.resolution||(e.resolution=Ar(t)),o=new Z(new ft(t,e)),o.baseTexture.cacheId=n,ft.addToCache(o.baseTexture,n),Z.addToCache(o,n)):!o&&t instanceof ft&&(o=new Z(t),Z.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=Z.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 Z(ft.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new ft(t,Object.assign({scaleMode:ft.defaultOptions.scaleMode,resolution:Ar(e)},s)),{resource:o}=n;o instanceof af&&(o.url=e);const a=new Z(n);return i||(i=e),ft.addToCache(a.baseTexture,i),Z.addToCache(a,i),i!==e&&(ft.addToCache(a.baseTexture,e),Z.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),ur[e]&&ur[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),ur[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=ur[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete ur[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)ur[t.textureCacheIds[e]]===t&&delete ur[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 Z._EMPTY||(Z._EMPTY=new Z(new ft),eo(Z._EMPTY),eo(Z._EMPTY.baseTexture)),Z._EMPTY}static get WHITE(){if(!Z._WHITE){const t=j.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Z._WHITE=new Z(ft.from(t)),eo(Z._WHITE),eo(Z._WHITE.baseTexture)}return Z._WHITE}}class _i extends Z{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 _i(new of(t))}}class hf{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Yt.NONE){const s=new of(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new _i(s)}getOptimalTexture(t,e,i=1,s=Yt.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=Gn(t),e=Gn(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||Yt.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}}}hf.SCREEN_KEY=-1;class qb extends kr{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class uf 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 Vt(this.vertices),this.uvBuffer=new Vt(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 Kb{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Yt.NONE,this.sourceFrame=new pt,this.destinationFrame=new pt,this.bindingSourceFrame=new pt,this.bindingDestinationFrame=new pt,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const ro=[new bt,new bt,new bt,new bt],Dl=new Rt;class cf{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new hf,this.statePool=[],this.quad=new qb,this.quadUv=new uf,this.tempRect=new pt,this.activeState={},this.globalUniforms=new We({outputFrame:new pt,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Kb,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(Dl.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,sr.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,sr.CLEAR,e);const d=h;h=u,u=d}i[c].apply(this,h,l.renderTexture,sr.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=sr.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===sr.CLEAR||e===sr.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(rr.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(rr.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(Rt.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=Yt.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||Yt.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=ro[0],s=ro[1],n=ro[2],o=ro[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?Dl.copyFrom(n):Dl.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)}}}cf.extension={type:W.RendererSystem,name:"filter"},K.add(cf);class Zb{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Yt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const Qb=new pt;class df{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Ol(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new pt,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;j.PREFER_ENV===ni.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 Zb(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=Yt.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=Yt.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 Ol(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=Qb,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 pt}destroy(){this.renderer=null}}df.extension={type:W.RendererSystem,name:"framebuffer"},K.add(df);const Ll={5126:4,5123:2,5121:1};class ff{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;j.PREFER_ENV===ni.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*Ll[d[m].type];for(const m in d){const y=d[m],_=y.size;y.stride===void 0&&(p[y.buffer]===_*Ll[y.type]?y.stride=0:y.stride=p[y.buffer]),y.start===void 0&&(y.start=f[y.buffer],f[y.buffer]+=_*Ll[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(nr.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}}ff.extension={type:W.RendererSystem,name:"geometry"},K.add(ff);const pf=new Rt;class mf{constructor(t,e){this._texture=t,this.mapCoord=new Rt,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&&(pf.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(pf));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 Jb=`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
|
-
`,
|
|
404
|
+
`,tE=`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 iE extends ve{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||rE,e||eE,i),this.maskSprite=s,this.maskMatrix=new Rt}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 yf(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 sE{constructor(t=null){this.type=Qt.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ve.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=Qt.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 _f{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 sE;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!==Qt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Qt.SCISSOR:this.renderer.scissor.push(i);break;case Qt.STENCIL:this.renderer.stencil.push(i);break;case Qt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Qt.COLOR:this.pushColorMask(i);break}i.type===Qt.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Qt.SCISSOR:this.renderer.scissor.pop(e);break;case Qt.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Qt.SPRITE:this.popSpriteMask(e);break;case Qt.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===Qt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Qt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Qt.SCISSOR:t.type=Qt.STENCIL:t.type=Qt.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 iE])),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}}_f.extension={type:W.RendererSystem,name:"mask"},K.add(_f);class vf{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 xf=new Rt,bf=[],Ef=class Fo extends vf{constructor(t){super(t),this.glConst=j.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,bf.pop()??new pt);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()||Fo.isMatrixRotated(e.worldTransform)||Fo.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Fo.isMatrixRotated(n)||(n=n?xf.copyFrom(n):xf.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&&bf.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Ef.extension={type:W.RendererSystem,name:"scissor"};let nE=Ef;K.add(nE);class Tf extends vf{constructor(t){super(t),this.glConst=j.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)}}Tf.extension={type:W.RendererSystem,name:"stencil"},K.add(Tf);class wf{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return gt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return gt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return gt("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}}wf.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"_plugin"},K.add(wf);class Af{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Rt,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}}Af.extension={type:W.RendererSystem,name:"projection"},K.add(Af);const oE=new Il,Sf=new pt;class Cf{constructor(t){this.renderer=t,this._tempMatrix=new Rt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(Sf))||t.getLocalBounds(Sf,!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=_i.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=oE,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}Cf.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"textureGenerator"},K.add(Cf);const vi=new pt,$s=new pt;class If{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new pt,this.destinationFrame=new pt,this.viewportFrame=new pt}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(vi.width=t.frame.width,vi.height=t.frame.height,e=vi),i||($s.x=t.frame.x,$s.y=t.frame.y,$s.width=e.width,$s.height=e.height,i=$s),o=n.framebuffer):(a=s.resolution,e||(vi.width=s._view.screen.width,vi.height=s._view.screen.height,e=vi),i||(i=vi,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=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=wt.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}}If.extension={type:W.RendererSystem,name:"renderTexture"},K.add(If);class aE{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 lE(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=sf(t,n.type),a={type:o,name:n.name,size:ef(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function hE(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=sf(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Qd(l,n.size)}}return e}function uE(r,t){var a;const e=Zd(r,r.VERTEX_SHADER,t.vertexSrc),i=Zd(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)||kb(r,s,e,i),t.attributeData=lE(s,r),t.uniformData=hE(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:Qd(h.type,h.size)}}return new aE(s,o)}function cE(r,t,e,i,s){e.buffer.update(s)}const dE={float:`
|
|
420
|
+
`;class eE extends ve{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||tE,e||Jb,i),this.maskSprite=s,this.maskMatrix=new Rt}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 mf(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 rE{constructor(t=null){this.type=Qt.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ve.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=Qt.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 gf{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 rE;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!==Qt.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Qt.SCISSOR:this.renderer.scissor.push(i);break;case Qt.STENCIL:this.renderer.stencil.push(i);break;case Qt.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Qt.COLOR:this.pushColorMask(i);break}i.type===Qt.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Qt.SCISSOR:this.renderer.scissor.pop(e);break;case Qt.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Qt.SPRITE:this.popSpriteMask(e);break;case Qt.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===Qt.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Qt.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Qt.SCISSOR:t.type=Qt.STENCIL:t.type=Qt.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 eE])),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}}gf.extension={type:W.RendererSystem,name:"mask"},K.add(gf);class yf{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 _f=new Rt,vf=[],xf=class Fo extends yf{constructor(t){super(t),this.glConst=j.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,vf.pop()??new pt);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()||Fo.isMatrixRotated(e.worldTransform)||Fo.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Fo.isMatrixRotated(n)||(n=n?_f.copyFrom(n):_f.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&&vf.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)}};xf.extension={type:W.RendererSystem,name:"scissor"};let iE=xf;K.add(iE);class bf extends yf{constructor(t){super(t),this.glConst=j.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)}}bf.extension={type:W.RendererSystem,name:"stencil"},K.add(bf);class Ef{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return gt("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return gt("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return gt("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}}Ef.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"_plugin"},K.add(Ef);class Tf{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new Rt,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}}Tf.extension={type:W.RendererSystem,name:"projection"},K.add(Tf);const sE=new Cl,wf=new pt;class Af{constructor(t){this.renderer=t,this._tempMatrix=new Rt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(wf))||t.getLocalBounds(wf,!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=_i.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=sE,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}Af.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"textureGenerator"},K.add(Af);const vi=new pt,$s=new pt;class Sf{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new pt,this.destinationFrame=new pt,this.viewportFrame=new pt}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(vi.width=t.frame.width,vi.height=t.frame.height,e=vi),i||($s.x=t.frame.x,$s.y=t.frame.y,$s.width=e.width,$s.height=e.height,i=$s),o=n.framebuffer):(a=s.resolution,e||(vi.width=s._view.screen.width,vi.height=s._view.screen.height,e=vi),i||(i=vi,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=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=wt.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}}Sf.extension={type:W.RendererSystem,name:"renderTexture"},K.add(Sf);class nE{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 oE(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=ef(t,n.type),a={type:o,name:n.name,size:Jd(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function aE(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=ef(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:Kd(l,n.size)}}return e}function lE(r,t){var a;const e=qd(r,r.VERTEX_SHADER,t.vertexSrc),i=qd(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)||Fb(r,s,e,i),t.attributeData=oE(s,r),t.uniformData=aE(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:Kd(h.type,h.size)}}return new nE(s,o)}function hE(r,t,e,i,s){e.buffer.update(s)}const uE={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
|
-
`},
|
|
458
|
+
`},Cf={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 cE(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=Cf[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 dE(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 fE(r,t){if(!r.autoManage)return{size:0,syncFunc:hE};const e=dE(r.uniforms,t),{uboElements:i,size:s}=cE(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<Zi.length;c++){const d=Zi[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Zi[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=
|
|
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<Zi.length;c++){const d=Zi[c];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Zi[c].codeUbo(a.data.name,l)),u=!0;break}}if(!u)if(a.data.size>1){const c=Jd(a.data.type),d=Math.max(Cf[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=
|
|
482
|
+
`)}else{const c=uE[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 gE=0;const io={textureCount:0,uboCount:0};class Mf{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=gE++}systemCheck(){if(!$b())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||(io.textureCount=0,io.uboCount=0,this.syncUniformGroup(t.uniformGroup,io)),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]=Bb(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,io,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]=mE(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=uE(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}}Mf.extension={type:W.RendererSystem,name:"shader"},K.add(Mf);class so{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(){}}so.defaultOptions={hello:!1},so.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"startup"},K.add(so);function yE(r,t=[]){return t[at.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.ADD]=[r.ONE,r.ONE],t[at.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.NONE]=[0,0],t[at.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[at.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[at.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[at.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[at.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[at.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[at.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[at.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[at.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[at.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const _E=0,vE=1,xE=2,bE=3,EE=4,TE=5,Pf=class Ah{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=at.NONE,this._blendEq=!1,this.map=[],this.map[_E]=this.setBlend,this.map[vE]=this.setOffset,this.map[xE]=this.setCullFace,this.map[bE]=this.setDepthTest,this.map[EE]=this.setFrontFace,this.map[TE]=this.setDepthMask,this.checks=[],this.defaultState=new cr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=yE(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(Ah.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Ah.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}};Pf.extension={type:W.RendererSystem,name:"state"};let wE=Pf;K.add(wE);class AE extends Ts{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 ze(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const 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 Hs=class Uo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Uo.defaultMaxIdle,this.checkCountMax=Uo.defaultCheckCountMax,this.mode=Uo.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}};Hs.defaultMode=ba.AUTO,Hs.defaultMaxIdle=60*60,Hs.defaultCheckCountMax=60*10,Hs.extension={type:W.RendererSystem,name:"textureGC"};let xi=Hs;K.add(xi);class Fl{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=tt.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function SE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:Y.FLOAT,[r.RGBA]:Y.FLOAT,[r.ALPHA]:Y.FLOAT,[r.LUMINANCE]:Y.FLOAT,[r.LUMINANCE_ALPHA]:Y.FLOAT,[r.R8]:Y.FLOAT,[r.R8_SNORM]:Y.FLOAT,[r.RG8]:Y.FLOAT,[r.RG8_SNORM]:Y.FLOAT,[r.RGB8]:Y.FLOAT,[r.RGB8_SNORM]:Y.FLOAT,[r.RGB565]:Y.FLOAT,[r.RGBA4]:Y.FLOAT,[r.RGB5_A1]:Y.FLOAT,[r.RGBA8]:Y.FLOAT,[r.RGBA8_SNORM]:Y.FLOAT,[r.RGB10_A2]:Y.FLOAT,[r.RGB10_A2UI]:Y.FLOAT,[r.SRGB8]:Y.FLOAT,[r.SRGB8_ALPHA8]:Y.FLOAT,[r.R16F]:Y.FLOAT,[r.RG16F]:Y.FLOAT,[r.RGB16F]:Y.FLOAT,[r.RGBA16F]:Y.FLOAT,[r.R32F]:Y.FLOAT,[r.RG32F]:Y.FLOAT,[r.RGB32F]:Y.FLOAT,[r.RGBA32F]:Y.FLOAT,[r.R11F_G11F_B10F]:Y.FLOAT,[r.RGB9_E5]:Y.FLOAT,[r.R8I]:Y.INT,[r.R8UI]:Y.UINT,[r.R16I]:Y.INT,[r.R16UI]:Y.UINT,[r.R32I]:Y.INT,[r.R32UI]:Y.UINT,[r.RG8I]:Y.INT,[r.RG8UI]:Y.UINT,[r.RG16I]:Y.INT,[r.RG16UI]:Y.UINT,[r.RG32I]:Y.INT,[r.RG32UI]:Y.UINT,[r.RGB8I]:Y.INT,[r.RGB8UI]:Y.UINT,[r.RGB16I]:Y.INT,[r.RGB16UI]:Y.UINT,[r.RGB32I]:Y.INT,[r.RGB32UI]:Y.UINT,[r.RGBA8I]:Y.INT,[r.RGBA8UI]:Y.UINT,[r.RGBA16I]:Y.INT,[r.RGBA16UI]:Y.UINT,[r.RGBA32I]:Y.INT,[r.RGBA32UI]:Y.UINT,[r.DEPTH_COMPONENT16]:Y.FLOAT,[r.DEPTH_COMPONENT24]:Y.FLOAT,[r.DEPTH_COMPONENT32F]:Y.FLOAT,[r.DEPTH_STENCIL]:Y.FLOAT,[r.DEPTH24_STENCIL8]:Y.FLOAT,[r.DEPTH32F_STENCIL8]:Y.FLOAT}:t={[r.RGB]:Y.FLOAT,[r.RGBA]:Y.FLOAT,[r.ALPHA]:Y.FLOAT,[r.LUMINANCE]:Y.FLOAT,[r.LUMINANCE_ALPHA]:Y.FLOAT,[r.DEPTH_STENCIL]:Y.FLOAT},t}function CE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[tt.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA8,[H.RGB]:r.RGB8,[H.RG]:r.RG8,[H.RED]:r.R8,[H.RGBA_INTEGER]:r.RGBA8UI,[H.RGB_INTEGER]:r.RGB8UI,[H.RG_INTEGER]:r.RG8UI,[H.RED_INTEGER]:r.R8UI,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[tt.BYTE]:{[H.RGBA]:r.RGBA8_SNORM,[H.RGB]:r.RGB8_SNORM,[H.RG]:r.RG8_SNORM,[H.RED]:r.R8_SNORM,[H.RGBA_INTEGER]:r.RGBA8I,[H.RGB_INTEGER]:r.RGB8I,[H.RG_INTEGER]:r.RG8I,[H.RED_INTEGER]:r.R8I},[tt.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:r.RGBA16UI,[H.RGB_INTEGER]:r.RGB16UI,[H.RG_INTEGER]:r.RG16UI,[H.RED_INTEGER]:r.R16UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[tt.SHORT]:{[H.RGBA_INTEGER]:r.RGBA16I,[H.RGB_INTEGER]:r.RGB16I,[H.RG_INTEGER]:r.RG16I,[H.RED_INTEGER]:r.R16I},[tt.UNSIGNED_INT]:{[H.RGBA_INTEGER]:r.RGBA32UI,[H.RGB_INTEGER]:r.RGB32UI,[H.RG_INTEGER]:r.RG32UI,[H.RED_INTEGER]:r.R32UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[tt.INT]:{[H.RGBA_INTEGER]:r.RGBA32I,[H.RGB_INTEGER]:r.RGB32I,[H.RG_INTEGER]:r.RG32I,[H.RED_INTEGER]:r.R32I},[tt.FLOAT]:{[H.RGBA]:r.RGBA32F,[H.RGB]:r.RGB32F,[H.RG]:r.RG32F,[H.RED]:r.R32F,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[tt.HALF_FLOAT]:{[H.RGBA]:r.RGBA16F,[H.RGB]:r.RGB16F,[H.RG]:r.RG16F,[H.RED]:r.R16F},[tt.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB565},[tt.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA4},[tt.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGB5_A1},[tt.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:r.RGB10_A2,[H.RGBA_INTEGER]:r.RGB10_A2UI},[tt.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:r.R11F_G11F_B10F},[tt.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:r.RGB9_E5},[tt.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[tt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[tt.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA,[H.RGB]:r.RGB,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[tt.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB},[tt.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA},[tt.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGBA}},t}class Of{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ft,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=CE(t),this.samplerTypes=SE(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new Fl(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Fl(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==Y.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Fl(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??Y.FLOAT,this.webGLVersion===2&&t.type===tt.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!==Y.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&&Ki(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===ir.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Dr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==ir.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===vr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===vr.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===vr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===vr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Of.extension={type:W.RendererSystem,name:"texture"},K.add(Of);class Nf{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}}Nf.extension={type:W.RendererSystem,name:"transformFeedback"},K.add(Nf);class no{constructor(t){this.renderer=t}init(t){this.screen=new pt(0,0,t.width,t.height),this.element=t.view||j.ADAPTER.createCanvas(),this.resolution=t.resolution||j.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}}no.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},no.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"_view"},K.add(no),j.PREFER_ENV=ni.WEBGL2,j.STRICT_TEXTURE_CACHE=!1,j.RENDER_OPTIONS={...to.defaultOptions,...Jn.defaultOptions,...no.defaultOptions,...so.defaultOptions},Object.defineProperties(j,{WRAP_MODE:{get(){return ft.defaultOptions.wrapMode},set(r){gt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ft.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return ft.defaultOptions.scaleMode},set(r){gt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ft.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return ft.defaultOptions.mipmap},set(r){gt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ft.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return ft.defaultOptions.anisotropicLevel},set(r){gt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ft.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return gt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ve.defaultResolution},set(r){ve.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return gt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ve.defaultMultisample},set(r){ve.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return yi.defaultMaxTextures},set(r){gt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),yi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return yi.defaultBatchSize},set(r){gt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),yi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return yi.canUploadSameBuffer},set(r){gt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),yi.canUploadSameBuffer=r}},GC_MODE:{get(){return xi.defaultMode},set(r){gt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),xi.defaultMode=r}},GC_MAX_IDLE:{get(){return xi.defaultMaxIdle},set(r){gt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),xi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return xi.defaultCheckCountMax},set(r){gt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),xi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Cr.defaultVertexPrecision},set(r){gt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Cr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Cr.defaultFragmentPrecision},set(r){gt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Cr.defaultFragmentPrecision=r}}});var bi=(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))(bi||{});class Ul{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 Df=class Pe{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 Ul(null,null,1/0),this.deltaMS=1/Pe.targetFPMS,this.elapsedMS=1/Pe.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=bi.NORMAL){return this._addListener(new Ul(t,e,i))}addOnce(t,e,i=bi.NORMAL){return this._addListener(new Ul(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*Pe.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,Pe.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(!Pe._shared){const t=Pe._shared=new Pe;t.autoStart=!0,t._protected=!0}return Pe._shared}static get system(){if(!Pe._system){const t=Pe._system=new Pe;t.autoStart=!0,t._protected=!0}return Pe._system}};Df.targetFPMS=.06;let Me=Df;Object.defineProperties(j,{TARGET_FPMS:{get(){return Me.targetFPMS},set(r){gt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Me.targetFPMS=r}}});class Lf{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,bi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Me.shared:new Me,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Lf.extension=W.Application,K.add(Lf);const Bf=[];K.handleByList(W.Renderer,Bf);function Ff(r){for(const t of Bf)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var IE=`attribute vec2 aVertexPosition;
|
|
490
|
+
`))}}let pE=0;const io={textureCount:0,uboCount:0};class If{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=pE++}systemCheck(){if(!kb())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||(io.textureCount=0,io.uboCount=0,this.syncUniformGroup(t.uniformGroup,io)),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]=Db(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,io,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]=fE(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const 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=lE(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}}If.extension={type:W.RendererSystem,name:"shader"},K.add(If);class so{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(){}}so.defaultOptions={hello:!1},so.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"startup"},K.add(so);function mE(r,t=[]){return t[at.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.ADD]=[r.ONE,r.ONE],t[at.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.NONE]=[0,0],t[at.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[at.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[at.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[at.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[at.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[at.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[at.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[at.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[at.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[at.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[at.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const gE=0,yE=1,_E=2,vE=3,xE=4,bE=5,Rf=class wh{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=at.NONE,this._blendEq=!1,this.map=[],this.map[gE]=this.setBlend,this.map[yE]=this.setOffset,this.map[_E]=this.setCullFace,this.map[vE]=this.setDepthTest,this.map[xE]=this.setFrontFace,this.map[bE]=this.setDepthMask,this.checks=[],this.defaultState=new cr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=mE(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(wh.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(wh.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}};Rf.extension={type:W.RendererSystem,name:"state"};let EE=Rf;K.add(EE);class TE extends Ts{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 ze(e)})}addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const 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 Hs=class Uo{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Uo.defaultMaxIdle,this.checkCountMax=Uo.defaultCheckCountMax,this.mode=Uo.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}};Hs.defaultMode=ba.AUTO,Hs.defaultMaxIdle=60*60,Hs.defaultCheckCountMax=60*10,Hs.extension={type:W.RendererSystem,name:"textureGC"};let xi=Hs;K.add(xi);class Bl{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=tt.UNSIGNED_BYTE,this.internalFormat=H.RGBA,this.samplerType=0}}function wE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:Y.FLOAT,[r.RGBA]:Y.FLOAT,[r.ALPHA]:Y.FLOAT,[r.LUMINANCE]:Y.FLOAT,[r.LUMINANCE_ALPHA]:Y.FLOAT,[r.R8]:Y.FLOAT,[r.R8_SNORM]:Y.FLOAT,[r.RG8]:Y.FLOAT,[r.RG8_SNORM]:Y.FLOAT,[r.RGB8]:Y.FLOAT,[r.RGB8_SNORM]:Y.FLOAT,[r.RGB565]:Y.FLOAT,[r.RGBA4]:Y.FLOAT,[r.RGB5_A1]:Y.FLOAT,[r.RGBA8]:Y.FLOAT,[r.RGBA8_SNORM]:Y.FLOAT,[r.RGB10_A2]:Y.FLOAT,[r.RGB10_A2UI]:Y.FLOAT,[r.SRGB8]:Y.FLOAT,[r.SRGB8_ALPHA8]:Y.FLOAT,[r.R16F]:Y.FLOAT,[r.RG16F]:Y.FLOAT,[r.RGB16F]:Y.FLOAT,[r.RGBA16F]:Y.FLOAT,[r.R32F]:Y.FLOAT,[r.RG32F]:Y.FLOAT,[r.RGB32F]:Y.FLOAT,[r.RGBA32F]:Y.FLOAT,[r.R11F_G11F_B10F]:Y.FLOAT,[r.RGB9_E5]:Y.FLOAT,[r.R8I]:Y.INT,[r.R8UI]:Y.UINT,[r.R16I]:Y.INT,[r.R16UI]:Y.UINT,[r.R32I]:Y.INT,[r.R32UI]:Y.UINT,[r.RG8I]:Y.INT,[r.RG8UI]:Y.UINT,[r.RG16I]:Y.INT,[r.RG16UI]:Y.UINT,[r.RG32I]:Y.INT,[r.RG32UI]:Y.UINT,[r.RGB8I]:Y.INT,[r.RGB8UI]:Y.UINT,[r.RGB16I]:Y.INT,[r.RGB16UI]:Y.UINT,[r.RGB32I]:Y.INT,[r.RGB32UI]:Y.UINT,[r.RGBA8I]:Y.INT,[r.RGBA8UI]:Y.UINT,[r.RGBA16I]:Y.INT,[r.RGBA16UI]:Y.UINT,[r.RGBA32I]:Y.INT,[r.RGBA32UI]:Y.UINT,[r.DEPTH_COMPONENT16]:Y.FLOAT,[r.DEPTH_COMPONENT24]:Y.FLOAT,[r.DEPTH_COMPONENT32F]:Y.FLOAT,[r.DEPTH_STENCIL]:Y.FLOAT,[r.DEPTH24_STENCIL8]:Y.FLOAT,[r.DEPTH32F_STENCIL8]:Y.FLOAT}:t={[r.RGB]:Y.FLOAT,[r.RGBA]:Y.FLOAT,[r.ALPHA]:Y.FLOAT,[r.LUMINANCE]:Y.FLOAT,[r.LUMINANCE_ALPHA]:Y.FLOAT,[r.DEPTH_STENCIL]:Y.FLOAT},t}function AE(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[tt.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA8,[H.RGB]:r.RGB8,[H.RG]:r.RG8,[H.RED]:r.R8,[H.RGBA_INTEGER]:r.RGBA8UI,[H.RGB_INTEGER]:r.RGB8UI,[H.RG_INTEGER]:r.RG8UI,[H.RED_INTEGER]:r.R8UI,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[tt.BYTE]:{[H.RGBA]:r.RGBA8_SNORM,[H.RGB]:r.RGB8_SNORM,[H.RG]:r.RG8_SNORM,[H.RED]:r.R8_SNORM,[H.RGBA_INTEGER]:r.RGBA8I,[H.RGB_INTEGER]:r.RGB8I,[H.RG_INTEGER]:r.RG8I,[H.RED_INTEGER]:r.R8I},[tt.UNSIGNED_SHORT]:{[H.RGBA_INTEGER]:r.RGBA16UI,[H.RGB_INTEGER]:r.RGB16UI,[H.RG_INTEGER]:r.RG16UI,[H.RED_INTEGER]:r.R16UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[tt.SHORT]:{[H.RGBA_INTEGER]:r.RGBA16I,[H.RGB_INTEGER]:r.RGB16I,[H.RG_INTEGER]:r.RG16I,[H.RED_INTEGER]:r.R16I},[tt.UNSIGNED_INT]:{[H.RGBA_INTEGER]:r.RGBA32UI,[H.RGB_INTEGER]:r.RGB32UI,[H.RG_INTEGER]:r.RG32UI,[H.RED_INTEGER]:r.R32UI,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[tt.INT]:{[H.RGBA_INTEGER]:r.RGBA32I,[H.RGB_INTEGER]:r.RGB32I,[H.RG_INTEGER]:r.RG32I,[H.RED_INTEGER]:r.R32I},[tt.FLOAT]:{[H.RGBA]:r.RGBA32F,[H.RGB]:r.RGB32F,[H.RG]:r.RG32F,[H.RED]:r.R32F,[H.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[tt.HALF_FLOAT]:{[H.RGBA]:r.RGBA16F,[H.RGB]:r.RGB16F,[H.RG]:r.RG16F,[H.RED]:r.R16F},[tt.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB565},[tt.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA4},[tt.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGB5_A1},[tt.UNSIGNED_INT_2_10_10_10_REV]:{[H.RGBA]:r.RGB10_A2,[H.RGBA_INTEGER]:r.RGB10_A2UI},[tt.UNSIGNED_INT_10F_11F_11F_REV]:{[H.RGB]:r.R11F_G11F_B10F},[tt.UNSIGNED_INT_5_9_9_9_REV]:{[H.RGB]:r.RGB9_E5},[tt.UNSIGNED_INT_24_8]:{[H.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[tt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[H.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[tt.UNSIGNED_BYTE]:{[H.RGBA]:r.RGBA,[H.RGB]:r.RGB,[H.ALPHA]:r.ALPHA,[H.LUMINANCE]:r.LUMINANCE,[H.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[tt.UNSIGNED_SHORT_5_6_5]:{[H.RGB]:r.RGB},[tt.UNSIGNED_SHORT_4_4_4_4]:{[H.RGBA]:r.RGBA},[tt.UNSIGNED_SHORT_5_5_5_1]:{[H.RGBA]:r.RGBA}},t}class Mf{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ft,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=AE(t),this.samplerTypes=wE(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 Bl(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 Bl(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!==Y.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new Bl(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]??Y.FLOAT,this.webGLVersion===2&&t.type===tt.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!==Y.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&&Ki(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===ir.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Dr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==ir.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===vr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===vr.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===vr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===vr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}Mf.extension={type:W.RendererSystem,name:"texture"},K.add(Mf);class Pf{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pf.extension={type:W.RendererSystem,name:"transformFeedback"},K.add(Pf);class no{constructor(t){this.renderer=t}init(t){this.screen=new pt(0,0,t.width,t.height),this.element=t.view||j.ADAPTER.createCanvas(),this.resolution=t.resolution||j.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}}no.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},no.extension={type:[W.RendererSystem,W.CanvasRendererSystem],name:"_view"},K.add(no),j.PREFER_ENV=ni.WEBGL2,j.STRICT_TEXTURE_CACHE=!1,j.RENDER_OPTIONS={...to.defaultOptions,...Jn.defaultOptions,...no.defaultOptions,...so.defaultOptions},Object.defineProperties(j,{WRAP_MODE:{get(){return ft.defaultOptions.wrapMode},set(r){gt("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ft.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return ft.defaultOptions.scaleMode},set(r){gt("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ft.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return ft.defaultOptions.mipmap},set(r){gt("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ft.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return ft.defaultOptions.anisotropicLevel},set(r){gt("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ft.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return gt("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ve.defaultResolution},set(r){ve.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return gt("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ve.defaultMultisample},set(r){ve.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return yi.defaultMaxTextures},set(r){gt("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),yi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return yi.defaultBatchSize},set(r){gt("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),yi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return yi.canUploadSameBuffer},set(r){gt("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),yi.canUploadSameBuffer=r}},GC_MODE:{get(){return xi.defaultMode},set(r){gt("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),xi.defaultMode=r}},GC_MAX_IDLE:{get(){return xi.defaultMaxIdle},set(r){gt("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),xi.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return xi.defaultCheckCountMax},set(r){gt("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),xi.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return Cr.defaultVertexPrecision},set(r){gt("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),Cr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return Cr.defaultFragmentPrecision},set(r){gt("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),Cr.defaultFragmentPrecision=r}}});var bi=(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))(bi||{});class Fl{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 Of=class Pe{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 Fl(null,null,1/0),this.deltaMS=1/Pe.targetFPMS,this.elapsedMS=1/Pe.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=bi.NORMAL){return this._addListener(new Fl(t,e,i))}addOnce(t,e,i=bi.NORMAL){return this._addListener(new Fl(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*Pe.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,Pe.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(!Pe._shared){const t=Pe._shared=new Pe;t.autoStart=!0,t._protected=!0}return Pe._shared}static get system(){if(!Pe._system){const t=Pe._system=new Pe;t.autoStart=!0,t._protected=!0}return Pe._system}};Of.targetFPMS=.06;let Me=Of;Object.defineProperties(j,{TARGET_FPMS:{get(){return Me.targetFPMS},set(r){gt("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),Me.targetFPMS=r}}});class Nf{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,bi.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Me.shared:new Me,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Nf.extension=W.Application,K.add(Nf);const Df=[];K.handleByList(W.Renderer,Df);function Lf(r){for(const t of Df)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var SE=`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
|
-
}`,
|
|
501
|
+
}`,CE=`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 ME=IE,Uf=RE;class kf{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>=Yt.HIGH?this.multisample=Yt.HIGH:e>=Yt.MEDIUM?this.multisample=Yt.MEDIUM:e>=Yt.LOW?this.multisample=Yt.LOW:this.multisample=Yt.NONE}destroy(){}}kf.extension={type:W.RendererSystem,name:"_multisample"},K.add(kf);class PE{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Gf{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 PE(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Gf.extension={type:W.RendererSystem,name:"buffer"},K.add(Gf);class $f{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}}$f.extension={type:W.RendererSystem,name:"objectRenderer"},K.add($f);const oo=class Sh extends AE{constructor(t){super(),this.type=ac.WEBGL,t=Object.assign({},j.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new We({projectionMatrix:new Rt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Sh.__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&&(gt("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=Sh.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:eb()}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 gt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return gt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return gt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return gt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){gt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return gt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){gt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return gt("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)}};oo.extension={type:W.Renderer,priority:1},oo.__plugins={},oo.__systems={};let kl=oo;K.handleByMap(W.RendererPlugin,kl.__plugins),K.handleByMap(W.RendererSystem,kl.__systems),K.add(kl);class Hf extends Us{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 ft;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 Us?this.addResourceAt(t[i],i):this.addResourceAt(Yd(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 OE extends Hf{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=Ui.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 NE extends Ir{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const Vf=class Ks extends Hf{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Ks.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Ks.SIDES;a++)this.items[a].target=Ui.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=Ui.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=Ui.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<Ks.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===Ks.SIDES}};Vf.SIDES=6;let DE=Vf;class Ji extends Ir{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Ji.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 j.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ce.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ji._EMPTY=Ji._EMPTY??j.ADAPTER.createCanvas(0,0),Ji._EMPTY}}const Gl=class ko extends Ir{constructor(t,e){e=e||{},super(j.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;Ir.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_${ci()}`,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)}};Gl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Gl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let $l=Gl;class LE extends Ir{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Hl=class Ch extends Ir{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];Ir.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||Ch.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=Me.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&&(Me.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||(Me.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Me.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Ch.TYPES.includes(e)}};Hl.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Hl.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Xf=Hl;Tl.push(Ji,hf,NE,Xf,LE,$l,$n,DE,OE);class ao{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?pt.EMPTY:(t=t||new pt(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d: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,b=u*g+l*v+d;p=Math.min(p,x-n),m=Math.max(m,x+n),f=Math.min(f,b-o),y=Math.max(y,b+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 Lt extends Ts{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Il,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 ao,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(Lt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new pt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ao);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 BE),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*Rb}set angle(t){this.transform.rotation=t*Mb}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 BE extends Lt{constructor(){super(...arguments),this.sortDirty=null}}Lt.prototype.displayObjectUpdateTransform=Lt.prototype.updateTransform;const FE=new Rt;function UE(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const zf=class Ih extends Lt{constructor(){super(),this.children=[],this.sortableChildren=Ih.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);Ki(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,Ki(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,Ki(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(UE),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!==Ih.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=FE.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!==Qt.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}};zf.defaultSortableChildren=!1;let Ye=zf;Ye.prototype.containerUpdateTransform=Ye.prototype.updateTransform,Object.defineProperties(j,{SORTABLE_CHILDREN:{get(){return Ye.defaultSortableChildren},set(r){gt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Ye.defaultSortableChildren=r}}});const Vs=new bt,kE=new Uint16Array([0,1,2,0,2,3]);class ts extends Ye{constructor(t){super(),this._anchor=new Sr(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 wt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=at.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Z.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=kE,this.pluginName="batch",this.isSprite=!0,this._roundPixels=j.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Fr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Fr(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 _=j.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=j.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 ao),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Vs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Vs.x>=s&&Vs.x<s+e&&(n=-i*this.anchor.y,Vs.y>=n&&Vs.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 Z?t:Z.from(t,e);return new ts(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=Fr(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=Fr(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||Z.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Wf=new Rt;Lt.prototype._cacheAsBitmap=!1,Lt.prototype._cacheData=null,Lt.prototype._cacheAsBitmapResolution=null,Lt.prototype._cacheAsBitmapMultisample=null;class GE{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(Lt.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 GE),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)}}}),Lt.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))},Lt.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new pt,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=_i.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${ci()}`;this._cacheData.textureCacheId=h,ft.addToCache(l.baseTexture,h),Z.addToCache(l,h);const u=this.transform.localTransform.copyTo(Wf).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 ts(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)},Lt.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))},Lt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new pt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=_i.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${ci()}`;this._cacheData.textureCacheId=a,ft.addToCache(o.baseTexture,a),Z.addToCache(o,a);const l=Wf;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 ts(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)},Lt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Lt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Lt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ft.removeFromCache(this._cacheData.textureCacheId),Z.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Lt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Lt.prototype.name=null,Ye.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},Lt.prototype.getGlobalPosition=function(r=new bt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var $E=`varying vec2 vTextureCoord;
|
|
527
|
+
`;const IE=SE,Bf=CE;class Ff{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>=Yt.HIGH?this.multisample=Yt.HIGH:e>=Yt.MEDIUM?this.multisample=Yt.MEDIUM:e>=Yt.LOW?this.multisample=Yt.LOW:this.multisample=Yt.NONE}destroy(){}}Ff.extension={type:W.RendererSystem,name:"_multisample"},K.add(Ff);class RE{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Uf{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 RE(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Uf.extension={type:W.RendererSystem,name:"buffer"},K.add(Uf);class kf{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}}kf.extension={type:W.RendererSystem,name:"objectRenderer"},K.add(kf);const oo=class Ah extends TE{constructor(t){super(),this.type=oc.WEBGL,t=Object.assign({},j.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new We({projectionMatrix:new Rt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Ah.__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&&(gt("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=Ah.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:Jx()}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 gt("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return gt("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return gt("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return gt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){gt("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return gt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){gt("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return gt("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)}};oo.extension={type:W.Renderer,priority:1},oo.__plugins={},oo.__systems={};let Ul=oo;K.handleByMap(W.RendererPlugin,Ul.__plugins),K.handleByMap(W.RendererSystem,Ul.__systems),K.add(Ul);class Gf extends Us{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 ft;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 Us?this.addResourceAt(t[i],i):this.addResourceAt(zd(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 ME extends Gf{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=Ui.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 PE extends Ir{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const $f=class Ks extends Gf{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==Ks.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Ks.SIDES;a++)this.items[a].target=Ui.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=Ui.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=Ui.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<Ks.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===Ks.SIDES}};$f.SIDES=6;let OE=$f;class Ji extends Ir{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Ji.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 j.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Ce.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ji._EMPTY=Ji._EMPTY??j.ADAPTER.createCanvas(0,0),Ji._EMPTY}}const kl=class ko extends Ir{constructor(t,e){e=e||{},super(j.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;Ir.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_${ci()}`,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)}};kl.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,kl.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let Gl=kl;class NE extends Ir{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const $l=class Sh extends Ir{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];Ir.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||Sh.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=Me.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&&(Me.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||(Me.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Me.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Sh.TYPES.includes(e)}};$l.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],$l.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Hf=$l;El.push(Ji,af,PE,Hf,NE,Gl,$n,OE,ME);class ao{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?pt.EMPTY:(t=t||new pt(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d: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,b=u*g+l*v+d;p=Math.min(p,x-n),m=Math.max(m,x+n),f=Math.min(f,b-o),y=Math.max(y,b+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 Lt extends Ts{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Cl,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 ao,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(Lt.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new pt),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds||(this._localBounds=new ao);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 DE),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*Cb}set angle(t){this.transform.rotation=t*Ib}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 DE extends Lt{constructor(){super(...arguments),this.sortDirty=null}}Lt.prototype.displayObjectUpdateTransform=Lt.prototype.updateTransform;const LE=new Rt;function BE(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const Vf=class Ch extends Lt{constructor(){super(),this.children=[],this.sortableChildren=Ch.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);Ki(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,Ki(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,Ki(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(BE),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!==Ch.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=LE.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!==Qt.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}};Vf.defaultSortableChildren=!1;let Ye=Vf;Ye.prototype.containerUpdateTransform=Ye.prototype.updateTransform,Object.defineProperties(j,{SORTABLE_CHILDREN:{get(){return Ye.defaultSortableChildren},set(r){gt("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),Ye.defaultSortableChildren=r}}});const Vs=new bt,FE=new Uint16Array([0,1,2,0,2,3]);class ts extends Ye{constructor(t){super(),this._anchor=new Sr(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 wt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=at.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Z.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=FE,this.pluginName="batch",this.isSprite=!0,this._roundPixels=j.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=Fr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=Fr(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 _=j.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=j.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 ao),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new pt),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,Vs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return Vs.x>=s&&Vs.x<s+e&&(n=-i*this.anchor.y,Vs.y>=n&&Vs.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 Z?t:Z.from(t,e);return new ts(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=Fr(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=Fr(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||Z.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const Xf=new Rt;Lt.prototype._cacheAsBitmap=!1,Lt.prototype._cacheData=null,Lt.prototype._cacheAsBitmapResolution=null,Lt.prototype._cacheAsBitmapMultisample=null;class UE{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(Lt.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 UE),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)}}}),Lt.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))},Lt.prototype._initCachedDisplayObject=function(r){var d,p;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new pt,!0);if((p=this.filters)!=null&&p.length){const f=this.filters[0].padding;e.pad(f)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=_i.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${ci()}`;this._cacheData.textureCacheId=h,ft.addToCache(l.baseTexture,h),Z.addToCache(l,h);const u=this.transform.localTransform.copyTo(Xf).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 ts(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)},Lt.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))},Lt.prototype._initCachedDisplayObjectCanvas=function(r){var u;if((u=this._cacheData)!=null&&u.sprite)return;const t=this.getLocalBounds(new pt,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=_i.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${ci()}`;this._cacheData.textureCacheId=a,ft.addToCache(o.baseTexture,a),Z.addToCache(o,a);const l=Xf;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 ts(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)},Lt.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Lt.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Lt.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,ft.removeFromCache(this._cacheData.textureCacheId),Z.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Lt.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Lt.prototype.name=null,Ye.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},Lt.prototype.getGlobalPosition=function(r=new bt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var kE=`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
|
|
537
|
-
`);function
|
|
538
|
-
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const
|
|
536
|
+
`;class GE extends ve{constructor(t=1){super(IE,kE,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const $E={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]},HE=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
|
537
|
+
`);function VE(r){const t=$E[r],e=t.length;let i=HE,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 XE=`
|
|
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
|
|
569
|
-
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}class
|
|
568
|
+
}`;function zE(r,t){const e=Math.ceil(r/2);let i=XE,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 Hl extends ve{constructor(t,e=8,i=4,s=ve.defaultResolution,n=5){const o=zE(n,t),a=VE(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,sr.CLEAR);for(let h=1;h<this.passes-1;h++){t.bindAndClear(a,sr.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 WE extends ve{constructor(t=8,e=4,i=ve.defaultResolution,s=5){super(),this._repeatEdgePixels=!1,this.blurXFilter=new Hl(!0,t,e,i,s),this.blurYFilter=new Hl(!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,sr.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 YE=`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
|
|
621
|
+
`;class Vl extends ve{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(Bf,YE,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]=wt.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=wt.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}}Vl.prototype.grayscale=Vl.prototype.greyscale;var jE=`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
|
-
`,
|
|
641
|
+
`,qE=`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
|
|
670
|
+
`;class KE extends ve{constructor(t,e){const i=new Rt;t.renderable=!1,super(qE,jE,{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 bt(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 ZE=`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
|
-
`,
|
|
791
|
+
`,QE=`
|
|
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
|
|
833
|
+
`;class JE extends ve{constructor(){super(QE,ZE)}}var tT=`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 iT extends ve{constructor(t=.5,e=Math.random()){super(Uf,rT,{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 Yf={AlphaFilter:HE,BlurFilter:jE,BlurFilterPass:Vl,ColorMatrixFilter:Xl,DisplacementFilter:QE,FXAAFilter:eT,NoiseFilter:iT};Object.entries(Yf).forEach(([r,t])=>{Object.defineProperty(Yf,r,{get(){return gt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class sT{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(Me.system.add(this.tickerUpdate,this,bi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Me.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 Gr=new sT;class Xs{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Xs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new bt,this.page=new bt,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 lo extends Xs{constructor(){super(...arguments),this.client=new bt,this.movement=new bt,this.offset=new bt,this.global=new bt,this.screen=new bt}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 je extends lo{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 es extends lo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}es.DOM_DELTA_PIXEL=0,es.DOM_DELTA_LINE=1,es.DOM_DELTA_PAGE=2;const nT=2048,oT=new bt,zl=new bt;class aT{constructor(t){this.dispatch=new Ts,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){Gr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,oT.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<nT&&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")&&(Gr.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")&&(Gr.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,zl),!t.hitArea.contains(zl.x,zl.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 je)){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 je)){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 je)){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 je)){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 je)){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 je)){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 es)){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(je);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(es);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(je);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 je&&e instanceof je&&(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 lo&&e instanceof lo&&(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 lT=1,hT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Wl=class Rh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new aT(null),Gr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new je(null),this.rootWheelEvent=new es(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Rh.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,Rh._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,Gr.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,Gr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Gr.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;Gr.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=lT),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=hT[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}};Wl.extension={name:"events",type:[W.RendererSystem,W.CanvasRendererSystem]},Wl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Yl=Wl;K.add(Yl);function jf(r){return r==="dynamic"||r==="static"}const uT={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??jf(Yl.defaultEventMode)},set interactive(r){gt("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??Yl.defaultEventMode},set eventMode(r){this._internalInteractive=jf(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 Xs))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}};Lt.mixin(uT);const cT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Lt.mixin(cT);const dT=9,ho=100,fT=0,pT=0,qf=2,Kf=1,mT=-1e3,gT=-1e3,yT=2;class Zf{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,(br.tablet||br.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${ho}px`,e.style.height=`${ho}px`,e.style.position="absolute",e.style.top=`${fT}px`,e.style.left=`${pT}px`,e.style.zIndex=qf.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=`${Kf}px`,t.style.height=`${Kf}px`,t.style.position="absolute",t.style.top=`${mT}px`,t.style.left=`${gT}px`,t.style.zIndex=yT.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(br.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,Ki(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=`${ho}px`,e.style.height=`${ho}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=qf.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 Xs(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===dT&&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}}Zf.extension={name:"accessibility",type:[W.RendererPlugin,W.CanvasRendererPlugin]},K.add(Zf);const Qf=class Mh{constructor(t){this.stage=new Ye,t=Object.assign({forceCanvas:!1},t),this.renderer=Ff(t),Mh._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=Mh._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}};Qf._plugins=[];let _T=Qf;K.handleByList(W.Application,_T._plugins);class Jf{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}}Jf.extension=W.Application,K.add(Jf);const tp={loader:W.LoadParser,resolver:W.ResolveParser,cache:W.CacheParser,detection:W.DetectionParser};K.handle(W.Asset,r=>{const t=r.ref;Object.entries(tp).filter(([e])=>!!t[e]).forEach(([e,i])=>K.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(tp).filter(e=>!!t[e]).forEach(e=>K.remove(t[e]))});class vT{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 rs(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 $r(r,t){const e=r.split("?")[0],i=se.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const qe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),jl=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function ep(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?ep(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function xT(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)}),ep(r,s,0,e,i)}else i.push(r);return i}const uo=r=>!Array.isArray(r);class bT{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=qe(t);let 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 Z){const a=e;i.forEach(l=>{a.baseTexture!==Z.EMPTY.baseTexture&&ft.addToCache(a.baseTexture,l),Z.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 Ei=new bT;class ET{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=uo(t),o=qe(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=se.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=qe(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=se.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 Ke=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ke||{});const
|
|
867
|
+
`;class eT extends ve{constructor(t=.5,e=Math.random()){super(Bf,tT,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const zf={AlphaFilter:GE,BlurFilter:WE,BlurFilterPass:Hl,ColorMatrixFilter:Vl,DisplacementFilter:KE,FXAAFilter:JE,NoiseFilter:eT};Object.entries(zf).forEach(([r,t])=>{Object.defineProperty(zf,r,{get(){return gt("7.1.0",`filters.${r} has moved to ${r}`),t}})});class rT{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||(Me.system.add(this.tickerUpdate,this,bi.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(Me.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 Gr=new rT;class Xs{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Xs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new bt,this.page=new bt,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 lo extends Xs{constructor(){super(...arguments),this.client=new bt,this.movement=new bt,this.offset=new bt,this.global=new bt,this.screen=new bt}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 je extends lo{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 es extends lo{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}es.DOM_DELTA_PIXEL=0,es.DOM_DELTA_LINE=1,es.DOM_DELTA_PAGE=2;const iT=2048,sT=new bt,Xl=new bt;class nT{constructor(t){this.dispatch=new Ts,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){Gr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,sT.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<iT&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(Gr.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")&&(Gr.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,Xl),!t.hitArea.contains(Xl.x,Xl.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 je)){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 je)){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 je)){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 je)){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 je)){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 je)){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 es)){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(je);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(es);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(je);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 je&&e instanceof je&&(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 lo&&e instanceof lo&&(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 oT=1,aT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},zl=class Ih{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new nT(null),Gr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new je(null),this.rootWheelEvent=new es(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Ih.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,Ih._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,Gr.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,Gr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;Gr.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;Gr.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=oT),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=aT[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}};zl.extension={name:"events",type:[W.RendererSystem,W.CanvasRendererSystem]},zl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Wl=zl;K.add(Wl);function Wf(r){return r==="dynamic"||r==="static"}const lT={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??Wf(Wl.defaultEventMode)},set interactive(r){gt("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??Wl.defaultEventMode},set eventMode(r){this._internalInteractive=Wf(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 Xs))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}};Lt.mixin(lT);const hT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Lt.mixin(hT);const uT=9,ho=100,cT=0,dT=0,Yf=2,jf=1,fT=-1e3,pT=-1e3,mT=2;class qf{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,(br.tablet||br.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${ho}px`,e.style.height=`${ho}px`,e.style.position="absolute",e.style.top=`${cT}px`,e.style.left=`${dT}px`,e.style.zIndex=Yf.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=`${jf}px`,t.style.height=`${jf}px`,t.style.position="absolute",t.style.top=`${fT}px`,t.style.left=`${pT}px`,t.style.zIndex=mT.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(br.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,Ki(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=`${ho}px`,e.style.height=`${ho}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=Yf.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 Xs(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===uT&&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}}qf.extension={name:"accessibility",type:[W.RendererPlugin,W.CanvasRendererPlugin]},K.add(qf);const Kf=class Rh{constructor(t){this.stage=new Ye,t=Object.assign({forceCanvas:!1},t),this.renderer=Lf(t),Rh._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=Rh._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}};Kf._plugins=[];let gT=Kf;K.handleByList(W.Application,gT._plugins);class Zf{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Zf.extension=W.Application,K.add(Zf);const Qf={loader:W.LoadParser,resolver:W.ResolveParser,cache:W.CacheParser,detection:W.DetectionParser};K.handle(W.Asset,r=>{const t=r.ref;Object.entries(Qf).filter(([e])=>!!t[e]).forEach(([e,i])=>K.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(Qf).filter(e=>!!t[e]).forEach(e=>K.remove(t[e]))});class yT{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 rs(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 $r(r,t){const e=r.split("?")[0],i=se.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const qe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Yl=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Jf(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?Jf(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function _T(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)}),Jf(r,s,0,e,i)}else i.push(r);return i}const uo=r=>!Array.isArray(r);class vT{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=qe(t);let 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 Z){const a=e;i.forEach(l=>{a.baseTexture!==Z.EMPTY.baseTexture&&ft.addToCache(a.baseTexture,l),Z.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 Ei=new vT;class xT{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=uo(t),o=qe(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const u=se.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=qe(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=se.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 Ke=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ke||{});const bT=".json",ET="application/json",TT={extension:{type:W.LoadParser,priority:Ke.Low},name:"loadJson",test(r){return rs(r,ET)||$r(r,bT)},async load(r){return await(await j.ADAPTER.fetch(r)).json()}};K.add(TT);const wT=".txt",AT="text/plain",ST={name:"loadTxt",extension:{type:W.LoadParser,priority:Ke.Low},test(r){return rs(r,AT)||$r(r,wT)},async load(r){return await(await j.ADAPTER.fetch(r)).text()}};K.add(ST);const CT=["normal","bold","100","200","300","400","500","600","700","800","900"],IT=[".ttf",".otf",".woff",".woff2"],RT=["font/ttf","font/otf","font/woff","font/woff2"],MT=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function PT(r){const t=se.extname(r),e=se.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(MT)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const OT=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function NT(r){return OT.test(r)?r:encodeURI(r)}const DT={extension:{type:W.LoadParser,priority:Ke.Low},name:"loadWebFont",test(r){return rs(r,RT)||$r(r,IT)},async load(r,t){var i,s,n;const e=j.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??PT(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(u=>CT.includes(u)))??["normal"],h=t.data??{};for(let u=0;u<l.length;u++){const c=l[u],d=new FontFace(a,`url(${NT(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=>j.ADAPTER.getFontFaceSet().delete(t))}};K.add(DT);const LT=`(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=qe
|
|
|
882
882
|
self.postMessage(result);
|
|
883
883
|
});
|
|
884
884
|
})();
|
|
885
|
-
`;let is=null,
|
|
885
|
+
`;let is=null,jl=class{constructor(){is||(is=URL.createObjectURL(new Blob([LT],{type:"application/javascript"}))),this.worker=new Worker(is)}};jl.revokeObjectURL=function(){is&&(URL.revokeObjectURL(is),is=null)};const BT=`(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=qe
|
|
|
908
908
|
}
|
|
909
909
|
};
|
|
910
910
|
})();
|
|
911
|
-
`;let ss=null;class
|
|
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`)},qe(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=qe(h||u).map(_=>typeof _=="string"?xT(_):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 b=this._parsers[x];if(b.test(v)){g=b.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=uo(t);t=qe(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=uo(t);t=qe(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=se.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??se.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class KT{constructor(){this._detections=[],this._initialized=!1,this.resolver=new qT,this.loader=new ET,this.cache=Ei,this._backgroundLoader=new vT(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=uo(t),s=qe(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),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 Ei.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ei.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,Ei.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=qe(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=qe(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=>{Ei.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 co.config.preferWorkers}set preferWorkers(t){gt("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 fo=new KT;K.handleByList(W.LoadParser,fo.loader.parsers).handleByList(W.ResolveParser,fo.resolver.parsers).handleByList(W.CacheParser,fo.cache.parsers).handleByList(W.DetectionParser,fo.detections);const ZT={extension:W.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof Z),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};K.add(ZT);async function np(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 QT={extension:{type:W.DetectionParser,priority:1},test:async()=>np("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};K.add(QT);const JT={extension:{type:W.DetectionParser,priority:0},test:async()=>np("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};K.add(JT);const op=["png","jpg","jpeg"],tw={extension:{type:W.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...op],remove:async r=>r.filter(t=>!op.includes(t))};K.add(tw);const ew="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Zl(r){return ew?!1:document.createElement("video").canPlayType(r)!==""}const rw={extension:{type:W.DetectionParser,priority:0},test:async()=>Zl("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};K.add(rw);const iw={extension:{type:W.DetectionParser,priority:0},test:async()=>Zl("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};K.add(iw);const sw={extension:{type:W.DetectionParser,priority:0},test:async()=>Zl("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};K.add(sw);const nw={extension:W.ResolveParser,test:co.test,parse:r=>{var t;return{resolution:parseFloat(((t=j.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:se.extname(r).slice(1),src:r}}};K.add(nw);var ue=(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))(ue||{});const po={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let fr,ns;function ap(){ns={bptc:fr.getExtension("EXT_texture_compression_bptc"),astc:fr.getExtension("WEBGL_compressed_texture_astc"),etc:fr.getExtension("WEBGL_compressed_texture_etc"),s3tc:fr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:fr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:fr.getExtension("WEBGL_compressed_texture_pvrtc")||fr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:fr.getExtension("WEBGL_compressed_texture_etc1"),atc:fr.getExtension("WEBGL_compressed_texture_atc")}}const ow={extension:{type:W.DetectionParser,priority:2},test:async()=>{const r=j.ADAPTER.createCanvas().getContext("webgl");return r?(fr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{ns||ap();const t=[];for(const e in ns)ns[e]&&t.push(e);return[...t,...r]},remove:async r=>(ns||ap(),r.filter(t=>!(t in ns)))};K.add(ow);class aw extends $n{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 gl(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 gl(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ti extends aw{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Ti._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ti._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,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=Ti._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,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*po[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*po[e];return l}}const Ql=4,mo=124,lw=32,lp=20,hw=542327876,go={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},uw={FOURCC:2},yo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},cw=1,dw=2,fw=4,pw=64,mw=512,gw=131072,yw=827611204,_w=861165636,vw=894720068,xw=808540228,bw=4,Ew={[yw]:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,[_w]:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,[vw]:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT},Tw={70:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:ue.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:ue.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:ue.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:ue.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function ww(r){const t=new Uint32Array(r);if(t[0]!==hw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,mo/Uint32Array.BYTES_PER_ELEMENT),i=e[go.HEIGHT],s=e[go.WIDTH],n=e[go.MIPMAP_COUNT],o=new Uint32Array(r,go.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,lw/Uint32Array.BYTES_PER_ELEMENT),a=o[cw];if(a&fw){const l=o[uw.FOURCC];if(l!==xw){const v=Ew[l],g=Ql+mo,x=new Uint8Array(r,g);return[new Ti(x,{format:v,width:s,height:i,levels:n})]}const h=Ql+mo,u=new Uint32Array(t.buffer,h,lp/Uint32Array.BYTES_PER_ELEMENT),c=u[yo.DXGI_FORMAT],d=u[yo.RESOURCE_DIMENSION],p=u[yo.MISC_FLAG],f=u[yo.ARRAY_SIZE],m=Tw[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===bw)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,_=Ql+mo+lp;if(f===1)y.push(new Uint8Array(r,_));else{const v=po[m];let g=0,x=s,b=i;for(let w=0;w<n;w++){const T=Math.max(1,x+3&-4),N=Math.max(1,b+3&-4),F=T*N*v;g+=F,x=x>>>1,b=b>>>1}let S=_;for(let w=0;w<f;w++)y.push(new Uint8Array(r,S,g)),S+=g}return y.map(v=>new Ti(v,{format:m,width:s,height:i,levels:n}))}throw a&pw?new Error("DDSParser does not support uncompressed texture data."):a&mw?new Error("DDSParser does not supported YUV uncompressed texture data."):a&gw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&dw?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],Aw=67305985,Ze={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Jl=64,up={[tt.UNSIGNED_BYTE]:1,[tt.UNSIGNED_SHORT]:2,[tt.INT]:4,[tt.UNSIGNED_INT]:4,[tt.FLOAT]:4,[tt.HALF_FLOAT]:8},Sw={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Cw={[tt.UNSIGNED_SHORT_4_4_4_4]:2,[tt.UNSIGNED_SHORT_5_5_5_1]:2,[tt.UNSIGNED_SHORT_5_6_5]:2};function Iw(r,t,e=!1){const i=new DataView(t);if(!Rw(r,i))return null;const s=i.getUint32(Ze.ENDIANNESS,!0)===Aw,n=i.getUint32(Ze.GL_TYPE,s),o=i.getUint32(Ze.GL_FORMAT,s),a=i.getUint32(Ze.GL_INTERNAL_FORMAT,s),l=i.getUint32(Ze.PIXEL_WIDTH,s),h=i.getUint32(Ze.PIXEL_HEIGHT,s)||1,u=i.getUint32(Ze.PIXEL_DEPTH,s)||1,c=i.getUint32(Ze.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Ze.NUMBER_OF_FACES,s),p=i.getUint32(Ze.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(Ze.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 b;if(n!==0?up[n]?b=up[n]*Sw[o]:b=Cw[n]:b=po[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const S=e?Pw(i,f,s):null;let w=x*b,T=l,N=h,F=_,z=v,C=Jl+f;for(let E=0;E<p;E++){const I=i.getUint32(C,s);let P=C+4;for(let $=0;$<c;$++){let k=g[$];k||(k=g[$]=new Array(p)),k[E]={levelID:E,levelWidth:p>1||n!==0?T:F,levelHeight:p>1||n!==0?N:z,levelBuffer:new Uint8Array(t,P,w)},P+=w}C+=I+4,C=C%4!==0?C+4-C%4:C,T=T>>1||1,N=N>>1||1,F=T+m-1&-4,z=N+y-1&-4,w=F*z*b}return n!==0?{uncompressed:g.map(E=>{let I=E[0].levelBuffer,P=!1;return n===tt.FLOAT?I=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===tt.UNSIGNED_INT?(P=!0,I=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===tt.INT&&(P=!0,I=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new $n(I,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:P?Mw(o):o}}),kvData:S}:{compressed:g.map(E=>new Ti(null,{format:a,width:l,height:h,levels:p,levelBuffers:E})),kvData:S}}function Rw(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 Mw(r){switch(r){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return r}}function Pw(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(Jl+s,e),o=Jl+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 Ow={extension:{type:W.LoadParser,priority:Ke.High},name:"loadDDS",test(r){return $r(r,".dds")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),s=ww(i).map(n=>{const o=new ft(n,{mipmap:ir.OFF,alphaMode:Ce.NO_PREMULTIPLIED_ALPHA,resolution:Ar(r),...t.data});return zs(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};K.add(Ow);const Nw={extension:{type:W.LoadParser,priority:Ke.High},name:"loadKTX",test(r){return $r(r,".ktx")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Iw(r,i),a=s??n,l={mipmap:ir.OFF,alphaMode:Ce.NO_PREMULTIPLIED_ALPHA,resolution:Ar(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 ft(c,l);return d.ktxKeyValueData=o,zs(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};K.add(Nw);const Dw=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Lw={extension:W.ResolveParser,test:r=>{const t=se.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(Dw.includes(n))return{resolution:parseFloat(((i=j.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=j.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};K.add(Lw);const _o=new pt,Bw=4,cp=class Zs{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&&Zs._flipY(i,s,n),a&&Zs._unpremultiplyAlpha(i);const l=new gb(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&&Zs._flipY(i,s,n),a&&Zs._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 _i?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(_o.width=e.width,_o.height=e.height,e=_o)));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===H.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=_o,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(Bw*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}}}};cp.extension={name:"extract",type:W.RendererSystem};let Fw=cp;K.add(Fw);const vo={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===he.CIRC){const f=r.shape;e=f.x,i=f.y,o=a=f.radius,s=n=0}else if(r.type===he.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+_,b=i-_;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=b,t[--p]=b,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!==he.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 dp(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 fp={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){dp(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];dp(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=H0(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])}}},Uw={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)}},kw={build(r){vo.build(r)},triangulate(r,t){vo.triangulate(r,t)}};var Fe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Fe||{}),Hr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Hr||{});const os={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 pp{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,b=y*u+_*l,S=h*(_+v),w=l*(_+v),T=c*(y+g),N=u*(y+g),F=Math.atan2(w-b,S-x),z=Math.atan2(N-b,T-x);return{cx:x+t,cy:b+e,radius:n,startAngle:F,endAngle:z,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=os._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/Vn)*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,b=Math.cos(x),S=-Math.sin(x);h.push((f*b+m*S)*n+i,(f*-S+m*b)*n+s)}}}class Gw{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 th{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,b=e;for(let S=1;S<=10;++S)u=S/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=b-_,x=y,b=_,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=os._segmentsCount(th.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 mp(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 wi(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 $w(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 bt(i[0],i[1]),a=new bt(i[i.length-2],i[i.length-1]),l=e.type!==he.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 k=(o.x+a.x)*.5,G=(a.y+o.y)*.5;i.unshift(k,G),i.push(k,G)}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],b=0,S=0,w=-(v-x),T=_-g,N=0,F=0,z=Math.sqrt(w*w+T*T);w/=z,T/=z,w*=f,T*=f;const C=n.alignment,E=(1-C)*2,I=C*2;l||(n.cap===Hr.ROUND?d+=wi(_-w*(E-I)*.5,v-T*(E-I)*.5,_-w*E,v-T*E,_+w*I,v+T*I,u,!0)+2:n.cap===Hr.SQUARE&&(d+=mp(_,v,w,T,E,I,!0,u))),u.push(_-w*E,v-T*E,_+w*I,v+T*I);for(let k=1;k<c-1;++k){_=i[(k-1)*2],v=i[(k-1)*2+1],g=i[k*2],x=i[k*2+1],b=i[(k+1)*2],S=i[(k+1)*2+1],w=-(v-x),T=_-g,z=Math.sqrt(w*w+T*T),w/=z,T/=z,w*=f,T*=f,N=-(x-S),F=g-b,z=Math.sqrt(N*N+F*F),N/=z,F/=z,N*=f,F*=f;const G=g-_,st=v-x,M=g-b,L=S-x,V=G*M+st*L,rt=st*M-L*G,Q=rt<0;if(Math.abs(rt)<.001*Math.abs(V)){u.push(g-w*E,x-T*E,g+w*I,x+T*I),V>=0&&(n.join===Fe.ROUND?d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+4:d+=2,u.push(g-N*I,x-F*I,g+N*E,x+F*E));continue}const X=(-w+_)*(-T+x)-(-w+g)*(-T+v),_t=(-N+b)*(-F+x)-(-N+g)*(-F+S),St=(G*_t-M*X)/rt,O=(L*X-st*_t)/rt,D=(St-g)*(St-g)+(O-x)*(O-x),ut=g+(St-g)*E,lt=x+(O-x)*E,Et=g-(St-g)*I,Tt=x-(O-x)*I,mr=Math.min(G*G+st*st,M*M+L*L),gr=Q?E:I,js=mr+gr*gr*m,IC=D<=js;let Lo=n.join;if(Lo===Fe.MITER&&D/m>y&&(Lo=Fe.BEVEL),IC)switch(Lo){case Fe.MITER:{u.push(ut,lt,Et,Tt);break}case Fe.BEVEL:{Q?u.push(ut,lt,g+w*I,x+T*I,ut,lt,g+N*I,x+F*I):u.push(g-w*E,x-T*E,Et,Tt,g-N*E,x-F*E,Et,Tt),d+=2;break}case Fe.ROUND:{Q?(u.push(ut,lt,g+w*I,x+T*I),d+=wi(g,x,g+w*I,x+T*I,g+N*I,x+F*I,u,!0)+4,u.push(ut,lt,g+N*I,x+F*I)):(u.push(g-w*E,x-T*E,Et,Tt),d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+4,u.push(g-N*E,x-F*E,Et,Tt));break}}else{switch(u.push(g-w*E,x-T*E,g+w*I,x+T*I),Lo){case Fe.MITER:{Q?u.push(Et,Tt,Et,Tt):u.push(ut,lt,ut,lt),d+=2;break}case Fe.ROUND:{Q?d+=wi(g,x,g+w*I,x+T*I,g+N*I,x+F*I,u,!0)+2:d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+2;break}}u.push(g-N*E,x-F*E,g+N*I,x+F*I),d+=2}}_=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],w=-(v-x),T=_-g,z=Math.sqrt(w*w+T*T),w/=z,T/=z,w*=f,T*=f,u.push(g-w*E,x-T*E,g+w*I,x+T*I),l||(n.cap===Hr.ROUND?d+=wi(g-w*(E-I)*.5,x-T*(E-I)*.5,g-w*E,x-T*E,g+w*I,x+T*I,u,!1)+2:n.cap===Hr.SQUARE&&(d+=mp(g,x,w,T,E,I,!1,u)));const P=t.indices,$=os.epsilon*os.epsilon;for(let k=p;k<d+p-2;++k)_=u[k*2],v=u[k*2+1],g=u[(k+1)*2],x=u[(k+1)*2+1],b=u[(k+2)*2],S=u[(k+2)*2+1],!(Math.abs(_*(x-S)+g*(S-v)+b*(v-x))<$)&&P.push(k,k+1,k+2)}function Hw(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==he.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 gp(r,t){r.lineStyle.native?Hw(r,t):$w(r,t)}class eh{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=os._segmentsCount(eh.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 rh={[he.POLY]:fp,[he.CIRC]:vo,[he.ELIP]:vo,[he.RECT]:Uw,[he.RREC]:kw},yp=[],xo=[];class bo{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 bo(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 as=new bt,_p=class Mm extends qd{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 ao,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(),xo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),yp.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 bo(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 bo(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,as):as.copyFrom(t),s.shape.contains(as.x,as.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(as.x,as.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;rh[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=Dr.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=yp.pop()||new Gw,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<Mm.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++ft._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),xo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=xo.pop();s||(s=new Al,s.texArray=new Pl),s.texArray.count=0,s.start=0,s.size=0,s.type=rr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=rr.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?rr.LINES:rr.TRIANGLES,o=null,n=p,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=xo.pop(),s||(s=new Al,s.texArray=new Pl),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=Dr.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)}ft._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?fp.triangulate(t,this):rh[t.type].triangulate(t,this)}processLine(t){gp(t,this);for(let e=0;e<t.holes.length;e++)gp(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];rh[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=wt.shared.setValue(e).toLittleEndianNumber(),a=wt.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}};_p.BATCHABLE_SIZE=100;let Vw=_p;class Eo{constructor(){this.color=16777215,this.alpha=1,this.texture=Z.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Eo;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=Z.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class ih extends Eo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Hr.BUTT,this.join=Fe.MITER,this.miterLimit=10}clone(){const t=new ih;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=Hr.BUTT,this.join=Fe.MITER,this.miterLimit=10}}const sh={},nh=class Go extends Ye{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 Eo,this._lineStyle=new ih,this._matrix=null,this._holeMode=!1,this.state=cr.for2d(),this._geometry=t||new Vw,this._geometry.refCount++,this._transformID=-1,this._tintColor=new wt(16777215),this.blendMode=at.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Go(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,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:Z.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Hr.BUTT,join:Fe.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new di,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new di,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,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),eh.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),th.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=pp.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+=Vn:o&&s<=n&&(s+=Vn),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 pp.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:Z.WHITE,color:t,alpha:e})}normalizeColor(t){const e=wt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Z.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new pt(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new Yn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new zn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new Wn(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 di(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===he.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:wt.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,wt.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 Rt,default:We.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;sh[i]=new dr(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,Go._TEMP_POINT),this._geometry.containsPoint(Go._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=wt.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)}};nh.curves=os,nh._TEMP_POINT=new bt;let Ws=nh;class Xw{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 oh=new bt,vp=new di,xp=class Pm extends Ye{constructor(t,e,i,s=rr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||cr.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=j.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===rr.TRIANGLES&&e.length<Pm.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=j.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 Xw(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,oh);const e=this.geometry.getBuffer("aVertexPosition").data,i=vp.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],vp.contains(oh.x,oh.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}};xp.BATCHABLE_SIZE=100;let bp=xp;class zw extends kr{constructor(t,e,i){super();const s=new Vt(t),n=new Vt(e,!0),o=new Vt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,tt.FLOAT).addAttribute("aTextureCoord",n,2,!1,tt.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Ww=`varying vec2 vTextureCoord;
|
|
911
|
+
`;let ss=null;class tp{constructor(){ss||(ss=URL.createObjectURL(new Blob([BT],{type:"application/javascript"}))),this.worker=new Worker(ss)}}tp.revokeObjectURL=function(){ss&&(URL.revokeObjectURL(ss),ss=null)};let ep=0,ql;class FT{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new jl;e.addEventListener("message",i=>{e.terminate(),jl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){ql===void 0&&(ql=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<ql&&(this._createdWorkers++,t=new tp().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[ep]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:ep++,id:i})}}const rp=new FT;function zs(r,t,e){r.resource.internal=!0;const i=new Z(r),s=()=>{delete t.promiseCache[e],Ei.has(e)&&Ei.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 UT=[".jpeg",".jpg",".png",".webp",".avif"],kT=["image/jpeg","image/png","image/webp","image/avif"];async function GT(r){const t=await j.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 co={name:"loadTextures",extension:{type:W.LoadParser,priority:Ke.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return rs(r,kT)||$r(r,UT)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await rp.isImageBitmapSupported()?s=await rp.loadImageBitmap(r):s=await GT(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=Ar(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new ft(s,n);return o.resource.src=r,zs(o,e,r)},unload(r){r.destroy(!0)}};K.add(co);const $T=".svg",HT="image/svg+xml",VT={extension:{type:W.LoadParser,priority:Ke.High},name:"loadSVG",test(r){return rs(r,HT)||$r(r,$T)},async testParse(r){return Gl.test(r)},async parse(r,t,e){var n;const i=new Gl(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new ft(i,{resolution:Ar(r),...t==null?void 0:t.data});return s.resource.src=t.src,zs(s,e,t.src)},async load(r,t){return(await j.ADAPTER.fetch(r)).text()},unload:co.unload};K.add(VT);const XT=[".mp4",".m4v",".webm",".ogv"],zT=["video/mp4","video/webm","video/ogg"],WT={name:"loadVideo",extension:{type:W.LoadParser,priority:Ke.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return rs(r,zT)||$r(r,XT)},async load(r,t,e){var o;let i;const s=await(await j.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 Hf(n,a);await l.load();const h=new ft(l,{alphaMode:await Qx(),resolution:Ar(r),...t==null?void 0:t.data});h.resource.src=r,i=zs(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};K.add(WT);class YT{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 qe(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"?(gt("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`)},qe(o).forEach(l=>{const{src:h,srcs:u}=l;let{data:c,format:d,loadParser:p}=l;const f=qe(h||u).map(_=>typeof _=="string"?_T(_):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 b=this._parsers[x];if(b.test(v)){g=b.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=uo(t);t=qe(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=uo(t);t=qe(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=se.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??se.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class jT{constructor(){this._detections=[],this._initialized=!1,this.resolver=new YT,this.loader=new xT,this.cache=Ei,this._backgroundLoader=new yT(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=uo(t),s=qe(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),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 Ei.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=Ei.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,Ei.set(u,h)}),o}async unload(t){this._initialized||await this.init();const e=qe(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=qe(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=>{Ei.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 co.config.preferWorkers}set preferWorkers(t){gt("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 fo=new jT;K.handleByList(W.LoadParser,fo.loader.parsers).handleByList(W.ResolveParser,fo.resolver.parsers).handleByList(W.CacheParser,fo.cache.parsers).handleByList(W.DetectionParser,fo.detections);const qT={extension:W.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof Z),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};K.add(qT);async function ip(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 KT={extension:{type:W.DetectionParser,priority:1},test:async()=>ip("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};K.add(KT);const ZT={extension:{type:W.DetectionParser,priority:0},test:async()=>ip("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};K.add(ZT);const sp=["png","jpg","jpeg"],QT={extension:{type:W.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...sp],remove:async r=>r.filter(t=>!sp.includes(t))};K.add(QT);const JT="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Kl(r){return JT?!1:document.createElement("video").canPlayType(r)!==""}const tw={extension:{type:W.DetectionParser,priority:0},test:async()=>Kl("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};K.add(tw);const ew={extension:{type:W.DetectionParser,priority:0},test:async()=>Kl("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};K.add(ew);const rw={extension:{type:W.DetectionParser,priority:0},test:async()=>Kl("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};K.add(rw);const iw={extension:W.ResolveParser,test:co.test,parse:r=>{var t;return{resolution:parseFloat(((t=j.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:se.extname(r).slice(1),src:r}}};K.add(iw);var ue=(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))(ue||{});const po={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let fr,ns;function np(){ns={bptc:fr.getExtension("EXT_texture_compression_bptc"),astc:fr.getExtension("WEBGL_compressed_texture_astc"),etc:fr.getExtension("WEBGL_compressed_texture_etc"),s3tc:fr.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:fr.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:fr.getExtension("WEBGL_compressed_texture_pvrtc")||fr.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:fr.getExtension("WEBGL_compressed_texture_etc1"),atc:fr.getExtension("WEBGL_compressed_texture_atc")}}const sw={extension:{type:W.DetectionParser,priority:2},test:async()=>{const r=j.ADAPTER.createCanvas().getContext("webgl");return r?(fr=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{ns||np();const t=[];for(const e in ns)ns[e]&&t.push(e);return[...t,...r]},remove:async r=>(ns||np(),r.filter(t=>!(t in ns)))};K.add(sw);class nw extends $n{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 ml(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 ml(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Ti extends nw{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Ti._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Ti._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,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=Ti._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,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*po[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*po[e];return l}}const Zl=4,mo=124,ow=32,op=20,aw=542327876,go={HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},lw={FOURCC:2},yo={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3},hw=1,uw=2,cw=4,dw=64,fw=512,pw=131072,mw=827611204,gw=861165636,yw=894720068,_w=808540228,vw=4,xw={[mw]:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,[gw]:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,[yw]:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT},bw={70:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:ue.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:ue.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:ue.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:ue.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:ue.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:ue.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:ue.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:ue.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function Ew(r){const t=new Uint32Array(r);if(t[0]!==aw)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,mo/Uint32Array.BYTES_PER_ELEMENT),i=e[go.HEIGHT],s=e[go.WIDTH],n=e[go.MIPMAP_COUNT],o=new Uint32Array(r,go.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,ow/Uint32Array.BYTES_PER_ELEMENT),a=o[hw];if(a&cw){const l=o[lw.FOURCC];if(l!==_w){const v=xw[l],g=Zl+mo,x=new Uint8Array(r,g);return[new Ti(x,{format:v,width:s,height:i,levels:n})]}const h=Zl+mo,u=new Uint32Array(t.buffer,h,op/Uint32Array.BYTES_PER_ELEMENT),c=u[yo.DXGI_FORMAT],d=u[yo.RESOURCE_DIMENSION],p=u[yo.MISC_FLAG],f=u[yo.ARRAY_SIZE],m=bw[c];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${c}`);if(p===vw)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,_=Zl+mo+op;if(f===1)y.push(new Uint8Array(r,_));else{const v=po[m];let g=0,x=s,b=i;for(let w=0;w<n;w++){const T=Math.max(1,x+3&-4),N=Math.max(1,b+3&-4),F=T*N*v;g+=F,x=x>>>1,b=b>>>1}let S=_;for(let w=0;w<f;w++)y.push(new Uint8Array(r,S,g)),S+=g}return y.map(v=>new Ti(v,{format:m,width:s,height:i,levels:n}))}throw a&dw?new Error("DDSParser does not support uncompressed texture data."):a&fw?new Error("DDSParser does not supported YUV uncompressed texture data."):a&pw?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&uw?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 ap=[171,75,84,88,32,49,49,187,13,10,26,10],Tw=67305985,Ze={ENDIANNESS:12,GL_TYPE:16,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},Ql=64,lp={[tt.UNSIGNED_BYTE]:1,[tt.UNSIGNED_SHORT]:2,[tt.INT]:4,[tt.UNSIGNED_INT]:4,[tt.FLOAT]:4,[tt.HALF_FLOAT]:8},ww={[H.RGBA]:4,[H.RGB]:3,[H.RG]:2,[H.RED]:1,[H.LUMINANCE]:1,[H.LUMINANCE_ALPHA]:2,[H.ALPHA]:1},Aw={[tt.UNSIGNED_SHORT_4_4_4_4]:2,[tt.UNSIGNED_SHORT_5_5_5_1]:2,[tt.UNSIGNED_SHORT_5_6_5]:2};function Sw(r,t,e=!1){const i=new DataView(t);if(!Cw(r,i))return null;const s=i.getUint32(Ze.ENDIANNESS,!0)===Tw,n=i.getUint32(Ze.GL_TYPE,s),o=i.getUint32(Ze.GL_FORMAT,s),a=i.getUint32(Ze.GL_INTERNAL_FORMAT,s),l=i.getUint32(Ze.PIXEL_WIDTH,s),h=i.getUint32(Ze.PIXEL_HEIGHT,s)||1,u=i.getUint32(Ze.PIXEL_DEPTH,s)||1,c=i.getUint32(Ze.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Ze.NUMBER_OF_FACES,s),p=i.getUint32(Ze.NUMBER_OF_MIPMAP_LEVELS,s),f=i.getUint32(Ze.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 b;if(n!==0?lp[n]?b=lp[n]*ww[o]:b=Aw[n]:b=po[a],b===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const S=e?Rw(i,f,s):null;let w=x*b,T=l,N=h,F=_,z=v,C=Ql+f;for(let E=0;E<p;E++){const I=i.getUint32(C,s);let P=C+4;for(let $=0;$<c;$++){let k=g[$];k||(k=g[$]=new Array(p)),k[E]={levelID:E,levelWidth:p>1||n!==0?T:F,levelHeight:p>1||n!==0?N:z,levelBuffer:new Uint8Array(t,P,w)},P+=w}C+=I+4,C=C%4!==0?C+4-C%4:C,T=T>>1||1,N=N>>1||1,F=T+m-1&-4,z=N+y-1&-4,w=F*z*b}return n!==0?{uncompressed:g.map(E=>{let I=E[0].levelBuffer,P=!1;return n===tt.FLOAT?I=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===tt.UNSIGNED_INT?(P=!0,I=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===tt.INT&&(P=!0,I=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new $n(I,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:P?Iw(o):o}}),kvData:S}:{compressed:g.map(E=>new Ti(null,{format:a,width:l,height:h,levels:p,levelBuffers:E})),kvData:S}}function Cw(r,t){for(let e=0;e<ap.length;e++)if(t.getUint8(e)!==ap[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function Iw(r){switch(r){case H.RGBA:return H.RGBA_INTEGER;case H.RGB:return H.RGB_INTEGER;case H.RG:return H.RG_INTEGER;case H.RED:return H.RED_INTEGER;default:return r}}function Rw(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(Ql+s,e),o=Ql+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 Mw={extension:{type:W.LoadParser,priority:Ke.High},name:"loadDDS",test(r){return $r(r,".dds")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),s=Ew(i).map(n=>{const o=new ft(n,{mipmap:ir.OFF,alphaMode:Ce.NO_PREMULTIPLIED_ALPHA,resolution:Ar(r),...t.data});return zs(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};K.add(Mw);const Pw={extension:{type:W.LoadParser,priority:Ke.High},name:"loadKTX",test(r){return $r(r,".ktx")},async load(r,t,e){const i=await(await j.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=Sw(r,i),a=s??n,l={mipmap:ir.OFF,alphaMode:Ce.NO_PREMULTIPLIED_ALPHA,resolution:Ar(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 ft(c,l);return d.ktxKeyValueData=o,zs(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};K.add(Pw);const Ow=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],Nw={extension:W.ResolveParser,test:r=>{const t=se.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(Ow.includes(n))return{resolution:parseFloat(((i=j.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=j.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};K.add(Nw);const _o=new pt,Dw=4,hp=class Zs{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&&Zs._flipY(i,s,n),a&&Zs._unpremultiplyAlpha(i);const l=new pb(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&&Zs._flipY(i,s,n),a&&Zs._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 _i?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(_o.width=e.width,_o.height=e.height,e=_o)));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===H.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=_o,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(Dw*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}}}};hp.extension={name:"extract",type:W.RendererSystem};let Lw=hp;K.add(Lw);const vo={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===he.CIRC){const f=r.shape;e=f.x,i=f.y,o=a=f.radius,s=n=0}else if(r.type===he.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+_,b=i-_;t[u++]=v,t[u++]=x,t[--c]=x,t[--c]=g,t[d++]=g,t[d++]=b,t[--p]=b,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!==he.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 up(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 cp={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){up(e,!1);const o=[];for(let h=0;h<i.length;h++){const u=i[h];up(u.points,!0),o.push(e.length/2),e=e.concat(u.points)}const a=G0(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])}}},Bw={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)}},Fw={build(r){vo.build(r)},triangulate(r,t){vo.triangulate(r,t)}};var Fe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(Fe||{}),Hr=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(Hr||{});const os={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 dp{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,b=y*u+_*l,S=h*(_+v),w=l*(_+v),T=c*(y+g),N=u*(y+g),F=Math.atan2(w-b,S-x),z=Math.atan2(N-b,T-x);return{cx:x+t,cy:b+e,radius:n,startAngle:F,endAngle:z,anticlockwise:h*u>c*l}}static arc(t,e,i,s,n,o,a,l,h){const u=a-o,c=os._segmentsCount(Math.abs(u)*n,Math.ceil(Math.abs(u)/Vn)*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,b=Math.cos(x),S=-Math.sin(x);h.push((f*b+m*S)*n+i,(f*-S+m*b)*n+s)}}}class Uw{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 Jl{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,b=e;for(let S=1;S<=10;++S)u=S/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=b-_,x=y,b=_,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=os._segmentsCount(Jl.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 fp(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 wi(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 kw(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 bt(i[0],i[1]),a=new bt(i[i.length-2],i[i.length-1]),l=e.type!==he.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 k=(o.x+a.x)*.5,G=(a.y+o.y)*.5;i.unshift(k,G),i.push(k,G)}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],b=0,S=0,w=-(v-x),T=_-g,N=0,F=0,z=Math.sqrt(w*w+T*T);w/=z,T/=z,w*=f,T*=f;const C=n.alignment,E=(1-C)*2,I=C*2;l||(n.cap===Hr.ROUND?d+=wi(_-w*(E-I)*.5,v-T*(E-I)*.5,_-w*E,v-T*E,_+w*I,v+T*I,u,!0)+2:n.cap===Hr.SQUARE&&(d+=fp(_,v,w,T,E,I,!0,u))),u.push(_-w*E,v-T*E,_+w*I,v+T*I);for(let k=1;k<c-1;++k){_=i[(k-1)*2],v=i[(k-1)*2+1],g=i[k*2],x=i[k*2+1],b=i[(k+1)*2],S=i[(k+1)*2+1],w=-(v-x),T=_-g,z=Math.sqrt(w*w+T*T),w/=z,T/=z,w*=f,T*=f,N=-(x-S),F=g-b,z=Math.sqrt(N*N+F*F),N/=z,F/=z,N*=f,F*=f;const G=g-_,st=v-x,M=g-b,L=S-x,V=G*M+st*L,rt=st*M-L*G,Q=rt<0;if(Math.abs(rt)<.001*Math.abs(V)){u.push(g-w*E,x-T*E,g+w*I,x+T*I),V>=0&&(n.join===Fe.ROUND?d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+4:d+=2,u.push(g-N*I,x-F*I,g+N*E,x+F*E));continue}const X=(-w+_)*(-T+x)-(-w+g)*(-T+v),_t=(-N+b)*(-F+x)-(-N+g)*(-F+S),St=(G*_t-M*X)/rt,O=(L*X-st*_t)/rt,D=(St-g)*(St-g)+(O-x)*(O-x),ut=g+(St-g)*E,lt=x+(O-x)*E,Et=g-(St-g)*I,Tt=x-(O-x)*I,mr=Math.min(G*G+st*st,M*M+L*L),gr=Q?E:I,js=mr+gr*gr*m,SC=D<=js;let Lo=n.join;if(Lo===Fe.MITER&&D/m>y&&(Lo=Fe.BEVEL),SC)switch(Lo){case Fe.MITER:{u.push(ut,lt,Et,Tt);break}case Fe.BEVEL:{Q?u.push(ut,lt,g+w*I,x+T*I,ut,lt,g+N*I,x+F*I):u.push(g-w*E,x-T*E,Et,Tt,g-N*E,x-F*E,Et,Tt),d+=2;break}case Fe.ROUND:{Q?(u.push(ut,lt,g+w*I,x+T*I),d+=wi(g,x,g+w*I,x+T*I,g+N*I,x+F*I,u,!0)+4,u.push(ut,lt,g+N*I,x+F*I)):(u.push(g-w*E,x-T*E,Et,Tt),d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+4,u.push(g-N*E,x-F*E,Et,Tt));break}}else{switch(u.push(g-w*E,x-T*E,g+w*I,x+T*I),Lo){case Fe.MITER:{Q?u.push(Et,Tt,Et,Tt):u.push(ut,lt,ut,lt),d+=2;break}case Fe.ROUND:{Q?d+=wi(g,x,g+w*I,x+T*I,g+N*I,x+F*I,u,!0)+2:d+=wi(g,x,g-w*E,x-T*E,g-N*E,x-F*E,u,!1)+2;break}}u.push(g-N*E,x-F*E,g+N*I,x+F*I),d+=2}}_=i[(c-2)*2],v=i[(c-2)*2+1],g=i[(c-1)*2],x=i[(c-1)*2+1],w=-(v-x),T=_-g,z=Math.sqrt(w*w+T*T),w/=z,T/=z,w*=f,T*=f,u.push(g-w*E,x-T*E,g+w*I,x+T*I),l||(n.cap===Hr.ROUND?d+=wi(g-w*(E-I)*.5,x-T*(E-I)*.5,g-w*E,x-T*E,g+w*I,x+T*I,u,!1)+2:n.cap===Hr.SQUARE&&(d+=fp(g,x,w,T,E,I,!1,u)));const P=t.indices,$=os.epsilon*os.epsilon;for(let k=p;k<d+p-2;++k)_=u[k*2],v=u[k*2+1],g=u[(k+1)*2],x=u[(k+1)*2+1],b=u[(k+2)*2],S=u[(k+2)*2+1],!(Math.abs(_*(x-S)+g*(S-v)+b*(v-x))<$)&&P.push(k,k+1,k+2)}function Gw(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==he.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 pp(r,t){r.lineStyle.native?Gw(r,t):kw(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),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=os._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 eh={[he.POLY]:cp,[he.CIRC]:vo,[he.ELIP]:vo,[he.RECT]:Bw,[he.RREC]:Fw},mp=[],xo=[];class bo{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 bo(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 as=new bt,gp=class Im extends Yd{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new ao,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(),xo.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),mp.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 bo(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 bo(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,as):as.copyFrom(t),s.shape.contains(as.x,as.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(as.x,as.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;eh[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=Dr.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=mp.pop()||new Uw,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<Im.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++ft._globalBatch;for(let c=0;c<this.drawCalls.length;c++)this.drawCalls[c].texArray.clear(),xo.push(this.drawCalls[c]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=xo.pop();s||(s=new wl,s.texArray=new Ml),s.texArray.count=0,s.start=0,s.size=0,s.type=rr.TRIANGLES;let n=0,o=null,a=0,l=!1,h=rr.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?rr.LINES:rr.TRIANGLES,o=null,n=p,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===p&&(t++,n=0,s.size>0&&(s=xo.pop(),s||(s=new wl,s.texArray=new Ml),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=Dr.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)}ft._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?cp.triangulate(t,this):eh[t.type].triangulate(t,this)}processLine(t){pp(t,this);for(let e=0;e<t.holes.length;e++)pp(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];eh[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=wt.shared.setValue(e).toLittleEndianNumber(),a=wt.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}};gp.BATCHABLE_SIZE=100;let $w=gp;class Eo{constructor(){this.color=16777215,this.alpha=1,this.texture=Z.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Eo;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=Z.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class rh extends Eo{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=Hr.BUTT,this.join=Fe.MITER,this.miterLimit=10}clone(){const t=new rh;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=Hr.BUTT,this.join=Fe.MITER,this.miterLimit=10}}const ih={},sh=class Go extends Ye{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 Eo,this._lineStyle=new rh,this._matrix=null,this._holeMode=!1,this.state=cr.for2d(),this._geometry=t||new $w,this._geometry.refCount++,this._transformID=-1,this._tintColor=new wt(16777215),this.blendMode=at.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new Go(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,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:Z.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:Hr.BUTT,join:Fe.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new di,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new di,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,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(),Jl.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=dp.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+=Vn:o&&s<=n&&(s+=Vn),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 dp.arc(a,l,t,e,i,s,n,o,u),this}beginFill(t=0,e){return this.beginTextureFill({texture:Z.WHITE,color:t,alpha:e})}normalizeColor(t){const e=wt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Z.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new pt(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new Yn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new zn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new Wn(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 di(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===he.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:wt.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,wt.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(!ih[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 Rt,default:We.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;ih[i]=new dr(a,o)}e=ih[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,Go._TEMP_POINT),this._geometry.containsPoint(Go._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=wt.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)}};sh.curves=os,sh._TEMP_POINT=new bt;let Ws=sh;class Hw{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 nh=new bt,yp=new di,_p=class Rm extends Ye{constructor(t,e,i,s=rr.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||cr.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=j.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===rr.TRIANGLES&&e.length<Rm.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=j.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 Hw(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,nh);const e=this.geometry.getBuffer("aVertexPosition").data,i=yp.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],yp.contains(nh.x,nh.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}};_p.BATCHABLE_SIZE=100;let vp=_p;class Vw extends kr{constructor(t,e,i){super();const s=new Vt(t),n=new Vt(e,!0),o=new Vt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,tt.FLOAT).addAttribute("aTextureCoord",n,2,!1,tt.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Xw=`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
|
-
`,
|
|
921
|
+
`,zw=`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
|
|
936
|
+
`;class xp extends dr{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:Rt.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||Cr.from(zw,Xw),i),this._colorDirty=!1,this.uvMatrix=new mf(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new wt(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;wt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class bp{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||tt.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 Vt(db(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 Vt(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 Vt(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===tt.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===tt.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===tt.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===tt.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 Ww=`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
|
-
}`,
|
|
944
|
+
}`,Yw=`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
|
|
970
|
-
`:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=J._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(!J.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:J._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:J._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(J.isBreakingSpace(n,o)||J.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 J.graphemeSegmenter(t)}static measureFont(t){if(J._fonts[t])return J._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=J._canvas,s=J._context;s.font=t;const n=J.METRICS_STRING+J.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(J.BASELINE_SYMBOL).width);const l=Math.ceil(J.HEIGHT_MULTIPLIER*a);if(a=a*J.BASELINE_MULTIPLIER|0,o===0||l===0)return J._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,J._fonts[t]=e,e}static clearMetrics(t=""){t?delete J._fonts[t]:J._fonts={}}static get _canvas(){var t;if(!J.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",wo))!=null&&t.measureText)return J.__canvas=i,i;e=j.ADAPTER.createCanvas()}catch{e=j.ADAPTER.createCanvas()}e.width=e.height=10,J.__canvas=e}return J.__canvas}static get _context(){return J.__context||(J.__context=J._canvas.getContext("2d",wo)),J.__context}};pr.METRICS_STRING="|ÉqÅ",pr.BASELINE_SYMBOL="M",pr.BASELINE_MULTIPLIER=1.4,pr.HEIGHT_MULTIPLIER=2,pr.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),pr.experimentalLetterSpacing=!1,pr._fonts={},pr._newlines=[10,13],pr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Vr=pr;const Kw=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Ap=class Qs{constructor(t){this.styleID=0,this.reset(),lh(this,t,t)}clone(){const t={};return lh(t,this,Qs.defaultStyle),new Qs(t)}reset(){lh(this,Qs.defaultStyle,Qs.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){Zw(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)&&!Kw.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Ap.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:To.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 Xr=Ap;function ah(r){const t=wt.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 Zw(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 lh(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Qw={texture:!0,children:!1,baseTexture:!0},Sp=class Ph extends ts{constructor(t,e,i){let s=!1;i||(i=j.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Z.from(i);n.orig=new pt,n.trim=new pt,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Ph.defaultResolution??j.RESOLUTION,this._autoResolution=Ph.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Vr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){gt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Vr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Vr.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,b=e.dropShadowBlur*this._resolution,S=e.dropShadowDistance*this._resolution;i.shadowColor=wt.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=b,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*S,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*S+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(Vr.experimentalLetterSpacingSupported&&(Vr.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=Vr.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=_b(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===To.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 b=0;b<u.length;b++){let S=0;typeof c[b]=="number"?S=c[b]:S=b/u.length;let w=Math.min(1,Math.max(0,y/h+S*x));w=Number(w.toFixed(5)),n.addColorStop(w,u[b])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let m;typeof c[f]=="number"?m=c[f]:m=p/d,n.addColorStop(m,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Qw,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=Fr(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=Fr(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 Xr?this._style=t:this._style=new Xr(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)}};Sp.defaultAutoResolution=!0;let Cp=Sp;class Jw{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function tA(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 Z){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function eA(r,t){if(r.baseTexture instanceof ft){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function rA(r,t){if(r._texture&&r._texture instanceof Z){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function iA(r,t){return t instanceof Cp?(t.updateText(!0),!0):!1}function sA(r,t){if(t instanceof Xr){const e=t.toFontString();return Vr.measureFont(e),!0}return!1}function nA(r,t){if(r instanceof Cp){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 oA(r,t){return r instanceof Xr?(t.includes(r)||t.push(r),!0):!1}const Ip=class Om{constructor(t){this.limiter=new Jw(Om.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(nA),this.registerFindHook(oA),this.registerFindHook(tA),this.registerFindHook(eA),this.registerFindHook(rA),this.registerUploadHook(iA),this.registerUploadHook(sA)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Me.system.addOnce(this.tick,this,bi.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)Me.system.addOnce(this.tick,this,bi.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 Ye)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Me.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}};Ip.uploadsPerFrame=4;let hh=Ip;Object.defineProperties(j,{UPLOADS_PER_FRAME:{get(){return hh.uploadsPerFrame},set(r){gt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),hh.uploadsPerFrame=r}}});function Rp(r,t){return t instanceof ft?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function aA(r,t){if(!(t instanceof Ws))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&&Rp(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function lA(r,t){return r instanceof Ws?(t.push(r),!0):!1}class Mp extends hh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(lA),this.registerUploadHook(Rp),this.registerUploadHook(aA)}}Mp.extension={name:"prepare",type:W.RendererSystem},K.add(Mp);var hA=`#version 300 es
|
|
969
|
+
`;class Ep extends Qn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new Rt,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:tt.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=dr.from(Yw,Ww,{}),this.state=cr.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=Bd(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=wt.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 bp(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new bp(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=wt.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}}Ep.extension={name:"particle",type:W.RendererPlugin},K.add(Ep);var To=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))(To||{});const wo={willReadFrequently:!0},pr=class J{static get experimentalLetterSpacingSupported(){let t=J._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.ADAPTER.getCanvasRenderingContext2D().prototype;t=J._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=J._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=J.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",wo);a.font=n;const l=(i?J.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=J._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 J(t,e,c,p,l,h,d+e.leading,u,o)}static _measureText(t,e,i){let s=!1;J.experimentalLetterSpacingSupported&&(J.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+=(J.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=J._canvas){const s=i.getContext("2d",wo);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:u}=e,c=J.collapseSpaces(u),d=J.collapseNewlines(u);let p=!c;const f=e.wordWrapWidth+h,m=J.tokenize(t);for(let y=0;y<m.length;y++){let _=m[y];if(J.isNewline(_)){if(!d){a+=J.addLine(o),p=!c,o="",n=0;continue}_=" "}if(c){const g=J.isBreakingSpace(_),x=J.isBreakingSpace(o[o.length-1]);if(g&&x)continue}const v=J.getFromCache(_,h,l,s);if(v>f)if(o!==""&&(a+=J.addLine(o),o="",n=0),J.canBreakWords(_,e.breakWords)){const g=J.wordWrapSplit(_);for(let x=0;x<g.length;x++){let b=g[x],S=b,w=1;for(;g[x+w];){const N=g[x+w];if(!J.canBreakChars(S,N,_,x,e.breakWords))b+=N;else break;S=N,w++}x+=w-1;const T=J.getFromCache(b,h,l,s);T+n>f&&(a+=J.addLine(o),p=!1,o="",n=0),o+=b,n+=T}}else{o.length>0&&(a+=J.addLine(o),o="",n=0);const g=y===m.length-1;a+=J.addLine(_,!g),p=!1,o="",n=0}else v+n>f&&(p=!1,a+=J.addLine(o),o="",n=0),(o.length>0||!J.isBreakingSpace(_)||p)&&(o+=_,n+=v)}return a+=J.addLine(o,!1),a}static addLine(t,e=!0){return t=J.trimRight(t),t=e?`${t}
|
|
970
|
+
`:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=J._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(!J.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:J._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:J._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(J.isBreakingSpace(n,o)||J.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 J.graphemeSegmenter(t)}static measureFont(t){if(J._fonts[t])return J._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=J._canvas,s=J._context;s.font=t;const n=J.METRICS_STRING+J.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(J.BASELINE_SYMBOL).width);const l=Math.ceil(J.HEIGHT_MULTIPLIER*a);if(a=a*J.BASELINE_MULTIPLIER|0,o===0||l===0)return J._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,J._fonts[t]=e,e}static clearMetrics(t=""){t?delete J._fonts[t]:J._fonts={}}static get _canvas(){var t;if(!J.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",wo))!=null&&t.measureText)return J.__canvas=i,i;e=j.ADAPTER.createCanvas()}catch{e=j.ADAPTER.createCanvas()}e.width=e.height=10,J.__canvas=e}return J.__canvas}static get _context(){return J.__context||(J.__context=J._canvas.getContext("2d",wo)),J.__context}};pr.METRICS_STRING="|ÉqÅ",pr.BASELINE_SYMBOL="M",pr.BASELINE_MULTIPLIER=1.4,pr.HEIGHT_MULTIPLIER=2,pr.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),pr.experimentalLetterSpacing=!1,pr._fonts={},pr._newlines=[10,13],pr._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let Vr=pr;const jw=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Tp=class Qs{constructor(t){this.styleID=0,this.reset(),ah(this,t,t)}clone(){const t={};return ah(t,this,Qs.defaultStyle),new Qs(t)}reset(){ah(this,Qs.defaultStyle,Qs.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=oh(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=oh(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){qw(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=oh(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)&&!jw.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};Tp.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:To.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 Xr=Tp;function oh(r){const t=wt.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 qw(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function ah(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Kw={texture:!0,children:!1,baseTexture:!0},wp=class Mh extends ts{constructor(t,e,i){let s=!1;i||(i=j.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Z.from(i);n.orig=new pt,n.trim=new pt,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Mh.defaultResolution??j.RESOLUTION,this._autoResolution=Mh.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return Vr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){gt("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),Vr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=Vr.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,b=e.dropShadowBlur*this._resolution,S=e.dropShadowDistance*this._resolution;i.shadowColor=wt.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=b,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*S,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*S+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(Vr.experimentalLetterSpacingSupported&&(Vr.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=Vr.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=gb(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===To.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 b=0;b<u.length;b++){let S=0;typeof c[b]=="number"?S=c[b]:S=b/u.length;let w=Math.min(1,Math.max(0,y/h+S*x));w=Number(w.toFixed(5)),n.addColorStop(w,u[b])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=u.length+1;let p=1;for(let f=0;f<u.length;f++){let m;typeof c[f]=="number"?m=c[f]:m=p/d,n.addColorStop(m,u[f]),p++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Kw,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=Fr(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=Fr(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 Xr?this._style=t:this._style=new Xr(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)}};wp.defaultAutoResolution=!0;let Ap=wp;class Zw{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function Qw(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 Z){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function Jw(r,t){if(r.baseTexture instanceof ft){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function tA(r,t){if(r._texture&&r._texture instanceof Z){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function eA(r,t){return t instanceof Ap?(t.updateText(!0),!0):!1}function rA(r,t){if(t instanceof Xr){const e=t.toFontString();return Vr.measureFont(e),!0}return!1}function iA(r,t){if(r instanceof Ap){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 sA(r,t){return r instanceof Xr?(t.includes(r)||t.push(r),!0):!1}const Sp=class Mm{constructor(t){this.limiter=new Zw(Mm.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(iA),this.registerFindHook(sA),this.registerFindHook(Qw),this.registerFindHook(Jw),this.registerFindHook(tA),this.registerUploadHook(eA),this.registerUploadHook(rA)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,Me.system.addOnce(this.tick,this,bi.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)Me.system.addOnce(this.tick,this,bi.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 Ye)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&Me.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}};Sp.uploadsPerFrame=4;let lh=Sp;Object.defineProperties(j,{UPLOADS_PER_FRAME:{get(){return lh.uploadsPerFrame},set(r){gt("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),lh.uploadsPerFrame=r}}});function Cp(r,t){return t instanceof ft?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function nA(r,t){if(!(t instanceof Ws))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&&Cp(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function oA(r,t){return r instanceof Ws?(t.push(r),!0):!1}class Ip extends lh{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(oA),this.registerUploadHook(Cp),this.registerUploadHook(nA)}}Ip.extension={name:"prepare",type:W.RendererSystem},K.add(Ip);var aA=`#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
|
-
`,
|
|
996
|
+
`,lA=`#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
|
-
`,
|
|
1016
|
+
`,hA=`#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
|
-
`,
|
|
1049
|
+
`,Rp=`#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
|
-
`,
|
|
1069
|
+
`,uA=`#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 Ao=new Rt;class Op extends Qn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new df,this.state=cr.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=dr.from(Pp,dA,e),this.shader=t.context.webGLVersion>1?dr.from(uA,hA,e):dr.from(Pp,cA,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!==Dr.CLAMP:l.wrapMode===Dr.CLAMP&&(l.wrapMode=Dr.REPEAT));const p=d?this.simpleShader:this.shader,f=a.width,m=a.height,y=t._width,_=t._height;Ao.set(u.a*f/y,u.b*f/_,u.c*m/y,u.d*m/_,u.tx/y,u.ty/_),Ao.invert(),d?Ao.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=Ao.toArray(!0),p.uniforms.uColor=wt.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=Ud(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Op.extension={name:"tilingSprite",type:W.RendererPlugin},K.add(Op);const Np=class Js{constructor(t,e,i){this.linkedSheets=[],(t instanceof ft||t instanceof Z)&&(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 Z?s:null,this.baseTexture=s instanceof ft?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=Ar(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<=Js.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Js.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 pt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new pt(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 pt(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 pt(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 Z(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),Z.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*Js.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Js.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=[]}};Np.BATCH_SIZE=1e3;let Dp=Np;const fA=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Lp(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=se.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,Lp([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const pA={extension:W.Asset,cache:{test:r=>r instanceof Dp,getCacheableAssets:(r,t)=>Lp(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&fA.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=j.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:W.LoadParser,priority:Ke.Normal},async testParse(r,t){return se.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=se.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=jl(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new Dp({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=jl(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)}}};K.add(pA);class So{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Co{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 So;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class uh{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new So,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const u=o[h];e.char.push({id:parseInt(u.getAttribute("id"),10),page:parseInt(u.getAttribute("page"),10)||0,x:parseInt(u.getAttribute("x"),10),y:parseInt(u.getAttribute("y"),10),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10),xoffset:parseInt(u.getAttribute("xoffset"),10),yoffset:parseInt(u.getAttribute("yoffset"),10),xadvance:parseInt(u.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class ch{static test(t){return typeof t=="string"&&t.includes("<font>")?uh.test(j.ADAPTER.parseXML(t)):!1}static parse(t){return uh.parse(j.ADAPTER.parseXML(t))}}const dh=[Co,uh,ch];function mA(r){for(let t=0;t<dh.length;t++)if(dh[t].test(r))return dh[t];return null}function gA(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===To.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 b=Math.max(f,x);b=Math.min(b,1),a.addColorStop(b,d[v]),f=b}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let m=1;for(let y=0;y<d.length;y++){let _;typeof p[y]=="number"?_=p[y]:_=m/f,a.addColorStop(_,d[y]),m++}}return a}function yA(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=gA(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=wt.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 Io(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function Bp(r){return Array.from?Array.from(r):r.split("")}function _A(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(...Bp(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const zr=class yr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Ar(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=Ce.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=ir.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 b=new pt(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 Z(h[p].baseTexture,b),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof So)s=t;else{const o=mA(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Z&&(e=[e]);const n=new yr(s,e,i);return yr.available[n.font]=n,n}static uninstall(t){const e=yr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete yr.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({},yr.defaultOptions,i),u=_A(s),c=e instanceof Xr?e:new Xr(e),d=a,p=new So;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 S=0;S<u.length;S++){y||(y=j.ADAPTER.createCanvas(),y.width=a,y.height=l,_=y.getContext("2d"),v=new ft(y,{resolution:o,...h}),x.push(new Z(v)),p.page.push({id:x.length-1,file:""}));const w=u[S],T=Vr.measureText(w,c,!1,y),N=T.width,F=Math.ceil(T.height),z=Math.ceil((c.fontStyle==="italic"?2:1)*N);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: '${w}')`);--S,y=null,_=null,v=null,m=0,f=0,g=0;continue}if(g=Math.max(F+T.fontProperties.descent,g),z*o+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${w}')`);--S,m+=g*o,m=Math.ceil(m),f=0,g=0;continue}yA(y,_,T,f,m,o,c);const C=Io(T.text);p.char.push({id:C,page:x.length-1,x:f/o,y:m/o,width:z,height:F,xoffset:0,yoffset:0,xadvance:N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(z+2*n)*o,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let S=0,w=u.length;S<w;S++){const T=u[S];for(let N=0;N<w;N++){const F=u[N],z=_.measureText(T).width,C=_.measureText(F).width,E=_.measureText(T+F).width-(z+C);E&&p.kerning.push({first:Io(T),second:Io(F),amount:E})}}const b=new yr(p,x,!0);return yr.available[t]!==void 0&&yr.uninstall(t),yr.available[t]=b,b}};zr.ALPHA=[["a","z"],["A","Z"]," "],zr.NUMERIC=[["0","9"]],zr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],zr.ASCII=[[" ","~"]],zr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:zr.ALPHANUMERIC},zr.available={};let Wr=zr;var vA=`// Pixi texture info\r
|
|
1084
|
+
`;const Ao=new Rt;class Mp extends Qn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new uf,this.state=cr.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=dr.from(Rp,uA,e),this.shader=t.context.webGLVersion>1?dr.from(lA,aA,e):dr.from(Rp,hA,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!==Dr.CLAMP:l.wrapMode===Dr.CLAMP&&(l.wrapMode=Dr.REPEAT));const p=d?this.simpleShader:this.shader,f=a.width,m=a.height,y=t._width,_=t._height;Ao.set(u.a*f/y,u.b*f/_,u.c*m/y,u.d*m/_,u.tx/y,u.ty/_),Ao.invert(),d?Ao.prepend(c.mapCoord):(p.uniforms.uMapCoord=c.mapCoord.toArray(!0),p.uniforms.uClampFrame=c.uClampFrame,p.uniforms.uClampOffset=c.uClampOffset),p.uniforms.uTransform=Ao.toArray(!0),p.uniforms.uColor=wt.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=Bd(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}Mp.extension={name:"tilingSprite",type:W.RendererPlugin},K.add(Mp);const Pp=class Js{constructor(t,e,i){this.linkedSheets=[],(t instanceof ft||t instanceof Z)&&(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 Z?s:null,this.baseTexture=s instanceof ft?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=Ar(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<=Js.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Js.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 pt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new pt(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 pt(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 pt(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 Z(this.baseTexture,a,u,l,n.rotated?2:0,n.anchor,n.borders),Z.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*Js.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Js.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=[]}};Pp.BATCH_SIZE=1e3;let Op=Pp;const cA=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function Np(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=se.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,Np([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const dA={extension:W.Asset,cache:{test:r=>r instanceof Op,getCacheableAssets:(r,t)=>Np(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&cA.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=j.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:W.LoadParser,priority:Ke.Normal},async testParse(r,t){return se.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=se.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Yl(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new Op({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=Yl(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)}}};K.add(dA);class So{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class Co{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 So;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 hh{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 So,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 uh{static test(t){return typeof t=="string"&&t.includes("<font>")?hh.test(j.ADAPTER.parseXML(t)):!1}static parse(t){return hh.parse(j.ADAPTER.parseXML(t))}}const ch=[Co,hh,uh];function fA(r){for(let t=0;t<ch.length;t++)if(ch[t].test(r))return ch[t];return null}function pA(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===To.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 b=Math.max(f,x);b=Math.min(b,1),a.addColorStop(b,d[v]),f=b}}}else{a=t.createLinearGradient(h,c/2,u+h,c/2);const f=d.length+1;let m=1;for(let y=0;y<d.length;y++){let _;typeof p[y]=="number"?_=p[y]:_=m/f,a.addColorStop(_,d[y]),m++}}return a}function mA(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=pA(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=wt.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 Io(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function Dp(r){return Array.from?Array.from(r):r.split("")}function gA(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(...Dp(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const zr=class yr{constructor(t,e,i){var u;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=Ar(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=Ce.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=ir.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 b=new pt(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 Z(h[p].baseTexture,b),page:p}}for(let c=0;c<t.kerning.length;c++){let{first:d,second:p,amount:f}=t.kerning[c];d/=l,p/=l,f/=l,this.chars[p]&&(this.chars[p].kerning[d]=f)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((u=a==null?void 0:a.fieldType)==null?void 0:u.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof So)s=t;else{const o=fA(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Z&&(e=[e]);const n=new yr(s,e,i);return yr.available[n.font]=n,n}static uninstall(t){const e=yr.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete yr.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({},yr.defaultOptions,i),u=gA(s),c=e instanceof Xr?e:new Xr(e),d=a,p=new So;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 S=0;S<u.length;S++){y||(y=j.ADAPTER.createCanvas(),y.width=a,y.height=l,_=y.getContext("2d"),v=new ft(y,{resolution:o,...h}),x.push(new Z(v)),p.page.push({id:x.length-1,file:""}));const w=u[S],T=Vr.measureText(w,c,!1,y),N=T.width,F=Math.ceil(T.height),z=Math.ceil((c.fontStyle==="italic"?2:1)*N);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: '${w}')`);--S,y=null,_=null,v=null,m=0,f=0,g=0;continue}if(g=Math.max(F+T.fontProperties.descent,g),z*o+f>=d){if(f===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${c.fontFamily}', fontSize: ${c.fontSize}px, char: '${w}')`);--S,m+=g*o,m=Math.ceil(m),f=0,g=0;continue}mA(y,_,T,f,m,o,c);const C=Io(T.text);p.char.push({id:C,page:x.length-1,x:f/o,y:m/o,width:z,height:F,xoffset:0,yoffset:0,xadvance:N-(c.dropShadow?c.dropShadowDistance:0)-(c.stroke?c.strokeThickness:0)}),f+=(z+2*n)*o,f=Math.ceil(f)}if(!(i!=null&&i.skipKerning))for(let S=0,w=u.length;S<w;S++){const T=u[S];for(let N=0;N<w;N++){const F=u[N],z=_.measureText(T).width,C=_.measureText(F).width,E=_.measureText(T+F).width-(z+C);E&&p.kerning.push({first:Io(T),second:Io(F),amount:E})}}const b=new yr(p,x,!0);return yr.available[t]!==void 0&&yr.uninstall(t),yr.available[t]=b,b}};zr.ALPHA=[["a","z"],["A","Z"]," "],zr.NUMERIC=[["0","9"]],zr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],zr.ASCII=[[" ","~"]],zr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:zr.ALPHANUMERIC},zr.available={};let Wr=zr;var yA=`// 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
|
-
`,
|
|
1122
|
+
`,_A=`// 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
|
|
1139
|
-
`)||" ",h=
|
|
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 P=t.chars[I];if(!P)continue;d&&P.kerning[d]&&(s.x+=P.kerning[d]);const $=
|
|
1141
|
-
`&&(/(?:\s)/.test(b)&&(p=_),o.push(p),f=Math.max(f,p),a.push(-1));const S=[];for(let C=0;C<=m;C++){let E=0;this._align==="right"?E=f-o[C]:this._align==="center"?E=(f-o[C])/2:this._align==="justify"&&(E=a[C]<0?0:(f-o[C])/a[C]),S.push(E)}const w=n.length,T={},N=[],F=this._activePagesMeshData;c.push(...F);for(let C=0;C<w;C++){const E=n[C].texture,I=E.baseTexture.uid;if(!T[I]){let P=c.pop();if(!P){const k=new
|
|
1138
|
+
`;const Lp=[],Bp=[],Fp=[],vA=class Pm extends Ye{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Pm.styleDefaults,e);if(!Wr.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new wt(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 Sr(()=>{this.dirty=!0},this,0,0),this._roundPixels=j.ROUND_PIXELS,this.dirty=!0,this._resolution=j.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var z;const t=Wr.available[this._fontName],e=this.fontSize,i=e/t.size,s=new bt,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
|
|
1139
|
+
`)||" ",h=Dp(l),u=this._maxWidth*t.size/e,c=t.distanceFieldType==="none"?Lp:Bp;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 E=h[C],I=Io(E);if(/(?:\s)/.test(E)&&(y=C,_=p,x++),E==="\r"||E===`
|
|
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 P=t.chars[I];if(!P)continue;d&&P.kerning[d]&&(s.x+=P.kerning[d]);const $=Fp.pop()||{texture:Z.EMPTY,line:0,charCode:0,prevSpaces:0,position:new bt};$.texture=P.texture,$.line=m,$.charCode=I,$.position.x=Math.round(s.x+P.xOffset+this._letterSpacing/2),$.position.y=Math.round(s.y+P.yOffset),$.prevSpaces=x,n.push($),p=$.position.x+Math.max(P.xAdvance-P.xOffset,P.texture.orig.width),s.x+=P.xAdvance+this._letterSpacing,g=Math.max(g,P.yOffset+P.texture.height),d=I,y!==-1&&u>0&&s.x>u&&(++v,Ki(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 b=h[h.length-1];b!=="\r"&&b!==`
|
|
1141
|
+
`&&(/(?:\s)/.test(b)&&(p=_),o.push(p),f=Math.max(f,p),a.push(-1));const S=[];for(let C=0;C<=m;C++){let E=0;this._align==="right"?E=f-o[C]:this._align==="center"?E=(f-o[C])/2:this._align==="justify"&&(E=a[C]<0?0:(f-o[C])/a[C]),S.push(E)}const w=n.length,T={},N=[],F=this._activePagesMeshData;c.push(...F);for(let C=0;C<w;C++){const E=n[C].texture,I=E.baseTexture.uid;if(!T[I]){let P=c.pop();if(!P){const k=new Vw;let G,st;t.distanceFieldType==="none"?(G=new xp(Z.EMPTY),st=at.NORMAL):(G=new xp(Z.EMPTY,{program:Cr.from(_A,yA),uniforms:{uFWidth:0}}),st=at.NORMAL_NPM);const M=new vp(k,G);M.blendMode=st,P={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:M,vertices:null,uvs:null,indices:null}}P.index=0,P.indexCount=0,P.vertexCount=0,P.uvsCount=0,P.total=0;const{_textureCache:$}=this;$[I]=$[I]||new Z(E.baseTexture),P.mesh.texture=$[I],P.mesh.tint=this._tintColor.value,N.push(P),T[I]=P}T[I].total++}for(let C=0;C<F.length;C++)N.includes(F[C])||this.removeChild(F[C].mesh);for(let C=0;C<N.length;C++)N[C].mesh.parent!==this&&this.addChild(N[C].mesh);this._activePagesMeshData=N;for(const C in T){const E=T[C],I=E.total;if(!(((z=E.indices)==null?void 0:z.length)>6*I)||E.vertices.length<vp.BATCHABLE_SIZE*2)E.vertices=new Float32Array(4*2*I),E.uvs=new Float32Array(4*2*I),E.indices=new Uint16Array(6*I);else{const P=E.total,$=E.vertices;for(let k=P*4*2;k<$.length;k++)$[k]=0}E.mesh.size=6*I}for(let C=0;C<w;C++){const E=n[C];let I=E.position.x+S[E.line]*(this._align==="justify"?E.prevSpaces:1);this._roundPixels&&(I=Math.round(I));const P=I*i,$=E.position.y*i,k=E.texture,G=T[k.baseTexture.uid],st=k.frame,M=k._uvs,L=G.index++;G.indices[L*6+0]=0+L*4,G.indices[L*6+1]=1+L*4,G.indices[L*6+2]=2+L*4,G.indices[L*6+3]=0+L*4,G.indices[L*6+4]=2+L*4,G.indices[L*6+5]=3+L*4,G.vertices[L*8+0]=P,G.vertices[L*8+1]=$,G.vertices[L*8+2]=P+st.width*i,G.vertices[L*8+3]=$,G.vertices[L*8+4]=P+st.width*i,G.vertices[L*8+5]=$+st.height*i,G.vertices[L*8+6]=P,G.vertices[L*8+7]=$+st.height*i,G.uvs[L*8+0]=M.x0,G.uvs[L*8+1]=M.y0,G.uvs[L*8+2]=M.x1,G.uvs[L*8+3]=M.y1,G.uvs[L*8+4]=M.x2,G.uvs[L*8+5]=M.y2,G.uvs[L*8+6]=M.x3,G.uvs[L*8+7]=M.y3}this._textWidth=f*i,this._textHeight=(s.y+t.lineHeight)*i;for(const C in T){const E=T[C];if(this.anchor.x!==0||this.anchor.y!==0){let k=0;const G=this._textWidth*this.anchor.x,st=this._textHeight*this.anchor.y;for(let M=0;M<E.total;M++)E.vertices[k++]-=G,E.vertices[k++]-=st,E.vertices[k++]-=G,E.vertices[k++]-=st,E.vertices[k++]-=G,E.vertices[k++]-=st,E.vertices[k++]-=G,E.vertices[k++]-=st}this._maxLineHeight=g*i;const I=E.mesh.geometry.getBuffer("aVertexPosition"),P=E.mesh.geometry.getBuffer("aTextureCoord"),$=E.mesh.geometry.getIndex();I.data=E.vertices,P.data=E.uvs,$.data=E.indices,I.update(),P.update(),$.update()}for(let C=0;C<n.length;C++)Fp.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}=Wr.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=Wr.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Wr.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Wr.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Wr.available[this._fontName].distanceFieldType==="none"?Lp:Bp;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=Z.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};vA.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const xA=[".xml",".fnt"],bA={extension:{type:W.LoadParser,priority:Ke.Normal},name:"loadBitmapFont",test(r){return xA.includes(se.extname(r).toLowerCase())},async testParse(r){return Co.test(r)||uh.test(r)},async parse(r,t,e){const i=Co.test(r)?Co.parse(r):uh.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const u=n[h].file;let c=se.join(se.dirname(s),u);c=Yl(c,s),o.push(c)}const a=await e.load(o),l=o.map(h=>a[h]);return Wr.install(i,l,!0)},async load(r,t){return(await j.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};K.add(bA);const dh=class cs extends Xr{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new cs(Object.keys(cs.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 cs.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=cs;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return j.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:se.basename(t,se.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=db(t)),typeof t=="number"?cb(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,cs.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}=j.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};fh.availableFonts={},fh.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let ph=fh;const Ro=class ds extends ts{constructor(t="",e={}){super(Z.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=Z.from(i,{scaleMode:j.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new pt,s.trim=new pt,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=ds.defaultMaxWidth,this.maxHeight=ds.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=ds.defaultAutoResolution,this._resolution=ds.defaultResolution??j.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({},ds.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=Fr(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=Fr(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 Xr?(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(/ /gi," ")}};Ro.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ro.defaultMaxWidth=2024,Ro.defaultMaxHeight=2024,Ro.defaultAutoResolution=!0;const wA=16777215,AA=.25,SA=16777215,CA=1,IA=1.5;let Yr=!1,Ys;const mh=r=>{const t={tint:r!=null&&r.fill?new wt(r.fill).toNumber():wA,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 wt(r==null?void 0:r.fill).alpha:AA},e={tint:r!=null&&r.stroke?new wt(r.stroke).toNumber():SA,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 wt(r==null?void 0:r.stroke).alpha:CA,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?IA:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Mo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=mh(i),o=new Ws;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new Ws,l=n.lineWidth===1?1:n.lineWidth/Ys;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}},RA=Mo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),MA=Mo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),PA=Mo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),OA=Mo((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()})})}),Gp=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},$p=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Gp(r);(n!==Ys||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(Yr=n===Ys,f.width=p/n,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),Ys=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)},NA=(r,t)=>{const e=new Ws,i=Ff({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Ys=Gp(r);const l=(g,x)=>{Yr=!1;const{selector:b}=g.target,S=typeof a=="function"?a(g,x):a;let w;b.type===vt.RECTANGLE?w=RA(e,b,S):b.type===vt.POLYGON?w=PA(e,b,S):b.type===vt.ELLIPSE?w=MA(e,b,S):b.type===vt.MULTIPOLYGLON?w=OA(e,b,S):console.warn(`Unsupported shape type: ${b.type}`),w&&s.set(g.id,{annotation:g,...w})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,b)=>{Yr=!1;const S=s.get(g.id);S&&(s.delete(g.id),S.fill.destroy(),S.stroke.destroy(),l(x,b))},c=(g,x)=>{const b=s.get(g);b&&(s.delete(g),b.fill.destroy(),b.stroke.destroy(),l(b.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},p=g=>{Yr=!1;const{children:x}=e;s.forEach(({fill:b,stroke:S,annotation:w})=>{const T=g?n.has(w.id)||g(w):!0;T&&!x.includes(b)?(e.addChild(b),e.addChild(S)):!T&&x.includes(b)&&(e.removeChild(b),e.removeChild(S))}),i.render(e)},f=g=>{o!==g&&(o&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const x=g.selected.map(w=>w.id),b=x.filter(w=>!n.has(w)),S=[...n].filter(w=>!x.includes(w));[...b,...S].forEach(w=>c(w,{selected:x.includes(w),hovered:w===o})),n=new Set(x),i.render(e)},y=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:b,stroke:S,strokeWidth:w},T)=>{w>1&&(Yr=!1);const N={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:z}=mh(g(x,N));b.tint=F.tint,b.alpha=F.alpha,S.tint=z.tint||16777215,S.alpha=z.alpha,s.set(x.id,{annotation:x,fill:b,stroke:S,strokeWidth:z.lineWidth})});else{const{fillStyle:x,strokeStyle:b}=mh(g);b.lineWidth>1&&(Yr=!1),s.forEach(({annotation:S,fill:w,stroke:T,strokeWidth:N},F)=>{w.tint=x.tint,w.alpha=x.alpha,T.tint=b.tint||16777215,T.alpha=b.alpha,s.set(S.id,{annotation:S,fill:w,stroke:T,strokeWidth:b.lineWidth})})}a=g,i.render(e),$p(r,e,s,i)()},_=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:$p(r,e,s,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:f,setSelected:m,setStyle:y,setVisible:_,updateAnnotation:u}};function DA(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;fn(r,c,S=>e(11,i=S)),fn(r,d,S=>e(8,s=S));const f=yn();let m,y;const _=S=>{const w=new de.Point(S.x,S.y),{x:T,y:N}=l.viewport.pointFromPixel(w);return l.viewport.viewportToImageCoordinates(T,N)},v=S=>{const{x:w,y:T}=S.position;y={x:w,y:T}},g=S=>w=>{const{x:T,y:N}=_(new de.Point(w.offsetX,w.offsetY)),F=u.getAt(T,N);F&&(!n||n(F))?(S.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(S.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=S=>{if(!y)return;const w=S.originalEvent,{x:T,y:N}=S.position,F=T-y.x,z=N-y.y;if(Math.sqrt(F*F+z*z)<5){const{x:E,y:I}=_(S.position),P=u.getAt(E,I);P?f("click",{originalEvent:w,annotation:P}):f("click",{originalEvent:w})}y=void 0};let b;return gn(()=>{var P;const{offsetWidth:S,offsetHeight:w}=l.canvas,T=document.createElement("canvas");T.width=S,T.height=w,T.className="a9s-gl-canvas",(P=l.element.querySelector(".openseadragon-canvas"))==null||P.appendChild(T),e(7,m=NA(l,T));const N=g(T);T.addEventListener("pointermove",N);const F=new ResizeObserver($=>{try{const{width:k,height:G}=$[0].contentRect;T.width=k,T.height=G,m.resize(k,G)}catch{console.warn("WebGL canvas already disposed")}});F.observe(T);const z=()=>{const $=l.viewport.getBounds();b=l.viewport.viewportToImageRectangle($);const{x:k,y:G,width:st,height:M}=b,L=u.getIntersecting(k,G,st,M);p.set(L.map(V=>V.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",z);const C=$=>$.filter(k=>Ge(k)),E=$=>Ge($.oldValue)&&Ge($.newValue),I=$=>{const{created:k,updated:G,deleted:st}=$.changes;if(C(k||[]).forEach(M=>m.addAnnotation(M)),C(st||[]).forEach(M=>m.removeAnnotation(M)),(G||[]).filter(M=>E(M)).forEach(({oldValue:M,newValue:L})=>m.updateAnnotation(M,L)),b){const{x:M,y:L,width:V,height:rt}=b,Q=u.getIntersecting(M,L,V,rt);p.set(Q.map(X=>X.id))}else p.set(u.all().map(M=>M.id));m.redraw()};return u.observe(I),()=>{var $;T.removeEventListener("pointermove",N),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",z),u.unobserve(I),m.destroy(),($=T.parentNode)==null||$.removeChild(T)}}),r.$$set=S=>{"filter"in S&&e(2,n=S.filter),"state"in S&&e(3,o=S.state),"style"in S&&e(4,a=S.style),"viewer"in S&&e(5,l=S.viewer),"visible"in S&&e(6,h=S.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 LA extends re{constructor(t){super(),ee(this,t,DA,null,Wt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const ce=[];for(let r=0;r<256;++r)ce.push((r+256).toString(16).slice(1));function BA(r,t=0){return(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase()}let gh;const FA=new Uint8Array(16);function UA(){if(!gh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");gh=crypto.getRandomValues.bind(crypto)}return gh(FA)}const Hp={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function kA(r,t,e){var s;if(Hp.randomUUID&&!r)return Hp.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??UA();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,BA(i)}var jr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(jr||{});const Po=(r,t)=>t,Oo=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}},yh=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)},_h=(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},GA=(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},$A={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}};Po(jr.ELLIPSE,$A);const HA={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=yh(s.points),a=n.reduce((l,h)=>l+yh(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(_h(n.points,t,e)){let a=!1;for(const l of o)if(_h(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},VA=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Oo(t)},No=r=>r.rings.map(e=>GA(e.points)).join(" ");Po(jr.MULTIPOLYGLON,HA);const XA={area:r=>{const t=r.geometry.points;return yh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return _h(i,t,e)}};Po(jr.POLYGON,XA);const zA={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};Po(jr.RECTANGLE,zA);const jt=" ";function WA(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===U.CLOSE_PATH)t+="z";else if(i.type===U.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===U.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===U.MOVE_TO)t+=(i.relative?"m":"M")+i.x+jt+i.y;else if(i.type===U.LINE_TO)t+=(i.relative?"l":"L")+i.x+jt+i.y;else if(i.type===U.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+jt+i.y1+jt+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+jt+i.y1+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+jt+i.y;else if(i.type===U.ARC)t+=(i.relative?"a":"A")+i.rX+jt+i.rY+jt+i.xRot+jt+ +i.lArcFlag+jt+ +i.sweepFlag+jt+i.x+jt+i.y;else throw new Error(`Unexpected command type "${i==null?void 0:i.type}" at index ${e}.`)}return t}function vh([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 qr=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*qr,[l,h]=vh([(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=vh([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*qr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*qr),r.phi1*=180/qr,r.phi2*=180/qr}function Vp(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 Ai=Math.PI/180;function Xp(r,t,e){return(1-e)*r+e*t}function zp(r,t,e,i){return r+Math.cos(i/180*qr)*t+Math.sin(i/180*qr)*e}function Wp(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]:YA(h/l,u/l,1e-6)}function Yp(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 YA(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 jA(r,t,e){r.cX||xh(r,t,e);const i=r.xRot/180*qr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:U.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]=vh([d*r.rX,p*r.rY],i);return[r.cX+f,r.cY+m]};for(let d=0;d<a;d++){const p=Xp(r.phi1,r.phi2,d/a),f=Xp(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*Ai/4),_=Math.cos(p*Ai)-y*Math.sin(p*Ai),v=Math.sin(p*Ai)+y*Math.cos(p*Ai),g=Math.cos(f*Ai),x=Math.sin(f*Ai),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:U.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function bh(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 qA(r,t=!0){if(r.length<2)return r;const e=qt.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===U.MOVE_TO&&s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s))),i}function Do(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===U.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:U.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 U.HORIZ_LINE_TO:i.push({type:U.HORIZ_LINE_TO,relative:!1,x:a.x});break;case U.VERT_LINE_TO:i.push({type:U.VERT_LINE_TO,relative:!1,y:a.y});break;case U.LINE_TO:case U.MOVE_TO:i.push({type:U.LINE_TO,relative:!1,x:a.x,y:a.y});break;case U.CURVE_TO:i.push({type:U.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case U.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case U.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case U.ARC:throw new Error("Unsupported command: A (arc)");case U.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:U.CLOSE_PATH}),i}function KA(r=1e13){Qe(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 jp(){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 ZA(){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 QA(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&U.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&U.HORIZ_LINE_TO&&(s.type=U.LINE_TO,s.y=s.relative?0:o),e&&s.type&U.VERT_LINE_TO&&(s.type=U.LINE_TO,s.x=s.relative?0:n),r&&s.type&U.CLOSE_PATH&&(s.type=U.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&U.ARC&&(s.rX===0||s.rY===0)&&(s.type=U.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&U.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];bh(h,u,c)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&U.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];bh(h,u,d)&&bh(h,c,d)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function qp(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&U.SMOOTH_CURVE_TO&&(s.type=U.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&U.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&U.SMOOTH_QUAD_TO&&(s.type=U.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&U.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function Kp(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&U.SMOOTH_QUAD_TO&&(e.type=U.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&U.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=U.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(o){if(isNaN(i)&&!(o.type&U.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&U.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&U.MOVE_TO&&(i=t,s=e),a}}function JA(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&U.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(U.CURVE_TO|U.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&U.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&U.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&U.LINE_COMMANDS||n.type&U.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&U.CURVE_TO||n.type&U.SMOOTH_CURVE_TO||n.type&U.QUAD_TO||n.type&U.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&U.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Kr(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&U.HORIZ_LINE_TO&&t!==0&&(o.type=U.LINE_TO,o.y=o.relative?0:l),o.type&U.VERT_LINE_TO&&e!==0&&(o.type=U.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=U.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function tS(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Kr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function eS(r,t=0){return Qe(r,t),Kr(1,0,0,1,r,t)}function rS(r,t=r){return Qe(r,t),Kr(r,0,0,t,0,0)}function iS(r){return Qe(r),Kr(1,0,Math.tan(r),1,0,0)}function sS(r){return Qe(r),Kr(1,Math.tan(r),0,1,0,0)}function nS(r=0){return Qe(r),Kr(-1,0,0,1,r,0)}function oS(r=0){return Qe(r),Kr(1,0,0,-1,0,r)}function aS(){return Je((r,t,e)=>U.ARC===r.type?jA(r,r.relative?0:t,r.relative?0:e):r)}function lS(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),U.ARC===r.type&&xh(r,t,e),r))}function Zp(){return r=>({...r})}function hS(){const r=Zp(),t=jp(),e=Kp(),i=qp(),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&U.DRAWING_COMMANDS&&(h(o),u(a)),l.type&U.HORIZ_LINE_TO&&h(l.x),l.type&U.VERT_LINE_TO&&u(l.y),l.type&U.LINE_TO&&(h(l.x),u(l.y)),l.type&U.CURVE_TO){h(l.x),u(l.y);const c=Wp(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(Yp(o,l.x1,l.x2,l.x,p));const d=Wp(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(Yp(a,l.y1,l.y2,l.y,p))}if(l.type&U.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=([b,S])=>{const T=Math.atan2(S,b)*180/Math.PI;return T<y?T+360:T},g=Vp(f,-d,0).map(v);for(const b of g)b>y&&b<_&&h(zp(l.cX,d,f,b));const x=Vp(m,-p,0).map(v);for(const b of x)b>y&&b<_&&u(zp(l.cY,p,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const qt={ROUND:KA,TO_ABS:jp,TO_REL:ZA,NORMALIZE_HVZ:QA,NORMALIZE_ST:qp,QT_TO_C:Kp,INFO:Je,SANITIZE:JA,MATRIX:Kr,ROTATE:tS,TRANSLATE:eS,SCALE:rS,SKEW_X:iS,SKEW_Y:sS,X_AXIS_SYMMETRY:nS,Y_AXIS_SYMMETRY:oS,A_TO_C:aS,ANNOTATE_ARCS:lS,CLONE:Zp,CALCULATE_BOUNDS:hS,REVERSE_PATH:qA};class Qp{round(t){return this.transform(qt.ROUND(t))}toAbs(){return this.transform(qt.TO_ABS())}toRel(){return this.transform(qt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(qt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(qt.NORMALIZE_ST())}qtToC(){return this.transform(qt.QT_TO_C())}aToC(){return this.transform(qt.A_TO_C())}sanitize(t){return this.transform(qt.SANITIZE(t))}translate(t,e){return this.transform(qt.TRANSLATE(t,e))}scale(t,e){return this.transform(qt.SCALE(t,e))}rotate(t,e,i){return this.transform(qt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(qt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(qt.SKEW_X(t))}skewY(t){return this.transform(qt.SKEW_Y(t))}xSymmetry(t){return this.transform(qt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(qt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(qt.ANNOTATE_ARCS())}}const uS=r=>r===" "||r===" "||r==="\r"||r===`
|
|
1149
|
-
`,Jp=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class cS extends Qp{constructor(){super();Pt(this,"curNumber","");Pt(this,"curCommandType",-1);Pt(this,"curCommandRelative",!1);Pt(this,"canParseCommandOrComma",!0);Pt(this,"curNumberHasExp",!1);Pt(this,"curNumberHasExpDigits",!1);Pt(this,"curNumberHasDecimal",!1);Pt(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===U.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=Jp(o)&&(this.curNumber==="0"&&o==="0"||a);if(Jp(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===U.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===dS[this.curCommandType]&&(U.HORIZ_LINE_TO===this.curCommandType?s({type:U.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):U.VERT_LINE_TO===this.curCommandType?s({type:U.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===U.MOVE_TO||this.curCommandType===U.LINE_TO||this.curCommandType===U.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),U.MOVE_TO===this.curCommandType&&(this.curCommandType=U.LINE_TO)):this.curCommandType===U.CURVE_TO?s({type:U.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===U.SMOOTH_CURVE_TO?s({type:U.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.QUAD_TO?s({type:U.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.ARC&&s({type:U.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(!uS(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:U.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=U.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=U.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=U.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=U.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=U.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=U.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=U.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=U.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=U.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 At=class At extends Qp{constructor(e){super();Pt(this,"commands");typeof e=="string"?this.commands=At.parse(e):this.commands=e}encode(){return At.encode(this.commands)}getBounds(){const e=qt.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=qt.REVERSE_PATH(this.commands,e),this}static encode(e){return WA(e)}static parse(e){const i=new cS,s=[];return i.parse(e,s),i.finish(s),s}};Pt(At,"CLOSE_PATH",1),Pt(At,"MOVE_TO",2),Pt(At,"HORIZ_LINE_TO",4),Pt(At,"VERT_LINE_TO",8),Pt(At,"LINE_TO",16),Pt(At,"CURVE_TO",32),Pt(At,"SMOOTH_CURVE_TO",64),Pt(At,"QUAD_TO",128),Pt(At,"SMOOTH_QUAD_TO",256),Pt(At,"ARC",512),Pt(At,"LINE_COMMANDS",At.LINE_TO|At.HORIZ_LINE_TO|At.VERT_LINE_TO),Pt(At,"DRAWING_COMMANDS",At.HORIZ_LINE_TO|At.VERT_LINE_TO|At.LINE_TO|At.CURVE_TO|At.SMOOTH_CURVE_TO|At.QUAD_TO|At.SMOOTH_QUAD_TO|At.ARC);let U=At;const dS={[U.MOVE_TO]:2,[U.LINE_TO]:2,[U.HORIZ_LINE_TO]:1,[U.VERT_LINE_TO]:1,[U.CLOSE_PATH]:0,[U.QUAD_TO]:4,[U.SMOOTH_QUAD_TO]:2,[U.CURVE_TO]:6,[U.SMOOTH_CURVE_TO]:4,[U.ARC]:7};function tm(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function em(r){let t,e;return t=new ls({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function fS(r){let t,e,i,s,n,o,a,l,h,u,c,d=Se(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=em(tm(r,d,m));const f=m=>et(p[m],1,1,()=>{p[m]=null});return{c(){t=xt("polygon"),s=Ve(),n=xt("polygon"),a=Ve();for(let m=0;m<p.length;m+=1)p[m].c();l=Re(),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"points",i=r[4].points.map(rm).join(" ")),R(n,"class","a9s-inner a9s-shape-handle"),R(n,"style",r[1]),R(n,"points",o=r[4].points.map(im).join(" "))},m(m,y){ct(m,t,y),ct(m,s,y),ct(m,n,y),ct(m,a,y);for(let _=0;_<p.length;_+=1)p[_]&&p[_].m(m,y);ct(m,l,y),h=!0,u||(c=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,y){if(r=m,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(rm).join(" ")))&&R(t,"points",i),(!h||y&2)&&R(n,"style",r[1]),(!h||y&16&&o!==(o=r[4].points.map(im).join(" ")))&&R(n,"points",o),y&536){d=Se(r[4].points);let _;for(_=0;_<d.length;_+=1){const v=tm(r,d,_);p[_]?(p[_].p(v,y),q(p[_],1)):(p[_]=em(v),p[_].c(),q(p[_],1),p[_].m(l.parentNode,l))}for(ge(),_=d.length;_<p.length;_+=1)f(_);ye()}},i(m){if(!h){for(let y=0;y<d.length;y+=1)q(p[y]);h=!0}},o(m){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)et(p[y]);h=!1},d(m){m&&(ht(t),ht(s),ht(n),ht(a),ht(l)),ii(p,m),u=!1,er(c)}}}function pS(r){let t,e;return t=new Eh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[fS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){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&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}const rm=r=>r.join(","),im=r=>r.join(",");function mS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const y=d.geometry;p==="SHAPE"?m=y.points.map(([v,g])=>[v+f[0],g+f[1]]):m=y.points.map(([v,g],x)=>p===`HANDLE-${x}`?[v+f[0],g+f[1]]:[v,g]);const _=Oo(m);return{...d,geometry:{points:m,bounds:_}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class gS extends re{constructor(t){super(),ee(this,t,mS,pS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const yS=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function _S(r){let t,e,i,s,n,o;return{c(){t=xt("rect"),R(t,"class",e=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(t,"x",i=r[0]-r[5]/2),R(t,"y",s=r[1]-r[5]/2),R(t,"width",r[5]),R(t,"height",r[5])},m(a,l){ct(a,t,l),n||(o=Zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=pn(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&R(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&R(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&R(t,"y",s),l&32&&R(t,"width",a[5]),l&32&&R(t,"height",a[5])},d(a){a&&ht(t),n=!1,o()}}}function vS(r){let t,e,i,s,n,o,a,l,h;return{c(){t=xt("g"),e=xt("circle"),s=xt("rect"),R(e,"cx",r[0]),R(e,"cy",r[1]),R(e,"r",i=r[3]/r[2]),R(e,"class","a9s-touch-halo svelte-1sgkh33"),mn(e,"touched",r[4]),R(s,"class",n=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(s,"x",o=r[0]-r[5]/2),R(s,"y",a=r[1]-r[5]/2),R(s,"width",r[5]),R(s,"height",r[5]),R(t,"class","a9s-touch-handle")},m(u,c){ct(u,t,c),Ae(t,e),Ae(t,s),l||(h=[Zt(e,"pointerdown",r[10]),Zt(e,"pointerdown",r[6]),Zt(e,"pointerup",r[7]),Zt(s,"pointerdown",r[9]),Zt(s,"pointerdown",r[6]),Zt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&R(e,"cx",u[0]),c&2&&R(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&R(e,"r",i),c&16&&mn(e,"touched",u[4]),c&256&&n!==(n=pn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&R(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&R(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&R(s,"y",a),c&32&&R(s,"width",u[5]),c&32&&R(s,"height",u[5])},d(u){u&&ht(t),l=!1,er(h)}}}function xS(r){let t;function e(n,o){return yS?vS:_S}let s=e()(r);return{c(){s.c(),t=Re()},m(n,o){s.m(n,o),ct(n,t,o)},p(n,[o]){s.p(n,o)},i:me,o:me,d(n){n&&ht(t),s.d(n)}}}function bS(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){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(8,t=pa(pa({},t),ic(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=ic(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class ls extends re{constructor(t){super(),ee(this,t,bS,xS,Wt,{x:0,y:1,scale:2,radius:3})}}function ES(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,b,S,w,T,N,F,z,C,E,I,P,$,k,G,st,M,L,V,rt,Q,X,_t,St;return G=new ls({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),G.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),M=new ls({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),M.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),V=new ls({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),V.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new ls({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Kt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=xt("rect"),a=Ve(),l=xt("rect"),p=Ve(),f=xt("rect"),v=Ve(),g=xt("rect"),w=Ve(),T=xt("rect"),C=Ve(),E=xt("rect"),k=Ve(),Ht(G.$$.fragment),st=Ve(),Ht(M.$$.fragment),L=Ve(),Ht(V.$$.fragment),rt=Ve(),Ht(Q.$$.fragment),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"x",i=r[4].x),R(t,"y",s=r[4].y),R(t,"width",n=r[4].w),R(t,"height",o=r[4].h),R(l,"class","a9s-inner a9s-shape-handle"),R(l,"style",r[1]),R(l,"x",h=r[4].x),R(l,"y",u=r[4].y),R(l,"width",c=r[4].w),R(l,"height",d=r[4].h),R(f,"class","a9s-edge-handle a9s-edge-handle-top"),R(f,"x",m=r[4].x),R(f,"y",y=r[4].y),R(f,"height",1),R(f,"width",_=r[4].w),R(g,"class","a9s-edge-handle a9s-edge-handle-right"),R(g,"x",x=r[4].x+r[4].w),R(g,"y",b=r[4].y),R(g,"height",S=r[4].h),R(g,"width",1),R(T,"class","a9s-edge-handle a9s-edge-handle-bottom"),R(T,"x",N=r[4].x),R(T,"y",F=r[4].y+r[4].h),R(T,"height",1),R(T,"width",z=r[4].w),R(E,"class","a9s-edge-handle a9s-edge-handle-left"),R(E,"x",I=r[4].x),R(E,"y",P=r[4].y),R(E,"height",$=r[4].h),R(E,"width",1)},m(O,D){ct(O,t,D),ct(O,a,D),ct(O,l,D),ct(O,p,D),ct(O,f,D),ct(O,v,D),ct(O,g,D),ct(O,w,D),ct(O,T,D),ct(O,C,D),ct(O,E,D),ct(O,k,D),Ft(G,O,D),ct(O,st,D),Ft(M,O,D),ct(O,L,D),Ft(V,O,D),ct(O,rt,D),Ft(Q,O,D),X=!0,_t||(St=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(l,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(f,"pointerdown",function(){Kt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Zt(g,"pointerdown",function(){Kt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Zt(T,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Zt(E,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(O,D){r=O,(!X||D&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!X||D&16&&i!==(i=r[4].x))&&R(t,"x",i),(!X||D&16&&s!==(s=r[4].y))&&R(t,"y",s),(!X||D&16&&n!==(n=r[4].w))&&R(t,"width",n),(!X||D&16&&o!==(o=r[4].h))&&R(t,"height",o),(!X||D&2)&&R(l,"style",r[1]),(!X||D&16&&h!==(h=r[4].x))&&R(l,"x",h),(!X||D&16&&u!==(u=r[4].y))&&R(l,"y",u),(!X||D&16&&c!==(c=r[4].w))&&R(l,"width",c),(!X||D&16&&d!==(d=r[4].h))&&R(l,"height",d),(!X||D&16&&m!==(m=r[4].x))&&R(f,"x",m),(!X||D&16&&y!==(y=r[4].y))&&R(f,"y",y),(!X||D&16&&_!==(_=r[4].w))&&R(f,"width",_),(!X||D&16&&x!==(x=r[4].x+r[4].w))&&R(g,"x",x),(!X||D&16&&b!==(b=r[4].y))&&R(g,"y",b),(!X||D&16&&S!==(S=r[4].h))&&R(g,"height",S),(!X||D&16&&N!==(N=r[4].x))&&R(T,"x",N),(!X||D&16&&F!==(F=r[4].y+r[4].h))&&R(T,"y",F),(!X||D&16&&z!==(z=r[4].w))&&R(T,"width",z),(!X||D&16&&I!==(I=r[4].x))&&R(E,"x",I),(!X||D&16&&P!==(P=r[4].y))&&R(E,"y",P),(!X||D&16&&$!==($=r[4].h))&&R(E,"height",$);const ut={};D&16&&(ut.x=r[4].x),D&16&&(ut.y=r[4].y),D&8&&(ut.scale=r[3]),G.$set(ut);const lt={};D&16&&(lt.x=r[4].x+r[4].w),D&16&&(lt.y=r[4].y),D&8&&(lt.scale=r[3]),M.$set(lt);const Et={};D&16&&(Et.x=r[4].x+r[4].w),D&16&&(Et.y=r[4].y+r[4].h),D&8&&(Et.scale=r[3]),V.$set(Et);const Tt={};D&16&&(Tt.x=r[4].x),D&16&&(Tt.y=r[4].y+r[4].h),D&8&&(Tt.scale=r[3]),Q.$set(Tt)},i(O){X||(q(G.$$.fragment,O),q(M.$$.fragment,O),q(V.$$.fragment,O),q(Q.$$.fragment,O),X=!0)},o(O){et(G.$$.fragment,O),et(M.$$.fragment,O),et(V.$$.fragment,O),et(Q.$$.fragment,O),X=!1},d(O){O&&(ht(t),ht(a),ht(l),ht(p),ht(f),ht(v),ht(g),ht(w),ht(T),ht(C),ht(E),ht(k),ht(st),ht(L),ht(rt)),Ut(G,O),Ut(M,O),Ut(V,O),Ut(Q,O),_t=!1,er(St)}}}function TS(r){let t,e;return t=new Eh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[ES,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){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&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function wS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[y,_]=[m.minX,m.minY],[v,g]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,v+=x,_+=b,g+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{_+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const S=Math.min(y,v),w=Math.min(_,g),T=Math.abs(v-y),N=Math.abs(g-_);return{...d,geometry:{x:S,y:w,w:T,h:N,bounds:{minX:S,minY:w,maxX:S+T,maxY:w+N}}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class AS extends re{constructor(t){super(),ee(this,t,wS,TS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}function sm(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function nm(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function om(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function am(r){let t,e;return t=new ls({props:{x:r[16][0],y:r[16][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`))&&r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[16][0]),s&16&&(n.y=r[16][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function lm(r){let t,e,i=Se(r[13].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=am(om(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&536){i=Se(o[13].points);let l;for(l=0;l<i.length;l+=1){const h=om(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=am(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function hm(r){let t,e,i,s,n,o,a,l,h,u=Se(r[10].rings),c=[];for(let p=0;p<u.length;p+=1)c[p]=lm(nm(r,u,p));const d=p=>et(c[p],1,1,()=>{c[p]=null});return{c(){t=xt("g"),e=xt("path"),n=xt("path");for(let p=0;p<c.length;p+=1)c[p].c();R(e,"class","a9s-outer"),R(e,"style",i=r[1]?"display:none;":void 0),R(e,"fill-rule","evenodd"),R(e,"d",s=No(r[10])),R(n,"class","a9s-inner"),R(n,"style",r[1]),R(n,"fill-rule","evenodd"),R(n,"d",o=No(r[10]))},m(p,f){ct(p,t,f),Ae(t,e),Ae(t,n);for(let m=0;m<c.length;m+=1)c[m]&&c[m].m(t,null);a=!0,l||(h=[Zt(e,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],l=!0)},p(p,f){if(r=p,(!a||f&2&&i!==(i=r[1]?"display:none;":void 0))&&R(e,"style",i),(!a||f&16&&s!==(s=No(r[10])))&&R(e,"d",s),(!a||f&2)&&R(n,"style",r[1]),(!a||f&16&&o!==(o=No(r[10])))&&R(n,"d",o),f&536){u=Se(r[10].rings);let m;for(m=0;m<u.length;m+=1){const y=nm(r,u,m);c[m]?(c[m].p(y,f),q(c[m],1)):(c[m]=lm(y),c[m].c(),q(c[m],1),c[m].m(t,null))}for(ge(),m=u.length;m<c.length;m+=1)d(m);ye()}},i(p){if(!a){for(let f=0;f<u.length;f+=1)q(c[f]);a=!0}},o(p){c=c.filter(Boolean);for(let f=0;f<c.length;f+=1)et(c[f]);a=!1},d(p){p&&ht(t),ii(c,p),l=!1,er(h)}}}function SS(r){let t,e,i=Se(r[4].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=hm(sm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&538){i=Se(o[4].polygons);let l;for(l=0;l<i.length;l+=1){const h=sm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=hm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function CS(r){let t,e;return t=new Eh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[SS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){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&524826&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function IS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.polygons;let y;if(p==="SHAPE")y=m.map(_=>{const v=_.rings.map((x,b)=>({points:x.points.map((w,T)=>[w[0]+f[0],w[1]+f[1]])})),g=Oo(v[0].points);return{rings:v,bounds:g}});else{const[_,v,g,x]=p.split("-").map(b=>parseInt(b));y=m.map((b,S)=>{if(S===v){const w=b.rings.map((N,F)=>F===g?{points:N.points.map((C,E)=>E===x?[C[0]+f[0],C[1]+f[1]]:C)}:N),T=Oo(w[0].points);return{rings:w,bounds:T}}else return b})}return{...d,geometry:{polygons:y,bounds:VA(y)}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class RS extends re{constructor(t){super(),ee(this,t,IS,CS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}jr.RECTANGLE,jr.POLYGON,jr.MULTIPOLYGLON;const MS=r=>({}),um=r=>({grab:r[0]});function PS(r){let t,e,i,s;const n=r[7].default,o=Qu(n,r,r[6],um);return{c(){t=xt("g"),o&&o.c(),R(t,"class","a9s-annotation selected")},m(a,l){ct(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Zt(t,"pointerup",r[2]),Zt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&ec(o,n,a,a[6],e?tc(n,a[6],l,MS):rc(a[6]),um)},i(a){e||(q(o,a),e=!0)},o(a){et(o,a),e=!1},d(a){a&&ht(t),o&&o.d(a),i=!1,er(s)}}}function OS(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=yn();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>y=>{h=m,u=l.elementToImage(y.offsetX,y.offsetY),c=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=m=>{if(h){const[y,_]=l.elementToImage(m.offsetX,m.offsetY),v=[y-u[0],_-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class Eh extends re{constructor(t){super(),ee(this,t,OS,PS,Wt,{shape:3,editor:4,transform:5})}}const NS=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function DS(r,t,e){let i;const s=yn();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return gn(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=NS(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 LS extends re{constructor(t){super(),ee(this,t,DS,null,Wt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const cm=(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},BS=r=>({transform:r&2,scale:r&1}),dm=r=>({transform:r[1],scale:r[0]});function FS(r){let t;const e=r[4].default,i=Qu(e,r,r[3],dm);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&ec(i,e,s,s[3],t?tc(e,s[3],n,BS):rc(s[3]),dm)},i(s){t||(q(i,s),t=!0)},o(s){et(i,s),t=!1},d(s){i&&i.d(s)}}}function US(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 de.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 gn(()=>(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 Th extends re{constructor(t){super(),ee(this,t,US,FS,Wt,{viewer:2})}}function kS(r,t,e){const i=yn();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,u;return gn(()=>{const c=n.closest("svg"),d=[],p=(f,m,y)=>{if(c==null||c.addEventListener(f,m,y),d.push(()=>c==null?void 0:c.removeEventListener(f,m,y)),f==="pointerup"||f==="dblclick"){const _=g=>{const{originalEvent:x}=g;m(x)},v=f==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(v,_),d.push(()=>l.removeHandler(v,_))}else if(f==="pointermove"){const _=v=>{const{originalEvent:g}=v;m(g)};l.addHandler("canvas-drag",_),d.push(()=>l.removeHandler("canvas-drag",_))}};return e(6,u=new o({target:n,props:{addEventListener:p,drawingMode:s,transform:a,viewportScale:h}})),u.$on("create",f=>i("create",f.detail)),()=>{d.forEach(f=>f()),u.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewer"in c&&e(4,l=c.viewer),"viewportScale"in c&&e(5,h=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&u&&u.$set({transform:a}),r.$$.dirty&96&&u&&u.$set({viewportScale:h})},[s,n,o,a,l,h,u]}class GS extends re{constructor(t){super(),ee(this,t,kS,null,Wt,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function fm(r,t,e){const i=r.slice();i[36]=t[e];const s=i[15](i[36].target.selector);return i[37]=s,i}function $S(r){let t=`${r[2]}-${r[5]}`,e,i,s=pm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&36&&Wt(t,t=`${n[2]}-${n[5]}`)?(ge(),et(s,1,1,me),ye(),s=pm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function HS(r){let t,e,i=Se(r[7].filter(r[26])),s=[];for(let o=0;o<i.length;o+=1)s[o]=ym(fm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a[0]&48322|a[1]&16){i=Se(o[7].filter(o[26]));let l;for(l=0;l<i.length;l+=1){const h=fm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=ym(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function pm(r){let t,e;return t=new GS({props:{target:r[6],tool:r[8],drawingMode:r[4],transform:{elementToImage:r[10]},viewer:r[3],viewportScale:r[35]}}),t.$on("create",r[14]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&256&&(n.tool=i[8]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&16&&(n.viewportScale=i[35]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function mm(r){let t=r[36].id,e,i,s=gm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&128&&Wt(t,t=n[36].id)?(ge(),et(s,1,1,me),ye(),s=gm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function gm(r){let t,e;return t=new LS({props:{target:r[6],editor:r[15](r[36].target.selector),annotation:r[36],style:r[1],transform:{elementToImage:r[10]},viewportScale:r[35]}}),t.$on("grab",r[11]),t.$on("change",function(){Kt(r[13](r[36]))&&r[13](r[36]).apply(this,arguments)}),t.$on("release",r[12]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&128&&(n.editor=r[15](r[36].target.selector)),s[0]&128&&(n.annotation=r[36]),s[0]&2&&(n.style=r[1]),s[1]&16&&(n.viewportScale=r[35]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function ym(r){let t,e,i=r[37]&&mm(r);return{c(){i&&i.c(),t=Re()},m(s,n){i&&i.m(s,n),ct(s,t,n),e=!0},p(s,n){s[37]?i?(i.p(s,n),n[0]&128&&q(i,1)):(i=mm(s),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(ge(),et(i,1,1,()=>{i=null}),ye())},i(s){e||(q(i),e=!0)},o(s){et(i),e=!1},d(s){s&&ht(t),i&&i.d(s)}}}function VS(r){let t,e,i,s,n,o;const a=[HS,$S],l=[];function h(u,c){var d;return u[6]&&((d=u[7])==null?void 0:d.length)===1?0:u[6]&&u[8]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=xt("svg"),e=xt("g"),s&&s.c(),R(e,"transform",n=r[34]),R(e,"class","svelte-190cqdf"),R(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),mn(t,"drawing",r[0])},m(u,c){ct(u,t,c),Ae(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&&(ge(),et(l[d],1,1,()=>{l[d]=null}),ye()),~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]&8&&n!==(n=u[34]))&&R(e,"transform",n),(!o||c[0]&1)&&mn(t,"drawing",u[0])},i(u){o||(q(s),o=!0)},o(u){et(s),o=!1},d(u){u&&ht(t),~i&&l[i].d(),r[27](null)}}}function XS(r){let t,e;return t=new Th({props:{viewer:r[3],$$slots:{default:[VS,({transform:i,scale:s})=>({34:i,35:s}),({transform:i,scale:s})=>[0,(i?8:0)|(s?16: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]&511|s[1]&536&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function zS(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=hn()[0]}=t,{user:f}=t,{viewer:m}=t,y=0;const _=()=>e(5,y+=1),v=()=>p,g=()=>a;navigator.userAgent.match(/firefox|fxios/i);let x;const{store:b,selection:S,hover:w}=c;fn(r,S,M=>e(25,o=M));let T,N,F;const z=M=>{b.unobserve(T);const L=M.filter(({editable:V})=>V).map(({id:V})=>V);L.length>0?(e(7,N=L.map(V=>b.getAnnotation(V))),T=V=>{const{updated:rt}=V.changes;e(7,N=(rt||[]).map(Q=>Q.newValue))},b.observe(T,{annotations:L}),m.forceRedraw()):e(7,N=void 0)},C=(M,L)=>{const{x:V,y:rt}=m.viewport.viewerElementToImageCoordinates(new de.Point(M,L));return[V,rt]},E=M=>{m.setMouseNavEnabled(!1),F=M.timeStamp},I=M=>{if(m.setMouseNavEnabled(!0),performance.now()-(F||0)<300){const{offsetX:V,offsetY:rt}=M.detail,[Q,X]=C(V,rt),_t=b.getAt(Q,X);if(_t&&(!l||l(_t))&&!N.find(O=>O.id===_t.id)){w.set(_t.id);const O=cm(_t.id,M.detail,S,h);S.userSelect(O)}}},P=M=>L=>{var X;const{target:V}=M,rt=10*60*1e3,Q=((X=V.creator)==null?void 0:X.id)!==f.id||!V.created||new Date().getTime()-V.created.getTime()>rt;b.updateTarget({...V,selector:L.detail,created:Q?V.created:new Date,updated:Q?new Date:void 0,updatedBy:Q?f:void 0})},$=M=>{const L=kA(),V={id:L,bodies:[],target:{annotation:L,selector:M.detail,creator:f,created:new Date}};b.addAnnotation(V),S.setSelected(V.id),m.setMouseNavEnabled(!0)},k=M=>Eu(M),G=M=>Ge(M);function st(M){_n[M?"unshift":"push"](()=>{x=M,e(6,x)})}return r.$$set=M=>{"drawingEnabled"in M&&e(0,a=M.drawingEnabled),"filter"in M&&e(16,l=M.filter),"multiSelect"in M&&e(17,h=M.multiSelect),"preferredDrawingMode"in M&&e(18,u=M.preferredDrawingMode),"state"in M&&e(19,c=M.state),"style"in M&&e(1,d=M.style),"toolName"in M&&e(2,p=M.toolName),"user"in M&&e(20,f=M.user),"viewer"in M&&e(3,m=M.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(8,{tool:i,opts:s}=un(p)||{tool:void 0,opts:void 0},i,(e(24,s),e(2,p))),r.$$.dirty[0]&17039360&&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&&S.clear(),r.$$.dirty[0]&33554457&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&33554432&&z(o.selected)},[a,d,p,m,n,y,x,N,i,S,C,E,I,P,$,k,l,h,u,c,f,_,v,g,s,o,G,st]}class WS extends re{constructor(t){super(),ee(this,t,zS,XS,Wt,{drawingEnabled:0,filter:16,multiSelect:17,preferredDrawingMode:18,state:19,style:1,toolName:2,user:20,viewer:3,cancelDrawing:21,getDrawingTool:22,isDrawingEnabled:23},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[21]}get getDrawingTool(){return this.$$.ctx[22]}get isDrawingEnabled(){return this.$$.ctx[23]}}function YS(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=xt("g"),e=xt("rect"),a=xt("text"),h=ma(l),R(e,"class","a9s-presence-label-bg svelte-1rehw2p"),R(e,"x",r[0]),R(e,"y",i=r[1]-18/r[3]),R(e,"height",s=18/r[3]),R(e,"fill",n=r[2].appearance.color),R(e,"stroke",o=r[2].appearance.color),R(a,"font-size",u=12/r[3]),R(a,"x",c=r[0]+Math.round(5/r[3])),R(a,"y",d=r[1]-5/r[3]),R(a,"class","svelte-1rehw2p"),R(t,"class","a9s-presence-label")},m(p,f){ct(p,t,f),Ae(t,e),Ae(t,a),Ae(a,h),r[6](t)},p(p,[f]){f&1&&R(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&R(e,"y",i),f&8&&s!==(s=18/p[3])&&R(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&R(e,"fill",n),f&4&&o!==(o=p[2].appearance.color)&&R(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&f0(h,l),f&8&&u!==(u=12/p[3])&&R(a,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&R(a,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&R(a,"y",d)},i:me,o:me,d(p){p&&ht(t),r[6](null)}}}function jS(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){_n[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 _m extends re{constructor(t){super(),ee(this,t,jS,YS,Wt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function qS(r){let t,e,i,s,n,o;return e=new _m({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=xt("g"),Ht(e.$$.fragment),i=xt("polygon"),R(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"points",n=r[2].points.map(vm).join(" ")),R(t,"class","a9s-presence-overlay")},m(a,l){ct(a,t,l),Ft(e,t,null),Ae(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))&&R(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(vm).join(" ")))&&R(i,"points",n)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){et(e.$$.fragment,a),o=!1},d(a){a&&ht(t),Ut(e)}}}const vm=r=>r.join(",");function KS(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 ZS extends re{constructor(t){super(),ee(this,t,KS,qS,Wt,{annotation:4,user:0,scale:1})}}function QS(r){let t,e,i,s,n,o,a,l,h;return e=new _m({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=xt("g"),Ht(e.$$.fragment),i=xt("rect"),R(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"x",n=r[2].x),R(i,"y",o=r[2].y),R(i,"width",a=r[2].w),R(i,"height",l=r[2].h),R(t,"class","a9s-presence-overlay")},m(u,c){ct(u,t,c),Ft(e,t,null),Ae(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))&&R(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&R(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&R(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&R(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&R(i,"height",l)},i(u){h||(q(e.$$.fragment,u),h=!0)},o(u){et(e.$$.fragment,u),h=!1},d(u){u&&ht(t),Ut(e)}}}function JS(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 tC extends re{constructor(t){super(),ee(this,t,JS,QS,Wt,{annotation:3,user:0,scale:1})}}const{Boolean:eC}=sc;function xm(r,t,e){const i=r.slice();return i[8]=t[e],i}function bm(r){let t,e;return t=new Th({props:{viewer:r[0],$$slots:{default:[sC,({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Em(r){let t,e,i=Se(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Tm(xm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&132){i=Se(o[2]);let l;for(l=0;l<i.length;l+=1){const h=xm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=Tm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(eC);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function rC(r){let t,e;return t=new ZS({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function iC(r){let t,e;return t=new tC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Tm(r){let t,e,i,s;const n=[iC,rC],o=[];function a(l,h){return l[8].annotation.target.selector.type===vt.RECTANGLE?0:l[8].annotation.target.selector.type===vt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~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){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function sC(r){let t,e,i,s,n=r[2].length>0&&Em(r);return{c(){t=xt("svg"),e=xt("g"),n&&n.c(),R(e,"transform",i=r[6]),R(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,t,a),Ae(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=Em(o),n.c(),q(n,1),n.m(e,null)):n&&(ge(),et(n,1,1,()=>{n=null}),ye()),(!s||a&64&&i!==(i=o[6]))&&R(e,"transform",i)},i(o){s||(q(n),s=!0)},o(o){et(n),s=!1},d(o){o&&ht(t),n&&n.d()}}}function nC(r){let t=!!r[1],e,i,s=t&&bm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(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=bm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function oC(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 m0(()=>{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 aC extends re{constructor(t){super(),ee(this,t,oC,nC,Wt,{store:3,viewer:0,provider:1})}}function lC(r){let t,e,i,s,n;return{c(){t=xt("rect"),R(t,"x",e=r[0].x),R(t,"y",i=r[0].y),R(t,"width",s=r[0].w),R(t,"height",n=r[0].h)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&R(t,"x",e),a&1&&i!==(i=o[0].y)&&R(t,"y",i),a&1&&s!==(s=o[0].w)&&R(t,"width",s),a&1&&n!==(n=o[0].h)&&R(t,"height",n)},i:me,o:me,d(o){o&&ht(t)}}}function hC(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 uC extends re{constructor(t){super(),ee(this,t,hC,lC,Wt,{annotation:1})}}function cC(r){let t,e;return{c(){t=xt("polygon"),R(t,"points",e=r[0].points.map(wm).join(" "))},m(i,s){ct(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(wm).join(" "))&&R(t,"points",e)},i:me,o:me,d(i){i&&ht(t)}}}const wm=r=>r.join(",");function dC(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 fC extends re{constructor(t){super(),ee(this,t,dC,cC,Wt,{annotation:1})}}function pC(r){let t,e,i,s,n;return{c(){t=xt("ellipse"),R(t,"cx",e=r[0].cx),R(t,"cy",i=r[0].cy),R(t,"rx",s=r[0].rx),R(t,"ry",n=r[0].ry)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&R(t,"cx",e),a&1&&i!==(i=o[0].cy)&&R(t,"cy",i),a&1&&s!==(s=o[0].rx)&&R(t,"rx",s),a&1&&n!==(n=o[0].ry)&&R(t,"ry",n)},i:me,o:me,d(o){o&&ht(t)}}}function mC(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 gC extends re{constructor(t){super(),ee(this,t,mC,pC,Wt,{annotation:1})}}const{Boolean:yC}=sc;function Am(r,t,e){const i=r.slice();return i[10]=t[e],i}function Sm(r){let t,e;return t=new Th({props:{viewer:r[0],$$slots:{default:[bC,({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function _C(r){let t,e;return t=new gC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function vC(r){let t,e;return t=new fC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function xC(r){let t,e;return t=new uC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Cm(r){let t,e,i,s;const n=[xC,vC,_C],o=[];function a(l,h){return l[10].target.selector.type===vt.RECTANGLE?0:l[10].target.selector.type===vt.POLYGON?1:l[10].target.selector.type===vt.ELLIPSE?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~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){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function bC(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=Se(r[1].filter(r[6])),y=[];for(let v=0;v<m.length;v+=1)y[v]=Cm(Am(r,m,v));const _=v=>et(y[v],1,1,()=>{y[v]=null});return{c(){var v,g,x,b;t=xt("svg"),e=xt("g"),i=xt("rect"),l=xt("rect");for(let S=0;S<y.length;S+=1)y[S].c();R(i,"class","a9s-union-bg svelte-n2zwns"),R(i,"x",s=(v=r[2])==null?void 0:v.minX),R(i,"y",n=(g=r[2])==null?void 0:g.minY),R(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),R(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),R(l,"class","a9s-union-fg svelte-n2zwns"),R(l,"x",h=(x=r[2])==null?void 0:x.minX),R(l,"y",u=(b=r[2])==null?void 0:b.minY),R(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),R(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),R(e,"transform",p=r[9]),R(t,"class","a9s-osd-selectionlayer svelte-n2zwns")},m(v,g){ct(v,t,g),Ae(t,e),Ae(e,i),Ae(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,b,S,w;if((!f||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&R(i,"x",s),(!f||g&4&&n!==(n=(b=v[2])==null?void 0:b.minY))&&R(i,"y",n),(!f||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&R(i,"width",o),(!f||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&R(i,"height",a),(!f||g&4&&h!==(h=(S=v[2])==null?void 0:S.minX))&&R(l,"x",h),(!f||g&4&&u!==(u=(w=v[2])==null?void 0:w.minY))&&R(l,"y",u),(!f||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&R(l,"width",c),(!f||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&R(l,"height",d),g&2){m=Se(v[1].filter(v[6]));let T;for(T=0;T<m.length;T+=1){const N=Am(v,m,T);y[T]?(y[T].p(N,g),q(y[T],1)):(y[T]=Cm(N),y[T].c(),q(y[T],1),y[T].m(e,null))}for(ge(),T=m.length;T<y.length;T+=1)_(T);ye()}(!f||g&512&&p!==(p=v[9]))&&R(e,"transform",p)},i(v){if(!f){for(let g=0;g<m.length;g+=1)q(y[g]);f=!0}},o(v){y=y.filter(yC);for(let g=0;g<y.length;g+=1)et(y[g]);f=!1},d(v){v&&ht(t),ii(y,v)}}}function EC(r){let t=!!r[2],e,i,s=t&&Sm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(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=Sm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function TC(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;fn(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=>Ge(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=>Ge(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 wC extends re{constructor(t){super(),ee(this,t,TC,EC,Wt,{state:4,viewer:0})}}const Im=(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=zu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Rm=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Ge(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,b=_+(u+d)*_,S=v+(h+c)*v,w=r.viewport.imageToViewportRectangle(g,x,b,S);r.viewport[e](w,s.immediately)},AC=(r,t)=>Rm(r,t,"fitBounds"),SC=(r,t)=>Rm(r,t,"fitBoundsWithConstraints"),CC=(r,t={})=>{const e=Yu(t,{drawingEnabled:!1,drawingMode:pu?"drag":"click",userSelectAction:$o.EDIT,theme:"light"}),i=Xu(e),{hover:s,selection:n,store:o}=i,a=jm(o,e.initialHistory),l=qm(i,a,e.adapter,e.autoSave);let h=ig(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=qu(a,r.element),f=new LA({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new aC({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new WS({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 wC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",L=>{const{originalEvent:V,annotation:rt}=L.detail,Q=X=>cm(X.id,V,n,e.multiSelect);d?n.isEmpty()&&rt&&n.userSelect(Q(rt),V):rt&&!(c==="click"&&u)?n.userSelect(Q(rt),V):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",L=>{if(s.current){const V=o.getAnnotation(s.current);l.emit("clickAnnotation",V,L)}}),Im(r,e.theme);const v=Zm(i,a,e.adapter),g=()=>y.cancelDrawing(),x=()=>{f.$destroy(),m.$destroy(),y.$destroy(),_.$destroy(),p.destroy(),a.destroy()},b=AC(r,o),S=SC(r,o),w=()=>y.getDrawingTool(),T=()=>h,N=()=>y.isDrawingEnabled(),F=(L,V,rt)=>Iu(L,V,rt),z=(L,V)=>Tu(L,V),C=L=>{if(!un(L))throw`No drawing tool named ${L}`;y.$set({toolName:L})},E=L=>{u=L,y.$set({drawingEnabled:L})},I=L=>{f.$set({filter:L}),y.$set({filter:L})},P=L=>d=L,$=L=>{f.$set({style:L}),y.$set({style:L})},k=L=>m.$set({provider:L}),G=L=>Im(r,L),st=L=>{h=L,y.$set({user:L})},M=L=>f.$set({visible:L});return{...v,cancelDrawing:g,destroy:x,fitBounds:b,fitBoundsWithConstraints:S,getDrawingTool:w,getUser:T,isDrawingEnabled:N,listDrawingTools:hn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:z,setDrawingEnabled:E,setDrawingTool:C,setFilter:I,setModalSelect:P,setPresenceProvider:k,setStyle:$,setTheme:G,setUser:st,setVisible:M,state:i,viewer:r}};Gt.ShapeType=vt,Gt.UserSelectAction=$o,Gt.W3CImageFormat=Xy,Gt.chainStyles=Dy,Gt.computeStyle=Ny,Gt.createBody=km,Gt.createImageAnnotator=h0,Gt.createOSDAnnotator=CC,Gt.defaultColorProvider=ng,Object.defineProperty(Gt,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=ub(t)),typeof t=="number"?hb(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,cs.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}=j.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}};dh.availableFonts={},dh.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 fh=dh;const Ro=class ds extends ts{constructor(t="",e={}){super(Z.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=Z.from(i,{scaleMode:j.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new pt,s.trim=new pt,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=ds.defaultMaxWidth,this.maxHeight=ds.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=ds.defaultAutoResolution,this._resolution=ds.defaultResolution??j.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({},ds.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=Fr(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=Fr(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 fh?(this.ownsStyle=!1,this._style=t):t instanceof Xr?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=fh.from(t)):(this.ownsStyle=!0,this._style=new fh(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(/ /gi," ")}};Ro.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},Ro.defaultMaxWidth=2024,Ro.defaultMaxHeight=2024,Ro.defaultAutoResolution=!0;const EA=16777215,TA=.25,wA=16777215,AA=1,SA=1.5;let Yr=!1,Ys;const ph=r=>{const t={tint:r!=null&&r.fill?new wt(r.fill).toNumber():EA,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 wt(r==null?void 0:r.fill).alpha:TA},e={tint:r!=null&&r.stroke?new wt(r.stroke).toNumber():wA,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 wt(r==null?void 0:r.stroke).alpha:AA,lineWidth:(r==null?void 0:r.strokeWidth)===void 0?SA:r.strokeWidth};return{fillStyle:t,strokeStyle:e}},Mo=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=ph(i),o=new Ws;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new Ws,l=n.lineWidth===1?1:n.lineWidth/Ys;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}},CA=Mo((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),IA=Mo((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),RA=Mo((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),MA=Mo((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()})})}),Up=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},kp=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=Up(r);(n!==Ys||!Yr)&&(Yr=!0,e.forEach(({stroke:d,strokeWidth:p})=>{const{lineStyle:f}=d.geometry.graphicsData[0];p>1?(Yr=n===Ys,f.width=p/n,f.native=!1,d.geometry.invalidate()):p===1&&!f.native&&(f.width=1,f.native=!0,d.geometry.invalidate())})),Ys=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)},PA=(r,t)=>{const e=new Ws,i=Lf({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o,a;Ys=Up(r);const l=(g,x)=>{Yr=!1;const{selector:b}=g.target,S=typeof a=="function"?a(g,x):a;let w;b.type===vt.RECTANGLE?w=CA(e,b,S):b.type===vt.POLYGON?w=RA(e,b,S):b.type===vt.ELLIPSE?w=IA(e,b,S):b.type===vt.MULTIPOLYGLON?w=MA(e,b,S):console.warn(`Unsupported shape type: ${b.type}`),w&&s.set(g.id,{annotation:g,...w})},h=g=>{const x=s.get(g.id);x&&(s.delete(g.id),x.fill.destroy(),x.stroke.destroy())},u=(g,x,b)=>{Yr=!1;const S=s.get(g.id);S&&(s.delete(g.id),S.fill.destroy(),S.stroke.destroy(),l(x,b))},c=(g,x)=>{const b=s.get(g);b&&(s.delete(g),b.fill.destroy(),b.stroke.destroy(),l(b.annotation,x))},d=(g,x)=>{i.resize(g,x),i.render(e)},p=g=>{Yr=!1;const{children:x}=e;s.forEach(({fill:b,stroke:S,annotation:w})=>{const T=g?n.has(w.id)||g(w):!0;T&&!x.includes(b)?(e.addChild(b),e.addChild(S)):!T&&x.includes(b)&&(e.removeChild(b),e.removeChild(S))}),i.render(e)},f=g=>{o!==g&&(o&&c(o,{selected:n.has(o)}),g&&c(g,{selected:n.has(g),hovered:!0}),o=g,i.render(e))},m=g=>{const x=g.selected.map(w=>w.id),b=x.filter(w=>!n.has(w)),S=[...n].filter(w=>!x.includes(w));[...b,...S].forEach(w=>c(w,{selected:x.includes(w),hovered:w===o})),n=new Set(x),i.render(e)},y=g=>{if(typeof g=="function")s.forEach(({annotation:x,fill:b,stroke:S,strokeWidth:w},T)=>{w>1&&(Yr=!1);const N={selected:n.has(x.id),hovered:o===x.id},{fillStyle:F,strokeStyle:z}=ph(g(x,N));b.tint=F.tint,b.alpha=F.alpha,S.tint=z.tint||16777215,S.alpha=z.alpha,s.set(x.id,{annotation:x,fill:b,stroke:S,strokeWidth:z.lineWidth})});else{const{fillStyle:x,strokeStyle:b}=ph(g);b.lineWidth>1&&(Yr=!1),s.forEach(({annotation:S,fill:w,stroke:T,strokeWidth:N},F)=>{w.tint=x.tint,w.alpha=x.alpha,T.tint=b.tint||16777215,T.alpha=b.alpha,s.set(S.id,{annotation:S,fill:w,stroke:T,strokeWidth:b.lineWidth})})}a=g,i.render(e),kp(r,e,s,i)()},_=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:l,destroy:()=>i.destroy(),redraw:kp(r,e,s,i),removeAnnotation:h,resize:d,setFilter:p,setHovered:f,setSelected:m,setStyle:y,setVisible:_,updateAnnotation:u}};function OA(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;fn(r,c,S=>e(11,i=S)),fn(r,d,S=>e(8,s=S));const f=yn();let m,y;const _=S=>{const w=new de.Point(S.x,S.y),{x:T,y:N}=l.viewport.pointFromPixel(w);return l.viewport.viewportToImageCoordinates(T,N)},v=S=>{const{x:w,y:T}=S.position;y={x:w,y:T}},g=S=>w=>{const{x:T,y:N}=_(new de.Point(w.offsetX,w.offsetY)),F=u.getAt(T,N);F&&(!n||n(F))?(S.classList.add("hover"),i!==F.id&&(c.set(F.id),m.setHovered(F.id))):(S.classList.remove("hover"),i&&(c.set(void 0),m.setHovered(void 0)))},x=S=>{if(!y)return;const w=S.originalEvent,{x:T,y:N}=S.position,F=T-y.x,z=N-y.y;if(Math.sqrt(F*F+z*z)<5){const{x:E,y:I}=_(S.position),P=u.getAt(E,I);P?f("click",{originalEvent:w,annotation:P}):f("click",{originalEvent:w})}y=void 0};let b;return gn(()=>{var P;const{offsetWidth:S,offsetHeight:w}=l.canvas,T=document.createElement("canvas");T.width=S,T.height=w,T.className="a9s-gl-canvas",(P=l.element.querySelector(".openseadragon-canvas"))==null||P.appendChild(T),e(7,m=PA(l,T));const N=g(T);T.addEventListener("pointermove",N);const F=new ResizeObserver($=>{try{const{width:k,height:G}=$[0].contentRect;T.width=k,T.height=G,m.resize(k,G)}catch{console.warn("WebGL canvas already disposed")}});F.observe(T);const z=()=>{const $=l.viewport.getBounds();b=l.viewport.viewportToImageRectangle($);const{x:k,y:G,width:st,height:M}=b,L=u.getIntersecting(k,G,st,M);p.set(L.map(V=>V.id))};l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",z);const C=$=>$.filter(k=>Ge(k)),E=$=>Ge($.oldValue)&&Ge($.newValue),I=$=>{const{created:k,updated:G,deleted:st}=$.changes;if(C(k||[]).forEach(M=>m.addAnnotation(M)),C(st||[]).forEach(M=>m.removeAnnotation(M)),(G||[]).filter(M=>E(M)).forEach(({oldValue:M,newValue:L})=>m.updateAnnotation(M,L)),b){const{x:M,y:L,width:V,height:rt}=b,Q=u.getIntersecting(M,L,V,rt);p.set(Q.map(X=>X.id))}else p.set(u.all().map(M=>M.id));m.redraw()};return u.observe(I),()=>{var $;T.removeEventListener("pointermove",N),F.disconnect(),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",z),u.unobserve(I),m.destroy(),($=T.parentNode)==null||$.removeChild(T)}}),r.$$set=S=>{"filter"in S&&e(2,n=S.filter),"state"in S&&e(3,o=S.state),"style"in S&&e(4,a=S.style),"viewer"in S&&e(5,l=S.viewer),"visible"in S&&e(6,h=S.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 NA extends re{constructor(t){super(),ee(this,t,OA,null,Wt,{filter:2,state:3,style:4,viewer:5,visible:6})}}const ce=[];for(let r=0;r<256;++r)ce.push((r+256).toString(16).slice(1));function DA(r,t=0){return(ce[r[t+0]]+ce[r[t+1]]+ce[r[t+2]]+ce[r[t+3]]+"-"+ce[r[t+4]]+ce[r[t+5]]+"-"+ce[r[t+6]]+ce[r[t+7]]+"-"+ce[r[t+8]]+ce[r[t+9]]+"-"+ce[r[t+10]]+ce[r[t+11]]+ce[r[t+12]]+ce[r[t+13]]+ce[r[t+14]]+ce[r[t+15]]).toLowerCase()}let mh;const LA=new Uint8Array(16);function BA(){if(!mh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");mh=crypto.getRandomValues.bind(crypto)}return mh(LA)}const Gp={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function FA(r,t,e){var s;if(Gp.randomUUID&&!r)return Gp.randomUUID();r=r||{};const i=r.random??((s=r.rng)==null?void 0:s.call(r))??BA();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,DA(i)}var jr=(r=>(r.ELLIPSE="ELLIPSE",r.MULTIPOLYGLON="MULTIPOLYGON",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(jr||{});const Po=(r,t)=>t,Oo=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}},gh=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)},yh=(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},UA=(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},kA={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}};Po(jr.ELLIPSE,kA);const GA={area:r=>{const{polygons:t}=r.geometry;return t.reduce((e,i)=>{const[s,...n]=i.rings,o=gh(s.points),a=n.reduce((l,h)=>l+gh(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(yh(n.points,t,e)){let a=!1;for(const l of o)if(yh(l.points,t,e)){a=!0;break}if(!a)return!0}}return!1}},$A=r=>{const t=r.reduce((e,i)=>[...e,...i.rings[0].points],[]);return Oo(t)},No=r=>r.rings.map(e=>UA(e.points)).join(" ");Po(jr.MULTIPOLYGLON,GA);const HA={area:r=>{const t=r.geometry.points;return gh(t)},intersects:(r,t,e)=>{const i=r.geometry.points;return yh(i,t,e)}};Po(jr.POLYGON,HA);const VA={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};Po(jr.RECTANGLE,VA);const jt=" ";function XA(r){let t="";Array.isArray(r)||(r=[r]);for(let e=0;e<r.length;e++){const i=r[e];if(i.type===U.CLOSE_PATH)t+="z";else if(i.type===U.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===U.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===U.MOVE_TO)t+=(i.relative?"m":"M")+i.x+jt+i.y;else if(i.type===U.LINE_TO)t+=(i.relative?"l":"L")+i.x+jt+i.y;else if(i.type===U.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+jt+i.y1+jt+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+jt+i.y2+jt+i.x+jt+i.y;else if(i.type===U.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+jt+i.y1+jt+i.x+jt+i.y;else if(i.type===U.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+jt+i.y;else if(i.type===U.ARC)t+=(i.relative?"a":"A")+i.rX+jt+i.rY+jt+i.xRot+jt+ +i.lArcFlag+jt+ +i.sweepFlag+jt+i.x+jt+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 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 qr=Math.PI;function vh(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*qr,[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*qr),r.sweepFlag===1&&r.phi2<r.phi1&&(r.phi2+=2*qr),r.phi1*=180/qr,r.phi2*=180/qr}function $p(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 Ai=Math.PI/180;function Hp(r,t,e){return(1-e)*r+e*t}function Vp(r,t,e,i){return r+Math.cos(i/180*qr)*t+Math.sin(i/180*qr)*e}function Xp(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]:zA(h/l,u/l,1e-6)}function zp(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 zA(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 WA(r,t,e){r.cX||vh(r,t,e);const i=r.xRot/180*qr;if(Math.abs(r.rX)<1e-10||Math.abs(r.rY)<1e-10)return[{relative:r.relative,type:U.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=Hp(r.phi1,r.phi2,d/a),f=Hp(r.phi1,r.phi2,(d+1)/a),m=f-p,y=4/3*Math.tan(m*Ai/4),_=Math.cos(p*Ai)-y*Math.sin(p*Ai),v=Math.sin(p*Ai)+y*Math.cos(p*Ai),g=Math.cos(f*Ai),x=Math.sin(f*Ai),b=g+y*x,S=x-y*g,w=c(_,v),T=c(b,S),N=c(g,x),F={relative:r.relative,type:U.CURVE_TO,x:N[0],y:N[1],x1:w[0],y1:w[1],x2:T[0],y2:T[1]};r.relative&&(F.x1-=h,F.y1-=u,F.x2-=h,F.y2-=u,F.x-=h,F.y-=u),h=N[0],u=N[1],l[d]=F}return l}function xh(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 YA(r,t=!0){if(r.length<2)return r;const e=qt.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===U.MOVE_TO&&s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s)),s=[]),s.push(o)}return s.length>0&&(t?i.push(...Do(s)):i.unshift(...Do(s))),i}function Do(r){var s;const t=((s=r[r.length-1])==null?void 0:s.type)===U.CLOSE_PATH,e=t?r.length-2:r.length-1,i=[{type:U.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 U.HORIZ_LINE_TO:i.push({type:U.HORIZ_LINE_TO,relative:!1,x:a.x});break;case U.VERT_LINE_TO:i.push({type:U.VERT_LINE_TO,relative:!1,y:a.y});break;case U.LINE_TO:case U.MOVE_TO:i.push({type:U.LINE_TO,relative:!1,x:a.x,y:a.y});break;case U.CURVE_TO:i.push({type:U.CURVE_TO,relative:!1,x:a.x,y:a.y,x1:o.x2,y1:o.y2,x2:o.x1,y2:o.y1});break;case U.SMOOTH_CURVE_TO:throw new Error("Unsupported command: S (smooth cubic bezier)");case U.SMOOTH_QUAD_TO:throw new Error("Unsupported command: T (smooth quadratic bezier)");case U.ARC:throw new Error("Unsupported command: A (arc)");case U.QUAD_TO:throw new Error("Unsupported command: Q (quadratic bezier)")}}return t&&i.push({type:U.CLOSE_PATH}),i}function jA(r=1e13){Qe(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 Wp(){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 qA(){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 KA(r=!0,t=!0,e=!0,i=!0){return Je((s,n,o,a,l)=>{if(isNaN(a)&&!(s.type&U.MOVE_TO))throw new Error("path must start with moveto");if(t&&s.type&U.HORIZ_LINE_TO&&(s.type=U.LINE_TO,s.y=s.relative?0:o),e&&s.type&U.VERT_LINE_TO&&(s.type=U.LINE_TO,s.x=s.relative?0:n),r&&s.type&U.CLOSE_PATH&&(s.type=U.LINE_TO,s.x=s.relative?a-n:a,s.y=s.relative?l-o:l),s.type&U.ARC&&(s.rX===0||s.rY===0)&&(s.type=U.LINE_TO,delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag),i&&s.type&U.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];xh(h,u,c)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1)}if(i&&s.type&U.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];xh(h,u,d)&&xh(h,c,d)&&(s.type=U.LINE_TO,delete s.x1,delete s.y1,delete s.x2,delete s.y2)}return s})}function Yp(){let r=NaN,t=NaN,e=NaN,i=NaN;return Je((s,n,o)=>(s.type&U.SMOOTH_CURVE_TO&&(s.type=U.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&U.CURVE_TO?(r=s.relative?n+s.x2:s.x2,t=s.relative?o+s.y2:s.y2):(r=NaN,t=NaN),s.type&U.SMOOTH_QUAD_TO&&(s.type=U.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&U.QUAD_TO?(e=s.relative?n+s.x1:s.x1,i=s.relative?o+s.y1:s.y1):(e=NaN,i=NaN),s))}function jp(){let r=NaN,t=NaN;return Je((e,i,s)=>{if(e.type&U.SMOOTH_QUAD_TO&&(e.type=U.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&U.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=U.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(o){if(isNaN(i)&&!(o.type&U.MOVE_TO))throw new Error("path must start with moveto");const a=r(o,t,e,i,s);return o.type&U.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&U.MOVE_TO&&(i=t,s=e),a}}function ZA(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&U.SMOOTH_CURVE_TO&&(d=isNaN(t)?0:o-t,p=isNaN(e)?0:a-e),n.type&(U.CURVE_TO|U.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&U.SMOOTH_QUAD_TO?(i=isNaN(i)?o:2*o-i,s=isNaN(s)?a:2*a-s):n.type&U.QUAD_TO?(i=n.relative?o+n.x1:n.x1,s=n.relative?a+n.y1:n.y2):(i=NaN,s=NaN),n.type&U.LINE_COMMANDS||n.type&U.ARC&&(n.rX===0||n.rY===0||!n.lArcFlag)||n.type&U.CURVE_TO||n.type&U.SMOOTH_CURVE_TO||n.type&U.QUAD_TO||n.type&U.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&U.CLOSE_PATH&&u(o-l)<=r&&u(a-h)<=r&&(c=!0),c?[]:n})}function Kr(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&U.HORIZ_LINE_TO&&t!==0&&(o.type=U.LINE_TO,o.y=o.relative?0:l),o.type&U.VERT_LINE_TO&&e!==0&&(o.type=U.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=U.LINE_TO;else{const _=o.xRot*Math.PI/180,v=Math.sin(_),g=Math.cos(_),x=1/m(o.rX),b=1/m(o.rY),S=m(g)*x+m(v)*b,w=2*v*g*(x-b),T=m(v)*x+m(g)*b,N=S*i*i-w*t*i+T*t*t,F=w*(r*i+t*e)-2*(S*e*i+T*r*t),z=S*e*e-w*r*e+T*r*r,C=(Math.atan2(F,N-z)+Math.PI)%Math.PI/2,E=Math.sin(C),I=Math.cos(C);o.rX=Math.abs(y)/Math.sqrt(N*m(I)+F*E*I+z*m(E)),o.rY=Math.abs(y)/Math.sqrt(N*m(E)-F*E*I+z*m(I)),o.xRot=C*180/Math.PI}return typeof o.sweepFlag<"u"&&0>y&&(o.sweepFlag=+!o.sweepFlag),o})}function QA(r,t=0,e=0){Qe(r,t,e);const i=Math.sin(r),s=Math.cos(r);return Kr(s,i,-i,s,t-t*s+e*i,e-t*i-e*s)}function JA(r,t=0){return Qe(r,t),Kr(1,0,0,1,r,t)}function tS(r,t=r){return Qe(r,t),Kr(r,0,0,t,0,0)}function eS(r){return Qe(r),Kr(1,0,Math.tan(r),1,0,0)}function rS(r){return Qe(r),Kr(1,Math.tan(r),0,1,0,0)}function iS(r=0){return Qe(r),Kr(-1,0,0,1,r,0)}function sS(r=0){return Qe(r),Kr(1,0,0,-1,0,r)}function nS(){return Je((r,t,e)=>U.ARC===r.type?WA(r,r.relative?0:t,r.relative?0:e):r)}function oS(){return Je((r,t,e)=>(r.relative&&(t=0,e=0),U.ARC===r.type&&vh(r,t,e),r))}function qp(){return r=>({...r})}function aS(){const r=qp(),t=Wp(),e=jp(),i=Yp(),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&U.DRAWING_COMMANDS&&(h(o),u(a)),l.type&U.HORIZ_LINE_TO&&h(l.x),l.type&U.VERT_LINE_TO&&u(l.y),l.type&U.LINE_TO&&(h(l.x),u(l.y)),l.type&U.CURVE_TO){h(l.x),u(l.y);const c=Xp(o,l.x1,l.x2,l.x);for(const p of c)0<p&&1>p&&h(zp(o,l.x1,l.x2,l.x,p));const d=Xp(a,l.y1,l.y2,l.y);for(const p of d)0<p&&1>p&&u(zp(a,l.y1,l.y2,l.y,p))}if(l.type&U.ARC){h(l.x),u(l.y),vh(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=([b,S])=>{const T=Math.atan2(S,b)*180/Math.PI;return T<y?T+360:T},g=$p(f,-d,0).map(v);for(const b of g)b>y&&b<_&&h(Vp(l.cX,d,f,b));const x=$p(m,-p,0).map(v);for(const b of x)b>y&&b<_&&u(Vp(l.cY,p,m,b))}return n});return s.minX=1/0,s.maxX=-1/0,s.minY=1/0,s.maxY=-1/0,s}const qt={ROUND:jA,TO_ABS:Wp,TO_REL:qA,NORMALIZE_HVZ:KA,NORMALIZE_ST:Yp,QT_TO_C:jp,INFO:Je,SANITIZE:ZA,MATRIX:Kr,ROTATE:QA,TRANSLATE:JA,SCALE:tS,SKEW_X:eS,SKEW_Y:rS,X_AXIS_SYMMETRY:iS,Y_AXIS_SYMMETRY:sS,A_TO_C:nS,ANNOTATE_ARCS:oS,CLONE:qp,CALCULATE_BOUNDS:aS,REVERSE_PATH:YA};class Kp{round(t){return this.transform(qt.ROUND(t))}toAbs(){return this.transform(qt.TO_ABS())}toRel(){return this.transform(qt.TO_REL())}normalizeHVZ(t,e,i){return this.transform(qt.NORMALIZE_HVZ(t,e,i))}normalizeST(){return this.transform(qt.NORMALIZE_ST())}qtToC(){return this.transform(qt.QT_TO_C())}aToC(){return this.transform(qt.A_TO_C())}sanitize(t){return this.transform(qt.SANITIZE(t))}translate(t,e){return this.transform(qt.TRANSLATE(t,e))}scale(t,e){return this.transform(qt.SCALE(t,e))}rotate(t,e,i){return this.transform(qt.ROTATE(t,e,i))}matrix(t,e,i,s,n,o){return this.transform(qt.MATRIX(t,e,i,s,n,o))}skewX(t){return this.transform(qt.SKEW_X(t))}skewY(t){return this.transform(qt.SKEW_Y(t))}xSymmetry(t){return this.transform(qt.X_AXIS_SYMMETRY(t))}ySymmetry(t){return this.transform(qt.Y_AXIS_SYMMETRY(t))}annotateArcs(){return this.transform(qt.ANNOTATE_ARCS())}}const lS=r=>r===" "||r===" "||r==="\r"||r===`
|
|
1149
|
+
`,Zp=r=>48<=r.charCodeAt(0)&&r.charCodeAt(0)<=57;class hS extends Kp{constructor(){super();Pt(this,"curNumber","");Pt(this,"curCommandType",-1);Pt(this,"curCommandRelative",!1);Pt(this,"canParseCommandOrComma",!0);Pt(this,"curNumberHasExp",!1);Pt(this,"curNumberHasExpDigits",!1);Pt(this,"curNumberHasDecimal",!1);Pt(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===U.ARC&&(this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber.length===1&&(this.curNumber==="0"||this.curNumber==="1"),l=Zp(o)&&(this.curNumber==="0"&&o==="0"||a);if(Zp(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===U.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===uS[this.curCommandType]&&(U.HORIZ_LINE_TO===this.curCommandType?s({type:U.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):U.VERT_LINE_TO===this.curCommandType?s({type:U.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===U.MOVE_TO||this.curCommandType===U.LINE_TO||this.curCommandType===U.SMOOTH_QUAD_TO?(s({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),U.MOVE_TO===this.curCommandType&&(this.curCommandType=U.LINE_TO)):this.curCommandType===U.CURVE_TO?s({type:U.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===U.SMOOTH_CURVE_TO?s({type:U.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.QUAD_TO?s({type:U.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===U.ARC&&s({type:U.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(!lS(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:U.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1;continue}else if(o==="h"||o==="H")this.curCommandType=U.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=U.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=U.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=U.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=U.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=U.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=U.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=U.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else if(o==="a"||o==="A")this.curCommandType=U.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 At=class At extends Kp{constructor(e){super();Pt(this,"commands");typeof e=="string"?this.commands=At.parse(e):this.commands=e}encode(){return At.encode(this.commands)}getBounds(){const e=qt.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=qt.REVERSE_PATH(this.commands,e),this}static encode(e){return XA(e)}static parse(e){const i=new hS,s=[];return i.parse(e,s),i.finish(s),s}};Pt(At,"CLOSE_PATH",1),Pt(At,"MOVE_TO",2),Pt(At,"HORIZ_LINE_TO",4),Pt(At,"VERT_LINE_TO",8),Pt(At,"LINE_TO",16),Pt(At,"CURVE_TO",32),Pt(At,"SMOOTH_CURVE_TO",64),Pt(At,"QUAD_TO",128),Pt(At,"SMOOTH_QUAD_TO",256),Pt(At,"ARC",512),Pt(At,"LINE_COMMANDS",At.LINE_TO|At.HORIZ_LINE_TO|At.VERT_LINE_TO),Pt(At,"DRAWING_COMMANDS",At.HORIZ_LINE_TO|At.VERT_LINE_TO|At.LINE_TO|At.CURVE_TO|At.SMOOTH_CURVE_TO|At.QUAD_TO|At.SMOOTH_QUAD_TO|At.ARC);let U=At;const uS={[U.MOVE_TO]:2,[U.LINE_TO]:2,[U.HORIZ_LINE_TO]:1,[U.VERT_LINE_TO]:1,[U.CLOSE_PATH]:0,[U.QUAD_TO]:4,[U.SMOOTH_QUAD_TO]:2,[U.CURVE_TO]:6,[U.SMOOTH_CURVE_TO]:4,[U.ARC]:7};function Qp(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Jp(r){let t,e;return t=new ls({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function cS(r){let t,e,i,s,n,o,a,l,h,u,c,d=Se(r[4].points),p=[];for(let m=0;m<d.length;m+=1)p[m]=Jp(Qp(r,d,m));const f=m=>et(p[m],1,1,()=>{p[m]=null});return{c(){t=xt("polygon"),s=Ve(),n=xt("polygon"),a=Ve();for(let m=0;m<p.length;m+=1)p[m].c();l=Re(),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"points",i=r[4].points.map(tm).join(" ")),R(n,"class","a9s-inner a9s-shape-handle"),R(n,"style",r[1]),R(n,"points",o=r[4].points.map(em).join(" "))},m(m,y){ct(m,t,y),ct(m,s,y),ct(m,n,y),ct(m,a,y);for(let _=0;_<p.length;_+=1)p[_]&&p[_].m(m,y);ct(m,l,y),h=!0,u||(c=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],u=!0)},p(m,y){if(r=m,(!h||y&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!h||y&16&&i!==(i=r[4].points.map(tm).join(" ")))&&R(t,"points",i),(!h||y&2)&&R(n,"style",r[1]),(!h||y&16&&o!==(o=r[4].points.map(em).join(" ")))&&R(n,"points",o),y&536){d=Se(r[4].points);let _;for(_=0;_<d.length;_+=1){const v=Qp(r,d,_);p[_]?(p[_].p(v,y),q(p[_],1)):(p[_]=Jp(v),p[_].c(),q(p[_],1),p[_].m(l.parentNode,l))}for(ge(),_=d.length;_<p.length;_+=1)f(_);ye()}},i(m){if(!h){for(let y=0;y<d.length;y+=1)q(p[y]);h=!0}},o(m){p=p.filter(Boolean);for(let y=0;y<p.length;y+=1)et(p[y]);h=!1},d(m){m&&(ht(t),ht(s),ht(n),ht(a),ht(l)),ii(p,m),u=!1,er(c)}}}function dS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[cS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){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&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}const tm=r=>r.join(","),em=r=>r.join(",");function fS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{let m;const y=d.geometry;p==="SHAPE"?m=y.points.map(([v,g])=>[v+f[0],g+f[1]]):m=y.points.map(([v,g],x)=>p===`HANDLE-${x}`?[v+f[0],g+f[1]]:[v,g]);const _=Oo(m);return{...d,geometry:{points:m,bounds:_}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class pS extends re{constructor(t){super(),ee(this,t,fS,dS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mS=typeof window>"u"||typeof navigator>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function gS(r){let t,e,i,s,n,o;return{c(){t=xt("rect"),R(t,"class",e=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(t,"x",i=r[0]-r[5]/2),R(t,"y",s=r[1]-r[5]/2),R(t,"width",r[5]),R(t,"height",r[5])},m(a,l){ct(a,t,l),n||(o=Zt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=pn(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&R(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&R(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&R(t,"y",s),l&32&&R(t,"width",a[5]),l&32&&R(t,"height",a[5])},d(a){a&&ht(t),n=!1,o()}}}function yS(r){let t,e,i,s,n,o,a,l,h;return{c(){t=xt("g"),e=xt("circle"),s=xt("rect"),R(e,"cx",r[0]),R(e,"cy",r[1]),R(e,"r",i=r[3]/r[2]),R(e,"class","a9s-touch-halo svelte-1sgkh33"),mn(e,"touched",r[4]),R(s,"class",n=pn(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),R(s,"x",o=r[0]-r[5]/2),R(s,"y",a=r[1]-r[5]/2),R(s,"width",r[5]),R(s,"height",r[5]),R(t,"class","a9s-touch-handle")},m(u,c){ct(u,t,c),Ae(t,e),Ae(t,s),l||(h=[Zt(e,"pointerdown",r[10]),Zt(e,"pointerdown",r[6]),Zt(e,"pointerup",r[7]),Zt(s,"pointerdown",r[9]),Zt(s,"pointerdown",r[6]),Zt(s,"pointerup",r[7])],l=!0)},p(u,c){c&1&&R(e,"cx",u[0]),c&2&&R(e,"cy",u[1]),c&12&&i!==(i=u[3]/u[2])&&R(e,"r",i),c&16&&mn(e,"touched",u[4]),c&256&&n!==(n=pn(`a9s-handle ${u[8].class||""}`.trim())+" svelte-1sgkh33")&&R(s,"class",n),c&33&&o!==(o=u[0]-u[5]/2)&&R(s,"x",o),c&34&&a!==(a=u[1]-u[5]/2)&&R(s,"y",a),c&32&&R(s,"width",u[5]),c&32&&R(s,"height",u[5])},d(u){u&&ht(t),l=!1,er(h)}}}function _S(r){let t;function e(n,o){return mS?yS:gS}let s=e()(r);return{c(){s.c(),t=Re()},m(n,o){s.m(n,o),ct(n,t,o)},p(n,[o]){s.p(n,o)},i:me,o:me,d(n){n&&ht(t),s.d(n)}}}function vS(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=f=>{f.pointerType==="touch"&&e(4,l=!0)},u=()=>e(4,l=!1);function c(f){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(8,t=pa(pa({},t),rc(f))),"x"in f&&e(0,s=f.x),"y"in f&&e(1,n=f.y),"scale"in f&&e(2,o=f.scale),"radius"in f&&e(3,a=f.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=rc(t),[s,n,o,a,l,i,h,u,t,c,d,p]}class ls extends re{constructor(t){super(),ee(this,t,vS,_S,Wt,{x:0,y:1,scale:2,radius:3})}}function xS(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m,y,_,v,g,x,b,S,w,T,N,F,z,C,E,I,P,$,k,G,st,M,L,V,rt,Q,X,_t,St;return G=new ls({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),G.$on("pointerdown",function(){Kt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),M=new ls({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),M.$on("pointerdown",function(){Kt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),V=new ls({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),V.$on("pointerdown",function(){Kt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new ls({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Kt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=xt("rect"),a=Ve(),l=xt("rect"),p=Ve(),f=xt("rect"),v=Ve(),g=xt("rect"),w=Ve(),T=xt("rect"),C=Ve(),E=xt("rect"),k=Ve(),Ht(G.$$.fragment),st=Ve(),Ht(M.$$.fragment),L=Ve(),Ht(V.$$.fragment),rt=Ve(),Ht(Q.$$.fragment),R(t,"class","a9s-outer"),R(t,"style",e=r[1]?"display:none;":void 0),R(t,"x",i=r[4].x),R(t,"y",s=r[4].y),R(t,"width",n=r[4].w),R(t,"height",o=r[4].h),R(l,"class","a9s-inner a9s-shape-handle"),R(l,"style",r[1]),R(l,"x",h=r[4].x),R(l,"y",u=r[4].y),R(l,"width",c=r[4].w),R(l,"height",d=r[4].h),R(f,"class","a9s-edge-handle a9s-edge-handle-top"),R(f,"x",m=r[4].x),R(f,"y",y=r[4].y),R(f,"height",1),R(f,"width",_=r[4].w),R(g,"class","a9s-edge-handle a9s-edge-handle-right"),R(g,"x",x=r[4].x+r[4].w),R(g,"y",b=r[4].y),R(g,"height",S=r[4].h),R(g,"width",1),R(T,"class","a9s-edge-handle a9s-edge-handle-bottom"),R(T,"x",N=r[4].x),R(T,"y",F=r[4].y+r[4].h),R(T,"height",1),R(T,"width",z=r[4].w),R(E,"class","a9s-edge-handle a9s-edge-handle-left"),R(E,"x",I=r[4].x),R(E,"y",P=r[4].y),R(E,"height",$=r[4].h),R(E,"width",1)},m(O,D){ct(O,t,D),ct(O,a,D),ct(O,l,D),ct(O,p,D),ct(O,f,D),ct(O,v,D),ct(O,g,D),ct(O,w,D),ct(O,T,D),ct(O,C,D),ct(O,E,D),ct(O,k,D),Ft(G,O,D),ct(O,st,D),Ft(M,O,D),ct(O,L,D),Ft(V,O,D),ct(O,rt,D),Ft(Q,O,D),X=!0,_t||(St=[Zt(t,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(l,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(f,"pointerdown",function(){Kt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Zt(g,"pointerdown",function(){Kt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Zt(T,"pointerdown",function(){Kt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Zt(E,"pointerdown",function(){Kt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(O,D){r=O,(!X||D&2&&e!==(e=r[1]?"display:none;":void 0))&&R(t,"style",e),(!X||D&16&&i!==(i=r[4].x))&&R(t,"x",i),(!X||D&16&&s!==(s=r[4].y))&&R(t,"y",s),(!X||D&16&&n!==(n=r[4].w))&&R(t,"width",n),(!X||D&16&&o!==(o=r[4].h))&&R(t,"height",o),(!X||D&2)&&R(l,"style",r[1]),(!X||D&16&&h!==(h=r[4].x))&&R(l,"x",h),(!X||D&16&&u!==(u=r[4].y))&&R(l,"y",u),(!X||D&16&&c!==(c=r[4].w))&&R(l,"width",c),(!X||D&16&&d!==(d=r[4].h))&&R(l,"height",d),(!X||D&16&&m!==(m=r[4].x))&&R(f,"x",m),(!X||D&16&&y!==(y=r[4].y))&&R(f,"y",y),(!X||D&16&&_!==(_=r[4].w))&&R(f,"width",_),(!X||D&16&&x!==(x=r[4].x+r[4].w))&&R(g,"x",x),(!X||D&16&&b!==(b=r[4].y))&&R(g,"y",b),(!X||D&16&&S!==(S=r[4].h))&&R(g,"height",S),(!X||D&16&&N!==(N=r[4].x))&&R(T,"x",N),(!X||D&16&&F!==(F=r[4].y+r[4].h))&&R(T,"y",F),(!X||D&16&&z!==(z=r[4].w))&&R(T,"width",z),(!X||D&16&&I!==(I=r[4].x))&&R(E,"x",I),(!X||D&16&&P!==(P=r[4].y))&&R(E,"y",P),(!X||D&16&&$!==($=r[4].h))&&R(E,"height",$);const ut={};D&16&&(ut.x=r[4].x),D&16&&(ut.y=r[4].y),D&8&&(ut.scale=r[3]),G.$set(ut);const lt={};D&16&&(lt.x=r[4].x+r[4].w),D&16&&(lt.y=r[4].y),D&8&&(lt.scale=r[3]),M.$set(lt);const Et={};D&16&&(Et.x=r[4].x+r[4].w),D&16&&(Et.y=r[4].y+r[4].h),D&8&&(Et.scale=r[3]),V.$set(Et);const Tt={};D&16&&(Tt.x=r[4].x),D&16&&(Tt.y=r[4].y+r[4].h),D&8&&(Tt.scale=r[3]),Q.$set(Tt)},i(O){X||(q(G.$$.fragment,O),q(M.$$.fragment,O),q(V.$$.fragment,O),q(Q.$$.fragment,O),X=!0)},o(O){et(G.$$.fragment,O),et(M.$$.fragment,O),et(V.$$.fragment,O),et(Q.$$.fragment,O),X=!1},d(O){O&&(ht(t),ht(a),ht(l),ht(p),ht(f),ht(v),ht(g),ht(w),ht(T),ht(C),ht(E),ht(k),ht(st),ht(L),ht(rt)),Ut(G,O),Ut(M,O),Ut(V,O),Ut(Q,O),_t=!1,er(St)}}}function bS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[xS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){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&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function ES(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.bounds;let[y,_]=[m.minX,m.minY],[v,g]=[m.maxX,m.maxY];const[x,b]=f;if(p==="SHAPE")y+=x,v+=x,_+=b,g+=b;else{switch(p){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{_+=b;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{g+=b;break}}switch(p){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{y+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const S=Math.min(y,v),w=Math.min(_,g),T=Math.abs(v-y),N=Math.abs(g-_);return{...d,geometry:{x:S,y:w,w:T,h:N,bounds:{minX:S,minY:w,maxX:S+T,maxY:w+N}}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class TS extends re{constructor(t){super(),ee(this,t,ES,bS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}function rm(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function im(r,t,e){const i=r.slice();return i[13]=t[e],i[15]=e,i}function sm(r,t,e){const i=r.slice();return i[16]=t[e],i[18]=e,i}function nm(r){let t,e;return t=new ls({props:{x:r[16][0],y:r[16][1],scale:r[3]}}),t.$on("pointerdown",function(){Kt(r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`))&&r[9](`HANDLE-${r[12]}-${r[15]}-${r[18]}`).apply(this,arguments)}),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[16][0]),s&16&&(n.y=r[16][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function om(r){let t,e,i=Se(r[13].points),s=[];for(let o=0;o<i.length;o+=1)s[o]=nm(sm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&536){i=Se(o[13].points);let l;for(l=0;l<i.length;l+=1){const h=sm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=nm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function am(r){let t,e,i,s,n,o,a,l,h,u=Se(r[10].rings),c=[];for(let p=0;p<u.length;p+=1)c[p]=om(im(r,u,p));const d=p=>et(c[p],1,1,()=>{c[p]=null});return{c(){t=xt("g"),e=xt("path"),n=xt("path");for(let p=0;p<c.length;p+=1)c[p].c();R(e,"class","a9s-outer"),R(e,"style",i=r[1]?"display:none;":void 0),R(e,"fill-rule","evenodd"),R(e,"d",s=No(r[10])),R(n,"class","a9s-inner"),R(n,"style",r[1]),R(n,"fill-rule","evenodd"),R(n,"d",o=No(r[10]))},m(p,f){ct(p,t,f),Ae(t,e),Ae(t,n);for(let m=0;m<c.length;m+=1)c[m]&&c[m].m(t,null);a=!0,l||(h=[Zt(e,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Zt(n,"pointerdown",function(){Kt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],l=!0)},p(p,f){if(r=p,(!a||f&2&&i!==(i=r[1]?"display:none;":void 0))&&R(e,"style",i),(!a||f&16&&s!==(s=No(r[10])))&&R(e,"d",s),(!a||f&2)&&R(n,"style",r[1]),(!a||f&16&&o!==(o=No(r[10])))&&R(n,"d",o),f&536){u=Se(r[10].rings);let m;for(m=0;m<u.length;m+=1){const y=im(r,u,m);c[m]?(c[m].p(y,f),q(c[m],1)):(c[m]=om(y),c[m].c(),q(c[m],1),c[m].m(t,null))}for(ge(),m=u.length;m<c.length;m+=1)d(m);ye()}},i(p){if(!a){for(let f=0;f<u.length;f+=1)q(c[f]);a=!0}},o(p){c=c.filter(Boolean);for(let f=0;f<c.length;f+=1)et(c[f]);a=!1},d(p){p&&ht(t),ii(c,p),l=!1,er(h)}}}function wS(r){let t,e,i=Se(r[4].polygons),s=[];for(let o=0;o<i.length;o+=1)s[o]=am(rm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&538){i=Se(o[4].polygons);let l;for(l=0;l<i.length;l+=1){const h=rm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=am(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function AS(r){let t,e;return t=new bh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[wS,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){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&524826&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function SS(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,p,f)=>{const m=d.geometry.polygons;let y;if(p==="SHAPE")y=m.map(_=>{const v=_.rings.map((x,b)=>({points:x.points.map((w,T)=>[w[0]+f[0],w[1]+f[1]])})),g=Oo(v[0].points);return{rings:v,bounds:g}});else{const[_,v,g,x]=p.split("-").map(b=>parseInt(b));y=m.map((b,S)=>{if(S===v){const w=b.rings.map((N,F)=>F===g?{points:N.points.map((C,E)=>E===x?[C[0]+f[0],C[1]+f[1]]:C)}:N),T=Oo(w[0].points);return{rings:w,bounds:T}}else return b})}return{...d,geometry:{polygons:y,bounds:$A(y)}}};function h(d){De.call(this,r,d)}function u(d){De.call(this,r,d)}function c(d){De.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,u,c]}class CS extends re{constructor(t){super(),ee(this,t,SS,AS,Wt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}jr.RECTANGLE,jr.POLYGON,jr.MULTIPOLYGLON;const IS=r=>({}),lm=r=>({grab:r[0]});function RS(r){let t,e,i,s;const n=r[7].default,o=Zu(n,r,r[6],lm);return{c(){t=xt("g"),o&&o.c(),R(t,"class","a9s-annotation selected")},m(a,l){ct(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Zt(t,"pointerup",r[2]),Zt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&tc(o,n,a,a[6],e?Ju(n,a[6],l,IS):ec(a[6]),lm)},i(a){e||(q(o,a),e=!0)},o(a){et(o,a),e=!1},d(a){a&&ht(t),o&&o.d(a),i=!1,er(s)}}}function MS(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=yn();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,u,c;const d=m=>y=>{h=m,u=l.elementToImage(y.offsetX,y.offsetY),c=o,y.target.setPointerCapture(y.pointerId),n("grab",y)},p=m=>{if(h){const[y,_]=l.elementToImage(m.offsetX,m.offsetY),v=[y-u[0],_-u[1]];e(3,o=a(c,h,v)),n("change",o)}},f=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,c=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,p,f,o,a,l,s,i]}class bh extends re{constructor(t){super(),ee(this,t,MS,RS,Wt,{shape:3,editor:4,transform:5})}}const PS=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s,stroke:n,strokeWidth:o,strokeOpacity:a}=e;let l="";return i&&(l+=`fill:${i};`,l+=`fill-opacity:${s||"0.25"};`),n&&(l+=`stroke:${n};`,l+=`stroke-width:${o||"1"};`,l+=`stroke-opacity:${a||"1"};`),l}};function OS(r,t,e){let i;const s=yn();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:u}=t,c;return gn(()=>(e(6,c=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:u}})),c.$on("change",d=>{c.$$set({shape:d.detail}),s("change",d.detail)}),c.$on("grab",d=>s("grab",d.detail)),c.$on("release",d=>s("release",d.detail)),()=>{c.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,u=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&e(7,i=PS(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 NS extends re{constructor(t){super(),ee(this,t,OS,null,Wt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}typeof navigator>"u"?!1:navigator.userAgent.indexOf("Mac OS X")!==-1;const hm=(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},DS=r=>({transform:r&2,scale:r&1}),um=r=>({transform:r[1],scale:r[0]});function LS(r){let t;const e=r[4].default,i=Zu(e,r,r[3],um);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&tc(i,e,s,s[3],t?Ju(e,s[3],n,DS):ec(s[3]),um)},i(s){t||(q(i,s),t=!0)},o(s){et(i,s),t=!1},d(s){i&&i.d(s)}}}function BS(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 de.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 gn(()=>(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 Eh extends re{constructor(t){super(),ee(this,t,BS,LS,Wt,{viewer:2})}}function FS(r,t,e){const i=yn();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,u;return gn(()=>{const c=n.closest("svg"),d=[],p=(f,m,y)=>{if(c==null||c.addEventListener(f,m,y),d.push(()=>c==null?void 0:c.removeEventListener(f,m,y)),f==="pointerup"||f==="dblclick"){const _=g=>{const{originalEvent:x}=g;m(x)},v=f==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(v,_),d.push(()=>l.removeHandler(v,_))}else if(f==="pointermove"){const _=v=>{const{originalEvent:g}=v;m(g)};l.addHandler("canvas-drag",_),d.push(()=>l.removeHandler("canvas-drag",_))}};return e(6,u=new o({target:n,props:{addEventListener:p,drawingMode:s,transform:a,viewportScale:h}})),u.$on("create",f=>i("create",f.detail)),()=>{d.forEach(f=>f()),u.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewer"in c&&e(4,l=c.viewer),"viewportScale"in c&&e(5,h=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&u&&u.$set({transform:a}),r.$$.dirty&96&&u&&u.$set({viewportScale:h})},[s,n,o,a,l,h,u]}class US extends re{constructor(t){super(),ee(this,t,FS,null,Wt,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function cm(r,t,e){const i=r.slice();i[36]=t[e];const s=i[15](i[36].target.selector);return i[37]=s,i}function kS(r){let t=`${r[2]}-${r[5]}`,e,i,s=dm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&36&&Wt(t,t=`${n[2]}-${n[5]}`)?(ge(),et(s,1,1,me),ye(),s=dm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function GS(r){let t,e,i=Se(r[7].filter(r[26])),s=[];for(let o=0;o<i.length;o+=1)s[o]=mm(cm(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a[0]&48322|a[1]&16){i=Se(o[7].filter(o[26]));let l;for(l=0;l<i.length;l+=1){const h=cm(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=mm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},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)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function dm(r){let t,e;return t=new US({props:{target:r[6],tool:r[8],drawingMode:r[4],transform:{elementToImage:r[10]},viewer:r[3],viewportScale:r[35]}}),t.$on("create",r[14]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){const n={};s[0]&64&&(n.target=i[6]),s[0]&256&&(n.tool=i[8]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[1]&16&&(n.viewportScale=i[35]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function fm(r){let t=r[36].id,e,i,s=pm(r);return{c(){s.c(),e=Re()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&128&&Wt(t,t=n[36].id)?(ge(),et(s,1,1,me),ye(),s=pm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s.d(n)}}}function pm(r){let t,e;return t=new NS({props:{target:r[6],editor:r[15](r[36].target.selector),annotation:r[36],style:r[1],transform:{elementToImage:r[10]},viewportScale:r[35]}}),t.$on("grab",r[11]),t.$on("change",function(){Kt(r[13](r[36]))&&r[13](r[36]).apply(this,arguments)}),t.$on("release",r[12]),{c(){Ht(t.$$.fragment)},m(i,s){Ft(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&64&&(n.target=r[6]),s[0]&128&&(n.editor=r[15](r[36].target.selector)),s[0]&128&&(n.annotation=r[36]),s[0]&2&&(n.style=r[1]),s[1]&16&&(n.viewportScale=r[35]),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function mm(r){let t,e,i=r[37]&&fm(r);return{c(){i&&i.c(),t=Re()},m(s,n){i&&i.m(s,n),ct(s,t,n),e=!0},p(s,n){s[37]?i?(i.p(s,n),n[0]&128&&q(i,1)):(i=fm(s),i.c(),q(i,1),i.m(t.parentNode,t)):i&&(ge(),et(i,1,1,()=>{i=null}),ye())},i(s){e||(q(i),e=!0)},o(s){et(i),e=!1},d(s){s&&ht(t),i&&i.d(s)}}}function $S(r){let t,e,i,s,n,o;const a=[GS,kS],l=[];function h(u,c){var d;return u[6]&&((d=u[7])==null?void 0:d.length)===1?0:u[6]&&u[8]&&u[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=xt("svg"),e=xt("g"),s&&s.c(),R(e,"transform",n=r[34]),R(e,"class","svelte-190cqdf"),R(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),mn(t,"drawing",r[0])},m(u,c){ct(u,t,c),Ae(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&&(ge(),et(l[d],1,1,()=>{l[d]=null}),ye()),~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]&8&&n!==(n=u[34]))&&R(e,"transform",n),(!o||c[0]&1)&&mn(t,"drawing",u[0])},i(u){o||(q(s),o=!0)},o(u){et(s),o=!1},d(u){u&&ht(t),~i&&l[i].d(),r[27](null)}}}function HS(r){let t,e;return t=new Eh({props:{viewer:r[3],$$slots:{default:[$S,({transform:i,scale:s})=>({34:i,35:s}),({transform:i,scale:s})=>[0,(i?8:0)|(s?16: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]&511|s[1]&536&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(q(t.$$.fragment,i),e=!0)},o(i){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function VS(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=hn()[0]}=t,{user:f}=t,{viewer:m}=t,y=0;const _=()=>e(5,y+=1),v=()=>p,g=()=>a;navigator.userAgent.match(/firefox|fxios/i);let x;const{store:b,selection:S,hover:w}=c;fn(r,S,M=>e(25,o=M));let T,N,F;const z=M=>{b.unobserve(T);const L=M.filter(({editable:V})=>V).map(({id:V})=>V);L.length>0?(e(7,N=L.map(V=>b.getAnnotation(V))),T=V=>{const{updated:rt}=V.changes;e(7,N=(rt||[]).map(Q=>Q.newValue))},b.observe(T,{annotations:L}),m.forceRedraw()):e(7,N=void 0)},C=(M,L)=>{const{x:V,y:rt}=m.viewport.viewerElementToImageCoordinates(new de.Point(M,L));return[V,rt]},E=M=>{m.setMouseNavEnabled(!1),F=M.timeStamp},I=M=>{if(m.setMouseNavEnabled(!0),performance.now()-(F||0)<300){const{offsetX:V,offsetY:rt}=M.detail,[Q,X]=C(V,rt),_t=b.getAt(Q,X);if(_t&&(!l||l(_t))&&!N.find(O=>O.id===_t.id)){w.set(_t.id);const O=hm(_t.id,M.detail,S,h);S.userSelect(O)}}},P=M=>L=>{var X;const{target:V}=M,rt=10*60*1e3,Q=((X=V.creator)==null?void 0:X.id)!==f.id||!V.created||new Date().getTime()-V.created.getTime()>rt;b.updateTarget({...V,selector:L.detail,created:Q?V.created:new Date,updated:Q?new Date:void 0,updatedBy:Q?f:void 0})},$=M=>{const L=FA(),V={id:L,bodies:[],target:{annotation:L,selector:M.detail,creator:f,created:new Date}};b.addAnnotation(V),S.setSelected(V.id),m.setMouseNavEnabled(!0)},k=M=>bu(M),G=M=>Ge(M);function st(M){_n[M?"unshift":"push"](()=>{x=M,e(6,x)})}return r.$$set=M=>{"drawingEnabled"in M&&e(0,a=M.drawingEnabled),"filter"in M&&e(16,l=M.filter),"multiSelect"in M&&e(17,h=M.multiSelect),"preferredDrawingMode"in M&&e(18,u=M.preferredDrawingMode),"state"in M&&e(19,c=M.state),"style"in M&&e(1,d=M.style),"toolName"in M&&e(2,p=M.toolName),"user"in M&&e(20,f=M.user),"viewer"in M&&e(3,m=M.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(8,{tool:i,opts:s}=un(p)||{tool:void 0,opts:void 0},i,(e(24,s),e(2,p))),r.$$.dirty[0]&17039360&&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&&S.clear(),r.$$.dirty[0]&33554457&&o.selected.length===0&&n==="drag"&&a&&m.setMouseNavEnabled(!1),r.$$.dirty[0]&33554432&&z(o.selected)},[a,d,p,m,n,y,x,N,i,S,C,E,I,P,$,k,l,h,u,c,f,_,v,g,s,o,G,st]}class XS extends re{constructor(t){super(),ee(this,t,VS,HS,Wt,{drawingEnabled:0,filter:16,multiSelect:17,preferredDrawingMode:18,state:19,style:1,toolName:2,user:20,viewer:3,cancelDrawing:21,getDrawingTool:22,isDrawingEnabled:23},null,[-1,-1])}get cancelDrawing(){return this.$$.ctx[21]}get getDrawingTool(){return this.$$.ctx[22]}get isDrawingEnabled(){return this.$$.ctx[23]}}function zS(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,u,c,d;return{c(){t=xt("g"),e=xt("rect"),a=xt("text"),h=ma(l),R(e,"class","a9s-presence-label-bg svelte-1rehw2p"),R(e,"x",r[0]),R(e,"y",i=r[1]-18/r[3]),R(e,"height",s=18/r[3]),R(e,"fill",n=r[2].appearance.color),R(e,"stroke",o=r[2].appearance.color),R(a,"font-size",u=12/r[3]),R(a,"x",c=r[0]+Math.round(5/r[3])),R(a,"y",d=r[1]-5/r[3]),R(a,"class","svelte-1rehw2p"),R(t,"class","a9s-presence-label")},m(p,f){ct(p,t,f),Ae(t,e),Ae(t,a),Ae(a,h),r[6](t)},p(p,[f]){f&1&&R(e,"x",p[0]),f&10&&i!==(i=p[1]-18/p[3])&&R(e,"y",i),f&8&&s!==(s=18/p[3])&&R(e,"height",s),f&4&&n!==(n=p[2].appearance.color)&&R(e,"fill",n),f&4&&o!==(o=p[2].appearance.color)&&R(e,"stroke",o),f&4&&l!==(l=p[2].appearance.label+"")&&c0(h,l),f&8&&u!==(u=12/p[3])&&R(a,"font-size",u),f&9&&c!==(c=p[0]+Math.round(5/p[3]))&&R(a,"x",c),f&10&&d!==(d=p[1]-5/p[3])&&R(a,"y",d)},i:me,o:me,d(p){p&&ht(t),r[6](null)}}}function WS(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){_n[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 gm extends re{constructor(t){super(),ee(this,t,WS,zS,Wt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function YS(r){let t,e,i,s,n,o;return e=new gm({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=xt("g"),Ht(e.$$.fragment),i=xt("polygon"),R(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"points",n=r[2].points.map(ym).join(" ")),R(t,"class","a9s-presence-overlay")},m(a,l){ct(a,t,l),Ft(e,t,null),Ae(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))&&R(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(ym).join(" ")))&&R(i,"points",n)},i(a){o||(q(e.$$.fragment,a),o=!0)},o(a){et(e.$$.fragment,a),o=!1},d(a){a&&ht(t),Ut(e)}}}const ym=r=>r.join(",");function jS(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 qS extends re{constructor(t){super(),ee(this,t,jS,YS,Wt,{annotation:4,user:0,scale:1})}}function KS(r){let t,e,i,s,n,o,a,l,h;return e=new gm({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=xt("g"),Ht(e.$$.fragment),i=xt("rect"),R(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),R(i,"stroke",s=r[0].appearance.color),R(i,"fill","transparent"),R(i,"x",n=r[2].x),R(i,"y",o=r[2].y),R(i,"width",a=r[2].w),R(i,"height",l=r[2].h),R(t,"class","a9s-presence-overlay")},m(u,c){ct(u,t,c),Ft(e,t,null),Ae(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))&&R(i,"stroke",s),(!h||c&4&&n!==(n=u[2].x))&&R(i,"x",n),(!h||c&4&&o!==(o=u[2].y))&&R(i,"y",o),(!h||c&4&&a!==(a=u[2].w))&&R(i,"width",a),(!h||c&4&&l!==(l=u[2].h))&&R(i,"height",l)},i(u){h||(q(e.$$.fragment,u),h=!0)},o(u){et(e.$$.fragment,u),h=!1},d(u){u&&ht(t),Ut(e)}}}function ZS(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 QS extends re{constructor(t){super(),ee(this,t,ZS,KS,Wt,{annotation:3,user:0,scale:1})}}const{Boolean:JS}=ic;function _m(r,t,e){const i=r.slice();return i[8]=t[e],i}function vm(r){let t,e;return t=new Eh({props:{viewer:r[0],$$slots:{default:[rC,({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function xm(r){let t,e,i=Se(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=bm(_m(r,i,o));const n=o=>et(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Re()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&132){i=Se(o[2]);let l;for(l=0;l<i.length;l+=1){const h=_m(o,i,l);s[l]?(s[l].p(h,a),q(s[l],1)):(s[l]=bm(h),s[l].c(),q(s[l],1),s[l].m(t.parentNode,t))}for(ge(),l=i.length;l<s.length;l+=1)n(l);ye()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)q(s[a]);e=!0}},o(o){s=s.filter(JS);for(let a=0;a<s.length;a+=1)et(s[a]);e=!1},d(o){o&&ht(t),ii(s,o)}}}function tC(r){let t,e;return t=new qS({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function eC(r){let t,e;return t=new QS({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function bm(r){let t,e,i,s;const n=[eC,tC],o=[];function a(l,h){return l[8].annotation.target.selector.type===vt.RECTANGLE?0:l[8].annotation.target.selector.type===vt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~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){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function rC(r){let t,e,i,s,n=r[2].length>0&&xm(r);return{c(){t=xt("svg"),e=xt("g"),n&&n.c(),R(e,"transform",i=r[6]),R(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,t,a),Ae(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=xm(o),n.c(),q(n,1),n.m(e,null)):n&&(ge(),et(n,1,1,()=>{n=null}),ye()),(!s||a&64&&i!==(i=o[6]))&&R(e,"transform",i)},i(o){s||(q(n),s=!0)},o(o){et(n),s=!1},d(o){o&&ht(t),n&&n.d()}}}function iC(r){let t=!!r[1],e,i,s=t&&vm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(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=vm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function sC(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 f0(()=>{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 nC extends re{constructor(t){super(),ee(this,t,sC,iC,Wt,{store:3,viewer:0,provider:1})}}function oC(r){let t,e,i,s,n;return{c(){t=xt("rect"),R(t,"x",e=r[0].x),R(t,"y",i=r[0].y),R(t,"width",s=r[0].w),R(t,"height",n=r[0].h)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].x)&&R(t,"x",e),a&1&&i!==(i=o[0].y)&&R(t,"y",i),a&1&&s!==(s=o[0].w)&&R(t,"width",s),a&1&&n!==(n=o[0].h)&&R(t,"height",n)},i:me,o:me,d(o){o&&ht(t)}}}function aC(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 lC extends re{constructor(t){super(),ee(this,t,aC,oC,Wt,{annotation:1})}}function hC(r){let t,e;return{c(){t=xt("polygon"),R(t,"points",e=r[0].points.map(Em).join(" "))},m(i,s){ct(i,t,s)},p(i,[s]){s&1&&e!==(e=i[0].points.map(Em).join(" "))&&R(t,"points",e)},i:me,o:me,d(i){i&&ht(t)}}}const Em=r=>r.join(",");function uC(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 cC extends re{constructor(t){super(),ee(this,t,uC,hC,Wt,{annotation:1})}}function dC(r){let t,e,i,s,n;return{c(){t=xt("ellipse"),R(t,"cx",e=r[0].cx),R(t,"cy",i=r[0].cy),R(t,"rx",s=r[0].rx),R(t,"ry",n=r[0].ry)},m(o,a){ct(o,t,a)},p(o,[a]){a&1&&e!==(e=o[0].cx)&&R(t,"cx",e),a&1&&i!==(i=o[0].cy)&&R(t,"cy",i),a&1&&s!==(s=o[0].rx)&&R(t,"rx",s),a&1&&n!==(n=o[0].ry)&&R(t,"ry",n)},i:me,o:me,d(o){o&&ht(t)}}}function fC(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 pC extends re{constructor(t){super(),ee(this,t,fC,dC,Wt,{annotation:1})}}const{Boolean:mC}=ic;function Tm(r,t,e){const i=r.slice();return i[10]=t[e],i}function wm(r){let t,e;return t=new Eh({props:{viewer:r[0],$$slots:{default:[vC,({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function gC(r){let t,e;return t=new pC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function yC(r){let t,e;return t=new cC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function _C(r){let t,e;return t=new lC({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){et(t.$$.fragment,i),e=!1},d(i){Ut(t,i)}}}function Am(r){let t,e,i,s;const n=[_C,yC,gC],o=[];function a(l,h){return l[10].target.selector.type===vt.RECTANGLE?0:l[10].target.selector.type===vt.POLYGON?1:l[10].target.selector.type===vt.ELLIPSE?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Re()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let u=t;t=a(l),t===u?~t&&o[t].p(l,h):(e&&(ge(),et(o[u],1,1,()=>{o[u]=null}),ye()),~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){et(e),s=!1},d(l){l&&ht(i),~t&&o[t].d(l)}}}function vC(r){let t,e,i,s,n,o,a,l,h,u,c,d,p,f,m=Se(r[1].filter(r[6])),y=[];for(let v=0;v<m.length;v+=1)y[v]=Am(Tm(r,m,v));const _=v=>et(y[v],1,1,()=>{y[v]=null});return{c(){var v,g,x,b;t=xt("svg"),e=xt("g"),i=xt("rect"),l=xt("rect");for(let S=0;S<y.length;S+=1)y[S].c();R(i,"class","a9s-union-bg svelte-n2zwns"),R(i,"x",s=(v=r[2])==null?void 0:v.minX),R(i,"y",n=(g=r[2])==null?void 0:g.minY),R(i,"width",o=r[2]?r[2].maxX-r[2].minX:0),R(i,"height",a=r[2]?r[2].maxY-r[2].minY:0),R(l,"class","a9s-union-fg svelte-n2zwns"),R(l,"x",h=(x=r[2])==null?void 0:x.minX),R(l,"y",u=(b=r[2])==null?void 0:b.minY),R(l,"width",c=r[2]?r[2].maxX-r[2].minX:0),R(l,"height",d=r[2]?r[2].maxY-r[2].minY:0),R(e,"transform",p=r[9]),R(t,"class","a9s-osd-selectionlayer svelte-n2zwns")},m(v,g){ct(v,t,g),Ae(t,e),Ae(e,i),Ae(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,b,S,w;if((!f||g&4&&s!==(s=(x=v[2])==null?void 0:x.minX))&&R(i,"x",s),(!f||g&4&&n!==(n=(b=v[2])==null?void 0:b.minY))&&R(i,"y",n),(!f||g&4&&o!==(o=v[2]?v[2].maxX-v[2].minX:0))&&R(i,"width",o),(!f||g&4&&a!==(a=v[2]?v[2].maxY-v[2].minY:0))&&R(i,"height",a),(!f||g&4&&h!==(h=(S=v[2])==null?void 0:S.minX))&&R(l,"x",h),(!f||g&4&&u!==(u=(w=v[2])==null?void 0:w.minY))&&R(l,"y",u),(!f||g&4&&c!==(c=v[2]?v[2].maxX-v[2].minX:0))&&R(l,"width",c),(!f||g&4&&d!==(d=v[2]?v[2].maxY-v[2].minY:0))&&R(l,"height",d),g&2){m=Se(v[1].filter(v[6]));let T;for(T=0;T<m.length;T+=1){const N=Tm(v,m,T);y[T]?(y[T].p(N,g),q(y[T],1)):(y[T]=Am(N),y[T].c(),q(y[T],1),y[T].m(e,null))}for(ge(),T=m.length;T<y.length;T+=1)_(T);ye()}(!f||g&512&&p!==(p=v[9]))&&R(e,"transform",p)},i(v){if(!f){for(let g=0;g<m.length;g+=1)q(y[g]);f=!0}},o(v){y=y.filter(mC);for(let g=0;g<y.length;g+=1)et(y[g]);f=!1},d(v){v&&ht(t),ii(y,v)}}}function xC(r){let t=!!r[2],e,i,s=t&&wm(r);return{c(){s&&s.c(),e=Re()},m(n,o){s&&s.m(n,o),ct(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=wm(n),s.c(),q(s,1),s.m(e.parentNode,e)):s&&(ge(),et(s,1,1,()=>{s=null}),ye())},i(n){i||(q(s),i=!0)},o(n){et(s),i=!1},d(n){n&&ht(e),s&&s.d(n)}}}function bC(r,t,e){let i,s,n,{state:o}=t,{viewer:a}=t;const{store:l}=o,{selection:h}=o;fn(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=>Ge(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=>Ge(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 EC extends re{constructor(t){super(),ee(this,t,bC,xC,Wt,{state:4,viewer:0})}}const Sm=(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=Xu(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Cm=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o||!Ge(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,b=_+(u+d)*_,S=v+(h+c)*v,w=r.viewport.imageToViewportRectangle(g,x,b,S);r.viewport[e](w,s.immediately)},TC=(r,t)=>Cm(r,t,"fitBounds"),wC=(r,t)=>Cm(r,t,"fitBoundsWithConstraints"),AC=(r,t={})=>{const e=Wu(t,{drawingEnabled:!1,drawingMode:fu?"drag":"click",userSelectAction:$o.EDIT,theme:"light"}),i=Vu(e),{hover:s,selection:n,store:o}=i,a=Wm(o,e.initialHistory),l=Ym(i,a,e.adapter,e.autoSave);let h=eg(),u=e.drawingEnabled,c=e.drawingMode,d=e.modalSelect;const p=ju(a,r.element),f=new NA({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),m=new nC({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),y=new XS({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 EC({target:r.element.querySelector(".openseadragon-canvas"),props:{state:i,viewer:r}});f.$on("click",L=>{const{originalEvent:V,annotation:rt}=L.detail,Q=X=>hm(X.id,V,n,e.multiSelect);d?n.isEmpty()&&rt&&n.userSelect(Q(rt),V):rt&&!(c==="click"&&u)?n.userSelect(Q(rt),V):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",L=>{if(s.current){const V=o.getAnnotation(s.current);l.emit("clickAnnotation",V,L)}}),Sm(r,e.theme);const v=qm(i,a,e.adapter),g=()=>y.cancelDrawing(),x=()=>{f.$destroy(),m.$destroy(),y.$destroy(),_.$destroy(),p.destroy(),a.destroy()},b=TC(r,o),S=wC(r,o),w=()=>y.getDrawingTool(),T=()=>h,N=()=>y.isDrawingEnabled(),F=(L,V,rt)=>Cu(L,V,rt),z=(L,V)=>Eu(L,V),C=L=>{if(!un(L))throw`No drawing tool named ${L}`;y.$set({toolName:L})},E=L=>{u=L,y.$set({drawingEnabled:L})},I=L=>{f.$set({filter:L}),y.$set({filter:L})},P=L=>d=L,$=L=>{f.$set({style:L}),y.$set({style:L})},k=L=>m.$set({provider:L}),G=L=>Sm(r,L),st=L=>{h=L,y.$set({user:L})},M=L=>f.$set({visible:L});return{...v,cancelDrawing:g,destroy:x,fitBounds:b,fitBoundsWithConstraints:S,getDrawingTool:w,getUser:T,isDrawingEnabled:N,listDrawingTools:hn,on:l.on,off:l.off,registerDrawingTool:F,registerShapeEditor:z,setDrawingEnabled:E,setDrawingTool:C,setFilter:I,setModalSelect:P,setPresenceProvider:k,setStyle:$,setTheme:G,setUser:st,setVisible:M,state:i,viewer:r}};Gt.ShapeType=vt,Gt.UserSelectAction=$o,Gt.W3CImageFormat=Hy,Gt.chainStyles=Oy,Gt.computeStyle=Py,Gt.createBody=Fm,Gt.createImageAnnotator=a0,Gt.createOSDAnnotator=AC,Gt.defaultColorProvider=ig,Object.defineProperty(Gt,Symbol.toStringTag,{value:"Module"})});
|
|
1150
1150
|
//# sourceMappingURL=annotorious-openseadragon.js.map
|