modern-canvas 0.1.1 → 0.1.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.
- package/README.md +1 -0
- package/dist/index.cjs +407 -2757
- package/dist/index.d.cts +53 -425
- package/dist/index.d.mts +53 -425
- package/dist/index.d.ts +53 -425
- package/dist/index.js +50 -50
- package/dist/index.mjs +409 -2733
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(g,Et){typeof exports=="object"&&typeof module<"u"?Et(exports):typeof define=="function"&&define.amd?define(["exports"],Et):(g=typeof globalThis<"u"?globalThis:g||self,Et(g.modernCanvas={}))})(this,function(g){"use strict";var Np=Object.defineProperty;var Fp=(g,Et,at)=>Et in g?Np(g,Et,{enumerable:!0,configurable:!0,writable:!0,value:at}):g[Et]=at;var d=(g,Et,at)=>Fp(g,typeof Et!="symbol"?Et+"":Et,at);var er,ke;const Et=Math.PI,at=Et*2;let Ll=0;function Dn(n){var e;return((e=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:e.id)??++Ll}function ss(n){return!(n&n-1)&&!!n}const kl=/([\w-]+)\((.+?)\)/g,Nl=/[^,]+/g,Fl=/([-e.\d]+)(.*)/;function ns(n){return Array.isArray(n)?n.map(e=>({name:e.name,args:e.args.map(t=>({...t,normalizedIntValue:t.normalizedDefaultIntValue}))})):{...n,normalizedIntValue:n.normalizedDefaultIntValue}}function xr(n,e,t={}){const r=wr(e,t);return r.length?r:Rn(n,e,t)}function wr(n,e={}){const t=[];let r;for(;(r=kl.exec(n))!==null;){const[,i,s]=r;i&&t.push({name:i,args:$l(i,s,e)})}return t}function $l(n,e,t={}){const r=[];let i,s=0;for(;(i=Nl.exec(e))!==null;)r.push(Rn(n,i[0],{...t,index:s++}));return r}function Rn(n,e,t={}){const{width:r=1,height:i=1,index:s=0}=t,o=e.match(Fl),a={unit:(o==null?void 0:o[2])??null,value:e,intValue:Number(o==null?void 0:o[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(n){case"scale":case"scaleX":case"scaleY":case"scale3d":a.normalizedDefaultIntValue=1;break}switch(a.unit){case"%":a.normalizedIntValue=a.intValue/100;break;case"rad":a.normalizedIntValue=a.intValue/at;break;case"deg":a.normalizedIntValue=a.intValue/360;break;case"px":switch(s){case 0:a.normalizedIntValue=a.intValue/r;break;case 1:a.normalizedIntValue=a.intValue/i;break}break;case"turn":case"em":case"rem":default:a.normalizedIntValue=a.intValue;break}return a}const Bn="WebGL2RenderingContext"in globalThis,Ln="ImageBitmap"in globalThis,kn="ResizeObserver"in globalThis,sr="PointerEvent"in globalThis,Nn="WheelEvent"in globalThis,zl="MouseEvent"in globalThis,_e="ontouchstart"in globalThis,Fn="onclick"in globalThis,os="createImageBitmap"in globalThis,as="AudioContext"in globalThis,ls="webkitAudioContext"in globalThis,hs="OfflineAudioContext"in globalThis,$n="webkitOfflineAudioContext"in globalThis,zn=as||ls,Pr=typeof window<"u",cs=globalThis.devicePixelRatio||1,us=n=>n!==null&&typeof n=="object"&&n.nodeType===1,Vn=n=>us(n)&&n.tagName==="VIDEO",Vl=n=>us(n)&&n.tagName==="IMG";function Xn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function jn(n){return Bn&&n instanceof globalThis.WebGL2RenderingContext}function Gn(){if(Pr)return globalThis.document.createElement("canvas")}function qn(n,e=globalThis.location){if(n.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(n,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Yn(n,e,t){t===null&&!e.startsWith("data:")?n.crossOrigin=qn(e):t!==!1&&(n.crossOrigin=typeof t=="string"?t:"anonymous")}let ve=class{constructor(){d(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}on(e,t,r){const i={value:t,options:r},s=this.eventListeners.get(e);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(e,[s,i]):this.eventListeners.set(e,i),this}once(e,t){return this.on(e,t,{once:!0})}off(e,t,r){var s,o;if(!t)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==t||typeof r=="object"&&(r!=null&&r.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===t&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(e);return this}emit(e,...t){var i,s;const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let o=r.length,a=0;a<o;a++){const l=r[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(e,l.value,l.options),l.value.apply(this,t)}else typeof r.options=="object"&&((s=r.options)!=null&&s.once)&&this.off(e,r.value,r.options),r.value.apply(this,t);return!0}else return!1}};const oi=new Map;function Z(n){let e,t;return typeof n=="string"?e=n:{tag:e,renderable:t}=n,function(r){Object.defineProperty(r.prototype,"tag",{value:e,enumerable:!0,configurable:!0}),typeof t<"u"&&Object.defineProperty(r,"renderable",{value:t,enumerable:!1,configurable:!1}),oi.set(e,r)}}const Wn=new WeakMap;function ai(n){let e=Wn.get(n);if(!e){const t=Object.getPrototypeOf(n);e=new Map(t?ai(t):void 0),Wn.set(n,e)}return e}function W(n,e,t={}){ai(n).set(e,t);const{default:r,alias:i}=t;let s=Object.getOwnPropertyDescriptor(n.prototype,e);if(!s){const o=i??Symbol.for(String(e));s={get(){return this[o]},set(a){this[o]=a}}}Object.defineProperty(n.prototype,e,{get(){var o;return((o=s.get)==null?void 0:o.call(this))??r},set(o){var l,h,c;const a=((l=s.get)==null?void 0:l.call(this))??r;(h=s.set)==null||h.call(this,o),(c=this.requestUpdate)==null||c.call(this,e,a,t)},configurable:!0,enumerable:!0})}function U(n){return function(e,t){W(e.constructor,t,n)}}function nt(n){return U({...n,protected:!0})}function Xl(n="node",e={}){const t=oi.get(n);if(!t)throw new Error(`Failed to createNode, tag: ${n}`);return new t().setProperties(e)}class ft{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(e,t={}){const{sort:r=0,once:i=!1}=t;this._queue[r]||(this._queue[r]=[]),this._queue[r].push({cb:e,once:i})}static off(e,t={}){const{sort:r=0}=t,i=this._queue[r];if(!i)return;const s=[];for(let o=i.length,a=0;a<o;a++){const l=i[a];l.cb!==e&&s.push(l)}s.length?this._queue[r]=s:this._queue.splice(r,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(e=>this._update(e)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(e){this._elapsed=e-this._currentTime,this._currentTime=e,this._requestId=requestAnimationFrame(t=>this._update(t)),this._performUpdate()}static _performUpdate(){const e=this._queue,t=[];for(let r=e.length,i=r;i>=0;i--){const s=e[i];if(!s)continue;const o=[];for(let a=s.length,l=0;l<a;l++){const h=s[l];try{h.cb()}catch(c){console.warn(c)}h.once||o.push(h)}o.length&&(t[i]=o)}this._queue=t}}d(ft,"_queue",[]),d(ft,"_currentTime",0),d(ft,"_elapsed",0),d(ft,"_requestId"),ft.start();async function fs(n){return new Promise(e=>{ft.on(()=>{n==null||n(),e()},{sort:1,once:!0})})}let jl=0;class li extends ve{constructor(){super(...arguments);d(this,"instanceId",++jl);d(this,"_defaultProperties");d(this,"_updatedProperties",new Map);d(this,"_changedProperties",new Set);d(this,"_updatePending",Promise.resolve());d(this,"_isUpdatePending",!1)}async _enqueueUpdate(){this._isUpdatePending=!0;try{await this._updatePending}catch(t){Promise.reject(t)}await fs(),this._performUpdate()}_performUpdate(){this._isUpdatePending&&(this._onUpdate(this._updatedProperties),this._updatedProperties=new Map,this._isUpdatePending=!1)}_onUpdate(t){}_onUpdateProperty(t,r,i,s){}isDirty(t){return this._updatedProperties.has(t)}getPropertyDeclarations(){return ai(this.constructor)}getPropertyDeclaration(t){return this.getPropertyDeclarations().get(t)}getDefaultProperties(){if(!this._defaultProperties){this._defaultProperties={};for(const[t,r]of this.getPropertyDeclarations())!r.protected&&!r.alias&&(this._defaultProperties[t]=r.default)}return this._defaultProperties}getProperty(t){return this[t]}setProperty(t,r){return this[t]=r,this}getProperties(t){const r={};for(const[i,s]of this.getPropertyDeclarations())!s.protected&&!s.alias&&(!t||t.includes(i))&&(r[i]=this.getProperty(i));return r}setProperties(t){if(t)for(const[r]of this.getPropertyDeclarations())r in t&&this.setProperty(r,t[r]);return this}requestUpdate(t,r,i){if(t!==void 0){const s=this[t];if(!Object.is(s,r))this._updatedProperties.set(t,r),this._changedProperties.add(t),i??(i=this.getPropertyDeclaration(t)),this._onUpdateProperty(t,s,r,i),this.emit("updateProperty",t,s,r,i);else return}this._isUpdatePending||(this._updatePending=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}destroy(){}}class ds extends li{constructor(){super(...arguments);d(this,"_refCount",0)}}class Ee extends ds{}class hi extends Ee{constructor(t={}){super();d(this,"vertexAttributes");d(this,"indexBuffer");d(this,"instanceCount");d(this,"mode");d(this,"_materialWeakMap",new WeakMap);this.vertexAttributes=new Map(Object.entries((t==null?void 0:t.vertexAttributes)??{})),this.indexBuffer=t==null?void 0:t.indexBuffer,this.instanceCount=t==null?void 0:t.instanceCount,this.mode=(t==null?void 0:t.mode)??"triangles"}_glVertexArray(t){var r;return{attributes:Object.fromEntries(Array.from(this.vertexAttributes).map(([i,s])=>[i,{buffer:s.buffer._glBuffer(t),size:s.size,type:s.type,normalized:s.normalized,stride:s.stride,offset:s.offset,divisor:s.divisor}])),elementArrayBuffer:(r=this.indexBuffer)==null?void 0:r._glBuffer(t)}}_glVertexArrayObject(t,r){let i=this._materialWeakMap.get(r);return i||(i={material:r.instanceId,geometry:this.instanceId},this._materialWeakMap.set(r,i)),t.getRelated(i,()=>t.vertexArray.create(r._glProgram(t),this._glVertexArray(t)))}draw(t,r,i){var l;t.flush(),r.activate(t,i);const s=this._glVertexArrayObject(t,r);let o=!1,a;this.vertexAttributes.forEach(h=>{(a==null?void 0:a.instanceId)!==h.buffer.instanceId&&(a=h.buffer,a.upload(t)&&(o=!0)),h.upload()&&(o=!0)}),(l=this.indexBuffer)!=null&&l.upload(t)&&(o=!0),o&&s&&t.vertexArray.update(r._glProgram(t),s,this._glVertexArray(t)),t.vertexArray.bind(s??this._glVertexArray(t)),t.draw({mode:this.mode,instanceCount:this.instanceCount}),t.vertexArray.unbind()}}var Gl=Object.defineProperty,Hn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Gl(e,t,i),i};class nr extends Ee{constructor(t){super();d(this,"needsUpload",!1);this.setProperties(t)}_glBufferOptions(){return{target:"element_array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(t){return t.getRelated(this,()=>t.buffer.create(this._glBufferOptions()))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"data":case"dynamic":this.needsUpload=!0;break}}upload(t){const r=this.needsUpload;return r&&(this.needsUpload=!1,t.buffer.update(this._glBuffer(t),this._glBufferOptions())),r}}Hn([nt({default:null})],nr.prototype,"data"),Hn([nt({default:!1})],nr.prototype,"dynamic");var ql=Object.defineProperty,Zn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ql(e,t,i),i};class be extends Ee{constructor(t){super();d(this,"needsUpload",!1);this.setProperties(t)}_glBufferOptions(){return{target:"array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(t){return t.getRelated(this,()=>t.buffer.create(this._glBufferOptions()))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"data":case"dynamic":this.needsUpload=!0;break}}upload(t){const r=this.needsUpload;return r&&(this.needsUpload=!1,t.buffer.update(this._glBuffer(t),this._glBufferOptions())),r}}Zn([nt({default:null})],be.prototype,"data"),Zn([nt({default:!1})],be.prototype,"dynamic");var Yl=Object.defineProperty,Ne=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Yl(e,t,i),i};class jt extends Ee{constructor(t){super();d(this,"stride");d(this,"offset");d(this,"divisor");d(this,"needsUpload",!1);this.setProperties({buffer:new be,...t})}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"buffer":case"size":case"normalized":case"type":case"stride":case"offset":case"divisor":this.needsUpload=!0;break}}upload(){const t=this.needsUpload;return t&&(this.needsUpload=!1),t}}Ne([nt()],jt.prototype,"buffer"),Ne([nt({default:0})],jt.prototype,"size"),Ne([nt({default:!1})],jt.prototype,"normalized"),Ne([nt({default:"float"})],jt.prototype,"type"),Ne([nt()],jt.prototype,"stride"),Ne([nt()],jt.prototype,"offset"),Ne([nt()],jt.prototype,"divisor");class Wl extends hi{constructor(){super({vertexAttributes:{position:new jt({buffer:new be({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const Ki=class Ki extends Ee{constructor(t={}){super();d(this,"vert");d(this,"frag");d(this,"uniforms");this.vert=t.vert??`precision highp float;
|
|
1
|
+
(function(g,Ee){typeof exports=="object"&&typeof module<"u"?Ee(exports):typeof define=="function"&&define.amd?define(["exports"],Ee):(g=typeof globalThis<"u"?globalThis:g||self,Ee(g.modernCanvas={}))})(this,function(g){"use strict";var ep=Object.defineProperty;var tp=(g,Ee,le)=>Ee in g?ep(g,Ee,{enumerable:!0,configurable:!0,writable:!0,value:le}):g[Ee]=le;var u=(g,Ee,le)=>tp(g,typeof Ee!="symbol"?Ee+"":Ee,le);var Yt,It;const Ee=Math.PI,le=Ee*2;let ll=0;function hn(n){var r;return((r=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:r.id)??++ll}function zi(n){return!(n&n-1)&&!!n}const hl=/([\w-]+)\((.+?)\)/g,cl=/[^,]+/g,ul=/([-e.\d]+)(.*)/;function Vi(n){return Array.isArray(n)?n.map(r=>({name:r.name,args:r.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...n,normalizedIntValue:n.normalizedDefaultIntValue}}function pr(n,r,e={}){const t=gr(r,e);return t.length?t:cn(n,r,e)}function gr(n,r={}){const e=[];let t;for(;(t=hl.exec(n))!==null;){const[,i,s]=t;i&&e.push({name:i,args:fl(i,s,r)})}return e}function fl(n,r,e={}){const t=[];let i,s=0;for(;(i=cl.exec(r))!==null;)t.push(cn(n,i[0],{...e,index:s++}));return t}function cn(n,r,e={}){const{width:t=1,height:i=1,index:s=0}=e,o=r.match(ul),a={unit:(o==null?void 0:o[2])??null,value:r,intValue:Number(o==null?void 0:o[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(n){case"scale":case"scaleX":case"scaleY":case"scale3d":a.normalizedDefaultIntValue=1;break}switch(a.unit){case"%":a.normalizedIntValue=a.intValue/100;break;case"rad":a.normalizedIntValue=a.intValue/le;break;case"deg":a.normalizedIntValue=a.intValue/360;break;case"px":switch(s){case 0:a.normalizedIntValue=a.intValue/t;break;case 1:a.normalizedIntValue=a.intValue/i;break}break;case"turn":case"em":case"rem":default:a.normalizedIntValue=a.intValue;break}return a}const un="WebGL2RenderingContext"in globalThis,fn="ImageBitmap"in globalThis,dn="ResizeObserver"in globalThis,Kt="PointerEvent"in globalThis,pn="WheelEvent"in globalThis,dl="MouseEvent"in globalThis,ft="ontouchstart"in globalThis,gn="onclick"in globalThis,ji="createImageBitmap"in globalThis,Gi="AudioContext"in globalThis,qi="webkitAudioContext"in globalThis,Wi="OfflineAudioContext"in globalThis,mn="webkitOfflineAudioContext"in globalThis,yn=Gi||qi,mr=typeof window<"u",Xi=globalThis.devicePixelRatio||1,Hi=n=>n!==null&&typeof n=="object"&&n.nodeType===1,vn=n=>Hi(n)&&n.tagName==="VIDEO",pl=n=>Hi(n)&&n.tagName==="IMG";function _n(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function bn(n){return un&&n instanceof globalThis.WebGL2RenderingContext}function wn(){if(mr)return globalThis.document.createElement("canvas")}function xn(n,r=globalThis.location){if(n.startsWith("data:"))return"";r=r||globalThis.location;const e=new URL(n,document.baseURI);return e.hostname!==r.hostname||e.port!==r.port||e.protocol!==r.protocol?"anonymous":""}function Pn(n,r,e){e===null&&!r.startsWith("data:")?n.crossOrigin=xn(r):e!==!1&&(n.crossOrigin=typeof e=="string"?e:"anonymous")}let dt=class{constructor(){u(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(r){return this.eventListeners.has(r)}on(r,e,t){const i={value:e,options:t},s=this.eventListeners.get(r);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(r,[s,i]):this.eventListeners.set(r,i),this}once(r,e){return this.on(r,e,{once:!0})}off(r,e,t){var s,o;if(!e)return this.eventListeners.delete(r),this;const i=this.eventListeners.get(r);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(r,a.length===1?a[0]:a):this.eventListeners.delete(r)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(r);return this}emit(r,...e){var i,s;const t=this.eventListeners.get(r);if(t){if(Array.isArray(t))for(let o=t.length,a=0;a<o;a++){const l=t[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(r,l.value,l.options),l.value.apply(this,e)}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(r,t.value,t.options),t.value.apply(this,e);return!0}else return!1}};const Yr=new Map;function H(n){let r,e;return typeof n=="string"?r=n:{tag:r,renderable:e}=n,function(t){Object.defineProperty(t.prototype,"tag",{value:r,enumerable:!0,configurable:!0}),typeof e<"u"&&Object.defineProperty(t,"renderable",{value:e,enumerable:!1,configurable:!1}),Yr.set(r,t)}}const Cn=new WeakMap;function Zr(n){let r=Cn.get(n);if(!r){const e=Object.getPrototypeOf(n);r=new Map(e?Zr(e):void 0),Cn.set(n,r)}return r}function bt(n,r,e={}){Zr(n).set(r,e);const{default:t,alias:i}=e;let s=Object.getOwnPropertyDescriptor(n.prototype,r);if(!s){const o=i??Symbol.for(String(r));s={get(){return this[o]},set(a){this[o]=a}}}Object.defineProperty(n.prototype,r,{get(){var o;return((o=s.get)==null?void 0:o.call(this))??t},set(o){var l,h,c;const a=((l=s.get)==null?void 0:l.call(this))??t;(h=s.set)==null||h.call(this,o),(c=this.requestUpdate)==null||c.call(this,r,a,e)},configurable:!0,enumerable:!0})}function A(n){return function(r,e){bt(r.constructor,e,n)}}function ee(n){return A({...n,protected:!0})}function gl(n="node",r={}){const e=Yr.get(n);if(!e)throw new Error(`Failed to createNode, tag: ${n}`);return new e().setProperties(r)}class ue{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(r,e={}){const{sort:t=0,once:i=!1}=e;this._queue[t]||(this._queue[t]=[]),this._queue[t].push({cb:r,once:i})}static off(r,e={}){const{sort:t=0}=e,i=this._queue[t];if(!i)return;const s=[];for(let o=i.length,a=0;a<o;a++){const l=i[a];l.cb!==r&&s.push(l)}s.length?this._queue[t]=s:this._queue.splice(t,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(r=>this._update(r)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(r){this._elapsed=r-this._currentTime,this._currentTime=r,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const r=this._queue,e=[];for(let t=r.length,i=t;i>=0;i--){const s=r[i];if(!s)continue;const o=[];for(let a=s.length,l=0;l<a;l++){const h=s[l];try{h.cb()}catch(c){console.warn(c)}h.once||o.push(h)}o.length&&(e[i]=o)}this._queue=e}}u(ue,"_queue",[]),u(ue,"_currentTime",0),u(ue,"_elapsed",0),u(ue,"_requestId"),ue.start();async function Yi(n){return new Promise(r=>{ue.on(()=>{n==null||n(),r()},{sort:1,once:!0})})}let ml=0;class Kr extends dt{constructor(){super(...arguments);u(this,"instanceId",++ml);u(this,"_defaultProperties");u(this,"_updatedProperties",new Map);u(this,"_changedProperties",new Set);u(this,"_updatePending",Promise.resolve());u(this,"_isUpdatePending",!1)}async _enqueueUpdate(){this._isUpdatePending=!0;try{await this._updatePending}catch(e){Promise.reject(e)}await Yi(),this._performUpdate()}_performUpdate(){this._isUpdatePending&&(this._onUpdate(this._updatedProperties),this._updatedProperties=new Map,this._isUpdatePending=!1)}_onUpdate(e){}_onUpdateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return Zr(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}getDefaultProperties(){if(!this._defaultProperties){this._defaultProperties={};for(const[e,t]of this.getPropertyDeclarations())!t.protected&&!t.alias&&(this._defaultProperties[e]=t.default)}return this._defaultProperties}getProperty(e){return this[e]}setProperty(e,t){return this[e]=t,this}getProperties(e){const t={};for(const[i,s]of this.getPropertyDeclarations())!s.protected&&!s.alias&&(!e||e.includes(i))&&(t[i]=this.getProperty(i));return t}setProperties(e){if(e)for(const[t]of this.getPropertyDeclarations())t in e&&this.setProperty(t,e[t]);return this}requestUpdate(e,t,i){if(e!==void 0){const s=this[e];if(!Object.is(s,t))this._updatedProperties.set(e,t),this._changedProperties.add(e),i??(i=this.getPropertyDeclaration(e)),this._onUpdateProperty(e,s,t,i),this.emit("updateProperty",e,s,t,i);else return}this._isUpdatePending||(this._updatePending=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}destroy(){}}class Zi extends Kr{constructor(){super(...arguments);u(this,"_refCount",0)}}class wt extends Zi{}class Jr extends wt{constructor(e={}){super();u(this,"vertexAttributes");u(this,"indexBuffer");u(this,"instanceCount");u(this,"mode");u(this,"_materialWeakMap",new WeakMap);this.vertexAttributes=new Map(Object.entries((e==null?void 0:e.vertexAttributes)??{})),this.indexBuffer=e==null?void 0:e.indexBuffer,this.instanceCount=e==null?void 0:e.instanceCount,this.mode=(e==null?void 0:e.mode)??"triangles"}_glVertexArray(e){var t;return{attributes:Object.fromEntries(Array.from(this.vertexAttributes).map(([i,s])=>[i,{buffer:s.buffer._glBuffer(e),size:s.size,type:s.type,normalized:s.normalized,stride:s.stride,offset:s.offset,divisor:s.divisor}])),elementArrayBuffer:(t=this.indexBuffer)==null?void 0:t._glBuffer(e)}}_glVertexArrayObject(e,t){let i=this._materialWeakMap.get(t);return i||(i={material:t.instanceId,geometry:this.instanceId},this._materialWeakMap.set(t,i)),e.getRelated(i,()=>e.vertexArray.create(t._glProgram(e),this._glVertexArray(e)))}draw(e,t,i){var l;e.flush(),t.activate(e,i);const s=this._glVertexArrayObject(e,t);let o=!1,a;this.vertexAttributes.forEach(h=>{(a==null?void 0:a.instanceId)!==h.buffer.instanceId&&(a=h.buffer,a.upload(e)&&(o=!0)),h.upload()&&(o=!0)}),(l=this.indexBuffer)!=null&&l.upload(e)&&(o=!0),o&&s&&e.vertexArray.update(t._glProgram(e),s,this._glVertexArray(e)),e.vertexArray.bind(s??this._glVertexArray(e)),e.draw({mode:this.mode,instanceCount:this.instanceCount}),e.vertexArray.unbind()}}var yl=Object.defineProperty,En=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&yl(r,e,i),i};class Jt extends wt{constructor(e){super();u(this,"needsUpload",!1);this.setProperties(e)}_glBufferOptions(){return{target:"element_array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}En([ee({default:null})],Jt.prototype,"data"),En([ee({default:!1})],Jt.prototype,"dynamic");var vl=Object.defineProperty,Tn=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&vl(r,e,i),i};class pt extends wt{constructor(e){super();u(this,"needsUpload",!1);this.setProperties(e)}_glBufferOptions(){return{target:"array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}Tn([ee({default:null})],pt.prototype,"data"),Tn([ee({default:!1})],pt.prototype,"dynamic");var _l=Object.defineProperty,Rt=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&_l(r,e,i),i};class ze extends wt{constructor(e){super();u(this,"stride");u(this,"offset");u(this,"divisor");u(this,"needsUpload",!1);this.setProperties({buffer:new pt,...e})}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"buffer":case"size":case"normalized":case"type":case"stride":case"offset":case"divisor":this.needsUpload=!0;break}}upload(){const e=this.needsUpload;return e&&(this.needsUpload=!1),e}}Rt([ee()],ze.prototype,"buffer"),Rt([ee({default:0})],ze.prototype,"size"),Rt([ee({default:!1})],ze.prototype,"normalized"),Rt([ee({default:"float"})],ze.prototype,"type"),Rt([ee()],ze.prototype,"stride"),Rt([ee()],ze.prototype,"offset"),Rt([ee()],ze.prototype,"divisor");class bl extends Jr{constructor(){super({vertexAttributes:{position:new ze({buffer:new pt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new Jt({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const Bi=class Bi extends wt{constructor(e={}){super();u(this,"vert");u(this,"frag");u(this,"uniforms");this.vert=e.vert??`precision highp float;
|
|
2
2
|
attribute vec2 position;
|
|
3
3
|
uniform mat3 projectionMatrix;
|
|
4
4
|
uniform mat3 modelViewMatrix;
|
|
5
5
|
void main(void) {
|
|
6
6
|
gl_Position = vec4((projectionMatrix * modelViewMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
7
|
-
}`,this.frag=
|
|
7
|
+
}`,this.frag=e.frag??`uniform vec4 tint;
|
|
8
8
|
void main(void) {
|
|
9
9
|
gl_FragColor = tint;
|
|
10
|
-
}`,this.uniforms=new Map(Object.entries(
|
|
11
|
-
${i}`),
|
|
12
|
-
${
|
|
10
|
+
}`,this.uniforms=new Map(Object.entries(e.uniforms??{projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}))}_glProgram(e){return e.getRelated(this,()=>{let t=this.vert,i=this.frag;return i.includes("precision")||(i=`precision mediump float;
|
|
11
|
+
${i}`),t.includes("precision")||(t=`precision mediump float;
|
|
12
|
+
${t}`),e.program.create({vert:t,frag:i})})}activate(e,t){e.program.bind(this._glProgram(e)),(t||this.uniforms.size>0)&&e.program.updateUniforms({...Object.fromEntries(this.uniforms.entries()),...t})}};u(Bi,"instance",new Bi);let ne=Bi;class Qr extends ne{static get instance(){return this._instance??(this._instance=new this)}constructor(){super({vert:`precision highp float;
|
|
13
13
|
attribute vec2 position;
|
|
14
14
|
attribute vec2 uv;
|
|
15
15
|
uniform mat3 projectionMatrix;
|
|
@@ -23,32 +23,32 @@ uniform sampler2D sampler;
|
|
|
23
23
|
uniform vec4 tint;
|
|
24
24
|
void main(void) {
|
|
25
25
|
gl_FragColor = texture2D(sampler, vUv) * tint;
|
|
26
|
-
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}d(ci,"_instance");class et extends hi{static get instance(){return this._instance??(this._instance=new this)}static draw(e,t=ci.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new jt({buffer:new be({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new jt({buffer:new be({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}d(et,"_instance");class Hl extends hi{constructor(){const t=new be({data:new Float32Array,dynamic:!0}),r=new be({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new jt({buffer:t,size:2,normalized:!1,type:"float"}),uv:new jt({buffer:r,size:2,normalized:!1,type:"float"})},indexBuffer:new nr({data:new Uint16Array,dynamic:!0})});d(this,"positionBuffer");d(this,"uvBuffer");this.positionBuffer=t,this.uvBuffer=r}update(t,r,i){return this.positionBuffer.data=t,this.uvBuffer.data=r,this.indexBuffer.data=i,this}}var Zl=Object.defineProperty,Kn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Zl(e,t,i),i};class ui extends li{constructor(){super();d(this,"_starting",!1);d(this,"_nextDeltaTime",0);this._onNextTick=this._onNextTick.bind(this)}get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}start(t){return this._starting||(this._starting=!0,this.removeAllListeners(),this.on("process",t),ft.on(this._onNextTick,{sort:0})),this}stop(){return this._starting&&(this._starting=!1,ft.off(this._onNextTick,{sort:0})),this}_onNextTick(){const t=ft.elapsed*this.speed;if((this._nextDeltaTime-=t)<=0){const i=(this._nextDeltaTime=this.spf)||t;this.emit("process",i)}}}Kn([U({default:24})],ui.prototype,"fps"),Kn([U({default:1})],ui.prototype,"speed");const Kl=8,fi=11920929e-14,Ql=1;function ps(n,e,t,r,i,s,o,a,l,h=.5){const u=Math.min(.99,Math.max(0,h));let f=(Ql-u)/1;return f*=f,Jl(e,t,r,i,s,o,a,l,n,f),n}function Jl(n,e,t,r,i,s,o,a,l,h){gs(n,e,t,r,i,s,o,a,l,h,0),l.push(o,a)}function gs(n,e,t,r,i,s,o,a,l,h,c){if(c>Kl)return;const u=(n+t)/2,f=(e+r)/2,p=(t+i)/2,y=(r+s)/2,_=(i+o)/2,m=(s+a)/2,b=(u+p)/2,w=(f+y)/2,x=(p+_)/2,C=(y+m)/2,P=(b+x)/2,E=(w+C)/2;if(c>0){let A=o-n,S=a-e;const T=Math.abs((t-o)*S-(r-a)*A),O=Math.abs((i-o)*S-(s-a)*A);if(T>fi&&O>fi){if((T+O)*(T+O)<=h*(A*A+S*S)){l.push(P,E);return}}else if(T>fi){if(T*T<=h*(A*A+S*S)){l.push(P,E);return}}else if(O>fi){if(O*O<=h*(A*A+S*S)){l.push(P,E);return}}else if(A=P-(n+o)/2,S=E-(e+a)/2,A*A+S*S<=h){l.push(P,E);return}}gs(n,e,u,f,b,w,P,E,l,h,c+1),gs(P,E,x,C,_,m,o,a,l,h,c+1)}const th=8,eh=11920929e-14,rh=1;function Qn(n,e,t,r,i,s,o,a=.5){const h=Math.min(.99,Math.max(0,a));let c=(rh-h)/1;return c*=c,ih(e,t,r,i,s,o,n,c),n}function ih(n,e,t,r,i,s,o,a){ms(o,n,e,t,r,i,s,a,0),o.push(i,s)}function ms(n,e,t,r,i,s,o,a,l){if(l>th)return;const h=(e+r)/2,c=(t+i)/2,u=(r+s)/2,f=(i+o)/2,p=(h+u)/2,y=(c+f)/2;let _=s-e,m=o-t;const b=Math.abs((r-s)*m-(i-o)*_);if(b>eh){if(b*b<=a*(_*_+m*m)){n.push(p,y);return}}else if(_=p-(e+s)/2,m=y-(t+o)/2,_*_+m*m<=a){n.push(p,y);return}ms(n,e,t,h,c,p,y,a,l+1),ms(n,p,y,u,f,s,o,a,l+1)}function ys(n,e,t,r,i,s,o,a){let l=Math.abs(i-s);(!o&&i>s||o&&s>i)&&(l=2*Math.PI-l),a=a||Math.max(6,Math.floor(6*r**(1/3)*(l/Math.PI))),a=Math.max(a,3);let h=l/a,c=i;h*=o?-1:1;for(let u=0;u<a+1;u++){const f=Math.cos(c),p=Math.sin(c),y=e+f*r,_=t+p*r;n.push(y,_),c+=h}}function sh(n,e,t,r,i,s){const o=n[n.length-2],l=n[n.length-1]-t,h=o-e,c=i-t,u=r-e,f=Math.abs(l*u-h*c);if(f<1e-8||s===0){(n[n.length-2]!==e||n[n.length-1]!==t)&&n.push(e,t);return}const p=l*l+h*h,y=c*c+u*u,_=l*c+h*u,m=s*Math.sqrt(p)/f,b=s*Math.sqrt(y)/f,w=m*_/p,x=b*_/y,C=m*u+b*h,P=m*c+b*l,E=h*(b+w),A=l*(b+w),S=u*(m+x),T=c*(m+x),O=Math.atan2(A-P,E-C),$=Math.atan2(T-P,S-C);ys(n,C+e,P+t,s,O,$,h*c>u*l)}const Cr=Math.PI*2,_s={centerX:0,centerY:0,ang1:0,ang2:0};function vs({x:n,y:e},t,r,i,s,o,a,l){n*=t,e*=r;const h=i*n-s*e,c=s*n+i*e;return l.x=h+o,l.y=c+a,l}function nh(n,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),r=e===1.5707963267948966?.551915024494:t,i=Math.cos(n),s=Math.sin(n),o=Math.cos(n+e),a=Math.sin(n+e);return[{x:i-s*r,y:s+i*r},{x:o+a*r,y:a-o*r},{x:o,y:a}]}function Jn(n,e,t,r){const i=n*r-e*t<0?-1:1;let s=n*t+e*r;return s>1&&(s=1),s<-1&&(s=-1),i*Math.acos(s)}function oh(n,e,t,r,i,s,o,a,l,h,c,u,f){const p=i**2,y=s**2,_=c**2,m=u**2;let b=p*y-p*m-y*_;b<0&&(b=0),b/=p*m+y*_,b=Math.sqrt(b)*(o===a?-1:1);const w=b*i/s*u,x=b*-s/i*c,C=h*w-l*x+(n+t)/2,P=l*w+h*x+(e+r)/2,E=(c-w)/i,A=(u-x)/s,S=(-c-w)/i,T=(-u-x)/s,O=Jn(1,0,E,A);let $=Jn(E,A,S,T);a===0&&$>0&&($-=Cr),a===1&&$<0&&($+=Cr),f.centerX=C,f.centerY=P,f.ang1=O,f.ang2=$}function to(n,e,t,r,i,s,o,a=0,l=0,h=0){if(s===0||o===0)return;const c=Math.sin(a*Cr/360),u=Math.cos(a*Cr/360),f=u*(e-r)/2+c*(t-i)/2,p=-c*(e-r)/2+u*(t-i)/2;if(f===0&&p===0)return;s=Math.abs(s),o=Math.abs(o);const y=f**2/s**2+p**2/o**2;y>1&&(s*=Math.sqrt(y),o*=Math.sqrt(y)),oh(e,t,r,i,s,o,l,h,c,u,f,p,_s);let{ang1:_,ang2:m}=_s;const{centerX:b,centerY:w}=_s;let x=Math.abs(m)/(Cr/4);Math.abs(1-x)<1e-7&&(x=1);const C=Math.max(Math.ceil(x),1);m/=C;let P=n[n.length-2],E=n[n.length-1];const A={x:0,y:0};for(let S=0;S<C;S++){const T=nh(_,m),{x:O,y:$}=vs(T[0],s,o,u,c,b,w,A),{x:N,y:B}=vs(T[1],s,o,u,c,b,w,A),{x:M,y:L}=vs(T[2],s,o,u,c,b,w,A);ps(n,P,E,O,$,N,B,M,L),P=M,E=L,_+=m}}class di{constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.radius=r}contains(e,t){if(this.radius<=0)return!1;const r=this.radius*this.radius;let i=this.x-e,s=this.y-t;return i*=i,s*=s,i+s<=r}strokeContains(e,t,r){if(this.radius===0)return!1;const i=this.x-e,s=this.y-t,o=this.radius,a=r/2,l=Math.sqrt(i*i+s*s);return l<o+a&&l>o-a}clone(){return new di(this.x,this.y,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){return e=e||new Gt,e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}class Tr{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.halfWidth=r,this.halfHeight=i}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let r=(e-this.x)/this.halfWidth,i=(t-this.y)/this.halfHeight;return r*=r,i*=i,r+i<=1}strokeContains(e,t,r){const{halfWidth:i,halfHeight:s}=this;if(i<=0||s<=0)return!1;const o=r/2,a=i-o,l=s-o,h=i+o,c=s+o,u=e-this.x,f=t-this.y,p=u*u/(a*a)+f*f/(l*l),y=u*u/(h*h)+f*f/(c*c);return p>1&&y<=1}clone(){return new Tr(this.x,this.y,this.halfWidth,this.halfHeight)}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}getBounds(){return new Gt(this.x-this.halfWidth,this.y-this.halfHeight,this.halfWidth*2,this.halfHeight*2)}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}function Er(n,e,t,r,i,s){const o=n-t,a=e-r,l=i-t,h=s-r,c=o*l+a*h,u=l*l+h*h;let f=-1;u!==0&&(f=c/u);let p,y;f<0?(p=t,y=r):f>1?(p=i,y=s):(p=t+f*l,y=r+f*h);const _=n-p,m=e-y;return _*_+m*m}class bs{constructor(e=0,t=0,r=0,i=0,s=0,o=0){this.x=e,this.y=t,this.x2=r,this.y2=i,this.x3=s,this.y3=o}contains(e,t){const r=(this.x-this.x3)*(t-this.y3)-(this.y-this.y3)*(e-this.x3),i=(this.x2-this.x)*(t-this.y)-(this.y2-this.y)*(e-this.x);if(r<0!=i<0&&r!==0&&i!==0)return!1;const s=(this.x3-this.x2)*(t-this.y2)-(this.y3-this.y2)*(e-this.x2);return s===0||s<0==r+i<=0}strokeContains(e,t,r){const i=r/2,s=i*i,{x:o,x2:a,x3:l,y:h,y2:c,y3:u}=this;return Er(e,t,o,h,a,u)<=s||Er(e,t,a,c,l,u)<=s||Er(e,t,l,u,o,h)<=s}clone(){return new bs(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(e){return this.x=e.x,this.y=e.y,this.x2=e.x2,this.y2=e.y2,this.x3=e.x3,this.y3=e.y3,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){e=e||new Gt;const t=Math.min(this.x,this.x2,this.x3),r=Math.max(this.x,this.x2,this.x3),i=Math.min(this.y,this.y2,this.y3),s=Math.max(this.y,this.y2,this.y3);return e.x=t,e.y=i,e.width=r-t,e.height=s-i,e}buildOutline(e){Es.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Es.triangulate(r,e,2,0,t,0)}}class Fe{constructor(...e){d(this,"points");d(this,"closed");let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const r=[];for(let i=0,s=t.length;i<s;i++)r.push(t[i].x,t[i].y);t=r}this.points=t,this.closed=!0}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}reset(){return this.points.length=0,this}contains(e,t){let r=!1;const i=this.points.length/2;for(let s=0,o=i-1;s<i;o=s++){const a=this.points[s*2],l=this.points[s*2+1],h=this.points[o*2],c=this.points[o*2+1];l>t!=c>t&&e<(h-a)*((t-l)/(c-l))+a&&(r=!r)}return r}strokeContains(e,t,r){const i=r/2,s=i*i,{points:o}=this,a=o.length-(this.closed?0:2);for(let l=0;l<a;l+=2){const h=o[l],c=o[l+1],u=o[(l+2)%o.length],f=o[(l+3)%o.length];if(Er(e,t,h,c,u,f)<=s)return!0}return!1}clone(){const e=this.points.slice(),t=new Fe(e);return t.closed=this.closed,t}copyFrom(e){return this.points=e.points.slice(),this.closed=e.closed,this}copyTo(e){return e.copyFrom(this),e}getBounds(e){e=e||new Gt;const t=this.points;let r=1/0,i=-1/0,s=1/0,o=-1/0;for(let a=0,l=t.length;a<l;a+=2){const h=t[a],c=t[a+1];r=h<r?h:r,i=h>i?h:i,s=c<s?c:s,o=c>o?c:o}return e.x=r,e.width=i-r,e.y=s,e.height=o-s,e}buildOutline(e){Cs.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Cs.triangulate(r,e,2,0,t,0)}}function pi(n,e,t,r,i,s){const o=n-t,a=e-r,l=Math.sqrt(o*o+a*a);return l>=i-s&&l<=i+s}class gi{constructor(e=0,t=0,r=0,i=0,s=r/4){this.x=e,this.y=t,this.width=r,this.height=i,this.radius=s}getBounds(e){return e=e||new Gt,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new gi(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const r=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+r&&t<=this.y+this.height-r||e>=this.x+r&&e<=this.x+this.width-r)return!0;let i=e-(this.x+r),s=t-(this.y+r);const o=r*r;if(i*i+s*s<=o||(i=e-(this.x+this.width-r),i*i+s*s<=o)||(s=t-(this.y+this.height-r),i*i+s*s<=o)||(i=e-(this.x+r),i*i+s*s<=o))return!0}return!1}strokeContains(e,t,r){const{x:i,y:s,width:o,height:a,radius:l}=this,h=r/2,c=i+l,u=s+l,f=o-l*2,p=a-l*2,y=i+o,_=s+a;return(e>=i-h&&e<=i+h||e>=y-h&&e<=y+h)&&t>=u&&t<=u+p||(t>=s-h&&t<=s+h||t>=_-h&&t<=_+h)&&e>=c&&e<=c+f?!0:e<c&&t<u&&pi(e,t,c,u,l,h)||e>y-l&&t<u&&pi(e,t,y-l,u,l,h)||e>y-l&&t>_-l&&pi(e,t,y-l,_-l,l,h)||e<c&&t>_-l&&pi(e,t,c,_-l,l,h)}buildOutline(e){$e.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),$e.triangulate(r,e,2,0,t,0)}}class ah extends Fe{constructor(e=0,t=0,r=5,i=1,s,o=0){s=s||i/2;const a=-1*Math.PI/2+o,l=r*2,h=at/l,c=[];for(let u=0;u<l;u++){const f=u%2?s:i,p=u*h+a;c.push(e+f*Math.cos(p),t+f*Math.sin(p))}super(c)}}const $e={build(n,e){let t,r,i,s,o,a;if(n instanceof di)t=n.x,r=n.y,o=a=n.radius,i=s=0;else if(n instanceof Tr)t=n.x,r=n.y,o=n.halfWidth,a=n.halfHeight,i=s=0;else{const C=n,P=C.width/2,E=C.height/2;t=C.x+P,r=C.y+E,o=a=Math.max(0,Math.min(C.radius,Math.min(P,E))),i=P-o,s=E-a}if(!(o>=0&&a>=0&&i>=0&&s>=0))return e;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(i?4:0)+(s?4:0);if(h===0)return e;if(l===0)return e[0]=e[6]=t+i,e[1]=e[3]=r+s,e[2]=e[4]=t-i,e[5]=e[7]=r-s,e;let c=0,u=l*4+(i?2:0)+2,f=u,p=h,y=i+o,_=s,m=t+y,b=t-y,w=r+_;if(e[c++]=m,e[c++]=w,e[--u]=w,e[--u]=b,s){const C=r-_;e[f++]=b,e[f++]=C,e[--p]=C,e[--p]=m}for(let C=1;C<l;C++){const P=Math.PI/2*(C/l),E=i+Math.cos(P)*o,A=s+Math.sin(P)*a,S=t+E,T=t-E,O=r+A,$=r-A;e[c++]=S,e[c++]=O,e[--u]=O,e[--u]=T,e[f++]=T,e[f++]=$,e[--p]=$,e[--p]=S}y=i,_=s+a,m=t+y,b=t-y,w=r+_;const x=r-_;return e[c++]=m,e[c++]=w,e[--p]=x,e[--p]=m,i&&(e[c++]=b,e[c++]=w,e[--p]=x,e[--p]=b),e},triangulate(n,e,t,r,i,s){if(n.length===0)return;let o=0,a=0;for(let c=0;c<n.length;c+=2)o+=n[c],a+=n[c+1];o/=n.length/2,a/=n.length/2;let l=r;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<n.length;c+=2)e[l*t]=n[c],e[l*t+1]=n[c+1],c>0&&(i[s++]=l,i[s++]=h,i[s++]=l-1),l++;i[s++]=h+1,i[s++]=h,i[s++]=l-1}},Qi=class Qi{constructor(e=0,t=0){this.x=e,this.y=t}static get shared(){const e=this._shared??new Qi;return e.x=0,e.y=0,e}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}};d(Qi,"_shared");let re=Qi;function lh(n){const e=n.length;if(e<6)return 1;let t=0;for(let r=0,i=n[e-2],s=n[e-1];r<e;r+=2){const o=n[r],a=n[r+1];t+=(o-i)*(a+s),i=o,s=a}return t<0?-1:1}function hh(n,e,t=2){const r=e.length,i=r?e[0]*t:n.length;let s=eo(n,0,i,t,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(r&&(s=ph(n,e,s,t)),n.length>80*t){a=1/0,l=1/0;let c=-1/0,u=-1/0;for(let f=t;f<i;f+=t){const p=n[f],y=n[f+1];p<a&&(a=p),y<l&&(l=y),p>c&&(c=p),y>u&&(u=y)}h=Math.max(c-a,u-l),h=h!==0?32767/h:0}return Mr(s,o,t,a,l,h,0),o}function eo(n,e,t,r,i){let s;if(i===Th(n,e,t,r)>0)for(let o=e;o<t;o+=r)s=no(o/r|0,n[o],n[o+1],s);else for(let o=t-r;o>=e;o-=r)s=no(o/r|0,n[o],n[o+1],s);return s&&or(s,s.next)&&(Or(s),s=s.next),s}function ze(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(or(t,t.next)||ot(t.prev,t,t.next)===0)){if(Or(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function Mr(n,e,t,r,i,s,o){if(!n)return;!o&&s&&vh(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(s?uh(n,r,i,s):ch(n)){e.push(l.i,n.i,h.i),Or(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=fh(ze(n),e),Mr(n,e,t,r,i,s,2)):o===2&&dh(n,e,t,r,i,s):Mr(ze(n),e,t,r,i,s,1);break}}}function ch(n){const e=n.prev,t=n,r=n.next;if(ot(e,t,r)>=0)return!1;const i=e.x,s=t.x,o=r.x,a=e.y,l=t.y,h=r.y,c=Math.min(i,s,o),u=Math.min(a,l,h),f=Math.max(i,s,o),p=Math.max(a,l,h);let y=r.next;for(;y!==e;){if(y.x>=c&&y.x<=f&&y.y>=u&&y.y<=p&&Sr(i,a,s,l,o,h,y.x,y.y)&&ot(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function uh(n,e,t,r){const i=n.prev,s=n,o=n.next;if(ot(i,s,o)>=0)return!1;const a=i.x,l=s.x,h=o.x,c=i.y,u=s.y,f=o.y,p=Math.min(a,l,h),y=Math.min(c,u,f),_=Math.max(a,l,h),m=Math.max(c,u,f),b=xs(p,y,e,t,r),w=xs(_,m,e,t,r);let x=n.prevZ,C=n.nextZ;for(;x&&x.z>=b&&C&&C.z<=w;){if(x.x>=p&&x.x<=_&&x.y>=y&&x.y<=m&&x!==i&&x!==o&&Sr(a,c,l,u,h,f,x.x,x.y)&&ot(x.prev,x,x.next)>=0||(x=x.prevZ,C.x>=p&&C.x<=_&&C.y>=y&&C.y<=m&&C!==i&&C!==o&&Sr(a,c,l,u,h,f,C.x,C.y)&&ot(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;x&&x.z>=b;){if(x.x>=p&&x.x<=_&&x.y>=y&&x.y<=m&&x!==i&&x!==o&&Sr(a,c,l,u,h,f,x.x,x.y)&&ot(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;C&&C.z<=w;){if(C.x>=p&&C.x<=_&&C.y>=y&&C.y<=m&&C!==i&&C!==o&&Sr(a,c,l,u,h,f,C.x,C.y)&&ot(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function fh(n,e){let t=n;do{const r=t.prev,i=t.next.next;!or(r,i)&&io(r,t,t.next,i)&&Ar(r,i)&&Ar(i,r)&&(e.push(r.i,t.i,i.i),Or(t),Or(t.next),t=n=i),t=t.next}while(t!==n);return ze(t)}function dh(n,e,t,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&wh(o,a)){let l=so(o,a);o=ze(o,o.next),l=ze(l,l.next),Mr(o,e,t,r,i,s,0),Mr(l,e,t,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function ph(n,e,t,r){const i=[];for(let s=0,o=e.length;s<o;s++){const a=e[s]*r,l=s<o-1?e[s+1]*r:n.length,h=eo(n,a,l,r,!1);h===h.next&&(h.steiner=!0),i.push(xh(h))}i.sort(gh);for(let s=0;s<i.length;s++)t=mh(i[s],t);return t}function gh(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function mh(n,e){const t=yh(n,e);if(!t)return e;const r=so(t,n);return ze(r,r.next),ze(t,t.next)}function yh(n,e){let t=e;const r=n.x,i=n.y;let s=-1/0,o;if(or(n,t))return t;do{if(or(n,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const u=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(u<=r&&u>s&&(s=u,o=t.x<t.next.x?t:t.next,u===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,h=o.y;let c=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&ro(i<h?r:s,i,l,h,i<h?s:r,i,t.x,t.y)){const u=Math.abs(i-t.y)/(r-t.x);Ar(t,n)&&(u<c||u===c&&(t.x>o.x||t.x===o.x&&_h(o,t)))&&(o=t,c=u)}t=t.next}while(t!==a);return o}function _h(n,e){return ot(n.prev,n,e.prev)<0&&ot(e.next,n,n.next)<0}function vh(n,e,t,r){let i=n;do i.z===0&&(i.z=xs(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,bh(i)}function bh(n){let e,t=1;do{let r=n,i;n=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let h=0;h<t&&(a++,o=o.nextZ,!!o);h++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,t*=2}while(e>1);return n}function xs(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function xh(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function ro(n,e,t,r,i,s,o,a){return(i-o)*(e-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(i-o)*(r-a)}function Sr(n,e,t,r,i,s,o,a){return!(n===o&&e===a)&&ro(n,e,t,r,i,s,o,a)}function wh(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Ph(n,e)&&(Ar(n,e)&&Ar(e,n)&&Ch(n,e)&&(ot(n.prev,n,e.prev)||ot(n,e.prev,e))||or(n,e)&&ot(n.prev,n,n.next)>0&&ot(e.prev,e,e.next)>0)}function ot(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function or(n,e){return n.x===e.x&&n.y===e.y}function io(n,e,t,r){const i=yi(ot(n,e,t)),s=yi(ot(n,e,r)),o=yi(ot(t,r,n)),a=yi(ot(t,r,e));return!!(i!==s&&o!==a||i===0&&mi(n,t,e)||s===0&&mi(n,r,e)||o===0&&mi(t,n,r)||a===0&&mi(t,e,r))}function mi(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function yi(n){return n>0?1:n<0?-1:0}function Ph(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&io(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ar(n,e){return ot(n.prev,n,n.next)<0?ot(n,e,n.next)>=0&&ot(n,n.prev,e)>=0:ot(n,e,n.prev)<0||ot(n,n.next,e)<0}function Ch(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function so(n,e){const t=ws(n.i,n.x,n.y),r=ws(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function no(n,e,t,r){const i=ws(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Or(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function ws(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Th(n,e,t,r){let i=0;for(let s=e,o=t-r;s<t;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}function Eh(n,e,t,r,i,s,o){const a=hh(n,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)s[o++]=a[h]+i,s[o++]=a[h+1]+i,s[o++]=a[h+2]+i;let l=i*r;for(let h=0;h<n.length;h+=2)t[l]=n[h],t[l+1]=n[h+1],l+=r}const oo=1e-4,Ps=1e-4;function ao(n,e,t,r,i,s,o,a){const l=n-t*i,h=e-r*i,c=n+t*s,u=e+r*s;let f,p;o?(f=r,p=-t):(f=-r,p=t);const y=l+f,_=h+p,m=c+f,b=u+p;return a.push(y,_),a.push(m,b),2}function Ve(n,e,t,r,i,s,o,a){const l=t-n,h=r-e;let c=Math.atan2(l,h),u=Math.atan2(i-n,s-e);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let f=c;const p=u-c,y=Math.abs(p),_=Math.sqrt(l*l+h*h),m=(15*y*Math.sqrt(_)/Math.PI>>0)+1,b=p/m;if(f+=b,a){o.push(n,e),o.push(t,r);for(let w=1,x=f;w<m;w++,x+=b)o.push(n,e),o.push(n+Math.sin(x)*_,e+Math.cos(x)*_);o.push(n,e),o.push(i,s)}else{o.push(t,r),o.push(n,e);for(let w=1,x=f;w<m;w++,x+=b)o.push(n+Math.sin(x)*_,e+Math.cos(x)*_),o.push(n,e);o.push(i,s),o.push(n,e)}return m*2}function lo(n,e,t,r,i,s,o,a,l){const h=oo;if(n.length===0)return;const c=e;let u=c.alignment;if(e.alignment!==.5){let z=lh(n);t&&(z*=-1),u=(u-.5)*z+.5}const f=new re(n[0],n[1]),p=new re(n[n.length-2],n[n.length-1]),y=r,_=Math.abs(f.x-p.x)<h&&Math.abs(f.y-p.y)<h;if(y){n=n.slice(),_&&(n.pop(),n.pop(),p.set(n[n.length-2],n[n.length-1]));const z=(f.x+p.x)*.5,Y=(p.y+f.y)*.5;n.unshift(z,Y),n.push(z,Y)}const m=i,b=n.length/2;let w=n.length;const x=m.length/2,C=c.width/2,P=C*C,E=c.miterLimit*c.miterLimit;let A=n[0],S=n[1],T=n[2],O=n[3],$=0,N=0,B=-(S-O),M=A-T,L=0,F=0,X=Math.sqrt(B*B+M*M);B/=X,M/=X,B*=C,M*=C;const q=u,I=(1-q)*2,R=q*2;y||(c.cap==="round"?w+=Ve(A-B*(I-R)*.5,S-M*(I-R)*.5,A-B*I,S-M*I,A+B*R,S+M*R,m,!0)+2:c.cap==="square"&&(w+=ao(A,S,B,M,I,R,!0,m))),m.push(A-B*I,S-M*I),m.push(A+B*R,S+M*R);for(let z=1;z<b-1;++z){A=n[(z-1)*2],S=n[(z-1)*2+1],T=n[z*2],O=n[z*2+1],$=n[(z+1)*2],N=n[(z+1)*2+1],B=-(S-O),M=A-T,X=Math.sqrt(B*B+M*M),B/=X,M/=X,B*=C,M*=C,L=-(O-N),F=T-$,X=Math.sqrt(L*L+F*F),L/=X,F/=X,L*=C,F*=C;const Y=T-A,H=S-O,j=T-$,Q=N-O,tt=Y*j+H*Q,st=H*j-Q*Y,Zt=st<0;if(Math.abs(st)<.001*Math.abs(tt)){m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),tt>=0&&(c.join==="round"?w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+4:w+=2,m.push(T-L*R,O-F*R),m.push(T+L*I,O+F*I));continue}const me=(-B+A)*(-M+O)-(-B+T)*(-M+S),Kt=(-L+$)*(-F+O)-(-L+T)*(-F+N),kt=(Y*Kt-j*me)/st,Xt=(Q*me-H*Kt)/st,ye=(kt-T)*(kt-T)+(Xt-O)*(Xt-O),oe=T+(kt-T)*I,ae=O+(Xt-O)*I,wt=T-(kt-T)*R,ir=O-(Xt-O)*R,Lp=Math.min(Y*Y+H*H,j*j+Q*Q),Ul=Zt?I:R,kp=Lp+Ul*Ul*P;ye<=kp?c.join==="bevel"||ye/P>E?(Zt?(m.push(oe,ae),m.push(T+B*R,O+M*R),m.push(oe,ae),m.push(T+L*R,O+F*R)):(m.push(T-B*I,O-M*I),m.push(wt,ir),m.push(T-L*I,O-F*I),m.push(wt,ir)),w+=2):c.join==="round"?Zt?(m.push(oe,ae),m.push(T+B*R,O+M*R),w+=Ve(T,O,T+B*R,O+M*R,T+L*R,O+F*R,m,!0)+4,m.push(oe,ae),m.push(T+L*R,O+F*R)):(m.push(T-B*I,O-M*I),m.push(wt,ir),w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+4,m.push(T-L*I,O-F*I),m.push(wt,ir)):(m.push(oe,ae),m.push(wt,ir)):(m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),c.join==="round"?Zt?w+=Ve(T,O,T+B*R,O+M*R,T+L*R,O+F*R,m,!0)+2:w+=Ve(T,O,T-B*I,O-M*I,T-L*I,O-F*I,m,!1)+2:c.join==="miter"&&ye/P<=E&&(Zt?(m.push(wt,ir),m.push(wt,ir)):(m.push(oe,ae),m.push(oe,ae)),w+=2),m.push(T-L*I,O-F*I),m.push(T+L*R,O+F*R),w+=2)}A=n[(b-2)*2],S=n[(b-2)*2+1],T=n[(b-1)*2],O=n[(b-1)*2+1],B=-(S-O),M=A-T,X=Math.sqrt(B*B+M*M),B/=X,M/=X,B*=C,M*=C,m.push(T-B*I,O-M*I),m.push(T+B*R,O+M*R),y||(c.cap==="round"?w+=Ve(T-B*(I-R)*.5,O-M*(I-R)*.5,T-B*I,O-M*I,T+B*R,O+M*R,m,!1)+2:c.cap==="square"&&(w+=ao(T,O,B,M,I,R,!1,m)));const k=Ps*Ps;for(let z=x;z<w+x-2;++z)A=m[z*2],S=m[z*2+1],T=m[(z+1)*2],O=m[(z+1)*2+1],$=m[(z+2)*2],N=m[(z+2)*2+1],!(Math.abs(A*(O-N)+T*(N-S)+$*(S-O))<k)&&a.push(z,z+1,z+2)}const Mh=[],Cs={build(n,e){for(let t=0;t<n.points.length;t++)e[t]=n.points[t];return e},triangulate(n,e,t,r,i,s){Eh(n,Mh,e,t,r,i,s)}},Ts={build(n,e){const t=n,r=t.x,i=t.y,s=t.width,o=t.height;return s>=0&&o>=0&&(e[0]=r,e[1]=i,e[2]=r+s,e[3]=i,e[4]=r+s,e[5]=i+o,e[6]=r,e[7]=i+o),e},triangulate(n,e,t,r,i,s){let o=0;r*=t,e[r+o]=n[0],e[r+o+1]=n[1],o+=t,e[r+o]=n[2],e[r+o+1]=n[3],o+=t,e[r+o]=n[6],e[r+o+1]=n[7],o+=t,e[r+o]=n[4],e[r+o+1]=n[5],o+=t;const a=r/t;i[s++]=a,i[s++]=a+1,i[s++]=a+2,i[s++]=a+1,i[s++]=a+3,i[s++]=a+2}},Es={build(n,e){return e[0]=n.x,e[1]=n.y,e[2]=n.x2,e[3]=n.y2,e[4]=n.x3,e[5]=n.y3,e},triangulate(n,e,t,r,i,s){let o=0;r*=t,e[r+o]=n[0],e[r+o+1]=n[1],o+=t,e[r+o]=n[2],e[r+o+1]=n[3],o+=t,e[r+o]=n[4],e[r+o+1]=n[5];const a=r/t;i[s++]=a,i[s++]=a+1,i[s++]=a+2}},_i=[new re,new re,new re,new re];class Gt{constructor(e=0,t=0,r=0,i=0){this.x=e,this.y=t,this.width=r,this.height=i}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,r){const{width:i,height:s}=this;if(i<=0||s<=0)return!1;const o=this.x,a=this.y,l=o-r/2,h=o+i+r/2,c=a-r/2,u=a+s+r/2,f=o+r/2,p=o+i-r/2,y=a+r/2,_=a+s-r/2;return e>=l&&e<=h&&t>=c&&t<=u&&!(e>f&&e<p&&t>y&&t<_)}clone(){return new Gt(this.x,this.y,this.width,this.height)}copyFrom(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}copyTo(e){e.copyFrom(this)}intersects(e,t){if(!t){const N=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=N)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const r=this.left,i=this.right,s=this.top,o=this.bottom;if(i<=r||o<=s)return!1;const a=_i[0].set(e.left,e.top),l=_i[1].set(e.left,e.bottom),h=_i[2].set(e.right,e.top),c=_i[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const{a:u,d:f,b:p,c:y}=t.toObject(),_=Math.sign(u*f-p*y);if(_===0||([a.x,a.y]=t.applyToPoint(a.x,a.y),[l.x,l.y]=t.applyToPoint(l.x,l.y),[h.x,h.y]=t.applyToPoint(h.x,h.y),[c.x,c.y]=t.applyToPoint(c.x,a.y),Math.max(a.x,l.x,h.x,c.x)<=r||Math.min(a.x,l.x,h.x,c.x)>=i||Math.max(a.y,l.y,h.y,c.y)<=s||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const m=_*(l.y-a.y),b=_*(a.x-l.x),w=m*r+b*s,x=m*i+b*s,C=m*r+b*o,P=m*i+b*o;if(Math.max(w,x,C,P)<=m*a.x+b*a.y||Math.min(w,x,C,P)>=m*c.x+b*c.y)return!1;const E=_*(a.y-h.y),A=_*(h.x-a.x),S=E*r+A*s,T=E*i+A*s,O=E*r+A*o,$=E*i+A*o;return!(Math.max(S,T,O,$)<=E*a.x+A*a.y||Math.min(S,T,O,$)>=E*c.x+A*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),r=Math.min(this.x+this.width,e.x+e.width),i=Math.max(this.y,e.y),s=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(r-t,0),this.y=i,this.height=Math.max(s-i,0),this}ceil(e=1,t=.001){const r=Math.ceil((this.x+this.width-t)*e)/e,i=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=r-this.x,this.height=i-this.y,this}enlarge(e){const t=Math.min(this.x,e.x),r=Math.max(this.x+this.width,e.x+e.width),i=Math.min(this.y,e.y),s=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=r-t,this.y=i,this.height=s-i,this}getBounds(e){return e=e||new Gt,e.copyFrom(this),e}buildOutline(e){Ts.build(this,e)}buildGeometry(e,t){const r=[];this.buildOutline(r),Ts.triangulate(r,e,2,0,t,0)}}class ie extends ve{constructor(t){super();d(this,"_array",[]);this.dim=t}get length(){return this.dim}_operate(t,r,i){const{dim:s,_array:o}=this;let a;typeof r=="number"?a=Array.from({length:s},()=>r):r instanceof le||r instanceof ie?a=r.toArray():a=r;let l,h=[];if(i?i instanceof ie?l=i:h=i:l=this,r instanceof le){const{cols:c}=r;switch(t){case"*":for(let u=0;u<s;u++){let f=0;for(let p=0;p<s;p++)f+=o[u]*a[p*c+u];h[u]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${t} ${r.toName()}'`)}}else switch(t){case"+":for(let c=0;c<s;c++)h[c]=o[c]+a[c];break;case"-":for(let c=0;c<s;c++)h[c]=o[c]-a[c];break;case"*":for(let c=0;c<s;c++)h[c]=o[c]*a[c];break;case"/":for(let c=0;c<s;c++)h[c]=o[c]/a[c];break;case"rot":{const c=Math.cos(a[0]),u=Math.sin(a[0]);h[0]=o[0]*c-o[1]*u,h[1]=o[1]*c+o[0]*u;break}case"==":{let c=!0;for(let u=0;u<s;u++)c=c&&o[u]===a[u];return c}case"=":for(let c=0;c<s;c++){const u=a[c];u!==void 0&&(o[c]=u)}return this._emitUpdate(o),this;default:throw new Error(`Not support operator in '${this.toName()} ${t} Vector'`)}return(l==null?void 0:l.set(h))??h}add(t,r){return this._operate("+",t,r)}sub(t,r){return this._operate("-",t,r)}multiply(t,r){return this._operate("*",t,r)}divide(t,r){return this._operate("/",t,r)}rotate(t){return this._operate("rot",t)}set(t,...r){return r.length&&typeof t=="number"&&(t=[t,...r]),this._operate("=",t)}equals(t){return this._operate("==",t)}clone(){const t=new this.constructor;return t.set(this.toArray()),t}onUpdate(t){return this.on("update",t),this}offUpdate(t){return this.off("update",t),this}_emitUpdate(t){this._onUpdate(t),this.emit("update",t)}_onUpdate(t){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class le extends ve{constructor(t,r,i){super();d(this,"_array",[]);this.rows=t,this.cols=r,i?this.set(i):this.identity()}get length(){return this.cols*this.rows}_operate(t,r,i){const{cols:s,rows:o,length:a,_array:l}=this;let h;typeof r=="number"?h=Array.from({length:a},()=>r):r instanceof ie||r instanceof le?h=r.toArray():h=r;let c,u=[];if(i?i instanceof ie||i instanceof le?c=i:u=i:r instanceof ie?c=new r.constructor:c=this,r instanceof ie){const{dim:f}=r;switch(t){case"*":for(let p=0;p<f;p++){let y=0;for(let _=0;_<s;_++)_<f&&(y+=l[p*s+_]*(h[_]??0));u[p]=y}break;default:throw new Error(`Not support operator in '${this.toName()} ${t} ${r.toName()}'`)}}else switch(t){case"*":for(let f=0;f<s;f++)for(let p=0;p<o;p++){const y=p*s;let _=0;for(let m=0;m<o;m++){const b=y+m,w=m*s+f;_+=l[b]*(h[w]??0)}u[y+f]=_}break;case"=":for(let f=0;f<a;f++){const p=h[f];p!==void 0&&(l[f]=p)}return this._emitUpdate(l),this;default:throw new Error(`Not support operator in '${this.toName()} ${t} Matrix2'`)}return(c==null?void 0:c.set(u))??u}identity(){const{cols:t,rows:r}=this,i=[];for(let s=0;s<t;s++)for(let o=0;o<r;o++){const a=o*t,l=s+a;i[l]=o+a===l?1:0}return this.set(i)}clone(){const t=new this.constructor;return t.set(this.toArray()),t}set(t){return this._operate("=",t)}multiply(t){return this._operate("*",t)}onUpdate(t){return this.on("update",t),this}offUpdate(t){return this.off("update",t),this}_emitUpdate(t){this._onUpdate(t),this.emit("update",t)}_onUpdate(t){}toArray(t=!1){const{cols:r,rows:i,_array:s}=this;if(t){const o=[];for(let a=0;a<i;a++)for(let l=0;l<r;l++)o[a+l*r]=s[l+a*r];return o}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}let Ms=class extends le{constructor(e){super(3,3,e)}invert(){const[e,t,r,i,s,o,a,l,h]=this._array,c=h*s-o*l,u=o*a-h*i,f=l*i-s*a,p=e*c+t*u+r*f;if(p===0)return this.set([0,0,0,0,0,0,0,0,0]);const y=1/p;return this.set([c*y,(r*l-h*t)*y,(o*t-r*s)*y,u*y,(h*e-r*a)*y,(r*i-o*e)*y,f*y,(t*a-l*e)*y,(s*e-t*i)*y])}};class qt extends Ms{constructor(t=!0){super();d(this,"_cx",1);d(this,"_sx",0);d(this,"_cy",0);d(this,"_sy",1);d(this,"_translateX",0);d(this,"_translateY",0);d(this,"_translateZ",1);d(this,"_scaleX",1);d(this,"_scaleY",1);d(this,"_skewX",0);d(this,"_skewY",0);d(this,"_rotate",0);d(this,"dirtyId",0);d(this,"_needsUpdateArray",!1);d(this,"_needsUpdateFields",!1);this.autoUpdate=t}_onUpdate(t){super._onUpdate(t),this._requestUpdateFields()}_updateSkew(){this._cx=Math.cos(this._rotate+this._skewY),this._sx=Math.sin(this._rotate+this._skewY),this._cy=-Math.sin(this._rotate-this._skewX),this._sy=Math.cos(this._rotate-this._skewX)}_requestUpdateArray(){this.autoUpdate?this._performUpdateArray():this._needsUpdateArray=!0}_requestUpdateFields(){this.autoUpdate?this._performUpdateFields():this._needsUpdateFields=!0}_performUpdateArray(){const t=this._cx*this._scaleX,r=this._sx*this._scaleX,i=this._cy*this._scaleY,s=this._sy*this._scaleY,o=this._translateX,a=this._translateY,l=this._translateZ,h=this._array;this._array=[t,i,o,r,s,a,h[6],h[7],l],this.dirtyId++}_performUpdateFields(){const{a:t,c:r,tx:i,b:s,d:o,ty:a,tz:l}=this.toObject(),h=-Math.atan2(-r,o),c=Math.atan2(s,t),u=Math.abs(h+c);u<1e-5||Math.abs(at-u)<1e-5?(this._rotate=c,this._skewX=this._skewY=0):(this._rotate=0,this._skewX=h,this._skewY=c),this._scaleX=Math.sqrt(t*t+s*s),this._scaleY=Math.sqrt(r*r+o*o),this._translateX=i,this._translateY=a,this._translateZ=l,this.dirtyId++}skew(t,r){return this._skewX=t,this._skewY=r,this._updateSkew(),this._requestUpdateArray(),this}skewX(t){return this.skew(t,this._skewY)}skewY(t){return this.skew(this._skewX,t)}translate(t,r,i=1){return this._translateX=t,this._translateY=r,this._translateZ=i,this._requestUpdateArray(),this}translateX(t){return this.translate(t,this._translateY)}translateY(t){return this.translate(this._translateX,t)}translateZ(t){return this.translate(this._translateX,this._translateY,t)}translate3d(t,r,i){return this.translate(t,r,i)}scale(t,r,i=1){return this._scaleX=t,this._scaleY=r,this._requestUpdateArray(),this}scaleX(t){return this.scale(t,this._scaleY)}scaleY(t){return this.scale(this._scaleX,t)}scale3d(t,r,i){return this.scale(t,r,i)}rotate(t){return this._rotate=t,this._updateSkew(),this._requestUpdateArray(),this}rotateX(t){return this.scaleY(this._rotateToScale(t))}rotateY(t){return this.scaleX(this._rotateToScale(t))}rotateZ(t){return this.rotate(t)}rotate3d(t,r,i,s){const[o,a,l]=this._rotate3d(t,r,i,s);return o&&this.rotateX(o),a&&this.rotateY(a),l&&this.rotateZ(l),this}_rotateToScale(t){const r=t/at;return r<=.5?r*-4+1:(r-1)*4+1}_rotate3d(t,r,i,s){if(t===1&&r===0&&i===0)return[s,0,0];if(t===0&&r===1&&i===0)return[0,s,0];if(t===0&&r===0)return[0,0,s];{const o=Math.cos(s),a=Math.sin(s),l=o+t*t*(1-o),h=t*r*(1-o)-i*a,c=t*i*(1-o)+r*a,u=o+r*r*(1-o),f=r*i*(1-o)-t*a,p=o+i*i*(1-o),y=-Math.atan2(-f,u),_=-Math.atan2(c,Math.sqrt(f*f+p*p)),m=-Math.atan2(-h,l);return[y,_,m]}}applyToPoint(t,r){const{a:i,c:s,tx:o,b:a,d:l,ty:h}=this.toObject();return[i*t+s*r+o,a*t+l*r+h]}inverse(){return this.clone().invert()}update(){let t=!1;return this._needsUpdateArray&&(this._needsUpdateArray=!1,this._performUpdateArray(),t=!0),this._needsUpdateFields&&(this._needsUpdateFields=!1,this._performUpdateFields(),t=!0),t}isIdentity(){const{a:t,b:r,c:i,d:s,tx:o,ty:a}=this.toObject();return t===1&&r===0&&i===0&&s===1&&o===0&&a===0}toObject(){const[t,r,i,s,o,a,,,l]=this._array;return{a:t,c:r,tx:i,b:s,d:o,ty:a,tz:l}}}const ho=new qt;class vi{constructor(e=1/0,t=1/0,r=-1/0,i=-1/0){d(this,"matrix",ho);d(this,"_rectangle");this.minX=e,this.minY=t,this.maxX=r,this.maxY=i}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Gt);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ho,this}set(e,t,r,i){return this.minX=e,this.minY=t,this.maxX=r,this.maxY=i,this}addFrame(e,t,r,i,s){s||(s=this.matrix);const{a:o,b:a,c:l,d:h,tx:c,ty:u}=s.toObject();let f=this.minX,p=this.minY,y=this.maxX,_=this.maxY,m=o*e+l*t+c,b=a*e+h*t+u;m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*r+l*t+c,b=a*r+h*t+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*e+l*i+c,b=a*e+h*i+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),m=o*r+l*i+c,b=a*r+h*i+u,m<f&&(f=m),b<p&&(p=b),m>y&&(y=m),b>_&&(_=b),this.minX=f,this.minY=p,this.maxX=y,this.maxY=_}addRect(e,t){return this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t),this}addBounds(e,t){return this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t),this}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,r=this.minY,i=this.maxX,s=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:u}=e.toObject();let f=o*t+l*r+c,p=a*t+h*r+u;this.minX=f,this.minY=p,this.maxX=f,this.maxY=p,f=o*i+l*r+c,p=a*i+h*r+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=o*t+l*s+c,p=a*t+h*s+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY,f=o*i+l*s+c,p=a*i+h*s+u,this.minX=f<this.minX?f:this.minX,this.minY=p<this.minY?p:this.minY,this.maxX=f>this.maxX?f:this.maxX,this.maxY=p>this.maxY?p:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,r,i){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<r&&(this.minY=r),this.maxY>i&&(this.maxY=i),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new vi(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}addVertexData(e,t,r,i){let s=this.minX,o=this.minY,a=this.maxX,l=this.maxY;i||(i=this.matrix);const{a:h,b:c,c:u,d:f,tx:p,ty:y}=i.toObject();for(let _=t;_<r;_+=2){const m=e[_],b=e[_+1],w=h*m+u*b+p,x=c*m+f*b+y;s=w<s?w:s,o=x<o?x:o,a=w>a?w:a,l=x>l?x:l}this.minX=s,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}}const Sh=/([astvzqmhlc])([^astvzqmhlc]*)/gi,Ah=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Ss={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0};class co{constructor(e){d(this,"defines",[]);d(this,"_calls",[]);d(this,"_dirty",!1);typeof e=="string"?this.defines=this._parseDefines(e):this.defines=e.defines.slice(),this.update()}get path2D(){const e=new As;return this._dirty&&(this._dirty=!1,this._calls.forEach(t=>{e[t.method](...t.args)})),e}_addCall(e,t=[],r=!0){return this._calls.push({method:e,args:t}),r&&(this._dirty=!0),this}_parseDefines(e){const t=[];return e.replace(Sh,(r,i,s)=>{var l;const o=((l=s.match(Ah))==null?void 0:l.map(Number))??[];let a=i.toLowerCase();for(a==="m"&&o.length>2&&(t.push({command:i,args:o.splice(0,2)}),a="l",i=i==="m"?"l":"L");;){if(o.length===Ss[a])return t.push({command:i,args:o}),"";if(o.length<Ss[a])throw new Error("malformed path defines");t.push({command:i,args:o.splice(0,Ss[a])})}}),t}update(){const e=[];let t=null,r=0,i=0;for(let s=0;s<this.defines.length;s++){const{command:o,args:a}=this.defines[s];switch(o){case"M":this._addCall("moveTo",[r=a[0],i=a[1]]);break;case"m":this._addCall("moveTo",[r+=a[0],i+=a[1]]);break;case"H":this._addCall("lineTo",[r=a[0],i]);break;case"h":this._addCall("lineTo",[r+=a[0],i]);break;case"V":this._addCall("lineTo",[r,i=a[0]]);break;case"v":this._addCall("lineTo",[r,i+=a[0]]);break;case"L":this._addCall("lineTo",[r=a[0],i=a[1]]);break;case"l":this._addCall("lineTo",[r+=a[0],i+=a[1]]);break;case"C":this._addCall("bezierCurveTo",[a[0],a[1],a[2],a[3],a[4],a[5]]),r=a[4],i=a[5];break;case"c":this._addCall("bezierCurveTo",[r+a[0],i+a[1],r+a[2],i+a[3],r+a[4],i+a[5]]),r+=a[4],i+=a[5];break;case"Q":this._addCall("quadraticCurveTo",[a[0],a[1],a[2],a[3]]),r=a[2],i=a[3];break;case"q":this._addCall("quadraticCurveTo",[r+a[0],i+a[1],r+a[2],i+a[3]]),r+=a[2],i+=a[3];break;case"S":this._smoothBezierCurveTo(a[0],a[1],a[2],a[3]),r=a[2],i=a[3];break;case"s":this._smoothBezierCurveTo(r+a[0],i+a[1],r+a[2],i+a[3]),r+=a[2],i+=a[3];break;case"T":this._smoothQuadraticCurveTo(r=a[0],i=a[1]);break;case"t":this._smoothQuadraticCurveTo(r+=a[0],i+=a[1]);break;case"A":this._addCall("ellipticalArc",[a[0],a[1],a[2],a[3],a[4],a[5],a[6]]),r=a[5],i=a[6];break;case"a":this._addCall("ellipticalArc",[a[0],a[1],a[2],a[3],a[4],a[5],a[6]]),r+=a[5],i+=a[6];break;case"Z":case"z":this._addCall("closePath"),e.length>0&&(t=e.pop(),t?(r=t.startX,i=t.startY):(r=0,i=0)),t=null;break;default:console.warn(`Unknown SVG path command: ${o}`)}o!=="Z"&&o!=="z"&&t===null&&(t={startX:r,startY:i},e.push(t))}}_getLastPoint(e){let t=this._calls.length-1,r=this._calls[t];if(!r)return e.x=0,e.y=0,e;for(;r.method==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;r=this._calls[t]}switch(r.method){case"moveTo":case"lineTo":e.set(r.args[0],r.args[1]);break;case"quadraticCurveTo":e.set(r.args[2],r.args[3]);break;case"bezierCurveTo":e.set(r.args[4],r.args[5]);break;case"arc":case"ellipticalArc":e.set(r.args[5],r.args[6]);break;case"addPath":r.args[0]._getLastPoint(e);break}return e}_smoothBezierCurveTo(e,t,r,i,s){const o=this._calls[this._calls.length-1],a=this._getLastPoint(re.shared);let l,h;if(!o||o.method!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.args[2],h=o.args[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this._addCall("bezierCurveTo",[l,h,e,t,r,i,s]),this}_smoothQuadraticCurveTo(e,t,r){const i=this._calls[this._calls.length-1],s=this._getLastPoint(re.shared);let o,a;if(!i||i.method!=="quadraticCurveTo")o=s.x,a=s.y;else{o=i.args[0],a=i.args[1];const l=s.x,h=s.y;o=l+(l-o),a=h+(h-a)}return this._addCall("quadraticCurveTo",[o,a,e,t,r]),this}}const Oh=new Gt;let As=class{constructor(){d(this,"_polygon");d(this,"_bounds",new vi);d(this,"shapes",[])}get bounds(){const e=this._bounds;e.clear();const t=this.shapes;for(let r=0;r<t.length;r++){const i=t[r],s=i.shape.getBounds(Oh);i.transform?e.addRect(s,i.transform):e.addRect(s)}return e}startPolygon(e,t){return this._polygon&&this.endPolygon(),this._polygon=new Fe([e,t]),this}endPolygon(e=!1){const t=this._polygon;return t&&t.points.length>2&&(t.closed=e,this.shapes.push({shape:t})),this._polygon=void 0,this}ensurePolygon(e=!0){var t;if(!this._polygon&&(this._polygon=new Fe,e)){const r=this.shapes[this.shapes.length-1];if(r){let i=r.shape.x,s=r.shape.y;if(!((t=r.transform)!=null&&t.isIdentity())){const o=r.transform.toObject(),a=i;i=o.a*i+o.c*s+o.tx,s=o.b*a+o.d*s+o.ty}this._polygon.points.push(i,s)}else this._polygon.points.push(0,0)}}beginPath(){return this}moveTo(e,t){return this.startPolygon(e,t),this}lineTo(e,t){this.ensurePolygon();const r=this._polygon.points,i=r[r.length-2],s=r[r.length-1];return(i!==e||s!==t)&&r.push(e,t),this}bezierCurveTo(e,t,r,i,s,o,a){return this.ensurePolygon(),ps(this._polygon.points,this._polygon.lastX,this._polygon.lastY,e,t,r,i,s,o,a),this}quadraticCurveTo(e,t,r,i,s){return this.ensurePolygon(),Qn(this._polygon.points,this._polygon.lastX,this._polygon.lastY,e,t,r,i,s),this}rect(e,t,r,i,s){this.addShape(new Gt(e,t,r,i),s)}roundRect(e,t,r,i,s,o){this.addShape(new gi(e,t,r,i,s),o)}ellipse(e,t,r,i,s){this.addShape(new Tr(e,t,r,i),s)}arc(e,t,r,i,s,o){this.ensurePolygon(!1);const a=this._polygon.points;return ys(a,e,t,r,i,s,o),this}ellipticalArc(e,t,r,i,s,o,a){return to(this._polygon.points,this._polygon.lastX,this._polygon.lastY,o,a,e,t,r,i,s),this}poly(e,t=!1,r){const i=new Fe(e);return i.closed=t,this.addShape(i,r),this}addShape(e,t){return this.endPolygon(),this.shapes.push({shape:e,transform:t}),this}addPath(e){return this.endPolygon(),e.endPolygon(),e.shapes.forEach(t=>{this.shapes.push(t)}),this}addSVGPath(e){return this.addPath(new co(e).path2D),this}closePath(){return this.endPolygon(!0),this}buildOutline(e=[]){return this.shapes.forEach(t=>t.shape.buildOutline(e)),e}buildGeometry(e=[],t=[]){return this.shapes.forEach(r=>r.shape.buildGeometry(e,t)),{vertices:e,indices:t}}};class Uh extends le{constructor(e){super(2,2,e)}}class uo extends le{constructor(e){super(4,4,e)}}class fo extends Ms{constructor(e=0,t=0,r=0,i=0,s=!1){super(),this._x=e,this._y=t,this._width=r,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(e){return this._flipY!==e&&(this._flipY=e,this._performUpdateArray()),this}translate(e,t){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._performUpdateArray()),this}resize(e,t){return(this._width!==e||this._height!==t)&&(this._width=e,this._height=t,this._performUpdateArray()),this}_performUpdateArray(){const e=this._width,t=this._height;if(!e||!t)return;const r=this._x,i=this._y,s=this._flipY?-1:1,o=1/e*2,a=s*(1/t*2),l=-1-r*o,h=-s-i*a;this.set([o,0,l,0,a,h,0,0,1])}}const po=Et/180,Ih=180/Et;function Me(n,e,t){return Math.max(n,Math.min(e,t))}function dt(n,e,t){return(1-t)*n+t*e}const Dh={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(n,e=20){if(!this.adaptive||!n||Number.isNaN(n))return e;let t=Math.ceil(n/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};let Rh=class is extends ie{get x(){return this._array[0]}set x(e){const[t,r]=this._array;t!==e&&this.set(e,r)}get y(){return this._array[1]}set y(e){const[t,r]=this._array;r!==e&&this.set(t,e)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}constructor(e=0,t){super(2),this.set(typeof e=="number"?[e,t??e]:e)}update(e,t){const[r,i]=this._array;return(r!==e||i!==t)&&this.set(e,t),this}getLength(){const[e,t]=this._array;return Math.sqrt(e*e+t*t)}getAngle(){const[e,t]=this._array;return Math.atan2(-e,-t)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){const[e,t]=this._array,r=1/(this.getLength()||1);return this.set(e*r,t*r),this}static lerp(e,t,r){return new is(t).clone().sub(new is(e)).multiply(r).add(new is(e))}};class Bh extends ie{constructor(){super(3)}}class go extends ie{constructor(e=0,t=0,r=0,i=0){super(4),this.set([e,t,r,i])}}var Lh=Object.defineProperty,kh=Object.getOwnPropertyDescriptor,ar=(n,e,t,r)=>{for(var i=r>1?void 0:r?kh(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Lh(e,t,i),i},Ur=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n))(Ur||{});g.Node=class extends ds{constructor(t){super();d(this,"renderable");d(this,"name",`${this.tag}:${String(this.instanceId)}`);d(this,"mask");d(this,"_computedVisibleDelay",0);d(this,"_computedVisibleDuration",Number.MAX_SAFE_INTEGER);d(this,"_computedVisibility","visible");d(this,"_internalMode",0);d(this,"_readyed",!1);d(this,"_tree");d(this,"_parent");d(this,"_children",[]);d(this,"_meta",new Map);this.setProperties(t).on("enterTree",this._onEnterTree.bind(this)).on("exitTree",this._onExitTree.bind(this)).on("parented",this._onParented.bind(this)).on("unparented",this._onUnparented.bind(this)).on("ready",this._onReady.bind(this)).on("process",this._onProcess.bind(this))}get children(){return this.getChildren()}get visibleTimeline(){const t=this._computedVisibleDelay;return[t,t+this._computedVisibleDuration]}get visibleRelativeTime(){var t;return(((t=this._tree)==null?void 0:t.timeline.current)??0)-this.visibleTimeline[0]}get visibleProgress(){const[t,r]=this.visibleTimeline;return Me(0,this.visibleRelativeTime/(r-t),1)}get siblingIndex(){return this.getIndex()}set siblingIndex(t){var r;(r=this._parent)==null||r.moveChild(this,t)}get previousSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[this.getIndex()-1]}get nextSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[this.getIndex()+1]}get firstSibling(){var t;return(t=this._parent)==null?void 0:t.getChildren()[0]}get lastSibling(){var r;const t=(r=this._parent)==null?void 0:r.getChildren();return t?t[t.length-1]:void 0}hasMeta(t){return this._meta.has(t)}getMeta(t,r){return this._meta.get(t)??r}setMeta(t,r){this._meta.set(t,r)}deleteMeta(t){this._meta.delete(t)}clearMeta(){this._meta.clear()}setName(t){return this.name=t,this}getTree(){return this._tree}getViewport(){var t;return(t=this._tree)==null?void 0:t.getCurrentViewport()}getWindow(){var t;return(t=this._tree)==null?void 0:t.root}isInsideTree(){return!!this._tree}_setTree(t){const r=this._tree;if(t!==r){t?(this._tree=t,this.emit("enterTree")):r&&(this.emit("exitTree"),this._tree=t);for(let i=this._children.length,s=0;s<i;s++){const o=this._children[s];!t&&this.emit("childExitingTree",o),o._setTree(t),t&&this.emit("childEnteredTree",o)}t&&(this.emit("postEnterTree"),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}isRenderable(){return this.renderable!==!1&&this.constructor.renderable&&this.isVisible()}isVisible(){return this._computedVisibility!=="hidden"}_updateVisibility(){var s;const t=this._parent;this._computedVisibleDelay=this.visibleDelay+((t==null?void 0:t._computedVisibleDelay)??0),t!=null&&t._computedVisibleDuration?this._computedVisibleDuration=Math.min(this._computedVisibleDelay+this.visibleDuration,t.visibleTimeline[1])-this._computedVisibleDelay:this._computedVisibleDuration=this.visibleDuration;let r=this.visibility??(t==null?void 0:t._computedVisibility)??"visible";const i=((s=this._tree)==null?void 0:s.timeline.current)??0;if(r!=="hidden"){const[o,a]=this.visibleTimeline;(i<o||i>a)&&(r="hidden")}this._computedVisibility=r}_onEnterTree(){this._enterTree(),this.emit("treeEntered")}_onExitTree(){this.emit("treeExiting"),this._exitTree(),this.emit("treeExited")}_onParented(){this._parented()}_onUnparented(){this._unparented()}_onReady(){this._ready()}_onProcess(t=0){this._updateVisibility();const r=this._tree;r==null||r.emit("nodeProcessing",this),this._process(t);const i=this.isRenderable();let s;if(r&&i){const o=r.renderStack.push(this);s=r.renderStack.currentCall,r.renderStack.currentCall=o}if(this.mask instanceof g.Node)this.getNode("__$mask")||(this.mask.renderable=!1,this.addChild(this.mask,1));else{const o=this.getNode("__$mask");o&&this.removeChild(o)}for(let o=this._children.length,a=0;a<o;a++)this._children[a].emit("process",t);r&&i&&(r.renderStack.currentCall=s),r==null||r.emit("nodeProcessed",this)}render(t,r){const i=this.mask;i&&(t.flush(),t.mask.push(this,i)),this._render(t),r==null||r(),i&&(t.flush(),t.mask.pop(this))}input(t){for(let r=this._children.length-1;r>=0;r--)this._children[r].input(t);this._input(t)}get parent(){return this._parent}hasParent(){return!!this._parent}getParent(){return this._parent}_setParent(t){var r;return(r=this._parent)!=null&&r.is(t)||(this._parent=t,this._setTree(t==null?void 0:t._tree),this.emit(t?"parented":"unparented")),this}getChildren(t=!1){switch(t){case!0:return this._children;case!1:return this._children.filter(r=>r._internalMode===0);default:return this._children.filter(r=>r._internalMode===t)}}getIndex(t=!1){var r;return((r=this._parent)==null?void 0:r.getChildren(t).indexOf(this))??0}getNode(t){return this._children.find(r=>r.name===t)}removeNode(t){var r;(r=this.getNode(t))==null||r.remove()}addSibling(t){return this.is(t)||!this.hasParent()||t.hasParent()?this:(t._internalMode=this._internalMode,this._parent.moveChild(t,this.getIndex(!0)+1),this)}addChild(t,r=t._internalMode){if(this.is(t)||t.hasParent())return this;switch(r){case 0:case 1:{const i=r===0?2:1,s=this._children.findIndex(o=>o._internalMode===i);s>-1?this._children.splice(s,0,t):this._children.push(t);break}case 2:this._children.push(t);break}return t._internalMode=r,t._setParent(this),this.emit("addChild",t),this}moveChild(t,r,i=t._internalMode){if(this.is(t)||t.hasParent()&&!this.is(t.parent))return this;t._internalMode=i;const s=this._children.indexOf(t);let o=this._children.findIndex(h=>{switch(i){case 0:return h._internalMode!==1;case 2:return h._internalMode===2;case 1:default:return!0}});o=o>-1?o:Math.max(0,this._children.length-1);let a=this._children.slice(o).findIndex(h=>{switch(i){case 1:return h._internalMode!==1;case 0:return h._internalMode===2;case 2:default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=Me(o,r>-1?r:a,a);return l!==s&&(s>-1&&this._children.splice(s,1),t._setParent(this),l>-1&&l<this._children.length?this._children.splice(l,0,t):this._children.push(t),s>-1?this.emit("moveChild",t,l,s):this.emit("addChild",t)),this}removeChild(t){const r=t.getIndex(!0);return this.is(t.parent)&&r>-1&&(this._children.splice(r,1),t._setParent(void 0),this.emit("removeChild",t,r)),this}removeChildren(){this.children.forEach(t=>this.removeChild(t))}remove(){var t;(t=this._parent)==null||t.removeChild(this)}forEach(t){return this.children.forEach(t),this}deepForEach(t){return this.children.forEach(r=>{t(r),r.deepForEach(t)}),this}is(t){return!!(t&&this.instanceId===t.instanceId)}_enterTree(){}_ready(){}_exitTree(){}_parented(){}_unparented(){}_process(t){}_input(t){}_render(t){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.children.map(t=>t.toJSON())}}static parse(t){if(Array.isArray(t))return t.map(l=>this.parse(l));const{tag:r,props:i,children:s}=t,o=oi.get(r)??g.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},ar([U()],g.Node.prototype,"name",2),ar([U()],g.Node.prototype,"mask",2),ar([U({default:"visible"})],g.Node.prototype,"visibility",2),ar([U({default:0})],g.Node.prototype,"visibleDelay",2),ar([U({default:Number.MAX_SAFE_INTEGER})],g.Node.prototype,"visibleDuration",2),g.Node=ar([Z("Node")],g.Node);class mo{constructor(){d(this,"currentCall");d(this,"calls",[])}createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){var r;const t=this.createCall(e);return(((r=this.currentCall)==null?void 0:r.calls)??this.calls).push(t),t}render(e){this.calls.forEach(function t(r){r.fn(e,()=>{r.calls.forEach(t)})}),this.calls=[]}}var Nh=Object.defineProperty,Fh=Object.getOwnPropertyDescriptor,Ir=(n,e,t,r)=>{for(var i=r>1?void 0:r?Fh(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Nh(e,t,i),i};g.Timer=class extends g.Node{static from(e){const[t,r]=e?Array.isArray(e)?e:[0,e]:[];return new g.Timer({start:t,end:r})}constructor(e){super(),this.setProperties(e)}_onUpdateProperty(e,t,r){switch(super._onUpdateProperty(e,t,r),e){case"start":this.start=Math.min(t,this.end);break;case"end":this.end=t||Number.MAX_SAFE_INTEGER;break}}addTime(e){const t=this.start,r=this.end;let i=this.current+e;return this.loop&&i>r&&(i=t+i%r),this.current=Me(t,i,r),this.emit("update",this.current,e),this}_process(e){super._process(e),this.addTime(e)}},Ir([U({default:0})],g.Timer.prototype,"start",2),Ir([U({default:0})],g.Timer.prototype,"current",2),Ir([U({default:Number.MAX_SAFE_INTEGER})],g.Timer.prototype,"end",2),Ir([U({default:!1})],g.Timer.prototype,"loop",2),g.Timer=Ir([Z("Timer")],g.Timer);var $h=Object.defineProperty,lr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&$h(e,t,i),i};class pt extends Ee{constructor(t){super();d(this,"_isPowerOfTwo",!1);d(this,"_needsUpload",!1);this.source=t,this._updateSize()}static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}_refreshPOT(){this._isPowerOfTwo=ss(this.realWidth)&&ss(this.realHeight)}_glTextureOptions(t,r){let i=this.source;"pixels"in i&&(i={pixels:i.pixels,width:this.realWidth,height:this.realHeight});let s=this.wrapMode;return t.version===1&&!this._isPowerOfTwo&&(s="clamp_to_edge"),{value:i,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:s,...r}}_glTexture(t,r){return t.getRelated(this,()=>t.texture.create(this._glTextureOptions(t,r)))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"width":case"height":case"filterMode":case"wrapMode":case"pixelRatio":case"source":this.requestUpload();break}}_updateSize(){const t=this.source;"pixels"in t?(this.width=Math.max(this.width,t.width),this.height=Math.max(this.height,t.height)):(this.width=Number(t.naturalWidth||t.videoWidth||t.width||0),this.height=Number(t.naturalHeight||t.videoHeight||t.height||0))}requestUpload(){this._needsUpload=!0,this._updateSize(),this._refreshPOT()}upload(t,r){return this._needsUpload?(this._needsUpload=!1,t.texture.update(this._glTexture(t,r),this._glTextureOptions(t,r)),!0):!1}activate(t,r=0){t.texture.bind({target:"texture_2d",value:this._glTexture(t,{location:r}),location:r}),this.upload(t,{location:r})}inactivate(t){t.texture.unbind(this._glTexture(t))}destroy(){Ln&&this.source instanceof ImageBitmap&&this.source.close()}}lr([nt()],pt.prototype,"source"),lr([nt({default:0})],pt.prototype,"width"),lr([nt({default:0})],pt.prototype,"height"),lr([nt({default:"linear"})],pt.prototype,"filterMode"),lr([nt({default:"clamp_to_edge"})],pt.prototype,"wrapMode"),lr([nt({default:1})],pt.prototype,"pixelRatio");function zh(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&os,crossorigin:(n==null?void 0:n.crossorigin)??null}}class Vh extends pt{constructor(t,r){const i=zh(r);super(t);d(this,"bitmap");d(this,"useBitmap");d(this,"preserveBitmap",!1);d(this,"_loadSource");d(this,"_loadBitmap");const s=t.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(t=>{this._loadSource=void 0;const r=this.source,i=()=>{r.onload=null,r.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>t(this)):t(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${r.src}`,a),this.emit("error",a),t(this)};r.complete&&r.src?s():(r.onload=s,r.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!os)return Promise.resolve(this);const t=this.source,r=!t.crossOrigin||t.crossOrigin==="anonymous";return this._loadBitmap=fetch(t.src,{mode:r?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,t.width,t.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(t){return{...super._glTextureOptions(t),value:this.bitmap??this.source}}upload(t){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(Pr&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const r=super.upload(t);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),r}}class Os extends pt{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}}var Xh=Object.defineProperty,yo=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Xh(e,t,i),i};function jh(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),autoPlay:!!((n==null?void 0:n.autoPlay)??!1),fps:Number((n==null?void 0:n.fps)??0),crossorigin:(n==null?void 0:n.crossorigin)??null,loop:!!((n==null?void 0:n.loop)??!1),muted:!!((n==null?void 0:n.muted)??!1),playsinline:!!((n==null?void 0:n.playsinline)??!0)}}const Us=(er=class extends pt{constructor(t,r){const i=jh(r);if(!Vn(t)){typeof t=="string"&&(t=[t]);const s=t[0].src||t[0],o=document.createElement("video");i.autoLoad&&o.setAttribute("preload","auto"),i.playsinline&&(o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline","")),i.muted&&(o.setAttribute("muted",""),o.muted=!0),i.loop&&o.setAttribute("loop",""),i.autoPlay&&o.setAttribute("autoplay",""),Yn(o,s,i.crossorigin);for(let a=0;a<t.length;++a){let{src:l,mime:h}=t[a];if(l=l||t[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const u=l.split("?").shift().toLowerCase(),f=u.slice(u.lastIndexOf(".")+1);h=h||er.mimeTypes.get(f)||`video/${f}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}t=o}super(t);d(this,"_spf",0);d(this,"_autoPlay",!1);d(this,"_sourceLoad");d(this,"_nextTime",0);d(this,"_connected",!1);d(this,"_requestId");d(this,"_resolve");d(this,"_reject");d(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});d(this,"_onPlayStop",()=>{this._setupAutoUpdate()});d(this,"_onCanPlay",()=>{const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const r=this.valid;this._nextTime=0,this.requestUpload(),this._nextTime=0,!r&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&t.play()});d(this,"_onError",t=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=void 0,this._resolve=void 0)});d(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});d(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});d(this,"requestUpload",()=>{const t=Math.floor(ft.elapsed*this.source.playbackRate);this._nextTime-=t,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(t){this.source.currentTime=t}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"fps":this._spf=r?Math.floor(1e3/r):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(ft.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(ft.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(ft.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const t=this.source;(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.isReady?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((r,i)=>{this.valid?(this._sourceLoad=void 0,r(this)):(this._resolve=r,this._reject=i,t.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();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())}},d(er,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),er);yo([nt({default:!0})],Us.prototype,"autoUpdate"),yo([nt({default:0})],Us.prototype,"fps");let _o=Us;class Is extends Os{}var Gh=Object.defineProperty,qh=Object.getOwnPropertyDescriptor,Dr=(n,e,t,r)=>{for(var i=r>1?void 0:r?qh(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Gh(e,t,i),i};g.Viewport=class extends g.Node{constructor(t=!1){super();d(this,"_projection",new fo);d(this,"_framebufferIndex",0);d(this,"_framebuffers",[{texture:new Is,needsUpload:!1},{texture:new Is,needsUpload:!1}]);this.flipY=t,this._projection.flipY(t)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(t){const{width:r,height:i}=this,{pixelRatio:s}=t;return this._framebuffers.forEach(o=>{const a=o.texture;a.pixelRatio=s,a.width=r,a.height=i,a.upload(t)}),{width:r,height:i,colorTextures:[this.texture._glTexture(t)]}}_glFramebuffer(t){return t.getRelated(this.framebuffer,()=>t.framebuffer.create(this._glFramebufferOptions(t)))}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y);break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height);break}}requestUpload(){this._framebuffers.forEach(t=>t.needsUpload=!0)}resize(t,r){this.width=t,this.height=r}upload(t){const r=this.framebuffer;return r.needsUpload?(r.needsUpload=!1,t.framebuffer.update(this._glFramebuffer(t),this._glFramebufferOptions(t)),!0):!1}activate(t){var r;t.flush(),(r=this._tree)==null||r.setCurrentViewport(this),t.framebuffer.bind(this._glFramebuffer(t)),this.upload(t)}redraw(t,r){t.flush();const i=this.framebuffer.texture;this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(t),t.clear(),i.activate(t,0),r()}activateWithCopy(t,r){this.resize(r.width,r.height),this.activate(t),t.clear(),r.texture.activate(t,0),et.draw(t,ci.instance,{sampler:0})}render(t,r){var s,o;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(t),t.clear(),super.render(t,r),t.flush(),i?i.activate(t):(t.framebuffer.bind(null),(o=this._tree)==null||o.setCurrentViewport(void 0))}toProjectionArray(t=!1){return this._projection.toArray(t)}},Dr([U({default:0})],g.Viewport.prototype,"x",2),Dr([U({default:0})],g.Viewport.prototype,"y",2),Dr([U({default:0})],g.Viewport.prototype,"width",2),Dr([U({default:0})],g.Viewport.prototype,"height",2),g.Viewport=Dr([Z({tag:"Viewport",renderable:!0})],g.Viewport);class vo extends ui{constructor(){super(...arguments);d(this,"renderStack",new mo);d(this,"root",new g.Viewport(!0)._setTree(this));d(this,"timeline",new g.Timer({loop:!0})._setTree(this));d(this,"_currentViewport")}getCurrentViewport(){return this._currentViewport}setCurrentViewport(t){this._currentViewport=t}_render(t,r=0){return this.timeline.addTime(r),this.emit("processing"),this.root.emit("process",r),this.emit("processed"),t.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(t),this._renderScreen(t),this}_renderScreen(t){t.state.reset();const r=t.pixelRatio,{width:i,height:s}=this.root;t.framebuffer.bind(null),t.viewport.bind({x:0,y:0,width:i*r,height:s*r}),t.clear();const o=this.root.texture;o.activate(t,0),et.draw(t),t.texture.unbind(o)}}var Yh={grad:.9,turn:360,rad:360/(2*Math.PI)},xe=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},yt=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*n)/t+0},Qt=function(n,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),n>t?t:n>e?n:e},bo=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},xo=function(n){return{r:Qt(n.r,0,255),g:Qt(n.g,0,255),b:Qt(n.b,0,255),a:Qt(n.a)}},Ds=function(n){return{r:yt(n.r),g:yt(n.g),b:yt(n.b),a:yt(n.a,3)}},Wh=/^#([0-9a-f]{3,8})$/i,bi=function(n){var e=n.toString(16);return e.length<2?"0"+e:e},wo=function(n){var e=n.r,t=n.g,r=n.b,i=n.a,s=Math.max(e,t,r),o=s-Math.min(e,t,r),a=o?s===e?(t-r)/o:s===t?2+(r-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:i}},Po=function(n){var e=n.h,t=n.s,r=n.v,i=n.a;e=e/360*6,t/=100,r/=100;var s=Math.floor(e),o=r*(1-t),a=r*(1-(e-s)*t),l=r*(1-(1-e+s)*t),h=s%6;return{r:255*[r,a,o,o,l,r][h],g:255*[l,r,r,a,o,o][h],b:255*[o,o,l,r,r,a][h],a:i}},Co=function(n){return{h:bo(n.h),s:Qt(n.s,0,100),l:Qt(n.l,0,100),a:Qt(n.a)}},To=function(n){return{h:yt(n.h),s:yt(n.s),l:yt(n.l),a:yt(n.a,3)}},Eo=function(n){return Po((t=(e=n).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},Rr=function(n){return{h:(e=wo(n)).h,s:(i=(200-(t=e.s))*(r=e.v)/100)>0&&i<200?t*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,r,i},Hh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qh=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Rs={string:[[function(n){var e=Wh.exec(n);return e?(n=e[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?yt(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?yt(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var e=Kh.exec(n)||Qh.exec(n);return e?e[2]!==e[4]||e[4]!==e[6]?null:xo({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(n){var e=Hh.exec(n)||Zh.exec(n);if(!e)return null;var t,r,i=Co({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(Yh[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Eo(i)},"hsl"]],object:[[function(n){var e=n.r,t=n.g,r=n.b,i=n.a,s=i===void 0?1:i;return xe(e)&&xe(t)&&xe(r)?xo({r:Number(e),g:Number(t),b:Number(r),a:Number(s)}):null},"rgb"],[function(n){var e=n.h,t=n.s,r=n.l,i=n.a,s=i===void 0?1:i;if(!xe(e)||!xe(t)||!xe(r))return null;var o=Co({h:Number(e),s:Number(t),l:Number(r),a:Number(s)});return Eo(o)},"hsl"],[function(n){var e=n.h,t=n.s,r=n.v,i=n.a,s=i===void 0?1:i;if(!xe(e)||!xe(t)||!xe(r))return null;var o=function(a){return{h:bo(a.h),s:Qt(a.s,0,100),v:Qt(a.v,0,100),a:Qt(a.a)}}({h:Number(e),s:Number(t),v:Number(r),a:Number(s)});return Po(o)},"hsv"]]},Mo=function(n,e){for(var t=0;t<e.length;t++){var r=e[t][0](n);if(r)return[r,e[t][1]]}return[null,void 0]},Jh=function(n){return typeof n=="string"?Mo(n.trim(),Rs.string):typeof n=="object"&&n!==null?Mo(n,Rs.object):[null,void 0]},Bs=function(n,e){var t=Rr(n);return{h:t.h,s:Qt(t.s+100*e,0,100),l:t.l,a:t.a}},Ls=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},So=function(n,e){var t=Rr(n);return{h:t.h,s:t.s,l:Qt(t.l+100*e,0,100),a:t.a}},ks=function(){function n(e){this.parsed=Jh(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return yt(Ls(this.rgba),2)},n.prototype.isDark=function(){return Ls(this.rgba)<.5},n.prototype.isLight=function(){return Ls(this.rgba)>=.5},n.prototype.toHex=function(){return e=Ds(this.rgba),t=e.r,r=e.g,i=e.b,o=(s=e.a)<1?bi(yt(255*s)):"","#"+bi(t)+bi(r)+bi(i)+o;var e,t,r,i,s,o},n.prototype.toRgb=function(){return Ds(this.rgba)},n.prototype.toRgbString=function(){return e=Ds(this.rgba),t=e.r,r=e.g,i=e.b,(s=e.a)<1?"rgba("+t+", "+r+", "+i+", "+s+")":"rgb("+t+", "+r+", "+i+")";var e,t,r,i,s},n.prototype.toHsl=function(){return To(Rr(this.rgba))},n.prototype.toHslString=function(){return e=To(Rr(this.rgba)),t=e.h,r=e.s,i=e.l,(s=e.a)<1?"hsla("+t+", "+r+"%, "+i+"%, "+s+")":"hsl("+t+", "+r+"%, "+i+"%)";var e,t,r,i,s},n.prototype.toHsv=function(){return e=wo(this.rgba),{h:yt(e.h),s:yt(e.s),v:yt(e.v),a:yt(e.a,3)};var e},n.prototype.invert=function(){return he({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},n.prototype.saturate=function(e){return e===void 0&&(e=.1),he(Bs(this.rgba,e))},n.prototype.desaturate=function(e){return e===void 0&&(e=.1),he(Bs(this.rgba,-e))},n.prototype.grayscale=function(){return he(Bs(this.rgba,-1))},n.prototype.lighten=function(e){return e===void 0&&(e=.1),he(So(this.rgba,e))},n.prototype.darken=function(e){return e===void 0&&(e=.1),he(So(this.rgba,-e))},n.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},n.prototype.alpha=function(e){return typeof e=="number"?he({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):yt(this.rgba.a,3);var t},n.prototype.hue=function(e){var t=Rr(this.rgba);return typeof e=="number"?he({h:e,s:t.s,l:t.l,a:t.a}):yt(t.h)},n.prototype.isEqual=function(e){return this.toHex()===he(e).toHex()},n}(),he=function(n){return n instanceof ks?n:new ks(n)},Ao=[],tc=function(n){n.forEach(function(e){Ao.indexOf(e)<0&&(e(ks,Rs),Ao.push(e))})};function ec(n,e){var t={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"},r={};for(var i in t)r[t[i]]=i;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=r[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,f="black";if(!s.length)for(var p in t)s[p]=new n(t[p]).toRgb();for(var y in t){var _=(a=c,l=s[y],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<u&&(u=_,f=y)}return f}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new n(l).toRgb():null},"name"])}tc([ec]);class Se{get value(){return this._value}set value(e){if(this._value===e)return;this._value=e;let t;typeof e=="number"?t={r:e>>24&255,g:e>>16&255,b:e>>8&255,a:e&255}:t=e;const r=he(t);r.isValid()?this._colord=r:console.warn(`Unable to convert color ${e}`)}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(e=0){this.value=e}toArgb(e=this.a,t=!0){if(e===1)return(255<<24)+this.rgb;if(e===0)return t?0:this.rgb;let r=this.r8,i=this.g8,s=this.b8;return t&&(r=r*e+.5|0,i=i*e+.5|0,s=s*e+.5|0),(e*255<<24)+(r<<16)+(i<<8)+s}toHex(){return this._colord.toHex()}toArray(){return[this.r,this.g,this.b,this.a]}}class Ns extends le{constructor(e){super(4,5,e)}hueRotate(e=0){const t=Math.sin(e),r=Math.cos(e),i=.213,s=.715,o=.072;return this.multiply([i+r*(1-i)+t*-i,s+r*-s+t*-s,o+r*-o+t*(1-o),0,0,i+r*-i+t*.143,s+r*(1-s)+t*.14,o+r*-o+t*-.283,0,0,i+r*-i+t*-(1-i),s+r*-s+t*s,o+r*(1-o)+t*o,0,0,0,0,0,1,0])}saturate(e=1){const t=(e-1)*2/3+1,r=(t-1)*-.5;return this.multiply([t,r,r,0,0,r,t,r,0,0,r,r,t,0,0,0,0,0,1,0])}brightness(e=1){const t=e;return this.multiply([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0])}contrast(e=1){const t=e,r=-128*(t-1);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}invert(e=1){const t=dt(1,-1,e),r=dt(0,255,e);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}sepia(e=1){const t=Me(0,e,1);return this.multiply([dt(1,.393,t),dt(0,.7689999,t),dt(0,.18899999,t),0,0,dt(0,.349,t),dt(1,.6859999,t),dt(0,.16799999,t),0,0,dt(0,.272,t),dt(0,.5339999,t),dt(1,.13099999,t),0,0,0,0,0,1,0])}opacity(e=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e,0])}grayscale(e=1){const t=Me(0,e,1),r=dt(1,.3,t),i=dt(0,.3,t),s=dt(1,.59,t),o=dt(0,.59,t),a=dt(1,.11,t),l=dt(0,.11,t);return this.multiply([r,o,l,0,0,i,s,l,0,0,i,o,a,0,0,0,0,0,1,0])}multiply(e){const t=e,r=this._array;return this.set([r[0]*t[0]+r[1]*t[5]+r[2]*t[10]+r[3]*t[15],r[0]*t[1]+r[1]*t[6]+r[2]*t[11]+r[3]*t[16],r[0]*t[2]+r[1]*t[7]+r[2]*t[12]+r[3]*t[17],r[0]*t[3]+r[1]*t[8]+r[2]*t[13]+r[3]*t[18],r[0]*t[4]+r[1]*t[9]+r[2]*t[14]+r[3]*t[19]+r[4],r[5]*t[0]+r[6]*t[5]+r[7]*t[10]+r[8]*t[15],r[5]*t[1]+r[6]*t[6]+r[7]*t[11]+r[8]*t[16],r[5]*t[2]+r[6]*t[7]+r[7]*t[12]+r[8]*t[17],r[5]*t[3]+r[6]*t[8]+r[7]*t[13]+r[8]*t[18],r[5]*t[4]+r[6]*t[9]+r[7]*t[14]+r[8]*t[19]+r[9],r[10]*t[0]+r[11]*t[5]+r[12]*t[10]+r[13]*t[15],r[10]*t[1]+r[11]*t[6]+r[12]*t[11]+r[13]*t[16],r[10]*t[2]+r[11]*t[7]+r[12]*t[12]+r[13]*t[17],r[10]*t[3]+r[11]*t[8]+r[12]*t[13]+r[13]*t[18],r[10]*t[4]+r[11]*t[9]+r[12]*t[14]+r[13]*t[19]+r[14],r[15]*t[0]+r[16]*t[5]+r[17]*t[10]+r[18]*t[15],r[15]*t[1]+r[16]*t[6]+r[17]*t[11]+r[18]*t[16],r[15]*t[2]+r[16]*t[7]+r[17]*t[12]+r[18]*t[17],r[15]*t[3]+r[16]*t[8]+r[17]*t[13]+r[18]*t[18],r[15]*t[4]+r[16]*t[9]+r[17]*t[14]+r[18]*t[19]+r[19]])}toMatrix4(){const e=this._array;return new uo([e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]])}toVector4(){const e=this._array;return new go(e[4]/255,e[9]/255,e[14]/255,e[19]/255)}}class Fs extends pt{constructor(e){const t=new Se(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}var rc=Object.defineProperty,Nt=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&rc(e,t,i),i};function Ft(){return function(n,e){Object.defineProperty(n.constructor.prototype,e,{get(){return(...t)=>(this._path2D[e](...t),this)},configurable:!0,enumerable:!0})}}class Mt{constructor(){d(this,"textureTransform");d(this,"fillStyle");d(this,"strokeStyle");d(this,"lineCap");d(this,"lineJoin");d(this,"lineWidth");d(this,"miterLimit");d(this,"_path2D",new As);d(this,"_defaultStyle",pt.EMPTY);d(this,"_stroked",[]);d(this,"_filled",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof pt?e=this.strokeStyle:e=new Fs(this.strokeStyle)),this._path2D.endPolygon(),this._path2D.shapes.length&&(this._stroked.push({shapes:this._path2D.shapes.slice(),texture:e,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this._path2D.shapes.length=0)}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(){let e=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof pt?e=this.fillStyle:e=new Fs(this.fillStyle)),this._filled.push({shapes:this._path2D.shapes.slice(),texture:e,textureTransform:this.textureTransform}),this._path2D.shapes.length=0}reset(){this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._path2D.endPolygon(),this._path2D.shapes.length=0,this._stroked.length=0,this._filled.length=0}buildUvs(e,t,r,i,s){if(i){let o=i.width,a=i.height;s&&([o,a]=s.applyToPoint(o,a));for(let l=t.length,h=e;h<l;h+=2)r.push(t[h]/o,t[h+1]/a)}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];let t=[],r=[],i=[],s=0,o;const a=l=>{e.push({type:l,vertices:t,indices:r,uvs:i,texture:o}),t=[],r=[],i=[],o=void 0};for(let l=this._stroked.length,h=0;h<l;h++){const c=this._stroked[h];o??(o=c.texture);const u=[];for(let f=c.shapes.length,p=0;p<f;p++)c.shapes[p].shape.buildOutline(u);s=t.length,lo(u,c.style,!1,!0,t,0,0,r),this.buildUvs(s,t,i,c.texture,c.textureTransform),a("stroke")}for(let l=this._filled.length,h=0;h<l;h++){const c=this._filled[h];o??(o=c.texture),o!==c.texture&&a("fill"),s=t.length;for(let u=c.shapes.length,f=0;f<u;f++)c.shapes[f].shape.buildGeometry(t,r);this.buildUvs(s,t,i,c.texture,c.textureTransform)}return t.length&&a("fill"),e}}Nt([Ft()],Mt.prototype,"moveTo"),Nt([Ft()],Mt.prototype,"lineTo"),Nt([Ft()],Mt.prototype,"bezierCurveTo"),Nt([Ft()],Mt.prototype,"quadraticCurveTo"),Nt([Ft()],Mt.prototype,"ellipticalArc"),Nt([Ft()],Mt.prototype,"rect"),Nt([Ft()],Mt.prototype,"roundRect"),Nt([Ft()],Mt.prototype,"ellipse"),Nt([Ft()],Mt.prototype,"arc"),Nt([Ft()],Mt.prototype,"poly"),Nt([Ft()],Mt.prototype,"addShape"),Nt([Ft()],Mt.prototype,"addPath"),Nt([Ft()],Mt.prototype,"addSvgPath"),Nt([Ft()],Mt.prototype,"closePath");class Ae{}class Oo extends Ae{install(e){const t=async r=>{const{parseFont:i}=await Promise.resolve().then(()=>Gf);return await e.fetch(r).then(s=>s.arrayBuffer()).then(s=>i(s))};return this.load=r=>e.loadBy(r,()=>t(r)),["woff","ttf"].forEach(r=>{e.register(r,t)}),e.font=this,this}}class Uo extends Ae{install(e){const t=async r=>{const{decodeFrames:i}=await import("modern-gif");return await e.fetch(r).then(s=>s.arrayBuffer()).then(s=>i(s)).then(s=>new Pi(s.map(o=>({duration:o.delay,texture:new Os(o.data,o.width,o.height)}))))};return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif"].forEach(r=>{e.register(r,t)}),e.gif=this,this}}class Io extends Ae{install(e){const t=r=>e.fetch(r).then(i=>i.json());return this.load=r=>e.loadBy(r,()=>t(r)),["json"].forEach(r=>{e.register(r,t)}),e.json=this,this}}class Do extends Ae{install(e){const t=async(r,i)=>(await import("lottie-web").then(o=>o.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await e.fetch(r).then(o=>o.json())});return this.load=(r,i)=>e.loadBy(r,()=>t(r,i)),["lottie"].forEach(r=>{e.register(r,t)}),e.lottie=this,this}}class Ro extends Ae{install(e){const t=async r=>await e.fetch(r).then(i=>i.text());return this.load=r=>e.loadBy(r,()=>t(r)),e.text=this,this}}class Bo extends Ae{install(e){const t=r=>e.fetchImageBitmap(r,{premultiplyAlpha:"premultiply"}).then(i=>new pt(i));return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(r=>{e.register(r,t)}),e.texture=this,this}}class Lo extends Ae{install(e){const t=r=>new _o(r).load();return this.load=r=>e.loadBy(r,()=>t(r)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(r=>{e.register(r,t)}),e.video=this,this}}const ic=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function sc(n){for(const[e,t]of ic)if(t.includes(n))return e}async function nc(n){var t,r;let e;if(n.startsWith("data:"))e=(t=n.match(/^data:(.+?);/))==null?void 0:t[1];else if(n.startsWith("http")){const i=(r=n.split(/[#?]/)[0].split(".").pop())==null?void 0:r.trim();i&&(e=sc(i))}return e??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const xi="WeakRef"in globalThis;class ko{constructor(){d(this,"defaultHandler",e=>this.fetch(e));d(this,"_handlers",new Map);d(this,"_handleing",new Map);d(this,"_handled",new Map);d(this,"_gc",xi?new FinalizationRegistry(e=>{const t=this.get(e);t&&"destroy"in t&&t.destroy(),this._handled.delete(e)}):void 0);xi||ft.on(this.gc.bind(this),{sort:2})}use(e){return e.install(this),this}register(e,t){return this._handlers.set(e,t),this}fetch(e){return fetch(e)}_fixSVG(e){const t=new DOMParser().parseFromString(decodeURIComponent(e.split(",")[1]),"image/svg+xml").documentElement;return t.setAttribute("width","512"),t.setAttribute("height","512"),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t.outerHTML)}`}async fetchImageBitmap(e,t){return e.startsWith("http")?await this.fetch(e).then(r=>r.blob()).then(r=>r.type==="image/svg+xml"?r.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),t)):createImageBitmap(r,t)):(e.startsWith("data:image/svg+xml;")&&(e=this._fixSVG(e)),new Promise(r=>{const i=new Image;i.src=e,i.onload=()=>i.decode().finally(()=>r(i))}).then(r=>createImageBitmap(r,t)))}get(e){let t=this._handled.get(e);return xi&&t instanceof WeakRef&&(t=t.deref(),t||this._handleing.delete(e)),t}set(e,t){let r=t;xi&&typeof t=="object"&&(this._gc.register(t,e),r=new WeakRef(t)),this._handled.set(e,r)}async loadBy(e,t){const r=this.get(e)??this._handleing.get(e);if(r)return r;const i=t().then(s=>(this.set(e,s),s)).finally(()=>{this._handleing.delete(e)});return this._handleing.set(e,i),i}async load(e,t){return this.loadBy(e,async()=>{const r=await nc(e);return(this._handlers.get(r)??this.defaultHandler)(e,t)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()))}gc(){this._handled.forEach((e,t)=>{const r=this.get(t);r&&"destroy"in r&&r.destroy()}),this._handled.clear()}}const we=new ko().use(new Oo).use(new Uo).use(new Io).use(new Do).use(new Ro).use(new Bo).use(new Lo);class hr{}class No extends hr{install(e){W(e,"backgroundColor"),W(e,"backgroundImage"),e.prototype.getComputedBackgroundImage=oc}}async function oc(){if(this.backgroundImage)return await we.texture.load(this.backgroundImage)}class Fo extends hr{install(e){W(e,"filter",{default:""}),e.prototype.getComputedFilter=ac,e.prototype.getComputedFilterColorMatrix=lc}}const $o={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function ac(){const n=wr(this.filter).reduce((e,{name:t,args:r})=>(e[t]=r[0].normalizedIntValue,e),{});return Object.keys($o).forEach(e=>{n[e]=n[e]??$o[e]}),n}function lc(){const n=new Ns,e=this.getComputedFilter();for(const t in e){const r=e[t];switch(t){case"hue-rotate":n.hueRotate(r*at);break;case"saturate":n.saturate(r);break;case"brightness":n.brightness(r);break;case"contrast":n.contrast(r);break;case"invert":n.invert(r);break;case"sepia":n.sepia(r);break;case"opacity":n.opacity(r);break;case"grayscale":n.grayscale(r);break}}return n}class zo extends hr{install(e){W(e,"offsetPath"),W(e,"offsetAnchor"),W(e,"offsetDistance"),W(e,"offsetPosition"),e.prototype.getComputedOffset=hc}}function hc(){var e;const n=this.offsetPath;if(n)if(n.startsWith("path")){const t=(e=n.match(/path\(["'](.+)["']\)/))==null?void 0:e[1];if(!t)return;t.split(" ").forEach(r=>{})}else n.startsWith("ray")||n.startsWith("url")||n.startsWith("circle")||n.startsWith("ellipse")||n.startsWith("insett")||n.startsWith("polygon")||n.startsWith("rect")||n.startsWith("xywh")}class Vo extends hr{install(e){W(e,"color",{default:"#000000"}),W(e,"fontSize",{default:14}),W(e,"fontWeight",{default:"normal"}),W(e,"fontFamily",{default:"sans-serif"}),W(e,"fontStyle",{default:"normal"}),W(e,"fontKerning",{default:"normal"}),W(e,"textWrap",{default:"wrap"}),W(e,"textAlign",{default:"start"}),W(e,"verticalAlign",{default:"middle"}),W(e,"textTransform",{default:"none"}),W(e,"textDecoration",{default:null}),W(e,"textStrokeWidth",{default:0}),W(e,"textStrokeColor",{default:"#000000"}),W(e,"direction",{default:"inherit"}),W(e,"lineHeight",{default:1}),W(e,"letterSpacing",{default:0}),W(e,"writingMode",{default:"horizontal-tb"})}}class Xo extends hr{install(e){W(e,"left",{default:0}),W(e,"top",{default:0}),W(e,"width",{default:0}),W(e,"height",{default:0}),W(e,"rotate",{default:0}),W(e,"scaleX",{default:1}),W(e,"scaleY",{default:1}),W(e,"transform"),W(e,"transformOrigin",{default:"center"}),e.prototype.getComputedTransform=cc,e.prototype.getComputedTransformOrigin=uc}}function cc(){const n=new qt,e=new qt(!1),t=new qt(!1).scale(this.scaleX,this.scaleY).translate(this.left,this.top).rotate(this.rotate*po);wr(this.transform??"",{width:this.width,height:this.height}).forEach(({name:c,args:u})=>{const f=u.map(p=>p.normalizedIntValue);switch(n.identity(),c){case"translate":n.translate(f[0]*this.width,(f[1]??f[0])*this.height);break;case"translateX":n.translateX(f[0]*this.width);break;case"translateY":n.translateY(f[0]*this.height);break;case"translateZ":n.translateZ(f[0]);break;case"translate3d":n.translate3d(f[0]*this.width,(f[1]??f[0])*this.height,f[2]??f[1]??f[0]);break;case"scale":n.scale(f[0],f[1]??f[0]);break;case"scaleX":n.scaleX(f[0]);break;case"scaleY":n.scaleY(f[0]);break;case"scale3d":n.scale3d(f[0],f[1]??f[0],f[2]??f[1]??f[0]);break;case"rotate":n.rotate(f[0]*at);break;case"rotateX":n.rotateX(f[0]*at);break;case"rotateY":n.rotateY(f[0]*at);break;case"rotateZ":n.rotateZ(f[0]*at);break;case"rotate3d":n.rotate3d(f[0]*at,(f[1]??f[0])*at,(f[2]??f[1]??f[0])*at,(f[3]??f[2]??f[1]??f[0])*at);break;case"skew":n.skew(f[0],f[0]??f[1]);break;case"skewX":n.skewX(f[0]);break;case"skewY":n.skewY(f[0]);break;case"matrix":n.set(f);break}e.multiply(n)}),t.update(),e.update();const r=t.toArray(),i=e.toArray(),s=[i[0]*r[0]+i[3]*r[1],i[1]*r[0]+i[4]*r[1],i[2]*r[0]+i[5]*r[1]+r[2],i[0]*r[3]+i[3]*r[4],i[1]*r[3]+i[4]*r[4],i[2]*r[3]+i[5]*r[4]+r[5],0,0,1],[o,a]=this.getComputedTransformOrigin(),l=o*this.width,h=a*this.height;return s[2]+=s[0]*-l+s[1]*-h+l,s[5]+=s[3]*-l+s[4]*-h+h,new qt().set(s)}function uc(){const[n,e=n]=this.transformOrigin.split(" ");return[n,e].map(t=>{switch(t=t.trim(),t){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(t)}})}const fc=Object.freeze(Object.defineProperty({__proto__:null,Style2DBackgroundModule:No,Style2DFilterModule:Fo,Style2DOffsetModule:zo,Style2DTextModule:Vo,Style2DTransformModule:Xo},Symbol.toStringTag,{value:"Module"}));var dc=Object.defineProperty,Xe=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&dc(e,t,i),i};class ce extends li{constructor(e){super(),this.setProperties(e)}_onUpdateProperty(e,t,r){switch(super._onUpdateProperty(e,t,r),e){case"fontSize":t<=0&&(this.fontSize=14);break;case"fontWeight":t||(this.fontWeight="normal");break;case"lineHeight":t||(this.lineHeight=1);break}}}Xe([U({default:"#000000"})],ce.prototype,"shadowColor"),Xe([U({default:0})],ce.prototype,"shadowOffsetX"),Xe([U({default:0})],ce.prototype,"shadowOffsetY"),Xe([U({default:0})],ce.prototype,"shadowBlur"),Xe([U({default:1})],ce.prototype,"opacity"),Xe([U({default:0})],ce.prototype,"borderRadius"),Xe([U({default:"visible"})],ce.prototype,"overflow"),Object.values(fc).forEach(n=>{new n().install(ce)});var pc=Object.defineProperty,gc=Object.getOwnPropertyDescriptor,$s=(n,e,t,r)=>{for(var i=r>1?void 0:r?gc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&pc(e,t,i),i};g.CanvasItem=class extends g.Node{constructor(t){super();d(this,"tint");d(this,"blendMode");d(this,"opacity",1);d(this,"_parentOpacity");d(this,"_tint",new Se(4294967295));d(this,"_backgroundColor",new Se(0));d(this,"_backgroundImage");d(this,"context",new Mt);d(this,"_resetContext",!0);d(this,"_redrawing",!1);d(this,"_reflowing",!1);d(this,"_repainting",!1);d(this,"_originalBatchables",[]);d(this,"_layoutedBatchables",[]);d(this,"_batchables",[]);this._onUpdateStyleProperty=this._onUpdateStyleProperty.bind(this),this.setProperties(t),this.style=new ce}get style(){return this._style}set style(t){var r;t.on("updateProperty",this._onUpdateStyleProperty),(r=this._style)==null||r.off("updateProperty",this._onUpdateStyleProperty),this._style=t}setProperties(t){if(t){const{style:r,...i}=t;r&&this.style.setProperties(r),super.setProperties(i)}return this}_onUpdateProperty(t,r,i,s){switch(super._onUpdateProperty(t,r,i,s),t){case"blendMode":this.requestRepaint();break;case"tint":this._tint.value=r||4294967295,this.requestRepaint();break}}_onUpdateStyleProperty(t,r,i,s){switch(t){case"backgroundColor":this._updateBackgroundColor();break;case"backgroundImage":this._updateBackgroundImage();break;case"opacity":this._updateOpacity();break;case"filter":this.requestRepaint();break;case"borderRadius":this.requestRedraw();break}}_updateBackgroundColor(){this._backgroundColor.value=this.style.backgroundColor||0,this._originalBatchables.length?this.requestRepaint():this._backgroundColor.a>0&&this.requestRedraw()}async _updateBackgroundImage(){this._backgroundImage=await this.style.getComputedBackgroundImage(),this.requestRedraw()}_updateOpacity(){var r;const t=Me(0,this.style.opacity,1)*(((r=this._parent)==null?void 0:r.opacity)??1);this.opacity!==t&&(this.opacity=t,this.requestRepaint())}isVisible(){return this.opacity>0&&super.isVisible()}requestRedraw(){this._redrawing=!0}requestReflow(){this._reflowing=!0}requestRepaint(){this._repainting=!0}_process(t){var i;const r=(i=this._parent)==null?void 0:i.opacity;r!==this._parentOpacity&&(this._parentOpacity=r,this._updateOpacity()),super._process(t)}_draw(){this._drawBackground(),this._drawContent()}_drawBackground(){const t=this._backgroundImage;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),this._fill())}_drawContent(){this._fill()}_fill(){this.style.borderRadius?this.context.roundRect(0,0,this.style.width,this.style.height,this.style.borderRadius):this.context.rect(0,0,this.style.width,this.style.height),this.context.fill()}_relayout(t){return this._reflow(t)}_reflow(t){return this._repaint(t)}_repaint(t){const r=this.style.getComputedFilterColorMatrix();return t.map(i=>({...i,backgroundColor:this._backgroundColor.abgr,tint:this._tint.toArgb(this.opacity,!0),colorMatrix:r.toMatrix4().toArray(!0),colorMatrixOffset:r.toVector4().toArray(),blendMode:this.blendMode}))}_render(t){let r;this._redrawing?(this._draw(),this._originalBatchables=this.context.toBatchables(),this._layoutedBatchables=this._relayout(this._originalBatchables),r=this._layoutedBatchables,this._resetContext&&this.context.reset()):this._reflowing?(this._layoutedBatchables=this._reflow(this._originalBatchables),r=this._layoutedBatchables):this._repainting&&(r=this._repaint(this._layoutedBatchables)),r&&(this._batchables=r,this._redrawing=!1,this._reflowing=!1,this._repainting=!1),this._batchables.forEach(i=>{var s,o;(s=i.texture)==null||s.upload(t),t.batch2D.render({...i,texture:(o=i.texture)==null?void 0:o._glTexture(t)})}),super._render(t)}toJSON(){const t=super.toJSON();return{...t,props:{style:this.style.toJSON(),...t.props}}}},$s([U()],g.CanvasItem.prototype,"tint",2),$s([U()],g.CanvasItem.prototype,"blendMode",2),g.CanvasItem=$s([Z("CanvasItem")],g.CanvasItem);var mc=Object.defineProperty,yc=Object.getOwnPropertyDescriptor,je=(n,e,t,r)=>{for(var i=r>1?void 0:r?yc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&mc(e,t,i),i};const jo=n=>n,Go=cr(.25,.1,.25,1),qo=cr(.42,0,1,1),Yo=cr(0,0,.58,1),Wo=cr(.42,0,.58,1);function cr(n,e,t,r){const s=3*n-3*t+1,o=3*t-6*n,a=3*n,l=3*e-3*r+1,h=3*r-6*e,c=3*e,u=_=>(3*s*_+2*o)*_+a,f=_=>((s*_+o)*_+a)*_,p=_=>((l*_+h)*_+c)*_;function y(_){let m=_,b,w;for(let P=0;P<8;P++){if(w=f(m)-_,Math.abs(w)<1e-6)return m;if(b=u(m),Math.abs(b)<1e-6)break;m-=w/b}let x=1,C=0;for(m=_;x>C;){if(w=f(m)-_,Math.abs(w)<1e-6)return m;w>0?x=m:C=m,m=(x+C)/2}return m}return _=>p(y(_))}const wi={linear:jo,ease:Go,easeIn:qo,easeOut:Yo,easeInOut:Wo};g.Animation2D=class extends g.Node{constructor(t){super();d(this,"easing");d(this,"_keyframes",[]);d(this,"_starting",!1);d(this,"_startProps",new WeakMap);this._onUpdateTime=this._onUpdateTime.bind(this),this.setProperties(t)}_enterTree(){var t;(t=this._tree)==null||t.timeline.on("update",this._onUpdateTime),this._updateStartProps()}_exitTree(){var t;(t=this._tree)==null||t.timeline.off("update",this._onUpdateTime),this.cancel()}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"mode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var r;let t;switch(this.mode){case"sibling":t=((r=this.getParent())==null?void 0:r.getChildren(!0).filter(i=>i instanceof g.CanvasItem))??[];break;case"parent":default:t=[this.getParent()].filter(Boolean);break}return t.map(i=>i.style)}_updateKeyframes(){const t=[],r=this.keyframes;for(let o=r.length,a=0;a<o;a++){const{offset:l=a===0?0:a/(o-1),easing:h="linear",...c}=r[a];t.push({offset:l,easing:this._parseEasing(h),props:c})}const i=t[0],s=t[t.length-1];i&&i.offset!==0&&t.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),s&&s.offset!==1&&t.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=t,this._updateStartProps()}_onUpdateTime(){if(!this.keyframes.length)return;if(this.isVisible())this._starting||(this._starting=!0,this._updateStartProps());else{if(!this._starting)return;this._starting=!1}const t=this._getTargets(),r=1/t.length,i=this.visibleProgress;t.forEach((s,o)=>{const a=r===1?i:Me(0,Math.max(0,i-r*o)/r,1),l=this._startProps.get(s);if(!l)return;const h=this._parseKeyframes(a,l);h!=null&&h.length&&this._commitStyle(a,s,l,h[0],h[1])})}_updateStartProps(){this.cancel(),this._getTargets().forEach(t=>{const r=new Map,i=this._keyframes;for(let s=i.length,o=0;o<s;o++)Object.keys(i[o].props).forEach(a=>{r.set(a,t[a])});this._startProps.set(t,r)})}_parseEasing(t){if(!t)return wi.linear;if(t in wi)return wi[t];const r=t.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return cr(r[0],r[1],r[2],r[3])}_parseKeyframes(t,r){let i;const s=this._keyframes;for(let o=s.length,a=0;a<o;a++){const l=s[a],{offset:h,easing:c}=l,u={...l.props};if(i&&t<=h){const{offset:f,easing:p}=i,y={...i.props};return r.forEach((_,m)=>{(!(m in y)||y[m]===null)&&(y[m]=_),(!(m in u)||u[m]===null)&&(u[m]=_)}),[{offset:f,easing:p,props:y},{offset:h,easing:c,props:u}]}i=l}return null}_commitStyle(t,r,i,s,o){const{offset:a,easing:l,props:h}=s,{offset:c,props:u}=o,f=c-a,p=l((t-a)/f),y={width:r.width,height:r.height,fontSize:r.fontSize};i.forEach((_,m)=>{r[m]=this._getDiffValue(m,h[m],u[m],p,y)})}_getDiffValue(t,r,i,s,o){let a,l;if(r===void 0||i===void 0)if(r!==void 0)a=xr(t,String(r),o),l=ns(a);else if(i!==void 0)l=xr(t,String(i),o),a=ns(l);else return;else a=xr(t,String(r),o),l=xr(t,String(i),o);if(Array.isArray(a)&&Array.isArray(l)){const h=new Set,c={},u={};a.forEach(({name:p,args:y})=>{c[p]=y,h.add(p)}),l.forEach(({name:p,args:y})=>{u[p]=y,h.add(p)});let f="";return h.forEach(p=>{var b,w;const y=Math.max(((b=c[p])==null?void 0:b.length)??0,((w=u[p])==null?void 0:w.length)??0),_=c[p],m=u[p];f+=`${p}(${Array.from({length:y},(x,C)=>{const P=_==null?void 0:_[C],E=m==null?void 0:m[C],A=(P==null?void 0:P.normalizedIntValue)??0,S=(E==null?void 0:E.normalizedIntValue)??0;return Number.isNaN(A)||Number.isNaN(S)?(E==null?void 0:E.value)??0:dt(A,S,s)}).join(", ")}) `}),f}else if(!Array.isArray(a)&&!Array.isArray(l))return Number.isNaN(a.normalizedIntValue)||Number.isNaN(l.normalizedIntValue)?l.value:dt(a.normalizedIntValue,l.normalizedIntValue,s)}cancel(){this._getTargets().forEach(t=>{var r;(r=this._startProps.get(t))==null||r.forEach((i,s)=>{t[s]=i}),this._startProps.delete(t)})}},je([U({default:"parent"})],g.Animation2D.prototype,"mode",2),je([U({default:!1})],g.Animation2D.prototype,"loop",2),je([U({default:[]})],g.Animation2D.prototype,"keyframes",2),je([U()],g.Animation2D.prototype,"easing",2),je([U({alias:"visibleDelay",default:0})],g.Animation2D.prototype,"delay",2),je([U({alias:"visibleDuration",default:2e3})],g.Animation2D.prototype,"duration",2),g.Animation2D=je([Z("Animation2D")],g.Animation2D);var _c=Object.defineProperty,vc=Object.getOwnPropertyDescriptor,bc=(n,e,t,r)=>{for(var i=r>1?void 0:r?vc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_c(e,t,i),i};g.Node2D=class extends g.CanvasItem{constructor(t){super();d(this,"_transform",new qt);d(this,"_parentTransformDirtyId");this.setProperties(t)}getBoundingBox(){let{left:t,top:r,width:i,height:s,rotate:o}=this.style;if(o){o=Math.abs(o%180),o=o/180*Math.PI;const a=Math.abs(Math.sin(o)),l=Math.abs(Math.cos(o)),h=s*a+i*l,c=s*l+i*a;t+=(i-h)/2,r+=(s-c)/2,i=h,s=c}return new Gt(t,r,i,s)}_onUpdateStyleProperty(t,r,i){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":case"height":this.mask instanceof g.Node2D&&(this.mask.style.width=this.style.width,this.mask.style.height=this.style.height),this.requestRedraw();case"scaleX":case"scaleY":case"left":case"top":case"rotate":case"transform":case"transformOrigin":this._updateTransform();break;case"overflow":this._updateOverflow();break}}_updateTransform(){const t=this.getParent(),r=t==null?void 0:t._transform;this._parentTransformDirtyId=r==null?void 0:r.dirtyId;const i=this.style.getComputedTransform().toArray();let s;if(r){const o=r.toArray();s=[i[0]*o[0]+i[3]*o[1],i[1]*o[0]+i[4]*o[1],i[2]*o[0]+i[5]*o[1]+o[2],i[0]*o[3]+i[3]*o[4],i[1]*o[3]+i[4]*o[4],i[2]*o[3]+i[5]*o[4]+o[5],0,0,1]}else s=i;this._transform.set(s),this._updateOverflow(),this.requestReflow()}_updateOverflow(){if(this.style.overflow==="hidden"){const[t,r,i,s,o,a]=this._transform.toArray(),l=this.style.width,h=this.style.height;this.mask={x:i,y:a,width:t*l+r*h,height:s*l+o*h}}else this.mask=void 0}_transformVertices(t){const[r,i,s,o,a,l]=this._transform.toArray(),h=t.slice();for(let c=t.length,u=0;u<c;u+=2){const f=t[u],p=t[u+1];h[u]=r*f+i*p+s,h[u+1]=o*f+a*p+l}return h}_reflow(t){return super._reflow(t.map(r=>({...r,vertices:this._transformVertices(r.vertices)})))}_process(t){var i;const r=this.getParent();((i=r==null?void 0:r._transform)==null?void 0:i.dirtyId)!==this._parentTransformDirtyId&&this._updateTransform(),super._process(t)}input(t){if(super.input(t),!t.target&&this.isRenderable()){const{screenX:r,screenY:i}=t;if(r&&i){const{width:s,height:o}=this.style,[a,l]=this._transform.inverse().applyToPoint(r,i);a>=0&&a<s&&l>=0&&l<o&&(t.target=this)}}}},g.Node2D=bc([Z({tag:"Node2D",renderable:!0})],g.Node2D);var xc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,mt=(n,e,t,r)=>{for(var i=r>1?void 0:r?wc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&xc(e,t,i),i};function _t(n){return function(e,t){Object.defineProperty(e.constructor.prototype,t,{get(){return n!=null&&n.method?(...r)=>(this.context[t].call(this.context,...r),n.redraw&&this.requestRedraw(),e):this.context[t]},set(r){this.context[t]=r},configurable:!0,enumerable:!0})}}g.Graphics2D=class extends g.Node2D{constructor(){super(...arguments);d(this,"_resetContext",!1);d(this,"lineCap");d(this,"lineJoin");d(this,"fillStyle");d(this,"strokeStyle");d(this,"lineWidth");d(this,"miterLimit")}drawCircle(t,r,i){return this.arc(t+i,r+i,i,0,at),this.fill(),this}drawEllipse(t,r,i,s){const o=i/2,a=s/2;return this.ellipse(t+o,r+a,o,a,0,0,at),this.fill(),this}},mt([_t()],g.Graphics2D.prototype,"lineCap",2),mt([_t()],g.Graphics2D.prototype,"lineJoin",2),mt([_t()],g.Graphics2D.prototype,"fillStyle",2),mt([_t()],g.Graphics2D.prototype,"strokeStyle",2),mt([_t()],g.Graphics2D.prototype,"lineWidth",2),mt([_t()],g.Graphics2D.prototype,"miterLimit",2),mt([_t({method:!0})],g.Graphics2D.prototype,"rect",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"fillRect",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"strokeRect",2),mt([_t({method:!0})],g.Graphics2D.prototype,"roundRect",2),mt([_t({method:!0})],g.Graphics2D.prototype,"ellipse",2),mt([_t({method:!0})],g.Graphics2D.prototype,"arc",2),mt([_t({method:!0})],g.Graphics2D.prototype,"beginPath",2),mt([_t({method:!0})],g.Graphics2D.prototype,"moveTo",2),mt([_t({method:!0})],g.Graphics2D.prototype,"lineTo",2),mt([_t({method:!0})],g.Graphics2D.prototype,"closePath",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"fill",2),mt([_t({method:!0,redraw:!0})],g.Graphics2D.prototype,"stroke",2),g.Graphics2D=mt([Z("Graphics2D")],g.Graphics2D);class Pi extends Ee{constructor(t){super();d(this,"frames");let r;if(Array.isArray(t))r=t;else if(t instanceof pt)r=[{texture:t,duration:0}];else throw new TypeError("Failed new Image2DResource");this.frames=r,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((t,r)=>r.duration+t,0),this}destroy(){this.frames.forEach(t=>{t.texture.destroy()})}}var Pc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ci=(n,e,t,r)=>{for(var i=r>1?void 0:r?Cc(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Pc(e,t,i),i};g.Image2D=class extends g.Node2D{constructor(t){super();d(this,"resource");d(this,"_frameIndex",0);d(this,"_complete",!1);d(this,"_wait",Promise.resolve());this.setProperties(t)}get currentTexture(){var t,r;return(r=(t=this.resource)==null?void 0:t.frames[this._frameIndex])==null?void 0:r.texture}get duration(){var t;return((t=this.resource)==null?void 0:t.duration)??0}get naturalWidth(){var t;return((t=this.currentTexture)==null?void 0:t.realWidth)??0}get naturalHeight(){var t;return((t=this.currentTexture)==null?void 0:t.realHeight)??0}get complete(){return this._complete}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._wait=this._load(r);break}}decode(){return this._wait}setResource(t){let r;if(t instanceof Pi?r=t:r=new Pi(t),this.resource=r.updateDuration(),this.currentTexture&&(!this.style.width||!this.style.height)){const i=this.currentTexture;this.style.width=i.realWidth,this.style.height=i.realHeight}return this}async _load(t){if(this._complete=!1,t)try{this.setResource(this.gif?await we.gif.load(t):await we.texture.load(t)),this.requestRedraw(),this.emit("load")}catch(r){console.warn(r),this.emit("error",r)}else this.resource=void 0;this._complete=!0}_getCurrentTime(){var i;const t=((i=this.resource)==null?void 0:i.duration)??0;if(!t||!this._tree)return 0;const r=this.visibleRelativeTime;return r<0?0:r%t}_updateFrameIndex(){if(!this.resource)return this;const t=this._getCurrentTime(),r=this.resource.frames,i=r.length;if(i<=1&&this._frameIndex===0)return this;let s=i-1;for(let o=0,a=0;a<i;a++)if(o+=r[a].duration??0,o>=t){s=a;break}return this._frameIndex!==s&&(this._frameIndex=s,this.requestRepaint()),this}_process(t){this._updateFrameIndex(),super._process(t)}_drawContent(){const t=this.currentTexture;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),super._drawContent())}_repaint(t){const r=this.currentTexture;return super._repaint(t.map((i,s)=>(this._backgroundImage?s===1:s===0)&&i.type==="fill"?{...i,texture:r!=null&&r.valid?r:void 0}:i))}},Ci([nt()],g.Image2D.prototype,"resource",2),Ci([U({default:!1})],g.Image2D.prototype,"gif",2),Ci([U({default:""})],g.Image2D.prototype,"src",2),g.Image2D=Ci([Z("Image2D")],g.Image2D);var Tc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,zs=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ec(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tc(e,t,i),i};g.Lottie2D=class extends g.Node2D{constructor(t){super();d(this,"duration",0);d(this,"texture",new pt(document.createElement("canvas")));d(this,"animation");this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._load();break}}_onUpdateStyleProperty(t,r,i){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":this.texture.source.width=this.style.width*this.pixelRatio;break;case"height":this.texture.source.height=this.style.height*this.pixelRatio;break}}async _load(){this.animation=await we.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(t){var r;(r=this.animation)==null||r.goToAndStop(this.visibleRelativeTime,!1),this.texture.requestUpload(),this.requestRepaint(),super._process(t)}_drawContent(){const t=this.texture;t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height),super._drawContent())}},zs([U({default:2})],g.Lottie2D.prototype,"pixelRatio",2),zs([U({default:""})],g.Lottie2D.prototype,"src",2),g.Lottie2D=zs([Z("Lottie2D")],g.Lottie2D);const Mc={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Vs(n,e){const{fill:t="#000",stroke:r="none",strokeWidth:i=r==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:u=0,shadowBlur:f=0,shadowColor:p="rgba(0, 0, 0, 0)"}=e;n.fillStyle=t,n.strokeStyle=r,n.lineWidth=i,n.lineCap=s,n.lineJoin=Mc[o],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=c,n.shadowOffsetY=u,n.shadowBlur=f,n.shadowColor=p}class D{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new D(1/0,1/0)}static get MIN(){return new D(-1/0,-1/0)}get array(){return[this.x,this.y]}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const r=-e/180*Math.PI,i=this.x-t.x,s=-(this.y-t.y),o=Math.sin(r),a=Math.cos(r);return this.set(t.x+(i*a-s*o),t.y-(i*o+s*a)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,r={x:0,y:0}){const i=e<0?r.x-this.x+r.x:this.x,s=t<0?r.y-this.y+r.y:this.y;return this.x=i*Math.abs(e),this.y=s*Math.abs(t),this}skew(e,t=0,r={x:0,y:0}){const i=this.x-r.x,s=this.y-r.y;return this.x=r.x+(i+Math.tan(e)*s),this.y=r.y+(s+Math.tan(t)*i),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new D(this.x,this.y)}}class K{constructor(e=0,t=0,r=0,i=0){this.left=e,this.top=t,this.width=r,this.height=i}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new D((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new K;if(e.length===1)return e[0].clone();const t=e[0],r=e.slice(1).reduce((i,s)=>(i.left=Math.min(i.left,s.left),i.top=Math.min(i.top,s.top),i.right=Math.max(i.right,s.right),i.bottom=Math.max(i.bottom,s.bottom),i),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new K(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new K(this.left,this.top,this.width,this.height)}}class $t{constructor(e=1,t=0,r=0,i=0,s=1,o=0,a=0,l=0,h=1){d(this,"elements",[]);this.set(e,t,r,i,s,o,a,l,h)}set(e,t,r,i,s,o,a,l,h){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=r,c[7]=o,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,s=this.elements,o=r[0],a=r[3],l=r[6],h=r[1],c=r[4],u=r[7],f=r[2],p=r[5],y=r[8],_=i[0],m=i[3],b=i[6],w=i[1],x=i[4],C=i[7],P=i[2],E=i[5],A=i[8];return s[0]=o*_+a*w+l*P,s[3]=o*m+a*x+l*E,s[6]=o*b+a*C+l*A,s[1]=h*_+c*w+u*P,s[4]=h*m+c*x+u*E,s[7]=h*b+c*C+u*A,s[2]=f*_+p*w+y*P,s[5]=f*m+p*x+y*E,s[8]=f*b+p*C+y*A,this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],h=e[7],c=e[8],u=c*o-a*h,f=a*l-c*s,p=h*s-o*l,y=t*u+r*f+i*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return e[0]=u*_,e[1]=(i*h-c*r)*_,e[2]=(a*r-i*o)*_,e[3]=f*_,e[4]=(c*t-i*l)*_,e[5]=(i*s-a*t)*_,e[6]=p*_,e[7]=(r*l-h*t)*_,e[8]=(o*t-r*s)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(Xs.makeScale(e,t)),this}rotate(e){return this.premultiply(Xs.makeRotation(-e)),this}translate(e,t){return this.premultiply(Xs.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Xs=new $t;function Ho(n,e,t,r){const i=n*t+e*r,s=Math.sqrt(n*n+e*e)*Math.sqrt(t*t+r*r);let o=Math.acos(Math.max(-1,Math.min(1,i/s)));return n*r-e*t<0&&(o=-o),o}function Sc(n,e,t,r,i,s,o,a){if(e===0||t===0){n.lineTo(a.x,a.y);return}r=r*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const l=(o.x-a.x)/2,h=(o.y-a.y)/2,c=Math.cos(r)*l+Math.sin(r)*h,u=-Math.sin(r)*l+Math.cos(r)*h;let f=e*e,p=t*t;const y=c*c,_=u*u,m=y/f+_/p;if(m>1){const O=Math.sqrt(m);e=O*e,t=O*t,f=e*e,p=t*t}const b=f*_+p*y,w=(f*p-b)/b;let x=Math.sqrt(Math.max(0,w));i===s&&(x=-x);const C=x*e*u/t,P=-x*t*c/e,E=Math.cos(r)*C-Math.sin(r)*P+(o.x+a.x)/2,A=Math.sin(r)*C+Math.cos(r)*P+(o.y+a.y)/2,S=Ho(1,0,(c-C)/e,(u-P)/t),T=Ho((c-C)/e,(u-P)/t,(-c-C)/e,(-u-P)/t)%(Math.PI*2);n.ellipse(E,A,e,t,r,S,S+T,s===0)}function ur(n,e){return n-(e-n)}function Zo(n,e){const t=new D,r=new D;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o.type==="m"||o.type==="M")o.type==="m"?t.add(o):t.copy(o),e.moveTo(t.x,t.y),r.copy(t);else if(o.type==="h"||o.type==="H")o.type==="h"?t.x+=o.x:t.x=o.x,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="v"||o.type==="V")o.type==="v"?t.y+=o.y:t.y=o.y,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="l"||o.type==="L")o.type==="l"?t.add(o):t.copy(o),e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="c"||o.type==="C")o.type==="c"?(e.bezierCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="s"||o.type==="S")o.type==="s"?(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="q"||o.type==="Q")o.type==="q"?(e.quadraticCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x,t.y+o.y),r.x=t.x+o.x1,r.y=t.y+o.y1,t.add(o)):(e.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,t.copy(o));else if(o.type==="t"||o.type==="T"){const a=ur(t.x,r.x),l=ur(t.y,r.y);r.x=a,r.y=l,o.type==="t"?(e.quadraticCurveTo(a,l,t.x+o.x,t.y+o.y),t.add(o)):(e.quadraticCurveTo(a,l,o.x,o.y),t.copy(o))}else if(o.type==="a"||o.type==="A"){const a=t.clone();if(o.type==="a"){if(o.x===0&&o.y===0)continue;t.add(o)}else{if(t.equals(o))continue;t.copy(o)}r.copy(t),Sc(e,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,a,t)}else o.type==="z"||o.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",o)}}const ct={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function ue(n,e,t=0){let a=0,l=!0,h="",c="";const u=[];function f(m,b,w){const x=new SyntaxError(`Unexpected character "${m}" at index ${b}.`);throw x.partial=w,x}function p(){h!==""&&(c===""?u.push(Number(h)):u.push(Number(h)*10**Number(c))),h="",c=""}let y;const _=n.length;for(let m=0;m<_;m++){if(y=n[m],Array.isArray(e)&&e.includes(u.length%t)&&ct.FLAGS.test(y)){a=1,h=y,p();continue}if(a===0){if(ct.WHITESPACE.test(y))continue;if(ct.DIGIT.test(y)||ct.SIGN.test(y)){a=1,h=y;continue}if(ct.POINT.test(y)){a=2,h=y;continue}ct.COMMA.test(y)&&(l&&f(y,m,u),l=!0)}if(a===1){if(ct.DIGIT.test(y)){h+=y;continue}if(ct.POINT.test(y)){h+=y,a=2;continue}if(ct.EXP.test(y)){a=3;continue}ct.SIGN.test(y)&&h.length===1&&ct.SIGN.test(h[0])&&f(y,m,u)}if(a===2){if(ct.DIGIT.test(y)){h+=y;continue}if(ct.EXP.test(y)){a=3;continue}ct.POINT.test(y)&&h[h.length-1]==="."&&f(y,m,u)}if(a===3){if(ct.DIGIT.test(y)){c+=y;continue}if(ct.SIGN.test(y)){if(c===""){c+=y;continue}c.length===1&&ct.SIGN.test(c)&&f(y,m,u)}}ct.WHITESPACE.test(y)?(p(),a=0,l=!1):ct.COMMA.test(y)?(p(),a=0,l=!0):ct.SIGN.test(y)?(p(),a=1,h=y):ct.POINT.test(y)?(p(),a=2,h=y):f(y,m,u)}return p(),u}function Ac(n){let e,t;const r=[];for(let i=0,s=n.length;i<s;i++){const o=n[i];switch(o.type){case"m":case"M":if(o.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&o.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y},e={x:o.x,y:o.y};break;case"h":case"H":r.push(`${o.type} ${o.x}`),t={x:o.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":r.push(`${o.type} ${o.y}`),t={x:(t==null?void 0:t.x)??0,y:o.y};break;case"l":case"L":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"c":case"C":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"s":case"S":r.push(`${o.type} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"q":case"Q":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"t":case"T":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"a":case"A":r.push(`${o.type} ${o.rx} ${o.ry} ${o.angle} ${o.largeArcFlag} ${o.sweepFlag} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"z":case"Z":r.push(o.type),e&&(t={x:e.x,y:e.y});break}}return r.join(" ")}const Oc=/[a-df-z][^a-df-z]*/gi;function Ko(n){const e=[],t=n.match(Oc);if(!t)return e;for(let r=0,i=t.length;r<i;r++){const s=t[r],o=s.charAt(0),a=s.slice(1).trim();let l;switch(o){case"m":case"M":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)h===0?e.push({type:o,x:l[h],y:l[h+1]}):e.push({type:o==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=ue(a);for(let h=0,c=l.length;h<c;h++)e.push({type:o,x:l[h]});break;case"v":case"V":l=ue(a);for(let h=0,c=l.length;h<c;h++)e.push({type:o,y:l[h]});break;case"l":case"L":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:o,x:l[h],y:l[h+1]});break;case"c":case"C":l=ue(a);for(let h=0,c=l.length;h<c;h+=6)e.push({type:o,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=ue(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:o,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=ue(a);for(let h=0,c=l.length;h<c;h+=4)e.push({type:o,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=ue(a);for(let h=0,c=l.length;h<c;h+=2)e.push({type:o,x:l[h],y:l[h+1]});break;case"a":case"A":l=ue(a,[3,4],7);for(let h=0,c=l.length;h<c;h+=7)e.push({type:o,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":e.push({type:o});break;default:console.warn(s)}}return e}class Ge{constructor(){d(this,"arcLengthDivisions",200);d(this,"_cacheArcLengths");d(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),r=this.getPoint(1);return(t.x-e.x)*(r.y-t.y)-(t.y-e.y)*(r.x-t.x)<0}getPointAt(e,t=new D){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let r,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)r=this.getPoint(o/e),s+=r.distanceTo(i),t.push(s),i=r;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const r=this.getLengths();let i=0;const s=r.length;let o;t?o=t:o=e*r[s-1];let a=0,l=s-1,h;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),h=r[i]-o,h<0)a=i+1;else if(h>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const c=r[i],f=r[i+1]-c,p=(o-c)/f;return(i+p)/(s-1)}getTangent(e,t=new D){const i=Math.max(0,e-1e-4),s=Math.min(1,e+1e-4);return t.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new D){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let r=0,i=1,s=(r+i)/2;for(;i-r>t;){s=(r+i)/2;const o=this.getPoint(s);if(o.distanceTo(e)<t)return s;o.x<e.x?r=s:i=s}return s}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=D.MAX,t=D.MIN){return this.getPoints().forEach(r=>{e.min(r),t.max(r)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new K(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return Ac(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}function Qo(n,e,t,r,i){const s=(r-e)*.5,o=(i-t)*.5,a=n*n,l=n*a;return(2*t-2*r+s+o)*l+(-3*t+3*r-2*s-o)*a+s*n+t}function Uc(n,e){const t=1-n;return t*t*e}function Ic(n,e){return 2*(1-n)*n*e}function Dc(n,e){return n*n*e}function Jo(n,e,t,r){return Uc(n,e)+Ic(n,t)+Dc(n,r)}function Rc(n,e){const t=1-n;return t*t*t*e}function Bc(n,e){const t=1-n;return 3*t*t*n*e}function Lc(n,e){return 3*(1-n)*n*n*e}function kc(n,e){return n*n*n*e}function ta(n,e,t,r,i){return Rc(n,e)+Bc(n,t)+Lc(n,r)+kc(n,i)}class Nc extends Ge{constructor(e=new D,t=new D,r=new D,i=new D){super(),this.start=e,this.startControl=t,this.endControl=r,this.end=i}getPoint(e,t=new D){const{start:r,startControl:i,endControl:s,end:o}=this;return t.set(ta(e,r.x,i.x,s.x,o.x),ta(e,r.y,i.y,s.y,o.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,r){const i=t*t-4*e*r;if(i<0)return[];const s=Math.sqrt(i),o=(-t+s)/(2*e),a=(-t-s)/(2*e);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(e=D.MAX,t=D.MIN){const r=this.start,i=this.startControl,s=this.endControl,o=this.end,a=this._solveQuadratic(3*(i.x-r.x),6*(s.x-i.x),3*(o.x-s.x)),l=this._solveQuadratic(3*(i.y-r.y),6*(s.y-i.y),3*(o.y-s.y)),h=[0,1,...a,...l];return((u,f)=>{for(const p of u)for(let y=0;y<=f;y++){const _=y/f-.5,m=Math.min(1,Math.max(0,p+_)),b=this.getPoint(m);e.x=Math.min(e.x,b.x),e.y=Math.min(e.y,b.y),t.x=Math.max(t.x,b.x),t.y=Math.max(t.y,b.y)}})(h,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:r,end:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:r.x,y2:r.y,x:i.x,y:i.y}]}drawTo(e){const{start:t,startControl:r,endControl:i,end:s}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Fc=new $t,ea=new $t,ra=new $t,Ti=new D;class $c extends Ge{constructor(e=new D,t=1,r=1,i=0,s=0,o=Math.PI*2,a=!1){super(),this.center=e,this.radiusX=t,this.radiusY=r,this.rotation=i,this.startAngle=s,this.endAngle=o,this.clockwise=a}isClockwise(){return this.clockwise}getPoint(e,t=new D){const r=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(s?i=0:i=r),this.clockwise&&!s&&(i===r?i=-r:i=i-r);const o=this.startAngle+e*i;let a=this.center.x+this.radiusX*Math.cos(o),l=this.center.y+this.radiusY*Math.sin(o);if(this.rotation!==0){const h=Math.cos(this.rotation),c=Math.sin(this.rotation),u=a-this.center.x,f=l-this.center.y;a=u*h-f*c+this.center.x,l=u*c+f*h+this.center.y}return t.set(a,l)}toCommands(){const{center:e,radiusX:t,radiusY:r,startAngle:i,endAngle:s,clockwise:o,rotation:a}=this,{x:l,y:h}=e,c=l+t*Math.cos(i)*Math.cos(a)-r*Math.sin(i)*Math.sin(a),u=h+t*Math.cos(i)*Math.sin(a)+r*Math.sin(i)*Math.cos(a),f=Math.abs(i-s),p=f>Math.PI?1:0,y=o?1:0,_=a*180/Math.PI;if(f>=2*Math.PI){const m=i+Math.PI,b=l+t*Math.cos(m)*Math.cos(a)-r*Math.sin(m)*Math.sin(a),w=h+t*Math.cos(m)*Math.sin(a)+r*Math.sin(m)*Math.cos(a);return[{type:"M",x:c,y:u},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:0,sweepFlag:y,x:b,y:w},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:0,sweepFlag:y,x:c,y:u}]}else{const m=l+t*Math.cos(s)*Math.cos(a)-r*Math.sin(s)*Math.sin(a),b=h+t*Math.cos(s)*Math.sin(a)+r*Math.sin(s)*Math.cos(a);return[{type:"M",x:c,y:u},{type:"A",rx:t,ry:r,angle:_,largeArcFlag:p,sweepFlag:y,x:m,y:b}]}}drawTo(e){const{center:t,radiusX:r,radiusY:i,rotation:s,startAngle:o,endAngle:a,clockwise:l}=this;return e.ellipse(t.x,t.y,r,i,s,o,a,!l),this}matrix(e){return Ti.set(this.center.x,this.center.y),Ti.applyMatrix3(e),this.center.x=Ti.x,this.center.y=Ti.y,Xc(e)?zc(this,e):Vc(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=D.MAX,t=D.MIN){const{center:r,radiusX:i,radiusY:s,rotation:o}=this,{x:a,y:l}=r,h=Math.cos(o),c=Math.sin(o),u=Math.sqrt(i*i*h*h+s*s*c*c),f=Math.sqrt(i*i*c*c+s*s*h*h);return e.x=Math.min(e.x,a-u),e.y=Math.min(e.y,l-f),t.x=Math.max(t.x,a+u),t.y=Math.max(t.y,l+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function zc(n,e){const t=n.radiusX,r=n.radiusY,i=Math.cos(n.rotation),s=Math.sin(n.rotation),o=new D(t*i,t*s),a=new D(-r*s,r*i),l=o.applyMatrix3(e),h=a.applyMatrix3(e),c=Fc.set(l.x,h.x,0,l.y,h.y,0,0,0,1),u=ea.copy(c).invert(),y=ra.copy(u).transpose().multiply(u).elements,_=jc(y[0],y[1],y[4]),m=Math.sqrt(_.rt1),b=Math.sqrt(_.rt2);if(n.radiusX=1/m,n.radiusY=1/b,n.rotation=Math.atan2(_.sn,_.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const x=ea.set(m,0,0,0,b,0,0,0,1),C=ra.set(_.cs,_.sn,0,-_.sn,_.cs,0,0,0,1),P=x.multiply(C).multiply(c),E=A=>{const{x:S,y:T}=new D(Math.cos(A),Math.sin(A)).applyMatrix3(P);return Math.atan2(T,S)};n.startAngle=E(n.startAngle),n.endAngle=E(n.endAngle),ia(e)&&(n.clockwise=!n.clockwise)}}function Vc(n,e){const t=sa(e),r=na(e);n.radiusX*=t,n.radiusY*=r;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);n.rotation+=i,ia(e)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function ia(n){const e=n.elements;return e[0]*e[4]-e[1]*e[3]<0}function Xc(n){const e=n.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const r=sa(n),i=na(n);return Math.abs(t/(r*i))>Number.EPSILON}function sa(n){const e=n.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function na(n){const e=n.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function jc(n,e,t){let r,i,s,o,a;const l=n+t,h=n-t,c=Math.sqrt(h*h+4*e*e);return l>0?(r=.5*(l+c),a=1/r,i=n*a*t-e*a*e):l<0?i=.5*(l-c):(r=.5*c,i=-.5*c),h>0?s=h+c:s=h-c,Math.abs(s)>2*Math.abs(e)?(a=-2*e/s,o=1/Math.sqrt(1+a*a),s=a*o):Math.abs(e)===0?(s=1,o=0):(a=-.5*s/e,s=1/Math.sqrt(1+a*a),o=a*s),h>0&&(a=s,s=-o,o=a),{rt1:r,rt2:i,cs:s,sn:o}}class js extends Ge{constructor(e=new D,t=new D){super(),this.start=e,this.end=t}getPoint(e,t=new D){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new D){return this.getPoint(e,t)}getTangent(e,t=new D){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new D){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=D.MAX,t=D.MIN){const{start:r,end:i}=this;return e.x=Math.min(e.x,r.x,i.x),e.y=Math.min(e.y,r.y,i.y),t.x=Math.max(t.x,r.x,i.x),t.y=Math.max(t.y,r.y,i.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:r}=this;return e.lineTo(t.x,t.y),e.lineTo(r.x,r.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class Gc extends Ge{constructor(e=new D,t=new D,r=new D){super(),this.start=e,this.control=t,this.end=r}getPoint(e,t=new D){const{start:r,control:i,end:s}=this;return t.set(Jo(e,r.x,i.x,s.x),Jo(e,r.y,i.y,s.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=D.MAX,t=D.MIN){const{start:r,control:i,end:s}=this,o=.5*(r.x+i.x),a=.5*(r.y+i.y),l=.5*(r.x+s.x),h=.5*(r.y+s.y);return e.x=Math.min(e.x,r.x,s.x,o,l),e.y=Math.min(e.y,r.y,s.y,a,h),t.x=Math.max(t.x,r.x,s.x,o,l),t.y=Math.max(t.y,r.y,s.y,a,h),{min:e,max:t}}toCommands(){const{start:e,control:t,end:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:r.x,y:r.y}]}drawTo(e){const{start:t,control:r,end:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(r.x,r.y,i.x,i.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class qc extends Ge{constructor(t,r,i=1,s=0,o=1){super();d(this,"curves",[]);d(this,"curveT",0);this.center=t,this.rx=r,this.aspectRatio=i,this.start=s,this.end=o,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:r}=this.center,i=this.rx,s=this.rx/this.aspectRatio,o=[new D(t-i,r-s),new D(t+i,r-s),new D(t+i,r+s),new D(t-i,r+s)];for(let a=0;a<4;a++)this.curves.push(new js(o[a].clone(),o[(a+1)%4].clone()));return this}getCurve(t){let r=(t*(this.end-this.start)+this.start)%1;r<0&&(r+=1),r*=(1+this.aspectRatio)*2;let i;return r<this.aspectRatio?(i=0,this.curveT=r/this.aspectRatio):r<this.aspectRatio+1?(i=1,this.curveT=(r-this.aspectRatio)/1):r<2*this.aspectRatio+1?(i=2,this.curveT=(r-this.aspectRatio-1)/this.aspectRatio):(i=3,this.curveT=(r-2*this.aspectRatio-1)/1),this.curves[i]}getPoint(t,r){return this.getCurve(t).getPoint(this.curveT,r)}getPointAt(t,r){return this.getPoint(t,r)}getTangent(t,r){return this.getCurve(t).getTangent(this.curveT,r)}getNormal(t,r){return this.getCurve(t).getNormal(this.curveT,r)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=D.MAX,r=D.MIN){return this.curves.forEach(i=>i.getMinMax(t,r)),{min:t,max:r}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(r=>r.drawTo(t)),this}}class Yc extends Ge{constructor(e=[]){super(),this.points=e}getPoint(e,t=new D){const{points:r}=this,i=(r.length-1)*e,s=Math.floor(i),o=i-s,a=r[s===0?s:s-1],l=r[s],h=r[s>r.length-2?r.length-1:s+1],c=r[s>r.length-3?r.length-1:s+2];return t.set(Qo(o,a.x,l.x,h.x,c.x),Qo(o,a.y,l.y,h.y,c.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++)this.points.push(e.points[t].clone());return this}}class Br extends Ge{constructor(t){super();d(this,"curves",[]);d(this,"startPoint");d(this,"currentPoint");d(this,"autoClose",!1);d(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let r=1,i=t.length;r<i;r++){const{x:s,y:o}=t[r];this.lineTo(s,o)}return this}addCommands(t){return Zo(t,this),this}addData(t){return this.addCommands(Ko(t)),this}getPoint(t,r=new D){const i=t*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=i){const a=s[o]-i,l=this.curves[o],h=l.getLength();return l.getPointAt(h===0?0:1-a/h,r)}o++}return r}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let r=0;for(let i=0,s=this.curves.length;i<s;i++)r+=this.curves[i].getLength(),t.push(r);return this._cacheLengths=t,t}getSpacedPoints(t=40){const r=[];for(let i=0;i<=t;i++)r.push(this.getPoint(i/t));return this.autoClose&&r.push(r[0]),r}getPoints(t=12){const r=[],i=this.curves;let s;for(let o=0,a=i.length;o<a;o++){const h=i[o].getPoints(t);for(let c=0;c<h.length;c++){const u=h[c];s!=null&&s.equals(u)||(r.push(u),s=u)}}return this.autoClose&&r.length>1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r}_setCurrentPoint(t){return this.currentPoint=new D(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const r=this.currentPoint;r&&!t.equals(r)&&(this.curves.push(new js(r.clone(),t)),r.copy(t)),this.startPoint=void 0}return this}moveTo(t,r){return this.currentPoint=new D(t,r),this.startPoint=this.currentPoint.clone(),this}lineTo(t,r){const i=this.currentPoint;return i!=null&&i.equals({x:t,y:r})||this.curves.push(new js((i==null?void 0:i.clone())??new D,new D(t,r))),this._setCurrentPoint({x:t,y:r}),this}bezierCurveTo(t,r,i,s,o,a){const l=this.currentPoint;return l!=null&&l.equals({x:o,y:a})||this.curves.push(new Nc((l==null?void 0:l.clone())??new D,new D(t,r),new D(i,s),new D(o,a))),this._setCurrentPoint({x:o,y:a}),this}quadraticCurveTo(t,r,i,s){const o=this.currentPoint;return o!=null&&o.equals({x:i,y:s})||this.curves.push(new Gc((o==null?void 0:o.clone())??new D,new D(t,r),new D(i,s))),this._setCurrentPoint({x:i,y:s}),this}arc(t,r,i,s,o,a){return this.ellipse(t,r,i,i,0,s,o,a),this}relativeArc(t,r,i,s,o,a){const l=this.currentPoint??new D;return this.arc(t+l.x,r+l.y,i,s,o,a),this}arcTo(t,r,i,s,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,r,i,s,o,a,l,h=!0){const c=new $c(new D(t,r),i,s,o,a,l,!h);if(this.curves.length>0){const u=c.getPoint(0);(!this.currentPoint||!u.equals(this.currentPoint))&&this.lineTo(u.x,u.y)}return this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(t,r,i,s,o,a,l,h){const c=this.currentPoint??new D;return this.ellipse(t+c.x,r+c.y,i,s,o,a,l,h),this}rect(t,r,i,s){return this.curves.push(new qc(new D(t+i/2,r+s/2),i/2,i/s)),this._setCurrentPoint({x:t,y:r}),this}splineThru(t){const r=this.currentPoint??new D;return this.curves.push(new Yc([r].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=D.MAX,r=D.MIN){return this.curves.forEach(i=>i.getMinMax(t,r)),{min:t,max:r}}getBoundingBox(){const{min:t,max:r}=this.getMinMax();return new K(t.x,t.y,r.x-t.x,r.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var i;const r=(i=this.curves[0])==null?void 0:i.getPoint(0);return r&&t.moveTo(r.x,r.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var r;super.copy(t),this.curves=[];for(let i=0,s=t.curves.length;i<s;i++)this.curves.push(t.curves[i].clone());return this.autoClose=t.autoClose,this.currentPoint=(r=t.currentPoint)==null?void 0:r.clone(),this}}function Wc(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Hc(n,e,t,r){const i=e.clone().sub(n),s=r.clone().sub(t),o=t.clone().sub(n),a=i.cross(s);if(a===0)return new D((n.x+t.x)/2,(n.y+t.y)/2);const l=o.cross(s)/a;return Math.abs(l)>1?new D((n.x+t.x)/2,(n.y+t.y)/2):new D(n.x+l*i.x,n.y+l*i.y)}class zt{constructor(e,t={}){d(this,"currentPath",new Br);d(this,"paths",[this.currentPath]);d(this,"style");e&&(e instanceof zt?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e)),this.style=t}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof zt?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new Br().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:r,curves:i}=this.currentPath;return r!=null&&r.equals({x:e,y:t})||(i.length?(this.currentPath=new Br().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,r,i,s,o){return this.currentPath.bezierCurveTo(e,t,r,i,s,o),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}arc(e,t,r,i,s,o){return this.currentPath.arc(e,t,r,i,s,o),this}arcTo(e,t,r,i,s){return this.currentPath.arcTo(e,t,r,i,s),this}ellipse(e,t,r,i,s,o,a,l){return this.currentPath.ellipse(e,t,r,i,s,o,a,l),this}rect(e,t,r,i){return this.currentPath.rect(e,t,r,i),this}addCommands(e){return Zo(e,this),this}addData(e){return this.addCommands(Ko(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,r={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.scale(e,t,r)}),this}skew(e,t=0,r={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.skew(e,t,r)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(r=>{r.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),r=[],i=[],s=[];t.forEach((a,l)=>{const h=a.getControlPoints(),c=a.isClockwise();s[l]=h,i[l]=c;const u=h[0],f=h[h.length-1]??u;r.push({start:c?f:u,end:c?u:f,index:l})});const o=[];return r.forEach((a,l)=>{o[l]=[],r.forEach((h,c)=>{c!==l&&h.start.equals(a.end)&&o[l].push(h.index)})}),t.forEach((a,l)=>{const h=i[l];s[l].forEach(u=>{const f=a.getTForPoint(u),p=a.getNormal(f).scale(h?e:-e);u.add(p)})}),o.forEach((a,l)=>{const h=s[l];a.forEach(c=>{const u=s[c],f=Hc(h[h.length-1],h[h.length-2]??h[h.length-1],u[0],u[1]??u[0]);f&&(h[h.length-1].copy(f),u[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=D.MAX,t=D.MIN,r=!0){const i=this.strokeWidth;return this.getCurves().forEach(s=>{if(s.getMinMax(e,t),r&&i>1){const o=i/2,a=s.isClockwise(),l=[];for(let h=0;h<=1;h+=1/s.arcLengthDivisions){const c=s.getPoint(h),u=s.getNormal(h),f=u.clone().scale(a?o:-o),p=u.clone().scale(a?-o:o);l.push(c.clone().add(f),c.clone().add(p),c.clone().add({x:o,y:0}),c.clone().add({x:-o,y:0}),c.clone().add({x:0,y:o}),c.clone().add({x:0,y:-o}),c.clone().add({x:o,y:o}),c.clone().add({x:-o,y:-o}))}e.min(...l),t.max(...l)}}),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:r}=this.getMinMax(void 0,void 0,e);return new K(t.x,t.y,r.x-t.x,r.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Vs(e,t),this.paths.forEach(s=>{s.drawTo(e)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Vs(e,t),this.getControlPoints().forEach(s=>{e.moveTo(s.x,s.y),e.arc(s.x,s.y,4,0,Math.PI*2)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSVGPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[Wc(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const i in t)t[i]!==void 0&&(r+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${r}"></path>`}toSVGString(){const{x:e,y:t,width:r,height:i}=this.getBoundingBox(),s=this.toSVGPathString();return`<svg viewBox="${e} ${t} ${r} ${i}" width="${r}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...r}=e,{left:i,top:s,width:o,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=o*t,l.height=a*t,l.style.width=`${o}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(t,t),h.translate(-i,-s),this.drawTo(h,r)),l}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Zc="px",Kc=90,oa=["mm","cm","in","pt","pc","px"],aa={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function J(n){let e="px";if(typeof n=="string"||n instanceof String)for(let r=0,i=oa.length;r<i;r++){const s=oa[r];if(n.endsWith(s)){e=s,n=n.substring(0,n.length-s.length);break}}let t;return t=aa[e][Zc],t<0&&(t=aa[e].in*Kc),t*Number.parseFloat(n)}const Qc=new $t,Ei=new $t,la=new $t,ha=new $t;function Jc(n,e,t){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const r=tu(n);return t.length>0&&r.premultiply(t[t.length-1]),e.copy(r),t.push(r),r}function tu(n){const e=new $t,t=Qc;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&e.translate(J(n.getAttribute("x")),J(n.getAttribute("y"))),n.hasAttribute("transform")){const r=n.getAttribute("transform").split(")");for(let i=r.length-1;i>=0;i--){const s=r[i].trim();if(s==="")continue;const o=s.indexOf("("),a=s.length;if(o>0&&o<a){const l=s.slice(0,o),h=ue(s.slice(o+1));switch(t.identity(),l){case"translate":if(h.length>=1){const c=h[0];let u=0;h.length>=2&&(u=h[1]),t.translate(c,u)}break;case"rotate":if(h.length>=1){let c=0,u=0,f=0;c=h[0]*Math.PI/180,h.length>=3&&(u=h[1],f=h[2]),Ei.makeTranslation(-u,-f),la.makeRotation(c),ha.multiplyMatrices(la,Ei),Ei.makeTranslation(u,f),t.multiplyMatrices(Ei,ha)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function eu(n){return new zt().addPath(new Br().arc(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("r")||0),0,Math.PI*2))}function ru(n,e){if(!(!n.sheet||!n.sheet.cssRules||!n.sheet.cssRules.length))for(let t=0;t<n.sheet.cssRules.length;t++){const r=n.sheet.cssRules[t];if(r.type!==1)continue;const i=r.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim()),s={};for(let o=r.style.length,a=0;a<o;a++){const l=r.style.item(a);s[l]=r.style.getPropertyValue(l)}for(let o=0;o<i.length;o++)e[i[o]]=Object.assign(e[i[o]]||{},{...s})}}function iu(n){return new zt().addPath(new Br().ellipse(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("rx")||0),J(n.getAttribute("ry")||0),0,0,Math.PI*2))}function su(n){return new zt().moveTo(J(n.getAttribute("x1")||0),J(n.getAttribute("y1")||0)).lineTo(J(n.getAttribute("x2")||0),J(n.getAttribute("y2")||0))}function nu(n){const e=new zt,t=n.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const ou=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function au(n){var r;const e=new zt;let t=0;return(r=n.getAttribute("points"))==null||r.replace(ou,(i,s,o)=>{const a=J(s),l=J(o);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,i}),e.currentPath.autoClose=!0,e}const lu=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function hu(n){var r;const e=new zt;let t=0;return(r=n.getAttribute("points"))==null||r.replace(lu,(i,s,o)=>{const a=J(s),l=J(o);return t===0?e.moveTo(a,l):e.lineTo(a,l),t++,i}),e.currentPath.autoClose=!1,e}function cu(n){const e=J(n.getAttribute("x")||0),t=J(n.getAttribute("y")||0),r=J(n.getAttribute("rx")||n.getAttribute("ry")||0),i=J(n.getAttribute("ry")||n.getAttribute("rx")||0),s=J(n.getAttribute("width")),o=J(n.getAttribute("height")),a=1-.551915024494,l=new zt;return l.moveTo(e+r,t),l.lineTo(e+s-r,t),(r!==0||i!==0)&&l.bezierCurveTo(e+s-r*a,t,e+s,t+i*a,e+s,t+i),l.lineTo(e+s,t+o-i),(r!==0||i!==0)&&l.bezierCurveTo(e+s,t+o-i*a,e+s-r*a,t+o,e+s-r,t+o),l.lineTo(e+r,t+o),(r!==0||i!==0)&&l.bezierCurveTo(e+r*a,t+o,e,t+o-i*a,e,t+o-i),l.lineTo(e,t+i),(r!==0||i!==0)&&l.bezierCurveTo(e,t+i*a,e+r*a,t,e+r,t),l}function fe(n,e,t){e=Object.assign({},e);let r={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)r=Object.assign(r,t[`.${h[c]}`])}n.hasAttribute("id")&&(r=Object.assign(r,t[`#${n.getAttribute("id")}`]));for(let h=n.style.length,c=0;c<h;c++){const u=n.style.item(c),f=n.style.getPropertyValue(u);e[u]=f,r[u]=f}function i(h,c,u=s){n.hasAttribute(h)&&(e[c]=u(n.getAttribute(h))),r[h]&&(e[c]=u(r[h]))}function s(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function o(h){return Math.max(0,Math.min(1,J(h)))}function a(h){return Math.max(0,J(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>J(c))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",a),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",a),i("stroke-dasharray","strokeDasharray",l),i("stroke-dashoffset","strokeDashoffset",J),i("visibility","visibility"),e}function Gs(n,e,t=[],r={}){var u;if(n.nodeType!==1)return t;let i=!1,s=null,o={...e};switch(n.nodeName){case"svg":o=fe(n,o,r);break;case"style":ru(n,r);break;case"g":o=fe(n,o,r);break;case"path":o=fe(n,o,r),n.hasAttribute("d")&&(s=nu(n));break;case"rect":o=fe(n,o,r),s=cu(n);break;case"polygon":o=fe(n,o,r),s=au(n);break;case"polyline":o=fe(n,o,r),s=hu(n);break;case"circle":o=fe(n,o,r),s=eu(n);break;case"ellipse":o=fe(n,o,r),s=iu(n);break;case"line":o=fe(n,o,r),s=su(n);break;case"defs":i=!0;break;case"use":{o=fe(n,o,r);const p=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),y=(u=n.viewportElement)==null?void 0:u.getElementById(p);y?Gs(y,o,t,r):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(n);break}if(o.display==="none")return t;Object.assign(e,o);const a=new $t,l=[],h=Jc(n,a,l);s&&(s.matrix(a),t.push(s),s.style=e);const c=n.childNodes;for(let f=0,p=c.length;f<p;f++){const y=c[f];i&&y.nodeName!=="style"&&y.nodeName!=="defs"||Gs(y,e,t,r)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}const ca="data:image/svg+xml;",ua=`${ca}base64,`,fa=`${ca}charset=utf8,`;function da(n){if(typeof n=="string"){let e;n.startsWith(ua)?(n=n.substring(ua.length,n.length),e=atob(n)):n.startsWith(fa)?(n=n.substring(fa.length,n.length),e=decodeURIComponent(n)):e=n;const t=new DOMParser().parseFromString(e,"text/xml"),r=t.querySelector("parsererror");if(r)throw new Error(`${r.textContent??"parser error"}
|
|
27
|
-
${e}`);return t.documentElement}else return n}function pa(n){return Gs(da(n),{})}function Lr(n,e=!0){if(!n.length)return;const t=D.MAX,r=D.MIN;return n.forEach(i=>i.getMinMax(t,r,e)),new K(t.x,t.y,r.x-t.x,r.y-t.y)}function uu(){return{overflow:"visible",visibility:"visible",filter:"none",left:0,top:0,width:0,height:0,rotate:0,opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"50% 50%",backgroundImage:"none",backgroundColor:"transparent",shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,borderRadius:0,borderColor:"transparent",borderWidth:1}}function fu(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%",scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"50% 50%",shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function du(){return{...uu(),...fu()}}var St=Uint8Array,Yt=Uint16Array,qs=Int32Array,Mi=new St([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Si=new St([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ys=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ga=function(n,e){for(var t=new Yt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];for(var i=new qs(t[30]),r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return{b:t,r:i}},ma=ga(Mi,2),ya=ma.b,Ws=ma.r;ya[28]=258,Ws[258]=28;for(var _a=ga(Si,0),pu=_a.b,va=_a.r,Hs=new Yt(32768),rt=0;rt<32768;++rt){var Oe=(rt&43690)>>1|(rt&21845)<<1;Oe=(Oe&52428)>>2|(Oe&13107)<<2,Oe=(Oe&61680)>>4|(Oe&3855)<<4,Hs[rt]=((Oe&65280)>>8|(Oe&255)<<8)>>1}for(var de=function(n,e,t){for(var r=n.length,i=0,s=new Yt(e);i<r;++i)n[i]&&++s[n[i]-1];var o=new Yt(e);for(i=1;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(t){a=new Yt(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var h=i<<4|n[i],c=e-n[i],u=o[n[i]-1]++<<c,f=u|(1<<c)-1;u<=f;++u)a[Hs[u]>>l]=h}else for(a=new Yt(r),i=0;i<r;++i)n[i]&&(a[i]=Hs[o[n[i]-1]++]>>15-n[i]);return a},Ue=new St(288),rt=0;rt<144;++rt)Ue[rt]=8;for(var rt=144;rt<256;++rt)Ue[rt]=9;for(var rt=256;rt<280;++rt)Ue[rt]=7;for(var rt=280;rt<288;++rt)Ue[rt]=8;for(var kr=new St(32),rt=0;rt<32;++rt)kr[rt]=5;var gu=de(Ue,9,0),mu=de(Ue,9,1),yu=de(kr,5,0),_u=de(kr,5,1),Zs=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},se=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},Ks=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},Qs=function(n){return(n+7)/8|0},ba=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new St(n.subarray(e,t))},vu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ne=function(n,e,t){var r=new Error(e||vu[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,ne),!t)throw r;return r},bu=function(n,e,t,r){var i=n.length,s=0;if(!i||e.f&&!e.l)return t||new St(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new St(i*3));var h=function(Kt){var kt=t.length;if(Kt>kt){var Xt=new St(Math.max(kt*2,Kt));Xt.set(t),t=Xt}},c=e.f||0,u=e.p||0,f=e.b||0,p=e.l,y=e.d,_=e.m,m=e.n,b=i*8;do{if(!p){c=se(n,u,1);var w=se(n,u+1,3);if(u+=3,w)if(w==1)p=mu,y=_u,_=9,m=5;else if(w==2){var E=se(n,u,31)+257,A=se(n,u+10,15)+4,S=E+se(n,u+5,31)+1;u+=14;for(var T=new St(S),O=new St(19),$=0;$<A;++$)O[Ys[$]]=se(n,u+$*3,7);u+=A*3;for(var N=Zs(O),B=(1<<N)-1,M=de(O,N,1),$=0;$<S;){var L=M[se(n,u,B)];u+=L&15;var x=L>>4;if(x<16)T[$++]=x;else{var F=0,X=0;for(x==16?(X=3+se(n,u,3),u+=2,F=T[$-1]):x==17?(X=3+se(n,u,7),u+=3):x==18&&(X=11+se(n,u,127),u+=7);X--;)T[$++]=F}}var q=T.subarray(0,E),I=T.subarray(E);_=Zs(q),m=Zs(I),p=de(q,_,1),y=de(I,m,1)}else ne(1);else{var x=Qs(u)+4,C=n[x-4]|n[x-3]<<8,P=x+C;if(P>i){l&&ne(0);break}a&&h(f+C),t.set(n.subarray(x,P),f),e.b=f+=C,e.p=u=P*8,e.f=c;continue}if(u>b){l&&ne(0);break}}a&&h(f+131072);for(var R=(1<<_)-1,k=(1<<m)-1,z=u;;z=u){var F=p[Ks(n,u)&R],Y=F>>4;if(u+=F&15,u>b){l&&ne(0);break}if(F||ne(2),Y<256)t[f++]=Y;else if(Y==256){z=u,p=null;break}else{var H=Y-254;if(Y>264){var $=Y-257,j=Mi[$];H=se(n,u,(1<<j)-1)+ya[$],u+=j}var Q=y[Ks(n,u)&k],tt=Q>>4;Q||ne(3),u+=Q&15;var I=pu[tt];if(tt>3){var j=Si[tt];I+=Ks(n,u)&(1<<j)-1,u+=j}if(u>b){l&&ne(0);break}a&&h(f+131072);var st=f+H;if(f<I){var Zt=s-I,me=Math.min(I,st);for(Zt+f<0&&ne(3);f<me;++f)t[f]=r[Zt+f]}for(;f<st;++f)t[f]=t[f-I]}}e.l=p,e.p=z,e.b=f,e.f=c,p&&(c=1,e.m=_,e.d=y,e.n=m)}while(!c);return f!=t.length&&o?ba(t,0,f):t.subarray(0,f)},Pe=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8},Nr=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},Js=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return{t:Ca,l:0};if(i==1){var o=new St(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(P,E){return P.f-E.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],h=0,c=1,u=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=t[t[h].f<t[u].f?h++:u++],l=t[h!=c&&t[h].f<t[u].f?h++:u++],t[c++]={s:-1,f:a.f+l.f,l:a,r:l};for(var f=s[0].s,r=1;r<i;++r)s[r].s>f&&(f=s[r].s);var p=new Yt(f+1),y=tn(t[c-1],p,0);if(y>e){var r=0,_=0,m=y-e,b=1<<m;for(s.sort(function(E,A){return p[A.s]-p[E.s]||E.f-A.f});r<i;++r){var w=s[r].s;if(p[w]>e)_+=b-(1<<y-p[w]),p[w]=e;else break}for(_>>=m;_>0;){var x=s[r].s;p[x]<e?_-=1<<e-p[x]++-1:++r}for(;r>=0&&_;--r){var C=s[r].s;p[C]==e&&(--p[C],++_)}y=e}return{t:new St(p),l:y}},tn=function(n,e,t){return n.s==-1?Math.max(tn(n.l,e,t+1),tn(n.r,e,t+1)):e[n.s]=t},xa=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new Yt(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return{c:t.subarray(0,r),n:e}},Fr=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},wa=function(n,e,t){var r=t.length,i=Qs(e+2);n[i]=r&255,n[i+1]=r>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s<r;++s)n[i+s+4]=t[s];return(i+4+r)*8},Pa=function(n,e,t,r,i,s,o,a,l,h,c){Pe(e,c++,t),++i[256];for(var u=Js(i,15),f=u.t,p=u.l,y=Js(s,15),_=y.t,m=y.l,b=xa(f),w=b.c,x=b.n,C=xa(_),P=C.c,E=C.n,A=new Yt(19),S=0;S<w.length;++S)++A[w[S]&31];for(var S=0;S<P.length;++S)++A[P[S]&31];for(var T=Js(A,7),O=T.t,$=T.l,N=19;N>4&&!O[Ys[N-1]];--N);var B=h+5<<3,M=Fr(i,Ue)+Fr(s,kr)+o,L=Fr(i,f)+Fr(s,_)+o+14+3*N+Fr(A,O)+2*A[16]+3*A[17]+7*A[18];if(l>=0&&B<=M&&B<=L)return wa(e,c,n.subarray(l,l+h));var F,X,q,I;if(Pe(e,c,1+(L<M)),c+=2,L<M){F=de(f,p,0),X=f,q=de(_,m,0),I=_;var R=de(O,$,0);Pe(e,c,x-257),Pe(e,c+5,E-1),Pe(e,c+10,N-4),c+=14;for(var S=0;S<N;++S)Pe(e,c+3*S,O[Ys[S]]);c+=3*N;for(var k=[w,P],z=0;z<2;++z)for(var Y=k[z],S=0;S<Y.length;++S){var H=Y[S]&31;Pe(e,c,R[H]),c+=O[H],H>15&&(Pe(e,c,Y[S]>>5&127),c+=Y[S]>>12)}}else F=gu,X=Ue,q=yu,I=kr;for(var S=0;S<a;++S){var j=r[S];if(j>255){var H=j>>18&31;Nr(e,c,F[H+257]),c+=X[H+257],H>7&&(Pe(e,c,j>>23&31),c+=Mi[H]);var Q=j&31;Nr(e,c,q[Q]),c+=I[Q],Q>3&&(Nr(e,c,j>>5&8191),c+=Si[Q])}else Nr(e,c,F[j]),c+=X[j]}return Nr(e,c,F[256]),c+X[256]},xu=new qs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ca=new St(0),wu=function(n,e,t,r,i,s){var o=s.z||n.length,a=new St(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),h=s.l,c=(s.r||0)&7;if(e){c&&(l[0]=s.r>>3);for(var u=xu[e-1],f=u>>13,p=u&8191,y=(1<<t)-1,_=s.p||new Yt(32768),m=s.h||new Yt(y+1),b=Math.ceil(t/3),w=2*b,x=function(ye){return(n[ye]^n[ye+1]<<b^n[ye+2]<<w)&y},C=new qs(25e3),P=new Yt(288),E=new Yt(32),A=0,S=0,T=s.i||0,O=0,$=s.w||0,N=0;T+2<o;++T){var B=x(T),M=T&32767,L=m[B];if(_[M]=L,m[B]=M,$<=T){var F=o-T;if((A>7e3||O>24576)&&(F>423||!h)){c=Pa(n,l,0,C,P,E,S,O,N,T-N,c),O=A=S=0,N=T;for(var X=0;X<286;++X)P[X]=0;for(var X=0;X<30;++X)E[X]=0}var q=2,I=0,R=p,k=M-L&32767;if(F>2&&B==x(T-k))for(var z=Math.min(f,F)-1,Y=Math.min(32767,T),H=Math.min(258,F);k<=Y&&--R&&M!=L;){if(n[T+q]==n[T+q-k]){for(var j=0;j<H&&n[T+j]==n[T+j-k];++j);if(j>q){if(q=j,I=k,j>z)break;for(var Q=Math.min(k,j-2),tt=0,X=0;X<Q;++X){var st=T-k+X&32767,Zt=_[st],me=st-Zt&32767;me>tt&&(tt=me,L=st)}}}M=L,L=_[M],k+=M-L&32767}if(I){C[O++]=268435456|Ws[q]<<18|va[I];var Kt=Ws[q]&31,kt=va[I]&31;S+=Mi[Kt]+Si[kt],++P[257+Kt],++E[kt],$=T+q,++A}else C[O++]=n[T],++P[n[T]]}}for(T=Math.max(T,$);T<o;++T)C[O++]=n[T],++P[n[T]];c=Pa(n,l,h,C,P,E,S,O,N,T-N,c),h||(s.r=c&7|l[c/8|0]<<3,c-=7,s.h=m,s.p=_,s.i=T,s.w=$)}else{for(var T=s.w||0;T<o+h;T+=65535){var Xt=T+65535;Xt>=o&&(l[c/8|0]=h,Xt=o),c=wa(l,c+1,n.subarray(T,Xt))}s.i=o}return ba(a,0,r+Qs(c)+i)},Ta=function(){var n=1,e=0;return{p:function(t){for(var r=n,i=e,s=t.length|0,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}n=r,e=i},d:function(){return n%=65521,e%=65521,(n&255)<<24|(n&65280)<<8|(e&255)<<8|e>>8}}},Pu=function(n,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),o=new St(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return wu(n,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+e.mem,t,r,i)},Ea=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},Cu=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(n[0]=120,n[1]=r<<6|(e.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,e.dictionary){var i=Ta();i.p(e.dictionary),Ea(n,2,i.d())}},Tu=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&ne(6,"invalid zlib data"),(n[1]>>5&1)==+!e&&ne(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Eu(n,e){e||(e={});var t=Ta();t.p(n);var r=Pu(n,e,e.dictionary?6:2,4);return Cu(r,e),Ea(r,r.length-4,t.d()),r}function Mu(n,e){return bu(n.subarray(Tu(n,e),-4),{i:2},e,e)}var Su=typeof TextDecoder<"u"&&new TextDecoder,Au=0;try{Su.decode(Ca,{stream:!0}),Au=1}catch{}const Ou="modern-font";function $r(n,e){if(!n)throw new Error(`[${Ou}] ${e}`)}function Uu(n){if("buffer"in n){const e=n.buffer;return n.byteOffset>0||n.byteLength<n.buffer.byteLength?e.slice(n.byteOffset,n.byteOffset+n.byteLength):e}else return n}function fr(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Iu(n){let e="";for(let t=0,r=n.length,i;t<r;t++)i=n.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function Ai(n){n=Iu(n);const e=[];for(let t=0,r=n.length,i;t<r;t++)i=n.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Du(n){let e="";for(let t=0,r=n.length;t<r;t++)n[t]<127?e+=String.fromCharCode(n[t]):e+=`%${(256+n[t]).toString(16).slice(1)}`;return unescape(e)}function Ru(n){let e="";for(let t=0,r=n.length;t<r;t+=2)e+=String.fromCharCode((n[t]<<8)+n[t+1]);return e}var Bu=Object.defineProperty,At=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Bu(e,t,i),i};const zr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ot(){return function(n,e){Object.defineProperty(n.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class vt extends DataView{constructor(t,r,i,s){super(Uu(t),r,i);d(this,"cursor",0);this.littleEndian=s}readColumn(t){if(t.size){const r=Array.from({length:t.size},(i,s)=>this.read(t.type,t.offset+s));switch(t.type){case"char":return r.join("");default:return r}}else return this.read(t.type,t.offset)}writeColumn(t,r){t.size?Array.from({length:t.size},(i,s)=>{this.write(t.type,r[s],t.offset+s)}):this.write(t.type,r,t.offset)}read(t,r=this.cursor,i=this.littleEndian){var h;switch(t){case"char":return this.readChar(r);case"fixed":return this.readFixed(r,i);case"longDateTime":return this.readLongDateTime(r,i)}const s=`get${t.replace(/^\S/,c=>c.toUpperCase())}`,o=this,a=(h=o[s])==null?void 0:h.bind(o),l=a==null?void 0:a(r,i);return this.cursor+=zr[t],l}readUint24(t=this.cursor){const[r,i,s]=this.readBytes(t,3);return(r<<16)+(i<<8)+s}readBytes(t,r){r==null&&(r=t,t=this.cursor);const i=[];for(let s=0;s<r;++s)i.push(this.getUint8(t+s));return this.cursor=t+r,i}readString(t,r){const i=this.readBytes(t,r);let s="";for(let o=0,a=i.length;o<a;o++)s+=String.fromCharCode(i[o]);return s}readFixed(t,r){const i=this.readInt32(t,r)/65536;return Math.ceil(i*1e5)/1e5}readLongDateTime(t=this.cursor,r){const i=this.readUint32(t+4,r),s=new Date;return s.setTime(i*1e3+-20775456e5),s}readChar(t){return this.readString(t,1)}write(t,r,i=this.cursor,s=this.littleEndian){var c;switch(t){case"char":return this.writeChar(r,i);case"fixed":return this.writeFixed(r,i);case"longDateTime":return this.writeLongDateTime(r,i)}const o=`set${t.replace(/^\S/,u=>u.toUpperCase())}`,a=this,l=(c=a[o])==null?void 0:c.bind(a),h=l==null?void 0:l(i,r,s);return this.cursor+=zr[t.toLowerCase()],h}writeString(t="",r=this.cursor){const i=t.replace(/[^\x00-\xFF]/g,"11").length;this.seek(r);for(let s=0,o=t.length,a;s<o;++s)a=t.charCodeAt(s)||0,a>127?this.writeUint16(a):this.writeUint8(a);return this.cursor+=i,this}writeChar(t,r){return this.writeString(t,r)}writeFixed(t,r){return this.writeInt32(Math.round(t*65536),r),this}writeLongDateTime(t,r=this.cursor){typeof t>"u"?t=-20775456e5:typeof t.getTime=="function"?t=t.getTime():/^\d+$/.test(t)?t=+t:t=Date.parse(t);const s=Math.round((t- -20775456e5)/1e3);return this.writeUint32(0,r),this.writeUint32(s,r+4),this}writeBytes(t,r=this.cursor){let i;if(Array.isArray(t)){i=t.length;for(let s=0;s<i;++s)this.setUint8(r+s,t[s])}else{const s=fr(t);i=s.byteLength;for(let o=0;o<i;++o)this.setUint8(r+o,s.getUint8(o))}return this.cursor=r+i,this}seek(t){return this.cursor=t,this}}At([Ot()],vt.prototype,"readInt8"),At([Ot()],vt.prototype,"readInt16"),At([Ot()],vt.prototype,"readInt32"),At([Ot()],vt.prototype,"readUint8"),At([Ot()],vt.prototype,"readUint16"),At([Ot()],vt.prototype,"readUint32"),At([Ot()],vt.prototype,"readFloat32"),At([Ot()],vt.prototype,"readFloat64"),At([Ot()],vt.prototype,"writeInt8"),At([Ot()],vt.prototype,"writeInt16"),At([Ot()],vt.prototype,"writeInt32"),At([Ot()],vt.prototype,"writeUint8"),At([Ot()],vt.prototype,"writeUint16"),At([Ot()],vt.prototype,"writeUint32"),At([Ot()],vt.prototype,"writeFloat32"),At([Ot()],vt.prototype,"writeFloat64");const Ma=new WeakMap;function v(n){const e=typeof n=="object"?n:{type:n},{size:t=1,type:r}=e;return(i,s)=>{if(typeof s!="string")return;let o=Ma.get(i);o||(o={columns:[],byteLength:0},Ma.set(i,o));const a={...e,name:s,byteLength:t*zr[r],offset:e.offset??o.columns.reduce((l,h)=>l+h.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,h)=>l+zr[h.type]*(h.size??1),0),Object.defineProperty(i.constructor.prototype,s,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class Wt{constructor(e,t,r,i){d(this,"view");this.view=new vt(e,t,r,i)}}class Oi extends Wt{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Lu=Object.defineProperty,Dt=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Lu(e,t,i),i};const Rt=class Il extends Oi{constructor(){super(...arguments);d(this,"format","EmbeddedOpenType");d(this,"mimeType","application/vnd.ms-fontobject")}static from(t){const r=t.sfnt,s=r.name.names,o=Ai(s.fontFamily||""),a=o.length,l=Ai(s.fontStyle||""),h=l.length,c=Ai(s.version||""),u=c.length,f=Ai(s.fullName||""),p=f.length,y=86+a+4+h+4+u+4+p+2+t.view.byteLength,_=new Il(new ArrayBuffer(y),0,y,!0);_.EOTSize=_.view.byteLength,_.FontDataSize=t.view.byteLength,_.Version=131073,_.Flags=0,_.Charset=1,_.MagicNumber=20556,_.Padding1=0,_.CheckSumAdjustment=r.head.checkSumAdjustment;const m=r.os2;return m&&(_.FontPANOSE=m.fontPANOSE,_.Italic=m.fsSelection,_.Weight=m.usWeightClass,_.fsType=m.fsType,_.UnicodeRange=m.ulUnicodeRange,_.CodePageRange=m.ulCodePageRange),_.view.writeUint16(a),_.view.writeBytes(o),_.view.writeUint16(0),_.view.writeUint16(h),_.view.writeBytes(l),_.view.writeUint16(0),_.view.writeUint16(u),_.view.writeBytes(c),_.view.writeUint16(0),_.view.writeUint16(p),_.view.writeBytes(f),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(t.view),_}};Dt([v("uint32")],Rt.prototype,"EOTSize"),Dt([v("uint32")],Rt.prototype,"FontDataSize"),Dt([v("uint32")],Rt.prototype,"Version"),Dt([v("uint32")],Rt.prototype,"Flags"),Dt([v({type:"uint8",size:10})],Rt.prototype,"FontPANOSE"),Dt([v("uint8")],Rt.prototype,"Charset"),Dt([v("uint8")],Rt.prototype,"Italic"),Dt([v("uint32")],Rt.prototype,"Weight"),Dt([v("uint16")],Rt.prototype,"fsType"),Dt([v("uint16")],Rt.prototype,"MagicNumber"),Dt([v({type:"uint8",size:16})],Rt.prototype,"UnicodeRange"),Dt([v({type:"uint8",size:8})],Rt.prototype,"CodePageRange"),Dt([v("uint32")],Rt.prototype,"CheckSumAdjustment"),Dt([v({type:"uint8",size:16})],Rt.prototype,"Reserved"),Dt([v("uint16")],Rt.prototype,"Padding1");var ku=Object.defineProperty,Ui=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ku(e,t,i),i};class dr extends Wt{constructor(e,t){super(e,t,16)}}Ui([v({type:"char",size:4})],dr.prototype,"tag"),Ui([v("uint32")],dr.prototype,"checkSum"),Ui([v("uint32")],dr.prototype,"offset"),Ui([v("uint32")],dr.prototype,"length");const en=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Nu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class rn{constructor(e){d(this,"index");d(this,"name");d(this,"isComposite",!1);d(this,"components",[]);d(this,"pathCommands",[]);const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*r,{xScale:a=o,yScale:l=o}=i,h=this.pathCommands,c=[];for(let u=0,f=h.length;u<f;u+=1){const p=h[u];p.type==="M"?c.push({type:"M",x:e+p.x*a,y:t+-p.y*l}):p.type==="L"?c.push({type:"L",x:e+p.x*a,y:t+-p.y*l}):p.type==="Q"?c.push({type:"Q",x1:e+p.x1*a,y1:t+-p.y1*l,x:e+p.x*a,y:t+-p.y*l}):p.type==="C"?c.push({type:"C",x1:e+p.x1*a,y1:t+-p.y1*l,x2:e+p.x2*a,y2:t+-p.y2*l,x:e+p.x*a,y:t+-p.y*l}):p.type==="Z"&&c.push({type:"Z"})}return c}}class Fu extends rn{parse(e,t,r){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,h=e.topDict.paintType,c=this.index;let u,f,p,y;const _=[],m=[];let b=0,w=!1,x=!1,C=o,P=0,E=0;function A(M,L){_.push({type:"L",x:M,y:L})}function S(M,L,F,X,q,I){_.push({type:"C",x1:M,y1:L,x2:F,y2:X,x:q,y:I})}function T(M,L){x&&h!==2&&O(),x=!0,_.push({type:"M",x:M,y:L})}function O(){_.push({type:"Z"})}function $(M){_.push(...M)}function N(){m.length%2!==0&&!w&&(C=m.shift()+s),b+=m.length>>1,m.length=0,w=!0}function B(M){let L,F,X,q,I,R,k,z,Y,H,j,Q,tt=0;for(;tt<M.length;){let st=M[tt++];switch(st){case 1:N();break;case 3:N();break;case 4:m.length>1&&!w&&(C=m.shift()+s,w=!0),E+=m.pop(),T(P,E);break;case 5:for(;m.length>0;)P+=m.shift(),E+=m.shift(),A(P,E);break;case 6:for(;m.length>0&&(P+=m.shift(),A(P,E),m.length!==0);)E+=m.shift(),A(P,E);break;case 7:for(;m.length>0&&(E+=m.shift(),A(P,E),m.length!==0);)P+=m.shift(),A(P,E);break;case 8:for(;m.length>0;)u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);break;case 10:I=m.pop()+l,R=e.subrs[I],R&&B(R);break;case 11:return;case 12:switch(st=M[tt],tt+=1,st){case 35:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y+m.shift(),Y=k+m.shift(),H=z+m.shift(),j=Y+m.shift(),Q=H+m.shift(),P=j+m.shift(),E=Q+m.shift(),m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 34:u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y,Y=k+m.shift(),H=y,j=Y+m.shift(),Q=E,P=j+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 36:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y,Y=k+m.shift(),H=y,j=Y+m.shift(),Q=H+m.shift(),P=j+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;case 37:u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),k=p+m.shift(),z=y+m.shift(),Y=k+m.shift(),H=z+m.shift(),j=Y+m.shift(),Q=H+m.shift(),Math.abs(j-P)>Math.abs(Q-E)?P=j+m.shift():E=Q+m.shift(),S(u,f,p,y,k,z),S(Y,H,j,Q,P,E);break;default:console.warn(`Glyph ${c}: unknown operator ${1200+st}`),m.length=0}break;case 14:if(m.length>=4){const Zt=en[m.pop()],me=en[m.pop()],Kt=m.pop(),kt=m.pop();if(Zt&&me){i.isComposite=!0,i.components=[];const Xt=e.charset.indexOf(Zt),ye=e.charset.indexOf(me);i.components.push({glyphIndex:ye,dx:0,dy:0}),i.components.push({glyphIndex:Xt,dx:kt,dy:Kt}),$(r.get(ye).pathCommands);const oe=JSON.parse(JSON.stringify(r.get(Xt).pathCommands));for(let ae=0;ae<oe.length;ae+=1){const wt=oe[ae];wt.type!=="Z"&&(wt.x+=kt,wt.y+=Kt),(wt.type==="Q"||wt.type==="C")&&(wt.x1+=kt,wt.y1+=Kt),wt.type==="C"&&(wt.x2+=kt,wt.y2+=Kt)}$(oe)}}else m.length>0&&!w&&(C=m.shift()+s,w=!0);x&&h!==2&&(O(),x=!1);break;case 18:N();break;case 19:case 20:N(),tt+=b+7>>3;break;case 21:m.length>2&&!w&&(C=m.shift()+s,w=!0),E+=m.pop(),P+=m.pop(),T(P,E);break;case 22:m.length>1&&!w&&(C=m.shift()+s,w=!0),P+=m.pop(),T(P,E);break;case 23:N();break;case 24:for(;m.length>2;)u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);P+=m.shift(),E+=m.shift(),A(P,E);break;case 25:for(;m.length>6;)P+=m.shift(),E+=m.shift(),A(P,E);u=P+m.shift(),f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+m.shift(),S(u,f,p,y,P,E);break;case 26:for(m.length%2&&(P+=m.shift());m.length>0;)u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p,E=y+m.shift(),S(u,f,p,y,P,E);break;case 27:for(m.length%2&&(E+=m.shift());m.length>0;)u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y,S(u,f,p,y,P,E);break;case 28:L=M[tt],F=M[tt+1],m.push((L<<24|F<<16)>>16),tt+=2;break;case 29:I=m.pop()+a,R=e.gsubrs[I],R&&B(R);break;case 30:for(;m.length>0&&(u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+(m.length===1?m.shift():0),S(u,f,p,y,P,E),m.length!==0);)u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),E=y+m.shift(),P=p+(m.length===1?m.shift():0),S(u,f,p,y,P,E);break;case 31:for(;m.length>0&&(u=P+m.shift(),f=E,p=u+m.shift(),y=f+m.shift(),E=y+m.shift(),P=p+(m.length===1?m.shift():0),S(u,f,p,y,P,E),m.length!==0);)u=P,f=E+m.shift(),p=u+m.shift(),y=f+m.shift(),P=p+m.shift(),E=y+(m.length===1?m.shift():0),S(u,f,p,y,P,E);break;default:st<32?console.warn(`Glyph ${c}: unknown operator ${st}`):st<247?m.push(st-139):st<251?(L=M[tt],tt+=1,m.push((st-247)*256+L+108)):st<255?(L=M[tt],tt+=1,m.push(-(st-251)*256-L-108)):(L=M[tt],F=M[tt+1],X=M[tt+2],q=M[tt+3],tt+=4,m.push((L<<24|F<<16|X<<8|q)/65536))}}}B(t),this.pathCommands=_,w&&(this.advanceWidth=C)}}class sn{constructor(e){d(this,"_items",[]);this._sfnt=e}get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const s=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);s&&(r.unicode??(r.unicode=s[0]),r.unicodes??(r.unicodes=s)),this._items[e]=r}return r}}class $u extends sn{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new Fu({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var zu=Object.defineProperty,Sa=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&zu(e,t,i),i};class Ii extends Wt{constructor(t,r,i,s){super(t,r,i,s);d(this,"_offsets");d(this,"_objects");this._init()}get offsets(){return this._offsets??(this._offsets=this.readOffsets())}get objects(){return this._objects??(this._objects=this.readObjects())}_init(){const t=this.view,r=this.count,i=this.offsetSize;this.objectOffset=(r+1)*i+2,this.endOffset=t.byteOffset+this.objectOffset+this.offsets[r]}readOffsets(){const t=this.view,r=this.count,i=this.offsetSize;t.seek(3);const s=[];for(let o=0,a=r+1;o<a;o++){const l=this.view;let h=0;for(let c=0;c<i;c++)h<<=8,h+=l.readUint8();s.push(h)}return s}readObjects(){const t=[];for(let r=0,i=this.count;r<i;r++)t.push(this.get(r));return t}get(t){const r=this.offsets,i=this.objectOffset,s=i+r[t],a=i+r[t+1]-s;return this._isString?this.view.readString(s,a):this.view.readBytes(s,a)}}Sa([v("uint16")],Ii.prototype,"count"),Sa([v("uint8")],Ii.prototype,"offsetSize");class Di extends Ii{constructor(){super(...arguments);d(this,"_isString",!1)}}class Aa extends Ii{constructor(){super(...arguments);d(this,"_isString",!0)}}const Vu=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Xu=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],ju=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Gu=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function Ri(n,e){return e<=390?Vu[e]:n[e-391]}function it(n,e="number",t){return(r,i)=>{if(typeof i!="string")return;const s={type:e,operator:n,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(s)},set(o){this._setProp(s,o)},configurable:!0,enumerable:!0})}}class Oa extends Wt{constructor(){super(...arguments);d(this,"_dict");d(this,"_stringIndex")}get dict(){return this._dict??(this._dict=this._readDict())}setStringIndex(t){return this._stringIndex=t,this}_readFloatOperand(){const t=this.view;let r="";const i=15,s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const o=t.readUint8(),a=o>>4,l=o&15;if(a===i||(r+=s[a],l===i))break;r+=s[l]}return Number.parseFloat(r)}_readOperand(t){const r=this.view;let i,s,o,a;if(t===28)return i=r.readUint8(),s=r.readUint8(),i<<8|s;if(t===29)return i=r.readUint8(),s=r.readUint8(),o=r.readUint8(),a=r.readUint8(),i<<24|s<<16|o<<8|a;if(t===30)return this._readFloatOperand();if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return i=r.readUint8(),(t-247)*256+i+108;if(t>=251&&t<=254)return i=r.readUint8(),-(t-251)*256-i-108;throw new Error(`invalid b0 ${t}, at: ${r.cursor}`)}_readDict(){const t=this.view;t.seek(0);let r=[];const i=t.cursor+t.byteLength,s={};for(;t.cursor<i;){let o=t.readUint8();o<=21?(o===12&&(o=1200+t.readUint8()),s[o]=r,r=[]):r.push(this._readOperand(o))}return s}_getProp(t){var i;const r=this.dict[t.operator]??t.default;switch(t.type){case"number":return r[0];case"string":return Ri(((i=this._stringIndex)==null?void 0:i.objects)??[],r[0]);case"number[]":return r}return r}_setProp(t,r){}}var qu=Object.defineProperty,nn=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&qu(e,t,i),i};class Bi extends Oa{}nn([it(19)],Bi.prototype,"subrs"),nn([it(20)],Bi.prototype,"defaultWidthX"),nn([it(21)],Bi.prototype,"nominalWidthX");var Yu=Object.defineProperty,ut=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Yu(e,t,i),i};class ht extends Oa{}ut([it(0,"string")],ht.prototype,"version"),ut([it(1,"string")],ht.prototype,"notice"),ut([it(1200,"string")],ht.prototype,"copyright"),ut([it(2,"string")],ht.prototype,"fullName"),ut([it(3,"string")],ht.prototype,"familyName"),ut([it(4,"string")],ht.prototype,"weight"),ut([it(1201)],ht.prototype,"isFixedPitch"),ut([it(1202)],ht.prototype,"italicAngle"),ut([it(1203,"number",-100)],ht.prototype,"underlinePosition"),ut([it(1204,"number",50)],ht.prototype,"underlineThickness"),ut([it(1205)],ht.prototype,"paintType"),ut([it(1206,"number",2)],ht.prototype,"charstringType"),ut([it(1207,"number[]",[.001,0,0,.001,0,0])],ht.prototype,"fontMatrix"),ut([it(13)],ht.prototype,"uniqueId"),ut([it(5,"number[]",[0,0,0,0])],ht.prototype,"fontBBox"),ut([it(1208)],ht.prototype,"strokeWidth"),ut([it(14)],ht.prototype,"xuid"),ut([it(15)],ht.prototype,"charset"),ut([it(16)],ht.prototype,"encoding"),ut([it(17)],ht.prototype,"charStrings"),ut([it(18,"number[]",[0,0])],ht.prototype,"private");function Pt(n,e=n){return t=>{qe.tableDefinitions.set(n,{tag:n,prop:e,class:t}),Object.defineProperty(qe.prototype,e,{get(){return this.get(n)},set(r){return this.set(n,r)},configurable:!0,enumerable:!0})}}const rr=class rr{constructor(e){d(this,"tables",new Map);d(this,"tableViews",new Map);(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,s=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)s[a]=t.get(r[a])||o;return s}getPathCommands(e,t,r,i,s){const o=[];return this.forEachGlyph(e,t,r,i,s,(a,l,h,c,u)=>{o.push(...a.getPathCommands(l,h,c,u,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,s={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let h=0;h<l.length;h+=1){const c=l[h];o.call(this,c,t,r,i,s),c.advanceWidth&&(t+=c.advanceWidth*a),s.letterSpacing?t+=s.letterSpacing*i:s.tracking&&(t+=s.tracking/1e3*i)}return t}clone(){return new rr(this.tableViews)}delete(e){const t=rr.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=rr.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=rr.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const s=this.tableViews.get(e);if(!s)return;r=new i(s.buffer,s.byteOffset,s.byteLength).setSfnt(this),this.tables.set(t.prop,r)}}return r}};d(rr,"tableDefinitions",new Map);let qe=rr;class Ut extends Wt{setSfnt(e){return this._sfnt=e,this}getSfnt(){return this._sfnt}}var Wu=Object.defineProperty,Hu=Object.getOwnPropertyDescriptor,Vr=(n,e,t,r)=>{for(var i=r>1?void 0:r?Hu(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Wu(e,t,i),i};let Ye=class extends Ut{constructor(e,t,r,i){super(e,t,r,i);d(this,"_glyphs");d(this,"privateDict");d(this,"subrsIndex");this._init()}get glyphs(){return this._glyphs??(this._glyphs=new $u(this._sfnt))}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}get defaultWidthX(){var e;return((e=this.privateDict)==null?void 0:e.defaultWidthX)??0}get nominalWidthX(){var e;return((e=this.privateDict)==null?void 0:e.nominalWidthX)??0}get subrs(){var e;return((e=this.subrsIndex)==null?void 0:e.objects)??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}_init(){const e=this.view,{buffer:t,byteOffset:r}=e,i=r+4;this.nameIndex=new Aa(t,i),this.topDictIndex=new Di(t,this.nameIndex.endOffset),this.stringIndex=new Aa(t,this.topDictIndex.endOffset),this.globalSubrIndex=new Di(t,this.stringIndex.endOffset),this.topDict=new ht(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const s=this.topDict.private[0],o=this.topDict.private[1];s&&(this.privateDict=new Bi(t,r+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Di(t,r+o+this.privateDict.subrs))),this.charStringsIndex=new Di(t,r+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=Xu:this.topDict.charset===1?this.charset=ju:this.topDict.charset===2?this.charset=Gu:this.charset=this._readCharset(r+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=en:this.topDict.encoding===1?this.encoding=Nu:this.encoding=this._readEncoding(r+this.topDict.encoding)}_readCharset(e,t,r){const i=this.view;i.seek(e);let s,o,a;t-=1;const l=[".notdef"],h=i.readUint8();if(h===0)for(s=0;s<t;s+=1)o=i.readUint16(),l.push(Ri(r,o));else if(h===1)for(;l.length<=t;)for(o=i.readUint16(),a=i.readUint8(),s=0;s<=a;s+=1)l.push(Ri(r,o)),o+=1;else if(h===2)for(;l.length<=t;)for(o=i.readUint16(),a=i.readUint16(),s=0;s<=a;s+=1)l.push(Ri(r,o)),o+=1;else throw new Error(`Unknown charset format ${h}`);return l}_readEncoding(e){const t=this.view;t.seek(e);let r,i;const s={},o=t.readUint8();if(o===0){const a=t.readUint8();for(r=0;r<a;r+=1)i=t.readUint8(),s[i]=r}else if(o===1){const a=t.readUint8();for(i=1,r=0;r<a;r+=1){const l=t.readUint8(),h=t.readUint8();for(let c=l;c<=l+h;c+=1)s[c]=i,i+=1}}else console.warn(`unknown encoding format:${o}`);return s}_calcSubroutineBias(e){let t;return e.length<1240?t=107:e.length<33900?t=1131:t=32768,t}};Vr([v("uint8")],Ye.prototype,"majorVersion",2),Vr([v("uint8")],Ye.prototype,"minorVersion",2),Vr([v("uint8")],Ye.prototype,"headerSize",2),Vr([v("uint8")],Ye.prototype,"offsetSize",2),Ye=Vr([Pt("CFF ","cff")],Ye);var Zu=Object.defineProperty,Li=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Zu(e,t,i),i};const Xr=class Dl extends Wt{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new Dl;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};Li([v("uint16")],Xr.prototype,"format"),Li([v("uint16")],Xr.prototype,"length"),Li([v("uint16")],Xr.prototype,"language"),Li([v({type:"uint8",size:256})],Xr.prototype,"glyphIndexArray");let on=Xr;var Ku=Object.defineProperty,an=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Ku(e,t,i),i};class jr extends Wt{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,s=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(h=>h===i);let l=0;for(let h=0;h<256;h++)if(r[h]===0)h>=a||h<s[0].firstCode||h>=s[0].firstCode+s[0].entryCount||s[0].idRangeOffset+(h-s[0].firstCode)>=o.length?l=0:(l=o[s[0].idRangeOffset+(h-s[0].firstCode)],l!==0&&(l=l+s[0].idDelta)),l!==0&&l<e&&t.set(h,l);else{const c=r[h];for(let u=0,f=s[c].entryCount;u<f;u++)if(s[c].idRangeOffset+u>=o.length?l=0:(l=o[s[c].idRangeOffset+u],l!==0&&(l=l+s[c].idDelta)),l!==0&&l<e){const p=(h<<8|u+s[c].firstCode)%65535;t.set(p,l)}}return t}}an([v("uint16")],jr.prototype,"format"),an([v("uint16")],jr.prototype,"length"),an([v("uint16")],jr.prototype,"language");function Ua(n){return n>32767?n-65536:n<-32767?n+65536:n}function ln(n,e){let t;const r=[];let i={};return n.forEach((s,o)=>{e&&o>e||((!t||o!==t.unicode+1||s!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:s,delta:Ua(s-o)}):(i.start=Number(o),i.startId=s,i.delta=Ua(s-o))),t={unicode:o,glyphIndex:s})}),t&&(i.end=t.unicode,r.push(i)),r}var Qu=Object.defineProperty,We=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Qu(e,t,i),i};const Ie=class Rl extends Wt{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=ln(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),s=2*2**i,o=new Rl(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=s,o.entrySelector=i,o.rangeShift=2*r-s,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,s=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<t;++h)for(let c=i[h],u=s[h];c<=u;++c)if(o[h]===0)e.set(c,(c+a[h])%65536);else{const f=h+o[h]/2+(c-i[h])-r,p=l[f];p!==0?e.set(c,(p+a[h])%65536):e.set(c,0)}return e.delete(65535),e}};We([v("uint16")],Ie.prototype,"format"),We([v("uint16")],Ie.prototype,"length"),We([v("uint16")],Ie.prototype,"language"),We([v("uint16")],Ie.prototype,"segCountX2"),We([v("uint16")],Ie.prototype,"searchRange"),We([v("uint16")],Ie.prototype,"entrySelector"),We([v("uint16")],Ie.prototype,"rangeShift");let hn=Ie;var Ju=Object.defineProperty,Gr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Ju(e,t,i),i};class He extends Wt{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}Gr([v("uint16")],He.prototype,"format"),Gr([v("uint16")],He.prototype,"length"),Gr([v("uint16")],He.prototype,"language"),Gr([v("uint16")],He.prototype,"firstCode"),Gr([v("uint16")],He.prototype,"entryCount");var tf=Object.defineProperty,qr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&tf(e,t,i),i};const pr=class Bl extends Wt{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=ln(e),r=new Bl(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const s=t[r];let o=s.startGlyphCode,a=s.startCharCode;const l=s.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};qr([v("uint16")],pr.prototype,"format"),qr([v("uint16")],pr.prototype,"reserved"),qr([v("uint32")],pr.prototype,"length"),qr([v("uint32")],pr.prototype,"language"),qr([v("uint32")],pr.prototype,"nGroups");let cn=pr;var ef=Object.defineProperty,un=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&ef(e,t,i),i};class Yr extends Wt{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:s}=t[r];s.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}un([v("uint16")],Yr.prototype,"format"),un([v("uint32")],Yr.prototype,"length"),un([v("uint32")],Yr.prototype,"numVarSelectorRecords");var rf=Object.defineProperty,sf=Object.getOwnPropertyDescriptor,fn=(n,e,t,r)=>{for(var i=r>1?void 0:r?sf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&rf(e,t,i),i};let gr=class extends Ut{constructor(){super(...arguments);d(this,"_unicodeToGlyphIndexMap");d(this,"_glyphIndexToUnicodesMap")}static from(e){const t=Array.from(e.keys()).some(u=>u>65535),r=hn.from(e),i=on.from(e),s=t?cn.from(e):void 0,o=4+(s?32:24),a=o+r.view.byteLength,l=a+i.view.byteLength,h=[{platformID:0,platformSpecificID:3,offset:o},{platformID:1,platformSpecificID:0,offset:a},{platformID:3,platformSpecificID:1,offset:o},s&&{platformID:3,platformSpecificID:10,offset:l}].filter(Boolean),c=new gr(new ArrayBuffer(4+8*h.length+r.view.byteLength+i.view.byteLength+((s==null?void 0:s.view.byteLength)??0)));return c.numberSubtables=h.length,c.view.seek(4),h.forEach(u=>{c.view.writeUint16(u.platformID),c.view.writeUint16(u.platformSpecificID),c.view.writeUint32(u.offset)}),c.view.writeBytes(r.view,o),c.view.writeBytes(i.view,a),s&&c.view.writeBytes(s.view,l),c}get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??(this._unicodeToGlyphIndexMap=this.readunicodeToGlyphIndexMap())}get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const e=new Map,t=this.unicodeToGlyphIndexMap,r=Array.from(t.keys());for(let i=0,s=r.length;i<s;i++){const o=r[i],a=t.get(o);e.has(a)?e.get(a).push(o):e.set(a,[o])}this._glyphIndexToUnicodesMap=e}return this._glyphIndexToUnicodesMap}readSubtables(){const e=this.numberSubtables;return this.view.seek(4),Array.from({length:e},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(t=>{this.view.seek(t.offset);const r=this.view.readUint16();let i;switch(r){case 0:i=new on(this.view.buffer,t.offset);break;case 2:i=new jr(this.view.buffer,t.offset,this.view.readUint16());break;case 4:i=new hn(this.view.buffer,t.offset,this.view.readUint16());break;case 6:i=new He(this.view.buffer,t.offset,this.view.readUint16());break;case 12:i=new cn(this.view.buffer,t.offset,this.view.readUint32(t.offset+4));break;case 14:default:i=new Yr(this.view.buffer,t.offset,this.view.readUint32());break}return{...t,format:r,view:i}})}readunicodeToGlyphIndexMap(){var a,l,h,c,u;const e=this.readSubtables(),t=(a=e.find(f=>f.format===0))==null?void 0:a.view,r=(l=e.find(f=>f.platformID===3&&f.platformSpecificID===3&&f.format===2))==null?void 0:l.view,i=(h=e.find(f=>f.platformID===3&&f.platformSpecificID===1&&f.format===4))==null?void 0:h.view,s=(c=e.find(f=>f.platformID===3&&f.platformSpecificID===10&&f.format===12))==null?void 0:c.view,o=(u=e.find(f=>f.platformID===0&&f.platformSpecificID===5&&f.format===14))==null?void 0:u.view;return new Map([...(t==null?void 0:t.getUnicodeToGlyphIndexMap())??[],...(r==null?void 0:r.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(i==null?void 0:i.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};fn([v("uint16")],gr.prototype,"version",2),fn([v("uint16")],gr.prototype,"numberSubtables",2),gr=fn([Pt("cmap")],gr);class nf extends rn{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const s=e[i];r.push(s),s.lastPointOfContour&&(t.push(r),r=[])}return $r(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const s=e[i],o={x:t.xScale*s.x+t.scale10*s.y+t.dx,y:t.scale01*s.x+t.yScale*s.y+t.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,s){let o;return(t&i)>0?(o=e.view.readUint8(),t&s||(o=-o),o=r+o):(t&s)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let _=0;_<i;_++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();$r(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let _=0;_<l;++_)h.push(e.view.readUint8());const c=e.view.byteOffset,u=a[a.length-1]+1;$r(u<2e4,`Bad numberOfCoordinates:${c}`);const f=[];let p,y=0;for(;y<u;)if(p=e.view.readUint8(),f.push(p),y++,p&8&&y<u){const _=e.view.readUint8();for(let m=0;m<_;m++)f.push(p),y++}if($r(f.length===u,`Bad flags length: ${f.length}, numberOfCoordinates: ${u}`),a.length>0){const _=[];let m;if(u>0){for(let x=0;x<u;x+=1)p=f[x],m={},m.onCurve=!!(p&1),m.lastPointOfContour=a.includes(x),_.push(m);let b=0;for(let x=0;x<u;x+=1)p=f[x],m=_[x],m.x=this._parseGlyphCoordinate(e,p,b,2,16),b=m.x;let w=0;for(let x=0;x<u;x+=1)p=f[x],m=_[x],m.y=this._parseGlyphCoordinate(e,p,w,4,32),w=m.y}this.points=_}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const h={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(h.dx=e.view.readInt16(),h.dy=e.view.readInt16()):h.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(h.dx=e.view.readInt8(),h.dy=e.view.readInt8()):h.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?h.xScale=h.yScale=e.view.readInt16()/16384:(a&64)>0?(h.xScale=e.view.readInt16()/16384,h.yScale=e.view.readInt16()/16384):(a&128)>0&&(h.xScale=e.view.readInt16()/16384,h.scale01=e.view.readInt16()/16384,h.scale10=e.view.readInt16()/16384,h.yScale=e.view.readInt16()/16384),this.components.push(h),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let h=0;h<this.instructionLength;h+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],h=r.get(l.glyphIndex);if(h.getPathCommands(),h.points){let c;if(l.matchedPoints===void 0)c=this._transformPoints(h.points,l);else{$r(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const u=this.points[l.matchedPoints[0]];let f=h.points[l.matchedPoints[1]];const p={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};f=this._transformPoints([f],p)[0],p.dx=u.x-f.x,p.dy=u.y-f.y,c=this._transformPoints(h.points,p)}this.points=this.points.concat(c)}}const s=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const h=o[a];let c=h[h.length-1],u=h[0];c.onCurve?s.push({type:"M",x:c.x,y:c.y}):u.onCurve?s.push({type:"M",x:u.x,y:u.y}):s.push({type:"M",x:(c.x+u.x)*.5,y:(c.y+u.y)*.5});for(let f=0,p=h.length;f<p;++f)if(c=u,u=h[(f+1)%p],c.onCurve)s.push({type:"L",x:c.x,y:c.y});else{let y=u;u.onCurve||(y={x:(c.x+u.x)*.5,y:(c.y+u.y)*.5}),s.push({type:"Q",x1:c.x,y1:c.y,x:y.x,y:y.y})}s.push({type:"Z"})}this.pathCommands=s}}class of extends sn{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new nf({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var af=Object.defineProperty,lf=Object.getOwnPropertyDescriptor,hf=(n,e,t,r)=>{for(var i=r>1?void 0:r?lf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&af(e,t,i),i};let ki=class extends Ut{constructor(){super(...arguments);d(this,"_glyphs")}static from(e){const t=e.reduce((i,s)=>i+s.byteLength,0),r=new ki(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeBytes(i)}),r}get glyphs(){return this._glyphs??(this._glyphs=new of(this._sfnt))}};ki=hf([Pt("glyf")],ki);var cf=Object.defineProperty,uf=Object.getOwnPropertyDescriptor,ff=(n,e,t,r)=>{for(var i=r>1?void 0:r?uf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&cf(e,t,i),i};let dn=class extends Ut{};dn=ff([Pt("GPOS","gpos")],dn);var df=Object.defineProperty,pf=Object.getOwnPropertyDescriptor,Ze=(n,e,t,r)=>{for(var i=r>1?void 0:r?pf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&df(e,t,i),i};let Ce=class extends Ut{};Ze([v("uint16")],Ce.prototype,"majorVersion",2),Ze([v("uint16")],Ce.prototype,"minorVersion",2),Ze([v("uint16")],Ce.prototype,"scriptListOffset",2),Ze([v("uint16")],Ce.prototype,"featureListOffset",2),Ze([v("uint16")],Ce.prototype,"lookupListOffset",2),Ze([v("uint16")],Ce.prototype,"featureVariationsOffset",2),Ce=Ze([Pt("GSUB","gsub")],Ce);var gf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,bt=(n,e,t,r)=>{for(var i=r>1?void 0:r?mf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gf(e,t,i),i};let gt=class extends Ut{constructor(n=new ArrayBuffer(54),e){super(n,e,Math.min(54,n.byteLength-(e??0)))}};bt([v("fixed")],gt.prototype,"version",2),bt([v("fixed")],gt.prototype,"fontRevision",2),bt([v("uint32")],gt.prototype,"checkSumAdjustment",2),bt([v("uint32")],gt.prototype,"magickNumber",2),bt([v("uint16")],gt.prototype,"flags",2),bt([v("uint16")],gt.prototype,"unitsPerEm",2),bt([v({type:"longDateTime"})],gt.prototype,"created",2),bt([v({type:"longDateTime"})],gt.prototype,"modified",2),bt([v("int16")],gt.prototype,"xMin",2),bt([v("int16")],gt.prototype,"yMin",2),bt([v("int16")],gt.prototype,"xMax",2),bt([v("int16")],gt.prototype,"yMax",2),bt([v("uint16")],gt.prototype,"macStyle",2),bt([v("uint16")],gt.prototype,"lowestRecPPEM",2),bt([v("int16")],gt.prototype,"fontDirectionHint",2),bt([v("int16")],gt.prototype,"indexToLocFormat",2),bt([v("int16")],gt.prototype,"glyphDataFormat",2),gt=bt([Pt("head")],gt);var yf=Object.defineProperty,_f=Object.getOwnPropertyDescriptor,Bt=(n,e,t,r)=>{for(var i=r>1?void 0:r?_f(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yf(e,t,i),i};let Ct=class extends Ut{constructor(n=new ArrayBuffer(36),e){super(n,e,Math.min(36,n.byteLength-(e??0)))}};Bt([v("fixed")],Ct.prototype,"version",2),Bt([v("int16")],Ct.prototype,"ascent",2),Bt([v("int16")],Ct.prototype,"descent",2),Bt([v("int16")],Ct.prototype,"lineGap",2),Bt([v("uint16")],Ct.prototype,"advanceWidthMax",2),Bt([v("int16")],Ct.prototype,"minLeftSideBearing",2),Bt([v("int16")],Ct.prototype,"minRightSideBearing",2),Bt([v("int16")],Ct.prototype,"xMaxExtent",2),Bt([v("int16")],Ct.prototype,"caretSlopeRise",2),Bt([v("int16")],Ct.prototype,"caretSlopeRun",2),Bt([v("int16")],Ct.prototype,"caretOffset",2),Bt([v({type:"int16",size:4})],Ct.prototype,"reserved",2),Bt([v("int16")],Ct.prototype,"metricDataFormat",2),Bt([v("uint16")],Ct.prototype,"numOfLongHorMetrics",2),Ct=Bt([Pt("hhea")],Ct);var vf=Object.defineProperty,bf=Object.getOwnPropertyDescriptor,xf=(n,e,t,r)=>{for(var i=r>1?void 0:r?bf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&vf(e,t,i),i};let Ni=class extends Ut{constructor(){super(...arguments);d(this,"_metrics")}static from(e){const t=e.length*4,r=new Ni(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeUint16(i.advanceWidth),r.view.writeUint16(i.leftSideBearing)}),r}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){const e=this._sfnt.maxp.numGlyphs,t=this._sfnt.hhea.numOfLongHorMetrics;let r=0;const i=this.view;return i.seek(0),Array.from({length:e}).map((s,o)=>(o<t&&(r=i.readUint16()),{advanceWidth:r,leftSideBearing:i.readUint16()}))}};Ni=xf([Pt("hmtx")],Ni);var wf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,Cf=(n,e,t,r)=>{for(var i=r>1?void 0:r?Pf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wf(e,t,i),i};let pn=class extends Ut{};pn=Cf([Pt("kern","kern")],pn);var Tf=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,Mf=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ef(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tf(e,t,i),i};let Fi=class extends Ut{constructor(){super(...arguments);d(this,"_locations")}static from(e,t=1){const r=e.length*(t?4:2),i=new Fi(new ArrayBuffer(r));return e.forEach(s=>{t?i.view.writeUint32(s):i.view.writeUint16(s/2)}),i}get locations(){return this._locations??(this._locations=this.readLocations())}readLocations(){const e=this._sfnt.maxp.numGlyphs,t=this._sfnt.head.indexToLocFormat,r=this.view;return r.seek(0),Array.from({length:e}).map(()=>t?r.readUint32():r.readUint16()*2)}};Fi=Mf([Pt("loca")],Fi);var Sf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,It=(n,e,t,r)=>{for(var i=r>1?void 0:r?Af(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Sf(e,t,i),i};let xt=class extends Ut{constructor(n=new ArrayBuffer(32),e){super(n,e,Math.min(32,n.byteLength-(e??0)))}};It([v("fixed")],xt.prototype,"version",2),It([v("uint16")],xt.prototype,"numGlyphs",2),It([v("uint16")],xt.prototype,"maxPoints",2),It([v("uint16")],xt.prototype,"maxContours",2),It([v("uint16")],xt.prototype,"maxComponentPoints",2),It([v("uint16")],xt.prototype,"maxComponentContours",2),It([v("uint16")],xt.prototype,"maxZones",2),It([v("uint16")],xt.prototype,"maxTwilightPoints",2),It([v("uint16")],xt.prototype,"maxStorage",2),It([v("uint16")],xt.prototype,"maxFunctionDefs",2),It([v("uint16")],xt.prototype,"maxInstructionDefs",2),It([v("uint16")],xt.prototype,"maxStackElements",2),It([v("uint16")],xt.prototype,"maxSizeOfInstructions",2),It([v("uint16")],xt.prototype,"maxComponentElements",2),It([v("uint16")],xt.prototype,"maxComponentDepth",2),xt=It([Pt("maxp")],xt);var Of=Object.defineProperty,Uf=Object.getOwnPropertyDescriptor,$i=(n,e,t,r)=>{for(var i=r>1?void 0:r?Uf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Of(e,t,i),i};const Ia={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},gn={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},If={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},Da={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let mr=class extends Ut{constructor(){super(...arguments);d(this,"_names")}get names(){return this._names??(this._names=this.readNames())}readNames(){const e=this.count;this.view.seek(6);const t=[];for(let l=0;l<e;++l)t.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const r=this.stringOffset;for(let l=0;l<e;++l){const h=t[l];h.name=this.view.readBytes(r+h.offset,h.length)}let i=gn.Macintosh,s=If.Default,o=0;t.some(l=>l.platform===gn.Microsoft&&l.encoding===Da.UCS2&&l.language===1033)&&(i=gn.Microsoft,s=Da.UCS2,o=1033);const a={};for(let l=0;l<e;++l){const h=t[l];h.platform===i&&h.encoding===s&&h.language===o&&Ia[h.nameId]&&(a[Ia[h.nameId]]=o===0?Du(h.name):Ru(h.name))}return a}};$i([v("uint16")],mr.prototype,"format",2),$i([v("uint16")],mr.prototype,"count",2),$i([v("uint16")],mr.prototype,"stringOffset",2),mr=$i([Pt("name")],mr);var Df=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,G=(n,e,t,r)=>{for(var i=r>1?void 0:r?Rf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Df(e,t,i),i};let V=class extends Ut{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};G([v("uint16")],V.prototype,"version",2),G([v("int16")],V.prototype,"xAvgCharWidth",2),G([v("uint16")],V.prototype,"usWeightClass",2),G([v("uint16")],V.prototype,"usWidthClass",2),G([v("uint16")],V.prototype,"fsType",2),G([v("uint16")],V.prototype,"ySubscriptXSize",2),G([v("uint16")],V.prototype,"ySubscriptYSize",2),G([v("uint16")],V.prototype,"ySubscriptXOffset",2),G([v("uint16")],V.prototype,"ySubscriptYOffset",2),G([v("uint16")],V.prototype,"ySuperscriptXSize",2),G([v("uint16")],V.prototype,"ySuperscriptYSize",2),G([v("uint16")],V.prototype,"ySuperscriptXOffset",2),G([v("uint16")],V.prototype,"ySuperscriptYOffset",2),G([v("uint16")],V.prototype,"yStrikeoutSize",2),G([v("uint16")],V.prototype,"yStrikeoutPosition",2),G([v("uint16")],V.prototype,"sFamilyClass",2),G([v({type:"uint8"})],V.prototype,"bFamilyType",2),G([v({type:"uint8"})],V.prototype,"bSerifStyle",2),G([v({type:"uint8"})],V.prototype,"bWeight",2),G([v({type:"uint8"})],V.prototype,"bProportion",2),G([v({type:"uint8"})],V.prototype,"bContrast",2),G([v({type:"uint8"})],V.prototype,"bStrokeVariation",2),G([v({type:"uint8"})],V.prototype,"bArmStyle",2),G([v({type:"uint8"})],V.prototype,"bLetterform",2),G([v({type:"uint8"})],V.prototype,"bMidline",2),G([v({type:"uint8"})],V.prototype,"bXHeight",2),G([v({type:"uint8",size:16})],V.prototype,"ulUnicodeRange",2),G([v({type:"char",size:4})],V.prototype,"achVendID",2),G([v("uint16")],V.prototype,"fsSelection",2),G([v("uint16")],V.prototype,"usFirstCharIndex",2),G([v("uint16")],V.prototype,"usLastCharIndex",2),G([v("int16")],V.prototype,"sTypoAscender",2),G([v("int16")],V.prototype,"sTypoDescender",2),G([v("int16")],V.prototype,"sTypoLineGap",2),G([v("uint16")],V.prototype,"usWinAscent",2),G([v("uint16")],V.prototype,"usWinDescent",2),G([v({offset:72,type:"uint8",size:8})],V.prototype,"ulCodePageRange",2),G([v({offset:72,type:"int16"})],V.prototype,"sxHeight",2),G([v("int16")],V.prototype,"sCapHeight",2),G([v("uint16")],V.prototype,"usDefaultChar",2),G([v("uint16")],V.prototype,"usBreakChar",2),G([v("uint16")],V.prototype,"usMaxContext",2),V=G([Pt("OS/2","os2")],V);var Bf=Object.defineProperty,Lf=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Lf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Bf(e,t,i),i};let Jt=class extends Ut{constructor(n=new ArrayBuffer(32),e,t){super(n,e,t)}};pe([v("fixed")],Jt.prototype,"format",2),pe([v("fixed")],Jt.prototype,"italicAngle",2),pe([v("int16")],Jt.prototype,"underlinePosition",2),pe([v("int16")],Jt.prototype,"underlineThickness",2),pe([v("uint32")],Jt.prototype,"isFixedPitch",2),pe([v("uint32")],Jt.prototype,"minMemType42",2),pe([v("uint32")],Jt.prototype,"maxMemType42",2),pe([v("uint32")],Jt.prototype,"minMemType1",2),pe([v("uint32")],Jt.prototype,"maxMemType1",2),Jt=pe([Pt("post")],Jt);var kf=Object.defineProperty,Nf=Object.getOwnPropertyDescriptor,Lt=(n,e,t,r)=>{for(var i=r>1?void 0:r?Nf(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&kf(e,t,i),i};let Tt=class extends Ut{constructor(n=new ArrayBuffer(36),e){super(n,e,Math.min(36,n.byteLength-(e??0)))}};Lt([v("fixed")],Tt.prototype,"version",2),Lt([v("int16")],Tt.prototype,"vertTypoAscender",2),Lt([v("int16")],Tt.prototype,"vertTypoDescender",2),Lt([v("int16")],Tt.prototype,"vertTypoLineGap",2),Lt([v("int16")],Tt.prototype,"advanceHeightMax",2),Lt([v("int16")],Tt.prototype,"minTopSideBearing",2),Lt([v("int16")],Tt.prototype,"minBottomSideBearing",2),Lt([v("int16")],Tt.prototype,"yMaxExtent",2),Lt([v("int16")],Tt.prototype,"caretSlopeRise",2),Lt([v("int16")],Tt.prototype,"caretSlopeRun",2),Lt([v("int16")],Tt.prototype,"caretOffset",2),Lt([v({type:"int16",size:4})],Tt.prototype,"reserved",2),Lt([v("int16")],Tt.prototype,"metricDataFormat",2),Lt([v("int16")],Tt.prototype,"numOfLongVerMetrics",2),Tt=Lt([Pt("vhea")],Tt);var Ff=Object.defineProperty,$f=Object.getOwnPropertyDescriptor,zf=(n,e,t,r)=>{for(var i=r>1?void 0:r?$f(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ff(e,t,i),i};let zi=class extends Ut{constructor(){super(...arguments);d(this,"_metrics")}static from(e){const t=e.length*4,r=new zi(new ArrayBuffer(t));return e.forEach(i=>{r.view.writeUint16(i.advanceHeight),r.view.writeInt16(i.topSideBearing)}),r}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){var s;const e=this._sfnt.maxp.numGlyphs,t=((s=this._sfnt.vhea)==null?void 0:s.numOfLongVerMetrics)??0,r=this.view;r.seek(0);let i=0;return Array.from({length:e}).map((o,a)=>(a<t&&(i=r.readUint16()),{advanceHeight:i,topSideBearing:r.readUint8()}))}};zi=zf([Pt("vmtx")],zi);var Vf=Object.defineProperty,Wr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Vf(e,t,i),i};class te extends Oi{constructor(){super(...arguments);d(this,"format","TrueType");d(this,"mimeType","font/ttf");d(this,"_sfnt")}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(fr(t).getUint32(0))}static checksum(t){const r=fr(t);let i=r.byteLength;for(;i%4;)i++;let s=0;for(let o=0,a=i/4;o<a;o+=4)o*4<i-4&&(s+=r.getUint32(o*4,!1));return s&4294967295}static from(t){const r=f=>f+3&-4,i=t.tableViews.size,s=Array.from(t.tableViews.values()).reduce((f,p)=>f+r(p.byteLength),0),o=new this(new ArrayBuffer(12+i*16+s));o.scalerType=65536,o.numTables=i;const a=Math.log(2);o.searchRange=Math.floor(Math.log(i)/a)*16,o.entrySelector=Math.floor(o.searchRange/a),o.rangeShift=i*16-o.searchRange;let l=12+i*16,h=0;const c=o.getDirectories();t.tableViews.forEach((f,p)=>{const y=c[h++];y.tag=p,y.checkSum=this.checksum(f),y.offset=l,y.length=f.byteLength,o.view.writeBytes(f,l),l+=r(y.length)});const u=o.createSfnt().head;return u.checkSumAdjustment=0,u.checkSumAdjustment=2981146554-this.checksum(o.view),o}getDirectories(){let t=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const r=new dr(this.view.buffer,t);return t+=r.view.byteLength,r})}createSfnt(){return new qe(this.getDirectories().reduce((t,r)=>(t[r.tag]=new DataView(this.view.buffer,this.view.byteOffset+r.offset,r.length),t),{}))}}d(te,"signature",new Set([65536,1953658213,1954115633])),Wr([v("uint32")],te.prototype,"scalerType"),Wr([v("uint16")],te.prototype,"numTables"),Wr([v("uint16")],te.prototype,"searchRange"),Wr([v("uint16")],te.prototype,"entrySelector"),Wr([v("uint16")],te.prototype,"rangeShift");class Vi extends te{constructor(){super(...arguments);d(this,"format","OpenType");d(this,"mimeType","font/otf")}static from(t){return super.from(t)}}d(Vi,"signature",new Set([1330926671]));var Xf=Object.defineProperty,Hr=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&Xf(e,t,i),i};class Ke extends Wt{constructor(e,t){super(e,t,20)}}Hr([v({type:"char",size:4})],Ke.prototype,"tag"),Hr([v("uint32")],Ke.prototype,"offset"),Hr([v("uint32")],Ke.prototype,"compLength"),Hr([v("uint32")],Ke.prototype,"origLength"),Hr([v("uint32")],Ke.prototype,"origChecksum");var jf=Object.defineProperty,Ht=(n,e,t,r)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(e,t,i)||i);return i&&jf(e,t,i),i};const Vt=(ke=class extends Oi{constructor(){super(...arguments);d(this,"format","WOFF");d(this,"mimeType","font/woff");d(this,"_sfnt")}get subfontFormat(){return te.is(this.flavor)?"TrueType":Vi.is(this.flavor)?"OpenType":"Open"}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(t){return typeof t=="number"?this.signature.has(t):this.signature.has(fr(t).getUint32(0))}static checkSum(t){const r=fr(t),i=r.byteLength,s=Math.floor(i/4);let o=0,a=0;for(;a<s;)o+=r.getUint32(4*a++,!1);let l=i-s*4;if(l){let h=s*4;for(;l>0;)o+=r.getUint8(h)<<l*8,h++,l--}return o%4294967296}static from(t,r=new ArrayBuffer(0)){const i=f=>f+3&-4,s=[];t.tableViews.forEach((f,p)=>{const y=fr(Eu(new Uint8Array(f.buffer,f.byteOffset,f.byteLength)));s.push({tag:p,view:y.byteLength<f.byteLength?y:f,rawView:f})});const o=s.length,a=s.reduce((f,p)=>f+i(p.view.byteLength),0),l=new ke(new ArrayBuffer(44+20*o+a+r.byteLength));l.signature=2001684038,l.flavor=65536,l.length=l.view.byteLength,l.numTables=o,l.totalSfntSize=12+16*o+s.reduce((f,p)=>f+i(p.rawView.byteLength),0);let h=44+o*20,c=0;const u=l.getDirectories();return s.forEach(f=>{const p=u[c++];p.tag=f.tag,p.offset=h,p.compLength=f.view.byteLength,p.origChecksum=ke.checkSum(f.rawView),p.origLength=f.rawView.byteLength,l.view.writeBytes(f.view,h),h+=i(p.compLength)}),l.view.writeBytes(r),l}getDirectories(){let t=44;return Array.from({length:this.numTables},()=>{const r=new Ke(this.view.buffer,t);return t+=r.view.byteLength,r})}createSfnt(){return new qe(this.getDirectories().reduce((t,r)=>{const i=r.tag,s=this.view.byteOffset+r.offset,o=r.compLength,a=r.origLength,l=s+o;return t[i]=o>=a?new DataView(this.view.buffer,s,o):new DataView(Mu(new Uint8Array(this.view.buffer.slice(s,l))).buffer),t},{}))}},d(ke,"signature",new Set([2001684038])),ke);Ht([v("uint32")],Vt.prototype,"signature"),Ht([v("uint32")],Vt.prototype,"flavor"),Ht([v("uint32")],Vt.prototype,"length"),Ht([v("uint16")],Vt.prototype,"numTables"),Ht([v("uint16")],Vt.prototype,"reserved"),Ht([v("uint32")],Vt.prototype,"totalSfntSize"),Ht([v("uint16")],Vt.prototype,"majorVersion"),Ht([v("uint16")],Vt.prototype,"minorVersion"),Ht([v("uint32")],Vt.prototype,"metaOffset"),Ht([v("uint32")],Vt.prototype,"metaLength"),Ht([v("uint32")],Vt.prototype,"metaOrigLength"),Ht([v("uint32")],Vt.prototype,"privOffset"),Ht([v("uint32")],Vt.prototype,"privLength");let Xi=Vt;function Ra(n,e=!0){if(te.is(n))return new te(n);if(Vi.is(n))return new Vi(n);if(Xi.is(n))return new Xi(n);if(e)throw new Error("Failed to parseFont")}const Ji=class Ji{constructor(){d(this,"fallbackFont");d(this,"loading",new Map);d(this,"loaded",new Map);d(this,"familyToUrl",new Map)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...Ji.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=document.createElement("style");return r.appendChild(document.createTextNode(`@font-face {
|
|
28
|
-
font-family: "${
|
|
29
|
-
src: url(${
|
|
30
|
-
}`)),document.head.appendChild(r),this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(r=>this.familyToUrl.get(r.trim())??this.familyToUrl.get(r)??r)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((i,s)=>i||this.loaded.get(s),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(e,t={}){const{cancelOther:r,injectFontFace:i=!0,injectStyleTag:s=!0,...o}=t,{src:a}=e;if(this.loaded.has(a))return r&&(this.loading.forEach(f=>f.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,o),this.loading.set(a,l)),r&&this.loading.forEach((f,p)=>{f!==l&&(f.cancel(),this.loading.delete(p))}),l.when.then(f=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const p=u(f);return t.noAdd||this.loaded.set(e.src,p),p.familySet.forEach(y=>{this.familyToUrl.set(y,a),typeof document<"u"&&(i&&this.injectFontFace(y,f),s&&this.injectStyleTag(y,a))}),p}}).catch(f=>{if(f instanceof DOMException&&f.message==="The user aborted a request.")return u();throw f}).finally(()=>{this.loading.delete(a)});function h(){return e.family?Array.isArray(e.family)?e.family:[e.family]:[]}function c(f){return h().forEach(p=>{f.familySet.add(p)}),f}function u(f=new ArrayBuffer(0)){let p;function y(){return p||(p=f.byteLength?Ra(f,!1):void 0),p}function _(){const m=y();if(m instanceof te||m instanceof Xi)return m.sfnt}return{...e,buffer:f,familySet:new Set(h()),getFont:y,getSfnt:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}};d(Ji,"defaultRequestInit",{cache:"force-cache"});let ji=Ji;const Ba=new ji,Gf=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:Oi,get Cff(){return Ye},get Cmap(){return gr},CmapSubtableFormat0:on,CmapSubtableFormat12:cn,CmapSubtableFormat14:Yr,CmapSubtableFormat2:jr,CmapSubtableFormat4:hn,CmapSubtableFormat6:He,FontDataObject:Wt,FontDataView:vt,Fonts:ji,get Glyf(){return ki},Glyph:rn,GlyphSet:sn,get Gpos(){return dn},get Gsub(){return Ce},get Head(){return gt},get Hhea(){return Ct},get Hmtx(){return Ni},get Kern(){return pn},get Loca(){return Fi},get Maxp(){return xt},get Name(){return mr},get Os2(){return V},get Post(){return Jt},Sfnt:qe,TableDirectory:dr,Ttf:te,get Vhea(){return Tt},get Vmtx(){return zi},Woff:Xi,WoffTableDirectoryEntry:Ke,createCmapSegments:ln,dataTypeToByteLength:zr,defineColumn:v,defineSfntTable:Pt,fonts:Ba,parseFont:Ra},Symbol.toStringTag,{value:"Module"}));function mn(n,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:r,y0:i,x1:s,y1:o,stops:a}=qf(e,t.left,t.top,t.width,t.height),l=n.createLinearGradient(r,i,s,o);return a.forEach(h=>l.addColorStop(h.offset,h.color)),l}return e}function Gi(n,e,t){n!=null&&n.color&&(n.color=mn(t,n.color,e)),n!=null&&n.backgroundColor&&(n.backgroundColor=mn(t,n.backgroundColor,e)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=mn(t,n.textStrokeColor,e))}function qf(n,e,t,r,i){var p;const s=((p=n.match(/linear-gradient\((.+)\)$/))==null?void 0:p[1])??"",o=s.split(",")[0],a=o.includes("deg")?o:"0deg",l=s.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),c=(Number(a.replace("deg",""))||0)*Math.PI/180,u=r*Math.sin(c),f=i*Math.cos(c);return{x0:e+r/2-u,y0:t+i/2+f,x1:e+r/2+u,y1:t+i/2-f,stops:Array.from(l).map(y=>{let _=y[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(y[3].replace("%",""))/100,color:_}})}}function Zr(n){const{ctx:e,path:t,fontSize:r,clipRect:i}=n;e.save(),e.beginPath();const s=t.style,o={...s,fill:n.color??s.fill,stroke:n.textStrokeColor??s.stroke,strokeWidth:n.textStrokeWidth?n.textStrokeWidth*r:s.strokeWidth,shadowOffsetX:(n.shadowOffsetX??0)*r,shadowOffsetY:(n.shadowOffsetY??0)*r,shadowBlur:(n.shadowBlur??0)*r,shadowColor:n.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function Yf(n,e,t){const{left:r,top:i,width:s,height:o}=t,a=n.canvas;a.dataset.viewBox=`${r} ${i} ${s} ${o}`,a.dataset.pixelRatio=String(e);const l=s,h=o;a.width=Math.max(1,Math.ceil(l*e)),a.height=Math.max(1,Math.ceil(h*e)),a.style.width=`${l}px`,a.style.height=`${h}px`,n.clearRect(0,0,a.width,a.height),n.scale(e,e),n.translate(-r,-i)}function Wf(n,e){const{paragraphs:t,computedStyle:r,glyphBox:i}=e;Gi(r,i,n),t.forEach(s=>{Gi(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{Gi(o.computedStyle,o.inlineBox,n)})})}const Hf=new Set(["©","®","÷"]),Zf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),Kf={1:"italic",32:"bold"},Qf={1:"italic",2:"bold"},La={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Jf{constructor(e,t,r){d(this,"path",new zt);d(this,"lineBox",new K);d(this,"inlineBox",new K);d(this,"glyphBox");d(this,"advanceWidth",0);d(this,"advanceHeight",0);d(this,"underlinePosition",0);d(this,"underlineThickness",0);d(this,"strikeoutPosition",0);d(this,"strikeoutSize",0);d(this,"ascender",0);d(this,"descender",0);d(this,"typoAscender",0);d(this,"typoDescender",0);d(this,"typoLineGap",0);d(this,"winAscent",0);d(this,"winDescent",0);d(this,"xHeight",0);d(this,"capHeight",0);d(this,"baseline",0);d(this,"centerDiviation",0);d(this,"fontStyle");this.content=e,this.index=t,this.parent=r}get center(){var e;return(e=this.glyphBox)==null?void 0:e.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(e){const t=this.computedStyle.fontFamily,r=e??Ba,i=t?r.get(t):r.fallbackFont;return i==null?void 0:i.getSfnt()}updateGlyph(e=this._getFontSfnt()){if(!e)return this;const{hhea:t,os2:r,post:i,head:s}=e,o=s.unitsPerEm,a=t.ascent,l=t.descent,{content:h,computedStyle:c,isVertical:u}=this,{fontSize:f}=c,p=o/f,y=e.getAdvanceWidth(h,f),_=(a+Math.abs(l))/p,m=a/p;return this.advanceWidth=y,this.advanceHeight=_,this.inlineBox.width=u?_:y,this.inlineBox.height=u?y:_,this.underlinePosition=(a-i.underlinePosition)/p,this.underlineThickness=i.underlineThickness/p,this.strikeoutPosition=(a-r.yStrikeoutPosition)/p,this.strikeoutSize=r.yStrikeoutSize/p,this.ascender=a/p,this.descender=l/p,this.typoAscender=r.sTypoAscender/p,this.typoDescender=r.sTypoDescender/p,this.typoLineGap=r.sTypoLineGap/p,this.winAscent=r.usWinAscent/p,this.winDescent=r.usWinDescent/p,this.xHeight=r.sxHeight/p,this.capHeight=r.sCapHeight/p,this.baseline=m,this.centerDiviation=_/2-m,this.fontStyle=Kf[r.fsSelection]??Qf[s.macStyle],this}update(e){const t=this._getFontSfnt(e);if(!t)return this;this.updateGlyph(t);const{isVertical:r,content:i,computedStyle:s,baseline:o,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:u,advanceWidth:f,advanceHeight:p}=this,{left:y,top:_}=a,m=s.fontStyle==="italic"&&u!=="italic";let b=y,w=_+o,x;const C=new zt;if(r&&(b+=(p-f)/2,Math.abs(f-p)>.1&&(w-=(l-c)/(l+Math.abs(h))*p),x=void 0),r&&!Hf.has(i)&&(i.codePointAt(0)<=256||Zf.has(i))){C.addCommands(t.getPathCommands(i,b,_+o-(p-f)/2,s.fontSize));const E={y:_-(p-f)/2+p/2,x:b+f/2};m&&this._italic(C,r?{x:E.x,y:_-(p-f)/2+o}:void 0),C.rotate(90,E)}else x!==void 0?(C.addCommands(t.glyphs.get(x).getPathCommands(b,w,s.fontSize)),m&&this._italic(C,r?{x:b+f/2,y:_+c/(l+Math.abs(h))*p}:void 0)):(C.addCommands(t.getPathCommands(i,b,w,s.fontSize)),m&&this._italic(C,r?{x:b+p/2,y:w}:void 0));const P=s.fontWeight??400;return P in La&&(P===700||P==="bold")&&u!=="bold"&&C.bold(La[P]*s.fontSize*.05),C.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=C,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,r){var i;if((i=this.path.paths[0])!=null&&i.curves.length)return this.path.getMinMax(e,t,r)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:r,max:i}=t;return new K(r.x,r.y,i.x-r.x,i.y-r.y)}drawTo(e,t={}){const r=this.computedStyle,i={ctx:e,path:this.path,fontSize:r.fontSize,color:r.color,...t};if(this.glyphBox)Zr(i);else{e.save(),e.beginPath();const s=this.path.style,o={...s,fill:i.color??s.fill,stroke:i.textStrokeColor??s.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:s.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};Vs(e,o),e.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function yn(n,e){return typeof n=="number"?n:n.endsWith("%")?(n=n.substring(0,n.length-1),Math.ceil(Number(n)/100*e.total)):n.endsWith("rem")?(n=n.substring(0,n.length-3),Number(n)*e.fontSize):n.endsWith("em")?(n=n.substring(0,n.length-2),Number(n)*e.fontSize):Number(n)}function ka(n){const e=De(n)?{}:n;return Object.keys(e).reduce((t,r)=>{let i=e[r];const s=Na(r),o=Na(i);return s&&(r=s),o&&(i=o),t[r]=i,t},{})}function De(n){return!n||n==="none"}function td(n,e){const t=Object.keys(n),r=Object.keys(e);return Array.from(new Set([...t,...r])).every(s=>yr(n[s],e[s]))}function yr(n,e){const t=typeof n;return t===typeof e?t==="object"?td(n,e):n===e:!1}function Na(n){const e=n.startsWith("#")?n.slice(1):n;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(e))return null;const r=e.length===3?e.split("").map(a=>a+a).join(""):e,i=Number.parseInt(r.slice(0,2),16),s=Number.parseInt(r.slice(2,4),16),o=Number.parseInt(r.slice(4,6),16);return`rgb(${i}, ${s}, ${o})`}function _n(n){if(!n)return n;const e={};for(const t in n)n[t]!==""&&n[t]!==void 0&&(e[t]=n[t]);return e}function vn(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class ed{constructor(e,t={},r){d(this,"inlineBox",new K);this.content=e,this.style=t,this.parent=r,this.updateComputedStyle().initCharacters()}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,..._n(this.style)},this}initCharacters(){const e=[];let t=0;for(const r of this.computedContent)e.push(new Jf(r,t++,this));return this.characters=e,this}}class Kr{constructor(e,t){d(this,"lineBox",new K);d(this,"fragments",[]);this.style=e,this.parentStyle=t,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={..._n(this.parentStyle),..._n(this.style)},this}addFragment(e,t){const r=new ed(e,t,this);return this.fragments.push(r),r}}function $p(n){return n}const br=class br{_styleToDomStyle(e){const t={};for(const r in e){const i=e[r];br.notZeroStyles.has(r)&&i===0||(typeof i=="number"&&br.pxStyles.has(r)?t[r]=`${i}px`:t[r]=i)}return t}createParagraphDom(e,t){const r=document.createDocumentFragment(),i=document.createElement("section"),s={...t},o=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":s.justifyContent="start";break;case"center":s.justifyContent="center";break;case"end":case"right":s.justifyContent="end";break}switch(t.verticalAlign){case"top":s.alignItems="top";break;case"middle":s.alignItems="center";break;case"bottom":s.alignItems="end";break}const a=!!(s.justifyContent||s.alignItems);Object.assign(i.style,{boxSizing:"border-box",display:a?"inline-flex":void 0,width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(s),position:"fixed",visibility:"hidden"});const l=document.createElement("ul");return Object.assign(l.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:a&&o?"100%":void 0,height:a&&!o?"100%":void 0}),e.forEach(h=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._styleToDomStyle(h.style)}),h.fragments.forEach(u=>{const f=document.createElement("span");Object.assign(f.style,{verticalAlign:"inherit",...this._styleToDomStyle(u.style)}),f.appendChild(document.createTextNode(u.content)),c.appendChild(f)}),l.appendChild(c)}),i.appendChild(l),r.appendChild(i),document.body.appendChild(r),{dom:i,destory:()=>{var h;return(h=i.parentNode)==null?void 0:h.removeChild(i)}}}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const r=e.data??"";let i=0;return Array.from(r).map(s=>{var u;const o=i+=r.substring(i).indexOf(s),a=o+s.length;i+=s.length,t.setStart(e,Math.max(o,0)),t.setEnd(e,a);const l=((u=t.getClientRects)==null?void 0:u.call(t))??[t.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=t.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(e){const t=[],r=[],i=[];return e.querySelectorAll("li").forEach((s,o)=>{const a=s.getBoundingClientRect();t.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();r.push({paragraphIndex:o,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let u=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(f=>{i.push({...f,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:u++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(f=>{f.firstChild instanceof window.Text&&this.measureDomText(f.firstChild).forEach(p=>{i.push({...p,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:u++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:r,characters:i}}measureParagraphDom(e,t){const r=t.getBoundingClientRect(),i=this.measureDom(t);i.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const u=e[l].fragments[h].characters[c],{fontHeight:f,isVertical:p}=u,y=s[o];u.inlineBox.left=y.left,u.inlineBox.top=y.top,u.inlineBox.width=y.width,u.inlineBox.height=y.height,p?(u.lineBox.left=y.left+(y.width-f)/2,u.lineBox.top=y.top,u.lineBox.width=f,u.lineBox.height=y.height):(u.lineBox.left=y.left,u.lineBox.top=y.top+(y.height-f)/2,u.lineBox.width=y.width,u.lineBox.height=f),o++}),{paragraphs:e,boundingBox:new K(0,0,r.width,r.height)}}measure(e,t,r){let i;r||({dom:r,destory:i}=this.createParagraphDom(e,t));const s=this.measureParagraphDom(e,r);return i==null||i(),s}};d(br,"notZeroStyles",new Set(["width","height"])),d(br,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let bn=br;class rd{constructor(){d(this,"eventListeners",new Map)}addEventListener(e,t,r){const i={value:t,options:r},s=this.eventListeners.get(e);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(e,[s,i]):this.eventListeners.set(e,i),this}removeEventListener(e,t,r){var s,o;if(!t)return this.eventListeners.delete(e),this;const i=this.eventListeners.get(e);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==t||typeof r=="object"&&(r!=null&&r.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(e,a.length===1?a[0]:a):this.eventListeners.delete(e)}else i.value===t&&(typeof r=="boolean"||!(r!=null&&r.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(e);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(e){return this.eventListeners.has(e)}dispatchEvent(e,t){var i,s;const r=this.eventListeners.get(e);if(r){if(Array.isArray(r))for(let o=r.length,a=0;a<o;a++){const l=r[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(e,l.value,l.options),l.value.apply(this,[t])}else typeof r.options=="object"&&((s=r.options)!=null&&s.once)&&this.off(e,r.value,r.options),r.value.apply(this,[t]);return!0}else return!1}on(e,t,r){return this.addEventListener(e,t,r)}once(e,t){return this.addEventListener(e,t,{once:!0})}off(e,t,r){return this.removeEventListener(e,t,r)}emit(e,t){this.dispatchEvent(e,t)}}function xn(n){const{highlight:e,highlightImage:t,highlightReferImage:r,highlightColormap:i,highlightLine:s,highlightSize:o,highlightThickness:a}=n;return{image:(e==null?void 0:e.image)??t??"none",referImage:(e==null?void 0:e.referImage)??r??"none",colormap:(e==null?void 0:e.colormap)??i??"none",line:(e==null?void 0:e.line)??s??"none",size:(e==null?void 0:e.size)??o??"cover",thickness:(e==null?void 0:e.thickness)??a??"100%"}}function id(){const n=[],e=[],t=new Map,r=new Map;async function i(o){if(!t.has(o)){t.set(o,o);try{t.set(o,await fetch(o).then(a=>a.text()))}catch(a){console.warn(a),t.delete(o)}}}function s(o){let a=r.get(o);if(!a){const l=da(vn(o)?t.get(o)??o:o),h=pa(l);a={dom:l,paths:h},r.set(o,a)}return a}return{name:"highlight",paths:n,load:async o=>{const a=new Set;o.forEachCharacter(l=>{const{computedStyle:h}=l,{image:c,referImage:u}=xn(h);vn(c)&&a.add(c),vn(u)&&a.add(u)}),await Promise.all(Array.from(a).map(l=>i(l)))},update:o=>{e.length=0,n.length=0;let a=[],l,h;o.forEachCharacter(c=>{const{computedStyle:u}=c,f=xn(u),{image:p,colormap:y,line:_,size:m,thickness:b}=f;if(De(p))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:w,isVertical:x}=c,{fontSize:C}=u;(!h||yr(h.image,p)&&yr(h.colormap,y)&&yr(h.line,_)&&yr(h.size,m)&&yr(h.thickness,b))&&(l!=null&&l.length)&&(x?l[0].inlineBox.left===w.left:l[0].inlineBox.top===w.top)&&l[0].fontSize===C?l.push(c):(l=[],l.push(c),a.push(l))}h=f}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const u=a[c],f=u[0],p=K.from(...u.filter(q=>q.glyphBox).map(q=>q.glyphBox)),{computedStyle:y}=f,{fontSize:_,writingMode:m}=y,{image:b,referImage:w,colormap:x,line:C,size:P,thickness:E}=xn(y),A=m.includes("vertical"),S=yn(E,{fontSize:_,total:p.width})/p.width,T=ka(x),{paths:O,dom:$}=s(b),N=Lr(O,!0),B=_/N.width*2,M=new K().copy(p);A&&(M.width=p.height,M.height=p.width,M.left=p.left+p.width);const L=Math.floor(M.width);let F=L;if(P!=="cover"&&(F=yn(P,{fontSize:_,total:p.width})||L,M.width=F),!De(w)&&De(C)){const q=Lr(s(w).paths,!0);N.copy(q)}else{let q;if(De(C))if(N.width/N.height>4){q="underline";const I=$.getAttribute("viewBox");if(I){const[R,k,z,Y]=I.split(" ").map(j=>Number(j)),H=k+Y/2;N.y<H&&N.y+N.height>H?q="line-through":N.y+N.height<H?q="overline":q="underline"}}else q="outline";else q=C;switch(q){case"outline":{const I=M.width*.2,R=M.height*.2;M.width+=I,M.height+=R,A?(M.x-=R/2,M.y-=I/2,M.x+=M.height):(M.x-=I/2,M.y-=R/2);break}case"overline":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width:M.y=f.inlineBox.top;break;case"line-through":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width-f.strikeoutPosition+M.height/2:M.y=f.inlineBox.top+f.strikeoutPosition-M.height/2;break;case"underline":M.height=N.height*B,A?M.x=f.inlineBox.left+f.inlineBox.width-f.underlinePosition:M.y=f.inlineBox.top+f.underlinePosition;break}}const X=new $t().translate(-N.x,-N.y).scale(M.width/N.width,M.height/N.height);A&&X.rotate(-Math.PI/2),X.translate(M.x,M.y);for(let q=0;q<Math.ceil(L/F);q++){const I=X.clone();A?I.translate(0,q*M.width):I.translate(q*M.width,0),O.forEach(R=>{const k=R.clone().matrix(I);k.style.strokeWidth&&(k.style.strokeWidth*=B*S),k.style.strokeMiterlimit&&(k.style.strokeMiterlimit*=B),k.style.strokeDashoffset&&(k.style.strokeDashoffset*=B),k.style.strokeDasharray&&(k.style.strokeDasharray=k.style.strokeDasharray.map(z=>z*B)),k.style.fill&&k.style.fill in T&&(k.style.fill=T[k.style.fill]),k.style.stroke&&k.style.stroke in T&&(k.style.stroke=T[k.style.stroke]),n.push(k),L!==F&&(A?e[n.length-1]=new K(p.left-p.width*2,p.top,p.width*4,p.height):e[n.length-1]=new K(p.left,p.top-p.height*2,p.width,p.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if(Zr({ctx:o,path:l,fontSize:a.computedStyle.fontSize,clipRect:e[h]}),a.debug){const c=Lr([l]);c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function sd(n,e){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
-
<circle cx="${n}" cy="${n}" r="${n}" fill="${
|
|
32
|
-
</svg>`}function nd(){const n=[];return{name:"listStyle",paths:n,update:e=>{n.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,s=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:u,listStyleType:f}=a,p=ka(c);let y=u,_;if(!De(h))_=h;else if(!De(f)){const x=i*.38/2;switch(y=y==="cover"?x*2:y,f){case"disc":_=sd(x,String(l));break}}if(!_)return;const m=pa(_),b=Lr(m);let w;o.fragments.forEach(x=>{x.characters.forEach(C=>{const{inlineBox:P}=C;if(r?(w==null?void 0:w.inlineBox.left)!==P.left:(w==null?void 0:w.inlineBox.top)!==P.top){w=C;const E=y==="cover"?1:yn(y,{total:i,fontSize:i})/i,A=new $t;if(r){const S=i/b.height*E;A.translate(-b.left,-b.top).rotate(Math.PI/2).scale(S,S).translate(P.left+(P.width-b.height*S)/2,P.top-s)}else{const S=i/b.height*E;A.translate(-b.left,-b.top).scale(S,S).translate(P.left-b.width*S-s,P.top+(P.height-b.height*S)/2)}n.push(...m.map(S=>{const T=S.clone();return T.matrix(A),T.style.fill&&T.style.fill in p&&(T.style.fill=p[T.style.fill]),T.style.stroke&&T.style.stroke in p&&(T.style.stroke=p[T.style.stroke]),T}))}})})})}}}const Re=new D,_r=new $t,Be=new $t;function od(){return{name:"render",getBoundingBox:n=>{const{characters:e,fontSize:t,effects:r}=n,i=[];return e.forEach(s=>{r==null||r.forEach(o=>{if(!s.glyphBox)return;const a=s.glyphBox.clone(),l=wn(n,o);Re.set(a.left,a.top),Re.applyMatrix3(l),a.left=Re.x,a.top=Re.y,Re.set(a.right,a.bottom),Re.applyMatrix3(l),a.width=Re.x-a.left,a.height=Re.y-a.top;const h=(o.shadowOffsetX??0)*t,c=(o.shadowOffsetY??0)*t,u=Math.max(.1,o.textStrokeWidth??0)*t;a.left+=h-u,a.top+=c-u,a.width+=u*2,a.height+=u*2,i.push(a)})}),i.length?K.from(...i):void 0},render:(n,e)=>{const{paragraphs:t,glyphBox:r,effects:i,style:s}=e;function o(a,l){n.fillStyle=a,n.fillRect(l.left,l.top,l.width,l.height)}s!=null&&s.backgroundColor&&o(s.backgroundColor,new K(0,0,n.canvas.width,n.canvas.height)),t.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&o(a.style.backgroundColor,a.lineBox)}),i?i.forEach(a=>{Gi(a,r,n),n.save();const[l,h,c,u,f,p]=wn(e,a).transpose().elements;n.transform(l,u,h,f,c,p),e.forEachCharacter(y=>{var _;(_=y.parent.style)!=null&&_.backgroundColor&&o(y.parent.style.backgroundColor,y.inlineBox),y.drawTo(n,a)}),n.restore()}):t.forEach(a=>{a.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&o(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(n)})})}),e.debug&&t.forEach(a=>{n.strokeRect(a.lineBox.x,a.lineBox.y,a.lineBox.width,a.lineBox.height)})}}}function wn(n,e){const{fontSize:t,glyphBox:r}=n,i=(e.translateX??0)*t,s=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:h,top:c,width:u,height:f}=r,p=h+u/2,y=c+f/2;return _r.identity(),Be.makeTranslation(i,s),_r.multiply(Be),Be.makeTranslation(p,y),_r.multiply(Be),Be.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),_r.multiply(Be),Be.makeTranslation(-p,-y),_r.multiply(Be),_r.clone()}function ad(){const n=[];return{name:"textDecoration",paths:n,update:e=>{n.length=0;const t=[];let r,i;e.forEachCharacter(s=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:u,strikeoutSize:f}=s,{color:p,textDecoration:y,writingMode:_}=o;if(De(y))i=void 0;else{let m=!1;if((i==null?void 0:i.textDecoration)===y&&(i==null?void 0:i.writingMode)===_&&(i==null?void 0:i.color)===p&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(y){case"underline":r[0].underlinePosition===h&&r[0].underlineThickness===c&&(m=!0);break;case"line-through":r[0].strikeoutPosition===u&&r[0].strikeoutSize===f&&(m=!0);break}m?r.push(s):(r=[],r.push(s),t.push(r)),i=o}}),t.forEach(s=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:u}=s[0],{color:f,textDecoration:p}=o,{left:y,top:_,width:m,height:b}=K.from(...s.map(E=>E.inlineBox));let w=a?y+m:_;const x=a?-1:1;let C=0;switch(p){case"overline":C=h*2;break;case"underline":w+=x*l,C=h*2;break;case"line-through":w+=x*c,C=u*2;break}w-=C;let P;a?P=new zt([{type:"M",x:w,y:_},{type:"L",x:w,y:_+b},{type:"L",x:w+C,y:_+b},{type:"L",x:w+C,y:_},{type:"Z"}],{fill:f}):P=new zt([{type:"M",x:y,y:w},{type:"L",x:y+m,y:w},{type:"L",x:y+m,y:w+C},{type:"L",x:y,y:w+C},{type:"Z"}],{fill:f}),n.push(P)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(s=>{e.save();const[o,a,l,h,c,u]=wn(t,s).transpose().elements;e.transform(o,h,a,c,l,u),n.forEach(f=>{Zr({ctx:e,path:f,fontSize:i.fontSize,...s})}),e.restore()}):n.forEach(s=>{Zr({ctx:e,path:s,fontSize:i.fontSize})})}}}const Pn=du();class Fa extends rd{constructor(t={}){super();d(this,"debug");d(this,"content");d(this,"style");d(this,"effects");d(this,"measureDom");d(this,"needsUpdate",!0);d(this,"computedStyle",{...Pn});d(this,"paragraphs",[]);d(this,"lineBox",new K);d(this,"rawGlyphBox",new K);d(this,"glyphBox",new K);d(this,"pathBox",new K);d(this,"boundingBox",new K);d(this,"measurer",new bn);d(this,"plugins",new Map);d(this,"fonts");this.debug=t.debug??!1,this.content=t.content??"",this.style=t.style??{},this.measureDom=t.measureDom,this.effects=t.effects,this.fonts=t.fonts,this.use(nd()).use(ad()).use(id()).use(od()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(t=>t.fragments.flatMap(r=>r.characters))}use(t){return this.plugins.set(t.name,t),this}forEachCharacter(t){return this.paragraphs.forEach((r,i)=>{r.fragments.forEach((s,o)=>{s.characters.forEach((a,l)=>{t(a,{paragraphIndex:i,fragmentIndex:o,characterIndex:l})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(t=>{var r;return(r=t.load)==null?void 0:r.call(t,this)}))}updateParagraphs(){this.computedStyle={...Pn,...this.style};let{content:t,computedStyle:r}=this;const i=[];if(typeof t=="string"){const s=new Kr({},r);s.addFragment(t),i.push(s)}else{t=Array.isArray(t)?t:[t];for(const s of t)if(typeof s=="string"){const o=new Kr({},r);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new Kr({},r);s.forEach(a=>{if(typeof a=="string")o.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&o.addFragment(l,h)}}),i.push(o)}else if("fragments"in s){const{fragments:o,...a}=s,l=new Kr(a,r);o.forEach(h=>{const{content:c,...u}=h;c!==void 0&&l.addFragment(c,u)}),i.push(l)}else if("content"in s){const{content:o,...a}=s;if(o!==void 0){const l=new Kr(a,r);l.addFragment(o),i.push(l)}}}return this.paragraphs=i,this}measure(t=this.measureDom){const r={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const i=this.measurer.measure(this.paragraphs,this.computedStyle,t);this.paragraphs=i.paragraphs,this.lineBox=i.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,o)=>(s.updateOrder??0)-(o.updateOrder??0)).forEach(s=>{var o;(o=s.update)==null||o.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in r)i[s]=this[s],this[s]=r[s];return this.emit("measure",{text:this,result:i}),i}getGlyphBox(){const t=D.MAX,r=D.MIN;return this.characters.forEach(i=>{if(!i.getGlyphMinMax(t,r)){const{inlineBox:s}=i,o=new D(s.left,s.top),a=new D(s.left+s.width,s.top+s.height);t.min(o,a),r.max(o,a)}}),new K(t.x,t.y,r.x-t.x,r.y-t.y)}updatePathBox(){return this.pathBox=K.from(this.glyphBox,...Array.from(this.plugins.values()).map(t=>t.getBoundingBox?t.getBoundingBox(this):Lr(t.paths??[])).filter(Boolean)),this}updateBoundingBox(){const{lineBox:t,rawGlyphBox:r,pathBox:i}=this,s=Math.min(i.left,i.left+t.left-r.left),o=Math.min(i.top,i.top+t.top-r.top),a=Math.max(i.right,i.right+t.right-r.right),l=Math.max(i.bottom,i.bottom+t.bottom-r.bottom);return this.boundingBox=new K(s,o,a-s,l-o),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const t=this.measure();for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(t){const{view:r,pixelRatio:i=2}=t,s=r.getContext("2d");s&&(this.needsUpdate&&this.update(),Yf(s,i,this.boundingBox),Wf(s,this),Array.from(this.plugins.values()).sort((o,a)=>(o.renderOrder??0)-(a.renderOrder??0)).forEach(o=>{var a;if(o.render)(a=o.render)==null||a.call(o,s,this);else if(o.paths){const l=this.computedStyle;o.paths.forEach(h=>{Zr({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:r,pixelRatio:i}))}}function ld(n,e){return new Fa(n).measure()}function hd(n,e){return new Fa(n).render(n)}var cd=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,Qr=(n,e,t,r)=>{for(var i=r>1?void 0:r?ud(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&cd(e,t,i),i};const fd=new Set(Object.keys(Pn));g.Text2D=class extends g.Node2D{constructor(t){super();d(this,"effects");d(this,"texture",new pt(document.createElement("canvas")));d(this,"_subTextsCount",0);this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"content":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&t==="effects"&&this._getSubTexts().forEach(s=>{s.setProperties({[t]:r})})}_onUpdateStyleProperty(t,r,i){if(t!=="height"){switch(super._onUpdateStyleProperty(t,r,i),t){case"width":this.split&&this._updateSubTexts();break}typeof t=="string"&&fd.has(t)&&(this._subTextsCount&&t!=="width"&&t!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[t]:r})}),this.requestRedraw())}}_getSubTexts(){return this.getChildren(Ur.FRONT).filter(t=>t instanceof g.Text2D)}_updateSubTexts(){const t=this._getSubTexts(),r=this.measure();let i=0;this.split&&r.paragraphs.forEach(s=>{s.fragments.forEach(o=>{o.characters.forEach(a=>{const l=t[i];l&&(l.style.left=a.inlineBox.left,l.style.top=a.inlineBox.top),i++})})})}measure(){const t=ld({content:this.content,style:{...this.style.toJSON(),height:void 0}});return this.style.width||(this.style.width=t.boundingBox.width),this.style.height||(this.style.height=t.boundingBox.height),t}_updateSplit(){this._subTextsCount&&(this.getChildren(Ur.FRONT).forEach(r=>this.removeChild(r)),this._subTextsCount=0);const t=this.measure();this.split&&t.paragraphs.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(s=>{this.addChild(new g.Text2D({pixelRatio:this.pixelRatio,content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),Ur.FRONT),this._subTextsCount++})})})}_drawContent(){var t,r;if(!this.split){const i=(r=(t=this.children)==null?void 0:t.find(s=>"onText2DRender"in s))==null?void 0:r.onText2DRender;i?i():hd({view:this.texture.source,pixelRatio:this.pixelRatio,content:this.content,effects:this.effects,style:this.style.toJSON()}),this.texture.requestUpload(),this.context.fillStyle=this.texture,this.context.textureTransform=new qt().scale(1/this.pixelRatio,1/this.pixelRatio),super._drawContent()}}},Qr([U({default:2})],g.Text2D.prototype,"pixelRatio",2),Qr([U({default:!1})],g.Text2D.prototype,"split",2),Qr([U({default:""})],g.Text2D.prototype,"content",2),Qr([U()],g.Text2D.prototype,"effects",2),g.Text2D=Qr([Z("Text2D")],g.Text2D);var dd=Object.defineProperty,pd=Object.getOwnPropertyDescriptor,$a=(n,e,t,r)=>{for(var i=r>1?void 0:r?pd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&dd(e,t,i),i};g.Video2D=class extends g.Node2D{constructor(t){super();d(this,"texture");d(this,"_wait",Promise.resolve());this.setProperties(t)}get duration(){var t;return(((t=this.texture)==null?void 0:t.duration)??0)*1e3}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._wait=this._load(r);break}}waitLoad(){return this._wait}async _load(t){this.texture=await we.video.load(t),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_drawContent(){const t=this.texture;t&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height)),super._drawContent()}_updateVideoCurrentTime(){let t=this.visibleRelativeTime;if(t<0)return;const r=this.texture;if(!r)return;const i=r.duration;t=i?t%(i*1e3):0,!r.isPlaying&&!r.seeking&&(t=~~t/1e3,r.currentTime!==t&&(r.currentTime=t))}_process(t){this._updateVideoCurrentTime(),super._process(t)}},$a([U({default:""})],g.Video2D.prototype,"src",2),g.Video2D=$a([Z("Video2D")],g.Video2D);const ts=class ts extends ve{constructor(){super(...arguments);d(this,"playbackRate",1);d(this,"muted",!1);d(this,"volume",1);d(this,"paused",!1)}static get instance(){return this._instance||(this._instance=new ts),this._instance}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(t){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}};d(ts,"_instance");let qi=ts;const si=class si extends ve{constructor(){super(...arguments);d(this,"_source",null);d(this,"_audio",null);d(this,"_end",0);d(this,"_pausedReal",!1);d(this,"_duration",0);d(this,"_start",0);d(this,"_playing",!1);d(this,"_paused",!1);d(this,"_playbackRate",1);d(this,"_volume",1);d(this,"_loop",!1);d(this,"_muted",!1);d(this,"_onUpdate",()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())})}get progress(){var t;return(((t=this._source)==null?void 0:t.currentTime)??0)/this._duration}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh())}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}set(t,r){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"playbackRate":this.playbackRate=r;break;case"volume":this.volume=r;break;case"paused":this.paused=r;break;case"loop":this.loop=r;break;case"muted":this.muted=r;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(t){this._playing=!1,this._duration=t.source.duration;const r=this._source=t.source.cloneNode(!1);return r.src=t.parent.src,r.onplay=this._onPlay.bind(this),r.onpause=this._onPause.bind(this),t.context.on("refresh",this.refresh),t.context.on("refreshPaused",this.refreshPaused),this._audio=t,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(t){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const t=this._audio.context,r=this._audio.parent;this._source.loop=this._loop||r.loop;const i=t.volume*(t.muted?0:1),s=r.volume*(r.muted?0:1),o=this._volume*(this._muted?0:1);this._source.volume=o*i*s,this._source.playbackRate=this._playbackRate*t.playbackRate*r.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const t=this._paused||this._audio.parent.paused||this._audio.context.paused;t!==this._pausedReal&&(this._pausedReal=t,t?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",t))}play(t={}){if(!this._source)return;const{start:r=0,end:i=0}=t;i&&console.assert(i>r,"End time is before start time"),t.playbackRate!==void 0&&(this._playbackRate=t.playbackRate),t.volume!==void 0&&(this._volume=t.volume),t.loop!==void 0&&(this._loop=t.loop),t.muted!==void 0&&(this._muted=t.muted),this.refresh(),this.loop&&i!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=r,this._end=i||this._duration,this._start=Math.max(0,this._start-si.PADDING),this._end=Math.min(this._end+si.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=r,this._source.onloadedmetadata=null,this.emit("progress",r,this._duration),ft.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){ft.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){ft.off(this._onUpdate),this.removeAllListeners();const t=this._source;t&&(t.onended=null,t.onplay=null,t.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}};d(si,"PADDING",.1);let Yi=si;class za{constructor(e){d(this,"source",new globalThis.Audio);d(this,"_src","");this.parent=e}get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return qi.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new Yi}}class Cn extends ve{constructor(t,r){super();d(this,"_processers",[]);this._input=t,this._output=r}get processors(){return this._processers}set processors(t){if(this._processers.forEach(r=>r.disconnect()),this._processers.length=0,this._input.connect(this._output),t.length){this._processers=t.slice(0),this._input.disconnect();let r;t.forEach(i=>{r?r.connect(i.destination):this._input.connect(i.destination),r=i}),r.connect(this._output)}}get destination(){return this._input}}class gd{constructor(e,t=null){this.destination=e,this.source=t}connect(e){var t;(t=this.source)==null||t.connect(e)}disconnect(){var e;(e=this.source)==null||e.disconnect()}}function md(){if(as)return new AudioContext;if(ls){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function yd(n,e,t){if(hs)return new OfflineAudioContext(n,e,t);if($n){const r=globalThis.webkitOfflineAudioContext;return new r(n,e,t)}else throw new Error("Failed to createOfflineAudioContext")}const es=class es extends Cn{constructor(){const t=md(),r=yd(1,2,hs?Math.max(8e3,Math.min(96e3,t.sampleRate)):44100),i=t.createDynamicsCompressor(),s=t.createAnalyser();s.connect(i),i.connect(t.destination);super(s,i);d(this,"_context");d(this,"_offlineContext");d(this,"_locked");d(this,"muted",!1);d(this,"volume",1);d(this,"playbackRate",1);d(this,"autoPause",!0);d(this,"_paused",!1);d(this,"_pausedOnBlur",!1);d(this,"_compressor");d(this,"_analyser");d(this,"_unlock",()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))});this._context=t,this._offlineContext=r,this._compressor=i,this._analyser=s,this._locked=t.state==="suspended"&&(_e||Fn),Pr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}static get instance(){return this._instance||(this._instance=new es),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(t,r){this.instance.setParamValue(t,r)}static decode(t){return this.instance.decode(t)}get audioContext(){return this._context}get offlineContext(){return this._offlineContext}get paused(){return this._paused}set paused(t){t&&this._context.state==="running"?this._context.suspend():!t&&this._context.state==="suspended"&&this._context.resume(),this._paused=t}_onFocus(){if(!this.autoPause)return;const t=this._context.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}playEmptySound(){const t=this._context.createBufferSource();t.buffer=this._context.createBuffer(1,1,22050),t.connect(this._context.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t){return new Promise((r,i)=>{const s=a=>{i(new Error((a==null?void 0:a.message)||"Unable to decode file"))},o=this._offlineContext.decodeAudioData(t,r,s);o&&o.catch(s)})}setParamValue(t,r){t.setValueAtTime?t.setValueAtTime(r,this._context.currentTime):t.value=r}};d(es,"_instance");let Le=es;class Va extends ve{constructor(){super(...arguments);d(this,"_audio",null);d(this,"_sourceNode",null);d(this,"_gain",null);d(this,"_progress",0);d(this,"_pausedReal",!1);d(this,"_paused",!1);d(this,"_volume",1);d(this,"_playbackRate",1);d(this,"_loop",!1);d(this,"_muted",!1);d(this,"_duration",0);d(this,"_end",0);d(this,"_elapsed",0);d(this,"_lastUpdate",this._now());d(this,"_processors",[]);d(this,"_onComplete",()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)});d(this,"_updateListener",()=>this._update())}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh(),this._update(!0))}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}init(t){return this._audio=t,t.context.on("refresh",this.refresh),t.context.on("refreshPaused",this.refreshPaused),this}_now(){var t;return((t=this._audio)==null?void 0:t.context.audioContext.currentTime)??0}play(t={}){var a;if(!this._audio)return;const{end:r=0,start:i=0}=t;r&&console.assert(r>i,"End time is before start time"),this._end=r,this._elapsed=i,t.volume!==void 0&&(this._volume=t.volume),t.playbackRate!==void 0&&(this._playbackRate=t.playbackRate),t.muted!==void 0&&(this._muted=t.muted),t.loop!==void 0&&(this._loop=t.loop),t.processors!==void 0&&(this._processors=t.processors),this._paused=!1;const{source:s,gain:o}=this._audio.cloneSource();this._sourceNode=s,this._gain=o,this.refresh(),s.onended=this._onComplete.bind(this),this._duration=((a=s.buffer)==null?void 0:a.duration)??0,this._lastUpdate=this._now(),this._loop?(s.loopStart=i,s.loopEnd=r,s.start(0,i)):r?s.start(0,i,r-i):s.start(0,i),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(t=!1){if(this._sourceNode){const r=this._now(),i=r-this._lastUpdate;if(i>0||t){this._elapsed+=i*this._sourceNode.playbackRate.value,this._lastUpdate=r;const s=this._duration;let o;if(this._sourceNode.loopStart){const a=this._sourceNode.loopEnd-this._sourceNode.loopStart;o=(this._sourceNode.loopStart+this._elapsed%a)/s}else o=this._elapsed%s/s;this._progress=o,this.emit("progress",o,s)}}}refresh(){if(!this._audio||!this._sourceNode)return;const t=this._audio.context,r=this._audio.parent;this._sourceNode.loop=this._loop||r.loop,t.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*r.volume*(r.muted?0:1)*t.volume*(t.muted?0:1)),t.setParamValue(this._sourceNode.playbackRate,this._playbackRate*r.playbackRate*t.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let t=this._sourceNode;this._processors.forEach(r=>{t.connect(r.destination),t=r}),t.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const t=this._paused||this._audio.parent.paused||this._audio.context.paused;t!==this._pausedReal&&(this._pausedReal=t,t?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",t))}_enableTicker(t){ft.off(this._updateListener),t&&ft.on(this._updateListener)}destroy(){var t,r,i;this.removeAllListeners(),this._stop(),(t=this._gain)==null||t.disconnect(),this._gain=null,(r=this._audio)==null||r.context.off("refresh",this.refresh),(i=this._audio)==null||i.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(s=>s.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class Xa extends Cn{constructor(t){const r=Le.audioContext,i=r.createBufferSource(),s=r.createGain(),o=r.createAnalyser();i.connect(o),o.connect(s),s.connect(Le.instance.destination);super(o,s);d(this,"_sourceBuffer");d(this,"_sourceNode");d(this,"_sourceLoad");d(this,"gain");d(this,"analyser");this.parent=t,this._sourceNode=i,this.gain=s,this.analyser=o}get context(){return Le.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){var t;return((t=this._sourceNode.buffer)==null?void 0:t.duration)??0}get buffer(){return this._sourceNode.buffer}set buffer(t){this._sourceNode.buffer=t}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(t=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>t(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>t(this)):t(this)})),this._sourceLoad}_loadUrl(t){return new Promise(r=>{fetch(t).then(i=>i.arrayBuffer()).then(i=>this._decode(i)).finally(()=>r(this))})}_decode(t){return Promise.resolve(t instanceof AudioBuffer?t:Le.decode(t)).then(r=>(this.parent.isLoaded=!0,this.buffer=r,r))}cloneSource(){const t=this.context,r=this._sourceNode,i=t.audioContext.createBufferSource(),s=t.audioContext.createGain();return i.buffer=r.buffer,i.loop=r.loop,t.setParamValue(i.playbackRate,r.playbackRate.value),i.connect(s),s.connect(this.destination),{source:i,gain:s}}createSound(){return new Va}}var ja=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,vd=(n,e,t)=>e in n?ja(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,bd=(n,e,t,r)=>{for(var i=r>1?void 0:r?_d(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ja(e,t,i),i},xd=(n,e,t)=>vd(n,e+"",t);g.Audio=class extends g.Node{constructor(t=""){super();d(this,"_sounds",[]);d(this,"_platformAudio",zn?new Xa(this):new za(this));d(this,"_src");d(this,"isLoaded",!1);d(this,"_volume",1);d(this,"_muted",!1);d(this,"_loop",!1);d(this,"_playbackRate",1);d(this,"_isPlaying",!1);d(this,"_paused",!1);d(this,"multiple",!1);d(this,"start",0);d(this,"end",0);d(this,"_onComplete",t=>{if(this._sounds){const r=this._sounds.indexOf(t);r>-1&&this._sounds.splice(r,1),this._isPlaying=this._sounds.length>0}this._recycleSound(t)});d(this,"_prevTime",0);d(this,"_timer",0);this.src=t}get platformAudio(){return this._platformAudio}get src(){return this._src}set src(t){this._src!==t&&(this._src=t,this.load())}get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get duration(){return this._platformAudio.duration*1e3}get volume(){return this._volume}set volume(t){this._volume!==t&&(this._volume=t,this.refresh())}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this.refresh())}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate!==t&&(this._playbackRate=t,this.refresh())}get isPlaying(){return this._isPlaying}get paused(){return this._paused}set paused(t){this._paused!==t&&(this._paused=t,this.refreshPaused())}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let t=this._sounds.length-1;t>=0;t--)this._sounds[t].stop();return this}play(t={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const r=this._createSound();this._sounds.push(r),r.once("end",()=>{var o;(o=t.complete)==null||o.call(t),this._onComplete(r)}),r.once("stop",()=>this._onComplete(r));const i=((t==null?void 0:t.start)??this.start)/1e3,s=((t==null?void 0:t.end)??this.end)/1e3;return r.play({...t,start:i,end:s}),r}_removeSounds(){for(let t=this._sounds.length-1;t>=0;t--)this._recycleSound(this._sounds[t]);this._sounds.length=0}_createSound(){return g.Audio._soundPool.length>0?g.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let t=this._sounds.length,r=0;r<t;r++)this._sounds[r].refresh()}refreshPaused(){for(let t=this._sounds.length,r=0;r<t;r++)this._sounds[r].refreshPaused()}_recycleSound(t){t.destroy(),g.Audio._soundPool.includes(t)||g.Audio._soundPool.push(t)}_process(t){var r;if(super._process(t),this.isRenderable()){const i=((r=this._tree)==null?void 0:r.timeline.current)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.visibleDelay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},xd(g.Audio,"_soundPool",[]),g.Audio=bd([Z("Audio")],g.Audio);class wd extends g.Node2D{}var Pd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Wi=(n,e,t,r)=>{for(var i=r>1?void 0:r?Cd(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Pd(e,t,i),i};g.AudioWaveform=class extends g.Node2D{constructor(t={}){super();d(this,"src");d(this,"gap",0);d(this,"color","#000000");d(this,"_audioBuffer");d(this,"_src",Pr?new pt(document.createElement("canvas")):void 0);d(this,"_needsUpdateTexture",!1);this.setProperties(t)}_onUpdateProperty(t,r,i){switch(super._onUpdateProperty(t,r,i),t){case"src":this._loadSrc(r);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(t){await globalThis.fetch(t).then(r=>r.arrayBuffer()).then(r=>Le.decode(r)).then(r=>{this._audioBuffer=r,this.syncTexture(!0)})}syncTexture(t=!1){var u,f;const r=this._audioBuffer;if(!r||!t&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(u=this._src)==null?void 0:u.source;if(!i)return;const{width:s=0,height:o=0}=this.style;i.width=s,i.height=o;const a=i.getContext("2d");if(!a){console.warn("Failed to getContext('2d') in syncTexture");return}a.fillStyle=this.color;const l=r.getChannelData(0),h=Math.ceil(l.length/s),c=o/2;for(let p=1,y=-1,_=0;_<s;_++){for(let m=0;m<h;m++){const b=l[_*h+m];b<p&&(p=b),b>y&&(y=b)}if(!this.gap||_%(this.gap*2)===0){const m=_,b=(1+p)*c,w=this.gap||1,x=Math.max(1,(y-p)*c);a.fillRect(m,b,w,x),p=1,y=-1}}(f=this._src)==null||f.requestUpload(),this.requestRedraw()}_process(t){this.syncTexture(),super._process(t)}_drawSrc(){const t=this._src;t!=null&&t.valid&&(this.context.fillStyle=t,this.context.textureTransform=new qt().scale(this.style.width/t.width,this.style.height/t.height))}},Wi([U()],g.AudioWaveform.prototype,"src",2),Wi([U()],g.AudioWaveform.prototype,"gap",2),Wi([U()],g.AudioWaveform.prototype,"color",2),g.AudioWaveform=Wi([Z("AudioWaveform")],g.AudioWaveform);const Td=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,Ed=/vec(\d)\((.*)\)/;function Md(n){n=n.trim();const e=n.match(Ed);if(e){const t=Array.from({length:Number(e[1])},()=>0);return e[2].split(",").forEach((r,i)=>{t[i]=Number(r.trim())}),t}return Number(n)}const ni=class ni extends lt{constructor(t){super();d(this,"vert",`attribute vec2 position;
|
|
26
|
+
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}u(Qr,"_instance");class te extends Jr{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=Qr.instance,t){this.instance.draw(r,e,t)}constructor(){super({vertexAttributes:{position:new ze({buffer:new pt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new ze({buffer:new pt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new Jt({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(te,"_instance");class wl extends Jr{constructor(){const e=new pt({data:new Float32Array,dynamic:!0}),t=new pt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new ze({buffer:e,size:2,normalized:!1,type:"float"}),uv:new ze({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new Jt({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}update(e,t,i){return this.positionBuffer.data=e,this.uvBuffer.data=t,this.indexBuffer.data=i,this}}var xl=Object.defineProperty,Sn=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&xl(r,e,i),i};class ei extends Kr{constructor(){super();u(this,"_starting",!1);u(this,"_nextDeltaTime",0);this._onNextTick=this._onNextTick.bind(this)}get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}start(e){return this._starting||(this._starting=!0,this.removeAllListeners(),this.on("process",e),ue.on(this._onNextTick,{sort:0})),this}stop(){return this._starting&&(this._starting=!1,ue.off(this._onNextTick,{sort:0})),this}_onNextTick(){const e=ue.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}}Sn([A({default:24})],ei.prototype,"fps"),Sn([A({default:1})],ei.prototype,"speed");class Je extends dt{constructor(e){super();u(this,"_array",[]);this.dim=e}get length(){return this.dim}_operate(e,t,i){const{dim:s,_array:o}=this;let a;typeof t=="number"?a=Array.from({length:s},()=>t):t instanceof it||t instanceof Je?a=t.toArray():a=t;let l,h=[];if(i?i instanceof Je?l=i:h=i:l=this,t instanceof it){const{cols:c}=t;switch(e){case"*":for(let f=0;f<s;f++){let p=0;for(let d=0;d<s;d++)p+=o[f]*a[d*c+f];h[f]=p}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let c=0;c<s;c++)h[c]=o[c]+a[c];break;case"-":for(let c=0;c<s;c++)h[c]=o[c]-a[c];break;case"*":for(let c=0;c<s;c++)h[c]=o[c]*a[c];break;case"/":for(let c=0;c<s;c++)h[c]=o[c]/a[c];break;case"rot":{const c=Math.cos(a[0]),f=Math.sin(a[0]);h[0]=o[0]*c-o[1]*f,h[1]=o[1]*c+o[0]*f;break}case"==":{let c=!0;for(let f=0;f<s;f++)c=c&&o[f]===a[f];return c}case"=":for(let c=0;c<s;c++){const f=a[c];f!==void 0&&(o[c]=f)}return this._emitUpdate(o),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(l==null?void 0:l.set(h))??h}add(e,t){return this._operate("+",e,t)}sub(e,t){return this._operate("-",e,t)}multiply(e,t){return this._operate("*",e,t)}divide(e,t){return this._operate("/",e,t)}rotate(e){return this._operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this._operate("=",e)}equals(e){return this._operate("==",e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}onUpdate(e){return this.on("update",e),this}offUpdate(e){return this.off("update",e),this}_emitUpdate(e){this._onUpdate(e),this.emit("update",e)}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class it extends dt{constructor(e,t,i){super();u(this,"_array",[]);this.rows=e,this.cols=t,i?this.set(i):this.identity()}get length(){return this.cols*this.rows}_operate(e,t,i){const{cols:s,rows:o,length:a,_array:l}=this;let h;typeof t=="number"?h=Array.from({length:a},()=>t):t instanceof Je||t instanceof it?h=t.toArray():h=t;let c,f=[];if(i?i instanceof Je||i instanceof it?c=i:f=i:t instanceof Je?c=new t.constructor:c=this,t instanceof Je){const{dim:p}=t;switch(e){case"*":for(let d=0;d<p;d++){let m=0;for(let v=0;v<s;v++)v<p&&(m+=l[d*s+v]*(h[v]??0));f[d]=m}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let p=0;p<s;p++)for(let d=0;d<o;d++){const m=d*s;let v=0;for(let y=0;y<o;y++){const S=m+y,C=y*s+p;v+=l[S]*(h[C]??0)}f[m+p]=v}break;case"=":for(let p=0;p<a;p++){const d=h[p];d!==void 0&&(l[p]=d)}return this._emitUpdate(l),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return(c==null?void 0:c.set(f))??f}identity(){const{cols:e,rows:t}=this,i=[];for(let s=0;s<e;s++)for(let o=0;o<t;o++){const a=o*e,l=s+a;i[l]=o+a===l?1:0}return this.set(i)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}set(e){return this._operate("=",e)}multiply(e){return this._operate("*",e)}onUpdate(e){return this.on("update",e),this}offUpdate(e){return this.off("update",e),this}_emitUpdate(e){this._onUpdate(e),this.emit("update",e)}_onUpdate(e){}toArray(e=!1){const{cols:t,rows:i,_array:s}=this;if(e){const o=[];for(let a=0;a<i;a++)for(let l=0;l<t;l++)o[a+l*t]=s[l+a*t];return o}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}class Pl extends it{constructor(r){super(2,2,r)}}let Ki=class extends it{constructor(r){super(3,3,r)}invert(){const[r,e,t,i,s,o,a,l,h]=this._array,c=h*s-o*l,f=o*a-h*i,p=l*i-s*a,d=r*c+e*f+t*p;if(d===0)return this.set([0,0,0,0,0,0,0,0,0]);const m=1/d;return this.set([c*m,(t*l-h*e)*m,(o*e-t*s)*m,f*m,(h*r-t*a)*m,(t*i-o*r)*m,p*m,(e*a-l*r)*m,(s*r-e*i)*m])}};class Mn extends it{constructor(r){super(4,4,r)}}class An extends Ki{constructor(r=0,e=0,t=0,i=0,s=!1){super(),this._x=r,this._y=e,this._width=t,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(r){return this._flipY!==r&&(this._flipY=r,this._performUpdateArray()),this}translate(r,e){return(this._x!==r||this._y!==e)&&(this._x=r,this._y=e,this._performUpdateArray()),this}resize(r,e){return(this._width!==r||this._height!==e)&&(this._width=r,this._height=e,this._performUpdateArray()),this}_performUpdateArray(){const r=this._width,e=this._height;if(!r||!e)return;const t=this._x,i=this._y,s=this._flipY?-1:1,o=1/r*2,a=s*(1/e*2),l=-1-t*o,h=-s-i*a;this.set([o,0,l,0,a,h,0,0,1])}}class qe extends Ki{constructor(e=!0){super();u(this,"_cx",1);u(this,"_sx",0);u(this,"_cy",0);u(this,"_sy",1);u(this,"_translateX",0);u(this,"_translateY",0);u(this,"_translateZ",1);u(this,"_scaleX",1);u(this,"_scaleY",1);u(this,"_skewX",0);u(this,"_skewY",0);u(this,"_rotate",0);u(this,"dirtyId",0);u(this,"_needsUpdateArray",!1);u(this,"_needsUpdateFields",!1);this.autoUpdate=e}_onUpdate(e){super._onUpdate(e),this._requestUpdateFields()}_updateSkew(){this._cx=Math.cos(this._rotate+this._skewY),this._sx=Math.sin(this._rotate+this._skewY),this._cy=-Math.sin(this._rotate-this._skewX),this._sy=Math.cos(this._rotate-this._skewX)}_requestUpdateArray(){this.autoUpdate?this._performUpdateArray():this._needsUpdateArray=!0}_requestUpdateFields(){this.autoUpdate?this._performUpdateFields():this._needsUpdateFields=!0}_performUpdateArray(){const e=this._cx*this._scaleX,t=this._sx*this._scaleX,i=this._cy*this._scaleY,s=this._sy*this._scaleY,o=this._translateX,a=this._translateY,l=this._translateZ,h=this._array;this._array=[e,i,o,t,s,a,h[6],h[7],l],this.dirtyId++}_performUpdateFields(){const{a:e,c:t,tx:i,b:s,d:o,ty:a,tz:l}=this.toObject(),h=-Math.atan2(-t,o),c=Math.atan2(s,e),f=Math.abs(h+c);f<1e-5||Math.abs(le-f)<1e-5?(this._rotate=c,this._skewX=this._skewY=0):(this._rotate=0,this._skewX=h,this._skewY=c),this._scaleX=Math.sqrt(e*e+s*s),this._scaleY=Math.sqrt(t*t+o*o),this._translateX=i,this._translateY=a,this._translateZ=l,this.dirtyId++}skew(e,t){return this._skewX=e,this._skewY=t,this._updateSkew(),this._requestUpdateArray(),this}skewX(e){return this.skew(e,this._skewY)}skewY(e){return this.skew(this._skewX,e)}translate(e,t,i=1){return this._translateX=e,this._translateY=t,this._translateZ=i,this._requestUpdateArray(),this}translateX(e){return this.translate(e,this._translateY)}translateY(e){return this.translate(this._translateX,e)}translateZ(e){return this.translate(this._translateX,this._translateY,e)}translate3d(e,t,i){return this.translate(e,t,i)}scale(e,t,i=1){return this._scaleX=e,this._scaleY=t,this._requestUpdateArray(),this}scaleX(e){return this.scale(e,this._scaleY)}scaleY(e){return this.scale(this._scaleX,e)}scale3d(e,t,i){return this.scale(e,t,i)}rotate(e){return this._rotate=e,this._updateSkew(),this._requestUpdateArray(),this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate3d(e,t,i,s){const[o,a,l]=this._rotate3d(e,t,i,s);return o&&this.rotateX(o),a&&this.rotateY(a),l&&this.rotateZ(l),this}_rotateToScale(e){const t=e/le;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,i,s){if(e===1&&t===0&&i===0)return[s,0,0];if(e===0&&t===1&&i===0)return[0,s,0];if(e===0&&t===0)return[0,0,s];{const o=Math.cos(s),a=Math.sin(s),l=o+e*e*(1-o),h=e*t*(1-o)-i*a,c=e*i*(1-o)+t*a,f=o+t*t*(1-o),p=t*i*(1-o)-e*a,d=o+i*i*(1-o),m=-Math.atan2(-p,f),v=-Math.atan2(c,Math.sqrt(p*p+d*d)),y=-Math.atan2(-h,l);return[m,v,y]}}applyToPoint(e,t){const{a:i,c:s,tx:o,b:a,d:l,ty:h}=this.toObject();return[i*e+s*t+o,a*e+l*t+h]}inverse(){return this.clone().invert()}update(){let e=!1;return this._needsUpdateArray&&(this._needsUpdateArray=!1,this._performUpdateArray(),e=!0),this._needsUpdateFields&&(this._needsUpdateFields=!1,this._performUpdateFields(),e=!0),e}isIdentity(){const{a:e,b:t,c:i,d:s,tx:o,ty:a}=this.toObject();return e===1&&t===0&&i===0&&s===1&&o===0&&a===0}toObject(){const[e,t,i,s,o,a,,,l]=this._array;return{a:e,c:t,tx:i,b:s,d:o,ty:a,tz:l}}}const On=Ee/180,Cl=180/Ee;function xt(n,r,e){return Math.max(n,Math.min(r,e))}function fe(n,r,e){return(1-e)*n+e*r}const El={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(n,r=20){if(!this.adaptive||!n||Number.isNaN(n))return r;let e=Math.ceil(n/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};let Tl=class $i extends Je{get x(){return this._array[0]}set x(r){const[e,t]=this._array;e!==r&&this.set(r,t)}get y(){return this._array[1]}set y(r){const[e,t]=this._array;t!==r&&this.set(e,r)}get width(){return this.x}set width(r){this.x=r}get height(){return this.y}set height(r){this.y=r}constructor(r=0,e){super(2),this.set(typeof r=="number"?[r,e??r]:r)}update(r,e){const[t,i]=this._array;return(t!==r||i!==e)&&this.set(r,e),this}getLength(){const[r,e]=this._array;return Math.sqrt(r*r+e*e)}getAngle(){const[r,e]=this._array;return Math.atan2(-r,-e)+Math.PI}distanceTo(r){return Math.hypot(r.x-this.x,r.y-this.y)}normalize(){const[r,e]=this._array,t=1/(this.getLength()||1);return this.set(r*t,e*t),this}static lerp(r,e,t){return new $i(e).clone().sub(new $i(r)).multiply(t).add(new $i(r))}};class Sl extends Je{constructor(){super(3)}}class Un extends Je{constructor(r=0,e=0,t=0,i=0){super(4),this.set([r,e,t,i])}}var Ml=Object.defineProperty,Al=Object.getOwnPropertyDescriptor,Qt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Al(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ml(r,e,i),i},yr=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n))(yr||{});g.Node=class extends Zi{constructor(e){super();u(this,"renderable");u(this,"name",`${this.tag}:${String(this.instanceId)}`);u(this,"mask");u(this,"_computedVisibleDelay",0);u(this,"_computedVisibleDuration",Number.MAX_SAFE_INTEGER);u(this,"_computedVisibility","visible");u(this,"_internalMode",0);u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this.setProperties(e).on("enterTree",this._onEnterTree.bind(this)).on("exitTree",this._onExitTree.bind(this)).on("parented",this._onParented.bind(this)).on("unparented",this._onUnparented.bind(this)).on("ready",this._onReady.bind(this)).on("process",this._onProcess.bind(this))}get children(){return this.getChildren()}get visibleTimeline(){const e=this._computedVisibleDelay;return[e,e+this._computedVisibleDuration]}get visibleRelativeTime(){var e;return(((e=this._tree)==null?void 0:e.timeline.current)??0)-this.visibleTimeline[0]}get visibleProgress(){const[e,t]=this.visibleTimeline;return xt(0,this.visibleRelativeTime/(t-e),1)}get siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}setName(e){return this.name=e,this}getTree(){return this._tree}getViewport(){var e;return(e=this._tree)==null?void 0:e.getCurrentViewport()}getWindow(){var e;return(e=this._tree)==null?void 0:e.root}isInsideTree(){return!!this._tree}_setTree(e){const t=this._tree;if(e!==t){e?(this._tree=e,this.emit("enterTree")):t&&(this.emit("exitTree"),this._tree=e);for(let i=this._children.length,s=0;s<i;s++){const o=this._children[s];!e&&this.emit("childExitingTree",o),o._setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("postEnterTree"),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}isRenderable(){return this.renderable!==!1&&this.constructor.renderable&&this.isVisible()}isVisible(){return this._computedVisibility!=="hidden"}_updateVisibility(){var s;const e=this._parent;this._computedVisibleDelay=this.visibleDelay+((e==null?void 0:e._computedVisibleDelay)??0),e!=null&&e._computedVisibleDuration?this._computedVisibleDuration=Math.min(this._computedVisibleDelay+this.visibleDuration,e.visibleTimeline[1])-this._computedVisibleDelay:this._computedVisibleDuration=this.visibleDuration;let t=this.visibility??(e==null?void 0:e._computedVisibility)??"visible";const i=((s=this._tree)==null?void 0:s.timeline.current)??0;if(t!=="hidden"){const[o,a]=this.visibleTimeline;(i<o||i>a)&&(t="hidden")}this._computedVisibility=t}_onEnterTree(){this._enterTree(),this.emit("treeEntered")}_onExitTree(){this.emit("treeExiting"),this._exitTree(),this.emit("treeExited")}_onParented(){this._parented()}_onUnparented(){this._unparented()}_onReady(){this._ready()}_onProcess(e=0){this._updateVisibility();const t=this._tree;t==null||t.emit("nodeProcessing",this),this._process(e);const i=this.isRenderable();let s;if(t&&i){const o=t.renderStack.push(this);s=t.renderStack.currentCall,t.renderStack.currentCall=o}if(this.mask instanceof g.Node)this.getNode("__$mask")||(this.mask.renderable=!1,this.addChild(this.mask,1));else{const o=this.getNode("__$mask");o&&this.removeChild(o)}for(let o=this._children.length,a=0;a<o;a++)this._children[a].emit("process",e);t&&i&&(t.renderStack.currentCall=s),t==null||t.emit("nodeProcessed",this)}render(e,t){const i=this.mask;i&&(e.flush(),e.mask.push(this,i)),this._render(e),t==null||t(),i&&(e.flush(),e.mask.pop(this))}input(e){for(let t=this._children.length-1;t>=0;t--)this._children[t].input(e);this._input(e)}get parent(){return this._parent}hasParent(){return!!this._parent}getParent(){return this._parent}_setParent(e){var t;return(t=this._parent)!=null&&t.is(e)||(this._parent=e,this._setTree(e==null?void 0:e._tree),this.emit(e?"parented":"unparented")),this}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t._internalMode===0);default:return this._children.filter(t=>t._internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e._internalMode=this._internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}addChild(e,t=e._internalMode){if(this.is(e)||e.hasParent())return this;switch(t){case 0:case 1:{const i=t===0?2:1,s=this._children.findIndex(o=>o._internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case 2:this._children.push(e);break}return e._internalMode=t,e._setParent(this),this.emit("addChild",e),this}moveChild(e,t,i=e._internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e._internalMode=i;const s=this._children.indexOf(e);let o=this._children.findIndex(h=>{switch(i){case 0:return h._internalMode!==1;case 2:return h._internalMode===2;case 1:default:return!0}});o=o>-1?o:Math.max(0,this._children.length-1);let a=this._children.slice(o).findIndex(h=>{switch(i){case 1:return h._internalMode!==1;case 0:return h._internalMode===2;case 2:default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=xt(o,t>-1?t:a,a);return l!==s&&(s>-1&&this._children.splice(s,1),e._setParent(this),l>-1&&l<this._children.length?this._children.splice(l,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,l,s):this.emit("addChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e._setParent(void 0),this.emit("removeChild",e,t)),this}removeChildren(){this.children.forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.children.forEach(e),this}deepForEach(e){return this.children.forEach(t=>{e(t),t.deepForEach(e)}),this}is(e){return!!(e&&this.instanceId===e.instanceId)}_enterTree(){}_ready(){}_exitTree(){}_parented(){}_unparented(){}_process(e){}_input(e){}_render(e){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.children.map(e=>e.toJSON())}}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{tag:t,props:i,children:s}=e,o=Yr.get(t)??g.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},Qt([A()],g.Node.prototype,"name",2),Qt([A()],g.Node.prototype,"mask",2),Qt([A({default:"visible"})],g.Node.prototype,"visibility",2),Qt([A({default:0})],g.Node.prototype,"visibleDelay",2),Qt([A({default:Number.MAX_SAFE_INTEGER})],g.Node.prototype,"visibleDuration",2),g.Node=Qt([H("Node")],g.Node);class Dn{constructor(){u(this,"currentCall");u(this,"calls",[])}createCall(r){return{renderable:r,parentCall:this.currentCall,fn:r.render.bind(r),calls:[]}}push(r){var t;const e=this.createCall(r);return(((t=this.currentCall)==null?void 0:t.calls)??this.calls).push(e),e}render(r){this.calls.forEach(function e(t){t.fn(r,()=>{t.calls.forEach(e)})}),this.calls=[]}}var Ol=Object.defineProperty,Ul=Object.getOwnPropertyDescriptor,vr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ul(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ol(r,e,i),i};g.Timer=class extends g.Node{static from(r){const[e,t]=r?Array.isArray(r)?r:[0,r]:[];return new g.Timer({start:e,end:t})}constructor(r){super(),this.setProperties(r)}_onUpdateProperty(r,e,t){switch(super._onUpdateProperty(r,e,t),r){case"start":this.start=Math.min(e,this.end);break;case"end":this.end=e||Number.MAX_SAFE_INTEGER;break}}addTime(r){const e=this.start,t=this.end;let i=this.current+r;return this.loop&&i>t&&(i=e+i%t),this.current=xt(e,i,t),this.emit("update",this.current,r),this}_process(r){super._process(r),this.addTime(r)}},vr([A({default:0})],g.Timer.prototype,"start",2),vr([A({default:0})],g.Timer.prototype,"current",2),vr([A({default:Number.MAX_SAFE_INTEGER})],g.Timer.prototype,"end",2),vr([A({default:!1})],g.Timer.prototype,"loop",2),g.Timer=vr([H("Timer")],g.Timer);var Dl=Object.defineProperty,er=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&Dl(r,e,i),i};class de extends wt{constructor(e){super();u(this,"_isPowerOfTwo",!1);u(this,"_needsUpload",!1);this.source=e,this._updateSize()}static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}_refreshPOT(){this._isPowerOfTwo=zi(this.realWidth)&&zi(this.realHeight)}_glTextureOptions(e,t){let i=this.source;"pixels"in i&&(i={pixels:i.pixels,width:this.realWidth,height:this.realHeight});let s=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(s="clamp_to_edge"),{value:i,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:s,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"width":case"height":case"filterMode":case"wrapMode":case"pixelRatio":case"source":this.requestUpload();break}}_updateSize(){const e=this.source;"pixels"in e?(this.width=Math.max(this.width,e.width),this.height=Math.max(this.height,e.height)):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0),this.height=Number(e.naturalHeight||e.videoHeight||e.height||0))}requestUpload(){this._needsUpload=!0,this._updateSize(),this._refreshPOT()}upload(e,t){return this._needsUpload?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t})}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){fn&&this.source instanceof ImageBitmap&&this.source.close()}}er([ee()],de.prototype,"source"),er([ee({default:0})],de.prototype,"width"),er([ee({default:0})],de.prototype,"height"),er([ee({default:"linear"})],de.prototype,"filterMode"),er([ee({default:"clamp_to_edge"})],de.prototype,"wrapMode"),er([ee({default:1})],de.prototype,"pixelRatio");function Il(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&ji,crossorigin:(n==null?void 0:n.crossorigin)??null}}class Rl extends de{constructor(e,t){const i=Il(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,a),this.emit("error",a),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!ji)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(mr&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Ji extends de{constructor(r,e=1,t=1){const i={width:e,height:t,pixels:null};r&&(ArrayBuffer.isView(r)?i.pixels=new Uint8Array(r.buffer):i.pixels=new Uint8Array(r)),super(i)}}var Bl=Object.defineProperty,In=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&Bl(r,e,i),i};function Ll(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),autoPlay:!!((n==null?void 0:n.autoPlay)??!1),fps:Number((n==null?void 0:n.fps)??0),crossorigin:(n==null?void 0:n.crossorigin)??null,loop:!!((n==null?void 0:n.loop)??!1),muted:!!((n==null?void 0:n.muted)??!1),playsinline:!!((n==null?void 0:n.playsinline)??!0)}}const Qi=(Yt=class extends de{constructor(e,t){const i=Ll(t);if(!vn(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],o=document.createElement("video");i.autoLoad&&o.setAttribute("preload","auto"),i.playsinline&&(o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline","")),i.muted&&(o.setAttribute("muted",""),o.muted=!0),i.loop&&o.setAttribute("loop",""),i.autoPlay&&o.setAttribute("autoplay",""),Pn(o,s,i.crossorigin);for(let a=0;a<e.length;++a){let{src:l,mime:h}=e[a];if(l=l||e[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const f=l.split("?").shift().toLowerCase(),p=f.slice(f.lastIndexOf(".")+1);h=h||Yt.mimeTypes.get(p)||`video/${p}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}e=o}super(e);u(this,"_spf",0);u(this,"_autoPlay",!1);u(this,"_sourceLoad");u(this,"_nextTime",0);u(this,"_connected",!1);u(this,"_requestId");u(this,"_resolve");u(this,"_reject");u(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});u(this,"_onPlayStop",()=>{this._setupAutoUpdate()});u(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()});u(this,"_onError",e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)});u(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});u(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});u(this,"requestUpload",()=>{const e=Math.floor(ue.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(ue.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(ue.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(ue.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,i)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=i,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}},u(Yt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Yt);In([ee({default:!0})],Qi.prototype,"autoUpdate"),In([ee({default:0})],Qi.prototype,"fps");let Rn=Qi;class es extends Ji{}var kl=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,_r=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nl(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&kl(r,e,i),i};g.Viewport=class extends g.Node{constructor(e=!1){super();u(this,"_projection",new An);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new es,needsUpload:!1},{texture:new es,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(e){const{width:t,height:i}=this,{pixelRatio:s}=e;return this._framebuffers.forEach(o=>{const a=o.texture;a.pixelRatio=s,a.width=t,a.height=i,a.upload(e)}),{width:t,height:i,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y);break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height);break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),e.framebuffer.bind(this._glFramebuffer(e)),this.upload(e)}redraw(e,t){e.flush();const i=this.framebuffer.texture;this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t()}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e),e.clear(),t.texture.activate(e,0),te.draw(e,Qr.instance,{sampler:0})}render(e,t){var s,o;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(e),e.clear(),super.render(e,t),e.flush(),i?i.activate(e):(e.framebuffer.bind(null),(o=this._tree)==null||o.setCurrentViewport(void 0))}toProjectionArray(e=!1){return this._projection.toArray(e)}},_r([A({default:0})],g.Viewport.prototype,"x",2),_r([A({default:0})],g.Viewport.prototype,"y",2),_r([A({default:0})],g.Viewport.prototype,"width",2),_r([A({default:0})],g.Viewport.prototype,"height",2),g.Viewport=_r([H({tag:"Viewport",renderable:!0})],g.Viewport);class Bn extends ei{constructor(){super(...arguments);u(this,"renderStack",new Dn);u(this,"root",new g.Viewport(!0)._setTree(this));u(this,"timeline",new g.Timer({loop:!0})._setTree(this));u(this,"_currentViewport")}getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}_render(e,t=0){return this.timeline.addTime(t),this.emit("processing"),this.root.emit("process",t),this.emit("processed"),e.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(e),this._renderScreen(e),this}_renderScreen(e){e.state.reset();const t=e.pixelRatio,{width:i,height:s}=this.root;e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:i*t,height:s*t}),e.clear();const o=this.root.texture;o.activate(e,0),te.draw(e),e.texture.unbind(o)}}var Fl={grad:.9,turn:360,rad:360/(2*Math.PI)},gt=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},me=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=Math.pow(10,r)),Math.round(e*n)/e+0},We=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=1),n>e?e:n>r?n:r},Ln=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},kn=function(n){return{r:We(n.r,0,255),g:We(n.g,0,255),b:We(n.b,0,255),a:We(n.a)}},ts=function(n){return{r:me(n.r),g:me(n.g),b:me(n.b),a:me(n.a,3)}},$l=/^#([0-9a-f]{3,8})$/i,ti=function(n){var r=n.toString(16);return r.length<2?"0"+r:r},Nn=function(n){var r=n.r,e=n.g,t=n.b,i=n.a,s=Math.max(r,e,t),o=s-Math.min(r,e,t),a=o?s===r?(e-t)/o:s===e?2+(t-r)/o:4+(r-e)/o:0;return{h:60*(a<0?a+6:a),s:s?o/s*100:0,v:s/255*100,a:i}},Fn=function(n){var r=n.h,e=n.s,t=n.v,i=n.a;r=r/360*6,e/=100,t/=100;var s=Math.floor(r),o=t*(1-e),a=t*(1-(r-s)*e),l=t*(1-(1-r+s)*e),h=s%6;return{r:255*[t,a,o,o,l,t][h],g:255*[l,t,t,a,o,o][h],b:255*[o,o,l,t,t,a][h],a:i}},$n=function(n){return{h:Ln(n.h),s:We(n.s,0,100),l:We(n.l,0,100),a:We(n.a)}},zn=function(n){return{h:me(n.h),s:me(n.s),l:me(n.l),a:me(n.a,3)}},Vn=function(n){return Fn((e=(r=n).s,{h:r.h,s:(e*=((t=r.l)<50?t:100-t)/100)>0?2*e/(t+e)*100:0,v:t+e,a:r.a}));var r,e,t},br=function(n){return{h:(r=Nn(n)).h,s:(i=(200-(e=r.s))*(t=r.v)/100)>0&&i<200?e*t/100/(i<=100?i:200-i)*100:0,l:i/2,a:r.a};var r,e,t,i},zl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,jl=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gl=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rs={string:[[function(n){var r=$l.exec(n);return r?(n=r[1]).length<=4?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?me(parseInt(n[3]+n[3],16)/255,2):1}:n.length===6||n.length===8?{r:parseInt(n.substr(0,2),16),g:parseInt(n.substr(2,2),16),b:parseInt(n.substr(4,2),16),a:n.length===8?me(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var r=jl.exec(n)||Gl.exec(n);return r?r[2]!==r[4]||r[4]!==r[6]?null:kn({r:Number(r[1])/(r[2]?100/255:1),g:Number(r[3])/(r[4]?100/255:1),b:Number(r[5])/(r[6]?100/255:1),a:r[7]===void 0?1:Number(r[7])/(r[8]?100:1)}):null},"rgb"],[function(n){var r=zl.exec(n)||Vl.exec(n);if(!r)return null;var e,t,i=$n({h:(e=r[1],t=r[2],t===void 0&&(t="deg"),Number(e)*(Fl[t]||1)),s:Number(r[3]),l:Number(r[4]),a:r[5]===void 0?1:Number(r[5])/(r[6]?100:1)});return Vn(i)},"hsl"]],object:[[function(n){var r=n.r,e=n.g,t=n.b,i=n.a,s=i===void 0?1:i;return gt(r)&>(e)&>(t)?kn({r:Number(r),g:Number(e),b:Number(t),a:Number(s)}):null},"rgb"],[function(n){var r=n.h,e=n.s,t=n.l,i=n.a,s=i===void 0?1:i;if(!gt(r)||!gt(e)||!gt(t))return null;var o=$n({h:Number(r),s:Number(e),l:Number(t),a:Number(s)});return Vn(o)},"hsl"],[function(n){var r=n.h,e=n.s,t=n.v,i=n.a,s=i===void 0?1:i;if(!gt(r)||!gt(e)||!gt(t))return null;var o=function(a){return{h:Ln(a.h),s:We(a.s,0,100),v:We(a.v,0,100),a:We(a.a)}}({h:Number(r),s:Number(e),v:Number(t),a:Number(s)});return Fn(o)},"hsv"]]},jn=function(n,r){for(var e=0;e<r.length;e++){var t=r[e][0](n);if(t)return[t,r[e][1]]}return[null,void 0]},ql=function(n){return typeof n=="string"?jn(n.trim(),rs.string):typeof n=="object"&&n!==null?jn(n,rs.object):[null,void 0]},is=function(n,r){var e=br(n);return{h:e.h,s:We(e.s+100*r,0,100),l:e.l,a:e.a}},ss=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},Gn=function(n,r){var e=br(n);return{h:e.h,s:e.s,l:We(e.l+100*r,0,100),a:e.a}},ns=function(){function n(r){this.parsed=ql(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return n.prototype.isValid=function(){return this.parsed!==null},n.prototype.brightness=function(){return me(ss(this.rgba),2)},n.prototype.isDark=function(){return ss(this.rgba)<.5},n.prototype.isLight=function(){return ss(this.rgba)>=.5},n.prototype.toHex=function(){return r=ts(this.rgba),e=r.r,t=r.g,i=r.b,o=(s=r.a)<1?ti(me(255*s)):"","#"+ti(e)+ti(t)+ti(i)+o;var r,e,t,i,s,o},n.prototype.toRgb=function(){return ts(this.rgba)},n.prototype.toRgbString=function(){return r=ts(this.rgba),e=r.r,t=r.g,i=r.b,(s=r.a)<1?"rgba("+e+", "+t+", "+i+", "+s+")":"rgb("+e+", "+t+", "+i+")";var r,e,t,i,s},n.prototype.toHsl=function(){return zn(br(this.rgba))},n.prototype.toHslString=function(){return r=zn(br(this.rgba)),e=r.h,t=r.s,i=r.l,(s=r.a)<1?"hsla("+e+", "+t+"%, "+i+"%, "+s+")":"hsl("+e+", "+t+"%, "+i+"%)";var r,e,t,i,s},n.prototype.toHsv=function(){return r=Nn(this.rgba),{h:me(r.h),s:me(r.s),v:me(r.v),a:me(r.a,3)};var r},n.prototype.invert=function(){return st({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},n.prototype.saturate=function(r){return r===void 0&&(r=.1),st(is(this.rgba,r))},n.prototype.desaturate=function(r){return r===void 0&&(r=.1),st(is(this.rgba,-r))},n.prototype.grayscale=function(){return st(is(this.rgba,-1))},n.prototype.lighten=function(r){return r===void 0&&(r=.1),st(Gn(this.rgba,r))},n.prototype.darken=function(r){return r===void 0&&(r=.1),st(Gn(this.rgba,-r))},n.prototype.rotate=function(r){return r===void 0&&(r=15),this.hue(this.hue()+r)},n.prototype.alpha=function(r){return typeof r=="number"?st({r:(e=this.rgba).r,g:e.g,b:e.b,a:r}):me(this.rgba.a,3);var e},n.prototype.hue=function(r){var e=br(this.rgba);return typeof r=="number"?st({h:r,s:e.s,l:e.l,a:e.a}):me(e.h)},n.prototype.isEqual=function(r){return this.toHex()===st(r).toHex()},n}(),st=function(n){return n instanceof ns?n:new ns(n)},qn=[],Wl=function(n){n.forEach(function(r){qn.indexOf(r)<0&&(r(ns,rs),qn.push(r))})};function Xl(n,r){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"},t={};for(var i in e)t[e[i]]=i;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=t[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),f=1/0,p="black";if(!s.length)for(var d in e)s[d]=new n(e[d]).toRgb();for(var m in e){var v=(a=c,l=s[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));v<f&&(f=v,p=m)}return p}},r.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new n(l).toRgb():null},"name"])}Wl([Xl]);class Pt{get value(){return this._value}set value(r){if(this._value===r)return;this._value=r;let e;typeof r=="number"?e={r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255}:e=r;const t=st(e);t.isValid()?this._colord=t:console.warn(`Unable to convert color ${r}`)}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(r=0){this.value=r}toArgb(r=this.a,e=!0){if(r===1)return(255<<24)+this.rgb;if(r===0)return e?0:this.rgb;let t=this.r8,i=this.g8,s=this.b8;return e&&(t=t*r+.5|0,i=i*r+.5|0,s=s*r+.5|0),(r*255<<24)+(t<<16)+(i<<8)+s}toHex(){return this._colord.toHex()}toArray(){return[this.r,this.g,this.b,this.a]}}class os extends it{constructor(r){super(4,5,r)}hueRotate(r=0){const e=Math.sin(r),t=Math.cos(r),i=.213,s=.715,o=.072;return this.multiply([i+t*(1-i)+e*-i,s+t*-s+e*-s,o+t*-o+e*(1-o),0,0,i+t*-i+e*.143,s+t*(1-s)+e*.14,o+t*-o+e*-.283,0,0,i+t*-i+e*-(1-i),s+t*-s+e*s,o+t*(1-o)+e*o,0,0,0,0,0,1,0])}saturate(r=1){const e=(r-1)*2/3+1,t=(e-1)*-.5;return this.multiply([e,t,t,0,0,t,e,t,0,0,t,t,e,0,0,0,0,0,1,0])}brightness(r=1){const e=r;return this.multiply([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])}contrast(r=1){const e=r,t=-128*(e-1);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}invert(r=1){const e=fe(1,-1,r),t=fe(0,255,r);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}sepia(r=1){const e=xt(0,r,1);return this.multiply([fe(1,.393,e),fe(0,.7689999,e),fe(0,.18899999,e),0,0,fe(0,.349,e),fe(1,.6859999,e),fe(0,.16799999,e),0,0,fe(0,.272,e),fe(0,.5339999,e),fe(1,.13099999,e),0,0,0,0,0,1,0])}opacity(r=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,r,0])}grayscale(r=1){const e=xt(0,r,1),t=fe(1,.3,e),i=fe(0,.3,e),s=fe(1,.59,e),o=fe(0,.59,e),a=fe(1,.11,e),l=fe(0,.11,e);return this.multiply([t,o,l,0,0,i,s,l,0,0,i,o,a,0,0,0,0,0,1,0])}multiply(r){const e=r,t=this._array;return this.set([t[0]*e[0]+t[1]*e[5]+t[2]*e[10]+t[3]*e[15],t[0]*e[1]+t[1]*e[6]+t[2]*e[11]+t[3]*e[16],t[0]*e[2]+t[1]*e[7]+t[2]*e[12]+t[3]*e[17],t[0]*e[3]+t[1]*e[8]+t[2]*e[13]+t[3]*e[18],t[0]*e[4]+t[1]*e[9]+t[2]*e[14]+t[3]*e[19]+t[4],t[5]*e[0]+t[6]*e[5]+t[7]*e[10]+t[8]*e[15],t[5]*e[1]+t[6]*e[6]+t[7]*e[11]+t[8]*e[16],t[5]*e[2]+t[6]*e[7]+t[7]*e[12]+t[8]*e[17],t[5]*e[3]+t[6]*e[8]+t[7]*e[13]+t[8]*e[18],t[5]*e[4]+t[6]*e[9]+t[7]*e[14]+t[8]*e[19]+t[9],t[10]*e[0]+t[11]*e[5]+t[12]*e[10]+t[13]*e[15],t[10]*e[1]+t[11]*e[6]+t[12]*e[11]+t[13]*e[16],t[10]*e[2]+t[11]*e[7]+t[12]*e[12]+t[13]*e[17],t[10]*e[3]+t[11]*e[8]+t[12]*e[13]+t[13]*e[18],t[10]*e[4]+t[11]*e[9]+t[12]*e[14]+t[13]*e[19]+t[14],t[15]*e[0]+t[16]*e[5]+t[17]*e[10]+t[18]*e[15],t[15]*e[1]+t[16]*e[6]+t[17]*e[11]+t[18]*e[16],t[15]*e[2]+t[16]*e[7]+t[17]*e[12]+t[18]*e[17],t[15]*e[3]+t[16]*e[8]+t[17]*e[13]+t[18]*e[18],t[15]*e[4]+t[16]*e[9]+t[17]*e[14]+t[18]*e[19]+t[19]])}toMatrix4(){const r=this._array;return new Mn([r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]])}toVector4(){const r=this._array;return new Un(r[4]/255,r[9]/255,r[14]/255,r[19]/255)}}class as extends de{constructor(r){const e=new Pt(r);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function Hl(n,r,e=2){const t=r&&r.length,i=t?r[0]*e:n.length;let s=Wn(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(t&&(s=Ql(n,r,s,e)),n.length>80*e){a=1/0,l=1/0;let c=-1/0,f=-1/0;for(let p=e;p<i;p+=e){const d=n[p],m=n[p+1];d<a&&(a=d),m<l&&(l=m),d>c&&(c=d),m>f&&(f=m)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return wr(s,o,e,a,l,h,0),o}function Wn(n,r,e,t,i){let s;if(i===ch(n,r,e,t)>0)for(let o=r;o<e;o+=t)s=Zn(o/t|0,n[o],n[o+1],s);else for(let o=e-t;o>=r;o-=t)s=Zn(o/t|0,n[o],n[o+1],s);return s&&tr(s,s.next)&&(Cr(s),s=s.next),s}function Bt(n,r){if(!n)return n;r||(r=n);let e=n,t;do if(t=!1,!e.steiner&&(tr(e,e.next)||se(e.prev,e,e.next)===0)){if(Cr(e),e=r=e.prev,e===e.next)break;t=!0}else e=e.next;while(t||e!==r);return r}function wr(n,r,e,t,i,s,o){if(!n)return;!o&&s&&sh(n,t,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(s?Zl(n,t,i,s):Yl(n)){r.push(l.i,n.i,h.i),Cr(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=Kl(Bt(n),r),wr(n,r,e,t,i,s,2)):o===2&&Jl(n,r,e,t,i,s):wr(Bt(n),r,e,t,i,s,1);break}}}function Yl(n){const r=n.prev,e=n,t=n.next;if(se(r,e,t)>=0)return!1;const i=r.x,s=e.x,o=t.x,a=r.y,l=e.y,h=t.y,c=Math.min(i,s,o),f=Math.min(a,l,h),p=Math.max(i,s,o),d=Math.max(a,l,h);let m=t.next;for(;m!==r;){if(m.x>=c&&m.x<=p&&m.y>=f&&m.y<=d&&xr(i,a,s,l,o,h,m.x,m.y)&&se(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Zl(n,r,e,t){const i=n.prev,s=n,o=n.next;if(se(i,s,o)>=0)return!1;const a=i.x,l=s.x,h=o.x,c=i.y,f=s.y,p=o.y,d=Math.min(a,l,h),m=Math.min(c,f,p),v=Math.max(a,l,h),y=Math.max(c,f,p),S=ls(d,m,r,e,t),C=ls(v,y,r,e,t);let x=n.prevZ,T=n.nextZ;for(;x&&x.z>=S&&T&&T.z<=C;){if(x.x>=d&&x.x<=v&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&xr(a,c,l,f,h,p,x.x,x.y)&&se(x.prev,x,x.next)>=0||(x=x.prevZ,T.x>=d&&T.x<=v&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&xr(a,c,l,f,h,p,T.x,T.y)&&se(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;x&&x.z>=S;){if(x.x>=d&&x.x<=v&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&xr(a,c,l,f,h,p,x.x,x.y)&&se(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;T&&T.z<=C;){if(T.x>=d&&T.x<=v&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&xr(a,c,l,f,h,p,T.x,T.y)&&se(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Kl(n,r){let e=n;do{const t=e.prev,i=e.next.next;!tr(t,i)&&Hn(t,e,e.next,i)&&Pr(t,i)&&Pr(i,t)&&(r.push(t.i,e.i,i.i),Cr(e),Cr(e.next),e=n=i),e=e.next}while(e!==n);return Bt(e)}function Jl(n,r,e,t,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&ah(o,a)){let l=Yn(o,a);o=Bt(o,o.next),l=Bt(l,l.next),wr(o,r,e,t,i,s,0),wr(l,r,e,t,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function Ql(n,r,e,t){const i=[];for(let s=0,o=r.length;s<o;s++){const a=r[s]*t,l=s<o-1?r[s+1]*t:n.length,h=Wn(n,a,l,t,!1);h===h.next&&(h.steiner=!0),i.push(oh(h))}i.sort(eh);for(let s=0;s<i.length;s++)e=th(i[s],e);return e}function eh(n,r){let e=n.x-r.x;if(e===0&&(e=n.y-r.y,e===0)){const t=(n.next.y-n.y)/(n.next.x-n.x),i=(r.next.y-r.y)/(r.next.x-r.x);e=t-i}return e}function th(n,r){const e=rh(n,r);if(!e)return r;const t=Yn(e,n);return Bt(t,t.next),Bt(e,e.next)}function rh(n,r){let e=r;const t=n.x,i=n.y;let s=-1/0,o;if(tr(n,e))return e;do{if(tr(n,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const f=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=t&&f>s&&(s=f,o=e.x<e.next.x?e:e.next,f===t))return o}e=e.next}while(e!==r);if(!o)return null;const a=o,l=o.x,h=o.y;let c=1/0;e=o;do{if(t>=e.x&&e.x>=l&&t!==e.x&&Xn(i<h?t:s,i,l,h,i<h?s:t,i,e.x,e.y)){const f=Math.abs(i-e.y)/(t-e.x);Pr(e,n)&&(f<c||f===c&&(e.x>o.x||e.x===o.x&&ih(o,e)))&&(o=e,c=f)}e=e.next}while(e!==a);return o}function ih(n,r){return se(n.prev,n,r.prev)<0&&se(r.next,n,n.next)<0}function sh(n,r,e,t){let i=n;do i.z===0&&(i.z=ls(i.x,i.y,r,e,t)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,nh(i)}function nh(n){let r,e=1;do{let t=n,i;n=null;let s=null;for(r=0;t;){r++;let o=t,a=0;for(let h=0;h<e&&(a++,o=o.nextZ,!!o);h++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||t.z<=o.z)?(i=t,t=t.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;t=o}s.nextZ=null,e*=2}while(r>1);return n}function ls(n,r,e,t,i){return n=(n-e)*i|0,r=(r-t)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,n|r<<1}function oh(n){let r=n,e=n;do(r.x<e.x||r.x===e.x&&r.y<e.y)&&(e=r),r=r.next;while(r!==n);return e}function Xn(n,r,e,t,i,s,o,a){return(i-o)*(r-a)>=(n-o)*(s-a)&&(n-o)*(t-a)>=(e-o)*(r-a)&&(e-o)*(s-a)>=(i-o)*(t-a)}function xr(n,r,e,t,i,s,o,a){return!(n===o&&r===a)&&Xn(n,r,e,t,i,s,o,a)}function ah(n,r){return n.next.i!==r.i&&n.prev.i!==r.i&&!lh(n,r)&&(Pr(n,r)&&Pr(r,n)&&hh(n,r)&&(se(n.prev,n,r.prev)||se(n,r.prev,r))||tr(n,r)&&se(n.prev,n,n.next)>0&&se(r.prev,r,r.next)>0)}function se(n,r,e){return(r.y-n.y)*(e.x-r.x)-(r.x-n.x)*(e.y-r.y)}function tr(n,r){return n.x===r.x&&n.y===r.y}function Hn(n,r,e,t){const i=ii(se(n,r,e)),s=ii(se(n,r,t)),o=ii(se(e,t,n)),a=ii(se(e,t,r));return!!(i!==s&&o!==a||i===0&&ri(n,e,r)||s===0&&ri(n,t,r)||o===0&&ri(e,n,t)||a===0&&ri(e,r,t))}function ri(n,r,e){return r.x<=Math.max(n.x,e.x)&&r.x>=Math.min(n.x,e.x)&&r.y<=Math.max(n.y,e.y)&&r.y>=Math.min(n.y,e.y)}function ii(n){return n>0?1:n<0?-1:0}function lh(n,r){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==r.i&&e.next.i!==r.i&&Hn(e,e.next,n,r))return!0;e=e.next}while(e!==n);return!1}function Pr(n,r){return se(n.prev,n,n.next)<0?se(n,r,n.next)>=0&&se(n,n.prev,r)>=0:se(n,r,n.prev)<0||se(n,n.next,r)<0}function hh(n,r){let e=n,t=!1;const i=(n.x+r.x)/2,s=(n.y+r.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(t=!t),e=e.next;while(e!==n);return t}function Yn(n,r){const e=hs(n.i,n.x,n.y),t=hs(r.i,r.x,r.y),i=n.next,s=r.prev;return n.next=r,r.prev=n,e.next=i,i.prev=e,t.next=e,e.prev=t,s.next=t,t.prev=s,t}function Zn(n,r,e,t){const i=hs(n,r,e);return t?(i.next=t.next,i.prev=t,t.next.prev=i,t.next=i):(i.prev=i,i.next=i),i}function Cr(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function hs(n,r,e){return{i:n,x:r,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ch(n,r,e,t){let i=0;for(let s=r,o=e-t;s<e;s+=t)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}function uh(n,r,e,t={}){const{radius:i=1}=t;n.moveTo(r,e),n.arc(r,e,i,0,Math.PI*2)}const fh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function cs(n,r){const{fill:e="#000",stroke:t="none",strokeWidth:i=t==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:d="rgba(0, 0, 0, 0)"}=r;n.fillStyle=e,n.strokeStyle=t,n.lineWidth=i,n.lineCap=s,n.lineJoin=fh[o],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=c,n.shadowOffsetY=f,n.shadowBlur=p,n.shadowColor=d}class O{constructor(r=0,e=0){this.x=r,this.y=e}static get MAX(){return new O(1/0,1/0)}static get MIN(){return new O(-1/0,-1/0)}get array(){return[this.x,this.y]}set(r,e){return this.x=r,this.y=e,this}add(r){return this.x+=r.x,this.y+=r.y,this}sub(r){return this.x-=r.x,this.y-=r.y,this}multiply(r){return this.x*=r.x,this.y*=r.y,this}divide(r){return this.x/=r.x,this.y/=r.y,this}dot(r){return this.x*r.x+this.y*r.y}cross(r){return this.x*r.y-this.y*r.x}rotate(r,e={x:0,y:0}){const t=-r/180*Math.PI,i=this.x-e.x,s=-(this.y-e.y),o=Math.sin(t),a=Math.cos(t);return this.set(e.x+(i*a-s*o),e.y-(i*o+s*a)),this}distanceTo(r){return Math.sqrt(this.distanceToSquared(r))}distanceToSquared(r){const e=this.x-r.x,t=this.y-r.y;return e*e+t*t}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(r,e=r,t={x:0,y:0}){const i=r<0?t.x-this.x+t.x:this.x,s=e<0?t.y-this.y+t.y:this.y;return this.x=i*Math.abs(r),this.y=s*Math.abs(e),this}skew(r,e=0,t={x:0,y:0}){const i=this.x-t.x,s=this.y-t.y;return this.x=t.x+(i+Math.tan(r)*s),this.y=t.y+(s+Math.tan(e)*i),this}min(...r){return this.x=Math.min(this.x,...r.map(e=>e.x)),this.y=Math.min(this.y,...r.map(e=>e.y)),this}max(...r){return this.x=Math.max(this.x,...r.map(e=>e.x)),this.y=Math.max(this.y,...r.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(r,e){return this.x=r.x+e.x,this.y=r.y+e.y,this}subVectors(r,e){return this.x=r.x-e.x,this.y=r.y-e.y,this}multiplyVectors(r,e){return this.x=r.x*e.x,this.y=r.y*e.y,this}divideVectors(r,e){return this.x=r.x/e.x,this.y=r.y/e.y,this}lerpVectors(r,e,t){return this.x=r.x+(e.x-r.x)*t,this.y=r.y+(e.y-r.y)*t,this}equals(r){return this.x===r.x&&this.y===r.y}applyMatrix3(r){const e=this.x,t=this.y,i=r.elements;return this.x=i[0]*e+i[3]*t+i[6],this.y=i[1]*e+i[4]*t+i[7],this}copy(r){return this.x=r.x,this.y=r.y,this}clone(){return new O(this.x,this.y)}}class Y{constructor(r=0,e=0,t=0,i=0){this.left=r,this.top=e,this.width=t,this.height=i}get x(){return this.left}set x(r){this.left=r}get y(){return this.top}set y(r){this.top=r}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new O((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...r){if(r.length===0)return new Y;if(r.length===1)return r[0].clone();const e=r[0],t=r.slice(1).reduce((i,s)=>(i.left=Math.min(i.left,s.left),i.top=Math.min(i.top,s.top),i.right=Math.max(i.right,s.right),i.bottom=Math.max(i.bottom,s.bottom),i),{left:(e==null?void 0:e.left)??0,top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0});return new Y(t.left,t.top,t.right-t.left,t.bottom-t.top)}translate(r,e){return this.left+=r,this.top+=e,this}copy(r){return this.left=r.left,this.top=r.top,this.width=r.width,this.height=r.height,this}clone(){return new Y(this.left,this.top,this.width,this.height)}}class ke{constructor(r=1,e=0,t=0,i=0,s=1,o=0,a=0,l=0,h=1){u(this,"elements",[]);this.set(r,e,t,i,s,o,a,l,h)}set(r,e,t,i,s,o,a,l,h){const c=this.elements;return c[0]=r,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=l,c[6]=t,c[7]=o,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(r){const e=this.elements,t=r.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}multiply(r){return this.multiplyMatrices(this,r)}premultiply(r){return this.multiplyMatrices(r,this)}multiplyMatrices(r,e){const t=r.elements,i=e.elements,s=this.elements,o=t[0],a=t[3],l=t[6],h=t[1],c=t[4],f=t[7],p=t[2],d=t[5],m=t[8],v=i[0],y=i[3],S=i[6],C=i[1],x=i[4],T=i[7],b=i[2],P=i[5],E=i[8];return s[0]=o*v+a*C+l*b,s[3]=o*y+a*x+l*P,s[6]=o*S+a*T+l*E,s[1]=h*v+c*C+f*b,s[4]=h*y+c*x+f*P,s[7]=h*S+c*T+f*E,s[2]=p*v+d*C+m*b,s[5]=p*y+d*x+m*P,s[8]=p*S+d*T+m*E,this}invert(){const r=this.elements,e=r[0],t=r[1],i=r[2],s=r[3],o=r[4],a=r[5],l=r[6],h=r[7],c=r[8],f=c*o-a*h,p=a*l-c*s,d=h*s-o*l,m=e*f+t*p+i*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return r[0]=f*v,r[1]=(i*h-c*t)*v,r[2]=(a*t-i*o)*v,r[3]=p*v,r[4]=(c*e-i*l)*v,r[5]=(i*s-a*e)*v,r[6]=d*v,r[7]=(t*l-h*e)*v,r[8]=(o*e-t*s)*v,this}transpose(){let r;const e=this.elements;return r=e[1],e[1]=e[3],e[3]=r,r=e[2],e[2]=e[6],e[6]=r,r=e[5],e[5]=e[7],e[7]=r,this}scale(r,e){return this.premultiply(us.makeScale(r,e)),this}rotate(r){return this.premultiply(us.makeRotation(-r)),this}translate(r,e){return this.premultiply(us.makeTranslation(r,e)),this}makeTranslation(r,e){return this.set(1,0,r,0,1,e,0,0,1),this}makeRotation(r){const e=Math.cos(r),t=Math.sin(r);return this.set(e,-t,0,t,e,0,0,0,1),this}makeScale(r,e){return this.set(r,0,0,0,e,0,0,0,1),this}fromArray(r,e=0){for(let t=0;t<9;t++)this.elements[t]=r[t+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const us=new ke;function Kn(n,r,e,t){const i=n*e+r*t,s=Math.sqrt(n*n+r*r)*Math.sqrt(e*e+t*t);let o=Math.acos(Math.max(-1,Math.min(1,i/s)));return n*t-r*e<0&&(o=-o),o}function dh(n,r,e,t,i,s,o,a){if(r===0||e===0){n.lineTo(a.x,a.y);return}t=t*Math.PI/180,r=Math.abs(r),e=Math.abs(e);const l=(o.x-a.x)/2,h=(o.y-a.y)/2,c=Math.cos(t)*l+Math.sin(t)*h,f=-Math.sin(t)*l+Math.cos(t)*h;let p=r*r,d=e*e;const m=c*c,v=f*f,y=m/p+v/d;if(y>1){const F=Math.sqrt(y);r=F*r,e=F*e,p=r*r,d=e*e}const S=p*v+d*m,C=(p*d-S)/S;let x=Math.sqrt(Math.max(0,C));i===s&&(x=-x);const T=x*r*f/e,b=-x*e*c/r,P=Math.cos(t)*T-Math.sin(t)*b+(o.x+a.x)/2,E=Math.sin(t)*T+Math.cos(t)*b+(o.y+a.y)/2,w=Kn(1,0,(c-T)/r,(f-b)/e),D=Kn((c-T)/r,(f-b)/e,(-c-T)/r,(-f-b)/e)%(Math.PI*2);n.ellipse(P,E,r,e,t,w,w+D,s===0)}const he={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function nt(n,r,e=0){let a=0,l=!0,h="",c="";const f=[];function p(y,S,C){const x=new SyntaxError(`Unexpected character "${y}" at index ${S}.`);throw x.partial=C,x}function d(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let m;const v=n.length;for(let y=0;y<v;y++){if(m=n[y],Array.isArray(r)&&r.includes(f.length%e)&&he.FLAGS.test(m)){a=1,h=m,d();continue}if(a===0){if(he.WHITESPACE.test(m))continue;if(he.DIGIT.test(m)||he.SIGN.test(m)){a=1,h=m;continue}if(he.POINT.test(m)){a=2,h=m;continue}he.COMMA.test(m)&&(l&&p(m,y,f),l=!0)}if(a===1){if(he.DIGIT.test(m)){h+=m;continue}if(he.POINT.test(m)){h+=m,a=2;continue}if(he.EXP.test(m)){a=3;continue}he.SIGN.test(m)&&h.length===1&&he.SIGN.test(h[0])&&p(m,y,f)}if(a===2){if(he.DIGIT.test(m)){h+=m;continue}if(he.EXP.test(m)){a=3;continue}he.POINT.test(m)&&h[h.length-1]==="."&&p(m,y,f)}if(a===3){if(he.DIGIT.test(m)){c+=m;continue}if(he.SIGN.test(m)){if(c===""){c+=m;continue}c.length===1&&he.SIGN.test(c)&&p(m,y,f)}}he.WHITESPACE.test(m)?(d(),a=0,l=!1):he.COMMA.test(m)?(d(),a=0,l=!0):he.SIGN.test(m)?(d(),a=1,h=m):he.POINT.test(m)?(d(),a=2,h=m):p(m,y,f)}return d(),f}function rr(n,r){return n-(r-n)}function Jn(n,r){const e=new O,t=new O;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o.type==="m"||o.type==="M")o.type==="m"?e.add(o):e.copy(o),r.moveTo(e.x,e.y),t.copy(e);else if(o.type==="h"||o.type==="H")o.type==="h"?e.x+=o.x:e.x=o.x,r.lineTo(e.x,e.y),t.copy(e);else if(o.type==="v"||o.type==="V")o.type==="v"?e.y+=o.y:e.y=o.y,r.lineTo(e.x,e.y),t.copy(e);else if(o.type==="l"||o.type==="L")o.type==="l"?e.add(o):e.copy(o),r.lineTo(e.x,e.y),t.copy(e);else if(o.type==="c"||o.type==="C")o.type==="c"?(r.bezierCurveTo(e.x+o.x1,e.y+o.y1,e.x+o.x2,e.y+o.y2,e.x+o.x,e.y+o.y),t.x=e.x+o.x2,t.y=e.y+o.y2,e.add(o)):(r.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),t.x=o.x2,t.y=o.y2,e.copy(o));else if(o.type==="s"||o.type==="S")o.type==="s"?(r.bezierCurveTo(rr(e.x,t.x),rr(e.y,t.y),e.x+o.x2,e.y+o.y2,e.x+o.x,e.y+o.y),t.x=e.x+o.x2,t.y=e.y+o.y2,e.add(o)):(r.bezierCurveTo(rr(e.x,t.x),rr(e.y,t.y),o.x2,o.y2,o.x,o.y),t.x=o.x2,t.y=o.y2,e.copy(o));else if(o.type==="q"||o.type==="Q")o.type==="q"?(r.quadraticCurveTo(e.x+o.x1,e.y+o.y1,e.x+o.x,e.y+o.y),t.x=e.x+o.x1,t.y=e.y+o.y1,e.add(o)):(r.quadraticCurveTo(o.x1,o.y1,o.x,o.y),t.x=o.x1,t.y=o.y1,e.copy(o));else if(o.type==="t"||o.type==="T"){const a=rr(e.x,t.x),l=rr(e.y,t.y);t.x=a,t.y=l,o.type==="t"?(r.quadraticCurveTo(a,l,e.x+o.x,e.y+o.y),e.add(o)):(r.quadraticCurveTo(a,l,o.x,o.y),e.copy(o))}else if(o.type==="a"||o.type==="A"){const a=e.clone();if(o.type==="a"){if(o.x===0&&o.y===0)continue;e.add(o)}else{if(e.equals(o))continue;e.copy(o)}t.copy(e),dh(r,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,a,e)}else o.type==="z"||o.type==="Z"?(r.startPoint&&e.copy(r.startPoint),r.closePath()):console.warn("Unsupported commands",o)}}function ph(n){let r,e;const t=[];for(let i=0,s=n.length;i<s;i++){const o=n[i];switch(o.type){case"m":case"M":if(o.x.toFixed(4)===(e==null?void 0:e.x.toFixed(4))&&o.y.toFixed(4)===(e==null?void 0:e.y.toFixed(4)))continue;t.push(`${o.type} ${o.x} ${o.y}`),e={x:o.x,y:o.y},r={x:o.x,y:o.y};break;case"h":case"H":t.push(`${o.type} ${o.x}`),e={x:o.x,y:(e==null?void 0:e.y)??0};break;case"v":case"V":t.push(`${o.type} ${o.y}`),e={x:(e==null?void 0:e.x)??0,y:o.y};break;case"l":case"L":t.push(`${o.type} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"c":case"C":t.push(`${o.type} ${o.x1} ${o.y1} ${o.x2} ${o.y2} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"s":case"S":t.push(`${o.type} ${o.x2} ${o.y2} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"q":case"Q":t.push(`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"t":case"T":t.push(`${o.type} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"a":case"A":t.push(`${o.type} ${o.rx} ${o.ry} ${o.angle} ${o.largeArcFlag} ${o.sweepFlag} ${o.x} ${o.y}`),e={x:o.x,y:o.y};break;case"z":case"Z":t.push(o.type),r&&(e={x:r.x,y:r.y});break}}return t.join(" ")}const gh=/[a-df-z][^a-df-z]*/gi;function Qn(n){const r=[],e=n.match(gh);if(!e)return r;for(let t=0,i=e.length;t<i;t++){const s=e[t],o=s.charAt(0),a=s.slice(1).trim();let l;switch(o){case"m":case"M":l=nt(a);for(let h=0,c=l.length;h<c;h+=2)h===0?r.push({type:o,x:l[h],y:l[h+1]}):r.push({type:o==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=nt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,x:l[h]});break;case"v":case"V":l=nt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,y:l[h]});break;case"l":case"L":l=nt(a);for(let h=0,c=l.length;h<c;h+=2)r.push({type:o,x:l[h],y:l[h+1]});break;case"c":case"C":l=nt(a);for(let h=0,c=l.length;h<c;h+=6)r.push({type:o,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=nt(a);for(let h=0,c=l.length;h<c;h+=4)r.push({type:o,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=nt(a);for(let h=0,c=l.length;h<c;h+=4)r.push({type:o,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=nt(a);for(let h=0,c=l.length;h<c;h+=2)r.push({type:o,x:l[h],y:l[h+1]});break;case"a":case"A":l=nt(a,[3,4],7);for(let h=0,c=l.length;h<c;h+=7)r.push({type:o,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":r.push({type:o});break;default:console.warn(s)}}return r}function eo(n,r,e,t,i){const s=(t-r)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*t+s+o)*l+(-3*e+3*t-2*s-o)*a+s*n+e}function mh(n,r){const e=1-n;return e*e*e*r}function yh(n,r){const e=1-n;return 3*e*e*n*r}function vh(n,r){return 3*(1-n)*n*n*r}function _h(n,r){return n*n*n*r}function to(n,r,e,t,i){return mh(n,r)+yh(n,e)+vh(n,t)+_h(n,i)}function bh(n,r={}){let{vertices:e=[],indices:t=[],holes:i=[],verticesStride:s=2,verticesOffset:o=0,indicesOffset:a=0}=r;const l=Hl(n,i,2);if(l){for(let c=0;c<l.length;c+=3)t[a++]=l[c]+o,t[a++]=l[c+1]+o,t[a++]=l[c+2]+o;let h=o*s;for(let c=0;c<n.length;c+=2)e[h]=n[c],e[h+1]=n[c+1],h+=s}return{vertices:e,indices:t}}const wh=8,si=11920929e-14,xh=1;function Ph(n,r,e,t,i,s,o,a,l=.5,h){const f=Math.min(.99,Math.max(0,l));let p=(xh-f)/1;return p*=p,fs(n,r,e,t,i,s,o,a,h,p,0),h.push(o,a),h}function fs(n,r,e,t,i,s,o,a,l,h,c){if(c>wh)return;const f=(n+e)/2,p=(r+t)/2,d=(e+i)/2,m=(t+s)/2,v=(i+o)/2,y=(s+a)/2,S=(f+d)/2,C=(p+m)/2,x=(d+v)/2,T=(m+y)/2,b=(S+x)/2,P=(C+T)/2;if(c>0){let E=o-n,w=a-r;const D=Math.abs((e-o)*w-(t-a)*E),F=Math.abs((i-o)*w-(s-a)*E);if(D>si&&F>si){if((D+F)*(D+F)<=h*(E*E+w*w)){l.push(b,P);return}}else if(D>si){if(D*D<=h*(E*E+w*w)){l.push(b,P);return}}else if(F>si){if(F*F<=h*(E*E+w*w)){l.push(b,P);return}}else if(E=b-(n+o)/2,w=P-(r+a)/2,E*E+w*w<=h){l.push(b,P);return}}fs(n,r,f,p,S,C,b,P,l,h,c+1),fs(b,P,x,T,v,y,o,a,l,h,c+1)}const Ch=8,Eh=11920929e-14,Th=1;function Sh(n,r,e,t,i,s,o=.5,a){const h=Math.min(.99,Math.max(0,o));let c=(Th-h)/1;return c*=c,ds(a,n,r,e,t,i,s,c,0),a.push(i,s),a}function ds(n,r,e,t,i,s,o,a,l){if(l>Ch)return;const h=(r+t)/2,c=(e+i)/2,f=(t+s)/2,p=(i+o)/2,d=(h+f)/2,m=(c+p)/2;let v=s-r,y=o-e;const S=Math.abs((t-s)*y-(i-o)*v);if(S>Eh){if(S*S<=a*(v*v+y*y)){n.push(d,m);return}}else if(v=d-(r+s)/2,y=m-(e+o)/2,v*v+y*y<=a){n.push(d,m);return}ds(n,r,e,h,c,d,m,a,l+1),ds(n,d,m,f,p,s,o,a,l+1)}function Mh(n,r){const e=1-n;return e*e*r}function Ah(n,r){return 2*(1-n)*n*r}function Oh(n,r){return n*n*r}function ro(n,r,e,t){return Mh(n,r)+Ah(n,e)+Oh(n,t)}const Uh=1e-4,io=1e-4;function so(n,r={}){const{vertices:e=[],indices:t=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:s=!1,closed:o=!0}=r,a=Uh;if(n.length===0)return{vertices:e,indices:t};const l=i;let h=l.alignment;if(i.alignment!==.5){let k=Dh(n);s&&(k*=-1),h=(h-.5)*k+.5}const c={x:n[0],y:n[1]},f={x:n[n.length-2],y:n[n.length-1]},p=o,d=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(p){n=n.slice(),d&&(n.pop(),n.pop(),f.x=n[n.length-2],f.y=n[n.length-1]);const k=(c.x+f.x)*.5,L=(f.y+c.y)*.5;n.unshift(k,L),n.push(k,L)}const m=e,v=n.length/2;let y=n.length;const S=m.length/2,C=l.width/2,x=C*C,T=l.miterLimit*l.miterLimit;let b=n[0],P=n[1],E=n[2],w=n[3],D=0,F=0,B=-(P-w),U=b-E,V=0,M=0,N=Math.sqrt(B*B+U*U);B/=N,U/=N,B*=C,U*=C;const q=h,R=(1-q)*2,I=q*2;p||(l.cap==="round"?y+=Lt(b-B*(R-I)*.5,P-U*(R-I)*.5,b-B*R,P-U*R,b+B*I,P+U*I,m,!0)+2:l.cap==="square"&&(y+=no(b,P,B,U,R,I,!0,m))),m.push(b-B*R,P-U*R),m.push(b+B*I,P+U*I);for(let k=1;k<v-1;++k){b=n[(k-1)*2],P=n[(k-1)*2+1],E=n[k*2],w=n[k*2+1],D=n[(k+1)*2],F=n[(k+1)*2+1],B=-(P-w),U=b-E,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=C,U*=C,V=-(w-F),M=E-D,N=Math.sqrt(V*V+M*M),V/=N,M/=N,V*=C,M*=C;const L=E-b,K=P-w,X=E-D,W=F-w,G=L*X+K*W,Q=K*X-W*L,Z=Q<0;if(Math.abs(Q)<.001*Math.abs(G)){m.push(E-B*R,w-U*R),m.push(E+B*I,w+U*I),G>=0&&(l.join==="round"?y+=Lt(E,w,E-B*R,w-U*R,E-V*R,w-M*R,m,!1)+4:y+=2,m.push(E-V*I,w-M*I),m.push(E+V*R,w+M*R));continue}const ae=(-B+b)*(-U+w)-(-B+E)*(-U+P),ut=(-V+D)*(-M+w)-(-V+E)*(-M+F),Ze=(L*ut-X*ae)/Q,Le=(W*ae-K*ut)/Q,Fe=(Ze-E)*(Ze-E)+(Le-w)*(Le-w),Ce=E+(Ze-E)*R,$e=w+(Le-w)*R,tt=E-(Ze-E)*I,rt=w-(Le-w)*I,Ke=Math.min(L*L+K*K,X*X+W*W),il=Z?R:I,Qd=Ke+il*il*x;Fe<=Qd?l.join==="bevel"||Fe/x>T?(Z?(m.push(Ce,$e),m.push(E+B*I,w+U*I),m.push(Ce,$e),m.push(E+V*I,w+M*I)):(m.push(E-B*R,w-U*R),m.push(tt,rt),m.push(E-V*R,w-M*R),m.push(tt,rt)),y+=2):l.join==="round"?Z?(m.push(Ce,$e),m.push(E+B*I,w+U*I),y+=Lt(E,w,E+B*I,w+U*I,E+V*I,w+M*I,m,!0)+4,m.push(Ce,$e),m.push(E+V*I,w+M*I)):(m.push(E-B*R,w-U*R),m.push(tt,rt),y+=Lt(E,w,E-B*R,w-U*R,E-V*R,w-M*R,m,!1)+4,m.push(E-V*R,w-M*R),m.push(tt,rt)):(m.push(Ce,$e),m.push(tt,rt)):(m.push(E-B*R,w-U*R),m.push(E+B*I,w+U*I),l.join==="round"?Z?y+=Lt(E,w,E+B*I,w+U*I,E+V*I,w+M*I,m,!0)+2:y+=Lt(E,w,E-B*R,w-U*R,E-V*R,w-M*R,m,!1)+2:l.join==="miter"&&Fe/x<=T&&(Z?(m.push(tt,rt),m.push(tt,rt)):(m.push(Ce,$e),m.push(Ce,$e)),y+=2),m.push(E-V*R,w-M*R),m.push(E+V*I,w+M*I),y+=2)}b=n[(v-2)*2],P=n[(v-2)*2+1],E=n[(v-1)*2],w=n[(v-1)*2+1],B=-(P-w),U=b-E,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=C,U*=C,m.push(E-B*R,w-U*R),m.push(E+B*I,w+U*I),p||(l.cap==="round"?y+=Lt(E-B*(R-I)*.5,w-U*(R-I)*.5,E-B*R,w-U*R,E+B*I,w+U*I,m,!1)+2:l.cap==="square"&&(y+=no(E,w,B,U,R,I,!1,m)));const j=io*io;for(let k=S;k<y+S-2;++k)b=m[k*2],P=m[k*2+1],E=m[(k+1)*2],w=m[(k+1)*2+1],D=m[(k+2)*2],F=m[(k+2)*2+1],!(Math.abs(b*(w-F)+E*(F-P)+D*(P-w))<j)&&t.push(k,k+1,k+2);return{vertices:e,indices:t}}function Dh(n){const r=n.length;if(r<6)return 1;let e=0;for(let t=0,i=n[r-2],s=n[r-1];t<r;t+=2){const o=n[t],a=n[t+1];e+=(o-i)*(a+s),i=o,s=a}return e<0?-1:1}function no(n,r,e,t,i,s,o,a){const l=n-e*i,h=r-t*i,c=n+e*s,f=r+t*s;let p,d;o?(p=t,d=-e):(p=-t,d=e);const m=l+p,v=h+d,y=c+p,S=f+d;return a.push(m,v),a.push(y,S),2}function Lt(n,r,e,t,i,s,o,a){const l=e-n,h=t-r;let c=Math.atan2(l,h),f=Math.atan2(i-n,s-r);a&&c<f?c+=Math.PI*2:!a&&c>f&&(f+=Math.PI*2);let p=c;const d=f-c,m=Math.abs(d),v=Math.sqrt(l*l+h*h),y=(15*m*Math.sqrt(v)/Math.PI>>0)+1,S=d/y;if(p+=S,a){o.push(n,r),o.push(e,t);for(let C=1,x=p;C<y;C++,x+=S)o.push(n,r),o.push(n+Math.sin(x)*v,r+Math.cos(x)*v);o.push(n,r),o.push(i,s)}else{o.push(e,t),o.push(n,r);for(let C=1,x=p;C<y;C++,x+=S)o.push(n+Math.sin(x)*v,r+Math.cos(x)*v),o.push(n,r);o.push(i,s),o.push(n,r)}return y*2}class ir{constructor(){u(this,"arcLengthDivision",200);u(this,"_arcLengths")}getPointAt(r,e=new O){return this.getPoint(this.getUToTMapping(r),e)}isClockwise(){const r=this.getPoint(1),e=this.getPoint(.5),t=this.getPoint(1);return(e.x-r.x)*(t.y-e.y)-(e.y-r.y)*(t.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(r){return this.getControlPointRefs().forEach(e=>{e.applyMatrix3(r)}),this}getUnevenPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPoint(i/s,t),e.push(t.x,t.y);return e}getSpacedPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPointAt(i/s,t),e.push(t.x,t.y);return e}getAdaptivePointArray(r=[]){return this.getUnevenPointArray(5,r)}_pointArrayToPoint(r,e=[]){for(let t=0,i=r.length;t<i;t+=2){const s=r[t],o=r[t+1];e.push(new O(s,o))}return e}getSpacedPoints(r,e=[]){const t=this.getSpacedPointArray(r);return this._pointArrayToPoint(t,e),e}getUnevenPoints(r,e=[]){const t=this.getUnevenPointArray(r);return this._pointArrayToPoint(t,e),e}getAdaptivePoints(r=[]){const e=this.getAdaptivePointArray();return this._pointArrayToPoint(e,r),r}getPoints(r,e=[]){let t;return r?t=this.getUnevenPointArray(r):t=this.getAdaptivePointArray(),this._pointArrayToPoint(t,e),e}getLength(){const r=this.getLengths();return r[r.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const r=this.arcLengthDivision,e=[0];for(let t=0,i=this.getPoint(0),s=1;s<=r;s++){const o=this.getPoint(s/r);t+=o.distanceTo(i),e.push(t),i=o}this._arcLengths=e}getUToTMapping(r,e){const t=this.getLengths(),i=t.length,s=e??r*t[i-1];if(i<2)return s/t[0];let o=0,a=0,l=i-1,h;for(;a<=l;)if(o=Math.floor(a+(l-a)/2),h=t[o]-s,h<0)a=o+1;else if(h>0)l=o-1;else{l=o;break}if(o=l,t[o]===s)return o/(i-1);const c=t[o],p=t[o+1]-c,d=(s-c)/p;return(o+d)/(i-1)}getTangent(r,e=new O){const i=Math.max(0,r-1e-4),s=Math.min(1,r+1e-4);return e.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(r,e){return this.getTangent(this.getUToTMapping(r),e)}getNormal(r,e=new O){return this.getTangent(r,e),e.set(-e.y,e.x).normalize()}getNormalAt(r,e){return this.getNormal(this.getUToTMapping(r),e)}getTForPoint(r,e=.001){let t=0,i=1,s=(t+i)/2;for(;i-t>e;){s=(t+i)/2;const o=this.getPoint(s);if(o.distanceTo(r)<e)return s;o.x<r.x?t=s:i=s}return s}getMinMax(r=O.MAX,e=O.MIN){const t=this.getPoints();for(let i=0,s=t.length;i<s;i++){const o=t[i];r.min(o),e.max(o)}return{min:r,max:e}}getBoundingBox(){const{min:r,max:e}=this.getMinMax();return new Y(r.x,r.y,e.x-r.x,e.y-r.y)}fillTriangulate(r){return bh(this.getPoints().reduce((e,t)=>(e.push(t.x,t.y),e),[]),r)}strokeTriangulate(r){return so(this.getPoints().reduce((e,t)=>(e.push(t.x,t.y),e),[]),r)}toCommands(){const r=[],e=this.getPoints();for(let t=0,i=e.length;t<i;t++){const s=e[t];t===0?r.push({type:"M",x:s.x,y:s.y}):r.push({type:"L",x:s.x,y:s.y})}return r}toData(){return ph(this.toCommands())}drawTo(r){return this.toCommands().forEach(e=>{switch(e.type){case"M":r.moveTo(e.x,e.y);break;case"L":r.lineTo(e.x,e.y);break}}),this}copy(r){return this.arcLengthDivision=r.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Ih=new ke,oo=new ke,ao=new ke,ni=new O;class ps extends ir{constructor(r=new O,e=new O,t=new O,i=0,s=0,o=Math.PI*2,a=!1){super(),this._center=r,this._radius=e,this._diff=t,this.rotate=i,this.startAngle=s,this.endAngle=o,this.clockwise=a}get cx(){return this._center.x}set cx(r){this._center.x=r}get cy(){return this._center.y}set cy(r){this._center.y=r}get rx(){return this._radius.x}set rx(r){this._radius.x=r}get ry(){return this._radius.y}set ry(r){this._radius.y=r}get dx(){return this._diff.x}set dx(r){this._diff.x=r}get dy(){return this._diff.y}set dy(r){this._diff.y=r}isClockwise(){return this.clockwise}getPoint(r,e=new O){const t=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=t;for(;i>t;)i-=t;i<Number.EPSILON&&(s?i=0:i=t),this.clockwise&&!s&&(i===t?i=-t:i=i-t);const o=this.startAngle+r*i;let a=this.cx+this.rx*Math.cos(o),l=this.cy+this.ry*Math.sin(o);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),f=a-this.cx,p=l-this.cy;a=f*h-p*c+this.cx,l=f*c+p*h+this.cy}return e.set(a,l)}toCommands(){const{cx:r,cy:e,rx:t,ry:i,startAngle:s,endAngle:o,clockwise:a,rotate:l}=this,h=r+t*Math.cos(s)*Math.cos(l)-i*Math.sin(s)*Math.sin(l),c=e+t*Math.cos(s)*Math.sin(l)+i*Math.sin(s)*Math.cos(l),f=Math.abs(s-o),p=f>Math.PI?1:0,d=a?1:0,m=l*180/Math.PI;if(f>=2*Math.PI){const v=s+Math.PI,y=r+t*Math.cos(v)*Math.cos(l)-i*Math.sin(v)*Math.sin(l),S=e+t*Math.cos(v)*Math.sin(l)+i*Math.sin(v)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:d,x:y,y:S},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:d,x:h,y:c}]}else{const v=r+t*Math.cos(o)*Math.cos(l)-i*Math.sin(o)*Math.sin(l),y=e+t*Math.cos(o)*Math.sin(l)+i*Math.sin(o)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:p,sweepFlag:d,x:v,y}]}}drawTo(r){const{cx:e,cy:t,rx:i,ry:s,rotate:o,startAngle:a,endAngle:l,clockwise:h}=this;return r.ellipse(e,t,i,s,o,a,l,!h),this}applyTransform(r){return ni.set(this.cx,this.cy),ni.applyMatrix3(r),this.cx=ni.x,this.cy=ni.y,Lh(r)?Rh(this,r):Bh(this,r),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,ry:s,dx:o,dy:a}=this;if(!(i>=0&&s>=0&&o>=0&&a>=0))return r;const l=Math.ceil(2.3*Math.sqrt(i+s)),h=l*8+(o?4:0)+(a?4:0);if(h===0)return r;const c=[];if(l===0)c[0]=c[6]=e+o,c[1]=c[3]=t+a,c[2]=c[4]=e-o,c[5]=c[7]=t-a;else{let f=0,p=l*4+(o?2:0)+2,d=p,m=h,v=o+i,y=a,S=e+v,C=e-v,x=t+y;if(c[f++]=S,c[f++]=x,c[--p]=x,c[--p]=C,a){const b=t-y;c[d++]=C,c[d++]=b,c[--m]=b,c[--m]=S}for(let b=1;b<l;b++){const P=Math.PI/2*(b/l),E=o+Math.cos(P)*i,w=a+Math.sin(P)*s,D=e+E,F=e-E,B=t+w,U=t-w;c[f++]=D,c[f++]=B,c[--p]=B,c[--p]=F,c[d++]=F,c[d++]=U,c[--m]=U,c[--m]=D}v=o,y=a+s,S=e+v,C=e-v,x=t+y;const T=t-y;c[f++]=S,c[f++]=x,c[--m]=T,c[--m]=S,o&&(c[f++]=C,c[f++]=x,c[--m]=T,c[--m]=C)}return Array.prototype.push.apply(r,c),r}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const a=this.getAdaptivePointArray();if(a.length===0)return{vertices:e,indices:t};let l=0,h=0;for(let p=0;p<a.length;p+=2)l+=a[p],h+=a[p+1];l/=a.length/2,h/=a.length/2;let c=s;e[c*i]=l,e[c*i+1]=h;const f=c++;for(let p=0;p<a.length;p+=2)e[c*i]=a[p],e[c*i+1]=a[p+1],p>0&&(t[o++]=c,t[o++]=f,t[o++]=c-1),c++;return t[o++]=f+1,t[o++]=f,t[o++]=c-1,{vertices:e,indices:t}}getMinMax(r=O.MAX,e=O.MIN){const{cx:t,cy:i,rx:s,ry:o,rotate:a}=this,l=Math.cos(a),h=Math.sin(a),c=Math.sqrt(s*s*l*l+o*o*h*h),f=Math.sqrt(s*s*h*h+o*o*l*l);return r.x=Math.min(r.x,t-c),r.y=Math.min(r.y,i-f),e.x=Math.max(e.x,t+c),e.y=Math.max(e.y,i+f),{min:r,max:e}}copy(r){return super.copy(r),this.cx=r.cx,this.cy=r.cy,this.rx=r.rx,this.ry=r.ry,this.dx=r.dx,this.dy=r.dy,this.startAngle=r.startAngle,this.endAngle=r.endAngle,this.clockwise=r.clockwise,this.rotate=r.rotate,this}}function Rh(n,r){const e=n.rx,t=n.ry,i=Math.cos(n.rotate),s=Math.sin(n.rotate),o=new O(e*i,e*s),a=new O(-t*s,t*i),l=o.applyMatrix3(r),h=a.applyMatrix3(r),c=Ih.set(l.x,h.x,0,l.y,h.y,0,0,0,1),f=oo.copy(c).invert(),m=ao.copy(f).transpose().multiply(f).elements,v=kh(m[0],m[1],m[4]),y=Math.sqrt(v.rt1),S=Math.sqrt(v.rt2);if(n.rx=1/y,n.ry=1/S,n.rotate=Math.atan2(v.sn,v.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const x=oo.set(y,0,0,0,S,0,0,0,1),T=ao.set(v.cs,v.sn,0,-v.sn,v.cs,0,0,0,1),b=x.multiply(T).multiply(c),P=E=>{const{x:w,y:D}=new O(Math.cos(E),Math.sin(E)).applyMatrix3(b);return Math.atan2(D,w)};n.startAngle=P(n.startAngle),n.endAngle=P(n.endAngle),lo(r)&&(n.clockwise=!n.clockwise)}}function Bh(n,r){const e=ho(r),t=co(r);n.rx*=e,n.ry*=t;const i=e>Number.EPSILON?Math.atan2(r.elements[1],r.elements[0]):Math.atan2(-r.elements[3],r.elements[4]);n.rotate+=i,lo(r)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function lo(n){const r=n.elements;return r[0]*r[4]-r[1]*r[3]<0}function Lh(n){const r=n.elements,e=r[0]*r[3]+r[1]*r[4];if(e===0)return!1;const t=ho(n),i=co(n);return Math.abs(e/(t*i))>Number.EPSILON}function ho(n){const r=n.elements;return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function co(n){const r=n.elements;return Math.sqrt(r[3]*r[3]+r[4]*r[4])}function kh(n,r,e){let t,i,s,o,a;const l=n+e,h=n-e,c=Math.sqrt(h*h+4*r*r);return l>0?(t=.5*(l+c),a=1/t,i=n*a*e-r*a*r):l<0?i=.5*(l-c):(t=.5*c,i=-.5*c),h>0?s=h+c:s=h-c,Math.abs(s)>2*Math.abs(r)?(a=-2*r/s,o=1/Math.sqrt(1+a*a),s=a*o):Math.abs(r)===0?(s=1,o=0):(a=-.5*s/r,s=1/Math.sqrt(1+a*a),o=a*s),h>0&&(a=s,s=-o,o=a),{rt1:t,rt2:i,cs:s,sn:o}}class Nh extends ps{constructor(r=0,e=0,t=1,i=0,s=Math.PI*2,o=!1){super(new O(r,e),new O(t,t),new O(0,0),0,i,s,o)}drawTo(r){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;return r.arc(e,t,i,s,o,!a),this}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;let l=Math.abs(s-o);(!a&&s>o||a&&o>s)&&(l=2*Math.PI-l);let h=Math.max(6,Math.floor(6*i**(1/3)*(l/Math.PI)));h=Math.max(h,3);let c=l/h,f=s;c*=a?1:-1;for(let p=0;p<h+1;p++){const d=Math.cos(f),m=Math.sin(f),v=e+d*i,y=t+m*i;r.push(v,y),f+=c}return r}}class gs extends ir{constructor(r=[]){super(),this.curves=r}addCurve(r){return this.curves.push(r),this}getPoint(r,e=new O){const t=r*this.getLength(),i=this.getLengths();let s=0;for(;s<i.length;){if(i[s]>=t){const o=i[s]-t,a=this.curves[s],l=a.getLength();return a.getPointAt(l===0?0:1-o/l,e)}s++}return e}updateLengths(){const r=[];for(let e=0,t=0,i=this.curves.length;e<i;e++)t+=this.curves[e].getLength(),r.push(t);this._arcLengths=r}getControlPointRefs(){return this.curves.flatMap(r=>r.getControlPointRefs())}getAdaptivePointArray(r=[]){let e;return this.curves.forEach(t=>{t.getAdaptivePointArray(r),e&&r[e-1]===r[e+1]&&r[e]===r[e+2]&&r.splice(e+1,2),e=r.length-1}),r}getMinMax(r=O.MAX,e=O.MIN){return this.curves.forEach(t=>t.getMinMax(r,e)),{min:r,max:e}}getBoundingBox(){const{min:r,max:e}=this.getMinMax();return new Y(r.x,r.y,e.x-r.x,e.y-r.y)}toCommands(){return this.curves.flatMap(r=>r.toCommands())}drawTo(r){var t;const e=(t=this.curves[0])==null?void 0:t.getPoint(0);return e&&r.moveTo(e.x,e.y),this.curves.forEach(i=>i.drawTo(r)),this}copy(r){return super.copy(r),this.curves=r.curves.map(e=>e.clone()),this}}class ms extends ir{constructor(r=new O,e=new O,t=new O,i=new O){super(),this.p1=r,this.cp1=e,this.cp2=t,this.p2=i}static from(r,e,t,i,s,o,a,l){return new ms(new O(r,e),new O(t,i),new O(s,o),new O(a,l))}getPoint(r,e=new O){const{p1:t,cp1:i,cp2:s,p2:o}=this;return e.set(to(r,t.x,i.x,s.x,o.x),to(r,t.y,i.y,s.y,o.y))}getAdaptivePointArray(r=[]){return Ph(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,r)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(r,e,t){const i=e*e-4*r*t;if(i<0)return[];const s=Math.sqrt(i),o=(-e+s)/(2*r),a=(-e-s)/(2*r);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(r=O.MAX,e=O.MIN){const{p1:t,cp1:i,cp2:s,p2:o}=this,a=this._solveQuadratic(3*(i.x-t.x),6*(s.x-i.x),3*(o.x-s.x)),l=this._solveQuadratic(3*(i.y-t.y),6*(s.y-i.y),3*(o.y-s.y)),h=[0,1,...a,...l];return((f,p)=>{for(const d of f)for(let m=0;m<=p;m++){const v=m/p-.5,y=Math.min(1,Math.max(0,d+v)),S=this.getPoint(y);r.x=Math.min(r.x,S.x),r.y=Math.min(r.y,S.y),e.x=Math.max(e.x,S.x),e.y=Math.max(e.y,S.y)}})(h,10),{min:r,max:e}}toCommands(){const{p1:r,cp1:e,cp2:t,p2:i}=this;return[{type:"M",x:r.x,y:r.y},{type:"C",x1:e.x,y1:e.y,x2:t.x,y2:t.y,x:i.x,y:i.y}]}drawTo(r){const{p1:e,cp1:t,cp2:i,p2:s}=this;return r.lineTo(e.x,e.y),r.bezierCurveTo(t.x,t.y,i.x,i.y,s.x,s.y),this}copy(r){return super.copy(r),this.p1.copy(r.p1),this.cp1.copy(r.cp1),this.cp2.copy(r.cp2),this.p2.copy(r.p2),this}}class Fh extends ps{constructor(r=0,e=0,t=1,i=1,s=0,o=0,a=Math.PI*2,l=!1){super(new O(r,e),new O(t,i),new O,s,o,a,l)}drawTo(r){return r.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Ct extends ir{constructor(r=new O,e=new O){super(),this.p1=r,this.p2=e}static from(r,e,t,i){return new Ct(new O(r,e),new O(t,i))}getPoint(r,e=new O){return r===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(r).add(this.p1),e}getPointAt(r,e=new O){return this.getPoint(r,e)}getTangent(r,e=new O){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(r,e=new O){return this.getTangent(r,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(r=[]){return r.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),r}getMinMax(r=O.MAX,e=O.MIN){const{p1:t,p2:i}=this;return r.x=Math.min(r.x,t.x,i.x),r.y=Math.min(r.y,t.y,i.y),e.x=Math.max(e.x,t.x,i.x),e.y=Math.max(e.y,t.y,i.y),{min:r,max:e}}toCommands(){const{p1:r,p2:e}=this;return[{type:"M",x:r.x,y:r.y},{type:"L",x:e.x,y:e.y}]}drawTo(r){const{p1:e,p2:t}=this;return r.lineTo(e.x,e.y),r.lineTo(t.x,t.y),this}copy(r){return super.copy(r),this.p1.copy(r.p1),this.p2.copy(r.p2),this}}class $h extends gs{}class ys extends ir{constructor(r=new O,e=new O,t=new O){super(),this.p1=r,this.cp=e,this.p2=t}static from(r,e,t,i,s,o){return new ys(new O(r,e),new O(t,i),new O(s,o))}getPoint(r,e=new O){const{p1:t,cp:i,p2:s}=this;return e.set(ro(r,t.x,i.x,s.x),ro(r,t.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(r=[]){return Sh(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,r)}getMinMax(r=O.MAX,e=O.MIN){const{p1:t,cp:i,p2:s}=this,o=.5*(t.x+i.x),a=.5*(t.y+i.y),l=.5*(t.x+s.x),h=.5*(t.y+s.y);return r.x=Math.min(r.x,t.x,s.x,o,l),r.y=Math.min(r.y,t.y,s.y,a,h),e.x=Math.max(e.x,t.x,s.x,o,l),e.y=Math.max(e.y,t.y,s.y,a,h),{min:r,max:e}}toCommands(){const{p1:r,cp:e,p2:t}=this;return[{type:"M",x:r.x,y:r.y},{type:"Q",x1:e.x,y1:e.y,x:t.x,y:t.y}]}drawTo(r){const{p1:e,cp:t,p2:i}=this;return r.lineTo(e.x,e.y),r.quadraticCurveTo(t.x,t.y,i.x,i.y),this}copy(r){return super.copy(r),this.p1.copy(r.p1),this.cp.copy(r.cp),this.p2.copy(r.p2),this}}class zh extends $h{constructor(r=0,e=0,t=0,i=0){super(),this.x=r,this.y=e,this.width=t,this.height=i,this.update()}update(){const{x:r,y:e,width:t,height:i}=this,s=[new O(r,e),new O(r+t,e),new O(r+t,e+i),new O(r,e+i)];return this.curves=[new Ct(s[0],s[1]),new Ct(s[1],s[2]),new Ct(s[2],s[3]),new Ct(s[3],s[0])],this}drawTo(r){return r.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const{x:a,y:l,width:h,height:c}=this,f=[a,l,a+h,l,a+h,l+c,a,l+c];let p=0;s*=i,e[s+p]=f[0],e[s+p+1]=f[1],p+=i,e[s+p]=f[2],e[s+p+1]=f[3],p+=i,e[s+p]=f[6],e[s+p+1]=f[7],p+=i,e[s+p]=f[4],e[s+p+1]=f[5],p+=i;const d=s/i;return t[o++]=d,t[o++]=d+1,t[o++]=d+2,t[o++]=d+1,t[o++]=d+3,t[o++]=d+2,{vertices:e,indices:t}}copy(r){return super.copy(r),this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height,this.update(),this}}class Vh extends ps{constructor(r=0,e=0,t=1,i=1,s=1){super(),this.x=r,this.y=e,this.width=t,this.height=i,this.radius=s,this.update()}update(){const{x:r,y:e,width:t,height:i,radius:s}=this,o=t/2,a=i/2,l=r+o,h=e+a,c=Math.max(0,Math.min(s,Math.min(o,a))),f=c,p=o-c,d=a-f;return this._center=new O(l,h),this._radius=new O(c,f),this._diff=new O(p,d),this}drawTo(r){const{x:e,y:t,width:i,height:s,radius:o}=this;return r.roundRect(e,t,i,s,o),this}copy(r){return super.copy(r),this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height,this.radius=r.radius,this.update(),this}}class jh extends ir{constructor(r=[]){super(),this.points=r}getPoint(r,e=new O){const{points:t}=this,i=(t.length-1)*r,s=Math.floor(i),o=i-s,a=t[s===0?s:s-1],l=t[s],h=t[s>t.length-2?t.length-1:s+1],c=t[s>t.length-3?t.length-1:s+2];return e.set(eo(o,a.x,l.x,h.x,c.x),eo(o,a.y,l.y,h.y,c.y)),e}getControlPointRefs(){return this.points}copy(r){super.copy(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++)this.points.push(r.points[e].clone());return this}}class Er extends gs{constructor(e){super();u(this,"startPoint");u(this,"currentPoint");u(this,"autoClose",!1);e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++){const{x:s,y:o}=e[t];this.lineTo(s,o)}return this}addCommands(e){return Jn(e,this),this}addData(e){return this.addCommands(Qn(e)),this}getUnevenPointArray(e=40,t=[]){return super.getUnevenPointArray(e,t),this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getSpacedPointArray(e=40,t=[]){return super.getSpacedPointArray(e,t),this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}_setCurrentPoint(e){return this.currentPoint=new O(e.x,e.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(e){if(this.curves.length>0){const t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){const e=this.startPoint;if(e){const t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Ct(t,e)),t.copy(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new O(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){const i=this.currentPoint;return i!=null&&i.equals({x:e,y:t})||this.curves.push(Ct.from((i==null?void 0:i.x)??0,(i==null?void 0:i.y)??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,i,s,o,a){const l=this.currentPoint;return l!=null&&l.equals({x:o,y:a})||this.curves.push(ms.from((l==null?void 0:l.x)??0,(l==null?void 0:l.y)??0,e,t,i,s,o,a)),this._setCurrentPoint({x:o,y:a}),this}quadraticCurveTo(e,t,i,s){const o=this.currentPoint;return o!=null&&o.equals({x:i,y:s})||this.curves.push(ys.from((o==null?void 0:o.x)??0,(o==null?void 0:o.y)??0,e,t,i,s)),this._setCurrentPoint({x:i,y:s}),this}arc(e,t,i,s,o,a){const l=new Nh(e,t,i,s,o,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeArc(e,t,i,s,o,a){var l,h;return e+=((l=this.currentPoint)==null?void 0:l.x)??0,t+=((h=this.currentPoint)==null?void 0:h.y)??0,this.arc(e,t,i,s,o,a),this}arcTo(e,t,i,s,o){return console.warn("Method arcTo not supported yet"),this}ellipse(e,t,i,s,o,a,l,h=!0){const c=new Fh(e,t,i,s,o,a,l,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,i,s,o,a,l,h){var c,f;return e+=((c=this.currentPoint)==null?void 0:c.x)??0,t+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(e,t,i,s,o,a,l,h),this}rect(e,t,i,s){const o=new zh(e,t,i,s);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,i,s,o){const a=new Vh(e,t,i,s,o);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){const t=this.currentPoint??new O;return this.curves.push(new jh([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){var i;const t=(i=this.curves[0])==null?void 0:i.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(s=>s.drawTo(e)),this.autoClose&&e.closePath(),this}copy(e){var t;return super.copy(e),this.autoClose=e.autoClose,this.currentPoint=(t=e.currentPoint)==null?void 0:t.clone(),this}}function Gh(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function qh(n,r,e,t){const i=r.clone().sub(n),s=t.clone().sub(e),o=e.clone().sub(n),a=i.cross(s);if(a===0)return new O((n.x+e.x)/2,(n.y+e.y)/2);const l=o.cross(s)/a;return Math.abs(l)>1?new O((n.x+e.x)/2,(n.y+e.y)/2):new O(n.x+l*i.x,n.y+l*i.y)}class Ue extends gs{constructor(e,t={}){super();u(this,"currentCurve",new Er);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof Ue?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof Ue?this.curves.push(...e.curves.map(t=>t.clone())):this.curves.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentCurve.closePath(),this.currentCurve.curves.length>0&&(this.currentCurve=new Er().moveTo(e.x,e.y),this.curves.push(this.currentCurve))),this}moveTo(e,t){var i;return(i=this.currentCurve.currentPoint)!=null&&i.equals({x:e,y:t})||(this.currentCurve.curves.length&&(this.currentCurve=new Er,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t)),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,i,s,o,a){return this.currentCurve.bezierCurveTo(e,t,i,s,o,a),this}quadraticCurveTo(e,t,i,s){return this.currentCurve.quadraticCurveTo(e,t,i,s),this}arc(e,t,i,s,o,a){return this.currentCurve.arc(e,t,i,s,o,a),this}arcTo(e,t,i,s,o){return this.currentCurve.arcTo(e,t,i,s,o),this}ellipse(e,t,i,s,o,a,l,h){return this.currentCurve.ellipse(e,t,i,s,o,a,l,h),this}rect(e,t,i,s){return this.currentCurve.rect(e,t,i,s),this}roundRect(e,t,i,s,o){return this.currentCurve.roundRect(e,t,i,s,o),this}addCommands(e){return Jn(e,this),this}addData(e){return this.addCommands(Qn(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,i={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.scale(e,t,i)}),this}skew(e,t=0,i={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.skew(e,t,i)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.curves,i=[],s=[],o=[];t.forEach((l,h)=>{if(!l.getLength())return;const c=l.getControlPointRefs(),f=l.isClockwise();o[h]=c,s[h]=f;const p=c[0],d=c[c.length-1]??p;i.push({start:f?d:p,end:f?p:d,index:h})});const a=[];return i.forEach((l,h)=>{a[h]=[],i.forEach((c,f)=>{f!==h&&c.start.equals(l.end)&&a[h].push(c.index)})}),t.forEach((l,h)=>{if(!l.getLength())return;const c=s[h];o[h].forEach(p=>{const d=l.getTForPoint(p),m=l.getNormal(d).scale(c?e:-e);p.add(m)})}),a.forEach((l,h)=>{const c=o[h];l.forEach(f=>{const p=o[f],d=qh(c[c.length-1],c[c.length-2]??c[c.length-1],p[0],p[1]??p[0]);d&&(c[c.length-1].copy(d),p[0].copy(d))})}),this}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=O.MAX,t=O.MIN,i=!0){const s=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(e,t),i&&s>1){const a=s/2,l=o.isClockwise(),h=[];for(let c=0;c<=1;c+=1/o.arcLengthDivision){const f=o.getPoint(c),p=o.getNormal(c),d=p.clone().scale(l?a:-a),m=p.clone().scale(l?-a:a);h.push(f.clone().add(d),f.clone().add(m),f.clone().add({x:a,y:0}),f.clone().add({x:-a,y:0}),f.clone().add({x:0,y:a}),f.clone().add({x:0,y:-a}),f.clone().add({x:a,y:a}),f.clone().add({x:-a,y:-a}))}e.min(...h),t.max(...h)}}),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:i}=this.getMinMax(void 0,void 0,e);return new Y(t.x,t.y,i.x-t.x,i.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:i="#000",stroke:s="none"}=t;return e.beginPath(),e.save(),cs(e,t),this.curves.forEach(o=>{o.drawTo(e)}),i!=="none"&&e.fill(),s!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:i="#000",stroke:s="none"}=t;return e.beginPath(),e.save(),cs(e,t),this.getControlPointRefs().forEach(o=>{uh(e,o.x,o.y,{radius:4})}),i!=="none"&&e.fill(),s!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(" ")}toSVGPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const s in e)e[s]!==void 0&&(t[Gh(s)]=e[s]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let i="";for(const s in t)t[s]!==void 0&&(i+=`${s}:${t[s]};`);return`<path d="${this.toData()}" style="${i}"></path>`}copy(e){return super.copy(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}}class vs{constructor(r=[]){this.paths=r}getBoundingBox(r=!0){if(!this.paths.length)return;const e=O.MAX,t=O.MIN;return this.paths.forEach(i=>i.getMinMax(e,t,r)),new Y(e.x,e.y,t.x-e.x,t.y-e.y)}toSVGString(){const{x:r,y:e,width:t,height:i}=this.getBoundingBox(),s=this.paths.map(o=>o.toSVGPathString()).join("");return`<svg viewBox="${r} ${e} ${t} ${i}" width="${t}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(r={}){const{pixelRatio:e=2,...t}=r,{left:i,top:s,width:o,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=o*e,l.height=a*e,l.style.width=`${o}px`,l.style.height=`${a}px`;const h=l.getContext("2d");return h&&(h.scale(e,e),h.translate(-i,-s),this.paths.forEach(c=>{c.drawTo(h,t)})),l}}const uo="data:image/svg+xml;",fo=`${uo}base64,`,po=`${uo}charset=utf8,`;function go(n){if(typeof n=="string"){let r;n.startsWith(fo)?(n=n.substring(fo.length,n.length),r=atob(n)):n.startsWith(po)?(n=n.substring(po.length,n.length),r=decodeURIComponent(n)):r=n;const e=new DOMParser().parseFromString(r,"text/xml"),t=e.querySelector("parsererror");if(t)throw new Error(`${t.textContent??"parser error"}
|
|
27
|
+
${r}`);return e.documentElement}else return n}const Wh="px",Xh=90,mo=["mm","cm","in","pt","pc","px"],yo={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function J(n){let r="px";if(typeof n=="string"||n instanceof String)for(let t=0,i=mo.length;t<i;t++){const s=mo[t];if(n.endsWith(s)){r=s,n=n.substring(0,n.length-s.length);break}}let e;return e=yo[r][Wh],e<0&&(e=yo[r].in*Xh),e*Number.parseFloat(n)}const Hh=new ke,oi=new ke,vo=new ke,_o=new ke;function Yh(n,r,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const t=Zh(n);return e.length>0&&t.premultiply(e[e.length-1]),r.copy(t),e.push(t),t}function Zh(n){const r=new ke,e=Hh;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&r.translate(J(n.getAttribute("x")),J(n.getAttribute("y"))),n.hasAttribute("transform")){const t=n.getAttribute("transform").split(")");for(let i=t.length-1;i>=0;i--){const s=t[i].trim();if(s==="")continue;const o=s.indexOf("("),a=s.length;if(o>0&&o<a){const l=s.slice(0,o),h=nt(s.slice(o+1));switch(e.identity(),l){case"translate":if(h.length>=1){const c=h[0];let f=0;h.length>=2&&(f=h[1]),e.translate(c,f)}break;case"rotate":if(h.length>=1){let c=0,f=0,p=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],p=h[2]),oi.makeTranslation(-f,-p),vo.makeRotation(c),_o.multiplyMatrices(vo,oi),oi.makeTranslation(f,p),e.multiplyMatrices(oi,_o)}break;case"scale":h.length>=1&&e.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&e.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&e.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&e.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}r.premultiply(e)}}return r}function Kh(n){return new Ue().addPath(new Er().arc(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("r")||0),0,Math.PI*2))}function Jh(n,r){if(!(!n.sheet||!n.sheet.cssRules||!n.sheet.cssRules.length))for(let e=0;e<n.sheet.cssRules.length;e++){const t=n.sheet.cssRules[e];if(t.type!==1)continue;const i=t.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim()),s={};for(let o=t.style.length,a=0;a<o;a++){const l=t.style.item(a);s[l]=t.style.getPropertyValue(l)}for(let o=0;o<i.length;o++)r[i[o]]=Object.assign(r[i[o]]||{},{...s})}}function Qh(n){return new Ue().addPath(new Er().ellipse(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("rx")||0),J(n.getAttribute("ry")||0),0,0,Math.PI*2))}function ec(n){return new Ue().moveTo(J(n.getAttribute("x1")||0),J(n.getAttribute("y1")||0)).lineTo(J(n.getAttribute("x2")||0),J(n.getAttribute("y2")||0))}function tc(n){const r=new Ue,e=n.getAttribute("d");return!e||e==="none"?null:(r.addData(e),r)}const rc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ic(n){var t;const r=new Ue;let e=0;return(t=n.getAttribute("points"))==null||t.replace(rc,(i,s,o)=>{const a=J(s),l=J(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentPath.autoClose=!0,r}const sc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function nc(n){var t;const r=new Ue;let e=0;return(t=n.getAttribute("points"))==null||t.replace(sc,(i,s,o)=>{const a=J(s),l=J(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentPath.autoClose=!1,r}function oc(n){const r=J(n.getAttribute("x")||0),e=J(n.getAttribute("y")||0),t=J(n.getAttribute("rx")||n.getAttribute("ry")||0),i=J(n.getAttribute("ry")||n.getAttribute("rx")||0),s=J(n.getAttribute("width")),o=J(n.getAttribute("height")),a=1-.551915024494,l=new Ue;return l.moveTo(r+t,e),l.lineTo(r+s-t,e),(t!==0||i!==0)&&l.bezierCurveTo(r+s-t*a,e,r+s,e+i*a,r+s,e+i),l.lineTo(r+s,e+o-i),(t!==0||i!==0)&&l.bezierCurveTo(r+s,e+o-i*a,r+s-t*a,e+o,r+s-t,e+o),l.lineTo(r+t,e+o),(t!==0||i!==0)&&l.bezierCurveTo(r+t*a,e+o,r,e+o-i*a,r,e+o-i),l.lineTo(r,e+i),(t!==0||i!==0)&&l.bezierCurveTo(r,e+i*a,r+t*a,e,r+t,e),l}function ot(n,r,e){r=Object.assign({},r);let t={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)t=Object.assign(t,e[`.${h[c]}`])}n.hasAttribute("id")&&(t=Object.assign(t,e[`#${n.getAttribute("id")}`]));for(let h=n.style.length,c=0;c<h;c++){const f=n.style.item(c),p=n.style.getPropertyValue(f);r[f]=p,t[f]=p}function i(h,c,f=s){n.hasAttribute(h)&&(r[c]=f(n.getAttribute(h))),t[h]&&(r[c]=f(t[h]))}function s(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function o(h){return Math.max(0,Math.min(1,J(h)))}function a(h){return Math.max(0,J(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>J(c))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",a),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",a),i("stroke-dasharray","strokeDasharray",l),i("stroke-dashoffset","strokeDashoffset",J),i("visibility","visibility"),r}function _s(n,r,e=[],t={}){var f;if(n.nodeType!==1)return e;let i=!1,s=null,o={...r};switch(n.nodeName){case"svg":o=ot(n,o,t);break;case"style":Jh(n,t);break;case"g":o=ot(n,o,t);break;case"path":o=ot(n,o,t),n.hasAttribute("d")&&(s=tc(n));break;case"rect":o=ot(n,o,t),s=oc(n);break;case"polygon":o=ot(n,o,t),s=ic(n);break;case"polyline":o=ot(n,o,t),s=nc(n);break;case"circle":o=ot(n,o,t),s=Kh(n);break;case"ellipse":o=ot(n,o,t),s=Qh(n);break;case"line":o=ot(n,o,t),s=ec(n);break;case"defs":i=!0;break;case"use":{o=ot(n,o,t);const d=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),m=(f=n.viewportElement)==null?void 0:f.getElementById(d);m?_s(m,o,e,t):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(n);break}if(o.display==="none")return e;Object.assign(r,o);const a=new ke,l=[],h=Yh(n,a,l);s&&(s.applyTransform(a),e.push(s),s.style=r);const c=n.childNodes;for(let p=0,d=c.length;p<d;p++){const m=c[p];i&&m.nodeName!=="style"&&m.nodeName!=="defs"||_s(m,r,e,t)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),e}function bo(n){return new vs(_s(go(n),{}))}class wo extends Ue{constructor(){super(...arguments);u(this,"textureTransform");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineCap");u(this,"lineJoin");u(this,"lineWidth");u(this,"miterLimit");u(this,"_defaultStyle",de.EMPTY);u(this,"_stroked",[]);u(this,"_filled",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof de?e=this.strokeStyle:e=new as(this.strokeStyle)),this.curves.length&&(this._stroked.push({shapes:this.curves.slice(),texture:e,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.curves.length=0)}fillRect(e,t,i,s){this.rect(e,t,i,s).fill()}strokeRect(e,t,i,s){this.rect(e,t,i,s).stroke()}fill(){let e=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof de?e=this.fillStyle:e=new as(this.fillStyle)),this._filled.push({shapes:this.curves.slice(),texture:e,textureTransform:this.textureTransform}),this.curves.length=0}reset(){this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this.curves.length=0,this._stroked.length=0,this._filled.length=0}buildUvs(e,t,i,s,o){if(s){let a=s.width,l=s.height;o&&([a,l]=o.applyToPoint(a,l));for(let h=t.length,c=e;c<h;c+=2)i.push(t[c]/a,t[c+1]/l)}else for(let a=t.length,l=e;l<a;l+=2)i.push(0,0)}toBatchables(){const e=[];let t=[],i=[],s=[],o=0,a;const l=h=>{e.push({type:h,vertices:t,indices:i,uvs:s,texture:a}),t=[],i=[],s=[],a=void 0};for(let h=this._stroked.length,c=0;c<h;c++){o=t.length;const f=this._stroked[c];a??(a=f.texture);const p=[];for(let d=f.shapes.length,m=0;m<d;m++)f.shapes[m].getAdaptivePointArray(p);so(p,{vertices:t,indices:i,lineStyle:f.style,flipAlignment:!1,closed:!0}),this.buildUvs(o,t,s,f.texture,f.textureTransform),l("stroke")}for(let h=this._filled.length,c=0;c<h;c++){const f=this._filled[c];a??(a=f.texture),a!==f.texture&&l("fill"),o=t.length;for(let p=f.shapes.length,d=0;d<p;d++)f.shapes[d].fillTriangulate({vertices:t,indices:i});this.buildUvs(o,t,s,f.texture,f.textureTransform)}return t.length&&l("fill"),e}}class Et{}class xo extends Et{install(r){const e=async t=>{const{parseFont:i}=await Promise.resolve().then(()=>hf);return await r.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s))};return this.load=t=>r.loadBy(t,()=>e(t)),["woff","ttf"].forEach(t=>{r.register(t,e)}),r.font=this,this}}class Po extends Et{install(r){const e=async t=>{const{decodeFrames:i}=await import("modern-gif");return await r.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s)).then(s=>new hi(s.map(o=>({duration:o.delay,texture:new Ji(o.data,o.width,o.height)}))))};return this.load=t=>r.loadBy(t,()=>e(t)),["image/gif"].forEach(t=>{r.register(t,e)}),r.gif=this,this}}class Co extends Et{install(r){const e=t=>r.fetch(t).then(i=>i.json());return this.load=t=>r.loadBy(t,()=>e(t)),["json"].forEach(t=>{r.register(t,e)}),r.json=this,this}}class Eo extends Et{install(r){const e=async(t,i)=>(await import("lottie-web").then(o=>o.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await r.fetch(t).then(o=>o.json())});return this.load=(t,i)=>r.loadBy(t,()=>e(t,i)),["lottie"].forEach(t=>{r.register(t,e)}),r.lottie=this,this}}class To extends Et{install(r){const e=async t=>await r.fetch(t).then(i=>i.text());return this.load=t=>r.loadBy(t,()=>e(t)),r.text=this,this}}class So extends Et{install(r){const e=t=>r.fetchImageBitmap(t,{premultiplyAlpha:"premultiply"}).then(i=>new de(i));return this.load=t=>r.loadBy(t,()=>e(t)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(t=>{r.register(t,e)}),r.texture=this,this}}class Mo extends Et{install(r){const e=t=>new Rn(t).load();return this.load=t=>r.loadBy(t,()=>e(t)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(t=>{r.register(t,e)}),r.video=this,this}}const ac=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function lc(n){for(const[r,e]of ac)if(e.includes(n))return r}async function hc(n){var e,t;let r;if(n.startsWith("data:"))r=(e=n.match(/^data:(.+?);/))==null?void 0:e[1];else if(n.startsWith("http")){const i=(t=n.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim();i&&(r=lc(i))}return r??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const ai="WeakRef"in globalThis;class Ao{constructor(){u(this,"defaultHandler",r=>this.fetch(r));u(this,"_handlers",new Map);u(this,"_handleing",new Map);u(this,"_handled",new Map);u(this,"_gc",ai?new FinalizationRegistry(r=>{const e=this.get(r);e&&"destroy"in e&&e.destroy(),this._handled.delete(r)}):void 0);ai||ue.on(this.gc.bind(this),{sort:2})}use(r){return r.install(this),this}register(r,e){return this._handlers.set(r,e),this}fetch(r){return fetch(r)}_fixSVG(r){const e=new DOMParser().parseFromString(decodeURIComponent(r.split(",")[1]),"image/svg+xml").documentElement;return e.setAttribute("width","512"),e.setAttribute("height","512"),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.outerHTML)}`}async fetchImageBitmap(r,e){return r.startsWith("http")?await this.fetch(r).then(t=>t.blob()).then(t=>t.type==="image/svg+xml"?t.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),e)):createImageBitmap(t,e)):(r.startsWith("data:image/svg+xml;")&&(r=this._fixSVG(r)),new Promise(t=>{const i=new Image;i.src=r,i.onload=()=>i.decode().finally(()=>t(i))}).then(t=>createImageBitmap(t,e)))}get(r){let e=this._handled.get(r);return ai&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(r)),e}set(r,e){let t=e;ai&&typeof e=="object"&&(this._gc.register(e,r),t=new WeakRef(e)),this._handled.set(r,t)}async loadBy(r,e){const t=this.get(r)??this._handleing.get(r);if(t)return t;const i=e().then(s=>(this.set(r,s),s)).finally(()=>{this._handleing.delete(r)});return this._handleing.set(r,i),i}async load(r,e){return this.loadBy(r,async()=>{const t=await hc(r);return(this._handlers.get(t)??this.defaultHandler)(r,e)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()))}gc(){this._handled.forEach((r,e)=>{const t=this.get(e);t&&"destroy"in t&&t.destroy()}),this._handled.clear()}}const mt=new Ao().use(new xo).use(new Po).use(new Co).use(new Eo).use(new To).use(new So).use(new Mo);class Tr{}class Oo extends Tr{install(r){bt(r,"backgroundColor"),bt(r,"backgroundImage"),r.prototype.getComputedBackgroundImage=cc}}async function cc(){if(this.backgroundImage)return await mt.texture.load(this.backgroundImage)}class Uo extends Tr{install(r){bt(r,"filter",{default:""}),r.prototype.getComputedFilter=uc,r.prototype.getComputedFilterColorMatrix=fc}}const Do={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function uc(){const n=gr(this.filter).reduce((r,{name:e,args:t})=>(r[e]=t[0].normalizedIntValue,r),{});return Object.keys(Do).forEach(r=>{n[r]=n[r]??Do[r]}),n}function fc(){const n=new os,r=this.getComputedFilter();for(const e in r){const t=r[e];switch(e){case"hue-rotate":n.hueRotate(t*le);break;case"saturate":n.saturate(t);break;case"brightness":n.brightness(t);break;case"contrast":n.contrast(t);break;case"invert":n.invert(t);break;case"sepia":n.sepia(t);break;case"opacity":n.opacity(t);break;case"grayscale":n.grayscale(t);break}}return n}function dc(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function Io(){return{left:0,top:0,width:0,height:0,rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function pc(){return{overflow:"visible",visibility:"visible",filter:"none",opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,...Io(),backgroundImage:"none",backgroundColor:"transparent",...dc(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function Ro(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function gc(){return{...pc(),...Ro()}}class Bo extends Tr{install(r){const e=Ro();for(const t in e)bt(r,t,{default:e[t]});bt(r,"direction",{default:"inherit"})}}class Lo extends Tr{install(r){const e=Io();for(const t in e)bt(r,t,{default:e[t]});r.prototype.getComputedTransform=mc,r.prototype.getComputedTransformOrigin=yc}}function mc(){const n=new qe,r=new qe(!1),e=new qe(!1).scale(this.scaleX,this.scaleY).translate(this.left,this.top).rotate(this.rotate*On);let t=this.transform;(!t||t==="none")&&(t=""),gr(t,{width:this.width,height:this.height}).forEach(({name:f,args:p})=>{const d=p.map(m=>m.normalizedIntValue);switch(n.identity(),f){case"translate":n.translate(d[0]*this.width,(d[1]??d[0])*this.height);break;case"translateX":n.translateX(d[0]*this.width);break;case"translateY":n.translateY(d[0]*this.height);break;case"translateZ":n.translateZ(d[0]);break;case"translate3d":n.translate3d(d[0]*this.width,(d[1]??d[0])*this.height,d[2]??d[1]??d[0]);break;case"scale":n.scale(d[0],d[1]??d[0]);break;case"scaleX":n.scaleX(d[0]);break;case"scaleY":n.scaleY(d[0]);break;case"scale3d":n.scale3d(d[0],d[1]??d[0],d[2]??d[1]??d[0]);break;case"rotate":n.rotate(d[0]*le);break;case"rotateX":n.rotateX(d[0]*le);break;case"rotateY":n.rotateY(d[0]*le);break;case"rotateZ":n.rotateZ(d[0]*le);break;case"rotate3d":n.rotate3d(d[0]*le,(d[1]??d[0])*le,(d[2]??d[1]??d[0])*le,(d[3]??d[2]??d[1]??d[0])*le);break;case"skew":n.skew(d[0],d[0]??d[1]);break;case"skewX":n.skewX(d[0]);break;case"skewY":n.skewY(d[0]);break;case"matrix":n.set(d);break}r.multiply(n)}),e.update(),r.update();const i=e.toArray(),s=r.toArray(),o=[s[0]*i[0]+s[3]*i[1],s[1]*i[0]+s[4]*i[1],s[2]*i[0]+s[5]*i[1]+i[2],s[0]*i[3]+s[3]*i[4],s[1]*i[3]+s[4]*i[4],s[2]*i[3]+s[5]*i[4]+i[5],0,0,1],[a,l]=this.getComputedTransformOrigin(),h=a*this.width,c=l*this.height;return o[2]+=o[0]*-h+o[1]*-c+h,o[5]+=o[3]*-h+o[4]*-c+c,new qe().set(o)}function yc(){const[n,r=n]=this.transformOrigin.split(" ");return[n,r].map(e=>{switch(e=e.trim(),e){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(e)}})}var vc=Object.defineProperty,kt=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&vc(r,e,i),i};class at extends Kr{constructor(r){super(),this.setProperties(r)}_onUpdateProperty(r,e,t){switch(super._onUpdateProperty(r,e,t),r){case"fontSize":e<=0&&(this.fontSize=14);break;case"fontWeight":e||(this.fontWeight="normal");break;case"lineHeight":e||(this.lineHeight=1);break}}}kt([A({default:"#000000"})],at.prototype,"shadowColor"),kt([A({default:0})],at.prototype,"shadowOffsetX"),kt([A({default:0})],at.prototype,"shadowOffsetY"),kt([A({default:0})],at.prototype,"shadowBlur"),kt([A({default:1})],at.prototype,"opacity"),kt([A({default:0})],at.prototype,"borderRadius"),kt([A({default:"visible"})],at.prototype,"overflow"),[Oo,Uo,Bo,Lo].forEach(n=>{new n().install(at)});var _c=Object.defineProperty,bc=Object.getOwnPropertyDescriptor,bs=(n,r,e,t)=>{for(var i=t>1?void 0:t?bc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&_c(r,e,i),i};g.CanvasItem=class extends g.Node{constructor(e){super();u(this,"tint");u(this,"blendMode");u(this,"opacity",1);u(this,"_parentOpacity");u(this,"_tint",new Pt(4294967295));u(this,"_backgroundColor",new Pt(0));u(this,"_backgroundImage");u(this,"context",new wo);u(this,"_resetContext",!0);u(this,"_redrawing",!1);u(this,"_reflowing",!1);u(this,"_repainting",!1);u(this,"_originalBatchables",[]);u(this,"_layoutedBatchables",[]);u(this,"_batchables",[]);this._onUpdateStyleProperty=this._onUpdateStyleProperty.bind(this),this.setProperties(e),this.style=new at}get style(){return this._style}set style(e){var t;e.on("updateProperty",this._onUpdateStyleProperty),(t=this._style)==null||t.off("updateProperty",this._onUpdateStyleProperty),this._style=e}setProperties(e){if(e){const{style:t,...i}=e;t&&this.style.setProperties(t),super.setProperties(i)}return this}_onUpdateProperty(e,t,i,s){switch(super._onUpdateProperty(e,t,i,s),e){case"blendMode":this.requestRepaint();break;case"tint":this._tint.value=t||4294967295,this.requestRepaint();break}}_onUpdateStyleProperty(e,t,i,s){switch(e){case"backgroundColor":this._updateBackgroundColor();break;case"backgroundImage":this._updateBackgroundImage();break;case"opacity":this._updateOpacity();break;case"filter":this.requestRepaint();break;case"borderRadius":this.requestRedraw();break}}_updateBackgroundColor(){this._backgroundColor.value=this.style.backgroundColor||0,this._originalBatchables.length?this.requestRepaint():this._backgroundColor.a>0&&this.requestRedraw()}async _updateBackgroundImage(){this._backgroundImage=await this.style.getComputedBackgroundImage(),this.requestRedraw()}_updateOpacity(){var t;const e=xt(0,this.style.opacity,1)*(((t=this._parent)==null?void 0:t.opacity)??1);this.opacity!==e&&(this.opacity=e,this.requestRepaint())}isVisible(){return this.opacity>0&&super.isVisible()}requestRedraw(){this._redrawing=!0}requestReflow(){this._reflowing=!0}requestRepaint(){this._repainting=!0}_process(e){var i;const t=(i=this._parent)==null?void 0:i.opacity;t!==this._parentOpacity&&(this._parentOpacity=t,this._updateOpacity()),super._process(e)}_draw(){this._drawBackground(),this._drawContent()}_drawBackground(){const e=this._backgroundImage;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new qe().scale(this.style.width/e.width,this.style.height/e.height),this._fill())}_drawContent(){this._fill()}_fill(){this.style.borderRadius?this.context.roundRect(0,0,this.style.width,this.style.height,this.style.borderRadius):this.context.rect(0,0,this.style.width,this.style.height),this.context.fill()}_relayout(e){return this._reflow(e)}_reflow(e){return this._repaint(e)}_repaint(e){const t=this.style.getComputedFilterColorMatrix();return e.map(i=>({...i,backgroundColor:this._backgroundColor.abgr,tint:this._tint.toArgb(this.opacity,!0),colorMatrix:t.toMatrix4().toArray(!0),colorMatrixOffset:t.toVector4().toArray(),blendMode:this.blendMode}))}_render(e){let t;this._redrawing?(this._draw(),this._originalBatchables=this.context.toBatchables(),this._layoutedBatchables=this._relayout(this._originalBatchables),t=this._layoutedBatchables,this._resetContext&&this.context.reset()):this._reflowing?(this._layoutedBatchables=this._reflow(this._originalBatchables),t=this._layoutedBatchables):this._repainting&&(t=this._repaint(this._layoutedBatchables)),t&&(this._batchables=t,this._redrawing=!1,this._reflowing=!1,this._repainting=!1),this._batchables.forEach(i=>{var s,o;(s=i.texture)==null||s.upload(e),e.batch2D.render({...i,texture:(o=i.texture)==null?void 0:o._glTexture(e)})}),super._render(e)}toJSON(){const e=super.toJSON();return{...e,props:{style:this.style.toJSON(),...e.props}}}},bs([A()],g.CanvasItem.prototype,"tint",2),bs([A()],g.CanvasItem.prototype,"blendMode",2),g.CanvasItem=bs([H("CanvasItem")],g.CanvasItem);var wc=Object.defineProperty,xc=Object.getOwnPropertyDescriptor,Nt=(n,r,e,t)=>{for(var i=t>1?void 0:t?xc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&wc(r,e,i),i};const ko=n=>n,No=sr(.25,.1,.25,1),Fo=sr(.42,0,1,1),$o=sr(0,0,.58,1),zo=sr(.42,0,.58,1);function sr(n,r,e,t){const s=3*n-3*e+1,o=3*e-6*n,a=3*n,l=3*r-3*t+1,h=3*t-6*r,c=3*r,f=v=>(3*s*v+2*o)*v+a,p=v=>((s*v+o)*v+a)*v,d=v=>((l*v+h)*v+c)*v;function m(v){let y=v,S,C;for(let b=0;b<8;b++){if(C=p(y)-v,Math.abs(C)<1e-6)return y;if(S=f(y),Math.abs(S)<1e-6)break;y-=C/S}let x=1,T=0;for(y=v;x>T;){if(C=p(y)-v,Math.abs(C)<1e-6)return y;C>0?x=y:T=y,y=(x+T)/2}return y}return v=>d(m(v))}const li={linear:ko,ease:No,easeIn:Fo,easeOut:$o,easeInOut:zo};g.Animation2D=class extends g.Node{constructor(e){super();u(this,"easing");u(this,"_keyframes",[]);u(this,"_starting",!1);u(this,"_startProps",new WeakMap);this._onUpdateTime=this._onUpdateTime.bind(this),this.setProperties(e)}_enterTree(){var e;(e=this._tree)==null||e.timeline.on("update",this._onUpdateTime),this._updateStartProps()}_exitTree(){var e;(e=this._tree)==null||e.timeline.off("update",this._onUpdateTime),this.cancel()}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"mode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var t;let e;switch(this.mode){case"sibling":e=((t=this.getParent())==null?void 0:t.getChildren(!0).filter(i=>i instanceof g.CanvasItem))??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(i=>i.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let o=t.length,a=0;a<o;a++){const{offset:l=a===0?0:a/(o-1),easing:h="linear",...c}=t[a];e.push({offset:l,easing:this._parseEasing(h),props:c})}const i=e[0],s=e[e.length-1];i&&i.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),s&&s.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateStartProps()}_onUpdateTime(){if(!this.keyframes.length)return;if(this.isVisible())this._starting||(this._starting=!0,this._updateStartProps());else{if(!this._starting)return;this._starting=!1}const e=this._getTargets(),t=1/e.length,i=this.visibleProgress;e.forEach((s,o)=>{const a=t===1?i:xt(0,Math.max(0,i-t*o)/t,1),l=this._startProps.get(s);if(!l)return;const h=this._parseKeyframes(a,l);h!=null&&h.length&&this._commitStyle(a,s,l,h[0],h[1])})}_updateStartProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,i=this._keyframes;for(let s=i.length,o=0;o<s;o++)Object.keys(i[o].props).forEach(a=>{t.set(a,e[a])});this._startProps.set(e,t)})}_parseEasing(e){if(!e)return li.linear;if(e in li)return li[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return sr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let i;const s=this._keyframes;for(let o=s.length,a=0;a<o;a++){const l=s[a],{offset:h,easing:c}=l,f={...l.props};if(i&&e<=h){const{offset:p,easing:d}=i,m={...i.props};return t.forEach((v,y)=>{(!(y in m)||m[y]===null)&&(m[y]=v),(!(y in f)||f[y]===null)&&(f[y]=v)}),[{offset:p,easing:d,props:m},{offset:h,easing:c,props:f}]}i=l}return null}_commitStyle(e,t,i,s,o){const{offset:a,easing:l,props:h}=s,{offset:c,props:f}=o,p=c-a,d=l((e-a)/p),m={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((v,y)=>{t[y]=this._getDiffValue(y,h[y],f[y],d,m)})}_getDiffValue(e,t,i,s,o){let a,l;if(t===void 0||i===void 0)if(t!==void 0)a=pr(e,String(t),o),l=Vi(a);else if(i!==void 0)l=pr(e,String(i),o),a=Vi(l);else return;else a=pr(e,String(t),o),l=pr(e,String(i),o);if(Array.isArray(a)&&Array.isArray(l)){const h=new Set,c={},f={};a.forEach(({name:d,args:m})=>{c[d]=m,h.add(d)}),l.forEach(({name:d,args:m})=>{f[d]=m,h.add(d)});let p="";return h.forEach(d=>{var S,C;const m=Math.max(((S=c[d])==null?void 0:S.length)??0,((C=f[d])==null?void 0:C.length)??0),v=c[d],y=f[d];p+=`${d}(${Array.from({length:m},(x,T)=>{const b=v==null?void 0:v[T],P=y==null?void 0:y[T],E=(b==null?void 0:b.normalizedIntValue)??0,w=(P==null?void 0:P.normalizedIntValue)??0;return Number.isNaN(E)||Number.isNaN(w)?(P==null?void 0:P.value)??0:fe(E,w,s)}).join(", ")}) `}),p}else if(!Array.isArray(a)&&!Array.isArray(l))return Number.isNaN(a.normalizedIntValue)||Number.isNaN(l.normalizedIntValue)?l.value:fe(a.normalizedIntValue,l.normalizedIntValue,s)}cancel(){this._getTargets().forEach(e=>{var t;(t=this._startProps.get(e))==null||t.forEach((i,s)=>{e[s]=i}),this._startProps.delete(e)})}},Nt([A({default:"parent"})],g.Animation2D.prototype,"mode",2),Nt([A({default:!1})],g.Animation2D.prototype,"loop",2),Nt([A({default:[]})],g.Animation2D.prototype,"keyframes",2),Nt([A()],g.Animation2D.prototype,"easing",2),Nt([A({alias:"visibleDelay",default:0})],g.Animation2D.prototype,"delay",2),Nt([A({alias:"visibleDuration",default:2e3})],g.Animation2D.prototype,"duration",2),g.Animation2D=Nt([H("Animation2D")],g.Animation2D);var Pc=Object.defineProperty,Cc=Object.getOwnPropertyDescriptor,Ec=(n,r,e,t)=>{for(var i=t>1?void 0:t?Cc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Pc(r,e,i),i};g.Node2D=class extends g.CanvasItem{constructor(e){super();u(this,"_transform",new qe);u(this,"_parentTransformDirtyId");this.setProperties(e)}getBoundingBox(){let{left:e,top:t,width:i,height:s,rotate:o}=this.style;if(o){o=Math.abs(o%180),o=o/180*Math.PI;const a=Math.abs(Math.sin(o)),l=Math.abs(Math.cos(o)),h=s*a+i*l,c=s*l+i*a;e+=(i-h)/2,t+=(s-c)/2,i=h,s=c}return new Y(e,t,i,s)}_onUpdateStyleProperty(e,t,i){switch(super._onUpdateStyleProperty(e,t,i),e){case"width":case"height":this.mask instanceof g.Node2D&&(this.mask.style.width=this.style.width,this.mask.style.height=this.style.height),this.requestRedraw();case"scaleX":case"scaleY":case"left":case"top":case"rotate":case"transform":case"transformOrigin":this._updateTransform();break;case"overflow":this._updateOverflow();break}}_updateTransform(){const e=this.getParent(),t=e==null?void 0:e._transform;this._parentTransformDirtyId=t==null?void 0:t.dirtyId;const i=this.style.getComputedTransform().toArray();let s;if(t){const o=t.toArray();s=[i[0]*o[0]+i[3]*o[1],i[1]*o[0]+i[4]*o[1],i[2]*o[0]+i[5]*o[1]+o[2],i[0]*o[3]+i[3]*o[4],i[1]*o[3]+i[4]*o[4],i[2]*o[3]+i[5]*o[4]+o[5],0,0,1]}else s=i;this._transform.set(s),this._updateOverflow(),this.requestReflow()}_updateOverflow(){if(this.style.overflow==="hidden"){const[e,t,i,s,o,a]=this._transform.toArray(),l=this.style.width,h=this.style.height;this.mask={x:i,y:a,width:e*l+t*h,height:s*l+o*h}}else this.mask=void 0}_transformVertices(e){const[t,i,s,o,a,l]=this._transform.toArray(),h=e.slice();for(let c=e.length,f=0;f<c;f+=2){const p=e[f],d=e[f+1];h[f]=t*p+i*d+s,h[f+1]=o*p+a*d+l}return h}_reflow(e){return super._reflow(e.map(t=>({...t,vertices:this._transformVertices(t.vertices)})))}_process(e){var i;const t=this.getParent();((i=t==null?void 0:t._transform)==null?void 0:i.dirtyId)!==this._parentTransformDirtyId&&this._updateTransform(),super._process(e)}input(e){if(super.input(e),!e.target&&this.isRenderable()){const{screenX:t,screenY:i}=e;if(t&&i){const{width:s,height:o}=this.style,[a,l]=this._transform.inverse().applyToPoint(t,i);a>=0&&a<s&&l>=0&&l<o&&(e.target=this)}}}},g.Node2D=Ec([H({tag:"Node2D",renderable:!0})],g.Node2D);var Tc=Object.defineProperty,Sc=Object.getOwnPropertyDescriptor,ge=(n,r,e,t)=>{for(var i=t>1?void 0:t?Sc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Tc(r,e,i),i};function ye(n){return function(r,e){Object.defineProperty(r.constructor.prototype,e,{get(){return n!=null&&n.method?(...t)=>(this.context[e].call(this.context,...t),n.redraw&&this.requestRedraw(),r):this.context[e]},set(t){this.context[e]=t},configurable:!0,enumerable:!0})}}g.Graphics2D=class extends g.Node2D{constructor(){super(...arguments);u(this,"_resetContext",!1);u(this,"lineCap");u(this,"lineJoin");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineWidth");u(this,"miterLimit")}drawCircle(e,t,i){return this.arc(e+i,t+i,i,0,le),this.fill(),this}drawEllipse(e,t,i,s){const o=i/2,a=s/2;return this.ellipse(e+o,t+a,o,a,0,0,le),this.fill(),this}},ge([ye()],g.Graphics2D.prototype,"lineCap",2),ge([ye()],g.Graphics2D.prototype,"lineJoin",2),ge([ye()],g.Graphics2D.prototype,"fillStyle",2),ge([ye()],g.Graphics2D.prototype,"strokeStyle",2),ge([ye()],g.Graphics2D.prototype,"lineWidth",2),ge([ye()],g.Graphics2D.prototype,"miterLimit",2),ge([ye({method:!0})],g.Graphics2D.prototype,"rect",2),ge([ye({method:!0,redraw:!0})],g.Graphics2D.prototype,"fillRect",2),ge([ye({method:!0,redraw:!0})],g.Graphics2D.prototype,"strokeRect",2),ge([ye({method:!0})],g.Graphics2D.prototype,"roundRect",2),ge([ye({method:!0})],g.Graphics2D.prototype,"ellipse",2),ge([ye({method:!0})],g.Graphics2D.prototype,"arc",2),ge([ye({method:!0})],g.Graphics2D.prototype,"beginPath",2),ge([ye({method:!0})],g.Graphics2D.prototype,"moveTo",2),ge([ye({method:!0})],g.Graphics2D.prototype,"lineTo",2),ge([ye({method:!0})],g.Graphics2D.prototype,"closePath",2),ge([ye({method:!0,redraw:!0})],g.Graphics2D.prototype,"fill",2),ge([ye({method:!0,redraw:!0})],g.Graphics2D.prototype,"stroke",2),g.Graphics2D=ge([H("Graphics2D")],g.Graphics2D);class hi extends wt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof de)t=[{texture:e,duration:0}];else throw new TypeError("Failed new Image2DResource");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}destroy(){this.frames.forEach(e=>{e.texture.destroy()})}}var Mc=Object.defineProperty,Ac=Object.getOwnPropertyDescriptor,ci=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ac(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Mc(r,e,i),i};g.Image2D=class extends g.Node2D{constructor(e){super();u(this,"resource");u(this,"_frameIndex",0);u(this,"_complete",!1);u(this,"_wait",Promise.resolve());this.setProperties(e)}get currentTexture(){var e,t;return(t=(e=this.resource)==null?void 0:e.frames[this._frameIndex])==null?void 0:t.texture}get duration(){var e;return((e=this.resource)==null?void 0:e.duration)??0}get naturalWidth(){var e;return((e=this.currentTexture)==null?void 0:e.realWidth)??0}get naturalHeight(){var e;return((e=this.currentTexture)==null?void 0:e.realHeight)??0}get complete(){return this._complete}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"src":this._wait=this._load(t);break}}decode(){return this._wait}setResource(e){let t;if(e instanceof hi?t=e:t=new hi(e),this.resource=t.updateDuration(),this.currentTexture&&(!this.style.width||!this.style.height)){const i=this.currentTexture;this.style.width=i.realWidth,this.style.height=i.realHeight}return this}async _load(e){if(this._complete=!1,e)try{this.setResource(this.gif?await mt.gif.load(e):await mt.texture.load(e)),this.requestRedraw(),this.emit("load")}catch(t){console.warn(t),this.emit("error",t)}else this.resource=void 0;this._complete=!0}_getCurrentTime(){var i;const e=((i=this.resource)==null?void 0:i.duration)??0;if(!e||!this._tree)return 0;const t=this.visibleRelativeTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.resource)return this;const e=this._getCurrentTime(),t=this.resource.frames,i=t.length;if(i<=1&&this._frameIndex===0)return this;let s=i-1;for(let o=0,a=0;a<i;a++)if(o+=t[a].duration??0,o>=e){s=a;break}return this._frameIndex!==s&&(this._frameIndex=s,this.requestRepaint()),this}_process(e){this._updateFrameIndex(),super._process(e)}_drawContent(){const e=this.currentTexture;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new qe().scale(this.style.width/e.width,this.style.height/e.height),super._drawContent())}_repaint(e){const t=this.currentTexture;return super._repaint(e.map((i,s)=>(this._backgroundImage?s===1:s===0)&&i.type==="fill"?{...i,texture:t!=null&&t.valid?t:void 0}:i))}},ci([ee()],g.Image2D.prototype,"resource",2),ci([A({default:!1})],g.Image2D.prototype,"gif",2),ci([A({default:""})],g.Image2D.prototype,"src",2),g.Image2D=ci([H("Image2D")],g.Image2D);var Oc=Object.defineProperty,Uc=Object.getOwnPropertyDescriptor,ws=(n,r,e,t)=>{for(var i=t>1?void 0:t?Uc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Oc(r,e,i),i};g.Lottie2D=class extends g.Node2D{constructor(e){super();u(this,"duration",0);u(this,"texture",new de(document.createElement("canvas")));u(this,"animation");this.setProperties(e)}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"src":this._load();break}}_onUpdateStyleProperty(e,t,i){switch(super._onUpdateStyleProperty(e,t,i),e){case"width":this.texture.source.width=this.style.width*this.pixelRatio;break;case"height":this.texture.source.height=this.style.height*this.pixelRatio;break}}async _load(){this.animation=await mt.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(e){var t;(t=this.animation)==null||t.goToAndStop(this.visibleRelativeTime,!1),this.texture.requestUpload(),this.requestRepaint(),super._process(e)}_drawContent(){const e=this.texture;e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new qe().scale(this.style.width/e.width,this.style.height/e.height),super._drawContent())}},ws([A({default:2})],g.Lottie2D.prototype,"pixelRatio",2),ws([A({default:""})],g.Lottie2D.prototype,"src",2),g.Lottie2D=ws([H("Lottie2D")],g.Lottie2D);var Te=Uint8Array,Ve=Uint16Array,xs=Int32Array,ui=new Te([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fi=new Te([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ps=new Te([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vo=function(n,r){for(var e=new Ve(31),t=0;t<31;++t)e[t]=r+=1<<n[t-1];for(var i=new xs(e[30]),t=1;t<30;++t)for(var s=e[t];s<e[t+1];++s)i[s]=s-e[t]<<5|t;return{b:e,r:i}},jo=Vo(ui,2),Go=jo.b,Cs=jo.r;Go[28]=258,Cs[258]=28;for(var qo=Vo(fi,0),Dc=qo.b,Wo=qo.r,Es=new Ve(32768),re=0;re<32768;++re){var Tt=(re&43690)>>1|(re&21845)<<1;Tt=(Tt&52428)>>2|(Tt&13107)<<2,Tt=(Tt&61680)>>4|(Tt&3855)<<4,Es[re]=((Tt&65280)>>8|(Tt&255)<<8)>>1}for(var lt=function(n,r,e){for(var t=n.length,i=0,s=new Ve(r);i<t;++i)n[i]&&++s[n[i]-1];var o=new Ve(r);for(i=1;i<r;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(e){a=new Ve(1<<r);var l=15-r;for(i=0;i<t;++i)if(n[i])for(var h=i<<4|n[i],c=r-n[i],f=o[n[i]-1]++<<c,p=f|(1<<c)-1;f<=p;++f)a[Es[f]>>l]=h}else for(a=new Ve(t),i=0;i<t;++i)n[i]&&(a[i]=Es[o[n[i]-1]++]>>15-n[i]);return a},St=new Te(288),re=0;re<144;++re)St[re]=8;for(var re=144;re<256;++re)St[re]=9;for(var re=256;re<280;++re)St[re]=7;for(var re=280;re<288;++re)St[re]=8;for(var Sr=new Te(32),re=0;re<32;++re)Sr[re]=5;var Ic=lt(St,9,0),Rc=lt(St,9,1),Bc=lt(Sr,5,0),Lc=lt(Sr,5,1),Ts=function(n){for(var r=n[0],e=1;e<n.length;++e)n[e]>r&&(r=n[e]);return r},Qe=function(n,r,e){var t=r/8|0;return(n[t]|n[t+1]<<8)>>(r&7)&e},Ss=function(n,r){var e=r/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(r&7)},Ms=function(n){return(n+7)/8|0},Xo=function(n,r,e){return(e==null||e>n.length)&&(e=n.length),new Te(n.subarray(r,e))},kc=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],et=function(n,r,e){var t=new Error(r||kc[n]);if(t.code=n,Error.captureStackTrace&&Error.captureStackTrace(t,et),!e)throw t;return t},Nc=function(n,r,e,t){var i=n.length,s=0;if(!i||r.f&&!r.l)return e||new Te(0);var o=!e,a=o||r.i!=2,l=r.i;o&&(e=new Te(i*3));var h=function(Le){var Fe=e.length;if(Le>Fe){var Ce=new Te(Math.max(Fe*2,Le));Ce.set(e),e=Ce}},c=r.f||0,f=r.p||0,p=r.b||0,d=r.l,m=r.d,v=r.m,y=r.n,S=i*8;do{if(!d){c=Qe(n,f,1);var C=Qe(n,f+1,3);if(f+=3,C)if(C==1)d=Rc,m=Lc,v=9,y=5;else if(C==2){var P=Qe(n,f,31)+257,E=Qe(n,f+10,15)+4,w=P+Qe(n,f+5,31)+1;f+=14;for(var D=new Te(w),F=new Te(19),B=0;B<E;++B)F[Ps[B]]=Qe(n,f+B*3,7);f+=E*3;for(var U=Ts(F),V=(1<<U)-1,M=lt(F,U,1),B=0;B<w;){var N=M[Qe(n,f,V)];f+=N&15;var x=N>>4;if(x<16)D[B++]=x;else{var q=0,R=0;for(x==16?(R=3+Qe(n,f,3),f+=2,q=D[B-1]):x==17?(R=3+Qe(n,f,7),f+=3):x==18&&(R=11+Qe(n,f,127),f+=7);R--;)D[B++]=q}}var I=D.subarray(0,P),j=D.subarray(P);v=Ts(I),y=Ts(j),d=lt(I,v,1),m=lt(j,y,1)}else et(1);else{var x=Ms(f)+4,T=n[x-4]|n[x-3]<<8,b=x+T;if(b>i){l&&et(0);break}a&&h(p+T),e.set(n.subarray(x,b),p),r.b=p+=T,r.p=f=b*8,r.f=c;continue}if(f>S){l&&et(0);break}}a&&h(p+131072);for(var k=(1<<v)-1,L=(1<<y)-1,K=f;;K=f){var q=d[Ss(n,f)&k],X=q>>4;if(f+=q&15,f>S){l&&et(0);break}if(q||et(2),X<256)e[p++]=X;else if(X==256){K=f,d=null;break}else{var W=X-254;if(X>264){var B=X-257,G=ui[B];W=Qe(n,f,(1<<G)-1)+Go[B],f+=G}var Q=m[Ss(n,f)&L],Z=Q>>4;Q||et(3),f+=Q&15;var j=Dc[Z];if(Z>3){var G=fi[Z];j+=Ss(n,f)&(1<<G)-1,f+=G}if(f>S){l&&et(0);break}a&&h(p+131072);var ae=p+W;if(p<j){var ut=s-j,Ze=Math.min(j,ae);for(ut+p<0&&et(3);p<Ze;++p)e[p]=t[ut+p]}for(;p<ae;++p)e[p]=e[p-j]}}r.l=d,r.p=K,r.b=p,r.f=c,d&&(c=1,r.m=v,r.d=m,r.n=y)}while(!c);return p!=e.length&&o?Xo(e,0,p):e.subarray(0,p)},yt=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8},Mr=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8,n[t+2]|=e>>16},As=function(n,r){for(var e=[],t=0;t<n.length;++t)n[t]&&e.push({s:t,f:n[t]});var i=e.length,s=e.slice();if(!i)return{t:Ko,l:0};if(i==1){var o=new Te(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort(function(b,P){return b.f-P.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,c=1,f=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=e[e[h].f<e[f].f?h++:f++],l=e[h!=c&&e[h].f<e[f].f?h++:f++],e[c++]={s:-1,f:a.f+l.f,l:a,r:l};for(var p=s[0].s,t=1;t<i;++t)s[t].s>p&&(p=s[t].s);var d=new Ve(p+1),m=Os(e[c-1],d,0);if(m>r){var t=0,v=0,y=m-r,S=1<<y;for(s.sort(function(P,E){return d[E.s]-d[P.s]||P.f-E.f});t<i;++t){var C=s[t].s;if(d[C]>r)v+=S-(1<<m-d[C]),d[C]=r;else break}for(v>>=y;v>0;){var x=s[t].s;d[x]<r?v-=1<<r-d[x]++-1:++t}for(;t>=0&&v;--t){var T=s[t].s;d[T]==r&&(--d[T],++v)}m=r}return{t:new Te(d),l:m}},Os=function(n,r,e){return n.s==-1?Math.max(Os(n.l,r,e+1),Os(n.r,r,e+1)):r[n.s]=e},Ho=function(n){for(var r=n.length;r&&!n[--r];);for(var e=new Ve(++r),t=0,i=n[0],s=1,o=function(l){e[t++]=l},a=1;a<=r;++a)if(n[a]==i&&a!=r)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return{c:e.subarray(0,t),n:r}},Ar=function(n,r){for(var e=0,t=0;t<r.length;++t)e+=n[t]*r[t];return e},Yo=function(n,r,e){var t=e.length,i=Ms(r+2);n[i]=t&255,n[i+1]=t>>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s<t;++s)n[i+s+4]=e[s];return(i+4+t)*8},Zo=function(n,r,e,t,i,s,o,a,l,h,c){yt(r,c++,e),++i[256];for(var f=As(i,15),p=f.t,d=f.l,m=As(s,15),v=m.t,y=m.l,S=Ho(p),C=S.c,x=S.n,T=Ho(v),b=T.c,P=T.n,E=new Ve(19),w=0;w<C.length;++w)++E[C[w]&31];for(var w=0;w<b.length;++w)++E[b[w]&31];for(var D=As(E,7),F=D.t,B=D.l,U=19;U>4&&!F[Ps[U-1]];--U);var V=h+5<<3,M=Ar(i,St)+Ar(s,Sr)+o,N=Ar(i,p)+Ar(s,v)+o+14+3*U+Ar(E,F)+2*E[16]+3*E[17]+7*E[18];if(l>=0&&V<=M&&V<=N)return Yo(r,c,n.subarray(l,l+h));var q,R,I,j;if(yt(r,c,1+(N<M)),c+=2,N<M){q=lt(p,d,0),R=p,I=lt(v,y,0),j=v;var k=lt(F,B,0);yt(r,c,x-257),yt(r,c+5,P-1),yt(r,c+10,U-4),c+=14;for(var w=0;w<U;++w)yt(r,c+3*w,F[Ps[w]]);c+=3*U;for(var L=[C,b],K=0;K<2;++K)for(var X=L[K],w=0;w<X.length;++w){var W=X[w]&31;yt(r,c,k[W]),c+=F[W],W>15&&(yt(r,c,X[w]>>5&127),c+=X[w]>>12)}}else q=Ic,R=St,I=Bc,j=Sr;for(var w=0;w<a;++w){var G=t[w];if(G>255){var W=G>>18&31;Mr(r,c,q[W+257]),c+=R[W+257],W>7&&(yt(r,c,G>>23&31),c+=ui[W]);var Q=G&31;Mr(r,c,I[Q]),c+=j[Q],Q>3&&(Mr(r,c,G>>5&8191),c+=fi[Q])}else Mr(r,c,q[G]),c+=R[G]}return Mr(r,c,q[256]),c+R[256]},Fc=new xs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ko=new Te(0),$c=function(n,r,e,t,i,s){var o=s.z||n.length,a=new Te(t+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(t,a.length-i),h=s.l,c=(s.r||0)&7;if(r){c&&(l[0]=s.r>>3);for(var f=Fc[r-1],p=f>>13,d=f&8191,m=(1<<e)-1,v=s.p||new Ve(32768),y=s.h||new Ve(m+1),S=Math.ceil(e/3),C=2*S,x=function($e){return(n[$e]^n[$e+1]<<S^n[$e+2]<<C)&m},T=new xs(25e3),b=new Ve(288),P=new Ve(32),E=0,w=0,D=s.i||0,F=0,B=s.w||0,U=0;D+2<o;++D){var V=x(D),M=D&32767,N=y[V];if(v[M]=N,y[V]=M,B<=D){var q=o-D;if((E>7e3||F>24576)&&(q>423||!h)){c=Zo(n,l,0,T,b,P,w,F,U,D-U,c),F=E=w=0,U=D;for(var R=0;R<286;++R)b[R]=0;for(var R=0;R<30;++R)P[R]=0}var I=2,j=0,k=d,L=M-N&32767;if(q>2&&V==x(D-L))for(var K=Math.min(p,q)-1,X=Math.min(32767,D),W=Math.min(258,q);L<=X&&--k&&M!=N;){if(n[D+I]==n[D+I-L]){for(var G=0;G<W&&n[D+G]==n[D+G-L];++G);if(G>I){if(I=G,j=L,G>K)break;for(var Q=Math.min(L,G-2),Z=0,R=0;R<Q;++R){var ae=D-L+R&32767,ut=v[ae],Ze=ae-ut&32767;Ze>Z&&(Z=Ze,N=ae)}}}M=N,N=v[M],L+=M-N&32767}if(j){T[F++]=268435456|Cs[I]<<18|Wo[j];var Le=Cs[I]&31,Fe=Wo[j]&31;w+=ui[Le]+fi[Fe],++b[257+Le],++P[Fe],B=D+I,++E}else T[F++]=n[D],++b[n[D]]}}for(D=Math.max(D,B);D<o;++D)T[F++]=n[D],++b[n[D]];c=Zo(n,l,h,T,b,P,w,F,U,D-U,c),h||(s.r=c&7|l[c/8|0]<<3,c-=7,s.h=y,s.p=v,s.i=D,s.w=B)}else{for(var D=s.w||0;D<o+h;D+=65535){var Ce=D+65535;Ce>=o&&(l[c/8|0]=h,Ce=o),c=Yo(l,c+1,n.subarray(D,Ce))}s.i=o}return Xo(a,0,t+Ms(c)+i)},Jo=function(){var n=1,r=0;return{p:function(e){for(var t=n,i=r,s=e.length|0,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=t+=e[o];t=(t&65535)+15*(t>>16),i=(i&65535)+15*(i>>16)}n=t,r=i},d:function(){return n%=65521,r%=65521,(n&255)<<24|(n&65280)<<8|(r&255)<<8|r>>8}}},zc=function(n,r,e,t,i){if(!i&&(i={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),o=new Te(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return $c(n,r.level==null?6:r.level,r.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+r.mem,e,t,i)},Qo=function(n,r,e){for(;e;++r)n[r]=e,e>>>=8},Vc=function(n,r){var e=r.level,t=e==0?0:e<6?1:e==9?3:2;if(n[0]=120,n[1]=t<<6|(r.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,r.dictionary){var i=Jo();i.p(r.dictionary),Qo(n,2,i.d())}},jc=function(n,r){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&et(6,"invalid zlib data"),(n[1]>>5&1)==+!r&&et(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Gc(n,r){r||(r={});var e=Jo();e.p(n);var t=zc(n,r,r.dictionary?6:2,4);return Vc(t,r),Qo(t,t.length-4,e.d()),t}function qc(n,r){return Nc(n.subarray(jc(n,r),-4),{i:2},r,r)}var Wc=typeof TextDecoder<"u"&&new TextDecoder,Xc=0;try{Wc.decode(Ko,{stream:!0}),Xc=1}catch{}const Hc="modern-font";function Or(n,r){if(!n)throw new Error(`[${Hc}] ${r}`)}function Yc(n){if("buffer"in n){const r=n.buffer;return n.byteOffset>0||n.byteLength<n.buffer.byteLength?r.slice(n.byteOffset,n.byteOffset+n.byteLength):r}else return n}function nr(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Zc(n){let r="";for(let e=0,t=n.length,i;e<t;e++)i=n.charCodeAt(e),i!==0&&(r+=String.fromCharCode(i));return r}function di(n){n=Zc(n);const r=[];for(let e=0,t=n.length,i;e<t;e++)i=n.charCodeAt(e),r.push(i>>8),r.push(i&255);return r}function Kc(n){let r="";for(let e=0,t=n.length;e<t;e++)n[e]<127?r+=String.fromCharCode(n[e]):r+=`%${(256+n[e]).toString(16).slice(1)}`;return unescape(r)}function Jc(n){let r="";for(let e=0,t=n.length;e<t;e+=2)r+=String.fromCharCode((n[e]<<8)+n[e+1]);return r}var Qc=Object.defineProperty,Se=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&Qc(r,e,i),i};const Ur={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Me(){return function(n,r){Object.defineProperty(n.constructor.prototype,r,{get(){if(typeof r=="string"){if(r.startsWith("read"))return(...e)=>this.read(r.substring(4).toLowerCase(),...e);if(r.startsWith("write"))return(...e)=>this.write(r.substring(5).toLowerCase(),...e)}},configurable:!0,enumerable:!0})}}class ve extends DataView{constructor(e,t,i,s){super(Yc(e),t,i);u(this,"cursor",0);this.littleEndian=s}readColumn(e){if(e.size){const t=Array.from({length:e.size},(i,s)=>this.read(e.type,e.offset+s));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(i,s)=>{this.write(e.type,t[s],e.offset+s)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,i=this.littleEndian){var h;switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,i);case"longDateTime":return this.readLongDateTime(t,i)}const s=`get${e.replace(/^\S/,c=>c.toUpperCase())}`,o=this,a=(h=o[s])==null?void 0:h.bind(o),l=a==null?void 0:a(t,i);return this.cursor+=Ur[e],l}readUint24(e=this.cursor){const[t,i,s]=this.readBytes(e,3);return(t<<16)+(i<<8)+s}readBytes(e,t){t==null&&(t=e,e=this.cursor);const i=[];for(let s=0;s<t;++s)i.push(this.getUint8(e+s));return this.cursor=e+t,i}readString(e,t){const i=this.readBytes(e,t);let s="";for(let o=0,a=i.length;o<a;o++)s+=String.fromCharCode(i[o]);return s}readFixed(e,t){const i=this.readInt32(e,t)/65536;return Math.ceil(i*1e5)/1e5}readLongDateTime(e=this.cursor,t){const i=this.readUint32(e+4,t),s=new Date;return s.setTime(i*1e3+-20775456e5),s}readChar(e){return this.readString(e,1)}write(e,t,i=this.cursor,s=this.littleEndian){var c;switch(e){case"char":return this.writeChar(t,i);case"fixed":return this.writeFixed(t,i);case"longDateTime":return this.writeLongDateTime(t,i)}const o=`set${e.replace(/^\S/,f=>f.toUpperCase())}`,a=this,l=(c=a[o])==null?void 0:c.bind(a),h=l==null?void 0:l(i,t,s);return this.cursor+=Ur[e.toLowerCase()],h}writeString(e="",t=this.cursor){const i=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let s=0,o=e.length,a;s<o;++s)a=e.charCodeAt(s)||0,a>127?this.writeUint16(a):this.writeUint8(a);return this.cursor+=i,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const s=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(s,t+4),this}writeBytes(e,t=this.cursor){let i;if(Array.isArray(e)){i=e.length;for(let s=0;s<i;++s)this.setUint8(t+s,e[s])}else{const s=nr(e);i=s.byteLength;for(let o=0;o<i;++o)this.setUint8(t+o,s.getUint8(o))}return this.cursor=t+i,this}seek(e){return this.cursor=e,this}}Se([Me()],ve.prototype,"readInt8"),Se([Me()],ve.prototype,"readInt16"),Se([Me()],ve.prototype,"readInt32"),Se([Me()],ve.prototype,"readUint8"),Se([Me()],ve.prototype,"readUint16"),Se([Me()],ve.prototype,"readUint32"),Se([Me()],ve.prototype,"readFloat32"),Se([Me()],ve.prototype,"readFloat64"),Se([Me()],ve.prototype,"writeInt8"),Se([Me()],ve.prototype,"writeInt16"),Se([Me()],ve.prototype,"writeInt32"),Se([Me()],ve.prototype,"writeUint8"),Se([Me()],ve.prototype,"writeUint16"),Se([Me()],ve.prototype,"writeUint32"),Se([Me()],ve.prototype,"writeFloat32"),Se([Me()],ve.prototype,"writeFloat64");const ea=new WeakMap;function _(n){const r=typeof n=="object"?n:{type:n},{size:e=1,type:t}=r;return(i,s)=>{if(typeof s!="string")return;let o=ea.get(i);o||(o={columns:[],byteLength:0},ea.set(i,o));const a={...r,name:s,byteLength:e*Ur[t],offset:r.offset??o.columns.reduce((l,h)=>l+h.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,h)=>l+Ur[h.type]*(h.size??1),0),Object.defineProperty(i.constructor.prototype,s,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class je{constructor(r,e,t,i){u(this,"view");this.view=new ve(r,e,t,i)}}class pi extends je{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(r){return new FontFace(r,this.view.buffer)}}var eu=Object.defineProperty,De=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&eu(r,e,i),i};const Ie=class sl extends pi{constructor(){super(...arguments);u(this,"format","EmbeddedOpenType");u(this,"mimeType","application/vnd.ms-fontobject")}static from(e){const t=e.sfnt,s=t.name.names,o=di(s.fontFamily||""),a=o.length,l=di(s.fontStyle||""),h=l.length,c=di(s.version||""),f=c.length,p=di(s.fullName||""),d=p.length,m=86+a+4+h+4+f+4+d+2+e.view.byteLength,v=new sl(new ArrayBuffer(m),0,m,!0);v.EOTSize=v.view.byteLength,v.FontDataSize=e.view.byteLength,v.Version=131073,v.Flags=0,v.Charset=1,v.MagicNumber=20556,v.Padding1=0,v.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(v.FontPANOSE=y.fontPANOSE,v.Italic=y.fsSelection,v.Weight=y.usWeightClass,v.fsType=y.fsType,v.UnicodeRange=y.ulUnicodeRange,v.CodePageRange=y.ulCodePageRange),v.view.writeUint16(a),v.view.writeBytes(o),v.view.writeUint16(0),v.view.writeUint16(h),v.view.writeBytes(l),v.view.writeUint16(0),v.view.writeUint16(f),v.view.writeBytes(c),v.view.writeUint16(0),v.view.writeUint16(d),v.view.writeBytes(p),v.view.writeUint16(0),v.view.writeUint16(0),v.view.writeBytes(e.view),v}};De([_("uint32")],Ie.prototype,"EOTSize"),De([_("uint32")],Ie.prototype,"FontDataSize"),De([_("uint32")],Ie.prototype,"Version"),De([_("uint32")],Ie.prototype,"Flags"),De([_({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([_("uint8")],Ie.prototype,"Charset"),De([_("uint8")],Ie.prototype,"Italic"),De([_("uint32")],Ie.prototype,"Weight"),De([_("uint16")],Ie.prototype,"fsType"),De([_("uint16")],Ie.prototype,"MagicNumber"),De([_({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([_({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([_("uint32")],Ie.prototype,"CheckSumAdjustment"),De([_({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([_("uint16")],Ie.prototype,"Padding1");var tu=Object.defineProperty,gi=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&tu(r,e,i),i};class or extends je{constructor(r,e){super(r,e,16)}}gi([_({type:"char",size:4})],or.prototype,"tag"),gi([_("uint32")],or.prototype,"checkSum"),gi([_("uint32")],or.prototype,"offset"),gi([_("uint32")],or.prototype,"length");const Us=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],ru=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class Ds{constructor(r){u(this,"index");u(this,"name");u(this,"isComposite",!1);u(this,"components",[]);u(this,"pathCommands",[]);const e={...r};if(this.index=e.index??0,e.name===".notdef"?e.unicode=void 0:e.name===".null"&&(e.unicode=0),e.unicode===0&&e.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=e.name??null,e.unicode&&(this.unicode=e.unicode),e.unicodes?this.unicodes=e.unicodes:e.unicode&&(this.unicodes=[e.unicode])}getPathCommands(r=0,e=0,t=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*t,{xScale:a=o,yScale:l=o}=i,h=this.pathCommands,c=[];for(let f=0,p=h.length;f<p;f+=1){const d=h[f];d.type==="M"?c.push({type:"M",x:r+d.x*a,y:e+-d.y*l}):d.type==="L"?c.push({type:"L",x:r+d.x*a,y:e+-d.y*l}):d.type==="Q"?c.push({type:"Q",x1:r+d.x1*a,y1:e+-d.y1*l,x:r+d.x*a,y:e+-d.y*l}):d.type==="C"?c.push({type:"C",x1:r+d.x1*a,y1:e+-d.y1*l,x2:r+d.x2*a,y2:e+-d.y2*l,x:r+d.x*a,y:e+-d.y*l}):d.type==="Z"&&c.push({type:"Z"})}return c}}class iu extends Ds{parse(r,e,t){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=r,h=r.topDict.paintType,c=this.index;let f,p,d,m;const v=[],y=[];let S=0,C=!1,x=!1,T=o,b=0,P=0;function E(M,N){v.push({type:"L",x:M,y:N})}function w(M,N,q,R,I,j){v.push({type:"C",x1:M,y1:N,x2:q,y2:R,x:I,y:j})}function D(M,N){x&&h!==2&&F(),x=!0,v.push({type:"M",x:M,y:N})}function F(){v.push({type:"Z"})}function B(M){v.push(...M)}function U(){y.length%2!==0&&!C&&(T=y.shift()+s),S+=y.length>>1,y.length=0,C=!0}function V(M){let N,q,R,I,j,k,L,K,X,W,G,Q,Z=0;for(;Z<M.length;){let ae=M[Z++];switch(ae){case 1:U();break;case 3:U();break;case 4:y.length>1&&!C&&(T=y.shift()+s,C=!0),P+=y.pop(),D(b,P);break;case 5:for(;y.length>0;)b+=y.shift(),P+=y.shift(),E(b,P);break;case 6:for(;y.length>0&&(b+=y.shift(),E(b,P),y.length!==0);)P+=y.shift(),E(b,P);break;case 7:for(;y.length>0&&(P+=y.shift(),E(b,P),y.length!==0);)b+=y.shift(),E(b,P);break;case 8:for(;y.length>0;)f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m+y.shift(),w(f,p,d,m,b,P);break;case 10:j=y.pop()+l,k=r.subrs[j],k&&V(k);break;case 11:return;case 12:switch(ae=M[Z],Z+=1,ae){case 35:f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),L=d+y.shift(),K=m+y.shift(),X=L+y.shift(),W=K+y.shift(),G=X+y.shift(),Q=W+y.shift(),b=G+y.shift(),P=Q+y.shift(),y.shift(),w(f,p,d,m,L,K),w(X,W,G,Q,b,P);break;case 34:f=b+y.shift(),p=P,d=f+y.shift(),m=p+y.shift(),L=d+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=P,b=G+y.shift(),w(f,p,d,m,L,K),w(X,W,G,Q,b,P);break;case 36:f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),L=d+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=W+y.shift(),b=G+y.shift(),w(f,p,d,m,L,K),w(X,W,G,Q,b,P);break;case 37:f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),L=d+y.shift(),K=m+y.shift(),X=L+y.shift(),W=K+y.shift(),G=X+y.shift(),Q=W+y.shift(),Math.abs(G-b)>Math.abs(Q-P)?b=G+y.shift():P=Q+y.shift(),w(f,p,d,m,L,K),w(X,W,G,Q,b,P);break;default:console.warn(`Glyph ${c}: unknown operator ${1200+ae}`),y.length=0}break;case 14:if(y.length>=4){const ut=Us[y.pop()],Ze=Us[y.pop()],Le=y.pop(),Fe=y.pop();if(ut&&Ze){i.isComposite=!0,i.components=[];const Ce=r.charset.indexOf(ut),$e=r.charset.indexOf(Ze);i.components.push({glyphIndex:$e,dx:0,dy:0}),i.components.push({glyphIndex:Ce,dx:Fe,dy:Le}),B(t.get($e).pathCommands);const tt=JSON.parse(JSON.stringify(t.get(Ce).pathCommands));for(let rt=0;rt<tt.length;rt+=1){const Ke=tt[rt];Ke.type!=="Z"&&(Ke.x+=Fe,Ke.y+=Le),(Ke.type==="Q"||Ke.type==="C")&&(Ke.x1+=Fe,Ke.y1+=Le),Ke.type==="C"&&(Ke.x2+=Fe,Ke.y2+=Le)}B(tt)}}else y.length>0&&!C&&(T=y.shift()+s,C=!0);x&&h!==2&&(F(),x=!1);break;case 18:U();break;case 19:case 20:U(),Z+=S+7>>3;break;case 21:y.length>2&&!C&&(T=y.shift()+s,C=!0),P+=y.pop(),b+=y.pop(),D(b,P);break;case 22:y.length>1&&!C&&(T=y.shift()+s,C=!0),b+=y.pop(),D(b,P);break;case 23:U();break;case 24:for(;y.length>2;)f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m+y.shift(),w(f,p,d,m,b,P);b+=y.shift(),P+=y.shift(),E(b,P);break;case 25:for(;y.length>6;)b+=y.shift(),P+=y.shift(),E(b,P);f=b+y.shift(),p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m+y.shift(),w(f,p,d,m,b,P);break;case 26:for(y.length%2&&(b+=y.shift());y.length>0;)f=b,p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d,P=m+y.shift(),w(f,p,d,m,b,P);break;case 27:for(y.length%2&&(P+=y.shift());y.length>0;)f=b+y.shift(),p=P,d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m,w(f,p,d,m,b,P);break;case 28:N=M[Z],q=M[Z+1],y.push((N<<24|q<<16)>>16),Z+=2;break;case 29:j=y.pop()+a,k=r.gsubrs[j],k&&V(k);break;case 30:for(;y.length>0&&(f=b,p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m+(y.length===1?y.shift():0),w(f,p,d,m,b,P),y.length!==0);)f=b+y.shift(),p=P,d=f+y.shift(),m=p+y.shift(),P=m+y.shift(),b=d+(y.length===1?y.shift():0),w(f,p,d,m,b,P);break;case 31:for(;y.length>0&&(f=b+y.shift(),p=P,d=f+y.shift(),m=p+y.shift(),P=m+y.shift(),b=d+(y.length===1?y.shift():0),w(f,p,d,m,b,P),y.length!==0);)f=b,p=P+y.shift(),d=f+y.shift(),m=p+y.shift(),b=d+y.shift(),P=m+(y.length===1?y.shift():0),w(f,p,d,m,b,P);break;default:ae<32?console.warn(`Glyph ${c}: unknown operator ${ae}`):ae<247?y.push(ae-139):ae<251?(N=M[Z],Z+=1,y.push((ae-247)*256+N+108)):ae<255?(N=M[Z],Z+=1,y.push(-(ae-251)*256-N-108)):(N=M[Z],q=M[Z+1],R=M[Z+2],I=M[Z+3],Z+=4,y.push((N<<24|q<<16|R<<8|I)/65536))}}}V(e),this.pathCommands=v,C&&(this.advanceWidth=T)}}class Is{constructor(r){u(this,"_items",[]);this._sfnt=r}get(r){const e=this._items[r];let t;if(e)t=e;else{t=this._get(r);const i=this._sfnt.hmtx.metrics[r];i&&(t.advanceWidth=t.advanceWidth||i.advanceWidth,t.leftSideBearing=t.leftSideBearing||i.leftSideBearing);const s=this._sfnt.cmap.glyphIndexToUnicodesMap.get(r);s&&(t.unicode??(t.unicode=s[0]),t.unicodes??(t.unicodes=s)),this._items[r]=t}return t}}class su extends Is{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(r){const e=this._sfnt.cff,t=new iu({index:r});return t.parse(e,e.charStringsIndex.get(r),this),t.name=e.charset[r],t}}var nu=Object.defineProperty,ta=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&nu(r,e,i),i};class mi extends je{constructor(e,t,i,s){super(e,t,i,s);u(this,"_offsets");u(this,"_objects");this._init()}get offsets(){return this._offsets??(this._offsets=this.readOffsets())}get objects(){return this._objects??(this._objects=this.readObjects())}_init(){const e=this.view,t=this.count,i=this.offsetSize;this.objectOffset=(t+1)*i+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,i=this.offsetSize;e.seek(3);const s=[];for(let o=0,a=t+1;o<a;o++){const l=this.view;let h=0;for(let c=0;c<i;c++)h<<=8,h+=l.readUint8();s.push(h)}return s}readObjects(){const e=[];for(let t=0,i=this.count;t<i;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,i=this.objectOffset,s=i+t[e],a=i+t[e+1]-s;return this._isString?this.view.readString(s,a):this.view.readBytes(s,a)}}ta([_("uint16")],mi.prototype,"count"),ta([_("uint8")],mi.prototype,"offsetSize");class yi extends mi{constructor(){super(...arguments);u(this,"_isString",!1)}}class ra extends mi{constructor(){super(...arguments);u(this,"_isString",!0)}}const ou=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],au=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],lu=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],hu=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function vi(n,r){return r<=390?ou[r]:n[r-391]}function ie(n,r="number",e){return(t,i)=>{if(typeof i!="string")return;const s={type:r,operator:n,default:e??r==="number"?0:void 0};Object.defineProperty(t.constructor.prototype,i,{get(){return this._getProp(s)},set(o){this._setProp(s,o)},configurable:!0,enumerable:!0})}}class ia extends je{constructor(){super(...arguments);u(this,"_dict");u(this,"_stringIndex")}get dict(){return this._dict??(this._dict=this._readDict())}setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const i=15,s=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const o=e.readUint8(),a=o>>4,l=o&15;if(a===i||(t+=s[a],l===i))break;t+=s[l]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let i,s,o,a;if(e===28)return i=t.readUint8(),s=t.readUint8(),i<<8|s;if(e===29)return i=t.readUint8(),s=t.readUint8(),o=t.readUint8(),a=t.readUint8(),i<<24|s<<16|o<<8|a;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return i=t.readUint8(),(e-247)*256+i+108;if(e>=251&&e<=254)return i=t.readUint8(),-(e-251)*256-i-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const i=e.cursor+e.byteLength,s={};for(;e.cursor<i;){let o=e.readUint8();o<=21?(o===12&&(o=1200+e.readUint8()),s[o]=t,t=[]):t.push(this._readOperand(o))}return s}_getProp(e){var i;const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return vi(((i=this._stringIndex)==null?void 0:i.objects)??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var cu=Object.defineProperty,Rs=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&cu(r,e,i),i};class _i extends ia{}Rs([ie(19)],_i.prototype,"subrs"),Rs([ie(20)],_i.prototype,"defaultWidthX"),Rs([ie(21)],_i.prototype,"nominalWidthX");var uu=Object.defineProperty,ce=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&uu(r,e,i),i};class oe extends ia{}ce([ie(0,"string")],oe.prototype,"version"),ce([ie(1,"string")],oe.prototype,"notice"),ce([ie(1200,"string")],oe.prototype,"copyright"),ce([ie(2,"string")],oe.prototype,"fullName"),ce([ie(3,"string")],oe.prototype,"familyName"),ce([ie(4,"string")],oe.prototype,"weight"),ce([ie(1201)],oe.prototype,"isFixedPitch"),ce([ie(1202)],oe.prototype,"italicAngle"),ce([ie(1203,"number",-100)],oe.prototype,"underlinePosition"),ce([ie(1204,"number",50)],oe.prototype,"underlineThickness"),ce([ie(1205)],oe.prototype,"paintType"),ce([ie(1206,"number",2)],oe.prototype,"charstringType"),ce([ie(1207,"number[]",[.001,0,0,.001,0,0])],oe.prototype,"fontMatrix"),ce([ie(13)],oe.prototype,"uniqueId"),ce([ie(5,"number[]",[0,0,0,0])],oe.prototype,"fontBBox"),ce([ie(1208)],oe.prototype,"strokeWidth"),ce([ie(14)],oe.prototype,"xuid"),ce([ie(15)],oe.prototype,"charset"),ce([ie(16)],oe.prototype,"encoding"),ce([ie(17)],oe.prototype,"charStrings"),ce([ie(18,"number[]",[0,0])],oe.prototype,"private");function we(n,r=n){return e=>{Ft.tableDefinitions.set(n,{tag:n,prop:r,class:e}),Object.defineProperty(Ft.prototype,r,{get(){return this.get(n)},set(t){return this.set(n,t)},configurable:!0,enumerable:!0})}}const Zt=class Zt{constructor(r){u(this,"tables",new Map);u(this,"tableViews",new Map);(r instanceof Map?r:new Map(Object.entries(r))).forEach((t,i)=>{this.tableViews.set(i,new DataView(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)))})}get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(r){let e=this.cmap.unicodeToGlyphIndexMap.get(r.codePointAt(0));if(e===void 0&&!this.hasGlyf){const{encoding:t,charset:i}=this.cff;e=i.indexOf(t[r.codePointAt(0)])}return e??0}charToGlyph(r){return this.glyphs.get(this.charToGlyphIndex(r))}textToGlyphIndexes(r){const e=[];for(const t of r)e.push(this.charToGlyphIndex(t));return e}textToGlyphs(r){const e=this.glyphs,t=this.textToGlyphIndexes(r),i=t.length,s=Array.from({length:i}),o=e.get(0);for(let a=0;a<i;a+=1)s[a]=e.get(t[a])||o;return s}getPathCommands(r,e,t,i,s){const o=[];return this.forEachGlyph(r,e,t,i,s,(a,l,h,c,f)=>{o.push(...a.getPathCommands(l,h,c,f,this))}),o}getAdvanceWidth(r,e,t){return this.forEachGlyph(r,0,0,e,t,()=>{})}forEachGlyph(r,e=0,t=0,i=72,s={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(r);for(let h=0;h<l.length;h+=1){const c=l[h];o.call(this,c,e,t,i,s),c.advanceWidth&&(e+=c.advanceWidth*a),s.letterSpacing?e+=s.letterSpacing*i:s.tracking&&(e+=s.tracking/1e3*i)}return e}clone(){return new Zt(this.tableViews)}delete(r){const e=Zt.tableDefinitions.get(r);return e?(this.tableViews.delete(r),this.tables.delete(e.prop),this):this}set(r,e){const t=Zt.tableDefinitions.get(r);return t&&this.tables.set(t.prop,e),this.tableViews.set(r,e.view),this}get(r){const e=Zt.tableDefinitions.get(r);if(!e)return;let t=this.tables.get(e.prop);if(!t){const i=e.class;if(i){const s=this.tableViews.get(r);if(!s)return;t=new i(s.buffer,s.byteOffset,s.byteLength).setSfnt(this),this.tables.set(e.prop,t)}}return t}};u(Zt,"tableDefinitions",new Map);let Ft=Zt;class Ae extends je{setSfnt(r){return this._sfnt=r,this}getSfnt(){return this._sfnt}}var fu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,Dr=(n,r,e,t)=>{for(var i=t>1?void 0:t?du(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&fu(r,e,i),i};let $t=class extends Ae{constructor(r,e,t,i){super(r,e,t,i);u(this,"_glyphs");u(this,"privateDict");u(this,"subrsIndex");this._init()}get glyphs(){return this._glyphs??(this._glyphs=new su(this._sfnt))}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}get defaultWidthX(){var r;return((r=this.privateDict)==null?void 0:r.defaultWidthX)??0}get nominalWidthX(){var r;return((r=this.privateDict)==null?void 0:r.nominalWidthX)??0}get subrs(){var r;return((r=this.subrsIndex)==null?void 0:r.objects)??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}_init(){const r=this.view,{buffer:e,byteOffset:t}=r,i=t+4;this.nameIndex=new ra(e,i),this.topDictIndex=new yi(e,this.nameIndex.endOffset),this.stringIndex=new ra(e,this.topDictIndex.endOffset),this.globalSubrIndex=new yi(e,this.stringIndex.endOffset),this.topDict=new oe(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const s=this.topDict.private[0],o=this.topDict.private[1];s&&(this.privateDict=new _i(e,t+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new yi(e,t+o+this.privateDict.subrs))),this.charStringsIndex=new yi(e,t+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=au:this.topDict.charset===1?this.charset=lu:this.topDict.charset===2?this.charset=hu:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Us:this.topDict.encoding===1?this.encoding=ru:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(r,e,t){const i=this.view;i.seek(r);let s,o,a;e-=1;const l=[".notdef"],h=i.readUint8();if(h===0)for(s=0;s<e;s+=1)o=i.readUint16(),l.push(vi(t,o));else if(h===1)for(;l.length<=e;)for(o=i.readUint16(),a=i.readUint8(),s=0;s<=a;s+=1)l.push(vi(t,o)),o+=1;else if(h===2)for(;l.length<=e;)for(o=i.readUint16(),a=i.readUint16(),s=0;s<=a;s+=1)l.push(vi(t,o)),o+=1;else throw new Error(`Unknown charset format ${h}`);return l}_readEncoding(r){const e=this.view;e.seek(r);let t,i;const s={},o=e.readUint8();if(o===0){const a=e.readUint8();for(t=0;t<a;t+=1)i=e.readUint8(),s[i]=t}else if(o===1){const a=e.readUint8();for(i=1,t=0;t<a;t+=1){const l=e.readUint8(),h=e.readUint8();for(let c=l;c<=l+h;c+=1)s[c]=i,i+=1}}else console.warn(`unknown encoding format:${o}`);return s}_calcSubroutineBias(r){let e;return r.length<1240?e=107:r.length<33900?e=1131:e=32768,e}};Dr([_("uint8")],$t.prototype,"majorVersion",2),Dr([_("uint8")],$t.prototype,"minorVersion",2),Dr([_("uint8")],$t.prototype,"headerSize",2),Dr([_("uint8")],$t.prototype,"offsetSize",2),$t=Dr([we("CFF ","cff")],$t);var pu=Object.defineProperty,bi=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&pu(r,e,i),i};const Ir=class nl extends je{constructor(r=new ArrayBuffer(262),e){super(r,e,262)}static from(r){const e=new nl;return e.format=0,e.length=e.view.byteLength,e.language=0,r.forEach((t,i)=>{i<256&&t<256&&e.view.writeUint8(t,6+i)}),e}getUnicodeToGlyphIndexMap(){const r=new Map;return this.glyphIndexArray.forEach((e,t)=>{r.set(t,e)}),r}};bi([_("uint16")],Ir.prototype,"format"),bi([_("uint16")],Ir.prototype,"length"),bi([_("uint16")],Ir.prototype,"language"),bi([_({type:"uint8",size:256})],Ir.prototype,"glyphIndexArray");let Bs=Ir;var gu=Object.defineProperty,Ls=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&gu(r,e,i),i};class Rr extends je{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((r,e)=>Math.max(r,e),0)}get subHeaders(){const r=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:r},(e,t)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(r-t)*8-2)/2}))}get glyphIndexArray(){const r=this.maxSubHeaderKey,e=6+256*2+r*8;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(r){const e=new Map,t=this.subHeaderKeys,i=this.maxSubHeaderKey,s=this.subHeaders,o=this.glyphIndexArray,a=t.findIndex(h=>h===i);let l=0;for(let h=0;h<256;h++)if(t[h]===0)h>=a||h<s[0].firstCode||h>=s[0].firstCode+s[0].entryCount||s[0].idRangeOffset+(h-s[0].firstCode)>=o.length?l=0:(l=o[s[0].idRangeOffset+(h-s[0].firstCode)],l!==0&&(l=l+s[0].idDelta)),l!==0&&l<r&&e.set(h,l);else{const c=t[h];for(let f=0,p=s[c].entryCount;f<p;f++)if(s[c].idRangeOffset+f>=o.length?l=0:(l=o[s[c].idRangeOffset+f],l!==0&&(l=l+s[c].idDelta)),l!==0&&l<r){const d=(h<<8|f+s[c].firstCode)%65535;e.set(d,l)}}return e}}Ls([_("uint16")],Rr.prototype,"format"),Ls([_("uint16")],Rr.prototype,"length"),Ls([_("uint16")],Rr.prototype,"language");function sa(n){return n>32767?n-65536:n<-32767?n+65536:n}function ks(n,r){let e;const t=[];let i={};return n.forEach((s,o)=>{r&&o>r||((!e||o!==e.unicode+1||s!==e.glyphIndex+1)&&(e?(i.end=e.unicode,t.push(i),i={start:o,startId:s,delta:sa(s-o)}):(i.start=Number(o),i.startId=s,i.delta=sa(s-o))),e={unicode:o,glyphIndex:s})}),e&&(i.end=e.unicode,t.push(i)),t}var mu=Object.defineProperty,zt=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&mu(r,e,i),i};const Mt=class ol extends je{get endCode(){const r=this.segCountX2;return this.view.seek(14),Array.from({length:r/2},()=>this.view.readUint16())}set endCode(r){this.view.seek(14),r.forEach(e=>this.view.writeUint16(e))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(r){this.view.writeUint16(r,14+this.segCountX2)}get startCode(){const r=this.segCountX2;return this.view.seek(14+r+2),Array.from({length:r/2},()=>this.view.readUint16())}set startCode(r){this.view.seek(14+this.segCountX2+2),r.forEach(e=>this.view.writeUint16(e))}get idDelta(){const r=this.segCountX2;return this.view.seek(14+r+2+r),Array.from({length:r/2},()=>this.view.readUint16())}set idDelta(r){const e=this.segCountX2;this.view.seek(14+e+2+e),r.forEach(t=>this.view.writeUint16(t))}get idRangeOffsetCursor(){const r=this.segCountX2;return 14+r+2+r*2}get idRangeOffset(){const r=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:r/2},()=>this.view.readUint16())}set idRangeOffset(r){this.view.seek(this.idRangeOffsetCursor),r.forEach(e=>this.view.writeUint16(e))}get glyphIndexArrayCursor(){const r=this.segCountX2;return 14+r+2+r*3}get glyphIndexArray(){const r=this.glyphIndexArrayCursor;this.view.seek(r);const e=(this.view.byteLength-r)/2;return Array.from({length:e},()=>this.view.readUint16())}static from(r){const e=ks(r,65535),t=e.length+1,i=Math.floor(Math.log(t)/Math.LN2),s=2*2**i,o=new ol(new ArrayBuffer(24+e.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=t*2,o.searchRange=s,o.entrySelector=i,o.rangeShift=2*t-s,o.endCode=[...e.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...e.map(a=>a.start),65535],o.idDelta=[...e.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:t},()=>0),o}getUnicodeToGlyphIndexMap(){const r=new Map,e=this.segCountX2/2,t=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,s=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<e;++h)for(let c=i[h],f=s[h];c<=f;++c)if(o[h]===0)r.set(c,(c+a[h])%65536);else{const p=h+o[h]/2+(c-i[h])-t,d=l[p];d!==0?r.set(c,(d+a[h])%65536):r.set(c,0)}return r.delete(65535),r}};zt([_("uint16")],Mt.prototype,"format"),zt([_("uint16")],Mt.prototype,"length"),zt([_("uint16")],Mt.prototype,"language"),zt([_("uint16")],Mt.prototype,"segCountX2"),zt([_("uint16")],Mt.prototype,"searchRange"),zt([_("uint16")],Mt.prototype,"entrySelector"),zt([_("uint16")],Mt.prototype,"rangeShift");let Ns=Mt;var yu=Object.defineProperty,Br=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&yu(r,e,i),i};class Vt extends je{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const r=this.glyphIndexArray,e=new Map;return r.forEach((t,i)=>{e.set(i,t)}),e}}Br([_("uint16")],Vt.prototype,"format"),Br([_("uint16")],Vt.prototype,"length"),Br([_("uint16")],Vt.prototype,"language"),Br([_("uint16")],Vt.prototype,"firstCode"),Br([_("uint16")],Vt.prototype,"entryCount");var vu=Object.defineProperty,Lr=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&vu(r,e,i),i};const ar=class al extends je{get groups(){const r=this.nGroups;return this.view.seek(16),Array.from({length:r},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(r){const e=ks(r),t=new al(new ArrayBuffer(16+e.length*12));return t.format=12,t.reserved=0,t.length=t.view.byteLength,t.language=0,t.nGroups=e.length,e.forEach(i=>{t.view.writeUint32(i.start),t.view.writeUint32(i.end),t.view.writeUint32(i.startId)}),t}getUnicodeToGlyphIndexMap(){const r=new Map,e=this.groups;for(let t=0,i=e.length;t<i;t++){const s=e[t];let o=s.startGlyphCode,a=s.startCharCode;const l=s.endCharCode;for(;a<=l;)r.set(a++,o++)}return r}};Lr([_("uint16")],ar.prototype,"format"),Lr([_("uint16")],ar.prototype,"reserved"),Lr([_("uint32")],ar.prototype,"length"),Lr([_("uint32")],ar.prototype,"language"),Lr([_("uint32")],ar.prototype,"nGroups");let Fs=ar;var _u=Object.defineProperty,$s=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&_u(r,e,i),i};class kr extends je{getVarSelectorRecords(){const r=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:r},()=>{const e={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(e.defaultUVSOffset){this.view.seek(e.defaultUVSOffset);const t=this.view.readUint32();e.unicodeValueRanges=Array.from({length:t},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(e.nonDefaultUVSOffset){this.view.seek(e.nonDefaultUVSOffset);const t=this.view.readUint32();e.uVSMappings=Array.from({length:t},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return e})}getUnicodeToGlyphIndexMap(){const r=new Map,e=this.getVarSelectorRecords();for(let t=0,i=e.length;t<i;t++){const{uVSMappings:s}=e[t];s.forEach(o=>{r.set(o.unicodeValue,o.glyphID)})}return r}}$s([_("uint16")],kr.prototype,"format"),$s([_("uint32")],kr.prototype,"length"),$s([_("uint32")],kr.prototype,"numVarSelectorRecords");var bu=Object.defineProperty,wu=Object.getOwnPropertyDescriptor,zs=(n,r,e,t)=>{for(var i=t>1?void 0:t?wu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&bu(r,e,i),i};let lr=class extends Ae{constructor(){super(...arguments);u(this,"_unicodeToGlyphIndexMap");u(this,"_glyphIndexToUnicodesMap")}static from(r){const e=Array.from(r.keys()).some(f=>f>65535),t=Ns.from(r),i=Bs.from(r),s=e?Fs.from(r):void 0,o=4+(s?32:24),a=o+t.view.byteLength,l=a+i.view.byteLength,h=[{platformID:0,platformSpecificID:3,offset:o},{platformID:1,platformSpecificID:0,offset:a},{platformID:3,platformSpecificID:1,offset:o},s&&{platformID:3,platformSpecificID:10,offset:l}].filter(Boolean),c=new lr(new ArrayBuffer(4+8*h.length+t.view.byteLength+i.view.byteLength+((s==null?void 0:s.view.byteLength)??0)));return c.numberSubtables=h.length,c.view.seek(4),h.forEach(f=>{c.view.writeUint16(f.platformID),c.view.writeUint16(f.platformSpecificID),c.view.writeUint32(f.offset)}),c.view.writeBytes(t.view,o),c.view.writeBytes(i.view,a),s&&c.view.writeBytes(s.view,l),c}get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??(this._unicodeToGlyphIndexMap=this.readunicodeToGlyphIndexMap())}get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const r=new Map,e=this.unicodeToGlyphIndexMap,t=Array.from(e.keys());for(let i=0,s=t.length;i<s;i++){const o=t[i],a=e.get(o);r.has(a)?r.get(a).push(o):r.set(a,[o])}this._glyphIndexToUnicodesMap=r}return this._glyphIndexToUnicodesMap}readSubtables(){const r=this.numberSubtables;return this.view.seek(4),Array.from({length:r},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);const t=this.view.readUint16();let i;switch(t){case 0:i=new Bs(this.view.buffer,e.offset);break;case 2:i=new Rr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:i=new Ns(this.view.buffer,e.offset,this.view.readUint16());break;case 6:i=new Vt(this.view.buffer,e.offset,this.view.readUint16());break;case 12:i=new Fs(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:i=new kr(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:i}})}readunicodeToGlyphIndexMap(){var a,l,h,c,f;const r=this.readSubtables(),e=(a=r.find(p=>p.format===0))==null?void 0:a.view,t=(l=r.find(p=>p.platformID===3&&p.platformSpecificID===3&&p.format===2))==null?void 0:l.view,i=(h=r.find(p=>p.platformID===3&&p.platformSpecificID===1&&p.format===4))==null?void 0:h.view,s=(c=r.find(p=>p.platformID===3&&p.platformSpecificID===10&&p.format===12))==null?void 0:c.view,o=(f=r.find(p=>p.platformID===0&&p.platformSpecificID===5&&p.format===14))==null?void 0:f.view;return new Map([...(e==null?void 0:e.getUnicodeToGlyphIndexMap())??[],...(t==null?void 0:t.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(i==null?void 0:i.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};zs([_("uint16")],lr.prototype,"version",2),zs([_("uint16")],lr.prototype,"numberSubtables",2),lr=zs([we("cmap")],lr);class xu extends Ds{_parseContours(r){const e=[];let t=[];for(let i=0;i<r.length;i+=1){const s=r[i];t.push(s),s.lastPointOfContour&&(e.push(t),t=[])}return Or(t.length===0,"There are still points left in the current contour."),e}_transformPoints(r,e){const t=[];for(let i=0;i<r.length;i+=1){const s=r[i],o={x:e.xScale*s.x+e.scale10*s.y+e.dx,y:e.scale01*s.x+e.yScale*s.y+e.dy,onCurve:s.onCurve,lastPointOfContour:s.lastPointOfContour};t.push(o)}return t}_parseGlyphCoordinate(r,e,t,i,s){let o;return(e&i)>0?(o=r.view.readUint8(),e&s||(o=-o),o=t+o):(e&s)>0?o=t:o=t+r.view.readInt16(),o}parse(r,e,t){r.view.seek(e);const i=this.numberOfContours=r.view.readInt16();if(this.xMin=r.view.readInt16(),this.yMin=r.view.readInt16(),this.xMax=r.view.readInt16(),this.yMax=r.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let v=0;v<i;v++)a.push(r.view.readUint16());const l=this.instructionLength=r.view.readUint16();Or(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let v=0;v<l;++v)h.push(r.view.readUint8());const c=r.view.byteOffset,f=a[a.length-1]+1;Or(f<2e4,`Bad numberOfCoordinates:${c}`);const p=[];let d,m=0;for(;m<f;)if(d=r.view.readUint8(),p.push(d),m++,d&8&&m<f){const v=r.view.readUint8();for(let y=0;y<v;y++)p.push(d),m++}if(Or(p.length===f,`Bad flags length: ${p.length}, numberOfCoordinates: ${f}`),a.length>0){const v=[];let y;if(f>0){for(let x=0;x<f;x+=1)d=p[x],y={},y.onCurve=!!(d&1),y.lastPointOfContour=a.includes(x),v.push(y);let S=0;for(let x=0;x<f;x+=1)d=p[x],y=v[x],y.x=this._parseGlyphCoordinate(r,d,S,2,16),S=y.x;let C=0;for(let x=0;x<f;x+=1)d=p[x],y=v[x],y.y=this._parseGlyphCoordinate(r,d,C,4,32),C=y.y}this.points=v}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=r.view.readUint16();const h={glyphIndex:r.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(h.dx=r.view.readInt16(),h.dy=r.view.readInt16()):h.matchedPoints=[r.view.readUint16(),r.view.readUint16()]:(a&2)>0?(h.dx=r.view.readInt8(),h.dy=r.view.readInt8()):h.matchedPoints=[r.view.readUint8(),r.view.readUint8()],(a&8)>0?h.xScale=h.yScale=r.view.readInt16()/16384:(a&64)>0?(h.xScale=r.view.readInt16()/16384,h.yScale=r.view.readInt16()/16384):(a&128)>0&&(h.xScale=r.view.readInt16()/16384,h.scale01=r.view.readInt16()/16384,h.scale10=r.view.readInt16()/16384,h.yScale=r.view.readInt16()/16384),this.components.push(h),l=!!(a&32)}if(a&256){this.instructionLength=r.view.readUint16(),this.instructions=[];for(let h=0;h<this.instructionLength;h+=1)this.instructions.push(r.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],h=t.get(l.glyphIndex);if(h.getPathCommands(),h.points){let c;if(l.matchedPoints===void 0)c=this._transformPoints(h.points,l);else{Or(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const f=this.points[l.matchedPoints[0]];let p=h.points[l.matchedPoints[1]];const d={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};p=this._transformPoints([p],d)[0],d.dx=f.x-p.x,d.dy=f.y-p.y,c=this._transformPoints(h.points,d)}this.points=this.points.concat(c)}}const s=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const h=o[a];let c=h[h.length-1],f=h[0];c.onCurve?s.push({type:"M",x:c.x,y:c.y}):f.onCurve?s.push({type:"M",x:f.x,y:f.y}):s.push({type:"M",x:(c.x+f.x)*.5,y:(c.y+f.y)*.5});for(let p=0,d=h.length;p<d;++p)if(c=f,f=h[(p+1)%d],c.onCurve)s.push({type:"L",x:c.x,y:c.y});else{let m=f;f.onCurve||(m={x:(c.x+f.x)*.5,y:(c.y+f.y)*.5}),s.push({type:"Q",x1:c.x,y1:c.y,x:m.x,y:m.y})}s.push({type:"Z"})}this.pathCommands=s}}class Pu extends Is{get length(){return this._sfnt.loca.locations.length}_get(r){const e=this._sfnt.loca.locations,t=e[r],i=new xu({index:r});return t!==e[r+1]&&i.parse(this._sfnt.glyf,t,this),i}}var Cu=Object.defineProperty,Eu=Object.getOwnPropertyDescriptor,Tu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Eu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Cu(r,e,i),i};let wi=class extends Ae{constructor(){super(...arguments);u(this,"_glyphs")}static from(r){const e=r.reduce((i,s)=>i+s.byteLength,0),t=new wi(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeBytes(i)}),t}get glyphs(){return this._glyphs??(this._glyphs=new Pu(this._sfnt))}};wi=Tu([we("glyf")],wi);var Su=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,Au=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Su(r,e,i),i};let Vs=class extends Ae{};Vs=Au([we("GPOS","gpos")],Vs);var Ou=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,jt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Uu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ou(r,e,i),i};let vt=class extends Ae{};jt([_("uint16")],vt.prototype,"majorVersion",2),jt([_("uint16")],vt.prototype,"minorVersion",2),jt([_("uint16")],vt.prototype,"scriptListOffset",2),jt([_("uint16")],vt.prototype,"featureListOffset",2),jt([_("uint16")],vt.prototype,"lookupListOffset",2),jt([_("uint16")],vt.prototype,"featureVariationsOffset",2),vt=jt([we("GSUB","gsub")],vt);var Du=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,_e=(n,r,e,t)=>{for(var i=t>1?void 0:t?Iu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Du(r,e,i),i};let pe=class extends Ae{constructor(n=new ArrayBuffer(54),r){super(n,r,Math.min(54,n.byteLength-(r??0)))}};_e([_("fixed")],pe.prototype,"version",2),_e([_("fixed")],pe.prototype,"fontRevision",2),_e([_("uint32")],pe.prototype,"checkSumAdjustment",2),_e([_("uint32")],pe.prototype,"magickNumber",2),_e([_("uint16")],pe.prototype,"flags",2),_e([_("uint16")],pe.prototype,"unitsPerEm",2),_e([_({type:"longDateTime"})],pe.prototype,"created",2),_e([_({type:"longDateTime"})],pe.prototype,"modified",2),_e([_("int16")],pe.prototype,"xMin",2),_e([_("int16")],pe.prototype,"yMin",2),_e([_("int16")],pe.prototype,"xMax",2),_e([_("int16")],pe.prototype,"yMax",2),_e([_("uint16")],pe.prototype,"macStyle",2),_e([_("uint16")],pe.prototype,"lowestRecPPEM",2),_e([_("int16")],pe.prototype,"fontDirectionHint",2),_e([_("int16")],pe.prototype,"indexToLocFormat",2),_e([_("int16")],pe.prototype,"glyphDataFormat",2),pe=_e([we("head")],pe);var Ru=Object.defineProperty,Bu=Object.getOwnPropertyDescriptor,Re=(n,r,e,t)=>{for(var i=t>1?void 0:t?Bu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ru(r,e,i),i};let xe=class extends Ae{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Re([_("fixed")],xe.prototype,"version",2),Re([_("int16")],xe.prototype,"ascent",2),Re([_("int16")],xe.prototype,"descent",2),Re([_("int16")],xe.prototype,"lineGap",2),Re([_("uint16")],xe.prototype,"advanceWidthMax",2),Re([_("int16")],xe.prototype,"minLeftSideBearing",2),Re([_("int16")],xe.prototype,"minRightSideBearing",2),Re([_("int16")],xe.prototype,"xMaxExtent",2),Re([_("int16")],xe.prototype,"caretSlopeRise",2),Re([_("int16")],xe.prototype,"caretSlopeRun",2),Re([_("int16")],xe.prototype,"caretOffset",2),Re([_({type:"int16",size:4})],xe.prototype,"reserved",2),Re([_("int16")],xe.prototype,"metricDataFormat",2),Re([_("uint16")],xe.prototype,"numOfLongHorMetrics",2),xe=Re([we("hhea")],xe);var Lu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,Nu=(n,r,e,t)=>{for(var i=t>1?void 0:t?ku(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Lu(r,e,i),i};let xi=class extends Ae{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new xi(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeUint16(i.advanceWidth),t.view.writeUint16(i.leftSideBearing)}),t}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){const r=this._sfnt.maxp.numGlyphs,e=this._sfnt.hhea.numOfLongHorMetrics;let t=0;const i=this.view;return i.seek(0),Array.from({length:r}).map((s,o)=>(o<e&&(t=i.readUint16()),{advanceWidth:t,leftSideBearing:i.readUint16()}))}};xi=Nu([we("hmtx")],xi);var Fu=Object.defineProperty,$u=Object.getOwnPropertyDescriptor,zu=(n,r,e,t)=>{for(var i=t>1?void 0:t?$u(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Fu(r,e,i),i};let js=class extends Ae{};js=zu([we("kern","kern")],js);var Vu=Object.defineProperty,ju=Object.getOwnPropertyDescriptor,Gu=(n,r,e,t)=>{for(var i=t>1?void 0:t?ju(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Vu(r,e,i),i};let Pi=class extends Ae{constructor(){super(...arguments);u(this,"_locations")}static from(r,e=1){const t=r.length*(e?4:2),i=new Pi(new ArrayBuffer(t));return r.forEach(s=>{e?i.view.writeUint32(s):i.view.writeUint16(s/2)}),i}get locations(){return this._locations??(this._locations=this.readLocations())}readLocations(){const r=this._sfnt.maxp.numGlyphs,e=this._sfnt.head.indexToLocFormat,t=this.view;return t.seek(0),Array.from({length:r}).map(()=>e?t.readUint32():t.readUint16()*2)}};Pi=Gu([we("loca")],Pi);var qu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Oe=(n,r,e,t)=>{for(var i=t>1?void 0:t?Wu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&qu(r,e,i),i};let be=class extends Ae{constructor(n=new ArrayBuffer(32),r){super(n,r,Math.min(32,n.byteLength-(r??0)))}};Oe([_("fixed")],be.prototype,"version",2),Oe([_("uint16")],be.prototype,"numGlyphs",2),Oe([_("uint16")],be.prototype,"maxPoints",2),Oe([_("uint16")],be.prototype,"maxContours",2),Oe([_("uint16")],be.prototype,"maxComponentPoints",2),Oe([_("uint16")],be.prototype,"maxComponentContours",2),Oe([_("uint16")],be.prototype,"maxZones",2),Oe([_("uint16")],be.prototype,"maxTwilightPoints",2),Oe([_("uint16")],be.prototype,"maxStorage",2),Oe([_("uint16")],be.prototype,"maxFunctionDefs",2),Oe([_("uint16")],be.prototype,"maxInstructionDefs",2),Oe([_("uint16")],be.prototype,"maxStackElements",2),Oe([_("uint16")],be.prototype,"maxSizeOfInstructions",2),Oe([_("uint16")],be.prototype,"maxComponentElements",2),Oe([_("uint16")],be.prototype,"maxComponentDepth",2),be=Oe([we("maxp")],be);var Xu=Object.defineProperty,Hu=Object.getOwnPropertyDescriptor,Ci=(n,r,e,t)=>{for(var i=t>1?void 0:t?Hu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Xu(r,e,i),i};const na={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},Gs={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Yu={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},oa={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let hr=class extends Ae{constructor(){super(...arguments);u(this,"_names")}get names(){return this._names??(this._names=this.readNames())}readNames(){const r=this.count;this.view.seek(6);const e=[];for(let l=0;l<r;++l)e.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const t=this.stringOffset;for(let l=0;l<r;++l){const h=e[l];h.name=this.view.readBytes(t+h.offset,h.length)}let i=Gs.Macintosh,s=Yu.Default,o=0;e.some(l=>l.platform===Gs.Microsoft&&l.encoding===oa.UCS2&&l.language===1033)&&(i=Gs.Microsoft,s=oa.UCS2,o=1033);const a={};for(let l=0;l<r;++l){const h=e[l];h.platform===i&&h.encoding===s&&h.language===o&&na[h.nameId]&&(a[na[h.nameId]]=o===0?Kc(h.name):Jc(h.name))}return a}};Ci([_("uint16")],hr.prototype,"format",2),Ci([_("uint16")],hr.prototype,"count",2),Ci([_("uint16")],hr.prototype,"stringOffset",2),hr=Ci([we("name")],hr);var Zu=Object.defineProperty,Ku=Object.getOwnPropertyDescriptor,z=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ku(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Zu(r,e,i),i};let $=class extends Ae{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};z([_("uint16")],$.prototype,"version",2),z([_("int16")],$.prototype,"xAvgCharWidth",2),z([_("uint16")],$.prototype,"usWeightClass",2),z([_("uint16")],$.prototype,"usWidthClass",2),z([_("uint16")],$.prototype,"fsType",2),z([_("uint16")],$.prototype,"ySubscriptXSize",2),z([_("uint16")],$.prototype,"ySubscriptYSize",2),z([_("uint16")],$.prototype,"ySubscriptXOffset",2),z([_("uint16")],$.prototype,"ySubscriptYOffset",2),z([_("uint16")],$.prototype,"ySuperscriptXSize",2),z([_("uint16")],$.prototype,"ySuperscriptYSize",2),z([_("uint16")],$.prototype,"ySuperscriptXOffset",2),z([_("uint16")],$.prototype,"ySuperscriptYOffset",2),z([_("uint16")],$.prototype,"yStrikeoutSize",2),z([_("uint16")],$.prototype,"yStrikeoutPosition",2),z([_("uint16")],$.prototype,"sFamilyClass",2),z([_({type:"uint8"})],$.prototype,"bFamilyType",2),z([_({type:"uint8"})],$.prototype,"bSerifStyle",2),z([_({type:"uint8"})],$.prototype,"bWeight",2),z([_({type:"uint8"})],$.prototype,"bProportion",2),z([_({type:"uint8"})],$.prototype,"bContrast",2),z([_({type:"uint8"})],$.prototype,"bStrokeVariation",2),z([_({type:"uint8"})],$.prototype,"bArmStyle",2),z([_({type:"uint8"})],$.prototype,"bLetterform",2),z([_({type:"uint8"})],$.prototype,"bMidline",2),z([_({type:"uint8"})],$.prototype,"bXHeight",2),z([_({type:"uint8",size:16})],$.prototype,"ulUnicodeRange",2),z([_({type:"char",size:4})],$.prototype,"achVendID",2),z([_("uint16")],$.prototype,"fsSelection",2),z([_("uint16")],$.prototype,"usFirstCharIndex",2),z([_("uint16")],$.prototype,"usLastCharIndex",2),z([_("int16")],$.prototype,"sTypoAscender",2),z([_("int16")],$.prototype,"sTypoDescender",2),z([_("int16")],$.prototype,"sTypoLineGap",2),z([_("uint16")],$.prototype,"usWinAscent",2),z([_("uint16")],$.prototype,"usWinDescent",2),z([_({offset:72,type:"uint8",size:8})],$.prototype,"ulCodePageRange",2),z([_({offset:72,type:"int16"})],$.prototype,"sxHeight",2),z([_("int16")],$.prototype,"sCapHeight",2),z([_("uint16")],$.prototype,"usDefaultChar",2),z([_("uint16")],$.prototype,"usBreakChar",2),z([_("uint16")],$.prototype,"usMaxContext",2),$=z([we("OS/2","os2")],$);var Ju=Object.defineProperty,Qu=Object.getOwnPropertyDescriptor,ht=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ju(r,e,i),i};let Xe=class extends Ae{constructor(n=new ArrayBuffer(32),r,e){super(n,r,e)}};ht([_("fixed")],Xe.prototype,"format",2),ht([_("fixed")],Xe.prototype,"italicAngle",2),ht([_("int16")],Xe.prototype,"underlinePosition",2),ht([_("int16")],Xe.prototype,"underlineThickness",2),ht([_("uint32")],Xe.prototype,"isFixedPitch",2),ht([_("uint32")],Xe.prototype,"minMemType42",2),ht([_("uint32")],Xe.prototype,"maxMemType42",2),ht([_("uint32")],Xe.prototype,"minMemType1",2),ht([_("uint32")],Xe.prototype,"maxMemType1",2),Xe=ht([we("post")],Xe);var ef=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,Be=(n,r,e,t)=>{for(var i=t>1?void 0:t?tf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ef(r,e,i),i};let Pe=class extends Ae{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Be([_("fixed")],Pe.prototype,"version",2),Be([_("int16")],Pe.prototype,"vertTypoAscender",2),Be([_("int16")],Pe.prototype,"vertTypoDescender",2),Be([_("int16")],Pe.prototype,"vertTypoLineGap",2),Be([_("int16")],Pe.prototype,"advanceHeightMax",2),Be([_("int16")],Pe.prototype,"minTopSideBearing",2),Be([_("int16")],Pe.prototype,"minBottomSideBearing",2),Be([_("int16")],Pe.prototype,"yMaxExtent",2),Be([_("int16")],Pe.prototype,"caretSlopeRise",2),Be([_("int16")],Pe.prototype,"caretSlopeRun",2),Be([_("int16")],Pe.prototype,"caretOffset",2),Be([_({type:"int16",size:4})],Pe.prototype,"reserved",2),Be([_("int16")],Pe.prototype,"metricDataFormat",2),Be([_("int16")],Pe.prototype,"numOfLongVerMetrics",2),Pe=Be([we("vhea")],Pe);var rf=Object.defineProperty,sf=Object.getOwnPropertyDescriptor,nf=(n,r,e,t)=>{for(var i=t>1?void 0:t?sf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&rf(r,e,i),i};let Ei=class extends Ae{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Ei(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeUint16(i.advanceHeight),t.view.writeInt16(i.topSideBearing)}),t}get metrics(){return this._metrics??(this._metrics=this.readMetrics())}readMetrics(){var s;const r=this._sfnt.maxp.numGlyphs,e=((s=this._sfnt.vhea)==null?void 0:s.numOfLongVerMetrics)??0,t=this.view;t.seek(0);let i=0;return Array.from({length:r}).map((o,a)=>(a<e&&(i=t.readUint16()),{advanceHeight:i,topSideBearing:t.readUint8()}))}};Ei=nf([we("vmtx")],Ei);var of=Object.defineProperty,Nr=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&of(r,e,i),i};class He extends pi{constructor(){super(...arguments);u(this,"format","TrueType");u(this,"mimeType","font/ttf");u(this,"_sfnt")}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(nr(e).getUint32(0))}static checksum(e){const t=nr(e);let i=t.byteLength;for(;i%4;)i++;let s=0;for(let o=0,a=i/4;o<a;o+=4)o*4<i-4&&(s+=t.getUint32(o*4,!1));return s&4294967295}static from(e){const t=p=>p+3&-4,i=e.tableViews.size,s=Array.from(e.tableViews.values()).reduce((p,d)=>p+t(d.byteLength),0),o=new this(new ArrayBuffer(12+i*16+s));o.scalerType=65536,o.numTables=i;const a=Math.log(2);o.searchRange=Math.floor(Math.log(i)/a)*16,o.entrySelector=Math.floor(o.searchRange/a),o.rangeShift=i*16-o.searchRange;let l=12+i*16,h=0;const c=o.getDirectories();e.tableViews.forEach((p,d)=>{const m=c[h++];m.tag=d,m.checkSum=this.checksum(p),m.offset=l,m.length=p.byteLength,o.view.writeBytes(p,l),l+=t(m.length)});const f=o.createSfnt().head;return f.checkSumAdjustment=0,f.checkSumAdjustment=2981146554-this.checksum(o.view),o}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const t=new or(this.view.buffer,e);return e+=t.view.byteLength,t})}createSfnt(){return new Ft(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}u(He,"signature",new Set([65536,1953658213,1954115633])),Nr([_("uint32")],He.prototype,"scalerType"),Nr([_("uint16")],He.prototype,"numTables"),Nr([_("uint16")],He.prototype,"searchRange"),Nr([_("uint16")],He.prototype,"entrySelector"),Nr([_("uint16")],He.prototype,"rangeShift");class Ti extends He{constructor(){super(...arguments);u(this,"format","OpenType");u(this,"mimeType","font/otf")}static from(e){return super.from(e)}}u(Ti,"signature",new Set([1330926671]));var af=Object.defineProperty,Fr=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&af(r,e,i),i};class Gt extends je{constructor(r,e){super(r,e,20)}}Fr([_({type:"char",size:4})],Gt.prototype,"tag"),Fr([_("uint32")],Gt.prototype,"offset"),Fr([_("uint32")],Gt.prototype,"compLength"),Fr([_("uint32")],Gt.prototype,"origLength"),Fr([_("uint32")],Gt.prototype,"origChecksum");var lf=Object.defineProperty,Ge=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&lf(r,e,i),i};const Ne=(It=class extends pi{constructor(){super(...arguments);u(this,"format","WOFF");u(this,"mimeType","font/woff");u(this,"_sfnt")}get subfontFormat(){return He.is(this.flavor)?"TrueType":Ti.is(this.flavor)?"OpenType":"Open"}get sfnt(){return this._sfnt||(this._sfnt=this.createSfnt()),this._sfnt}static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(nr(e).getUint32(0))}static checkSum(e){const t=nr(e),i=t.byteLength,s=Math.floor(i/4);let o=0,a=0;for(;a<s;)o+=t.getUint32(4*a++,!1);let l=i-s*4;if(l){let h=s*4;for(;l>0;)o+=t.getUint8(h)<<l*8,h++,l--}return o%4294967296}static from(e,t=new ArrayBuffer(0)){const i=p=>p+3&-4,s=[];e.tableViews.forEach((p,d)=>{const m=nr(Gc(new Uint8Array(p.buffer,p.byteOffset,p.byteLength)));s.push({tag:d,view:m.byteLength<p.byteLength?m:p,rawView:p})});const o=s.length,a=s.reduce((p,d)=>p+i(d.view.byteLength),0),l=new It(new ArrayBuffer(44+20*o+a+t.byteLength));l.signature=2001684038,l.flavor=65536,l.length=l.view.byteLength,l.numTables=o,l.totalSfntSize=12+16*o+s.reduce((p,d)=>p+i(d.rawView.byteLength),0);let h=44+o*20,c=0;const f=l.getDirectories();return s.forEach(p=>{const d=f[c++];d.tag=p.tag,d.offset=h,d.compLength=p.view.byteLength,d.origChecksum=It.checkSum(p.rawView),d.origLength=p.rawView.byteLength,l.view.writeBytes(p.view,h),h+=i(d.compLength)}),l.view.writeBytes(t),l}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new Gt(this.view.buffer,e);return e+=t.view.byteLength,t})}createSfnt(){return new Ft(this.getDirectories().reduce((e,t)=>{const i=t.tag,s=this.view.byteOffset+t.offset,o=t.compLength,a=t.origLength,l=s+o;return e[i]=o>=a?new DataView(this.view.buffer,s,o):new DataView(qc(new Uint8Array(this.view.buffer.slice(s,l))).buffer),e},{}))}},u(It,"signature",new Set([2001684038])),It);Ge([_("uint32")],Ne.prototype,"signature"),Ge([_("uint32")],Ne.prototype,"flavor"),Ge([_("uint32")],Ne.prototype,"length"),Ge([_("uint16")],Ne.prototype,"numTables"),Ge([_("uint16")],Ne.prototype,"reserved"),Ge([_("uint32")],Ne.prototype,"totalSfntSize"),Ge([_("uint16")],Ne.prototype,"majorVersion"),Ge([_("uint16")],Ne.prototype,"minorVersion"),Ge([_("uint32")],Ne.prototype,"metaOffset"),Ge([_("uint32")],Ne.prototype,"metaLength"),Ge([_("uint32")],Ne.prototype,"metaOrigLength"),Ge([_("uint32")],Ne.prototype,"privOffset"),Ge([_("uint32")],Ne.prototype,"privLength");let Si=Ne;function aa(n,r=!0){if(He.is(n))return new He(n);if(Ti.is(n))return new Ti(n);if(Si.is(n))return new Si(n);if(r)throw new Error("Failed to parseFont")}const Li=class Li{constructor(){u(this,"fallbackFont");u(this,"loading",new Map);u(this,"loaded",new Map);u(this,"familyToUrl",new Map)}_createRequest(r,e){const t=new AbortController;return{url:r,when:fetch(r,{...Li.defaultRequestInit,...e,signal:t.signal}).then(i=>i.arrayBuffer()),cancel:()=>t.abort()}}injectFontFace(r,e){return document.fonts.add(new FontFace(r,e)),this}injectStyleTag(r,e){const t=document.createElement("style");return t.appendChild(document.createTextNode(`@font-face {
|
|
28
|
+
font-family: "${r}";
|
|
29
|
+
src: url(${e});
|
|
30
|
+
}`)),document.head.appendChild(t),this}_parseUrls(r){const e=Array.from(new Set([...r.split(","),r]));return Array.from(new Set(e.map(t=>this.familyToUrl.get(t.trim())??this.familyToUrl.get(t)??t)))}get(r){let e;return r&&(e=this._parseUrls(r).reduce((i,s)=>i||this.loaded.get(s),void 0)),e??this.fallbackFont}set(r,e){return this.familyToUrl.set(r,e.src),this.loaded.set(e.src,e),this}delete(r){return this._parseUrls(r).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(r,e={}){const{cancelOther:t,injectFontFace:i=!0,injectStyleTag:s=!0,...o}=e,{src:a}=r;if(this.loaded.has(a))return t&&(this.loading.forEach(p=>p.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,o),this.loading.set(a,l)),t&&this.loading.forEach((p,d)=>{p!==l&&(p.cancel(),this.loading.delete(d))}),l.when.then(p=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const d=f(p);return e.noAdd||this.loaded.set(r.src,d),d.familySet.forEach(m=>{this.familyToUrl.set(m,a),typeof document<"u"&&(i&&this.injectFontFace(m,p),s&&this.injectStyleTag(m,a))}),d}}).catch(p=>{if(p instanceof DOMException&&p.message==="The user aborted a request.")return f();throw p}).finally(()=>{this.loading.delete(a)});function h(){return r.family?Array.isArray(r.family)?r.family:[r.family]:[]}function c(p){return h().forEach(d=>{p.familySet.add(d)}),p}function f(p=new ArrayBuffer(0)){let d;function m(){return d||(d=p.byteLength?aa(p,!1):void 0),d}function v(){const y=m();if(y instanceof He||y instanceof Si)return y.sfnt}return{...r,buffer:p,familySet:new Set(h()),getFont:m,getSfnt:v}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(r=>r.when))}};u(Li,"defaultRequestInit",{cache:"force-cache"});let Mi=Li;const la=new Mi,hf=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:pi,get Cff(){return $t},get Cmap(){return lr},CmapSubtableFormat0:Bs,CmapSubtableFormat12:Fs,CmapSubtableFormat14:kr,CmapSubtableFormat2:Rr,CmapSubtableFormat4:Ns,CmapSubtableFormat6:Vt,FontDataObject:je,FontDataView:ve,Fonts:Mi,get Glyf(){return wi},Glyph:Ds,GlyphSet:Is,get Gpos(){return Vs},get Gsub(){return vt},get Head(){return pe},get Hhea(){return xe},get Hmtx(){return xi},get Kern(){return js},get Loca(){return Pi},get Maxp(){return be},get Name(){return hr},get Os2(){return $},get Post(){return Xe},Sfnt:Ft,TableDirectory:or,Ttf:He,get Vhea(){return Pe},get Vmtx(){return Ei},Woff:Si,WoffTableDirectoryEntry:Gt,createCmapSegments:ks,dataTypeToByteLength:Ur,defineColumn:_,defineSfntTable:we,fonts:la,parseFont:aa},Symbol.toStringTag,{value:"Module"}));function qs(n,r,e){if(typeof r=="string"&&r.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:o,stops:a}=cf(r,e.left,e.top,e.width,e.height),l=n.createLinearGradient(t,i,s,o);return a.forEach(h=>l.addColorStop(h.offset,h.color)),l}return r}function Ai(n,r,e){n!=null&&n.color&&(n.color=qs(e,n.color,r)),n!=null&&n.backgroundColor&&(n.backgroundColor=qs(e,n.backgroundColor,r)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=qs(e,n.textStrokeColor,r))}function cf(n,r,e,t,i){var d;const s=((d=n.match(/linear-gradient\((.+)\)$/))==null?void 0:d[1])??"",o=s.split(",")[0],a=o.includes("deg")?o:"0deg",l=s.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),c=(Number(a.replace("deg",""))||0)*Math.PI/180,f=t*Math.sin(c),p=i*Math.cos(c);return{x0:r+t/2-f,y0:e+i/2+p,x1:r+t/2+f,y1:e+i/2-p,stops:Array.from(l).map(m=>{let v=m[2];return v.startsWith("(")?v=v.split(",").length>3?`rgba${v}`:`rgb${v}`:v=`#${v}`,{offset:Number(m[3].replace("%",""))/100,color:v}})}}function $r(n){const{ctx:r,path:e,fontSize:t,clipRect:i}=n;r.save(),r.beginPath();const s=e.style,o={...s,fill:n.color??s.fill,stroke:n.textStrokeColor??s.stroke,strokeWidth:n.textStrokeWidth?n.textStrokeWidth*t:s.strokeWidth,shadowOffsetX:(n.shadowOffsetX??0)*t,shadowOffsetY:(n.shadowOffsetY??0)*t,shadowBlur:(n.shadowBlur??0)*t,shadowColor:n.shadowColor};i&&(r.rect(i.left,i.top,i.width,i.height),r.clip(),r.beginPath()),e.drawTo(r,o),r.restore()}function uf(n,r,e){const{left:t,top:i,width:s,height:o}=e,a=n.canvas;a.dataset.viewBox=`${t} ${i} ${s} ${o}`,a.dataset.pixelRatio=String(r);const l=s,h=o;a.width=Math.max(1,Math.ceil(l*r)),a.height=Math.max(1,Math.ceil(h*r)),a.style.width=`${l}px`,a.style.height=`${h}px`,n.clearRect(0,0,a.width,a.height),n.scale(r,r),n.translate(-t,-i)}function ff(n,r){const{paragraphs:e,computedStyle:t,glyphBox:i}=r;Ai(t,i,n),e.forEach(s=>{Ai(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{Ai(o.computedStyle,o.inlineBox,n)})})}const df=new Set(["©","®","÷"]),pf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),gf={1:"italic",32:"bold"},mf={1:"italic",2:"bold"},ha={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class yf{constructor(r,e,t){u(this,"path",new Ue);u(this,"lineBox",new Y);u(this,"inlineBox",new Y);u(this,"glyphBox");u(this,"advanceWidth",0);u(this,"advanceHeight",0);u(this,"underlinePosition",0);u(this,"underlineThickness",0);u(this,"strikeoutPosition",0);u(this,"strikeoutSize",0);u(this,"ascender",0);u(this,"descender",0);u(this,"typoAscender",0);u(this,"typoDescender",0);u(this,"typoLineGap",0);u(this,"winAscent",0);u(this,"winDescent",0);u(this,"xHeight",0);u(this,"capHeight",0);u(this,"baseline",0);u(this,"centerDiviation",0);u(this,"fontStyle");this.content=r,this.index=e,this.parent=t}get center(){var r;return(r=this.glyphBox)==null?void 0:r.center}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSfnt(r){const e=this.computedStyle.fontFamily,t=r??la,i=e?t.get(e):t.fallbackFont;return i==null?void 0:i.getSfnt()}updateGlyph(r=this._getFontSfnt()){if(!r)return this;const{hhea:e,os2:t,post:i,head:s}=r,o=s.unitsPerEm,a=e.ascent,l=e.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:p}=c,d=o/p,m=r.getAdvanceWidth(h,p),v=(a+Math.abs(l))/d,y=a/d;return this.advanceWidth=m,this.advanceHeight=v,this.inlineBox.width=f?v:m,this.inlineBox.height=f?m:v,this.underlinePosition=(a-i.underlinePosition)/d,this.underlineThickness=i.underlineThickness/d,this.strikeoutPosition=(a-t.yStrikeoutPosition)/d,this.strikeoutSize=t.yStrikeoutSize/d,this.ascender=a/d,this.descender=l/d,this.typoAscender=t.sTypoAscender/d,this.typoDescender=t.sTypoDescender/d,this.typoLineGap=t.sTypoLineGap/d,this.winAscent=t.usWinAscent/d,this.winDescent=t.usWinDescent/d,this.xHeight=t.sxHeight/d,this.capHeight=t.sCapHeight/d,this.baseline=y,this.centerDiviation=v/2-y,this.fontStyle=gf[t.fsSelection]??mf[s.macStyle],this}update(r){const e=this._getFontSfnt(r);if(!e)return this;this.updateGlyph(e);const{isVertical:t,content:i,computedStyle:s,baseline:o,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:p,advanceHeight:d}=this,{left:m,top:v}=a,y=s.fontStyle==="italic"&&f!=="italic";let S=m,C=v+o,x;const T=new Ue;if(t&&(S+=(d-p)/2,Math.abs(p-d)>.1&&(C-=(l-c)/(l+Math.abs(h))*d),x=void 0),t&&!df.has(i)&&(i.codePointAt(0)<=256||pf.has(i))){T.addCommands(e.getPathCommands(i,S,v+o-(d-p)/2,s.fontSize));const P={y:v-(d-p)/2+d/2,x:S+p/2};y&&this._italic(T,t?{x:P.x,y:v-(d-p)/2+o}:void 0),T.rotate(90,P)}else x!==void 0?(T.addCommands(e.glyphs.get(x).getPathCommands(S,C,s.fontSize)),y&&this._italic(T,t?{x:S+p/2,y:v+c/(l+Math.abs(h))*d}:void 0)):(T.addCommands(e.getPathCommands(i,S,C,s.fontSize)),y&&this._italic(T,t?{x:S+d/2,y:C}:void 0));const b=s.fontWeight??400;return b in ha&&(b===700||b==="bold")&&f!=="bold"&&T.bold(ha[b]*s.fontSize*.05),T.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=T,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(r,e){r.skew(-.24,0,e||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(r,e,t){var i;if((i=this.path.curves[0])!=null&&i.curves.length)return this.path.getMinMax(r,e,t)}getGlyphBoundingBox(r){const e=this.getGlyphMinMax(void 0,void 0,r);if(!e)return;const{min:t,max:i}=e;return new Y(t.x,t.y,i.x-t.x,i.y-t.y)}drawTo(r,e={}){const t=this.computedStyle,i={ctx:r,path:this.path,fontSize:t.fontSize,color:t.color,...e};if(this.glyphBox)$r(i);else{r.save(),r.beginPath();const s=this.path.style,o={...s,fill:i.color??s.fill,stroke:i.textStrokeColor??s.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:s.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};cs(r,o),r.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(r.textBaseline="middle",r.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(r.textBaseline="alphabetic",r.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),r.restore()}}}function Ws(n,r){return typeof n=="number"?n:n.endsWith("%")?(n=n.substring(0,n.length-1),Math.ceil(Number(n)/100*r.total)):n.endsWith("rem")?(n=n.substring(0,n.length-3),Number(n)*r.fontSize):n.endsWith("em")?(n=n.substring(0,n.length-2),Number(n)*r.fontSize):Number(n)}function ca(n){const r=At(n)?{}:n;return Object.keys(r).reduce((e,t)=>{let i=r[t];const s=ua(t),o=ua(i);return s&&(t=s),o&&(i=o),e[t]=i,e},{})}function At(n){return!n||n==="none"}function vf(n,r){const e=Object.keys(n),t=Object.keys(r);return Array.from(new Set([...e,...t])).every(s=>cr(n[s],r[s]))}function cr(n,r){const e=typeof n;return e===typeof r?e==="object"?vf(n,r):n===r:!1}function ua(n){const r=n.startsWith("#")?n.slice(1):n;if(!/^(?:[0-9A-F]{3}|[0-9A-F]{6})$/i.test(r))return null;const t=r.length===3?r.split("").map(a=>a+a).join(""):r,i=Number.parseInt(t.slice(0,2),16),s=Number.parseInt(t.slice(2,4),16),o=Number.parseInt(t.slice(4,6),16);return`rgb(${i}, ${s}, ${o})`}function Xs(n){if(!n)return n;const r={};for(const e in n)n[e]!==""&&n[e]!==void 0&&(r[e]=n[e]);return r}function Hs(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class _f{constructor(r,e={},t){u(this,"inlineBox",new Y);this.content=r,this.style=e,this.parent=t,this.updateComputedStyle().initCharacters()}get computedContent(){const r=this.computedStyle;return r.textTransform==="uppercase"?this.content.toUpperCase():r.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Xs(this.style)},this}initCharacters(){const r=[];let e=0;for(const t of this.computedContent)r.push(new yf(t,e++,this));return this.characters=r,this}}class zr{constructor(r,e){u(this,"lineBox",new Y);u(this,"fragments",[]);this.style=r,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Xs(this.parentStyle),...Xs(this.style)},this}addFragment(r,e){const t=new _f(r,e,this);return this.fragments.push(t),t}}function rp(n){return n}const dr=class dr{_styleToDomStyle(r){const e={};for(const t in r){const i=r[t];dr.notZeroStyles.has(t)&&i===0||(typeof i=="number"&&dr.pxStyles.has(t)?e[t]=`${i}px`:e[t]=i)}return e}createParagraphDom(r,e){const t=document.createDocumentFragment(),i=document.createElement("section"),s={...e},o=e.writingMode.includes("horizontal");switch(e.textAlign){case"start":case"left":s.justifyContent="start";break;case"center":s.justifyContent="center";break;case"end":case"right":s.justifyContent="end";break}switch(e.verticalAlign){case"top":s.alignItems="top";break;case"middle":s.alignItems="center";break;case"bottom":s.alignItems="end";break}const a=!!(s.justifyContent||s.alignItems);Object.assign(i.style,{boxSizing:"border-box",display:a?"inline-flex":void 0,width:"max-content",height:"max-content",whiteSpace:"pre-wrap",wordBreak:"break-all",...this._styleToDomStyle(s),position:"fixed",visibility:"hidden"});const l=document.createElement("ul");return Object.assign(l.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:a&&o?"100%":void 0,height:a&&!o?"100%":void 0}),r.forEach(h=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._styleToDomStyle(h.style)}),h.fragments.forEach(f=>{const p=document.createElement("span");Object.assign(p.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),p.appendChild(document.createTextNode(f.content)),c.appendChild(p)}),l.appendChild(c)}),i.appendChild(l),t.appendChild(i),document.body.appendChild(t),{dom:i,destory:()=>{var h;return(h=i.parentNode)==null?void 0:h.removeChild(i)}}}measureDomText(r){const e=document.createRange();e.selectNodeContents(r);const t=r.data??"";let i=0;return Array.from(t).map(s=>{var f;const o=i+=t.substring(i).indexOf(s),a=o+s.length;i+=s.length,e.setStart(r,Math.max(o,0)),e.setEnd(r,a);const l=((f=e.getClientRects)==null?void 0:f.call(e))??[e.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=e.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(r){const e=[],t=[],i=[];return r.querySelectorAll("li").forEach((s,o)=>{const a=s.getBoundingClientRect();e.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();t.push({paragraphIndex:o,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(p=>{i.push({...p,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(p=>{p.firstChild instanceof window.Text&&this.measureDomText(p.firstChild).forEach(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:e,fragments:t,characters:i}}measureParagraphDom(r,e){const t=e.getBoundingClientRect(),i=this.measureDom(e);i.paragraphs.forEach(a=>{const l=r[a.paragraphIndex];l.lineBox.left=a.left-t.left,l.lineBox.top=a.top-t.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=r[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-t.left,l.inlineBox.top=a.top-t.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-t.left,top:a.top-t.top});const f=r[l].fragments[h].characters[c],{fontHeight:p,isVertical:d}=f,m=s[o];f.inlineBox.left=m.left,f.inlineBox.top=m.top,f.inlineBox.width=m.width,f.inlineBox.height=m.height,d?(f.lineBox.left=m.left+(m.width-p)/2,f.lineBox.top=m.top,f.lineBox.width=p,f.lineBox.height=m.height):(f.lineBox.left=m.left,f.lineBox.top=m.top+(m.height-p)/2,f.lineBox.width=m.width,f.lineBox.height=p),o++}),{paragraphs:r,boundingBox:new Y(0,0,t.width,t.height)}}measure(r,e,t){let i;t||({dom:t,destory:i}=this.createParagraphDom(r,e));const s=this.measureParagraphDom(r,t);return i==null||i(),s}};u(dr,"notZeroStyles",new Set(["width","height"])),u(dr,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let Ys=dr;class bf{constructor(){u(this,"eventListeners",new Map)}addEventListener(r,e,t){const i={value:e,options:t},s=this.eventListeners.get(r);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(r,[s,i]):this.eventListeners.set(r,i),this}removeEventListener(r,e,t){var s,o;if(!e)return this.eventListeners.delete(r),this;const i=this.eventListeners.get(r);if(!i)return this;if(Array.isArray(i)){const a=[];for(let l=0,h=i.length;l<h;l++){const c=i[l];(c.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof c.options=="boolean"||!((s=c.options)!=null&&s.once)))&&a.push(c)}a.length?this.eventListeners.set(r,a.length===1?a[0]:a):this.eventListeners.delete(r)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(o=i.options)!=null&&o.once)&&this.eventListeners.delete(r);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(r){return this.eventListeners.has(r)}dispatchEvent(r,e){var i,s;const t=this.eventListeners.get(r);if(t){if(Array.isArray(t))for(let o=t.length,a=0;a<o;a++){const l=t[a];typeof l.options=="object"&&((i=l.options)!=null&&i.once)&&this.off(r,l.value,l.options),l.value.apply(this,[e])}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(r,t.value,t.options),t.value.apply(this,[e]);return!0}else return!1}on(r,e,t){return this.addEventListener(r,e,t)}once(r,e){return this.addEventListener(r,e,{once:!0})}off(r,e,t){return this.removeEventListener(r,e,t)}emit(r,e){this.dispatchEvent(r,e)}}function Zs(n){const{highlight:r,highlightImage:e,highlightReferImage:t,highlightColormap:i,highlightLine:s,highlightSize:o,highlightThickness:a}=n;return{image:(r==null?void 0:r.image)??e??"none",referImage:(r==null?void 0:r.referImage)??t??"none",colormap:(r==null?void 0:r.colormap)??i??"none",line:(r==null?void 0:r.line)??s??"none",size:(r==null?void 0:r.size)??o??"cover",thickness:(r==null?void 0:r.thickness)??a??"100%"}}function wf(){const n=[],r=[],e=new Map,t=new Map;async function i(o){if(!e.has(o)){e.set(o,o);try{e.set(o,await fetch(o).then(a=>a.text()))}catch(a){console.warn(a),e.delete(o)}}}function s(o){let a=t.get(o);if(!a){const l=go(Hs(o)?e.get(o)??o:o),h=bo(l);a={dom:l,pathSet:h},t.set(o,a)}return a}return{name:"highlight",paths:n,load:async o=>{const a=new Set;o.forEachCharacter(l=>{const{computedStyle:h}=l,{image:c,referImage:f}=Zs(h);Hs(c)&&a.add(c),Hs(f)&&a.add(f)}),await Promise.all(Array.from(a).map(l=>i(l)))},update:o=>{r.length=0,n.length=0;let a=[],l,h;o.forEachCharacter(c=>{const{computedStyle:f}=c,p=Zs(f),{image:d,colormap:m,line:v,size:y,thickness:S}=p;if(At(d))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:C,isVertical:x}=c,{fontSize:T}=f;(!h||cr(h.image,d)&&cr(h.colormap,m)&&cr(h.line,v)&&cr(h.size,y)&&cr(h.thickness,S))&&(l!=null&&l.length)&&(x?l[0].inlineBox.left===C.left:l[0].inlineBox.top===C.top)&&l[0].fontSize===T?l.push(c):(l=[],l.push(c),a.push(l))}h=p}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],p=f[0],d=Y.from(...f.filter(I=>I.glyphBox).map(I=>I.glyphBox)),{computedStyle:m}=p,{fontSize:v,writingMode:y}=m,{image:S,referImage:C,colormap:x,line:T,size:b,thickness:P}=Zs(m),E=y.includes("vertical"),w=Ws(P,{fontSize:v,total:d.width})/d.width,D=ca(x),{pathSet:F,dom:B}=s(S),U=F.getBoundingBox(!0),V=v/U.width*2,M=new Y().copy(d);E&&(M.width=d.height,M.height=d.width,M.left=d.left+d.width);const N=Math.floor(M.width);let q=N;if(b!=="cover"&&(q=Ws(b,{fontSize:v,total:d.width})||N,M.width=q),!At(C)&&At(T)){const I=s(C).pathSet.getBoundingBox(!0);U.copy(I)}else{let I;if(At(T))if(U.width/U.height>4){I="underline";const j=B.getAttribute("viewBox");if(j){const[k,L,K,X]=j.split(" ").map(G=>Number(G)),W=L+X/2;U.y<W&&U.y+U.height>W?I="line-through":U.y+U.height<W?I="overline":I="underline"}}else I="outline";else I=T;switch(I){case"outline":{const j=M.width*.2,k=M.height*.2;M.width+=j,M.height+=k,E?(M.x-=k/2,M.y-=j/2,M.x+=M.height):(M.x-=j/2,M.y-=k/2);break}case"overline":M.height=U.height*V,E?M.x=p.inlineBox.left+p.inlineBox.width:M.y=p.inlineBox.top;break;case"line-through":M.height=U.height*V,E?M.x=p.inlineBox.left+p.inlineBox.width-p.strikeoutPosition+M.height/2:M.y=p.inlineBox.top+p.strikeoutPosition-M.height/2;break;case"underline":M.height=U.height*V,E?M.x=p.inlineBox.left+p.inlineBox.width-p.underlinePosition:M.y=p.inlineBox.top+p.underlinePosition;break}}const R=new ke().translate(-U.x,-U.y).scale(M.width/U.width,M.height/U.height);E&&R.rotate(-Math.PI/2),R.translate(M.x,M.y);for(let I=0;I<Math.ceil(N/q);I++){const j=R.clone();E?j.translate(0,I*M.width):j.translate(I*M.width,0),F.paths.forEach(k=>{const L=k.clone().applyTransform(j);L.style.strokeWidth&&(L.style.strokeWidth*=V*w),L.style.strokeMiterlimit&&(L.style.strokeMiterlimit*=V),L.style.strokeDashoffset&&(L.style.strokeDashoffset*=V),L.style.strokeDasharray&&(L.style.strokeDasharray=L.style.strokeDasharray.map(K=>K*V)),L.style.fill&&L.style.fill in D&&(L.style.fill=D[L.style.fill]),L.style.stroke&&L.style.stroke in D&&(L.style.stroke=D[L.style.stroke]),n.push(L),N!==q&&(E?r[n.length-1]=new Y(d.left-d.width*2,d.top,d.width*4,d.height):r[n.length-1]=new Y(d.left,d.top-d.height*2,d.width,d.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if($r({ctx:o,path:l,fontSize:a.computedStyle.fontSize,clipRect:r[h]}),a.debug){const c=new vs([l]).getBoundingBox();c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function xf(n,r){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
<circle cx="${n}" cy="${n}" r="${n}" fill="${r}" />
|
|
32
|
+
</svg>`}function Pf(){const n=[];return{name:"listStyle",paths:n,update:r=>{n.length=0;const{paragraphs:e,isVertical:t,fontSize:i}=r,s=i*.45;e.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:p}=a,d=ca(c);let m=f,v;if(!At(h))v=h;else if(!At(p)){const x=i*.38/2;switch(m=m==="cover"?x*2:m,p){case"disc":v=xf(x,String(l));break}}if(!v)return;const y=bo(v),S=y.getBoundingBox();let C;o.fragments.forEach(x=>{x.characters.forEach(T=>{const{inlineBox:b}=T;if(t?(C==null?void 0:C.inlineBox.left)!==b.left:(C==null?void 0:C.inlineBox.top)!==b.top){C=T;const P=m==="cover"?1:Ws(m,{total:i,fontSize:i})/i,E=new ke;if(t){const w=i/S.height*P;E.translate(-S.left,-S.top).rotate(Math.PI/2).scale(w,w).translate(b.left+(b.width-S.height*w)/2,b.top-s)}else{const w=i/S.height*P;E.translate(-S.left,-S.top).scale(w,w).translate(b.left-S.width*w-s,b.top+(b.height-S.height*w)/2)}n.push(...y.paths.map(w=>{const D=w.clone();return D.applyTransform(E),D.style.fill&&D.style.fill in d&&(D.style.fill=d[D.style.fill]),D.style.stroke&&D.style.stroke in d&&(D.style.stroke=d[D.style.stroke]),D}))}})})})}}}const Ot=new O,ur=new ke,Ut=new ke;function Cf(){return{name:"render",getBoundingBox:n=>{const{characters:r,fontSize:e,effects:t}=n,i=[];return r.forEach(s=>{t==null||t.forEach(o=>{if(!s.glyphBox)return;const a=s.glyphBox.clone(),l=Ks(n,o);Ot.set(a.left,a.top),Ot.applyMatrix3(l),a.left=Ot.x,a.top=Ot.y,Ot.set(a.right,a.bottom),Ot.applyMatrix3(l),a.width=Ot.x-a.left,a.height=Ot.y-a.top;const h=(o.shadowOffsetX??0)*e,c=(o.shadowOffsetY??0)*e,f=Math.max(.1,o.textStrokeWidth??0)*e;a.left+=h-f,a.top+=c-f,a.width+=f*2,a.height+=f*2,i.push(a)})}),i.length?Y.from(...i):void 0},render:(n,r)=>{const{paragraphs:e,glyphBox:t,effects:i,style:s}=r;function o(a,l){n.fillStyle=a,n.fillRect(l.left,l.top,l.width,l.height)}s!=null&&s.backgroundColor&&o(s.backgroundColor,new Y(0,0,n.canvas.width,n.canvas.height)),e.forEach(a=>{var l;(l=a.style)!=null&&l.backgroundColor&&o(a.style.backgroundColor,a.lineBox)}),i?i.forEach(a=>{Ai(a,t,n),n.save();const[l,h,c,f,p,d]=Ks(r,a).transpose().elements;n.transform(l,f,h,p,c,d),r.forEachCharacter(m=>{var v;(v=m.parent.style)!=null&&v.backgroundColor&&o(m.parent.style.backgroundColor,m.inlineBox),m.drawTo(n,a)}),n.restore()}):e.forEach(a=>{a.fragments.forEach(l=>{var h;(h=l.style)!=null&&h.backgroundColor&&o(l.computedStyle.backgroundColor,l.inlineBox),l.characters.forEach(c=>{c.drawTo(n)})})}),r.debug&&e.forEach(a=>{n.strokeRect(a.lineBox.x,a.lineBox.y,a.lineBox.width,a.lineBox.height)})}}}function Ks(n,r){const{fontSize:e,glyphBox:t}=n,i=(r.translateX??0)*e,s=(r.translateY??0)*e,o=Math.PI*2,a=(r.skewX??0)/360*o,l=(r.skewY??0)/360*o,{left:h,top:c,width:f,height:p}=t,d=h+f/2,m=c+p/2;return ur.identity(),Ut.makeTranslation(i,s),ur.multiply(Ut),Ut.makeTranslation(d,m),ur.multiply(Ut),Ut.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),ur.multiply(Ut),Ut.makeTranslation(-d,-m),ur.multiply(Ut),ur.clone()}function Ef(){const n=[];return{name:"textDecoration",paths:n,update:r=>{n.length=0;const e=[];let t,i;r.forEachCharacter(s=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:p}=s,{color:d,textDecoration:m,writingMode:v}=o;if(At(m))i=void 0;else{let y=!1;if((i==null?void 0:i.textDecoration)===m&&(i==null?void 0:i.writingMode)===v&&(i==null?void 0:i.color)===d&&(a?t[0].inlineBox.left===l.left:t[0].inlineBox.top===l.top))switch(m){case"underline":t[0].underlinePosition===h&&t[0].underlineThickness===c&&(y=!0);break;case"line-through":t[0].strikeoutPosition===f&&t[0].strikeoutSize===p&&(y=!0);break}y?t.push(s):(t=[],t.push(s),e.push(t)),i=o}}),e.forEach(s=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=s[0],{color:p,textDecoration:d}=o,{left:m,top:v,width:y,height:S}=Y.from(...s.map(P=>P.inlineBox));let C=a?m+y:v;const x=a?-1:1;let T=0;switch(d){case"overline":T=h*2;break;case"underline":C+=x*l,T=h*2;break;case"line-through":C+=x*c,T=f*2;break}C-=T;let b;a?b=new Ue([{type:"M",x:C,y:v},{type:"L",x:C,y:v+S},{type:"L",x:C+T,y:v+S},{type:"L",x:C+T,y:v},{type:"Z"}],{fill:p}):b=new Ue([{type:"M",x:m,y:C},{type:"L",x:m+y,y:C},{type:"L",x:m+y,y:C+T},{type:"L",x:m,y:C+T},{type:"Z"}],{fill:p}),n.push(b)})},render:(r,e)=>{const{effects:t,computedStyle:i}=e;t?t.forEach(s=>{r.save();const[o,a,l,h,c,f]=Ks(e,s).transpose().elements;r.transform(o,h,a,c,l,f),n.forEach(p=>{$r({ctx:r,path:p,fontSize:i.fontSize,...s})}),r.restore()}):n.forEach(s=>{$r({ctx:r,path:s,fontSize:i.fontSize})})}}}const Js=gc();class Tf extends bf{constructor(e={}){super();u(this,"debug");u(this,"content");u(this,"style");u(this,"effects");u(this,"measureDom");u(this,"needsUpdate",!0);u(this,"computedStyle",{...Js});u(this,"paragraphs",[]);u(this,"lineBox",new Y);u(this,"rawGlyphBox",new Y);u(this,"glyphBox",new Y);u(this,"pathBox",new Y);u(this,"boundingBox",new Y);u(this,"measurer",new Ys);u(this,"plugins",new Map);u(this,"fonts");this.debug=e.debug??!1,this.content=e.content??"",this.style=e.style??{},this.measureDom=e.measureDom,this.effects=e.effects,this.fonts=e.fonts,this.use(Pf()).use(Ef()).use(wf()).use(Cf()),this.updateParagraphs()}get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,i)=>{t.fragments.forEach((s,o)=>{s.characters.forEach((a,l)=>{e(a,{paragraphIndex:i,fragmentIndex:o,characterIndex:l})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>{var t;return(t=e.load)==null?void 0:t.call(e,this)}))}updateParagraphs(){this.computedStyle={...Js,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new zr({},t);s.addFragment(e),i.push(s)}else{e=Array.isArray(e)?e:[e];for(const s of e)if(typeof s=="string"){const o=new zr({},t);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new zr({},t);s.forEach(a=>{if(typeof a=="string")o.addFragment(a);else{const{content:l,...h}=a;l!==void 0&&o.addFragment(l,h)}}),i.push(o)}else if("fragments"in s){const{fragments:o,...a}=s,l=new zr(a,t);o.forEach(h=>{const{content:c,...f}=h;c!==void 0&&l.addFragment(c,f)}),i.push(l)}else if("content"in s){const{content:o,...a}=s;if(o!==void 0){const l=new zr(a,t);l.addFragment(o),i.push(l)}}}return this.paragraphs=i,this}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const i=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=i.paragraphs,this.lineBox=i.boundingBox,this.characters.forEach(s=>{s.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((s,o)=>(s.updateOrder??0)-(o.updateOrder??0)).forEach(s=>{var o;(o=s.update)==null||o.call(s,this)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const s in t)i[s]=this[s],this[s]=t[s];return this.emit("measure",{text:this,result:i}),i}getGlyphBox(){const e=O.MAX,t=O.MIN;return this.characters.forEach(i=>{if(!i.getGlyphMinMax(e,t)){const{inlineBox:s}=i,o=new O(s.left,s.top),a=new O(s.left+s.width,s.top+s.height);e.min(o,a),t.max(o,a)}}),new Y(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Y.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):new vs(e.paths??[]).getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){const{lineBox:e,rawGlyphBox:t,pathBox:i}=this,s=Math.min(i.left,i.left+e.left-t.left),o=Math.min(i.top,i.top+e.top-t.top),a=Math.max(i.right,i.right+e.right-t.right),l=Math.max(i.bottom,i.bottom+e.bottom-t.bottom);return this.boundingBox=new Y(s,o,a-s,l-o),this}requestUpdate(){return this.needsUpdate=!0,this}update(){const e=this.measure();for(const t in e)this[t]=e[t];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(e){const{view:t,pixelRatio:i=2}=e,s=t.getContext("2d");s&&(this.needsUpdate&&this.update(),uf(s,i,this.boundingBox),ff(s,this),Array.from(this.plugins.values()).sort((o,a)=>(o.renderOrder??0)-(a.renderOrder??0)).forEach(o=>{var a;if(o.render)(a=o.render)==null||a.call(o,s,this);else if(o.paths){const l=this.computedStyle;o.paths.forEach(h=>{$r({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Sf=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,qt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Sf(r,e,i),i};const Af=new Set(Object.keys(Js));g.Text2D=class extends g.Node2D{constructor(e){super();u(this,"effects");u(this,"measureDom");u(this,"fonts");u(this,"text",new Tf);u(this,"texture",new de(document.createElement("canvas")));u(this,"_subTextsCount",0);this.setProperties(e)}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"content":case"effects":case"measureDom":case"fonts":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&e==="effects"&&this._getSubTexts().forEach(s=>{s.setProperties({[e]:t})})}_updateText(){this.text.style=this.style.toJSON(),this.text.content=this.content??"",this.text.effects=this.effects,this.text.fonts=this.fonts,this.text.measureDom=this.measureDom}_onUpdateStyleProperty(e,t,i){if(e!=="height"){switch(super._onUpdateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&Af.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}}_getSubTexts(){return this.getChildren(yr.FRONT).filter(e=>e instanceof g.Text2D)}_updateSubTexts(){const e=this._getSubTexts(),t=this.measure();let i=0;this.split&&t.paragraphs.forEach(s=>{s.fragments.forEach(o=>{o.characters.forEach(a=>{const l=e[i];l&&(l.style.left=a.inlineBox.left,l.style.top=a.inlineBox.top),i++})})})}measure(){this._updateText();const e=this.text.measure();return this.style.width||(this.style.width=e.boundingBox.width),this.style.height||(this.style.height=e.boundingBox.height),e}_updateSplit(){this._subTextsCount&&(this.getChildren(yr.FRONT).forEach(t=>this.removeChild(t)),this._subTextsCount=0);const e=this.measure();this.split&&e.paragraphs.forEach(t=>{t.fragments.forEach(i=>{i.characters.forEach(s=>{this.addChild(new g.Text2D({pixelRatio:this.pixelRatio,content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),yr.FRONT),this._subTextsCount++})})})}_drawContent(){var e,t;if(!this.split){const i=(t=(e=this.children)==null?void 0:e.find(s=>"onText2DRender"in s))==null?void 0:t.onText2DRender;i?i():(this._updateText(),this.text.render({pixelRatio:this.pixelRatio,view:this.texture.source})),this.texture.requestUpload(),this.context.fillStyle=this.texture,this.context.textureTransform=new qe().scale(1/this.pixelRatio,1/this.pixelRatio),super._drawContent()}}},qt([A({default:2})],g.Text2D.prototype,"pixelRatio",2),qt([A({default:!1})],g.Text2D.prototype,"split",2),qt([A({default:""})],g.Text2D.prototype,"content",2),qt([A()],g.Text2D.prototype,"effects",2),qt([ee()],g.Text2D.prototype,"measureDom",2),qt([ee()],g.Text2D.prototype,"fonts",2),g.Text2D=qt([H("Text2D")],g.Text2D);var Of=Object.defineProperty,Uf=Object.getOwnPropertyDescriptor,fa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Uf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Of(r,e,i),i};g.Video2D=class extends g.Node2D{constructor(e){super();u(this,"texture");u(this,"_wait",Promise.resolve());this.setProperties(e)}get duration(){var e;return(((e=this.texture)==null?void 0:e.duration)??0)*1e3}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await mt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_drawContent(){const e=this.texture;e&&(this.context.fillStyle=e,this.context.textureTransform=new qe().scale(this.style.width/e.width,this.style.height/e.height)),super._drawContent()}_updateVideoCurrentTime(){let e=this.visibleRelativeTime;if(e<0)return;const t=this.texture;if(!t)return;const i=t.duration;e=i?e%(i*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},fa([A({default:""})],g.Video2D.prototype,"src",2),g.Video2D=fa([H("Video2D")],g.Video2D);const ki=class ki extends dt{constructor(){super(...arguments);u(this,"playbackRate",1);u(this,"muted",!1);u(this,"volume",1);u(this,"paused",!1)}static get instance(){return this._instance||(this._instance=new ki),this._instance}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}};u(ki,"_instance");let Oi=ki;const Xr=class Xr extends dt{constructor(){super(...arguments);u(this,"_source",null);u(this,"_audio",null);u(this,"_end",0);u(this,"_pausedReal",!1);u(this,"_duration",0);u(this,"_start",0);u(this,"_playing",!1);u(this,"_paused",!1);u(this,"_playbackRate",1);u(this,"_volume",1);u(this,"_loop",!1);u(this,"_muted",!1);u(this,"_onUpdate",()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())})}get progress(){var e;return(((e=this._source)==null?void 0:e.currentTime)??0)/this._duration}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const i=e.volume*(e.muted?0:1),s=t.volume*(t.muted?0:1),o=this._volume*(this._muted?0:1);this._source.volume=o*i*s,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:i=0}=e;i&&console.assert(i>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&i!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=i||this._duration,this._start=Math.max(0,this._start-Xr.PADDING),this._end=Math.min(this._end+Xr.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),ue.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){ue.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){ue.off(this._onUpdate),this.removeAllListeners();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}};u(Xr,"PADDING",.1);let Ui=Xr;class da{constructor(r){u(this,"source",new globalThis.Audio);u(this,"_src","");this.parent=r}get src(){return this._src}set src(r){this._src!==r&&(this._src=r,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return Oi.instance}async load(){return new Promise(r=>{this.source.onload=()=>r(this),this.source.src=this._src,this.source.load()})}createSound(){return new Ui}}class Qs extends dt{constructor(e,t){super();u(this,"_processers",[]);this._input=e,this._output=t}get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(i=>{t?t.connect(i.destination):this._input.connect(i.destination),t=i}),t.connect(this._output)}}get destination(){return this._input}}class Df{constructor(r,e=null){this.destination=r,this.source=e}connect(r){var e;(e=this.source)==null||e.connect(r)}disconnect(){var r;(r=this.source)==null||r.disconnect()}}function If(){if(Gi)return new AudioContext;if(qi){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function Rf(n,r,e){if(Wi)return new OfflineAudioContext(n,r,e);if(mn){const t=globalThis.webkitOfflineAudioContext;return new t(n,r,e)}else throw new Error("Failed to createOfflineAudioContext")}const Ni=class Ni extends Qs{constructor(){const e=If(),t=Rf(1,2,Wi?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),i=e.createDynamicsCompressor(),s=e.createAnalyser();s.connect(i),i.connect(e.destination);super(s,i);u(this,"_context");u(this,"_offlineContext");u(this,"_locked");u(this,"muted",!1);u(this,"volume",1);u(this,"playbackRate",1);u(this,"autoPause",!0);u(this,"_paused",!1);u(this,"_pausedOnBlur",!1);u(this,"_compressor");u(this,"_analyser");u(this,"_unlock",()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))});this._context=e,this._offlineContext=t,this._compressor=i,this._analyser=s,this._locked=e.state==="suspended"&&(ft||gn),mr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}static get instance(){return this._instance||(this._instance=new Ni),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}get audioContext(){return this._context}get offlineContext(){return this._offlineContext}get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,i)=>{const s=a=>{i(new Error((a==null?void 0:a.message)||"Unable to decode file"))},o=this._offlineContext.decodeAudioData(e,t,s);o&&o.catch(s)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}};u(Ni,"_instance");let Dt=Ni;class pa extends dt{constructor(){super(...arguments);u(this,"_audio",null);u(this,"_sourceNode",null);u(this,"_gain",null);u(this,"_progress",0);u(this,"_pausedReal",!1);u(this,"_paused",!1);u(this,"_volume",1);u(this,"_playbackRate",1);u(this,"_loop",!1);u(this,"_muted",!1);u(this,"_duration",0);u(this,"_end",0);u(this,"_elapsed",0);u(this,"_lastUpdate",this._now());u(this,"_processors",[]);u(this,"_onComplete",()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)});u(this,"_updateListener",()=>this._update())}get progress(){return this._progress}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){var e;return((e=this._audio)==null?void 0:e.context.audioContext.currentTime)??0}play(e={}){var a;if(!this._audio)return;const{end:t=0,start:i=0}=e;t&&console.assert(t>i,"End time is before start time"),this._end=t,this._elapsed=i,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:s,gain:o}=this._audio.cloneSource();this._sourceNode=s,this._gain=o,this.refresh(),s.onended=this._onComplete.bind(this),this._duration=((a=s.buffer)==null?void 0:a.duration)??0,this._lastUpdate=this._now(),this._loop?(s.loopStart=i,s.loopEnd=t,s.start(0,i)):t?s.start(0,i,t-i):s.start(0,i),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),i=t-this._lastUpdate;if(i>0||e){this._elapsed+=i*this._sourceNode.playbackRate.value,this._lastUpdate=t;const s=this._duration;let o;if(this._sourceNode.loopStart){const a=this._sourceNode.loopEnd-this._sourceNode.loopStart;o=(this._sourceNode.loopStart+this._elapsed%a)/s}else o=this._elapsed%s/s;this._progress=o,this.emit("progress",o,s)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_enableTicker(e){ue.off(this._updateListener),e&&ue.on(this._updateListener)}destroy(){var e,t,i;this.removeAllListeners(),this._stop(),(e=this._gain)==null||e.disconnect(),this._gain=null,(t=this._audio)==null||t.context.off("refresh",this.refresh),(i=this._audio)==null||i.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(s=>s.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class ga extends Qs{constructor(e){const t=Dt.audioContext,i=t.createBufferSource(),s=t.createGain(),o=t.createAnalyser();i.connect(o),o.connect(s),s.connect(Dt.instance.destination);super(o,s);u(this,"_sourceBuffer");u(this,"_sourceNode");u(this,"_sourceLoad");u(this,"gain");u(this,"analyser");this.parent=e,this._sourceNode=i,this.gain=s,this.analyser=o}get context(){return Dt.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){var e;return((e=this._sourceNode.buffer)==null?void 0:e.duration)??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(i=>i.arrayBuffer()).then(i=>this._decode(i)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:Dt.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,i=e.audioContext.createBufferSource(),s=e.audioContext.createGain();return i.buffer=t.buffer,i.loop=t.loop,e.setParamValue(i.playbackRate,t.playbackRate.value),i.connect(s),s.connect(this.destination),{source:i,gain:s}}createSound(){return new pa}}var ma=Object.defineProperty,Bf=Object.getOwnPropertyDescriptor,Lf=(n,r,e)=>r in n?ma(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,kf=(n,r,e,t)=>{for(var i=t>1?void 0:t?Bf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ma(r,e,i),i},Nf=(n,r,e)=>Lf(n,r+"",e);g.Audio=class extends g.Node{constructor(e=""){super();u(this,"_sounds",[]);u(this,"_platformAudio",yn?new ga(this):new da(this));u(this,"_src");u(this,"isLoaded",!1);u(this,"_volume",1);u(this,"_muted",!1);u(this,"_loop",!1);u(this,"_playbackRate",1);u(this,"_isPlaying",!1);u(this,"_paused",!1);u(this,"multiple",!1);u(this,"start",0);u(this,"end",0);u(this,"_onComplete",e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)});u(this,"_prevTime",0);u(this,"_timer",0);this.src=e}get platformAudio(){return this._platformAudio}get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get duration(){return this._platformAudio.duration*1e3}get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}get isPlaying(){return this._isPlaying}get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{var o;(o=e.complete)==null||o.call(e),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const i=((e==null?void 0:e.start)??this.start)/1e3,s=((e==null?void 0:e.end)??this.end)/1e3;return t.play({...e,start:i,end:s}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return g.Audio._soundPool.length>0?g.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_recycleSound(e){e.destroy(),g.Audio._soundPool.includes(e)||g.Audio._soundPool.push(e)}_process(e){var t;if(super._process(e),this.isRenderable()){const i=((t=this._tree)==null?void 0:t.timeline.current)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.visibleDelay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Nf(g.Audio,"_soundPool",[]),g.Audio=kf([H("Audio")],g.Audio);class Ff extends g.Node2D{}var $f=Object.defineProperty,zf=Object.getOwnPropertyDescriptor,Di=(n,r,e,t)=>{for(var i=t>1?void 0:t?zf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&$f(r,e,i),i};g.AudioWaveform=class extends g.Node2D{constructor(e={}){super();u(this,"src");u(this,"gap",0);u(this,"color","#000000");u(this,"_audioBuffer");u(this,"_src",mr?new de(document.createElement("canvas")):void 0);u(this,"_needsUpdateTexture",!1);this.setProperties(e)}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>Dt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){var f,p;const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(f=this._src)==null?void 0:f.source;if(!i)return;const{width:s=0,height:o=0}=this.style;i.width=s,i.height=o;const a=i.getContext("2d");if(!a){console.warn("Failed to getContext('2d') in syncTexture");return}a.fillStyle=this.color;const l=t.getChannelData(0),h=Math.ceil(l.length/s),c=o/2;for(let d=1,m=-1,v=0;v<s;v++){for(let y=0;y<h;y++){const S=l[v*h+y];S<d&&(d=S),S>m&&(m=S)}if(!this.gap||v%(this.gap*2)===0){const y=v,S=(1+d)*c,C=this.gap||1,x=Math.max(1,(m-d)*c);a.fillRect(y,S,C,x),d=1,m=-1}}(p=this._src)==null||p.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new qe().scale(this.style.width/e.width,this.style.height/e.height))}},Di([A()],g.AudioWaveform.prototype,"src",2),Di([A()],g.AudioWaveform.prototype,"gap",2),Di([A()],g.AudioWaveform.prototype,"color",2),g.AudioWaveform=Di([H("AudioWaveform")],g.AudioWaveform);const Vf=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,jf=/vec(\d)\((.*)\)/;function Gf(n){n=n.trim();const r=n.match(jf);if(r){const e=Array.from({length:Number(r[1])},()=>0);return r[2].split(",").forEach((t,i)=>{e[i]=Number(t.trim())}),e}return Number(n)}const Hr=class Hr extends ne{constructor(e){super();u(this,"vert",`attribute vec2 position;
|
|
33
33
|
attribute vec2 uv;
|
|
34
34
|
varying vec2 vUv;
|
|
35
35
|
void main() {
|
|
36
36
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
37
37
|
vUv = uv;
|
|
38
|
-
}`);
|
|
38
|
+
}`);u(this,"uniforms",new Map([["ratio",0],["from",0],["to",1],["progress",0]]));u(this,"has",{getColor:!1,getFromColor:!1,getToColor:!1,transform:!1,transition:!1});const t=this.has;for(const s in Hr.RE)t[s]=Hr.RE[s].test(e);this.frag=`precision highp float;
|
|
39
39
|
varying vec2 vUv;
|
|
40
40
|
uniform float ratio;
|
|
41
41
|
uniform float progress;
|
|
42
|
-
${
|
|
43
|
-
uniform sampler2D from;`:""}${
|
|
42
|
+
${t.getColor||t.getFromColor||t.getToColor?`
|
|
43
|
+
uniform sampler2D from;`:""}${t.getFromColor||t.getToColor?`
|
|
44
44
|
uniform sampler2D to;`:""}
|
|
45
|
-
${
|
|
46
|
-
vec4 getColor(vec2 uv) { return texture2D(from, uv); }`:""}${
|
|
45
|
+
${t.getColor?`
|
|
46
|
+
vec4 getColor(vec2 uv) { return texture2D(from, uv); }`:""}${t.getFromColor||t.getToColor?`
|
|
47
47
|
vec4 getFromColor(vec2 uv) { return texture2D(from, uv); }
|
|
48
48
|
vec4 getToColor(vec2 uv) { return texture2D(to, uv); }`:""}
|
|
49
|
-
${
|
|
50
|
-
void main(void) { gl_FragColor = transform(vUv); }`:
|
|
51
|
-
void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=
|
|
49
|
+
${e}${t.transform?`
|
|
50
|
+
void main(void) { gl_FragColor = transform(vUv); }`:t.transition?`
|
|
51
|
+
void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=e.matchAll(Vf);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),Gf(s[2]))})}};u(Hr,"RE",{getColor:/\sgetColor\s*\(/,getFromColor:/\sgetFromColor\s*\(/,getToColor:/\sgetToColor\s*\(/,transform:/\stransform\s*\(/,transition:/\stransition\s*\(/});let Ii=Hr;var qf=Object.defineProperty,Wf=Object.getOwnPropertyDescriptor,Wt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Wf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&qf(r,e,i),i};g.Effect=class extends g.Node{constructor(e){super();u(this,"material");u(this,"mode");u(this,"viewport",new g.Viewport);u(this,"viewport2",new g.Viewport);u(this,"_renderId",0);u(this,"_renderViewport");u(this,"_previousSibling");u(this,"_nextSibling");u(this,"_onProcessing",()=>{switch(this._updateVisibility(),this._mode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}});u(this,"_onNodeProcessed",e=>{var i;if(!this.isRenderable())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._mode){case"transition":e.is(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.is(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}});this.setProperties(e)}get _mode(){return this.mode??"parent"}_onUpdateProperty(e,t,i){switch(super._onUpdateProperty(e,t,i),e){case"glsl":{const s=new Ii(t);!this.mode&&s.has.transition&&(this.mode="transition"),this.material=s;break}case"glslSrc":{t?mt.text.load(t).then(s=>this.glsl=s):this.glsl="";break}}}_enterTree(){const e=this._tree;e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport._setTree(e),this.viewport2._setTree(e)}_exitTree(){const e=this._tree;e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport._setTree(void 0),this.viewport2._setTree(void 0)}_processParent(){var a,l;const e=(a=this._tree)==null?void 0:a.renderStack;if(!e)return;const t=(l=e.currentCall)==null?void 0:l.parentCall;if(!t)return;const i=t.calls;let s,o;i.forEach((h,c)=>{var f;(h.renderable.is(this._parent)||(f=h.renderable.parent)!=null&&f.is(this._parent))&&(s=s??c,o=c)}),!(s===void 0||o===void 0)&&(i.splice(o+1,0,e.createCall(this)),i.splice(s,0,e.createCall(this)))}_processChildren(){var e;this._children.length&&(super.emit("process"),(e=this._tree)==null||e.renderStack.push(this))}_onProcess(e=0){switch(this._renderId=0,this._mode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){var i;const t=(i=this._tree)==null?void 0:i.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&(this.viewport.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(e),e.clear(),this.viewport.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&this.viewport.resize(this._renderViewport.width,this._renderViewport.height),this.viewport.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport.activate(e),this.apply(e,this.viewport,{redraw:!0,target:this._mode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport.texture.activate(e,0),te.draw(e))}}_parseTargetArea(){if(this._mode==="parent"&&this._parent instanceof g.Node2D){const e=this._parent.getBoundingBox();return[e.left/this.viewport.width,e.top/this.viewport.height,e.width/this.viewport.width,e.height/this.viewport.height]}}_render(e){switch(this._mode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,i){this.material&&(i!=null&&i.redraw?t.redraw(e,()=>{te.draw(e,this.material,{from:0,to:1,progress:this.visibleProgress,ratio:t.width/t.height})}):te.draw(e,this.material,{from:0,to:1,progress:this.visibleProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Wt([ee()],g.Effect.prototype,"material",2),Wt([A()],g.Effect.prototype,"mode",2),Wt([A({default:""})],g.Effect.prototype,"glsl",2),Wt([A({default:""})],g.Effect.prototype,"glslSrc",2),Wt([A({alias:"visibleDelay"})],g.Effect.prototype,"delay",2),Wt([A({alias:"visibleDuration"})],g.Effect.prototype,"duration",2),g.Effect=Wt([H({tag:"Effect",renderable:!0})],g.Effect);var ya=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,Hf=(n,r,e)=>r in n?ya(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,en=(n,r,e,t)=>{for(var i=t>1?void 0:t?Xf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ya(r,e,i),i},va=(n,r,e)=>Hf(n,typeof r!="symbol"?r+"":r,e);const Yf=`attribute vec2 position;
|
|
52
52
|
attribute vec2 uv;
|
|
53
53
|
varying vec2 vUv[9];
|
|
54
54
|
uniform float strength;
|
|
@@ -64,7 +64,7 @@ void main(void) {
|
|
|
64
64
|
vUv[6] = uv + vec2(2.0 * strength, 0.0);
|
|
65
65
|
vUv[7] = uv + vec2(3.0 * strength, 0.0);
|
|
66
66
|
vUv[8] = uv + vec2(4.0 * strength, 0.0);
|
|
67
|
-
}`,
|
|
67
|
+
}`,Zf=`attribute vec2 position;
|
|
68
68
|
attribute vec2 uv;
|
|
69
69
|
uniform float strength;
|
|
70
70
|
varying vec2 vUv[9];
|
|
@@ -80,7 +80,7 @@ void main(void) {
|
|
|
80
80
|
vUv[6] = uv + vec2(0.0, 2.0 * strength);
|
|
81
81
|
vUv[7] = uv + vec2(0.0, 3.0 * strength);
|
|
82
82
|
vUv[8] = uv + vec2(0.0, 4.0 * strength);
|
|
83
|
-
}`,
|
|
83
|
+
}`,_a=`varying vec2 vUv[9];
|
|
84
84
|
uniform sampler2D sampler;
|
|
85
85
|
|
|
86
86
|
void main(void) {
|
|
@@ -114,7 +114,7 @@ void main(void) {
|
|
|
114
114
|
gl_FragColor += texture2D(sampler, vUv[7]) * 0.067234;
|
|
115
115
|
gl_FragColor += texture2D(sampler, vUv[8]) * 0.028532;
|
|
116
116
|
}
|
|
117
|
-
}`;g.BlurEffect=class extends g.Effect{apply(e
|
|
117
|
+
}`;g.BlurEffect=class extends g.Effect{apply(r,e){e.redraw(r,()=>{te.draw(r,g.BlurEffect.materialX,{sampler:0,strength:1/e.width*this.strength/this.quality})}),e.redraw(r,()=>{te.draw(r,g.BlurEffect.materialY,{sampler:0,strength:1/e.height*this.strength/this.quality})})}},va(g.BlurEffect,"materialX",new ne({vert:Yf,frag:_a})),va(g.BlurEffect,"materialY",new ne({vert:Zf,frag:_a})),en([A({default:8})],g.BlurEffect.prototype,"strength",2),en([A({default:4})],g.BlurEffect.prototype,"quality",2),g.BlurEffect=en([H("BlurEffect")],g.BlurEffect);var ba=Object.defineProperty,Kf=Object.getOwnPropertyDescriptor,Jf=(n,r,e)=>r in n?ba(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,_t=(n,r,e,t)=>{for(var i=t>1?void 0:t?Kf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ba(r,e,i),i},Qf=(n,r,e)=>Jf(n,r+"",e);g.ColorAdjustEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"saturation",1);u(this,"contrast",1);u(this,"brightness",1);u(this,"red",1);u(this,"green",1);u(this,"blue",1);u(this,"alpha",1);u(this,"gamma",1)}apply(e,t){t.redraw(e,()=>{te.draw(e,g.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Qf(g.ColorAdjustEffect,"material",new ne({vert:`precision mediump float;
|
|
118
118
|
attribute vec2 position;
|
|
119
119
|
attribute vec2 uv;
|
|
120
120
|
varying vec2 vUv;
|
|
@@ -145,7 +145,7 @@ void main(void) {
|
|
|
145
145
|
c.rgb *= c.a;
|
|
146
146
|
}
|
|
147
147
|
gl_FragColor = c * alpha;
|
|
148
|
-
}`})),
|
|
148
|
+
}`})),_t([A()],g.ColorAdjustEffect.prototype,"saturation",2),_t([A()],g.ColorAdjustEffect.prototype,"contrast",2),_t([A()],g.ColorAdjustEffect.prototype,"brightness",2),_t([A()],g.ColorAdjustEffect.prototype,"red",2),_t([A()],g.ColorAdjustEffect.prototype,"green",2),_t([A()],g.ColorAdjustEffect.prototype,"blue",2),_t([A()],g.ColorAdjustEffect.prototype,"alpha",2),_t([A()],g.ColorAdjustEffect.prototype,"gamma",2),g.ColorAdjustEffect=_t([H("ColorAdjustEffect")],g.ColorAdjustEffect);var wa=Object.defineProperty,ed=Object.getOwnPropertyDescriptor,td=(n,r,e)=>r in n?wa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,xa=(n,r,e,t)=>{for(var i=t>1?void 0:t?ed(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&wa(r,e,i),i},rd=(n,r,e)=>td(n,r+"",e);g.ColorFilterEffect=class extends g.Effect{constructor(e){super();u(this,"_colorMatrix",new os);this.setProperties(e)}apply(e,t){if(!this.filter)return;const i=gr(this.filter),s=this._colorMatrix.identity();i.forEach(({name:o,args:a})=>{const l=a.map(h=>h.normalizedIntValue);switch(o){case"hue-rotate":case"hueRotate":s.hueRotate(l[0]*le);break;case"saturate":s.saturate(l[0]);break;case"brightness":s.brightness(l[0]);break;case"contrast":s.contrast(l[0]);break;case"invert":s.invert(l[0]);break;case"sepia":s.sepia(l[0]);break;case"opacity":s.opacity(l[0]);break;case"grayscale":s.grayscale(l[0]);break}}),t.redraw(e,()=>{te.draw(e,g.ColorFilterEffect.material,{sampler:0,m:s.toArray()})})}},rd(g.ColorFilterEffect,"material",new ne({vert:`precision mediump float;
|
|
149
149
|
attribute vec2 position;
|
|
150
150
|
attribute vec2 uv;
|
|
151
151
|
varying vec2 vUv;
|
|
@@ -168,7 +168,7 @@ void main(void) {
|
|
|
168
168
|
m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14] / 255.0,
|
|
169
169
|
m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19] / 255.0
|
|
170
170
|
);
|
|
171
|
-
}`})),
|
|
171
|
+
}`})),xa([A({default:""})],g.ColorFilterEffect.prototype,"filter",2),g.ColorFilterEffect=xa([H("ColorFilterEffect")],g.ColorFilterEffect);var Pa=Object.defineProperty,id=Object.getOwnPropertyDescriptor,sd=(n,r,e)=>r in n?Pa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,tn=(n,r,e,t)=>{for(var i=t>1?void 0:t?id(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Pa(r,e,i),i},nd=(n,r,e)=>sd(n,r+"",e);const Vr=50;g.ColorOverlayEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"alpha",.5);u(this,"_color",new Pt)}apply(e,t){t.redraw(e,()=>{const i=this.colors.map(s=>{this._color.value=s;const o=this._color.toArray();return o[3]=this.alpha,o});for(;i.length<Vr;)i.push([0,0,0,0]);te.draw(e,g.ColorOverlayEffect.material,{sampler:0,colors:i.slice(0,Vr).flatMap(s=>s)})})}},nd(g.ColorOverlayEffect,"material",new ne({vert:`precision mediump float;
|
|
172
172
|
attribute vec2 position;
|
|
173
173
|
attribute vec2 uv;
|
|
174
174
|
varying vec2 vUv;
|
|
@@ -177,7 +177,7 @@ void main() {
|
|
|
177
177
|
vUv = uv;
|
|
178
178
|
}`,frag:`precision mediump float;
|
|
179
179
|
uniform sampler2D sampler;
|
|
180
|
-
uniform vec4 colors[${
|
|
180
|
+
uniform vec4 colors[${Vr}];
|
|
181
181
|
varying vec2 vUv;
|
|
182
182
|
|
|
183
183
|
float calcWidth() {
|
|
@@ -186,7 +186,7 @@ float calcWidth() {
|
|
|
186
186
|
|
|
187
187
|
int calcCount() {
|
|
188
188
|
int count = 0;
|
|
189
|
-
for (int i = 0; i < ${
|
|
189
|
+
for (int i = 0; i < ${Vr}; i++) {
|
|
190
190
|
if (colors[i] != vec4(0,0,0,0)){
|
|
191
191
|
count++;
|
|
192
192
|
}
|
|
@@ -198,7 +198,7 @@ vec4 calcColor(float x) {
|
|
|
198
198
|
float perUnit = calcWidth() / float(calcCount());
|
|
199
199
|
int index = int(x / perUnit);
|
|
200
200
|
|
|
201
|
-
for(int i=0; i<${
|
|
201
|
+
for(int i=0; i<${Vr}; i++){
|
|
202
202
|
if(i==index){
|
|
203
203
|
return colors[i];
|
|
204
204
|
}
|
|
@@ -211,7 +211,7 @@ void main(void) {
|
|
|
211
211
|
vec4 color = texture2D(sampler, vUv);
|
|
212
212
|
vec4 mask = calcColor(vUv.x);
|
|
213
213
|
gl_FragColor = vec4(mix(color.rgb, mask.rgb, color.a * mask.a), color.a);
|
|
214
|
-
}`})),
|
|
214
|
+
}`})),tn([A()],g.ColorOverlayEffect.prototype,"colors",2),tn([A()],g.ColorOverlayEffect.prototype,"alpha",2),g.ColorOverlayEffect=tn([H("ColorOverlayEffect")],g.ColorOverlayEffect);var Ca=Object.defineProperty,od=Object.getOwnPropertyDescriptor,ad=(n,r,e)=>r in n?Ca(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,rn=(n,r,e,t)=>{for(var i=t>1?void 0:t?od(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ca(r,e,i),i},ld=(n,r,e)=>ad(n,r+"",e);g.ColorRemoveEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.5);u(this,"_color",new Pt)}apply(e,t){const s=new Float32Array(150),o=this.colors.map(a=>(this._color.value=a,this._color.toArray().slice(0,3)));for(;o.length<50;)o.push([-1,0,0]);o.slice(0,50).forEach((a,l)=>{s[l*3]=a[0],s[l*3+1]=a[1],s[l*3+2]=a[2]}),t.redraw(e,()=>{te.draw(e,g.ColorRemoveEffect.material,{sampler:0,epsilon:this.epsilon,originalColors:s})})}},ld(g.ColorRemoveEffect,"material",new ne({vert:`precision mediump float;
|
|
215
215
|
attribute vec2 position;
|
|
216
216
|
attribute vec2 uv;
|
|
217
217
|
varying vec2 vUv;
|
|
@@ -240,7 +240,7 @@ void main(void) {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
gl_FragColor = color;
|
|
243
|
-
}`})),
|
|
243
|
+
}`})),rn([A()],g.ColorRemoveEffect.prototype,"colors",2),rn([A()],g.ColorRemoveEffect.prototype,"epsilon",2),g.ColorRemoveEffect=rn([H("ColorRemoveEffect")],g.ColorRemoveEffect);var Ea=Object.defineProperty,hd=Object.getOwnPropertyDescriptor,cd=(n,r,e)=>r in n?Ea(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,sn=(n,r,e,t)=>{for(var i=t>1?void 0:t?hd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ea(r,e,i),i},ud=(n,r,e)=>cd(n,r+"",e);const jr=50;g.ColorReplaceEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.05);u(this,"_color",new Pt)}apply(e,t){const i=this.colors.map(l=>{this._color.value=l[0];const h=this._color.toArray().slice(0,3);this._color.value=l[1];const c=this._color.toArray().slice(0,3);return[h,c]}),s=this.epsilon,o=new Float32Array(jr*3),a=new Float32Array(jr*3);for(;i.length<jr;)i.push([[-1,0,0],[0,0,0,1]]);i.slice(0,jr).forEach(([l,h],c)=>{o[c*3]=l[0],o[c*3+1]=l[1],o[c*3+2]=l[2],a[c*3]=h[0],a[c*3+1]=h[1],a[c*3+2]=h[2]}),t.redraw(e,()=>{te.draw(e,g.ColorReplaceEffect.material,{sampler:0,epsilon:s,originalColors:o,targetColors:a})})}},ud(g.ColorReplaceEffect,"material",new ne({vert:`precision mediump float;
|
|
244
244
|
attribute vec2 position;
|
|
245
245
|
attribute vec2 uv;
|
|
246
246
|
varying vec2 vUv;
|
|
@@ -250,7 +250,7 @@ void main() {
|
|
|
250
250
|
}`,frag:`varying vec2 vUv;
|
|
251
251
|
uniform sampler2D sampler;
|
|
252
252
|
uniform float epsilon;
|
|
253
|
-
const int MAX_COLORS = ${
|
|
253
|
+
const int MAX_COLORS = ${jr};
|
|
254
254
|
uniform vec3 originalColors[MAX_COLORS];
|
|
255
255
|
uniform vec3 targetColors[MAX_COLORS];
|
|
256
256
|
|
|
@@ -276,7 +276,7 @@ void main(void) {
|
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
}`})),
|
|
279
|
+
}`})),sn([A()],g.ColorReplaceEffect.prototype,"colors",2),sn([A()],g.ColorReplaceEffect.prototype,"epsilon",2),g.ColorReplaceEffect=sn([H("ColorReplaceEffect")],g.ColorReplaceEffect);var Ta=Object.defineProperty,fd=Object.getOwnPropertyDescriptor,dd=(n,r,e)=>r in n?Ta(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Sa=(n,r,e,t)=>{for(var i=t>1?void 0:t?fd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ta(r,e,i),i},pd=(n,r,e)=>dd(n,r+"",e);g.EmbossEffect=class extends g.Effect{constructor(e=5){super();u(this,"strength");this.strength=e}apply(e,t){t.redraw(e,()=>{te.draw(e,g.EmbossEffect.material,{sampler:0,strength:this.strength,inputSize:[t.width,t.height,1/t.width,1/t.height]})})}},pd(g.EmbossEffect,"material",new ne({vert:`precision mediump float;
|
|
280
280
|
attribute vec2 position;
|
|
281
281
|
attribute vec2 uv;
|
|
282
282
|
varying vec2 vUv;
|
|
@@ -298,7 +298,7 @@ void main(void) {
|
|
|
298
298
|
color.rgb = vec3((color.r + color.g + color.b) / 3.0);
|
|
299
299
|
float alpha = texture2D(sampler, vUv).a;
|
|
300
300
|
gl_FragColor = vec4(color.rgb * alpha, alpha);
|
|
301
|
-
}`})),
|
|
301
|
+
}`})),Sa([A()],g.EmbossEffect.prototype,"strength",2),g.EmbossEffect=Sa([H("EmbossEffect")],g.EmbossEffect);var Ma=Object.defineProperty,gd=Object.getOwnPropertyDescriptor,md=(n,r,e)=>r in n?Ma(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,ct=(n,r,e,t)=>{for(var i=t>1?void 0:t?gd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ma(r,e,i),i},yd=(n,r,e)=>md(n,r+"",e);g.GlitchEffect=class extends g.Effect{constructor(){super();u(this,"_canvas");u(this,"_texture");u(this,"_sizes");u(this,"_offsets");u(this,"_redraw",!1);u(this,"slices",10);u(this,"sampleSize",512);u(this,"offset",100);u(this,"direction",0);u(this,"fillMode",2);u(this,"seed",0);u(this,"red",[2,2]);u(this,"green",[-10,4]);u(this,"blue",[10,-4]);this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new de(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const e=this.sampleSize,t=this._texture,i=this._canvas.getContext("2d");i.clearRect(0,0,8,e);let s,o=0;for(let a=0;a<this.slices;a++){s=Math.floor(this._offsets[a]*256);const l=this._sizes[a]*e,h=s>0?s:0,c=s<0?-s:0;i.fillStyle=`rgba(${h}, ${c}, 0, 1)`,i.fillRect(0,o>>0,e,l+1>>0),o+=l}t.requestUpload()}apply(e,t){this._redraw||(this._redraw=!0,this.redraw());const i=t.width,s=t.height,o=this.direction*(Math.PI/180),a=Math.sin(o),l=Math.cos(o);t.redraw(e,()=>{this._texture.activate(e,1),te.draw(e,g.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[i,s,0,0],dimensions:[i,s],aspect:s/i,displacementMap:1,offset:this.offset,sinDir:a,cosDir:l,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},yd(g.GlitchEffect,"material",new ne({vert:`precision mediump float;
|
|
302
302
|
attribute vec2 position;
|
|
303
303
|
attribute vec2 uv;
|
|
304
304
|
varying vec2 vUv;
|
|
@@ -399,7 +399,7 @@ void main(void) {
|
|
|
399
399
|
gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
|
|
400
400
|
gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
|
|
401
401
|
gl_FragColor.a = texture2D(sampler, coord).a;
|
|
402
|
-
}`})),
|
|
402
|
+
}`})),ct([A()],g.GlitchEffect.prototype,"slices",2),ct([A()],g.GlitchEffect.prototype,"sampleSize",2),ct([A()],g.GlitchEffect.prototype,"offset",2),ct([A()],g.GlitchEffect.prototype,"direction",2),ct([A()],g.GlitchEffect.prototype,"fillMode",2),ct([A()],g.GlitchEffect.prototype,"seed",2),ct([A()],g.GlitchEffect.prototype,"red",2),ct([A()],g.GlitchEffect.prototype,"green",2),ct([A()],g.GlitchEffect.prototype,"blue",2),g.GlitchEffect=ct([H("GlitchEffect")],g.GlitchEffect);var Aa=Object.defineProperty,vd=Object.getOwnPropertyDescriptor,_d=(n,r,e)=>r in n?Aa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Xt=(n,r,e,t)=>{for(var i=t>1?void 0:t?vd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Aa(r,e,i),i},bd=(n,r,e)=>_d(n,r+"",e);g.GodrayEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"angle",30);u(this,"gain",.5);u(this,"lacunarity",2.5);u(this,"parallel",!0);u(this,"center",[0,0]);u(this,"alpha",1)}apply(e,t){const i=this.angle*(Math.PI/180),s=this.parallel?[Math.cos(i),Math.sin(i)]:this.center;t.redraw(e,()=>{te.draw(e,g.GodrayEffect.material,{sampler:0,inputSize:[t.width,t.height,0,0],gain:this.gain,lacunarity:this.lacunarity,parallel:this.parallel,alpha:this.alpha,light:s,aspect:t.height/t.width})})}},bd(g.GodrayEffect,"material",new ne({vert:`precision mediump float;
|
|
403
403
|
attribute vec2 position;
|
|
404
404
|
attribute vec2 uv;
|
|
405
405
|
varying vec2 vUv;
|
|
@@ -529,7 +529,7 @@ void main(void) {
|
|
|
529
529
|
mist.a = 1.0;
|
|
530
530
|
mist *= alpha;
|
|
531
531
|
gl_FragColor = vec4(color.rgb + mist.rgb, color.a);
|
|
532
|
-
}`})),
|
|
532
|
+
}`})),Xt([A()],g.GodrayEffect.prototype,"angle",2),Xt([A()],g.GodrayEffect.prototype,"gain",2),Xt([A()],g.GodrayEffect.prototype,"lacunarity",2),Xt([A()],g.GodrayEffect.prototype,"parallel",2),Xt([A()],g.GodrayEffect.prototype,"center",2),Xt([A()],g.GodrayEffect.prototype,"alpha",2),g.GodrayEffect=Xt([H("GodrayEffect")],g.GodrayEffect);var Oa=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,xd=(n,r,e)=>r in n?Oa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Pd=(n,r,e,t)=>{for(var i=t>1?void 0:t?wd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Oa(r,e,i),i},Cd=(n,r,e)=>xd(n,r+"",e);g.KawaseEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"blur",10);u(this,"quality",10)}apply(e,t){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=this.blur,l=this.quality,h=t.width,c=t.height,f=[],p=[a];if(a>0){let C=a;const x=a/l;for(let T=1;T<l;T++)C-=x,p.push(C)}const d=1/h,m=1/c,v=[];let y;const S=l-1;for(let C=0;C<S;C++)y=p[C]+.5,v[0]=y*d,v[1]=y*m,f.push({offset:v});y=p[S]+.5,v[0]=y*d,v[1]=y*m,f.push({offset:v}),f.forEach(C=>{te.draw(e,g.KawaseEffect.material,{sampler:s,progress:o,...C})})}},Cd(g.KawaseEffect,"material",new ne({vert:`attribute vec2 position;
|
|
533
533
|
attribute vec2 uv;
|
|
534
534
|
varying vec2 vUv;
|
|
535
535
|
void main() {
|
|
@@ -550,7 +550,7 @@ void main(void) {
|
|
|
550
550
|
color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y - offset1.y));
|
|
551
551
|
color *= 0.25;
|
|
552
552
|
gl_FragColor = color;
|
|
553
|
-
}`})),g.KawaseEffect=
|
|
553
|
+
}`})),g.KawaseEffect=Pd([H("KawaseEffect")],g.KawaseEffect);var Ua=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,Td=(n,r,e)=>r in n?Ua(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Sd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ed(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ua(r,e,i),i},Md=(n,r,e)=>Td(n,r+"",e);g.LeftEraseEffect=class extends g.Effect{apply(r){te.draw(r,g.LeftEraseEffect.material,{previous:0,next:1,progress:this.visibleProgress})}},Md(g.LeftEraseEffect,"material",new ne({vert:`attribute vec2 position;
|
|
554
554
|
attribute vec2 uv;
|
|
555
555
|
varying vec2 vUv;
|
|
556
556
|
void main() {
|
|
@@ -575,7 +575,7 @@ void main() {
|
|
|
575
575
|
mixPercent = 1.0;
|
|
576
576
|
}
|
|
577
577
|
gl_FragColor = mix(src2Color, src1Color, mixPercent);
|
|
578
|
-
}`})),g.LeftEraseEffect=
|
|
578
|
+
}`})),g.LeftEraseEffect=Sd([H("LeftEraseEffect")],g.LeftEraseEffect);var Da=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,Od=(n,r,e)=>r in n?Da(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,nn=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ad(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Da(r,e,i),i},Ud=(n,r,e)=>Od(n,r+"",e);g.MaskEffect=class extends g.Effect{constructor(e){super();u(this,"texture");this.setProperties(e)}async load(){this.texture=void 0,this.src&&(this.texture=await mt.texture.load(this.src))}_onUpdateProperty(e,t,i){var s;switch(super._onUpdateProperty(e,t,i),e){case"src":this.load();break;case"texture":(s=i==null?void 0:i.destroy)==null||s.call(i);break}}apply(e,t,i){this.texture&&i.targetArea&&t.redraw(e,()=>{this.texture.activate(e,1),te.draw(e,g.MaskEffect.material,{sampler:0,mask:1,area:i.targetArea}),e.texture.unbind(1)})}},Ud(g.MaskEffect,"material",new ne({vert:`precision mediump float;
|
|
579
579
|
attribute vec2 position;
|
|
580
580
|
attribute vec2 uv;
|
|
581
581
|
varying vec2 vUv;
|
|
@@ -604,7 +604,7 @@ void main(void) {
|
|
|
604
604
|
} else {
|
|
605
605
|
gl_FragColor = vec4(0.);
|
|
606
606
|
}
|
|
607
|
-
}`})),
|
|
607
|
+
}`})),nn([ee()],g.MaskEffect.prototype,"texture",2),nn([A({default:""})],g.MaskEffect.prototype,"src",2),g.MaskEffect=nn([H("MaskEffect")],g.MaskEffect);var Ia=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Id=(n,r,e)=>r in n?Ia(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Ra=(n,r,e,t)=>{for(var i=t>1?void 0:t?Dd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ia(r,e,i),i},Rd=(n,r,e)=>Id(n,r+"",e);g.PixelateEffect=class extends g.Effect{constructor(e=10){super();u(this,"size");this.size=e}apply(e,t){t.redraw(e,()=>{te.draw(e,g.PixelateEffect.material,{sampler:0,size:[this.size,this.size],filterArea:[t.width,t.height,0,0]})})}},Rd(g.PixelateEffect,"material",new ne({vert:`precision mediump float;
|
|
608
608
|
attribute vec2 position;
|
|
609
609
|
attribute vec2 uv;
|
|
610
610
|
varying vec2 vUv;
|
|
@@ -637,7 +637,7 @@ void main(void) {
|
|
|
637
637
|
coord = pixelate(coord, size);
|
|
638
638
|
coord = unmapCoord(coord);
|
|
639
639
|
gl_FragColor = texture2D(sampler, coord);
|
|
640
|
-
}`})),
|
|
640
|
+
}`})),Ra([A()],g.PixelateEffect.prototype,"size",2),g.PixelateEffect=Ra([H("PixelateEffect")],g.PixelateEffect);var Ba=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Ld=(n,r,e)=>r in n?Ba(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,kd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Bd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ba(r,e,i),i},Nd=(n,r,e)=>Ld(n,r+"",e);g.TiltShiftEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"blur",100);u(this,"gradientBlur",600)}apply(e,t){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height,h=[0,l/2],c=[600,l/2],f=[a,l],p=c[0]-h[0],d=c[1]-h[1],m=Math.sqrt(p*p+d*d);te.draw(e,g.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[p/m,d/m],texSize:f}),te.draw(e,g.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[-d/m,p/m],texSize:f})}},Nd(g.TiltShiftEffect,"material",new ne({vert:`attribute vec2 position;
|
|
641
641
|
attribute vec2 uv;
|
|
642
642
|
varying vec2 vUv;
|
|
643
643
|
void main() {
|
|
@@ -681,7 +681,7 @@ void main(void) {
|
|
|
681
681
|
color.rgb /= color.a + 0.00001;
|
|
682
682
|
|
|
683
683
|
gl_FragColor = color;
|
|
684
|
-
}`})),g.TiltShiftEffect=
|
|
684
|
+
}`})),g.TiltShiftEffect=kd([H("TiltShiftEffect")],g.TiltShiftEffect);var La=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,$d=(n,r,e)=>r in n?La(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,zd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&La(r,e,i),i},Vd=(n,r,e)=>$d(n,r+"",e);g.TwistEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"radius");u(this,"angle",4);u(this,"padding",20);u(this,"offset")}apply(e,t){const i=this.visibleProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height;te.draw(e,g.TwistEffect.material,{sampler:s,progress:o,filterArea:[a,l,0,0],radius:this.radius??a,angle:this.angle,padding:this.padding,offset:this.offset??[a/2,l/2]})}},Vd(g.TwistEffect,"material",new ne({vert:`attribute vec2 position;
|
|
685
685
|
attribute vec2 uv;
|
|
686
686
|
varying vec2 vUv;
|
|
687
687
|
void main() {
|
|
@@ -727,7 +727,7 @@ void main(void) {
|
|
|
727
727
|
coord = twist(coord, radius - (progress * radius));
|
|
728
728
|
coord = unmapCoord(coord);
|
|
729
729
|
gl_FragColor = texture2D(sampler, coord);
|
|
730
|
-
}`})),g.TwistEffect=
|
|
730
|
+
}`})),g.TwistEffect=zd([H("TwistEffect")],g.TwistEffect);var ka=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,Gd=(n,r,e)=>r in n?ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Gr=(n,r,e,t)=>{for(var i=t>1?void 0:t?jd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ka(r,e,i),i},qd=(n,r,e)=>Gd(n,r+"",e);g.ZoomBlurEffect=class extends g.Effect{constructor(){super(...arguments);u(this,"center");u(this,"innerRadius",20);u(this,"radius",-1);u(this,"strength",.1)}apply(e,t){t.redraw(e,()=>{te.draw(e,g.ZoomBlurEffect.material,{sampler:0,center:this.center??[t.width/2,t.height/2],innerRadius:this.innerRadius,radius:this.radius,strength:this.strength,inputSize:[t.width,t.height,1/t.width,1/t.height]})})}},qd(g.ZoomBlurEffect,"material",new ne({vert:`attribute vec2 position;
|
|
731
731
|
attribute vec2 uv;
|
|
732
732
|
varying vec2 vUv;
|
|
733
733
|
void main() {
|
|
@@ -807,7 +807,7 @@ void main() {
|
|
|
807
807
|
color /= total;
|
|
808
808
|
|
|
809
809
|
gl_FragColor = color;
|
|
810
|
-
}`})),ei([U()],g.ZoomBlurEffect.prototype,"center",2),ei([U()],g.ZoomBlurEffect.prototype,"innerRadius",2),ei([U()],g.ZoomBlurEffect.prototype,"radius",2),ei([U()],g.ZoomBlurEffect.prototype,"strength",2),g.ZoomBlurEffect=ei([Z("ZoomBlurEffect")],g.ZoomBlurEffect);class Zi{constructor(){d(this,"bubbles",!0);d(this,"cancelable",!1);d(this,"which");d(this,"cancelBubble",!0);d(this,"returnValue");d(this,"srcElement");d(this,"composed",!1);d(this,"currentTarget");d(this,"defaultPrevented",!1);d(this,"eventPhase",Zi.prototype.NONE);d(this,"isTrusted");d(this,"target");d(this,"timeStamp");d(this,"type");d(this,"nativeEvent");d(this,"originalEvent");d(this,"propagationStopped",!1);d(this,"propagationImmediatelyStopped",!1);d(this,"path");d(this,"detail");d(this,"view");d(this,"layer",{x:0,y:0});d(this,"page",{x:0,y:0});d(this,"NONE",0);d(this,"CAPTURING_PHASE",1);d(this,"AT_TARGET",2);d(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...e){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...e){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class On extends Zi{constructor(){super(...arguments);d(this,"altKey");d(this,"button");d(this,"buttons");d(this,"ctrlKey");d(this,"metaKey");d(this,"relatedTarget");d(this,"shiftKey");d(this,"client",{x:0,y:0});d(this,"movement",{x:0,y:0});d(this,"offset",{x:0,y:0});d(this,"global",{x:0,y:0});d(this,"screen",{x:0,y:0})}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}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(...t){throw new Error("Method not implemented.")}}class fl extends On{constructor(){super(...arguments);d(this,"width",0);d(this,"height",0);d(this,"isPrimary",!1);d(this,"pointerType");d(this,"pressure");d(this,"tangentialPressure");d(this,"tiltX");d(this,"tiltY");d(this,"twist")}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class ri extends On{constructor(){super(...arguments);d(this,"deltaMode");d(this,"deltaX");d(this,"deltaY");d(this,"deltaZ");d(this,"DOM_DELTA_PIXEL",0);d(this,"DOM_DELTA_LINE",1);d(this,"DOM_DELTA_PAGE",2)}}d(ri,"DOM_DELTA_PIXEL",0),d(ri,"DOM_DELTA_LINE",1),d(ri,"DOM_DELTA_PAGE",2);const Ap={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class dl extends ve{constructor(){super(...arguments);d(this,"target");d(this,"cursor","default");d(this,"cursorStyles",{default:"inherit",pointer:"pointer"});d(this,"setuped",!1);d(this,"event");d(this,"enableMoveEvent",!0);d(this,"enableWheelEvent",!0);d(this,"enableClickEvent",!0);d(this,"onPointerDown",t=>{if(_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointerdown",this.event=this.clonePointerEvent(r[i]));this.setCursor(this.cursor)});d(this,"onPointerOver",t=>{if(!this.enableClickEvent||_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointerover",this.event=this.clonePointerEvent(r[i]))});d(this,"onPointerMove",t=>{if(!this.enableMoveEvent||_e&&t.pointerType==="touch")return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("pointermove",this.event=this.clonePointerEvent(r[i]))});d(this,"onPointerUp",t=>{if(!this.enableClickEvent||_e&&t.pointerType==="touch")return;let r=t.target;t.composedPath&&t.composedPath().length>0&&(r=t.composedPath()[0]);const i=r!==this.target?"outside":"",s=this.normalize(t);for(let o=0,a=s.length;o<a;o++){const l=this.clonePointerEvent(s[o]);l.type+=i,this.emit("pointerup",this.event=l)}});d(this,"onWheel",t=>{if(!this.enableWheelEvent)return;const r=this.normalize(t);for(let i=0,s=r.length;i<s;i++)this.emit("wheel",this.event=this.cloneWheelEvent(r[i]))})}setTarget(t){this.removeEventListeners(),this.target=t,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const t=this.target.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):sr&&(t.touchAction=""),sr?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),globalThis.document.removeEventListener("pointermove",this.onPointerMove),globalThis.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),globalThis.document.removeEventListener("mousemove",this.onPointerMove),globalThis.removeEventListener("mouseup",this.onPointerUp)),_e&&(this.target.removeEventListener("touchstart",this.onPointerDown),this.target.removeEventListener("touchmove",this.onPointerMove),this.target.removeEventListener("touchend",this.onPointerUp)),this.target.removeEventListener("wheel",this.onWheel),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const t=this.target.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):sr&&(t.touchAction="none")),sr?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),globalThis.document.addEventListener("pointermove",this.onPointerMove),globalThis.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),globalThis.document.addEventListener("mousemove",this.onPointerMove),globalThis.addEventListener("mouseup",this.onPointerUp)),_e&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel,{passive:!0}),this.setuped=!0}normalize(t){const r=[];if(_e&&t instanceof globalThis.TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const o=t.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.type=t.type,r.push(o)}else if(Nn&&t instanceof globalThis.WheelEvent)r.push(t);else if(sr&&t instanceof globalThis.PointerEvent)r.push(t);else{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=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),r.push(i)}return r}cloneWheelEvent(t){const r=new ri;return this.copyMouseEvent(r,t),r.deltaX=t.deltaX,r.deltaY=t.deltaY,r.deltaZ=t.deltaZ,r.deltaMode=t.deltaMode,this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.x=r.screen.x,r.global.y=r.screen.y,r.offset.x=r.screen.x,r.offset.y=r.screen.y,r.nativeEvent=t,r.type=t.type,r}clonePointerEvent(t){const r=new fl;return r.originalEvent=null,r.nativeEvent=t,r.pointerId=t.pointerId,r.width=t.width,r.height=t.height,r.isPrimary=t.isPrimary,r.pointerType=t.pointerType,r.pressure=t.pressure,r.tangentialPressure=t.tangentialPressure,r.tiltX=t.tiltX,r.tiltY=t.tiltY,r.twist=t.twist,r.isTrusted=t.isTrusted,this.copyMouseEvent(r,t),this.mapPositionToPoint(r.screen,t.clientX,t.clientY),r.global.x=r.screen.x,r.global.y=r.screen.y,r.offset.x=r.screen.x,r.offset.y=r.screen.y,r.type==="pointerleave"?r.type="pointerout":r.type.startsWith("mouse")?r.type=r.type.replace("mouse","pointer"):r.type.startsWith("touch")&&(r.type=Ap[r.type]||r.type),r}copyMouseEvent(t,r){t.isTrusted=r.isTrusted,t.timeStamp=performance.now(),t.type=r.type,t.altKey=r.altKey,t.button=r.button,t.buttons=r.buttons,t.client.x=r.clientX,t.client.y=r.clientY,t.ctrlKey=r.ctrlKey,t.metaKey=r.metaKey,t.movement.x=r.movementX,t.movement.y=r.movementY,t.page.x=r.pageX,t.page.y=r.pageY,t.relatedTarget=null,t.shiftKey=r.shiftKey}setCursor(t){if(!this.target||(t=t||"default",this.cursor===t))return;this.cursor=t;const r=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),i=this.cursorStyles[t];if(i)switch(typeof i){case"string":r&&(this.target.style.cursor=i);break;case"function":i(t);break;case"object":r&&Object.assign(this.target.style,i);break}else r&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.target.style.cursor=t)}mapPositionToPoint(t,r,i){if(!this.target)return;const s=Number(this.target.getAttribute("width"))||0,o=Number(this.target.getAttribute("height"))||0,a=Number(this.target.getAttribute("data-pixel-ratio"))||1,l=this.target.isConnected?this.target.getBoundingClientRect():{x:0,y:0,width:s,height:o,left:0,top:0},h=1/a;t.x=(r-l.left)*(s/l.width)*h,t.y=(i-l.top)*(o/l.height)*h}}class pl{constructor(){d(this,"view");d(this,"pixelRatio",cs);d(this,"screen",{x:0,y:0,width:0,height:0});d(this,"related",new WeakMap)}getRelated(e,t){let r=this.related.get(e);return r||(t?(this.related.set(e,r=t()),r):(console.warn("Failed to get related",e),null))}resize(e,t,r=!0){const i=Math.floor(e*this.pixelRatio),s=Math.floor(t*this.pixelRatio),o=i/this.pixelRatio,a=s/this.pixelRatio;this.view&&(this.view.width=i,this.view.height=s),this.screen.width=o,this.screen.height=a,r&&this.view&&(this.view.style.width=`${o}px`,this.view.style.height=`${a}px`)}}var vr=(n=>(n.NORMAL="normal",n.ADD="add",n.MULTIPLY="multiply",n.SCREEN="screen",n.NONE="none",n.NORMAL_NPM="normal_npm",n.ADD_NPM="add_npm",n.SCREEN_NPM="screen_npm",n.SRC_IN="src_in",n.SRC_OUT="src_out",n.SRC_ATOP="src_atop",n.DST_OVER="dst_over",n.DST_IN="dst_in",n.DST_OUT="dst_out",n.DST_ATOP="dst_atop",n.XOR="xor",n.SUBTRACT="subtract",n))(vr||{});function gl(n){return{normal:[n.ONE,n.ONE_MINUS_SRC_ALPHA],add:[n.ONE,n.ONE],multiply:[n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],screen:[n.ONE,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],add_npm:[n.SRC_ALPHA,n.ONE,n.ONE,n.ONE],screen_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],src_in:[n.DST_ALPHA,n.ZERO],src_out:[n.ONE_MINUS_DST_ALPHA,n.ZERO],src_atop:[n.DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],dst_over:[n.ONE_MINUS_DST_ALPHA,n.ONE],dst_in:[n.ZERO,n.SRC_ALPHA],dst_out:[n.ZERO,n.ONE_MINUS_SRC_ALPHA],dst_atop:[n.ONE_MINUS_DST_ALPHA,n.SRC_ALPHA],xor:[n.ONE_MINUS_DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],subtract:[n.ONE,n.ONE,n.ONE,n.ONE,n.FUNC_REVERSE_SUBTRACT,n.FUNC_ADD]}}class ee{get gl(){return this._renderer.gl}install(e){this._renderer=e}onUpdateContext(){}flush(){}reset(){}destroy(){}}const rs=class rs{constructor(e){d(this,"_blendMode",vr.NORMAL);d(this,"_polygonOffset",0);d(this,"bitmap",0);if(e)for(const t in e)this[t]=e[t]}static _init(){this._properties.forEach((e,t)=>{Object.defineProperty(this.prototype,e,{get(){return!!(this.bitmap&1<<t)},set(r){!!(this.bitmap&1<<t)!==r&&(this.bitmap^=1<<t)},enumerable:!0,configurable:!0})})}static for2D(){const e=new rs;return e.depthTest=!1,e.blend=!0,e}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==vr.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}};d(rs,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let tr=rs;tr._init();class ml extends ee{constructor(){super(...arguments);d(this,"_blendEq",!1);d(this,"_setters",tr._properties.map(t=>this[`set${t.replace(/^\S/,r=>r.toUpperCase())}`]));d(this,"boundStateBitmap",0);d(this,"boundBlendMode");d(this,"blendModes");d(this,"defaultState",new tr({blend:!0}))}install(t){super.install(t),t.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=gl(this._renderer.gl)}toggle(t,r){this._renderer.gl[r?"enable":"disable"](t)}setBlend(t){this.toggle(this._renderer.gl.BLEND,t)}setOffsets(t){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,t)}setCulling(t){this.toggle(this._renderer.gl.CULL_FACE,t)}setDepthTest(t){this.toggle(this._renderer.gl.DEPTH_TEST,t)}setDepthMask(t){this._renderer.gl.depthMask(t)}setClockwiseFrontFace(t){const r=this._renderer.gl;r.frontFace(r[t?"CW":"CCW"])}setBlendMode(t){if(t===this.boundBlendMode)return;this.boundBlendMode=t;const r=this.blendModes[t],i=this._renderer.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,r){this._renderer.gl.polygonOffset(t,r)}bind(t){var r;if(this.boundStateBitmap!==t.bitmap){let i=this.boundStateBitmap^t.bitmap,s=0;for(;i;)i&1&&((r=this._setters[s])==null||r.call(this,!!(t.bitmap&1<<s))),i=i>>1,s++;this.boundStateBitmap=t.bitmap}t.blend&&this.setBlendMode(t.blendMode),t.offsets&&this.setPolygonOffset(1,t.polygonOffset)}reset(){super.reset();const t=this._renderer.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(vr.NORMAL)}}class yl extends ee{constructor(){super(...arguments);d(this,"_state",tr.for2D());d(this,"_batchSize",4096*4);d(this,"_vertexSize",27);d(this,"_drawCallUid",0);d(this,"_defaultTint",4294967295);d(this,"_defaultBackgroundColor",0);d(this,"_defaultColorMatrixOffset",[0,0,0,0]);d(this,"_defaultColorMatrix",[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);d(this,"_batchables",[]);d(this,"_vertexCount",0);d(this,"_indexCount",0);d(this,"_attributeBuffer",[]);d(this,"_indexBuffers",[]);d(this,"_shaders",new Map);d(this,"_attributes",{aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aTint:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}})}install(t){super.install(t),t.batch2D=this}_getShader(t){let r=this._shaders.get(t);return r||this._shaders.set(t,r=this._createShader(t)),r}_createShader(t){const r=this._renderer,i=r.program.create({vert:`precision highp float;
|
|
810
|
+
}`})),Gr([A()],g.ZoomBlurEffect.prototype,"center",2),Gr([A()],g.ZoomBlurEffect.prototype,"innerRadius",2),Gr([A()],g.ZoomBlurEffect.prototype,"radius",2),Gr([A()],g.ZoomBlurEffect.prototype,"strength",2),g.ZoomBlurEffect=Gr([H("ZoomBlurEffect")],g.ZoomBlurEffect);class Ri{constructor(){u(this,"bubbles",!0);u(this,"cancelable",!1);u(this,"which");u(this,"cancelBubble",!0);u(this,"returnValue");u(this,"srcElement");u(this,"composed",!1);u(this,"currentTarget");u(this,"defaultPrevented",!1);u(this,"eventPhase",Ri.prototype.NONE);u(this,"isTrusted");u(this,"target");u(this,"timeStamp");u(this,"type");u(this,"nativeEvent");u(this,"originalEvent");u(this,"propagationStopped",!1);u(this,"propagationImmediatelyStopped",!1);u(this,"path");u(this,"detail");u(this,"view");u(this,"layer",{x:0,y:0});u(this,"page",{x:0,y:0});u(this,"NONE",0);u(this,"CAPTURING_PHASE",1);u(this,"AT_TARGET",2);u(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...r){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class on extends Ri{constructor(){super(...arguments);u(this,"altKey");u(this,"button");u(this,"buttons");u(this,"ctrlKey");u(this,"metaKey");u(this,"relatedTarget");u(this,"shiftKey");u(this,"client",{x:0,y:0});u(this,"movement",{x:0,y:0});u(this,"offset",{x:0,y:0});u(this,"global",{x:0,y:0});u(this,"screen",{x:0,y:0})}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}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}}class Na extends on{constructor(){super(...arguments);u(this,"width",0);u(this,"height",0);u(this,"isPrimary",!1);u(this,"pointerType");u(this,"pressure");u(this,"tangentialPressure");u(this,"tiltX");u(this,"tiltY");u(this,"twist")}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class qr extends on{constructor(){super(...arguments);u(this,"deltaMode");u(this,"deltaX");u(this,"deltaY");u(this,"deltaZ");u(this,"DOM_DELTA_PIXEL",0);u(this,"DOM_DELTA_LINE",1);u(this,"DOM_DELTA_PAGE",2)}}u(qr,"DOM_DELTA_PIXEL",0),u(qr,"DOM_DELTA_LINE",1),u(qr,"DOM_DELTA_PAGE",2);const Wd={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class Fa extends dt{constructor(){super(...arguments);u(this,"target");u(this,"cursor","default");u(this,"cursorStyles",{default:"inherit",pointer:"pointer"});u(this,"setuped",!1);u(this,"event");u(this,"enableMoveEvent",!0);u(this,"enableWheelEvent",!0);u(this,"enableClickEvent",!0);u(this,"onPointerDown",e=>{if(ft&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerdown",this.event=this.clonePointerEvent(t[i]));this.setCursor(this.cursor)});u(this,"onPointerOver",e=>{if(!this.enableClickEvent||ft&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointerover",this.event=this.clonePointerEvent(t[i]))});u(this,"onPointerMove",e=>{if(!this.enableMoveEvent||ft&&e.pointerType==="touch")return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("pointermove",this.event=this.clonePointerEvent(t[i]))});u(this,"onPointerUp",e=>{if(!this.enableClickEvent||ft&&e.pointerType==="touch")return;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.target?"outside":"",s=this.normalize(e);for(let o=0,a=s.length;o<a;o++){const l=this.clonePointerEvent(s[o]);l.type+=i,this.emit("pointerup",this.event=l)}});u(this,"onWheel",e=>{if(!this.enableWheelEvent)return;const t=this.normalize(e);for(let i=0,s=t.length;i<s;i++)this.emit("wheel",this.event=this.cloneWheelEvent(t[i]))})}setTarget(e){this.removeEventListeners(),this.target=e,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const e=this.target.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):Kt&&(e.touchAction=""),Kt?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),globalThis.document.removeEventListener("pointermove",this.onPointerMove),globalThis.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),globalThis.document.removeEventListener("mousemove",this.onPointerMove),globalThis.removeEventListener("mouseup",this.onPointerUp)),ft&&(this.target.removeEventListener("touchstart",this.onPointerDown),this.target.removeEventListener("touchmove",this.onPointerMove),this.target.removeEventListener("touchend",this.onPointerUp)),this.target.removeEventListener("wheel",this.onWheel),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const e=this.target.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):Kt&&(e.touchAction="none")),Kt?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),globalThis.document.addEventListener("pointermove",this.onPointerMove),globalThis.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),globalThis.document.addEventListener("mousemove",this.onPointerMove),globalThis.addEventListener("mouseup",this.onPointerUp)),ft&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel,{passive:!0}),this.setuped=!0}normalize(e){const t=[];if(ft&&e instanceof globalThis.TouchEvent)for(let i=0,s=e.changedTouches.length;i<s;i++){const o=e.changedTouches[i];typeof o.button>"u"&&(o.button=0),typeof o.buttons>"u"&&(o.buttons=1),typeof o.isPrimary>"u"&&(o.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof o.width>"u"&&(o.width=o.radiusX||1),typeof o.height>"u"&&(o.height=o.radiusY||1),typeof o.tiltX>"u"&&(o.tiltX=0),typeof o.tiltY>"u"&&(o.tiltY=0),typeof o.pointerType>"u"&&(o.pointerType="touch"),typeof o.pointerId>"u"&&(o.pointerId=o.identifier||0),typeof o.pressure>"u"&&(o.pressure=o.force||.5),typeof o.twist>"u"&&(o.twist=0),typeof o.tangentialPressure>"u"&&(o.tangentialPressure=0),typeof o.layerX>"u"&&(o.layerX=o.offsetX=o.clientX),typeof o.layerY>"u"&&(o.layerY=o.offsetY=o.clientY),o.type=e.type,t.push(o)}else if(pn&&e instanceof globalThis.WheelEvent)t.push(e);else if(Kt&&e instanceof globalThis.PointerEvent)t.push(e);else{const i=e;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=1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),t.push(i)}return t}cloneWheelEvent(e){const t=new qr;return this.copyMouseEvent(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.nativeEvent=e,t.type=e.type,t}clonePointerEvent(e){const t=new Na;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,t.isTrusted=e.isTrusted,this.copyMouseEvent(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.type==="pointerleave"?t.type="pointerout":t.type.startsWith("mouse")?t.type=t.type.replace("mouse","pointer"):t.type.startsWith("touch")&&(t.type=Wd[t.type]||t.type),t}copyMouseEvent(e,t){e.isTrusted=t.isTrusted,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}setCursor(e){if(!this.target||(e=e||"default",this.cursor===e))return;this.cursor=e;const t=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.target.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.target.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.target.style.cursor=e)}mapPositionToPoint(e,t,i){if(!this.target)return;const s=Number(this.target.getAttribute("width"))||0,o=Number(this.target.getAttribute("height"))||0,a=Number(this.target.getAttribute("data-pixel-ratio"))||1,l=this.target.isConnected?this.target.getBoundingClientRect():{x:0,y:0,width:s,height:o,left:0,top:0},h=1/a;e.x=(t-l.left)*(s/l.width)*h,e.y=(i-l.top)*(o/l.height)*h}}class $a{constructor(){u(this,"view");u(this,"pixelRatio",Xi);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new WeakMap)}getRelated(r,e){let t=this.related.get(r);return t||(e?(this.related.set(r,t=e()),t):(console.warn("Failed to get related",r),null))}resize(r,e,t=!0){const i=Math.floor(r*this.pixelRatio),s=Math.floor(e*this.pixelRatio),o=i/this.pixelRatio,a=s/this.pixelRatio;this.view&&(this.view.width=i,this.view.height=s),this.screen.width=o,this.screen.height=a,t&&this.view&&(this.view.style.width=`${o}px`,this.view.style.height=`${a}px`)}}var fr=(n=>(n.NORMAL="normal",n.ADD="add",n.MULTIPLY="multiply",n.SCREEN="screen",n.NONE="none",n.NORMAL_NPM="normal_npm",n.ADD_NPM="add_npm",n.SCREEN_NPM="screen_npm",n.SRC_IN="src_in",n.SRC_OUT="src_out",n.SRC_ATOP="src_atop",n.DST_OVER="dst_over",n.DST_IN="dst_in",n.DST_OUT="dst_out",n.DST_ATOP="dst_atop",n.XOR="xor",n.SUBTRACT="subtract",n))(fr||{});function za(n){return{normal:[n.ONE,n.ONE_MINUS_SRC_ALPHA],add:[n.ONE,n.ONE],multiply:[n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],screen:[n.ONE,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA],add_npm:[n.SRC_ALPHA,n.ONE,n.ONE,n.ONE],screen_npm:[n.SRC_ALPHA,n.ONE_MINUS_SRC_COLOR,n.ONE,n.ONE_MINUS_SRC_ALPHA],src_in:[n.DST_ALPHA,n.ZERO],src_out:[n.ONE_MINUS_DST_ALPHA,n.ZERO],src_atop:[n.DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],dst_over:[n.ONE_MINUS_DST_ALPHA,n.ONE],dst_in:[n.ZERO,n.SRC_ALPHA],dst_out:[n.ZERO,n.ONE_MINUS_SRC_ALPHA],dst_atop:[n.ONE_MINUS_DST_ALPHA,n.SRC_ALPHA],xor:[n.ONE_MINUS_DST_ALPHA,n.ONE_MINUS_SRC_ALPHA],subtract:[n.ONE,n.ONE,n.ONE,n.ONE,n.FUNC_REVERSE_SUBTRACT,n.FUNC_ADD]}}class Ye{get gl(){return this._renderer.gl}install(r){this._renderer=r}onUpdateContext(){}flush(){}reset(){}destroy(){}}const Fi=class Fi{constructor(r){u(this,"_blendMode",fr.NORMAL);u(this,"_polygonOffset",0);u(this,"bitmap",0);if(r)for(const e in r)this[e]=r[e]}static _init(){this._properties.forEach((r,e)=>{Object.defineProperty(this.prototype,r,{get(){return!!(this.bitmap&1<<e)},set(t){!!(this.bitmap&1<<e)!==t&&(this.bitmap^=1<<e)},enumerable:!0,configurable:!0})})}static for2D(){const r=new Fi;return r.depthTest=!1,r.blend=!0,r}get blendMode(){return this._blendMode}set blendMode(r){this.blend=r!==fr.NONE,this._blendMode=r}get polygonOffset(){return this._polygonOffset}set polygonOffset(r){this.offsets=!!r,this._polygonOffset=r}};u(Fi,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let Ht=Fi;Ht._init();class Va extends Ye{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",Ht._properties.map(e=>this[`set${e.replace(/^\S/,t=>t.toUpperCase())}`]));u(this,"boundStateBitmap",0);u(this,"boundBlendMode");u(this,"blendModes");u(this,"defaultState",new Ht({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=za(this._renderer.gl)}toggle(e,t){this._renderer.gl[t?"enable":"disable"](e)}setBlend(e){this.toggle(this._renderer.gl.BLEND,e)}setOffsets(e){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,e)}setCulling(e){this.toggle(this._renderer.gl.CULL_FACE,e)}setDepthTest(e){this.toggle(this._renderer.gl.DEPTH_TEST,e)}setDepthMask(e){this._renderer.gl.depthMask(e)}setClockwiseFrontFace(e){const t=this._renderer.gl;t.frontFace(t[e?"CW":"CCW"])}setBlendMode(e){if(e===this.boundBlendMode)return;this.boundBlendMode=e;const t=this.blendModes[e],i=this._renderer.gl;t.length===2?i.blendFunc(t[0],t[1]):i.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,i.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,t){this._renderer.gl.polygonOffset(e,t)}bind(e){var t;if(this.boundStateBitmap!==e.bitmap){let i=this.boundStateBitmap^e.bitmap,s=0;for(;i;)i&1&&((t=this._setters[s])==null||t.call(this,!!(e.bitmap&1<<s))),i=i>>1,s++;this.boundStateBitmap=e.bitmap}e.blend&&this.setBlendMode(e.blendMode),e.offsets&&this.setPolygonOffset(1,e.polygonOffset)}reset(){super.reset();const e=this._renderer.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(fr.NORMAL)}}class ja extends Ye{constructor(){super(...arguments);u(this,"_state",Ht.for2D());u(this,"_batchSize",4096*4);u(this,"_vertexSize",27);u(this,"_drawCallUid",0);u(this,"_defaultTint",4294967295);u(this,"_defaultBackgroundColor",0);u(this,"_defaultColorMatrixOffset",[0,0,0,0]);u(this,"_defaultColorMatrix",[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);u(this,"_batchables",[]);u(this,"_vertexCount",0);u(this,"_indexCount",0);u(this,"_attributeBuffer",[]);u(this,"_indexBuffers",[]);u(this,"_shaders",new Map);u(this,"_attributes",{aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aTint:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}})}install(e){super.install(e),e.batch2D=this}_getShader(e){let t=this._shaders.get(e);return t||this._shaders.set(e,t=this._createShader(e)),t}_createShader(e){const t=this._renderer,i=t.program.create({vert:`precision highp float;
|
|
811
811
|
attribute float aTextureId;
|
|
812
812
|
attribute vec2 aPosition;
|
|
813
813
|
attribute vec2 aUv;
|
|
@@ -843,18 +843,18 @@ varying vec4 vBackgroundColor;
|
|
|
843
843
|
varying mat4 vColorMatrix;
|
|
844
844
|
varying vec4 vColorMatrixOffset;
|
|
845
845
|
|
|
846
|
-
uniform sampler2D samplers[${
|
|
846
|
+
uniform sampler2D samplers[${e}];
|
|
847
847
|
|
|
848
848
|
void main(void) {
|
|
849
849
|
vec4 color;
|
|
850
850
|
if (vTextureId < 0.0)
|
|
851
851
|
{
|
|
852
852
|
color = vec4(0.0, 0.0, 0.0, 0.0);
|
|
853
|
-
}${Array.from({length:
|
|
854
|
-
else `),
|
|
855
|
-
if (vTextureId < ${
|
|
853
|
+
}${Array.from({length:e},(c,f)=>{let p=" ";return f>=0&&(p+=`
|
|
854
|
+
else `),f<e-1&&(p+=`
|
|
855
|
+
if (vTextureId < ${f}.5)`),`${p}
|
|
856
856
|
{
|
|
857
|
-
color = texture2D(samplers[${
|
|
857
|
+
color = texture2D(samplers[${f}], vUv);
|
|
858
858
|
}`}).join("")}
|
|
859
859
|
|
|
860
860
|
color += (1.0 - color.a) * vBackgroundColor;
|
|
@@ -864,6 +864,6 @@ void main(void) {
|
|
|
864
864
|
color += vColorMatrixOffset;
|
|
865
865
|
}
|
|
866
866
|
gl_FragColor = color;
|
|
867
|
-
}`}),s=r.buffer.create({target:"array_buffer",data:new Float32Array(1),usage:"dynamic_draw"}),o=r.buffer.create({target:"element_array_buffer",data:new Uint16Array(1),usage:"dynamic_draw"}),a={attributes:Object.fromEntries(Object.entries(this._attributes).map(([c,u])=>[c,{...u,buffer:s}])),elementArrayBuffer:o},l=r.vertexArray.create(i,a),h=new Int32Array(Array.from({length:t},(c,u)=>u));return{update:(c,u)=>{r.vertexArray.bind(l??a),r.buffer.update(s,{target:"array_buffer",data:c}),r.buffer.update(o,{target:"element_array_buffer",data:u})},draw:c=>{const u=this._renderer;u.program.bind(i),u.program.updateUniforms(i,{samplers:h,tint:[1,1,1,1],translationMatrix:[1,0,0,0,1,0,0,0,1],...u.program.uniforms}),u.vertexArray.bind(l??a),u.draw(c)}}}render(t){const{vertices:r,indices:i}=t,s=r.length/2;this._vertexCount+s>this._batchSize&&this.flush(),this._vertexCount+=s,this._indexCount+=i.length,this._batchables.push(t)}flush(){if(super.flush(),this._vertexCount===0)return;const t=this._vertexCount,r=this._indexCount,i=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const s=this._renderer.texture.maxUnits,o=this._getAttributeBuffer(t),a=new Float32Array(o),l=new Uint32Array(o),h=this._getIndexBuffer(r);let c=0,u=0;const f=[];for(let y=i.length,_={id:++this._drawCallUid},m=[],b=new Map,w=0,x=0,C=0;C<y;C++){const P=i[C].texture,E=C===y-1;if(!P||b.has(P)){if(!E)continue}else m.push(P),b.set(P,w++);if(E||w>=s){_.textures=m,_.textureLocationMap=b,w=0,_.first=u;for(let A=x;A<=C;A++){const{indices:S,vertices:T,uvs:O=[],texture:$,tint:N=this._defaultTint,backgroundColor:B=this._defaultBackgroundColor,colorMatrix:M=this._defaultColorMatrix,colorMatrixOffset:L=this._defaultColorMatrixOffset,blendMode:F=vr.NORMAL}=i[A],X=($?b.get($):-1)??-1;x<A&&_.blendMode!==F&&(_.count=u-_.first,f.push(_),x=A,_={id:++this._drawCallUid},_.textures=m,_.first=u);const q=c/this._vertexSize;for(let I=T.length,R=0;R<I;R+=2){a[c++]=X,a[c++]=T[R],a[c++]=T[R+1],a[c++]=O[R]??0,a[c++]=O[R+1]??0,l[c++]=N,l[c++]=B;for(let k=0;k<4;k++)a[c++]=L[k]??0;for(let k=0;k<16;k++)a[c++]=M[k]??0}for(let I=S.length,R=0;R<I;R++)h[u++]=q+S[R];_.blendMode=F}x=C+1,_.count=u-_.first,f.push(_),_={id:++this._drawCallUid},m=[],b=new Map}}const p=this._getShader(s);p.update(o,h);for(let y=f.length,_=0;_<y;_++){const m=f[_],{first:b=0,textures:w,textureLocationMap:x}=m;for(let C=w.length,P=0;P<C;P++){const E=w[P],A=x.get(E);A!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:A,value:E})}this._state.blendMode=m.blendMode,this._renderer.state.bind(this._state),p.draw({mode:"triangles",count:m.count,first:b,bytesPerElement:2})}}_getAttributeBuffer(t){const r=Un(Math.ceil(t/8)),i=In(r),s=r*8;this._attributeBuffer.length<=i&&(this._indexBuffers.length=i+1);let o=this._attributeBuffer[s];return o||(this._attributeBuffer[s]=o=new ArrayBuffer(s*this._vertexSize*4)),o}_getIndexBuffer(t){const r=Un(Math.ceil(t/12)),i=In(r),s=r*12;this._indexBuffers.length<=i&&(this._indexBuffers.length=i+1);let o=this._indexBuffers[i];return o||(this._indexBuffers[i]=o=new Uint16Array(s)),o}}function Un(n){return n+=n===0?1:0,--n,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n+1}function In(n){let e=(n>65535?1:0)<<4;n>>>=e;let t=(n>255?1:0)<<3;return n>>>=t,e|=t,t=(n>15?1:0)<<2,n>>>=t,e|=t,t=(n>3?1:0)<<1,n>>>=t,e|=t,e|n>>1}class _l extends ee{constructor(){super(...arguments);d(this,"boundArrayBuffer",null);d(this,"boundTarget","array_buffer")}install(t){super.install(t),t.buffer=this}create(t){const r=this.gl.createBuffer();if(!r)throw new Error("failed to create");return t&&(this.bind({target:t.target,value:r}),this.update(t)),r}getMeta(t){return this._renderer.getRelated(t,()=>({id:Dn(t),length:0,byteLength:0,bytesPerElement:0}))}update(...t){if(t.length>1){this.bind({target:t[1].target,value:t[0]}),this.update(t[1]);return}const r=t[0],i=(r.target??this.boundTarget)==="array_buffer"?this.boundArrayBuffer:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer;if(!i)return;const s=this.getMeta(i);Object.assign(s,{target:r.target,usage:r.usage});const o=s.target??this.boundTarget,a=s.usage??"static_draw",l=r.data,h=this.gl;let c;Array.isArray(l)?o==="array_buffer"?c=new Float32Array(l):c=new Uint32Array(l):c=l;const u=this._renderer.getBindPoint(o);c&&c.byteLength<=s.byteLength?h.bufferSubData(u,0,c):(h.bufferData(u,c,this._renderer.getBindPoint(a)),s.length=(c==null?void 0:c.length)??0,s.byteLength=(c==null?void 0:c.byteLength)??0,s.bytesPerElement=s.length?s.byteLength/s.length:0)}bind(t){let{target:r,value:i}=t;if(i){const o=this.getMeta(i);r??(r=o.target??this.boundTarget),o.target=r}else r??(r=this.boundTarget);const s=this._renderer.getBindPoint(r);this._renderer.gl.bindBuffer(s,i),r==="array_buffer"?this.boundArrayBuffer=i:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer=i,this.boundTarget=r}unbind(t){return this.bind({target:t,value:null})}reset(){super.reset(),this.boundArrayBuffer=null,this.boundTarget="array_buffer"}}class vl extends ee{constructor(){super(...arguments);d(this,"boundFramebuffer",null);d(this,"_msaaSamples",[]);d(this,"_hasMRT",!0);d(this,"_writeDepthTexture",!0)}install(t){super.install(t),t.framebuffer=this}onUpdateContext(){if(this._hasMRT=!0,this._writeDepthTexture=!0,this._renderer.version===1){const t=this._renderer.gl,r=this._renderer.extensions.drawBuffers,i=this._renderer.extensions.depthTexture;r?t.drawBuffers=s=>r.drawBuffersWEBGL(s):(this._hasMRT=!1,t.drawBuffers=()=>{}),i||(this._writeDepthTexture=!1)}else{const t=this._renderer.gl;this._msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}}create(t){const r=this._renderer.gl.createFramebuffer();if(!r)throw new Error("Unable to create framebuffer");return t&&(this.bind(r),this.update(t)),r}getMeta(t){return this._renderer.getRelated(t,()=>({width:0,height:0,mipLevel:0,stencil:!1,depth:!1,depthTexture:null,colorTextures:[],multisample:0}))}update(...t){if(t.length>1)return this.bind(t[0]),this.update(t[1]);const r=this.boundFramebuffer;if(!r)return;const i=t[0],s=this.getMeta(r);Object.assign(s,{...i});const o=this._renderer.gl;let a=s.colorTextures.length;"drawBuffers"in o||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=s.colorTextures[l];this._renderer.texture.bind({location:0,target:"texture_2d",value:h,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+l,o.TEXTURE_2D,h,s.mipLevel),this._renderer.texture.unbind(h)}if(a>1&&o.drawBuffers(s.colorTextures.map((l,h)=>o.COLOR_ATTACHMENT0+h)),s.depthTexture&&(this._renderer.version>1||this._renderer.extensions.depthTexture)&&(this._renderer.texture.bind({location:0,target:"texture_2d",value:s.depthTexture,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,s.depthTexture,s.mipLevel),this._renderer.texture.unbind(s.depthTexture)),(s.stencilBuffer||s.stencil||s.depth)&&!(s.depthTexture&&this._writeDepthTexture)){s.stencilBuffer??(s.stencilBuffer=o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,s.stencilBuffer);const{attachment:l,format:h}=this._getAttachmentAndFormat(s);s.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,s.multisample,h,s.width,s.height):o.renderbufferStorage(o.RENDERBUFFER,h,s.width*this._renderer.pixelRatio,s.height*this._renderer.pixelRatio),o.framebufferRenderbuffer(o.FRAMEBUFFER,l,o.RENDERBUFFER,s.stencilBuffer)}else s.stencilBuffer&&(o.deleteRenderbuffer(s.stencilBuffer),s.stencilBuffer=null)}_getAttachmentAndFormat(t){const r=this.gl;let i,s;return this._renderer.version===1?(i=r.DEPTH_STENCIL_ATTACHMENT,s=r.DEPTH_STENCIL):t.depth&&t.stencil?(i=r.DEPTH_STENCIL_ATTACHMENT,s=r.DEPTH24_STENCIL8):t.depth?(i=r.DEPTH_ATTACHMENT,s=r.DEPTH_COMPONENT24):(i=r.STENCIL_ATTACHMENT,s=r.STENCIL_INDEX8),{attachment:i,format:s}}resize(t,r,i){const s=this.gl,o=this.getMeta(t);if(Object.assign(o,{width:r,height:i}),o.stencil){const{format:l}=this._getAttachmentAndFormat(o);s.bindRenderbuffer(s.RENDERBUFFER,o.stencil),o.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,l,o.width,o.height):s.renderbufferStorage(s.RENDERBUFFER,l,o.width,o.height)}let a=o.colorTextures.length;s.drawBuffers||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=o.colorTextures[l];this._renderer.texture.update(h,{value:{pixels:null,width:o.width,height:o.height}}),l===0&&o.msaaBuffer&&(s.bindRenderbuffer(s.RENDERBUFFER,o.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,s.RGBA,o.width,o.height))}o.depthTexture&&this._renderer.texture.update(o.depthTexture,{value:{pixels:null,width:o.width,height:o.height}})}bind(t){const r=this._renderer.gl,i=t;if({value:this.boundFramebuffer!==i}.value&&(r.bindFramebuffer(r.FRAMEBUFFER,i),this.boundFramebuffer=i),i){const a=this.getMeta(i);for(let c=0;c<a.colorTextures.length;c++)this._renderer.texture.unbind(a.colorTextures[c]);a.depthTexture&&this._renderer.texture.unbind(a.depthTexture);const l=a.width>>a.mipLevel,h=a.height>>a.mipLevel;this._renderer.viewport.bind({x:0,y:0,width:l*this._renderer.pixelRatio,height:h*this._renderer.pixelRatio})}else this._renderer.viewport.bind({x:0,y:0,width:this._renderer.screen.width,height:this._renderer.screen.height})}forceStencil(){const t=this.boundFramebuffer;if(!t)return;const r=this.getMeta(t);if(!r||r.stencilBuffer)return;const i=this._renderer.gl;r.stencilBuffer=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,r.stencilBuffer);let s,o;this._renderer.version===1?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH_STENCIL):r.depth?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH24_STENCIL8):(s=i.STENCIL_ATTACHMENT,o=i.STENCIL_INDEX8),r.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,r.multisample,o,r.width*this._renderer.pixelRatio,r.height*this._renderer.pixelRatio):i.renderbufferStorage(i.RENDERBUFFER,o,r.width*this._renderer.pixelRatio,r.height*this._renderer.pixelRatio),i.framebufferRenderbuffer(i.FRAMEBUFFER,s,i.RENDERBUFFER,r.stencilBuffer)}reset(){super.reset(),this.boundFramebuffer=null}}class bl extends ee{constructor(){super(...arguments);d(this,"stack",[])}install(t){super.install(t),t.mask=this}get length(){return this.stack.length}get last(){return this.stack[this.length-1]}push(t,r){const i={source:t,mask:r};this.stack.push(i),typeof i.mask=="number"?this.pushColorMask(i):"render"in i.mask?this._renderer.stencil.push(i):this._renderer.scissor.push(i)}pop(t){const r=this.stack.pop();!r||r.source!==t||(typeof r.mask=="number"?this.popColorMask(r):"render"in r.mask?this._renderer.stencil.pop(r):this._renderer.scissor.pop(r))}pushColorMask(t){const r=t.preComputedColor??15,i=t.preComputedColor=r&t.mask;i!==r&&this.useColorMask(i)}popColorMask(t){const r=t.preComputedColor??15,i=this.length>0?this.last.preComputedColor??15:15;i!==r&&this.useColorMask(i)}useColorMask(t){this._renderer.gl.colorMask((t&1)!==0,(t&2)!==0,(t&4)!==0,(t&8)!==0)}}class xl extends ee{constructor(){super(...arguments);d(this,"boundProgram",null);d(this,"uniforms",{projectionMatrix:[1,0,0,0,1,0,0,0,1]})}install(t){super.install(t),t.program=this}create(t){const r=this.gl.createProgram();if(!r)throw new Error("Unable to create program");return t&&this.update(r,t),r}getMeta(t){return this._renderer.getRelated(t,()=>({attributes:new Map,uniforms:new Map,boundUniforms:new WeakMap}))}update(...t){if(t.length>1){const h=this.boundProgram;this.boundProgram=t[0],this.update(t[1]),this.boundProgram=h;return}const r=t[0],i=this.boundProgram;if(!i)return;const s=this.gl,o=this.getMeta(i),a=this.createShader(r.vert,"vertex_shader"),l=this.createShader(r.frag,"fragment_shader");if(s.attachShader(i,a),s.attachShader(i,l),s.linkProgram(i),s.deleteShader(a),s.deleteShader(l),!s.getProgramParameter(i,s.LINK_STATUS))throw new Error(`Unable to link program: ${s.getProgramInfoLog(i)}`);o.attributes.clear(),o.uniforms.clear();for(let h=s.getProgramParameter(i,s.ACTIVE_ATTRIBUTES),c=0;c<h;c++){const u=s.getActiveAttrib(i,c);if(!u||u.name.startsWith("gl_"))continue;const f=this._renderer.bindPoints.get(u.type)??String(u.type);o.attributes.set(u.name,{type:f,name:u.name,size:Op(f),location:s.getAttribLocation(i,u.name)})}for(let h=s.getProgramParameter(i,s.ACTIVE_UNIFORMS),c=0;c<h;c++){const u=s.getActiveUniform(i,c);if(!u)continue;const f=u.name.replace(/\[.*?\]$/,"");let p=s.getUniformLocation(i,f);p||(p=s.getUniformLocation(i,u.name)),o.uniforms.set(f,{name:f,index:c,type:this._renderer.bindPoints.get(u.type)??String(u.type),size:u.size,isArray:f!==u.name,location:p})}}bind(t){const r=this.gl;({value:this.boundProgram!==t}).value&&(r.useProgram(t),this.boundProgram=t)}createShader(t,r){const i=this.gl,s=i.createShader(this._renderer.getBindPoint(r));if(!s)throw new Error("Unable to create shader");if(i.shaderSource(s,t),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error(`Unable to compiling shader :
|
|
868
|
-
${
|
|
869
|
-
${i.getShaderInfoLog(s)}`);return s}updateUniforms(...t){if(t.length>1){this.bind(t[0]),this.updateUniforms(t[1]);return}const r=this.boundProgram;if(!r)return;const i=this.gl,s=t[0],{uniforms:o,boundUniforms:a}=this.getMeta(r);for(const l in s){const h=s[l],c=o.get(l);if(!c)continue;const{type:u,isArray:f,location:p}=c;if(!(!p||a.get(p)===h))switch(a.set(p,h),u){case"float":f?i.uniform1fv(p,h):i.uniform1f(p,h);break;case"unsigned_int":f?i.uniform1uiv(p,h):i.uniform1ui(p,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":f?i.uniform1iv(p,h):i.uniform1i(p,h);break;case"bool_vec2":case"int_vec2":i.uniform2iv(p,h);break;case"unsigned_int_vec2":i.uniform2uiv(p,h);break;case"float_vec2":i.uniform2fv(p,h);break;case"bool_vec3":case"int_vec3":i.uniform3iv(p,h);break;case"unsigned_int_vec3":i.uniform3uiv(p,h);break;case"float_vec3":i.uniform3fv(p,h);break;case"bool_vec4":case"int_vec4":i.uniform4iv(p,h);break;case"unsigned_int_vec4":i.uniform4uiv(p,h);break;case"float_vec4":i.uniform4fv(p,h);break;case"float_mat2":i.uniformMatrix2fv(p,!1,h);break;case"float_mat3":i.uniformMatrix3fv(p,!1,h);break;case"float_mat4":i.uniformMatrix4fv(p,!1,h);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={}}destroy(){super.destroy(),this.bind(null)}}function Op(n){switch(n){case"float":case"int":case"unsigned_int":case"bool":case"sampler_2d":return 1;case"float_vec2":case"int_vec2":case"unsigned_int_vec2":case"bool_vec2":return 2;case"float_vec3":case"int_vec3":case"unsigned_int_vec3":case"bool_vec3":return 3;case"float_vec4":case"int_vec4":case"unsigned_int_vec4":case"bool_vec4":case"float_mat2":return 4;case"float_mat3":return 9;case"float_mat4":return 16;default:return 1}}class wl extends ee{install(e){super.install(e),e.scissor=this}get length(){var e;return((e=this._renderer.mask.last)==null?void 0:e.scissorCounter)??0}push(e){const t=this._renderer.gl;t.enable(t.SCISSOR_TEST),e.scissorCounter??(e.scissorCounter=0),e.scissorCounter++,this.use()}pop(e){if(this.length>0)this.use();else{const t=this._renderer.gl;t.disable(t.SCISSOR_TEST)}}use(){const e=this._renderer,t=e.mask.last.mask;let r;e.viewport.boundViewport?r=e.viewport.boundViewport.height-t.height-t.y:r=e.screen.height-t.height-t.y,e.gl.scissor(t.x,r,t.width,t.height)}}class Pl extends ee{install(e){super.install(e),e.stencil=this}get length(){var e;return((e=this._renderer.mask.last)==null?void 0:e.stencilCounter)??0}push(e){const t=this._renderer.gl,r=e.mask,i=e.stencilCounter??(e.stencilCounter=0);e.stencilCounter===0&&(this._renderer.framebuffer.forceStencil(),t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.enable(t.STENCIL_TEST)),e.stencilCounter++;const s=e.color;s&&(e.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilFunc(t.EQUAL,i,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.INCR),r.render(this._renderer),this._renderer.flush(),s&&(e.color=s,t.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}pop(e){const t=this._renderer.gl,r=e.mask;if(!this.length)t.disable(t.STENCIL_TEST);else{const i=this._renderer.mask.last,s=(i==null?void 0:i.color)??15;s!==0&&(i.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),r.render(this._renderer),this._renderer.flush(),s!==0&&(i.color=s,t.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}}use(){const e=this._renderer.gl;e.stencilFunc(e.EQUAL,this.length,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}function Up(n,e){const t=new Set([...Object.keys(n),...Object.keys(e)]),r={};return t.forEach(i=>{r[i]=n[i]!==e[i]}),r}class Cl extends ee{constructor(){super(...arguments);d(this,"maxUnits",0);d(this,"boundLocation",0);d(this,"boundTarget","texture_2d");d(this,"boundTextures",[]);d(this,"emptyTextures",{texture_2d:null,texture_cube_map:null})}install(t){super.install(t),t.texture=this}onUpdateContext(){super.onUpdateContext();const t=this.gl;this.maxUnits=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(let s=0;s<this.maxUnits;s++)this.boundTextures[s]={texture_2d:null,texture_cube_map:null};const r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4));const i=t.createTexture();t.bindTexture(t.TEXTURE_CUBE_MAP,i);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),this.emptyTextures={texture_2d:r,texture_cube_map:i};for(let s=this.boundTextures.length,o=0;o<s;o++)this.unbind(o)}create(t){const r=this.gl.createTexture();if(!r)throw new Error("Unable to create texture");return t&&(this.bind({location:t.location,target:t.target,value:r,forceUpdateLocation:!0}),this.update({filterMode:"linear",wrapMode:"repeat",...t})),r}getMeta(t){return this._renderer.getRelated(t,()=>({}))}update(...t){if(t.length>1){this.bind({location:t[1].location,target:t[1].target,value:t[0],forceUpdateLocation:!0}),this.update(t[1]);return}const r=t[0],{value:i,...s}=r,o=this.boundTextures[this.boundLocation][r.target??this.boundTarget];if(!o)return;const a=this.gl,l=this.getMeta(o),h=Up(l,s);Object.assign(l,s);const c=this._renderer.getBindPoint(l.target??this.boundTarget);if(i!==void 0&&(i===null?a.texImage2D(c,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,null):"pixels"in i?a.texImage2D(c,0,a.RGBA,i.width,i.height,0,a.RGBA,a.UNSIGNED_BYTE,i.pixels):a.texImage2D(c,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i)),h.wrapMode&&l.wrapMode){const f=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,f),a.texParameteri(c,a.TEXTURE_WRAP_T,f)}const u=l.filterMode;if(h.filterMode&&u){const f=this._renderer.getBindPoint(u.split("_")[0]);u.includes("_")?a.texParameteri(c,a.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(u)):a.texParameteri(c,a.TEXTURE_MIN_FILTER,f),a.texParameteri(c,a.TEXTURE_MAG_FILTER,f)}if(l.anisoLevel&&u==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:f,TEXTURE_MAX_ANISOTROPY_EXT:p}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,p,Math.min(l.anisoLevel,a.getParameter(f)))}}bind(t){const r=this.gl;let i,s,o,a;if(t&&"value"in t?{target:s,value:i,location:o,forceUpdateLocation:a}=t:i=t,i){const y=this.getMeta(i);y.target=s??(s=y.target??"texture_2d"),y.location=o??(o=y.location??0)}else s??(s="texture_2d"),o??(o=0);let l=this.boundTextures[o];l||(this.boundTextures[o]=l={texture_2d:null,texture_cube_map:null});const h=l[s]??null,c=this.boundLocation,u=i!==h,f={location:o!==c&&(u||a),texture:u},p=this._renderer.getBindPoint(s);f.location&&(r.activeTexture(r.TEXTURE0+o),this.boundLocation=o),f.texture&&(r.bindTexture(p,i??this.emptyTextures[s]),l[s]=i),this.boundTarget=s}unbind(t,r="texture_2d"){const i=this._renderer.gl;if(typeof t=="number")this.bind({value:null,target:r,location:t});else{const s=this.getMeta(t),{target:o=this.boundTarget}=s,a=this._renderer.getBindPoint(o);for(let l=0;l<this.boundTextures.length;l++)this.boundTextures[l][o]===t&&(this.boundLocation!==l&&(i.activeTexture(i.TEXTURE0+l),this.boundLocation=l),i.bindTexture(a,this.emptyTextures[o]),this.boundTextures[l][o]=null)}}reset(){super.reset(),this.boundLocation=0,this.boundTarget="texture_2d",this.boundTextures=[],this.maxUnits=0}}class Tl extends ee{constructor(){super(...arguments);d(this,"boundVertexArrayNull",{attributes:{},elementArrayBuffer:null});d(this,"boundVertexArrayObject",null);d(this,"boundVertexArray",this.boundVertexArrayNull)}install(t){super.install(t),t.vertexArray=this}enableVertexAttrib(t,r,i,s=1){const{buffer:o,size:a=0,type:l="float",normalized:h=!1,stride:c=0,offset:u=0,divisor:f}=i,p=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let y=0;y<s;y++)p.enableVertexAttribArray(r+y),p.vertexAttribPointer(r+y,a,this._renderer.getBindPoint(l),h,c,u+(c-u)/s*y);f&&("vertexAttribDivisor"in p?p.vertexAttribDivisor(r,f):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[t]={enable:!0,...i}}create(...t){const r=this._renderer.gl;if(!("createVertexArray"in r))return null;const i=r.createVertexArray();if(!i)throw new Error("Unable to create vertex array");return t.length===2?this.update(t[0],i,t[1]):t.length===1&&this.update(i,t[0]),i}getVertexArrayMeta(t){return this._renderer.getRelated(t,()=>({attributes:{},elementArrayBuffer:null}))}update(...t){var o,a,l;if(t.length>2){this._renderer.program.bind(t[0]),this.update(t[1],t[2]);return}else if(t.length===2)if(t[0]){const h=t[0],c=t[1],u=this.getVertexArrayMeta(h);this.bind(h),this.update(c),u.attributes=this.boundVertexArray.attributes,u.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(t[1]);const r=this._renderer.program.boundProgram;if(!r)return;const i=t[0];if(i.attributes){const h=this._renderer.program.getMeta(r),c={},u={};for(const p in i.attributes){const y=i.attributes[p],_=h.attributes.get(p);let m;"buffer"in y?m={...y}:m={buffer:y},m.size=m.size||(_==null?void 0:_.size)||0;const b=this._renderer.buffer.getMeta(m.buffer),w=Number(((o=_==null?void 0:_.type.match(/mat(\d)/))==null?void 0:o[1])??1);let x;switch(m.type){case"unsigned_byte":x=m.size;break;case"unsigned_short":x=m.size*2;break;case"float":default:x=m.size*4;break}x*=w,c[a=b.id]??(c[a]=0),c[b.id]+=x,u[p]={attrib:m,meta:b,info:_,byteLength:x,dimension:w}}const f={};for(const p in u){const{attrib:y,meta:_,info:m,byteLength:b,dimension:w}=u[p];(m==null?void 0:m.location)!==void 0&&(f[l=_.id]??(f[l]=0),y.offset??(y.offset=f[_.id]),y.stride??(y.stride=c[_.id]===b?0:c[_.id]),this.enableVertexAttrib(p,m.location,y,w),f[_.id]+=b)}}const s=i.elementArrayBuffer??null;this._renderer.buffer.bind({target:"element_array_buffer",value:s}),this.boundVertexArray.elementArrayBuffer=s}bind(t){const r=this._renderer.gl;if(t&&"attributes"in t)this.update(t);else if("bindVertexArray"in r){const i=this.boundVertexArrayObject;({value:t!==i}).value&&(r.bindVertexArray(t),this.boundVertexArrayObject=t,t?this.boundVertexArray={...this.getVertexArrayMeta(t)}:this.boundVertexArray=this.boundVertexArrayNull)}}unbind(){return this.bind(null)}reset(){super.reset(),this.boundVertexArrayNull={attributes:{},elementArrayBuffer:null},this.boundVertexArray=this.boundVertexArrayNull,this.boundVertexArrayObject=null}}class El extends ee{constructor(){super(...arguments);d(this,"boundViewport",{x:0,y:0,width:0,height:0})}install(t){super.install(t),t.viewport=this}bind(t){const r=this.boundViewport,i=Math.floor(t.x),s=Math.floor(t.y),o=Math.floor(t.width),a=Math.floor(t.height);r.x===i&&r.y===s&&r.width===o&&r.height===a||(this._renderer.gl.viewport(i,s,o,a),r.x=i,r.y=s,r.width=o,r.height=a)}reset(){super.reset(),this.boundViewport={x:0,y:0,width:0,height:0}}}class Ml extends pl{constructor(t=Gn(),r){super();d(this,"_modules",[new Cl,new _l,new vl,new xl,new Tl,new El,new ml,new bl,new wl,new Pl,new yl]);d(this,"bindPoints",new Map);if(!t)throw new Error("Failed to createHTMLCanvas");Xn(t)?this._setupContext(t,r):(this.gl=t,this.version=jn(this.gl)?2:1),this._setupBindPoints()._setupExtensions()._setupPolyfill(),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._modules.forEach(i=>i.install(this)),this._modules.forEach(i=>i.onUpdateContext())}_setupContext(t,r){this.view=t;let i=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),s=2;if(i||(i=t.getContext("webgl",r)||t.getContext("experimental-webgl",r),s=1),!i)throw new Error("Unable to getContext");return this.gl=i,this.version=s,this._onContextLost=this._onContextLost.bind(this),this._onContextRestored=this._onContextRestored.bind(this),t.addEventListener("webglcontextlost",this._onContextLost,!1),t.addEventListener("webglcontextrestored",this._onContextRestored,!1),this}_setupExtensions(){const t=this.gl,r={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"),s3tcSRGB: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")};return this.version===1?(r.instancedArrays=t.getExtension("ANGLE_instanced_arrays"),r.drawBuffers=t.getExtension("WEBGL_draw_buffers"),r.depthTexture=t.getExtension("WEBGL_depth_texture"),r.vertexArrayObject=t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),r.uint32ElementIndex=t.getExtension("OES_element_index_uint"),r.floatTexture=t.getExtension("OES_texture_float"),r.textureHalfFloat=t.getExtension("OES_texture_half_float"),r.textureHalfFloatLinear=t.getExtension("OES_texture_half_float_linear")):this.version===2&&(r.colorBufferFloat=t.getExtension("EXT_color_buffer_float")),this.extensions=r,this}_setupBindPoints(){for(const t in this.gl)if(t===t.toUpperCase()){const r=this.gl[t];typeof r=="number"&&this.bindPoints.set(r,t.toLowerCase())}return this}_setupPolyfill(){if(this.version===1){const{instancedArrays:t,vertexArrayObject:r,drawBuffers:i}=this.extensions,s=this.gl;r&&(s.createVertexArray=()=>r.createVertexArrayOES(),s.bindVertexArray=o=>r.bindVertexArrayOES(o),s.deleteVertexArray=o=>r.deleteVertexArrayOES(o)),t&&(s.vertexAttribDivisor=(o,a)=>t.vertexAttribDivisorANGLE(o,a),s.drawElementsInstanced=(o,a,l,h,c)=>t.drawElementsInstancedANGLE(o,a,l,h,c),s.drawArraysInstanced=(o,a,l,h)=>t.drawArraysInstancedANGLE(o,a,l,h)),i&&(s.drawBuffers=o=>i.drawBuffersWEBGL(o))}return this}_onContextLost(t){t.preventDefault(),setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0)}_onContextRestored(){}getBindPoint(t){return this.gl[t.toUpperCase()]}clear(t=this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT){this.gl.clear(t)}draw(t={}){const{mode:r="triangles",first:i=0,instanceCount:s}=t;let{count:o=0,bytesPerElement:a=0}=t;if(!o||!a){const h=this.vertexArray.boundVertexArray.elementArrayBuffer??Object.values(this.vertexArray.boundVertexArray.attributes)[0];if(h){const c=this.buffer.getMeta(h);o||(o=c.length),a||(a=c.bytesPerElement)}}const l=this.getBindPoint(r);if(a)if(a===2||a===4&&this.extensions.uint32ElementIndex){const h=a===2?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT;s&&"drawElementsInstanced"in this.gl?this.gl.drawElementsInstanced(l,o,h,i*a,s):this.gl.drawElements(l,o,h,i*a)}else console.warn("Unsupported index buffer type: uint32");else s&&"drawArraysInstanced"in this.gl?this.gl.drawArraysInstanced(l,i,o,s):this.gl.drawArrays(l,i,o)}reset(){this._modules.forEach(t=>t.reset())}flush(){this._modules.forEach(t=>t.flush())}destroy(){var t,r,i;this._modules.forEach(s=>s.destroy()),(t=this.view)==null||t.removeEventListener("webglcontextlost",this._onContextLost,!1),(r=this.view)==null||r.removeEventListener("webglcontextrestored",this._onContextRestored,!1),(i=this.extensions.loseContext)==null||i.loseContext()}toPixels(){const t=this.gl.drawingBufferWidth,r=this.gl.drawingBufferHeight,i=t*r*4,s=t*4,o=(r-1)*s,a=new Uint8Array(i),l=new Uint8ClampedArray(i);this.gl.readPixels(0,0,t,r,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a);for(let h=0;h<i;h+=s)l.set(a.subarray(h,h+s),o-h);return l}}const Sl={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class Al extends vo{constructor(t={}){var c,u;const{view:r,width:i,height:s,pixelRatio:o=cs,background:a=0,autoResize:l,...h}=t;super();d(this,"input",new dl);d(this,"renderer");d(this,"_background",new Se);d(this,"_resizeObserver",kn?new ResizeObserver(t=>{const r=t[0];if(r.target===this.view){const{inlineSize:i,blockSize:s}=Array.isArray(r.contentBoxSize)?r.contentBoxSize[0]:r.contentBoxSize;this.resize(i,s)}}):void 0);this.renderer=new Ml(r,{...Sl,...h}),this._setupInput(),this.pixelRatio=o,this.background=a,l?this.enableAutoResize(l):this.resize(i||this.gl.drawingBufferWidth||((c=this.view)==null?void 0:c.clientWidth)||200,s||this.gl.drawingBufferHeight||((u=this.view)==null?void 0:u.clientHeight)||200)}get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(t){this.renderer.pixelRatio=t,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(t))}get background(){return this._background.value}set background(t){this._background.value=t}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(t=>{this.input.on(t,r=>{this.hasEventListener(t)&&(this.root.input(r),this.emit(t,r))})})),this}enableAutoResize(t=!0){var r,i;return this.view&&(t?(r=this._resizeObserver)==null||r.observe(this.view):(i=this._resizeObserver)==null||i.unobserve(this.view)),this}resize(t,r,i=!1){return this.renderer.resize(t,r,i),this.root.width=t,this.root.height=r,this.renderer.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this}nextTick(){return fs()}waitUntilLoad(){return we.waitUntilLoad()}render(t=0){return this.gl.clearColor(...this._background.toArray()),this._render(this.renderer,t)}start(){return this.render(),super.start(t=>{this.render(t)})}destroy(){this.stop(),this.root.getChildren(!0).forEach(t=>this.root.removeChild(t)),this.input.removeEventListeners(),this.enableAutoResize(!1),this.renderer.destroy()}toPixels(){return this.render(),this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){var s,o;const t=this.toImageData(),r=document.createElement("canvas");r.width=t.width,r.height=t.height,(s=r.getContext("2d"))==null||s.putImageData(t,0,0);const i=document.createElement("canvas");return i.width=this.width,i.height=this.height,(o=i.getContext("2d"))==null||o.drawImage(r,0,0,r.width,r.height,0,0,i.width,i.height),i}}let ii,Ip;const Ol=[];async function Dp(n=100){for(;;){const e=Ol.shift();if(e)try{await e()}catch(t){console.error(t)}else await new Promise(t=>setTimeout(t,n))}}async function Rp(n){ii??(ii=new Al({width:1,height:1}));const e=ii.root;e.removeChildren();const{data:t,width:r,height:i}=n;return ii.resize(r,i),(Array.isArray(t)?t:[t]).forEach(s=>{s instanceof g.Node?e.addChild(s):e.addChild(g.Node.parse(s))}),await ii.waitUntilLoad(),ii.toCanvas2D()}async function Bp(n){return Ip??(Ip=Dp()),new Promise(e=>{Ol.push(async()=>e(await Rp(n)))})}g.Assets=ko,g.AudioPipeline=Cn,g.AudioProcessor=gd,g.AudioSpectrum=wd,g.Bounds=vi,g.CanvasContext=Mt,g.Circle=di,g.Color=Se,g.ColorMatrix=Ns,g.ColorTexture=Fs,g.DEG_TO_RAD=po,g.DEVICE_PIXEL_RATIO=cs,g.EffectMaterial=Hi,g.Ellipse=Tr,g.Engine=Al,g.EventEmitter=ve,g.FontLoader=Oo,g.Geometry=hi,g.GifLoader=Uo,g.HTMLAudio=za,g.HTMLAudioContext=qi,g.HTMLSound=Yi,g.IN_BROWSER=Pr,g.Image2DResource=Pi,g.ImageTexture=Vh,g.IndexBuffer=nr,g.Input=dl,g.InternalMode=Ur,g.JsonLoader=Io,g.Loader=Ae,g.LottieLoader=Do,g.MainLoop=ui,g.Material=lt,g.Matrix=le,g.Matrix2=Uh,g.Matrix3=Ms,g.Matrix4=uo,g.MouseInputEvent=On,g.PI=Et,g.PI_2=at,g.Path2D=As,g.PixelsTexture=Os,g.Point=re,g.PointerInputEvent=fl,g.Polygon=Fe,g.Projection2D=fo,g.QuadGeometry=Wl,g.QuadUvGeometry=et,g.RAD_TO_DEG=Ih,g.Rectangle=Gt,g.Reference=ds,g.RenderStack=mo,g.Renderer=pl,g.Resource=Ee,g.RoundedRectangle=gi,g.SUPPORTS_AUDIO_CONTEXT=as,g.SUPPORTS_CLICK_EVENTS=Fn,g.SUPPORTS_CREATE_IMAGE_BITMAP=os,g.SUPPORTS_IMAGE_BITMAP=Ln,g.SUPPORTS_MOUSE_EVENTS=zl,g.SUPPORTS_OFFLINE_AUDIO_CONTEXT=hs,g.SUPPORTS_POINTER_EVENTS=sr,g.SUPPORTS_RESIZE_OBSERVER=kn,g.SUPPORTS_TOUCH_EVENTS=_e,g.SUPPORTS_WEBGL2=Bn,g.SUPPORTS_WEBKIT_AUDIO_CONTEXT=ls,g.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=$n,g.SUPPORTS_WEB_AUDIO=zn,g.SUPPORTS_WHEEL_EVENTS=Nn,g.SVGPath=co,g.SceneTree=vo,g.Star=ah,g.Style2D=ce,g.Style2DBackgroundModule=No,g.Style2DFilterModule=Fo,g.Style2DModule=hr,g.Style2DOffsetModule=zo,g.Style2DTextModule=Vo,g.Style2DTransformModule=Xo,g.TextLoader=Ro,g.Texture=pt,g.TextureLoader=Bo,g.Ticker=ft,g.Transform2D=qt,g.Triangle=bs,g.UIInputEvent=Zi,g.UvGeometry=Hl,g.UvMaterial=ci,g.Vector=ie,g.Vector2=Rh,g.Vector3=Bh,g.Vector4=go,g.VertexAttribute=jt,g.VertexBuffer=be,g.VideoLoader=Lo,g.VideoTexture=_o,g.ViewportTexture=Is,g.WebAudio=Xa,g.WebAudioContext=Le,g.WebGLBatch2DModule=yl,g.WebGLBlendMode=vr,g.WebGLBufferModule=_l,g.WebGLFramebufferModule=vl,g.WebGLMaskModule=bl,g.WebGLModule=ee,g.WebGLProgramModule=xl,g.WebGLRenderer=Ml,g.WebGLScissorModule=wl,g.WebGLState=tr,g.WebGLStateModule=ml,g.WebGLStencilModule=Pl,g.WebGLTextureModule=Cl,g.WebGLVertexArrayModule=Tl,g.WebGLViewportModule=El,g.WebSound=Va,g.WheelInputEvent=ri,g._Object=li,g.assets=we,g.buildAdaptiveBezier=ps,g.buildAdaptiveQuadratic=Qn,g.buildArc=ys,g.buildArcTo=sh,g.buildArcToSvg=to,g.buildCircle=$e,g.buildLine=lo,g.buildPolygon=Cs,g.buildRectangle=Ts,g.buildTriangle=Es,g.clamp=Me,g.closePointEps=oo,g.createHTMLCanvas=Gn,g.createNode=Xl,g.crossOrigin=Yn,g.cubicBezier=cr,g.curveEps=Ps,g.curves=Dh,g.customNode=Z,g.customNodes=oi,g.defaultOptions=Sl,g.defineProperty=W,g.determineCrossOrigin=qn,g.ease=Go,g.easeIn=qo,g.easeInOut=Wo,g.easeOut=Yo,g.getDeclarations=ai,g.getDefaultCssPropertyValue=ns,g.isCanvasElement=Xn,g.isElementNode=us,g.isImageElement=Vl,g.isPow2=ss,g.isVideoElement=Vn,g.isWebgl2=jn,g.lerp=dt,g.linear=jo,g.log2=In,g.mapWebGLBlendModes=gl,g.nextPow2=Un,g.nextTick=fs,g.parseCssFunctions=wr,g.parseCssProperty=xr,g.property=U,g.protectedProperty=nt,g.render=Bp,g.squaredDistanceToLineSegment=Er,g.timingFunctions=wi,g.uid=Dn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
867
|
+
}`}),s=t.buffer.create({target:"array_buffer",data:new Float32Array(1),usage:"dynamic_draw"}),o=t.buffer.create({target:"element_array_buffer",data:new Uint16Array(1),usage:"dynamic_draw"}),a={attributes:Object.fromEntries(Object.entries(this._attributes).map(([c,f])=>[c,{...f,buffer:s}])),elementArrayBuffer:o},l=t.vertexArray.create(i,a),h=new Int32Array(Array.from({length:e},(c,f)=>f));return{update:(c,f)=>{t.vertexArray.bind(l??a),t.buffer.update(s,{target:"array_buffer",data:c}),t.buffer.update(o,{target:"element_array_buffer",data:f})},draw:c=>{const f=this._renderer;f.program.bind(i),f.program.updateUniforms(i,{samplers:h,tint:[1,1,1,1],translationMatrix:[1,0,0,0,1,0,0,0,1],...f.program.uniforms}),f.vertexArray.bind(l??a),f.draw(c)}}}render(e){const{vertices:t,indices:i}=e,s=t.length/2;this._vertexCount+s>this._batchSize&&this.flush(),this._vertexCount+=s,this._indexCount+=i.length,this._batchables.push(e)}flush(){if(super.flush(),this._vertexCount===0)return;const e=this._vertexCount,t=this._indexCount,i=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const s=this._renderer.texture.maxUnits,o=this._getAttributeBuffer(e),a=new Float32Array(o),l=new Uint32Array(o),h=this._getIndexBuffer(t);let c=0,f=0;const p=[];for(let m=i.length,v={id:++this._drawCallUid},y=[],S=new Map,C=0,x=0,T=0;T<m;T++){const b=i[T].texture,P=T===m-1;if(!b||S.has(b)){if(!P)continue}else y.push(b),S.set(b,C++);if(P||C>=s){v.textures=y,v.textureLocationMap=S,C=0,v.first=f;for(let E=x;E<=T;E++){const{indices:w,vertices:D,uvs:F=[],texture:B,tint:U=this._defaultTint,backgroundColor:V=this._defaultBackgroundColor,colorMatrix:M=this._defaultColorMatrix,colorMatrixOffset:N=this._defaultColorMatrixOffset,blendMode:q=fr.NORMAL}=i[E],R=(B?S.get(B):-1)??-1;x<E&&v.blendMode!==q&&(v.count=f-v.first,p.push(v),x=E,v={id:++this._drawCallUid},v.textures=y,v.first=f);const I=c/this._vertexSize;for(let j=D.length,k=0;k<j;k+=2){a[c++]=R,a[c++]=D[k],a[c++]=D[k+1],a[c++]=F[k]??0,a[c++]=F[k+1]??0,l[c++]=U,l[c++]=V;for(let L=0;L<4;L++)a[c++]=N[L]??0;for(let L=0;L<16;L++)a[c++]=M[L]??0}for(let j=w.length,k=0;k<j;k++)h[f++]=I+w[k];v.blendMode=q}x=T+1,v.count=f-v.first,p.push(v),v={id:++this._drawCallUid},y=[],S=new Map}}const d=this._getShader(s);d.update(o,h);for(let m=p.length,v=0;v<m;v++){const y=p[v],{first:S=0,textures:C,textureLocationMap:x}=y;for(let T=C.length,b=0;b<T;b++){const P=C[b],E=x.get(P);E!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:E,value:P})}this._state.blendMode=y.blendMode,this._renderer.state.bind(this._state),d.draw({mode:"triangles",count:y.count,first:S,bytesPerElement:2})}}_getAttributeBuffer(e){const t=an(Math.ceil(e/8)),i=ln(t),s=t*8;this._attributeBuffer.length<=i&&(this._indexBuffers.length=i+1);let o=this._attributeBuffer[s];return o||(this._attributeBuffer[s]=o=new ArrayBuffer(s*this._vertexSize*4)),o}_getIndexBuffer(e){const t=an(Math.ceil(e/12)),i=ln(t),s=t*12;this._indexBuffers.length<=i&&(this._indexBuffers.length=i+1);let o=this._indexBuffers[i];return o||(this._indexBuffers[i]=o=new Uint16Array(s)),o}}function an(n){return n+=n===0?1:0,--n,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n+1}function ln(n){let r=(n>65535?1:0)<<4;n>>>=r;let e=(n>255?1:0)<<3;return n>>>=e,r|=e,e=(n>15?1:0)<<2,n>>>=e,r|=e,e=(n>3?1:0)<<1,n>>>=e,r|=e,r|n>>1}class Ga extends Ye{constructor(){super(...arguments);u(this,"boundArrayBuffer",null);u(this,"boundTarget","array_buffer")}install(e){super.install(e),e.buffer=this}create(e){const t=this.gl.createBuffer();if(!t)throw new Error("failed to create");return e&&(this.bind({target:e.target,value:t}),this.update(e)),t}getMeta(e){return this._renderer.getRelated(e,()=>({id:hn(e),length:0,byteLength:0,bytesPerElement:0}))}update(...e){if(e.length>1){this.bind({target:e[1].target,value:e[0]}),this.update(e[1]);return}const t=e[0],i=(t.target??this.boundTarget)==="array_buffer"?this.boundArrayBuffer:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer;if(!i)return;const s=this.getMeta(i);Object.assign(s,{target:t.target,usage:t.usage});const o=s.target??this.boundTarget,a=s.usage??"static_draw",l=t.data,h=this.gl;let c;Array.isArray(l)?o==="array_buffer"?c=new Float32Array(l):c=new Uint32Array(l):c=l;const f=this._renderer.getBindPoint(o);c&&c.byteLength<=s.byteLength?h.bufferSubData(f,0,c):(h.bufferData(f,c,this._renderer.getBindPoint(a)),s.length=(c==null?void 0:c.length)??0,s.byteLength=(c==null?void 0:c.byteLength)??0,s.bytesPerElement=s.length?s.byteLength/s.length:0)}bind(e){let{target:t,value:i}=e;if(i){const o=this.getMeta(i);t??(t=o.target??this.boundTarget),o.target=t}else t??(t=this.boundTarget);const s=this._renderer.getBindPoint(t);this._renderer.gl.bindBuffer(s,i),t==="array_buffer"?this.boundArrayBuffer=i:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer=i,this.boundTarget=t}unbind(e){return this.bind({target:e,value:null})}reset(){super.reset(),this.boundArrayBuffer=null,this.boundTarget="array_buffer"}}class qa extends Ye{constructor(){super(...arguments);u(this,"boundFramebuffer",null);u(this,"_msaaSamples",[]);u(this,"_hasMRT",!0);u(this,"_writeDepthTexture",!0)}install(e){super.install(e),e.framebuffer=this}onUpdateContext(){if(this._hasMRT=!0,this._writeDepthTexture=!0,this._renderer.version===1){const e=this._renderer.gl,t=this._renderer.extensions.drawBuffers,i=this._renderer.extensions.depthTexture;t?e.drawBuffers=s=>t.drawBuffersWEBGL(s):(this._hasMRT=!1,e.drawBuffers=()=>{}),i||(this._writeDepthTexture=!1)}else{const e=this._renderer.gl;this._msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}}create(e){const t=this._renderer.gl.createFramebuffer();if(!t)throw new Error("Unable to create framebuffer");return e&&(this.bind(t),this.update(e)),t}getMeta(e){return this._renderer.getRelated(e,()=>({width:0,height:0,mipLevel:0,stencil:!1,depth:!1,depthTexture:null,colorTextures:[],multisample:0}))}update(...e){if(e.length>1)return this.bind(e[0]),this.update(e[1]);const t=this.boundFramebuffer;if(!t)return;const i=e[0],s=this.getMeta(t);Object.assign(s,{...i});const o=this._renderer.gl;let a=s.colorTextures.length;"drawBuffers"in o||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=s.colorTextures[l];this._renderer.texture.bind({location:0,target:"texture_2d",value:h,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0+l,o.TEXTURE_2D,h,s.mipLevel),this._renderer.texture.unbind(h)}if(a>1&&o.drawBuffers(s.colorTextures.map((l,h)=>o.COLOR_ATTACHMENT0+h)),s.depthTexture&&(this._renderer.version>1||this._renderer.extensions.depthTexture)&&(this._renderer.texture.bind({location:0,target:"texture_2d",value:s.depthTexture,forceUpdateLocation:!0}),o.framebufferTexture2D(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.TEXTURE_2D,s.depthTexture,s.mipLevel),this._renderer.texture.unbind(s.depthTexture)),(s.stencilBuffer||s.stencil||s.depth)&&!(s.depthTexture&&this._writeDepthTexture)){s.stencilBuffer??(s.stencilBuffer=o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,s.stencilBuffer);const{attachment:l,format:h}=this._getAttachmentAndFormat(s);s.msaaBuffer?o.renderbufferStorageMultisample(o.RENDERBUFFER,s.multisample,h,s.width,s.height):o.renderbufferStorage(o.RENDERBUFFER,h,s.width*this._renderer.pixelRatio,s.height*this._renderer.pixelRatio),o.framebufferRenderbuffer(o.FRAMEBUFFER,l,o.RENDERBUFFER,s.stencilBuffer)}else s.stencilBuffer&&(o.deleteRenderbuffer(s.stencilBuffer),s.stencilBuffer=null)}_getAttachmentAndFormat(e){const t=this.gl;let i,s;return this._renderer.version===1?(i=t.DEPTH_STENCIL_ATTACHMENT,s=t.DEPTH_STENCIL):e.depth&&e.stencil?(i=t.DEPTH_STENCIL_ATTACHMENT,s=t.DEPTH24_STENCIL8):e.depth?(i=t.DEPTH_ATTACHMENT,s=t.DEPTH_COMPONENT24):(i=t.STENCIL_ATTACHMENT,s=t.STENCIL_INDEX8),{attachment:i,format:s}}resize(e,t,i){const s=this.gl,o=this.getMeta(e);if(Object.assign(o,{width:t,height:i}),o.stencil){const{format:l}=this._getAttachmentAndFormat(o);s.bindRenderbuffer(s.RENDERBUFFER,o.stencil),o.msaaBuffer?s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,l,o.width,o.height):s.renderbufferStorage(s.RENDERBUFFER,l,o.width,o.height)}let a=o.colorTextures.length;s.drawBuffers||(a=Math.min(a,1));for(let l=0;l<a;l++){const h=o.colorTextures[l];this._renderer.texture.update(h,{value:{pixels:null,width:o.width,height:o.height}}),l===0&&o.msaaBuffer&&(s.bindRenderbuffer(s.RENDERBUFFER,o.msaaBuffer),s.renderbufferStorageMultisample(s.RENDERBUFFER,o.multisample,s.RGBA,o.width,o.height))}o.depthTexture&&this._renderer.texture.update(o.depthTexture,{value:{pixels:null,width:o.width,height:o.height}})}bind(e){const t=this._renderer.gl,i=e;if({value:this.boundFramebuffer!==i}.value&&(t.bindFramebuffer(t.FRAMEBUFFER,i),this.boundFramebuffer=i),i){const a=this.getMeta(i);for(let c=0;c<a.colorTextures.length;c++)this._renderer.texture.unbind(a.colorTextures[c]);a.depthTexture&&this._renderer.texture.unbind(a.depthTexture);const l=a.width>>a.mipLevel,h=a.height>>a.mipLevel;this._renderer.viewport.bind({x:0,y:0,width:l*this._renderer.pixelRatio,height:h*this._renderer.pixelRatio})}else this._renderer.viewport.bind({x:0,y:0,width:this._renderer.screen.width,height:this._renderer.screen.height})}forceStencil(){const e=this.boundFramebuffer;if(!e)return;const t=this.getMeta(e);if(!t||t.stencilBuffer)return;const i=this._renderer.gl;t.stencilBuffer=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,t.stencilBuffer);let s,o;this._renderer.version===1?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH_STENCIL):t.depth?(s=i.DEPTH_STENCIL_ATTACHMENT,o=i.DEPTH24_STENCIL8):(s=i.STENCIL_ATTACHMENT,o=i.STENCIL_INDEX8),t.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,t.multisample,o,t.width*this._renderer.pixelRatio,t.height*this._renderer.pixelRatio):i.renderbufferStorage(i.RENDERBUFFER,o,t.width*this._renderer.pixelRatio,t.height*this._renderer.pixelRatio),i.framebufferRenderbuffer(i.FRAMEBUFFER,s,i.RENDERBUFFER,t.stencilBuffer)}reset(){super.reset(),this.boundFramebuffer=null}}class Wa extends Ye{constructor(){super(...arguments);u(this,"stack",[])}install(e){super.install(e),e.mask=this}get length(){return this.stack.length}get last(){return this.stack[this.length-1]}push(e,t){const i={source:e,mask:t};this.stack.push(i),typeof i.mask=="number"?this.pushColorMask(i):"render"in i.mask?this._renderer.stencil.push(i):this._renderer.scissor.push(i)}pop(e){const t=this.stack.pop();!t||t.source!==e||(typeof t.mask=="number"?this.popColorMask(t):"render"in t.mask?this._renderer.stencil.pop(t):this._renderer.scissor.pop(t))}pushColorMask(e){const t=e.preComputedColor??15,i=e.preComputedColor=t&e.mask;i!==t&&this.useColorMask(i)}popColorMask(e){const t=e.preComputedColor??15,i=this.length>0?this.last.preComputedColor??15:15;i!==t&&this.useColorMask(i)}useColorMask(e){this._renderer.gl.colorMask((e&1)!==0,(e&2)!==0,(e&4)!==0,(e&8)!==0)}}class Xa extends Ye{constructor(){super(...arguments);u(this,"boundProgram",null);u(this,"uniforms",{projectionMatrix:[1,0,0,0,1,0,0,0,1]})}install(e){super.install(e),e.program=this}create(e){const t=this.gl.createProgram();if(!t)throw new Error("Unable to create program");return e&&this.update(t,e),t}getMeta(e){return this._renderer.getRelated(e,()=>({attributes:new Map,uniforms:new Map,boundUniforms:new WeakMap}))}update(...e){if(e.length>1){const h=this.boundProgram;this.boundProgram=e[0],this.update(e[1]),this.boundProgram=h;return}const t=e[0],i=this.boundProgram;if(!i)return;const s=this.gl,o=this.getMeta(i),a=this.createShader(t.vert,"vertex_shader"),l=this.createShader(t.frag,"fragment_shader");if(s.attachShader(i,a),s.attachShader(i,l),s.linkProgram(i),s.deleteShader(a),s.deleteShader(l),!s.getProgramParameter(i,s.LINK_STATUS))throw new Error(`Unable to link program: ${s.getProgramInfoLog(i)}`);o.attributes.clear(),o.uniforms.clear();for(let h=s.getProgramParameter(i,s.ACTIVE_ATTRIBUTES),c=0;c<h;c++){const f=s.getActiveAttrib(i,c);if(!f||f.name.startsWith("gl_"))continue;const p=this._renderer.bindPoints.get(f.type)??String(f.type);o.attributes.set(f.name,{type:p,name:f.name,size:Xd(p),location:s.getAttribLocation(i,f.name)})}for(let h=s.getProgramParameter(i,s.ACTIVE_UNIFORMS),c=0;c<h;c++){const f=s.getActiveUniform(i,c);if(!f)continue;const p=f.name.replace(/\[.*?\]$/,"");let d=s.getUniformLocation(i,p);d||(d=s.getUniformLocation(i,f.name)),o.uniforms.set(p,{name:p,index:c,type:this._renderer.bindPoints.get(f.type)??String(f.type),size:f.size,isArray:p!==f.name,location:d})}}bind(e){const t=this.gl;({value:this.boundProgram!==e}).value&&(t.useProgram(e),this.boundProgram=e)}createShader(e,t){const i=this.gl,s=i.createShader(this._renderer.getBindPoint(t));if(!s)throw new Error("Unable to create shader");if(i.shaderSource(s,e),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error(`Unable to compiling shader :
|
|
868
|
+
${e}
|
|
869
|
+
${i.getShaderInfoLog(s)}`);return s}updateUniforms(...e){if(e.length>1){this.bind(e[0]),this.updateUniforms(e[1]);return}const t=this.boundProgram;if(!t)return;const i=this.gl,s=e[0],{uniforms:o,boundUniforms:a}=this.getMeta(t);for(const l in s){const h=s[l],c=o.get(l);if(!c)continue;const{type:f,isArray:p,location:d}=c;if(!(!d||a.get(d)===h))switch(a.set(d,h),f){case"float":p?i.uniform1fv(d,h):i.uniform1f(d,h);break;case"unsigned_int":p?i.uniform1uiv(d,h):i.uniform1ui(d,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":p?i.uniform1iv(d,h):i.uniform1i(d,h);break;case"bool_vec2":case"int_vec2":i.uniform2iv(d,h);break;case"unsigned_int_vec2":i.uniform2uiv(d,h);break;case"float_vec2":i.uniform2fv(d,h);break;case"bool_vec3":case"int_vec3":i.uniform3iv(d,h);break;case"unsigned_int_vec3":i.uniform3uiv(d,h);break;case"float_vec3":i.uniform3fv(d,h);break;case"bool_vec4":case"int_vec4":i.uniform4iv(d,h);break;case"unsigned_int_vec4":i.uniform4uiv(d,h);break;case"float_vec4":i.uniform4fv(d,h);break;case"float_mat2":i.uniformMatrix2fv(d,!1,h);break;case"float_mat3":i.uniformMatrix3fv(d,!1,h);break;case"float_mat4":i.uniformMatrix4fv(d,!1,h);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={}}destroy(){super.destroy(),this.bind(null)}}function Xd(n){switch(n){case"float":case"int":case"unsigned_int":case"bool":case"sampler_2d":return 1;case"float_vec2":case"int_vec2":case"unsigned_int_vec2":case"bool_vec2":return 2;case"float_vec3":case"int_vec3":case"unsigned_int_vec3":case"bool_vec3":return 3;case"float_vec4":case"int_vec4":case"unsigned_int_vec4":case"bool_vec4":case"float_mat2":return 4;case"float_mat3":return 9;case"float_mat4":return 16;default:return 1}}class Ha extends Ye{install(r){super.install(r),r.scissor=this}get length(){var r;return((r=this._renderer.mask.last)==null?void 0:r.scissorCounter)??0}push(r){const e=this._renderer.gl;e.enable(e.SCISSOR_TEST),r.scissorCounter??(r.scissorCounter=0),r.scissorCounter++,this.use()}pop(r){if(this.length>0)this.use();else{const e=this._renderer.gl;e.disable(e.SCISSOR_TEST)}}use(){const r=this._renderer,e=r.mask.last.mask;let t;r.viewport.boundViewport?t=r.viewport.boundViewport.height-e.height-e.y:t=r.screen.height-e.height-e.y,r.gl.scissor(e.x,t,e.width,e.height)}}class Ya extends Ye{install(r){super.install(r),r.stencil=this}get length(){var r;return((r=this._renderer.mask.last)==null?void 0:r.stencilCounter)??0}push(r){const e=this._renderer.gl,t=r.mask,i=r.stencilCounter??(r.stencilCounter=0);r.stencilCounter===0&&(this._renderer.framebuffer.forceStencil(),e.clearStencil(0),e.clear(e.STENCIL_BUFFER_BIT),e.enable(e.STENCIL_TEST)),r.stencilCounter++;const s=r.color;s&&(r.color=0,e.colorMask(!1,!1,!1,!1)),e.stencilFunc(e.EQUAL,i,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.INCR),t.render(this._renderer),this._renderer.flush(),s&&(r.color=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}pop(r){const e=this._renderer.gl,t=r.mask;if(!this.length)e.disable(e.STENCIL_TEST);else{const i=this._renderer.mask.last,s=(i==null?void 0:i.color)??15;s!==0&&(i.color=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.render(this._renderer),this._renderer.flush(),s!==0&&(i.color=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this.use()}}use(){const r=this._renderer.gl;r.stencilFunc(r.EQUAL,this.length,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}}function Hd(n,r){const e=new Set([...Object.keys(n),...Object.keys(r)]),t={};return e.forEach(i=>{t[i]=n[i]!==r[i]}),t}class Za extends Ye{constructor(){super(...arguments);u(this,"maxUnits",0);u(this,"boundLocation",0);u(this,"boundTarget","texture_2d");u(this,"boundTextures",[]);u(this,"emptyTextures",{texture_2d:null,texture_cube_map:null})}install(e){super.install(e),e.texture=this}onUpdateContext(){super.onUpdateContext();const e=this.gl;this.maxUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(let s=0;s<this.maxUnits;s++)this.boundTextures[s]={texture_2d:null,texture_cube_map:null};const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4));const i=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,i);for(let s=0;s<6;s++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR),this.emptyTextures={texture_2d:t,texture_cube_map:i};for(let s=this.boundTextures.length,o=0;o<s;o++)this.unbind(o)}create(e){const t=this.gl.createTexture();if(!t)throw new Error("Unable to create texture");return e&&(this.bind({location:e.location,target:e.target,value:t,forceUpdateLocation:!0}),this.update({filterMode:"linear",wrapMode:"repeat",...e})),t}getMeta(e){return this._renderer.getRelated(e,()=>({}))}update(...e){if(e.length>1){this.bind({location:e[1].location,target:e[1].target,value:e[0],forceUpdateLocation:!0}),this.update(e[1]);return}const t=e[0],{value:i,...s}=t,o=this.boundTextures[this.boundLocation][t.target??this.boundTarget];if(!o)return;const a=this.gl,l=this.getMeta(o),h=Hd(l,s);Object.assign(l,s);const c=this._renderer.getBindPoint(l.target??this.boundTarget);if(i!==void 0&&(i===null?a.texImage2D(c,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,null):"pixels"in i?a.texImage2D(c,0,a.RGBA,i.width,i.height,0,a.RGBA,a.UNSIGNED_BYTE,i.pixels):a.texImage2D(c,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i)),h.wrapMode&&l.wrapMode){const p=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,p),a.texParameteri(c,a.TEXTURE_WRAP_T,p)}const f=l.filterMode;if(h.filterMode&&f){const p=this._renderer.getBindPoint(f.split("_")[0]);f.includes("_")?a.texParameteri(c,a.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(f)):a.texParameteri(c,a.TEXTURE_MIN_FILTER,p),a.texParameteri(c,a.TEXTURE_MAG_FILTER,p)}if(l.anisoLevel&&f==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:p,TEXTURE_MAX_ANISOTROPY_EXT:d}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,d,Math.min(l.anisoLevel,a.getParameter(p)))}}bind(e){const t=this.gl;let i,s,o,a;if(e&&"value"in e?{target:s,value:i,location:o,forceUpdateLocation:a}=e:i=e,i){const m=this.getMeta(i);m.target=s??(s=m.target??"texture_2d"),m.location=o??(o=m.location??0)}else s??(s="texture_2d"),o??(o=0);let l=this.boundTextures[o];l||(this.boundTextures[o]=l={texture_2d:null,texture_cube_map:null});const h=l[s]??null,c=this.boundLocation,f=i!==h,p={location:o!==c&&(f||a),texture:f},d=this._renderer.getBindPoint(s);p.location&&(t.activeTexture(t.TEXTURE0+o),this.boundLocation=o),p.texture&&(t.bindTexture(d,i??this.emptyTextures[s]),l[s]=i),this.boundTarget=s}unbind(e,t="texture_2d"){const i=this._renderer.gl;if(typeof e=="number")this.bind({value:null,target:t,location:e});else{const s=this.getMeta(e),{target:o=this.boundTarget}=s,a=this._renderer.getBindPoint(o);for(let l=0;l<this.boundTextures.length;l++)this.boundTextures[l][o]===e&&(this.boundLocation!==l&&(i.activeTexture(i.TEXTURE0+l),this.boundLocation=l),i.bindTexture(a,this.emptyTextures[o]),this.boundTextures[l][o]=null)}}reset(){super.reset(),this.boundLocation=0,this.boundTarget="texture_2d",this.boundTextures=[],this.maxUnits=0}}class Ka extends Ye{constructor(){super(...arguments);u(this,"boundVertexArrayNull",{attributes:{},elementArrayBuffer:null});u(this,"boundVertexArrayObject",null);u(this,"boundVertexArray",this.boundVertexArrayNull)}install(e){super.install(e),e.vertexArray=this}enableVertexAttrib(e,t,i,s=1){const{buffer:o,size:a=0,type:l="float",normalized:h=!1,stride:c=0,offset:f=0,divisor:p}=i,d=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let m=0;m<s;m++)d.enableVertexAttribArray(t+m),d.vertexAttribPointer(t+m,a,this._renderer.getBindPoint(l),h,c,f+(c-f)/s*m);p&&("vertexAttribDivisor"in d?d.vertexAttribDivisor(t,p):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[e]={enable:!0,...i}}create(...e){const t=this._renderer.gl;if(!("createVertexArray"in t))return null;const i=t.createVertexArray();if(!i)throw new Error("Unable to create vertex array");return e.length===2?this.update(e[0],i,e[1]):e.length===1&&this.update(i,e[0]),i}getVertexArrayMeta(e){return this._renderer.getRelated(e,()=>({attributes:{},elementArrayBuffer:null}))}update(...e){var o,a,l;if(e.length>2){this._renderer.program.bind(e[0]),this.update(e[1],e[2]);return}else if(e.length===2)if(e[0]){const h=e[0],c=e[1],f=this.getVertexArrayMeta(h);this.bind(h),this.update(c),f.attributes=this.boundVertexArray.attributes,f.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(e[1]);const t=this._renderer.program.boundProgram;if(!t)return;const i=e[0];if(i.attributes){const h=this._renderer.program.getMeta(t),c={},f={};for(const d in i.attributes){const m=i.attributes[d],v=h.attributes.get(d);let y;"buffer"in m?y={...m}:y={buffer:m},y.size=y.size||(v==null?void 0:v.size)||0;const S=this._renderer.buffer.getMeta(y.buffer),C=Number(((o=v==null?void 0:v.type.match(/mat(\d)/))==null?void 0:o[1])??1);let x;switch(y.type){case"unsigned_byte":x=y.size;break;case"unsigned_short":x=y.size*2;break;case"float":default:x=y.size*4;break}x*=C,c[a=S.id]??(c[a]=0),c[S.id]+=x,f[d]={attrib:y,meta:S,info:v,byteLength:x,dimension:C}}const p={};for(const d in f){const{attrib:m,meta:v,info:y,byteLength:S,dimension:C}=f[d];(y==null?void 0:y.location)!==void 0&&(p[l=v.id]??(p[l]=0),m.offset??(m.offset=p[v.id]),m.stride??(m.stride=c[v.id]===S?0:c[v.id]),this.enableVertexAttrib(d,y.location,m,C),p[v.id]+=S)}}const s=i.elementArrayBuffer??null;this._renderer.buffer.bind({target:"element_array_buffer",value:s}),this.boundVertexArray.elementArrayBuffer=s}bind(e){const t=this._renderer.gl;if(e&&"attributes"in e)this.update(e);else if("bindVertexArray"in t){const i=this.boundVertexArrayObject;({value:e!==i}).value&&(t.bindVertexArray(e),this.boundVertexArrayObject=e,e?this.boundVertexArray={...this.getVertexArrayMeta(e)}:this.boundVertexArray=this.boundVertexArrayNull)}}unbind(){return this.bind(null)}reset(){super.reset(),this.boundVertexArrayNull={attributes:{},elementArrayBuffer:null},this.boundVertexArray=this.boundVertexArrayNull,this.boundVertexArrayObject=null}}class Ja extends Ye{constructor(){super(...arguments);u(this,"boundViewport",{x:0,y:0,width:0,height:0})}install(e){super.install(e),e.viewport=this}bind(e){const t=this.boundViewport,i=Math.floor(e.x),s=Math.floor(e.y),o=Math.floor(e.width),a=Math.floor(e.height);t.x===i&&t.y===s&&t.width===o&&t.height===a||(this._renderer.gl.viewport(i,s,o,a),t.x=i,t.y=s,t.width=o,t.height=a)}reset(){super.reset(),this.boundViewport={x:0,y:0,width:0,height:0}}}class Qa extends $a{constructor(e=wn(),t){super();u(this,"_modules",[new Za,new Ga,new qa,new Xa,new Ka,new Ja,new Va,new Wa,new Ha,new Ya,new ja]);u(this,"bindPoints",new Map);if(!e)throw new Error("Failed to createHTMLCanvas");_n(e)?this._setupContext(e,t):(this.gl=e,this.version=bn(this.gl)?2:1),this._setupBindPoints()._setupExtensions()._setupPolyfill(),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._modules.forEach(i=>i.install(this)),this._modules.forEach(i=>i.onUpdateContext())}_setupContext(e,t){this.view=e;let i=e.getContext("webgl2",t)||e.getContext("experimental-webgl2",t),s=2;if(i||(i=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),s=1),!i)throw new Error("Unable to getContext");return this.gl=i,this.version=s,this._onContextLost=this._onContextLost.bind(this),this._onContextRestored=this._onContextRestored.bind(this),e.addEventListener("webglcontextlost",this._onContextLost,!1),e.addEventListener("webglcontextrestored",this._onContextRestored,!1),this}_setupExtensions(){const e=this.gl,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tcSRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};return this.version===1?(t.instancedArrays=e.getExtension("ANGLE_instanced_arrays"),t.drawBuffers=e.getExtension("WEBGL_draw_buffers"),t.depthTexture=e.getExtension("WEBGL_depth_texture"),t.vertexArrayObject=e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),t.uint32ElementIndex=e.getExtension("OES_element_index_uint"),t.floatTexture=e.getExtension("OES_texture_float"),t.textureHalfFloat=e.getExtension("OES_texture_half_float"),t.textureHalfFloatLinear=e.getExtension("OES_texture_half_float_linear")):this.version===2&&(t.colorBufferFloat=e.getExtension("EXT_color_buffer_float")),this.extensions=t,this}_setupBindPoints(){for(const e in this.gl)if(e===e.toUpperCase()){const t=this.gl[e];typeof t=="number"&&this.bindPoints.set(t,e.toLowerCase())}return this}_setupPolyfill(){if(this.version===1){const{instancedArrays:e,vertexArrayObject:t,drawBuffers:i}=this.extensions,s=this.gl;t&&(s.createVertexArray=()=>t.createVertexArrayOES(),s.bindVertexArray=o=>t.bindVertexArrayOES(o),s.deleteVertexArray=o=>t.deleteVertexArrayOES(o)),e&&(s.vertexAttribDivisor=(o,a)=>e.vertexAttribDivisorANGLE(o,a),s.drawElementsInstanced=(o,a,l,h,c)=>e.drawElementsInstancedANGLE(o,a,l,h,c),s.drawArraysInstanced=(o,a,l,h)=>e.drawArraysInstancedANGLE(o,a,l,h)),i&&(s.drawBuffers=o=>i.drawBuffersWEBGL(o))}return this}_onContextLost(e){e.preventDefault(),setTimeout(()=>{var t;this.gl.isContextLost()&&((t=this.extensions.loseContext)==null||t.restoreContext())},0)}_onContextRestored(){}getBindPoint(e){return this.gl[e.toUpperCase()]}clear(e=this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT){this.gl.clear(e)}draw(e={}){const{mode:t="triangles",first:i=0,instanceCount:s}=e;let{count:o=0,bytesPerElement:a=0}=e;if(!o||!a){const h=this.vertexArray.boundVertexArray.elementArrayBuffer??Object.values(this.vertexArray.boundVertexArray.attributes)[0];if(h){const c=this.buffer.getMeta(h);o||(o=c.length),a||(a=c.bytesPerElement)}}const l=this.getBindPoint(t);if(a)if(a===2||a===4&&this.extensions.uint32ElementIndex){const h=a===2?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT;s&&"drawElementsInstanced"in this.gl?this.gl.drawElementsInstanced(l,o,h,i*a,s):this.gl.drawElements(l,o,h,i*a)}else console.warn("Unsupported index buffer type: uint32");else s&&"drawArraysInstanced"in this.gl?this.gl.drawArraysInstanced(l,i,o,s):this.gl.drawArrays(l,i,o)}reset(){this._modules.forEach(e=>e.reset())}flush(){this._modules.forEach(e=>e.flush())}destroy(){var e,t,i;this._modules.forEach(s=>s.destroy()),(e=this.view)==null||e.removeEventListener("webglcontextlost",this._onContextLost,!1),(t=this.view)==null||t.removeEventListener("webglcontextrestored",this._onContextRestored,!1),(i=this.extensions.loseContext)==null||i.loseContext()}toPixels(){const e=this.gl.drawingBufferWidth,t=this.gl.drawingBufferHeight,i=e*t*4,s=e*4,o=(t-1)*s,a=new Uint8Array(i),l=new Uint8ClampedArray(i);this.gl.readPixels(0,0,e,t,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a);for(let h=0;h<i;h+=s)l.set(a.subarray(h,h+s),o-h);return l}}const el={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class tl extends Bn{constructor(e={}){var c,f;const{view:t,width:i,height:s,pixelRatio:o=Xi,background:a=0,autoResize:l,...h}=e;super();u(this,"input",new Fa);u(this,"renderer");u(this,"_background",new Pt);u(this,"_resizeObserver",dn?new ResizeObserver(e=>{const t=e[0];if(t.target===this.view){const{inlineSize:i,blockSize:s}=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize;this.resize(i,s)}}):void 0);this.renderer=new Qa(t,{...el,...h}),this._setupInput(),this.pixelRatio=o,this.background=a,l?this.enableAutoResize(l):this.resize(i||this.gl.drawingBufferWidth||((c=this.view)==null?void 0:c.clientWidth)||200,s||this.gl.drawingBufferHeight||((f=this.view)==null?void 0:f.clientHeight)||200,!t)}get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(e){this.renderer.pixelRatio=e,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(e))}get background(){return this._background.value}set background(e){this._background.value=e}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(e=>{this.input.on(e,t=>{this.hasEventListener(e)&&(this.root.input(t),this.emit(e,t))})})),this}enableAutoResize(e=!0){var t,i;return this.view&&(e?(t=this._resizeObserver)==null||t.observe(this.view):(i=this._resizeObserver)==null||i.unobserve(this.view)),this}resize(e,t,i=!1){return this.renderer.resize(e,t,i),this.root.width=e,this.root.height=t,this.renderer.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this}nextTick(){return Yi()}waitUntilLoad(){return mt.waitUntilLoad()}render(e=0){return this.gl.clearColor(...this._background.toArray()),this._render(this.renderer,e)}start(){return this.render(),super.start(e=>{this.render(e)})}destroy(){this.stop(),this.root.getChildren(!0).forEach(e=>this.root.removeChild(e)),this.input.removeEventListeners(),this.enableAutoResize(!1),this.renderer.destroy()}toPixels(){return this.render(),this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){var s,o;const e=this.toImageData(),t=document.createElement("canvas");t.width=e.width,t.height=e.height,(s=t.getContext("2d"))==null||s.putImageData(e,0,0);const i=document.createElement("canvas");return i.width=this.width,i.height=this.height,(o=i.getContext("2d"))==null||o.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i}}let Wr,Yd;const rl=[];async function Zd(n=100){for(;;){const r=rl.shift();if(r)try{await r()}catch(e){console.error(e)}else await new Promise(e=>setTimeout(e,n))}}async function Kd(n){Wr??(Wr=new tl({width:1,height:1}));const r=Wr.root;r.removeChildren();const{data:e,width:t,height:i}=n;return Wr.resize(t,i),(Array.isArray(e)?e:[e]).forEach(s=>{s instanceof g.Node?r.addChild(s):r.addChild(g.Node.parse(s))}),await Wr.waitUntilLoad(),Wr.toCanvas2D()}async function Jd(n){return Yd??(Yd=Zd()),new Promise(r=>{rl.push(async()=>r(await Kd(n)))})}g.Assets=Ao,g.AudioPipeline=Qs,g.AudioProcessor=Df,g.AudioSpectrum=Ff,g.CanvasContext=wo,g.Color=Pt,g.ColorMatrix=os,g.ColorTexture=as,g.DEG_TO_RAD=On,g.DEVICE_PIXEL_RATIO=Xi,g.EffectMaterial=Ii,g.Engine=tl,g.EventEmitter=dt,g.FontLoader=xo,g.Geometry=Jr,g.GifLoader=Po,g.HTMLAudio=da,g.HTMLAudioContext=Oi,g.HTMLSound=Ui,g.IN_BROWSER=mr,g.Image2DResource=hi,g.ImageTexture=Rl,g.IndexBuffer=Jt,g.Input=Fa,g.InternalMode=yr,g.JsonLoader=Co,g.Loader=Et,g.LottieLoader=Eo,g.MainLoop=ei,g.Material=ne,g.Matrix=it,g.Matrix2=Pl,g.Matrix3=Ki,g.Matrix4=Mn,g.MouseInputEvent=on,g.PI=Ee,g.PI_2=le,g.PixelsTexture=Ji,g.PointerInputEvent=Na,g.Projection2D=An,g.QuadGeometry=bl,g.QuadUvGeometry=te,g.RAD_TO_DEG=Cl,g.Reference=Zi,g.RenderStack=Dn,g.Renderer=$a,g.Resource=wt,g.SUPPORTS_AUDIO_CONTEXT=Gi,g.SUPPORTS_CLICK_EVENTS=gn,g.SUPPORTS_CREATE_IMAGE_BITMAP=ji,g.SUPPORTS_IMAGE_BITMAP=fn,g.SUPPORTS_MOUSE_EVENTS=dl,g.SUPPORTS_OFFLINE_AUDIO_CONTEXT=Wi,g.SUPPORTS_POINTER_EVENTS=Kt,g.SUPPORTS_RESIZE_OBSERVER=dn,g.SUPPORTS_TOUCH_EVENTS=ft,g.SUPPORTS_WEBGL2=un,g.SUPPORTS_WEBKIT_AUDIO_CONTEXT=qi,g.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=mn,g.SUPPORTS_WEB_AUDIO=yn,g.SUPPORTS_WHEEL_EVENTS=pn,g.SceneTree=Bn,g.Style2D=at,g.Style2DBackgroundModule=Oo,g.Style2DFilterModule=Uo,g.Style2DModule=Tr,g.Style2DTextModule=Bo,g.Style2DTransformModule=Lo,g.TextLoader=To,g.Texture=de,g.TextureLoader=So,g.Ticker=ue,g.Transform2D=qe,g.UIInputEvent=Ri,g.UvGeometry=wl,g.UvMaterial=Qr,g.Vector=Je,g.Vector2=Tl,g.Vector3=Sl,g.Vector4=Un,g.VertexAttribute=ze,g.VertexBuffer=pt,g.VideoLoader=Mo,g.VideoTexture=Rn,g.ViewportTexture=es,g.WebAudio=ga,g.WebAudioContext=Dt,g.WebGLBatch2DModule=ja,g.WebGLBlendMode=fr,g.WebGLBufferModule=Ga,g.WebGLFramebufferModule=qa,g.WebGLMaskModule=Wa,g.WebGLModule=Ye,g.WebGLProgramModule=Xa,g.WebGLRenderer=Qa,g.WebGLScissorModule=Ha,g.WebGLState=Ht,g.WebGLStateModule=Va,g.WebGLStencilModule=Ya,g.WebGLTextureModule=Za,g.WebGLVertexArrayModule=Ka,g.WebGLViewportModule=Ja,g.WebSound=pa,g.WheelInputEvent=qr,g._Object=Kr,g.assets=mt,g.clamp=xt,g.createHTMLCanvas=wn,g.createNode=gl,g.crossOrigin=Pn,g.cubicBezier=sr,g.curves=El,g.customNode=H,g.customNodes=Yr,g.defaultOptions=el,g.defineProperty=bt,g.determineCrossOrigin=xn,g.ease=No,g.easeIn=Fo,g.easeInOut=zo,g.easeOut=$o,g.getDeclarations=Zr,g.getDefaultCssPropertyValue=Vi,g.isCanvasElement=_n,g.isElementNode=Hi,g.isImageElement=pl,g.isPow2=zi,g.isVideoElement=vn,g.isWebgl2=bn,g.lerp=fe,g.linear=ko,g.log2=ln,g.mapWebGLBlendModes=za,g.nextPow2=an,g.nextTick=Yi,g.parseCssFunctions=gr,g.parseCssProperty=pr,g.property=A,g.protectedProperty=ee,g.render=Jd,g.timingFunctions=li,g.uid=hn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|