modern-canvas 0.2.2 → 0.2.4

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,Me){typeof exports=="object"&&typeof module<"u"?Me(exports):typeof define=="function"&&define.amd?define(["exports"],Me):(d=typeof globalThis<"u"?globalThis:d||self,Me(d.modernCanvas={}))})(this,function(d){"use strict";var Op=Object.defineProperty;var Up=(d,Me,le)=>Me in d?Op(d,Me,{enumerable:!0,configurable:!0,writable:!0,value:le}):d[Me]=le;var u=(d,Me,le)=>Up(d,typeof Me!="symbol"?Me+"":Me,le);var Xt,Bt;const Me=Math.PI,le=Me*2;let gl=0;function gn(n){var r;return((r=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:r.id)??++gl}function Zi(n){return!(n&n-1)&&!!n}const ml=/([\w-]+)\((.+?)\)/g,yl=/[^,]+/g,_l=/([-e.\d]+)(.*)/;function Ki(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:mn(n,r,e)}function yr(n,r={}){const e=[];let t;for(;(t=ml.exec(n))!==null;){const[,i,s]=t;i&&e.push({name:i,args:vl(i,s,r)})}return e}function vl(n,r,e={}){const t=[];let i,s=0;for(;(i=yl.exec(r))!==null;)t.push(mn(n,i[0],{...e,index:s++}));return t}function mn(n,r,e={}){const{width:t=1,height:i=1,index:s=0}=e,o=r.match(_l),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 yn="WebGL2RenderingContext"in globalThis,_n="ImageBitmap"in globalThis,vn="ResizeObserver"in globalThis,Yt="PointerEvent"in globalThis,bn="WheelEvent"in globalThis,bl="MouseEvent"in globalThis,gt="ontouchstart"in globalThis,wn="onclick"in globalThis,Ji="createImageBitmap"in globalThis,Qi="AudioContext"in globalThis,es="webkitAudioContext"in globalThis,ts="OfflineAudioContext"in globalThis,xn="webkitOfflineAudioContext"in globalThis,Pn=Qi||es,_r=typeof window<"u",rs=globalThis.devicePixelRatio||1,is=n=>n!==null&&typeof n=="object"&&n.nodeType===1,Cn=n=>is(n)&&n.tagName==="VIDEO",wl=n=>is(n)&&n.tagName==="IMG";function Tn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function En(n){return yn&&n instanceof globalThis.WebGL2RenderingContext}function Sn(){if(_r)return globalThis.document.createElement("canvas")}function Mn(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 An(n,r,e){e===null&&!r.startsWith("data:")?n.crossOrigin=Mn(r):e!==!1&&(n.crossOrigin=typeof e=="string"?e:"anonymous")}class Zt{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 On=new Zt;function Qr(n){let r=On.get(n);if(!r){const e=Object.getPrototypeOf(n);r=new Map(e?Qr(e):void 0),On.set(n,r)}return r}function vr(n,r,e={}){Qr(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 M(n){return function(r,e){vr(r.constructor,e,n)}}const ei=new Map;function q(n,r){return function(e){Object.defineProperty(e.prototype,"tag",{value:n,enumerable:!0,configurable:!0}),r&&Object.keys(r).forEach(t=>{vr(e,t,{default:r[t]})}),ei.set(n,e)}}function ue(n){return M({...n,protected:!0})}function xl(n="node",r={}){const e=ei.get(n);if(!e)throw new Error(`Failed to createNode, tag: ${n}`);return new e().setProperties(r)}class fe{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(fe,"_queue",[]),u(fe,"_currentTime",0),u(fe,"_elapsed",0),u(fe,"_requestId"),fe.start();async function ss(n){return new Promise(r=>{fe.on(()=>{n==null||n(),r()},{sort:1,once:!0})})}let mt=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}},Pl=0;class ti extends mt{constructor(){super(...arguments);u(this,"instanceId",++Pl);u(this,"_defaultProperties");u(this,"_updatedProperties",new Map);u(this,"_changedProperties",new Set);u(this,"_updatingPromise",Promise.resolve());u(this,"_updating",!1)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await ss(),this._performUpdate()}_performUpdate(){this._updating&&(this._onUpdate(this._updatedProperties),this._updatedProperties=new Map,this._updating=!1)}_onUpdate(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return Qr(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._updateProperty(e,s,t,i),this.emit("updateProperty",e,s,t,i);else return}this._updating||(this._updatingPromise=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}clone(){return new this.constructor(this.toJSON())}destroy(){this.removeAllListeners()}}class Un extends ti{}class ri{constructor(){u(this,"bubbles",!0);u(this,"cancelable",!1);u(this,"which");u(this,"cancelBubble",!0);u(this,"returnValue");u(this,"srcElement");u(this,"composed",!1);u(this,"currentTarget");u(this,"defaultPrevented",!1);u(this,"eventPhase",ri.prototype.NONE);u(this,"isTrusted");u(this,"target");u(this,"timeStamp");u(this,"type");u(this,"nativeEvent");u(this,"originalEvent");u(this,"propagationStopped",!1);u(this,"propagationImmediatelyStopped",!1);u(this,"path");u(this,"detail");u(this,"view");u(this,"layer",{x:0,y:0});u(this,"page",{x:0,y:0});u(this,"NONE",0);u(this,"CAPTURING_PHASE",1);u(this,"AT_TARGET",2);u(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...r){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class ns extends ri{constructor(){super(...arguments);u(this,"altKey");u(this,"button");u(this,"buttons");u(this,"ctrlKey");u(this,"metaKey");u(this,"relatedTarget");u(this,"shiftKey");u(this,"client",{x:0,y:0});u(this,"movement",{x:0,y:0});u(this,"offset",{x:0,y:0});u(this,"global",{x:0,y:0});u(this,"screen",{x:0,y:0})}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}}class Dn extends ns{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 br extends ns{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(br,"DOM_DELTA_PIXEL",0),u(br,"DOM_DELTA_LINE",1),u(br,"DOM_DELTA_PAGE",2);const Cl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class In extends mt{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(gt&&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||gt&&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||gt&&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||gt&&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=""):Yt&&(e.touchAction=""),Yt?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.removeEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.removeEventListener("mouseup",this.onPointerUp)),gt&&(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"):Yt&&(e.touchAction="none")),Yt?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.addEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.addEventListener("mouseup",this.onPointerUp)),gt&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel),this.setuped=!0}normalize(e){const t=[];if(gt&&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(bn&&e instanceof globalThis.WheelEvent)t.push(e);else if(Yt&&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 br;return this.copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,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 Dn;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=Cl[t.type]||t.type),t}copyMouseEvent(e,t){e.preventDefault=t.preventDefault.bind(t),e.stopPropagation=t.stopPropagation.bind(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 yt extends Un{}var Tl={grad:.9,turn:360,rad:360/(2*Math.PI)},_t=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},_e=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=Math.pow(10,r)),Math.round(e*n)/e+0},Xe=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=1),n>e?e:n>r?n:r},Rn=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},Bn=function(n){return{r:Xe(n.r,0,255),g:Xe(n.g,0,255),b:Xe(n.b,0,255),a:Xe(n.a)}},os=function(n){return{r:_e(n.r),g:_e(n.g),b:_e(n.b),a:_e(n.a,3)}},El=/^#([0-9a-f]{3,8})$/i,ii=function(n){var r=n.toString(16);return r.length<2?"0"+r:r},Ln=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}},kn=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}},Nn=function(n){return{h:Rn(n.h),s:Xe(n.s,0,100),l:Xe(n.l,0,100),a:Xe(n.a)}},$n=function(n){return{h:_e(n.h),s:_e(n.s),l:_e(n.l),a:_e(n.a,3)}},Fn=function(n){return kn((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},wr=function(n){return{h:(r=Ln(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},Sl=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ml=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Al=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ol=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,as={string:[[function(n){var r=El.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?_e(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?_e(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var r=Al.exec(n)||Ol.exec(n);return r?r[2]!==r[4]||r[4]!==r[6]?null:Bn({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=Sl.exec(n)||Ml.exec(n);if(!r)return null;var e,t,i=Nn({h:(e=r[1],t=r[2],t===void 0&&(t="deg"),Number(e)*(Tl[t]||1)),s:Number(r[3]),l:Number(r[4]),a:r[5]===void 0?1:Number(r[5])/(r[6]?100:1)});return Fn(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 _t(r)&&_t(e)&&_t(t)?Bn({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(!_t(r)||!_t(e)||!_t(t))return null;var o=Nn({h:Number(r),s:Number(e),l:Number(t),a:Number(s)});return Fn(o)},"hsl"],[function(n){var r=n.h,e=n.s,t=n.v,i=n.a,s=i===void 0?1:i;if(!_t(r)||!_t(e)||!_t(t))return null;var o=function(a){return{h:Rn(a.h),s:Xe(a.s,0,100),v:Xe(a.v,0,100),a:Xe(a.a)}}({h:Number(r),s:Number(e),v:Number(t),a:Number(s)});return kn(o)},"hsv"]]},zn=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]},Ul=function(n){return typeof n=="string"?zn(n.trim(),as.string):typeof n=="object"&&n!==null?zn(n,as.object):[null,void 0]},ls=function(n,r){var e=wr(n);return{h:e.h,s:Xe(e.s+100*r,0,100),l:e.l,a:e.a}},hs=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},Vn=function(n,r){var e=wr(n);return{h:e.h,s:e.s,l:Xe(e.l+100*r,0,100),a:e.a}},cs=function(){function n(r){this.parsed=Ul(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 _e(hs(this.rgba),2)},n.prototype.isDark=function(){return hs(this.rgba)<.5},n.prototype.isLight=function(){return hs(this.rgba)>=.5},n.prototype.toHex=function(){return r=os(this.rgba),e=r.r,t=r.g,i=r.b,o=(s=r.a)<1?ii(_e(255*s)):"","#"+ii(e)+ii(t)+ii(i)+o;var r,e,t,i,s,o},n.prototype.toRgb=function(){return os(this.rgba)},n.prototype.toRgbString=function(){return r=os(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 $n(wr(this.rgba))},n.prototype.toHslString=function(){return r=$n(wr(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=Ln(this.rgba),{h:_e(r.h),s:_e(r.s),v:_e(r.v),a:_e(r.a,3)};var r},n.prototype.invert=function(){return nt({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),nt(ls(this.rgba,r))},n.prototype.desaturate=function(r){return r===void 0&&(r=.1),nt(ls(this.rgba,-r))},n.prototype.grayscale=function(){return nt(ls(this.rgba,-1))},n.prototype.lighten=function(r){return r===void 0&&(r=.1),nt(Vn(this.rgba,r))},n.prototype.darken=function(r){return r===void 0&&(r=.1),nt(Vn(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"?nt({r:(e=this.rgba).r,g:e.g,b:e.b,a:r}):_e(this.rgba.a,3);var e},n.prototype.hue=function(r){var e=wr(this.rgba);return typeof r=="number"?nt({h:r,s:e.s,l:e.l,a:e.a}):_e(e.h)},n.prototype.isEqual=function(r){return this.toHex()===nt(r).toHex()},n}(),nt=function(n){return n instanceof cs?n:new cs(n)},jn=[],Dl=function(n){n.forEach(function(r){jn.indexOf(r)<0&&(r(cs,as),jn.push(r))})};function Il(n,r){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},t={};for(var i in e)t[e[i]]=i;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=t[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),f=1/0,p="black";if(!s.length)for(var m in e)s[m]=new n(e[m]).toRgb();for(var g in e){var _=(a=c,l=s[g],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<f&&(f=_,p=g)}return p}},r.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new n(l).toRgb():null},"name"])}Dl([Il]);class Ct{get value(){return this._value}set value(r){if(r===void 0||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)/255}:e=r;const t=nt(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 Qe extends mt{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 ot||t instanceof Qe?a=t.toArray():a=t;let l,h=[];if(i?i instanceof Qe?l=i:h=i:l=this,t instanceof ot){const{cols:c}=t;switch(e){case"*":for(let f=0;f<s;f++){let p=0;for(let m=0;m<s;m++)p+=o[f]*a[m*c+f];h[f]=p}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let c=0;c<s;c++)h[c]=o[c]+a[c];break;case"-":for(let c=0;c<s;c++)h[c]=o[c]-a[c];break;case"*":for(let c=0;c<s;c++)h[c]=o[c]*a[c];break;case"/":for(let c=0;c<s;c++)h[c]=o[c]/a[c];break;case"rot":{const c=Math.cos(a[0]),f=Math.sin(a[0]);h[0]=o[0]*c-o[1]*f,h[1]=o[1]*c+o[0]*f;break}case"==":{let c=!0;for(let f=0;f<s;f++)c=c&&o[f]===a[f];return c}case"=":for(let c=0;c<s;c++){const f=a[c];f!==void 0&&(o[c]=f)}return this._emitUpdate(o),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(l==null?void 0:l.set(h))??h}add(e,t){return this._operate("+",e,t)}sub(e,t){return this._operate("-",e,t)}multiply(e,t){return this._operate("*",e,t)}divide(e,t){return this._operate("/",e,t)}rotate(e){return this._operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this._operate("=",e)}equals(e){return this._operate("==",e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_emitUpdate(e){this._onUpdate(e),this.emit("update",e)}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class ot extends mt{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 Qe||t instanceof ot?h=t.toArray():h=t;let c,f=[];if(i?i instanceof Qe||i instanceof ot?c=i:f=i:t instanceof Qe?c=new t.constructor:c=this,t instanceof Qe){const{dim:p}=t;switch(e){case"*":for(let m=0;m<p;m++){let g=0;for(let _=0;_<s;_++)_<p&&(g+=l[m*s+_]*(h[_]??0));f[m]=g}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let p=0;p<s;p++)for(let m=0;m<o;m++){const g=m*s;let _=0;for(let y=0;y<o;y++){const S=g+y,T=y*s+p;_+=l[S]*(h[T]??0)}f[g+p]=_}break;case"=":for(let p=0;p<a;p++){const m=h[p];m!==void 0&&(l[p]=m)}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 Gn extends ot{constructor(r){super(4,4,r)}}const qn=Me/180,Rl=180/Me;function at(n,r,e){return Math.max(n,Math.min(r,e))}function de(n,r,e){return(1-e)*n+e*r}const Bl={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}};class Wn extends Qe{constructor(r=0,e=0,t=0,i=0){super(4),this.set([r,e,t,i])}}class us extends ot{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=de(1,-1,r),t=de(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=at(0,r,1);return this.multiply([de(1,.393,e),de(0,.7689999,e),de(0,.18899999,e),0,0,de(0,.349,e),de(1,.6859999,e),de(0,.16799999,e),0,0,de(0,.272,e),de(0,.5339999,e),de(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=at(0,r,1),t=de(1,.3,e),i=de(0,.3,e),s=de(1,.59,e),o=de(0,.59,e),a=de(1,.11,e),l=de(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 Gn([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 Wn(r[4]/255,r[9]/255,r[14]/255,r[19]/255)}}class Ll extends ot{constructor(r){super(2,2,r)}}let fs=class extends ot{constructor(r){super(3,3,r)}invert(){const[r,e,t,i,s,o,a,l,h]=this._array,c=h*s-o*l,f=o*a-h*i,p=l*i-s*a,m=r*c+e*f+t*p;if(m===0)return this.set([0,0,0,0,0,0,0,0,0]);const g=1/m;return this.set([c*g,(t*l-h*e)*g,(o*e-t*s)*g,f*g,(h*r-t*a)*g,(t*i-o*r)*g,p*g,(e*a-l*r)*g,(s*r-e*i)*g])}};class Xn extends fs{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])}}let si=class Yi extends Qe{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 Yi(e).clone().sub(new Yi(r)).multiply(t).add(new Yi(r))}};class ni{constructor(...r){u(this,"end",new si);u(this,"position");u(this,"size");const e=new si,t=new si;switch(r.length){case 0:break;case 1:e.set(r[0].position),t.set(r[0].size);break;case 2:e.set(r[0]),t.set(r[1]);break;default:e.set(r[0],r[1]),t.set(r[2],r[3]);break}this.update=this.update.bind(this),this.position=e.on("update",this.update),this.size=t.on("update",this.update),this.update()}get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toArray(){return[this.x,this.y,this.width,this.height]}}class et extends fs{constructor(e=!0){super();u(this,"_cx",1);u(this,"_sx",0);u(this,"_cy",0);u(this,"_sy",1);u(this,"_translateX",0);u(this,"_translateY",0);u(this,"_translateZ",1);u(this,"_scaleX",1);u(this,"_scaleY",1);u(this,"_skewX",0);u(this,"_skewY",0);u(this,"_rotate",0);u(this,"dirtyId",0);u(this,"_needsUpdateArray",!1);u(this,"_needsUpdateFields",!1);this.autoUpdate=e}_onUpdate(e){super._onUpdate(e),this._requestUpdateFields()}_updateSkew(){this._cx=Math.cos(this._rotate+this._skewY),this._sx=Math.sin(this._rotate+this._skewY),this._cy=-Math.sin(this._rotate-this._skewX),this._sy=Math.cos(this._rotate-this._skewX)}_requestUpdateArray(){this.autoUpdate?this._performUpdateArray():this._needsUpdateArray=!0}_requestUpdateFields(){this.autoUpdate?this._performUpdateFields():this._needsUpdateFields=!0}_performUpdateArray(){const e=this._cx*this._scaleX,t=this._sx*this._scaleX,i=this._cy*this._scaleY,s=this._sy*this._scaleY,o=this._translateX,a=this._translateY,l=this._translateZ,h=this._array;this._array=[e,i,o,t,s,a,h[6],h[7],l],this.dirtyId++}_performUpdateFields(){const{a:e,c:t,tx:i,b:s,d:o,ty:a,tz:l}=this.toObject(),h=-Math.atan2(-t,o),c=Math.atan2(s,e),f=Math.abs(h+c);f<1e-5||Math.abs(le-f)<1e-5?(this._rotate=c,this._skewX=this._skewY=0):(this._rotate=0,this._skewX=h,this._skewY=c),this._scaleX=Math.sqrt(e*e+s*s),this._scaleY=Math.sqrt(t*t+o*o),this._translateX=i,this._translateY=a,this._translateZ=l,this.dirtyId++}skew(e,t){return this._skewX=e,this._skewY=t,this._updateSkew(),this._requestUpdateArray(),this}skewX(e){return this.skew(e,this._skewY)}skewY(e){return this.skew(this._skewX,e)}translate(e,t,i=1){return this._translateX=e,this._translateY=t,this._translateZ=i,this._requestUpdateArray(),this}translateX(e){return this.translate(e,this._translateY)}translateY(e){return this.translate(this._translateX,e)}translateZ(e){return this.translate(this._translateX,this._translateY,e)}translate3d(e,t,i){return this.translate(e,t,i)}scale(e,t,i=1){return this._scaleX=e,this._scaleY=t,this._requestUpdateArray(),this}scaleX(e){return this.scale(e,this._scaleY)}scaleY(e){return this.scale(this._scaleX,e)}scale3d(e,t,i){return this.scale(e,t,i)}rotate(e){return this._rotate=e,this._updateSkew(),this._requestUpdateArray(),this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate3d(e,t,i,s){const[o,a,l]=this._rotate3d(e,t,i,s);return o&&this.rotateX(o),a&&this.rotateY(a),l&&this.rotateZ(l),this}_rotateToScale(e){const t=e/le;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,i,s){if(e===1&&t===0&&i===0)return[s,0,0];if(e===0&&t===1&&i===0)return[0,s,0];if(e===0&&t===0)return[0,0,s];{const o=Math.cos(s),a=Math.sin(s),l=o+e*e*(1-o),h=e*t*(1-o)-i*a,c=e*i*(1-o)+t*a,f=o+t*t*(1-o),p=t*i*(1-o)-e*a,m=o+i*i*(1-o),g=-Math.atan2(-p,f),_=-Math.atan2(c,Math.sqrt(p*p+m*m)),y=-Math.atan2(-h,l);return[g,_,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}}}class kl extends Qe{constructor(){super(3)}}var Nl=Object.defineProperty,Hn=(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&&Nl(r,e,i),i};class oi extends ti{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),fe.on(this._onNextTick,{sort:0})),this}stop(){return this._starting&&(this._starting=!1,fe.off(this._onNextTick,{sort:0})),this}_onNextTick(){const e=fe.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}}Hn([M({default:24})],oi.prototype,"fps"),Hn([M({default:1})],oi.prototype,"speed");class Yn{constructor(){u(this,"view");u(this,"pixelRatio",rs);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new Zt)}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 Kt=(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))(Kt||{});function Zn(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 He{get gl(){return this._renderer.gl}install(r){this._renderer=r}onUpdateContext(){}flush(){}reset(){}destroy(){}}const Gi=class Gi{constructor(r){u(this,"_blendMode",Kt.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 Gi;return r.depthTest=!1,r.blend=!0,r}get blendMode(){return this._blendMode}set blendMode(r){this.blend=r!==Kt.NONE,this._blendMode=r}get polygonOffset(){return this._polygonOffset}set polygonOffset(r){this.offsets=!!r,this._polygonOffset=r}};u(Gi,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let Lt=Gi;Lt._init();class Kn extends He{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",Lt._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 Lt({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=Zn(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(Kt.NORMAL)}}class Jn extends He{constructor(){super(...arguments);u(this,"_state",Lt.for2D());u(this,"_batchSize",4096*4);u(this,"_vertexSize",27);u(this,"_drawCallUid",0);u(this,"_defaultModulate",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"},aModulate:{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;
1
+ (function(d,Me){typeof exports=="object"&&typeof module<"u"?Me(exports):typeof define=="function"&&define.amd?define(["exports"],Me):(d=typeof globalThis<"u"?globalThis:d||self,Me(d.modernCanvas={}))})(this,function(d){"use strict";var Dp=Object.defineProperty;var Rp=(d,Me,le)=>Me in d?Dp(d,Me,{enumerable:!0,configurable:!0,writable:!0,value:le}):d[Me]=le;var u=(d,Me,le)=>Rp(d,typeof Me!="symbol"?Me+"":Me,le);var Xt,Bt;const Me=Math.PI,le=Me*2;let gl=0;function gn(n){var r;return((r=n==null?void 0:n.__SPECTOR_Object_TAG)==null?void 0:r.id)??++gl}function Zi(n){return!(n&n-1)&&!!n}const ml=/([\w-]+)\((.+?)\)/g,yl=/[^,]+/g,_l=/([-e.\d]+)(.*)/;function Ki(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:mn(n,r,e)}function yr(n,r={}){const e=[];let t;for(;(t=ml.exec(n))!==null;){const[,i,s]=t;i&&e.push({name:i,args:vl(i,s,r)})}return e}function vl(n,r,e={}){const t=[];let i,s=0;for(;(i=yl.exec(r))!==null;)t.push(mn(n,i[0],{...e,index:s++}));return t}function mn(n,r,e={}){const{width:t=1,height:i=1,index:s=0}=e,o=r.match(_l),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 yn="WebGL2RenderingContext"in globalThis,_n="ImageBitmap"in globalThis,vn="ResizeObserver"in globalThis,Yt="PointerEvent"in globalThis,bn="WheelEvent"in globalThis,bl="MouseEvent"in globalThis,gt="ontouchstart"in globalThis,wn="onclick"in globalThis,Ji="createImageBitmap"in globalThis,Qi="AudioContext"in globalThis,es="webkitAudioContext"in globalThis,ts="OfflineAudioContext"in globalThis,xn="webkitOfflineAudioContext"in globalThis,Pn=Qi||es,_r=typeof window<"u",rs=globalThis.devicePixelRatio||1,is=n=>n!==null&&typeof n=="object"&&n.nodeType===1,Cn=n=>is(n)&&n.tagName==="VIDEO",wl=n=>is(n)&&n.tagName==="IMG";function Tn(n){return typeof n=="object"&&n!==null&&n.nodeType===1&&n.tagName==="CANVAS"}function Sn(n){return yn&&n instanceof globalThis.WebGL2RenderingContext}function En(){if(_r)return globalThis.document.createElement("canvas")}function Mn(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 An(n,r,e){e===null&&!r.startsWith("data:")?n.crossOrigin=Mn(r):e!==!1&&(n.crossOrigin=typeof e=="string"?e:"anonymous")}class Zt{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 On=new Zt;function Qr(n){let r=On.get(n);if(!r){const e=Object.getPrototypeOf(n);r=new Map(e?Qr(e):void 0),On.set(n,r)}return r}function vr(n,r,e={}){Qr(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 M(n){return function(r,e){vr(r.constructor,e,n)}}const ei=new Map;function j(n,r){return function(e){Object.defineProperty(e.prototype,"tag",{value:n,enumerable:!0,configurable:!0}),r&&Object.keys(r).forEach(t=>{vr(e,t,{default:r[t]})}),ei.set(n,e)}}function ue(n){return M({...n,protected:!0})}function xl(n="node",r={}){const e=ei.get(n);if(!e)throw new Error(`Failed to createNode, tag: ${n}`);return new e().setProperties(r)}class fe{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(fe,"_queue",[]),u(fe,"_currentTime",0),u(fe,"_elapsed",0),u(fe,"_requestId"),fe.start();async function ss(n){return new Promise(r=>{fe.on(()=>{n==null||n(),r()},{sort:1,once:!0})})}let mt=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}},Pl=0;class ti extends mt{constructor(){super(...arguments);u(this,"instanceId",++Pl);u(this,"_defaultProperties");u(this,"_updatedProperties",new Map);u(this,"_changedProperties",new Set);u(this,"_updatingPromise",Promise.resolve());u(this,"_updating",!1)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await ss(),this._performUpdate()}_performUpdate(){this._updating&&(this._onUpdate(this._updatedProperties),this._updatedProperties=new Map,this._updating=!1)}_onUpdate(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return Qr(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._updateProperty(e,s,t,i),this.emit("updateProperty",e,s,t,i);else return}this._updating||(this._updatingPromise=this._enqueueUpdate())}toJSON(){return this.getProperties(Array.from(this._changedProperties))}clone(){return new this.constructor(this.toJSON())}destroy(){this.removeAllListeners()}}class Un extends ti{}class ri{constructor(){u(this,"bubbles",!0);u(this,"cancelable",!1);u(this,"which");u(this,"cancelBubble",!0);u(this,"returnValue");u(this,"srcElement");u(this,"composed",!1);u(this,"currentTarget");u(this,"defaultPrevented",!1);u(this,"eventPhase",ri.prototype.NONE);u(this,"isTrusted");u(this,"target");u(this,"timeStamp");u(this,"type");u(this,"nativeEvent");u(this,"originalEvent");u(this,"propagationStopped",!1);u(this,"propagationImmediatelyStopped",!1);u(this,"path");u(this,"detail");u(this,"view");u(this,"layer",{x:0,y:0});u(this,"page",{x:0,y:0});u(this,"NONE",0);u(this,"CAPTURING_PHASE",1);u(this,"AT_TARGET",2);u(this,"BUBBLING_PHASE",3)}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}initEvent(...r){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...r){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}composedPath(){return this.path}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class ns extends ri{constructor(){super(...arguments);u(this,"altKey");u(this,"button");u(this,"buttons");u(this,"ctrlKey");u(this,"metaKey");u(this,"relatedTarget");u(this,"shiftKey");u(this,"client",{x:0,y:0});u(this,"movement",{x:0,y:0});u(this,"offset",{x:0,y:0});u(this,"global",{x:0,y:0});u(this,"screen",{x:0,y:0})}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}}class In extends ns{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 br extends ns{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(br,"DOM_DELTA_PIXEL",0),u(br,"DOM_DELTA_LINE",1),u(br,"DOM_DELTA_PAGE",2);const Cl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class Dn extends mt{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(gt&&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||gt&&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||gt&&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||gt&&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=""):Yt&&(e.touchAction=""),Yt?(this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointerleave",this.onPointerOver),this.target.removeEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.removeEventListener("pointerup",this.onPointerUp)):(this.target.removeEventListener("mousedown",this.onPointerDown),this.target.removeEventListener("mouseout",this.onPointerOver),this.target.removeEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.removeEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.removeEventListener("mouseup",this.onPointerUp)),gt&&(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"):Yt&&(e.touchAction="none")),Yt?(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointerleave",this.onPointerOver),this.target.addEventListener("pointerover",this.onPointerOver),this.target.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.target.ownerDocument.addEventListener("pointerup",this.onPointerUp)):(this.target.addEventListener("mousedown",this.onPointerDown),this.target.addEventListener("mouseout",this.onPointerOver),this.target.addEventListener("mouseover",this.onPointerOver),this.target.ownerDocument.addEventListener("mousemove",this.onPointerMove),this.target.ownerDocument.addEventListener("mouseup",this.onPointerUp)),gt&&(this.target.addEventListener("touchstart",this.onPointerDown),this.target.addEventListener("touchmove",this.onPointerMove),this.target.addEventListener("touchend",this.onPointerUp)),this.target.addEventListener("wheel",this.onWheel),this.setuped=!0}normalize(e){const t=[];if(gt&&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(bn&&e instanceof globalThis.WheelEvent)t.push(e);else if(Yt&&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 br;return this.copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,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 In;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=Cl[t.type]||t.type),t}copyMouseEvent(e,t){e.preventDefault=t.preventDefault.bind(t),e.stopPropagation=t.stopPropagation.bind(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 yt extends Un{}var Tl={grad:.9,turn:360,rad:360/(2*Math.PI)},_t=function(n){return typeof n=="string"?n.length>0:typeof n=="number"},ye=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=Math.pow(10,r)),Math.round(e*n)/e+0},Xe=function(n,r,e){return r===void 0&&(r=0),e===void 0&&(e=1),n>e?e:n>r?n:r},Rn=function(n){return(n=isFinite(n)?n%360:0)>0?n:n+360},Bn=function(n){return{r:Xe(n.r,0,255),g:Xe(n.g,0,255),b:Xe(n.b,0,255),a:Xe(n.a)}},os=function(n){return{r:ye(n.r),g:ye(n.g),b:ye(n.b),a:ye(n.a,3)}},Sl=/^#([0-9a-f]{3,8})$/i,ii=function(n){var r=n.toString(16);return r.length<2?"0"+r:r},kn=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}},Ln=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}},Nn=function(n){return{h:Rn(n.h),s:Xe(n.s,0,100),l:Xe(n.l,0,100),a:Xe(n.a)}},Fn=function(n){return{h:ye(n.h),s:ye(n.s),l:ye(n.l),a:ye(n.a,3)}},$n=function(n){return Ln((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},wr=function(n){return{h:(r=kn(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},El=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ml=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Al=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ol=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,as={string:[[function(n){var r=Sl.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?ye(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?ye(parseInt(n.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(n){var r=Al.exec(n)||Ol.exec(n);return r?r[2]!==r[4]||r[4]!==r[6]?null:Bn({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=El.exec(n)||Ml.exec(n);if(!r)return null;var e,t,i=Nn({h:(e=r[1],t=r[2],t===void 0&&(t="deg"),Number(e)*(Tl[t]||1)),s:Number(r[3]),l:Number(r[4]),a:r[5]===void 0?1:Number(r[5])/(r[6]?100:1)});return $n(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 _t(r)&&_t(e)&&_t(t)?Bn({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(!_t(r)||!_t(e)||!_t(t))return null;var o=Nn({h:Number(r),s:Number(e),l:Number(t),a:Number(s)});return $n(o)},"hsl"],[function(n){var r=n.h,e=n.s,t=n.v,i=n.a,s=i===void 0?1:i;if(!_t(r)||!_t(e)||!_t(t))return null;var o=function(a){return{h:Rn(a.h),s:Xe(a.s,0,100),v:Xe(a.v,0,100),a:Xe(a.a)}}({h:Number(r),s:Number(e),v:Number(t),a:Number(s)});return Ln(o)},"hsv"]]},zn=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]},Ul=function(n){return typeof n=="string"?zn(n.trim(),as.string):typeof n=="object"&&n!==null?zn(n,as.object):[null,void 0]},ls=function(n,r){var e=wr(n);return{h:e.h,s:Xe(e.s+100*r,0,100),l:e.l,a:e.a}},hs=function(n){return(299*n.r+587*n.g+114*n.b)/1e3/255},Vn=function(n,r){var e=wr(n);return{h:e.h,s:e.s,l:Xe(e.l+100*r,0,100),a:e.a}},cs=function(){function n(r){this.parsed=Ul(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 ye(hs(this.rgba),2)},n.prototype.isDark=function(){return hs(this.rgba)<.5},n.prototype.isLight=function(){return hs(this.rgba)>=.5},n.prototype.toHex=function(){return r=os(this.rgba),e=r.r,t=r.g,i=r.b,o=(s=r.a)<1?ii(ye(255*s)):"","#"+ii(e)+ii(t)+ii(i)+o;var r,e,t,i,s,o},n.prototype.toRgb=function(){return os(this.rgba)},n.prototype.toRgbString=function(){return r=os(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 Fn(wr(this.rgba))},n.prototype.toHslString=function(){return r=Fn(wr(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=kn(this.rgba),{h:ye(r.h),s:ye(r.s),v:ye(r.v),a:ye(r.a,3)};var r},n.prototype.invert=function(){return nt({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),nt(ls(this.rgba,r))},n.prototype.desaturate=function(r){return r===void 0&&(r=.1),nt(ls(this.rgba,-r))},n.prototype.grayscale=function(){return nt(ls(this.rgba,-1))},n.prototype.lighten=function(r){return r===void 0&&(r=.1),nt(Vn(this.rgba,r))},n.prototype.darken=function(r){return r===void 0&&(r=.1),nt(Vn(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"?nt({r:(e=this.rgba).r,g:e.g,b:e.b,a:r}):ye(this.rgba.a,3);var e},n.prototype.hue=function(r){var e=wr(this.rgba);return typeof r=="number"?nt({h:r,s:e.s,l:e.l,a:e.a}):ye(e.h)},n.prototype.isEqual=function(r){return this.toHex()===nt(r).toHex()},n}(),nt=function(n){return n instanceof cs?n:new cs(n)},jn=[],Il=function(n){n.forEach(function(r){jn.indexOf(r)<0&&(r(cs,as),jn.push(r))})};function Dl(n,r){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},t={};for(var i in e)t[e[i]]=i;var s={};n.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=t[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),f=1/0,p="black";if(!s.length)for(var m in e)s[m]=new n(e[m]).toRgb();for(var g in e){var _=(a=c,l=s[g],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));_<f&&(f=_,p=g)}return p}},r.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new n(l).toRgb():null},"name"])}Il([Dl]);class Ct{get value(){return this._value}set value(r){if(r===void 0||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)/255}:e=r;const t=nt(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 Qe extends mt{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 ot||t instanceof Qe?a=t.toArray():a=t;let l,h=[];if(i?i instanceof Qe?l=i:h=i:l=this,t instanceof ot){const{cols:c}=t;switch(e){case"*":for(let f=0;f<s;f++){let p=0;for(let m=0;m<s;m++)p+=o[f]*a[m*c+f];h[f]=p}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let c=0;c<s;c++)h[c]=o[c]+a[c];break;case"-":for(let c=0;c<s;c++)h[c]=o[c]-a[c];break;case"*":for(let c=0;c<s;c++)h[c]=o[c]*a[c];break;case"/":for(let c=0;c<s;c++)h[c]=o[c]/a[c];break;case"rot":{const c=Math.cos(a[0]),f=Math.sin(a[0]);h[0]=o[0]*c-o[1]*f,h[1]=o[1]*c+o[0]*f;break}case"==":{let c=!0;for(let f=0;f<s;f++)c=c&&o[f]===a[f];return c}case"=":for(let c=0;c<s;c++){const f=a[c];f!==void 0&&(o[c]=f)}return this._emitUpdate(o),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(l==null?void 0:l.set(h))??h}add(e,t){return this._operate("+",e,t)}sub(e,t){return this._operate("-",e,t)}multiply(e,t){return this._operate("*",e,t)}divide(e,t){return this._operate("/",e,t)}rotate(e){return this._operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this._operate("=",e)}equals(e){return this._operate("==",e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_emitUpdate(e){this._onUpdate(e),this.emit("update",e)}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class ot extends mt{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 Qe||t instanceof ot?h=t.toArray():h=t;let c,f=[];if(i?i instanceof Qe||i instanceof ot?c=i:f=i:t instanceof Qe?c=new t.constructor:c=this,t instanceof Qe){const{dim:p}=t;switch(e){case"*":for(let m=0;m<p;m++){let g=0;for(let _=0;_<s;_++)_<p&&(g+=l[m*s+_]*(h[_]??0));f[m]=g}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let p=0;p<s;p++)for(let m=0;m<o;m++){const g=m*s;let _=0;for(let y=0;y<o;y++){const E=g+y,T=y*s+p;_+=l[E]*(h[T]??0)}f[g+p]=_}break;case"=":for(let p=0;p<a;p++){const m=h[p];m!==void 0&&(l[p]=m)}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 Gn extends ot{constructor(r){super(4,4,r)}}const qn=Me/180,Rl=180/Me;function at(n,r,e){return Math.max(n,Math.min(r,e))}function de(n,r,e){return(1-e)*n+e*r}const Bl={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}};class Wn extends Qe{constructor(r=0,e=0,t=0,i=0){super(4),this.set([r,e,t,i])}}class us extends ot{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=de(1,-1,r),t=de(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=at(0,r,1);return this.multiply([de(1,.393,e),de(0,.7689999,e),de(0,.18899999,e),0,0,de(0,.349,e),de(1,.6859999,e),de(0,.16799999,e),0,0,de(0,.272,e),de(0,.5339999,e),de(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=at(0,r,1),t=de(1,.3,e),i=de(0,.3,e),s=de(1,.59,e),o=de(0,.59,e),a=de(1,.11,e),l=de(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 Gn([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 Wn(r[4]/255,r[9]/255,r[14]/255,r[19]/255)}}class kl extends ot{constructor(r){super(2,2,r)}}let fs=class extends ot{constructor(r){super(3,3,r)}invert(){const[r,e,t,i,s,o,a,l,h]=this._array,c=h*s-o*l,f=o*a-h*i,p=l*i-s*a,m=r*c+e*f+t*p;if(m===0)return this.set([0,0,0,0,0,0,0,0,0]);const g=1/m;return this.set([c*g,(t*l-h*e)*g,(o*e-t*s)*g,f*g,(h*r-t*a)*g,(t*i-o*r)*g,p*g,(e*a-l*r)*g,(s*r-e*i)*g])}};class Xn extends fs{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])}}let si=class Yi extends Qe{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 Yi(e).clone().sub(new Yi(r)).multiply(t).add(new Yi(r))}};class ni{constructor(...r){u(this,"end",new si);u(this,"position");u(this,"size");const e=new si,t=new si;switch(r.length){case 0:break;case 1:e.set(r[0].position),t.set(r[0].size);break;case 2:e.set(r[0]),t.set(r[1]);break;default:e.set(r[0],r[1]),t.set(r[2],r[3]);break}this.update=this.update.bind(this),this.position=e.on("update",this.update),this.size=t.on("update",this.update),this.update()}get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toArray(){return[this.x,this.y,this.width,this.height]}}class et extends fs{constructor(e=!0){super();u(this,"_cx",1);u(this,"_sx",0);u(this,"_cy",0);u(this,"_sy",1);u(this,"_translateX",0);u(this,"_translateY",0);u(this,"_translateZ",1);u(this,"_scaleX",1);u(this,"_scaleY",1);u(this,"_skewX",0);u(this,"_skewY",0);u(this,"_rotate",0);u(this,"dirtyId",0);u(this,"_needsUpdateArray",!1);u(this,"_needsUpdateFields",!1);this.autoUpdate=e}_onUpdate(e){super._onUpdate(e),this._requestUpdateFields()}_updateSkew(){this._cx=Math.cos(this._rotate+this._skewY),this._sx=Math.sin(this._rotate+this._skewY),this._cy=-Math.sin(this._rotate-this._skewX),this._sy=Math.cos(this._rotate-this._skewX)}_requestUpdateArray(){this.autoUpdate?this._performUpdateArray():this._needsUpdateArray=!0}_requestUpdateFields(){this.autoUpdate?this._performUpdateFields():this._needsUpdateFields=!0}_performUpdateArray(){const e=this._cx*this._scaleX,t=this._sx*this._scaleX,i=this._cy*this._scaleY,s=this._sy*this._scaleY,o=this._translateX,a=this._translateY,l=this._translateZ,h=this._array;this._array=[e,i,o,t,s,a,h[6],h[7],l],this.dirtyId++}_performUpdateFields(){const{a:e,c:t,tx:i,b:s,d:o,ty:a,tz:l}=this.toObject(),h=-Math.atan2(-t,o),c=Math.atan2(s,e),f=Math.abs(h+c);f<1e-5||Math.abs(le-f)<1e-5?(this._rotate=c,this._skewX=this._skewY=0):(this._rotate=0,this._skewX=h,this._skewY=c),this._scaleX=Math.sqrt(e*e+s*s),this._scaleY=Math.sqrt(t*t+o*o),this._translateX=i,this._translateY=a,this._translateZ=l,this.dirtyId++}skew(e,t){return this._skewX=e,this._skewY=t,this._updateSkew(),this._requestUpdateArray(),this}skewX(e){return this.skew(e,this._skewY)}skewY(e){return this.skew(this._skewX,e)}translate(e,t,i=1){return this._translateX=e,this._translateY=t,this._translateZ=i,this._requestUpdateArray(),this}translateX(e){return this.translate(e,this._translateY)}translateY(e){return this.translate(this._translateX,e)}translateZ(e){return this.translate(this._translateX,this._translateY,e)}translate3d(e,t,i){return this.translate(e,t,i)}scale(e,t,i=1){return this._scaleX=e,this._scaleY=t,this._requestUpdateArray(),this}scaleX(e){return this.scale(e,this._scaleY)}scaleY(e){return this.scale(this._scaleX,e)}scale3d(e,t,i){return this.scale(e,t,i)}rotate(e){return this._rotate=e,this._updateSkew(),this._requestUpdateArray(),this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate3d(e,t,i,s){const[o,a,l]=this._rotate3d(e,t,i,s);return o&&this.rotateX(o),a&&this.rotateY(a),l&&this.rotateZ(l),this}_rotateToScale(e){const t=e/le;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,i,s){if(e===1&&t===0&&i===0)return[s,0,0];if(e===0&&t===1&&i===0)return[0,s,0];if(e===0&&t===0)return[0,0,s];{const o=Math.cos(s),a=Math.sin(s),l=o+e*e*(1-o),h=e*t*(1-o)-i*a,c=e*i*(1-o)+t*a,f=o+t*t*(1-o),p=t*i*(1-o)-e*a,m=o+i*i*(1-o),g=-Math.atan2(-p,f),_=-Math.atan2(c,Math.sqrt(p*p+m*m)),y=-Math.atan2(-h,l);return[g,_,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}}}class Ll extends Qe{constructor(){super(3)}}var Nl=Object.defineProperty,Hn=(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&&Nl(r,e,i),i};class oi extends ti{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),fe.on(this._onNextTick,{sort:0})),this}stop(){return this._starting&&(this._starting=!1,fe.off(this._onNextTick,{sort:0})),this}_onNextTick(){const e=fe.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}}Hn([M({default:24})],oi.prototype,"fps"),Hn([M({default:1})],oi.prototype,"speed");class Yn{constructor(){u(this,"view");u(this,"pixelRatio",rs);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new Zt)}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 Kt=(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))(Kt||{});function Zn(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 He{get gl(){return this._renderer.gl}install(r){this._renderer=r}onUpdateContext(){}flush(){}reset(){}destroy(){}}const Gi=class Gi{constructor(r){u(this,"_blendMode",Kt.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 Gi;return r.depthTest=!1,r.blend=!0,r}get blendMode(){return this._blendMode}set blendMode(r){this.blend=r!==Kt.NONE,this._blendMode=r}get polygonOffset(){return this._polygonOffset}set polygonOffset(r){this.offsets=!!r,this._polygonOffset=r}};u(Gi,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let kt=Gi;kt._init();class Kn extends He{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",kt._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 kt({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=Zn(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(Kt.NORMAL)}}class Jn extends He{constructor(){super(...arguments);u(this,"_state",kt.for2D());u(this,"_batchSize",4096*4);u(this,"_vertexSize",27);u(this,"_drawCallUid",0);u(this,"_defaultModulate",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"},aModulate:{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;
2
2
  attribute float aTextureId;
3
3
  attribute vec2 aPosition;
4
4
  attribute vec2 aUv;
@@ -55,10 +55,10 @@ void main(void) {
55
55
  color += vColorMatrixOffset;
56
56
  }
57
57
  gl_FragColor = color;
58
- }`}),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,modulate:[1,1,1,1],translationMatrix:[1,0,0,0,1,0,0,0,1],...f.program.uniforms}),f.vertexArray.bind(l??a),f.draw(c)}}}render(e){const{vertices:t,indices:i}=e,s=t.length/2;this._vertexCount+s>this._batchSize&&this.flush(),this._vertexCount+=s,this._indexCount+=i.length,this._batchables.push(e)}flush(){if(super.flush(),this._vertexCount===0)return;const e=this._vertexCount,t=this._indexCount,i=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const s=this._renderer.texture.maxUnits,o=this._getAttributeBuffer(e),a=new Float32Array(o),l=new Uint32Array(o),h=this._getIndexBuffer(t);let c=0,f=0;const p=[];for(let g=i.length,_={id:++this._drawCallUid},y=[],S=new Map,T=0,P=0,E=0;E<g;E++){const w=i[E].texture,v=E===g-1;if(!w||S.has(w)){if(!v)continue}else y.push(w),S.set(w,T++);if(v||T>=s){_.textures=y,_.textureLocationMap=S,T=0,_.first=f;for(let x=P;x<=E;x++){const{indices:C,vertices:D,uvs:$=[],texture:B,modulate:U=this._defaultModulate,backgroundColor:V=this._defaultBackgroundColor,colorMatrix:A=this._defaultColorMatrix,colorMatrixOffset:N=this._defaultColorMatrixOffset,blendMode:W=Kt.NORMAL}=i[x],R=(B?S.get(B):-1)??-1;P<x&&_.blendMode!==W&&(_.count=f-_.first,p.push(_),P=x,_={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++]=$[k]??0,a[c++]=$[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++]=A[L]??0}for(let j=C.length,k=0;k<j;k++)h[f++]=I+C[k];_.blendMode=W}P=E+1,_.count=f-_.first,p.push(_),_={id:++this._drawCallUid},y=[],S=new Map}}const m=this._getShader(s);m.update(o,h);for(let g=p.length,_=0;_<g;_++){const y=p[_],{first:S=0,textures:T,textureLocationMap:P}=y;for(let E=T.length,w=0;w<E;w++){const v=T[w],x=P.get(v);x!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:x,value:v})}this._state.blendMode=y.blendMode,this._renderer.state.bind(this._state),m.draw({mode:"triangles",count:y.count,first:S,bytesPerElement:2})}}_getAttributeBuffer(e){const t=ds(Math.ceil(e/8)),i=ps(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=ds(Math.ceil(e/12)),i=ps(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 ds(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 ps(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 Qn extends He{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:gn(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 eo extends He{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 to extends He{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 ro extends He{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 Zt}))}update(...e){if(e.length>1){const h=this.boundProgram;this.boundProgram=e[0],this.update(e[1]),this.boundProgram=h;return}const t=e[0],i=this.boundProgram;if(!i)return;const s=this.gl,o=this.getMeta(i),a=this.createShader(t.vert,"vertex_shader"),l=this.createShader(t.frag,"fragment_shader");if(s.attachShader(i,a),s.attachShader(i,l),s.linkProgram(i),s.deleteShader(a),s.deleteShader(l),!s.getProgramParameter(i,s.LINK_STATUS))throw new Error(`Unable to link program: ${s.getProgramInfoLog(i)}`);o.attributes.clear(),o.uniforms.clear();for(let h=s.getProgramParameter(i,s.ACTIVE_ATTRIBUTES),c=0;c<h;c++){const f=s.getActiveAttrib(i,c);if(!f||f.name.startsWith("gl_"))continue;const p=this._renderer.bindPoints.get(f.type)??String(f.type);o.attributes.set(f.name,{type:p,name:f.name,size:$l(p),location:s.getAttribLocation(i,f.name)})}for(let h=s.getProgramParameter(i,s.ACTIVE_UNIFORMS),c=0;c<h;c++){const f=s.getActiveUniform(i,c);if(!f)continue;const p=f.name.replace(/\[.*?\]$/,"");let m=s.getUniformLocation(i,p);m||(m=s.getUniformLocation(i,f.name)),o.uniforms.set(p,{name:p,index:c,type:this._renderer.bindPoints.get(f.type)??String(f.type),size:f.size,isArray:p!==f.name,location:m})}}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 :
58
+ }`}),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,modulate:[1,1,1,1],translationMatrix:[1,0,0,0,1,0,0,0,1],...f.program.uniforms}),f.vertexArray.bind(l??a),f.draw(c)}}}render(e){const{vertices:t,indices:i}=e,s=t.length/2;this._vertexCount+s>this._batchSize&&this.flush(),this._vertexCount+=s,this._indexCount+=i.length,this._batchables.push(e)}flush(){if(super.flush(),this._vertexCount===0)return;const e=this._vertexCount,t=this._indexCount,i=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const s=this._renderer.texture.maxUnits,o=this._getAttributeBuffer(e),a=new Float32Array(o),l=new Uint32Array(o),h=this._getIndexBuffer(t);let c=0,f=0;const p=[];for(let g=i.length,_={id:++this._drawCallUid},y=[],E=new Map,T=0,P=0,S=0;S<g;S++){const w=i[S].texture,v=S===g-1;if(!w||E.has(w)){if(!v)continue}else y.push(w),E.set(w,T++);if(v||T>=s){_.textures=y,_.textureLocationMap=E,T=0,_.first=f;for(let x=P;x<=S;x++){const{indices:C,vertices:I,uvs:F=[],texture:B,modulate:U=this._defaultModulate,backgroundColor:V=this._defaultBackgroundColor,colorMatrix:A=this._defaultColorMatrix,colorMatrixOffset:N=this._defaultColorMatrixOffset,blendMode:W=Kt.NORMAL}=i[x],R=(B?E.get(B):-1)??-1;P<x&&_.blendMode!==W&&(_.count=f-_.first,p.push(_),P=x,_={id:++this._drawCallUid},_.textures=y,_.first=f);const D=c/this._vertexSize;for(let G=I.length,L=0;L<G;L+=2){a[c++]=R,a[c++]=I[L],a[c++]=I[L+1],a[c++]=F[L]??0,a[c++]=F[L+1]??0,l[c++]=U,l[c++]=V;for(let k=0;k<4;k++)a[c++]=N[k]??0;for(let k=0;k<16;k++)a[c++]=A[k]??0}for(let G=C.length,L=0;L<G;L++)h[f++]=D+C[L];_.blendMode=W}P=S+1,_.count=f-_.first,p.push(_),_={id:++this._drawCallUid},y=[],E=new Map}}const m=this._getShader(s);m.update(o,h);for(let g=p.length,_=0;_<g;_++){const y=p[_],{first:E=0,textures:T,textureLocationMap:P}=y;for(let S=T.length,w=0;w<S;w++){const v=T[w],x=P.get(v);x!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:x,value:v})}this._state.blendMode=y.blendMode,this._renderer.state.bind(this._state),m.draw({mode:"triangles",count:y.count,first:E,bytesPerElement:2})}}_getAttributeBuffer(e){const t=ds(Math.ceil(e/8)),i=ps(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=ds(Math.ceil(e/12)),i=ps(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 ds(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 ps(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 Qn extends He{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:gn(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 eo extends He{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 to extends He{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 ro extends He{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 Zt}))}update(...e){if(e.length>1){const h=this.boundProgram;this.boundProgram=e[0],this.update(e[1]),this.boundProgram=h;return}const t=e[0],i=this.boundProgram;if(!i)return;const s=this.gl,o=this.getMeta(i),a=this.createShader(t.vert,"vertex_shader"),l=this.createShader(t.frag,"fragment_shader");if(s.attachShader(i,a),s.attachShader(i,l),s.linkProgram(i),s.deleteShader(a),s.deleteShader(l),!s.getProgramParameter(i,s.LINK_STATUS))throw new Error(`Unable to link program: ${s.getProgramInfoLog(i)}`);o.attributes.clear(),o.uniforms.clear();for(let h=s.getProgramParameter(i,s.ACTIVE_ATTRIBUTES),c=0;c<h;c++){const f=s.getActiveAttrib(i,c);if(!f||f.name.startsWith("gl_"))continue;const p=this._renderer.bindPoints.get(f.type)??String(f.type);o.attributes.set(f.name,{type:p,name:f.name,size:Fl(p),location:s.getAttribLocation(i,f.name)})}for(let h=s.getProgramParameter(i,s.ACTIVE_UNIFORMS),c=0;c<h;c++){const f=s.getActiveUniform(i,c);if(!f)continue;const p=f.name.replace(/\[.*?\]$/,"");let m=s.getUniformLocation(i,p);m||(m=s.getUniformLocation(i,f.name)),o.uniforms.set(p,{name:p,index:c,type:this._renderer.bindPoints.get(f.type)??String(f.type),size:f.size,isArray:p!==f.name,location:m})}}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 :
59
59
  ${e}
60
- ${i.getShaderInfoLog(s)}`);return s}updateUniforms(...e){if(e.length>1){this.bind(e[0]),this.updateUniforms(e[1]);return}const t=this.boundProgram;if(!t)return;const i=this.gl,s=e[0],{uniforms:o,boundUniforms:a}=this.getMeta(t);for(const l in s){const h=s[l],c=o.get(l);if(!c)continue;const{type:f,isArray:p,location:m}=c;if(!(!m||a.get(m)===h))switch(a.set(m,h),f){case"float":p?i.uniform1fv(m,h):i.uniform1f(m,h);break;case"unsigned_int":p?i.uniform1uiv(m,h):i.uniform1ui(m,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":p?i.uniform1iv(m,h):i.uniform1i(m,h);break;case"bool_vec2":case"int_vec2":i.uniform2iv(m,h);break;case"unsigned_int_vec2":i.uniform2uiv(m,h);break;case"float_vec2":i.uniform2fv(m,h);break;case"bool_vec3":case"int_vec3":i.uniform3iv(m,h);break;case"unsigned_int_vec3":i.uniform3uiv(m,h);break;case"float_vec3":i.uniform3fv(m,h);break;case"bool_vec4":case"int_vec4":i.uniform4iv(m,h);break;case"unsigned_int_vec4":i.uniform4uiv(m,h);break;case"float_vec4":i.uniform4fv(m,h);break;case"float_mat2":i.uniformMatrix2fv(m,!1,h);break;case"float_mat3":i.uniformMatrix3fv(m,!1,h);break;case"float_mat4":i.uniformMatrix4fv(m,!1,h);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={}}destroy(){super.destroy(),this.bind(null)}}function $l(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 io extends He{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,{pixelRatio:e,mask:t,viewport:i,screen:s,gl:o}=r,a=t.last.mask;let l;i.boundViewport?l=i.boundViewport.height-(a.height+a.y)*e:l=(s.height-(a.height+a.y))*e,o.scissor(a.x*e,l,a.width*e,a.height*e)}}class so extends He{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 Fl(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 no extends He{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=Fl(l,s);Object.assign(l,s);const c=this._renderer.getBindPoint(l.target??this.boundTarget);if(i!==void 0&&(i===null?a.texImage2D(c,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,null):"pixels"in i?a.texImage2D(c,0,a.RGBA,i.width,i.height,0,a.RGBA,a.UNSIGNED_BYTE,i.pixels):a.texImage2D(c,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i)),h.wrapMode&&l.wrapMode){const p=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,p),a.texParameteri(c,a.TEXTURE_WRAP_T,p)}const f=l.filterMode;if(h.filterMode&&f){const p=this._renderer.getBindPoint(f.split("_")[0]);f.includes("_")?a.texParameteri(c,a.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(f)):a.texParameteri(c,a.TEXTURE_MIN_FILTER,p),a.texParameteri(c,a.TEXTURE_MAG_FILTER,p)}if(l.anisoLevel&&f==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:p,TEXTURE_MAX_ANISOTROPY_EXT:m}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,m,Math.min(l.anisoLevel,a.getParameter(p)))}}bind(e){const t=this.gl;let i,s,o,a;if(e&&"value"in e?{target:s,value:i,location:o,forceUpdateLocation:a}=e:i=e,i){const g=this.getMeta(i);g.target=s??(s=g.target??"texture_2d"),g.location=o??(o=g.location??0)}else s??(s="texture_2d"),o??(o=0);let l=this.boundTextures[o];l||(this.boundTextures[o]=l={texture_2d:null,texture_cube_map:null});const h=l[s]??null,c=this.boundLocation,f=i!==h,p={location:o!==c&&(f||a),texture:f},m=this._renderer.getBindPoint(s);p.location&&(t.activeTexture(t.TEXTURE0+o),this.boundLocation=o),p.texture&&(t.bindTexture(m,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 oo extends He{constructor(){super(...arguments);u(this,"boundVertexArrayNull",{attributes:{},elementArrayBuffer:null});u(this,"boundVertexArrayObject",null);u(this,"boundVertexArray",this.boundVertexArrayNull)}install(e){super.install(e),e.vertexArray=this}enableVertexAttrib(e,t,i,s=1){const{buffer:o,size:a=0,type:l="float",normalized:h=!1,stride:c=0,offset:f=0,divisor:p}=i,m=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let g=0;g<s;g++)m.enableVertexAttribArray(t+g),m.vertexAttribPointer(t+g,a,this._renderer.getBindPoint(l),h,c,f+(c-f)/s*g);p&&("vertexAttribDivisor"in m?m.vertexAttribDivisor(t,p):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[e]={enable:!0,...i}}create(...e){const t=this._renderer.gl;if(!("createVertexArray"in t))return null;const i=t.createVertexArray();if(!i)throw new Error("Unable to create vertex array");return e.length===2?this.update(e[0],i,e[1]):e.length===1&&this.update(i,e[0]),i}getVertexArrayMeta(e){return this._renderer.getRelated(e,()=>({attributes:{},elementArrayBuffer:null}))}update(...e){var o,a,l;if(e.length>2){this._renderer.program.bind(e[0]),this.update(e[1],e[2]);return}else if(e.length===2)if(e[0]){const h=e[0],c=e[1],f=this.getVertexArrayMeta(h);this.bind(h),this.update(c),f.attributes=this.boundVertexArray.attributes,f.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(e[1]);const t=this._renderer.program.boundProgram;if(!t)return;const i=e[0];if(i.attributes){const h=this._renderer.program.getMeta(t),c={},f={};for(const m in i.attributes){const g=i.attributes[m],_=h.attributes.get(m);let y;"buffer"in g?y={...g}:y={buffer:g},y.size=y.size||(_==null?void 0:_.size)||0;const S=this._renderer.buffer.getMeta(y.buffer),T=Number(((o=_==null?void 0:_.type.match(/mat(\d)/))==null?void 0:o[1])??1);let P;switch(y.type){case"unsigned_byte":P=y.size;break;case"unsigned_short":P=y.size*2;break;case"float":default:P=y.size*4;break}P*=T,c[a=S.id]??(c[a]=0),c[S.id]+=P,f[m]={attrib:y,meta:S,info:_,byteLength:P,dimension:T}}const p={};for(const m in f){const{attrib:g,meta:_,info:y,byteLength:S,dimension:T}=f[m];(y==null?void 0:y.location)!==void 0&&(p[l=_.id]??(p[l]=0),g.offset??(g.offset=p[_.id]),g.stride??(g.stride=c[_.id]===S?0:c[_.id]),this.enableVertexAttrib(m,y.location,g,T),p[_.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 ao extends He{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 lo extends Yn{constructor(e=Sn(),t){super();u(this,"_modules",[new no,new Qn,new eo,new ro,new oo,new ao,new Kn,new to,new io,new so,new Jn]);u(this,"bindPoints",new Map);if(!e)throw new Error("Failed to createHTMLCanvas");Tn(e)?this._setupContext(e,t):(this.gl=e,this.version=En(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}}class Tt{}class ho extends Tt{install(r){const e=async t=>{const{parseFont:i}=await Promise.resolve().then(()=>_f);return await r.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s))};return this.load=t=>r.loadBy(t,()=>e(t)),["woff","ttf","otf"].forEach(t=>{r.register(t,e)}),r.font=this,this}}function zl(n,r,e=2){const t=r&&r.length,i=t?r[0]*e:n.length;let s=co(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(t&&(s=Wl(n,r,s,e)),n.length>80*e){a=1/0,l=1/0;let c=-1/0,f=-1/0;for(let p=e;p<i;p+=e){const m=n[p],g=n[p+1];m<a&&(a=m),g<l&&(l=g),m>c&&(c=m),g>f&&(f=g)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return xr(s,o,e,a,l,h,0),o}function co(n,r,e,t,i){let s;if(i===ih(n,r,e,t)>0)for(let o=r;o<e;o+=t)s=go(o/t|0,n[o],n[o+1],s);else for(let o=e-t;o>=r;o-=t)s=go(o/t|0,n[o],n[o+1],s);return s&&Jt(s,s.next)&&(Tr(s),s=s.next),s}function kt(n,r){if(!n)return n;r||(r=n);let e=n,t;do if(t=!1,!e.steiner&&(Jt(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 xr(n,r,e,t,i,s,o){if(!n)return;!o&&s&&Kl(n,t,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(s?jl(n,t,i,s):Vl(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=Gl(kt(n),r),xr(n,r,e,t,i,s,2)):o===2&&ql(n,r,e,t,i,s):xr(kt(n),r,e,t,i,s,1);break}}}function Vl(n){const r=n.prev,e=n,t=n.next;if(se(r,e,t)>=0)return!1;const i=r.x,s=e.x,o=t.x,a=r.y,l=e.y,h=t.y,c=Math.min(i,s,o),f=Math.min(a,l,h),p=Math.max(i,s,o),m=Math.max(a,l,h);let g=t.next;for(;g!==r;){if(g.x>=c&&g.x<=p&&g.y>=f&&g.y<=m&&Pr(i,a,s,l,o,h,g.x,g.y)&&se(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function jl(n,r,e,t){const i=n.prev,s=n,o=n.next;if(se(i,s,o)>=0)return!1;const a=i.x,l=s.x,h=o.x,c=i.y,f=s.y,p=o.y,m=Math.min(a,l,h),g=Math.min(c,f,p),_=Math.max(a,l,h),y=Math.max(c,f,p),S=gs(m,g,r,e,t),T=gs(_,y,r,e,t);let P=n.prevZ,E=n.nextZ;for(;P&&P.z>=S&&E&&E.z<=T;){if(P.x>=m&&P.x<=_&&P.y>=g&&P.y<=y&&P!==i&&P!==o&&Pr(a,c,l,f,h,p,P.x,P.y)&&se(P.prev,P,P.next)>=0||(P=P.prevZ,E.x>=m&&E.x<=_&&E.y>=g&&E.y<=y&&E!==i&&E!==o&&Pr(a,c,l,f,h,p,E.x,E.y)&&se(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;P&&P.z>=S;){if(P.x>=m&&P.x<=_&&P.y>=g&&P.y<=y&&P!==i&&P!==o&&Pr(a,c,l,f,h,p,P.x,P.y)&&se(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;E&&E.z<=T;){if(E.x>=m&&E.x<=_&&E.y>=g&&E.y<=y&&E!==i&&E!==o&&Pr(a,c,l,f,h,p,E.x,E.y)&&se(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function Gl(n,r){let e=n;do{const t=e.prev,i=e.next.next;!Jt(t,i)&&fo(t,e,e.next,i)&&Cr(t,i)&&Cr(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 kt(e)}function ql(n,r,e,t,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&eh(o,a)){let l=po(o,a);o=kt(o,o.next),l=kt(l,l.next),xr(o,r,e,t,i,s,0),xr(l,r,e,t,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function Wl(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=co(n,a,l,t,!1);h===h.next&&(h.steiner=!0),i.push(Ql(h))}i.sort(Xl);for(let s=0;s<i.length;s++)e=Hl(i[s],e);return e}function Xl(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 Hl(n,r){const e=Yl(n,r);if(!e)return r;const t=po(e,n);return kt(t,t.next),kt(e,e.next)}function Yl(n,r){let e=r;const t=n.x,i=n.y;let s=-1/0,o;if(Jt(n,e))return e;do{if(Jt(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&&uo(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);Cr(e,n)&&(f<c||f===c&&(e.x>o.x||e.x===o.x&&Zl(o,e)))&&(o=e,c=f)}e=e.next}while(e!==a);return o}function Zl(n,r){return se(n.prev,n,r.prev)<0&&se(r.next,n,n.next)<0}function Kl(n,r,e,t){let i=n;do i.z===0&&(i.z=gs(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,Jl(i)}function Jl(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 gs(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 Ql(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 uo(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 Pr(n,r,e,t,i,s,o,a){return!(n===o&&r===a)&&uo(n,r,e,t,i,s,o,a)}function eh(n,r){return n.next.i!==r.i&&n.prev.i!==r.i&&!th(n,r)&&(Cr(n,r)&&Cr(r,n)&&rh(n,r)&&(se(n.prev,n,r.prev)||se(n,r.prev,r))||Jt(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 Jt(n,r){return n.x===r.x&&n.y===r.y}function fo(n,r,e,t){const i=li(se(n,r,e)),s=li(se(n,r,t)),o=li(se(e,t,n)),a=li(se(e,t,r));return!!(i!==s&&o!==a||i===0&&ai(n,e,r)||s===0&&ai(n,t,r)||o===0&&ai(e,n,t)||a===0&&ai(e,r,t))}function ai(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 li(n){return n>0?1:n<0?-1:0}function th(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&&fo(e,e.next,n,r))return!0;e=e.next}while(e!==n);return!1}function Cr(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 rh(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 po(n,r){const e=ms(n.i,n.x,n.y),t=ms(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 go(n,r,e,t){const i=ms(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 ms(n,r,e){return{i:n,x:r,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ih(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 sh(n,r,e,t={}){const{radius:i=1}=t;n.moveTo(r,e),n.arc(r,e,i,0,Math.PI*2)}const nh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function ys(n,r){const{fill:e="#000",stroke:t="none",strokeWidth:i=t==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m="rgba(0, 0, 0, 0)"}=r;n.fillStyle=e,n.strokeStyle=t,n.lineWidth=i,n.lineCap=s,n.lineJoin=nh[o],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=c,n.shadowOffsetY=f,n.shadowBlur=p,n.shadowColor=m}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 Z{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 Z;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 Z(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 Z(this.left,this.top,this.width,this.height)}}class $e{constructor(r=1,e=0,t=0,i=0,s=1,o=0,a=0,l=0,h=1){u(this,"elements",[]);this.set(r,e,t,i,s,o,a,l,h)}set(r,e,t,i,s,o,a,l,h){const c=this.elements;return c[0]=r,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=l,c[6]=t,c[7]=o,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(r){const e=this.elements,t=r.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}multiply(r){return this.multiplyMatrices(this,r)}premultiply(r){return this.multiplyMatrices(r,this)}multiplyMatrices(r,e){const t=r.elements,i=e.elements,s=this.elements,o=t[0],a=t[3],l=t[6],h=t[1],c=t[4],f=t[7],p=t[2],m=t[5],g=t[8],_=i[0],y=i[3],S=i[6],T=i[1],P=i[4],E=i[7],w=i[2],v=i[5],x=i[8];return s[0]=o*_+a*T+l*w,s[3]=o*y+a*P+l*v,s[6]=o*S+a*E+l*x,s[1]=h*_+c*T+f*w,s[4]=h*y+c*P+f*v,s[7]=h*S+c*E+f*x,s[2]=p*_+m*T+g*w,s[5]=p*y+m*P+g*v,s[8]=p*S+m*E+g*x,this}invert(){const r=this.elements,e=r[0],t=r[1],i=r[2],s=r[3],o=r[4],a=r[5],l=r[6],h=r[7],c=r[8],f=c*o-a*h,p=a*l-c*s,m=h*s-o*l,g=e*f+t*p+i*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return r[0]=f*_,r[1]=(i*h-c*t)*_,r[2]=(a*t-i*o)*_,r[3]=p*_,r[4]=(c*e-i*l)*_,r[5]=(i*s-a*e)*_,r[6]=m*_,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(_s.makeScale(r,e)),this}rotate(r){return this.premultiply(_s.makeRotation(-r)),this}translate(r,e){return this.premultiply(_s.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 _s=new $e;function mo(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 oh(n,r,e,t,i,s,o,a){if(r===0||e===0){n.lineTo(a.x,a.y);return}t=t*Math.PI/180,r=Math.abs(r),e=Math.abs(e);const l=(o.x-a.x)/2,h=(o.y-a.y)/2,c=Math.cos(t)*l+Math.sin(t)*h,f=-Math.sin(t)*l+Math.cos(t)*h;let p=r*r,m=e*e;const g=c*c,_=f*f,y=g/p+_/m;if(y>1){const $=Math.sqrt(y);r=$*r,e=$*e,p=r*r,m=e*e}const S=p*_+m*g,T=(p*m-S)/S;let P=Math.sqrt(Math.max(0,T));i===s&&(P=-P);const E=P*r*f/e,w=-P*e*c/r,v=Math.cos(t)*E-Math.sin(t)*w+(o.x+a.x)/2,x=Math.sin(t)*E+Math.cos(t)*w+(o.y+a.y)/2,C=mo(1,0,(c-E)/r,(f-w)/e),D=mo((c-E)/r,(f-w)/e,(-c-E)/r,(-f-w)/e)%(Math.PI*2);n.ellipse(v,x,r,e,t,C,C+D,s===0)}const he={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function lt(n,r,e=0){let a=0,l=!0,h="",c="";const f=[];function p(y,S,T){const P=new SyntaxError(`Unexpected character "${y}" at index ${S}.`);throw P.partial=T,P}function m(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let g;const _=n.length;for(let y=0;y<_;y++){if(g=n[y],Array.isArray(r)&&r.includes(f.length%e)&&he.FLAGS.test(g)){a=1,h=g,m();continue}if(a===0){if(he.WHITESPACE.test(g))continue;if(he.DIGIT.test(g)||he.SIGN.test(g)){a=1,h=g;continue}if(he.POINT.test(g)){a=2,h=g;continue}he.COMMA.test(g)&&(l&&p(g,y,f),l=!0)}if(a===1){if(he.DIGIT.test(g)){h+=g;continue}if(he.POINT.test(g)){h+=g,a=2;continue}if(he.EXP.test(g)){a=3;continue}he.SIGN.test(g)&&h.length===1&&he.SIGN.test(h[0])&&p(g,y,f)}if(a===2){if(he.DIGIT.test(g)){h+=g;continue}if(he.EXP.test(g)){a=3;continue}he.POINT.test(g)&&h[h.length-1]==="."&&p(g,y,f)}if(a===3){if(he.DIGIT.test(g)){c+=g;continue}if(he.SIGN.test(g)){if(c===""){c+=g;continue}c.length===1&&he.SIGN.test(c)&&p(g,y,f)}}he.WHITESPACE.test(g)?(m(),a=0,l=!1):he.COMMA.test(g)?(m(),a=0,l=!0):he.SIGN.test(g)?(m(),a=1,h=g):he.POINT.test(g)?(m(),a=2,h=g):p(g,y,f)}return m(),f}function Qt(n,r){return n-(r-n)}function yo(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(Qt(e.x,t.x),Qt(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(Qt(e.x,t.x),Qt(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=Qt(e.x,t.x),l=Qt(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),oh(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 ah(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 lh=/[a-df-z][^a-df-z]*/gi;function _o(n){const r=[],e=n.match(lh);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=lt(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=lt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,x:l[h]});break;case"v":case"V":l=lt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,y:l[h]});break;case"l":case"L":l=lt(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=lt(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=lt(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=lt(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=lt(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=lt(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 vo(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 hh(n,r){const e=1-n;return e*e*e*r}function ch(n,r){const e=1-n;return 3*e*e*n*r}function uh(n,r){return 3*(1-n)*n*n*r}function fh(n,r){return n*n*n*r}function bo(n,r,e,t,i){return hh(n,r)+ch(n,e)+uh(n,t)+fh(n,i)}function dh(n,r={}){let{vertices:e=[],indices:t=[],holes:i=[],verticesStride:s=2,verticesOffset:o=0,indicesOffset:a=0}=r;const l=zl(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 ph=8,hi=11920929e-14,gh=1;function mh(n,r,e,t,i,s,o,a,l=.5,h){const f=Math.min(.99,Math.max(0,l));let p=(gh-f)/1;return p*=p,vs(n,r,e,t,i,s,o,a,h,p,0),h.push(o,a),h}function vs(n,r,e,t,i,s,o,a,l,h,c){if(c>ph)return;const f=(n+e)/2,p=(r+t)/2,m=(e+i)/2,g=(t+s)/2,_=(i+o)/2,y=(s+a)/2,S=(f+m)/2,T=(p+g)/2,P=(m+_)/2,E=(g+y)/2,w=(S+P)/2,v=(T+E)/2;if(c>0){let x=o-n,C=a-r;const D=Math.abs((e-o)*C-(t-a)*x),$=Math.abs((i-o)*C-(s-a)*x);if(D>hi&&$>hi){if((D+$)*(D+$)<=h*(x*x+C*C)){l.push(w,v);return}}else if(D>hi){if(D*D<=h*(x*x+C*C)){l.push(w,v);return}}else if($>hi){if($*$<=h*(x*x+C*C)){l.push(w,v);return}}else if(x=w-(n+o)/2,C=v-(r+a)/2,x*x+C*C<=h){l.push(w,v);return}}vs(n,r,f,p,S,T,w,v,l,h,c+1),vs(w,v,P,E,_,y,o,a,l,h,c+1)}const yh=8,_h=11920929e-14,vh=1;function bh(n,r,e,t,i,s,o=.5,a){const h=Math.min(.99,Math.max(0,o));let c=(vh-h)/1;return c*=c,bs(a,n,r,e,t,i,s,c,0),a.push(i,s),a}function bs(n,r,e,t,i,s,o,a,l){if(l>yh)return;const h=(r+t)/2,c=(e+i)/2,f=(t+s)/2,p=(i+o)/2,m=(h+f)/2,g=(c+p)/2;let _=s-r,y=o-e;const S=Math.abs((t-s)*y-(i-o)*_);if(S>_h){if(S*S<=a*(_*_+y*y)){n.push(m,g);return}}else if(_=m-(r+s)/2,y=g-(e+o)/2,_*_+y*y<=a){n.push(m,g);return}bs(n,r,e,h,c,m,g,a,l+1),bs(n,m,g,f,p,s,o,a,l+1)}function wh(n,r){const e=1-n;return e*e*r}function xh(n,r){return 2*(1-n)*n*r}function Ph(n,r){return n*n*r}function wo(n,r,e,t){return wh(n,r)+xh(n,e)+Ph(n,t)}const Ch=1e-4,xo=1e-4;function Th(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=Ch;if(n.length===0)return{vertices:e,indices:t};const l=i;let h=l.alignment;if(i.alignment!==.5){let k=Eh(n);s&&(k*=-1),h=(h-.5)*k+.5}const c={x:n[0],y:n[1]},f={x:n[n.length-2],y:n[n.length-1]},p=o,m=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(p){n=n.slice(),m&&(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 g=e,_=n.length/2;let y=n.length;const S=g.length/2,T=l.width/2,P=T*T,E=l.miterLimit*l.miterLimit;let w=n[0],v=n[1],x=n[2],C=n[3],D=0,$=0,B=-(v-C),U=w-x,V=0,A=0,N=Math.sqrt(B*B+U*U);B/=N,U/=N,B*=T,U*=T;const W=h,R=(1-W)*2,I=W*2;p||(l.cap==="round"?y+=Nt(w-B*(R-I)*.5,v-U*(R-I)*.5,w-B*R,v-U*R,w+B*I,v+U*I,g,!0)+2:l.cap==="square"&&(y+=Po(w,v,B,U,R,I,!0,g))),g.push(w-B*R,v-U*R),g.push(w+B*I,v+U*I);for(let k=1;k<_-1;++k){w=n[(k-1)*2],v=n[(k-1)*2+1],x=n[k*2],C=n[k*2+1],D=n[(k+1)*2],$=n[(k+1)*2+1],B=-(v-C),U=w-x,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=T,U*=T,V=-(C-$),A=x-D,N=Math.sqrt(V*V+A*A),V/=N,A/=N,V*=T,A*=T;const L=x-w,K=v-C,H=x-D,X=$-C,G=L*H+K*X,ee=K*H-X*L,Y=ee<0;if(Math.abs(ee)<.001*Math.abs(G)){g.push(x-B*R,C-U*R),g.push(x+B*I,C+U*I),G>=0&&(l.join==="round"?y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+4:y+=2,g.push(x-V*I,C-A*I),g.push(x+V*R,C+A*R));continue}const ae=(-B+w)*(-U+C)-(-B+x)*(-U+v),pt=(-V+D)*(-A+C)-(-V+x)*(-A+$),Ke=(L*pt-H*ae)/ee,Ne=(X*ae-K*pt)/ee,ze=(Ke-x)*(Ke-x)+(Ne-C)*(Ne-C),Se=x+(Ke-x)*R,Ve=C+(Ne-C)*R,it=x-(Ke-x)*I,st=C-(Ne-C)*I,Je=Math.min(L*L+K*K,H*H+X*X),cl=Y?R:I,Ap=Je+cl*cl*P;ze<=Ap?l.join==="bevel"||ze/P>E?(Y?(g.push(Se,Ve),g.push(x+B*I,C+U*I),g.push(Se,Ve),g.push(x+V*I,C+A*I)):(g.push(x-B*R,C-U*R),g.push(it,st),g.push(x-V*R,C-A*R),g.push(it,st)),y+=2):l.join==="round"?Y?(g.push(Se,Ve),g.push(x+B*I,C+U*I),y+=Nt(x,C,x+B*I,C+U*I,x+V*I,C+A*I,g,!0)+4,g.push(Se,Ve),g.push(x+V*I,C+A*I)):(g.push(x-B*R,C-U*R),g.push(it,st),y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+4,g.push(x-V*R,C-A*R),g.push(it,st)):(g.push(Se,Ve),g.push(it,st)):(g.push(x-B*R,C-U*R),g.push(x+B*I,C+U*I),l.join==="round"?Y?y+=Nt(x,C,x+B*I,C+U*I,x+V*I,C+A*I,g,!0)+2:y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+2:l.join==="miter"&&ze/P<=E&&(Y?(g.push(it,st),g.push(it,st)):(g.push(Se,Ve),g.push(Se,Ve)),y+=2),g.push(x-V*R,C-A*R),g.push(x+V*I,C+A*I),y+=2)}w=n[(_-2)*2],v=n[(_-2)*2+1],x=n[(_-1)*2],C=n[(_-1)*2+1],B=-(v-C),U=w-x,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=T,U*=T,g.push(x-B*R,C-U*R),g.push(x+B*I,C+U*I),p||(l.cap==="round"?y+=Nt(x-B*(R-I)*.5,C-U*(R-I)*.5,x-B*R,C-U*R,x+B*I,C+U*I,g,!1)+2:l.cap==="square"&&(y+=Po(x,C,B,U,R,I,!1,g)));const j=xo*xo;for(let k=S;k<y+S-2;++k)w=g[k*2],v=g[k*2+1],x=g[(k+1)*2],C=g[(k+1)*2+1],D=g[(k+2)*2],$=g[(k+2)*2+1],!(Math.abs(w*(C-$)+x*($-v)+D*(v-C))<j)&&t.push(k,k+1,k+2);return{vertices:e,indices:t}}function Eh(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 Po(n,r,e,t,i,s,o,a){const l=n-e*i,h=r-t*i,c=n+e*s,f=r+t*s;let p,m;o?(p=t,m=-e):(p=-t,m=e);const g=l+p,_=h+m,y=c+p,S=f+m;return a.push(g,_),a.push(y,S),2}function Nt(n,r,e,t,i,s,o,a){const l=e-n,h=t-r;let c=Math.atan2(l,h),f=Math.atan2(i-n,s-r);a&&c<f?c+=Math.PI*2:!a&&c>f&&(f+=Math.PI*2);let p=c;const m=f-c,g=Math.abs(m),_=Math.sqrt(l*l+h*h),y=(15*g*Math.sqrt(_)/Math.PI>>0)+1,S=m/y;if(p+=S,a){o.push(n,r),o.push(e,t);for(let T=1,P=p;T<y;T++,P+=S)o.push(n,r),o.push(n+Math.sin(P)*_,r+Math.cos(P)*_);o.push(n,r),o.push(i,s)}else{o.push(e,t),o.push(n,r);for(let T=1,P=p;T<y;T++,P+=S)o.push(n+Math.sin(P)*_,r+Math.cos(P)*_),o.push(n,r);o.push(i,s),o.push(n,r)}return y*2}class er{constructor(){u(this,"arcLengthDivision",200);u(this,"_arcLengths")}getPointAt(r,e=new O){return this.getPoint(this.getUToTMapping(r),e)}isClockwise(){const r=this.getPoint(1),e=this.getPoint(.5),t=this.getPoint(1);return(e.x-r.x)*(t.y-e.y)-(e.y-r.y)*(t.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(r){return this.getControlPointRefs().forEach(e=>{e.applyMatrix3(r)}),this}getUnevenPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPoint(i/s,t),e.push(t.x,t.y);return e}getSpacedPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPointAt(i/s,t),e.push(t.x,t.y);return e}getAdaptivePointArray(r=[]){return this.getUnevenPointArray(5,r)}_pointArrayToPoint(r,e=[]){for(let t=0,i=r.length;t<i;t+=2){const s=r[t],o=r[t+1];e.push(new O(s,o))}return e}getSpacedPoints(r,e=[]){const t=this.getSpacedPointArray(r);return this._pointArrayToPoint(t,e),e}getUnevenPoints(r,e=[]){const t=this.getUnevenPointArray(r);return this._pointArrayToPoint(t,e),e}getAdaptivePoints(r=[]){const e=this.getAdaptivePointArray();return this._pointArrayToPoint(e,r),r}getPoints(r,e=[]){let t;return r?t=this.getUnevenPointArray(r):t=this.getAdaptivePointArray(),this._pointArrayToPoint(t,e),e}getLength(){const r=this.getLengths();return r[r.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const r=this.arcLengthDivision,e=[0];for(let t=0,i=this.getPoint(0),s=1;s<=r;s++){const o=this.getPoint(s/r);t+=o.distanceTo(i),e.push(t),i=o}this._arcLengths=e}getUToTMapping(r,e){const t=this.getLengths(),i=t.length,s=e??r*t[i-1];if(i<2)return s/t[0];let o=0,a=0,l=i-1,h;for(;a<=l;)if(o=Math.floor(a+(l-a)/2),h=t[o]-s,h<0)a=o+1;else if(h>0)l=o-1;else{l=o;break}if(o=l,t[o]===s)return o/(i-1);const c=t[o],p=t[o+1]-c,m=(s-c)/p;return(o+m)/(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 Z(r.x,r.y,e.x-r.x,e.y-r.y)}fillTriangulate(r){return dh(this.getAdaptivePointArray(),r)}strokeTriangulate(r){return Th(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 ah(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 Sh=new $e,Co=new $e,To=new $e,ci=new O;class ws extends er{constructor(r=new O,e=new O,t=new O,i=0,s=0,o=Math.PI*2,a=!1){super(),this._center=r,this._radius=e,this._diff=t,this.rotate=i,this.startAngle=s,this.endAngle=o,this.clockwise=a}get cx(){return this._center.x}set cx(r){this._center.x=r}get cy(){return this._center.y}set cy(r){this._center.y=r}get rx(){return this._radius.x}set rx(r){this._radius.x=r}get ry(){return this._radius.y}set ry(r){this._radius.y=r}get dx(){return this._diff.x}set dx(r){this._diff.x=r}get dy(){return this._diff.y}set dy(r){this._diff.y=r}isClockwise(){return this.clockwise}getPoint(r,e=new O){const t=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=t;for(;i>t;)i-=t;i<Number.EPSILON&&(s?i=0:i=t),this.clockwise&&!s&&(i===t?i=-t:i=i-t);const o=this.startAngle+r*i;let a=this.cx+this.rx*Math.cos(o),l=this.cy+this.ry*Math.sin(o);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),f=a-this.cx,p=l-this.cy;a=f*h-p*c+this.cx,l=f*c+p*h+this.cy}return e.set(a,l)}toCommands(){const{cx:r,cy:e,rx:t,ry:i,startAngle:s,endAngle:o,clockwise:a,rotate:l}=this,h=r+t*Math.cos(s)*Math.cos(l)-i*Math.sin(s)*Math.sin(l),c=e+t*Math.cos(s)*Math.sin(l)+i*Math.sin(s)*Math.cos(l),f=Math.abs(s-o),p=f>Math.PI?1:0,m=a?1:0,g=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:g,largeArcFlag:0,sweepFlag:m,x:y,y:S},{type:"A",rx:t,ry:i,angle:g,largeArcFlag:0,sweepFlag:m,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:g,largeArcFlag:p,sweepFlag:m,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 ci.set(this.cx,this.cy),ci.applyMatrix3(r),this.cx=ci.x,this.cy=ci.y,Oh(r)?Mh(this,r):Ah(this,r),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,ry:s,dx:o,dy:a}=this;if(!(i>=0&&s>=0&&o>=0&&a>=0))return r;const l=Math.ceil(2.3*Math.sqrt(i+s)),h=l*8+(o?4:0)+(a?4:0);if(h===0)return r;const c=[];if(l===0)c[0]=c[6]=e+o,c[1]=c[3]=t+a,c[2]=c[4]=e-o,c[5]=c[7]=t-a;else{let f=0,p=l*4+(o?2:0)+2,m=p,g=h,_=o+i,y=a,S=e+_,T=e-_,P=t+y;if(c[f++]=S,c[f++]=P,c[--p]=P,c[--p]=T,a){const w=t-y;c[m++]=T,c[m++]=w,c[--g]=w,c[--g]=S}for(let w=1;w<l;w++){const v=Math.PI/2*(w/l),x=o+Math.cos(v)*i,C=a+Math.sin(v)*s,D=e+x,$=e-x,B=t+C,U=t-C;c[f++]=D,c[f++]=B,c[--p]=B,c[--p]=$,c[m++]=$,c[m++]=U,c[--g]=U,c[--g]=D}_=o,y=a+s,S=e+_,T=e-_,P=t+y;const E=t-y;c[f++]=S,c[f++]=P,c[--g]=E,c[--g]=S,o&&(c[f++]=T,c[f++]=P,c[--g]=E,c[--g]=T)}return Array.prototype.push.apply(r,c),r}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const a=this.getAdaptivePointArray();if(a.length===0)return{vertices:e,indices:t};let l=0,h=0;for(let p=0;p<a.length;p+=2)l+=a[p],h+=a[p+1];l/=a.length/2,h/=a.length/2;let c=s;e[c*i]=l,e[c*i+1]=h;const f=c++;for(let p=0;p<a.length;p+=2)e[c*i]=a[p],e[c*i+1]=a[p+1],p>0&&(t[o++]=c,t[o++]=f,t[o++]=c-1),c++;return t[o++]=f+1,t[o++]=f,t[o++]=c-1,{vertices:e,indices:t}}getMinMax(r=O.MAX,e=O.MIN){const{cx:t,cy:i,rx:s,ry:o,rotate:a}=this,l=Math.cos(a),h=Math.sin(a),c=Math.sqrt(s*s*l*l+o*o*h*h),f=Math.sqrt(s*s*h*h+o*o*l*l);return r.x=Math.min(r.x,t-c),r.y=Math.min(r.y,i-f),e.x=Math.max(e.x,t+c),e.y=Math.max(e.y,i+f),{min:r,max:e}}copy(r){return super.copy(r),this.cx=r.cx,this.cy=r.cy,this.rx=r.rx,this.ry=r.ry,this.dx=r.dx,this.dy=r.dy,this.startAngle=r.startAngle,this.endAngle=r.endAngle,this.clockwise=r.clockwise,this.rotate=r.rotate,this}}function Mh(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=Sh.set(l.x,h.x,0,l.y,h.y,0,0,0,1),f=Co.copy(c).invert(),g=To.copy(f).transpose().multiply(f).elements,_=Uh(g[0],g[1],g[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 P=Co.set(y,0,0,0,S,0,0,0,1),E=To.set(_.cs,_.sn,0,-_.sn,_.cs,0,0,0,1),w=P.multiply(E).multiply(c),v=x=>{const{x:C,y:D}=new O(Math.cos(x),Math.sin(x)).applyMatrix3(w);return Math.atan2(D,C)};n.startAngle=v(n.startAngle),n.endAngle=v(n.endAngle),Eo(r)&&(n.clockwise=!n.clockwise)}}function Ah(n,r){const e=So(r),t=Mo(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,Eo(r)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function Eo(n){const r=n.elements;return r[0]*r[4]-r[1]*r[3]<0}function Oh(n){const r=n.elements,e=r[0]*r[3]+r[1]*r[4];if(e===0)return!1;const t=So(n),i=Mo(n);return Math.abs(e/(t*i))>Number.EPSILON}function So(n){const r=n.elements;return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function Mo(n){const r=n.elements;return Math.sqrt(r[3]*r[3]+r[4]*r[4])}function Uh(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 Dh extends ws{constructor(r=0,e=0,t=1,i=0,s=Math.PI*2,o=!1){super(new O(r,e),new O(t,t),new O(0,0),0,i,s,o)}drawTo(r){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;return r.arc(e,t,i,s,o,!a),this}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;let l=Math.abs(s-o);(!a&&s>o||a&&o>s)&&(l=2*Math.PI-l);let h=Math.max(6,Math.floor(6*i**(1/3)*(l/Math.PI)));h=Math.max(h,3);let c=l/h,f=s;c*=a?1:-1;for(let p=0;p<h+1;p++){const m=Math.cos(f),g=Math.sin(f),_=e+m*i,y=t+g*i;r.push(_,y),f+=c}return r}}class Er extends er{constructor(r=[]){super(),this.curves=r}getFlatCurves(){return this.curves.flatMap(r=>r instanceof Er?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 Z(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 xs extends er{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 xs(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(bo(r,t.x,i.x,s.x,o.x),bo(r,t.y,i.y,s.y,o.y))}getAdaptivePointArray(r=[]){return mh(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,r)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(r,e,t){const i=e*e-4*r*t;if(i<0)return[];const s=Math.sqrt(i),o=(-e+s)/(2*r),a=(-e-s)/(2*r);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(r=O.MAX,e=O.MIN){const{p1:t,cp1:i,cp2:s,p2:o}=this,a=this._solveQuadratic(3*(i.x-t.x),6*(s.x-i.x),3*(o.x-s.x)),l=this._solveQuadratic(3*(i.y-t.y),6*(s.y-i.y),3*(o.y-s.y)),h=[0,1,...a,...l];return((f,p)=>{for(const m of f)for(let g=0;g<=p;g++){const _=g/p-.5,y=Math.min(1,Math.max(0,m+_)),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 Ih extends ws{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 Et extends er{constructor(r=new O,e=new O){super(),this.p1=r,this.p2=e}static from(r,e,t,i){return new Et(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 Rh extends Er{}class Ps extends er{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 Ps(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(wo(r,t.x,i.x,s.x),wo(r,t.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(r=[]){return bh(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 Bh extends Rh{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 Et(s[0],s[1]),new Et(s[1],s[2]),new Et(s[2],s[3]),new Et(s[3],s[0])],this}drawTo(r){return r.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const{x:a,y:l,width:h,height:c}=this,f=[a,l,a+h,l,a+h,l+c,a,l+c];let p=0;s*=i,e[s+p]=f[0],e[s+p+1]=f[1],p+=i,e[s+p]=f[2],e[s+p+1]=f[3],p+=i,e[s+p]=f[6],e[s+p+1]=f[7],p+=i,e[s+p]=f[4],e[s+p+1]=f[5],p+=i;const m=s/i;return t[o++]=m,t[o++]=m+1,t[o++]=m+2,t[o++]=m+1,t[o++]=m+3,t[o++]=m+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 Lh extends ws{constructor(r=0,e=0,t=1,i=1,s=1){super(),this.x=r,this.y=e,this.width=t,this.height=i,this.radius=s,this.update()}update(){const{x:r,y:e,width:t,height:i,radius:s}=this,o=t/2,a=i/2,l=r+o,h=e+a,c=Math.max(0,Math.min(s,Math.min(o,a))),f=c,p=o-c,m=a-f;return this._center=new O(l,h),this._radius=new O(c,f),this._diff=new O(p,m),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 kh extends er{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(vo(o,a.x,l.x,h.x,c.x),vo(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 tr extends Er{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 yo(e,this),this}addData(e){return this.addCommands(_o(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 Et(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(Et.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(xs.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(Ps.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 Dh(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 Ih(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 Bh(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 Lh(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 kh([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 Nh(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function $h(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 Pe extends Er{constructor(e,t={}){super();u(this,"currentCurve",new tr);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof Pe?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 Pe?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 tr().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 tr,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 tr,this.curves.push(this.currentCurve),this.style={},this}addCommands(e){return yo(e,this),this}addData(e){return this.addCommands(_o(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 p=c[0],m=c[c.length-1]??p;i.push({start:f?m:p,end:f?p:m,index:h})});const a=[];return i.forEach((l,h)=>{a[h]=[],i.forEach((c,f)=>{var p;c.start&&l.end&&f!==h&&((p=c.start)!=null&&p.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 p=o[f],m=$h(c[c.length-1],c[c.length-2]??c[c.length-1],p[0],p[1]??p[0]);m&&(c[c.length-1].copy(m),p[0].copy(m))})}),this}getMinMax(e=O.MAX,t=O.MIN,i=!0){const s=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(e,t),i&&s>1){const a=s/2,l=o.isClockwise(),h=[];for(let c=0;c<=1;c+=1/o.arcLengthDivision){const f=o.getPoint(c),p=o.getNormal(c),m=p.clone().scale(l?a:-a),g=p.clone().scale(l?-a:a);h.push(f.clone().add(m),f.clone().add(g),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 Z(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(),ys(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(),ys(e,t),this.getControlPointRefs().forEach(o=>{sh(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[Nh(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 Cs{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 Z(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 Ao="data:image/svg+xml;",Oo=`${Ao}base64,`,Uo=`${Ao}charset=utf8,`;function Do(n){if(typeof n=="string"){let r;n.startsWith(Oo)?(n=n.substring(Oo.length,n.length),r=atob(n)):n.startsWith(Uo)?(n=n.substring(Uo.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"}
61
- ${r}`);return e.documentElement}else return n}const Fh="px",zh=90,Io=["mm","cm","in","pt","pc","px"],Ro={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 Q(n){let r="px";if(typeof n=="string"||n instanceof String)for(let t=0,i=Io.length;t<i;t++){const s=Io[t];if(n.endsWith(s)){r=s,n=n.substring(0,n.length-s.length);break}}let e;return e=Ro[r][Fh],e<0&&(e=Ro[r].in*zh),e*Number.parseFloat(n)}const Vh=new $e,ui=new $e,Bo=new $e,Lo=new $e;function jh(n,r,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const t=Gh(n);return e.length>0&&t.premultiply(e[e.length-1]),r.copy(t),e.push(t),t}function Gh(n){const r=new $e,e=Vh;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&r.translate(Q(n.getAttribute("x")),Q(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=lt(s.slice(o+1));switch(e.identity(),l){case"translate":if(h.length>=1){const c=h[0];let f=0;h.length>=2&&(f=h[1]),e.translate(c,f)}break;case"rotate":if(h.length>=1){let c=0,f=0,p=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],p=h[2]),ui.makeTranslation(-f,-p),Bo.makeRotation(c),Lo.multiplyMatrices(Bo,ui),ui.makeTranslation(f,p),e.multiplyMatrices(ui,Lo)}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 qh(n){return new Pe().arc(Q(n.getAttribute("cx")||0),Q(n.getAttribute("cy")||0),Q(n.getAttribute("r")||0),0,Math.PI*2)}function Wh(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 Xh(n){return new Pe().ellipse(Q(n.getAttribute("cx")||0),Q(n.getAttribute("cy")||0),Q(n.getAttribute("rx")||0),Q(n.getAttribute("ry")||0),0,0,Math.PI*2)}function Hh(n){return new Pe().moveTo(Q(n.getAttribute("x1")||0),Q(n.getAttribute("y1")||0)).lineTo(Q(n.getAttribute("x2")||0),Q(n.getAttribute("y2")||0))}function Yh(n){const r=new Pe,e=n.getAttribute("d");return!e||e==="none"?null:(r.addData(e),r)}const Zh=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Kh(n){var t;const r=new Pe;let e=0;return(t=n.getAttribute("points"))==null||t.replace(Zh,(i,s,o)=>{const a=Q(s),l=Q(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!0,r}const Jh=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Qh(n){var t;const r=new Pe;let e=0;return(t=n.getAttribute("points"))==null||t.replace(Jh,(i,s,o)=>{const a=Q(s),l=Q(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!1,r}function ec(n){const r=Q(n.getAttribute("x")||0),e=Q(n.getAttribute("y")||0),t=Q(n.getAttribute("rx")||n.getAttribute("ry")||0),i=Q(n.getAttribute("ry")||n.getAttribute("rx")||0),s=Q(n.getAttribute("width")),o=Q(n.getAttribute("height")),a=1-.551915024494,l=new Pe;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 ht(n,r,e){r=Object.assign({},r);let t={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)t=Object.assign(t,e[`.${h[c]}`])}n.hasAttribute("id")&&(t=Object.assign(t,e[`#${n.getAttribute("id")}`]));for(let h=n.style.length,c=0;c<h;c++){const f=n.style.item(c),p=n.style.getPropertyValue(f);r[f]=p,t[f]=p}function i(h,c,f=s){n.hasAttribute(h)&&(r[c]=f(n.getAttribute(h))),t[h]&&(r[c]=f(t[h]))}function s(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function o(h){return Math.max(0,Math.min(1,Q(h)))}function a(h){return Math.max(0,Q(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>Q(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",Q),i("visibility","visibility"),r}function Ts(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=ht(n,o,t);break;case"style":Wh(n,t);break;case"g":o=ht(n,o,t);break;case"path":o=ht(n,o,t),n.hasAttribute("d")&&(s=Yh(n));break;case"rect":o=ht(n,o,t),s=ec(n);break;case"polygon":o=ht(n,o,t),s=Kh(n);break;case"polyline":o=ht(n,o,t),s=Qh(n);break;case"circle":o=ht(n,o,t),s=qh(n);break;case"ellipse":o=ht(n,o,t),s=Xh(n);break;case"line":o=ht(n,o,t),s=Hh(n);break;case"defs":i=!0;break;case"use":{o=ht(n,o,t);const m=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),g=(f=n.viewportElement)==null?void 0:f.getElementById(m);g?Ts(g,o,e,t):console.warn(`'use node' references non-existent node id: ${m}`);break}default:console.warn(n);break}if(o.display==="none")return e;Object.assign(r,o);const a=new $e,l=[],h=jh(n,a,l);s&&(s.applyTransform(a),e.push(s),s.style=r);const c=n.childNodes;for(let p=0,m=c.length;p<m;p++){const g=c[p];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||Ts(g,r,e,t)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),e}function ko(n){return new Cs(Ts(Do(n),{}))}class fi extends yt{constructor(e={}){super();u(this,"vertexAttributes");u(this,"indexBuffer");u(this,"instanceCount");u(this,"mode");u(this,"_materialWeakMap",new Zt);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 tc=Object.defineProperty,No=(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&&tc(r,e,i),i};class rr extends yt{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()))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}No([ue({default:null})],rr.prototype,"data"),No([ue({default:!1})],rr.prototype,"dynamic");var rc=Object.defineProperty,$o=(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&&rc(r,e,i),i};class vt extends yt{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()))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}$o([ue({default:null})],vt.prototype,"data"),$o([ue({default:!1})],vt.prototype,"dynamic");var ic=Object.defineProperty,$t=(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&&ic(r,e,i),i};class je extends yt{constructor(e){super();u(this,"stride");u(this,"offset");u(this,"divisor");u(this,"needsUpload",!1);this.setProperties({buffer:new vt,...e})}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}$t([ue()],je.prototype,"buffer"),$t([ue({default:0})],je.prototype,"size"),$t([ue({default:!1})],je.prototype,"normalized"),$t([ue({default:"float"})],je.prototype,"type"),$t([ue()],je.prototype,"stride"),$t([ue()],je.prototype,"offset"),$t([ue()],je.prototype,"divisor");class sc extends fi{constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const qi=class qi extends yt{constructor(e={}){super();u(this,"vert");u(this,"frag");u(this,"uniforms");this.vert=e.vert??`precision highp float;
60
+ ${i.getShaderInfoLog(s)}`);return s}updateUniforms(...e){if(e.length>1){this.bind(e[0]),this.updateUniforms(e[1]);return}const t=this.boundProgram;if(!t)return;const i=this.gl,s=e[0],{uniforms:o,boundUniforms:a}=this.getMeta(t);for(const l in s){const h=s[l],c=o.get(l);if(!c)continue;const{type:f,isArray:p,location:m}=c;if(!(!m||a.get(m)===h))switch(a.set(m,h),f){case"float":p?i.uniform1fv(m,h):i.uniform1f(m,h);break;case"unsigned_int":p?i.uniform1uiv(m,h):i.uniform1ui(m,h);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":p?i.uniform1iv(m,h):i.uniform1i(m,h);break;case"bool_vec2":case"int_vec2":i.uniform2iv(m,h);break;case"unsigned_int_vec2":i.uniform2uiv(m,h);break;case"float_vec2":i.uniform2fv(m,h);break;case"bool_vec3":case"int_vec3":i.uniform3iv(m,h);break;case"unsigned_int_vec3":i.uniform3uiv(m,h);break;case"float_vec3":i.uniform3fv(m,h);break;case"bool_vec4":case"int_vec4":i.uniform4iv(m,h);break;case"unsigned_int_vec4":i.uniform4uiv(m,h);break;case"float_vec4":i.uniform4fv(m,h);break;case"float_mat2":i.uniformMatrix2fv(m,!1,h);break;case"float_mat3":i.uniformMatrix3fv(m,!1,h);break;case"float_mat4":i.uniformMatrix4fv(m,!1,h);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={}}destroy(){super.destroy(),this.bind(null)}}function Fl(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 io extends He{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,{pixelRatio:e,mask:t,viewport:i,screen:s,gl:o}=r,a=t.last.mask;let l;i.boundViewport?l=i.boundViewport.height-(a.height+a.y)*e:l=(s.height-(a.height+a.y))*e,o.scissor(a.x*e,l,a.width*e,a.height*e)}}class so extends He{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 $l(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 no extends He{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=$l(l,s);Object.assign(l,s);const c=this._renderer.getBindPoint(l.target??this.boundTarget);if(i!==void 0&&(i===null?a.texImage2D(c,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,null):"pixels"in i?a.texImage2D(c,0,a.RGBA,i.width,i.height,0,a.RGBA,a.UNSIGNED_BYTE,i.pixels):a.texImage2D(c,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,i)),h.wrapMode&&l.wrapMode){const p=this._renderer.getBindPoint(l.wrapMode);a.texParameteri(c,a.TEXTURE_WRAP_S,p),a.texParameteri(c,a.TEXTURE_WRAP_T,p)}const f=l.filterMode;if(h.filterMode&&f){const p=this._renderer.getBindPoint(f.split("_")[0]);f.includes("_")?a.texParameteri(c,a.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(f)):a.texParameteri(c,a.TEXTURE_MIN_FILTER,p),a.texParameteri(c,a.TEXTURE_MAG_FILTER,p)}if(l.anisoLevel&&f==="linear"&&this._renderer.extensions.anisotropicFiltering&&h.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:p,TEXTURE_MAX_ANISOTROPY_EXT:m}=this._renderer.extensions.anisotropicFiltering;a.texParameterf(c,m,Math.min(l.anisoLevel,a.getParameter(p)))}}bind(e){const t=this.gl;let i,s,o,a;if(e&&"value"in e?{target:s,value:i,location:o,forceUpdateLocation:a}=e:i=e,i){const g=this.getMeta(i);g.target=s??(s=g.target??"texture_2d"),g.location=o??(o=g.location??0)}else s??(s="texture_2d"),o??(o=0);let l=this.boundTextures[o];l||(this.boundTextures[o]=l={texture_2d:null,texture_cube_map:null});const h=l[s]??null,c=this.boundLocation,f=i!==h,p={location:o!==c&&(f||a),texture:f},m=this._renderer.getBindPoint(s);p.location&&(t.activeTexture(t.TEXTURE0+o),this.boundLocation=o),p.texture&&(t.bindTexture(m,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 oo extends He{constructor(){super(...arguments);u(this,"boundVertexArrayNull",{attributes:{},elementArrayBuffer:null});u(this,"boundVertexArrayObject",null);u(this,"boundVertexArray",this.boundVertexArrayNull)}install(e){super.install(e),e.vertexArray=this}enableVertexAttrib(e,t,i,s=1){const{buffer:o,size:a=0,type:l="float",normalized:h=!1,stride:c=0,offset:f=0,divisor:p}=i,m=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:o});for(let g=0;g<s;g++)m.enableVertexAttribArray(t+g),m.vertexAttribPointer(t+g,a,this._renderer.getBindPoint(l),h,c,f+(c-f)/s*g);p&&("vertexAttribDivisor"in m?m.vertexAttribDivisor(t,p):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[e]={enable:!0,...i}}create(...e){const t=this._renderer.gl;if(!("createVertexArray"in t))return null;const i=t.createVertexArray();if(!i)throw new Error("Unable to create vertex array");return e.length===2?this.update(e[0],i,e[1]):e.length===1&&this.update(i,e[0]),i}getVertexArrayMeta(e){return this._renderer.getRelated(e,()=>({attributes:{},elementArrayBuffer:null}))}update(...e){var o,a,l;if(e.length>2){this._renderer.program.bind(e[0]),this.update(e[1],e[2]);return}else if(e.length===2)if(e[0]){const h=e[0],c=e[1],f=this.getVertexArrayMeta(h);this.bind(h),this.update(c),f.attributes=this.boundVertexArray.attributes,f.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(e[1]);const t=this._renderer.program.boundProgram;if(!t)return;const i=e[0];if(i.attributes){const h=this._renderer.program.getMeta(t),c={},f={};for(const m in i.attributes){const g=i.attributes[m],_=h.attributes.get(m);let y;"buffer"in g?y={...g}:y={buffer:g},y.size=y.size||(_==null?void 0:_.size)||0;const E=this._renderer.buffer.getMeta(y.buffer),T=Number(((o=_==null?void 0:_.type.match(/mat(\d)/))==null?void 0:o[1])??1);let P;switch(y.type){case"unsigned_byte":P=y.size;break;case"unsigned_short":P=y.size*2;break;case"float":default:P=y.size*4;break}P*=T,c[a=E.id]??(c[a]=0),c[E.id]+=P,f[m]={attrib:y,meta:E,info:_,byteLength:P,dimension:T}}const p={};for(const m in f){const{attrib:g,meta:_,info:y,byteLength:E,dimension:T}=f[m];(y==null?void 0:y.location)!==void 0&&(p[l=_.id]??(p[l]=0),g.offset??(g.offset=p[_.id]),g.stride??(g.stride=c[_.id]===E?0:c[_.id]),this.enableVertexAttrib(m,y.location,g,T),p[_.id]+=E)}}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 ao extends He{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 lo extends Yn{constructor(e=En(),t){super();u(this,"_modules",[new no,new Qn,new eo,new ro,new oo,new ao,new Kn,new to,new io,new so,new Jn]);u(this,"bindPoints",new Map);if(!e)throw new Error("Failed to createHTMLCanvas");Tn(e)?this._setupContext(e,t):(this.gl=e,this.version=Sn(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}}class Tt{}class ho extends Tt{install(r){const e=async t=>{const{parseFont:i}=await Promise.resolve().then(()=>cd);return await r.fetch(t).then(s=>s.arrayBuffer()).then(s=>i(s))};return this.load=t=>r.loadBy(t,()=>e(t)),["woff","ttf","otf"].forEach(t=>{r.register(t,e)}),r.font=this,this}}function zl(n,r,e=2){const t=r&&r.length,i=t?r[0]*e:n.length;let s=co(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,h;if(t&&(s=Wl(n,r,s,e)),n.length>80*e){a=1/0,l=1/0;let c=-1/0,f=-1/0;for(let p=e;p<i;p+=e){const m=n[p],g=n[p+1];m<a&&(a=m),g<l&&(l=g),m>c&&(c=m),g>f&&(f=g)}h=Math.max(c-a,f-l),h=h!==0?32767/h:0}return xr(s,o,e,a,l,h,0),o}function co(n,r,e,t,i){let s;if(i===ih(n,r,e,t)>0)for(let o=r;o<e;o+=t)s=go(o/t|0,n[o],n[o+1],s);else for(let o=e-t;o>=r;o-=t)s=go(o/t|0,n[o],n[o+1],s);return s&&Jt(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&&(Jt(e,e.next)||ie(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 xr(n,r,e,t,i,s,o){if(!n)return;!o&&s&&Kl(n,t,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,h=n.next;if(s?jl(n,t,i,s):Vl(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=Gl(Lt(n),r),xr(n,r,e,t,i,s,2)):o===2&&ql(n,r,e,t,i,s):xr(Lt(n),r,e,t,i,s,1);break}}}function Vl(n){const r=n.prev,e=n,t=n.next;if(ie(r,e,t)>=0)return!1;const i=r.x,s=e.x,o=t.x,a=r.y,l=e.y,h=t.y,c=Math.min(i,s,o),f=Math.min(a,l,h),p=Math.max(i,s,o),m=Math.max(a,l,h);let g=t.next;for(;g!==r;){if(g.x>=c&&g.x<=p&&g.y>=f&&g.y<=m&&Pr(i,a,s,l,o,h,g.x,g.y)&&ie(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function jl(n,r,e,t){const i=n.prev,s=n,o=n.next;if(ie(i,s,o)>=0)return!1;const a=i.x,l=s.x,h=o.x,c=i.y,f=s.y,p=o.y,m=Math.min(a,l,h),g=Math.min(c,f,p),_=Math.max(a,l,h),y=Math.max(c,f,p),E=gs(m,g,r,e,t),T=gs(_,y,r,e,t);let P=n.prevZ,S=n.nextZ;for(;P&&P.z>=E&&S&&S.z<=T;){if(P.x>=m&&P.x<=_&&P.y>=g&&P.y<=y&&P!==i&&P!==o&&Pr(a,c,l,f,h,p,P.x,P.y)&&ie(P.prev,P,P.next)>=0||(P=P.prevZ,S.x>=m&&S.x<=_&&S.y>=g&&S.y<=y&&S!==i&&S!==o&&Pr(a,c,l,f,h,p,S.x,S.y)&&ie(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;P&&P.z>=E;){if(P.x>=m&&P.x<=_&&P.y>=g&&P.y<=y&&P!==i&&P!==o&&Pr(a,c,l,f,h,p,P.x,P.y)&&ie(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;S&&S.z<=T;){if(S.x>=m&&S.x<=_&&S.y>=g&&S.y<=y&&S!==i&&S!==o&&Pr(a,c,l,f,h,p,S.x,S.y)&&ie(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function Gl(n,r){let e=n;do{const t=e.prev,i=e.next.next;!Jt(t,i)&&fo(t,e,e.next,i)&&Cr(t,i)&&Cr(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 ql(n,r,e,t,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&eh(o,a)){let l=po(o,a);o=Lt(o,o.next),l=Lt(l,l.next),xr(o,r,e,t,i,s,0),xr(l,r,e,t,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function Wl(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=co(n,a,l,t,!1);h===h.next&&(h.steiner=!0),i.push(Ql(h))}i.sort(Xl);for(let s=0;s<i.length;s++)e=Hl(i[s],e);return e}function Xl(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 Hl(n,r){const e=Yl(n,r);if(!e)return r;const t=po(e,n);return Lt(t,t.next),Lt(e,e.next)}function Yl(n,r){let e=r;const t=n.x,i=n.y;let s=-1/0,o;if(Jt(n,e))return e;do{if(Jt(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&&uo(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);Cr(e,n)&&(f<c||f===c&&(e.x>o.x||e.x===o.x&&Zl(o,e)))&&(o=e,c=f)}e=e.next}while(e!==a);return o}function Zl(n,r){return ie(n.prev,n,r.prev)<0&&ie(r.next,n,n.next)<0}function Kl(n,r,e,t){let i=n;do i.z===0&&(i.z=gs(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,Jl(i)}function Jl(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 gs(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 Ql(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 uo(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 Pr(n,r,e,t,i,s,o,a){return!(n===o&&r===a)&&uo(n,r,e,t,i,s,o,a)}function eh(n,r){return n.next.i!==r.i&&n.prev.i!==r.i&&!th(n,r)&&(Cr(n,r)&&Cr(r,n)&&rh(n,r)&&(ie(n.prev,n,r.prev)||ie(n,r.prev,r))||Jt(n,r)&&ie(n.prev,n,n.next)>0&&ie(r.prev,r,r.next)>0)}function ie(n,r,e){return(r.y-n.y)*(e.x-r.x)-(r.x-n.x)*(e.y-r.y)}function Jt(n,r){return n.x===r.x&&n.y===r.y}function fo(n,r,e,t){const i=li(ie(n,r,e)),s=li(ie(n,r,t)),o=li(ie(e,t,n)),a=li(ie(e,t,r));return!!(i!==s&&o!==a||i===0&&ai(n,e,r)||s===0&&ai(n,t,r)||o===0&&ai(e,n,t)||a===0&&ai(e,r,t))}function ai(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 li(n){return n>0?1:n<0?-1:0}function th(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&&fo(e,e.next,n,r))return!0;e=e.next}while(e!==n);return!1}function Cr(n,r){return ie(n.prev,n,n.next)<0?ie(n,r,n.next)>=0&&ie(n,n.prev,r)>=0:ie(n,r,n.prev)<0||ie(n,n.next,r)<0}function rh(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 po(n,r){const e=ms(n.i,n.x,n.y),t=ms(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 go(n,r,e,t){const i=ms(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 ms(n,r,e){return{i:n,x:r,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ih(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 sh(n,r,e,t={}){const{radius:i=1}=t;n.moveTo(r,e),n.arc(r,e,i,0,Math.PI*2)}const nh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function ys(n,r){const{fill:e="#000",stroke:t="none",strokeWidth:i=t==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:c=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m="rgba(0, 0, 0, 0)"}=r;n.fillStyle=e,n.strokeStyle=t,n.lineWidth=i,n.lineCap=s,n.lineJoin=nh[o],n.miterLimit=a,n.setLineDash(l),n.lineDashOffset=h,n.shadowOffsetX=c,n.shadowOffsetY=f,n.shadowBlur=p,n.shadowColor=m}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 Z{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 Z;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 Z(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 Z(this.left,this.top,this.width,this.height)}}class Fe{constructor(r=1,e=0,t=0,i=0,s=1,o=0,a=0,l=0,h=1){u(this,"elements",[]);this.set(r,e,t,i,s,o,a,l,h)}set(r,e,t,i,s,o,a,l,h){const c=this.elements;return c[0]=r,c[1]=i,c[2]=a,c[3]=e,c[4]=s,c[5]=l,c[6]=t,c[7]=o,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(r){const e=this.elements,t=r.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}multiply(r){return this.multiplyMatrices(this,r)}premultiply(r){return this.multiplyMatrices(r,this)}multiplyMatrices(r,e){const t=r.elements,i=e.elements,s=this.elements,o=t[0],a=t[3],l=t[6],h=t[1],c=t[4],f=t[7],p=t[2],m=t[5],g=t[8],_=i[0],y=i[3],E=i[6],T=i[1],P=i[4],S=i[7],w=i[2],v=i[5],x=i[8];return s[0]=o*_+a*T+l*w,s[3]=o*y+a*P+l*v,s[6]=o*E+a*S+l*x,s[1]=h*_+c*T+f*w,s[4]=h*y+c*P+f*v,s[7]=h*E+c*S+f*x,s[2]=p*_+m*T+g*w,s[5]=p*y+m*P+g*v,s[8]=p*E+m*S+g*x,this}invert(){const r=this.elements,e=r[0],t=r[1],i=r[2],s=r[3],o=r[4],a=r[5],l=r[6],h=r[7],c=r[8],f=c*o-a*h,p=a*l-c*s,m=h*s-o*l,g=e*f+t*p+i*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return r[0]=f*_,r[1]=(i*h-c*t)*_,r[2]=(a*t-i*o)*_,r[3]=p*_,r[4]=(c*e-i*l)*_,r[5]=(i*s-a*e)*_,r[6]=m*_,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(_s.makeScale(r,e)),this}rotate(r){return this.premultiply(_s.makeRotation(-r)),this}translate(r,e){return this.premultiply(_s.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 _s=new Fe;function mo(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 oh(n,r,e,t,i,s,o,a){if(r===0||e===0){n.lineTo(a.x,a.y);return}t=t*Math.PI/180,r=Math.abs(r),e=Math.abs(e);const l=(o.x-a.x)/2,h=(o.y-a.y)/2,c=Math.cos(t)*l+Math.sin(t)*h,f=-Math.sin(t)*l+Math.cos(t)*h;let p=r*r,m=e*e;const g=c*c,_=f*f,y=g/p+_/m;if(y>1){const F=Math.sqrt(y);r=F*r,e=F*e,p=r*r,m=e*e}const E=p*_+m*g,T=(p*m-E)/E;let P=Math.sqrt(Math.max(0,T));i===s&&(P=-P);const S=P*r*f/e,w=-P*e*c/r,v=Math.cos(t)*S-Math.sin(t)*w+(o.x+a.x)/2,x=Math.sin(t)*S+Math.cos(t)*w+(o.y+a.y)/2,C=mo(1,0,(c-S)/r,(f-w)/e),I=mo((c-S)/r,(f-w)/e,(-c-S)/r,(-f-w)/e)%(Math.PI*2);n.ellipse(v,x,r,e,t,C,C+I,s===0)}const he={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function lt(n,r,e=0){let a=0,l=!0,h="",c="";const f=[];function p(y,E,T){const P=new SyntaxError(`Unexpected character "${y}" at index ${E}.`);throw P.partial=T,P}function m(){h!==""&&(c===""?f.push(Number(h)):f.push(Number(h)*10**Number(c))),h="",c=""}let g;const _=n.length;for(let y=0;y<_;y++){if(g=n[y],Array.isArray(r)&&r.includes(f.length%e)&&he.FLAGS.test(g)){a=1,h=g,m();continue}if(a===0){if(he.WHITESPACE.test(g))continue;if(he.DIGIT.test(g)||he.SIGN.test(g)){a=1,h=g;continue}if(he.POINT.test(g)){a=2,h=g;continue}he.COMMA.test(g)&&(l&&p(g,y,f),l=!0)}if(a===1){if(he.DIGIT.test(g)){h+=g;continue}if(he.POINT.test(g)){h+=g,a=2;continue}if(he.EXP.test(g)){a=3;continue}he.SIGN.test(g)&&h.length===1&&he.SIGN.test(h[0])&&p(g,y,f)}if(a===2){if(he.DIGIT.test(g)){h+=g;continue}if(he.EXP.test(g)){a=3;continue}he.POINT.test(g)&&h[h.length-1]==="."&&p(g,y,f)}if(a===3){if(he.DIGIT.test(g)){c+=g;continue}if(he.SIGN.test(g)){if(c===""){c+=g;continue}c.length===1&&he.SIGN.test(c)&&p(g,y,f)}}he.WHITESPACE.test(g)?(m(),a=0,l=!1):he.COMMA.test(g)?(m(),a=0,l=!0):he.SIGN.test(g)?(m(),a=1,h=g):he.POINT.test(g)?(m(),a=2,h=g):p(g,y,f)}return m(),f}function Qt(n,r){return n-(r-n)}function yo(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(Qt(e.x,t.x),Qt(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(Qt(e.x,t.x),Qt(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=Qt(e.x,t.x),l=Qt(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),oh(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 ah(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 lh=/[a-df-z][^a-df-z]*/gi;function _o(n){const r=[],e=n.match(lh);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=lt(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=lt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,x:l[h]});break;case"v":case"V":l=lt(a);for(let h=0,c=l.length;h<c;h++)r.push({type:o,y:l[h]});break;case"l":case"L":l=lt(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=lt(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=lt(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=lt(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=lt(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=lt(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 vo(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 hh(n,r){const e=1-n;return e*e*e*r}function ch(n,r){const e=1-n;return 3*e*e*n*r}function uh(n,r){return 3*(1-n)*n*n*r}function fh(n,r){return n*n*n*r}function bo(n,r,e,t,i){return hh(n,r)+ch(n,e)+uh(n,t)+fh(n,i)}function dh(n,r={}){let{vertices:e=[],indices:t=[],holes:i=[],verticesStride:s=2,verticesOffset:o=0,indicesOffset:a=0}=r;const l=zl(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 ph=8,hi=11920929e-14,gh=1;function mh(n,r,e,t,i,s,o,a,l=.5,h){const f=Math.min(.99,Math.max(0,l));let p=(gh-f)/1;return p*=p,vs(n,r,e,t,i,s,o,a,h,p,0),h.push(o,a),h}function vs(n,r,e,t,i,s,o,a,l,h,c){if(c>ph)return;const f=(n+e)/2,p=(r+t)/2,m=(e+i)/2,g=(t+s)/2,_=(i+o)/2,y=(s+a)/2,E=(f+m)/2,T=(p+g)/2,P=(m+_)/2,S=(g+y)/2,w=(E+P)/2,v=(T+S)/2;if(c>0){let x=o-n,C=a-r;const I=Math.abs((e-o)*C-(t-a)*x),F=Math.abs((i-o)*C-(s-a)*x);if(I>hi&&F>hi){if((I+F)*(I+F)<=h*(x*x+C*C)){l.push(w,v);return}}else if(I>hi){if(I*I<=h*(x*x+C*C)){l.push(w,v);return}}else if(F>hi){if(F*F<=h*(x*x+C*C)){l.push(w,v);return}}else if(x=w-(n+o)/2,C=v-(r+a)/2,x*x+C*C<=h){l.push(w,v);return}}vs(n,r,f,p,E,T,w,v,l,h,c+1),vs(w,v,P,S,_,y,o,a,l,h,c+1)}const yh=8,_h=11920929e-14,vh=1;function bh(n,r,e,t,i,s,o=.5,a){const h=Math.min(.99,Math.max(0,o));let c=(vh-h)/1;return c*=c,bs(a,n,r,e,t,i,s,c,0),a.push(i,s),a}function bs(n,r,e,t,i,s,o,a,l){if(l>yh)return;const h=(r+t)/2,c=(e+i)/2,f=(t+s)/2,p=(i+o)/2,m=(h+f)/2,g=(c+p)/2;let _=s-r,y=o-e;const E=Math.abs((t-s)*y-(i-o)*_);if(E>_h){if(E*E<=a*(_*_+y*y)){n.push(m,g);return}}else if(_=m-(r+s)/2,y=g-(e+o)/2,_*_+y*y<=a){n.push(m,g);return}bs(n,r,e,h,c,m,g,a,l+1),bs(n,m,g,f,p,s,o,a,l+1)}function wh(n,r){const e=1-n;return e*e*r}function xh(n,r){return 2*(1-n)*n*r}function Ph(n,r){return n*n*r}function wo(n,r,e,t){return wh(n,r)+xh(n,e)+Ph(n,t)}const Ch=1e-4,xo=1e-4;function Th(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=Ch;if(n.length===0)return{vertices:e,indices:t};const l=i;let h=l.alignment;if(i.alignment!==.5){let L=Sh(n);s&&(L*=-1),h=(h-.5)*L+.5}const c={x:n[0],y:n[1]},f={x:n[n.length-2],y:n[n.length-1]},p=o,m=Math.abs(c.x-f.x)<a&&Math.abs(c.y-f.y)<a;if(p){n=n.slice(),m&&(n.pop(),n.pop(),f.x=n[n.length-2],f.y=n[n.length-1]);const L=(c.x+f.x)*.5,k=(f.y+c.y)*.5;n.unshift(L,k),n.push(L,k)}const g=e,_=n.length/2;let y=n.length;const E=g.length/2,T=l.width/2,P=T*T,S=l.miterLimit*l.miterLimit;let w=n[0],v=n[1],x=n[2],C=n[3],I=0,F=0,B=-(v-C),U=w-x,V=0,A=0,N=Math.sqrt(B*B+U*U);B/=N,U/=N,B*=T,U*=T;const W=h,R=(1-W)*2,D=W*2;p||(l.cap==="round"?y+=Nt(w-B*(R-D)*.5,v-U*(R-D)*.5,w-B*R,v-U*R,w+B*D,v+U*D,g,!0)+2:l.cap==="square"&&(y+=Po(w,v,B,U,R,D,!0,g))),g.push(w-B*R,v-U*R),g.push(w+B*D,v+U*D);for(let L=1;L<_-1;++L){w=n[(L-1)*2],v=n[(L-1)*2+1],x=n[L*2],C=n[L*2+1],I=n[(L+1)*2],F=n[(L+1)*2+1],B=-(v-C),U=w-x,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=T,U*=T,V=-(C-F),A=x-I,N=Math.sqrt(V*V+A*A),V/=N,A/=N,V*=T,A*=T;const k=x-w,K=v-C,H=x-I,X=F-C,q=k*H+K*X,ee=K*H-X*k,Y=ee<0;if(Math.abs(ee)<.001*Math.abs(q)){g.push(x-B*R,C-U*R),g.push(x+B*D,C+U*D),q>=0&&(l.join==="round"?y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+4:y+=2,g.push(x-V*D,C-A*D),g.push(x+V*R,C+A*R));continue}const ae=(-B+w)*(-U+C)-(-B+x)*(-U+v),pt=(-V+I)*(-A+C)-(-V+x)*(-A+F),Ke=(k*pt-H*ae)/ee,Ne=(X*ae-K*pt)/ee,ze=(Ke-x)*(Ke-x)+(Ne-C)*(Ne-C),Ee=x+(Ke-x)*R,Ve=C+(Ne-C)*R,it=x-(Ke-x)*D,st=C-(Ne-C)*D,Je=Math.min(k*k+K*K,H*H+X*X),cl=Y?R:D,Ip=Je+cl*cl*P;ze<=Ip?l.join==="bevel"||ze/P>S?(Y?(g.push(Ee,Ve),g.push(x+B*D,C+U*D),g.push(Ee,Ve),g.push(x+V*D,C+A*D)):(g.push(x-B*R,C-U*R),g.push(it,st),g.push(x-V*R,C-A*R),g.push(it,st)),y+=2):l.join==="round"?Y?(g.push(Ee,Ve),g.push(x+B*D,C+U*D),y+=Nt(x,C,x+B*D,C+U*D,x+V*D,C+A*D,g,!0)+4,g.push(Ee,Ve),g.push(x+V*D,C+A*D)):(g.push(x-B*R,C-U*R),g.push(it,st),y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+4,g.push(x-V*R,C-A*R),g.push(it,st)):(g.push(Ee,Ve),g.push(it,st)):(g.push(x-B*R,C-U*R),g.push(x+B*D,C+U*D),l.join==="round"?Y?y+=Nt(x,C,x+B*D,C+U*D,x+V*D,C+A*D,g,!0)+2:y+=Nt(x,C,x-B*R,C-U*R,x-V*R,C-A*R,g,!1)+2:l.join==="miter"&&ze/P<=S&&(Y?(g.push(it,st),g.push(it,st)):(g.push(Ee,Ve),g.push(Ee,Ve)),y+=2),g.push(x-V*R,C-A*R),g.push(x+V*D,C+A*D),y+=2)}w=n[(_-2)*2],v=n[(_-2)*2+1],x=n[(_-1)*2],C=n[(_-1)*2+1],B=-(v-C),U=w-x,N=Math.sqrt(B*B+U*U),B/=N,U/=N,B*=T,U*=T,g.push(x-B*R,C-U*R),g.push(x+B*D,C+U*D),p||(l.cap==="round"?y+=Nt(x-B*(R-D)*.5,C-U*(R-D)*.5,x-B*R,C-U*R,x+B*D,C+U*D,g,!1)+2:l.cap==="square"&&(y+=Po(x,C,B,U,R,D,!1,g)));const G=xo*xo;for(let L=E;L<y+E-2;++L)w=g[L*2],v=g[L*2+1],x=g[(L+1)*2],C=g[(L+1)*2+1],I=g[(L+2)*2],F=g[(L+2)*2+1],!(Math.abs(w*(C-F)+x*(F-v)+I*(v-C))<G)&&t.push(L,L+1,L+2);return{vertices:e,indices:t}}function Sh(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 Po(n,r,e,t,i,s,o,a){const l=n-e*i,h=r-t*i,c=n+e*s,f=r+t*s;let p,m;o?(p=t,m=-e):(p=-t,m=e);const g=l+p,_=h+m,y=c+p,E=f+m;return a.push(g,_),a.push(y,E),2}function Nt(n,r,e,t,i,s,o,a){const l=e-n,h=t-r;let c=Math.atan2(l,h),f=Math.atan2(i-n,s-r);a&&c<f?c+=Math.PI*2:!a&&c>f&&(f+=Math.PI*2);let p=c;const m=f-c,g=Math.abs(m),_=Math.sqrt(l*l+h*h),y=(15*g*Math.sqrt(_)/Math.PI>>0)+1,E=m/y;if(p+=E,a){o.push(n,r),o.push(e,t);for(let T=1,P=p;T<y;T++,P+=E)o.push(n,r),o.push(n+Math.sin(P)*_,r+Math.cos(P)*_);o.push(n,r),o.push(i,s)}else{o.push(e,t),o.push(n,r);for(let T=1,P=p;T<y;T++,P+=E)o.push(n+Math.sin(P)*_,r+Math.cos(P)*_),o.push(n,r);o.push(i,s),o.push(n,r)}return y*2}class er{constructor(){u(this,"arcLengthDivision",200);u(this,"_arcLengths")}getPointAt(r,e=new O){return this.getPoint(this.getUToTMapping(r),e)}isClockwise(){const r=this.getPoint(1),e=this.getPoint(.5),t=this.getPoint(1);return(e.x-r.x)*(t.y-e.y)-(e.y-r.y)*(t.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(r){return this.getControlPointRefs().forEach(e=>{e.applyMatrix3(r)}),this}getUnevenPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPoint(i/s,t),e.push(t.x,t.y);return e}getSpacedPointArray(r=5,e=[]){const t=new O;for(let i=0,s=Math.max(1,r)-1;i<=s;i++)this.getPointAt(i/s,t),e.push(t.x,t.y);return e}getAdaptivePointArray(r=[]){return this.getUnevenPointArray(5,r)}_pointArrayToPoint(r,e=[]){for(let t=0,i=r.length;t<i;t+=2){const s=r[t],o=r[t+1];e.push(new O(s,o))}return e}getSpacedPoints(r,e=[]){const t=this.getSpacedPointArray(r);return this._pointArrayToPoint(t,e),e}getUnevenPoints(r,e=[]){const t=this.getUnevenPointArray(r);return this._pointArrayToPoint(t,e),e}getAdaptivePoints(r=[]){const e=this.getAdaptivePointArray();return this._pointArrayToPoint(e,r),r}getPoints(r,e=[]){let t;return r?t=this.getUnevenPointArray(r):t=this.getAdaptivePointArray(),this._pointArrayToPoint(t,e),e}getLength(){const r=this.getLengths();return r[r.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const r=this.arcLengthDivision,e=[0];for(let t=0,i=this.getPoint(0),s=1;s<=r;s++){const o=this.getPoint(s/r);t+=o.distanceTo(i),e.push(t),i=o}this._arcLengths=e}getUToTMapping(r,e){const t=this.getLengths(),i=t.length,s=e??r*t[i-1];if(i<2)return s/t[0];let o=0,a=0,l=i-1,h;for(;a<=l;)if(o=Math.floor(a+(l-a)/2),h=t[o]-s,h<0)a=o+1;else if(h>0)l=o-1;else{l=o;break}if(o=l,t[o]===s)return o/(i-1);const c=t[o],p=t[o+1]-c,m=(s-c)/p;return(o+m)/(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 Z(r.x,r.y,e.x-r.x,e.y-r.y)}fillTriangulate(r){return dh(this.getAdaptivePointArray(),r)}strokeTriangulate(r){return Th(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 ah(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 Eh=new Fe,Co=new Fe,To=new Fe,ci=new O;class ws extends er{constructor(r=new O,e=new O,t=new O,i=0,s=0,o=Math.PI*2,a=!1){super(),this._center=r,this._radius=e,this._diff=t,this.rotate=i,this.startAngle=s,this.endAngle=o,this.clockwise=a}get cx(){return this._center.x}set cx(r){this._center.x=r}get cy(){return this._center.y}set cy(r){this._center.y=r}get rx(){return this._radius.x}set rx(r){this._radius.x=r}get ry(){return this._radius.y}set ry(r){this._radius.y=r}get dx(){return this._diff.x}set dx(r){this._diff.x=r}get dy(){return this._diff.y}set dy(r){this._diff.y=r}isClockwise(){return this.clockwise}getPoint(r,e=new O){const t=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=t;for(;i>t;)i-=t;i<Number.EPSILON&&(s?i=0:i=t),this.clockwise&&!s&&(i===t?i=-t:i=i-t);const o=this.startAngle+r*i;let a=this.cx+this.rx*Math.cos(o),l=this.cy+this.ry*Math.sin(o);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),f=a-this.cx,p=l-this.cy;a=f*h-p*c+this.cx,l=f*c+p*h+this.cy}return e.set(a,l)}toCommands(){const{cx:r,cy:e,rx:t,ry:i,startAngle:s,endAngle:o,clockwise:a,rotate:l}=this,h=r+t*Math.cos(s)*Math.cos(l)-i*Math.sin(s)*Math.sin(l),c=e+t*Math.cos(s)*Math.sin(l)+i*Math.sin(s)*Math.cos(l),f=Math.abs(s-o),p=f>Math.PI?1:0,m=a?1:0,g=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),E=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:g,largeArcFlag:0,sweepFlag:m,x:y,y:E},{type:"A",rx:t,ry:i,angle:g,largeArcFlag:0,sweepFlag:m,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:g,largeArcFlag:p,sweepFlag:m,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 ci.set(this.cx,this.cy),ci.applyMatrix3(r),this.cx=ci.x,this.cy=ci.y,Oh(r)?Mh(this,r):Ah(this,r),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,ry:s,dx:o,dy:a}=this;if(!(i>=0&&s>=0&&o>=0&&a>=0))return r;const l=Math.ceil(2.3*Math.sqrt(i+s)),h=l*8+(o?4:0)+(a?4:0);if(h===0)return r;const c=[];if(l===0)c[0]=c[6]=e+o,c[1]=c[3]=t+a,c[2]=c[4]=e-o,c[5]=c[7]=t-a;else{let f=0,p=l*4+(o?2:0)+2,m=p,g=h,_=o+i,y=a,E=e+_,T=e-_,P=t+y;if(c[f++]=E,c[f++]=P,c[--p]=P,c[--p]=T,a){const w=t-y;c[m++]=T,c[m++]=w,c[--g]=w,c[--g]=E}for(let w=1;w<l;w++){const v=Math.PI/2*(w/l),x=o+Math.cos(v)*i,C=a+Math.sin(v)*s,I=e+x,F=e-x,B=t+C,U=t-C;c[f++]=I,c[f++]=B,c[--p]=B,c[--p]=F,c[m++]=F,c[m++]=U,c[--g]=U,c[--g]=I}_=o,y=a+s,E=e+_,T=e-_,P=t+y;const S=t-y;c[f++]=E,c[f++]=P,c[--g]=S,c[--g]=E,o&&(c[f++]=T,c[f++]=P,c[--g]=S,c[--g]=T)}return Array.prototype.push.apply(r,c),r}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const a=this.getAdaptivePointArray();if(a.length===0)return{vertices:e,indices:t};let l=0,h=0;for(let p=0;p<a.length;p+=2)l+=a[p],h+=a[p+1];l/=a.length/2,h/=a.length/2;let c=s;e[c*i]=l,e[c*i+1]=h;const f=c++;for(let p=0;p<a.length;p+=2)e[c*i]=a[p],e[c*i+1]=a[p+1],p>0&&(t[o++]=c,t[o++]=f,t[o++]=c-1),c++;return t[o++]=f+1,t[o++]=f,t[o++]=c-1,{vertices:e,indices:t}}getMinMax(r=O.MAX,e=O.MIN){const{cx:t,cy:i,rx:s,ry:o,rotate:a}=this,l=Math.cos(a),h=Math.sin(a),c=Math.sqrt(s*s*l*l+o*o*h*h),f=Math.sqrt(s*s*h*h+o*o*l*l);return r.x=Math.min(r.x,t-c),r.y=Math.min(r.y,i-f),e.x=Math.max(e.x,t+c),e.y=Math.max(e.y,i+f),{min:r,max:e}}copy(r){return super.copy(r),this.cx=r.cx,this.cy=r.cy,this.rx=r.rx,this.ry=r.ry,this.dx=r.dx,this.dy=r.dy,this.startAngle=r.startAngle,this.endAngle=r.endAngle,this.clockwise=r.clockwise,this.rotate=r.rotate,this}}function Mh(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=Eh.set(l.x,h.x,0,l.y,h.y,0,0,0,1),f=Co.copy(c).invert(),g=To.copy(f).transpose().multiply(f).elements,_=Uh(g[0],g[1],g[4]),y=Math.sqrt(_.rt1),E=Math.sqrt(_.rt2);if(n.rx=1/y,n.ry=1/E,n.rotate=Math.atan2(_.sn,_.cs),!((n.endAngle-n.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=Co.set(y,0,0,0,E,0,0,0,1),S=To.set(_.cs,_.sn,0,-_.sn,_.cs,0,0,0,1),w=P.multiply(S).multiply(c),v=x=>{const{x:C,y:I}=new O(Math.cos(x),Math.sin(x)).applyMatrix3(w);return Math.atan2(I,C)};n.startAngle=v(n.startAngle),n.endAngle=v(n.endAngle),So(r)&&(n.clockwise=!n.clockwise)}}function Ah(n,r){const e=Eo(r),t=Mo(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,So(r)&&(n.startAngle*=-1,n.endAngle*=-1,n.clockwise=!n.clockwise)}function So(n){const r=n.elements;return r[0]*r[4]-r[1]*r[3]<0}function Oh(n){const r=n.elements,e=r[0]*r[3]+r[1]*r[4];if(e===0)return!1;const t=Eo(n),i=Mo(n);return Math.abs(e/(t*i))>Number.EPSILON}function Eo(n){const r=n.elements;return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function Mo(n){const r=n.elements;return Math.sqrt(r[3]*r[3]+r[4]*r[4])}function Uh(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 Ih extends ws{constructor(r=0,e=0,t=1,i=0,s=Math.PI*2,o=!1){super(new O(r,e),new O(t,t),new O(0,0),0,i,s,o)}drawTo(r){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;return r.arc(e,t,i,s,o,!a),this}getAdaptivePointArray(r=[]){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:o,clockwise:a}=this;let l=Math.abs(s-o);(!a&&s>o||a&&o>s)&&(l=2*Math.PI-l);let h=Math.max(6,Math.floor(6*i**(1/3)*(l/Math.PI)));h=Math.max(h,3);let c=l/h,f=s;c*=a?1:-1;for(let p=0;p<h+1;p++){const m=Math.cos(f),g=Math.sin(f),_=e+m*i,y=t+g*i;r.push(_,y),f+=c}return r}}class Sr extends er{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 Z(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 xs extends er{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 xs(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(bo(r,t.x,i.x,s.x,o.x),bo(r,t.y,i.y,s.y,o.y))}getAdaptivePointArray(r=[]){return mh(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,r)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(r,e,t){const i=e*e-4*r*t;if(i<0)return[];const s=Math.sqrt(i),o=(-e+s)/(2*r),a=(-e-s)/(2*r);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(r=O.MAX,e=O.MIN){const{p1:t,cp1:i,cp2:s,p2:o}=this,a=this._solveQuadratic(3*(i.x-t.x),6*(s.x-i.x),3*(o.x-s.x)),l=this._solveQuadratic(3*(i.y-t.y),6*(s.y-i.y),3*(o.y-s.y)),h=[0,1,...a,...l];return((f,p)=>{for(const m of f)for(let g=0;g<=p;g++){const _=g/p-.5,y=Math.min(1,Math.max(0,m+_)),E=this.getPoint(y);r.x=Math.min(r.x,E.x),r.y=Math.min(r.y,E.y),e.x=Math.max(e.x,E.x),e.y=Math.max(e.y,E.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 Dh extends ws{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 St extends er{constructor(r=new O,e=new O){super(),this.p1=r,this.p2=e}static from(r,e,t,i){return new St(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 Rh extends Sr{}class Ps extends er{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 Ps(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(wo(r,t.x,i.x,s.x),wo(r,t.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(r=[]){return bh(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 Bh extends Rh{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 St(s[0],s[1]),new St(s[1],s[2]),new St(s[2],s[3]),new St(s[3],s[0])],this}drawTo(r){return r.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(r={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=0,indicesOffset:o=0}=r;const{x:a,y:l,width:h,height:c}=this,f=[a,l,a+h,l,a+h,l+c,a,l+c];let p=0;s*=i,e[s+p]=f[0],e[s+p+1]=f[1],p+=i,e[s+p]=f[2],e[s+p+1]=f[3],p+=i,e[s+p]=f[6],e[s+p+1]=f[7],p+=i,e[s+p]=f[4],e[s+p+1]=f[5],p+=i;const m=s/i;return t[o++]=m,t[o++]=m+1,t[o++]=m+2,t[o++]=m+1,t[o++]=m+3,t[o++]=m+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 kh extends ws{constructor(r=0,e=0,t=1,i=1,s=1){super(),this.x=r,this.y=e,this.width=t,this.height=i,this.radius=s,this.update()}update(){const{x:r,y:e,width:t,height:i,radius:s}=this,o=t/2,a=i/2,l=r+o,h=e+a,c=Math.max(0,Math.min(s,Math.min(o,a))),f=c,p=o-c,m=a-f;return this._center=new O(l,h),this._radius=new O(c,f),this._diff=new O(p,m),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 Lh extends er{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(vo(o,a.x,l.x,h.x,c.x),vo(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 tr 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 yo(e,this),this}addData(e){return this.addCommands(_o(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 St(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(St.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(xs.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(Ps.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 Ih(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 Dh(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 Bh(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 kh(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 Lh([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 Nh(n){return n.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Fh(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 Pe extends Sr{constructor(e,t={}){super();u(this,"currentCurve",new tr);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof Pe?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 Pe?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 tr().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 tr,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 tr,this.curves.push(this.currentCurve),this.style={},this}addCommands(e){return yo(e,this),this}addData(e){return this.addCommands(_o(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 p=c[0],m=c[c.length-1]??p;i.push({start:f?m:p,end:f?p:m,index:h})});const a=[];return i.forEach((l,h)=>{a[h]=[],i.forEach((c,f)=>{var p;c.start&&l.end&&f!==h&&((p=c.start)!=null&&p.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 p=o[f],m=Fh(c[c.length-1],c[c.length-2]??c[c.length-1],p[0],p[1]??p[0]);m&&(c[c.length-1].copy(m),p[0].copy(m))})}),this}getMinMax(e=O.MAX,t=O.MIN,i=!0){const s=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(e,t),i&&s>1){const a=s/2,l=o.isClockwise(),h=[];for(let c=0;c<=1;c+=1/o.arcLengthDivision){const f=o.getPoint(c),p=o.getNormal(c),m=p.clone().scale(l?a:-a),g=p.clone().scale(l?-a:a);h.push(f.clone().add(m),f.clone().add(g),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 Z(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(),ys(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(),ys(e,t),this.getControlPointRefs().forEach(o=>{sh(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[Nh(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 Cs{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 Z(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 Ao="data:image/svg+xml;",Oo=`${Ao}base64,`,Uo=`${Ao}charset=utf8,`;function Io(n){if(typeof n=="string"){let r;n.startsWith(Oo)?(n=n.substring(Oo.length,n.length),r=atob(n)):n.startsWith(Uo)?(n=n.substring(Uo.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"}
61
+ ${r}`);return e.documentElement}else return n}const $h="px",zh=90,Do=["mm","cm","in","pt","pc","px"],Ro={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 Q(n){let r="px";if(typeof n=="string"||n instanceof String)for(let t=0,i=Do.length;t<i;t++){const s=Do[t];if(n.endsWith(s)){r=s,n=n.substring(0,n.length-s.length);break}}let e;return e=Ro[r][$h],e<0&&(e=Ro[r].in*zh),e*Number.parseFloat(n)}const Vh=new Fe,ui=new Fe,Bo=new Fe,ko=new Fe;function jh(n,r,e){if(!(n.hasAttribute("transform")||n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))))return null;const t=Gh(n);return e.length>0&&t.premultiply(e[e.length-1]),r.copy(t),e.push(t),t}function Gh(n){const r=new Fe,e=Vh;if(n.nodeName==="use"&&(n.hasAttribute("x")||n.hasAttribute("y"))&&r.translate(Q(n.getAttribute("x")),Q(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=lt(s.slice(o+1));switch(e.identity(),l){case"translate":if(h.length>=1){const c=h[0];let f=0;h.length>=2&&(f=h[1]),e.translate(c,f)}break;case"rotate":if(h.length>=1){let c=0,f=0,p=0;c=h[0]*Math.PI/180,h.length>=3&&(f=h[1],p=h[2]),ui.makeTranslation(-f,-p),Bo.makeRotation(c),ko.multiplyMatrices(Bo,ui),ui.makeTranslation(f,p),e.multiplyMatrices(ui,ko)}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 qh(n){return new Pe().arc(Q(n.getAttribute("cx")||0),Q(n.getAttribute("cy")||0),Q(n.getAttribute("r")||0),0,Math.PI*2)}function Wh(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 Xh(n){return new Pe().ellipse(Q(n.getAttribute("cx")||0),Q(n.getAttribute("cy")||0),Q(n.getAttribute("rx")||0),Q(n.getAttribute("ry")||0),0,0,Math.PI*2)}function Hh(n){return new Pe().moveTo(Q(n.getAttribute("x1")||0),Q(n.getAttribute("y1")||0)).lineTo(Q(n.getAttribute("x2")||0),Q(n.getAttribute("y2")||0))}function Yh(n){const r=new Pe,e=n.getAttribute("d");return!e||e==="none"?null:(r.addData(e),r)}const Zh=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Kh(n){var t;const r=new Pe;let e=0;return(t=n.getAttribute("points"))==null||t.replace(Zh,(i,s,o)=>{const a=Q(s),l=Q(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!0,r}const Jh=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Qh(n){var t;const r=new Pe;let e=0;return(t=n.getAttribute("points"))==null||t.replace(Jh,(i,s,o)=>{const a=Q(s),l=Q(o);return e===0?r.moveTo(a,l):r.lineTo(a,l),e++,i}),r.currentCurve.autoClose=!1,r}function ec(n){const r=Q(n.getAttribute("x")||0),e=Q(n.getAttribute("y")||0),t=Q(n.getAttribute("rx")||n.getAttribute("ry")||0),i=Q(n.getAttribute("ry")||n.getAttribute("rx")||0),s=Q(n.getAttribute("width")),o=Q(n.getAttribute("height")),a=1-.551915024494,l=new Pe;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 ht(n,r,e){r=Object.assign({},r);let t={};if(n.hasAttribute("class")){const h=n.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<h.length;c++)t=Object.assign(t,e[`.${h[c]}`])}n.hasAttribute("id")&&(t=Object.assign(t,e[`#${n.getAttribute("id")}`]));for(let h=n.style.length,c=0;c<h;c++){const f=n.style.item(c),p=n.style.getPropertyValue(f);r[f]=p,t[f]=p}function i(h,c,f=s){n.hasAttribute(h)&&(r[c]=f(n.getAttribute(h))),t[h]&&(r[c]=f(t[h]))}function s(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function o(h){return Math.max(0,Math.min(1,Q(h)))}function a(h){return Math.max(0,Q(h))}function l(h){return h.split(" ").filter(c=>c!=="").map(c=>Q(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",Q),i("visibility","visibility"),r}function Ts(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=ht(n,o,t);break;case"style":Wh(n,t);break;case"g":o=ht(n,o,t);break;case"path":o=ht(n,o,t),n.hasAttribute("d")&&(s=Yh(n));break;case"rect":o=ht(n,o,t),s=ec(n);break;case"polygon":o=ht(n,o,t),s=Kh(n);break;case"polyline":o=ht(n,o,t),s=Qh(n);break;case"circle":o=ht(n,o,t),s=qh(n);break;case"ellipse":o=ht(n,o,t),s=Xh(n);break;case"line":o=ht(n,o,t),s=Hh(n);break;case"defs":i=!0;break;case"use":{o=ht(n,o,t);const m=(n.getAttributeNS("http://www.w3.org/1999/xlink","href")||n.getAttribute("href")||"").substring(1),g=(f=n.viewportElement)==null?void 0:f.getElementById(m);g?Ts(g,o,e,t):console.warn(`'use node' references non-existent node id: ${m}`);break}default:console.warn(n);break}if(o.display==="none")return e;Object.assign(r,o);const a=new Fe,l=[],h=jh(n,a,l);s&&(s.applyTransform(a),e.push(s),s.style=r);const c=n.childNodes;for(let p=0,m=c.length;p<m;p++){const g=c[p];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||Ts(g,r,e,t)}return h&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),e}function Lo(n){return new Cs(Ts(Io(n),{}))}class fi extends yt{constructor(e={}){super();u(this,"vertexAttributes");u(this,"indexBuffer");u(this,"instanceCount");u(this,"mode");u(this,"_materialWeakMap",new Zt);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 tc=Object.defineProperty,No=(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&&tc(r,e,i),i};class rr extends yt{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()))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}No([ue({default:null})],rr.prototype,"data"),No([ue({default:!1})],rr.prototype,"dynamic");var rc=Object.defineProperty,Fo=(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&&rc(r,e,i),i};class vt extends yt{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()))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}Fo([ue({default:null})],vt.prototype,"data"),Fo([ue({default:!1})],vt.prototype,"dynamic");var ic=Object.defineProperty,Ft=(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&&ic(r,e,i),i};class je extends yt{constructor(e){super();u(this,"stride");u(this,"offset");u(this,"divisor");u(this,"needsUpload",!1);this.setProperties({buffer:new vt,...e})}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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}}Ft([ue()],je.prototype,"buffer"),Ft([ue({default:0})],je.prototype,"size"),Ft([ue({default:!1})],je.prototype,"normalized"),Ft([ue({default:"float"})],je.prototype,"type"),Ft([ue()],je.prototype,"stride"),Ft([ue()],je.prototype,"offset"),Ft([ue()],je.prototype,"divisor");class sc extends fi{constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}const qi=class qi extends yt{constructor(e={}){super();u(this,"vert");u(this,"frag");u(this,"uniforms");this.vert=e.vert??`precision highp float;
62
62
  attribute vec2 position;
63
63
  uniform mat3 projectionMatrix;
64
64
  uniform mat3 modelViewMatrix;
@@ -69,7 +69,7 @@ void main(void) {
69
69
  gl_FragColor = tint;
70
70
  }`,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;
71
71
  ${i}`),t.includes("precision")||(t=`precision mediump float;
72
- ${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(qi,"instance",new qi);let ne=qi;const nc=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,oc=/vec(\d)\((.*)\)/;function ac(n){n=n.trim();const r=n.match(oc);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 Kr=class Kr extends ne{constructor(e){super();u(this,"vert",`attribute vec2 position;
72
+ ${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(qi,"instance",new qi);let se=qi;const nc=/^uniform \w+ (.+?);\s*\/\/\s*=\s*([^;]+?)[\s;]*$/gm,oc=/vec(\d)\((.*)\)/;function ac(n){n=n.trim();const r=n.match(oc);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 Kr=class Kr extends se{constructor(e){super();u(this,"vert",`attribute vec2 position;
73
73
  attribute vec2 uv;
74
74
  varying vec2 vUv;
75
75
  void main() {
@@ -88,7 +88,7 @@ vec4 getFromColor(vec2 uv) { return texture2D(from, uv); }
88
88
  vec4 getToColor(vec2 uv) { return texture2D(to, uv); }`:""}
89
89
  ${e}${t.transform?`
90
90
  void main(void) { gl_FragColor = transform(vUv); }`:t.transition?`
91
- void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=e.matchAll(nc);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),ac(s[2]))})}};u(Kr,"RE",{getColor:/\sgetColor\s*\(/,getFromColor:/\sgetFromColor\s*\(/,getToColor:/\sgetToColor\s*\(/,transform:/\stransform\s*\(/,transition:/\stransition\s*\(/});let di=Kr;class ir extends ne{static get instance(){return this._instance??(this._instance=new this)}constructor(){super({vert:`precision highp float;
91
+ void main(void) { gl_FragColor = transition(vUv); }`:""}`;const i=e.matchAll(nc);for(const s of i)s[1]&&s[2]&&s[1].split(",").forEach(o=>{this.uniforms.set(o.trim(),ac(s[2]))})}};u(Kr,"RE",{getColor:/\sgetColor\s*\(/,getFromColor:/\sgetFromColor\s*\(/,getToColor:/\sgetToColor\s*\(/,transform:/\stransform\s*\(/,transition:/\stransition\s*\(/});let di=Kr;class ir extends se{static get instance(){return this._instance??(this._instance=new this)}constructor(){super({vert:`precision highp float;
92
92
  attribute vec2 position;
93
93
  attribute vec2 uv;
94
94
  uniform mat3 projectionMatrix;
@@ -102,12 +102,7 @@ uniform sampler2D sampler;
102
102
  uniform vec4 tint;
103
103
  void main(void) {
104
104
  gl_FragColor = texture2D(sampler, vUv) * tint;
105
- }`,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(ir,"_instance");class J extends fi{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ir.instance,t){this.instance.draw(r,e,t)}constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(J,"_instance");class lc extends fi{constructor(){const e=new vt({data:new Float32Array,dynamic:!0}),t=new vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new rr({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}}function hc(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function Fo(){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 cc(){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,...Fo(),backgroundImage:"none",backgroundColor:"transparent",...hc(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function zo(){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 uc(){return{...cc(),...zo()}}var fc=Object.defineProperty,pe=(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&&fc(r,e,i),i};const Vo={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};class re extends yt{constructor(e){super();u(this,"_backgroundColor",new Ct);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=this.backgroundColor;break}}canPointeEvents(){return this.pointerEvents!=="none"}getComputedOpacity(){return at(0,this.opacity,1)}getComputedBackgroundColor(){return this._backgroundColor}async getComputedBackgroundImage(){if(this.backgroundImage)return await Pt.texture.load(this.backgroundImage)}getComputedTransform(){const{scaleX:e,scaleY:t,left:i,top:s,width:o,height:a,rotate:l}=this,h=new et,c=new et(!1),f=new et(!1).scale(e,t).translate(i,s).rotate(l*qn);let p=this.transform;(!p||p==="none")&&(p=""),yr(p,{width:o,height:a}).forEach(({name:E,args:w})=>{const v=w.map(x=>x.normalizedIntValue);switch(h.identity(),E){case"translate":h.translate(v[0]*o,(v[1]??v[0])*this.height);break;case"translateX":h.translateX(v[0]*o);break;case"translateY":h.translateY(v[0]*a);break;case"translateZ":h.translateZ(v[0]);break;case"translate3d":h.translate3d(v[0]*o,(v[1]??v[0])*a,v[2]??v[1]??v[0]);break;case"scale":h.scale(v[0],v[1]??v[0]);break;case"scaleX":h.scaleX(v[0]);break;case"scaleY":h.scaleY(v[0]);break;case"scale3d":h.scale3d(v[0],v[1]??v[0],v[2]??v[1]??v[0]);break;case"rotate":h.rotate(v[0]*le);break;case"rotateX":h.rotateX(v[0]*le);break;case"rotateY":h.rotateY(v[0]*le);break;case"rotateZ":h.rotateZ(v[0]*le);break;case"rotate3d":h.rotate3d(v[0]*le,(v[1]??v[0])*le,(v[2]??v[1]??v[0])*le,(v[3]??v[2]??v[1]??v[0])*le);break;case"skew":h.skew(v[0],v[0]??v[1]);break;case"skewX":h.skewX(v[0]);break;case"skewY":h.skewY(v[0]);break;case"matrix":h.set(v);break}c.multiply(h)}),f.update(),c.update();const m=f.toArray(),g=c.toArray(),_=[g[0]*m[0]+g[3]*m[1],g[1]*m[0]+g[4]*m[1],g[2]*m[0]+g[5]*m[1]+m[2],g[0]*m[3]+g[3]*m[4],g[1]*m[3]+g[4]*m[4],g[2]*m[3]+g[5]*m[4]+m[5],0,0,1],[y,S]=this.getComputedTransformOrigin(),T=y*o,P=S*a;return _[2]+=_[0]*-T+_[1]*-P+T,_[5]+=_[3]*-T+_[4]*-P+P,new et().set(_)}getComputedTransformOrigin(){const[e,t=e]=this.transformOrigin.split(" ");return[e,t].map(i=>{switch(i=i.trim(),i){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(i)}})}getComputedFilter(){const e=yr(this.filter).reduce((t,{name:i,args:s})=>(t[i]=s[0].normalizedIntValue,t),{});return Object.keys(Vo).forEach(t=>{e[t]=e[t]??Vo[t]}),e}getComputedFilterColorMatrix(){const e=new us,t=this.getComputedFilter();for(const i in t){const s=t[i];switch(i){case"hue-rotate":e.hueRotate(s*le);break;case"saturate":e.saturate(s);break;case"brightness":e.brightness(s);break;case"contrast":e.contrast(s);break;case"invert":e.invert(s);break;case"sepia":e.sepia(s);break;case"opacity":e.opacity(s);break;case"grayscale":e.grayscale(s);break}}return e}}pe([M()],re.prototype,"backgroundColor"),pe([M()],re.prototype,"backgroundImage"),pe([M({default:""})],re.prototype,"filter"),pe([M({default:"inherit"})],re.prototype,"direction"),pe([M({default:"#000000"})],re.prototype,"shadowColor"),pe([M({default:0})],re.prototype,"shadowOffsetX"),pe([M({default:0})],re.prototype,"shadowOffsetY"),pe([M({default:0})],re.prototype,"shadowBlur"),pe([M({default:1})],re.prototype,"opacity"),pe([M({default:0})],re.prototype,"borderWidth"),pe([M({default:0})],re.prototype,"borderRadius"),pe([M({default:"#000000"})],re.prototype,"borderColor"),pe([M({default:"none"})],re.prototype,"borderStyle"),pe([M({default:0})],re.prototype,"outlineWidth"),pe([M({default:0})],re.prototype,"outlineOffset"),pe([M({default:"#000000"})],re.prototype,"outlineColor"),pe([M({default:"none"})],re.prototype,"outlineStyle"),pe([M({default:"visible"})],re.prototype,"visibility"),pe([M({default:"visible"})],re.prototype,"overflow"),pe([M({default:"auto"})],re.prototype,"pointerEvents");const jo=Fo();for(const n in jo)vr(re,n,{default:jo[n]});const Go=zo();for(const n in Go)vr(re,n,{default:Go[n]});var dc=Object.defineProperty,sr=(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&&dc(r,e,i),i};class me extends yt{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)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Zi(this.realWidth)&&Zi(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){_n&&this.source instanceof ImageBitmap&&this.source.close()}}sr([ue()],me.prototype,"source"),sr([M({default:0})],me.prototype,"width"),sr([M({default:0})],me.prototype,"height"),sr([M({default:"linear"})],me.prototype,"filterMode"),sr([M({default:"clamp_to_edge"})],me.prototype,"wrapMode"),sr([M({default:1})],me.prototype,"pixelRatio");var pc=Object.defineProperty,gc=(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&&pc(r,e,i),i};class Sr extends me{constructor(r=document.createElement("canvas")){super(r)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(r,e,t,i)}}gc([M({default:2})],Sr.prototype,"pixelRatio");class Es extends me{constructor(r){const e=new Ct(r);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function mc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&Ji,crossorigin:(n==null?void 0:n.crossorigin)??null}}class yc extends me{constructor(e,t){const i=mc(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,a),this.emit("error",a),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ji)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(_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 Ss extends me{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)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.round(e*this.pixelRatio);break;case"height":this.source.height=Math.round(e*this.pixelRatio);break}super._updateProperty(r,e,t,i)}}var _c=Object.defineProperty,qo=(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&&_c(r,e,i),i};function vc(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 Ms=(Xt=class extends me{constructor(e,t){const i=vc(t);if(!Cn(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",""),An(o,s,i.crossorigin);for(let a=0;a<e.length;++a){let{src:l,mime:h}=e[a];if(l=l||e[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const f=l.split("?").shift().toLowerCase(),p=f.slice(f.lastIndexOf(".")+1);h=h||Xt.mimeTypes.get(p)||`video/${p}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}e=o}super(e);u(this,"_spf",0);u(this,"_autoPlay",!1);u(this,"_sourceLoad");u(this,"_nextTime",0);u(this,"_connected",!1);u(this,"_requestId");u(this,"_resolve");u(this,"_reject");u(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});u(this,"_onPlayStop",()=>{this._setupAutoUpdate()});u(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),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(fe.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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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&&(fe.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||(fe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(fe.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(Xt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Xt);qo([ue({default:!0})],Ms.prototype,"autoUpdate"),qo([ue({default:0})],Ms.prototype,"fps");let Wo=Ms;class As extends Ss{}class Xo extends Pe{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",me.EMPTY);u(this,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof me?e=this.strokeStyle:e=new Es(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new Pe(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 tr,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 me?e=this.fillStyle:e=new Es(this.fillStyle)),this._fille.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new tr,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=c=>{e.push({type:c,vertices:t,indices:i,uvs:s,texture:a}),t=[],i=[],s=[],a=void 0};let h=t.length;for(let c=this._fille.length,f=0;f<c;f++){const p=this._fille[f];a??(a=p.texture),a!==p.texture&&l("fill"),o=t.length,p.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(o,t,s,p.texture,p.textureTransform)}t.length-h>0&&l("fill"),h=t.length;for(let c=this._stroke.length,f=0;f<c;f++){o=t.length;const p=this._stroke[f];a??(a=p.texture),p.path.strokeTriangulate({vertices:t,indices:i,lineStyle:p.style,flipAlignment:!1,closed:!0}),this.buildUvs(o,t,s,p.texture,p.textureTransform),l("stroke")}return t.length-h>0&&l("stroke"),e}}var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,nr=(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};d.Node=class extends ti{constructor(e,t=[]){super();u(this,"name",`${this.tag}:${String(this.instanceId)}`);u(this,"mask");u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties(e).append(t).on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}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("treeEnter",e)):t&&(this.emit("treeExit",t),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("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;this._parent=e,this.setTree(e==null?void 0:e._tree),e?this.emit("parented",e):i&&this.emit("unparented",i)}return this}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()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return this._tree.paused;case"when_paused":return!this._tree.paused;case"always":return!0;case"disabled":default:return!1}}canRender(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess();s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let o;if(i){const a=t.renderStack.push(this);o=t.renderStack.currentCall,t.renderStack.currentCall=a}if(this.mask instanceof d.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.addChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}for(let a=this._children.length,l=0;l<a;l++)this._children[l].emit("process",e);i&&(t.renderStack.currentCall=o),s&&(this.emit("processed",e),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,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");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)}append(...e){let t;return Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.addChild(i)}),this}addChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return this;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(o=>o.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":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"default":return h.internalMode!=="front";case"back":return h.internalMode==="back";case"front":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"front":return h.internalMode!=="front";case"default":return h.internalMode==="back";case"back":default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=at(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.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}is(e){return!!(e&&this.instanceId===e.instanceId)}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.getChildren().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=ei.get(t)??d.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},nr([M()],d.Node.prototype,"name",2),nr([M()],d.Node.prototype,"mask",2),nr([M({default:"inherit"})],d.Node.prototype,"processMode",2),nr([M({default:"inherit"})],d.Node.prototype,"renderMode",2),nr([M({default:"default"})],d.Node.prototype,"internalMode",2),d.Node=nr([q("Node")],d.Node);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,pi=(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};d.TimelineNode=class extends d.Node{constructor(e,t=[]){super();u(this,"computedDuration",0);u(this,"_currentTime",0);u(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return at(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?at(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime)}}_process(e){this._updateCurrentTime(),super._process(e)}},pi([M({default:0})],d.TimelineNode.prototype,"delay",2),pi([M({default:0})],d.TimelineNode.prototype,"duration",2),pi([M({default:!1})],d.TimelineNode.prototype,"paused",2),d.TimelineNode=pi([q("TimelineNode")],d.TimelineNode);var Cc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,Os=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tc(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};d.CanvasItem=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"opacity",1);u(this,"visible",!0);u(this,"_parentOpacity");u(this,"_parentVisible");u(this,"_modulate",new Ct(4294967295));u(this,"_backgroundImage");u(this,"context",new Xo);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._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new re,this.setProperties(e).append(t)}get style(){return this._style}set style(e){var i;const t=(...s)=>{this.emit("updateStyleProperty",...s),this._updateStyleProperty(s[0],s[1],s[2],s[3])};e.on("updateProperty",t),(i=this._style)==null||i.off("updateProperty",t),this._style=e}setProperties(e){if(e){const{style:t,...i}=e;t&&this.style.setProperties(t),super.setProperties(i)}return this}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"blendMode":this.requestRepaint();break;case"modulate":this._modulate.value=t,this.requestRepaint();break}}_updateStyleProperty(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;case"visibility":this._updateVisible();break}}_updateBackgroundColor(){const e=this.style.getComputedBackgroundColor();this._originalBatchables.length?this.requestRepaint():e.a>0&&this.requestRedraw()}async _updateBackgroundImage(){this._backgroundImage=await this.style.getComputedBackgroundImage(),this.requestRedraw()}_updateOpacity(){var t;const e=this.style.getComputedOpacity()*(((t=this.getParent())==null?void 0:t.opacity)??1);this.opacity!==e&&(this.opacity=e,this.requestRepaint())}_updateCurrentTime(e=!1){super._updateCurrentTime(e),this._updateVisible()}_updateVisible(){var t;let e=this.style.visibility==="visible"&&(((t=this.getParent())==null?void 0:t.visible)??!0);e&&!this.isInsideTimeRange()&&(e=!1),this.visible=e}show(){this.style.visibility="visible"}hide(){this.style.visibility="hidden"}isVisibleInTree(){return this.opacity>0&&this.visible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestReflow(){this._reflowing=!0}requestRepaint(){this._repainting=!0}_process(e){const t=this.getParent();this._parentVisible!==(t==null?void 0:t.visible)&&(this._parentVisible=t==null?void 0:t.visible,this._updateVisible()),this._parentOpacity!==(t==null?void 0:t.opacity)&&(this._parentOpacity=t==null?void 0:t.opacity,this._updateOpacity()),super._process(e)}_draw(){this._drawBackground(),this._drawContent(),this._drawBorder(),this._drawOutline()}_drawBackground(){const e=this._backgroundImage;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height),this._fill())}_drawContent(){this._fill()}_drawBorder(){this.style.borderWidth&&this.style.borderStyle!=="none"&&(this.context.lineWidth=this.style.borderWidth,this.context.strokeStyle=this.style.borderColor,this._stroke())}_drawOutline(){this.style.outlineWidth&&this.style.outlineColor!=="none"&&(this.context.lineWidth=this.style.outlineWidth,this.context.strokeStyle=this.style.outlineColor,this._stroke())}_drawBoundingRect(){const{borderRadius:e,width:t,height:i}=this.style;t&&i&&(e?this.context.roundRect(0,0,t,i,e):this.context.rect(0,0,t,i))}_fill(){this._drawBoundingRect(),this.context.fill()}_stroke(){this._drawBoundingRect(),this.context.stroke()}_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.style.getComputedBackgroundColor().abgr,modulate:this._modulate.toArgb(this.opacity,!0),colorMatrix:t.toMatrix4().toArray(!0),colorMatrixOffset:t.toVector4().toArray(),blendMode:this.blendMode}))}_render(e){let t;this._redrawing?(this.emit("draw"),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}}}},Os([M()],d.CanvasItem.prototype,"modulate",2),Os([M()],d.CanvasItem.prototype,"blendMode",2),d.CanvasItem=Os([q("CanvasItem")],d.CanvasItem);class Ec extends d.Node{constructor(){super(...arguments);u(this,"currentCall");u(this,"calls",[])}createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){var i;const t=this.createCall(e);return(((i=this.currentCall)==null?void 0:i.calls)??this.calls).push(t),t}render(e){this.calls.forEach(function t(i){i.fn(e,()=>{i.calls.forEach(t)})}),this.calls=[]}}var Sc=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Mr=(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};d.Timeline=class extends d.Node{static from(r,e=!1){const[t,i]=r?Array.isArray(r)?r:[0,r]:[];return new d.Timeline({startTime:t,endTime:i,loop:e})}constructor(r){super(),this.setProperties(r)}_updateProperty(r,e,t){switch(super._updateProperty(r,e,t),r){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(r){const e=this.startTime,t=this.endTime;let i=this.currentTime;return i=i+r,this.loop&&i>t&&(i=e+i%t),i=at(e,i,t),this.currentTime=i,this.emit("updateCurrentTime",i,r),this}_process(r){super._process(r),this.addTime(r)}},Mr([M({default:0})],d.Timeline.prototype,"startTime",2),Mr([M({default:0})],d.Timeline.prototype,"currentTime",2),Mr([M({default:Number.MAX_SAFE_INTEGER})],d.Timeline.prototype,"endTime",2),Mr([M({default:!1})],d.Timeline.prototype,"loop",2),d.Timeline=Mr([q("Timeline")],d.Timeline);var Ac=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Ar=(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};d.Viewport=class extends d.Node{constructor(e=!1){super();u(this,"_projection",new Xn);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new As,needsUpload:!1},{texture:new As,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}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)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");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&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),e.framebuffer.bind(this._glFramebuffer(e)),this.upload(e),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),J.draw(e,ir.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))}getRect(){return new ni(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Ar([M({default:0})],d.Viewport.prototype,"x",2),Ar([M({default:0})],d.Viewport.prototype,"y",2),Ar([M({default:0})],d.Viewport.prototype,"width",2),Ar([M({default:0})],d.Viewport.prototype,"height",2),d.Viewport=Ar([q("Viewport")],d.Viewport);var Uc=Object.defineProperty,Ho=(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&&Uc(r,e,i),i};class gi extends oi{constructor(e=new d.Timeline){super();u(this,"renderStack",new Ec);u(this,"root",new d.Viewport(!0).setTree(this));u(this,"timeline");u(this,"_backgroundColor",new Ct);u(this,"_currentViewport");this.timeline=e.setTree(this)}getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=t;break}}_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{pixelRatio:t}=e,{width:i,height:s}=this.root;e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:i*t,height:s*t}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const o=this.root.texture;o.activate(e,0),J.draw(e),e.texture.unbind(o)}}Ho([M({default:!1})],gi.prototype,"paused"),Ho([M()],gi.prototype,"backgroundColor");var Dc=Object.defineProperty,Ic=Object.getOwnPropertyDescriptor,Rc=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ic(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&&Dc(r,e,i),i};d.Node2D=class extends d.CanvasItem{constructor(e,t=[]){super();u(this,"transform",new et);u(this,"_parentTransformDirtyId");this.setProperties(e).append(t)}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":case"height":this.mask instanceof d.Node2D&&(this.mask.style.width=this.style.width,this.mask.style.height=this.style.height),this.requestRedraw();case"scaleX":case"scaleY":case"left":case"top":case"rotate":case"transform":case"transformOrigin":this._updateTransform();break;case"overflow":this._updateOverflow();break}}_updateTransform(){const e=this.getParent(),t=e==null?void 0:e.transform;this._parentTransformDirtyId=t==null?void 0:t.dirtyId;const i=this.style.getComputedTransform().toArray();let s;if(t){const o=t.toArray();s=[i[0]*o[0]+i[3]*o[1],i[1]*o[0]+i[4]*o[1],i[2]*o[0]+i[5]*o[1]+o[2],i[0]*o[3]+i[3]*o[4],i[1]*o[3]+i[4]*o[4],i[2]*o[3]+i[5]*o[4]+o[5],0,0,1]}else s=i;this.transform.set(s),this._updateOverflow(),this.requestReflow()}_updateOverflow(){if(this.style.overflow==="hidden"){const[e,t,i,s,o,a]=this.transform.toArray(),l=this.style.width,h=this.style.height;this.mask={x:i,y:a,width:e*l+t*h,height:s*l+o*h}}else this.mask=void 0}_transformVertices(e){const[t,i,s,o,a,l]=this.transform.toArray(),h=e.slice();for(let c=e.length,f=0;f<c;f+=2){const p=e[f],m=e[f+1];h[f]=t*p+i*m+s,h[f+1]=o*p+a*m+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,t){if(super._input(e,t),!e.target&&this.isVisibleInTree()&&this.style.canPointeEvents())switch(t){case"pointerdown":case"pointermove":case"pointerup":{const{screenX:i,screenY:s}=e;if(i&&s){const{width:o,height:a}=this.style,[l,h]=this.transform.inverse().applyToPoint(i,s);l>=0&&l<o&&h>=0&&h<a&&(e.target=this,this.emit(t,e))}break}}}clone(){return new this.constructor(this.toJSON(),this.getChildren(!0))}},d.Node2D=Rc([q("Node2D")],d.Node2D);var Bc=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,ye=(n,r,e,t)=>{for(var i=t>1?void 0:t?Lc(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};function ve(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})}}d.Graphics2D=class extends d.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}},ye([ve()],d.Graphics2D.prototype,"lineCap",2),ye([ve()],d.Graphics2D.prototype,"lineJoin",2),ye([ve()],d.Graphics2D.prototype,"fillStyle",2),ye([ve()],d.Graphics2D.prototype,"strokeStyle",2),ye([ve()],d.Graphics2D.prototype,"lineWidth",2),ye([ve()],d.Graphics2D.prototype,"miterLimit",2),ye([ve({method:!0})],d.Graphics2D.prototype,"rect",2),ye([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"fillRect",2),ye([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"strokeRect",2),ye([ve({method:!0})],d.Graphics2D.prototype,"roundRect",2),ye([ve({method:!0})],d.Graphics2D.prototype,"ellipse",2),ye([ve({method:!0})],d.Graphics2D.prototype,"arc",2),ye([ve({method:!0})],d.Graphics2D.prototype,"beginPath",2),ye([ve({method:!0})],d.Graphics2D.prototype,"moveTo",2),ye([ve({method:!0})],d.Graphics2D.prototype,"lineTo",2),ye([ve({method:!0})],d.Graphics2D.prototype,"closePath",2),ye([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"fill",2),ye([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"stroke",2),d.Graphics2D=ye([q("Graphics2D")],d.Graphics2D);class mi extends yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof me)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 kc=Object.defineProperty,Nc=Object.getOwnPropertyDescriptor,yi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nc(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&&kc(r,e,i),i};d.Image2D=class extends d.Node2D{constructor(e,t=[]){super();u(this,"resource");u(this,"_frameIndex",0);u(this,"_complete",!1);u(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get currentTexture(){var e,t;return(t=(e=this.resource)==null?void 0:e.frames[this._frameIndex])==null?void 0:t.texture}get framesDuration(){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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}decode(){return this._wait}setResource(e){let t;if(e instanceof mi?t=e:t=new mi(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 Pt.gif.load(e):await Pt.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}_getFrameCurrentTime(){const e=this.framesDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.resource)return this;const e=this._getFrameCurrentTime(),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 et().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))}},yi([ue()],d.Image2D.prototype,"resource",2),yi([M({default:!1})],d.Image2D.prototype,"gif",2),yi([M({default:""})],d.Image2D.prototype,"src",2),d.Image2D=yi([q("Image2D")],d.Image2D);class _i extends d.Node2D{constructor(){super(...arguments);u(this,"texture")}getRect(){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 ni(e,t,i,s)}_drawContent(){var e;(e=this.texture)!=null&&e.valid&&(this.context.fillStyle=this.texture,this.context.textureTransform=new et().scale(this.style.width/this.texture.width,this.style.height/this.texture.height),super._drawContent())}}var $c=Object.defineProperty,Fc=Object.getOwnPropertyDescriptor,Yo=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&$c(r,e,i),i};d.Lottie2D=class extends _i{constructor(e,t=[]){super();u(this,"texture",new Sr);u(this,"animation");this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._load();break}}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await Pt.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.currentTime,!1),this.texture.requestUpload(),this.requestRepaint(),super._process(e)}},Yo([M({default:""})],d.Lottie2D.prototype,"src",2),d.Lottie2D=Yo([q("Lottie2D")],d.Lottie2D);var Ae=Uint8Array,Ge=Uint16Array,Us=Int32Array,vi=new Ae([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]),bi=new Ae([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]),Ds=new Ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zo=function(n,r){for(var e=new Ge(31),t=0;t<31;++t)e[t]=r+=1<<n[t-1];for(var i=new Us(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}},Ko=Zo(vi,2),Jo=Ko.b,Is=Ko.r;Jo[28]=258,Is[258]=28;for(var Qo=Zo(bi,0),zc=Qo.b,ea=Qo.r,Rs=new Ge(32768),te=0;te<32768;++te){var St=(te&43690)>>1|(te&21845)<<1;St=(St&52428)>>2|(St&13107)<<2,St=(St&61680)>>4|(St&3855)<<4,Rs[te]=((St&65280)>>8|(St&255)<<8)>>1}for(var ct=function(n,r,e){for(var t=n.length,i=0,s=new Ge(r);i<t;++i)n[i]&&++s[n[i]-1];var o=new Ge(r);for(i=1;i<r;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(e){a=new Ge(1<<r);var l=15-r;for(i=0;i<t;++i)if(n[i])for(var h=i<<4|n[i],c=r-n[i],f=o[n[i]-1]++<<c,p=f|(1<<c)-1;f<=p;++f)a[Rs[f]>>l]=h}else for(a=new Ge(t),i=0;i<t;++i)n[i]&&(a[i]=Rs[o[n[i]-1]++]>>15-n[i]);return a},Mt=new Ae(288),te=0;te<144;++te)Mt[te]=8;for(var te=144;te<256;++te)Mt[te]=9;for(var te=256;te<280;++te)Mt[te]=7;for(var te=280;te<288;++te)Mt[te]=8;for(var Or=new Ae(32),te=0;te<32;++te)Or[te]=5;var Vc=ct(Mt,9,0),jc=ct(Mt,9,1),Gc=ct(Or,5,0),qc=ct(Or,5,1),Bs=function(n){for(var r=n[0],e=1;e<n.length;++e)n[e]>r&&(r=n[e]);return r},tt=function(n,r,e){var t=r/8|0;return(n[t]|n[t+1]<<8)>>(r&7)&e},Ls=function(n,r){var e=r/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(r&7)},ks=function(n){return(n+7)/8|0},ta=function(n,r,e){return(e==null||e>n.length)&&(e=n.length),new Ae(n.subarray(r,e))},Wc=["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"],rt=function(n,r,e){var t=new Error(r||Wc[n]);if(t.code=n,Error.captureStackTrace&&Error.captureStackTrace(t,rt),!e)throw t;return t},Xc=function(n,r,e,t){var i=n.length,s=0;if(!i||r.f&&!r.l)return e||new Ae(0);var o=!e,a=o||r.i!=2,l=r.i;o&&(e=new Ae(i*3));var h=function(Ne){var ze=e.length;if(Ne>ze){var Se=new Ae(Math.max(ze*2,Ne));Se.set(e),e=Se}},c=r.f||0,f=r.p||0,p=r.b||0,m=r.l,g=r.d,_=r.m,y=r.n,S=i*8;do{if(!m){c=tt(n,f,1);var T=tt(n,f+1,3);if(f+=3,T)if(T==1)m=jc,g=qc,_=9,y=5;else if(T==2){var v=tt(n,f,31)+257,x=tt(n,f+10,15)+4,C=v+tt(n,f+5,31)+1;f+=14;for(var D=new Ae(C),$=new Ae(19),B=0;B<x;++B)$[Ds[B]]=tt(n,f+B*3,7);f+=x*3;for(var U=Bs($),V=(1<<U)-1,A=ct($,U,1),B=0;B<C;){var N=A[tt(n,f,V)];f+=N&15;var P=N>>4;if(P<16)D[B++]=P;else{var W=0,R=0;for(P==16?(R=3+tt(n,f,3),f+=2,W=D[B-1]):P==17?(R=3+tt(n,f,7),f+=3):P==18&&(R=11+tt(n,f,127),f+=7);R--;)D[B++]=W}}var I=D.subarray(0,v),j=D.subarray(v);_=Bs(I),y=Bs(j),m=ct(I,_,1),g=ct(j,y,1)}else rt(1);else{var P=ks(f)+4,E=n[P-4]|n[P-3]<<8,w=P+E;if(w>i){l&&rt(0);break}a&&h(p+E),e.set(n.subarray(P,w),p),r.b=p+=E,r.p=f=w*8,r.f=c;continue}if(f>S){l&&rt(0);break}}a&&h(p+131072);for(var k=(1<<_)-1,L=(1<<y)-1,K=f;;K=f){var W=m[Ls(n,f)&k],H=W>>4;if(f+=W&15,f>S){l&&rt(0);break}if(W||rt(2),H<256)e[p++]=H;else if(H==256){K=f,m=null;break}else{var X=H-254;if(H>264){var B=H-257,G=vi[B];X=tt(n,f,(1<<G)-1)+Jo[B],f+=G}var ee=g[Ls(n,f)&L],Y=ee>>4;ee||rt(3),f+=ee&15;var j=zc[Y];if(Y>3){var G=bi[Y];j+=Ls(n,f)&(1<<G)-1,f+=G}if(f>S){l&&rt(0);break}a&&h(p+131072);var ae=p+X;if(p<j){var pt=s-j,Ke=Math.min(j,ae);for(pt+p<0&&rt(3);p<Ke;++p)e[p]=t[pt+p]}for(;p<ae;++p)e[p]=e[p-j]}}r.l=m,r.p=K,r.b=p,r.f=c,m&&(c=1,r.m=_,r.d=g,r.n=y)}while(!c);return p!=e.length&&o?ta(e,0,p):e.subarray(0,p)},bt=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8},Ur=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},Ns=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:na,l:0};if(i==1){var o=new Ae(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort(function(w,v){return w.f-v.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,c=1,f=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=e[e[h].f<e[f].f?h++:f++],l=e[h!=c&&e[h].f<e[f].f?h++:f++],e[c++]={s:-1,f:a.f+l.f,l:a,r:l};for(var p=s[0].s,t=1;t<i;++t)s[t].s>p&&(p=s[t].s);var m=new Ge(p+1),g=$s(e[c-1],m,0);if(g>r){var t=0,_=0,y=g-r,S=1<<y;for(s.sort(function(v,x){return m[x.s]-m[v.s]||v.f-x.f});t<i;++t){var T=s[t].s;if(m[T]>r)_+=S-(1<<g-m[T]),m[T]=r;else break}for(_>>=y;_>0;){var P=s[t].s;m[P]<r?_-=1<<r-m[P]++-1:++t}for(;t>=0&&_;--t){var E=s[t].s;m[E]==r&&(--m[E],++_)}g=r}return{t:new Ae(m),l:g}},$s=function(n,r,e){return n.s==-1?Math.max($s(n.l,r,e+1),$s(n.r,r,e+1)):r[n.s]=e},ra=function(n){for(var r=n.length;r&&!n[--r];);for(var e=new Ge(++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}},Dr=function(n,r){for(var e=0,t=0;t<r.length;++t)e+=n[t]*r[t];return e},ia=function(n,r,e){var t=e.length,i=ks(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},sa=function(n,r,e,t,i,s,o,a,l,h,c){bt(r,c++,e),++i[256];for(var f=Ns(i,15),p=f.t,m=f.l,g=Ns(s,15),_=g.t,y=g.l,S=ra(p),T=S.c,P=S.n,E=ra(_),w=E.c,v=E.n,x=new Ge(19),C=0;C<T.length;++C)++x[T[C]&31];for(var C=0;C<w.length;++C)++x[w[C]&31];for(var D=Ns(x,7),$=D.t,B=D.l,U=19;U>4&&!$[Ds[U-1]];--U);var V=h+5<<3,A=Dr(i,Mt)+Dr(s,Or)+o,N=Dr(i,p)+Dr(s,_)+o+14+3*U+Dr(x,$)+2*x[16]+3*x[17]+7*x[18];if(l>=0&&V<=A&&V<=N)return ia(r,c,n.subarray(l,l+h));var W,R,I,j;if(bt(r,c,1+(N<A)),c+=2,N<A){W=ct(p,m,0),R=p,I=ct(_,y,0),j=_;var k=ct($,B,0);bt(r,c,P-257),bt(r,c+5,v-1),bt(r,c+10,U-4),c+=14;for(var C=0;C<U;++C)bt(r,c+3*C,$[Ds[C]]);c+=3*U;for(var L=[T,w],K=0;K<2;++K)for(var H=L[K],C=0;C<H.length;++C){var X=H[C]&31;bt(r,c,k[X]),c+=$[X],X>15&&(bt(r,c,H[C]>>5&127),c+=H[C]>>12)}}else W=Vc,R=Mt,I=Gc,j=Or;for(var C=0;C<a;++C){var G=t[C];if(G>255){var X=G>>18&31;Ur(r,c,W[X+257]),c+=R[X+257],X>7&&(bt(r,c,G>>23&31),c+=vi[X]);var ee=G&31;Ur(r,c,I[ee]),c+=j[ee],ee>3&&(Ur(r,c,G>>5&8191),c+=bi[ee])}else Ur(r,c,W[G]),c+=R[G]}return Ur(r,c,W[256]),c+R[256]},Hc=new Us([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),na=new Ae(0),Yc=function(n,r,e,t,i,s){var o=s.z||n.length,a=new Ae(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=Hc[r-1],p=f>>13,m=f&8191,g=(1<<e)-1,_=s.p||new Ge(32768),y=s.h||new Ge(g+1),S=Math.ceil(e/3),T=2*S,P=function(Ve){return(n[Ve]^n[Ve+1]<<S^n[Ve+2]<<T)&g},E=new Us(25e3),w=new Ge(288),v=new Ge(32),x=0,C=0,D=s.i||0,$=0,B=s.w||0,U=0;D+2<o;++D){var V=P(D),A=D&32767,N=y[V];if(_[A]=N,y[V]=A,B<=D){var W=o-D;if((x>7e3||$>24576)&&(W>423||!h)){c=sa(n,l,0,E,w,v,C,$,U,D-U,c),$=x=C=0,U=D;for(var R=0;R<286;++R)w[R]=0;for(var R=0;R<30;++R)v[R]=0}var I=2,j=0,k=m,L=A-N&32767;if(W>2&&V==P(D-L))for(var K=Math.min(p,W)-1,H=Math.min(32767,D),X=Math.min(258,W);L<=H&&--k&&A!=N;){if(n[D+I]==n[D+I-L]){for(var G=0;G<X&&n[D+G]==n[D+G-L];++G);if(G>I){if(I=G,j=L,G>K)break;for(var ee=Math.min(L,G-2),Y=0,R=0;R<ee;++R){var ae=D-L+R&32767,pt=_[ae],Ke=ae-pt&32767;Ke>Y&&(Y=Ke,N=ae)}}}A=N,N=_[A],L+=A-N&32767}if(j){E[$++]=268435456|Is[I]<<18|ea[j];var Ne=Is[I]&31,ze=ea[j]&31;C+=vi[Ne]+bi[ze],++w[257+Ne],++v[ze],B=D+I,++x}else E[$++]=n[D],++w[n[D]]}}for(D=Math.max(D,B);D<o;++D)E[$++]=n[D],++w[n[D]];c=sa(n,l,h,E,w,v,C,$,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 Se=D+65535;Se>=o&&(l[c/8|0]=h,Se=o),c=ia(l,c+1,n.subarray(D,Se))}s.i=o}return ta(a,0,t+ks(c)+i)},oa=function(){var n=1,r=0;return{p:function(e){for(var t=n,i=r,s=e.length|0,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=t+=e[o];t=(t&65535)+15*(t>>16),i=(i&65535)+15*(i>>16)}n=t,r=i},d:function(){return n%=65521,r%=65521,(n&255)<<24|(n&65280)<<8|(r&255)<<8|r>>8}}},Zc=function(n,r,e,t,i){if(!i&&(i={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),o=new Ae(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return Yc(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)},aa=function(n,r,e){for(;e;++r)n[r]=e,e>>>=8},Kc=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=oa();i.p(r.dictionary),aa(n,2,i.d())}},Jc=function(n,r){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&rt(6,"invalid zlib data"),(n[1]>>5&1)==1&&rt(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Qc(n,r){r||(r={});var e=oa();e.p(n);var t=Zc(n,r,r.dictionary?6:2,4);return Kc(t,r),aa(t,t.length-4,e.d()),t}function eu(n,r){return Xc(n.subarray(Jc(n),-4),{i:2},r,r)}var tu=typeof TextDecoder<"u"&&new TextDecoder,ru=0;try{tu.decode(na,{stream:!0}),ru=1}catch{}const iu="modern-font";function Ir(n,r){if(!n)throw new Error(`[${iu}] ${r}`)}function su(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 or(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function nu(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 wi(n){n=nu(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 ou(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 au(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 lu=Object.defineProperty,Oe=(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&&lu(r,e,i),i};const Rr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ue(){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 be extends DataView{constructor(e,t,i,s){super(su(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+=Rr[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+=Rr[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=or(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}}Oe([Ue()],be.prototype,"readInt8"),Oe([Ue()],be.prototype,"readInt16"),Oe([Ue()],be.prototype,"readInt32"),Oe([Ue()],be.prototype,"readUint8"),Oe([Ue()],be.prototype,"readUint16"),Oe([Ue()],be.prototype,"readUint32"),Oe([Ue()],be.prototype,"readFloat32"),Oe([Ue()],be.prototype,"readFloat64"),Oe([Ue()],be.prototype,"writeInt8"),Oe([Ue()],be.prototype,"writeInt16"),Oe([Ue()],be.prototype,"writeInt32"),Oe([Ue()],be.prototype,"writeUint8"),Oe([Ue()],be.prototype,"writeUint16"),Oe([Ue()],be.prototype,"writeUint32"),Oe([Ue()],be.prototype,"writeFloat32"),Oe([Ue()],be.prototype,"writeFloat64");const la=new WeakMap;function b(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=la.get(i);o||(o={columns:[],byteLength:0},la.set(i,o));const a={...r,name:s,byteLength:e*Rr[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+Rr[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 qe{constructor(r,e,t,i){u(this,"view");this.view=new be(r,e,t,i)}}class xi extends qe{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 hu=Object.defineProperty,Re=(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&&hu(r,e,i),i};const Be=class ul extends xi{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=wi(s.fontFamily||""),a=o.length,l=wi(s.fontStyle||""),h=l.length,c=wi(s.version||""),f=c.length,p=wi(s.fullName||""),m=p.length,g=86+a+4+h+4+f+4+m+2+e.view.byteLength,_=new ul(new ArrayBuffer(g),0,g,!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(m),_.view.writeBytes(p),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(e.view),_}};Re([b("uint32")],Be.prototype,"EOTSize"),Re([b("uint32")],Be.prototype,"FontDataSize"),Re([b("uint32")],Be.prototype,"Version"),Re([b("uint32")],Be.prototype,"Flags"),Re([b({type:"uint8",size:10})],Be.prototype,"FontPANOSE"),Re([b("uint8")],Be.prototype,"Charset"),Re([b("uint8")],Be.prototype,"Italic"),Re([b("uint32")],Be.prototype,"Weight"),Re([b("uint16")],Be.prototype,"fsType"),Re([b("uint16")],Be.prototype,"MagicNumber"),Re([b({type:"uint8",size:16})],Be.prototype,"UnicodeRange"),Re([b({type:"uint8",size:8})],Be.prototype,"CodePageRange"),Re([b("uint32")],Be.prototype,"CheckSumAdjustment"),Re([b({type:"uint8",size:16})],Be.prototype,"Reserved"),Re([b("uint16")],Be.prototype,"Padding1");var cu=Object.defineProperty,Pi=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&cu(r,e,i),i};class ar extends qe{constructor(r,e){super(r,e,16)}}Pi([b({type:"char",size:4})],ar.prototype,"tag"),Pi([b("uint32")],ar.prototype,"checkSum"),Pi([b("uint32")],ar.prototype,"offset"),Pi([b("uint32")],ar.prototype,"length");const Fs=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],uu=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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 zs{constructor(r){u(this,"index");u(this,"name");u(this,"isComposite",!1);u(this,"components",[]);u(this,"pathCommands",[]);const e={...r};if(this.index=e.index??0,e.name===".notdef"?e.unicode=void 0:e.name===".null"&&(e.unicode=0),e.unicode===0&&e.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=e.name??null,e.unicode&&(this.unicode=e.unicode),e.unicodes?this.unicodes=e.unicodes:e.unicode&&(this.unicodes=[e.unicode])}getPathCommands(r=0,e=0,t=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*t,{xScale:a=o,yScale:l=o}=i,h=this.pathCommands,c=[];for(let f=0,p=h.length;f<p;f+=1){const m=h[f];m.type==="M"?c.push({type:"M",x:r+m.x*a,y:e+-m.y*l}):m.type==="L"?c.push({type:"L",x:r+m.x*a,y:e+-m.y*l}):m.type==="Q"?c.push({type:"Q",x1:r+m.x1*a,y1:e+-m.y1*l,x:r+m.x*a,y:e+-m.y*l}):m.type==="C"?c.push({type:"C",x1:r+m.x1*a,y1:e+-m.y1*l,x2:r+m.x2*a,y2:e+-m.y2*l,x:r+m.x*a,y:e+-m.y*l}):m.type==="Z"&&c.push({type:"Z"})}return c}}class fu extends zs{parse(r,e,t){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=r,h=r.topDict.paintType,c=this.index;let f,p,m,g;const _=[],y=[];let S=0,T=!1,P=!1,E=o,w=0,v=0;function x(A,N){_.push({type:"L",x:A,y:N})}function C(A,N,W,R,I,j){_.push({type:"C",x1:A,y1:N,x2:W,y2:R,x:I,y:j})}function D(A,N){P&&h!==2&&$(),P=!0,_.push({type:"M",x:A,y:N})}function $(){_.push({type:"Z"})}function B(A){_.push(...A)}function U(){y.length%2!==0&&!T&&(E=y.shift()+s),S+=y.length>>1,y.length=0,T=!0}function V(A){let N,W,R,I,j,k,L,K,H,X,G,ee,Y=0;for(;Y<A.length;){let ae=A[Y++];switch(ae){case 1:U();break;case 3:U();break;case 4:y.length>1&&!T&&(E=y.shift()+s,T=!0),v+=y.pop(),D(w,v);break;case 5:for(;y.length>0;)w+=y.shift(),v+=y.shift(),x(w,v);break;case 6:for(;y.length>0&&(w+=y.shift(),x(w,v),y.length!==0);)v+=y.shift(),x(w,v);break;case 7:for(;y.length>0&&(v+=y.shift(),x(w,v),y.length!==0);)w+=y.shift(),x(w,v);break;case 8:for(;y.length>0;)f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);break;case 10:j=y.pop()+l,k=r.subrs[j],k&&V(k);break;case 11:return;case 12:switch(ae=A[Y],Y+=1,ae){case 35:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),L=m+y.shift(),K=g+y.shift(),H=L+y.shift(),X=K+y.shift(),G=H+y.shift(),ee=X+y.shift(),w=G+y.shift(),v=ee+y.shift(),y.shift(),C(f,p,m,g,L,K),C(H,X,G,ee,w,v);break;case 34:f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),L=m+y.shift(),K=g,H=L+y.shift(),X=g,G=H+y.shift(),ee=v,w=G+y.shift(),C(f,p,m,g,L,K),C(H,X,G,ee,w,v);break;case 36:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),L=m+y.shift(),K=g,H=L+y.shift(),X=g,G=H+y.shift(),ee=X+y.shift(),w=G+y.shift(),C(f,p,m,g,L,K),C(H,X,G,ee,w,v);break;case 37:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),L=m+y.shift(),K=g+y.shift(),H=L+y.shift(),X=K+y.shift(),G=H+y.shift(),ee=X+y.shift(),Math.abs(G-w)>Math.abs(ee-v)?w=G+y.shift():v=ee+y.shift(),C(f,p,m,g,L,K),C(H,X,G,ee,w,v);break;default:console.warn(`Glyph ${c}: unknown operator ${1200+ae}`),y.length=0}break;case 14:if(y.length>=4){const pt=Fs[y.pop()],Ke=Fs[y.pop()],Ne=y.pop(),ze=y.pop();if(pt&&Ke){i.isComposite=!0,i.components=[];const Se=r.charset.indexOf(pt),Ve=r.charset.indexOf(Ke);i.components.push({glyphIndex:Ve,dx:0,dy:0}),i.components.push({glyphIndex:Se,dx:ze,dy:Ne}),B(t.get(Ve).pathCommands);const it=JSON.parse(JSON.stringify(t.get(Se).pathCommands));for(let st=0;st<it.length;st+=1){const Je=it[st];Je.type!=="Z"&&(Je.x+=ze,Je.y+=Ne),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=ze,Je.y1+=Ne),Je.type==="C"&&(Je.x2+=ze,Je.y2+=Ne)}B(it)}}else y.length>0&&!T&&(E=y.shift()+s,T=!0);P&&h!==2&&($(),P=!1);break;case 18:U();break;case 19:case 20:U(),Y+=S+7>>3;break;case 21:y.length>2&&!T&&(E=y.shift()+s,T=!0),v+=y.pop(),w+=y.pop(),D(w,v);break;case 22:y.length>1&&!T&&(E=y.shift()+s,T=!0),w+=y.pop(),D(w,v);break;case 23:U();break;case 24:for(;y.length>2;)f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);w+=y.shift(),v+=y.shift(),x(w,v);break;case 25:for(;y.length>6;)w+=y.shift(),v+=y.shift(),x(w,v);f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);break;case 26:for(y.length%2&&(w+=y.shift());y.length>0;)f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m,v=g+y.shift(),C(f,p,m,g,w,v);break;case 27:for(y.length%2&&(v+=y.shift());y.length>0;)f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g,C(f,p,m,g,w,v);break;case 28:N=A[Y],W=A[Y+1],y.push((N<<24|W<<16)>>16),Y+=2;break;case 29:j=y.pop()+a,k=r.gsubrs[j],k&&V(k);break;case 30:for(;y.length>0&&(f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+(y.length===1?y.shift():0),C(f,p,m,g,w,v),y.length!==0);)f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),v=g+y.shift(),w=m+(y.length===1?y.shift():0),C(f,p,m,g,w,v);break;case 31:for(;y.length>0&&(f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),v=g+y.shift(),w=m+(y.length===1?y.shift():0),C(f,p,m,g,w,v),y.length!==0);)f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+(y.length===1?y.shift():0),C(f,p,m,g,w,v);break;default:ae<32?console.warn(`Glyph ${c}: unknown operator ${ae}`):ae<247?y.push(ae-139):ae<251?(N=A[Y],Y+=1,y.push((ae-247)*256+N+108)):ae<255?(N=A[Y],Y+=1,y.push(-(ae-251)*256-N-108)):(N=A[Y],W=A[Y+1],R=A[Y+2],I=A[Y+3],Y+=4,y.push((N<<24|W<<16|R<<8|I)/65536))}}}V(e),this.pathCommands=_,T&&(this.advanceWidth=E)}}class Vs{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 du extends Vs{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(r){const e=this._sfnt.cff,t=new fu({index:r});return t.parse(e,e.charStringsIndex.get(r),this),t.name=e.charset[r],t}}var pu=Object.defineProperty,ha=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&pu(r,e,i),i};class Ci extends qe{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)}}ha([b("uint16")],Ci.prototype,"count"),ha([b("uint8")],Ci.prototype,"offsetSize");class Ti extends Ci{constructor(){super(...arguments);u(this,"_isString",!1)}}class ca extends Ci{constructor(){super(...arguments);u(this,"_isString",!0)}}const gu=[".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"],mu=[".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"],yu=[".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"],_u=[".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 Ei(n,r){return r<=390?gu[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 ua extends qe{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 Ei(((i=this._stringIndex)==null?void 0:i.objects)??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var vu=Object.defineProperty,js=(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};class Si extends ua{}js([ie(19)],Si.prototype,"subrs"),js([ie(20)],Si.prototype,"defaultWidthX"),js([ie(21)],Si.prototype,"nominalWidthX");var bu=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&&bu(r,e,i),i};class oe extends ua{}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 Ce(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 Ht=class Ht{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 numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}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 Ht(this.tableViews)}delete(r){const e=Ht.tableDefinitions.get(r);return e?(this.tableViews.delete(r),this.tables.delete(e.prop),this):this}set(r,e){const t=Ht.tableDefinitions.get(r);return t&&this.tables.set(t.prop,e),this.tableViews.set(r,e.view),this}get(r){const e=Ht.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(Ht,"tableDefinitions",new Map);let Ft=Ht;class De extends qe{setSFNT(r){return this._sfnt=r,this}getSFNT(){return this._sfnt}}var wu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Br=(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 zt=class extends De{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 du(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 ca(e,i),this.topDictIndex=new Ti(e,this.nameIndex.endOffset),this.stringIndex=new ca(e,this.topDictIndex.endOffset),this.globalSubrIndex=new Ti(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 Si(e,t+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Ti(e,t+o+this.privateDict.subrs))),this.charStringsIndex=new Ti(e,t+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=mu:this.topDict.charset===1?this.charset=yu:this.topDict.charset===2?this.charset=_u:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=Fs:this.topDict.encoding===1?this.encoding=uu: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(Ei(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(Ei(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(Ei(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}};Br([b("uint8")],zt.prototype,"majorVersion",2),Br([b("uint8")],zt.prototype,"minorVersion",2),Br([b("uint8")],zt.prototype,"headerSize",2),Br([b("uint8")],zt.prototype,"offsetSize",2),zt=Br([Ce("CFF ","cff")],zt);var Pu=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&&Pu(r,e,i),i};const Lr=class fl extends qe{constructor(r=new ArrayBuffer(262),e){super(r,e,262)}static from(r){const e=new fl;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}};Mi([b("uint16")],Lr.prototype,"format"),Mi([b("uint16")],Lr.prototype,"length"),Mi([b("uint16")],Lr.prototype,"language"),Mi([b({type:"uint8",size:256})],Lr.prototype,"glyphIndexArray");let Gs=Lr;var Cu=Object.defineProperty,qs=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&Cu(r,e,i),i};class kr extends qe{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((r,e)=>Math.max(r,e),0)}get subHeaders(){const r=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:r},(e,t)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(r-t)*8-2)/2}))}get glyphIndexArray(){const r=this.maxSubHeaderKey,e=6+256*2+r*8;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(r){const e=new Map,t=this.subHeaderKeys,i=this.maxSubHeaderKey,s=this.subHeaders,o=this.glyphIndexArray,a=t.findIndex(h=>h===i);let l=0;for(let h=0;h<256;h++)if(t[h]===0)h>=a||h<s[0].firstCode||h>=s[0].firstCode+s[0].entryCount||s[0].idRangeOffset+(h-s[0].firstCode)>=o.length?l=0:(l=o[s[0].idRangeOffset+(h-s[0].firstCode)],l!==0&&(l=l+s[0].idDelta)),l!==0&&l<r&&e.set(h,l);else{const c=t[h];for(let f=0,p=s[c].entryCount;f<p;f++)if(s[c].idRangeOffset+f>=o.length?l=0:(l=o[s[c].idRangeOffset+f],l!==0&&(l=l+s[c].idDelta)),l!==0&&l<r){const m=(h<<8|f+s[c].firstCode)%65535;e.set(m,l)}}return e}}qs([b("uint16")],kr.prototype,"format"),qs([b("uint16")],kr.prototype,"length"),qs([b("uint16")],kr.prototype,"language");function fa(n){return n>32767?n-65536:n<-32767?n+65536:n}function Ws(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:fa(s-o)}):(i.start=Number(o),i.startId=s,i.delta=fa(s-o))),e={unicode:o,glyphIndex:s})}),e&&(i.end=e.unicode,t.push(i)),t}var Tu=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&&Tu(r,e,i),i};const At=class dl extends qe{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=Ws(r,65535),t=e.length+1,i=Math.floor(Math.log(t)/Math.LN2),s=2*2**i,o=new dl(new ArrayBuffer(24+e.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=t*2,o.searchRange=s,o.entrySelector=i,o.rangeShift=2*t-s,o.endCode=[...e.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...e.map(a=>a.start),65535],o.idDelta=[...e.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:t},()=>0),o}getUnicodeToGlyphIndexMap(){const r=new Map,e=this.segCountX2/2,t=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,s=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<e;++h)for(let c=i[h],f=s[h];c<=f;++c)if(o[h]===0)r.set(c,(c+a[h])%65536);else{const p=h+o[h]/2+(c-i[h])-t,m=l[p];m!==0?r.set(c,(m+a[h])%65536):r.set(c,0)}return r.delete(65535),r}};Vt([b("uint16")],At.prototype,"format"),Vt([b("uint16")],At.prototype,"length"),Vt([b("uint16")],At.prototype,"language"),Vt([b("uint16")],At.prototype,"segCountX2"),Vt([b("uint16")],At.prototype,"searchRange"),Vt([b("uint16")],At.prototype,"entrySelector"),Vt([b("uint16")],At.prototype,"rangeShift");let Xs=At;var Eu=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&&Eu(r,e,i),i};class jt extends qe{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}}Nr([b("uint16")],jt.prototype,"format"),Nr([b("uint16")],jt.prototype,"length"),Nr([b("uint16")],jt.prototype,"language"),Nr([b("uint16")],jt.prototype,"firstCode"),Nr([b("uint16")],jt.prototype,"entryCount");var Su=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&&Su(r,e,i),i};const lr=class pl extends qe{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=Ws(r),t=new pl(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}};$r([b("uint16")],lr.prototype,"format"),$r([b("uint16")],lr.prototype,"reserved"),$r([b("uint32")],lr.prototype,"length"),$r([b("uint32")],lr.prototype,"language"),$r([b("uint32")],lr.prototype,"nGroups");let Hs=lr;var Mu=Object.defineProperty,Ys=(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 Fr extends qe{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}}Ys([b("uint16")],Fr.prototype,"format"),Ys([b("uint32")],Fr.prototype,"length"),Ys([b("uint32")],Fr.prototype,"numVarSelectorRecords");var Au=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,Zs=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ou(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&&Au(r,e,i),i};let hr=class extends De{constructor(){super(...arguments);u(this,"_unicodeToGlyphIndexMap");u(this,"_glyphIndexToUnicodesMap")}static from(r){const e=Array.from(r.keys()).some(f=>f>65535),t=Xs.from(r),i=Gs.from(r),s=e?Hs.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 hr(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 Gs(this.view.buffer,e.offset);break;case 2:i=new kr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:i=new Xs(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 Hs(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(p=>p.format===0))==null?void 0:a.view,t=(l=r.find(p=>p.platformID===3&&p.platformSpecificID===3&&p.format===2))==null?void 0:l.view,i=(h=r.find(p=>p.platformID===3&&p.platformSpecificID===1&&p.format===4))==null?void 0:h.view,s=(c=r.find(p=>p.platformID===3&&p.platformSpecificID===10&&p.format===12))==null?void 0:c.view,o=(f=r.find(p=>p.platformID===0&&p.platformSpecificID===5&&p.format===14))==null?void 0:f.view;return new Map([...(e==null?void 0:e.getUnicodeToGlyphIndexMap())??[],...(t==null?void 0:t.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(i==null?void 0:i.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};Zs([b("uint16")],hr.prototype,"version",2),Zs([b("uint16")],hr.prototype,"numberSubtables",2),hr=Zs([Ce("cmap")],hr);class Uu extends zs{_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 Ir(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();Ir(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;Ir(f<2e4,`Bad numberOfCoordinates:${c}`);const p=[];let m,g=0;for(;g<f;)if(m=r.view.readUint8(),p.push(m),g++,m&8&&g<f){const _=r.view.readUint8();for(let y=0;y<_;y++)p.push(m),g++}if(Ir(p.length===f,`Bad flags length: ${p.length}, numberOfCoordinates: ${f}`),a.length>0){const _=[];let y;if(f>0){for(let P=0;P<f;P+=1)m=p[P],y={},y.onCurve=!!(m&1),y.lastPointOfContour=a.includes(P),_.push(y);let S=0;for(let P=0;P<f;P+=1)m=p[P],y=_[P],y.x=this._parseGlyphCoordinate(r,m,S,2,16),S=y.x;let T=0;for(let P=0;P<f;P+=1)m=p[P],y=_[P],y.y=this._parseGlyphCoordinate(r,m,T,4,32),T=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{Ir(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const f=this.points[l.matchedPoints[0]];let p=h.points[l.matchedPoints[1]];const m={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};p=this._transformPoints([p],m)[0],m.dx=f.x-p.x,m.dy=f.y-p.y,c=this._transformPoints(h.points,m)}this.points=this.points.concat(c)}}const s=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const h=o[a];let c=h[h.length-1],f=h[0];c.onCurve?s.push({type:"M",x:c.x,y:c.y}):f.onCurve?s.push({type:"M",x:f.x,y:f.y}):s.push({type:"M",x:(c.x+f.x)*.5,y:(c.y+f.y)*.5});for(let p=0,m=h.length;p<m;++p)if(c=f,f=h[(p+1)%m],c.onCurve)s.push({type:"L",x:c.x,y:c.y});else{let g=f;f.onCurve||(g={x:(c.x+f.x)*.5,y:(c.y+f.y)*.5}),s.push({type:"Q",x1:c.x,y1:c.y,x:g.x,y:g.y})}s.push({type:"Z"})}this.pathCommands=s}}class Du extends Vs{get length(){return this._sfnt.loca.locations.length}_get(r){const e=this._sfnt.loca.locations,t=e[r],i=new Uu({index:r});return t!==e[r+1]&&i.parse(this._sfnt.glyf,t,this),i}}var Iu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Bu=(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 Ai=class extends De{constructor(){super(...arguments);u(this,"_glyphs")}static from(r){const e=r.reduce((i,s)=>i+s.byteLength,0),t=new Ai(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeBytes(i)}),t}get glyphs(){return this._glyphs??(this._glyphs=new Du(this._sfnt))}};Ai=Bu([Ce("glyf")],Ai);var Lu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,Nu=(n,r,e,t)=>{for(var i=t>1?void 0:t?ku(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Lu(r,e,i),i};let Ks=class extends De{};Ks=Nu([Ce("GPOS","gpos")],Ks);var $u=Object.defineProperty,Fu=Object.getOwnPropertyDescriptor,Gt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fu(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 wt=class extends De{};Gt([b("uint16")],wt.prototype,"majorVersion",2),Gt([b("uint16")],wt.prototype,"minorVersion",2),Gt([b("uint16")],wt.prototype,"scriptListOffset",2),Gt([b("uint16")],wt.prototype,"featureListOffset",2),Gt([b("uint16")],wt.prototype,"lookupListOffset",2),Gt([b("uint16")],wt.prototype,"featureVariationsOffset",2),wt=Gt([Ce("GSUB","gsub")],wt);var zu=Object.defineProperty,Vu=Object.getOwnPropertyDescriptor,we=(n,r,e,t)=>{for(var i=t>1?void 0:t?Vu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&zu(r,e,i),i};let ge=class extends De{constructor(n=new ArrayBuffer(54),r){super(n,r,Math.min(54,n.byteLength-(r??0)))}};we([b("fixed")],ge.prototype,"version",2),we([b("fixed")],ge.prototype,"fontRevision",2),we([b("uint32")],ge.prototype,"checkSumAdjustment",2),we([b("uint32")],ge.prototype,"magickNumber",2),we([b("uint16")],ge.prototype,"flags",2),we([b("uint16")],ge.prototype,"unitsPerEm",2),we([b({type:"longDateTime"})],ge.prototype,"created",2),we([b({type:"longDateTime"})],ge.prototype,"modified",2),we([b("int16")],ge.prototype,"xMin",2),we([b("int16")],ge.prototype,"yMin",2),we([b("int16")],ge.prototype,"xMax",2),we([b("int16")],ge.prototype,"yMax",2),we([b("uint16")],ge.prototype,"macStyle",2),we([b("uint16")],ge.prototype,"lowestRecPPEM",2),we([b("int16")],ge.prototype,"fontDirectionHint",2),we([b("int16")],ge.prototype,"indexToLocFormat",2),we([b("int16")],ge.prototype,"glyphDataFormat",2),ge=we([Ce("head")],ge);var ju=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,Le=(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 Te=class extends De{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Le([b("fixed")],Te.prototype,"version",2),Le([b("int16")],Te.prototype,"ascent",2),Le([b("int16")],Te.prototype,"descent",2),Le([b("int16")],Te.prototype,"lineGap",2),Le([b("uint16")],Te.prototype,"advanceWidthMax",2),Le([b("int16")],Te.prototype,"minLeftSideBearing",2),Le([b("int16")],Te.prototype,"minRightSideBearing",2),Le([b("int16")],Te.prototype,"xMaxExtent",2),Le([b("int16")],Te.prototype,"caretSlopeRise",2),Le([b("int16")],Te.prototype,"caretSlopeRun",2),Le([b("int16")],Te.prototype,"caretOffset",2),Le([b({type:"int16",size:4})],Te.prototype,"reserved",2),Le([b("int16")],Te.prototype,"metricDataFormat",2),Le([b("uint16")],Te.prototype,"numOfLongHorMetrics",2),Te=Le([Ce("hhea")],Te);var qu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Xu=(n,r,e,t)=>{for(var i=t>1?void 0:t?Wu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&qu(r,e,i),i};let Oi=class extends De{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Oi(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()}))}};Oi=Xu([Ce("hmtx")],Oi);var Hu=Object.defineProperty,Yu=Object.getOwnPropertyDescriptor,Zu=(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};let Js=class extends De{};Js=Zu([Ce("kern","kern")],Js);var Ku=Object.defineProperty,Ju=Object.getOwnPropertyDescriptor,Qu=(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 Ui=class extends De{constructor(){super(...arguments);u(this,"_locations")}static from(r,e=1){const t=r.length*(e?4:2),i=new Ui(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)}};Ui=Qu([Ce("loca")],Ui);var ef=Object.defineProperty,tf=Object.getOwnPropertyDescriptor,Ie=(n,r,e,t)=>{for(var i=t>1?void 0:t?tf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ef(r,e,i),i};let xe=class extends De{constructor(n=new ArrayBuffer(32),r){super(n,r,Math.min(32,n.byteLength-(r??0)))}};Ie([b("fixed")],xe.prototype,"version",2),Ie([b("uint16")],xe.prototype,"numGlyphs",2),Ie([b("uint16")],xe.prototype,"maxPoints",2),Ie([b("uint16")],xe.prototype,"maxContours",2),Ie([b("uint16")],xe.prototype,"maxComponentPoints",2),Ie([b("uint16")],xe.prototype,"maxComponentContours",2),Ie([b("uint16")],xe.prototype,"maxZones",2),Ie([b("uint16")],xe.prototype,"maxTwilightPoints",2),Ie([b("uint16")],xe.prototype,"maxStorage",2),Ie([b("uint16")],xe.prototype,"maxFunctionDefs",2),Ie([b("uint16")],xe.prototype,"maxInstructionDefs",2),Ie([b("uint16")],xe.prototype,"maxStackElements",2),Ie([b("uint16")],xe.prototype,"maxSizeOfInstructions",2),Ie([b("uint16")],xe.prototype,"maxComponentElements",2),Ie([b("uint16")],xe.prototype,"maxComponentDepth",2),xe=Ie([Ce("maxp")],xe);var rf=Object.defineProperty,sf=Object.getOwnPropertyDescriptor,Di=(n,r,e,t)=>{for(var i=t>1?void 0:t?sf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&rf(r,e,i),i};const da={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},nf={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},pa={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let cr=class extends De{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=nf.Default,o=0;e.some(l=>l.platform===Qs.Microsoft&&l.encoding===pa.UCS2&&l.language===1033)&&(i=Qs.Microsoft,s=pa.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&&da[h.nameId]&&(a[da[h.nameId]]=o===0?ou(h.name):au(h.name))}return a}};Di([b("uint16")],cr.prototype,"format",2),Di([b("uint16")],cr.prototype,"count",2),Di([b("uint16")],cr.prototype,"stringOffset",2),cr=Di([Ce("name")],cr);var of=Object.defineProperty,af=Object.getOwnPropertyDescriptor,z=(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&&of(r,e,i),i};let F=class extends De{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};z([b("uint16")],F.prototype,"version",2),z([b("int16")],F.prototype,"xAvgCharWidth",2),z([b("uint16")],F.prototype,"usWeightClass",2),z([b("uint16")],F.prototype,"usWidthClass",2),z([b("uint16")],F.prototype,"fsType",2),z([b("uint16")],F.prototype,"ySubscriptXSize",2),z([b("uint16")],F.prototype,"ySubscriptYSize",2),z([b("uint16")],F.prototype,"ySubscriptXOffset",2),z([b("uint16")],F.prototype,"ySubscriptYOffset",2),z([b("uint16")],F.prototype,"ySuperscriptXSize",2),z([b("uint16")],F.prototype,"ySuperscriptYSize",2),z([b("uint16")],F.prototype,"ySuperscriptXOffset",2),z([b("uint16")],F.prototype,"ySuperscriptYOffset",2),z([b("uint16")],F.prototype,"yStrikeoutSize",2),z([b("uint16")],F.prototype,"yStrikeoutPosition",2),z([b("uint16")],F.prototype,"sFamilyClass",2),z([b({type:"uint8"})],F.prototype,"bFamilyType",2),z([b({type:"uint8"})],F.prototype,"bSerifStyle",2),z([b({type:"uint8"})],F.prototype,"bWeight",2),z([b({type:"uint8"})],F.prototype,"bProportion",2),z([b({type:"uint8"})],F.prototype,"bContrast",2),z([b({type:"uint8"})],F.prototype,"bStrokeVariation",2),z([b({type:"uint8"})],F.prototype,"bArmStyle",2),z([b({type:"uint8"})],F.prototype,"bLetterform",2),z([b({type:"uint8"})],F.prototype,"bMidline",2),z([b({type:"uint8"})],F.prototype,"bXHeight",2),z([b({type:"uint8",size:16})],F.prototype,"ulUnicodeRange",2),z([b({type:"char",size:4})],F.prototype,"achVendID",2),z([b("uint16")],F.prototype,"fsSelection",2),z([b("uint16")],F.prototype,"usFirstCharIndex",2),z([b("uint16")],F.prototype,"usLastCharIndex",2),z([b("int16")],F.prototype,"sTypoAscender",2),z([b("int16")],F.prototype,"sTypoDescender",2),z([b("int16")],F.prototype,"sTypoLineGap",2),z([b("uint16")],F.prototype,"usWinAscent",2),z([b("uint16")],F.prototype,"usWinDescent",2),z([b({offset:72,type:"uint8",size:8})],F.prototype,"ulCodePageRange",2),z([b({offset:72,type:"int16"})],F.prototype,"sxHeight",2),z([b("int16")],F.prototype,"sCapHeight",2),z([b("uint16")],F.prototype,"usDefaultChar",2),z([b("uint16")],F.prototype,"usBreakChar",2),z([b("uint16")],F.prototype,"usMaxContext",2),F=z([Ce("OS/2","os2")],F);var lf=Object.defineProperty,hf=Object.getOwnPropertyDescriptor,ut=(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&&lf(r,e,i),i};let Ye=class extends De{constructor(n=new ArrayBuffer(32),r,e){super(n,r,e)}};ut([b("fixed")],Ye.prototype,"format",2),ut([b("fixed")],Ye.prototype,"italicAngle",2),ut([b("int16")],Ye.prototype,"underlinePosition",2),ut([b("int16")],Ye.prototype,"underlineThickness",2),ut([b("uint32")],Ye.prototype,"isFixedPitch",2),ut([b("uint32")],Ye.prototype,"minMemType42",2),ut([b("uint32")],Ye.prototype,"maxMemType42",2),ut([b("uint32")],Ye.prototype,"minMemType1",2),ut([b("uint32")],Ye.prototype,"maxMemType1",2),Ye=ut([Ce("post")],Ye);var cf=Object.defineProperty,uf=Object.getOwnPropertyDescriptor,ke=(n,r,e,t)=>{for(var i=t>1?void 0:t?uf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&cf(r,e,i),i};let Ee=class extends De{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};ke([b("fixed")],Ee.prototype,"version",2),ke([b("int16")],Ee.prototype,"vertTypoAscender",2),ke([b("int16")],Ee.prototype,"vertTypoDescender",2),ke([b("int16")],Ee.prototype,"vertTypoLineGap",2),ke([b("int16")],Ee.prototype,"advanceHeightMax",2),ke([b("int16")],Ee.prototype,"minTopSideBearing",2),ke([b("int16")],Ee.prototype,"minBottomSideBearing",2),ke([b("int16")],Ee.prototype,"yMaxExtent",2),ke([b("int16")],Ee.prototype,"caretSlopeRise",2),ke([b("int16")],Ee.prototype,"caretSlopeRun",2),ke([b("int16")],Ee.prototype,"caretOffset",2),ke([b({type:"int16",size:4})],Ee.prototype,"reserved",2),ke([b("int16")],Ee.prototype,"metricDataFormat",2),ke([b("int16")],Ee.prototype,"numOfLongVerMetrics",2),Ee=ke([Ce("vhea")],Ee);var ff=Object.defineProperty,df=Object.getOwnPropertyDescriptor,pf=(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&&ff(r,e,i),i};let Ii=class extends De{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Ii(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()}))}};Ii=pf([Ce("vmtx")],Ii);var gf=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&&gf(r,e,i),i};class Ze extends xi{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(or(e).getUint32(0))}static checksum(e){const t=or(e);let i=t.byteLength;for(;i%4;)i++;let s=0;for(let o=0,a=i/4;o<a;o+=4)o*4<i-4&&(s+=t.getUint32(o*4,!1));return s&4294967295}static from(e){const t=p=>p+3&-4,i=e.tableViews.size,s=Array.from(e.tableViews.values()).reduce((p,m)=>p+t(m.byteLength),0),o=new this(new ArrayBuffer(12+i*16+s));o.scalerType=65536,o.numTables=i;const a=Math.log(2);o.searchRange=Math.floor(Math.log(i)/a)*16,o.entrySelector=Math.floor(o.searchRange/a),o.rangeShift=i*16-o.searchRange;let l=12+i*16,h=0;const c=o.getDirectories();e.tableViews.forEach((p,m)=>{const g=c[h++];g.tag=m,g.checkSum=this.checksum(p),g.offset=l,g.length=p.byteLength,o.view.writeBytes(p,l),l+=t(g.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 ar(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(Ze,"signature",new Set([65536,1953658213,1954115633])),zr([b("uint32")],Ze.prototype,"scalerType"),zr([b("uint16")],Ze.prototype,"numTables"),zr([b("uint16")],Ze.prototype,"searchRange"),zr([b("uint16")],Ze.prototype,"entrySelector"),zr([b("uint16")],Ze.prototype,"rangeShift");class Ri extends Ze{constructor(){super(...arguments);u(this,"format","OpenType");u(this,"mimeType","font/otf")}static from(e){return super.from(e)}}u(Ri,"signature",new Set([1330926671]));var mf=Object.defineProperty,Vr=(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&&mf(r,e,i),i};class qt extends qe{constructor(r,e){super(r,e,20)}}Vr([b({type:"char",size:4})],qt.prototype,"tag"),Vr([b("uint32")],qt.prototype,"offset"),Vr([b("uint32")],qt.prototype,"compLength"),Vr([b("uint32")],qt.prototype,"origLength"),Vr([b("uint32")],qt.prototype,"origChecksum");var yf=Object.defineProperty,We=(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&&yf(r,e,i),i};const Fe=(Bt=class extends xi{constructor(){super(...arguments);u(this,"format","WOFF");u(this,"mimeType","font/woff");u(this,"_sfnt")}get subfontFormat(){return Ze.is(this.flavor)?"TrueType":Ri.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(or(e).getUint32(0))}static checkSum(e){const t=or(e),i=t.byteLength,s=Math.floor(i/4);let o=0,a=0;for(;a<s;)o+=t.getUint32(4*a++,!1);let l=i-s*4;if(l){let h=s*4;for(;l>0;)o+=t.getUint8(h)<<l*8,h++,l--}return o%4294967296}static from(e,t=new ArrayBuffer(0)){const i=p=>p+3&-4,s=[];e.tableViews.forEach((p,m)=>{const g=or(Qc(new Uint8Array(p.buffer,p.byteOffset,p.byteLength)));s.push({tag:m,view:g.byteLength<p.byteLength?g:p,rawView:p})});const o=s.length,a=s.reduce((p,m)=>p+i(m.view.byteLength),0),l=new Bt(new ArrayBuffer(44+20*o+a+t.byteLength));l.signature=2001684038,l.flavor=65536,l.length=l.view.byteLength,l.numTables=o,l.totalSFNTSize=12+16*o+s.reduce((p,m)=>p+i(m.rawView.byteLength),0);let h=44+o*20,c=0;const f=l.getDirectories();return s.forEach(p=>{const m=f[c++];m.tag=p.tag,m.offset=h,m.compLength=p.view.byteLength,m.origChecksum=Bt.checkSum(p.rawView),m.origLength=p.rawView.byteLength,l.view.writeBytes(p.view,h),h+=i(m.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 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(eu(new Uint8Array(this.view.buffer.slice(s,l))).buffer),e},{}))}},u(Bt,"signature",new Set([2001684038])),Bt);We([b("uint32")],Fe.prototype,"signature"),We([b("uint32")],Fe.prototype,"flavor"),We([b("uint32")],Fe.prototype,"length"),We([b("uint16")],Fe.prototype,"numTables"),We([b("uint16")],Fe.prototype,"reserved"),We([b("uint32")],Fe.prototype,"totalSFNTSize"),We([b("uint16")],Fe.prototype,"majorVersion"),We([b("uint16")],Fe.prototype,"minorVersion"),We([b("uint32")],Fe.prototype,"metaOffset"),We([b("uint32")],Fe.prototype,"metaLength"),We([b("uint32")],Fe.prototype,"metaOrigLength"),We([b("uint32")],Fe.prototype,"privOffset"),We([b("uint32")],Fe.prototype,"privLength");let Bi=Fe;function ga(n,r=!0){if(Ze.is(n))return new Ze(n);if(Ri.is(n))return new Ri(n);if(Bi.is(n))return new Bi(n);if(r)throw new Error("Failed to parseFont")}function ma(n,r=!0){const e=ga(n,!1);if(e)return e;if(r)throw new Error("Failed to parseFont")}const Wi=class Wi{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,{...Wi.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 {
106
- font-family: "${r}";
107
- src: url(${e});
108
- }`)),document.head.appendChild(t),this}_parseUrls(r){const e=Array.from(new Set([...r.split(","),r]));return Array.from(new Set(e.map(t=>this.familyToUrl.get(t.trim())??this.familyToUrl.get(t)??t)))}get(r){let e;return r&&(e=this._parseUrls(r).reduce((i,s)=>i||this.loaded.get(s),void 0)),e??this.fallbackFont}set(r,e){return this.familyToUrl.set(r,e.src),this.loaded.set(e.src,e),this}delete(r){return this._parseUrls(r).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(r,e={}){const{cancelOther:t,injectFontFace:i=!0,injectStyleTag:s=!0,...o}=e,{src:a}=r;if(this.loaded.has(a))return t&&(this.loading.forEach(p=>p.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,o),this.loading.set(a,l)),t&&this.loading.forEach((p,m)=>{p!==l&&(p.cancel(),this.loading.delete(m))}),l.when.then(p=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const m=f(p);return e.noAdd||this.loaded.set(r.src,m),m.familySet.forEach(g=>{this.familyToUrl.set(g,a),typeof document<"u"&&(i&&this.injectFontFace(g,p),s&&this.injectStyleTag(g,a))}),m}}).catch(p=>{if(p instanceof DOMException&&p.message==="The user aborted a request.")return f();throw p}).finally(()=>{this.loading.delete(a)});function h(){return r.family?Array.isArray(r.family)?r.family:[r.family]:[]}function c(p){return h().forEach(m=>{p.familySet.add(m)}),p}function f(p=new ArrayBuffer(0)){let m;function g(){return m||(m=p.byteLength?ma(p,!1):void 0),m}function _(){const y=g();if(y instanceof Ze||y instanceof Bi)return y.sfnt}return{...r,buffer:p,familySet:new Set(h()),getFont:g,getSFNT:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(r=>r.when))}};u(Wi,"defaultRequestInit",{cache:"force-cache"});let Li=Wi;const ya=new Li,_f=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:xi,get Cff(){return zt},get Cmap(){return hr},CmapSubtableFormat0:Gs,CmapSubtableFormat12:Hs,CmapSubtableFormat14:Fr,CmapSubtableFormat2:kr,CmapSubtableFormat4:Xs,CmapSubtableFormat6:jt,FontDataObject:qe,FontDataView:be,Fonts:Li,get Glyf(){return Ai},Glyph:zs,GlyphSet:Vs,get Gpos(){return Ks},get Gsub(){return wt},get Head(){return ge},get Hhea(){return Te},get Hmtx(){return Oi},get Kern(){return Js},get Loca(){return Ui},get Maxp(){return xe},get Name(){return cr},get Os2(){return F},get Post(){return Ye},SFNT:Ft,TTF:Ze,TableDirectory:ar,get Vhea(){return Ee},get Vmtx(){return Ii},WOFF:Bi,WOFFTableDirectoryEntry:qt,createCmapSegments:Ws,dataTypeToByteLength:Rr,defineColumn:b,defineSFNTTable:Ce,fonts:ya,parseFont:ma,parseSFNTFont:ga},Symbol.toStringTag,{value:"Module"}));function en(n,r,e){if(typeof r=="string"&&r.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:o,stops:a}=vf(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 ki(n,r,e){n!=null&&n.color&&(n.color=en(e,n.color,r)),n!=null&&n.backgroundColor&&(n.backgroundColor=en(e,n.backgroundColor,r)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=en(e,n.textStrokeColor,r))}function vf(n,r,e,t,i){var m;const s=((m=n.match(/linear-gradient\((.+)\)$/))==null?void 0:m[1])??"",o=s.split(",")[0],a=o.includes("deg")?o:"0deg",l=s.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),c=(Number(a.replace("deg",""))||0)*Math.PI/180,f=t*Math.sin(c),p=i*Math.cos(c);return{x0:r+t/2-f,y0:e+i/2+p,x1:r+t/2+f,y1:e+i/2-p,stops:Array.from(l).map(g=>{let _=g[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(g[3].replace("%",""))/100,color:_}})}}function jr(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 bf(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 wf(n,r){const{paragraphs:e,computedStyle:t,glyphBox:i}=r;ki(t,i,n),e.forEach(s=>{ki(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{ki(o.computedStyle,o.inlineBox,n)})})}const xf=new Set(["©","®","÷"]),Pf=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),Cf={1:"italic",32:"bold"},Tf={1:"italic",2:"bold"},_a={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Ef{constructor(r,e,t){u(this,"path",new Pe);u(this,"lineBox",new Z);u(this,"inlineBox",new Z);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??ya,i=e?t.get(e):t.fallbackFont;return i==null?void 0:i.getSFNT()}updateGlyph(r=this._getFontSFNT()){if(!r)return this;const{hhea:e,os2:t,post:i,head:s}=r,o=s.unitsPerEm,a=e.ascent,l=e.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:p}=c,m=o/p,g=r.getAdvanceWidth(h,p),_=(a+Math.abs(l))/m,y=a/m;return this.advanceWidth=g,this.advanceHeight=_,this.inlineBox.width=f?_:g,this.inlineBox.height=f?g:_,this.underlinePosition=(a-i.underlinePosition)/m,this.underlineThickness=i.underlineThickness/m,this.strikeoutPosition=(a-t.yStrikeoutPosition)/m,this.strikeoutSize=t.yStrikeoutSize/m,this.ascender=a/m,this.descender=l/m,this.typoAscender=t.sTypoAscender/m,this.typoDescender=t.sTypoDescender/m,this.typoLineGap=t.sTypoLineGap/m,this.winAscent=t.usWinAscent/m,this.winDescent=t.usWinDescent/m,this.xHeight=t.sxHeight/m,this.capHeight=t.sCapHeight/m,this.baseline=y,this.centerDiviation=_/2-y,this.fontStyle=Cf[t.fsSelection]??Tf[s.macStyle],this}update(r){const e=this._getFontSFNT(r);if(!e)return this;this.updateGlyph(e);const{isVertical:t,content:i,computedStyle:s,baseline:o,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:p,advanceHeight:m}=this,{left:g,top:_}=a,y=s.fontStyle==="italic"&&f!=="italic";let S=g,T=_+o,P;const E=new Pe;if(t&&(S+=(m-p)/2,Math.abs(p-m)>.1&&(T-=(l-c)/(l+Math.abs(h))*m),P=void 0),t&&!xf.has(i)&&(i.codePointAt(0)<=256||Pf.has(i))){E.addCommands(e.getPathCommands(i,S,_+o-(m-p)/2,s.fontSize));const v={y:_-(m-p)/2+m/2,x:S+p/2};y&&this._italic(E,t?{x:v.x,y:_-(m-p)/2+o}:void 0),E.rotate(90,v)}else P!==void 0?(E.addCommands(e.glyphs.get(P).getPathCommands(S,T,s.fontSize)),y&&this._italic(E,t?{x:S+p/2,y:_+c/(l+Math.abs(h))*m}:void 0)):(E.addCommands(e.getPathCommands(i,S,T,s.fontSize)),y&&this._italic(E,t?{x:S+m/2,y:T}:void 0));const w=s.fontWeight??400;return w in _a&&(w===700||w==="bold")&&f!=="bold"&&E.bold(_a[w]*s.fontSize*.05),E.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=E,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 Z(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)jr(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};ys(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 tn(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 va(n){const r=Ot(n)?{}:n;return Object.keys(r).reduce((e,t)=>{let i=r[t];const s=ba(t),o=ba(i);return s&&(t=s),o&&(i=o),e[t]=i,e},{})}function Ot(n){return!n||n==="none"}function Sf(n,r){const e=Object.keys(n),t=Object.keys(r);return Array.from(new Set([...e,...t])).every(s=>ur(n[s],r[s]))}function ur(n,r){const e=typeof n;return e===typeof r?e==="object"?Sf(n,r):n===r:!1}function ba(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 rn(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 sn(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class Mf{constructor(r,e={},t){u(this,"inlineBox",new Z);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,...rn(this.style)},this}initCharacters(){const r=[];let e=0;for(const t of this.computedContent)r.push(new Ef(t,e++,this));return this.characters=r,this}}class Gr{constructor(r,e){u(this,"lineBox",new Z);u(this,"fragments",[]);this.style=r,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...rn(this.parentStyle),...rn(this.style)},this}addFragment(r,e){const t=new Mf(r,e,this);return this.fragments.push(t),t}}function Dp(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 p=document.createElement("span");Object.assign(p.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),p.appendChild(document.createTextNode(f.content)),c.appendChild(p)}),l.appendChild(c)}),i.appendChild(l),t.appendChild(i),document.body.appendChild(t),{dom:i,destory:()=>{var h;return(h=i.parentNode)==null?void 0:h.removeChild(i)}}}measureDomText(r){const e=document.createRange();e.selectNodeContents(r);const t=r.data??"";let i=0;return Array.from(t).map(s=>{var f;const o=i+=t.substring(i).indexOf(s),a=o+s.length;i+=s.length,e.setStart(r,Math.max(o,0)),e.setEnd(r,a);const l=((f=e.getClientRects)==null?void 0:f.call(e))??[e.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=e.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(r){const e=[],t=[],i=[];return r.querySelectorAll("li").forEach((s,o)=>{const a=s.getBoundingClientRect();e.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();t.push({paragraphIndex:o,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(p=>{i.push({...p,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(p=>{p.firstChild instanceof window.Text&&this.measureDomText(p.firstChild).forEach(m=>{i.push({...m,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:e,fragments:t,characters:i}}measureParagraphDom(r,e){const t=e.getBoundingClientRect(),i=this.measureDom(e);i.paragraphs.forEach(a=>{const l=r[a.paragraphIndex];l.lineBox.left=a.left-t.left,l.lineBox.top=a.top-t.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=r[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-t.left,l.inlineBox.top=a.top-t.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-t.left,top:a.top-t.top});const f=r[l].fragments[h].characters[c],{fontHeight:p,isVertical:m}=f,g=s[o];f.inlineBox.left=g.left,f.inlineBox.top=g.top,f.inlineBox.width=g.width,f.inlineBox.height=g.height,m?(f.lineBox.left=g.left+(g.width-p)/2,f.lineBox.top=g.top,f.lineBox.width=p,f.lineBox.height=g.height):(f.lineBox.left=g.left,f.lineBox.top=g.top+(g.height-p)/2,f.lineBox.width=g.width,f.lineBox.height=p),o++}),{paragraphs:r,boundingBox:new Z(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 nn=gr;class Af{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 on(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 Of(){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=Do(sn(o)?e.get(o)??o:o),h=ko(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}=on(h);sn(c)&&a.add(c),sn(f)&&a.add(f)}),await Promise.all(Array.from(a).map(l=>i(l)))},update:o=>{r.length=0,n.length=0;let a=[],l,h;o.forEachCharacter(c=>{const{computedStyle:f}=c,p=on(f),{image:m,colormap:g,line:_,size:y,thickness:S}=p;if(Ot(m))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:T,isVertical:P}=c,{fontSize:E}=f;(!h||ur(h.image,m)&&ur(h.colormap,g)&&ur(h.line,_)&&ur(h.size,y)&&ur(h.thickness,S))&&(l!=null&&l.length)&&(P?l[0].inlineBox.left===T.left:l[0].inlineBox.top===T.top)&&l[0].fontSize===E?l.push(c):(l=[],l.push(c),a.push(l))}h=p}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],p=f[0],m=Z.from(...f.filter(I=>I.glyphBox).map(I=>I.glyphBox)),{computedStyle:g}=p,{fontSize:_,writingMode:y}=g,{image:S,referImage:T,colormap:P,line:E,size:w,thickness:v}=on(g),x=y.includes("vertical"),C=tn(v,{fontSize:_,total:m.width})/m.width,D=va(P),{pathSet:$,dom:B}=s(S),U=$.getBoundingBox(!0),V=_/U.width*2,A=new Z().copy(m);x&&(A.width=m.height,A.height=m.width,A.left=m.left+m.width);const N=Math.floor(A.width);let W=N;if(w!=="cover"&&(W=tn(w,{fontSize:_,total:m.width})||N,A.width=W),!Ot(T)&&Ot(E)){const I=s(T).pathSet.getBoundingBox(!0);U.copy(I)}else{let I;if(Ot(E))if(U.width/U.height>4){I="underline";const j=B.getAttribute("viewBox");if(j){const[k,L,K,H]=j.split(" ").map(G=>Number(G)),X=L+H/2;U.y<X&&U.y+U.height>X?I="line-through":U.y+U.height<X?I="overline":I="underline"}}else I="outline";else I=E;switch(I){case"outline":{const j=A.width*.2,k=A.height*.2;A.width+=j,A.height+=k,x?(A.x-=k/2,A.y-=j/2,A.x+=A.height):(A.x-=j/2,A.y-=k/2);break}case"overline":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width:A.y=p.inlineBox.top;break;case"line-through":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width-p.strikeoutPosition+A.height/2:A.y=p.inlineBox.top+p.strikeoutPosition-A.height/2;break;case"underline":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width-p.underlinePosition:A.y=p.inlineBox.top+p.underlinePosition;break}}const R=new $e().translate(-U.x,-U.y).scale(A.width/U.width,A.height/U.height);x&&R.rotate(-Math.PI/2),R.translate(A.x,A.y);for(let I=0;I<Math.ceil(N/W);I++){const j=R.clone();x?j.translate(0,I*A.width):j.translate(I*A.width,0),$.paths.forEach(k=>{const L=k.clone().applyTransform(j);L.style.strokeWidth&&(L.style.strokeWidth*=V*C),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!==W&&(x?r[n.length-1]=new Z(m.left-m.width*2,m.top,m.width*4,m.height):r[n.length-1]=new Z(m.left,m.top-m.height*2,m.width,m.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if(jr({ctx:o,path:l,fontSize:a.computedStyle.fontSize,clipRect:r[h]}),a.debug){const c=new Cs([l]).getBoundingBox();c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function Uf(n,r){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
109
- <circle cx="${n}" cy="${n}" r="${n}" fill="${r}" />
110
- </svg>`}function Df(){const n=[];return{name:"listStyle",paths:n,update:r=>{n.length=0;const{paragraphs:e,isVertical:t,fontSize:i}=r,s=i*.45;e.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:p}=a,m=va(c);let g=f,_;if(!Ot(h))_=h;else if(!Ot(p)){const P=i*.38/2;switch(g=g==="cover"?P*2:g,p){case"disc":_=Uf(P,String(l));break}}if(!_)return;const y=ko(_),S=y.getBoundingBox();let T;o.fragments.forEach(P=>{P.characters.forEach(E=>{const{inlineBox:w}=E;if(t?(T==null?void 0:T.inlineBox.left)!==w.left:(T==null?void 0:T.inlineBox.top)!==w.top){T=E;const v=g==="cover"?1:tn(g,{total:i,fontSize:i})/i,x=new $e;if(t){const C=i/S.height*v;x.translate(-S.left,-S.top).rotate(Math.PI/2).scale(C,C).translate(w.left+(w.width-S.height*C)/2,w.top-s)}else{const C=i/S.height*v;x.translate(-S.left,-S.top).scale(C,C).translate(w.left-S.width*C-s,w.top+(w.height-S.height*C)/2)}n.push(...y.paths.map(C=>{const D=C.clone();return D.applyTransform(x),D.style.fill&&D.style.fill in m&&(D.style.fill=m[D.style.fill]),D.style.stroke&&D.style.stroke in m&&(D.style.stroke=m[D.style.stroke]),D}))}})})})}}}const Ut=new O,fr=new $e,Dt=new $e;function If(){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=an(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?Z.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 Z(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=>{ki(a,t,n),n.save();const[l,h,c,f,p,m]=an(r,a).transpose().elements;n.transform(l,f,h,p,c,m),r.forEachCharacter(g=>{var _;(_=g.parent.style)!=null&&_.backgroundColor&&o(g.parent.style.backgroundColor,g.inlineBox),g.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 an(n,r){const{fontSize:e,glyphBox:t}=n,i=(r.translateX??0)*e,s=(r.translateY??0)*e,o=Math.PI*2,a=(r.skewX??0)/360*o,l=(r.skewY??0)/360*o,{left:h,top:c,width:f,height:p}=t,m=h+f/2,g=c+p/2;return fr.identity(),Dt.makeTranslation(i,s),fr.multiply(Dt),Dt.makeTranslation(m,g),fr.multiply(Dt),Dt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),fr.multiply(Dt),Dt.makeTranslation(-m,-g),fr.multiply(Dt),fr.clone()}function Rf(){const n=[];return{name:"textDecoration",paths:n,update:r=>{n.length=0;const e=[];let t,i;r.forEachCharacter(s=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:p}=s,{color:m,textDecoration:g,writingMode:_}=o;if(Ot(g))i=void 0;else{let y=!1;if((i==null?void 0:i.textDecoration)===g&&(i==null?void 0:i.writingMode)===_&&(i==null?void 0:i.color)===m&&(a?t[0].inlineBox.left===l.left:t[0].inlineBox.top===l.top))switch(g){case"underline":t[0].underlinePosition===h&&t[0].underlineThickness===c&&(y=!0);break;case"line-through":t[0].strikeoutPosition===f&&t[0].strikeoutSize===p&&(y=!0);break}y?t.push(s):(t=[],t.push(s),e.push(t)),i=o}}),e.forEach(s=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=s[0],{color:p,textDecoration:m}=o,{left:g,top:_,width:y,height:S}=Z.from(...s.map(v=>v.inlineBox));let T=a?g+y:_;const P=a?-1:1;let E=0;switch(m){case"overline":E=h*2;break;case"underline":T+=P*l,E=h*2;break;case"line-through":T+=P*c,E=f*2;break}T-=E;let w;a?w=new Pe([{type:"M",x:T,y:_},{type:"L",x:T,y:_+S},{type:"L",x:T+E,y:_+S},{type:"L",x:T+E,y:_},{type:"Z"}],{fill:p}):w=new Pe([{type:"M",x:g,y:T},{type:"L",x:g+y,y:T},{type:"L",x:g+y,y:T+E},{type:"L",x:g,y:T+E},{type:"Z"}],{fill:p}),n.push(w)})},render:(r,e)=>{const{effects:t,computedStyle:i}=e;t?t.forEach(s=>{r.save();const[o,a,l,h,c,f]=an(e,s).transpose().elements;r.transform(o,h,a,c,l,f),n.forEach(p=>{jr({ctx:r,path:p,fontSize:i.fontSize,...s})}),r.restore()}):n.forEach(s=>{jr({ctx:r,path:s,fontSize:i.fontSize})})}}}const ln=uc();class Bf extends Af{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",{...ln});u(this,"paragraphs",[]);u(this,"lineBox",new Z);u(this,"rawGlyphBox",new Z);u(this,"glyphBox",new Z);u(this,"pathBox",new Z);u(this,"boundingBox",new Z);u(this,"measurer",new nn);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(Df()).use(Rf()).use(Of()).use(If()),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={...ln,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new Gr({},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 Gr({},t);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new Gr({},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 Gr(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 Gr(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 Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):new Cs(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 Z(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(),bf(s,i,this.boundingBox),wf(s,this),Array.from(this.plugins.values()).sort((o,a)=>(o.renderOrder??0)-(a.renderOrder??0)).forEach(o=>{var a;if(o.render)(a=o.render)==null||a.call(o,s,this);else if(o.paths){const l=this.computedStyle;o.paths.forEach(h=>{jr({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Lf=Object.defineProperty,kf=Object.getOwnPropertyDescriptor,dr=(n,r,e,t)=>{for(var i=t>1?void 0:t?kf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Lf(r,e,i),i};const Nf=new Set(Object.keys(ln));d.Text2D=class extends _i{constructor(e,t=[]){super();u(this,"effects");u(this,"measureDom");u(this,"fonts");u(this,"texture",new Sr);u(this,"text",new Bf);u(this,"_subTextsCount",0);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"content":case"effects":case"measureDom":case"fonts":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&e==="effects"&&this._getSubTexts().forEach(o=>{o.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()}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&Nf.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}_getSubTexts(){return this.getChildren("front").filter(e=>e instanceof d.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("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 d.Text2D({content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),"front"),this._subTextsCount++})})})}_drawContent(){var e,t;if(!this.split){const i=(t=(e=this.getChildren())==null?void 0:e.find(s=>"onText2DRender"in s))==null?void 0:t.onText2DRender;i?i():(this._updateText(),this.text.render({pixelRatio:this.texture.pixelRatio,view:this.texture.source})),this.texture.requestUpload(),super._drawContent()}}},dr([M({default:!1})],d.Text2D.prototype,"split",2),dr([M({default:""})],d.Text2D.prototype,"content",2),dr([M()],d.Text2D.prototype,"effects",2),dr([ue()],d.Text2D.prototype,"measureDom",2),dr([ue()],d.Text2D.prototype,"fonts",2),d.Text2D=dr([q("Text2D")],d.Text2D);var $f=Object.defineProperty,Ff=Object.getOwnPropertyDescriptor,wa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ff(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&$f(r,e,i),i};d.Video2D=class extends _i{constructor(e,t=[]){super();u(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get videoDuration(){var e;return(((e=this.texture)==null?void 0:e.duration)??0)*1e3}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Pt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;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)}},wa([M({default:""})],d.Video2D.prototype,"src",2),d.Video2D=wa([q("Video2D")],d.Video2D);var zf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,qr=(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};const xa=n=>n,Pa=pr(.25,.1,.25,1),Ca=pr(.42,0,1,1),Ta=pr(0,0,.58,1),Ea=pr(.42,0,.58,1);function pr(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,p=_=>((s*_+o)*_+a)*_,m=_=>((l*_+h)*_+c)*_;function g(_){let y=_,S,T;for(let w=0;w<8;w++){if(T=p(y)-_,Math.abs(T)<1e-6)return y;if(S=f(y),Math.abs(S)<1e-6)break;y-=T/S}let P=1,E=0;for(y=_;P>E;){if(T=p(y)-_,Math.abs(T)<1e-6)return y;T>0?P=y:E=y,y=(P+E)/2}return y}return _=>m(g(_))}const Ni={linear:xa,ease:Pa,easeIn:Ca,easeOut:Ta,easeInOut:Ea};d.Animation=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"easing");u(this,"_keyframes",[]);u(this,"_isFirstUpdatePosition",!1);u(this,"_cachedProps",new Zt);u(this,"_stoped",!1);this.commitStyles=this.commitStyles.bind(this),this.setProperties(e).append(t)}_treeEnter(e){e.timeline.on("updateCurrentTime",this.commitStyles),this._updateCachedProps()}_treeExit(e){e.timeline.on("updateCurrentTime",this.commitStyles),this.cancel()}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"animationMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var t;let e;switch(this.animationMode){case"sibling":e=((t=this.getParent())==null?void 0:t.getChildren(!0).filter(i=>i instanceof d.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._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,i=this.currentTimeProgress;e.forEach((s,o)=>{const a=t===1?i:at(0,Math.max(0,i-t*o)/t,1),l=this._cachedProps.get(s);if(!l)return;const h=this._parseKeyframes(a,l);h!=null&&h.length&&this._commitStyle(a,s,l,h[0],h[1])})}_updateCachedProps(){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._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return Ni.linear;if(e in Ni)return Ni[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return pr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let i;const s=this._keyframes;for(let o=s.length,a=0;a<o;a++){const l=s[a],{offset:h,easing:c}=l,f={...l.props};if(i&&e<=h){const{offset:p,easing:m}=i,g={...i.props};return t.forEach((_,y)=>{(!(y in g)||g[y]===null)&&(g[y]=_),(!(y in f)||f[y]===null)&&(f[y]=_)}),[{offset:p,easing:m,props:g},{offset:h,easing:c,props:f}]}i=l}return null}_commitStyle(e,t,i,s,o){const{offset:a,easing:l,props:h}=s,{offset:c,props:f}=o,p=c-a,m=l((e-a)/p),g={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((_,y)=>{t[y]=this._getDiffValue(y,h[y],f[y],m,g)})}_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=Ki(a);else if(i!==void 0)l=mr(e,String(i),o),a=Ki(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:m,args:g})=>{c[m]=g,h.add(m)}),l.forEach(({name:m,args:g})=>{f[m]=g,h.add(m)});let p="";return h.forEach(m=>{var S,T;const g=Math.max(((S=c[m])==null?void 0:S.length)??0,((T=f[m])==null?void 0:T.length)??0),_=c[m],y=f[m];p+=`${m}(${Array.from({length:g},(P,E)=>{const w=_==null?void 0:_[E],v=y==null?void 0:y[E],x=(w==null?void 0:w.normalizedIntValue)??0,C=(v==null?void 0:v.normalizedIntValue)??0;return Number.isNaN(x)||Number.isNaN(C)?(v==null?void 0:v.value)??0:de(x,C,s)}).join(", ")}) `}),p}else if(!Array.isArray(a)&&!Array.isArray(l))return Number.isNaN(a.normalizedIntValue)||Number.isNaN(l.normalizedIntValue)?l.value:de(a.normalizedIntValue,l.normalizedIntValue,s)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{var t;(t=this._cachedProps.get(e))==null||t.forEach((i,s)=>{e[s]=i}),this._cachedProps.delete(e)})}},qr([M({default:"parent"})],d.Animation.prototype,"animationMode",2),qr([M({default:!1})],d.Animation.prototype,"loop",2),qr([M({default:[]})],d.Animation.prototype,"keyframes",2),qr([M()],d.Animation.prototype,"easing",2),d.Animation=qr([q("Animation",{renderMode:"disabled",processMode:"disabled",duration:2e3})],d.Animation);const Xi=class Xi extends mt{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 Xi),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(Xi,"_instance");let $i=Xi;const Jr=class Jr extends mt{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-Jr.PADDING),this._end=Math.min(this._end+Jr.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),fe.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){fe.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){fe.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(Jr,"PADDING",.1);let Fi=Jr;class Sa{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 $i.instance}async load(){return new Promise(r=>{this.source.onload=()=>r(this),this.source.src=this._src,this.source.load()})}createSound(){return new Fi}}class hn extends mt{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 jf{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 Gf(){if(Qi)return new AudioContext;if(es){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function qf(n,r,e){if(ts)return new OfflineAudioContext(n,r,e);if(xn){const t=globalThis.webkitOfflineAudioContext;return new t(n,r,e)}else throw new Error("Failed to createOfflineAudioContext")}const Hi=class Hi extends hn{constructor(){const e=Gf(),t=qf(1,2,ts?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"&&(gt||wn),_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 Hi),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(Hi,"_instance");let It=Hi;class Ma extends mt{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){fe.off(this._updateListener),e&&fe.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 Aa extends hn{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 Ma}}var Oa=Object.defineProperty,Wf=Object.getOwnPropertyDescriptor,Xf=(n,r,e)=>r in n?Oa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Hf=(n,r,e,t)=>{for(var i=t>1?void 0:t?Wf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Oa(r,e,i),i},Yf=(n,r,e)=>Xf(n,r+"",e);d.Audio=class extends d.TimelineNode{constructor(e=""){super();u(this,"_sounds",[]);u(this,"_platformAudio",Pn?new Aa(this):new Sa(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,"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 audioDuration(){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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"paused":this.refreshPaused();break}}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 d.Audio._soundPool.length>0?d.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(),d.Audio._soundPool.includes(e)||d.Audio._soundPool.push(e)}_process(e){var t;if(super._process(e),this.canProcess()){const i=((t=this._tree)==null?void 0:t.timeline.currentTime)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Yf(d.Audio,"_soundPool",[]),d.Audio=Hf([q("Audio")],d.Audio);class Zf extends d.Node2D{}var Kf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,zi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Jf(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&&Kf(r,e,i),i};d.AudioWaveform=class extends d.Node2D{constructor(e={}){super();u(this,"src");u(this,"gap",0);u(this,"color","#000000");u(this,"_audioBuffer");u(this,"_src",_r?new me(document.createElement("canvas")):void 0);u(this,"_needsUpdateTexture",!1);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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,p;const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(f=this._src)==null?void 0:f.source;if(!i)return;const{width:s=0,height:o=0}=this.style;i.width=s,i.height=o;const a=i.getContext("2d");if(!a){console.warn("Failed to getContext('2d') in syncTexture");return}a.fillStyle=this.color;const l=t.getChannelData(0),h=Math.ceil(l.length/s),c=o/2;for(let m=1,g=-1,_=0;_<s;_++){for(let y=0;y<h;y++){const S=l[_*h+y];S<m&&(m=S),S>g&&(g=S)}if(!this.gap||_%(this.gap*2)===0){const y=_,S=(1+m)*c,T=this.gap||1,P=Math.max(1,(g-m)*c);a.fillRect(y,S,T,P),m=1,g=-1}}(p=this._src)==null||p.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height))}},zi([M()],d.AudioWaveform.prototype,"src",2),zi([M()],d.AudioWaveform.prototype,"gap",2),zi([M()],d.AudioWaveform.prototype,"color",2),d.AudioWaveform=zi([q("AudioWaveform")],d.AudioWaveform);var Qf=Object.defineProperty,ed=Object.getOwnPropertyDescriptor,Wr=(n,r,e,t)=>{for(var i=t>1?void 0:t?ed(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Qf(r,e,i),i};d.Effect=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"material");u(this,"mode");u(this,"viewport1",new d.Viewport);u(this,"viewport2",new d.Viewport);u(this,"_renderId",0);u(this,"_renderViewport");u(this,"_previousSibling");u(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _mode(){return this.mode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const o=new di(t);!this.mode&&o.has.transition&&(this.mode="transition"),this.material=o;break}case"glslSrc":{t?Pt.text.load(t).then(o=>this.glsl=o):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){switch(this._updateCurrentTime(),this._mode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){var i;if(!this.isInsideTimeRange())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}}_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.viewport1.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.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,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.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._mode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),J.draw(e))}}_parseTargetArea(){if(this._mode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.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,()=>{J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Wr([ue()],d.Effect.prototype,"material",2),Wr([M()],d.Effect.prototype,"mode",2),Wr([M({default:""})],d.Effect.prototype,"glsl",2),Wr([M({default:""})],d.Effect.prototype,"glslSrc",2),d.Effect=Wr([q("Effect")],d.Effect);var Ua=Object.defineProperty,td=Object.getOwnPropertyDescriptor,rd=(n,r,e)=>r in n?Ua(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,cn=(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&&Ua(r,e,i),i},Da=(n,r,e)=>rd(n,typeof r!="symbol"?r+"":r,e);const id=`attribute vec2 position;
105
+ }`,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(ir,"_instance");class J extends fi{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ir.instance,t){this.instance.draw(r,e,t)}constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(J,"_instance");class lc extends fi{constructor(){const e=new vt({data:new Float32Array,dynamic:!0}),t=new vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new rr({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}}function hc(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function $o(){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 cc(){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,...$o(),backgroundImage:"none",backgroundColor:"transparent",...hc(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function zo(){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 uc(){return{...cc(),...zo()}}var fc=Object.defineProperty,_e=(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&&fc(r,e,i),i};const Vo={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};class ne extends yt{constructor(e){super();u(this,"_backgroundColor",new Ct);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=this.backgroundColor==="none"?void 0:this.backgroundColor;break}}canPointeEvents(){return this.pointerEvents!=="none"}getComputedOpacity(){return at(0,this.opacity,1)}getComputedBackgroundColor(){return this._backgroundColor}async loadBackgroundImage(){if(this.backgroundImage!=="none")return await Pt.texture.load(this.backgroundImage)}getComputedTransform(){const{scaleX:e,scaleY:t,left:i,top:s,width:o,height:a,rotate:l}=this,h=new et,c=new et(!1),f=new et(!1).scale(e,t).translate(i,s).rotate(l*qn);let p=this.transform;(!p||p==="none")&&(p=""),yr(p,{width:o,height:a}).forEach(({name:S,args:w})=>{const v=w.map(x=>x.normalizedIntValue);switch(h.identity(),S){case"translate":h.translate(v[0]*o,(v[1]??v[0])*this.height);break;case"translateX":h.translateX(v[0]*o);break;case"translateY":h.translateY(v[0]*a);break;case"translateZ":h.translateZ(v[0]);break;case"translate3d":h.translate3d(v[0]*o,(v[1]??v[0])*a,v[2]??v[1]??v[0]);break;case"scale":h.scale(v[0],v[1]??v[0]);break;case"scaleX":h.scaleX(v[0]);break;case"scaleY":h.scaleY(v[0]);break;case"scale3d":h.scale3d(v[0],v[1]??v[0],v[2]??v[1]??v[0]);break;case"rotate":h.rotate(v[0]*le);break;case"rotateX":h.rotateX(v[0]*le);break;case"rotateY":h.rotateY(v[0]*le);break;case"rotateZ":h.rotateZ(v[0]*le);break;case"rotate3d":h.rotate3d(v[0]*le,(v[1]??v[0])*le,(v[2]??v[1]??v[0])*le,(v[3]??v[2]??v[1]??v[0])*le);break;case"skew":h.skew(v[0],v[0]??v[1]);break;case"skewX":h.skewX(v[0]);break;case"skewY":h.skewY(v[0]);break;case"matrix":h.set(v);break}c.multiply(h)}),f.update(),c.update();const m=f.toArray(),g=c.toArray(),_=[g[0]*m[0]+g[3]*m[1],g[1]*m[0]+g[4]*m[1],g[2]*m[0]+g[5]*m[1]+m[2],g[0]*m[3]+g[3]*m[4],g[1]*m[3]+g[4]*m[4],g[2]*m[3]+g[5]*m[4]+m[5],0,0,1],[y,E]=this.getComputedTransformOrigin(),T=y*o,P=E*a;return _[2]+=_[0]*-T+_[1]*-P+T,_[5]+=_[3]*-T+_[4]*-P+P,new et().set(_)}getComputedTransformOrigin(){const[e,t=e]=this.transformOrigin.split(" ");return[e,t].map(i=>{switch(i=i.trim(),i){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(i)}})}getComputedFilter(){let e={};return this.filter==="none"||(e=yr(this.filter).reduce((t,{name:i,args:s})=>(t[i]=s[0].normalizedIntValue,t),e),Object.keys(Vo).forEach(t=>{e[t]=e[t]??Vo[t]})),e}getComputedFilterColorMatrix(){const e=new us,t=this.getComputedFilter();for(const i in t){const s=t[i];switch(i){case"hue-rotate":e.hueRotate(s*le);break;case"saturate":e.saturate(s);break;case"brightness":e.brightness(s);break;case"contrast":e.contrast(s);break;case"invert":e.invert(s);break;case"sepia":e.sepia(s);break;case"opacity":e.opacity(s);break;case"grayscale":e.grayscale(s);break}}return e}}_e([M({default:"none"})],ne.prototype,"backgroundColor"),_e([M({default:"none"})],ne.prototype,"backgroundImage"),_e([M({default:"none"})],ne.prototype,"filter"),_e([M({default:"inherit"})],ne.prototype,"direction"),_e([M({default:"none"})],ne.prototype,"boxShadow"),_e([M({default:"none"})],ne.prototype,"maskImage"),_e([M({default:1})],ne.prototype,"opacity"),_e([M({default:0})],ne.prototype,"borderWidth"),_e([M({default:0})],ne.prototype,"borderRadius"),_e([M({default:"#000000"})],ne.prototype,"borderColor"),_e([M({default:"none"})],ne.prototype,"borderStyle"),_e([M({default:0})],ne.prototype,"outlineWidth"),_e([M({default:0})],ne.prototype,"outlineOffset"),_e([M({default:"#000000"})],ne.prototype,"outlineColor"),_e([M({default:"none"})],ne.prototype,"outlineStyle"),_e([M({default:"visible"})],ne.prototype,"visibility"),_e([M({default:"visible"})],ne.prototype,"overflow"),_e([M({default:"auto"})],ne.prototype,"pointerEvents");const jo=$o();for(const n in jo)vr(ne,n,{default:jo[n]});const Go=zo();for(const n in Go)vr(ne,n,{default:Go[n]});var dc=Object.defineProperty,sr=(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&&dc(r,e,i),i};class ge extends yt{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)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Zi(this.realWidth)&&Zi(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){_n&&this.source instanceof ImageBitmap&&this.source.close()}}sr([ue()],ge.prototype,"source"),sr([M({default:0})],ge.prototype,"width"),sr([M({default:0})],ge.prototype,"height"),sr([M({default:"linear"})],ge.prototype,"filterMode"),sr([M({default:"clamp_to_edge"})],ge.prototype,"wrapMode"),sr([M({default:1})],ge.prototype,"pixelRatio");var pc=Object.defineProperty,gc=(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&&pc(r,e,i),i};class Er extends ge{constructor(r=document.createElement("canvas")){super(r)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(r,e,t,i)}}gc([M({default:2})],Er.prototype,"pixelRatio");class Ss extends ge{constructor(r){const e=new Ct(r);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function mc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&Ji,crossorigin:(n==null?void 0:n.crossorigin)??null}}class yc extends ge{constructor(e,t){const i=mc(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,a),this.emit("error",a),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ji)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(_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 ge{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)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.round(e*this.pixelRatio);break;case"height":this.source.height=Math.round(e*this.pixelRatio);break}super._updateProperty(r,e,t,i)}}var _c=Object.defineProperty,qo=(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&&_c(r,e,i),i};function vc(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 Ms=(Xt=class extends ge{constructor(e,t){const i=vc(t);if(!Cn(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",""),An(o,s,i.crossorigin);for(let a=0;a<e.length;++a){let{src:l,mime:h}=e[a];if(l=l||e[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const f=l.split("?").shift().toLowerCase(),p=f.slice(f.lastIndexOf(".")+1);h=h||Xt.mimeTypes.get(p)||`video/${p}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}e=o}super(e);u(this,"_spf",0);u(this,"_autoPlay",!1);u(this,"_sourceLoad");u(this,"_nextTime",0);u(this,"_connected",!1);u(this,"_requestId");u(this,"_resolve");u(this,"_reject");u(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});u(this,"_onPlayStop",()=>{this._setupAutoUpdate()});u(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),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(fe.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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),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&&(fe.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||(fe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(fe.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(Xt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Xt);qo([ue({default:!0})],Ms.prototype,"autoUpdate"),qo([ue({default:0})],Ms.prototype,"fps");let Wo=Ms;class As extends Es{}class Xo extends Pe{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",ge.EMPTY);u(this,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof ge?e=this.strokeStyle:e=new Ss(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new Pe(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 tr,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 ge?e=this.fillStyle:e=new Ss(this.fillStyle)),this._fille.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new tr,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=c=>{e.push({type:c,vertices:t,indices:i,uvs:s,texture:a}),t=[],i=[],s=[],a=void 0};let h=t.length;for(let c=this._fille.length,f=0;f<c;f++){const p=this._fille[f];a??(a=p.texture),a!==p.texture&&l("fill"),o=t.length,p.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(o,t,s,p.texture,p.textureTransform)}t.length-h>0&&l("fill"),h=t.length;for(let c=this._stroke.length,f=0;f<c;f++){o=t.length;const p=this._stroke[f];a??(a=p.texture),p.path.strokeTriangulate({vertices:t,indices:i,lineStyle:p.style,flipAlignment:!1,closed:!0}),this.buildUvs(o,t,s,p.texture,p.textureTransform),l("stroke")}return t.length-h>0&&l("stroke"),e}}var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,nr=(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};d.Node=class extends ti{constructor(e,t=[]){super();u(this,"name",`${this.tag}:${String(this.instanceId)}`);u(this,"mask");u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties(e).append(t).on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}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("treeEnter",e)):t&&(this.emit("treeExit",t),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("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;this._parent=e,this.setTree(e==null?void 0:e._tree),e?this.emit("parented",e):i&&this.emit("unparented",i)}return this}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()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return!this._tree.paused;case"when_paused":return this._tree.paused;case"always":return!0;case"disabled":default:return!1}}canRender(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess();s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let o;if(i){const a=t.renderStack.push(this);o=t.renderStack.currentCall,t.renderStack.currentCall=a}if(this.mask instanceof d.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.addChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}for(let a=this._children.length,l=0;l<a;l++)this._children[l].emit("process",e);i&&(t.renderStack.currentCall=o),s&&(this.emit("processed",e),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,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");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)}append(...e){let t;return Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.addChild(i)}),this}addChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return this;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(o=>o.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":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"default":return h.internalMode!=="front";case"back":return h.internalMode==="back";case"front":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"front":return h.internalMode!=="front";case"default":return h.internalMode==="back";case"back":default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=at(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.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}is(e){return!!(e&&this.instanceId===e.instanceId)}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.getChildren().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=ei.get(t)??d.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},nr([M()],d.Node.prototype,"name",2),nr([M()],d.Node.prototype,"mask",2),nr([M({default:"inherit"})],d.Node.prototype,"processMode",2),nr([M({default:"inherit"})],d.Node.prototype,"renderMode",2),nr([M({default:"default"})],d.Node.prototype,"internalMode",2),d.Node=nr([j("Node")],d.Node);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,pi=(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};d.TimelineNode=class extends d.Node{constructor(e,t=[]){super();u(this,"computedDuration",0);u(this,"_currentTime",0);u(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return at(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?at(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime)}}_process(e){this._updateCurrentTime(),super._process(e)}},pi([M({default:0})],d.TimelineNode.prototype,"delay",2),pi([M({default:0})],d.TimelineNode.prototype,"duration",2),pi([M({default:!1})],d.TimelineNode.prototype,"paused",2),d.TimelineNode=pi([j("TimelineNode")],d.TimelineNode);var Cc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,Mr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tc(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};d.Viewport=class extends d.Node{constructor(e=!1){super();u(this,"_projection",new Xn);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new As,needsUpload:!1},{texture:new As,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}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)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");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&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),e.framebuffer.bind(this._glFramebuffer(e)),this.upload(e),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),J.draw(e,ir.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))}getRect(){return new ni(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Mr([M({default:0})],d.Viewport.prototype,"x",2),Mr([M({default:0})],d.Viewport.prototype,"y",2),Mr([M({default:0})],d.Viewport.prototype,"width",2),Mr([M({default:0})],d.Viewport.prototype,"height",2),d.Viewport=Mr([j("Viewport")],d.Viewport);var Sc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,Ar=(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&&Sc(r,e,i),i};d.Effect=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"material");u(this,"effectMode");u(this,"viewport1",new d.Viewport);u(this,"viewport2",new d.Viewport);u(this,"_renderId",0);u(this,"_renderViewport");u(this,"_previousSibling");u(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _effectMode(){return this.effectMode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const o=new di(t);!this.effectMode&&o.has.transition&&(this.effectMode="transition"),this.material=o;break}case"glslSrc":{t?Pt.text.load(t).then(o=>this.glsl=o):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){var i;if(!this.isInsideTimeRange())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._effectMode){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}}_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){if(this.canProcess())switch(this._renderId=0,this._effectMode){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.viewport1.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.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,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.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),J.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){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,()=>{J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Ar([ue()],d.Effect.prototype,"material",2),Ar([M()],d.Effect.prototype,"effectMode",2),Ar([M({default:""})],d.Effect.prototype,"glsl",2),Ar([M({default:""})],d.Effect.prototype,"glslSrc",2),d.Effect=Ar([j("Effect")],d.Effect);var Ho=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Ac=(n,r,e)=>r in n?Ho(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Os=(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&&Ho(r,e,i),i},Yo=(n,r,e)=>Ac(n,typeof r!="symbol"?r+"":r,e);const Oc=`attribute vec2 position;
111
106
  attribute vec2 uv;
112
107
  varying vec2 vUv[9];
113
108
  uniform float strength;
@@ -123,7 +118,7 @@ void main(void) {
123
118
  vUv[6] = uv + vec2(2.0 * strength, 0.0);
124
119
  vUv[7] = uv + vec2(3.0 * strength, 0.0);
125
120
  vUv[8] = uv + vec2(4.0 * strength, 0.0);
126
- }`,sd=`attribute vec2 position;
121
+ }`,Uc=`attribute vec2 position;
127
122
  attribute vec2 uv;
128
123
  uniform float strength;
129
124
  varying vec2 vUv[9];
@@ -139,7 +134,7 @@ void main(void) {
139
134
  vUv[6] = uv + vec2(0.0, 2.0 * strength);
140
135
  vUv[7] = uv + vec2(0.0, 3.0 * strength);
141
136
  vUv[8] = uv + vec2(0.0, 4.0 * strength);
142
- }`,Ia=`varying vec2 vUv[9];
137
+ }`,Zo=`varying vec2 vUv[9];
143
138
  uniform sampler2D sampler;
144
139
 
145
140
  void main(void) {
@@ -173,7 +168,7 @@ void main(void) {
173
168
  gl_FragColor += texture2D(sampler, vUv[7]) * 0.067234;
174
169
  gl_FragColor += texture2D(sampler, vUv[8]) * 0.028532;
175
170
  }
176
- }`;d.BlurEffect=class extends d.Effect{apply(r,e){e.redraw(r,()=>{J.draw(r,d.BlurEffect.materialX,{sampler:0,strength:1/e.width*this.strength/this.quality})}),e.redraw(r,()=>{J.draw(r,d.BlurEffect.materialY,{sampler:0,strength:1/e.height*this.strength/this.quality})})}},Da(d.BlurEffect,"materialX",new ne({vert:id,frag:Ia})),Da(d.BlurEffect,"materialY",new ne({vert:sd,frag:Ia})),cn([M({default:8})],d.BlurEffect.prototype,"strength",2),cn([M({default:4})],d.BlurEffect.prototype,"quality",2),d.BlurEffect=cn([q("BlurEffect")],d.BlurEffect);var Ra=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,od=(n,r,e)=>r in n?Ra(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?nd(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&&Ra(r,e,i),i},ad=(n,r,e)=>od(n,r+"",e);d.ColorAdjustEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"saturation",1);u(this,"contrast",1);u(this,"brightness",1);u(this,"red",1);u(this,"green",1);u(this,"blue",1);u(this,"alpha",1);u(this,"gamma",1)}apply(e,t){t.redraw(e,()=>{J.draw(e,d.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},ad(d.ColorAdjustEffect,"material",new ne({vert:`precision mediump float;
171
+ }`;d.BlurEffect=class extends d.Effect{apply(r,e){e.redraw(r,()=>{J.draw(r,d.BlurEffect.materialX,{sampler:0,strength:1/e.width*this.strength/this.quality})}),e.redraw(r,()=>{J.draw(r,d.BlurEffect.materialY,{sampler:0,strength:1/e.height*this.strength/this.quality})})}},Yo(d.BlurEffect,"materialX",new se({vert:Oc,frag:Zo})),Yo(d.BlurEffect,"materialY",new se({vert:Uc,frag:Zo})),Os([M({default:8})],d.BlurEffect.prototype,"strength",2),Os([M({default:4})],d.BlurEffect.prototype,"quality",2),d.BlurEffect=Os([j("BlurEffect")],d.BlurEffect);var Ko=Object.defineProperty,Ic=Object.getOwnPropertyDescriptor,Dc=(n,r,e)=>r in n?Ko(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,bt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ic(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&&Ko(r,e,i),i},Rc=(n,r,e)=>Dc(n,r+"",e);d.ColorAdjustEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"saturation",1);u(this,"contrast",1);u(this,"brightness",1);u(this,"red",1);u(this,"green",1);u(this,"blue",1);u(this,"alpha",1);u(this,"gamma",1)}apply(e,t){t.redraw(e,()=>{J.draw(e,d.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Rc(d.ColorAdjustEffect,"material",new se({vert:`precision mediump float;
177
172
  attribute vec2 position;
178
173
  attribute vec2 uv;
179
174
  varying vec2 vUv;
@@ -204,7 +199,7 @@ void main(void) {
204
199
  c.rgb *= c.a;
205
200
  }
206
201
  gl_FragColor = c * alpha;
207
- }`})),xt([M()],d.ColorAdjustEffect.prototype,"saturation",2),xt([M()],d.ColorAdjustEffect.prototype,"contrast",2),xt([M()],d.ColorAdjustEffect.prototype,"brightness",2),xt([M()],d.ColorAdjustEffect.prototype,"red",2),xt([M()],d.ColorAdjustEffect.prototype,"green",2),xt([M()],d.ColorAdjustEffect.prototype,"blue",2),xt([M()],d.ColorAdjustEffect.prototype,"alpha",2),xt([M()],d.ColorAdjustEffect.prototype,"gamma",2),d.ColorAdjustEffect=xt([q("ColorAdjustEffect")],d.ColorAdjustEffect);var Ba=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,hd=(n,r,e)=>r in n?Ba(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,La=(n,r,e,t)=>{for(var i=t>1?void 0:t?ld(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ba(r,e,i),i},cd=(n,r,e)=>hd(n,r+"",e);d.ColorFilterEffect=class extends d.Effect{constructor(e){super();u(this,"_colorMatrix",new us);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,()=>{J.draw(e,d.ColorFilterEffect.material,{sampler:0,m:s.toArray()})})}},cd(d.ColorFilterEffect,"material",new ne({vert:`precision mediump float;
202
+ }`})),bt([M()],d.ColorAdjustEffect.prototype,"saturation",2),bt([M()],d.ColorAdjustEffect.prototype,"contrast",2),bt([M()],d.ColorAdjustEffect.prototype,"brightness",2),bt([M()],d.ColorAdjustEffect.prototype,"red",2),bt([M()],d.ColorAdjustEffect.prototype,"green",2),bt([M()],d.ColorAdjustEffect.prototype,"blue",2),bt([M()],d.ColorAdjustEffect.prototype,"alpha",2),bt([M()],d.ColorAdjustEffect.prototype,"gamma",2),d.ColorAdjustEffect=bt([j("ColorAdjustEffect")],d.ColorAdjustEffect);var Jo=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,kc=(n,r,e)=>r in n?Jo(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Qo=(n,r,e,t)=>{for(var i=t>1?void 0:t?Bc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Jo(r,e,i),i},Lc=(n,r,e)=>kc(n,r+"",e);d.ColorFilterEffect=class extends d.Effect{constructor(e){super();u(this,"_colorMatrix",new us);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,()=>{J.draw(e,d.ColorFilterEffect.material,{sampler:0,m:s.toArray()})})}},Lc(d.ColorFilterEffect,"material",new se({vert:`precision mediump float;
208
203
  attribute vec2 position;
209
204
  attribute vec2 uv;
210
205
  varying vec2 vUv;
@@ -227,7 +222,7 @@ void main(void) {
227
222
  m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14] / 255.0,
228
223
  m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19] / 255.0
229
224
  );
230
- }`})),La([M({default:""})],d.ColorFilterEffect.prototype,"filter",2),d.ColorFilterEffect=La([q("ColorFilterEffect")],d.ColorFilterEffect);var ka=Object.defineProperty,ud=Object.getOwnPropertyDescriptor,fd=(n,r,e)=>r in n?ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,un=(n,r,e,t)=>{for(var i=t>1?void 0:t?ud(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},dd=(n,r,e)=>fd(n,r+"",e);const Xr=50;d.ColorOverlayEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"alpha",.5);u(this,"_color",new Ct)}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<Xr;)i.push([0,0,0,0]);J.draw(e,d.ColorOverlayEffect.material,{sampler:0,colors:i.slice(0,Xr).flatMap(s=>s)})})}},dd(d.ColorOverlayEffect,"material",new ne({vert:`precision mediump float;
225
+ }`})),Qo([M({default:""})],d.ColorFilterEffect.prototype,"filter",2),d.ColorFilterEffect=Qo([j("ColorFilterEffect")],d.ColorFilterEffect);var ea=Object.defineProperty,Nc=Object.getOwnPropertyDescriptor,Fc=(n,r,e)=>r in n?ea(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Us=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nc(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},$c=(n,r,e)=>Fc(n,r+"",e);const Or=50;d.ColorOverlayEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"alpha",.5);u(this,"_color",new Ct)}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<Or;)i.push([0,0,0,0]);J.draw(e,d.ColorOverlayEffect.material,{sampler:0,colors:i.slice(0,Or).flatMap(s=>s)})})}},$c(d.ColorOverlayEffect,"material",new se({vert:`precision mediump float;
231
226
  attribute vec2 position;
232
227
  attribute vec2 uv;
233
228
  varying vec2 vUv;
@@ -236,7 +231,7 @@ void main() {
236
231
  vUv = uv;
237
232
  }`,frag:`precision mediump float;
238
233
  uniform sampler2D sampler;
239
- uniform vec4 colors[${Xr}];
234
+ uniform vec4 colors[${Or}];
240
235
  varying vec2 vUv;
241
236
 
242
237
  float calcWidth() {
@@ -245,7 +240,7 @@ float calcWidth() {
245
240
 
246
241
  int calcCount() {
247
242
  int count = 0;
248
- for (int i = 0; i < ${Xr}; i++) {
243
+ for (int i = 0; i < ${Or}; i++) {
249
244
  if (colors[i] != vec4(0,0,0,0)){
250
245
  count++;
251
246
  }
@@ -257,7 +252,7 @@ vec4 calcColor(float x) {
257
252
  float perUnit = calcWidth() / float(calcCount());
258
253
  int index = int(x / perUnit);
259
254
 
260
- for(int i=0; i<${Xr}; i++){
255
+ for(int i=0; i<${Or}; i++){
261
256
  if(i==index){
262
257
  return colors[i];
263
258
  }
@@ -270,7 +265,7 @@ void main(void) {
270
265
  vec4 color = texture2D(sampler, vUv);
271
266
  vec4 mask = calcColor(vUv.x);
272
267
  gl_FragColor = vec4(mix(color.rgb, mask.rgb, color.a * mask.a), color.a);
273
- }`})),un([M()],d.ColorOverlayEffect.prototype,"colors",2),un([M()],d.ColorOverlayEffect.prototype,"alpha",2),d.ColorOverlayEffect=un([q("ColorOverlayEffect")],d.ColorOverlayEffect);var Na=Object.defineProperty,pd=Object.getOwnPropertyDescriptor,gd=(n,r,e)=>r in n?Na(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,fn=(n,r,e,t)=>{for(var i=t>1?void 0:t?pd(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&&Na(r,e,i),i},md=(n,r,e)=>gd(n,r+"",e);d.ColorRemoveEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.5);u(this,"_color",new Ct)}apply(e,t){const s=new Float32Array(150),o=this.colors.map(a=>(this._color.value=a,this._color.toArray().slice(0,3)));for(;o.length<50;)o.push([-1,0,0]);o.slice(0,50).forEach((a,l)=>{s[l*3]=a[0],s[l*3+1]=a[1],s[l*3+2]=a[2]}),t.redraw(e,()=>{J.draw(e,d.ColorRemoveEffect.material,{sampler:0,epsilon:this.epsilon,originalColors:s})})}},md(d.ColorRemoveEffect,"material",new ne({vert:`precision mediump float;
268
+ }`})),Us([M()],d.ColorOverlayEffect.prototype,"colors",2),Us([M()],d.ColorOverlayEffect.prototype,"alpha",2),d.ColorOverlayEffect=Us([j("ColorOverlayEffect")],d.ColorOverlayEffect);var ta=Object.defineProperty,zc=Object.getOwnPropertyDescriptor,Vc=(n,r,e)=>r in n?ta(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Is=(n,r,e,t)=>{for(var i=t>1?void 0:t?zc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ta(r,e,i),i},jc=(n,r,e)=>Vc(n,r+"",e);d.ColorRemoveEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.5);u(this,"_color",new Ct)}apply(e,t){const s=new Float32Array(150),o=this.colors.map(a=>(this._color.value=a,this._color.toArray().slice(0,3)));for(;o.length<50;)o.push([-1,0,0]);o.slice(0,50).forEach((a,l)=>{s[l*3]=a[0],s[l*3+1]=a[1],s[l*3+2]=a[2]}),t.redraw(e,()=>{J.draw(e,d.ColorRemoveEffect.material,{sampler:0,epsilon:this.epsilon,originalColors:s})})}},jc(d.ColorRemoveEffect,"material",new se({vert:`precision mediump float;
274
269
  attribute vec2 position;
275
270
  attribute vec2 uv;
276
271
  varying vec2 vUv;
@@ -299,7 +294,7 @@ void main(void) {
299
294
  }
300
295
 
301
296
  gl_FragColor = color;
302
- }`})),fn([M()],d.ColorRemoveEffect.prototype,"colors",2),fn([M()],d.ColorRemoveEffect.prototype,"epsilon",2),d.ColorRemoveEffect=fn([q("ColorRemoveEffect")],d.ColorRemoveEffect);var $a=Object.defineProperty,yd=Object.getOwnPropertyDescriptor,_d=(n,r,e)=>r in n?$a(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,dn=(n,r,e,t)=>{for(var i=t>1?void 0:t?yd(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&&$a(r,e,i),i},vd=(n,r,e)=>_d(n,r+"",e);const Hr=50;d.ColorReplaceEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.05);u(this,"_color",new Ct)}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(Hr*3),a=new Float32Array(Hr*3);for(;i.length<Hr;)i.push([[-1,0,0],[0,0,0,1]]);i.slice(0,Hr).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,()=>{J.draw(e,d.ColorReplaceEffect.material,{sampler:0,epsilon:s,originalColors:o,targetColors:a})})}},vd(d.ColorReplaceEffect,"material",new ne({vert:`precision mediump float;
297
+ }`})),Is([M()],d.ColorRemoveEffect.prototype,"colors",2),Is([M()],d.ColorRemoveEffect.prototype,"epsilon",2),d.ColorRemoveEffect=Is([j("ColorRemoveEffect")],d.ColorRemoveEffect);var ra=Object.defineProperty,Gc=Object.getOwnPropertyDescriptor,qc=(n,r,e)=>r in n?ra(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Ds=(n,r,e,t)=>{for(var i=t>1?void 0:t?Gc(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&&ra(r,e,i),i},Wc=(n,r,e)=>qc(n,r+"",e);const Ur=50;d.ColorReplaceEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"colors",[]);u(this,"epsilon",.05);u(this,"_color",new Ct)}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(Ur*3),a=new Float32Array(Ur*3);for(;i.length<Ur;)i.push([[-1,0,0],[0,0,0,1]]);i.slice(0,Ur).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,()=>{J.draw(e,d.ColorReplaceEffect.material,{sampler:0,epsilon:s,originalColors:o,targetColors:a})})}},Wc(d.ColorReplaceEffect,"material",new se({vert:`precision mediump float;
303
298
  attribute vec2 position;
304
299
  attribute vec2 uv;
305
300
  varying vec2 vUv;
@@ -309,7 +304,7 @@ void main() {
309
304
  }`,frag:`varying vec2 vUv;
310
305
  uniform sampler2D sampler;
311
306
  uniform float epsilon;
312
- const int MAX_COLORS = ${Hr};
307
+ const int MAX_COLORS = ${Ur};
313
308
  uniform vec3 originalColors[MAX_COLORS];
314
309
  uniform vec3 targetColors[MAX_COLORS];
315
310
 
@@ -335,7 +330,7 @@ void main(void) {
335
330
  return;
336
331
  }
337
332
  }
338
- }`})),dn([M()],d.ColorReplaceEffect.prototype,"colors",2),dn([M()],d.ColorReplaceEffect.prototype,"epsilon",2),d.ColorReplaceEffect=dn([q("ColorReplaceEffect")],d.ColorReplaceEffect);var Fa=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,wd=(n,r,e)=>r in n?Fa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,za=(n,r,e,t)=>{for(var i=t>1?void 0:t?bd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Fa(r,e,i),i},xd=(n,r,e)=>wd(n,r+"",e);d.EmbossEffect=class extends d.Effect{constructor(e=5){super();u(this,"strength");this.strength=e}apply(e,t){t.redraw(e,()=>{J.draw(e,d.EmbossEffect.material,{sampler:0,strength:this.strength,inputSize:[t.width,t.height,1/t.width,1/t.height]})})}},xd(d.EmbossEffect,"material",new ne({vert:`precision mediump float;
333
+ }`})),Ds([M()],d.ColorReplaceEffect.prototype,"colors",2),Ds([M()],d.ColorReplaceEffect.prototype,"epsilon",2),d.ColorReplaceEffect=Ds([j("ColorReplaceEffect")],d.ColorReplaceEffect);var ia=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,Hc=(n,r,e)=>r in n?ia(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,sa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Xc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ia(r,e,i),i},Yc=(n,r,e)=>Hc(n,r+"",e);d.EmbossEffect=class extends d.Effect{constructor(e=5){super();u(this,"strength");this.strength=e}apply(e,t){t.redraw(e,()=>{J.draw(e,d.EmbossEffect.material,{sampler:0,strength:this.strength,inputSize:[t.width,t.height,1/t.width,1/t.height]})})}},Yc(d.EmbossEffect,"material",new se({vert:`precision mediump float;
339
334
  attribute vec2 position;
340
335
  attribute vec2 uv;
341
336
  varying vec2 vUv;
@@ -357,7 +352,7 @@ void main(void) {
357
352
  color.rgb = vec3((color.r + color.g + color.b) / 3.0);
358
353
  float alpha = texture2D(sampler, vUv).a;
359
354
  gl_FragColor = vec4(color.rgb * alpha, alpha);
360
- }`})),za([M()],d.EmbossEffect.prototype,"strength",2),d.EmbossEffect=za([q("EmbossEffect")],d.EmbossEffect);var Va=Object.defineProperty,Pd=Object.getOwnPropertyDescriptor,Cd=(n,r,e)=>r in n?Va(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,ft=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pd(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&&Va(r,e,i),i},Td=(n,r,e)=>Cd(n,r+"",e);d.GlitchEffect=class extends d.Effect{constructor(){super();u(this,"_canvas");u(this,"_texture");u(this,"_sizes");u(this,"_offsets");u(this,"_redraw",!1);u(this,"slices",10);u(this,"sampleSize",512);u(this,"offset",100);u(this,"direction",0);u(this,"fillMode",2);u(this,"seed",0);u(this,"red",[2,2]);u(this,"green",[-10,4]);u(this,"blue",[10,-4]);this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new me(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const e=this.sampleSize,t=this._texture,i=this._canvas.getContext("2d");i.clearRect(0,0,8,e);let s,o=0;for(let a=0;a<this.slices;a++){s=Math.floor(this._offsets[a]*256);const l=this._sizes[a]*e,h=s>0?s:0,c=s<0?-s:0;i.fillStyle=`rgba(${h}, ${c}, 0, 1)`,i.fillRect(0,o>>0,e,l+1>>0),o+=l}t.requestUpload()}apply(e,t){this._redraw||(this._redraw=!0,this.redraw());const i=t.width,s=t.height,o=this.direction*(Math.PI/180),a=Math.sin(o),l=Math.cos(o);t.redraw(e,()=>{this._texture.activate(e,1),J.draw(e,d.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[i,s,0,0],dimensions:[i,s],aspect:s/i,displacementMap:1,offset:this.offset,sinDir:a,cosDir:l,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},Td(d.GlitchEffect,"material",new ne({vert:`precision mediump float;
355
+ }`})),sa([M()],d.EmbossEffect.prototype,"strength",2),d.EmbossEffect=sa([j("EmbossEffect")],d.EmbossEffect);var na=Object.defineProperty,Zc=Object.getOwnPropertyDescriptor,Kc=(n,r,e)=>r in n?na(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,ct=(n,r,e,t)=>{for(var i=t>1?void 0:t?Zc(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&&na(r,e,i),i},Jc=(n,r,e)=>Kc(n,r+"",e);d.GlitchEffect=class extends d.Effect{constructor(){super();u(this,"_canvas");u(this,"_texture");u(this,"_sizes");u(this,"_offsets");u(this,"_redraw",!1);u(this,"slices",10);u(this,"sampleSize",512);u(this,"offset",100);u(this,"direction",0);u(this,"fillMode",2);u(this,"seed",0);u(this,"red",[2,2]);u(this,"green",[-10,4]);u(this,"blue",[10,-4]);this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new ge(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const e=this.sampleSize,t=this._texture,i=this._canvas.getContext("2d");i.clearRect(0,0,8,e);let s,o=0;for(let a=0;a<this.slices;a++){s=Math.floor(this._offsets[a]*256);const l=this._sizes[a]*e,h=s>0?s:0,c=s<0?-s:0;i.fillStyle=`rgba(${h}, ${c}, 0, 1)`,i.fillRect(0,o>>0,e,l+1>>0),o+=l}t.requestUpload()}apply(e,t){this._redraw||(this._redraw=!0,this.redraw());const i=t.width,s=t.height,o=this.direction*(Math.PI/180),a=Math.sin(o),l=Math.cos(o);t.redraw(e,()=>{this._texture.activate(e,1),J.draw(e,d.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[i,s,0,0],dimensions:[i,s],aspect:s/i,displacementMap:1,offset:this.offset,sinDir:a,cosDir:l,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},Jc(d.GlitchEffect,"material",new se({vert:`precision mediump float;
361
356
  attribute vec2 position;
362
357
  attribute vec2 uv;
363
358
  varying vec2 vUv;
@@ -458,7 +453,7 @@ void main(void) {
458
453
  gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
459
454
  gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
460
455
  gl_FragColor.a = texture2D(sampler, coord).a;
461
- }`})),ft([M()],d.GlitchEffect.prototype,"slices",2),ft([M()],d.GlitchEffect.prototype,"sampleSize",2),ft([M()],d.GlitchEffect.prototype,"offset",2),ft([M()],d.GlitchEffect.prototype,"direction",2),ft([M()],d.GlitchEffect.prototype,"fillMode",2),ft([M()],d.GlitchEffect.prototype,"seed",2),ft([M()],d.GlitchEffect.prototype,"red",2),ft([M()],d.GlitchEffect.prototype,"green",2),ft([M()],d.GlitchEffect.prototype,"blue",2),d.GlitchEffect=ft([q("GlitchEffect")],d.GlitchEffect);var ja=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,Sd=(n,r,e)=>r in n?ja(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Wt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ed(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ja(r,e,i),i},Md=(n,r,e)=>Sd(n,r+"",e);d.GodrayEffect=class extends d.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,()=>{J.draw(e,d.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})})}},Md(d.GodrayEffect,"material",new ne({vert:`precision mediump float;
456
+ }`})),ct([M()],d.GlitchEffect.prototype,"slices",2),ct([M()],d.GlitchEffect.prototype,"sampleSize",2),ct([M()],d.GlitchEffect.prototype,"offset",2),ct([M()],d.GlitchEffect.prototype,"direction",2),ct([M()],d.GlitchEffect.prototype,"fillMode",2),ct([M()],d.GlitchEffect.prototype,"seed",2),ct([M()],d.GlitchEffect.prototype,"red",2),ct([M()],d.GlitchEffect.prototype,"green",2),ct([M()],d.GlitchEffect.prototype,"blue",2),d.GlitchEffect=ct([j("GlitchEffect")],d.GlitchEffect);var oa=Object.defineProperty,Qc=Object.getOwnPropertyDescriptor,eu=(n,r,e)=>r in n?oa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,$t=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qc(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},tu=(n,r,e)=>eu(n,r+"",e);d.GodrayEffect=class extends d.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,()=>{J.draw(e,d.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})})}},tu(d.GodrayEffect,"material",new se({vert:`precision mediump float;
462
457
  attribute vec2 position;
463
458
  attribute vec2 uv;
464
459
  varying vec2 vUv;
@@ -588,53 +583,7 @@ void main(void) {
588
583
  mist.a = 1.0;
589
584
  mist *= alpha;
590
585
  gl_FragColor = vec4(color.rgb + mist.rgb, color.a);
591
- }`})),Wt([M()],d.GodrayEffect.prototype,"angle",2),Wt([M()],d.GodrayEffect.prototype,"gain",2),Wt([M()],d.GodrayEffect.prototype,"lacunarity",2),Wt([M()],d.GodrayEffect.prototype,"parallel",2),Wt([M()],d.GodrayEffect.prototype,"center",2),Wt([M()],d.GodrayEffect.prototype,"alpha",2),d.GodrayEffect=Wt([q("GodrayEffect")],d.GodrayEffect);var Ga=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,Od=(n,r,e)=>r in n?Ga(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Ud=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ad(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ga(r,e,i),i},Dd=(n,r,e)=>Od(n,r+"",e);d.KawaseEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"blur",10);u(this,"quality",10)}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=this.blur,l=this.quality,h=t.width,c=t.height,f=[],p=[a];if(a>0){let T=a;const P=a/l;for(let E=1;E<l;E++)T-=P,p.push(T)}const m=1/h,g=1/c,_=[];let y;const S=l-1;for(let T=0;T<S;T++)y=p[T]+.5,_[0]=y*m,_[1]=y*g,f.push({offset:_});y=p[S]+.5,_[0]=y*m,_[1]=y*g,f.push({offset:_}),f.forEach(T=>{J.draw(e,d.KawaseEffect.material,{sampler:s,progress:o,...T})})}},Dd(d.KawaseEffect,"material",new ne({vert:`attribute vec2 position;
592
- attribute vec2 uv;
593
- varying vec2 vUv;
594
- void main() {
595
- gl_Position = vec4(position, 0.0, 1.0);
596
- vUv = uv;
597
- }`,frag:`precision highp float;
598
- varying vec2 vUv;
599
- uniform sampler2D sampler;
600
- uniform vec2 offset;
601
- uniform float progress;
602
-
603
- void main(void) {
604
- vec2 offset1 = vec2(offset.x - progress * offset.x, offset.y - progress * offset.y);
605
- vec4 color = vec4(0.0);
606
- color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y + offset1.y));
607
- color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y + offset1.y));
608
- color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y - offset1.y));
609
- color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y - offset1.y));
610
- color *= 0.25;
611
- gl_FragColor = color;
612
- }`})),d.KawaseEffect=Ud([q("KawaseEffect")],d.KawaseEffect);var qa=Object.defineProperty,Id=Object.getOwnPropertyDescriptor,Rd=(n,r,e)=>r in n?qa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Bd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Id(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&qa(r,e,i),i},Ld=(n,r,e)=>Rd(n,r+"",e);d.LeftEraseEffect=class extends d.Effect{apply(r){J.draw(r,d.LeftEraseEffect.material,{previous:0,next:1,progress:this.currentTimeProgress})}},Ld(d.LeftEraseEffect,"material",new ne({vert:`attribute vec2 position;
613
- attribute vec2 uv;
614
- varying vec2 vUv;
615
- void main() {
616
- gl_Position = vec4(position, 0.0, 1.0);
617
- vUv = uv;
618
- }`,frag:`precision highp float;
619
- varying vec2 vUv;
620
- uniform float progress;
621
- uniform sampler2D previous;
622
- uniform sampler2D next;
623
-
624
- float easeInOutQuint(float t) {
625
- return t < 0.5 ? 16.0*t*t*t*t*t : 1.0+16.0*(--t)*t*t*t*t;
626
- }
627
-
628
- void main() {
629
- vec4 src1Color = texture2D(previous, vUv);
630
- vec4 src2Color = texture2D(next, vUv);
631
- float mProgress = 1.0 - progress;
632
- float mixPercent = 0.0;
633
- if (vUv.x <= mProgress) {
634
- mixPercent = 1.0;
635
- }
636
- gl_FragColor = mix(src2Color, src1Color, mixPercent);
637
- }`})),d.LeftEraseEffect=Bd([q("LeftEraseEffect")],d.LeftEraseEffect);var Wa=Object.defineProperty,kd=Object.getOwnPropertyDescriptor,Nd=(n,r,e)=>r in n?Wa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,pn=(n,r,e,t)=>{for(var i=t>1?void 0:t?kd(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},$d=(n,r,e)=>Nd(n,r+"",e);d.MaskEffect=class extends d.Effect{constructor(e,t=[]){super();u(this,"texture");this.setProperties(e).append(t)}async load(){this.texture=void 0,this.src&&(this.texture=await Pt.texture.load(this.src))}_updateProperty(e,t,i,s){var o;switch(super._updateProperty(e,t,i,s),e){case"src":this.load();break;case"texture":(o=i==null?void 0:i.destroy)==null||o.call(i);break}}apply(e,t,i){this.texture&&i.targetArea&&t.redraw(e,()=>{this.texture.activate(e,1),J.draw(e,d.MaskEffect.material,{sampler:0,mask:1,area:i.targetArea}),e.texture.unbind(1)})}},$d(d.MaskEffect,"material",new ne({vert:`precision mediump float;
586
+ }`})),$t([M()],d.GodrayEffect.prototype,"angle",2),$t([M()],d.GodrayEffect.prototype,"gain",2),$t([M()],d.GodrayEffect.prototype,"lacunarity",2),$t([M()],d.GodrayEffect.prototype,"parallel",2),$t([M()],d.GodrayEffect.prototype,"center",2),$t([M()],d.GodrayEffect.prototype,"alpha",2),d.GodrayEffect=$t([j("GodrayEffect")],d.GodrayEffect);var aa=Object.defineProperty,ru=Object.getOwnPropertyDescriptor,iu=(n,r,e)=>r in n?aa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Rs=(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&&aa(r,e,i),i},su=(n,r,e)=>iu(n,r+"",e);d.MaskEffect=class extends d.Effect{constructor(e,t=[]){super();u(this,"texture");this.setProperties(e).append(t)}async load(){this.texture=void 0,this.src&&(this.texture=await Pt.texture.load(this.src))}_updateProperty(e,t,i,s){var o;switch(super._updateProperty(e,t,i,s),e){case"src":this.load();break;case"texture":(o=i==null?void 0:i.destroy)==null||o.call(i);break}}apply(e,t,i){this.texture&&i.targetArea&&t.redraw(e,()=>{this.texture.activate(e,1),J.draw(e,d.MaskEffect.material,{sampler:0,mask:1,area:i.targetArea}),e.texture.unbind(1)})}},su(d.MaskEffect,"material",new se({vert:`precision mediump float;
638
587
  attribute vec2 position;
639
588
  attribute vec2 uv;
640
589
  varying vec2 vUv;
@@ -663,7 +612,7 @@ void main(void) {
663
612
  } else {
664
613
  gl_FragColor = vec4(0.);
665
614
  }
666
- }`})),pn([ue()],d.MaskEffect.prototype,"texture",2),pn([M({default:""})],d.MaskEffect.prototype,"src",2),d.MaskEffect=pn([q("MaskEffect")],d.MaskEffect);var Xa=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,zd=(n,r,e)=>r in n?Xa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Ha=(n,r,e,t)=>{for(var i=t>1?void 0:t?Fd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Xa(r,e,i),i},Vd=(n,r,e)=>zd(n,r+"",e);d.PixelateEffect=class extends d.Effect{constructor(e=10){super();u(this,"size");this.size=e}apply(e,t){t.redraw(e,()=>{J.draw(e,d.PixelateEffect.material,{sampler:0,size:[this.size,this.size],filterArea:[t.width,t.height,0,0]})})}},Vd(d.PixelateEffect,"material",new ne({vert:`precision mediump float;
615
+ }`})),Rs([ue()],d.MaskEffect.prototype,"texture",2),Rs([M({default:""})],d.MaskEffect.prototype,"src",2),d.MaskEffect=Rs([j("MaskEffect")],d.MaskEffect);var la=Object.defineProperty,nu=Object.getOwnPropertyDescriptor,ou=(n,r,e)=>r in n?la(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,ha=(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&&la(r,e,i),i},au=(n,r,e)=>ou(n,r+"",e);d.PixelateEffect=class extends d.Effect{constructor(e=10){super();u(this,"size");this.size=e}apply(e,t){t.redraw(e,()=>{J.draw(e,d.PixelateEffect.material,{sampler:0,size:[this.size,this.size],filterArea:[t.width,t.height,0,0]})})}},au(d.PixelateEffect,"material",new se({vert:`precision mediump float;
667
616
  attribute vec2 position;
668
617
  attribute vec2 uv;
669
618
  varying vec2 vUv;
@@ -696,7 +645,7 @@ void main(void) {
696
645
  coord = pixelate(coord, size);
697
646
  coord = unmapCoord(coord);
698
647
  gl_FragColor = texture2D(sampler, coord);
699
- }`})),Ha([M()],d.PixelateEffect.prototype,"size",2),d.PixelateEffect=Ha([q("PixelateEffect")],d.PixelateEffect);var Ya=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,Gd=(n,r,e)=>r in n?Ya(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,qd=(n,r,e,t)=>{for(var i=t>1?void 0:t?jd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ya(r,e,i),i},Wd=(n,r,e)=>Gd(n,r+"",e);d.ShadowEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"blur",new d.BlurEffect);u(this,"viewport3",new d.Viewport)}apply(e,t){this.viewport3.activateWithCopy(e,t),this.viewport3.redraw(e,()=>{J.draw(e,d.ShadowEffect.material,{sampler:0,offset:[.001,.001],color:[0,0,0],alpha:.5})}),this.blur.apply(e,this.viewport3),t.redraw(e,()=>{this.viewport3.texture.activate(e,1),J.draw(e,ir.instance,{sampler:1}),J.draw(e,ir.instance,{sampler:0}),e.texture.unbind(1)})}},Wd(d.ShadowEffect,"material",new ne({vert:`precision mediump float;
648
+ }`})),ha([M()],d.PixelateEffect.prototype,"size",2),d.PixelateEffect=ha([j("PixelateEffect")],d.PixelateEffect);var ca=Object.defineProperty,lu=Object.getOwnPropertyDescriptor,hu=(n,r,e)=>r in n?ca(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,cu=(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&&ca(r,e,i),i},uu=(n,r,e)=>hu(n,r+"",e);d.ShadowEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"blur",new d.BlurEffect);u(this,"viewport3",new d.Viewport)}apply(e,t){this.viewport3.activateWithCopy(e,t),this.viewport3.redraw(e,()=>{J.draw(e,d.ShadowEffect.material,{sampler:0,offset:[.001,.001],color:[0,0,0],alpha:.5})}),this.blur.apply(e,this.viewport3),t.redraw(e,()=>{this.viewport3.texture.activate(e,1),J.draw(e,ir.instance,{sampler:1}),J.draw(e,ir.instance,{sampler:0}),e.texture.unbind(1)})}},uu(d.ShadowEffect,"material",new se({vert:`precision mediump float;
700
649
  attribute vec2 position;
701
650
  attribute vec2 uv;
702
651
  varying vec2 vUv;
@@ -715,7 +664,138 @@ void main(void) {
715
664
  sample.rgb = color.rgb * sample.a;
716
665
  sample *= alpha;
717
666
  gl_FragColor = sample;
718
- }`})),d.ShadowEffect=qd([q("ShadowEffect")],d.ShadowEffect);var Za=Object.defineProperty,Xd=Object.getOwnPropertyDescriptor,Hd=(n,r,e)=>r in n?Za(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Yd=(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&&Za(r,e,i),i},Zd=(n,r,e)=>Hd(n,r+"",e);d.TiltShiftEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"blur",100);u(this,"gradientBlur",600)}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height,h=[0,l/2],c=[600,l/2],f=[a,l],p=c[0]-h[0],m=c[1]-h[1],g=Math.sqrt(p*p+m*m);J.draw(e,d.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[p/g,m/g],texSize:f}),J.draw(e,d.TiltShiftEffect.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[-m/g,p/g],texSize:f})}},Zd(d.TiltShiftEffect,"material",new ne({vert:`attribute vec2 position;
667
+ }`})),d.ShadowEffect=cu([j("ShadowEffect")],d.ShadowEffect);var ua=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,du=(n,r,e)=>r in n?ua(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Ir=(n,r,e,t)=>{for(var i=t>1?void 0:t?fu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&ua(r,e,i),i},pu=(n,r,e)=>du(n,r+"",e);d.ZoomBlurEffect=class extends d.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,()=>{J.draw(e,d.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]})})}},pu(d.ZoomBlurEffect,"material",new se({vert:`attribute vec2 position;
668
+ attribute vec2 uv;
669
+ varying vec2 vUv;
670
+ void main() {
671
+ gl_Position = vec4(position, 0.0, 1.0);
672
+ vUv = uv;
673
+ }`,frag:`varying vec2 vUv;
674
+ uniform sampler2D sampler;
675
+ uniform vec4 inputSize;
676
+
677
+ uniform vec2 center;
678
+ uniform float strength;
679
+ uniform float innerRadius;
680
+ uniform float radius;
681
+
682
+ const float MAX_KERNEL_SIZE = 32.0;
683
+
684
+ highp float rand(vec2 co, float seed) {
685
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
686
+ highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);
687
+ return fract(sin(sn) * c + seed);
688
+ }
689
+
690
+ void main() {
691
+ float minGradient = innerRadius * 0.3;
692
+ float innerRadius1 = (innerRadius + minGradient * 0.5) / inputSize.x;
693
+
694
+ float gradient = radius * 0.3;
695
+ float radius1 = (radius - gradient * 0.5) / inputSize.x;
696
+
697
+ float countLimit = MAX_KERNEL_SIZE;
698
+
699
+ vec2 dir = vec2(center.xy / inputSize.xy - vUv);
700
+ float dist = length(vec2(dir.x, dir.y * inputSize.y / inputSize.x));
701
+
702
+ float strength1 = strength;
703
+
704
+ float delta = 0.0;
705
+ float gap;
706
+ if (dist < innerRadius1) {
707
+ delta = innerRadius1 - dist;
708
+ gap = minGradient;
709
+ } else if (radius1 >= 0.0 && dist > radius1) { // radius1 < 0 means it's infinity
710
+ delta = dist - radius1;
711
+ gap = gradient;
712
+ }
713
+
714
+ if (delta > 0.0) {
715
+ float normalCount = gap / inputSize.x;
716
+ delta = (normalCount - delta) / normalCount;
717
+ countLimit *= delta;
718
+ strength1 *= delta;
719
+ if (countLimit < 1.0) {
720
+ gl_FragColor = texture2D(sampler, vUv);
721
+ return;
722
+ }
723
+ }
724
+
725
+ float offset = rand(vUv, 0.0);
726
+
727
+ float total = 0.0;
728
+ vec4 color = vec4(0.0);
729
+
730
+ dir *= strength1;
731
+
732
+ for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {
733
+ float percent = (t + offset) / MAX_KERNEL_SIZE;
734
+ float weight = 4.0 * (percent - percent * percent);
735
+ vec2 p = vUv + dir * percent;
736
+ color += texture2D(sampler, p) * weight;
737
+ total += weight;
738
+
739
+ if (t > countLimit){
740
+ break;
741
+ }
742
+ }
743
+
744
+ color /= total;
745
+
746
+ gl_FragColor = color;
747
+ }`})),Ir([M()],d.ZoomBlurEffect.prototype,"center",2),Ir([M()],d.ZoomBlurEffect.prototype,"innerRadius",2),Ir([M()],d.ZoomBlurEffect.prototype,"radius",2),Ir([M()],d.ZoomBlurEffect.prototype,"strength",2),d.ZoomBlurEffect=Ir([j("ZoomBlurEffect")],d.ZoomBlurEffect);var gu=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,Bs=(n,r,e,t)=>{for(var i=t>1?void 0:t?mu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&gu(r,e,i),i};d.CanvasItem=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"opacity",1);u(this,"visible",!0);u(this,"_parentOpacity");u(this,"_parentVisible");u(this,"_modulate",new Ct(4294967295));u(this,"_backgroundImage");u(this,"context",new Xo);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._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new ne,this.setProperties(e).append(t)}get style(){return this._style}set style(e){var i;const t=(...s)=>{this.emit("updateStyleProperty",...s),this._updateStyleProperty(s[0],s[1],s[2],s[3])};e.on("updateProperty",t),(i=this._style)==null||i.off("updateProperty",t),this._style=e}setProperties(e){if(e){const{style:t,...i}=e;t&&this.style.setProperties(t),super.setProperties(i)}return this}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break}}_updateStyleProperty(e,t,i,s){switch(e){case"backgroundColor":this._updateBackgroundColor();break;case"backgroundImage":this._updateBackgroundImage();break;case"opacity":this._updateOpacity();break;case"visibility":this._updateVisible();break;case"filter":this.requestRepaint();break;case"boxShadow":this._updateBoxShadow();break;case"maskImage":this._updateMaskImage();break;case"borderRadius":this.requestRedraw();break}}_updateBoxShadow(){const e="__$style.shadow";if(this.style.boxShadow!=="none")this.getNode(e)||this.addChild(new d.ShadowEffect,"back");else{const t=this.getNode(e);t&&this.removeChild(t)}}_updateMaskImage(){const e="__$style.maskImage",t=this.style.maskImage;if(t&&t!=="none"){const i=this.getNode(e);i?i.src=t:this.addChild(new d.MaskEffect({src:t}),"back")}else{const i=this.getNode(e);i&&this.removeChild(i)}}_updateBackgroundColor(){const e=this.style.getComputedBackgroundColor();this._originalBatchables.length?this.requestRepaint():e.a>0&&this.requestRedraw()}async _updateBackgroundImage(){this._backgroundImage=await this.style.loadBackgroundImage(),this.requestRedraw()}_updateOpacity(){var t;const e=this.style.getComputedOpacity()*(((t=this.getParent())==null?void 0:t.opacity)??1);this.opacity!==e&&(this.opacity=e,this.requestRepaint())}_updateCurrentTime(e=!1){super._updateCurrentTime(e),this._updateVisible()}_updateVisible(){var t;let e=this.style.visibility==="visible"&&(((t=this.getParent())==null?void 0:t.visible)??!0);e&&!this.isInsideTimeRange()&&(e=!1),this.visible=e}show(){this.style.visibility="visible"}hide(){this.style.visibility="hidden"}isVisibleInTree(){return this.opacity>0&&this.visible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestReflow(){this._reflowing=!0}requestRepaint(){this._repainting=!0}_process(e){const t=this.getParent();this._parentVisible!==(t==null?void 0:t.visible)&&(this._parentVisible=t==null?void 0:t.visible,this._updateVisible()),this._parentOpacity!==(t==null?void 0:t.opacity)&&(this._parentOpacity=t==null?void 0:t.opacity,this._updateOpacity()),super._process(e)}_draw(){this._drawBackground(),this._drawContent(),this._drawBorder(),this._drawOutline()}_drawBackground(){const e=this._backgroundImage;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height),this._fillBoundingRect())}_drawContent(){this._fillBoundingRect()}_drawBorder(){this.style.borderWidth&&this.style.borderStyle!=="none"&&(this.context.lineWidth=this.style.borderWidth,this.context.strokeStyle=this.style.borderColor,this._strokeBoundingRect())}_drawOutline(){this.style.outlineWidth&&this.style.outlineColor!=="none"&&(this.context.lineWidth=this.style.outlineWidth,this.context.strokeStyle=this.style.outlineColor,this._strokeBoundingRect())}_drawBoundingRect(){const{borderRadius:e,width:t,height:i}=this.style;t&&i&&(e?this.context.roundRect(0,0,t,i,e):this.context.rect(0,0,t,i))}_fillBoundingRect(){this._drawBoundingRect(),this.context.fill()}_strokeBoundingRect(){this._drawBoundingRect(),this.context.stroke()}_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.style.getComputedBackgroundColor().abgr,modulate:this._modulate.toArgb(this.opacity,!0),colorMatrix:t.toMatrix4().toArray(!0),colorMatrixOffset:t.toVector4().toArray(),blendMode:this.blendMode}))}_render(e){let t;this._redrawing?(this.emit("draw"),this._draw(),this._originalBatchables=this.context.toBatchables(),this._layoutedBatchables=this._relayout(this._originalBatchables),t=this._layoutedBatchables,this._resetContext&&this.context.reset()):this._reflowing?(this._layoutedBatchables=this._reflow(this._originalBatchables),t=this._layoutedBatchables):this._repainting&&(t=this._repaint(this._layoutedBatchables)),t&&(this._batchables=t,this._redrawing=!1,this._reflowing=!1,this._repainting=!1),this._batchables.forEach(i=>{var s,o;(s=i.texture)==null||s.upload(e),e.batch2D.render({...i,texture:(o=i.texture)==null?void 0:o._glTexture(e)})}),super._render(e)}toJSON(){const e=super.toJSON();return{...e,props:{style:this.style.toJSON(),...e.props}}}},Bs([M()],d.CanvasItem.prototype,"modulate",2),Bs([M()],d.CanvasItem.prototype,"blendMode",2),d.CanvasItem=Bs([j("CanvasItem")],d.CanvasItem);class yu extends d.Node{constructor(){super(...arguments);u(this,"currentCall");u(this,"calls",[])}createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){var i;const t=this.createCall(e);return(((i=this.currentCall)==null?void 0:i.calls)??this.calls).push(t),t}render(e){this.calls.forEach(function t(i){i.fn(e,()=>{i.calls.forEach(t)})}),this.calls=[]}}var _u=Object.defineProperty,vu=Object.getOwnPropertyDescriptor,Dr=(n,r,e,t)=>{for(var i=t>1?void 0:t?vu(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};d.Timeline=class extends d.Node{static from(r,e=!1){const[t,i]=r?Array.isArray(r)?r:[0,r]:[];return new d.Timeline({startTime:t,endTime:i,loop:e})}constructor(r){super(),this.setProperties(r)}_updateProperty(r,e,t){switch(super._updateProperty(r,e,t),r){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(r){const e=this.startTime,t=this.endTime;let i=this.currentTime;return i=i+r,this.loop&&i>t&&(i=e+i%t),i=at(e,i,t),this.currentTime=i,this.emit("updateCurrentTime",i,r),this}_process(r){super._process(r),this.addTime(r)}},Dr([M({default:0})],d.Timeline.prototype,"startTime",2),Dr([M({default:0})],d.Timeline.prototype,"currentTime",2),Dr([M({default:Number.MAX_SAFE_INTEGER})],d.Timeline.prototype,"endTime",2),Dr([M({default:!1})],d.Timeline.prototype,"loop",2),d.Timeline=Dr([j("Timeline")],d.Timeline);var bu=Object.defineProperty,fa=(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 gi extends oi{constructor(e=new d.Timeline){super();u(this,"renderStack",new yu);u(this,"root",new d.Viewport(!0).setTree(this));u(this,"timeline");u(this,"_backgroundColor",new Ct);u(this,"_currentViewport");this.timeline=e.setTree(this)}getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=t;break}}_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{pixelRatio:t}=e,{width:i,height:s}=this.root;e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:i*t,height:s*t}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const o=this.root.texture;o.activate(e,0),J.draw(e),e.texture.unbind(o)}}fa([M({default:!1})],gi.prototype,"paused"),fa([M()],gi.prototype,"backgroundColor");var wu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,Pu=(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};d.Transition=class extends d.Effect{constructor(r,e=[]){super(),this.setProperties(r).append(e)}},d.Transition=Pu([j("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],d.Transition);var Cu=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&&Cu(r,e,i),i};d.Node2D=class extends d.CanvasItem{constructor(e,t=[]){super();u(this,"transform",new et);u(this,"_parentTransformDirtyId");this.setProperties(e).append(t)}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":case"height":this.mask instanceof d.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()}getRect(){const[e,t,i,s,o,a]=this.transform.toArray(),l=this.style.width,h=this.style.height;return new ni(i,a,e*l+t*h,s*l+o*h)}_updateOverflow(){if(this.style.overflow==="hidden"){const e=this.getRect();this.mask={x:e.x,y:e.y,width:e.width,height:e.height}}else this.mask=void 0}_transformVertices(e){const[t,i,s,o,a,l]=this.transform.toArray(),h=e.slice();for(let c=e.length,f=0;f<c;f+=2){const p=e[f],m=e[f+1];h[f]=t*p+i*m+s,h[f+1]=o*p+a*m+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,t){if(super._input(e,t),!e.target&&this.isVisibleInTree()&&this.style.canPointeEvents())switch(t){case"pointerdown":case"pointermove":case"pointerup":{const{screenX:i,screenY:s}=e;if(i&&s){const{width:o,height:a}=this.style,[l,h]=this.transform.inverse().applyToPoint(i,s);l>=0&&l<o&&h>=0&&h<a&&(e.target=this,this.emit(t,e))}break}}}clone(){return new this.constructor(this.toJSON(),this.getChildren(!0))}},d.Node2D=Su([j("Node2D")],d.Node2D);var Eu=Object.defineProperty,Mu=Object.getOwnPropertyDescriptor,me=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Eu(r,e,i),i};function ve(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})}}d.Graphics2D=class extends d.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}},me([ve()],d.Graphics2D.prototype,"lineCap",2),me([ve()],d.Graphics2D.prototype,"lineJoin",2),me([ve()],d.Graphics2D.prototype,"fillStyle",2),me([ve()],d.Graphics2D.prototype,"strokeStyle",2),me([ve()],d.Graphics2D.prototype,"lineWidth",2),me([ve()],d.Graphics2D.prototype,"miterLimit",2),me([ve({method:!0})],d.Graphics2D.prototype,"rect",2),me([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"fillRect",2),me([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"strokeRect",2),me([ve({method:!0})],d.Graphics2D.prototype,"roundRect",2),me([ve({method:!0})],d.Graphics2D.prototype,"ellipse",2),me([ve({method:!0})],d.Graphics2D.prototype,"arc",2),me([ve({method:!0})],d.Graphics2D.prototype,"beginPath",2),me([ve({method:!0})],d.Graphics2D.prototype,"moveTo",2),me([ve({method:!0})],d.Graphics2D.prototype,"lineTo",2),me([ve({method:!0})],d.Graphics2D.prototype,"closePath",2),me([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"fill",2),me([ve({method:!0,redraw:!0})],d.Graphics2D.prototype,"stroke",2),d.Graphics2D=me([j("Graphics2D")],d.Graphics2D);class mi extends yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof ge)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 Au=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,yi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ou(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&&Au(r,e,i),i};d.Image2D=class extends d.Node2D{constructor(e,t=[]){super();u(this,"resource");u(this,"_frameIndex",0);u(this,"_complete",!1);u(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get currentTexture(){var e,t;return(t=(e=this.resource)==null?void 0:e.frames[this._frameIndex])==null?void 0:t.texture}get framesDuration(){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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}decode(){return this._wait}setResource(e){let t;if(e instanceof mi?t=e:t=new mi(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 Pt.gif.load(e):await Pt.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}_getFrameCurrentTime(){const e=this.framesDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.resource)return this;const e=this._getFrameCurrentTime(),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 et().scale(this.style.width/e.width,this.style.height/e.height),super._drawContent())}},yi([ue()],d.Image2D.prototype,"resource",2),yi([M({default:!1})],d.Image2D.prototype,"gif",2),yi([M({default:""})],d.Image2D.prototype,"src",2),d.Image2D=yi([j("Image2D")],d.Image2D);class _i extends d.Node2D{constructor(){super(...arguments);u(this,"texture")}_drawContent(){var e;(e=this.texture)!=null&&e.valid&&(this.context.fillStyle=this.texture,this.context.textureTransform=new et().scale(this.style.width/this.texture.width,this.style.height/this.texture.height),super._drawContent())}}var Uu=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,da=(n,r,e,t)=>{for(var i=t>1?void 0:t?Iu(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Uu(r,e,i),i};d.Lottie2D=class extends _i{constructor(e,t=[]){super();u(this,"texture",new Er);u(this,"animation");this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._load();break}}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await Pt.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.currentTime,!1),this.texture.requestUpload(),this.requestRepaint(),super._process(e)}},da([M({default:""})],d.Lottie2D.prototype,"src",2),d.Lottie2D=da([j("Lottie2D")],d.Lottie2D);var Ae=Uint8Array,Ge=Uint16Array,ks=Int32Array,vi=new Ae([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]),bi=new Ae([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]),Ls=new Ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pa=function(n,r){for(var e=new Ge(31),t=0;t<31;++t)e[t]=r+=1<<n[t-1];for(var i=new ks(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}},ga=pa(vi,2),ma=ga.b,Ns=ga.r;ma[28]=258,Ns[258]=28;for(var ya=pa(bi,0),Du=ya.b,_a=ya.r,Fs=new Ge(32768),te=0;te<32768;++te){var Et=(te&43690)>>1|(te&21845)<<1;Et=(Et&52428)>>2|(Et&13107)<<2,Et=(Et&61680)>>4|(Et&3855)<<4,Fs[te]=((Et&65280)>>8|(Et&255)<<8)>>1}for(var ut=function(n,r,e){for(var t=n.length,i=0,s=new Ge(r);i<t;++i)n[i]&&++s[n[i]-1];var o=new Ge(r);for(i=1;i<r;++i)o[i]=o[i-1]+s[i-1]<<1;var a;if(e){a=new Ge(1<<r);var l=15-r;for(i=0;i<t;++i)if(n[i])for(var h=i<<4|n[i],c=r-n[i],f=o[n[i]-1]++<<c,p=f|(1<<c)-1;f<=p;++f)a[Fs[f]>>l]=h}else for(a=new Ge(t),i=0;i<t;++i)n[i]&&(a[i]=Fs[o[n[i]-1]++]>>15-n[i]);return a},Mt=new Ae(288),te=0;te<144;++te)Mt[te]=8;for(var te=144;te<256;++te)Mt[te]=9;for(var te=256;te<280;++te)Mt[te]=7;for(var te=280;te<288;++te)Mt[te]=8;for(var Rr=new Ae(32),te=0;te<32;++te)Rr[te]=5;var Ru=ut(Mt,9,0),Bu=ut(Mt,9,1),ku=ut(Rr,5,0),Lu=ut(Rr,5,1),$s=function(n){for(var r=n[0],e=1;e<n.length;++e)n[e]>r&&(r=n[e]);return r},tt=function(n,r,e){var t=r/8|0;return(n[t]|n[t+1]<<8)>>(r&7)&e},zs=function(n,r){var e=r/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(r&7)},Vs=function(n){return(n+7)/8|0},va=function(n,r,e){return(e==null||e>n.length)&&(e=n.length),new Ae(n.subarray(r,e))},Nu=["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"],rt=function(n,r,e){var t=new Error(r||Nu[n]);if(t.code=n,Error.captureStackTrace&&Error.captureStackTrace(t,rt),!e)throw t;return t},Fu=function(n,r,e,t){var i=n.length,s=0;if(!i||r.f&&!r.l)return e||new Ae(0);var o=!e,a=o||r.i!=2,l=r.i;o&&(e=new Ae(i*3));var h=function(Ne){var ze=e.length;if(Ne>ze){var Ee=new Ae(Math.max(ze*2,Ne));Ee.set(e),e=Ee}},c=r.f||0,f=r.p||0,p=r.b||0,m=r.l,g=r.d,_=r.m,y=r.n,E=i*8;do{if(!m){c=tt(n,f,1);var T=tt(n,f+1,3);if(f+=3,T)if(T==1)m=Bu,g=Lu,_=9,y=5;else if(T==2){var v=tt(n,f,31)+257,x=tt(n,f+10,15)+4,C=v+tt(n,f+5,31)+1;f+=14;for(var I=new Ae(C),F=new Ae(19),B=0;B<x;++B)F[Ls[B]]=tt(n,f+B*3,7);f+=x*3;for(var U=$s(F),V=(1<<U)-1,A=ut(F,U,1),B=0;B<C;){var N=A[tt(n,f,V)];f+=N&15;var P=N>>4;if(P<16)I[B++]=P;else{var W=0,R=0;for(P==16?(R=3+tt(n,f,3),f+=2,W=I[B-1]):P==17?(R=3+tt(n,f,7),f+=3):P==18&&(R=11+tt(n,f,127),f+=7);R--;)I[B++]=W}}var D=I.subarray(0,v),G=I.subarray(v);_=$s(D),y=$s(G),m=ut(D,_,1),g=ut(G,y,1)}else rt(1);else{var P=Vs(f)+4,S=n[P-4]|n[P-3]<<8,w=P+S;if(w>i){l&&rt(0);break}a&&h(p+S),e.set(n.subarray(P,w),p),r.b=p+=S,r.p=f=w*8,r.f=c;continue}if(f>E){l&&rt(0);break}}a&&h(p+131072);for(var L=(1<<_)-1,k=(1<<y)-1,K=f;;K=f){var W=m[zs(n,f)&L],H=W>>4;if(f+=W&15,f>E){l&&rt(0);break}if(W||rt(2),H<256)e[p++]=H;else if(H==256){K=f,m=null;break}else{var X=H-254;if(H>264){var B=H-257,q=vi[B];X=tt(n,f,(1<<q)-1)+ma[B],f+=q}var ee=g[zs(n,f)&k],Y=ee>>4;ee||rt(3),f+=ee&15;var G=Du[Y];if(Y>3){var q=bi[Y];G+=zs(n,f)&(1<<q)-1,f+=q}if(f>E){l&&rt(0);break}a&&h(p+131072);var ae=p+X;if(p<G){var pt=s-G,Ke=Math.min(G,ae);for(pt+p<0&&rt(3);p<Ke;++p)e[p]=t[pt+p]}for(;p<ae;++p)e[p]=e[p-G]}}r.l=m,r.p=K,r.b=p,r.f=c,m&&(c=1,r.m=_,r.d=g,r.n=y)}while(!c);return p!=e.length&&o?va(e,0,p):e.subarray(0,p)},wt=function(n,r,e){e<<=r&7;var t=r/8|0;n[t]|=e,n[t+1]|=e>>8},Br=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},js=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:Pa,l:0};if(i==1){var o=new Ae(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort(function(w,v){return w.f-v.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,c=1,f=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=e[e[h].f<e[f].f?h++:f++],l=e[h!=c&&e[h].f<e[f].f?h++:f++],e[c++]={s:-1,f:a.f+l.f,l:a,r:l};for(var p=s[0].s,t=1;t<i;++t)s[t].s>p&&(p=s[t].s);var m=new Ge(p+1),g=Gs(e[c-1],m,0);if(g>r){var t=0,_=0,y=g-r,E=1<<y;for(s.sort(function(v,x){return m[x.s]-m[v.s]||v.f-x.f});t<i;++t){var T=s[t].s;if(m[T]>r)_+=E-(1<<g-m[T]),m[T]=r;else break}for(_>>=y;_>0;){var P=s[t].s;m[P]<r?_-=1<<r-m[P]++-1:++t}for(;t>=0&&_;--t){var S=s[t].s;m[S]==r&&(--m[S],++_)}g=r}return{t:new Ae(m),l:g}},Gs=function(n,r,e){return n.s==-1?Math.max(Gs(n.l,r,e+1),Gs(n.r,r,e+1)):r[n.s]=e},ba=function(n){for(var r=n.length;r&&!n[--r];);for(var e=new Ge(++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}},kr=function(n,r){for(var e=0,t=0;t<r.length;++t)e+=n[t]*r[t];return e},wa=function(n,r,e){var t=e.length,i=Vs(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},xa=function(n,r,e,t,i,s,o,a,l,h,c){wt(r,c++,e),++i[256];for(var f=js(i,15),p=f.t,m=f.l,g=js(s,15),_=g.t,y=g.l,E=ba(p),T=E.c,P=E.n,S=ba(_),w=S.c,v=S.n,x=new Ge(19),C=0;C<T.length;++C)++x[T[C]&31];for(var C=0;C<w.length;++C)++x[w[C]&31];for(var I=js(x,7),F=I.t,B=I.l,U=19;U>4&&!F[Ls[U-1]];--U);var V=h+5<<3,A=kr(i,Mt)+kr(s,Rr)+o,N=kr(i,p)+kr(s,_)+o+14+3*U+kr(x,F)+2*x[16]+3*x[17]+7*x[18];if(l>=0&&V<=A&&V<=N)return wa(r,c,n.subarray(l,l+h));var W,R,D,G;if(wt(r,c,1+(N<A)),c+=2,N<A){W=ut(p,m,0),R=p,D=ut(_,y,0),G=_;var L=ut(F,B,0);wt(r,c,P-257),wt(r,c+5,v-1),wt(r,c+10,U-4),c+=14;for(var C=0;C<U;++C)wt(r,c+3*C,F[Ls[C]]);c+=3*U;for(var k=[T,w],K=0;K<2;++K)for(var H=k[K],C=0;C<H.length;++C){var X=H[C]&31;wt(r,c,L[X]),c+=F[X],X>15&&(wt(r,c,H[C]>>5&127),c+=H[C]>>12)}}else W=Ru,R=Mt,D=ku,G=Rr;for(var C=0;C<a;++C){var q=t[C];if(q>255){var X=q>>18&31;Br(r,c,W[X+257]),c+=R[X+257],X>7&&(wt(r,c,q>>23&31),c+=vi[X]);var ee=q&31;Br(r,c,D[ee]),c+=G[ee],ee>3&&(Br(r,c,q>>5&8191),c+=bi[ee])}else Br(r,c,W[q]),c+=R[q]}return Br(r,c,W[256]),c+R[256]},$u=new ks([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pa=new Ae(0),zu=function(n,r,e,t,i,s){var o=s.z||n.length,a=new Ae(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=$u[r-1],p=f>>13,m=f&8191,g=(1<<e)-1,_=s.p||new Ge(32768),y=s.h||new Ge(g+1),E=Math.ceil(e/3),T=2*E,P=function(Ve){return(n[Ve]^n[Ve+1]<<E^n[Ve+2]<<T)&g},S=new ks(25e3),w=new Ge(288),v=new Ge(32),x=0,C=0,I=s.i||0,F=0,B=s.w||0,U=0;I+2<o;++I){var V=P(I),A=I&32767,N=y[V];if(_[A]=N,y[V]=A,B<=I){var W=o-I;if((x>7e3||F>24576)&&(W>423||!h)){c=xa(n,l,0,S,w,v,C,F,U,I-U,c),F=x=C=0,U=I;for(var R=0;R<286;++R)w[R]=0;for(var R=0;R<30;++R)v[R]=0}var D=2,G=0,L=m,k=A-N&32767;if(W>2&&V==P(I-k))for(var K=Math.min(p,W)-1,H=Math.min(32767,I),X=Math.min(258,W);k<=H&&--L&&A!=N;){if(n[I+D]==n[I+D-k]){for(var q=0;q<X&&n[I+q]==n[I+q-k];++q);if(q>D){if(D=q,G=k,q>K)break;for(var ee=Math.min(k,q-2),Y=0,R=0;R<ee;++R){var ae=I-k+R&32767,pt=_[ae],Ke=ae-pt&32767;Ke>Y&&(Y=Ke,N=ae)}}}A=N,N=_[A],k+=A-N&32767}if(G){S[F++]=268435456|Ns[D]<<18|_a[G];var Ne=Ns[D]&31,ze=_a[G]&31;C+=vi[Ne]+bi[ze],++w[257+Ne],++v[ze],B=I+D,++x}else S[F++]=n[I],++w[n[I]]}}for(I=Math.max(I,B);I<o;++I)S[F++]=n[I],++w[n[I]];c=xa(n,l,h,S,w,v,C,F,U,I-U,c),h||(s.r=c&7|l[c/8|0]<<3,c-=7,s.h=y,s.p=_,s.i=I,s.w=B)}else{for(var I=s.w||0;I<o+h;I+=65535){var Ee=I+65535;Ee>=o&&(l[c/8|0]=h,Ee=o),c=wa(l,c+1,n.subarray(I,Ee))}s.i=o}return va(a,0,t+Vs(c)+i)},Ca=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}}},Vu=function(n,r,e,t,i){if(!i&&(i={l:1},r.dictionary)){var s=r.dictionary.subarray(-32768),o=new Ae(s.length+n.length);o.set(s),o.set(n,s.length),n=o,i.w=s.length}return zu(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)},Ta=function(n,r,e){for(;e;++r)n[r]=e,e>>>=8},ju=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=Ca();i.p(r.dictionary),Ta(n,2,i.d())}},Gu=function(n,r){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&rt(6,"invalid zlib data"),(n[1]>>5&1)==1&&rt(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function qu(n,r){r||(r={});var e=Ca();e.p(n);var t=Vu(n,r,r.dictionary?6:2,4);return ju(t,r),Ta(t,t.length-4,e.d()),t}function Wu(n,r){return Fu(n.subarray(Gu(n),-4),{i:2},r,r)}var Xu=typeof TextDecoder<"u"&&new TextDecoder,Hu=0;try{Xu.decode(Pa,{stream:!0}),Hu=1}catch{}const Yu="modern-font";function Lr(n,r){if(!n)throw new Error(`[${Yu}] ${r}`)}function Zu(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 or(n){return"buffer"in n?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n)}function Ku(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 wi(n){n=Ku(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 Ju(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 Qu(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 ef=Object.defineProperty,Oe=(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&&ef(r,e,i),i};const Nr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ue(){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 be extends DataView{constructor(e,t,i,s){super(Zu(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+=Nr[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+=Nr[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=or(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}}Oe([Ue()],be.prototype,"readInt8"),Oe([Ue()],be.prototype,"readInt16"),Oe([Ue()],be.prototype,"readInt32"),Oe([Ue()],be.prototype,"readUint8"),Oe([Ue()],be.prototype,"readUint16"),Oe([Ue()],be.prototype,"readUint32"),Oe([Ue()],be.prototype,"readFloat32"),Oe([Ue()],be.prototype,"readFloat64"),Oe([Ue()],be.prototype,"writeInt8"),Oe([Ue()],be.prototype,"writeInt16"),Oe([Ue()],be.prototype,"writeInt32"),Oe([Ue()],be.prototype,"writeUint8"),Oe([Ue()],be.prototype,"writeUint16"),Oe([Ue()],be.prototype,"writeUint32"),Oe([Ue()],be.prototype,"writeFloat32"),Oe([Ue()],be.prototype,"writeFloat64");const Sa=new WeakMap;function b(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=Sa.get(i);o||(o={columns:[],byteLength:0},Sa.set(i,o));const a={...r,name:s,byteLength:e*Nr[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+Nr[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 qe{constructor(r,e,t,i){u(this,"view");this.view=new be(r,e,t,i)}}class xi extends qe{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 tf=Object.defineProperty,Re=(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&&tf(r,e,i),i};const Be=class ul extends xi{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=wi(s.fontFamily||""),a=o.length,l=wi(s.fontStyle||""),h=l.length,c=wi(s.version||""),f=c.length,p=wi(s.fullName||""),m=p.length,g=86+a+4+h+4+f+4+m+2+e.view.byteLength,_=new ul(new ArrayBuffer(g),0,g,!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(m),_.view.writeBytes(p),_.view.writeUint16(0),_.view.writeUint16(0),_.view.writeBytes(e.view),_}};Re([b("uint32")],Be.prototype,"EOTSize"),Re([b("uint32")],Be.prototype,"FontDataSize"),Re([b("uint32")],Be.prototype,"Version"),Re([b("uint32")],Be.prototype,"Flags"),Re([b({type:"uint8",size:10})],Be.prototype,"FontPANOSE"),Re([b("uint8")],Be.prototype,"Charset"),Re([b("uint8")],Be.prototype,"Italic"),Re([b("uint32")],Be.prototype,"Weight"),Re([b("uint16")],Be.prototype,"fsType"),Re([b("uint16")],Be.prototype,"MagicNumber"),Re([b({type:"uint8",size:16})],Be.prototype,"UnicodeRange"),Re([b({type:"uint8",size:8})],Be.prototype,"CodePageRange"),Re([b("uint32")],Be.prototype,"CheckSumAdjustment"),Re([b({type:"uint8",size:16})],Be.prototype,"Reserved"),Re([b("uint16")],Be.prototype,"Padding1");var rf=Object.defineProperty,Pi=(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&&rf(r,e,i),i};class ar extends qe{constructor(r,e){super(r,e,16)}}Pi([b({type:"char",size:4})],ar.prototype,"tag"),Pi([b("uint32")],ar.prototype,"checkSum"),Pi([b("uint32")],ar.prototype,"offset"),Pi([b("uint32")],ar.prototype,"length");const qs=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],sf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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 Ws{constructor(r){u(this,"index");u(this,"name");u(this,"isComposite",!1);u(this,"components",[]);u(this,"pathCommands",[]);const e={...r};if(this.index=e.index??0,e.name===".notdef"?e.unicode=void 0:e.name===".null"&&(e.unicode=0),e.unicode===0&&e.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=e.name??null,e.unicode&&(this.unicode=e.unicode),e.unicodes?this.unicodes=e.unicodes:e.unicode&&(this.unicodes=[e.unicode])}getPathCommands(r=0,e=0,t=72,i={},s){const o=1/((s==null?void 0:s.unitsPerEm)??1e3)*t,{xScale:a=o,yScale:l=o}=i,h=this.pathCommands,c=[];for(let f=0,p=h.length;f<p;f+=1){const m=h[f];m.type==="M"?c.push({type:"M",x:r+m.x*a,y:e+-m.y*l}):m.type==="L"?c.push({type:"L",x:r+m.x*a,y:e+-m.y*l}):m.type==="Q"?c.push({type:"Q",x1:r+m.x1*a,y1:e+-m.y1*l,x:r+m.x*a,y:e+-m.y*l}):m.type==="C"?c.push({type:"C",x1:r+m.x1*a,y1:e+-m.y1*l,x2:r+m.x2*a,y2:e+-m.y2*l,x:r+m.x*a,y:e+-m.y*l}):m.type==="Z"&&c.push({type:"Z"})}return c}}class nf extends Ws{parse(r,e,t){const i=this,{nominalWidthX:s,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=r,h=r.topDict.paintType,c=this.index;let f,p,m,g;const _=[],y=[];let E=0,T=!1,P=!1,S=o,w=0,v=0;function x(A,N){_.push({type:"L",x:A,y:N})}function C(A,N,W,R,D,G){_.push({type:"C",x1:A,y1:N,x2:W,y2:R,x:D,y:G})}function I(A,N){P&&h!==2&&F(),P=!0,_.push({type:"M",x:A,y:N})}function F(){_.push({type:"Z"})}function B(A){_.push(...A)}function U(){y.length%2!==0&&!T&&(S=y.shift()+s),E+=y.length>>1,y.length=0,T=!0}function V(A){let N,W,R,D,G,L,k,K,H,X,q,ee,Y=0;for(;Y<A.length;){let ae=A[Y++];switch(ae){case 1:U();break;case 3:U();break;case 4:y.length>1&&!T&&(S=y.shift()+s,T=!0),v+=y.pop(),I(w,v);break;case 5:for(;y.length>0;)w+=y.shift(),v+=y.shift(),x(w,v);break;case 6:for(;y.length>0&&(w+=y.shift(),x(w,v),y.length!==0);)v+=y.shift(),x(w,v);break;case 7:for(;y.length>0&&(v+=y.shift(),x(w,v),y.length!==0);)w+=y.shift(),x(w,v);break;case 8:for(;y.length>0;)f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);break;case 10:G=y.pop()+l,L=r.subrs[G],L&&V(L);break;case 11:return;case 12:switch(ae=A[Y],Y+=1,ae){case 35:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),k=m+y.shift(),K=g+y.shift(),H=k+y.shift(),X=K+y.shift(),q=H+y.shift(),ee=X+y.shift(),w=q+y.shift(),v=ee+y.shift(),y.shift(),C(f,p,m,g,k,K),C(H,X,q,ee,w,v);break;case 34:f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),k=m+y.shift(),K=g,H=k+y.shift(),X=g,q=H+y.shift(),ee=v,w=q+y.shift(),C(f,p,m,g,k,K),C(H,X,q,ee,w,v);break;case 36:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),k=m+y.shift(),K=g,H=k+y.shift(),X=g,q=H+y.shift(),ee=X+y.shift(),w=q+y.shift(),C(f,p,m,g,k,K),C(H,X,q,ee,w,v);break;case 37:f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),k=m+y.shift(),K=g+y.shift(),H=k+y.shift(),X=K+y.shift(),q=H+y.shift(),ee=X+y.shift(),Math.abs(q-w)>Math.abs(ee-v)?w=q+y.shift():v=ee+y.shift(),C(f,p,m,g,k,K),C(H,X,q,ee,w,v);break;default:console.warn(`Glyph ${c}: unknown operator ${1200+ae}`),y.length=0}break;case 14:if(y.length>=4){const pt=qs[y.pop()],Ke=qs[y.pop()],Ne=y.pop(),ze=y.pop();if(pt&&Ke){i.isComposite=!0,i.components=[];const Ee=r.charset.indexOf(pt),Ve=r.charset.indexOf(Ke);i.components.push({glyphIndex:Ve,dx:0,dy:0}),i.components.push({glyphIndex:Ee,dx:ze,dy:Ne}),B(t.get(Ve).pathCommands);const it=JSON.parse(JSON.stringify(t.get(Ee).pathCommands));for(let st=0;st<it.length;st+=1){const Je=it[st];Je.type!=="Z"&&(Je.x+=ze,Je.y+=Ne),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=ze,Je.y1+=Ne),Je.type==="C"&&(Je.x2+=ze,Je.y2+=Ne)}B(it)}}else y.length>0&&!T&&(S=y.shift()+s,T=!0);P&&h!==2&&(F(),P=!1);break;case 18:U();break;case 19:case 20:U(),Y+=E+7>>3;break;case 21:y.length>2&&!T&&(S=y.shift()+s,T=!0),v+=y.pop(),w+=y.pop(),I(w,v);break;case 22:y.length>1&&!T&&(S=y.shift()+s,T=!0),w+=y.pop(),I(w,v);break;case 23:U();break;case 24:for(;y.length>2;)f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);w+=y.shift(),v+=y.shift(),x(w,v);break;case 25:for(;y.length>6;)w+=y.shift(),v+=y.shift(),x(w,v);f=w+y.shift(),p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+y.shift(),C(f,p,m,g,w,v);break;case 26:for(y.length%2&&(w+=y.shift());y.length>0;)f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m,v=g+y.shift(),C(f,p,m,g,w,v);break;case 27:for(y.length%2&&(v+=y.shift());y.length>0;)f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g,C(f,p,m,g,w,v);break;case 28:N=A[Y],W=A[Y+1],y.push((N<<24|W<<16)>>16),Y+=2;break;case 29:G=y.pop()+a,L=r.gsubrs[G],L&&V(L);break;case 30:for(;y.length>0&&(f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+(y.length===1?y.shift():0),C(f,p,m,g,w,v),y.length!==0);)f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),v=g+y.shift(),w=m+(y.length===1?y.shift():0),C(f,p,m,g,w,v);break;case 31:for(;y.length>0&&(f=w+y.shift(),p=v,m=f+y.shift(),g=p+y.shift(),v=g+y.shift(),w=m+(y.length===1?y.shift():0),C(f,p,m,g,w,v),y.length!==0);)f=w,p=v+y.shift(),m=f+y.shift(),g=p+y.shift(),w=m+y.shift(),v=g+(y.length===1?y.shift():0),C(f,p,m,g,w,v);break;default:ae<32?console.warn(`Glyph ${c}: unknown operator ${ae}`):ae<247?y.push(ae-139):ae<251?(N=A[Y],Y+=1,y.push((ae-247)*256+N+108)):ae<255?(N=A[Y],Y+=1,y.push(-(ae-251)*256-N-108)):(N=A[Y],W=A[Y+1],R=A[Y+2],D=A[Y+3],Y+=4,y.push((N<<24|W<<16|R<<8|D)/65536))}}}V(e),this.pathCommands=_,T&&(this.advanceWidth=S)}}class Xs{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 of extends Xs{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(r){const e=this._sfnt.cff,t=new nf({index:r});return t.parse(e,e.charStringsIndex.get(r),this),t.name=e.charset[r],t}}var af=Object.defineProperty,Ea=(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 Ci extends qe{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)}}Ea([b("uint16")],Ci.prototype,"count"),Ea([b("uint8")],Ci.prototype,"offsetSize");class Ti extends Ci{constructor(){super(...arguments);u(this,"_isString",!1)}}class Ma extends Ci{constructor(){super(...arguments);u(this,"_isString",!0)}}const lf=[".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"],hf=[".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"],cf=[".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"],uf=[".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 Si(n,r){return r<=390?lf[r]:n[r-391]}function re(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 Aa extends qe{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 Si(((i=this._stringIndex)==null?void 0:i.objects)??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var ff=Object.defineProperty,Hs=(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&&ff(r,e,i),i};class Ei extends Aa{}Hs([re(19)],Ei.prototype,"subrs"),Hs([re(20)],Ei.prototype,"defaultWidthX"),Hs([re(21)],Ei.prototype,"nominalWidthX");var df=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&&df(r,e,i),i};class oe extends Aa{}ce([re(0,"string")],oe.prototype,"version"),ce([re(1,"string")],oe.prototype,"notice"),ce([re(1200,"string")],oe.prototype,"copyright"),ce([re(2,"string")],oe.prototype,"fullName"),ce([re(3,"string")],oe.prototype,"familyName"),ce([re(4,"string")],oe.prototype,"weight"),ce([re(1201)],oe.prototype,"isFixedPitch"),ce([re(1202)],oe.prototype,"italicAngle"),ce([re(1203,"number",-100)],oe.prototype,"underlinePosition"),ce([re(1204,"number",50)],oe.prototype,"underlineThickness"),ce([re(1205)],oe.prototype,"paintType"),ce([re(1206,"number",2)],oe.prototype,"charstringType"),ce([re(1207,"number[]",[.001,0,0,.001,0,0])],oe.prototype,"fontMatrix"),ce([re(13)],oe.prototype,"uniqueId"),ce([re(5,"number[]",[0,0,0,0])],oe.prototype,"fontBBox"),ce([re(1208)],oe.prototype,"strokeWidth"),ce([re(14)],oe.prototype,"xuid"),ce([re(15)],oe.prototype,"charset"),ce([re(16)],oe.prototype,"encoding"),ce([re(17)],oe.prototype,"charStrings"),ce([re(18,"number[]",[0,0])],oe.prototype,"private");function Ce(n,r=n){return e=>{zt.tableDefinitions.set(n,{tag:n,prop:r,class:e}),Object.defineProperty(zt.prototype,r,{get(){return this.get(n)},set(t){return this.set(n,t)},configurable:!0,enumerable:!0})}}const Ht=class Ht{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 numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}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 Ht(this.tableViews)}delete(r){const e=Ht.tableDefinitions.get(r);return e?(this.tableViews.delete(r),this.tables.delete(e.prop),this):this}set(r,e){const t=Ht.tableDefinitions.get(r);return t&&this.tables.set(t.prop,e),this.tableViews.set(r,e.view),this}get(r){const e=Ht.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(Ht,"tableDefinitions",new Map);let zt=Ht;class Ie extends qe{setSFNT(r){return this._sfnt=r,this}getSFNT(){return this._sfnt}}var pf=Object.defineProperty,gf=Object.getOwnPropertyDescriptor,Fr=(n,r,e,t)=>{for(var i=t>1?void 0:t?gf(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&&pf(r,e,i),i};let Vt=class extends Ie{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 of(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 Ma(e,i),this.topDictIndex=new Ti(e,this.nameIndex.endOffset),this.stringIndex=new Ma(e,this.topDictIndex.endOffset),this.globalSubrIndex=new Ti(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 Ei(e,t+o,s).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Ti(e,t+o+this.privateDict.subrs))),this.charStringsIndex=new Ti(e,t+this.topDict.charStrings);const a=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=hf:this.topDict.charset===1?this.charset=cf:this.topDict.charset===2?this.charset=uf:this.charset=this._readCharset(t+this.topDict.charset,a,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=qs:this.topDict.encoding===1?this.encoding=sf: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(Si(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(Si(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(Si(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}};Fr([b("uint8")],Vt.prototype,"majorVersion",2),Fr([b("uint8")],Vt.prototype,"minorVersion",2),Fr([b("uint8")],Vt.prototype,"headerSize",2),Fr([b("uint8")],Vt.prototype,"offsetSize",2),Vt=Fr([Ce("CFF ","cff")],Vt);var mf=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&&mf(r,e,i),i};const $r=class fl extends qe{constructor(r=new ArrayBuffer(262),e){super(r,e,262)}static from(r){const e=new fl;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}};Mi([b("uint16")],$r.prototype,"format"),Mi([b("uint16")],$r.prototype,"length"),Mi([b("uint16")],$r.prototype,"language"),Mi([b({type:"uint8",size:256})],$r.prototype,"glyphIndexArray");let Ys=$r;var yf=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&&yf(r,e,i),i};class zr extends qe{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((r,e)=>Math.max(r,e),0)}get subHeaders(){const r=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:r},(e,t)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(r-t)*8-2)/2}))}get glyphIndexArray(){const r=this.maxSubHeaderKey,e=6+256*2+r*8;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(r){const e=new Map,t=this.subHeaderKeys,i=this.maxSubHeaderKey,s=this.subHeaders,o=this.glyphIndexArray,a=t.findIndex(h=>h===i);let l=0;for(let h=0;h<256;h++)if(t[h]===0)h>=a||h<s[0].firstCode||h>=s[0].firstCode+s[0].entryCount||s[0].idRangeOffset+(h-s[0].firstCode)>=o.length?l=0:(l=o[s[0].idRangeOffset+(h-s[0].firstCode)],l!==0&&(l=l+s[0].idDelta)),l!==0&&l<r&&e.set(h,l);else{const c=t[h];for(let f=0,p=s[c].entryCount;f<p;f++)if(s[c].idRangeOffset+f>=o.length?l=0:(l=o[s[c].idRangeOffset+f],l!==0&&(l=l+s[c].idDelta)),l!==0&&l<r){const m=(h<<8|f+s[c].firstCode)%65535;e.set(m,l)}}return e}}Zs([b("uint16")],zr.prototype,"format"),Zs([b("uint16")],zr.prototype,"length"),Zs([b("uint16")],zr.prototype,"language");function Oa(n){return n>32767?n-65536:n<-32767?n+65536:n}function Ks(n,r){let e;const t=[];let i={};return n.forEach((s,o)=>{r&&o>r||((!e||o!==e.unicode+1||s!==e.glyphIndex+1)&&(e?(i.end=e.unicode,t.push(i),i={start:o,startId:s,delta:Oa(s-o)}):(i.start=Number(o),i.startId=s,i.delta=Oa(s-o))),e={unicode:o,glyphIndex:s})}),e&&(i.end=e.unicode,t.push(i)),t}var _f=Object.defineProperty,jt=(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&&_f(r,e,i),i};const At=class dl extends qe{get endCode(){const r=this.segCountX2;return this.view.seek(14),Array.from({length:r/2},()=>this.view.readUint16())}set endCode(r){this.view.seek(14),r.forEach(e=>this.view.writeUint16(e))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(r){this.view.writeUint16(r,14+this.segCountX2)}get startCode(){const r=this.segCountX2;return this.view.seek(14+r+2),Array.from({length:r/2},()=>this.view.readUint16())}set startCode(r){this.view.seek(14+this.segCountX2+2),r.forEach(e=>this.view.writeUint16(e))}get idDelta(){const r=this.segCountX2;return this.view.seek(14+r+2+r),Array.from({length:r/2},()=>this.view.readUint16())}set idDelta(r){const e=this.segCountX2;this.view.seek(14+e+2+e),r.forEach(t=>this.view.writeUint16(t))}get idRangeOffsetCursor(){const r=this.segCountX2;return 14+r+2+r*2}get idRangeOffset(){const r=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:r/2},()=>this.view.readUint16())}set idRangeOffset(r){this.view.seek(this.idRangeOffsetCursor),r.forEach(e=>this.view.writeUint16(e))}get glyphIndexArrayCursor(){const r=this.segCountX2;return 14+r+2+r*3}get glyphIndexArray(){const r=this.glyphIndexArrayCursor;this.view.seek(r);const e=(this.view.byteLength-r)/2;return Array.from({length:e},()=>this.view.readUint16())}static from(r){const e=Ks(r,65535),t=e.length+1,i=Math.floor(Math.log(t)/Math.LN2),s=2*2**i,o=new dl(new ArrayBuffer(24+e.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=t*2,o.searchRange=s,o.entrySelector=i,o.rangeShift=2*t-s,o.endCode=[...e.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...e.map(a=>a.start),65535],o.idDelta=[...e.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:t},()=>0),o}getUnicodeToGlyphIndexMap(){const r=new Map,e=this.segCountX2/2,t=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,s=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let h=0;h<e;++h)for(let c=i[h],f=s[h];c<=f;++c)if(o[h]===0)r.set(c,(c+a[h])%65536);else{const p=h+o[h]/2+(c-i[h])-t,m=l[p];m!==0?r.set(c,(m+a[h])%65536):r.set(c,0)}return r.delete(65535),r}};jt([b("uint16")],At.prototype,"format"),jt([b("uint16")],At.prototype,"length"),jt([b("uint16")],At.prototype,"language"),jt([b("uint16")],At.prototype,"segCountX2"),jt([b("uint16")],At.prototype,"searchRange"),jt([b("uint16")],At.prototype,"entrySelector"),jt([b("uint16")],At.prototype,"rangeShift");let Js=At;var vf=Object.defineProperty,Vr=(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&&vf(r,e,i),i};class Gt extends qe{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}}Vr([b("uint16")],Gt.prototype,"format"),Vr([b("uint16")],Gt.prototype,"length"),Vr([b("uint16")],Gt.prototype,"language"),Vr([b("uint16")],Gt.prototype,"firstCode"),Vr([b("uint16")],Gt.prototype,"entryCount");var bf=Object.defineProperty,jr=(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&&bf(r,e,i),i};const lr=class pl extends qe{get groups(){const r=this.nGroups;return this.view.seek(16),Array.from({length:r},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(r){const e=Ks(r),t=new pl(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}};jr([b("uint16")],lr.prototype,"format"),jr([b("uint16")],lr.prototype,"reserved"),jr([b("uint32")],lr.prototype,"length"),jr([b("uint32")],lr.prototype,"language"),jr([b("uint32")],lr.prototype,"nGroups");let Qs=lr;var wf=Object.defineProperty,en=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&wf(r,e,i),i};class Gr extends qe{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}}en([b("uint16")],Gr.prototype,"format"),en([b("uint32")],Gr.prototype,"length"),en([b("uint32")],Gr.prototype,"numVarSelectorRecords");var xf=Object.defineProperty,Pf=Object.getOwnPropertyDescriptor,tn=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pf(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&&xf(r,e,i),i};let hr=class extends Ie{constructor(){super(...arguments);u(this,"_unicodeToGlyphIndexMap");u(this,"_glyphIndexToUnicodesMap")}static from(r){const e=Array.from(r.keys()).some(f=>f>65535),t=Js.from(r),i=Ys.from(r),s=e?Qs.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 hr(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 Ys(this.view.buffer,e.offset);break;case 2:i=new zr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:i=new Js(this.view.buffer,e.offset,this.view.readUint16());break;case 6:i=new Gt(this.view.buffer,e.offset,this.view.readUint16());break;case 12:i=new Qs(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:i=new Gr(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:i}})}readunicodeToGlyphIndexMap(){var a,l,h,c,f;const r=this.readSubtables(),e=(a=r.find(p=>p.format===0))==null?void 0:a.view,t=(l=r.find(p=>p.platformID===3&&p.platformSpecificID===3&&p.format===2))==null?void 0:l.view,i=(h=r.find(p=>p.platformID===3&&p.platformSpecificID===1&&p.format===4))==null?void 0:h.view,s=(c=r.find(p=>p.platformID===3&&p.platformSpecificID===10&&p.format===12))==null?void 0:c.view,o=(f=r.find(p=>p.platformID===0&&p.platformSpecificID===5&&p.format===14))==null?void 0:f.view;return new Map([...(e==null?void 0:e.getUnicodeToGlyphIndexMap())??[],...(t==null?void 0:t.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs))??[],...(i==null?void 0:i.getUnicodeToGlyphIndexMap())??[],...(s==null?void 0:s.getUnicodeToGlyphIndexMap())??[],...(o==null?void 0:o.getUnicodeToGlyphIndexMap())??[]])}};tn([b("uint16")],hr.prototype,"version",2),tn([b("uint16")],hr.prototype,"numberSubtables",2),hr=tn([Ce("cmap")],hr);class Cf extends Ws{_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 Lr(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();Lr(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;Lr(f<2e4,`Bad numberOfCoordinates:${c}`);const p=[];let m,g=0;for(;g<f;)if(m=r.view.readUint8(),p.push(m),g++,m&8&&g<f){const _=r.view.readUint8();for(let y=0;y<_;y++)p.push(m),g++}if(Lr(p.length===f,`Bad flags length: ${p.length}, numberOfCoordinates: ${f}`),a.length>0){const _=[];let y;if(f>0){for(let P=0;P<f;P+=1)m=p[P],y={},y.onCurve=!!(m&1),y.lastPointOfContour=a.includes(P),_.push(y);let E=0;for(let P=0;P<f;P+=1)m=p[P],y=_[P],y.x=this._parseGlyphCoordinate(r,m,E,2,16),E=y.x;let T=0;for(let P=0;P<f;P+=1)m=p[P],y=_[P],y.y=this._parseGlyphCoordinate(r,m,T,4,32),T=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{Lr(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>h.points.length-1,`Matched points out of range in ${this.name}`);const f=this.points[l.matchedPoints[0]];let p=h.points[l.matchedPoints[1]];const m={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};p=this._transformPoints([p],m)[0],m.dx=f.x-p.x,m.dy=f.y-p.y,c=this._transformPoints(h.points,m)}this.points=this.points.concat(c)}}const s=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const h=o[a];let c=h[h.length-1],f=h[0];c.onCurve?s.push({type:"M",x:c.x,y:c.y}):f.onCurve?s.push({type:"M",x:f.x,y:f.y}):s.push({type:"M",x:(c.x+f.x)*.5,y:(c.y+f.y)*.5});for(let p=0,m=h.length;p<m;++p)if(c=f,f=h[(p+1)%m],c.onCurve)s.push({type:"L",x:c.x,y:c.y});else{let g=f;f.onCurve||(g={x:(c.x+f.x)*.5,y:(c.y+f.y)*.5}),s.push({type:"Q",x1:c.x,y1:c.y,x:g.x,y:g.y})}s.push({type:"Z"})}this.pathCommands=s}}class Tf extends Xs{get length(){return this._sfnt.loca.locations.length}_get(r){const e=this._sfnt.loca.locations,t=e[r],i=new Cf({index:r});return t!==e[r+1]&&i.parse(this._sfnt.glyf,t,this),i}}var Sf=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,Mf=(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&&Sf(r,e,i),i};let Ai=class extends Ie{constructor(){super(...arguments);u(this,"_glyphs")}static from(r){const e=r.reduce((i,s)=>i+s.byteLength,0),t=new Ai(new ArrayBuffer(e));return r.forEach(i=>{t.view.writeBytes(i)}),t}get glyphs(){return this._glyphs??(this._glyphs=new Tf(this._sfnt))}};Ai=Mf([Ce("glyf")],Ai);var Af=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,Uf=(n,r,e,t)=>{for(var i=t>1?void 0:t?Of(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&&Af(r,e,i),i};let rn=class extends Ie{};rn=Uf([Ce("GPOS","gpos")],rn);var If=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,qt=(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&&If(r,e,i),i};let xt=class extends Ie{};qt([b("uint16")],xt.prototype,"majorVersion",2),qt([b("uint16")],xt.prototype,"minorVersion",2),qt([b("uint16")],xt.prototype,"scriptListOffset",2),qt([b("uint16")],xt.prototype,"featureListOffset",2),qt([b("uint16")],xt.prototype,"lookupListOffset",2),qt([b("uint16")],xt.prototype,"featureVariationsOffset",2),xt=qt([Ce("GSUB","gsub")],xt);var Rf=Object.defineProperty,Bf=Object.getOwnPropertyDescriptor,we=(n,r,e,t)=>{for(var i=t>1?void 0:t?Bf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Rf(r,e,i),i};let pe=class extends Ie{constructor(n=new ArrayBuffer(54),r){super(n,r,Math.min(54,n.byteLength-(r??0)))}};we([b("fixed")],pe.prototype,"version",2),we([b("fixed")],pe.prototype,"fontRevision",2),we([b("uint32")],pe.prototype,"checkSumAdjustment",2),we([b("uint32")],pe.prototype,"magickNumber",2),we([b("uint16")],pe.prototype,"flags",2),we([b("uint16")],pe.prototype,"unitsPerEm",2),we([b({type:"longDateTime"})],pe.prototype,"created",2),we([b({type:"longDateTime"})],pe.prototype,"modified",2),we([b("int16")],pe.prototype,"xMin",2),we([b("int16")],pe.prototype,"yMin",2),we([b("int16")],pe.prototype,"xMax",2),we([b("int16")],pe.prototype,"yMax",2),we([b("uint16")],pe.prototype,"macStyle",2),we([b("uint16")],pe.prototype,"lowestRecPPEM",2),we([b("int16")],pe.prototype,"fontDirectionHint",2),we([b("int16")],pe.prototype,"indexToLocFormat",2),we([b("int16")],pe.prototype,"glyphDataFormat",2),pe=we([Ce("head")],pe);var kf=Object.defineProperty,Lf=Object.getOwnPropertyDescriptor,ke=(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&&kf(r,e,i),i};let Te=class extends Ie{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};ke([b("fixed")],Te.prototype,"version",2),ke([b("int16")],Te.prototype,"ascent",2),ke([b("int16")],Te.prototype,"descent",2),ke([b("int16")],Te.prototype,"lineGap",2),ke([b("uint16")],Te.prototype,"advanceWidthMax",2),ke([b("int16")],Te.prototype,"minLeftSideBearing",2),ke([b("int16")],Te.prototype,"minRightSideBearing",2),ke([b("int16")],Te.prototype,"xMaxExtent",2),ke([b("int16")],Te.prototype,"caretSlopeRise",2),ke([b("int16")],Te.prototype,"caretSlopeRun",2),ke([b("int16")],Te.prototype,"caretOffset",2),ke([b({type:"int16",size:4})],Te.prototype,"reserved",2),ke([b("int16")],Te.prototype,"metricDataFormat",2),ke([b("uint16")],Te.prototype,"numOfLongHorMetrics",2),Te=ke([Ce("hhea")],Te);var Nf=Object.defineProperty,Ff=Object.getOwnPropertyDescriptor,$f=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ff(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&&Nf(r,e,i),i};let Oi=class extends Ie{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Oi(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()}))}};Oi=$f([Ce("hmtx")],Oi);var zf=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,jf=(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};let sn=class extends Ie{};sn=jf([Ce("kern","kern")],sn);var Gf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Wf=(n,r,e,t)=>{for(var i=t>1?void 0:t?qf(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&&Gf(r,e,i),i};let Ui=class extends Ie{constructor(){super(...arguments);u(this,"_locations")}static from(r,e=1){const t=r.length*(e?4:2),i=new Ui(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)}};Ui=Wf([Ce("loca")],Ui);var Xf=Object.defineProperty,Hf=Object.getOwnPropertyDescriptor,De=(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&&Xf(r,e,i),i};let xe=class extends Ie{constructor(n=new ArrayBuffer(32),r){super(n,r,Math.min(32,n.byteLength-(r??0)))}};De([b("fixed")],xe.prototype,"version",2),De([b("uint16")],xe.prototype,"numGlyphs",2),De([b("uint16")],xe.prototype,"maxPoints",2),De([b("uint16")],xe.prototype,"maxContours",2),De([b("uint16")],xe.prototype,"maxComponentPoints",2),De([b("uint16")],xe.prototype,"maxComponentContours",2),De([b("uint16")],xe.prototype,"maxZones",2),De([b("uint16")],xe.prototype,"maxTwilightPoints",2),De([b("uint16")],xe.prototype,"maxStorage",2),De([b("uint16")],xe.prototype,"maxFunctionDefs",2),De([b("uint16")],xe.prototype,"maxInstructionDefs",2),De([b("uint16")],xe.prototype,"maxStackElements",2),De([b("uint16")],xe.prototype,"maxSizeOfInstructions",2),De([b("uint16")],xe.prototype,"maxComponentElements",2),De([b("uint16")],xe.prototype,"maxComponentDepth",2),xe=De([Ce("maxp")],xe);var Yf=Object.defineProperty,Zf=Object.getOwnPropertyDescriptor,Ii=(n,r,e,t)=>{for(var i=t>1?void 0:t?Zf(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Yf(r,e,i),i};const Ua={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"},nn={Unicode:0,Macintosh:1,reserved:2,Microsoft:3},Kf={Default:0,"Version1.1":1,ISO10646:2,UnicodeBMP:3,UnicodenonBMP:4,UnicodeVariationSequences:5,FullUnicodecoverage:6},Ia={Symbol:0,UCS2:1,ShiftJIS:2,PRC:3,BigFive:4,Johab:5,UCS4:6};let cr=class extends Ie{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=nn.Macintosh,s=Kf.Default,o=0;e.some(l=>l.platform===nn.Microsoft&&l.encoding===Ia.UCS2&&l.language===1033)&&(i=nn.Microsoft,s=Ia.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&&Ua[h.nameId]&&(a[Ua[h.nameId]]=o===0?Ju(h.name):Qu(h.name))}return a}};Ii([b("uint16")],cr.prototype,"format",2),Ii([b("uint16")],cr.prototype,"count",2),Ii([b("uint16")],cr.prototype,"stringOffset",2),cr=Ii([Ce("name")],cr);var Jf=Object.defineProperty,Qf=Object.getOwnPropertyDescriptor,z=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qf(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&&Jf(r,e,i),i};let $=class extends Ie{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};z([b("uint16")],$.prototype,"version",2),z([b("int16")],$.prototype,"xAvgCharWidth",2),z([b("uint16")],$.prototype,"usWeightClass",2),z([b("uint16")],$.prototype,"usWidthClass",2),z([b("uint16")],$.prototype,"fsType",2),z([b("uint16")],$.prototype,"ySubscriptXSize",2),z([b("uint16")],$.prototype,"ySubscriptYSize",2),z([b("uint16")],$.prototype,"ySubscriptXOffset",2),z([b("uint16")],$.prototype,"ySubscriptYOffset",2),z([b("uint16")],$.prototype,"ySuperscriptXSize",2),z([b("uint16")],$.prototype,"ySuperscriptYSize",2),z([b("uint16")],$.prototype,"ySuperscriptXOffset",2),z([b("uint16")],$.prototype,"ySuperscriptYOffset",2),z([b("uint16")],$.prototype,"yStrikeoutSize",2),z([b("uint16")],$.prototype,"yStrikeoutPosition",2),z([b("uint16")],$.prototype,"sFamilyClass",2),z([b({type:"uint8"})],$.prototype,"bFamilyType",2),z([b({type:"uint8"})],$.prototype,"bSerifStyle",2),z([b({type:"uint8"})],$.prototype,"bWeight",2),z([b({type:"uint8"})],$.prototype,"bProportion",2),z([b({type:"uint8"})],$.prototype,"bContrast",2),z([b({type:"uint8"})],$.prototype,"bStrokeVariation",2),z([b({type:"uint8"})],$.prototype,"bArmStyle",2),z([b({type:"uint8"})],$.prototype,"bLetterform",2),z([b({type:"uint8"})],$.prototype,"bMidline",2),z([b({type:"uint8"})],$.prototype,"bXHeight",2),z([b({type:"uint8",size:16})],$.prototype,"ulUnicodeRange",2),z([b({type:"char",size:4})],$.prototype,"achVendID",2),z([b("uint16")],$.prototype,"fsSelection",2),z([b("uint16")],$.prototype,"usFirstCharIndex",2),z([b("uint16")],$.prototype,"usLastCharIndex",2),z([b("int16")],$.prototype,"sTypoAscender",2),z([b("int16")],$.prototype,"sTypoDescender",2),z([b("int16")],$.prototype,"sTypoLineGap",2),z([b("uint16")],$.prototype,"usWinAscent",2),z([b("uint16")],$.prototype,"usWinDescent",2),z([b({offset:72,type:"uint8",size:8})],$.prototype,"ulCodePageRange",2),z([b({offset:72,type:"int16"})],$.prototype,"sxHeight",2),z([b("int16")],$.prototype,"sCapHeight",2),z([b("uint16")],$.prototype,"usDefaultChar",2),z([b("uint16")],$.prototype,"usBreakChar",2),z([b("uint16")],$.prototype,"usMaxContext",2),$=z([Ce("OS/2","os2")],$);var ed=Object.defineProperty,td=Object.getOwnPropertyDescriptor,ft=(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&&ed(r,e,i),i};let Ye=class extends Ie{constructor(n=new ArrayBuffer(32),r,e){super(n,r,e)}};ft([b("fixed")],Ye.prototype,"format",2),ft([b("fixed")],Ye.prototype,"italicAngle",2),ft([b("int16")],Ye.prototype,"underlinePosition",2),ft([b("int16")],Ye.prototype,"underlineThickness",2),ft([b("uint32")],Ye.prototype,"isFixedPitch",2),ft([b("uint32")],Ye.prototype,"minMemType42",2),ft([b("uint32")],Ye.prototype,"maxMemType42",2),ft([b("uint32")],Ye.prototype,"minMemType1",2),ft([b("uint32")],Ye.prototype,"maxMemType1",2),Ye=ft([Ce("post")],Ye);var rd=Object.defineProperty,id=Object.getOwnPropertyDescriptor,Le=(n,r,e,t)=>{for(var i=t>1?void 0:t?id(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&rd(r,e,i),i};let Se=class extends Ie{constructor(n=new ArrayBuffer(36),r){super(n,r,Math.min(36,n.byteLength-(r??0)))}};Le([b("fixed")],Se.prototype,"version",2),Le([b("int16")],Se.prototype,"vertTypoAscender",2),Le([b("int16")],Se.prototype,"vertTypoDescender",2),Le([b("int16")],Se.prototype,"vertTypoLineGap",2),Le([b("int16")],Se.prototype,"advanceHeightMax",2),Le([b("int16")],Se.prototype,"minTopSideBearing",2),Le([b("int16")],Se.prototype,"minBottomSideBearing",2),Le([b("int16")],Se.prototype,"yMaxExtent",2),Le([b("int16")],Se.prototype,"caretSlopeRise",2),Le([b("int16")],Se.prototype,"caretSlopeRun",2),Le([b("int16")],Se.prototype,"caretOffset",2),Le([b({type:"int16",size:4})],Se.prototype,"reserved",2),Le([b("int16")],Se.prototype,"metricDataFormat",2),Le([b("int16")],Se.prototype,"numOfLongVerMetrics",2),Se=Le([Ce("vhea")],Se);var sd=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,od=(n,r,e,t)=>{for(var i=t>1?void 0:t?nd(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&&sd(r,e,i),i};let Di=class extends Ie{constructor(){super(...arguments);u(this,"_metrics")}static from(r){const e=r.length*4,t=new Di(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()}))}};Di=od([Ce("vmtx")],Di);var ad=Object.defineProperty,qr=(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&&ad(r,e,i),i};class Ze extends xi{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(or(e).getUint32(0))}static checksum(e){const t=or(e);let i=t.byteLength;for(;i%4;)i++;let s=0;for(let o=0,a=i/4;o<a;o+=4)o*4<i-4&&(s+=t.getUint32(o*4,!1));return s&4294967295}static from(e){const t=p=>p+3&-4,i=e.tableViews.size,s=Array.from(e.tableViews.values()).reduce((p,m)=>p+t(m.byteLength),0),o=new this(new ArrayBuffer(12+i*16+s));o.scalerType=65536,o.numTables=i;const a=Math.log(2);o.searchRange=Math.floor(Math.log(i)/a)*16,o.entrySelector=Math.floor(o.searchRange/a),o.rangeShift=i*16-o.searchRange;let l=12+i*16,h=0;const c=o.getDirectories();e.tableViews.forEach((p,m)=>{const g=c[h++];g.tag=m,g.checkSum=this.checksum(p),g.offset=l,g.length=p.byteLength,o.view.writeBytes(p,l),l+=t(g.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 ar(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new zt(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}u(Ze,"signature",new Set([65536,1953658213,1954115633])),qr([b("uint32")],Ze.prototype,"scalerType"),qr([b("uint16")],Ze.prototype,"numTables"),qr([b("uint16")],Ze.prototype,"searchRange"),qr([b("uint16")],Ze.prototype,"entrySelector"),qr([b("uint16")],Ze.prototype,"rangeShift");class Ri extends Ze{constructor(){super(...arguments);u(this,"format","OpenType");u(this,"mimeType","font/otf")}static from(e){return super.from(e)}}u(Ri,"signature",new Set([1330926671]));var ld=Object.defineProperty,Wr=(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&&ld(r,e,i),i};class Wt extends qe{constructor(r,e){super(r,e,20)}}Wr([b({type:"char",size:4})],Wt.prototype,"tag"),Wr([b("uint32")],Wt.prototype,"offset"),Wr([b("uint32")],Wt.prototype,"compLength"),Wr([b("uint32")],Wt.prototype,"origLength"),Wr([b("uint32")],Wt.prototype,"origChecksum");var hd=Object.defineProperty,We=(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&&hd(r,e,i),i};const $e=(Bt=class extends xi{constructor(){super(...arguments);u(this,"format","WOFF");u(this,"mimeType","font/woff");u(this,"_sfnt")}get subfontFormat(){return Ze.is(this.flavor)?"TrueType":Ri.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(or(e).getUint32(0))}static checkSum(e){const t=or(e),i=t.byteLength,s=Math.floor(i/4);let o=0,a=0;for(;a<s;)o+=t.getUint32(4*a++,!1);let l=i-s*4;if(l){let h=s*4;for(;l>0;)o+=t.getUint8(h)<<l*8,h++,l--}return o%4294967296}static from(e,t=new ArrayBuffer(0)){const i=p=>p+3&-4,s=[];e.tableViews.forEach((p,m)=>{const g=or(qu(new Uint8Array(p.buffer,p.byteOffset,p.byteLength)));s.push({tag:m,view:g.byteLength<p.byteLength?g:p,rawView:p})});const o=s.length,a=s.reduce((p,m)=>p+i(m.view.byteLength),0),l=new Bt(new ArrayBuffer(44+20*o+a+t.byteLength));l.signature=2001684038,l.flavor=65536,l.length=l.view.byteLength,l.numTables=o,l.totalSFNTSize=12+16*o+s.reduce((p,m)=>p+i(m.rawView.byteLength),0);let h=44+o*20,c=0;const f=l.getDirectories();return s.forEach(p=>{const m=f[c++];m.tag=p.tag,m.offset=h,m.compLength=p.view.byteLength,m.origChecksum=Bt.checkSum(p.rawView),m.origLength=p.rawView.byteLength,l.view.writeBytes(p.view,h),h+=i(m.compLength)}),l.view.writeBytes(t),l}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new Wt(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new zt(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(Wu(new Uint8Array(this.view.buffer.slice(s,l))).buffer),e},{}))}},u(Bt,"signature",new Set([2001684038])),Bt);We([b("uint32")],$e.prototype,"signature"),We([b("uint32")],$e.prototype,"flavor"),We([b("uint32")],$e.prototype,"length"),We([b("uint16")],$e.prototype,"numTables"),We([b("uint16")],$e.prototype,"reserved"),We([b("uint32")],$e.prototype,"totalSFNTSize"),We([b("uint16")],$e.prototype,"majorVersion"),We([b("uint16")],$e.prototype,"minorVersion"),We([b("uint32")],$e.prototype,"metaOffset"),We([b("uint32")],$e.prototype,"metaLength"),We([b("uint32")],$e.prototype,"metaOrigLength"),We([b("uint32")],$e.prototype,"privOffset"),We([b("uint32")],$e.prototype,"privLength");let Bi=$e;function Da(n,r=!0){if(Ze.is(n))return new Ze(n);if(Ri.is(n))return new Ri(n);if(Bi.is(n))return new Bi(n);if(r)throw new Error("Failed to parseFont")}function Ra(n,r=!0){const e=Da(n,!1);if(e)return e;if(r)throw new Error("Failed to parseFont")}const Wi=class Wi{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,{...Wi.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 {
748
+ font-family: "${r}";
749
+ src: url(${e});
750
+ }`)),document.head.appendChild(t),this}_parseUrls(r){const e=Array.from(new Set([...r.split(","),r]));return Array.from(new Set(e.map(t=>this.familyToUrl.get(t.trim())??this.familyToUrl.get(t)??t)))}get(r){let e;return r&&(e=this._parseUrls(r).reduce((i,s)=>i||this.loaded.get(s),void 0)),e??this.fallbackFont}set(r,e){return this.familyToUrl.set(r,e.src),this.loaded.set(e.src,e),this}delete(r){return this._parseUrls(r).forEach(e=>{this.familyToUrl.delete(e),this.loaded.delete(e)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(r,e={}){const{cancelOther:t,injectFontFace:i=!0,injectStyleTag:s=!0,...o}=e,{src:a}=r;if(this.loaded.has(a))return t&&(this.loading.forEach(p=>p.cancel()),this.loading.clear()),c(this.loaded.get(a));let l=this.loading.get(a);return l||(l=this._createRequest(a,o),this.loading.set(a,l)),t&&this.loading.forEach((p,m)=>{p!==l&&(p.cancel(),this.loading.delete(m))}),l.when.then(p=>{if(this.loaded.has(a))return c(this.loaded.get(a));{const m=f(p);return e.noAdd||this.loaded.set(r.src,m),m.familySet.forEach(g=>{this.familyToUrl.set(g,a),typeof document<"u"&&(i&&this.injectFontFace(g,p),s&&this.injectStyleTag(g,a))}),m}}).catch(p=>{if(p instanceof DOMException&&p.message==="The user aborted a request.")return f();throw p}).finally(()=>{this.loading.delete(a)});function h(){return r.family?Array.isArray(r.family)?r.family:[r.family]:[]}function c(p){return h().forEach(m=>{p.familySet.add(m)}),p}function f(p=new ArrayBuffer(0)){let m;function g(){return m||(m=p.byteLength?Ra(p,!1):void 0),m}function _(){const y=g();if(y instanceof Ze||y instanceof Bi)return y.sfnt}return{...r,buffer:p,familySet:new Set(h()),getFont:g,getSFNT:_}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(r=>r.when))}};u(Wi,"defaultRequestInit",{cache:"force-cache"});let ki=Wi;const Ba=new ki,cd=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:xi,get Cff(){return Vt},get Cmap(){return hr},CmapSubtableFormat0:Ys,CmapSubtableFormat12:Qs,CmapSubtableFormat14:Gr,CmapSubtableFormat2:zr,CmapSubtableFormat4:Js,CmapSubtableFormat6:Gt,FontDataObject:qe,FontDataView:be,Fonts:ki,get Glyf(){return Ai},Glyph:Ws,GlyphSet:Xs,get Gpos(){return rn},get Gsub(){return xt},get Head(){return pe},get Hhea(){return Te},get Hmtx(){return Oi},get Kern(){return sn},get Loca(){return Ui},get Maxp(){return xe},get Name(){return cr},get Os2(){return $},get Post(){return Ye},SFNT:zt,TTF:Ze,TableDirectory:ar,get Vhea(){return Se},get Vmtx(){return Di},WOFF:Bi,WOFFTableDirectoryEntry:Wt,createCmapSegments:Ks,dataTypeToByteLength:Nr,defineColumn:b,defineSFNTTable:Ce,fonts:Ba,parseFont:Ra,parseSFNTFont:Da},Symbol.toStringTag,{value:"Module"}));function on(n,r,e){if(typeof r=="string"&&r.startsWith("linear-gradient")){const{x0:t,y0:i,x1:s,y1:o,stops:a}=ud(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 Li(n,r,e){n!=null&&n.color&&(n.color=on(e,n.color,r)),n!=null&&n.backgroundColor&&(n.backgroundColor=on(e,n.backgroundColor,r)),n!=null&&n.textStrokeColor&&(n.textStrokeColor=on(e,n.textStrokeColor,r))}function ud(n,r,e,t,i){var m;const s=((m=n.match(/linear-gradient\((.+)\)$/))==null?void 0:m[1])??"",o=s.split(",")[0],a=o.includes("deg")?o:"0deg",l=s.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),c=(Number(a.replace("deg",""))||0)*Math.PI/180,f=t*Math.sin(c),p=i*Math.cos(c);return{x0:r+t/2-f,y0:e+i/2+p,x1:r+t/2+f,y1:e+i/2-p,stops:Array.from(l).map(g=>{let _=g[2];return _.startsWith("(")?_=_.split(",").length>3?`rgba${_}`:`rgb${_}`:_=`#${_}`,{offset:Number(g[3].replace("%",""))/100,color:_}})}}function Xr(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 fd(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 dd(n,r){const{paragraphs:e,computedStyle:t,glyphBox:i}=r;Li(t,i,n),e.forEach(s=>{Li(s.computedStyle,s.lineBox,n),s.fragments.forEach(o=>{Li(o.computedStyle,o.inlineBox,n)})})}const pd=new Set(["©","®","÷"]),gd=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),md={1:"italic",32:"bold"},yd={1:"italic",2:"bold"},ka={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class _d{constructor(r,e,t){u(this,"path",new Pe);u(this,"lineBox",new Z);u(this,"inlineBox",new Z);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??Ba,i=e?t.get(e):t.fallbackFont;return i==null?void 0:i.getSFNT()}updateGlyph(r=this._getFontSFNT()){if(!r)return this;const{hhea:e,os2:t,post:i,head:s}=r,o=s.unitsPerEm,a=e.ascent,l=e.descent,{content:h,computedStyle:c,isVertical:f}=this,{fontSize:p}=c,m=o/p,g=r.getAdvanceWidth(h,p),_=(a+Math.abs(l))/m,y=a/m;return this.advanceWidth=g,this.advanceHeight=_,this.inlineBox.width=f?_:g,this.inlineBox.height=f?g:_,this.underlinePosition=(a-i.underlinePosition)/m,this.underlineThickness=i.underlineThickness/m,this.strikeoutPosition=(a-t.yStrikeoutPosition)/m,this.strikeoutSize=t.yStrikeoutSize/m,this.ascender=a/m,this.descender=l/m,this.typoAscender=t.sTypoAscender/m,this.typoDescender=t.sTypoDescender/m,this.typoLineGap=t.sTypoLineGap/m,this.winAscent=t.usWinAscent/m,this.winDescent=t.usWinDescent/m,this.xHeight=t.sxHeight/m,this.capHeight=t.sCapHeight/m,this.baseline=y,this.centerDiviation=_/2-y,this.fontStyle=md[t.fsSelection]??yd[s.macStyle],this}update(r){const e=this._getFontSFNT(r);if(!e)return this;this.updateGlyph(e);const{isVertical:t,content:i,computedStyle:s,baseline:o,inlineBox:a,ascender:l,descender:h,typoAscender:c,fontStyle:f,advanceWidth:p,advanceHeight:m}=this,{left:g,top:_}=a,y=s.fontStyle==="italic"&&f!=="italic";let E=g,T=_+o,P;const S=new Pe;if(t&&(E+=(m-p)/2,Math.abs(p-m)>.1&&(T-=(l-c)/(l+Math.abs(h))*m),P=void 0),t&&!pd.has(i)&&(i.codePointAt(0)<=256||gd.has(i))){S.addCommands(e.getPathCommands(i,E,_+o-(m-p)/2,s.fontSize));const v={y:_-(m-p)/2+m/2,x:E+p/2};y&&this._italic(S,t?{x:v.x,y:_-(m-p)/2+o}:void 0),S.rotate(90,v)}else P!==void 0?(S.addCommands(e.glyphs.get(P).getPathCommands(E,T,s.fontSize)),y&&this._italic(S,t?{x:E+p/2,y:_+c/(l+Math.abs(h))*m}:void 0)):(S.addCommands(e.getPathCommands(i,E,T,s.fontSize)),y&&this._italic(S,t?{x:E+m/2,y:T}:void 0));const w=s.fontWeight??400;return w in ka&&(w===700||w==="bold")&&f!=="bold"&&S.bold(ka[w]*s.fontSize*.05),S.style={fill:s.color,stroke:s.textStrokeWidth?s.textStrokeColor:"none",strokeWidth:s.textStrokeWidth?s.textStrokeWidth*s.fontSize*.03:0},this.path=S,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 Z(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)Xr(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};ys(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 an(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 La(n){const r=Ot(n)?{}:n;return Object.keys(r).reduce((e,t)=>{let i=r[t];const s=Na(t),o=Na(i);return s&&(t=s),o&&(i=o),e[t]=i,e},{})}function Ot(n){return!n||n==="none"}function vd(n,r){const e=Object.keys(n),t=Object.keys(r);return Array.from(new Set([...e,...t])).every(s=>ur(n[s],r[s]))}function ur(n,r){const e=typeof n;return e===typeof r?e==="object"?vd(n,r):n===r:!1}function Na(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 ln(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 hn(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("blob://")}class bd{constructor(r,e={},t){u(this,"inlineBox",new Z);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,...ln(this.style)},this}initCharacters(){const r=[];let e=0;for(const t of this.computedContent)r.push(new _d(t,e++,this));return this.characters=r,this}}class Hr{constructor(r,e){u(this,"lineBox",new Z);u(this,"fragments",[]);this.style=r,this.parentStyle=e,this.updateComputedStyle()}updateComputedStyle(){return this.computedStyle={...ln(this.parentStyle),...ln(this.style)},this}addFragment(r,e){const t=new bd(r,e,this);return this.fragments.push(t),t}}function Bp(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 p=document.createElement("span");Object.assign(p.style,{verticalAlign:"inherit",...this._styleToDomStyle(f.style)}),p.appendChild(document.createTextNode(f.content)),c.appendChild(p)}),l.appendChild(c)}),i.appendChild(l),t.appendChild(i),document.body.appendChild(t),{dom:i,destory:()=>{var h;return(h=i.parentNode)==null?void 0:h.removeChild(i)}}}measureDomText(r){const e=document.createRange();e.selectNodeContents(r);const t=r.data??"";let i=0;return Array.from(t).map(s=>{var f;const o=i+=t.substring(i).indexOf(s),a=o+s.length;i+=s.length,e.setStart(r,Math.max(o,0)),e.setEnd(r,a);const l=((f=e.getClientRects)==null?void 0:f.call(e))??[e.getBoundingClientRect()];let h=l[l.length-1];l.length>1&&h.width<2&&(h=l[l.length-2]);const c=e.toString();if(c!==""&&h&&h.width+h.height!==0)return{content:c,top:h.top,left:h.left,height:h.height,width:h.width}}).filter(Boolean)}measureDom(r){const e=[],t=[],i=[];return r.querySelectorAll("li").forEach((s,o)=>{const a=s.getBoundingClientRect();e.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),s.querySelectorAll(":scope > *").forEach((l,h)=>{const c=l.getBoundingClientRect();t.push({paragraphIndex:o,fragmentIndex:h,left:c.left,top:c.top,width:c.width,height:c.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(p=>{i.push({...p,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(p=>{p.firstChild instanceof window.Text&&this.measureDomText(p.firstChild).forEach(m=>{i.push({...m,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:h,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:e,fragments:t,characters:i}}measureParagraphDom(r,e){const t=e.getBoundingClientRect(),i=this.measureDom(e);i.paragraphs.forEach(a=>{const l=r[a.paragraphIndex];l.lineBox.left=a.left-t.left,l.lineBox.top=a.top-t.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=r[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-t.left,l.inlineBox.top=a.top-t.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const s=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:h,characterIndex:c}=a;s.push({...a,newParagraphIndex:l,left:a.left-t.left,top:a.top-t.top});const f=r[l].fragments[h].characters[c],{fontHeight:p,isVertical:m}=f,g=s[o];f.inlineBox.left=g.left,f.inlineBox.top=g.top,f.inlineBox.width=g.width,f.inlineBox.height=g.height,m?(f.lineBox.left=g.left+(g.width-p)/2,f.lineBox.top=g.top,f.lineBox.width=p,f.lineBox.height=g.height):(f.lineBox.left=g.left,f.lineBox.top=g.top+(g.height-p)/2,f.lineBox.width=g.width,f.lineBox.height=p),o++}),{paragraphs:r,boundingBox:new Z(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 cn=gr;class wd{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 un(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 xd(){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=Io(hn(o)?e.get(o)??o:o),h=Lo(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}=un(h);hn(c)&&a.add(c),hn(f)&&a.add(f)}),await Promise.all(Array.from(a).map(l=>i(l)))},update:o=>{r.length=0,n.length=0;let a=[],l,h;o.forEachCharacter(c=>{const{computedStyle:f}=c,p=un(f),{image:m,colormap:g,line:_,size:y,thickness:E}=p;if(Ot(m))l!=null&&l.length&&(l=[],a.push(l));else{const{inlineBox:T,isVertical:P}=c,{fontSize:S}=f;(!h||ur(h.image,m)&&ur(h.colormap,g)&&ur(h.line,_)&&ur(h.size,y)&&ur(h.thickness,E))&&(l!=null&&l.length)&&(P?l[0].inlineBox.left===T.left:l[0].inlineBox.top===T.top)&&l[0].fontSize===S?l.push(c):(l=[],l.push(c),a.push(l))}h=p}),a=a.filter(c=>c.length);for(let c=0;c<a.length;c++){const f=a[c],p=f[0],m=Z.from(...f.filter(D=>D.glyphBox).map(D=>D.glyphBox)),{computedStyle:g}=p,{fontSize:_,writingMode:y}=g,{image:E,referImage:T,colormap:P,line:S,size:w,thickness:v}=un(g),x=y.includes("vertical"),C=an(v,{fontSize:_,total:m.width})/m.width,I=La(P),{pathSet:F,dom:B}=s(E),U=F.getBoundingBox(!0),V=_/U.width*2,A=new Z().copy(m);x&&(A.width=m.height,A.height=m.width,A.left=m.left+m.width);const N=Math.floor(A.width);let W=N;if(w!=="cover"&&(W=an(w,{fontSize:_,total:m.width})||N,A.width=W),!Ot(T)&&Ot(S)){const D=s(T).pathSet.getBoundingBox(!0);U.copy(D)}else{let D;if(Ot(S))if(U.width/U.height>4){D="underline";const G=B.getAttribute("viewBox");if(G){const[L,k,K,H]=G.split(" ").map(q=>Number(q)),X=k+H/2;U.y<X&&U.y+U.height>X?D="line-through":U.y+U.height<X?D="overline":D="underline"}}else D="outline";else D=S;switch(D){case"outline":{const G=A.width*.2,L=A.height*.2;A.width+=G,A.height+=L,x?(A.x-=L/2,A.y-=G/2,A.x+=A.height):(A.x-=G/2,A.y-=L/2);break}case"overline":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width:A.y=p.inlineBox.top;break;case"line-through":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width-p.strikeoutPosition+A.height/2:A.y=p.inlineBox.top+p.strikeoutPosition-A.height/2;break;case"underline":A.height=U.height*V,x?A.x=p.inlineBox.left+p.inlineBox.width-p.underlinePosition:A.y=p.inlineBox.top+p.underlinePosition;break}}const R=new Fe().translate(-U.x,-U.y).scale(A.width/U.width,A.height/U.height);x&&R.rotate(-Math.PI/2),R.translate(A.x,A.y);for(let D=0;D<Math.ceil(N/W);D++){const G=R.clone();x?G.translate(0,D*A.width):G.translate(D*A.width,0),F.paths.forEach(L=>{const k=L.clone().applyTransform(G);k.style.strokeWidth&&(k.style.strokeWidth*=V*C),k.style.strokeMiterlimit&&(k.style.strokeMiterlimit*=V),k.style.strokeDashoffset&&(k.style.strokeDashoffset*=V),k.style.strokeDasharray&&(k.style.strokeDasharray=k.style.strokeDasharray.map(K=>K*V)),k.style.fill&&k.style.fill in I&&(k.style.fill=I[k.style.fill]),k.style.stroke&&k.style.stroke in I&&(k.style.stroke=I[k.style.stroke]),n.push(k),N!==W&&(x?r[n.length-1]=new Z(m.left-m.width*2,m.top,m.width*4,m.height):r[n.length-1]=new Z(m.left,m.top-m.height*2,m.width,m.height*4))})}}},renderOrder:-1,render:(o,a)=>{n.forEach((l,h)=>{if(Xr({ctx:o,path:l,fontSize:a.computedStyle.fontSize,clipRect:r[h]}),a.debug){const c=new Cs([l]).getBoundingBox();c&&o.strokeRect(c.x,c.y,c.width,c.height)}})}}}function Pd(n,r){return`<svg width="${n*2}" height="${n*2}" xmlns="http://www.w3.org/2000/svg">
751
+ <circle cx="${n}" cy="${n}" r="${n}" fill="${r}" />
752
+ </svg>`}function Cd(){const n=[];return{name:"listStyle",paths:n,update:r=>{n.length=0;const{paragraphs:e,isVertical:t,fontSize:i}=r,s=i*.45;e.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:h,listStyleColormap:c,listStyleSize:f,listStyleType:p}=a,m=La(c);let g=f,_;if(!Ot(h))_=h;else if(!Ot(p)){const P=i*.38/2;switch(g=g==="cover"?P*2:g,p){case"disc":_=Pd(P,String(l));break}}if(!_)return;const y=Lo(_),E=y.getBoundingBox();let T;o.fragments.forEach(P=>{P.characters.forEach(S=>{const{inlineBox:w}=S;if(t?(T==null?void 0:T.inlineBox.left)!==w.left:(T==null?void 0:T.inlineBox.top)!==w.top){T=S;const v=g==="cover"?1:an(g,{total:i,fontSize:i})/i,x=new Fe;if(t){const C=i/E.height*v;x.translate(-E.left,-E.top).rotate(Math.PI/2).scale(C,C).translate(w.left+(w.width-E.height*C)/2,w.top-s)}else{const C=i/E.height*v;x.translate(-E.left,-E.top).scale(C,C).translate(w.left-E.width*C-s,w.top+(w.height-E.height*C)/2)}n.push(...y.paths.map(C=>{const I=C.clone();return I.applyTransform(x),I.style.fill&&I.style.fill in m&&(I.style.fill=m[I.style.fill]),I.style.stroke&&I.style.stroke in m&&(I.style.stroke=m[I.style.stroke]),I}))}})})})}}}const Ut=new O,fr=new Fe,It=new Fe;function Td(){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=fn(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?Z.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 Z(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=>{Li(a,t,n),n.save();const[l,h,c,f,p,m]=fn(r,a).transpose().elements;n.transform(l,f,h,p,c,m),r.forEachCharacter(g=>{var _;(_=g.parent.style)!=null&&_.backgroundColor&&o(g.parent.style.backgroundColor,g.inlineBox),g.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 fn(n,r){const{fontSize:e,glyphBox:t}=n,i=(r.translateX??0)*e,s=(r.translateY??0)*e,o=Math.PI*2,a=(r.skewX??0)/360*o,l=(r.skewY??0)/360*o,{left:h,top:c,width:f,height:p}=t,m=h+f/2,g=c+p/2;return fr.identity(),It.makeTranslation(i,s),fr.multiply(It),It.makeTranslation(m,g),fr.multiply(It),It.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),fr.multiply(It),It.makeTranslation(-m,-g),fr.multiply(It),fr.clone()}function Sd(){const n=[];return{name:"textDecoration",paths:n,update:r=>{n.length=0;const e=[];let t,i;r.forEachCharacter(s=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:h,underlineThickness:c,strikeoutPosition:f,strikeoutSize:p}=s,{color:m,textDecoration:g,writingMode:_}=o;if(Ot(g))i=void 0;else{let y=!1;if((i==null?void 0:i.textDecoration)===g&&(i==null?void 0:i.writingMode)===_&&(i==null?void 0:i.color)===m&&(a?t[0].inlineBox.left===l.left:t[0].inlineBox.top===l.top))switch(g){case"underline":t[0].underlinePosition===h&&t[0].underlineThickness===c&&(y=!0);break;case"line-through":t[0].strikeoutPosition===f&&t[0].strikeoutSize===p&&(y=!0);break}y?t.push(s):(t=[],t.push(s),e.push(t)),i=o}}),e.forEach(s=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:h,strikeoutPosition:c,strikeoutSize:f}=s[0],{color:p,textDecoration:m}=o,{left:g,top:_,width:y,height:E}=Z.from(...s.map(v=>v.inlineBox));let T=a?g+y:_;const P=a?-1:1;let S=0;switch(m){case"overline":S=h*2;break;case"underline":T+=P*l,S=h*2;break;case"line-through":T+=P*c,S=f*2;break}T-=S;let w;a?w=new Pe([{type:"M",x:T,y:_},{type:"L",x:T,y:_+E},{type:"L",x:T+S,y:_+E},{type:"L",x:T+S,y:_},{type:"Z"}],{fill:p}):w=new Pe([{type:"M",x:g,y:T},{type:"L",x:g+y,y:T},{type:"L",x:g+y,y:T+S},{type:"L",x:g,y:T+S},{type:"Z"}],{fill:p}),n.push(w)})},render:(r,e)=>{const{effects:t,computedStyle:i}=e;t?t.forEach(s=>{r.save();const[o,a,l,h,c,f]=fn(e,s).transpose().elements;r.transform(o,h,a,c,l,f),n.forEach(p=>{Xr({ctx:r,path:p,fontSize:i.fontSize,...s})}),r.restore()}):n.forEach(s=>{Xr({ctx:r,path:s,fontSize:i.fontSize})})}}}const dn=uc();class Ed extends wd{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",{...dn});u(this,"paragraphs",[]);u(this,"lineBox",new Z);u(this,"rawGlyphBox",new Z);u(this,"glyphBox",new Z);u(this,"pathBox",new Z);u(this,"boundingBox",new Z);u(this,"measurer",new cn);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(Cd()).use(Sd()).use(xd()).use(Td()),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={...dn,...this.style};let{content:e,computedStyle:t}=this;const i=[];if(typeof e=="string"){const s=new Hr({},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 Hr({},t);o.addFragment(s),i.push(o)}else if(Array.isArray(s)){const o=new Hr({},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 Hr(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 Hr(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 Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):new Cs(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 Z(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(),fd(s,i,this.boundingBox),dd(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=>{Xr({ctx:s,path:h,fontSize:l.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:i}))}}var Md=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,dr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ad(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Md(r,e,i),i};const Od=new Set(Object.keys(dn));d.Text2D=class extends _i{constructor(e,t=[]){super();u(this,"effects");u(this,"measureDom");u(this,"fonts");u(this,"texture",new Er);u(this,"text",new Ed);u(this,"_subTextsCount",0);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"content":case"effects":case"measureDom":case"fonts":case"split":this._updateSplit(),this.requestRedraw();break}this._subTextsCount&&e==="effects"&&this._getSubTexts().forEach(o=>{o.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()}_updateStyleProperty(e,t,i){switch(super._updateStyleProperty(e,t,i),e){case"width":this.split&&this._updateSubTexts();break}typeof e=="string"&&Od.has(e)&&(this._subTextsCount&&e!=="width"&&e!=="height"&&this._getSubTexts().forEach(s=>{s.style.setProperties({[e]:t})}),this.requestRedraw())}_getSubTexts(){return this.getChildren("front").filter(e=>e instanceof d.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("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 d.Text2D({content:s.content,style:{...s.computedStyle,left:s.inlineBox.x,top:s.inlineBox.y,width:0,height:0,effects:this.effects}}),"front"),this._subTextsCount++})})})}_drawContent(){var e,t;if(!this.split){const i=(t=(e=this.getChildren())==null?void 0:e.find(s=>"onText2DRender"in s))==null?void 0:t.onText2DRender;i?i():(this._updateText(),this.text.render({pixelRatio:this.texture.pixelRatio,view:this.texture.source})),this.texture.requestUpload(),super._drawContent()}}},dr([M({default:!1})],d.Text2D.prototype,"split",2),dr([M({default:""})],d.Text2D.prototype,"content",2),dr([M()],d.Text2D.prototype,"effects",2),dr([ue()],d.Text2D.prototype,"measureDom",2),dr([ue()],d.Text2D.prototype,"fonts",2),d.Text2D=dr([j("Text2D")],d.Text2D);var Ud=Object.defineProperty,Id=Object.getOwnPropertyDescriptor,Fa=(n,r,e,t)=>{for(var i=t>1?void 0:t?Id(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ud(r,e,i),i};d.Video2D=class extends _i{constructor(e,t=[]){super();u(this,"_wait",Promise.resolve());this.setProperties(e),this.append(t)}get videoDuration(){var e;return(((e=this.texture)==null?void 0:e.duration)??0)*1e3}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Pt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;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([M({default:""})],d.Video2D.prototype,"src",2),d.Video2D=Fa([j("Video2D")],d.Video2D);var Dd=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Yr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Rd(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&&Dd(r,e,i),i};const $a=n=>n,za=pr(.25,.1,.25,1),Va=pr(.42,0,1,1),ja=pr(0,0,.58,1),Ga=pr(.42,0,.58,1);function pr(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,p=_=>((s*_+o)*_+a)*_,m=_=>((l*_+h)*_+c)*_;function g(_){let y=_,E,T;for(let w=0;w<8;w++){if(T=p(y)-_,Math.abs(T)<1e-6)return y;if(E=f(y),Math.abs(E)<1e-6)break;y-=T/E}let P=1,S=0;for(y=_;P>S;){if(T=p(y)-_,Math.abs(T)<1e-6)return y;T>0?P=y:S=y,y=(P+S)/2}return y}return _=>m(g(_))}const Ni={linear:$a,ease:za,easeIn:Va,easeOut:ja,easeInOut:Ga};d.Animation=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"easing");u(this,"_keyframes",[]);u(this,"_isFirstUpdatePosition",!1);u(this,"_cachedProps",new Zt);u(this,"_stoped",!1);this._process=this._process.bind(this),this.setProperties(e).append(t)}_treeEnter(e){e.timeline.on("updateCurrentTime",this._process),this._updateCachedProps()}_treeExit(e){e.timeline.on("updateCurrentTime",this._process),this.cancel()}_onProcess(){}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){var t;let e;switch(this.effectMode){case"sibling":e=((t=this.getParent())==null?void 0:t.getChildren(!0).filter(i=>i instanceof d.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._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,i=this.currentTimeProgress;e.forEach((s,o)=>{const a=t===1?i:at(0,Math.max(0,i-t*o)/t,1),l=this._cachedProps.get(s);if(!l)return;const h=this._parseKeyframes(a,l);h!=null&&h.length&&this._commitStyle(a,s,l,h[0],h[1])})}_updateCachedProps(){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._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return Ni.linear;if(e in Ni)return Ni[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(i=>Number(i));return pr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let i;const s=this._keyframes;for(let o=s.length,a=0;a<o;a++){const l=s[a],{offset:h,easing:c}=l,f={...l.props};if(i&&e<=h){const{offset:p,easing:m}=i,g={...i.props};return t.forEach((_,y)=>{(!(y in g)||g[y]===null)&&(g[y]=_),(!(y in f)||f[y]===null)&&(f[y]=_)}),[{offset:p,easing:m,props:g},{offset:h,easing:c,props:f}]}i=l}return null}_commitStyle(e,t,i,s,o){const{offset:a,easing:l,props:h}=s,{offset:c,props:f}=o,p=c-a,m=l((e-a)/p),g={width:t.width,height:t.height,fontSize:t.fontSize};i.forEach((_,y)=>{t[y]=this._getDiffValue(y,h[y],f[y],m,g)})}_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=Ki(a);else if(i!==void 0)l=mr(e,String(i),o),a=Ki(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:m,args:g})=>{c[m]=g,h.add(m)}),l.forEach(({name:m,args:g})=>{f[m]=g,h.add(m)});let p="";return h.forEach(m=>{var E,T;const g=Math.max(((E=c[m])==null?void 0:E.length)??0,((T=f[m])==null?void 0:T.length)??0),_=c[m],y=f[m];p+=`${m}(${Array.from({length:g},(P,S)=>{const w=_==null?void 0:_[S],v=y==null?void 0:y[S],x=(w==null?void 0:w.normalizedIntValue)??0,C=(v==null?void 0:v.normalizedIntValue)??0;return Number.isNaN(x)||Number.isNaN(C)?(v==null?void 0:v.value)??0:de(x,C,s)}).join(", ")}) `}),p}else if(!Array.isArray(a)&&!Array.isArray(l))return Number.isNaN(a.normalizedIntValue)||Number.isNaN(l.normalizedIntValue)?l.value:de(a.normalizedIntValue,l.normalizedIntValue,s)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{var t;(t=this._cachedProps.get(e))==null||t.forEach((i,s)=>{e[s]=i}),this._cachedProps.delete(e)})}},Yr([M({default:"parent"})],d.Animation.prototype,"effectMode",2),Yr([M({default:!1})],d.Animation.prototype,"loop",2),Yr([M({default:[]})],d.Animation.prototype,"keyframes",2),Yr([M()],d.Animation.prototype,"easing",2),d.Animation=Yr([j("Animation",{renderMode:"disabled",processMode:"pausable",duration:2e3})],d.Animation);const Xi=class Xi extends mt{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 Xi),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(Xi,"_instance");let Fi=Xi;const Jr=class Jr extends mt{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-Jr.PADDING),this._end=Math.min(this._end+Jr.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),fe.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onComplete(){fe.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){fe.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(Jr,"PADDING",.1);let $i=Jr;class qa{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 Fi.instance}async load(){return new Promise(r=>{this.source.onload=()=>r(this),this.source.src=this._src,this.source.load()})}createSound(){return new $i}}class pn extends mt{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 Bd{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 kd(){if(Qi)return new AudioContext;if(es){const n=globalThis.webkitAudioContext;return new n}else throw new Error("Failed to createAudioContext")}function Ld(n,r,e){if(ts)return new OfflineAudioContext(n,r,e);if(xn){const t=globalThis.webkitOfflineAudioContext;return new t(n,r,e)}else throw new Error("Failed to createOfflineAudioContext")}const Hi=class Hi extends pn{constructor(){const e=kd(),t=Ld(1,2,ts?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"&&(gt||wn),_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 Hi),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(Hi,"_instance");let Dt=Hi;class Wa extends mt{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){fe.off(this._updateListener),e&&fe.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 Xa extends pn{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 Wa}}var Ha=Object.defineProperty,Nd=Object.getOwnPropertyDescriptor,Fd=(n,r,e)=>r in n?Ha(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,$d=(n,r,e,t)=>{for(var i=t>1?void 0:t?Nd(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&&Ha(r,e,i),i},zd=(n,r,e)=>Fd(n,r+"",e);d.Audio=class extends d.TimelineNode{constructor(e=""){super();u(this,"_sounds",[]);u(this,"_platformAudio",Pn?new Xa(this):new qa(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,"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 audioDuration(){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}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"paused":this.refreshPaused();break}}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 d.Audio._soundPool.length>0?d.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(),d.Audio._soundPool.includes(e)||d.Audio._soundPool.push(e)}_process(e){var t;if(super._process(e),this.canProcess()){const i=((t=this._tree)==null?void 0:t.timeline.currentTime)??0;i-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(i-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=i}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},zd(d.Audio,"_soundPool",[]),d.Audio=$d([j("Audio")],d.Audio);class Vd extends d.Node2D{}var jd=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,zi=(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&&jd(r,e,i),i};d.AudioWaveform=class extends d.Node2D{constructor(e={}){super();u(this,"src");u(this,"gap",0);u(this,"color","#000000");u(this,"_audioBuffer");u(this,"_src",_r?new ge(document.createElement("canvas")):void 0);u(this,"_needsUpdateTexture",!1);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>Dt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){var f,p;const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const i=(f=this._src)==null?void 0:f.source;if(!i)return;const{width:s=0,height:o=0}=this.style;i.width=s,i.height=o;const a=i.getContext("2d");if(!a){console.warn("Failed to getContext('2d') in syncTexture");return}a.fillStyle=this.color;const l=t.getChannelData(0),h=Math.ceil(l.length/s),c=o/2;for(let m=1,g=-1,_=0;_<s;_++){for(let y=0;y<h;y++){const E=l[_*h+y];E<m&&(m=E),E>g&&(g=E)}if(!this.gap||_%(this.gap*2)===0){const y=_,E=(1+m)*c,T=this.gap||1,P=Math.max(1,(g-m)*c);a.fillRect(y,E,T,P),m=1,g=-1}}(p=this._src)==null||p.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height))}},zi([M()],d.AudioWaveform.prototype,"src",2),zi([M()],d.AudioWaveform.prototype,"gap",2),zi([M()],d.AudioWaveform.prototype,"color",2),d.AudioWaveform=zi([j("AudioWaveform")],d.AudioWaveform);var qd=Object.defineProperty,Wd=Object.getOwnPropertyDescriptor,Xd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Wd(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&qd(r,e,i),i};d.Control=class extends d.CanvasItem{constructor(r,e=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(r),this.append(e)}_parented(r){super._parented(r),r.on("updateRect",this._parentUpdateRect)}_unparented(r){super._unparented(r),r.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const r=this._parent.getRect();this.style.left=r.left,this.style.top=r.top,this.style.width=r.width,this.style.height=r.height}_input(r,e){super._input(r,e),this._guiInput(r,e)}_updateStyleProperty(r,e,t,i){switch(super._updateStyleProperty(r,e,t,i),r){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(r,e){}getRect(){let{left:r,top:e,width:t,height:i,rotate:s}=this.style;if(s){s=Math.abs(s%180),s=s/180*Math.PI;const o=Math.abs(Math.sin(s)),a=Math.abs(Math.cos(s)),l=i*o+t*a,h=i*a+t*o;r+=(t-l)/2,e+=(i-h)/2,t=l,i=h}return new ni(r,e,t,i)}},d.Control=Xd([j("Control")],d.Control);var Hd=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Rt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Yd(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&&Hd(r,e,i),i};d.Range=class extends d.Control{constructor(r,e=[]){super(),this.setProperties(r).append(e)}_updateProperty(r,e,t,i){switch(super._updateProperty(r,e,t,i),r){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},Rt([M({default:!1})],d.Range.prototype,"allowGreater",2),Rt([M({default:!1})],d.Range.prototype,"allowLesser",2),Rt([M({default:1})],d.Range.prototype,"page",2),Rt([M({default:0})],d.Range.prototype,"minValue",2),Rt([M({default:100})],d.Range.prototype,"maxValue",2),Rt([M({default:.01})],d.Range.prototype,"step",2),Rt([M({default:0})],d.Range.prototype,"value",2),d.Range=Rt([j("Range")],d.Range);var Zd=Object.defineProperty,Kd=Object.getOwnPropertyDescriptor,dt=(n,r,e,t)=>{for(var i=t>1?void 0:t?Kd(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&&Zd(r,e,i),i};d.Ruler=class extends d.Control{constructor(e,t=[]){super();u(this,"texture",new Er);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.style,{offsetX:i,offsetY:s,thickness:o,markHeight:a,markBackgroundColor:l,markColor:h,color:c,gap:f,scale:p}=this,g=this.texture.source.getContext("2d");g.reset(),g.scale(this.texture.pixelRatio,this.texture.pixelRatio);const _=Math.round(i),y=Math.round(s);g.beginPath(),g.fillStyle=l||"#EEE",g.fillRect(0,0,e,o),g.fillRect(0,0,o,t),g.fill(),g.strokeStyle=h||"#000",g.moveTo(o,0),g.lineTo(o,t),g.moveTo(0,o),g.lineTo(e,o),g.stroke();const E=f,T=f*p;let P,S,w,v,x;for(E>=T?(P=E/T,S=Math.floor(P)*E/20,w=E/20*Math.floor(P)/P):(P=T/E,S=Math.floor(E/20/P),S>=2?S=Math.floor(S/2)*2:S=1,w=S*P),g.fillStyle=g.strokeStyle,v=_,x=0;v<e;x++,v+=w)g.moveTo(v,o-(x%5?a:2*a)),g.lineTo(v,o);for(v=_,x=0;v>o;x++,v-=w)g.moveTo(v,o-(x%5?a:2*a)),g.lineTo(v,o);let C=0;for(v=y,x=0;v>o;x++,v-=w)g.moveTo(o-(x%5?a:2*a),v),g.lineTo(o,v);for(v=y,x=0;v<t;x++,v+=w)g.moveTo(o-(x%5?a:2*a),v),g.lineTo(o,v);for(g.save(),g.fillStyle=c,g.scale(.8,.8),C=o-8,v=_,x=0;v<e;x++,v+=w)x%10===0&&g.fillText(String(Math.ceil(S*x)),v*1.25-3,C*1.25);for(v=_,x=0;v>o;x++,v-=w)x%10===0&&g.fillText(String(Math.ceil(-S*x)),v*1.25-3,C*1.25);for(C=0,v=y,x=0;v>o;x++,v-=w)x%10===0&&g.fillText(String(Math.ceil(S*x)),C*1.25,v*1.25+3);for(v=y,x=0;v<t;x++,v+=w)x%10===0&&g.fillText(String(Math.ceil(-S*x)),C*1.25,v*1.25+3);g.restore(),g.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},dt([M({default:0})],d.Ruler.prototype,"offsetX",2),dt([M({default:0})],d.Ruler.prototype,"offsetY",2),dt([M({default:20})],d.Ruler.prototype,"thickness",2),dt([M({default:3})],d.Ruler.prototype,"markHeight",2),dt([M({default:"#b2b6bc"})],d.Ruler.prototype,"color",2),dt([M({default:"#f9f9fa"})],d.Ruler.prototype,"markBackgroundColor",2),dt([M({default:"#b2b6bc"})],d.Ruler.prototype,"markColor",2),dt([M({default:300})],d.Ruler.prototype,"gap",2),dt([M({default:1})],d.Ruler.prototype,"scale",2),d.Ruler=dt([j("Ruler")],d.Ruler);var Jd=Object.defineProperty,Qd=Object.getOwnPropertyDescriptor,Ya=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qd(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&&Jd(r,e,i),i};d.ScrollBar=class extends d.Range{constructor(r,e=[]){super(),this.setProperties(r).append(e)}_updateStyleProperty(r,e,t,i){switch(super._updateStyleProperty(r,e,t,i),r){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_guiInput(r,e){super._guiInput(r,e)}_draw(){let r,e,t,i,s;this.direction==="vertical"?(t=10,i=this.style.height*(this.page/(this.maxValue-this.minValue)),r=this.style.left+this.style.width-t,e=this.style.height*(this.value/(this.maxValue-this.minValue)),s=t/2):(t=this.style.width*(this.page/(this.maxValue-this.minValue)),i=10,r=this.style.width*(this.value/(this.maxValue-this.minValue)),e=this.style.top+this.style.height-i,s=i/2),this.context.roundRect(r,e,t,i,s),this.context.fillStyle=34,this.context.fill()}},Ya([M({default:"vertical"})],d.ScrollBar.prototype,"direction",2),d.ScrollBar=Ya([j("ScrollBar")],d.ScrollBar);var ep=Object.defineProperty,tp=Object.getOwnPropertyDescriptor,rp=(n,r,e,t)=>{for(var i=t>1?void 0:t?tp(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&&ep(r,e,i),i};d.XScrollBar=class extends d.ScrollBar{constructor(r,e=[]){super(),this.setProperties(r).append(e)}},d.XScrollBar=rp([j("XScrollBar",{direction:"horizontal"})],d.XScrollBar);var ip=Object.defineProperty,sp=Object.getOwnPropertyDescriptor,np=(n,r,e,t)=>{for(var i=t>1?void 0:t?sp(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&&ip(r,e,i),i};d.YScrollBar=class extends d.ScrollBar{constructor(r,e=[]){super(),this.setProperties(r).append(e)}},d.YScrollBar=np([j("YScrollBar",{direction:"vertical"})],d.YScrollBar);var op=Object.defineProperty,ap=Object.getOwnPropertyDescriptor,Vi=(n,r,e,t)=>{for(var i=t>1?void 0:t?ap(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&&op(r,e,i),i};d.Scaler=class extends d.Node{get target(){var r;if((r=this.parent)!=null&&r.style)return this.parent}constructor(r,e=[]){super(),this.setProperties(r),this.append(e)}_updateProperty(r,e,t,i){switch(super._updateProperty(r,e,t,i),r){case"value":case"min":case"max":{this.value=at(this.minValue,this.value,this.maxValue),this._updateScale();break}}}_updateScale(){const r=this.target;r&&(r.style.scaleX=this.value,r.style.scaleY=this.value,this.emit("updateScale",this.value))}_onWheel(r){if(!this.target)return;if(r.preventDefault(),!(r.wheelDeltaY?Math.abs(Math.abs(r.wheelDeltaY)-Math.abs(3*r.deltaY))<3:r.deltaMode===0)&&r.ctrlKey){r.preventDefault();let i=r.deltaY/(r.ctrlKey?1:100);i*=-.015,this.value+=i}}_input(r,e){switch(super._input(r,e),e){case"wheel":this._onWheel(r);break}}},Vi([M({default:1})],d.Scaler.prototype,"value",2),Vi([M({default:.05})],d.Scaler.prototype,"minValue",2),Vi([M({default:10})],d.Scaler.prototype,"maxValue",2),d.Scaler=Vi([j("Scaler",{processMode:"disabled",renderMode:"disabled"})],d.Scaler);var Za=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,hp=(n,r,e)=>r in n?Za(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,cp=(n,r,e,t)=>{for(var i=t>1?void 0:t?lp(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&&Za(r,e,i),i},up=(n,r,e)=>hp(n,r+"",e);d.KawaseTransition=class extends d.Transition{constructor(){super(...arguments);u(this,"blur",10);u(this,"quality",10)}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=this.blur,l=this.quality,h=t.width,c=t.height,f=[],p=[a];if(a>0){let T=a;const P=a/l;for(let S=1;S<l;S++)T-=P,p.push(T)}const m=1/h,g=1/c,_=[];let y;const E=l-1;for(let T=0;T<E;T++)y=p[T]+.5,_[0]=y*m,_[1]=y*g,f.push({offset:_});y=p[E]+.5,_[0]=y*m,_[1]=y*g,f.push({offset:_}),f.forEach(T=>{J.draw(e,d.KawaseTransition.material,{sampler:s,progress:o,...T})})}},up(d.KawaseTransition,"material",new se({vert:`attribute vec2 position;
753
+ attribute vec2 uv;
754
+ varying vec2 vUv;
755
+ void main() {
756
+ gl_Position = vec4(position, 0.0, 1.0);
757
+ vUv = uv;
758
+ }`,frag:`precision highp float;
759
+ varying vec2 vUv;
760
+ uniform sampler2D sampler;
761
+ uniform vec2 offset;
762
+ uniform float progress;
763
+
764
+ void main(void) {
765
+ vec2 offset1 = vec2(offset.x - progress * offset.x, offset.y - progress * offset.y);
766
+ vec4 color = vec4(0.0);
767
+ color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y + offset1.y));
768
+ color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y + offset1.y));
769
+ color += texture2D(sampler, vec2(vUv.x + offset1.x, vUv.y - offset1.y));
770
+ color += texture2D(sampler, vec2(vUv.x - offset1.x, vUv.y - offset1.y));
771
+ color *= 0.25;
772
+ gl_FragColor = color;
773
+ }`})),d.KawaseTransition=cp([j("KawaseTransition")],d.KawaseTransition);var Ka=Object.defineProperty,fp=Object.getOwnPropertyDescriptor,dp=(n,r,e)=>r in n?Ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,pp=(n,r,e,t)=>{for(var i=t>1?void 0:t?fp(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},gp=(n,r,e)=>dp(n,r+"",e);d.LeftEraseTransition=class extends d.Transition{apply(r){J.draw(r,d.LeftEraseTransition.material,{previous:0,next:1,progress:this.currentTimeProgress})}},gp(d.LeftEraseTransition,"material",new se({vert:`attribute vec2 position;
774
+ attribute vec2 uv;
775
+ varying vec2 vUv;
776
+ void main() {
777
+ gl_Position = vec4(position, 0.0, 1.0);
778
+ vUv = uv;
779
+ }`,frag:`precision highp float;
780
+ varying vec2 vUv;
781
+ uniform float progress;
782
+ uniform sampler2D previous;
783
+ uniform sampler2D next;
784
+
785
+ float easeInOutQuint(float t) {
786
+ return t < 0.5 ? 16.0*t*t*t*t*t : 1.0+16.0*(--t)*t*t*t*t;
787
+ }
788
+
789
+ void main() {
790
+ vec4 src1Color = texture2D(previous, vUv);
791
+ vec4 src2Color = texture2D(next, vUv);
792
+ float mProgress = 1.0 - progress;
793
+ float mixPercent = 0.0;
794
+ if (vUv.x <= mProgress) {
795
+ mixPercent = 1.0;
796
+ }
797
+ gl_FragColor = mix(src2Color, src1Color, mixPercent);
798
+ }`})),d.LeftEraseTransition=pp([j("LeftEraseTransition")],d.LeftEraseTransition);var Ja=Object.defineProperty,mp=Object.getOwnPropertyDescriptor,yp=(n,r,e)=>r in n?Ja(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,_p=(n,r,e,t)=>{for(var i=t>1?void 0:t?mp(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&&Ja(r,e,i),i},vp=(n,r,e)=>yp(n,r+"",e);d.TiltShiftTransition=class extends d.Transition{constructor(){super(...arguments);u(this,"blur",100);u(this,"gradientBlur",600)}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height,h=[0,l/2],c=[600,l/2],f=[a,l],p=c[0]-h[0],m=c[1]-h[1],g=Math.sqrt(p*p+m*m);J.draw(e,d.TiltShiftTransition.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[p/g,m/g],texSize:f}),J.draw(e,d.TiltShiftTransition.material,{sampler:s,progress:o,blur:this.blur,gradientBlur:this.gradientBlur,start:h,end:c,delta:[-m/g,p/g],texSize:f})}},vp(d.TiltShiftTransition,"material",new se({vert:`attribute vec2 position;
719
799
  attribute vec2 uv;
720
800
  varying vec2 vUv;
721
801
  void main() {
@@ -759,7 +839,7 @@ void main(void) {
759
839
  color.rgb /= color.a + 0.00001;
760
840
 
761
841
  gl_FragColor = color;
762
- }`})),d.TiltShiftEffect=Yd([q("TiltShiftEffect")],d.TiltShiftEffect);var Ka=Object.defineProperty,Kd=Object.getOwnPropertyDescriptor,Jd=(n,r,e)=>r in n?Ka(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Qd=(n,r,e,t)=>{for(var i=t>1?void 0:t?Kd(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},ep=(n,r,e)=>Jd(n,r+"",e);d.TwistEffect=class extends d.Effect{constructor(){super(...arguments);u(this,"radius");u(this,"angle",4);u(this,"padding",20);u(this,"offset")}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height;J.draw(e,d.TwistEffect.material,{sampler:s,progress:o,filterArea:[a,l,0,0],radius:this.radius??a,angle:this.angle,padding:this.padding,offset:this.offset??[a/2,l/2]})}},ep(d.TwistEffect,"material",new ne({vert:`attribute vec2 position;
842
+ }`})),d.TiltShiftTransition=_p([j("TiltShiftTransition")],d.TiltShiftTransition);var Qa=Object.defineProperty,bp=Object.getOwnPropertyDescriptor,wp=(n,r,e)=>r in n?Qa(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,xp=(n,r,e,t)=>{for(var i=t>1?void 0:t?bp(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&&Qa(r,e,i),i},Pp=(n,r,e)=>wp(n,r+"",e);d.TwistTransition=class extends d.Transition{constructor(){super(...arguments);u(this,"radius");u(this,"angle",4);u(this,"padding",20);u(this,"offset")}apply(e,t){const i=this.currentTimeProgress;let s,o;i<.5?(s=0,o=(.5-i)/.5):(s=1,o=(i-.5)/.5);const a=t.width,l=t.height;J.draw(e,d.TwistTransition.material,{sampler:s,progress:o,filterArea:[a,l,0,0],radius:this.radius??a,angle:this.angle,padding:this.padding,offset:this.offset??[a/2,l/2]})}},Pp(d.TwistTransition,"material",new se({vert:`attribute vec2 position;
763
843
  attribute vec2 uv;
764
844
  varying vec2 vUv;
765
845
  void main() {
@@ -805,84 +885,4 @@ void main(void) {
805
885
  coord = twist(coord, radius - (progress * radius));
806
886
  coord = unmapCoord(coord);
807
887
  gl_FragColor = texture2D(sampler, coord);
808
- }`})),d.TwistEffect=Qd([q("TwistEffect")],d.TwistEffect);var Ja=Object.defineProperty,tp=Object.getOwnPropertyDescriptor,rp=(n,r,e)=>r in n?Ja(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Yr=(n,r,e,t)=>{for(var i=t>1?void 0:t?tp(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&&Ja(r,e,i),i},ip=(n,r,e)=>rp(n,r+"",e);d.ZoomBlurEffect=class extends d.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,()=>{J.draw(e,d.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]})})}},ip(d.ZoomBlurEffect,"material",new ne({vert:`attribute vec2 position;
809
- attribute vec2 uv;
810
- varying vec2 vUv;
811
- void main() {
812
- gl_Position = vec4(position, 0.0, 1.0);
813
- vUv = uv;
814
- }`,frag:`varying vec2 vUv;
815
- uniform sampler2D sampler;
816
- uniform vec4 inputSize;
817
-
818
- uniform vec2 center;
819
- uniform float strength;
820
- uniform float innerRadius;
821
- uniform float radius;
822
-
823
- const float MAX_KERNEL_SIZE = 32.0;
824
-
825
- highp float rand(vec2 co, float seed) {
826
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
827
- highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);
828
- return fract(sin(sn) * c + seed);
829
- }
830
-
831
- void main() {
832
- float minGradient = innerRadius * 0.3;
833
- float innerRadius1 = (innerRadius + minGradient * 0.5) / inputSize.x;
834
-
835
- float gradient = radius * 0.3;
836
- float radius1 = (radius - gradient * 0.5) / inputSize.x;
837
-
838
- float countLimit = MAX_KERNEL_SIZE;
839
-
840
- vec2 dir = vec2(center.xy / inputSize.xy - vUv);
841
- float dist = length(vec2(dir.x, dir.y * inputSize.y / inputSize.x));
842
-
843
- float strength1 = strength;
844
-
845
- float delta = 0.0;
846
- float gap;
847
- if (dist < innerRadius1) {
848
- delta = innerRadius1 - dist;
849
- gap = minGradient;
850
- } else if (radius1 >= 0.0 && dist > radius1) { // radius1 < 0 means it's infinity
851
- delta = dist - radius1;
852
- gap = gradient;
853
- }
854
-
855
- if (delta > 0.0) {
856
- float normalCount = gap / inputSize.x;
857
- delta = (normalCount - delta) / normalCount;
858
- countLimit *= delta;
859
- strength1 *= delta;
860
- if (countLimit < 1.0) {
861
- gl_FragColor = texture2D(sampler, vUv);
862
- return;
863
- }
864
- }
865
-
866
- float offset = rand(vUv, 0.0);
867
-
868
- float total = 0.0;
869
- vec4 color = vec4(0.0);
870
-
871
- dir *= strength1;
872
-
873
- for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {
874
- float percent = (t + offset) / MAX_KERNEL_SIZE;
875
- float weight = 4.0 * (percent - percent * percent);
876
- vec2 p = vUv + dir * percent;
877
- color += texture2D(sampler, p) * weight;
878
- total += weight;
879
-
880
- if (t > countLimit){
881
- break;
882
- }
883
- }
884
-
885
- color /= total;
886
-
887
- gl_FragColor = color;
888
- }`})),Yr([M()],d.ZoomBlurEffect.prototype,"center",2),Yr([M()],d.ZoomBlurEffect.prototype,"innerRadius",2),Yr([M()],d.ZoomBlurEffect.prototype,"radius",2),Yr([M()],d.ZoomBlurEffect.prototype,"strength",2),d.ZoomBlurEffect=Yr([q("ZoomBlurEffect")],d.ZoomBlurEffect);var sp=Object.defineProperty,np=Object.getOwnPropertyDescriptor,op=(n,r,e,t)=>{for(var i=t>1?void 0:t?np(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&&sp(r,e,i),i};d.Control=class extends d.CanvasItem{constructor(r,e=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(r),this.append(e)}_parented(r){super._parented(r),r.on("updateRect",this._parentUpdateRect)}_unparented(r){super._unparented(r),r.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const r=this._parent.getRect();this.style.left=r.left,this.style.top=r.top,this.style.width=r.width,this.style.height=r.height}_input(r,e){super._input(r,e),this._guiInput(r,e)}_updateStyleProperty(r,e,t,i){switch(super._updateStyleProperty(r,e,t,i),r){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(r,e){}getRect(){let{left:r,top:e,width:t,height:i,rotate:s}=this.style;if(s){s=Math.abs(s%180),s=s/180*Math.PI;const o=Math.abs(Math.sin(s)),a=Math.abs(Math.cos(s)),l=i*o+t*a,h=i*a+t*o;r+=(t-l)/2,e+=(i-h)/2,t=l,i=h}return new ni(r,e,t,i)}},d.Control=op([q("Control")],d.Control);var ap=Object.defineProperty,lp=Object.getOwnPropertyDescriptor,Rt=(n,r,e,t)=>{for(var i=t>1?void 0:t?lp(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&&ap(r,e,i),i};d.Range=class extends d.Control{constructor(r,e=[]){super(),this.setProperties(r).append(e)}_updateProperty(r,e,t,i){switch(super._updateProperty(r,e,t,i),r){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},Rt([M({default:!1})],d.Range.prototype,"allowGreater",2),Rt([M({default:!1})],d.Range.prototype,"allowLesser",2),Rt([M({default:1})],d.Range.prototype,"page",2),Rt([M({default:0})],d.Range.prototype,"minValue",2),Rt([M({default:100})],d.Range.prototype,"maxValue",2),Rt([M({default:.01})],d.Range.prototype,"step",2),Rt([M({default:0})],d.Range.prototype,"value",2),d.Range=Rt([q("Range")],d.Range);var hp=Object.defineProperty,cp=Object.getOwnPropertyDescriptor,dt=(n,r,e,t)=>{for(var i=t>1?void 0:t?cp(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&&hp(r,e,i),i};d.Ruler=class extends d.Control{constructor(e,t=[]){super();u(this,"texture",new Sr);this.setProperties(e),this.append(t)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.style,{offsetX:i,offsetY:s,thickness:o,markHeight:a,markBackgroundColor:l,markColor:h,color:c,gap:f,scale:p}=this,g=this.texture.source.getContext("2d");g.reset(),g.scale(this.texture.pixelRatio,this.texture.pixelRatio);const _=Math.round(i),y=Math.round(s);g.beginPath(),g.fillStyle=l||"#EEE",g.fillRect(0,0,e,o),g.fillRect(0,0,o,t),g.fill(),g.strokeStyle=h||"#000",g.moveTo(o,0),g.lineTo(o,t),g.moveTo(0,o),g.lineTo(e,o),g.stroke();const S=f,T=f*p;let P,E,w,v,x;for(S>=T?(P=S/T,E=Math.floor(P)*S/20,w=S/20*Math.floor(P)/P):(P=T/S,E=Math.floor(S/20/P),E>=2?E=Math.floor(E/2)*2:E=1,w=E*P),g.fillStyle=g.strokeStyle,v=_,x=0;v<e;x++,v+=w)g.moveTo(v,o-(x%5?a:2*a)),g.lineTo(v,o);for(v=_,x=0;v>o;x++,v-=w)g.moveTo(v,o-(x%5?a:2*a)),g.lineTo(v,o);let C=0;for(v=y,x=0;v>o;x++,v-=w)g.moveTo(o-(x%5?a:2*a),v),g.lineTo(o,v);for(v=y,x=0;v<t;x++,v+=w)g.moveTo(o-(x%5?a:2*a),v),g.lineTo(o,v);for(g.save(),g.fillStyle=c,g.scale(.8,.8),C=o-8,v=_,x=0;v<e;x++,v+=w)x%10===0&&g.fillText(String(Math.ceil(E*x)),v*1.25-3,C*1.25);for(v=_,x=0;v>o;x++,v-=w)x%10===0&&g.fillText(String(Math.ceil(-E*x)),v*1.25-3,C*1.25);for(C=0,v=y,x=0;v>o;x++,v-=w)x%10===0&&g.fillText(String(Math.ceil(E*x)),C*1.25,v*1.25+3);for(v=y,x=0;v<t;x++,v+=w)x%10===0&&g.fillText(String(Math.ceil(-E*x)),C*1.25,v*1.25+3);g.restore(),g.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e!=null&&e.valid&&(this.context.fillStyle=e,this.context.textureTransform=new et().scale(this.style.width/e.width,this.style.height/e.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},dt([M({default:0})],d.Ruler.prototype,"offsetX",2),dt([M({default:0})],d.Ruler.prototype,"offsetY",2),dt([M({default:20})],d.Ruler.prototype,"thickness",2),dt([M({default:3})],d.Ruler.prototype,"markHeight",2),dt([M({default:"#b2b6bc"})],d.Ruler.prototype,"color",2),dt([M({default:"#f9f9fa"})],d.Ruler.prototype,"markBackgroundColor",2),dt([M({default:"#b2b6bc"})],d.Ruler.prototype,"markColor",2),dt([M({default:300})],d.Ruler.prototype,"gap",2),dt([M({default:1})],d.Ruler.prototype,"scale",2),d.Ruler=dt([q("Ruler")],d.Ruler);var up=Object.defineProperty,fp=Object.getOwnPropertyDescriptor,Qa=(n,r,e,t)=>{for(var i=t>1?void 0:t?fp(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&&up(r,e,i),i};d.ScrollBar=class extends d.Range{constructor(r,e=[]){super(),this.setProperties(r).append(e)}_updateStyleProperty(r,e,t,i){switch(super._updateStyleProperty(r,e,t,i),r){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_guiInput(r,e){super._guiInput(r,e)}_draw(){let r,e,t,i,s;this.direction==="vertical"?(t=10,i=this.style.height*(this.page/(this.maxValue-this.minValue)),r=this.style.left+this.style.width-t,e=this.style.height*(this.value/(this.maxValue-this.minValue)),s=t/2):(t=this.style.width*(this.page/(this.maxValue-this.minValue)),i=10,r=this.style.width*(this.value/(this.maxValue-this.minValue)),e=this.style.top+this.style.height-i,s=i/2),this.context.roundRect(r,e,t,i,s),this.context.fillStyle=34,this.context.fill()}},Qa([M({default:"vertical"})],d.ScrollBar.prototype,"direction",2),d.ScrollBar=Qa([q("ScrollBar")],d.ScrollBar);var dp=Object.defineProperty,pp=Object.getOwnPropertyDescriptor,gp=(n,r,e,t)=>{for(var i=t>1?void 0:t?pp(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&&dp(r,e,i),i};d.XScrollBar=class extends d.ScrollBar{constructor(r,e=[]){super(),this.setProperties(r).append(e)}},d.XScrollBar=gp([q("XScrollBar",{direction:"horizontal"})],d.XScrollBar);var mp=Object.defineProperty,yp=Object.getOwnPropertyDescriptor,_p=(n,r,e,t)=>{for(var i=t>1?void 0:t?yp(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&&mp(r,e,i),i};d.YScrollBar=class extends d.ScrollBar{constructor(r,e=[]){super(),this.setProperties(r).append(e)}},d.YScrollBar=_p([q("YScrollBar",{direction:"vertical"})],d.YScrollBar);var vp=Object.defineProperty,bp=Object.getOwnPropertyDescriptor,Vi=(n,r,e,t)=>{for(var i=t>1?void 0:t?bp(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&&vp(r,e,i),i};d.Scaler=class extends d.Node{get target(){var r;if((r=this.parent)!=null&&r.style)return this.parent}constructor(r,e=[]){super(),this.setProperties(r),this.append(e)}_updateProperty(r,e,t,i){switch(super._updateProperty(r,e,t,i),r){case"value":case"min":case"max":{this.value=at(this.minValue,this.value,this.maxValue),this._updateScale();break}}}_updateScale(){const r=this.target;r&&(r.style.scaleX=this.value,r.style.scaleY=this.value,this.emit("updateScale",this.value))}_onWheel(r){if(!this.target)return;if(r.preventDefault(),!(r.wheelDeltaY?Math.abs(Math.abs(r.wheelDeltaY)-Math.abs(3*r.deltaY))<3:r.deltaMode===0)&&r.ctrlKey){r.preventDefault();let i=r.deltaY/(r.ctrlKey?1:100);i*=-.015,this.value+=i}}_input(r,e){switch(super._input(r,e),e){case"wheel":this._onWheel(r);break}}},Vi([M({default:1})],d.Scaler.prototype,"value",2),Vi([M({default:.05})],d.Scaler.prototype,"minValue",2),Vi([M({default:10})],d.Scaler.prototype,"maxValue",2),d.Scaler=Vi([q("Scaler",{processMode:"disabled",renderMode:"disabled"})],d.Scaler);class el 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 mi(s.map(o=>({duration:o.delay,texture:new Ss(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 tl 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 rl 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 il 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 sl extends Tt{install(r){const e=t=>r.fetchImageBitmap(t,{premultiplyAlpha:"premultiply"}).then(i=>new me(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 nl extends Tt{install(r){const e=t=>new Wo(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 wp=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 xp(n){for(const[r,e]of wp)if(e.includes(n))return r}async function Pp(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=xp(i))}return r??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const ji="WeakRef"in globalThis;class ol{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",ji?new FinalizationRegistry(r=>{const e=this.get(r);e&&"destroy"in e&&e.destroy(),this._handled.delete(r)}):void 0);ji||fe.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 ji&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(r)),e}set(r,e){let t=e;ji&&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 Pp(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 Pt=new ol().use(new ho).use(new el).use(new tl).use(new rl).use(new il).use(new sl).use(new nl);class Cp extends d.Control{constructor(){super();u(this,"name","CanvasEditor");u(this,"hover",new d.Node2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));u(this,"selectionRect",new d.Node2D({name:"selectionRect",internalMode:"back",style:{visibility:"hidden",width:1,height:1,backgroundColor:16711695,outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));u(this,"selector",new d.Node2D({name:"selector"}));u(this,"scaler",new d.Scaler({internalMode:"back"}).on("updateScale",e=>{this.ruler.scale=e;const t=this.drawboard.style.height*e,i=this.drawboard.style.width*e;t>this.style.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.style.height):this.yScrollBar.style.visibility="hidden",i>this.style.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=i,this.xScrollBar.page=this.style.width):this.xScrollBar.style.visibility="hidden"}));u(this,"xScrollBar",new d.XScrollBar({internalMode:"back",style:{visibility:"hidden"}}));u(this,"yScrollBar",new d.YScrollBar({internalMode:"back",style:{visibility:"hidden"}}));u(this,"drawboard",new d.Node2D({name:"drawboard",style:{width:500,height:500,backgroundColor:4294967295,overflow:"hidden",pointerEvents:"none"}}).append(this.scaler,new d.ShadowEffect({internalMode:"back"})));u(this,"ruler",new d.Ruler({name:"ruler",offsetX:100,offsetY:100}).append(this.drawboard,this.hover,this.selectionRect,this.xScrollBar,this.yScrollBar));u(this,"_pointerStart");u(this,"_pointerOffset");u(this,"selected");this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":this.drawboard.style.left=(this.style.width-this.drawboard.style.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.style.height-this.drawboard.style.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){const t=e.target;this._pointerOffset={x:e.offsetX,y:e.offsetY},t instanceof d.Node2D?(this.selected=t,this._pointerStart=t.style.clone()):(this.selected=void 0,this._pointerStart=void 0,this.selectionRect.style.visibility="visible",this.selectionRect.style.left=e.screen.x,this.selectionRect.style.top=e.screen.y,this.selectionRect.style.width=1,this.selectionRect.style.height=1),this._onHover()}_onPointermove(e){const{selected:t,_pointerStart:i,_pointerOffset:s}=this,o=s?{x:e.offsetX-s.x,y:e.offsetY-s.y}:{x:0,y:0};t&&i?(t.style.left=i.left+o.x,t.style.top=i.top+o.y):this.selectionRect.isVisibleInTree()&&(this.selectionRect.style.width=o.x,this.selectionRect.style.height=o.y),this._onHover()}_onPointerup(){this.selected=void 0,this.selectionRect.style.visibility="hidden",this._onHover()}_onHover(){const e=this.selected;e instanceof d.Node2D?(this.hover.style.visibility="visible",this.hover.style.width=e.style.width,this.hover.style.height=e.style.height,this.hover.transform.set(e.transform),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}}const al={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class ll extends gi{constructor(e={}){var p,m;const{view:t,width:i,height:s,pixelRatio:o=rs,backgroundColor:a=0,autoResize:l,autoStart:h,timeline:c,...f}=e;super(c);u(this,"input",new In);u(this,"renderer");u(this,"_resizeObserver",vn?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 lo(t,{...al,...f}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,l?(!t&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(l)):this.resize(i||this.gl.drawingBufferWidth||((p=this.view)==null?void 0:p.clientWidth)||200,s||this.gl.drawingBufferHeight||((m=this.view)==null?void 0:m.clientHeight)||200,!t),h&&this.start()}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))}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),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 ss()}waitUntilLoad(){return Pt.waitUntilLoad()}render(e=0){return 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 Zr,Tp;const hl=[];async function Ep(n=100){for(;;){const r=hl.shift();if(r)try{await r()}catch(e){console.error(e)}else await new Promise(e=>setTimeout(e,n))}}async function Sp(n){Zr??(Zr=new ll({width:1,height:1}));const r=Zr.root;r.removeChildren();const{data:e,width:t,height:i}=n;return Zr.resize(t,i),(Array.isArray(e)?e:[e]).forEach(s=>{s instanceof d.Node?r.addChild(s):r.addChild(d.Node.parse(s))}),await Zr.waitUntilLoad(),Zr.toCanvas2D()}async function Mp(n){return Tp??(Tp=Ep()),new Promise(r=>{hl.push(async()=>r(await Sp(n)))})}d.Assets=ol,d.AudioPipeline=hn,d.AudioProcessor=jf,d.AudioSpectrum=Zf,d.CanvasContext=Xo,d.CanvasEditor=Cp,d.CanvasItemStyle=re,d.CanvasTexture=Sr,d.Color=Ct,d.ColorMatrix=us,d.ColorTexture=Es,d.CoreObject=ti,d.DEG_TO_RAD=qn,d.DEVICE_PIXEL_RATIO=rs,d.EffectMaterial=di,d.Engine=ll,d.EventEmitter=mt,d.FontLoader=ho,d.Geometry=fi,d.GifLoader=el,d.HTMLAudio=Sa,d.HTMLAudioContext=$i,d.HTMLSound=Fi,d.IN_BROWSER=_r,d.Image2DResource=mi,d.ImageTexture=yc,d.IndexBuffer=rr,d.Input=In,d.InputEvent=ri,d.JsonLoader=tl,d.Loader=Tt,d.LottieLoader=rl,d.MainLoop=oi,d.Material=ne,d.Matrix=ot,d.Matrix2=Ll,d.Matrix3=fs,d.Matrix4=Gn,d.MouseInputEvent=ns,d.PI=Me,d.PI_2=le,d.PixelsTexture=Ss,d.PointerInputEvent=Dn,d.Projection2D=Xn,d.QuadGeometry=sc,d.QuadUvGeometry=J,d.RAD_TO_DEG=Rl,d.RawWeakMap=Zt,d.Rect2=ni,d.RefCounted=Un,d.Renderer=Yn,d.Resource=yt,d.SUPPORTS_AUDIO_CONTEXT=Qi,d.SUPPORTS_CLICK_EVENTS=wn,d.SUPPORTS_CREATE_IMAGE_BITMAP=Ji,d.SUPPORTS_IMAGE_BITMAP=_n,d.SUPPORTS_MOUSE_EVENTS=bl,d.SUPPORTS_OFFLINE_AUDIO_CONTEXT=ts,d.SUPPORTS_POINTER_EVENTS=Yt,d.SUPPORTS_RESIZE_OBSERVER=vn,d.SUPPORTS_TOUCH_EVENTS=gt,d.SUPPORTS_WEBGL2=yn,d.SUPPORTS_WEBKIT_AUDIO_CONTEXT=es,d.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=xn,d.SUPPORTS_WEB_AUDIO=Pn,d.SUPPORTS_WHEEL_EVENTS=bn,d.SceneTree=gi,d.TextLoader=il,d.Texture2D=me,d.TextureLoader=sl,d.TextureRect2D=_i,d.Ticker=fe,d.Transform2D=et,d.UvGeometry=lc,d.UvMaterial=ir,d.Vector=Qe,d.Vector2=si,d.Vector3=kl,d.Vector4=Wn,d.VertexAttribute=je,d.VertexBuffer=vt,d.VideoLoader=nl,d.VideoTexture=Wo,d.ViewportTexture=As,d.WebAudio=Aa,d.WebAudioContext=It,d.WebGLBatch2DModule=Jn,d.WebGLBlendMode=Kt,d.WebGLBufferModule=Qn,d.WebGLFramebufferModule=eo,d.WebGLMaskModule=to,d.WebGLModule=He,d.WebGLProgramModule=ro,d.WebGLRenderer=lo,d.WebGLScissorModule=io,d.WebGLState=Lt,d.WebGLStateModule=Kn,d.WebGLStencilModule=so,d.WebGLTextureModule=no,d.WebGLVertexArrayModule=oo,d.WebGLViewportModule=ao,d.WebSound=Ma,d.WheelInputEvent=br,d.assets=Pt,d.clamp=at,d.createHTMLCanvas=Sn,d.createNode=xl,d.crossOrigin=An,d.cubicBezier=pr,d.curves=Bl,d.customNode=q,d.customNodes=ei,d.defaultOptions=al,d.defineProperty=vr,d.determineCrossOrigin=Mn,d.ease=Pa,d.easeIn=Ca,d.easeInOut=Ea,d.easeOut=Ta,d.getDeclarations=Qr,d.getDefaultCssPropertyValue=Ki,d.isCanvasElement=Tn,d.isElementNode=is,d.isImageElement=wl,d.isPow2=Zi,d.isVideoElement=Cn,d.isWebgl2=En,d.lerp=de,d.linear=xa,d.log2=ps,d.mapWebGLBlendModes=Zn,d.nextPow2=ds,d.nextTick=ss,d.parseCssFunctions=yr,d.parseCssProperty=mr,d.property=M,d.protectedProperty=ue,d.render=Mp,d.timingFunctions=Ni,d.uid=gn,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
888
+ }`})),d.TwistTransition=xp([j("TwistTransition")],d.TwistTransition);class el 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 mi(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 tl 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 rl 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 il 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 sl extends Tt{install(r){const e=t=>r.fetchImageBitmap(t,{premultiplyAlpha:"premultiply"}).then(i=>new ge(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 nl extends Tt{install(r){const e=t=>new Wo(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 Cp=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 Tp(n){for(const[r,e]of Cp)if(e.includes(n))return r}async function Sp(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=Tp(i))}return r??await fetch(n).then(i=>i.headers.get("Content-Type"))??""}const ji="WeakRef"in globalThis;class ol{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",ji?new FinalizationRegistry(r=>{const e=this.get(r);e&&"destroy"in e&&e.destroy(),this._handled.delete(r)}):void 0);ji||fe.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;charset=utf-8,")&&(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 ji&&e instanceof WeakRef&&(e=e.deref(),e||this._handleing.delete(r)),e}set(r,e){let t=e;ji&&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 Sp(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 Pt=new ol().use(new ho).use(new el).use(new tl).use(new rl).use(new il).use(new sl).use(new nl);class Ep extends d.Control{constructor(){super();u(this,"name","CanvasEditor");u(this,"hover",new d.Node2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));u(this,"selectionRect",new d.Node2D({name:"selectionRect",internalMode:"back",style:{visibility:"hidden",width:1,height:1,backgroundColor:16711695,outlineStyle:"solid",outlineColor:16711935,outlineWidth:2,pointerEvents:"none"}}));u(this,"selector",new d.Node2D({name:"selector"}));u(this,"scaler",new d.Scaler({internalMode:"back"}).on("updateScale",e=>{this.ruler.scale=e;const t=this.drawboard.style.height*e,i=this.drawboard.style.width*e;t>this.style.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.style.height):this.yScrollBar.style.visibility="hidden",i>this.style.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=i,this.xScrollBar.page=this.style.width):this.xScrollBar.style.visibility="hidden"}));u(this,"xScrollBar",new d.XScrollBar({internalMode:"back",style:{visibility:"hidden"}}));u(this,"yScrollBar",new d.YScrollBar({internalMode:"back",style:{visibility:"hidden"}}));u(this,"drawboard",new d.Node2D({name:"drawboard",style:{width:500,height:500,backgroundColor:4294967295,overflow:"hidden",pointerEvents:"none",boxShadow:"2px 2px 2px 1px rgba(0, 0, 0, 0.2)"}}).append(this.scaler));u(this,"ruler",new d.Ruler({name:"ruler",offsetX:100,offsetY:100}).append(this.drawboard,this.hover,this.selectionRect,this.xScrollBar,this.yScrollBar));u(this,"_pointerStart");u(this,"_pointerOffset");u(this,"selected");this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,i,s){switch(super._updateStyleProperty(e,t,i,s),e){case"width":this.drawboard.style.left=(this.style.width-this.drawboard.style.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.style.height-this.drawboard.style.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){const t=e.target;this._pointerOffset={x:e.offsetX,y:e.offsetY},t instanceof d.Node2D?(this.selected=t,this._pointerStart=t.style.clone()):(this.selected=void 0,this._pointerStart=void 0,this.selectionRect.style.visibility="visible",this.selectionRect.style.left=e.screen.x,this.selectionRect.style.top=e.screen.y,this.selectionRect.style.width=1,this.selectionRect.style.height=1),this._onHover()}_onPointermove(e){const{selected:t,_pointerStart:i,_pointerOffset:s}=this,o=s?{x:e.offsetX-s.x,y:e.offsetY-s.y}:{x:0,y:0};t&&i?(t.style.left=i.left+o.x,t.style.top=i.top+o.y):this.selectionRect.isVisibleInTree()&&(this.selectionRect.style.width=o.x,this.selectionRect.style.height=o.y),this._onHover()}_onPointerup(){this.selected=void 0,this.selectionRect.style.visibility="hidden",this._onHover()}_onHover(){const e=this.selected;e instanceof d.Node2D?(this.hover.style.visibility="visible",this.hover.style.width=e.style.width,this.hover.style.height=e.style.height,this.hover.transform.set(e.transform),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}}const al={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class ll extends gi{constructor(e={}){var p,m;const{view:t,width:i,height:s,pixelRatio:o=rs,backgroundColor:a=0,autoResize:l,autoStart:h,timeline:c,...f}=e;super(c);u(this,"input",new Dn);u(this,"renderer");u(this,"_resizeObserver",vn?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 lo(t,{...al,...f}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,l?(!t&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(l)):this.resize(i||this.gl.drawingBufferWidth||((p=this.view)==null?void 0:p.clientWidth)||200,s||this.gl.drawingBufferHeight||((m=this.view)==null?void 0:m.clientHeight)||200,!t),h&&this.start()}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))}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),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 ss()}waitUntilLoad(){return Pt.waitUntilLoad()}render(e=0){return 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 Zr,Mp;const hl=[];async function Ap(n=100){for(;;){const r=hl.shift();if(r)try{await r()}catch(e){console.error(e)}else await new Promise(e=>setTimeout(e,n))}}async function Op(n){Zr??(Zr=new ll({width:1,height:1}));const r=Zr.root;r.removeChildren();const{data:e,width:t,height:i}=n;return Zr.resize(t,i),(Array.isArray(e)?e:[e]).forEach(s=>{s instanceof d.Node?r.addChild(s):r.addChild(d.Node.parse(s))}),await Zr.waitUntilLoad(),Zr.toCanvas2D()}async function Up(n){return Mp??(Mp=Ap()),new Promise(r=>{hl.push(async()=>r(await Op(n)))})}d.Assets=ol,d.AudioPipeline=pn,d.AudioProcessor=Bd,d.AudioSpectrum=Vd,d.CanvasContext=Xo,d.CanvasEditor=Ep,d.CanvasItemStyle=ne,d.CanvasTexture=Er,d.Color=Ct,d.ColorMatrix=us,d.ColorTexture=Ss,d.CoreObject=ti,d.DEG_TO_RAD=qn,d.DEVICE_PIXEL_RATIO=rs,d.EffectMaterial=di,d.Engine=ll,d.EventEmitter=mt,d.FontLoader=ho,d.Geometry=fi,d.GifLoader=el,d.HTMLAudio=qa,d.HTMLAudioContext=Fi,d.HTMLSound=$i,d.IN_BROWSER=_r,d.Image2DResource=mi,d.ImageTexture=yc,d.IndexBuffer=rr,d.Input=Dn,d.InputEvent=ri,d.JsonLoader=tl,d.Loader=Tt,d.LottieLoader=rl,d.MainLoop=oi,d.Material=se,d.Matrix=ot,d.Matrix2=kl,d.Matrix3=fs,d.Matrix4=Gn,d.MouseInputEvent=ns,d.PI=Me,d.PI_2=le,d.PixelsTexture=Es,d.PointerInputEvent=In,d.Projection2D=Xn,d.QuadGeometry=sc,d.QuadUvGeometry=J,d.RAD_TO_DEG=Rl,d.RawWeakMap=Zt,d.Rect2=ni,d.RefCounted=Un,d.Renderer=Yn,d.Resource=yt,d.SUPPORTS_AUDIO_CONTEXT=Qi,d.SUPPORTS_CLICK_EVENTS=wn,d.SUPPORTS_CREATE_IMAGE_BITMAP=Ji,d.SUPPORTS_IMAGE_BITMAP=_n,d.SUPPORTS_MOUSE_EVENTS=bl,d.SUPPORTS_OFFLINE_AUDIO_CONTEXT=ts,d.SUPPORTS_POINTER_EVENTS=Yt,d.SUPPORTS_RESIZE_OBSERVER=vn,d.SUPPORTS_TOUCH_EVENTS=gt,d.SUPPORTS_WEBGL2=yn,d.SUPPORTS_WEBKIT_AUDIO_CONTEXT=es,d.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=xn,d.SUPPORTS_WEB_AUDIO=Pn,d.SUPPORTS_WHEEL_EVENTS=bn,d.SceneTree=gi,d.TextLoader=il,d.Texture2D=ge,d.TextureLoader=sl,d.TextureRect2D=_i,d.Ticker=fe,d.Transform2D=et,d.UvGeometry=lc,d.UvMaterial=ir,d.Vector=Qe,d.Vector2=si,d.Vector3=Ll,d.Vector4=Wn,d.VertexAttribute=je,d.VertexBuffer=vt,d.VideoLoader=nl,d.VideoTexture=Wo,d.ViewportTexture=As,d.WebAudio=Xa,d.WebAudioContext=Dt,d.WebGLBatch2DModule=Jn,d.WebGLBlendMode=Kt,d.WebGLBufferModule=Qn,d.WebGLFramebufferModule=eo,d.WebGLMaskModule=to,d.WebGLModule=He,d.WebGLProgramModule=ro,d.WebGLRenderer=lo,d.WebGLScissorModule=io,d.WebGLState=kt,d.WebGLStateModule=Kn,d.WebGLStencilModule=so,d.WebGLTextureModule=no,d.WebGLVertexArrayModule=oo,d.WebGLViewportModule=ao,d.WebSound=Wa,d.WheelInputEvent=br,d.assets=Pt,d.clamp=at,d.createHTMLCanvas=En,d.createNode=xl,d.crossOrigin=An,d.cubicBezier=pr,d.curves=Bl,d.customNode=j,d.customNodes=ei,d.defaultOptions=al,d.defineProperty=vr,d.determineCrossOrigin=Mn,d.ease=za,d.easeIn=Va,d.easeInOut=Ga,d.easeOut=ja,d.getDeclarations=Qr,d.getDefaultCssPropertyValue=Ki,d.isCanvasElement=Tn,d.isElementNode=is,d.isImageElement=wl,d.isPow2=Zi,d.isVideoElement=Cn,d.isWebgl2=Sn,d.lerp=de,d.linear=$a,d.log2=ps,d.mapWebGLBlendModes=Zn,d.nextPow2=ds,d.nextTick=ss,d.parseCssFunctions=yr,d.parseCssProperty=mr,d.property=M,d.protectedProperty=ue,d.render=Up,d.timingFunctions=Ni,d.uid=gn,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});