modern-canvas 0.1.8 → 0.1.9
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 +17 -0
- package/dist/index.cjs +111 -111
- package/dist/index.js +21 -21
- package/dist/index.mjs +111 -111
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,Te){typeof exports=="object"&&typeof module<"u"?Te(exports):typeof define=="function"&&define.amd?define(["exports"],Te):(g=typeof globalThis<"u"?globalThis:g||self,Te(g.modernCanvas={}))})(this,function(g){"use strict";var tp=Object.defineProperty;var rp=(g,Te,le)=>Te in g?tp(g,Te,{enumerable:!0,configurable:!0,writable:!0,value:le}):g[Te]=le;var u=(g,Te,le)=>rp(g,typeof Te!="symbol"?Te+"":Te,le);var Zt,Rt;const Te=Math.PI,le=Te*2;let ll=0;function cn(n){var r;return((r=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:r.id)??++ll}function Vi(n){return!(n&n-1)&&!!n}const hl=/([\w-]+)\((.+?)\)/g,cl=/[^,]+/g,ul=/([-e.\d]+)(.*)/;function ji(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 mr(n,r,e={}){const t=yr(r,e);return t.length?t:un(n,r,e)}function yr(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(un(n,i[0],{...e,index:s++}));return t}function un(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 fn="WebGL2RenderingContext"in globalThis,dn="ImageBitmap"in globalThis,pn="ResizeObserver"in globalThis,Jt="PointerEvent"in globalThis,gn="WheelEvent"in globalThis,dl="MouseEvent"in globalThis,ft="ontouchstart"in globalThis,mn="onclick"in globalThis,Gi="createImageBitmap"in globalThis,qi="AudioContext"in globalThis,Wi="webkitAudioContext"in globalThis,Xi="OfflineAudioContext"in globalThis,yn="webkitOfflineAudioContext"in globalThis,_n=qi||Wi,_r=typeof window<"u",Hi=globalThis.devicePixelRatio||1,Yi=n=>n!==null&&typeof n=="object"&&n.nodeType===1,vn=n=>Yi(n)&&n.tagName==="VIDEO",pl=n=>Yi(n)&&n.tagName==="IMG";function bn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function wn(n){return fn&&n instanceof globalThis.WebGL2RenderingContext}function xn(){if(_r)return globalThis.document.createElement("canvas")}function Pn(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 Cn(n,r,e){e===null&&!r.startsWith("data:")?n.crossOrigin=Pn(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}};class Qt{constructor(){u(this,"_map",new WeakMap)}_toRaw(r){if(r&&typeof r=="object"){const e=r.__v_raw;e&&(r=this._toRaw(e))}return r}delete(r){return this._map.delete(this._toRaw(r))}get(r){return this._map.get(this._toRaw(r))}has(r){return this._map.has(this._toRaw(r))}set(r,e){return this._map.set(this._toRaw(r),this._toRaw(e)),this}}const Zr=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}),Zr.set(r,t)}}const En=new Qt;function Kr(n){let r=En.get(n);if(!r){const e=Object.getPrototypeOf(n);r=new Map(e?Kr(e):void 0),En.set(n,r)}return r}function bt(n,r,e={}){Kr(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=Zr.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 Zi(n){return new Promise(r=>{ue.on(()=>{n==null||n(),r()},{sort:1,once:!0})})}let ml=0;class Jr 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 Zi(),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 Kr(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 Ki extends Jr{constructor(){super(...arguments);u(this,"_refCount",0)}}class wt extends Ki{}class Qr extends wt{constructor(e={}){super();u(this,"vertexAttributes");u(this,"indexBuffer");u(this,"instanceCount");u(this,"mode");u(this,"_materialWeakMap",new Qt);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,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&&yl(r,e,i),i};class er 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}}Tn([ee({default:null})],er.prototype,"data"),Tn([ee({default:!1})],er.prototype,"dynamic");var _l=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&&_l(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}}Sn([ee({default:null})],pt.prototype,"data"),Sn([ee({default:!1})],pt.prototype,"dynamic");var vl=Object.defineProperty,Bt=(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 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}}Bt([ee()],ze.prototype,"buffer"),Bt([ee({default:0})],ze.prototype,"size"),Bt([ee({default:!1})],ze.prototype,"normalized"),Bt([ee({default:"float"})],ze.prototype,"type"),Bt([ee()],ze.prototype,"stride"),Bt([ee()],ze.prototype,"offset"),Bt([ee()],ze.prototype,"divisor");class bl extends Qr{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 er({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const Li=class Li extends wt{constructor(e={}){super();u(this,"vert");u(this,"frag");u(this,"uniforms");this.vert=e.vert??`precision highp float;
|
|
1
|
+
(function(g,Te){typeof exports=="object"&&typeof module<"u"?Te(exports):typeof define=="function"&&define.amd?define(["exports"],Te):(g=typeof globalThis<"u"?globalThis:g||self,Te(g.modernCanvas={}))})(this,function(g){"use strict";var tp=Object.defineProperty;var rp=(g,Te,le)=>Te in g?tp(g,Te,{enumerable:!0,configurable:!0,writable:!0,value:le}):g[Te]=le;var u=(g,Te,le)=>rp(g,typeof Te!="symbol"?Te+"":Te,le);var Yt,It;const Te=Math.PI,le=Te*2;let ll=0;function cn(n){var r;return((r=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:r.id)??++ll}function ji(n){return!(n&n-1)&&!!n}const hl=/([\w-]+)\((.+?)\)/g,cl=/[^,]+/g,ul=/([-e.\d]+)(.*)/;function Gi(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 mr(n,r,e={}){const t=yr(r,e);return t.length?t:un(n,r,e)}function yr(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(un(n,i[0],{...e,index:s++}));return t}function un(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 fn="WebGL2RenderingContext"in globalThis,dn="ImageBitmap"in globalThis,pn="ResizeObserver"in globalThis,Kt="PointerEvent"in globalThis,gn="WheelEvent"in globalThis,dl="MouseEvent"in globalThis,ft="ontouchstart"in globalThis,mn="onclick"in globalThis,qi="createImageBitmap"in globalThis,Wi="AudioContext"in globalThis,Xi="webkitAudioContext"in globalThis,Hi="OfflineAudioContext"in globalThis,yn="webkitOfflineAudioContext"in globalThis,_n=Wi||Xi,_r=typeof window<"u",Yi=globalThis.devicePixelRatio||1,Zi=n=>n!==null&&typeof n=="object"&&n.nodeType===1,vn=n=>Zi(n)&&n.tagName==="VIDEO",pl=n=>Zi(n)&&n.tagName==="IMG";function bn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function wn(n){return fn&&n instanceof globalThis.WebGL2RenderingContext}function xn(){if(_r)return globalThis.document.createElement("canvas")}function Pn(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 Cn(n,r,e){e===null&&!r.startsWith("data:")?n.crossOrigin=Pn(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}};class Jt{constructor(){u(this,"_map",new WeakMap)}_toRaw(r){if(r&&typeof r=="object"){const e=r.__v_raw;e&&(r=this._toRaw(e))}return r}delete(r){return this._map.delete(this._toRaw(r))}get(r){return this._map.get(this._toRaw(r))}has(r){return this._map.has(this._toRaw(r))}set(r,e){return this._map.set(this._toRaw(r),this._toRaw(e)),this}}const Kr=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}),Kr.set(r,t)}}const En=new Jt;function Jr(n){let r=En.get(n);if(!r){const e=Object.getPrototypeOf(n);r=new Map(e?Jr(e):void 0),En.set(n,r)}return r}function bt(n,r,e={}){Jr(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=Kr.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 Ki(n){return new Promise(r=>{ue.on(()=>{n==null||n(),r()},{sort:1,once:!0})})}let ml=0;class Qr 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 Ki(),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 Jr(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 Ji extends Qr{constructor(){super(...arguments);u(this,"_refCount",0)}}class wt extends Ji{}class ei extends wt{constructor(e={}){super();u(this,"vertexAttributes");u(this,"indexBuffer");u(this,"instanceCount");u(this,"mode");u(this,"_materialWeakMap",new Jt);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,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&&yl(r,e,i),i};class Qt 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}}Tn([ee({default:null})],Qt.prototype,"data"),Tn([ee({default:!1})],Qt.prototype,"dynamic");var _l=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&&_l(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}}Sn([ee({default:null})],pt.prototype,"data"),Sn([ee({default:!1})],pt.prototype,"dynamic");var vl=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&&vl(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 ei{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 Qt({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const ki=class ki 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;
|
|
@@ -9,7 +9,7 @@ void main(void) {
|
|
|
9
9
|
gl_FragColor = tint;
|
|
10
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
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(
|
|
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(ki,"instance",new ki);let ne=ki;class ti 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,19 +23,19 @@ 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])}})}}u(ei,"_instance");class te extends Qr{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ei.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 er({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(te,"_instance");class wl extends Qr{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 er({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,Mn=(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 ti extends Jr{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)}}}Mn([A({default:24})],ti.prototype,"fps"),Mn([A({default:1})],ti.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 d=0;for(let p=0;p<s;p++)d+=o[f]*a[p*c+f];h[f]=d}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:d}=t;switch(e){case"*":for(let p=0;p<d;p++){let m=0;for(let _=0;_<s;_++)_<d&&(m+=l[p*s+_]*(h[_]??0));f[p]=m}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let d=0;d<s;d++)for(let p=0;p<o;p++){const m=p*s;let _=0;for(let y=0;y<o;y++){const S=m+y,C=y*s+d;_+=l[S]*(h[C]??0)}f[m+d]=_}break;case"=":for(let d=0;d<a;d++){const p=h[d];p!==void 0&&(l[d]=p)}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 Ji=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,d=l*i-s*a,p=r*c+e*f+t*d;if(p===0)return this.set([0,0,0,0,0,0,0,0,0]);const m=1/p;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,d*m,(e*a-l*r)*m,(s*r-e*i)*m])}};class An extends it{constructor(r){super(4,4,r)}}class On extends Ji{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 Ji{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),d=t*i*(1-o)-e*a,p=o+i*i*(1-o),m=-Math.atan2(-d,f),_=-Math.atan2(c,Math.sqrt(d*d+p*p)),y=-Math.atan2(-h,l);return[m,_,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 Un=Te/180,Cl=180/Te;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 zi 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 zi(e).clone().sub(new zi(r)).multiply(t).add(new zi(r))}};class Sl extends Je{constructor(){super(3)}}class Dn 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,tr=(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},vr=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n))(vr||{});g.Node=class extends Ki{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=Zr.get(t)??g.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},tr([A()],g.Node.prototype,"name",2),tr([A()],g.Node.prototype,"mask",2),tr([A({default:"visible"})],g.Node.prototype,"visibility",2),tr([A({default:0})],g.Node.prototype,"visibleDelay",2),tr([A({default:Number.MAX_SAFE_INTEGER})],g.Node.prototype,"visibleDuration",2),g.Node=tr([H("Node")],g.Node);class In{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,br=(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)}},br([A({default:0})],g.Timer.prototype,"start",2),br([A({default:0})],g.Timer.prototype,"current",2),br([A({default:Number.MAX_SAFE_INTEGER})],g.Timer.prototype,"end",2),br([A({default:!1})],g.Timer.prototype,"loop",2),g.Timer=br([H("Timer")],g.Timer);var Dl=Object.defineProperty,rr=(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=Vi(this.realWidth)&&Vi(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(){dn&&this.source instanceof ImageBitmap&&this.source.close()}}rr([ee()],de.prototype,"source"),rr([ee({default:0})],de.prototype,"width"),rr([ee({default:0})],de.prototype,"height"),rr([ee({default:"linear"})],de.prototype,"filterMode"),rr([ee({default:"clamp_to_edge"})],de.prototype,"wrapMode"),rr([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)&&Gi,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||!Gi)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(_r&&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 Qi 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,Rn=(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 es=(Zt=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",""),Cn(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(),d=f.slice(f.lastIndexOf(".")+1);h=h||Zt.mimeTypes.get(d)||`video/${d}`}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(Zt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Zt);Rn([ee({default:!0})],es.prototype,"autoUpdate"),Rn([ee({default:0})],es.prototype,"fps");let Bn=es;class ts extends Qi{}var kl=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,wr=(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 On);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new ts,needsUpload:!1},{texture:new ts,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,ei.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)}},wr([A({default:0})],g.Viewport.prototype,"x",2),wr([A({default:0})],g.Viewport.prototype,"y",2),wr([A({default:0})],g.Viewport.prototype,"width",2),wr([A({default:0})],g.Viewport.prototype,"height",2),g.Viewport=wr([H({tag:"Viewport",renderable:!0})],g.Viewport);class Ln extends ti{constructor(){super(...arguments);u(this,"renderStack",new In);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},kn=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},Nn=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)}},rs=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,ri=function(n){var r=n.toString(16);return r.length<2?"0"+r:r},Fn=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}},$n=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}},zn=function(n){return{h:kn(n.h),s:We(n.s,0,100),l:We(n.l,0,100),a:We(n.a)}},Vn=function(n){return{h:me(n.h),s:me(n.s),l:me(n.l),a:me(n.a,3)}},jn=function(n){return $n((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},xr=function(n){return{h:(r=Fn(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,is={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:Nn({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=zn({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 jn(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)?Nn({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=zn({h:Number(r),s:Number(e),l:Number(t),a:Number(s)});return jn(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:kn(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 $n(o)},"hsv"]]},Gn=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"?Gn(n.trim(),is.string):typeof n=="object"&&n!==null?Gn(n,is.object):[null,void 0]},ss=function(n,r){var e=xr(n);return{h:e.h,s:We(e.s+100*r,0,100),l:e.l,a:e.a}},ns=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},qn=function(n,r){var e=xr(n);return{h:e.h,s:e.s,l:We(e.l+100*r,0,100),a:e.a}},os=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(ns(this.rgba),2)},n.prototype.isDark=function(){return ns(this.rgba)<.5},n.prototype.isLight=function(){return ns(this.rgba)>=.5},n.prototype.toHex=function(){return r=rs(this.rgba),e=r.r,t=r.g,i=r.b,o=(s=r.a)<1?ri(me(255*s)):"","#"+ri(e)+ri(t)+ri(i)+o;var r,e,t,i,s,o},n.prototype.toRgb=function(){return rs(this.rgba)},n.prototype.toRgbString=function(){return r=rs(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 Vn(xr(this.rgba))},n.prototype.toHslString=function(){return r=Vn(xr(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=Fn(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(ss(this.rgba,r))},n.prototype.desaturate=function(r){return r===void 0&&(r=.1),st(ss(this.rgba,-r))},n.prototype.grayscale=function(){return st(ss(this.rgba,-1))},n.prototype.lighten=function(r){return r===void 0&&(r=.1),st(qn(this.rgba,r))},n.prototype.darken=function(r){return r===void 0&&(r=.1),st(qn(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=xr(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 os?n:new os(n)},Wn=[],Wl=function(n){n.forEach(function(r){Wn.indexOf(r)<0&&(r(os,is),Wn.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,d="black";if(!s.length)for(var p in e)s[p]=new n(e[p]).toRgb();for(var m in e){var _=(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));_<f&&(f=_,d=m)}return d}},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 as 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 An([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 Dn(r[4]/255,r[9]/255,r[14]/255,r[19]/255)}}class ls 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=Xn(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 d=e;d<i;d+=e){const p=n[d],m=n[d+1];p<a&&(a=p),m<l&&(l=m),p>c&&(c=p),m>f&&(f=m)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return Pr(s,o,e,a,l,h,0),o}function Xn(n,r,e,t,i){let s;if(i===ch(n,r,e,t)>0)for(let o=r;o<e;o+=t)s=Kn(o/t|0,n[o],n[o+1],s);else for(let o=e-t;o>=r;o-=t)s=Kn(o/t|0,n[o],n[o+1],s);return s&&ir(s,s.next)&&(Tr(s),s=s.next),s}function Lt(n,r){if(!n)return n;r||(r=n);let e=n,t;do if(t=!1,!e.steiner&&(ir(e,e.next)||se(e.prev,e,e.next)===0)){if(Tr(e),e=r=e.prev,e===e.next)break;t=!0}else e=e.next;while(t||e!==r);return r}function Pr(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),Tr(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=Kl(Lt(n),r),Pr(n,r,e,t,i,s,2)):o===2&&Jl(n,r,e,t,i,s):Pr(Lt(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),d=Math.max(i,s,o),p=Math.max(a,l,h);let m=t.next;for(;m!==r;){if(m.x>=c&&m.x<=d&&m.y>=f&&m.y<=p&&Cr(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,d=o.y,p=Math.min(a,l,h),m=Math.min(c,f,d),_=Math.max(a,l,h),y=Math.max(c,f,d),S=hs(p,m,r,e,t),C=hs(_,y,r,e,t);let x=n.prevZ,T=n.nextZ;for(;x&&x.z>=S&&T&&T.z<=C;){if(x.x>=p&&x.x<=_&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&Cr(a,c,l,f,h,d,x.x,x.y)&&se(x.prev,x,x.next)>=0||(x=x.prevZ,T.x>=p&&T.x<=_&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&Cr(a,c,l,f,h,d,T.x,T.y)&&se(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;x&&x.z>=S;){if(x.x>=p&&x.x<=_&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&Cr(a,c,l,f,h,d,x.x,x.y)&&se(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;T&&T.z<=C;){if(T.x>=p&&T.x<=_&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&Cr(a,c,l,f,h,d,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;!ir(t,i)&&Yn(t,e,e.next,i)&&Er(t,i)&&Er(i,t)&&(r.push(t.i,e.i,i.i),Tr(e),Tr(e.next),e=n=i),e=e.next}while(e!==n);return Lt(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=Zn(o,a);o=Lt(o,o.next),l=Lt(l,l.next),Pr(o,r,e,t,i,s,0),Pr(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=Xn(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=Zn(e,n);return Lt(t,t.next),Lt(e,e.next)}function rh(n,r){let e=r;const t=n.x,i=n.y;let s=-1/0,o;if(ir(n,e))return e;do{if(ir(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&&Hn(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);Er(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=hs(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 hs(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 Hn(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 Cr(n,r,e,t,i,s,o,a){return!(n===o&&r===a)&&Hn(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)&&(Er(n,r)&&Er(r,n)&&hh(n,r)&&(se(n.prev,n,r.prev)||se(n,r.prev,r))||ir(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 ir(n,r){return n.x===r.x&&n.y===r.y}function Yn(n,r,e,t){const i=si(se(n,r,e)),s=si(se(n,r,t)),o=si(se(e,t,n)),a=si(se(e,t,r));return!!(i!==s&&o!==a||i===0&&ii(n,e,r)||s===0&&ii(n,t,r)||o===0&&ii(e,n,t)||a===0&&ii(e,r,t))}function ii(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 si(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&&Yn(e,e.next,n,r))return!0;e=e.next}while(e!==n);return!1}function Er(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 Zn(n,r){const e=cs(n.i,n.x,n.y),t=cs(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 Kn(n,r,e,t){const i=cs(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 Tr(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 cs(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 us(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:d=0,shadowColor:p="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=d,n.shadowColor=p}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],d=t[2],p=t[5],m=t[8],_=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*_+a*C+l*b,s[3]=o*y+a*x+l*P,s[6]=o*S+a*T+l*E,s[1]=h*_+c*C+f*b,s[4]=h*y+c*x+f*P,s[7]=h*S+c*T+f*E,s[2]=d*_+p*C+m*b,s[5]=d*y+p*x+m*P,s[8]=d*S+p*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,d=a*l-c*s,p=h*s-o*l,m=e*f+t*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/m;return r[0]=f*_,r[1]=(i*h-c*t)*_,r[2]=(a*t-i*o)*_,r[3]=d*_,r[4]=(c*e-i*l)*_,r[5]=(i*s-a*e)*_,r[6]=p*_,r[7]=(t*l-h*e)*_,r[8]=(o*e-t*s)*_,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(fs.makeScale(r,e)),this}rotate(r){return this.premultiply(fs.makeRotation(-r)),this}translate(r,e){return this.premultiply(fs.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 fs=new ke;function Jn(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 d=r*r,p=e*e;const m=c*c,_=f*f,y=m/d+_/p;if(y>1){const F=Math.sqrt(y);r=F*r,e=F*e,d=r*r,p=e*e}const S=d*_+p*m,C=(d*p-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=Jn(1,0,(c-T)/r,(f-b)/e),D=Jn((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 d(y,S,C){const x=new SyntaxError(`Unexpected character "${y}" at index ${S}.`);throw x.partial=C,x}function p(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let m;const _=n.length;for(let y=0;y<_;y++){if(m=n[y],Array.isArray(r)&&r.includes(f.length%e)&&he.FLAGS.test(m)){a=1,h=m,p();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&&d(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])&&d(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]==="."&&d(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)&&d(m,y,f)}}he.WHITESPACE.test(m)?(p(),a=0,l=!1):he.COMMA.test(m)?(p(),a=0,l=!0):he.SIGN.test(m)?(p(),a=1,h=m):he.POINT.test(m)?(p(),a=2,h=m):d(m,y,f)}return p(),f}function sr(n,r){return n-(r-n)}function Qn(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(sr(e.x,t.x),sr(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(sr(e.x,t.x),sr(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=sr(e.x,t.x),l=sr(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 eo(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 to(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 _h(n,r){return 3*(1-n)*n*n*r}function vh(n,r){return n*n*n*r}function ro(n,r,e,t,i){return mh(n,r)+yh(n,e)+_h(n,t)+vh(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,ni=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 d=(xh-f)/1;return d*=d,ds(n,r,e,t,i,s,o,a,h,d,0),h.push(o,a),h}function ds(n,r,e,t,i,s,o,a,l,h,c){if(c>wh)return;const f=(n+e)/2,d=(r+t)/2,p=(e+i)/2,m=(t+s)/2,_=(i+o)/2,y=(s+a)/2,S=(f+p)/2,C=(d+m)/2,x=(p+_)/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>ni&&F>ni){if((D+F)*(D+F)<=h*(E*E+w*w)){l.push(b,P);return}}else if(D>ni){if(D*D<=h*(E*E+w*w)){l.push(b,P);return}}else if(F>ni){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}}ds(n,r,f,d,S,C,b,P,l,h,c+1),ds(b,P,x,T,_,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,ps(a,n,r,e,t,i,s,c,0),a.push(i,s),a}function ps(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,d=(i+o)/2,p=(h+f)/2,m=(c+d)/2;let _=s-r,y=o-e;const S=Math.abs((t-s)*y-(i-o)*_);if(S>Eh){if(S*S<=a*(_*_+y*y)){n.push(p,m);return}}else if(_=p-(r+s)/2,y=m-(e+o)/2,_*_+y*y<=a){n.push(p,m);return}ps(n,r,e,h,c,p,m,a,l+1),ps(n,p,m,f,d,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 io(n,r,e,t){return Mh(n,r)+Ah(n,e)+Oh(n,t)}const Uh=1e-4,so=1e-4;function Dh(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=Ih(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]},d=o,p=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(d){n=n.slice(),p&&(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,_=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;d||(l.cap==="round"?y+=kt(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<_-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+=kt(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),Ee=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,ep=Ke+il*il*x;Fe<=ep?l.join==="bevel"||Fe/x>T?(Z?(m.push(Ee,$e),m.push(E+B*I,w+U*I),m.push(Ee,$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(Ee,$e),m.push(E+B*I,w+U*I),y+=kt(E,w,E+B*I,w+U*I,E+V*I,w+M*I,m,!0)+4,m.push(Ee,$e),m.push(E+V*I,w+M*I)):(m.push(E-B*R,w-U*R),m.push(tt,rt),y+=kt(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(Ee,$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+=kt(E,w,E+B*I,w+U*I,E+V*I,w+M*I,m,!0)+2:y+=kt(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(Ee,$e),m.push(Ee,$e)),y+=2),m.push(E-V*R,w-M*R),m.push(E+V*I,w+M*I),y+=2)}b=n[(_-2)*2],P=n[(_-2)*2+1],E=n[(_-1)*2],w=n[(_-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),d||(l.cap==="round"?y+=kt(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=so*so;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 Ih(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 d,p;o?(d=t,p=-e):(d=-t,p=e);const m=l+d,_=h+p,y=c+d,S=f+p;return a.push(m,_),a.push(y,S),2}function kt(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 d=c;const p=f-c,m=Math.abs(p),_=Math.sqrt(l*l+h*h),y=(15*m*Math.sqrt(_)/Math.PI>>0)+1,S=p/y;if(d+=S,a){o.push(n,r),o.push(e,t);for(let C=1,x=d;C<y;C++,x+=S)o.push(n,r),o.push(n+Math.sin(x)*_,r+Math.cos(x)*_);o.push(n,r),o.push(i,s)}else{o.push(e,t),o.push(n,r);for(let C=1,x=d;C<y;C++,x+=S)o.push(n+Math.sin(x)*_,r+Math.cos(x)*_),o.push(n,r);o.push(i,s),o.push(n,r)}return y*2}class nr{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],d=t[o+1]-c,p=(s-c)/d;return(o+p)/(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.getAdaptivePointArray(),r)}strokeTriangulate(r){return Dh(this.getAdaptivePointArray(),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 Rh=new ke,oo=new ke,ao=new ke,oi=new O;class gs extends nr{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,d=l-this.cy;a=f*h-d*c+this.cx,l=f*c+d*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),d=f>Math.PI?1:0,p=a?1:0,m=l*180/Math.PI;if(f>=2*Math.PI){const _=s+Math.PI,y=r+t*Math.cos(_)*Math.cos(l)-i*Math.sin(_)*Math.sin(l),S=e+t*Math.cos(_)*Math.sin(l)+i*Math.sin(_)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:p,x:y,y:S},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:p,x:h,y:c}]}else{const _=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:d,sweepFlag:p,x:_,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 oi.set(this.cx,this.cy),oi.applyMatrix3(r),this.cx=oi.x,this.cy=oi.y,kh(r)?Bh(this,r):Lh(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,d=l*4+(o?2:0)+2,p=d,m=h,_=o+i,y=a,S=e+_,C=e-_,x=t+y;if(c[f++]=S,c[f++]=x,c[--d]=x,c[--d]=C,a){const b=t-y;c[p++]=C,c[p++]=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[--d]=B,c[--d]=F,c[p++]=F,c[p++]=U,c[--m]=U,c[--m]=D}_=o,y=a+s,S=e+_,C=e-_,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 d=0;d<a.length;d+=2)l+=a[d],h+=a[d+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 d=0;d<a.length;d+=2)e[c*i]=a[d],e[c*i+1]=a[d+1],d>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 Bh(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=Rh.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,_=Nh(m[0],m[1],m[4]),y=Math.sqrt(_.rt1),S=Math.sqrt(_.rt2);if(n.rx=1/y,n.ry=1/S,n.rotate=Math.atan2(_.sn,_.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(_.cs,_.sn,0,-_.sn,_.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 Lh(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 kh(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 Nh(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 Fh extends gs{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 d=0;d<h+1;d++){const p=Math.cos(f),m=Math.sin(f),_=e+p*i,y=t+m*i;r.push(_,y),f+=c}return r}}class ms extends nr{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 ys extends nr{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 ys(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(ro(r,t.x,i.x,s.x,o.x),ro(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,d)=>{for(const p of f)for(let m=0;m<=d;m++){const _=m/d-.5,y=Math.min(1,Math.max(0,p+_)),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 $h extends gs{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 nr{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 zh extends ms{}class _s extends nr{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 _s(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(io(r,t.x,i.x,s.x),io(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 Vh extends zh{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 d=0;s*=i,e[s+d]=f[0],e[s+d+1]=f[1],d+=i,e[s+d]=f[2],e[s+d+1]=f[3],d+=i,e[s+d]=f[6],e[s+d+1]=f[7],d+=i,e[s+d]=f[4],e[s+d+1]=f[5],d+=i;const p=s/i;return t[o++]=p,t[o++]=p+1,t[o++]=p+2,t[o++]=p+1,t[o++]=p+3,t[o++]=p+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 jh extends gs{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,d=o-c,p=a-f;return this._center=new O(l,h),this._radius=new O(c,f),this._diff=new O(d,p),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 Gh extends nr{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(to(o,a.x,l.x,h.x,c.x),to(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 Et extends ms{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 Qn(e,this),this}addData(e){return this.addCommands(eo(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(ys.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(_s.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 Fh(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 $h(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 Vh(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 jh(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 Gh([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 qh(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Wh(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 we extends ms{constructor(e,t={}){super();u(this,"currentCurve",new Et);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof we?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 we?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 Et().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 Et,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}reset(){return this.currentCurve=new Et,this.curves.push(this.currentCurve),this.style={},this}addCommands(e){return Qn(e,this),this}addData(e){return this.addCommands(eo(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 d=c[0],p=c[c.length-1]??d;i.push({start:f?p:d,end:f?d:p,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(d=>{const p=l.getTForPoint(d),m=l.getNormal(p).scale(c?e:-e);d.add(m)})}),a.forEach((l,h)=>{const c=o[h];l.forEach(f=>{const d=o[f],p=Wh(c[c.length-1],c[c.length-2]??c[c.length-1],d[0],d[1]??d[0]);p&&(c[c.length-1].copy(p),d[0].copy(p))})}),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),d=o.getNormal(c),p=d.clone().scale(l?a:-a),m=d.clone().scale(l?-a:a);h.push(f.clone().add(p),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(),us(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(),us(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[qh(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 Xh="px",Hh=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][Xh],e<0&&(e=yo[r].in*Hh),e*Number.parseFloat(n)}const Yh=new ke,ai=new ke,_o=new ke,vo=new ke;function Zh(n,r,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const t=Kh(n);return e.length>0&&t.premultiply(e[e.length-1]),r.copy(t),e.push(t),t}function Kh(n){const r=new ke,e=Yh;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,d=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],d=h[2]),ai.makeTranslation(-f,-d),_o.makeRotation(c),vo.multiplyMatrices(_o,ai),ai.makeTranslation(f,d),e.multiplyMatrices(ai,vo)}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 Jh(n){return new we().addPath(new Et().arc(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("r")||0),0,Math.PI*2))}function Qh(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 ec(n){return new we().addPath(new Et().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 tc(n){return new we().moveTo(J(n.getAttribute("x1")||0),J(n.getAttribute("y1")||0)).lineTo(J(n.getAttribute("x2")||0),J(n.getAttribute("y2")||0))}function rc(n){const r=new we,e=n.getAttribute("d");return!e||e==="none"?null:(r.addData(e),r)}const ic=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function sc(n){var t;const r=new we;let e=0;return(t=n.getAttribute("points"))==null||t.replace(ic,(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 nc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function oc(n){var t;const r=new we;let e=0;return(t=n.getAttribute("points"))==null||t.replace(nc,(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 ac(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 we;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),d=n.style.getPropertyValue(f);r[f]=d,t[f]=d}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 bs(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":Qh(n,t);break;case"g":o=ot(n,o,t);break;case"path":o=ot(n,o,t),n.hasAttribute("d")&&(s=rc(n));break;case"rect":o=ot(n,o,t),s=ac(n);break;case"polygon":o=ot(n,o,t),s=sc(n);break;case"polyline":o=ot(n,o,t),s=oc(n);break;case"circle":o=ot(n,o,t),s=Jh(n);break;case"ellipse":o=ot(n,o,t),s=ec(n);break;case"line":o=ot(n,o,t),s=tc(n);break;case"defs":i=!0;break;case"use":{o=ot(n,o,t);const p=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),m=(f=n.viewportElement)==null?void 0:f.getElementById(p);m?bs(m,o,e,t):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(n);break}if(o.display==="none")return e;Object.assign(r,o);const a=new ke,l=[],h=Zh(n,a,l);s&&(s.applyTransform(a),e.push(s),s.style=r);const c=n.childNodes;for(let d=0,p=c.length;d<p;d++){const m=c[d];i&&m.nodeName!=="style"&&m.nodeName!=="defs"||bs(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(bs(go(n),{}))}class wo extends we{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,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof de?e=this.strokeStyle:e=new ls(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new we(this),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.currentCurve=new Et,this.curves=[this.currentCurve])}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 ls(this.fillStyle)),this._fille.push({path:new we(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new Et,this.curves=[this.currentCurve]}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._stroke=e._stroke.slice(),this._fille=e._fille.slice(),this}reset(){return super.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._stroke.length=0,this._fille.length=0,this}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._stroke.length,c=0;c<h;c++){o=t.length;const f=this._stroke[c];a??(a=f.texture),f.path.strokeTriangulate({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._fille.length,c=0;c<h;c++){const f=this._fille[c];a??(a=f.texture),a!==f.texture&&l("fill"),o=t.length,f.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(o,t,s,f.texture,f.textureTransform)}return t.length&&l("fill"),e}}class Tt{}class xo extends Tt{install(r){const e=async t=>{const{parseFont:i}=await Promise.resolve().then(()=>cf);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 Tt{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 ci(s.map(o=>({duration:o.delay,texture:new Qi(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 Tt{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 Tt{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 Tt{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 Tt{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 Tt{install(r){const e=t=>new Bn(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 lc=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 hc(n){for(const[r,e]of lc)if(e.includes(n))return r}async function cc(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=hc(i))}return r??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const li="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",li?new FinalizationRegistry(r=>{const e=this.get(r);e&&"destroy"in e&&e.destroy(),this._handled.delete(r)}):void 0);li||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 li&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(r)),e}set(r,e){let t=e;li&&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 cc(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 Sr{}class Oo extends Sr{install(r){bt(r,"backgroundColor"),bt(r,"backgroundImage"),r.prototype.getComputedBackgroundImage=uc}}async function uc(){if(this.backgroundImage)return await mt.texture.load(this.backgroundImage)}class Uo extends Sr{install(r){bt(r,"filter",{default:""}),r.prototype.getComputedFilter=fc,r.prototype.getComputedFilterColorMatrix=dc}}const Do={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function fc(){const n=yr(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 dc(){const n=new as,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 pc(){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 gc(){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",...pc(),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 mc(){return{...gc(),...Ro()}}class Bo extends Sr{install(r){const e=Ro();for(const t in e)bt(r,t,{default:e[t]});bt(r,"direction",{default:"inherit"})}}class Lo extends Sr{install(r){const e=Io();for(const t in e)bt(r,t,{default:e[t]});r.prototype.getComputedTransform=yc,r.prototype.getComputedTransformOrigin=_c}}function yc(){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*Un);let t=this.transform;(!t||t==="none")&&(t=""),yr(t,{width:this.width,height:this.height}).forEach(({name:f,args:d})=>{const p=d.map(m=>m.normalizedIntValue);switch(n.identity(),f){case"translate":n.translate(p[0]*this.width,(p[1]??p[0])*this.height);break;case"translateX":n.translateX(p[0]*this.width);break;case"translateY":n.translateY(p[0]*this.height);break;case"translateZ":n.translateZ(p[0]);break;case"translate3d":n.translate3d(p[0]*this.width,(p[1]??p[0])*this.height,p[2]??p[1]??p[0]);break;case"scale":n.scale(p[0],p[1]??p[0]);break;case"scaleX":n.scaleX(p[0]);break;case"scaleY":n.scaleY(p[0]);break;case"scale3d":n.scale3d(p[0],p[1]??p[0],p[2]??p[1]??p[0]);break;case"rotate":n.rotate(p[0]*le);break;case"rotateX":n.rotateX(p[0]*le);break;case"rotateY":n.rotateY(p[0]*le);break;case"rotateZ":n.rotateZ(p[0]*le);break;case"rotate3d":n.rotate3d(p[0]*le,(p[1]??p[0])*le,(p[2]??p[1]??p[0])*le,(p[3]??p[2]??p[1]??p[0])*le);break;case"skew":n.skew(p[0],p[0]??p[1]);break;case"skewX":n.skewX(p[0]);break;case"skewY":n.skewY(p[0]);break;case"matrix":n.set(p);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 _c(){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,Nt=(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 Jr{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}}}Nt([A({default:"#000000"})],at.prototype,"shadowColor"),Nt([A({default:0})],at.prototype,"shadowOffsetX"),Nt([A({default:0})],at.prototype,"shadowOffsetY"),Nt([A({default:0})],at.prototype,"shadowBlur"),Nt([A({default:1})],at.prototype,"opacity"),Nt([A({default:0})],at.prototype,"borderRadius"),Nt([A({default:"visible"})],at.prototype,"overflow"),[Oo,Uo,Bo,Lo].forEach(n=>{new n().install(at)});var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,ws=(n,r,e,t)=>{for(var i=t>1?void 0:t?wc(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&&bc(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}}}},ws([A()],g.CanvasItem.prototype,"tint",2),ws([A()],g.CanvasItem.prototype,"blendMode",2),g.CanvasItem=ws([H("CanvasItem")],g.CanvasItem);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,Ft=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pc(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&&xc(r,e,i),i};const ko=n=>n,No=or(.25,.1,.25,1),Fo=or(.42,0,1,1),$o=or(0,0,.58,1),zo=or(.42,0,.58,1);function or(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=_=>(3*s*_+2*o)*_+a,d=_=>((s*_+o)*_+a)*_,p=_=>((l*_+h)*_+c)*_;function m(_){let y=_,S,C;for(let b=0;b<8;b++){if(C=d(y)-_,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=_;x>T;){if(C=d(y)-_,Math.abs(C)<1e-6)return y;C>0?x=y:T=y,y=(x+T)/2}return y}return _=>p(m(_))}const hi={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 Qt);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 hi.linear;if(e in hi)return hi[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return or(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:d,easing:p}=i,m={...i.props};return t.forEach((_,y)=>{(!(y in m)||m[y]===null)&&(m[y]=_),(!(y in f)||f[y]===null)&&(f[y]=_)}),[{offset:d,easing:p,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,d=c-a,p=l((e-a)/d),m={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((_,y)=>{t[y]=this._getDiffValue(y,h[y],f[y],p,m)})}_getDiffValue(e,t,i,s,o){let a,l;if(t===void 0||i===void 0)if(t!==void 0)a=mr(e,String(t),o),l=ji(a);else if(i!==void 0)l=mr(e,String(i),o),a=ji(l);else return;else a=mr(e,String(t),o),l=mr(e,String(i),o);if(Array.isArray(a)&&Array.isArray(l)){const h=new Set,c={},f={};a.forEach(({name:p,args:m})=>{c[p]=m,h.add(p)}),l.forEach(({name:p,args:m})=>{f[p]=m,h.add(p)});let d="";return h.forEach(p=>{var S,C;const m=Math.max(((S=c[p])==null?void 0:S.length)??0,((C=f[p])==null?void 0:C.length)??0),_=c[p],y=f[p];d+=`${p}(${Array.from({length:m},(x,T)=>{const b=_==null?void 0:_[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(", ")}) `}),d}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)})}},Ft([A({default:"parent"})],g.Animation2D.prototype,"mode",2),Ft([A({default:!1})],g.Animation2D.prototype,"loop",2),Ft([A({default:[]})],g.Animation2D.prototype,"keyframes",2),Ft([A()],g.Animation2D.prototype,"easing",2),Ft([A({alias:"visibleDelay",default:0})],g.Animation2D.prototype,"delay",2),Ft([A({alias:"visibleDuration",default:2e3})],g.Animation2D.prototype,"duration",2),g.Animation2D=Ft([H("Animation2D")],g.Animation2D);var Cc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,Tc=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ec(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&&Cc(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 d=e[f],p=e[f+1];h[f]=t*d+i*p+s,h[f+1]=o*d+a*p+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=Tc([H({tag:"Node2D",renderable:!0})],g.Node2D);var Sc=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,ge=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mc(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&&Sc(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 ci 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 Ac=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,ui=(n,r,e,t)=>{for(var i=t>1?void 0:t?Oc(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&&Ac(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 ci?t=e:t=new ci(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))}},ui([ee()],g.Image2D.prototype,"resource",2),ui([A({default:!1})],g.Image2D.prototype,"gif",2),ui([A({default:""})],g.Image2D.prototype,"src",2),g.Image2D=ui([H("Image2D")],g.Image2D);var Uc=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,xs=(n,r,e,t)=>{for(var i=t>1?void 0:t?Dc(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&&Uc(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())}},xs([A({default:2})],g.Lottie2D.prototype,"pixelRatio",2),xs([A({default:""})],g.Lottie2D.prototype,"src",2),g.Lottie2D=xs([H("Lottie2D")],g.Lottie2D);var Se=Uint8Array,Ve=Uint16Array,Ps=Int32Array,fi=new Se([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]),di=new Se([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]),Cs=new Se([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 Ps(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(fi,2),Go=jo.b,Es=jo.r;Go[28]=258,Es[258]=28;for(var qo=Vo(di,0),Ic=qo.b,Wo=qo.r,Ts=new Ve(32768),re=0;re<32768;++re){var St=(re&43690)>>1|(re&21845)<<1;St=(St&52428)>>2|(St&13107)<<2,St=(St&61680)>>4|(St&3855)<<4,Ts[re]=((St&65280)>>8|(St&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,d=f|(1<<c)-1;f<=d;++f)a[Ts[f]>>l]=h}else for(a=new Ve(t),i=0;i<t;++i)n[i]&&(a[i]=Ts[o[n[i]-1]++]>>15-n[i]);return a},Mt=new Se(288),re=0;re<144;++re)Mt[re]=8;for(var re=144;re<256;++re)Mt[re]=9;for(var re=256;re<280;++re)Mt[re]=7;for(var re=280;re<288;++re)Mt[re]=8;for(var Mr=new Se(32),re=0;re<32;++re)Mr[re]=5;var Rc=lt(Mt,9,0),Bc=lt(Mt,9,1),Lc=lt(Mr,5,0),kc=lt(Mr,5,1),Ss=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},Ms=function(n,r){var e=r/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(r&7)},As=function(n){return(n+7)/8|0},Xo=function(n,r,e){return(e==null||e>n.length)&&(e=n.length),new Se(n.subarray(r,e))},Nc=["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||Nc[n]);if(t.code=n,Error.captureStackTrace&&Error.captureStackTrace(t,et),!e)throw t;return t},Fc=function(n,r,e,t){var i=n.length,s=0;if(!i||r.f&&!r.l)return e||new Se(0);var o=!e,a=o||r.i!=2,l=r.i;o&&(e=new Se(i*3));var h=function(Le){var Fe=e.length;if(Le>Fe){var Ee=new Se(Math.max(Fe*2,Le));Ee.set(e),e=Ee}},c=r.f||0,f=r.p||0,d=r.b||0,p=r.l,m=r.d,_=r.m,y=r.n,S=i*8;do{if(!p){c=Qe(n,f,1);var C=Qe(n,f+1,3);if(f+=3,C)if(C==1)p=Bc,m=kc,_=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 Se(w),F=new Se(19),B=0;B<E;++B)F[Cs[B]]=Qe(n,f+B*3,7);f+=E*3;for(var U=Ss(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);_=Ss(I),y=Ss(j),p=lt(I,_,1),m=lt(j,y,1)}else et(1);else{var x=As(f)+4,T=n[x-4]|n[x-3]<<8,b=x+T;if(b>i){l&&et(0);break}a&&h(d+T),e.set(n.subarray(x,b),d),r.b=d+=T,r.p=f=b*8,r.f=c;continue}if(f>S){l&&et(0);break}}a&&h(d+131072);for(var k=(1<<_)-1,L=(1<<y)-1,K=f;;K=f){var q=p[Ms(n,f)&k],X=q>>4;if(f+=q&15,f>S){l&&et(0);break}if(q||et(2),X<256)e[d++]=X;else if(X==256){K=f,p=null;break}else{var W=X-254;if(X>264){var B=X-257,G=fi[B];W=Qe(n,f,(1<<G)-1)+Go[B],f+=G}var Q=m[Ms(n,f)&L],Z=Q>>4;Q||et(3),f+=Q&15;var j=Ic[Z];if(Z>3){var G=di[Z];j+=Ms(n,f)&(1<<G)-1,f+=G}if(f>S){l&&et(0);break}a&&h(d+131072);var ae=d+W;if(d<j){var ut=s-j,Ze=Math.min(j,ae);for(ut+d<0&&et(3);d<Ze;++d)e[d]=t[ut+d]}for(;d<ae;++d)e[d]=e[d-j]}}r.l=p,r.p=K,r.b=d,r.f=c,p&&(c=1,r.m=_,r.d=m,r.n=y)}while(!c);return d!=e.length&&o?Xo(e,0,d):e.subarray(0,d)},yt=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8},Ar=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},Os=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 Se(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 d=s[0].s,t=1;t<i;++t)s[t].s>d&&(d=s[t].s);var p=new Ve(d+1),m=Us(e[c-1],p,0);if(m>r){var t=0,_=0,y=m-r,S=1<<y;for(s.sort(function(P,E){return p[E.s]-p[P.s]||P.f-E.f});t<i;++t){var C=s[t].s;if(p[C]>r)_+=S-(1<<m-p[C]),p[C]=r;else break}for(_>>=y;_>0;){var x=s[t].s;p[x]<r?_-=1<<r-p[x]++-1:++t}for(;t>=0&&_;--t){var T=s[t].s;p[T]==r&&(--p[T],++_)}m=r}return{t:new Se(p),l:m}},Us=function(n,r,e){return n.s==-1?Math.max(Us(n.l,r,e+1),Us(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}},Or=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=As(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=Os(i,15),d=f.t,p=f.l,m=Os(s,15),_=m.t,y=m.l,S=Ho(d),C=S.c,x=S.n,T=Ho(_),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=Os(E,7),F=D.t,B=D.l,U=19;U>4&&!F[Cs[U-1]];--U);var V=h+5<<3,M=Or(i,Mt)+Or(s,Mr)+o,N=Or(i,d)+Or(s,_)+o+14+3*U+Or(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(d,p,0),R=d,I=lt(_,y,0),j=_;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[Cs[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=Rc,R=Mt,I=Lc,j=Mr;for(var w=0;w<a;++w){var G=t[w];if(G>255){var W=G>>18&31;Ar(r,c,q[W+257]),c+=R[W+257],W>7&&(yt(r,c,G>>23&31),c+=fi[W]);var Q=G&31;Ar(r,c,I[Q]),c+=j[Q],Q>3&&(Ar(r,c,G>>5&8191),c+=di[Q])}else Ar(r,c,q[G]),c+=R[G]}return Ar(r,c,q[256]),c+R[256]},$c=new Ps([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ko=new Se(0),zc=function(n,r,e,t,i,s){var o=s.z||n.length,a=new Se(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=$c[r-1],d=f>>13,p=f&8191,m=(1<<e)-1,_=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 Ps(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(_[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=p,L=M-N&32767;if(q>2&&V==x(D-L))for(var K=Math.min(d,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=_[ae],Ze=ae-ut&32767;Ze>Z&&(Z=Ze,N=ae)}}}M=N,N=_[M],L+=M-N&32767}if(j){T[F++]=268435456|Es[I]<<18|Wo[j];var Le=Es[I]&31,Fe=Wo[j]&31;w+=fi[Le]+di[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=_,s.i=D,s.w=B)}else{for(var D=s.w||0;D<o+h;D+=65535){var Ee=D+65535;Ee>=o&&(l[c/8|0]=h,Ee=o),c=Yo(l,c+1,n.subarray(D,Ee))}s.i=o}return Xo(a,0,t+As(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}}},Vc=function(n,r,e,t,i){if(!i&&(i={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),o=new Se(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return zc(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},jc=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())}},Gc=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 qc(n,r){r||(r={});var e=Jo();e.p(n);var t=Vc(n,r,r.dictionary?6:2,4);return jc(t,r),Qo(t,t.length-4,e.d()),t}function Wc(n,r){return Fc(n.subarray(Gc(n,r),-4),{i:2},r,r)}var Xc=typeof TextDecoder<"u"&&new TextDecoder,Hc=0;try{Xc.decode(Ko,{stream:!0}),Hc=1}catch{}const Yc="modern-font";function Ur(n,r){if(!n)throw new Error(`[${Yc}] ${r}`)}function Zc(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 ar(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Kc(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 pi(n){n=Kc(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 Jc(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 Qc(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 eu=Object.defineProperty,Me=(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 Dr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ae(){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 _e extends DataView{constructor(e,t,i,s){super(Zc(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+=Dr[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+=Dr[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=ar(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}}Me([Ae()],_e.prototype,"readInt8"),Me([Ae()],_e.prototype,"readInt16"),Me([Ae()],_e.prototype,"readInt32"),Me([Ae()],_e.prototype,"readUint8"),Me([Ae()],_e.prototype,"readUint16"),Me([Ae()],_e.prototype,"readUint32"),Me([Ae()],_e.prototype,"readFloat32"),Me([Ae()],_e.prototype,"readFloat64"),Me([Ae()],_e.prototype,"writeInt8"),Me([Ae()],_e.prototype,"writeInt16"),Me([Ae()],_e.prototype,"writeInt32"),Me([Ae()],_e.prototype,"writeUint8"),Me([Ae()],_e.prototype,"writeUint16"),Me([Ae()],_e.prototype,"writeUint32"),Me([Ae()],_e.prototype,"writeFloat32"),Me([Ae()],_e.prototype,"writeFloat64");const ea=new WeakMap;function v(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*Dr[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+Dr[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 _e(r,e,t,i)}}class gi 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 tu=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&&tu(r,e,i),i};const Ie=class sl extends gi{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=pi(s.fontFamily||""),a=o.length,l=pi(s.fontStyle||""),h=l.length,c=pi(s.version||""),f=c.length,d=pi(s.fullName||""),p=d.length,m=86+a+4+h+4+f+4+p+2+e.view.byteLength,_=new sl(new ArrayBuffer(m),0,m,!0);_.EOTSize=_.view.byteLength,_.FontDataSize=e.view.byteLength,_.Version=131073,_.Flags=0,_.Charset=1,_.MagicNumber=20556,_.Padding1=0,_.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(_.FontPANOSE=y.fontPANOSE,_.Italic=y.fsSelection,_.Weight=y.usWeightClass,_.fsType=y.fsType,_.UnicodeRange=y.ulUnicodeRange,_.CodePageRange=y.ulCodePageRange),_.view.writeUint16(a),_.view.writeBytes(o),_.view.writeUint16(0),_.view.writeUint16(h),_.view.writeBytes(l),_.view.writeUint16(0),_.view.writeUint16(f),_.view.writeBytes(c),_.view.writeUint16(0),_.view.writeUint16(p),_.view.writeBytes(d),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(e.view),_}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var ru=Object.defineProperty,mi=(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&&ru(r,e,i),i};class lr extends je{constructor(r,e){super(r,e,16)}}mi([v({type:"char",size:4})],lr.prototype,"tag"),mi([v("uint32")],lr.prototype,"checkSum"),mi([v("uint32")],lr.prototype,"offset"),mi([v("uint32")],lr.prototype,"length");const Ds=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],iu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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 Is{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,d=h.length;f<d;f+=1){const p=h[f];p.type==="M"?c.push({type:"M",x:r+p.x*a,y:e+-p.y*l}):p.type==="L"?c.push({type:"L",x:r+p.x*a,y:e+-p.y*l}):p.type==="Q"?c.push({type:"Q",x1:r+p.x1*a,y1:e+-p.y1*l,x:r+p.x*a,y:e+-p.y*l}):p.type==="C"?c.push({type:"C",x1:r+p.x1*a,y1:e+-p.y1*l,x2:r+p.x2*a,y2:e+-p.y2*l,x:r+p.x*a,y:e+-p.y*l}):p.type==="Z"&&c.push({type:"Z"})}return c}}class su extends Is{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,d,p,m;const _=[],y=[];let S=0,C=!1,x=!1,T=o,b=0,P=0;function E(M,N){_.push({type:"L",x:M,y:N})}function w(M,N,q,R,I,j){_.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,_.push({type:"M",x:M,y:N})}function F(){_.push({type:"Z"})}function B(M){_.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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+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,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 34:f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),L=p+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=P,b=G+y.shift(),w(f,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 36:f=b+y.shift(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=W+y.shift(),b=G+y.shift(),w(f,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 37:f=b+y.shift(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+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,d,p,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=Ds[y.pop()],Ze=Ds[y.pop()],Le=y.pop(),Fe=y.pop();if(ut&&Ze){i.isComposite=!0,i.components=[];const Ee=r.charset.indexOf(ut),$e=r.charset.indexOf(Ze);i.components.push({glyphIndex:$e,dx:0,dy:0}),i.components.push({glyphIndex:Ee,dx:Fe,dy:Le}),B(t.get($e).pathCommands);const tt=JSON.parse(JSON.stringify(t.get(Ee).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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,m,b,P);break;case 26:for(y.length%2&&(b+=y.shift());y.length>0;)f=b,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p,P=m+y.shift(),w(f,d,p,m,b,P);break;case 27:for(y.length%2&&(P+=y.shift());y.length>0;)f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m,w(f,d,p,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,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+(y.length===1?y.shift():0),w(f,d,p,m,b,P),y.length!==0);)f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),P=m+y.shift(),b=p+(y.length===1?y.shift():0),w(f,d,p,m,b,P);break;case 31:for(;y.length>0&&(f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),P=m+y.shift(),b=p+(y.length===1?y.shift():0),w(f,d,p,m,b,P),y.length!==0);)f=b,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+(y.length===1?y.shift():0),w(f,d,p,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=_,C&&(this.advanceWidth=T)}}class Rs{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 nu extends Rs{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(r){const e=this._sfnt.cff,t=new su({index:r});return t.parse(e,e.charStringsIndex.get(r),this),t.name=e.charset[r],t}}var ou=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&&ou(r,e,i),i};class yi 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([v("uint16")],yi.prototype,"count"),ta([v("uint8")],yi.prototype,"offsetSize");class _i extends yi{constructor(){super(...arguments);u(this,"_isString",!1)}}class ra extends yi{constructor(){super(...arguments);u(this,"_isString",!0)}}const 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","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"],lu=[".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"],hu=[".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"],cu=[".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?au[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 uu=Object.defineProperty,Bs=(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 bi extends ia{}Bs([ie(19)],bi.prototype,"subrs"),Bs([ie(20)],bi.prototype,"defaultWidthX"),Bs([ie(21)],bi.prototype,"nominalWidthX");var fu=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&&fu(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 xe(n,r=n){return e=>{$t.tableDefinitions.set(n,{tag:n,prop:r,class:e}),Object.defineProperty($t.prototype,r,{get(){return this.get(n)},set(t){return this.set(n,t)},configurable:!0,enumerable:!0})}}const Kt=class Kt{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 Kt(this.tableViews)}delete(r){const e=Kt.tableDefinitions.get(r);return e?(this.tableViews.delete(r),this.tables.delete(e.prop),this):this}set(r,e){const t=Kt.tableDefinitions.get(r);return t&&this.tables.set(t.prop,e),this.tableViews.set(r,e.view),this}get(r){const e=Kt.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(Kt,"tableDefinitions",new Map);let $t=Kt;class Oe extends je{setSfnt(r){return this._sfnt=r,this}getSfnt(){return this._sfnt}}var du=Object.defineProperty,pu=Object.getOwnPropertyDescriptor,Ir=(n,r,e,t)=>{for(var i=t>1?void 0:t?pu(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 zt=class extends Oe{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 nu(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 _i(e,this.nameIndex.endOffset),this.stringIndex=new ra(e,this.topDictIndex.endOffset),this.globalSubrIndex=new _i(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 bi(e,t+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new _i(e,t+o+this.privateDict.subrs))),this.charStringsIndex=new _i(e,t+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=lu:this.topDict.charset===1?this.charset=hu:this.topDict.charset===2?this.charset=cu:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Ds:this.topDict.encoding===1?this.encoding=iu: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}};Ir([v("uint8")],zt.prototype,"majorVersion",2),Ir([v("uint8")],zt.prototype,"minorVersion",2),Ir([v("uint8")],zt.prototype,"headerSize",2),Ir([v("uint8")],zt.prototype,"offsetSize",2),zt=Ir([xe("CFF ","cff")],zt);var gu=Object.defineProperty,wi=(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};const Rr=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}};wi([v("uint16")],Rr.prototype,"format"),wi([v("uint16")],Rr.prototype,"length"),wi([v("uint16")],Rr.prototype,"language"),wi([v({type:"uint8",size:256})],Rr.prototype,"glyphIndexArray");let Ls=Rr;var mu=Object.defineProperty,ks=(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};class Br 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,d=s[c].entryCount;f<d;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 p=(h<<8|f+s[c].firstCode)%65535;e.set(p,l)}}return e}}ks([v("uint16")],Br.prototype,"format"),ks([v("uint16")],Br.prototype,"length"),ks([v("uint16")],Br.prototype,"language");function sa(n){return n>32767?n-65536:n<-32767?n+65536:n}function Ns(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 yu=Object.defineProperty,Vt=(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};const At=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=Ns(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 d=h+o[h]/2+(c-i[h])-t,p=l[d];p!==0?r.set(c,(p+a[h])%65536):r.set(c,0)}return r.delete(65535),r}};Vt([v("uint16")],At.prototype,"format"),Vt([v("uint16")],At.prototype,"length"),Vt([v("uint16")],At.prototype,"language"),Vt([v("uint16")],At.prototype,"segCountX2"),Vt([v("uint16")],At.prototype,"searchRange"),Vt([v("uint16")],At.prototype,"entrySelector"),Vt([v("uint16")],At.prototype,"rangeShift");let Fs=At;var _u=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&&_u(r,e,i),i};class jt 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}}Lr([v("uint16")],jt.prototype,"format"),Lr([v("uint16")],jt.prototype,"length"),Lr([v("uint16")],jt.prototype,"language"),Lr([v("uint16")],jt.prototype,"firstCode"),Lr([v("uint16")],jt.prototype,"entryCount");var vu=Object.defineProperty,kr=(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 hr=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=Ns(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}};kr([v("uint16")],hr.prototype,"format"),kr([v("uint16")],hr.prototype,"reserved"),kr([v("uint32")],hr.prototype,"length"),kr([v("uint32")],hr.prototype,"language"),kr([v("uint32")],hr.prototype,"nGroups");let $s=hr;var bu=Object.defineProperty,zs=(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&&bu(r,e,i),i};class Nr 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}}zs([v("uint16")],Nr.prototype,"format"),zs([v("uint32")],Nr.prototype,"length"),zs([v("uint32")],Nr.prototype,"numVarSelectorRecords");var wu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Vs=(n,r,e,t)=>{for(var i=t>1?void 0:t?xu(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&&wu(r,e,i),i};let cr=class extends Oe{constructor(){super(...arguments);u(this,"_unicodeToGlyphIndexMap");u(this,"_glyphIndexToUnicodesMap")}static from(r){const e=Array.from(r.keys()).some(f=>f>65535),t=Fs.from(r),i=Ls.from(r),s=e?$s.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 cr(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 Ls(this.view.buffer,e.offset);break;case 2:i=new Br(this.view.buffer,e.offset,this.view.readUint16());break;case 4:i=new Fs(this.view.buffer,e.offset,this.view.readUint16());break;case 6:i=new jt(this.view.buffer,e.offset,this.view.readUint16());break;case 12:i=new $s(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:i=new Nr(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(d=>d.format===0))==null?void 0:a.view,t=(l=r.find(d=>d.platformID===3&&d.platformSpecificID===3&&d.format===2))==null?void 0:l.view,i=(h=r.find(d=>d.platformID===3&&d.platformSpecificID===1&&d.format===4))==null?void 0:h.view,s=(c=r.find(d=>d.platformID===3&&d.platformSpecificID===10&&d.format===12))==null?void 0:c.view,o=(f=r.find(d=>d.platformID===0&&d.platformSpecificID===5&&d.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())??[]])}};Vs([v("uint16")],cr.prototype,"version",2),Vs([v("uint16")],cr.prototype,"numberSubtables",2),cr=Vs([xe("cmap")],cr);class Pu extends Is{_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 Ur(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 _=0;_<i;_++)a.push(r.view.readUint16());const l=this.instructionLength=r.view.readUint16();Ur(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let _=0;_<l;++_)h.push(r.view.readUint8());const c=r.view.byteOffset,f=a[a.length-1]+1;Ur(f<2e4,`Bad numberOfCoordinates:${c}`);const d=[];let p,m=0;for(;m<f;)if(p=r.view.readUint8(),d.push(p),m++,p&8&&m<f){const _=r.view.readUint8();for(let y=0;y<_;y++)d.push(p),m++}if(Ur(d.length===f,`Bad flags length: ${d.length}, numberOfCoordinates: ${f}`),a.length>0){const _=[];let y;if(f>0){for(let x=0;x<f;x+=1)p=d[x],y={},y.onCurve=!!(p&1),y.lastPointOfContour=a.includes(x),_.push(y);let S=0;for(let x=0;x<f;x+=1)p=d[x],y=_[x],y.x=this._parseGlyphCoordinate(r,p,S,2,16),S=y.x;let C=0;for(let x=0;x<f;x+=1)p=d[x],y=_[x],y.y=this._parseGlyphCoordinate(r,p,C,4,32),C=y.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=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{Ur(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 d=h.points[l.matchedPoints[1]];const p={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],p)[0],p.dx=f.x-d.x,p.dy=f.y-d.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],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 d=0,p=h.length;d<p;++d)if(c=f,f=h[(d+1)%p],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 Cu extends Rs{get length(){return this._sfnt.loca.locations.length}_get(r){const e=this._sfnt.loca.locations,t=e[r],i=new Pu({index:r});return t!==e[r+1]&&i.parse(this._sfnt.glyf,t,this),i}}var Eu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Su=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tu(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&&Eu(r,e,i),i};let xi=class extends Oe{constructor(){super(...arguments);u(this,"_glyphs")}static from(r){const e=r.reduce((i,s)=>i+s.byteLength,0),t=new xi(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeBytes(i)}),t}get glyphs(){return this._glyphs??(this._glyphs=new Cu(this._sfnt))}};xi=Su([xe("glyf")],xi);var Mu=Object.defineProperty,Au=Object.getOwnPropertyDescriptor,Ou=(n,r,e,t)=>{for(var i=t>1?void 0:t?Au(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&&Mu(r,e,i),i};let js=class extends Oe{};js=Ou([xe("GPOS","gpos")],js);var Uu=Object.defineProperty,Du=Object.getOwnPropertyDescriptor,Gt=(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&&Uu(r,e,i),i};let _t=class extends Oe{};Gt([v("uint16")],_t.prototype,"majorVersion",2),Gt([v("uint16")],_t.prototype,"minorVersion",2),Gt([v("uint16")],_t.prototype,"scriptListOffset",2),Gt([v("uint16")],_t.prototype,"featureListOffset",2),Gt([v("uint16")],_t.prototype,"lookupListOffset",2),Gt([v("uint16")],_t.prototype,"featureVariationsOffset",2),_t=Gt([xe("GSUB","gsub")],_t);var Iu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,ve=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ru(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&&Iu(r,e,i),i};let pe=class extends Oe{constructor(n=new ArrayBuffer(54),r){super(n,r,Math.min(54,n.byteLength-(r??0)))}};ve([v("fixed")],pe.prototype,"version",2),ve([v("fixed")],pe.prototype,"fontRevision",2),ve([v("uint32")],pe.prototype,"checkSumAdjustment",2),ve([v("uint32")],pe.prototype,"magickNumber",2),ve([v("uint16")],pe.prototype,"flags",2),ve([v("uint16")],pe.prototype,"unitsPerEm",2),ve([v({type:"longDateTime"})],pe.prototype,"created",2),ve([v({type:"longDateTime"})],pe.prototype,"modified",2),ve([v("int16")],pe.prototype,"xMin",2),ve([v("int16")],pe.prototype,"yMin",2),ve([v("int16")],pe.prototype,"xMax",2),ve([v("int16")],pe.prototype,"yMax",2),ve([v("uint16")],pe.prototype,"macStyle",2),ve([v("uint16")],pe.prototype,"lowestRecPPEM",2),ve([v("int16")],pe.prototype,"fontDirectionHint",2),ve([v("int16")],pe.prototype,"indexToLocFormat",2),ve([v("int16")],pe.prototype,"glyphDataFormat",2),pe=ve([xe("head")],pe);var Bu=Object.defineProperty,Lu=Object.getOwnPropertyDescriptor,Re=(n,r,e,t)=>{for(var i=t>1?void 0:t?Lu(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 Pe=class extends Oe{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Re([v("fixed")],Pe.prototype,"version",2),Re([v("int16")],Pe.prototype,"ascent",2),Re([v("int16")],Pe.prototype,"descent",2),Re([v("int16")],Pe.prototype,"lineGap",2),Re([v("uint16")],Pe.prototype,"advanceWidthMax",2),Re([v("int16")],Pe.prototype,"minLeftSideBearing",2),Re([v("int16")],Pe.prototype,"minRightSideBearing",2),Re([v("int16")],Pe.prototype,"xMaxExtent",2),Re([v("int16")],Pe.prototype,"caretSlopeRise",2),Re([v("int16")],Pe.prototype,"caretSlopeRun",2),Re([v("int16")],Pe.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],Pe.prototype,"reserved",2),Re([v("int16")],Pe.prototype,"metricDataFormat",2),Re([v("uint16")],Pe.prototype,"numOfLongHorMetrics",2),Pe=Re([xe("hhea")],Pe);var ku=Object.defineProperty,Nu=Object.getOwnPropertyDescriptor,Fu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nu(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&&ku(r,e,i),i};let Pi=class extends Oe{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Pi(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()}))}};Pi=Fu([xe("hmtx")],Pi);var $u=Object.defineProperty,zu=Object.getOwnPropertyDescriptor,Vu=(n,r,e,t)=>{for(var i=t>1?void 0:t?zu(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&&$u(r,e,i),i};let Gs=class extends Oe{};Gs=Vu([xe("kern","kern")],Gs);var ju=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,qu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Gu(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 Ci=class extends Oe{constructor(){super(...arguments);u(this,"_locations")}static from(r,e=1){const t=r.length*(e?4:2),i=new Ci(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)}};Ci=qu([xe("loca")],Ci);var Wu=Object.defineProperty,Xu=Object.getOwnPropertyDescriptor,Ue=(n,r,e,t)=>{for(var i=t>1?void 0:t?Xu(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&&Wu(r,e,i),i};let be=class extends Oe{constructor(n=new ArrayBuffer(32),r){super(n,r,Math.min(32,n.byteLength-(r??0)))}};Ue([v("fixed")],be.prototype,"version",2),Ue([v("uint16")],be.prototype,"numGlyphs",2),Ue([v("uint16")],be.prototype,"maxPoints",2),Ue([v("uint16")],be.prototype,"maxContours",2),Ue([v("uint16")],be.prototype,"maxComponentPoints",2),Ue([v("uint16")],be.prototype,"maxComponentContours",2),Ue([v("uint16")],be.prototype,"maxZones",2),Ue([v("uint16")],be.prototype,"maxTwilightPoints",2),Ue([v("uint16")],be.prototype,"maxStorage",2),Ue([v("uint16")],be.prototype,"maxFunctionDefs",2),Ue([v("uint16")],be.prototype,"maxInstructionDefs",2),Ue([v("uint16")],be.prototype,"maxStackElements",2),Ue([v("uint16")],be.prototype,"maxSizeOfInstructions",2),Ue([v("uint16")],be.prototype,"maxComponentElements",2),Ue([v("uint16")],be.prototype,"maxComponentDepth",2),be=Ue([xe("maxp")],be);var Hu=Object.defineProperty,Yu=Object.getOwnPropertyDescriptor,Ei=(n,r,e,t)=>{for(var i=t>1?void 0:t?Yu(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&&Hu(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"},qs={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Zu={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 ur=class extends Oe{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=qs.Macintosh,s=Zu.Default,o=0;e.some(l=>l.platform===qs.Microsoft&&l.encoding===oa.UCS2&&l.language===1033)&&(i=qs.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?Jc(h.name):Qc(h.name))}return a}};Ei([v("uint16")],ur.prototype,"format",2),Ei([v("uint16")],ur.prototype,"count",2),Ei([v("uint16")],ur.prototype,"stringOffset",2),ur=Ei([xe("name")],ur);var Ku=Object.defineProperty,Ju=Object.getOwnPropertyDescriptor,z=(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&&Ku(r,e,i),i};let $=class extends Oe{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};z([v("uint16")],$.prototype,"version",2),z([v("int16")],$.prototype,"xAvgCharWidth",2),z([v("uint16")],$.prototype,"usWeightClass",2),z([v("uint16")],$.prototype,"usWidthClass",2),z([v("uint16")],$.prototype,"fsType",2),z([v("uint16")],$.prototype,"ySubscriptXSize",2),z([v("uint16")],$.prototype,"ySubscriptYSize",2),z([v("uint16")],$.prototype,"ySubscriptXOffset",2),z([v("uint16")],$.prototype,"ySubscriptYOffset",2),z([v("uint16")],$.prototype,"ySuperscriptXSize",2),z([v("uint16")],$.prototype,"ySuperscriptYSize",2),z([v("uint16")],$.prototype,"ySuperscriptXOffset",2),z([v("uint16")],$.prototype,"ySuperscriptYOffset",2),z([v("uint16")],$.prototype,"yStrikeoutSize",2),z([v("uint16")],$.prototype,"yStrikeoutPosition",2),z([v("uint16")],$.prototype,"sFamilyClass",2),z([v({type:"uint8"})],$.prototype,"bFamilyType",2),z([v({type:"uint8"})],$.prototype,"bSerifStyle",2),z([v({type:"uint8"})],$.prototype,"bWeight",2),z([v({type:"uint8"})],$.prototype,"bProportion",2),z([v({type:"uint8"})],$.prototype,"bContrast",2),z([v({type:"uint8"})],$.prototype,"bStrokeVariation",2),z([v({type:"uint8"})],$.prototype,"bArmStyle",2),z([v({type:"uint8"})],$.prototype,"bLetterform",2),z([v({type:"uint8"})],$.prototype,"bMidline",2),z([v({type:"uint8"})],$.prototype,"bXHeight",2),z([v({type:"uint8",size:16})],$.prototype,"ulUnicodeRange",2),z([v({type:"char",size:4})],$.prototype,"achVendID",2),z([v("uint16")],$.prototype,"fsSelection",2),z([v("uint16")],$.prototype,"usFirstCharIndex",2),z([v("uint16")],$.prototype,"usLastCharIndex",2),z([v("int16")],$.prototype,"sTypoAscender",2),z([v("int16")],$.prototype,"sTypoDescender",2),z([v("int16")],$.prototype,"sTypoLineGap",2),z([v("uint16")],$.prototype,"usWinAscent",2),z([v("uint16")],$.prototype,"usWinDescent",2),z([v({offset:72,type:"uint8",size:8})],$.prototype,"ulCodePageRange",2),z([v({offset:72,type:"int16"})],$.prototype,"sxHeight",2),z([v("int16")],$.prototype,"sCapHeight",2),z([v("uint16")],$.prototype,"usDefaultChar",2),z([v("uint16")],$.prototype,"usBreakChar",2),z([v("uint16")],$.prototype,"usMaxContext",2),$=z([xe("OS/2","os2")],$);var Qu=Object.defineProperty,ef=Object.getOwnPropertyDescriptor,ht=(n,r,e,t)=>{for(var i=t>1?void 0:t?ef(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 Xe=class extends Oe{constructor(n=new ArrayBuffer(32),r,e){super(n,r,e)}};ht([v("fixed")],Xe.prototype,"format",2),ht([v("fixed")],Xe.prototype,"italicAngle",2),ht([v("int16")],Xe.prototype,"underlinePosition",2),ht([v("int16")],Xe.prototype,"underlineThickness",2),ht([v("uint32")],Xe.prototype,"isFixedPitch",2),ht([v("uint32")],Xe.prototype,"minMemType42",2),ht([v("uint32")],Xe.prototype,"maxMemType42",2),ht([v("uint32")],Xe.prototype,"minMemType1",2),ht([v("uint32")],Xe.prototype,"maxMemType1",2),Xe=ht([xe("post")],Xe);var tf=Object.defineProperty,rf=Object.getOwnPropertyDescriptor,Be=(n,r,e,t)=>{for(var i=t>1?void 0:t?rf(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&&tf(r,e,i),i};let Ce=class extends Oe{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Be([v("fixed")],Ce.prototype,"version",2),Be([v("int16")],Ce.prototype,"vertTypoAscender",2),Be([v("int16")],Ce.prototype,"vertTypoDescender",2),Be([v("int16")],Ce.prototype,"vertTypoLineGap",2),Be([v("int16")],Ce.prototype,"advanceHeightMax",2),Be([v("int16")],Ce.prototype,"minTopSideBearing",2),Be([v("int16")],Ce.prototype,"minBottomSideBearing",2),Be([v("int16")],Ce.prototype,"yMaxExtent",2),Be([v("int16")],Ce.prototype,"caretSlopeRise",2),Be([v("int16")],Ce.prototype,"caretSlopeRun",2),Be([v("int16")],Ce.prototype,"caretOffset",2),Be([v({type:"int16",size:4})],Ce.prototype,"reserved",2),Be([v("int16")],Ce.prototype,"metricDataFormat",2),Be([v("int16")],Ce.prototype,"numOfLongVerMetrics",2),Ce=Be([xe("vhea")],Ce);var sf=Object.defineProperty,nf=Object.getOwnPropertyDescriptor,of=(n,r,e,t)=>{for(var i=t>1?void 0:t?nf(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};let Ti=class extends Oe{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Ti(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()}))}};Ti=of([xe("vmtx")],Ti);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 He extends gi{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(ar(e).getUint32(0))}static checksum(e){const t=ar(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=d=>d+3&-4,i=e.tableViews.size,s=Array.from(e.tableViews.values()).reduce((d,p)=>d+t(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();e.tableViews.forEach((d,p)=>{const m=c[h++];m.tag=p,m.checkSum=this.checksum(d),m.offset=l,m.length=d.byteLength,o.view.writeBytes(d,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 lr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSfnt(){return new $t(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])),Fr([v("uint32")],He.prototype,"scalerType"),Fr([v("uint16")],He.prototype,"numTables"),Fr([v("uint16")],He.prototype,"searchRange"),Fr([v("uint16")],He.prototype,"entrySelector"),Fr([v("uint16")],He.prototype,"rangeShift");class Si extends He{constructor(){super(...arguments);u(this,"format","OpenType");u(this,"mimeType","font/otf")}static from(e){return super.from(e)}}u(Si,"signature",new Set([1330926671]));var lf=Object.defineProperty,$r=(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};class qt extends je{constructor(r,e){super(r,e,20)}}$r([v({type:"char",size:4})],qt.prototype,"tag"),$r([v("uint32")],qt.prototype,"offset"),$r([v("uint32")],qt.prototype,"compLength"),$r([v("uint32")],qt.prototype,"origLength"),$r([v("uint32")],qt.prototype,"origChecksum");var hf=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&&hf(r,e,i),i};const Ne=(Rt=class extends gi{constructor(){super(...arguments);u(this,"format","WOFF");u(this,"mimeType","font/woff");u(this,"_sfnt")}get subfontFormat(){return He.is(this.flavor)?"TrueType":Si.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(ar(e).getUint32(0))}static checkSum(e){const t=ar(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=d=>d+3&-4,s=[];e.tableViews.forEach((d,p)=>{const m=ar(qc(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)));s.push({tag:p,view:m.byteLength<d.byteLength?m:d,rawView:d})});const o=s.length,a=s.reduce((d,p)=>d+i(p.view.byteLength),0),l=new Rt(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((d,p)=>d+i(p.rawView.byteLength),0);let h=44+o*20,c=0;const f=l.getDirectories();return s.forEach(d=>{const p=f[c++];p.tag=d.tag,p.offset=h,p.compLength=d.view.byteLength,p.origChecksum=Rt.checkSum(d.rawView),p.origLength=d.rawView.byteLength,l.view.writeBytes(d.view,h),h+=i(p.compLength)}),l.view.writeBytes(t),l}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new qt(this.view.buffer,e);return e+=t.view.byteLength,t})}createSfnt(){return new $t(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(Wc(new Uint8Array(this.view.buffer.slice(s,l))).buffer),e},{}))}},u(Rt,"signature",new Set([2001684038])),Rt);Ge([v("uint32")],Ne.prototype,"signature"),Ge([v("uint32")],Ne.prototype,"flavor"),Ge([v("uint32")],Ne.prototype,"length"),Ge([v("uint16")],Ne.prototype,"numTables"),Ge([v("uint16")],Ne.prototype,"reserved"),Ge([v("uint32")],Ne.prototype,"totalSfntSize"),Ge([v("uint16")],Ne.prototype,"majorVersion"),Ge([v("uint16")],Ne.prototype,"minorVersion"),Ge([v("uint32")],Ne.prototype,"metaOffset"),Ge([v("uint32")],Ne.prototype,"metaLength"),Ge([v("uint32")],Ne.prototype,"metaOrigLength"),Ge([v("uint32")],Ne.prototype,"privOffset"),Ge([v("uint32")],Ne.prototype,"privLength");let Mi=Ne;function aa(n,r=!0){if(He.is(n))return new He(n);if(Si.is(n))return new Si(n);if(Mi.is(n))return new Mi(n);if(r)throw new Error("Failed to parseFont")}const ki=class ki{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,{...ki.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 {
|
|
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(ti,"_instance");class te extends ei{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ti.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 Qt({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(te,"_instance");class wl extends ei{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 Qt({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,Mn=(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 ri extends Qr{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)}}}Mn([A({default:24})],ri.prototype,"fps"),Mn([A({default:1})],ri.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 d=0;for(let p=0;p<s;p++)d+=o[f]*a[p*c+f];h[f]=d}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:d}=t;switch(e){case"*":for(let p=0;p<d;p++){let m=0;for(let _=0;_<s;_++)_<d&&(m+=l[p*s+_]*(h[_]??0));f[p]=m}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let d=0;d<s;d++)for(let p=0;p<o;p++){const m=p*s;let _=0;for(let y=0;y<o;y++){const S=m+y,C=y*s+d;_+=l[S]*(h[C]??0)}f[m+d]=_}break;case"=":for(let d=0;d<a;d++){const p=h[d];p!==void 0&&(l[d]=p)}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 Qi=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,d=l*i-s*a,p=r*c+e*f+t*d;if(p===0)return this.set([0,0,0,0,0,0,0,0,0]);const m=1/p;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,d*m,(e*a-l*r)*m,(s*r-e*i)*m])}};class An extends it{constructor(r){super(4,4,r)}}class On extends Qi{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 Qi{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),d=t*i*(1-o)-e*a,p=o+i*i*(1-o),m=-Math.atan2(-d,f),_=-Math.atan2(c,Math.sqrt(d*d+p*p)),y=-Math.atan2(-h,l);return[m,_,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 Un=Te/180,Cl=180/Te;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 Vi 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 Vi(e).clone().sub(new Vi(r)).multiply(t).add(new Vi(r))}};class Sl extends Je{constructor(){super(3)}}class Dn 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,er=(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},vr=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.FRONT=1]="FRONT",n[n.BACK=2]="BACK",n))(vr||{});g.Node=class extends Ji{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=Kr.get(t)??g.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},er([A()],g.Node.prototype,"name",2),er([A()],g.Node.prototype,"mask",2),er([A({default:"visible"})],g.Node.prototype,"visibility",2),er([A({default:0})],g.Node.prototype,"visibleDelay",2),er([A({default:Number.MAX_SAFE_INTEGER})],g.Node.prototype,"visibleDuration",2),g.Node=er([H("Node")],g.Node);class In{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,br=(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)}},br([A({default:0})],g.Timer.prototype,"start",2),br([A({default:0})],g.Timer.prototype,"current",2),br([A({default:Number.MAX_SAFE_INTEGER})],g.Timer.prototype,"end",2),br([A({default:!1})],g.Timer.prototype,"loop",2),g.Timer=br([H("Timer")],g.Timer);var Dl=Object.defineProperty,tr=(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=ji(this.realWidth)&&ji(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(){dn&&this.source instanceof ImageBitmap&&this.source.close()}}tr([ee()],de.prototype,"source"),tr([ee({default:0})],de.prototype,"width"),tr([ee({default:0})],de.prototype,"height"),tr([ee({default:"linear"})],de.prototype,"filterMode"),tr([ee({default:"clamp_to_edge"})],de.prototype,"wrapMode"),tr([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)&&qi,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||!qi)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(_r&&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 es 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,Rn=(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 ts=(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",""),Cn(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(),d=f.slice(f.lastIndexOf(".")+1);h=h||Yt.mimeTypes.get(d)||`video/${d}`}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);Rn([ee({default:!0})],ts.prototype,"autoUpdate"),Rn([ee({default:0})],ts.prototype,"fps");let Bn=ts;class rs extends es{}var kl=Object.defineProperty,Nl=Object.getOwnPropertyDescriptor,wr=(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 On);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new rs,needsUpload:!1},{texture:new rs,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,ti.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)}},wr([A({default:0})],g.Viewport.prototype,"x",2),wr([A({default:0})],g.Viewport.prototype,"y",2),wr([A({default:0})],g.Viewport.prototype,"width",2),wr([A({default:0})],g.Viewport.prototype,"height",2),g.Viewport=wr([H({tag:"Viewport",renderable:!0})],g.Viewport);class Ln extends ri{constructor(){super(...arguments);u(this,"renderStack",new In);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},kn=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},Nn=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)}},is=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,ii=function(n){var r=n.toString(16);return r.length<2?"0"+r:r},Fn=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}},$n=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}},zn=function(n){return{h:kn(n.h),s:We(n.s,0,100),l:We(n.l,0,100),a:We(n.a)}},Vn=function(n){return{h:me(n.h),s:me(n.s),l:me(n.l),a:me(n.a,3)}},jn=function(n){return $n((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},xr=function(n){return{h:(r=Fn(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,ss={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:Nn({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=zn({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 jn(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)?Nn({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=zn({h:Number(r),s:Number(e),l:Number(t),a:Number(s)});return jn(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:kn(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 $n(o)},"hsv"]]},Gn=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"?Gn(n.trim(),ss.string):typeof n=="object"&&n!==null?Gn(n,ss.object):[null,void 0]},ns=function(n,r){var e=xr(n);return{h:e.h,s:We(e.s+100*r,0,100),l:e.l,a:e.a}},os=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},qn=function(n,r){var e=xr(n);return{h:e.h,s:e.s,l:We(e.l+100*r,0,100),a:e.a}},as=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(os(this.rgba),2)},n.prototype.isDark=function(){return os(this.rgba)<.5},n.prototype.isLight=function(){return os(this.rgba)>=.5},n.prototype.toHex=function(){return r=is(this.rgba),e=r.r,t=r.g,i=r.b,o=(s=r.a)<1?ii(me(255*s)):"","#"+ii(e)+ii(t)+ii(i)+o;var r,e,t,i,s,o},n.prototype.toRgb=function(){return is(this.rgba)},n.prototype.toRgbString=function(){return r=is(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 Vn(xr(this.rgba))},n.prototype.toHslString=function(){return r=Vn(xr(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=Fn(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(ns(this.rgba,r))},n.prototype.desaturate=function(r){return r===void 0&&(r=.1),st(ns(this.rgba,-r))},n.prototype.grayscale=function(){return st(ns(this.rgba,-1))},n.prototype.lighten=function(r){return r===void 0&&(r=.1),st(qn(this.rgba,r))},n.prototype.darken=function(r){return r===void 0&&(r=.1),st(qn(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=xr(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 as?n:new as(n)},Wn=[],Wl=function(n){n.forEach(function(r){Wn.indexOf(r)<0&&(r(as,ss),Wn.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,d="black";if(!s.length)for(var p in e)s[p]=new n(e[p]).toRgb();for(var m in e){var _=(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));_<f&&(f=_,d=m)}return d}},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 ls 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*-.213,s+t*-.715+e*-.715,o+t*-.072+e*(1-o),0,0,i+t*-.213+e*.143,s+t*(1-s)+e*.14,o+t*-.072+e*-.283,0,0,i+t*-.213+e*-.787,s+t*-.715+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 An([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 Dn(r[4]/255,r[9]/255,r[14]/255,r[19]/255)}}class hs 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=Xn(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 d=e;d<i;d+=e){const p=n[d],m=n[d+1];p<a&&(a=p),m<l&&(l=m),p>c&&(c=p),m>f&&(f=m)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return Pr(s,o,e,a,l,h,0),o}function Xn(n,r,e,t,i){let s;if(i===ch(n,r,e,t)>0)for(let o=r;o<e;o+=t)s=Kn(o/t|0,n[o],n[o+1],s);else for(let o=e-t;o>=r;o-=t)s=Kn(o/t|0,n[o],n[o+1],s);return s&&rr(s,s.next)&&(Tr(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&&(rr(e,e.next)||se(e.prev,e,e.next)===0)){if(Tr(e),e=r=e.prev,e===e.next)break;t=!0}else e=e.next;while(t||e!==r);return r}function Pr(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),Tr(n),n=h.next,a=h.next;continue}if(n=h,n===a){o?o===1?(n=Kl(Bt(n),r),Pr(n,r,e,t,i,s,2)):o===2&&Jl(n,r,e,t,i,s):Pr(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),d=Math.max(i,s,o),p=Math.max(a,l,h);let m=t.next;for(;m!==r;){if(m.x>=c&&m.x<=d&&m.y>=f&&m.y<=p&&Cr(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,d=o.y,p=Math.min(a,l,h),m=Math.min(c,f,d),_=Math.max(a,l,h),y=Math.max(c,f,d),S=cs(p,m,r,e,t),C=cs(_,y,r,e,t);let x=n.prevZ,T=n.nextZ;for(;x&&x.z>=S&&T&&T.z<=C;){if(x.x>=p&&x.x<=_&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&Cr(a,c,l,f,h,d,x.x,x.y)&&se(x.prev,x,x.next)>=0||(x=x.prevZ,T.x>=p&&T.x<=_&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&Cr(a,c,l,f,h,d,T.x,T.y)&&se(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;x&&x.z>=S;){if(x.x>=p&&x.x<=_&&x.y>=m&&x.y<=y&&x!==i&&x!==o&&Cr(a,c,l,f,h,d,x.x,x.y)&&se(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;T&&T.z<=C;){if(T.x>=p&&T.x<=_&&T.y>=m&&T.y<=y&&T!==i&&T!==o&&Cr(a,c,l,f,h,d,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;!rr(t,i)&&Yn(t,e,e.next,i)&&Er(t,i)&&Er(i,t)&&(r.push(t.i,e.i,i.i),Tr(e),Tr(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=Zn(o,a);o=Bt(o,o.next),l=Bt(l,l.next),Pr(o,r,e,t,i,s,0),Pr(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=Xn(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=Zn(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(rr(n,e))return e;do{if(rr(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&&Hn(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);Er(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=cs(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 cs(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 Hn(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 Cr(n,r,e,t,i,s,o,a){return!(n===o&&r===a)&&Hn(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)&&(Er(n,r)&&Er(r,n)&&hh(n,r)&&(se(n.prev,n,r.prev)||se(n,r.prev,r))||rr(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 rr(n,r){return n.x===r.x&&n.y===r.y}function Yn(n,r,e,t){const i=ni(se(n,r,e)),s=ni(se(n,r,t)),o=ni(se(e,t,n)),a=ni(se(e,t,r));return!!(i!==s&&o!==a||i===0&&si(n,e,r)||s===0&&si(n,t,r)||o===0&&si(e,n,t)||a===0&&si(e,r,t))}function si(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 ni(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&&Yn(e,e.next,n,r))return!0;e=e.next}while(e!==n);return!1}function Er(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 Zn(n,r){const e=us(n.i,n.x,n.y),t=us(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 Kn(n,r,e,t){const i=us(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 Tr(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 us(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 fs(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:d=0,shadowColor:p="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=d,n.shadowColor=p}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],d=t[2],p=t[5],m=t[8],_=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*_+a*C+l*b,s[3]=o*y+a*x+l*P,s[6]=o*S+a*T+l*E,s[1]=h*_+c*C+f*b,s[4]=h*y+c*x+f*P,s[7]=h*S+c*T+f*E,s[2]=d*_+p*C+m*b,s[5]=d*y+p*x+m*P,s[8]=d*S+p*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,d=a*l-c*s,p=h*s-o*l,m=e*f+t*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/m;return r[0]=f*_,r[1]=(i*h-c*t)*_,r[2]=(a*t-i*o)*_,r[3]=d*_,r[4]=(c*e-i*l)*_,r[5]=(i*s-a*e)*_,r[6]=p*_,r[7]=(t*l-h*e)*_,r[8]=(o*e-t*s)*_,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(ds.makeScale(r,e)),this}rotate(r){return this.premultiply(ds.makeRotation(-r)),this}translate(r,e){return this.premultiply(ds.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 ds=new ke;function Jn(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 d=r*r,p=e*e;const m=c*c,_=f*f,y=m/d+_/p;if(y>1){const F=Math.sqrt(y);r=F*r,e=F*e,d=r*r,p=e*e}const S=d*_+p*m,C=(d*p-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=Jn(1,0,(c-T)/r,(f-b)/e),D=Jn((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 d(y,S,C){const x=new SyntaxError(`Unexpected character "${y}" at index ${S}.`);throw x.partial=C,x}function p(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let m;const _=n.length;for(let y=0;y<_;y++){if(m=n[y],Array.isArray(r)&&r.includes(f.length%e)&&he.FLAGS.test(m)){a=1,h=m,p();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&&d(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])&&d(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]==="."&&d(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)&&d(m,y,f)}}he.WHITESPACE.test(m)?(p(),a=0,l=!1):he.COMMA.test(m)?(p(),a=0,l=!0):he.SIGN.test(m)?(p(),a=1,h=m):he.POINT.test(m)?(p(),a=2,h=m):d(m,y,f)}return p(),f}function ir(n,r){return n-(r-n)}function Qn(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(ir(e.x,t.x),ir(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(ir(e.x,t.x),ir(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=ir(e.x,t.x),l=ir(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 eo(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 to(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 _h(n,r){return 3*(1-n)*n*n*r}function vh(n,r){return n*n*n*r}function ro(n,r,e,t,i){return mh(n,r)+yh(n,e)+_h(n,t)+vh(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,oi=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 d=(xh-f)/1;return d*=d,ps(n,r,e,t,i,s,o,a,h,d,0),h.push(o,a),h}function ps(n,r,e,t,i,s,o,a,l,h,c){if(c>wh)return;const f=(n+e)/2,d=(r+t)/2,p=(e+i)/2,m=(t+s)/2,_=(i+o)/2,y=(s+a)/2,S=(f+p)/2,C=(d+m)/2,x=(p+_)/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>oi&&F>oi){if((D+F)*(D+F)<=h*(E*E+w*w)){l.push(b,P);return}}else if(D>oi){if(D*D<=h*(E*E+w*w)){l.push(b,P);return}}else if(F>oi){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}}ps(n,r,f,d,S,C,b,P,l,h,c+1),ps(b,P,x,T,_,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,gs(a,n,r,e,t,i,s,c,0),a.push(i,s),a}function gs(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,d=(i+o)/2,p=(h+f)/2,m=(c+d)/2;let _=s-r,y=o-e;const S=Math.abs((t-s)*y-(i-o)*_);if(S>Eh){if(S*S<=a*(_*_+y*y)){n.push(p,m);return}}else if(_=p-(r+s)/2,y=m-(e+o)/2,_*_+y*y<=a){n.push(p,m);return}gs(n,r,e,h,c,p,m,a,l+1),gs(n,p,m,f,d,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 io(n,r,e,t){return Mh(n,r)+Ah(n,e)+Oh(n,t)}const Uh=1e-4,so=1e-4;function Dh(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=Ih(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]},d=o,p=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(d){n=n.slice(),p&&(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,_=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;d||(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<_-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),Ee=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,ep=Ke+il*il*x;Fe<=ep?l.join==="bevel"||Fe/x>T?(Z?(m.push(Ee,$e),m.push(E+B*I,w+U*I),m.push(Ee,$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(Ee,$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(Ee,$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(Ee,$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(Ee,$e),m.push(Ee,$e)),y+=2),m.push(E-V*R,w-M*R),m.push(E+V*I,w+M*I),y+=2)}b=n[(_-2)*2],P=n[(_-2)*2+1],E=n[(_-1)*2],w=n[(_-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),d||(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=so*so;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 Ih(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 d,p;o?(d=t,p=-e):(d=-t,p=e);const m=l+d,_=h+p,y=c+d,S=f+p;return a.push(m,_),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 d=c;const p=f-c,m=Math.abs(p),_=Math.sqrt(l*l+h*h),y=(15*m*Math.sqrt(_)/Math.PI>>0)+1,S=p/y;if(d+=S,a){o.push(n,r),o.push(e,t);for(let C=1,x=d;C<y;C++,x+=S)o.push(n,r),o.push(n+Math.sin(x)*_,r+Math.cos(x)*_);o.push(n,r),o.push(i,s)}else{o.push(e,t),o.push(n,r);for(let C=1,x=d;C<y;C++,x+=S)o.push(n+Math.sin(x)*_,r+Math.cos(x)*_),o.push(n,r);o.push(i,s),o.push(n,r)}return y*2}class sr{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],d=t[o+1]-c,p=(s-c)/d;return(o+p)/(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.getAdaptivePointArray(),r)}strokeTriangulate(r){return Dh(this.getAdaptivePointArray(),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 Rh=new ke,oo=new ke,ao=new ke,ai=new O;class ms extends sr{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,d=l-this.cy;a=f*h-d*c+this.cx,l=f*c+d*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),d=f>Math.PI?1:0,p=a?1:0,m=l*180/Math.PI;if(f>=2*Math.PI){const _=s+Math.PI,y=r+t*Math.cos(_)*Math.cos(l)-i*Math.sin(_)*Math.sin(l),S=e+t*Math.cos(_)*Math.sin(l)+i*Math.sin(_)*Math.cos(l);return[{type:"M",x:h,y:c},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:p,x:y,y:S},{type:"A",rx:t,ry:i,angle:m,largeArcFlag:0,sweepFlag:p,x:h,y:c}]}else{const _=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:d,sweepFlag:p,x:_,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 ai.set(this.cx,this.cy),ai.applyMatrix3(r),this.cx=ai.x,this.cy=ai.y,kh(r)?Bh(this,r):Lh(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,d=l*4+(o?2:0)+2,p=d,m=h,_=o+i,y=a,S=e+_,C=e-_,x=t+y;if(c[f++]=S,c[f++]=x,c[--d]=x,c[--d]=C,a){const b=t-y;c[p++]=C,c[p++]=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[--d]=B,c[--d]=F,c[p++]=F,c[p++]=U,c[--m]=U,c[--m]=D}_=o,y=a+s,S=e+_,C=e-_,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 d=0;d<a.length;d+=2)l+=a[d],h+=a[d+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 d=0;d<a.length;d+=2)e[c*i]=a[d],e[c*i+1]=a[d+1],d>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 Bh(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=Rh.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,_=Nh(m[0],m[1],m[4]),y=Math.sqrt(_.rt1),S=Math.sqrt(_.rt2);if(n.rx=1/y,n.ry=1/S,n.rotate=Math.atan2(_.sn,_.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(_.cs,_.sn,0,-_.sn,_.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 Lh(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 kh(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 Nh(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 Fh extends ms{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 d=0;d<h+1;d++){const p=Math.cos(f),m=Math.sin(f),_=e+p*i,y=t+m*i;r.push(_,y),f+=c}return r}}class Sr extends sr{constructor(r=[]){super(),this.curves=r}getFlatCurves(){return this.curves.flatMap(r=>r instanceof Sr?r.getFlatCurves():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}applyTransform(r){return this.curves.forEach(e=>e.applyTransform(r)),this}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 ys extends sr{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 ys(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(ro(r,t.x,i.x,s.x,o.x),ro(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,d)=>{for(const p of f)for(let m=0;m<=d;m++){const _=m/d-.5,y=Math.min(1,Math.max(0,p+_)),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 $h extends ms{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 sr{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 zh extends Sr{}class _s extends sr{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 _s(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(io(r,t.x,i.x,s.x),io(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 Vh extends zh{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 d=0;s*=i,e[s+d]=f[0],e[s+d+1]=f[1],d+=i,e[s+d]=f[2],e[s+d+1]=f[3],d+=i,e[s+d]=f[6],e[s+d+1]=f[7],d+=i,e[s+d]=f[4],e[s+d+1]=f[5],d+=i;const p=s/i;return t[o++]=p,t[o++]=p+1,t[o++]=p+2,t[o++]=p+1,t[o++]=p+3,t[o++]=p+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 jh extends ms{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,d=o-c,p=a-f;return this._center=new O(l,h),this._radius=new O(c,f),this._diff=new O(d,p),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 Gh extends sr{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(to(o,a.x,l.x,h.x,c.x),to(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 nr extends Sr{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 Qn(e,this),this}addData(e){return this.addCommands(eo(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(ys.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(_s.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 Fh(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 $h(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 Vh(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 jh(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 Gh([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 qh(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Wh(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 we extends Sr{constructor(e,t={}){super();u(this,"currentCurve",new nr);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof we?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 we?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 nr().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 nr,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}reset(){return this.currentCurve=new nr,this.curves.push(this.currentCurve),this.style={},this}addCommands(e){return Qn(e,this),this}addData(e){return this.addCommands(eo(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.getFlatCurves(),i=[],s=[],o=[];t.forEach((l,h)=>{const c=l.getControlPointRefs(),f=l.isClockwise();o[h]=c,s[h]=f;const d=c[0],p=c[c.length-1]??d;i.push({start:f?p:d,end:f?d:p,index:h})});const a=[];return i.forEach((l,h)=>{a[h]=[],i.forEach((c,f)=>{var d;c.start&&l.end&&f!==h&&((d=c.start)!=null&&d.equals(l.end))&&a[h].push(c.index)})}),t.forEach((l,h)=>{const c=s[h];o[h].forEach(f=>{f.add(l.getNormal(l.getTForPoint(f)).scale(c?e:-e))})}),a.forEach((l,h)=>{const c=o[h];l.forEach(f=>{const d=o[f],p=Wh(c[c.length-1],c[c.length-2]??c[c.length-1],d[0],d[1]??d[0]);p&&(c[c.length-1].copy(p),d[0].copy(p))})}),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),d=o.getNormal(c),p=d.clone().scale(l?a:-a),m=d.clone().scale(l?-a:a);h.push(f.clone().add(p),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(),fs(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(),fs(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[qh(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 Xh="px",Hh=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][Xh],e<0&&(e=yo[r].in*Hh),e*Number.parseFloat(n)}const Yh=new ke,li=new ke,_o=new ke,vo=new ke;function Zh(n,r,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const t=Kh(n);return e.length>0&&t.premultiply(e[e.length-1]),r.copy(t),e.push(t),t}function Kh(n){const r=new ke,e=Yh;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,d=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],d=h[2]),li.makeTranslation(-f,-d),_o.makeRotation(c),vo.multiplyMatrices(_o,li),li.makeTranslation(f,d),e.multiplyMatrices(li,vo)}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 Jh(n){return new we().arc(J(n.getAttribute("cx")||0),J(n.getAttribute("cy")||0),J(n.getAttribute("r")||0),0,Math.PI*2)}function Qh(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 ec(n){return new we().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 tc(n){return new we().moveTo(J(n.getAttribute("x1")||0),J(n.getAttribute("y1")||0)).lineTo(J(n.getAttribute("x2")||0),J(n.getAttribute("y2")||0))}function rc(n){const r=new we,e=n.getAttribute("d");return!e||e==="none"?null:(r.addData(e),r)}const ic=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function sc(n){var t;const r=new we;let e=0;return(t=n.getAttribute("points"))==null||t.replace(ic,(i,s,o)=>{const a=J(s),l=J(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!0,r}const nc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function oc(n){var t;const r=new we;let e=0;return(t=n.getAttribute("points"))==null||t.replace(nc,(i,s,o)=>{const a=J(s),l=J(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!1,r}function ac(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 we;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),d=n.style.getPropertyValue(f);r[f]=d,t[f]=d}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 bs(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":Qh(n,t);break;case"g":o=ot(n,o,t);break;case"path":o=ot(n,o,t),n.hasAttribute("d")&&(s=rc(n));break;case"rect":o=ot(n,o,t),s=ac(n);break;case"polygon":o=ot(n,o,t),s=sc(n);break;case"polyline":o=ot(n,o,t),s=oc(n);break;case"circle":o=ot(n,o,t),s=Jh(n);break;case"ellipse":o=ot(n,o,t),s=ec(n);break;case"line":o=ot(n,o,t),s=tc(n);break;case"defs":i=!0;break;case"use":{o=ot(n,o,t);const p=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),m=(f=n.viewportElement)==null?void 0:f.getElementById(p);m?bs(m,o,e,t):console.warn(`'use node' references non-existent node id: ${p}`);break}default:console.warn(n);break}if(o.display==="none")return e;Object.assign(r,o);const a=new ke,l=[],h=Zh(n,a,l);s&&(s.applyTransform(a),e.push(s),s.style=r);const c=n.childNodes;for(let d=0,p=c.length;d<p;d++){const m=c[d];i&&m.nodeName!=="style"&&m.nodeName!=="defs"||bs(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(bs(go(n),{}))}class wo extends we{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,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof de?e=this.strokeStyle:e=new hs(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new we(this),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.currentCurve=new nr,this.curves=[this.currentCurve])}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 hs(this.fillStyle)),this._fille.push({path:new we(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new nr,this.curves=[this.currentCurve]}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._stroke=e._stroke.slice(),this._fille=e._fille.slice(),this}reset(){return super.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._stroke.length=0,this._fille.length=0,this}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._stroke.length,c=0;c<h;c++){o=t.length;const f=this._stroke[c];a??(a=f.texture),f.path.strokeTriangulate({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._fille.length,c=0;c<h;c++){const f=this._fille[c];a??(a=f.texture),a!==f.texture&&l("fill"),o=t.length,f.path.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(()=>cf);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 ui(s.map(o=>({duration:o.delay,texture:new es(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 Bn(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 lc=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 hc(n){for(const[r,e]of lc)if(e.includes(n))return r}async function cc(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=hc(i))}return r??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const hi="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",hi?new FinalizationRegistry(r=>{const e=this.get(r);e&&"destroy"in e&&e.destroy(),this._handled.delete(r)}):void 0);hi||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 hi&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(r)),e}set(r,e){let t=e;hi&&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 cc(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 Mr{}class Oo extends Mr{install(r){bt(r,"backgroundColor"),bt(r,"backgroundImage"),r.prototype.getComputedBackgroundImage=uc}}async function uc(){if(this.backgroundImage)return await mt.texture.load(this.backgroundImage)}class Uo extends Mr{install(r){bt(r,"filter",{default:""}),r.prototype.getComputedFilter=fc,r.prototype.getComputedFilterColorMatrix=dc}}const Do={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function fc(){const n=yr(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 dc(){const n=new ls,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 pc(){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 gc(){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",...pc(),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 mc(){return{...gc(),...Ro()}}class Bo extends Mr{install(r){const e=Ro();for(const t in e)bt(r,t,{default:e[t]});bt(r,"direction",{default:"inherit"})}}class Lo extends Mr{install(r){const e=Io();for(const t in e)bt(r,t,{default:e[t]});r.prototype.getComputedTransform=yc,r.prototype.getComputedTransformOrigin=_c}}function yc(){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*Un);let t=this.transform;(!t||t==="none")&&(t=""),yr(t,{width:this.width,height:this.height}).forEach(({name:f,args:d})=>{const p=d.map(m=>m.normalizedIntValue);switch(n.identity(),f){case"translate":n.translate(p[0]*this.width,(p[1]??p[0])*this.height);break;case"translateX":n.translateX(p[0]*this.width);break;case"translateY":n.translateY(p[0]*this.height);break;case"translateZ":n.translateZ(p[0]);break;case"translate3d":n.translate3d(p[0]*this.width,(p[1]??p[0])*this.height,p[2]??p[1]??p[0]);break;case"scale":n.scale(p[0],p[1]??p[0]);break;case"scaleX":n.scaleX(p[0]);break;case"scaleY":n.scaleY(p[0]);break;case"scale3d":n.scale3d(p[0],p[1]??p[0],p[2]??p[1]??p[0]);break;case"rotate":n.rotate(p[0]*le);break;case"rotateX":n.rotateX(p[0]*le);break;case"rotateY":n.rotateY(p[0]*le);break;case"rotateZ":n.rotateZ(p[0]*le);break;case"rotate3d":n.rotate3d(p[0]*le,(p[1]??p[0])*le,(p[2]??p[1]??p[0])*le,(p[3]??p[2]??p[1]??p[0])*le);break;case"skew":n.skew(p[0],p[0]??p[1]);break;case"skewX":n.skewX(p[0]);break;case"skewY":n.skewY(p[0]);break;case"matrix":n.set(p);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 _c(){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 Qr{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 bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,ws=(n,r,e,t)=>{for(var i=t>1?void 0:t?wc(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&&bc(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}}}},ws([A()],g.CanvasItem.prototype,"tint",2),ws([A()],g.CanvasItem.prototype,"blendMode",2),g.CanvasItem=ws([H("CanvasItem")],g.CanvasItem);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,Nt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pc(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&&xc(r,e,i),i};const ko=n=>n,No=or(.25,.1,.25,1),Fo=or(.42,0,1,1),$o=or(0,0,.58,1),zo=or(.42,0,.58,1);function or(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=_=>(3*s*_+2*o)*_+a,d=_=>((s*_+o)*_+a)*_,p=_=>((l*_+h)*_+c)*_;function m(_){let y=_,S,C;for(let b=0;b<8;b++){if(C=d(y)-_,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=_;x>T;){if(C=d(y)-_,Math.abs(C)<1e-6)return y;C>0?x=y:T=y,y=(x+T)/2}return y}return _=>p(m(_))}const ci={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 Jt);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 ci.linear;if(e in ci)return ci[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return or(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:d,easing:p}=i,m={...i.props};return t.forEach((_,y)=>{(!(y in m)||m[y]===null)&&(m[y]=_),(!(y in f)||f[y]===null)&&(f[y]=_)}),[{offset:d,easing:p,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,d=c-a,p=l((e-a)/d),m={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((_,y)=>{t[y]=this._getDiffValue(y,h[y],f[y],p,m)})}_getDiffValue(e,t,i,s,o){let a,l;if(t===void 0||i===void 0)if(t!==void 0)a=mr(e,String(t),o),l=Gi(a);else if(i!==void 0)l=mr(e,String(i),o),a=Gi(l);else return;else a=mr(e,String(t),o),l=mr(e,String(i),o);if(Array.isArray(a)&&Array.isArray(l)){const h=new Set,c={},f={};a.forEach(({name:p,args:m})=>{c[p]=m,h.add(p)}),l.forEach(({name:p,args:m})=>{f[p]=m,h.add(p)});let d="";return h.forEach(p=>{var S,C;const m=Math.max(((S=c[p])==null?void 0:S.length)??0,((C=f[p])==null?void 0:C.length)??0),_=c[p],y=f[p];d+=`${p}(${Array.from({length:m},(x,T)=>{const b=_==null?void 0:_[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(", ")}) `}),d}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 Cc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,Tc=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ec(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&&Cc(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 d=e[f],p=e[f+1];h[f]=t*d+i*p+s,h[f+1]=o*d+a*p+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=Tc([H({tag:"Node2D",renderable:!0})],g.Node2D);var Sc=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,ge=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mc(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&&Sc(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 ui 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 Ac=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,fi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Oc(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&&Ac(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 ui?t=e:t=new ui(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))}},fi([ee()],g.Image2D.prototype,"resource",2),fi([A({default:!1})],g.Image2D.prototype,"gif",2),fi([A({default:""})],g.Image2D.prototype,"src",2),g.Image2D=fi([H("Image2D")],g.Image2D);var Uc=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,xs=(n,r,e,t)=>{for(var i=t>1?void 0:t?Dc(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&&Uc(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())}},xs([A({default:2})],g.Lottie2D.prototype,"pixelRatio",2),xs([A({default:""})],g.Lottie2D.prototype,"src",2),g.Lottie2D=xs([H("Lottie2D")],g.Lottie2D);var Se=Uint8Array,Ve=Uint16Array,Ps=Int32Array,di=new Se([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]),pi=new Se([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]),Cs=new Se([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 Ps(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(di,2),Go=jo.b,Es=jo.r;Go[28]=258,Es[258]=28;for(var qo=Vo(pi,0),Ic=qo.b,Wo=qo.r,Ts=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,Ts[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,d=f|(1<<c)-1;f<=d;++f)a[Ts[f]>>l]=h}else for(a=new Ve(t),i=0;i<t;++i)n[i]&&(a[i]=Ts[o[n[i]-1]++]>>15-n[i]);return a},St=new Se(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 Ar=new Se(32),re=0;re<32;++re)Ar[re]=5;var Rc=lt(St,9,0),Bc=lt(St,9,1),Lc=lt(Ar,5,0),kc=lt(Ar,5,1),Ss=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},Ms=function(n,r){var e=r/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(r&7)},As=function(n){return(n+7)/8|0},Xo=function(n,r,e){return(e==null||e>n.length)&&(e=n.length),new Se(n.subarray(r,e))},Nc=["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||Nc[n]);if(t.code=n,Error.captureStackTrace&&Error.captureStackTrace(t,et),!e)throw t;return t},Fc=function(n,r,e,t){var i=n.length,s=0;if(!i||r.f&&!r.l)return e||new Se(0);var o=!e,a=o||r.i!=2,l=r.i;o&&(e=new Se(i*3));var h=function(Le){var Fe=e.length;if(Le>Fe){var Ee=new Se(Math.max(Fe*2,Le));Ee.set(e),e=Ee}},c=r.f||0,f=r.p||0,d=r.b||0,p=r.l,m=r.d,_=r.m,y=r.n,S=i*8;do{if(!p){c=Qe(n,f,1);var C=Qe(n,f+1,3);if(f+=3,C)if(C==1)p=Bc,m=kc,_=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 Se(w),F=new Se(19),B=0;B<E;++B)F[Cs[B]]=Qe(n,f+B*3,7);f+=E*3;for(var U=Ss(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);_=Ss(I),y=Ss(j),p=lt(I,_,1),m=lt(j,y,1)}else et(1);else{var x=As(f)+4,T=n[x-4]|n[x-3]<<8,b=x+T;if(b>i){l&&et(0);break}a&&h(d+T),e.set(n.subarray(x,b),d),r.b=d+=T,r.p=f=b*8,r.f=c;continue}if(f>S){l&&et(0);break}}a&&h(d+131072);for(var k=(1<<_)-1,L=(1<<y)-1,K=f;;K=f){var q=p[Ms(n,f)&k],X=q>>4;if(f+=q&15,f>S){l&&et(0);break}if(q||et(2),X<256)e[d++]=X;else if(X==256){K=f,p=null;break}else{var W=X-254;if(X>264){var B=X-257,G=di[B];W=Qe(n,f,(1<<G)-1)+Go[B],f+=G}var Q=m[Ms(n,f)&L],Z=Q>>4;Q||et(3),f+=Q&15;var j=Ic[Z];if(Z>3){var G=pi[Z];j+=Ms(n,f)&(1<<G)-1,f+=G}if(f>S){l&&et(0);break}a&&h(d+131072);var ae=d+W;if(d<j){var ut=s-j,Ze=Math.min(j,ae);for(ut+d<0&&et(3);d<Ze;++d)e[d]=t[ut+d]}for(;d<ae;++d)e[d]=e[d-j]}}r.l=p,r.p=K,r.b=d,r.f=c,p&&(c=1,r.m=_,r.d=m,r.n=y)}while(!c);return d!=e.length&&o?Xo(e,0,d):e.subarray(0,d)},yt=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8},Or=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},Os=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 Se(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 d=s[0].s,t=1;t<i;++t)s[t].s>d&&(d=s[t].s);var p=new Ve(d+1),m=Us(e[c-1],p,0);if(m>r){var t=0,_=0,y=m-r,S=1<<y;for(s.sort(function(P,E){return p[E.s]-p[P.s]||P.f-E.f});t<i;++t){var C=s[t].s;if(p[C]>r)_+=S-(1<<m-p[C]),p[C]=r;else break}for(_>>=y;_>0;){var x=s[t].s;p[x]<r?_-=1<<r-p[x]++-1:++t}for(;t>=0&&_;--t){var T=s[t].s;p[T]==r&&(--p[T],++_)}m=r}return{t:new Se(p),l:m}},Us=function(n,r,e){return n.s==-1?Math.max(Us(n.l,r,e+1),Us(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}},Ur=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=As(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=Os(i,15),d=f.t,p=f.l,m=Os(s,15),_=m.t,y=m.l,S=Ho(d),C=S.c,x=S.n,T=Ho(_),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=Os(E,7),F=D.t,B=D.l,U=19;U>4&&!F[Cs[U-1]];--U);var V=h+5<<3,M=Ur(i,St)+Ur(s,Ar)+o,N=Ur(i,d)+Ur(s,_)+o+14+3*U+Ur(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(d,p,0),R=d,I=lt(_,y,0),j=_;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[Cs[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=Rc,R=St,I=Lc,j=Ar;for(var w=0;w<a;++w){var G=t[w];if(G>255){var W=G>>18&31;Or(r,c,q[W+257]),c+=R[W+257],W>7&&(yt(r,c,G>>23&31),c+=di[W]);var Q=G&31;Or(r,c,I[Q]),c+=j[Q],Q>3&&(Or(r,c,G>>5&8191),c+=pi[Q])}else Or(r,c,q[G]),c+=R[G]}return Or(r,c,q[256]),c+R[256]},$c=new Ps([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ko=new Se(0),zc=function(n,r,e,t,i,s){var o=s.z||n.length,a=new Se(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=$c[r-1],d=f>>13,p=f&8191,m=(1<<e)-1,_=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 Ps(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(_[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=p,L=M-N&32767;if(q>2&&V==x(D-L))for(var K=Math.min(d,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=_[ae],Ze=ae-ut&32767;Ze>Z&&(Z=Ze,N=ae)}}}M=N,N=_[M],L+=M-N&32767}if(j){T[F++]=268435456|Es[I]<<18|Wo[j];var Le=Es[I]&31,Fe=Wo[j]&31;w+=di[Le]+pi[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=_,s.i=D,s.w=B)}else{for(var D=s.w||0;D<o+h;D+=65535){var Ee=D+65535;Ee>=o&&(l[c/8|0]=h,Ee=o),c=Yo(l,c+1,n.subarray(D,Ee))}s.i=o}return Xo(a,0,t+As(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}}},Vc=function(n,r,e,t,i){if(!i&&(i={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),o=new Se(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return zc(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},jc=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())}},Gc=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)==1&&et(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function qc(n,r){r||(r={});var e=Jo();e.p(n);var t=Vc(n,r,r.dictionary?6:2,4);return jc(t,r),Qo(t,t.length-4,e.d()),t}function Wc(n,r){return Fc(n.subarray(Gc(n),-4),{i:2},r,r)}var Xc=typeof TextDecoder<"u"&&new TextDecoder,Hc=0;try{Xc.decode(Ko,{stream:!0}),Hc=1}catch{}const Yc="modern-font";function Dr(n,r){if(!n)throw new Error(`[${Yc}] ${r}`)}function Zc(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 ar(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Kc(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 gi(n){n=Kc(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 Jc(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 Qc(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 eu=Object.defineProperty,Me=(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 Ir={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ae(){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 _e extends DataView{constructor(e,t,i,s){super(Zc(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+=Ir[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+=Ir[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=ar(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}}Me([Ae()],_e.prototype,"readInt8"),Me([Ae()],_e.prototype,"readInt16"),Me([Ae()],_e.prototype,"readInt32"),Me([Ae()],_e.prototype,"readUint8"),Me([Ae()],_e.prototype,"readUint16"),Me([Ae()],_e.prototype,"readUint32"),Me([Ae()],_e.prototype,"readFloat32"),Me([Ae()],_e.prototype,"readFloat64"),Me([Ae()],_e.prototype,"writeInt8"),Me([Ae()],_e.prototype,"writeInt16"),Me([Ae()],_e.prototype,"writeInt32"),Me([Ae()],_e.prototype,"writeUint8"),Me([Ae()],_e.prototype,"writeUint16"),Me([Ae()],_e.prototype,"writeUint32"),Me([Ae()],_e.prototype,"writeFloat32"),Me([Ae()],_e.prototype,"writeFloat64");const ea=new WeakMap;function v(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*Ir[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+Ir[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 _e(r,e,t,i)}}class mi 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 tu=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&&tu(r,e,i),i};const Ie=class sl extends mi{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=gi(s.fontFamily||""),a=o.length,l=gi(s.fontStyle||""),h=l.length,c=gi(s.version||""),f=c.length,d=gi(s.fullName||""),p=d.length,m=86+a+4+h+4+f+4+p+2+e.view.byteLength,_=new sl(new ArrayBuffer(m),0,m,!0);_.EOTSize=_.view.byteLength,_.FontDataSize=e.view.byteLength,_.Version=131073,_.Flags=0,_.Charset=1,_.MagicNumber=20556,_.Padding1=0,_.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(_.FontPANOSE=y.fontPANOSE,_.Italic=y.fsSelection,_.Weight=y.usWeightClass,_.fsType=y.fsType,_.UnicodeRange=y.ulUnicodeRange,_.CodePageRange=y.ulCodePageRange),_.view.writeUint16(a),_.view.writeBytes(o),_.view.writeUint16(0),_.view.writeUint16(h),_.view.writeBytes(l),_.view.writeUint16(0),_.view.writeUint16(f),_.view.writeBytes(c),_.view.writeUint16(0),_.view.writeUint16(p),_.view.writeBytes(d),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(e.view),_}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var ru=Object.defineProperty,yi=(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&&ru(r,e,i),i};class lr extends je{constructor(r,e){super(r,e,16)}}yi([v({type:"char",size:4})],lr.prototype,"tag"),yi([v("uint32")],lr.prototype,"checkSum"),yi([v("uint32")],lr.prototype,"offset"),yi([v("uint32")],lr.prototype,"length");const Ds=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],iu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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 Is{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,d=h.length;f<d;f+=1){const p=h[f];p.type==="M"?c.push({type:"M",x:r+p.x*a,y:e+-p.y*l}):p.type==="L"?c.push({type:"L",x:r+p.x*a,y:e+-p.y*l}):p.type==="Q"?c.push({type:"Q",x1:r+p.x1*a,y1:e+-p.y1*l,x:r+p.x*a,y:e+-p.y*l}):p.type==="C"?c.push({type:"C",x1:r+p.x1*a,y1:e+-p.y1*l,x2:r+p.x2*a,y2:e+-p.y2*l,x:r+p.x*a,y:e+-p.y*l}):p.type==="Z"&&c.push({type:"Z"})}return c}}class su extends Is{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,d,p,m;const _=[],y=[];let S=0,C=!1,x=!1,T=o,b=0,P=0;function E(M,N){_.push({type:"L",x:M,y:N})}function w(M,N,q,R,I,j){_.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,_.push({type:"M",x:M,y:N})}function F(){_.push({type:"Z"})}function B(M){_.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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+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,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 34:f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),L=p+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=P,b=G+y.shift(),w(f,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 36:f=b+y.shift(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+y.shift(),K=m,X=L+y.shift(),W=m,G=X+y.shift(),Q=W+y.shift(),b=G+y.shift(),w(f,d,p,m,L,K),w(X,W,G,Q,b,P);break;case 37:f=b+y.shift(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),L=p+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,d,p,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=Ds[y.pop()],Ze=Ds[y.pop()],Le=y.pop(),Fe=y.pop();if(ut&&Ze){i.isComposite=!0,i.components=[];const Ee=r.charset.indexOf(ut),$e=r.charset.indexOf(Ze);i.components.push({glyphIndex:$e,dx:0,dy:0}),i.components.push({glyphIndex:Ee,dx:Fe,dy:Le}),B(t.get($e).pathCommands);const tt=JSON.parse(JSON.stringify(t.get(Ee).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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,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(),d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+y.shift(),w(f,d,p,m,b,P);break;case 26:for(y.length%2&&(b+=y.shift());y.length>0;)f=b,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p,P=m+y.shift(),w(f,d,p,m,b,P);break;case 27:for(y.length%2&&(P+=y.shift());y.length>0;)f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m,w(f,d,p,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,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+(y.length===1?y.shift():0),w(f,d,p,m,b,P),y.length!==0);)f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),P=m+y.shift(),b=p+(y.length===1?y.shift():0),w(f,d,p,m,b,P);break;case 31:for(;y.length>0&&(f=b+y.shift(),d=P,p=f+y.shift(),m=d+y.shift(),P=m+y.shift(),b=p+(y.length===1?y.shift():0),w(f,d,p,m,b,P),y.length!==0);)f=b,d=P+y.shift(),p=f+y.shift(),m=d+y.shift(),b=p+y.shift(),P=m+(y.length===1?y.shift():0),w(f,d,p,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=_,C&&(this.advanceWidth=T)}}class Rs{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 nu extends Rs{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(r){const e=this._sfnt.cff,t=new su({index:r});return t.parse(e,e.charStringsIndex.get(r),this),t.name=e.charset[r],t}}var ou=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&&ou(r,e,i),i};class _i 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([v("uint16")],_i.prototype,"count"),ta([v("uint8")],_i.prototype,"offsetSize");class vi extends _i{constructor(){super(...arguments);u(this,"_isString",!1)}}class ra extends _i{constructor(){super(...arguments);u(this,"_isString",!0)}}const 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","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"],lu=[".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"],hu=[".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"],cu=[".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 bi(n,r){return r<=390?au[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 bi(((i=this._stringIndex)==null?void 0:i.objects)??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var uu=Object.defineProperty,Bs=(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 wi extends ia{}Bs([ie(19)],wi.prototype,"subrs"),Bs([ie(20)],wi.prototype,"defaultWidthX"),Bs([ie(21)],wi.prototype,"nominalWidthX");var fu=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&&fu(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 xe(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 Oe extends je{setSfnt(r){return this._sfnt=r,this}getSfnt(){return this._sfnt}}var du=Object.defineProperty,pu=Object.getOwnPropertyDescriptor,Rr=(n,r,e,t)=>{for(var i=t>1?void 0:t?pu(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 $t=class extends Oe{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 nu(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 vi(e,this.nameIndex.endOffset),this.stringIndex=new ra(e,this.topDictIndex.endOffset),this.globalSubrIndex=new vi(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 wi(e,t+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new vi(e,t+o+this.privateDict.subrs))),this.charStringsIndex=new vi(e,t+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=lu:this.topDict.charset===1?this.charset=hu:this.topDict.charset===2?this.charset=cu:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Ds:this.topDict.encoding===1?this.encoding=iu: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(bi(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(bi(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(bi(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}};Rr([v("uint8")],$t.prototype,"majorVersion",2),Rr([v("uint8")],$t.prototype,"minorVersion",2),Rr([v("uint8")],$t.prototype,"headerSize",2),Rr([v("uint8")],$t.prototype,"offsetSize",2),$t=Rr([xe("CFF ","cff")],$t);var gu=Object.defineProperty,xi=(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};const Br=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}};xi([v("uint16")],Br.prototype,"format"),xi([v("uint16")],Br.prototype,"length"),xi([v("uint16")],Br.prototype,"language"),xi([v({type:"uint8",size:256})],Br.prototype,"glyphIndexArray");let Ls=Br;var mu=Object.defineProperty,ks=(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};class Lr 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,d=s[c].entryCount;f<d;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 p=(h<<8|f+s[c].firstCode)%65535;e.set(p,l)}}return e}}ks([v("uint16")],Lr.prototype,"format"),ks([v("uint16")],Lr.prototype,"length"),ks([v("uint16")],Lr.prototype,"language");function sa(n){return n>32767?n-65536:n<-32767?n+65536:n}function Ns(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 yu=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&&yu(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=Ns(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 d=h+o[h]/2+(c-i[h])-t,p=l[d];p!==0?r.set(c,(p+a[h])%65536):r.set(c,0)}return r.delete(65535),r}};zt([v("uint16")],Mt.prototype,"format"),zt([v("uint16")],Mt.prototype,"length"),zt([v("uint16")],Mt.prototype,"language"),zt([v("uint16")],Mt.prototype,"segCountX2"),zt([v("uint16")],Mt.prototype,"searchRange"),zt([v("uint16")],Mt.prototype,"entrySelector"),zt([v("uint16")],Mt.prototype,"rangeShift");let Fs=Mt;var _u=Object.defineProperty,kr=(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 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}}kr([v("uint16")],Vt.prototype,"format"),kr([v("uint16")],Vt.prototype,"length"),kr([v("uint16")],Vt.prototype,"language"),kr([v("uint16")],Vt.prototype,"firstCode"),kr([v("uint16")],Vt.prototype,"entryCount");var vu=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&&vu(r,e,i),i};const hr=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=Ns(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}};Nr([v("uint16")],hr.prototype,"format"),Nr([v("uint16")],hr.prototype,"reserved"),Nr([v("uint32")],hr.prototype,"length"),Nr([v("uint32")],hr.prototype,"language"),Nr([v("uint32")],hr.prototype,"nGroups");let $s=hr;var bu=Object.defineProperty,zs=(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&&bu(r,e,i),i};class Fr 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}}zs([v("uint16")],Fr.prototype,"format"),zs([v("uint32")],Fr.prototype,"length"),zs([v("uint32")],Fr.prototype,"numVarSelectorRecords");var wu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Vs=(n,r,e,t)=>{for(var i=t>1?void 0:t?xu(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&&wu(r,e,i),i};let cr=class extends Oe{constructor(){super(...arguments);u(this,"_unicodeToGlyphIndexMap");u(this,"_glyphIndexToUnicodesMap")}static from(r){const e=Array.from(r.keys()).some(f=>f>65535),t=Fs.from(r),i=Ls.from(r),s=e?$s.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 cr(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 Ls(this.view.buffer,e.offset);break;case 2:i=new Lr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:i=new Fs(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 $s(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:i=new Fr(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(d=>d.format===0))==null?void 0:a.view,t=(l=r.find(d=>d.platformID===3&&d.platformSpecificID===3&&d.format===2))==null?void 0:l.view,i=(h=r.find(d=>d.platformID===3&&d.platformSpecificID===1&&d.format===4))==null?void 0:h.view,s=(c=r.find(d=>d.platformID===3&&d.platformSpecificID===10&&d.format===12))==null?void 0:c.view,o=(f=r.find(d=>d.platformID===0&&d.platformSpecificID===5&&d.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())??[]])}};Vs([v("uint16")],cr.prototype,"version",2),Vs([v("uint16")],cr.prototype,"numberSubtables",2),cr=Vs([xe("cmap")],cr);class Pu extends Is{_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 Dr(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 _=0;_<i;_++)a.push(r.view.readUint16());const l=this.instructionLength=r.view.readUint16();Dr(l<5e3,`Bad instructionLength:${l}`);const h=this.instructions=[];for(let _=0;_<l;++_)h.push(r.view.readUint8());const c=r.view.byteOffset,f=a[a.length-1]+1;Dr(f<2e4,`Bad numberOfCoordinates:${c}`);const d=[];let p,m=0;for(;m<f;)if(p=r.view.readUint8(),d.push(p),m++,p&8&&m<f){const _=r.view.readUint8();for(let y=0;y<_;y++)d.push(p),m++}if(Dr(d.length===f,`Bad flags length: ${d.length}, numberOfCoordinates: ${f}`),a.length>0){const _=[];let y;if(f>0){for(let x=0;x<f;x+=1)p=d[x],y={},y.onCurve=!!(p&1),y.lastPointOfContour=a.includes(x),_.push(y);let S=0;for(let x=0;x<f;x+=1)p=d[x],y=_[x],y.x=this._parseGlyphCoordinate(r,p,S,2,16),S=y.x;let C=0;for(let x=0;x<f;x+=1)p=d[x],y=_[x],y.y=this._parseGlyphCoordinate(r,p,C,4,32),C=y.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=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{Dr(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 d=h.points[l.matchedPoints[1]];const p={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],p)[0],p.dx=f.x-d.x,p.dy=f.y-d.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],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 d=0,p=h.length;d<p;++d)if(c=f,f=h[(d+1)%p],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 Cu extends Rs{get length(){return this._sfnt.loca.locations.length}_get(r){const e=this._sfnt.loca.locations,t=e[r],i=new Pu({index:r});return t!==e[r+1]&&i.parse(this._sfnt.glyf,t,this),i}}var Eu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Su=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tu(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&&Eu(r,e,i),i};let Pi=class extends Oe{constructor(){super(...arguments);u(this,"_glyphs")}static from(r){const e=r.reduce((i,s)=>i+s.byteLength,0),t=new Pi(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeBytes(i)}),t}get glyphs(){return this._glyphs??(this._glyphs=new Cu(this._sfnt))}};Pi=Su([xe("glyf")],Pi);var Mu=Object.defineProperty,Au=Object.getOwnPropertyDescriptor,Ou=(n,r,e,t)=>{for(var i=t>1?void 0:t?Au(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&&Mu(r,e,i),i};let js=class extends Oe{};js=Ou([xe("GPOS","gpos")],js);var Uu=Object.defineProperty,Du=Object.getOwnPropertyDescriptor,jt=(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&&Uu(r,e,i),i};let _t=class extends Oe{};jt([v("uint16")],_t.prototype,"majorVersion",2),jt([v("uint16")],_t.prototype,"minorVersion",2),jt([v("uint16")],_t.prototype,"scriptListOffset",2),jt([v("uint16")],_t.prototype,"featureListOffset",2),jt([v("uint16")],_t.prototype,"lookupListOffset",2),jt([v("uint16")],_t.prototype,"featureVariationsOffset",2),_t=jt([xe("GSUB","gsub")],_t);var Iu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,ve=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ru(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&&Iu(r,e,i),i};let pe=class extends Oe{constructor(n=new ArrayBuffer(54),r){super(n,r,Math.min(54,n.byteLength-(r??0)))}};ve([v("fixed")],pe.prototype,"version",2),ve([v("fixed")],pe.prototype,"fontRevision",2),ve([v("uint32")],pe.prototype,"checkSumAdjustment",2),ve([v("uint32")],pe.prototype,"magickNumber",2),ve([v("uint16")],pe.prototype,"flags",2),ve([v("uint16")],pe.prototype,"unitsPerEm",2),ve([v({type:"longDateTime"})],pe.prototype,"created",2),ve([v({type:"longDateTime"})],pe.prototype,"modified",2),ve([v("int16")],pe.prototype,"xMin",2),ve([v("int16")],pe.prototype,"yMin",2),ve([v("int16")],pe.prototype,"xMax",2),ve([v("int16")],pe.prototype,"yMax",2),ve([v("uint16")],pe.prototype,"macStyle",2),ve([v("uint16")],pe.prototype,"lowestRecPPEM",2),ve([v("int16")],pe.prototype,"fontDirectionHint",2),ve([v("int16")],pe.prototype,"indexToLocFormat",2),ve([v("int16")],pe.prototype,"glyphDataFormat",2),pe=ve([xe("head")],pe);var Bu=Object.defineProperty,Lu=Object.getOwnPropertyDescriptor,Re=(n,r,e,t)=>{for(var i=t>1?void 0:t?Lu(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 Pe=class extends Oe{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Re([v("fixed")],Pe.prototype,"version",2),Re([v("int16")],Pe.prototype,"ascent",2),Re([v("int16")],Pe.prototype,"descent",2),Re([v("int16")],Pe.prototype,"lineGap",2),Re([v("uint16")],Pe.prototype,"advanceWidthMax",2),Re([v("int16")],Pe.prototype,"minLeftSideBearing",2),Re([v("int16")],Pe.prototype,"minRightSideBearing",2),Re([v("int16")],Pe.prototype,"xMaxExtent",2),Re([v("int16")],Pe.prototype,"caretSlopeRise",2),Re([v("int16")],Pe.prototype,"caretSlopeRun",2),Re([v("int16")],Pe.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],Pe.prototype,"reserved",2),Re([v("int16")],Pe.prototype,"metricDataFormat",2),Re([v("uint16")],Pe.prototype,"numOfLongHorMetrics",2),Pe=Re([xe("hhea")],Pe);var ku=Object.defineProperty,Nu=Object.getOwnPropertyDescriptor,Fu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nu(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&&ku(r,e,i),i};let Ci=class extends Oe{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Ci(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()}))}};Ci=Fu([xe("hmtx")],Ci);var $u=Object.defineProperty,zu=Object.getOwnPropertyDescriptor,Vu=(n,r,e,t)=>{for(var i=t>1?void 0:t?zu(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&&$u(r,e,i),i};let Gs=class extends Oe{};Gs=Vu([xe("kern","kern")],Gs);var ju=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,qu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Gu(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 Ei=class extends Oe{constructor(){super(...arguments);u(this,"_locations")}static from(r,e=1){const t=r.length*(e?4:2),i=new Ei(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)}};Ei=qu([xe("loca")],Ei);var Wu=Object.defineProperty,Xu=Object.getOwnPropertyDescriptor,Ue=(n,r,e,t)=>{for(var i=t>1?void 0:t?Xu(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&&Wu(r,e,i),i};let be=class extends Oe{constructor(n=new ArrayBuffer(32),r){super(n,r,Math.min(32,n.byteLength-(r??0)))}};Ue([v("fixed")],be.prototype,"version",2),Ue([v("uint16")],be.prototype,"numGlyphs",2),Ue([v("uint16")],be.prototype,"maxPoints",2),Ue([v("uint16")],be.prototype,"maxContours",2),Ue([v("uint16")],be.prototype,"maxComponentPoints",2),Ue([v("uint16")],be.prototype,"maxComponentContours",2),Ue([v("uint16")],be.prototype,"maxZones",2),Ue([v("uint16")],be.prototype,"maxTwilightPoints",2),Ue([v("uint16")],be.prototype,"maxStorage",2),Ue([v("uint16")],be.prototype,"maxFunctionDefs",2),Ue([v("uint16")],be.prototype,"maxInstructionDefs",2),Ue([v("uint16")],be.prototype,"maxStackElements",2),Ue([v("uint16")],be.prototype,"maxSizeOfInstructions",2),Ue([v("uint16")],be.prototype,"maxComponentElements",2),Ue([v("uint16")],be.prototype,"maxComponentDepth",2),be=Ue([xe("maxp")],be);var Hu=Object.defineProperty,Yu=Object.getOwnPropertyDescriptor,Ti=(n,r,e,t)=>{for(var i=t>1?void 0:t?Yu(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&&Hu(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"},qs={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Zu={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 ur=class extends Oe{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=qs.Macintosh,s=Zu.Default,o=0;e.some(l=>l.platform===qs.Microsoft&&l.encoding===oa.UCS2&&l.language===1033)&&(i=qs.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?Jc(h.name):Qc(h.name))}return a}};Ti([v("uint16")],ur.prototype,"format",2),Ti([v("uint16")],ur.prototype,"count",2),Ti([v("uint16")],ur.prototype,"stringOffset",2),ur=Ti([xe("name")],ur);var Ku=Object.defineProperty,Ju=Object.getOwnPropertyDescriptor,z=(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&&Ku(r,e,i),i};let $=class extends Oe{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};z([v("uint16")],$.prototype,"version",2),z([v("int16")],$.prototype,"xAvgCharWidth",2),z([v("uint16")],$.prototype,"usWeightClass",2),z([v("uint16")],$.prototype,"usWidthClass",2),z([v("uint16")],$.prototype,"fsType",2),z([v("uint16")],$.prototype,"ySubscriptXSize",2),z([v("uint16")],$.prototype,"ySubscriptYSize",2),z([v("uint16")],$.prototype,"ySubscriptXOffset",2),z([v("uint16")],$.prototype,"ySubscriptYOffset",2),z([v("uint16")],$.prototype,"ySuperscriptXSize",2),z([v("uint16")],$.prototype,"ySuperscriptYSize",2),z([v("uint16")],$.prototype,"ySuperscriptXOffset",2),z([v("uint16")],$.prototype,"ySuperscriptYOffset",2),z([v("uint16")],$.prototype,"yStrikeoutSize",2),z([v("uint16")],$.prototype,"yStrikeoutPosition",2),z([v("uint16")],$.prototype,"sFamilyClass",2),z([v({type:"uint8"})],$.prototype,"bFamilyType",2),z([v({type:"uint8"})],$.prototype,"bSerifStyle",2),z([v({type:"uint8"})],$.prototype,"bWeight",2),z([v({type:"uint8"})],$.prototype,"bProportion",2),z([v({type:"uint8"})],$.prototype,"bContrast",2),z([v({type:"uint8"})],$.prototype,"bStrokeVariation",2),z([v({type:"uint8"})],$.prototype,"bArmStyle",2),z([v({type:"uint8"})],$.prototype,"bLetterform",2),z([v({type:"uint8"})],$.prototype,"bMidline",2),z([v({type:"uint8"})],$.prototype,"bXHeight",2),z([v({type:"uint8",size:16})],$.prototype,"ulUnicodeRange",2),z([v({type:"char",size:4})],$.prototype,"achVendID",2),z([v("uint16")],$.prototype,"fsSelection",2),z([v("uint16")],$.prototype,"usFirstCharIndex",2),z([v("uint16")],$.prototype,"usLastCharIndex",2),z([v("int16")],$.prototype,"sTypoAscender",2),z([v("int16")],$.prototype,"sTypoDescender",2),z([v("int16")],$.prototype,"sTypoLineGap",2),z([v("uint16")],$.prototype,"usWinAscent",2),z([v("uint16")],$.prototype,"usWinDescent",2),z([v({offset:72,type:"uint8",size:8})],$.prototype,"ulCodePageRange",2),z([v({offset:72,type:"int16"})],$.prototype,"sxHeight",2),z([v("int16")],$.prototype,"sCapHeight",2),z([v("uint16")],$.prototype,"usDefaultChar",2),z([v("uint16")],$.prototype,"usBreakChar",2),z([v("uint16")],$.prototype,"usMaxContext",2),$=z([xe("OS/2","os2")],$);var Qu=Object.defineProperty,ef=Object.getOwnPropertyDescriptor,ht=(n,r,e,t)=>{for(var i=t>1?void 0:t?ef(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 Xe=class extends Oe{constructor(n=new ArrayBuffer(32),r,e){super(n,r,e)}};ht([v("fixed")],Xe.prototype,"format",2),ht([v("fixed")],Xe.prototype,"italicAngle",2),ht([v("int16")],Xe.prototype,"underlinePosition",2),ht([v("int16")],Xe.prototype,"underlineThickness",2),ht([v("uint32")],Xe.prototype,"isFixedPitch",2),ht([v("uint32")],Xe.prototype,"minMemType42",2),ht([v("uint32")],Xe.prototype,"maxMemType42",2),ht([v("uint32")],Xe.prototype,"minMemType1",2),ht([v("uint32")],Xe.prototype,"maxMemType1",2),Xe=ht([xe("post")],Xe);var tf=Object.defineProperty,rf=Object.getOwnPropertyDescriptor,Be=(n,r,e,t)=>{for(var i=t>1?void 0:t?rf(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&&tf(r,e,i),i};let Ce=class extends Oe{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Be([v("fixed")],Ce.prototype,"version",2),Be([v("int16")],Ce.prototype,"vertTypoAscender",2),Be([v("int16")],Ce.prototype,"vertTypoDescender",2),Be([v("int16")],Ce.prototype,"vertTypoLineGap",2),Be([v("int16")],Ce.prototype,"advanceHeightMax",2),Be([v("int16")],Ce.prototype,"minTopSideBearing",2),Be([v("int16")],Ce.prototype,"minBottomSideBearing",2),Be([v("int16")],Ce.prototype,"yMaxExtent",2),Be([v("int16")],Ce.prototype,"caretSlopeRise",2),Be([v("int16")],Ce.prototype,"caretSlopeRun",2),Be([v("int16")],Ce.prototype,"caretOffset",2),Be([v({type:"int16",size:4})],Ce.prototype,"reserved",2),Be([v("int16")],Ce.prototype,"metricDataFormat",2),Be([v("int16")],Ce.prototype,"numOfLongVerMetrics",2),Ce=Be([xe("vhea")],Ce);var sf=Object.defineProperty,nf=Object.getOwnPropertyDescriptor,of=(n,r,e,t)=>{for(var i=t>1?void 0:t?nf(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};let Si=class extends Oe{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Si(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()}))}};Si=of([xe("vmtx")],Si);var af=Object.defineProperty,$r=(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 He extends mi{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(ar(e).getUint32(0))}static checksum(e){const t=ar(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=d=>d+3&-4,i=e.tableViews.size,s=Array.from(e.tableViews.values()).reduce((d,p)=>d+t(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();e.tableViews.forEach((d,p)=>{const m=c[h++];m.tag=p,m.checkSum=this.checksum(d),m.offset=l,m.length=d.byteLength,o.view.writeBytes(d,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 lr(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])),$r([v("uint32")],He.prototype,"scalerType"),$r([v("uint16")],He.prototype,"numTables"),$r([v("uint16")],He.prototype,"searchRange"),$r([v("uint16")],He.prototype,"entrySelector"),$r([v("uint16")],He.prototype,"rangeShift");class Mi extends He{constructor(){super(...arguments);u(this,"format","OpenType");u(this,"mimeType","font/otf")}static from(e){return super.from(e)}}u(Mi,"signature",new Set([1330926671]));var lf=Object.defineProperty,zr=(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};class Gt extends je{constructor(r,e){super(r,e,20)}}zr([v({type:"char",size:4})],Gt.prototype,"tag"),zr([v("uint32")],Gt.prototype,"offset"),zr([v("uint32")],Gt.prototype,"compLength"),zr([v("uint32")],Gt.prototype,"origLength"),zr([v("uint32")],Gt.prototype,"origChecksum");var hf=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&&hf(r,e,i),i};const Ne=(It=class extends mi{constructor(){super(...arguments);u(this,"format","WOFF");u(this,"mimeType","font/woff");u(this,"_sfnt")}get subfontFormat(){return He.is(this.flavor)?"TrueType":Mi.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(ar(e).getUint32(0))}static checkSum(e){const t=ar(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=d=>d+3&-4,s=[];e.tableViews.forEach((d,p)=>{const m=ar(qc(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)));s.push({tag:p,view:m.byteLength<d.byteLength?m:d,rawView:d})});const o=s.length,a=s.reduce((d,p)=>d+i(p.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((d,p)=>d+i(p.rawView.byteLength),0);let h=44+o*20,c=0;const f=l.getDirectories();return s.forEach(d=>{const p=f[c++];p.tag=d.tag,p.offset=h,p.compLength=d.view.byteLength,p.origChecksum=It.checkSum(d.rawView),p.origLength=d.rawView.byteLength,l.view.writeBytes(d.view,h),h+=i(p.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(Wc(new Uint8Array(this.view.buffer.slice(s,l))).buffer),e},{}))}},u(It,"signature",new Set([2001684038])),It);Ge([v("uint32")],Ne.prototype,"signature"),Ge([v("uint32")],Ne.prototype,"flavor"),Ge([v("uint32")],Ne.prototype,"length"),Ge([v("uint16")],Ne.prototype,"numTables"),Ge([v("uint16")],Ne.prototype,"reserved"),Ge([v("uint32")],Ne.prototype,"totalSfntSize"),Ge([v("uint16")],Ne.prototype,"majorVersion"),Ge([v("uint16")],Ne.prototype,"minorVersion"),Ge([v("uint32")],Ne.prototype,"metaOffset"),Ge([v("uint32")],Ne.prototype,"metaLength"),Ge([v("uint32")],Ne.prototype,"metaOrigLength"),Ge([v("uint32")],Ne.prototype,"privOffset"),Ge([v("uint32")],Ne.prototype,"privLength");let Ai=Ne;function aa(n,r=!0){if(He.is(n))return new He(n);if(Mi.is(n))return new Mi(n);if(Ai.is(n))return new Ai(n);if(r)throw new Error("Failed to parseFont")}const Ni=class Ni{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,{...Ni.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
28
|
font-family: "${r}";
|
|
29
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(d=>d.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((d,p)=>{d!==l&&(d.cancel(),this.loading.delete(p))}),l.when.then(d=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const p=f(d);return e.noAdd||this.loaded.set(r.src,p),p.familySet.forEach(m=>{this.familyToUrl.set(m,a),typeof document<"u"&&(i&&this.injectFontFace(m,d),s&&this.injectStyleTag(m,a))}),p}}).catch(d=>{if(d instanceof DOMException&&d.message==="The user aborted a request.")return f();throw d}).finally(()=>{this.loading.delete(a)});function h(){return r.family?Array.isArray(r.family)?r.family:[r.family]:[]}function c(d){return h().forEach(p=>{d.familySet.add(p)}),d}function f(d=new ArrayBuffer(0)){let p;function m(){return p||(p=d.byteLength?aa(d,!1):void 0),p}function _(){const y=m();if(y instanceof He||y instanceof Mi)return y.sfnt}return{...r,buffer:d,familySet:new Set(h()),getFont:m,getSfnt:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(r=>r.when))}};u(ki,"defaultRequestInit",{cache:"force-cache"});let Ai=ki;const la=new Ai,cf=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:gi,get Cff(){return zt},get Cmap(){return cr},CmapSubtableFormat0:Ls,CmapSubtableFormat12:$s,CmapSubtableFormat14:Nr,CmapSubtableFormat2:Br,CmapSubtableFormat4:Fs,CmapSubtableFormat6:jt,FontDataObject:je,FontDataView:_e,Fonts:Ai,get Glyf(){return xi},Glyph:Is,GlyphSet:Rs,get Gpos(){return js},get Gsub(){return _t},get Head(){return pe},get Hhea(){return Pe},get Hmtx(){return Pi},get Kern(){return Gs},get Loca(){return Ci},get Maxp(){return be},get Name(){return ur},get Os2(){return $},get Post(){return Xe},Sfnt:$t,TableDirectory:lr,Ttf:He,get Vhea(){return Ce},get Vmtx(){return Ti},Woff:Mi,WoffTableDirectoryEntry:qt,createCmapSegments:Ns,dataTypeToByteLength:Dr,defineColumn:v,defineSfntTable:xe,fonts:la,parseFont:aa},Symbol.toStringTag,{value:"Module"}));function Ws(n,r,e){if(typeof r=="string"&&r.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:o,stops:a}=uf(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 Oi(n,r,e){n!=null&&n.color&&(n.color=Ws(e,n.color,r)),n!=null&&n.backgroundColor&&(n.backgroundColor=Ws(e,n.backgroundColor,r)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=Ws(e,n.textStrokeColor,r))}function uf(n,r,e,t,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,f=t*Math.sin(c),d=i*Math.cos(c);return{x0:r+t/2-f,y0:e+i/2+d,x1:r+t/2+f,y1:e+i/2-d,stops:Array.from(l).map(m=>{let _=m[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(m[3].replace("%",""))/100,color:_}})}}function zr(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 ff(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 df(n,r){const{paragraphs:e,computedStyle:t,glyphBox:i}=r;Oi(t,i,n),e.forEach(s=>{Oi(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{Oi(o.computedStyle,o.inlineBox,n)})})}const pf=new Set(["©","®","÷"]),gf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),mf={1:"italic",32:"bold"},yf={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 _f{constructor(r,e,t){u(this,"path",new we);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:d}=c,p=o/d,m=r.getAdvanceWidth(h,d),_=(a+Math.abs(l))/p,y=a/p;return this.advanceWidth=m,this.advanceHeight=_,this.inlineBox.width=f?_:m,this.inlineBox.height=f?m:_,this.underlinePosition=(a-i.underlinePosition)/p,this.underlineThickness=i.underlineThickness/p,this.strikeoutPosition=(a-t.yStrikeoutPosition)/p,this.strikeoutSize=t.yStrikeoutSize/p,this.ascender=a/p,this.descender=l/p,this.typoAscender=t.sTypoAscender/p,this.typoDescender=t.sTypoDescender/p,this.typoLineGap=t.sTypoLineGap/p,this.winAscent=t.usWinAscent/p,this.winDescent=t.usWinDescent/p,this.xHeight=t.sxHeight/p,this.capHeight=t.sCapHeight/p,this.baseline=y,this.centerDiviation=_/2-y,this.fontStyle=mf[t.fsSelection]??yf[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:d,advanceHeight:p}=this,{left:m,top:_}=a,y=s.fontStyle==="italic"&&f!=="italic";let S=m,C=_+o,x;const T=new we;if(t&&(S+=(p-d)/2,Math.abs(d-p)>.1&&(C-=(l-c)/(l+Math.abs(h))*p),x=void 0),t&&!pf.has(i)&&(i.codePointAt(0)<=256||gf.has(i))){T.addCommands(e.getPathCommands(i,S,_+o-(p-d)/2,s.fontSize));const P={y:_-(p-d)/2+p/2,x:S+d/2};y&&this._italic(T,t?{x:P.x,y:_-(p-d)/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+d/2,y:_+c/(l+Math.abs(h))*p}:void 0)):(T.addCommands(e.getPathCommands(i,S,C,s.fontSize)),y&&this._italic(T,t?{x:S+p/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)zr(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};us(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 Xs(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=Ot(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 Ot(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=>fr(n[s],r[s]))}function fr(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 Hs(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 Ys(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class bf{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,...Hs(this.style)},this}initCharacters(){const r=[];let e=0;for(const t of this.computedContent)r.push(new _f(t,e++,this));return this.characters=r,this}}class Vr{constructor(r,e){u(this,"lineBox",new Y);u(this,"fragments",[]);this.style=r,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Hs(this.parentStyle),...Hs(this.style)},this}addFragment(r,e){const t=new bf(r,e,this);return this.fragments.push(t),t}}function ip(n){return n}const gr=class gr{_styleToDomStyle(r){const e={};for(const t in r){const i=r[t];gr.notZeroStyles.has(t)&&i===0||(typeof i=="number"&&gr.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 d=document.createElement("span");Object.assign(d.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),d.appendChild(document.createTextNode(f.content)),c.appendChild(d)}),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(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(d=>{d.firstChild instanceof window.Text&&this.measureDomText(d.firstChild).forEach(p=>{i.push({...p,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:d,isVertical:p}=f,m=s[o];f.inlineBox.left=m.left,f.inlineBox.top=m.top,f.inlineBox.width=m.width,f.inlineBox.height=m.height,p?(f.lineBox.left=m.left+(m.width-d)/2,f.lineBox.top=m.top,f.lineBox.width=d,f.lineBox.height=m.height):(f.lineBox.left=m.left,f.lineBox.top=m.top+(m.height-d)/2,f.lineBox.width=m.width,f.lineBox.height=d),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(gr,"notZeroStyles",new Set(["width","height"])),u(gr,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let Zs=gr;class wf{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 Ks(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 xf(){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(Ys(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}=Ks(h);Ys(c)&&a.add(c),Ys(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,d=Ks(f),{image:p,colormap:m,line:_,size:y,thickness:S}=d;if(Ot(p))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:C,isVertical:x}=c,{fontSize:T}=f;(!h||fr(h.image,p)&&fr(h.colormap,m)&&fr(h.line,_)&&fr(h.size,y)&&fr(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=d}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],d=f[0],p=Y.from(...f.filter(I=>I.glyphBox).map(I=>I.glyphBox)),{computedStyle:m}=d,{fontSize:_,writingMode:y}=m,{image:S,referImage:C,colormap:x,line:T,size:b,thickness:P}=Ks(m),E=y.includes("vertical"),w=Xs(P,{fontSize:_,total:p.width})/p.width,D=ca(x),{pathSet:F,dom:B}=s(S),U=F.getBoundingBox(!0),V=_/U.width*2,M=new Y().copy(p);E&&(M.width=p.height,M.height=p.width,M.left=p.left+p.width);const N=Math.floor(M.width);let q=N;if(b!=="cover"&&(q=Xs(b,{fontSize:_,total:p.width})||N,M.width=q),!Ot(C)&&Ot(T)){const I=s(C).pathSet.getBoundingBox(!0);U.copy(I)}else{let I;if(Ot(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=d.inlineBox.left+d.inlineBox.width:M.y=d.inlineBox.top;break;case"line-through":M.height=U.height*V,E?M.x=d.inlineBox.left+d.inlineBox.width-d.strikeoutPosition+M.height/2:M.y=d.inlineBox.top+d.strikeoutPosition-M.height/2;break;case"underline":M.height=U.height*V,E?M.x=d.inlineBox.left+d.inlineBox.width-d.underlinePosition:M.y=d.inlineBox.top+d.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(p.left-p.width*2,p.top,p.width*4,p.height):r[n.length-1]=new Y(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:r[h]}),a.debug){const c=new vs([l]).getBoundingBox();c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function Pf(n,r){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
|
|
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(d=>d.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((d,p)=>{d!==l&&(d.cancel(),this.loading.delete(p))}),l.when.then(d=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const p=f(d);return e.noAdd||this.loaded.set(r.src,p),p.familySet.forEach(m=>{this.familyToUrl.set(m,a),typeof document<"u"&&(i&&this.injectFontFace(m,d),s&&this.injectStyleTag(m,a))}),p}}).catch(d=>{if(d instanceof DOMException&&d.message==="The user aborted a request.")return f();throw d}).finally(()=>{this.loading.delete(a)});function h(){return r.family?Array.isArray(r.family)?r.family:[r.family]:[]}function c(d){return h().forEach(p=>{d.familySet.add(p)}),d}function f(d=new ArrayBuffer(0)){let p;function m(){return p||(p=d.byteLength?aa(d,!1):void 0),p}function _(){const y=m();if(y instanceof He||y instanceof Ai)return y.sfnt}return{...r,buffer:d,familySet:new Set(h()),getFont:m,getSfnt:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(r=>r.when))}};u(Ni,"defaultRequestInit",{cache:"force-cache"});let Oi=Ni;const la=new Oi,cf=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:mi,get Cff(){return $t},get Cmap(){return cr},CmapSubtableFormat0:Ls,CmapSubtableFormat12:$s,CmapSubtableFormat14:Fr,CmapSubtableFormat2:Lr,CmapSubtableFormat4:Fs,CmapSubtableFormat6:Vt,FontDataObject:je,FontDataView:_e,Fonts:Oi,get Glyf(){return Pi},Glyph:Is,GlyphSet:Rs,get Gpos(){return js},get Gsub(){return _t},get Head(){return pe},get Hhea(){return Pe},get Hmtx(){return Ci},get Kern(){return Gs},get Loca(){return Ei},get Maxp(){return be},get Name(){return ur},get Os2(){return $},get Post(){return Xe},Sfnt:Ft,TableDirectory:lr,Ttf:He,get Vhea(){return Ce},get Vmtx(){return Si},Woff:Ai,WoffTableDirectoryEntry:Gt,createCmapSegments:Ns,dataTypeToByteLength:Ir,defineColumn:v,defineSfntTable:xe,fonts:la,parseFont:aa},Symbol.toStringTag,{value:"Module"}));function Ws(n,r,e){if(typeof r=="string"&&r.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:o,stops:a}=uf(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 Ui(n,r,e){n!=null&&n.color&&(n.color=Ws(e,n.color,r)),n!=null&&n.backgroundColor&&(n.backgroundColor=Ws(e,n.backgroundColor,r)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=Ws(e,n.textStrokeColor,r))}function uf(n,r,e,t,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,f=t*Math.sin(c),d=i*Math.cos(c);return{x0:r+t/2-f,y0:e+i/2+d,x1:r+t/2+f,y1:e+i/2-d,stops:Array.from(l).map(m=>{let _=m[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(m[3].replace("%",""))/100,color:_}})}}function Vr(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 ff(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 df(n,r){const{paragraphs:e,computedStyle:t,glyphBox:i}=r;Ui(t,i,n),e.forEach(s=>{Ui(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{Ui(o.computedStyle,o.inlineBox,n)})})}const pf=new Set(["©","®","÷"]),gf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),mf={1:"italic",32:"bold"},yf={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 _f{constructor(r,e,t){u(this,"path",new we);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:d}=c,p=o/d,m=r.getAdvanceWidth(h,d),_=(a+Math.abs(l))/p,y=a/p;return this.advanceWidth=m,this.advanceHeight=_,this.inlineBox.width=f?_:m,this.inlineBox.height=f?m:_,this.underlinePosition=(a-i.underlinePosition)/p,this.underlineThickness=i.underlineThickness/p,this.strikeoutPosition=(a-t.yStrikeoutPosition)/p,this.strikeoutSize=t.yStrikeoutSize/p,this.ascender=a/p,this.descender=l/p,this.typoAscender=t.sTypoAscender/p,this.typoDescender=t.sTypoDescender/p,this.typoLineGap=t.sTypoLineGap/p,this.winAscent=t.usWinAscent/p,this.winDescent=t.usWinDescent/p,this.xHeight=t.sxHeight/p,this.capHeight=t.sCapHeight/p,this.baseline=y,this.centerDiviation=_/2-y,this.fontStyle=mf[t.fsSelection]??yf[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:d,advanceHeight:p}=this,{left:m,top:_}=a,y=s.fontStyle==="italic"&&f!=="italic";let S=m,C=_+o,x;const T=new we;if(t&&(S+=(p-d)/2,Math.abs(d-p)>.1&&(C-=(l-c)/(l+Math.abs(h))*p),x=void 0),t&&!pf.has(i)&&(i.codePointAt(0)<=256||gf.has(i))){T.addCommands(e.getPathCommands(i,S,_+o-(p-d)/2,s.fontSize));const P={y:_-(p-d)/2+p/2,x:S+d/2};y&&this._italic(T,t?{x:P.x,y:_-(p-d)/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+d/2,y:_+c/(l+Math.abs(h))*p}:void 0)):(T.addCommands(e.getPathCommands(i,S,C,s.fontSize)),y&&this._italic(T,t?{x:S+p/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)Vr(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};fs(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 Xs(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=>fr(n[s],r[s]))}function fr(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 Hs(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 Ys(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class bf{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,...Hs(this.style)},this}initCharacters(){const r=[];let e=0;for(const t of this.computedContent)r.push(new _f(t,e++,this));return this.characters=r,this}}class jr{constructor(r,e){u(this,"lineBox",new Y);u(this,"fragments",[]);this.style=r,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...Hs(this.parentStyle),...Hs(this.style)},this}addFragment(r,e){const t=new bf(r,e,this);return this.fragments.push(t),t}}function ip(n){return n}const gr=class gr{_styleToDomStyle(r){const e={};for(const t in r){const i=r[t];gr.notZeroStyles.has(t)&&i===0||(typeof i=="number"&&gr.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 d=document.createElement("span");Object.assign(d.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),d.appendChild(document.createTextNode(f.content)),c.appendChild(d)}),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(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(d=>{d.firstChild instanceof window.Text&&this.measureDomText(d.firstChild).forEach(p=>{i.push({...p,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:d,isVertical:p}=f,m=s[o];f.inlineBox.left=m.left,f.inlineBox.top=m.top,f.inlineBox.width=m.width,f.inlineBox.height=m.height,p?(f.lineBox.left=m.left+(m.width-d)/2,f.lineBox.top=m.top,f.lineBox.width=d,f.lineBox.height=m.height):(f.lineBox.left=m.left,f.lineBox.top=m.top+(m.height-d)/2,f.lineBox.width=m.width,f.lineBox.height=d),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(gr,"notZeroStyles",new Set(["width","height"])),u(gr,"pxStyles",new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","marginLeft","marginTop","marginRight","marginBottom","paddingLeft","paddingTop","paddingRight","paddingBottom"]));let Zs=gr;class wf{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 Ks(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 xf(){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(Ys(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}=Ks(h);Ys(c)&&a.add(c),Ys(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,d=Ks(f),{image:p,colormap:m,line:_,size:y,thickness:S}=d;if(At(p))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:C,isVertical:x}=c,{fontSize:T}=f;(!h||fr(h.image,p)&&fr(h.colormap,m)&&fr(h.line,_)&&fr(h.size,y)&&fr(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=d}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],d=f[0],p=Y.from(...f.filter(I=>I.glyphBox).map(I=>I.glyphBox)),{computedStyle:m}=d,{fontSize:_,writingMode:y}=m,{image:S,referImage:C,colormap:x,line:T,size:b,thickness:P}=Ks(m),E=y.includes("vertical"),w=Xs(P,{fontSize:_,total:p.width})/p.width,D=ca(x),{pathSet:F,dom:B}=s(S),U=F.getBoundingBox(!0),V=_/U.width*2,M=new Y().copy(p);E&&(M.width=p.height,M.height=p.width,M.left=p.left+p.width);const N=Math.floor(M.width);let q=N;if(b!=="cover"&&(q=Xs(b,{fontSize:_,total:p.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=d.inlineBox.left+d.inlineBox.width:M.y=d.inlineBox.top;break;case"line-through":M.height=U.height*V,E?M.x=d.inlineBox.left+d.inlineBox.width-d.strikeoutPosition+M.height/2:M.y=d.inlineBox.top+d.strikeoutPosition-M.height/2;break;case"underline":M.height=U.height*V,E?M.x=d.inlineBox.left+d.inlineBox.width-d.underlinePosition:M.y=d.inlineBox.top+d.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(p.left-p.width*2,p.top,p.width*4,p.height):r[n.length-1]=new Y(p.left,p.top-p.height*2,p.width,p.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if(Vr({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 Pf(n,r){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
|
|
31
31
|
<circle cx="${n}" cy="${n}" r="${n}" fill="${r}" />
|
|
32
|
-
</svg>`}function Cf(){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:d}=a,p=ca(c);let m=f,_;if(!Ot(h))_=h;else if(!Ot(d)){const x=i*.38/2;switch(m=m==="cover"?x*2:m,d){case"disc":_=Pf(x,String(l));break}}if(!_)return;const y=bo(_),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:Xs(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 p&&(D.style.fill=p[D.style.fill]),D.style.stroke&&D.style.stroke in p&&(D.style.stroke=p[D.style.stroke]),D}))}})})})}}}const Ut=new O,dr=new ke,Dt=new ke;function Ef(){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=Js(n,o);Ut.set(a.left,a.top),Ut.applyMatrix3(l),a.left=Ut.x,a.top=Ut.y,Ut.set(a.right,a.bottom),Ut.applyMatrix3(l),a.width=Ut.x-a.left,a.height=Ut.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=>{Oi(a,t,n),n.save();const[l,h,c,f,d,p]=Js(r,a).transpose().elements;n.transform(l,f,h,d,c,p),r.forEachCharacter(m=>{var _;(_=m.parent.style)!=null&&_.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 Js(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:d}=t,p=h+f/2,m=c+d/2;return dr.identity(),Dt.makeTranslation(i,s),dr.multiply(Dt),Dt.makeTranslation(p,m),dr.multiply(Dt),Dt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),dr.multiply(Dt),Dt.makeTranslation(-p,-m),dr.multiply(Dt),dr.clone()}function Tf(){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:d}=s,{color:p,textDecoration:m,writingMode:_}=o;if(Ot(m))i=void 0;else{let y=!1;if((i==null?void 0:i.textDecoration)===m&&(i==null?void 0:i.writingMode)===_&&(i==null?void 0:i.color)===p&&(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===d&&(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:d,textDecoration:p}=o,{left:m,top:_,width:y,height:S}=Y.from(...s.map(P=>P.inlineBox));let C=a?m+y:_;const x=a?-1:1;let T=0;switch(p){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 we([{type:"M",x:C,y:_},{type:"L",x:C,y:_+S},{type:"L",x:C+T,y:_+S},{type:"L",x:C+T,y:_},{type:"Z"}],{fill:d}):b=new we([{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:d}),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]=Js(e,s).transpose().elements;r.transform(o,h,a,c,l,f),n.forEach(d=>{zr({ctx:r,path:d,fontSize:i.fontSize,...s})}),r.restore()}):n.forEach(s=>{zr({ctx:r,path:s,fontSize:i.fontSize})})}}}const Qs=mc();class Sf extends wf{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",{...Qs});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 Zs);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(Cf()).use(Tf()).use(xf()).use(Ef()),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={...Qs,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new Vr({},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 Vr({},t);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new Vr({},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 Vr(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 Vr(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(),ff(s,i,this.boundingBox),df(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:t,pixelRatio:i}))}}var Mf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,Wt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Af(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&&Mf(r,e,i),i};const Of=new Set(Object.keys(Qs));g.Text2D=class extends g.Node2D{constructor(e){super();u(this,"effects");u(this,"measureDom");u(this,"fonts");u(this,"text",new Sf);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,this.text.requestUpdate()}_onUpdateStyleProperty(e,t,i){if(e!=="height"){switch(super._onUpdateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&Of.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}}_getSubTexts(){return this.getChildren(vr.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(vr.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}}),vr.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()}}},Wt([A({default:2})],g.Text2D.prototype,"pixelRatio",2),Wt([A({default:!1})],g.Text2D.prototype,"split",2),Wt([A({default:""})],g.Text2D.prototype,"content",2),Wt([A()],g.Text2D.prototype,"effects",2),Wt([ee()],g.Text2D.prototype,"measureDom",2),Wt([ee()],g.Text2D.prototype,"fonts",2),g.Text2D=Wt([H("Text2D")],g.Text2D);var Uf=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,fa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Df(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&&Uf(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 Ni=class Ni 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 Ni),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(Ni,"_instance");let Ui=Ni;const Hr=class Hr 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-Hr.PADDING),this._end=Math.min(this._end+Hr.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(Hr,"PADDING",.1);let Di=Hr;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 Ui.instance}async load(){return new Promise(r=>{this.source.onload=()=>r(this),this.source.src=this._src,this.source.load()})}createSound(){return new Di}}class en 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 If{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 Rf(){if(qi)return new AudioContext;if(Wi){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function Bf(n,r,e){if(Xi)return new OfflineAudioContext(n,r,e);if(yn){const t=globalThis.webkitOfflineAudioContext;return new t(n,r,e)}else throw new Error("Failed to createOfflineAudioContext")}const Fi=class Fi extends en{constructor(){const e=Rf(),t=Bf(1,2,Xi?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||mn),_r&&(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 Fi),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(Fi,"_instance");let It=Fi;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 en{constructor(e){const t=It.audioContext,i=t.createBufferSource(),s=t.createGain(),o=t.createAnalyser();i.connect(o),o.connect(s),s.connect(It.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 It.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:It.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,Lf=Object.getOwnPropertyDescriptor,kf=(n,r,e)=>r in n?ma(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Nf=(n,r,e,t)=>{for(var i=t>1?void 0:t?Lf(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},Ff=(n,r,e)=>kf(n,r+"",e);g.Audio=class extends g.Node{constructor(e=""){super();u(this,"_sounds",[]);u(this,"_platformAudio",_n?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)}},Ff(g.Audio,"_soundPool",[]),g.Audio=Nf([H("Audio")],g.Audio);class $f extends g.Node2D{}var zf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Ii=(n,r,e,t)=>{for(var i=t>1?void 0:t?Vf(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&&zf(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",_r?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=>It.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){var f,d;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 p=1,m=-1,_=0;_<s;_++){for(let y=0;y<h;y++){const S=l[_*h+y];S<p&&(p=S),S>m&&(m=S)}if(!this.gap||_%(this.gap*2)===0){const y=_,S=(1+p)*c,C=this.gap||1,x=Math.max(1,(m-p)*c);a.fillRect(y,S,C,x),p=1,m=-1}}(d=this._src)==null||d.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))}},Ii([A()],g.AudioWaveform.prototype,"src",2),Ii([A()],g.AudioWaveform.prototype,"gap",2),Ii([A()],g.AudioWaveform.prototype,"color",2),g.AudioWaveform=Ii([H("AudioWaveform")],g.AudioWaveform);const jf=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,Gf=/vec(\d)\((.*)\)/;function qf(n){n=n.trim();const r=n.match(Gf);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 Yr=class Yr extends ne{constructor(e){super();u(this,"vert",`attribute vec2 position;
|
|
32
|
+
</svg>`}function Cf(){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:d}=a,p=ca(c);let m=f,_;if(!At(h))_=h;else if(!At(d)){const x=i*.38/2;switch(m=m==="cover"?x*2:m,d){case"disc":_=Pf(x,String(l));break}}if(!_)return;const y=bo(_),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:Xs(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 p&&(D.style.fill=p[D.style.fill]),D.style.stroke&&D.style.stroke in p&&(D.style.stroke=p[D.style.stroke]),D}))}})})})}}}const Ot=new O,dr=new ke,Ut=new ke;function Ef(){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=Js(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=>{Ui(a,t,n),n.save();const[l,h,c,f,d,p]=Js(r,a).transpose().elements;n.transform(l,f,h,d,c,p),r.forEachCharacter(m=>{var _;(_=m.parent.style)!=null&&_.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 Js(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:d}=t,p=h+f/2,m=c+d/2;return dr.identity(),Ut.makeTranslation(i,s),dr.multiply(Ut),Ut.makeTranslation(p,m),dr.multiply(Ut),Ut.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),dr.multiply(Ut),Ut.makeTranslation(-p,-m),dr.multiply(Ut),dr.clone()}function Tf(){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:d}=s,{color:p,textDecoration:m,writingMode:_}=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)===_&&(i==null?void 0:i.color)===p&&(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===d&&(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:d,textDecoration:p}=o,{left:m,top:_,width:y,height:S}=Y.from(...s.map(P=>P.inlineBox));let C=a?m+y:_;const x=a?-1:1;let T=0;switch(p){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 we([{type:"M",x:C,y:_},{type:"L",x:C,y:_+S},{type:"L",x:C+T,y:_+S},{type:"L",x:C+T,y:_},{type:"Z"}],{fill:d}):b=new we([{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:d}),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]=Js(e,s).transpose().elements;r.transform(o,h,a,c,l,f),n.forEach(d=>{Vr({ctx:r,path:d,fontSize:i.fontSize,...s})}),r.restore()}):n.forEach(s=>{Vr({ctx:r,path:s,fontSize:i.fontSize})})}}}const Qs=mc();class Sf extends wf{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",{...Qs});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 Zs);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(Cf()).use(Tf()).use(xf()).use(Ef()),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={...Qs,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new jr({},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 jr({},t);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new jr({},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 jr(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 jr(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(),ff(s,i,this.boundingBox),df(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=>{Vr({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Mf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,qt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Af(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&&Mf(r,e,i),i};const Of=new Set(Object.keys(Qs));g.Text2D=class extends g.Node2D{constructor(e){super();u(this,"effects");u(this,"measureDom");u(this,"fonts");u(this,"text",new Sf);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,this.text.requestUpdate()}_onUpdateStyleProperty(e,t,i){if(e!=="height"){switch(super._onUpdateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&Of.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}}_getSubTexts(){return this.getChildren(vr.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(vr.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}}),vr.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 Uf=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,fa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Df(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&&Uf(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 Fi=class Fi 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 Fi),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(Fi,"_instance");let Di=Fi;const Yr=class Yr 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-Yr.PADDING),this._end=Math.min(this._end+Yr.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(Yr,"PADDING",.1);let Ii=Yr;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 Di.instance}async load(){return new Promise(r=>{this.source.onload=()=>r(this),this.source.src=this._src,this.source.load()})}createSound(){return new Ii}}class en 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 If{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 Rf(){if(Wi)return new AudioContext;if(Xi){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function Bf(n,r,e){if(Hi)return new OfflineAudioContext(n,r,e);if(yn){const t=globalThis.webkitOfflineAudioContext;return new t(n,r,e)}else throw new Error("Failed to createOfflineAudioContext")}const $i=class $i extends en{constructor(){const e=Rf(),t=Bf(1,2,Hi?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||mn),_r&&(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 $i),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($i,"_instance");let Dt=$i;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 en{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,Lf=Object.getOwnPropertyDescriptor,kf=(n,r,e)=>r in n?ma(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Nf=(n,r,e,t)=>{for(var i=t>1?void 0:t?Lf(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},Ff=(n,r,e)=>kf(n,r+"",e);g.Audio=class extends g.Node{constructor(e=""){super();u(this,"_sounds",[]);u(this,"_platformAudio",_n?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)}},Ff(g.Audio,"_soundPool",[]),g.Audio=Nf([H("Audio")],g.Audio);class $f extends g.Node2D{}var zf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Ri=(n,r,e,t)=>{for(var i=t>1?void 0:t?Vf(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&&zf(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",_r?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,d;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 p=1,m=-1,_=0;_<s;_++){for(let y=0;y<h;y++){const S=l[_*h+y];S<p&&(p=S),S>m&&(m=S)}if(!this.gap||_%(this.gap*2)===0){const y=_,S=(1+p)*c,C=this.gap||1,x=Math.max(1,(m-p)*c);a.fillRect(y,S,C,x),p=1,m=-1}}(d=this._src)==null||d.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))}},Ri([A()],g.AudioWaveform.prototype,"src",2),Ri([A()],g.AudioWaveform.prototype,"gap",2),Ri([A()],g.AudioWaveform.prototype,"color",2),g.AudioWaveform=Ri([H("AudioWaveform")],g.AudioWaveform);const jf=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,Gf=/vec(\d)\((.*)\)/;function qf(n){n=n.trim();const r=n.match(Gf);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 Zr=class Zr 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
|
-
}`);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
|
|
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 Zr.RE)t[s]=Zr.RE[s].test(e);this.frag=`precision highp float;
|
|
39
39
|
varying vec2 vUv;
|
|
40
40
|
uniform float ratio;
|
|
41
41
|
uniform float progress;
|
|
@@ -48,7 +48,7 @@ vec4 getFromColor(vec2 uv) { return texture2D(from, uv); }
|
|
|
48
48
|
vec4 getToColor(vec2 uv) { return texture2D(to, uv); }`:""}
|
|
49
49
|
${e}${t.transform?`
|
|
50
50
|
void main(void) { gl_FragColor = transform(vUv); }`:t.transition?`
|
|
51
|
-
void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=e.matchAll(jf);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),qf(s[2]))})}};u(
|
|
51
|
+
void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=e.matchAll(jf);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),qf(s[2]))})}};u(Zr,"RE",{getColor:/\sgetColor\s*\(/,getFromColor:/\sgetFromColor\s*\(/,getToColor:/\sgetToColor\s*\(/,transform:/\stransform\s*\(/,transition:/\stransition\s*\(/});let Bi=Zr;var Wf=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,Wt=(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&&Wf(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 Bi(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,Hf=Object.getOwnPropertyDescriptor,Yf=(n,r,e)=>r in n?ya(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?Hf(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},_a=(n,r,e)=>Yf(n,typeof r!="symbol"?r+"":r,e);const Zf=`attribute vec2 position;
|
|
52
52
|
attribute vec2 uv;
|
|
53
53
|
varying vec2 vUv[9];
|
|
54
54
|
uniform float strength;
|
|
@@ -145,7 +145,7 @@ void main(void) {
|
|
|
145
145
|
c.rgb *= c.a;
|
|
146
146
|
}
|
|
147
147
|
gl_FragColor = c * alpha;
|
|
148
|
-
}`})),vt([A()],g.ColorAdjustEffect.prototype,"saturation",2),vt([A()],g.ColorAdjustEffect.prototype,"contrast",2),vt([A()],g.ColorAdjustEffect.prototype,"brightness",2),vt([A()],g.ColorAdjustEffect.prototype,"red",2),vt([A()],g.ColorAdjustEffect.prototype,"green",2),vt([A()],g.ColorAdjustEffect.prototype,"blue",2),vt([A()],g.ColorAdjustEffect.prototype,"alpha",2),vt([A()],g.ColorAdjustEffect.prototype,"gamma",2),g.ColorAdjustEffect=vt([H("ColorAdjustEffect")],g.ColorAdjustEffect);var wa=Object.defineProperty,td=Object.getOwnPropertyDescriptor,rd=(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?td(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},id=(n,r,e)=>rd(n,r+"",e);g.ColorFilterEffect=class extends g.Effect{constructor(e){super();u(this,"_colorMatrix",new
|
|
148
|
+
}`})),vt([A()],g.ColorAdjustEffect.prototype,"saturation",2),vt([A()],g.ColorAdjustEffect.prototype,"contrast",2),vt([A()],g.ColorAdjustEffect.prototype,"brightness",2),vt([A()],g.ColorAdjustEffect.prototype,"red",2),vt([A()],g.ColorAdjustEffect.prototype,"green",2),vt([A()],g.ColorAdjustEffect.prototype,"blue",2),vt([A()],g.ColorAdjustEffect.prototype,"alpha",2),vt([A()],g.ColorAdjustEffect.prototype,"gamma",2),g.ColorAdjustEffect=vt([H("ColorAdjustEffect")],g.ColorAdjustEffect);var wa=Object.defineProperty,td=Object.getOwnPropertyDescriptor,rd=(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?td(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},id=(n,r,e)=>rd(n,r+"",e);g.ColorFilterEffect=class extends g.Effect{constructor(e){super();u(this,"_colorMatrix",new ls);this.setProperties(e)}apply(e,t){if(!this.filter)return;const i=yr(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()})})}},id(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
|
-
}`})),xa([A({default:""})],g.ColorFilterEffect.prototype,"filter",2),g.ColorFilterEffect=xa([H("ColorFilterEffect")],g.ColorFilterEffect);var Pa=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,nd=(n,r,e)=>r in n?Pa(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?sd(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},od=(n,r,e)=>nd(n,r+"",e);const
|
|
171
|
+
}`})),xa([A({default:""})],g.ColorFilterEffect.prototype,"filter",2),g.ColorFilterEffect=xa([H("ColorFilterEffect")],g.ColorFilterEffect);var Pa=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,nd=(n,r,e)=>r in n?Pa(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?sd(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},od=(n,r,e)=>nd(n,r+"",e);const Gr=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<Gr;)i.push([0,0,0,0]);te.draw(e,g.ColorOverlayEffect.material,{sampler:0,colors:i.slice(0,Gr).flatMap(s=>s)})})}},od(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[${Gr}];
|
|
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 < ${Gr}; 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<${Gr}; i++){
|
|
202
202
|
if(i==index){
|
|
203
203
|
return colors[i];
|
|
204
204
|
}
|
|
@@ -240,7 +240,7 @@ void main(void) {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
gl_FragColor = color;
|
|
243
|
-
}`})),sn([A()],g.ColorRemoveEffect.prototype,"colors",2),sn([A()],g.ColorRemoveEffect.prototype,"epsilon",2),g.ColorRemoveEffect=sn([H("ColorRemoveEffect")],g.ColorRemoveEffect);var Ea=Object.defineProperty,cd=Object.getOwnPropertyDescriptor,ud=(n,r,e)=>r in n?Ea(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?cd(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},fd=(n,r,e)=>ud(n,r+"",e);const
|
|
243
|
+
}`})),sn([A()],g.ColorRemoveEffect.prototype,"colors",2),sn([A()],g.ColorRemoveEffect.prototype,"epsilon",2),g.ColorRemoveEffect=sn([H("ColorRemoveEffect")],g.ColorRemoveEffect);var Ea=Object.defineProperty,cd=Object.getOwnPropertyDescriptor,ud=(n,r,e)=>r in n?Ea(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?cd(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},fd=(n,r,e)=>ud(n,r+"",e);const qr=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(qr*3),a=new Float32Array(qr*3);for(;i.length<qr;)i.push([[-1,0,0],[0,0,0,1]]);i.slice(0,qr).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})})}},fd(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 = ${qr};
|
|
254
254
|
uniform vec3 originalColors[MAX_COLORS];
|
|
255
255
|
uniform vec3 targetColors[MAX_COLORS];
|
|
256
256
|
|
|
@@ -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
|
-
}`})),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,bd=(n,r,e)=>r in n?Aa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,
|
|
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,bd=(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},wd=(n,r,e)=>bd(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})})}},wd(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,xd=Object.getOwnPropertyDescriptor,Pd=(n,r,e)=>r in n?Oa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Cd=(n,r,e,t)=>{for(var i=t>1?void 0:t?xd(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},Ed=(n,r,e)=>Pd(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=[],d=[a];if(a>0){let C=a;const x=a/l;for(let T=1;T<l;T++)C-=x,d.push(C)}const p=1/h,m=1/c,_=[];let y;const S=l-1;for(let C=0;C<S;C++)y=d[C]+.5,_[0]=y*p,_[1]=y*m,f.push({offset:_});y=d[S]+.5,_[0]=y*p,_[1]=y*m,f.push({offset:_}),f.forEach(C=>{te.draw(e,g.KawaseEffect.material,{sampler:s,progress:o,...C})})}},Ed(g.KawaseEffect,"material",new ne({vert:`attribute vec2 position;
|
|
533
533
|
attribute vec2 uv;
|
|
534
534
|
varying vec2 vUv;
|
|
535
535
|
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=Vd([H("TwistEffect")],g.TwistEffect);var ka=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,qd=(n,r,e)=>r in n?ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,
|
|
730
|
+
}`})),g.TwistEffect=Vd([H("TwistEffect")],g.TwistEffect);var ka=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,qd=(n,r,e)=>r in n?ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Wr=(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&&ka(r,e,i),i},Wd=(n,r,e)=>qd(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]})})}},Wd(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
|
-
}`})),qr([A()],g.ZoomBlurEffect.prototype,"center",2),qr([A()],g.ZoomBlurEffect.prototype,"innerRadius",2),qr([A()],g.ZoomBlurEffect.prototype,"radius",2),qr([A()],g.ZoomBlurEffect.prototype,"strength",2),g.ZoomBlurEffect=qr([H("ZoomBlurEffect")],g.ZoomBlurEffect);class Bi{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",Bi.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 an extends Bi{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 an{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 Wr extends an{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(Wr,"DOM_DELTA_PIXEL",0),u(Wr,"DOM_DELTA_LINE",1),u(Wr,"DOM_DELTA_PAGE",2);const Xd={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=""):Jt&&(e.touchAction=""),Jt?(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"):Jt&&(e.touchAction="none")),Jt?(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(gn&&e instanceof globalThis.WheelEvent)t.push(e);else if(Jt&&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 Wr;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=Xd[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",Hi);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new Qt)}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 pr=(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))(pr||{});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 $i=class $i{constructor(r){u(this,"_blendMode",pr.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 $i;return r.depthTest=!1,r.blend=!0,r}get blendMode(){return this._blendMode}set blendMode(r){this.blend=r!==pr.NONE,this._blendMode=r}get polygonOffset(){return this._polygonOffset}set polygonOffset(r){this.offsets=!!r,this._polygonOffset=r}};u($i,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let Yt=$i;Yt._init();class Va extends Ye{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",Yt._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 Yt({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(pr.NORMAL)}}class ja extends Ye{constructor(){super(...arguments);u(this,"_state",Yt.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;
|
|
810
|
+
}`})),Wr([A()],g.ZoomBlurEffect.prototype,"center",2),Wr([A()],g.ZoomBlurEffect.prototype,"innerRadius",2),Wr([A()],g.ZoomBlurEffect.prototype,"radius",2),Wr([A()],g.ZoomBlurEffect.prototype,"strength",2),g.ZoomBlurEffect=Wr([H("ZoomBlurEffect")],g.ZoomBlurEffect);class Li{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",Li.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 an extends Li{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 an{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 Xr extends an{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(Xr,"DOM_DELTA_PIXEL",0),u(Xr,"DOM_DELTA_LINE",1),u(Xr,"DOM_DELTA_PAGE",2);const Xd={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(gn&&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 Xr;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=Xd[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",Yi);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new Jt)}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 pr=(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))(pr||{});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 zi=class zi{constructor(r){u(this,"_blendMode",pr.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 zi;return r.depthTest=!1,r.blend=!0,r}get blendMode(){return this._blendMode}set blendMode(r){this.blend=r!==pr.NONE,this._blendMode=r}get polygonOffset(){return this._polygonOffset}set polygonOffset(r){this.offsets=!!r,this._polygonOffset=r}};u(zi,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let Ht=zi;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(pr.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;
|
|
@@ -864,6 +864,6 @@ void main(void) {
|
|
|
864
864
|
color += vColorMatrixOffset;
|
|
865
865
|
}
|
|
866
866
|
gl_FragColor = color;
|
|
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 d=[];for(let m=i.length,_={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){_.textures=y,_.textureLocationMap=S,C=0,_.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=pr.NORMAL}=i[E],R=(B?S.get(B):-1)??-1;x<E&&_.blendMode!==q&&(_.count=f-_.first,d.push(_),x=E,_={id:++this._drawCallUid},_.textures=y,_.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];_.blendMode=q}x=T+1,_.count=f-_.first,d.push(_),_={id:++this._drawCallUid},y=[],S=new Map}}const p=this._getShader(s);p.update(o,h);for(let m=d.length,_=0;_<m;_++){const y=d[_],{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),p.draw({mode:"triangles",count:y.count,first:S,bytesPerElement:2})}}_getAttributeBuffer(e){const t=ln(Math.ceil(e/8)),i=hn(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=ln(Math.ceil(e/12)),i=hn(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 ln(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 hn(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:cn(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 Qt}))}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 d=this._renderer.bindPoints.get(f.type)??String(f.type);o.attributes.set(f.name,{type:d,name:f.name,size:Hd(d),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 d=f.name.replace(/\[.*?\]$/,"");let p=s.getUniformLocation(i,d);p||(p=s.getUniformLocation(i,f.name)),o.uniforms.set(d,{name:d,index:c,type:this._renderer.bindPoints.get(f.type)??String(f.type),size:f.size,isArray:d!==f.name,location:p})}}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 :
|
|
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 d=[];for(let m=i.length,_={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){_.textures=y,_.textureLocationMap=S,C=0,_.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=pr.NORMAL}=i[E],R=(B?S.get(B):-1)??-1;x<E&&_.blendMode!==q&&(_.count=f-_.first,d.push(_),x=E,_={id:++this._drawCallUid},_.textures=y,_.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];_.blendMode=q}x=T+1,_.count=f-_.first,d.push(_),_={id:++this._drawCallUid},y=[],S=new Map}}const p=this._getShader(s);p.update(o,h);for(let m=d.length,_=0;_<m;_++){const y=d[_],{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),p.draw({mode:"triangles",count:y.count,first:S,bytesPerElement:2})}}_getAttributeBuffer(e){const t=ln(Math.ceil(e/8)),i=hn(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=ln(Math.ceil(e/12)),i=hn(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 ln(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 hn(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:cn(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 Jt}))}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 d=this._renderer.bindPoints.get(f.type)??String(f.type);o.attributes.set(f.name,{type:d,name:f.name,size:Hd(d),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 d=f.name.replace(/\[.*?\]$/,"");let p=s.getUniformLocation(i,d);p||(p=s.getUniformLocation(i,f.name)),o.uniforms.set(d,{name:d,index:c,type:this._renderer.bindPoints.get(f.type)??String(f.type),size:f.size,isArray:d!==f.name,location:p})}}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
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:d,location:p}=c;if(!(!p||a.get(p)===h))switch(a.set(p,h),f){case"float":d?i.uniform1fv(p,h):i.uniform1f(p,h);break;case"unsigned_int":d?i.uniform1uiv(p,h):i.uniform1ui(p,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":d?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 Hd(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 Yd(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=Yd(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 d=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,d),a.texParameteri(c,a.TEXTURE_WRAP_T,d)}const f=l.filterMode;if(h.filterMode&&f){const d=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,d),a.texParameteri(c,a.TEXTURE_MAG_FILTER,d)}if(l.anisoLevel&&f==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:d,TEXTURE_MAX_ANISOTROPY_EXT:p}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,p,Math.min(l.anisoLevel,a.getParameter(d)))}}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,d={location:o!==c&&(f||a),texture:f},p=this._renderer.getBindPoint(s);d.location&&(t.activeTexture(t.TEXTURE0+o),this.boundLocation=o),d.texture&&(t.bindTexture(p,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:d}=i,p=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let m=0;m<s;m++)p.enableVertexAttribArray(t+m),p.vertexAttribPointer(t+m,a,this._renderer.getBindPoint(l),h,c,f+(c-f)/s*m);d&&("vertexAttribDivisor"in p?p.vertexAttribDivisor(t,d):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 p in i.attributes){const m=i.attributes[p],_=h.attributes.get(p);let y;"buffer"in m?y={...m}:y={buffer:m},y.size=y.size||(_==null?void 0:_.size)||0;const S=this._renderer.buffer.getMeta(y.buffer),C=Number(((o=_==null?void 0:_.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[p]={attrib:y,meta:S,info:_,byteLength:x,dimension:C}}const d={};for(const p in f){const{attrib:m,meta:_,info:y,byteLength:S,dimension:C}=f[p];(y==null?void 0:y.location)!==void 0&&(d[l=_.id]??(d[l]=0),m.offset??(m.offset=d[_.id]),m.stride??(m.stride=c[_.id]===S?0:c[_.id]),this.enableVertexAttrib(p,y.location,m,C),d[_.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=xn(),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");bn(e)?this._setupContext(e,t):(this.gl=e,this.version=wn(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 Ln{constructor(e={}){var c,f;const{view:t,width:i,height:s,pixelRatio:o=Hi,background:a=0,autoResize:l,...h}=e;super();u(this,"input",new Fa);u(this,"renderer");u(this,"_background",new Pt);u(this,"_resizeObserver",pn?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 Zi()}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 Xr,Zd;const rl=[];async function Kd(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 Jd(n){Xr??(Xr=new tl({width:1,height:1}));const r=Xr.root;r.removeChildren();const{data:e,width:t,height:i}=n;return Xr.resize(t,i),(Array.isArray(e)?e:[e]).forEach(s=>{s instanceof g.Node?r.addChild(s):r.addChild(g.Node.parse(s))}),await Xr.waitUntilLoad(),Xr.toCanvas2D()}async function Qd(n){return Zd??(Zd=Kd()),new Promise(r=>{rl.push(async()=>r(await Jd(n)))})}g.Assets=Ao,g.AudioPipeline=en,g.AudioProcessor=If,g.AudioSpectrum=$f,g.CanvasContext=wo,g.Color=Pt,g.ColorMatrix=as,g.ColorTexture=ls,g.DEG_TO_RAD=Un,g.DEVICE_PIXEL_RATIO=Hi,g.EffectMaterial=Ri,g.Engine=tl,g.EventEmitter=dt,g.FontLoader=xo,g.Geometry=Qr,g.GifLoader=Po,g.HTMLAudio=da,g.HTMLAudioContext=Ui,g.HTMLSound=Di,g.IN_BROWSER=_r,g.Image2DResource=ci,g.ImageTexture=Rl,g.IndexBuffer=er,g.Input=Fa,g.InternalMode=vr,g.JsonLoader=Co,g.Loader=Tt,g.LottieLoader=Eo,g.MainLoop=ti,g.Material=ne,g.Matrix=it,g.Matrix2=Pl,g.Matrix3=Ji,g.Matrix4=An,g.MouseInputEvent=an,g.PI=Te,g.PI_2=le,g.PixelsTexture=Qi,g.PointerInputEvent=Na,g.Projection2D=On,g.QuadGeometry=bl,g.QuadUvGeometry=te,g.RAD_TO_DEG=Cl,g.RawWeakMap=Qt,g.Reference=Ki,g.RenderStack=In,g.Renderer=$a,g.Resource=wt,g.SUPPORTS_AUDIO_CONTEXT=qi,g.SUPPORTS_CLICK_EVENTS=mn,g.SUPPORTS_CREATE_IMAGE_BITMAP=Gi,g.SUPPORTS_IMAGE_BITMAP=dn,g.SUPPORTS_MOUSE_EVENTS=dl,g.SUPPORTS_OFFLINE_AUDIO_CONTEXT=Xi,g.SUPPORTS_POINTER_EVENTS=Jt,g.SUPPORTS_RESIZE_OBSERVER=pn,g.SUPPORTS_TOUCH_EVENTS=ft,g.SUPPORTS_WEBGL2=fn,g.SUPPORTS_WEBKIT_AUDIO_CONTEXT=Wi,g.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=yn,g.SUPPORTS_WEB_AUDIO=_n,g.SUPPORTS_WHEEL_EVENTS=gn,g.SceneTree=Ln,g.Style2D=at,g.Style2DBackgroundModule=Oo,g.Style2DFilterModule=Uo,g.Style2DModule=Sr,g.Style2DTextModule=Bo,g.Style2DTransformModule=Lo,g.TextLoader=To,g.Texture=de,g.TextureLoader=So,g.Ticker=ue,g.Transform2D=qe,g.UIInputEvent=Bi,g.UvGeometry=wl,g.UvMaterial=ei,g.Vector=Je,g.Vector2=Tl,g.Vector3=Sl,g.Vector4=Dn,g.VertexAttribute=ze,g.VertexBuffer=pt,g.VideoLoader=Mo,g.VideoTexture=Bn,g.ViewportTexture=ts,g.WebAudio=ga,g.WebAudioContext=It,g.WebGLBatch2DModule=ja,g.WebGLBlendMode=pr,g.WebGLBufferModule=Ga,g.WebGLFramebufferModule=qa,g.WebGLMaskModule=Wa,g.WebGLModule=Ye,g.WebGLProgramModule=Xa,g.WebGLRenderer=Qa,g.WebGLScissorModule=Ha,g.WebGLState=Yt,g.WebGLStateModule=Va,g.WebGLStencilModule=Ya,g.WebGLTextureModule=Za,g.WebGLVertexArrayModule=Ka,g.WebGLViewportModule=Ja,g.WebSound=pa,g.WheelInputEvent=Wr,g._Object=Jr,g.assets=mt,g.clamp=xt,g.createHTMLCanvas=xn,g.createNode=gl,g.crossOrigin=Cn,g.cubicBezier=or,g.curves=El,g.customNode=H,g.customNodes=Zr,g.defaultOptions=el,g.defineProperty=bt,g.determineCrossOrigin=Pn,g.ease=No,g.easeIn=Fo,g.easeInOut=zo,g.easeOut=$o,g.getDeclarations=Kr,g.getDefaultCssPropertyValue=ji,g.isCanvasElement=bn,g.isElementNode=Yi,g.isImageElement=pl,g.isPow2=Vi,g.isVideoElement=vn,g.isWebgl2=wn,g.lerp=fe,g.linear=ko,g.log2=hn,g.mapWebGLBlendModes=za,g.nextPow2=ln,g.nextTick=Zi,g.parseCssFunctions=yr,g.parseCssProperty=mr,g.property=A,g.protectedProperty=ee,g.render=Qd,g.timingFunctions=hi,g.uid=cn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
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:d,location:p}=c;if(!(!p||a.get(p)===h))switch(a.set(p,h),f){case"float":d?i.uniform1fv(p,h):i.uniform1f(p,h);break;case"unsigned_int":d?i.uniform1uiv(p,h):i.uniform1ui(p,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":d?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 Hd(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 Yd(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=Yd(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 d=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,d),a.texParameteri(c,a.TEXTURE_WRAP_T,d)}const f=l.filterMode;if(h.filterMode&&f){const d=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,d),a.texParameteri(c,a.TEXTURE_MAG_FILTER,d)}if(l.anisoLevel&&f==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:d,TEXTURE_MAX_ANISOTROPY_EXT:p}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,p,Math.min(l.anisoLevel,a.getParameter(d)))}}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,d={location:o!==c&&(f||a),texture:f},p=this._renderer.getBindPoint(s);d.location&&(t.activeTexture(t.TEXTURE0+o),this.boundLocation=o),d.texture&&(t.bindTexture(p,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:d}=i,p=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let m=0;m<s;m++)p.enableVertexAttribArray(t+m),p.vertexAttribPointer(t+m,a,this._renderer.getBindPoint(l),h,c,f+(c-f)/s*m);d&&("vertexAttribDivisor"in p?p.vertexAttribDivisor(t,d):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 p in i.attributes){const m=i.attributes[p],_=h.attributes.get(p);let y;"buffer"in m?y={...m}:y={buffer:m},y.size=y.size||(_==null?void 0:_.size)||0;const S=this._renderer.buffer.getMeta(y.buffer),C=Number(((o=_==null?void 0:_.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[p]={attrib:y,meta:S,info:_,byteLength:x,dimension:C}}const d={};for(const p in f){const{attrib:m,meta:_,info:y,byteLength:S,dimension:C}=f[p];(y==null?void 0:y.location)!==void 0&&(d[l=_.id]??(d[l]=0),m.offset??(m.offset=d[_.id]),m.stride??(m.stride=c[_.id]===S?0:c[_.id]),this.enableVertexAttrib(p,y.location,m,C),d[_.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=xn(),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");bn(e)?this._setupContext(e,t):(this.gl=e,this.version=wn(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 Ln{constructor(e={}){var c,f;const{view:t,width:i,height:s,pixelRatio:o=Yi,background:a=0,autoResize:l,...h}=e;super();u(this,"input",new Fa);u(this,"renderer");u(this,"_background",new Pt);u(this,"_resizeObserver",pn?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 Ki()}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 Hr,Zd;const rl=[];async function Kd(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 Jd(n){Hr??(Hr=new tl({width:1,height:1}));const r=Hr.root;r.removeChildren();const{data:e,width:t,height:i}=n;return Hr.resize(t,i),(Array.isArray(e)?e:[e]).forEach(s=>{s instanceof g.Node?r.addChild(s):r.addChild(g.Node.parse(s))}),await Hr.waitUntilLoad(),Hr.toCanvas2D()}async function Qd(n){return Zd??(Zd=Kd()),new Promise(r=>{rl.push(async()=>r(await Jd(n)))})}g.Assets=Ao,g.AudioPipeline=en,g.AudioProcessor=If,g.AudioSpectrum=$f,g.CanvasContext=wo,g.Color=Pt,g.ColorMatrix=ls,g.ColorTexture=hs,g.DEG_TO_RAD=Un,g.DEVICE_PIXEL_RATIO=Yi,g.EffectMaterial=Bi,g.Engine=tl,g.EventEmitter=dt,g.FontLoader=xo,g.Geometry=ei,g.GifLoader=Po,g.HTMLAudio=da,g.HTMLAudioContext=Di,g.HTMLSound=Ii,g.IN_BROWSER=_r,g.Image2DResource=ui,g.ImageTexture=Rl,g.IndexBuffer=Qt,g.Input=Fa,g.InternalMode=vr,g.JsonLoader=Co,g.Loader=Et,g.LottieLoader=Eo,g.MainLoop=ri,g.Material=ne,g.Matrix=it,g.Matrix2=Pl,g.Matrix3=Qi,g.Matrix4=An,g.MouseInputEvent=an,g.PI=Te,g.PI_2=le,g.PixelsTexture=es,g.PointerInputEvent=Na,g.Projection2D=On,g.QuadGeometry=bl,g.QuadUvGeometry=te,g.RAD_TO_DEG=Cl,g.RawWeakMap=Jt,g.Reference=Ji,g.RenderStack=In,g.Renderer=$a,g.Resource=wt,g.SUPPORTS_AUDIO_CONTEXT=Wi,g.SUPPORTS_CLICK_EVENTS=mn,g.SUPPORTS_CREATE_IMAGE_BITMAP=qi,g.SUPPORTS_IMAGE_BITMAP=dn,g.SUPPORTS_MOUSE_EVENTS=dl,g.SUPPORTS_OFFLINE_AUDIO_CONTEXT=Hi,g.SUPPORTS_POINTER_EVENTS=Kt,g.SUPPORTS_RESIZE_OBSERVER=pn,g.SUPPORTS_TOUCH_EVENTS=ft,g.SUPPORTS_WEBGL2=fn,g.SUPPORTS_WEBKIT_AUDIO_CONTEXT=Xi,g.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=yn,g.SUPPORTS_WEB_AUDIO=_n,g.SUPPORTS_WHEEL_EVENTS=gn,g.SceneTree=Ln,g.Style2D=at,g.Style2DBackgroundModule=Oo,g.Style2DFilterModule=Uo,g.Style2DModule=Mr,g.Style2DTextModule=Bo,g.Style2DTransformModule=Lo,g.TextLoader=To,g.Texture=de,g.TextureLoader=So,g.Ticker=ue,g.Transform2D=qe,g.UIInputEvent=Li,g.UvGeometry=wl,g.UvMaterial=ti,g.Vector=Je,g.Vector2=Tl,g.Vector3=Sl,g.Vector4=Dn,g.VertexAttribute=ze,g.VertexBuffer=pt,g.VideoLoader=Mo,g.VideoTexture=Bn,g.ViewportTexture=rs,g.WebAudio=ga,g.WebAudioContext=Dt,g.WebGLBatch2DModule=ja,g.WebGLBlendMode=pr,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=Xr,g._Object=Qr,g.assets=mt,g.clamp=xt,g.createHTMLCanvas=xn,g.createNode=gl,g.crossOrigin=Cn,g.cubicBezier=or,g.curves=El,g.customNode=H,g.customNodes=Kr,g.defaultOptions=el,g.defineProperty=bt,g.determineCrossOrigin=Pn,g.ease=No,g.easeIn=Fo,g.easeInOut=zo,g.easeOut=$o,g.getDeclarations=Jr,g.getDefaultCssPropertyValue=Gi,g.isCanvasElement=bn,g.isElementNode=Zi,g.isImageElement=pl,g.isPow2=ji,g.isVideoElement=vn,g.isWebgl2=wn,g.lerp=fe,g.linear=ko,g.log2=hn,g.mapWebGLBlendModes=za,g.nextPow2=ln,g.nextTick=Ki,g.parseCssFunctions=yr,g.parseCssProperty=mr,g.property=A,g.protectedProperty=ee,g.render=Qd,g.timingFunctions=ci,g.uid=cn,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|