modern-canvas 0.4.45 → 0.4.46
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.cjs +13 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +13 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -248,10 +248,20 @@ function defineProperty(constructor, name, declaration = {}) {
|
|
|
248
248
|
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
249
249
|
Object.defineProperty(constructor.prototype, name, {
|
|
250
250
|
get() {
|
|
251
|
-
|
|
251
|
+
let value = descriptor.get?.call(this);
|
|
252
|
+
if (value === void 0) {
|
|
253
|
+
value = getDefaultValue();
|
|
254
|
+
if (value !== void 0) {
|
|
255
|
+
descriptor.set?.call(this, value);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
252
259
|
},
|
|
253
260
|
set(value) {
|
|
254
|
-
|
|
261
|
+
let oldValue = descriptor.get?.call(this);
|
|
262
|
+
if (oldValue === void 0) {
|
|
263
|
+
oldValue = getDefaultValue();
|
|
264
|
+
}
|
|
255
265
|
descriptor.set?.call(this, value);
|
|
256
266
|
this.requestUpdate?.(name, oldValue, declaration);
|
|
257
267
|
},
|
|
@@ -6058,7 +6068,7 @@ exports.Node = class Node extends CoreObject {
|
|
|
6058
6068
|
removeChild(child) {
|
|
6059
6069
|
const index = child.getIndex();
|
|
6060
6070
|
if (this.is(child.parent) && index > -1) {
|
|
6061
|
-
this._children.
|
|
6071
|
+
this._children.getInternal(child.internalMode).splice(index, 1);
|
|
6062
6072
|
child.setParent(void 0);
|
|
6063
6073
|
this.emit("removeChild", child, index);
|
|
6064
6074
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(g=typeof globalThis<"u"?globalThis:g||self,tt(g.modernCanvas={}))})(this,function(g){"use strict";var IE=Object.defineProperty;var pE=(g,tt,Ht)=>tt in g?IE(g,tt,{enumerable:!0,configurable:!0,writable:!0,value:Ht}):g[tt]=Ht;var u=(g,tt,Ht)=>pE(g,typeof tt!="symbol"?tt+"":tt,Ht);var kA,CA;var tt=typeof document<"u"?document.currentScript:null;const Ht=Math.PI,At=Ht*2;let Gh=0;function co(r){var A;return((A=r==null?void 0:r.__SPECTOR_Object_TAG)==null?void 0:A.id)??++Gh}function ys(r){return!(r&r-1)&&!!r}const Lh=/([\w-]+)\((.+?)\)/g,Oh=/[^,]+/g,Hh=/([-e.\d]+)(.*)/;function ms(r){return Array.isArray(r)?r.map(A=>({name:A.name,args:A.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...r,normalizedIntValue:r.normalizedDefaultIntValue}}function Ei(r,A,e={}){const t=Bi(A,e);return t.length?t:go(r,A,e)}function Bi(r,A={}){const e=[];let t;for(;(t=Lh.exec(r))!==null;){const[,i,s]=t;i&&e.push({name:i,args:Jh(i,s,A)})}return e}function Jh(r,A,e={}){const t=[];let i,s=0;for(;(i=Oh.exec(A))!==null;)t.push(go(r,i[0],{...e,index:s++}));return t}function go(r,A,e={}){const{width:t=1,height:i=1,index:s=0}=e,n=A.match(Hh),o={unit:(n==null?void 0:n[2])??null,value:A,intValue:Number(n==null?void 0:n[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(r){case"scale":case"scaleX":case"scaleY":case"scale3d":o.normalizedDefaultIntValue=1;break}switch(o.unit){case"%":o.normalizedIntValue=o.intValue/100;break;case"rad":o.normalizedIntValue=o.intValue/At;break;case"deg":o.normalizedIntValue=o.intValue/360;break;case"px":switch(s){case 0:o.normalizedIntValue=o.intValue/t;break;case 1:o.normalizedIntValue=o.intValue/i;break}break;case"turn":case"em":case"rem":default:o.normalizedIntValue=o.intValue;break}return o}const uo="WebGL2RenderingContext"in globalThis,fo="ImageBitmap"in globalThis,Io="ResizeObserver"in globalThis,NA="PointerEvent"in globalThis,po="WheelEvent"in globalThis,Kh="MouseEvent"in globalThis,Jt="ontouchstart"in globalThis,Eo="onclick"in globalThis,ws="createImageBitmap"in globalThis,vs="AudioContext"in globalThis,_s="webkitAudioContext"in globalThis,bs="OfflineAudioContext"in globalThis,Bo="webkitOfflineAudioContext"in globalThis,Co=vs||_s,Ci=typeof window<"u",Ds=globalThis.devicePixelRatio||1,xs=r=>r!==null&&typeof r=="object"&&r.nodeType===1,Qo=r=>xs(r)&&r.tagName==="VIDEO",Yh=r=>xs(r)&&r.tagName==="IMG";function yo(r){return typeof r=="object"&&r!==null&&r.nodeType===1&&r.tagName==="CANVAS"}function mo(r){return uo&&r instanceof globalThis.WebGL2RenderingContext}function wo(){if(Ci)return globalThis.document.createElement("canvas")}function vo(r,A=globalThis.location){if(r.startsWith("data:"))return"";A=A||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==A.hostname||e.port!==A.port||e.protocol!==A.protocol?"anonymous":""}function _o(r,A,e){e===null&&!A.startsWith("data:")?r.crossOrigin=vo(A):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}class FA{constructor(){u(this,"_map",new WeakMap)}_toRaw(A){if(A&&typeof A=="object"){const e=A.__v_raw;e&&(A=this._toRaw(e))}return A}delete(A){return this._map.delete(this._toRaw(A))}get(A){return this._map.get(this._toRaw(A))}has(A){return this._map.has(this._toRaw(A))}set(A,e){return this._map.set(this._toRaw(A),this._toRaw(e)),this}}const bo=new FA;function or(r){let A=bo.get(r);if(!A){const e=Object.getPrototypeOf(r);A=new Map(e?or(e):void 0),bo.set(r,A)}return A}function Qi(r,A,e={}){or(r).set(A,e);const{default:t,alias:i}=e;let s=Object.getOwnPropertyDescriptor(r.prototype,A);if(!s){const o=i??Symbol.for(String(A));s={get(){return this[o]},set(a){this[o]=a}}}const n=()=>typeof t=="function"?t():t;Object.defineProperty(r.prototype,A,{get(){var o;return((o=s.get)==null?void 0:o.call(this))??n()},set(o){var l,h,c;const a=((l=s.get)==null?void 0:l.call(this))??n();(h=s.set)==null||h.call(this,o),(c=this.requestUpdate)==null||c.call(this,A,a,e)},configurable:!0,enumerable:!0})}function S(r){return function(A,e){Qi(A.constructor,e,r)}}const ar=new Map;function ne(r,A){return function(e){Object.defineProperty(e.prototype,"tag",{value:r,enumerable:!0,configurable:!0}),A&&Object.keys(A).forEach(t=>{Qi(e,t,{default:A[t]})}),ar.set(r,e)}}function Be(r){return S({...r,protected:!0})}function zh(r="node",A={}){const e=ar.get(r);if(!e)throw new Error(`Failed to createNode, tag: ${r}`);return new e().setProperties(A)}class Se{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(A,e={}){const{sort:t=0,once:i=!1}=e;this._queue[t]||(this._queue[t]=[]),this._queue[t].push({cb:A,once:i})}static off(A,e={}){const{sort:t=0}=e,i=this._queue[t];if(!i)return;const s=[];for(let n=i.length,o=0;o<n;o++){const a=i[o];a.cb!==A&&s.push(a)}s.length?this._queue[t]=s:this._queue.splice(t,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(A=>this._update(A)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(A){this._elapsed=A-this._currentTime,this._currentTime=A,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const A=this._queue,e=[];for(let t=A.length,i=t;i>=0;i--){const s=A[i];if(!s)continue;const n=[];for(let o=s.length,a=0;a<o;a++){const l=s[a];try{l.cb()}catch(h){console.warn(h)}l.once||n.push(l)}n.length&&(e[i]=n)}this._queue=e}}u(Se,"_queue",[]),u(Se,"_currentTime",0),u(Se,"_elapsed",0),u(Se,"_requestId"),Se.start();async function Ss(r){return new Promise(A=>{Se.on(()=>{r==null||r(),A()},{sort:1,once:!0})})}let Kt=class{constructor(){u(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(A){return this.eventListeners.has(A)}on(A,e,t){const i={value:e,options:t},s=this.eventListeners.get(A);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(A,[s,i]):this.eventListeners.set(A,i),this}once(A,e){return this.on(A,e,{once:!0})}off(A,e,t){var s,n;if(!e)return this.eventListeners.delete(A),this;const i=this.eventListeners.get(A);if(!i)return this;if(Array.isArray(i)){const o=[];for(let a=0,l=i.length;a<l;a++){const h=i[a];(h.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof h.options=="boolean"||!((s=h.options)!=null&&s.once)))&&o.push(h)}o.length?this.eventListeners.set(A,o.length===1?o[0]:o):this.eventListeners.delete(A)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(n=i.options)!=null&&n.once)&&this.eventListeners.delete(A);return this}emit(A,...e){var i,s;const t=this.eventListeners.get(A);if(t){if(Array.isArray(t))for(let n=t.length,o=0;o<n;o++){const a=t[o];typeof a.options=="object"&&((i=a.options)!=null&&i.once)&&this.off(A,a.value,a.options),a.value.apply(this,e)}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(A,t.value,t.options),t.value.apply(this,e);return!0}else return!1}},Wh=0;class rA extends Kt{constructor(){super(...arguments);u(this,"instanceId",++Wh);u(this,"_defaultProperties");u(this,"_updatedProperties",new Map);u(this,"_changedProperties",new Set);u(this,"_updatingPromise",Promise.resolve());u(this,"_updating",!1)}is(e){return!!(e&&this.instanceId===e.instanceId)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await Ss(),this._updating&&(this.update(),this._updating=!1)}update(){this._update(this._updatedProperties),this._updatedProperties=new Map}_update(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return or(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]=typeof t.default=="function"?t.default():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&&typeof e=="object")for(const[t]of this.getPropertyDeclarations())t in e&&this.setProperty(t,e[t]);return this}resetProperties(){for(const[e,t]of this.getPropertyDeclarations())this.setProperty(e,t.default);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(){const e={},t=this.getProperties(Array.from(this._changedProperties));for(const i in t){const s=t[i];s&&typeof s=="object"?"toJSON"in s&&typeof s.toJSON=="function"?e[i]=s.toJSON():e[i]={...s}:e[i]=s}return e}clone(){return new this.constructor(this.toJSON())}free(){this.removeAllListeners()}}class Do extends rA{}class lr{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",lr.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(...A){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...A){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 Ms extends lr{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 xo extends Ms{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 yi extends Ms{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(yi,"DOM_DELTA_PIXEL",0),u(yi,"DOM_DELTA_LINE",1),u(yi,"DOM_DELTA_PAGE",2);const Vh={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class So extends Kt{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(Jt&&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||Jt&&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||Jt&&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||Jt&&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 n=0,o=s.length;n<o;n++){const a=this.clonePointerEvent(s[n]);a.type+=i,this.emit("pointerup",this.event=a)}});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=""):NA&&(e.touchAction=""),NA?(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)),Jt&&(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"):NA&&(e.touchAction="none")),NA?(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)),Jt&&(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(Jt&&e instanceof globalThis.TouchEvent)for(let i=0,s=e.changedTouches.length;i<s;i++){const n=e.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(po&&e instanceof globalThis.WheelEvent)t.push(e);else if(NA&&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 yi;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 xo;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=Vh[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,n=Number(this.target.getAttribute("height"))||0,o=Number(this.target.getAttribute("data-pixel-ratio"))||1,a=this.target.isConnected?this.target.getBoundingClientRect():{width:s,height:n,left:0,top:0},l=1/o;e.x=(t-a.left)*(s/a.width)*l,e.y=(i-a.top)*(n/a.height)*l}}class Yt extends Do{}var qh={grad:.9,turn:360,rad:360/(2*Math.PI)},zt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Ue=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=Math.pow(10,A)),Math.round(e*r)/e+0},pt=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=1),r>e?e:r>A?r:A},Mo=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Ro=function(r){return{r:pt(r.r,0,255),g:pt(r.g,0,255),b:pt(r.b,0,255),a:pt(r.a)}},Rs=function(r){return{r:Ue(r.r),g:Ue(r.g),b:Ue(r.b),a:Ue(r.a,3)}},Xh=/^#([0-9a-f]{3,8})$/i,hr=function(r){var A=r.toString(16);return A.length<2?"0"+A:A},Po=function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=Math.max(A,e,t),n=s-Math.min(A,e,t),o=n?s===A?(e-t)/n:s===e?2+(t-A)/n:4+(A-e)/n:0;return{h:60*(o<0?o+6:o),s:s?n/s*100:0,v:s/255*100,a:i}},ko=function(r){var A=r.h,e=r.s,t=r.v,i=r.a;A=A/360*6,e/=100,t/=100;var s=Math.floor(A),n=t*(1-e),o=t*(1-(A-s)*e),a=t*(1-(1-A+s)*e),l=s%6;return{r:255*[t,o,n,n,a,t][l],g:255*[a,t,t,o,n,n][l],b:255*[n,n,a,t,t,o][l],a:i}},Uo=function(r){return{h:Mo(r.h),s:pt(r.s,0,100),l:pt(r.l,0,100),a:pt(r.a)}},No=function(r){return{h:Ue(r.h),s:Ue(r.s),l:Ue(r.l),a:Ue(r.a,3)}},Fo=function(r){return ko((e=(A=r).s,{h:A.h,s:(e*=((t=A.l)<50?t:100-t)/100)>0?2*e/(t+e)*100:0,v:t+e,a:A.a}));var A,e,t},mi=function(r){return{h:(A=Po(r)).h,s:(i=(200-(e=A.s))*(t=A.v)/100)>0&&i<200?e*t/100/(i<=100?i:200-i)*100:0,l:i/2,a:A.a};var A,e,t,i},jh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$h=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ec=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ps={string:[[function(r){var A=Xh.exec(r);return A?(r=A[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Ue(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Ue(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var A=$h.exec(r)||ec.exec(r);return A?A[2]!==A[4]||A[4]!==A[6]?null:Ro({r:Number(A[1])/(A[2]?100/255:1),g:Number(A[3])/(A[4]?100/255:1),b:Number(A[5])/(A[6]?100/255:1),a:A[7]===void 0?1:Number(A[7])/(A[8]?100:1)}):null},"rgb"],[function(r){var A=jh.exec(r)||Zh.exec(r);if(!A)return null;var e,t,i=Uo({h:(e=A[1],t=A[2],t===void 0&&(t="deg"),Number(e)*(qh[t]||1)),s:Number(A[3]),l:Number(A[4]),a:A[5]===void 0?1:Number(A[5])/(A[6]?100:1)});return Fo(i)},"hsl"]],object:[[function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=i===void 0?1:i;return zt(A)&&zt(e)&&zt(t)?Ro({r:Number(A),g:Number(e),b:Number(t),a:Number(s)}):null},"rgb"],[function(r){var A=r.h,e=r.s,t=r.l,i=r.a,s=i===void 0?1:i;if(!zt(A)||!zt(e)||!zt(t))return null;var n=Uo({h:Number(A),s:Number(e),l:Number(t),a:Number(s)});return Fo(n)},"hsl"],[function(r){var A=r.h,e=r.s,t=r.v,i=r.a,s=i===void 0?1:i;if(!zt(A)||!zt(e)||!zt(t))return null;var n=function(o){return{h:Mo(o.h),s:pt(o.s,0,100),v:pt(o.v,0,100),a:pt(o.a)}}({h:Number(A),s:Number(e),v:Number(t),a:Number(s)});return ko(n)},"hsv"]]},To=function(r,A){for(var e=0;e<A.length;e++){var t=A[e][0](r);if(t)return[t,A[e][1]]}return[null,void 0]},tc=function(r){return typeof r=="string"?To(r.trim(),Ps.string):typeof r=="object"&&r!==null?To(r,Ps.object):[null,void 0]},ks=function(r,A){var e=mi(r);return{h:e.h,s:pt(e.s+100*A,0,100),l:e.l,a:e.a}},Us=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Go=function(r,A){var e=mi(r);return{h:e.h,s:e.s,l:pt(e.l+100*A,0,100),a:e.a}},Ns=function(){function r(A){this.parsed=tc(A)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Ue(Us(this.rgba),2)},r.prototype.isDark=function(){return Us(this.rgba)<.5},r.prototype.isLight=function(){return Us(this.rgba)>=.5},r.prototype.toHex=function(){return A=Rs(this.rgba),e=A.r,t=A.g,i=A.b,n=(s=A.a)<1?hr(Ue(255*s)):"","#"+hr(e)+hr(t)+hr(i)+n;var A,e,t,i,s,n},r.prototype.toRgb=function(){return Rs(this.rgba)},r.prototype.toRgbString=function(){return A=Rs(this.rgba),e=A.r,t=A.g,i=A.b,(s=A.a)<1?"rgba("+e+", "+t+", "+i+", "+s+")":"rgb("+e+", "+t+", "+i+")";var A,e,t,i,s},r.prototype.toHsl=function(){return No(mi(this.rgba))},r.prototype.toHslString=function(){return A=No(mi(this.rgba)),e=A.h,t=A.s,i=A.l,(s=A.a)<1?"hsla("+e+", "+t+"%, "+i+"%, "+s+")":"hsl("+e+", "+t+"%, "+i+"%)";var A,e,t,i,s},r.prototype.toHsv=function(){return A=Po(this.rgba),{h:Ue(A.h),s:Ue(A.s),v:Ue(A.v),a:Ue(A.a,3)};var A},r.prototype.invert=function(){return xt({r:255-(A=this.rgba).r,g:255-A.g,b:255-A.b,a:A.a});var A},r.prototype.saturate=function(A){return A===void 0&&(A=.1),xt(ks(this.rgba,A))},r.prototype.desaturate=function(A){return A===void 0&&(A=.1),xt(ks(this.rgba,-A))},r.prototype.grayscale=function(){return xt(ks(this.rgba,-1))},r.prototype.lighten=function(A){return A===void 0&&(A=.1),xt(Go(this.rgba,A))},r.prototype.darken=function(A){return A===void 0&&(A=.1),xt(Go(this.rgba,-A))},r.prototype.rotate=function(A){return A===void 0&&(A=15),this.hue(this.hue()+A)},r.prototype.alpha=function(A){return typeof A=="number"?xt({r:(e=this.rgba).r,g:e.g,b:e.b,a:A}):Ue(this.rgba.a,3);var e},r.prototype.hue=function(A){var e=mi(this.rgba);return typeof A=="number"?xt({h:A,s:e.s,l:e.l,a:e.a}):Ue(e.h)},r.prototype.isEqual=function(A){return this.toHex()===xt(A).toHex()},r}(),xt=function(r){return r instanceof Ns?r:new Ns(r)},Lo=[],Ac=function(r){r.forEach(function(A){Lo.indexOf(A)<0&&(A(Ns,Ps),Lo.push(A))})};function ic(r,A){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={};r.prototype.toName=function(n){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,a,l=t[this.toHex()];if(l)return l;if(n!=null&&n.closest){var h=this.toRgb(),c=1/0,f="black";if(!s.length)for(var I in e)s[I]=new r(e[I]).toRgb();for(var d in e){var C=(o=h,a=s[d],Math.pow(o.r-a.r,2)+Math.pow(o.g-a.g,2)+Math.pow(o.b-a.b,2));C<c&&(c=C,f=d)}return f}},A.string.push([function(n){var o=n.toLowerCase(),a=o==="transparent"?"#0000":e[o];return a?new r(a).toRgb():null},"name"])}function he(r){return r==null||r==="none"}function TA(r,A=0,e=10**A){return Math.round(e*r)/e+0}function Fs(r,A=!1){if(typeof r!="object"||!r)return r;if(Array.isArray(r))return A?r.map(t=>Fs(t,A)):r;const e={};for(const t in r){const i=r[t];i!=null&&(A?e[t]=Fs(i,A):e[t]=i)}return e}function Ts(r,A){const e={};return A.forEach(t=>{t in r&&(e[t]=r[t])}),e}function Gs(r){let A;return typeof r=="number"?A={r:r>>24&255,g:r>>16&255,b:r>>8&255,a:(r&255)/255}:A=r,xt(A)}function rc(r){return{r:TA(r.r),g:TA(r.g),b:TA(r.b),a:TA(r.a,3)}}function cr(r){const A=r.toString(16);return A.length<2?`0${A}`:A}const Oo="#000000FF";function sc(r){return Gs(r).isValid()}function ht(r,A=!1){const e=Gs(r);if(!e.isValid()){if(typeof r=="string")return r;const o=`Failed to normalizeColor ${r}`;if(A)throw new Error(o);return console.warn(o),Oo}const{r:t,g:i,b:s,a:n}=rc(e.rgba);return`#${cr(t)}${cr(i)}${cr(s)}${cr(TA(n*255))}`}var gr=gr||{};gr.parse=function(){const r={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let A="";function e(N){const U=new Error(`${A}: ${N}`);throw U.source=A,U}function t(){const N=i();return A.length>0&&e("Invalid input not EOF"),N}function i(){return w(s)}function s(){return n("linear-gradient",r.linearGradient,a)||n("repeating-linear-gradient",r.repeatingLinearGradient,a)||n("radial-gradient",r.radialGradient,c)||n("repeating-radial-gradient",r.repeatingRadialGradient,c)}function n(N,U,X){return o(U,ee=>{const oe=X();return oe&&(J(r.comma)||e("Missing comma before color stops")),{type:N,orientation:oe,colorStops:w(R)}})}function o(N,U){const X=J(N);if(X){J(r.startCall)||e("Missing (");const ee=U(X);return J(r.endCall)||e("Missing )"),ee}}function a(){const N=l();if(N)return N;const U=ie("position-keyword",r.positionKeywords,1);return U?{type:"directional",value:U.value}:h()}function l(){return ie("directional",r.sideOrCorner,1)}function h(){return ie("angular",r.angleValue,1)||ie("angular",r.radianValue,1)}function c(){let N,U=f(),X;return U&&(N=[],N.push(U),X=A,J(r.comma)&&(U=f(),U?N.push(U):A=X)),N}function f(){let N=I()||d();if(N)N.at=p();else{const U=C();if(U){N=U;const X=p();X&&(N.at=X)}else{const X=p();if(X)N={type:"default-radial",at:X};else{const ee=M();ee&&(N={type:"default-radial",at:ee})}}}return N}function I(){const N=ie("shape",/^(circle)/i,0);return N&&(N.style=q()||C()),N}function d(){const N=ie("shape",/^(ellipse)/i,0);return N&&(N.style=M()||L()||C()),N}function C(){return ie("extent-keyword",r.extentKeywords,1)}function p(){if(ie("position",/^at/,0)){const N=M();return N||e("Missing positioning value"),N}}function M(){const N=P();if(N.x||N.y)return{type:"position",value:N}}function P(){return{x:L(),y:L()}}function w(N){let U=N();const X=[];if(U)for(X.push(U);J(r.comma);)U=N(),U?X.push(U):e("One extra comma");return X}function R(){const N=_();return N||e("Expected color definition"),N.length=L(),N}function _(){return b()||K()||V()||z()||D()||Ae()||m()}function m(){return ie("literal",r.literalColor,0)}function b(){return ie("hex",r.hexColor,1)}function D(){return o(r.rgbColor,()=>({type:"rgb",value:w(W)}))}function z(){return o(r.rgbaColor,()=>({type:"rgba",value:w(W)}))}function Ae(){return o(r.varColor,()=>({type:"var",value:te()}))}function V(){return o(r.hslColor,()=>{J(r.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const U=W();J(r.comma);let X=J(r.percentageValue);const ee=X?X[1]:null;J(r.comma),X=J(r.percentageValue);const oe=X?X[1]:null;return(!ee||!oe)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[U,ee,oe]}})}function K(){return o(r.hslaColor,()=>{const N=W();J(r.comma);let U=J(r.percentageValue);const X=U?U[1]:null;J(r.comma),U=J(r.percentageValue);const ee=U?U[1]:null;J(r.comma);const oe=W();return(!X||!ee)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[N,X,ee,oe]}})}function te(){return J(r.variableName)[1]}function W(){return J(r.number)[1]}function L(){return ie("%",r.percentageValue,1)||se()||H()||q()}function se(){return ie("position-keyword",r.positionKeywords,1)}function H(){return o(r.calcValue,()=>{let N=1,U=0;for(;N>0&&U<A.length;){const ee=A.charAt(U);ee==="("?N++:ee===")"&&N--,U++}N>0&&e("Missing closing parenthesis in calc() expression");const X=A.substring(0,U-1);return $(U-1),{type:"calc",value:X}})}function q(){return ie("px",r.pixelValue,1)||ie("em",r.emValue,1)}function ie(N,U,X){const ee=J(U);if(ee)return{type:N,value:ee[X]}}function J(N){let U,X;return X=/^\s+/.exec(A),X&&$(X[0].length),U=N.exec(A),U&&$(U[0].length),U}function $(N){A=A.substr(N)}return function(N){return A=N.toString().trim(),A.endsWith(";")&&(A=A.slice(0,-1)),t()}}();const nc=gr.parse.bind(gr);var ur=ur||{};ur.stringify=function(){var r={"visit_linear-gradient":function(A){return r.visit_gradient(A)},"visit_repeating-linear-gradient":function(A){return r.visit_gradient(A)},"visit_radial-gradient":function(A){return r.visit_gradient(A)},"visit_repeating-radial-gradient":function(A){return r.visit_gradient(A)},visit_gradient:function(A){var e=r.visit(A.orientation);return e&&(e+=", "),A.type+"("+e+r.visit(A.colorStops)+")"},visit_shape:function(A){var e=A.value,t=r.visit(A.at),i=r.visit(A.style);return i&&(e+=" "+i),t&&(e+=" at "+t),e},"visit_default-radial":function(A){var e="",t=r.visit(A.at);return t&&(e+=t),e},"visit_extent-keyword":function(A){var e=A.value,t=r.visit(A.at);return t&&(e+=" at "+t),e},"visit_position-keyword":function(A){return A.value},visit_position:function(A){return r.visit(A.value.x)+" "+r.visit(A.value.y)},"visit_%":function(A){return A.value+"%"},visit_em:function(A){return A.value+"em"},visit_px:function(A){return A.value+"px"},visit_calc:function(A){return"calc("+A.value+")"},visit_literal:function(A){return r.visit_color(A.value,A)},visit_hex:function(A){return r.visit_color("#"+A.value,A)},visit_rgb:function(A){return r.visit_color("rgb("+A.value.join(", ")+")",A)},visit_rgba:function(A){return r.visit_color("rgba("+A.value.join(", ")+")",A)},visit_hsl:function(A){return r.visit_color("hsl("+A.value[0]+", "+A.value[1]+"%, "+A.value[2]+"%)",A)},visit_hsla:function(A){return r.visit_color("hsla("+A.value[0]+", "+A.value[1]+"%, "+A.value[2]+"%, "+A.value[3]+")",A)},visit_var:function(A){return r.visit_color("var("+A.value+")",A)},visit_color:function(A,e){var t=A,i=r.visit(e.length);return i&&(t+=" "+i),t},visit_angular:function(A){return A.value+"deg"},visit_directional:function(A){return"to "+A.value},visit_array:function(A){var e="",t=A.length;return A.forEach(function(i,s){e+=r.visit(i),s<t-1&&(e+=", ")}),e},visit_object:function(A){return A.width&&A.height?r.visit(A.width)+" "+r.visit(A.height):""},visit:function(A){if(!A)return"";if(A instanceof Array)return r.visit_array(A);if(typeof A=="object"&&!A.type)return r.visit_object(A);if(A.type){var e=r["visit_"+A.type];if(e)return e(A);throw Error("Missing visitor visit_"+A.type)}else throw Error("Invalid node.")}};return function(A){return r.visit(A)}}(),ur.stringify.bind(ur);function Ho(r){const A=r.length-1;return r.map((e,t)=>{var o;const i=e.value;let s=TA(t/A,3),n="#00000000";switch(e.type){case"rgb":n=ht({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":n=ht({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":n=ht(e.value);break;case"hex":n=ht(`#${e.value}`);break}switch((o=e.length)==null?void 0:o.type){case"%":s=Number(e.length.value)/100;break}return{offset:s,color:n}})}function Jo(r){var e;let A=0;switch((e=r.orientation)==null?void 0:e.type){case"angular":A=Number(r.orientation.value);break}return{type:"linear-gradient",angle:A,stops:Ho(r.colorStops)}}function Ko(r){var A;return(A=r.orientation)==null||A.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Ho(r.colorStops)}}function wi(r){return r.startsWith("linear-gradient(")||r.startsWith("radial-gradient(")}function oc(r){return nc(r).map(A=>{switch(A==null?void 0:A.type){case"linear-gradient":return Jo(A);case"repeating-linear-gradient":return{...Jo(A),repeat:!0};case"radial-gradient":return Ko(A);case"repeating-radial-gradient":return{...Ko(A),repeat:!0};default:return}}).filter(Boolean)}function ac(r){let A;return typeof r=="string"?A={color:r}:A=r,{color:ht(A.color)}}function lc(r){let A;if(typeof r=="string"?A={image:r}:A=r,A.image){const{type:e,...t}=oc(A.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:t};case"linear-gradient":return{linearGradient:t}}}return A}function hc(r){let A;return typeof r=="string"?A={image:r}:A=r,A}function cc(r){let A;return typeof r=="string"?A={preset:r}:A=r,{preset:A.preset,foregroundColor:he(A.foregroundColor)?void 0:ht(A.foregroundColor),backgroundColor:he(A.backgroundColor)?void 0:ht(A.backgroundColor)}}function gc(r){return!he(r.color)}function uc(r){return typeof r=="string"?sc(r):gc(r)}function fc(r){return!he(r.image)&&wi(r.image)||!!r.linearGradient||!!r.radialGradient}function dc(r){return typeof r=="string"?wi(r):fc(r)}function Ic(r){return!he(r.image)&&!wi(r.image)}function pc(r){return typeof r=="string"?!wi(r):Ic(r)}function Ec(r){return!he(r.preset)}function Bc(r){return typeof r=="string"?!1:Ec(r)}function mA(r){return uc(r)?ac(r):dc(r)?lc(r):pc(r)?hc(r):Bc(r)?cc(r):{}}function Cc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["fillWithShape"])}}function Qc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["fillWithShape"])}}function yc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["width","style","headEnd","tailEnd"])}}function mc(r){return typeof r=="string"?{color:ht(r)}:{...r,color:he(r.color)?Oo:ht(r.color)}}function wc(){return{boxShadow:"none"}}function vc(r){return typeof r=="string"?r.startsWith("<svg")?{svg:r}:{paths:[{data:r}]}:Array.isArray(r)?{paths:r.map(A=>typeof A=="string"?{data:A}:A)}:r}function _c(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function bc(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Dc(){return{..._c(),...bc(),...wc(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function xc(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Sc(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Mc(){return{...xc(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Rc(){return{...Sc(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function Pc(){return{...Rc(),...Mc(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function fr(r){return Fs({...r,color:he(r.color)?void 0:ht(r.color),backgroundColor:he(r.backgroundColor)?void 0:ht(r.backgroundColor),borderColor:he(r.borderColor)?void 0:ht(r.borderColor),outlineColor:he(r.outlineColor)?void 0:ht(r.outlineColor),shadowColor:he(r.shadowColor)?void 0:ht(r.shadowColor)})}function Yo(){return{...Dc(),...Pc()}}function zo(r=""){return(Array.isArray(r)?r:[r]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[fr(e)]}:"fragments"in e?{...fr(e),fragments:e.fragments.map(t=>fr(t))}:Array.isArray(e)?{fragments:e.map(t=>typeof t=="string"?{content:t}:fr(t))}:{fragments:[]})}function kc(r){return typeof r=="string"?{content:[{fragments:[{content:r}]}]}:"content"in r?{...r,content:zo(r.content)}:{content:zo(r)}}Ac([ic]);class Wt{get value(){return this._value}set value(A){this._colord=Gs(A??"none")}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(A=0){this.value=A}toHex(){return this._colord.toHex()}toRgb(){return this._colord.toRgb()}toRgbString(){return this._colord.toRgbString()}toHsl(){return this._colord.toHsl()}toHslString(){return this._colord.toHslString()}toHsv(){return this._colord.toHsv()}toArgb(A=this.a,e=!0){if(A===1)return(255<<24)+this.rgb;if(A===0)return e?0:this.rgb;let t=this.r8,i=this.g8,s=this.b8;return e&&(t=t*A+.5|0,i=i*A+.5|0,s=s*A+.5|0),(A*255<<24)+(t<<16)+(i<<8)+s}toArray(){return[this.r,this.g,this.b,this.a]}}class mt extends Kt{constructor(e){super();u(this,"_array",[]);this.dim=e}get length(){return this.dim}_operate(e,t,i){const{dim:s,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:s},()=>t):t instanceof St||t instanceof mt?o=t.toArray():o=t;let a,l=[];if(i?i instanceof mt?a=i:l=i:a=this,t instanceof St){const{cols:h}=t;switch(e){case"*":for(let c=0;c<s;c++){let f=0;for(let I=0;I<s;I++)f+=n[c]*o[I*h+c];l[c]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let h=0;h<s;h++)l[h]=n[h]+o[h];break;case"-":for(let h=0;h<s;h++)l[h]=n[h]-o[h];break;case"*":for(let h=0;h<s;h++)l[h]=n[h]*o[h];break;case"/":for(let h=0;h<s;h++)l[h]=n[h]/o[h];break;case"rot":{const h=Math.cos(o[0]),c=Math.sin(o[0]);l[0]=n[0]*h-n[1]*c,l[1]=n[1]*h+n[0]*c;break}case"==":{let h=!0;for(let c=0;c<s;c++)h=h&&n[c]===o[c];return h}case"=":for(let h=0;h<s;h++){const c=o[h];c!==void 0&&(n[h]=c)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(a==null?void 0:a.set(l))??l}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)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class St extends Kt{constructor(e,t,i){super();u(this,"_array",[]);u(this,"dirtyId",0);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:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof mt||t instanceof St?l=t.toArray():l=t;let h,c=[];if(i?i instanceof mt||i instanceof St?h=i:c=i:t instanceof mt?h=new t.constructor:h=this,t instanceof mt){const{dim:f}=t;switch(e){case"*":for(let I=0;I<f;I++){let d=0;for(let C=0;C<s;C++)C<f&&(d+=a[I*s+C]*(l[C]??0));c[I]=d}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<s;f++)for(let I=0;I<n;I++){const d=I*s;let C=0;for(let p=0;p<n;p++){const M=d+p,P=p*s+f;C+=a[M]*(l[P]??0)}c[d+f]=C}break;case"=":for(let f=0;f<o;f++){const I=l[f];I!==void 0&&(a[f]=I)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return(h==null?void 0:h.set(c))??c}identity(){const{cols:e,rows:t}=this,i=[];for(let s=0;s<e;s++)for(let n=0;n<t;n++){const o=n*e,a=s+o;i[a]=n+o===a?1:0}return this.set(i)}set(e){return this._operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this._operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:i,_array:s}=this;if(e){const n=[];for(let o=0;o<i;o++)for(let a=0;a<t;a++)n[o+a*t]=s[a+o*t];return n}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}class Wo extends St{constructor(A){super(4,4,A)}}const Vo=Ht/180,Uc=180/Ht;function Vt(r,A,e){return Math.max(r,Math.min(A,e))}function Me(r,A,e){return(1-e)*r+e*A}const Nc={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,A=20){if(!this.adaptive||!r||Number.isNaN(r))return A;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class qo extends mt{constructor(A=0,e=0,t=0,i=0){super(4),this.set([A,e,t,i])}}class Ls extends St{constructor(A){super(4,5,A)}hueRotate(A=0){const e=Math.sin(A),t=Math.cos(A),i=.213,s=.715,n=.072;return this.multiply([i+t*(1-i)+e*-.213,s+t*-.715+e*-.715,n+t*-.072+e*(1-n),0,0,i+t*-.213+e*.143,s+t*(1-s)+e*.14,n+t*-.072+e*-.283,0,0,i+t*-.213+e*-.787,s+t*-.715+e*s,n+t*(1-n)+e*n,0,0,0,0,0,1,0])}saturate(A=1){const e=(A-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(A=1){const e=A;return this.multiply([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])}contrast(A=1){const e=A,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(A=1){const e=Me(1,-1,A),t=Me(0,255,A);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}sepia(A=1){const e=Vt(0,A,1);return this.multiply([Me(1,.393,e),Me(0,.7689999,e),Me(0,.18899999,e),0,0,Me(0,.349,e),Me(1,.6859999,e),Me(0,.16799999,e),0,0,Me(0,.272,e),Me(0,.5339999,e),Me(1,.13099999,e),0,0,0,0,0,1,0])}opacity(A=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,A,0])}grayscale(A=1){const e=Vt(0,A,1),t=Me(1,.3,e),i=Me(0,.3,e),s=Me(1,.59,e),n=Me(0,.59,e),o=Me(1,.11,e),a=Me(0,.11,e);return this.multiply([t,n,a,0,0,i,s,a,0,0,i,n,o,0,0,0,0,0,1,0])}multiply(A){const e=A,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 A=this._array;return new Wo([A[0],A[1],A[2],A[3],A[5],A[6],A[7],A[8],A[10],A[11],A[12],A[13],A[15],A[16],A[17],A[18]])}toVector4(){const A=this._array;return new qo(A[4]/255,A[9]/255,A[14]/255,A[19]/255)}}class Fc extends St{constructor(A){super(2,2,A)}}let Os=class extends St{constructor(A){super(3,3,A)}invert(){const[A,e,t,i,s,n,o,a,l]=this._array,h=l*s-n*a,c=n*o-l*i,f=a*i-s*o,I=A*h+e*c+t*f;if(I===0)return this.set([0,0,0,0,0,0,0,0,0]);const d=1/I;return this.set([h*d,(t*a-l*e)*d,(n*e-t*s)*d,c*d,(l*A-t*o)*d,(t*i-n*A)*d,f*d,(e*o-a*A)*d,(s*A-e*i)*d])}};class Xo extends Os{constructor(A=0,e=0,t=0,i=0,s=!1){super(),this._x=A,this._y=e,this._width=t,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(A){return this._flipY!==A&&(this._flipY=A,this._performUpdateArray()),this}translate(A,e){return(this._x!==A||this._y!==e)&&(this._x=A,this._y=e,this._performUpdateArray()),this}resize(A,e){return(this._width!==A||this._height!==e)&&(this._width=A,this._height=e,this._performUpdateArray()),this}_performUpdateArray(){const A=this._width,e=this._height;if(!A||!e)return;const t=this._x,i=this._y,s=this._flipY?-1:1,n=1/A*2,o=s*(1/e*2),a=-1-t*n,l=-s-i*o;this.set([n,0,a,0,o,l,0,0,1])}}let wt=class Qs extends mt{get x(){return this._array[0]}set x(A){const[e,t]=this._array;e!==A&&this.set(A,t)}get y(){return this._array[1]}set y(A){const[e,t]=this._array;t!==A&&this.set(e,A)}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}get left(){return this.x}set left(A){this.x=A}get top(){return this.y}set top(A){this.y=A}constructor(A=0,e){super(2),this.set(typeof A=="number"?[A,e??A]:A)}update(A,e){const[t,i]=this._array;return(t!==A||i!==e)&&this.set(A,e),this}getLength(){const[A,e]=this._array;return Math.sqrt(A*A+e*e)}getAngle(){const[A,e]=this._array;return Math.atan2(-A,-e)+Math.PI}distanceTo(A){return Math.hypot(A.x-this.x,A.y-this.y)}normalize(){const[A,e]=this._array,t=1/(this.getLength()||1);return this.set(A*t,e*t),this}static lerp(A,e,t){return new Qs(e).clone().sub(new Qs(A)).multiply(t).add(new Qs(A))}};class Hs{constructor(...A){u(this,"end",new wt);u(this,"position");u(this,"size");const e=new wt,t=new wt;switch(A.length){case 0:break;case 1:e.set(A[0].position),t.set(A[0].size);break;case 2:e.set(A[0]),t.set(A[1]);break;default:e.set(A[0],A[1]),t.set(A[2],A[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]}}const BA=class BA extends Os{premultiply(A){return A.multiply(this,this)}skewX(A){return this.skew(A,0)}skewY(A){return this.skew(0,A)}skew(A,e){return this.premultiply(BA._t2d.makeSkew(A,e))}makeSkew(A,e){const t=Math.tan(A),i=Math.tan(e);return this.set([1,i,0,t,1,0,0,0,1]),this}translateX(A){return this.translate(A,0)}translateY(A){return this.translate(0,A)}translateZ(A){return this.translate(0,0,A)}translate3d(A,e,t){return this.translate(A,e,t)}translate(A,e,t=0){return this.premultiply(BA._t2d.makeTranslation(A,e,t))}makeTranslation(A,e,t=0){return this.set([1,0,A,0,1,e,0,0,1]),this}scaleX(A){return this.scale(A,1)}scaleY(A){return this.scale(1,A)}scale3d(A,e,t=1){return this.scale(A,e,t)}scale(A,e,t=1){return this.premultiply(BA._t2d.makeScale(A,e,t))}makeScale(A,e,t=1){return this.set([A,0,0,0,e,0,0,0,1]),this}rotateX(A){return this.scaleY(this._rotateToScale(A))}rotateY(A){return this.scaleX(this._rotateToScale(A))}rotateZ(A){return this.rotate(A)}rotate(A){return this.premultiply(BA._t2d.makeRotation(A))}rotate3d(A,e,t,i){const[s,n,o]=this._rotate3d(A,e,t,i);return s&&this.rotateX(s),n&&this.rotateY(n),o&&this.rotateZ(o),this}_rotateToScale(A){const e=A/At;return e<=.5?e*-4+1:(e-1)*4+1}_rotate3d(A,e,t,i){if(A===1&&e===0&&t===0)return[i,0,0];if(A===0&&e===1&&t===0)return[0,i,0];if(A===0&&e===0)return[0,0,i];{const s=Math.cos(i),n=Math.sin(i),o=s+A*A*(1-s),a=A*e*(1-s)-t*n,l=A*t*(1-s)+e*n,h=s+e*e*(1-s),c=e*t*(1-s)-A*n,f=s+t*t*(1-s),I=-Math.atan2(-c,h),d=-Math.atan2(l,Math.sqrt(c*c+f*f)),C=-Math.atan2(-a,o);return[I,d,C]}}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set([e,-t,0,t,e,0,0,0,1]),this}applyToPoint(A,e){const{a:t,c:i,tx:s,b:n,d:o,ty:a}=this.toObject();return[t*A+i*e+s,n*A+o*e+a]}inverse(){return this.clone().invert()}isIdentity(){const{a:A,b:e,c:t,d:i,tx:s,ty:n}=this.toObject();return A===1&&e===0&&t===0&&i===1&&s===0&&n===0}toObject(){const[A,e,t,i,s,n,,,o]=this._array;return{a:A,c:e,tx:t,b:i,d:s,ty:n,tz:o}}};u(BA,"_t2d",new BA);let Et=BA;class Tc extends mt{constructor(){super(3)}}var Gc=Object.defineProperty,jo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Gc(A,e,i),i};class dr extends rA{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){this._starting||(this._starting=!0,this.off("process"),this.on("process",e),Se.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,Se.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=Se.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}free(){super.free(),this.stop()}}jo([S({default:24})],dr.prototype,"fps"),jo([S({default:1})],dr.prototype,"speed");class Zo{constructor(){u(this,"view");u(this,"pixelRatio",Ds);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new FA)}getRelated(A,e){let t=this.related.get(A);return t||(e?(this.related.set(A,t=e()),t):(console.warn("Failed to get related",A),null))}resize(A,e,t=!0){this.view&&(this.view.width=Math.floor(A*this.pixelRatio),this.view.height=Math.floor(e*this.pixelRatio)),this.screen.width=A,this.screen.height=e,t&&this.view&&(this.view.style.width=`${A}px`,this.view.style.height=`${e}px`)}}var GA=(r=>(r.NORMAL="normal",r.ADD="add",r.MULTIPLY="multiply",r.SCREEN="screen",r.NONE="none",r.NORMAL_NPM="normal_npm",r.ADD_NPM="add_npm",r.SCREEN_NPM="screen_npm",r.SRC_IN="src_in",r.SRC_OUT="src_out",r.SRC_ATOP="src_atop",r.DST_OVER="dst_over",r.DST_IN="dst_in",r.DST_OUT="dst_out",r.DST_ATOP="dst_atop",r.XOR="xor",r.SUBTRACT="subtract",r))(GA||{});function $o(r){return{normal:[r.ONE,r.ONE_MINUS_SRC_ALPHA],add:[r.ONE,r.ONE],multiply:[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],screen:[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],add_npm:[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],screen_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],src_in:[r.DST_ALPHA,r.ZERO],src_out:[r.ONE_MINUS_DST_ALPHA,r.ZERO],src_atop:[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],dst_over:[r.ONE_MINUS_DST_ALPHA,r.ONE],dst_in:[r.ZERO,r.SRC_ALPHA],dst_out:[r.ZERO,r.ONE_MINUS_SRC_ALPHA],dst_atop:[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],xor:[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],subtract:[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD]}}class Bt{get gl(){return this._renderer.gl}install(A){this._renderer=A}onUpdateContext(){}flush(){}reset(){}free(){}}const ss=class ss{constructor(A){u(this,"_blendMode",GA.NORMAL);u(this,"_polygonOffset",0);u(this,"bitmap",0);if(A)for(const e in A)this[e]=A[e]}static _init(){this._properties.forEach((A,e)=>{Object.defineProperty(this.prototype,A,{get(){return!!(this.bitmap&1<<e)},set(t){!!(this.bitmap&1<<e)!==t&&(this.bitmap^=1<<e)},enumerable:!0,configurable:!0})})}static for2D(){const A=new ss;return A.depthTest=!1,A.blend=!0,A}get blendMode(){return this._blendMode}set blendMode(A){this.blend=A!==GA.NONE,this._blendMode=A}get polygonOffset(){return this._polygonOffset}set polygonOffset(A){this.offsets=!!A,this._polygonOffset=A}};u(ss,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let wA=ss;wA._init();class ea extends Bt{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",wA._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 wA({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=$o(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(GA.NORMAL)}}class ta extends Bt{constructor(){super(...arguments);u(this,"_state",wA.for2D());u(this,"_batchSize",4096*4);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"},aDisableWrapMode:{size:4,normalized:!0,type:"float"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}});u(this,"_vertexSize",31)}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(g,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(g=typeof globalThis<"u"?globalThis:g||self,tt(g.modernCanvas={}))})(this,function(g){"use strict";var IE=Object.defineProperty;var pE=(g,tt,Ht)=>tt in g?IE(g,tt,{enumerable:!0,configurable:!0,writable:!0,value:Ht}):g[tt]=Ht;var u=(g,tt,Ht)=>pE(g,typeof tt!="symbol"?tt+"":tt,Ht);var kA,CA;var tt=typeof document<"u"?document.currentScript:null;const Ht=Math.PI,At=Ht*2;let Gh=0;function co(r){var A;return((A=r==null?void 0:r.__SPECTOR_Object_TAG)==null?void 0:A.id)??++Gh}function ys(r){return!(r&r-1)&&!!r}const Lh=/([\w-]+)\((.+?)\)/g,Oh=/[^,]+/g,Hh=/([-e.\d]+)(.*)/;function ms(r){return Array.isArray(r)?r.map(A=>({name:A.name,args:A.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...r,normalizedIntValue:r.normalizedDefaultIntValue}}function Ei(r,A,e={}){const t=Bi(A,e);return t.length?t:go(r,A,e)}function Bi(r,A={}){const e=[];let t;for(;(t=Lh.exec(r))!==null;){const[,i,s]=t;i&&e.push({name:i,args:Jh(i,s,A)})}return e}function Jh(r,A,e={}){const t=[];let i,s=0;for(;(i=Oh.exec(A))!==null;)t.push(go(r,i[0],{...e,index:s++}));return t}function go(r,A,e={}){const{width:t=1,height:i=1,index:s=0}=e,n=A.match(Hh),o={unit:(n==null?void 0:n[2])??null,value:A,intValue:Number(n==null?void 0:n[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(r){case"scale":case"scaleX":case"scaleY":case"scale3d":o.normalizedDefaultIntValue=1;break}switch(o.unit){case"%":o.normalizedIntValue=o.intValue/100;break;case"rad":o.normalizedIntValue=o.intValue/At;break;case"deg":o.normalizedIntValue=o.intValue/360;break;case"px":switch(s){case 0:o.normalizedIntValue=o.intValue/t;break;case 1:o.normalizedIntValue=o.intValue/i;break}break;case"turn":case"em":case"rem":default:o.normalizedIntValue=o.intValue;break}return o}const uo="WebGL2RenderingContext"in globalThis,fo="ImageBitmap"in globalThis,Io="ResizeObserver"in globalThis,NA="PointerEvent"in globalThis,po="WheelEvent"in globalThis,Kh="MouseEvent"in globalThis,Jt="ontouchstart"in globalThis,Eo="onclick"in globalThis,ws="createImageBitmap"in globalThis,vs="AudioContext"in globalThis,_s="webkitAudioContext"in globalThis,bs="OfflineAudioContext"in globalThis,Bo="webkitOfflineAudioContext"in globalThis,Co=vs||_s,Ci=typeof window<"u",Ds=globalThis.devicePixelRatio||1,xs=r=>r!==null&&typeof r=="object"&&r.nodeType===1,Qo=r=>xs(r)&&r.tagName==="VIDEO",Yh=r=>xs(r)&&r.tagName==="IMG";function yo(r){return typeof r=="object"&&r!==null&&r.nodeType===1&&r.tagName==="CANVAS"}function mo(r){return uo&&r instanceof globalThis.WebGL2RenderingContext}function wo(){if(Ci)return globalThis.document.createElement("canvas")}function vo(r,A=globalThis.location){if(r.startsWith("data:"))return"";A=A||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==A.hostname||e.port!==A.port||e.protocol!==A.protocol?"anonymous":""}function _o(r,A,e){e===null&&!A.startsWith("data:")?r.crossOrigin=vo(A):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}class FA{constructor(){u(this,"_map",new WeakMap)}_toRaw(A){if(A&&typeof A=="object"){const e=A.__v_raw;e&&(A=this._toRaw(e))}return A}delete(A){return this._map.delete(this._toRaw(A))}get(A){return this._map.get(this._toRaw(A))}has(A){return this._map.has(this._toRaw(A))}set(A,e){return this._map.set(this._toRaw(A),this._toRaw(e)),this}}const bo=new FA;function or(r){let A=bo.get(r);if(!A){const e=Object.getPrototypeOf(r);A=new Map(e?or(e):void 0),bo.set(r,A)}return A}function Qi(r,A,e={}){or(r).set(A,e);const{default:t,alias:i}=e;let s=Object.getOwnPropertyDescriptor(r.prototype,A);if(!s){const o=i??Symbol.for(String(A));s={get(){return this[o]},set(a){this[o]=a}}}const n=()=>typeof t=="function"?t():t;Object.defineProperty(r.prototype,A,{get(){var a,l;let o=(a=s.get)==null?void 0:a.call(this);return o===void 0&&(o=n(),o!==void 0&&((l=s.set)==null||l.call(this,o))),o},set(o){var l,h,c;let a=(l=s.get)==null?void 0:l.call(this);a===void 0&&(a=n()),(h=s.set)==null||h.call(this,o),(c=this.requestUpdate)==null||c.call(this,A,a,e)},configurable:!0,enumerable:!0})}function S(r){return function(A,e){Qi(A.constructor,e,r)}}const ar=new Map;function ne(r,A){return function(e){Object.defineProperty(e.prototype,"tag",{value:r,enumerable:!0,configurable:!0}),A&&Object.keys(A).forEach(t=>{Qi(e,t,{default:A[t]})}),ar.set(r,e)}}function Be(r){return S({...r,protected:!0})}function zh(r="node",A={}){const e=ar.get(r);if(!e)throw new Error(`Failed to createNode, tag: ${r}`);return new e().setProperties(A)}class Se{static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(A,e={}){const{sort:t=0,once:i=!1}=e;this._queue[t]||(this._queue[t]=[]),this._queue[t].push({cb:A,once:i})}static off(A,e={}){const{sort:t=0}=e,i=this._queue[t];if(!i)return;const s=[];for(let n=i.length,o=0;o<n;o++){const a=i[o];a.cb!==A&&s.push(a)}s.length?this._queue[t]=s:this._queue.splice(t,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(A=>this._update(A)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(A){this._elapsed=A-this._currentTime,this._currentTime=A,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const A=this._queue,e=[];for(let t=A.length,i=t;i>=0;i--){const s=A[i];if(!s)continue;const n=[];for(let o=s.length,a=0;a<o;a++){const l=s[a];try{l.cb()}catch(h){console.warn(h)}l.once||n.push(l)}n.length&&(e[i]=n)}this._queue=e}}u(Se,"_queue",[]),u(Se,"_currentTime",0),u(Se,"_elapsed",0),u(Se,"_requestId"),Se.start();async function Ss(r){return new Promise(A=>{Se.on(()=>{r==null||r(),A()},{sort:1,once:!0})})}let Kt=class{constructor(){u(this,"eventListeners",new Map)}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(A){return this.eventListeners.has(A)}on(A,e,t){const i={value:e,options:t},s=this.eventListeners.get(A);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(A,[s,i]):this.eventListeners.set(A,i),this}once(A,e){return this.on(A,e,{once:!0})}off(A,e,t){var s,n;if(!e)return this.eventListeners.delete(A),this;const i=this.eventListeners.get(A);if(!i)return this;if(Array.isArray(i)){const o=[];for(let a=0,l=i.length;a<l;a++){const h=i[a];(h.value!==e||typeof t=="object"&&(t!=null&&t.once)&&(typeof h.options=="boolean"||!((s=h.options)!=null&&s.once)))&&o.push(h)}o.length?this.eventListeners.set(A,o.length===1?o[0]:o):this.eventListeners.delete(A)}else i.value===e&&(typeof t=="boolean"||!(t!=null&&t.once)||typeof i.options=="boolean"||(n=i.options)!=null&&n.once)&&this.eventListeners.delete(A);return this}emit(A,...e){var i,s;const t=this.eventListeners.get(A);if(t){if(Array.isArray(t))for(let n=t.length,o=0;o<n;o++){const a=t[o];typeof a.options=="object"&&((i=a.options)!=null&&i.once)&&this.off(A,a.value,a.options),a.value.apply(this,e)}else typeof t.options=="object"&&((s=t.options)!=null&&s.once)&&this.off(A,t.value,t.options),t.value.apply(this,e);return!0}else return!1}},Wh=0;class rA extends Kt{constructor(){super(...arguments);u(this,"instanceId",++Wh);u(this,"_defaultProperties");u(this,"_updatedProperties",new Map);u(this,"_changedProperties",new Set);u(this,"_updatingPromise",Promise.resolve());u(this,"_updating",!1)}is(e){return!!(e&&this.instanceId===e.instanceId)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await Ss(),this._updating&&(this.update(),this._updating=!1)}update(){this._update(this._updatedProperties),this._updatedProperties=new Map}_update(e){}_updateProperty(e,t,i,s){}isDirty(e){return this._updatedProperties.has(e)}getPropertyDeclarations(){return or(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]=typeof t.default=="function"?t.default():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&&typeof e=="object")for(const[t]of this.getPropertyDeclarations())t in e&&this.setProperty(t,e[t]);return this}resetProperties(){for(const[e,t]of this.getPropertyDeclarations())this.setProperty(e,t.default);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(){const e={},t=this.getProperties(Array.from(this._changedProperties));for(const i in t){const s=t[i];s&&typeof s=="object"?"toJSON"in s&&typeof s.toJSON=="function"?e[i]=s.toJSON():e[i]={...s}:e[i]=s}return e}clone(){return new this.constructor(this.toJSON())}free(){this.removeAllListeners()}}class Do extends rA{}class lr{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",lr.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(...A){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(...A){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 Ms extends lr{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 xo extends Ms{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 yi extends Ms{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(yi,"DOM_DELTA_PIXEL",0),u(yi,"DOM_DELTA_LINE",1),u(yi,"DOM_DELTA_PAGE",2);const Vh={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class So extends Kt{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(Jt&&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||Jt&&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||Jt&&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||Jt&&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 n=0,o=s.length;n<o;n++){const a=this.clonePointerEvent(s[n]);a.type+=i,this.emit("pointerup",this.event=a)}});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=""):NA&&(e.touchAction=""),NA?(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)),Jt&&(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"):NA&&(e.touchAction="none")),NA?(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)),Jt&&(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(Jt&&e instanceof globalThis.TouchEvent)for(let i=0,s=e.changedTouches.length;i<s;i++){const n=e.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(po&&e instanceof globalThis.WheelEvent)t.push(e);else if(NA&&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 yi;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 xo;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=Vh[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,n=Number(this.target.getAttribute("height"))||0,o=Number(this.target.getAttribute("data-pixel-ratio"))||1,a=this.target.isConnected?this.target.getBoundingClientRect():{width:s,height:n,left:0,top:0},l=1/o;e.x=(t-a.left)*(s/a.width)*l,e.y=(i-a.top)*(n/a.height)*l}}class Yt extends Do{}var qh={grad:.9,turn:360,rad:360/(2*Math.PI)},zt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Ue=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=Math.pow(10,A)),Math.round(e*r)/e+0},pt=function(r,A,e){return A===void 0&&(A=0),e===void 0&&(e=1),r>e?e:r>A?r:A},Mo=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Ro=function(r){return{r:pt(r.r,0,255),g:pt(r.g,0,255),b:pt(r.b,0,255),a:pt(r.a)}},Rs=function(r){return{r:Ue(r.r),g:Ue(r.g),b:Ue(r.b),a:Ue(r.a,3)}},Xh=/^#([0-9a-f]{3,8})$/i,hr=function(r){var A=r.toString(16);return A.length<2?"0"+A:A},Po=function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=Math.max(A,e,t),n=s-Math.min(A,e,t),o=n?s===A?(e-t)/n:s===e?2+(t-A)/n:4+(A-e)/n:0;return{h:60*(o<0?o+6:o),s:s?n/s*100:0,v:s/255*100,a:i}},ko=function(r){var A=r.h,e=r.s,t=r.v,i=r.a;A=A/360*6,e/=100,t/=100;var s=Math.floor(A),n=t*(1-e),o=t*(1-(A-s)*e),a=t*(1-(1-A+s)*e),l=s%6;return{r:255*[t,o,n,n,a,t][l],g:255*[a,t,t,o,n,n][l],b:255*[n,n,a,t,t,o][l],a:i}},Uo=function(r){return{h:Mo(r.h),s:pt(r.s,0,100),l:pt(r.l,0,100),a:pt(r.a)}},No=function(r){return{h:Ue(r.h),s:Ue(r.s),l:Ue(r.l),a:Ue(r.a,3)}},Fo=function(r){return ko((e=(A=r).s,{h:A.h,s:(e*=((t=A.l)<50?t:100-t)/100)>0?2*e/(t+e)*100:0,v:t+e,a:A.a}));var A,e,t},mi=function(r){return{h:(A=Po(r)).h,s:(i=(200-(e=A.s))*(t=A.v)/100)>0&&i<200?e*t/100/(i<=100?i:200-i)*100:0,l:i/2,a:A.a};var A,e,t,i},jh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$h=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ec=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ps={string:[[function(r){var A=Xh.exec(r);return A?(r=A[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Ue(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Ue(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var A=$h.exec(r)||ec.exec(r);return A?A[2]!==A[4]||A[4]!==A[6]?null:Ro({r:Number(A[1])/(A[2]?100/255:1),g:Number(A[3])/(A[4]?100/255:1),b:Number(A[5])/(A[6]?100/255:1),a:A[7]===void 0?1:Number(A[7])/(A[8]?100:1)}):null},"rgb"],[function(r){var A=jh.exec(r)||Zh.exec(r);if(!A)return null;var e,t,i=Uo({h:(e=A[1],t=A[2],t===void 0&&(t="deg"),Number(e)*(qh[t]||1)),s:Number(A[3]),l:Number(A[4]),a:A[5]===void 0?1:Number(A[5])/(A[6]?100:1)});return Fo(i)},"hsl"]],object:[[function(r){var A=r.r,e=r.g,t=r.b,i=r.a,s=i===void 0?1:i;return zt(A)&&zt(e)&&zt(t)?Ro({r:Number(A),g:Number(e),b:Number(t),a:Number(s)}):null},"rgb"],[function(r){var A=r.h,e=r.s,t=r.l,i=r.a,s=i===void 0?1:i;if(!zt(A)||!zt(e)||!zt(t))return null;var n=Uo({h:Number(A),s:Number(e),l:Number(t),a:Number(s)});return Fo(n)},"hsl"],[function(r){var A=r.h,e=r.s,t=r.v,i=r.a,s=i===void 0?1:i;if(!zt(A)||!zt(e)||!zt(t))return null;var n=function(o){return{h:Mo(o.h),s:pt(o.s,0,100),v:pt(o.v,0,100),a:pt(o.a)}}({h:Number(A),s:Number(e),v:Number(t),a:Number(s)});return ko(n)},"hsv"]]},To=function(r,A){for(var e=0;e<A.length;e++){var t=A[e][0](r);if(t)return[t,A[e][1]]}return[null,void 0]},tc=function(r){return typeof r=="string"?To(r.trim(),Ps.string):typeof r=="object"&&r!==null?To(r,Ps.object):[null,void 0]},ks=function(r,A){var e=mi(r);return{h:e.h,s:pt(e.s+100*A,0,100),l:e.l,a:e.a}},Us=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Go=function(r,A){var e=mi(r);return{h:e.h,s:e.s,l:pt(e.l+100*A,0,100),a:e.a}},Ns=function(){function r(A){this.parsed=tc(A)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Ue(Us(this.rgba),2)},r.prototype.isDark=function(){return Us(this.rgba)<.5},r.prototype.isLight=function(){return Us(this.rgba)>=.5},r.prototype.toHex=function(){return A=Rs(this.rgba),e=A.r,t=A.g,i=A.b,n=(s=A.a)<1?hr(Ue(255*s)):"","#"+hr(e)+hr(t)+hr(i)+n;var A,e,t,i,s,n},r.prototype.toRgb=function(){return Rs(this.rgba)},r.prototype.toRgbString=function(){return A=Rs(this.rgba),e=A.r,t=A.g,i=A.b,(s=A.a)<1?"rgba("+e+", "+t+", "+i+", "+s+")":"rgb("+e+", "+t+", "+i+")";var A,e,t,i,s},r.prototype.toHsl=function(){return No(mi(this.rgba))},r.prototype.toHslString=function(){return A=No(mi(this.rgba)),e=A.h,t=A.s,i=A.l,(s=A.a)<1?"hsla("+e+", "+t+"%, "+i+"%, "+s+")":"hsl("+e+", "+t+"%, "+i+"%)";var A,e,t,i,s},r.prototype.toHsv=function(){return A=Po(this.rgba),{h:Ue(A.h),s:Ue(A.s),v:Ue(A.v),a:Ue(A.a,3)};var A},r.prototype.invert=function(){return xt({r:255-(A=this.rgba).r,g:255-A.g,b:255-A.b,a:A.a});var A},r.prototype.saturate=function(A){return A===void 0&&(A=.1),xt(ks(this.rgba,A))},r.prototype.desaturate=function(A){return A===void 0&&(A=.1),xt(ks(this.rgba,-A))},r.prototype.grayscale=function(){return xt(ks(this.rgba,-1))},r.prototype.lighten=function(A){return A===void 0&&(A=.1),xt(Go(this.rgba,A))},r.prototype.darken=function(A){return A===void 0&&(A=.1),xt(Go(this.rgba,-A))},r.prototype.rotate=function(A){return A===void 0&&(A=15),this.hue(this.hue()+A)},r.prototype.alpha=function(A){return typeof A=="number"?xt({r:(e=this.rgba).r,g:e.g,b:e.b,a:A}):Ue(this.rgba.a,3);var e},r.prototype.hue=function(A){var e=mi(this.rgba);return typeof A=="number"?xt({h:A,s:e.s,l:e.l,a:e.a}):Ue(e.h)},r.prototype.isEqual=function(A){return this.toHex()===xt(A).toHex()},r}(),xt=function(r){return r instanceof Ns?r:new Ns(r)},Lo=[],Ac=function(r){r.forEach(function(A){Lo.indexOf(A)<0&&(A(Ns,Ps),Lo.push(A))})};function ic(r,A){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={};r.prototype.toName=function(n){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,a,l=t[this.toHex()];if(l)return l;if(n!=null&&n.closest){var h=this.toRgb(),c=1/0,f="black";if(!s.length)for(var I in e)s[I]=new r(e[I]).toRgb();for(var d in e){var C=(o=h,a=s[d],Math.pow(o.r-a.r,2)+Math.pow(o.g-a.g,2)+Math.pow(o.b-a.b,2));C<c&&(c=C,f=d)}return f}},A.string.push([function(n){var o=n.toLowerCase(),a=o==="transparent"?"#0000":e[o];return a?new r(a).toRgb():null},"name"])}function he(r){return r==null||r==="none"}function TA(r,A=0,e=10**A){return Math.round(e*r)/e+0}function Fs(r,A=!1){if(typeof r!="object"||!r)return r;if(Array.isArray(r))return A?r.map(t=>Fs(t,A)):r;const e={};for(const t in r){const i=r[t];i!=null&&(A?e[t]=Fs(i,A):e[t]=i)}return e}function Ts(r,A){const e={};return A.forEach(t=>{t in r&&(e[t]=r[t])}),e}function Gs(r){let A;return typeof r=="number"?A={r:r>>24&255,g:r>>16&255,b:r>>8&255,a:(r&255)/255}:A=r,xt(A)}function rc(r){return{r:TA(r.r),g:TA(r.g),b:TA(r.b),a:TA(r.a,3)}}function cr(r){const A=r.toString(16);return A.length<2?`0${A}`:A}const Oo="#000000FF";function sc(r){return Gs(r).isValid()}function ht(r,A=!1){const e=Gs(r);if(!e.isValid()){if(typeof r=="string")return r;const o=`Failed to normalizeColor ${r}`;if(A)throw new Error(o);return console.warn(o),Oo}const{r:t,g:i,b:s,a:n}=rc(e.rgba);return`#${cr(t)}${cr(i)}${cr(s)}${cr(TA(n*255))}`}var gr=gr||{};gr.parse=function(){const r={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let A="";function e(N){const U=new Error(`${A}: ${N}`);throw U.source=A,U}function t(){const N=i();return A.length>0&&e("Invalid input not EOF"),N}function i(){return w(s)}function s(){return n("linear-gradient",r.linearGradient,a)||n("repeating-linear-gradient",r.repeatingLinearGradient,a)||n("radial-gradient",r.radialGradient,c)||n("repeating-radial-gradient",r.repeatingRadialGradient,c)}function n(N,U,X){return o(U,ee=>{const oe=X();return oe&&(J(r.comma)||e("Missing comma before color stops")),{type:N,orientation:oe,colorStops:w(R)}})}function o(N,U){const X=J(N);if(X){J(r.startCall)||e("Missing (");const ee=U(X);return J(r.endCall)||e("Missing )"),ee}}function a(){const N=l();if(N)return N;const U=ie("position-keyword",r.positionKeywords,1);return U?{type:"directional",value:U.value}:h()}function l(){return ie("directional",r.sideOrCorner,1)}function h(){return ie("angular",r.angleValue,1)||ie("angular",r.radianValue,1)}function c(){let N,U=f(),X;return U&&(N=[],N.push(U),X=A,J(r.comma)&&(U=f(),U?N.push(U):A=X)),N}function f(){let N=I()||d();if(N)N.at=p();else{const U=C();if(U){N=U;const X=p();X&&(N.at=X)}else{const X=p();if(X)N={type:"default-radial",at:X};else{const ee=M();ee&&(N={type:"default-radial",at:ee})}}}return N}function I(){const N=ie("shape",/^(circle)/i,0);return N&&(N.style=q()||C()),N}function d(){const N=ie("shape",/^(ellipse)/i,0);return N&&(N.style=M()||L()||C()),N}function C(){return ie("extent-keyword",r.extentKeywords,1)}function p(){if(ie("position",/^at/,0)){const N=M();return N||e("Missing positioning value"),N}}function M(){const N=P();if(N.x||N.y)return{type:"position",value:N}}function P(){return{x:L(),y:L()}}function w(N){let U=N();const X=[];if(U)for(X.push(U);J(r.comma);)U=N(),U?X.push(U):e("One extra comma");return X}function R(){const N=_();return N||e("Expected color definition"),N.length=L(),N}function _(){return b()||K()||V()||z()||D()||Ae()||m()}function m(){return ie("literal",r.literalColor,0)}function b(){return ie("hex",r.hexColor,1)}function D(){return o(r.rgbColor,()=>({type:"rgb",value:w(W)}))}function z(){return o(r.rgbaColor,()=>({type:"rgba",value:w(W)}))}function Ae(){return o(r.varColor,()=>({type:"var",value:te()}))}function V(){return o(r.hslColor,()=>{J(r.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const U=W();J(r.comma);let X=J(r.percentageValue);const ee=X?X[1]:null;J(r.comma),X=J(r.percentageValue);const oe=X?X[1]:null;return(!ee||!oe)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[U,ee,oe]}})}function K(){return o(r.hslaColor,()=>{const N=W();J(r.comma);let U=J(r.percentageValue);const X=U?U[1]:null;J(r.comma),U=J(r.percentageValue);const ee=U?U[1]:null;J(r.comma);const oe=W();return(!X||!ee)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[N,X,ee,oe]}})}function te(){return J(r.variableName)[1]}function W(){return J(r.number)[1]}function L(){return ie("%",r.percentageValue,1)||se()||H()||q()}function se(){return ie("position-keyword",r.positionKeywords,1)}function H(){return o(r.calcValue,()=>{let N=1,U=0;for(;N>0&&U<A.length;){const ee=A.charAt(U);ee==="("?N++:ee===")"&&N--,U++}N>0&&e("Missing closing parenthesis in calc() expression");const X=A.substring(0,U-1);return $(U-1),{type:"calc",value:X}})}function q(){return ie("px",r.pixelValue,1)||ie("em",r.emValue,1)}function ie(N,U,X){const ee=J(U);if(ee)return{type:N,value:ee[X]}}function J(N){let U,X;return X=/^\s+/.exec(A),X&&$(X[0].length),U=N.exec(A),U&&$(U[0].length),U}function $(N){A=A.substr(N)}return function(N){return A=N.toString().trim(),A.endsWith(";")&&(A=A.slice(0,-1)),t()}}();const nc=gr.parse.bind(gr);var ur=ur||{};ur.stringify=function(){var r={"visit_linear-gradient":function(A){return r.visit_gradient(A)},"visit_repeating-linear-gradient":function(A){return r.visit_gradient(A)},"visit_radial-gradient":function(A){return r.visit_gradient(A)},"visit_repeating-radial-gradient":function(A){return r.visit_gradient(A)},visit_gradient:function(A){var e=r.visit(A.orientation);return e&&(e+=", "),A.type+"("+e+r.visit(A.colorStops)+")"},visit_shape:function(A){var e=A.value,t=r.visit(A.at),i=r.visit(A.style);return i&&(e+=" "+i),t&&(e+=" at "+t),e},"visit_default-radial":function(A){var e="",t=r.visit(A.at);return t&&(e+=t),e},"visit_extent-keyword":function(A){var e=A.value,t=r.visit(A.at);return t&&(e+=" at "+t),e},"visit_position-keyword":function(A){return A.value},visit_position:function(A){return r.visit(A.value.x)+" "+r.visit(A.value.y)},"visit_%":function(A){return A.value+"%"},visit_em:function(A){return A.value+"em"},visit_px:function(A){return A.value+"px"},visit_calc:function(A){return"calc("+A.value+")"},visit_literal:function(A){return r.visit_color(A.value,A)},visit_hex:function(A){return r.visit_color("#"+A.value,A)},visit_rgb:function(A){return r.visit_color("rgb("+A.value.join(", ")+")",A)},visit_rgba:function(A){return r.visit_color("rgba("+A.value.join(", ")+")",A)},visit_hsl:function(A){return r.visit_color("hsl("+A.value[0]+", "+A.value[1]+"%, "+A.value[2]+"%)",A)},visit_hsla:function(A){return r.visit_color("hsla("+A.value[0]+", "+A.value[1]+"%, "+A.value[2]+"%, "+A.value[3]+")",A)},visit_var:function(A){return r.visit_color("var("+A.value+")",A)},visit_color:function(A,e){var t=A,i=r.visit(e.length);return i&&(t+=" "+i),t},visit_angular:function(A){return A.value+"deg"},visit_directional:function(A){return"to "+A.value},visit_array:function(A){var e="",t=A.length;return A.forEach(function(i,s){e+=r.visit(i),s<t-1&&(e+=", ")}),e},visit_object:function(A){return A.width&&A.height?r.visit(A.width)+" "+r.visit(A.height):""},visit:function(A){if(!A)return"";if(A instanceof Array)return r.visit_array(A);if(typeof A=="object"&&!A.type)return r.visit_object(A);if(A.type){var e=r["visit_"+A.type];if(e)return e(A);throw Error("Missing visitor visit_"+A.type)}else throw Error("Invalid node.")}};return function(A){return r.visit(A)}}(),ur.stringify.bind(ur);function Ho(r){const A=r.length-1;return r.map((e,t)=>{var o;const i=e.value;let s=TA(t/A,3),n="#00000000";switch(e.type){case"rgb":n=ht({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":n=ht({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":n=ht(e.value);break;case"hex":n=ht(`#${e.value}`);break}switch((o=e.length)==null?void 0:o.type){case"%":s=Number(e.length.value)/100;break}return{offset:s,color:n}})}function Jo(r){var e;let A=0;switch((e=r.orientation)==null?void 0:e.type){case"angular":A=Number(r.orientation.value);break}return{type:"linear-gradient",angle:A,stops:Ho(r.colorStops)}}function Ko(r){var A;return(A=r.orientation)==null||A.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Ho(r.colorStops)}}function wi(r){return r.startsWith("linear-gradient(")||r.startsWith("radial-gradient(")}function oc(r){return nc(r).map(A=>{switch(A==null?void 0:A.type){case"linear-gradient":return Jo(A);case"repeating-linear-gradient":return{...Jo(A),repeat:!0};case"radial-gradient":return Ko(A);case"repeating-radial-gradient":return{...Ko(A),repeat:!0};default:return}}).filter(Boolean)}function ac(r){let A;return typeof r=="string"?A={color:r}:A=r,{color:ht(A.color)}}function lc(r){let A;if(typeof r=="string"?A={image:r}:A=r,A.image){const{type:e,...t}=oc(A.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:t};case"linear-gradient":return{linearGradient:t}}}return A}function hc(r){let A;return typeof r=="string"?A={image:r}:A=r,A}function cc(r){let A;return typeof r=="string"?A={preset:r}:A=r,{preset:A.preset,foregroundColor:he(A.foregroundColor)?void 0:ht(A.foregroundColor),backgroundColor:he(A.backgroundColor)?void 0:ht(A.backgroundColor)}}function gc(r){return!he(r.color)}function uc(r){return typeof r=="string"?sc(r):gc(r)}function fc(r){return!he(r.image)&&wi(r.image)||!!r.linearGradient||!!r.radialGradient}function dc(r){return typeof r=="string"?wi(r):fc(r)}function Ic(r){return!he(r.image)&&!wi(r.image)}function pc(r){return typeof r=="string"?!wi(r):Ic(r)}function Ec(r){return!he(r.preset)}function Bc(r){return typeof r=="string"?!1:Ec(r)}function mA(r){return uc(r)?ac(r):dc(r)?lc(r):pc(r)?hc(r):Bc(r)?cc(r):{}}function Cc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["fillWithShape"])}}function Qc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["fillWithShape"])}}function yc(r){return typeof r=="string"?{...mA(r)}:{...mA(r),...Ts(r,["width","style","headEnd","tailEnd"])}}function mc(r){return typeof r=="string"?{color:ht(r)}:{...r,color:he(r.color)?Oo:ht(r.color)}}function wc(){return{boxShadow:"none"}}function vc(r){return typeof r=="string"?r.startsWith("<svg")?{svg:r}:{paths:[{data:r}]}:Array.isArray(r)?{paths:r.map(A=>typeof A=="string"?{data:A}:A)}:r}function _c(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function bc(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Dc(){return{..._c(),...bc(),...wc(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function xc(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Sc(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Mc(){return{...xc(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Rc(){return{...Sc(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function Pc(){return{...Rc(),...Mc(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function fr(r){return Fs({...r,color:he(r.color)?void 0:ht(r.color),backgroundColor:he(r.backgroundColor)?void 0:ht(r.backgroundColor),borderColor:he(r.borderColor)?void 0:ht(r.borderColor),outlineColor:he(r.outlineColor)?void 0:ht(r.outlineColor),shadowColor:he(r.shadowColor)?void 0:ht(r.shadowColor)})}function Yo(){return{...Dc(),...Pc()}}function zo(r=""){return(Array.isArray(r)?r:[r]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[fr(e)]}:"fragments"in e?{...fr(e),fragments:e.fragments.map(t=>fr(t))}:Array.isArray(e)?{fragments:e.map(t=>typeof t=="string"?{content:t}:fr(t))}:{fragments:[]})}function kc(r){return typeof r=="string"?{content:[{fragments:[{content:r}]}]}:"content"in r?{...r,content:zo(r.content)}:{content:zo(r)}}Ac([ic]);class Wt{get value(){return this._value}set value(A){this._colord=Gs(A??"none")}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(A=0){this.value=A}toHex(){return this._colord.toHex()}toRgb(){return this._colord.toRgb()}toRgbString(){return this._colord.toRgbString()}toHsl(){return this._colord.toHsl()}toHslString(){return this._colord.toHslString()}toHsv(){return this._colord.toHsv()}toArgb(A=this.a,e=!0){if(A===1)return(255<<24)+this.rgb;if(A===0)return e?0:this.rgb;let t=this.r8,i=this.g8,s=this.b8;return e&&(t=t*A+.5|0,i=i*A+.5|0,s=s*A+.5|0),(A*255<<24)+(t<<16)+(i<<8)+s}toArray(){return[this.r,this.g,this.b,this.a]}}class mt extends Kt{constructor(e){super();u(this,"_array",[]);this.dim=e}get length(){return this.dim}_operate(e,t,i){const{dim:s,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:s},()=>t):t instanceof St||t instanceof mt?o=t.toArray():o=t;let a,l=[];if(i?i instanceof mt?a=i:l=i:a=this,t instanceof St){const{cols:h}=t;switch(e){case"*":for(let c=0;c<s;c++){let f=0;for(let I=0;I<s;I++)f+=n[c]*o[I*h+c];l[c]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let h=0;h<s;h++)l[h]=n[h]+o[h];break;case"-":for(let h=0;h<s;h++)l[h]=n[h]-o[h];break;case"*":for(let h=0;h<s;h++)l[h]=n[h]*o[h];break;case"/":for(let h=0;h<s;h++)l[h]=n[h]/o[h];break;case"rot":{const h=Math.cos(o[0]),c=Math.sin(o[0]);l[0]=n[0]*h-n[1]*c,l[1]=n[1]*h+n[0]*c;break}case"==":{let h=!0;for(let c=0;c<s;c++)h=h&&n[c]===o[c];return h}case"=":for(let h=0;h<s;h++){const c=o[h];c!==void 0&&(n[h]=c)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return(a==null?void 0:a.set(l))??l}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)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toArray(){return this._array.slice()}toName(){return`Vector${this.dim}`}}class St extends Kt{constructor(e,t,i){super();u(this,"_array",[]);u(this,"dirtyId",0);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:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof mt||t instanceof St?l=t.toArray():l=t;let h,c=[];if(i?i instanceof mt||i instanceof St?h=i:c=i:t instanceof mt?h=new t.constructor:h=this,t instanceof mt){const{dim:f}=t;switch(e){case"*":for(let I=0;I<f;I++){let d=0;for(let C=0;C<s;C++)C<f&&(d+=a[I*s+C]*(l[C]??0));c[I]=d}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<s;f++)for(let I=0;I<n;I++){const d=I*s;let C=0;for(let p=0;p<n;p++){const M=d+p,P=p*s+f;C+=a[M]*(l[P]??0)}c[d+f]=C}break;case"=":for(let f=0;f<o;f++){const I=l[f];I!==void 0&&(a[f]=I)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return(h==null?void 0:h.set(c))??c}identity(){const{cols:e,rows:t}=this,i=[];for(let s=0;s<e;s++)for(let n=0;n<t;n++){const o=n*e,a=s+o;i[a]=n+o===a?1:0}return this.set(i)}set(e){return this._operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this._operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:i,_array:s}=this;if(e){const n=[];for(let o=0;o<i;o++)for(let a=0;a<t;a++)n[o+a*t]=s[a+o*t];return n}return s.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array}}class Wo extends St{constructor(A){super(4,4,A)}}const Vo=Ht/180,Uc=180/Ht;function Vt(r,A,e){return Math.max(r,Math.min(A,e))}function Me(r,A,e){return(1-e)*r+e*A}const Nc={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,A=20){if(!this.adaptive||!r||Number.isNaN(r))return A;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class qo extends mt{constructor(A=0,e=0,t=0,i=0){super(4),this.set([A,e,t,i])}}class Ls extends St{constructor(A){super(4,5,A)}hueRotate(A=0){const e=Math.sin(A),t=Math.cos(A),i=.213,s=.715,n=.072;return this.multiply([i+t*(1-i)+e*-.213,s+t*-.715+e*-.715,n+t*-.072+e*(1-n),0,0,i+t*-.213+e*.143,s+t*(1-s)+e*.14,n+t*-.072+e*-.283,0,0,i+t*-.213+e*-.787,s+t*-.715+e*s,n+t*(1-n)+e*n,0,0,0,0,0,1,0])}saturate(A=1){const e=(A-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(A=1){const e=A;return this.multiply([e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0])}contrast(A=1){const e=A,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(A=1){const e=Me(1,-1,A),t=Me(0,255,A);return this.multiply([e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0])}sepia(A=1){const e=Vt(0,A,1);return this.multiply([Me(1,.393,e),Me(0,.7689999,e),Me(0,.18899999,e),0,0,Me(0,.349,e),Me(1,.6859999,e),Me(0,.16799999,e),0,0,Me(0,.272,e),Me(0,.5339999,e),Me(1,.13099999,e),0,0,0,0,0,1,0])}opacity(A=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,A,0])}grayscale(A=1){const e=Vt(0,A,1),t=Me(1,.3,e),i=Me(0,.3,e),s=Me(1,.59,e),n=Me(0,.59,e),o=Me(1,.11,e),a=Me(0,.11,e);return this.multiply([t,n,a,0,0,i,s,a,0,0,i,n,o,0,0,0,0,0,1,0])}multiply(A){const e=A,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 A=this._array;return new Wo([A[0],A[1],A[2],A[3],A[5],A[6],A[7],A[8],A[10],A[11],A[12],A[13],A[15],A[16],A[17],A[18]])}toVector4(){const A=this._array;return new qo(A[4]/255,A[9]/255,A[14]/255,A[19]/255)}}class Fc extends St{constructor(A){super(2,2,A)}}let Os=class extends St{constructor(A){super(3,3,A)}invert(){const[A,e,t,i,s,n,o,a,l]=this._array,h=l*s-n*a,c=n*o-l*i,f=a*i-s*o,I=A*h+e*c+t*f;if(I===0)return this.set([0,0,0,0,0,0,0,0,0]);const d=1/I;return this.set([h*d,(t*a-l*e)*d,(n*e-t*s)*d,c*d,(l*A-t*o)*d,(t*i-n*A)*d,f*d,(e*o-a*A)*d,(s*A-e*i)*d])}};class Xo extends Os{constructor(A=0,e=0,t=0,i=0,s=!1){super(),this._x=A,this._y=e,this._width=t,this._height=i,this._flipY=s,this._performUpdateArray()}flipY(A){return this._flipY!==A&&(this._flipY=A,this._performUpdateArray()),this}translate(A,e){return(this._x!==A||this._y!==e)&&(this._x=A,this._y=e,this._performUpdateArray()),this}resize(A,e){return(this._width!==A||this._height!==e)&&(this._width=A,this._height=e,this._performUpdateArray()),this}_performUpdateArray(){const A=this._width,e=this._height;if(!A||!e)return;const t=this._x,i=this._y,s=this._flipY?-1:1,n=1/A*2,o=s*(1/e*2),a=-1-t*n,l=-s-i*o;this.set([n,0,a,0,o,l,0,0,1])}}let wt=class Qs extends mt{get x(){return this._array[0]}set x(A){const[e,t]=this._array;e!==A&&this.set(A,t)}get y(){return this._array[1]}set y(A){const[e,t]=this._array;t!==A&&this.set(e,A)}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}get left(){return this.x}set left(A){this.x=A}get top(){return this.y}set top(A){this.y=A}constructor(A=0,e){super(2),this.set(typeof A=="number"?[A,e??A]:A)}update(A,e){const[t,i]=this._array;return(t!==A||i!==e)&&this.set(A,e),this}getLength(){const[A,e]=this._array;return Math.sqrt(A*A+e*e)}getAngle(){const[A,e]=this._array;return Math.atan2(-A,-e)+Math.PI}distanceTo(A){return Math.hypot(A.x-this.x,A.y-this.y)}normalize(){const[A,e]=this._array,t=1/(this.getLength()||1);return this.set(A*t,e*t),this}static lerp(A,e,t){return new Qs(e).clone().sub(new Qs(A)).multiply(t).add(new Qs(A))}};class Hs{constructor(...A){u(this,"end",new wt);u(this,"position");u(this,"size");const e=new wt,t=new wt;switch(A.length){case 0:break;case 1:e.set(A[0].position),t.set(A[0].size);break;case 2:e.set(A[0]),t.set(A[1]);break;default:e.set(A[0],A[1]),t.set(A[2],A[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]}}const BA=class BA extends Os{premultiply(A){return A.multiply(this,this)}skewX(A){return this.skew(A,0)}skewY(A){return this.skew(0,A)}skew(A,e){return this.premultiply(BA._t2d.makeSkew(A,e))}makeSkew(A,e){const t=Math.tan(A),i=Math.tan(e);return this.set([1,i,0,t,1,0,0,0,1]),this}translateX(A){return this.translate(A,0)}translateY(A){return this.translate(0,A)}translateZ(A){return this.translate(0,0,A)}translate3d(A,e,t){return this.translate(A,e,t)}translate(A,e,t=0){return this.premultiply(BA._t2d.makeTranslation(A,e,t))}makeTranslation(A,e,t=0){return this.set([1,0,A,0,1,e,0,0,1]),this}scaleX(A){return this.scale(A,1)}scaleY(A){return this.scale(1,A)}scale3d(A,e,t=1){return this.scale(A,e,t)}scale(A,e,t=1){return this.premultiply(BA._t2d.makeScale(A,e,t))}makeScale(A,e,t=1){return this.set([A,0,0,0,e,0,0,0,1]),this}rotateX(A){return this.scaleY(this._rotateToScale(A))}rotateY(A){return this.scaleX(this._rotateToScale(A))}rotateZ(A){return this.rotate(A)}rotate(A){return this.premultiply(BA._t2d.makeRotation(A))}rotate3d(A,e,t,i){const[s,n,o]=this._rotate3d(A,e,t,i);return s&&this.rotateX(s),n&&this.rotateY(n),o&&this.rotateZ(o),this}_rotateToScale(A){const e=A/At;return e<=.5?e*-4+1:(e-1)*4+1}_rotate3d(A,e,t,i){if(A===1&&e===0&&t===0)return[i,0,0];if(A===0&&e===1&&t===0)return[0,i,0];if(A===0&&e===0)return[0,0,i];{const s=Math.cos(i),n=Math.sin(i),o=s+A*A*(1-s),a=A*e*(1-s)-t*n,l=A*t*(1-s)+e*n,h=s+e*e*(1-s),c=e*t*(1-s)-A*n,f=s+t*t*(1-s),I=-Math.atan2(-c,h),d=-Math.atan2(l,Math.sqrt(c*c+f*f)),C=-Math.atan2(-a,o);return[I,d,C]}}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set([e,-t,0,t,e,0,0,0,1]),this}applyToPoint(A,e){const{a:t,c:i,tx:s,b:n,d:o,ty:a}=this.toObject();return[t*A+i*e+s,n*A+o*e+a]}inverse(){return this.clone().invert()}isIdentity(){const{a:A,b:e,c:t,d:i,tx:s,ty:n}=this.toObject();return A===1&&e===0&&t===0&&i===1&&s===0&&n===0}toObject(){const[A,e,t,i,s,n,,,o]=this._array;return{a:A,c:e,tx:t,b:i,d:s,ty:n,tz:o}}};u(BA,"_t2d",new BA);let Et=BA;class Tc extends mt{constructor(){super(3)}}var Gc=Object.defineProperty,jo=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Gc(A,e,i),i};class dr extends rA{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){this._starting||(this._starting=!0,this.off("process"),this.on("process",e),Se.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,Se.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=Se.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const i=(this._nextDeltaTime=this.spf)||e;this.emit("process",i)}}free(){super.free(),this.stop()}}jo([S({default:24})],dr.prototype,"fps"),jo([S({default:1})],dr.prototype,"speed");class Zo{constructor(){u(this,"view");u(this,"pixelRatio",Ds);u(this,"screen",{x:0,y:0,width:0,height:0});u(this,"related",new FA)}getRelated(A,e){let t=this.related.get(A);return t||(e?(this.related.set(A,t=e()),t):(console.warn("Failed to get related",A),null))}resize(A,e,t=!0){this.view&&(this.view.width=Math.floor(A*this.pixelRatio),this.view.height=Math.floor(e*this.pixelRatio)),this.screen.width=A,this.screen.height=e,t&&this.view&&(this.view.style.width=`${A}px`,this.view.style.height=`${e}px`)}}var GA=(r=>(r.NORMAL="normal",r.ADD="add",r.MULTIPLY="multiply",r.SCREEN="screen",r.NONE="none",r.NORMAL_NPM="normal_npm",r.ADD_NPM="add_npm",r.SCREEN_NPM="screen_npm",r.SRC_IN="src_in",r.SRC_OUT="src_out",r.SRC_ATOP="src_atop",r.DST_OVER="dst_over",r.DST_IN="dst_in",r.DST_OUT="dst_out",r.DST_ATOP="dst_atop",r.XOR="xor",r.SUBTRACT="subtract",r))(GA||{});function $o(r){return{normal:[r.ONE,r.ONE_MINUS_SRC_ALPHA],add:[r.ONE,r.ONE],multiply:[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],screen:[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],add_npm:[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],screen_npm:[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],src_in:[r.DST_ALPHA,r.ZERO],src_out:[r.ONE_MINUS_DST_ALPHA,r.ZERO],src_atop:[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],dst_over:[r.ONE_MINUS_DST_ALPHA,r.ONE],dst_in:[r.ZERO,r.SRC_ALPHA],dst_out:[r.ZERO,r.ONE_MINUS_SRC_ALPHA],dst_atop:[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],xor:[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],subtract:[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD]}}class Bt{get gl(){return this._renderer.gl}install(A){this._renderer=A}onUpdateContext(){}flush(){}reset(){}free(){}}const ss=class ss{constructor(A){u(this,"_blendMode",GA.NORMAL);u(this,"_polygonOffset",0);u(this,"bitmap",0);if(A)for(const e in A)this[e]=A[e]}static _init(){this._properties.forEach((A,e)=>{Object.defineProperty(this.prototype,A,{get(){return!!(this.bitmap&1<<e)},set(t){!!(this.bitmap&1<<e)!==t&&(this.bitmap^=1<<e)},enumerable:!0,configurable:!0})})}static for2D(){const A=new ss;return A.depthTest=!1,A.blend=!0,A}get blendMode(){return this._blendMode}set blendMode(A){this.blend=A!==GA.NONE,this._blendMode=A}get polygonOffset(){return this._polygonOffset}set polygonOffset(A){this.offsets=!!A,this._polygonOffset=A}};u(ss,"_properties",["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"]);let wA=ss;wA._init();class ea extends Bt{constructor(){super(...arguments);u(this,"_blendEq",!1);u(this,"_setters",wA._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 wA({blend:!0}))}install(e){super.install(e),e.state=this}onUpdateContext(){super.onUpdateContext(),this.blendModes=$o(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(GA.NORMAL)}}class ta extends Bt{constructor(){super(...arguments);u(this,"_state",wA.for2D());u(this,"_batchSize",4096*4);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"},aDisableWrapMode:{size:4,normalized:!0,type:"float"},aColorMatrixOffset:{size:4,normalized:!1,type:"float"},aColorMatrix:{size:4,normalized:!1,type:"float"}});u(this,"_vertexSize",31)}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;
|
|
@@ -110,7 +110,7 @@ uniform sampler2D sampler;
|
|
|
110
110
|
uniform vec4 tint;
|
|
111
111
|
void main(void) {
|
|
112
112
|
gl_FragColor = texture2D(sampler, vUv) * tint;
|
|
113
|
-
}`,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(OA,"_instance");class fe extends Ir{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=OA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new gt({buffer:new qt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new gt({buffer:new qt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new LA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(fe,"_instance");class qc extends Ir{constructor(){const e=new qt({data:new Float32Array,dynamic:!0}),t=new qt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new gt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new gt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new LA({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var Xc=Object.defineProperty,HA=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Xc(A,e,i),i};class _e 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=ys(this.realWidth)&&ys(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))}free(){fo&&this.source instanceof ImageBitmap&&this.source.close()}}HA([Be()],_e.prototype,"source"),HA([S({default:0})],_e.prototype,"width"),HA([S({default:0})],_e.prototype,"height"),HA([S({default:"linear"})],_e.prototype,"filterMode"),HA([S({default:"clamp_to_edge"})],_e.prototype,"wrapMode"),HA([S({default:1})],_e.prototype,"pixelRatio");class Er extends Yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof _e)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}free(){this.frames.forEach(e=>{e.texture.free()})}}var jc=Object.defineProperty,Zc=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&jc(A,e,i),i};class JA extends _e{constructor(A=document.createElement("canvas")){super(A)}_updateProperty(A,e,t,i){switch(A){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(A,e,t,i)}}Zc([S({default:2})],JA.prototype,"pixelRatio");class Ba extends _e{constructor(A){const e=new Wt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}class Br extends _e{static test(A){return wi(A)}static linearGradient(A,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");if(!s)throw new Error("Failed to parse linear gradient, get canvas context is null.");let{angle:n=0,stops:o}=A;n-=Math.PI/2;const a=e/2,l=t/2,h=Math.sqrt(e*e+t*t)/2,c=a+h*Math.cos(n+Math.PI),f=l+h*Math.sin(n+Math.PI),I=a+h*Math.cos(n),d=l+h*Math.sin(n),C=s.createLinearGradient(c,f,I,d);o.forEach(M=>{C.addColorStop(M.offset,M.color)}),s.fillStyle=C,s.fillRect(0,0,i.width,i.height);const p=s.getImageData(0,0,i.width,i.height);return{width:p.width,height:p.height,pixels:new Uint8Array(p.data.buffer)}}constructor(A,e,t){super(Br.linearGradient(A,e,t))}}function $c(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&ws,crossorigin:(r==null?void 0:r.crossorigin)??null}}class eg extends _e{constructor(e,t){const i=$c(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,n=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!n,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)},n=o=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!ws)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(Ci&&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 Ys extends _e{constructor(A,e=1,t=1){const i={width:e,height:t,pixels:null};A&&(ArrayBuffer.isView(A)?i.pixels=new Uint8Array(A.buffer):i.pixels=new Uint8Array(A)),super(i)}_updateProperty(A,e,t,i){switch(A){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(A,e,t,i)}}var tg=Object.defineProperty,Ca=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&tg(A,e,i),i};function Ag(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),autoPlay:!!((r==null?void 0:r.autoPlay)??!1),fps:Number((r==null?void 0:r.fps)??0),crossorigin:(r==null?void 0:r.crossorigin)??null,loop:!!((r==null?void 0:r.loop)??!1),muted:!!((r==null?void 0:r.muted)??!1),playsinline:!!((r==null?void 0:r.playsinline)??!0)}}const zs=(kA=class extends _e{constructor(e,t){const i=Ag(t);if(!Qo(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],n=document.createElement("video");i.autoLoad&&n.setAttribute("preload","auto"),i.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),i.muted&&(n.setAttribute("muted",""),n.muted=!0),i.loop&&n.setAttribute("loop",""),i.autoPlay&&n.setAttribute("autoplay",""),_o(n,s,i.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const c=a.split("?").shift().toLowerCase(),f=c.slice(c.lastIndexOf(".")+1);l=l||kA.mimeTypes.get(f)||`video/${f}`}const h=document.createElement("source");h.src=a,l&&(h.type=l),n.appendChild(h)}e=n}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(Se.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&&(Se.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||(Se.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Se.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}free(){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(kA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),kA);Ca([Be({default:!0})],zs.prototype,"autoUpdate"),Ca([Be({default:0})],zs.prototype,"fps");let Qa=zs;class Ws extends Ys{}class ya extends Array{constructor(...e){super();u(this,"front",[]);u(this,"back",[]);this.set(e)}get internal(){return[...this.front,...this,...this.back]}set(e){return this.front.length=0,this.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){switch(e){case"front":return this.front;case"default":return this;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}}toJSON(){return[...this]}}var ig=Object.defineProperty,rg=Object.getOwnPropertyDescriptor,nA=(r,A,e,t)=>{for(var i=t>1?void 0:t?rg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ig(A,e,i),i};const ma={};function sg(r){let A=ma[r]??0;return A++,ma[r]=A,A}g.Node=class extends rA{constructor(e,t=[]){super();u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",new ya);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({name:`${this.tag}:${sg(this.tag)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...i}=e;if(t)for(const s in t)this.meta[s]=t[s];super.setProperties(i)}return this}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!=null&&e.is(t))){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const i=this._children.internal;for(let s=i.length,n=0;n<s;n++){const o=i[n];!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;i&&this.emit("unparented",i),this._parent=e,e&&this.emit("parented",e),this.setTree(e==null?void 0:e._tree)}return this}get children(){return this._children}set children(e){e instanceof ya?this._children=e:this._children.set(e)}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.children[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.children[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.children[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.children;return e?e[e.length-1]:void 0}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.processPaused;case"when_paused":return this._tree.processPaused;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}}_update(e){super._update(e)}_updateProperty(e,t,i,s){super._updateProperty(e,t,i,s)}_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(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(i){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof g.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),i&&(t.renderStack.currentCall=a),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){this._children.internal.forEach(i=>i.input(e,t)),this._input(e,t)}getIndex(){var e;return((e=this._parent)==null?void 0:e.children.getInternal(this.internalMode).indexOf(this))??0}getNode(e){return this._children.internal.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()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.moveChild(i,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.appendChild(i)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;const s=this._children.getInternal(e.internalMode),n=s.indexOf(e),o=this._children.getInternal(i);return(e.internalMode!==i||t!==n)&&(n>-1&&s.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode=i,this}removeChild(e){const t=e.getIndex();return this.is(e.parent)&&t>-1&&(this._children.internal.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this._children.forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEachChild(e){return this._children.forEach(e),this}forEachDescendant(e){return this._children.forEach(t=>{e(t),t.forEachDescendant(e)}),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}clone(){return new this.constructor(this.toJSON().props,this._children.internal)}toJSON(){return{tag:this.tag,props:super.toJSON(),children:[...this._children.map(e=>e.toJSON())]}}static parse(e){if(Array.isArray(e))return e.map(a=>this.parse(a));const{tag:t,props:i,children:s}=e,n=ar.get(t)??g.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},nA([S()],g.Node.prototype,"name",2),nA([S()],g.Node.prototype,"mask",2),nA([S({default:"inherit"})],g.Node.prototype,"processMode",2),nA([S({default:"default"})],g.Node.prototype,"processSortMode",2),nA([S({default:"inherit"})],g.Node.prototype,"renderMode",2),nA([S({default:"default"})],g.Node.prototype,"internalMode",2),nA([S({default:()=>({})})],g.Node.prototype,"meta",2),g.Node=nA([ne("Node")],g.Node);var ng=Object.defineProperty,og=Object.getOwnPropertyDescriptor,vi=(r,A,e,t)=>{for(var i=t>1?void 0:t?og(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ng(A,e,i),i};g.TimelineNode=class extends g.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 Vt(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?Vt(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),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},vi([S({default:0})],g.TimelineNode.prototype,"delay",2),vi([S({default:0})],g.TimelineNode.prototype,"duration",2),vi([S({default:!1})],g.TimelineNode.prototype,"paused",2),vi([Be()],g.TimelineNode.prototype,"insideTimeRange",2),g.TimelineNode=vi([ne("TimelineNode")],g.TimelineNode);var ag=Object.defineProperty,lg=Object.getOwnPropertyDescriptor,_i=(r,A,e,t)=>{for(var i=t>1?void 0:t?lg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ag(A,e,i),i};g.Viewport=class extends g.Node{constructor(e=!1){super();u(this,"_projection",new Xo);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new Ws,needsUpload:!1},{texture:new Ws,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(n=>{const o=n.texture;o.width=t,o.height=i,o.pixelRatio=s,o.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),this.upload(e),e.framebuffer.bind(this._glFramebuffer(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),fe.draw(e,OA.instance,{sampler:0}))}render(e,t){var s,n;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),(n=this._tree)==null||n.setCurrentViewport(void 0))}getRect(){return new Hs(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},_i([S({default:0})],g.Viewport.prototype,"x",2),_i([S({default:0})],g.Viewport.prototype,"y",2),_i([S({default:0})],g.Viewport.prototype,"width",2),_i([S({default:0})],g.Viewport.prototype,"height",2),g.Viewport=_i([ne("Viewport")],g.Viewport);var hg=Object.defineProperty,cg=Object.getOwnPropertyDescriptor,bi=(r,A,e,t)=>{for(var i=t>1?void 0:t?cg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&hg(A,e,i),i};g.Effect=class extends g.TimelineNode{constructor(e,t=[]){super();u(this,"viewport1",new g.Viewport);u(this,"viewport2",new g.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 n=new pr(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Gt.text.load(t).then(n=>this.glsl=n):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(){if(this.canProcess())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.canProcess()||!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 o,a;const e=(o=this._tree)==null?void 0:o.renderStack;if(!e)return;const t=(a=e.currentCall)==null?void 0:a.parentCall;if(!t)return;const i=t.calls;let s,n;i.forEach((l,h)=>{var c;(l.renderable.is(this._parent)||(c=l.renderable.parent)!=null&&c.is(this._parent))&&(s=s??h,n=h)}),!(s===void 0||n===void 0)&&(i.splice(n+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),fe.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,()=>{fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},bi([Be()],g.Effect.prototype,"material",2),bi([S()],g.Effect.prototype,"effectMode",2),bi([S({default:""})],g.Effect.prototype,"glsl",2),bi([S({default:""})],g.Effect.prototype,"glslSrc",2),g.Effect=bi([ne("Effect")],g.Effect);var wa=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,ug=(r,A,e)=>A in r?wa(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,Xt=(r,A,e,t)=>{for(var i=t>1?void 0:t?gg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&wa(A,e,i),i},fg=(r,A,e)=>ug(r,A+"",e);g.ColorAdjustEffect=class extends g.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}apply(A,e){e.redraw(A,()=>{fe.draw(A,g.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},fg(g.ColorAdjustEffect,"material",new Ce({vert:`precision mediump float;
|
|
113
|
+
}`,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(OA,"_instance");class fe extends Ir{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=OA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new gt({buffer:new qt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new gt({buffer:new qt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new LA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(fe,"_instance");class qc extends Ir{constructor(){const e=new qt({data:new Float32Array,dynamic:!0}),t=new qt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new gt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new gt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new LA({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var Xc=Object.defineProperty,HA=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&Xc(A,e,i),i};class _e 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=ys(this.realWidth)&&ys(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))}free(){fo&&this.source instanceof ImageBitmap&&this.source.close()}}HA([Be()],_e.prototype,"source"),HA([S({default:0})],_e.prototype,"width"),HA([S({default:0})],_e.prototype,"height"),HA([S({default:"linear"})],_e.prototype,"filterMode"),HA([S({default:"clamp_to_edge"})],_e.prototype,"wrapMode"),HA([S({default:1})],_e.prototype,"pixelRatio");class Er extends Yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof _e)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}free(){this.frames.forEach(e=>{e.texture.free()})}}var jc=Object.defineProperty,Zc=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&jc(A,e,i),i};class JA extends _e{constructor(A=document.createElement("canvas")){super(A)}_updateProperty(A,e,t,i){switch(A){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(A,e,t,i)}}Zc([S({default:2})],JA.prototype,"pixelRatio");class Ba extends _e{constructor(A){const e=new Wt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}class Br extends _e{static test(A){return wi(A)}static linearGradient(A,e,t){const i=document.createElement("canvas");i.width=e,i.height=t;const s=i.getContext("2d");if(!s)throw new Error("Failed to parse linear gradient, get canvas context is null.");let{angle:n=0,stops:o}=A;n-=Math.PI/2;const a=e/2,l=t/2,h=Math.sqrt(e*e+t*t)/2,c=a+h*Math.cos(n+Math.PI),f=l+h*Math.sin(n+Math.PI),I=a+h*Math.cos(n),d=l+h*Math.sin(n),C=s.createLinearGradient(c,f,I,d);o.forEach(M=>{C.addColorStop(M.offset,M.color)}),s.fillStyle=C,s.fillRect(0,0,i.width,i.height);const p=s.getImageData(0,0,i.width,i.height);return{width:p.width,height:p.height,pixels:new Uint8Array(p.data.buffer)}}constructor(A,e,t){super(Br.linearGradient(A,e,t))}}function $c(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&ws,crossorigin:(r==null?void 0:r.crossorigin)??null}}class eg extends _e{constructor(e,t){const i=$c(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,n=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!n,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)},n=o=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!ws)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(Ci&&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 Ys extends _e{constructor(A,e=1,t=1){const i={width:e,height:t,pixels:null};A&&(ArrayBuffer.isView(A)?i.pixels=new Uint8Array(A.buffer):i.pixels=new Uint8Array(A)),super(i)}_updateProperty(A,e,t,i){switch(A){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(A,e,t,i)}}var tg=Object.defineProperty,Ca=(r,A,e,t)=>{for(var i=void 0,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(A,e,i)||i);return i&&tg(A,e,i),i};function Ag(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),autoPlay:!!((r==null?void 0:r.autoPlay)??!1),fps:Number((r==null?void 0:r.fps)??0),crossorigin:(r==null?void 0:r.crossorigin)??null,loop:!!((r==null?void 0:r.loop)??!1),muted:!!((r==null?void 0:r.muted)??!1),playsinline:!!((r==null?void 0:r.playsinline)??!0)}}const zs=(kA=class extends _e{constructor(e,t){const i=Ag(t);if(!Qo(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],n=document.createElement("video");i.autoLoad&&n.setAttribute("preload","auto"),i.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),i.muted&&(n.setAttribute("muted",""),n.muted=!0),i.loop&&n.setAttribute("loop",""),i.autoPlay&&n.setAttribute("autoplay",""),_o(n,s,i.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const c=a.split("?").shift().toLowerCase(),f=c.slice(c.lastIndexOf(".")+1);l=l||kA.mimeTypes.get(f)||`video/${f}`}const h=document.createElement("source");h.src=a,l&&(h.type=l),n.appendChild(h)}e=n}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(Se.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&&(Se.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||(Se.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Se.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}free(){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(kA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),kA);Ca([Be({default:!0})],zs.prototype,"autoUpdate"),Ca([Be({default:0})],zs.prototype,"fps");let Qa=zs;class Ws extends Ys{}class ya extends Array{constructor(...e){super();u(this,"front",[]);u(this,"back",[]);this.set(e)}get internal(){return[...this.front,...this,...this.back]}set(e){return this.front.length=0,this.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){switch(e){case"front":return this.front;case"default":return this;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}}toJSON(){return[...this]}}var ig=Object.defineProperty,rg=Object.getOwnPropertyDescriptor,nA=(r,A,e,t)=>{for(var i=t>1?void 0:t?rg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ig(A,e,i),i};const ma={};function sg(r){let A=ma[r]??0;return A++,ma[r]=A,A}g.Node=class extends rA{constructor(e,t=[]){super();u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",new ya);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({name:`${this.tag}:${sg(this.tag)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...i}=e;if(t)for(const s in t)this.meta[s]=t[s];super.setProperties(i)}return this}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!=null&&e.is(t))){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const i=this._children.internal;for(let s=i.length,n=0;n<s;n++){const o=i[n];!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;i&&this.emit("unparented",i),this._parent=e,e&&this.emit("parented",e),this.setTree(e==null?void 0:e._tree)}return this}get children(){return this._children}set children(e){e instanceof ya?this._children=e:this._children.set(e)}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.children[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.children[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.children[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.children;return e?e[e.length-1]:void 0}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.processPaused;case"when_paused":return this._tree.processPaused;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}}_update(e){super._update(e)}_updateProperty(e,t,i,s){super._updateProperty(e,t,i,s)}_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(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(i){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof g.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),i&&(t.renderStack.currentCall=a),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){this._children.internal.forEach(i=>i.input(e,t)),this._input(e,t)}getIndex(){var e;return((e=this._parent)==null?void 0:e.children.getInternal(this.internalMode).indexOf(this))??0}getNode(e){return this._children.internal.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()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.moveChild(i,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.appendChild(i)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{var s;(s=this._parent)==null||s.moveChild(i,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;const s=this._children.getInternal(e.internalMode),n=s.indexOf(e),o=this._children.getInternal(i);return(e.internalMode!==i||t!==n)&&(n>-1&&s.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode=i,this}removeChild(e){const t=e.getIndex();return this.is(e.parent)&&t>-1&&(this._children.getInternal(e.internalMode).splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this._children.forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEachChild(e){return this._children.forEach(e),this}forEachDescendant(e){return this._children.forEach(t=>{e(t),t.forEachDescendant(e)}),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}clone(){return new this.constructor(this.toJSON().props,this._children.internal)}toJSON(){return{tag:this.tag,props:super.toJSON(),children:[...this._children.map(e=>e.toJSON())]}}static parse(e){if(Array.isArray(e))return e.map(a=>this.parse(a));const{tag:t,props:i,children:s}=e,n=ar.get(t)??g.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},nA([S()],g.Node.prototype,"name",2),nA([S()],g.Node.prototype,"mask",2),nA([S({default:"inherit"})],g.Node.prototype,"processMode",2),nA([S({default:"default"})],g.Node.prototype,"processSortMode",2),nA([S({default:"inherit"})],g.Node.prototype,"renderMode",2),nA([S({default:"default"})],g.Node.prototype,"internalMode",2),nA([S({default:()=>({})})],g.Node.prototype,"meta",2),g.Node=nA([ne("Node")],g.Node);var ng=Object.defineProperty,og=Object.getOwnPropertyDescriptor,vi=(r,A,e,t)=>{for(var i=t>1?void 0:t?og(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ng(A,e,i),i};g.TimelineNode=class extends g.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 Vt(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?Vt(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),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},vi([S({default:0})],g.TimelineNode.prototype,"delay",2),vi([S({default:0})],g.TimelineNode.prototype,"duration",2),vi([S({default:!1})],g.TimelineNode.prototype,"paused",2),vi([Be()],g.TimelineNode.prototype,"insideTimeRange",2),g.TimelineNode=vi([ne("TimelineNode")],g.TimelineNode);var ag=Object.defineProperty,lg=Object.getOwnPropertyDescriptor,_i=(r,A,e,t)=>{for(var i=t>1?void 0:t?lg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&ag(A,e,i),i};g.Viewport=class extends g.Node{constructor(e=!1){super();u(this,"_projection",new Xo);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new Ws,needsUpload:!1},{texture:new Ws,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(n=>{const o=n.texture;o.width=t,o.height=i,o.pixelRatio=s,o.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),this.upload(e),e.framebuffer.bind(this._glFramebuffer(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),fe.draw(e,OA.instance,{sampler:0}))}render(e,t){var s,n;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),(n=this._tree)==null||n.setCurrentViewport(void 0))}getRect(){return new Hs(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},_i([S({default:0})],g.Viewport.prototype,"x",2),_i([S({default:0})],g.Viewport.prototype,"y",2),_i([S({default:0})],g.Viewport.prototype,"width",2),_i([S({default:0})],g.Viewport.prototype,"height",2),g.Viewport=_i([ne("Viewport")],g.Viewport);var hg=Object.defineProperty,cg=Object.getOwnPropertyDescriptor,bi=(r,A,e,t)=>{for(var i=t>1?void 0:t?cg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&hg(A,e,i),i};g.Effect=class extends g.TimelineNode{constructor(e,t=[]){super();u(this,"viewport1",new g.Viewport);u(this,"viewport2",new g.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 n=new pr(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Gt.text.load(t).then(n=>this.glsl=n):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(){if(this.canProcess())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.canProcess()||!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 o,a;const e=(o=this._tree)==null?void 0:o.renderStack;if(!e)return;const t=(a=e.currentCall)==null?void 0:a.parentCall;if(!t)return;const i=t.calls;let s,n;i.forEach((l,h)=>{var c;(l.renderable.is(this._parent)||(c=l.renderable.parent)!=null&&c.is(this._parent))&&(s=s??h,n=h)}),!(s===void 0||n===void 0)&&(i.splice(n+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),fe.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,()=>{fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):fe.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},bi([Be()],g.Effect.prototype,"material",2),bi([S()],g.Effect.prototype,"effectMode",2),bi([S({default:""})],g.Effect.prototype,"glsl",2),bi([S({default:""})],g.Effect.prototype,"glslSrc",2),g.Effect=bi([ne("Effect")],g.Effect);var wa=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,ug=(r,A,e)=>A in r?wa(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,Xt=(r,A,e,t)=>{for(var i=t>1?void 0:t?gg(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=(t?n(A,e,i):n(i))||i);return t&&i&&wa(A,e,i),i},fg=(r,A,e)=>ug(r,A+"",e);g.ColorAdjustEffect=class extends g.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}apply(A,e){e.redraw(A,()=>{fe.draw(A,g.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},fg(g.ColorAdjustEffect,"material",new Ce({vert:`precision mediump float;
|
|
114
114
|
attribute vec2 position;
|
|
115
115
|
attribute vec2 uv;
|
|
116
116
|
varying vec2 vUv;
|
package/dist/index.mjs
CHANGED
|
@@ -242,10 +242,20 @@ function defineProperty(constructor, name, declaration = {}) {
|
|
|
242
242
|
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
243
243
|
Object.defineProperty(constructor.prototype, name, {
|
|
244
244
|
get() {
|
|
245
|
-
|
|
245
|
+
let value = descriptor.get?.call(this);
|
|
246
|
+
if (value === void 0) {
|
|
247
|
+
value = getDefaultValue();
|
|
248
|
+
if (value !== void 0) {
|
|
249
|
+
descriptor.set?.call(this, value);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return value;
|
|
246
253
|
},
|
|
247
254
|
set(value) {
|
|
248
|
-
|
|
255
|
+
let oldValue = descriptor.get?.call(this);
|
|
256
|
+
if (oldValue === void 0) {
|
|
257
|
+
oldValue = getDefaultValue();
|
|
258
|
+
}
|
|
249
259
|
descriptor.set?.call(this, value);
|
|
250
260
|
this.requestUpdate?.(name, oldValue, declaration);
|
|
251
261
|
},
|
|
@@ -6052,7 +6062,7 @@ let Node = class extends CoreObject {
|
|
|
6052
6062
|
removeChild(child) {
|
|
6053
6063
|
const index = child.getIndex();
|
|
6054
6064
|
if (this.is(child.parent) && index > -1) {
|
|
6055
|
-
this._children.
|
|
6065
|
+
this._children.getInternal(child.internalMode).splice(index, 1);
|
|
6056
6066
|
child.setParent(void 0);
|
|
6057
6067
|
this.emit("removeChild", child, index);
|
|
6058
6068
|
}
|