UNPKG

modern-canvas

Version:

A JavaScript WebGL rendering engine.

2 lines 561 kB
(function(g,QA){typeof exports=="object"&&typeof module<"u"?QA(exports):typeof define=="function"&&define.amd?define(["exports"],QA):(g=typeof globalThis<"u"?globalThis:g||self,QA(g.modernCanvas={}))})(this,function(g){"use strict";var QA=typeof document<"u"?document.currentScript:null,Nc={grad:.9,turn:360,rad:360/(2*Math.PI)},He=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Mt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},Ie=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},$n=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},to=function(r){return{r:Ie(r.r,0,255),g:Ie(r.g,0,255),b:Ie(r.b,0,255),a:Ie(r.a)}},is=function(r){return{r:Mt(r.r),g:Mt(r.g),b:Mt(r.b),a:Mt(r.a,3)}},Fc=/^#([0-9a-f]{3,8})$/i,$i=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},eo=function(r){var t=r.r,e=r.g,A=r.b,i=r.a,s=Math.max(t,e,A),n=s-Math.min(t,e,A),o=n?s===t?(e-A)/n:s===e?2+(A-t)/n:4+(t-e)/n:0;return{h:60*(o<0?o+6:o),s:s?n/s*100:0,v:s/255*100,a:i}},Ao=function(r){var t=r.h,e=r.s,A=r.v,i=r.a;t=t/360*6,e/=100,A/=100;var s=Math.floor(t),n=A*(1-e),o=A*(1-(t-s)*e),a=A*(1-(1-t+s)*e),l=s%6;return{r:255*[A,o,n,n,a,A][l],g:255*[a,A,A,o,n,n][l],b:255*[n,n,a,A,A,o][l],a:i}},io=function(r){return{h:$n(r.h),s:Ie(r.s,0,100),l:Ie(r.l,0,100),a:Ie(r.a)}},ro=function(r){return{h:Mt(r.h),s:Mt(r.s),l:Mt(r.l),a:Mt(r.a,3)}},so=function(r){return Ao((e=(t=r).s,{h:t.h,s:(e*=((A=t.l)<50?A:100-A)/100)>0?2*e/(A+e)*100:0,v:A+e,a:t.a}));var t,e,A},li=function(r){return{h:(t=eo(r)).h,s:(i=(200-(e=t.s))*(A=t.v)/100)>0&&i<200?e*A/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,e,A,i},Tc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Oc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rs={string:[[function(r){var t=Fc.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Mt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Mt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=Gc.exec(r)||Oc.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:to({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=Tc.exec(r)||Lc.exec(r);if(!t)return null;var e,A,i=io({h:(e=t[1],A=t[2],A===void 0&&(A="deg"),Number(e)*(Nc[A]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return so(i)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,A=r.b,i=r.a,s=i===void 0?1:i;return He(t)&&He(e)&&He(A)?to({r:Number(t),g:Number(e),b:Number(A),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,A=r.l,i=r.a,s=i===void 0?1:i;if(!He(t)||!He(e)||!He(A))return null;var n=io({h:Number(t),s:Number(e),l:Number(A),a:Number(s)});return so(n)},"hsl"],[function(r){var t=r.h,e=r.s,A=r.v,i=r.a,s=i===void 0?1:i;if(!He(t)||!He(e)||!He(A))return null;var n=function(o){return{h:$n(o.h),s:Ie(o.s,0,100),v:Ie(o.v,0,100),a:Ie(o.a)}}({h:Number(t),s:Number(e),v:Number(A),a:Number(s)});return Ao(n)},"hsv"]]},no=function(r,t){for(var e=0;e<t.length;e++){var A=t[e][0](r);if(A)return[A,t[e][1]]}return[null,void 0]},Hc=function(r){return typeof r=="string"?no(r.trim(),rs.string):typeof r=="object"&&r!==null?no(r,rs.object):[null,void 0]},ss=function(r,t){var e=li(r);return{h:e.h,s:Ie(e.s+100*t,0,100),l:e.l,a:e.a}},ns=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},oo=function(r,t){var e=li(r);return{h:e.h,s:e.s,l:Ie(e.l+100*t,0,100),a:e.a}},os=function(){function r(t){this.parsed=Hc(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Mt(ns(this.rgba),2)},r.prototype.isDark=function(){return ns(this.rgba)<.5},r.prototype.isLight=function(){return ns(this.rgba)>=.5},r.prototype.toHex=function(){return t=is(this.rgba),e=t.r,A=t.g,i=t.b,n=(s=t.a)<1?$i(Mt(255*s)):"","#"+$i(e)+$i(A)+$i(i)+n;var t,e,A,i,s,n},r.prototype.toRgb=function(){return is(this.rgba)},r.prototype.toRgbString=function(){return t=is(this.rgba),e=t.r,A=t.g,i=t.b,(s=t.a)<1?"rgba("+e+", "+A+", "+i+", "+s+")":"rgb("+e+", "+A+", "+i+")";var t,e,A,i,s},r.prototype.toHsl=function(){return ro(li(this.rgba))},r.prototype.toHslString=function(){return t=ro(li(this.rgba)),e=t.h,A=t.s,i=t.l,(s=t.a)<1?"hsla("+e+", "+A+"%, "+i+"%, "+s+")":"hsl("+e+", "+A+"%, "+i+"%)";var t,e,A,i,s},r.prototype.toHsv=function(){return t=eo(this.rgba),{h:Mt(t.h),s:Mt(t.s),v:Mt(t.v),a:Mt(t.a,3)};var t},r.prototype.invert=function(){return be({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),be(ss(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),be(ss(this.rgba,-t))},r.prototype.grayscale=function(){return be(ss(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),be(oo(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),be(oo(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?be({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Mt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=li(this.rgba);return typeof t=="number"?be({h:t,s:e.s,l:e.l,a:e.a}):Mt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===be(t).toHex()},r}(),be=function(r){return r instanceof os?r:new os(r)},ao=[],Jc=function(r){r.forEach(function(t){ao.indexOf(t)<0&&(t(os,rs),ao.push(t))})};const Kc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Yc=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Kc[e[r]&63];return t};class Je{eventListeners=new Map;addEventListener(t,e,A){const i={value:e,options:A},s=this.eventListeners.get(t);return s?Array.isArray(s)?s.push(i):this.eventListeners.set(t,[s,i]):this.eventListeners.set(t,i),this}removeEventListener(t,e,A){if(!e)return this.eventListeners.delete(t),this;const i=this.eventListeners.get(t);if(!i)return this;if(Array.isArray(i)){const s=[];for(let n=0,o=i.length;n<o;n++){const a=i[n];(a.value!==e||typeof A=="object"&&A?.once&&(typeof a.options=="boolean"||!a.options?.once))&&s.push(a)}s.length?this.eventListeners.set(t,s.length===1?s[0]:s):this.eventListeners.delete(t)}else i.value===e&&(typeof A=="boolean"||!A?.once||typeof i.options=="boolean"||i.options?.once)&&this.eventListeners.delete(t);return this}removeAllListeners(){return this.eventListeners.clear(),this}hasEventListener(t){return this.eventListeners.has(t)}dispatchEvent(t,...e){const A=this.eventListeners.get(t);if(A){if(Array.isArray(A))for(let i=A.length,s=0;s<i;s++){const n=A[s];typeof n.options=="object"&&n.options?.once&&this.off(t,n.value,n.options),n.value.apply(this,e)}else typeof A.options=="object"&&A.options?.once&&this.off(t,A.value,A.options),A.value.apply(this,e);return!0}else return!1}on(t,e,A){return this.addEventListener(t,e,A)}once(t,e){return this.addEventListener(t,e,{once:!0})}off(t,e,A){return this.removeEventListener(t,e,A)}emit(t,...e){this.dispatchEvent(t,...e)}}function lt(r){return r==null||r==="none"}function UA(r,t=0,e=10**t){return Math.round(e*r)/e+0}function ae(r,t=!1){if(typeof r!="object"||!r)return r;if(Array.isArray(r))return t?r.map(A=>ae(A,t)):r;const e={};for(const A in r){const i=r[A];i!=null&&(t?e[A]=ae(i,t):e[A]=i)}return e}function as(r,t){const e={};return t.forEach(A=>{A in r&&(e[A]=r[A])}),e}function ls(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){const e=Array.from(new Set([...Object.keys(r),...Object.keys(t)]));return!e.length||e.every(A=>r[A]===t[A])}return!1}function Vc(r,t,e){const A=t.length-1;if(A<0)return r===void 0?e:r;for(let i=0;i<A;i++){if(r==null)return e;r=r[t[i]]}return r==null||r[t[A]]===void 0?e:r[t[A]]}function Wc(r,t,e){const A=t.length-1;for(let i=0;i<A;i++)typeof r[t[i]]!="object"&&(r[t[i]]={}),r=r[t[i]];r[t[A]]=e}function zc(r,t,e){return r==null||!t||typeof t!="string"?e:r[t]!==void 0?r[t]:(t=t.replace(/\[(\w+)\]/g,".$1"),t=t.replace(/^\./,""),Vc(r,t.split("."),e))}function qc(r,t,e){if(!(typeof r!="object"||!t))return t=t.replace(/\[(\w+)\]/g,".$1"),t=t.replace(/^\./,""),Wc(r,t.split("."),e)}let lo=class{_map=new WeakMap;_toRaw(t){if(t&&typeof t=="object"){const e=t.__v_raw;e&&(t=this._toRaw(e))}return t}delete(t){return this._map.delete(this._toRaw(t))}get(t){return this._map.get(this._toRaw(t))}has(t){return this._map.has(this._toRaw(t))}set(t,e){return this._map.set(this._toRaw(t),this._toRaw(e)),this}};function cs(r){let t;return typeof r=="number"?t={r:r>>24&255,g:r>>16&255,b:r>>8&255,a:(r&255)/255}:t=r,be(t)}function Xc(r){return{r:UA(r.r),g:UA(r.g),b:UA(r.b),a:UA(r.a,3)}}function tr(r){const t=r.toString(16);return t.length<2?`0${t}`:t}const co="#000000FF";function jc(r){return cs(r).isValid()}function ne(r,t=!1){const e=cs(r);if(!e.isValid()){if(typeof r=="string")return r;const o=`Failed to normalizeColor ${r}`;if(t)throw new Error(o);return console.warn(o),co}const{r:A,g:i,b:s,a:n}=Xc(e.rgba);return`#${tr(A)}${tr(i)}${tr(s)}${tr(UA(n*255))}`}var er=er||{};er.parse=function(){const r={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let t="";function e(U){const P=new Error(`${t}: ${U}`);throw P.source=t,P}function A(){const U=i();return t.length>0&&e("Invalid input not EOF"),U}function i(){return m(s)}function s(){return n("linear-gradient",r.linearGradient,a)||n("repeating-linear-gradient",r.repeatingLinearGradient,a)||n("radial-gradient",r.radialGradient,h)||n("repeating-radial-gradient",r.repeatingRadialGradient,h)}function n(U,P,q){return o(P,$=>{const nt=q();return nt&&(K(r.comma)||e("Missing comma before color stops")),{type:U,orientation:nt,colorStops:m(D)}})}function o(U,P){const q=K(U);if(q){K(r.startCall)||e("Missing (");const $=P(q);return K(r.endCall)||e("Missing )"),$}}function a(){const U=l();if(U)return U;const P=tt("position-keyword",r.positionKeywords,1);return P?{type:"directional",value:P.value}:c()}function l(){return tt("directional",r.sideOrCorner,1)}function c(){return tt("angular",r.angleValue,1)||tt("angular",r.radianValue,1)}function h(){let U,P=u(),q;return P&&(U=[],U.push(P),q=t,K(r.comma)&&(P=u(),P?U.push(P):t=q)),U}function u(){let U=d()||f();if(U)U.at=p();else{const P=E();if(P){U=P;const q=p();q&&(U.at=q)}else{const q=p();if(q)U={type:"default-radial",at:q};else{const $=x();$&&(U={type:"default-radial",at:$})}}}return U}function d(){const U=tt("shape",/^(circle)/i,0);return U&&(U.style=z()||E()),U}function f(){const U=tt("shape",/^(ellipse)/i,0);return U&&(U.style=x()||T()||E()),U}function E(){return tt("extent-keyword",r.extentKeywords,1)}function p(){if(tt("position",/^at/,0)){const U=x();return U||e("Missing positioning value"),U}}function x(){const U=R();if(U.x||U.y)return{type:"position",value:U}}function R(){return{x:T(),y:T()}}function m(U){let P=U();const q=[];if(P)for(q.push(P);K(r.comma);)P=U(),P?q.push(P):e("One extra comma");return q}function D(){const U=Q();return U||e("Expected color definition"),U.length=T(),U}function Q(){return S()||H()||W()||V()||M()||et()||w()}function w(){return tt("literal",r.literalColor,0)}function S(){return tt("hex",r.hexColor,1)}function M(){return o(r.rgbColor,()=>({type:"rgb",value:m(J)}))}function V(){return o(r.rgbaColor,()=>({type:"rgba",value:m(J)}))}function et(){return o(r.varColor,()=>({type:"var",value:Z()}))}function W(){return o(r.hslColor,()=>{K(r.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const P=J();K(r.comma);let q=K(r.percentageValue);const $=q?q[1]:null;K(r.comma),q=K(r.percentageValue);const nt=q?q[1]:null;return(!$||!nt)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[P,$,nt]}})}function H(){return o(r.hslaColor,()=>{const U=J();K(r.comma);let P=K(r.percentageValue);const q=P?P[1]:null;K(r.comma),P=K(r.percentageValue);const $=P?P[1]:null;K(r.comma);const nt=J();return(!q||!$)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[U,q,$,nt]}})}function Z(){return K(r.variableName)[1]}function J(){return K(r.number)[1]}function T(){return tt("%",r.percentageValue,1)||it()||L()||z()}function it(){return tt("position-keyword",r.positionKeywords,1)}function L(){return o(r.calcValue,()=>{let U=1,P=0;for(;U>0&&P<t.length;){const $=t.charAt(P);$==="("?U++:$===")"&&U--,P++}U>0&&e("Missing closing parenthesis in calc() expression");const q=t.substring(0,P-1);return At(P-1),{type:"calc",value:q}})}function z(){return tt("px",r.pixelValue,1)||tt("em",r.emValue,1)}function tt(U,P,q){const $=K(P);if($)return{type:U,value:$[q]}}function K(U){let P,q;return q=/^\s+/.exec(t),q&&At(q[0].length),P=U.exec(t),P&&At(P[0].length),P}function At(U){t=t.substr(U)}return function(U){return t=U.toString().trim(),t.endsWith(";")&&(t=t.slice(0,-1)),A()}}();const Zc=er.parse.bind(er);var Ar=Ar||{};Ar.stringify=function(){var r={"visit_linear-gradient":function(t){return r.visit_gradient(t)},"visit_repeating-linear-gradient":function(t){return r.visit_gradient(t)},"visit_radial-gradient":function(t){return r.visit_gradient(t)},"visit_repeating-radial-gradient":function(t){return r.visit_gradient(t)},visit_gradient:function(t){var e=r.visit(t.orientation);return e&&(e+=", "),t.type+"("+e+r.visit(t.colorStops)+")"},visit_shape:function(t){var e=t.value,A=r.visit(t.at),i=r.visit(t.style);return i&&(e+=" "+i),A&&(e+=" at "+A),e},"visit_default-radial":function(t){var e="",A=r.visit(t.at);return A&&(e+=A),e},"visit_extent-keyword":function(t){var e=t.value,A=r.visit(t.at);return A&&(e+=" at "+A),e},"visit_position-keyword":function(t){return t.value},visit_position:function(t){return r.visit(t.value.x)+" "+r.visit(t.value.y)},"visit_%":function(t){return t.value+"%"},visit_em:function(t){return t.value+"em"},visit_px:function(t){return t.value+"px"},visit_calc:function(t){return"calc("+t.value+")"},visit_literal:function(t){return r.visit_color(t.value,t)},visit_hex:function(t){return r.visit_color("#"+t.value,t)},visit_rgb:function(t){return r.visit_color("rgb("+t.value.join(", ")+")",t)},visit_rgba:function(t){return r.visit_color("rgba("+t.value.join(", ")+")",t)},visit_hsl:function(t){return r.visit_color("hsl("+t.value[0]+", "+t.value[1]+"%, "+t.value[2]+"%)",t)},visit_hsla:function(t){return r.visit_color("hsla("+t.value[0]+", "+t.value[1]+"%, "+t.value[2]+"%, "+t.value[3]+")",t)},visit_var:function(t){return r.visit_color("var("+t.value+")",t)},visit_color:function(t,e){var A=t,i=r.visit(e.length);return i&&(A+=" "+i),A},visit_angular:function(t){return t.value+"deg"},visit_directional:function(t){return"to "+t.value},visit_array:function(t){var e="",A=t.length;return t.forEach(function(i,s){e+=r.visit(i),s<A-1&&(e+=", ")}),e},visit_object:function(t){return t.width&&t.height?r.visit(t.width)+" "+r.visit(t.height):""},visit:function(t){if(!t)return"";if(t instanceof Array)return r.visit_array(t);if(typeof t=="object"&&!t.type)return r.visit_object(t);if(t.type){var e=r["visit_"+t.type];if(e)return e(t);throw Error("Missing visitor visit_"+t.type)}else throw Error("Invalid node.")}};return function(t){return r.visit(t)}}(),Ar.stringify.bind(Ar);function ho(r){const t=r.length-1;return r.map((e,A)=>{const i=e.value;let s=UA(A/t,3),n="#00000000";switch(e.type){case"rgb":n=ne({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":n=ne({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":n=ne(e.value);break;case"hex":n=ne(`#${e.value}`);break}switch(e.length?.type){case"%":s=Number(e.length.value)/100;break}return{offset:s,color:n}})}function go(r){let t=0;switch(r.orientation?.type){case"angular":t=Number(r.orientation.value);break}return{type:"linear-gradient",angle:t,stops:ho(r.colorStops)}}function uo(r){return r.orientation?.map(t=>{switch(t?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:ho(r.colorStops)}}function ci(r){return r.startsWith("linear-gradient(")||r.startsWith("radial-gradient(")}function $c(r){return Zc(r).map(t=>{switch(t?.type){case"linear-gradient":return go(t);case"repeating-linear-gradient":return{...go(t),repeat:!0};case"radial-gradient":return uo(t);case"repeating-radial-gradient":return{...uo(t),repeat:!0};default:return}}).filter(Boolean)}function th(r){let t;return typeof r=="string"?t={color:r}:t=r,{color:ne(t.color)}}function eh(r){let t;if(typeof r=="string"?t={image:r}:t=r,t.image){const{type:e,...A}=$c(t.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:A};case"linear-gradient":return{linearGradient:A}}}return t}function Ah(r){let t;return typeof r=="string"?t={image:r}:t=r,t}function ih(r){let t;return typeof r=="string"?t={preset:r}:t=r,{preset:t.preset,foregroundColor:lt(t.foregroundColor)?void 0:ne(t.foregroundColor),backgroundColor:lt(t.backgroundColor)?void 0:ne(t.backgroundColor)}}function hs(r){return!lt(r.color)}function rh(r){return typeof r=="string"?jc(r):hs(r)}function sh(r){return!lt(r.image)&&ci(r.image)||!!r.linearGradient||!!r.radialGradient}function nh(r){return typeof r=="string"?ci(r):sh(r)}function oh(r){return!lt(r.image)&&!ci(r.image)}function ah(r){return typeof r=="string"?!ci(r):oh(r)}function lh(r){return!lt(r.preset)}function ch(r){return typeof r=="string"?!1:lh(r)}function De(r){const t=r&&typeof r=="object"?r.enabled:void 0;return rh(r)?ae({enabled:t,...th(r)}):nh(r)?ae({enabled:t,...eh(r)}):ah(r)?ae({enabled:t,...Ah(r)}):ch(r)?ae({enabled:t,...ih(r)}):{}}function hh(r){return typeof r=="string"?{...De(r)}:{...De(r),...as(r,["fillWithShape"])}}const gs=Symbol("properties"),fo=Symbol("defaultValueInited");function us(r){let t;if(Object.hasOwn(r,gs))t=r[gs];else{const e=Object.getPrototypeOf(r);t=new Map(e?us(e):void 0),r[gs]=t}return t}function gh(r,t={}){const e=Symbol.for(r),{default:A,fallback:i,alias:s}=t,n={declaration:t,internalKey:e},o=()=>typeof A=="function"?A():A,a=()=>typeof i=="function"?i():i;function l(){let h;if(s&&s!==r?h=zc(this,s):typeof this.getter<"u"?h=this.getter(r,n):h=this[e],h=h??a(),h===void 0&&A!==void 0&&!this[fo]){this[fo]=!0;const u=o();u!==void 0&&(c.call(this,u),h=u)}return h}function c(h){s&&s!==r?qc(this,s,h):typeof this.setter<"u"?this.setter(r,h,n):this[e]=h}return{get:l,set:c}}function ir(r,t,e={}){us(r).set(t,e);const A=gh(t,e);Object.defineProperty(r.prototype,t,{get(){return A.get.call(this)},set(i){const s=A.get.call(this);A.set.call(this,i),this.onUpdateProperty?.(t,i,s,e)},configurable:!0,enumerable:!0})}function v(r){return function(t,e){if(typeof e!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");ir(t.constructor,e,r)}}function uh(r){return typeof r=="string"?{...De(r)}:{...De(r),...as(r,["fillWithShape"])}}const Io=()=>Yc(10);function rr(r){return typeof r=="string"?{...De(r)}:{...De(r),...as(r,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function fh(r){return typeof r=="string"?{color:ne(r)}:{...r,color:lt(r.color)?co:ne(r.color)}}function dh(){return{boxShadow:"none"}}function Ih(r){return typeof r=="string"?r.startsWith("<svg")?{svg:r}:{paths:[{data:r}]}:Array.isArray(r)?{paths:r.map(t=>typeof t=="string"?{data:t}:t)}:r}function ph(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Bh(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Eh(){return{...ph(),...Bh(),...dh(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Ch(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Qh(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function yh(){return{...Ch(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function mh(){return{...Qh(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function wh(){return{...mh(),...yh(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function sr(r){return ae({...r,color:lt(r.color)?void 0:ne(r.color),backgroundColor:lt(r.backgroundColor)?void 0:ne(r.backgroundColor),borderColor:lt(r.borderColor)?void 0:ne(r.borderColor),outlineColor:lt(r.outlineColor)?void 0:ne(r.outlineColor),shadowColor:lt(r.shadowColor)?void 0:ne(r.shadowColor)})}function po(){return{...Eh(),...wh()}}const vh=/\r\n|\n\r|\n|\r/,_h=new RegExp(`^(${vh.source})$`),Bo=` `;function bh(r){return _h.test(r)}function fs(r){const t=[];function e(){return t[t.length-1]}function A(o,a,l){const c=o?sr(o):{},h=a?De(a):void 0,u=l?rr(l):void 0,d=ae({...c,fill:h,outline:u,fragments:[]});return t[t.length-1]?.fragments.length===0?t[t.length-1]=d:t.push(d),d}function i(o="",a,l,c){const h=a?sr(a):{},u=l?De(l):void 0,d=c?rr(c):void 0;Array.from(o).forEach(f=>{if(bh(f)){const{fragments:E,fill:p,outline:x,...R}=e()||A();E.length||E.push(ae({...h,fill:u,outline:d,content:Bo})),A(R,p,x)}else{const E=e()||A(),p=E.fragments[E.fragments.length-1];if(p){const{content:x,fill:R,outline:m,...D}=p;if(ls(u,R)&&ls(d,m)&&ls(h,D)){p.content=`${x}${f}`;return}}E.fragments.push(ae({...h,fill:u,outline:d,content:f}))}})}(Array.isArray(r)?r:[r]).forEach(o=>{if(typeof o=="string")A(),i(o);else if(Eo(o)){const{content:a,fill:l,outline:c,...h}=o;A(h,l,c),i(a)}else if(Dh(o)){const{fragments:a,fill:l,outline:c,...h}=o;A(h,l,c),a.forEach(u=>{const{content:d,fill:f,outline:E,...p}=u;i(d,p,f,E)})}else Array.isArray(o)?(A(),o.forEach(a=>{if(typeof a=="string")i(a);else if(Eo(a)){const{content:l,fill:c,outline:h,...u}=a;i(l,u,c,h)}})):console.warn("Failed to parse text content",o)});const n=e();return n&&!n.fragments.length&&n.fragments.push({content:Bo}),t}function Dh(r){return r&&typeof r=="object"&&"fragments"in r&&Array.isArray(r.fragments)}function Eo(r){return r&&typeof r=="object"&&"content"in r&&typeof r.content=="string"}function Co(r){return typeof r=="string"||Array.isArray(r)?{content:fs(r)}:ae({...r,content:fs(r.content??""),style:r.style?sr(r.style):void 0,effects:r.effects?r.effects.map(t=>sr(t)):void 0,measureDom:r.measureDom,fonts:r.fonts,fill:r.fill?De(r.fill):void 0,outline:r.outline?rr(r.outline):void 0})}const nr=new Map;function st(r,t){return function(e){Object.defineProperty(e.prototype,"is",{value:r,enumerable:!0,configurable:!0}),t&&Object.keys(t).forEach(A=>{ir(e,A,{fallback:t[A]})}),nr.set(r,e)}}function xh(r="node",t={}){const e=nr.get(r);if(!e)throw new Error(`Failed to createNode, tag: ${r}`);return new e().setProperties(t)}class Yt{static _queue=[];static _currentTime=0;static _elapsed=0;static _requestId;static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(t,e={}){const{sort:A=0,once:i=!1}=e;this._queue[A]||(this._queue[A]=[]),this._queue[A].push({cb:t,once:i})}static off(t,e={}){const{sort:A=0}=e,i=this._queue[A];if(!i)return;const s=[];for(let n=i.length,o=0;o<n;o++){const a=i[o];a.cb!==t&&s.push(a)}s.length?this._queue[A]=s:this._queue.splice(A,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(t=>this._update(t)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(t){this._elapsed=t-this._currentTime,this._currentTime=t,this._requestId=requestAnimationFrame(e=>this._update(e)),this._performUpdate()}static _performUpdate(){const t=this._queue,e=[];for(let A=t.length,i=A;i>=0;i--){const s=t[i];if(!s)continue;const n=[];for(let o=s.length,a=0;a<o;a++){const l=s[a];try{l.cb()}catch(c){console.warn(c)}l.once||n.push(l)}n.length&&(e[i]=n)}this._queue=e}}Yt.start();async function ds(r){return new Promise(t=>{Yt.on(()=>{r?.(),t()},{sort:1,once:!0})})}const or=Math.PI,le=or*2;let Sh=0;function Qo(r){return r?.__SPECTOR_Object_TAG?.id??++Sh}function Is(r){return!(r&r-1)&&!!r}const Mh=/([\w-]+)\((.+?)\)/g,Rh=/[^,]+/g,kh=/([-e.\d]+)(.*)/;function ps(r){return Array.isArray(r)?r.map(t=>({name:t.name,args:t.args.map(e=>({...e,normalizedIntValue:e.normalizedDefaultIntValue}))})):{...r,normalizedIntValue:r.normalizedDefaultIntValue}}function hi(r,t,e={}){const A=gi(t,e);return A.length?A:yo(r,t,e)}function gi(r,t={}){const e=[];let A;for(;(A=Mh.exec(r))!==null;){const[,i,s]=A;i&&e.push({name:i,args:Ph(i,s,t)})}return e}function Ph(r,t,e={}){const A=[];let i,s=0;for(;(i=Rh.exec(t))!==null;)A.push(yo(r,i[0],{...e,index:s++}));return A}function yo(r,t,e={}){const{width:A=1,height:i=1,index:s=0}=e,n=t.match(kh),o={unit:n?.[2]??null,value:t,intValue:Number(n?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(r){case"scale":case"scaleX":case"scaleY":case"scale3d":o.normalizedDefaultIntValue=1;break}switch(o.unit){case"%":o.normalizedIntValue=o.intValue/100;break;case"rad":o.normalizedIntValue=o.intValue/le;break;case"deg":o.normalizedIntValue=o.intValue/360;break;case"px":switch(s){case 0:o.normalizedIntValue=o.intValue/A;break;case 1:o.normalizedIntValue=o.intValue/i;break}break;case"turn":case"em":case"rem":default:o.normalizedIntValue=o.intValue;break}return o}const mo="WebGL2RenderingContext"in globalThis,wo="ImageBitmap"in globalThis,vo="ResizeObserver"in globalThis,NA="PointerEvent"in globalThis,_o="WheelEvent"in globalThis,Uh="MouseEvent"in globalThis,Ke="ontouchstart"in globalThis,bo="onclick"in globalThis,Bs="createImageBitmap"in globalThis,Es="AudioContext"in globalThis,Cs="webkitAudioContext"in globalThis,Qs="OfflineAudioContext"in globalThis,Do="webkitOfflineAudioContext"in globalThis,xo=Es||Cs,ui=typeof window<"u",ys=globalThis.devicePixelRatio||1,ms=r=>r!==null&&typeof r=="object"&&r.nodeType===1,So=r=>ms(r)&&r.tagName==="VIDEO",Nh=r=>ms(r)&&r.tagName==="IMG";function Mo(r){return typeof r=="object"&&r!==null&&r.nodeType===1&&r.tagName==="CANVAS"}function Ro(r){return mo&&r instanceof globalThis.WebGL2RenderingContext}function ko(){if(ui)return globalThis.document.createElement("canvas")}function Po(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function Uo(r,t,e){e===null&&!t.startsWith("data:")?r.crossOrigin=Po(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}class ws{_map=new WeakMap;_toRaw(t){if(t&&typeof t=="object"){const e=t.__v_raw;e&&(t=this._toRaw(e))}return t}delete(t){return this._map.delete(this._toRaw(t))}get(t){return this._map.get(this._toRaw(t))}has(t){return this._map.has(this._toRaw(t))}set(t,e){return this._map.set(this._toRaw(t),this._toRaw(e)),this}}class fi{cursor;bubbles=!1;cancelBubble=!1;cancelable=!1;composed=!1;defaultPrevented=!1;eventPhase=fi.prototype.NONE;isTrusted=!1;timeStamp=0;type="";composedPath(){return this.path}initEvent(...t){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){"preventDefault"in this.nativeEvent&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}propagationImmediatelyStopped=!1;stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}propagationStopped=!1;stopPropagation(){"stopPropagation"in this.nativeEvent&&this.nativeEvent.stopPropagation(),this.propagationStopped=!0}NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;initUIEvent(...t){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class No extends fi{getModifierState(...t){throw new Error("getModifierState() is a legacy DOM API. It is not implemented in the Federated Events API.")}initKeyboardEvent(...t){throw new Error("initKeyboardEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class vs extends fi{client={x:0,y:0};get clientX(){return this.client.x}get clientY(){return this.client.y}layer={x:0,y:0};get layerX(){return this.layer.x}get layerY(){return this.layer.y}movement={x:0,y:0};get movementX(){return this.movement.x}get movementY(){return this.movement.y}offset={x:0,y:0};get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}page={x:0,y:0};get pageX(){return this.page.x}get pageY(){return this.page.y}screen={x:0,y:0};get screenX(){return this.screen.x}get screenY(){return this.screen.y}get x(){return this.clientX}get y(){return this.clientY}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(...t){throw new Error("Method not implemented.")}global={x:0,y:0};get globalX(){return this.global.x}get globalY(){return this.global.y}}class Fo extends vs{width=0;height=0;isPrimary=!1;getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class To extends vs{static DOM_DELTA_PIXEL=0;DOM_DELTA_PIXEL=0;static DOM_DELTA_LINE=1;DOM_DELTA_LINE=1;static DOM_DELTA_PAGE=2;DOM_DELTA_PAGE=2}const Fh={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class Lo extends Je{event;target;cursor="default";cursorStyles={default:"inherit",pointer:"pointer"};setuped=!1;enableMoveEvent=!0;enableWheelEvent=!0;enableClickEvent=!0;setTarget(t){this.removeEventListeners(),this.target=t,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const t=this.target.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):NA&&(t.touchAction=""),NA?(this.target.removeEventListener("pointerdown",this._onPointerDown),this.target.removeEventListener("pointerleave",this._onPointerOver),this.target.removeEventListener("pointerover",this._onPointerOver),this.target.removeEventListener("pointermove",this._onPointerMove),this.target.removeEventListener("pointerup",this._onPointerUp)):(this.target.removeEventListener("mousedown",this._onPointerDown),this.target.removeEventListener("mouseout",this._onPointerOver),this.target.removeEventListener("mouseover",this._onPointerOver),this.target.removeEventListener("mousemove",this._onPointerMove),this.target.removeEventListener("mouseup",this._onPointerUp)),Ke&&(this.target.removeEventListener("touchstart",this._onPointerDown),this.target.removeEventListener("touchmove",this._onPointerMove),this.target.removeEventListener("touchend",this._onPointerUp)),this.target.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keypress",this._onKeyPress),document.removeEventListener("keyup",this._onKeyUp),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const t=this.target.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):NA&&(t.touchAction="none")),NA?(this.target.addEventListener("pointerdown",this._onPointerDown),this.target.addEventListener("pointerleave",this._onPointerOver),this.target.addEventListener("pointerover",this._onPointerOver),this.target.addEventListener("pointermove",this._onPointerMove),this.target.addEventListener("pointerup",this._onPointerUp)):(this.target.addEventListener("mousedown",this._onPointerDown),this.target.addEventListener("mouseout",this._onPointerOver),this.target.addEventListener("mouseover",this._onPointerOver),this.target.addEventListener("mousemove",this._onPointerMove),this.target.addEventListener("mouseup",this._onPointerUp)),Ke&&(this.target.addEventListener("touchstart",this._onPointerDown),this.target.addEventListener("touchmove",this._onPointerMove),this.target.addEventListener("touchend",this._onPointerUp)),this.target.addEventListener("wheel",this._onWheel),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("keypress",this._onKeyPress),document.addEventListener("keyup",this._onKeyUp),this.setuped=!0}normalize(t){const e=[];if(Ke&&t instanceof globalThis.TouchEvent)for(let A=0,i=t.changedTouches.length;A<i;A++){const s=t.changedTouches[A];typeof s.button>"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.type=t.type,e.push(s)}else if(_o&&t instanceof globalThis.WheelEvent)e.push(t);else if(NA&&t instanceof globalThis.PointerEvent)e.push(t);else{const A=t;typeof A.isPrimary>"u"&&(A.isPrimary=!0),typeof A.width>"u"&&(A.width=1),typeof A.height>"u"&&(A.height=1),typeof A.tiltX>"u"&&(A.tiltX=0),typeof A.tiltY>"u"&&(A.tiltY=0),typeof A.pointerType>"u"&&(A.pointerType="mouse"),typeof A.pointerId>"u"&&(A.pointerId=1),typeof A.pressure>"u"&&(A.pressure=.5),typeof A.twist>"u"&&(A.twist=0),typeof A.tangentialPressure>"u"&&(A.tangentialPressure=0),e.push(A)}return e}_clonePointerEvent(t){const e=new Fo;return e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,e.isTrusted=t.isTrusted,this._copyMouseEvent(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.x=e.screen.x,e.global.y=e.screen.y,e.offset.x=e.screen.x,e.offset.y=e.screen.y,e.type==="pointerleave"?e.type="pointerout":e.type.startsWith("mouse")?e.type=e.type.replace("mouse","pointer"):e.type.startsWith("touch")&&(e.type=Fh[e.type]||e.type),e}_copyInputEvent(t,e){t.nativeEvent=e,t.bubbles=e.bubbles,t.cancelBubble=e.cancelBubble,t.cancelable=e.cancelable,t.composed=e.composed,t.currentTarget=e.currentTarget,t.defaultPrevented=e.defaultPrevented,t.eventPhase=e.eventPhase,t.isTrusted=e.isTrusted,t.returnValue=e.returnValue,t.srcElement=e.srcElement,t.timeStamp=e.timeStamp,t.type=e.type}_copyMouseEvent(t,e){this._copyInputEvent(t,e),t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}_cloneWheelEvent(t){const e=new To;return this._copyMouseEvent(e,t),e.wheelDeltaY=t.wheelDeltaY,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.x=e.screen.x,e.global.y=e.screen.y,e.offset.x=e.screen.x,e.offset.y=e.screen.y,e}_cloneKeyboardEvent(t){const e=new No;return this._copyInputEvent(e,t),e.altKey=t.altKey,e.charCode=t.charCode,e.code=t.code,e.ctrlKey=t.ctrlKey,e.isComposing=t.isComposing,e.key=t.key,e.keyCode=t.keyCode,e.location=t.location,e.metaKey=t.metaKey,e.repeat=t.repeat,e.shiftKey=t.shiftKey,e}setCursor(t="default"){if(!this.target||this.cursor===t)return;this.cursor=t;const e=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),A=this.cursorStyles[t];if(A)switch(typeof A){case"string":e&&(this.target.style.cursor=A);break;case"function":A(t);break;case"object":e&&Object.assign(this.target.style,A);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.target.style.cursor=t)}mapPositionToPoint(t,e,A){if(!this.target)return;const i=this.target.isConnected?this.target.getBoundingClientRect():void 0,s=Number(this.target.getAttribute("data-pixel-ratio"))||1,n=Number(this.target.getAttribute("width"))||(i?i.width*s:0),o=Number(this.target.getAttribute("height"))||(i?i.height*s:0),a=i??{width:n,height:o,left:0,top:0},l=1/s;t.x=(e-a.left)*(n/a.width)*l,t.y=(A-a.top)*(o/a.height)*l}_onKeyDown=t=>{const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("keydown",this.event=this._cloneKeyboardEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyPress=t=>{const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("keypress",this.event=this._cloneKeyboardEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyUp=t=>{const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("keyup",this.event=this._cloneKeyboardEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerDown=t=>{if(Ke&&t.pointerType==="touch")return;const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("pointerdown",this.event=this._clonePointerEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerOver=t=>{if(!this.enableClickEvent||Ke&&t.pointerType==="touch")return;const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("pointerover",this.event=this._clonePointerEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerMove=t=>{if(!this.enableMoveEvent||Ke&&t.pointerType==="touch")return;const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("pointermove",this.event=this._clonePointerEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerUp=t=>{if(!this.enableClickEvent||Ke&&t.pointerType==="touch")return;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const A=e!==this.target?"outside":"",i=this.normalize(t);for(let s=0,n=i.length;s<n;s++){const o=this._clonePointerEvent(i[s]);o.type+=A,this.emit("pointerup",this.event=o)}this.event?.cursor&&this.setCursor(this.event.cursor)};_onWheel=t=>{if(!this.enableWheelEvent)return;const e=this.normalize(t);for(let A=0,i=e.length;A<i;A++)this.emit("wheel",this.event=this._cloneWheelEvent(e[A]));this.event?.cursor&&this.setCursor(this.event.cursor)}}let Th=0;class sA extends Je{instanceId=++Th;_customPropertyAccessor;_properties=new Map;_updatedProperties=new Map;_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;useCustomPropertyAccessor(t){return this._customPropertyAccessor=t,this.getPropertyDeclarations().forEach((e,A)=>{const i=t.get(A,()=>{}),s=this._properties.get(A);i===void 0?s!==void 0&&t.set(A,s):i!==s&&(e.alias&&e.alias!==A?this.setProperty(A,i):this._properties.set(A,i),this._updateProperty(A,i,s,e),this.emit("updateProperty",A,i,s,e))}),this}getter(t,e){return e?.declaration.protected?this[e.internalKey]:this._customPropertyAccessor?this._customPropertyAccessor.get(t,()=>this._properties.get(t)):this._properties.get(t)}setter(t,e,A){A?.declaration.protected?this[A.internalKey]=e:(this._customPropertyAccessor&&this._customPropertyAccessor.set(t,e),this._properties.set(t,e))}equal(t){return!!(t&&this.instanceId===t.instanceId)}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(t){Promise.reject(t)}await ds(),this._updating&&(this.update(),this._updating=!1)}update(){this._update(this._updatedProperties),this._updatedProperties=new Map}_update(t){}_updateProperty(t,e,A,i){}isDirty(t){return this._updatedProperties.has(t)}getPropertyDeclarations(){return us(this.constructor)}getPropertyDeclaration(t){return this.getPropertyDeclarations().get(t)}getProperty(t){return this[t]}setProperty(t,e){return this[t]=e,this}getProperties(t){const e={};for(const[A,i]of this.getPropertyDeclarations())!i.protected&&!i.alias&&(!t||t.includes(A))&&(e[A]=this.getProperty(A));return e}setProperties(t){if(t&&typeof t=="object")for(const[e]of this.getPropertyDeclarations())e in t&&this.setProperty(e,t[e]);return this}resetProperties(){for(const[t,e]of this.getPropertyDeclarations())this.setProperty(t,typeof e.fallback=="function"?e.fallback():e.fallback);return this}onUpdateProperty(t,e,A,i){this.requestUpdate(t,e,A,i)}requestUpdate(t,e,A,i){if(t!==void 0)if(!Object.is(e,A))this._updatedProperties.set(t,A),this._changedProperties.add(t),i??=this.getPropertyDeclaration(t),this._updateProperty(t,e,A,i),this.emit("updateProperty",t,e,A,i);else return;this._updating||(this._updatingPromise=this._enqueueUpdate())}toJSON(){const t={};return this._properties.forEach((e,A)=>{e!==void 0&&(e&&typeof e=="object"?"toJSON"in e&&typeof e.toJSON=="function"?t[A]=e.toJSON():Array.isArray(e)?t[A]=[...e]:t[A]={...e}:t[A]=e)}),t}clone(){return new this.constructor(this.toJSON())}free(){this.removeAllListeners()}}class Go extends sA{}class Ye extends Go{}function Lh(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},A={};for(var i in e)A[e[i]]=i;var s={};r.prototype.toName=function(n){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,a,l=A[this.toHex()];if(l)return l;if(n?.closest){var c=this.toRgb(),h=1/0,u="black";if(!s.length)for(var d in e)s[d]=new r(e[d]).toRgb();for(var f in e){var E=(o=c,a=s[f],Math.pow(o.r-a.r,2)+Math.pow(o.g-a.g,2)+Math.pow(o.b-a.b,2));E<h&&(h=E,u=f)}return u}},t.string.push([function(n){var o=n.toLowerCase(),a=o==="transparent"?"#0000":e[o];return a?new r(a).toRgb():null},"name"])}Jc([Lh]);class xe{get value(){return this._value}set value(t){this._colord=cs(t??"none")}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(t=0){this.value=t}toHex(){return this._colord.toHex()}toRgb(){return this._colord.toRgb()}toRgbString(){return this._colord.toRgbString()}toHsl(){return this._colord.toHsl()}toHslString(){return this._colord.toHslString()}toHsv(){return this._colord.toHsv()}toArgb(t=this.a,e=!0){if(t===1)return(255<<24)+this.rgb;if(t===0)return e?0:this.rgb;let A=this.r8,i=this.g8,s=this.b8;return e&&(A=A*t+.5|0,i=i*t+.5|0,s=s*t+.5|0),(t*255<<24)+(A<<16)+(i<<8)+s}toArray(){return[this.r,this.g,this.b,this.a]}}class Ce extends Je{constructor(t){super(),this.dim=t}_array=[];get length(){return this.dim}operate(t,e,A){const{dim:i,_array:s}=this;let n;typeof e=="number"?n=Array.from({length:i},()=>e):e instanceof Se||e instanceof Ce?n=e.toArray():n=e;let o,a=[];if(A?A instanceof Ce?o=A:a=A:o=this,e instanceof Se){const{cols:l}=e;switch(t){case"*":for(let c=0;c<i;c++){let h=0;for(let u=0;u<i;u++)h+=s[c]*n[u*l+c];a[c]=h}break;default:throw new Error(`Not support operator in '${this.toName()} ${t} ${e.toName()}'`)}}else switch(t){case"+":for(let l=0;l<i;l++)a[l]=s[l]+n[l];break;case"-":for(let l=0;l<i;l++)a[l]=s[l]-n[l];break;case"*":for(let l=0;l<i;l++)a[l]=s[l]*n[l];break;case"/":for(let l=0;l<i;l++)a[l]=s[l]/n[l];break;case"rot":{const l=Math.cos(n[0]),c=Math.sin(n[0]);a[0]=s[0]*l-s[1]*c,a[1]=s[1]*l+s[0]*c;break}case"==":{let l=!0;for(let c=0;c<i;c++)l=l&&s[c]===n[c];return l}case"=":for(let l=0;l<i;l++){const c=n[l];c!==void 0&&(s[l]=c)}return this._onUpdate(s),this.emit("update",s),this;default:throw new Error(`Not support operator in '${this.toName()} ${t} Vector'`)}return o?.set(a)??a}add(t,...e){return e.length&&typeof t=="number"&&(t=[t,...e]),this.operate("+",t)}sub(t,...e){return e.length&&typeof t=="number"&&(t=[t,...e]),this.operate("-",t)}multiply(t,...e){return e.length&&typeof t=="number"&&(t=[t,...e]),this.operate("*",t)}divide(t,...e){return e.length&&typeof t=="number"&&(t=[t,...e]),this.operate("/",t)}rotate(t){return this.operate("rot",t)}set(t,...e){return e.length&&typeof t=="number"&&(t=[t,...e]),this.operate("=",t)}equals(t){return this.operate("==",t)}copy(t){return this.set(t)}clone(){const t=new this.constructor;return t.set(this.toArray()),t}_onUpdate(t){}toName(){return`Vector${this.dim}`}toArray(){return this._array.slice()}toJSON(){return this.toArray()}}class Se extends Je{constructor(t,e,A){super(),this.rows=t,this.cols=e,A?this.set(A):this.identity()}_array=[];dirtyId=0;get length(){return this.cols*this.rows}operate(t,e,A){const{cols:i,rows:s,length:n,_array:o}=this;let a;typeof e=="number"?a=Array.from({length:n},()=>e):e instanceof Ce||e in