From cfacc2af07bb7b8b6a3d59f383372141dab8e226 Mon Sep 17 00:00:00 2001 From: Jono Brandel Date: Mon, 6 Jan 2025 12:33:08 -0800 Subject: [PATCH 1/4] Fix group shallow getBoundingClientRect --- src/group.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/group.js b/src/group.js index 55d5c876..c6a1deda 100644 --- a/src/group.js +++ b/src/group.js @@ -672,10 +672,10 @@ export class Group extends Shape { const [cx, cy] = matrix.multiply(rect.left, rect.bottom); const [dx, dy] = matrix.multiply(rect.right, rect.bottom); - top = min(ay, by, cy, dy); - left = min(ax, bx, cx, dx); - right = max(ax, bx, cx, dx); - bottom = max(ay, by, cy, dy); + top = min(ay, by, cy, dy, top); + left = min(ax, bx, cx, dx, left); + right = max(ax, bx, cx, dx, right); + bottom = max(ay, by, cy, dy, bottom); } else { top = min(rect.top, top); left = min(rect.left, left); From 59dc9992ff34663e3068e64b4cd988ec70baed02 Mon Sep 17 00:00:00 2001 From: Jono Brandel Date: Mon, 6 Jan 2025 13:33:01 -0800 Subject: [PATCH 2/4] Added tests --- tests/suite/core.js | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/suite/core.js b/tests/suite/core.js index 669d6883..8e12448b 100755 --- a/tests/suite/core.js +++ b/tests/suite/core.js @@ -1186,6 +1186,52 @@ QUnit.test('Two.Group Object Conversion', function (assert) { // ); }); +QUnit.test('Two.Group.getBoundingClientRect(shallow)', function (assert) { + assert.expect(6); + + const group = new Two.Group(); + + for (let i = 0; i < 3; i++) { + const x = i * 100; + const width = 100; + const height = 50; + const child = new Two.Rectangle(x, 0, width, height); + group.add(child); + } + + const rect = group.getBoundingClientRect(true); + assert.equal( + rect.top, + -25.5, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates top property.' + ); + assert.equal( + rect.bottom, + 25.5, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates bottom property.' + ); + assert.equal( + rect.left, + -50.5, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates left property.' + ); + assert.equal( + rect.right, + 250.5, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates right property.' + ); + assert.equal( + rect.width, + 301, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates width property.' + ); + assert.equal( + rect.height, + 51, + 'Two.Group.getBoundingClientRect(shallow) correctly calculates height property.' + ); +}); + QUnit.test('Two.Text Object Conversion', function (assert) { assert.expect(9); From 539be940e22746e2e2d7ed73c357bb9640d42e05 Mon Sep 17 00:00:00 2001 From: Jono Brandel Date: Mon, 6 Jan 2025 13:33:08 -0800 Subject: [PATCH 3/4] Updated Builds --- build/two.js | 12 ++++++------ build/two.min.js | 2 +- build/two.module.js | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/two.js b/build/two.js index a2805372..fbeb83c2 100644 --- a/build/two.js +++ b/build/two.js @@ -766,8 +766,8 @@ var Two = (() => { svg: "SVGRenderer", canvas: "CanvasRenderer" }, - Version: "v0.8.15", - PublishDate: "2025-01-01T01:30:08.872Z", + Version: "v0.8.16", + PublishDate: "2025-01-06T21:30:44.526Z", Identifier: "two-", Resolution: 12, AutoCalculateImportedMatrices: true, @@ -6186,10 +6186,10 @@ var Two = (() => { const [bx, by] = matrix.multiply(rect.right, rect.top); const [cx, cy] = matrix.multiply(rect.left, rect.bottom); const [dx, dy] = matrix.multiply(rect.right, rect.bottom); - top = min3(ay, by, cy, dy); - left = min3(ax, bx, cx, dx); - right = max3(ax, bx, cx, dx); - bottom = max3(ay, by, cy, dy); + top = min3(ay, by, cy, dy, top); + left = min3(ax, bx, cx, dx, left); + right = max3(ax, bx, cx, dx, right); + bottom = max3(ay, by, cy, dy, bottom); } else { top = min3(rect.top, top); left = min3(rect.left, left); diff --git a/build/two.min.js b/build/two.min.js index 2256a256..114b59ac 100644 --- a/build/two.min.js +++ b/build/two.min.js @@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -var Two=(()=>{var Re=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var $i=Object.prototype.hasOwnProperty;var Ji=(i,t,e)=>t in i?Re(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Be=(i,t)=>{for(var e in t)Re(i,e,{get:t[e],enumerable:!0})},Zi=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ki(t))!$i.call(i,r)&&r!==e&&Re(i,r,{get:()=>t[r],enumerable:!(s=qi(t,r))||s.enumerable});return i};var Qi=i=>Zi(Re({},"__esModule",{value:!0}),i);var w=(i,t,e)=>(Ji(i,typeof t!="symbol"?t+"":t,e),e);var $s={};Be($s,{default:()=>I});var lt={Image:null,isHeadless:!1,shim:function(i,t){return i.tagName=i.nodeName=t||"canvas",i.nodeType=1,i.getAttribute=function(e){return this[e]},i.setAttribute=function(e,s){return this[e]=s,this},i},polyfill:function(i,t){return lt.shim(i),typeof t<"u"&&(lt.Image=t),lt.isHeadless=!0,i}};var He={};Be(He,{Curve:()=>Zt,getAnchorsFromArcData:()=>is,getComponentOnCubicBezier:()=>se,getControlPoints:()=>di,getCurveBoundingBox:()=>We,getCurveFromPoints:()=>Xe,getCurveLength:()=>De,getReflection:()=>Ae,integrate:()=>ui,subdivide:()=>ye});var Ue={};Be(Ue,{HALF_PI:()=>Z,NumArray:()=>vt,TWO_PI:()=>J,decomposeMatrix:()=>Et,getComputedMatrix:()=>ze,getPoT:()=>je,lerp:()=>ct,mod:()=>nt,setMatrix:()=>Ve,toFixed:()=>U});var Y;typeof window<"u"?Y=window:typeof global<"u"?Y=global:typeof self<"u"&&(Y=self);var hi,J=Math.PI*2,Z=Math.PI*.5;function Et(i,t,e,s,r,n){let o;return arguments.length<=1?(o=i.a,t=i.b,e=i.c,s=i.d,r=i.e,n=i.f):o=i,{translateX:r,translateY:n,scaleX:Math.sqrt(o*o+t*t),scaleY:Math.sqrt(e*e+s*s),rotation:180*Math.atan2(t,o)/Math.PI}}function Ve(i){hi=i}function ze(i,t){t=t&&t.identity()||new hi;let e=i,s=[];for(;e&&e._matrix;)s.push(e._matrix),e=e.parent;s.reverse();for(let r=0;r=4){let n=arguments[0]-arguments[2],o=arguments[1]-arguments[3];return Math.atan2(o,n)}let s=t.x-e.x,r=t.y-e.y;return Math.atan2(r,s)}static distanceBetween(t,e){return Math.sqrt(kt.distanceBetweenSquared(t,e))}static distanceBetweenSquared(t,e){let s=t.x-e.x,r=t.y-e.y;return s*s+r*r}set(t,e){return this.x=t,this.y=e,this}copy(t){return this.x=t.x,this.y=t.y,this}clear(){return this.x=0,this.y=0,this}clone(){return new kt(this.x,this.y)}add(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x+=t,this.y+=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x+=t.x,this.y+=t.y):(this.x+=t,this.y+=e),this)}addSelf(t){return this.add.apply(this,arguments)}sub(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x-=t,this.y-=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x-=t.x,this.y-=t.y):(this.x-=t,this.y-=e),this)}subtract(){return this.sub.apply(this,arguments)}subSelf(t){return this.sub.apply(this,arguments)}subtractSelf(t){return this.sub.apply(this,arguments)}multiply(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x*=t,this.y*=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x*=t.x,this.y*=t.y):(this.x*=t,this.y*=e),this)}multiplySelf(t){return this.multiply.apply(this,arguments)}multiplyScalar(t){return this.multiply(t)}divide(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x/=t,this.y/=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x/=t.x,this.y/=t.y):(this.x/=t,this.y/=e),isNaN(this.x)&&(this.x=0),isNaN(this.y)&&(this.y=0),this)}divideSelf(t){return this.divide.apply(this,arguments)}divideScalar(t){return this.divide(t)}negate(){return this.multiply(-1)}dot(t){return this.x*t.x+this.y*t.y}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.divideScalar(this.length())}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}setLength(t){return this.normalize().multiplyScalar(t)}equals(t,e){return e=typeof e>"u"?1e-4:e,this.distanceTo(t)"u"?1e-4:t,this.length()>1,f=s&1?n[h++]*i(a):0;for(;h=0&&t<4294967296}var S={isNaN:function(i){return typeof i=="number"&&i!==+i},isElement:function(i){return!!(i&&i.nodeType===1)},isObject:function(i){let t=typeof i;return t==="function"||t==="object"&&!!i},extend:function(i){let t=_i.call(arguments,1);for(let e=0;e0&&this.push.apply(this,arguments[0]):arguments.length>0&&this.push.apply(this,arguments)}pop(){let t=super.pop.apply(this,arguments);return this.trigger(g.Types.remove,[t]),t}shift(){let t=super.shift.apply(this,arguments);return this.trigger(g.Types.remove,[t]),t}push(){let t=super.push.apply(this,arguments);return this.trigger(g.Types.insert,arguments),t}unshift(){let t=super.unshift.apply(this,arguments);return this.trigger(g.Types.insert,arguments),t}splice(){let t=super.splice.apply(this,arguments);if(this.trigger(g.Types.remove,t),arguments.length>2){let e=this.slice(arguments[0],arguments[0]+arguments.length-2);this.trigger(g.Types.insert,e),this.trigger(g.Types.order)}return t}sort(){return super.sort.apply(this,arguments),this.trigger(g.Types.order),this}reverse(){return super.reverse.apply(this,arguments),this.trigger(g.Types.order),this}indexOf(){return super.indexOf.apply(this,arguments)}map(t,e){let s=[];for(let r=0;r=4&&(this._flagVideo=!0),this}flagReset(){return this._flagSrc=this._flagImage=this._flagLoaded=this._flagRepeat=this._flagVideo=this._flagScale=this._flagOffset=!1,super.flagReset.call(this),this}},V=st;w(V,"Properties",["src","loaded","repeat","scale","offset","image"]),w(V,"RegularExpressions",gi),w(V,"ImageRegistry",new Tt),w(V,"Register",{canvas:function(t,e){t._src="#"+t.id,st.ImageRegistry.add(t.src,t.image),typeof e=="function"&&e()},img:function(t,e){let s=t.image,r=function(o){!lt.isHeadless&&s.removeEventListener&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),typeof e=="function"&&e()},n=function(o){throw!lt.isHeadless&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),new et("unable to load "+t.src)};typeof s.width=="number"&&s.width>0&&typeof s.height=="number"&&s.height>0?r():!lt.isHeadless&&typeof s.addEventListener=="function"&&(s.addEventListener("load",r,!1),s.addEventListener("error",n,!1)),t._src=st.getAbsoluteURL(t._src),!(!lt.isHeadless&&s&&s.getAttribute("two-src"))&&(lt.isHeadless||s.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,s),lt.isHeadless?st.loadHeadlessBuffer(t,r):t.image.src=t.src)},video:function(t,e){if(lt.isHeadless)throw new et("video textures are not implemented in headless environments.");let s=function(n){t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),t.image.width=t.image.videoWidth,t.image.height=t.image.videoHeight,typeof e=="function"&&e()},r=function(n){throw t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),new et("unable to load "+t.src)};t._src=st.getAbsoluteURL(t._src),t.image.getAttribute("two-src")||(t.image.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,t.image)),t.image.readyState>=4?s():(t.image.addEventListener("canplaythrough",s,!1),t.image.addEventListener("error",r,!1),t.image.src=t.src,t.image.load())}});var mi={src:{enumerable:!0,get:function(){return this._src},set:function(i){this._src=i,this._flagSrc=!0}},loaded:{enumerable:!0,get:function(){return this._loaded},set:function(i){this._loaded=i,this._flagLoaded=!0}},repeat:{enumerable:!0,get:function(){return this._repeat},set:function(i){this._repeat=i,this._flagRepeat=!0}},image:{enumerable:!0,get:function(){return this._image},set:function(i){let t=V.getTag(i),e;switch(t){case"canvas":e="#"+i.id;break;default:e=i.src}V.ImageRegistry.contains(e)?this._image=V.ImageRegistry.get(i.src):this._image=i,this._flagImage=!0}},offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset&&this._offset.unbind(g.Types.change,this._renderer.flagOffset),this._offset=i,this._offset.bind(g.Types.change,this._renderer.flagOffset),this._flagOffset=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof x&&this._scale.unbind(g.Types.change,this._renderer.flagScale),this._scale=i,this._scale instanceof x&&this._scale.bind(g.Types.change,this._renderer.flagScale),this._flagScale=!0}}};function os(){this._flagOffset=!0}function as(){this._flagScale=!0}var Rt=class extends mt{_flagOffset=!0;_flagOpacity=!0;_flagColor=!0;_offset=0;_opacity=1;_color="#fff";constructor(t,e,s){super();for(let r in yi)Object.defineProperty(this,r,yi[r]);this._renderer.type="stop",this.offset=typeof t=="number"?t:Rt.Index<=0?0:1,this.opacity=typeof s=="number"?s:1,this.color=typeof e=="string"?e:Rt.Index<=0?"#fff":"#000",Rt.Index=(Rt.Index+1)%2}static fromObject(t){let e=new Rt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e{t[e]=this[e]},this),t}flagReset(){return this._flagOffset=this._flagColor=this._flagOpacity=!1,super.flagReset.call(this),this}},ht=Rt;w(ht,"Index",0),w(ht,"Properties",["offset","opacity","color"]);var yi={offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset=i,this._flagOffset=!0,this.parent&&(this.parent._flagStops=!0)}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0,this.parent&&(this.parent._flagStops=!0)}},color:{enumerable:!0,get:function(){return this._color},set:function(i){this._color=i,this._flagColor=!0,this.parent&&(this.parent._flagStops=!0)}}};var Vt=class extends mt{_flagStops=!1;_flagSpread=!1;_flagUnits=!1;_spread="";_units="";constructor(t){super();for(let e in bi)Object.defineProperty(this,e,bi[e]);this._renderer.type="gradient",this._renderer.flagStops=ls.bind(this),this._renderer.bindStops=hs.bind(this),this._renderer.unbindStops=fs.bind(this),this.spread="pad",this.units="objectBoundingBox",t&&(this.stops=t)}static fromObject(t){let e=t.stops;e&&e.length>0&&(e=e.map(r=>r instanceof ht?r:new ht().copy(r)));let s=new Vt().copy(t);return"id"in t&&(s.id=t.id),s}clone(t){let e=this.stops.map(r=>r.clone()),s=new Vt(e);return S.each(Vt.Properties,r=>{s[r]=this[r]},this),t&&t.add(s),s}copy(t){super.copy.call(this,t);for(let e=0;ee.toObject())};return S.each(Vt.Properties,e=>{t[e]=this[e]},this),t}_update(){return(this._flagSpread||this._flagStops)&&this.trigger(g.Types.change),this}flagReset(){return this._flagSpread=this._flagUnits=this._flagStops=!1,super.flagReset.call(this),this}},G=Vt;w(G,"Stop",ht),w(G,"Properties",["spread","stops","units"]);var bi={spread:{enumerable:!0,get:function(){return this._spread},set:function(i){this._spread=i,this._flagSpread=!0}},units:{enumerable:!0,get:function(){return this._units},set:function(i){this._units=i,this._flagUnits=!0}},stops:{enumerable:!0,get:function(){return this._stops},set:function(i){let t=this._renderer.bindStops,e=this._renderer.unbindStops;this._stops&&this._stops.unbind(g.Types.insert,t).unbind(g.Types.remove,e),this._stops=new ut((i||[]).slice(0)),this._stops.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._stops)}}};function ls(){this._flagStops=!0}function hs(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagStops),i[t].parent=this;this._renderer.flagStops()}function fs(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagStops),delete i[t].parent;this._renderer.flagStops()}var oe=class extends G{_flagEndPoints=!1;_left=null;_right=null;constructor(t,e,s,r,n){super(n);for(let o in xi)Object.defineProperty(this,o,xi[o]);this._renderer.type="linear-gradient",this._renderer.flagEndPoints=cs.bind(this),this.left=new x,this.right=new x,typeof t=="number"&&(this.left.x=t),typeof e=="number"&&(this.left.y=e),typeof s=="number"&&(this.right.x=s),typeof r=="number"&&(this.right.y=r)}static fromObject(t){let e=new oe().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e=s)return s-r>=0;r+=o}return!1}function ae(i,t){let e=i._length;if(t<=0)return 0;if(t>=e)return i._lengths.length-1;for(let s=0,r=0;s=t)return t-=r,Math.max(s-1,0)+t/i._lengths[s];r+=i._lengths[s]}return-1}function Se(i,t,e){let s,r,n,o,a,h,l,f,c=t.controls&&t.controls.right,d=i.controls&&i.controls.left;return s=t.x,a=t.y,r=(c||t).x,h=(c||t).y,n=(d||i).x,l=(d||i).y,o=i.x,f=i.y,c&&t._relative&&(r+=t.x,h+=t.y),d&&i._relative&&(n+=i.x,l+=i.y),De(s,a,r,h,n,l,o,f,e)}function Ge(i,t,e){let s,r,n,o,a,h,l,f,c=t.controls&&t.controls.right,d=i.controls&&i.controls.left;return s=t.x,a=t.y,r=(c||t).x,h=(c||t).y,n=(d||i).x,l=(d||i).y,o=i.x,f=i.y,c&&t._relative&&(r+=t.x,h+=t.y),d&&i._relative&&(n+=i.x,l+=i.y),ye(s,a,r,h,n,l,o,f,e)}function St(i){switch(i.renderer.type){case"texture":return V.fromObject(i);case"gradient":return G.fromObject(i);case"linear-gradient":return W.fromObject(i);case"radial-gradient":return X.fromObject(i)}return i}var _s=Math.cos,ps=Math.sin,vi=Math.tan,qe=[],yt=class extends g{elements=new vt(9);manual=!1;constructor(t,e,s,r,n,o){super();let a=t;Array.isArray(a)||(a=Array.prototype.slice.call(arguments)),this.identity(),a.length>0&&this.set(a)}static Multiply(t,e,s){if(e.length<=3){let F=t,M,B,P,O=e[0]||0,j=e[1]||0,N=e[2]||0;return M=F[0]*O+F[1]*j+F[2]*N,B=F[3]*O+F[4]*j+F[5]*N,P=F[6]*O+F[7]*j+F[8]*N,[M,B,P]}let r=t[0],n=t[1],o=t[2],a=t[3],h=t[4],l=t[5],f=t[6],c=t[7],d=t[8],_=e[0],u=e[1],y=e[2],b=e[3],m=e[4],p=e[5],R=e[6],A=e[7],k=e[8];return s=s||new vt(9),s[0]=r*_+n*b+o*R,s[1]=r*u+n*m+o*A,s[2]=r*y+n*p+o*k,s[3]=a*_+h*b+l*R,s[4]=a*u+h*m+l*A,s[5]=a*y+h*p+l*k,s[6]=f*_+c*b+d*R,s[7]=f*u+c*m+d*A,s[8]=f*y+c*p+d*k,s}static fromObject(t){return new yt().copy(t)}set(t,e,s,r,n,o,a,h,l){if(typeof e>"u"){let f=t;t=f[0],e=f[1],s=f[2],r=f[3],n=f[4],o=f[5],a=f[6],h=f[7],l=f[8]}return this.elements[0]=t,this.elements[1]=e,this.elements[2]=s,this.elements[3]=r,this.elements[4]=n,this.elements[5]=o,this.elements[6]=a,this.elements[7]=h,this.elements[8]=l,this.trigger(g.Types.change)}copy(t){return this.elements[0]=t.elements[0],this.elements[1]=t.elements[1],this.elements[2]=t.elements[2],this.elements[3]=t.elements[3],this.elements[4]=t.elements[4],this.elements[5]=t.elements[5],this.elements[6]=t.elements[6],this.elements[7]=t.elements[7],this.elements[8]=t.elements[8],this.manual=t.manual,this.trigger(g.Types.change)}identity(){return this.elements[0]=yt.Identity[0],this.elements[1]=yt.Identity[1],this.elements[2]=yt.Identity[2],this.elements[3]=yt.Identity[3],this.elements[4]=yt.Identity[4],this.elements[5]=yt.Identity[5],this.elements[6]=yt.Identity[6],this.elements[7]=yt.Identity[7],this.elements[8]=yt.Identity[8],this.trigger(g.Types.change)}multiply(t,e,s,r,n,o,a,h,l){if(typeof e>"u")return this.elements[0]*=t,this.elements[1]*=t,this.elements[2]*=t,this.elements[3]*=t,this.elements[4]*=t,this.elements[5]*=t,this.elements[6]*=t,this.elements[7]*=t,this.elements[8]*=t,this.trigger(g.Types.change);if(typeof s>"u"&&(s=1),typeof r>"u"){t=t||0,e=e||0,s=s||0,n=this.elements;let z=n[0]*t+n[1]*e+n[2]*s,it=n[3]*t+n[4]*e+n[5]*s,dt=n[6]*t+n[7]*e+n[8]*s;return[z,it,dt]}let f=this.elements,c=[t,e,s,r,n,o,a,h,l],d=f[0],_=f[1],u=f[2],y=f[3],b=f[4],m=f[5],p=f[6],R=f[7],A=f[8],k=c[0],F=c[1],M=c[2],B=c[3],P=c[4],O=c[5],j=c[6],N=c[7],q=c[8];return this.elements[0]=d*k+_*B+u*j,this.elements[1]=d*F+_*P+u*N,this.elements[2]=d*M+_*O+u*q,this.elements[3]=y*k+b*B+m*j,this.elements[4]=y*F+b*P+m*N,this.elements[5]=y*M+b*O+m*q,this.elements[6]=p*k+R*B+A*j,this.elements[7]=p*F+R*P+A*N,this.elements[8]=p*M+R*O+A*q,this.trigger(g.Types.change)}inverse(t){let e=this.elements;t=t||new yt;let s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],l=e[6],f=e[7],c=e[8],d=c*a-h*f,_=-c*o+h*l,u=f*o-a*l,y=s*d+r*_+n*u;return y?(y=1/y,t.elements[0]=d*y,t.elements[1]=(-c*r+n*f)*y,t.elements[2]=(h*r-n*a)*y,t.elements[3]=_*y,t.elements[4]=(c*s-n*l)*y,t.elements[5]=(-h*s+n*o)*y,t.elements[6]=u*y,t.elements[7]=(-f*s+r*l)*y,t.elements[8]=(a*s-r*o)*y,t):null}scale(t,e){return arguments.length<=1&&(e=t),this.multiply(t,0,0,0,e,0,0,0,1)}rotate(t){let e=_s(t),s=ps(t);return this.multiply(e,-s,0,s,e,0,0,0,1)}translate(t,e){return this.multiply(1,0,t,0,1,e,0,0,1)}skewX(t){let e=vi(t);return this.multiply(1,e,0,0,1,0,0,0,1)}skewY(t){let e=vi(t);return this.multiply(1,0,0,e,1,0,0,0,1)}toString(t){return qe.length=0,this.toTransformArray(t,qe),qe.map(U).join(" ")}toTransformArray(t,e){let s=this.elements,r=!!e,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],f=s[5];if(t){let c=s[6],d=s[7],_=s[8];if(r){e[0]=n,e[1]=h,e[2]=c,e[3]=o,e[4]=l,e[5]=d,e[6]=a,e[7]=f,e[8]=_;return}return[n,h,c,o,l,d,a,f,_]}if(r){e[0]=n,e[1]=h,e[2]=o,e[3]=l,e[4]=a,e[5]=f;return}return[n,h,o,l,a,f]}toArray(t,e){let s=this.elements,r=!!e,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],f=s[5];if(t){let c=s[6],d=s[7],_=s[8];if(r){e[0]=n,e[1]=o,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=c,e[7]=d,e[8]=_;return}return[n,o,a,h,l,f,c,d,_]}if(r){e[0]=n,e[1]=o,e[2]=a,e[3]=h,e[4]=l,e[5]=f;return}return[n,o,a,h,l,f]}toObject(){return{renderer:{type:"matrix"},elements:this.toArray(!0),manual:!!this.manual}}clone(){return new yt().copy(this)}},At=yt;w(At,"Identity",[1,0,0,0,1,0,0,0,1]);Ve(At);var ot=class extends mt{_flagMatrix=!0;_flagScale=!1;_matrix=null;_worldMatrix=null;_position=null;_rotation=0;_scale=1;_skewX=0;_skewY=0;constructor(){super();for(let t in Ee)Object.defineProperty(this,t,Ee[t]);this._renderer.flagMatrix=ki.bind(this),this.isShape=!0,this.matrix=new At,this.worldMatrix=new At,this.position=new x,this.rotation=0,this.scale=1,this.skewX=0,this.skewY=0}static fromObject(t){let e=new ot().copy(t);return"id"in t&&(e.id=t.id),e}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get translation(){return Ee.position.get.apply(this,arguments)}set translation(t){Ee.position.set.apply(this,arguments)}addTo(t){return t.add(this),this}remove(){return this.parent?(this.parent.remove(this),this):this}copy(t){return super.copy.call(this,t),"position"in t&&(t.position instanceof x?this.position=t.position:this.position.copy(t.position)),"rotation"in t&&(this.rotation=t.rotation),"scale"in t&&(this.scale=typeof t.scale=="number"||t.scale instanceof x?t.scale:new x(t.scale.x,t.scale.y)),"skewX"in t&&(this.skewX=t.skewX),"skewY"in t&&(this.skewY=t.skewY),"matrix"in t&&t.matrix.manual&&(this.matrix.copy(t.matrix),this.matrix.manual=!0),this}clone(t){let e=new ot;return e.position.copy(this.position),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,this.matrix.manual&&e.matrix.copy(this.matrix),t&&t.add(e),e._update()}toObject(){let t=super.toObject.call(this);return t.renderer={type:"shape"},t.isShape=!0,t.translation=this.translation.toObject(),t.rotation=this.translation.rotation,t.scale=this.scale instanceof x?this.scale.toObject():this.scale,t.skewX=this.skewX,t.skewY=this.skewY,t.matrix=this.matrix.toObject(),t}_update(t){return!this._matrix.manual&&this._flagMatrix&&(this._matrix.identity().translate(this.position.x,this.position.y),this._scale instanceof x?this._matrix.scale(this._scale.x,this._scale.y):this._matrix.scale(this._scale),this._matrix.rotate(this.rotation),this._matrix.skewX(this.skewX),this._matrix.skewY(this.skewY)),t&&this.parent&&this.parent._update&&this.parent._update(),this}flagReset(){return this._flagMatrix=this._flagScale=!1,super.flagReset.call(this),this}},Ee={position:{enumerable:!0,get:function(){return this._position},set:function(i){this._position&&this._position.unbind(g.Types.change,this._renderer.flagMatrix),this._position=i,this._position.bind(g.Types.change,this._renderer.flagMatrix),ki.call(this)}},rotation:{enumerable:!0,get:function(){return this._rotation},set:function(i){this._rotation=i,this._flagMatrix=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof x&&this._scale.unbind(g.Types.change,this._renderer.flagMatrix),this._scale=i,this._scale instanceof x&&this._scale.bind(g.Types.change,this._renderer.flagMatrix),this._flagMatrix=!0,this._flagScale=!0}},skewX:{enumerable:!0,get:function(){return this._skewX},set:function(i){this._skewX=i,this._flagMatrix=!0}},skewY:{enumerable:!0,get:function(){return this._skewY},set:function(i){this._skewY=i,this._flagMatrix=!0}},matrix:{enumerable:!0,get:function(){return this._matrix},set:function(i){this._matrix=i,this._flagMatrix=!0}},worldMatrix:{enumerable:!0,get:function(){return ze(this,this._worldMatrix),this._worldMatrix},set:function(i){this._worldMatrix=i}}};function ki(){this._flagMatrix=!0}var le=Math.min,he=Math.max,gs=Math.ceil,ms=Math.floor,ys=new x,It=class extends ot{_flagVertices=!0;_flagLength=!0;_flagFill=!0;_flagStroke=!0;_flagLinewidth=!0;_flagOpacity=!0;_flagVisible=!0;_flagCap=!0;_flagJoin=!0;_flagMiter=!0;_flagMask=!1;_flagClip=!1;_length=0;_fill="#fff";_stroke="#000";_linewidth=1;_opacity=1;_visible=!0;_cap="round";_join="round";_miter=4;_closed=!0;_curved=!1;_automatic=!0;_beginning=0;_ending=1;_mask=null;_clip=!1;_dashes=null;constructor(t,e,s,r){super();for(let n in Ri)Object.defineProperty(this,n,Ri[n]);this._renderer.type="path",this._renderer.flagVertices=Ke.bind(this),this._renderer.bindVertices=$e.bind(this),this._renderer.unbindVertices=Je.bind(this),this._renderer.flagFill=Ze.bind(this),this._renderer.flagStroke=Qe.bind(this),this._renderer.vertices=[],this._renderer.collection=[],this.closed=!!e,this.curved=!!s,this.beginning=0,this.ending=1,this.fill="#fff",this.stroke="#000",this.linewidth=1,this.opacity=1,this.className="",this.visible=!0,this.cap="butt",this.join="miter",this.miter=4,this.vertices=t,this.automatic=!r,this.dashes=[],this.dashes.offset=0}static fromObject(t){let e=typeof t.fill=="string"?t.fill:St(t.fill),s=typeof t.stroke=="string"?t.stroke:St(t.stroke),r=new It().copy({...t,fill:e,stroke:s});return"id"in t&&(r.id=t.id),r}copy(t){super.copy.call(this,t),this.vertices=[];for(let e=0;ee.toObject()),S.each(It.Properties,e=>{typeof this[e]<"u"&&(this[e].toObject?t[e]=this[e].toObject():t[e]=this[e])},this),t}noFill(){return this.fill="none",this}noStroke(){return this.stroke="none",this.linewidth=0,this}corner(){let t=this.getBoundingClientRect(!0),e=t.width/2,s=t.height/2,r=t.left+t.width/2,n=t.top+t.height/2;for(let o=0;o0||this.stroke&&!/(transparent|none)/i.test(this.stroke))if(this.matrix.manual){let{scaleX:d,scaleY:_}=Et(e.elements[0],e.elements[3],e.elements[1],e.elements[4],e.elements[2],e.elements[5]);typeof d=="number"&&typeof _=="number"&&(s=Math.max(d,_)*(this.linewidth||0)/2)}else s*=typeof this.scale=="number"?this.scale:Math.max(this.scale.x,this.scale.y);if(r<=0)return{width:0,height:0};for(n=0;n=p){this._closed?(s=nt(tt,R),r=nt(tt-1,R),tt===0&&(s=r,r=tt)):(s=tt,r=Math.min(Math.max(tt-1,0),A)),k=this.vertices[s],F=this.vertices[r],p-=at,this._lengths[tt]!==0?t=p/this._lengths[tt]:t=0;break}at+=this._lengths[tt]}if(k===null||F===null)return null;if(k){if(!F)return k}else return F;m=F.controls&&F.controls.right,b=k.controls&&k.controls.left,a=F.x,d=F.y,h=(m||F).x,_=(m||F).y,l=(b||k).x,u=(b||k).y,f=k.x,y=k.y,m&&F.relative&&(h+=F.x,_+=F.y),b&&k.relative&&(l+=k.x,u+=k.y),o=se(t,a,h,l,f),c=se(t,d,_,u,y);let M=ct(a,h,t),B=ct(d,_,t),P=ct(h,l,t),O=ct(_,u,t),j=ct(l,f,t),N=ct(u,y,t),q=ct(M,P,t),z=ct(B,O,t),it=ct(P,j,t),dt=ct(O,N,t);return S.isObject(e)?(e.x=o,e.y=c,e instanceof T&&(e.controls.left.x=q,e.controls.left.y=z,e.controls.right.x=it,e.controls.right.y=dt,(typeof e.relative!="boolean"||e.relative)&&(e.controls.left.x-=o,e.controls.left.y-=c,e.controls.right.x-=o,e.controls.right.y-=c)),e.t=t,e):(n=new T(o,c,q-o,z-c,it-o,dt-c,this._curved?v.curve:v.line),n.t=t,n)}plot(){if(this.curved)return Xe(this._collection,this.closed),this;for(let t=0;t0&&(n[n.length-1].command=v.line),r=a;return}o=Ge(a,r,t),n=n.concat(o),S.each(o,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line}),h>=e&&(this._closed&&this._automatic?(r=a,o=Ge(a,r,t),n=n.concat(o),S.each(o,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line})):s&&n.push(new T(a.x,a.y)),n[n.length-1].command=s?v.close:v.line),r=a},this),this._automatic=!1,this._curved=!1,this.vertices=n,this}_updateLength(t,e){e||this._update();let s=this.vertices.length,r=s-1,n=!1,o=this.vertices[r],a=0;return typeof this._lengths>"u"&&(this._lengths=[]),S.each(this.vertices,function(h,l){if(l<=0&&!n||h.command===v.move){o=h,this._lengths[l]=0;return}this._lengths[l]=Se(h,o,t),a+=this._lengths[l],l>=r&&n&&(o=this.vertices[(l+1)%s],this._lengths[l+1]=Se(h,o,t),a+=this._lengths[l+1]),o=h},this),this._length=a,this._flagLength=!1,this}_update(){if(this._flagVertices){this._automatic&&this.plot(),this._flagLength&&this._updateLength(void 0,!0);let t=this._collection.length,e=this._closed,s=Math.min(this._beginning,this._ending),r=Math.max(this._beginning,this._ending),n=ae(this,s*this._length),o=ae(this,r*this._length),a=gs(n),h=ms(o),l,f,c,d,_,u;for(this._renderer.vertices.length=0,u=0;uh&&!f?(_=this._renderer.collection[u].copy(this._collection[u]),this.getPointAt(r,_),_.command=this._renderer.collection[u].command,this._renderer.vertices.push(_),f=_,c=this._collection[u-1],c&&c.controls&&(_.relative?_.controls.right.clear():_.controls.right.copy(_),c.relative?this._renderer.collection[u-1].controls.right.copy(c.controls.right).lerp(x.zero,1-_.t):this._renderer.collection[u-1].controls.right.copy(c.controls.right).lerp(c,1-_.t))):u>=a&&u<=h&&(_=this._renderer.collection[u].copy(this._collection[u]),this._renderer.vertices.push(_),u===h&&Ye(this,r)?(f=_,!e&&f.controls&&(f.relative?f.controls.right.clear():f.controls.right.copy(f))):u===a&&Ye(this,s)&&(l=_,l.command=v.move,!e&&l.controls&&(l.relative?l.controls.left.clear():l.controls.left.copy(l))));a>0&&!l&&(u=a-1,_=this._renderer.collection[u].copy(this._collection[u]),this.getPointAt(s,_),_.command=v.move,this._renderer.vertices.unshift(_),d=this._collection[u+1],d&&d.controls&&(_.controls.left.clear(),d.relative?this._renderer.collection[u+1].controls.left.copy(d.controls.left).lerp(x.zero,_.t):(ys.copy(d),this._renderer.collection[u+1].controls.left.copy(d.controls.left).lerp(d,_.t))))}return ot.prototype._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagCap=this._flagJoin=this._flagMiter=this._flagClip=!1,ot.prototype.flagReset.call(this),this}},C=It;w(C,"Properties",["fill","stroke","linewidth","opacity","visible","cap","join","miter","closed","curved","automatic","beginning","ending","dashes"]),w(C,"Utils",{getCurveLength:Se});var Ri={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},cap:{enumerable:!0,get:function(){return this._cap},set:function(i){this._cap=i,this._flagCap=!0}},join:{enumerable:!0,get:function(){return this._join},set:function(i){this._join=i,this._flagJoin=!0}},miter:{enumerable:!0,get:function(){return this._miter},set:function(i){this._miter=i,this._flagMiter=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.unbind(g.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.bind(g.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.unbind(g.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.bind(g.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},closed:{enumerable:!0,get:function(){return this._closed},set:function(i){this._closed=!!i,this._flagVertices=!0}},curved:{enumerable:!0,get:function(){return this._curved},set:function(i){this._curved=!!i,this._flagVertices=!0}},automatic:{enumerable:!0,get:function(){return this._automatic},set:function(i){if(i===this._automatic)return;this._automatic=!!i;let t=this._automatic?"ignore":"listen";S.each(this.vertices,function(e){e[t]()})}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(g.Types.insert,t).unbind(g.Types.remove,e),i instanceof ut?this._collection=i:this._collection=new ut(i||[]),this._collection.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._collection)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}},clip:{enumerable:!0,get:function(){return this._clip},set:function(i){this._clip=i,this._flagClip=!0}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};function Ke(){this._flagVertices=!0,this._flagLength=!0,this.parent&&(this.parent._flagLength=!0)}function $e(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Je(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Ze(){this._flagFill=!0}function Qe(){this._flagStroke=!0}var fe=class extends C{constructor(t,e,s,r){let n=[new T,new T,new T,new T];super(n,!0,!1,!0),this._renderer.type="rectangle";for(let o in Ai)Object.defineProperty(this,o,Ai[o]);this.width=typeof s=="number"?s:1,this.height=typeof r=="number"?r:1,this.origin=new x,typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e),this._update()}static fromObject(t){let e=new fe().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e0&&(S.isNaN(this._lastFrame)&&(this._lastFrame=a-1),o=S.performance.now()-this._startTime,d=this._lastFrame+1,h=1e3*(d-this._firstFrame)/this._frameRate,this._loop?o=o%h:o=Math.min(o,h),l=ct(this._firstFrame,d,o/h),l=Math.floor(l),l!==this._index&&(this._index=l,l>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()));let _=this._index%e,u=Math.floor(this._index/e),y=-r*_+(f-r)/2,b=-n*u+(c-n)/2;y!==t.offset.x&&(t.offset.x=y),b!==t.offset.y&&(t.offset.y=b)}return super._update.call(this),this}flagReset(){return this._flagTexture=this._flagColumns=this._flagRows=this._flagFrameRate=!1,super.flagReset.call(this),this}},jt=ce;w(jt,"Properties",["texture","columns","rows","frameRate","index","firstFrame","lastFrame","loop"]);var Fi={texture:{enumerable:!0,get:function(){return this._texture},set:function(i){this._texture=i,this._flagTexture=!0}},columns:{enumerable:!0,get:function(){return this._columns},set:function(i){this._columns=i,this._flagColumns=!0}},rows:{enumerable:!0,get:function(){return this._rows},set:function(i){this._rows=i,this._flagRows=!0}},frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}},firstFrame:{enumerable:!0,get:function(){return this._firstFrame},set:function(i){this._firstFrame=i}},lastFrame:{enumerable:!0,get:function(){return this._lastFrame},set:function(i){this._lastFrame=i}},loop:{enumerable:!0,get:function(){return this._loop},set:function(i){this._loop=!!i}}};var be=class extends ut{#t={};get ids(){return this.#t}constructor(t){t=Array.isArray(t)?t:Array.prototype.slice.call(arguments),super(t),this.attach(t),this.on(g.Types.insert,this.attach),this.on(g.Types.remove,this.detach)}attach(t){for(let e=0;e0,a=this.vertices,h=o?a.length/2:a.length,l,f=0,c,d,_,u,y,b,m,p,R;for(n?h--:o||(h-=2),c=0,d=h-1;c2&&(t-=1);let e=4/3*Math.tan(Math.PI/(t*2)),s=this._radius,r=s*e;for(let n=0;n2&&(t-=1);let e=4/3*Math.tan(Math.PI/(this.vertices.length*2)),s=this._width/2,r=this._height/2;for(let n=0;ne.toObject()),S.each(Bt.Properties,function(e){typeof this[e]<"u"&&(this[e].toObject?t[e]=this[e].toObject():t[e]=this[e])},this),t}noFill=C.prototype.noFill;noStroke=C.prototype.noStroke;corner=C.prototype.corner;center=C.prototype.center;getBoundingClientRect=C.prototype.getBoundingClientRect;subdivide(t){this._update();let e=[];for(let s=0;s=n&&l<=o&&(h=this._collection[l],this._renderer.collection.push(h),this._renderer.vertices[a*2+0]=h.x,this._renderer.vertices[a*2+1]=h.y,a++)}return super._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagSize=this._flagSizeAttenuation=!1,super.flagReset.call(this),this}},Ht=Bt;w(Ht,"Properties",["fill","stroke","linewidth","opacity","visible","size","sizeAttenuation","beginning","ending","dashes"]);var Mi={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},size:{enumerable:!0,get:function(){return this._size},set:function(i){this._size=i,this._flagSize=!0}},sizeAttenuation:{enumerable:!0,get:function(){return this._sizeAttenuation},set:function(i){this._sizeAttenuation=i,this._flagSizeAttenuation=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.unbind(g.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.bind(g.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.unbind(g.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.bind(g.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(g.Types.insert,t).unbind(g.Types.remove,e),i instanceof ut?this._collection=i:this._collection=new ut(i||[]),this._collection.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._collection)}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};var ws=Math.cos,vs=Math.sin,Yt=class extends C{_flagWidth=!1;_flagHeight=!1;_flagSides=!1;_radius=0;_width=0;_height=0;_sides=0;constructor(t,e,s,r){r=Math.max(r||0,3),super(),this._renderer.type="polygon";for(let n in Oi)Object.defineProperty(this,n,Oi[n]);this.closed=!0,this.automatic=!1,typeof s=="number"&&(this.radius=s),typeof r=="number"&&(this.sides=r),this._update(),typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e)}static fromObject(t){let e=new Yt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;et&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new T(a,h)):this.vertices[r].set(a,h),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagWidth=this._flagHeight=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=new Yt(0,0,0,this.sides);e.translation.copy(this.translation),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,e.width=this.width,e.height=this.height,this.matrix.manual&&e.matrix.copy(this.matrix);for(let s=0;s"u"&&typeof s=="number"&&typeof r=="number"&&(n=Math.floor(Math.min(s,r)/12));let o=[];for(let a=0;a<10;a++)o.push(new T(0,0,0,0,0,0,a===0?v.move:v.curve));super(o),this._renderer.type="rounded-rectangle";for(let a in Ci)Object.defineProperty(this,a,Ci[a]);this.closed=!0,this.automatic=!1,this._renderer.flagRadius=ks.bind(this),typeof s=="number"&&(this.width=s),typeof r=="number"&&(this.height=r),typeof n=="number"&&(this.radius=n),this._update(),typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e)}static fromObject(t){let e=new qt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;et&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new T(h,l)):this.vertices[r].set(h,l),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagInnerRadius=this._flagOuterRadius=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=this.innerRadius,s=this.outerRadius,r=this.sides,n=new Kt(0,0,e,s,r);n.translation.copy(this.translation),n.rotation=this.rotation,n.scale=this.scale,n.skewX=this.skewX,n.skewY=this.skewY,this.matrix.manual&&n.matrix.copy(this.matrix);for(let o=0;o{t.children[s]=e.toObject()},this),t}corner(){let t=this.getBoundingClientRect(!0);for(let e=0;e=0&&e.push(r),r.children)for(let n=0;n=0&&this.children.splice(r,1),this.children.push(s)}return this}remove(t){let e=arguments.length,s=this.parent;if(e<=0&&s)return s.remove(this),this;t instanceof Array?t=t.slice():t=Array.prototype.slice.call(arguments);for(let r=0;r=0&&this.children.splice(o,1)}return this}getBoundingClientRect(t){let e,s,r,n,o,a;this._update(!0);let h=1/0,l=-1/0,f=1/0,c=-1/0,d=/texture|gradient/i;s=t?this.matrix:this.worldMatrix;for(let _=0;_a+e?(s.beginning=1,s.ending=1):la&&ha&&l0&&e(this._children)),this._children=new be(i),this._children.bind(g.Types.insert,t),this._children.bind(g.Types.remove,e),this._children.bind(g.Types.order,s),i.length>0&&t(i)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}}};function Vi(i,t){let e=i.parent,s;if(e===t){r();return}if(e&&e.children.ids[i.id]&&(s=Array.prototype.indexOf.call(e.children,i),e.children.splice(s,1),n()),t){r();return}n(),e._flagAdditions&&e.additions.length===0&&(e._flagAdditions=!1),e._flagSubtractions&&e.subtractions.length===0&&(e._flagSubtractions=!1),delete i.parent;function r(){t.subtractions.length>0&&(s=Array.prototype.indexOf.call(t.subtractions,i),s>=0&&t.subtractions.splice(s,1)),t.additions.length>0&&(s=Array.prototype.indexOf.call(t.additions,i),s>=0&&t.additions.splice(s,1)),i.parent=t,t.additions.push(i),t._flagAdditions=!0}function n(){s=Array.prototype.indexOf.call(e.additions,i),s>=0&&e.additions.splice(s,1),s=Array.prototype.indexOf.call(e.subtractions,i),s<0&&(e.subtractions.push(i),e._flagSubtractions=!0)}}var te=class extends C{constructor(t,e,s,r){let n=[new T(t,e),new T(s,r)];super(n);for(let o in zi)Object.defineProperty(this,o,zi[o]);this.vertices[0].command=v.move,this.vertices[1].command=v.line,this.automatic=!1}},zi={left:{enumerable:!0,get:function(){return this.vertices[0]},set:function(i){if(S.isObject(i))this.vertices.splice(0,1,i);else{let t=new et("Two.Line.x argument is not an object.");console.warn(t.name,t.message)}}},right:{enumerable:!0,get:function(){return this.vertices[1]},set:function(i){if(S.isObject(i))this.vertices.splice(1,1,i);else{let t=new et("Two.Line.y argument is not an object.");console.warn(t.name,t.message)}}}};var Pt={path:/[+-]?(?:\d*\.\d+|\d+)(?:[eE][+-]\d+)?/g,cssBackgroundImage:/url\(['"]?#([\w\d-_]*)['"]?\)/i,unitSuffix:/[a-zA-Z%]*/i},Es={start:"left",middle:"center",end:"right"},ji=["id","class","transform","xmlns","viewBox"],Ts=["x","y","width","height","href","xlink:href"];function Ms(i){return Es[i]}function Os(i){let t=i.getAttribute("dominant-baseline"),e=i.getAttribute("alignment-baseline");return t||e}function xe(i){return i.replace(/svg:/gi,"").toLowerCase()}function Ui(i,t){if(t.x+=i.translateX,t.y+=i.translateY,t.x*=i.scaleX,t.y*=i.scaleY,i.rotation!==0){let e=t.length();t.x=e*Math.cos(i.rotation),t.y=e*Math.sin(i.rotation)}}function Cs(i,t){t||(t={});let e=i.split(";");for(let s=0;s"u"||typeof o>"u"||(t[n]=o.replace(/\s/,""))}return t}function Ps(i){let t={},e=Ls(i),s=Math.max(e.length,i.style.length);for(let r=0;r=0&&t.splice(r,1)}return t}function Is(i,t){let e=t.split(/[\s,]/),s=-parseFloat(e[0]),r=-parseFloat(e[1]),n=parseFloat(e[2]),o=parseFloat(e[3]);if(s&&r)for(let c=0;c"u"&&/none/i.test(s.display))||typeof s.visibility>"u"&&/hidden/i.test(s.visibility);for(h in s)switch(l=s[h],h){case"gradientTransform":if(/none/i.test(l)||(a=i.gradientTransform&&i.gradientTransform.baseVal&&i.gradientTransform.baseVal.length>0?i.gradientTransform.baseVal[0].matrix:i.getCTM?i.getCTM():null,a===null))break;switch(d=Et(a),t._renderer.type){case"linear-gradient":Ui(d,t.left),Ui(d,t.right);break;case"radial-gradient":t.center.x+=d.translateX,t.center.y+=d.translateY,t.focal.x+=d.translateX,t.focal.y+=d.translateY,t.radius*=Math.max(d.scaleX,d.scaleY);break}break;case"transform":if(/none/i.test(l)||(a=i.transform&&i.transform.baseVal&&i.transform.baseVal.length>0?i.transform.baseVal[0].matrix:i.getCTM?i.getCTM():null,a===null))break;Q.AutoCalculateImportedMatrices?(d=Et(a),t.translation.set(d.translateX,d.translateY),t.rotation=Math.PI*(d.rotation/180),t.scale=new x(d.scaleX,d.scaleY),_=parseFloat((s.x+"").replace("px")),u=parseFloat((s.y+"").replace("px")),_&&(t.translation.x=_),u&&(t.translation.y=u)):(a=i.getCTM(),t._matrix.manual=!0,t._matrix.set(a.a,a.b,a.c,a.d,a.e,a.f));break;case"visible":if(t instanceof K){t._visible=l;break}t.visible=l;break;case"stroke-linecap":if(t instanceof K){t._cap=l;break}t.cap=l;break;case"stroke-linejoin":if(t instanceof K){t._join=l;break}t.join=l;break;case"stroke-miterlimit":if(t instanceof K){t._miter=l;break}t.miter=l;break;case"stroke-width":if(t instanceof K){t._linewidth=parseFloat(l);break}t.linewidth=parseFloat(l);break;case"opacity":case"stroke-opacity":case"fill-opacity":if(t instanceof K){t._opacity=parseFloat(l);break}t.opacity=parseFloat(l);break;case"clip-path":if(Pt.cssBackgroundImage.test(l)&&(y=l.replace(Pt.cssBackgroundImage,"$1"),$.defs.current&&$.defs.current.contains(y)&&(m=$.defs.current.get(y),m&&m.childNodes.length>0)))switch(m=m.childNodes[0],p=xe(m.nodeName),t.mask=$[p].call(this,m,{}),t._renderer.type){case"text":case"path":t.position.add(t.mask.position),t.mask.position.clear();break}break;case"fill":case"stroke":f=(t instanceof K?"_":"")+h,Pt.cssBackgroundImage.test(l)?(y=l.replace(Pt.cssBackgroundImage,"$1"),$.defs.current&&$.defs.current.contains(y)?(m=$.defs.current.get(y),m.object||(p=xe(m.nodeName),m.object=$[p].call(this,m,{})),m=m.object):(b=Ns(this),m=b.getById(y)),t[f]=m):t[f]=l;break;case"id":t.id=l;break;case"class":case"className":t.classList=l.split(" "),t._flagClassName=!0;break;case"x":case"y":if(R=t instanceof G,A=t instanceof W,k=t instanceof X,R||A||k)break;l.match("[a-z%]$")&&!l.endsWith("px")&&(F=new et("only pixel values are supported with the "+h+" attribute."),console.warn(F.name,F.message)),t.translation[h]=parseFloat(l);break;case"font-family":t instanceof ft&&(t.family=l);break;case"font-size":t instanceof ft&&(t.size=l);break;case"font-weight":t instanceof ft&&(t.weight=l);break;case"font-style":t instanceof ft&&(t.style=l);break;case"text-decoration":t instanceof ft&&(t.decoration=l);break;case"line-height":t instanceof ft&&(t.leading=l);break}return Object.keys(i.dataset).length&&(t.dataset=i.dataset),s}function Bs(i,t){for(let e=0,s=i.childNodes.length;e with no href."),console.warn(e.name,e.message),null;let r=s.slice(1);if(!$.defs.current.contains(r))return e=new et("unable to find element for reference "+s+"."),console.warn(e.name,e.message),null;let o=$.defs.current.get(r).cloneNode(!0);for(let h=0;h1&&(m=1);break;case"m":case"l":case"t":u.length>2&&(m=2);break;case"s":case"q":u.length>4&&(m=4);break;case"c":u.length>6&&(m=6);break;case"a":u.length>7&&(m=7);break}if(m){for(p=0,R=u.length,k=0;p0)switch(y){case"m":A="l";break;case"M":A="L";break}F.push(A+u.slice(p,p+m).join(" ")),k++}f=Array.prototype.concat.apply(f,F)}else f.push(d)}),S.each(f,function(d,_){let u,y,b,m=d[0],p=m.toLowerCase();l=d.slice(1).trim().match(Pt.path),n=m===p;let R,A,k,F,M,B,P,O,j,N,q,z,it,dt,tt,xt,at;switch(p){case"z":if(_>=c)r=!0;else{y=a.x,b=a.y,u=new T(y,b,void 0,void 0,void 0,void 0,v.close);for(let Lt=s.length-1;Lt>=0;Lt--){let Nt=s[Lt];if(/m/i.test(Nt.command)){a=Nt;break}}}break;case"m":case"l":h=void 0,y=parseFloat(l[0]),b=parseFloat(l[1]),u=new T(y,b,void 0,void 0,void 0,void 0,/m/i.test(p)?v.move:v.line),n&&u.addSelf(a),a=u;break;case"h":case"v":N=/h/i.test(p)?"x":"y",q=/x/i.test(N)?"y":"x",u=new T(void 0,void 0,void 0,void 0,void 0,void 0,v.line),u[N]=parseFloat(l[0]),u[q]=a[q],n&&(u[N]+=a[N]),a=u;break;case"c":case"s":R=a.x,A=a.y,h||(h=new x),/c/i.test(p)?(k=parseFloat(l[0]),F=parseFloat(l[1]),M=parseFloat(l[2]),B=parseFloat(l[3]),P=parseFloat(l[4]),O=parseFloat(l[5])):(j=Ae(a,h,n),k=j.x,F=j.y,M=parseFloat(l[0]),B=parseFloat(l[1]),P=parseFloat(l[2]),O=parseFloat(l[3])),n&&(k+=R,F+=A,M+=R,B+=A,P+=R,O+=A),a.controls.right.set(k-a.x,F-a.y),u=new T(P,O,M-P,B-O,void 0,void 0,v.curve),a=u,h=u.controls.left;break;case"t":case"q":R=a.x,A=a.y,h||(h=new x),/q/i.test(p)?(k=parseFloat(l[0]),F=parseFloat(l[1]),M=parseFloat(l[0]),B=parseFloat(l[1]),P=parseFloat(l[2]),O=parseFloat(l[3])):(j=Ae(a,h,n),k=j.x,F=j.y,M=j.x,B=j.y,P=parseFloat(l[0]),O=parseFloat(l[1])),n&&(k+=R,F+=A,M+=R,B+=A,P+=R,O+=A),a.controls.right.set((k-a.x)*.33,(F-a.y)*.33),u=new T(P,O,M-P,B-O,void 0,void 0,v.curve),a=u,h=u.controls.left;break;case"a":R=a.x,A=a.y,it=parseFloat(l[0]),dt=parseFloat(l[1]),tt=parseFloat(l[2]),xt=parseFloat(l[3]),at=parseFloat(l[4]),P=parseFloat(l[5]),O=parseFloat(l[6]),n&&(P+=R,O+=A),z=new T(P,O),z.command=v.arc,z.rx=it,z.ry=dt,z.xAxisRotation=tt,z.largeArcFlag=xt,z.sweepFlag=at,u=z,a=z,h=void 0;break}u&&(Array.isArray(u)?s=s.concat(u):s.push(u))})}e=new C(s,r,void 0,!0),e.stroke="none",e.fill="black";let o=e.getBoundingClientRect(!0);return o.centroid={x:o.left+o.width/2,y:o.top+o.height/2},S.each(e.vertices,function(a){a.subSelf(o.centroid)}),Ft.call(this,i,e,t),e.translation.addSelf(o.centroid),e},circle:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("r")),n=new Mt(0,0,r);return n.stroke="none",n.fill="black",Ft.call(this,i,n,t),n.translation.x=e,n.translation.y=s,n},ellipse:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("rx")),n=parseFloat(i.getAttribute("ry")),o=new Ot(0,0,r,n);return o.stroke="none",o.fill="black",Ft.call(this,i,o,t),o.translation.x=e,o.translation.y=s,o},rect:function(i,t){let e=parseFloat(i.getAttribute("rx")),s=parseFloat(i.getAttribute("ry"));if(!S.isNaN(e)||!S.isNaN(s))return $["rounded-rect"](i);let r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),o=r/2,a=n/2,h=new pt(0,0,r,n);return h.stroke="none",h.fill="black",Ft.call(this,i,h,t),h.translation.x+=o,h.translation.y+=a,h},"rounded-rect":function(i,t){let e=parseFloat(i.getAttribute("rx"))||0,s=parseFloat(i.getAttribute("ry"))||0,r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),o=r/2,a=n/2,h=new x(e,s),l=new Ct(0,0,r,n,h);return l.stroke="none",l.fill="black",Ft.call(this,i,l,t),l.translation.x+=o,l.translation.y+=a,l},line:function(i,t){let e=parseFloat(i.getAttribute("x1")),s=parseFloat(i.getAttribute("y1")),r=parseFloat(i.getAttribute("x2")),n=parseFloat(i.getAttribute("y2")),o=new te(e,s,r,n).noFill();return Ft.call(this,i,o,t),o},lineargradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("x1")||0),n=parseFloat(i.getAttribute("y1")||0),o=parseFloat(i.getAttribute("x2")||0),a=parseFloat(i.getAttribute("y2")||0),h=(o+r)/2,l=(a+n)/2;/userSpaceOnUse/i.test(e)&&(r-=h,n-=l,o-=h,a-=l);let f=[];for(let d=0;d1?p[1]:void 0),b===null?(p=m?m.match(/stop-opacity:\s?([0-9.-]*)/):!1,b=p&&p.length>1?parseFloat(p[1]):1):b=parseFloat(b),f.push(new ht(u,y,b))}let c=new W(r,n,o,a,f);return c.spread=s,c.units=e,Ft.call(this,i,c,t),c},radialgradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("cx"))||0,n=parseFloat(i.getAttribute("cy"))||0,o=parseFloat(i.getAttribute("r")),a=parseFloat(i.getAttribute("fx")),h=parseFloat(i.getAttribute("fy"));S.isNaN(a)&&(a=r),S.isNaN(h)&&(h=n);let l=Math.abs(r+a)/2,f=Math.abs(n+h)/2;/userSpaceOnUse/i.test(e)&&(r-=l,n-=f,a-=l,h-=f);let c=[];for(let _=0;_1?R[1]:void 0),m===null?(R=p?p.match(/stop-opacity:\s?([0-9.-]*)/):!1,m=R&&R.length>1?parseFloat(R[1]):1):m=parseFloat(m),c.push(new ht(y,b,m))}let d=new X(r,n,o,c,a,h);return d.spread=s,d.units=e,Ft.call(this,i,d,t),d},text:function(i,t){let e=Ms(i.getAttribute("text-anchor"))||"left",s=Os(i)||"baseline",r=i.textContent,n=new ft(r);return Ft.call(this,i,n,t),n.alignment=e,n.baseline=s,n},clippath:function(i,t){return $.defs.current&&!$.defs.current.contains(i.id)&&$.defs.current.add(i.id,i),null},image:function(i,t){let e,s=i.getAttribute("href")||i.getAttribute("xlink:href");if(!s)return e=new et("encountered with no href."),console.warn(e.name,e.message),null;let r=parseFloat(i.getAttribute("x"))||0,n=parseFloat(i.getAttribute("y"))||0,o=parseFloat(i.getAttribute("width")),a=parseFloat(i.getAttribute("height")),h=new jt(s,r,n);return S.isNaN(o)||(h.width=o),S.isNaN(a)||(h.height=a),Ft.call(this,i,h,t),h}};function ni(i,t){let e=new XMLHttpRequest;return e.open("GET",i),e.onreadystatechange=function(){e.readyState===4&&e.status===200&&t(e.responseText)},e.send(),e}var ee=class extends pt{_flagTextures=!1;_flagFrameRate=!1;_flagIndex=!1;_amount=1;_duration=0;_index=0;_startTime=0;_playing=!1;_firstFrame=0;_lastFrame=0;_loop=!0;_textures=null;_frameRate=0;_origin=null;constructor(t,e,s,r){super(e,s,0,0);for(let n in Di)Object.defineProperty(this,n,Di[n]);this._renderer.flagTextures=Vs.bind(this),this._renderer.bindTextures=zs.bind(this),this._renderer.unbindTextures=js.bind(this),this.noStroke(),this.noFill(),Array.isArray(t)?this.textures=t.map(Wi.bind(this)):this.textures=[Wi(t)],this.origin=new x,this._update(),typeof r=="number"?this.frameRate=r:this.frameRate=ee.DefaultFrameRate,this.index=0}static fromObject(t){let e=new ee().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e0?(n=this._amount,S.isNaN(this._lastFrame)&&(this._lastFrame=n-1),r=S.performance.now()-this._startTime,l=this._lastFrame+1,o=1e3*(l-this._firstFrame)/this._frameRate,this._loop?r=r%o:r=Math.min(r,o),h=ct(this._firstFrame,l,r/o),h=Math.floor(h),h!==this._index&&(this._index=h,a=t[this._index],a.loaded&&(e=a.image.width,s=a.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s),this.fill=a,h>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()))):(this._flagIndex||!(this.fill instanceof V))&&(a=t[this._index],a.loaded&&(e=a.image.width,s=a.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s)),this.fill=a)),super._update.call(this),this}flagReset(){return this._flagTextures=this._flagFrameRate=!1,super.flagReset.call(this),this}},ie=ee;w(ie,"Properties",["textures","frameRate","index","firstFrame","lastFrame","loop"]),w(ie,"DefaultFrameRate",30);var Di={frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}},textures:{enumerable:!0,get:function(){return this._textures},set:function(i){let t=this._renderer.bindTextures,e=this._renderer.unbindTextures;this._textures&&this._textures.unbind(g.Types.insert,t).unbind(g.Types.remove,e),this._textures=new ut((i||[]).slice(0)),this._textures.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._textures)}},firstFrame:{enumerable:!0,get:function(){return this._firstFrame},set:function(i){this._firstFrame=i}},lastFrame:{enumerable:!0,get:function(){return this._lastFrame},set:function(i){this._lastFrame=i}},loop:{enumerable:!0,get:function(){return this._loop},set:function(i){this._loop=!!i}}};function Vs(){this._flagTextures=!0}function zs(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function js(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function Wi(i){if(i instanceof V)return i;if(typeof i=="string")return new V(i)}var oi=[],ai=Math.max,Us=Math.min,Xi=Math.abs,Oe=Math.sin,Ce=Math.cos,Ds=Math.acos,Le=Math.sqrt,H={isHidden:/(undefined|none|transparent)/i,alignments:{left:"start",middle:"center",right:"end"},baselines:{top:"top",middle:"middle",bottom:"bottom",baseline:"alphabetic"},getRendererType:function(i){return i in H?i:"path"},group:{renderChild:function(i){let t=H.getRendererType(i._renderer.type);H[t].render.call(i,this.ctx,!0,this.clip)},render:function(i){if(!this._visible)return this;this._update();let t=this._matrix.elements,e=this.parent;this._renderer.opacity=this._opacity*(e&&e._renderer?e._renderer.opacity:1);let s=this._mask,r=Pe(t),n=!r||!!s;if(this._renderer.context||(this._renderer.context={}),this._renderer.context.ctx=i,n&&(i.save(),r||i.transform(t[0],t[3],t[1],t[4],t[2],t[5])),s){let o=H.getRendererType(s._renderer.type);H[o].render.call(s,i,!0)}if(this._opacity>0&&this._scale!==0)for(let o=0;o0&&(i.lineDashOffset=at.offset||0,i.setLineDash(at)),i.beginPath();let Nt,de,_e,pe,ge,me,_t;for(let D=0;D=y&&d&&(R=A,j=p.controls&&p.controls.right||x.zero,N=R.controls&&R.controls.left||x.zero,p._relative?(M=j.x+p.x,B=j.y+p.y):(M=j.x,B=j.y),R._relative?(k=N.x+R.x,F=N.y+R.y):(k=N.x,F=N.y),q=R.x,z=R.y,i.bezierCurveTo(M,B,k,F,q,z));break;case v.line:i.lineTo(q,z);break;case v.move:A=p,i.moveTo(q,z);break}return d&&i.closePath(),!dt&&!e&&(H.isHidden.test(o)||(xt=o._renderer&&o._renderer.offset,xt&&(i.save(),i.translate(-o._renderer.offset.x,-o._renderer.offset.y),i.scale(o._renderer.scale.x,o._renderer.scale.y)),i.fill(),xt&&i.restore()),H.isHidden.test(r)||(xt=r._renderer&&r._renderer.offset,xt&&(i.save(),i.translate(-r._renderer.offset.x,-r._renderer.offset.y),i.scale(r._renderer.scale.x,r._renderer.scale.y),i.lineWidth=n/r._renderer.scale.x),i.stroke(),xt&&i.restore())),tt||i.restore(),dt&&!e&&i.clip(),at&&at.length>0&&i.setLineDash(oi),this.flagReset()}},points:{render:function(i,t,e){let s,r,n,o,a,h,l,f,c,d,_,u,y,b,m,p;if(p=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,a=this._opacity*(p||1),h=this._visible,!t&&(!h||a===0))return this;if(this._update(),s=this._matrix.elements,r=this._stroke,n=this._linewidth,o=this._fill,f=this._renderer.collection,c=f.length,y=Pe(s),m=this.dashes,l=this._size,y||(i.save(),i.transform(s[0],s[3],s[1],s[4],s[2],s[5])),o)if(typeof o=="string")i.fillStyle=o;else{let k=H.getRendererType(o._renderer.type);H[k].render.call(o,i,this),i.fillStyle=o._renderer.effect}if(r){if(typeof r=="string")i.strokeStyle=r;else{let k=H.getRendererType(r._renderer.type);H[k].render.call(r,i,this),i.strokeStyle=r._renderer.effect}n&&(i.lineWidth=n)}typeof a=="number"&&(i.globalAlpha=a),m&&m.length>0&&(i.lineDashOffset=m.offset||0,i.setLineDash(m)),i.beginPath();let R=l*.5,A;this._sizeAttenuation||(A=this.worldMatrix.elements,A=Et(A[0],A[3],A[1],A[4],A[2],A[5]),R/=Math.max(A.scaleX,A.scaleY));for(let k=0;k0&&i.setLineDash(oi),this.flagReset()}},text:{render:function(i,t,e){let s=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,r=this._opacity*s,n=this._visible,o=this._mask,a=this._clip;if(!t&&(!n||a||r===0))return this;this._update();let h=this._matrix.elements,l=this._stroke,f=this._linewidth,c=this._fill,d=this._decoration,_=this._direction,u=Pe(h),y=c._renderer&&c._renderer.offset&&l._renderer&&l._renderer.offset,b=this.dashes,m=H.alignments[this._alignment]||this._alignment,p=H.baselines[this._baseline]||this._baseline,R,A,k,F,M,B,P,O,j,N,q;if(u||(i.save(),i.transform(h[0],h[3],h[1],h[4],h[2],h[5])),o){let z=H.getRendererType(o._renderer.type);H[z].render.call(o,i,!0)}if(y||(i.font=[this._style,this._weight,this._size+"px/"+this._leading+"px",this._family].join(" ")),i.textAlign=m,i.textBaseline=p,i.direction=_,c)if(typeof c=="string")i.fillStyle=c;else{let z=H.getRendererType(c._renderer.type);H[z].render.call(c,i,this),i.fillStyle=c._renderer.effect}if(l){if(typeof l=="string")i.strokeStyle=l;else{let z=H.getRendererType(l._renderer.type);H[z].render.call(l,i,this),i.strokeStyle=l._renderer.effect}f&&(i.lineWidth=f)}if(typeof r=="number"&&(i.globalAlpha=r),b&&b.length>0&&(i.lineDashOffset=b.offset||0,i.setLineDash(b)),!a&&!e&&(H.isHidden.test(c)||(c._renderer&&c._renderer.offset?(B=c._renderer.scale.x,P=c._renderer.scale.y,i.save(),i.translate(-c._renderer.offset.x,-c._renderer.offset.y),i.scale(B,P),R=this._size/c._renderer.scale.y,A=this._leading/c._renderer.scale.y,i.font=[this._style,this._weight,R+"px/",A+"px",this._family].join(" "),k=c._renderer.offset.x/c._renderer.scale.x,F=c._renderer.offset.y/c._renderer.scale.y,i.fillText(this.value,k,F),i.restore()):i.fillText(this.value,0,0)),H.isHidden.test(l)||(l._renderer&&l._renderer.offset?(B=l._renderer.scale.x,P=l._renderer.scale.y,i.save(),i.translate(-l._renderer.offset.x,-l._renderer.offset.y),i.scale(B,P),R=this._size/l._renderer.scale.y,A=this._leading/l._renderer.scale.y,i.font=[this._style,this._weight,R+"px/",A+"px",this._family].join(" "),k=l._renderer.offset.x/l._renderer.scale.x,F=l._renderer.offset.y/l._renderer.scale.y,M=f/l._renderer.scale.x,i.lineWidth=M,i.strokeText(this.value,k,F),i.restore()):i.strokeText(this.value,0,0))),/(underline|strikethrough)/i.test(d)){let z=i.measureText(this.value),it=1;switch(d){case"underline":j=z.actualBoundingBoxDescent,q=z.actualBoundingBoxDescent;break;case"strikethrough":j=0,q=0,it=.5;break}switch(p){case"top":j+=this._size*it,q+=this._size*it;break;case"baseline":case"bottom":j-=this._size*it,q-=this._size*it;break}switch(m){case"left":case"start":O=0,N=z.width;break;case"right":case"end":O=-z.width,N=0;break;default:O=-z.width/2,N=z.width/2}i.lineWidth=Math.max(Math.floor(this._size/15),1),i.strokeStyle=i.fillStyle,i.beginPath(),i.moveTo(O,j),i.lineTo(N,q),i.stroke()}return u||i.restore(),a&&!e&&i.clip(),b&&b.length>0&&i.setLineDash(oi),this.flagReset()}},"linear-gradient":{render:function(i,t){if(!!t){if(this._update(),!this._renderer.effect||this._flagEndPoints||this._flagStops||this._flagUnits){let e,s=this.left._x,r=this.left._y,n=this.right._x,o=this.right._y;/objectBoundingBox/i.test(this._units)&&(e=t.getBoundingClientRect(!0),s=(s-.5)*e.width,r=(r-.5)*e.height,n=(n-.5)*e.width,o=(o-.5)*e.height),this._renderer.effect=i.createLinearGradient(s,r,n,o);for(let a=0;a1){let z=Le(p);s=z*s,r=z*r,b=s*s,m=r*r}let R=b*y+m*u,A=(b*m-R)/R,k=Le(ai(0,A));n===o&&(k=-k);let F=k*s*_/r,M=-k*r*d/s,B=Ce(a)*F-Oe(a)*M+(t+h)/2,P=Oe(a)*F+Ce(a)*M+(e+l)/2,O=Hi(1,0,(d-F)/s,(_-M)/r),j=Hi((d-F)/s,(_-M)/r,(-d-F)/s,(-_-M)/r)%J,N=O+j;Ws(i,B,P,s,r,O,N,o===0,a)}},rt=class extends g{constructor(t){super();let e=t.smoothing!==!1;this.domElement=t.domElement||document.createElement("canvas"),this.ctx=this.domElement.getContext("2d"),this.overdraw=t.overdraw||!1,typeof this.ctx.imageSmoothingEnabled<"u"&&(this.ctx.imageSmoothingEnabled=e),this.scene=new K,this.scene.parent=this}setSize(t,e,s){return this.width=t,this.height=e,this.ratio=typeof s>"u"?ne(this.ctx):s,this.domElement.width=t*this.ratio,this.domElement.height=e*this.ratio,this.domElement.style&&S.extend(this.domElement.style,{width:t+"px",height:e+"px"}),this.trigger(g.Types.resize,t,e,s)}render(){let t=this.ratio===1;return t||(this.ctx.save(),this.ctx.scale(this.ratio,this.ratio)),this.overdraw||this.ctx.clearRect(0,0,this.width,this.height),H.group.render.call(this.scene,this.ctx),t||this.ctx.restore(),this}};w(rt,"Utils",H);function Ws(i,t,e,s,r,n,o,a,h){let l=o-n,f=Zt.Tolerance.epsilon,c=Math.abs(l)0&&E.setAttributes(s,t),s},setAttributes:function(i,t){let e=Object.keys(t);for(let s=0;s=s&&t&&(a.command===v.curve&&(c=r,p=a.controls&&a.controls.right||a,R=c.controls&&c.controls.left||c,a.relative?(d=U(p.x+a.x),_=U(p.y+a.y)):(d=U(p.x),_=U(p.y)),c.relative?(u=U(R.x+c.x),y=U(R.y+c.y)):(u=U(R.x),y=U(R.y)),P=U(c.x),O=U(c.y),f+=" C "+d+" "+_+" "+u+" "+y+" "+P+" "+O),a.command!==v.close&&(f+=" Z")),n+=f+" "}return n},pointsToString:function(i,t){let e="",s=t*.5;for(let r=0;r"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}if(this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t["stroke-opacity"]=this._opacity,t["fill-opacity"]=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this._flagCap&&(t["stroke-linecap"]=this._cap),this._flagJoin&&(t["stroke-linejoin"]=this._join),this._flagMiter&&(t["stroke-miterlimit"]=this._miter),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("path",t),i.appendChild(this._renderer.elem)),this._flagClip){let s=E.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}if(this._flagMask)if(this._mask){let s=E.getRendererType(this._mask._renderer.type);E[s].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")}else this._renderer.elem.removeAttribute("clip-path");return this.flagReset()}},points:{render:function(i){if(this._opacity===0&&!this._flagOpacity)return this;this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagVertices||this._flagSize||this._flagSizeAttenuation){let s=this._size;if(!this._sizeAttenuation){let n=this.worldMatrix.elements,o=Et(n[0],n[3],n[1],n[4],n[2],n[5]);s/=Math.max(o.scaleX,o.scaleY)}let r=E.pointsToString(this._renderer.collection,s);t.d=r}if(this._fill&&this._fill._renderer){this._renderer.hasFillEffect=!0,this._fill._update();let s=E.getRendererType(this._fill._renderer.type);E[s].render.call(this._fill,i,!0)}if(this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill,this._renderer.hasFillEffect&&typeof this._fill.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}return this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t["stroke-opacity"]=this._opacity,t["fill-opacity"]=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("path",t),i.appendChild(this._renderer.elem)),this.flagReset()}},text:{render:function(i){this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagFamily&&(t["font-family"]=this._family),this._flagSize&&(t["font-size"]=this._size),this._flagLeading&&(t["line-height"]=this._leading),this._flagAlignment&&(t["text-anchor"]=E.alignments[this._alignment]||this._alignment),this._flagBaseline&&(t["dominant-baseline"]=E.baselines[this._baseline]||this._baseline),this._flagStyle&&(t["font-style"]=this._style),this._flagWeight&&(t["font-weight"]=this._weight),this._flagDecoration&&(t["text-decoration"]=this._decoration),this._flagDirection&&(t.direction=this._direction),this._fill&&this._fill._renderer){this._renderer.hasFillEffect=!0,this._fill._update();let s=E.getRendererType(this._fill._renderer.type);E[s].render.call(this._fill,i,!0)}if(this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill,this._renderer.hasFillEffect&&typeof this._fill.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}if(this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t.opacity=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("text",t),i.appendChild(this._renderer.elem)),this._flagClip){let s=E.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}if(this._flagMask)if(this._mask){let s=E.getRendererType(this._mask._renderer.type);E[s].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")}else this._renderer.elem.removeAttribute("clip-path");return this._flagValue&&(this._renderer.elem.textContent=this._value),this.flagReset()}},"linear-gradient":{render:function(i,t){t||this._update();let e={};if(this._flagId&&(e.id=this._id),this._flagEndPoints&&(e.x1=this.left._x,e.y1=this.left._y,e.x2=this.right._x,e.y2=this.right._y),this._flagSpread&&(e.spreadMethod=this._spread),this._flagUnits&&(e.gradientUnits=this._units),this._renderer.elem?E.setAttributes(this._renderer.elem,e):(e.id=this._id,this._renderer.elem=E.createElement("linearGradient",e)),this._renderer.elem.parentNode===null&&i.defs.appendChild(this._renderer.elem),this._flagStops){let s=this._renderer.elem.childNodes.length!==this.stops.length;if(s)for(;this._renderer.elem.lastChild;)this._renderer.elem.removeChild(this._renderer.elem.lastChild);for(let r=0;r0&&(e.x*=-1),e.y>0&&(e.y*=-1)),(this._flagScale||this._flagLoaded||this._flagRepeat)&&(e.width=0,e.height=0,r)){switch(e.width=r.width,e.height=r.height,this._repeat){case"no-repeat":e.width+=1,e.height+=1;break}this._scale instanceof x?(e.width*=this._scale.x,e.height*=this._scale.y):(e.width*=this._scale,e.height*=this._scale),s.width=e.width,s.height=e.height}return(this._flagScale||this._flagLoaded)&&(this._renderer.image?E.setAttributes(this._renderer.image,s):this._renderer.image=E.createElement("image",s)),this._renderer.elem?Object.keys(e).length!==0&&E.setAttributes(this._renderer.elem,e):(e.id=this._id,e.patternUnits="userSpaceOnUse",this._renderer.elem=E.createElement("pattern",e)),this._renderer.elem.parentNode===null&&i.defs.appendChild(this._renderer.elem),this._renderer.elem&&this._renderer.image&&!this._renderer.appended&&(this._renderer.elem.appendChild(this._renderer.image),this._renderer.appended=!0),this.flagReset()}}},we=class extends g{constructor(t){super(),this.domElement=t.domElement||E.createElement("svg"),this.scene=new K,this.scene.parent=this,this.defs=E.createElement("defs"),this.defs._flagUpdate=!1,this.domElement.appendChild(this.defs),this.domElement.defs=this.defs,this.domElement.style.overflow="hidden"}setSize(t,e){return this.width=t,this.height=e,E.setAttributes(this.domElement,{width:t,height:e}),this.trigger(g.Types.resize,t,e)}render(){return E.group.render.call(this.scene,this.domElement),E.defs.update(this.domElement),this}};w(we,"Utils",E);var wt={create:function(i,t,e){let s=i.createShader(i[e]);if(i.shaderSource(s,t),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS)){let n=i.getShaderInfoLog(s);throw i.deleteShader(s),new et("unable to compile shader "+s+": "+n)}return s},types:{vertex:"VERTEX_SHADER",fragment:"FRAGMENT_SHADER"},path:{vertex:` +var Two=(()=>{var Re=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var Ki=Object.getOwnPropertyNames;var $i=Object.prototype.hasOwnProperty;var Ji=(i,t,e)=>t in i?Re(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var Be=(i,t)=>{for(var e in t)Re(i,e,{get:t[e],enumerable:!0})},Zi=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ki(t))!$i.call(i,r)&&r!==e&&Re(i,r,{get:()=>t[r],enumerable:!(s=qi(t,r))||s.enumerable});return i};var Qi=i=>Zi(Re({},"__esModule",{value:!0}),i);var w=(i,t,e)=>(Ji(i,typeof t!="symbol"?t+"":t,e),e);var $s={};Be($s,{default:()=>I});var lt={Image:null,isHeadless:!1,shim:function(i,t){return i.tagName=i.nodeName=t||"canvas",i.nodeType=1,i.getAttribute=function(e){return this[e]},i.setAttribute=function(e,s){return this[e]=s,this},i},polyfill:function(i,t){return lt.shim(i),typeof t<"u"&&(lt.Image=t),lt.isHeadless=!0,i}};var He={};Be(He,{Curve:()=>Zt,getAnchorsFromArcData:()=>is,getComponentOnCubicBezier:()=>se,getControlPoints:()=>di,getCurveBoundingBox:()=>We,getCurveFromPoints:()=>Xe,getCurveLength:()=>De,getReflection:()=>Ae,integrate:()=>ui,subdivide:()=>ye});var Ue={};Be(Ue,{HALF_PI:()=>Z,NumArray:()=>vt,TWO_PI:()=>J,decomposeMatrix:()=>Et,getComputedMatrix:()=>ze,getPoT:()=>je,lerp:()=>ct,mod:()=>nt,setMatrix:()=>Ve,toFixed:()=>U});var Y;typeof window<"u"?Y=window:typeof global<"u"?Y=global:typeof self<"u"&&(Y=self);var hi,J=Math.PI*2,Z=Math.PI*.5;function Et(i,t,e,s,r,n){let o;return arguments.length<=1?(o=i.a,t=i.b,e=i.c,s=i.d,r=i.e,n=i.f):o=i,{translateX:r,translateY:n,scaleX:Math.sqrt(o*o+t*t),scaleY:Math.sqrt(e*e+s*s),rotation:180*Math.atan2(t,o)/Math.PI}}function Ve(i){hi=i}function ze(i,t){t=t&&t.identity()||new hi;let e=i,s=[];for(;e&&e._matrix;)s.push(e._matrix),e=e.parent;s.reverse();for(let r=0;r=4){let n=arguments[0]-arguments[2],o=arguments[1]-arguments[3];return Math.atan2(o,n)}let s=t.x-e.x,r=t.y-e.y;return Math.atan2(r,s)}static distanceBetween(t,e){return Math.sqrt(kt.distanceBetweenSquared(t,e))}static distanceBetweenSquared(t,e){let s=t.x-e.x,r=t.y-e.y;return s*s+r*r}set(t,e){return this.x=t,this.y=e,this}copy(t){return this.x=t.x,this.y=t.y,this}clear(){return this.x=0,this.y=0,this}clone(){return new kt(this.x,this.y)}add(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x+=t,this.y+=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x+=t.x,this.y+=t.y):(this.x+=t,this.y+=e),this)}addSelf(t){return this.add.apply(this,arguments)}sub(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x-=t,this.y-=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x-=t.x,this.y-=t.y):(this.x-=t,this.y-=e),this)}subtract(){return this.sub.apply(this,arguments)}subSelf(t){return this.sub.apply(this,arguments)}subtractSelf(t){return this.sub.apply(this,arguments)}multiply(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x*=t,this.y*=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x*=t.x,this.y*=t.y):(this.x*=t,this.y*=e),this)}multiplySelf(t){return this.multiply.apply(this,arguments)}multiplyScalar(t){return this.multiply(t)}divide(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x/=t,this.y/=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x/=t.x,this.y/=t.y):(this.x/=t,this.y/=e),isNaN(this.x)&&(this.x=0),isNaN(this.y)&&(this.y=0),this)}divideSelf(t){return this.divide.apply(this,arguments)}divideScalar(t){return this.divide(t)}negate(){return this.multiply(-1)}dot(t){return this.x*t.x+this.y*t.y}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.divideScalar(this.length())}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}setLength(t){return this.normalize().multiplyScalar(t)}equals(t,e){return e=typeof e>"u"?1e-4:e,this.distanceTo(t)"u"?1e-4:t,this.length()>1,f=s&1?n[h++]*i(a):0;for(;h=0&&t<4294967296}var S={isNaN:function(i){return typeof i=="number"&&i!==+i},isElement:function(i){return!!(i&&i.nodeType===1)},isObject:function(i){let t=typeof i;return t==="function"||t==="object"&&!!i},extend:function(i){let t=_i.call(arguments,1);for(let e=0;e0&&this.push.apply(this,arguments[0]):arguments.length>0&&this.push.apply(this,arguments)}pop(){let t=super.pop.apply(this,arguments);return this.trigger(g.Types.remove,[t]),t}shift(){let t=super.shift.apply(this,arguments);return this.trigger(g.Types.remove,[t]),t}push(){let t=super.push.apply(this,arguments);return this.trigger(g.Types.insert,arguments),t}unshift(){let t=super.unshift.apply(this,arguments);return this.trigger(g.Types.insert,arguments),t}splice(){let t=super.splice.apply(this,arguments);if(this.trigger(g.Types.remove,t),arguments.length>2){let e=this.slice(arguments[0],arguments[0]+arguments.length-2);this.trigger(g.Types.insert,e),this.trigger(g.Types.order)}return t}sort(){return super.sort.apply(this,arguments),this.trigger(g.Types.order),this}reverse(){return super.reverse.apply(this,arguments),this.trigger(g.Types.order),this}indexOf(){return super.indexOf.apply(this,arguments)}map(t,e){let s=[];for(let r=0;r=4&&(this._flagVideo=!0),this}flagReset(){return this._flagSrc=this._flagImage=this._flagLoaded=this._flagRepeat=this._flagVideo=this._flagScale=this._flagOffset=!1,super.flagReset.call(this),this}},V=st;w(V,"Properties",["src","loaded","repeat","scale","offset","image"]),w(V,"RegularExpressions",gi),w(V,"ImageRegistry",new Tt),w(V,"Register",{canvas:function(t,e){t._src="#"+t.id,st.ImageRegistry.add(t.src,t.image),typeof e=="function"&&e()},img:function(t,e){let s=t.image,r=function(o){!lt.isHeadless&&s.removeEventListener&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),typeof e=="function"&&e()},n=function(o){throw!lt.isHeadless&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),new et("unable to load "+t.src)};typeof s.width=="number"&&s.width>0&&typeof s.height=="number"&&s.height>0?r():!lt.isHeadless&&typeof s.addEventListener=="function"&&(s.addEventListener("load",r,!1),s.addEventListener("error",n,!1)),t._src=st.getAbsoluteURL(t._src),!(!lt.isHeadless&&s&&s.getAttribute("two-src"))&&(lt.isHeadless||s.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,s),lt.isHeadless?st.loadHeadlessBuffer(t,r):t.image.src=t.src)},video:function(t,e){if(lt.isHeadless)throw new et("video textures are not implemented in headless environments.");let s=function(n){t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),t.image.width=t.image.videoWidth,t.image.height=t.image.videoHeight,typeof e=="function"&&e()},r=function(n){throw t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),new et("unable to load "+t.src)};t._src=st.getAbsoluteURL(t._src),t.image.getAttribute("two-src")||(t.image.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,t.image)),t.image.readyState>=4?s():(t.image.addEventListener("canplaythrough",s,!1),t.image.addEventListener("error",r,!1),t.image.src=t.src,t.image.load())}});var mi={src:{enumerable:!0,get:function(){return this._src},set:function(i){this._src=i,this._flagSrc=!0}},loaded:{enumerable:!0,get:function(){return this._loaded},set:function(i){this._loaded=i,this._flagLoaded=!0}},repeat:{enumerable:!0,get:function(){return this._repeat},set:function(i){this._repeat=i,this._flagRepeat=!0}},image:{enumerable:!0,get:function(){return this._image},set:function(i){let t=V.getTag(i),e;switch(t){case"canvas":e="#"+i.id;break;default:e=i.src}V.ImageRegistry.contains(e)?this._image=V.ImageRegistry.get(i.src):this._image=i,this._flagImage=!0}},offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset&&this._offset.unbind(g.Types.change,this._renderer.flagOffset),this._offset=i,this._offset.bind(g.Types.change,this._renderer.flagOffset),this._flagOffset=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof x&&this._scale.unbind(g.Types.change,this._renderer.flagScale),this._scale=i,this._scale instanceof x&&this._scale.bind(g.Types.change,this._renderer.flagScale),this._flagScale=!0}}};function os(){this._flagOffset=!0}function as(){this._flagScale=!0}var Rt=class extends mt{_flagOffset=!0;_flagOpacity=!0;_flagColor=!0;_offset=0;_opacity=1;_color="#fff";constructor(t,e,s){super();for(let r in yi)Object.defineProperty(this,r,yi[r]);this._renderer.type="stop",this.offset=typeof t=="number"?t:Rt.Index<=0?0:1,this.opacity=typeof s=="number"?s:1,this.color=typeof e=="string"?e:Rt.Index<=0?"#fff":"#000",Rt.Index=(Rt.Index+1)%2}static fromObject(t){let e=new Rt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e{t[e]=this[e]},this),t}flagReset(){return this._flagOffset=this._flagColor=this._flagOpacity=!1,super.flagReset.call(this),this}},ht=Rt;w(ht,"Index",0),w(ht,"Properties",["offset","opacity","color"]);var yi={offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset=i,this._flagOffset=!0,this.parent&&(this.parent._flagStops=!0)}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0,this.parent&&(this.parent._flagStops=!0)}},color:{enumerable:!0,get:function(){return this._color},set:function(i){this._color=i,this._flagColor=!0,this.parent&&(this.parent._flagStops=!0)}}};var Vt=class extends mt{_flagStops=!1;_flagSpread=!1;_flagUnits=!1;_spread="";_units="";constructor(t){super();for(let e in bi)Object.defineProperty(this,e,bi[e]);this._renderer.type="gradient",this._renderer.flagStops=ls.bind(this),this._renderer.bindStops=hs.bind(this),this._renderer.unbindStops=fs.bind(this),this.spread="pad",this.units="objectBoundingBox",t&&(this.stops=t)}static fromObject(t){let e=t.stops;e&&e.length>0&&(e=e.map(r=>r instanceof ht?r:new ht().copy(r)));let s=new Vt().copy(t);return"id"in t&&(s.id=t.id),s}clone(t){let e=this.stops.map(r=>r.clone()),s=new Vt(e);return S.each(Vt.Properties,r=>{s[r]=this[r]},this),t&&t.add(s),s}copy(t){super.copy.call(this,t);for(let e=0;ee.toObject())};return S.each(Vt.Properties,e=>{t[e]=this[e]},this),t}_update(){return(this._flagSpread||this._flagStops)&&this.trigger(g.Types.change),this}flagReset(){return this._flagSpread=this._flagUnits=this._flagStops=!1,super.flagReset.call(this),this}},G=Vt;w(G,"Stop",ht),w(G,"Properties",["spread","stops","units"]);var bi={spread:{enumerable:!0,get:function(){return this._spread},set:function(i){this._spread=i,this._flagSpread=!0}},units:{enumerable:!0,get:function(){return this._units},set:function(i){this._units=i,this._flagUnits=!0}},stops:{enumerable:!0,get:function(){return this._stops},set:function(i){let t=this._renderer.bindStops,e=this._renderer.unbindStops;this._stops&&this._stops.unbind(g.Types.insert,t).unbind(g.Types.remove,e),this._stops=new ut((i||[]).slice(0)),this._stops.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._stops)}}};function ls(){this._flagStops=!0}function hs(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagStops),i[t].parent=this;this._renderer.flagStops()}function fs(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagStops),delete i[t].parent;this._renderer.flagStops()}var oe=class extends G{_flagEndPoints=!1;_left=null;_right=null;constructor(t,e,s,r,n){super(n);for(let o in xi)Object.defineProperty(this,o,xi[o]);this._renderer.type="linear-gradient",this._renderer.flagEndPoints=cs.bind(this),this.left=new x,this.right=new x,typeof t=="number"&&(this.left.x=t),typeof e=="number"&&(this.left.y=e),typeof s=="number"&&(this.right.x=s),typeof r=="number"&&(this.right.y=r)}static fromObject(t){let e=new oe().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e=s)return s-r>=0;r+=o}return!1}function ae(i,t){let e=i._length;if(t<=0)return 0;if(t>=e)return i._lengths.length-1;for(let s=0,r=0;s=t)return t-=r,Math.max(s-1,0)+t/i._lengths[s];r+=i._lengths[s]}return-1}function Se(i,t,e){let s,r,n,o,a,h,l,f,c=t.controls&&t.controls.right,d=i.controls&&i.controls.left;return s=t.x,a=t.y,r=(c||t).x,h=(c||t).y,n=(d||i).x,l=(d||i).y,o=i.x,f=i.y,c&&t._relative&&(r+=t.x,h+=t.y),d&&i._relative&&(n+=i.x,l+=i.y),De(s,a,r,h,n,l,o,f,e)}function Ge(i,t,e){let s,r,n,o,a,h,l,f,c=t.controls&&t.controls.right,d=i.controls&&i.controls.left;return s=t.x,a=t.y,r=(c||t).x,h=(c||t).y,n=(d||i).x,l=(d||i).y,o=i.x,f=i.y,c&&t._relative&&(r+=t.x,h+=t.y),d&&i._relative&&(n+=i.x,l+=i.y),ye(s,a,r,h,n,l,o,f,e)}function St(i){switch(i.renderer.type){case"texture":return V.fromObject(i);case"gradient":return G.fromObject(i);case"linear-gradient":return W.fromObject(i);case"radial-gradient":return X.fromObject(i)}return i}var _s=Math.cos,ps=Math.sin,vi=Math.tan,qe=[],yt=class extends g{elements=new vt(9);manual=!1;constructor(t,e,s,r,n,o){super();let a=t;Array.isArray(a)||(a=Array.prototype.slice.call(arguments)),this.identity(),a.length>0&&this.set(a)}static Multiply(t,e,s){if(e.length<=3){let F=t,M,B,P,O=e[0]||0,j=e[1]||0,N=e[2]||0;return M=F[0]*O+F[1]*j+F[2]*N,B=F[3]*O+F[4]*j+F[5]*N,P=F[6]*O+F[7]*j+F[8]*N,[M,B,P]}let r=t[0],n=t[1],o=t[2],a=t[3],h=t[4],l=t[5],f=t[6],c=t[7],d=t[8],_=e[0],u=e[1],y=e[2],b=e[3],m=e[4],p=e[5],R=e[6],A=e[7],k=e[8];return s=s||new vt(9),s[0]=r*_+n*b+o*R,s[1]=r*u+n*m+o*A,s[2]=r*y+n*p+o*k,s[3]=a*_+h*b+l*R,s[4]=a*u+h*m+l*A,s[5]=a*y+h*p+l*k,s[6]=f*_+c*b+d*R,s[7]=f*u+c*m+d*A,s[8]=f*y+c*p+d*k,s}static fromObject(t){return new yt().copy(t)}set(t,e,s,r,n,o,a,h,l){if(typeof e>"u"){let f=t;t=f[0],e=f[1],s=f[2],r=f[3],n=f[4],o=f[5],a=f[6],h=f[7],l=f[8]}return this.elements[0]=t,this.elements[1]=e,this.elements[2]=s,this.elements[3]=r,this.elements[4]=n,this.elements[5]=o,this.elements[6]=a,this.elements[7]=h,this.elements[8]=l,this.trigger(g.Types.change)}copy(t){return this.elements[0]=t.elements[0],this.elements[1]=t.elements[1],this.elements[2]=t.elements[2],this.elements[3]=t.elements[3],this.elements[4]=t.elements[4],this.elements[5]=t.elements[5],this.elements[6]=t.elements[6],this.elements[7]=t.elements[7],this.elements[8]=t.elements[8],this.manual=t.manual,this.trigger(g.Types.change)}identity(){return this.elements[0]=yt.Identity[0],this.elements[1]=yt.Identity[1],this.elements[2]=yt.Identity[2],this.elements[3]=yt.Identity[3],this.elements[4]=yt.Identity[4],this.elements[5]=yt.Identity[5],this.elements[6]=yt.Identity[6],this.elements[7]=yt.Identity[7],this.elements[8]=yt.Identity[8],this.trigger(g.Types.change)}multiply(t,e,s,r,n,o,a,h,l){if(typeof e>"u")return this.elements[0]*=t,this.elements[1]*=t,this.elements[2]*=t,this.elements[3]*=t,this.elements[4]*=t,this.elements[5]*=t,this.elements[6]*=t,this.elements[7]*=t,this.elements[8]*=t,this.trigger(g.Types.change);if(typeof s>"u"&&(s=1),typeof r>"u"){t=t||0,e=e||0,s=s||0,n=this.elements;let z=n[0]*t+n[1]*e+n[2]*s,it=n[3]*t+n[4]*e+n[5]*s,dt=n[6]*t+n[7]*e+n[8]*s;return[z,it,dt]}let f=this.elements,c=[t,e,s,r,n,o,a,h,l],d=f[0],_=f[1],u=f[2],y=f[3],b=f[4],m=f[5],p=f[6],R=f[7],A=f[8],k=c[0],F=c[1],M=c[2],B=c[3],P=c[4],O=c[5],j=c[6],N=c[7],q=c[8];return this.elements[0]=d*k+_*B+u*j,this.elements[1]=d*F+_*P+u*N,this.elements[2]=d*M+_*O+u*q,this.elements[3]=y*k+b*B+m*j,this.elements[4]=y*F+b*P+m*N,this.elements[5]=y*M+b*O+m*q,this.elements[6]=p*k+R*B+A*j,this.elements[7]=p*F+R*P+A*N,this.elements[8]=p*M+R*O+A*q,this.trigger(g.Types.change)}inverse(t){let e=this.elements;t=t||new yt;let s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],l=e[6],f=e[7],c=e[8],d=c*a-h*f,_=-c*o+h*l,u=f*o-a*l,y=s*d+r*_+n*u;return y?(y=1/y,t.elements[0]=d*y,t.elements[1]=(-c*r+n*f)*y,t.elements[2]=(h*r-n*a)*y,t.elements[3]=_*y,t.elements[4]=(c*s-n*l)*y,t.elements[5]=(-h*s+n*o)*y,t.elements[6]=u*y,t.elements[7]=(-f*s+r*l)*y,t.elements[8]=(a*s-r*o)*y,t):null}scale(t,e){return arguments.length<=1&&(e=t),this.multiply(t,0,0,0,e,0,0,0,1)}rotate(t){let e=_s(t),s=ps(t);return this.multiply(e,-s,0,s,e,0,0,0,1)}translate(t,e){return this.multiply(1,0,t,0,1,e,0,0,1)}skewX(t){let e=vi(t);return this.multiply(1,e,0,0,1,0,0,0,1)}skewY(t){let e=vi(t);return this.multiply(1,0,0,e,1,0,0,0,1)}toString(t){return qe.length=0,this.toTransformArray(t,qe),qe.map(U).join(" ")}toTransformArray(t,e){let s=this.elements,r=!!e,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],f=s[5];if(t){let c=s[6],d=s[7],_=s[8];if(r){e[0]=n,e[1]=h,e[2]=c,e[3]=o,e[4]=l,e[5]=d,e[6]=a,e[7]=f,e[8]=_;return}return[n,h,c,o,l,d,a,f,_]}if(r){e[0]=n,e[1]=h,e[2]=o,e[3]=l,e[4]=a,e[5]=f;return}return[n,h,o,l,a,f]}toArray(t,e){let s=this.elements,r=!!e,n=s[0],o=s[1],a=s[2],h=s[3],l=s[4],f=s[5];if(t){let c=s[6],d=s[7],_=s[8];if(r){e[0]=n,e[1]=o,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=c,e[7]=d,e[8]=_;return}return[n,o,a,h,l,f,c,d,_]}if(r){e[0]=n,e[1]=o,e[2]=a,e[3]=h,e[4]=l,e[5]=f;return}return[n,o,a,h,l,f]}toObject(){return{renderer:{type:"matrix"},elements:this.toArray(!0),manual:!!this.manual}}clone(){return new yt().copy(this)}},At=yt;w(At,"Identity",[1,0,0,0,1,0,0,0,1]);Ve(At);var ot=class extends mt{_flagMatrix=!0;_flagScale=!1;_matrix=null;_worldMatrix=null;_position=null;_rotation=0;_scale=1;_skewX=0;_skewY=0;constructor(){super();for(let t in Ee)Object.defineProperty(this,t,Ee[t]);this._renderer.flagMatrix=ki.bind(this),this.isShape=!0,this.matrix=new At,this.worldMatrix=new At,this.position=new x,this.rotation=0,this.scale=1,this.skewX=0,this.skewY=0}static fromObject(t){let e=new ot().copy(t);return"id"in t&&(e.id=t.id),e}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get translation(){return Ee.position.get.apply(this,arguments)}set translation(t){Ee.position.set.apply(this,arguments)}addTo(t){return t.add(this),this}remove(){return this.parent?(this.parent.remove(this),this):this}copy(t){return super.copy.call(this,t),"position"in t&&(t.position instanceof x?this.position=t.position:this.position.copy(t.position)),"rotation"in t&&(this.rotation=t.rotation),"scale"in t&&(this.scale=typeof t.scale=="number"||t.scale instanceof x?t.scale:new x(t.scale.x,t.scale.y)),"skewX"in t&&(this.skewX=t.skewX),"skewY"in t&&(this.skewY=t.skewY),"matrix"in t&&t.matrix.manual&&(this.matrix.copy(t.matrix),this.matrix.manual=!0),this}clone(t){let e=new ot;return e.position.copy(this.position),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,this.matrix.manual&&e.matrix.copy(this.matrix),t&&t.add(e),e._update()}toObject(){let t=super.toObject.call(this);return t.renderer={type:"shape"},t.isShape=!0,t.translation=this.translation.toObject(),t.rotation=this.translation.rotation,t.scale=this.scale instanceof x?this.scale.toObject():this.scale,t.skewX=this.skewX,t.skewY=this.skewY,t.matrix=this.matrix.toObject(),t}_update(t){return!this._matrix.manual&&this._flagMatrix&&(this._matrix.identity().translate(this.position.x,this.position.y),this._scale instanceof x?this._matrix.scale(this._scale.x,this._scale.y):this._matrix.scale(this._scale),this._matrix.rotate(this.rotation),this._matrix.skewX(this.skewX),this._matrix.skewY(this.skewY)),t&&this.parent&&this.parent._update&&this.parent._update(),this}flagReset(){return this._flagMatrix=this._flagScale=!1,super.flagReset.call(this),this}},Ee={position:{enumerable:!0,get:function(){return this._position},set:function(i){this._position&&this._position.unbind(g.Types.change,this._renderer.flagMatrix),this._position=i,this._position.bind(g.Types.change,this._renderer.flagMatrix),ki.call(this)}},rotation:{enumerable:!0,get:function(){return this._rotation},set:function(i){this._rotation=i,this._flagMatrix=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof x&&this._scale.unbind(g.Types.change,this._renderer.flagMatrix),this._scale=i,this._scale instanceof x&&this._scale.bind(g.Types.change,this._renderer.flagMatrix),this._flagMatrix=!0,this._flagScale=!0}},skewX:{enumerable:!0,get:function(){return this._skewX},set:function(i){this._skewX=i,this._flagMatrix=!0}},skewY:{enumerable:!0,get:function(){return this._skewY},set:function(i){this._skewY=i,this._flagMatrix=!0}},matrix:{enumerable:!0,get:function(){return this._matrix},set:function(i){this._matrix=i,this._flagMatrix=!0}},worldMatrix:{enumerable:!0,get:function(){return ze(this,this._worldMatrix),this._worldMatrix},set:function(i){this._worldMatrix=i}}};function ki(){this._flagMatrix=!0}var le=Math.min,he=Math.max,gs=Math.ceil,ms=Math.floor,ys=new x,It=class extends ot{_flagVertices=!0;_flagLength=!0;_flagFill=!0;_flagStroke=!0;_flagLinewidth=!0;_flagOpacity=!0;_flagVisible=!0;_flagCap=!0;_flagJoin=!0;_flagMiter=!0;_flagMask=!1;_flagClip=!1;_length=0;_fill="#fff";_stroke="#000";_linewidth=1;_opacity=1;_visible=!0;_cap="round";_join="round";_miter=4;_closed=!0;_curved=!1;_automatic=!0;_beginning=0;_ending=1;_mask=null;_clip=!1;_dashes=null;constructor(t,e,s,r){super();for(let n in Ri)Object.defineProperty(this,n,Ri[n]);this._renderer.type="path",this._renderer.flagVertices=Ke.bind(this),this._renderer.bindVertices=$e.bind(this),this._renderer.unbindVertices=Je.bind(this),this._renderer.flagFill=Ze.bind(this),this._renderer.flagStroke=Qe.bind(this),this._renderer.vertices=[],this._renderer.collection=[],this.closed=!!e,this.curved=!!s,this.beginning=0,this.ending=1,this.fill="#fff",this.stroke="#000",this.linewidth=1,this.opacity=1,this.className="",this.visible=!0,this.cap="butt",this.join="miter",this.miter=4,this.vertices=t,this.automatic=!r,this.dashes=[],this.dashes.offset=0}static fromObject(t){let e=typeof t.fill=="string"?t.fill:St(t.fill),s=typeof t.stroke=="string"?t.stroke:St(t.stroke),r=new It().copy({...t,fill:e,stroke:s});return"id"in t&&(r.id=t.id),r}copy(t){super.copy.call(this,t),this.vertices=[];for(let e=0;ee.toObject()),S.each(It.Properties,e=>{typeof this[e]<"u"&&(this[e].toObject?t[e]=this[e].toObject():t[e]=this[e])},this),t}noFill(){return this.fill="none",this}noStroke(){return this.stroke="none",this.linewidth=0,this}corner(){let t=this.getBoundingClientRect(!0),e=t.width/2,s=t.height/2,r=t.left+t.width/2,n=t.top+t.height/2;for(let o=0;o0||this.stroke&&!/(transparent|none)/i.test(this.stroke))if(this.matrix.manual){let{scaleX:d,scaleY:_}=Et(e.elements[0],e.elements[3],e.elements[1],e.elements[4],e.elements[2],e.elements[5]);typeof d=="number"&&typeof _=="number"&&(s=Math.max(d,_)*(this.linewidth||0)/2)}else s*=typeof this.scale=="number"?this.scale:Math.max(this.scale.x,this.scale.y);if(r<=0)return{width:0,height:0};for(n=0;n=p){this._closed?(s=nt(tt,R),r=nt(tt-1,R),tt===0&&(s=r,r=tt)):(s=tt,r=Math.min(Math.max(tt-1,0),A)),k=this.vertices[s],F=this.vertices[r],p-=at,this._lengths[tt]!==0?t=p/this._lengths[tt]:t=0;break}at+=this._lengths[tt]}if(k===null||F===null)return null;if(k){if(!F)return k}else return F;m=F.controls&&F.controls.right,b=k.controls&&k.controls.left,a=F.x,d=F.y,h=(m||F).x,_=(m||F).y,l=(b||k).x,u=(b||k).y,f=k.x,y=k.y,m&&F.relative&&(h+=F.x,_+=F.y),b&&k.relative&&(l+=k.x,u+=k.y),o=se(t,a,h,l,f),c=se(t,d,_,u,y);let M=ct(a,h,t),B=ct(d,_,t),P=ct(h,l,t),O=ct(_,u,t),j=ct(l,f,t),N=ct(u,y,t),q=ct(M,P,t),z=ct(B,O,t),it=ct(P,j,t),dt=ct(O,N,t);return S.isObject(e)?(e.x=o,e.y=c,e instanceof T&&(e.controls.left.x=q,e.controls.left.y=z,e.controls.right.x=it,e.controls.right.y=dt,(typeof e.relative!="boolean"||e.relative)&&(e.controls.left.x-=o,e.controls.left.y-=c,e.controls.right.x-=o,e.controls.right.y-=c)),e.t=t,e):(n=new T(o,c,q-o,z-c,it-o,dt-c,this._curved?v.curve:v.line),n.t=t,n)}plot(){if(this.curved)return Xe(this._collection,this.closed),this;for(let t=0;t0&&(n[n.length-1].command=v.line),r=a;return}o=Ge(a,r,t),n=n.concat(o),S.each(o,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line}),h>=e&&(this._closed&&this._automatic?(r=a,o=Ge(a,r,t),n=n.concat(o),S.each(o,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line})):s&&n.push(new T(a.x,a.y)),n[n.length-1].command=s?v.close:v.line),r=a},this),this._automatic=!1,this._curved=!1,this.vertices=n,this}_updateLength(t,e){e||this._update();let s=this.vertices.length,r=s-1,n=!1,o=this.vertices[r],a=0;return typeof this._lengths>"u"&&(this._lengths=[]),S.each(this.vertices,function(h,l){if(l<=0&&!n||h.command===v.move){o=h,this._lengths[l]=0;return}this._lengths[l]=Se(h,o,t),a+=this._lengths[l],l>=r&&n&&(o=this.vertices[(l+1)%s],this._lengths[l+1]=Se(h,o,t),a+=this._lengths[l+1]),o=h},this),this._length=a,this._flagLength=!1,this}_update(){if(this._flagVertices){this._automatic&&this.plot(),this._flagLength&&this._updateLength(void 0,!0);let t=this._collection.length,e=this._closed,s=Math.min(this._beginning,this._ending),r=Math.max(this._beginning,this._ending),n=ae(this,s*this._length),o=ae(this,r*this._length),a=gs(n),h=ms(o),l,f,c,d,_,u;for(this._renderer.vertices.length=0,u=0;uh&&!f?(_=this._renderer.collection[u].copy(this._collection[u]),this.getPointAt(r,_),_.command=this._renderer.collection[u].command,this._renderer.vertices.push(_),f=_,c=this._collection[u-1],c&&c.controls&&(_.relative?_.controls.right.clear():_.controls.right.copy(_),c.relative?this._renderer.collection[u-1].controls.right.copy(c.controls.right).lerp(x.zero,1-_.t):this._renderer.collection[u-1].controls.right.copy(c.controls.right).lerp(c,1-_.t))):u>=a&&u<=h&&(_=this._renderer.collection[u].copy(this._collection[u]),this._renderer.vertices.push(_),u===h&&Ye(this,r)?(f=_,!e&&f.controls&&(f.relative?f.controls.right.clear():f.controls.right.copy(f))):u===a&&Ye(this,s)&&(l=_,l.command=v.move,!e&&l.controls&&(l.relative?l.controls.left.clear():l.controls.left.copy(l))));a>0&&!l&&(u=a-1,_=this._renderer.collection[u].copy(this._collection[u]),this.getPointAt(s,_),_.command=v.move,this._renderer.vertices.unshift(_),d=this._collection[u+1],d&&d.controls&&(_.controls.left.clear(),d.relative?this._renderer.collection[u+1].controls.left.copy(d.controls.left).lerp(x.zero,_.t):(ys.copy(d),this._renderer.collection[u+1].controls.left.copy(d.controls.left).lerp(d,_.t))))}return ot.prototype._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagCap=this._flagJoin=this._flagMiter=this._flagClip=!1,ot.prototype.flagReset.call(this),this}},C=It;w(C,"Properties",["fill","stroke","linewidth","opacity","visible","cap","join","miter","closed","curved","automatic","beginning","ending","dashes"]),w(C,"Utils",{getCurveLength:Se});var Ri={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},cap:{enumerable:!0,get:function(){return this._cap},set:function(i){this._cap=i,this._flagCap=!0}},join:{enumerable:!0,get:function(){return this._join},set:function(i){this._join=i,this._flagJoin=!0}},miter:{enumerable:!0,get:function(){return this._miter},set:function(i){this._miter=i,this._flagMiter=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.unbind(g.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.bind(g.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.unbind(g.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.bind(g.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},closed:{enumerable:!0,get:function(){return this._closed},set:function(i){this._closed=!!i,this._flagVertices=!0}},curved:{enumerable:!0,get:function(){return this._curved},set:function(i){this._curved=!!i,this._flagVertices=!0}},automatic:{enumerable:!0,get:function(){return this._automatic},set:function(i){if(i===this._automatic)return;this._automatic=!!i;let t=this._automatic?"ignore":"listen";S.each(this.vertices,function(e){e[t]()})}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(g.Types.insert,t).unbind(g.Types.remove,e),i instanceof ut?this._collection=i:this._collection=new ut(i||[]),this._collection.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._collection)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}},clip:{enumerable:!0,get:function(){return this._clip},set:function(i){this._clip=i,this._flagClip=!0}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};function Ke(){this._flagVertices=!0,this._flagLength=!0,this.parent&&(this.parent._flagLength=!0)}function $e(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Je(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Ze(){this._flagFill=!0}function Qe(){this._flagStroke=!0}var fe=class extends C{constructor(t,e,s,r){let n=[new T,new T,new T,new T];super(n,!0,!1,!0),this._renderer.type="rectangle";for(let o in Ai)Object.defineProperty(this,o,Ai[o]);this.width=typeof s=="number"?s:1,this.height=typeof r=="number"?r:1,this.origin=new x,typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e),this._update()}static fromObject(t){let e=new fe().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e0&&(S.isNaN(this._lastFrame)&&(this._lastFrame=a-1),o=S.performance.now()-this._startTime,d=this._lastFrame+1,h=1e3*(d-this._firstFrame)/this._frameRate,this._loop?o=o%h:o=Math.min(o,h),l=ct(this._firstFrame,d,o/h),l=Math.floor(l),l!==this._index&&(this._index=l,l>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()));let _=this._index%e,u=Math.floor(this._index/e),y=-r*_+(f-r)/2,b=-n*u+(c-n)/2;y!==t.offset.x&&(t.offset.x=y),b!==t.offset.y&&(t.offset.y=b)}return super._update.call(this),this}flagReset(){return this._flagTexture=this._flagColumns=this._flagRows=this._flagFrameRate=!1,super.flagReset.call(this),this}},jt=ce;w(jt,"Properties",["texture","columns","rows","frameRate","index","firstFrame","lastFrame","loop"]);var Fi={texture:{enumerable:!0,get:function(){return this._texture},set:function(i){this._texture=i,this._flagTexture=!0}},columns:{enumerable:!0,get:function(){return this._columns},set:function(i){this._columns=i,this._flagColumns=!0}},rows:{enumerable:!0,get:function(){return this._rows},set:function(i){this._rows=i,this._flagRows=!0}},frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}},firstFrame:{enumerable:!0,get:function(){return this._firstFrame},set:function(i){this._firstFrame=i}},lastFrame:{enumerable:!0,get:function(){return this._lastFrame},set:function(i){this._lastFrame=i}},loop:{enumerable:!0,get:function(){return this._loop},set:function(i){this._loop=!!i}}};var be=class extends ut{#t={};get ids(){return this.#t}constructor(t){t=Array.isArray(t)?t:Array.prototype.slice.call(arguments),super(t),this.attach(t),this.on(g.Types.insert,this.attach),this.on(g.Types.remove,this.detach)}attach(t){for(let e=0;e0,a=this.vertices,h=o?a.length/2:a.length,l,f=0,c,d,_,u,y,b,m,p,R;for(n?h--:o||(h-=2),c=0,d=h-1;c2&&(t-=1);let e=4/3*Math.tan(Math.PI/(t*2)),s=this._radius,r=s*e;for(let n=0;n2&&(t-=1);let e=4/3*Math.tan(Math.PI/(this.vertices.length*2)),s=this._width/2,r=this._height/2;for(let n=0;ne.toObject()),S.each(Bt.Properties,function(e){typeof this[e]<"u"&&(this[e].toObject?t[e]=this[e].toObject():t[e]=this[e])},this),t}noFill=C.prototype.noFill;noStroke=C.prototype.noStroke;corner=C.prototype.corner;center=C.prototype.center;getBoundingClientRect=C.prototype.getBoundingClientRect;subdivide(t){this._update();let e=[];for(let s=0;s=n&&l<=o&&(h=this._collection[l],this._renderer.collection.push(h),this._renderer.vertices[a*2+0]=h.x,this._renderer.vertices[a*2+1]=h.y,a++)}return super._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagSize=this._flagSizeAttenuation=!1,super.flagReset.call(this),this}},Ht=Bt;w(Ht,"Properties",["fill","stroke","linewidth","opacity","visible","size","sizeAttenuation","beginning","ending","dashes"]);var Mi={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},size:{enumerable:!0,get:function(){return this._size},set:function(i){this._size=i,this._flagSize=!0}},sizeAttenuation:{enumerable:!0,get:function(){return this._sizeAttenuation},set:function(i){this._sizeAttenuation=i,this._flagSizeAttenuation=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.unbind(g.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof G||this._fill instanceof W||this._fill instanceof X||this._fill instanceof V)&&this._fill.bind(g.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.unbind(g.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof G||this._stroke instanceof W||this._stroke instanceof X||this._stroke instanceof V)&&this._stroke.bind(g.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(g.Types.insert,t).unbind(g.Types.remove,e),i instanceof ut?this._collection=i:this._collection=new ut(i||[]),this._collection.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._collection)}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};var ws=Math.cos,vs=Math.sin,Yt=class extends C{_flagWidth=!1;_flagHeight=!1;_flagSides=!1;_radius=0;_width=0;_height=0;_sides=0;constructor(t,e,s,r){r=Math.max(r||0,3),super(),this._renderer.type="polygon";for(let n in Oi)Object.defineProperty(this,n,Oi[n]);this.closed=!0,this.automatic=!1,typeof s=="number"&&(this.radius=s),typeof r=="number"&&(this.sides=r),this._update(),typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e)}static fromObject(t){let e=new Yt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;et&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new T(a,h)):this.vertices[r].set(a,h),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagWidth=this._flagHeight=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=new Yt(0,0,0,this.sides);e.translation.copy(this.translation),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,e.width=this.width,e.height=this.height,this.matrix.manual&&e.matrix.copy(this.matrix);for(let s=0;s"u"&&typeof s=="number"&&typeof r=="number"&&(n=Math.floor(Math.min(s,r)/12));let o=[];for(let a=0;a<10;a++)o.push(new T(0,0,0,0,0,0,a===0?v.move:v.curve));super(o),this._renderer.type="rounded-rectangle";for(let a in Ci)Object.defineProperty(this,a,Ci[a]);this.closed=!0,this.automatic=!1,this._renderer.flagRadius=ks.bind(this),typeof s=="number"&&(this.width=s),typeof r=="number"&&(this.height=r),typeof n=="number"&&(this.radius=n),this._update(),typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e)}static fromObject(t){let e=new qt().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;et&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new T(h,l)):this.vertices[r].set(h,l),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagInnerRadius=this._flagOuterRadius=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=this.innerRadius,s=this.outerRadius,r=this.sides,n=new Kt(0,0,e,s,r);n.translation.copy(this.translation),n.rotation=this.rotation,n.scale=this.scale,n.skewX=this.skewX,n.skewY=this.skewY,this.matrix.manual&&n.matrix.copy(this.matrix);for(let o=0;o{t.children[s]=e.toObject()},this),t}corner(){let t=this.getBoundingClientRect(!0);for(let e=0;e=0&&e.push(r),r.children)for(let n=0;n=0&&this.children.splice(r,1),this.children.push(s)}return this}remove(t){let e=arguments.length,s=this.parent;if(e<=0&&s)return s.remove(this),this;t instanceof Array?t=t.slice():t=Array.prototype.slice.call(arguments);for(let r=0;r=0&&this.children.splice(o,1)}return this}getBoundingClientRect(t){let e,s,r,n,o,a;this._update(!0);let h=1/0,l=-1/0,f=1/0,c=-1/0,d=/texture|gradient/i;s=t?this.matrix:this.worldMatrix;for(let _=0;_a+e?(s.beginning=1,s.ending=1):la&&ha&&l0&&e(this._children)),this._children=new be(i),this._children.bind(g.Types.insert,t),this._children.bind(g.Types.remove,e),this._children.bind(g.Types.order,s),i.length>0&&t(i)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}}};function Vi(i,t){let e=i.parent,s;if(e===t){r();return}if(e&&e.children.ids[i.id]&&(s=Array.prototype.indexOf.call(e.children,i),e.children.splice(s,1),n()),t){r();return}n(),e._flagAdditions&&e.additions.length===0&&(e._flagAdditions=!1),e._flagSubtractions&&e.subtractions.length===0&&(e._flagSubtractions=!1),delete i.parent;function r(){t.subtractions.length>0&&(s=Array.prototype.indexOf.call(t.subtractions,i),s>=0&&t.subtractions.splice(s,1)),t.additions.length>0&&(s=Array.prototype.indexOf.call(t.additions,i),s>=0&&t.additions.splice(s,1)),i.parent=t,t.additions.push(i),t._flagAdditions=!0}function n(){s=Array.prototype.indexOf.call(e.additions,i),s>=0&&e.additions.splice(s,1),s=Array.prototype.indexOf.call(e.subtractions,i),s<0&&(e.subtractions.push(i),e._flagSubtractions=!0)}}var te=class extends C{constructor(t,e,s,r){let n=[new T(t,e),new T(s,r)];super(n);for(let o in zi)Object.defineProperty(this,o,zi[o]);this.vertices[0].command=v.move,this.vertices[1].command=v.line,this.automatic=!1}},zi={left:{enumerable:!0,get:function(){return this.vertices[0]},set:function(i){if(S.isObject(i))this.vertices.splice(0,1,i);else{let t=new et("Two.Line.x argument is not an object.");console.warn(t.name,t.message)}}},right:{enumerable:!0,get:function(){return this.vertices[1]},set:function(i){if(S.isObject(i))this.vertices.splice(1,1,i);else{let t=new et("Two.Line.y argument is not an object.");console.warn(t.name,t.message)}}}};var Pt={path:/[+-]?(?:\d*\.\d+|\d+)(?:[eE][+-]\d+)?/g,cssBackgroundImage:/url\(['"]?#([\w\d-_]*)['"]?\)/i,unitSuffix:/[a-zA-Z%]*/i},Es={start:"left",middle:"center",end:"right"},ji=["id","class","transform","xmlns","viewBox"],Ts=["x","y","width","height","href","xlink:href"];function Ms(i){return Es[i]}function Os(i){let t=i.getAttribute("dominant-baseline"),e=i.getAttribute("alignment-baseline");return t||e}function xe(i){return i.replace(/svg:/gi,"").toLowerCase()}function Ui(i,t){if(t.x+=i.translateX,t.y+=i.translateY,t.x*=i.scaleX,t.y*=i.scaleY,i.rotation!==0){let e=t.length();t.x=e*Math.cos(i.rotation),t.y=e*Math.sin(i.rotation)}}function Cs(i,t){t||(t={});let e=i.split(";");for(let s=0;s"u"||typeof o>"u"||(t[n]=o.replace(/\s/,""))}return t}function Ps(i){let t={},e=Ls(i),s=Math.max(e.length,i.style.length);for(let r=0;r=0&&t.splice(r,1)}return t}function Is(i,t){let e=t.split(/[\s,]/),s=-parseFloat(e[0]),r=-parseFloat(e[1]),n=parseFloat(e[2]),o=parseFloat(e[3]);if(s&&r)for(let c=0;c"u"&&/none/i.test(s.display))||typeof s.visibility>"u"&&/hidden/i.test(s.visibility);for(h in s)switch(l=s[h],h){case"gradientTransform":if(/none/i.test(l)||(a=i.gradientTransform&&i.gradientTransform.baseVal&&i.gradientTransform.baseVal.length>0?i.gradientTransform.baseVal[0].matrix:i.getCTM?i.getCTM():null,a===null))break;switch(d=Et(a),t._renderer.type){case"linear-gradient":Ui(d,t.left),Ui(d,t.right);break;case"radial-gradient":t.center.x+=d.translateX,t.center.y+=d.translateY,t.focal.x+=d.translateX,t.focal.y+=d.translateY,t.radius*=Math.max(d.scaleX,d.scaleY);break}break;case"transform":if(/none/i.test(l)||(a=i.transform&&i.transform.baseVal&&i.transform.baseVal.length>0?i.transform.baseVal[0].matrix:i.getCTM?i.getCTM():null,a===null))break;Q.AutoCalculateImportedMatrices?(d=Et(a),t.translation.set(d.translateX,d.translateY),t.rotation=Math.PI*(d.rotation/180),t.scale=new x(d.scaleX,d.scaleY),_=parseFloat((s.x+"").replace("px")),u=parseFloat((s.y+"").replace("px")),_&&(t.translation.x=_),u&&(t.translation.y=u)):(a=i.getCTM(),t._matrix.manual=!0,t._matrix.set(a.a,a.b,a.c,a.d,a.e,a.f));break;case"visible":if(t instanceof K){t._visible=l;break}t.visible=l;break;case"stroke-linecap":if(t instanceof K){t._cap=l;break}t.cap=l;break;case"stroke-linejoin":if(t instanceof K){t._join=l;break}t.join=l;break;case"stroke-miterlimit":if(t instanceof K){t._miter=l;break}t.miter=l;break;case"stroke-width":if(t instanceof K){t._linewidth=parseFloat(l);break}t.linewidth=parseFloat(l);break;case"opacity":case"stroke-opacity":case"fill-opacity":if(t instanceof K){t._opacity=parseFloat(l);break}t.opacity=parseFloat(l);break;case"clip-path":if(Pt.cssBackgroundImage.test(l)&&(y=l.replace(Pt.cssBackgroundImage,"$1"),$.defs.current&&$.defs.current.contains(y)&&(m=$.defs.current.get(y),m&&m.childNodes.length>0)))switch(m=m.childNodes[0],p=xe(m.nodeName),t.mask=$[p].call(this,m,{}),t._renderer.type){case"text":case"path":t.position.add(t.mask.position),t.mask.position.clear();break}break;case"fill":case"stroke":f=(t instanceof K?"_":"")+h,Pt.cssBackgroundImage.test(l)?(y=l.replace(Pt.cssBackgroundImage,"$1"),$.defs.current&&$.defs.current.contains(y)?(m=$.defs.current.get(y),m.object||(p=xe(m.nodeName),m.object=$[p].call(this,m,{})),m=m.object):(b=Ns(this),m=b.getById(y)),t[f]=m):t[f]=l;break;case"id":t.id=l;break;case"class":case"className":t.classList=l.split(" "),t._flagClassName=!0;break;case"x":case"y":if(R=t instanceof G,A=t instanceof W,k=t instanceof X,R||A||k)break;l.match("[a-z%]$")&&!l.endsWith("px")&&(F=new et("only pixel values are supported with the "+h+" attribute."),console.warn(F.name,F.message)),t.translation[h]=parseFloat(l);break;case"font-family":t instanceof ft&&(t.family=l);break;case"font-size":t instanceof ft&&(t.size=l);break;case"font-weight":t instanceof ft&&(t.weight=l);break;case"font-style":t instanceof ft&&(t.style=l);break;case"text-decoration":t instanceof ft&&(t.decoration=l);break;case"line-height":t instanceof ft&&(t.leading=l);break}return Object.keys(i.dataset).length&&(t.dataset=i.dataset),s}function Bs(i,t){for(let e=0,s=i.childNodes.length;e with no href."),console.warn(e.name,e.message),null;let r=s.slice(1);if(!$.defs.current.contains(r))return e=new et("unable to find element for reference "+s+"."),console.warn(e.name,e.message),null;let o=$.defs.current.get(r).cloneNode(!0);for(let h=0;h1&&(m=1);break;case"m":case"l":case"t":u.length>2&&(m=2);break;case"s":case"q":u.length>4&&(m=4);break;case"c":u.length>6&&(m=6);break;case"a":u.length>7&&(m=7);break}if(m){for(p=0,R=u.length,k=0;p0)switch(y){case"m":A="l";break;case"M":A="L";break}F.push(A+u.slice(p,p+m).join(" ")),k++}f=Array.prototype.concat.apply(f,F)}else f.push(d)}),S.each(f,function(d,_){let u,y,b,m=d[0],p=m.toLowerCase();l=d.slice(1).trim().match(Pt.path),n=m===p;let R,A,k,F,M,B,P,O,j,N,q,z,it,dt,tt,xt,at;switch(p){case"z":if(_>=c)r=!0;else{y=a.x,b=a.y,u=new T(y,b,void 0,void 0,void 0,void 0,v.close);for(let Lt=s.length-1;Lt>=0;Lt--){let Nt=s[Lt];if(/m/i.test(Nt.command)){a=Nt;break}}}break;case"m":case"l":h=void 0,y=parseFloat(l[0]),b=parseFloat(l[1]),u=new T(y,b,void 0,void 0,void 0,void 0,/m/i.test(p)?v.move:v.line),n&&u.addSelf(a),a=u;break;case"h":case"v":N=/h/i.test(p)?"x":"y",q=/x/i.test(N)?"y":"x",u=new T(void 0,void 0,void 0,void 0,void 0,void 0,v.line),u[N]=parseFloat(l[0]),u[q]=a[q],n&&(u[N]+=a[N]),a=u;break;case"c":case"s":R=a.x,A=a.y,h||(h=new x),/c/i.test(p)?(k=parseFloat(l[0]),F=parseFloat(l[1]),M=parseFloat(l[2]),B=parseFloat(l[3]),P=parseFloat(l[4]),O=parseFloat(l[5])):(j=Ae(a,h,n),k=j.x,F=j.y,M=parseFloat(l[0]),B=parseFloat(l[1]),P=parseFloat(l[2]),O=parseFloat(l[3])),n&&(k+=R,F+=A,M+=R,B+=A,P+=R,O+=A),a.controls.right.set(k-a.x,F-a.y),u=new T(P,O,M-P,B-O,void 0,void 0,v.curve),a=u,h=u.controls.left;break;case"t":case"q":R=a.x,A=a.y,h||(h=new x),/q/i.test(p)?(k=parseFloat(l[0]),F=parseFloat(l[1]),M=parseFloat(l[0]),B=parseFloat(l[1]),P=parseFloat(l[2]),O=parseFloat(l[3])):(j=Ae(a,h,n),k=j.x,F=j.y,M=j.x,B=j.y,P=parseFloat(l[0]),O=parseFloat(l[1])),n&&(k+=R,F+=A,M+=R,B+=A,P+=R,O+=A),a.controls.right.set((k-a.x)*.33,(F-a.y)*.33),u=new T(P,O,M-P,B-O,void 0,void 0,v.curve),a=u,h=u.controls.left;break;case"a":R=a.x,A=a.y,it=parseFloat(l[0]),dt=parseFloat(l[1]),tt=parseFloat(l[2]),xt=parseFloat(l[3]),at=parseFloat(l[4]),P=parseFloat(l[5]),O=parseFloat(l[6]),n&&(P+=R,O+=A),z=new T(P,O),z.command=v.arc,z.rx=it,z.ry=dt,z.xAxisRotation=tt,z.largeArcFlag=xt,z.sweepFlag=at,u=z,a=z,h=void 0;break}u&&(Array.isArray(u)?s=s.concat(u):s.push(u))})}e=new C(s,r,void 0,!0),e.stroke="none",e.fill="black";let o=e.getBoundingClientRect(!0);return o.centroid={x:o.left+o.width/2,y:o.top+o.height/2},S.each(e.vertices,function(a){a.subSelf(o.centroid)}),Ft.call(this,i,e,t),e.translation.addSelf(o.centroid),e},circle:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("r")),n=new Mt(0,0,r);return n.stroke="none",n.fill="black",Ft.call(this,i,n,t),n.translation.x=e,n.translation.y=s,n},ellipse:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("rx")),n=parseFloat(i.getAttribute("ry")),o=new Ot(0,0,r,n);return o.stroke="none",o.fill="black",Ft.call(this,i,o,t),o.translation.x=e,o.translation.y=s,o},rect:function(i,t){let e=parseFloat(i.getAttribute("rx")),s=parseFloat(i.getAttribute("ry"));if(!S.isNaN(e)||!S.isNaN(s))return $["rounded-rect"](i);let r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),o=r/2,a=n/2,h=new pt(0,0,r,n);return h.stroke="none",h.fill="black",Ft.call(this,i,h,t),h.translation.x+=o,h.translation.y+=a,h},"rounded-rect":function(i,t){let e=parseFloat(i.getAttribute("rx"))||0,s=parseFloat(i.getAttribute("ry"))||0,r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),o=r/2,a=n/2,h=new x(e,s),l=new Ct(0,0,r,n,h);return l.stroke="none",l.fill="black",Ft.call(this,i,l,t),l.translation.x+=o,l.translation.y+=a,l},line:function(i,t){let e=parseFloat(i.getAttribute("x1")),s=parseFloat(i.getAttribute("y1")),r=parseFloat(i.getAttribute("x2")),n=parseFloat(i.getAttribute("y2")),o=new te(e,s,r,n).noFill();return Ft.call(this,i,o,t),o},lineargradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("x1")||0),n=parseFloat(i.getAttribute("y1")||0),o=parseFloat(i.getAttribute("x2")||0),a=parseFloat(i.getAttribute("y2")||0),h=(o+r)/2,l=(a+n)/2;/userSpaceOnUse/i.test(e)&&(r-=h,n-=l,o-=h,a-=l);let f=[];for(let d=0;d1?p[1]:void 0),b===null?(p=m?m.match(/stop-opacity:\s?([0-9.-]*)/):!1,b=p&&p.length>1?parseFloat(p[1]):1):b=parseFloat(b),f.push(new ht(u,y,b))}let c=new W(r,n,o,a,f);return c.spread=s,c.units=e,Ft.call(this,i,c,t),c},radialgradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("cx"))||0,n=parseFloat(i.getAttribute("cy"))||0,o=parseFloat(i.getAttribute("r")),a=parseFloat(i.getAttribute("fx")),h=parseFloat(i.getAttribute("fy"));S.isNaN(a)&&(a=r),S.isNaN(h)&&(h=n);let l=Math.abs(r+a)/2,f=Math.abs(n+h)/2;/userSpaceOnUse/i.test(e)&&(r-=l,n-=f,a-=l,h-=f);let c=[];for(let _=0;_1?R[1]:void 0),m===null?(R=p?p.match(/stop-opacity:\s?([0-9.-]*)/):!1,m=R&&R.length>1?parseFloat(R[1]):1):m=parseFloat(m),c.push(new ht(y,b,m))}let d=new X(r,n,o,c,a,h);return d.spread=s,d.units=e,Ft.call(this,i,d,t),d},text:function(i,t){let e=Ms(i.getAttribute("text-anchor"))||"left",s=Os(i)||"baseline",r=i.textContent,n=new ft(r);return Ft.call(this,i,n,t),n.alignment=e,n.baseline=s,n},clippath:function(i,t){return $.defs.current&&!$.defs.current.contains(i.id)&&$.defs.current.add(i.id,i),null},image:function(i,t){let e,s=i.getAttribute("href")||i.getAttribute("xlink:href");if(!s)return e=new et("encountered with no href."),console.warn(e.name,e.message),null;let r=parseFloat(i.getAttribute("x"))||0,n=parseFloat(i.getAttribute("y"))||0,o=parseFloat(i.getAttribute("width")),a=parseFloat(i.getAttribute("height")),h=new jt(s,r,n);return S.isNaN(o)||(h.width=o),S.isNaN(a)||(h.height=a),Ft.call(this,i,h,t),h}};function ni(i,t){let e=new XMLHttpRequest;return e.open("GET",i),e.onreadystatechange=function(){e.readyState===4&&e.status===200&&t(e.responseText)},e.send(),e}var ee=class extends pt{_flagTextures=!1;_flagFrameRate=!1;_flagIndex=!1;_amount=1;_duration=0;_index=0;_startTime=0;_playing=!1;_firstFrame=0;_lastFrame=0;_loop=!0;_textures=null;_frameRate=0;_origin=null;constructor(t,e,s,r){super(e,s,0,0);for(let n in Di)Object.defineProperty(this,n,Di[n]);this._renderer.flagTextures=Vs.bind(this),this._renderer.bindTextures=zs.bind(this),this._renderer.unbindTextures=js.bind(this),this.noStroke(),this.noFill(),Array.isArray(t)?this.textures=t.map(Wi.bind(this)):this.textures=[Wi(t)],this.origin=new x,this._update(),typeof r=="number"?this.frameRate=r:this.frameRate=ee.DefaultFrameRate,this.index=0}static fromObject(t){let e=new ee().copy(t);return"id"in t&&(e.id=t.id),e}copy(t){super.copy.call(this,t);for(let e=0;e0?(n=this._amount,S.isNaN(this._lastFrame)&&(this._lastFrame=n-1),r=S.performance.now()-this._startTime,l=this._lastFrame+1,o=1e3*(l-this._firstFrame)/this._frameRate,this._loop?r=r%o:r=Math.min(r,o),h=ct(this._firstFrame,l,r/o),h=Math.floor(h),h!==this._index&&(this._index=h,a=t[this._index],a.loaded&&(e=a.image.width,s=a.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s),this.fill=a,h>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()))):(this._flagIndex||!(this.fill instanceof V))&&(a=t[this._index],a.loaded&&(e=a.image.width,s=a.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s)),this.fill=a)),super._update.call(this),this}flagReset(){return this._flagTextures=this._flagFrameRate=!1,super.flagReset.call(this),this}},ie=ee;w(ie,"Properties",["textures","frameRate","index","firstFrame","lastFrame","loop"]),w(ie,"DefaultFrameRate",30);var Di={frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}},textures:{enumerable:!0,get:function(){return this._textures},set:function(i){let t=this._renderer.bindTextures,e=this._renderer.unbindTextures;this._textures&&this._textures.unbind(g.Types.insert,t).unbind(g.Types.remove,e),this._textures=new ut((i||[]).slice(0)),this._textures.bind(g.Types.insert,t).bind(g.Types.remove,e),t(this._textures)}},firstFrame:{enumerable:!0,get:function(){return this._firstFrame},set:function(i){this._firstFrame=i}},lastFrame:{enumerable:!0,get:function(){return this._lastFrame},set:function(i){this._lastFrame=i}},loop:{enumerable:!0,get:function(){return this._loop},set:function(i){this._loop=!!i}}};function Vs(){this._flagTextures=!0}function zs(i){let t=i.length;for(;t--;)i[t].bind(g.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function js(i){let t=i.length;for(;t--;)i[t].unbind(g.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function Wi(i){if(i instanceof V)return i;if(typeof i=="string")return new V(i)}var oi=[],ai=Math.max,Us=Math.min,Xi=Math.abs,Oe=Math.sin,Ce=Math.cos,Ds=Math.acos,Le=Math.sqrt,H={isHidden:/(undefined|none|transparent)/i,alignments:{left:"start",middle:"center",right:"end"},baselines:{top:"top",middle:"middle",bottom:"bottom",baseline:"alphabetic"},getRendererType:function(i){return i in H?i:"path"},group:{renderChild:function(i){let t=H.getRendererType(i._renderer.type);H[t].render.call(i,this.ctx,!0,this.clip)},render:function(i){if(!this._visible)return this;this._update();let t=this._matrix.elements,e=this.parent;this._renderer.opacity=this._opacity*(e&&e._renderer?e._renderer.opacity:1);let s=this._mask,r=Pe(t),n=!r||!!s;if(this._renderer.context||(this._renderer.context={}),this._renderer.context.ctx=i,n&&(i.save(),r||i.transform(t[0],t[3],t[1],t[4],t[2],t[5])),s){let o=H.getRendererType(s._renderer.type);H[o].render.call(s,i,!0)}if(this._opacity>0&&this._scale!==0)for(let o=0;o0&&(i.lineDashOffset=at.offset||0,i.setLineDash(at)),i.beginPath();let Nt,de,_e,pe,ge,me,_t;for(let D=0;D=y&&d&&(R=A,j=p.controls&&p.controls.right||x.zero,N=R.controls&&R.controls.left||x.zero,p._relative?(M=j.x+p.x,B=j.y+p.y):(M=j.x,B=j.y),R._relative?(k=N.x+R.x,F=N.y+R.y):(k=N.x,F=N.y),q=R.x,z=R.y,i.bezierCurveTo(M,B,k,F,q,z));break;case v.line:i.lineTo(q,z);break;case v.move:A=p,i.moveTo(q,z);break}return d&&i.closePath(),!dt&&!e&&(H.isHidden.test(o)||(xt=o._renderer&&o._renderer.offset,xt&&(i.save(),i.translate(-o._renderer.offset.x,-o._renderer.offset.y),i.scale(o._renderer.scale.x,o._renderer.scale.y)),i.fill(),xt&&i.restore()),H.isHidden.test(r)||(xt=r._renderer&&r._renderer.offset,xt&&(i.save(),i.translate(-r._renderer.offset.x,-r._renderer.offset.y),i.scale(r._renderer.scale.x,r._renderer.scale.y),i.lineWidth=n/r._renderer.scale.x),i.stroke(),xt&&i.restore())),tt||i.restore(),dt&&!e&&i.clip(),at&&at.length>0&&i.setLineDash(oi),this.flagReset()}},points:{render:function(i,t,e){let s,r,n,o,a,h,l,f,c,d,_,u,y,b,m,p;if(p=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,a=this._opacity*(p||1),h=this._visible,!t&&(!h||a===0))return this;if(this._update(),s=this._matrix.elements,r=this._stroke,n=this._linewidth,o=this._fill,f=this._renderer.collection,c=f.length,y=Pe(s),m=this.dashes,l=this._size,y||(i.save(),i.transform(s[0],s[3],s[1],s[4],s[2],s[5])),o)if(typeof o=="string")i.fillStyle=o;else{let k=H.getRendererType(o._renderer.type);H[k].render.call(o,i,this),i.fillStyle=o._renderer.effect}if(r){if(typeof r=="string")i.strokeStyle=r;else{let k=H.getRendererType(r._renderer.type);H[k].render.call(r,i,this),i.strokeStyle=r._renderer.effect}n&&(i.lineWidth=n)}typeof a=="number"&&(i.globalAlpha=a),m&&m.length>0&&(i.lineDashOffset=m.offset||0,i.setLineDash(m)),i.beginPath();let R=l*.5,A;this._sizeAttenuation||(A=this.worldMatrix.elements,A=Et(A[0],A[3],A[1],A[4],A[2],A[5]),R/=Math.max(A.scaleX,A.scaleY));for(let k=0;k0&&i.setLineDash(oi),this.flagReset()}},text:{render:function(i,t,e){let s=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,r=this._opacity*s,n=this._visible,o=this._mask,a=this._clip;if(!t&&(!n||a||r===0))return this;this._update();let h=this._matrix.elements,l=this._stroke,f=this._linewidth,c=this._fill,d=this._decoration,_=this._direction,u=Pe(h),y=c._renderer&&c._renderer.offset&&l._renderer&&l._renderer.offset,b=this.dashes,m=H.alignments[this._alignment]||this._alignment,p=H.baselines[this._baseline]||this._baseline,R,A,k,F,M,B,P,O,j,N,q;if(u||(i.save(),i.transform(h[0],h[3],h[1],h[4],h[2],h[5])),o){let z=H.getRendererType(o._renderer.type);H[z].render.call(o,i,!0)}if(y||(i.font=[this._style,this._weight,this._size+"px/"+this._leading+"px",this._family].join(" ")),i.textAlign=m,i.textBaseline=p,i.direction=_,c)if(typeof c=="string")i.fillStyle=c;else{let z=H.getRendererType(c._renderer.type);H[z].render.call(c,i,this),i.fillStyle=c._renderer.effect}if(l){if(typeof l=="string")i.strokeStyle=l;else{let z=H.getRendererType(l._renderer.type);H[z].render.call(l,i,this),i.strokeStyle=l._renderer.effect}f&&(i.lineWidth=f)}if(typeof r=="number"&&(i.globalAlpha=r),b&&b.length>0&&(i.lineDashOffset=b.offset||0,i.setLineDash(b)),!a&&!e&&(H.isHidden.test(c)||(c._renderer&&c._renderer.offset?(B=c._renderer.scale.x,P=c._renderer.scale.y,i.save(),i.translate(-c._renderer.offset.x,-c._renderer.offset.y),i.scale(B,P),R=this._size/c._renderer.scale.y,A=this._leading/c._renderer.scale.y,i.font=[this._style,this._weight,R+"px/",A+"px",this._family].join(" "),k=c._renderer.offset.x/c._renderer.scale.x,F=c._renderer.offset.y/c._renderer.scale.y,i.fillText(this.value,k,F),i.restore()):i.fillText(this.value,0,0)),H.isHidden.test(l)||(l._renderer&&l._renderer.offset?(B=l._renderer.scale.x,P=l._renderer.scale.y,i.save(),i.translate(-l._renderer.offset.x,-l._renderer.offset.y),i.scale(B,P),R=this._size/l._renderer.scale.y,A=this._leading/l._renderer.scale.y,i.font=[this._style,this._weight,R+"px/",A+"px",this._family].join(" "),k=l._renderer.offset.x/l._renderer.scale.x,F=l._renderer.offset.y/l._renderer.scale.y,M=f/l._renderer.scale.x,i.lineWidth=M,i.strokeText(this.value,k,F),i.restore()):i.strokeText(this.value,0,0))),/(underline|strikethrough)/i.test(d)){let z=i.measureText(this.value),it=1;switch(d){case"underline":j=z.actualBoundingBoxDescent,q=z.actualBoundingBoxDescent;break;case"strikethrough":j=0,q=0,it=.5;break}switch(p){case"top":j+=this._size*it,q+=this._size*it;break;case"baseline":case"bottom":j-=this._size*it,q-=this._size*it;break}switch(m){case"left":case"start":O=0,N=z.width;break;case"right":case"end":O=-z.width,N=0;break;default:O=-z.width/2,N=z.width/2}i.lineWidth=Math.max(Math.floor(this._size/15),1),i.strokeStyle=i.fillStyle,i.beginPath(),i.moveTo(O,j),i.lineTo(N,q),i.stroke()}return u||i.restore(),a&&!e&&i.clip(),b&&b.length>0&&i.setLineDash(oi),this.flagReset()}},"linear-gradient":{render:function(i,t){if(!!t){if(this._update(),!this._renderer.effect||this._flagEndPoints||this._flagStops||this._flagUnits){let e,s=this.left._x,r=this.left._y,n=this.right._x,o=this.right._y;/objectBoundingBox/i.test(this._units)&&(e=t.getBoundingClientRect(!0),s=(s-.5)*e.width,r=(r-.5)*e.height,n=(n-.5)*e.width,o=(o-.5)*e.height),this._renderer.effect=i.createLinearGradient(s,r,n,o);for(let a=0;a1){let z=Le(p);s=z*s,r=z*r,b=s*s,m=r*r}let R=b*y+m*u,A=(b*m-R)/R,k=Le(ai(0,A));n===o&&(k=-k);let F=k*s*_/r,M=-k*r*d/s,B=Ce(a)*F-Oe(a)*M+(t+h)/2,P=Oe(a)*F+Ce(a)*M+(e+l)/2,O=Hi(1,0,(d-F)/s,(_-M)/r),j=Hi((d-F)/s,(_-M)/r,(-d-F)/s,(-_-M)/r)%J,N=O+j;Ws(i,B,P,s,r,O,N,o===0,a)}},rt=class extends g{constructor(t){super();let e=t.smoothing!==!1;this.domElement=t.domElement||document.createElement("canvas"),this.ctx=this.domElement.getContext("2d"),this.overdraw=t.overdraw||!1,typeof this.ctx.imageSmoothingEnabled<"u"&&(this.ctx.imageSmoothingEnabled=e),this.scene=new K,this.scene.parent=this}setSize(t,e,s){return this.width=t,this.height=e,this.ratio=typeof s>"u"?ne(this.ctx):s,this.domElement.width=t*this.ratio,this.domElement.height=e*this.ratio,this.domElement.style&&S.extend(this.domElement.style,{width:t+"px",height:e+"px"}),this.trigger(g.Types.resize,t,e,s)}render(){let t=this.ratio===1;return t||(this.ctx.save(),this.ctx.scale(this.ratio,this.ratio)),this.overdraw||this.ctx.clearRect(0,0,this.width,this.height),H.group.render.call(this.scene,this.ctx),t||this.ctx.restore(),this}};w(rt,"Utils",H);function Ws(i,t,e,s,r,n,o,a,h){let l=o-n,f=Zt.Tolerance.epsilon,c=Math.abs(l)0&&E.setAttributes(s,t),s},setAttributes:function(i,t){let e=Object.keys(t);for(let s=0;s=s&&t&&(a.command===v.curve&&(c=r,p=a.controls&&a.controls.right||a,R=c.controls&&c.controls.left||c,a.relative?(d=U(p.x+a.x),_=U(p.y+a.y)):(d=U(p.x),_=U(p.y)),c.relative?(u=U(R.x+c.x),y=U(R.y+c.y)):(u=U(R.x),y=U(R.y)),P=U(c.x),O=U(c.y),f+=" C "+d+" "+_+" "+u+" "+y+" "+P+" "+O),a.command!==v.close&&(f+=" Z")),n+=f+" "}return n},pointsToString:function(i,t){let e="",s=t*.5;for(let r=0;r"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}if(this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t["stroke-opacity"]=this._opacity,t["fill-opacity"]=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this._flagCap&&(t["stroke-linecap"]=this._cap),this._flagJoin&&(t["stroke-linejoin"]=this._join),this._flagMiter&&(t["stroke-miterlimit"]=this._miter),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("path",t),i.appendChild(this._renderer.elem)),this._flagClip){let s=E.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}if(this._flagMask)if(this._mask){let s=E.getRendererType(this._mask._renderer.type);E[s].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")}else this._renderer.elem.removeAttribute("clip-path");return this.flagReset()}},points:{render:function(i){if(this._opacity===0&&!this._flagOpacity)return this;this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagVertices||this._flagSize||this._flagSizeAttenuation){let s=this._size;if(!this._sizeAttenuation){let n=this.worldMatrix.elements,o=Et(n[0],n[3],n[1],n[4],n[2],n[5]);s/=Math.max(o.scaleX,o.scaleY)}let r=E.pointsToString(this._renderer.collection,s);t.d=r}if(this._fill&&this._fill._renderer){this._renderer.hasFillEffect=!0,this._fill._update();let s=E.getRendererType(this._fill._renderer.type);E[s].render.call(this._fill,i,!0)}if(this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill,this._renderer.hasFillEffect&&typeof this._fill.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}return this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t["stroke-opacity"]=this._opacity,t["fill-opacity"]=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("path",t),i.appendChild(this._renderer.elem)),this.flagReset()}},text:{render:function(i){this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagFamily&&(t["font-family"]=this._family),this._flagSize&&(t["font-size"]=this._size),this._flagLeading&&(t["line-height"]=this._leading),this._flagAlignment&&(t["text-anchor"]=E.alignments[this._alignment]||this._alignment),this._flagBaseline&&(t["dominant-baseline"]=E.baselines[this._baseline]||this._baseline),this._flagStyle&&(t["font-style"]=this._style),this._flagWeight&&(t["font-weight"]=this._weight),this._flagDecoration&&(t["text-decoration"]=this._decoration),this._flagDirection&&(t.direction=this._direction),this._fill&&this._fill._renderer){this._renderer.hasFillEffect=!0,this._fill._update();let s=E.getRendererType(this._fill._renderer.type);E[s].render.call(this._fill,i,!0)}if(this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill,this._renderer.hasFillEffect&&typeof this._fill.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasFillEffect)),this._stroke&&this._stroke._renderer){this._renderer.hasStrokeEffect=!0,this._stroke._update();let s=E.getRendererType(this._stroke._renderer.type);E[s].render.call(this._stroke,i,!0)}if(this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke,this._renderer.hasStrokeEffect&&typeof this._stroke.id>"u"&&(i.defs._flagUpdate=!0,delete this._renderer.hasStrokeEffect)),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t.opacity=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?E.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=E.createElement("text",t),i.appendChild(this._renderer.elem)),this._flagClip){let s=E.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}if(this._flagMask)if(this._mask){let s=E.getRendererType(this._mask._renderer.type);E[s].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")}else this._renderer.elem.removeAttribute("clip-path");return this._flagValue&&(this._renderer.elem.textContent=this._value),this.flagReset()}},"linear-gradient":{render:function(i,t){t||this._update();let e={};if(this._flagId&&(e.id=this._id),this._flagEndPoints&&(e.x1=this.left._x,e.y1=this.left._y,e.x2=this.right._x,e.y2=this.right._y),this._flagSpread&&(e.spreadMethod=this._spread),this._flagUnits&&(e.gradientUnits=this._units),this._renderer.elem?E.setAttributes(this._renderer.elem,e):(e.id=this._id,this._renderer.elem=E.createElement("linearGradient",e)),this._renderer.elem.parentNode===null&&i.defs.appendChild(this._renderer.elem),this._flagStops){let s=this._renderer.elem.childNodes.length!==this.stops.length;if(s)for(;this._renderer.elem.lastChild;)this._renderer.elem.removeChild(this._renderer.elem.lastChild);for(let r=0;r0&&(e.x*=-1),e.y>0&&(e.y*=-1)),(this._flagScale||this._flagLoaded||this._flagRepeat)&&(e.width=0,e.height=0,r)){switch(e.width=r.width,e.height=r.height,this._repeat){case"no-repeat":e.width+=1,e.height+=1;break}this._scale instanceof x?(e.width*=this._scale.x,e.height*=this._scale.y):(e.width*=this._scale,e.height*=this._scale),s.width=e.width,s.height=e.height}return(this._flagScale||this._flagLoaded)&&(this._renderer.image?E.setAttributes(this._renderer.image,s):this._renderer.image=E.createElement("image",s)),this._renderer.elem?Object.keys(e).length!==0&&E.setAttributes(this._renderer.elem,e):(e.id=this._id,e.patternUnits="userSpaceOnUse",this._renderer.elem=E.createElement("pattern",e)),this._renderer.elem.parentNode===null&&i.defs.appendChild(this._renderer.elem),this._renderer.elem&&this._renderer.image&&!this._renderer.appended&&(this._renderer.elem.appendChild(this._renderer.image),this._renderer.appended=!0),this.flagReset()}}},we=class extends g{constructor(t){super(),this.domElement=t.domElement||E.createElement("svg"),this.scene=new K,this.scene.parent=this,this.defs=E.createElement("defs"),this.defs._flagUpdate=!1,this.domElement.appendChild(this.defs),this.domElement.defs=this.defs,this.domElement.style.overflow="hidden"}setSize(t,e){return this.width=t,this.height=e,E.setAttributes(this.domElement,{width:t,height:e}),this.trigger(g.Types.resize,t,e)}render(){return E.group.render.call(this.scene,this.domElement),E.defs.update(this.domElement),this}};w(we,"Utils",E);var wt={create:function(i,t,e){let s=i.createShader(i[e]);if(i.shaderSource(s,t),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS)){let n=i.getShaderInfoLog(s);throw i.deleteShader(s),new et("unable to compile shader "+s+": "+n)}return s},types:{vertex:"VERTEX_SHADER",fragment:"FRAGMENT_SHADER"},path:{vertex:` precision mediump float; attribute vec2 a_position; diff --git a/build/two.module.js b/build/two.module.js index 1e04bf04..5b0460da 100644 --- a/build/two.module.js +++ b/build/two.module.js @@ -782,8 +782,8 @@ var Constants = { svg: "SVGRenderer", canvas: "CanvasRenderer" }, - Version: "v0.8.15", - PublishDate: "2025-01-01T01:30:08.872Z", + Version: "v0.8.16", + PublishDate: "2025-01-06T21:30:44.526Z", Identifier: "two-", Resolution: 12, AutoCalculateImportedMatrices: true, @@ -6206,10 +6206,10 @@ var _Group = class extends Shape { const [bx, by] = matrix.multiply(rect.right, rect.top); const [cx, cy] = matrix.multiply(rect.left, rect.bottom); const [dx, dy] = matrix.multiply(rect.right, rect.bottom); - top = min3(ay, by, cy, dy); - left = min3(ax, bx, cx, dx); - right = max3(ax, bx, cx, dx); - bottom = max3(ay, by, cy, dy); + top = min3(ay, by, cy, dy, top); + left = min3(ax, bx, cx, dx, left); + right = max3(ax, bx, cx, dx, right); + bottom = max3(ay, by, cy, dy, bottom); } else { top = min3(rect.top, top); left = min3(rect.left, left); From 923665260a8c75c7ead6cec90b4fee5eb9279280 Mon Sep 17 00:00:00 2001 From: Jono Brandel Date: Mon, 6 Jan 2025 13:33:52 -0800 Subject: [PATCH 4/4] Update README.md --- wiki/changelog/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/wiki/changelog/README.md b/wiki/changelog/README.md index acbb8140..8ac32f61 100644 --- a/wiki/changelog/README.md +++ b/wiki/changelog/README.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. The format ## Nightly + `Two.ZUI.reset` updates the surfaces to be reflect reset orientation ++ `Two.Group.getBoundingClientRect(shallow)` correctly infers min and max values to calculate dimensions correctly ## Dec 31, 2024 v0.8.15