modern-canvas 0.4.31 → 0.4.32

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 CHANGED
@@ -6002,14 +6002,14 @@ exports.Node = class Node extends CoreObject {
6002
6002
  remove() {
6003
6003
  this._parent?.removeChild(this);
6004
6004
  }
6005
- forEach(fn) {
6006
- this.getChildren().forEach(fn);
6005
+ forEachChild(callbackfn) {
6006
+ this.getChildren().forEach(callbackfn);
6007
6007
  return this;
6008
6008
  }
6009
- deepForEach(fn) {
6009
+ forEachDescendant(callbackfn) {
6010
6010
  this.getChildren().forEach((child) => {
6011
- fn(child);
6012
- child.deepForEach(fn);
6011
+ callbackfn(child);
6012
+ child.forEachDescendant(callbackfn);
6013
6013
  });
6014
6014
  return this;
6015
6015
  }
@@ -7312,6 +7312,11 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
7312
7312
  requestRelayout() {
7313
7313
  this._relayouting = true;
7314
7314
  this.requestUpdate();
7315
+ this.forEachChild((node) => {
7316
+ if (node instanceof exports.CanvasItem) {
7317
+ node.requestRelayout();
7318
+ }
7319
+ });
7315
7320
  }
7316
7321
  requestRepaint() {
7317
7322
  this._repainting = true;
package/dist/index.d.cts CHANGED
@@ -1688,8 +1688,8 @@ declare class Node extends CoreObject {
1688
1688
  removeChild<T extends Node>(child: T): T;
1689
1689
  removeChildren(): void;
1690
1690
  remove(): void;
1691
- forEach(fn: (child: Node) => void): this;
1692
- deepForEach(fn: (descendant: Node) => void): this;
1691
+ forEachChild(callbackfn: (value: Node, index: number, array: Node[]) => void): this;
1692
+ forEachDescendant(callbackfn: (descendant: Node) => void): this;
1693
1693
  /** override */
1694
1694
  protected _ready(): void;
1695
1695
  protected _treeEnter(tree: SceneTree): void;
package/dist/index.d.mts CHANGED
@@ -1688,8 +1688,8 @@ declare class Node extends CoreObject {
1688
1688
  removeChild<T extends Node>(child: T): T;
1689
1689
  removeChildren(): void;
1690
1690
  remove(): void;
1691
- forEach(fn: (child: Node) => void): this;
1692
- deepForEach(fn: (descendant: Node) => void): this;
1691
+ forEachChild(callbackfn: (value: Node, index: number, array: Node[]) => void): this;
1692
+ forEachDescendant(callbackfn: (descendant: Node) => void): this;
1693
1693
  /** override */
1694
1694
  protected _ready(): void;
1695
1695
  protected _treeEnter(tree: SceneTree): void;
package/dist/index.d.ts CHANGED
@@ -1688,8 +1688,8 @@ declare class Node extends CoreObject {
1688
1688
  removeChild<T extends Node>(child: T): T;
1689
1689
  removeChildren(): void;
1690
1690
  remove(): void;
1691
- forEach(fn: (child: Node) => void): this;
1692
- deepForEach(fn: (descendant: Node) => void): this;
1691
+ forEachChild(callbackfn: (value: Node, index: number, array: Node[]) => void): this;
1692
+ forEachDescendant(callbackfn: (descendant: Node) => void): this;
1693
1693
  /** override */
1694
1694
  protected _ready(): void;
1695
1695
  protected _treeEnter(tree: SceneTree): void;
package/dist/index.js CHANGED
@@ -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(JA,"_instance");class ue extends ur{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=JA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new lt({buffer:new Vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new lt({buffer:new Vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new HA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(ue,"_instance");class rg extends ur{constructor(){const e=new Vt({data:new Float32Array,dynamic:!0}),t=new Vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new lt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new lt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new HA({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var sg=Object.defineProperty,KA=(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&&sg(A,e,i),i};class ve 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=Bs(this.realWidth)&&Bs(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(){ro&&this.source instanceof ImageBitmap&&this.source.close()}}KA([pe()],ve.prototype,"source"),KA([D({default:0})],ve.prototype,"width"),KA([D({default:0})],ve.prototype,"height"),KA([D({default:"linear"})],ve.prototype,"filterMode"),KA([D({default:"clamp_to_edge"})],ve.prototype,"wrapMode"),KA([D({default:1})],ve.prototype,"pixelRatio");class dr extends Yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof ve)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 ng=Object.defineProperty,og=(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&&ng(A,e,i),i};class YA extends ve{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)}}og([D({default:2})],YA.prototype,"pixelRatio");class Ts extends ve{constructor(A){const e=new zt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function ag(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&Cs,crossorigin:(r==null?void 0:r.crossorigin)??null}}class lg extends ve{constructor(e,t){const i=ag(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||!Cs)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(yi&&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 Ls extends ve{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 hg=Object.defineProperty,ia=(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&&hg(A,e,i),i};function gg(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 Gs=(FA=class extends ve{constructor(e,t){const i=gg(t);if(!ho(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",""),Io(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 g=a.split("?").shift().toLowerCase(),f=g.slice(g.lastIndexOf(".")+1);l=l||FA.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(xe.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&&(xe.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||(xe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(xe.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(FA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),FA);ia([pe({default:!0})],Gs.prototype,"autoUpdate"),ia([pe({default:0})],Gs.prototype,"fps");let ra=Gs;class Os extends Ls{}var cg=Object.defineProperty,ug=Object.getOwnPropertyDescriptor,wA=(r,A,e,t)=>{for(var i=t>1?void 0:t?ug(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&&cg(A,e,i),i};const sa={};function fg(r){let A=sa[r]??0;return A++,sa[r]=A,A}c.Node=class extends Kt{constructor(e,t=[]){super();u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.tag}:${fg(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)}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);for(let i=this._children.length,s=0;s<i;s++){const n=this._children[s];!e&&this.emit("childExitingTree",n),n.setTree(e),e&&this.emit("childEnteredTree",n)}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 siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return!this._tree.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=[];for(let l=this._children.length,h=0;h<l;h++){const g=this._children[h];switch(g.processSortMode){case"default":o.push(g);break;case"parent_before":n.push(g);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 c.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){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}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(!0))})}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(!0)+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex(!0)),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(n=>n.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let n=this._children.findIndex(l=>{switch(i){case"default":return l.internalMode!=="front";case"back":return l.internalMode==="back";case"front":default:return!0}});n=n>-1?n:Math.max(0,this._children.length-1);let o=this._children.slice(n).findIndex(l=>{switch(i){case"front":return l.internalMode!=="front";case"default":return l.internalMode==="back";case"back":default:return!1}});o=o>-1?n+o:Math.max(0,this._children.length);const a=xt(n,t>-1?t:o,o);return a!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),a>-1&&a<this._children.length?this._children.splice(a,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,a,s):this.emit("appendChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}_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.getChildren(!0))}toJSON(){return{tag:this.tag,props:{name:this.name,...super.toJSON()},meta:Object.fromEntries(this._meta.entries()),children:this.getChildren().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=lr.get(t)??c.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},wA([pe()],c.Node.prototype,"name",2),wA([D()],c.Node.prototype,"mask",2),wA([D({default:"inherit"})],c.Node.prototype,"processMode",2),wA([D({default:"default"})],c.Node.prototype,"processSortMode",2),wA([D({default:"inherit"})],c.Node.prototype,"renderMode",2),wA([D({default:"default"})],c.Node.prototype,"internalMode",2),c.Node=wA([te("Node")],c.Node);var dg=Object.defineProperty,Ig=Object.getOwnPropertyDescriptor,_i=(r,A,e,t)=>{for(var i=t>1?void 0:t?Ig(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&&dg(A,e,i),i};c.TimelineNode=class extends c.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 xt(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?xt(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()}},_i([D({default:0})],c.TimelineNode.prototype,"delay",2),_i([D({default:0})],c.TimelineNode.prototype,"duration",2),_i([D({default:!1})],c.TimelineNode.prototype,"paused",2),_i([pe()],c.TimelineNode.prototype,"insideTimeRange",2),c.TimelineNode=_i([te("TimelineNode")],c.TimelineNode);var pg=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,Di=(r,A,e,t)=>{for(var i=t>1?void 0:t?Bg(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&&pg(A,e,i),i};c.Viewport=class extends c.Node{constructor(e=!1){super();u(this,"_projection",new Uo);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new Os,needsUpload:!1},{texture:new Os,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),ue.draw(e,JA.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 ks(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Di([D({default:0})],c.Viewport.prototype,"x",2),Di([D({default:0})],c.Viewport.prototype,"y",2),Di([D({default:0})],c.Viewport.prototype,"width",2),Di([D({default:0})],c.Viewport.prototype,"height",2),c.Viewport=Di([te("Viewport")],c.Viewport);var Eg=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&&Eg(A,e,i),i};c.Effect=class extends c.TimelineNode{constructor(e,t=[]){super();u(this,"viewport1",new c.Viewport);u(this,"viewport2",new c.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 fr(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Tt.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 g;(l.renderable.is(this._parent)||(g=l.renderable.parent)!=null&&g.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),ue.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,()=>{ue.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):ue.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},bi([pe()],c.Effect.prototype,"material",2),bi([D()],c.Effect.prototype,"effectMode",2),bi([D({default:""})],c.Effect.prototype,"glsl",2),bi([D({default:""})],c.Effect.prototype,"glslSrc",2),c.Effect=bi([te("Effect")],c.Effect);var na=Object.defineProperty,Qg=Object.getOwnPropertyDescriptor,yg=(r,A,e)=>A in r?na(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,qt=(r,A,e,t)=>{for(var i=t>1?void 0:t?Qg(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&&na(A,e,i),i},mg=(r,A,e)=>yg(r,A+"",e);c.ColorAdjustEffect=class extends c.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}apply(A,e){e.redraw(A,()=>{ue.draw(A,c.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)})})}},mg(c.ColorAdjustEffect,"material",new Ee({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(JA,"_instance");class ue extends ur{static get instance(){return this._instance??(this._instance=new this)}static draw(A,e=JA.instance,t){this.instance.draw(A,e,t)}constructor(){super({vertexAttributes:{position:new lt({buffer:new Vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new lt({buffer:new Vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new HA({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(ue,"_instance");class rg extends ur{constructor(){const e=new Vt({data:new Float32Array,dynamic:!0}),t=new Vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new lt({buffer:e,size:2,normalized:!1,type:"float"}),uv:new lt({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new HA({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}}var sg=Object.defineProperty,KA=(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&&sg(A,e,i),i};class ve 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=Bs(this.realWidth)&&Bs(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(){ro&&this.source instanceof ImageBitmap&&this.source.close()}}KA([pe()],ve.prototype,"source"),KA([D({default:0})],ve.prototype,"width"),KA([D({default:0})],ve.prototype,"height"),KA([D({default:"linear"})],ve.prototype,"filterMode"),KA([D({default:"clamp_to_edge"})],ve.prototype,"wrapMode"),KA([D({default:1})],ve.prototype,"pixelRatio");class dr extends Yt{constructor(e){super();u(this,"frames");let t;if(Array.isArray(e))t=e;else if(e instanceof ve)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 ng=Object.defineProperty,og=(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&&ng(A,e,i),i};class YA extends ve{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)}}og([D({default:2})],YA.prototype,"pixelRatio");class Ts extends ve{constructor(A){const e=new zt(A);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function ag(r){return{autoLoad:!!((r==null?void 0:r.autoLoad)??!0),useBitmap:!!((r==null?void 0:r.useBitmap)??!0)&&Cs,crossorigin:(r==null?void 0:r.crossorigin)??null}}class lg extends ve{constructor(e,t){const i=ag(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||!Cs)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(yi&&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 Ls extends ve{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 hg=Object.defineProperty,ia=(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&&hg(A,e,i),i};function gg(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 Gs=(FA=class extends ve{constructor(e,t){const i=gg(t);if(!ho(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",""),Io(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 g=a.split("?").shift().toLowerCase(),f=g.slice(g.lastIndexOf(".")+1);l=l||FA.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(xe.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&&(xe.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||(xe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(xe.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(FA,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),FA);ia([pe({default:!0})],Gs.prototype,"autoUpdate"),ia([pe({default:0})],Gs.prototype,"fps");let ra=Gs;class Os extends Ls{}var cg=Object.defineProperty,ug=Object.getOwnPropertyDescriptor,wA=(r,A,e,t)=>{for(var i=t>1?void 0:t?ug(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&&cg(A,e,i),i};const sa={};function fg(r){let A=sa[r]??0;return A++,sa[r]=A,A}c.Node=class extends Kt{constructor(e,t=[]){super();u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.tag}:${fg(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)}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);for(let i=this._children.length,s=0;s<i;s++){const n=this._children[s];!e&&this.emit("childExitingTree",n),n.setTree(e),e&&this.emit("childEnteredTree",n)}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 siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return!this._tree.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=[];for(let l=this._children.length,h=0;h<l;h++){const g=this._children[h];switch(g.processSortMode){case"default":o.push(g);break;case"parent_before":n.push(g);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 c.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){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}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(!0))})}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(!0)+1)})}insertBefore(e,t){return!t.hasParent()||!this.is(t.parent)||this.moveChild(e,t.getIndex(!0)),e}appendChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return e;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(n=>n.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let n=this._children.findIndex(l=>{switch(i){case"default":return l.internalMode!=="front";case"back":return l.internalMode==="back";case"front":default:return!0}});n=n>-1?n:Math.max(0,this._children.length-1);let o=this._children.slice(n).findIndex(l=>{switch(i){case"front":return l.internalMode!=="front";case"default":return l.internalMode==="back";case"back":default:return!1}});o=o>-1?n+o:Math.max(0,this._children.length);const a=xt(n,t>-1?t:o,o);return a!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),a>-1&&a<this._children.length?this._children.splice(a,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,a,s):this.emit("appendChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEachChild(e){return this.getChildren().forEach(e),this}forEachDescendant(e){return this.getChildren().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.getChildren(!0))}toJSON(){return{tag:this.tag,props:{name:this.name,...super.toJSON()},meta:Object.fromEntries(this._meta.entries()),children:this.getChildren().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=lr.get(t)??c.Node,o=new n(i);return s==null||s.forEach(a=>o.appendChild(this.parse(a))),o}},wA([pe()],c.Node.prototype,"name",2),wA([D()],c.Node.prototype,"mask",2),wA([D({default:"inherit"})],c.Node.prototype,"processMode",2),wA([D({default:"default"})],c.Node.prototype,"processSortMode",2),wA([D({default:"inherit"})],c.Node.prototype,"renderMode",2),wA([D({default:"default"})],c.Node.prototype,"internalMode",2),c.Node=wA([te("Node")],c.Node);var dg=Object.defineProperty,Ig=Object.getOwnPropertyDescriptor,_i=(r,A,e,t)=>{for(var i=t>1?void 0:t?Ig(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&&dg(A,e,i),i};c.TimelineNode=class extends c.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 xt(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?xt(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()}},_i([D({default:0})],c.TimelineNode.prototype,"delay",2),_i([D({default:0})],c.TimelineNode.prototype,"duration",2),_i([D({default:!1})],c.TimelineNode.prototype,"paused",2),_i([pe()],c.TimelineNode.prototype,"insideTimeRange",2),c.TimelineNode=_i([te("TimelineNode")],c.TimelineNode);var pg=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,Di=(r,A,e,t)=>{for(var i=t>1?void 0:t?Bg(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&&pg(A,e,i),i};c.Viewport=class extends c.Node{constructor(e=!1){super();u(this,"_projection",new Uo);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new Os,needsUpload:!1},{texture:new Os,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),ue.draw(e,JA.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 ks(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Di([D({default:0})],c.Viewport.prototype,"x",2),Di([D({default:0})],c.Viewport.prototype,"y",2),Di([D({default:0})],c.Viewport.prototype,"width",2),Di([D({default:0})],c.Viewport.prototype,"height",2),c.Viewport=Di([te("Viewport")],c.Viewport);var Eg=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&&Eg(A,e,i),i};c.Effect=class extends c.TimelineNode{constructor(e,t=[]){super();u(this,"viewport1",new c.Viewport);u(this,"viewport2",new c.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 fr(t);!this.effectMode&&n.has.transition&&(this.effectMode="transition"),this.material=n;break}case"glslSrc":{t?Tt.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 g;(l.renderable.is(this._parent)||(g=l.renderable.parent)!=null&&g.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),ue.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,()=>{ue.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):ue.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},bi([pe()],c.Effect.prototype,"material",2),bi([D()],c.Effect.prototype,"effectMode",2),bi([D({default:""})],c.Effect.prototype,"glsl",2),bi([D({default:""})],c.Effect.prototype,"glslSrc",2),c.Effect=bi([te("Effect")],c.Effect);var na=Object.defineProperty,Qg=Object.getOwnPropertyDescriptor,yg=(r,A,e)=>A in r?na(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,qt=(r,A,e,t)=>{for(var i=t>1?void 0:t?Qg(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&&na(A,e,i),i},mg=(r,A,e)=>yg(r,A+"",e);c.ColorAdjustEffect=class extends c.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}apply(A,e){e.redraw(A,()=>{ue.draw(A,c.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)})})}},mg(c.ColorAdjustEffect,"material",new Ee({vert:`precision mediump float;
114
114
  attribute vec2 position;
115
115
  attribute vec2 uv;
116
116
  varying vec2 vUv;
@@ -273,7 +273,7 @@ void main(void) {
273
273
  }
274
274
  }
275
275
  }`})),Ks([D({default:[]})],c.ColorReplaceEffect.prototype,"colors",2),Ks([D({default:.05})],c.ColorReplaceEffect.prototype,"epsilon",2),c.ColorReplaceEffect=Ks([te("ColorReplaceEffect")],c.ColorReplaceEffect);function Ng(r,A,e=2){const t=A&&A.length,i=t?A[0]*e:r.length;let s=ca(r,0,i,e,!0);const n=[];if(!s||s.next===s.prev)return n;let o,a,l;if(t&&(s=Og(r,A,s,e)),r.length>80*e){o=1/0,a=1/0;let h=-1/0,g=-1/0;for(let f=e;f<i;f+=e){const I=r[f],d=r[f+1];I<o&&(o=I),d<a&&(a=d),I>h&&(h=I),d>g&&(g=d)}l=Math.max(h-o,g-a),l=l!==0?32767/l:0}return Mi(s,n,e,o,a,l,0),n}function ca(r,A,e,t,i){let s;if(i===Zg(r,A,e,t)>0)for(let n=A;n<e;n+=t)s=Ia(n/t|0,r[n],r[n+1],s);else for(let n=e-t;n>=A;n-=t)s=Ia(n/t|0,r[n],r[n+1],s);return s&&WA(s,s.next)&&(Ui(s),s=s.next),s}function vA(r,A){if(!r)return r;A||(A=r);let e=r,t;do if(t=!1,!e.steiner&&(WA(e,e.next)||ye(e.prev,e,e.next)===0)){if(Ui(e),e=A=e.prev,e===e.next)break;t=!0}else e=e.next;while(t||e!==A);return A}function Mi(r,A,e,t,i,s,n){if(!r)return;!n&&s&&Wg(r,t,i,s);let o=r;for(;r.prev!==r.next;){const a=r.prev,l=r.next;if(s?Tg(r,t,i,s):Fg(r)){A.push(a.i,r.i,l.i),Ui(r),r=l.next,o=l.next;continue}if(r=l,r===o){n?n===1?(r=Lg(vA(r),A),Mi(r,A,e,t,i,s,2)):n===2&&Gg(r,A,e,t,i,s):Mi(vA(r),A,e,t,i,s,1);break}}}function Fg(r){const A=r.prev,e=r,t=r.next;if(ye(A,e,t)>=0)return!1;const i=A.x,s=e.x,n=t.x,o=A.y,a=e.y,l=t.y,h=Math.min(i,s,n),g=Math.min(o,a,l),f=Math.max(i,s,n),I=Math.max(o,a,l);let d=t.next;for(;d!==A;){if(d.x>=h&&d.x<=f&&d.y>=g&&d.y<=I&&Ri(i,o,s,a,n,l,d.x,d.y)&&ye(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Tg(r,A,e,t){const i=r.prev,s=r,n=r.next;if(ye(i,s,n)>=0)return!1;const o=i.x,a=s.x,l=n.x,h=i.y,g=s.y,f=n.y,I=Math.min(o,a,l),d=Math.min(h,g,f),C=Math.max(o,a,l),p=Math.max(h,g,f),M=Ys(I,d,A,e,t),R=Ys(C,p,A,e,t);let _=r.prevZ,P=r.nextZ;for(;_&&_.z>=M&&P&&P.z<=R;){if(_.x>=I&&_.x<=C&&_.y>=d&&_.y<=p&&_!==i&&_!==n&&Ri(o,h,a,g,l,f,_.x,_.y)&&ye(_.prev,_,_.next)>=0||(_=_.prevZ,P.x>=I&&P.x<=C&&P.y>=d&&P.y<=p&&P!==i&&P!==n&&Ri(o,h,a,g,l,f,P.x,P.y)&&ye(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;_&&_.z>=M;){if(_.x>=I&&_.x<=C&&_.y>=d&&_.y<=p&&_!==i&&_!==n&&Ri(o,h,a,g,l,f,_.x,_.y)&&ye(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;P&&P.z<=R;){if(P.x>=I&&P.x<=C&&P.y>=d&&P.y<=p&&P!==i&&P!==n&&Ri(o,h,a,g,l,f,P.x,P.y)&&ye(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Lg(r,A){let e=r;do{const t=e.prev,i=e.next.next;!WA(t,i)&&fa(t,e,e.next,i)&&Pi(t,i)&&Pi(i,t)&&(A.push(t.i,e.i,i.i),Ui(e),Ui(e.next),e=r=i),e=e.next}while(e!==r);return vA(e)}function Gg(r,A,e,t,i,s){let n=r;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&qg(n,o)){let a=da(n,o);n=vA(n,n.next),a=vA(a,a.next),Mi(n,A,e,t,i,s,0),Mi(a,A,e,t,i,s,0);return}o=o.next}n=n.next}while(n!==r)}function Og(r,A,e,t){const i=[];for(let s=0,n=A.length;s<n;s++){const o=A[s]*t,a=s<n-1?A[s+1]*t:r.length,l=ca(r,o,a,t,!1);l===l.next&&(l.steiner=!0),i.push(Vg(l))}i.sort(Hg);for(let s=0;s<i.length;s++)e=Jg(i[s],e);return e}function Hg(r,A){let e=r.x-A.x;if(e===0&&(e=r.y-A.y,e===0)){const t=(r.next.y-r.y)/(r.next.x-r.x),i=(A.next.y-A.y)/(A.next.x-A.x);e=t-i}return e}function Jg(r,A){const e=Kg(r,A);if(!e)return A;const t=da(e,r);return vA(t,t.next),vA(e,e.next)}function Kg(r,A){let e=A;const t=r.x,i=r.y;let s=-1/0,n;if(WA(r,e))return e;do{if(WA(r,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const g=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(g<=t&&g>s&&(s=g,n=e.x<e.next.x?e:e.next,g===t))return n}e=e.next}while(e!==A);if(!n)return null;const o=n,a=n.x,l=n.y;let h=1/0;e=n;do{if(t>=e.x&&e.x>=a&&t!==e.x&&ua(i<l?t:s,i,a,l,i<l?s:t,i,e.x,e.y)){const g=Math.abs(i-e.y)/(t-e.x);Pi(e,r)&&(g<h||g===h&&(e.x>n.x||e.x===n.x&&Yg(n,e)))&&(n=e,h=g)}e=e.next}while(e!==o);return n}function Yg(r,A){return ye(r.prev,r,A.prev)<0&&ye(A.next,r,r.next)<0}function Wg(r,A,e,t){let i=r;do i.z===0&&(i.z=Ys(i.x,i.y,A,e,t)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,zg(i)}function zg(r){let A,e=1;do{let t=r,i;r=null;let s=null;for(A=0;t;){A++;let n=t,o=0;for(let l=0;l<e&&(o++,n=n.nextZ,!!n);l++);let a=e;for(;o>0||a>0&&n;)o!==0&&(a===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,o--):(i=n,n=n.nextZ,a--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,e*=2}while(A>1);return r}function Ys(r,A,e,t,i){return r=(r-e)*i|0,A=(A-t)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,r|A<<1}function Vg(r){let A=r,e=r;do(A.x<e.x||A.x===e.x&&A.y<e.y)&&(e=A),A=A.next;while(A!==r);return e}function ua(r,A,e,t,i,s,n,o){return(i-n)*(A-o)>=(r-n)*(s-o)&&(r-n)*(t-o)>=(e-n)*(A-o)&&(e-n)*(s-o)>=(i-n)*(t-o)}function Ri(r,A,e,t,i,s,n,o){return!(r===n&&A===o)&&ua(r,A,e,t,i,s,n,o)}function qg(r,A){return r.next.i!==A.i&&r.prev.i!==A.i&&!Xg(r,A)&&(Pi(r,A)&&Pi(A,r)&&jg(r,A)&&(ye(r.prev,r,A.prev)||ye(r,A.prev,A))||WA(r,A)&&ye(r.prev,r,r.next)>0&&ye(A.prev,A,A.next)>0)}function ye(r,A,e){return(A.y-r.y)*(e.x-A.x)-(A.x-r.x)*(e.y-A.y)}function WA(r,A){return r.x===A.x&&r.y===A.y}function fa(r,A,e,t){const i=pr(ye(r,A,e)),s=pr(ye(r,A,t)),n=pr(ye(e,t,r)),o=pr(ye(e,t,A));return!!(i!==s&&n!==o||i===0&&Ir(r,e,A)||s===0&&Ir(r,t,A)||n===0&&Ir(e,r,t)||o===0&&Ir(e,A,t))}function Ir(r,A,e){return A.x<=Math.max(r.x,e.x)&&A.x>=Math.min(r.x,e.x)&&A.y<=Math.max(r.y,e.y)&&A.y>=Math.min(r.y,e.y)}function pr(r){return r>0?1:r<0?-1:0}function Xg(r,A){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==A.i&&e.next.i!==A.i&&fa(e,e.next,r,A))return!0;e=e.next}while(e!==r);return!1}function Pi(r,A){return ye(r.prev,r,r.next)<0?ye(r,A,r.next)>=0&&ye(r,r.prev,A)>=0:ye(r,A,r.prev)<0||ye(r,r.next,A)<0}function jg(r,A){let e=r,t=!1;const i=(r.x+A.x)/2,s=(r.y+A.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(t=!t),e=e.next;while(e!==r);return t}function da(r,A){const e=Ws(r.i,r.x,r.y),t=Ws(A.i,A.x,A.y),i=r.next,s=A.prev;return r.next=A,A.prev=r,e.next=i,i.prev=e,t.next=e,e.prev=t,s.next=t,t.prev=s,t}function Ia(r,A,e,t){const i=Ws(r,A,e);return t?(i.next=t.next,i.prev=t,t.next.prev=i,t.next=i):(i.prev=i,i.next=i),i}function Ui(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Ws(r,A,e){return{i:r,x:A,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Zg(r,A,e,t){let i=0;for(let s=A,n=e-t;s<e;s+=t)i+=(r[n]-r[s])*(r[s+1]+r[n+1]),n=s;return i}function $g(r,A,e,t={}){const{radius:i=1}=t;r.moveTo(A,e),r.arc(A,e,i,0,Math.PI*2)}const ec={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function zs(r,A){const{fill:e="#000",stroke:t="none",strokeWidth:i=t==="none"?0:1,strokeLinecap:s="round",strokeLinejoin:n="miter",strokeMiterlimit:o=0,strokeDasharray:a=[],strokeDashoffset:l=0,shadowOffsetX:h=0,shadowOffsetY:g=0,shadowBlur:f=0,shadowColor:I="rgba(0, 0, 0, 0)"}=A;r.fillStyle=e,r.strokeStyle=t,r.lineWidth=i,r.lineCap=s,r.lineJoin=ec[n],r.miterLimit=o,r.setLineDash(a),r.lineDashOffset=l,r.shadowOffsetX=h,r.shadowOffsetY=g,r.shadowBlur=f,r.shadowColor=I}class F{constructor(A=0,e=0){this.x=A,this.y=e}static get MAX(){return new F(1/0,1/0)}static get MIN(){return new F(-1/0,-1/0)}get array(){return[this.x,this.y]}set(A,e){return this.x=A,this.y=e,this}add(A){return this.x+=A.x,this.y+=A.y,this}sub(A){return this.x-=A.x,this.y-=A.y,this}multiply(A){return this.x*=A.x,this.y*=A.y,this}divide(A){return this.x/=A.x,this.y/=A.y,this}dot(A){return this.x*A.x+this.y*A.y}cross(A){return this.x*A.y-this.y*A.x}rotate(A,e={x:0,y:0}){const t=-A/180*Math.PI,i=this.x-e.x,s=-(this.y-e.y),n=Math.sin(t),o=Math.cos(t);return this.set(e.x+(i*o-s*n),e.y-(i*n+s*o)),this}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){const e=this.x-A.x,t=this.y-A.y;return e*e+t*t}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(A,e=A,t={x:0,y:0}){const i=A<0?t.x-this.x+t.x:this.x,s=e<0?t.y-this.y+t.y:this.y;return this.x=i*Math.abs(A),this.y=s*Math.abs(e),this}skew(A,e=0,t={x:0,y:0}){const i=this.x-t.x,s=this.y-t.y;return this.x=t.x+(i+Math.tan(A)*s),this.y=t.y+(s+Math.tan(e)*i),this}min(...A){return this.x=Math.min(this.x,...A.map(e=>e.x)),this.y=Math.min(this.y,...A.map(e=>e.y)),this}max(...A){return this.x=Math.max(this.x,...A.map(e=>e.x)),this.y=Math.max(this.y,...A.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(A,e){return this.x=A.x+e.x,this.y=A.y+e.y,this}subVectors(A,e){return this.x=A.x-e.x,this.y=A.y-e.y,this}multiplyVectors(A,e){return this.x=A.x*e.x,this.y=A.y*e.y,this}divideVectors(A,e){return this.x=A.x/e.x,this.y=A.y/e.y,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this}equals(A){return this.x===A.x&&this.y===A.y}applyMatrix3(A){const e=this.x,t=this.y,i=A.elements;return this.x=i[0]*e+i[3]*t+i[6],this.y=i[1]*e+i[4]*t+i[7],this}copy(A){return this.x=A.x,this.y=A.y,this}clone(){return new F(this.x,this.y)}}class he{constructor(A=0,e=0,t=0,i=0){this.left=A,this.top=e,this.width=t,this.height=i}get x(){return this.left}set x(A){this.left=A}get y(){return this.top}set y(A){this.top=A}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new F((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...A){if(A.length===0)return new he;if(A.length===1)return A[0].clone();const e=A[0],t=A.slice(1).reduce((i,s)=>(i.left=Math.min(i.left,s.left),i.top=Math.min(i.top,s.top),i.right=Math.max(i.right,s.right),i.bottom=Math.max(i.bottom,s.bottom),i),{left:(e==null?void 0:e.left)??0,top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0});return new he(t.left,t.top,t.right-t.left,t.bottom-t.top)}translate(A,e){return this.left+=A,this.top+=e,this}copy(A){return this.left=A.left,this.top=A.top,this.width=A.width,this.height=A.height,this}clone(){return new he(this.left,this.top,this.width,this.height)}}class Je{constructor(A=1,e=0,t=0,i=0,s=1,n=0,o=0,a=0,l=1){u(this,"elements",[]);this.set(A,e,t,i,s,n,o,a,l)}set(A,e,t,i,s,n,o,a,l){const h=this.elements;return h[0]=A,h[1]=i,h[2]=o,h[3]=e,h[4]=s,h[5]=a,h[6]=t,h[7]=n,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){const e=this.elements,t=A.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,e){const t=A.elements,i=e.elements,s=this.elements,n=t[0],o=t[3],a=t[6],l=t[1],h=t[4],g=t[7],f=t[2],I=t[5],d=t[8],C=i[0],p=i[3],M=i[6],R=i[1],_=i[4],P=i[7],v=i[2],w=i[5],b=i[8];return s[0]=n*C+o*R+a*v,s[3]=n*p+o*_+a*w,s[6]=n*M+o*P+a*b,s[1]=l*C+h*R+g*v,s[4]=l*p+h*_+g*w,s[7]=l*M+h*P+g*b,s[2]=f*C+I*R+d*v,s[5]=f*p+I*_+d*w,s[8]=f*M+I*P+d*b,this}invert(){const A=this.elements,e=A[0],t=A[1],i=A[2],s=A[3],n=A[4],o=A[5],a=A[6],l=A[7],h=A[8],g=h*n-o*l,f=o*a-h*s,I=l*s-n*a,d=e*g+t*f+i*I;if(d===0)return this.set(0,0,0,0,0,0,0,0,0);const C=1/d;return A[0]=g*C,A[1]=(i*l-h*t)*C,A[2]=(o*t-i*n)*C,A[3]=f*C,A[4]=(h*e-i*a)*C,A[5]=(i*s-o*e)*C,A[6]=I*C,A[7]=(t*a-l*e)*C,A[8]=(n*e-t*s)*C,this}transpose(){let A;const e=this.elements;return A=e[1],e[1]=e[3],e[3]=A,A=e[2],e[2]=e[6],e[6]=A,A=e[5],e[5]=e[7],e[7]=A,this}scale(A,e){return this.premultiply(Vs.makeScale(A,e)),this}rotate(A){return this.premultiply(Vs.makeRotation(-A)),this}translate(A,e){return this.premultiply(Vs.makeTranslation(A,e)),this}makeTranslation(A,e){return this.set(1,0,A,0,1,e,0,0,1),this}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set(e,-t,0,t,e,0,0,0,1),this}makeScale(A,e){return this.set(A,0,0,0,e,0,0,0,1),this}fromArray(A,e=0){for(let t=0;t<9;t++)this.elements[t]=A[t+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Vs=new Je;function pa(r,A,e,t){const i=r*e+A*t,s=Math.sqrt(r*r+A*A)*Math.sqrt(e*e+t*t);let n=Math.acos(Math.max(-1,Math.min(1,i/s)));return r*t-A*e<0&&(n=-n),n}function tc(r,A,e,t,i,s,n,o){if(A===0||e===0){r.lineTo(o.x,o.y);return}t=t*Math.PI/180,A=Math.abs(A),e=Math.abs(e);const a=(n.x-o.x)/2,l=(n.y-o.y)/2,h=Math.cos(t)*a+Math.sin(t)*l,g=-Math.sin(t)*a+Math.cos(t)*l;let f=A*A,I=e*e;const d=h*h,C=g*g,p=d/f+C/I;if(p>1){const $=Math.sqrt(p);A=$*A,e=$*e,f=A*A,I=e*e}const M=f*C+I*d,R=(f*I-M)/M;let _=Math.sqrt(Math.max(0,R));i===s&&(_=-_);const P=_*A*g/e,v=-_*e*h/A,w=Math.cos(t)*P-Math.sin(t)*v+(n.x+o.x)/2,b=Math.sin(t)*P+Math.cos(t)*v+(n.y+o.y)/2,S=pa(1,0,(h-P)/A,(g-v)/e),L=pa((h-P)/A,(g-v)/e,(-h-P)/A,(-g-v)/e)%(Math.PI*2);r.ellipse(w,b,A,e,t,S,S+L,s===0)}const _e={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function St(r,A,e=0){let o=0,a=!0,l="",h="";const g=[];function f(p,M,R){const _=new SyntaxError(`Unexpected character "${p}" at index ${M}.`);throw _.partial=R,_}function I(){l!==""&&(h===""?g.push(Number(l)):g.push(Number(l)*10**Number(h))),l="",h=""}let d;const C=r.length;for(let p=0;p<C;p++){if(d=r[p],Array.isArray(A)&&A.includes(g.length%e)&&_e.FLAGS.test(d)){o=1,l=d,I();continue}if(o===0){if(_e.WHITESPACE.test(d))continue;if(_e.DIGIT.test(d)||_e.SIGN.test(d)){o=1,l=d;continue}if(_e.POINT.test(d)){o=2,l=d;continue}_e.COMMA.test(d)&&(a&&f(d,p,g),a=!0)}if(o===1){if(_e.DIGIT.test(d)){l+=d;continue}if(_e.POINT.test(d)){l+=d,o=2;continue}if(_e.EXP.test(d)){o=3;continue}_e.SIGN.test(d)&&l.length===1&&_e.SIGN.test(l[0])&&f(d,p,g)}if(o===2){if(_e.DIGIT.test(d)){l+=d;continue}if(_e.EXP.test(d)){o=3;continue}_e.POINT.test(d)&&l[l.length-1]==="."&&f(d,p,g)}if(o===3){if(_e.DIGIT.test(d)){h+=d;continue}if(_e.SIGN.test(d)){if(h===""){h+=d;continue}h.length===1&&_e.SIGN.test(h)&&f(d,p,g)}}_e.WHITESPACE.test(d)?(I(),o=0,a=!1):_e.COMMA.test(d)?(I(),o=0,a=!0):_e.SIGN.test(d)?(I(),o=1,l=d):_e.POINT.test(d)?(I(),o=2,l=d):f(d,p,g)}return I(),g}function zA(r,A){return r-(A-r)}function Ba(r,A){const e=new F,t=new F;for(let i=0,s=r.length;i<s;i++){const n=r[i];if(n.type==="m"||n.type==="M")n.type==="m"?e.add(n):e.copy(n),A.moveTo(e.x,e.y),t.copy(e);else if(n.type==="h"||n.type==="H")n.type==="h"?e.x+=n.x:e.x=n.x,A.lineTo(e.x,e.y),t.copy(e);else if(n.type==="v"||n.type==="V")n.type==="v"?e.y+=n.y:e.y=n.y,A.lineTo(e.x,e.y),t.copy(e);else if(n.type==="l"||n.type==="L")n.type==="l"?e.add(n):e.copy(n),A.lineTo(e.x,e.y),t.copy(e);else if(n.type==="c"||n.type==="C")n.type==="c"?(A.bezierCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),t.x=e.x+n.x2,t.y=e.y+n.y2,e.add(n)):(A.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),t.x=n.x2,t.y=n.y2,e.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(A.bezierCurveTo(zA(e.x,t.x),zA(e.y,t.y),e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),t.x=e.x+n.x2,t.y=e.y+n.y2,e.add(n)):(A.bezierCurveTo(zA(e.x,t.x),zA(e.y,t.y),n.x2,n.y2,n.x,n.y),t.x=n.x2,t.y=n.y2,e.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(A.quadraticCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x,e.y+n.y),t.x=e.x+n.x1,t.y=e.y+n.y1,e.add(n)):(A.quadraticCurveTo(n.x1,n.y1,n.x,n.y),t.x=n.x1,t.y=n.y1,e.copy(n));else if(n.type==="t"||n.type==="T"){const o=zA(e.x,t.x),a=zA(e.y,t.y);t.x=o,t.y=a,n.type==="t"?(A.quadraticCurveTo(o,a,e.x+n.x,e.y+n.y),e.add(n)):(A.quadraticCurveTo(o,a,n.x,n.y),e.copy(n))}else if(n.type==="a"||n.type==="A"){const o=e.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;e.add(n)}else{if(e.equals(n))continue;e.copy(n)}t.copy(e),tc(A,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,o,e)}else n.type==="z"||n.type==="Z"?(A.startPoint&&e.copy(A.startPoint),A.closePath()):console.warn("Unsupported commands",n)}}function Ac(r){let A,e;const t=[];for(let i=0,s=r.length;i<s;i++){const n=r[i];switch(n.type){case"m":case"M":if(n.x.toFixed(4)===(e==null?void 0:e.x.toFixed(4))&&n.y.toFixed(4)===(e==null?void 0:e.y.toFixed(4)))continue;t.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y},A={x:n.x,y:n.y};break;case"h":case"H":t.push(`${n.type} ${n.x}`),e={x:n.x,y:(e==null?void 0:e.y)??0};break;case"v":case"V":t.push(`${n.type} ${n.y}`),e={x:(e==null?void 0:e.x)??0,y:n.y};break;case"l":case"L":t.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"c":case"C":t.push(`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"s":case"S":t.push(`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"q":case"Q":t.push(`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"t":case"T":t.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"a":case"A":t.push(`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"z":case"Z":t.push(n.type),A&&(e={x:A.x,y:A.y});break}}return t.join(" ")}const ic=/[a-df-z][^a-df-z]*/gi;function Ea(r){const A=[],e=r.match(ic);if(!e)return A;for(let t=0,i=e.length;t<i;t++){const s=e[t],n=s.charAt(0),o=s.slice(1).trim();let a;switch(n){case"m":case"M":a=St(o);for(let l=0,h=a.length;l<h;l+=2)l===0?A.push({type:n,x:a[l],y:a[l+1]}):A.push({type:n==="m"?"l":"L",x:a[l],y:a[l+1]});break;case"h":case"H":a=St(o);for(let l=0,h=a.length;l<h;l++)A.push({type:n,x:a[l]});break;case"v":case"V":a=St(o);for(let l=0,h=a.length;l<h;l++)A.push({type:n,y:a[l]});break;case"l":case"L":a=St(o);for(let l=0,h=a.length;l<h;l+=2)A.push({type:n,x:a[l],y:a[l+1]});break;case"c":case"C":a=St(o);for(let l=0,h=a.length;l<h;l+=6)A.push({type:n,x1:a[l],y1:a[l+1],x2:a[l+2],y2:a[l+3],x:a[l+4],y:a[l+5]});break;case"s":case"S":a=St(o);for(let l=0,h=a.length;l<h;l+=4)A.push({type:n,x2:a[l],y2:a[l+1],x:a[l+2],y:a[l+3]});break;case"q":case"Q":a=St(o);for(let l=0,h=a.length;l<h;l+=4)A.push({type:n,x1:a[l],y1:a[l+1],x:a[l+2],y:a[l+3]});break;case"t":case"T":a=St(o);for(let l=0,h=a.length;l<h;l+=2)A.push({type:n,x:a[l],y:a[l+1]});break;case"a":case"A":a=St(o,[3,4],7);for(let l=0,h=a.length;l<h;l+=7)A.push({type:n,rx:a[l],ry:a[l+1],angle:a[l+2],largeArcFlag:a[l+3],sweepFlag:a[l+4],x:a[l+5],y:a[l+6]});break;case"z":case"Z":A.push({type:n});break;default:console.warn(s)}}return A}function Ca(r,A,e,t,i){const s=(t-A)*.5,n=(i-e)*.5,o=r*r,a=r*o;return(2*e-2*t+s+n)*a+(-3*e+3*t-2*s-n)*o+s*r+e}function rc(r,A){const e=1-r;return e*e*e*A}function sc(r,A){const e=1-r;return 3*e*e*r*A}function nc(r,A){return 3*(1-r)*r*r*A}function oc(r,A){return r*r*r*A}function Qa(r,A,e,t,i){return rc(r,A)+sc(r,e)+nc(r,t)+oc(r,i)}function ya(r,A={}){let{vertices:e=[],indices:t=[],holes:i=[],verticesStride:s=2,verticesOffset:n=e.length/s,indicesOffset:o=t.length}=A;const a=Ng(r,i,2);if(a){for(let h=0;h<a.length;h+=3)t[o++]=a[h]+n,t[o++]=a[h+1]+n,t[o++]=a[h+2]+n;let l=n*s;for(let h=0;h<r.length;h+=2)e[l]=r[h],e[l+1]=r[h+1],l+=s}return{vertices:e,indices:t}}const ac=8,Br=11920929e-14,lc=1;function hc(r,A,e,t,i,s,n,o,a=.5,l=[]){const g=Math.min(.99,Math.max(0,a));let f=(lc-g)/1;return f*=f,qs(r,A,e,t,i,s,n,o,l,f,0),l.push(n,o),l}function qs(r,A,e,t,i,s,n,o,a,l,h){if(h>ac)return;const g=(r+e)/2,f=(A+t)/2,I=(e+i)/2,d=(t+s)/2,C=(i+n)/2,p=(s+o)/2,M=(g+I)/2,R=(f+d)/2,_=(I+C)/2,P=(d+p)/2,v=(M+_)/2,w=(R+P)/2;if(h>0){let b=n-r,S=o-A;const L=Math.abs((e-n)*S-(t-o)*b),$=Math.abs((i-n)*S-(s-o)*b);if(L>Br&&$>Br){if((L+$)*(L+$)<=l*(b*b+S*S)){a.push(v,w);return}}else if(L>Br){if(L*L<=l*(b*b+S*S)){a.push(v,w);return}}else if($>Br){if($*$<=l*(b*b+S*S)){a.push(v,w);return}}else if(b=v-(r+n)/2,S=w-(A+o)/2,b*b+S*S<=l){a.push(v,w);return}}qs(r,A,g,f,M,R,v,w,a,l,h+1),qs(v,w,_,P,C,p,n,o,a,l,h+1)}const gc=8,cc=11920929e-14,uc=1;function fc(r,A,e,t,i,s,n=.5,o=[]){const l=Math.min(.99,Math.max(0,n));let h=(uc-l)/1;return h*=h,Xs(o,r,A,e,t,i,s,h,0),o.push(i,s),o}function Xs(r,A,e,t,i,s,n,o,a){if(a>gc)return;const l=(A+t)/2,h=(e+i)/2,g=(t+s)/2,f=(i+n)/2,I=(l+g)/2,d=(h+f)/2;let C=s-A,p=n-e;const M=Math.abs((t-s)*p-(i-n)*C);if(M>cc){if(M*M<=o*(C*C+p*p)){r.push(I,d);return}}else if(C=I-(A+s)/2,p=d-(e+n)/2,C*C+p*p<=o){r.push(I,d);return}Xs(r,A,e,l,h,I,d,o,a+1),Xs(r,I,d,g,f,s,n,o,a+1)}function dc(r,A){const e=1-r;return e*e*A}function Ic(r,A){return 2*(1-r)*r*A}function pc(r,A){return r*r*A}function ma(r,A,e,t){return dc(r,A)+Ic(r,e)+pc(r,t)}const Bc=1e-4,wa=1e-4;function Ec(r,A={}){const{vertices:e=[],indices:t=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:s=!1,closed:n=!0}=A,o=Bc;if(r.length===0)return{vertices:e,indices:t};const a=i;let l=a.alignment;if(i.alignment!==.5){let q=Cc(r);s&&(q*=-1),l=(l-.5)*q+.5}const h={x:r[0],y:r[1]},g={x:r[r.length-2],y:r[r.length-1]},f=n,I=Math.abs(h.x-g.x)<o&&Math.abs(h.y-g.y)<o;if(f){r=r.slice(),I&&(r.pop(),r.pop(),g.x=r[r.length-2],g.y=r[r.length-1]);const q=(h.x+g.x)*.5,j=(g.y+h.y)*.5;r.unshift(q,j),r.push(q,j)}const d=e,C=r.length/2;let p=r.length;const M=d.length/2,R=a.width/2,_=R*R,P=a.miterLimit*a.miterLimit;let v=r[0],w=r[1],b=r[2],S=r[3],L=0,$=0,K=-(w-S),J=v-b,Z=0,Y=0,O=Math.sqrt(K*K+J*J);K/=O,J/=O,K*=R,J*=R;const Ae=l,G=(1-Ae)*2,W=Ae*2;f||(a.cap==="round"?p+=_A(v-K*(G-W)*.5,w-J*(G-W)*.5,v-K*G,w-J*G,v+K*W,w+J*W,d,!0)+2:a.cap==="square"&&(p+=va(v,w,K,J,G,W,!0,d))),d.push(v-K*G,w-J*G),d.push(v+K*W,w+J*W);for(let q=1;q<C-1;++q){v=r[(q-1)*2],w=r[(q-1)*2+1],b=r[q*2],S=r[q*2+1],L=r[(q+1)*2],$=r[(q+1)*2+1],K=-(w-S),J=v-b,O=Math.sqrt(K*K+J*J),K/=O,J/=O,K*=R,J*=R,Z=-(S-$),Y=b-L,O=Math.sqrt(Z*Z+Y*Y),Z/=O,Y/=O,Z*=R,Y*=R;const j=b-v,se=w-S,X=b-L,ae=$-S,ie=j*X+se*ae,le=se*X-ae*j,z=le<0;if(Math.abs(le)<.001*Math.abs(ie)){d.push(b-K*G,S-J*G),d.push(b+K*W,S+J*W),ie>=0&&(a.join==="round"?p+=_A(b,S,b-K*G,S-J*G,b-Z*G,S-Y*G,d,!1)+4:p+=2,d.push(b-Z*W,S-Y*W),d.push(b+Z*G,S+Y*G));continue}const Ie=(-K+v)*(-J+S)-(-K+b)*(-J+w),nt=(-Z+L)*(-Y+S)-(-Z+b)*(-Y+$),ot=(j*nt-X*Ie)/le,Oe=(ae*Ie-se*nt)/le,ge=(ot-b)*(ot-b)+(Oe-S)*(Oe-S),me=b+(ot-b)*G,He=S+(Oe-S)*G,ze=b-(ot-b)*W,be=S-(Oe-S)*W,$e=Math.min(j*j+se*se,X*X+ae*ae),Gt=z?G:W,os=$e+Gt*Gt*_;ge<=os?a.join==="bevel"||ge/_>P?(z?(d.push(me,He),d.push(b+K*W,S+J*W),d.push(me,He),d.push(b+Z*W,S+Y*W)):(d.push(b-K*G,S-J*G),d.push(ze,be),d.push(b-Z*G,S-Y*G),d.push(ze,be)),p+=2):a.join==="round"?z?(d.push(me,He),d.push(b+K*W,S+J*W),p+=_A(b,S,b+K*W,S+J*W,b+Z*W,S+Y*W,d,!0)+4,d.push(me,He),d.push(b+Z*W,S+Y*W)):(d.push(b-K*G,S-J*G),d.push(ze,be),p+=_A(b,S,b-K*G,S-J*G,b-Z*G,S-Y*G,d,!1)+4,d.push(b-Z*G,S-Y*G),d.push(ze,be)):(d.push(me,He),d.push(ze,be)):(d.push(b-K*G,S-J*G),d.push(b+K*W,S+J*W),a.join==="round"?z?p+=_A(b,S,b+K*W,S+J*W,b+Z*W,S+Y*W,d,!0)+2:p+=_A(b,S,b-K*G,S-J*G,b-Z*G,S-Y*G,d,!1)+2:a.join==="miter"&&ge/_<=P&&(z?(d.push(ze,be),d.push(ze,be)):(d.push(me,He),d.push(me,He)),p+=2),d.push(b-Z*G,S-Y*G),d.push(b+Z*W,S+Y*W),p+=2)}v=r[(C-2)*2],w=r[(C-2)*2+1],b=r[(C-1)*2],S=r[(C-1)*2+1],K=-(w-S),J=v-b,O=Math.sqrt(K*K+J*J),K/=O,J/=O,K*=R,J*=R,d.push(b-K*G,S-J*G),d.push(b+K*W,S+J*W),f||(a.cap==="round"?p+=_A(b-K*(G-W)*.5,S-J*(G-W)*.5,b-K*G,S-J*G,b+K*W,S+J*W,d,!1)+2:a.cap==="square"&&(p+=va(b,S,K,J,G,W,!1,d)));const oe=wa*wa;for(let q=M;q<p+M-2;++q)v=d[q*2],w=d[q*2+1],b=d[(q+1)*2],S=d[(q+1)*2+1],L=d[(q+2)*2],$=d[(q+2)*2+1],!(Math.abs(v*(S-$)+b*($-w)+L*(w-S))<oe)&&t.push(q,q+1,q+2);return{vertices:e,indices:t}}function Cc(r){const A=r.length;if(A<6)return 1;let e=0;for(let t=0,i=r[A-2],s=r[A-1];t<A;t+=2){const n=r[t],o=r[t+1];e+=(n-i)*(o+s),i=n,s=o}return e<0?-1:1}function va(r,A,e,t,i,s,n,o){const a=r-e*i,l=A-t*i,h=r+e*s,g=A+t*s;let f,I;n?(f=t,I=-e):(f=-t,I=e);const d=a+f,C=l+I,p=h+f,M=g+I;return o.push(d,C),o.push(p,M),2}function _A(r,A,e,t,i,s,n,o){const a=e-r,l=t-A;let h=Math.atan2(a,l),g=Math.atan2(i-r,s-A);o&&h<g?h+=Math.PI*2:!o&&h>g&&(g+=Math.PI*2);let f=h;const I=g-h,d=Math.abs(I),C=Math.sqrt(a*a+l*l),p=(15*d*Math.sqrt(C)/Math.PI>>0)+1,M=I/p;if(f+=M,o){n.push(r,A),n.push(e,t);for(let R=1,_=f;R<p;R++,_+=M)n.push(r,A),n.push(r+Math.sin(_)*C,A+Math.cos(_)*C);n.push(r,A),n.push(i,s)}else{n.push(e,t),n.push(r,A);for(let R=1,_=f;R<p;R++,_+=M)n.push(r+Math.sin(_)*C,A+Math.cos(_)*C),n.push(r,A);n.push(i,s),n.push(r,A)}return p*2}class VA{constructor(){u(this,"arcLengthDivision",200);u(this,"_arcLengths")}getPointAt(A,e=new F){return this.getPoint(this.getUToTMapping(A),e)}isClockwise(){const A=this.getPoint(1),e=this.getPoint(.5),t=this.getPoint(1);return(e.x-A.x)*(t.y-e.y)-(e.y-A.y)*(t.x-e.x)<0}getControlPointRefs(){return[]}applyTransform(A){return this.getControlPointRefs().forEach(e=>{e.applyMatrix3(A)}),this}getUnevenPointArray(A=5,e=[]){const t=new F;for(let i=0,s=Math.max(1,A)-1;i<=s;i++)this.getPoint(i/s,t),e.push(t.x,t.y);return e}getSpacedPointArray(A=5,e=[]){const t=new F;for(let i=0,s=Math.max(1,A)-1;i<=s;i++)this.getPointAt(i/s,t),e.push(t.x,t.y);return e}getAdaptivePointArray(A=[]){return this.getUnevenPointArray(5,A)}_pointArrayToPoint(A,e=[]){for(let t=0,i=A.length;t<i;t+=2){const s=A[t],n=A[t+1];e.push(new F(s,n))}return e}getSpacedPoints(A,e=[]){const t=this.getSpacedPointArray(A);return this._pointArrayToPoint(t,e),e}getUnevenPoints(A,e=[]){const t=this.getUnevenPointArray(A);return this._pointArrayToPoint(t,e),e}getAdaptivePoints(A=[]){const e=this.getAdaptivePointArray();return this._pointArrayToPoint(e,A),A}getPoints(A,e=[]){let t;return A?t=this.getUnevenPointArray(A):t=this.getAdaptivePointArray(),this._pointArrayToPoint(t,e),e}getLength(){const A=this.getLengths();return A[A.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const A=this.arcLengthDivision,e=[0];for(let t=0,i=this.getPoint(0),s=1;s<=A;s++){const n=this.getPoint(s/A);t+=n.distanceTo(i),e.push(t),i=n}this._arcLengths=e}getUToTMapping(A,e){const t=this.getLengths(),i=t.length,s=e??A*t[i-1];if(i<2)return s/t[0];let n=0,o=0,a=i-1,l;for(;o<=a;)if(n=Math.floor(o+(a-o)/2),l=t[n]-s,l<0)o=n+1;else if(l>0)a=n-1;else{a=n;break}if(n=a,t[n]===s)return n/(i-1);const h=t[n],f=t[n+1]-h,I=(s-h)/f;return(n+I)/(i-1)}getTangent(A,e=new F){const i=Math.max(0,A-1e-4),s=Math.min(1,A+1e-4);return e.copy(this.getPoint(s).sub(this.getPoint(i)).normalize())}getTangentAt(A,e){return this.getTangent(this.getUToTMapping(A),e)}getNormal(A,e=new F){return this.getTangent(A,e),e.set(-e.y,e.x).normalize()}getNormalAt(A,e){return this.getNormal(this.getUToTMapping(A),e)}getTForPoint(A,e=.001){let t=0,i=1,s=(t+i)/2;for(;i-t>e;){s=(t+i)/2;const n=this.getPoint(s);if(n.distanceTo(A)<e)return s;n.x<A.x?t=s:i=s}return s}getMinMax(A=F.MAX,e=F.MIN){const t=this.getPoints();for(let i=0,s=t.length;i<s;i++){const n=t[i];A.min(n),e.max(n)}return{min:A,max:e}}getBoundingBox(){const{min:A,max:e}=this.getMinMax();return new he(A.x,A.y,e.x-A.x,e.y-A.y)}fillTriangulate(A){return ya(this.getAdaptivePointArray(),A)}strokeTriangulate(A){return Ec(this.getAdaptivePointArray(),A)}toTriangulatedSVGString(A=this.fillTriangulate(),e=0){const{vertices:t,indices:i}=A,s={x:-e,y:-e},n={x:e,y:e},o=h=>{const g=t[h*2],f=t[h*2+1];return s.x=Math.min(s.x,g+e),n.x=Math.max(n.x,g+e),s.y=Math.min(s.y,f+e),n.y=Math.max(n.y,f+e),[g,f]};let a="";for(let h=0,g=i.length;h<g;h+=3){const f=o(i[h]),I=o(i[h+1]),d=o(i[h+2]);a+=`<polygon points="${f.join(",")} ${I.join(",")} ${d.join(",")}" fill="none" stroke="black" />`}const l=[s.x,s.y,n.x-s.x,n.y-s.y];return`<svg width="${l[2]}" height="${l[3]}" viewBox="${l.join(" ")}" xmlns="http://www.w3.org/2000/svg">${a}</svg>`}toTriangulatedSVG(A,e){return new DOMParser().parseFromString(this.toTriangulatedSVGString(A,e),"image/svg+xml").documentElement}toCommands(){const A=[],e=this.getPoints();for(let t=0,i=e.length;t<i;t++){const s=e[t];t===0?A.push({type:"M",x:s.x,y:s.y}):A.push({type:"L",x:s.x,y:s.y})}return A}toData(){return Ac(this.toCommands())}drawTo(A){return this.toCommands().forEach(e=>{switch(e.type){case"M":A.moveTo(e.x,e.y);break;case"L":A.lineTo(e.x,e.y);break}}),this}copy(A){return this.arcLengthDivision=A.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Qc=new Je,_a=new Je,Da=new Je,Er=new F;class js extends VA{constructor(A=new F,e=new F,t=new F,i=0,s=0,n=Math.PI*2,o=!1){super(),this._center=A,this._radius=e,this._diff=t,this.rotate=i,this.startAngle=s,this.endAngle=n,this.clockwise=o}get cx(){return this._center.x}set cx(A){this._center.x=A}get cy(){return this._center.y}set cy(A){this._center.y=A}get rx(){return this._radius.x}set rx(A){this._radius.x=A}get ry(){return this._radius.y}set ry(A){this._radius.y=A}get dx(){return this._diff.x}set dx(A){this._diff.x=A}get dy(){return this._diff.y}set dy(A){this._diff.y=A}isClockwise(){return this.clockwise}_getDeltaAngle(){const A=Math.PI*2;let e=this.endAngle-this.startAngle;const t=Math.abs(e)<Number.EPSILON;return e=(e%A+A)%A,t?e=0:this.clockwise||(e=e===0?-A:e-A),e}getPoint(A,e=new F){const t=this._getDeltaAngle(),i=this.startAngle+A*t;let s=this.cx+this.rx*Math.cos(i),n=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const o=Math.cos(this.rotate),a=Math.sin(this.rotate),l=s-this.cx,h=n-this.cy;s=l*o-h*a+this.cx,n=l*a+h*o+this.cy}return e.set(s,n)}toCommands(){const{cx:A,cy:e,rx:t,ry:i,startAngle:s,endAngle:n,clockwise:o,rotate:a}=this,l=A+t*Math.cos(s)*Math.cos(a)-i*Math.sin(s)*Math.sin(a),h=e+t*Math.cos(s)*Math.sin(a)+i*Math.sin(s)*Math.cos(a),g=Math.abs(s-n),f=g>Math.PI?1:0,I=o?1:0,d=a*180/Math.PI;if(g>=2*Math.PI){const C=s+Math.PI,p=A+t*Math.cos(C)*Math.cos(a)-i*Math.sin(C)*Math.sin(a),M=e+t*Math.cos(C)*Math.sin(a)+i*Math.sin(C)*Math.cos(a);return[{type:"M",x:l,y:h},{type:"A",rx:t,ry:i,angle:d,largeArcFlag:0,sweepFlag:I,x:p,y:M},{type:"A",rx:t,ry:i,angle:d,largeArcFlag:0,sweepFlag:I,x:l,y:h}]}else{const C=A+t*Math.cos(n)*Math.cos(a)-i*Math.sin(n)*Math.sin(a),p=e+t*Math.cos(n)*Math.sin(a)+i*Math.sin(n)*Math.cos(a);return[{type:"M",x:l,y:h},{type:"A",rx:t,ry:i,angle:d,largeArcFlag:f,sweepFlag:I,x:C,y:p}]}}drawTo(A){const{cx:e,cy:t,rx:i,ry:s,rotate:n,startAngle:o,endAngle:a,clockwise:l}=this;return A.ellipse(e,t,i,s,n,o,a,!l),this}applyTransform(A){return Er.set(this.cx,this.cy),Er.applyMatrix3(A),this.cx=Er.x,this.cy=Er.y,wc(A)?yc(this,A):mc(this,A),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(A=[]){const{cx:e,cy:t,rx:i,ry:s,dx:n,dy:o}=this;if(!(i>=0&&s>=0&&n>=0&&o>=0))return A;const a=Math.ceil(2.3*Math.sqrt(i+s)),l=e,h=t,g=a*8+(n?4:0)+(o?4:0);if(g===0)return A;if(a===0)return A[0]=A[6]=l+n,A[1]=A[3]=h+o,A[2]=A[4]=l-n,A[5]=A[7]=h-o,A;let f=0,I=a*4+(n?2:0)+2,d=I,C=g,p=n+i,M=o,R=l+p,_=l-p,P=h+M;if(A[f++]=R,A[f++]=P,A[--I]=P,A[--I]=_,o){const w=h-M;A[d++]=_,A[d++]=w,A[--C]=w,A[--C]=R}for(let w=1;w<a;w++){const b=Math.PI/2*(w/a),S=n+Math.cos(b)*i,L=o+Math.sin(b)*s,$=l+S,K=l-S,J=h+L,Z=h-L;A[f++]=$,A[f++]=J,A[--I]=J,A[--I]=K,A[d++]=K,A[d++]=Z,A[--C]=Z,A[--C]=$}p=n,M=o+s,R=l+p,_=l-p,P=h+M;const v=h-M;return A[f++]=R,A[f++]=P,A[--C]=v,A[--C]=R,n&&(A[f++]=_,A[f++]=P,A[--C]=v,A[--C]=_),A}fillTriangulate(A={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=e.length/i,indicesOffset:n=t.length}=A;const o=this.getAdaptivePointArray();if(o.length===0)return{vertices:e,indices:t};let a=0,l=0;for(let f=0;f<o.length;f+=2)a+=o[f],l+=o[f+1];a/=o.length/2,l/=o.length/2;let h=s;e[h*i]=a,e[h*i+1]=l;const g=h++;for(let f=0;f<o.length;f+=2)e[h*i]=o[f],e[h*i+1]=o[f+1],f>0&&(t[n++]=h,t[n++]=g,t[n++]=h-1),h++;return t[n++]=g+1,t[n++]=g,t[n++]=h-1,{vertices:e,indices:t}}getMinMax(A=F.MAX,e=F.MIN){const{cx:t,cy:i,rx:s,ry:n,rotate:o}=this,a=Math.cos(o),l=Math.sin(o),h=Math.sqrt(s*s*a*a+n*n*l*l),g=Math.sqrt(s*s*l*l+n*n*a*a);return A.x=Math.min(A.x,t-h),A.y=Math.min(A.y,i-g),e.x=Math.max(e.x,t+h),e.y=Math.max(e.y,i+g),{min:A,max:e}}copy(A){return super.copy(A),this.cx=A.cx,this.cy=A.cy,this.rx=A.rx,this.ry=A.ry,this.dx=A.dx,this.dy=A.dy,this.startAngle=A.startAngle,this.endAngle=A.endAngle,this.clockwise=A.clockwise,this.rotate=A.rotate,this}}function yc(r,A){const e=r.rx,t=r.ry,i=Math.cos(r.rotate),s=Math.sin(r.rotate),n=new F(e*i,e*s),o=new F(-t*s,t*i),a=n.applyMatrix3(A),l=o.applyMatrix3(A),h=Qc.set(a.x,l.x,0,a.y,l.y,0,0,0,1),g=_a.copy(h).invert(),d=Da.copy(g).transpose().multiply(g).elements,C=vc(d[0],d[1],d[4]),p=Math.sqrt(C.rt1),M=Math.sqrt(C.rt2);if(r.rx=1/p,r.ry=1/M,r.rotate=Math.atan2(C.sn,C.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const _=_a.set(p,0,0,0,M,0,0,0,1),P=Da.set(C.cs,C.sn,0,-C.sn,C.cs,0,0,0,1),v=_.multiply(P).multiply(h),w=b=>{const{x:S,y:L}=new F(Math.cos(b),Math.sin(b)).applyMatrix3(v);return Math.atan2(L,S)};r.startAngle=w(r.startAngle),r.endAngle=w(r.endAngle),ba(A)&&(r.clockwise=!r.clockwise)}}function mc(r,A){const e=xa(A),t=Sa(A);r.rx*=e,r.ry*=t;const i=e>Number.EPSILON?Math.atan2(A.elements[1],A.elements[0]):Math.atan2(-A.elements[3],A.elements[4]);r.rotate+=i,ba(A)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function ba(r){const A=r.elements;return A[0]*A[4]-A[1]*A[3]<0}function wc(r){const A=r.elements,e=A[0]*A[3]+A[1]*A[4];if(e===0)return!1;const t=xa(r),i=Sa(r);return Math.abs(e/(t*i))>Number.EPSILON}function xa(r){const A=r.elements;return Math.sqrt(A[0]*A[0]+A[1]*A[1])}function Sa(r){const A=r.elements;return Math.sqrt(A[3]*A[3]+A[4]*A[4])}function vc(r,A,e){let t,i,s,n,o;const a=r+e,l=r-e,h=Math.sqrt(l*l+4*A*A);return a>0?(t=.5*(a+h),o=1/t,i=r*o*e-A*o*A):a<0?i=.5*(a-h):(t=.5*h,i=-.5*h),l>0?s=l+h:s=l-h,Math.abs(s)>2*Math.abs(A)?(o=-2*A/s,n=1/Math.sqrt(1+o*o),s=o*n):Math.abs(A)===0?(s=1,n=0):(o=-.5*s/A,s=1/Math.sqrt(1+o*o),n=o*s),l>0&&(o=s,s=-n,n=o),{rt1:t,rt2:i,cs:s,sn:n}}class _c extends js{constructor(A=0,e=0,t=1,i=0,s=Math.PI*2,n=!1){super(new F(A,e),new F(t,t),new F,0,i,s,n)}drawTo(A){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;return A.arc(e,t,i,s,n,!o),this}getAdaptivePointArray(A=[]){const{cx:e,cy:t,rx:i,startAngle:s,endAngle:n,clockwise:o}=this;let a=Math.abs(s-n);(!o&&s>n||o&&n>s)&&(a=2*Math.PI-a);let l=Math.max(6,Math.floor(6*i**(1/3)*(a/Math.PI)));l=Math.max(l,3);let h=a/l,g=s;h*=o?1:-1;for(let f=0;f<l+1;f++){const I=Math.cos(g),d=Math.sin(g),C=e+I*i,p=t+d*i;A.push(C,p),g+=h}return A}}class Xt extends VA{constructor(A=new F,e=new F){super(),this.p1=A,this.p2=e}static from(A,e,t,i){return new Xt(new F(A,e),new F(t,i))}getPoint(A,e=new F){return A===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(A).add(this.p1),e}getPointAt(A,e=new F){return this.getPoint(A,e)}getTangent(A,e=new F){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(A,e=new F){return this.getTangent(A,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(A=[]){return A.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),A}getMinMax(A=F.MAX,e=F.MIN){const{p1:t,p2:i}=this;return A.x=Math.min(A.x,t.x,i.x),A.y=Math.min(A.y,t.y,i.y),e.x=Math.max(e.x,t.x,i.x),e.y=Math.max(e.y,t.y,i.y),{min:A,max:e}}toCommands(){const{p1:A,p2:e}=this;return[{type:"M",x:A.x,y:A.y},{type:"L",x:e.x,y:e.y}]}fillTriangulate(A={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=e.length/i,indicesOffset:n=t.length}=A;const o=this.p1.x,a=this.p1.y,l=this.p2.x-this.p1.x||1,h=this.p2.y-this.p2.y||1,g=[o,a,o+l,a,o+l,a+h,o,a+h];let f=0;s*=i,e[s+f]=g[0],e[s+f+1]=g[1],f+=i,e[s+f]=g[2],e[s+f+1]=g[3],f+=i,e[s+f]=g[6],e[s+f+1]=g[7],f+=i,e[s+f]=g[4],e[s+f+1]=g[5],f+=i;const I=s/i;return t[n++]=I,t[n++]=I+1,t[n++]=I+2,t[n++]=I+1,t[n++]=I+3,t[n++]=I+2,{vertices:e,indices:t}}drawTo(A){const{p1:e,p2:t}=this;return A.lineTo(e.x,e.y),A.lineTo(t.x,t.y),this}copy(A){return super.copy(A),this.p1.copy(A.p1),this.p2.copy(A.p2),this}}class ki extends VA{constructor(A=[]){super(),this.curves=A}getFlatCurves(){return this.curves.flatMap(A=>A instanceof ki?A.getFlatCurves():A)}addCurve(A){return this.curves.push(A),this}getPoint(A,e=new F){const t=A*this.getLength(),i=this.getLengths();let s=0;for(;s<i.length;){if(i[s]>=t){const n=i[s]-t,o=this.curves[s],a=o.getLength();return o.getPointAt(a===0?0:1-n/a,e)}s++}return e}updateLengths(){const A=[];for(let e=0,t=0,i=this.curves.length;e<i;e++)t+=this.curves[e].getLength(),A.push(t);this._arcLengths=A}getControlPointRefs(){return this.curves.flatMap(A=>A.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(A,e){return A[e-1]===A[e+1]&&A[e]===A[e+2]&&A.splice(e+1,2),A}getSpacedPointArray(A=5,e=[]){let t;return this.curves.forEach(i=>{i.getSpacedPointArray(A,e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}getAdaptivePointArray(A=[]){let e;return this.curves.forEach(t=>{t.getAdaptivePointArray(A),e&&this._removeNextPointIfEqualPrevPoint(A,e),e=A.length-1}),A}fillTriangulate(A){const e=(A==null?void 0:A.indices)??[],t=(A==null?void 0:A.vertices)??[],i=[],s=()=>{if(i.length){const n=[];i.forEach(o=>{const a=o.p1.x,l=o.p1.y;(n[n.length-2]!==a||n[n.length-1]!==l)&&n.push(a,l),n.push(o.p2.x,o.p2.y)}),ya(n,{...A,indices:e,vertices:t}),i.length=0}};return this.curves.forEach(n=>{n instanceof Xt?i.push(n):(s(),n.fillTriangulate({...A,indices:e,vertices:t}))}),s(),{indices:e,vertices:t}}applyTransform(A){return this.curves.forEach(e=>e.applyTransform(A)),this}getMinMax(A=F.MAX,e=F.MIN){return this.curves.forEach(t=>t.getMinMax(A,e)),{min:A,max:e}}getBoundingBox(){const{min:A,max:e}=this.getMinMax();return new he(A.x,A.y,e.x-A.x,e.y-A.y)}toCommands(){return this.curves.flatMap(A=>A.toCommands())}drawTo(A){var t;const e=(t=this.curves[0])==null?void 0:t.getPoint(0);return e&&A.moveTo(e.x,e.y),this.curves.forEach(i=>i.drawTo(A)),this}copy(A){return super.copy(A),this.curves=A.curves.map(e=>e.clone()),this}}class Zs extends VA{constructor(A=new F,e=new F,t=new F,i=new F){super(),this.p1=A,this.cp1=e,this.cp2=t,this.p2=i}static from(A,e,t,i,s,n,o,a){return new Zs(new F(A,e),new F(t,i),new F(s,n),new F(o,a))}getPoint(A,e=new F){const{p1:t,cp1:i,cp2:s,p2:n}=this;return e.set(Qa(A,t.x,i.x,s.x,n.x),Qa(A,t.y,i.y,s.y,n.y))}getAdaptivePointArray(A=[]){return hc(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,A)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(A,e,t){const i=e*e-4*A*t;if(i<0)return[];const s=Math.sqrt(i),n=(-e+s)/(2*A),o=(-e-s)/(2*A);return[n,o].filter(a=>a>=0&&a<=1)}getMinMax(A=F.MAX,e=F.MIN){const{p1:t,cp1:i,cp2:s,p2:n}=this,o=this._solveQuadratic(3*(i.x-t.x),6*(s.x-i.x),3*(n.x-s.x)),a=this._solveQuadratic(3*(i.y-t.y),6*(s.y-i.y),3*(n.y-s.y)),l=[0,1,...o,...a];return((g,f)=>{for(const I of g)for(let d=0;d<=f;d++){const C=d/f-.5,p=Math.min(1,Math.max(0,I+C)),M=this.getPoint(p);A.x=Math.min(A.x,M.x),A.y=Math.min(A.y,M.y),e.x=Math.max(e.x,M.x),e.y=Math.max(e.y,M.y)}})(l,10),{min:A,max:e}}toCommands(){const{p1:A,cp1:e,cp2:t,p2:i}=this;return[{type:"M",x:A.x,y:A.y},{type:"C",x1:e.x,y1:e.y,x2:t.x,y2:t.y,x:i.x,y:i.y}]}drawTo(A){const{p1:e,cp1:t,cp2:i,p2:s}=this;return A.lineTo(e.x,e.y),A.bezierCurveTo(t.x,t.y,i.x,i.y,s.x,s.y),this}copy(A){return super.copy(A),this.p1.copy(A.p1),this.cp1.copy(A.cp1),this.cp2.copy(A.cp2),this.p2.copy(A.p2),this}}class Dc extends js{constructor(A=0,e=0,t=1,i=1,s=0,n=0,o=Math.PI*2,a=!1){super(new F(A,e),new F(t,i),new F,s,n,o,a)}drawTo(A){return A.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class bc extends ki{}class $s extends VA{constructor(A=new F,e=new F,t=new F){super(),this.p1=A,this.cp=e,this.p2=t}static from(A,e,t,i,s,n){return new $s(new F(A,e),new F(t,i),new F(s,n))}getPoint(A,e=new F){const{p1:t,cp:i,p2:s}=this;return e.set(ma(A,t.x,i.x,s.x),ma(A,t.y,i.y,s.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(A=[]){return fc(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,A)}getMinMax(A=F.MAX,e=F.MIN){const{p1:t,cp:i,p2:s}=this,n=.5*(t.x+i.x),o=.5*(t.y+i.y),a=.5*(t.x+s.x),l=.5*(t.y+s.y);return A.x=Math.min(A.x,t.x,s.x,n,a),A.y=Math.min(A.y,t.y,s.y,o,l),e.x=Math.max(e.x,t.x,s.x,n,a),e.y=Math.max(e.y,t.y,s.y,o,l),{min:A,max:e}}toCommands(){const{p1:A,cp:e,p2:t}=this;return[{type:"M",x:A.x,y:A.y},{type:"Q",x1:e.x,y1:e.y,x:t.x,y:t.y}]}drawTo(A){const{p1:e,cp:t,p2:i}=this;return A.lineTo(e.x,e.y),A.quadraticCurveTo(t.x,t.y,i.x,i.y),this}copy(A){return super.copy(A),this.p1.copy(A.p1),this.cp.copy(A.cp),this.p2.copy(A.p2),this}}class xc extends bc{constructor(A=0,e=0,t=0,i=0){super(),this.x=A,this.y=e,this.width=t,this.height=i,this.update()}update(){const{x:A,y:e,width:t,height:i}=this,s=[new F(A,e),new F(A+t,e),new F(A+t,e+i),new F(A,e+i)];return this.curves=[new Xt(s[0],s[1]),new Xt(s[1],s[2]),new Xt(s[2],s[3]),new Xt(s[3],s[0])],this}drawTo(A){return A.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(A={}){let{vertices:e=[],indices:t=[],verticesStride:i=2,verticesOffset:s=e.length/i,indicesOffset:n=t.length}=A;const{x:o,y:a,width:l,height:h}=this,g=[o,a,o+l,a,o+l,a+h,o,a+h];let f=0;s*=i,e[s+f]=g[0],e[s+f+1]=g[1],f+=i,e[s+f]=g[2],e[s+f+1]=g[3],f+=i,e[s+f]=g[6],e[s+f+1]=g[7],f+=i,e[s+f]=g[4],e[s+f+1]=g[5],f+=i;const I=s/i;return t[n++]=I,t[n++]=I+1,t[n++]=I+2,t[n++]=I+1,t[n++]=I+3,t[n++]=I+2,{vertices:e,indices:t}}copy(A){return super.copy(A),this.x=A.x,this.y=A.y,this.width=A.width,this.height=A.height,this.update(),this}}class Sc extends js{constructor(A=0,e=0,t=1,i=1,s=1){super(),this.x=A,this.y=e,this.width=t,this.height=i,this.radius=s,this.update()}update(){const{x:A,y:e,width:t,height:i,radius:s}=this,n=t/2,o=i/2,a=A+n,l=e+o,h=Math.max(0,Math.min(s,Math.min(n,o))),g=h;return this._center=new F(a,l),this._radius=new F(h,g),this._diff=new F(n-h,o-g),this}drawTo(A){const{x:e,y:t,width:i,height:s,radius:n}=this;return A.roundRect(e,t,i,s,n),this}copy(A){return super.copy(A),this.x=A.x,this.y=A.y,this.width=A.width,this.height=A.height,this.radius=A.radius,this.update(),this}}class Mc extends VA{constructor(A=[]){super(),this.points=A}getPoint(A,e=new F){const{points:t}=this,i=(t.length-1)*A,s=Math.floor(i),n=i-s,o=t[s===0?s:s-1],a=t[s],l=t[s>t.length-2?t.length-1:s+1],h=t[s>t.length-3?t.length-1:s+2];return e.set(Ca(n,o.x,a.x,l.x,h.x),Ca(n,o.y,a.y,l.y,h.y)),e}getControlPointRefs(){return this.points}copy(A){super.copy(A),this.points=[];for(let e=0,t=A.points.length;e<t;e++)this.points.push(A.points[e].clone());return this}}class Cr extends ki{constructor(e){super();u(this,"startPoint");u(this,"currentPoint");u(this,"autoClose",!1);e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++){const{x:s,y:n}=e[t];this.lineTo(s,n)}return this}addCommands(e){return Ba(e,this),this}addData(e){return this.addCommands(Ea(e)),this}_closePointArray(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenPointArray(e=40,t=[]){return this._closePointArray(super.getUnevenPointArray(e,t))}getSpacedPointArray(e=40,t=[]){return this._closePointArray(super.getSpacedPointArray(e,t))}getAdaptivePointArray(e=[]){return this._closePointArray(super.getAdaptivePointArray(e))}_setCurrentPoint(e){return this.currentPoint=new F(e.x,e.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(e){if(this.curves.length>0){const t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){const e=this.startPoint;if(e){const t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Xt(t.clone(),e.clone())),t.copy(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new F(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){const i=this.currentPoint;return i!=null&&i.equals({x:e,y:t})||this.curves.push(Xt.from((i==null?void 0:i.x)??0,(i==null?void 0:i.y)??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,i,s,n,o){const a=this.currentPoint;return a!=null&&a.equals({x:n,y:o})||this.curves.push(Zs.from((a==null?void 0:a.x)??0,(a==null?void 0:a.y)??0,e,t,i,s,n,o)),this._setCurrentPoint({x:n,y:o}),this}quadraticCurveTo(e,t,i,s){const n=this.currentPoint;return n!=null&&n.equals({x:i,y:s})||this.curves.push($s.from((n==null?void 0:n.x)??0,(n==null?void 0:n.y)??0,e,t,i,s)),this._setCurrentPoint({x:i,y:s}),this}arc(e,t,i,s,n,o){const a=new _c(e,t,i,s,n,!o);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint(a.getPoint(1)),this}relativeArc(e,t,i,s,n,o){var a,l;return e+=((a=this.currentPoint)==null?void 0:a.x)??0,t+=((l=this.currentPoint)==null?void 0:l.y)??0,this.arc(e,t,i,s,n,o),this}arcTo(e,t,i,s,n){return console.warn("Method arcTo not supported yet"),this}ellipse(e,t,i,s,n,o,a,l=!0){const h=new Dc(e,t,i,s,n,o,a,!l);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeEllipse(e,t,i,s,n,o,a,l){var h,g;return e+=((h=this.currentPoint)==null?void 0:h.x)??0,t+=((g=this.currentPoint)==null?void 0:g.y)??0,this.ellipse(e,t,i,s,n,o,a,l),this}rect(e,t,i,s){const n=new xc(e,t,i,s);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,i,s,n){const o=new Sc(e,t,i,s,n);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){const t=this.currentPoint??new F;return this.curves.push(new Mc([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){var i;const t=(i=this.curves[0])==null?void 0:i.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(s=>s.drawTo(e)),this.autoClose&&e.closePath(),this}copy(e){var t;return super.copy(e),this.autoClose=e.autoClose,this.currentPoint=(t=e.currentPoint)==null?void 0:t.clone(),this}}function Rc(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Pc(r,A,e,t){const i=A.clone().sub(r),s=t.clone().sub(e),n=e.clone().sub(r),o=i.cross(s);if(o===0)return new F((r.x+e.x)/2,(r.y+e.y)/2);const a=n.cross(s)/o;return Math.abs(a)>1?new F((r.x+e.x)/2,(r.y+e.y)/2):new F(r.x+a*i.x,r.y+a*i.y)}class ke extends ki{constructor(e,t={}){super();u(this,"currentCurve",new Cr);u(this,"style");this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof ke?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){const t=this.curves.findIndex(i=>i===this.currentCurve);return t>-1&&this.curves.splice(t,1),e instanceof ke?this.curves.push(...e.curves.filter(i=>i.curves.length).map(i=>i.clone())):e.curves.length&&this.curves.push(e),this.curves.push(this.currentCurve),this}closePath(){const e=this.startPoint;return e&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new Cr().moveTo(e.x,e.y),this.curves.push(this.currentCurve))),this}moveTo(e,t){var i;return(i=this.currentCurve.currentPoint)!=null&&i.equals({x:e,y:t})||(this.currentCurve.curves.length&&(this.currentCurve=new Cr,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t)),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,i,s,n,o){return this.currentCurve.bezierCurveTo(e,t,i,s,n,o),this}quadraticCurveTo(e,t,i,s){return this.currentCurve.quadraticCurveTo(e,t,i,s),this}arc(e,t,i,s,n,o){return this.currentCurve.arc(e,t,i,s,n,o),this}arcTo(e,t,i,s,n){return this.currentCurve.arcTo(e,t,i,s,n),this}ellipse(e,t,i,s,n,o,a,l){return this.currentCurve.ellipse(e,t,i,s,n,o,a,l),this}rect(e,t,i,s){return this.currentCurve.rect(e,t,i,s),this}roundRect(e,t,i,s,n){return this.currentCurve.roundRect(e,t,i,s,n),this}reset(){return this.currentCurve=new Cr,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return Ba(e,this),this}addData(e){return this.addCommands(Ea(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,i={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.scale(e,t,i)}),this}skew(e,t=0,i={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.skew(e,t,i)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getFlatCurves(),i=[],s=[],n=[];t.forEach((a,l)=>{const h=a.getControlPointRefs(),g=a.isClockwise();n[l]=h,s[l]=g;const f=h[0],I=h[h.length-1]??f;i.push({start:g?I:f,end:g?f:I,index:l})});const o=[];return i.forEach((a,l)=>{o[l]=[],i.forEach((h,g)=>{var f;h.start&&a.end&&g!==l&&((f=h.start)!=null&&f.equals(a.end))&&o[l].push(h.index)})}),t.forEach((a,l)=>{const h=s[l];n[l].forEach(g=>{g.add(a.getNormal(a.getTForPoint(g)).scale(h?e:-e))})}),o.forEach((a,l)=>{const h=n[l];a.forEach(g=>{const f=n[g],I=Pc(h[h.length-1],h[h.length-2]??h[h.length-1],f[0],f[1]??f[0]);I&&(h[h.length-1].copy(I),f[0].copy(I))})}),this}getMinMax(e=F.MAX,t=F.MIN,i=!0){const s=this.strokeWidth;return this.curves.forEach(n=>{if(n.getMinMax(e,t),i&&s>1){const o=s/2,a=n.isClockwise(),l=[];for(let h=0;h<=1;h+=1/n.arcLengthDivision){const g=n.getPoint(h),f=n.getNormal(h),I=f.clone().scale(a?o:-o),d=f.clone().scale(a?-o:o);l.push(g.clone().add(I),g.clone().add(d),g.clone().add({x:o,y:0}),g.clone().add({x:-o,y:0}),g.clone().add({x:0,y:o}),g.clone().add({x:0,y:-o}),g.clone().add({x:o,y:o}),g.clone().add({x:-o,y:-o}))}e.min(...l),t.max(...l)}}),{min:e,max:t}}strokeTriangulate(e){const t=(e==null?void 0:e.indices)??[],i=(e==null?void 0:e.vertices)??[];return this.curves.forEach(s=>{s.strokeTriangulate({...e,indices:t,vertices:i})}),{indices:t,vertices:i}}getBoundingBox(e=!0){const{min:t,max:i}=this.getMinMax(void 0,void 0,e);return new he(t.x,t.y,i.x-t.x,i.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:i="#000",stroke:s="none"}=t;return e.beginPath(),e.save(),zs(e,t),this.curves.forEach(n=>{n.drawTo(e)}),i!=="none"&&e.fill(),s!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:i="#000",stroke:s="none"}=t;return e.beginPath(),e.save(),zs(e,t),this.getControlPointRefs().forEach(n=>{$g(e,n.x,n.y,{radius:4})}),i!=="none"&&e.fill(),s!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(" ")}toSVGPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const s in e)e[s]!==void 0&&(t[Rc(s)]=e[s]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let i="";for(const s in t)t[s]!==void 0&&(i+=`${s}:${t[s]};`);return`<path d="${this.toData()}" style="${i}"></path>`}copy(e){return super.copy(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}}class nA{constructor(A=[],e){this.paths=A,this.viewBox=e}getBoundingBox(A=!0){if(!this.paths.length)return;const e=F.MAX,t=F.MIN;return this.paths.forEach(i=>i.getMinMax(e,t,A)),new he(e.x,e.y,t.x-e.x,t.y-e.y)}toSVGString(){const{x:A,y:e,width:t,height:i}=this.getBoundingBox(),s=this.paths.map(n=>n.toSVGPathString()).join("");return`<svg viewBox="${A} ${e} ${t} ${i}" width="${t}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toSVGUrl(){return`data:image/svg+xml;base64,${btoa(this.toSVGString())}`}toSVG(){return new DOMParser().parseFromString(this.toSVGString(),"image/svg+xml").documentElement}toCanvas(A={}){const{pixelRatio:e=2,...t}=A,{left:i,top:s,width:n,height:o}=this.getBoundingBox(),a=document.createElement("canvas");a.width=n*e,a.height=o*e,a.style.width=`${n}px`,a.style.height=`${o}px`;const l=a.getContext("2d");return l&&(l.scale(e,e),l.translate(-i,-s),this.paths.forEach(h=>{h.drawTo(l,t)})),a}}const Ma="data:image/svg+xml;",Ra=`${Ma}base64,`,Pa=`${Ma}charset=utf8,`;function en(r){if(typeof r=="string"){let A;r.startsWith(Ra)?(r=r.substring(Ra.length,r.length),A=atob(r)):r.startsWith(Pa)?(r=r.substring(Pa.length,r.length),A=decodeURIComponent(r)):A=r;const e=new DOMParser().parseFromString(A,"text/xml"),t=e.querySelector("parsererror");if(t)throw new Error(`${t.textContent??"parser error"}
276
- ${A}`);return e.documentElement}else return r}const Uc="px",kc=90,Ua=["mm","cm","in","pt","pc","px"],ka={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function Be(r){let A="px";if(typeof r=="string"||r instanceof String)for(let t=0,i=Ua.length;t<i;t++){const s=Ua[t];if(r.endsWith(s)){A=s,r=r.substring(0,r.length-s.length);break}}let e;return e=ka[A][Uc],e<0&&(e=ka[A].in*kc),e*Number.parseFloat(r)}const Nc=new Je,Qr=new Je,Na=new Je,Fa=new Je;function Fc(r,A,e){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const t=Tc(r);return e.length>0&&t.premultiply(e[e.length-1]),A.copy(t),e.push(t),t}function Tc(r){const A=new Je,e=Nc;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&A.translate(Be(r.getAttribute("x")),Be(r.getAttribute("y"))),r.hasAttribute("transform")){const t=r.getAttribute("transform").split(")");for(let i=t.length-1;i>=0;i--){const s=t[i].trim();if(s==="")continue;const n=s.indexOf("("),o=s.length;if(n>0&&n<o){const a=s.slice(0,n),l=St(s.slice(n+1));switch(e.identity(),a){case"translate":if(l.length>=1){const h=l[0];let g=0;l.length>=2&&(g=l[1]),e.translate(h,g)}break;case"rotate":if(l.length>=1){let h=0,g=0,f=0;h=l[0]*Math.PI/180,l.length>=3&&(g=l[1],f=l[2]),Qr.makeTranslation(-g,-f),Na.makeRotation(h),Fa.multiplyMatrices(Na,Qr),Qr.makeTranslation(g,f),e.multiplyMatrices(Qr,Fa)}break;case"scale":l.length>=1&&e.scale(l[0],l[1]??l[0]);break;case"skewX":l.length===1&&e.set(1,Math.tan(l[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":l.length===1&&e.set(1,0,0,Math.tan(l[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":l.length===6&&e.set(l[0],l[2],l[4],l[1],l[3],l[5],0,0,1);break}}A.premultiply(e)}}return A}function Lc(r){return new ke().arc(Be(r.getAttribute("cx")||0),Be(r.getAttribute("cy")||0),Be(r.getAttribute("r")||0),0,Math.PI*2)}function Gc(r,A){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let e=0;e<r.sheet.cssRules.length;e++){const t=r.sheet.cssRules[e];if(t.type!==1)continue;const i=t.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),s={};for(let n=t.style.length,o=0;o<n;o++){const a=t.style.item(o);s[a]=t.style.getPropertyValue(a)}for(let n=0;n<i.length;n++)A[i[n]]=Object.assign(A[i[n]]||{},{...s})}}function Oc(r){return new ke().ellipse(Be(r.getAttribute("cx")||0),Be(r.getAttribute("cy")||0),Be(r.getAttribute("rx")||0),Be(r.getAttribute("ry")||0),0,0,Math.PI*2)}function Hc(r){return new ke().moveTo(Be(r.getAttribute("x1")||0),Be(r.getAttribute("y1")||0)).lineTo(Be(r.getAttribute("x2")||0),Be(r.getAttribute("y2")||0))}function Jc(r){const A=new ke,e=r.getAttribute("d");return!e||e==="none"?null:(A.addData(e),A)}const Kc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Yc(r){var t;const A=new ke;let e=0;return(t=r.getAttribute("points"))==null||t.replace(Kc,(i,s,n)=>{const o=Be(s),a=Be(n);return e===0?A.moveTo(o,a):A.lineTo(o,a),e++,i}),A.currentCurve.autoClose=!0,A}const Wc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function zc(r){var t;const A=new ke;let e=0;return(t=r.getAttribute("points"))==null||t.replace(Wc,(i,s,n)=>{const o=Be(s),a=Be(n);return e===0?A.moveTo(o,a):A.lineTo(o,a),e++,i}),A.currentCurve.autoClose=!1,A}function Vc(r){const A=Be(r.getAttribute("x")||0),e=Be(r.getAttribute("y")||0),t=Be(r.getAttribute("rx")||r.getAttribute("ry")||0),i=Be(r.getAttribute("ry")||r.getAttribute("rx")||0),s=Be(r.getAttribute("width")),n=Be(r.getAttribute("height")),o=1-.551915024494,a=new ke;return a.moveTo(A+t,e),a.lineTo(A+s-t,e),(t!==0||i!==0)&&a.bezierCurveTo(A+s-t*o,e,A+s,e+i*o,A+s,e+i),a.lineTo(A+s,e+n-i),(t!==0||i!==0)&&a.bezierCurveTo(A+s,e+n-i*o,A+s-t*o,e+n,A+s-t,e+n),a.lineTo(A+t,e+n),(t!==0||i!==0)&&a.bezierCurveTo(A+t*o,e+n,A,e+n-i*o,A,e+n-i),a.lineTo(A,e+i),(t!==0||i!==0)&&a.bezierCurveTo(A,e+i*o,A+t*o,e,A+t,e),a}function Mt(r,A,e){A=Object.assign({},A);let t={};if(r.hasAttribute("class")){const l=r.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<l.length;h++)t=Object.assign(t,e[`.${l[h]}`])}r.hasAttribute("id")&&(t=Object.assign(t,e[`#${r.getAttribute("id")}`]));for(let l=r.style.length,h=0;h<l;h++){const g=r.style.item(h),f=r.style.getPropertyValue(g);A[g]=f,t[g]=f}function i(l,h,g=s){r.hasAttribute(l)&&(A[h]=g(r.getAttribute(l))),t[l]&&(A[h]=g(t[l]))}function s(l){return l.startsWith("url")&&console.warn("url access in attributes is not implemented."),l}function n(l){return Math.max(0,Math.min(1,Be(l)))}function o(l){return Math.max(0,Be(l))}function a(l){return l.split(" ").filter(h=>h!=="").map(h=>Be(h))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",o),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",o),i("stroke-dasharray","strokeDasharray",a),i("stroke-dashoffset","strokeDashoffset",Be),i("visibility","visibility"),A}function tn(r,A,e=[],t={}){var g;if(r.nodeType!==1)return e;let i=!1,s=null,n={...A};switch(r.nodeName){case"svg":n=Mt(r,n,t);break;case"style":Gc(r,t);break;case"g":n=Mt(r,n,t);break;case"path":n=Mt(r,n,t),r.hasAttribute("d")&&(s=Jc(r));break;case"rect":n=Mt(r,n,t),s=Vc(r);break;case"polygon":n=Mt(r,n,t),s=Yc(r);break;case"polyline":n=Mt(r,n,t),s=zc(r);break;case"circle":n=Mt(r,n,t),s=Lc(r);break;case"ellipse":n=Mt(r,n,t),s=Oc(r);break;case"line":n=Mt(r,n,t),s=Hc(r);break;case"defs":i=!0;break;case"use":{n=Mt(r,n,t);const I=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||r.getAttribute("href")||"").substring(1),d=(g=r.viewportElement)==null?void 0:g.getElementById(I);d?tn(d,n,e,t):console.warn(`'use node' references non-existent node id: ${I}`);break}default:console.warn(r);break}if(n.display==="none")return e;const o=new Je,a=[],l=Fc(r,o,a);s&&(s.applyTransform(o),e.push(s),s.style={...n});const h=r.childNodes;for(let f=0,I=h.length;f<I;f++){const d=h[f];i&&d.nodeName!=="style"&&d.nodeName!=="defs"||tn(d,n,e,t)}return l&&(a.pop(),a.length>0?o.copy(a[a.length-1]):o.identity()),e}function An(r){var e;const A=en(r);return new nA(tn(A,{}),(e=A.getAttribute("viewBox"))==null?void 0:e.trim().split(" ").map(t=>Number(t)))}class Ta extends ke{constructor(){super(...arguments);u(this,"textureTransform");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineCap");u(this,"lineJoin");u(this,"lineWidth");u(this,"miterLimit");u(this,"_defaultStyle",ve.EMPTY);u(this,"_draws",[])}stroke(e){let t=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof ve?t=this.strokeStyle:t=new Ts(this.strokeStyle)),this.curves.length&&(this._draws.push({...e,type:"stroke",path:new ke(this),texture:t,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),super.reset())}fillRect(e,t,i,s){this.rect(e,t,i,s).fill()}strokeRect(e,t,i,s){this.rect(e,t,i,s).stroke()}fill(e){let t=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof ve?t=this.fillStyle:t=new Ts(this.fillStyle)),this._draws.push({...e,type:"fill",path:new ke(this),texture:t,textureTransform:this.textureTransform}),super.reset()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._draws.length=0,this}buildUvs(e,t,i,s,n){if(s){const o=s.width,a=s.height;for(let l=t.length,h=e;h<l;h+=2){const g=t[h],f=t[h+1];let I,d;n?[I,d]=n==null?void 0:n.applyToPoint(g,f):[I,d]=[g/o,f/a],i.push(I,d)}}else for(let o=t.length,a=e;a<o;a+=2)i.push(0,0)}toBatchables(){const e=[];let t=[],i=[],s=[],n;const o=l=>{e.push({vertices:t,indices:i,uvs:s,texture:n,type:l.type,disableWrapMode:l.disableWrapMode}),t=[],i=[],s=[],n=void 0};for(let l=this._draws.length,h=0;h<l;h++){const g=this._draws[h],f=this._draws[h-1];t.length&&f&&(f==null?void 0:f.type)!==g.type&&o(f);const I=n;I||(n=g.texture),t.length&&I!==g.texture&&!(I!=null&&I.is(g.texture))&&(o(g),n=g.texture);const d=t.length;g.type==="fill"?(g.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(d,t,s,g.texture,g.textureTransform)):(g.path.strokeTriangulate({vertices:t,indices:i,lineStyle:g.style,flipAlignment:!1,closed:!0}),this.buildUvs(d,t,s,g.texture,g.textureTransform))}const a=this._draws[this._draws.length-1];return a&&t.length&&o(a),e}}var qc=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,Ni=(r,A,e,t)=>{for(var i=t>1?void 0:t?Xc(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&&qc(A,e,i),i};c.CanvasItem=class extends c.TimelineNode{constructor(e,t=[]){super();u(this,"_parentGlobalVisible");u(this,"_globalVisible");u(this,"_parentGlobalOpacity");u(this,"_globalOpacity");u(this,"_modulate",new zt(4294967295));u(this,"context",new Ta);u(this,"_resetContext",!0);u(this,"_redrawing",!1);u(this,"_relayouting",!1);u(this,"_repainting",!1);u(this,"_originalBatchables",[]);u(this,"_layoutedBatchables",[]);u(this,"_batchables",[]);this.setProperties(e).append(t)}get globalVisible(){return this._globalVisible??!0}get globalOpacity(){return this._globalOpacity??1}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0,this.requestUpdate()}requestRelayout(){this._relayouting=!0,this.requestUpdate()}requestRepaint(){this._repainting=!0,this.requestUpdate()}_updateGlobalVisible(){var e;this._parentGlobalVisible=(e=this.getParent())==null?void 0:e.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){var t;this._parentGlobalOpacity=(t=this.getParent())==null?void 0:t.opacity;const e=xt(0,this.opacity,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){var e;return(e=this._tree)==null||e.log(this.name,"redrawing"),this._draw(),this.context.toBatchables()}_relayout(e){var t;return(t=this._tree)==null||t.log(this.name,"relayouting"),e}_repaint(e){var t;return(t=this._tree)==null||t.log(this.name,"repainting"),e.map(i=>({...i,modulate:this._modulate.toArgb(this.globalOpacity,!0),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==(t==null?void 0:t.globalVisible)&&this.requestUpdate(),this._parentGlobalOpacity!==(t==null?void 0:t.globalOpacity)&&this.requestUpdate()}_update(){const e=this.getParent();this._parentGlobalVisible!==(e==null?void 0:e.globalVisible)&&this._updateGlobalVisible(),this._parentGlobalOpacity!==(e==null?void 0:e.globalOpacity)&&this._updateGlobalOpacity();const t=this._redrawing;let i=this._relayouting,s=this._repainting,n;t&&(this._originalBatchables=this._redraw(),i=!0),i&&(this._layoutedBatchables=this._relayout(this._originalBatchables),s=!0),s&&(n=this._repaint(this._layoutedBatchables)),t&&this._resetContext&&this.context.reset(),n&&(this._batchables=n,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._batchables.forEach(t=>{var i,s;(i=t.texture)==null||i.upload(e),e.batch2D.render({...t,texture:(s=t.texture)==null?void 0:s._glTexture(e)})}),super._render(e)}},Ni([D()],c.CanvasItem.prototype,"modulate",2),Ni([D()],c.CanvasItem.prototype,"blendMode",2),Ni([pe({default:!0})],c.CanvasItem.prototype,"visible",2),Ni([pe({default:1})],c.CanvasItem.prototype,"opacity",2),c.CanvasItem=Ni([te("CanvasItem")],c.CanvasItem);class jc{constructor(){u(this,"currentCall");u(this,"calls",[])}createCall(A){return{renderable:A,parentCall:this.currentCall,fn:A.render.bind(A),calls:[]}}push(A){var t;const e=this.createCall(A);return(((t=this.currentCall)==null?void 0:t.calls)??this.calls).push(e),e}render(A){this.calls.forEach(function e(t){t.fn(A,()=>{t.calls.forEach(e)})}),this.calls=[]}}var Zc=Object.defineProperty,$c=Object.getOwnPropertyDescriptor,Fi=(r,A,e,t)=>{for(var i=t>1?void 0:t?$c(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&&Zc(A,e,i),i};c.Timeline=class extends c.Node{static from(A,e=!1){const[t,i]=A?Array.isArray(A)?A:[0,A]:[];return new c.Timeline({startTime:t,endTime:i,loop:e})}constructor(A){super(),this.setProperties(A)}_updateProperty(A,e,t){switch(super._updateProperty(A,e,t),A){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(A){const e=this.startTime,t=this.endTime;let i=this.currentTime;return i=i+A,this.loop&&i>t&&(i=e+i%t),i=xt(e,i,t),this.currentTime=i,this.emit("updateCurrentTime",i,A),this}_process(A){super._process(A),this.addTime(A)}},Fi([D({default:0})],c.Timeline.prototype,"startTime",2),Fi([D({default:0})],c.Timeline.prototype,"currentTime",2),Fi([D({default:Number.MAX_SAFE_INTEGER})],c.Timeline.prototype,"endTime",2),Fi([D({default:!1})],c.Timeline.prototype,"loop",2),c.Timeline=Fi([te("Timeline")],c.Timeline);var eu=Object.defineProperty,rn=(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&&eu(A,e,i),i};class Ti extends cr{constructor(e=new c.Timeline){super();u(this,"input",new Co);u(this,"renderStack",new jc);u(this,"root",new c.Viewport(!0).setTree(this));u(this,"timeline");u(this,"_backgroundColor",new zt);u(this,"_currentViewport");this.timeline=e.setTree(this)}getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=t;break}}log(...e){this.debug&&console.log("[modern-canvas]",...e)}_process(e=0){this.timeline.emit("process",e),this.emit("processing"),this.root.emit("process",e),this.emit("processed")}_render(e){this.emit("rendering"),e.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(e),this._renderScreen(e),this.emit("rendered")}_renderScreen(e){e.state.reset(),e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:this.root.width*e.pixelRatio,height:this.root.height*e.pixelRatio}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const t=this.root.texture;t.activate(e,0),ue.draw(e),e.texture.unbind(t)}free(){super.free(),this.root.getChildren(!0).forEach(e=>this.root.removeChild(e)),this.input.removeEventListeners()}}rn([D({default:!1})],Ti.prototype,"processPaused"),rn([D()],Ti.prototype,"backgroundColor"),rn([pe({default:!1})],Ti.prototype,"debug");var tu=Object.getOwnPropertyDescriptor,Au=(r,A,e,t)=>{for(var i=t>1?void 0:t?tu(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};c.Transition=class extends c.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},c.Transition=Au([te("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],c.Transition);var La=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,ru=(r,A,e)=>A in r?La(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,sn=(r,A,e,t)=>{for(var i=t>1?void 0:t?iu(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&&La(A,e,i),i},Ga=(r,A,e)=>ru(r,typeof A!="symbol"?A+"":A,e);const Oa=`varying vec2 vUv[9];
276
+ ${A}`);return e.documentElement}else return r}const Uc="px",kc=90,Ua=["mm","cm","in","pt","pc","px"],ka={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function Be(r){let A="px";if(typeof r=="string"||r instanceof String)for(let t=0,i=Ua.length;t<i;t++){const s=Ua[t];if(r.endsWith(s)){A=s,r=r.substring(0,r.length-s.length);break}}let e;return e=ka[A][Uc],e<0&&(e=ka[A].in*kc),e*Number.parseFloat(r)}const Nc=new Je,Qr=new Je,Na=new Je,Fa=new Je;function Fc(r,A,e){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const t=Tc(r);return e.length>0&&t.premultiply(e[e.length-1]),A.copy(t),e.push(t),t}function Tc(r){const A=new Je,e=Nc;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&A.translate(Be(r.getAttribute("x")),Be(r.getAttribute("y"))),r.hasAttribute("transform")){const t=r.getAttribute("transform").split(")");for(let i=t.length-1;i>=0;i--){const s=t[i].trim();if(s==="")continue;const n=s.indexOf("("),o=s.length;if(n>0&&n<o){const a=s.slice(0,n),l=St(s.slice(n+1));switch(e.identity(),a){case"translate":if(l.length>=1){const h=l[0];let g=0;l.length>=2&&(g=l[1]),e.translate(h,g)}break;case"rotate":if(l.length>=1){let h=0,g=0,f=0;h=l[0]*Math.PI/180,l.length>=3&&(g=l[1],f=l[2]),Qr.makeTranslation(-g,-f),Na.makeRotation(h),Fa.multiplyMatrices(Na,Qr),Qr.makeTranslation(g,f),e.multiplyMatrices(Qr,Fa)}break;case"scale":l.length>=1&&e.scale(l[0],l[1]??l[0]);break;case"skewX":l.length===1&&e.set(1,Math.tan(l[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":l.length===1&&e.set(1,0,0,Math.tan(l[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":l.length===6&&e.set(l[0],l[2],l[4],l[1],l[3],l[5],0,0,1);break}}A.premultiply(e)}}return A}function Lc(r){return new ke().arc(Be(r.getAttribute("cx")||0),Be(r.getAttribute("cy")||0),Be(r.getAttribute("r")||0),0,Math.PI*2)}function Gc(r,A){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let e=0;e<r.sheet.cssRules.length;e++){const t=r.sheet.cssRules[e];if(t.type!==1)continue;const i=t.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),s={};for(let n=t.style.length,o=0;o<n;o++){const a=t.style.item(o);s[a]=t.style.getPropertyValue(a)}for(let n=0;n<i.length;n++)A[i[n]]=Object.assign(A[i[n]]||{},{...s})}}function Oc(r){return new ke().ellipse(Be(r.getAttribute("cx")||0),Be(r.getAttribute("cy")||0),Be(r.getAttribute("rx")||0),Be(r.getAttribute("ry")||0),0,0,Math.PI*2)}function Hc(r){return new ke().moveTo(Be(r.getAttribute("x1")||0),Be(r.getAttribute("y1")||0)).lineTo(Be(r.getAttribute("x2")||0),Be(r.getAttribute("y2")||0))}function Jc(r){const A=new ke,e=r.getAttribute("d");return!e||e==="none"?null:(A.addData(e),A)}const Kc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Yc(r){var t;const A=new ke;let e=0;return(t=r.getAttribute("points"))==null||t.replace(Kc,(i,s,n)=>{const o=Be(s),a=Be(n);return e===0?A.moveTo(o,a):A.lineTo(o,a),e++,i}),A.currentCurve.autoClose=!0,A}const Wc=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function zc(r){var t;const A=new ke;let e=0;return(t=r.getAttribute("points"))==null||t.replace(Wc,(i,s,n)=>{const o=Be(s),a=Be(n);return e===0?A.moveTo(o,a):A.lineTo(o,a),e++,i}),A.currentCurve.autoClose=!1,A}function Vc(r){const A=Be(r.getAttribute("x")||0),e=Be(r.getAttribute("y")||0),t=Be(r.getAttribute("rx")||r.getAttribute("ry")||0),i=Be(r.getAttribute("ry")||r.getAttribute("rx")||0),s=Be(r.getAttribute("width")),n=Be(r.getAttribute("height")),o=1-.551915024494,a=new ke;return a.moveTo(A+t,e),a.lineTo(A+s-t,e),(t!==0||i!==0)&&a.bezierCurveTo(A+s-t*o,e,A+s,e+i*o,A+s,e+i),a.lineTo(A+s,e+n-i),(t!==0||i!==0)&&a.bezierCurveTo(A+s,e+n-i*o,A+s-t*o,e+n,A+s-t,e+n),a.lineTo(A+t,e+n),(t!==0||i!==0)&&a.bezierCurveTo(A+t*o,e+n,A,e+n-i*o,A,e+n-i),a.lineTo(A,e+i),(t!==0||i!==0)&&a.bezierCurveTo(A,e+i*o,A+t*o,e,A+t,e),a}function Mt(r,A,e){A=Object.assign({},A);let t={};if(r.hasAttribute("class")){const l=r.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<l.length;h++)t=Object.assign(t,e[`.${l[h]}`])}r.hasAttribute("id")&&(t=Object.assign(t,e[`#${r.getAttribute("id")}`]));for(let l=r.style.length,h=0;h<l;h++){const g=r.style.item(h),f=r.style.getPropertyValue(g);A[g]=f,t[g]=f}function i(l,h,g=s){r.hasAttribute(l)&&(A[h]=g(r.getAttribute(l))),t[l]&&(A[h]=g(t[l]))}function s(l){return l.startsWith("url")&&console.warn("url access in attributes is not implemented."),l}function n(l){return Math.max(0,Math.min(1,Be(l)))}function o(l){return Math.max(0,Be(l))}function a(l){return l.split(" ").filter(h=>h!=="").map(h=>Be(h))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",o),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",o),i("stroke-dasharray","strokeDasharray",a),i("stroke-dashoffset","strokeDashoffset",Be),i("visibility","visibility"),A}function tn(r,A,e=[],t={}){var g;if(r.nodeType!==1)return e;let i=!1,s=null,n={...A};switch(r.nodeName){case"svg":n=Mt(r,n,t);break;case"style":Gc(r,t);break;case"g":n=Mt(r,n,t);break;case"path":n=Mt(r,n,t),r.hasAttribute("d")&&(s=Jc(r));break;case"rect":n=Mt(r,n,t),s=Vc(r);break;case"polygon":n=Mt(r,n,t),s=Yc(r);break;case"polyline":n=Mt(r,n,t),s=zc(r);break;case"circle":n=Mt(r,n,t),s=Lc(r);break;case"ellipse":n=Mt(r,n,t),s=Oc(r);break;case"line":n=Mt(r,n,t),s=Hc(r);break;case"defs":i=!0;break;case"use":{n=Mt(r,n,t);const I=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||r.getAttribute("href")||"").substring(1),d=(g=r.viewportElement)==null?void 0:g.getElementById(I);d?tn(d,n,e,t):console.warn(`'use node' references non-existent node id: ${I}`);break}default:console.warn(r);break}if(n.display==="none")return e;const o=new Je,a=[],l=Fc(r,o,a);s&&(s.applyTransform(o),e.push(s),s.style={...n});const h=r.childNodes;for(let f=0,I=h.length;f<I;f++){const d=h[f];i&&d.nodeName!=="style"&&d.nodeName!=="defs"||tn(d,n,e,t)}return l&&(a.pop(),a.length>0?o.copy(a[a.length-1]):o.identity()),e}function An(r){var e;const A=en(r);return new nA(tn(A,{}),(e=A.getAttribute("viewBox"))==null?void 0:e.trim().split(" ").map(t=>Number(t)))}class Ta extends ke{constructor(){super(...arguments);u(this,"textureTransform");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineCap");u(this,"lineJoin");u(this,"lineWidth");u(this,"miterLimit");u(this,"_defaultStyle",ve.EMPTY);u(this,"_draws",[])}stroke(e){let t=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof ve?t=this.strokeStyle:t=new Ts(this.strokeStyle)),this.curves.length&&(this._draws.push({...e,type:"stroke",path:new ke(this),texture:t,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),super.reset())}fillRect(e,t,i,s){this.rect(e,t,i,s).fill()}strokeRect(e,t,i,s){this.rect(e,t,i,s).stroke()}fill(e){let t=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof ve?t=this.fillStyle:t=new Ts(this.fillStyle)),this._draws.push({...e,type:"fill",path:new ke(this),texture:t,textureTransform:this.textureTransform}),super.reset()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._draws.length=0,this}buildUvs(e,t,i,s,n){if(s){const o=s.width,a=s.height;for(let l=t.length,h=e;h<l;h+=2){const g=t[h],f=t[h+1];let I,d;n?[I,d]=n==null?void 0:n.applyToPoint(g,f):[I,d]=[g/o,f/a],i.push(I,d)}}else for(let o=t.length,a=e;a<o;a+=2)i.push(0,0)}toBatchables(){const e=[];let t=[],i=[],s=[],n;const o=l=>{e.push({vertices:t,indices:i,uvs:s,texture:n,type:l.type,disableWrapMode:l.disableWrapMode}),t=[],i=[],s=[],n=void 0};for(let l=this._draws.length,h=0;h<l;h++){const g=this._draws[h],f=this._draws[h-1];t.length&&f&&(f==null?void 0:f.type)!==g.type&&o(f);const I=n;I||(n=g.texture),t.length&&I!==g.texture&&!(I!=null&&I.is(g.texture))&&(o(g),n=g.texture);const d=t.length;g.type==="fill"?(g.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(d,t,s,g.texture,g.textureTransform)):(g.path.strokeTriangulate({vertices:t,indices:i,lineStyle:g.style,flipAlignment:!1,closed:!0}),this.buildUvs(d,t,s,g.texture,g.textureTransform))}const a=this._draws[this._draws.length-1];return a&&t.length&&o(a),e}}var qc=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,Ni=(r,A,e,t)=>{for(var i=t>1?void 0:t?Xc(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&&qc(A,e,i),i};c.CanvasItem=class extends c.TimelineNode{constructor(e,t=[]){super();u(this,"_parentGlobalVisible");u(this,"_globalVisible");u(this,"_parentGlobalOpacity");u(this,"_globalOpacity");u(this,"_modulate",new zt(4294967295));u(this,"context",new Ta);u(this,"_resetContext",!0);u(this,"_redrawing",!1);u(this,"_relayouting",!1);u(this,"_repainting",!1);u(this,"_originalBatchables",[]);u(this,"_layoutedBatchables",[]);u(this,"_batchables",[]);this.setProperties(e).append(t)}get globalVisible(){return this._globalVisible??!0}get globalOpacity(){return this._globalOpacity??1}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0,this.requestUpdate()}requestRelayout(){this._relayouting=!0,this.requestUpdate(),this.forEachChild(e=>{e instanceof c.CanvasItem&&e.requestRelayout()})}requestRepaint(){this._repainting=!0,this.requestUpdate()}_updateGlobalVisible(){var e;this._parentGlobalVisible=(e=this.getParent())==null?void 0:e.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){var t;this._parentGlobalOpacity=(t=this.getParent())==null?void 0:t.opacity;const e=xt(0,this.opacity,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){var e;return(e=this._tree)==null||e.log(this.name,"redrawing"),this._draw(),this.context.toBatchables()}_relayout(e){var t;return(t=this._tree)==null||t.log(this.name,"relayouting"),e}_repaint(e){var t;return(t=this._tree)==null||t.log(this.name,"repainting"),e.map(i=>({...i,modulate:this._modulate.toArgb(this.globalOpacity,!0),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==(t==null?void 0:t.globalVisible)&&this.requestUpdate(),this._parentGlobalOpacity!==(t==null?void 0:t.globalOpacity)&&this.requestUpdate()}_update(){const e=this.getParent();this._parentGlobalVisible!==(e==null?void 0:e.globalVisible)&&this._updateGlobalVisible(),this._parentGlobalOpacity!==(e==null?void 0:e.globalOpacity)&&this._updateGlobalOpacity();const t=this._redrawing;let i=this._relayouting,s=this._repainting,n;t&&(this._originalBatchables=this._redraw(),i=!0),i&&(this._layoutedBatchables=this._relayout(this._originalBatchables),s=!0),s&&(n=this._repaint(this._layoutedBatchables)),t&&this._resetContext&&this.context.reset(),n&&(this._batchables=n,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._batchables.forEach(t=>{var i,s;(i=t.texture)==null||i.upload(e),e.batch2D.render({...t,texture:(s=t.texture)==null?void 0:s._glTexture(e)})}),super._render(e)}},Ni([D()],c.CanvasItem.prototype,"modulate",2),Ni([D()],c.CanvasItem.prototype,"blendMode",2),Ni([pe({default:!0})],c.CanvasItem.prototype,"visible",2),Ni([pe({default:1})],c.CanvasItem.prototype,"opacity",2),c.CanvasItem=Ni([te("CanvasItem")],c.CanvasItem);class jc{constructor(){u(this,"currentCall");u(this,"calls",[])}createCall(A){return{renderable:A,parentCall:this.currentCall,fn:A.render.bind(A),calls:[]}}push(A){var t;const e=this.createCall(A);return(((t=this.currentCall)==null?void 0:t.calls)??this.calls).push(e),e}render(A){this.calls.forEach(function e(t){t.fn(A,()=>{t.calls.forEach(e)})}),this.calls=[]}}var Zc=Object.defineProperty,$c=Object.getOwnPropertyDescriptor,Fi=(r,A,e,t)=>{for(var i=t>1?void 0:t?$c(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&&Zc(A,e,i),i};c.Timeline=class extends c.Node{static from(A,e=!1){const[t,i]=A?Array.isArray(A)?A:[0,A]:[];return new c.Timeline({startTime:t,endTime:i,loop:e})}constructor(A){super(),this.setProperties(A)}_updateProperty(A,e,t){switch(super._updateProperty(A,e,t),A){case"startTime":this.startTime=Math.min(e,this.endTime);break;case"endTime":this.endTime=e||Number.MAX_SAFE_INTEGER;break}}addTime(A){const e=this.startTime,t=this.endTime;let i=this.currentTime;return i=i+A,this.loop&&i>t&&(i=e+i%t),i=xt(e,i,t),this.currentTime=i,this.emit("updateCurrentTime",i,A),this}_process(A){super._process(A),this.addTime(A)}},Fi([D({default:0})],c.Timeline.prototype,"startTime",2),Fi([D({default:0})],c.Timeline.prototype,"currentTime",2),Fi([D({default:Number.MAX_SAFE_INTEGER})],c.Timeline.prototype,"endTime",2),Fi([D({default:!1})],c.Timeline.prototype,"loop",2),c.Timeline=Fi([te("Timeline")],c.Timeline);var eu=Object.defineProperty,rn=(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&&eu(A,e,i),i};class Ti extends cr{constructor(e=new c.Timeline){super();u(this,"input",new Co);u(this,"renderStack",new jc);u(this,"root",new c.Viewport(!0).setTree(this));u(this,"timeline");u(this,"_backgroundColor",new zt);u(this,"_currentViewport");this.timeline=e.setTree(this)}getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=t;break}}log(...e){this.debug&&console.log("[modern-canvas]",...e)}_process(e=0){this.timeline.emit("process",e),this.emit("processing"),this.root.emit("process",e),this.emit("processed")}_render(e){this.emit("rendering"),e.program.uniforms.projectionMatrix=this.root.toProjectionArray(!0),this.renderStack.render(e),this._renderScreen(e),this.emit("rendered")}_renderScreen(e){e.state.reset(),e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:this.root.width*e.pixelRatio,height:this.root.height*e.pixelRatio}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const t=this.root.texture;t.activate(e,0),ue.draw(e),e.texture.unbind(t)}free(){super.free(),this.root.getChildren(!0).forEach(e=>this.root.removeChild(e)),this.input.removeEventListeners()}}rn([D({default:!1})],Ti.prototype,"processPaused"),rn([D()],Ti.prototype,"backgroundColor"),rn([pe({default:!1})],Ti.prototype,"debug");var tu=Object.getOwnPropertyDescriptor,Au=(r,A,e,t)=>{for(var i=t>1?void 0:t?tu(A,e):A,s=r.length-1,n;s>=0;s--)(n=r[s])&&(i=n(i)||i);return i};c.Transition=class extends c.Effect{constructor(A,e=[]){super(),this.setProperties(A).append(e)}},c.Transition=Au([te("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],c.Transition);var La=Object.defineProperty,iu=Object.getOwnPropertyDescriptor,ru=(r,A,e)=>A in r?La(r,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[A]=e,sn=(r,A,e,t)=>{for(var i=t>1?void 0:t?iu(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&&La(A,e,i),i},Ga=(r,A,e)=>ru(r,typeof A!="symbol"?A+"":A,e);const Oa=`varying vec2 vUv[9];
277
277
  uniform sampler2D sampler;
278
278
 
279
279
  void main(void) {
package/dist/index.mjs CHANGED
@@ -5996,14 +5996,14 @@ let Node = class extends CoreObject {
5996
5996
  remove() {
5997
5997
  this._parent?.removeChild(this);
5998
5998
  }
5999
- forEach(fn) {
6000
- this.getChildren().forEach(fn);
5999
+ forEachChild(callbackfn) {
6000
+ this.getChildren().forEach(callbackfn);
6001
6001
  return this;
6002
6002
  }
6003
- deepForEach(fn) {
6003
+ forEachDescendant(callbackfn) {
6004
6004
  this.getChildren().forEach((child) => {
6005
- fn(child);
6006
- child.deepForEach(fn);
6005
+ callbackfn(child);
6006
+ child.forEachDescendant(callbackfn);
6007
6007
  });
6008
6008
  return this;
6009
6009
  }
@@ -7306,6 +7306,11 @@ let CanvasItem = class extends TimelineNode {
7306
7306
  requestRelayout() {
7307
7307
  this._relayouting = true;
7308
7308
  this.requestUpdate();
7309
+ this.forEachChild((node) => {
7310
+ if (node instanceof CanvasItem) {
7311
+ node.requestRelayout();
7312
+ }
7313
+ });
7309
7314
  }
7310
7315
  requestRepaint() {
7311
7316
  this._repainting = true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.4.31",
4
+ "version": "0.4.32",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",