@emasoft/svg-matrix 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/svg-matrix.js +7 -6
- package/bin/svgm.js +109 -40
- package/dist/svg-matrix.min.js +7 -7
- package/dist/svg-toolbox.min.js +148 -228
- package/dist/svgm.min.js +152 -232
- package/dist/version.json +5 -5
- package/package.json +1 -1
- package/scripts/postinstall.js +72 -41
- package/scripts/test-postinstall.js +18 -16
- package/scripts/version-sync.js +78 -60
- package/src/animation-optimization.js +190 -98
- package/src/animation-references.js +11 -3
- package/src/arc-length.js +23 -20
- package/src/bezier-analysis.js +9 -13
- package/src/bezier-intersections.js +18 -4
- package/src/browser-verify.js +35 -8
- package/src/clip-path-resolver.js +285 -114
- package/src/convert-path-data.js +20 -8
- package/src/css-specificity.js +33 -9
- package/src/douglas-peucker.js +272 -141
- package/src/geometry-to-path.js +79 -22
- package/src/gjk-collision.js +287 -126
- package/src/index.js +56 -21
- package/src/inkscape-support.js +122 -101
- package/src/logger.js +43 -27
- package/src/marker-resolver.js +201 -121
- package/src/mask-resolver.js +231 -98
- package/src/matrix.js +9 -5
- package/src/mesh-gradient.js +22 -14
- package/src/off-canvas-detection.js +53 -17
- package/src/path-optimization.js +356 -171
- package/src/path-simplification.js +671 -256
- package/src/pattern-resolver.js +1 -3
- package/src/polygon-clip.js +396 -78
- package/src/svg-boolean-ops.js +90 -23
- package/src/svg-collections.js +1546 -667
- package/src/svg-flatten.js +152 -38
- package/src/svg-matrix-lib.js +2 -2
- package/src/svg-parser.js +5 -1
- package/src/svg-rendering-context.js +3 -1
- package/src/svg-toolbox-lib.js +2 -2
- package/src/svg-toolbox.js +99 -457
- package/src/svg-validation-data.js +513 -345
- package/src/svg2-polyfills.js +156 -93
- package/src/svgm-lib.js +8 -4
- package/src/transform-optimization.js +168 -51
- package/src/transforms2d.js +73 -40
- package/src/transforms3d.js +34 -27
- package/src/use-symbol-resolver.js +175 -76
- package/src/vector.js +80 -44
- package/src/vendor/inkscape-hatch-polyfill.js +143 -108
- package/src/vendor/inkscape-hatch-polyfill.min.js +291 -1
- package/src/vendor/inkscape-mesh-polyfill.js +953 -766
- package/src/vendor/inkscape-mesh-polyfill.min.js +896 -1
- package/src/verification.js +3 -4
package/dist/svgm.min.js
CHANGED
|
@@ -1,207 +1,127 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,"\t"],
|
|
3
|
-
* decimal.js v10.6.0
|
|
4
|
-
* An arbitrary-precision Decimal type for JavaScript.
|
|
5
|
-
* https://github.com/MikeMcl/decimal.js
|
|
6
|
-
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
7
|
-
* MIT Licence
|
|
8
|
-
*/var y5=9000000000000000,J4=1e9,$0="0123456789abcdef",o0="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",x0="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",t2={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-y5,maxE:y5,crypto:!1},dt,L4,d3=!0,b0="[DecimalError] ",H4=b0+"Invalid argument: ",Nt=b0+"Precision limit exceeded",It=b0+"crypto unavailable",Bt="[object Decimal]",q3=Math.floor,G3=Math.pow,Pe=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Se=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Te=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Dt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,S4=1e7,S3=7,Ae=9007199254740991,fe=o0.length-1,a2=x0.length-1,r3={toStringTag:Bt};r3.absoluteValue=r3.abs=function(){var t=new this.constructor(this);if(t.s<0)t.s=1;return E3(t)};r3.ceil=function(){return E3(new this.constructor(this),this.e+1,2)};r3.clampedTo=r3.clamp=function(t,a){var e,i=this,r=i.constructor;if(t=new r(t),a=new r(a),!t.s||!a.s)return new r(NaN);if(t.gt(a))throw Error(H4+a);return e=i.cmp(t),e<0?t:i.cmp(a)>0?a:new r(i)};r3.comparedTo=r3.cmp=function(t){var a,e,i,r,l=this,o=l.d,x=(t=new l.constructor(t)).d,p=l.s,n=t.s;if(!o||!x)return!p||!n?NaN:p!==n?p:o===x?0:!o^p<0?1:-1;if(!o[0]||!x[0])return o[0]?p:x[0]?-n:0;if(p!==n)return p;if(l.e!==t.e)return l.e>t.e^p<0?1:-1;i=o.length,r=x.length;for(a=0,e=i<r?i:r;a<e;++a)if(o[a]!==x[a])return o[a]>x[a]^p<0?1:-1;return i===r?0:i>r^p<0?1:-1};r3.cosine=r3.cos=function(){var t,a,e=this,i=e.constructor;if(!e.d)return new i(NaN);if(!e.d[0])return new i(1);return t=i.precision,a=i.rounding,i.precision=t+Math.max(e.e,e.sd())+S3,i.rounding=1,e=de(i,Yt(i,e)),i.precision=t,i.rounding=a,E3(L4==2||L4==3?e.neg():e,t,a,!0)};r3.cubeRoot=r3.cbrt=function(){var t,a,e,i,r,l,o,x,p,n,c=this,s=c.constructor;if(!c.isFinite()||c.isZero())return new s(c);if(d3=!1,l=c.s*G3(c.s*c,0.3333333333333333),!l||Math.abs(l)==1/0){if(e=z3(c.d),t=c.e,l=(t-e.length+1)%3)e+=l==1||l==-2?"0":"00";if(l=G3(e,0.3333333333333333),t=q3((t+1)/3)-(t%3==(t<0?-1:2)),l==1/0)e="5e"+t;else e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t;i=new s(e),i.s=c.s}else i=new s(l.toString());o=(t=s.precision)+3;for(;;)if(x=i,p=x.times(x).times(x),n=p.plus(c),i=X3(n.plus(c).times(x),n.plus(p),o+2,1),z3(x.d).slice(0,o)===(e=z3(i.d)).slice(0,o))if(e=e.slice(o-3,o+1),e=="9999"||!r&&e=="4999"){if(!r){if(E3(x,t+1,0),x.times(x).times(x).eq(c)){i=x;break}}o+=4,r=1}else{if(!+e||!+e.slice(1)&&e.charAt(0)=="5")E3(i,t+1,1),a=!i.times(i).times(i).eq(c);break}return d3=!0,E3(i,t,s.rounding,a)};r3.decimalPlaces=r3.dp=function(){var t,a=this.d,e=NaN;if(a){if(t=a.length-1,e=(t-q3(this.e/S3))*S3,t=a[t],t)for(;t%10==0;t/=10)e--;if(e<0)e=0}return e};r3.dividedBy=r3.div=function(t){return X3(this,new this.constructor(t))};r3.dividedToIntegerBy=r3.divToInt=function(t){var a=this,e=a.constructor;return E3(X3(a,new e(t),0,1,1),e.precision,e.rounding)};r3.equals=r3.eq=function(t){return this.cmp(t)===0};r3.floor=function(){return E3(new this.constructor(this),this.e+1,3)};r3.greaterThan=r3.gt=function(t){return this.cmp(t)>0};r3.greaterThanOrEqualTo=r3.gte=function(t){var a=this.cmp(t);return a==1||a===0};r3.hyperbolicCosine=r3.cosh=function(){var t,a,e,i,r,l=this,o=l.constructor,x=new o(1);if(!l.isFinite())return new o(l.s?1/0:NaN);if(l.isZero())return x;if(e=o.precision,i=o.rounding,o.precision=e+Math.max(l.e,l.sd())+4,o.rounding=1,r=l.d.length,r<32)t=Math.ceil(r/3),a=(1/S0(4,t)).toString();else t=16,a="2.3283064365386962890625e-10";l=E5(o,1,l.times(a),new o(1),!0);var p,n=t,c=new o(8);for(;n--;)p=l.times(l),l=x.minus(p.times(c.minus(p.times(c))));return E3(l,o.precision=e,o.rounding=i,!0)};r3.hyperbolicSine=r3.sinh=function(){var t,a,e,i,r=this,l=r.constructor;if(!r.isFinite()||r.isZero())return new l(r);if(a=l.precision,e=l.rounding,l.precision=a+Math.max(r.e,r.sd())+4,l.rounding=1,i=r.d.length,i<3)r=E5(l,2,r,r,!0);else{t=1.4*Math.sqrt(i),t=t>16?16:t|0,r=r.times(1/S0(5,t)),r=E5(l,2,r,r,!0);var o,x=new l(5),p=new l(16),n=new l(20);for(;t--;)o=r.times(r),r=r.times(x.plus(o.times(p.times(o).plus(n))))}return l.precision=a,l.rounding=e,E3(r,a,e,!0)};r3.hyperbolicTangent=r3.tanh=function(){var t,a,e=this,i=e.constructor;if(!e.isFinite())return new i(e.s);if(e.isZero())return new i(e);return t=i.precision,a=i.rounding,i.precision=t+7,i.rounding=1,X3(e.sinh(),e.cosh(),i.precision=t,i.rounding=a)};r3.inverseCosine=r3.acos=function(){var t=this,a=t.constructor,e=t.abs().cmp(1),i=a.precision,r=a.rounding;if(e!==-1)return e===0?t.isNeg()?d4(a,i,r):new a(0):new a(NaN);if(t.isZero())return d4(a,i+4,r).times(0.5);return a.precision=i+6,a.rounding=1,t=new a(1).minus(t).div(t.plus(1)).sqrt().atan(),a.precision=i,a.rounding=r,t.times(2)};r3.inverseHyperbolicCosine=r3.acosh=function(){var t,a,e=this,i=e.constructor;if(e.lte(1))return new i(e.eq(1)?0:NaN);if(!e.isFinite())return new i(e);return t=i.precision,a=i.rounding,i.precision=t+Math.max(Math.abs(e.e),e.sd())+4,i.rounding=1,d3=!1,e=e.times(e).minus(1).sqrt().plus(e),d3=!0,i.precision=t,i.rounding=a,e.ln()};r3.inverseHyperbolicSine=r3.asinh=function(){var t,a,e=this,i=e.constructor;if(!e.isFinite()||e.isZero())return new i(e);return t=i.precision,a=i.rounding,i.precision=t+2*Math.max(Math.abs(e.e),e.sd())+6,i.rounding=1,d3=!1,e=e.times(e).plus(1).sqrt().plus(e),d3=!0,i.precision=t,i.rounding=a,e.ln()};r3.inverseHyperbolicTangent=r3.atanh=function(){var t,a,e,i,r=this,l=r.constructor;if(!r.isFinite())return new l(NaN);if(r.e>=0)return new l(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN);if(t=l.precision,a=l.rounding,i=r.sd(),Math.max(i,t)<2*-r.e-1)return E3(new l(r),t,a,!0);return l.precision=e=i-r.e,r=X3(r.plus(1),new l(1).minus(r),e+t,1),l.precision=t+4,l.rounding=1,r=r.ln(),l.precision=t,l.rounding=a,r.times(0.5)};r3.inverseSine=r3.asin=function(){var t,a,e,i,r=this,l=r.constructor;if(r.isZero())return new l(r);if(a=r.abs().cmp(1),e=l.precision,i=l.rounding,a!==-1){if(a===0)return t=d4(l,e+4,i).times(0.5),t.s=r.s,t;return new l(NaN)}return l.precision=e+6,l.rounding=1,r=r.div(new l(1).minus(r.times(r)).sqrt().plus(1)).atan(),l.precision=e,l.rounding=i,r.times(2)};r3.inverseTangent=r3.atan=function(){var t,a,e,i,r,l,o,x,p,n=this,c=n.constructor,s=c.precision,m=c.rounding;if(!n.isFinite()){if(!n.s)return new c(NaN);if(s+4<=a2)return o=d4(c,s+4,m).times(0.5),o.s=n.s,o}else if(n.isZero())return new c(n);else if(n.abs().eq(1)&&s+4<=a2)return o=d4(c,s+4,m).times(0.25),o.s=n.s,o;c.precision=x=s+10,c.rounding=1,e=Math.min(28,x/S3+2|0);for(t=e;t;--t)n=n.div(n.times(n).plus(1).sqrt().plus(1));d3=!1,a=Math.ceil(x/S3),i=1,p=n.times(n),o=new c(n),r=n;for(;t!==-1;)if(r=r.times(p),l=o.minus(r.div(i+=2)),r=r.times(p),o=l.plus(r.div(i+=2)),o.d[a]!==void 0)for(t=a;o.d[t]===l.d[t]&&t--;);if(e)o=o.times(2<<e-1);return d3=!0,E3(o,c.precision=s,c.rounding=m,!0)};r3.isFinite=function(){return!!this.d};r3.isInteger=r3.isInt=function(){return!!this.d&&q3(this.e/S3)>this.d.length-2};r3.isNaN=function(){return!this.s};r3.isNegative=r3.isNeg=function(){return this.s<0};r3.isPositive=r3.isPos=function(){return this.s>0};r3.isZero=function(){return!!this.d&&this.d[0]===0};r3.lessThan=r3.lt=function(t){return this.cmp(t)<0};r3.lessThanOrEqualTo=r3.lte=function(t){return this.cmp(t)<1};r3.logarithm=r3.log=function(t){var a,e,i,r,l,o,x,p,n=this,c=n.constructor,s=c.precision,m=c.rounding,g=5;if(t==null)t=new c(10),a=!0;else{if(t=new c(t),e=t.d,t.s<0||!e||!e[0]||t.eq(1))return new c(NaN);a=t.eq(10)}if(e=n.d,n.s<0||!e||!e[0]||n.eq(1))return new c(e&&!e[0]?-1/0:n.s!=1?NaN:e?0:1/0);if(a)if(e.length>1)l=!0;else{for(r=e[0];r%10===0;)r/=10;l=r!==1}if(d3=!1,x=s+g,o=z4(n,x),i=a?n0(c,x+10):z4(t,x),p=X3(o,i,x,1),w5(p.d,r=s,m))do if(x+=10,o=z4(n,x),i=a?n0(c,x+10):z4(t,x),p=X3(o,i,x,1),!l){if(+z3(p.d).slice(r+1,r+15)+1==100000000000000)p=E3(p,s+1,0);break}while(w5(p.d,r+=10,m));return d3=!0,E3(p,s,m)};r3.minus=r3.sub=function(t){var a,e,i,r,l,o,x,p,n,c,s,m,g=this,u=g.constructor;if(t=new u(t),!g.d||!t.d){if(!g.s||!t.s)t=new u(NaN);else if(g.d)t.s=-t.s;else t=new u(t.d||g.s!==t.s?g:NaN);return t}if(g.s!=t.s)return t.s=-t.s,g.plus(t);if(n=g.d,m=t.d,x=u.precision,p=u.rounding,!n[0]||!m[0]){if(m[0])t.s=-t.s;else if(n[0])t=new u(g);else return new u(p===3?-0:0);return d3?E3(t,x,p):t}if(e=q3(t.e/S3),c=q3(g.e/S3),n=n.slice(),l=c-e,l){if(s=l<0,s)a=n,l=-l,o=m.length;else a=m,e=c,o=n.length;if(i=Math.max(Math.ceil(x/S3),o)+2,l>i)l=i,a.length=1;a.reverse();for(i=l;i--;)a.push(0);a.reverse()}else{if(i=n.length,o=m.length,s=i<o,s)o=i;for(i=0;i<o;i++)if(n[i]!=m[i]){s=n[i]<m[i];break}l=0}if(s)a=n,n=m,m=a,t.s=-t.s;o=n.length;for(i=m.length-o;i>0;--i)n[o++]=0;for(i=m.length;i>l;){if(n[--i]<m[i]){for(r=i;r&&n[--r]===0;)n[r]=S4-1;--n[r],n[i]+=S4}n[i]-=m[i]}for(;n[--o]===0;)n.pop();for(;n[0]===0;n.shift())--e;if(!n[0])return new u(p===3?-0:0);return t.d=n,t.e=P0(n,e),d3?E3(t,x,p):t};r3.modulo=r3.mod=function(t){var a,e=this,i=e.constructor;if(t=new i(t),!e.d||!t.s||t.d&&!t.d[0])return new i(NaN);if(!t.d||e.d&&!e.d[0])return E3(new i(e),i.precision,i.rounding);if(d3=!1,i.modulo==9)a=X3(e,t.abs(),0,3,1),a.s*=t.s;else a=X3(e,t,0,i.modulo,1);return a=a.times(t),d3=!0,e.minus(a)};r3.naturalExponential=r3.exp=function(){return e2(this)};r3.naturalLogarithm=r3.ln=function(){return z4(this)};r3.negated=r3.neg=function(){var t=new this.constructor(this);return t.s=-t.s,E3(t)};r3.plus=r3.add=function(t){var a,e,i,r,l,o,x,p,n,c,s=this,m=s.constructor;if(t=new m(t),!s.d||!t.d){if(!s.s||!t.s)t=new m(NaN);else if(!s.d)t=new m(t.d||s.s===t.s?s:NaN);return t}if(s.s!=t.s)return t.s=-t.s,s.minus(t);if(n=s.d,c=t.d,x=m.precision,p=m.rounding,!n[0]||!c[0]){if(!c[0])t=new m(s);return d3?E3(t,x,p):t}if(l=q3(s.e/S3),i=q3(t.e/S3),n=n.slice(),r=l-i,r){if(r<0)e=n,r=-r,o=c.length;else e=c,i=l,o=n.length;if(l=Math.ceil(x/S3),o=l>o?l+1:o+1,r>o)r=o,e.length=1;e.reverse();for(;r--;)e.push(0);e.reverse()}if(o=n.length,r=c.length,o-r<0)r=o,e=c,c=n,n=e;for(a=0;r;)a=(n[--r]=n[r]+c[r]+a)/S4|0,n[r]%=S4;if(a)n.unshift(a),++i;for(o=n.length;n[--o]==0;)n.pop();return t.d=n,t.e=P0(n,i),d3?E3(t,x,p):t};r3.precision=r3.sd=function(t){var a,e=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(H4+t);if(e.d){if(a=Rt(e.d),t&&e.e+1>a)a=e.e+1}else a=NaN;return a};r3.round=function(){var t=this,a=t.constructor;return E3(new a(t),t.e+1,a.rounding)};r3.sine=r3.sin=function(){var t,a,e=this,i=e.constructor;if(!e.isFinite())return new i(NaN);if(e.isZero())return new i(e);return t=i.precision,a=i.rounding,i.precision=t+Math.max(e.e,e.sd())+S3,i.rounding=1,e=Ie(i,Yt(i,e)),i.precision=t,i.rounding=a,E3(L4>2?e.neg():e,t,a,!0)};r3.squareRoot=r3.sqrt=function(){var t,a,e,i,r,l,o=this,x=o.d,p=o.e,n=o.s,c=o.constructor;if(n!==1||!x||!x[0])return new c(!n||n<0&&(!x||x[0])?NaN:x?o:1/0);if(d3=!1,n=Math.sqrt(+o),n==0||n==1/0){if(a=z3(x),(a.length+p)%2==0)a+="0";if(n=Math.sqrt(a),p=q3((p+1)/2)-(p<0||p%2),n==1/0)a="5e"+p;else a=n.toExponential(),a=a.slice(0,a.indexOf("e")+1)+p;i=new c(a)}else i=new c(n.toString());e=(p=c.precision)+3;for(;;)if(l=i,i=l.plus(X3(o,l,e+2,1)).times(0.5),z3(l.d).slice(0,e)===(a=z3(i.d)).slice(0,e))if(a=a.slice(e-3,e+1),a=="9999"||!r&&a=="4999"){if(!r){if(E3(l,p+1,0),l.times(l).eq(o)){i=l;break}}e+=4,r=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")E3(i,p+1,1),t=!i.times(i).eq(o);break}return d3=!0,E3(i,p,c.rounding,t)};r3.tangent=r3.tan=function(){var t,a,e=this,i=e.constructor;if(!e.isFinite())return new i(NaN);if(e.isZero())return new i(e);return t=i.precision,a=i.rounding,i.precision=t+10,i.rounding=1,e=e.sin(),e.s=1,e=X3(e,new i(1).minus(e.times(e)).sqrt(),t+10,0),i.precision=t,i.rounding=a,E3(L4==2||L4==4?e.neg():e,t,a,!0)};r3.times=r3.mul=function(t){var a,e,i,r,l,o,x,p,n,c=this,s=c.constructor,m=c.d,g=(t=new s(t)).d;if(t.s*=c.s,!m||!m[0]||!g||!g[0])return new s(!t.s||m&&!m[0]&&!g||g&&!g[0]&&!m?NaN:!m||!g?t.s/0:t.s*0);if(e=q3(c.e/S3)+q3(t.e/S3),p=m.length,n=g.length,p<n)l=m,m=g,g=l,o=p,p=n,n=o;l=[],o=p+n;for(i=o;i--;)l.push(0);for(i=n;--i>=0;){a=0;for(r=p+i;r>i;)x=l[r]+g[i]*m[r-i-1]+a,l[r--]=x%S4|0,a=x/S4|0;l[r]=(l[r]+a)%S4|0}for(;!l[--o];)l.pop();if(a)++e;else l.shift();return t.d=l,t.e=P0(l,e),d3?E3(t,s.precision,s.rounding):t};r3.toBinary=function(t,a){return u2(this,2,t,a)};r3.toDecimalPlaces=r3.toDP=function(t,a){var e=this,i=e.constructor;if(e=new i(e),t===void 0)return e;if(r4(t,0,J4),a===void 0)a=i.rounding;else r4(a,0,8);return E3(e,t+e.e+1,a)};r3.toExponential=function(t,a){var e,i=this,r=i.constructor;if(t===void 0)e=I4(i,!0);else{if(r4(t,0,J4),a===void 0)a=r.rounding;else r4(a,0,8);i=E3(new r(i),t+1,a),e=I4(i,!0,t+1)}return i.isNeg()&&!i.isZero()?"-"+e:e};r3.toFixed=function(t,a){var e,i,r=this,l=r.constructor;if(t===void 0)e=I4(r);else{if(r4(t,0,J4),a===void 0)a=l.rounding;else r4(a,0,8);i=E3(new l(r),t+r.e+1,a),e=I4(i,!1,t+i.e+1)}return r.isNeg()&&!r.isZero()?"-"+e:e};r3.toFraction=function(t){var a,e,i,r,l,o,x,p,n,c,s,m,g=this,u=g.d,y=g.constructor;if(!u)return new y(g);if(n=e=new y(1),i=p=new y(0),a=new y(i),l=a.e=Rt(u)-g.e-1,o=l%S3,a.d[0]=G3(10,o<0?S3+o:o),t==null)t=l>0?a:n;else{if(x=new y(t),!x.isInt()||x.lt(n))throw Error(H4+x);t=x.gt(a)?l>0?a:n:x}d3=!1,x=new y(z3(u)),c=y.precision,y.precision=l=u.length*S3*2;for(;;){if(s=X3(x,a,0,1,1),r=e.plus(s.times(i)),r.cmp(t)==1)break;e=i,i=r,r=n,n=p.plus(s.times(r)),p=r,r=a,a=x.minus(s.times(r)),x=r}return r=X3(t.minus(e),i,0,1,1),p=p.plus(r.times(n)),e=e.plus(r.times(i)),p.s=n.s=g.s,m=X3(n,i,l,1).minus(g).abs().cmp(X3(p,e,l,1).minus(g).abs())<1?[n,i]:[p,e],y.precision=c,d3=!0,m};r3.toHexadecimal=r3.toHex=function(t,a){return u2(this,16,t,a)};r3.toNearest=function(t,a){var e=this,i=e.constructor;if(e=new i(e),t==null){if(!e.d)return e;t=new i(1),a=i.rounding}else{if(t=new i(t),a===void 0)a=i.rounding;else r4(a,0,8);if(!e.d)return t.s?e:t;if(!t.d){if(t.s)t.s=e.s;return t}}if(t.d[0])d3=!1,e=X3(e,t,0,a,1).times(t),d3=!0,E3(e);else t.s=e.s,e=t;return e};r3.toNumber=function(){return+this};r3.toOctal=function(t,a){return u2(this,8,t,a)};r3.toPower=r3.pow=function(t){var a,e,i,r,l,o,x=this,p=x.constructor,n=+(t=new p(t));if(!x.d||!t.d||!x.d[0]||!t.d[0])return new p(G3(+x,n));if(x=new p(x),x.eq(1))return x;if(i=p.precision,l=p.rounding,t.eq(1))return E3(x,i,l);if(a=q3(t.e/S3),a>=t.d.length-1&&(e=n<0?-n:n)<=Ae)return r=wt(p,x,e,i),t.s<0?new p(1).div(r):E3(r,i,l);if(o=x.s,o<0){if(a<t.d.length-1)return new p(NaN);if((t.d[a]&1)==0)o=1;if(x.e==0&&x.d[0]==1&&x.d.length==1)return x.s=o,x}if(e=G3(+x,n),a=e==0||!isFinite(e)?q3(n*(Math.log("0."+z3(x.d))/Math.LN10+x.e+1)):new p(e+"").e,a>p.maxE+1||a<p.minE-1)return new p(a>0?o/0:0);if(d3=!1,p.rounding=x.s=1,e=Math.min(12,(a+"").length),r=e2(t.times(z4(x,i+e)),i),r.d){if(r=E3(r,i+5,1),w5(r.d,i,l)){if(a=i+10,r=E3(e2(t.times(z4(x,a+e)),a),a+5,1),+z3(r.d).slice(i+1,i+15)+1==100000000000000)r=E3(r,i+1,0)}}return r.s=o,d3=!0,p.rounding=l,E3(r,i,l)};r3.toPrecision=function(t,a){var e,i=this,r=i.constructor;if(t===void 0)e=I4(i,i.e<=r.toExpNeg||i.e>=r.toExpPos);else{if(r4(t,1,J4),a===void 0)a=r.rounding;else r4(a,0,8);i=E3(new r(i),t,a),e=I4(i,t<=i.e||i.e<=r.toExpNeg,t)}return i.isNeg()&&!i.isZero()?"-"+e:e};r3.toSignificantDigits=r3.toSD=function(t,a){var e=this,i=e.constructor;if(t===void 0)t=i.precision,a=i.rounding;else if(r4(t,1,J4),a===void 0)a=i.rounding;else r4(a,0,8);return E3(new i(e),t,a)};r3.toString=function(){var t=this,a=t.constructor,e=I4(t,t.e<=a.toExpNeg||t.e>=a.toExpPos);return t.isNeg()&&!t.isZero()?"-"+e:e};r3.truncated=r3.trunc=function(){return E3(new this.constructor(this),this.e+1,1)};r3.valueOf=r3.toJSON=function(){var t=this,a=t.constructor,e=I4(t,t.e<=a.toExpNeg||t.e>=a.toExpPos);return t.isNeg()?"-"+e:e};function z3(t){var a,e,i,r=t.length-1,l="",o=t[0];if(r>0){l+=o;for(a=1;a<r;a++){if(i=t[a]+"",e=S3-i.length,e)l+=j4(e);l+=i}if(o=t[a],i=o+"",e=S3-i.length,e)l+=j4(e)}else if(o===0)return"0";for(;o%10===0;)o/=10;return l+o}function r4(t,a,e){if(t!==~~t||t<a||t>e)throw Error(H4+t)}function w5(t,a,e,i){var r,l,o,x;for(l=t[0];l>=10;l/=10)--a;if(--a<0)a+=S3,r=0;else r=Math.ceil((a+1)/S3),a%=S3;if(l=G3(10,S3-a),x=t[r]%l|0,i==null)if(a<3){if(a==0)x=x/100|0;else if(a==1)x=x/10|0;o=e<4&&x==99999||e>3&&x==49999||x==50000||x==0}else o=(e<4&&x+1==l||e>3&&x+1==l/2)&&(t[r+1]/l/100|0)==G3(10,a-2)-1||(x==l/2||x==0)&&(t[r+1]/l/100|0)==0;else if(a<4){if(a==0)x=x/1000|0;else if(a==1)x=x/100|0;else if(a==2)x=x/10|0;o=(i||e<4)&&x==9999||!i&&e>3&&x==4999}else o=((i||e<4)&&x+1==l||!i&&e>3&&x+1==l/2)&&(t[r+1]/l/1000|0)==G3(10,a-3)-1;return o}function Z5(t,a,e){var i,r=[0],l,o=0,x=t.length;for(;o<x;){for(l=r.length;l--;)r[l]*=a;r[0]+=$0.indexOf(t.charAt(o++));for(i=0;i<r.length;i++)if(r[i]>e-1){if(r[i+1]===void 0)r[i+1]=0;r[i+1]+=r[i]/e|0,r[i]%=e}}return r.reverse()}function de(t,a){var e,i,r;if(a.isZero())return a;if(i=a.d.length,i<32)e=Math.ceil(i/3),r=(1/S0(4,e)).toString();else e=16,r="2.3283064365386962890625e-10";t.precision+=e,a=E5(t,1,a.times(r),new t(1));for(var l=e;l--;){var o=a.times(a);a=o.times(o).minus(o).times(8).plus(1)}return t.precision-=e,a}var X3=function(){function t(i,r,l){var o,x=0,p=i.length;for(i=i.slice();p--;)o=i[p]*r+x,i[p]=o%l|0,x=o/l|0;if(x)i.unshift(x);return i}function a(i,r,l,o){var x,p;if(l!=o)p=l>o?1:-1;else for(x=p=0;x<l;x++)if(i[x]!=r[x]){p=i[x]>r[x]?1:-1;break}return p}function e(i,r,l,o){var x=0;for(;l--;)i[l]-=x,x=i[l]<r[l]?1:0,i[l]=x*o+i[l]-r[l];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,l,o,x,p){var n,c,s,m,g,u,y,v,E,C,P,S,f,B,R,k,N,I,d,Y,X=i.constructor,F=i.s==r.s?1:-1,V=i.d,T=r.d;if(!V||!V[0]||!T||!T[0])return new X(!i.s||!r.s||(V?T&&V[0]==T[0]:!T)?NaN:V&&V[0]==0||!T?F*0:F/0);if(p)g=1,c=i.e-r.e;else p=S4,g=S3,c=q3(i.e/g)-q3(r.e/g);d=T.length,N=V.length,E=new X(F),C=E.d=[];for(s=0;T[s]==(V[s]||0);s++);if(T[s]>(V[s]||0))c--;if(l==null)B=l=X.precision,o=X.rounding;else if(x)B=l+(i.e-r.e)+1;else B=l;if(B<0)C.push(1),u=!0;else{if(B=B/g+2|0,s=0,d==1){m=0,T=T[0],B++;for(;(s<N||m)&&B--;s++)R=m*p+(V[s]||0),C[s]=R/T|0,m=R%T|0;u=m||s<N}else{if(m=p/(T[0]+1)|0,m>1)T=t(T,m,p),V=t(V,m,p),d=T.length,N=V.length;k=d,P=V.slice(0,d),S=P.length;for(;S<d;)P[S++]=0;if(Y=T.slice(),Y.unshift(0),I=T[0],T[1]>=p/2)++I;do{if(m=0,n=a(T,P,d,S),n<0){if(f=P[0],d!=S)f=f*p+(P[1]||0);if(m=f/I|0,m>1){if(m>=p)m=p-1;if(y=t(T,m,p),v=y.length,S=P.length,n=a(y,P,v,S),n==1)m--,e(y,d<v?Y:T,v,p)}else{if(m==0)n=m=1;y=T.slice()}if(v=y.length,v<S)y.unshift(0);if(e(P,y,S,p),n==-1){if(S=P.length,n=a(T,P,d,S),n<1)m++,e(P,d<S?Y:T,S,p)}S=P.length}else if(n===0)m++,P=[0];if(C[s++]=m,n&&P[0])P[S++]=V[k]||0;else P=[V[k]],S=1}while((k++<N||P[0]!==void 0)&&B--);u=P[0]!==void 0}if(!C[0])C.shift()}if(g==1)E.e=c,dt=u;else{for(s=1,m=C[0];m>=10;m/=10)s++;E.e=s+c*g-1,E3(E,x?l+E.e+1:l,o,u)}return E}}();function E3(t,a,e,i){var r,l,o,x,p,n,c,s,m,g=t.constructor;t:if(a!=null){if(s=t.d,!s)return t;for(r=1,x=s[0];x>=10;x/=10)r++;if(l=a-r,l<0)l+=S3,o=a,c=s[m=0],p=c/G3(10,r-o-1)%10|0;else if(m=Math.ceil((l+1)/S3),x=s.length,m>=x)if(i){for(;x++<=m;)s.push(0);c=p=0,r=1,l%=S3,o=l-S3+1}else break t;else{c=x=s[m];for(r=1;x>=10;x/=10)r++;l%=S3,o=l-S3+r,p=o<0?0:c/G3(10,r-o-1)%10|0}if(i=i||a<0||s[m+1]!==void 0||(o<0?c:c%G3(10,r-o-1)),n=e<4?(p||i)&&(e==0||e==(t.s<0?3:2)):p>5||p==5&&(e==4||i||e==6&&(l>0?o>0?c/G3(10,r-o):0:s[m-1])%10&1||e==(t.s<0?8:7)),a<1||!s[0]){if(s.length=0,n)a-=t.e+1,s[0]=G3(10,(S3-a%S3)%S3),t.e=-a||0;else s[0]=t.e=0;return t}if(l==0)s.length=m,x=1,m--;else s.length=m+1,x=G3(10,S3-l),s[m]=o>0?(c/G3(10,r-o)%G3(10,o)|0)*x:0;if(n)for(;;)if(m==0){for(l=1,o=s[0];o>=10;o/=10)l++;o=s[0]+=x;for(x=1;o>=10;o/=10)x++;if(l!=x){if(t.e++,s[0]==S4)s[0]=1}break}else{if(s[m]+=x,s[m]!=S4)break;s[m--]=0,x=1}for(l=s.length;s[--l]===0;)s.pop()}if(d3){if(t.e>g.maxE)t.d=null,t.e=NaN;else if(t.e<g.minE)t.e=0,t.d=[0]}return t}function I4(t,a,e){if(!t.isFinite())return kt(t);var i,r=t.e,l=z3(t.d),o=l.length;if(a){if(e&&(i=e-o)>0)l=l.charAt(0)+"."+l.slice(1)+j4(i);else if(o>1)l=l.charAt(0)+"."+l.slice(1);l=l+(t.e<0?"e":"e+")+t.e}else if(r<0){if(l="0."+j4(-r-1)+l,e&&(i=e-o)>0)l+=j4(i)}else if(r>=o){if(l+=j4(r+1-o),e&&(i=e-r-1)>0)l=l+"."+j4(i)}else{if((i=r+1)<o)l=l.slice(0,i)+"."+l.slice(i);if(e&&(i=e-o)>0){if(r+1===o)l+=".";l+=j4(i)}}return l}function P0(t,a){var e=t[0];for(a*=S3;e>=10;e/=10)a++;return a}function n0(t,a,e){if(a>fe){if(d3=!0,e)t.precision=e;throw Error(Nt)}return E3(new t(o0),a,1,!0)}function d4(t,a,e){if(a>a2)throw Error(Nt);return E3(new t(x0),a,e,!0)}function Rt(t){var a=t.length-1,e=a*S3+1;if(a=t[a],a){for(;a%10==0;a/=10)e--;for(a=t[0];a>=10;a/=10)e++}return e}function j4(t){var a="";for(;t--;)a+="0";return a}function wt(t,a,e,i){var r,l=new t(1),o=Math.ceil(i/S3+4);d3=!1;for(;;){if(e%2){if(l=l.times(a),h6(l.d,o))r=!0}if(e=q3(e/2),e===0){if(e=l.d.length-1,r&&l.d[e]===0)++l.d[e];break}a=a.times(a),h6(a.d,o)}return d3=!0,l}function y6(t){return t.d[t.d.length-1]&1}function Lt(t,a,e){var i,r,l=new t(a[0]),o=0;for(;++o<a.length;){if(r=new t(a[o]),!r.s){l=r;break}if(i=l.cmp(r),i===e||i===0&&l.s===e)l=r}return l}function e2(t,a){var e,i,r,l,o,x,p,n=0,c=0,s=0,m=t.constructor,g=m.rounding,u=m.precision;if(!t.d||!t.d[0]||t.e>17)return new m(t.d?!t.d[0]?1:t.s<0?0:1/0:t.s?t.s<0?0:t:NaN);if(a==null)d3=!1,p=u;else p=a;x=new m(0.03125);while(t.e>-2)t=t.times(x),s+=5;i=Math.log(G3(2,s))/Math.LN10*2+5|0,p+=i,e=l=o=new m(1),m.precision=p;for(;;){if(l=E3(l.times(t),p,1),e=e.times(++c),x=o.plus(X3(l,e,p,1)),z3(x.d).slice(0,p)===z3(o.d).slice(0,p)){r=s;while(r--)o=E3(o.times(o),p,1);if(a==null)if(n<3&&w5(o.d,p-i,g,n))m.precision=p+=10,e=l=x=new m(1),c=0,n++;else return E3(o,m.precision=u,g,d3=!0);else return m.precision=u,o}o=x}}function z4(t,a){var e,i,r,l,o,x,p,n,c,s,m,g=1,u=10,y=t,v=y.d,E=y.constructor,C=E.rounding,P=E.precision;if(y.s<0||!v||!v[0]||!y.e&&v[0]==1&&v.length==1)return new E(v&&!v[0]?-1/0:y.s!=1?NaN:v?0:y);if(a==null)d3=!1,c=P;else c=a;if(E.precision=c+=u,e=z3(v),i=e.charAt(0),Math.abs(l=y.e)<1500000000000000){while(i<7&&i!=1||i==1&&e.charAt(1)>3)y=y.times(t),e=z3(y.d),i=e.charAt(0),g++;if(l=y.e,i>1)y=new E("0."+e),l++;else y=new E(i+"."+e.slice(1))}else return n=n0(E,c+2,P).times(l+""),y=z4(new E(i+"."+e.slice(1)),c-u).plus(n),E.precision=P,a==null?E3(y,P,C,d3=!0):y;s=y,p=o=y=X3(y.minus(1),y.plus(1),c,1),m=E3(y.times(y),c,1),r=3;for(;;){if(o=E3(o.times(m),c,1),n=p.plus(X3(o,new E(r),c,1)),z3(n.d).slice(0,c)===z3(p.d).slice(0,c)){if(p=p.times(2),l!==0)p=p.plus(n0(E,c+2,P).times(l+""));if(p=X3(p,new E(g),c,1),a==null)if(w5(p.d,c-u,C,x))E.precision=c+=u,n=o=y=X3(s.minus(1),s.plus(1),c,1),m=E3(y.times(y),c,1),r=x=1;else return E3(p,E.precision=P,C,d3=!0);else return E.precision=P,p}p=n,r+=2}}function kt(t){return String(t.s*t.s/0)}function J5(t,a){var e,i,r;if((e=a.indexOf("."))>-1)a=a.replace(".","");if((i=a.search(/e/i))>0){if(e<0)e=i;e+=+a.slice(i+1),a=a.substring(0,i)}else if(e<0)e=a.length;for(i=0;a.charCodeAt(i)===48;i++);for(r=a.length;a.charCodeAt(r-1)===48;--r);if(a=a.slice(i,r),a){if(r-=i,t.e=e=e-i-1,t.d=[],i=(e+1)%S3,e<0)i+=S3;if(i<r){if(i)t.d.push(+a.slice(0,i));for(r-=S3;i<r;)t.d.push(+a.slice(i,i+=S3));a=a.slice(i),i=S3-a.length}else i-=r;for(;i--;)a+="0";if(t.d.push(+a),d3){if(t.e>t.constructor.maxE)t.d=null,t.e=NaN;else if(t.e<t.constructor.minE)t.e=0,t.d=[0]}}else t.e=0,t.d=[0];return t}function Ne(t,a){var e,i,r,l,o,x,p,n,c;if(a.indexOf("_")>-1){if(a=a.replace(/(\d)_(?=\d)/g,"$1"),Dt.test(a))return J5(t,a)}else if(a==="Infinity"||a==="NaN"){if(!+a)t.s=NaN;return t.e=NaN,t.d=null,t}if(Se.test(a))e=16,a=a.toLowerCase();else if(Pe.test(a))e=2;else if(Te.test(a))e=8;else throw Error(H4+a);if(l=a.search(/p/i),l>0)p=+a.slice(l+1),a=a.substring(2,l);else a=a.slice(2);if(l=a.indexOf("."),o=l>=0,i=t.constructor,o)a=a.replace(".",""),x=a.length,l=x-l,r=wt(i,new i(e),l,l*2);n=Z5(a,e,S4),c=n.length-1;for(l=c;n[l]===0;--l)n.pop();if(l<0)return new i(t.s*0);if(t.e=P0(n,c),t.d=n,d3=!1,o)t=X3(t,r,x*4);if(p)t=t.times(Math.abs(p)<54?G3(2,p):V5.pow(2,p));return d3=!0,t}function Ie(t,a){var e,i=a.d.length;if(i<3)return a.isZero()?a:E5(t,2,a,a);e=1.4*Math.sqrt(i),e=e>16?16:e|0,a=a.times(1/S0(5,e)),a=E5(t,2,a,a);var r,l=new t(5),o=new t(16),x=new t(20);for(;e--;)r=a.times(a),a=a.times(l.plus(r.times(o.times(r).minus(x))));return a}function E5(t,a,e,i,r){var l,o,x,p,n=1,c=t.precision,s=Math.ceil(c/S3);d3=!1,p=e.times(e),x=new t(i);for(;;){if(o=X3(x.times(p),new t(a++*a++),c,1),x=r?i.plus(o):i.minus(o),i=X3(o.times(p),new t(a++*a++),c,1),o=x.plus(i),o.d[s]!==void 0){for(l=s;o.d[l]===x.d[l]&&l--;);if(l==-1)break}l=x,x=i,i=o,o=l,n++}return d3=!0,o.d.length=s+1,o}function S0(t,a){var e=t;while(--a)e*=t;return e}function Yt(t,a){var e,i=a.s<0,r=d4(t,t.precision,1),l=r.times(0.5);if(a=a.abs(),a.lte(l))return L4=i?4:1,a;if(e=a.divToInt(r),e.isZero())L4=i?3:2;else{if(a=a.minus(e.times(r)),a.lte(l))return L4=y6(e)?i?2:3:i?4:1,a;L4=y6(e)?i?1:4:i?3:2}return a.minus(r).abs()}function u2(t,a,e,i){var r,l,o,x,p,n,c,s,m,g=t.constructor,u=e!==void 0;if(u)if(r4(e,1,J4),i===void 0)i=g.rounding;else r4(i,0,8);else e=g.precision,i=g.rounding;if(!t.isFinite())c=kt(t);else{if(c=I4(t),o=c.indexOf("."),u){if(r=2,a==16)e=e*4-3;else if(a==8)e=e*3-2}else r=a;if(o>=0)c=c.replace(".",""),m=new g(1),m.e=c.length-o,m.d=Z5(I4(m),10,r),m.e=m.d.length;s=Z5(c,10,r),l=p=s.length;for(;s[--p]==0;)s.pop();if(!s[0])c=u?"0p+0":"0";else{if(o<0)l--;else t=new g(t),t.d=s,t.e=l,t=X3(t,m,e,i,0,r),s=t.d,l=t.e,n=dt;if(o=s[e],x=r/2,n=n||s[e+1]!==void 0,n=i<4?(o!==void 0||n)&&(i===0||i===(t.s<0?3:2)):o>x||o===x&&(i===4||n||i===6&&s[e-1]&1||i===(t.s<0?8:7)),s.length=e,n){for(;++s[--e]>r-1;)if(s[e]=0,!e)++l,s.unshift(1)}for(p=s.length;!s[p-1];--p);for(o=0,c="";o<p;o++)c+=$0.charAt(s[o]);if(u){if(p>1)if(a==16||a==8){o=a==16?4:3;for(--p;p%o;p++)c+="0";s=Z5(c,r,a);for(p=s.length;!s[p-1];--p);for(o=1,c="1.";o<p;o++)c+=$0.charAt(s[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(l<0?"p":"p+")+l}else if(l<0){for(;++l;)c="0"+c;c="0."+c}else if(++l>p)for(l-=p;l--;)c+="0";else if(l<p)c=c.slice(0,l)+"."+c.slice(l)}c=(a==16?"0x":a==2?"0b":a==8?"0o":"")+c}return t.s<0?"-"+c:c}function h6(t,a){if(t.length>a)return t.length=a,!0}function Be(t){return new this(t).abs()}function De(t){return new this(t).acos()}function Re(t){return new this(t).acosh()}function we(t,a){return new this(t).plus(a)}function Le(t){return new this(t).asin()}function ke(t){return new this(t).asinh()}function Ye(t){return new this(t).atan()}function Xe(t){return new this(t).atanh()}function Oe(t,a){t=new this(t),a=new this(a);var e,i=this.precision,r=this.rounding,l=i+4;if(!t.s||!a.s)e=new this(NaN);else if(!t.d&&!a.d)e=d4(this,l,1).times(a.s>0?0.25:0.75),e.s=t.s;else if(!a.d||t.isZero())e=a.s<0?d4(this,i,r):new this(0),e.s=t.s;else if(!t.d||a.isZero())e=d4(this,l,1).times(0.5),e.s=t.s;else if(a.s<0)this.precision=l,this.rounding=1,e=this.atan(X3(t,a,l,1)),a=d4(this,l,1),this.precision=i,this.rounding=r,e=t.s<0?e.minus(a):e.plus(a);else e=this.atan(X3(t,a,l,1));return e}function Ve(t){return new this(t).cbrt()}function Ue(t){return E3(t=new this(t),t.e+1,2)}function Me(t,a,e){return new this(t).clamp(a,e)}function _e(t){if(!t||typeof t!=="object")throw Error(b0+"Object expected");var a,e,i,r=t.defaults===!0,l=["precision",1,J4,"rounding",0,8,"toExpNeg",-y5,0,"toExpPos",0,y5,"maxE",0,y5,"minE",-y5,0,"modulo",0,9];for(a=0;a<l.length;a+=3){if(e=l[a],r)this[e]=t2[e];if((i=t[e])!==void 0)if(q3(i)===i&&i>=l[a+1]&&i<=l[a+2])this[e]=i;else throw Error(H4+e+": "+i)}if(e="crypto",r)this[e]=t2[e];if((i=t[e])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(It);else this[e]=!1;else throw Error(H4+e+": "+i);return this}function Fe(t){return new this(t).cos()}function Ge(t){return new this(t).cosh()}function Xt(t){var a,e,i;function r(l){var o,x,p,n=this;if(!(n instanceof r))return new r(l);if(n.constructor=r,v6(l)){if(n.s=l.s,d3)if(!l.d||l.e>r.maxE)n.e=NaN,n.d=null;else if(l.e<r.minE)n.e=0,n.d=[0];else n.e=l.e,n.d=l.d.slice();else n.e=l.e,n.d=l.d?l.d.slice():l.d;return}if(p=typeof l,p==="number"){if(l===0){n.s=1/l<0?-1:1,n.e=0,n.d=[0];return}if(l<0)l=-l,n.s=-1;else n.s=1;if(l===~~l&&l<1e7){for(o=0,x=l;x>=10;x/=10)o++;if(d3)if(o>r.maxE)n.e=NaN,n.d=null;else if(o<r.minE)n.e=0,n.d=[0];else n.e=o,n.d=[l];else n.e=o,n.d=[l];return}if(l*0!==0){if(!l)n.s=NaN;n.e=NaN,n.d=null;return}return J5(n,l.toString())}if(p==="string"){if((x=l.charCodeAt(0))===45)l=l.slice(1),n.s=-1;else{if(x===43)l=l.slice(1);n.s=1}return Dt.test(l)?J5(n,l):Ne(n,l)}if(p==="bigint"){if(l<0)l=-l,n.s=-1;else n.s=1;return J5(n,l.toString())}throw Error(H4+l)}if(r.prototype=r3,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=_e,r.clone=Xt,r.isDecimal=v6,r.abs=Be,r.acos=De,r.acosh=Re,r.add=we,r.asin=Le,r.asinh=ke,r.atan=Ye,r.atanh=Xe,r.atan2=Oe,r.cbrt=Ve,r.ceil=Ue,r.clamp=Me,r.cos=Fe,r.cosh=Ge,r.div=je,r.exp=We,r.floor=ze,r.hypot=He,r.ln=Qe,r.log=qe,r.log10=Ze,r.log2=Ke,r.max=Je,r.min=$e,r.mod=ti,r.mul=ai,r.pow=ei,r.random=ii,r.round=ri,r.sign=li,r.sin=oi,r.sinh=xi,r.sqrt=ni,r.sub=pi,r.sum=ci,r.tan=si,r.tanh=mi,r.trunc=gi,t===void 0)t={};if(t){if(t.defaults!==!0){i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(a=0;a<i.length;)if(!t.hasOwnProperty(e=i[a++]))t[e]=this[e]}}return r.config(t),r}function je(t,a){return new this(t).div(a)}function We(t){return new this(t).exp()}function ze(t){return E3(t=new this(t),t.e+1,3)}function He(){var t,a,e=new this(0);d3=!1;for(t=0;t<arguments.length;)if(a=new this(arguments[t++]),!a.d){if(a.s)return d3=!0,new this(1/0);e=a}else if(e.d)e=e.plus(a.times(a));return d3=!0,e.sqrt()}function v6(t){return t instanceof V5||t&&t.toStringTag===Bt||!1}function Qe(t){return new this(t).ln()}function qe(t,a){return new this(t).log(a)}function Ke(t){return new this(t).log(2)}function Ze(t){return new this(t).log(10)}function Je(){return Lt(this,arguments,-1)}function $e(){return Lt(this,arguments,1)}function ti(t,a){return new this(t).mod(a)}function ai(t,a){return new this(t).mul(a)}function ei(t,a){return new this(t).pow(a)}function ii(t){var a,e,i,r,l=0,o=new this(1),x=[];if(t===void 0)t=this.precision;else r4(t,1,J4);if(i=Math.ceil(t/S3),!this.crypto)for(;l<i;)x[l++]=Math.random()*1e7|0;else if(crypto.getRandomValues){a=crypto.getRandomValues(new Uint32Array(i));for(;l<i;)if(r=a[l],r>=4290000000)a[l]=crypto.getRandomValues(new Uint32Array(1))[0];else x[l++]=r%1e7}else if(crypto.randomBytes){a=crypto.randomBytes(i*=4);for(;l<i;)if(r=a[l]+(a[l+1]<<8)+(a[l+2]<<16)+((a[l+3]&127)<<24),r>=2140000000)crypto.randomBytes(4).copy(a,l);else x.push(r%1e7),l+=4;l=i/4}else throw Error(It);if(i=x[--l],t%=S3,i&&t)r=G3(10,S3-t),x[l]=(i/r|0)*r;for(;x[l]===0;l--)x.pop();if(l<0)e=0,x=[0];else{e=-1;for(;x[0]===0;e-=S3)x.shift();for(i=1,r=x[0];r>=10;r/=10)i++;if(i<S3)e-=S3-i}return o.e=e,o.d=x,o}function ri(t){return E3(t=new this(t),t.e+1,this.rounding)}function li(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function oi(t){return new this(t).sin()}function xi(t){return new this(t).sinh()}function ni(t){return new this(t).sqrt()}function pi(t,a){return new this(t).sub(a)}function ci(){var t=0,a=arguments,e=new this(a[t]);d3=!1;for(;e.s&&++t<a.length;)e=e.plus(a[t]);return d3=!0,E3(e,this.precision,this.rounding)}function si(t){return new this(t).tan()}function mi(t){return new this(t).tanh()}function gi(t){return E3(t=new this(t),t.e+1,1)}r3[Symbol.for("nodejs.util.inspect.custom")]=r3.toString;r3[Symbol.toStringTag]="Decimal";var V5=r3.constructor=Xt(t2);o0=new V5(o0);x0=new V5(x0);var h=V5,G0=(t)=>{if(t===null||t===void 0)throw Error(`Cannot convert ${t===null?"null":"undefined"} to Decimal`);if(t instanceof h)return t;try{return new h(t)}catch(a){throw Error(`Invalid numeric value: ${a.message}`)}};class k3{constructor(t){if(!Array.isArray(t))throw Error("Vector requires array");if(t.length===0)throw Error("Vector requires at least one component");try{this.data=t.map((a,e)=>{if(a===null||a===void 0)throw Error(`Vector component at index ${e} is ${a===null?"null":"undefined"}`);return G0(a)})}catch(a){throw Error(`Vector constructor failed: ${a.message}`)}this.length=this.data.length}static from(t){if(t===null||t===void 0)throw Error(`Vector.from: argument is ${t===null?"null":"undefined"}`);return new k3(t)}clone(){return new k3(this.data.map((t)=>new h(t)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map((t)=>t.toNumber())}toStringArray(){return this.data.map((t)=>t.toString())}add(t){if(!t||!(t instanceof k3))throw Error("add: argument must be a Vector");if(this.length!==t.length)throw Error(`add: dimension mismatch (${this.length} vs ${t.length})`);return new k3(this.data.map((a,e)=>a.plus(t.data[e])))}sub(t){if(!t||!(t instanceof k3))throw Error("sub: argument must be a Vector");if(this.length!==t.length)throw Error(`sub: dimension mismatch (${this.length} vs ${t.length})`);return new k3(this.data.map((a,e)=>a.minus(t.data[e])))}scale(t){if(t===null||t===void 0)throw Error(`scale: scalar is ${t===null?"null":"undefined"}`);let a;try{a=G0(t)}catch(e){throw Error(`scale: invalid scalar - ${e.message}`)}return new k3(this.data.map((e)=>e.mul(a)))}negate(){return new k3(this.data.map((t)=>t.negated()))}dot(t){if(!t||!(t instanceof k3))throw Error("dot: argument must be a Vector");if(this.length!==t.length)throw Error(`dot: dimension mismatch (${this.length} vs ${t.length})`);return this.data.reduce((a,e,i)=>a.plus(e.mul(t.data[i])),new h(0))}outer(t){if(!t||!(t instanceof k3))throw Error("outer: argument must be a Vector");if(this.length===0||t.length===0)throw Error("outer: cannot compute outer product with empty vector");let a=this.length,e=t.length;return Array.from({length:a},(i,r)=>Array.from({length:e},(l,o)=>this.data[r].mul(t.data[o])))}cross(t){if(!t||!(t instanceof k3))throw Error("cross: argument must be a Vector");if(this.length!==3||t.length!==3)throw Error(`cross: requires 3D vectors (got ${this.length}D and ${t.length}D)`);let[a,e,i]=this.data,[r,l,o]=t.data;return new k3([e.mul(o).minus(i.mul(l)),i.mul(r).minus(a.mul(o)),a.mul(l).minus(e.mul(r))])}norm(){let t=new h(0);for(let a of this.data)t=t.plus(a.mul(a));return t.sqrt()}normalize(){let t=this.norm();if(t.isZero())throw Error("Cannot normalize zero vector");return this.scale(new h(1).div(t))}angleBetween(t){if(!t||!(t instanceof k3))throw Error("angleBetween: argument must be a Vector");if(this.length!==t.length)throw Error(`angleBetween: dimension mismatch (${this.length} vs ${t.length})`);let a=this.dot(t),e=this.norm(),i=t.norm();if(e.isZero()||i.isZero())throw Error("angleBetween: angle with zero vector is undefined");let r=a.div(e.mul(i)).toNumber(),l=Math.min(1,Math.max(-1,r));return new h(Math.acos(l))}projectOnto(t){if(!t||!(t instanceof k3))throw Error("projectOnto: argument must be a Vector");if(this.length!==t.length)throw Error(`projectOnto: dimension mismatch (${this.length} vs ${t.length})`);let a=t.dot(t);if(a.isZero())throw Error("projectOnto: cannot project onto zero vector");let e=this.dot(t).div(a);return t.scale(e)}orthogonal(){if(this.norm().isZero())throw Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new k3([this.data[1].negated(),this.data[0]]);for(let t=0;t<this.length;t++){let a=Array.from({length:this.length},(l,o)=>new h(o===t?1:0)),e=new k3(a),i=e.projectOnto(this),r=e.sub(i);if(!r.norm().isZero())return r.normalize()}throw Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo(t){if(!t||!(t instanceof k3))throw Error("isOrthogonalTo: argument must be a Vector");if(this.length!==t.length)throw Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${t.length})`);return this.dot(t).isZero()}distance(t){if(!t||!(t instanceof k3))throw Error("distance: argument must be a Vector");if(this.length!==t.length)throw Error(`distance: dimension mismatch (${this.length} vs ${t.length})`);return this.sub(t).norm()}equals(t,a=0){if(!(t instanceof k3))return!1;if(t.length!==this.length)return!1;if(a===null)throw Error("equals: tolerance cannot be null");let e;try{if(e=G0(a),e.isNaN())throw Error("equals: tolerance cannot be NaN");if(e.isNegative())throw Error("equals: tolerance must be non-negative")}catch(i){throw Error(`equals: invalid tolerance - ${i.message}`)}for(let i=0;i<this.length;i++)if(this.data[i].minus(t.data[i]).abs().greaterThan(e))return!1;return!0}}var g5=(t)=>{if(t==null)throw Error("Cannot convert null or undefined to Decimal");return t instanceof h?t:new h(t)};class s3{constructor(t){if(!Array.isArray(t)||t.length===0)throw Error("Matrix requires non-empty 2D array");if(!Array.isArray(t[0])||t[0].length===0)throw Error("Matrix rows must be non-empty arrays");let a=t[0].length;for(let e of t)if(!Array.isArray(e)||e.length!==a)throw Error("All rows must have same length");this.data=t.map((e)=>e.map((i)=>g5(i))),this.rows=t.length,this.cols=a}static from(t){return new s3(t)}static zeros(t,a){if(!Number.isInteger(t)||t<=0)throw Error("rows must be a positive integer");if(!Number.isInteger(a)||a<=0)throw Error("cols must be a positive integer");let e=Array.from({length:t},()=>Array.from({length:a},()=>new h(0)));return new s3(e)}static identity(t){if(!Number.isInteger(t)||t<=0)throw Error("size must be a positive integer");let a=Array.from({length:t},(e,i)=>Array.from({length:t},(r,l)=>i===l?new h(1):new h(0)));return new s3(a)}clone(){return new s3(this.data.map((t)=>t.map((a)=>new h(a))))}toArrayOfStrings(){return this.data.map((t)=>t.map((a)=>a.toString()))}toNumberArray(){return this.data.map((t)=>t.map((a)=>a.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector(t){let a;if(t instanceof k3)a=t;else if(Array.isArray(t))a=k3.from(t);else throw Error("applyToVector expects Vector or array");if(this.cols!==a.length)throw Error("shape mismatch: matrix cols must equal vector length");let e=[];for(let i=0;i<this.rows;i++){let r=new h(0);for(let l=0;l<this.cols;l++)r=r.plus(this.data[i][l].mul(a.data[l]));e.push(r)}return new k3(e)}add(t){if(t instanceof s3){if(this.rows!==t.rows||this.cols!==t.cols)throw Error("shape mismatch: matrices must have same dimensions");return new s3(this.data.map((a,e)=>a.map((i,r)=>i.plus(t.data[e][r]))))}else{let a=g5(t);return new s3(this.data.map((e)=>e.map((i)=>i.plus(a))))}}sub(t){if(t instanceof s3){if(this.rows!==t.rows||this.cols!==t.cols)throw Error("shape mismatch: matrices must have same dimensions");return new s3(this.data.map((a,e)=>a.map((i,r)=>i.minus(t.data[e][r]))))}else{let a=g5(t);return new s3(this.data.map((e)=>e.map((i)=>i.minus(a))))}}mul(t){if(t instanceof s3){if(this.cols!==t.rows)throw Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let a=Array.from({length:this.rows},()=>Array.from({length:t.cols},()=>new h(0)));for(let e=0;e<this.rows;e++)for(let i=0;i<this.cols;i++){let r=this.data[e][i];if(r.isZero())continue;for(let l=0;l<t.cols;l++)a[e][l]=a[e][l].plus(r.mul(t.data[i][l]))}return new s3(a)}else{let a=g5(t);return new s3(this.data.map((e)=>e.map((i)=>i.mul(a))))}}div(t){let a=g5(t);if(a.isZero())throw Error("Cannot divide by zero");return new s3(this.data.map((e)=>e.map((i)=>i.div(a))))}negate(){return new s3(this.data.map((t)=>t.map((a)=>a.negated())))}transpose(){let t=Array.from({length:this.cols},(a,e)=>Array.from({length:this.rows},(i,r)=>new h(this.data[r][e])));return new s3(t)}trace(){if(!this.isSquare())throw Error("Trace only defined for square matrices");let t=new h(0);for(let a=0;a<this.rows;a++)t=t.plus(this.data[a][a]);return t}equals(t,a=0){if(!(t instanceof s3))return!1;if(this.rows!==t.rows||this.cols!==t.cols)return!1;let e=g5(a);if(e.isNegative()||!e.isFinite())throw Error("tolerance must be non-negative and finite");for(let i=0;i<this.rows;i++)for(let r=0;r<this.cols;r++)if(this.data[i][r].minus(t.data[i][r]).abs().greaterThan(e))return!1;return!0}lu(){if(!this.isSquare())throw Error("LU decomposition requires square matrix");let t=this.rows,a=this.data.map((o)=>o.map((x)=>new h(x))),e=Array.from({length:t},(o,x)=>x),i=Array.from({length:t},()=>Array.from({length:t},()=>new h(0)));for(let o=0;o<t;o++)i[o][o]=new h(1);for(let o=0;o<t;o++){let x=o,p=a[o][o].abs();for(let n=o+1;n<t;n++){let c=a[n][o].abs();if(c.greaterThan(p))p=c,x=n}if(a[x][o].isZero())throw Error("Singular matrix: LU decomposition failed");if(x!==o){let n=a[o];a[o]=a[x],a[x]=n;let c=e[o];e[o]=e[x],e[x]=c;for(let s=0;s<o;s++){let m=i[o][s];i[o][s]=i[x][s],i[x][s]=m}}for(let n=o+1;n<t;n++){let c=a[n][o].div(a[o][o]);i[n][o]=c;for(let s=o;s<t;s++)a[n][s]=a[n][s].minus(c.mul(a[o][s]))}}let r=Array.from({length:t},(o,x)=>Array.from({length:t},(p,n)=>n<x?new h(0):a[x][n])),l=s3.zeros(t,t);for(let o=0;o<t;o++)l.data[o][e[o]]=new h(1);return{L:new s3(i),U:new s3(r),P:l}}determinant(){if(!this.isSquare())throw Error("Determinant only defined for square matrices");let t=this.rows,{L:a,U:e,P:i}=this.lu(),r=new h(1);for(let x=0;x<t;x++)r=r.mul(e.data[x][x]);let l=[];for(let x=0;x<t;x++)for(let p=0;p<t;p++)if(i.data[x][p].equals(1))l.push(p);let o=0;for(let x=0;x<l.length;x++)for(let p=x+1;p<l.length;p++)if(l[x]>l[p])o++;if(o%2===1)r=r.negated();return r}inverse(){if(!this.isSquare())throw Error("Inverse only defined for square matrices");let t=this.rows,a=Array.from({length:t},(i,r)=>Array.from({length:2*t},(l,o)=>o<t?new h(this.data[r][o]):o-t===r?new h(1):new h(0)));for(let i=0;i<t;i++){let r=i,l=a[i][i].abs();for(let x=i+1;x<t;x++){let p=a[x][i].abs();if(p.greaterThan(l))l=p,r=x}if(a[r][i].isZero())throw Error("Singular matrix: inverse does not exist");if(r!==i){let x=a[i];a[i]=a[r],a[r]=x}let o=a[i][i];for(let x=0;x<2*t;x++)a[i][x]=a[i][x].div(o);for(let x=0;x<t;x++){if(x===i)continue;let p=a[x][i];if(p.isZero())continue;for(let n=0;n<2*t;n++)a[x][n]=a[x][n].minus(p.mul(a[i][n]))}}let e=a.map((i)=>i.slice(t));return new s3(e)}solve(t){let a;if(t instanceof k3)a=t;else if(Array.isArray(t))a=k3.from(t);else throw Error("b must be Vector or array");if(!this.isSquare())throw Error("solve() only implemented for square matrices");let e=this.rows;if(a.length!==e)throw Error("dimension mismatch: b length must equal matrix rows");let i=Array.from({length:e},(l,o)=>Array.from({length:e+1},(x,p)=>new h(p<e?this.data[o][p]:a.data[o])));for(let l=0;l<e;l++){let o=l,x=i[l][l].abs();for(let p=l+1;p<e;p++){let n=i[p][l].abs();if(n.greaterThan(x))x=n,o=p}if(i[o][l].isZero())throw Error("Singular matrix: no unique solution");if(o!==l){let p=i[l];i[l]=i[o],i[o]=p}for(let p=l+1;p<e;p++){let n=i[p][l].div(i[l][l]);if(n.isZero())continue;for(let c=l;c<e+1;c++)i[p][c]=i[p][c].minus(n.mul(i[l][c]))}}let r=Array.from({length:e},()=>new h(0));for(let l=e-1;l>=0;l--){if(i[l][l].isZero())throw Error("Zero diagonal element in back substitution: system is singular");let o=new h(0);for(let x=l+1;x<e;x++)o=o.plus(i[l][x].mul(r[x]));r[l]=i[l][e].minus(o).div(i[l][l])}return new k3(r)}qr(){let t=this.rows,a=this.cols,e=this.data.map((l)=>l.map((o)=>new h(o))),i=s3.identity(t).data;for(let l=0;l<Math.min(t,a);l++){let o=[];for(let s=l;s<t;s++)o.push(e[s][l]);let x=new h(0);for(let s of o)x=x.plus(s.mul(s));if(x=x.sqrt(),x.isZero())continue;let p=o[0].isNegative()?new h(-1):new h(1),n=o.slice();n[0]=n[0].plus(p.mul(x));let c=new h(0);for(let s of n)c=c.plus(s.mul(s));if(c=c.sqrt(),c.isZero())continue;for(let s=0;s<n.length;s++)n[s]=n[s].div(c);for(let s=l;s<a;s++){let m=new h(0);for(let g=0;g<n.length;g++)m=m.plus(n[g].mul(e[l+g][s]));for(let g=0;g<n.length;g++)e[l+g][s]=e[l+g][s].minus(new h(2).mul(n[g]).mul(m))}for(let s=0;s<t;s++){let m=new h(0);for(let g=0;g<n.length;g++)m=m.plus(n[g].mul(i[l+g][s]));for(let g=0;g<n.length;g++)i[l+g][s]=i[l+g][s].minus(new h(2).mul(n[g]).mul(m))}}let r=Array.from({length:t},(l,o)=>Array.from({length:a},(x,p)=>o<=p?e[o][p]:new h(0)));return{Q:new s3(i).transpose(),R:new s3(r)}}exp(t={}){let a=this.rows;if(!this.isSquare())throw Error("Matrix exponential requires square matrix");let e=s3.identity(a),i=t.maxIter||120;if(!Number.isInteger(i)||i<=0)throw Error("maxIter must be a positive integer");let r=new h(t.tolerance||"1e-40");if(r.isNegative()||r.isZero()||!r.isFinite())throw Error("tolerance must be positive and finite");let l=((c)=>{let s=new h(0);for(let m=0;m<c.rows;m++){let g=new h(0);for(let u=0;u<c.cols;u++)g=g.plus(c.data[m][u].abs());if(g.greaterThan(s))s=g}return s})(this),o=0;if(l.greaterThan(new h(1))){let c=l.toNumber();if(!isFinite(c))throw Error("Matrix norm too large for exponential computation");if(o=Math.max(0,Math.ceil(Math.log2(c))),o>50)throw Error(`Matrix norm too large: requires ${o} scaling steps (max 50 allowed)`)}let x=this;if(o>0)x=this.mul(new h(1).div(new h(2).pow(o)));let p=e.clone(),n=e.clone();for(let c=1;c<i;c++){p=p.mul(x).mul(new h(1).div(c)),n=n.add(p);let s=new h(0);for(let m=0;m<p.rows;m++)for(let g=0;g<p.cols;g++)s=s.plus(p.data[m][g].abs());if(s.lessThan(r))break}for(let c=0;c<o;c++)n=n.mul(n);return n}}var Ot={};U4(Ot,{translation:()=>g4,stretchAlongAxis:()=>yi,skew:()=>i2,scale:()=>n5,rotateAroundPoint:()=>Vt,rotate:()=>L5,reflectY:()=>vi,reflectX:()=>hi,reflectOrigin:()=>ui,applyTransform:()=>e4});var i4=(t)=>{if(t instanceof h){if(!t.isFinite())throw Error(`Value must be finite (got ${t.toString()})`);return t}try{let a=new h(t);if(!a.isFinite())throw Error(`Value must be finite (got ${t})`);return a}catch(a){throw Error(`Invalid numeric value: "${t}" (${a.message})`)}};function J3(t,a){if(t===void 0||t===null)throw Error(`${a} is required`);if(typeof t!=="number"&&typeof t!=="string"&&!(t instanceof h))throw Error(`${a} must be a number, string, or Decimal`);if(typeof t==="number"&&!isFinite(t))throw Error(`${a} must be a finite number (got ${t})`);if(t instanceof h&&!t.isFinite())throw Error(`${a} must be a finite Decimal (got ${t.toString()})`)}function g4(t,a){return J3(t,"tx"),J3(a,"ty"),s3.from([[new h(1),new h(0),i4(t)],[new h(0),new h(1),i4(a)],[new h(0),new h(0),new h(1)]])}function n5(t,a=null){if(J3(t,"sx"),a!==null)J3(a,"sy");let e=a===null?t:a,i=i4(t),r=i4(e);if(i.isZero()||r.isZero())throw Error("Scale factors cannot be zero (creates singular matrix)");return s3.from([[i,new h(0),new h(0)],[new h(0),r,new h(0)],[new h(0),new h(0),new h(1)]])}function L5(t){J3(t,"theta");let a=i4(t).toNumber(),e=Math.PI,i=a-2*e*Math.floor((a+e)/(2*e));if(!isFinite(i))throw Error(`Angle normalization failed for theta=${t} (too large or invalid)`);let r=new h(Math.cos(i)),l=new h(Math.sin(i));if(!r.isFinite()||!l.isFinite())throw Error(`Trigonometric computation failed for theta=${t} (produced non-finite values)`);return s3.from([[r,l.negated(),new h(0)],[l,r,new h(0)],[new h(0),new h(0),new h(1)]])}function Vt(t,a,e){J3(t,"theta"),J3(a,"px"),J3(e,"py");let i=i4(a),r=i4(e);return g4(i,r).mul(L5(t)).mul(g4(i.negated(),r.negated()))}function i2(t,a){J3(t,"ax"),J3(a,"ay");let e=i4(t),i=i4(a);if(new h(1).minus(e.mul(i)).lessThanOrEqualTo(0))throw Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${e.mul(i).toString()}, must be < 1)`);return s3.from([[new h(1),e,new h(0)],[i,new h(1),new h(0)],[new h(0),new h(0),new h(1)]])}function yi(t,a,e){J3(t,"ux"),J3(a,"uy"),J3(e,"k");let i=i4(t),r=i4(a),l=i4(e);if(l.isZero())throw Error("Stretch factor k cannot be zero (creates singular matrix)");let o=i.mul(i).plus(r.mul(r));if(o.isZero())throw Error("Axis vector (ux, uy) cannot be zero");let x=o.minus(1).abs(),p=new h(0.000001);if(x.greaterThan(p))throw Error(`Axis vector (ux, uy) must be normalized (||u|| = 1). Current magnitude squared: ${o.toString()}, expected: 1. Use normalized vector: (${i.div(o.sqrt()).toString()}, ${r.div(o.sqrt()).toString()})`);let n=new h(1),c=l.minus(n),s=n.plus(c.mul(i.mul(i))),m=c.mul(i.mul(r)),g=c.mul(r.mul(i)),u=n.plus(c.mul(r.mul(r)));return s3.from([[s,m,new h(0)],[g,u,new h(0)],[new h(0),new h(0),new h(1)]])}function e4(t,a,e){if(!t||typeof t.mul!=="function")throw Error("applyTransform: first argument must be a Matrix");if(!t.data||!Array.isArray(t.data)||t.data.length!==3||!t.data[0]||t.data[0].length!==3||!t.data[1]||t.data[1].length!==3||!t.data[2]||t.data[2].length!==3)throw Error("applyTransform: matrix must be 3x3");J3(a,"x"),J3(e,"y");let i=s3.from([[i4(a)],[i4(e)],[new h(1)]]),r=t.mul(i);if(!r||!r.data||!Array.isArray(r.data)||r.data.length!==3||!r.data[0]||!r.data[0][0]||!r.data[1]||!r.data[1][0]||!r.data[2]||!r.data[2][0])throw Error("applyTransform: matrix multiplication produced invalid result");let l=r.data[0][0],o=r.data[1][0],x=r.data[2][0];if(x.isZero())throw Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[l.div(x),o.div(x)]}function hi(){return s3.from([[new h(1),new h(0),new h(0)],[new h(0),new h(-1),new h(0)],[new h(0),new h(0),new h(1)]])}function vi(){return s3.from([[new h(-1),new h(0),new h(0)],[new h(0),new h(1),new h(0)],[new h(0),new h(0),new h(1)]])}function ui(){return s3.from([[new h(-1),new h(0),new h(0)],[new h(0),new h(-1),new h(0)],[new h(0),new h(0),new h(1)]])}var Ut={};U4(Ut,{translation:()=>r2,scale:()=>Ei,rotateZ:()=>Pi,rotateY:()=>bi,rotateX:()=>Ci,rotateAroundPoint:()=>Si,rotateAroundAxis:()=>Mt,reflectYZ:()=>di,reflectXZ:()=>fi,reflectXY:()=>Ai,reflectOrigin:()=>Ni,applyTransform:()=>Ti});var j3=(t)=>{if(t instanceof h)return t;try{let a=new h(t);if(!a.isFinite())throw Error(`Value must be finite, got ${t}`);return a}catch(a){throw Error(`Invalid numeric value: ${t}`)}};function V3(t,a){if(t===void 0||t===null)throw Error(`${a} is required`);if(typeof t!=="number"&&typeof t!=="string"&&!(t instanceof h))throw Error(`${a} must be a number, string, or Decimal`)}function T0(t){let a=t.toNumber();if(!Number.isFinite(a))throw Error(`Angle must be finite, got ${t}`);if(Math.abs(a)<=6.283185307179586)return a;let e=6.283185307179586,i=a%e;if(i>e)i-=e;else if(i<-e)i+=e;return i}function r2(t,a,e){return V3(t,"tx"),V3(a,"ty"),V3(e,"tz"),s3.from([[new h(1),new h(0),new h(0),j3(t)],[new h(0),new h(1),new h(0),j3(a)],[new h(0),new h(0),new h(1),j3(e)],[new h(0),new h(0),new h(0),new h(1)]])}function Ei(t,a=null,e=null){if(V3(t,"sx"),a!==null)V3(a,"sy");if(e!==null)V3(e,"sz");let i=a===null?t:a,r=e===null?t:e,l=j3(t),o=j3(i),x=j3(r);if(l.isZero()||o.isZero()||x.isZero());return s3.from([[l,new h(0),new h(0),new h(0)],[new h(0),o,new h(0),new h(0)],[new h(0),new h(0),x,new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function Ci(t){V3(t,"theta");let a=j3(t),e=T0(a),i=new h(Math.cos(e)),r=new h(Math.sin(e));return s3.from([[new h(1),new h(0),new h(0),new h(0)],[new h(0),i,r.negated(),new h(0)],[new h(0),r,i,new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function bi(t){V3(t,"theta");let a=j3(t),e=T0(a),i=new h(Math.cos(e)),r=new h(Math.sin(e));return s3.from([[i,new h(0),r,new h(0)],[new h(0),new h(1),new h(0),new h(0)],[r.negated(),new h(0),i,new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function Pi(t){V3(t,"theta");let a=j3(t),e=T0(a),i=new h(Math.cos(e)),r=new h(Math.sin(e));return s3.from([[i,r.negated(),new h(0),new h(0)],[r,i,new h(0),new h(0)],[new h(0),new h(0),new h(1),new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function Mt(t,a,e,i){V3(t,"ux"),V3(a,"uy"),V3(e,"uz"),V3(i,"theta");let r=[j3(t),j3(a),j3(e)],l=r[0].mul(r[0]).plus(r[1].mul(r[1])).plus(r[2].mul(r[2])).sqrt();if(l.isZero())throw Error("Rotation axis cannot be zero vector (ux=0, uy=0, uz=0)");r[0]=r[0].div(l),r[1]=r[1].div(l),r[2]=r[2].div(l);let o=j3(i),x=T0(o),p=new h(Math.cos(x)),n=new h(Math.sin(x)),c=new h(1),s=r[0].mul(r[0]),m=r[1].mul(r[1]),g=r[2].mul(r[2]),u=s.plus(p.mul(c.minus(s))),y=r[0].mul(r[1]).mul(c.minus(p)).minus(r[2].mul(n)),v=r[0].mul(r[2]).mul(c.minus(p)).plus(r[1].mul(n)),E=r[1].mul(r[0]).mul(c.minus(p)).plus(r[2].mul(n)),C=m.plus(p.mul(c.minus(m))),P=r[1].mul(r[2]).mul(c.minus(p)).minus(r[0].mul(n)),S=r[2].mul(r[0]).mul(c.minus(p)).minus(r[1].mul(n)),f=r[2].mul(r[1]).mul(c.minus(p)).plus(r[0].mul(n)),B=g.plus(p.mul(c.minus(g)));return s3.from([[u,y,v,new h(0)],[E,C,P,new h(0)],[S,f,B,new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function Si(t,a,e,i,r,l,o){V3(t,"ux"),V3(a,"uy"),V3(e,"uz"),V3(i,"theta"),V3(r,"px"),V3(l,"py"),V3(o,"pz");let x=j3(r),p=j3(l),n=j3(o);return r2(x,p,n).mul(Mt(t,a,e,i)).mul(r2(x.negated(),p.negated(),n.negated()))}function Ti(t,a,e,i){if(!(t instanceof s3))throw Error("M must be a Matrix instance");if(t.rows!==4||t.cols!==4)throw Error(`M must be a 4x4 matrix, got ${t.rows}x${t.cols}`);V3(a,"x"),V3(e,"y"),V3(i,"z");let r=s3.from([[j3(a)],[j3(e)],[j3(i)],[new h(1)]]),l=t.mul(r),o=l.data[0][0],x=l.data[1][0],p=l.data[2][0],n=l.data[3][0];if(n.isZero())throw Error("Perspective division by zero: transformation results in point at infinity");return[o.div(n),x.div(n),p.div(n)]}function Ai(){return s3.from([[new h(1),new h(0),new h(0),new h(0)],[new h(0),new h(1),new h(0),new h(0)],[new h(0),new h(0),new h(-1),new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function fi(){return s3.from([[new h(1),new h(0),new h(0),new h(0)],[new h(0),new h(-1),new h(0),new h(0)],[new h(0),new h(0),new h(1),new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function di(){return s3.from([[new h(-1),new h(0),new h(0),new h(0)],[new h(0),new h(1),new h(0),new h(0)],[new h(0),new h(0),new h(1),new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}function Ni(){return s3.from([[new h(-1),new h(0),new h(0),new h(0)],[new h(0),new h(-1),new h(0),new h(0)],[new h(0),new h(0),new h(-1),new h(0)],[new h(0),new h(0),new h(0),new h(1)]])}var E2={};U4(E2,{validateXML:()=>G9,validateSVGAsync:()=>Yo,validateSVG:()=>j9,straightCurves:()=>Ya,sortDefsChildren:()=>E9,sortAttrs:()=>u9,simplifyPaths:()=>J9,simplifyPath:()=>q9,saveOutput:()=>Wa,reusePaths:()=>C9,removeXlink:()=>S9,removeXMLProcInst:()=>t9,removeXMLNS:()=>l9,removeViewBox:()=>r9,removeUselessDefs:()=>Za,removeUselessCommands:()=>Va,removeUnknownsAndDefaults:()=>qa,removeTitle:()=>a9,removeStyleElement:()=>P9,removeScriptElement:()=>x9,removeRasterImages:()=>o9,removeOffCanvasPath:()=>b9,removeNonInheritableGroupAttrs:()=>Ka,removeMetadata:()=>Y0,removeLeadingZero:()=>Ia,removeHiddenElements:()=>w0,removeEmptyText:()=>Ja,removeEmptyContainers:()=>L0,removeEmptyAttrs:()=>i9,removeElementsByAttr:()=>B9,removeEditorsNSData:()=>G2,removeDoctype:()=>$a,removeDimensions:()=>d9,removeDesc:()=>e9,removeComments:()=>k0,removeAttrs:()=>I9,removeAttributesBySelector:()=>N9,printHierarchicalMatrix:()=>No,presetNone:()=>H2,presetDefault:()=>z2,prefixIds:()=>f9,optimizePaths:()=>Z9,optimizeAnimationTiming:()=>K9,optimize:()=>R9,negativeExtraSpace:()=>Ba,moveGroupAttrsToElems:()=>y9,moveElemsAttrsToGroup:()=>h9,minifyStyles:()=>W2,mergePaths:()=>g9,measureDistance:()=>F9,loadInput:()=>F5,lineShorthands:()=>wa,inlineStyles:()=>v9,imageToPath:()=>M9,generateOutput:()=>G5,generateFullCompatibilityMatrix:()=>fo,generateFlexibleSVGTable:()=>W9,generateCompatibilityMatrixSVG_legacy:()=>Io,generateCompatibilityMatrixSVG:()=>Bo,generateCompatibilityMatrixFlexible:()=>Do,formatPrecision:()=>ja,floatPrecision:()=>Oa,flattenUseElements:()=>U9,flattenPatterns:()=>O9,flattenMasks:()=>k9,flattenGradients:()=>Y9,flattenFilters:()=>V9,flattenClipPaths:()=>L9,flattenAll:()=>Q9,fixInvalidSVG:()=>z9,exportEmbeddedResources:()=>ae,escapeXml:()=>yo,embedExternalDependencies:()=>q2,detectOutputTarget:()=>_2,detectInputType:()=>A5,detectCollisions:()=>_9,default:()=>Zo,decomposeTransform:()=>$9,createOperation:()=>p3,createConfig:()=>w9,convertTransform:()=>c9,convertToZ:()=>La,convertToRelative:()=>Da,convertToAbsolute:()=>Ra,convertStyleToAttrs:()=>j2,convertShapesToPath:()=>n9,convertQuadraticToSmooth:()=>Ma,convertPathData:()=>p9,convertEllipseToCircle:()=>s9,convertCubicToSmooth:()=>_a,convertCubicToQuadratic:()=>Ua,convertColors:()=>X0,collapseRepeated:()=>Xa,collapseGroups:()=>m9,cleanupNumericValues:()=>R0,cleanupListOfValues:()=>za,cleanupIds:()=>F2,cleanupEnableBackground:()=>Qa,cleanupAttributes:()=>Ha,arcShorthands:()=>Fa,applyPreset:()=>D9,analyzeCompatibilityMatrix:()=>Ao,analyzeCompatibility:()=>Co,addClassesToSVGElement:()=>A9,addAttributesToSVGElement:()=>T9,ValidationSeverity:()=>f3,PRECISION_LEVELS:()=>Ga,OutputTarget:()=>c4,OutputFormat:()=>h4,MAX_PRECISION:()=>O5,InputType:()=>Y3,DEFAULT_PRECISION:()=>u0});h.set({precision:80});var cx=new h("1e-40"),sx=new h("1e-10");h.set({precision:80});var O3=(t)=>t instanceof h?t:new h(t),Ii=new h("1e-40"),Bi=new h("1e-30");function Di(t,a){if(t==null)throw TypeError("translationMatrix: tx parameter is required");if(a==null)throw TypeError("translationMatrix: ty parameter is required");return s3.from([[1,0,O3(t)],[0,1,O3(a)],[0,0,1]])}function Ri(t){if(t==null)throw TypeError("rotationMatrix: angle parameter is required");let a=O3(t),e=h.cos(a),i=h.sin(a);return s3.from([[e,i.neg(),0],[i,e,0],[0,0,1]])}function wi(t,a){if(t==null)throw TypeError("scaleMatrix: sx parameter is required");if(a==null)throw TypeError("scaleMatrix: sy parameter is required");return s3.from([[O3(t),0,0],[0,O3(a),0],[0,0,1]])}function Li(t){if(t==null)throw TypeError("skewXMatrix: angle parameter is required");let a=h.tan(O3(t));return s3.from([[1,a,0],[0,1,0],[0,0,1]])}function ki(t){if(t==null)throw TypeError("skewYMatrix: angle parameter is required");let a=h.tan(O3(t));return s3.from([[1,0,0],[a,1,0],[0,0,1]])}function Yi(t){if(!t)throw TypeError("extractLinearPart: matrix parameter is required");if(!t.data)throw TypeError("extractLinearPart: matrix must have data property");if(t.rows<2||t.cols<2)throw RangeError("extractLinearPart: matrix must be at least 2x2");let a=t.data;return{a:a[0][0],b:a[1][0],c:a[0][1],d:a[1][1]}}function Xi(t){if(!t)throw TypeError("extractTranslation: matrix parameter is required");if(!t.data)throw TypeError("extractTranslation: matrix must have data property");if(t.rows<2||t.cols<3)throw RangeError("extractTranslation: matrix must be at least 2x3");let a=t.data;return{tx:a[0][2],ty:a[1][2]}}function Oi(t){if(!t)throw TypeError("decomposeMatrix: matrix parameter is required");let{a,b:e,c:i,d:r}=Yi(t),{tx:l,ty:o}=Xi(t),x=a.mul(r).minus(e.mul(i)),p=a.mul(a).plus(e.mul(e)).sqrt();if(p.abs().lessThan(Ii))return{translateX:l,translateY:o,rotation:O3(0),scaleX:O3(0),scaleY:O3(0),skewX:O3(0),skewY:O3(0),verified:!1,maxError:O3("Infinity"),singular:!0};let n=x.div(p);if(n.abs().greaterThan(new h("1e40")))return{translateX:l,translateY:o,rotation:O3(0),scaleX:O3(0),scaleY:O3(0),skewX:O3(0),skewY:O3(0),verified:!1,maxError:O3("Infinity"),singular:!0};if(x.lessThan(0))p=p.neg(),n=n.neg();let c=h.atan2(e,a),s=h.cos(c),m=h.sin(c),g=a.mul(s).plus(e.mul(m)),u=i.mul(s).plus(r.mul(m)),y,v=new h("1e-30");if(g.abs().greaterThan(v)){let f=u.div(g);if(f.abs().greaterThan(new h("1e10")))y=O3(0);else y=h.atan(f)}else y=O3(0);let E=O3(0),C=Vi({translateX:l,translateY:o,rotation:c,scaleX:p,scaleY:n,skewX:y,skewY:O3(0)}),P=Ui(t,C),S=P.lessThan(Bi);return{translateX:l,translateY:o,rotation:c,scaleX:p,scaleY:n,skewX:y,skewY:E,verified:S,maxError:P}}function Vi(t){if(!t)throw TypeError("composeTransform: components parameter is required");if(t.translateX==null)throw TypeError("composeTransform: components.translateX is required");if(t.translateY==null)throw TypeError("composeTransform: components.translateY is required");if(t.rotation==null)throw TypeError("composeTransform: components.rotation is required");if(t.scaleX==null)throw TypeError("composeTransform: components.scaleX is required");if(t.scaleY==null)throw TypeError("composeTransform: components.scaleY is required");if(t.skewX==null)throw TypeError("composeTransform: components.skewX is required");let{translateX:a,translateY:e,rotation:i,scaleX:r,scaleY:l,skewX:o,skewY:x=0}=t,p=Di(a,e),n=Ri(i),c=Li(o),s=ki(x),m=wi(r,l);return p.mul(n).mul(s).mul(c).mul(m)}function Ui(t,a){if(!t)throw TypeError("matrixMaxDifference: m1 parameter is required");if(!a)throw TypeError("matrixMaxDifference: m2 parameter is required");if(!t.data)throw TypeError("matrixMaxDifference: m1 must have data property");if(!a.data)throw TypeError("matrixMaxDifference: m2 must have data property");if(t.rows!==a.rows||t.cols!==a.cols)throw RangeError(`matrixMaxDifference: matrices must have same dimensions (${t.rows}x${t.cols} vs ${a.rows}x${a.cols})`);let e=O3(0);for(let i=0;i<t.rows;i++)for(let r=0;r<t.cols;r++){let l=t.data[i][r].minus(a.data[i][r]).abs();if(l.greaterThan(e))e=l}return e}h.set({precision:80});var y4=(t)=>t instanceof h?t:new h(t),U3=new h("1e-40"),u6=100;function k4(t,a){if(t==null)throw TypeError("point: x coordinate cannot be null or undefined");if(a==null)throw TypeError("point: y coordinate cannot be null or undefined");return{x:y4(t),y:y4(a)}}function Mi(t,a){if(!t||t.x==null||t.y==null)throw TypeError("vectorAdd: first vector must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("vectorAdd: second vector must have x and y properties");return{x:t.x.plus(a.x),y:t.y.plus(a.y)}}function F3(t,a){if(!t||t.x==null||t.y==null)throw TypeError("vectorSub: first vector must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("vectorSub: second vector must have x and y properties");return{x:t.x.minus(a.x),y:t.y.minus(a.y)}}function k5(t){if(!t||t.x==null||t.y==null)throw TypeError("vectorNeg: vector must have x and y properties");return{x:t.x.neg(),y:t.y.neg()}}function l2(t,a){if(!t||t.x==null||t.y==null)throw TypeError("vectorScale: vector must have x and y properties");if(a==null)throw TypeError("vectorScale: scale factor cannot be null or undefined");let e=y4(a);return{x:t.x.mul(e),y:t.y.mul(e)}}function a4(t,a){if(!t||t.x==null||t.y==null)throw TypeError("dot: first vector must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("dot: second vector must have x and y properties");return t.x.mul(a.x).plus(t.y.mul(a.y))}function B5(t,a){if(!t||t.x==null||t.y==null)throw TypeError("cross: first vector must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("cross: second vector must have x and y properties");return t.x.mul(a.y).minus(t.y.mul(a.x))}function s4(t){if(!t||t.x==null||t.y==null)throw TypeError("magnitudeSquared: vector must have x and y properties");return t.x.mul(t.x).plus(t.y.mul(t.y))}function r5(t){if(!t||t.x==null||t.y==null)throw TypeError("magnitude: vector must have x and y properties");return s4(t).sqrt()}function _i(t){if(!t||t.x==null||t.y==null)throw TypeError("normalize: vector must have x and y properties");let a=r5(t);if(a.lessThan(U3))return{x:y4(0),y:y4(0)};return{x:t.x.div(a),y:t.y.div(a)}}function G4(t,a,e){if(!t||t.x==null||t.y==null)throw TypeError("tripleProduct: first vector must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("tripleProduct: second vector must have x and y properties");if(!e||e.x==null||e.y==null)throw TypeError("tripleProduct: third vector must have x and y properties");let i=a4(t,e),r=a4(a,e);return F3(l2(a,i),l2(t,r))}function E6(t,a){if(!Array.isArray(t))throw TypeError("supportPoint: polygon must be an array");if(!a||a.x==null||a.y==null)throw TypeError("supportPoint: direction must have x and y properties");if(t.length===0)throw TypeError("supportPoint: polygon cannot be empty");if(!t[0]||t[0].x==null||t[0].y==null)throw TypeError("supportPoint: polygon[0] must have x and y properties");let e=a4(t[0],a),i=t[0];for(let r=1;r<t.length;r++){if(!t[r]||t[r].x==null||t[r].y==null)throw TypeError(`supportPoint: polygon[${r}] must have x and y properties`);let l=a4(t[r],a);if(l.greaterThan(e))e=l,i=t[r]}return i}function C6(t,a,e){if(!Array.isArray(t))throw TypeError("minkowskiSupport: polygonA must be an array");if(!Array.isArray(a))throw TypeError("minkowskiSupport: polygonB must be an array");if(!e||e.x==null||e.y==null)throw TypeError("minkowskiSupport: direction must have x and y properties");let i=E6(t,e),r=E6(a,k5(e));return F3(i,r)}function Fi(t,a){if(!Array.isArray(t))throw TypeError("processLineSimplex: simplex must be an array");if(t.length!==2)throw TypeError("processLineSimplex: simplex must have exactly 2 points");if(!a||a.x==null||a.y==null)throw TypeError("processLineSimplex: direction must have x and y properties");if(!t[0]||t[0].x==null||t[0].y==null)throw TypeError("processLineSimplex: simplex[0] must have x and y properties");if(!t[1]||t[1].x==null||t[1].y==null)throw TypeError("processLineSimplex: simplex[1] must have x and y properties");let e=t[0],i=t[1],r=F3(i,e),l=k5(e),o=s4(r);if(o.lessThan(U3)){if(s4(e).lessThan(U3))return{contains:!0,newDirection:a};return{contains:!1,newDirection:l}}let x=G4(r,l,r);if(s4(x).lessThan(U3)){let p=a4(r,l);if(p.greaterThanOrEqualTo(0)&&p.lessThanOrEqualTo(o))return{contains:!0,newDirection:a};return{contains:!1,newDirection:l}}return{contains:!1,newDirection:x}}function Gi(t,a){if(!Array.isArray(t))throw TypeError("processTriangleSimplex: simplex must be an array");if(t.length!==3)throw TypeError("processTriangleSimplex: simplex must have exactly 3 points");if(!a||a.x==null||a.y==null)throw TypeError("processTriangleSimplex: direction must have x and y properties");if(!t[0]||t[0].x==null||t[0].y==null)throw TypeError("processTriangleSimplex: simplex[0] must have x and y properties");if(!t[1]||t[1].x==null||t[1].y==null)throw TypeError("processTriangleSimplex: simplex[1] must have x and y properties");if(!t[2]||t[2].x==null||t[2].y==null)throw TypeError("processTriangleSimplex: simplex[2] must have x and y properties");let e=t[0],i=t[1],r=t[2],l=F3(i,e),o=F3(r,e),x=k5(e),p=s4(l),n=s4(o);if(p.lessThan(U3))return{contains:!1,newDirection:G4(o,x,o),newSimplex:[e,r]};if(n.lessThan(U3))return{contains:!1,newDirection:G4(l,x,l),newSimplex:[e,i]};let c=G4(o,l,l),s=G4(l,o,o);if(s4(c).lessThan(U3)&&s4(s).lessThan(U3)){let m=F3(r,i),g=s4(m);if(g.greaterThan(p)&&g.greaterThan(n))return{contains:!1,newDirection:G4(m,k5(i),m),newSimplex:[i,r]};else if(p.greaterThan(n))return{contains:!1,newDirection:G4(l,x,l),newSimplex:[e,i]};else return{contains:!1,newDirection:G4(o,x,o),newSimplex:[e,r]}}if(a4(c,x).greaterThan(U3))return{contains:!1,newDirection:c,newSimplex:[e,i]};if(a4(s,x).greaterThan(U3))return{contains:!1,newDirection:s,newSimplex:[e,r]};return{contains:!0,newDirection:a,newSimplex:t}}function _t(t,a){if(!Array.isArray(t))throw TypeError("gjkIntersects: polygonA must be an array");if(!Array.isArray(a))throw TypeError("gjkIntersects: polygonB must be an array");if(t.length===0||a.length===0)return{intersects:!1,iterations:0,simplex:[],verified:!0};if(t.length===1&&a.length===1){if(!t[0]||t[0].x==null||t[0].y==null)throw TypeError("gjkIntersects: polygonA[0] must have x and y properties");if(!a[0]||a[0].x==null||a[0].y==null)throw TypeError("gjkIntersects: polygonB[0] must have x and y properties");return{intersects:r5(F3(t[0],a[0])).lessThan(U3),iterations:1,simplex:[],verified:!0}}let e=F3(p0(a),p0(t));if(s4(e).lessThan(U3))e=k4(1,0);let i=[C6(t,a,e)];if(e=k5(i[0]),s4(i[0]).lessThan(U3))return{intersects:!0,iterations:1,simplex:i,verified:j0(t,a)};for(let r=0;r<u6;r++){let l=C6(t,a,e);if(a4(l,e).lessThanOrEqualTo(y4(0)))return{intersects:!1,iterations:r+1,simplex:i,verified:!0};if(i.unshift(l),i.length===2){let o=Fi(i,e);if(o.contains)return{intersects:!0,iterations:r+1,simplex:i,verified:j0(t,a)};e=o.newDirection}else if(i.length===3){let o=Gi(i,e);if(o.contains)return{intersects:!0,iterations:r+1,simplex:o.newSimplex,verified:j0(t,a)};i=o.newSimplex,e=o.newDirection}if(s4(e).lessThan(U3))return{intersects:!1,iterations:r+1,simplex:i,verified:!1};e=_i(e)}return{intersects:!1,iterations:u6,simplex:i,verified:!1}}function p0(t){if(!Array.isArray(t))throw TypeError("centroid: polygon must be an array");if(t.length===0)throw TypeError("centroid: polygon cannot be empty");let a=y4(0),e=y4(0);for(let r=0;r<t.length;r++){if(!t[r]||t[r].x==null||t[r].y==null)throw TypeError(`centroid: polygon[${r}] must have x and y properties`);a=a.plus(t[r].x),e=e.plus(t[r].y)}let i=y4(t.length);return{x:a.div(i),y:e.div(i)}}function b6(t,a){if(!t||t.x==null||t.y==null)throw TypeError("pointInConvexPolygon: point must have x and y properties");if(!Array.isArray(a))throw TypeError("pointInConvexPolygon: polygon must be an array");if(a.length<3)return!1;let e=null;for(let i=0;i<a.length;i++){let r=a[i],l=a[(i+1)%a.length];if(!r||r.x==null||r.y==null)throw TypeError(`pointInConvexPolygon: polygon[${i}] must have x and y properties`);if(!l||l.x==null||l.y==null)throw TypeError(`pointInConvexPolygon: polygon[${(i+1)%a.length}] must have x and y properties`);let o=F3(l,r),x=F3(t,r),p=B5(o,x);if(p.abs().lessThan(U3))continue;let n=p.greaterThan(0);if(e===null)e=n;else if(e!==n)return!1}return!0}function j0(t,a){if(!Array.isArray(t))throw TypeError("verifyIntersection: polygonA must be an array");if(!Array.isArray(a))throw TypeError("verifyIntersection: polygonB must be an array");for(let e=0;e<t.length;e++){if(!t[e]||t[e].x==null||t[e].y==null)throw TypeError(`verifyIntersection: polygonA[${e}] must have x and y properties`);if(b6(t[e],a))return!0}for(let e=0;e<a.length;e++){if(!a[e]||a[e].x==null||a[e].y==null)throw TypeError(`verifyIntersection: polygonB[${e}] must have x and y properties`);if(b6(a[e],t))return!0}for(let e=0;e<t.length;e++){let i=t[e],r=t[(e+1)%t.length];if(!i||i.x==null||i.y==null)throw TypeError(`verifyIntersection: polygonA[${e}] must have x and y properties`);if(!r||r.x==null||r.y==null)throw TypeError(`verifyIntersection: polygonA[${(e+1)%t.length}] must have x and y properties`);for(let l=0;l<a.length;l++){let o=a[l],x=a[(l+1)%a.length];if(!o||o.x==null||o.y==null)throw TypeError(`verifyIntersection: polygonB[${l}] must have x and y properties`);if(!x||x.x==null||x.y==null)throw TypeError(`verifyIntersection: polygonB[${(l+1)%a.length}] must have x and y properties`);if(ji(i,r,o,x))return!0}}return!1}function ji(t,a,e,i){if(!t||t.x==null||t.y==null)throw TypeError("segmentsIntersect: a1 must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("segmentsIntersect: a2 must have x and y properties");if(!e||e.x==null||e.y==null)throw TypeError("segmentsIntersect: b1 must have x and y properties");if(!i||i.x==null||i.y==null)throw TypeError("segmentsIntersect: b2 must have x and y properties");let r=F3(a,t),l=F3(i,e),o=B5(r,l);if(o.abs().lessThan(U3)){let c=F3(e,t);if(B5(r,c).abs().lessThan(U3)){let s=a4(r,r);if(s.lessThan(U3)){let v=a4(l,l);if(v.lessThan(U3))return r5(c).lessThan(U3);let E=a4(c,l).div(v);return E.greaterThanOrEqualTo(0)&&E.lessThanOrEqualTo(1)}let m=a4(c,r).div(s),g=F3(i,t),u=a4(g,r).div(s),y=h.min(m,u);return h.max(m,u).greaterThanOrEqualTo(0)&&y.lessThanOrEqualTo(1)}return!1}let x=F3(e,t),p=B5(x,l).div(o),n=B5(x,r).div(o);return p.greaterThanOrEqualTo(0)&&p.lessThanOrEqualTo(1)&&n.greaterThanOrEqualTo(0)&&n.lessThanOrEqualTo(1)}function Wi(t,a){if(!Array.isArray(t))throw TypeError("gjkDistance: polygonA must be an array");if(!Array.isArray(a))throw TypeError("gjkDistance: polygonB must be an array");if(t.length===0)throw TypeError("gjkDistance: polygonA cannot be empty");if(a.length===0)throw TypeError("gjkDistance: polygonB cannot be empty");if(_t(t,a).intersects)return{distance:y4(0),closestA:p0(t),closestB:p0(a),verified:!0};if(!t[0]||t[0].x==null||t[0].y==null)throw TypeError("gjkDistance: polygonA[0] must have x and y properties");if(!a[0]||a[0].x==null||a[0].y==null)throw TypeError("gjkDistance: polygonB[0] must have x and y properties");let e=y4(1/0),i=t[0],r=a[0];for(let o=0;o<t.length;o++){if(!t[o]||t[o].x==null||t[o].y==null)throw TypeError(`gjkDistance: polygonA[${o}] must have x and y properties`);for(let x=0;x<a.length;x++){if(!a[x]||a[x].x==null||a[x].y==null)throw TypeError(`gjkDistance: polygonB[${x}] must have x and y properties`);let p=r5(F3(t[o],a[x]));if(p.lessThan(e))e=p,i=t[o],r=a[x]}}for(let o=0;o<t.length;o++){if(!t[o]||t[o].x==null||t[o].y==null)throw TypeError(`gjkDistance: polygonA[${o}] must have x and y properties`);for(let x=0;x<a.length;x++){let p=a[x],n=a[(x+1)%a.length];if(!p||p.x==null||p.y==null)throw TypeError(`gjkDistance: polygonB[${x}] must have x and y properties`);if(!n||n.x==null||n.y==null)throw TypeError(`gjkDistance: polygonB[${(x+1)%a.length}] must have x and y properties`);let c=P6(t[o],p,n),s=r5(F3(t[o],c));if(s.lessThan(e))e=s,i=t[o],r=c}}for(let o=0;o<a.length;o++){if(!a[o]||a[o].x==null||a[o].y==null)throw TypeError(`gjkDistance: polygonB[${o}] must have x and y properties`);for(let x=0;x<t.length;x++){let p=t[x],n=t[(x+1)%t.length];if(!p||p.x==null||p.y==null)throw TypeError(`gjkDistance: polygonA[${x}] must have x and y properties`);if(!n||n.x==null||n.y==null)throw TypeError(`gjkDistance: polygonA[${(x+1)%t.length}] must have x and y properties`);let c=P6(a[o],p,n),s=r5(F3(a[o],c));if(s.lessThan(e))e=s,i=c,r=a[o]}}let l=r5(F3(i,r)).minus(e).abs().lessThan(U3);return{distance:e,closestA:i,closestB:r,verified:l}}function P6(t,a,e){if(!t||t.x==null||t.y==null)throw TypeError("closestPointOnSegment: pt must have x and y properties");if(!a||a.x==null||a.y==null)throw TypeError("closestPointOnSegment: a must have x and y properties");if(!e||e.x==null||e.y==null)throw TypeError("closestPointOnSegment: b must have x and y properties");let i=F3(e,a),r=F3(t,a),l=s4(i);if(l.lessThan(U3))return a;let o=a4(r,i).div(l);return o=h.max(y4(0),h.min(y4(1),o)),Mi(a,l2(i,o))}function Ft(t,a){if(!Array.isArray(t))throw TypeError("polygonsOverlap: polygonA must be an array");if(!Array.isArray(a))throw TypeError("polygonsOverlap: polygonB must be an array");let e=t.map((l,o)=>{if(!l||l.x==null||l.y==null)throw TypeError(`polygonsOverlap: polygonA[${o}] must have x and y properties`);return k4(l.x,l.y)}),i=a.map((l,o)=>{if(!l||l.x==null||l.y==null)throw TypeError(`polygonsOverlap: polygonB[${o}] must have x and y properties`);return k4(l.x,l.y)}),r=_t(e,i);return{overlaps:r.intersects,verified:r.verified}}function zi(t,a){if(!Array.isArray(t))throw TypeError("polygonsDistance: polygonA must be an array");if(!Array.isArray(a))throw TypeError("polygonsDistance: polygonB must be an array");let e=t.map((l,o)=>{if(!l||l.x==null||l.y==null)throw TypeError(`polygonsDistance: polygonA[${o}] must have x and y properties`);return k4(l.x,l.y)}),i=a.map((l,o)=>{if(!l||l.x==null||l.y==null)throw TypeError(`polygonsDistance: polygonB[${o}] must have x and y properties`);return k4(l.x,l.y)}),r=Wi(e,i);return{distance:r.distance,closestA:r.closestA,closestB:r.closestB,verified:r.verified}}h.set({precision:80});var mx=new h("1e-40"),gx=new h("1e-10");h.set({precision:80});var yx=new h("1e-40"),hx=new h("1e-30");h.set({precision:80});var n3=(t)=>t instanceof h?t:new h(t),vx=new h("1e-40"),Hi=new h("1e-10");function Qi(t){if(typeof t!=="string")throw Error("ViewBox must be a string");let a=t.trim().split(/[\s,]+/).filter((e)=>e.length>0);if(a.length!==4)throw Error(`Invalid viewBox format: expected 4 values, got ${a.length}`);try{let e=n3(a[0]),i=n3(a[1]),r=n3(a[2]),l=n3(a[3]);if(r.lessThanOrEqualTo(0)||l.lessThanOrEqualTo(0))throw Error("ViewBox width and height must be positive");let o=`${e.toString()} ${i.toString()} ${r.toString()} ${l.toString()}`,x=a.join(" ");return{x:e,y:i,width:r,height:l,verified:o===x}}catch(e){throw Error(`Invalid viewBox values: ${e.message}`)}}function qi(t,a,e,i){if(t==null||a==null||e==null||i==null)throw Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let r=n3(t),l=n3(a),o=n3(e),x=n3(i);if(o.lessThan(r))throw Error(`createBBox: maxX (${o}) must be >= minX (${r})`);if(x.lessThan(l))throw Error(`createBBox: maxY (${x}) must be >= minY (${l})`);return{minX:r,minY:l,maxX:o,maxY:x,width:o.minus(r),height:x.minus(l)}}function S6(t,a,e,i,r,l,o,x,p=20){if(t==null||a==null||e==null||i==null||r==null||l==null||o==null||x==null)throw Error("sampleCubicBezier: all coordinate parameters must be provided");if(p==null||p<=0)throw Error("sampleCubicBezier: samples must be a positive number");let n=[];for(let c=0;c<=p;c++){let s=n3(c).div(p),m=n3(1).minus(s),g=s.mul(s),u=g.mul(s),y=m.mul(m),v=y.mul(m),E=v.mul(t).plus(n3(3).mul(y).mul(s).mul(e)).plus(n3(3).mul(m).mul(g).mul(r)).plus(u.mul(o)),C=v.mul(a).plus(n3(3).mul(y).mul(s).mul(i)).plus(n3(3).mul(m).mul(g).mul(l)).plus(u.mul(x));n.push({x:E,y:C})}return n}function T6(t,a,e,i,r,l,o=20){if(t==null||a==null||e==null||i==null||r==null||l==null)throw Error("sampleQuadraticBezier: all coordinate parameters must be provided");if(o==null||o<=0)throw Error("sampleQuadraticBezier: samples must be a positive number");let x=[];for(let p=0;p<=o;p++){let n=n3(p).div(o),c=n3(1).minus(n),s=c.mul(c),m=n.mul(n),g=s.mul(t).plus(n3(2).mul(c).mul(n).mul(e)).plus(m.mul(r)),u=s.mul(a).plus(n3(2).mul(c).mul(n).mul(i)).plus(m.mul(l));x.push({x:g,y:u})}return x}function Ki(t,a,e=Hi){if(!t||typeof t!=="object"||t.x==null||t.y==null)throw Error("pointInBBox: pt must be an object with x and y properties");if(!a||typeof a!=="object")throw Error("pointInBBox: bbox must be a bounding box object");if(a.minX==null||a.minY==null||a.maxX==null||a.maxY==null)throw Error("pointInBBox: bbox must have minX, minY, maxX, maxY properties");return t.x.greaterThanOrEqualTo(a.minX.minus(e))&&t.x.lessThanOrEqualTo(a.maxX.plus(e))&&t.y.greaterThanOrEqualTo(a.minY.minus(e))&&t.y.lessThanOrEqualTo(a.maxY.plus(e))}function Zi(t){if(!t||t.length===0)throw Error("pathBoundingBox: path commands array is empty");let a=n3(1/0),e=n3(1/0),i=n3(-1/0),r=n3(-1/0),l=n3(0),o=n3(0),x=n3(0),p=n3(0),n=n3(0),c=n3(0),s=null,m=[];for(let y of t){if(!y||typeof y!=="object"||!y.type||typeof y.type!=="string")throw Error("pathBoundingBox: each command must be an object with a string type property");let v=y.type.toUpperCase(),E=y.type===y.type.toLowerCase();switch(v){case"M":{if(y.x==null||y.y==null)throw Error("pathBoundingBox: M command requires x and y properties");let C=E?l.plus(n3(y.x)):n3(y.x),P=E?o.plus(n3(y.y)):n3(y.y);l=C,o=P,x=l,p=o,a=h.min(a,l),e=h.min(e,o),i=h.max(i,l),r=h.max(r,o),m.push({x:l,y:o}),n=l,c=o,s="M"}break;case"L":{if(y.x==null||y.y==null)throw Error("pathBoundingBox: L command requires x and y properties");let C=E?l.plus(n3(y.x)):n3(y.x),P=E?o.plus(n3(y.y)):n3(y.y);a=h.min(a,C),e=h.min(e,P),i=h.max(i,C),r=h.max(r,P),m.push({x:C,y:P}),l=C,o=P,n=l,c=o,s="L"}break;case"H":{if(y.x==null)throw Error("pathBoundingBox: H command requires x property");let C=E?l.plus(n3(y.x)):n3(y.x);a=h.min(a,C),i=h.max(i,C),m.push({x:C,y:o}),l=C,n=l,c=o,s="H"}break;case"V":{if(y.y==null)throw Error("pathBoundingBox: V command requires y property");let C=E?o.plus(n3(y.y)):n3(y.y);e=h.min(e,C),r=h.max(r,C),m.push({x:l,y:C}),o=C,n=l,c=o,s="V"}break;case"C":{if(y.x1==null||y.y1==null||y.x2==null||y.y2==null||y.x==null||y.y==null)throw Error("pathBoundingBox: C command requires x1, y1, x2, y2, x, y properties");let C=E?l.plus(n3(y.x1)):n3(y.x1),P=E?o.plus(n3(y.y1)):n3(y.y1),S=E?l.plus(n3(y.x2)):n3(y.x2),f=E?o.plus(n3(y.y2)):n3(y.y2),B=E?l.plus(n3(y.x)):n3(y.x),R=E?o.plus(n3(y.y)):n3(y.y),k=S6(l,o,C,P,S,f,B,R,20);for(let N of k)a=h.min(a,N.x),e=h.min(e,N.y),i=h.max(i,N.x),r=h.max(r,N.y),m.push(N);n=S,c=f,l=B,o=R,s="C"}break;case"S":{if(y.x2==null||y.y2==null||y.x==null||y.y==null)throw Error("pathBoundingBox: S command requires x2, y2, x, y properties");let C=E?l.plus(n3(y.x2)):n3(y.x2),P=E?o.plus(n3(y.y2)):n3(y.y2),S=E?l.plus(n3(y.x)):n3(y.x),f=E?o.plus(n3(y.y)):n3(y.y),B,R;if(s==="C"||s==="S")B=l.mul(2).minus(n),R=o.mul(2).minus(c);else B=l,R=o;let k=S6(l,o,B,R,C,P,S,f,20);for(let N of k)a=h.min(a,N.x),e=h.min(e,N.y),i=h.max(i,N.x),r=h.max(r,N.y),m.push(N);n=C,c=P,l=S,o=f,s="S"}break;case"Q":{if(y.x1==null||y.y1==null||y.x==null||y.y==null)throw Error("pathBoundingBox: Q command requires x1, y1, x, y properties");let C=E?l.plus(n3(y.x1)):n3(y.x1),P=E?o.plus(n3(y.y1)):n3(y.y1),S=E?l.plus(n3(y.x)):n3(y.x),f=E?o.plus(n3(y.y)):n3(y.y),B=T6(l,o,C,P,S,f,20);for(let R of B)a=h.min(a,R.x),e=h.min(e,R.y),i=h.max(i,R.x),r=h.max(r,R.y),m.push(R);n=C,c=P,l=S,o=f,s="Q"}break;case"T":{if(y.x==null||y.y==null)throw Error("pathBoundingBox: T command requires x and y properties");let C=E?l.plus(n3(y.x)):n3(y.x),P=E?o.plus(n3(y.y)):n3(y.y),S,f;if(s==="Q"||s==="T")S=l.mul(2).minus(n),f=o.mul(2).minus(c);else S=l,f=o;let B=T6(l,o,S,f,C,P,20);for(let R of B)a=h.min(a,R.x),e=h.min(e,R.y),i=h.max(i,R.x),r=h.max(r,R.y),m.push(R);n=S,c=f,l=C,o=P,s="T"}break;case"A":{if(y.x==null||y.y==null||y.rx==null||y.ry==null)throw Error("pathBoundingBox: A command requires x, y, rx, ry properties");let C=E?l.plus(n3(y.x)):n3(y.x),P=E?o.plus(n3(y.y)):n3(y.y),S=n3(y.rx).abs(),f=n3(y.ry).abs();if(S.isZero()||f.isZero())a=h.min(a,l,C),e=h.min(e,o,P),i=h.max(i,l,C),r=h.max(r,o,P),m.push({x:l,y:o},{x:C,y:P});else{a=h.min(a,l,C),e=h.min(e,o,P),i=h.max(i,l,C),r=h.max(r,o,P);let B=l.plus(C).div(2),R=o.plus(P).div(2);a=h.min(a,B.minus(S)),e=h.min(e,R.minus(f)),i=h.max(i,B.plus(S)),r=h.max(r,R.plus(f));let k=20;for(let N=0;N<=k;N++){let I=n3(N).div(k),d=l.plus(C.minus(l).mul(I)),Y=o.plus(P.minus(o).mul(I));m.push({x:d,y:Y})}}l=C,o=P,n=l,c=o,s="A"}break;case"Z":l=x,o=p,n=l,c=o,s="Z";break;default:throw Error(`pathBoundingBox: unknown path command type: ${v}`)}}if(!a.isFinite()||!e.isFinite()||!i.isFinite()||!r.isFinite())throw Error("Invalid bounding box: no valid coordinates found");let g=qi(a,e,i,r),u=!0;for(let y of m)if(!Ki(y,g)){u=!1;break}return{...g,verified:u}}function A6(t){if(!t||typeof t!=="object")throw Error("bboxToPolygon: bbox must be a bounding box object");if(t.minX==null||t.minY==null||t.maxX==null||t.maxY==null)throw Error("bboxToPolygon: bbox must have minX, minY, maxX, maxY properties");return[k4(t.minX,t.minY),k4(t.maxX,t.minY),k4(t.maxX,t.maxY),k4(t.minX,t.maxY)]}function Ji(t,a){if(!a||typeof a!=="object")throw Error("bboxIntersectsViewBox: viewBox must be an object");if(a.x==null||a.y==null||a.width==null||a.height==null)throw Error("bboxIntersectsViewBox: viewBox must have x, y, width, height properties");let e=A6(t),i=A6({minX:a.x,minY:a.y,maxX:a.x.plus(a.width),maxY:a.y.plus(a.height)}),r=Ft(e,i);return{intersects:r.overlaps,verified:r.verified}}var Z3={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function $i(t){if(typeof t!=="string"||!t.trim())throw Error("Selector must be a non-empty string");let a=t.trim(),e=[],i=tr(a);for(let r of i){if(!r.trim())continue;let l=ar(r.trim());e.push(...l)}return e}function tr(t){if(typeof t!=="string")throw Error("Selector must be a string");let a=[],e="",i=0,r=0,l=!1,o=null;for(let p=0;p<t.length;p++){let n=t[p],c=p>0?t[p-1]:null;if((n==='"'||n==="'")&&c!=="\\"){if(!l)l=!0,o=n;else if(n===o)l=!1,o=null}if(!l){if(n==="["&&c!=="\\")i++;else if(n==="]"&&c!=="\\"){if(i--,i<0)throw Error(`Unbalanced brackets at position ${p}`)}else if(n==="("&&c!=="\\")r++;else if(n===")"&&c!=="\\"){if(r--,r<0)throw Error(`Unbalanced parentheses at position ${p}`)}}if(!l&&i===0&&r===0){if(n===">"||n==="+"||n==="~"){let s=e.trim();if(s)a.push(s);e="";continue}else if(n===" "){let s=e.trim();if(s){a.push(s),e="";continue}else continue}}e+=n}if(l)throw Error("Unclosed quote in selector");if(i!==0)throw Error("Unclosed brackets in selector");if(r!==0)throw Error("Unclosed parentheses in selector");let x=e.trim();if(x)a.push(x);return a}function ar(t){if(typeof t!=="string")throw Error("Selector must be a string");let a=[],e=0;while(e<t.length){let i=t[e];if(i==="#"){let r=t.slice(e).match(/^#([a-zA-Z_-][\w-]*)/);if(!r)throw Error(`Invalid ID selector at position ${e}`);a.push({type:Z3.ID,value:r[1]}),e+=r[0].length}else if(i==="."){let r=t.slice(e).match(/^\.([a-zA-Z_-][\w-]*)/);if(!r)throw Error(`Invalid class selector at position ${e}`);a.push({type:Z3.CLASS,value:r[1]}),e+=r[0].length}else if(i==="["){let r=er(t,e);if(r===-1)throw Error(`Unclosed attribute selector at position ${e}`);let l=t.slice(e+1,r);a.push({type:Z3.ATTRIBUTE,value:l}),e=r+1}else if(i===":")if(e+1<t.length&&t[e+1]===":"){let r=t.slice(e).match(/^::([\w-]+)/);if(!r)throw Error(`Invalid pseudo-element at position ${e}`);a.push({type:Z3.PSEUDO_ELEMENT,value:r[1]}),e+=r[0].length}else{let r=t.slice(e).match(/^:([\w-]+)/);if(!r)throw Error(`Invalid pseudo-class at position ${e}`);let l=r[1];if(e+=r[0].length,e<t.length&&t[e]==="("){let x=ir(t,e);if(x===-1)throw Error(`Unclosed pseudo-class function at position ${e}`);l+=t.slice(e,x+1),e=x+1}let o=["before","after","first-line","first-letter"].includes(l);a.push({type:o?Z3.PSEUDO_ELEMENT:Z3.PSEUDO_CLASS,value:l})}else if(i==="*"){let r=e+1;if(r<t.length&&t[r]==="|"){if(r++,r<t.length&&t[r]==="*")r++}a.push({type:Z3.UNIVERSAL,value:"*"}),e=r}else if(/[a-zA-Z]/.test(i)){let r=t.slice(e).match(/^([a-zA-Z][\w-]*)/);if(!r)throw Error(`Invalid type selector at position ${e}`);let l=r[1],o=e+r[0].length;if(o<t.length&&t[o]==="|"){o++;let x=t.slice(o).match(/^([a-zA-Z*][\w-]*)/);if(x)l=x[1],o+=x[0].length}a.push({type:Z3.TYPE,value:l}),e=o}else if(i===">"||i==="+"||i==="~"||i===" ")e++;else throw Error(`Unexpected character '${i}' at position ${e}`)}return a}function er(t,a){if(typeof t!=="string")throw Error("str must be a string");if(typeof a!=="number"||a<0||a>=t.length)throw Error("startIdx must be a valid index within the string");let e=0,i=!1,r=null;for(let l=a;l<t.length;l++){let o=t[l],x=l>0?t[l-1]:null;if((o==='"'||o==="'")&&x!=="\\"){if(!i)i=!0,r=o;else if(o===r)i=!1,r=null}if(!i){if(o==="["&&x!=="\\")e++;if(o==="]"&&x!=="\\"){if(e--,e===0)return l}}}return-1}function ir(t,a){if(typeof t!=="string")throw Error("str must be a string");if(typeof a!=="number"||a<0||a>=t.length)throw Error("startIdx must be a valid index within the string");let e=0,i=!1,r=null;for(let l=a;l<t.length;l++){let o=t[l],x=l>0?t[l-1]:null;if((o==='"'||o==="'")&&x!=="\\"){if(!i)i=!0,r=o;else if(o===r)i=!1,r=null}if(!i){if(o==="("&&x!=="\\")e++;if(o===")"&&x!=="\\"){if(e--,e===0)return l}}}return-1}function o2(t){let a=typeof t==="string"?$i(t):t;if(!Array.isArray(a))throw Error("Selector must be a string or an array of components");let e=0,i=0,r=0;for(let l of a){if(!l||typeof l.type!=="string")throw Error("Invalid component: must have a 'type' property");switch(l.type){case Z3.ID:e++;break;case Z3.CLASS:case Z3.ATTRIBUTE:i++;break;case Z3.PSEUDO_CLASS:{let o=l.value;if(o.startsWith("where(")&&o.endsWith(")"))break;if((o.startsWith("not(")||o.startsWith("is(")||o.startsWith("has("))&&o.endsWith(")")){let x=o.match(/^(\w+)\(/)[1],p=o.slice(x.length+1,-1);if(p.trim()){let n=rr(p),c=[0,0,0];for(let s of n)if(s.trim()){let m=o2(s.trim());if(x2(m,c)>0)c=m}e+=c[0],i+=c[1],r+=c[2]}break}if((o.startsWith("nth-child(")||o.startsWith("nth-last-child("))&&o.endsWith(")")){let x=o.match(/^([\w-]+)\(/)[1],p=o.slice(x.length+1,-1).match(/\s+of\s+(.+)$/);if(p){let n=p[1].trim(),c=o2(n);e+=c[0],i+=c[1],r+=c[2]}i++;break}i++;break}case Z3.TYPE:case Z3.PSEUDO_ELEMENT:r++;break;case Z3.UNIVERSAL:break;default:break}}return[e,i,r]}function rr(t){if(typeof t!=="string")throw Error("selectorList must be a string");let a=[],e="",i=0,r=0,l=!1,o=null;for(let x=0;x<t.length;x++){let p=t[x],n=x>0?t[x-1]:null;if((p==='"'||p==="'")&&n!=="\\"){if(!l)l=!0,o=p;else if(p===o)l=!1,o=null}if(!l){if(p==="(")i++;if(p===")")i--;if(p==="[")r++;if(p==="]")r--;if(p===","&&i===0&&r===0){a.push(e),e="";continue}}e+=p}if(e)a.push(e);return a}function x2(t,a){if(!Array.isArray(t)||t.length!==3)throw Error("spec1 must be an array of 3 numbers");if(!Array.isArray(a)||a.length!==3)throw Error("spec2 must be an array of 3 numbers");for(let e=0;e<3;e++){if(typeof t[e]!=="number"||!Number.isFinite(t[e])||t[e]<0)throw Error(`spec1[${e}] must be a non-negative finite number`);if(typeof a[e]!=="number"||!Number.isFinite(a[e])||a[e]<0)throw Error(`spec2[${e}] must be a non-negative finite number`)}for(let e=0;e<3;e++){if(t[e]<a[e])return-1;if(t[e]>a[e])return 1}return 0}var Gt={};U4(Gt,{transformPathData:()=>xr,transformArcParams:()=>zt,rectToPathData:()=>S2,polylineToPathData:()=>f0,polygonToPathData:()=>A2,pathToCubics:()=>nr,pathToAbsolute:()=>d0,pathArrayToString:()=>U5,parsePathData:()=>s5,lineToPathData:()=>T2,getKappaForArc:()=>jt,getKappa:()=>A0,ellipseToPathDataHP:()=>C2,ellipseToPathData:()=>P2,convertElementToPath:()=>Ht,circleToPathDataHP:()=>Wt,circleToPathData:()=>b2});var w3=(t)=>t instanceof h?t:new h(t);function A0(){let t=new h(2),a=new h(3);return new h(4).mul(t.sqrt().minus(1)).div(a)}function jt(t){if(t==null)throw Error("getKappaForArc: thetaRadians parameter is required");let a=w3(t);if(!a.isFinite())throw Error("getKappaForArc: thetaRadians must be finite");if(a.isZero()||a.isNegative())throw Error("getKappaForArc: thetaRadians must be positive");let e=new h(4),i=new h(3);return e.div(i).mul(h.tan(a.div(e)))}function Wt(t,a,e,i=8,r=6){if(t==null||a==null||e==null)throw Error("circleToPathDataHP: cx, cy, and r parameters are required");let l=w3(e);if(!l.isFinite()||l.isNegative())throw Error("circleToPathDataHP: radius must be finite and non-negative");if(l.isZero())return"";if(!Number.isFinite(i)||i<=0)throw Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(r)||r<0)throw Error("circleToPathDataHP: precision must be non-negative");return C2(t,a,e,e,i,r)}function C2(t,a,e,i,r=8,l=6){if(t==null||a==null||e==null||i==null)throw Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(r)||r<=0)throw Error("ellipseToPathDataHP: arcs must be a positive number");if(!Number.isFinite(l)||l<0)throw Error("ellipseToPathDataHP: precision must be non-negative");let o=r;if(o%4!==0)o=Math.ceil(o/4)*4;let x=w3(t),p=w3(a),n=w3(e),c=w3(i);if(!n.isFinite()||n.isNegative())throw Error("ellipseToPathDataHP: rx must be finite and non-negative");if(!c.isFinite()||c.isNegative())throw Error("ellipseToPathDataHP: ry must be finite and non-negative");if(n.isZero()||c.isZero())return"";let s=(y)=>c5(y,l),m=h.acos(-1).mul(2).div(o),g=jt(m),u=[];for(let y=0;y<o;y++){let v=m.mul(y),E=m.mul(y+1),C=h.cos(v),P=h.sin(v),S=h.cos(E),f=h.sin(E),B=x.plus(n.mul(C)),R=p.plus(c.mul(P)),k=x.plus(n.mul(S)),N=p.plus(c.mul(f)),I=P.neg(),d=C,Y=f.neg(),X=S,F=B.plus(g.mul(n).mul(I)),V=R.plus(g.mul(c).mul(d)),T=k.minus(g.mul(n).mul(Y)),j=N.minus(g.mul(c).mul(X));if(y===0)u.push(`M${s(B)} ${s(R)}`);u.push(`C${s(F)} ${s(V)} ${s(T)} ${s(j)} ${s(k)} ${s(N)}`)}return u.push("Z"),u.join(" ")}function c5(t,a=6){if(t==null)throw Error("formatNumber: value parameter is required");if(!Number.isFinite(a)||a<0)throw Error("formatNumber: precision must be non-negative");let e=w3(t);if(!e.isFinite())throw Error("formatNumber: value must be finite");let i=e.toFixed(a);if(i.includes("."))i=i.replace(/\.?0+$/,"");return i}function b2(t,a,e,i=6){if(t==null||a==null||e==null)throw Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(i)||i<0)throw Error("circleToPathData: precision must be non-negative");let r=w3(t),l=w3(a),o=w3(e);if(!o.isFinite()||o.isNegative())throw Error("circleToPathData: radius must be finite and non-negative");if(o.isZero())return"";let x=A0().mul(o),p=r.plus(o),n=l,c=p,s=n.minus(x),m=r.plus(x),g=l.minus(o),u=r,y=l.minus(o),v=r.minus(x),E=y,C=r.minus(o),P=l.minus(x),S=r.minus(o),f=l,B=S,R=l.plus(x),k=r.minus(x),N=l.plus(o),I=r,d=l.plus(o),Y=r.plus(x),X=d,F=p,V=l.plus(x),T=(j)=>c5(j,i);return`M${T(p)} ${T(n)}C${T(c)} ${T(s)} ${T(m)} ${T(g)} ${T(u)} ${T(y)}C${T(v)} ${T(E)} ${T(C)} ${T(P)} ${T(S)} ${T(f)}C${T(B)} ${T(R)} ${T(k)} ${T(N)} ${T(I)} ${T(d)}C${T(Y)} ${T(X)} ${T(F)} ${T(V)} ${T(p)} ${T(n)}Z`}function P2(t,a,e,i,r=6){if(t==null||a==null||e==null||i==null)throw Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(r)||r<0)throw Error("ellipseToPathData: precision must be non-negative");let l=w3(t),o=w3(a),x=w3(e),p=w3(i);if(!x.isFinite()||x.isNegative())throw Error("ellipseToPathData: rx must be finite and non-negative");if(!p.isFinite()||p.isNegative())throw Error("ellipseToPathData: ry must be finite and non-negative");if(x.isZero()||p.isZero())return"";let n=A0(),c=n.mul(x),s=n.mul(p),m=l.plus(x),g=o,u=m,y=g.minus(s),v=l.plus(c),E=o.minus(p),C=l,P=o.minus(p),S=l.minus(c),f=P,B=l.minus(x),R=o.minus(s),k=l.minus(x),N=o,I=k,d=o.plus(s),Y=l.minus(c),X=o.plus(p),F=l,V=o.plus(p),T=l.plus(c),j=V,A=m,z=o.plus(s),i3=(K)=>c5(K,r);return`M${i3(m)} ${i3(g)}C${i3(u)} ${i3(y)} ${i3(v)} ${i3(E)} ${i3(C)} ${i3(P)}C${i3(S)} ${i3(f)} ${i3(B)} ${i3(R)} ${i3(k)} ${i3(N)}C${i3(I)} ${i3(d)} ${i3(Y)} ${i3(X)} ${i3(F)} ${i3(V)}C${i3(T)} ${i3(j)} ${i3(A)} ${i3(z)} ${i3(m)} ${i3(g)}Z`}function S2(t,a,e,i,r=0,l=null,o=!1,x=6){if(t==null||a==null||e==null||i==null)throw Error("rectToPathData: x, y, width, and height parameters are required");if(!Number.isFinite(x)||x<0)throw Error("rectToPathData: precision must be non-negative");let p=w3(t),n=w3(a),c=w3(e),s=w3(i);if(!p.isFinite())throw Error("rectToPathData: x must be finite");if(!n.isFinite())throw Error("rectToPathData: y must be finite");if(!c.isFinite()||c.isNegative())throw Error("rectToPathData: width must be finite and non-negative");if(!s.isFinite()||s.isNegative())throw Error("rectToPathData: height must be finite and non-negative");if(c.isZero()||s.isZero())return"";let m=w3(r||0),g=l!==null?w3(l):m;if(!m.isFinite()||m.isNegative())throw Error("rectToPathData: rx must be finite and non-negative");if(!g.isFinite()||g.isNegative())throw Error("rectToPathData: ry must be finite and non-negative");let u=c.div(2),y=s.div(2);if(m.gt(u))m=u;if(g.gt(y))g=y;let v=(Y)=>c5(Y,x);if(m.isZero()||g.isZero()){let Y=p.plus(c),X=n.plus(s);return`M${v(p)} ${v(n)}H${v(Y)}V${v(X)}H${v(p)}Z`}let E=p,C=p.plus(c),P=n,S=n.plus(s),f=E.plus(m),B=C.minus(m),R=P.plus(g),k=S.minus(g);if(o)return`M${v(f)} ${v(P)}L${v(B)} ${v(P)}A${v(m)} ${v(g)} 0 0 1 ${v(C)} ${v(R)}L${v(C)} ${v(k)}A${v(m)} ${v(g)} 0 0 1 ${v(B)} ${v(S)}L${v(f)} ${v(S)}A${v(m)} ${v(g)} 0 0 1 ${v(E)} ${v(k)}L${v(E)} ${v(R)}A${v(m)} ${v(g)} 0 0 1 ${v(f)} ${v(P)}Z`;let N=A0(),I=N.mul(m),d=N.mul(g);return`M${v(f)} ${v(P)}L${v(B)} ${v(P)}C${v(B.plus(I))} ${v(P)} ${v(C)} ${v(R.minus(d))} ${v(C)} ${v(R)}L${v(C)} ${v(k)}C${v(C)} ${v(k.plus(d))} ${v(B.plus(I))} ${v(S)} ${v(B)} ${v(S)}L${v(f)} ${v(S)}C${v(f.minus(I))} ${v(S)} ${v(E)} ${v(k.plus(d))} ${v(E)} ${v(k)}L${v(E)} ${v(R)}C${v(E)} ${v(R.minus(d))} ${v(f.minus(I))} ${v(P)} ${v(f)} ${v(P)}Z`}function T2(t,a,e,i,r=6){if(t==null||a==null||e==null||i==null)throw Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(r)||r<0)throw Error("lineToPathData: precision must be non-negative");let l=w3(t),o=w3(a),x=w3(e),p=w3(i);if(!l.isFinite()||!o.isFinite()||!x.isFinite()||!p.isFinite())throw Error("lineToPathData: all coordinates must be finite");let n=(c)=>c5(c,r);return`M${n(l)} ${n(o)}L${n(x)} ${n(p)}`}function lr(t){if(t==null)return[];if(Array.isArray(t))try{return t.map(([l,o])=>[w3(l),w3(o)])}catch(l){return[]}let a=t;if(typeof a==="object"&&a.baseVal!==void 0)a=a.baseVal;if(typeof a!=="string")if(typeof a.toString==="function")a=a.toString();else return[];let e=[],i=a.split(/[\s,]+/).filter((l)=>l.length>0);for(let l of i)try{e.push(w3(l))}catch(o){continue}let r=[];for(let l=0;l<e.length;l+=2)if(l+1<e.length)r.push([e[l],e[l+1]]);return r}function f0(t,a=6){if(!Number.isFinite(a)||a<0)throw Error("polylineToPathData: precision must be non-negative");let e=lr(t);if(e.length===0)return"";let i=(x)=>c5(x,a),[r,l]=e[0],o=`M${i(r)} ${i(l)}`;for(let x=1;x<e.length;x++){let[p,n]=e[x];o+=`L${i(p)} ${i(n)}`}return o}function A2(t,a=6){if(!Number.isFinite(a)||a<0)throw Error("polygonToPathData: precision must be non-negative");let e=f0(t,a);return e?e+" Z":""}var or={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function s5(t){if(t==null)throw Error("parsePathData: pathData parameter is required");if(typeof t!=="string")throw Error("parsePathData: pathData must be a string");let a=[],e=/([MmLlHhVvCcSsQqTtAaZz])\s*([^MmLlHhVvCcSsQqTtAaZz]*)/g,i;while((i=e.exec(t))!==null){let r=i[1],l=i[2].trim(),o=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,x=[];if(l.length>0)for(let n of l.matchAll(o))try{x.push(w3(n[0]))}catch(c){continue}let p=or[r];if(p===0||x.length===0)a.push({command:r,args:[]});else for(let n=0;n<x.length;n+=p){let c=x.slice(n,n+p);if(c.length===p){let s=r;if(n>0&&(r==="M"||r==="m"))s=r==="M"?"L":"l";a.push({command:s,args:c})}}}return a}function U5(t,a=6){if(t==null)throw Error("pathArrayToString: commands parameter is required");if(!Array.isArray(t))throw Error("pathArrayToString: commands must be an array");if(!Number.isFinite(a)||a<0)throw Error("pathArrayToString: precision must be non-negative");return t.map((e)=>{if(!e||typeof e.command!=="string"||!Array.isArray(e.args))throw Error("pathArrayToString: each command must have 'command' (string) and 'args' (array) properties");let{command:i,args:r}=e,l=r.map((o)=>c5(o,a)).join(" ");return l.length>0?`${i} ${l}`:i}).join(" ")}function d0(t){if(t==null)throw Error("pathToAbsolute: pathData parameter is required");let a=s5(t),e=[],i=new h(0),r=new h(0),l=new h(0),o=new h(0),x=new h(0),p=new h(0),n="";for(let{command:c,args:s}of a){let m=c===c.toLowerCase(),g=c.toUpperCase();if(g==="M"){if(s.length<2)continue;let u=m?i.plus(s[0]):s[0],y=m?r.plus(s[1]):s[1];i=u,r=y,l=u,o=y,e.push({command:"M",args:[u,y]}),n="M"}else if(g==="L"){if(s.length<2)continue;let u=m?i.plus(s[0]):s[0],y=m?r.plus(s[1]):s[1];i=u,r=y,e.push({command:"L",args:[u,y]}),n="L"}else if(g==="H"){if(s.length<1)continue;let u=m?i.plus(s[0]):s[0];i=u,e.push({command:"L",args:[u,r]}),n="H"}else if(g==="V"){if(s.length<1)continue;let u=m?r.plus(s[0]):s[0];r=u,e.push({command:"L",args:[i,u]}),n="V"}else if(g==="C"){if(s.length<6)continue;let u=m?i.plus(s[0]):s[0],y=m?r.plus(s[1]):s[1],v=m?i.plus(s[2]):s[2],E=m?r.plus(s[3]):s[3],C=m?i.plus(s[4]):s[4],P=m?r.plus(s[5]):s[5];x=v,p=E,i=C,r=P,e.push({command:"C",args:[u,y,v,E,C,P]}),n="C"}else if(g==="S"){if(s.length<4)continue;let u,y;if(n==="C"||n==="S")u=i.mul(2).minus(x),y=r.mul(2).minus(p);else u=i,y=r;let v=m?i.plus(s[0]):s[0],E=m?r.plus(s[1]):s[1],C=m?i.plus(s[2]):s[2],P=m?r.plus(s[3]):s[3];x=v,p=E,i=C,r=P,e.push({command:"C",args:[u,y,v,E,C,P]}),n="S"}else if(g==="Q"){if(s.length<4)continue;let u=m?i.plus(s[0]):s[0],y=m?r.plus(s[1]):s[1],v=m?i.plus(s[2]):s[2],E=m?r.plus(s[3]):s[3];x=u,p=y,i=v,r=E,e.push({command:"Q",args:[u,y,v,E]}),n="Q"}else if(g==="T"){if(s.length<2)continue;let u,y;if(n==="Q"||n==="T")u=i.mul(2).minus(x),y=r.mul(2).minus(p);else u=i,y=r;let v=m?i.plus(s[0]):s[0],E=m?r.plus(s[1]):s[1];x=u,p=y,i=v,r=E,e.push({command:"Q",args:[u,y,v,E]}),n="T"}else if(g==="A"){if(s.length<7)continue;let u=m?i.plus(s[5]):s[5],y=m?r.plus(s[6]):s[6];i=u,r=y,e.push({command:"A",args:[s[0],s[1],s[2],s[3],s[4],u,y]}),n="A"}else if(g==="Z")i=l,r=o,e.push({command:"Z",args:[]}),n="Z";else e.push({command:c,args:s}),n=c}return U5(e)}function zt(t,a,e,i,r,l,o,x){if(t==null||a==null||e==null||i==null||r==null||l==null||o==null)throw Error("transformArcParams: all parameters (rx, ry, xAxisRotation, largeArc, sweep, endX, endY) are required");if(x==null)throw Error("transformArcParams: matrix parameter is required");if(!x.data||!Array.isArray(x.data)||x.data.length!==3)throw Error("transformArcParams: matrix must be 3x3");if(!Array.isArray(x.data[0])||x.data[0].length<2||!Array.isArray(x.data[1])||x.data[1].length<2||!Array.isArray(x.data[2])||x.data[2].length<1)throw Error("transformArcParams: matrix must have valid 3x3 structure");let p=w3(t),n=w3(a),c=w3(e),s=w3(l),m=w3(o),g=s3.from([[s],[m],[new h(1)]]),u=x.mul(g),y=u.data[2][0];if(y.isZero())throw Error("transformArcParams: division by zero in homogeneous coordinate transformation");let v=u.data[0][0].div(y),E=u.data[1][0].div(y),C=x.data[0][0],P=x.data[0][1],S=x.data[1][0],f=x.data[1][1],B=C.mul(f).minus(P.mul(S)).isNegative()?r===1?0:1:r,R=c.mul(new h(Math.PI)).div(180),k=h.cos(R),N=h.sin(R),I=p.mul(k),d=p.mul(N),Y=n.mul(N).neg(),X=n.mul(k),F=C.mul(I).plus(P.mul(d)),V=S.mul(I).plus(f.mul(d)),T=C.mul(Y).plus(P.mul(X)),j=S.mul(Y).plus(f.mul(X)),A=h.sqrt(F.mul(F).plus(V.mul(V))),z=h.sqrt(T.mul(T).plus(j.mul(j))),i3=h.atan2(V,F).mul(180).div(new h(Math.PI));return[A,z,i3,i,B,v,E]}function xr(t,a,e=6){if(t==null)throw Error("transformPathData: pathData parameter is required");if(a==null)throw Error("transformPathData: matrix parameter is required");if(!a.data||!Array.isArray(a.data)||a.data.length!==3)throw Error("transformPathData: matrix must be 3x3");if(!Array.isArray(a.data[0])||a.data[0].length<2||!Array.isArray(a.data[1])||a.data[1].length<2||!Array.isArray(a.data[2])||a.data[2].length<1)throw Error("transformPathData: matrix must have valid 3x3 structure");if(!Number.isFinite(e)||e<0)throw Error("transformPathData: precision must be non-negative");let i=d0(t),r=s5(i),l=[];for(let{command:o,args:x}of r)if(o==="M"||o==="L"){if(x.length<2)continue;let p=s3.from([[x[0]],[x[1]],[new h(1)]]),n=a.mul(p),c=n.data[2][0];if(c.isZero())throw Error("transformPathData: division by zero in homogeneous coordinate transformation");let s=n.data[0][0].div(c),m=n.data[1][0].div(c);l.push({command:o,args:[s,m]})}else if(o==="C"){if(x.length<6)continue;let p=[];for(let n=0;n<6;n+=2){let c=s3.from([[x[n]],[x[n+1]],[new h(1)]]),s=a.mul(c),m=s.data[2][0];if(m.isZero())throw Error("transformPathData: division by zero in homogeneous coordinate transformation");p.push(s.data[0][0].div(m)),p.push(s.data[1][0].div(m))}l.push({command:o,args:p})}else if(o==="A"){if(x.length<7)continue;let[p,n,c,s,m,g,u]=zt(x[0],x[1],x[2],x[3],x[4],x[5],x[6],a);l.push({command:o,args:[p,n,c,s,m,g,u]})}else l.push({command:o,args:x});return U5(l,e)}function f6(t,a,e,i,r,l){if(t==null||a==null||e==null||i==null||r==null||l==null)throw Error("quadraticToCubic: all parameters (x0, y0, x1, y1, x2, y2) are required");let o=new h(2).div(3),x=t.plus(o.mul(e.minus(t))),p=a.plus(o.mul(i.minus(a))),n=r.plus(o.mul(e.minus(r))),c=l.plus(o.mul(i.minus(l)));return[x,p,n,c,r,l]}function nr(t){if(t==null)throw Error("pathToCubics: pathData parameter is required");let a=d0(t),e=s5(a),i=[],r=new h(0),l=new h(0),o=new h(0),x=new h(0),p="";for(let{command:n,args:c}of e)if(n==="M"){if(c.length<2)continue;r=c[0],l=c[1],i.push({command:"M",args:[r,l]}),p="M"}else if(n==="L"){if(c.length<2)continue;let s=c[0],m=c[1];i.push({command:"C",args:[r,l,s,m,s,m]}),r=s,l=m,p="L"}else if(n==="C"){if(c.length<6)continue;let[s,m,g,u,y,v]=c;i.push({command:"C",args:[s,m,g,u,y,v]}),o=g,x=u,r=y,l=v,p="C"}else if(n==="S"){if(c.length<4)continue;let s,m;if(p==="C"||p==="S")s=r.mul(2).minus(o),m=l.mul(2).minus(x);else s=r,m=l;let[g,u,y,v]=c;i.push({command:"C",args:[s,m,g,u,y,v]}),o=g,x=u,r=y,l=v,p="S"}else if(n==="Q"){if(c.length<4)continue;let[s,m,g,u]=c,y=f6(r,l,s,m,g,u);i.push({command:"C",args:y}),o=s,x=m,r=g,l=u,p="Q"}else if(n==="T"){if(c.length<2)continue;let s,m;if(p==="Q"||p==="T")s=r.mul(2).minus(o),m=l.mul(2).minus(x);else s=r,m=l;let[g,u]=c,y=f6(r,l,s,m,g,u);i.push({command:"C",args:y}),o=s,x=m,r=g,l=u,p="T"}else if(n==="Z")i.push({command:"Z",args:[]}),p="Z";else i.push({command:n,args:c}),p=n;return U5(i)}function Ht(t,a=6){if(t==null)throw Error("convertElementToPath: element parameter is required");if(!Number.isFinite(a)||a<0)throw Error("convertElementToPath: precision must be non-negative");let e=(r,l=0)=>{let o=t.getAttribute?t.getAttribute(r):t[r];return pr(o!==void 0&&o!==null?o:l)},i=(t.tagName||t.type||"").toLowerCase();if(i==="circle")return b2(e("cx",0),e("cy",0),e("r",0),a);else if(i==="ellipse")return P2(e("cx",0),e("cy",0),e("rx",0),e("ry",0),a);else if(i==="rect")return S2(e("x",0),e("y",0),e("width",0),e("height",0),e("rx",0),e("ry",null),!1,a);else if(i==="line")return T2(e("x1",0),e("y1",0),e("x2",0),e("y2",0),a);else if(i==="polyline")return f0(e("points",""),a);else if(i==="polygon")return A2(e("points",""),a);return null}function pr(t){if(t==null)return 0;if(typeof t==="string"){let e=parseFloat(t);return isNaN(e)?0:e}if(typeof t==="number")return isNaN(t)?0:t;if(t instanceof h)return t.toNumber();let a=Number(t);return isNaN(a)?0:a}h.set({precision:80});function cr(t,a,e){return Qt(t,a,e,e)}function Qt(t,a,e,i){let r=(S)=>new h(S),l=r(t),o=r(a),x=r(e),p=r(i);if(!x.isFinite()||!p.isFinite()||!l.isFinite()||!o.isFinite())throw Error("Ellipse parameters must be finite");if(x.eq(0)||p.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(x.lt(0)||p.lt(0))throw Error("Ellipse radii must be non-negative");let n=r("0.5522847498307936"),c=x.mul(n),s=p.mul(n),m=l.plus(x),g=o,u=l,y=o.minus(p),v=l.minus(x),E=o,C=l,P=o.plus(p);return[`M ${m.toFixed(6)} ${g.toFixed(6)}`,`C ${m.toFixed(6)} ${g.minus(s).toFixed(6)} ${u.plus(c).toFixed(6)} ${y.toFixed(6)} ${u.toFixed(6)} ${y.toFixed(6)}`,`C ${u.minus(c).toFixed(6)} ${y.toFixed(6)} ${v.toFixed(6)} ${E.minus(s).toFixed(6)} ${v.toFixed(6)} ${E.toFixed(6)}`,`C ${v.toFixed(6)} ${E.plus(s).toFixed(6)} ${C.minus(c).toFixed(6)} ${P.toFixed(6)} ${C.toFixed(6)} ${P.toFixed(6)}`,`C ${C.plus(c).toFixed(6)} ${P.toFixed(6)} ${m.toFixed(6)} ${g.plus(s).toFixed(6)} ${m.toFixed(6)} ${g.toFixed(6)}`,"Z"].join(" ")}function sr(t,a,e,i,r=0,l=null){let o=(y)=>new h(y),x=o(t),p=o(a),n=o(e),c=o(i);if(n.lte(0)||c.lte(0))throw Error("Rectangle dimensions must be positive");if(!n.isFinite()||!c.isFinite()||!x.isFinite()||!p.isFinite())throw Error("Rectangle parameters must be finite");let s=o(r),m=l!==null?o(l):s;if(s.lt(0)||m.lt(0))throw Error("Rectangle corner radii must be non-negative");let g=n.div(2),u=c.div(2);if(s.gt(g))s=g;if(m.gt(u))m=u;if(!(s.gt(0)||m.gt(0)))return[`M ${x.toFixed(6)} ${p.toFixed(6)}`,`L ${x.plus(n).toFixed(6)} ${p.toFixed(6)}`,`L ${x.plus(n).toFixed(6)} ${p.plus(c).toFixed(6)}`,`L ${x.toFixed(6)} ${p.plus(c).toFixed(6)}`,"Z"].join(" ");return[`M ${x.plus(s).toFixed(6)} ${p.toFixed(6)}`,`L ${x.plus(n).minus(s).toFixed(6)} ${p.toFixed(6)}`,`A ${s.toFixed(6)} ${m.toFixed(6)} 0 0 1 ${x.plus(n).toFixed(6)} ${p.plus(m).toFixed(6)}`,`L ${x.plus(n).toFixed(6)} ${p.plus(c).minus(m).toFixed(6)}`,`A ${s.toFixed(6)} ${m.toFixed(6)} 0 0 1 ${x.plus(n).minus(s).toFixed(6)} ${p.plus(c).toFixed(6)}`,`L ${x.plus(s).toFixed(6)} ${p.plus(c).toFixed(6)}`,`A ${s.toFixed(6)} ${m.toFixed(6)} 0 0 1 ${x.toFixed(6)} ${p.plus(c).minus(m).toFixed(6)}`,`L ${x.toFixed(6)} ${p.plus(m).toFixed(6)}`,`A ${s.toFixed(6)} ${m.toFixed(6)} 0 0 1 ${x.plus(s).toFixed(6)} ${p.toFixed(6)}`].join(" ")}function mr(t,a,e,i){let r=(n)=>new h(n),l=r(t),o=r(a),x=r(e),p=r(i);if(!l.isFinite()||!o.isFinite()||!x.isFinite()||!p.isFinite())throw Error("lineToPath: all parameters must be finite");return`M ${l.toFixed(6)} ${o.toFixed(6)} L ${x.toFixed(6)} ${p.toFixed(6)}`}function gr(t){let a=qt(t);if(a.length===0)return"";let e=`M ${a[0][0]} ${a[0][1]}`;for(let i=1;i<a.length;i++)e+=` L ${a[i][0]} ${a[i][1]}`;return e+" Z"}function yr(t){let a=qt(t);if(a.length===0)return"";let e=`M ${a[0][0]} ${a[0][1]}`;for(let i=1;i<a.length;i++)e+=` L ${a[i][0]} ${a[i][1]}`;return e}function qt(t){if(!t)return[];let a;try{if(Array.isArray(t))a=t.flat().map((i)=>new h(i).toFixed(6));else if(typeof t==="string")a=t.trim().split(/[\s,]+/).filter((i)=>i.length>0).map((i)=>new h(i).toFixed(6));else return console.warn("parsePointPairs: invalid input type"),[]}catch(i){return console.warn(`parsePointPairs: parse error - ${i.message}`),[]}if(a.length%2!==0)console.warn("parsePointPairs: odd number of coordinates, ignoring last value"),a=a.slice(0,-1);let e=[];for(let i=0;i+1<a.length;i+=2)e.push([a[i],a[i+1]]);return e}function hr(t,a,e,i,r,l,o,x){let p=(o3)=>new h(o3),n=p("1e-16");if(!x||!x.data||!Array.isArray(x.data)||x.data.length<3)throw Error("transformArc: invalid matrix");let c=p(t),s=p(a);if(c.lte(0)||s.lte(0))return console.warn("transformArc: radii must be positive, returning degenerate arc"),{rx:0,ry:0,xAxisRotation:0,largeArcFlag:i,sweepFlag:r,x:p(l).toNumber(),y:p(o).toNumber()};let m=i;if(typeof m!=="number"||m!==0&&m!==1)console.warn(`transformArc: largeArcFlag must be 0 or 1, got ${i}`),m=m?1:0;let g=r;if(typeof g!=="number"||g!==0&&g!==1)console.warn(`transformArc: sweepFlag must be 0 or 1, got ${r}`),g=g?1:0;let u=x.data[0][0],y=x.data[1][0],v=x.data[0][1],E=x.data[1][1],C=x.data[0][2],P=x.data[1][2],S=p(l),f=p(o),B=u.mul(S).plus(v.mul(f)).plus(C),R=y.mul(S).plus(E.mul(f)).plus(P),k=p(e).mul(p(Math.PI)).div(180),N=h.sin(k),I=h.cos(k),d=u.mul(c).mul(I).plus(v.mul(c).mul(N)),Y=y.mul(c).mul(I).plus(E.mul(c).mul(N)),X=u.mul(s.neg()).mul(N).plus(v.mul(s).mul(I)),F=y.mul(s.neg()).mul(N).plus(E.mul(s).mul(I)),V=d.mul(d).plus(X.mul(X)),T=Y.mul(Y).plus(F.mul(F)),j=d.mul(Y).plus(X.mul(F)).mul(2),A=V.minus(T),z,i3,K;if(j.abs().lt(n))z=p(0),i3=V,K=T;else if(A.abs().lt(n))i3=V.plus(j.mul("0.5")),K=V.minus(j.mul("0.5")),z=p(Math.PI).div(4);else{let o3=p(1).plus(j.mul(j).div(A.mul(A))).sqrt();i3=V.plus(T).plus(o3.mul(A)).div(2),K=V.plus(T).minus(o3.mul(A)).div(2),z=h.atan(j.div(A)).div(2)}if(i3.lt(0))i3=p(0);if(K.lt(0))K=p(0);let $=i3.sqrt(),w=K.sqrt();if(A.lte(0)){let o3=$;$=w,w=o3}if(w.gt($)){let o3=$;$=w,w=o3,z=z.plus(p(Math.PI).div(2))}let G=u.mul(E).minus(y.mul(v)),a3=g;if(G.lt(0))a3=g?0:1;let e3=z.mul(180).div(p(Math.PI));while(e3.lt(0))e3=e3.plus(180);while(e3.gte(180))e3=e3.minus(180);return{rx:$.toNumber(),ry:w.toNumber(),xAxisRotation:e3.toNumber(),largeArcFlag:m,sweepFlag:a3,x:B.toNumber(),y:R.toNumber()}}function vr(t,a){if(!t||typeof t!=="string")return console.warn("parseTransformFunction: invalid function name"),s3.identity(3);if(!a||!Array.isArray(a))return console.warn("parseTransformFunction: invalid arguments array"),s3.identity(3);let e=(i)=>new h(i);switch(t.toLowerCase()){case"translate":{let i=a[0]!==void 0?a[0]:0,r=a[1]!==void 0?a[1]:0;return g4(i,r)}case"scale":{let i=a[0]!==void 0?a[0]:1,r=a[1]!==void 0?a[1]:i;return n5(i,r)}case"rotate":{let i=a[0]!==void 0?a[0]:0,r=e(i).mul(e(Math.PI)).div(180);if(a.length>=3){if(a[1]===void 0||a[2]===void 0||!isFinite(a[1])||!isFinite(a[2]))return console.warn("parseTransformFunction: rotate(angle, cx, cy) has invalid cx or cy, using origin rotation"),L5(r);let l=a[1],o=a[2];return Vt(r,l,o)}return L5(r)}case"skewx":{let i=a[0]!==void 0?a[0]:0,r=e(i).mul(e(Math.PI)).div(180),l=h.tan(r);return i2(l,0)}case"skewy":{let i=a[0]!==void 0?a[0]:0,r=e(i).mul(e(Math.PI)).div(180),l=h.tan(r);return i2(0,l)}case"matrix":{if(a.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${a.length}`),s3.identity(3);let[i,r,l,o,x,p]=a.slice(0,6).map((n)=>e(n!==void 0?n:0));return s3.from([[i,l,x],[r,o,p],[e(0),e(0),e(1)]])}default:return console.warn(`Unknown transform function: ${t}`),s3.identity(3)}}function X4(t){if(!t||t.trim()==="")return s3.identity(3);let a=/(\w+)\s*\(([^)]*)\)/g,e,i=s3.identity(3);while((e=a.exec(t))!==null){let r=e[1],l=e[2].split(/[\s,]+/).filter((x)=>x.length>0).map((x)=>{let p=parseFloat(x);if(isNaN(p))return console.warn(`parseTransformAttribute: invalid numeric argument "${x}" in ${r}(), using 0`),0;return p}),o=vr(r,l);i=i.mul(o)}return i}function v4(t,a,e){if(!t||!t.data||!Array.isArray(t.data))throw Error("applyToPoint: invalid CTM matrix");let i=(o)=>new h(o);try{let o=i(a),x=i(e);if(!o.isFinite()||!x.isFinite())throw Error("applyToPoint: coordinates must be finite")}catch(o){throw Error(`applyToPoint: invalid coordinates - ${o.message}`)}let[r,l]=e4(t,a,e);return{x:r,y:l}}function ur(t,a=6){if(!t||!t.data||!Array.isArray(t.data)||t.data.length<3||!Array.isArray(t.data[0])||!Array.isArray(t.data[1])||t.data[0].length<3||t.data[1].length<3)throw Error("toSVGMatrix: invalid CTM matrix structure");let e=a;if(typeof e!=="number"||e<0||e>20)console.warn("toSVGMatrix: invalid precision, using default 6"),e=6;try{let i=t.data[0][0].toFixed(e),r=t.data[1][0].toFixed(e),l=t.data[0][1].toFixed(e),o=t.data[1][1].toFixed(e),x=t.data[0][2].toFixed(e),p=t.data[1][2].toFixed(e);return`matrix(${i}, ${r}, ${l}, ${o}, ${x}, ${p})`}catch(i){throw Error(`toSVGMatrix: invalid matrix elements - ${i.message}`)}}function c0(t,a,e={}){if(!t||typeof t!=="string")return console.warn("transformPathData: invalid pathData (must be string)"),"";if(!a||!a.data)return console.warn("transformPathData: invalid CTM matrix"),t;let{toAbsolute:i=!0,precision:r=6}=e,l=r;if(typeof l!=="number"||l<0||l>20||!isFinite(l))console.warn("transformPathData: invalid precision, using default 6"),l=6;let o=(g)=>new h(g),x=Er(t);if(x.length===0)return"";let p=[],n=o(0),c=o(0),s=o(0),m=o(0);for(let{cmd:g,args:u}of x){let y=g===g.toLowerCase();switch(g.toUpperCase()){case"M":{let v=[];if(u.length%2!==0)console.warn(`transformPathData: M command has ${u.length} args, expected multiple of 2`);for(let E=0;E+1<u.length;E+=2){let C=o(u[E]),P=o(u[E+1]);if(y)C=C.plus(n),P=P.plus(c);let S=v4(a,C,P);if(v.push(S.x.toFixed(l),S.y.toFixed(l)),n=C,c=P,E===0)s=C,m=P}p.push((i?"M":g)+" "+v.join(" "));break}case"L":{let v=[];if(u.length%2!==0)console.warn(`transformPathData: L command has ${u.length} args, expected multiple of 2`);for(let E=0;E+1<u.length;E+=2){let C=o(u[E]),P=o(u[E+1]);if(y)C=C.plus(n),P=P.plus(c);let S=v4(a,C,P);v.push(S.x.toFixed(l),S.y.toFixed(l)),n=C,c=P}p.push((i?"L":g)+" "+v.join(" "));break}case"H":{if(u.length<1){console.warn("transformPathData: H command requires at least 1 argument");break}for(let v=0;v<u.length;v++){let E=o(u[v]);if(y)E=E.plus(n);let C=v4(a,E,c);p.push("L "+C.x.toFixed(l)+" "+C.y.toFixed(l)),n=E}break}case"V":{if(u.length<1){console.warn("transformPathData: V command requires at least 1 argument");break}for(let v=0;v<u.length;v++){let E=n,C=o(u[v]);if(y)C=C.plus(c);let P=v4(a,E,C);p.push("L "+P.x.toFixed(l)+" "+P.y.toFixed(l)),c=C}break}case"C":{let v=[];if(u.length%6!==0)console.warn(`transformPathData: C command has ${u.length} args, expected multiple of 6`);for(let E=0;E+5<u.length;E+=6){let C=o(u[E]),P=o(u[E+1]),S=o(u[E+2]),f=o(u[E+3]),B=o(u[E+4]),R=o(u[E+5]);if(y)C=C.plus(n),P=P.plus(c),S=S.plus(n),f=f.plus(c),B=B.plus(n),R=R.plus(c);let k=v4(a,C,P),N=v4(a,S,f),I=v4(a,B,R);v.push(k.x.toFixed(l),k.y.toFixed(l),N.x.toFixed(l),N.y.toFixed(l),I.x.toFixed(l),I.y.toFixed(l)),n=B,c=R}p.push((i?"C":g)+" "+v.join(" "));break}case"S":{let v=[];if(u.length%4!==0)console.warn(`transformPathData: S command has ${u.length} args, expected multiple of 4`);for(let E=0;E+3<u.length;E+=4){let C=o(u[E]),P=o(u[E+1]),S=o(u[E+2]),f=o(u[E+3]);if(y)C=C.plus(n),P=P.plus(c),S=S.plus(n),f=f.plus(c);let B=v4(a,C,P),R=v4(a,S,f);v.push(B.x.toFixed(l),B.y.toFixed(l),R.x.toFixed(l),R.y.toFixed(l)),n=S,c=f}p.push((i?"S":g)+" "+v.join(" "));break}case"Q":{let v=[];if(u.length%4!==0)console.warn(`transformPathData: Q command has ${u.length} args, expected multiple of 4`);for(let E=0;E+3<u.length;E+=4){let C=o(u[E]),P=o(u[E+1]),S=o(u[E+2]),f=o(u[E+3]);if(y)C=C.plus(n),P=P.plus(c),S=S.plus(n),f=f.plus(c);let B=v4(a,C,P),R=v4(a,S,f);v.push(B.x.toFixed(l),B.y.toFixed(l),R.x.toFixed(l),R.y.toFixed(l)),n=S,c=f}p.push((i?"Q":g)+" "+v.join(" "));break}case"T":{let v=[];if(u.length%2!==0)console.warn(`transformPathData: T command has ${u.length} args, expected multiple of 2`);for(let E=0;E+1<u.length;E+=2){let C=o(u[E]),P=o(u[E+1]);if(y)C=C.plus(n),P=P.plus(c);let S=v4(a,C,P);v.push(S.x.toFixed(l),S.y.toFixed(l)),n=C,c=P}p.push((i?"T":g)+" "+v.join(" "));break}case"A":{let v=[];if(u.length%7!==0)console.warn(`transformPathData: Arc command has ${u.length} args, expected multiple of 7`);for(let E=0;E+6<u.length;E+=7){let C=u[E],P=u[E+1],S=u[E+2],f=u[E+3],B=u[E+4],R=o(u[E+5]),k=o(u[E+6]);if(y)R=R.plus(n),k=k.plus(c);let N=hr(C,P,S,f,B,R.toNumber(),k.toNumber(),a);v.push(N.rx.toFixed(l),N.ry.toFixed(l),N.xAxisRotation.toFixed(l),N.largeArcFlag,N.sweepFlag,N.x.toFixed(l),N.y.toFixed(l)),n=R,c=k}p.push((i?"A":g)+" "+v.join(" "));break}case"Z":{p.push("Z"),n=s,c=m;break}default:p.push(g+" "+u.join(" "))}}return p.join(" ")}function Er(t){if(!t||typeof t!=="string")return[];let a=[],e=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,i;while((i=e.exec(t))!==null){let r=i[1],l=i[2].trim(),o=l.length>0?l.split(/[\s,]+/).filter((x)=>x.length>0).map((x)=>{let p=parseFloat(x);if(isNaN(p))return console.warn(`parsePathCommands: invalid number '${x}'`),0;return p}):[];a.push({cmd:r,args:o})}return a}var f2={};U4(f2,{sign:()=>d2,segmentIntersection:()=>N0,reversePolygon:()=>D2,polygonUnion:()=>B0,polygonIntersection:()=>s0,polygonDifference:()=>$t,polygonArea:()=>Y5,pointsEqual:()=>Q4,pointOnSegment:()=>N2,pointInPolygon:()=>P4,point:()=>R3,lineSegmentIntersection:()=>Zt,isCounterClockwise:()=>B2,isConvex:()=>w2,ensureCCW:()=>I0,dot:()=>Kt,default:()=>Tr,cross:()=>O4,convexHull:()=>R2,clipPolygonSH:()=>I2,boundingBox:()=>q4,bboxIntersects:()=>M5});h.set({precision:80});var u4=(t)=>t instanceof h?t:new h(t),m4=new h("1e-40");function R3(t,a){if(t===null||t===void 0)throw Error("point: x coordinate is required");if(a===null||a===void 0)throw Error("point: y coordinate is required");return{x:u4(t),y:u4(a)}}function Q4(t,a,e=m4){if(!t||typeof t!=="object"||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("pointsEqual: p1 must be a point with x and y properties");if(!a||typeof a!=="object"||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("pointsEqual: p2 must be a point with x and y properties");if(!e||typeof e.abs!=="function")throw Error("pointsEqual: tolerance must be a Decimal instance");return t.x.minus(a.x).abs().lt(e)&&t.y.minus(a.y).abs().lt(e)}function O4(t,a,e){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("cross: origin point o must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("cross: point a must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("cross: point b must have x and y properties");let i=a.x.minus(t.x),r=a.y.minus(t.y),l=e.x.minus(t.x),o=e.y.minus(t.y);return i.mul(o).minus(r.mul(l))}function Kt(t,a,e){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("dot: origin point o must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("dot: point a must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("dot: point b must have x and y properties");let i=a.x.minus(t.x),r=a.y.minus(t.y),l=e.x.minus(t.x),o=e.y.minus(t.y);return i.mul(l).plus(r.mul(o))}function d2(t){if(t===null||t===void 0||typeof t.abs!=="function")throw Error("sign: val must be a Decimal instance");if(t.abs().lt(m4))return 0;return t.lt(0)?-1:1}function N0(t,a,e,i){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("segmentIntersection: point a must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("segmentIntersection: point b must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("segmentIntersection: point c must have x and y properties");if(!i||i.x===null||i.x===void 0||i.y===null||i.y===void 0)throw Error("segmentIntersection: point d must have x and y properties");let r=a.x.minus(t.x),l=a.y.minus(t.y),o=i.x.minus(e.x),x=i.y.minus(e.y),p=r.mul(x).minus(l.mul(o));if(p.abs().lt(m4))return null;let n=e.x.minus(t.x),c=e.y.minus(t.y),s=n.mul(x).minus(c.mul(o)).div(p),m=n.mul(l).minus(c.mul(r)).div(p),g=u4(0),u=u4(1);if(s.gte(g)&&s.lte(u)&&m.gte(g)&&m.lte(u))return{x:t.x.plus(r.mul(s)),y:t.y.plus(l.mul(s)),t:s,s:m};return null}function Zt(t,a,e,i){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("lineSegmentIntersection: lineA must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("lineSegmentIntersection: lineB must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("lineSegmentIntersection: segA must have x and y properties");if(!i||i.x===null||i.x===void 0||i.y===null||i.y===void 0)throw Error("lineSegmentIntersection: segB must have x and y properties");let r=a.x.minus(t.x),l=a.y.minus(t.y),o=i.x.minus(e.x),x=i.y.minus(e.y),p=r.mul(x).minus(l.mul(o));if(p.abs().lt(m4))return null;let n=e.x.minus(t.x),c=e.y.minus(t.y),s=n.mul(l).minus(c.mul(r)).div(p);if(s.gte(0)&&s.lte(1))return{x:e.x.plus(o.mul(s)),y:e.y.plus(x.mul(s)),s};return null}function P4(t,a){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("pointInPolygon: pt must have x and y properties");if(!Array.isArray(a))throw Error("pointInPolygon: polygon must be an array");let e=a.length;if(e<3)return-1;for(let r=0;r<e;r++)if(!a[r]||a[r].x===null||a[r].x===void 0||a[r].y===null||a[r].y===void 0)throw Error(`pointInPolygon: polygon[${r}] must have x and y properties`);let i=0;for(let r=0;r<e;r++){let l=a[r],o=a[(r+1)%e];if(N2(t,l,o))return 0;if(l.y.lte(t.y)){if(o.y.gt(t.y)){if(O4(l,o,t).gt(0))i++}}else if(o.y.lte(t.y)){if(O4(l,o,t).lt(0))i--}}return i!==0?1:-1}function N2(t,a,e){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("pointOnSegment: pt must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("pointOnSegment: segment point a must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("pointOnSegment: segment point b must have x and y properties");if(O4(a,e,t).abs().gt(m4))return!1;let i=h.min(a.x,e.x),r=h.max(a.x,e.x),l=h.min(a.y,e.y),o=h.max(a.y,e.y);return t.x.gte(i.minus(m4))&&t.x.lte(r.plus(m4))&&t.y.gte(l.minus(m4))&&t.y.lte(o.plus(m4))}function I2(t,a){if(!Array.isArray(t))throw Error("clipPolygonSH: subject must be an array");if(!Array.isArray(a))throw Error("clipPolygonSH: clip must be an array");if(t.length<3||a.length<3)return[];for(let r=0;r<t.length;r++)if(!t[r]||t[r].x===null||t[r].x===void 0||t[r].y===null||t[r].y===void 0)throw Error(`clipPolygonSH: subject[${r}] must have x and y properties`);for(let r=0;r<a.length;r++)if(!a[r]||a[r].x===null||a[r].x===void 0||a[r].y===null||a[r].y===void 0)throw Error(`clipPolygonSH: clip[${r}] must have x and y properties`);let e=t.map((r)=>R3(r.x,r.y)),i=a.map((r)=>R3(r.x,r.y));i=I0(i);for(let r=0;r<i.length;r++){if(e.length===0)return[];let l=i[r],o=i[(r+1)%i.length],x=e;e=[];for(let p=0;p<x.length;p++){let n=x[p],c=x[(p+x.length-1)%x.length],s=d6(n,l,o),m=d6(c,l,o);if(s){if(!m){let g=N6(c,n,l,o);if(g)e.push(g)}e.push(n)}else if(m){let g=N6(c,n,l,o);if(g)e.push(g)}}}return e}function d6(t,a,e){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("isInsideEdge: pt must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("isInsideEdge: edgeStart must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("isInsideEdge: edgeEnd must have x and y properties");return O4(a,e,t).gte(0)}function N6(t,a,e,i){if(!t||t.x===null||t.x===void 0||t.y===null||t.y===void 0)throw Error("lineIntersection: point a must have x and y properties");if(!a||a.x===null||a.x===void 0||a.y===null||a.y===void 0)throw Error("lineIntersection: point b must have x and y properties");if(!e||e.x===null||e.x===void 0||e.y===null||e.y===void 0)throw Error("lineIntersection: point c must have x and y properties");if(!i||i.x===null||i.x===void 0||i.y===null||i.y===void 0)throw Error("lineIntersection: point d must have x and y properties");let r=a.x.minus(t.x),l=a.y.minus(t.y),o=i.x.minus(e.x),x=i.y.minus(e.y),p=r.mul(x).minus(l.mul(o));if(p.abs().lt(m4))return null;let n=e.x.minus(t.x),c=e.y.minus(t.y),s=n.mul(x).minus(c.mul(o)).div(p);return{x:t.x.plus(r.mul(s)),y:t.y.plus(l.mul(s))}}function Y5(t){if(!Array.isArray(t))throw Error("polygonArea: polygon must be an array");let a=t.length;if(a<3)return u4(0);for(let i=0;i<a;i++)if(!t[i]||t[i].x===null||t[i].x===void 0||t[i].y===null||t[i].y===void 0)throw Error(`polygonArea: polygon[${i}] must have x and y properties`);let e=u4(0);for(let i=0;i<a;i++){let r=t[i],l=t[(i+1)%a];e=e.plus(r.x.mul(l.y).minus(l.x.mul(r.y)))}return e.div(2)}function B2(t){if(!Array.isArray(t))throw Error("isCounterClockwise: polygon must be an array");return Y5(t).gt(0)}function D2(t){if(!Array.isArray(t))throw Error("reversePolygon: polygon must be an array");return[...t].reverse()}function I0(t){if(!Array.isArray(t))throw Error("ensureCCW: polygon must be an array");if(!B2(t))return D2(t);return t}function R2(t){if(!Array.isArray(t))throw Error("convexHull: points must be an array");if(t.length<3){for(let o=0;o<t.length;o++)if(!t[o]||t[o].x===null||t[o].x===void 0||t[o].y===null||t[o].y===void 0)throw Error(`convexHull: points[${o}] must have x and y properties`);return t.map((o)=>R3(o.x,o.y))}for(let o=0;o<t.length;o++)if(!t[o]||t[o].x===null||t[o].x===void 0||t[o].y===null||t[o].y===void 0)throw Error(`convexHull: points[${o}] must have x and y properties`);let a=t.map((o)=>R3(o.x,o.y)),e=0;for(let o=1;o<a.length;o++)if(a[o].y.lt(a[e].y)||a[o].y.eq(a[e].y)&&a[o].x.lt(a[e].x))e=o;[a[0],a[e]]=[a[e],a[0]];let i=a[0],r=a.slice(1).sort((o,x)=>{let p=O4(i,o,x);if(p.abs().lt(m4)){let n=o.x.minus(i.x).pow(2).plus(o.y.minus(i.y).pow(2)),c=x.x.minus(i.x).pow(2).plus(x.y.minus(i.y).pow(2)),s=n.minus(c);if(s.abs().lt(m4))return 0;return s.lt(0)?-1:1}return-d2(p)}),l=[i];for(let o of r){while(l.length>1&&O4(l[l.length-2],l[l.length-1],o).lte(0))l.pop();l.push(o)}return l}function q4(t){if(!Array.isArray(t))throw Error("boundingBox: polygon must be an array");if(t.length===0)return null;if(!t[0]||t[0].x===null||t[0].x===void 0||t[0].y===null||t[0].y===void 0)throw Error("boundingBox: polygon[0] must have x and y properties");let a=u4(t[0].x),e=u4(t[0].y),i=u4(t[0].x),r=u4(t[0].y);for(let l=0;l<t.length;l++){let o=t[l];if(!o||o.x===null||o.x===void 0||o.y===null||o.y===void 0)throw Error(`boundingBox: polygon[${l}] must have x and y properties`);let x=u4(o.x),p=u4(o.y);if(x.lt(a))a=x;if(p.lt(e))e=p;if(x.gt(i))i=x;if(p.gt(r))r=p}return{minX:a,minY:e,maxX:i,maxY:r}}function M5(t,a){if(!t||!a)return!1;if(t.minX===null||t.minX===void 0||t.minY===null||t.minY===void 0||t.maxX===null||t.maxX===void 0||t.maxY===null||t.maxY===void 0)throw Error("bboxIntersects: bb1 must have minX, minY, maxX, maxY properties");if(a.minX===null||a.minX===void 0||a.minY===null||a.minY===void 0||a.maxX===null||a.maxX===void 0||a.maxY===null||a.maxY===void 0)throw Error("bboxIntersects: bb2 must have minX, minY, maxX, maxY properties");return!(t.maxX.lt(a.minX)||a.maxX.lt(t.minX)||t.maxY.lt(a.minY)||a.maxY.lt(t.minY))}function s0(t,a){if(!Array.isArray(t))throw Error("polygonIntersection: subject must be an array");if(!Array.isArray(a))throw Error("polygonIntersection: clip must be an array");for(let o=0;o<t.length;o++)if(!t[o]||t[o].x===null||t[o].x===void 0||t[o].y===null||t[o].y===void 0)throw Error(`polygonIntersection: subject[${o}] must have x and y properties`);for(let o=0;o<a.length;o++)if(!a[o]||a[o].x===null||a[o].x===void 0||a[o].y===null||a[o].y===void 0)throw Error(`polygonIntersection: clip[${o}] must have x and y properties`);let e=t.map((o)=>R3(o.x,o.y)),i=a.map((o)=>R3(o.x,o.y)),r=q4(e),l=q4(i);if(!M5(r,l))return[];if(w2(i)){let o=I2(e,I0(i));return o.length>=3?[o]:[]}return Cr(e,i)}function w2(t){if(!Array.isArray(t))throw Error("isConvex: polygon must be an array");let a=t.length;if(a<3)return!1;for(let i=0;i<a;i++)if(!t[i]||t[i].x===null||t[i].x===void 0||t[i].y===null||t[i].y===void 0)throw Error(`isConvex: polygon[${i}] must have x and y properties`);let e=0;for(let i=0;i<a;i++){let r=t[i],l=t[(i+1)%a],o=t[(i+2)%a],x=O4(r,l,o),p=x.gt(0)?1:x.lt(0)?-1:0;if(p!==0){if(e===0)e=p;else if(e!==p)return!1}}return!0}function Cr(t,a){if(!Array.isArray(t)||!Array.isArray(a))throw Error("generalPolygonIntersection: both arguments must be arrays");let e=[];for(let p=0;p<t.length;p++){let n=t[p],c=t[(p+1)%t.length];for(let s=0;s<a.length;s++){let m=a[s],g=a[(s+1)%a.length],u=N0(n,c,m,g);if(u)e.push(R3(u.x,u.y))}}let i=t.filter((p)=>P4(p,a)>=0),r=a.filter((p)=>P4(p,t)>=0),l=[...e,...i,...r];if(l.length<3)return[];let o=br(l);if(o.length<3)return[];let x=R2(o);return x.length>=3?[x]:[]}function br(t){if(!Array.isArray(t))throw Error("removeDuplicatePoints: points must be an array");let a=[];for(let e of t){let i=!1;for(let r of a)if(Q4(e,r)){i=!0;break}if(!i)a.push(e)}return a}function B0(t,a){if(!Array.isArray(t))throw Error("polygonUnion: polygon1 must be an array");if(!Array.isArray(a))throw Error("polygonUnion: polygon2 must be an array");for(let o=0;o<t.length;o++)if(!t[o]||t[o].x===null||t[o].x===void 0||t[o].y===null||t[o].y===void 0)throw Error(`polygonUnion: polygon1[${o}] must have x and y properties`);for(let o=0;o<a.length;o++)if(!a[o]||a[o].x===null||a[o].x===void 0||a[o].y===null||a[o].y===void 0)throw Error(`polygonUnion: polygon2[${o}] must have x and y properties`);let e=t.map((o)=>R3(o.x,o.y)),i=a.map((o)=>R3(o.x,o.y)),r=q4(e),l=q4(i);if(!M5(r,l))return[e,i];return Pr(e,i)}function Pr(t,a){if(!Array.isArray(t)||!Array.isArray(a))throw Error("traceBoundaryUnion: both arguments must be arrays");let e=Jt(t,a);if(e.length===0){let y=P4(t[0],a),v=P4(a[0],t);if(y>0)return[a];else if(v>0)return[t];else return[t,a]}let i=m0(t,e.map((y)=>({edgeIndex:y.edge1,t:y.t1,point:y.point,intersectionId:y.id}))),r=m0(a,e.map((y)=>({edgeIndex:y.edge2,t:y.t2,point:y.point,intersectionId:y.id}))),l=new Map;for(let y=0;y<i.length;y++)if(i[y].intersectionId!==void 0){if(!l.has(i[y].intersectionId))l.set(i[y].intersectionId,{});l.get(i[y].intersectionId).idx1=y}for(let y=0;y<r.length;y++)if(r[y].intersectionId!==void 0){if(!l.has(r[y].intersectionId))l.set(r[y].intersectionId,{});l.get(r[y].intersectionId).idx2=y}let o=1,x=-1;for(let y=0;y<i.length;y++){let v=i[y];if(v.intersectionId===void 0&&P4(v,a)<0){x=y;break}}if(x===-1){o=2;for(let y=0;y<r.length;y++){let v=r[y];if(v.intersectionId===void 0&&P4(v,t)<0){x=y;break}}}if(x===-1){let y=Y5(t).abs(),v=Y5(a).abs();return y.gt(v)?[t]:[a]}let p=[],n=o===1,c=x,s=new Set,m=(i.length+r.length)*3,g=0,u=`${o}-${x}`;while(g<m){g++;let y=n?i:r,v=n?r:i,E=y[c];if(p.length===0||!Q4(p[p.length-1],E))p.push(R3(E.x,E.y));let C=(c+1)%y.length,P=y[C];if(P.intersectionId!==void 0&&!s.has(P.intersectionId)){p.push(R3(P.x,P.y)),s.add(P.intersectionId);let S=l.get(P.intersectionId),f=n?S.idx2:S.idx1;n=!n,c=(f+1)%v.length}else c=C;if(`${n?1:2}-${c}`===u)break}if(p.length>1&&Q4(p[0],p[p.length-1]))p.pop();return p.length>=3?[p]:[]}function Jt(t,a){if(!Array.isArray(t)||!Array.isArray(a))throw Error("findAllIntersections: both arguments must be arrays");let e=[],i=0;for(let r=0;r<t.length;r++){let l=t[r],o=t[(r+1)%t.length];for(let x=0;x<a.length;x++){let p=a[x],n=a[(x+1)%a.length],c=N0(l,o,p,n);if(c)e.push({id:i++,point:R3(c.x,c.y),edge1:r,edge2:x,t1:c.t,t2:c.s})}}return e}function m0(t,a){if(!Array.isArray(t))throw Error("augmentPolygon: polygon must be an array");if(!Array.isArray(a))throw Error("augmentPolygon: insertions must be an array");let e=new Map;for(let r of a){if(!e.has(r.edgeIndex))e.set(r.edgeIndex,[]);e.get(r.edgeIndex).push(r)}for(let r of e.values())r.sort((l,o)=>l.t.minus(o.t).toNumber());let i=[];for(let r=0;r<t.length;r++)if(i.push({...t[r]}),e.has(r))for(let l of e.get(r))i.push({x:l.point.x,y:l.point.y,intersectionId:l.intersectionId});return i}function $t(t,a){if(!Array.isArray(t))throw Error("polygonDifference: polygon1 must be an array");if(!Array.isArray(a))throw Error("polygonDifference: polygon2 must be an array");for(let o=0;o<t.length;o++)if(!t[o]||t[o].x===null||t[o].x===void 0||t[o].y===null||t[o].y===void 0)throw Error(`polygonDifference: polygon1[${o}] must have x and y properties`);for(let o=0;o<a.length;o++)if(!a[o]||a[o].x===null||a[o].x===void 0||a[o].y===null||a[o].y===void 0)throw Error(`polygonDifference: polygon2[${o}] must have x and y properties`);let e=t.map((o)=>R3(o.x,o.y)),i=a.map((o)=>R3(o.x,o.y)),r=q4(e),l=q4(i);if(!M5(r,l))return[e];return Sr(e,i)}function Sr(t,a){if(!Array.isArray(t)||!Array.isArray(a))throw Error("traceBoundaryDifference: both arguments must be arrays");let e=Jt(t,a);if(e.length===0)if(P4(t[0],a)>0)return[];else return[t];let i=m0(t,e.map((g)=>({edgeIndex:g.edge1,t:g.t1,point:g.point,intersectionId:g.id}))),r=m0(a,e.map((g)=>({edgeIndex:g.edge2,t:g.t2,point:g.point,intersectionId:g.id}))),l=new Map;for(let g=0;g<i.length;g++)if(i[g].intersectionId!==void 0){if(!l.has(i[g].intersectionId))l.set(i[g].intersectionId,{});l.get(i[g].intersectionId).idx1=g}for(let g=0;g<r.length;g++)if(r[g].intersectionId!==void 0){if(!l.has(r[g].intersectionId))l.set(r[g].intersectionId,{});l.get(r[g].intersectionId).idx2=g}let o=-1;for(let g=0;g<i.length;g++){let u=i[g];if(u.intersectionId===void 0&&P4(u,a)<0){o=g;break}}if(o===-1)return[];let x=[],p=!0,n=o,c=new Set,s=(i.length+r.length)*3,m=0;while(m<s){m++;let g=(p?i:r)[n];if(x.length===0||!Q4(x[x.length-1],g))x.push(R3(g.x,g.y));let u=`${p?1:2}-${n}`;if(c.has(u))break;if(c.add(u),p){let y=(n+1)%i.length,v=i[y];if(v.intersectionId!==void 0){let E=i[(y+1)%i.length];if(P4(E,a)>0){let C=l.get(v.intersectionId);x.push(R3(v.x,v.y)),p=!1,n=(C.idx2-1+r.length)%r.length}else n=y}else n=y}else{let y=(n-1+r.length)%r.length,v=r[y];if(v.intersectionId!==void 0){let E=l.get(v.intersectionId);x.push(R3(v.x,v.y)),p=!0,n=(E.idx1+1)%i.length}else n=y}if(p&&n===o)break}if(x.length>1&&Q4(x[0],x[x.length-1]))x.pop();return x.length>=3?[x]:[]}var Tr={point:R3,pointsEqual:Q4,cross:O4,dot:Kt,sign:d2,segmentIntersection:N0,lineSegmentIntersection:Zt,pointInPolygon:P4,pointOnSegment:N2,clipPolygonSH:I2,polygonArea:Y5,isCounterClockwise:B2,reversePolygon:D2,ensureCCW:I0,isConvex:w2,convexHull:R2,boundingBox:q4,bboxIntersects:M5,polygonIntersection:s0,polygonUnion:B0,polygonDifference:$t,EPSILON:m4};h.set({precision:80});var $5=(t)=>t instanceof h?t:new h(t),w4=new h("1e-40"),{point:_4,pointsEqual:ux,cross:n2,polygonArea:Ex,polygonIntersection:Cx,polygonUnion:bx,polygonDifference:Px,isCounterClockwise:Sx,ensureCCW:Tx,segmentIntersection:Ax}=f2,D5={NONZERO:"nonzero",EVENODD:"evenodd"};function I6(t,a,e=D5.NONZERO){if(!t||typeof t!=="object")throw Error("pointInPolygonWithRule: pt must be an object with x, y properties");if(t.x===void 0||t.x===null||t.y===void 0||t.y===null)throw Error("pointInPolygonWithRule: pt must have x and y properties");if(!Array.isArray(a))throw Error("pointInPolygonWithRule: polygon must be an array");let i=a.length;if(i<3)return-1;let r=0;for(let l=0;l<i;l++){let o=a[l],x=a[(l+1)%i];if(Ar(t,o,x))return 0;if(o.y.lte(t.y)){if(x.y.gt(t.y)){if(n2(o,x,t).gt(0))r++}}else if(x.y.lte(t.y)){if(n2(o,x,t).lt(0))r--}}if(e===D5.EVENODD)return Math.abs(r)%2===1?1:-1;else return r!==0?1:-1}function Ar(t,a,e){if(!t||!a||!e)throw Error("pointOnSegment: pt, a, and b must be defined");if(t.x===void 0||t.x===null||t.y===void 0||t.y===null||a.x===void 0||a.x===null||a.y===void 0||a.y===null||e.x===void 0||e.x===null||e.y===void 0||e.y===null)throw Error("pointOnSegment: all points must have x and y properties");if(n2(a,e,t).abs().gt(w4))return!1;let i=h.min(a.x,e.x),r=h.max(a.x,e.x),l=h.min(a.y,e.y),o=h.max(a.y,e.y);return t.x.gte(i.minus(w4))&&t.x.lte(r.plus(w4))&&t.y.gte(l.minus(w4))&&t.y.lte(o.plus(w4))}function fr(t,a,e={}){if(!Array.isArray(t))throw Error("offsetPolygon: polygon must be an array");if(a===void 0||a===null)throw Error("offsetPolygon: distance must be defined");if(!e||typeof e!=="object")throw Error("offsetPolygon: options must be an object");let i=$5(a);if(i.lte(0))throw Error("offsetPolygon: distance must be positive");let r=e.linejoin||"miter",l=$5(e.miterLimit||4);if(t.length<3)return{outer:[],inner:[]};let o=t.length,x=[],p=[];for(let n=0;n<o;n++){let c=t[(n-1+o)%o],s=t[n],m=t[(n+1)%o],g=s.x.minus(c.x),u=s.y.minus(c.y),y=m.x.minus(s.x),v=m.y.minus(s.y),E=g.pow(2).plus(u.pow(2)).sqrt(),C=y.pow(2).plus(v.pow(2)).sqrt();if(E.lt(w4)||C.lt(w4))continue;let P=u.div(E),S=g.neg().div(E),f=v.div(C),B=y.neg().div(C),R=P.plus(f).div(2),k=S.plus(B).div(2),N=R.pow(2).plus(k.pow(2)).sqrt();if(N.lt(w4))R=P,k=S;else R=R.div(N),k=k.div(N);let I=P.times(f).plus(S.times(B)),d=$5(1).minus(I).div(2).sqrt(),Y=i;if(d.gt(w4)){let X=i.div(d);if(r==="miter"&&X.lte(i.times(l)))Y=X;else if(r==="bevel"||X.gt(i.times(l))){let F=_4(s.x.plus(P.times(i)),s.y.plus(S.times(i))),V=_4(s.x.plus(f.times(i)),s.y.plus(B.times(i)));x.push(F,V);let T=_4(s.x.minus(P.times(i)),s.y.minus(S.times(i))),j=_4(s.x.minus(f.times(i)),s.y.minus(B.times(i)));p.push(T,j);continue}else if(r==="round"){let F=Math.atan2(S.toNumber(),P.toNumber()),V=Math.atan2(B.toNumber(),f.toNumber())-F;if(V<-Math.PI)V+=2*Math.PI;if(V>Math.PI)V-=2*Math.PI;let T=Math.max(2,Math.ceil(Math.abs(V)/(Math.PI/8)));for(let j=0;j<=T;j++){let A=F+V*(j/T);x.push(_4(s.x.plus(i.times(Math.cos(A))),s.y.plus(i.times(Math.sin(A))))),p.push(_4(s.x.minus(i.times(Math.cos(A))),s.y.minus(i.times(Math.sin(A)))))}continue}}x.push(_4(s.x.plus(R.times(Y)),s.y.plus(k.times(Y)))),p.push(_4(s.x.minus(R.times(Y)),s.y.minus(k.times(Y))))}return{outer:x,inner:p.reverse()}}function B6(t,a){if(!Array.isArray(t))throw Error("strokeToFilledPolygon: polygon must be an array");if(!a||typeof a!=="object")throw Error("strokeToFilledPolygon: strokeProps must be an object");if(a.width===void 0||a.width===null)throw Error("strokeToFilledPolygon: strokeProps must have width property");let e=$5(a.width).div(2);if(e.lte(0))throw Error("strokeToFilledPolygon: width must be positive");return fr(t,e,a).outer}h.set({precision:80});var f4=(t)=>t instanceof h?t:new h(t),dr={fill:"black","fill-rule":"nonzero","fill-opacity":1,stroke:"none","stroke-width":1,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":4,"stroke-dasharray":"none","stroke-dashoffset":0,"stroke-opacity":1,"marker-start":"none","marker-mid":"none","marker-end":"none","paint-order":"normal","clip-path":"none","clip-rule":"nonzero",mask:"none","mask-type":"luminance",opacity:1,transform:"none","vector-effect":"none",filter:"none"};class L2{constructor(t,a={},e=null){if(!t)throw Error("SVGRenderingContext: element parameter is required");if(a!==null&&typeof a!=="object")throw Error("SVGRenderingContext: inherited must be an object or null");this.element=t,this.defsMap=e||new Map,this.properties=this._extractProperties(t,a||{}),this.dashArray=this._parseDashArray(this.properties["stroke-dasharray"]),this.dashOffset=f4(this.properties["stroke-dashoffset"]||0),this.markers={start:this._parseMarkerRef(this.properties["marker-start"]),mid:this._parseMarkerRef(this.properties["marker-mid"]),end:this._parseMarkerRef(this.properties["marker-end"])},this.hasFill=this.properties.fill!=="none"&&this.properties["fill-opacity"]>0,this.hasStroke=this.properties.stroke!=="none"&&f4(this.properties["stroke-width"]).gt(0)&&this.properties["stroke-opacity"]>0,this.hasMarkers=this.markers.start||this.markers.mid||this.markers.end}_extractProperties(t,a){if(a!==null&&typeof a!=="object")throw Error("_extractProperties: inherited must be an object or null");let e={...dr,...a||{}};if(t&&t.getAttributeNames)for(let r of t.getAttributeNames()){let l=t.getAttribute(r);if(l!==null&&l!==void 0)e[r]=l}if(e.style){let r=this._parseStyleAttribute(e.style);Object.assign(e,r)}let i=["stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity"];for(let r of i)if(typeof e[r]==="string"){let l=parseFloat(e[r]);if(!isNaN(l))e[r]=l}return e}_parseStyleAttribute(t){let a={};if(!t)return a;let e=t.split(";");for(let i of e){if(!i.includes(":"))continue;let[r,l]=i.split(":").map((o)=>o.trim());if(r&&l)a[r]=l}return a}_parseDashArray(t){if(!t||t==="none")return null;let a=t.toString().split(/[\s,]+/).filter((i)=>i),e=[];for(let i of a){let r=parseFloat(i);if(isNaN(r)||!isFinite(r))throw Error(`_parseDashArray: invalid dash value '${i}'`);if(r<0)throw Error(`_parseDashArray: dash values must be non-negative, got ${r}`);e.push(f4(r))}if(e.length===0)return null;if(e.length%2===1)return[...e,...e];return e}_parseMarkerRef(t){if(!t||t==="none")return null;let a=t.match(/url\(#?([^)]+)\)/);return a?a[1]:null}get fillRule(){return this.properties["fill-rule"]||"nonzero"}get clipRule(){return this.properties["clip-rule"]||"nonzero"}get strokeWidth(){return f4(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return f4(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return f4(0);let t=this.strokeWidth.div(2),a=t;if(this.strokeLinejoin==="miter")a=t.times(this.strokeMiterlimit);if(this.strokeLinecap==="square"){let e=t.times(2);if(e.gt(a))a=e}return a}expandBBoxForStroke(t){if(!t||typeof t!=="object")throw Error("expandBBoxForStroke: bbox must be an object");if(!("x"in t)||!("y"in t)||!("width"in t)||!("height"in t))throw Error("expandBBoxForStroke: bbox must have x, y, width, height properties");if(typeof t.x.minus!=="function"||typeof t.y.minus!=="function"||typeof t.width.plus!=="function"||typeof t.height.plus!=="function")throw Error("expandBBoxForStroke: bbox properties must be Decimal instances");if(!this.hasStroke)return t;let a=this.getStrokeExtent();return{x:t.x.minus(a),y:t.y.minus(a),width:t.width.plus(a.times(2)),height:t.height.plus(a.times(2))}}expandBBoxForMarkers(t,a=null){if(!t||typeof t!=="object")throw Error("expandBBoxForMarkers: bbox must be an object");if(!("x"in t)||!("y"in t)||!("width"in t)||!("height"in t))throw Error("expandBBoxForMarkers: bbox must have x, y, width, height properties");if(typeof t.x.minus!=="function"||typeof t.y.minus!=="function"||typeof t.width.plus!=="function"||typeof t.height.plus!=="function")throw Error("expandBBoxForMarkers: bbox properties must be Decimal instances");if(!this.hasMarkers)return t;let e=f4(0);if(a){if(typeof a!=="object")throw Error("expandBBoxForMarkers: markerSizes must be an object");let r=[a.start,a.mid,a.end].filter((l)=>l!==null&&l!==void 0).map((l)=>{let o=typeof l==="number"?l:parseFloat(l);if(isNaN(o)||!isFinite(o))throw Error(`expandBBoxForMarkers: invalid marker size '${l}'`);return f4(o)});if(r.length>0)e=h.max(...r)}else e=this.strokeWidth.times(3);if(e.lte(0))return t;let i=e.div(2);return{x:t.x.minus(i),y:t.y.minus(i),width:t.width.plus(i.times(2)),height:t.height.plus(i.times(2))}}expandBBoxForFilter(t,a=null){if(!t||typeof t!=="object")throw Error("expandBBoxForFilter: bbox must be an object");if(!("x"in t)||!("y"in t)||!("width"in t)||!("height"in t))throw Error("expandBBoxForFilter: bbox must have x, y, width, height properties");if(typeof t.x.minus!=="function"||typeof t.y.minus!=="function"||typeof t.width.times!=="function"||typeof t.height.times!=="function")throw Error("expandBBoxForFilter: bbox properties must be Decimal instances");let e=this.properties.filter;if(!e||e==="none")return t;let i=t.width.times("0.1"),r=t.height.times("0.1");if(a){if(typeof a!=="object")throw Error("expandBBoxForFilter: filterDef must be an object");if(a.x!==void 0){let l=parseFloat(a.x);if(isNaN(l)||!isFinite(l))throw Error(`expandBBoxForFilter: invalid filterDef.x value '${a.x}'`);i=f4(l).abs()}if(a.y!==void 0){let l=parseFloat(a.y);if(isNaN(l)||!isFinite(l))throw Error(`expandBBoxForFilter: invalid filterDef.y value '${a.y}'`);r=f4(l).abs()}}return{x:t.x.minus(i),y:t.y.minus(r),width:t.width.plus(i.times(2)),height:t.height.plus(r.times(2))}}getRenderedBBox(t,a={}){if(!t||typeof t!=="object")throw Error("getRenderedBBox: geometryBBox must be an object");if(!("x"in t)||!("y"in t)||!("width"in t)||!("height"in t))throw Error("getRenderedBBox: geometryBBox must have x, y, width, height properties");if(typeof t.x.minus!=="function"||typeof t.y.minus!=="function")throw Error("getRenderedBBox: geometryBBox properties must be Decimal instances");if(a!==null&&typeof a!=="object")throw Error("getRenderedBBox: options must be an object or null");let e={...t};return e=this.expandBBoxForStroke(e),e=this.expandBBoxForMarkers(e,a.markerSizes),e=this.expandBBoxForFilter(e,a.filterDef),e}getFilledArea(t){if(!Array.isArray(t))throw Error("getFilledArea: polygon must be an array");if(t.length===0)throw Error("getFilledArea: polygon must not be empty");let a=[];if(this.hasFill)a.push({polygon:t,fillRule:this.fillRule,type:"fill"});if(this.hasStroke){let e=B6(t,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(e&&e.length>0)a.push({polygon:e,fillRule:"nonzero",type:"stroke"})}return a}isPointInRenderedArea(t,a){if(!t||typeof t!=="object")throw Error("isPointInRenderedArea: point must be an object");if(t.x===void 0||t.y===void 0)throw Error("isPointInRenderedArea: point must have x and y properties");if(!Array.isArray(a))throw Error("isPointInRenderedArea: polygon must be an array");if(a.length===0)throw Error("isPointInRenderedArea: polygon must not be empty");if(this.hasFill){let e=this.fillRule==="evenodd"?D5.EVENODD:D5.NONZERO;if(I6(t,a,e)>=0)return!0}if(this.hasStroke){let e=B6(a,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(e&&e.length>0){if(I6(t,e,D5.NONZERO)>=0)return!0}}return!1}canMergeWith(t){if(!(t instanceof L2))throw Error("canMergeWith: other must be an instance of SVGRenderingContext");if(this.fillRule!==t.fillRule)return{canMerge:!1,reason:"Different fill-rule"};if(this.hasStroke||t.hasStroke){if(this.hasStroke!==t.hasStroke)return{canMerge:!1,reason:"Different stroke presence"};if(!this.strokeWidth.eq(t.strokeWidth))return{canMerge:!1,reason:"Different stroke-width"};if(this.strokeLinecap!==t.strokeLinecap)return{canMerge:!1,reason:"Different stroke-linecap"};if(this.strokeLinejoin!==t.strokeLinejoin)return{canMerge:!1,reason:"Different stroke-linejoin"}}if(this.hasMarkers||t.hasMarkers)return{canMerge:!1,reason:"Has markers"};if(this.properties["clip-path"]!=="none"||t.properties["clip-path"]!=="none")return{canMerge:!1,reason:"Has clip-path"};if(this.properties.mask!=="none"||t.properties.mask!=="none")return{canMerge:!1,reason:"Has mask"};if(this.properties.filter!=="none"||t.properties.filter!=="none")return{canMerge:!1,reason:"Has filter"};return{canMerge:!0,reason:null}}toSummary(){return{hasFill:this.hasFill,hasStroke:this.hasStroke,hasMarkers:this.hasMarkers,fillRule:this.fillRule,strokeWidth:this.hasStroke?this.strokeWidth.toNumber():0,strokeExtent:this.getStrokeExtent().toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,clipPath:this.properties["clip-path"],filter:this.properties.filter}}}function g0(t,a={},e=null){if(!t)throw Error("createRenderingContext: element parameter is required");return new L2(t,a,e)}function y0(t){if(!t)throw Error("getInheritedProperties: element parameter is required");let a={},e=["fill","fill-rule","fill-opacity","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","stroke-opacity","marker-start","marker-mid","marker-end","clip-rule","opacity","font-family","font-size","font-style","font-weight"];if(!t.parentNode)return a;let i=t.parentNode;while(i&&i.tagName){for(let r of e)if(a[r]===void 0){let l=i.getAttribute?i.getAttribute(r):null;if(l!==null&&l!==void 0)a[r]=l}i=i.parentNode}return a}var ta={};U4(ta,{serializeSVG:()=>C4,parseUrlReference:()=>Z4,parseSVG:()=>_3,findElementsWithAttribute:()=>V4,default:()=>Br,buildDefsMap:()=>K4,SVGElement:()=>T3});h.set({precision:80});function aa(t,a){if(!t||!a)throw Error("setOwnerDocument: element and document are required");if(!t.children||!Array.isArray(t.children))throw Error("setOwnerDocument: element must have a children array");t.ownerDocument=a;for(let e of t.children)if(e instanceof T3)aa(e,a)}function _3(t){if(typeof t!=="string")throw Error("parseSVG: input must be a string");if(t.trim().length===0)throw Error("parseSVG: input cannot be empty");let a=t.trim(),e=ia(a,0);if(!e.element)throw Error("Failed to parse SVG: no root element found");let i=new ea(e.element);return aa(e.element,i),e.element}class ea{constructor(t=null){this.documentElement=t}createElement(t){if(!t||typeof t!=="string")throw Error("createElement: tagName must be a non-empty string");let a=new T3(t);return a.ownerDocument=this,a}createElementNS(t,a){if(t!==null&&t!==void 0&&typeof t!=="string")throw Error("createElementNS: namespace must be a string");return this.createElement(a)}}class T3{constructor(t,a={},e=[],i=""){if(!t||typeof t!=="string")throw Error("SVGElement: tagName must be a non-empty string");if(a!==null&&typeof a!=="object")throw Error("SVGElement: attributes must be an object");if(!Array.isArray(e))throw Error("SVGElement: children must be an array");if(typeof i!=="string")throw Error("SVGElement: textContent must be a string");this.tagName=t,this.nodeName=t.toUpperCase(),this._attributes={...a},this.children=e,this.childNodes=e,this.textContent=i,this.parentNode=null,this.ownerDocument=null;for(let r of e)if(r instanceof T3)r.parentNode=this}getAttribute(t){if(typeof t!=="string")throw Error("getAttribute: name must be a string");return this._attributes[t]??null}setAttribute(t,a){if(typeof t!=="string")throw Error("setAttribute: name must be a string");if(a!==null&&a!==void 0)this._attributes[t]=String(a);else this._attributes[t]=""}hasAttribute(t){if(typeof t!=="string")throw Error("hasAttribute: name must be a string");return t in this._attributes}removeAttribute(t){if(typeof t!=="string")throw Error("removeAttribute: name must be a string");delete this._attributes[t]}getAttributeNames(){return Object.keys(this._attributes)}getElementsByTagName(t){if(typeof t!=="string")throw Error("getElementsByTagName: tagName must be a string");if(t.length===0)return[];let a=t.toLowerCase(),e=[],i=(r)=>{for(let l of r.children)if(l instanceof T3){if(l.tagName.toLowerCase()===a||a==="*")e.push(l);i(l)}};return i(this),e}getElementById(t){if(typeof t!=="string")throw Error("getElementById: id must be a string");if(t.length===0)return null;let a=(e)=>{if(e.getAttribute("id")===t)return e;for(let i of e.children)if(i instanceof T3){let r=a(i);if(r)return r}return null};return a(this)}querySelector(t){if(typeof t!=="string")throw Error("querySelector: selector must be a string");return this.querySelectorAll(t)[0]||null}querySelectorAll(t){if(typeof t!=="string")throw Error("querySelectorAll: selector must be a string");let a=[],e=D6(t),i=(r)=>{for(let l of r.children)if(l instanceof T3){if(R6(l,e))a.push(l);i(l)}};return i(this),a}matches(t){if(typeof t!=="string")throw Error("matches: selector must be a string");let a=D6(t);return R6(this,a)}cloneNode(t=!0){if(typeof t!=="boolean")throw Error("cloneNode: deep must be a boolean");let a=t?this.children.map((i)=>i instanceof T3?i.cloneNode(!0):i):[],e=new T3(this.tagName,{...this._attributes},a,this.textContent);if(this.ownerDocument){let i=(r,l)=>{r.ownerDocument=l;for(let o of r.children)if(o instanceof T3)i(o,l)};i(e,this.ownerDocument)}return e}appendChild(t){if(t===null||t===void 0)throw Error("appendChild: child cannot be null or undefined");if(t instanceof T3&&t.parentNode)t.parentNode.removeChild(t);if(t instanceof T3)t.parentNode=this;return this.children.push(t),this.childNodes=this.children,t}removeChild(t){if(t===null||t===void 0)throw Error("removeChild: child cannot be null or undefined");let a=this.children.indexOf(t);if(a>=0){if(this.children.splice(a,1),this.childNodes=this.children,t instanceof T3)t.parentNode=null}return t}insertBefore(t,a){if(t===null||t===void 0)throw Error("insertBefore: newChild cannot be null or undefined");if(a===null||a===void 0)throw Error("insertBefore: refChild cannot be null or undefined");if(t instanceof T3&&t.parentNode)t.parentNode.removeChild(t);let e=this.children.indexOf(a);if(e>=0){if(t instanceof T3)t.parentNode=this;this.children.splice(e,0,t),this.childNodes=this.children}else this.appendChild(t);return t}replaceChild(t,a){if(t===null||t===void 0)throw Error("replaceChild: newChild cannot be null or undefined");if(a===null||a===void 0)throw Error("replaceChild: oldChild cannot be null or undefined");if(t instanceof T3&&t.parentNode)t.parentNode.removeChild(t);let e=this.children.indexOf(a);if(e>=0){if(a instanceof T3)a.parentNode=null;if(t instanceof T3)t.parentNode=this;this.children[e]=t,this.childNodes=this.children}return a}get style(){let t=this.getAttribute("style")||"",a={};if(t.length===0)return a;return t.split(";").forEach((e)=>{let i=e.indexOf(":");if(i>0){let r=e.slice(0,i).trim(),l=e.slice(i+1).trim();if(r&&l)a[r]=l}}),a}get firstChild(){return this.children[0]||null}get lastChild(){return this.children[this.children.length-1]||null}get nextSibling(){if(!this.parentNode)return null;let t=this.parentNode.children,a=t.indexOf(this);return t[a+1]||null}get previousSibling(){if(!this.parentNode)return null;let t=this.parentNode.children,a=t.indexOf(this);return a>0?t[a-1]:null}serialize(t=0,a=!1){if(typeof t!=="number"||!Number.isFinite(t)||t<0)throw Error("serialize: indent must be a non-negative finite number");if(typeof a!=="boolean")throw Error("serialize: minify must be a boolean");let e=a?"":" ".repeat(t),i=this._attributes["data-cdata-pending"]==="true",r=Object.entries(this._attributes).filter(([n])=>n!=="data-cdata-pending").map(([n,c])=>`${n}="${Nr(c)}"`).join(" "),l=r?" "+r:"";if(this.children.length===0&&!this.textContent)return`${e}<${this.tagName}${l}/>`;let o=a?"":`
|
|
9
|
-
`,
|
|
1
|
+
var bK=Object.create;var{getPrototypeOf:fK,defineProperty:u$,getOwnPropertyNames:sJ,getOwnPropertyDescriptor:SK}=Object,oJ=Object.prototype.hasOwnProperty;var i7=($,J,Z)=>{Z=$!=null?bK(fK($)):{};let K=J||!$||!$.__esModule?u$(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of sJ($))if(!oJ.call(K,Q))u$(K,Q,{get:()=>$[Q],enumerable:!0});return K},lJ=new WeakMap,vK=($)=>{var J=lJ.get($),Z;if(J)return J;if(J=u$({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")sJ($).map((K)=>!oJ.call(J,K)&&u$(J,K,{get:()=>$[K],enumerable:!(Z=SK($,K))||Z.enumerable}));return lJ.set($,J),J};var x7=($,J)=>{for(var Z in J)u$($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var iJ=($,J)=>()=>($&&(J=$($=0)),J);var T7=(($)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy($,{get:(J,Z)=>(typeof require!=="undefined"?require:J)[Z]}):$)(function($){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var V$={};x7(V$,{win32:()=>_J,toNamespacedPath:()=>VW,sep:()=>wW,resolve:()=>jW,relative:()=>UW,posix:()=>H$,parse:()=>kW,normalize:()=>GW,join:()=>_W,isAbsolute:()=>FW,format:()=>XW,extname:()=>MW,dirname:()=>OW,delimiter:()=>LW,default:()=>zW,basename:()=>YW});var tH,s5,eH,$W,JW,ZW,KW=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),QW=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of $W(J))!ZW.call($,Q)&&Q!==Z&&s5($,Q,{get:()=>J[Q],enumerable:!(K=eH(J,Q))||K.enumerable});return $},qW=($,J,Z)=>(Z=$!=null?tH(JW($)):{},QW(J||!$||!$.__esModule?s5(Z,"default",{value:$,enumerable:!0}):Z,$)),HW,o5,p0,WW,l5=function($){return $},i5=function(){throw new Error("Not implemented")},H$,_J,zW,jW,GW,FW,_W,UW,VW,OW,YW,MW,XW,kW,wW,LW;var O$=iJ(()=>{tH=Object.create,s5=Object.defineProperty,eH=Object.getOwnPropertyDescriptor,$W=Object.getOwnPropertyNames,JW=Object.getPrototypeOf,ZW=Object.prototype.hasOwnProperty,HW=KW(($,J)=>{function Z(H){if(typeof H!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(H))}function K(H,W){for(var z="",j=0,G=-1,F=0,_,U=0;U<=H.length;++U){if(U<H.length)_=H.charCodeAt(U);else{if(_===47)break;_=47}if(_===47){if(!(G===U-1||F===1))if(G!==U-1&&F===2){if(z.length<2||j!==2||z.charCodeAt(z.length-1)!==46||z.charCodeAt(z.length-2)!==46){if(z.length>2){var M=z.lastIndexOf("/");if(M!==z.length-1){M===-1?(z="",j=0):(z=z.slice(0,M),j=z.length-1-z.lastIndexOf("/")),G=U,F=0;continue}}else if(z.length===2||z.length===1){z="",j=0,G=U,F=0;continue}}W&&(z.length>0?z+="/..":z="..",j=2)}else z.length>0?z+="/"+H.slice(G+1,U):z=H.slice(G+1,U),j=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return z}function Q(H,W){var z=W.dir||W.root,j=W.base||(W.name||"")+(W.ext||"");return z?z===W.root?z+j:z+H+j:j}var q={resolve:function(){for(var H="",W=!1,z,j=arguments.length-1;j>=-1&&!W;j--){var G;j>=0?G=arguments[j]:(z===void 0&&(z=process.cwd()),G=z),Z(G),G.length!==0&&(H=G+"/"+H,W=G.charCodeAt(0)===47)}return H=K(H,!W),W?H.length>0?"/"+H:"/":H.length>0?H:"."},normalize:function(H){if(Z(H),H.length===0)return".";var W=H.charCodeAt(0)===47,z=H.charCodeAt(H.length-1)===47;return H=K(H,!W),H.length===0&&!W&&(H="."),H.length>0&&z&&(H+="/"),W?"/"+H:H},isAbsolute:function(H){return Z(H),H.length>0&&H.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var H,W=0;W<arguments.length;++W){var z=arguments[W];Z(z),z.length>0&&(H===void 0?H=z:H+="/"+z)}return H===void 0?".":q.normalize(H)},relative:function(H,W){if(Z(H),Z(W),H===W||(H=q.resolve(H),W=q.resolve(W),H===W))return"";for(var z=1;z<H.length&&H.charCodeAt(z)===47;++z);for(var j=H.length,G=j-z,F=1;F<W.length&&W.charCodeAt(F)===47;++F);for(var _=W.length,U=_-F,M=G<U?G:U,V=-1,Y=0;Y<=M;++Y){if(Y===M){if(U>M){if(W.charCodeAt(F+Y)===47)return W.slice(F+Y+1);if(Y===0)return W.slice(F+Y)}else G>M&&(H.charCodeAt(z+Y)===47?V=Y:Y===0&&(V=0));break}var X=H.charCodeAt(z+Y),k=W.charCodeAt(F+Y);if(X!==k)break;X===47&&(V=Y)}var w="";for(Y=z+V+1;Y<=j;++Y)(Y===j||H.charCodeAt(Y)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+W.slice(F+V):(F+=V,W.charCodeAt(F)===47&&++F,W.slice(F))},_makeLong:function(H){return H},dirname:function(H){if(Z(H),H.length===0)return".";for(var W=H.charCodeAt(0),z=W===47,j=-1,G=!0,F=H.length-1;F>=1;--F)if(W=H.charCodeAt(F),W===47){if(!G){j=F;break}}else G=!1;return j===-1?z?"/":".":z&&j===1?"//":H.slice(0,j)},basename:function(H,W){if(W!==void 0&&typeof W!="string")throw new TypeError('"ext" argument must be a string');Z(H);var z=0,j=-1,G=!0,F;if(W!==void 0&&W.length>0&&W.length<=H.length){if(W.length===H.length&&W===H)return"";var _=W.length-1,U=-1;for(F=H.length-1;F>=0;--F){var M=H.charCodeAt(F);if(M===47){if(!G){z=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(M===W.charCodeAt(_)?--_===-1&&(j=F):(_=-1,j=U))}return z===j?j=U:j===-1&&(j=H.length),H.slice(z,j)}else{for(F=H.length-1;F>=0;--F)if(H.charCodeAt(F)===47){if(!G){z=F+1;break}}else j===-1&&(G=!1,j=F+1);return j===-1?"":H.slice(z,j)}},extname:function(H){Z(H);for(var W=-1,z=0,j=-1,G=!0,F=0,_=H.length-1;_>=0;--_){var U=H.charCodeAt(_);if(U===47){if(!G){z=_+1;break}continue}j===-1&&(G=!1,j=_+1),U===46?W===-1?W=_:F!==1&&(F=1):W!==-1&&(F=-1)}return W===-1||j===-1||F===0||F===1&&W===j-1&&W===z+1?"":H.slice(W,j)},format:function(H){if(H===null||typeof H!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof H);return Q("/",H)},parse:function(H){Z(H);var W={root:"",dir:"",base:"",ext:"",name:""};if(H.length===0)return W;var z=H.charCodeAt(0),j=z===47,G;j?(W.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,M=!0,V=H.length-1,Y=0;V>=G;--V){if(z=H.charCodeAt(V),z===47){if(!M){_=V+1;break}continue}U===-1&&(M=!1,U=V+1),z===46?F===-1?F=V:Y!==1&&(Y=1):F!==-1&&(Y=-1)}return F===-1||U===-1||Y===0||Y===1&&F===U-1&&F===_+1?U!==-1&&(_===0&&j?W.base=W.name=H.slice(1,U):W.base=W.name=H.slice(_,U)):(_===0&&j?(W.name=H.slice(1,F),W.base=H.slice(1,U)):(W.name=H.slice(_,F),W.base=H.slice(_,U)),W.ext=H.slice(F,U)),_>0?W.dir=H.slice(0,_-1):j&&(W.dir="/"),W},sep:"/",delimiter:":",win32:null,posix:null};q.posix=q,J.exports=q}),o5=qW(HW()),p0=o5,WW=o5;p0.parse??=i5;WW.parse??=i5;H$={resolve:p0.resolve.bind(p0),normalize:p0.normalize.bind(p0),isAbsolute:p0.isAbsolute.bind(p0),join:p0.join.bind(p0),relative:p0.relative.bind(p0),toNamespacedPath:l5,dirname:p0.dirname.bind(p0),basename:p0.basename.bind(p0),extname:p0.extname.bind(p0),format:p0.format.bind(p0),parse:p0.parse.bind(p0),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:l5},_J={sep:"\\",delimiter:";",win32:void 0,...H$,posix:H$};H$.win32=_J.win32=_J;H$.posix=H$;zW=H$,{resolve:jW,normalize:GW,isAbsolute:FW,join:_W,relative:UW,toNamespacedPath:VW,dirname:OW,basename:YW,extname:MW,format:XW,parse:kW,sep:wW,delimiter:LW}=H$});var CK={};x7(CK,{resolveObject:()=>IK,resolve:()=>NK,parse:()=>h$,format:()=>BK,default:()=>wz,Url:()=>X7,URLSearchParams:()=>LK,URL:()=>bJ});function fJ($){return typeof $=="string"}function RK($){return typeof $=="object"&&$!==null}function Q9($){return $===null}function Fz($){return $==null}function X7(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function h$($,J,Z){if($&&RK($)&&$ instanceof X7)return $;var K=new X7;return K.parse($,J,Z),K}function BK($){return fJ($)&&($=h$($)),$ instanceof X7?$.format():X7.prototype.format.call($)}function NK($,J){return h$($,!1,!0).resolve(J)}function IK($,J){return $?h$($,!1,!0).resolveObject(J):J}var bJ,LK,_z,Uz,Vz,Oz,Yz,AJ,XK,kK,Mz=255,wK,Xz,kz,EJ,D$,TJ,wz;var PK=iJ(()=>{({URL:bJ,URLSearchParams:LK}=globalThis);_z=/^([a-z0-9.+-]+:)/i,Uz=/:[0-9]*$/,Vz=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Oz=["<",">",'"',"`"," ","\r",`
|
|
2
|
+
`,"\t"],Yz=["{","}","|","\\","^","`"].concat(Oz),AJ=["'"].concat(Yz),XK=["%","/","?",";","#"].concat(AJ),kK=["/","?","#"],wK=/^[+a-z0-9A-Z_-]{0,63}$/,Xz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,kz={javascript:!0,"javascript:":!0},EJ={javascript:!0,"javascript:":!0},D$={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},TJ={parse($){var J=decodeURIComponent;return($+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(Z,K,Q){var q=K.split("="),H=J(q[0]||""),W=J(q[1]||""),z=Z[H];return Z[H]=z===void 0?W:[].concat(z,W),Z},{})},stringify($){var J=encodeURIComponent;return Object.keys($||{}).reduce(function(Z,K){return[].concat($[K]).forEach(function(Q){Z.push(J(K)+"="+J(Q))}),Z},[]).join("&").replace(/\s/g,"+")}};X7.prototype.parse=function($,J,Z){if(!fJ($))throw new TypeError("Parameter 'url' must be a string, not "+typeof $);var K=$.indexOf("?"),Q=K!==-1&&K<$.indexOf("#")?"?":"#",q=$.split(Q),H=/\\/g;q[0]=q[0].replace(H,"/"),$=q.join(Q);var W=$;if(W=W.trim(),!Z&&$.split("#").length===1){var z=Vz.exec(W);if(z)return this.path=W,this.href=W,this.pathname=z[1],z[2]?(this.search=z[2],J?this.query=TJ.parse(this.search.substr(1)):this.query=this.search.substr(1)):J&&(this.search="",this.query={}),this}var j=_z.exec(W);if(j){j=j[0];var G=j.toLowerCase();this.protocol=G,W=W.substr(j.length)}if(Z||j||W.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=W.substr(0,2)==="//";F&&!(j&&EJ[j])&&(W=W.substr(2),this.slashes=!0)}if(!EJ[j]&&(F||j&&!D$[j])){for(var _=-1,U=0;U<kK.length;U++){var M=W.indexOf(kK[U]);M!==-1&&(_===-1||M<_)&&(_=M)}var V,Y;_===-1?Y=W.lastIndexOf("@"):Y=W.lastIndexOf("@",_),Y!==-1&&(V=W.slice(0,Y),W=W.slice(Y+1),this.auth=decodeURIComponent(V)),_=-1;for(var U=0;U<XK.length;U++){var M=W.indexOf(XK[U]);M!==-1&&(_===-1||M<_)&&(_=M)}_===-1&&(_=W.length),this.host=W.slice(0,_),W=W.slice(_),this.parseHost(),this.hostname=this.hostname||"";var X=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!X)for(var k=this.hostname.split(/\./),U=0,w=k.length;U<w;U++){var R=k[U];if(!!R&&!R.match(wK)){for(var I="",P=0,u=R.length;P<u;P++)R.charCodeAt(P)>127?I+="x":I+=R[P];if(!I.match(wK)){var g=k.slice(0,U),b=k.slice(U+1),h=R.match(Xz);h&&(g.push(h[1]),b.unshift(h[2])),b.length&&(W="/"+b.join(".")+W),this.hostname=g.join(".");break}}}this.hostname.length>Mz?this.hostname="":this.hostname=this.hostname.toLowerCase(),X||(this.hostname=new bJ(`https://${this.hostname}`).hostname);var v=this.port?":"+this.port:"",E=this.hostname||"";this.host=E+v,this.href+=this.host,X&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),W[0]!=="/"&&(W="/"+W))}if(!kz[G])for(var U=0,w=AJ.length;U<w;U++){var m=AJ[U];if(W.indexOf(m)!==-1){var c=encodeURIComponent(m);c===m&&(c=escape(m)),W=W.split(m).join(c)}}var d=W.indexOf("#");d!==-1&&(this.hash=W.substr(d),W=W.slice(0,d));var N=W.indexOf("?");if(N!==-1?(this.search=W.substr(N),this.query=W.substr(N+1),J&&(this.query=TJ.parse(this.query)),W=W.slice(0,N)):J&&(this.search="",this.query={}),W&&(this.pathname=W),D$[G]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var v=this.pathname||"",y=this.search||"";this.path=v+y}return this.href=this.format(),this};X7.prototype.format=function(){var $=this.auth||"";$&&($=encodeURIComponent($),$=$.replace(/%3A/i,":"),$+="@");var J=this.protocol||"",Z=this.pathname||"",K=this.hash||"",Q=!1,q="";this.host?Q=$+this.host:this.hostname&&(Q=$+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Q+=":"+this.port)),this.query&&RK(this.query)&&Object.keys(this.query).length&&(q=TJ.stringify(this.query));var H=this.search||q&&"?"+q||"";return J&&J.substr(-1)!==":"&&(J+=":"),this.slashes||(!J||D$[J])&&Q!==!1?(Q="//"+(Q||""),Z&&Z.charAt(0)!=="/"&&(Z="/"+Z)):Q||(Q=""),K&&K.charAt(0)!=="#"&&(K="#"+K),H&&H.charAt(0)!=="?"&&(H="?"+H),Z=Z.replace(/[?#]/g,function(W){return encodeURIComponent(W)}),H=H.replace("#","%23"),J+Q+Z+H+K};X7.prototype.resolve=function($){return this.resolveObject(h$($,!1,!0)).format()};X7.prototype.resolveObject=function($){if(fJ($)){var J=new X7;J.parse($,!1,!0),$=J}for(var Z=new X7,K=Object.keys(this),Q=0;Q<K.length;Q++){var q=K[Q];Z[q]=this[q]}if(Z.hash=$.hash,$.href==="")return Z.href=Z.format(),Z;if($.slashes&&!$.protocol){for(var H=Object.keys($),W=0;W<H.length;W++){var z=H[W];z!=="protocol"&&(Z[z]=$[z])}return D$[Z.protocol]&&Z.hostname&&!Z.pathname&&(Z.path=Z.pathname="/"),Z.href=Z.format(),Z}if($.protocol&&$.protocol!==Z.protocol){if(!D$[$.protocol]){for(var j=Object.keys($),G=0;G<j.length;G++){var F=j[G];Z[F]=$[F]}return Z.href=Z.format(),Z}if(Z.protocol=$.protocol,!$.host&&!EJ[$.protocol]){for(var w=($.pathname||"").split("/");w.length&&!($.host=w.shift()););$.host||($.host=""),$.hostname||($.hostname=""),w[0]!==""&&w.unshift(""),w.length<2&&w.unshift(""),Z.pathname=w.join("/")}else Z.pathname=$.pathname;if(Z.search=$.search,Z.query=$.query,Z.host=$.host||"",Z.auth=$.auth,Z.hostname=$.hostname||$.host,Z.port=$.port,Z.pathname||Z.search){var _=Z.pathname||"",U=Z.search||"";Z.path=_+U}return Z.slashes=Z.slashes||$.slashes,Z.href=Z.format(),Z}var M=Z.pathname&&Z.pathname.charAt(0)==="/",V=$.host||$.pathname&&$.pathname.charAt(0)==="/",Y=V||M||Z.host&&$.pathname,X=Y,k=Z.pathname&&Z.pathname.split("/")||[],w=$.pathname&&$.pathname.split("/")||[],R=Z.protocol&&!D$[Z.protocol];if(R&&(Z.hostname="",Z.port=null,Z.host&&(k[0]===""?k[0]=Z.host:k.unshift(Z.host)),Z.host="",$.protocol&&($.hostname=null,$.port=null,$.host&&(w[0]===""?w[0]=$.host:w.unshift($.host)),$.host=null),Y=Y&&(w[0]===""||k[0]==="")),V)Z.host=$.host||$.host===""?$.host:Z.host,Z.hostname=$.hostname||$.hostname===""?$.hostname:Z.hostname,Z.search=$.search,Z.query=$.query,k=w;else if(w.length)k||(k=[]),k.pop(),k=k.concat(w),Z.search=$.search,Z.query=$.query;else if(!Fz($.search)){if(R){Z.hostname=Z.host=k.shift();var I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return Z.search=$.search,Z.query=$.query,(!Q9(Z.pathname)||!Q9(Z.search))&&(Z.path=(Z.pathname?Z.pathname:"")+(Z.search?Z.search:"")),Z.href=Z.format(),Z}if(!k.length)return Z.pathname=null,Z.search?Z.path="/"+Z.search:Z.path=null,Z.href=Z.format(),Z;for(var P=k.slice(-1)[0],u=(Z.host||$.host||k.length>1)&&(P==="."||P==="..")||P==="",g=0,b=k.length;b>=0;b--)P=k[b],P==="."?k.splice(b,1):P===".."?(k.splice(b,1),g++):g&&(k.splice(b,1),g--);if(!Y&&!X)for(;g--;g)k.unshift("..");Y&&k[0]!==""&&(!k[0]||k[0].charAt(0)!=="/")&&k.unshift(""),u&&k.join("/").substr(-1)!=="/"&&k.push("");var h=k[0]===""||k[0]&&k[0].charAt(0)==="/";if(R){Z.hostname=Z.host=h?"":k.length?k.shift():"";var I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return Y=Y||Z.host&&k.length,Y&&!h&&k.unshift(""),k.length?Z.pathname=k.join("/"):(Z.pathname=null,Z.path=null),(!Q9(Z.pathname)||!Q9(Z.search))&&(Z.path=(Z.pathname?Z.pathname:"")+(Z.search?Z.search:"")),Z.auth=$.auth||Z.auth,Z.slashes=Z.slashes||$.slashes,Z.href=Z.format(),Z};X7.prototype.parseHost=function(){var $=this.host,J=Uz.exec($);J&&(J=J[0],J!==":"&&(this.port=J.substr(1)),$=$.substr(0,$.length-J.length)),$&&(this.hostname=$)};wz={parse:h$,resolve:NK,resolveObject:IK,format:BK,Url:X7,URL:bJ,URLSearchParams:LK}});/*!
|
|
3
|
+
* decimal.js v10.6.0
|
|
4
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
5
|
+
* https://github.com/MikeMcl/decimal.js
|
|
6
|
+
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
7
|
+
* MIT Licence
|
|
8
|
+
*/var R$=9000000000000000,e7=1e9,W9="0123456789abcdef",U6="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",V6="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",z9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-R$,maxE:R$,crypto:!1},eJ,m7,P0=!0,Y6="[DecimalError] ",t7=Y6+"Invalid argument: ",$8=Y6+"Precision limit exceeded",J8=Y6+"crypto unavailable",Z8="[object Decimal]",e0=Math.floor,n0=Math.pow,DK=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,hK=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,yK=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,K8=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,C7=1e7,R0=7,uK=9007199254740991,gK=U6.length-1,j9=V6.length-1,K0={toStringTag:Z8};K0.absoluteValue=K0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return M0($)};K0.ceil=function(){return M0(new this.constructor(this),this.e+1,2)};K0.clampedTo=K0.clamp=function($,J){var Z,K=this,Q=K.constructor;if($=new Q($),J=new Q(J),!$.s||!J.s)return new Q(NaN);if($.gt(J))throw Error(t7+J);return Z=K.cmp($),Z<0?$:K.cmp(J)>0?J:new Q(K)};K0.comparedTo=K0.cmp=function($){var J,Z,K,Q,q=this,H=q.d,W=($=new q.constructor($)).d,z=q.s,j=$.s;if(!H||!W)return!z||!j?NaN:z!==j?z:H===W?0:!H^z<0?1:-1;if(!H[0]||!W[0])return H[0]?z:W[0]?-j:0;if(z!==j)return z;if(q.e!==$.e)return q.e>$.e^z<0?1:-1;K=H.length,Q=W.length;for(J=0,Z=K<Q?K:Q;J<Z;++J)if(H[J]!==W[J])return H[J]>W[J]^z<0?1:-1;return K===Q?0:K>Q^z<0?1:-1};K0.cosine=K0.cos=function(){var $,J,Z=this,K=Z.constructor;if(!Z.d)return new K(NaN);if(!Z.d[0])return new K(1);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+R0,K.rounding=1,Z=xK(K,z8(K,Z)),K.precision=$,K.rounding=J,M0(m7==2||m7==3?Z.neg():Z,$,J,!0)};K0.cubeRoot=K0.cbrt=function(){var $,J,Z,K,Q,q,H,W,z,j,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(P0=!1,q=G.s*n0(G.s*G,0.3333333333333333),!q||Math.abs(q)==1/0){if(Z=a0(G.d),$=G.e,q=($-Z.length+1)%3)Z+=q==1||q==-2?"0":"00";if(q=n0(Z,0.3333333333333333),$=e0(($+1)/3)-($%3==($<0?-1:2)),q==1/0)Z="5e"+$;else Z=q.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+$;K=new F(Z),K.s=G.s}else K=new F(q.toString());H=($=F.precision)+3;for(;;)if(W=K,z=W.times(W).times(W),j=z.plus(G),K=v0(j.plus(G).times(W),j.plus(z),H+2,1),a0(W.d).slice(0,H)===(Z=a0(K.d)).slice(0,H))if(Z=Z.slice(H-3,H+1),Z=="9999"||!Q&&Z=="4999"){if(!Q){if(M0(W,$+1,0),W.times(W).times(W).eq(G)){K=W;break}}H+=4,Q=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")M0(K,$+1,1),J=!K.times(K).times(K).eq(G);break}return P0=!0,M0(K,$,F.rounding,J)};K0.decimalPlaces=K0.dp=function(){var $,J=this.d,Z=NaN;if(J){if($=J.length-1,Z=($-e0(this.e/R0))*R0,$=J[$],$)for(;$%10==0;$/=10)Z--;if(Z<0)Z=0}return Z};K0.dividedBy=K0.div=function($){return v0(this,new this.constructor($))};K0.dividedToIntegerBy=K0.divToInt=function($){var J=this,Z=J.constructor;return M0(v0(J,new Z($),0,1,1),Z.precision,Z.rounding)};K0.equals=K0.eq=function($){return this.cmp($)===0};K0.floor=function(){return M0(new this.constructor(this),this.e+1,3)};K0.greaterThan=K0.gt=function($){return this.cmp($)>0};K0.greaterThanOrEqualTo=K0.gte=function($){var J=this.cmp($);return J==1||J===0};K0.hyperbolicCosine=K0.cosh=function(){var $,J,Z,K,Q,q=this,H=q.constructor,W=new H(1);if(!q.isFinite())return new H(q.s?1/0:NaN);if(q.isZero())return W;if(Z=H.precision,K=H.rounding,H.precision=Z+Math.max(q.e,q.sd())+4,H.rounding=1,Q=q.d.length,Q<32)$=Math.ceil(Q/3),J=(1/X6(4,$)).toString();else $=16,J="2.3283064365386962890625e-10";q=B$(H,1,q.times(J),new H(1),!0);var z,j=$,G=new H(8);for(;j--;)z=q.times(q),q=W.minus(z.times(G.minus(z.times(G))));return M0(q,H.precision=Z,H.rounding=K,!0)};K0.hyperbolicSine=K0.sinh=function(){var $,J,Z,K,Q=this,q=Q.constructor;if(!Q.isFinite()||Q.isZero())return new q(Q);if(J=q.precision,Z=q.rounding,q.precision=J+Math.max(Q.e,Q.sd())+4,q.rounding=1,K=Q.d.length,K<3)Q=B$(q,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/X6(5,$)),Q=B$(q,2,Q,Q,!0);var H,W=new q(5),z=new q(16),j=new q(20);for(;$--;)H=Q.times(Q),Q=Q.times(W.plus(H.times(z.times(H).plus(j))))}return q.precision=J,q.rounding=Z,M0(Q,J,Z,!0)};K0.hyperbolicTangent=K0.tanh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(Z.s);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+7,K.rounding=1,v0(Z.sinh(),Z.cosh(),K.precision=$,K.rounding=J)};K0.inverseCosine=K0.acos=function(){var $=this,J=$.constructor,Z=$.abs().cmp(1),K=J.precision,Q=J.rounding;if(Z!==-1)return Z===0?$.isNeg()?b7(J,K,Q):new J(0):new J(NaN);if($.isZero())return b7(J,K+4,Q).times(0.5);return J.precision=K+6,J.rounding=1,$=new J(1).minus($).div($.plus(1)).sqrt().atan(),J.precision=K,J.rounding=Q,$.times(2)};K0.inverseHyperbolicCosine=K0.acosh=function(){var $,J,Z=this,K=Z.constructor;if(Z.lte(1))return new K(Z.eq(1)?0:NaN);if(!Z.isFinite())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Math.abs(Z.e),Z.sd())+4,K.rounding=1,P0=!1,Z=Z.times(Z).minus(1).sqrt().plus(Z),P0=!0,K.precision=$,K.rounding=J,Z.ln()};K0.inverseHyperbolicSine=K0.asinh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite()||Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+2*Math.max(Math.abs(Z.e),Z.sd())+6,K.rounding=1,P0=!1,Z=Z.times(Z).plus(1).sqrt().plus(Z),P0=!0,K.precision=$,K.rounding=J,Z.ln()};K0.inverseHyperbolicTangent=K0.atanh=function(){var $,J,Z,K,Q=this,q=Q.constructor;if(!Q.isFinite())return new q(NaN);if(Q.e>=0)return new q(Q.abs().eq(1)?Q.s/0:Q.isZero()?Q:NaN);if($=q.precision,J=q.rounding,K=Q.sd(),Math.max(K,$)<2*-Q.e-1)return M0(new q(Q),$,J,!0);return q.precision=Z=K-Q.e,Q=v0(Q.plus(1),new q(1).minus(Q),Z+$,1),q.precision=$+4,q.rounding=1,Q=Q.ln(),q.precision=$,q.rounding=J,Q.times(0.5)};K0.inverseSine=K0.asin=function(){var $,J,Z,K,Q=this,q=Q.constructor;if(Q.isZero())return new q(Q);if(J=Q.abs().cmp(1),Z=q.precision,K=q.rounding,J!==-1){if(J===0)return $=b7(q,Z+4,K).times(0.5),$.s=Q.s,$;return new q(NaN)}return q.precision=Z+6,q.rounding=1,Q=Q.div(new q(1).minus(Q.times(Q)).sqrt().plus(1)).atan(),q.precision=Z,q.rounding=K,Q.times(2)};K0.inverseTangent=K0.atan=function(){var $,J,Z,K,Q,q,H,W,z,j=this,G=j.constructor,F=G.precision,_=G.rounding;if(!j.isFinite()){if(!j.s)return new G(NaN);if(F+4<=j9)return H=b7(G,F+4,_).times(0.5),H.s=j.s,H}else if(j.isZero())return new G(j);else if(j.abs().eq(1)&&F+4<=j9)return H=b7(G,F+4,_).times(0.25),H.s=j.s,H;G.precision=W=F+10,G.rounding=1,Z=Math.min(28,W/R0+2|0);for($=Z;$;--$)j=j.div(j.times(j).plus(1).sqrt().plus(1));P0=!1,J=Math.ceil(W/R0),K=1,z=j.times(j),H=new G(j),Q=j;for(;$!==-1;)if(Q=Q.times(z),q=H.minus(Q.div(K+=2)),Q=Q.times(z),H=q.plus(Q.div(K+=2)),H.d[J]!==void 0)for($=J;H.d[$]===q.d[$]&&$--;);if(Z)H=H.times(2<<Z-1);return P0=!0,M0(H,G.precision=F,G.rounding=_,!0)};K0.isFinite=function(){return!!this.d};K0.isInteger=K0.isInt=function(){return!!this.d&&e0(this.e/R0)>this.d.length-2};K0.isNaN=function(){return!this.s};K0.isNegative=K0.isNeg=function(){return this.s<0};K0.isPositive=K0.isPos=function(){return this.s>0};K0.isZero=function(){return!!this.d&&this.d[0]===0};K0.lessThan=K0.lt=function($){return this.cmp($)<0};K0.lessThanOrEqualTo=K0.lte=function($){return this.cmp($)<1};K0.logarithm=K0.log=function($){var J,Z,K,Q,q,H,W,z,j=this,G=j.constructor,F=G.precision,_=G.rounding,U=5;if($==null)$=new G(10),J=!0;else{if($=new G($),Z=$.d,$.s<0||!Z||!Z[0]||$.eq(1))return new G(NaN);J=$.eq(10)}if(Z=j.d,j.s<0||!Z||!Z[0]||j.eq(1))return new G(Z&&!Z[0]?-1/0:j.s!=1?NaN:Z?0:1/0);if(J)if(Z.length>1)q=!0;else{for(Q=Z[0];Q%10===0;)Q/=10;q=Q!==1}if(P0=!1,W=F+U,H=a7(j,W),K=J?O6(G,W+10):a7($,W),z=v0(H,K,W,1),g$(z.d,Q=F,_))do if(W+=10,H=a7(j,W),K=J?O6(G,W+10):a7($,W),z=v0(H,K,W,1),!q){if(+a0(z.d).slice(Q+1,Q+15)+1==100000000000000)z=M0(z,F+1,0);break}while(g$(z.d,Q+=10,_));return P0=!0,M0(z,F,_)};K0.minus=K0.sub=function($){var J,Z,K,Q,q,H,W,z,j,G,F,_,U=this,M=U.constructor;if($=new M($),!U.d||!$.d){if(!U.s||!$.s)$=new M(NaN);else if(U.d)$.s=-$.s;else $=new M($.d||U.s!==$.s?U:NaN);return $}if(U.s!=$.s)return $.s=-$.s,U.plus($);if(j=U.d,_=$.d,W=M.precision,z=M.rounding,!j[0]||!_[0]){if(_[0])$.s=-$.s;else if(j[0])$=new M(U);else return new M(z===3?-0:0);return P0?M0($,W,z):$}if(Z=e0($.e/R0),G=e0(U.e/R0),j=j.slice(),q=G-Z,q){if(F=q<0,F)J=j,q=-q,H=_.length;else J=_,Z=G,H=j.length;if(K=Math.max(Math.ceil(W/R0),H)+2,q>K)q=K,J.length=1;J.reverse();for(K=q;K--;)J.push(0);J.reverse()}else{if(K=j.length,H=_.length,F=K<H,F)H=K;for(K=0;K<H;K++)if(j[K]!=_[K]){F=j[K]<_[K];break}q=0}if(F)J=j,j=_,_=J,$.s=-$.s;H=j.length;for(K=_.length-H;K>0;--K)j[H++]=0;for(K=_.length;K>q;){if(j[--K]<_[K]){for(Q=K;Q&&j[--Q]===0;)j[Q]=C7-1;--j[Q],j[K]+=C7}j[K]-=_[K]}for(;j[--H]===0;)j.pop();for(;j[0]===0;j.shift())--Z;if(!j[0])return new M(z===3?-0:0);return $.d=j,$.e=M6(j,Z),P0?M0($,W,z):$};K0.modulo=K0.mod=function($){var J,Z=this,K=Z.constructor;if($=new K($),!Z.d||!$.s||$.d&&!$.d[0])return new K(NaN);if(!$.d||Z.d&&!Z.d[0])return M0(new K(Z),K.precision,K.rounding);if(P0=!1,K.modulo==9)J=v0(Z,$.abs(),0,3,1),J.s*=$.s;else J=v0(Z,$,0,K.modulo,1);return J=J.times($),P0=!0,Z.minus(J)};K0.naturalExponential=K0.exp=function(){return G9(this)};K0.naturalLogarithm=K0.ln=function(){return a7(this)};K0.negated=K0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,M0($)};K0.plus=K0.add=function($){var J,Z,K,Q,q,H,W,z,j,G,F=this,_=F.constructor;if($=new _($),!F.d||!$.d){if(!F.s||!$.s)$=new _(NaN);else if(!F.d)$=new _($.d||F.s===$.s?F:NaN);return $}if(F.s!=$.s)return $.s=-$.s,F.minus($);if(j=F.d,G=$.d,W=_.precision,z=_.rounding,!j[0]||!G[0]){if(!G[0])$=new _(F);return P0?M0($,W,z):$}if(q=e0(F.e/R0),K=e0($.e/R0),j=j.slice(),Q=q-K,Q){if(Q<0)Z=j,Q=-Q,H=G.length;else Z=G,K=q,H=j.length;if(q=Math.ceil(W/R0),H=q>H?q+1:H+1,Q>H)Q=H,Z.length=1;Z.reverse();for(;Q--;)Z.push(0);Z.reverse()}if(H=j.length,Q=G.length,H-Q<0)Q=H,Z=G,G=j,j=Z;for(J=0;Q;)J=(j[--Q]=j[Q]+G[Q]+J)/C7|0,j[Q]%=C7;if(J)j.unshift(J),++K;for(H=j.length;j[--H]==0;)j.pop();return $.d=j,$.e=M6(j,K),P0?M0($,W,z):$};K0.precision=K0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(t7+$);if(Z.d){if(J=Q8(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};K0.round=function(){var $=this,J=$.constructor;return M0(new J($),$.e+1,J.rounding)};K0.sine=K0.sin=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+R0,K.rounding=1,Z=dK(K,z8(K,Z)),K.precision=$,K.rounding=J,M0(m7>2?Z.neg():Z,$,J,!0)};K0.squareRoot=K0.sqrt=function(){var $,J,Z,K,Q,q,H=this,W=H.d,z=H.e,j=H.s,G=H.constructor;if(j!==1||!W||!W[0])return new G(!j||j<0&&(!W||W[0])?NaN:W?H:1/0);if(P0=!1,j=Math.sqrt(+H),j==0||j==1/0){if(J=a0(W),(J.length+z)%2==0)J+="0";if(j=Math.sqrt(J),z=e0((z+1)/2)-(z<0||z%2),j==1/0)J="5e"+z;else J=j.toExponential(),J=J.slice(0,J.indexOf("e")+1)+z;K=new G(J)}else K=new G(j.toString());Z=(z=G.precision)+3;for(;;)if(q=K,K=q.plus(v0(H,q,Z+2,1)).times(0.5),a0(q.d).slice(0,Z)===(J=a0(K.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!Q&&J=="4999"){if(!Q){if(M0(q,z+1,0),q.times(q).eq(H)){K=q;break}}Z+=4,Q=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")M0(K,z+1,1),$=!K.times(K).eq(H);break}return P0=!0,M0(K,z,G.rounding,$)};K0.tangent=K0.tan=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+10,K.rounding=1,Z=Z.sin(),Z.s=1,Z=v0(Z,new K(1).minus(Z.times(Z)).sqrt(),$+10,0),K.precision=$,K.rounding=J,M0(m7==2||m7==4?Z.neg():Z,$,J,!0)};K0.times=K0.mul=function($){var J,Z,K,Q,q,H,W,z,j,G=this,F=G.constructor,_=G.d,U=($=new F($)).d;if($.s*=G.s,!_||!_[0]||!U||!U[0])return new F(!$.s||_&&!_[0]&&!U||U&&!U[0]&&!_?NaN:!_||!U?$.s/0:$.s*0);if(Z=e0(G.e/R0)+e0($.e/R0),z=_.length,j=U.length,z<j)q=_,_=U,U=q,H=z,z=j,j=H;q=[],H=z+j;for(K=H;K--;)q.push(0);for(K=j;--K>=0;){J=0;for(Q=z+K;Q>K;)W=q[Q]+U[K]*_[Q-K-1]+J,q[Q--]=W%C7|0,J=W/C7|0;q[Q]=(q[Q]+J)%C7|0}for(;!q[--H];)q.pop();if(J)++Z;else q.shift();return $.d=q,$.e=M6(q,Z),P0?M0($,F.precision,F.rounding):$};K0.toBinary=function($,J){return F9(this,2,$,J)};K0.toDecimalPlaces=K0.toDP=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$===void 0)return Z;if(Q7($,0,e7),J===void 0)J=K.rounding;else Q7(J,0,8);return M0(Z,$+Z.e+1,J)};K0.toExponential=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=f7(K,!0);else{if(Q7($,0,e7),J===void 0)J=Q.rounding;else Q7(J,0,8);K=M0(new Q(K),$+1,J),Z=f7(K,!0,$+1)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};K0.toFixed=function($,J){var Z,K,Q=this,q=Q.constructor;if($===void 0)Z=f7(Q);else{if(Q7($,0,e7),J===void 0)J=q.rounding;else Q7(J,0,8);K=M0(new q(Q),$+Q.e+1,J),Z=f7(K,!1,$+K.e+1)}return Q.isNeg()&&!Q.isZero()?"-"+Z:Z};K0.toFraction=function($){var J,Z,K,Q,q,H,W,z,j,G,F,_,U=this,M=U.d,V=U.constructor;if(!M)return new V(U);if(j=Z=new V(1),K=z=new V(0),J=new V(K),q=J.e=Q8(M)-U.e-1,H=q%R0,J.d[0]=n0(10,H<0?R0+H:H),$==null)$=q>0?J:j;else{if(W=new V($),!W.isInt()||W.lt(j))throw Error(t7+W);$=W.gt(J)?q>0?J:j:W}P0=!1,W=new V(a0(M)),G=V.precision,V.precision=q=M.length*R0*2;for(;;){if(F=v0(W,J,0,1,1),Q=Z.plus(F.times(K)),Q.cmp($)==1)break;Z=K,K=Q,Q=j,j=z.plus(F.times(Q)),z=Q,Q=J,J=W.minus(F.times(Q)),W=Q}return Q=v0($.minus(Z),K,0,1,1),z=z.plus(Q.times(j)),Z=Z.plus(Q.times(K)),z.s=j.s=U.s,_=v0(j,K,q,1).minus(U).abs().cmp(v0(z,Z,q,1).minus(U).abs())<1?[j,K]:[z,Z],V.precision=G,P0=!0,_};K0.toHexadecimal=K0.toHex=function($,J){return F9(this,16,$,J)};K0.toNearest=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$==null){if(!Z.d)return Z;$=new K(1),J=K.rounding}else{if($=new K($),J===void 0)J=K.rounding;else Q7(J,0,8);if(!Z.d)return $.s?Z:$;if(!$.d){if($.s)$.s=Z.s;return $}}if($.d[0])P0=!1,Z=v0(Z,$,0,J,1).times($),P0=!0,M0(Z);else $.s=Z.s,Z=$;return Z};K0.toNumber=function(){return+this};K0.toOctal=function($,J){return F9(this,8,$,J)};K0.toPower=K0.pow=function($){var J,Z,K,Q,q,H,W=this,z=W.constructor,j=+($=new z($));if(!W.d||!$.d||!W.d[0]||!$.d[0])return new z(n0(+W,j));if(W=new z(W),W.eq(1))return W;if(K=z.precision,q=z.rounding,$.eq(1))return M0(W,K,q);if(J=e0($.e/R0),J>=$.d.length-1&&(Z=j<0?-j:j)<=uK)return Q=q8(z,W,Z,K),$.s<0?new z(1).div(Q):M0(Q,K,q);if(H=W.s,H<0){if(J<$.d.length-1)return new z(NaN);if(($.d[J]&1)==0)H=1;if(W.e==0&&W.d[0]==1&&W.d.length==1)return W.s=H,W}if(Z=n0(+W,j),J=Z==0||!isFinite(Z)?e0(j*(Math.log("0."+a0(W.d))/Math.LN10+W.e+1)):new z(Z+"").e,J>z.maxE+1||J<z.minE-1)return new z(J>0?H/0:0);if(P0=!1,z.rounding=W.s=1,Z=Math.min(12,(J+"").length),Q=G9($.times(a7(W,K+Z)),K),Q.d){if(Q=M0(Q,K+5,1),g$(Q.d,K,q)){if(J=K+10,Q=M0(G9($.times(a7(W,J+Z)),J),J+5,1),+a0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=M0(Q,K+1,0)}}return Q.s=H,P0=!0,z.rounding=q,M0(Q,K,q)};K0.toPrecision=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=f7(K,K.e<=Q.toExpNeg||K.e>=Q.toExpPos);else{if(Q7($,1,e7),J===void 0)J=Q.rounding;else Q7(J,0,8);K=M0(new Q(K),$,J),Z=f7(K,$<=K.e||K.e<=Q.toExpNeg,$)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};K0.toSignificantDigits=K0.toSD=function($,J){var Z=this,K=Z.constructor;if($===void 0)$=K.precision,J=K.rounding;else if(Q7($,1,e7),J===void 0)J=K.rounding;else Q7(J,0,8);return M0(new K(Z),$,J)};K0.toString=function(){var $=this,J=$.constructor,Z=f7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()&&!$.isZero()?"-"+Z:Z};K0.truncated=K0.trunc=function(){return M0(new this.constructor(this),this.e+1,1)};K0.valueOf=K0.toJSON=function(){var $=this,J=$.constructor,Z=f7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()?"-"+Z:Z};function a0($){var J,Z,K,Q=$.length-1,q="",H=$[0];if(Q>0){q+=H;for(J=1;J<Q;J++){if(K=$[J]+"",Z=R0-K.length,Z)q+=r7(Z);q+=K}if(H=$[J],K=H+"",Z=R0-K.length,Z)q+=r7(Z)}else if(H===0)return"0";for(;H%10===0;)H/=10;return q+H}function Q7($,J,Z){if($!==~~$||$<J||$>Z)throw Error(t7+$)}function g$($,J,Z,K){var Q,q,H,W;for(q=$[0];q>=10;q/=10)--J;if(--J<0)J+=R0,Q=0;else Q=Math.ceil((J+1)/R0),J%=R0;if(q=n0(10,R0-J),W=$[Q]%q|0,K==null)if(J<3){if(J==0)W=W/100|0;else if(J==1)W=W/10|0;H=Z<4&&W==99999||Z>3&&W==49999||W==50000||W==0}else H=(Z<4&&W+1==q||Z>3&&W+1==q/2)&&($[Q+1]/q/100|0)==n0(10,J-2)-1||(W==q/2||W==0)&&($[Q+1]/q/100|0)==0;else if(J<4){if(J==0)W=W/1000|0;else if(J==1)W=W/100|0;else if(J==2)W=W/10|0;H=(K||Z<4)&&W==9999||!K&&Z>3&&W==4999}else H=((K||Z<4)&&W+1==q||!K&&Z>3&&W+1==q/2)&&($[Q+1]/q/1000|0)==n0(10,J-3)-1;return H}function F6($,J,Z){var K,Q=[0],q,H=0,W=$.length;for(;H<W;){for(q=Q.length;q--;)Q[q]*=J;Q[0]+=W9.indexOf($.charAt(H++));for(K=0;K<Q.length;K++)if(Q[K]>Z-1){if(Q[K+1]===void 0)Q[K+1]=0;Q[K+1]+=Q[K]/Z|0,Q[K]%=Z}}return Q.reverse()}function xK($,J){var Z,K,Q;if(J.isZero())return J;if(K=J.d.length,K<32)Z=Math.ceil(K/3),Q=(1/X6(4,Z)).toString();else Z=16,Q="2.3283064365386962890625e-10";$.precision+=Z,J=B$($,1,J.times(Q),new $(1));for(var q=Z;q--;){var H=J.times(J);J=H.times(H).minus(H).times(8).plus(1)}return $.precision-=Z,J}var v0=function(){function $(K,Q,q){var H,W=0,z=K.length;for(K=K.slice();z--;)H=K[z]*Q+W,K[z]=H%q|0,W=H/q|0;if(W)K.unshift(W);return K}function J(K,Q,q,H){var W,z;if(q!=H)z=q>H?1:-1;else for(W=z=0;W<q;W++)if(K[W]!=Q[W]){z=K[W]>Q[W]?1:-1;break}return z}function Z(K,Q,q,H){var W=0;for(;q--;)K[q]-=W,W=K[q]<Q[q]?1:0,K[q]=W*H+K[q]-Q[q];for(;!K[0]&&K.length>1;)K.shift()}return function(K,Q,q,H,W,z){var j,G,F,_,U,M,V,Y,X,k,w,R,I,P,u,g,b,h,v,E,m=K.constructor,c=K.s==Q.s?1:-1,d=K.d,N=Q.d;if(!d||!d[0]||!N||!N[0])return new m(!K.s||!Q.s||(d?N&&d[0]==N[0]:!N)?NaN:d&&d[0]==0||!N?c*0:c/0);if(z)U=1,G=K.e-Q.e;else z=C7,U=R0,G=e0(K.e/U)-e0(Q.e/U);v=N.length,b=d.length,X=new m(c),k=X.d=[];for(F=0;N[F]==(d[F]||0);F++);if(N[F]>(d[F]||0))G--;if(q==null)P=q=m.precision,H=m.rounding;else if(W)P=q+(K.e-Q.e)+1;else P=q;if(P<0)k.push(1),M=!0;else{if(P=P/U+2|0,F=0,v==1){_=0,N=N[0],P++;for(;(F<b||_)&&P--;F++)u=_*z+(d[F]||0),k[F]=u/N|0,_=u%N|0;M=_||F<b}else{if(_=z/(N[0]+1)|0,_>1)N=$(N,_,z),d=$(d,_,z),v=N.length,b=d.length;g=v,w=d.slice(0,v),R=w.length;for(;R<v;)w[R++]=0;if(E=N.slice(),E.unshift(0),h=N[0],N[1]>=z/2)++h;do{if(_=0,j=J(N,w,v,R),j<0){if(I=w[0],v!=R)I=I*z+(w[1]||0);if(_=I/h|0,_>1){if(_>=z)_=z-1;if(V=$(N,_,z),Y=V.length,R=w.length,j=J(V,w,Y,R),j==1)_--,Z(V,v<Y?E:N,Y,z)}else{if(_==0)j=_=1;V=N.slice()}if(Y=V.length,Y<R)V.unshift(0);if(Z(w,V,R,z),j==-1){if(R=w.length,j=J(N,w,v,R),j<1)_++,Z(w,v<R?E:N,R,z)}R=w.length}else if(j===0)_++,w=[0];if(k[F++]=_,j&&w[0])w[R++]=d[g]||0;else w=[d[g]],R=1}while((g++<b||w[0]!==void 0)&&P--);M=w[0]!==void 0}if(!k[0])k.shift()}if(U==1)X.e=G,eJ=M;else{for(F=1,_=k[0];_>=10;_/=10)F++;X.e=F+G*U-1,M0(X,W?q+X.e+1:q,H,M)}return X}}();function M0($,J,Z,K){var Q,q,H,W,z,j,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(Q=1,W=F[0];W>=10;W/=10)Q++;if(q=J-Q,q<0)q+=R0,H=J,G=F[_=0],z=G/n0(10,Q-H-1)%10|0;else if(_=Math.ceil((q+1)/R0),W=F.length,_>=W)if(K){for(;W++<=_;)F.push(0);G=z=0,Q=1,q%=R0,H=q-R0+1}else break $;else{G=W=F[_];for(Q=1;W>=10;W/=10)Q++;q%=R0,H=q-R0+Q,z=H<0?0:G/n0(10,Q-H-1)%10|0}if(K=K||J<0||F[_+1]!==void 0||(H<0?G:G%n0(10,Q-H-1)),j=Z<4?(z||K)&&(Z==0||Z==($.s<0?3:2)):z>5||z==5&&(Z==4||K||Z==6&&(q>0?H>0?G/n0(10,Q-H):0:F[_-1])%10&1||Z==($.s<0?8:7)),J<1||!F[0]){if(F.length=0,j)J-=$.e+1,F[0]=n0(10,(R0-J%R0)%R0),$.e=-J||0;else F[0]=$.e=0;return $}if(q==0)F.length=_,W=1,_--;else F.length=_+1,W=n0(10,R0-q),F[_]=H>0?(G/n0(10,Q-H)%n0(10,H)|0)*W:0;if(j)for(;;)if(_==0){for(q=1,H=F[0];H>=10;H/=10)q++;H=F[0]+=W;for(W=1;H>=10;H/=10)W++;if(q!=W){if($.e++,F[0]==C7)F[0]=1}break}else{if(F[_]+=W,F[_]!=C7)break;F[_--]=0,W=1}for(q=F.length;F[--q]===0;)F.pop()}if(P0){if($.e>U.maxE)$.d=null,$.e=NaN;else if($.e<U.minE)$.e=0,$.d=[0]}return $}function f7($,J,Z){if(!$.isFinite())return W8($);var K,Q=$.e,q=a0($.d),H=q.length;if(J){if(Z&&(K=Z-H)>0)q=q.charAt(0)+"."+q.slice(1)+r7(K);else if(H>1)q=q.charAt(0)+"."+q.slice(1);q=q+($.e<0?"e":"e+")+$.e}else if(Q<0){if(q="0."+r7(-Q-1)+q,Z&&(K=Z-H)>0)q+=r7(K)}else if(Q>=H){if(q+=r7(Q+1-H),Z&&(K=Z-Q-1)>0)q=q+"."+r7(K)}else{if((K=Q+1)<H)q=q.slice(0,K)+"."+q.slice(K);if(Z&&(K=Z-H)>0){if(Q+1===H)q+=".";q+=r7(K)}}return q}function M6($,J){var Z=$[0];for(J*=R0;Z>=10;Z/=10)J++;return J}function O6($,J,Z){if(J>gK){if(P0=!0,Z)$.precision=Z;throw Error($8)}return M0(new $(U6),J,1,!0)}function b7($,J,Z){if(J>j9)throw Error($8);return M0(new $(V6),J,Z,!0)}function Q8($){var J=$.length-1,Z=J*R0+1;if(J=$[J],J){for(;J%10==0;J/=10)Z--;for(J=$[0];J>=10;J/=10)Z++}return Z}function r7($){var J="";for(;$--;)J+="0";return J}function q8($,J,Z,K){var Q,q=new $(1),H=Math.ceil(K/R0+4);P0=!1;for(;;){if(Z%2){if(q=q.times(J),aJ(q.d,H))Q=!0}if(Z=e0(Z/2),Z===0){if(Z=q.d.length-1,Q&&q.d[Z]===0)++q.d[Z];break}J=J.times(J),aJ(J.d,H)}return P0=!0,q}function rJ($){return $.d[$.d.length-1]&1}function H8($,J,Z){var K,Q,q=new $(J[0]),H=0;for(;++H<J.length;){if(Q=new $(J[H]),!Q.s){q=Q;break}if(K=q.cmp(Q),K===Z||K===0&&q.s===Z)q=Q}return q}function G9($,J){var Z,K,Q,q,H,W,z,j=0,G=0,F=0,_=$.constructor,U=_.rounding,M=_.precision;if(!$.d||!$.d[0]||$.e>17)return new _($.d?!$.d[0]?1:$.s<0?0:1/0:$.s?$.s<0?0:$:NaN);if(J==null)P0=!1,z=M;else z=J;W=new _(0.03125);while($.e>-2)$=$.times(W),F+=5;K=Math.log(n0(2,F))/Math.LN10*2+5|0,z+=K,Z=q=H=new _(1),_.precision=z;for(;;){if(q=M0(q.times($),z,1),Z=Z.times(++G),W=H.plus(v0(q,Z,z,1)),a0(W.d).slice(0,z)===a0(H.d).slice(0,z)){Q=F;while(Q--)H=M0(H.times(H),z,1);if(J==null)if(j<3&&g$(H.d,z-K,U,j))_.precision=z+=10,Z=q=W=new _(1),G=0,j++;else return M0(H,_.precision=M,U,P0=!0);else return _.precision=M,H}H=W}}function a7($,J){var Z,K,Q,q,H,W,z,j,G,F,_,U=1,M=10,V=$,Y=V.d,X=V.constructor,k=X.rounding,w=X.precision;if(V.s<0||!Y||!Y[0]||!V.e&&Y[0]==1&&Y.length==1)return new X(Y&&!Y[0]?-1/0:V.s!=1?NaN:Y?0:V);if(J==null)P0=!1,G=w;else G=J;if(X.precision=G+=M,Z=a0(Y),K=Z.charAt(0),Math.abs(q=V.e)<1500000000000000){while(K<7&&K!=1||K==1&&Z.charAt(1)>3)V=V.times($),Z=a0(V.d),K=Z.charAt(0),U++;if(q=V.e,K>1)V=new X("0."+Z),q++;else V=new X(K+"."+Z.slice(1))}else return j=O6(X,G+2,w).times(q+""),V=a7(new X(K+"."+Z.slice(1)),G-M).plus(j),X.precision=w,J==null?M0(V,w,k,P0=!0):V;F=V,z=H=V=v0(V.minus(1),V.plus(1),G,1),_=M0(V.times(V),G,1),Q=3;for(;;){if(H=M0(H.times(_),G,1),j=z.plus(v0(H,new X(Q),G,1)),a0(j.d).slice(0,G)===a0(z.d).slice(0,G)){if(z=z.times(2),q!==0)z=z.plus(O6(X,G+2,w).times(q+""));if(z=v0(z,new X(U),G,1),J==null)if(g$(z.d,G-M,k,W))X.precision=G+=M,j=H=V=v0(F.minus(1),F.plus(1),G,1),_=M0(V.times(V),G,1),Q=W=1;else return M0(z,X.precision=w,k,P0=!0);else return X.precision=w,z}z=j,Q+=2}}function W8($){return String($.s*$.s/0)}function _6($,J){var Z,K,Q;if((Z=J.indexOf("."))>-1)J=J.replace(".","");if((K=J.search(/e/i))>0){if(Z<0)Z=K;Z+=+J.slice(K+1),J=J.substring(0,K)}else if(Z<0)Z=J.length;for(K=0;J.charCodeAt(K)===48;K++);for(Q=J.length;J.charCodeAt(Q-1)===48;--Q);if(J=J.slice(K,Q),J){if(Q-=K,$.e=Z=Z-K-1,$.d=[],K=(Z+1)%R0,Z<0)K+=R0;if(K<Q){if(K)$.d.push(+J.slice(0,K));for(Q-=R0;K<Q;)$.d.push(+J.slice(K,K+=R0));J=J.slice(K),K=R0-J.length}else K-=Q;for(;K--;)J+="0";if($.d.push(+J),P0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function mK($,J){var Z,K,Q,q,H,W,z,j,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),K8.test(J))return _6($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(hK.test(J))Z=16,J=J.toLowerCase();else if(DK.test(J))Z=2;else if(yK.test(J))Z=8;else throw Error(t7+J);if(q=J.search(/p/i),q>0)z=+J.slice(q+1),J=J.substring(2,q);else J=J.slice(2);if(q=J.indexOf("."),H=q>=0,K=$.constructor,H)J=J.replace(".",""),W=J.length,q=W-q,Q=q8(K,new K(Z),q,q*2);j=F6(J,Z,C7),G=j.length-1;for(q=G;j[q]===0;--q)j.pop();if(q<0)return new K($.s*0);if($.e=M6(j,G),$.d=j,P0=!1,H)$=v0($,Q,W*4);if(z)$=$.times(Math.abs(z)<54?n0(2,z):x$.pow(2,z));return P0=!0,$}function dK($,J){var Z,K=J.d.length;if(K<3)return J.isZero()?J:B$($,2,J,J);Z=1.4*Math.sqrt(K),Z=Z>16?16:Z|0,J=J.times(1/X6(5,Z)),J=B$($,2,J,J);var Q,q=new $(5),H=new $(16),W=new $(20);for(;Z--;)Q=J.times(J),J=J.times(q.plus(Q.times(H.times(Q).minus(W))));return J}function B$($,J,Z,K,Q){var q,H,W,z,j=1,G=$.precision,F=Math.ceil(G/R0);P0=!1,z=Z.times(Z),W=new $(K);for(;;){if(H=v0(W.times(z),new $(J++*J++),G,1),W=Q?K.plus(H):K.minus(H),K=v0(H.times(z),new $(J++*J++),G,1),H=W.plus(K),H.d[F]!==void 0){for(q=F;H.d[q]===W.d[q]&&q--;);if(q==-1)break}q=W,W=K,K=H,H=q,j++}return P0=!0,H.d.length=F+1,H}function X6($,J){var Z=$;while(--J)Z*=$;return Z}function z8($,J){var Z,K=J.s<0,Q=b7($,$.precision,1),q=Q.times(0.5);if(J=J.abs(),J.lte(q))return m7=K?4:1,J;if(Z=J.divToInt(Q),Z.isZero())m7=K?3:2;else{if(J=J.minus(Z.times(Q)),J.lte(q))return m7=rJ(Z)?K?2:3:K?4:1,J;m7=rJ(Z)?K?1:4:K?3:2}return J.minus(Q).abs()}function F9($,J,Z,K){var Q,q,H,W,z,j,G,F,_,U=$.constructor,M=Z!==void 0;if(M)if(Q7(Z,1,e7),K===void 0)K=U.rounding;else Q7(K,0,8);else Z=U.precision,K=U.rounding;if(!$.isFinite())G=W8($);else{if(G=f7($),H=G.indexOf("."),M){if(Q=2,J==16)Z=Z*4-3;else if(J==8)Z=Z*3-2}else Q=J;if(H>=0)G=G.replace(".",""),_=new U(1),_.e=G.length-H,_.d=F6(f7(_),10,Q),_.e=_.d.length;F=F6(G,10,Q),q=z=F.length;for(;F[--z]==0;)F.pop();if(!F[0])G=M?"0p+0":"0";else{if(H<0)q--;else $=new U($),$.d=F,$.e=q,$=v0($,_,Z,K,0,Q),F=$.d,q=$.e,j=eJ;if(H=F[Z],W=Q/2,j=j||F[Z+1]!==void 0,j=K<4?(H!==void 0||j)&&(K===0||K===($.s<0?3:2)):H>W||H===W&&(K===4||j||K===6&&F[Z-1]&1||K===($.s<0?8:7)),F.length=Z,j){for(;++F[--Z]>Q-1;)if(F[Z]=0,!Z)++q,F.unshift(1)}for(z=F.length;!F[z-1];--z);for(H=0,G="";H<z;H++)G+=W9.charAt(F[H]);if(M){if(z>1)if(J==16||J==8){H=J==16?4:3;for(--z;z%H;z++)G+="0";F=F6(G,Q,J);for(z=F.length;!F[z-1];--z);for(H=1,G="1.";H<z;H++)G+=W9.charAt(F[H])}else G=G.charAt(0)+"."+G.slice(1);G=G+(q<0?"p":"p+")+q}else if(q<0){for(;++q;)G="0"+G;G="0."+G}else if(++q>z)for(q-=z;q--;)G+="0";else if(q<z)G=G.slice(0,q)+"."+G.slice(q)}G=(J==16?"0x":J==2?"0b":J==8?"0o":"")+G}return $.s<0?"-"+G:G}function aJ($,J){if($.length>J)return $.length=J,!0}function pK($){return new this($).abs()}function cK($){return new this($).acos()}function nK($){return new this($).acosh()}function lK($,J){return new this($).plus(J)}function sK($){return new this($).asin()}function oK($){return new this($).asinh()}function iK($){return new this($).atan()}function rK($){return new this($).atanh()}function aK($,J){$=new this($),J=new this(J);var Z,K=this.precision,Q=this.rounding,q=K+4;if(!$.s||!J.s)Z=new this(NaN);else if(!$.d&&!J.d)Z=b7(this,q,1).times(J.s>0?0.25:0.75),Z.s=$.s;else if(!J.d||$.isZero())Z=J.s<0?b7(this,K,Q):new this(0),Z.s=$.s;else if(!$.d||J.isZero())Z=b7(this,q,1).times(0.5),Z.s=$.s;else if(J.s<0)this.precision=q,this.rounding=1,Z=this.atan(v0($,J,q,1)),J=b7(this,q,1),this.precision=K,this.rounding=Q,Z=$.s<0?Z.minus(J):Z.plus(J);else Z=this.atan(v0($,J,q,1));return Z}function tK($){return new this($).cbrt()}function eK($){return M0($=new this($),$.e+1,2)}function $Q($,J,Z){return new this($).clamp(J,Z)}function JQ($){if(!$||typeof $!=="object")throw Error(Y6+"Object expected");var J,Z,K,Q=$.defaults===!0,q=["precision",1,e7,"rounding",0,8,"toExpNeg",-R$,0,"toExpPos",0,R$,"maxE",0,R$,"minE",-R$,0,"modulo",0,9];for(J=0;J<q.length;J+=3){if(Z=q[J],Q)this[Z]=z9[Z];if((K=$[Z])!==void 0)if(e0(K)===K&&K>=q[J+1]&&K<=q[J+2])this[Z]=K;else throw Error(t7+Z+": "+K)}if(Z="crypto",Q)this[Z]=z9[Z];if((K=$[Z])!==void 0)if(K===!0||K===!1||K===0||K===1)if(K)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[Z]=!0;else throw Error(J8);else this[Z]=!1;else throw Error(t7+Z+": "+K);return this}function ZQ($){return new this($).cos()}function KQ($){return new this($).cosh()}function j8($){var J,Z,K;function Q(q){var H,W,z,j=this;if(!(j instanceof Q))return new Q(q);if(j.constructor=Q,tJ(q)){if(j.s=q.s,P0)if(!q.d||q.e>Q.maxE)j.e=NaN,j.d=null;else if(q.e<Q.minE)j.e=0,j.d=[0];else j.e=q.e,j.d=q.d.slice();else j.e=q.e,j.d=q.d?q.d.slice():q.d;return}if(z=typeof q,z==="number"){if(q===0){j.s=1/q<0?-1:1,j.e=0,j.d=[0];return}if(q<0)q=-q,j.s=-1;else j.s=1;if(q===~~q&&q<1e7){for(H=0,W=q;W>=10;W/=10)H++;if(P0)if(H>Q.maxE)j.e=NaN,j.d=null;else if(H<Q.minE)j.e=0,j.d=[0];else j.e=H,j.d=[q];else j.e=H,j.d=[q];return}if(q*0!==0){if(!q)j.s=NaN;j.e=NaN,j.d=null;return}return _6(j,q.toString())}if(z==="string"){if((W=q.charCodeAt(0))===45)q=q.slice(1),j.s=-1;else{if(W===43)q=q.slice(1);j.s=1}return K8.test(q)?_6(j,q):mK(j,q)}if(z==="bigint"){if(q<0)q=-q,j.s=-1;else j.s=1;return _6(j,q.toString())}throw Error(t7+q)}if(Q.prototype=K0,Q.ROUND_UP=0,Q.ROUND_DOWN=1,Q.ROUND_CEIL=2,Q.ROUND_FLOOR=3,Q.ROUND_HALF_UP=4,Q.ROUND_HALF_DOWN=5,Q.ROUND_HALF_EVEN=6,Q.ROUND_HALF_CEIL=7,Q.ROUND_HALF_FLOOR=8,Q.EUCLID=9,Q.config=Q.set=JQ,Q.clone=j8,Q.isDecimal=tJ,Q.abs=pK,Q.acos=cK,Q.acosh=nK,Q.add=lK,Q.asin=sK,Q.asinh=oK,Q.atan=iK,Q.atanh=rK,Q.atan2=aK,Q.cbrt=tK,Q.ceil=eK,Q.clamp=$Q,Q.cos=ZQ,Q.cosh=KQ,Q.div=QQ,Q.exp=qQ,Q.floor=HQ,Q.hypot=WQ,Q.ln=zQ,Q.log=jQ,Q.log10=FQ,Q.log2=GQ,Q.max=_Q,Q.min=UQ,Q.mod=VQ,Q.mul=OQ,Q.pow=YQ,Q.random=MQ,Q.round=XQ,Q.sign=kQ,Q.sin=wQ,Q.sinh=LQ,Q.sqrt=RQ,Q.sub=BQ,Q.sum=NQ,Q.tan=IQ,Q.tanh=CQ,Q.trunc=PQ,$===void 0)$={};if($){if($.defaults!==!0){K=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(J=0;J<K.length;)if(!$.hasOwnProperty(Z=K[J++]))$[Z]=this[Z]}}return Q.config($),Q}function QQ($,J){return new this($).div(J)}function qQ($){return new this($).exp()}function HQ($){return M0($=new this($),$.e+1,3)}function WQ(){var $,J,Z=new this(0);P0=!1;for($=0;$<arguments.length;)if(J=new this(arguments[$++]),!J.d){if(J.s)return P0=!0,new this(1/0);Z=J}else if(Z.d)Z=Z.plus(J.times(J));return P0=!0,Z.sqrt()}function tJ($){return $ instanceof x$||$&&$.toStringTag===Z8||!1}function zQ($){return new this($).ln()}function jQ($,J){return new this($).log(J)}function GQ($){return new this($).log(2)}function FQ($){return new this($).log(10)}function _Q(){return H8(this,arguments,-1)}function UQ(){return H8(this,arguments,1)}function VQ($,J){return new this($).mod(J)}function OQ($,J){return new this($).mul(J)}function YQ($,J){return new this($).pow(J)}function MQ($){var J,Z,K,Q,q=0,H=new this(1),W=[];if($===void 0)$=this.precision;else Q7($,1,e7);if(K=Math.ceil($/R0),!this.crypto)for(;q<K;)W[q++]=Math.random()*1e7|0;else if(crypto.getRandomValues){J=crypto.getRandomValues(new Uint32Array(K));for(;q<K;)if(Q=J[q],Q>=4290000000)J[q]=crypto.getRandomValues(new Uint32Array(1))[0];else W[q++]=Q%1e7}else if(crypto.randomBytes){J=crypto.randomBytes(K*=4);for(;q<K;)if(Q=J[q]+(J[q+1]<<8)+(J[q+2]<<16)+((J[q+3]&127)<<24),Q>=2140000000)crypto.randomBytes(4).copy(J,q);else W.push(Q%1e7),q+=4;q=K/4}else throw Error(J8);if(K=W[--q],$%=R0,K&&$)Q=n0(10,R0-$),W[q]=(K/Q|0)*Q;for(;W[q]===0;q--)W.pop();if(q<0)Z=0,W=[0];else{Z=-1;for(;W[0]===0;Z-=R0)W.shift();for(K=1,Q=W[0];Q>=10;Q/=10)K++;if(K<R0)Z-=R0-K}return H.e=Z,H.d=W,H}function XQ($){return M0($=new this($),$.e+1,this.rounding)}function kQ($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function wQ($){return new this($).sin()}function LQ($){return new this($).sinh()}function RQ($){return new this($).sqrt()}function BQ($,J){return new this($).sub(J)}function NQ(){var $=0,J=arguments,Z=new this(J[$]);P0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return P0=!0,M0(Z,this.precision,this.rounding)}function IQ($){return new this($).tan()}function CQ($){return new this($).tanh()}function PQ($){return M0($=new this($),$.e+1,1)}K0[Symbol.for("nodejs.util.inspect.custom")]=K0.toString;K0[Symbol.toStringTag]="Decimal";var x$=K0.constructor=j8(z9);U6=new x$(U6);V6=new x$(V6);var O=x$;var _9=($)=>{if($===null||$===void 0)throw new Error(`Cannot convert ${$===null?"null":"undefined"} to Decimal`);if($ instanceof O)return $;try{return new O($)}catch(J){throw new Error(`Invalid numeric value: ${J.message}`)}};class S0{constructor($){if(!Array.isArray($))throw new Error("Vector requires array");if($.length===0)throw new Error("Vector requires at least one component");try{this.data=$.map((J,Z)=>{if(J===null||J===void 0)throw new Error(`Vector component at index ${Z} is ${J===null?"null":"undefined"}`);return _9(J)})}catch(J){throw new Error(`Vector constructor failed: ${J.message}`)}this.length=this.data.length}static from($){if($===null||$===void 0)throw new Error(`Vector.from: argument is ${$===null?"null":"undefined"}`);return new S0($)}clone(){return new S0(this.data.map(($)=>new O($)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map(($)=>$.toNumber())}toStringArray(){return this.data.map(($)=>$.toString())}add($){if(!$||!($ instanceof S0))throw new Error("add: argument must be a Vector");if(this.length!==$.length)throw new Error(`add: dimension mismatch (${this.length} vs ${$.length})`);return new S0(this.data.map((J,Z)=>J.plus($.data[Z])))}sub($){if(!$||!($ instanceof S0))throw new Error("sub: argument must be a Vector");if(this.length!==$.length)throw new Error(`sub: dimension mismatch (${this.length} vs ${$.length})`);return new S0(this.data.map((J,Z)=>J.minus($.data[Z])))}scale($){if($===null||$===void 0)throw new Error(`scale: scalar is ${$===null?"null":"undefined"}`);let J;try{J=_9($)}catch(Z){throw new Error(`scale: invalid scalar - ${Z.message}`)}return new S0(this.data.map((Z)=>Z.mul(J)))}negate(){return new S0(this.data.map(($)=>$.negated()))}dot($){if(!$||!($ instanceof S0))throw new Error("dot: argument must be a Vector");if(this.length!==$.length)throw new Error(`dot: dimension mismatch (${this.length} vs ${$.length})`);return this.data.reduce((J,Z,K)=>J.plus(Z.mul($.data[K])),new O(0))}outer($){if(!$||!($ instanceof S0))throw new Error("outer: argument must be a Vector");if(this.length===0||$.length===0)throw new Error("outer: cannot compute outer product with empty vector");let J=this.length,Z=$.length;return Array.from({length:J},(Q,q)=>Array.from({length:Z},(H,W)=>this.data[q].mul($.data[W])))}cross($){if(!$||!($ instanceof S0))throw new Error("cross: argument must be a Vector");if(this.length!==3||$.length!==3)throw new Error(`cross: requires 3D vectors (got ${this.length}D and ${$.length}D)`);let[J,Z,K]=this.data,[Q,q,H]=$.data;return new S0([Z.mul(H).minus(K.mul(q)),K.mul(Q).minus(J.mul(H)),J.mul(q).minus(Z.mul(Q))])}norm(){let $=new O(0);for(let J of this.data)$=$.plus(J.mul(J));return $.sqrt()}normalize(){let $=this.norm();if($.isZero())throw new Error("Cannot normalize zero vector");return this.scale(new O(1).div($))}angleBetween($){if(!$||!($ instanceof S0))throw new Error("angleBetween: argument must be a Vector");if(this.length!==$.length)throw new Error(`angleBetween: dimension mismatch (${this.length} vs ${$.length})`);let J=this.dot($),Z=this.norm(),K=$.norm();if(Z.isZero()||K.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let q=J.div(Z.mul(K)).toNumber(),H=Math.min(1,Math.max(-1,q));return new O(Math.acos(H))}projectOnto($){if(!$||!($ instanceof S0))throw new Error("projectOnto: argument must be a Vector");if(this.length!==$.length)throw new Error(`projectOnto: dimension mismatch (${this.length} vs ${$.length})`);let J=$.dot($);if(J.isZero())throw new Error("projectOnto: cannot project onto zero vector");let Z=this.dot($).div(J);return $.scale(Z)}orthogonal(){if(this.norm().isZero())throw new Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new S0([this.data[1].negated(),this.data[0]]);for(let J=0;J<this.length;J++){let Z=Array.from({length:this.length},(W,z)=>new O(z===J?1:0)),K=new S0(Z),Q=K.projectOnto(this),q=K.sub(Q);if(!q.norm().isZero())return q.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo($){if(!$||!($ instanceof S0))throw new Error("isOrthogonalTo: argument must be a Vector");if(this.length!==$.length)throw new Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${$.length})`);return this.dot($).isZero()}distance($){if(!$||!($ instanceof S0))throw new Error("distance: argument must be a Vector");if(this.length!==$.length)throw new Error(`distance: dimension mismatch (${this.length} vs ${$.length})`);return this.sub($).norm()}equals($,J=0){if(!($ instanceof S0))return!1;if($.length!==this.length)return!1;if(J===null)throw new Error("equals: tolerance cannot be null");let Z;try{if(Z=_9(J),Z.isNaN())throw new Error("equals: tolerance cannot be NaN");if(Z.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(K){throw new Error(`equals: invalid tolerance - ${K.message}`)}for(let K=0;K<this.length;K++)if(this.data[K].minus($.data[K]).abs().greaterThan(Z))return!1;return!0}}var N$=($)=>{if($==null)throw new Error("Cannot convert null or undefined to Decimal");return $ instanceof O?$:new O($)};class W0{constructor($){if(!Array.isArray($)||$.length===0)throw new Error("Matrix requires non-empty 2D array");if(!Array.isArray($[0])||$[0].length===0)throw new Error("Matrix rows must be non-empty arrays");let J=$[0].length;for(let Z of $)if(!Array.isArray(Z)||Z.length!==J)throw new Error("All rows must have same length");this.data=$.map((Z)=>Z.map((K)=>N$(K))),this.rows=$.length,this.cols=J}static from($){return new W0($)}static zeros($,J){if(!Number.isInteger($)||$<=0)throw new Error("rows must be a positive integer");if(!Number.isInteger(J)||J<=0)throw new Error("cols must be a positive integer");let Z=Array.from({length:$},()=>Array.from({length:J},()=>new O(0)));return new W0(Z)}static identity($){if(!Number.isInteger($)||$<=0)throw new Error("size must be a positive integer");let J=Array.from({length:$},(Z,K)=>Array.from({length:$},(Q,q)=>K===q?new O(1):new O(0)));return new W0(J)}clone(){return new W0(this.data.map(($)=>$.map((J)=>new O(J))))}toArrayOfStrings(){return this.data.map(($)=>$.map((J)=>J.toString()))}toNumberArray(){return this.data.map(($)=>$.map((J)=>J.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector($){let J;if($ instanceof S0)J=$;else if(Array.isArray($))J=S0.from($);else throw new Error("applyToVector expects Vector or array");if(this.cols!==J.length)throw new Error("shape mismatch: matrix cols must equal vector length");let Z=[];for(let K=0;K<this.rows;K++){let Q=new O(0);for(let q=0;q<this.cols;q++)Q=Q.plus(this.data[K][q].mul(J.data[q]));Z.push(Q)}return new S0(Z)}add($){if($ instanceof W0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new W0(this.data.map((J,Z)=>J.map((K,Q)=>K.plus($.data[Z][Q]))))}else{let J=N$($);return new W0(this.data.map((Z)=>Z.map((K)=>K.plus(J))))}}sub($){if($ instanceof W0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new W0(this.data.map((J,Z)=>J.map((K,Q)=>K.minus($.data[Z][Q]))))}else{let J=N$($);return new W0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof W0){if(this.cols!==$.rows)throw new Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let J=Array.from({length:this.rows},()=>Array.from({length:$.cols},()=>new O(0)));for(let Z=0;Z<this.rows;Z++)for(let K=0;K<this.cols;K++){let Q=this.data[Z][K];if(Q.isZero())continue;for(let q=0;q<$.cols;q++)J[Z][q]=J[Z][q].plus(Q.mul($.data[K][q]))}return new W0(J)}else{let J=N$($);return new W0(this.data.map((Z)=>Z.map((K)=>K.mul(J))))}}div($){let J=N$($);if(J.isZero())throw new Error("Cannot divide by zero");return new W0(this.data.map((Z)=>Z.map((K)=>K.div(J))))}negate(){return new W0(this.data.map(($)=>$.map((J)=>J.negated())))}transpose(){let $=Array.from({length:this.cols},(J,Z)=>Array.from({length:this.rows},(K,Q)=>new O(this.data[Q][Z])));return new W0($)}trace(){if(!this.isSquare())throw new Error("Trace only defined for square matrices");let $=new O(0);for(let J=0;J<this.rows;J++)$=$.plus(this.data[J][J]);return $}equals($,J=0){if(!($ instanceof W0))return!1;if(this.rows!==$.rows||this.cols!==$.cols)return!1;let Z=N$(J);if(Z.isNegative()||!Z.isFinite())throw new Error("tolerance must be non-negative and finite");for(let K=0;K<this.rows;K++)for(let Q=0;Q<this.cols;Q++)if(this.data[K][Q].minus($.data[K][Q]).abs().greaterThan(Z))return!1;return!0}lu(){if(!this.isSquare())throw new Error("LU decomposition requires square matrix");let $=this.rows,J=this.data.map((H)=>H.map((W)=>new O(W))),Z=Array.from({length:$},(H,W)=>W),K=Array.from({length:$},()=>Array.from({length:$},()=>new O(0)));for(let H=0;H<$;H++)K[H][H]=new O(1);for(let H=0;H<$;H++){let W=H,z=J[H][H].abs();for(let j=H+1;j<$;j++){let G=J[j][H].abs();if(G.greaterThan(z))z=G,W=j}if(J[W][H].isZero())throw new Error("Singular matrix: LU decomposition failed");if(W!==H){let j=J[H];J[H]=J[W],J[W]=j;let G=Z[H];Z[H]=Z[W],Z[W]=G;for(let F=0;F<H;F++){let _=K[H][F];K[H][F]=K[W][F],K[W][F]=_}}for(let j=H+1;j<$;j++){let G=J[j][H].div(J[H][H]);K[j][H]=G;for(let F=H;F<$;F++)J[j][F]=J[j][F].minus(G.mul(J[H][F]))}}let Q=Array.from({length:$},(H,W)=>Array.from({length:$},(z,j)=>j<W?new O(0):J[W][j])),q=W0.zeros($,$);for(let H=0;H<$;H++)q.data[H][Z[H]]=new O(1);return{L:new W0(K),U:new W0(Q),P:q}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let $=this.rows,{L:J,U:Z,P:K}=this.lu(),Q=new O(1);for(let W=0;W<$;W++)Q=Q.mul(Z.data[W][W]);let q=[];for(let W=0;W<$;W++)for(let z=0;z<$;z++)if(K.data[W][z].equals(1))q.push(z);let H=0;for(let W=0;W<q.length;W++)for(let z=W+1;z<q.length;z++)if(q[W]>q[z])H++;if(H%2===1)Q=Q.negated();return Q}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let $=this.rows,J=Array.from({length:$},(K,Q)=>Array.from({length:2*$},(q,H)=>H<$?new O(this.data[Q][H]):H-$===Q?new O(1):new O(0)));for(let K=0;K<$;K++){let Q=K,q=J[K][K].abs();for(let W=K+1;W<$;W++){let z=J[W][K].abs();if(z.greaterThan(q))q=z,Q=W}if(J[Q][K].isZero())throw new Error("Singular matrix: inverse does not exist");if(Q!==K){let W=J[K];J[K]=J[Q],J[Q]=W}let H=J[K][K];for(let W=0;W<2*$;W++)J[K][W]=J[K][W].div(H);for(let W=0;W<$;W++){if(W===K)continue;let z=J[W][K];if(z.isZero())continue;for(let j=0;j<2*$;j++)J[W][j]=J[W][j].minus(z.mul(J[K][j]))}}let Z=J.map((K)=>K.slice($));return new W0(Z)}solve($){let J;if($ instanceof S0)J=$;else if(Array.isArray($))J=S0.from($);else throw new Error("b must be Vector or array");if(!this.isSquare())throw new Error("solve() only implemented for square matrices");let Z=this.rows;if(J.length!==Z)throw new Error("dimension mismatch: b length must equal matrix rows");let K=Array.from({length:Z},(q,H)=>Array.from({length:Z+1},(W,z)=>new O(z<Z?this.data[H][z]:J.data[H])));for(let q=0;q<Z;q++){let H=q,W=K[q][q].abs();for(let z=q+1;z<Z;z++){let j=K[z][q].abs();if(j.greaterThan(W))W=j,H=z}if(K[H][q].isZero())throw new Error("Singular matrix: no unique solution");if(H!==q){let z=K[q];K[q]=K[H],K[H]=z}for(let z=q+1;z<Z;z++){let j=K[z][q].div(K[q][q]);if(j.isZero())continue;for(let G=q;G<Z+1;G++)K[z][G]=K[z][G].minus(j.mul(K[q][G]))}}let Q=Array.from({length:Z},()=>new O(0));for(let q=Z-1;q>=0;q--){if(K[q][q].isZero())throw new Error("Zero diagonal element in back substitution: system is singular");let H=new O(0);for(let W=q+1;W<Z;W++)H=H.plus(K[q][W].mul(Q[W]));Q[q]=K[q][Z].minus(H).div(K[q][q])}return new S0(Q)}qr(){let $=this.rows,J=this.cols,Z=this.data.map((q)=>q.map((H)=>new O(H))),K=W0.identity($).data;for(let q=0;q<Math.min($,J);q++){let H=[];for(let F=q;F<$;F++)H.push(Z[F][q]);let W=new O(0);for(let F of H)W=W.plus(F.mul(F));if(W=W.sqrt(),W.isZero())continue;let z=H[0].isNegative()?new O(-1):new O(1),j=H.slice();j[0]=j[0].plus(z.mul(W));let G=new O(0);for(let F of j)G=G.plus(F.mul(F));if(G=G.sqrt(),G.isZero())continue;for(let F=0;F<j.length;F++)j[F]=j[F].div(G);for(let F=q;F<J;F++){let _=new O(0);for(let U=0;U<j.length;U++)_=_.plus(j[U].mul(Z[q+U][F]));for(let U=0;U<j.length;U++)Z[q+U][F]=Z[q+U][F].minus(new O(2).mul(j[U]).mul(_))}for(let F=0;F<$;F++){let _=new O(0);for(let U=0;U<j.length;U++)_=_.plus(j[U].mul(K[q+U][F]));for(let U=0;U<j.length;U++)K[q+U][F]=K[q+U][F].minus(new O(2).mul(j[U]).mul(_))}}let Q=Array.from({length:$},(q,H)=>Array.from({length:J},(W,z)=>H<=z?Z[H][z]:new O(0)));return{Q:new W0(K).transpose(),R:new W0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=W0.identity(J),K=$.maxIter||120;if(!Number.isInteger(K)||K<=0)throw new Error("maxIter must be a positive integer");let Q=new O($.tolerance||"1e-40");if(Q.isNegative()||Q.isZero()||!Q.isFinite())throw new Error("tolerance must be positive and finite");let H=((F)=>{let _=new O(0);for(let U=0;U<F.rows;U++){let M=new O(0);for(let V=0;V<F.cols;V++)M=M.plus(F.data[U][V].abs());if(M.greaterThan(_))_=M}return _})(this),W=0;if(H.greaterThan(new O(1))){let F=H.toNumber();if(!isFinite(F))throw new Error("Matrix norm too large for exponential computation");if(W=Math.max(0,Math.ceil(Math.log2(F))),W>50)throw new Error(`Matrix norm too large: requires ${W} scaling steps (max 50 allowed)`)}let z=this;if(W>0)z=this.mul(new O(1).div(new O(2).pow(W)));let j=Z.clone(),G=Z.clone();for(let F=1;F<K;F++){j=j.mul(z).mul(new O(1).div(F)),G=G.add(j);let _=new O(0);for(let U=0;U<j.rows;U++)for(let M=0;M<j.cols;M++)_=_.plus(j.data[U][M].abs());if(_.lessThan(Q))break}for(let F=0;F<W;F++)G=G.mul(G);return G}}var L7={};x7(L7,{translation:()=>r0,stretchAlongAxis:()=>AQ,skew:()=>k6,scale:()=>w7,rotateAroundPoint:()=>U9,rotate:()=>j$,reflectY:()=>TQ,reflectX:()=>EQ,reflectOrigin:()=>bQ,applyTransform:()=>c0});var q7=($)=>{if($ instanceof O){if(!$.isFinite())throw new Error(`Value must be finite (got ${$.toString()})`);return $}try{let J=new O($);if(!J.isFinite())throw new Error(`Value must be finite (got ${$})`);return J}catch(J){throw new Error(`Invalid numeric value: "${$}" (${J.message})`)}};function J7($,J){if($===void 0||$===null)throw new Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof O))throw new Error(`${J} must be a number, string, or Decimal`);if(typeof $==="number"&&!isFinite($))throw new Error(`${J} must be a finite number (got ${$})`);if($ instanceof O&&!$.isFinite())throw new Error(`${J} must be a finite Decimal (got ${$.toString()})`)}function r0($,J){return J7($,"tx"),J7(J,"ty"),W0.from([[new O(1),new O(0),q7($)],[new O(0),new O(1),q7(J)],[new O(0),new O(0),new O(1)]])}function w7($,J=null){if(J7($,"sx"),J!==null)J7(J,"sy");let Z=J===null?$:J,K=q7($),Q=q7(Z);if(K.isZero()||Q.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return W0.from([[K,new O(0),new O(0)],[new O(0),Q,new O(0)],[new O(0),new O(0),new O(1)]])}function j$($){J7($,"theta");let Z=q7($).toNumber(),K=Math.PI,Q=Z-2*K*Math.floor((Z+K)/(2*K));if(!isFinite(Q))throw new Error(`Angle normalization failed for theta=${$} (too large or invalid)`);let q=new O(Math.cos(Q)),H=new O(Math.sin(Q));if(!q.isFinite()||!H.isFinite())throw new Error(`Trigonometric computation failed for theta=${$} (produced non-finite values)`);return W0.from([[q,H.negated(),new O(0)],[H,q,new O(0)],[new O(0),new O(0),new O(1)]])}function U9($,J,Z){J7($,"theta"),J7(J,"px"),J7(Z,"py");let K=q7(J),Q=q7(Z);return r0(K,Q).mul(j$($)).mul(r0(K.negated(),Q.negated()))}function k6($,J){J7($,"ax"),J7(J,"ay");let Z=q7($),K=q7(J);if(new O(1).minus(Z.mul(K)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${Z.mul(K).toString()}, must be < 1)`);return W0.from([[new O(1),Z,new O(0)],[K,new O(1),new O(0)],[new O(0),new O(0),new O(1)]])}function AQ($,J,Z){J7($,"ux"),J7(J,"uy"),J7(Z,"k");let K=q7($),Q=q7(J),q=q7(Z);if(q.isZero())throw new Error("Stretch factor k cannot be zero (creates singular matrix)");let H=K.mul(K).plus(Q.mul(Q));if(H.isZero())throw new Error("Axis vector (ux, uy) cannot be zero");let W=H.minus(1).abs(),z=new O(0.000001);if(W.greaterThan(z))throw new Error(`Axis vector (ux, uy) must be normalized (||u|| = 1). Current magnitude squared: ${H.toString()}, expected: 1. Use normalized vector: (${K.div(H.sqrt()).toString()}, ${Q.div(H.sqrt()).toString()})`);let j=new O(1),G=q.minus(j),F=j.plus(G.mul(K.mul(K))),_=G.mul(K.mul(Q)),U=G.mul(Q.mul(K)),M=j.plus(G.mul(Q.mul(Q)));return W0.from([[F,_,new O(0)],[U,M,new O(0)],[new O(0),new O(0),new O(1)]])}function c0($,J,Z){if(!$||typeof $.mul!=="function")throw new Error("applyTransform: first argument must be a Matrix");if(!$.data||!Array.isArray($.data)||$.data.length!==3||!$.data[0]||$.data[0].length!==3||!$.data[1]||$.data[1].length!==3||!$.data[2]||$.data[2].length!==3)throw new Error("applyTransform: matrix must be 3x3");J7(J,"x"),J7(Z,"y");let K=W0.from([[q7(J)],[q7(Z)],[new O(1)]]),Q=$.mul(K);if(!Q||!Q.data||!Array.isArray(Q.data)||Q.data.length!==3||!Q.data[0]||!Q.data[0][0]||!Q.data[1]||!Q.data[1][0]||!Q.data[2]||!Q.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let q=Q.data[0][0],H=Q.data[1][0],W=Q.data[2][0];if(W.isZero())throw new Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[q.div(W),H.div(W)]}function EQ(){return W0.from([[new O(1),new O(0),new O(0)],[new O(0),new O(-1),new O(0)],[new O(0),new O(0),new O(1)]])}function TQ(){return W0.from([[new O(-1),new O(0),new O(0)],[new O(0),new O(1),new O(0)],[new O(0),new O(0),new O(1)]])}function bQ(){return W0.from([[new O(-1),new O(0),new O(0)],[new O(0),new O(-1),new O(0)],[new O(0),new O(0),new O(1)]])}var O9={};x7(O9,{translation:()=>V9,scale:()=>fQ,rotateZ:()=>DQ,rotateY:()=>vQ,rotateX:()=>SQ,rotateAroundPoint:()=>hQ,rotateAroundAxis:()=>G8,reflectYZ:()=>xQ,reflectXZ:()=>gQ,reflectXY:()=>uQ,reflectOrigin:()=>mQ,applyTransform:()=>yQ});var l0=($)=>{if($ instanceof O)return $;try{let J=new O($);if(!J.isFinite())throw new Error(`Value must be finite, got ${$}`);return J}catch(J){throw new Error(`Invalid numeric value: ${$}`)}};function g0($,J){if($===void 0||$===null)throw new Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof O))throw new Error(`${J} must be a number, string, or Decimal`)}function w6($){let J=$.toNumber();if(!Number.isFinite(J))throw new Error(`Angle must be finite, got ${$}`);if(Math.abs(J)<=6.283185307179586)return J;let Z=6.283185307179586,K=J%Z;if(K>Z)K-=Z;else if(K<-Z)K+=Z;return K}function V9($,J,Z){return g0($,"tx"),g0(J,"ty"),g0(Z,"tz"),W0.from([[new O(1),new O(0),new O(0),l0($)],[new O(0),new O(1),new O(0),l0(J)],[new O(0),new O(0),new O(1),l0(Z)],[new O(0),new O(0),new O(0),new O(1)]])}function fQ($,J=null,Z=null){if(g0($,"sx"),J!==null)g0(J,"sy");if(Z!==null)g0(Z,"sz");let K=J===null?$:J,Q=Z===null?$:Z,q=l0($),H=l0(K),W=l0(Q);if(q.isZero()||H.isZero()||W.isZero());return W0.from([[q,new O(0),new O(0),new O(0)],[new O(0),H,new O(0),new O(0)],[new O(0),new O(0),W,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function SQ($){g0($,"theta");let J=l0($),Z=w6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return W0.from([[new O(1),new O(0),new O(0),new O(0)],[new O(0),K,Q.negated(),new O(0)],[new O(0),Q,K,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function vQ($){g0($,"theta");let J=l0($),Z=w6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return W0.from([[K,new O(0),Q,new O(0)],[new O(0),new O(1),new O(0),new O(0)],[Q.negated(),new O(0),K,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function DQ($){g0($,"theta");let J=l0($),Z=w6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return W0.from([[K,Q.negated(),new O(0),new O(0)],[Q,K,new O(0),new O(0)],[new O(0),new O(0),new O(1),new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function G8($,J,Z,K){g0($,"ux"),g0(J,"uy"),g0(Z,"uz"),g0(K,"theta");let Q=[l0($),l0(J),l0(Z)],q=Q[0].mul(Q[0]).plus(Q[1].mul(Q[1])).plus(Q[2].mul(Q[2])).sqrt();if(q.isZero())throw new Error("Rotation axis cannot be zero vector (ux=0, uy=0, uz=0)");Q[0]=Q[0].div(q),Q[1]=Q[1].div(q),Q[2]=Q[2].div(q);let H=l0(K),W=w6(H),z=new O(Math.cos(W)),j=new O(Math.sin(W)),G=new O(1),F=Q[0].mul(Q[0]),_=Q[1].mul(Q[1]),U=Q[2].mul(Q[2]),M=F.plus(z.mul(G.minus(F))),V=Q[0].mul(Q[1]).mul(G.minus(z)).minus(Q[2].mul(j)),Y=Q[0].mul(Q[2]).mul(G.minus(z)).plus(Q[1].mul(j)),X=Q[1].mul(Q[0]).mul(G.minus(z)).plus(Q[2].mul(j)),k=_.plus(z.mul(G.minus(_))),w=Q[1].mul(Q[2]).mul(G.minus(z)).minus(Q[0].mul(j)),R=Q[2].mul(Q[0]).mul(G.minus(z)).minus(Q[1].mul(j)),I=Q[2].mul(Q[1]).mul(G.minus(z)).plus(Q[0].mul(j)),P=U.plus(z.mul(G.minus(U)));return W0.from([[M,V,Y,new O(0)],[X,k,w,new O(0)],[R,I,P,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function hQ($,J,Z,K,Q,q,H){g0($,"ux"),g0(J,"uy"),g0(Z,"uz"),g0(K,"theta"),g0(Q,"px"),g0(q,"py"),g0(H,"pz");let W=l0(Q),z=l0(q),j=l0(H);return V9(W,z,j).mul(G8($,J,Z,K)).mul(V9(W.negated(),z.negated(),j.negated()))}function yQ($,J,Z,K){if(!($ instanceof W0))throw new Error("M must be a Matrix instance");if($.rows!==4||$.cols!==4)throw new Error(`M must be a 4x4 matrix, got ${$.rows}x${$.cols}`);g0(J,"x"),g0(Z,"y"),g0(K,"z");let Q=W0.from([[l0(J)],[l0(Z)],[l0(K)],[new O(1)]]),q=$.mul(Q),H=q.data[0][0],W=q.data[1][0],z=q.data[2][0],j=q.data[3][0];if(j.isZero())throw new Error("Perspective division by zero: transformation results in point at infinity");return[H.div(j),W.div(j),z.div(j)]}function uQ(){return W0.from([[new O(1),new O(0),new O(0),new O(0)],[new O(0),new O(1),new O(0),new O(0)],[new O(0),new O(0),new O(-1),new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function gQ(){return W0.from([[new O(1),new O(0),new O(0),new O(0)],[new O(0),new O(-1),new O(0),new O(0)],[new O(0),new O(0),new O(1),new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function xQ(){return W0.from([[new O(-1),new O(0),new O(0),new O(0)],[new O(0),new O(1),new O(0),new O(0)],[new O(0),new O(0),new O(1),new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function mQ(){return W0.from([[new O(-1),new O(0),new O(0),new O(0)],[new O(0),new O(-1),new O(0),new O(0)],[new O(0),new O(0),new O(-1),new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}var K9={};x7(K9,{validateXML:()=>qK,validateSVGAsync:()=>oW,validateSVG:()=>HK,straightCurves:()=>QJ,sortDefsChildren:()=>vZ,sortAttrs:()=>SZ,simplifyPaths:()=>VK,simplifyPath:()=>FK,saveOutput:()=>WZ,reusePaths:()=>DZ,removeXlink:()=>uZ,removeXMLProcInst:()=>YZ,removeXMLNS:()=>LZ,removeViewBox:()=>wZ,removeUselessDefs:()=>UZ,removeUselessCommands:()=>WJ,removeUnknownsAndDefaults:()=>FZ,removeTitle:()=>MZ,removeStyleElement:()=>yZ,removeScriptElement:()=>BZ,removeRasterImages:()=>RZ,removeOffCanvasPath:()=>hZ,removeNonInheritableGroupAttrs:()=>_Z,removeMetadata:()=>J9,removeLeadingZero:()=>t9,removeHiddenElements:()=>t6,removeEmptyText:()=>VZ,removeEmptyContainers:()=>e6,removeEmptyAttrs:()=>kZ,removeElementsByAttr:()=>nZ,removeEditorsNSData:()=>LJ,removeDoctype:()=>OZ,removeDimensions:()=>dZ,removeDesc:()=>XZ,removeComments:()=>$9,removeAttrs:()=>cZ,removeAttributesBySelector:()=>pZ,printHierarchicalMatrix:()=>mW,presetNone:()=>IJ,presetDefault:()=>NJ,prefixIds:()=>mZ,optimizePaths:()=>UK,optimizeAnimationTiming:()=>_K,optimize:()=>sZ,negativeExtraSpace:()=>e9,moveGroupAttrsToElems:()=>TZ,moveElemsAttrsToGroup:()=>bZ,minifyStyles:()=>BJ,mergePaths:()=>EZ,measureDistance:()=>QK,loadInput:()=>W6,lineShorthands:()=>ZJ,inlineStyles:()=>fZ,imageToPath:()=>ZK,generateOutput:()=>z6,generateFullCompatibilityMatrix:()=>xW,generateFlexibleSVGTable:()=>WK,generateCompatibilityMatrixSVG:()=>dW,generateCompatibilityMatrixFlexible:()=>pW,formatPrecision:()=>HZ,floatPrecision:()=>HJ,flattenUseElements:()=>JK,flattenPatterns:()=>eZ,flattenMasks:()=>rZ,flattenGradients:()=>aZ,flattenFilters:()=>$K,flattenClipPaths:()=>iZ,flattenAll:()=>GK,fixInvalidSVG:()=>zK,exportEmbeddedResources:()=>MK,escapeXml:()=>EW,embedExternalDependencies:()=>PJ,detectOutputTarget:()=>kJ,detectInputType:()=>w$,detectCollisions:()=>KK,default:()=>Gz,decomposeTransform:()=>OK,createOperation:()=>F0,createConfig:()=>oZ,convertTransform:()=>CZ,convertToZ:()=>KJ,convertToRelative:()=>$J,convertToAbsolute:()=>JJ,convertStyleToAttrs:()=>RJ,convertShapesToPath:()=>NZ,convertQuadraticToSmooth:()=>jJ,convertPathData:()=>IZ,convertEllipseToCircle:()=>PZ,convertCubicToSmooth:()=>GJ,convertCubicToQuadratic:()=>zJ,convertColors:()=>Z9,collapseRepeated:()=>qJ,collapseGroups:()=>AZ,cleanupNumericValues:()=>a6,cleanupListOfValues:()=>zZ,cleanupIds:()=>wJ,cleanupEnableBackground:()=>GZ,cleanupAttributes:()=>jZ,arcShorthands:()=>FJ,applyPreset:()=>lZ,analyzeCompatibilityMatrix:()=>gW,analyzeCompatibility:()=>vW,addClassesToSVGElement:()=>xZ,addAttributesToSVGElement:()=>gZ,ValidationSeverity:()=>A0,PRECISION_LEVELS:()=>qZ,OutputTarget:()=>Y7,OutputFormat:()=>M7,MAX_PRECISION:()=>H6,InputType:()=>D0,DEFAULT_PRECISION:()=>o6});O.set({precision:80});var dz=new O("1e-40"),pz=new O("1e-10");O.set({precision:80});var y0=($)=>$ instanceof O?$:new O($),pQ=new O("1e-40"),cQ=new O("1e-30");function nQ($,J){if($==null)throw new TypeError("translationMatrix: tx parameter is required");if(J==null)throw new TypeError("translationMatrix: ty parameter is required");return W0.from([[1,0,y0($)],[0,1,y0(J)],[0,0,1]])}function lQ($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=y0($),Z=O.cos(J),K=O.sin(J);return W0.from([[Z,K.neg(),0],[K,Z,0],[0,0,1]])}function sQ($,J){if($==null)throw new TypeError("scaleMatrix: sx parameter is required");if(J==null)throw new TypeError("scaleMatrix: sy parameter is required");return W0.from([[y0($),0,0],[0,y0(J),0],[0,0,1]])}function oQ($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=O.tan(y0($));return W0.from([[1,J,0],[0,1,0],[0,0,1]])}function iQ($){if($==null)throw new TypeError("skewYMatrix: angle parameter is required");let J=O.tan(y0($));return W0.from([[1,0,0],[J,1,0],[0,0,1]])}function rQ($){if(!$)throw new TypeError("extractLinearPart: matrix parameter is required");if(!$.data)throw new TypeError("extractLinearPart: matrix must have data property");if($.rows<2||$.cols<2)throw new RangeError("extractLinearPart: matrix must be at least 2x2");let J=$.data;return{a:J[0][0],b:J[1][0],c:J[0][1],d:J[1][1]}}function aQ($){if(!$)throw new TypeError("extractTranslation: matrix parameter is required");if(!$.data)throw new TypeError("extractTranslation: matrix must have data property");if($.rows<2||$.cols<3)throw new RangeError("extractTranslation: matrix must be at least 2x3");let J=$.data;return{tx:J[0][2],ty:J[1][2]}}function F8($){if(!$)throw new TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:K,d:Q}=rQ($),{tx:q,ty:H}=aQ($),W=J.mul(Q).minus(Z.mul(K)),z=J.mul(J).plus(Z.mul(Z)).sqrt();if(z.abs().lessThan(pQ))return{translateX:q,translateY:H,rotation:y0(0),scaleX:y0(0),scaleY:y0(0),skewX:y0(0),skewY:y0(0),verified:!1,maxError:y0("Infinity"),singular:!0};let j=W.div(z);if(j.abs().greaterThan(new O("1e40")))return{translateX:q,translateY:H,rotation:y0(0),scaleX:y0(0),scaleY:y0(0),skewX:y0(0),skewY:y0(0),verified:!1,maxError:y0("Infinity"),singular:!0};if(W.lessThan(0))z=z.neg(),j=j.neg();let G=O.atan2(Z,J),F=O.cos(G),_=O.sin(G),U=J.mul(F).plus(Z.mul(_)),M=K.mul(F).plus(Q.mul(_)),V,Y=new O("1e-30");if(U.abs().greaterThan(Y)){let I=M.div(U);if(I.abs().greaterThan(new O("1e10")))V=y0(0);else V=O.atan(I)}else V=y0(0);let X=y0(0),k=tQ({translateX:q,translateY:H,rotation:G,scaleX:z,scaleY:j,skewX:V,skewY:y0(0)}),w=eQ($,k),R=w.lessThan(cQ);return{translateX:q,translateY:H,rotation:G,scaleX:z,scaleY:j,skewX:V,skewY:X,verified:R,maxError:w}}function tQ($){if(!$)throw new TypeError("composeTransform: components parameter is required");if($.translateX==null)throw new TypeError("composeTransform: components.translateX is required");if($.translateY==null)throw new TypeError("composeTransform: components.translateY is required");if($.rotation==null)throw new TypeError("composeTransform: components.rotation is required");if($.scaleX==null)throw new TypeError("composeTransform: components.scaleX is required");if($.scaleY==null)throw new TypeError("composeTransform: components.scaleY is required");if($.skewX==null)throw new TypeError("composeTransform: components.skewX is required");let{translateX:J,translateY:Z,rotation:K,scaleX:Q,scaleY:q,skewX:H,skewY:W=0}=$,z=nQ(J,Z),j=lQ(K),G=oQ(H),F=iQ(W),_=sQ(Q,q);return z.mul(j).mul(F).mul(G).mul(_)}function eQ($,J){if(!$)throw new TypeError("matrixMaxDifference: m1 parameter is required");if(!J)throw new TypeError("matrixMaxDifference: m2 parameter is required");if(!$.data)throw new TypeError("matrixMaxDifference: m1 must have data property");if(!J.data)throw new TypeError("matrixMaxDifference: m2 must have data property");if($.rows!==J.rows||$.cols!==J.cols)throw new RangeError(`matrixMaxDifference: matrices must have same dimensions (${$.rows}x${$.cols} vs ${J.rows}x${J.cols})`);let Z=y0(0);for(let K=0;K<$.rows;K++)for(let Q=0;Q<$.cols;Q++){let q=$.data[K][Q].minus(J.data[K][Q]).abs();if(q.greaterThan(Z))Z=q}return Z}O.set({precision:80});var U7=($)=>$ instanceof O?$:new O($),m0=new O("1e-40"),_8=100;function S7($,J){if($==null)throw new TypeError("point: x coordinate cannot be null or undefined");if(J==null)throw new TypeError("point: y coordinate cannot be null or undefined");return{x:U7($),y:U7(J)}}function Jq($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorAdd: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorAdd: second vector must have x and y properties");return{x:$.x.plus(J.x),y:$.y.plus(J.y)}}function d0($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorSub: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorSub: second vector must have x and y properties");return{x:$.x.minus(J.x),y:$.y.minus(J.y)}}function d$($){if(!$||$.x==null||$.y==null)throw new TypeError("vectorNeg: vector must have x and y properties");return{x:$.x.neg(),y:$.y.neg()}}function M9($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorScale: vector must have x and y properties");if(J==null)throw new TypeError("vectorScale: scale factor cannot be null or undefined");let Z=U7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function H7($,J){if(!$||$.x==null||$.y==null)throw new TypeError("dot: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("dot: second vector must have x and y properties");return $.x.mul(J.x).plus($.y.mul(J.y))}function m$($,J){if(!$||$.x==null||$.y==null)throw new TypeError("cross: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("cross: second vector must have x and y properties");return $.x.mul(J.y).minus($.y.mul(J.x))}function _7($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitudeSquared: vector must have x and y properties");return $.x.mul($.x).plus($.y.mul($.y))}function G$($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitude: vector must have x and y properties");return _7($).sqrt()}function Zq($){if(!$||$.x==null||$.y==null)throw new TypeError("normalize: vector must have x and y properties");let J=G$($);if(J.lessThan(m0))return{x:U7(0),y:U7(0)};return{x:$.x.div(J),y:$.y.div(J)}}function $$($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("tripleProduct: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("tripleProduct: second vector must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("tripleProduct: third vector must have x and y properties");let K=H7($,Z),Q=H7(J,Z);return d0(M9(J,K),M9($,Q))}function U8($,J){if(!Array.isArray($))throw new TypeError("supportPoint: polygon must be an array");if(!J||J.x==null||J.y==null)throw new TypeError("supportPoint: direction must have x and y properties");if($.length===0)throw new TypeError("supportPoint: polygon cannot be empty");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("supportPoint: polygon[0] must have x and y properties");let Z=H7($[0],J),K=$[0];for(let Q=1;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`supportPoint: polygon[${Q}] must have x and y properties`);let q=H7($[Q],J);if(q.greaterThan(Z))Z=q,K=$[Q]}return K}function V8($,J,Z){if(!Array.isArray($))throw new TypeError("minkowskiSupport: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("minkowskiSupport: polygonB must be an array");if(!Z||Z.x==null||Z.y==null)throw new TypeError("minkowskiSupport: direction must have x and y properties");let K=U8($,Z),Q=U8(J,d$(Z));return d0(K,Q)}function Kq($,J){if(!Array.isArray($))throw new TypeError("processLineSimplex: simplex must be an array");if($.length!==2)throw new TypeError("processLineSimplex: simplex must have exactly 2 points");if(!J||J.x==null||J.y==null)throw new TypeError("processLineSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processLineSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processLineSimplex: simplex[1] must have x and y properties");let Z=$[0],K=$[1],Q=d0(K,Z),q=d$(Z),H=_7(Q);if(H.lessThan(m0)){if(_7(Z).lessThan(m0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}let W=$$(Q,q,Q);if(_7(W).lessThan(m0)){let z=H7(Q,q);if(z.greaterThanOrEqualTo(0)&&z.lessThanOrEqualTo(H))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}return{contains:!1,newDirection:W}}function Qq($,J){if(!Array.isArray($))throw new TypeError("processTriangleSimplex: simplex must be an array");if($.length!==3)throw new TypeError("processTriangleSimplex: simplex must have exactly 3 points");if(!J||J.x==null||J.y==null)throw new TypeError("processTriangleSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processTriangleSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processTriangleSimplex: simplex[1] must have x and y properties");if(!$[2]||$[2].x==null||$[2].y==null)throw new TypeError("processTriangleSimplex: simplex[2] must have x and y properties");let Z=$[0],K=$[1],Q=$[2],q=d0(K,Z),H=d0(Q,Z),W=d$(Z),z=_7(q),j=_7(H);if(z.lessThan(m0))return{contains:!1,newDirection:$$(H,W,H),newSimplex:[Z,Q]};if(j.lessThan(m0))return{contains:!1,newDirection:$$(q,W,q),newSimplex:[Z,K]};let G=$$(H,q,q),F=$$(q,H,H);if(_7(G).lessThan(m0)&&_7(F).lessThan(m0)){let _=d0(Q,K),U=_7(_);if(U.greaterThan(z)&&U.greaterThan(j))return{contains:!1,newDirection:$$(_,d$(K),_),newSimplex:[K,Q]};else if(z.greaterThan(j))return{contains:!1,newDirection:$$(q,W,q),newSimplex:[Z,K]};else return{contains:!1,newDirection:$$(H,W,H),newSimplex:[Z,Q]}}if(H7(G,W).greaterThan(m0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(H7(F,W).greaterThan(m0))return{contains:!1,newDirection:F,newSimplex:[Z,Q]};return{contains:!0,newDirection:J,newSimplex:$}}function M8($,J){if(!Array.isArray($))throw new TypeError("gjkIntersects: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkIntersects: polygonB must be an array");if($.length===0||J.length===0)return{intersects:!1,iterations:0,simplex:[],verified:!0};if($.length===1&&J.length===1){if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkIntersects: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkIntersects: polygonB[0] must have x and y properties");return{intersects:G$(d0($[0],J[0])).lessThan(m0),iterations:1,simplex:[],verified:!0}}let Z=d0(L6(J),L6($));if(_7(Z).lessThan(m0))Z=S7(1,0);let K=[V8($,J,Z)];if(Z=d$(K[0]),_7(K[0]).lessThan(m0))return{intersects:!0,iterations:1,simplex:K,verified:Y9($,J)};for(let Q=0;Q<_8;Q++){let q=V8($,J,Z);if(H7(q,Z).lessThanOrEqualTo(U7(0)))return{intersects:!1,iterations:Q+1,simplex:K,verified:!0};if(K.unshift(q),K.length===2){let H=Kq(K,Z);if(H.contains)return{intersects:!0,iterations:Q+1,simplex:K,verified:Y9($,J)};Z=H.newDirection}else if(K.length===3){let H=Qq(K,Z);if(H.contains)return{intersects:!0,iterations:Q+1,simplex:H.newSimplex,verified:Y9($,J)};K=H.newSimplex,Z=H.newDirection}if(_7(Z).lessThan(m0))return{intersects:!1,iterations:Q+1,simplex:K,verified:!1};Z=Zq(Z)}return{intersects:!1,iterations:_8,simplex:K,verified:!1}}function L6($){if(!Array.isArray($))throw new TypeError("centroid: polygon must be an array");if($.length===0)throw new TypeError("centroid: polygon cannot be empty");let J=U7(0),Z=U7(0);for(let Q=0;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`centroid: polygon[${Q}] must have x and y properties`);J=J.plus($[Q].x),Z=Z.plus($[Q].y)}let K=U7($.length);return{x:J.div(K),y:Z.div(K)}}function O8($,J){if(!$||$.x==null||$.y==null)throw new TypeError("pointInConvexPolygon: point must have x and y properties");if(!Array.isArray(J))throw new TypeError("pointInConvexPolygon: polygon must be an array");if(J.length<3)return!1;let Z=null;for(let K=0;K<J.length;K++){let Q=J[K],q=J[(K+1)%J.length];if(!Q||Q.x==null||Q.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${K}] must have x and y properties`);if(!q||q.x==null||q.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${(K+1)%J.length}] must have x and y properties`);let H=d0(q,Q),W=d0($,Q),z=m$(H,W);if(z.abs().lessThan(m0))continue;let j=z.greaterThan(0);if(Z===null)Z=j;else if(Z!==j)return!1}return!0}function Y9($,J){if(!Array.isArray($))throw new TypeError("verifyIntersection: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("verifyIntersection: polygonB must be an array");for(let Z=0;Z<$.length;Z++){if(!$[Z]||$[Z].x==null||$[Z].y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(O8($[Z],J))return!0}for(let Z=0;Z<J.length;Z++){if(!J[Z]||J[Z].x==null||J[Z].y==null)throw new TypeError(`verifyIntersection: polygonB[${Z}] must have x and y properties`);if(O8(J[Z],$))return!0}for(let Z=0;Z<$.length;Z++){let K=$[Z],Q=$[(Z+1)%$.length];if(!K||K.x==null||K.y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(!Q||Q.x==null||Q.y==null)throw new TypeError(`verifyIntersection: polygonA[${(Z+1)%$.length}] must have x and y properties`);for(let q=0;q<J.length;q++){let H=J[q],W=J[(q+1)%J.length];if(!H||H.x==null||H.y==null)throw new TypeError(`verifyIntersection: polygonB[${q}] must have x and y properties`);if(!W||W.x==null||W.y==null)throw new TypeError(`verifyIntersection: polygonB[${(q+1)%J.length}] must have x and y properties`);if(qq(K,Q,H,W))return!0}}return!1}function qq($,J,Z,K){if(!$||$.x==null||$.y==null)throw new TypeError("segmentsIntersect: a1 must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("segmentsIntersect: a2 must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("segmentsIntersect: b1 must have x and y properties");if(!K||K.x==null||K.y==null)throw new TypeError("segmentsIntersect: b2 must have x and y properties");let Q=d0(J,$),q=d0(K,Z),H=m$(Q,q);if(H.abs().lessThan(m0)){let G=d0(Z,$);if(m$(Q,G).abs().lessThan(m0)){let F=H7(Q,Q);if(F.lessThan(m0)){let X=H7(q,q);if(X.lessThan(m0))return G$(G).lessThan(m0);let k=H7(G,q).div(X);return k.greaterThanOrEqualTo(0)&&k.lessThanOrEqualTo(1)}let _=H7(G,Q).div(F),U=d0(K,$),M=H7(U,Q).div(F),V=O.min(_,M);return O.max(_,M).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let W=d0(Z,$),z=m$(W,q).div(H),j=m$(W,Q).div(H);return z.greaterThanOrEqualTo(0)&&z.lessThanOrEqualTo(1)&&j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)}function Hq($,J){if(!Array.isArray($))throw new TypeError("gjkDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkDistance: polygonB must be an array");if($.length===0)throw new TypeError("gjkDistance: polygonA cannot be empty");if(J.length===0)throw new TypeError("gjkDistance: polygonB cannot be empty");if(M8($,J).intersects)return{distance:U7(0),closestA:L6($),closestB:L6(J),verified:!0};if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkDistance: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkDistance: polygonB[0] must have x and y properties");let K=U7(1/0),Q=$[0],q=J[0];for(let z=0;z<$.length;z++){if(!$[z]||$[z].x==null||$[z].y==null)throw new TypeError(`gjkDistance: polygonA[${z}] must have x and y properties`);for(let j=0;j<J.length;j++){if(!J[j]||J[j].x==null||J[j].y==null)throw new TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);let G=G$(d0($[z],J[j]));if(G.lessThan(K))K=G,Q=$[z],q=J[j]}}for(let z=0;z<$.length;z++){if(!$[z]||$[z].x==null||$[z].y==null)throw new TypeError(`gjkDistance: polygonA[${z}] must have x and y properties`);for(let j=0;j<J.length;j++){let G=J[j],F=J[(j+1)%J.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonB[${(j+1)%J.length}] must have x and y properties`);let _=Y8($[z],G,F),U=G$(d0($[z],_));if(U.lessThan(K))K=U,Q=$[z],q=_}}for(let z=0;z<J.length;z++){if(!J[z]||J[z].x==null||J[z].y==null)throw new TypeError(`gjkDistance: polygonB[${z}] must have x and y properties`);for(let j=0;j<$.length;j++){let G=$[j],F=$[(j+1)%$.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonA[${(j+1)%$.length}] must have x and y properties`);let _=Y8(J[z],G,F),U=G$(d0(J[z],_));if(U.lessThan(K))K=U,Q=_,q=J[z]}}let W=G$(d0(Q,q)).minus(K).abs().lessThan(m0);return{distance:K,closestA:Q,closestB:q,verified:W}}function Y8($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("closestPointOnSegment: pt must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("closestPointOnSegment: a must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("closestPointOnSegment: b must have x and y properties");let K=d0(Z,J),Q=d0($,J),q=_7(K);if(q.lessThan(m0))return J;let H=H7(Q,K).div(q);return H=O.max(U7(0),O.min(U7(1),H)),Jq(J,M9(K,H))}function R6($,J){if(!Array.isArray($))throw new TypeError("polygonsOverlap: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsOverlap: polygonB must be an array");let Z=$.map((q,H)=>{if(!q||q.x==null||q.y==null)throw new TypeError(`polygonsOverlap: polygonA[${H}] must have x and y properties`);return S7(q.x,q.y)}),K=J.map((q,H)=>{if(!q||q.x==null||q.y==null)throw new TypeError(`polygonsOverlap: polygonB[${H}] must have x and y properties`);return S7(q.x,q.y)}),Q=M8(Z,K);return{overlaps:Q.intersects,verified:Q.verified}}function X8($,J){if(!Array.isArray($))throw new TypeError("polygonsDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsDistance: polygonB must be an array");let Z=$.map((q,H)=>{if(!q||q.x==null||q.y==null)throw new TypeError(`polygonsDistance: polygonA[${H}] must have x and y properties`);return S7(q.x,q.y)}),K=J.map((q,H)=>{if(!q||q.x==null||q.y==null)throw new TypeError(`polygonsDistance: polygonB[${H}] must have x and y properties`);return S7(q.x,q.y)}),Q=Hq(Z,K);return{distance:Q.distance,closestA:Q.closestA,closestB:Q.closestB,verified:Q.verified}}O.set({precision:80});var oz=new O("1e-40"),iz=new O("1e-10");O.set({precision:80});var tz=new O("1e-40"),ez=new O("1e-30");O.set({precision:80});var j0=($)=>$ instanceof O?$:new O($),Z4=new O("1e-40"),Gq=new O("1e-10");function R8($){if(typeof $!=="string")throw new Error("ViewBox must be a string");let J=$.trim().split(/[\s,]+/).filter((Z)=>Z.length>0);if(J.length!==4)throw new Error(`Invalid viewBox format: expected 4 values, got ${J.length}`);try{let Z=j0(J[0]),K=j0(J[1]),Q=j0(J[2]),q=j0(J[3]);if(Q.lessThanOrEqualTo(0)||q.lessThanOrEqualTo(0))throw new Error("ViewBox width and height must be positive");let H=`${Z.toString()} ${K.toString()} ${Q.toString()} ${q.toString()}`,W=J.join(" ");return{x:Z,y:K,width:Q,height:q,verified:H===W}}catch(Z){throw new Error(`Invalid viewBox values: ${Z.message}`)}}function Fq($,J,Z,K){if($==null||J==null||Z==null||K==null)throw new Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let Q=j0($),q=j0(J),H=j0(Z),W=j0(K);if(H.lessThan(Q))throw new Error(`createBBox: maxX (${H}) must be >= minX (${Q})`);if(W.lessThan(q))throw new Error(`createBBox: maxY (${W}) must be >= minY (${q})`);return{minX:Q,minY:q,maxX:H,maxY:W,width:H.minus(Q),height:W.minus(q)}}function k8($,J,Z,K,Q,q,H,W,z=20){if($==null||J==null||Z==null||K==null||Q==null||q==null||H==null||W==null)throw new Error("sampleCubicBezier: all coordinate parameters must be provided");if(z==null||z<=0)throw new Error("sampleCubicBezier: samples must be a positive number");let j=[];for(let G=0;G<=z;G++){let F=j0(G).div(z),_=j0(1).minus(F),U=F.mul(F),M=U.mul(F),V=_.mul(_),Y=V.mul(_),X=Y.mul($).plus(j0(3).mul(V).mul(F).mul(Z)).plus(j0(3).mul(_).mul(U).mul(Q)).plus(M.mul(H)),k=Y.mul(J).plus(j0(3).mul(V).mul(F).mul(K)).plus(j0(3).mul(_).mul(U).mul(q)).plus(M.mul(W));j.push({x:X,y:k})}return j}function w8($,J,Z,K,Q,q,H=20){if($==null||J==null||Z==null||K==null||Q==null||q==null)throw new Error("sampleQuadraticBezier: all coordinate parameters must be provided");if(H==null||H<=0)throw new Error("sampleQuadraticBezier: samples must be a positive number");let W=[];for(let z=0;z<=H;z++){let j=j0(z).div(H),G=j0(1).minus(j),F=G.mul(G),_=j.mul(j),U=F.mul($).plus(j0(2).mul(G).mul(j).mul(Z)).plus(_.mul(Q)),M=F.mul(J).plus(j0(2).mul(G).mul(j).mul(K)).plus(_.mul(q));W.push({x:U,y:M})}return W}function _q($,J,Z=Gq){if(!$||typeof $!=="object"||$.x==null||$.y==null)throw new Error("pointInBBox: pt must be an object with x and y properties");if(!J||typeof J!=="object")throw new Error("pointInBBox: bbox must be a bounding box object");if(J.minX==null||J.minY==null||J.maxX==null||J.maxY==null)throw new Error("pointInBBox: bbox must have minX, minY, maxX, maxY properties");return $.x.greaterThanOrEqualTo(J.minX.minus(Z))&&$.x.lessThanOrEqualTo(J.maxX.plus(Z))&&$.y.greaterThanOrEqualTo(J.minY.minus(Z))&&$.y.lessThanOrEqualTo(J.maxY.plus(Z))}function B8($){if(!$||$.length===0)throw new Error("pathBoundingBox: path commands array is empty");let J=j0(1/0),Z=j0(1/0),K=j0(-1/0),Q=j0(-1/0),q=j0(0),H=j0(0),W=j0(0),z=j0(0),j=j0(0),G=j0(0),F=null,_=[];for(let V of $){if(!V||typeof V!=="object"||!V.type||typeof V.type!=="string")throw new Error("pathBoundingBox: each command must be an object with a string type property");let Y=V.type.toUpperCase(),X=V.type===V.type.toLowerCase();switch(Y){case"M":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: M command requires x and y properties");let k=X?q.plus(j0(V.x)):j0(V.x),w=X?H.plus(j0(V.y)):j0(V.y);q=k,H=w,W=q,z=H,J=O.min(J,q),Z=O.min(Z,H),K=O.max(K,q),Q=O.max(Q,H),_.push({x:q,y:H}),j=q,G=H,F="M"}break;case"L":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: L command requires x and y properties");let k=X?q.plus(j0(V.x)):j0(V.x),w=X?H.plus(j0(V.y)):j0(V.y);J=O.min(J,k),Z=O.min(Z,w),K=O.max(K,k),Q=O.max(Q,w),_.push({x:k,y:w}),q=k,H=w,j=q,G=H,F="L"}break;case"H":{if(V.x==null)throw new Error("pathBoundingBox: H command requires x property");let k=X?q.plus(j0(V.x)):j0(V.x);J=O.min(J,k),K=O.max(K,k),_.push({x:k,y:H}),q=k,j=q,G=H,F="H"}break;case"V":{if(V.y==null)throw new Error("pathBoundingBox: V command requires y property");let k=X?H.plus(j0(V.y)):j0(V.y);Z=O.min(Z,k),Q=O.max(Q,k),_.push({x:q,y:k}),H=k,j=q,G=H,F="V"}break;case"C":{if(V.x1==null||V.y1==null||V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: C command requires x1, y1, x2, y2, x, y properties");let k=X?q.plus(j0(V.x1)):j0(V.x1),w=X?H.plus(j0(V.y1)):j0(V.y1),R=X?q.plus(j0(V.x2)):j0(V.x2),I=X?H.plus(j0(V.y2)):j0(V.y2),P=X?q.plus(j0(V.x)):j0(V.x),u=X?H.plus(j0(V.y)):j0(V.y),g=k8(q,H,k,w,R,I,P,u,20);for(let b of g)J=O.min(J,b.x),Z=O.min(Z,b.y),K=O.max(K,b.x),Q=O.max(Q,b.y),_.push(b);j=R,G=I,q=P,H=u,F="C"}break;case"S":{if(V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: S command requires x2, y2, x, y properties");let k=X?q.plus(j0(V.x2)):j0(V.x2),w=X?H.plus(j0(V.y2)):j0(V.y2),R=X?q.plus(j0(V.x)):j0(V.x),I=X?H.plus(j0(V.y)):j0(V.y),P,u;if(F==="C"||F==="S")P=q.mul(2).minus(j),u=H.mul(2).minus(G);else P=q,u=H;let g=k8(q,H,P,u,k,w,R,I,20);for(let b of g)J=O.min(J,b.x),Z=O.min(Z,b.y),K=O.max(K,b.x),Q=O.max(Q,b.y),_.push(b);j=k,G=w,q=R,H=I,F="S"}break;case"Q":{if(V.x1==null||V.y1==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: Q command requires x1, y1, x, y properties");let k=X?q.plus(j0(V.x1)):j0(V.x1),w=X?H.plus(j0(V.y1)):j0(V.y1),R=X?q.plus(j0(V.x)):j0(V.x),I=X?H.plus(j0(V.y)):j0(V.y),P=w8(q,H,k,w,R,I,20);for(let u of P)J=O.min(J,u.x),Z=O.min(Z,u.y),K=O.max(K,u.x),Q=O.max(Q,u.y),_.push(u);j=k,G=w,q=R,H=I,F="Q"}break;case"T":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: T command requires x and y properties");let k=X?q.plus(j0(V.x)):j0(V.x),w=X?H.plus(j0(V.y)):j0(V.y),R,I;if(F==="Q"||F==="T")R=q.mul(2).minus(j),I=H.mul(2).minus(G);else R=q,I=H;let P=w8(q,H,R,I,k,w,20);for(let u of P)J=O.min(J,u.x),Z=O.min(Z,u.y),K=O.max(K,u.x),Q=O.max(Q,u.y),_.push(u);j=R,G=I,q=k,H=w,F="T"}break;case"A":{if(V.x==null||V.y==null||V.rx==null||V.ry==null)throw new Error("pathBoundingBox: A command requires x, y, rx, ry properties");let k=X?q.plus(j0(V.x)):j0(V.x),w=X?H.plus(j0(V.y)):j0(V.y),R=j0(V.rx).abs(),I=j0(V.ry).abs();if(R.isZero()||I.isZero())J=O.min(J,q,k),Z=O.min(Z,H,w),K=O.max(K,q,k),Q=O.max(Q,H,w),_.push({x:q,y:H},{x:k,y:w});else{J=O.min(J,q,k),Z=O.min(Z,H,w),K=O.max(K,q,k),Q=O.max(Q,H,w);let P=q.plus(k).div(2),u=H.plus(w).div(2);J=O.min(J,P.minus(R)),Z=O.min(Z,u.minus(I)),K=O.max(K,P.plus(R)),Q=O.max(Q,u.plus(I));let g=20;for(let b=0;b<=g;b++){let h=j0(b).div(g),v=q.plus(k.minus(q).mul(h)),E=H.plus(w.minus(H).mul(h));_.push({x:v,y:E})}}q=k,H=w,j=q,G=H,F="A"}break;case"Z":q=W,H=z,j=q,G=H,F="Z";break;default:throw new Error(`pathBoundingBox: unknown path command type: ${Y}`)}}if(!J.isFinite()||!Z.isFinite()||!K.isFinite()||!Q.isFinite())throw new Error("Invalid bounding box: no valid coordinates found");let U=Fq(J,Z,K,Q),M=!0;for(let V of _)if(!_q(V,U)){M=!1;break}return{...U,verified:M}}function L8($){if(!$||typeof $!=="object")throw new Error("bboxToPolygon: bbox must be a bounding box object");if($.minX==null||$.minY==null||$.maxX==null||$.maxY==null)throw new Error("bboxToPolygon: bbox must have minX, minY, maxX, maxY properties");return[S7($.minX,$.minY),S7($.maxX,$.minY),S7($.maxX,$.maxY),S7($.minX,$.maxY)]}function N8($,J){if(!J||typeof J!=="object")throw new Error("bboxIntersectsViewBox: viewBox must be an object");if(J.x==null||J.y==null||J.width==null||J.height==null)throw new Error("bboxIntersectsViewBox: viewBox must have x, y, width, height properties");let Z=L8($),K=L8({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),Q=R6(Z,K);return{intersects:Q.overlaps,verified:Q.verified}}var Z7={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function Vq($){if(typeof $!=="string"||!$.trim())throw new Error("Selector must be a non-empty string");let J=$.trim(),Z=[],K=Oq(J);for(let Q of K){if(!Q.trim())continue;let q=Yq(Q.trim());Z.push(...q)}return Z}function Oq($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z="",K=0,Q=0,q=!1,H=null;for(let z=0;z<$.length;z++){let j=$[z],G=z>0?$[z-1]:null;if((j==='"'||j==="'")&&G!=="\\"){if(!q)q=!0,H=j;else if(j===H)q=!1,H=null}if(!q){if(j==="["&&G!=="\\")K++;else if(j==="]"&&G!=="\\"){if(K--,K<0)throw new Error(`Unbalanced brackets at position ${z}`)}else if(j==="("&&G!=="\\")Q++;else if(j===")"&&G!=="\\"){if(Q--,Q<0)throw new Error(`Unbalanced parentheses at position ${z}`)}}if(!q&&K===0&&Q===0){if(j===">"||j==="+"||j==="~"){let F=Z.trim();if(F)J.push(F);Z="";continue}else if(j===" "){let F=Z.trim();if(F){J.push(F),Z="";continue}else continue}}Z+=j}if(q)throw new Error("Unclosed quote in selector");if(K!==0)throw new Error("Unclosed brackets in selector");if(Q!==0)throw new Error("Unclosed parentheses in selector");let W=Z.trim();if(W)J.push(W);return J}function Yq($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z=0;while(Z<$.length){let K=$[Z];if(K==="#"){let Q=$.slice(Z).match(/^#([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid ID selector at position ${Z}`);J.push({type:Z7.ID,value:Q[1]}),Z+=Q[0].length}else if(K==="."){let Q=$.slice(Z).match(/^\.([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid class selector at position ${Z}`);J.push({type:Z7.CLASS,value:Q[1]}),Z+=Q[0].length}else if(K==="["){let Q=Mq($,Z);if(Q===-1)throw new Error(`Unclosed attribute selector at position ${Z}`);let q=$.slice(Z+1,Q);J.push({type:Z7.ATTRIBUTE,value:q}),Z=Q+1}else if(K===":")if(Z+1<$.length&&$[Z+1]===":"){let Q=$.slice(Z).match(/^::([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-element at position ${Z}`);J.push({type:Z7.PSEUDO_ELEMENT,value:Q[1]}),Z+=Q[0].length}else{let Q=$.slice(Z).match(/^:([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-class at position ${Z}`);let q=Q[1];if(Z+=Q[0].length,Z<$.length&&$[Z]==="("){let z=Xq($,Z);if(z===-1)throw new Error(`Unclosed pseudo-class function at position ${Z}`);q+=$.slice(Z,z+1),Z=z+1}let W=["before","after","first-line","first-letter"].includes(q);J.push({type:W?Z7.PSEUDO_ELEMENT:Z7.PSEUDO_CLASS,value:q})}else if(K==="*"){let Q=Z+1;if(Q<$.length&&$[Q]==="|"){if(Q++,Q<$.length&&$[Q]==="*")Q++}J.push({type:Z7.UNIVERSAL,value:"*"}),Z=Q}else if(/[a-zA-Z]/.test(K)){let Q=$.slice(Z).match(/^([a-zA-Z][\w-]*)/);if(!Q)throw new Error(`Invalid type selector at position ${Z}`);let q=Q[1],H=Z+Q[0].length;if(H<$.length&&$[H]==="|"){H++;let W=$.slice(H).match(/^([a-zA-Z*][\w-]*)/);if(W)q=W[1],H+=W[0].length}J.push({type:Z7.TYPE,value:q}),Z=H}else if(K===">"||K==="+"||K==="~"||K===" ")Z++;else throw new Error(`Unexpected character '${K}' at position ${Z}`)}return J}function Mq($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let q=J;q<$.length;q++){let H=$[q],W=q>0?$[q-1]:null;if((H==='"'||H==="'")&&W!=="\\"){if(!K)K=!0,Q=H;else if(H===Q)K=!1,Q=null}if(!K){if(H==="["&&W!=="\\")Z++;if(H==="]"&&W!=="\\"){if(Z--,Z===0)return q}}}return-1}function Xq($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let q=J;q<$.length;q++){let H=$[q],W=q>0?$[q-1]:null;if((H==='"'||H==="'")&&W!=="\\"){if(!K)K=!0,Q=H;else if(H===Q)K=!1,Q=null}if(!K){if(H==="("&&W!=="\\")Z++;if(H===")"&&W!=="\\"){if(Z--,Z===0)return q}}}return-1}function B6($){let J=typeof $==="string"?Vq($):$;if(!Array.isArray(J))throw new Error("Selector must be a string or an array of components");let Z=0,K=0,Q=0;for(let q of J){if(!q||typeof q.type!=="string")throw new Error("Invalid component: must have a 'type' property");switch(q.type){case Z7.ID:Z++;break;case Z7.CLASS:case Z7.ATTRIBUTE:K++;break;case Z7.PSEUDO_CLASS:{let H=q.value;if(H.startsWith("where(")&&H.endsWith(")"))break;if((H.startsWith("not(")||H.startsWith("is(")||H.startsWith("has("))&&H.endsWith(")")){let W=H.match(/^(\w+)\(/)[1],z=H.slice(W.length+1,-1);if(z.trim()){let j=kq(z),G=[0,0,0];for(let F of j)if(F.trim()){let _=B6(F.trim());if(N6(_,G)>0)G=_}Z+=G[0],K+=G[1],Q+=G[2]}break}if((H.startsWith("nth-child(")||H.startsWith("nth-last-child("))&&H.endsWith(")")){let W=H.match(/^([\w-]+)\(/)[1],j=H.slice(W.length+1,-1).match(/\s+of\s+(.+)$/);if(j){let G=j[1].trim(),F=B6(G);Z+=F[0],K+=F[1],Q+=F[2]}K++;break}K++;break}case Z7.TYPE:case Z7.PSEUDO_ELEMENT:Q++;break;case Z7.UNIVERSAL:break;default:break}}return[Z,K,Q]}function kq($){if(typeof $!=="string")throw new Error("selectorList must be a string");let J=[],Z="",K=0,Q=0,q=!1,H=null;for(let W=0;W<$.length;W++){let z=$[W],j=W>0?$[W-1]:null;if((z==='"'||z==="'")&&j!=="\\"){if(!q)q=!0,H=z;else if(z===H)q=!1,H=null}if(!q){if(z==="(")K++;if(z===")")K--;if(z==="[")Q++;if(z==="]")Q--;if(z===","&&K===0&&Q===0){J.push(Z),Z="";continue}}Z+=z}if(Z)J.push(Z);return J}function N6($,J){if(!Array.isArray($)||$.length!==3)throw new Error("spec1 must be an array of 3 numbers");if(!Array.isArray(J)||J.length!==3)throw new Error("spec2 must be an array of 3 numbers");for(let Z=0;Z<3;Z++){if(typeof $[Z]!=="number"||!Number.isFinite($[Z])||$[Z]<0)throw new Error(`spec1[${Z}] must be a non-negative finite number`);if(typeof J[Z]!=="number"||!Number.isFinite(J[Z])||J[Z]<0)throw new Error(`spec2[${Z}] must be a non-negative finite number`)}for(let Z=0;Z<3;Z++){if($[Z]<J[Z])return-1;if($[Z]>J[Z])return 1}return 0}var n$={};x7(n$,{transformPathData:()=>Bq,transformArcParams:()=>P8,rectToPathData:()=>E6,polylineToPathData:()=>p$,polygonToPathData:()=>b6,pathToCubics:()=>Nq,pathToAbsolute:()=>c$,pathArrayToString:()=>I$,parsePathData:()=>J$,lineToPathData:()=>T6,getKappaForArc:()=>C8,getKappa:()=>I6,ellipseToPathDataHP:()=>C6,ellipseToPathData:()=>A6,convertElementToPath:()=>k9,circleToPathDataHP:()=>X9,circleToPathData:()=>P6});var f0=($)=>$ instanceof O?$:new O($);function I6(){let $=new O(2),J=new O(3);return new O(4).mul($.sqrt().minus(1)).div(J)}function C8($){if($==null)throw new Error("getKappaForArc: thetaRadians parameter is required");let J=f0($);if(!J.isFinite())throw new Error("getKappaForArc: thetaRadians must be finite");if(J.isZero()||J.isNegative())throw new Error("getKappaForArc: thetaRadians must be positive");let Z=new O(4),K=new O(3);return Z.div(K).mul(O.tan(J.div(Z)))}function X9($,J,Z,K=8,Q=6){if($==null||J==null||Z==null)throw new Error("circleToPathDataHP: cx, cy, and r parameters are required");let q=f0(Z);if(!q.isFinite()||q.isNegative())throw new Error("circleToPathDataHP: radius must be finite and non-negative");if(q.isZero())return"";if(!Number.isFinite(K)||K<=0)throw new Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(Q)||Q<0)throw new Error("circleToPathDataHP: precision must be non-negative");return C6($,J,Z,Z,K,Q)}function C6($,J,Z,K,Q=8,q=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<=0)throw new Error("ellipseToPathDataHP: arcs must be a positive number");if(!Number.isFinite(q)||q<0)throw new Error("ellipseToPathDataHP: precision must be non-negative");let H=Q;if(H%4!==0)H=Math.ceil(H/4)*4;let W=f0($),z=f0(J),j=f0(Z),G=f0(K);if(!j.isFinite()||j.isNegative())throw new Error("ellipseToPathDataHP: rx must be finite and non-negative");if(!G.isFinite()||G.isNegative())throw new Error("ellipseToPathDataHP: ry must be finite and non-negative");if(j.isZero()||G.isZero())return"";let F=(X)=>F$(X,q),M=O.acos(-1).mul(2).div(H),V=C8(M),Y=[];for(let X=0;X<H;X++){let k=M.mul(X),w=M.mul(X+1),R=O.cos(k),I=O.sin(k),P=O.cos(w),u=O.sin(w),g=W.plus(j.mul(R)),b=z.plus(G.mul(I)),h=W.plus(j.mul(P)),v=z.plus(G.mul(u)),E=I.neg(),m=R,c=u.neg(),d=P,N=g.plus(V.mul(j).mul(E)),y=b.plus(V.mul(G).mul(m)),B=h.minus(V.mul(j).mul(c)),t=v.minus(V.mul(G).mul(d));if(X===0)Y.push(`M${F(g)} ${F(b)}`);Y.push(`C${F(N)} ${F(y)} ${F(B)} ${F(t)} ${F(h)} ${F(v)}`)}return Y.push("Z"),Y.join(" ")}function F$($,J=6){if($==null)throw new Error("formatNumber: value parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("formatNumber: precision must be non-negative");let Z=f0($);if(!Z.isFinite())throw new Error("formatNumber: value must be finite");let K=Z.toFixed(J);if(K.includes("."))K=K.replace(/\.?0+$/,"");return K}function P6($,J,Z,K=6){if($==null||J==null||Z==null)throw new Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(K)||K<0)throw new Error("circleToPathData: precision must be non-negative");let Q=f0($),q=f0(J),H=f0(Z);if(!H.isFinite()||H.isNegative())throw new Error("circleToPathData: radius must be finite and non-negative");if(H.isZero())return"";let W=I6().mul(H),z=Q.plus(H),j=q,G=z,F=j.minus(W),_=Q.plus(W),U=q.minus(H),M=Q,V=q.minus(H),Y=Q.minus(W),X=V,k=Q.minus(H),w=q.minus(W),R=Q.minus(H),I=q,P=R,u=q.plus(W),g=Q.minus(W),b=q.plus(H),h=Q,v=q.plus(H),E=Q.plus(W),m=v,c=z,d=q.plus(W),N=(y)=>F$(y,K);return`M${N(z)} ${N(j)}C${N(G)} ${N(F)} ${N(_)} ${N(U)} ${N(M)} ${N(V)}C${N(Y)} ${N(X)} ${N(k)} ${N(w)} ${N(R)} ${N(I)}C${N(P)} ${N(u)} ${N(g)} ${N(b)} ${N(h)} ${N(v)}C${N(E)} ${N(m)} ${N(c)} ${N(d)} ${N(z)} ${N(j)}Z`}function A6($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("ellipseToPathData: precision must be non-negative");let q=f0($),H=f0(J),W=f0(Z),z=f0(K);if(!W.isFinite()||W.isNegative())throw new Error("ellipseToPathData: rx must be finite and non-negative");if(!z.isFinite()||z.isNegative())throw new Error("ellipseToPathData: ry must be finite and non-negative");if(W.isZero()||z.isZero())return"";let j=I6(),G=j.mul(W),F=j.mul(z),_=q.plus(W),U=H,M=_,V=U.minus(F),Y=q.plus(G),X=H.minus(z),k=q,w=H.minus(z),R=q.minus(G),I=w,P=q.minus(W),u=H.minus(F),g=q.minus(W),b=H,h=g,v=H.plus(F),E=q.minus(G),m=H.plus(z),c=q,d=H.plus(z),N=q.plus(G),y=d,B=_,t=H.plus(F),i=(l)=>F$(l,Q);return`M${i(_)} ${i(U)}C${i(M)} ${i(V)} ${i(Y)} ${i(X)} ${i(k)} ${i(w)}C${i(R)} ${i(I)} ${i(P)} ${i(u)} ${i(g)} ${i(b)}C${i(h)} ${i(v)} ${i(E)} ${i(m)} ${i(c)} ${i(d)}C${i(N)} ${i(y)} ${i(B)} ${i(t)} ${i(_)} ${i(U)}Z`}function E6($,J,Z,K,Q=0,q=null,H=!1,W=6){if($==null||J==null||Z==null||K==null)throw new Error("rectToPathData: x, y, width, and height parameters are required");if(!Number.isFinite(W)||W<0)throw new Error("rectToPathData: precision must be non-negative");let z=f0($),j=f0(J),G=f0(Z),F=f0(K);if(!z.isFinite())throw new Error("rectToPathData: x must be finite");if(!j.isFinite())throw new Error("rectToPathData: y must be finite");if(!G.isFinite()||G.isNegative())throw new Error("rectToPathData: width must be finite and non-negative");if(!F.isFinite()||F.isNegative())throw new Error("rectToPathData: height must be finite and non-negative");if(G.isZero()||F.isZero())return"";let _=f0(Q||0),U=q!==null?f0(q):_;if(!_.isFinite()||_.isNegative())throw new Error("rectToPathData: rx must be finite and non-negative");if(!U.isFinite()||U.isNegative())throw new Error("rectToPathData: ry must be finite and non-negative");let M=G.div(2),V=F.div(2);if(_.gt(M))_=M;if(U.gt(V))U=V;let Y=(E)=>F$(E,W);if(_.isZero()||U.isZero()){let E=z.plus(G),m=j.plus(F);return`M${Y(z)} ${Y(j)}H${Y(E)}V${Y(m)}H${Y(z)}Z`}let X=z,k=z.plus(G),w=j,R=j.plus(F),I=X.plus(_),P=k.minus(_),u=w.plus(U),g=R.minus(U);if(H)return`M${Y(I)} ${Y(w)}L${Y(P)} ${Y(w)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(k)} ${Y(u)}L${Y(k)} ${Y(g)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(P)} ${Y(R)}L${Y(I)} ${Y(R)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(X)} ${Y(g)}L${Y(X)} ${Y(u)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(I)} ${Y(w)}Z`;let b=I6(),h=b.mul(_),v=b.mul(U);return`M${Y(I)} ${Y(w)}L${Y(P)} ${Y(w)}C${Y(P.plus(h))} ${Y(w)} ${Y(k)} ${Y(u.minus(v))} ${Y(k)} ${Y(u)}L${Y(k)} ${Y(g)}C${Y(k)} ${Y(g.plus(v))} ${Y(P.plus(h))} ${Y(R)} ${Y(P)} ${Y(R)}L${Y(I)} ${Y(R)}C${Y(I.minus(h))} ${Y(R)} ${Y(X)} ${Y(g.plus(v))} ${Y(X)} ${Y(g)}L${Y(X)} ${Y(u)}C${Y(X)} ${Y(u.minus(v))} ${Y(I.minus(h))} ${Y(w)} ${Y(I)} ${Y(w)}Z`}function T6($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("lineToPathData: precision must be non-negative");let q=f0($),H=f0(J),W=f0(Z),z=f0(K);if(!q.isFinite()||!H.isFinite()||!W.isFinite()||!z.isFinite())throw new Error("lineToPathData: all coordinates must be finite");let j=(G)=>F$(G,Q);return`M${j(q)} ${j(H)}L${j(W)} ${j(z)}`}function Lq($){if($==null)return[];if(Array.isArray($))try{return $.map(([q,H])=>[f0(q),f0(H)])}catch(q){return[]}let J=$;if(typeof J==="object"&&J.baseVal!==void 0)J=J.baseVal;if(typeof J!=="string")if(typeof J.toString==="function")J=J.toString();else return[];let Z=[],K=J.split(/[\s,]+/).filter((q)=>q.length>0);for(let q of K)try{Z.push(f0(q))}catch(H){continue}let Q=[];for(let q=0;q<Z.length;q+=2)if(q+1<Z.length)Q.push([Z[q],Z[q+1]]);return Q}function p$($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polylineToPathData: precision must be non-negative");let Z=Lq($);if(Z.length===0)return"";let K=(W)=>F$(W,J),[Q,q]=Z[0],H=`M${K(Q)} ${K(q)}`;for(let W=1;W<Z.length;W++){let[z,j]=Z[W];H+=`L${K(z)} ${K(j)}`}return H}function b6($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polygonToPathData: precision must be non-negative");let Z=p$($,J);return Z?Z+" Z":""}var Rq={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function J$($){if($==null)throw new Error("parsePathData: pathData parameter is required");if(typeof $!=="string")throw new Error("parsePathData: pathData must be a string");let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])\s*([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],q=K[2].trim(),H=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,W=[];if(q.length>0)for(let j of q.matchAll(H))try{W.push(f0(j[0]))}catch(G){continue}let z=Rq[Q];if(z===0||W.length===0)J.push({command:Q,args:[]});else for(let j=0;j<W.length;j+=z){let G=W.slice(j,j+z);if(G.length===z){let F=Q;if(j>0&&(Q==="M"||Q==="m"))F=Q==="M"?"L":"l";J.push({command:F,args:G})}}}return J}function I$($,J=6){if($==null)throw new Error("pathArrayToString: commands parameter is required");if(!Array.isArray($))throw new Error("pathArrayToString: commands must be an array");if(!Number.isFinite(J)||J<0)throw new Error("pathArrayToString: precision must be non-negative");return $.map((Z)=>{if(!Z||typeof Z.command!=="string"||!Array.isArray(Z.args))throw new Error("pathArrayToString: each command must have 'command' (string) and 'args' (array) properties");let{command:K,args:Q}=Z,q=Q.map((H)=>F$(H,J)).join(" ");return q.length>0?`${K} ${q}`:K}).join(" ")}function c$($){if($==null)throw new Error("pathToAbsolute: pathData parameter is required");let J=J$($),Z=[],K=new O(0),Q=new O(0),q=new O(0),H=new O(0),W=new O(0),z=new O(0),j="";for(let{command:G,args:F}of J){let _=G===G.toLowerCase(),U=G.toUpperCase();if(U==="M"){if(F.length<2)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=M,Q=V,q=M,H=V,Z.push({command:"M",args:[M,V]}),j="M"}else if(U==="L"){if(F.length<2)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=M,Q=V,Z.push({command:"L",args:[M,V]}),j="L"}else if(U==="H"){if(F.length<1)continue;let M=_?K.plus(F[0]):F[0];K=M,Z.push({command:"L",args:[M,Q]}),j="H"}else if(U==="V"){if(F.length<1)continue;let M=_?Q.plus(F[0]):F[0];Q=M,Z.push({command:"L",args:[K,M]}),j="V"}else if(U==="C"){if(F.length<6)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],Y=_?K.plus(F[2]):F[2],X=_?Q.plus(F[3]):F[3],k=_?K.plus(F[4]):F[4],w=_?Q.plus(F[5]):F[5];W=Y,z=X,K=k,Q=w,Z.push({command:"C",args:[M,V,Y,X,k,w]}),j="C"}else if(U==="S"){if(F.length<4)continue;let M,V;if(j==="C"||j==="S")M=K.mul(2).minus(W),V=Q.mul(2).minus(z);else M=K,V=Q;let Y=_?K.plus(F[0]):F[0],X=_?Q.plus(F[1]):F[1],k=_?K.plus(F[2]):F[2],w=_?Q.plus(F[3]):F[3];W=Y,z=X,K=k,Q=w,Z.push({command:"C",args:[M,V,Y,X,k,w]}),j="S"}else if(U==="Q"){if(F.length<4)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],Y=_?K.plus(F[2]):F[2],X=_?Q.plus(F[3]):F[3];W=M,z=V,K=Y,Q=X,Z.push({command:"Q",args:[M,V,Y,X]}),j="Q"}else if(U==="T"){if(F.length<2)continue;let M,V;if(j==="Q"||j==="T")M=K.mul(2).minus(W),V=Q.mul(2).minus(z);else M=K,V=Q;let Y=_?K.plus(F[0]):F[0],X=_?Q.plus(F[1]):F[1];W=M,z=V,K=Y,Q=X,Z.push({command:"Q",args:[M,V,Y,X]}),j="T"}else if(U==="A"){if(F.length<7)continue;let M=_?K.plus(F[5]):F[5],V=_?Q.plus(F[6]):F[6];K=M,Q=V,Z.push({command:"A",args:[F[0],F[1],F[2],F[3],F[4],M,V]}),j="A"}else if(U==="Z")K=q,Q=H,Z.push({command:"Z",args:[]}),j="Z";else Z.push({command:G,args:F}),j=G}return I$(Z)}function P8($,J,Z,K,Q,q,H,W){if($==null||J==null||Z==null||K==null||Q==null||q==null||H==null)throw new Error("transformArcParams: all parameters (rx, ry, xAxisRotation, largeArc, sweep, endX, endY) are required");if(W==null)throw new Error("transformArcParams: matrix parameter is required");if(!W.data||!Array.isArray(W.data)||W.data.length!==3)throw new Error("transformArcParams: matrix must be 3x3");if(!Array.isArray(W.data[0])||W.data[0].length<2||!Array.isArray(W.data[1])||W.data[1].length<2||!Array.isArray(W.data[2])||W.data[2].length<1)throw new Error("transformArcParams: matrix must have valid 3x3 structure");let z=f0($),j=f0(J),G=f0(Z),F=f0(q),_=f0(H),U=W0.from([[F],[_],[new O(1)]]),M=W.mul(U),V=M.data[2][0];if(V.isZero())throw new Error("transformArcParams: division by zero in homogeneous coordinate transformation");let Y=M.data[0][0].div(V),X=M.data[1][0].div(V),k=W.data[0][0],w=W.data[0][1],R=W.data[1][0],I=W.data[1][1],u=k.mul(I).minus(w.mul(R)).isNegative()?Q===1?0:1:Q,g=G.mul(new O(Math.PI)).div(180),b=O.cos(g),h=O.sin(g),v=z.mul(b),E=z.mul(h),m=j.mul(h).neg(),c=j.mul(b),d=k.mul(v).plus(w.mul(E)),N=R.mul(v).plus(I.mul(E)),y=k.mul(m).plus(w.mul(c)),B=R.mul(m).plus(I.mul(c)),t=O.sqrt(d.mul(d).plus(N.mul(N))),i=O.sqrt(y.mul(y).plus(B.mul(B))),q0=O.atan2(N,d).mul(180).div(new O(Math.PI));return[t,i,q0,K,u,Y,X]}function Bq($,J,Z=6){if($==null)throw new Error("transformPathData: pathData parameter is required");if(J==null)throw new Error("transformPathData: matrix parameter is required");if(!J.data||!Array.isArray(J.data)||J.data.length!==3)throw new Error("transformPathData: matrix must be 3x3");if(!Array.isArray(J.data[0])||J.data[0].length<2||!Array.isArray(J.data[1])||J.data[1].length<2||!Array.isArray(J.data[2])||J.data[2].length<1)throw new Error("transformPathData: matrix must have valid 3x3 structure");if(!Number.isFinite(Z)||Z<0)throw new Error("transformPathData: precision must be non-negative");let K=c$($),Q=J$(K),q=[];for(let{command:H,args:W}of Q)if(H==="M"||H==="L"){if(W.length<2)continue;let z=W0.from([[W[0]],[W[1]],[new O(1)]]),j=J.mul(z),G=j.data[2][0];if(G.isZero())throw new Error("transformPathData: division by zero in homogeneous coordinate transformation");let F=j.data[0][0].div(G),_=j.data[1][0].div(G);q.push({command:H,args:[F,_]})}else if(H==="C"){if(W.length<6)continue;let z=[];for(let j=0;j<6;j+=2){let G=W0.from([[W[j]],[W[j+1]],[new O(1)]]),F=J.mul(G),_=F.data[2][0];if(_.isZero())throw new Error("transformPathData: division by zero in homogeneous coordinate transformation");z.push(F.data[0][0].div(_)),z.push(F.data[1][0].div(_))}q.push({command:H,args:z})}else if(H==="A"){if(W.length<7)continue;let[z,j,G,F,_,U,M]=P8(W[0],W[1],W[2],W[3],W[4],W[5],W[6],J);q.push({command:H,args:[z,j,G,F,_,U,M]})}else q.push({command:H,args:W});return I$(q,Z)}function I8($,J,Z,K,Q,q){if($==null||J==null||Z==null||K==null||Q==null||q==null)throw new Error("quadraticToCubic: all parameters (x0, y0, x1, y1, x2, y2) are required");let H=new O(2).div(3),W=$.plus(H.mul(Z.minus($))),z=J.plus(H.mul(K.minus(J))),j=Q.plus(H.mul(Z.minus(Q))),G=q.plus(H.mul(K.minus(q)));return[W,z,j,G,Q,q]}function Nq($){if($==null)throw new Error("pathToCubics: pathData parameter is required");let J=c$($),Z=J$(J),K=[],Q=new O(0),q=new O(0),H=new O(0),W=new O(0),z="";for(let{command:j,args:G}of Z)if(j==="M"){if(G.length<2)continue;Q=G[0],q=G[1],K.push({command:"M",args:[Q,q]}),z="M"}else if(j==="L"){if(G.length<2)continue;let F=G[0],_=G[1];K.push({command:"C",args:[Q,q,F,_,F,_]}),Q=F,q=_,z="L"}else if(j==="C"){if(G.length<6)continue;let[F,_,U,M,V,Y]=G;K.push({command:"C",args:[F,_,U,M,V,Y]}),H=U,W=M,Q=V,q=Y,z="C"}else if(j==="S"){if(G.length<4)continue;let F,_;if(z==="C"||z==="S")F=Q.mul(2).minus(H),_=q.mul(2).minus(W);else F=Q,_=q;let[U,M,V,Y]=G;K.push({command:"C",args:[F,_,U,M,V,Y]}),H=U,W=M,Q=V,q=Y,z="S"}else if(j==="Q"){if(G.length<4)continue;let[F,_,U,M]=G,V=I8(Q,q,F,_,U,M);K.push({command:"C",args:V}),H=F,W=_,Q=U,q=M,z="Q"}else if(j==="T"){if(G.length<2)continue;let F,_;if(z==="Q"||z==="T")F=Q.mul(2).minus(H),_=q.mul(2).minus(W);else F=Q,_=q;let[U,M]=G,V=I8(Q,q,F,_,U,M);K.push({command:"C",args:V}),H=F,W=_,Q=U,q=M,z="T"}else if(j==="Z")K.push({command:"Z",args:[]}),z="Z";else K.push({command:j,args:G}),z=j;return I$(K)}function k9($,J=6){if($==null)throw new Error("convertElementToPath: element parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("convertElementToPath: precision must be non-negative");let Z=(Q,q=0)=>{let H=$.getAttribute?$.getAttribute(Q):$[Q];return Iq(H!==void 0&&H!==null?H:q)},K=($.tagName||$.type||"").toLowerCase();if(K==="circle")return P6(Z("cx",0),Z("cy",0),Z("r",0),J);else if(K==="ellipse")return A6(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(K==="rect")return E6(Z("x",0),Z("y",0),Z("width",0),Z("height",0),Z("rx",0),Z("ry",null),!1,J);else if(K==="line")return T6(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(K==="polyline")return p$(Z("points",""),J);else if(K==="polygon")return b6(Z("points",""),J);return null}function Iq($){if($==null)return 0;if(typeof $==="string"){let Z=parseFloat($);return isNaN(Z)?0:Z}if(typeof $==="number")return isNaN($)?0:$;if($ instanceof O)return $.toNumber();let J=Number($);return isNaN(J)?0:J}O.set({precision:80});function A8($,J,Z){return w9($,J,Z,Z)}function w9($,J,Z,K){let Q=(R)=>new O(R),q=Q($),H=Q(J),W=Q(Z),z=Q(K);if(!W.isFinite()||!z.isFinite()||!q.isFinite()||!H.isFinite())throw new Error("Ellipse parameters must be finite");if(W.eq(0)||z.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(W.lt(0)||z.lt(0))throw new Error("Ellipse radii must be non-negative");let j=Q("0.5522847498307936"),G=W.mul(j),F=z.mul(j),_=q.plus(W),U=H,M=q,V=H.minus(z),Y=q.minus(W),X=H,k=q,w=H.plus(z);return[`M ${_.toFixed(6)} ${U.toFixed(6)}`,`C ${_.toFixed(6)} ${U.minus(F).toFixed(6)} ${M.plus(G).toFixed(6)} ${V.toFixed(6)} ${M.toFixed(6)} ${V.toFixed(6)}`,`C ${M.minus(G).toFixed(6)} ${V.toFixed(6)} ${Y.toFixed(6)} ${X.minus(F).toFixed(6)} ${Y.toFixed(6)} ${X.toFixed(6)}`,`C ${Y.toFixed(6)} ${X.plus(F).toFixed(6)} ${k.minus(G).toFixed(6)} ${w.toFixed(6)} ${k.toFixed(6)} ${w.toFixed(6)}`,`C ${k.plus(G).toFixed(6)} ${w.toFixed(6)} ${_.toFixed(6)} ${U.plus(F).toFixed(6)} ${_.toFixed(6)} ${U.toFixed(6)}`,"Z"].join(" ")}function E8($,J,Z,K,Q=0,q=null){let H=(Y)=>new O(Y),W=H($),z=H(J),j=H(Z),G=H(K);if(j.lte(0)||G.lte(0))throw new Error("Rectangle dimensions must be positive");if(!j.isFinite()||!G.isFinite()||!W.isFinite()||!z.isFinite())throw new Error("Rectangle parameters must be finite");let F=H(Q),_=q!==null?H(q):F;if(F.lt(0)||_.lt(0))throw new Error("Rectangle corner radii must be non-negative");let U=j.div(2),M=G.div(2);if(F.gt(U))F=U;if(_.gt(M))_=M;if(!(F.gt(0)||_.gt(0)))return[`M ${W.toFixed(6)} ${z.toFixed(6)}`,`L ${W.plus(j).toFixed(6)} ${z.toFixed(6)}`,`L ${W.plus(j).toFixed(6)} ${z.plus(G).toFixed(6)}`,`L ${W.toFixed(6)} ${z.plus(G).toFixed(6)}`,"Z"].join(" ");return[`M ${W.plus(F).toFixed(6)} ${z.toFixed(6)}`,`L ${W.plus(j).minus(F).toFixed(6)} ${z.toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(j).toFixed(6)} ${z.plus(_).toFixed(6)}`,`L ${W.plus(j).toFixed(6)} ${z.plus(G).minus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(j).minus(F).toFixed(6)} ${z.plus(G).toFixed(6)}`,`L ${W.plus(F).toFixed(6)} ${z.plus(G).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.toFixed(6)} ${z.plus(G).minus(_).toFixed(6)}`,`L ${W.toFixed(6)} ${z.plus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(F).toFixed(6)} ${z.toFixed(6)}`].join(" ")}function T8($,J,Z,K){let Q=(j)=>new O(j),q=Q($),H=Q(J),W=Q(Z),z=Q(K);if(!q.isFinite()||!H.isFinite()||!W.isFinite()||!z.isFinite())throw new Error("lineToPath: all parameters must be finite");return`M ${q.toFixed(6)} ${H.toFixed(6)} L ${W.toFixed(6)} ${z.toFixed(6)}`}function b8($){let J=S8($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z+" Z"}function f8($){let J=S8($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z}function S8($){if(!$)return[];let J;try{if(Array.isArray($))J=$.flat().map((K)=>new O(K).toFixed(6));else if(typeof $==="string")J=$.trim().split(/[\s,]+/).filter((K)=>K.length>0).map((K)=>new O(K).toFixed(6));else return console.warn("parsePointPairs: invalid input type"),[]}catch(K){return console.warn(`parsePointPairs: parse error - ${K.message}`),[]}if(J.length%2!==0)console.warn("parsePointPairs: odd number of coordinates, ignoring last value"),J=J.slice(0,-1);let Z=[];for(let K=0;K+1<J.length;K+=2)Z.push([J[K],J[K+1]]);return Z}function Cq($,J,Z,K,Q,q,H,W){let z=(Q0)=>new O(Q0),j=z("1e-16");if(!W||!W.data||!Array.isArray(W.data)||W.data.length<3)throw new Error("transformArc: invalid matrix");let G=z($),F=z(J);if(G.lte(0)||F.lte(0))return console.warn("transformArc: radii must be positive, returning degenerate arc"),{rx:0,ry:0,xAxisRotation:0,largeArcFlag:K,sweepFlag:Q,x:z(q).toNumber(),y:z(H).toNumber()};let _=K;if(typeof _!=="number"||_!==0&&_!==1)console.warn(`transformArc: largeArcFlag must be 0 or 1, got ${K}`),_=_?1:0;let U=Q;if(typeof U!=="number"||U!==0&&U!==1)console.warn(`transformArc: sweepFlag must be 0 or 1, got ${Q}`),U=U?1:0;let M=W.data[0][0],V=W.data[1][0],Y=W.data[0][1],X=W.data[1][1],k=W.data[0][2],w=W.data[1][2],R=z(q),I=z(H),P=M.mul(R).plus(Y.mul(I)).plus(k),u=V.mul(R).plus(X.mul(I)).plus(w),g=z(Z).mul(z(Math.PI)).div(180),b=O.sin(g),h=O.cos(g),v=M.mul(G).mul(h).plus(Y.mul(G).mul(b)),E=V.mul(G).mul(h).plus(X.mul(G).mul(b)),m=M.mul(F.neg()).mul(b).plus(Y.mul(F).mul(h)),c=V.mul(F.neg()).mul(b).plus(X.mul(F).mul(h)),d=v.mul(v).plus(m.mul(m)),N=E.mul(E).plus(c.mul(c)),y=v.mul(E).plus(m.mul(c)).mul(2),B=d.minus(N),t,i,l;if(y.abs().lt(j))t=z(0),i=d,l=N;else if(B.abs().lt(j))i=d.plus(y.mul("0.5")),l=d.minus(y.mul("0.5")),t=z(Math.PI).div(4);else{let Q0=z(1).plus(y.mul(y).div(B.mul(B))).sqrt();i=d.plus(N).plus(Q0.mul(B)).div(2),l=d.plus(N).minus(Q0.mul(B)).div(2),t=O.atan(y.div(B)).div(2)}if(i.lt(0))i=z(0);if(l.lt(0))l=z(0);let q0=i.sqrt(),f=l.sqrt();if(B.lte(0)){let Q0=q0;q0=f,f=Q0}if(f.gt(q0)){let Q0=q0;q0=f,f=Q0,t=t.plus(z(Math.PI).div(2))}let A=M.mul(X).minus(V.mul(Y)),e=U;if(A.lt(0))e=U?0:1;let $0=t.mul(180).div(z(Math.PI));while($0.lt(0))$0=$0.plus(180);while($0.gte(180))$0=$0.minus(180);return{rx:q0.toNumber(),ry:f.toNumber(),xAxisRotation:$0.toNumber(),largeArcFlag:_,sweepFlag:e,x:P.toNumber(),y:u.toNumber()}}function Pq($,J){if(!$||typeof $!=="string")return console.warn("parseTransformFunction: invalid function name"),W0.identity(3);if(!J||!Array.isArray(J))return console.warn("parseTransformFunction: invalid arguments array"),W0.identity(3);let Z=(K)=>new O(K);switch($.toLowerCase()){case"translate":{let K=J[0]!==void 0?J[0]:0,Q=J[1]!==void 0?J[1]:0;return r0(K,Q)}case"scale":{let K=J[0]!==void 0?J[0]:1,Q=J[1]!==void 0?J[1]:K;return w7(K,Q)}case"rotate":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180);if(J.length>=3){if(J[1]===void 0||J[2]===void 0||!isFinite(J[1])||!isFinite(J[2]))return console.warn("parseTransformFunction: rotate(angle, cx, cy) has invalid cx or cy, using origin rotation"),j$(Q);let q=J[1],H=J[2];return U9(Q,q,H)}return j$(Q)}case"skewx":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),q=O.tan(Q);return k6(q,0)}case"skewy":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),q=O.tan(Q);return k6(0,q)}case"matrix":{if(J.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${J.length}`),W0.identity(3);let[K,Q,q,H,W,z]=J.slice(0,6).map((j)=>Z(j!==void 0?j:0));return W0.from([[K,q,W],[Q,H,z],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),W0.identity(3)}}function V7($){if(!$||$.trim()==="")return W0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,K=W0.identity(3);while((Z=J.exec($))!==null){let Q=Z[1],H=Z[2].split(/[\s,]+/).filter((z)=>z.length>0).map((z)=>{let j=parseFloat(z);if(isNaN(j))return console.warn(`parseTransformAttribute: invalid numeric argument "${z}" in ${Q}(), using 0`),0;return j}),W=Pq(Q,H);K=K.mul(W)}return K}function R7($,J,Z){if(!$||!$.data||!Array.isArray($.data))throw new Error("applyToPoint: invalid CTM matrix");let K=(H)=>new O(H);try{let H=K(J),W=K(Z);if(!H.isFinite()||!W.isFinite())throw new Error("applyToPoint: coordinates must be finite")}catch(H){throw new Error(`applyToPoint: invalid coordinates - ${H.message}`)}let[Q,q]=c0($,J,Z);return{x:Q,y:q}}function v8($,J=6){if(!$||!$.data||!Array.isArray($.data)||$.data.length<3||!Array.isArray($.data[0])||!Array.isArray($.data[1])||$.data[0].length<3||$.data[1].length<3)throw new Error("toSVGMatrix: invalid CTM matrix structure");let Z=J;if(typeof Z!=="number"||Z<0||Z>20)console.warn("toSVGMatrix: invalid precision, using default 6"),Z=6;try{let K=$.data[0][0].toFixed(Z),Q=$.data[1][0].toFixed(Z),q=$.data[0][1].toFixed(Z),H=$.data[1][1].toFixed(Z),W=$.data[0][2].toFixed(Z),z=$.data[1][2].toFixed(Z);return`matrix(${K}, ${Q}, ${q}, ${H}, ${W}, ${z})`}catch(K){throw new Error(`toSVGMatrix: invalid matrix elements - ${K.message}`)}}function C$($,J,Z={}){if(!$||typeof $!=="string")return console.warn("transformPathData: invalid pathData (must be string)"),"";if(!J||!J.data)return console.warn("transformPathData: invalid CTM matrix"),$;let{toAbsolute:K=!0,precision:Q=6}=Z,q=Q;if(typeof q!=="number"||q<0||q>20||!isFinite(q))console.warn("transformPathData: invalid precision, using default 6"),q=6;let H=(U)=>new O(U),W=Aq($);if(W.length===0)return"";let z=[],j=H(0),G=H(0),F=H(0),_=H(0);for(let{cmd:U,args:M}of W){let V=U===U.toLowerCase();switch(U.toUpperCase()){case"M":{let X=[];if(M.length%2!==0)console.warn(`transformPathData: M command has ${M.length} args, expected multiple of 2`);for(let k=0;k+1<M.length;k+=2){let w=H(M[k]),R=H(M[k+1]);if(V)w=w.plus(j),R=R.plus(G);let I=R7(J,w,R);if(X.push(I.x.toFixed(q),I.y.toFixed(q)),j=w,G=R,k===0)F=w,_=R}z.push((K?"M":U)+" "+X.join(" "));break}case"L":{let X=[];if(M.length%2!==0)console.warn(`transformPathData: L command has ${M.length} args, expected multiple of 2`);for(let k=0;k+1<M.length;k+=2){let w=H(M[k]),R=H(M[k+1]);if(V)w=w.plus(j),R=R.plus(G);let I=R7(J,w,R);X.push(I.x.toFixed(q),I.y.toFixed(q)),j=w,G=R}z.push((K?"L":U)+" "+X.join(" "));break}case"H":{if(M.length<1){console.warn("transformPathData: H command requires at least 1 argument");break}for(let X=0;X<M.length;X++){let k=H(M[X]);if(V)k=k.plus(j);let R=R7(J,k,G);z.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),j=k}break}case"V":{if(M.length<1){console.warn("transformPathData: V command requires at least 1 argument");break}for(let X=0;X<M.length;X++){let k=j,w=H(M[X]);if(V)w=w.plus(G);let R=R7(J,k,w);z.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),G=w}break}case"C":{let X=[];if(M.length%6!==0)console.warn(`transformPathData: C command has ${M.length} args, expected multiple of 6`);for(let k=0;k+5<M.length;k+=6){let w=H(M[k]),R=H(M[k+1]),I=H(M[k+2]),P=H(M[k+3]),u=H(M[k+4]),g=H(M[k+5]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G),u=u.plus(j),g=g.plus(G);let b=R7(J,w,R),h=R7(J,I,P),v=R7(J,u,g);X.push(b.x.toFixed(q),b.y.toFixed(q),h.x.toFixed(q),h.y.toFixed(q),v.x.toFixed(q),v.y.toFixed(q)),j=u,G=g}z.push((K?"C":U)+" "+X.join(" "));break}case"S":{let X=[];if(M.length%4!==0)console.warn(`transformPathData: S command has ${M.length} args, expected multiple of 4`);for(let k=0;k+3<M.length;k+=4){let w=H(M[k]),R=H(M[k+1]),I=H(M[k+2]),P=H(M[k+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G);let u=R7(J,w,R),g=R7(J,I,P);X.push(u.x.toFixed(q),u.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),j=I,G=P}z.push((K?"S":U)+" "+X.join(" "));break}case"Q":{let X=[];if(M.length%4!==0)console.warn(`transformPathData: Q command has ${M.length} args, expected multiple of 4`);for(let k=0;k+3<M.length;k+=4){let w=H(M[k]),R=H(M[k+1]),I=H(M[k+2]),P=H(M[k+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G);let u=R7(J,w,R),g=R7(J,I,P);X.push(u.x.toFixed(q),u.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),j=I,G=P}z.push((K?"Q":U)+" "+X.join(" "));break}case"T":{let X=[];if(M.length%2!==0)console.warn(`transformPathData: T command has ${M.length} args, expected multiple of 2`);for(let k=0;k+1<M.length;k+=2){let w=H(M[k]),R=H(M[k+1]);if(V)w=w.plus(j),R=R.plus(G);let I=R7(J,w,R);X.push(I.x.toFixed(q),I.y.toFixed(q)),j=w,G=R}z.push((K?"T":U)+" "+X.join(" "));break}case"A":{let X=[];if(M.length%7!==0)console.warn(`transformPathData: Arc command has ${M.length} args, expected multiple of 7`);for(let k=0;k+6<M.length;k+=7){let w=M[k],R=M[k+1],I=M[k+2],P=M[k+3],u=M[k+4],g=H(M[k+5]),b=H(M[k+6]);if(V)g=g.plus(j),b=b.plus(G);let h=Cq(w,R,I,P,u,g.toNumber(),b.toNumber(),J);X.push(h.rx.toFixed(q),h.ry.toFixed(q),h.xAxisRotation.toFixed(q),h.largeArcFlag,h.sweepFlag,h.x.toFixed(q),h.y.toFixed(q)),j=g,G=b}z.push((K?"A":U)+" "+X.join(" "));break}case"Z":{z.push("Z"),j=F,G=_;break}default:z.push(U+" "+M.join(" "))}}return z.join(" ")}function Aq($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],q=K[2].trim(),H=q.length>0?q.split(/[\s,]+/).filter((W)=>W.length>0).map((W)=>{let z=parseFloat(W);if(isNaN(z))return console.warn(`parsePathCommands: invalid number '${W}'`),0;return z}):[];J.push({cmd:Q,args:H})}return J}var A7={};x7(A7,{sign:()=>L9,segmentIntersection:()=>S6,reversePolygon:()=>I9,polygonUnion:()=>_$,polygonIntersection:()=>v7,polygonDifference:()=>m8,polygonArea:()=>l$,pointsEqual:()=>d7,pointOnSegment:()=>R9,pointInPolygon:()=>P7,point:()=>b0,lineSegmentIntersection:()=>g8,isCounterClockwise:()=>N9,isConvex:()=>P9,ensureCCW:()=>v6,dot:()=>u8,default:()=>Sq,cross:()=>p7,convexHull:()=>C9,clipPolygonSH:()=>B9,boundingBox:()=>c7,bboxIntersects:()=>s$});O.set({precision:80});var B7=($)=>$ instanceof O?$:new O($),O7=new O("1e-40");function b0($,J){if($===null||$===void 0)throw new Error("point: x coordinate is required");if(J===null||J===void 0)throw new Error("point: y coordinate is required");return{x:B7($),y:B7(J)}}function d7($,J,Z=O7){if(!$||typeof $!=="object"||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointsEqual: p1 must be a point with x and y properties");if(!J||typeof J!=="object"||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointsEqual: p2 must be a point with x and y properties");if(!Z||typeof Z.abs!=="function")throw new Error("pointsEqual: tolerance must be a Decimal instance");return $.x.minus(J.x).abs().lt(Z)&&$.y.minus(J.y).abs().lt(Z)}function p7($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("cross: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("cross: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("cross: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),q=Z.x.minus($.x),H=Z.y.minus($.y);return K.mul(H).minus(Q.mul(q))}function u8($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("dot: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("dot: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("dot: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),q=Z.x.minus($.x),H=Z.y.minus($.y);return K.mul(q).plus(Q.mul(H))}function L9($){if($===null||$===void 0||typeof $.abs!=="function")throw new Error("sign: val must be a Decimal instance");if($.abs().lt(O7))return 0;return $.lt(0)?-1:1}function S6($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("segmentIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("segmentIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("segmentIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("segmentIntersection: point d must have x and y properties");let Q=J.x.minus($.x),q=J.y.minus($.y),H=K.x.minus(Z.x),W=K.y.minus(Z.y),z=Q.mul(W).minus(q.mul(H));if(z.abs().lt(O7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(W).minus(G.mul(H)).div(z),_=j.mul(q).minus(G.mul(Q)).div(z),U=B7(0),M=B7(1);if(F.gte(U)&&F.lte(M)&&_.gte(U)&&_.lte(M))return{x:$.x.plus(Q.mul(F)),y:$.y.plus(q.mul(F)),t:F,s:_};return null}function g8($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineSegmentIntersection: lineA must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineSegmentIntersection: lineB must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineSegmentIntersection: segA must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineSegmentIntersection: segB must have x and y properties");let Q=J.x.minus($.x),q=J.y.minus($.y),H=K.x.minus(Z.x),W=K.y.minus(Z.y),z=Q.mul(W).minus(q.mul(H));if(z.abs().lt(O7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(q).minus(G.mul(Q)).div(z);if(F.gte(0)&&F.lte(1))return{x:Z.x.plus(H.mul(F)),y:Z.y.plus(W.mul(F)),s:F};return null}function P7($,J){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointInPolygon: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygon: polygon must be an array");let Z=J.length;if(Z<3)return-1;for(let Q=0;Q<Z;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`pointInPolygon: polygon[${Q}] must have x and y properties`);let K=0;for(let Q=0;Q<Z;Q++){let q=J[Q],H=J[(Q+1)%Z];if(R9($,q,H))return 0;if(q.y.lte($.y)){if(H.y.gt($.y)){if(p7(q,H,$).gt(0))K++}}else if(H.y.lte($.y)){if(p7(q,H,$).lt(0))K--}}return K!==0?1:-1}function R9($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointOnSegment: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointOnSegment: segment point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("pointOnSegment: segment point b must have x and y properties");if(p7(J,Z,$).abs().gt(O7))return!1;let Q=O.min(J.x,Z.x),q=O.max(J.x,Z.x),H=O.min(J.y,Z.y),W=O.max(J.y,Z.y);return $.x.gte(Q.minus(O7))&&$.x.lte(q.plus(O7))&&$.y.gte(H.minus(O7))&&$.y.lte(W.plus(O7))}function B9($,J){if(!Array.isArray($))throw new Error("clipPolygonSH: subject must be an array");if(!Array.isArray(J))throw new Error("clipPolygonSH: clip must be an array");if($.length<3||J.length<3)return[];for(let Q=0;Q<$.length;Q++)if(!$[Q]||$[Q].x===null||$[Q].x===void 0||$[Q].y===null||$[Q].y===void 0)throw new Error(`clipPolygonSH: subject[${Q}] must have x and y properties`);for(let Q=0;Q<J.length;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`clipPolygonSH: clip[${Q}] must have x and y properties`);let Z=$.map((Q)=>b0(Q.x,Q.y)),K=J.map((Q)=>b0(Q.x,Q.y));K=v6(K);for(let Q=0;Q<K.length;Q++){if(Z.length===0)return[];let q=K[Q],H=K[(Q+1)%K.length],W=Z;Z=[];for(let z=0;z<W.length;z++){let j=W[z],G=W[(z+W.length-1)%W.length],F=h8(j,q,H),_=h8(G,q,H);if(F){if(!_){let U=y8(G,j,q,H);if(U)Z.push(U)}Z.push(j)}else if(_){let U=y8(G,j,q,H);if(U)Z.push(U)}}}return Z}function h8($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("isInsideEdge: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("isInsideEdge: edgeStart must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("isInsideEdge: edgeEnd must have x and y properties");return p7(J,Z,$).gte(0)}function y8($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineIntersection: point d must have x and y properties");let Q=J.x.minus($.x),q=J.y.minus($.y),H=K.x.minus(Z.x),W=K.y.minus(Z.y),z=Q.mul(W).minus(q.mul(H));if(z.abs().lt(O7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(W).minus(G.mul(H)).div(z);return{x:$.x.plus(Q.mul(F)),y:$.y.plus(q.mul(F))}}function l$($){if(!Array.isArray($))throw new Error("polygonArea: polygon must be an array");let J=$.length;if(J<3)return B7(0);for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`polygonArea: polygon[${K}] must have x and y properties`);let Z=B7(0);for(let K=0;K<J;K++){let Q=$[K],q=$[(K+1)%J];Z=Z.plus(Q.x.mul(q.y).minus(q.x.mul(Q.y)))}return Z.div(2)}function N9($){if(!Array.isArray($))throw new Error("isCounterClockwise: polygon must be an array");return l$($).gt(0)}function I9($){if(!Array.isArray($))throw new Error("reversePolygon: polygon must be an array");return[...$].reverse()}function v6($){if(!Array.isArray($))throw new Error("ensureCCW: polygon must be an array");if(!N9($))return I9($);return $}function C9($){if(!Array.isArray($))throw new Error("convexHull: points must be an array");if($.length<3){for(let H=0;H<$.length;H++)if(!$[H]||$[H].x===null||$[H].x===void 0||$[H].y===null||$[H].y===void 0)throw new Error(`convexHull: points[${H}] must have x and y properties`);return $.map((H)=>b0(H.x,H.y))}for(let H=0;H<$.length;H++)if(!$[H]||$[H].x===null||$[H].x===void 0||$[H].y===null||$[H].y===void 0)throw new Error(`convexHull: points[${H}] must have x and y properties`);let J=$.map((H)=>b0(H.x,H.y)),Z=0;for(let H=1;H<J.length;H++)if(J[H].y.lt(J[Z].y)||J[H].y.eq(J[Z].y)&&J[H].x.lt(J[Z].x))Z=H;[J[0],J[Z]]=[J[Z],J[0]];let K=J[0],Q=J.slice(1).sort((H,W)=>{let z=p7(K,H,W);if(z.abs().lt(O7)){let G=H.x.minus(K.x).pow(2).plus(H.y.minus(K.y).pow(2)),F=W.x.minus(K.x).pow(2).plus(W.y.minus(K.y).pow(2)),_=G.minus(F);if(_.abs().lt(O7))return 0;return _.lt(0)?-1:1}return-L9(z)}),q=[K];for(let H of Q){while(q.length>1&&p7(q[q.length-2],q[q.length-1],H).lte(0))q.pop();q.push(H)}return q}function c7($){if(!Array.isArray($))throw new Error("boundingBox: polygon must be an array");if($.length===0)return null;if(!$[0]||$[0].x===null||$[0].x===void 0||$[0].y===null||$[0].y===void 0)throw new Error("boundingBox: polygon[0] must have x and y properties");let J=B7($[0].x),Z=B7($[0].y),K=B7($[0].x),Q=B7($[0].y);for(let q=0;q<$.length;q++){let H=$[q];if(!H||H.x===null||H.x===void 0||H.y===null||H.y===void 0)throw new Error(`boundingBox: polygon[${q}] must have x and y properties`);let W=B7(H.x),z=B7(H.y);if(W.lt(J))J=W;if(z.lt(Z))Z=z;if(W.gt(K))K=W;if(z.gt(Q))Q=z}return{minX:J,minY:Z,maxX:K,maxY:Q}}function s$($,J){if(!$||!J)return!1;if($.minX===null||$.minX===void 0||$.minY===null||$.minY===void 0||$.maxX===null||$.maxX===void 0||$.maxY===null||$.maxY===void 0)throw new Error("bboxIntersects: bb1 must have minX, minY, maxX, maxY properties");if(J.minX===null||J.minX===void 0||J.minY===null||J.minY===void 0||J.maxX===null||J.maxX===void 0||J.maxY===null||J.maxY===void 0)throw new Error("bboxIntersects: bb2 must have minX, minY, maxX, maxY properties");return!($.maxX.lt(J.minX)||J.maxX.lt($.minX)||$.maxY.lt(J.minY)||J.maxY.lt($.minY))}function v7($,J){if(!Array.isArray($))throw new Error("polygonIntersection: subject must be an array");if(!Array.isArray(J))throw new Error("polygonIntersection: clip must be an array");for(let H=0;H<$.length;H++)if(!$[H]||$[H].x===null||$[H].x===void 0||$[H].y===null||$[H].y===void 0)throw new Error(`polygonIntersection: subject[${H}] must have x and y properties`);for(let H=0;H<J.length;H++)if(!J[H]||J[H].x===null||J[H].x===void 0||J[H].y===null||J[H].y===void 0)throw new Error(`polygonIntersection: clip[${H}] must have x and y properties`);let Z=$.map((H)=>b0(H.x,H.y)),K=J.map((H)=>b0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!s$(Q,q))return[];if(P9(K)){let H=B9(Z,v6(K));return H.length>=3?[H]:[]}return Eq(Z,K)}function P9($){if(!Array.isArray($))throw new Error("isConvex: polygon must be an array");let J=$.length;if(J<3)return!1;for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`isConvex: polygon[${K}] must have x and y properties`);let Z=0;for(let K=0;K<J;K++){let Q=$[K],q=$[(K+1)%J],H=$[(K+2)%J],W=p7(Q,q,H),z=W.gt(0)?1:W.lt(0)?-1:0;if(z!==0){if(Z===0)Z=z;else if(Z!==z)return!1}}return!0}function Eq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("generalPolygonIntersection: both arguments must be arrays");let Z=[];for(let z=0;z<$.length;z++){let j=$[z],G=$[(z+1)%$.length];for(let F=0;F<J.length;F++){let _=J[F],U=J[(F+1)%J.length],M=S6(j,G,_,U);if(M)Z.push(b0(M.x,M.y))}}let K=$.filter((z)=>P7(z,J)>=0),Q=J.filter((z)=>P7(z,$)>=0),q=[...Z,...K,...Q];if(q.length<3)return[];let H=Tq(q);if(H.length<3)return[];let W=C9(H);return W.length>=3?[W]:[]}function Tq($){if(!Array.isArray($))throw new Error("removeDuplicatePoints: points must be an array");let J=[];for(let Z of $){let K=!1;for(let Q of J)if(d7(Z,Q)){K=!0;break}if(!K)J.push(Z)}return J}function _$($,J){if(!Array.isArray($))throw new Error("polygonUnion: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonUnion: polygon2 must be an array");for(let H=0;H<$.length;H++)if(!$[H]||$[H].x===null||$[H].x===void 0||$[H].y===null||$[H].y===void 0)throw new Error(`polygonUnion: polygon1[${H}] must have x and y properties`);for(let H=0;H<J.length;H++)if(!J[H]||J[H].x===null||J[H].x===void 0||J[H].y===null||J[H].y===void 0)throw new Error(`polygonUnion: polygon2[${H}] must have x and y properties`);let Z=$.map((H)=>b0(H.x,H.y)),K=J.map((H)=>b0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!s$(Q,q))return[Z,K];return bq(Z,K)}function bq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryUnion: both arguments must be arrays");let Z=x8($,J);if(Z.length===0){let V=P7($[0],J),Y=P7(J[0],$);if(V>0)return[J];else if(Y>0)return[$];else return[$,J]}let K=f6($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),Q=f6(J,Z.map((V)=>({edgeIndex:V.edge2,t:V.t2,point:V.point,intersectionId:V.id}))),q=new Map;for(let V=0;V<K.length;V++)if(K[V].intersectionId!==void 0){if(!q.has(K[V].intersectionId))q.set(K[V].intersectionId,{});q.get(K[V].intersectionId).idx1=V}for(let V=0;V<Q.length;V++)if(Q[V].intersectionId!==void 0){if(!q.has(Q[V].intersectionId))q.set(Q[V].intersectionId,{});q.get(Q[V].intersectionId).idx2=V}let H=1,W=-1;for(let V=0;V<K.length;V++){let Y=K[V];if(Y.intersectionId===void 0&&P7(Y,J)<0){W=V;break}}if(W===-1){H=2;for(let V=0;V<Q.length;V++){let Y=Q[V];if(Y.intersectionId===void 0&&P7(Y,$)<0){W=V;break}}}if(W===-1){let V=l$($).abs(),Y=l$(J).abs();return V.gt(Y)?[$]:[J]}let z=[],j=H===1,G=W,F=new Set,_=(K.length+Q.length)*3,U=0,M=`${H}-${W}`;while(U<_){U++;let V=j?K:Q,Y=j?Q:K,X=V[G];if(z.length===0||!d7(z[z.length-1],X))z.push(b0(X.x,X.y));let k=(G+1)%V.length,w=V[k];if(w.intersectionId!==void 0&&!F.has(w.intersectionId)){z.push(b0(w.x,w.y)),F.add(w.intersectionId);let I=q.get(w.intersectionId),P=j?I.idx2:I.idx1;j=!j,G=(P+1)%Y.length}else G=k;if(`${j?1:2}-${G}`===M)break}if(z.length>1&&d7(z[0],z[z.length-1]))z.pop();return z.length>=3?[z]:[]}function x8($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("findAllIntersections: both arguments must be arrays");let Z=[],K=0;for(let Q=0;Q<$.length;Q++){let q=$[Q],H=$[(Q+1)%$.length];for(let W=0;W<J.length;W++){let z=J[W],j=J[(W+1)%J.length],G=S6(q,H,z,j);if(G)Z.push({id:K++,point:b0(G.x,G.y),edge1:Q,edge2:W,t1:G.t,t2:G.s})}}return Z}function f6($,J){if(!Array.isArray($))throw new Error("augmentPolygon: polygon must be an array");if(!Array.isArray(J))throw new Error("augmentPolygon: insertions must be an array");let Z=new Map;for(let Q of J){if(!Z.has(Q.edgeIndex))Z.set(Q.edgeIndex,[]);Z.get(Q.edgeIndex).push(Q)}for(let Q of Z.values())Q.sort((q,H)=>q.t.minus(H.t).toNumber());let K=[];for(let Q=0;Q<$.length;Q++)if(K.push({...$[Q]}),Z.has(Q))for(let q of Z.get(Q))K.push({x:q.point.x,y:q.point.y,intersectionId:q.intersectionId});return K}function m8($,J){if(!Array.isArray($))throw new Error("polygonDifference: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonDifference: polygon2 must be an array");for(let H=0;H<$.length;H++)if(!$[H]||$[H].x===null||$[H].x===void 0||$[H].y===null||$[H].y===void 0)throw new Error(`polygonDifference: polygon1[${H}] must have x and y properties`);for(let H=0;H<J.length;H++)if(!J[H]||J[H].x===null||J[H].x===void 0||J[H].y===null||J[H].y===void 0)throw new Error(`polygonDifference: polygon2[${H}] must have x and y properties`);let Z=$.map((H)=>b0(H.x,H.y)),K=J.map((H)=>b0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!s$(Q,q))return[Z];return fq(Z,K)}function fq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryDifference: both arguments must be arrays");let Z=x8($,J);if(Z.length===0)if(P7($[0],J)>0)return[];else return[$];let K=f6($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),Q=f6(J,Z.map((U)=>({edgeIndex:U.edge2,t:U.t2,point:U.point,intersectionId:U.id}))),q=new Map;for(let U=0;U<K.length;U++)if(K[U].intersectionId!==void 0){if(!q.has(K[U].intersectionId))q.set(K[U].intersectionId,{});q.get(K[U].intersectionId).idx1=U}for(let U=0;U<Q.length;U++)if(Q[U].intersectionId!==void 0){if(!q.has(Q[U].intersectionId))q.set(Q[U].intersectionId,{});q.get(Q[U].intersectionId).idx2=U}let H=-1;for(let U=0;U<K.length;U++){let M=K[U];if(M.intersectionId===void 0&&P7(M,J)<0){H=U;break}}if(H===-1)return[];let W=[],z=!0,j=H,G=new Set,F=(K.length+Q.length)*3,_=0;while(_<F){_++;let M=(z?K:Q)[j];if(W.length===0||!d7(W[W.length-1],M))W.push(b0(M.x,M.y));let V=`${z?1:2}-${j}`;if(G.has(V))break;if(G.add(V),z){let Y=(j+1)%K.length,X=K[Y];if(X.intersectionId!==void 0){let k=K[(Y+1)%K.length];if(P7(k,J)>0){let R=q.get(X.intersectionId);W.push(b0(X.x,X.y)),z=!1,j=(R.idx2-1+Q.length)%Q.length}else j=Y}else j=Y}else{let Y=(j-1+Q.length)%Q.length,X=Q[Y];if(X.intersectionId!==void 0){let k=q.get(X.intersectionId);W.push(b0(X.x,X.y)),z=!0,j=(k.idx1+1)%K.length}else j=Y}if(z&&j===H)break}if(W.length>1&&d7(W[0],W[W.length-1]))W.pop();return W.length>=3?[W]:[]}var Sq={point:b0,pointsEqual:d7,cross:p7,dot:u8,sign:L9,segmentIntersection:S6,lineSegmentIntersection:g8,pointInPolygon:P7,pointOnSegment:R9,clipPolygonSH:B9,polygonArea:l$,isCounterClockwise:N9,reversePolygon:I9,ensureCCW:v6,isConvex:P9,convexHull:C9,boundingBox:c7,bboxIntersects:s$,polygonIntersection:v7,polygonUnion:_$,polygonDifference:m8,EPSILON:O7};O.set({precision:80});var D6=($)=>$ instanceof O?$:new O($),n7=new O("1e-40"),{point:Z$,pointsEqual:j4,cross:A9,polygonArea:G4,polygonIntersection:F4,polygonUnion:_4,polygonDifference:U4,isCounterClockwise:V4,ensureCCW:O4,segmentIntersection:Y4}=A7,K$={NONZERO:"nonzero",EVENODD:"evenodd"};function h6($,J,Z=K$.NONZERO){if(!$||typeof $!=="object")throw new Error("pointInPolygonWithRule: pt must be an object with x, y properties");if($.x===void 0||$.x===null||$.y===void 0||$.y===null)throw new Error("pointInPolygonWithRule: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygonWithRule: polygon must be an array");let K=J.length;if(K<3)return-1;let Q=0;for(let q=0;q<K;q++){let H=J[q],W=J[(q+1)%K];if(vq($,H,W))return 0;if(H.y.lte($.y)){if(W.y.gt($.y)){if(A9(H,W,$).gt(0))Q++}}else if(W.y.lte($.y)){if(A9(H,W,$).lt(0))Q--}}if(Z===K$.EVENODD)return Math.abs(Q)%2===1?1:-1;else return Q!==0?1:-1}function vq($,J,Z){if(!$||!J||!Z)throw new Error("pointOnSegment: pt, a, and b must be defined");if($.x===void 0||$.x===null||$.y===void 0||$.y===null||J.x===void 0||J.x===null||J.y===void 0||J.y===null||Z.x===void 0||Z.x===null||Z.y===void 0||Z.y===null)throw new Error("pointOnSegment: all points must have x and y properties");if(A9(J,Z,$).abs().gt(n7))return!1;let Q=O.min(J.x,Z.x),q=O.max(J.x,Z.x),H=O.min(J.y,Z.y),W=O.max(J.y,Z.y);return $.x.gte(Q.minus(n7))&&$.x.lte(q.plus(n7))&&$.y.gte(H.minus(n7))&&$.y.lte(W.plus(n7))}function d8($,J,Z={}){if(!Array.isArray($))throw new Error("offsetPolygon: polygon must be an array");if(J===void 0||J===null)throw new Error("offsetPolygon: distance must be defined");if(!Z||typeof Z!=="object")throw new Error("offsetPolygon: options must be an object");let K=D6(J);if(K.lte(0))throw new Error("offsetPolygon: distance must be positive");let Q=Z.linejoin||"miter",q=D6(Z.miterLimit||4);if($.length<3)return{outer:[],inner:[]};let H=$.length,W=[],z=[];for(let j=0;j<H;j++){let G=$[(j-1+H)%H],F=$[j],_=$[(j+1)%H],U=F.x.minus(G.x),M=F.y.minus(G.y),V=_.x.minus(F.x),Y=_.y.minus(F.y),X=U.pow(2).plus(M.pow(2)).sqrt(),k=V.pow(2).plus(Y.pow(2)).sqrt();if(X.lt(n7)||k.lt(n7))continue;let w=M.div(X),R=U.neg().div(X),I=Y.div(k),P=V.neg().div(k),u=w.plus(I).div(2),g=R.plus(P).div(2),b=u.pow(2).plus(g.pow(2)).sqrt();if(b.lt(n7))u=w,g=R;else u=u.div(b),g=g.div(b);let h=w.times(I).plus(R.times(P)),v=D6(1).minus(h).div(2).sqrt(),E=K;if(v.gt(n7)){let m=K.div(v);if(Q==="miter"&&m.lte(K.times(q)))E=m;else if(Q==="bevel"||m.gt(K.times(q))){let c=Z$(F.x.plus(w.times(K)),F.y.plus(R.times(K))),d=Z$(F.x.plus(I.times(K)),F.y.plus(P.times(K)));W.push(c,d);let N=Z$(F.x.minus(w.times(K)),F.y.minus(R.times(K))),y=Z$(F.x.minus(I.times(K)),F.y.minus(P.times(K)));z.push(N,y);continue}else if(Q==="round"){let c=Math.atan2(R.toNumber(),w.toNumber()),N=Math.atan2(P.toNumber(),I.toNumber())-c;if(N<-Math.PI)N+=2*Math.PI;if(N>Math.PI)N-=2*Math.PI;let y=Math.max(2,Math.ceil(Math.abs(N)/(Math.PI/8)));for(let B=0;B<=y;B++){let t=c+N*(B/y);W.push(Z$(F.x.plus(K.times(Math.cos(t))),F.y.plus(K.times(Math.sin(t))))),z.push(Z$(F.x.minus(K.times(Math.cos(t))),F.y.minus(K.times(Math.sin(t)))))}continue}}W.push(Z$(F.x.plus(u.times(E)),F.y.plus(g.times(E)))),z.push(Z$(F.x.minus(u.times(E)),F.y.minus(g.times(E))))}return{outer:W,inner:z.reverse()}}function E9($,J){if(!Array.isArray($))throw new Error("strokeToFilledPolygon: polygon must be an array");if(!J||typeof J!=="object")throw new Error("strokeToFilledPolygon: strokeProps must be an object");if(J.width===void 0||J.width===null)throw new Error("strokeToFilledPolygon: strokeProps must have width property");let Z=D6(J.width).div(2);if(Z.lte(0))throw new Error("strokeToFilledPolygon: width must be positive");return d8($,Z,J).outer}O.set({precision:80});var D7=($)=>$ instanceof O?$:new O($),Dq={fill:"black","fill-rule":"nonzero","fill-opacity":1,stroke:"none","stroke-width":1,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":4,"stroke-dasharray":"none","stroke-dashoffset":0,"stroke-opacity":1,"marker-start":"none","marker-mid":"none","marker-end":"none","paint-order":"normal","clip-path":"none","clip-rule":"nonzero",mask:"none","mask-type":"luminance",opacity:1,transform:"none","vector-effect":"none",filter:"none"};class y6{constructor($,J={},Z=null){if(!$)throw new Error("SVGRenderingContext: element parameter is required");if(J!==null&&typeof J!=="object")throw new Error("SVGRenderingContext: inherited must be an object or null");this.element=$,this.defsMap=Z||new Map,this.properties=this._extractProperties($,J||{}),this.dashArray=this._parseDashArray(this.properties["stroke-dasharray"]),this.dashOffset=D7(this.properties["stroke-dashoffset"]||0),this.markers={start:this._parseMarkerRef(this.properties["marker-start"]),mid:this._parseMarkerRef(this.properties["marker-mid"]),end:this._parseMarkerRef(this.properties["marker-end"])},this.hasFill=this.properties.fill!=="none"&&this.properties["fill-opacity"]>0,this.hasStroke=this.properties.stroke!=="none"&&D7(this.properties["stroke-width"]).gt(0)&&this.properties["stroke-opacity"]>0,this.hasMarkers=this.markers.start||this.markers.mid||this.markers.end}_extractProperties($,J){if(J!==null&&typeof J!=="object")throw new Error("_extractProperties: inherited must be an object or null");let Z={...Dq,...J||{}};if($&&$.getAttributeNames)for(let Q of $.getAttributeNames()){let q=$.getAttribute(Q);if(q!==null&&q!==void 0)Z[Q]=q}if(Z.style){let Q=this._parseStyleAttribute(Z.style);Object.assign(Z,Q)}let K=["stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity"];for(let Q of K)if(typeof Z[Q]==="string"){let q=parseFloat(Z[Q]);if(!isNaN(q))Z[Q]=q}return Z}_parseStyleAttribute($){let J={};if(!$)return J;let Z=$.split(";");for(let K of Z){if(!K.includes(":"))continue;let[Q,q]=K.split(":").map((H)=>H.trim());if(Q&&q)J[Q]=q}return J}_parseDashArray($){if(!$||$==="none")return null;let J=$.toString().split(/[\s,]+/).filter((K)=>K),Z=[];for(let K of J){let Q=parseFloat(K);if(isNaN(Q)||!isFinite(Q))throw new Error(`_parseDashArray: invalid dash value '${K}'`);if(Q<0)throw new Error(`_parseDashArray: dash values must be non-negative, got ${Q}`);Z.push(D7(Q))}if(Z.length===0)return null;if(Z.length%2===1)return[...Z,...Z];return Z}_parseMarkerRef($){if(!$||$==="none")return null;let J=$.match(/url\(#?([^)]+)\)/);return J?J[1]:null}get fillRule(){return this.properties["fill-rule"]||"nonzero"}get clipRule(){return this.properties["clip-rule"]||"nonzero"}get strokeWidth(){return D7(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return D7(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return D7(0);let $=this.strokeWidth.div(2),J=$;if(this.strokeLinejoin==="miter")J=$.times(this.strokeMiterlimit);if(this.strokeLinecap==="square"){let Z=$.times(2);if(Z.gt(J))J=Z}return J}expandBBoxForStroke($){if(!$||typeof $!=="object")throw new Error("expandBBoxForStroke: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForStroke: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForStroke: bbox properties must be Decimal instances");if(!this.hasStroke)return $;let J=this.getStrokeExtent();return{x:$.x.minus(J),y:$.y.minus(J),width:$.width.plus(J.times(2)),height:$.height.plus(J.times(2))}}expandBBoxForMarkers($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForMarkers: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForMarkers: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForMarkers: bbox properties must be Decimal instances");if(!this.hasMarkers)return $;let Z=D7(0);if(J){if(typeof J!=="object")throw new Error("expandBBoxForMarkers: markerSizes must be an object");let Q=[J.start,J.mid,J.end].filter((q)=>q!==null&&q!==void 0).map((q)=>{let H=typeof q==="number"?q:parseFloat(q);if(isNaN(H)||!isFinite(H))throw new Error(`expandBBoxForMarkers: invalid marker size '${q}'`);return D7(H)});if(Q.length>0)Z=O.max(...Q)}else Z=this.strokeWidth.times(3);if(Z.lte(0))return $;let K=Z.div(2);return{x:$.x.minus(K),y:$.y.minus(K),width:$.width.plus(K.times(2)),height:$.height.plus(K.times(2))}}expandBBoxForFilter($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForFilter: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForFilter: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.times!=="function"||typeof $.height.times!=="function")throw new Error("expandBBoxForFilter: bbox properties must be Decimal instances");let Z=this.properties.filter;if(!Z||Z==="none")return $;let K=$.width.times("0.1"),Q=$.height.times("0.1");if(J){if(typeof J!=="object")throw new Error("expandBBoxForFilter: filterDef must be an object");if(J.x!==void 0){let q=parseFloat(J.x);if(isNaN(q)||!isFinite(q))throw new Error(`expandBBoxForFilter: invalid filterDef.x value '${J.x}'`);K=D7(q).abs()}if(J.y!==void 0){let q=parseFloat(J.y);if(isNaN(q)||!isFinite(q))throw new Error(`expandBBoxForFilter: invalid filterDef.y value '${J.y}'`);Q=D7(q).abs()}}return{x:$.x.minus(K),y:$.y.minus(Q),width:$.width.plus(K.times(2)),height:$.height.plus(Q.times(2))}}getRenderedBBox($,J={}){if(!$||typeof $!=="object")throw new Error("getRenderedBBox: geometryBBox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getRenderedBBox: geometryBBox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function")throw new Error("getRenderedBBox: geometryBBox properties must be Decimal instances");if(J!==null&&typeof J!=="object")throw new Error("getRenderedBBox: options must be an object or null");let Z={...$};return Z=this.expandBBoxForStroke(Z),Z=this.expandBBoxForMarkers(Z,J.markerSizes),Z=this.expandBBoxForFilter(Z,J.filterDef),Z}getFilledArea($){if(!Array.isArray($))throw new Error("getFilledArea: polygon must be an array");if($.length===0)throw new Error("getFilledArea: polygon must not be empty");let J=[];if(this.hasFill)J.push({polygon:$,fillRule:this.fillRule,type:"fill"});if(this.hasStroke){let Z=E9($,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0)J.push({polygon:Z,fillRule:"nonzero",type:"stroke"})}return J}isPointInRenderedArea($,J){if(!$||typeof $!=="object")throw new Error("isPointInRenderedArea: point must be an object");if($.x===void 0||$.y===void 0)throw new Error("isPointInRenderedArea: point must have x and y properties");if(!Array.isArray(J))throw new Error("isPointInRenderedArea: polygon must be an array");if(J.length===0)throw new Error("isPointInRenderedArea: polygon must not be empty");if(this.hasFill){let Z=this.fillRule==="evenodd"?K$.EVENODD:K$.NONZERO;if(h6($,J,Z)>=0)return!0}if(this.hasStroke){let Z=E9(J,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0){if(h6($,Z,K$.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof y6))throw new Error("canMergeWith: other must be an instance of SVGRenderingContext");if(this.fillRule!==$.fillRule)return{canMerge:!1,reason:"Different fill-rule"};if(this.hasStroke||$.hasStroke){if(this.hasStroke!==$.hasStroke)return{canMerge:!1,reason:"Different stroke presence"};if(!this.strokeWidth.eq($.strokeWidth))return{canMerge:!1,reason:"Different stroke-width"};if(this.strokeLinecap!==$.strokeLinecap)return{canMerge:!1,reason:"Different stroke-linecap"};if(this.strokeLinejoin!==$.strokeLinejoin)return{canMerge:!1,reason:"Different stroke-linejoin"}}if(this.hasMarkers||$.hasMarkers)return{canMerge:!1,reason:"Has markers"};if(this.properties["clip-path"]!=="none"||$.properties["clip-path"]!=="none")return{canMerge:!1,reason:"Has clip-path"};if(this.properties.mask!=="none"||$.properties.mask!=="none")return{canMerge:!1,reason:"Has mask"};if(this.properties.filter!=="none"||$.properties.filter!=="none")return{canMerge:!1,reason:"Has filter"};return{canMerge:!0,reason:null}}toSummary(){return{hasFill:this.hasFill,hasStroke:this.hasStroke,hasMarkers:this.hasMarkers,fillRule:this.fillRule,strokeWidth:this.hasStroke?this.strokeWidth.toNumber():0,strokeExtent:this.getStrokeExtent().toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,clipPath:this.properties["clip-path"],filter:this.properties.filter}}}function o$($,J={},Z=null){if(!$)throw new Error("createRenderingContext: element parameter is required");return new y6($,J,Z)}function i$($){if(!$)throw new Error("getInheritedProperties: element parameter is required");let J={},Z=["fill","fill-rule","fill-opacity","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","stroke-opacity","marker-start","marker-mid","marker-end","clip-rule","opacity","font-family","font-size","font-style","font-weight"];if(!$.parentNode)return J;let K=$.parentNode;while(K&&K.tagName){for(let Q of Z)if(J[Q]===void 0){let q=K.getAttribute?K.getAttribute(Q):null;if(q!==null&&q!==void 0)J[Q]=q}K=K.parentNode}return J}var T9={};x7(T9,{serializeSVG:()=>K7,parseUrlReference:()=>y7,parseSVG:()=>u0,findElementsWithAttribute:()=>E7,default:()=>uq,buildDefsMap:()=>h7,SVGElement:()=>w0});O.set({precision:80});function l8($,J){if(!$||!J)throw new Error("setOwnerDocument: element and document are required");if(!$.children||!Array.isArray($.children))throw new Error("setOwnerDocument: element must have a children array");$.ownerDocument=J;for(let Z of $.children)if(Z instanceof w0)l8(Z,J)}function u0($){if(typeof $!=="string")throw new Error("parseSVG: input must be a string");if($.trim().length===0)throw new Error("parseSVG: input cannot be empty");let J=$.trim(),Z=o8(J,0);if(!Z.element)throw new Error("Failed to parse SVG: no root element found");let K=new s8(Z.element);return l8(Z.element,K),Z.element}class s8{constructor($=null){this.documentElement=$}createElement($){if(!$||typeof $!=="string")throw new Error("createElement: tagName must be a non-empty string");let J=new w0($);return J.ownerDocument=this,J}createElementNS($,J){if($!==null&&$!==void 0&&typeof $!=="string")throw new Error("createElementNS: namespace must be a string");return this.createElement(J)}}class w0{constructor($,J={},Z=[],K=""){if(!$||typeof $!=="string")throw new Error("SVGElement: tagName must be a non-empty string");if(J!==null&&typeof J!=="object")throw new Error("SVGElement: attributes must be an object");if(!Array.isArray(Z))throw new Error("SVGElement: children must be an array");if(typeof K!=="string")throw new Error("SVGElement: textContent must be a string");this.tagName=$,this.nodeName=$.toUpperCase(),this._attributes={...J},this.children=Z,this.childNodes=Z,this.textContent=K,this.parentNode=null,this.ownerDocument=null;for(let Q of Z)if(Q instanceof w0)Q.parentNode=this}getAttribute($){if(typeof $!=="string")throw new Error("getAttribute: name must be a string");return this._attributes[$]??null}setAttribute($,J){if(typeof $!=="string")throw new Error("setAttribute: name must be a string");if(J!==null&&J!==void 0)this._attributes[$]=String(J);else this._attributes[$]=""}hasAttribute($){if(typeof $!=="string")throw new Error("hasAttribute: name must be a string");return $ in this._attributes}removeAttribute($){if(typeof $!=="string")throw new Error("removeAttribute: name must be a string");delete this._attributes[$]}getAttributeNames(){return Object.keys(this._attributes)}getElementsByTagName($){if(typeof $!=="string")throw new Error("getElementsByTagName: tagName must be a string");if($.length===0)return[];let J=$.toLowerCase(),Z=[],K=(Q)=>{for(let q of Q.children)if(q instanceof w0){if(q.tagName.toLowerCase()===J||J==="*")Z.push(q);K(q)}};return K(this),Z}getElementById($){if(typeof $!=="string")throw new Error("getElementById: id must be a string");if($.length===0)return null;let J=(Z)=>{if(Z.getAttribute("id")===$)return Z;for(let K of Z.children)if(K instanceof w0){let Q=J(K);if(Q)return Q}return null};return J(this)}querySelector($){if(typeof $!=="string")throw new Error("querySelector: selector must be a string");return this.querySelectorAll($)[0]||null}querySelectorAll($){if(typeof $!=="string")throw new Error("querySelectorAll: selector must be a string");let J=[],Z=p8($),K=(Q)=>{for(let q of Q.children)if(q instanceof w0){if(c8(q,Z))J.push(q);K(q)}};return K(this),J}matches($){if(typeof $!=="string")throw new Error("matches: selector must be a string");let J=p8($);return c8(this,J)}cloneNode($=!0){if(typeof $!=="boolean")throw new Error("cloneNode: deep must be a boolean");let J=$?this.children.map((K)=>K instanceof w0?K.cloneNode(!0):K):[],Z=new w0(this.tagName,{...this._attributes},J,this.textContent);if(this.ownerDocument){let K=(Q,q)=>{Q.ownerDocument=q;for(let H of Q.children)if(H instanceof w0)K(H,q)};K(Z,this.ownerDocument)}return Z}appendChild($){if($===null||$===void 0)throw new Error("appendChild: child cannot be null or undefined");if($ instanceof w0&&$.parentNode)$.parentNode.removeChild($);if($ instanceof w0)$.parentNode=this;return this.children.push($),this.childNodes=this.children,$}removeChild($){if($===null||$===void 0)throw new Error("removeChild: child cannot be null or undefined");let J=this.children.indexOf($);if(J>=0){if(this.children.splice(J,1),this.childNodes=this.children,$ instanceof w0)$.parentNode=null}return $}insertBefore($,J){if($===null||$===void 0)throw new Error("insertBefore: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("insertBefore: refChild cannot be null or undefined");if($ instanceof w0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if($ instanceof w0)$.parentNode=this;this.children.splice(Z,0,$),this.childNodes=this.children}else this.appendChild($);return $}replaceChild($,J){if($===null||$===void 0)throw new Error("replaceChild: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("replaceChild: oldChild cannot be null or undefined");if($ instanceof w0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if(J instanceof w0)J.parentNode=null;if($ instanceof w0)$.parentNode=this;this.children[Z]=$,this.childNodes=this.children}return J}get style(){let $=this.getAttribute("style")||"",J={};if($.length===0)return J;return $.split(";").forEach((Z)=>{let K=Z.indexOf(":");if(K>0){let Q=Z.slice(0,K).trim(),q=Z.slice(K+1).trim();if(Q&&q)J[Q]=q}}),J}get firstChild(){return this.children[0]||null}get lastChild(){return this.children[this.children.length-1]||null}get nextSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return $[J+1]||null}get previousSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return J>0?$[J-1]:null}serialize($=0,J=!1){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new Error("serialize: indent must be a non-negative finite number");if(typeof J!=="boolean")throw new Error("serialize: minify must be a boolean");let Z=J?"":" ".repeat($),K=this._attributes["data-cdata-pending"]==="true",Q=Object.entries(this._attributes).filter(([j])=>j!=="data-cdata-pending").map(([j,G])=>`${j}="${hq(G)}"`).join(" "),q=Q?" "+Q:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${q}/>`;let H=J?"":`
|
|
9
|
+
`,W=this.children.map((j)=>j instanceof w0?j.serialize($+1,J):u6(j)).join(H),z="";if(this.textContent&&this.children.length>0)if(K)z=`<![CDATA[
|
|
10
10
|
${this.textContent}
|
|
11
|
-
]]>`+
|
|
11
|
+
]]>`+H+W;else z=u6(this.textContent)+H+W;else if(this.textContent)if(K)z=`<![CDATA[
|
|
12
12
|
${this.textContent}
|
|
13
|
-
]]>`;else
|
|
14
|
-
`)}}function
|
|
15
|
-
`)
|
|
13
|
+
]]>`;else z=u6(this.textContent);else z=W;if(this.children.length===0)return`${Z}<${this.tagName}${q}>${z}</${this.tagName}>`;return`${Z}<${this.tagName}${q}>${H}${z}${H}${Z}</${this.tagName}>`}get outerHTML(){return this.serialize(0)}get innerHTML(){return this.children.map(($)=>$ instanceof w0?$.serialize(0):u6($)).join(`
|
|
14
|
+
`)}}function o8($,J,Z=!1){if(typeof $!=="string")throw new Error("parseElement: str must be a string");if(typeof J!=="number"||!Number.isFinite(J)||J<0)throw new Error("parseElement: pos must be a non-negative finite number");if($.length===0)return{element:null,endPos:0};if(J>=$.length)return{element:null,endPos:J};let K=J;while(K<$.length){let M=$.slice(K).match(/^(\s+)/);if(M){K+=M[1].length;continue}if($.slice(K,K+4)==="<!--"){let V=$.indexOf("-->",K+4);if(V===-1)break;K=V+3;continue}if($.slice(K,K+9)==="<![CDATA["){let V=$.indexOf("]]>",K+9);if(V===-1)break;K=V+3;continue}if($.slice(K,K+2)==="<?"){let V=$.indexOf("?>",K+2);if(V===-1)break;K=V+2;continue}if($.slice(K,K+9).toUpperCase()==="<!DOCTYPE"){let V=0,Y=K+9;while(Y<$.length){if($[Y]==="[")V++;else if($[Y]==="]")V--;else if($[Y]===">"&&V===0){K=Y+1;break}Y++}if(Y>=$.length)break;continue}break}if(K>=$.length||$[K]!=="<")return{element:null,endPos:K};let Q=$.slice(K).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!Q)return{element:null,endPos:K};let q=Q[1];K+=Q[0].length;let H={};while(K<$.length){let M=$.slice(K).match(/^(\s+)/);if(M)K+=M[1].length;if($[K]===">"){K++;break}if($.slice(K,K+2)==="/>")return K+=2,{element:new w0(q,H,[]),endPos:K};let V=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let Y=V[1],X=V[2]!==void 0?V[2]:V[3];H[Y]=yq(X),K+=V[0].length}else{let Y=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(Y)H[Y[1]]="",K+=Y[0].length;else K++}}let W=[],z="",j=`</${q}>`;while(K<$.length){if($.slice(K,K+j.length).toLowerCase()===j.toLowerCase()){K+=j.length;break}if($[K]==="<"&&$[K+1]!=="/"){if($.slice(K,K+9)==="<![CDATA["){let X=$.indexOf("]]>",K+9);if(X!==-1){z+=$.slice(K+9,X),K=X+3;continue}}if($.slice(K,K+4)==="<!--"){let X=$.indexOf("-->",K+4);if(X!==-1){K=X+3;continue}}let M=H["xml:space"],Y=o8($,K,M==="preserve"?!0:M==="default"?!1:Z);if(Y.element)W.push(Y.element),K=Y.endPos;else K++}else if($[K]==="<"&&$[K+1]==="/"){let M=$.slice(K).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(M&&M[1].toLowerCase()===q.toLowerCase()){K+=M[0].length;break}K++}else{let M=$.indexOf("<",K);if(M===-1)z+=$.slice(K),K=$.length;else z+=$.slice(K,M),K=M}}let G=new w0(q,H,W,""),F=H["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?n8(z):n8(z.trim());return G.textContent=U,{element:G,endPos:K}}function p8($){if(typeof $!=="string")throw new Error("parseSelector: selector must be a string");let J=$.trim();if(J.length===0)throw new Error("parseSelector: selector cannot be empty");let Z=[],K=J.split(/\s*,\s*/);for(let Q of K){let q={tag:null,id:null,classes:[],attrs:[]},H=Q,W=H.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(W)q.tag=W[1].toLowerCase(),H=H.slice(W[0].length);let z=H.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(z)q.id=z[1],H=H.replace(z[0],"");let j=H.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of j)q.classes.push(F[1]);let G=H.matchAll(/\[([a-zA-Z][a-zA-Z0-9_:-]*)(?:=["']?([^"'\]]+)["']?)?\]/g);for(let F of G)q.attrs.push({name:F[1],value:F[2]});Z.push(q)}return Z}function c8($,J){if(!($ instanceof w0))throw new Error("matchesAllSelectors: el must be an SVGElement");if(!Array.isArray(J))throw new Error("matchesAllSelectors: matchers must be an array");return J.some((Z)=>{if(Z.tag&&$.tagName.toLowerCase()!==Z.tag)return!1;if(Z.id&&$.getAttribute("id")!==Z.id)return!1;let K=($.getAttribute("class")||"").split(/\s+/).filter((Q)=>Q.length>0);for(let Q of Z.classes)if(!K.includes(Q))return!1;for(let Q of Z.attrs){if(!$.hasAttribute(Q.name))return!1;if(Q.value!==void 0&&$.getAttribute(Q.name)!==Q.value)return!1}return!0})}function u6($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function hq($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function yq($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function n8($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function h7($){if(!$)throw new Error("buildDefsMap: svgRoot cannot be null or undefined");if(!($ instanceof w0))throw new Error("buildDefsMap: svgRoot must be an SVGElement");let J=new Map,Z=(K)=>{let Q=K.getAttribute("id");if(Q)J.set(Q,K);for(let q of K.children)if(q instanceof w0)Z(q)};return Z($),J}function E7($,J){if(!$)throw new Error("findElementsWithAttribute: root cannot be null or undefined");if(!($ instanceof w0))throw new Error("findElementsWithAttribute: root must be an SVGElement");if(typeof J!=="string")throw new Error("findElementsWithAttribute: attrName must be a string");let Z=[],K=(Q)=>{if(Q.hasAttribute(J))Z.push(Q);for(let q of Q.children)if(q instanceof w0)K(q)};return K($),Z}function y7($){if(!$||typeof $!=="string")return null;let J=$.trim();if(J.length===0)return null;let Z=J.match(/url\(\s*["']?#?([^"')]+)["']?\s*\)/i);return Z?Z[1]:null}function K7($,J={}){if(!$)throw new Error("serializeSVG: document is required");if(typeof $.serialize!=="function"){if(typeof $==="string")return $;throw new Error(`serializeSVG: expected SVGElement with serialize method, got ${$?.constructor?.name||typeof $}`)}let Z=J.minify||!1;return'<?xml version="1.0" encoding="UTF-8"?>'+(Z?"":`
|
|
15
|
+
`)+$.serialize(0,Z)}var uq={parseSVG:u0,SVGElement:w0,buildDefsMap:h7,findElementsWithAttribute:E7,parseUrlReference:y7,serializeSVG:K7};var{appendFileSync:gq}=(()=>({}));var xq=100,mq=5000,r$={SILENT:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},g6={level:r$.WARN,logToFile:null,timestamps:!1,_buffer:[],_flushTimer:null,_safeStringify($){if($===null)return"null";if($===void 0)return"undefined";if($ instanceof Error)return $.stack||`${$.name}: ${$.message}`;if(typeof $!=="object")return String($);try{let J=new WeakSet;return JSON.stringify($,(Z,K)=>{if(typeof K==="object"&&K!==null){if(J.has(K))return"[Circular]";J.add(K)}return K})}catch{return String($)}},_format($,J){if(typeof $!=="string"||!$)throw new Error("Logger._format: level must be a non-empty string");let Z=this._safeStringify(J);if(this.timestamps)return`[${new Date().toISOString()}] [${$}] ${Z}`;return`[${$}] ${Z}`},_bufferWrite($){if(!this.logToFile)return;if(this._buffer.push($),this._buffer.length>=xq)this.flush();if(!this._flushTimer)this._flushTimer=setInterval(()=>this.flush(),mq),this._flushTimer.unref()},flush(){if(!this.logToFile||this._buffer.length===0)return;try{let $=this._buffer.join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`;Dr(this.logToFile,t),this._buffer=[]}catch{this._buffer=[]}},error(t,...a){if(this.level<d5.ERROR)return;let e=this._format("ERROR",t),i=a.length?" "+a.map((r)=>this._safeStringify(r)).join(" "):"";console.error(e,...a),this._bufferWrite(e+i),this.flush()},warn(t,...a){if(this.level<d5.WARN)return;let e=this._format("WARN",t),i=a.length?" "+a.map((r)=>this._safeStringify(r)).join(" "):"";console.warn(e,...a),this._bufferWrite(e+i)},info(t,...a){if(this.level<d5.INFO)return;let e=this._format("INFO",t),i=a.length?" "+a.map((r)=>this._safeStringify(r)).join(" "):"";console.log(e,...a),this._bufferWrite(e+i)},debug(t,...a){if(this.level<d5.DEBUG)return;let e=this._format("DEBUG",t),i=a.length?" "+a.map((r)=>this._safeStringify(r)).join(" "):"";console.log(e,...a),this._bufferWrite(e+i)},shutdown(){if(this._flushTimer)clearInterval(this._flushTimer),this._flushTimer=null;this.flush()}},Lr=X4;h.set({precision:80});var g3=(t)=>t instanceof h?t:new h(t),ra=20;function p5(t,a=ra){if(typeof t!=="string")throw Error("pathToPolygon: pathData must be a string");if(typeof a!=="number"||a<=0||!Number.isFinite(a))throw Error(`pathToPolygon: samplesPerCurve must be a positive finite number, got ${a}`);let e=[],i=g3(0),r=g3(0),l=g3(0),o=g3(0),x=kr(t);if(!Array.isArray(x))throw Error("pathToPolygon: parsePathCommands must return an array");for(let p of x){let{type:n,args:c}=p;if(!Array.isArray(c))throw Error(`pathToPolygon: command args must be an array for command ${n}`);switch(n){case"M":if(c.length<2)throw Error(`pathToPolygon: M command requires 2 arguments, got ${c.length}`);i=g3(c[0]),r=g3(c[1]),l=i,o=r,e.push(R3(i,r));break;case"m":if(c.length<2)throw Error(`pathToPolygon: m command requires 2 arguments, got ${c.length}`);i=i.plus(c[0]),r=r.plus(c[1]),l=i,o=r,e.push(R3(i,r));break;case"L":if(c.length<2)throw Error(`pathToPolygon: L command requires 2 arguments, got ${c.length}`);i=g3(c[0]),r=g3(c[1]),e.push(R3(i,r));break;case"l":if(c.length<2)throw Error(`pathToPolygon: l command requires 2 arguments, got ${c.length}`);i=i.plus(c[0]),r=r.plus(c[1]),e.push(R3(i,r));break;case"H":if(c.length<1)throw Error(`pathToPolygon: H command requires 1 argument, got ${c.length}`);i=g3(c[0]),e.push(R3(i,r));break;case"h":if(c.length<1)throw Error(`pathToPolygon: h command requires 1 argument, got ${c.length}`);i=i.plus(c[0]),e.push(R3(i,r));break;case"V":if(c.length<1)throw Error(`pathToPolygon: V command requires 1 argument, got ${c.length}`);r=g3(c[0]),e.push(R3(i,r));break;case"v":if(c.length<1)throw Error(`pathToPolygon: v command requires 1 argument, got ${c.length}`);r=r.plus(c[0]),e.push(R3(i,r));break;case"C":if(c.length<6)throw Error(`pathToPolygon: C command requires 6 arguments, got ${c.length}`);k6(e,i,r,g3(c[0]),g3(c[1]),g3(c[2]),g3(c[3]),g3(c[4]),g3(c[5]),a),i=g3(c[4]),r=g3(c[5]);break;case"c":if(c.length<6)throw Error(`pathToPolygon: c command requires 6 arguments, got ${c.length}`);k6(e,i,r,i.plus(c[0]),r.plus(c[1]),i.plus(c[2]),r.plus(c[3]),i.plus(c[4]),r.plus(c[5]),a),i=i.plus(c[4]),r=r.plus(c[5]);break;case"Q":if(c.length<4)throw Error(`pathToPolygon: Q command requires 4 arguments, got ${c.length}`);Y6(e,i,r,g3(c[0]),g3(c[1]),g3(c[2]),g3(c[3]),a),i=g3(c[2]),r=g3(c[3]);break;case"q":if(c.length<4)throw Error(`pathToPolygon: q command requires 4 arguments, got ${c.length}`);Y6(e,i,r,i.plus(c[0]),r.plus(c[1]),i.plus(c[2]),r.plus(c[3]),a),i=i.plus(c[2]),r=r.plus(c[3]);break;case"A":if(c.length<7)throw Error(`pathToPolygon: A command requires 7 arguments, got ${c.length}`);X6(e,i,r,g3(c[0]),g3(c[1]),g3(c[2]),c[3],c[4],g3(c[5]),g3(c[6]),a),i=g3(c[5]),r=g3(c[6]);break;case"a":if(c.length<7)throw Error(`pathToPolygon: a command requires 7 arguments, got ${c.length}`);X6(e,i,r,g3(c[0]),g3(c[1]),g3(c[2]),c[3],c[4],i.plus(c[5]),r.plus(c[6]),a),i=i.plus(c[5]),r=r.plus(c[6]);break;case"Z":case"z":i=l,r=o;break;default:break}}return Yr(e)}function kr(t){if(typeof t!=="string")throw Error(`parsePathCommands: pathData must be a string, got ${typeof t}`);let a=[],e=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,i;while((i=e.exec(t))!==null){let r=i[1],l=i[2].trim(),o=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,x=l.length>0?Array.from(l.matchAll(o),(p)=>Number(p[0])):[];a.push({type:r,args:x})}return a}function k6(t,a,e,i,r,l,o,x,p,n){if(!Array.isArray(t))throw Error("sampleCubicBezier: points must be an array");if(typeof n!=="number"||n<=0||!Number.isFinite(n))throw Error(`sampleCubicBezier: samples must be a positive finite number, got ${n}`);if(!(a instanceof h)||!(e instanceof h)||!(i instanceof h)||!(r instanceof h)||!(l instanceof h)||!(o instanceof h)||!(x instanceof h)||!(p instanceof h))throw Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let c=1;c<=n;c++){let s=g3(c).div(n),m=g3(1).minus(s),g=m.mul(m),u=g.mul(m),y=s.mul(s),v=y.mul(s),E=u.mul(a).plus(g3(3).mul(g).mul(s).mul(i)).plus(g3(3).mul(m).mul(y).mul(l)).plus(v.mul(x)),C=u.mul(e).plus(g3(3).mul(g).mul(s).mul(r)).plus(g3(3).mul(m).mul(y).mul(o)).plus(v.mul(p));t.push(R3(E,C))}}function Y6(t,a,e,i,r,l,o,x){if(!Array.isArray(t))throw Error("sampleQuadraticBezier: points must be an array");if(typeof x!=="number"||x<=0||!Number.isFinite(x))throw Error(`sampleQuadraticBezier: samples must be a positive finite number, got ${x}`);if(!(a instanceof h)||!(e instanceof h)||!(i instanceof h)||!(r instanceof h)||!(l instanceof h)||!(o instanceof h))throw Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let p=1;p<=x;p++){let n=g3(p).div(x),c=g3(1).minus(n),s=c.mul(c),m=n.mul(n),g=s.mul(a).plus(g3(2).mul(c).mul(n).mul(i)).plus(m.mul(l)),u=s.mul(e).plus(g3(2).mul(c).mul(n).mul(r)).plus(m.mul(o));t.push(R3(g,u))}}function X6(t,a,e,i,r,l,o,x,p,n,c){if(!Array.isArray(t))throw Error("sampleArc: points must be an array");if(typeof c!=="number"||c<=0||!Number.isFinite(c))throw Error(`sampleArc: samples must be a positive finite number, got ${c}`);if(!(a instanceof h)||!(e instanceof h)||!(i instanceof h)||!(r instanceof h)||!(l instanceof h)||!(p instanceof h)||!(n instanceof h))throw Error("sampleArc: all coordinate and angle parameters must be Decimal instances");if(typeof o!=="number"||o!==0&&o!==1)throw Error(`sampleArc: largeArc must be 0 or 1, got ${o}`);if(typeof x!=="number"||x!==0&&x!==1)throw Error(`sampleArc: sweep must be 0 or 1, got ${x}`);if(i.eq(0)||r.eq(0)){t.push(R3(p,n));return}let s=i.abs(),m=r.abs(),g=l.mul(Math.PI).div(180),u=g.cos(),y=g.sin(),v=a.minus(p).div(2),E=e.minus(n).div(2),C=u.mul(v).plus(y.mul(E)),P=u.mul(E).minus(y.mul(v)),S=s.mul(s),f=m.mul(m),B=C.mul(C),R=P.mul(P),k=B.div(S).plus(R.div(f));if(k.gt(1)){let e3=k.sqrt();s=s.mul(e3),m=m.mul(e3),S=s.mul(s),f=m.mul(m)}let N=S.mul(f).minus(S.mul(R)).minus(f.mul(B));if(N=N.div(S.mul(R).plus(f.mul(B))),N.lt(0))N=g3(0);if(N=N.sqrt(),o===x)N=N.neg();let I=N.mul(i).mul(P).div(r),d=N.neg().mul(r).mul(C).div(i),Y=a.plus(p).div(2),X=e.plus(n).div(2),F=u.mul(I).minus(y.mul(d)).plus(Y),V=y.mul(I).plus(u.mul(d)).plus(X),T=C.minus(I).div(i),j=P.minus(d).div(r),A=C.neg().minus(I).div(i),z=P.neg().minus(d).div(r),i3=T.mul(T).plus(j.mul(j)).sqrt();if(i3.eq(0)){L6.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),t.push(R3(p,n));return}let K=h.acos(T.div(i3));if(j.lt(0))K=K.neg();let $=i3.mul(A.mul(A).plus(z.mul(z)).sqrt());if($.eq(0)){L6.warn("sampleArc: degenerate arc - zero length, treating as single point"),t.push(R3(p,n));return}let w=h.acos(T.mul(A).plus(j.mul(z)).div($));if(T.mul(z).minus(j.mul(A)).lt(0))w=w.neg();let G=g3(Math.PI),a3=G.mul(2);if(x&&w.lt(0))w=w.plus(a3);else if(!x&&w.gt(0))w=w.minus(a3);for(let e3=1;e3<=c;e3++){let o3=g3(e3).div(c),y3=K.plus(w.mul(o3)),N3=y3.cos(),Q=y3.sin(),J=u.mul(i.mul(N3)).minus(y.mul(r.mul(Q))).plus(F),c3=y.mul(i.mul(N3)).plus(u.mul(r.mul(Q))).plus(V);t.push(R3(J,c3))}}function Yr(t){if(!Array.isArray(t))throw Error("removeDuplicateConsecutive: points must be an array");if(t.length<2)return t;let a=[t[0]];for(let e=1;e<t.length;e++)if(!Q4(t[e],a[a.length-1]))a.push(t[e]);return a}function k2(t,a=null,e=ra,i=4){if(!t||typeof t!=="object")throw Error("shapeToPolygon: element must be an object");if(!t.type||typeof t.type!=="string")throw Error("shapeToPolygon: element.type must be a string");if(typeof e!=="number"||e<=0||!Number.isFinite(e))throw Error(`shapeToPolygon: samples must be a positive finite number, got ${e}`);if(typeof i!=="number"||i<=0||!Number.isFinite(i))throw Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${i}`);if(a!==null&&!(a instanceof s3))throw Error("shapeToPolygon: ctm must be null or a Matrix instance");let r;switch(t.type){case"circle":if(i>4)r=Wt(t.cx||0,t.cy||0,t.r||0,i,10);else r=cr(g3(t.cx||0),g3(t.cy||0),g3(t.r||0));break;case"ellipse":if(i>4)r=C2(t.cx||0,t.cy||0,t.rx||0,t.ry||0,i,10);else r=Qt(g3(t.cx||0),g3(t.cy||0),g3(t.rx||0),g3(t.ry||0));break;case"rect":r=sr(g3(t.x||0),g3(t.y||0),g3(t.width||0),g3(t.height||0),g3(t.rx||0),t.ry!==void 0?g3(t.ry):null);break;case"line":r=mr(g3(t.x1||0),g3(t.y1||0),g3(t.x2||0),g3(t.y2||0));break;case"polygon":r=gr(t.points||"");break;case"polyline":r=yr(t.points||"");break;case"path":r=t.d||"";break;default:return[]}if(t.transform){let l=Lr(t.transform);if(!(l instanceof s3))throw Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof l}`);r=c0(r,l)}if(a)r=c0(r,a);return p5(r,e)}function la(t,a=6){if(!Array.isArray(t))throw Error("polygonToPathData: polygon must be an array");if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error(`polygonToPathData: precision must be a non-negative finite number, got ${a}`);if(t.length<2)return"";let e=(r)=>(r instanceof h?r:g3(r)).toFixed(a).replace(/\.?0+$/,""),i=`M ${e(t[0].x)} ${e(t[0].y)}`;for(let r=1;r<t.length;r++)i+=` L ${e(t[r].x)} ${e(t[r].y)}`;return i+" Z"}h.set({precision:80});h.set({precision:80});var O6=(t)=>t instanceof h?t:new h(t),V6=-0.1,U6=-0.1,M6=1.2,_6=1.2,t0={LUMINANCE:"luminance",ALPHA:"alpha"};function Xr(t){if(!t)throw Error("parseMaskElement: maskElement is required");if(!t.getAttribute)throw Error("parseMaskElement: maskElement must be a DOM element");let a={id:t.getAttribute("id")||"",maskUnits:t.getAttribute("maskUnits")||"objectBoundingBox",maskContentUnits:t.getAttribute("maskContentUnits")||"userSpaceOnUse",maskType:t.getAttribute("mask-type")||t.style?.maskType||"luminance",x:t.getAttribute("x"),y:t.getAttribute("y"),width:t.getAttribute("width"),height:t.getAttribute("height"),transform:t.getAttribute("transform")||null,children:[]},e=(i,r)=>{let l=parseFloat(i);return isNaN(l)?r:l};if(a.maskUnits==="objectBoundingBox")a.x=a.x!==null?e(a.x,V6):V6,a.y=a.y!==null?e(a.y,U6):U6,a.width=a.width!==null?e(a.width,M6):M6,a.height=a.height!==null?e(a.height,_6):_6;else a.x=a.x!==null?e(a.x,null):null,a.y=a.y!==null?e(a.y,null):null,a.width=a.width!==null?e(a.width,null):null,a.height=a.height!==null?e(a.height,null):null;if(!t.children)return a;for(let i of t.children){if(!i.tagName)continue;let r=i.tagName.toLowerCase(),l={type:r,fill:i.getAttribute("fill")||i.style?.fill||"black",fillOpacity:e(i.getAttribute("fill-opacity")||i.style?.fillOpacity||"1",1),opacity:e(i.getAttribute("opacity")||i.style?.opacity||"1",1),transform:i.getAttribute("transform")||null};switch(r){case"rect":l.x=e(i.getAttribute("x")||"0",0),l.y=e(i.getAttribute("y")||"0",0),l.width=e(i.getAttribute("width")||"0",0),l.height=e(i.getAttribute("height")||"0",0),l.rx=e(i.getAttribute("rx")||"0",0),l.ry=e(i.getAttribute("ry")||"0",0);break;case"circle":l.cx=e(i.getAttribute("cx")||"0",0),l.cy=e(i.getAttribute("cy")||"0",0),l.r=e(i.getAttribute("r")||"0",0);break;case"ellipse":l.cx=e(i.getAttribute("cx")||"0",0),l.cy=e(i.getAttribute("cy")||"0",0),l.rx=e(i.getAttribute("rx")||"0",0),l.ry=e(i.getAttribute("ry")||"0",0);break;case"path":l.d=i.getAttribute("d")||"";break;case"polygon":l.points=i.getAttribute("points")||"";break;case"polyline":l.points=i.getAttribute("points")||"";break;case"g":if(l.children=[],i.children){for(let o of i.children)if(o.tagName)l.children.push({type:o.tagName.toLowerCase(),fill:o.getAttribute("fill")||"inherit"})}break;default:break}a.children.push(l)}return a}function Or(t,a,e,i=20){if(!t)throw Error("maskChildToPolygon: child is required");if(!a)throw Error("maskChildToPolygon: targetBBox is required");if(!e)throw Error("maskChildToPolygon: contentUnits is required");if(typeof i!=="number"||i<=0)throw Error("maskChildToPolygon: samples must be a positive number");if(typeof a.x!=="number"||typeof a.y!=="number"||typeof a.width!=="number"||typeof a.height!=="number")throw Error("maskChildToPolygon: targetBBox must have numeric x, y, width, height properties");if(a.width<0||a.height<0)throw Error("maskChildToPolygon: targetBBox width and height cannot be negative");let r={type:t.type,...t,transform:t.transform},l=k2(r,null,i);if(!Array.isArray(l))return[];if(e==="objectBoundingBox"&&l.length>0){if(a.width===0||a.height===0)return[];l=l.map((o)=>({x:O6(a.x).plus(o.x.mul(a.width)),y:O6(a.y).plus(o.y.mul(a.height))}))}return l}function Vr(t){if(!t||t==="none"||t==="transparent")return 0;if(typeof t!=="string")return 0;let a=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(a){let l=parseInt(a[1],10),o=parseInt(a[2],10),x=parseInt(a[3],10);if(isNaN(l)||isNaN(o)||isNaN(x))return 0;let p=Math.max(0,Math.min(255,l))/255,n=Math.max(0,Math.min(255,o))/255,c=Math.max(0,Math.min(255,x))/255,s=0.2126*p+0.7152*n+0.0722*c;return isNaN(s)?0:s}let e=t.match(/^#([0-9a-f]{3,6})$/i);if(e){let l=e[1];if(l.length===3)l=l[0]+l[0]+l[1]+l[1]+l[2]+l[2];let o=parseInt(l.slice(0,2),16),x=parseInt(l.slice(2,4),16),p=parseInt(l.slice(4,6),16);if(isNaN(o)||isNaN(x)||isNaN(p))return 0;let n=0.2126*(o/255)+0.7152*(x/255)+0.0722*(p/255);return isNaN(n)?0:n}let i={white:1,black:0,red:0.2126,green:0.7152,blue:0.0722,yellow:0.9278,cyan:0.7874,magenta:0.2848,gray:0.5,grey:0.5},r=t.toLowerCase();if(i[r]!==void 0)return i[r];return 0}function Ur(t,a){if(!t)throw Error("getMaskChildOpacity: child is required");if(!a)throw Error("getMaskChildOpacity: maskType is required");if(a!==t0.LUMINANCE&&a!==t0.ALPHA)throw Error('getMaskChildOpacity: maskType must be "luminance" or "alpha"');let e=typeof t.fillOpacity==="number"&&!isNaN(t.fillOpacity)?t.fillOpacity:1,i=typeof t.opacity==="number"&&!isNaN(t.opacity)?t.opacity:1,r=e*i;if(a===t0.ALPHA)return r;let l=Vr(t.fill),o=r*l;return isNaN(o)?0:o}function Mr(t,a,e={}){if(!t)throw Error("resolveMask: maskData is required");if(!a)throw Error("resolveMask: targetBBox is required");if(!Array.isArray(t.children))throw Error("resolveMask: maskData.children must be an array");let{samples:i=20}=e;if(typeof i!=="number"||i<=0)throw Error("resolveMask: samples must be a positive number");let r=t.maskType||t0.LUMINANCE,l=[];for(let o of t.children){if(!o)continue;let x=Or(o,a,t.maskContentUnits,i);if(x.length>=3){let p=Ur(o,r);l.push({polygon:x,opacity:p})}}return l}function _r(t,a,e=0.5,i={}){if(!t)throw Error("maskToClipPath: maskData is required");if(!a)throw Error("maskToClipPath: targetBBox is required");if(typeof e!=="number"||e<0||e>1)throw Error("maskToClipPath: opacityThreshold must be a number between 0 and 1");let r=Mr(t,a,i),l=[];for(let{polygon:o,opacity:x}of r)if(x>=e&&o&&o.length>=3)if(l.length===0)l=o;else{let p=B0(l,o);if(p.length>0&&p[0].length>=3)l=p[0]}return l}function Fr(t,a,e={}){if(!t)throw Error("maskToPathData: maskData is required");if(!a)throw Error("maskToPathData: targetBBox is required");let i=_r(t,a,0.5,e);if(i.length<3)return"";let r="",l=0;for(let o=0;o<i.length;o++){let x=i[o];if(!x||x.x===void 0||x.y===void 0)continue;let p=Number(x.x),n=Number(x.y);if(isNaN(p)||isNaN(n)||!isFinite(p)||!isFinite(n))continue;let c=p.toFixed(6),s=n.toFixed(6);r+=l===0?`M ${c} ${s}`:` L ${c} ${s}`,l++}if(l>=3)r+=" Z";else return"";return r}h.set({precision:80});function Gr(t){if(!t)throw Error("parseUseElement: useElement is required");let a=t.getAttribute("href")||t.getAttribute("xlink:href")||"",e=a.startsWith("#")?a.slice(1):a;if(!e)throw Error("parseUseElement: href attribute must reference a valid element id (found empty reference)");let i=parseFloat(t.getAttribute("x")||"0"),r=parseFloat(t.getAttribute("y")||"0");if(isNaN(i)||isNaN(r)||!isFinite(i)||!isFinite(r))throw Error("parseUseElement: x and y attributes must be valid finite numbers");let l=null,o=null;if(t.getAttribute("width")){if(l=parseFloat(t.getAttribute("width")),isNaN(l)||!isFinite(l)||l<=0)throw Error("parseUseElement: width attribute must be a valid positive finite number")}if(t.getAttribute("height")){if(o=parseFloat(t.getAttribute("height")),isNaN(o)||!isFinite(o)||o<=0)throw Error("parseUseElement: height attribute must be a valid positive finite number")}return{href:e,x:i,y:r,width:l,height:o,transform:t.getAttribute("transform")||null,style:oa(t)}}function jr(t){if(!t)throw Error("parseSymbolElement: symbolElement is required");let a=parseFloat(t.getAttribute("refX")||"0"),e=parseFloat(t.getAttribute("refY")||"0");if(isNaN(a)||isNaN(e)||!isFinite(a)||!isFinite(e))throw Error("parseSymbolElement: refX and refY must be valid finite numbers");let i={id:t.getAttribute("id")||"",viewBox:t.getAttribute("viewBox")||null,preserveAspectRatio:t.getAttribute("preserveAspectRatio")||"xMidYMid meet",children:[],refX:a,refY:e};if(i.viewBox){let r=i.viewBox.trim().split(/[\s,]+/).map(Number);if(r.length===4&&r.every((l)=>!isNaN(l)&&isFinite(l)))i.viewBoxParsed={x:r[0],y:r[1],width:r[2],height:r[3]}}for(let r of t.children)i.children.push(Y2(r));return i}function Y2(t){if(!t||!t.tagName)throw Error("parseChildElement: element with tagName is required");let a=t.tagName.toLowerCase(),e={type:a,id:t.getAttribute("id")||null,transform:t.getAttribute("transform")||null,style:oa(t)},i=(r,l="0")=>{let o=parseFloat(t.getAttribute(r)||l);if(isNaN(o)||!isFinite(o))throw Error(`parseChildElement: ${r} must be a valid finite number in ${a} element`);return o};switch(a){case"rect":e.x=i("x"),e.y=i("y"),e.width=i("width"),e.height=i("height"),e.rx=i("rx"),e.ry=i("ry");break;case"circle":e.cx=i("cx"),e.cy=i("cy"),e.r=i("r");break;case"ellipse":e.cx=i("cx"),e.cy=i("cy"),e.rx=i("rx"),e.ry=i("ry");break;case"path":e.d=t.getAttribute("d")||"";break;case"polygon":e.points=t.getAttribute("points")||"";break;case"polyline":e.points=t.getAttribute("points")||"";break;case"line":e.x1=i("x1"),e.y1=i("y1"),e.x2=i("x2"),e.y2=i("y2");break;case"g":e.children=[];for(let r of t.children)e.children.push(Y2(r));break;case"use":e.href=(t.getAttribute("href")||t.getAttribute("xlink:href")||"").replace("#",""),e.x=i("x"),e.y=i("y"),e.width=t.getAttribute("width")?i("width"):null,e.height=t.getAttribute("height")?i("height"):null;break;default:break}return e}function oa(t){if(!t)throw Error("extractStyleAttributes: element is required");return{fill:t.getAttribute("fill"),stroke:t.getAttribute("stroke"),strokeWidth:t.getAttribute("stroke-width"),opacity:t.getAttribute("opacity"),fillOpacity:t.getAttribute("fill-opacity"),strokeOpacity:t.getAttribute("stroke-opacity"),visibility:t.getAttribute("visibility"),display:t.getAttribute("display")}}function Wr(t,a,e,i="xMidYMid meet"){if(!t||!a||!e)return s3.identity(3);if(!isFinite(a)||!isFinite(e)||a<=0||e<=0)return s3.identity(3);let{width:r,height:l,x:o,y:x}=t;if(!isFinite(r)||!isFinite(l)||!isFinite(o)||!isFinite(x)||r<=0||l<=0)return s3.identity(3);let p=i.trim().split(/\s+/),n=p[0]||"xMidYMid",c=p[1]||"meet";if(n==="none"){let C=a/r,P=e/l;return g4(-o*C,-x*P).mul(n5(C,P))}let s=a/r,m=e/l,g;if(c==="slice")g=Math.max(s,m);else g=Math.min(s,m);let u=-o*g,y=-x*g,v=r*g,E=l*g;if(n.includes("xMid"))u+=(a-v)/2;else if(n.includes("xMax"))u+=a-v;if(n.includes("YMid"))y+=(e-E)/2;else if(n.includes("YMax"))y+=e-E;return g4(u,y).mul(n5(g,g))}function xa(t,a,e={}){if(!t||!t.href)throw Error("resolveUse: useData with href property is required");if(!a)throw Error("resolveUse: defs map is required");if(typeof t.x!=="number"||isNaN(t.x)||!isFinite(t.x))throw Error("resolveUse: useData.x must be a valid finite number");if(typeof t.y!=="number"||isNaN(t.y)||!isFinite(t.y))throw Error("resolveUse: useData.y must be a valid finite number");if(t.width!==null&&(typeof t.width!=="number"||isNaN(t.width)||!isFinite(t.width)||t.width<=0))throw Error("resolveUse: useData.width must be null or a positive finite number");if(t.height!==null&&(typeof t.height!=="number"||isNaN(t.height)||!isFinite(t.height)||t.height<=0))throw Error("resolveUse: useData.height must be null or a positive finite number");if(t.style!==null&&t.style!==void 0){if(typeof t.style!=="object"||Array.isArray(t.style))throw Error("resolveUse: useData.style must be null, undefined, or a valid non-array object")}if(t.transform!==null&&t.transform!==void 0&&typeof t.transform!=="string")throw Error("resolveUse: useData.transform must be null, undefined, or a string");if(e&&typeof e!=="object")throw Error("resolveUse: options must be an object or undefined");let{maxDepth:i=10,_visited:r=new Set}=e;if(typeof i!=="number"||i<=0||!isFinite(i))throw Error("resolveUse: maxDepth must be a positive finite number");if(r.has(t.href))return console.warn(`resolveUse: circular reference detected for '#${t.href}', skipping to prevent infinite loop`),null;let l=a[t.href];if(!l)return console.warn(`resolveUse: target element '#${t.href}' not found in defs map`),null;r.add(t.href);let o=g4(t.x,t.y);if(t.transform){let n=X4(t.transform);o=o.mul(n)}if(l.type==="symbol"&&l.viewBoxParsed){if(typeof l.viewBoxParsed.x!=="number"||typeof l.viewBoxParsed.y!=="number"||typeof l.viewBoxParsed.width!=="number"||typeof l.viewBoxParsed.height!=="number"||!isFinite(l.viewBoxParsed.x)||!isFinite(l.viewBoxParsed.y)||!isFinite(l.viewBoxParsed.width)||!isFinite(l.viewBoxParsed.height)||l.viewBoxParsed.width<=0||l.viewBoxParsed.height<=0)throw Error("resolveUse: target.viewBoxParsed must have finite x, y and positive finite width, height");let n=t.width!==null?t.width:l.viewBoxParsed.width,c=t.height!==null?t.height:l.viewBoxParsed.height;o=Wr(l.viewBoxParsed,n,c,l.preserveAspectRatio||"xMidYMid meet").mul(o)}let x=[],p=l.children&&Array.isArray(l.children)&&l.children.length>0?l.children:[l];for(let n of p)if(n.type==="use"){if(i<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${n.href}', skipping nested resolution`);continue}let c=xa(n,a,{maxDepth:i-1,_visited:r});if(c)x.push(c)}else x.push({element:n,transform:s3.identity(3)});return r.delete(t.href),{element:l,transform:o,children:x,inheritedStyle:t.style}}function na(t,a=20){let e=[];if(!t)return e;if(typeof a!=="number"||a<=0||!isFinite(a))throw Error("flattenResolvedUse: samples must be a positive finite number");if(!t.children||!t.transform)return e;for(let i of t.children){if(!i||!i.transform)continue;let r=t.transform.mul(i.transform),l=i.element;if(i.children){let o=na(i,a);for(let x of o)x.polygon=x.polygon.map((p)=>{let[n,c]=e4(t.transform,p.x,p.y);return{x:n,y:c}}),e.push(x)}else{let o=zr(l,r,a);if(o.length>=3)e.push({polygon:o,style:Hr(t.inheritedStyle,l.style)})}}return e}function zr(t,a,e=20){if(!t)throw Error("elementToPolygon: element is required");if(typeof e!=="number"||e<=0||!isFinite(e))throw Error("elementToPolygon: samples must be a positive finite number");let i=k2(t,null,e);if(a&&i.length>0)i=i.map((r)=>{let[l,o]=e4(a,r.x,r.y);return{x:l,y:o}});return i}function Hr(t,a){if(!a||typeof a!=="object"||Array.isArray(a))throw Error("mergeStyles: element must be a valid non-array object");let e={...a};if(t!==null&&t!==void 0){if(typeof t!=="object"||Array.isArray(t))throw Error("mergeStyles: inherited must be null, undefined, or a valid non-array object")}for(let[i,r]of Object.entries(t||{}))if(r!==null&&(e[i]===null||e[i]===void 0))e[i]=r;return e}function Qr(t,a=20){if(typeof a!=="number"||a<=0||!isFinite(a))throw Error("resolvedUseToPathData: samples must be a positive finite number");let e=na(t,a),i=[];for(let{polygon:r}of e)if(r.length>=3){let l="";for(let o=0;o<r.length;o++){let x=r[o],p=Number(x.x),n=Number(x.y);if(isNaN(p)||isNaN(n))continue;l+=o===0?`M ${p.toFixed(6)} ${n.toFixed(6)}`:` L ${p.toFixed(6)} ${n.toFixed(6)}`}l+=" Z",i.push(l)}return i.join(" ")}h.set({precision:80});var t4=(t)=>t instanceof h?t:new h(t);function qr(t){if(!t)throw Error("parsePatternElement: patternElement is required");if(typeof t.getAttribute!=="function")throw Error("parsePatternElement: patternElement must be a DOM element with getAttribute method");let a={id:t.getAttribute("id")||"",patternUnits:t.getAttribute("patternUnits")||"objectBoundingBox",patternContentUnits:t.getAttribute("patternContentUnits")||"userSpaceOnUse",patternTransform:t.getAttribute("patternTransform")||null,x:t.getAttribute("x"),y:t.getAttribute("y"),width:t.getAttribute("width"),height:t.getAttribute("height"),viewBox:t.getAttribute("viewBox")||null,preserveAspectRatio:t.getAttribute("preserveAspectRatio")||"xMidYMid meet",href:t.getAttribute("href")||t.getAttribute("xlink:href")||null,children:[]},e=(i,r)=>{if(i===null||i===void 0)return r;let l=parseFloat(i);return isNaN(l)?r:l};if(a.x=e(a.x,0),a.y=e(a.y,0),a.width=e(a.width,0),a.height=e(a.height,0),a.viewBox){let i=a.viewBox.trim().split(/[\s,]+/).map(Number);if(i.length===4&&i.every((r)=>!isNaN(r)&&isFinite(r)))a.viewBoxParsed={x:i[0],y:i[1],width:i[2],height:i[3]}}if(t.children&&typeof t.children[Symbol.iterator]==="function")for(let i of t.children){if(!i||typeof i.getAttribute!=="function")continue;let r=i.tagName?i.tagName.toLowerCase():"";if(!r)continue;let l={type:r,fill:i.getAttribute("fill")||"black",stroke:i.getAttribute("stroke")||"none",strokeWidth:e(i.getAttribute("stroke-width"),1),opacity:e(i.getAttribute("opacity"),1),transform:i.getAttribute("transform")||null};switch(r){case"rect":l.x=e(i.getAttribute("x"),0),l.y=e(i.getAttribute("y"),0),l.width=e(i.getAttribute("width"),0),l.height=e(i.getAttribute("height"),0),l.rx=e(i.getAttribute("rx"),0),l.ry=e(i.getAttribute("ry"),0);break;case"circle":l.cx=e(i.getAttribute("cx"),0),l.cy=e(i.getAttribute("cy"),0),l.r=e(i.getAttribute("r"),0);break;case"ellipse":l.cx=e(i.getAttribute("cx"),0),l.cy=e(i.getAttribute("cy"),0),l.rx=e(i.getAttribute("rx"),0),l.ry=e(i.getAttribute("ry"),0);break;case"path":l.d=i.getAttribute("d")||"";break;case"polygon":l.points=i.getAttribute("points")||"";break;case"polyline":l.points=i.getAttribute("points")||"";break;case"line":l.x1=e(i.getAttribute("x1"),0),l.y1=e(i.getAttribute("y1"),0),l.x2=e(i.getAttribute("x2"),0),l.y2=e(i.getAttribute("y2"),0);break;case"use":l.href=i.getAttribute("href")||i.getAttribute("xlink:href")||"",l.x=e(i.getAttribute("x"),0),l.y=e(i.getAttribute("y"),0);break;case"g":if(l.children=[],i.children&&typeof i.children[Symbol.iterator]==="function"){for(let o of i.children)if(o&&o.tagName&&typeof o.getAttribute==="function")l.children.push({type:o.tagName.toLowerCase(),fill:o.getAttribute("fill")||"inherit"})}break;default:break}a.children.push(l)}return a}function Kr(t,a){if(!t)throw Error("getPatternTile: patternData is required");if(!a)throw Error("getPatternTile: targetBBox is required");if(typeof a.x!=="number"||typeof a.y!=="number"||typeof a.width!=="number"||typeof a.height!=="number")throw Error("getPatternTile: targetBBox must have numeric x, y, width, and height properties");if(typeof t.x!=="number"||typeof t.y!=="number"||typeof t.width!=="number"||typeof t.height!=="number")throw Error("getPatternTile: patternData must have numeric x, y, width, and height properties");if(t.patternUnits==="objectBoundingBox")return{x:t4(a.x).plus(t4(t.x).mul(a.width)),y:t4(a.y).plus(t4(t.y).mul(a.height)),width:t4(t.width).mul(a.width),height:t4(t.height).mul(a.height)};return{x:t4(t.x),y:t4(t.y),width:t4(t.width),height:t4(t.height)}}function Zr(t,a,e){if(!t)throw Error("getPatternContentTransform: patternData is required");if(!a)throw Error("getPatternContentTransform: tile is required");if(!e)throw Error("getPatternContentTransform: targetBBox is required");if(!a.width||!a.height)throw Error("getPatternContentTransform: tile must have width and height properties");if(typeof e.x!=="number"||typeof e.y!=="number"||typeof e.width!=="number"||typeof e.height!=="number")throw Error("getPatternContentTransform: targetBBox must have numeric x, y, width, and height properties");let i=s3.identity(3);if(t.viewBoxParsed){let r=t.viewBoxParsed;if(typeof r.x!=="number"||typeof r.y!=="number"||typeof r.width!=="number"||typeof r.height!=="number")throw Error("getPatternContentTransform: viewBoxParsed must have numeric x, y, width, and height properties");let l=Number(a.width),o=Number(a.height);if(l===0||o===0)throw Error("getPatternContentTransform: tile width and height must be non-zero when viewBox is present");if(r.width===0||r.height===0)throw Error("getPatternContentTransform: viewBox width and height must be non-zero");let x=l/r.width,p=o/r.height,n=Math.min(x,p);if(!isFinite(n))throw Error("getPatternContentTransform: computed scale is not finite");let c=(l-r.width*n)/2,s=(o-r.height*n)/2;i=i.mul(g4(c-r.x*n,s-r.y*n)),i=i.mul(n5(n,n))}if(t.patternContentUnits==="objectBoundingBox"){if(e.width===0||e.height===0)throw Error("getPatternContentTransform: targetBBox width and height must be non-zero when patternContentUnits is objectBoundingBox");i=i.mul(g4(e.x,e.y)),i=i.mul(n5(e.width,e.height))}return i}function Jr(t,a=null,e=20){if(!t)throw Error("patternChildToPolygon: child is required");if(!t.type)throw Error("patternChildToPolygon: child must have a type property");if(typeof e!=="number"||e<=0||!isFinite(e))throw Error("patternChildToPolygon: samples must be a positive finite number");let i={type:t.type,...t,transform:t.transform},r=k2(i,null,e);if(!Array.isArray(r))return[];if(a&&r.length>0)r=r.map((l)=>{if(!l||typeof l.x!=="number"||typeof l.y!=="number")throw Error("patternChildToPolygon: invalid polygon point - must have numeric x and y properties");let[o,x]=e4(a,l.x,l.y);return{x:o,y:x}});return r}function $r(t,a){if(!t)throw Error("getTilePositions: tile is required");if(!a)throw Error("getTilePositions: coverBBox is required");if(!("x"in t)||!("y"in t)||!("width"in t)||!("height"in t))throw Error("getTilePositions: tile must have x, y, width, and height properties");if(typeof a.x!=="number"||typeof a.y!=="number"||typeof a.width!=="number"||typeof a.height!=="number")throw Error("getTilePositions: coverBBox must have numeric x, y, width, and height properties");let e=[],i=Number(t.x),r=Number(t.y),l=Number(t.width),o=Number(t.height);if(!isFinite(i)||!isFinite(r)||!isFinite(l)||!isFinite(o))throw Error("getTilePositions: tile dimensions must be finite numbers");if(l<=0||o<=0)return e;let x=Math.floor((a.x-i)/l),p=Math.ceil((a.x+a.width-i)/l),n=Math.floor((a.y-r)/o),c=Math.ceil((a.y+a.height-r)/o);if(!isFinite(x)||!isFinite(p)||!isFinite(n)||!isFinite(c))throw Error("getTilePositions: computed tile indices are not finite");for(let s=x;s<p;s++)for(let m=n;m<c;m++)e.push({x:t4(i).plus(t4(l).mul(s)),y:t4(r).plus(t4(o).mul(m))});return e}function tl(t,a,e={}){if(!t)throw Error("resolvePattern: patternData is required");if(!a)throw Error("resolvePattern: targetBBox is required");if(!Array.isArray(t.children))throw Error("resolvePattern: patternData.children must be an array");let{samples:i=20,maxTiles:r=1000}=e,l=[],o=Kr(t,a);if(Number(o.width)<=0||Number(o.height)<=0)return l;let x=Zr(t,o,a),p=il(t.patternTransform),n=$r(o,a).slice(0,r);for(let c of n){let s=g4(c.x,c.y);for(let m of t.children){let g=p.mul(s.mul(x)),u=Jr(m,g,i);if(u.length>=3)l.push({polygon:u,fill:m.fill,stroke:m.stroke,strokeWidth:m.strokeWidth,opacity:m.opacity})}}return l}function al(t,a,e={}){if(!t)throw Error("patternToClipPath: patternData is required");if(!a)throw Error("patternToClipPath: targetBBox is required");let i=tl(t,a,e),r=[];for(let{polygon:l,opacity:o}of i)if(o>0&&l.length>=3)if(r.length===0)r=l;else{let x=B0(r,l);if(Array.isArray(x)&&x.length>0&&Array.isArray(x[0])&&x[0].length>=3)r=x[0]}return r}function el(t,a,e={}){if(!t)throw Error("patternToPathData: patternData is required");if(!a)throw Error("patternToPathData: targetBBox is required");let i=al(t,a,e);if(!Array.isArray(i))return"";if(i.length<3)return"";let r="";for(let l=0;l<i.length;l++){let o=i[l];if(!o||typeof o.x!=="number"||typeof o.y!=="number")throw Error("patternToPathData: invalid polygon point - must have numeric x and y properties");if(!isFinite(o.x)||!isFinite(o.y))throw Error("patternToPathData: polygon point coordinates must be finite numbers");let x=Number(o.x).toFixed(6),p=Number(o.y).toFixed(6);r+=l===0?`M ${x} ${p}`:` L ${x} ${p}`}return r+=" Z",r}function il(t){if(!t)return s3.identity(3);return(void 0)(t)}h.set({precision:80});function W0(t,a,e,i=1,r=!1){if(!t)throw Error("getMarkerTransform: markerDef is required");if(!a||typeof a.x!=="number"||typeof a.y!=="number")throw Error("getMarkerTransform: position must be an object with x and y numeric properties");if(typeof e!=="number"||isNaN(e)||!isFinite(e))throw Error("getMarkerTransform: tangentAngle must be a valid finite number");if(typeof i!=="number"||isNaN(i)||i<=0)throw Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:l,markerHeight:o,refX:x,refY:p,orient:n,markerUnits:c,viewBox:s}=t;if(typeof l!=="number"||l<=0)throw Error("getMarkerTransform: markerDef.markerWidth must be a positive number");if(typeof o!=="number"||o<=0)throw Error("getMarkerTransform: markerDef.markerHeight must be a positive number");if(typeof x!=="number"||!isFinite(x))throw Error("getMarkerTransform: markerDef.refX must be a finite number");if(typeof p!=="number"||!isFinite(p))throw Error("getMarkerTransform: markerDef.refY must be a finite number");let m=s3.identity(3),g=g4(a.x,a.y);m=m.mul(g);let u=0;if(n==="auto")u=e;else if(n==="auto-start-reverse")u=r?e+Math.PI:e;else if(typeof n==="number")u=n*(Math.PI/180);if(u!==0){let C=L5(u);m=m.mul(C)}let y=1,v=1;if(c==="strokeWidth")y=i,v=i;if(s){let{width:C,height:P}=s;if(C>0&&P>0&&isFinite(C)&&isFinite(P)){let S=l/C,f=o/P;if(isFinite(S)&&isFinite(f)){let B=Math.min(S,f);y*=B,v*=B;let R=g4(-s.x,-s.y);m=m.mul(R)}}}if(y!==1||v!==1){let C=n5(y,v);m=m.mul(C)}let E=g4(-x,-p);return m=m.mul(E),m}function rl(t){if(typeof t!=="string")throw Error("getPathVertices: pathData must be a string");let a=[],e=0,i=0,r=0,l=0,o=pa(t);for(let x=0;x<o.length;x++){let p=o[x],n=e,c=i;switch(p.type){case"M":if(e=p.x,i=p.y,r=e,l=i,a.length>0){let s=a[a.length-1],m=Math.atan2(i-c,e-n);s.tangentOut=m}a.push({x:e,y:i,tangentIn:0,tangentOut:0,index:a.length});break;case"L":{e=p.x,i=p.y;let s=e-n,m=i-c,g=s===0&&m===0?a.length>0?a[a.length-1].tangentOut:0:Math.atan2(m,s);if(a.length>0)a[a.length-1].tangentOut=g;a.push({x:e,y:i,tangentIn:g,tangentOut:g,index:a.length});break}case"C":{e=p.x,i=p.y;let s=p.x1-n,m=p.y1-c,g=s===0&&m===0?Math.atan2(p.y2-c,p.x2-n):Math.atan2(m,s),u=e-p.x2,y=i-p.y2,v=u===0&&y===0?Math.atan2(i-p.y1,e-p.x1):Math.atan2(y,u);if(a.length>0)a[a.length-1].tangentOut=g;a.push({x:e,y:i,tangentIn:v,tangentOut:v,index:a.length});break}case"Q":{e=p.x,i=p.y;let s=p.x1-n,m=p.y1-c,g=s===0&&m===0?Math.atan2(i-c,e-n):Math.atan2(m,s),u=e-p.x1,y=i-p.y1,v=u===0&&y===0?Math.atan2(i-c,e-n):Math.atan2(y,u);if(a.length>0)a[a.length-1].tangentOut=g;a.push({x:e,y:i,tangentIn:v,tangentOut:v,index:a.length});break}case"A":{e=p.x,i=p.y;let s=e-n,m=i-c,g=s===0&&m===0?a.length>0?a[a.length-1].tangentOut:0:Math.atan2(m,s);if(a.length>0)a[a.length-1].tangentOut=g;a.push({x:e,y:i,tangentIn:g,tangentOut:g,index:a.length});break}case"Z":{e=r,i=l;let s=e-n,m=i-c,g=s===0&&m===0?a.length>0?a[a.length-1].tangentOut:0:Math.atan2(m,s);if(a.length>0)a[a.length-1].tangentOut=g;if(a.length>0)a[0].tangentIn=g;break}default:break}}return a}function pa(t){if(typeof t!=="string")throw Error("parsePathCommands: pathData must be a string");let a=[];if(t.trim()==="")return a;let e=t.replace(/([MmLlHhVvCcSsQqTtAaZz])/g," $1 ").trim(),i=/[MmLlHhVvCcSsQqTtAaZz]/,r=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,l=[],o=0;while(o<e.length){while(o<e.length&&/[\s,]/.test(e[o]))o++;if(o>=e.length)break;if(i.test(e[o]))l.push(e[o]),o++;else{r.lastIndex=o;let s=r.exec(e);if(s&&s.index===o)l.push(s[0]),o=r.lastIndex;else o++}}let x=0,p=0,n=0,c=(s,m)=>{if(s>=l.length)throw Error(`parsePathCommands: missing ${m} parameter at token ${s}`);let g=parseFloat(l[s]);if(isNaN(g)||!isFinite(g))throw Error(`parsePathCommands: invalid ${m} value "${l[s]}" at token ${s}`);return g};while(x<l.length){let s=l[x];switch(s.toUpperCase()){case"M":{let m=c(x+1,"M.x"),g=c(x+2,"M.y");a.push({type:"M",x:s==="M"?m:p+m,y:s==="M"?g:n+g}),p=a[a.length-1].x,n=a[a.length-1].y,x+=3;break}case"L":{let m=c(x+1,"L.x"),g=c(x+2,"L.y");a.push({type:"L",x:s==="L"?m:p+m,y:s==="L"?g:n+g}),p=a[a.length-1].x,n=a[a.length-1].y,x+=3;break}case"H":{let m=c(x+1,"H.x");a.push({type:"L",x:s==="H"?m:p+m,y:n}),p=a[a.length-1].x,x+=2;break}case"V":{let m=c(x+1,"V.y");a.push({type:"L",x:p,y:s==="V"?m:n+m}),n=a[a.length-1].y,x+=2;break}case"C":{let m=c(x+1,"C.x1"),g=c(x+2,"C.y1"),u=c(x+3,"C.x2"),y=c(x+4,"C.y2"),v=c(x+5,"C.x"),E=c(x+6,"C.y");a.push({type:"C",x1:s==="C"?m:p+m,y1:s==="C"?g:n+g,x2:s==="C"?u:p+u,y2:s==="C"?y:n+y,x:s==="C"?v:p+v,y:s==="C"?E:n+E}),p=a[a.length-1].x,n=a[a.length-1].y,x+=7;break}case"Q":{let m=c(x+1,"Q.x1"),g=c(x+2,"Q.y1"),u=c(x+3,"Q.x"),y=c(x+4,"Q.y");a.push({type:"Q",x1:s==="Q"?m:p+m,y1:s==="Q"?g:n+g,x:s==="Q"?u:p+u,y:s==="Q"?y:n+y}),p=a[a.length-1].x,n=a[a.length-1].y,x+=5;break}case"A":{let m=c(x+1,"A.rx"),g=c(x+2,"A.ry"),u=c(x+3,"A.rotation");if(x+4>=l.length||x+5>=l.length)throw Error("parsePathCommands: missing arc flag parameters");let y=parseInt(l[x+4],10),v=parseInt(l[x+5],10);if(isNaN(y)||isNaN(v))throw Error("parsePathCommands: invalid arc flag values");let E=c(x+6,"A.x"),C=c(x+7,"A.y");a.push({type:"A",rx:m,ry:g,xAxisRotation:u,largeArcFlag:y,sweepFlag:v,x:s==="A"?E:p+E,y:s==="A"?C:n+C}),p=a[a.length-1].x,n=a[a.length-1].y,x+=8;break}case"Z":a.push({type:"Z"}),x+=1;break;default:x+=1}}return a}function ll(t,a){if(!t)throw Error("resolveMarkers: pathElement is required");if(!a||typeof a!=="object")throw Error("resolveMarkers: defsMap must be an object");let e=[],i=t.getAttribute("marker-start"),r=t.getAttribute("marker-mid"),l=t.getAttribute("marker-end"),o=t.getAttribute("stroke-width")||"1",x=parseFloat(o);if(isNaN(x)||x<=0)throw Error("resolveMarkers: stroke-width must be a positive number");let p=t.getAttribute("d")||"",n=rl(p);if(n.length===0)return e;let c=(s)=>{if(!s)return null;let m=s.match(/url\(#([^)]+)\)/);return m?m[1]:null};if(i){let s=c(i),m=s?a[s]:null;if(m&&n.length>0){let g=n[0],u=n.length>1?g.tangentOut:g.tangentIn;e.push({markerDef:m,position:{x:g.x,y:g.y},transform:W0(m,{x:g.x,y:g.y},u,x,!0),type:"start",vertex:g})}}if(r&&n.length>2){let s=c(r),m=s?a[s]:null;if(m)for(let g=1;g<n.length-1;g++){let u=n[g],y=u.tangentIn,v=u.tangentOut-y;while(v>Math.PI)v-=2*Math.PI;while(v<-Math.PI)v+=2*Math.PI;let E=y+v/2;e.push({markerDef:m,position:{x:u.x,y:u.y},transform:W0(m,{x:u.x,y:u.y},E,x,!1),type:"mid",vertex:u})}}if(l){let s=c(l),m=s?a[s]:null;if(m&&n.length>0){let g=n[n.length-1],u=g.tangentIn;e.push({markerDef:m,position:{x:g.x,y:g.y},transform:W0(m,{x:g.x,y:g.y},u,x,!1),type:"end",vertex:g})}}return e}function ol(t,a={}){if(!t)throw Error("markerToPolygons: markerInstance is required");if(!t.markerDef)throw Error("markerToPolygons: markerInstance.markerDef is required");if(!t.transform)throw Error("markerToPolygons: markerInstance.transform is required");let{precision:e=2,curveSegments:i=10}=a;if(typeof e!=="number"||e<0)throw Error("markerToPolygons: precision must be a non-negative number");if(typeof i!=="number"||i<=0)throw Error("markerToPolygons: curveSegments must be a positive number");let r=[],{markerDef:l,transform:o}=t;if(!Array.isArray(l.children))throw Error("markerToPolygons: markerDef.children must be an array");for(let x of l.children){let p=[];switch(x.type){case"path":p=xl(x.d,i);break;case"rect":p=[{x:x.x,y:x.y},{x:x.x+x.width,y:x.y},{x:x.x+x.width,y:x.y+x.height},{x:x.x,y:x.y+x.height}];break;case"circle":p=nl(x.cx,x.cy,x.r,i*4);break;case"ellipse":p=pl(x.cx,x.cy,x.rx,x.ry,i*4);break;case"line":p=[{x:x.x1,y:x.y1},{x:x.x2,y:x.y2}];break;case"polygon":case"polyline":p=cl(x.points);break;default:break}if(p.length>0){let n=p.map((c)=>{let s=e4(o,c.x,c.y);return{x:parseFloat(s[0].toFixed(e)),y:parseFloat(s[1].toFixed(e))}});r.push(n)}}return r}function xl(t,a=10){if(typeof t!=="string")throw Error("pathToPoints: pathData must be a string");if(typeof a!=="number"||a<=0)throw Error("pathToPoints: segments must be a positive number");let e=[],i=pa(t),r=0,l=0;for(let o of i)switch(o.type){case"M":r=o.x,l=o.y,e.push({x:r,y:l});break;case"L":r=o.x,l=o.y,e.push({x:r,y:l});break;case"C":for(let x=1;x<=a;x++){let p=x/a,n=1-p,c=n*n*n*r+3*n*n*p*o.x1+3*n*p*p*o.x2+p*p*p*o.x,s=n*n*n*l+3*n*n*p*o.y1+3*n*p*p*o.y2+p*p*p*o.y;e.push({x:c,y:s})}r=o.x,l=o.y;break;case"Q":for(let x=1;x<=a;x++){let p=x/a,n=1-p,c=n*n*r+2*n*p*o.x1+p*p*o.x,s=n*n*l+2*n*p*o.y1+p*p*o.y;e.push({x:c,y:s})}r=o.x,l=o.y;break;case"A":r=o.x,l=o.y,e.push({x:r,y:l});break;default:break}return e}function nl(t,a,e,i=32){if(typeof t!=="number"||!isFinite(t))throw Error("circleToPoints: cx must be a finite number");if(typeof a!=="number"||!isFinite(a))throw Error("circleToPoints: cy must be a finite number");if(typeof e!=="number"||!isFinite(e)||e<0)throw Error("circleToPoints: r must be a non-negative finite number");if(typeof i!=="number"||i<=0)throw Error("circleToPoints: segments must be a positive number");let r=[];for(let l=0;l<i;l++){let o=l/i*2*Math.PI;r.push({x:t+e*Math.cos(o),y:a+e*Math.sin(o)})}return r}function pl(t,a,e,i,r=32){if(typeof t!=="number"||!isFinite(t))throw Error("ellipseToPoints: cx must be a finite number");if(typeof a!=="number"||!isFinite(a))throw Error("ellipseToPoints: cy must be a finite number");if(typeof e!=="number"||!isFinite(e)||e<0)throw Error("ellipseToPoints: rx must be a non-negative finite number");if(typeof i!=="number"||!isFinite(i)||i<0)throw Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof r!=="number"||r<=0)throw Error("ellipseToPoints: segments must be a positive number");let l=[];for(let o=0;o<r;o++){let x=o/r*2*Math.PI;l.push({x:t+e*Math.cos(x),y:a+i*Math.sin(x)})}return l}function cl(t){if(typeof t!=="string")throw Error("parsePoints: pointsStr must be a string");let a=[],e=t.trim().split(/[\s,]+/).map(Number).filter((i)=>!isNaN(i)&&isFinite(i));if(e.length%2!==0)throw Error("parsePoints: pointsStr must contain an even number of valid coordinates");for(let i=0;i<e.length;i+=2)a.push({x:e[i],y:e[i+1]});return a}function sl(t,a=2){if(!Array.isArray(t))throw Error("markersToPathData: markerInstances must be an array");if(typeof a!=="number"||a<0)throw Error("markersToPathData: precision must be a non-negative number");let e=[];for(let i of t){let r=ol(i,{precision:a});for(let l of r){if(l.length===0)continue;let o=l[0];e.push(`M ${o.x.toFixed(a)} ${o.y.toFixed(a)}`);for(let x=1;x<l.length;x++){let p=l[x];e.push(`L ${p.x.toFixed(a)} ${p.y.toFixed(a)}`)}e.push("Z")}}return e.join(" ")}h.set({precision:80});var C3=(t)=>t instanceof h?t:new h(t),W3=new h(0),C5=new h(1);function S5(){let t=h.precision;if(t<20)throw Error(`Decimal precision (${t}) is too low for verification. Minimum required: 20`);let a=Math.max(1,t-10);return new h(10).pow(-a)}function ml(t,a,e){let i=S5();if(!t)return{valid:!1,error:new h(1/0),tolerance:i,message:"Matrix parameter is null or undefined"};if(a==null||e==null)return{valid:!1,error:new h(1/0),tolerance:i,message:"Coordinates x or y are null or undefined"};let r=C3(a),l=C3(e);try{let[o,x]=e4(t,r,l),p=t.inverse();if(!p)return{valid:!1,error:new h(1/0),tolerance:i,message:"Matrix is not invertible (determinant = 0)",details:{determinant:t.determinant()}};let[n,c]=e4(p,o,x),s=r.minus(n).abs(),m=l.minus(c).abs(),g=h.max(s,m),u=g.lessThan(i);return{valid:u,error:g,tolerance:i,message:u?`Round-trip verified: error ${g.toExponential()} < tolerance ${i.toExponential()}`:`Round-trip FAILED: error ${g.toExponential()} >= tolerance ${i.toExponential()}`,details:{original:{x:r.toString(),y:l.toString()},transformed:{x:o.toString(),y:x.toString()},recovered:{x:n.toString(),y:c.toString()},errorX:s.toExponential(),errorY:m.toExponential()}}}catch(o){return{valid:!1,error:new h(1/0),tolerance:i,message:`Verification error: ${o.message}`}}}function ca(t){let a=S5();if(!t)return{valid:!1,error:new h(1/0),tolerance:a,message:"Matrix parameter is null or undefined"};try{let e=t.inverse();if(!e)return{valid:!1,error:new h(1/0),tolerance:a,message:"Matrix is singular (not invertible)",details:{determinant:t.determinant().toString()}};let i=t.mul(e),r=t.rows,l=W3,o=[];for(let p=0;p<r;p++)for(let n=0;n<r;n++){let c=p===n?C5:W3,s=i.data[p][n],m=s.minus(c).abs();if(m.greaterThan(l))l=m;if(m.greaterThanOrEqualTo(a))o.push({row:p,col:n,expected:c.toString(),actual:s.toString(),error:m.toExponential()})}let x=l.lessThan(a);return{valid:x,error:l,tolerance:a,message:x?`Matrix inversion verified: max error ${l.toExponential()} < tolerance`:`Matrix inversion FAILED: max error ${l.toExponential()} at ${o.length} positions`,details:{matrixSize:`${r}x${r}`,maxError:l.toExponential(),failedElements:o.slice(0,5)}}}catch(e){return{valid:!1,error:new h(1/0),tolerance:a,message:`Verification error: ${e.message}`}}}function F6(t,a,e=null){let i=S5(),r=e||new h("1e-6");if(!t||!Array.isArray(t))return{valid:!1,error:W3,tolerance:i,message:"Inner polygon parameter is null, undefined, or not an array"};if(!a||!Array.isArray(a))return{valid:!1,error:W3,tolerance:i,message:"Outer polygon parameter is null, undefined, or not an array"};if(t.length<3||a.length<3)return{valid:!1,error:W3,tolerance:i,message:"Polygons must have at least 3 vertices"};try{let l=!0,o=[],x=W3;for(let p=0;p<t.length;p++){let n=t[p];if(!vl(n,a)){let c=gl(n,a);if(c.greaterThan(x))x=c;if(c.greaterThan(r))l=!1,o.push({index:p,x:n.x.toString(),y:n.y.toString(),distanceOutside:c.toExponential()})}}return{valid:l,error:x,tolerance:r,message:l?`All inner polygon points are inside or within tolerance (max outside: ${x.toExponential()})`:`${o.length} points exceed tolerance distance outside outer polygon`,details:{innerVertices:t.length,outerVertices:a.length,maxOutsideDistance:x.toExponential(),outsidePoints:o.slice(0,5)}}}catch(l){return{valid:!1,error:new h(1/0),tolerance:i,message:`Verification error: ${l.message}`}}}function gl(t,a){if(!t||t.x==null||t.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!a||!Array.isArray(a)||a.length===0)throw Error("Invalid polygon parameter: must be non-empty array of points");let e=new h(1/0),i=C3(t.x),r=C3(t.y);for(let l=0;l<a.length;l++){let o=(l+1)%a.length,x=a[l],p=a[o],n=C3(x.x),c=C3(x.y),s=C3(p.x),m=C3(p.y),g=s.minus(n),u=m.minus(c),y=g.times(g).plus(u.times(u)),v;if(y.isZero())v=sa(t,x);else{let E=h.max(W3,h.min(C5,i.minus(n).times(g).plus(r.minus(c).times(u)).div(y))),C=n.plus(E.times(g)),P=c.plus(E.times(u));v=i.minus(C).pow(2).plus(r.minus(P).pow(2)).sqrt()}if(v.lessThan(e))e=v}return e}function yl(t,a,e){let i=S5();if(!t||!Array.isArray(t))return{valid:!1,error:W3,tolerance:i,message:"Poly1 parameter must be an array"};if(!a||!Array.isArray(a))return{valid:!1,error:W3,tolerance:i,message:"Poly2 parameter must be an array"};if(!e||!Array.isArray(e))return{valid:!1,error:W3,tolerance:i,message:"Intersection parameter must be an array"};if(e.length<3)return{valid:!0,error:W3,tolerance:i,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:e.length}};try{let r=F6(e,t),l=F6(e,a),o=R5(t),x=R5(a),p=R5(e),n=h.min(o,x),c=p.lessThanOrEqualTo(n.times(C5.plus(i))),s=r.valid&&l.valid&&c;return{valid:s,error:s?W3:C5,tolerance:i,message:s?"Intersection verified: contained in both polygons, area valid":`Intersection FAILED: ${!r.valid?"not in poly1, ":""}${!l.valid?"not in poly2, ":""}${!c?"area too large":""}`,details:{containedInPoly1:r.valid,containedInPoly2:l.valid,area1:o.toString(),area2:x.toString(),intersectionArea:p.toString(),areaValid:c}}}catch(r){return{valid:!1,error:new h(1/0),tolerance:i,message:`Verification error: ${r.message}`}}}function hl(t,a,e){let i=S5();if(!t||typeof t!=="object")return{valid:!1,error:new h(1/0),tolerance:i,message:"Original gradient parameter must be an object"};if(!a||typeof a!=="object")return{valid:!1,error:new h(1/0),tolerance:i,message:"Baked gradient parameter must be an object"};if(!e)return{valid:!1,error:new h(1/0),tolerance:i,message:"Matrix parameter is null or undefined"};try{let[r,l]=e4(e,C3(t.x1||0),C3(t.y1||0)),[o,x]=e4(e,C3(t.x2||1),C3(t.y2||0)),p=C3(a.x1).minus(r).abs(),n=C3(a.y1).minus(l).abs(),c=C3(a.x2).minus(o).abs(),s=C3(a.y2).minus(x).abs(),m=h.max(p,n,c,s),g=m.lessThan(i);return{valid:g,error:m,tolerance:i,message:g?`Linear gradient transform verified: max error ${m.toExponential()}`:`Linear gradient transform FAILED: max error ${m.toExponential()}`,details:{expected:{x1:r.toString(),y1:l.toString(),x2:o.toString(),y2:x.toString()},actual:a}}}catch(r){return{valid:!1,error:new h(1/0),tolerance:i,message:`Verification error: ${r.message}`}}}function R5(t){if(!t||!Array.isArray(t))throw Error("Invalid polygon parameter: must be an array");if(t.length<3)return W3;let a=W3,e=t.length;for(let i=0;i<e;i++){let r=(i+1)%e,l=C3(t[i].x),o=C3(t[i].y),x=C3(t[r].x),p=C3(t[r].y);a=a.plus(l.times(p).minus(x.times(o)))}return a.abs().div(2)}function vl(t,a){if(!t||t.x==null||t.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!a||!Array.isArray(a)||a.length===0)throw Error("Invalid polygon parameter: must be non-empty array of points");let e=C3(t.x),i=C3(t.y),r=a.length,l=!1;for(let o=0,x=r-1;o<r;x=o++){let p=C3(a[o].x),n=C3(a[o].y),c=C3(a[x].x),s=C3(a[x].y);if(ul(t,a[o],a[x]))return!0;if(n.greaterThan(i)!==s.greaterThan(i)&&e.lessThan(c.minus(p).times(i.minus(n)).div(s.minus(n)).plus(p)))l=!l}return l}function ul(t,a,e){if(!t||t.x==null||t.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!a||a.x==null||a.y==null)throw Error("Invalid segStart parameter: must have x and y properties");if(!e||e.x==null||e.y==null)throw Error("Invalid segEnd parameter: must have x and y properties");let i=S5(),r=C3(t.x),l=C3(t.y),o=C3(a.x),x=C3(a.y),p=C3(e.x),n=C3(e.y),c=h.min(o,p).minus(i),s=h.max(o,p).plus(i),m=h.min(x,n).minus(i),g=h.max(x,n).plus(i);if(r.lessThan(c)||r.greaterThan(s)||l.lessThan(m)||l.greaterThan(g))return!1;let u=p.minus(o).times(l.minus(x)).minus(n.minus(x).times(r.minus(o))).abs(),y=sa(a,e);return u.div(y.plus(i)).lessThan(i)}function sa(t,a){if(!t||t.x==null||t.y==null)throw Error("Invalid p1 parameter: must have x and y properties");if(!a||a.x==null||a.y==null)throw Error("Invalid p2 parameter: must have x and y properties");let e=C3(a.x).minus(C3(t.x)),i=C3(a.y).minus(C3(t.y));return e.times(e).plus(i.times(i)).sqrt()}function El(t,a){if(!t||t.length<3||!a||a.length<3)return[];let e=[];for(let i=0;i<a.length;i++){let r=a[i],l=a[(i+1)%a.length],o=[];for(let x=0;x<t.length;x++){let p=t[x],n=t[(x+1)%t.length],c=!G6(p,r,l),s=!G6(n,r,l);if(c){if(o.push(p),!s)o.push(j6(p,n,r,l))}else if(s)o.push(j6(p,n,r,l))}if(o.length>=3)e.push(o)}return e}function Cl(t,a,e=[],i="1e-10"){let r=i instanceof h?i:new h(i),l=e||[];if(!t||!Array.isArray(t))return{valid:!1,error:new h(1/0),tolerance:r,message:"Original polygon parameter must be an array"};if(!a||!Array.isArray(a))return{valid:!1,error:new h(1/0),tolerance:r,message:"Clipped polygon parameter must be an array"};try{let o=R5(t),x=a.length>=3?R5(a):W3,p=o.minus(x),n=x.lessThanOrEqualTo(o.times(C5.plus(r))),c=p.greaterThanOrEqualTo(W3.minus(r.times(o))),s=o.isZero()?C5:x.div(o),m=W3,g=n&&c;return{valid:g,error:m,tolerance:r,message:g?`ClipPath E2E verified: area conserved (clipped ${s.times(100).toFixed(2)}% of original)`:"ClipPath E2E FAILED: invalid intersection (clipped > original or negative outside)",details:{originalArea:o.toString(),clippedArea:x.toString(),outsideArea:p.toString(),areaRatio:s.toFixed(6),fragmentCount:l.length,clippedValid:n,outsideValid:c}}}catch(o){return{valid:!1,error:new h(1/0),tolerance:r,message:`E2E verification error: ${o.message}`}}}function G6(t,a,e){if(!t||t.x==null||t.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!a||a.x==null||a.y==null)throw Error("Invalid edgeStart parameter: must have x and y properties");if(!e||e.x==null||e.y==null)throw Error("Invalid edgeEnd parameter: must have x and y properties");let i=C3(t.x).toNumber(),r=C3(t.y).toNumber(),l=C3(a.x).toNumber(),o=C3(a.y).toNumber(),x=C3(e.x).toNumber(),p=C3(e.y).toNumber();return(x-l)*(r-o)-(p-o)*(i-l)>=0}function j6(t,a,e,i){if(!t||t.x==null||t.y==null)throw Error("Invalid p1 parameter: must have x and y properties");if(!a||a.x==null||a.y==null)throw Error("Invalid p2 parameter: must have x and y properties");if(!e||e.x==null||e.y==null)throw Error("Invalid p3 parameter: must have x and y properties");if(!i||i.x==null||i.y==null)throw Error("Invalid p4 parameter: must have x and y properties");let r=C3(t.x).toNumber(),l=C3(t.y).toNumber(),o=C3(a.x).toNumber(),x=C3(a.y).toNumber(),p=C3(e.x).toNumber(),n=C3(e.y).toNumber(),c=C3(i.x).toNumber(),s=C3(i.y).toNumber(),m=(r-o)*(n-s)-(l-x)*(p-c);if(Math.abs(m)<0.0000000001)return{x:C3((r+o)/2),y:C3((l+x)/2)};let g=((r-p)*(n-s)-(l-n)*(p-c))/m;return{x:C3(r+g*(o-r)),y:C3(l+g*(x-l))}}var bl=["animate","animateTransform","animateMotion","animateColor","set"],W6=["href","xlink:href"],z6=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],Pl=["begin","end"],Sl=["values","from","to","by"];function p2(t){if(!t||typeof t!=="string")return null;let a=t.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return a&&a[1]?a[1]:null}function H6(t){if(!t||typeof t!=="string")return null;if(t.startsWith("#")){let a=t.substring(1);return a&&!a.startsWith("#")?a:null}return null}function Tl(t){if(!t||typeof t!=="string")return[];let a=[],e=t.split(";");for(let i of e){let r=i.trim();if(r.startsWith("#")){let o=r.substring(1);if(o)a.push(o)}let l=p2(r);if(l)a.push(l)}return a}function Al(t){if(!t||typeof t!=="string")return[];let a=[],e=t.split(";");for(let i of e){let r=i.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\.(begin|end|click|mousedown|mouseup|mouseover|mouseout|mousemove|mouseenter|mouseleave|focusin|focusout|activate|repeat)(?:[+-]\d+(?:\.\d+)?[a-z]*)?/);if(r)a.push(r[1])}return a}function X2(t){if(!t||typeof t!=="string")return[];let a=[],e=/url\(\s*["']?#([^"')]+)["']?\s*\)/g,i;while((i=e.exec(t))!==null)if(i[1])a.push(i[1]);return a}function fl(t){if(!t||typeof t!=="string")return[];let a=[],e=/getElementById\(\s*["']([^"']+)["']\s*\)/g,i;while((i=e.exec(t))!==null)if(i[1])a.push(i[1]);let r=/querySelector(?:All)?\(\s*["']#([^"'#\s]+)["']\s*\)/g;while((i=r.exec(t))!==null)if(i[1])a.push(i[1]);return a}function dl(t){if(!t||typeof t!=="object"||!(t instanceof T3))throw TypeError("collectElementReferences: el must be a valid SVGElement");if(typeof t.getAttributeNames!=="function")throw TypeError("collectElementReferences: el must have getAttributeNames method");let a={static:new Set,animation:new Set,css:new Set,js:new Set},e=t.tagName?.toLowerCase()||"",i=bl.includes(e),r=t.getAttributeNames();if(!Array.isArray(r))throw TypeError("collectElementReferences: getAttributeNames must return an array");for(let l of r){let o=t.getAttribute(l);if(!o)continue;if(W6.includes(l)){let x=H6(o);if(x)if(i)a.animation.add(x);else a.static.add(x)}if(z6.includes(l)||l==="style"){let x=p2(o);if(x)a.static.add(x);if(l==="style")X2(o).forEach((p)=>a.css.add(p))}if(Pl.includes(l))Al(o).forEach((x)=>a.animation.add(x));if(Sl.includes(l))Tl(o).forEach((x)=>a.animation.add(x));if(!z6.includes(l)&&o.includes("url(")){let x=p2(o);if(x)a.static.add(x)}}if(e==="animatemotion"){if(typeof t.getElementsByTagName!=="function")throw TypeError("collectElementReferences: el must have getElementsByTagName method");let l=t.getElementsByTagName("mpath");if(!l||typeof l[Symbol.iterator]!=="function")throw TypeError("collectElementReferences: getElementsByTagName must return an iterable");for(let o of l){if(!o||typeof o.getAttribute!=="function")continue;for(let x of W6){let p=o.getAttribute(x),n=H6(p);if(n)a.animation.add(n)}}}return a}function Nl(t){if(!t||typeof t!=="object"||!(t instanceof T3))throw TypeError("collectAllReferences: root must be a valid SVGElement");let a={all:new Set,static:new Set,animation:new Set,css:new Set,js:new Set,details:new Map},e={animation:4,js:3,css:2,static:1},i=(l,o,x)=>{if(a.all.add(l),a[o].add(l),!a.details.has(l))a.details.set(l,{sources:[],type:o});else{let p=a.details.get(l);if(e[o]>e[p.type])p.type=o}a.details.get(l).sources.push(x)},r=(l,o="")=>{let x=l.tagName?.toLowerCase()||"",p=o?`${o}>${x}`:x,n=l.getAttribute("id"),c=n?`${x}#${n}`:p,s=dl(l);if(s.static.forEach((m)=>i(m,"static",c)),s.animation.forEach((m)=>i(m,"animation",c)),s.css.forEach((m)=>i(m,"css",c)),s.js.forEach((m)=>i(m,"js",c)),x==="style"){let m=l.textContent||"";X2(m).forEach((g)=>i(g,"css","<style>"))}if(x==="script"){let m=l.textContent||"";fl(m).forEach((g)=>i(g,"js","<script>"))}if(l.children&&typeof l.children[Symbol.iterator]==="function"){for(let m of l.children)if(m instanceof T3)r(m,p)}};return r(t),a}h.set({precision:80});var E4=(t)=>t instanceof h?t:new h(t),Il={precision:6,curveSegments:20,clipSegments:64,bezierArcs:8,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,preserveIds:!1,svg2Polyfills:!1,e2eTolerance:"1e-10"};function _5(t,a={}){if(t===null||t===void 0)throw Error("flattenSVG: svgString parameter is required");if(typeof t!=="string")throw Error(`flattenSVG: svgString must be a string, got ${typeof t}`);if(t.trim().length===0)throw Error("flattenSVG: svgString cannot be empty");let e={...Il,...a},i={useResolved:0,markersResolved:0,patternsResolved:0,masksResolved:0,clipPathsApplied:0,transformsFlattened:0,gradientsProcessed:0,defsRemoved:0,errors:[],verifications:{transforms:[],matrices:[],polygons:[],gradients:[],e2e:[],passed:0,failed:0,allPassed:!0},clipOutsideFragments:[]};try{let r=_3(t);if(r.tagName.toLowerCase()!=="svg")throw Error("Root element must be <svg>");let l=K4(r),o=e.removeUnusedDefs?Ol(r):null;if(e.resolveUse){let x=Bl(r,l,e);i.useResolved=x.count,i.errors.push(...x.errors),l=K4(r)}if(e.resolveMarkers){let x=Dl(r,l,e);i.markersResolved=x.count,i.errors.push(...x.errors)}if(e.resolvePatterns){let x=Rl(r,l,e);i.patternsResolved=x.count,i.errors.push(...x.errors)}if(e.resolveMasks){let x=wl(r,l,e);i.masksResolved=x.count,i.errors.push(...x.errors)}if(e.resolveClipPaths){let x=Ll(r,l,e,i);i.clipPathsApplied=x.count,i.errors.push(...x.errors)}if(e.flattenTransforms){let x=kl(r,e,i);i.transformsFlattened=x.count,i.errors.push(...x.errors)}if(e.bakeGradients){let x=Xl(r,e,i);i.gradientsProcessed=x.count,i.errors.push(...x.errors)}if(e.removeUnusedDefs&&o){let x=Vl(r,o);i.defsRemoved=x.count}return{svg:C4(r),stats:i}}catch(r){return i.errors.push(`Pipeline error: ${r.message}`),{svg:t,stats:i}}}var ma=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),ga=new Set(["foreignobject","audio","video","iframe","script","style",...ma]);function c2(t){if(!t)return!1;let a=t.tagName?.toLowerCase();if(ga.has(a))return!0;for(let e of t.children||[])if(e&&e.tagName&&c2(e))return!0;return!1}function Bl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("resolveAllUseElements: invalid root element");if(!a||!(a instanceof Map))throw Error("resolveAllUseElements: defsMap must be a Map");if(!e||typeof e!=="object")throw Error("resolveAllUseElements: opts must be an object");let i=[],r=0,l=t.getElementsByTagName("use"),o={};for(let[x,p]of a.entries())if(p.tagName.toLowerCase()==="symbol")o[x]=jr(p),o[x].type="symbol";else o[x]=Y2(p);for(let x of[...l])try{let p=x.getAttribute("href")||x.getAttribute("xlink:href");if(!p)continue;let n=p.replace(/^#/,""),c=a.get(n);if(!c){i.push(`use: referenced element #${n} not found`);continue}let s=c2(c),m=c2(x);if(s||m){let v=c.cloneNode(!0),E=parseFloat(x.getAttribute("x")||"0"),C=parseFloat(x.getAttribute("y")||"0");if(isNaN(E)||isNaN(C)){i.push(`use: invalid x/y coordinates for element #${n}`);continue}let P=x.getAttribute("transform")||"",S="";if(P)S=P;if(E!==0||C!==0){let R=`translate(${E}, ${C})`;S=S?`${S} ${R}`:R}let f=new T3("g",{});if(S)f.setAttribute("transform",S);let B=X5(x);for(let[R,k]of Object.entries(B))if(k&&!f.hasAttribute(R))f.setAttribute(R,k);if(c.tagName.toLowerCase()==="symbol"){for(let R of v.children||[])if(R&&R.tagName)f.appendChild(R.cloneNode(!0))}else v.removeAttribute("id"),f.appendChild(v);for(let R of x.children||[])if(R&&R.tagName){let k=R.tagName.toLowerCase();if(ma.has(k))f.appendChild(R.cloneNode(!0))}if(x.parentNode)x.parentNode.replaceChild(f,x),r++;continue}let g=Gr(x),u=xa(g,o,{samples:e.curveSegments});if(!u){i.push(`use: failed to resolve #${n}`);continue}let y=Qr(u,e.curveSegments);if(y){let v=new T3("path",{d:y,...X5(x)});if(u.style){for(let[E,C]of Object.entries(u.style))if(C&&!v.hasAttribute(E))v.setAttribute(E,C)}if(x.parentNode)x.parentNode.replaceChild(v,x),r++}}catch(p){i.push(`use: ${p.message}`)}return{count:r,errors:i}}function Dl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("resolveAllMarkers: invalid root element");if(!a||!(a instanceof Map))throw Error("resolveAllMarkers: defsMap must be a Map");if(!e||typeof e!=="object")throw Error("resolveAllMarkers: opts must be an object");let i=[],r=0,l=["marker-start","marker-mid","marker-end","marker"];for(let o of l){let x=V4(t,o);for(let p of x){if(p.tagName!=="path"&&p.tagName!=="line"&&p.tagName!=="polyline"&&p.tagName!=="polygon")continue;try{let n=ll(p,Object.fromEntries(a));if(!n||n.length===0)continue;let c=sl(n,e.precision);if(c){let s=new T3("path",{d:c,fill:p.getAttribute("stroke")||"currentColor"});if(p.parentNode){let m=p.nextSibling;if(m)p.parentNode.insertBefore(s,m);else p.parentNode.appendChild(s);r++}}for(let s of l)p.removeAttribute(s)}catch(n){i.push(`marker: ${n.message}`)}}}return{count:r,errors:i}}function Rl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("resolveAllPatterns: invalid root element");if(!a||!(a instanceof Map))throw Error("resolveAllPatterns: defsMap must be a Map");if(!e||typeof e!=="object")throw Error("resolveAllPatterns: opts must be an object");let i=[],r=0,l=V4(t,"fill");for(let o of l){let x=o.getAttribute("fill");if(!x||!x.includes("url("))continue;let p=Z4(x);if(!p)continue;let n=a.get(p);if(!n||n.tagName.toLowerCase()!=="pattern")continue;try{let c=n.getAttribute("patternUnits")||"objectBoundingBox",s=n.getAttribute("patternContentUnits")||"userSpaceOnUse",m=n.getAttribute("patternTransform");if(c!=="objectBoundingBox")i.push(`pattern ${p}: non-default patternUnits="${c}" may cause rendering issues`);if(s!=="userSpaceOnUse")i.push(`pattern ${p}: non-default patternContentUnits="${s}" may cause rendering issues`);if(m)i.push(`pattern ${p}: patternTransform present - complex transformation may cause rendering issues`);let g=ya(o);if(!g)continue;let u=qr(n),y=el(u,g,{samples:e.curveSegments});if(y){let v=new T3("g",{}),E=new T3("path",{d:y,fill:"#000"});if(v.appendChild(E),o.setAttribute("fill","none"),o.setAttribute("stroke",o.getAttribute("stroke")||"none"),o.parentNode)o.parentNode.insertBefore(v,o),r++}}catch(c){i.push(`pattern: ${c.message}`)}}return{count:r,errors:i}}function wl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("resolveAllMasks: invalid root element");if(!a||!(a instanceof Map))throw Error("resolveAllMasks: defsMap must be a Map");if(!e||typeof e!=="object")throw Error("resolveAllMasks: opts must be an object");let i=[],r=0,l=V4(t,"mask");for(let o of l){let x=o.getAttribute("mask");if(!x||!x.includes("url("))continue;let p=Z4(x);if(!p)continue;let n=a.get(p);if(!n||n.tagName.toLowerCase()!=="mask")continue;try{let c=n.getAttribute("maskUnits")||"objectBoundingBox",s=n.getAttribute("maskContentUnits")||"userSpaceOnUse";if(c!=="objectBoundingBox")i.push(`mask ${p}: non-default maskUnits="${c}" may cause rendering issues`);if(s!=="userSpaceOnUse")i.push(`mask ${p}: non-default maskContentUnits="${s}" may cause rendering issues`);let m=ya(o);if(!m)continue;let g=Xr(n),u=Fr(g,m,{samples:e.curveSegments,opacityThreshold:0.5});if(u){let y=b5(o,e.precision);if(y){let v=p5(y,e.curveSegments),E=p5(u,e.curveSegments),C=ha(v,E);if(C&&C.length>2){let P=la(C,e.precision);o.setAttribute("d",P),o.removeAttribute("mask"),r++}}}}catch(c){i.push(`mask: ${c.message}`)}}return{count:r,errors:i}}function Ll(t,a,e,i){if(!t||!t.getElementsByTagName)throw Error("applyAllClipPaths: invalid root element");if(!a||!(a instanceof Map))throw Error("applyAllClipPaths: defsMap must be a Map");if(!e||typeof e!=="object")throw Error("applyAllClipPaths: opts must be an object");if(!i||typeof i!=="object")throw Error("applyAllClipPaths: stats must be an object");let r=[],l=0;if(!i.verifications.e2e)i.verifications.e2e=[];if(!i.clipOutsideFragments)i.clipOutsideFragments=[];let o=V4(t,"clip-path");for(let x of o){let p=x.getAttribute("clip-path");if(!p||!p.includes("url("))continue;let n=Z4(p);if(!n)continue;let c=a.get(n),s=c?c.tagName.toLowerCase():"";if(!c||s!=="clippath")continue;try{if((c.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")r.push(`clipPath ${n}: objectBoundingBox units require bbox-relative coordinate transformation`);let m=b5(x,e.precision);if(!m)continue;let g="";if(c.children&&c.children.length>0){for(let S of c.children)if(S&&S.tagName){let f=b5(S,e.precision);if(f)g+=(g?" ":"")+f}}if(!g)continue;let u=e.clipSegments||64,y=p5(m,u),v=p5(g,u),E=ha(y,v),C=y.map((S)=>({x:S.x instanceof h?S.x:E4(S.x),y:S.y instanceof h?S.y:E4(S.y)})),P=v.map((S)=>({x:S.x instanceof h?S.x:E4(S.x),y:S.y instanceof h?S.y:E4(S.y)}));if(E&&E.length>2){let S=E.map((N)=>({x:N.x instanceof h?N.x:E4(N.x),y:N.y instanceof h?N.y:E4(N.y)})),f=yl(C,P,S);if(i.verifications.polygons.push({element:x.tagName,clipPathId:n,...f}),f.valid)i.verifications.passed++;else i.verifications.failed++,i.verifications.allPassed=!1;let B=El(C,P);i.clipOutsideFragments.push({elementId:x.getAttribute("id")||`clip-${l}`,clipPathId:n,fragments:B,visible:!1});let R=e.e2eTolerance||"1e-10",k=Cl(C,S,B,R);if(i.verifications.e2e.push({element:x.tagName,clipPathId:n,type:"clip-area-conservation",...k}),k.valid)i.verifications.passed++;else i.verifications.failed++,i.verifications.allPassed=!1}if(E&&E.length>2){let S=la(E,e.precision),f=x;if(x.tagName==="path")x.setAttribute("d",S);else{let B=new T3("path",{d:S,...X5(x)});if(x.parentNode)x.parentNode.replaceChild(B,x),f=B}f.removeAttribute("clip-path"),l++}}catch(m){r.push(`clipPath: ${m.message}`)}}return{count:l,errors:r}}function kl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("flattenAllTransforms: invalid root element");if(!a||typeof a!=="object")throw Error("flattenAllTransforms: opts must be an object");if(!e||typeof e!=="object")throw Error("flattenAllTransforms: stats must be an object");let i=[],r=0,l=V4(t,"transform");for(let o of l){let x=o.getAttribute("transform");if(!x)continue;try{let p=X4(x),n=ca(p);if(e.verifications.matrices.push({element:o.tagName,transform:x,...n}),n.valid)e.verifications.passed++;else e.verifications.failed++,e.verifications.allPassed=!1;let c=b5(o,a.precision);if(!c){if(o.tagName==="g")Yl(o,p,a,e),o.removeAttribute("transform"),r++;continue}let s=[],m=p5(c,4);if(m&&m.length>0)s=m.slice(0,4).map((y)=>({x:y.x instanceof h?y.x:E4(y.x),y:y.y instanceof h?y.y:E4(y.y)}));let g=c0(c,p,{precision:a.precision});for(let y=0;y<s.length;y++){let v=s[y],E=ml(p,v.x,v.y);if(e.verifications.transforms.push({element:o.tagName,pointIndex:y,...E}),E.valid)e.verifications.passed++;else e.verifications.failed++,e.verifications.allPassed=!1}let u=o;if(o.tagName==="path")o.setAttribute("d",g);else{let y=new T3("path",{d:g,...X5(o)});for(let v of Ul(o.tagName))y.removeAttribute(v);if(o.parentNode)o.parentNode.replaceChild(y,o),u=y}u.removeAttribute("transform"),r++}catch(p){i.push(`transform: ${p.message}`)}}return{count:r,errors:i}}function Yl(t,a,e,i){if(!t||!t.children)throw Error("propagateTransformToChildren: invalid group element");if(!a||!a.data)throw Error("propagateTransformToChildren: invalid matrix");if(!e||typeof e!=="object")throw Error("propagateTransformToChildren: opts must be an object");if(!i||typeof i!=="object")throw Error("propagateTransformToChildren: stats must be an object");for(let r of[...t.children]){if(!(r&&r.tagName))continue;if(r.tagName==="g"){let l=r.getAttribute("transform");if(l){let o=X4(l),x=a.mul(o);r.setAttribute("transform",Q6(x))}else r.setAttribute("transform",Q6(a))}else{let l=b5(r,e.precision);if(l){let o=r.getAttribute("transform"),x=a;if(o){let s=X4(o);x=a.mul(s)}let p=ca(x);if(i.verifications.matrices.push({element:r.tagName,context:"group-propagation",...p}),p.valid)i.verifications.passed++;else i.verifications.failed++,i.verifications.allPassed=!1;let n=c0(l,x,{precision:e.precision}),c=r;if(r.tagName==="path")r.setAttribute("d",n);else{let s=new T3("path",{d:n,...X5(r)});t.replaceChild(s,r),c=s}c.removeAttribute("transform")}}}}function Xl(t,a,e){if(!t||!t.getElementsByTagName)throw Error("bakeAllGradientTransforms: invalid root element");if(!a||typeof a!=="object")throw Error("bakeAllGradientTransforms: opts must be an object");if(!e||typeof e!=="object")throw Error("bakeAllGradientTransforms: stats must be an object");let i=[],r=0,l=t.getElementsByTagName("linearGradient");for(let x of l){let p=x.getAttribute("gradientTransform");if(!p)continue;try{let n=X4(p),c=parseFloat(x.getAttribute("x1")||"0"),s=parseFloat(x.getAttribute("y1")||"0"),m=parseFloat(x.getAttribute("x2")||"1"),g=parseFloat(x.getAttribute("y2")||"0");if(isNaN(c)||isNaN(s)||isNaN(m)||isNaN(g)){i.push(`linearGradient: invalid coordinate values for gradient ${x.getAttribute("id")||"unknown"}`);continue}let[u,y]=e4(n,c,s),[v,E]=e4(n,m,g),C=hl({x1:c,y1:s,x2:m,y2:g},{x1:u.toNumber(),y1:y.toNumber(),x2:v.toNumber(),y2:E.toNumber()},n);if(e.verifications.gradients.push({gradientId:x.getAttribute("id")||"unknown",type:"linear",...C}),C.valid)e.verifications.passed++;else e.verifications.failed++,e.verifications.allPassed=!1;x.setAttribute("x1",u.toFixed(a.precision)),x.setAttribute("y1",y.toFixed(a.precision)),x.setAttribute("x2",v.toFixed(a.precision)),x.setAttribute("y2",E.toFixed(a.precision)),x.removeAttribute("gradientTransform"),r++}catch(n){i.push(`linearGradient: ${n.message}`)}}let o=t.getElementsByTagName("radialGradient");for(let x of o){let p=x.getAttribute("gradientTransform");if(!p)continue;try{let n=X4(p),c=parseFloat(x.getAttribute("cx")||"0.5"),s=parseFloat(x.getAttribute("cy")||"0.5"),m=parseFloat(x.getAttribute("fx")||c.toString()),g=parseFloat(x.getAttribute("fy")||s.toString()),u=parseFloat(x.getAttribute("r")||"0.5");if(isNaN(c)||isNaN(s)||isNaN(m)||isNaN(g)||isNaN(u)){i.push(`radialGradient: invalid coordinate/radius values for gradient ${x.getAttribute("id")||"unknown"}`);continue}if(u<=0){i.push(`radialGradient: radius must be positive for gradient ${x.getAttribute("id")||"unknown"}`);continue}let[y,v]=e4(n,c,s),[E,C]=e4(n,m,g),P=n.data[0][0].toNumber()*n.data[1][1].toNumber();if(Math.abs(P)<0.0000000001){i.push("radialGradient: matrix determinant too close to zero (degenerate transform)");continue}let S=Math.sqrt(Math.abs(P)),f=u*S;x.setAttribute("cx",y.toFixed(a.precision)),x.setAttribute("cy",v.toFixed(a.precision)),x.setAttribute("fx",E.toFixed(a.precision)),x.setAttribute("fy",C.toFixed(a.precision)),x.setAttribute("r",f.toFixed(a.precision)),x.removeAttribute("gradientTransform"),r++}catch(n){i.push(`radialGradient: ${n.message}`)}}return{count:r,errors:i}}function Ol(t){if(!t||!t.getElementsByTagName)throw Error("collectAllReferences: invalid root element");let a=new Set,e=(i)=>{if(!i||!i.getAttributeNames)return;if(i.tagName&&i.tagName.toLowerCase()==="style"){let r=i.textContent||"";if(r)X2(r).forEach((l)=>a.add(l))}for(let r of i.getAttributeNames()){let l=i.getAttribute(r);if(!l)continue;if(l.includes("url(")){let o=Z4(l);if(o)a.add(o)}if(r==="href"||r==="xlink:href"){let o=l.replace(/^#/,"");if(o&&o!==l)a.add(o)}}for(let r of i.children)if(r&&r.tagName)e(r)};return e(t),a}function Vl(t,a){if(!t||!t.getElementsByTagName)throw Error("removeUnusedDefinitions: invalid root element");if(!a||!(a instanceof Set))throw Error("removeUnusedDefinitions: referencedIds must be a Set");let e=0;function i(l){if(!l||!l.getAttribute)return!1;let o=l.getAttribute("id");if(o&&a.has(o))return!0;for(let x of l.children||[])if(x&&x.tagName&&i(x))return!0;return!1}let r=t.getElementsByTagName("defs");for(let l of r)for(let o of[...l.children])if(o&&o.tagName){let x=o.tagName.toLowerCase();if(ga.has(x))continue;if(!i(o))l.removeChild(o),e++}return{count:e}}function b5(t,a){if(!t||!t.tagName)return null;if(typeof a!=="number"||isNaN(a)||a<0)throw Error(`getElementPathData: precision must be a non-negative number, got ${a}`);let e=t.tagName.toLowerCase();if(e==="path")return t.getAttribute("d");let i=(r,l=0)=>{let o=t.getAttribute(r);if(o===null)return l;let x=parseFloat(o);if(isNaN(x))throw Error(`getElementPathData: invalid numeric value "${o}" for attribute "${r}"`);return x};switch(e){case"rect":{let r=t.getAttribute("ry")!==null?i("ry"):null;return S2(i("x"),i("y"),i("width"),i("height"),i("rx"),r,!1,a)}case"circle":return b2(i("cx"),i("cy"),i("r"),a);case"ellipse":return P2(i("cx"),i("cy"),i("rx"),i("ry"),a);case"line":return T2(i("x1"),i("y1"),i("x2"),i("y2"),a);case"polyline":return f0(t.getAttribute("points")||"",a);case"polygon":return A2(t.getAttribute("points")||"",a);default:return null}}function ya(t){if(!t||!t.tagName)return null;let a=b5(t,6);if(!a)return null;try{let e=p5(a,10);if(!e||e.length===0)return null;let i=1/0,r=1/0,l=-1/0,o=-1/0;for(let x of e){if(!x||x.x===void 0&&x.y===void 0)continue;let p=x.x instanceof h?x.x.toNumber():typeof x.x==="number"?x.x:0,n=x.y instanceof h?x.y.toNumber():typeof x.y==="number"?x.y:0;if(isNaN(p)||isNaN(n))continue;if(p<i)i=p;if(n<r)r=n;if(p>l)l=p;if(n>o)o=n}if(i===1/0||l===-1/0||r===1/0||o===-1/0)return null;return{x:i,y:r,width:l-i,height:o-r}}catch{return null}}function X5(t){if(!t||!t.getAttribute)return{};let a=["stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","vector-effect","fill","fill-opacity","fill-rule","clip-path","mask","filter","opacity","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display","color","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","letter-spacing","word-spacing","text-decoration","shape-rendering","text-rendering","image-rendering","color-rendering","paint-order","pointer-events","cursor","class","style","id"],e={};for(let i of a){let r=t.getAttribute(i);if(r!==null)e[i]=r}return e}function Ul(t){if(!t||typeof t!=="string")return[];return{rect:["x","y","width","height","rx","ry"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],polyline:["points"],polygon:["points"],image:["x","y","width","height","href","xlink:href","preserveAspectRatio"]}[t.toLowerCase()]||[]}function Q6(t){if(!t||!t.data||!Array.isArray(t.data))throw Error("matrixToTransform: invalid matrix");if(!t.data[0]||!t.data[1]||!t.data[0][0]||!t.data[0][1]||!t.data[0][2]||!t.data[1][0]||!t.data[1][1]||!t.data[1][2])throw Error("matrixToTransform: matrix is missing required elements");let a=t.data[0][0].toNumber(),e=t.data[1][0].toNumber(),i=t.data[0][1].toNumber(),r=t.data[1][1].toNumber(),l=t.data[0][2].toNumber(),o=t.data[1][2].toNumber();if(!isFinite(a)||!isFinite(e)||!isFinite(i)||!isFinite(r)||!isFinite(l)||!isFinite(o))throw Error("matrixToTransform: matrix contains non-finite values");return`matrix(${a} ${e} ${i} ${r} ${l} ${o})`}function ha(t,a){if(!t||t.length<3||!a||a.length<3)return t;if(f2&&s0)try{return s0(t,a)}catch(i){}let e=[...t];for(let i=0;i<a.length;i++){if(e.length===0)break;let r=e;e=[];let l=a[i],o=a[(i+1)%a.length];for(let x=0;x<r.length;x++){let p=r[x],n=r[(x+1)%r.length],c=q6(p,l,o),s=q6(n,l,o);if(c){if(e.push(p),!s)e.push(K6(p,n,l,o))}else if(s)e.push(K6(p,n,l,o))}}return e}function q6(t,a,e){if(!t||t.x===void 0&&t.y===void 0)throw Error("isInsideEdge: invalid point");if(!a||a.x===void 0&&a.y===void 0)throw Error("isInsideEdge: invalid edgeStart");if(!e||e.x===void 0&&e.y===void 0)throw Error("isInsideEdge: invalid edgeEnd");let i=t.x instanceof h?t.x.toNumber():t.x||0,r=t.y instanceof h?t.y.toNumber():t.y||0,l=a.x instanceof h?a.x.toNumber():a.x||0,o=a.y instanceof h?a.y.toNumber():a.y||0,x=e.x instanceof h?e.x.toNumber():e.x||0,p=e.y instanceof h?e.y.toNumber():e.y||0;return(x-l)*(r-o)-(p-o)*(i-l)>=0}function K6(t,a,e,i){if(!t||t.x===void 0&&t.y===void 0)throw Error("lineIntersect: invalid p1");if(!a||a.x===void 0&&a.y===void 0)throw Error("lineIntersect: invalid p2");if(!e||e.x===void 0&&e.y===void 0)throw Error("lineIntersect: invalid p3");if(!i||i.x===void 0&&i.y===void 0)throw Error("lineIntersect: invalid p4");let r=t.x instanceof h?t.x.toNumber():t.x||0,l=t.y instanceof h?t.y.toNumber():t.y||0,o=a.x instanceof h?a.x.toNumber():a.x||0,x=a.y instanceof h?a.y.toNumber():a.y||0,p=e.x instanceof h?e.x.toNumber():e.x||0,n=e.y instanceof h?e.y.toNumber():e.y||0,c=i.x instanceof h?i.x.toNumber():i.x||0,s=i.y instanceof h?i.y.toNumber():i.y||0,m=(r-o)*(n-s)-(l-x)*(p-c);if(Math.abs(m)<0.0000000001)return{x:E4((r+o)/2),y:E4((l+x)/2)};let g=((r-p)*(n-s)-(l-n)*(p-c))/m;return{x:E4(r+g*(o-r)),y:E4(l+g*(x-l))}}var P5=new Set(["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","dominant-baseline","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","marker","marker-end","marker-mid","marker-start","paint-order","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","visibility","word-spacing","writing-mode"]),a0={animation:new Set(["animate","animateColor","animatecolor","animateMotion","animatemotion","animateTransform","animatetransform","set"]),descriptive:new Set(["desc","metadata","title"]),shape:new Set(["circle","ellipse","line","path","polygon","polyline","rect"]),structural:new Set(["defs","g","svg","symbol","use"]),paintServer:new Set(["hatch","linearGradient","lineargradient","meshGradient","meshgradient","pattern","radialGradient","radialgradient","solidColor","solidcolor"]),nonRendering:new Set(["clipPath","clippath","filter","linearGradient","lineargradient","marker","mask","pattern","radialGradient","radialgradient","solidColor","solidcolor","symbol"]),container:new Set(["a","defs","g","marker","mask","pattern","svg","switch","symbol"]),textContent:new Set(["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","text","textPath","tref","tspan"]),filterPrimitive:new Set(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),lightSource:new Set(["feDistantLight","fePointLight","feSpotLight"])},h0={svg:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),g:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),defs:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view","meshgradient","meshGradient","hatch","solidcolor","solidColor"]),symbol:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),marker:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),clipPath:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","text","title","use"]),mask:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),pattern:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),a:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),switch:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","cursor","desc","ellipse","foreignObject","g","image","line","metadata","path","polygon","polyline","rect","set","svg","switch","text","title","use","view"]),text:new Set(["a","altGlyph","animate","animateColor","animateMotion","animateTransform","desc","metadata","set","textPath","title","tref","tspan"]),textPath:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),tspan:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),linearGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),radialGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),meshgradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshGradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshrow:new Set(["meshpatch"]),meshpatch:new Set(["stop"]),hatch:new Set(["animate","animateTransform","desc","hatchpath","hatchPath","metadata","script","set","style","title"]),hatchpath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),hatchPath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),filter:new Set(["animate","animateTransform","desc","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","metadata","set","title"]),feBlend:new Set(["animate","set"]),feColorMatrix:new Set(["animate","set"]),feComponentTransfer:new Set(["feFuncA","feFuncB","feFuncG","feFuncR"]),feComposite:new Set(["animate","set"]),feConvolveMatrix:new Set(["animate","set"]),feDiffuseLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feDisplacementMap:new Set(["animate","set"]),feDropShadow:new Set(["animate","set"]),feFlood:new Set(["animate","set"]),feFuncA:new Set(["animate","set"]),feFuncB:new Set(["animate","set"]),feFuncG:new Set(["animate","set"]),feFuncR:new Set(["animate","set"]),feGaussianBlur:new Set(["animate","set"]),feImage:new Set(["animate","set"]),feMerge:new Set(["feMergeNode"]),feMergeNode:new Set(["animate","set"]),feMorphology:new Set(["animate","set"]),feOffset:new Set(["animate","set"]),feSpecularLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feTile:new Set(["animate","set"]),feTurbulence:new Set(["animate","set"]),animate:new Set(["desc","metadata","title"]),animateColor:new Set(["desc","metadata","title"]),animateMotion:new Set(["desc","metadata","mpath","title"]),animateTransform:new Set(["desc","metadata","title"]),set:new Set(["desc","metadata","title"]),circle:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),ellipse:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),line:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),path:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polygon:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polyline:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),rect:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),image:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),use:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),title:new Set([]),desc:new Set([]),metadata:new Set([]),feDistantLight:new Set(["animate","set"]),fePointLight:new Set(["animate","set"]),feSpotLight:new Set(["animate","set"]),stop:new Set(["animate","set"]),solidColor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),solidcolor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),tref:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyph:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyphDef:new Set(["altGlyphItem"]),altGlyphItem:new Set(["glyphRef","altGlyphItem"]),glyph:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","title","use"]),glyphRef:new Set([]),foreignObject:new Set([]),style:new Set([]),script:new Set([]),view:new Set(["desc","metadata","title"]),mpath:new Set(["desc","metadata","title"])},Ml={userAction:new Set([":hover",":active",":focus",":focus-within",":focus-visible"]),treeStructural:new Set([":root",":empty",":first-child",":last-child",":only-child",":first-of-type",":last-of-type",":only-of-type",":nth-child",":nth-last-child",":nth-of-type",":nth-last-of-type"]),link:new Set([":link",":visited",":any-link",":local-link",":target"]),input:new Set([":enabled",":disabled",":read-only",":read-write",":placeholder-shown",":default",":checked",":indeterminate",":valid",":invalid",":in-range",":out-of-range",":required",":optional"]),linguistic:new Set([":lang",":dir"]),functional:new Set([":not",":is",":where",":has"]),preventInlining:new Set([":hover",":active",":focus",":focus-within",":focus-visible",":visited",":target",":lang",":dir",":not",":is",":where",":has"])};h.set({precision:20,rounding:h.ROUND_HALF_UP});var va={linear:[0,0,1,1],ease:[0.25,0.1,0.25,1],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]};function D0(t,a=3){if(t===null||t===void 0)throw Error("formatSplineValue: value parameter is required");if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("formatSplineValue: precision must be a non-negative finite number");let e=typeof t==="number"?t:parseFloat(t);if(!Number.isFinite(e))throw Error(`formatSplineValue: value must be a finite number, got ${t}`);let i=new h(t).toDecimalPlaces(a).toString();if(i.includes("."))i=i.replace(/\.?0+$/,"");if(i.startsWith("0."))i=i.substring(1);else if(i.startsWith("-0."))i="-"+i.substring(2);if(i===""||i==="."||i==="-0")i="0";return i}function O2(t){if(!t||typeof t!=="string")return[];return t.split(";").map((a)=>a.trim()).filter((a)=>a).map((a)=>{let e=a.split(/[\s,]+/).map((i)=>parseFloat(i)).filter((i)=>Number.isFinite(i));if(e.length!==4)throw Error(`parseKeySplines: invalid spline "${a}", expected 4 values, got ${e.length}`);return e})}function ua(t,a=3){if(!Array.isArray(t))throw Error("serializeKeySplines: splines must be an array");if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("serializeKeySplines: precision must be a non-negative finite number");return t.map((e,i)=>{if(!Array.isArray(e))throw Error(`serializeKeySplines: spline at index ${i} must be an array`);if(e.length!==4)throw Error(`serializeKeySplines: spline at index ${i} must have exactly 4 values, got ${e.length}`);return e.map((r)=>D0(r,a)).join(" ")}).join("; ")}function V2(t,a=0.001){if(!Array.isArray(t)||t.length!==4)return!1;if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("isLinearSpline: tolerance must be a non-negative finite number");let[e,i,r,l]=t;if(!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(l))return!1;return Math.abs(e)<a&&Math.abs(i)<a&&Math.abs(r-1)<a&&Math.abs(l-1)<a}function _l(t){let a=O2(t);if(a.length===0)return!1;return a.every((e)=>V2(e))}function Ea(t,a=0.01){if(!Array.isArray(t)||t.length!==4)return null;if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("identifyStandardEasing: tolerance must be a non-negative finite number");if(!t.every((e)=>Number.isFinite(e)))return null;for(let[e,i]of Object.entries(va))if(t.every((r,l)=>Math.abs(r-i[l])<a))return e;return null}function Ca(t,a={}){let e=a.precision??3,i=a.removeLinear!==!1,r=O2(t);if(r.length===0)return{value:null,allLinear:!1,standardEasings:[]};let l=r.every((x)=>V2(x)),o=r.map((x)=>Ea(x)).filter(Boolean);if(l&&i)return{value:null,allLinear:!0,standardEasings:o};return{value:ua(r,e),allLinear:l,standardEasings:o}}function Fl(t){if(!t||typeof t!=="string")return[];return t.split(";").map((a)=>parseFloat(a.trim())).filter((a)=>Number.isFinite(a))}function Gl(t,a=3){if(!Array.isArray(t))throw Error("serializeKeyTimes: times must be an array");if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("serializeKeyTimes: precision must be a non-negative finite number");if(t.length===0)return"";return t.map((e)=>D0(e,a)).join("; ")}function ba(t,a=3){if(t===null||t===void 0)throw Error("optimizeKeyTimes: keyTimes parameter is required");if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("optimizeKeyTimes: precision must be a non-negative finite number");let e=Fl(t);if(e.length===0)return t;return Gl(e,a)}function s2(t,a=3){if(!t||typeof t!=="string")return t;if(typeof a!=="number"||a<0||!Number.isFinite(a))throw Error("optimizeAnimationValues: precision must be a non-negative finite number");let e=t.split(";");if(e.length===0)return t;return e.map((i)=>{let r=i.trim();if(r.startsWith("#")||r.includes("url("))return r;return r.split(/[\s,]+/).filter((l)=>l).map((l)=>{let o=parseFloat(l);if(!Number.isFinite(o))return l;return D0(o,a)}).join(" ")}).join("; ")}function jl(t,a={}){if(!t||typeof t!=="object")throw Error("optimizeElementTiming: el parameter must be a valid element");if(typeof t.getAttribute!=="function"||typeof t.setAttribute!=="function"||typeof t.removeAttribute!=="function")throw Error("optimizeElementTiming: el parameter must have getAttribute, setAttribute, and removeAttribute methods");let e=a.precision??3,i=a.removeLinearSplines!==!1,r=a.optimizeValues!==!1;if(typeof e!=="number"||e<0||!Number.isFinite(e))throw Error("optimizeElementTiming: options.precision must be a non-negative finite number");let l=[],o=!1,x=t.getAttribute("keySplines");if(x){let n=Ca(x,{precision:e,removeLinear:i});if(n.allLinear&&i){if(t.getAttribute("calcMode")==="spline")t.setAttribute("calcMode","linear"),t.removeAttribute("keySplines"),l.push('Converted linear splines to calcMode="linear"'),o=!0}else if(n.value&&n.value!==x)t.setAttribute("keySplines",n.value),l.push(`keySplines: "${x}" -> "${n.value}"`),o=!0}let p=t.getAttribute("keyTimes");if(p){let n=ba(p,e);if(n!==p)t.setAttribute("keyTimes",n),l.push(`keyTimes: "${p}" -> "${n}"`),o=!0}if(r){let n=t.getAttribute("values");if(n){let c=s2(n,e);if(c!==n)t.setAttribute("values",c),l.push(`values: "${n}" -> "${c}"`),o=!0}}for(let n of["from","to","by"]){let c=t.getAttribute(n);if(c){let s=s2(c,e);if(s!==c)t.setAttribute(n,s),l.push(`${n}: "${c}" -> "${s}"`),o=!0}}return{modified:o,changes:l}}var Wl=["animate","animatetransform","animatemotion","animatecolor","set"];function zl(t,a={}){if(!t||typeof t!=="object")throw Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let e=0,i=0,r=[],l=(o)=>{if(!o||typeof o!=="object")return;let x=o.tagName?.toLowerCase();if(!x)return;if(Wl.includes(x)){let n=jl(o,a);if(n.modified)e++,i+=n.changes.length,r.push({element:x,id:o.getAttribute("id")||null,changes:n.changes})}let p=o.children||[];for(let n of p)l(n)};return l(t),{elementsModified:e,totalChanges:i,details:r}}h.set({precision:80});var U2={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function Hl(t){if(typeof t!=="string")throw TypeError(`parseArcArgs: argsStr must be a string, got ${typeof t}`);let a=[],e=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,i=0,r=0;while(i<t.length){while(i<t.length&&/[\s,]/.test(t[i]))i++;if(i>=t.length)break;let l=r%7;if(l===3||l===4)if(t[i]==="0"||t[i]==="1")a.push(t[i]==="1"?1:0),i++,r++;else return null;else{e.lastIndex=i;let o=e.exec(t);if(o&&o.index===i)a.push(parseFloat(o[0])),i=e.lastIndex,r++;else i++}}return a}function H3(t){if(!t||typeof t!=="string")return[];let a=[],e=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,i;while((i=e.exec(t))!==null){let r=i[1],l=i[2].trim();if(r==="Z"||r==="z"){a.push({command:"Z",args:[]});let p=l.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g);if(p&&p.length>=2){a.push({command:"M",args:[parseFloat(p[0]),parseFloat(p[1])]});for(let n=2;n+1<p.length;n+=2)a.push({command:"L",args:[parseFloat(p[n]),parseFloat(p[n+1])]})}continue}let o;if(r==="A"||r==="a"){if(o=Hl(l),o===null){console.warn(`Invalid arc command with malformed flags - skipping: ${r}${l}`);continue}for(let p=0;p<o.length;p+=7)if(p+6<o.length)o[p]=Math.abs(o[p]),o[p+1]=Math.abs(o[p+1])}else{let p=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;o=[];let n;while((n=p.exec(l))!==null)o.push(parseFloat(n[0]))}let x=U2[r];if(x===void 0){console.warn(`Unknown SVG path command '${r}' - skipping`);continue}if(x===0||o.length===0)a.push({command:r,args:[]});else for(let p=0;p<o.length;p+=x){let n=o.slice(p,p+x);if(n.length===x){let c=p>0&&(r==="M"||r==="m")?r==="M"?"L":"l":r;a.push({command:c,args:n})}else if(n.length>0)console.warn(`Incomplete ${r} command: expected ${x} args, got ${n.length} - remaining args dropped`)}}return a}function W4(t,a=3){if(typeof t!=="number")throw TypeError(`formatNumber: num must be a number, got ${typeof t}`);if(typeof a!=="number"||!Number.isInteger(a)||a<0)throw TypeError(`formatNumber: precision must be a non-negative integer, got ${a}`);if(!isFinite(t))return"0";if(t===0)return"0";let e=Math.pow(10,a),i=(Math.round(t*e)/e).toFixed(a);if(i.includes("."))i=i.replace(/\.?0+$/,"");if(i.startsWith("0."))i=i.substring(1);else if(i.startsWith("-0."))i="-"+i.substring(2);if(i===""||i==="."||i==="-.")i="0";return i}function T4(t,a,e){if(!t||typeof t!=="object")throw TypeError(`toAbsolute: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`toAbsolute: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("toAbsolute: cmd.args must be an array");if(typeof a!=="number"||!isFinite(a))throw TypeError(`toAbsolute: cx must be a finite number, got ${a}`);if(typeof e!=="number"||!isFinite(e))throw TypeError(`toAbsolute: cy must be a finite number, got ${e}`);let{command:i,args:r}=t;if(i===i.toUpperCase()){if(U2[i]===void 0)throw TypeError(`toAbsolute: unknown command '${i}'`);return t}let l=i.toUpperCase(),o=[...r];switch(i){case"m":case"l":case"t":if(o.length<2)throw RangeError(`toAbsolute: command ${i} requires at least 2 args, got ${o.length}`);o[0]+=a,o[1]+=e;break;case"h":if(o.length<1)throw RangeError(`toAbsolute: command ${i} requires at least 1 arg, got ${o.length}`);o[0]+=a;break;case"v":if(o.length<1)throw RangeError(`toAbsolute: command ${i} requires at least 1 arg, got ${o.length}`);o[0]+=e;break;case"c":if(o.length<6)throw RangeError(`toAbsolute: command ${i} requires at least 6 args, got ${o.length}`);o[0]+=a,o[1]+=e,o[2]+=a,o[3]+=e,o[4]+=a,o[5]+=e;break;case"s":case"q":if(o.length<4)throw RangeError(`toAbsolute: command ${i} requires at least 4 args, got ${o.length}`);o[0]+=a,o[1]+=e,o[2]+=a,o[3]+=e;break;case"a":if(o.length<7)throw RangeError(`toAbsolute: command ${i} requires at least 7 args, got ${o.length}`);o[5]+=a,o[6]+=e;break;default:throw TypeError(`toAbsolute: unsupported command '${i}' for conversion`)}return{command:l,args:o}}function Pa(t,a,e){if(!t||typeof t!=="object")throw TypeError(`toRelative: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`toRelative: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("toRelative: cmd.args must be an array");if(typeof a!=="number"||!isFinite(a))throw TypeError(`toRelative: cx must be a finite number, got ${a}`);if(typeof e!=="number"||!isFinite(e))throw TypeError(`toRelative: cy must be a finite number, got ${e}`);let{command:i,args:r}=t;if(i===i.toLowerCase()&&i!=="z"){if(U2[i]===void 0)throw TypeError(`toRelative: unknown command '${i}'`);return t}if(i==="Z"||i==="z")return{command:"z",args:[]};let l=i.toLowerCase(),o=[...r];switch(i){case"M":case"L":case"T":if(o.length<2)throw RangeError(`toRelative: command ${i} requires at least 2 args, got ${o.length}`);o[0]-=a,o[1]-=e;break;case"H":if(o.length<1)throw RangeError(`toRelative: command ${i} requires at least 1 arg, got ${o.length}`);o[0]-=a;break;case"V":if(o.length<1)throw RangeError(`toRelative: command ${i} requires at least 1 arg, got ${o.length}`);o[0]-=e;break;case"C":if(o.length<6)throw RangeError(`toRelative: command ${i} requires at least 6 args, got ${o.length}`);o[0]-=a,o[1]-=e,o[2]-=a,o[3]-=e,o[4]-=a,o[5]-=e;break;case"S":case"Q":if(o.length<4)throw RangeError(`toRelative: command ${i} requires at least 4 args, got ${o.length}`);o[0]-=a,o[1]-=e,o[2]-=a,o[3]-=e;break;case"A":if(o.length<7)throw RangeError(`toRelative: command ${i} requires at least 7 args, got ${o.length}`);o[5]-=a,o[6]-=e;break;default:throw TypeError(`toRelative: unsupported command '${i}' for conversion`)}return{command:l,args:o}}function Ql(t,a,e,i=0.000001){if(!t||typeof t!=="object")throw TypeError(`lineToHV: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`lineToHV: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("lineToHV: cmd.args must be an array");if(typeof a!=="number"||!isFinite(a))throw TypeError(`lineToHV: cx must be a finite number, got ${a}`);if(typeof e!=="number"||!isFinite(e))throw TypeError(`lineToHV: cy must be a finite number, got ${e}`);if(typeof i!=="number"||!isFinite(i)||i<0)throw TypeError(`lineToHV: tolerance must be a non-negative finite number, got ${i}`);let{command:r,args:l}=t;if(r!=="L"&&r!=="l")return null;if(l.length<2)throw RangeError(`lineToHV: command ${r} requires at least 2 args, got ${l.length}`);let o=r==="L",x=o?l[0]:a+l[0],p=o?l[1]:e+l[1];if(Math.abs(p-e)<i)return o?{command:"H",args:[x]}:{command:"h",args:[x-a]};if(Math.abs(x-a)<i)return o?{command:"V",args:[p]}:{command:"v",args:[p-e]};return null}function ql(t,a,e,i,r,l=0.000001){if(!t||typeof t!=="object")throw TypeError(`lineToZ: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`lineToZ: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("lineToZ: cmd.args must be an array");if(typeof a!=="number"||!isFinite(a))throw TypeError(`lineToZ: cx must be a finite number, got ${a}`);if(typeof e!=="number"||!isFinite(e))throw TypeError(`lineToZ: cy must be a finite number, got ${e}`);if(typeof i!=="number"||!isFinite(i))throw TypeError(`lineToZ: startX must be a finite number, got ${i}`);if(typeof r!=="number"||!isFinite(r))throw TypeError(`lineToZ: startY must be a finite number, got ${r}`);if(typeof l!=="number"||!isFinite(l)||l<0)throw TypeError(`lineToZ: tolerance must be a non-negative finite number, got ${l}`);let{command:o,args:x}=t;if(o!=="L"&&o!=="l")return!1;if(x.length<2)throw RangeError(`lineToZ: command ${o} requires at least 2 args, got ${x.length}`);let p=o==="L",n=p?x[0]:a+x[0],c=p?x[1]:e+x[1];return Math.abs(n-i)<l&&Math.abs(c-r)<l}function Kl(t,a,e,i,r,l,o,x,p=0.5){let n={x0:t,y0:a,cp1x:e,cp1y:i,cp2x:r,cp2y:l,x3:o,y3:x,tolerance:p};for(let[u,y]of Object.entries(n))if(typeof y!=="number"||!isFinite(y))throw TypeError(`isCurveStraight: ${u} must be a finite number, got ${y}`);if(p<0)throw TypeError(`isCurveStraight: tolerance must be non-negative, got ${p}`);let c=(o-t)**2+(x-a)**2;if(c<0.0000000001){let u=Math.sqrt((e-t)**2+(i-a)**2),y=Math.sqrt((r-t)**2+(l-a)**2);return Math.max(u,y)<p}let s=Math.sqrt(c),m=Math.abs((x-a)*e-(o-t)*i+o*a-x*t)/s,g=Math.abs((x-a)*r-(o-t)*l+o*a-x*t)/s;return Math.max(m,g)<p}function Zl(t,a,e,i=0.5){if(!t||typeof t!=="object")throw TypeError(`straightCurveToLine: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`straightCurveToLine: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("straightCurveToLine: cmd.args must be an array");if(typeof a!=="number"||!isFinite(a))throw TypeError(`straightCurveToLine: cx must be a finite number, got ${a}`);if(typeof e!=="number"||!isFinite(e))throw TypeError(`straightCurveToLine: cy must be a finite number, got ${e}`);if(typeof i!=="number"||!isFinite(i)||i<0)throw TypeError(`straightCurveToLine: tolerance must be a non-negative finite number, got ${i}`);let{command:r,args:l}=t;if(r!=="C"&&r!=="c")return null;if(l.length<6)throw RangeError(`straightCurveToLine: command ${r} requires at least 6 args, got ${l.length}`);let o=r==="C",x=o?l[0]:a+l[0],p=o?l[1]:e+l[1],n=o?l[2]:a+l[2],c=o?l[3]:e+l[3],s=o?l[4]:a+l[4],m=o?l[5]:e+l[5];if(Kl(a,e,x,p,n,c,s,m,i))return o?{command:"L",args:[s,m]}:{command:"l",args:[s-a,m-e]};return null}function m2(t,a,e=3,i=!1){if(!t||typeof t!=="object")throw TypeError(`serializeCommand: cmd must be an object, got ${typeof t}`);if(typeof t.command!=="string")throw TypeError(`serializeCommand: cmd.command must be a string, got ${typeof t.command}`);if(!Array.isArray(t.args))throw TypeError("serializeCommand: cmd.args must be an array");if(a!==null&&typeof a!=="string")throw TypeError(`serializeCommand: prevCommand must be a string or null, got ${typeof a}`);if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw TypeError(`serializeCommand: precision must be a non-negative integer, got ${e}`);if(typeof i!=="boolean")throw TypeError(`serializeCommand: prevLastArgHadDecimal must be a boolean, got ${typeof i}`);let{command:r,args:l}=t;if(r==="Z"||r==="z")return{str:"z",lastArgHadDecimal:!1};if(r==="A"||r==="a"){if(l.length<7)throw RangeError(`serializeCommand: arc command requires at least 7 args, got ${l.length}`);if(l.length>7)console.warn(`serializeCommand: arc command has ${l.length} args (expected 7) - only first 7 will be used`);let c=[W4(l[0],e),W4(l[1],e),W4(l[2],e),l[3]?"1":"0",l[4]?"1":"0",W4(l[5],e),W4(l[6],e)].join(" ");return{str:r+c,lastArgHadDecimal:c.includes(".")}}if(l.length===0)throw RangeError(`serializeCommand: command ${r} has empty args array (only Z/z should have no args)`);let o=l.map((c)=>W4(c,e)),x="";for(let c=0;c<o.length;c++){let s=o[c];if(c===0)x=s;else{let m=o[c-1].includes(".");if(s.startsWith("-"))x+=s;else if(s.startsWith(".")&&m)x+=s;else x+=" "+s}}let p=(o[o.length-1]||"").includes("."),n=r;if(a==="M"&&r==="L")n="";else if(a==="m"&&r==="l")n="";else if(a===r&&r!=="A"&&r!=="a")n="";if(n)return{str:n+x,lastArgHadDecimal:p};else{let c=o[0]||"";if(c.startsWith("-"))return{str:x,lastArgHadDecimal:p};else if(c.startsWith(".")&&i)return{str:x,lastArgHadDecimal:p};else return{str:" "+x,lastArgHadDecimal:p}}}function Q3(t,a=3){if(!Array.isArray(t))throw TypeError(`serializePath: commands must be an array, got ${typeof t}`);if(typeof a!=="number"||!Number.isInteger(a)||a<0)throw TypeError(`serializePath: precision must be a non-negative integer, got ${a}`);if(t.length===0)return"";let e="",i=null,r=!1;for(let l of t){let{str:o,lastArgHadDecimal:x}=m2(l,i,a,r);e+=o,i=l.command,r=x}return e}function Sa(t,a={}){if(typeof t!=="string")throw TypeError(`convertPathData: d must be a string, got ${typeof t}`);if(typeof a!=="object"||a===null||Array.isArray(a))throw TypeError(`convertPathData: options must be an object, got ${typeof a}`);let{floatPrecision:e=3,straightCurves:i=!0,lineShorthands:r=!0,convertToZ:l=!0,utilizeAbsolute:o=!0,straightTolerance:x=0.5}=a;if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw TypeError(`convertPathData: floatPrecision must be a non-negative integer, got ${e}`);if(typeof i!=="boolean")throw TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof i}`);if(typeof r!=="boolean")throw TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof r}`);if(typeof l!=="boolean")throw TypeError(`convertPathData: convertToZ must be a boolean, got ${typeof l}`);if(typeof o!=="boolean")throw TypeError(`convertPathData: utilizeAbsolute must be a boolean, got ${typeof o}`);if(typeof x!=="number"||!isFinite(x)||x<0)throw TypeError(`convertPathData: straightTolerance must be a non-negative finite number, got ${x}`);let p=t.length,n=H3(t);if(n.length===0)return{d:t,originalLength:p,optimizedLength:p,savings:0};let c=0,s=0,m=0,g=0,u=[];for(let v=0;v<n.length;v++){let E=n[v];if(E.command==="A"||E.command==="a"){if(E.args.length<7)console.warn(`Arc command has insufficient args (${E.args.length} < 7) - skipping optimization`);else if(E.args[0]===0||E.args[1]===0){let P=E.command==="A",S=E.args[5],f=E.args[6];E=P?{command:"L",args:[S,f]}:{command:"l",args:[S,f]}}}if(i&&(E.command==="C"||E.command==="c")){let P=Zl(E,c,s,x);if(P)E=P}if(r&&(E.command==="L"||E.command==="l")){let P=Ql(E,c,s);if(P)E=P}if(l&&(E.command==="L"||E.command==="l")){if(ql(E,c,s,m,g))E={command:"z",args:[]}}if(o&&E.command!=="Z"&&E.command!=="z"){let P=T4(E,c,s),S=Pa(E,c,s),f=m2(P,null,e);E=m2(S,null,e).str.length<f.str.length?S:P}u.push(E);let C=T4(E,c,s);switch(C.command){case"M":if(C.args.length>=2)c=C.args[0],s=C.args[1],m=c,g=s;break;case"L":case"T":if(C.args.length>=2)c=C.args[0],s=C.args[1];break;case"H":if(C.args.length>=1)c=C.args[0];break;case"V":if(C.args.length>=1)s=C.args[0];break;case"C":if(C.args.length>=6)c=C.args[4],s=C.args[5];break;case"S":case"Q":if(C.args.length>=4)c=C.args[2],s=C.args[3];break;case"A":if(C.args.length>=7)c=C.args[5],s=C.args[6];break;case"Z":c=m,s=g;break;default:break}}let y=Q3(u,e);return{d:y,originalLength:p,optimizedLength:y.length,savings:p-y.length}}function Jl(t,a={}){if(!t||typeof t!=="object")throw TypeError(`optimizeDocumentPaths: root must be a DOM element object, got ${typeof t}`);if(typeof a!=="object"||a===null||Array.isArray(a))throw TypeError(`optimizeDocumentPaths: options must be an object, got ${typeof a}`);let e=0,i=0,r=[],l=(o)=>{if(!o||typeof o!=="object")return;if(o.tagName?.toLowerCase()==="path"){let x=o.getAttribute("d");if(x){let p=Sa(x,a);if(p.savings>0)o.setAttribute("d",p.d),e++,i+=p.savings,r.push({id:o.getAttribute("id")||null,originalLength:p.originalLength,optimizedLength:p.optimizedLength,savings:p.savings})}}for(let x of o.children||[])l(x)};return l(t),{pathsOptimized:e,totalSavings:i,details:r}}function Ta(t,a,e){if(!t||typeof t.x!=="number"||typeof t.y!=="number")throw TypeError("perpendicularDistance: point must be an object with numeric x and y properties");if(!a||typeof a.x!=="number"||typeof a.y!=="number")throw TypeError("perpendicularDistance: lineStart must be an object with numeric x and y properties");if(!e||typeof e.x!=="number"||typeof e.y!=="number")throw TypeError("perpendicularDistance: lineEnd must be an object with numeric x and y properties");if(!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(a.x)||!Number.isFinite(a.y)||!Number.isFinite(e.x)||!Number.isFinite(e.y))throw RangeError("perpendicularDistance: all coordinates must be finite numbers");let i=e.x-a.x,r=e.y-a.y,l=i*i+r*r;if(l<0.0000000001){let p=t.x-a.x,n=t.y-a.y;return Math.sqrt(p*p+n*n)}let o=Math.abs(r*t.x-i*t.y+e.x*a.y-e.y*a.x),x=Math.sqrt(l);return o/x}function v0(t,a){if(!Array.isArray(t))throw TypeError("douglasPeucker: points must be an array");if(t.length===0)throw RangeError("douglasPeucker: points array cannot be empty");for(let o=0;o<t.length;o++){let x=t[o];if(!x||typeof x!=="object")throw TypeError(`douglasPeucker: point at index ${o} must be an object`);if(typeof x.x!=="number"||!Number.isFinite(x.x))throw TypeError(`douglasPeucker: point at index ${o} must have a finite numeric x property`);if(typeof x.y!=="number"||!Number.isFinite(x.y))throw TypeError(`douglasPeucker: point at index ${o} must have a finite numeric y property`)}if(typeof a!=="number"||!Number.isFinite(a))throw TypeError("douglasPeucker: tolerance must be a finite number");if(a<0)throw RangeError("douglasPeucker: tolerance cannot be negative");if(a>0&&a<0.0000000001)throw RangeError("douglasPeucker: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(t.length<=2)return t;if(t.length>1e4)return $l(t,a);let e=0,i=0,r=t[0],l=t[t.length-1];for(let o=1;o<t.length-1;o++){let x=Ta(t[o],r,l);if(x>e)e=x,i=o}if(e>a){let o=v0(t.slice(0,i+1),a),x=v0(t.slice(i),a);return o.slice(0,-1).concat(x)}else return[r,l]}function $l(t,a){if(t.length<=2)return t;let e=Array(t.length).fill(!1);e[0]=!0,e[t.length-1]=!0;let i=[[0,t.length-1]];while(i.length>0){let[r,l]=i.pop();if(l-r<=1)continue;let o=0,x=r,p=t[r],n=t[l];for(let c=r+1;c<l;c++){let s=Ta(t[c],p,n);if(s>o)o=s,x=c}if(o>a)e[x]=!0,i.push([r,x]),i.push([x,l])}return t.filter((r,l)=>e[l])}function Aa(t,a){if(!Array.isArray(t))throw TypeError("visvalingamWhyatt: points must be an array");if(t.length===0)throw RangeError("visvalingamWhyatt: points array cannot be empty");for(let x=0;x<t.length;x++){let p=t[x];if(!p||typeof p!=="object")throw TypeError(`visvalingamWhyatt: point at index ${x} must be an object`);if(typeof p.x!=="number"||!Number.isFinite(p.x))throw TypeError(`visvalingamWhyatt: point at index ${x} must have a finite numeric x property`);if(typeof p.y!=="number"||!Number.isFinite(p.y))throw TypeError(`visvalingamWhyatt: point at index ${x} must have a finite numeric y property`)}if(typeof a!=="number"||!Number.isFinite(a))throw TypeError("visvalingamWhyatt: minArea must be a finite number");if(a<0)throw RangeError("visvalingamWhyatt: minArea cannot be negative");if(t.length<=2)return t;let e=(x,p,n)=>{return Math.abs((p.x-x.x)*(n.y-x.y)-(n.x-x.x)*(p.y-x.y))/2},i=t.map((x,p)=>({...x,index:p})),r=Array(i.length).fill(1/0);for(let x=1;x<i.length-1;x++)r[x]=e(i[x-1],i[x],i[x+1]);let l=Array(i.length).fill(!0),o=i.length;while(o>2){let x=1/0,p=-1;for(let s=1;s<i.length-1;s++)if(l[s]&&r[s]<x)x=r[s],p=s;if(x>=a||p===-1)break;l[p]=!1,o--;let n=p-1;while(n>=0&&!l[n])n--;let c=p+1;while(c<i.length&&!l[c])c++;if(n>0){let s=n-1;while(s>=0&&!l[s])s--;if(s>=0&&c<i.length)r[n]=e(i[s],i[n],i[c])}if(c<i.length-1){let s=c+1;while(s<i.length&&!l[s])s++;if(s<i.length&&n>=0)r[c]=e(i[n],i[c],i[s])}}return i.filter((x,p)=>l[p])}function fa(t,a,e="douglas-peucker"){if(!Array.isArray(t))throw TypeError("simplifyPolyline: points must be an array");if(t.length===0)throw RangeError("simplifyPolyline: points array cannot be empty");if(typeof a!=="number"||!Number.isFinite(a))throw TypeError("simplifyPolyline: tolerance must be a finite number");if(a<0)throw RangeError("simplifyPolyline: tolerance cannot be negative");if(a>0&&a<0.0000000001)throw RangeError("simplifyPolyline: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(typeof e!=="string")throw TypeError("simplifyPolyline: algorithm must be a string");let i=["douglas-peucker","visvalingam"];if(!i.includes(e))throw RangeError(`simplifyPolyline: algorithm must be one of: ${i.join(", ")}`);if(e==="visvalingam")return Aa(t,a*a);return v0(t,a)}function to(t){if(!Array.isArray(t))throw TypeError("extractPolylinePoints: commands must be an array");let a=[],e=0,i=0,r=0,l=0;for(let o of t){if(!o||typeof o!=="object")throw TypeError("extractPolylinePoints: each command must be an object");if(typeof o.command!=="string")throw TypeError('extractPolylinePoints: each command must have a string "command" property');if(!Array.isArray(o.args))throw TypeError('extractPolylinePoints: each command must have an "args" array');let{command:x,args:p}=o,n=(s)=>{if(p.length<s)throw RangeError(`extractPolylinePoints: command "${x}" requires at least ${s} arguments, got ${p.length}`)},c=(s)=>{if(typeof p[s]!=="number"||!Number.isFinite(p[s]))throw TypeError(`extractPolylinePoints: command "${x}" argument at index ${s} must be a finite number, got ${p[s]}`)};switch(x){case"M":n(2),c(0),c(1),e=p[0],i=p[1],r=e,l=i,a.push({x:e,y:i});break;case"m":n(2),c(0),c(1),e+=p[0],i+=p[1],r=e,l=i,a.push({x:e,y:i});break;case"L":n(2),c(0),c(1),e=p[0],i=p[1],a.push({x:e,y:i});break;case"l":n(2),c(0),c(1),e+=p[0],i+=p[1],a.push({x:e,y:i});break;case"H":n(1),c(0),e=p[0],a.push({x:e,y:i});break;case"h":n(1),c(0),e+=p[0],a.push({x:e,y:i});break;case"V":n(1),c(0),i=p[0],a.push({x:e,y:i});break;case"v":n(1),c(0),i+=p[0],a.push({x:e,y:i});break;case"Z":case"z":if(e!==r||i!==l)a.push({x:r,y:l});e=r,i=l;break;case"C":n(6),c(4),c(5),e=p[4],i=p[5];break;case"c":n(6),c(4),c(5),e+=p[4],i+=p[5];break;case"S":case"Q":n(4),c(2),c(3),e=p[2],i=p[3];break;case"s":case"q":n(4),c(2),c(3),e+=p[2],i+=p[3];break;case"T":n(2),c(0),c(1),e=p[0],i=p[1];break;case"t":n(2),c(0),c(1),e+=p[0],i+=p[1];break;case"A":n(7),c(5),c(6),e=p[5],i=p[6];break;case"a":n(7),c(5),c(6),e+=p[5],i+=p[6];break;default:break}}return a}function ao(t,a=!1){if(!Array.isArray(t))throw TypeError("rebuildPathFromPoints: points must be an array");if(t.length===0)return[];if(typeof a!=="boolean")throw TypeError("rebuildPathFromPoints: closed must be a boolean");for(let i=0;i<t.length;i++){let r=t[i];if(!r||typeof r!=="object")throw TypeError(`rebuildPathFromPoints: point at index ${i} must be an object`);if(typeof r.x!=="number"||!Number.isFinite(r.x))throw TypeError(`rebuildPathFromPoints: point at index ${i} must have a finite numeric x property`);if(typeof r.y!=="number"||!Number.isFinite(r.y))throw TypeError(`rebuildPathFromPoints: point at index ${i} must have a finite numeric y property`)}let e=[];e.push({command:"M",args:[t[0].x,t[0].y]});for(let i=1;i<t.length;i++)e.push({command:"L",args:[t[i].x,t[i].y]});if(a)e.push({command:"Z",args:[]});return e}function da(t){if(!Array.isArray(t))throw TypeError("isPurePolyline: commands must be an array");let a=new Set(["M","m","L","l","H","h","V","v","Z","z"]);return t.every((e)=>{if(!e||typeof e!=="object"||typeof e.command!=="string")return!1;return a.has(e.command)})}function Na(t,a,e="douglas-peucker"){if(!Array.isArray(t))throw TypeError("simplifyPath: commands must be an array");if(typeof a!=="number"||!Number.isFinite(a))throw TypeError("simplifyPath: tolerance must be a finite number");if(a<0)throw RangeError("simplifyPath: tolerance cannot be negative");if(a>0&&a<0.0000000001)throw RangeError("simplifyPath: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(!da(t)||t.length<3)return{commands:t,simplified:!1,originalPoints:0,simplifiedPoints:0};let i=to(t),r=i.length;if(r<3)return{commands:t,simplified:!1,originalPoints:r,simplifiedPoints:r};let l=t[t.length-1].command.toLowerCase()==="z";if(l&&i.length>1){let p=i[0],n=i[i.length-1];if(Math.abs(n.x-p.x)<0.0000000001&&Math.abs(n.y-p.y)<0.0000000001)i=i.slice(0,-1)}let o=fa(i,a,e),x=o.length;if(x>=r)return{commands:t,simplified:!1,originalPoints:r,simplifiedPoints:r};return{commands:ao(o,l),simplified:!0,originalPoints:r,simplifiedPoints:x}}function l4(t){if(typeof t!=="string")throw TypeError("Path d must be a string")}function o4(t){if(typeof t!=="number"||!Number.isFinite(t)||t<0)throw TypeError(`Precision must be a finite non-negative number, got ${t}`)}function $4(t){if(typeof t!=="number"||!Number.isFinite(t)||t<0)throw TypeError(`Tolerance must be a finite non-negative number, got ${t}`)}function x4(t,a=0){if(!t||typeof t!=="object")throw TypeError("Command must be an object");if(typeof t.command!=="string")throw TypeError("Command must have a string 'command' property");if(!Array.isArray(t.args))throw TypeError("Command must have an array 'args' property");if(t.args.length<a)throw TypeError(`Command ${t.command} requires at least ${a} args, got ${t.args.length}`);for(let e=0;e<t.args.length;e++)if(typeof t.args[e]!=="number"||!Number.isFinite(t.args[e]))throw TypeError(`Command ${t.command} arg[${e}] must be a finite number, got ${t.args[e]}`)}function Ia(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;e.forEach((r)=>x4(r));let i=e.map((r)=>({command:r.command,args:r.args.map((l)=>{let o=W4(l,a),x=parseFloat(o);if(!Number.isFinite(x))throw Error(`Invalid numeric value encountered: ${o}`);return x})}));return Q3(i,a)}function Ba(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;return e.forEach((i)=>x4(i)),Q3(e,a)}function Da(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;e.forEach((p)=>x4(p));let i=0,r=0,l=0,o=0,x=[];for(let p of e){let n=Pa(p,i,r);x.push(n);let c=T4(p,i,r);switch(c.command){case"M":i=c.args[0],r=c.args[1],l=i,o=r;break;case"L":case"T":i=c.args[0],r=c.args[1];break;case"H":i=c.args[0];break;case"V":r=c.args[0];break;case"C":i=c.args[4],r=c.args[5];break;case"S":case"Q":i=c.args[2],r=c.args[3];break;case"A":i=c.args[5],r=c.args[6];break;case"Z":i=l,r=o;break;default:break}}return Q3(x,a)}function Ra(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;e.forEach((p)=>x4(p));let i=0,r=0,l=0,o=0,x=[];for(let p of e){let n=T4(p,i,r);switch(x.push(n),n.command){case"M":i=n.args[0],r=n.args[1],l=i,o=r;break;case"L":case"T":i=n.args[0],r=n.args[1];break;case"H":i=n.args[0];break;case"V":r=n.args[0];break;case"C":i=n.args[4],r=n.args[5];break;case"S":case"Q":i=n.args[2],r=n.args[3];break;case"A":i=n.args[5],r=n.args[6];break;case"Z":i=l,r=o;break;default:break}}return Q3(x,a)}function wa(t,a=0.000001,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((n)=>x4(n));let r=0,l=0,o=0,x=0,p=[];for(let n of i){let c=n;if(n.command==="L"||n.command==="l"){let m=n.command==="L",g=m?n.args[0]:r+n.args[0],u=m?n.args[1]:l+n.args[1];if(Math.abs(u-l)<a)c=m?{command:"H",args:[g]}:{command:"h",args:[g-r]};else if(Math.abs(g-r)<a)c=m?{command:"V",args:[u]}:{command:"v",args:[u-l]}}p.push(c);let s=T4(c,r,l);switch(s.command){case"M":r=s.args[0],l=s.args[1],o=r,x=l;break;case"L":case"T":r=s.args[0],l=s.args[1];break;case"H":r=s.args[0];break;case"V":l=s.args[0];break;case"C":r=s.args[4],l=s.args[5];break;case"S":case"Q":r=s.args[2],l=s.args[3];break;case"A":r=s.args[5],l=s.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(p,e)}function La(t,a=0.000001,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((n)=>x4(n));let r=0,l=0,o=0,x=0,p=[];for(let n=0;n<i.length;n++){let c=i[n],s=c;if(c.command==="L"||c.command==="l"){let g=c.command==="L",u=g?c.args[0]:r+c.args[0],y=g?c.args[1]:l+c.args[1];if((n===i.length-1||i[n+1].command==="M"||i[n+1].command==="m")&&Math.abs(u-o)<a&&Math.abs(y-x)<a)s={command:"z",args:[]}}p.push(s);let m=T4(s,r,l);switch(m.command){case"M":r=m.args[0],l=m.args[1],o=r,x=l;break;case"L":case"T":r=m.args[0],l=m.args[1];break;case"H":r=m.args[0];break;case"V":l=m.args[0];break;case"C":r=m.args[4],l=m.args[5];break;case"S":case"Q":r=m.args[2],l=m.args[3];break;case"A":r=m.args[5],l=m.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(p,e)}function T5(...t){for(let a=0;a<t.length;a++)if(typeof t[a]!=="number"||!Number.isFinite(t[a]))throw TypeError(`Coordinate at position ${a} must be a finite number, got ${t[a]}`)}function ka(t){if(typeof t!=="number"||!Number.isFinite(t))throw TypeError(`Parameter t must be a finite number, got ${t}`);if(t<0||t>1)throw RangeError(`Parameter t must be in range [0, 1], got ${t}`)}function e0(t,a,e,i,r,l,o,x,p){ka(t),T5(a,e,i,r,l,o,x,p);let n=1-t,c=n*n,s=c*n,m=t*t,g=m*t;return{x:s*a+3*c*t*i+3*n*m*l+g*x,y:s*e+3*c*t*r+3*n*m*o+g*p}}function z0(t,a,e,i,r,l){T5(t,a,e,i,r,l);let o=r-e,x=l-i,p=o*o+x*x;if(p<0.0000000001)return Math.sqrt((t-e)**2+(a-i)**2);let n=Math.max(0,Math.min(1,((t-e)*o+(a-i)*x)/p)),c=e+n*o,s=i+n*x;return Math.sqrt((t-c)**2+(a-s)**2)}function eo(t,a,e,i,r,l,o,x){T5(t,a,e,i,r,l,o,x);let p=0,n=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let c of n){let s=e0(c,t,a,e,i,r,l,o,x),m=z0(s.x,s.y,t,a,o,x);if(m>p)p=m}for(let c=0;c<n.length-1;c++){let s=(n[c]+n[c+1])/2,m=e0(s,t,a,e,i,r,l,o,x),g=z0(m.x,m.y,t,a,o,x);if(g>p)p=g}for(let c of[0.05,0.95]){let s=e0(c,t,a,e,i,r,l,o,x),m=z0(s.x,s.y,t,a,o,x);if(m>p)p=m}return p}function io(t,a,e,i,r,l,o,x,p){return eo(t,a,e,i,r,l,o,x)<=p}function Ya(t,a=0.5,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((n)=>x4(n));let r=0,l=0,o=0,x=0,p=[];for(let n of i){let c=n;if(n.command==="C"||n.command==="c"){let m=n.command==="C",g=m?n.args[0]:r+n.args[0],u=m?n.args[1]:l+n.args[1],y=m?n.args[2]:r+n.args[2],v=m?n.args[3]:l+n.args[3],E=m?n.args[4]:r+n.args[4],C=m?n.args[5]:l+n.args[5];if(io(r,l,g,u,y,v,E,C,a))c=m?{command:"L",args:[E,C]}:{command:"l",args:[E-r,C-l]}}p.push(c);let s=T4(c,r,l);switch(s.command){case"M":r=s.args[0],l=s.args[1],o=r,x=l;break;case"L":case"T":r=s.args[0],l=s.args[1];break;case"H":r=s.args[0];break;case"V":l=s.args[0];break;case"C":r=s.args[4],l=s.args[5];break;case"S":case"Q":r=s.args[2],l=s.args[3];break;case"A":r=s.args[5],l=s.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(p,e)}function Xa(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;return e.forEach((i)=>x4(i)),Q3(e,a)}function Oa(t,a=3){if(l4(t),o4(a),a>15)throw RangeError(`Precision ${a} is too large (max 15)`);let e=H3(t);if(e.length===0)return t;e.forEach((l)=>x4(l));let i=Math.pow(10,a),r=e.map((l)=>({command:l.command,args:l.args.map((o)=>Math.round(o*i)/i)}));return Q3(r,a)}function Va(t,a=0.000001,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((n)=>x4(n));let r=0,l=0,o=0,x=0,p=[];for(let n of i){let c=T4(n,r,l),s=!0;switch(c.command){case"L":case"T":if(Math.abs(c.args[0]-r)<a&&Math.abs(c.args[1]-l)<a)s=!1;break;case"H":if(Math.abs(c.args[0]-r)<a)s=!1;break;case"V":if(Math.abs(c.args[0]-l)<a)s=!1;break;case"C":if(Math.abs(c.args[4]-r)<a&&Math.abs(c.args[5]-l)<a&&Math.abs(c.args[0]-r)<a&&Math.abs(c.args[1]-l)<a&&Math.abs(c.args[2]-r)<a&&Math.abs(c.args[3]-l)<a)s=!1;break;case"S":if(Math.abs(c.args[2]-r)<a&&Math.abs(c.args[3]-l)<a&&Math.abs(c.args[0]-r)<a&&Math.abs(c.args[1]-l)<a)s=!1;break;case"Q":if(Math.abs(c.args[2]-r)<a&&Math.abs(c.args[3]-l)<a&&Math.abs(c.args[0]-r)<a&&Math.abs(c.args[1]-l)<a)s=!1;break;case"A":if(Math.abs(c.args[5]-r)<a&&Math.abs(c.args[6]-l)<a||Math.abs(c.args[0])<a||Math.abs(c.args[1])<a)s=!1;break;default:break}if(s)switch(p.push(n),c.command){case"M":r=c.args[0],l=c.args[1],o=r,x=l;break;case"L":case"T":r=c.args[0],l=c.args[1];break;case"H":r=c.args[0];break;case"V":l=c.args[0];break;case"C":r=c.args[4],l=c.args[5];break;case"S":case"Q":r=c.args[2],l=c.args[3];break;case"A":r=c.args[5],l=c.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(p,e)}function ro(t,a,e,i,r,l,o){ka(t),T5(a,e,i,r,l,o);let x=1-t,p=x*x,n=t*t;return{x:p*a+2*x*t*i+n*l,y:p*e+2*x*t*r+n*o}}function lo(t,a,e,i,r,l,o,x,p,n){T5(t,a,e,i,r,l,o,x,p,n);let c=0,s=[0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95];for(let m of s){let g=e0(m,t,a,e,i,r,l,o,x),u=ro(m,t,a,p,n,o,x),y=Math.sqrt((g.x-u.x)**2+(g.y-u.y)**2);if(y>c)c=y}return c}function oo(t,a,e,i,r,l,o,x,p){T5(t,a,e,i,r,l,o,x),$4(p);let n=(3*(e+r)-t-o)/4,c=(3*(i+l)-a-x)/4;if(lo(t,a,e,i,r,l,o,x,n,c)<=p)return{cpx:n,cpy:c};return null}function Ua(t,a=0.5,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((n)=>x4(n));let r=0,l=0,o=0,x=0,p=[];for(let n of i){let c=n;if(n.command==="C"||n.command==="c"){let m=n.command==="C",g=m?n.args[0]:r+n.args[0],u=m?n.args[1]:l+n.args[1],y=m?n.args[2]:r+n.args[2],v=m?n.args[3]:l+n.args[3],E=m?n.args[4]:r+n.args[4],C=m?n.args[5]:l+n.args[5],P=oo(r,l,g,u,y,v,E,C,a);if(P)c=m?{command:"Q",args:[P.cpx,P.cpy,E,C]}:{command:"q",args:[P.cpx-r,P.cpy-l,E-r,C-l]}}p.push(c);let s=T4(c,r,l);switch(s.command){case"M":r=s.args[0],l=s.args[1],o=r,x=l;break;case"L":case"T":r=s.args[0],l=s.args[1];break;case"H":r=s.args[0];break;case"V":l=s.args[0];break;case"C":r=s.args[4],l=s.args[5];break;case"S":case"Q":r=s.args[2],l=s.args[3];break;case"A":r=s.args[5],l=s.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(p,e)}function Ma(t,a=0.000001,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((s)=>x4(s));let r=0,l=0,o=0,x=0,p=null,n=null,c=[];for(let s of i){let m=s,g=T4(s,r,l);if(g.command==="Q"&&p!==null){let u=2*r-p,y=2*l-n;if(Math.abs(g.args[0]-u)<a&&Math.abs(g.args[1]-y)<a)m=s.command==="Q"?{command:"T",args:[g.args[2],g.args[3]]}:{command:"t",args:[g.args[2]-r,g.args[3]-l]}}if(c.push(m),g.command==="Q")p=g.args[0],n=g.args[1];else if(g.command==="T")if(p!==null)p=2*r-p,n=2*l-n;else p=r,n=l;else p=null,n=null;switch(g.command){case"M":r=g.args[0],l=g.args[1],o=r,x=l;break;case"L":case"T":r=g.args[0],l=g.args[1];break;case"H":r=g.args[0];break;case"V":l=g.args[0];break;case"C":r=g.args[4],l=g.args[5];break;case"S":case"Q":r=g.args[2],l=g.args[3];break;case"A":r=g.args[5],l=g.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(c,e)}function _a(t,a=0.000001,e=3){l4(t),$4(a),o4(e);let i=H3(t);if(i.length===0)return t;i.forEach((s)=>x4(s));let r=0,l=0,o=0,x=0,p=null,n=null,c=[];for(let s of i){let m=s,g=T4(s,r,l);if(g.command==="C"&&p!==null){let u=2*r-p,y=2*l-n;if(Math.abs(g.args[0]-u)<a&&Math.abs(g.args[1]-y)<a)m=s.command==="C"?{command:"S",args:[g.args[2],g.args[3],g.args[4],g.args[5]]}:{command:"s",args:[g.args[2]-r,g.args[3]-l,g.args[4]-r,g.args[5]-l]}}if(c.push(m),g.command==="C")p=g.args[2],n=g.args[3];else if(g.command==="S")p=g.args[0],n=g.args[1];else p=null,n=null;switch(g.command){case"M":r=g.args[0],l=g.args[1],o=r,x=l;break;case"L":case"T":r=g.args[0],l=g.args[1];break;case"H":r=g.args[0];break;case"V":l=g.args[0];break;case"C":r=g.args[4],l=g.args[5];break;case"S":case"Q":r=g.args[2],l=g.args[3];break;case"A":r=g.args[5],l=g.args[6];break;case"Z":r=o,l=x;break;default:break}}return Q3(c,e)}function Fa(t,a=3){l4(t),o4(a);let e=H3(t);if(e.length===0)return t;e.forEach((r)=>x4(r));let i=e.map((r)=>{if(r.command==="A"||r.command==="a"){let l=[...r.args];if(l.length!==7)throw Error(`Arc command requires 7 arguments, got ${l.length}`);if(l[2]=(l[2]%360+360)%360,Math.abs(l[0]-l[1])<0.000001)l[2]=0;return l[3]=l[3]?1:0,l[4]=l[4]?1:0,{command:r.command,args:l}}return r});return Q3(i,a)}var l5=new Set(["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]),g2=new Set([...l5].map((t)=>t.toLowerCase())),o5=new Set(["accent-height","accumulate","additive","alignment-baseline","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clip-path","clip-rule","clipPathUnits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","contentScriptType","contentStyleType","cursor","cx","cy","d","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fill-rule","filter","filterRes","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","horiz-adv-x","horiz-origin-x","horiz-origin-y","href","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","onabort","onactivate","onbegin","onclick","onend","onerror","onfocusin","onfocusout","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onrepeat","onresize","onscroll","onunload","onzoom","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","path","pathLength","patternContentUnits","patternTransform","patternUnits","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfaceScale","systemLanguage","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","title","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:id","xml:lang","xml:space","xmlns","xmlns:xlink","y","y1","y2","yChannelSelector","z","zoomAndPan","line-height","marker"]),y2=new Set([...o5].map((t)=>t.toLowerCase())),xo=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),no=new Set(["href","tabindex","lang","transform-origin","vector-effect","paint-order","pathLength","fr","side","crossorigin","role","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-controls","aria-expanded","aria-haspopup","aria-live","aria-atomic","aria-relevant","aria-busy","aria-owns"]),po=(t)=>{if(!t||typeof t!=="string")return!1;return xo.has(t.toLowerCase())},co=(t)=>{if(!t||typeof t!=="string")return!1;let a=t.toLowerCase();return no.has(a)||a.startsWith("aria-")||a.startsWith("data-")},Z6=new Set(["foreignobject","script","style","title","desc","metadata"]),i0=new Map,so=(t,a)=>{if(typeof t!=="string"||typeof a!=="string")throw Error("Both parameters must be strings");let e=`${t}|${a}`;if(i0.has(e))return i0.get(e);if(t.length===0)return a.length;if(a.length===0)return t.length;let i=[];for(let l=0;l<=a.length;l++)i[l]=[l];for(let l=0;l<=t.length;l++)i[0][l]=l;for(let l=1;l<=a.length;l++)for(let o=1;o<=t.length;o++){let x=t[o-1]===a[l-1]?0:1;i[l][o]=Math.min(i[l-1][o]+1,i[l][o-1]+1,i[l-1][o-1]+x)}let r=i[a.length][t.length];return i0.set(e,r),r},mo=()=>i0.clear(),h5=(t,a,e=2)=>{if(!t||typeof t!=="string")return null;if(!a||!(a instanceof Set)||a.size===0)return null;let i=typeof e!=="number"||e<0?2:e,r=t.toLowerCase(),l=null,o=i+1;for(let x of a){let p=so(r,x.toLowerCase());if(p>0&&p<o)o=p,l=x}return l};function Y4(t){if(!t||typeof t!=="string")return!1;return/(%|em|rem|px|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|Q)$/i.test(t.trim())}function go(t,a,e=100){let i=new Set,r=t,l=0;while(r!==null&&r!==void 0&&l<e){if(i.has(r))return!0;i.add(r),r=a(r),l++}return l>=e}function J6(t){if(!t||typeof t!=="string")return t||"";return t.replace(/<(script|style)([^>]*)\sdata-cdata-pending="true"([^>]*)>([\s\S]*?)<\/\1>/gi,(a,e,i,r,l)=>{let o=l.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),x=(i+r).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),p=x?" "+x:"";return`<${e}${p}><![CDATA[
|
|
18
|
-
${
|
|
19
|
-
]]></${e}>`})}var r0=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,O5=80,u0=6,Ga={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};h.set({precision:O5,rounding:h.ROUND_HALF_UP});var M2=(t)=>t instanceof h?t:new h(t);function Z(t){return t!==null&&typeof t==="object"&&typeof t.tagName==="string"&&typeof t.getAttribute==="function"&&typeof t.setAttribute==="function"}function ja(t,a=u0){if(t===null||t===void 0)return"0";let e=a;if(typeof a!=="number"||isNaN(a)||a<0)e=u0;if(e>O5)e=O5;let i=M2(t).toFixed(e);if(i.includes("."))return i.replace(/\.?0+$/,"");return i}function yo(t){if(t===null||t===void 0)return"";return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Y3={SVG_STRING:"string",DOM_ELEMENT:"dom",FILE_PATH:"file",URL:"url",XML_DOCUMENT:"xml",CSS_SELECTOR:"selector",OBJECT_ELEMENT:"object",EMBED_ELEMENT:"embed",IFRAME_ELEMENT:"iframe"},h4={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},c4={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function _2(t){if(t===null||t===void 0)return c4.STRING;if(typeof t==="object"&&t.nodeType)return c4.DOM_UPDATE;if(typeof t==="string"){let a=t.trim();if(typeof document<"u"&&(a.startsWith("#")||a.startsWith(".")||a.startsWith("[")))return c4.DOM_REPLACE;if(a.includes("/")||a.includes("\\")||/\.\w+$/.test(a))return c4.FILE;if(a.toLowerCase()==="download")return c4.DOWNLOAD}return c4.STRING}async function Wa(t,a=null,e={}){let i=_2(a),r;if(typeof t==="string")r=t;else r=G5(t,h4.SVG_STRING,e);switch(i){case c4.STRING:return r;case c4.FILE:{if(typeof process<"u"&&process.versions?.node){let l=await import("fs"),o=(await Promise.resolve().then(()=>(v5(),x5))).dirname(a);if(o&&o!=="."&&!l.existsSync(o))l.mkdirSync(o,{recursive:!0});l.writeFileSync(a,r,"utf8");return}throw Error("File saving requires Node.js environment")}case c4.DOM_REPLACE:{if(typeof document>"u")throw Error("DOM operations require browser environment");let l=document.querySelector(a);if(!l)throw Error(`No element found for selector: ${a}`);l.innerHTML=r;return}case c4.DOM_UPDATE:{if(typeof document>"u")throw Error("DOM operations require browser environment");if(a.tagName?.toLowerCase()==="svg"){let l=new DOMParser().parseFromString(r,"image/svg+xml").documentElement;while(a.attributes.length>0)a.removeAttribute(a.attributes[0].name);for(let o of l.attributes)a.setAttribute(o.name,o.value);a.innerHTML=l.innerHTML}else a.innerHTML=r;return}case c4.DOWNLOAD:{if(typeof document>"u"||typeof Blob>"u")throw Error("Download requires browser environment");let l=new Blob([r],{type:"image/svg+xml"}),o=URL.createObjectURL(l),x=document.createElement("a");x.href=o,x.download=e.filename||"output.svg",document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(o);return}default:return r}}function A5(t){if(t===null||t===void 0)throw Error("Input cannot be null or undefined");if(typeof t==="string"){let a=t.trim();if(a.startsWith("<"))return Y3.SVG_STRING;else if(t.startsWith("http://")||t.startsWith("https://"))return Y3.URL;else if(typeof document<"u"&&(a.startsWith("#")||a.startsWith(".")||a.startsWith("[")))return Y3.CSS_SELECTOR;else return Y3.FILE_PATH}if(typeof HTMLObjectElement<"u"&&t instanceof HTMLObjectElement)return Y3.OBJECT_ELEMENT;if(typeof HTMLEmbedElement<"u"&&t instanceof HTMLEmbedElement)return Y3.EMBED_ELEMENT;if(typeof HTMLIFrameElement<"u"&&t instanceof HTMLIFrameElement)return Y3.IFRAME_ELEMENT;if(Z(t))return Y3.DOM_ELEMENT;if(t&&t.nodeType===9)return Y3.XML_DOCUMENT;return Y3.SVG_STRING}async function F5(t,a){switch(a){case Y3.SVG_STRING:return _3(t);case Y3.DOM_ELEMENT:if(t&&typeof t.serialize==="function")return t;if(typeof XMLSerializer<"u"){let e=new XMLSerializer().serializeToString(t);return _3(e)}return t;case Y3.XML_DOCUMENT:{let e=t.documentElement||t;if(e&&typeof e.serialize==="function")return e;if(typeof XMLSerializer<"u"){let i=new XMLSerializer().serializeToString(e);return _3(i)}return e}case Y3.FILE_PATH:{let e=(()=>({})).readFileSync(t,"utf8");return _3(e)}if(typeof process<"u"&&process.versions?.node){let{readFileSync:e}=await import("fs"),i=e(t,"utf8");return _3(i)}throw Error("File loading requires Node.js environment");case Y3.URL:if(typeof fetch<"u"){let e=await(await fetch(t)).text();return _3(e)}throw Error("URL loading requires fetch API");case Y3.CSS_SELECTOR:if(typeof document<"u"){let e=document.querySelector(t);if(!e)throw Error(`No element found for selector: ${t}`);if(e.tagName.toLowerCase()==="svg")return _3(new XMLSerializer().serializeToString(e));let i=e.querySelector("svg");if(i)return _3(new XMLSerializer().serializeToString(i));throw Error(`Element "${t}" is not an SVG and contains no SVG`)}throw Error("CSS selector requires browser environment");case Y3.OBJECT_ELEMENT:try{if(t.contentDocument&&t.contentDocument.documentElement){let e=t.contentDocument.documentElement;if(e.tagName.toLowerCase()==="svg")return _3(new XMLSerializer().serializeToString(e))}}catch(e){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${e.message}`);throw Error("HTMLObjectElement: SVG content not accessible (cross-origin or security error)")}throw Error("HTMLObjectElement: SVG content not accessible (not loaded or cross-origin)");case Y3.EMBED_ELEMENT:if(typeof t.getSVGDocument==="function"){let e=t.getSVGDocument();if(e&&e.documentElement)return _3(new XMLSerializer().serializeToString(e.documentElement))}throw Error("HTMLEmbedElement: SVG content not accessible");case Y3.IFRAME_ELEMENT:try{let e=t.contentDocument;if(e&&e.documentElement){let i=e.documentElement;if(i.tagName.toLowerCase()==="svg")return _3(new XMLSerializer().serializeToString(i))}}catch(e){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${e.message}`);throw Error("HTMLIFrameElement: SVG content not accessible (cross-origin)")}throw Error("HTMLIFrameElement: No SVG content found");default:throw Error(`Unknown input type: ${a}`)}}function G5(t,a,e={}){switch(a){case h4.SVG_STRING:{let i=C4(t,{minify:e.minify!==!1});return J6(i)}case h4.DOM_ELEMENT:return t;case h4.XML_DOCUMENT:return t;default:{let i=C4(t,{minify:e.minify!==!1});return J6(i)}}}function p3(t){return async function(a,e={}){let i=A5(a),r=await F5(a,i),l=e.outputFormat||(i===Y3.DOM_ELEMENT?h4.DOM_ELEMENT:h4.SVG_STRING),o=await t(r,e);return G5(o,l,e)}}var F2=p3((t,a={})=>{let e=a.minify!==!1,i=a.remove!==!1,r=a.force||!1,l=a.preserve||[],o=a.preservePrefixes||[];if(!r){let f=t.querySelectorAll("script").length>0,B=Array.from(t.querySelectorAll("style")).some((R)=>R.textContent&&R.textContent.trim().length>0);if(f||B)return t}let x=(f)=>{if(l.includes(f))return!0;if(o.some((B)=>f.startsWith(B)))return!0;return!1},p=(f)=>{try{return decodeURI(f)}catch(B){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${B.message}`);return f}},n=Nl(t),c=new Set;for(let f of n.all)c.add(f),c.add(p(f));let s=new Map,m=(f)=>{let B=f.getAttribute("id");if(B){if(!s.has(B))s.set(B,f)}for(let R of f.children)if(Z(R))m(R)};m(t);let g=new Set,u=new Set,y=(f)=>{let B=f.getAttribute("id");if(B){if(g.has(B))u.add(B);g.add(B)}for(let R of f.children)if(Z(R))y(R)};y(t);let v=new Set,E=new Map,C=0,P=()=>{let f;do f=`a${C++}`;while(c.has(f)&&!s.has(f));return f},S=(f)=>{let B=f.getAttribute("id");if(B){if(u.has(B)){if(v.has(B)){f.removeAttribute("id");return}v.add(B)}let R=p(B),k=c.has(B)||c.has(R);if(x(B));else if(!k&&i)f.removeAttribute("id");else if(e&&k){let N=P();if(E.set(B,N),R!==B)E.set(R,N);f.setAttribute("id",N)}}for(let R of f.children)if(Z(R))S(R)};if(S(t),e){let f=(k)=>{let N=(I)=>I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let I of k.getAttributeNames()){let d=k.getAttribute(I);if(d&&d.includes("url(#")){for(let[Y,X]of E){let F=N(Y);d=d.replace(new RegExp(`url\\(#${F}\\)`,"g"),`url(#${X})`);let V=N(encodeURI(Y));d=d.replace(new RegExp(`url\\(#${V}\\)`,"g"),`url(#${X})`)}k.setAttribute(I,d)}if((I==="href"||I==="xlink:href")&&d?.startsWith("#")){let Y=d.substring(1),X=p(Y);if(E.has(Y))k.setAttribute(I,`#${E.get(Y)}`);else if(E.has(X))k.setAttribute(I,`#${E.get(X)}`)}if((I==="begin"||I==="end")&&d){for(let[Y,X]of E){let F=N(Y);d=d.replace(new RegExp(`^${F}\\.`,"g"),`${X}.`),d=d.replace(new RegExp(`;${F}\\.`,"g"),`;${X}.`)}k.setAttribute(I,d)}if((I==="values"||I==="from"||I==="to"||I==="by")&&d){for(let[Y,X]of E){let F=N(Y);d=d.replace(new RegExp(`#${F}([;\\s]|$)`,"g"),`#${X}$1`)}k.setAttribute(I,d)}}for(let I of k.children)if(Z(I))f(I)};f(t);let B=(k)=>k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=t.getElementsByTagName("style");for(let k of R){let N=k.textContent;if(!N)continue;for(let[I,d]of E){let Y=B(I);N=N.replace(new RegExp(`#${Y}([^\\w-]|$)`,"g"),`#${d}$1`),N=N.replace(new RegExp(`url\\(#${Y}\\)`,"g"),`url(#${d})`)}k.textContent=N}}return t}),R0=p3((t,a={})=>{let e=a.precision||6,i=(l)=>{let o=parseFloat(l);if(isNaN(o))return l;let x=M2(o).toDecimalPlaces(e).toString();if(x.includes("."))x=x.replace(/0+$/,""),x=x.replace(/\.$/,"");return x},r=(l)=>{for(let o of l.getAttributeNames()){let x=l.getAttribute(o);if(o.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|stroke-width|font-size)$/)){if(Y4(x))continue;l.setAttribute(o,i(x))}if(o==="d"&&x){let p=x.replace(r0,(n)=>i(n));l.setAttribute("d",p)}if(o==="transform"&&x){let p=x.replace(r0,(n)=>i(n));l.setAttribute("transform",p)}if(o==="points"&&x){let p=x.replace(r0,(n)=>i(n));l.setAttribute("points",p)}}for(let o of l.children)if(Z(o))r(o)};return r(t),t}),za=p3((t,a={})=>{let e=a.precision||6,i=(l)=>{let o=parseFloat(l);if(isNaN(o))return l;let x=M2(o).toDecimalPlaces(e).toString();if(x.includes("."))x=x.replace(/0+$/,""),x=x.replace(/\.$/,"");return x},r=(l)=>{for(let o of["points"]){let x=l.getAttribute(o);if(x){let p=x.replace(r0,i);l.setAttribute(o,p)}}for(let o of l.children)if(Z(o))r(o)};return r(t),t}),Ha=p3((t,a={})=>{let e=["data-name","data-id","class"],i=["xmlns:serif"],r=(l)=>{for(let o of e)if(l.hasAttribute(o))l.removeAttribute(o);if(!a.preserveVendor){for(let o of i)if(l.hasAttribute(o))l.removeAttribute(o)}for(let o of l.children)if(Z(o))r(o)};return r(t),t}),Qa=p3((t,a={})=>{let e=(i)=>{if(i.hasAttribute("enable-background"))i.removeAttribute("enable-background");for(let r of i.children)if(Z(r))e(r)};return e(t),t}),qa=p3((t,a={})=>{let e=Array.from(t.querySelectorAll("style")).some((E)=>{let C=E.textContent||"";return C.includes("@media")||C.includes(":hover")||C.includes(":focus")||C.includes(":active")||C.includes(":visited")||C.includes(":first-child")||C.includes(":last-child")||C.includes(":nth-child")||C.includes(":not(")}),i=t.querySelectorAll("script").length>0,r=new Set,l=t.outerHTML||"",o=l.matchAll(/url\(#([^)]+)\)/g);for(let E of o)r.add(E[1]);let x=l.matchAll(/xlink:href="#([^"]+)"/g);for(let E of x)r.add(E[1]);let p=l.matchAll(/\shref="#([^"]+)"/g);for(let E of p)r.add(E[1]);let n={clippath:"clipPath",textpath:"textPath",lineargradient:"linearGradient",radialgradient:"radialGradient",meshgradient:"meshGradient",hatchpath:"hatchPath",solidcolor:"solidColor",foreignobject:"foreignObject",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",animatemotion:"animateMotion",animatetransform:"animateTransform"},c=(E)=>n[E]||E,s=["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","tref","textPath","textpath","defs","clipPath","clippath","mask","pattern","linearGradient","lineargradient","radialGradient","radialgradient","meshGradient","meshgradient","meshrow","meshpatch","hatch","hatchpath","hatchPath","solidcolor","solidColor","stop","image","use","symbol","marker","title","desc","metadata","foreignObject","foreignobject","switch","a","filter","feBlend","feblend","feColorMatrix","fecolormatrix","feComponentTransfer","fecomponenttransfer","feComposite","fecomposite","feConvolveMatrix","feconvolvematrix","feDiffuseLighting","fediffuselighting","feDisplacementMap","fedisplacementmap","feDistantLight","fedistantlight","feDropShadow","fedropshadow","feFlood","feflood","feFuncA","fefunca","feFuncB","fefuncb","feFuncG","fefuncg","feFuncR","fefuncr","feGaussianBlur","fegaussianblur","feImage","feimage","feMerge","femerge","feMergeNode","femergenode","feMorphology","femorphology","feOffset","feoffset","fePointLight","fepointlight","feSpecularLighting","fespecularlighting","feSpotLight","fespotlight","feTile","fetile","feTurbulence","feturbulence","animate","animateMotion","animatemotion","animateTransform","animatetransform","set","mpath","view","cursor","style","script","font","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","glyph","missing-glyph","hkern","vkern"],m={fill:"#000","fill-opacity":"1","fill-rule":"nonzero",stroke:"none","stroke-width":"1","stroke-opacity":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0",opacity:"1",visibility:"visible",display:"inline",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none","marker-start":"none","marker-mid":"none","marker-end":"none","stop-color":"#000","stop-opacity":"1","flood-color":"#000","flood-opacity":"1","lighting-color":"#fff","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","paint-order":"normal","vector-effect":"none","text-anchor":"start","text-overflow":"clip","text-decoration":"none","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline","writing-mode":"lr-tb",direction:"ltr","unicode-bidi":"normal","letter-spacing":"normal","word-spacing":"normal","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none"},g={circle:{cx:"0",cy:"0"},ellipse:{cx:"0",cy:"0"},line:{x1:"0",y1:"0",x2:"0",y2:"0"},rect:{x:"0",y:"0",rx:"0",ry:"0"},image:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},svg:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},symbol:{preserveAspectRatio:"xMidYMid meet"},marker:{markerUnits:"strokeWidth",refX:"0",refY:"0",markerWidth:"3",markerHeight:"3"},linearGradient:{x1:"0",y1:"0",x2:"100%",y2:"0",spreadMethod:"pad"},radialGradient:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%",spreadMethod:"pad"},pattern:{x:"0",y:"0",patternUnits:"objectBoundingBox",patternContentUnits:"userSpaceOnUse"},clipPath:{clipPathUnits:"userSpaceOnUse"},mask:{maskUnits:"objectBoundingBox",maskContentUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},filter:{primitiveUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},feBlend:{mode:"normal"},feColorMatrix:{type:"matrix"},feComposite:{operator:"over",k1:"0",k2:"0",k3:"0",k4:"0"},feTurbulence:{baseFrequency:"0",numOctaves:"1",seed:"0",stitchTiles:"noStitch",type:"turbulence"},feDisplacementMap:{scale:"0",xChannelSelector:"A",yChannelSelector:"A"},feDistantLight:{azimuth:"0",elevation:"0"},fePointLight:{x:"0",y:"0",z:"0"},a:{target:"_self"},textPath:{startOffset:"0"}},u=(E)=>{if(E.startsWith("data-"))return!0;if(E.startsWith("aria-"))return!0;if(E==="role")return!0;if(E==="xmlns")return!0;if(E.includes(":")&&!E.startsWith("xml:")&&!E.startsWith("xlink:"))return!0;return!1},y=(E,C)=>{let P=E.parentNode;while(P&&Z(P)){let S=P.getAttribute(C);if(S!==null)return S;P=P.parentNode}return null},v=(E,C={})=>{if(E.tagName==="foreignObject")return;if(E.tagName.includes(":"))return;if(!E.getAttribute("id")){for(let[R,k]of Object.entries(m))if(!u(R)&&E.getAttribute(R)===k)E.removeAttribute(R);let B=g[E.tagName.toLowerCase()]||{};for(let[R,k]of Object.entries(B))if(!u(R)&&E.getAttribute(R)===k)E.removeAttribute(R);if(!e){for(let R of E.getAttributeNames())if(P5.has(R)&&!u(R)){let k=E.getAttribute(R),N=y(E,R);if(N!==null&&k===N)E.removeAttribute(R)}}}let P={...C};for(let B of P5){let R=E.getAttribute(B);if(R!==null)P[B]=R}let S=E.tagName.toLowerCase(),f=h0[S]||h0[c(S)];for(let B of[...E.children])if(Z(B)){if(B.tagName.includes(":"))continue;let R=B.tagName.toLowerCase(),k=B.getAttribute("id"),N=i&&k,I=(d)=>{let Y=d.getAttribute("id");if(Y&&r.has(Y))return!0;for(let X of d.children||[])if(Z(X)&&I(X))return!0;return!1};if(!s.includes(R)){if(!I(B)&&!N){E.removeChild(B);continue}}if(f&&!f.has(R)&&!f.has(c(R))){if(!I(B)&&!N){E.removeChild(B);continue}}v(B,P)}};return v(t,{}),t}),Ka=p3((t,a={})=>{let e=["x","y","width","height","viewBox"],i=(r)=>{if(r.tagName==="g"){for(let l of e)if(r.hasAttribute(l))r.removeAttribute(l)}for(let l of r.children)if(Z(l))i(l)};return i(t),t}),Za=p3((t,a={})=>{let e=t.getElementsByTagName("defs");for(let i of[...e])if(i.children.length===0){if(i.parentNode)i.parentNode.removeChild(i)}return t}),w0=p3((t,a={})=>{let e=a.force||!1,i=t.querySelectorAll("script").length>0,r=new Set,l=(c)=>{for(let s of c.getAttributeNames()){let m=c.getAttribute(s);if(m&&m.includes("url(#")){let g=m.matchAll(/url\(#([^)]+)\)/g);for(let u of g)r.add(u[1])}if((s==="href"||s==="xlink:href")&&m&&m.startsWith("#"))r.add(m.substring(1))}for(let s of c.children)if(Z(s))l(s)};l(t);let o=(c)=>{let s=c.getAttribute("href")||c.getAttribute("xlink:href");if(s&&s.startsWith("#"))return!0;for(let m of c.getAttributeNames?c.getAttributeNames():[]){let g=c.getAttribute(m);if(g&&g.includes("url(#"))return!0}return!1},x=(c)=>{for(let s of c.children){if(!Z(s))continue;let m=s.tagName?.toLowerCase();if(a0.animation.has(m))return!0;if(x(s))return!0}return!1},p=(c)=>{let s=c.getAttribute("id");if(s&&(r.has(s)||i))return!0;for(let m of c.children){if(!Z(m))continue;if(p(m))return!0}return!1},n=(c,s=!1)=>{let m=c.tagName.toLowerCase(),g=s||m==="defs",u=c.getAttribute("display"),y=c.getAttribute("visibility"),v=parseFloat(c.getAttribute("opacity")||"1");if(u==="none"||y==="hidden"||v===0){if(!e&&p(c));else if(!e&&m==="marker");else if(!e&&(c.getAttribute("marker-start")||c.getAttribute("marker-mid")||c.getAttribute("marker-end")));else if(!e&&g&&a0.nonRendering.has(m));else if(!e&&a0.animation.has(m));else if(!e&&x(c));else if(!e&&m==="use");else if(!e&&o(c));else if(c.parentNode){c.parentNode.removeChild(c);return}}for(let E of[...c.children])if(Z(E))n(E,g)};return n(t),t}),Ja=p3((t,a={})=>{let e=t.getElementsByTagName("text"),i=(o)=>{let x=o.textContent||"";if(o.children)for(let p of o.children)x+=i(p);return x},r=(o,x)=>{if(!x||x.length===0)return!1;return(o.getAttributeNames?o.getAttributeNames():[]).some((p)=>x.some((n)=>p.startsWith(n+":")))},l=a.preserveNamespaces||[];for(let o of[...e]){let x=i(o),p=!x||x.trim()==="",n=r(o,l);if(p&&!n){if(o.parentNode)o.parentNode.removeChild(o)}}return t}),L0=p3((t,a={})=>{let e=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],i=t.querySelectorAll("script").length>0,r=new Set,l=(x)=>{for(let p of x.getAttributeNames?x.getAttributeNames():[]){let n=x.getAttribute(p);if(n&&n.includes("url(#")){let c=n.matchAll(/url\(#([^)]+)\)/g);for(let s of c)r.add(s[1])}if((p==="href"||p==="xlink:href")&&n&&n.startsWith("#"))r.add(n.substring(1))}for(let p of x.children||[])if(Z(p))l(p)};l(t);let o=(x)=>{for(let c of[...x.children])if(Z(c))o(c);let p=x.tagName?.toLowerCase();if(!e.includes(x.tagName)&&!e.includes(p))return;if(x.getAttribute("href")||x.getAttribute("xlink:href"))return;let n=x.getAttribute("id");if(n&&(r.has(n)||i))return;if(x.children.length===0){if(x.parentNode)x.parentNode.removeChild(x)}};return o(t),t}),$a=p3((t,a={})=>{return t}),t9=p3((t,a={})=>{return t}),k0=p3((t,a={})=>{return t}),Y0=p3((t,a={})=>{if(a.preserveVendor)return t;let e=t.getElementsByTagName("metadata");for(let i of[...e])if(i.parentNode)i.parentNode.removeChild(i);return t}),a9=p3((t,a={})=>{let e=t.getElementsByTagName("title");for(let i of[...e])if(i.parentNode)i.parentNode.removeChild(i);return t}),e9=p3((t,a={})=>{let e=t.getElementsByTagName("desc");for(let i of[...e])if(i.parentNode)i.parentNode.removeChild(i);return t}),G2=p3((t,a={})=>{if(a.preserveVendor===!0)return t;let e=a.preserveNamespaces||[],i=new Set(e);if(i.has("sodipodi"))i.add("inkscape");if(i.has("inkscape"))i.add("sodipodi");let r=["inkscape","sodipodi","illustrator","sketch","ai","serif","vectornator","figma"].filter((n)=>!i.has(n));if(r.length===0)return t;let l=(n)=>{for(let c of[...n.children])if(Z(c)){let s=c.tagName.indexOf(":");if(s>0){let m=c.tagName.substring(0,s);if(r.includes(m)){n.removeChild(c);continue}}l(c)}};l(t);let o=(n)=>{for(let c of[...n.getAttributeNames()]){if(c.startsWith("xmlns:"))continue;let s=c.indexOf(":");if(s>0){let m=c.substring(0,s);if(r.includes(m))n.removeAttribute(c)}}for(let c of n.children)if(Z(c))o(c)};o(t);let x=new Set,p=(n)=>{for(let s of n.getAttributeNames()){if(s.startsWith("xmlns:"))continue;let m=s.indexOf(":");if(m>0){let g=s.substring(0,m);x.add(g)}}let c=n.tagName.indexOf(":");if(c>0)x.add(n.tagName.substring(0,c));for(let s of n.children)if(Z(s))p(s)};p(t);for(let n of r){let c=`xmlns:${n}`;if(t.hasAttribute(c)&&!x.has(n))t.removeAttribute(c)}return t}),i9=p3((t,a={})=>{let e=(i)=>{for(let r of[...i.getAttributeNames()]){let l=i.getAttribute(r);if(l===""||l===null)i.removeAttribute(r)}for(let r of i.children)if(Z(r))e(r)};return e(t),t}),r9=p3((t,a={})=>{let e=t.getAttribute("width"),i=t.getAttribute("height"),r=t.getAttribute("viewBox");if(Y4(e)||Y4(i))return t;if(e&&i&&r){let l=r.split(/[\s,]+/).map(parseFloat),o=parseFloat(e),x=parseFloat(i);if(isNaN(o)||isNaN(x)||l.some((n)=>isNaN(n)))return t;let p=0.000001;if(l.length===4&&Math.abs(l[0])<p&&Math.abs(l[1])<p&&Math.abs(l[2]-o)<p&&Math.abs(l[3]-x)<p)t.removeAttribute("viewBox")}return t}),l9=p3((t,a={})=>{let e=a.preserveSvgNamespace!==!1,i=a.removeXlinkNamespace!==!1;if(a.preserveVendor){if(!e)t.removeAttribute("xmlns");return t}if(!e)t.removeAttribute("xmlns");if(i){let r=!1,l=(o)=>{for(let x of o.getAttributeNames())if(x.startsWith("xlink:")){r=!0;return}for(let x of o.children){if(Z(x))l(x);if(r)return}};if(l(t),!r)t.removeAttribute("xmlns:xlink")}return t.removeAttribute("xmlns:svg"),t}),o9=p3((t,a={})=>{let e=t.querySelectorAll("script").length>0,i=new Set,r=(o)=>{for(let x of o.getAttributeNames()){let p=o.getAttribute(x);if(p&&p.includes("url(#")){let n=p.matchAll(/url\(#([^)]+)\)/g);for(let c of n)i.add(c[1])}if((x==="href"||x==="xlink:href")&&p&&p.startsWith("#"))i.add(p.substring(1))}for(let x of o.children)if(Z(x))r(x)};r(t);let l=t.getElementsByTagName("image");for(let o of[...l]){let x=o.getAttribute("id");if(x&&(i.has(x)||e))continue;if(o.parentNode)o.parentNode.removeChild(o)}return t}),x9=p3((t,a={})=>{let e=new Set,i=(l)=>{for(let o of l.getAttributeNames()){let x=l.getAttribute(o);if(x&&x.includes("url(#")){let p=x.matchAll(/url\(#([^)]+)\)/g);for(let n of p)e.add(n[1])}if((o==="href"||o==="xlink:href")&&x&&x.startsWith("#"))e.add(x.substring(1))}for(let o of l.children)if(Z(o))i(o)};i(t);let r=t.getElementsByTagName("script");for(let l of[...r]){let o=l.getAttribute("id");if(!o||!e.has(o)){if(l.parentNode)l.parentNode.removeChild(l)}}return t}),n9=p3((t,a={})=>{let e=a.precision||6,i=a.convertRoundedRects||!1,r=["rect","circle","ellipse","line","polyline","polygon"],l=(o)=>{if(r.includes(o.tagName)){if(o.tagName==="rect"){let p=parseFloat(o.getAttribute("x")||"0"),n=parseFloat(o.getAttribute("y")||"0"),c=parseFloat(o.getAttribute("width")||"0"),s=parseFloat(o.getAttribute("height")||"0");if(isNaN(p)||isNaN(n)||isNaN(c)||isNaN(s)){for(let m of[...o.children])if(Z(m))l(m);return}}if(o.tagName==="rect"&&!i){let p=parseFloat(o.getAttribute("rx")||"0"),n=parseFloat(o.getAttribute("ry")||"0");if(isNaN(p)||isNaN(n)||p>0||n>0){for(let c of[...o.children])if(Z(c))l(c);return}}if(o.tagName==="polyline"||o.tagName==="polygon"){if((o.getAttribute("points")||"").trim().split(/[\s,]+/).length<4){for(let p of[...o.children])if(Z(p))l(p);return}}let x=Ht(o,e);if(x){let p=new T3("path",{d:x});for(let n of o.getAttributeNames())if(!n.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let c=o.getAttribute(n);if(c!==null)p.setAttribute(n,c)}for(let n of[...o.children])p.appendChild(n);if(o.parentNode)o.parentNode.replaceChild(p,o)}}for(let x of[...o.children])if(Z(x))l(x)};return l(t),t}),p9=p3((t,a={})=>{let e=a.precision||6,i=a.force||!1,r=new Set,l=(x)=>{for(let p of["href","xlink:href"]){let n=x.getAttribute(p);if(n&&n.startsWith("#"))r.add(n.substring(1))}for(let p of x.children)if(Z(p))l(p)};l(t);let o=t.getElementsByTagName("path");for(let x of o){let p=x.getAttribute("d");if(!p)continue;let n=x.getAttribute("id");if(!i&&n&&r.has(n))continue;if(!i&&x.getAttribute("style"))continue;let c=x.getAttribute("stroke-linecap"),s=c&&c!=="butt";if((p.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!i&&x.getAttribute("marker-mid"))continue;let m=d0(p);x.setAttribute("d",m)}return t}),c9=p3((t,a={})=>{let e=a.precision||6,i=a.force||!1,r=(l)=>{let o=l.getAttribute("transform");if(o){let x=X4(o),p=ur(x,e);if(!i&&p.length>=o.length);else if(!i&&l.getAttribute("stroke")&&l.getAttribute("stroke")!=="none"){let n=x.data[0][0].toNumber(),c=x.data[0][1].toNumber(),s=x.data[1][0].toNumber(),m=x.data[1][1].toNumber(),g=n*m-c*s,u=Math.abs(n-m)<0.000001&&Math.abs(c+s)<0.000001,y=0.0000000001;if(!u&&Math.abs(g)>0.0000000001);else l.setAttribute("transform",p)}else l.setAttribute("transform",p)}for(let x of l.children)if(Z(x))r(x)};return r(t),t}),X0=p3((t,a={})=>{let e=["fill","stroke","stop-color","flood-color","lighting-color"],i=(l)=>{if(!l||typeof l!=="string")return l;let o={white:"#fff",black:"#000",red:"#f00",green:"#0f0",blue:"#00f",yellow:"#ff0",cyan:"#0ff",magenta:"#f0f"};if(o[l.toLowerCase()])return o[l.toLowerCase()];let x=l.match(/^#([0-9a-f]{6})$/i);if(x){let p=x[1];if(p[0]===p[1]&&p[2]===p[3]&&p[4]===p[5])return`#${p[0]}${p[2]}${p[4]}`}return l},r=(l)=>{for(let o of e){let x=l.getAttribute(o);if(x)l.setAttribute(o,i(x))}for(let o of l.children)if(Z(o))r(o)};return r(t),t}),j2=p3((t,a={})=>{let e=a.preserveVendor||!1,i=new Set(["alignment-baseline","baseline-shift","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","display","dominant-baseline","enable-background","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","kerning","letter-spacing","lighting-color","marker","marker-end","marker-mid","marker-start","mask","opacity","overflow","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","transform","transform-origin","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"]),r=(l)=>{let o=l.getAttribute("style");if(o){let x=o.split(";").map((n)=>n.trim()).filter((n)=>n),p=[];for(let n of x){let c=n.indexOf(":");if(c===-1)continue;let s=n.substring(0,c).trim(),m=n.substring(c+1).trim();if(s&&m){if(!s.startsWith("-")&&i.has(s))l.setAttribute(s,m);else if(e&&s.startsWith("-"))p.push(n)}}if(p.length>0)l.setAttribute("style",p.join("; "));else l.removeAttribute("style")}for(let x of l.children)if(Z(x))r(x)};return r(t),t}),s9=p3((t,a={})=>{let e=t.getElementsByTagName("ellipse");for(let i of[...e]){let r=parseFloat(i.getAttribute("rx")||"0"),l=parseFloat(i.getAttribute("ry")||"0");if(isNaN(r)||isNaN(l))continue;if(Math.abs(r-l)<0.001){let o=new T3("circle",{});for(let x of i.getAttributeNames()){let p=i.getAttribute(x);if(x==="rx"||x==="ry")o.setAttribute("r",p);else o.setAttribute(x,p)}for(let x of[...i.children])o.appendChild(x);if(i.parentNode)i.parentNode.replaceChild(o,i)}}return t}),m9=p3((t,a={})=>{let e=a.force||!1,i=(r,l=!1,o=!1)=>{let x=r.tagName.toLowerCase(),p=o||x==="switch";for(let n of[...r.children])if(Z(n))i(n,!1,p);if(x!=="g")return;if(!e&&(l||p))return;if(!e&&r.getAttribute("filter"))return;if(r.children.length===1){let n=r.children[0];if(!Z(n))return;if(!e&&n.getAttribute("id"))return;let c=Array.from(r.children).some((g)=>Z(g)&&a0.animation.has(g.tagName.toLowerCase()));if(!e&&c)return;let s=r.getAttributeNames(),m=s.some((g)=>{if(P5.has(g))return!1;return n.hasAttribute(g)});if(!e&&m)return;if(s.length===0){if(r.parentNode)r.parentNode.replaceChild(n,r)}else{let g=!0;for(let u of s){if(!P5.has(u)&&u!=="class"&&u!=="style"){g=!1;break}if(n.hasAttribute(u)){g=!1;break}}if(g&&r.parentNode){for(let u of s){let y=r.getAttribute(u);if(y!==null)n.setAttribute(u,y)}r.parentNode.replaceChild(n,r)}}}};return i(t,!0),t}),g9=p3((t,a={})=>{let e=a.force||!1,i=(l)=>l&&l.includes("url("),r=(l)=>{let o=[...l.children].filter((x)=>Z(x)&&x.tagName==="path");for(let x=0;x<o.length-1;x++){let p=o[x],n=o[x+1];if(!e&&(p.children.length>0||n.children.length>0))continue;let c=["marker-start","marker-mid","marker-end"].some((g)=>p.getAttribute(g)||n.getAttribute(g));if(!e&&c)continue;if(!e&&(p.getAttribute("clip-path")||p.getAttribute("mask")||n.getAttribute("clip-path")||n.getAttribute("mask")))continue;if(!e){let g=p.getAttribute("fill"),u=p.getAttribute("stroke"),y=n.getAttribute("fill"),v=n.getAttribute("stroke");if(i(g)||i(u)||i(y)||i(v))continue}if(!e){let g=p.getAttribute("fill-rule")||"nonzero",u=n.getAttribute("fill-rule")||"nonzero";if(g!==u)continue}if(!e&&(p.getAttribute("filter")||n.getAttribute("filter")))continue;let s=p.getAttributeNames().filter((g)=>g!=="d").sort(),m=n.getAttributeNames().filter((g)=>g!=="d").sort();if(JSON.stringify(s)===JSON.stringify(m)){let g=!0;for(let u of s)if(p.getAttribute(u)!==n.getAttribute(u)){g=!1;break}if(g){let u=p.getAttribute("d"),y=n.getAttribute("d");if(p.setAttribute("d",`${u} ${y}`),n.parentNode)n.parentNode.removeChild(n);o.splice(x+1,1),x--}}}for(let x of l.children)if(Z(x))r(x)};return r(t),t}),y9=p3((t,a={})=>{let e=(i)=>{if(i.tagName==="g")for(let r of[...i.getAttributeNames()]){if(!P5.has(r))continue;let l=i.getAttribute(r);if(l){for(let o of i.children)if(Z(o)&&!o.hasAttribute(r))o.setAttribute(r,l);i.removeAttribute(r)}}for(let r of i.children)if(Z(r))e(r)};return e(t),t}),h9=p3((t,a={})=>{let e=(i)=>{if(i.tagName==="g"&&i.children.length>1)for(let r of P5){let l=null,o=!0;for(let x of i.children){if(!Z(x))continue;let p=x.getAttribute(r);if(!p){o=!1;break}if(l===null)l=p;else if(l!==p){o=!1;break}}if(o&&l){i.setAttribute(r,l);for(let x of i.children)if(Z(x))x.removeAttribute(r)}}for(let r of i.children)if(Z(r))e(r)};return e(t),t}),W2=p3((t,a={})=>{if(t.getElementsByTagName("script").length>0&&!a.force)return t;let e=t.getElementsByTagName("style");for(let i of e){let r=i.textContent;if(!r||!r.trim())continue;let l=r.includes("<![CDATA[")||r.includes("]]>"),o="",x="";if(l){let p=r.match(/^(\s*<!\[CDATA\[\s*)/),n=r.match(/(\s*\]\]>\s*)$/);if(p)o="<![CDATA[",r=r.replace(/^\s*<!\[CDATA\[\s*/,"");if(n)x="]]>",r=r.replace(/\s*\]\]>\s*$/,"")}if(r=r.replace(/\/\*[\s\S]*?\*\//g,""),r=r.replace(/\s+/g," "),r=r.replace(/\s*([{}:;,])\s*/g,"$1"),r=r.trim(),o||x)r=o+r+x;i.textContent=r}return t}),v9=p3((t,a={})=>{let e=a.onlyMatchedOnce!==!1,i=a.removeStyleElement!==!1,r=t.getElementsByTagName("style"),l=[];for(let o of r){let x=o.getAttribute("type");if(x&&x!=="text/css")continue;let p=o.textContent;if(!p||!p.trim())continue;if(p.includes("@media")||p.includes("@keyframes")||p.includes("@supports")||p.includes("@font-face"))continue;let n=p.match(/([^{]+)\{([^}]+)\}/g)||[],c=[];for(let g of n){let u=g.match(/([^{]+)\{([^}]+)\}/);if(!u)continue;let y=u[1].trim(),v=u[2].trim(),E=!1;for(let P of Ml.preventInlining)if(y.includes(P)){E=!0;break}if(E){l.push(g);continue}let C;try{C=o2(y)}catch(P){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${P.message}`);l.push(g);continue}c.push({selector:y,declarations:v,specificity:C,originalRule:g})}c.sort((g,u)=>x2(g.specificity,u.specificity));let s=new WeakMap,m=new Set;for(let{selector:g,declarations:u,specificity:y,originalRule:v}of c)try{let E=t.querySelectorAll(g);if(e&&g.startsWith("#")&&E.length>1){l.push(v);continue}for(let C of E){let P=C,S=!1;while(P){if(P.tagName==="foreignObject"){S=!0;break}P=P.parentNode}if(S)continue;if(!s.has(C))s.set(C,new Map),m.add(C);let f=s.get(C),B=C.getAttribute("style")||"";if(B&&f.size===0){let k=B.split(";");for(let N of k){let I=N.indexOf(":");if(I>0){let d=N.substring(0,I).trim(),Y=N.substring(I+1).trim(),X=Y.includes("!important");if(X)Y=Y.replace(/\s*!important\s*/g,"").trim();f.set(d,{specificity:[1,0,0,0],isImportant:X,value:Y})}}}let R=u.split(";");for(let k of R){let N=k.indexOf(":");if(N<=0)continue;let I=k.substring(0,N).trim(),d=k.substring(N+1).trim(),Y=d.includes("!important");if(Y)d=d.replace(/\s*!important\s*/g,"").trim();let X=f.get(I);if(X){let F=x2(y,X.specificity);if(F<0){if(Y&&!X.isImportant)f.set(I,{specificity:y,isImportant:Y,value:d})}else if(F===0){if(Y||!X.isImportant)f.set(I,{specificity:y,isImportant:Y,value:d})}else if(!X.isImportant||Y)f.set(I,{specificity:y,isImportant:Y,value:d})}else f.set(I,{specificity:y,isImportant:Y,value:d})}}}catch(E){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${E.message}`);l.push(v)}for(let g of m){let u=s.get(g),y=[];for(let[v,{value:E,isImportant:C}]of u)if(C)y.push(`${v}: ${E} !important`);else y.push(`${v}: ${E}`);g.setAttribute("style",y.join("; "))}if(i&&o.parentNode)if(l.length>0)o.textContent=l.join(`
|
|
20
|
-
`);else o.parentNode.removeChild(o)}return t}),u9=p3((t,a={})=>{let e=(i)=>{let r=i.getAttributeNames().sort(),l=r.map((o)=>[o,i.getAttribute(o)]);for(let o of r)i.removeAttribute(o);for(let[o,x]of l)i.setAttribute(o,x);for(let o of i.children)if(Z(o))e(o)};return e(t),t}),E9=p3((t,a={})=>{let e=t.getElementsByTagName("defs");for(let i of e){let r=[...i.children].filter((l)=>Z(l));r.sort((l,o)=>l.tagName.localeCompare(o.tagName));for(let l of[...i.children])i.removeChild(l);for(let l of r)i.appendChild(l)}return t}),C9=p3((t,a={})=>{let e=a.threshold||2,i=t.getElementsByTagName("path"),r=new Map;for(let x of i){let p=x.getAttribute("d");if(p){if(!r.has(p))r.set(p,[]);r.get(p).push(x)}}let l=t.querySelector("defs");if(!l)if(l=new T3("defs",{}),t.firstChild)t.insertBefore(l,t.firstChild);else t.appendChild(l);let o=0;for(let[x,p]of r)if(p.length>=e){let n=`path${o++}`,c=new T3("path",{id:n,d:x});l.appendChild(c);for(let s of p){let m=new T3("use",{href:`#${n}`});for(let g of s.getAttributeNames())if(g!=="d"){let u=s.getAttribute(g);if(u!==null)m.setAttribute(g,u)}for(let g of[...s.children])m.appendChild(g);if(s.parentNode)s.parentNode.replaceChild(m,s)}}return t}),b9=p3((t,a={})=>{let e=t.getAttribute("viewBox");if(!e)return t;let i=Qi(e);if(!i)return t;let r=K4(t),l=t.getElementsByTagName("path");for(let o of[...l]){let x=o.getAttribute("d");if(!x)continue;try{let p=s5(x),n=Zi(p);if(!n)continue;let c=y0(o),s=g0(o,c,r).getRenderedBBox(n),m={x:s.x,y:s.y,width:s.width,height:s.height};if(!Ji(m,i)){if(o.parentNode)o.parentNode.removeChild(o)}}catch(p){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${p.message}`)}}return t}),P9=p3((t,a={})=>{let e=t.getElementsByTagName("style");for(let i of[...e])if(i.parentNode)i.parentNode.removeChild(i);return t}),S9=p3((t,a={})=>{let e={new:"_blank",replace:"_self"},i=!1,r=(l)=>{for(let o of[...l.getAttributeNames()])if(o.startsWith("xlink:")){let x=o.substring(6),p=l.getAttribute(o);if(x==="href")i=!0;else if(x==="show"){if(!l.hasAttribute("target")){let n=e[p];if(n)l.setAttribute("target",n)}l.removeAttribute(o)}else if(x==="title"){if(!(l.querySelector&&l.querySelector("title"))&&p){let n=new T3("title",{},[],p);if(typeof l.insertBefore==="function"&&l.firstChild)l.insertBefore(n,l.firstChild);else if(typeof l.appendChild==="function")l.appendChild(n);else if(l.children&&Array.isArray(l.children))l.children.unshift(n),n.parentNode=l}l.removeAttribute(o)}else if(["actuate","type","role","arcrole"].includes(x))l.removeAttribute(o);else i=!0}for(let o of l.children)if(Z(o))r(o)};if(r(t),!i)t.removeAttribute("xmlns:xlink");return t}),T9=p3((t,a={})=>{let e=a.attributes||{};for(let[i,r]of Object.entries(e))t.setAttribute(i,r);return t}),A9=p3((t,a={})=>{let e=a.classes||[],i=t.getAttribute("class")||"",r=i?`${i} ${e.join(" ")}`:e.join(" ");return t.setAttribute("class",r.trim()),t}),f9=p3((t,a={})=>{let e=a.prefix||"svg",i=new Map,r=new Map,l=(n)=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=(n)=>{let c=n.getAttribute("id");if(c){let s=`${e}${c}`;i.set(c,s),n.setAttribute("id",s)}for(let s of n.children)if(Z(s))o(s)};if(o(t),a.prefixClassNames!==!1){let n=(s)=>{let m=s.getAttribute("class");if(m){for(let g of m.split(/\s+/))if(g&&!r.has(g))r.set(g,`${e}${g}`)}for(let g of s.children)if(Z(g))n(g)};n(t);let c=(s)=>{let m=s.getAttribute("class");if(m){let g=m.split(/\s+/).map((u)=>r.get(u)||u).join(" ");s.setAttribute("class",g)}for(let g of s.children)if(Z(g))c(g)};c(t)}let x=t.getElementsByTagName("style");for(let n of x){let c=n.textContent;if(!c)continue;for(let[s,m]of i){let g=l(s);c=c.replace(new RegExp(`#${g}([^\\w-]|$)`,"g"),`#${m}$1`),c=c.replace(new RegExp(`url\\(#${g}\\)`,"g"),`url(#${m})`)}if(a.prefixClassNames!==!1)for(let[s,m]of r){let g=l(s);c=c.replace(new RegExp(`\\.${g}([^\\w-]|$)`,"g"),`.${m}$1`)}n.textContent=c}let p=(n)=>{for(let c of n.getAttributeNames()){let s=n.getAttribute(c);if(s&&s.includes("url(#")){for(let[m,g]of i){let u=l(m);s=s.replace(new RegExp(`url\\(#${u}\\)`,"g"),`url(#${g})`)}n.setAttribute(c,s)}if((c==="href"||c==="xlink:href")&&s?.startsWith("#")){let m=s.substring(1);if(i.has(m))n.setAttribute(c,`#${i.get(m)}`)}if(c==="begin"||c==="end"){for(let[m,g]of i){let u=l(m);s=s.replace(new RegExp(`(^|;|\\s)${u}\\.`,"g"),`$1${g}.`)}n.setAttribute(c,s)}if(c==="values"||c==="from"||c==="to"||c==="by"){for(let[m,g]of i){let u=l(m);s=s.replace(new RegExp(`#${u}([;\\s]|$)`,"g"),`#${g}$1`)}n.setAttribute(c,s)}}for(let c of n.children)if(Z(c))p(c)};return p(t),t}),d9=p3((t,a={})=>{return t.removeAttribute("width"),t.removeAttribute("height"),t}),N9=p3((t,a={})=>{let e=a.selector||"*",i=a.attributes||[];try{let r=t.querySelectorAll(e);for(let l of r)for(let o of i)if(l.hasAttribute(o))l.removeAttribute(o)}catch(r){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${r.message}`)}return t}),I9=p3((t,a={})=>{let e=a.pattern?new RegExp(a.pattern):null,i=a.attrs||[],r=(l)=>{for(let o of[...l.getAttributeNames()])if(i.includes(o)||e&&e.test(o))l.removeAttribute(o);for(let o of l.children)if(Z(o))r(o)};return r(t),t}),B9=p3((t,a={})=>{let{name:e,value:i}=a;if(!e)return t;let r=(l)=>{for(let o of[...l.children]){if(!Z(o))continue;let x=o.getAttribute(e);if(i===void 0){if(x!==null){l.removeChild(o);continue}}else if(x===i){l.removeChild(o);continue}r(o)}};return r(t),t}),z2=p3(async(t,a={})=>{let e={...a,outputFormat:h4.DOM_ELEMENT},i=t;return i=await Y0(i,e),i=await k0(i,e),i=await L0(i,e),i=await w0(i,e),i=await R0(i,e),i=await X0(i,e),i=await j2(i,e),i=await G2(i,e),i=await F2(i,e),i=await W2(i,e),i}),H2=p3((t,a={})=>{return t}),D9=p3(async(t,a={})=>{let e=a.preset||"default",i={...a,outputFormat:h4.DOM_ELEMENT};switch(e){case"default":return await z2(t,i);case"none":return await H2(t,i);default:return t}}),R9=p3(async(t,a={})=>{let e=a.config||{},i={...a,outputFormat:h4.DOM_ELEMENT},r=t;if(e.removeMetadata!==!1)r=await Y0(r,i);if(e.removeComments!==!1)r=await k0(r,i);if(e.cleanupNumericValues!==!1)r=await R0(r,i);if(e.convertColors!==!1)r=await X0(r,i);if(e.removeHiddenElements!==!1)r=await w0(r,i);if(e.removeEmptyContainers!==!1)r=await L0(r,i);return r});function w9(t={}){return{precision:t.precision||6,removeMetadata:t.removeMetadata!==!1,removeComments:t.removeComments!==!1,cleanupNumericValues:t.cleanupNumericValues!==!1,convertColors:t.convertColors!==!1,removeHiddenElements:t.removeHiddenElements!==!1,removeEmptyContainers:t.removeEmptyContainers!==!1,...t}}var L9=p3(async(t,a={})=>{let e=C4(t,{minify:a.minify!==!1}),i=await _5(e,{...a,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return _3(i.svg)}),k9=p3(async(t,a={})=>{let e=C4(t,{minify:a.minify!==!1}),i=await _5(e,{...a,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return _3(i.svg)}),Y9=p3((t,a={})=>{let e=K4(t),i=(n)=>{let c=e.get(n);if(!c)return null;let s=c.getAttribute("href")||c.getAttribute("xlink:href");return s?.startsWith("#")?s.substring(1):null},r=(n,c)=>{let s=n.getAttribute("gradientUnits")||"objectBoundingBox",m=n.getAttribute("gradientTransform");if(go(c,i)){if(a.verbose)console.warn(`Circular gradient reference detected: #${c}`);return!1}if(s==="userSpaceOnUse")return!1;if(m)return!1;return!0},l=V4(t,"fill");for(let n of l){let c=n.getAttribute("fill");if(c&&c.includes("url(")){let s=Z4(c);if(s&&e.has(s)){let m=e.get(s),g=m.tagName.toLowerCase();if(g==="lineargradient"||g==="radialgradient"){if(!r(m,s)){if(a.verbose)console.warn(`Skipping gradient flatten for ${s}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let u=$6(m,a.position||0.5);n.setAttribute("fill",u)}}else n.setAttribute("fill",a.fallbackColor||"#808080")}}let o=V4(t,"stroke");for(let n of o){let c=n.getAttribute("stroke");if(c&&c.includes("url(")){let s=Z4(c);if(s&&e.has(s)){let m=e.get(s),g=m.tagName.toLowerCase();if(g==="lineargradient"||g==="radialgradient"){if(!r(m,s)){if(a.verbose)console.warn(`Skipping gradient flatten for ${s}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let u=$6(m,a.position||0.5);n.setAttribute("stroke",u)}}else n.setAttribute("stroke",a.fallbackColor||"#808080")}}let x=[...t.querySelectorAll("linearGradient, radialGradient")],p=(n)=>n.replace(/["\\]/g,"\\$&");for(let n of x){let c=n.getAttribute("id"),s=c?p(c):"";if(!(c&&([...t.querySelectorAll(`[fill*="url(#${s})"]`)].length>0||[...t.querySelectorAll(`[stroke*="url(#${s})"]`)].length>0))&&n.parentNode)n.parentNode.removeChild(n)}return t});function $6(t,a=0.5){let e=[...t.children].filter((x)=>x.tagName&&x.tagName.toLowerCase()==="stop");if(e.length===0)return"#808080";if(e.length===1)return tt(e[0]);let i=e.map((x)=>{let p=x.getAttribute("offset")||"0";if(p.endsWith("%"))p=parseFloat(p)/100;else p=parseFloat(p);return p=isNaN(p)?0:Math.max(0,Math.min(1,p)),{offset:p,color:tt(x),opacity:ho(x)}});i.sort((x,p)=>x.offset-p.offset);let r=null,l=null;for(let x=0;x<i.length;x++){let p=i[x];if(p.offset<=a)r=p;if(p.offset>=a&&!l){l=p;break}}if(!r)return i[0].color;if(!l)return i[i.length-1].color;if(r.offset===l.offset)return r.color;let o=(a-r.offset)/(l.offset-r.offset);return uo(r.color,l.color,o)}function tt(t){let a=t.getAttribute("stop-color");if(!a){let e=t.getAttribute("style");if(e){let i=e.match(/stop-color\s*:\s*([^;]+)/i);if(i)a=i[1].trim()}}if(!a)a="#000000";return vo(a)}function ho(t){let a=t.getAttribute("stop-opacity");if(!a){let i=t.getAttribute("style");if(i){let r=i.match(/stop-opacity\s*:\s*([^;]+)/i);if(r)a=r[1].trim()}}let e=a?parseFloat(a):1;return isNaN(e)?1:e}function vo(t){if(!t||typeof t!=="string")return"#000000";let a=t.trim().toLowerCase();if(a.startsWith("#")){if(a.length===4)return"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3];return a}if(a.startsWith("rgb(")){let i=a.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(i){let r=parseInt(i[1],10),l=parseInt(i[2],10),o=parseInt(i[3],10);return X9(r,l,o)}}let e={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",olive:"#808000",lime:"#00ff00",aqua:"#00ffff",teal:"#008080",navy:"#000080",fuchsia:"#ff00ff",purple:"#800080"};if(e[a])return e[a];return"#000000"}function uo(t,a,e){let i=(g)=>{let u=g.replace("#","");if(u.length===3)u=u[0]+u[0]+u[1]+u[1]+u[2]+u[2];let y=parseInt(u.slice(0,2),16),v=parseInt(u.slice(2,4),16),E=parseInt(u.slice(4,6),16);if(isNaN(y)||isNaN(v)||isNaN(E))return[0,0,0];return[y,v,E]},[r,l,o]=i(t),[x,p,n]=i(a),c=Math.round(r+(x-r)*e),s=Math.round(l+(p-l)*e),m=Math.round(o+(n-o)*e);return X9(c,s,m)}function X9(t,a,e){let i=(r)=>{return Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")};return"#"+i(t)+i(a)+i(e)}var O9=p3(async(t,a={})=>{let e=C4(t,{minify:a.minify!==!1}),i=await _5(e,{...a,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return _3(i.svg)}),V9=p3((t,a={})=>{let e=(r)=>{if(r.hasAttribute("filter"))r.removeAttribute("filter");for(let l of r.children)if(Z(l))e(l)};e(t);let i=t.getElementsByTagName("filter");for(let r of[...i])if(r.parentNode)r.parentNode.removeChild(r);return t}),U9=p3(async(t,a={})=>{let e=C4(t,{minify:a.minify!==!1}),i=await _5(e,{...a,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return _3(i.svg)}),M9=p3((t,a={})=>{let e=t.getElementsByTagName("image");for(let i of[...e])i.setAttribute("data-trace-needed","true");return t}),_9=p3((t,a={})=>{let{samples:e=10,includeStroke:i=!0,includeFillOnly:r=!1}=a,l=[...t.getElementsByTagName("path"),...t.getElementsByTagName("rect"),...t.getElementsByTagName("circle"),...t.getElementsByTagName("ellipse")],o=K4(t),x=[];for(let p=0;p<l.length;p++)for(let n=p+1;n<l.length;n++){let c=l[p],s=l[n],m=E0(c,e),g=E0(s,e);if(!m||!g)continue;let u=y0(c),y=y0(s),v=g0(c,u,o),E=g0(s,y,o);if(i&&!r){if(v.hasStroke){let C=v.getStrokeExtent().toNumber();m=at(m,C)}if(E.hasStroke){let C=E.getStrokeExtent().toNumber();g=at(g,C)}}if(Ft(m,g).overlaps)x.push({shape1:c.tagName,shape2:s.tagName,id1:c.getAttribute("id"),id2:s.getAttribute("id"),stroke1:v.hasStroke?v.strokeWidth.toNumber():0,stroke2:E.hasStroke?E.strokeWidth.toNumber():0,fillRule1:v.fillRule,fillRule2:E.fillRule})}if(x.length>0)t.setAttribute("data-collisions",JSON.stringify(x));return t});function at(t,a){if(a<=0||!t||t.length===0)return t;let e=0,i=0;for(let r of t)e+=r.x,i+=r.y;return e/=t.length,i/=t.length,t.map((r)=>{let l=r.x-e,o=r.y-i,x=Math.sqrt(l*l+o*o);if(x<0.0001)return r;let p=(x+a)/x;return{x:e+l*p,y:i+o*p}})}var F9=p3((t,a={})=>{let{id1:e,id2:i}=a;if(!e||!i)return t;let r=t.getElementById(e),l=t.getElementById(i);if(!r||!l)return t;let o=E0(r,a.samples||10),x=E0(l,a.samples||10);if(o&&x){let p=zi(o,x);t.setAttribute("data-distance",p.distance.toString())}return t}),G9=p3((t,a={})=>{let e=[],i=[],r=new Set,l=new Set,o=(p)=>{if(p.tagName.includes(":")){let n=p.tagName.split(":")[0];r.add(n)}for(let n of p.getAttributeNames()){let c=p.getAttribute(n);if(n==="xmlns")l.add("");else if(n.startsWith("xmlns:")){let s=n.substring(6);l.add(s)}if(n.includes(":")&&!n.startsWith("xmlns:")){let s=n.split(":")[0];r.add(s)}if(c&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(c))e.push(`Invalid XML characters in attribute '${n}' of <${p.tagName}>`)}if(p.textContent&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(p.textContent))e.push(`Invalid XML characters in text content of <${p.tagName}>`);for(let n of p.children)if(Z(n))o(n)};o(t);for(let p of r)if(p&&!l.has(p))e.push(`Unbound namespace prefix: '${p}' - SVGO would produce invalid XML here`);let x={valid:e.length===0,errors:e,warnings:i,namespacesUsed:[...r],namespacesDeclared:[...l]};return t.setAttribute("data-xml-validation",JSON.stringify(x)),t}),j9=p3((t,a={})=>{let e=[],i=[],r=a.version||"1.1";if(t.tagName!=="svg")e.push("Root element must be <svg>");let l=t.getAttribute("xmlns");if(!l)i.push("Missing xmlns attribute (required for standalone SVG)");else if(l!=="http://www.w3.org/2000/svg")e.push(`Invalid SVG namespace: expected 'http://www.w3.org/2000/svg', got '${l}'`);let o=t.getAttribute("viewBox");if(o){let s=o.split(/[\s,]+/);if(s.length!==4)e.push(`Invalid viewBox: expected 4 values, got ${s.length}`);else if(s.some((m)=>isNaN(parseFloat(m))))e.push("Invalid viewBox: contains non-numeric values");else{let[m,g,u,y]=s.map(parseFloat);if(u<0||y<0)e.push("Invalid viewBox: width and height must be non-negative")}}let x={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},p={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},n=(s,m=0)=>{if(!s||!s.tagName){i.push(`Element at depth ${m} has no tagName property`);return}let g=s.tagName.toLowerCase(),u=s.tagName;if(p[u])e.push(`Invalid SVG 2.0 element: <${u}> must be lowercase <${p[u]}> per SVG 2.0 specification`);if(g==="meshgradient"){let y=s.getAttribute("id");if(x.meshGradients.push(y||null),x.needsPolyfills=!0,!y)i.push("<meshgradient> element without 'id' attribute may be difficult to reference")}if(g==="hatch"){let y=s.getAttribute("id");if(x.hatches.push(y||null),x.needsPolyfills=!0,!y)i.push("<hatch> element without 'id' attribute may be difficult to reference")}if(g==="solidcolor"){let y=s.getAttribute("id");if(x.solidColors.push(y||null),x.needsPolyfills=!0,!y)i.push("<solidcolor> element without 'id' attribute may be difficult to reference")}if(g==="path"){let y=s.getAttribute("d");if(!y||!y.trim())e.push("<path> element missing required 'd' attribute");else{let v=y.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!v||v.length===0)e.push("<path> 'd' attribute contains no valid commands");let E=y.trim()[0];if(E!=="M"&&E!=="m")e.push("<path> 'd' must start with M or m command")}}if(g==="rect"){let y=s.getAttribute("width"),v=s.getAttribute("height");if(y!==null&&!Y4(y)&&parseFloat(y)<0)e.push("<rect> width must be non-negative");if(v!==null&&!Y4(v)&&parseFloat(v)<0)e.push("<rect> height must be non-negative")}if(g==="circle"){let y=s.getAttribute("r");if(y!==null&&parseFloat(y)<0)e.push("<circle> r must be non-negative")}if(g==="ellipse"){let y=s.getAttribute("rx"),v=s.getAttribute("ry");if(y!==null&&parseFloat(y)<0)e.push("<ellipse> rx must be non-negative");if(v!==null&&parseFloat(v)<0)e.push("<ellipse> ry must be non-negative")}if(g==="use"){let y=s.getAttribute("href")||s.getAttribute("xlink:href");if(y&&y.startsWith("#")){let v=y.substring(1);if(!t.getElementById(v))i.push(`<use> references non-existent ID: '${v}'`)}}for(let y of["fill","stroke","clip-path","mask","filter"]){let v=s.getAttribute(y);if(v&&v.startsWith("url(#")){let E=v.match(/url\(#([^)]+)\)/);if(E){let C=E[1];if(!t.getElementById(C))i.push(`<${s.tagName}> ${y} references non-existent ID: '${C}'`)}}}if(h0[g]){let y=h0[g];for(let v of s.children)if(Z(v)){let E=v.tagName.toLowerCase();if(!y.has(E))i.push(`<${E}> is not a standard child of <${g}>`)}}for(let y of s.children)if(Z(y))n(y,m+1)};if(n(t),x.needsPolyfills){let s=[];if(x.meshGradients.length>0)s.push(`meshgradient (${x.meshGradients.length} found)`);if(x.hatches.length>0)s.push(`hatch (${x.hatches.length} found)`);if(x.solidColors.length>0)s.push(`solidcolor (${x.solidColors.length} found)`);i.push(`SVG contains SVG 2.0 features that require polyfills for browser compatibility: ${s.join(", ")}. Use --svg2-polyfills option to inject runtime polyfills.`)}let c={valid:e.length===0,svgVersion:r,errors:e,warnings:i,elementsChecked:H9(t),svg2Features:x};if(t.setAttribute("data-svg-validation",JSON.stringify(c)),e.length>0)t.setAttribute("data-validation-errors",JSON.stringify(e));else t.setAttribute("data-validation-status","valid");return t}),Eo=new Set(["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout","keydown","keyup","keypress","activate","load","unload","abort","error","resize","scroll","beginEvent","endEvent","repeatEvent","touchstart","touchend","touchmove","touchcancel","wheel","auxclick","input","beforeinput","select","compositionstart","compositionupdate","compositionend"]),Co=p3((t,a={})=>{let e=a.verbose||!1,i=a.printTables!==!1,r={valid:!0,timestamp:new Date().toISOString(),media:{hasAudio:!1,hasVideo:!1,audioElements:[],videoElements:[],foreignObjectWithMedia:[],mediaEmbedMethod:null},smil:{hasAnimations:!1,animationCount:0,animationElements:{animate:0,animateTransform:0,animateMotion:0,animateColor:0,set:0},hasInteractiveAnimations:!1,eventTriggers:[],timingTriggers:[]},compatibility:{worksInAllBrowsers:!0,issues:[],recommendations:[]},errors:[],warnings:[],info:[]},l=(y)=>{let v=[],E=y.toLowerCase(),C=(P)=>{if(P.tagName&&P.tagName.toLowerCase()===E)v.push(P);for(let S of P.children||[])if(S&&S.tagName)C(S)};return C(t),v},o=(y,v=[])=>{if(y.tagName)v.push(y);for(let E of y.children||[])if(E&&E.tagName)o(E,v);return v},x=l("audio");if(x.length>0)r.media.hasAudio=!0,r.media.audioElements=x.map((y)=>({id:y.getAttribute("id"),src:y.getAttribute("src"),hasSource:l("source").filter((v)=>v.parentNode===y).length>0}));let p=l("video");if(p.length>0)r.media.hasVideo=!0,r.media.videoElements=p.map((y)=>({id:y.getAttribute("id"),src:y.getAttribute("src")}));let n=l("foreignObject");for(let y of n){let v=y.children||[],E=!1,C=[],P=(S)=>{let f=S.tagName?.toLowerCase();if(f==="audio"||f==="video")E=!0,C.push({type:f,id:S.getAttribute("id"),src:S.getAttribute("src")});for(let B of S.children||[])if(B&&B.tagName)P(B)};for(let S of v)if(S&&S.tagName)P(S);if(E)r.media.hasAudio=!0,r.media.foreignObjectWithMedia.push({id:y.getAttribute("id"),media:C}),r.media.mediaEmbedMethod="foreignObject"}let c=o(t);for(let y of c)for(let v of["src","href","xlink:href"]){let E=y.getAttribute(v);if(E&&E.startsWith("data:audio/"))r.media.hasAudio=!0,r.media.mediaEmbedMethod="data-uri";if(E&&E.startsWith("data:video/"))r.media.hasVideo=!0,r.media.mediaEmbedMethod="data-uri"}let s=["animate","animateTransform","animateMotion","animateColor","set"];for(let y of s){let v=l(y),E=v.length;r.smil.animationElements[y==="animateTransform"?"animateTransform":y==="animateMotion"?"animateMotion":y==="animateColor"?"animateColor":y]=E,r.smil.animationCount+=E;for(let C of v){let P=C.getAttribute("begin")||"",S=C.getAttribute("end")||"",f=(k,N)=>{let I=k.split(";").map((d)=>d.trim()).filter(Boolean);for(let d of I){let Y=d.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(Y){let[,X,F,V]=Y;if(Eo.has(F))r.smil.hasInteractiveAnimations=!0,r.smil.eventTriggers.push({animationElement:y,animationId:C.getAttribute("id"),attribute:N,event:F,targetId:X||null,offset:V?.trim()||null,parentId:C.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(d)||d==="indefinite")r.smil.timingTriggers.push({animationElement:y,value:d});else if(/\.(begin|end)/.test(d))r.smil.timingTriggers.push({animationElement:y,value:d,type:"syncbase"})}};if(P)f(P,"begin");if(S)f(S,"end");let B=C.getAttribute("onbegin"),R=C.getAttribute("onend");if(B||R){if(r.smil.hasInteractiveAnimations=!0,B?.includes("play()")||R?.includes("play()"))r.info.push(`Animation uses JavaScript to trigger audio playback via ${B?"onbegin":"onend"} handler`)}}}if(r.smil.hasAnimations=r.smil.animationCount>0,r.media.hasAudio)r.compatibility.worksInAllBrowsers=!1,r.warnings.push("SVG contains embedded audio. Browser autoplay policies will block playback in most scenarios."),r.compatibility.issues.push({type:"AUDIO_AUTOPLAY_BLOCKED",severity:"HIGH",description:"Embedded audio in SVG is blocked by Chrome/Firefox/Safari autoplay policies",affectedBrowsers:["Chrome","Firefox","Safari","Edge"]}),r.compatibility.recommendations.push("To enable audio playback, embed the SVG in an HTML page that extracts audio dynamically after user interaction","Use JavaScript to extract audio data URI from foreignObject and create Audio element on click","Consider using Web Audio API for more control over audio playback");if(r.media.hasVideo)r.compatibility.worksInAllBrowsers=!1,r.warnings.push("SVG contains embedded video. This has limited browser support and autoplay restrictions.");if(r.smil.hasAnimations)r.info.push(`SVG contains ${r.smil.animationCount} SMIL animation elements`),r.compatibility.issues.push({type:"SMIL_IE_UNSUPPORTED",severity:"LOW",description:"SMIL animations are not supported in IE11",affectedBrowsers:["IE (no support)"]});if(r.smil.hasInteractiveAnimations){let y=[...new Set(r.smil.eventTriggers.map((v)=>v.event))];if(r.info.push(`SVG contains interactive SMIL animations triggered by: ${y.join(", ")}`),y.includes("click")||y.includes("mouseover"))r.compatibility.recommendations.push("Interactive animations (click/hover) work in most browsers but require the SVG to be inline or loaded as <object>/<embed>","Using <img> tag to display SVG will disable all interactivity and animations")}let m={Chrome:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Autoplay blocked without user gesture"},Firefox:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"MEI (Media Engagement Index) affects autoplay"},Safari:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Strict autoplay policy"},Edge:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Chromium-based, same as Chrome"},"IE 11":{smil:"No support",audio:"No support",interactive:"No support",notes:"Use CSS animations or JavaScript"}},g=[{scenario:"Standalone SVG",protocol:"file://",example:"file:///path/to/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"Standalone SVG",protocol:"http://",example:"http://localhost/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"SVG in HTML via <img>",protocol:"any",example:'<img src="sample.svg">',smilWorks:!1,audioWorks:!1,interactiveWorks:!1,notes:"All scripting and interactivity disabled"},{scenario:"SVG in HTML via <object>",protocol:"any",example:'<object data="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"SVG in HTML via <embed>",protocol:"any",example:'<embed src="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"Inline SVG in HTML",protocol:"any",example:"<svg>...</svg> in HTML",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full features, audio needs user gesture"},{scenario:"HTML extracts audio on click",protocol:"file://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"},{scenario:"HTML extracts audio on click",protocol:"http://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"}],u=[{trigger:'begin="click"',description:"Animation starts on click (on animation target)",syntax:'<animate begin="click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Target element must be clickable (not in <defs>)"},{trigger:'begin="elementId.click"',description:"Animation starts when another element is clicked",syntax:'<animate begin="button.click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Referenced element must exist with matching id"},{trigger:'begin="mouseover"',description:"Animation starts on mouse hover",syntax:'<animate begin="mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Often paired with mouseout for hover effects"},{trigger:'begin="elementId.mouseover"',description:"Animation starts when hovering another element",syntax:'<animate begin="trigger.mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Useful for triggering animations on related elements"},{trigger:'begin="mouseout"',description:"Animation starts when mouse leaves",syntax:'<animate begin="mouseout" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Use with mouseover for complete hover cycle"},{trigger:'begin="focus"',description:"Animation starts when element receives focus",syntax:'<animate begin="focus" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Works with focusable elements (links, inputs)"},{trigger:'begin="accessKey(s)"',description:"Animation starts on keyboard shortcut",syntax:'<animate begin="accessKey(s)" .../>',browserSupport:"Limited",notes:"Press Alt+S (Windows) or Ctrl+Opt+S (Mac)"}];if(r.tables={browserSupport:m,usageScenarios:g,smilEventScenarios:u},i&&(r.media.hasAudio||r.media.hasVideo||r.smil.hasInteractiveAnimations)){if(console.log(`
|
|
17
|
+
`;gq(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<r$.ERROR)return;let Z=this._format("ERROR",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.error(Z,...J),this._bufferWrite(Z+K),this.flush()},warn($,...J){if(this.level<r$.WARN)return;let Z=this._format("WARN",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.warn(Z,...J),this._bufferWrite(Z+K)},info($,...J){if(this.level<r$.INFO)return;let Z=this._format("INFO",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},debug($,...J){if(this.level<r$.DEBUG)return;let Z=this._format("DEBUG",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},shutdown(){if(this._flushTimer)clearInterval(this._flushTimer),this._flushTimer=null;this.flush()}};var dq=V7;O.set({precision:80});var U0=($)=>$ instanceof O?$:new O($),t8=20;function Q$($,J=t8){if(typeof $!=="string")throw new Error("pathToPolygon: pathData must be a string");if(typeof J!=="number"||J<=0||!Number.isFinite(J))throw new Error(`pathToPolygon: samplesPerCurve must be a positive finite number, got ${J}`);let Z=[],K=U0(0),Q=U0(0),q=U0(0),H=U0(0),W=pq($);if(!Array.isArray(W))throw new Error("pathToPolygon: parsePathCommands must return an array");for(let z of W){let{type:j,args:G}=z;if(!Array.isArray(G))throw new Error(`pathToPolygon: command args must be an array for command ${j}`);switch(j){case"M":if(G.length<2)throw new Error(`pathToPolygon: M command requires 2 arguments, got ${G.length}`);K=U0(G[0]),Q=U0(G[1]),q=K,H=Q,Z.push(b0(K,Q));break;case"m":if(G.length<2)throw new Error(`pathToPolygon: m command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),q=K,H=Q,Z.push(b0(K,Q));break;case"L":if(G.length<2)throw new Error(`pathToPolygon: L command requires 2 arguments, got ${G.length}`);K=U0(G[0]),Q=U0(G[1]),Z.push(b0(K,Q));break;case"l":if(G.length<2)throw new Error(`pathToPolygon: l command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),Z.push(b0(K,Q));break;case"H":if(G.length<1)throw new Error(`pathToPolygon: H command requires 1 argument, got ${G.length}`);K=U0(G[0]),Z.push(b0(K,Q));break;case"h":if(G.length<1)throw new Error(`pathToPolygon: h command requires 1 argument, got ${G.length}`);K=K.plus(G[0]),Z.push(b0(K,Q));break;case"V":if(G.length<1)throw new Error(`pathToPolygon: V command requires 1 argument, got ${G.length}`);Q=U0(G[0]),Z.push(b0(K,Q));break;case"v":if(G.length<1)throw new Error(`pathToPolygon: v command requires 1 argument, got ${G.length}`);Q=Q.plus(G[0]),Z.push(b0(K,Q));break;case"C":if(G.length<6)throw new Error(`pathToPolygon: C command requires 6 arguments, got ${G.length}`);i8(Z,K,Q,U0(G[0]),U0(G[1]),U0(G[2]),U0(G[3]),U0(G[4]),U0(G[5]),J),K=U0(G[4]),Q=U0(G[5]);break;case"c":if(G.length<6)throw new Error(`pathToPolygon: c command requires 6 arguments, got ${G.length}`);i8(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),K.plus(G[4]),Q.plus(G[5]),J),K=K.plus(G[4]),Q=Q.plus(G[5]);break;case"Q":if(G.length<4)throw new Error(`pathToPolygon: Q command requires 4 arguments, got ${G.length}`);r8(Z,K,Q,U0(G[0]),U0(G[1]),U0(G[2]),U0(G[3]),J),K=U0(G[2]),Q=U0(G[3]);break;case"q":if(G.length<4)throw new Error(`pathToPolygon: q command requires 4 arguments, got ${G.length}`);r8(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),J),K=K.plus(G[2]),Q=Q.plus(G[3]);break;case"A":if(G.length<7)throw new Error(`pathToPolygon: A command requires 7 arguments, got ${G.length}`);a8(Z,K,Q,U0(G[0]),U0(G[1]),U0(G[2]),G[3],G[4],U0(G[5]),U0(G[6]),J),K=U0(G[5]),Q=U0(G[6]);break;case"a":if(G.length<7)throw new Error(`pathToPolygon: a command requires 7 arguments, got ${G.length}`);a8(Z,K,Q,U0(G[0]),U0(G[1]),U0(G[2]),G[3],G[4],K.plus(G[5]),Q.plus(G[6]),J),K=K.plus(G[5]),Q=Q.plus(G[6]);break;case"Z":case"z":K=q,Q=H;break;default:break}}return cq(Z)}function pq($){if(typeof $!=="string")throw new Error(`parsePathCommands: pathData must be a string, got ${typeof $}`);let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],q=K[2].trim(),H=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,W=q.length>0?Array.from(q.matchAll(H),(z)=>Number(z[0])):[];J.push({type:Q,args:W})}return J}function i8($,J,Z,K,Q,q,H,W,z,j){if(!Array.isArray($))throw new Error("sampleCubicBezier: points must be an array");if(typeof j!=="number"||j<=0||!Number.isFinite(j))throw new Error(`sampleCubicBezier: samples must be a positive finite number, got ${j}`);if(!(J instanceof O)||!(Z instanceof O)||!(K instanceof O)||!(Q instanceof O)||!(q instanceof O)||!(H instanceof O)||!(W instanceof O)||!(z instanceof O))throw new Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let G=1;G<=j;G++){let F=U0(G).div(j),_=U0(1).minus(F),U=_.mul(_),M=U.mul(_),V=F.mul(F),Y=V.mul(F),X=M.mul(J).plus(U0(3).mul(U).mul(F).mul(K)).plus(U0(3).mul(_).mul(V).mul(q)).plus(Y.mul(W)),k=M.mul(Z).plus(U0(3).mul(U).mul(F).mul(Q)).plus(U0(3).mul(_).mul(V).mul(H)).plus(Y.mul(z));$.push(b0(X,k))}}function r8($,J,Z,K,Q,q,H,W){if(!Array.isArray($))throw new Error("sampleQuadraticBezier: points must be an array");if(typeof W!=="number"||W<=0||!Number.isFinite(W))throw new Error(`sampleQuadraticBezier: samples must be a positive finite number, got ${W}`);if(!(J instanceof O)||!(Z instanceof O)||!(K instanceof O)||!(Q instanceof O)||!(q instanceof O)||!(H instanceof O))throw new Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let z=1;z<=W;z++){let j=U0(z).div(W),G=U0(1).minus(j),F=G.mul(G),_=j.mul(j),U=F.mul(J).plus(U0(2).mul(G).mul(j).mul(K)).plus(_.mul(q)),M=F.mul(Z).plus(U0(2).mul(G).mul(j).mul(Q)).plus(_.mul(H));$.push(b0(U,M))}}function a8($,J,Z,K,Q,q,H,W,z,j,G){if(!Array.isArray($))throw new Error("sampleArc: points must be an array");if(typeof G!=="number"||G<=0||!Number.isFinite(G))throw new Error(`sampleArc: samples must be a positive finite number, got ${G}`);if(!(J instanceof O)||!(Z instanceof O)||!(K instanceof O)||!(Q instanceof O)||!(q instanceof O)||!(z instanceof O)||!(j instanceof O))throw new Error("sampleArc: all coordinate and angle parameters must be Decimal instances");if(typeof H!=="number"||H!==0&&H!==1)throw new Error(`sampleArc: largeArc must be 0 or 1, got ${H}`);if(typeof W!=="number"||W!==0&&W!==1)throw new Error(`sampleArc: sweep must be 0 or 1, got ${W}`);if(K.eq(0)||Q.eq(0)){$.push(b0(z,j));return}let F=K.abs(),_=Q.abs(),U=q.mul(Math.PI).div(180),M=U.cos(),V=U.sin(),Y=J.minus(z).div(2),X=Z.minus(j).div(2),k=M.mul(Y).plus(V.mul(X)),w=M.mul(X).minus(V.mul(Y)),R=F.mul(F),I=_.mul(_),P=k.mul(k),u=w.mul(w),g=P.div(R).plus(u.div(I));if(g.gt(1)){let $0=g.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),I=_.mul(_)}let b=R.mul(I).minus(R.mul(u)).minus(I.mul(P));if(b=b.div(R.mul(u).plus(I.mul(P))),b.lt(0))b=U0(0);if(b=b.sqrt(),H===W)b=b.neg();let h=b.mul(K).mul(w).div(Q),v=b.neg().mul(Q).mul(k).div(K),E=J.plus(z).div(2),m=Z.plus(j).div(2),c=M.mul(h).minus(V.mul(v)).plus(E),d=V.mul(h).plus(M.mul(v)).plus(m),N=k.minus(h).div(K),y=w.minus(v).div(Q),B=k.neg().minus(h).div(K),t=w.neg().minus(v).div(Q),i=N.mul(N).plus(y.mul(y)).sqrt();if(i.eq(0)){g6.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(b0(z,j));return}let l=O.acos(N.div(i));if(y.lt(0))l=l.neg();let q0=i.mul(B.mul(B).plus(t.mul(t)).sqrt());if(q0.eq(0)){g6.warn("sampleArc: degenerate arc - zero length, treating as single point"),$.push(b0(z,j));return}let f=O.acos(N.mul(B).plus(y.mul(t)).div(q0));if(N.mul(t).minus(y.mul(B)).lt(0))f=f.neg();let A=U0(Math.PI),e=A.mul(2);if(W&&f.lt(0))f=f.plus(e);else if(!W&&f.gt(0))f=f.minus(e);for(let $0=1;$0<=G;$0++){let Q0=U0($0).div(G),V0=l.plus(f.mul(Q0)),N0=V0.cos(),h0=V0.sin(),o=M.mul(K.mul(N0)).minus(V.mul(Q.mul(h0))).plus(c),J0=V.mul(K.mul(N0)).plus(M.mul(Q.mul(h0))).plus(d);$.push(b0(o,J0))}}function cq($){if(!Array.isArray($))throw new Error("removeDuplicateConsecutive: points must be an array");if($.length<2)return $;let J=[$[0]];for(let Z=1;Z<$.length;Z++)if(!d7($[Z],J[J.length-1]))J.push($[Z]);return J}function P$($,J=null,Z=t8,K=4){if(!$||typeof $!=="object")throw new Error("shapeToPolygon: element must be an object");if(!$.type||typeof $.type!=="string")throw new Error("shapeToPolygon: element.type must be a string");if(typeof Z!=="number"||Z<=0||!Number.isFinite(Z))throw new Error(`shapeToPolygon: samples must be a positive finite number, got ${Z}`);if(typeof K!=="number"||K<=0||!Number.isFinite(K))throw new Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${K}`);if(J!==null&&!(J instanceof W0))throw new Error("shapeToPolygon: ctm must be null or a Matrix instance");let Q;switch($.type){case"circle":if(K>4)Q=X9($.cx||0,$.cy||0,$.r||0,K,10);else Q=A8(U0($.cx||0),U0($.cy||0),U0($.r||0));break;case"ellipse":if(K>4)Q=C6($.cx||0,$.cy||0,$.rx||0,$.ry||0,K,10);else Q=w9(U0($.cx||0),U0($.cy||0),U0($.rx||0),U0($.ry||0));break;case"rect":Q=E8(U0($.x||0),U0($.y||0),U0($.width||0),U0($.height||0),U0($.rx||0),$.ry!==void 0?U0($.ry):null);break;case"line":Q=T8(U0($.x1||0),U0($.y1||0),U0($.x2||0),U0($.y2||0));break;case"polygon":Q=b8($.points||"");break;case"polyline":Q=f8($.points||"");break;case"path":Q=$.d||"";break;default:return[]}if($.transform){let q=dq($.transform);if(!(q instanceof W0))throw new Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof q}`);Q=C$(Q,q)}if(J)Q=C$(Q,J);return Q$(Q,Z)}function b9($,J=6){if(!Array.isArray($))throw new Error("polygonToPathData: polygon must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error(`polygonToPathData: precision must be a non-negative finite number, got ${J}`);if($.length<2)return"";let Z=(Q)=>(Q instanceof O?Q:U0(Q)).toFixed(J).replace(/\.?0+$/,""),K=`M ${Z($[0].x)} ${Z($[0].y)}`;for(let Q=1;Q<$.length;Q++)K+=` L ${Z($[Q].x)} ${Z($[Q].y)}`;return K+" Z"}O.set({precision:80});O.set({precision:80});var e8=($)=>$ instanceof O?$:new O($),$5=-0.1,J5=-0.1,Z5=1.2,K5=1.2,x6={LUMINANCE:"luminance",ALPHA:"alpha"};function Q5($){if(!$)throw new Error("parseMaskElement: maskElement is required");if(!$.getAttribute)throw new Error("parseMaskElement: maskElement must be a DOM element");let J={id:$.getAttribute("id")||"",maskUnits:$.getAttribute("maskUnits")||"objectBoundingBox",maskContentUnits:$.getAttribute("maskContentUnits")||"userSpaceOnUse",maskType:$.getAttribute("mask-type")||$.style?.maskType||"luminance",x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),transform:$.getAttribute("transform")||null,children:[]},Z=(K,Q)=>{let q=parseFloat(K);return isNaN(q)?Q:q};if(J.maskUnits==="objectBoundingBox")J.x=J.x!==null?Z(J.x,$5):$5,J.y=J.y!==null?Z(J.y,J5):J5,J.width=J.width!==null?Z(J.width,Z5):Z5,J.height=J.height!==null?Z(J.height,K5):K5;else J.x=J.x!==null?Z(J.x,null):null,J.y=J.y!==null?Z(J.y,null):null,J.width=J.width!==null?Z(J.width,null):null,J.height=J.height!==null?Z(J.height,null):null;if(!$.children)return J;for(let K of $.children){if(!K.tagName)continue;let Q=K.tagName.toLowerCase(),q={type:Q,fill:K.getAttribute("fill")||K.style?.fill||"black",fillOpacity:Z(K.getAttribute("fill-opacity")||K.style?.fillOpacity||"1",1),opacity:Z(K.getAttribute("opacity")||K.style?.opacity||"1",1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":q.x=Z(K.getAttribute("x")||"0",0),q.y=Z(K.getAttribute("y")||"0",0),q.width=Z(K.getAttribute("width")||"0",0),q.height=Z(K.getAttribute("height")||"0",0),q.rx=Z(K.getAttribute("rx")||"0",0),q.ry=Z(K.getAttribute("ry")||"0",0);break;case"circle":q.cx=Z(K.getAttribute("cx")||"0",0),q.cy=Z(K.getAttribute("cy")||"0",0),q.r=Z(K.getAttribute("r")||"0",0);break;case"ellipse":q.cx=Z(K.getAttribute("cx")||"0",0),q.cy=Z(K.getAttribute("cy")||"0",0),q.rx=Z(K.getAttribute("rx")||"0",0),q.ry=Z(K.getAttribute("ry")||"0",0);break;case"path":q.d=K.getAttribute("d")||"";break;case"polygon":q.points=K.getAttribute("points")||"";break;case"polyline":q.points=K.getAttribute("points")||"";break;case"g":if(q.children=[],K.children){for(let H of K.children)if(H.tagName)q.children.push({type:H.tagName.toLowerCase(),fill:H.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(q)}return J}function nq($,J,Z,K=20){if(!$)throw new Error("maskChildToPolygon: child is required");if(!J)throw new Error("maskChildToPolygon: targetBBox is required");if(!Z)throw new Error("maskChildToPolygon: contentUnits is required");if(typeof K!=="number"||K<=0)throw new Error("maskChildToPolygon: samples must be a positive number");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("maskChildToPolygon: targetBBox must have numeric x, y, width, height properties");if(J.width<0||J.height<0)throw new Error("maskChildToPolygon: targetBBox width and height cannot be negative");let Q={type:$.type,...$,transform:$.transform},q=P$(Q,null,K);if(!Array.isArray(q))return[];if(Z==="objectBoundingBox"&&q.length>0){if(J.width===0||J.height===0)return[];q=q.map((H)=>({x:e8(J.x).plus(H.x.mul(J.width)),y:e8(J.y).plus(H.y.mul(J.height))}))}return q}function lq($){if(!$||$==="none"||$==="transparent")return 0;if(typeof $!=="string")return 0;let J=$.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(J){let q=parseInt(J[1],10),H=parseInt(J[2],10),W=parseInt(J[3],10);if(isNaN(q)||isNaN(H)||isNaN(W))return 0;let z=Math.max(0,Math.min(255,q))/255,j=Math.max(0,Math.min(255,H))/255,G=Math.max(0,Math.min(255,W))/255,F=0.2126*z+0.7152*j+0.0722*G;return isNaN(F)?0:F}let Z=$.match(/^#([0-9a-f]{3,6})$/i);if(Z){let q=Z[1];if(q.length===3)q=q[0]+q[0]+q[1]+q[1]+q[2]+q[2];let H=parseInt(q.slice(0,2),16),W=parseInt(q.slice(2,4),16),z=parseInt(q.slice(4,6),16);if(isNaN(H)||isNaN(W)||isNaN(z))return 0;let j=0.2126*(H/255)+0.7152*(W/255)+0.0722*(z/255);return isNaN(j)?0:j}let K={white:1,black:0,red:0.2126,green:0.7152,blue:0.0722,yellow:0.9278,cyan:0.7874,magenta:0.2848,gray:0.5,grey:0.5},Q=$.toLowerCase();if(K[Q]!==void 0)return K[Q];return 0}function sq($,J){if(!$)throw new Error("getMaskChildOpacity: child is required");if(!J)throw new Error("getMaskChildOpacity: maskType is required");if(J!==x6.LUMINANCE&&J!==x6.ALPHA)throw new Error('getMaskChildOpacity: maskType must be "luminance" or "alpha"');let Z=typeof $.fillOpacity==="number"&&!isNaN($.fillOpacity)?$.fillOpacity:1,K=typeof $.opacity==="number"&&!isNaN($.opacity)?$.opacity:1,Q=Z*K;if(J===x6.ALPHA)return Q;let q=lq($.fill),H=Q*q;return isNaN(H)?0:H}function oq($,J,Z={}){if(!$)throw new Error("resolveMask: maskData is required");if(!J)throw new Error("resolveMask: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolveMask: maskData.children must be an array");let{samples:K=20}=Z;if(typeof K!=="number"||K<=0)throw new Error("resolveMask: samples must be a positive number");let Q=$.maskType||x6.LUMINANCE,q=[];for(let H of $.children){if(!H)continue;let W=nq(H,J,$.maskContentUnits,K);if(W.length>=3){let z=sq(H,Q);q.push({polygon:W,opacity:z})}}return q}function iq($,J,Z=0.5,K={}){if(!$)throw new Error("maskToClipPath: maskData is required");if(!J)throw new Error("maskToClipPath: targetBBox is required");if(typeof Z!=="number"||Z<0||Z>1)throw new Error("maskToClipPath: opacityThreshold must be a number between 0 and 1");let Q=oq($,J,K),q=[];for(let{polygon:H,opacity:W}of Q)if(W>=Z&&H&&H.length>=3)if(q.length===0)q=H;else{let z=_$(q,H);if(z.length>0&&z[0].length>=3)q=z[0]}return q}function q5($,J,Z={}){if(!$)throw new Error("maskToPathData: maskData is required");if(!J)throw new Error("maskToPathData: targetBBox is required");let K=iq($,J,0.5,Z);if(K.length<3)return"";let Q="",q=0;for(let H=0;H<K.length;H++){let W=K[H];if(!W||W.x===void 0||W.y===void 0)continue;let z=Number(W.x),j=Number(W.y);if(isNaN(z)||isNaN(j)||!isFinite(z)||!isFinite(j))continue;let G=z.toFixed(6),F=j.toFixed(6);Q+=q===0?`M ${G} ${F}`:` L ${G} ${F}`,q++}if(q>=3)Q+=" Z";else return"";return Q}O.set({precision:80});function H5($){if(!$)throw new Error("parseUseElement: useElement is required");let J=$.getAttribute("href")||$.getAttribute("xlink:href")||"",Z=J.startsWith("#")?J.slice(1):J;if(!Z)throw new Error("parseUseElement: href attribute must reference a valid element id (found empty reference)");let K=parseFloat($.getAttribute("x")||"0"),Q=parseFloat($.getAttribute("y")||"0");if(isNaN(K)||isNaN(Q)||!isFinite(K)||!isFinite(Q))throw new Error("parseUseElement: x and y attributes must be valid finite numbers");let q=null,H=null;if($.getAttribute("width")){if(q=parseFloat($.getAttribute("width")),isNaN(q)||!isFinite(q)||q<=0)throw new Error("parseUseElement: width attribute must be a valid positive finite number")}if($.getAttribute("height")){if(H=parseFloat($.getAttribute("height")),isNaN(H)||!isFinite(H)||H<=0)throw new Error("parseUseElement: height attribute must be a valid positive finite number")}return{href:Z,x:K,y:Q,width:q,height:H,transform:$.getAttribute("transform")||null,style:z5($)}}function W5($){if(!$)throw new Error("parseSymbolElement: symbolElement is required");let J=parseFloat($.getAttribute("refX")||"0"),Z=parseFloat($.getAttribute("refY")||"0");if(isNaN(J)||isNaN(Z)||!isFinite(J)||!isFinite(Z))throw new Error("parseSymbolElement: refX and refY must be valid finite numbers");let K={id:$.getAttribute("id")||"",viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",children:[],refX:J,refY:Z};if(K.viewBox){let Q=K.viewBox.trim().split(/[\s,]+/).map(Number);if(Q.length===4&&Q.every((q)=>!isNaN(q)&&isFinite(q)))K.viewBoxParsed={x:Q[0],y:Q[1],width:Q[2],height:Q[3]}}for(let Q of $.children)K.children.push(m6(Q));return K}function m6($){if(!$||!$.tagName)throw new Error("parseChildElement: element with tagName is required");let J=$.tagName.toLowerCase(),Z={type:J,id:$.getAttribute("id")||null,transform:$.getAttribute("transform")||null,style:z5($)},K=(Q,q="0")=>{let H=parseFloat($.getAttribute(Q)||q);if(isNaN(H)||!isFinite(H))throw new Error(`parseChildElement: ${Q} must be a valid finite number in ${J} element`);return H};switch(J){case"rect":Z.x=K("x"),Z.y=K("y"),Z.width=K("width"),Z.height=K("height"),Z.rx=K("rx"),Z.ry=K("ry");break;case"circle":Z.cx=K("cx"),Z.cy=K("cy"),Z.r=K("r");break;case"ellipse":Z.cx=K("cx"),Z.cy=K("cy"),Z.rx=K("rx"),Z.ry=K("ry");break;case"path":Z.d=$.getAttribute("d")||"";break;case"polygon":Z.points=$.getAttribute("points")||"";break;case"polyline":Z.points=$.getAttribute("points")||"";break;case"line":Z.x1=K("x1"),Z.y1=K("y1"),Z.x2=K("x2"),Z.y2=K("y2");break;case"g":Z.children=[];for(let Q of $.children)Z.children.push(m6(Q));break;case"use":Z.href=($.getAttribute("href")||$.getAttribute("xlink:href")||"").replace("#",""),Z.x=K("x"),Z.y=K("y"),Z.width=$.getAttribute("width")?K("width"):null,Z.height=$.getAttribute("height")?K("height"):null;break;default:break}return Z}function z5($){if(!$)throw new Error("extractStyleAttributes: element is required");return{fill:$.getAttribute("fill"),stroke:$.getAttribute("stroke"),strokeWidth:$.getAttribute("stroke-width"),opacity:$.getAttribute("opacity"),fillOpacity:$.getAttribute("fill-opacity"),strokeOpacity:$.getAttribute("stroke-opacity"),visibility:$.getAttribute("visibility"),display:$.getAttribute("display")}}function aq($,J,Z,K="xMidYMid meet"){if(!$||!J||!Z)return W0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return W0.identity(3);let{width:Q,height:q,x:H,y:W}=$;if(!isFinite(Q)||!isFinite(q)||!isFinite(H)||!isFinite(W)||Q<=0||q<=0)return W0.identity(3);let z=K.trim().split(/\s+/),j=z[0]||"xMidYMid",G=z[1]||"meet";if(j==="none"){let k=J/Q,w=Z/q;return r0(-H*k,-W*w).mul(w7(k,w))}let F=J/Q,_=Z/q,U;if(G==="slice")U=Math.max(F,_);else U=Math.min(F,_);let M=-H*U,V=-W*U,Y=Q*U,X=q*U;if(j.includes("xMid"))M+=(J-Y)/2;else if(j.includes("xMax"))M+=J-Y;if(j.includes("YMid"))V+=(Z-X)/2;else if(j.includes("YMax"))V+=Z-X;return r0(M,V).mul(w7(U,U))}function S9($,J,Z={}){if(!$||!$.href)throw new Error("resolveUse: useData with href property is required");if(!J)throw new Error("resolveUse: defs map is required");if(typeof $.x!=="number"||isNaN($.x)||!isFinite($.x))throw new Error("resolveUse: useData.x must be a valid finite number");if(typeof $.y!=="number"||isNaN($.y)||!isFinite($.y))throw new Error("resolveUse: useData.y must be a valid finite number");if($.width!==null&&(typeof $.width!=="number"||isNaN($.width)||!isFinite($.width)||$.width<=0))throw new Error("resolveUse: useData.width must be null or a positive finite number");if($.height!==null&&(typeof $.height!=="number"||isNaN($.height)||!isFinite($.height)||$.height<=0))throw new Error("resolveUse: useData.height must be null or a positive finite number");if($.style!==null&&$.style!==void 0){if(typeof $.style!=="object"||Array.isArray($.style))throw new Error("resolveUse: useData.style must be null, undefined, or a valid non-array object")}if($.transform!==null&&$.transform!==void 0&&typeof $.transform!=="string")throw new Error("resolveUse: useData.transform must be null, undefined, or a string");if(Z&&typeof Z!=="object")throw new Error("resolveUse: options must be an object or undefined");let{maxDepth:K=10,_visited:Q=new Set}=Z;if(typeof K!=="number"||K<=0||!isFinite(K))throw new Error("resolveUse: maxDepth must be a positive finite number");if(Q.has($.href))return console.warn(`resolveUse: circular reference detected for '#${$.href}', skipping to prevent infinite loop`),null;let q=J[$.href];if(!q)return console.warn(`resolveUse: target element '#${$.href}' not found in defs map`),null;Q.add($.href);let H=r0($.x,$.y);if($.transform){let j=V7($.transform);H=H.mul(j)}if(q.type==="symbol"&&q.viewBoxParsed){if(typeof q.viewBoxParsed.x!=="number"||typeof q.viewBoxParsed.y!=="number"||typeof q.viewBoxParsed.width!=="number"||typeof q.viewBoxParsed.height!=="number"||!isFinite(q.viewBoxParsed.x)||!isFinite(q.viewBoxParsed.y)||!isFinite(q.viewBoxParsed.width)||!isFinite(q.viewBoxParsed.height)||q.viewBoxParsed.width<=0||q.viewBoxParsed.height<=0)throw new Error("resolveUse: target.viewBoxParsed must have finite x, y and positive finite width, height");let j=$.width!==null?$.width:q.viewBoxParsed.width,G=$.height!==null?$.height:q.viewBoxParsed.height;H=aq(q.viewBoxParsed,j,G,q.preserveAspectRatio||"xMidYMid meet").mul(H)}let W=[],z=q.children&&Array.isArray(q.children)&&q.children.length>0?q.children:[q];for(let j of z)if(j.type==="use"){if(K<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${j.href}', skipping nested resolution`);continue}let G=S9(j,J,{maxDepth:K-1,_visited:Q});if(G)W.push(G)}else W.push({element:j,transform:W0.identity(3)});return Q.delete($.href),{element:q,transform:H,children:W,inheritedStyle:$.style}}function j5($,J=20){let Z=[];if(!$)return Z;if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("flattenResolvedUse: samples must be a positive finite number");if(!$.children||!$.transform)return Z;for(let K of $.children){if(!K||!K.transform)continue;let Q=$.transform.mul(K.transform),q=K.element;if(K.children){let H=j5(K,J);for(let W of H)W.polygon=W.polygon.map((z)=>{let[j,G]=c0($.transform,z.x,z.y);return{x:j,y:G}}),Z.push(W)}else{let H=tq(q,Q,J);if(H.length>=3)Z.push({polygon:H,style:eq($.inheritedStyle,q.style)})}}return Z}function tq($,J,Z=20){if(!$)throw new Error("elementToPolygon: element is required");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("elementToPolygon: samples must be a positive finite number");let K=P$($,null,Z);if(J&&K.length>0)K=K.map((Q)=>{let[q,H]=c0(J,Q.x,Q.y);return{x:q,y:H}});return K}function eq($,J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("mergeStyles: element must be a valid non-array object");let Z={...J};if($!==null&&$!==void 0){if(typeof $!=="object"||Array.isArray($))throw new Error("mergeStyles: inherited must be null, undefined, or a valid non-array object")}for(let[K,Q]of Object.entries($||{}))if(Q!==null&&(Z[K]===null||Z[K]===void 0))Z[K]=Q;return Z}function G5($,J=20){if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("resolvedUseToPathData: samples must be a positive finite number");let Z=j5($,J),K=[];for(let{polygon:Q}of Z)if(Q.length>=3){let q="";for(let H=0;H<Q.length;H++){let W=Q[H],z=Number(W.x),j=Number(W.y);if(isNaN(z)||isNaN(j))continue;q+=H===0?`M ${z.toFixed(6)} ${j.toFixed(6)}`:` L ${z.toFixed(6)} ${j.toFixed(6)}`}q+=" Z",K.push(q)}return K.join(" ")}O.set({precision:80});var W7=($)=>$ instanceof O?$:new O($);function F5($){if(!$)throw new Error("parsePatternElement: patternElement is required");if(typeof $.getAttribute!=="function")throw new Error("parsePatternElement: patternElement must be a DOM element with getAttribute method");let J={id:$.getAttribute("id")||"",patternUnits:$.getAttribute("patternUnits")||"objectBoundingBox",patternContentUnits:$.getAttribute("patternContentUnits")||"userSpaceOnUse",patternTransform:$.getAttribute("patternTransform")||null,x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",href:$.getAttribute("href")||$.getAttribute("xlink:href")||null,children:[]},Z=(K,Q)=>{if(K===null||K===void 0)return Q;let q=parseFloat(K);return isNaN(q)?Q:q};if(J.x=Z(J.x,0),J.y=Z(J.y,0),J.width=Z(J.width,0),J.height=Z(J.height,0),J.viewBox){let K=J.viewBox.trim().split(/[\s,]+/).map(Number);if(K.length===4&&K.every((Q)=>!isNaN(Q)&&isFinite(Q)))J.viewBoxParsed={x:K[0],y:K[1],width:K[2],height:K[3]}}if($.children&&typeof $.children[Symbol.iterator]==="function")for(let K of $.children){if(!K||typeof K.getAttribute!=="function")continue;let Q=K.tagName?K.tagName.toLowerCase():"";if(!Q)continue;let q={type:Q,fill:K.getAttribute("fill")||"black",stroke:K.getAttribute("stroke")||"none",strokeWidth:Z(K.getAttribute("stroke-width"),1),opacity:Z(K.getAttribute("opacity"),1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":q.x=Z(K.getAttribute("x"),0),q.y=Z(K.getAttribute("y"),0),q.width=Z(K.getAttribute("width"),0),q.height=Z(K.getAttribute("height"),0),q.rx=Z(K.getAttribute("rx"),0),q.ry=Z(K.getAttribute("ry"),0);break;case"circle":q.cx=Z(K.getAttribute("cx"),0),q.cy=Z(K.getAttribute("cy"),0),q.r=Z(K.getAttribute("r"),0);break;case"ellipse":q.cx=Z(K.getAttribute("cx"),0),q.cy=Z(K.getAttribute("cy"),0),q.rx=Z(K.getAttribute("rx"),0),q.ry=Z(K.getAttribute("ry"),0);break;case"path":q.d=K.getAttribute("d")||"";break;case"polygon":q.points=K.getAttribute("points")||"";break;case"polyline":q.points=K.getAttribute("points")||"";break;case"line":q.x1=Z(K.getAttribute("x1"),0),q.y1=Z(K.getAttribute("y1"),0),q.x2=Z(K.getAttribute("x2"),0),q.y2=Z(K.getAttribute("y2"),0);break;case"use":q.href=K.getAttribute("href")||K.getAttribute("xlink:href")||"",q.x=Z(K.getAttribute("x"),0),q.y=Z(K.getAttribute("y"),0);break;case"g":if(q.children=[],K.children&&typeof K.children[Symbol.iterator]==="function"){for(let H of K.children)if(H&&H.tagName&&typeof H.getAttribute==="function")q.children.push({type:H.tagName.toLowerCase(),fill:H.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(q)}return J}function JH($,J){if(!$)throw new Error("getPatternTile: patternData is required");if(!J)throw new Error("getPatternTile: targetBBox is required");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getPatternTile: targetBBox must have numeric x, y, width, and height properties");if(typeof $.x!=="number"||typeof $.y!=="number"||typeof $.width!=="number"||typeof $.height!=="number")throw new Error("getPatternTile: patternData must have numeric x, y, width, and height properties");if($.patternUnits==="objectBoundingBox")return{x:W7(J.x).plus(W7($.x).mul(J.width)),y:W7(J.y).plus(W7($.y).mul(J.height)),width:W7($.width).mul(J.width),height:W7($.height).mul(J.height)};return{x:W7($.x),y:W7($.y),width:W7($.width),height:W7($.height)}}function ZH($,J,Z){if(!$)throw new Error("getPatternContentTransform: patternData is required");if(!J)throw new Error("getPatternContentTransform: tile is required");if(!Z)throw new Error("getPatternContentTransform: targetBBox is required");if(!J.width||!J.height)throw new Error("getPatternContentTransform: tile must have width and height properties");if(typeof Z.x!=="number"||typeof Z.y!=="number"||typeof Z.width!=="number"||typeof Z.height!=="number")throw new Error("getPatternContentTransform: targetBBox must have numeric x, y, width, and height properties");let K=W0.identity(3);if($.viewBoxParsed){let Q=$.viewBoxParsed;if(typeof Q.x!=="number"||typeof Q.y!=="number"||typeof Q.width!=="number"||typeof Q.height!=="number")throw new Error("getPatternContentTransform: viewBoxParsed must have numeric x, y, width, and height properties");let q=Number(J.width),H=Number(J.height);if(q===0||H===0)throw new Error("getPatternContentTransform: tile width and height must be non-zero when viewBox is present");if(Q.width===0||Q.height===0)throw new Error("getPatternContentTransform: viewBox width and height must be non-zero");let W=q/Q.width,z=H/Q.height,j=Math.min(W,z);if(!isFinite(j))throw new Error("getPatternContentTransform: computed scale is not finite");let G=(q-Q.width*j)/2,F=(H-Q.height*j)/2;K=K.mul(r0(G-Q.x*j,F-Q.y*j)),K=K.mul(w7(j,j))}if($.patternContentUnits==="objectBoundingBox"){if(Z.width===0||Z.height===0)throw new Error("getPatternContentTransform: targetBBox width and height must be non-zero when patternContentUnits is objectBoundingBox");K=K.mul(r0(Z.x,Z.y)),K=K.mul(w7(Z.width,Z.height))}return K}function KH($,J=null,Z=20){if(!$)throw new Error("patternChildToPolygon: child is required");if(!$.type)throw new Error("patternChildToPolygon: child must have a type property");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("patternChildToPolygon: samples must be a positive finite number");let K={type:$.type,...$,transform:$.transform},Q=P$(K,null,Z);if(!Array.isArray(Q))return[];if(J&&Q.length>0)Q=Q.map((q)=>{if(!q||typeof q.x!=="number"||typeof q.y!=="number")throw new Error("patternChildToPolygon: invalid polygon point - must have numeric x and y properties");let[H,W]=c0(J,q.x,q.y);return{x:H,y:W}});return Q}function QH($,J){if(!$)throw new Error("getTilePositions: tile is required");if(!J)throw new Error("getTilePositions: coverBBox is required");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getTilePositions: tile must have x, y, width, and height properties");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getTilePositions: coverBBox must have numeric x, y, width, and height properties");let Z=[],K=Number($.x),Q=Number($.y),q=Number($.width),H=Number($.height);if(!isFinite(K)||!isFinite(Q)||!isFinite(q)||!isFinite(H))throw new Error("getTilePositions: tile dimensions must be finite numbers");if(q<=0||H<=0)return Z;let W=Math.floor((J.x-K)/q),z=Math.ceil((J.x+J.width-K)/q),j=Math.floor((J.y-Q)/H),G=Math.ceil((J.y+J.height-Q)/H);if(!isFinite(W)||!isFinite(z)||!isFinite(j)||!isFinite(G))throw new Error("getTilePositions: computed tile indices are not finite");for(let F=W;F<z;F++)for(let _=j;_<G;_++)Z.push({x:W7(K).plus(W7(q).mul(F)),y:W7(Q).plus(W7(H).mul(_))});return Z}function qH($,J,Z={}){if(!$)throw new Error("resolvePattern: patternData is required");if(!J)throw new Error("resolvePattern: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolvePattern: patternData.children must be an array");let{samples:K=20,maxTiles:Q=1000}=Z,q=[],H=JH($,J);if(Number(H.width)<=0||Number(H.height)<=0)return q;let W=ZH($,H,J),z=WH($.patternTransform),G=QH(H,J).slice(0,Q);for(let F of G){let _=r0(F.x,F.y);for(let U of $.children){let M=z.mul(_.mul(W)),V=KH(U,M,K);if(V.length>=3)q.push({polygon:V,fill:U.fill,stroke:U.stroke,strokeWidth:U.strokeWidth,opacity:U.opacity})}}return q}function HH($,J,Z={}){if(!$)throw new Error("patternToClipPath: patternData is required");if(!J)throw new Error("patternToClipPath: targetBBox is required");let K=qH($,J,Z),Q=[];for(let{polygon:q,opacity:H}of K)if(H>0&&q.length>=3)if(Q.length===0)Q=q;else{let W=_$(Q,q);if(Array.isArray(W)&&W.length>0&&Array.isArray(W[0])&&W[0].length>=3)Q=W[0]}return Q}function _5($,J,Z={}){if(!$)throw new Error("patternToPathData: patternData is required");if(!J)throw new Error("patternToPathData: targetBBox is required");let K=HH($,J,Z);if(!Array.isArray(K))return"";if(K.length<3)return"";let Q="";for(let q=0;q<K.length;q++){let H=K[q];if(!H||typeof H.x!=="number"||typeof H.y!=="number")throw new Error("patternToPathData: invalid polygon point - must have numeric x and y properties");if(!isFinite(H.x)||!isFinite(H.y))throw new Error("patternToPathData: polygon point coordinates must be finite numbers");let W=Number(H.x).toFixed(6),z=Number(H.y).toFixed(6);Q+=q===0?`M ${W} ${z}`:` L ${W} ${z}`}return Q+=" Z",Q}function WH($){if(!$)return W0.identity(3);return(void 0)($)}O.set({precision:80});function v9($,J,Z,K=1,Q=!1){if(!$)throw new Error("getMarkerTransform: markerDef is required");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new Error("getMarkerTransform: position must be an object with x and y numeric properties");if(typeof Z!=="number"||isNaN(Z)||!isFinite(Z))throw new Error("getMarkerTransform: tangentAngle must be a valid finite number");if(typeof K!=="number"||isNaN(K)||K<=0)throw new Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:q,markerHeight:H,refX:W,refY:z,orient:j,markerUnits:G,viewBox:F}=$;if(typeof q!=="number"||q<=0)throw new Error("getMarkerTransform: markerDef.markerWidth must be a positive number");if(typeof H!=="number"||H<=0)throw new Error("getMarkerTransform: markerDef.markerHeight must be a positive number");if(typeof W!=="number"||!isFinite(W))throw new Error("getMarkerTransform: markerDef.refX must be a finite number");if(typeof z!=="number"||!isFinite(z))throw new Error("getMarkerTransform: markerDef.refY must be a finite number");let _=W0.identity(3),U=r0(J.x,J.y);_=_.mul(U);let M=0;if(j==="auto")M=Z;else if(j==="auto-start-reverse")M=Q?Z+Math.PI:Z;else if(typeof j==="number")M=j*(Math.PI/180);if(M!==0){let k=j$(M);_=_.mul(k)}let V=1,Y=1;if(G==="strokeWidth")V=K,Y=K;if(F){let{width:k,height:w}=F;if(k>0&&w>0&&isFinite(k)&&isFinite(w)){let R=q/k,I=H/w;if(isFinite(R)&&isFinite(I)){let P=Math.min(R,I);V*=P,Y*=P;let u=r0(-F.x,-F.y);_=_.mul(u)}}}if(V!==1||Y!==1){let k=w7(V,Y);_=_.mul(k)}let X=r0(-W,-z);return _=_.mul(X),_}function jH($){if(typeof $!=="string")throw new Error("getPathVertices: pathData must be a string");let J=[],Z=0,K=0,Q=0,q=0,H=U5($);for(let W=0;W<H.length;W++){let z=H[W],j=Z,G=K;switch(z.type){case"M":if(Z=z.x,K=z.y,Q=Z,q=K,J.length>0){let F=J[J.length-1],_=Math.atan2(K-G,Z-j);F.tangentOut=_}J.push({x:Z,y:K,tangentIn:0,tangentOut:0,index:J.length});break;case"L":{Z=z.x,K=z.y;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"C":{Z=z.x,K=z.y;let F=z.x1-j,_=z.y1-G,U=F===0&&_===0?Math.atan2(z.y2-G,z.x2-j):Math.atan2(_,F),M=Z-z.x2,V=K-z.y2,Y=M===0&&V===0?Math.atan2(K-z.y1,Z-z.x1):Math.atan2(V,M);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:Y,tangentOut:Y,index:J.length});break}case"Q":{Z=z.x,K=z.y;let F=z.x1-j,_=z.y1-G,U=F===0&&_===0?Math.atan2(K-G,Z-j):Math.atan2(_,F),M=Z-z.x1,V=K-z.y1,Y=M===0&&V===0?Math.atan2(K-G,Z-j):Math.atan2(V,M);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:Y,tangentOut:Y,index:J.length});break}case"A":{Z=z.x,K=z.y;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"Z":{Z=Q,K=q;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;if(J.length>0)J[0].tangentIn=U;break}default:break}}return J}function U5($){if(typeof $!=="string")throw new Error("parsePathCommands: pathData must be a string");let J=[];if($.trim()==="")return J;let Z=$.replace(/([MmLlHhVvCcSsQqTtAaZz])/g," $1 ").trim(),K=/[MmLlHhVvCcSsQqTtAaZz]/,Q=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,q=[],H=0;while(H<Z.length){while(H<Z.length&&/[\s,]/.test(Z[H]))H++;if(H>=Z.length)break;if(K.test(Z[H]))q.push(Z[H]),H++;else{Q.lastIndex=H;let F=Q.exec(Z);if(F&&F.index===H)q.push(F[0]),H=Q.lastIndex;else H++}}let W=0,z=0,j=0,G=(F,_)=>{if(F>=q.length)throw new Error(`parsePathCommands: missing ${_} parameter at token ${F}`);let U=parseFloat(q[F]);if(isNaN(U)||!isFinite(U))throw new Error(`parsePathCommands: invalid ${_} value "${q[F]}" at token ${F}`);return U};while(W<q.length){let F=q[W];switch(F.toUpperCase()){case"M":{let _=G(W+1,"M.x"),U=G(W+2,"M.y");J.push({type:"M",x:F==="M"?_:z+_,y:F==="M"?U:j+U}),z=J[J.length-1].x,j=J[J.length-1].y,W+=3;break}case"L":{let _=G(W+1,"L.x"),U=G(W+2,"L.y");J.push({type:"L",x:F==="L"?_:z+_,y:F==="L"?U:j+U}),z=J[J.length-1].x,j=J[J.length-1].y,W+=3;break}case"H":{let _=G(W+1,"H.x");J.push({type:"L",x:F==="H"?_:z+_,y:j}),z=J[J.length-1].x,W+=2;break}case"V":{let _=G(W+1,"V.y");J.push({type:"L",x:z,y:F==="V"?_:j+_}),j=J[J.length-1].y,W+=2;break}case"C":{let _=G(W+1,"C.x1"),U=G(W+2,"C.y1"),M=G(W+3,"C.x2"),V=G(W+4,"C.y2"),Y=G(W+5,"C.x"),X=G(W+6,"C.y");J.push({type:"C",x1:F==="C"?_:z+_,y1:F==="C"?U:j+U,x2:F==="C"?M:z+M,y2:F==="C"?V:j+V,x:F==="C"?Y:z+Y,y:F==="C"?X:j+X}),z=J[J.length-1].x,j=J[J.length-1].y,W+=7;break}case"Q":{let _=G(W+1,"Q.x1"),U=G(W+2,"Q.y1"),M=G(W+3,"Q.x"),V=G(W+4,"Q.y");J.push({type:"Q",x1:F==="Q"?_:z+_,y1:F==="Q"?U:j+U,x:F==="Q"?M:z+M,y:F==="Q"?V:j+V}),z=J[J.length-1].x,j=J[J.length-1].y,W+=5;break}case"A":{let _=G(W+1,"A.rx"),U=G(W+2,"A.ry"),M=G(W+3,"A.rotation");if(W+4>=q.length||W+5>=q.length)throw new Error("parsePathCommands: missing arc flag parameters");let V=parseInt(q[W+4],10),Y=parseInt(q[W+5],10);if(isNaN(V)||isNaN(Y))throw new Error("parsePathCommands: invalid arc flag values");let X=G(W+6,"A.x"),k=G(W+7,"A.y");J.push({type:"A",rx:_,ry:U,xAxisRotation:M,largeArcFlag:V,sweepFlag:Y,x:F==="A"?X:z+X,y:F==="A"?k:j+k}),z=J[J.length-1].x,j=J[J.length-1].y,W+=8;break}case"Z":J.push({type:"Z"}),W+=1;break;default:W+=1}}return J}function V5($,J){if(!$)throw new Error("resolveMarkers: pathElement is required");if(!J||typeof J!=="object")throw new Error("resolveMarkers: defsMap must be an object");let Z=[],K=$.getAttribute("marker-start"),Q=$.getAttribute("marker-mid"),q=$.getAttribute("marker-end"),H=$.getAttribute("stroke-width")||"1",W=parseFloat(H);if(isNaN(W)||W<=0)throw new Error("resolveMarkers: stroke-width must be a positive number");let z=$.getAttribute("d")||"",j=jH(z);if(j.length===0)return Z;let G=(F)=>{if(!F)return null;let _=F.match(/url\(#([^)]+)\)/);return _?_[1]:null};if(K){let F=G(K),_=F?J[F]:null;if(_&&j.length>0){let U=j[0],M=j.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:v9(_,{x:U.x,y:U.y},M,W,!0),type:"start",vertex:U})}}if(Q&&j.length>2){let F=G(Q),_=F?J[F]:null;if(_)for(let U=1;U<j.length-1;U++){let M=j[U],V=M.tangentIn,X=M.tangentOut-V;while(X>Math.PI)X-=2*Math.PI;while(X<-Math.PI)X+=2*Math.PI;let k=V+X/2;Z.push({markerDef:_,position:{x:M.x,y:M.y},transform:v9(_,{x:M.x,y:M.y},k,W,!1),type:"mid",vertex:M})}}if(q){let F=G(q),_=F?J[F]:null;if(_&&j.length>0){let U=j[j.length-1],M=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:v9(_,{x:U.x,y:U.y},M,W,!1),type:"end",vertex:U})}}return Z}function GH($,J={}){if(!$)throw new Error("markerToPolygons: markerInstance is required");if(!$.markerDef)throw new Error("markerToPolygons: markerInstance.markerDef is required");if(!$.transform)throw new Error("markerToPolygons: markerInstance.transform is required");let{precision:Z=2,curveSegments:K=10}=J;if(typeof Z!=="number"||Z<0)throw new Error("markerToPolygons: precision must be a non-negative number");if(typeof K!=="number"||K<=0)throw new Error("markerToPolygons: curveSegments must be a positive number");let Q=[],{markerDef:q,transform:H}=$;if(!Array.isArray(q.children))throw new Error("markerToPolygons: markerDef.children must be an array");for(let W of q.children){let z=[];switch(W.type){case"path":z=FH(W.d,K);break;case"rect":z=[{x:W.x,y:W.y},{x:W.x+W.width,y:W.y},{x:W.x+W.width,y:W.y+W.height},{x:W.x,y:W.y+W.height}];break;case"circle":z=_H(W.cx,W.cy,W.r,K*4);break;case"ellipse":z=UH(W.cx,W.cy,W.rx,W.ry,K*4);break;case"line":z=[{x:W.x1,y:W.y1},{x:W.x2,y:W.y2}];break;case"polygon":case"polyline":z=VH(W.points);break;default:break}if(z.length>0){let j=z.map((G)=>{let F=c0(H,G.x,G.y);return{x:parseFloat(F[0].toFixed(Z)),y:parseFloat(F[1].toFixed(Z))}});Q.push(j)}}return Q}function FH($,J=10){if(typeof $!=="string")throw new Error("pathToPoints: pathData must be a string");if(typeof J!=="number"||J<=0)throw new Error("pathToPoints: segments must be a positive number");let Z=[],K=U5($),Q=0,q=0;for(let H of K)switch(H.type){case"M":Q=H.x,q=H.y,Z.push({x:Q,y:q});break;case"L":Q=H.x,q=H.y,Z.push({x:Q,y:q});break;case"C":for(let W=1;W<=J;W++){let z=W/J,j=1-z,G=j*j*j*Q+3*j*j*z*H.x1+3*j*z*z*H.x2+z*z*z*H.x,F=j*j*j*q+3*j*j*z*H.y1+3*j*z*z*H.y2+z*z*z*H.y;Z.push({x:G,y:F})}Q=H.x,q=H.y;break;case"Q":for(let W=1;W<=J;W++){let z=W/J,j=1-z,G=j*j*Q+2*j*z*H.x1+z*z*H.x,F=j*j*q+2*j*z*H.y1+z*z*H.y;Z.push({x:G,y:F})}Q=H.x,q=H.y;break;case"A":Q=H.x,q=H.y,Z.push({x:Q,y:q});break;default:break}return Z}function _H($,J,Z,K=32){if(typeof $!=="number"||!isFinite($))throw new Error("circleToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("circleToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("circleToPoints: r must be a non-negative finite number");if(typeof K!=="number"||K<=0)throw new Error("circleToPoints: segments must be a positive number");let Q=[];for(let q=0;q<K;q++){let H=q/K*2*Math.PI;Q.push({x:$+Z*Math.cos(H),y:J+Z*Math.sin(H)})}return Q}function UH($,J,Z,K,Q=32){if(typeof $!=="number"||!isFinite($))throw new Error("ellipseToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("ellipseToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("ellipseToPoints: rx must be a non-negative finite number");if(typeof K!=="number"||!isFinite(K)||K<0)throw new Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof Q!=="number"||Q<=0)throw new Error("ellipseToPoints: segments must be a positive number");let q=[];for(let H=0;H<Q;H++){let W=H/Q*2*Math.PI;q.push({x:$+Z*Math.cos(W),y:J+K*Math.sin(W)})}return q}function VH($){if(typeof $!=="string")throw new Error("parsePoints: pointsStr must be a string");let J=[],Z=$.trim().split(/[\s,]+/).map(Number).filter((K)=>!isNaN(K)&&isFinite(K));if(Z.length%2!==0)throw new Error("parsePoints: pointsStr must contain an even number of valid coordinates");for(let K=0;K<Z.length;K+=2)J.push({x:Z[K],y:Z[K+1]});return J}function O5($,J=2){if(!Array.isArray($))throw new Error("markersToPathData: markerInstances must be an array");if(typeof J!=="number"||J<0)throw new Error("markersToPathData: precision must be a non-negative number");let Z=[];for(let K of $){let Q=GH(K,{precision:J});for(let q of Q){if(q.length===0)continue;let H=q[0];Z.push(`M ${H.x.toFixed(J)} ${H.y.toFixed(J)}`);for(let W=1;W<q.length;W++){let z=q[W];Z.push(`L ${z.x.toFixed(J)} ${z.y.toFixed(J)}`)}Z.push("Z")}}return Z.join(" ")}O.set({precision:80});var k0=($)=>$ instanceof O?$:new O($),t0=new O(0),E$=new O(1);function T$(){let $=O.precision;if($<20)throw new Error(`Decimal precision (${$}) is too low for verification. Minimum required: 20`);let J=Math.max(1,$-10);return new O(10).pow(-J)}function k5($,J,Z){let K=T$();if(!$)return{valid:!1,error:new O(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};if(J==null||Z==null)return{valid:!1,error:new O(1/0),tolerance:K,message:"Coordinates x or y are null or undefined"};let Q=k0(J),q=k0(Z);try{let[H,W]=c0($,Q,q),z=$.inverse();if(!z)return{valid:!1,error:new O(1/0),tolerance:K,message:"Matrix is not invertible (determinant = 0)",details:{determinant:$.determinant()}};let[j,G]=c0(z,H,W),F=Q.minus(j).abs(),_=q.minus(G).abs(),U=O.max(F,_),M=U.lessThan(K);return{valid:M,error:U,tolerance:K,message:M?`Round-trip verified: error ${U.toExponential()} < tolerance ${K.toExponential()}`:`Round-trip FAILED: error ${U.toExponential()} >= tolerance ${K.toExponential()}`,details:{original:{x:Q.toString(),y:q.toString()},transformed:{x:H.toString(),y:W.toString()},recovered:{x:j.toString(),y:G.toString()},errorX:F.toExponential(),errorY:_.toExponential()}}}catch(H){return{valid:!1,error:new O(1/0),tolerance:K,message:`Verification error: ${H.message}`}}}function D9($){let J=T$();if(!$)return{valid:!1,error:new O(1/0),tolerance:J,message:"Matrix parameter is null or undefined"};try{let Z=$.inverse();if(!Z)return{valid:!1,error:new O(1/0),tolerance:J,message:"Matrix is singular (not invertible)",details:{determinant:$.determinant().toString()}};let K=$.mul(Z),Q=$.rows,q=t0,H=[];for(let z=0;z<Q;z++)for(let j=0;j<Q;j++){let G=z===j?E$:t0,F=K.data[z][j],_=F.minus(G).abs();if(_.greaterThan(q))q=_;if(_.greaterThanOrEqualTo(J))H.push({row:z,col:j,expected:G.toString(),actual:F.toString(),error:_.toExponential()})}let W=q.lessThan(J);return{valid:W,error:q,tolerance:J,message:W?`Matrix inversion verified: max error ${q.toExponential()} < tolerance`:`Matrix inversion FAILED: max error ${q.toExponential()} at ${H.length} positions`,details:{matrixSize:`${Q}x${Q}`,maxError:q.toExponential(),failedElements:H.slice(0,5)}}}catch(Z){return{valid:!1,error:new O(1/0),tolerance:J,message:`Verification error: ${Z.message}`}}}function Y5($,J,Z=null){let K=T$(),Q=Z||new O("1e-6");if(!$||!Array.isArray($))return{valid:!1,error:t0,tolerance:K,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:t0,tolerance:K,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:t0,tolerance:K,message:"Polygons must have at least 3 vertices"};try{let q=!0,H=[],W=t0;for(let z=0;z<$.length;z++){let j=$[z];if(!MH(j,J)){let G=YH(j,J);if(G.greaterThan(W))W=G;if(G.greaterThan(Q))q=!1,H.push({index:z,x:j.x.toString(),y:j.y.toString(),distanceOutside:G.toExponential()})}}return{valid:q,error:W,tolerance:Q,message:q?`All inner polygon points are inside or within tolerance (max outside: ${W.toExponential()})`:`${H.length} points exceed tolerance distance outside outer polygon`,details:{innerVertices:$.length,outerVertices:J.length,maxOutsideDistance:W.toExponential(),outsidePoints:H.slice(0,5)}}}catch(q){return{valid:!1,error:new O(1/0),tolerance:K,message:`Verification error: ${q.message}`}}}function YH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=new O(1/0),K=k0($.x),Q=k0($.y);for(let q=0;q<J.length;q++){let H=(q+1)%J.length,W=J[q],z=J[H],j=k0(W.x),G=k0(W.y),F=k0(z.x),_=k0(z.y),U=F.minus(j),M=_.minus(G),V=U.times(U).plus(M.times(M)),Y;if(V.isZero())Y=R5($,W);else{let X=O.max(t0,O.min(E$,K.minus(j).times(U).plus(Q.minus(G).times(M)).div(V))),k=j.plus(X.times(U)),w=G.plus(X.times(M));Y=K.minus(k).pow(2).plus(Q.minus(w).pow(2)).sqrt()}if(Y.lessThan(Z))Z=Y}return Z}function w5($,J,Z){let K=T$();if(!$||!Array.isArray($))return{valid:!1,error:t0,tolerance:K,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:t0,tolerance:K,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:t0,tolerance:K,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:t0,tolerance:K,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:Z.length}};try{let Q=Y5(Z,$),q=Y5(Z,J),H=a$($),W=a$(J),z=a$(Z),j=O.min(H,W),G=z.lessThanOrEqualTo(j.times(E$.plus(K))),F=Q.valid&&q.valid&&G;return{valid:F,error:F?t0:E$,tolerance:K,message:F?"Intersection verified: contained in both polygons, area valid":`Intersection FAILED: ${!Q.valid?"not in poly1, ":""}${!q.valid?"not in poly2, ":""}${!G?"area too large":""}`,details:{containedInPoly1:Q.valid,containedInPoly2:q.valid,area1:H.toString(),area2:W.toString(),intersectionArea:z.toString(),areaValid:G}}}catch(Q){return{valid:!1,error:new O(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function L5($,J,Z){let K=T$();if(!$||typeof $!=="object")return{valid:!1,error:new O(1/0),tolerance:K,message:"Original gradient parameter must be an object"};if(!J||typeof J!=="object")return{valid:!1,error:new O(1/0),tolerance:K,message:"Baked gradient parameter must be an object"};if(!Z)return{valid:!1,error:new O(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};try{let[Q,q]=c0(Z,k0($.x1||0),k0($.y1||0)),[H,W]=c0(Z,k0($.x2||1),k0($.y2||0)),z=k0(J.x1).minus(Q).abs(),j=k0(J.y1).minus(q).abs(),G=k0(J.x2).minus(H).abs(),F=k0(J.y2).minus(W).abs(),_=O.max(z,j,G,F),U=_.lessThan(K);return{valid:U,error:_,tolerance:K,message:U?`Linear gradient transform verified: max error ${_.toExponential()}`:`Linear gradient transform FAILED: max error ${_.toExponential()}`,details:{expected:{x1:Q.toString(),y1:q.toString(),x2:H.toString(),y2:W.toString()},actual:J}}}catch(Q){return{valid:!1,error:new O(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function a$($){if(!$||!Array.isArray($))throw new Error("Invalid polygon parameter: must be an array");if($.length<3)return t0;let J=t0,Z=$.length;for(let K=0;K<Z;K++){let Q=(K+1)%Z,q=k0($[K].x),H=k0($[K].y),W=k0($[Q].x),z=k0($[Q].y);J=J.plus(q.times(z).minus(W.times(H)))}return J.abs().div(2)}function MH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=k0($.x),K=k0($.y),Q=J.length,q=!1;for(let H=0,W=Q-1;H<Q;W=H++){let z=k0(J[H].x),j=k0(J[H].y),G=k0(J[W].x),F=k0(J[W].y);if(XH($,J[H],J[W]))return!0;if(j.greaterThan(K)!==F.greaterThan(K)&&Z.lessThan(G.minus(z).times(K.minus(j)).div(F.minus(j)).plus(z)))q=!q}return q}function XH($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid segStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid segEnd parameter: must have x and y properties");let K=T$(),Q=k0($.x),q=k0($.y),H=k0(J.x),W=k0(J.y),z=k0(Z.x),j=k0(Z.y),G=O.min(H,z).minus(K),F=O.max(H,z).plus(K),_=O.min(W,j).minus(K),U=O.max(W,j).plus(K);if(Q.lessThan(G)||Q.greaterThan(F)||q.lessThan(_)||q.greaterThan(U))return!1;let M=z.minus(H).times(q.minus(W)).minus(j.minus(W).times(Q.minus(H))).abs(),V=R5(J,Z);return M.div(V.plus(K)).lessThan(K)}function R5($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");let Z=k0(J.x).minus(k0($.x)),K=k0(J.y).minus(k0($.y));return Z.times(Z).plus(K.times(K)).sqrt()}function B5($,J){if(!$||$.length<3||!J||J.length<3)return[];let Z=[];for(let K=0;K<J.length;K++){let Q=J[K],q=J[(K+1)%J.length],H=[];for(let W=0;W<$.length;W++){let z=$[W],j=$[(W+1)%$.length],G=!M5(z,Q,q),F=!M5(j,Q,q);if(G){if(H.push(z),!F)H.push(X5(z,j,Q,q))}else if(F)H.push(X5(z,j,Q,q))}if(H.length>=3)Z.push(H)}return Z}function N5($,J,Z=[],K="1e-10"){let Q=K instanceof O?K:new O(K),q=Z||[];if(!$||!Array.isArray($))return{valid:!1,error:new O(1/0),tolerance:Q,message:"Original polygon parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:new O(1/0),tolerance:Q,message:"Clipped polygon parameter must be an array"};try{let H=a$($),W=J.length>=3?a$(J):t0,z=H.minus(W),j=W.lessThanOrEqualTo(H.times(E$.plus(Q))),G=z.greaterThanOrEqualTo(t0.minus(Q.times(H))),F=H.isZero()?E$:W.div(H),_=t0,U=j&&G;return{valid:U,error:_,tolerance:Q,message:U?`ClipPath E2E verified: area conserved (clipped ${F.times(100).toFixed(2)}% of original)`:"ClipPath E2E FAILED: invalid intersection (clipped > original or negative outside)",details:{originalArea:H.toString(),clippedArea:W.toString(),outsideArea:z.toString(),areaRatio:F.toFixed(6),fragmentCount:q.length,clippedValid:j,outsideValid:G}}}catch(H){return{valid:!1,error:new O(1/0),tolerance:Q,message:`E2E verification error: ${H.message}`}}}function M5($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid edgeStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid edgeEnd parameter: must have x and y properties");let K=k0($.x).toNumber(),Q=k0($.y).toNumber(),q=k0(J.x).toNumber(),H=k0(J.y).toNumber(),W=k0(Z.x).toNumber(),z=k0(Z.y).toNumber();return(W-q)*(Q-H)-(z-H)*(K-q)>=0}function X5($,J,Z,K){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid p3 parameter: must have x and y properties");if(!K||K.x==null||K.y==null)throw new Error("Invalid p4 parameter: must have x and y properties");let Q=k0($.x).toNumber(),q=k0($.y).toNumber(),H=k0(J.x).toNumber(),W=k0(J.y).toNumber(),z=k0(Z.x).toNumber(),j=k0(Z.y).toNumber(),G=k0(K.x).toNumber(),F=k0(K.y).toNumber(),_=(Q-H)*(j-F)-(q-W)*(z-G);if(Math.abs(_)<0.0000000001)return{x:k0((Q+H)/2),y:k0((q+W)/2)};let U=((Q-z)*(j-F)-(q-j)*(z-G))/_;return{x:k0(Q+U*(H-Q)),y:k0(q+U*(W-q))}}var A5=["animate","animateTransform","animateMotion","animateColor","set"],I5=["href","xlink:href"],C5=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],wH=["begin","end"],LH=["values","from","to","by"];function h9($){if(!$||typeof $!=="string")return null;let J=$.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return J&&J[1]?J[1]:null}function P5($){if(!$||typeof $!=="string")return null;if($.startsWith("#")){let J=$.substring(1);return J&&!J.startsWith("#")?J:null}return null}function E5($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let Q=K.trim();if(Q.startsWith("#")){let H=Q.substring(1);if(H)J.push(H)}let q=h9(Q);if(q)J.push(q)}return J}function T5($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let q=K.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\.(begin|end|click|mousedown|mouseup|mouseover|mouseout|mousemove|mouseenter|mouseleave|focusin|focusout|activate|repeat)(?:[+-]\d+(?:\.\d+)?[a-z]*)?/);if(q)J.push(q[1])}return J}function t$($){if(!$||typeof $!=="string")return[];let J=[],Z=/url\(\s*["']?#([^"')]+)["']?\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);return J}function b5($){if(!$||typeof $!=="string")return[];let J=[],Z=/getElementById\(\s*["']([^"']+)["']\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);let Q=/querySelector(?:All)?\(\s*["']#([^"'#\s]+)["']\s*\)/g;while((K=Q.exec($))!==null)if(K[1])J.push(K[1]);return J}function RH($){if(!$||typeof $!=="object"||!($ instanceof w0))throw new TypeError("collectElementReferences: el must be a valid SVGElement");if(typeof $.getAttributeNames!=="function")throw new TypeError("collectElementReferences: el must have getAttributeNames method");let J={static:new Set,animation:new Set,css:new Set,js:new Set},Z=$.tagName?.toLowerCase()||"",K=A5.includes(Z),Q=$.getAttributeNames();if(!Array.isArray(Q))throw new TypeError("collectElementReferences: getAttributeNames must return an array");for(let q of Q){let H=$.getAttribute(q);if(!H)continue;if(I5.includes(q)){let W=P5(H);if(W)if(K)J.animation.add(W);else J.static.add(W)}if(C5.includes(q)||q==="style"){let W=h9(H);if(W)J.static.add(W);if(q==="style")t$(H).forEach((z)=>J.css.add(z))}if(wH.includes(q))T5(H).forEach((W)=>J.animation.add(W));if(LH.includes(q))E5(H).forEach((W)=>J.animation.add(W));if(!C5.includes(q)&&H.includes("url(")){let W=h9(H);if(W)J.static.add(W)}}if(Z==="animatemotion"){if(typeof $.getElementsByTagName!=="function")throw new TypeError("collectElementReferences: el must have getElementsByTagName method");let q=$.getElementsByTagName("mpath");if(!q||typeof q[Symbol.iterator]!=="function")throw new TypeError("collectElementReferences: getElementsByTagName must return an iterable");for(let H of q){if(!H||typeof H.getAttribute!=="function")continue;for(let W of I5){let z=H.getAttribute(W),j=P5(z);if(j)J.animation.add(j)}}}return J}function f5($){if(!$||typeof $!=="object"||!($ instanceof w0))throw new TypeError("collectAllReferences: root must be a valid SVGElement");let J={all:new Set,static:new Set,animation:new Set,css:new Set,js:new Set,details:new Map},Z={animation:4,js:3,css:2,static:1},K=(q,H,W)=>{if(J.all.add(q),J[H].add(q),!J.details.has(q))J.details.set(q,{sources:[],type:H});else{let z=J.details.get(q);if(Z[H]>Z[z.type])z.type=H}J.details.get(q).sources.push(W)},Q=(q,H="")=>{let W=q.tagName?.toLowerCase()||"",z=H?`${H}>${W}`:W,j=q.getAttribute("id"),G=j?`${W}#${j}`:z,F=RH(q);if(F.static.forEach((_)=>K(_,"static",G)),F.animation.forEach((_)=>K(_,"animation",G)),F.css.forEach((_)=>K(_,"css",G)),F.js.forEach((_)=>K(_,"js",G)),W==="style"){let _=q.textContent||"";t$(_).forEach((U)=>K(U,"css","<style>"))}if(W==="script"){let _=q.textContent||"";b5(_).forEach((U)=>K(U,"js","<script>"))}if(q.children&&typeof q.children[Symbol.iterator]==="function"){for(let _ of q.children)if(_ instanceof w0)Q(_,z)}};return Q($),J}O.set({precision:80});var N7=($)=>$ instanceof O?$:new O($),BH={precision:6,curveSegments:20,clipSegments:64,bezierArcs:8,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,preserveIds:!1,svg2Polyfills:!1,e2eTolerance:"1e-10"};function f$($,J={}){if($===null||$===void 0)throw new Error("flattenSVG: svgString parameter is required");if(typeof $!=="string")throw new Error(`flattenSVG: svgString must be a string, got ${typeof $}`);if($.trim().length===0)throw new Error("flattenSVG: svgString cannot be empty");let Z={...BH,...J},K={useResolved:0,markersResolved:0,patternsResolved:0,masksResolved:0,clipPathsApplied:0,transformsFlattened:0,gradientsProcessed:0,defsRemoved:0,errors:[],verifications:{transforms:[],matrices:[],polygons:[],gradients:[],e2e:[],passed:0,failed:0,allPassed:!0},clipOutsideFragments:[]};try{let Q=u0($);if(Q.tagName.toLowerCase()!=="svg")throw new Error("Root element must be <svg>");let q=h7(Q),H=Z.removeUnusedDefs?fH(Q):null;if(Z.resolveUse){let z=NH(Q,q,Z);K.useResolved=z.count,K.errors.push(...z.errors),q=h7(Q)}if(Z.resolveMarkers){let z=IH(Q,q,Z);K.markersResolved=z.count,K.errors.push(...z.errors)}if(Z.resolvePatterns){let z=CH(Q,q,Z);K.patternsResolved=z.count,K.errors.push(...z.errors)}if(Z.resolveMasks){let z=PH(Q,q,Z);K.masksResolved=z.count,K.errors.push(...z.errors)}if(Z.resolveClipPaths){let z=AH(Q,q,Z,K);K.clipPathsApplied=z.count,K.errors.push(...z.errors)}if(Z.flattenTransforms){let z=EH(Q,Z,K);K.transformsFlattened=z.count,K.errors.push(...z.errors)}if(Z.bakeGradients){let z=bH(Q,Z,K);K.gradientsProcessed=z.count,K.errors.push(...z.errors)}if(Z.removeUnusedDefs&&H){let z=SH(Q,H);K.defsRemoved=z.count}return{svg:K7(Q),stats:K}}catch(Q){return K.errors.push(`Pipeline error: ${Q.message}`),{svg:$,stats:K}}}var h5=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),y5=new Set(["foreignobject","audio","video","iframe","script","style",...h5]);function y9($){if(!$)return!1;let J=$.tagName?.toLowerCase();if(y5.has(J))return!0;for(let Z of $.children||[])if(Z&&Z.tagName&&y9(Z))return!0;return!1}function NH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllUseElements: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllUseElements: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllUseElements: opts must be an object");let K=[],Q=0,q=$.getElementsByTagName("use"),H={};for(let[W,z]of J.entries())if(z.tagName.toLowerCase()==="symbol")H[W]=W5(z),H[W].type="symbol";else H[W]=m6(z);for(let W of[...q])try{let z=W.getAttribute("href")||W.getAttribute("xlink:href");if(!z)continue;let j=z.replace(/^#/,""),G=J.get(j);if(!G){K.push(`use: referenced element #${j} not found`);continue}let F=y9(G),_=y9(W);if(F||_){let Y=G.cloneNode(!0),X=parseFloat(W.getAttribute("x")||"0"),k=parseFloat(W.getAttribute("y")||"0");if(isNaN(X)||isNaN(k)){K.push(`use: invalid x/y coordinates for element #${j}`);continue}let w=W.getAttribute("transform")||"",R="";if(w)R=w;if(X!==0||k!==0){let g=`translate(${X}, ${k})`;R=R?`${R} ${g}`:g}let I=new w0("g",{});if(R)I.setAttribute("transform",R);let P=e$(W);for(let[g,b]of Object.entries(P))if(b&&!I.hasAttribute(g))I.setAttribute(g,b);if(G.tagName.toLowerCase()==="symbol"){for(let g of Y.children||[])if(g&&g.tagName)I.appendChild(g.cloneNode(!0))}else Y.removeAttribute("id"),I.appendChild(Y);for(let g of W.children||[])if(g&&g.tagName){let b=g.tagName.toLowerCase();if(h5.has(b))I.appendChild(g.cloneNode(!0))}if(W.parentNode)W.parentNode.replaceChild(I,W),Q++;continue}let U=H5(W),M=S9(U,H,{samples:Z.curveSegments});if(!M){K.push(`use: failed to resolve #${j}`);continue}let V=G5(M,Z.curveSegments);if(V){let Y=new w0("path",{d:V,...e$(W)});if(M.style){for(let[X,k]of Object.entries(M.style))if(k&&!Y.hasAttribute(X))Y.setAttribute(X,k)}if(W.parentNode)W.parentNode.replaceChild(Y,W),Q++}}catch(z){K.push(`use: ${z.message}`)}return{count:Q,errors:K}}function IH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMarkers: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMarkers: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMarkers: opts must be an object");let K=[],Q=0,q=["marker-start","marker-mid","marker-end","marker"];for(let H of q){let W=E7($,H);for(let z of W){if(z.tagName!=="path"&&z.tagName!=="line"&&z.tagName!=="polyline"&&z.tagName!=="polygon")continue;try{let j=V5(z,Object.fromEntries(J));if(!j||j.length===0)continue;let G=O5(j,Z.precision);if(G){let F=new w0("path",{d:G,fill:z.getAttribute("stroke")||"currentColor"});if(z.parentNode){let _=z.nextSibling;if(_)z.parentNode.insertBefore(F,_);else z.parentNode.appendChild(F);Q++}}for(let F of q)z.removeAttribute(F)}catch(j){K.push(`marker: ${j.message}`)}}}return{count:Q,errors:K}}function CH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllPatterns: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllPatterns: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllPatterns: opts must be an object");let K=[],Q=0,q=E7($,"fill");for(let H of q){let W=H.getAttribute("fill");if(!W||!W.includes("url("))continue;let z=y7(W);if(!z)continue;let j=J.get(z);if(!j||j.tagName.toLowerCase()!=="pattern")continue;try{let G=j.getAttribute("patternUnits")||"objectBoundingBox",F=j.getAttribute("patternContentUnits")||"userSpaceOnUse",_=j.getAttribute("patternTransform");if(G!=="objectBoundingBox")K.push(`pattern ${z}: non-default patternUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`pattern ${z}: non-default patternContentUnits="${F}" may cause rendering issues`);if(_)K.push(`pattern ${z}: patternTransform present - complex transformation may cause rendering issues`);let U=u5(H);if(!U)continue;let M=F5(j),V=_5(M,U,{samples:Z.curveSegments});if(V){let Y=new w0("g",{}),X=new w0("path",{d:V,fill:"#000"});if(Y.appendChild(X),H.setAttribute("fill","none"),H.setAttribute("stroke",H.getAttribute("stroke")||"none"),H.parentNode)H.parentNode.insertBefore(Y,H),Q++}}catch(G){K.push(`pattern: ${G.message}`)}}return{count:Q,errors:K}}function PH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMasks: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMasks: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMasks: opts must be an object");let K=[],Q=0,q=E7($,"mask");for(let H of q){let W=H.getAttribute("mask");if(!W||!W.includes("url("))continue;let z=y7(W);if(!z)continue;let j=J.get(z);if(!j||j.tagName.toLowerCase()!=="mask")continue;try{let G=j.getAttribute("maskUnits")||"objectBoundingBox",F=j.getAttribute("maskContentUnits")||"userSpaceOnUse";if(G!=="objectBoundingBox")K.push(`mask ${z}: non-default maskUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`mask ${z}: non-default maskContentUnits="${F}" may cause rendering issues`);let _=u5(H);if(!_)continue;let U=Q5(j),M=q5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(M){let V=b$(H,Z.precision);if(V){let Y=Q$(V,Z.curveSegments),X=Q$(M,Z.curveSegments),k=g5(Y,X);if(k&&k.length>2){let w=b9(k,Z.precision);H.setAttribute("d",w),H.removeAttribute("mask"),Q++}}}}catch(G){K.push(`mask: ${G.message}`)}}return{count:Q,errors:K}}function AH($,J,Z,K){if(!$||!$.getElementsByTagName)throw new Error("applyAllClipPaths: invalid root element");if(!J||!(J instanceof Map))throw new Error("applyAllClipPaths: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("applyAllClipPaths: opts must be an object");if(!K||typeof K!=="object")throw new Error("applyAllClipPaths: stats must be an object");let Q=[],q=0;if(!K.verifications.e2e)K.verifications.e2e=[];if(!K.clipOutsideFragments)K.clipOutsideFragments=[];let H=E7($,"clip-path");for(let W of H){let z=W.getAttribute("clip-path");if(!z||!z.includes("url("))continue;let j=y7(z);if(!j)continue;let G=J.get(j),F=G?G.tagName.toLowerCase():"";if(!G||F!=="clippath")continue;try{if((G.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")Q.push(`clipPath ${j}: objectBoundingBox units require bbox-relative coordinate transformation`);let U=b$(W,Z.precision);if(!U)continue;let M="";if(G.children&&G.children.length>0){for(let I of G.children)if(I&&I.tagName){let P=b$(I,Z.precision);if(P)M+=(M?" ":"")+P}}if(!M)continue;let V=Z.clipSegments||64,Y=Q$(U,V),X=Q$(M,V),k=g5(Y,X),w=Y.map((I)=>({x:I.x instanceof O?I.x:N7(I.x),y:I.y instanceof O?I.y:N7(I.y)})),R=X.map((I)=>({x:I.x instanceof O?I.x:N7(I.x),y:I.y instanceof O?I.y:N7(I.y)}));if(k&&k.length>2){let I=k.map((h)=>({x:h.x instanceof O?h.x:N7(h.x),y:h.y instanceof O?h.y:N7(h.y)})),P=w5(w,R,I);if(K.verifications.polygons.push({element:W.tagName,clipPathId:j,...P}),P.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let u=B5(w,R);K.clipOutsideFragments.push({elementId:W.getAttribute("id")||`clip-${q}`,clipPathId:j,fragments:u,visible:!1});let g=Z.e2eTolerance||"1e-10",b=N5(w,I,u,g);if(K.verifications.e2e.push({element:W.tagName,clipPathId:j,type:"clip-area-conservation",...b}),b.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1}if(k&&k.length>2){let I=b9(k,Z.precision),P=W;if(W.tagName==="path")W.setAttribute("d",I);else{let u=new w0("path",{d:I,...e$(W)});if(W.parentNode)W.parentNode.replaceChild(u,W),P=u}P.removeAttribute("clip-path"),q++}}catch(_){Q.push(`clipPath: ${_.message}`)}}return{count:q,errors:Q}}function EH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("flattenAllTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("flattenAllTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("flattenAllTransforms: stats must be an object");let K=[],Q=0,q=E7($,"transform");for(let H of q){let W=H.getAttribute("transform");if(!W)continue;try{let z=V7(W),j=D9(z);if(Z.verifications.matrices.push({element:H.tagName,transform:W,...j}),j.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;let G=b$(H,J.precision);if(!G){if(H.tagName==="g")TH(H,z,J,Z),H.removeAttribute("transform"),Q++;continue}let F=[],_=Q$(G,4);if(_&&_.length>0)F=_.slice(0,4).map((V)=>({x:V.x instanceof O?V.x:N7(V.x),y:V.y instanceof O?V.y:N7(V.y)}));let U=C$(G,z,{precision:J.precision});for(let V=0;V<F.length;V++){let Y=F[V],X=k5(z,Y.x,Y.y);if(Z.verifications.transforms.push({element:H.tagName,pointIndex:V,...X}),X.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1}let M=H;if(H.tagName==="path")H.setAttribute("d",U);else{let V=new w0("path",{d:U,...e$(H)});for(let Y of vH(H.tagName))V.removeAttribute(Y);if(H.parentNode)H.parentNode.replaceChild(V,H),M=V}M.removeAttribute("transform"),Q++}catch(z){K.push(`transform: ${z.message}`)}}return{count:Q,errors:K}}function TH($,J,Z,K){if(!$||!$.children)throw new Error("propagateTransformToChildren: invalid group element");if(!J||!J.data)throw new Error("propagateTransformToChildren: invalid matrix");if(!Z||typeof Z!=="object")throw new Error("propagateTransformToChildren: opts must be an object");if(!K||typeof K!=="object")throw new Error("propagateTransformToChildren: stats must be an object");for(let Q of[...$.children]){if(!(Q&&Q.tagName))continue;if(Q.tagName==="g"){let q=Q.getAttribute("transform");if(q){let H=V7(q),W=J.mul(H);Q.setAttribute("transform",S5(W))}else Q.setAttribute("transform",S5(J))}else{let q=b$(Q,Z.precision);if(q){let H=Q.getAttribute("transform"),W=J;if(H){let F=V7(H);W=J.mul(F)}let z=D9(W);if(K.verifications.matrices.push({element:Q.tagName,context:"group-propagation",...z}),z.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let j=C$(q,W,{precision:Z.precision}),G=Q;if(Q.tagName==="path")Q.setAttribute("d",j);else{let F=new w0("path",{d:j,...e$(Q)});$.replaceChild(F,Q),G=F}G.removeAttribute("transform")}}}}function bH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("bakeAllGradientTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("bakeAllGradientTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("bakeAllGradientTransforms: stats must be an object");let K=[],Q=0,q=$.getElementsByTagName("linearGradient");for(let W of q){let z=W.getAttribute("gradientTransform");if(!z)continue;try{let j=V7(z),G=parseFloat(W.getAttribute("x1")||"0"),F=parseFloat(W.getAttribute("y1")||"0"),_=parseFloat(W.getAttribute("x2")||"1"),U=parseFloat(W.getAttribute("y2")||"0");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)){K.push(`linearGradient: invalid coordinate values for gradient ${W.getAttribute("id")||"unknown"}`);continue}let[M,V]=c0(j,G,F),[Y,X]=c0(j,_,U),k=L5({x1:G,y1:F,x2:_,y2:U},{x1:M.toNumber(),y1:V.toNumber(),x2:Y.toNumber(),y2:X.toNumber()},j);if(Z.verifications.gradients.push({gradientId:W.getAttribute("id")||"unknown",type:"linear",...k}),k.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;W.setAttribute("x1",M.toFixed(J.precision)),W.setAttribute("y1",V.toFixed(J.precision)),W.setAttribute("x2",Y.toFixed(J.precision)),W.setAttribute("y2",X.toFixed(J.precision)),W.removeAttribute("gradientTransform"),Q++}catch(j){K.push(`linearGradient: ${j.message}`)}}let H=$.getElementsByTagName("radialGradient");for(let W of H){let z=W.getAttribute("gradientTransform");if(!z)continue;try{let j=V7(z),G=parseFloat(W.getAttribute("cx")||"0.5"),F=parseFloat(W.getAttribute("cy")||"0.5"),_=parseFloat(W.getAttribute("fx")||G.toString()),U=parseFloat(W.getAttribute("fy")||F.toString()),M=parseFloat(W.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(M)){K.push(`radialGradient: invalid coordinate/radius values for gradient ${W.getAttribute("id")||"unknown"}`);continue}if(M<=0){K.push(`radialGradient: radius must be positive for gradient ${W.getAttribute("id")||"unknown"}`);continue}let[V,Y]=c0(j,G,F),[X,k]=c0(j,_,U),w=j.data[0][0].toNumber()*j.data[1][1].toNumber();if(Math.abs(w)<0.0000000001){K.push("radialGradient: matrix determinant too close to zero (degenerate transform)");continue}let R=Math.sqrt(Math.abs(w)),I=M*R;W.setAttribute("cx",V.toFixed(J.precision)),W.setAttribute("cy",Y.toFixed(J.precision)),W.setAttribute("fx",X.toFixed(J.precision)),W.setAttribute("fy",k.toFixed(J.precision)),W.setAttribute("r",I.toFixed(J.precision)),W.removeAttribute("gradientTransform"),Q++}catch(j){K.push(`radialGradient: ${j.message}`)}}return{count:Q,errors:K}}function fH($){if(!$||!$.getElementsByTagName)throw new Error("collectAllReferences: invalid root element");let J=new Set,Z=(K)=>{if(!K||!K.getAttributeNames)return;if(K.tagName&&K.tagName.toLowerCase()==="style"){let Q=K.textContent||"";if(Q)t$(Q).forEach((H)=>J.add(H))}for(let Q of K.getAttributeNames()){let q=K.getAttribute(Q);if(!q)continue;if(q.includes("url(")){let H=y7(q);if(H)J.add(H)}if(Q==="href"||Q==="xlink:href"){let H=q.replace(/^#/,"");if(H&&H!==q)J.add(H)}}for(let Q of K.children)if(Q&&Q.tagName)Z(Q)};return Z($),J}function SH($,J){if(!$||!$.getElementsByTagName)throw new Error("removeUnusedDefinitions: invalid root element");if(!J||!(J instanceof Set))throw new Error("removeUnusedDefinitions: referencedIds must be a Set");let Z=0;function K(q){if(!q||!q.getAttribute)return!1;let H=q.getAttribute("id");if(H&&J.has(H))return!0;for(let W of q.children||[])if(W&&W.tagName&&K(W))return!0;return!1}let Q=$.getElementsByTagName("defs");for(let q of Q)for(let H of[...q.children])if(H&&H.tagName){let W=H.tagName.toLowerCase();if(y5.has(W))continue;if(!K(H))q.removeChild(H),Z++}return{count:Z}}function b$($,J){if(!$||!$.tagName)return null;if(typeof J!=="number"||isNaN(J)||J<0)throw new Error(`getElementPathData: precision must be a non-negative number, got ${J}`);let Z=$.tagName.toLowerCase();if(Z==="path")return $.getAttribute("d");let K=(Q,q=0)=>{let H=$.getAttribute(Q);if(H===null)return q;let W=parseFloat(H);if(isNaN(W))throw new Error(`getElementPathData: invalid numeric value "${H}" for attribute "${Q}"`);return W};switch(Z){case"rect":{let q=$.getAttribute("ry")!==null?K("ry"):null;return E6(K("x"),K("y"),K("width"),K("height"),K("rx"),q,!1,J)}case"circle":return P6(K("cx"),K("cy"),K("r"),J);case"ellipse":return A6(K("cx"),K("cy"),K("rx"),K("ry"),J);case"line":return T6(K("x1"),K("y1"),K("x2"),K("y2"),J);case"polyline":return p$($.getAttribute("points")||"",J);case"polygon":return b6($.getAttribute("points")||"",J);default:return null}}function u5($){if(!$||!$.tagName)return null;let J=b$($,6);if(!J)return null;try{let Z=Q$(J,10);if(!Z||Z.length===0)return null;let K=1/0,Q=1/0,q=-1/0,H=-1/0;for(let W of Z){if(!W||W.x===void 0&&W.y===void 0)continue;let z=W.x instanceof O?W.x.toNumber():typeof W.x==="number"?W.x:0,j=W.y instanceof O?W.y.toNumber():typeof W.y==="number"?W.y:0;if(isNaN(z)||isNaN(j))continue;if(z<K)K=z;if(j<Q)Q=j;if(z>q)q=z;if(j>H)H=j}if(K===1/0||q===-1/0||Q===1/0||H===-1/0)return null;return{x:K,y:Q,width:q-K,height:H-Q}}catch{return null}}function e$($){if(!$||!$.getAttribute)return{};let J=["stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","vector-effect","fill","fill-opacity","fill-rule","clip-path","mask","filter","opacity","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display","color","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","letter-spacing","word-spacing","text-decoration","shape-rendering","text-rendering","image-rendering","color-rendering","paint-order","pointer-events","cursor","class","style","id"],Z={};for(let K of J){let Q=$.getAttribute(K);if(Q!==null)Z[K]=Q}return Z}function vH($){if(!$||typeof $!=="string")return[];return{rect:["x","y","width","height","rx","ry"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],polyline:["points"],polygon:["points"],image:["x","y","width","height","href","xlink:href","preserveAspectRatio"]}[$.toLowerCase()]||[]}function S5($){if(!$||!$.data||!Array.isArray($.data))throw new Error("matrixToTransform: invalid matrix");if(!$.data[0]||!$.data[1]||!$.data[0][0]||!$.data[0][1]||!$.data[0][2]||!$.data[1][0]||!$.data[1][1]||!$.data[1][2])throw new Error("matrixToTransform: matrix is missing required elements");let J=$.data[0][0].toNumber(),Z=$.data[1][0].toNumber(),K=$.data[0][1].toNumber(),Q=$.data[1][1].toNumber(),q=$.data[0][2].toNumber(),H=$.data[1][2].toNumber();if(!isFinite(J)||!isFinite(Z)||!isFinite(K)||!isFinite(Q)||!isFinite(q)||!isFinite(H))throw new Error("matrixToTransform: matrix contains non-finite values");return`matrix(${J} ${Z} ${K} ${Q} ${q} ${H})`}function g5($,J){if(!$||$.length<3||!J||J.length<3)return $;if(A7&&v7)try{return v7($,J)}catch(K){}let Z=[...$];for(let K=0;K<J.length;K++){if(Z.length===0)break;let Q=Z;Z=[];let q=J[K],H=J[(K+1)%J.length];for(let W=0;W<Q.length;W++){let z=Q[W],j=Q[(W+1)%Q.length],G=v5(z,q,H),F=v5(j,q,H);if(G){if(Z.push(z),!F)Z.push(D5(z,j,q,H))}else if(F)Z.push(D5(z,j,q,H))}}return Z}function v5($,J,Z){if(!$||$.x===void 0&&$.y===void 0)throw new Error("isInsideEdge: invalid point");if(!J||J.x===void 0&&J.y===void 0)throw new Error("isInsideEdge: invalid edgeStart");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("isInsideEdge: invalid edgeEnd");let K=$.x instanceof O?$.x.toNumber():$.x||0,Q=$.y instanceof O?$.y.toNumber():$.y||0,q=J.x instanceof O?J.x.toNumber():J.x||0,H=J.y instanceof O?J.y.toNumber():J.y||0,W=Z.x instanceof O?Z.x.toNumber():Z.x||0,z=Z.y instanceof O?Z.y.toNumber():Z.y||0;return(W-q)*(Q-H)-(z-H)*(K-q)>=0}function D5($,J,Z,K){if(!$||$.x===void 0&&$.y===void 0)throw new Error("lineIntersect: invalid p1");if(!J||J.x===void 0&&J.y===void 0)throw new Error("lineIntersect: invalid p2");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("lineIntersect: invalid p3");if(!K||K.x===void 0&&K.y===void 0)throw new Error("lineIntersect: invalid p4");let Q=$.x instanceof O?$.x.toNumber():$.x||0,q=$.y instanceof O?$.y.toNumber():$.y||0,H=J.x instanceof O?J.x.toNumber():J.x||0,W=J.y instanceof O?J.y.toNumber():J.y||0,z=Z.x instanceof O?Z.x.toNumber():Z.x||0,j=Z.y instanceof O?Z.y.toNumber():Z.y||0,G=K.x instanceof O?K.x.toNumber():K.x||0,F=K.y instanceof O?K.y.toNumber():K.y||0,_=(Q-H)*(j-F)-(q-W)*(z-G);if(Math.abs(_)<0.0000000001)return{x:N7((Q+H)/2),y:N7((q+W)/2)};let U=((Q-z)*(j-F)-(q-j)*(z-G))/_;return{x:N7(Q+U*(H-Q)),y:N7(q+U*(W-q))}}var U$=new Set(["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","dominant-baseline","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","marker","marker-end","marker-mid","marker-start","paint-order","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","visibility","word-spacing","writing-mode"]);var $6={animation:new Set(["animate","animateColor","animatecolor","animateMotion","animatemotion","animateTransform","animatetransform","set"]),descriptive:new Set(["desc","metadata","title"]),shape:new Set(["circle","ellipse","line","path","polygon","polyline","rect"]),structural:new Set(["defs","g","svg","symbol","use"]),paintServer:new Set(["hatch","linearGradient","lineargradient","meshGradient","meshgradient","pattern","radialGradient","radialgradient","solidColor","solidcolor"]),nonRendering:new Set(["clipPath","clippath","filter","linearGradient","lineargradient","marker","mask","pattern","radialGradient","radialgradient","solidColor","solidcolor","symbol"]),container:new Set(["a","defs","g","marker","mask","pattern","svg","switch","symbol"]),textContent:new Set(["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","text","textPath","tref","tspan"]),filterPrimitive:new Set(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),lightSource:new Set(["feDistantLight","fePointLight","feSpotLight"])};var J6={svg:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),g:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),defs:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view","meshgradient","meshGradient","hatch","solidcolor","solidColor"]),symbol:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),marker:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),clipPath:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","text","title","use"]),mask:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),pattern:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),a:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),switch:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","cursor","desc","ellipse","foreignObject","g","image","line","metadata","path","polygon","polyline","rect","set","svg","switch","text","title","use","view"]),text:new Set(["a","altGlyph","animate","animateColor","animateMotion","animateTransform","desc","metadata","set","textPath","title","tref","tspan"]),textPath:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),tspan:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),linearGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),radialGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),meshgradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshGradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshrow:new Set(["meshpatch"]),meshpatch:new Set(["stop"]),hatch:new Set(["animate","animateTransform","desc","hatchpath","hatchPath","metadata","script","set","style","title"]),hatchpath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),hatchPath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),filter:new Set(["animate","animateTransform","desc","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","metadata","set","title"]),feBlend:new Set(["animate","set"]),feColorMatrix:new Set(["animate","set"]),feComponentTransfer:new Set(["feFuncA","feFuncB","feFuncG","feFuncR"]),feComposite:new Set(["animate","set"]),feConvolveMatrix:new Set(["animate","set"]),feDiffuseLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feDisplacementMap:new Set(["animate","set"]),feDropShadow:new Set(["animate","set"]),feFlood:new Set(["animate","set"]),feFuncA:new Set(["animate","set"]),feFuncB:new Set(["animate","set"]),feFuncG:new Set(["animate","set"]),feFuncR:new Set(["animate","set"]),feGaussianBlur:new Set(["animate","set"]),feImage:new Set(["animate","set"]),feMerge:new Set(["feMergeNode"]),feMergeNode:new Set(["animate","set"]),feMorphology:new Set(["animate","set"]),feOffset:new Set(["animate","set"]),feSpecularLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feTile:new Set(["animate","set"]),feTurbulence:new Set(["animate","set"]),animate:new Set(["desc","metadata","title"]),animateColor:new Set(["desc","metadata","title"]),animateMotion:new Set(["desc","metadata","mpath","title"]),animateTransform:new Set(["desc","metadata","title"]),set:new Set(["desc","metadata","title"]),circle:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),ellipse:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),line:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),path:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polygon:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polyline:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),rect:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),image:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),use:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),title:new Set([]),desc:new Set([]),metadata:new Set([]),feDistantLight:new Set(["animate","set"]),fePointLight:new Set(["animate","set"]),feSpotLight:new Set(["animate","set"]),stop:new Set(["animate","set"]),solidColor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),solidcolor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),tref:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyph:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyphDef:new Set(["altGlyphItem"]),altGlyphItem:new Set(["glyphRef","altGlyphItem"]),glyph:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","title","use"]),glyphRef:new Set([]),foreignObject:new Set([]),style:new Set([]),script:new Set([]),view:new Set(["desc","metadata","title"]),mpath:new Set(["desc","metadata","title"])},x5={userAction:new Set([":hover",":active",":focus",":focus-within",":focus-visible"]),treeStructural:new Set([":root",":empty",":first-child",":last-child",":only-child",":first-of-type",":last-of-type",":only-of-type",":nth-child",":nth-last-child",":nth-of-type",":nth-last-of-type"]),link:new Set([":link",":visited",":any-link",":local-link",":target"]),input:new Set([":enabled",":disabled",":read-only",":read-write",":placeholder-shown",":default",":checked",":indeterminate",":valid",":invalid",":in-range",":out-of-range",":required",":optional"]),linguistic:new Set([":lang",":dir"]),functional:new Set([":not",":is",":where",":has"]),preventInlining:new Set([":hover",":active",":focus",":focus-within",":focus-visible",":visited",":target",":lang",":dir",":not",":is",":where",":has"])};O.set({precision:20,rounding:O.ROUND_HALF_UP});var u9={linear:[0,0,1,1],ease:[0.25,0.1,0.25,1],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]};function Z6($,J=3){if($===null||$===void 0)throw new Error("formatSplineValue: value parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("formatSplineValue: precision must be a non-negative finite number");let Z=typeof $==="number"?$:parseFloat($);if(!Number.isFinite(Z))throw new Error(`formatSplineValue: value must be a finite number, got ${$}`);let q=new O($).toDecimalPlaces(J).toString();if(q.includes("."))q=q.replace(/\.?0+$/,"");if(q.startsWith("0."))q=q.substring(1);else if(q.startsWith("-0."))q="-"+q.substring(2);if(q===""||q==="."||q==="-0")q="0";return q}function p6($){if(!$||typeof $!=="string")return[];return $.split(";").map((Z)=>Z.trim()).filter((Z)=>Z).map((Z)=>{let K=Z.split(/[\s,]+/).map((Q)=>parseFloat(Q)).filter((Q)=>Number.isFinite(Q));if(K.length!==4)throw new Error(`parseKeySplines: invalid spline "${Z}", expected 4 values, got ${K.length}`);return K})}function g9($,J=3){if(!Array.isArray($))throw new Error("serializeKeySplines: splines must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeySplines: precision must be a non-negative finite number");return $.map((Z,K)=>{if(!Array.isArray(Z))throw new Error(`serializeKeySplines: spline at index ${K} must be an array`);if(Z.length!==4)throw new Error(`serializeKeySplines: spline at index ${K} must have exactly 4 values, got ${Z.length}`);return Z.map((Q)=>Z6(Q,J)).join(" ")}).join("; ")}function c6($,J=0.001){if(!Array.isArray($)||$.length!==4)return!1;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("isLinearSpline: tolerance must be a non-negative finite number");let[Z,K,Q,q]=$;if(!Number.isFinite(Z)||!Number.isFinite(K)||!Number.isFinite(Q)||!Number.isFinite(q))return!1;return Math.abs(Z)<J&&Math.abs(K)<J&&Math.abs(Q-1)<J&&Math.abs(q-1)<J}function m5($){let J=p6($);if(J.length===0)return!1;return J.every((Z)=>c6(Z))}function x9($,J=0.01){if(!Array.isArray($)||$.length!==4)return null;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("identifyStandardEasing: tolerance must be a non-negative finite number");if(!$.every((Z)=>Number.isFinite(Z)))return null;for(let[Z,K]of Object.entries(u9))if($.every((q,H)=>Math.abs(q-K[H])<J))return Z;return null}function m9($,J={}){let Z=J.precision??3,K=J.removeLinear!==!1,Q=p6($);if(Q.length===0)return{value:null,allLinear:!1,standardEasings:[]};let q=Q.every((z)=>c6(z)),H=Q.map((z)=>x9(z)).filter(Boolean);if(q&&K)return{value:null,allLinear:!0,standardEasings:H};return{value:g9(Q,Z),allLinear:q,standardEasings:H}}function DH($){if(!$||typeof $!=="string")return[];return $.split(";").map((J)=>parseFloat(J.trim())).filter((J)=>Number.isFinite(J))}function hH($,J=3){if(!Array.isArray($))throw new Error("serializeKeyTimes: times must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeyTimes: precision must be a non-negative finite number");if($.length===0)return"";return $.map((Z)=>Z6(Z,J)).join("; ")}function d9($,J=3){if($===null||$===void 0)throw new Error("optimizeKeyTimes: keyTimes parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeKeyTimes: precision must be a non-negative finite number");let Z=DH($);if(Z.length===0)return $;return hH(Z,J)}function d6($,J=3){if(!$||typeof $!=="string")return $;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeAnimationValues: precision must be a non-negative finite number");let Z=$.split(";");if(Z.length===0)return $;return Z.map((Q)=>{let q=Q.trim();if(q.startsWith("#")||q.includes("url("))return q;return q.split(/[\s,]+/).filter((z)=>z).map((z)=>{let j=parseFloat(z);if(!Number.isFinite(j))return z;return Z6(j,J)}).join(" ")}).join("; ")}function yH($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeElementTiming: el parameter must be a valid element");if(typeof $.getAttribute!=="function"||typeof $.setAttribute!=="function"||typeof $.removeAttribute!=="function")throw new Error("optimizeElementTiming: el parameter must have getAttribute, setAttribute, and removeAttribute methods");let Z=J.precision??3,K=J.removeLinearSplines!==!1,Q=J.optimizeValues!==!1;if(typeof Z!=="number"||Z<0||!Number.isFinite(Z))throw new Error("optimizeElementTiming: options.precision must be a non-negative finite number");let q=[],H=!1,W=$.getAttribute("keySplines");if(W){let j=m9(W,{precision:Z,removeLinear:K});if(j.allLinear&&K){if($.getAttribute("calcMode")==="spline")$.setAttribute("calcMode","linear"),$.removeAttribute("keySplines"),q.push('Converted linear splines to calcMode="linear"'),H=!0}else if(j.value&&j.value!==W)$.setAttribute("keySplines",j.value),q.push(`keySplines: "${W}" -> "${j.value}"`),H=!0}let z=$.getAttribute("keyTimes");if(z){let j=d9(z,Z);if(j!==z)$.setAttribute("keyTimes",j),q.push(`keyTimes: "${z}" -> "${j}"`),H=!0}if(Q){let j=$.getAttribute("values");if(j){let G=d6(j,Z);if(G!==j)$.setAttribute("values",G),q.push(`values: "${j}" -> "${G}"`),H=!0}}for(let j of["from","to","by"]){let G=$.getAttribute(j);if(G){let F=d6(G,Z);if(F!==G)$.setAttribute(j,F),q.push(`${j}: "${G}" -> "${F}"`),H=!0}}return{modified:H,changes:q}}var uH=["animate","animatetransform","animatemotion","animatecolor","set"];function d5($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let Z=0,K=0,Q=[],q=(H)=>{if(!H||typeof H!=="object")return;let W=H.tagName?.toLowerCase();if(!W)return;if(uH.includes(W)){let j=yH(H,J);if(j.modified)Z++,K+=j.changes.length,Q.push({element:W,id:H.getAttribute("id")||null,changes:j.changes})}let z=H.children||[];for(let j of z)q(j)};return q($),{elementsModified:Z,totalChanges:K,details:Q}}O.set({precision:80});var c9={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function gH($){if(typeof $!=="string")throw new TypeError(`parseArcArgs: argsStr must be a string, got ${typeof $}`);let J=[],Z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,K=0,Q=0;while(K<$.length){while(K<$.length&&/[\s,]/.test($[K]))K++;if(K>=$.length)break;let q=Q%7;if(q===3||q===4)if($[K]==="0"||$[K]==="1")J.push($[K]==="1"?1:0),K++,Q++;else return null;else{Z.lastIndex=K;let H=Z.exec($);if(H&&H.index===K)J.push(parseFloat(H[0])),K=Z.lastIndex,Q++;else K++}}return J}function s0($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],q=K[2].trim();if(Q==="Z"||Q==="z"){J.push({command:"Z",args:[]});let z=q.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g);if(z&&z.length>=2){J.push({command:"M",args:[parseFloat(z[0]),parseFloat(z[1])]});for(let j=2;j+1<z.length;j+=2)J.push({command:"L",args:[parseFloat(z[j]),parseFloat(z[j+1])]})}continue}let H;if(Q==="A"||Q==="a"){if(H=gH(q),H===null){console.warn(`Invalid arc command with malformed flags - skipping: ${Q}${q}`);continue}for(let z=0;z<H.length;z+=7)if(z+6<H.length)H[z]=Math.abs(H[z]),H[z+1]=Math.abs(H[z+1])}else{let z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;H=[];let j;while((j=z.exec(q))!==null)H.push(parseFloat(j[0]))}let W=c9[Q];if(W===void 0){console.warn(`Unknown SVG path command '${Q}' - skipping`);continue}if(W===0||H.length===0)J.push({command:Q,args:[]});else for(let z=0;z<H.length;z+=W){let j=H.slice(z,z+W);if(j.length===W){let G=z>0&&(Q==="M"||Q==="m")?Q==="M"?"L":"l":Q;J.push({command:G,args:j})}else if(j.length>0)console.warn(`Incomplete ${Q} command: expected ${W} args, got ${j.length} - remaining args dropped`)}}return J}function u7($,J=3){if(typeof $!=="number")throw new TypeError(`formatNumber: num must be a number, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`formatNumber: precision must be a non-negative integer, got ${J}`);if(!isFinite($))return"0";if($===0)return"0";let Z=Math.pow(10,J),Q=(Math.round($*Z)/Z).toFixed(J);if(Q.includes("."))Q=Q.replace(/\.?0+$/,"");if(Q.startsWith("0."))Q=Q.substring(1);else if(Q.startsWith("-0."))Q="-"+Q.substring(2);if(Q===""||Q==="."||Q==="-.")Q="0";return Q}function I7($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toAbsolute: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toAbsolute: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toAbsolute: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toAbsolute: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toAbsolute: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toUpperCase()){if(c9[K]===void 0)throw new TypeError(`toAbsolute: unknown command '${K}'`);return $}let q=K.toUpperCase(),H=[...Q];switch(K){case"m":case"l":case"t":if(H.length<2)throw new RangeError(`toAbsolute: command ${K} requires at least 2 args, got ${H.length}`);H[0]+=J,H[1]+=Z;break;case"h":if(H.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${H.length}`);H[0]+=J;break;case"v":if(H.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${H.length}`);H[0]+=Z;break;case"c":if(H.length<6)throw new RangeError(`toAbsolute: command ${K} requires at least 6 args, got ${H.length}`);H[0]+=J,H[1]+=Z,H[2]+=J,H[3]+=Z,H[4]+=J,H[5]+=Z;break;case"s":case"q":if(H.length<4)throw new RangeError(`toAbsolute: command ${K} requires at least 4 args, got ${H.length}`);H[0]+=J,H[1]+=Z,H[2]+=J,H[3]+=Z;break;case"a":if(H.length<7)throw new RangeError(`toAbsolute: command ${K} requires at least 7 args, got ${H.length}`);H[5]+=J,H[6]+=Z;break;default:throw new TypeError(`toAbsolute: unsupported command '${K}' for conversion`)}return{command:q,args:H}}function n9($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toRelative: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toRelative: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toRelative: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toRelative: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toRelative: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toLowerCase()&&K!=="z"){if(c9[K]===void 0)throw new TypeError(`toRelative: unknown command '${K}'`);return $}if(K==="Z"||K==="z")return{command:"z",args:[]};let q=K.toLowerCase(),H=[...Q];switch(K){case"M":case"L":case"T":if(H.length<2)throw new RangeError(`toRelative: command ${K} requires at least 2 args, got ${H.length}`);H[0]-=J,H[1]-=Z;break;case"H":if(H.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${H.length}`);H[0]-=J;break;case"V":if(H.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${H.length}`);H[0]-=Z;break;case"C":if(H.length<6)throw new RangeError(`toRelative: command ${K} requires at least 6 args, got ${H.length}`);H[0]-=J,H[1]-=Z,H[2]-=J,H[3]-=Z,H[4]-=J,H[5]-=Z;break;case"S":case"Q":if(H.length<4)throw new RangeError(`toRelative: command ${K} requires at least 4 args, got ${H.length}`);H[0]-=J,H[1]-=Z,H[2]-=J,H[3]-=Z;break;case"A":if(H.length<7)throw new RangeError(`toRelative: command ${K} requires at least 7 args, got ${H.length}`);H[5]-=J,H[6]-=Z;break;default:throw new TypeError(`toRelative: unsupported command '${K}' for conversion`)}return{command:q,args:H}}function xH($,J,Z,K=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToHV: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToHV: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToHV: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToHV: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToHV: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`lineToHV: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:q}=$;if(Q!=="L"&&Q!=="l")return null;if(q.length<2)throw new RangeError(`lineToHV: command ${Q} requires at least 2 args, got ${q.length}`);let H=Q==="L",W=H?q[0]:J+q[0],z=H?q[1]:Z+q[1];if(Math.abs(z-Z)<K)return H?{command:"H",args:[W]}:{command:"h",args:[W-J]};if(Math.abs(W-J)<K)return H?{command:"V",args:[z]}:{command:"v",args:[z-Z]};return null}function mH($,J,Z,K,Q,q=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToZ: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToZ: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToZ: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToZ: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToZ: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K))throw new TypeError(`lineToZ: startX must be a finite number, got ${K}`);if(typeof Q!=="number"||!isFinite(Q))throw new TypeError(`lineToZ: startY must be a finite number, got ${Q}`);if(typeof q!=="number"||!isFinite(q)||q<0)throw new TypeError(`lineToZ: tolerance must be a non-negative finite number, got ${q}`);let{command:H,args:W}=$;if(H!=="L"&&H!=="l")return!1;if(W.length<2)throw new RangeError(`lineToZ: command ${H} requires at least 2 args, got ${W.length}`);let z=H==="L",j=z?W[0]:J+W[0],G=z?W[1]:Z+W[1];return Math.abs(j-K)<q&&Math.abs(G-Q)<q}function dH($,J,Z,K,Q,q,H,W,z=0.5){let j={x0:$,y0:J,cp1x:Z,cp1y:K,cp2x:Q,cp2y:q,x3:H,y3:W,tolerance:z};for(let[M,V]of Object.entries(j))if(typeof V!=="number"||!isFinite(V))throw new TypeError(`isCurveStraight: ${M} must be a finite number, got ${V}`);if(z<0)throw new TypeError(`isCurveStraight: tolerance must be non-negative, got ${z}`);let G=(H-$)**2+(W-J)**2;if(G<0.0000000001){let M=Math.sqrt((Z-$)**2+(K-J)**2),V=Math.sqrt((Q-$)**2+(q-J)**2);return Math.max(M,V)<z}let F=Math.sqrt(G),_=Math.abs((W-J)*Z-(H-$)*K+H*J-W*$)/F,U=Math.abs((W-J)*Q-(H-$)*q+H*J-W*$)/F;return Math.max(_,U)<z}function pH($,J,Z,K=0.5){if(!$||typeof $!=="object")throw new TypeError(`straightCurveToLine: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`straightCurveToLine: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("straightCurveToLine: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`straightCurveToLine: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`straightCurveToLine: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`straightCurveToLine: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:q}=$;if(Q!=="C"&&Q!=="c")return null;if(q.length<6)throw new RangeError(`straightCurveToLine: command ${Q} requires at least 6 args, got ${q.length}`);let H=Q==="C",W=H?q[0]:J+q[0],z=H?q[1]:Z+q[1],j=H?q[2]:J+q[2],G=H?q[3]:Z+q[3],F=H?q[4]:J+q[4],_=H?q[5]:Z+q[5];if(dH(J,Z,W,z,j,G,F,_,K))return H?{command:"L",args:[F,_]}:{command:"l",args:[F-J,_-Z]};return null}function p9($,J,Z=3,K=!1){if(!$||typeof $!=="object")throw new TypeError(`serializeCommand: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`serializeCommand: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("serializeCommand: cmd.args must be an array");if(J!==null&&typeof J!=="string")throw new TypeError(`serializeCommand: prevCommand must be a string or null, got ${typeof J}`);if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`serializeCommand: precision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`serializeCommand: prevLastArgHadDecimal must be a boolean, got ${typeof K}`);let{command:Q,args:q}=$;if(Q==="Z"||Q==="z")return{str:"z",lastArgHadDecimal:!1};if(Q==="A"||Q==="a"){if(q.length<7)throw new RangeError(`serializeCommand: arc command requires at least 7 args, got ${q.length}`);if(q.length>7)console.warn(`serializeCommand: arc command has ${q.length} args (expected 7) - only first 7 will be used`);let F=[u7(q[0],Z),u7(q[1],Z),u7(q[2],Z),q[3]?"1":"0",q[4]?"1":"0",u7(q[5],Z),u7(q[6],Z)].join(" ");return{str:Q+F,lastArgHadDecimal:F.includes(".")}}if(q.length===0)throw new RangeError(`serializeCommand: command ${Q} has empty args array (only Z/z should have no args)`);let H=q.map((F)=>u7(F,Z)),W="";for(let F=0;F<H.length;F++){let _=H[F];if(F===0)W=_;else{let M=H[F-1].includes(".");if(_.startsWith("-"))W+=_;else if(_.startsWith(".")&&M)W+=_;else W+=" "+_}}let j=(H[H.length-1]||"").includes("."),G=Q;if(J==="M"&&Q==="L")G="";else if(J==="m"&&Q==="l")G="";else if(J===Q&&Q!=="A"&&Q!=="a")G="";if(G)return{str:G+W,lastArgHadDecimal:j};else{let F=H[0]||"";if(F.startsWith("-"))return{str:W,lastArgHadDecimal:j};else if(F.startsWith(".")&&K)return{str:W,lastArgHadDecimal:j};else return{str:" "+W,lastArgHadDecimal:j}}}function o0($,J=3){if(!Array.isArray($))throw new TypeError(`serializePath: commands must be an array, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`serializePath: precision must be a non-negative integer, got ${J}`);if($.length===0)return"";let Z="",K=null,Q=!1;for(let q of $){let{str:H,lastArgHadDecimal:W}=p9(q,K,J,Q);Z+=H,K=q.command,Q=W}return Z}function l9($,J={}){if(typeof $!=="string")throw new TypeError(`convertPathData: d must be a string, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`convertPathData: options must be an object, got ${typeof J}`);let{floatPrecision:Z=3,straightCurves:K=!0,lineShorthands:Q=!0,convertToZ:q=!0,utilizeAbsolute:H=!0,straightTolerance:W=0.5}=J;if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`convertPathData: floatPrecision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof K}`);if(typeof Q!=="boolean")throw new TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof Q}`);if(typeof q!=="boolean")throw new TypeError(`convertPathData: convertToZ must be a boolean, got ${typeof q}`);if(typeof H!=="boolean")throw new TypeError(`convertPathData: utilizeAbsolute must be a boolean, got ${typeof H}`);if(typeof W!=="number"||!isFinite(W)||W<0)throw new TypeError(`convertPathData: straightTolerance must be a non-negative finite number, got ${W}`);let z=$.length,j=s0($);if(j.length===0)return{d:$,originalLength:z,optimizedLength:z,savings:0};let G=0,F=0,_=0,U=0,M=[];for(let Y=0;Y<j.length;Y++){let X=j[Y];if(X.command==="A"||X.command==="a"){if(X.args.length<7)console.warn(`Arc command has insufficient args (${X.args.length} < 7) - skipping optimization`);else if(X.args[0]===0||X.args[1]===0){let w=X.command==="A",R=X.args[5],I=X.args[6];X=w?{command:"L",args:[R,I]}:{command:"l",args:[R,I]}}}if(K&&(X.command==="C"||X.command==="c")){let w=pH(X,G,F,W);if(w)X=w}if(Q&&(X.command==="L"||X.command==="l")){let w=xH(X,G,F);if(w)X=w}if(q&&(X.command==="L"||X.command==="l")){if(mH(X,G,F,_,U))X={command:"z",args:[]}}if(H&&X.command!=="Z"&&X.command!=="z"){let w=I7(X,G,F),R=n9(X,G,F),I=p9(w,null,Z);X=p9(R,null,Z).str.length<I.str.length?R:w}M.push(X);let k=I7(X,G,F);switch(k.command){case"M":if(k.args.length>=2)G=k.args[0],F=k.args[1],_=G,U=F;break;case"L":case"T":if(k.args.length>=2)G=k.args[0],F=k.args[1];break;case"H":if(k.args.length>=1)G=k.args[0];break;case"V":if(k.args.length>=1)F=k.args[0];break;case"C":if(k.args.length>=6)G=k.args[4],F=k.args[5];break;case"S":case"Q":if(k.args.length>=4)G=k.args[2],F=k.args[3];break;case"A":if(k.args.length>=7)G=k.args[5],F=k.args[6];break;case"Z":G=_,F=U;break;default:break}}let V=o0(M,Z);return{d:V,originalLength:z,optimizedLength:V.length,savings:z-V.length}}function p5($,J={}){if(!$||typeof $!=="object")throw new TypeError(`optimizeDocumentPaths: root must be a DOM element object, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`optimizeDocumentPaths: options must be an object, got ${typeof J}`);let Z=0,K=0,Q=[],q=(H)=>{if(!H||typeof H!=="object")return;if(H.tagName?.toLowerCase()==="path"){let z=H.getAttribute("d");if(z){let j=l9(z,J);if(j.savings>0)H.setAttribute("d",j.d),Z++,K+=j.savings,Q.push({id:H.getAttribute("id")||null,originalLength:j.originalLength,optimizedLength:j.optimizedLength,savings:j.savings})}}for(let z of H.children||[])q(z)};return q($),{pathsOptimized:Z,totalSavings:K,details:Q}}function c5($,J,Z){if(!$||typeof $.x!=="number"||typeof $.y!=="number")throw new TypeError("perpendicularDistance: point must be an object with numeric x and y properties");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new TypeError("perpendicularDistance: lineStart must be an object with numeric x and y properties");if(!Z||typeof Z.x!=="number"||typeof Z.y!=="number")throw new TypeError("perpendicularDistance: lineEnd must be an object with numeric x and y properties");if(!Number.isFinite($.x)||!Number.isFinite($.y)||!Number.isFinite(J.x)||!Number.isFinite(J.y)||!Number.isFinite(Z.x)||!Number.isFinite(Z.y))throw new RangeError("perpendicularDistance: all coordinates must be finite numbers");let K=Z.x-J.x,Q=Z.y-J.y,q=K*K+Q*Q;if(q<0.0000000001){let z=$.x-J.x,j=$.y-J.y;return Math.sqrt(z*z+j*j)}let H=Math.abs(Q*$.x-K*$.y+Z.x*J.y-Z.y*J.x),W=Math.sqrt(q);return H/W}function K6($,J){if(!Array.isArray($))throw new TypeError("douglasPeucker: points must be an array");if($.length===0)throw new RangeError("douglasPeucker: points array cannot be empty");for(let H=0;H<$.length;H++){let W=$[H];if(!W||typeof W!=="object")throw new TypeError(`douglasPeucker: point at index ${H} must be an object`);if(typeof W.x!=="number"||!Number.isFinite(W.x))throw new TypeError(`douglasPeucker: point at index ${H} must have a finite numeric x property`);if(typeof W.y!=="number"||!Number.isFinite(W.y))throw new TypeError(`douglasPeucker: point at index ${H} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("douglasPeucker: tolerance must be a finite number");if(J<0)throw new RangeError("douglasPeucker: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("douglasPeucker: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if($.length<=2)return $;if($.length>1e4)return cH($,J);let Z=0,K=0,Q=$[0],q=$[$.length-1];for(let H=1;H<$.length-1;H++){let W=c5($[H],Q,q);if(W>Z)Z=W,K=H}if(Z>J){let H=K6($.slice(0,K+1),J),W=K6($.slice(K),J);return H.slice(0,-1).concat(W)}else return[Q,q]}function cH($,J){if($.length<=2)return $;let Z=new Array($.length).fill(!1);Z[0]=!0,Z[$.length-1]=!0;let K=[[0,$.length-1]];while(K.length>0){let[Q,q]=K.pop();if(q-Q<=1)continue;let H=0,W=Q,z=$[Q],j=$[q];for(let G=Q+1;G<q;G++){let F=c5($[G],z,j);if(F>H)H=F,W=G}if(H>J)Z[W]=!0,K.push([Q,W]),K.push([W,q])}return $.filter((Q,q)=>Z[q])}function s9($,J){if(!Array.isArray($))throw new TypeError("visvalingamWhyatt: points must be an array");if($.length===0)throw new RangeError("visvalingamWhyatt: points array cannot be empty");for(let W=0;W<$.length;W++){let z=$[W];if(!z||typeof z!=="object")throw new TypeError(`visvalingamWhyatt: point at index ${W} must be an object`);if(typeof z.x!=="number"||!Number.isFinite(z.x))throw new TypeError(`visvalingamWhyatt: point at index ${W} must have a finite numeric x property`);if(typeof z.y!=="number"||!Number.isFinite(z.y))throw new TypeError(`visvalingamWhyatt: point at index ${W} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("visvalingamWhyatt: minArea must be a finite number");if(J<0)throw new RangeError("visvalingamWhyatt: minArea cannot be negative");if($.length<=2)return $;let Z=(W,z,j)=>{return Math.abs((z.x-W.x)*(j.y-W.y)-(j.x-W.x)*(z.y-W.y))/2},K=$.map((W,z)=>({...W,index:z})),Q=new Array(K.length).fill(1/0);for(let W=1;W<K.length-1;W++)Q[W]=Z(K[W-1],K[W],K[W+1]);let q=new Array(K.length).fill(!0),H=K.length;while(H>2){let W=1/0,z=-1;for(let F=1;F<K.length-1;F++)if(q[F]&&Q[F]<W)W=Q[F],z=F;if(W>=J||z===-1)break;q[z]=!1,H--;let j=z-1;while(j>=0&&!q[j])j--;let G=z+1;while(G<K.length&&!q[G])G++;if(j>0){let F=j-1;while(F>=0&&!q[F])F--;if(F>=0&&G<K.length)Q[j]=Z(K[F],K[j],K[G])}if(G<K.length-1){let F=G+1;while(F<K.length&&!q[F])F++;if(F<K.length&&j>=0)Q[G]=Z(K[j],K[G],K[F])}}return K.filter((W,z)=>q[z])}function o9($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPolyline: points must be an array");if($.length===0)throw new RangeError("simplifyPolyline: points array cannot be empty");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPolyline: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPolyline: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPolyline: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(typeof Z!=="string")throw new TypeError("simplifyPolyline: algorithm must be a string");let K=["douglas-peucker","visvalingam"];if(!K.includes(Z))throw new RangeError(`simplifyPolyline: algorithm must be one of: ${K.join(", ")}`);if(Z==="visvalingam")return s9($,J*J);return K6($,J)}function nH($){if(!Array.isArray($))throw new TypeError("extractPolylinePoints: commands must be an array");let J=[],Z=0,K=0,Q=0,q=0;for(let H of $){if(!H||typeof H!=="object")throw new TypeError("extractPolylinePoints: each command must be an object");if(typeof H.command!=="string")throw new TypeError('extractPolylinePoints: each command must have a string "command" property');if(!Array.isArray(H.args))throw new TypeError('extractPolylinePoints: each command must have an "args" array');let{command:W,args:z}=H,j=(F)=>{if(z.length<F)throw new RangeError(`extractPolylinePoints: command "${W}" requires at least ${F} arguments, got ${z.length}`)},G=(F)=>{if(typeof z[F]!=="number"||!Number.isFinite(z[F]))throw new TypeError(`extractPolylinePoints: command "${W}" argument at index ${F} must be a finite number, got ${z[F]}`)};switch(W){case"M":j(2),G(0),G(1),Z=z[0],K=z[1],Q=Z,q=K,J.push({x:Z,y:K});break;case"m":j(2),G(0),G(1),Z+=z[0],K+=z[1],Q=Z,q=K,J.push({x:Z,y:K});break;case"L":j(2),G(0),G(1),Z=z[0],K=z[1],J.push({x:Z,y:K});break;case"l":j(2),G(0),G(1),Z+=z[0],K+=z[1],J.push({x:Z,y:K});break;case"H":j(1),G(0),Z=z[0],J.push({x:Z,y:K});break;case"h":j(1),G(0),Z+=z[0],J.push({x:Z,y:K});break;case"V":j(1),G(0),K=z[0],J.push({x:Z,y:K});break;case"v":j(1),G(0),K+=z[0],J.push({x:Z,y:K});break;case"Z":case"z":if(Z!==Q||K!==q)J.push({x:Q,y:q});Z=Q,K=q;break;case"C":j(6),G(4),G(5),Z=z[4],K=z[5];break;case"c":j(6),G(4),G(5),Z+=z[4],K+=z[5];break;case"S":case"Q":j(4),G(2),G(3),Z=z[2],K=z[3];break;case"s":case"q":j(4),G(2),G(3),Z+=z[2],K+=z[3];break;case"T":j(2),G(0),G(1),Z=z[0],K=z[1];break;case"t":j(2),G(0),G(1),Z+=z[0],K+=z[1];break;case"A":j(7),G(5),G(6),Z=z[5],K=z[6];break;case"a":j(7),G(5),G(6),Z+=z[5],K+=z[6];break;default:break}}return J}function lH($,J=!1){if(!Array.isArray($))throw new TypeError("rebuildPathFromPoints: points must be an array");if($.length===0)return[];if(typeof J!=="boolean")throw new TypeError("rebuildPathFromPoints: closed must be a boolean");for(let K=0;K<$.length;K++){let Q=$[K];if(!Q||typeof Q!=="object")throw new TypeError(`rebuildPathFromPoints: point at index ${K} must be an object`);if(typeof Q.x!=="number"||!Number.isFinite(Q.x))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric x property`);if(typeof Q.y!=="number"||!Number.isFinite(Q.y))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric y property`)}let Z=[];Z.push({command:"M",args:[$[0].x,$[0].y]});for(let K=1;K<$.length;K++)Z.push({command:"L",args:[$[K].x,$[K].y]});if(J)Z.push({command:"Z",args:[]});return Z}function i9($){if(!Array.isArray($))throw new TypeError("isPurePolyline: commands must be an array");let J=new Set(["M","m","L","l","H","h","V","v","Z","z"]);return $.every((Z)=>{if(!Z||typeof Z!=="object"||typeof Z.command!=="string")return!1;return J.has(Z.command)})}function r9($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPath: commands must be an array");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPath: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPath: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPath: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(!i9($)||$.length<3)return{commands:$,simplified:!1,originalPoints:0,simplifiedPoints:0};let K=nH($),Q=K.length;if(Q<3)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};let q=$[$.length-1].command.toLowerCase()==="z";if(q&&K.length>1){let j=K[0],G=K[K.length-1];if(Math.abs(G.x-j.x)<0.0000000001&&Math.abs(G.y-j.y)<0.0000000001)K=K.slice(0,-1)}let H=o9(K,J,Z),W=H.length;if(W>=Q)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};return{commands:lH(H,q),simplified:!0,originalPoints:Q,simplifiedPoints:W}}function z7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function j7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Precision must be a finite non-negative number, got ${$}`)}function q$($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Tolerance must be a finite non-negative number, got ${$}`)}function G7($,J=0){if(!$||typeof $!=="object")throw new TypeError("Command must be an object");if(typeof $.command!=="string")throw new TypeError("Command must have a string 'command' property");if(!Array.isArray($.args))throw new TypeError("Command must have an array 'args' property");if($.args.length<J)throw new TypeError(`Command ${$.command} requires at least ${J} args, got ${$.args.length}`);for(let Z=0;Z<$.args.length;Z++)if(typeof $.args[Z]!=="number"||!Number.isFinite($.args[Z]))throw new TypeError(`Command ${$.command} arg[${Z}] must be a finite number, got ${$.args[Z]}`)}function t9($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;Z.forEach((Q)=>G7(Q));let K=Z.map((Q)=>({command:Q.command,args:Q.args.map((q)=>{let H=u7(q,J),W=parseFloat(H);if(!Number.isFinite(W))throw new Error(`Invalid numeric value encountered: ${H}`);return W})}));return o0(K,J)}function e9($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;return Z.forEach((K)=>G7(K)),o0(Z,J)}function $J($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;Z.forEach((z)=>G7(z));let K=0,Q=0,q=0,H=0,W=[];for(let z of Z){let j=n9(z,K,Q);W.push(j);let G=I7(z,K,Q);switch(G.command){case"M":K=G.args[0],Q=G.args[1],q=K,H=Q;break;case"L":case"T":K=G.args[0],Q=G.args[1];break;case"H":K=G.args[0];break;case"V":Q=G.args[0];break;case"C":K=G.args[4],Q=G.args[5];break;case"S":case"Q":K=G.args[2],Q=G.args[3];break;case"A":K=G.args[5],Q=G.args[6];break;case"Z":K=q,Q=H;break;default:break}}return o0(W,J)}function JJ($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;Z.forEach((z)=>G7(z));let K=0,Q=0,q=0,H=0,W=[];for(let z of Z){let j=I7(z,K,Q);switch(W.push(j),j.command){case"M":K=j.args[0],Q=j.args[1],q=K,H=Q;break;case"L":case"T":K=j.args[0],Q=j.args[1];break;case"H":K=j.args[0];break;case"V":Q=j.args[0];break;case"C":K=j.args[4],Q=j.args[5];break;case"S":case"Q":K=j.args[2],Q=j.args[3];break;case"A":K=j.args[5],Q=j.args[6];break;case"Z":K=q,Q=H;break;default:break}}return o0(W,J)}function ZJ($,J=0.000001,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((j)=>G7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j of K){let G=j;if(j.command==="L"||j.command==="l"){let _=j.command==="L",U=_?j.args[0]:Q+j.args[0],M=_?j.args[1]:q+j.args[1];if(Math.abs(M-q)<J)G=_?{command:"H",args:[U]}:{command:"h",args:[U-Q]};else if(Math.abs(U-Q)<J)G=_?{command:"V",args:[M]}:{command:"v",args:[M-q]}}z.push(G);let F=I7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,W=q;break;case"L":case"T":Q=F.args[0],q=F.args[1];break;case"H":Q=F.args[0];break;case"V":q=F.args[0];break;case"C":Q=F.args[4],q=F.args[5];break;case"S":case"Q":Q=F.args[2],q=F.args[3];break;case"A":Q=F.args[5],q=F.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(z,Z)}function KJ($,J=0.000001,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((j)=>G7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j=0;j<K.length;j++){let G=K[j],F=G;if(G.command==="L"||G.command==="l"){let U=G.command==="L",M=U?G.args[0]:Q+G.args[0],V=U?G.args[1]:q+G.args[1];if((j===K.length-1||K[j+1].command==="M"||K[j+1].command==="m")&&Math.abs(M-H)<J&&Math.abs(V-W)<J)F={command:"z",args:[]}}z.push(F);let _=I7(F,Q,q);switch(_.command){case"M":Q=_.args[0],q=_.args[1],H=Q,W=q;break;case"L":case"T":Q=_.args[0],q=_.args[1];break;case"H":Q=_.args[0];break;case"V":q=_.args[0];break;case"C":Q=_.args[4],q=_.args[5];break;case"S":case"Q":Q=_.args[2],q=_.args[3];break;case"A":Q=_.args[5],q=_.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(z,Z)}function S$(...$){for(let J=0;J<$.length;J++)if(typeof $[J]!=="number"||!Number.isFinite($[J]))throw new TypeError(`Coordinate at position ${J} must be a finite number, got ${$[J]}`)}function n5($){if(typeof $!=="number"||!Number.isFinite($))throw new TypeError(`Parameter t must be a finite number, got ${$}`);if($<0||$>1)throw new RangeError(`Parameter t must be in range [0, 1], got ${$}`)}function n6($,J,Z,K,Q,q,H,W,z){n5($),S$(J,Z,K,Q,q,H,W,z);let j=1-$,G=j*j,F=G*j,_=$*$,U=_*$;return{x:F*J+3*G*$*K+3*j*_*q+U*W,y:F*Z+3*G*$*Q+3*j*_*H+U*z}}function a9($,J,Z,K,Q,q){S$($,J,Z,K,Q,q);let H=Q-Z,W=q-K,z=H*H+W*W;if(z<0.0000000001)return Math.sqrt(($-Z)**2+(J-K)**2);let j=Math.max(0,Math.min(1,(($-Z)*H+(J-K)*W)/z)),G=Z+j*H,F=K+j*W;return Math.sqrt(($-G)**2+(J-F)**2)}function sH($,J,Z,K,Q,q,H,W){S$($,J,Z,K,Q,q,H,W);let z=0,j=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let G of j){let F=n6(G,$,J,Z,K,Q,q,H,W),_=a9(F.x,F.y,$,J,H,W);if(_>z)z=_}for(let G=0;G<j.length-1;G++){let F=(j[G]+j[G+1])/2,_=n6(F,$,J,Z,K,Q,q,H,W),U=a9(_.x,_.y,$,J,H,W);if(U>z)z=U}for(let G of[0.05,0.95]){let F=n6(G,$,J,Z,K,Q,q,H,W),_=a9(F.x,F.y,$,J,H,W);if(_>z)z=_}return z}function oH($,J,Z,K,Q,q,H,W,z){return sH($,J,Z,K,Q,q,H,W)<=z}function QJ($,J=0.5,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((j)=>G7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j of K){let G=j;if(j.command==="C"||j.command==="c"){let _=j.command==="C",U=_?j.args[0]:Q+j.args[0],M=_?j.args[1]:q+j.args[1],V=_?j.args[2]:Q+j.args[2],Y=_?j.args[3]:q+j.args[3],X=_?j.args[4]:Q+j.args[4],k=_?j.args[5]:q+j.args[5];if(oH(Q,q,U,M,V,Y,X,k,J))G=_?{command:"L",args:[X,k]}:{command:"l",args:[X-Q,k-q]}}z.push(G);let F=I7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,W=q;break;case"L":case"T":Q=F.args[0],q=F.args[1];break;case"H":Q=F.args[0];break;case"V":q=F.args[0];break;case"C":Q=F.args[4],q=F.args[5];break;case"S":case"Q":Q=F.args[2],q=F.args[3];break;case"A":Q=F.args[5],q=F.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(z,Z)}function qJ($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;return Z.forEach((K)=>G7(K)),o0(Z,J)}function HJ($,J=3){if(z7($),j7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=s0($);if(Z.length===0)return $;Z.forEach((q)=>G7(q));let K=Math.pow(10,J),Q=Z.map((q)=>({command:q.command,args:q.args.map((H)=>Math.round(H*K)/K)}));return o0(Q,J)}function WJ($,J=0.000001,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((j)=>G7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j of K){let G=I7(j,Q,q),F=!0;switch(G.command){case"L":case"T":if(Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"H":if(Math.abs(G.args[0]-Q)<J)F=!1;break;case"V":if(Math.abs(G.args[0]-q)<J)F=!1;break;case"C":if(Math.abs(G.args[4]-Q)<J&&Math.abs(G.args[5]-q)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-q)<J&&Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-q)<J)F=!1;break;case"S":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-q)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"Q":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-q)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"A":if(Math.abs(G.args[5]-Q)<J&&Math.abs(G.args[6]-q)<J||Math.abs(G.args[0])<J||Math.abs(G.args[1])<J)F=!1;break;default:break}if(F)switch(z.push(j),G.command){case"M":Q=G.args[0],q=G.args[1],H=Q,W=q;break;case"L":case"T":Q=G.args[0],q=G.args[1];break;case"H":Q=G.args[0];break;case"V":q=G.args[0];break;case"C":Q=G.args[4],q=G.args[5];break;case"S":case"Q":Q=G.args[2],q=G.args[3];break;case"A":Q=G.args[5],q=G.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(z,Z)}function iH($,J,Z,K,Q,q,H){n5($),S$(J,Z,K,Q,q,H);let W=1-$,z=W*W,j=$*$;return{x:z*J+2*W*$*K+j*q,y:z*Z+2*W*$*Q+j*H}}function rH($,J,Z,K,Q,q,H,W,z,j){S$($,J,Z,K,Q,q,H,W,z,j);let G=0,F=[0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95];for(let _ of F){let U=n6(_,$,J,Z,K,Q,q,H,W),M=iH(_,$,J,z,j,H,W),V=Math.sqrt((U.x-M.x)**2+(U.y-M.y)**2);if(V>G)G=V}return G}function aH($,J,Z,K,Q,q,H,W,z){S$($,J,Z,K,Q,q,H,W),q$(z);let j=(3*(Z+Q)-$-H)/4,G=(3*(K+q)-J-W)/4;if(rH($,J,Z,K,Q,q,H,W,j,G)<=z)return{cpx:j,cpy:G};return null}function zJ($,J=0.5,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((j)=>G7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j of K){let G=j;if(j.command==="C"||j.command==="c"){let _=j.command==="C",U=_?j.args[0]:Q+j.args[0],M=_?j.args[1]:q+j.args[1],V=_?j.args[2]:Q+j.args[2],Y=_?j.args[3]:q+j.args[3],X=_?j.args[4]:Q+j.args[4],k=_?j.args[5]:q+j.args[5],w=aH(Q,q,U,M,V,Y,X,k,J);if(w)G=_?{command:"Q",args:[w.cpx,w.cpy,X,k]}:{command:"q",args:[w.cpx-Q,w.cpy-q,X-Q,k-q]}}z.push(G);let F=I7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,W=q;break;case"L":case"T":Q=F.args[0],q=F.args[1];break;case"H":Q=F.args[0];break;case"V":q=F.args[0];break;case"C":Q=F.args[4],q=F.args[5];break;case"S":case"Q":Q=F.args[2],q=F.args[3];break;case"A":Q=F.args[5],q=F.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(z,Z)}function jJ($,J=0.000001,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((F)=>G7(F));let Q=0,q=0,H=0,W=0,z=null,j=null,G=[];for(let F of K){let _=F,U=I7(F,Q,q);if(U.command==="Q"&&z!==null){let M=2*Q-z,V=2*q-j;if(Math.abs(U.args[0]-M)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="Q"?{command:"T",args:[U.args[2],U.args[3]]}:{command:"t",args:[U.args[2]-Q,U.args[3]-q]}}if(G.push(_),U.command==="Q")z=U.args[0],j=U.args[1];else if(U.command==="T")if(z!==null)z=2*Q-z,j=2*q-j;else z=Q,j=q;else z=null,j=null;switch(U.command){case"M":Q=U.args[0],q=U.args[1],H=Q,W=q;break;case"L":case"T":Q=U.args[0],q=U.args[1];break;case"H":Q=U.args[0];break;case"V":q=U.args[0];break;case"C":Q=U.args[4],q=U.args[5];break;case"S":case"Q":Q=U.args[2],q=U.args[3];break;case"A":Q=U.args[5],q=U.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(G,Z)}function GJ($,J=0.000001,Z=3){z7($),q$(J),j7(Z);let K=s0($);if(K.length===0)return $;K.forEach((F)=>G7(F));let Q=0,q=0,H=0,W=0,z=null,j=null,G=[];for(let F of K){let _=F,U=I7(F,Q,q);if(U.command==="C"&&z!==null){let M=2*Q-z,V=2*q-j;if(Math.abs(U.args[0]-M)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="C"?{command:"S",args:[U.args[2],U.args[3],U.args[4],U.args[5]]}:{command:"s",args:[U.args[2]-Q,U.args[3]-q,U.args[4]-Q,U.args[5]-q]}}if(G.push(_),U.command==="C")z=U.args[2],j=U.args[3];else if(U.command==="S")z=U.args[0],j=U.args[1];else z=null,j=null;switch(U.command){case"M":Q=U.args[0],q=U.args[1],H=Q,W=q;break;case"L":case"T":Q=U.args[0],q=U.args[1];break;case"H":Q=U.args[0];break;case"V":q=U.args[0];break;case"C":Q=U.args[4],q=U.args[5];break;case"S":case"Q":Q=U.args[2],q=U.args[3];break;case"A":Q=U.args[5],q=U.args[6];break;case"Z":Q=H,q=W;break;default:break}}return o0(G,Z)}function FJ($,J=3){z7($),j7(J);let Z=s0($);if(Z.length===0)return $;Z.forEach((Q)=>G7(Q));let K=Z.map((Q)=>{if(Q.command==="A"||Q.command==="a"){let q=[...Q.args];if(q.length!==7)throw new Error(`Arc command requires 7 arguments, got ${q.length}`);if(q[2]=(q[2]%360+360)%360,Math.abs(q[0]-q[1])<0.000001)q[2]=0;return q[3]=q[3]?1:0,q[4]=q[4]?1:0,{command:Q.command,args:q}}return Q});return o0(K,J)}var X$=new Set(["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]),OJ=new Set([...X$].map(($)=>$.toLowerCase())),k$=new Set(["accent-height","accumulate","additive","alignment-baseline","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clip-path","clip-rule","clipPathUnits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","contentScriptType","contentStyleType","cursor","cx","cy","d","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fill-rule","filter","filterRes","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","horiz-adv-x","horiz-origin-x","horiz-origin-y","href","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","onabort","onactivate","onbegin","onclick","onend","onerror","onfocusin","onfocusout","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onrepeat","onresize","onscroll","onunload","onzoom","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","path","pathLength","patternContentUnits","patternTransform","patternUnits","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfaceScale","systemLanguage","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","title","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:id","xml:lang","xml:space","xmlns","xmlns:xlink","y","y1","y2","yChannelSelector","z","zoomAndPan","line-height","marker"]),YJ=new Set([...k$].map(($)=>$.toLowerCase())),RW=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),BW=new Set(["href","tabindex","lang","transform-origin","vector-effect","paint-order","pathLength","fr","side","crossorigin","role","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-controls","aria-expanded","aria-haspopup","aria-live","aria-atomic","aria-relevant","aria-busy","aria-owns"]),NW=($)=>{if(!$||typeof $!=="string")return!1;return RW.has($.toLowerCase())},IW=($)=>{if(!$||typeof $!=="string")return!1;let J=$.toLowerCase();return BW.has(J)||J.startsWith("aria-")||J.startsWith("data-")},r5=new Set(["foreignobject","script","style","title","desc","metadata"]),l6=new Map,CW=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw new Error("Both parameters must be strings");let Z=`${$}|${J}`;if(l6.has(Z))return l6.get(Z);if($.length===0)return J.length;if(J.length===0)return $.length;let K=[];for(let q=0;q<=J.length;q++)K[q]=[q];for(let q=0;q<=$.length;q++)K[0][q]=q;for(let q=1;q<=J.length;q++)for(let H=1;H<=$.length;H++){let W=$[H-1]===J[q-1]?0:1;K[q][H]=Math.min(K[q-1][H]+1,K[q][H-1]+1,K[q-1][H-1]+W)}let Q=K[J.length][$.length];return l6.set(Z,Q),Q},PW=()=>l6.clear(),v$=($,J,Z=2)=>{if(!$||typeof $!=="string")return null;if(!J||!(J instanceof Set)||J.size===0)return null;let K=typeof Z!=="number"||Z<0?2:Z,Q=$.toLowerCase(),q=null,H=K+1;for(let W of J){let z=CW(Q,W.toLowerCase());if(z>0&&z<H)H=z,q=W}return q};function o7($){if(!$||typeof $!=="string")return!1;return/(%|em|rem|px|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|Q)$/i.test($.trim())}function AW($,J,Z=100){let K=new Set,Q=$,q=0;while(Q!==null&&Q!==void 0&&q<Z){if(K.has(Q))return!0;K.add(Q),Q=J(Q),q++}return q>=Z}function a5($){if(!$||typeof $!=="string")return $||"";return $.replace(/<(script|style)([^>]*)\sdata-cdata-pending="true"([^>]*)>([\s\S]*?)<\/\1>/gi,(J,Z,K,Q,q)=>{let H=q.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),W=(K+Q).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),z=W?" "+W:"";return`<${Z}${z}><![CDATA[
|
|
18
|
+
${H}
|
|
19
|
+
]]></${Z}>`})}var s6=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,H6=80,o6=6,qZ={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};O.set({precision:H6,rounding:O.ROUND_HALF_UP});var XJ=($)=>$ instanceof O?$:new O($);function a($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function HZ($,J=o6){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=o6;if(Z>H6)Z=H6;let Q=XJ($).toFixed(Z);if(Q.includes("."))return Q.replace(/\.?0+$/,"");return Q}function EW($){if($===null||$===void 0)return"";return String($).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var D0={SVG_STRING:"string",DOM_ELEMENT:"dom",FILE_PATH:"file",URL:"url",XML_DOCUMENT:"xml",CSS_SELECTOR:"selector",OBJECT_ELEMENT:"object",EMBED_ELEMENT:"embed",IFRAME_ELEMENT:"iframe"},M7={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},Y7={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function kJ($){if($===null||$===void 0)return Y7.STRING;if(typeof $==="object"&&$.nodeType)return Y7.DOM_UPDATE;if(typeof $==="string"){let J=$.trim();if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return Y7.DOM_REPLACE;if(J.includes("/")||J.includes("\\")||/\.\w+$/.test(J))return Y7.FILE;if(J.toLowerCase()==="download")return Y7.DOWNLOAD}return Y7.STRING}async function WZ($,J=null,Z={}){let K=kJ(J),Q;if(typeof $==="string")Q=$;else Q=z6($,M7.SVG_STRING,Z);switch(K){case Y7.STRING:return Q;case Y7.FILE:{if(typeof process!=="undefined"&&process.versions?.node){let q=await import("fs"),W=(await Promise.resolve().then(() => (O$(),V$))).dirname(J);if(W&&W!=="."&&!q.existsSync(W))q.mkdirSync(W,{recursive:!0});q.writeFileSync(J,Q,"utf8");return}throw new Error("File saving requires Node.js environment")}case Y7.DOM_REPLACE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");let q=document.querySelector(J);if(!q)throw new Error(`No element found for selector: ${J}`);q.innerHTML=Q;return}case Y7.DOM_UPDATE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");if(J.tagName?.toLowerCase()==="svg"){let W=new DOMParser().parseFromString(Q,"image/svg+xml").documentElement;while(J.attributes.length>0)J.removeAttribute(J.attributes[0].name);for(let z of W.attributes)J.setAttribute(z.name,z.value);J.innerHTML=W.innerHTML}else J.innerHTML=Q;return}case Y7.DOWNLOAD:{if(typeof document==="undefined"||typeof Blob==="undefined")throw new Error("Download requires browser environment");let q=new Blob([Q],{type:"image/svg+xml"}),H=URL.createObjectURL(q),W=document.createElement("a");W.href=H,W.download=Z.filename||"output.svg",document.body.appendChild(W),W.click(),document.body.removeChild(W),URL.revokeObjectURL(H);return}default:return Q}}function w$($){if($===null||$===void 0)throw new Error("Input cannot be null or undefined");if(typeof $==="string"){let J=$.trim();if(J.startsWith("<"))return D0.SVG_STRING;else if($.startsWith("http://")||$.startsWith("https://"))return D0.URL;else if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return D0.CSS_SELECTOR;else return D0.FILE_PATH}if(typeof HTMLObjectElement!=="undefined"&&$ instanceof HTMLObjectElement)return D0.OBJECT_ELEMENT;if(typeof HTMLEmbedElement!=="undefined"&&$ instanceof HTMLEmbedElement)return D0.EMBED_ELEMENT;if(typeof HTMLIFrameElement!=="undefined"&&$ instanceof HTMLIFrameElement)return D0.IFRAME_ELEMENT;if(a($))return D0.DOM_ELEMENT;if($&&$.nodeType===9)return D0.XML_DOCUMENT;return D0.SVG_STRING}async function W6($,J){switch(J){case D0.SVG_STRING:return u0($);case D0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer!=="undefined"){let K=new XMLSerializer().serializeToString($);return u0(K)}return $;case D0.XML_DOCUMENT:{let Z=$.documentElement||$;if(Z&&typeof Z.serialize==="function")return Z;if(typeof XMLSerializer!=="undefined"){let Q=new XMLSerializer().serializeToString(Z);return u0(Q)}return Z}case D0.FILE_PATH:{let K=(()=>({})).readFileSync($,"utf8");return u0(K)}if(typeof process!=="undefined"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),K=Z($,"utf8");return u0(K)}throw new Error("File loading requires Node.js environment");case D0.URL:if(typeof fetch!=="undefined"){let K=await(await fetch($)).text();return u0(K)}throw new Error("URL loading requires fetch API");case D0.CSS_SELECTOR:if(typeof document!=="undefined"){let Z=document.querySelector($);if(!Z)throw new Error(`No element found for selector: ${$}`);if(Z.tagName.toLowerCase()==="svg")return u0(new XMLSerializer().serializeToString(Z));let K=Z.querySelector("svg");if(K)return u0(new XMLSerializer().serializeToString(K));throw new Error(`Element "${$}" is not an SVG and contains no SVG`)}throw new Error("CSS selector requires browser environment");case D0.OBJECT_ELEMENT:try{if($.contentDocument&&$.contentDocument.documentElement){let Z=$.contentDocument.documentElement;if(Z.tagName.toLowerCase()==="svg")return u0(new XMLSerializer().serializeToString(Z))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLObjectElement: SVG content not accessible (cross-origin or security error)")}throw new Error("HTMLObjectElement: SVG content not accessible (not loaded or cross-origin)");case D0.EMBED_ELEMENT:if(typeof $.getSVGDocument==="function"){let Z=$.getSVGDocument();if(Z&&Z.documentElement)return u0(new XMLSerializer().serializeToString(Z.documentElement))}throw new Error("HTMLEmbedElement: SVG content not accessible");case D0.IFRAME_ELEMENT:try{let Z=$.contentDocument;if(Z&&Z.documentElement){let K=Z.documentElement;if(K.tagName.toLowerCase()==="svg")return u0(new XMLSerializer().serializeToString(K))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLIFrameElement: SVG content not accessible (cross-origin)")}throw new Error("HTMLIFrameElement: No SVG content found");default:throw new Error(`Unknown input type: ${J}`)}}function z6($,J,Z={}){switch(J){case M7.SVG_STRING:{let K=K7($,{minify:Z.minify!==!1});return a5(K)}case M7.DOM_ELEMENT:return $;case M7.XML_DOCUMENT:return $;default:{let K=K7($,{minify:Z.minify!==!1});return a5(K)}}}function F0($){return async function(J,Z={}){let K=w$(J),Q=await W6(J,K),q=Z.outputFormat||(K===D0.DOM_ELEMENT?M7.DOM_ELEMENT:M7.SVG_STRING),H=await $(Q,Z);return z6(H,q,Z)}}var wJ=F0(($,J={})=>{let Z=J.minify!==!1,K=J.remove!==!1,Q=J.force||!1,q=J.preserve||[],H=J.preservePrefixes||[];if(!Q){let I=$.querySelectorAll("script").length>0,P=Array.from($.querySelectorAll("style")).some((u)=>u.textContent&&u.textContent.trim().length>0);if(I||P)return $}let W=(I)=>{if(q.includes(I))return!0;if(H.some((P)=>I.startsWith(P)))return!0;return!1},z=(I)=>{try{return decodeURI(I)}catch(P){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${P.message}`);return I}},j=f5($),G=new Set;for(let I of j.all)G.add(I),G.add(z(I));let F=new Map,_=(I)=>{let P=I.getAttribute("id");if(P){if(!F.has(P))F.set(P,I)}for(let u of I.children)if(a(u))_(u)};_($);let U=new Set,M=new Set,V=(I)=>{let P=I.getAttribute("id");if(P){if(U.has(P))M.add(P);U.add(P)}for(let u of I.children)if(a(u))V(u)};V($);let Y=new Set,X=new Map,k=0,w=()=>{let I;do I=`a${k++}`;while(G.has(I)&&!F.has(I));return I},R=(I)=>{let P=I.getAttribute("id");if(P){if(M.has(P)){if(Y.has(P)){I.removeAttribute("id");return}Y.add(P)}let u=z(P),g=G.has(P)||G.has(u);if(W(P));else if(!g&&K)I.removeAttribute("id");else if(Z&&g){let b=w();if(X.set(P,b),u!==P)X.set(u,b);I.setAttribute("id",b)}}for(let u of I.children)if(a(u))R(u)};if(R($),Z){let I=(g)=>{let b=(h)=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let h of g.getAttributeNames()){let v=g.getAttribute(h);if(v&&v.includes("url(#")){for(let[E,m]of X){let c=b(E);v=v.replace(new RegExp(`url\\(#${c}\\)`,"g"),`url(#${m})`);let d=b(encodeURI(E));v=v.replace(new RegExp(`url\\(#${d}\\)`,"g"),`url(#${m})`)}g.setAttribute(h,v)}if((h==="href"||h==="xlink:href")&&v?.startsWith("#")){let E=v.substring(1),m=z(E);if(X.has(E))g.setAttribute(h,`#${X.get(E)}`);else if(X.has(m))g.setAttribute(h,`#${X.get(m)}`)}if((h==="begin"||h==="end")&&v){for(let[E,m]of X){let c=b(E);v=v.replace(new RegExp(`^${c}\\.`,"g"),`${m}.`),v=v.replace(new RegExp(`;${c}\\.`,"g"),`;${m}.`)}g.setAttribute(h,v)}if((h==="values"||h==="from"||h==="to"||h==="by")&&v){for(let[E,m]of X){let c=b(E);v=v.replace(new RegExp(`#${c}([;\\s]|$)`,"g"),`#${m}$1`)}g.setAttribute(h,v)}}for(let h of g.children)if(a(h))I(h)};I($);let P=(g)=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=$.getElementsByTagName("style");for(let g of u){let b=g.textContent;if(!b)continue;for(let[h,v]of X){let E=P(h);b=b.replace(new RegExp(`#${E}([^\\w-]|$)`,"g"),`#${v}$1`),b=b.replace(new RegExp(`url\\(#${E}\\)`,"g"),`url(#${v})`)}g.textContent=b}}return $}),a6=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let j=XJ(H).toDecimalPlaces(Z).toString();if(j.includes("."))j=j.replace(/0+$/,""),j=j.replace(/\.$/,"");return j},Q=(q)=>{for(let H of q.getAttributeNames()){let W=q.getAttribute(H);if(H.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|stroke-width|font-size)$/)){if(o7(W))continue;q.setAttribute(H,K(W))}if(H==="d"&&W){let z=W.replace(s6,(j)=>K(j));q.setAttribute("d",z)}if(H==="transform"&&W){let z=W.replace(s6,(j)=>K(j));q.setAttribute("transform",z)}if(H==="points"&&W){let z=W.replace(s6,(j)=>K(j));q.setAttribute("points",z)}}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),zZ=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let z=XJ(H).toDecimalPlaces(Z).toString();if(z.includes("."))z=z.replace(/0+$/,""),z=z.replace(/\.$/,"");return z},Q=(q)=>{for(let H of["points"]){let W=q.getAttribute(H);if(W){let z=W.replace(s6,K);q.setAttribute(H,z)}}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),jZ=F0(($,J={})=>{let Z=["data-name","data-id","class"],K=["xmlns:serif"],Q=(q)=>{for(let H of Z)if(q.hasAttribute(H))q.removeAttribute(H);if(!J.preserveVendor){for(let H of K)if(q.hasAttribute(H))q.removeAttribute(H)}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),GZ=F0(($,J={})=>{let Z=(K)=>{if(K.hasAttribute("enable-background"))K.removeAttribute("enable-background");for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),FZ=F0(($,J={})=>{let Z=Array.from($.querySelectorAll("style")).some((X)=>{let k=X.textContent||"";return k.includes("@media")||k.includes(":hover")||k.includes(":focus")||k.includes(":active")||k.includes(":visited")||k.includes(":first-child")||k.includes(":last-child")||k.includes(":nth-child")||k.includes(":not(")}),K=$.querySelectorAll("script").length>0,Q=new Set,q=$.outerHTML||"",H=q.matchAll(/url\(#([^)]+)\)/g);for(let X of H)Q.add(X[1]);let W=q.matchAll(/xlink:href="#([^"]+)"/g);for(let X of W)Q.add(X[1]);let z=q.matchAll(/\shref="#([^"]+)"/g);for(let X of z)Q.add(X[1]);let j={clippath:"clipPath",textpath:"textPath",lineargradient:"linearGradient",radialgradient:"radialGradient",meshgradient:"meshGradient",hatchpath:"hatchPath",solidcolor:"solidColor",foreignobject:"foreignObject",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",animatemotion:"animateMotion",animatetransform:"animateTransform"},G=(X)=>j[X]||X,F=["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","tref","textPath","textpath","defs","clipPath","clippath","mask","pattern","linearGradient","lineargradient","radialGradient","radialgradient","meshGradient","meshgradient","meshrow","meshpatch","hatch","hatchpath","hatchPath","solidcolor","solidColor","stop","image","use","symbol","marker","title","desc","metadata","foreignObject","foreignobject","switch","a","filter","feBlend","feblend","feColorMatrix","fecolormatrix","feComponentTransfer","fecomponenttransfer","feComposite","fecomposite","feConvolveMatrix","feconvolvematrix","feDiffuseLighting","fediffuselighting","feDisplacementMap","fedisplacementmap","feDistantLight","fedistantlight","feDropShadow","fedropshadow","feFlood","feflood","feFuncA","fefunca","feFuncB","fefuncb","feFuncG","fefuncg","feFuncR","fefuncr","feGaussianBlur","fegaussianblur","feImage","feimage","feMerge","femerge","feMergeNode","femergenode","feMorphology","femorphology","feOffset","feoffset","fePointLight","fepointlight","feSpecularLighting","fespecularlighting","feSpotLight","fespotlight","feTile","fetile","feTurbulence","feturbulence","animate","animateMotion","animatemotion","animateTransform","animatetransform","set","mpath","view","cursor","style","script","font","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","glyph","missing-glyph","hkern","vkern"],_={fill:"#000","fill-opacity":"1","fill-rule":"nonzero",stroke:"none","stroke-width":"1","stroke-opacity":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0",opacity:"1",visibility:"visible",display:"inline",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none","marker-start":"none","marker-mid":"none","marker-end":"none","stop-color":"#000","stop-opacity":"1","flood-color":"#000","flood-opacity":"1","lighting-color":"#fff","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","paint-order":"normal","vector-effect":"none","text-anchor":"start","text-overflow":"clip","text-decoration":"none","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline","writing-mode":"lr-tb",direction:"ltr","unicode-bidi":"normal","letter-spacing":"normal","word-spacing":"normal","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none"},U={circle:{cx:"0",cy:"0"},ellipse:{cx:"0",cy:"0"},line:{x1:"0",y1:"0",x2:"0",y2:"0"},rect:{x:"0",y:"0",rx:"0",ry:"0"},image:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},svg:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},symbol:{preserveAspectRatio:"xMidYMid meet"},marker:{markerUnits:"strokeWidth",refX:"0",refY:"0",markerWidth:"3",markerHeight:"3"},linearGradient:{x1:"0",y1:"0",x2:"100%",y2:"0",spreadMethod:"pad"},radialGradient:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%",spreadMethod:"pad"},pattern:{x:"0",y:"0",patternUnits:"objectBoundingBox",patternContentUnits:"userSpaceOnUse"},clipPath:{clipPathUnits:"userSpaceOnUse"},mask:{maskUnits:"objectBoundingBox",maskContentUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},filter:{primitiveUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},feBlend:{mode:"normal"},feColorMatrix:{type:"matrix"},feComposite:{operator:"over",k1:"0",k2:"0",k3:"0",k4:"0"},feTurbulence:{baseFrequency:"0",numOctaves:"1",seed:"0",stitchTiles:"noStitch",type:"turbulence"},feDisplacementMap:{scale:"0",xChannelSelector:"A",yChannelSelector:"A"},feDistantLight:{azimuth:"0",elevation:"0"},fePointLight:{x:"0",y:"0",z:"0"},a:{target:"_self"},textPath:{startOffset:"0"}},M=(X)=>{if(X.startsWith("data-"))return!0;if(X.startsWith("aria-"))return!0;if(X==="role")return!0;if(X==="xmlns")return!0;if(X.includes(":")&&!X.startsWith("xml:")&&!X.startsWith("xlink:"))return!0;return!1},V=(X,k)=>{let w=X.parentNode;while(w&&a(w)){let R=w.getAttribute(k);if(R!==null)return R;w=w.parentNode}return null},Y=(X,k={})=>{if(X.tagName==="foreignObject")return;if(X.tagName.includes(":"))return;if(!X.getAttribute("id")){for(let[u,g]of Object.entries(_))if(!M(u)&&X.getAttribute(u)===g)X.removeAttribute(u);let P=U[X.tagName.toLowerCase()]||{};for(let[u,g]of Object.entries(P))if(!M(u)&&X.getAttribute(u)===g)X.removeAttribute(u);if(!Z){for(let u of X.getAttributeNames())if(U$.has(u)&&!M(u)){let g=X.getAttribute(u),b=V(X,u);if(b!==null&&g===b)X.removeAttribute(u)}}}let w={...k};for(let P of U$){let u=X.getAttribute(P);if(u!==null)w[P]=u}let R=X.tagName.toLowerCase(),I=J6[R]||J6[G(R)];for(let P of[...X.children])if(a(P)){if(P.tagName.includes(":"))continue;let u=P.tagName.toLowerCase(),g=P.getAttribute("id"),b=K&&g,h=(v)=>{let E=v.getAttribute("id");if(E&&Q.has(E))return!0;for(let m of v.children||[])if(a(m)&&h(m))return!0;return!1};if(!F.includes(u)){if(!h(P)&&!b){X.removeChild(P);continue}}if(I&&!I.has(u)&&!I.has(G(u))){if(!h(P)&&!b){X.removeChild(P);continue}}Y(P,w)}};return Y($,{}),$}),_Z=F0(($,J={})=>{let Z=["x","y","width","height","viewBox"],K=(Q)=>{if(Q.tagName==="g"){for(let q of Z)if(Q.hasAttribute(q))Q.removeAttribute(q)}for(let q of Q.children)if(a(q))K(q)};return K($),$}),UZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of[...Z])if(K.children.length===0){if(K.parentNode)K.parentNode.removeChild(K)}return $}),t6=F0(($,J={})=>{let Z=J.force||!1,K=$.querySelectorAll("script").length>0,Q=new Set,q=(G)=>{for(let F of G.getAttributeNames()){let _=G.getAttribute(F);if(_&&_.includes("url(#")){let U=_.matchAll(/url\(#([^)]+)\)/g);for(let M of U)Q.add(M[1])}if((F==="href"||F==="xlink:href")&&_&&_.startsWith("#"))Q.add(_.substring(1))}for(let F of G.children)if(a(F))q(F)};q($);let H=(G)=>{let F=G.getAttribute("href")||G.getAttribute("xlink:href");if(F&&F.startsWith("#"))return!0;for(let _ of G.getAttributeNames?G.getAttributeNames():[]){let U=G.getAttribute(_);if(U&&U.includes("url(#"))return!0}return!1},W=(G)=>{for(let F of G.children){if(!a(F))continue;let _=F.tagName?.toLowerCase();if($6.animation.has(_))return!0;if(W(F))return!0}return!1},z=(G)=>{let F=G.getAttribute("id");if(F&&(Q.has(F)||K))return!0;for(let _ of G.children){if(!a(_))continue;if(z(_))return!0}return!1},j=(G,F=!1)=>{let _=G.tagName.toLowerCase(),U=F||_==="defs",M=G.getAttribute("display"),V=G.getAttribute("visibility"),Y=parseFloat(G.getAttribute("opacity")||"1");if(M==="none"||V==="hidden"||Y===0){if(!Z&&z(G));else if(!Z&&_==="marker");else if(!Z&&(G.getAttribute("marker-start")||G.getAttribute("marker-mid")||G.getAttribute("marker-end")));else if(!Z&&U&&$6.nonRendering.has(_));else if(!Z&&$6.animation.has(_));else if(!Z&&W(G));else if(!Z&&_==="use");else if(!Z&&H(G));else if(G.parentNode){G.parentNode.removeChild(G);return}}for(let k of[...G.children])if(a(k))j(k,U)};return j($),$}),VZ=F0(($,J={})=>{let Z=$.getElementsByTagName("text"),K=(H)=>{let W=H.textContent||"";if(H.children)for(let z of H.children)W+=K(z);return W},Q=(H,W)=>{if(!W||W.length===0)return!1;return(H.getAttributeNames?H.getAttributeNames():[]).some((j)=>W.some((G)=>j.startsWith(G+":")))},q=J.preserveNamespaces||[];for(let H of[...Z]){let W=K(H),z=!W||W.trim()==="",j=Q(H,q);if(z&&!j){if(H.parentNode)H.parentNode.removeChild(H)}}return $}),e6=F0(($,J={})=>{let Z=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],K=$.querySelectorAll("script").length>0,Q=new Set,q=(W)=>{for(let z of W.getAttributeNames?W.getAttributeNames():[]){let j=W.getAttribute(z);if(j&&j.includes("url(#")){let G=j.matchAll(/url\(#([^)]+)\)/g);for(let F of G)Q.add(F[1])}if((z==="href"||z==="xlink:href")&&j&&j.startsWith("#"))Q.add(j.substring(1))}for(let z of W.children||[])if(a(z))q(z)};q($);let H=(W)=>{for(let G of[...W.children])if(a(G))H(G);let z=W.tagName?.toLowerCase();if(!Z.includes(W.tagName)&&!Z.includes(z))return;if(W.getAttribute("href")||W.getAttribute("xlink:href"))return;let j=W.getAttribute("id");if(j&&(Q.has(j)||K))return;if(W.children.length===0){if(W.parentNode)W.parentNode.removeChild(W)}};return H($),$}),OZ=F0(($,J={})=>{return $}),YZ=F0(($,J={})=>{return $}),$9=F0(($,J={})=>{return $}),J9=F0(($,J={})=>{if(J.preserveVendor)return $;let Z=$.getElementsByTagName("metadata");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),MZ=F0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),XZ=F0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),LJ=F0(($,J={})=>{if(J.preserveVendor===!0)return $;let Z=J.preserveNamespaces||[],K=new Set(Z);if(K.has("sodipodi"))K.add("inkscape");if(K.has("inkscape"))K.add("sodipodi");let Q=["inkscape","sodipodi","illustrator","sketch","ai","serif","vectornator","figma"].filter((j)=>!K.has(j));if(Q.length===0)return $;let q=(j)=>{for(let G of[...j.children])if(a(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(Q.includes(_)){j.removeChild(G);continue}}q(G)}};q($);let H=(j)=>{for(let G of[...j.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(Q.includes(_))j.removeAttribute(G)}}for(let G of j.children)if(a(G))H(G)};H($);let W=new Set,z=(j)=>{for(let F of j.getAttributeNames()){if(F.startsWith("xmlns:"))continue;let _=F.indexOf(":");if(_>0){let U=F.substring(0,_);W.add(U)}}let G=j.tagName.indexOf(":");if(G>0)W.add(j.tagName.substring(0,G));for(let F of j.children)if(a(F))z(F)};z($);for(let j of Q){let G=`xmlns:${j}`;if($.hasAttribute(G)&&!W.has(j))$.removeAttribute(G)}return $}),kZ=F0(($,J={})=>{let Z=(K)=>{for(let Q of[...K.getAttributeNames()]){let q=K.getAttribute(Q);if(q===""||q===null)K.removeAttribute(Q)}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),wZ=F0(($,J={})=>{let Z=$.getAttribute("width"),K=$.getAttribute("height"),Q=$.getAttribute("viewBox");if(o7(Z)||o7(K))return $;if(Z&&K&&Q){let q=Q.split(/[\s,]+/).map(parseFloat),H=parseFloat(Z),W=parseFloat(K);if(isNaN(H)||isNaN(W)||q.some((j)=>isNaN(j)))return $;let z=0.000001;if(q.length===4&&Math.abs(q[0])<z&&Math.abs(q[1])<z&&Math.abs(q[2]-H)<z&&Math.abs(q[3]-W)<z)$.removeAttribute("viewBox")}return $}),LZ=F0(($,J={})=>{let Z=J.preserveSvgNamespace!==!1,K=J.removeXlinkNamespace!==!1;if(J.preserveVendor){if(!Z)$.removeAttribute("xmlns");return $}if(!Z)$.removeAttribute("xmlns");if(K){let Q=!1,q=(H)=>{for(let W of H.getAttributeNames())if(W.startsWith("xlink:")){Q=!0;return}for(let W of H.children){if(a(W))q(W);if(Q)return}};if(q($),!Q)$.removeAttribute("xmlns:xlink")}return $.removeAttribute("xmlns:svg"),$}),RZ=F0(($,J={})=>{let Z=$.querySelectorAll("script").length>0,K=new Set,Q=(H)=>{for(let W of H.getAttributeNames()){let z=H.getAttribute(W);if(z&&z.includes("url(#")){let j=z.matchAll(/url\(#([^)]+)\)/g);for(let G of j)K.add(G[1])}if((W==="href"||W==="xlink:href")&&z&&z.startsWith("#"))K.add(z.substring(1))}for(let W of H.children)if(a(W))Q(W)};Q($);let q=$.getElementsByTagName("image");for(let H of[...q]){let W=H.getAttribute("id");if(W&&(K.has(W)||Z))continue;if(H.parentNode)H.parentNode.removeChild(H)}return $}),BZ=F0(($,J={})=>{let Z=new Set,K=(q)=>{for(let H of q.getAttributeNames()){let W=q.getAttribute(H);if(W&&W.includes("url(#")){let z=W.matchAll(/url\(#([^)]+)\)/g);for(let j of z)Z.add(j[1])}if((H==="href"||H==="xlink:href")&&W&&W.startsWith("#"))Z.add(W.substring(1))}for(let H of q.children)if(a(H))K(H)};K($);let Q=$.getElementsByTagName("script");for(let q of[...Q]){let H=q.getAttribute("id");if(!H||!Z.has(H)){if(q.parentNode)q.parentNode.removeChild(q)}}return $}),NZ=F0(($,J={})=>{let Z=J.precision||6,K=J.convertRoundedRects||!1,Q=["rect","circle","ellipse","line","polyline","polygon"],q=(H)=>{if(Q.includes(H.tagName)){if(H.tagName==="rect"){let z=parseFloat(H.getAttribute("x")||"0"),j=parseFloat(H.getAttribute("y")||"0"),G=parseFloat(H.getAttribute("width")||"0"),F=parseFloat(H.getAttribute("height")||"0");if(isNaN(z)||isNaN(j)||isNaN(G)||isNaN(F)){for(let _ of[...H.children])if(a(_))q(_);return}}if(H.tagName==="rect"&&!K){let z=parseFloat(H.getAttribute("rx")||"0"),j=parseFloat(H.getAttribute("ry")||"0");if(isNaN(z)||isNaN(j)||z>0||j>0){for(let G of[...H.children])if(a(G))q(G);return}}if(H.tagName==="polyline"||H.tagName==="polygon"){if((H.getAttribute("points")||"").trim().split(/[\s,]+/).length<4){for(let G of[...H.children])if(a(G))q(G);return}}let W=k9(H,Z);if(W){let z=new w0("path",{d:W});for(let j of H.getAttributeNames())if(!j.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let G=H.getAttribute(j);if(G!==null)z.setAttribute(j,G)}for(let j of[...H.children])z.appendChild(j);if(H.parentNode)H.parentNode.replaceChild(z,H)}}for(let W of[...H.children])if(a(W))q(W)};return q($),$}),IZ=F0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=new Set,q=(W)=>{for(let z of["href","xlink:href"]){let j=W.getAttribute(z);if(j&&j.startsWith("#"))Q.add(j.substring(1))}for(let z of W.children)if(a(z))q(z)};q($);let H=$.getElementsByTagName("path");for(let W of H){let z=W.getAttribute("d");if(!z)continue;let j=W.getAttribute("id");if(!K&&j&&Q.has(j))continue;if(!K&&W.getAttribute("style"))continue;let G=W.getAttribute("stroke-linecap"),F=G&&G!=="butt";if((z.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!K&&W.getAttribute("marker-mid"))continue;let U=c$(z);W.setAttribute("d",U)}return $}),CZ=F0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=(q)=>{let H=q.getAttribute("transform");if(H){let W=V7(H),z=v8(W,Z);if(!K&&z.length>=H.length);else if(!K&&q.getAttribute("stroke")&&q.getAttribute("stroke")!=="none"){let j=W.data[0][0].toNumber(),G=W.data[0][1].toNumber(),F=W.data[1][0].toNumber(),_=W.data[1][1].toNumber(),U=j*_-G*F,M=Math.abs(j-_)<0.000001&&Math.abs(G+F)<0.000001,V=0.0000000001;if(!M&&Math.abs(U)>0.0000000001);else q.setAttribute("transform",z)}else q.setAttribute("transform",z)}for(let W of q.children)if(a(W))Q(W)};return Q($),$}),Z9=F0(($,J={})=>{let Z=["fill","stroke","stop-color","flood-color","lighting-color"],K=(q)=>{if(!q||typeof q!=="string")return q;let H={white:"#fff",black:"#000",red:"#f00",green:"#0f0",blue:"#00f",yellow:"#ff0",cyan:"#0ff",magenta:"#f0f"};if(H[q.toLowerCase()])return H[q.toLowerCase()];let W=q.match(/^#([0-9a-f]{6})$/i);if(W){let z=W[1];if(z[0]===z[1]&&z[2]===z[3]&&z[4]===z[5])return`#${z[0]}${z[2]}${z[4]}`}return q},Q=(q)=>{for(let H of Z){let W=q.getAttribute(H);if(W)q.setAttribute(H,K(W))}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),RJ=F0(($,J={})=>{let Z=J.preserveVendor||!1,K=new Set(["alignment-baseline","baseline-shift","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","display","dominant-baseline","enable-background","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","kerning","letter-spacing","lighting-color","marker","marker-end","marker-mid","marker-start","mask","opacity","overflow","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","transform","transform-origin","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"]),Q=(q)=>{let H=q.getAttribute("style");if(H){let W=H.split(";").map((j)=>j.trim()).filter((j)=>j),z=[];for(let j of W){let G=j.indexOf(":");if(G===-1)continue;let F=j.substring(0,G).trim(),_=j.substring(G+1).trim();if(F&&_){if(!F.startsWith("-")&&K.has(F))q.setAttribute(F,_);else if(Z&&F.startsWith("-"))z.push(j)}}if(z.length>0)q.setAttribute("style",z.join("; "));else q.removeAttribute("style")}for(let W of q.children)if(a(W))Q(W)};return Q($),$}),PZ=F0(($,J={})=>{let Z=$.getElementsByTagName("ellipse");for(let K of[...Z]){let Q=parseFloat(K.getAttribute("rx")||"0"),q=parseFloat(K.getAttribute("ry")||"0");if(isNaN(Q)||isNaN(q))continue;if(Math.abs(Q-q)<0.001){let H=new w0("circle",{});for(let W of K.getAttributeNames()){let z=K.getAttribute(W);if(W==="rx"||W==="ry")H.setAttribute("r",z);else H.setAttribute(W,z)}for(let W of[...K.children])H.appendChild(W);if(K.parentNode)K.parentNode.replaceChild(H,K)}}return $}),AZ=F0(($,J={})=>{let Z=J.force||!1,K=(Q,q=!1,H=!1)=>{let W=Q.tagName.toLowerCase(),z=H||W==="switch";for(let j of[...Q.children])if(a(j))K(j,!1,z);if(W!=="g")return;if(!Z&&(q||z))return;if(!Z&&Q.getAttribute("filter"))return;if(Q.children.length===1){let j=Q.children[0];if(!a(j))return;if(!Z&&j.getAttribute("id"))return;let G=Array.from(Q.children).some((U)=>a(U)&&$6.animation.has(U.tagName.toLowerCase()));if(!Z&&G)return;let F=Q.getAttributeNames(),_=F.some((U)=>{if(U$.has(U))return!1;return j.hasAttribute(U)});if(!Z&&_)return;if(F.length===0){if(Q.parentNode)Q.parentNode.replaceChild(j,Q)}else{let U=!0;for(let M of F){if(!U$.has(M)&&M!=="class"&&M!=="style"){U=!1;break}if(j.hasAttribute(M)){U=!1;break}}if(U&&Q.parentNode){for(let M of F){let V=Q.getAttribute(M);if(V!==null)j.setAttribute(M,V)}Q.parentNode.replaceChild(j,Q)}}}};return K($,!0),$}),EZ=F0(($,J={})=>{let Z=J.force||!1,K=(q)=>q&&q.includes("url("),Q=(q)=>{let H=[...q.children].filter((W)=>a(W)&&W.tagName==="path");for(let W=0;W<H.length-1;W++){let z=H[W],j=H[W+1];if(!Z&&(z.children.length>0||j.children.length>0))continue;let F=["marker-start","marker-mid","marker-end"].some((M)=>z.getAttribute(M)||j.getAttribute(M));if(!Z&&F)continue;if(!Z&&(z.getAttribute("clip-path")||z.getAttribute("mask")||j.getAttribute("clip-path")||j.getAttribute("mask")))continue;if(!Z){let M=z.getAttribute("fill"),V=z.getAttribute("stroke"),Y=j.getAttribute("fill"),X=j.getAttribute("stroke");if(K(M)||K(V)||K(Y)||K(X))continue}if(!Z){let M=z.getAttribute("fill-rule")||"nonzero",V=j.getAttribute("fill-rule")||"nonzero";if(M!==V)continue}if(!Z&&(z.getAttribute("filter")||j.getAttribute("filter")))continue;let _=z.getAttributeNames().filter((M)=>M!=="d").sort(),U=j.getAttributeNames().filter((M)=>M!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let M=!0;for(let V of _)if(z.getAttribute(V)!==j.getAttribute(V)){M=!1;break}if(M){let V=z.getAttribute("d"),Y=j.getAttribute("d");if(z.setAttribute("d",`${V} ${Y}`),j.parentNode)j.parentNode.removeChild(j);H.splice(W+1,1),W--}}}for(let W of q.children)if(a(W))Q(W)};return Q($),$}),TZ=F0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g")for(let Q of[...K.getAttributeNames()]){if(!U$.has(Q))continue;let q=K.getAttribute(Q);if(q){for(let H of K.children)if(a(H)&&!H.hasAttribute(Q))H.setAttribute(Q,q);K.removeAttribute(Q)}}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),bZ=F0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g"&&K.children.length>1)for(let Q of U$){let q=null,H=!0;for(let W of K.children){if(!a(W))continue;let z=W.getAttribute(Q);if(!z){H=!1;break}if(q===null)q=z;else if(q!==z){H=!1;break}}if(H&&q){K.setAttribute(Q,q);for(let W of K.children)if(a(W))W.removeAttribute(Q)}}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),BJ=F0(($,J={})=>{if($.getElementsByTagName("script").length>0&&!J.force)return $;let K=$.getElementsByTagName("style");for(let Q of K){let q=Q.textContent;if(!q||!q.trim())continue;let H=q.includes("<![CDATA[")||q.includes("]]>"),W="",z="";if(H){let j=q.match(/^(\s*<!\[CDATA\[\s*)/),G=q.match(/(\s*\]\]>\s*)$/);if(j)W="<![CDATA[",q=q.replace(/^\s*<!\[CDATA\[\s*/,"");if(G)z="]]>",q=q.replace(/\s*\]\]>\s*$/,"")}if(q=q.replace(/\/\*[\s\S]*?\*\//g,""),q=q.replace(/\s+/g," "),q=q.replace(/\s*([{}:;,])\s*/g,"$1"),q=q.trim(),W||z)q=W+q+z;Q.textContent=q}return $}),fZ=F0(($,J={})=>{let Z=J.onlyMatchedOnce!==!1,K=J.removeStyleElement!==!1,Q=$.getElementsByTagName("style"),q=[];for(let H of Q){let W=H.getAttribute("type");if(W&&W!=="text/css")continue;let z=H.textContent;if(!z||!z.trim())continue;if(z.includes("@media")||z.includes("@keyframes")||z.includes("@supports")||z.includes("@font-face"))continue;let j=z.match(/([^{]+)\{([^}]+)\}/g)||[],G=[];for(let U of j){let M=U.match(/([^{]+)\{([^}]+)\}/);if(!M)continue;let V=M[1].trim(),Y=M[2].trim(),X=!1;for(let w of x5.preventInlining)if(V.includes(w)){X=!0;break}if(X){q.push(U);continue}let k;try{k=B6(V)}catch(w){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${w.message}`);q.push(U);continue}G.push({selector:V,declarations:Y,specificity:k,originalRule:U})}G.sort((U,M)=>N6(U.specificity,M.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:M,specificity:V,originalRule:Y}of G)try{let X=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&X.length>1){q.push(Y);continue}for(let k of X){let w=k,R=!1;while(w){if(w.tagName==="foreignObject"){R=!0;break}w=w.parentNode}if(R)continue;if(!F.has(k))F.set(k,new Map),_.add(k);let I=F.get(k),P=k.getAttribute("style")||"";if(P&&I.size===0){let g=P.split(";");for(let b of g){let h=b.indexOf(":");if(h>0){let v=b.substring(0,h).trim(),E=b.substring(h+1).trim(),m=E.includes("!important");if(m)E=E.replace(/\s*!important\s*/g,"").trim();I.set(v,{specificity:[1,0,0,0],isImportant:m,value:E})}}}let u=M.split(";");for(let g of u){let b=g.indexOf(":");if(b<=0)continue;let h=g.substring(0,b).trim(),v=g.substring(b+1).trim(),E=v.includes("!important");if(E)v=v.replace(/\s*!important\s*/g,"").trim();let m=I.get(h);if(m){let c=N6(V,m.specificity);if(c<0){if(E&&!m.isImportant)I.set(h,{specificity:V,isImportant:E,value:v})}else if(c===0){if(E||!m.isImportant)I.set(h,{specificity:V,isImportant:E,value:v})}else if(!m.isImportant||E)I.set(h,{specificity:V,isImportant:E,value:v})}else I.set(h,{specificity:V,isImportant:E,value:v})}}}catch(X){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${X.message}`);q.push(Y)}for(let U of _){let M=F.get(U),V=[];for(let[Y,{value:X,isImportant:k}]of M)if(k)V.push(`${Y}: ${X} !important`);else V.push(`${Y}: ${X}`);U.setAttribute("style",V.join("; "))}if(K&&H.parentNode)if(q.length>0)H.textContent=q.join(`
|
|
20
|
+
`);else H.parentNode.removeChild(H)}return $}),SZ=F0(($,J={})=>{let Z=(K)=>{let Q=K.getAttributeNames().sort(),q=Q.map((H)=>[H,K.getAttribute(H)]);for(let H of Q)K.removeAttribute(H);for(let[H,W]of q)K.setAttribute(H,W);for(let H of K.children)if(a(H))Z(H)};return Z($),$}),vZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of Z){let Q=[...K.children].filter((q)=>a(q));Q.sort((q,H)=>q.tagName.localeCompare(H.tagName));for(let q of[...K.children])K.removeChild(q);for(let q of Q)K.appendChild(q)}return $}),DZ=F0(($,J={})=>{let Z=J.threshold||2,K=$.getElementsByTagName("path"),Q=new Map;for(let W of K){let z=W.getAttribute("d");if(z){if(!Q.has(z))Q.set(z,[]);Q.get(z).push(W)}}let q=$.querySelector("defs");if(!q)if(q=new w0("defs",{}),$.firstChild)$.insertBefore(q,$.firstChild);else $.appendChild(q);let H=0;for(let[W,z]of Q)if(z.length>=Z){let j=`path${H++}`,G=new w0("path",{id:j,d:W});q.appendChild(G);for(let F of z){let _=new w0("use",{href:`#${j}`});for(let U of F.getAttributeNames())if(U!=="d"){let M=F.getAttribute(U);if(M!==null)_.setAttribute(U,M)}for(let U of[...F.children])_.appendChild(U);if(F.parentNode)F.parentNode.replaceChild(_,F)}}return $}),hZ=F0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let K=R8(Z);if(!K)return $;let Q=h7($),q=$.getElementsByTagName("path");for(let H of[...q]){let W=H.getAttribute("d");if(!W)continue;try{let z=J$(W),j=B8(z);if(!j)continue;let G=i$(H),_=o$(H,G,Q).getRenderedBBox(j),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!N8(U,K)){if(H.parentNode)H.parentNode.removeChild(H)}}catch(z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${z.message}`)}}return $}),yZ=F0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),uZ=F0(($,J={})=>{let Z={new:"_blank",replace:"_self"},K=!1,Q=(q)=>{for(let H of[...q.getAttributeNames()])if(H.startsWith("xlink:")){let W=H.substring(6),z=q.getAttribute(H);if(W==="href")K=!0;else if(W==="show"){if(!q.hasAttribute("target")){let j=Z[z];if(j)q.setAttribute("target",j)}q.removeAttribute(H)}else if(W==="title"){if(!(q.querySelector&&q.querySelector("title"))&&z){let G=new w0("title",{},[],z);if(typeof q.insertBefore==="function"&&q.firstChild)q.insertBefore(G,q.firstChild);else if(typeof q.appendChild==="function")q.appendChild(G);else if(q.children&&Array.isArray(q.children))q.children.unshift(G),G.parentNode=q}q.removeAttribute(H)}else if(["actuate","type","role","arcrole"].includes(W))q.removeAttribute(H);else K=!0}for(let H of q.children)if(a(H))Q(H)};if(Q($),!K)$.removeAttribute("xmlns:xlink");return $}),gZ=F0(($,J={})=>{let Z=J.attributes||{};for(let[K,Q]of Object.entries(Z))$.setAttribute(K,Q);return $}),xZ=F0(($,J={})=>{let Z=J.classes||[],K=$.getAttribute("class")||"",Q=K?`${K} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",Q.trim()),$}),mZ=F0(($,J={})=>{let Z=J.prefix||"svg",K=new Map,Q=new Map,q=(j)=>j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=(j)=>{let G=j.getAttribute("id");if(G){let F=`${Z}${G}`;K.set(G,F),j.setAttribute("id",F)}for(let F of j.children)if(a(F))H(F)};if(H($),J.prefixClassNames!==!1){let j=(F)=>{let _=F.getAttribute("class");if(_){for(let U of _.split(/\s+/))if(U&&!Q.has(U))Q.set(U,`${Z}${U}`)}for(let U of F.children)if(a(U))j(U)};j($);let G=(F)=>{let _=F.getAttribute("class");if(_){let U=_.split(/\s+/).map((M)=>Q.get(M)||M).join(" ");F.setAttribute("class",U)}for(let U of F.children)if(a(U))G(U)};G($)}let W=$.getElementsByTagName("style");for(let j of W){let G=j.textContent;if(!G)continue;for(let[F,_]of K){let U=q(F);G=G.replace(new RegExp(`#${U}([^\\w-]|$)`,"g"),`#${_}$1`),G=G.replace(new RegExp(`url\\(#${U}\\)`,"g"),`url(#${_})`)}if(J.prefixClassNames!==!1)for(let[F,_]of Q){let U=q(F);G=G.replace(new RegExp(`\\.${U}([^\\w-]|$)`,"g"),`.${_}$1`)}j.textContent=G}let z=(j)=>{for(let G of j.getAttributeNames()){let F=j.getAttribute(G);if(F&&F.includes("url(#")){for(let[_,U]of K){let M=q(_);F=F.replace(new RegExp(`url\\(#${M}\\)`,"g"),`url(#${U})`)}j.setAttribute(G,F)}if((G==="href"||G==="xlink:href")&&F?.startsWith("#")){let _=F.substring(1);if(K.has(_))j.setAttribute(G,`#${K.get(_)}`)}if(G==="begin"||G==="end"){for(let[_,U]of K){let M=q(_);F=F.replace(new RegExp(`(^|;|\\s)${M}\\.`,"g"),`$1${U}.`)}j.setAttribute(G,F)}if(G==="values"||G==="from"||G==="to"||G==="by"){for(let[_,U]of K){let M=q(_);F=F.replace(new RegExp(`#${M}([;\\s]|$)`,"g"),`#${U}$1`)}j.setAttribute(G,F)}}for(let G of j.children)if(a(G))z(G)};return z($),$}),dZ=F0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),pZ=F0(($,J={})=>{let Z=J.selector||"*",K=J.attributes||[];try{let Q=$.querySelectorAll(Z);for(let q of Q)for(let H of K)if(q.hasAttribute(H))q.removeAttribute(H)}catch(Q){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Q.message}`)}return $}),cZ=F0(($,J={})=>{let Z=J.pattern?new RegExp(J.pattern):null,K=J.attrs||[],Q=(q)=>{for(let H of[...q.getAttributeNames()])if(K.includes(H)||Z&&Z.test(H))q.removeAttribute(H);for(let H of q.children)if(a(H))Q(H)};return Q($),$}),nZ=F0(($,J={})=>{let{name:Z,value:K}=J;if(!Z)return $;let Q=(q)=>{for(let H of[...q.children]){if(!a(H))continue;let W=H.getAttribute(Z);if(K===void 0){if(W!==null){q.removeChild(H);continue}}else if(W===K){q.removeChild(H);continue}Q(H)}};return Q($),$}),NJ=F0(async($,J={})=>{let Z={...J,outputFormat:M7.DOM_ELEMENT},K=$;return K=await J9(K,Z),K=await $9(K,Z),K=await e6(K,Z),K=await t6(K,Z),K=await a6(K,Z),K=await Z9(K,Z),K=await RJ(K,Z),K=await LJ(K,Z),K=await wJ(K,Z),K=await BJ(K,Z),K}),IJ=F0(($,J={})=>{return $}),lZ=F0(async($,J={})=>{let Z=J.preset||"default",K={...J,outputFormat:M7.DOM_ELEMENT};switch(Z){case"default":return await NJ($,K);case"none":return await IJ($,K);default:return $}}),sZ=F0(async($,J={})=>{let Z=J.config||{},K={...J,outputFormat:M7.DOM_ELEMENT},Q=$;if(Z.removeMetadata!==!1)Q=await J9(Q,K);if(Z.removeComments!==!1)Q=await $9(Q,K);if(Z.cleanupNumericValues!==!1)Q=await a6(Q,K);if(Z.convertColors!==!1)Q=await Z9(Q,K);if(Z.removeHiddenElements!==!1)Q=await t6(Q,K);if(Z.removeEmptyContainers!==!1)Q=await e6(Q,K);return Q});function oZ($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var iZ=F0(async($,J={})=>{let Z=K7($,{minify:J.minify!==!1}),K=await f$(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),rZ=F0(async($,J={})=>{let Z=K7($,{minify:J.minify!==!1}),K=await f$(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),aZ=F0(($,J={})=>{let Z=h7($),K=(j)=>{let G=Z.get(j);if(!G)return null;let F=G.getAttribute("href")||G.getAttribute("xlink:href");return F?.startsWith("#")?F.substring(1):null},Q=(j,G)=>{let F=j.getAttribute("gradientUnits")||"objectBoundingBox",_=j.getAttribute("gradientTransform");if(AW(G,K)){if(J.verbose)console.warn(`Circular gradient reference detected: #${G}`);return!1}if(F==="userSpaceOnUse")return!1;if(_)return!1;return!0},q=E7($,"fill");for(let j of q){let G=j.getAttribute("fill");if(G&&G.includes("url(")){let F=y7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let M=t5(_,J.position||0.5);j.setAttribute("fill",M)}}else j.setAttribute("fill",J.fallbackColor||"#808080")}}let H=E7($,"stroke");for(let j of H){let G=j.getAttribute("stroke");if(G&&G.includes("url(")){let F=y7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let M=t5(_,J.position||0.5);j.setAttribute("stroke",M)}}else j.setAttribute("stroke",J.fallbackColor||"#808080")}}let W=[...$.querySelectorAll("linearGradient, radialGradient")],z=(j)=>j.replace(/["\\]/g,"\\$&");for(let j of W){let G=j.getAttribute("id"),F=G?z(G):"";if(!(G&&([...$.querySelectorAll(`[fill*="url(#${F})"]`)].length>0||[...$.querySelectorAll(`[stroke*="url(#${F})"]`)].length>0))&&j.parentNode)j.parentNode.removeChild(j)}return $});function t5($,J=0.5){let Z=[...$.children].filter((W)=>W.tagName&&W.tagName.toLowerCase()==="stop");if(Z.length===0)return"#808080";if(Z.length===1)return e5(Z[0]);let K=Z.map((W)=>{let z=W.getAttribute("offset")||"0";if(z.endsWith("%"))z=parseFloat(z)/100;else z=parseFloat(z);return z=isNaN(z)?0:Math.max(0,Math.min(1,z)),{offset:z,color:e5(W),opacity:TW(W)}});K.sort((W,z)=>W.offset-z.offset);let Q=null,q=null;for(let W=0;W<K.length;W++){let z=K[W];if(z.offset<=J)Q=z;if(z.offset>=J&&!q){q=z;break}}if(!Q)return K[0].color;if(!q)return K[K.length-1].color;if(Q.offset===q.offset)return Q.color;let H=(J-Q.offset)/(q.offset-Q.offset);return fW(Q.color,q.color,H)}function e5($){let J=$.getAttribute("stop-color");if(!J){let Z=$.getAttribute("style");if(Z){let K=Z.match(/stop-color\s*:\s*([^;]+)/i);if(K)J=K[1].trim()}}if(!J)J="#000000";return bW(J)}function TW($){let J=$.getAttribute("stop-opacity");if(!J){let K=$.getAttribute("style");if(K){let Q=K.match(/stop-opacity\s*:\s*([^;]+)/i);if(Q)J=Q[1].trim()}}let Z=J?parseFloat(J):1;return isNaN(Z)?1:Z}function bW($){if(!$||typeof $!=="string")return"#000000";let J=$.trim().toLowerCase();if(J.startsWith("#")){if(J.length===4)return"#"+J[1]+J[1]+J[2]+J[2]+J[3]+J[3];return J}if(J.startsWith("rgb(")){let K=J.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(K){let Q=parseInt(K[1],10),q=parseInt(K[2],10),H=parseInt(K[3],10);return tZ(Q,q,H)}}let Z={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",olive:"#808000",lime:"#00ff00",aqua:"#00ffff",teal:"#008080",navy:"#000080",fuchsia:"#ff00ff",purple:"#800080"};if(Z[J])return Z[J];return"#000000"}function fW($,J,Z){let K=(U)=>{let M=U.replace("#","");if(M.length===3)M=M[0]+M[0]+M[1]+M[1]+M[2]+M[2];let V=parseInt(M.slice(0,2),16),Y=parseInt(M.slice(2,4),16),X=parseInt(M.slice(4,6),16);if(isNaN(V)||isNaN(Y)||isNaN(X))return[0,0,0];return[V,Y,X]},[Q,q,H]=K($),[W,z,j]=K(J),G=Math.round(Q+(W-Q)*Z),F=Math.round(q+(z-q)*Z),_=Math.round(H+(j-H)*Z);return tZ(G,F,_)}function tZ($,J,Z){let K=(Q)=>{return Math.max(0,Math.min(255,Math.round(Q))).toString(16).padStart(2,"0")};return"#"+K($)+K(J)+K(Z)}var eZ=F0(async($,J={})=>{let Z=K7($,{minify:J.minify!==!1}),K=await f$(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),$K=F0(($,J={})=>{let Z=(Q)=>{if(Q.hasAttribute("filter"))Q.removeAttribute("filter");for(let q of Q.children)if(a(q))Z(q)};Z($);let K=$.getElementsByTagName("filter");for(let Q of[...K])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),JK=F0(async($,J={})=>{let Z=K7($,{minify:J.minify!==!1}),K=await f$(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),ZK=F0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let K of[...Z])K.setAttribute("data-trace-needed","true");return $}),KK=F0(($,J={})=>{let{samples:Z=10,includeStroke:K=!0,includeFillOnly:Q=!1}=J,q=[...$.getElementsByTagName("path"),...$.getElementsByTagName("rect"),...$.getElementsByTagName("circle"),...$.getElementsByTagName("ellipse")],H=h7($),W=[];for(let z=0;z<q.length;z++)for(let j=z+1;j<q.length;j++){let G=q[z],F=q[j],_=i6(G,Z),U=i6(F,Z);if(!_||!U)continue;let M=i$(G),V=i$(F),Y=o$(G,M,H),X=o$(F,V,H);if(K&&!Q){if(Y.hasStroke){let w=Y.getStrokeExtent().toNumber();_=$Z(_,w)}if(X.hasStroke){let w=X.getStrokeExtent().toNumber();U=$Z(U,w)}}if(R6(_,U).overlaps)W.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:Y.hasStroke?Y.strokeWidth.toNumber():0,stroke2:X.hasStroke?X.strokeWidth.toNumber():0,fillRule1:Y.fillRule,fillRule2:X.fillRule})}if(W.length>0)$.setAttribute("data-collisions",JSON.stringify(W));return $});function $Z($,J){if(J<=0||!$||$.length===0)return $;let Z=0,K=0;for(let Q of $)Z+=Q.x,K+=Q.y;return Z/=$.length,K/=$.length,$.map((Q)=>{let q=Q.x-Z,H=Q.y-K,W=Math.sqrt(q*q+H*H);if(W<0.0001)return Q;let z=(W+J)/W;return{x:Z+q*z,y:K+H*z}})}var QK=F0(($,J={})=>{let{id1:Z,id2:K}=J;if(!Z||!K)return $;let Q=$.getElementById(Z),q=$.getElementById(K);if(!Q||!q)return $;let H=i6(Q,J.samples||10),W=i6(q,J.samples||10);if(H&&W){let z=X8(H,W);$.setAttribute("data-distance",z.distance.toString())}return $}),qK=F0(($,J={})=>{let Z=[],K=[],Q=new Set,q=new Set,H=(z)=>{if(z.tagName.includes(":")){let j=z.tagName.split(":")[0];Q.add(j)}for(let j of z.getAttributeNames()){let G=z.getAttribute(j);if(j==="xmlns")q.add("");else if(j.startsWith("xmlns:")){let F=j.substring(6);q.add(F)}if(j.includes(":")&&!j.startsWith("xmlns:")){let F=j.split(":")[0];Q.add(F)}if(G&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(G))Z.push(`Invalid XML characters in attribute '${j}' of <${z.tagName}>`)}if(z.textContent&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(z.textContent))Z.push(`Invalid XML characters in text content of <${z.tagName}>`);for(let j of z.children)if(a(j))H(j)};H($);for(let z of Q)if(z&&!q.has(z))Z.push(`Unbound namespace prefix: '${z}' - SVGO would produce invalid XML here`);let W={valid:Z.length===0,errors:Z,warnings:K,namespacesUsed:[...Q],namespacesDeclared:[...q]};return $.setAttribute("data-xml-validation",JSON.stringify(W)),$}),HK=F0(($,J={})=>{let Z=[],K=[],Q=J.version||"1.1";if($.tagName!=="svg")Z.push("Root element must be <svg>");let q=$.getAttribute("xmlns");if(!q)K.push("Missing xmlns attribute (required for standalone SVG)");else if(q!=="http://www.w3.org/2000/svg")Z.push(`Invalid SVG namespace: expected 'http://www.w3.org/2000/svg', got '${q}'`);let H=$.getAttribute("viewBox");if(H){let F=H.split(/[\s,]+/);if(F.length!==4)Z.push(`Invalid viewBox: expected 4 values, got ${F.length}`);else if(F.some((_)=>isNaN(parseFloat(_))))Z.push("Invalid viewBox: contains non-numeric values");else{let[_,U,M,V]=F.map(parseFloat);if(M<0||V<0)Z.push("Invalid viewBox: width and height must be non-negative")}}let W={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},z={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},j=(F,_=0)=>{if(!F||!F.tagName){K.push(`Element at depth ${_} has no tagName property`);return}let U=F.tagName.toLowerCase(),M=F.tagName;if(z[M])Z.push(`Invalid SVG 2.0 element: <${M}> must be lowercase <${z[M]}> per SVG 2.0 specification`);if(U==="meshgradient"){let V=F.getAttribute("id");if(W.meshGradients.push(V||null),W.needsPolyfills=!0,!V)K.push("<meshgradient> element without 'id' attribute may be difficult to reference")}if(U==="hatch"){let V=F.getAttribute("id");if(W.hatches.push(V||null),W.needsPolyfills=!0,!V)K.push("<hatch> element without 'id' attribute may be difficult to reference")}if(U==="solidcolor"){let V=F.getAttribute("id");if(W.solidColors.push(V||null),W.needsPolyfills=!0,!V)K.push("<solidcolor> element without 'id' attribute may be difficult to reference")}if(U==="path"){let V=F.getAttribute("d");if(!V||!V.trim())Z.push("<path> element missing required 'd' attribute");else{let Y=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!Y||Y.length===0)Z.push("<path> 'd' attribute contains no valid commands");let X=V.trim()[0];if(X!=="M"&&X!=="m")Z.push("<path> 'd' must start with M or m command")}}if(U==="rect"){let V=F.getAttribute("width"),Y=F.getAttribute("height");if(V!==null&&!o7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(Y!==null&&!o7(Y)&&parseFloat(Y)<0)Z.push("<rect> height must be non-negative")}if(U==="circle"){let V=F.getAttribute("r");if(V!==null&&parseFloat(V)<0)Z.push("<circle> r must be non-negative")}if(U==="ellipse"){let V=F.getAttribute("rx"),Y=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(Y!==null&&parseFloat(Y)<0)Z.push("<ellipse> ry must be non-negative")}if(U==="use"){let V=F.getAttribute("href")||F.getAttribute("xlink:href");if(V&&V.startsWith("#")){let Y=V.substring(1);if(!$.getElementById(Y))K.push(`<use> references non-existent ID: '${Y}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let Y=F.getAttribute(V);if(Y&&Y.startsWith("url(#")){let X=Y.match(/url\(#([^)]+)\)/);if(X){let k=X[1];if(!$.getElementById(k))K.push(`<${F.tagName}> ${V} references non-existent ID: '${k}'`)}}}if(J6[U]){let V=J6[U];for(let Y of F.children)if(a(Y)){let X=Y.tagName.toLowerCase();if(!V.has(X))K.push(`<${X}> is not a standard child of <${U}>`)}}for(let V of F.children)if(a(V))j(V,_+1)};if(j($),W.needsPolyfills){let F=[];if(W.meshGradients.length>0)F.push(`meshgradient (${W.meshGradients.length} found)`);if(W.hatches.length>0)F.push(`hatch (${W.hatches.length} found)`);if(W.solidColors.length>0)F.push(`solidcolor (${W.solidColors.length} found)`);K.push(`SVG contains SVG 2.0 features that require polyfills for browser compatibility: ${F.join(", ")}. Use --svg2-polyfills option to inject runtime polyfills.`)}let G={valid:Z.length===0,svgVersion:Q,errors:Z,warnings:K,elementsChecked:jK($),svg2Features:W};if($.setAttribute("data-svg-validation",JSON.stringify(G)),Z.length>0)$.setAttribute("data-validation-errors",JSON.stringify(Z));else $.setAttribute("data-validation-status","valid");return $}),SW=new Set(["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout","keydown","keyup","keypress","activate","load","unload","abort","error","resize","scroll","beginEvent","endEvent","repeatEvent","touchstart","touchend","touchmove","touchcancel","wheel","auxclick","input","beforeinput","select","compositionstart","compositionupdate","compositionend"]),vW=F0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q={valid:!0,timestamp:new Date().toISOString(),media:{hasAudio:!1,hasVideo:!1,audioElements:[],videoElements:[],foreignObjectWithMedia:[],mediaEmbedMethod:null},smil:{hasAnimations:!1,animationCount:0,animationElements:{animate:0,animateTransform:0,animateMotion:0,animateColor:0,set:0},hasInteractiveAnimations:!1,eventTriggers:[],timingTriggers:[]},compatibility:{worksInAllBrowsers:!0,issues:[],recommendations:[]},errors:[],warnings:[],info:[]},q=(V)=>{let Y=[],X=V.toLowerCase(),k=(w)=>{if(w.tagName&&w.tagName.toLowerCase()===X)Y.push(w);for(let R of w.children||[])if(R&&R.tagName)k(R)};return k($),Y},H=(V,Y=[])=>{if(V.tagName)Y.push(V);for(let X of V.children||[])if(X&&X.tagName)H(X,Y);return Y},W=q("audio");if(W.length>0)Q.media.hasAudio=!0,Q.media.audioElements=W.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src"),hasSource:q("source").filter((Y)=>Y.parentNode===V).length>0}));let z=q("video");if(z.length>0)Q.media.hasVideo=!0,Q.media.videoElements=z.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src")}));let j=q("foreignObject");for(let V of j){let Y=V.children||[],X=!1,k=[],w=(R)=>{let I=R.tagName?.toLowerCase();if(I==="audio"||I==="video")X=!0,k.push({type:I,id:R.getAttribute("id"),src:R.getAttribute("src")});for(let P of R.children||[])if(P&&P.tagName)w(P)};for(let R of Y)if(R&&R.tagName)w(R);if(X)Q.media.hasAudio=!0,Q.media.foreignObjectWithMedia.push({id:V.getAttribute("id"),media:k}),Q.media.mediaEmbedMethod="foreignObject"}let G=H($);for(let V of G)for(let Y of["src","href","xlink:href"]){let X=V.getAttribute(Y);if(X&&X.startsWith("data:audio/"))Q.media.hasAudio=!0,Q.media.mediaEmbedMethod="data-uri";if(X&&X.startsWith("data:video/"))Q.media.hasVideo=!0,Q.media.mediaEmbedMethod="data-uri"}let F=["animate","animateTransform","animateMotion","animateColor","set"];for(let V of F){let Y=q(V),X=Y.length;Q.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=X,Q.smil.animationCount+=X;for(let k of Y){let w=k.getAttribute("begin")||"",R=k.getAttribute("end")||"",I=(g,b)=>{let h=g.split(";").map((v)=>v.trim()).filter(Boolean);for(let v of h){let E=v.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(E){let[,m,c,d]=E;if(SW.has(c))Q.smil.hasInteractiveAnimations=!0,Q.smil.eventTriggers.push({animationElement:V,animationId:k.getAttribute("id"),attribute:b,event:c,targetId:m||null,offset:d?.trim()||null,parentId:k.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(v)||v==="indefinite")Q.smil.timingTriggers.push({animationElement:V,value:v});else if(/\.(begin|end)/.test(v))Q.smil.timingTriggers.push({animationElement:V,value:v,type:"syncbase"})}};if(w)I(w,"begin");if(R)I(R,"end");let P=k.getAttribute("onbegin"),u=k.getAttribute("onend");if(P||u){if(Q.smil.hasInteractiveAnimations=!0,P?.includes("play()")||u?.includes("play()"))Q.info.push(`Animation uses JavaScript to trigger audio playback via ${P?"onbegin":"onend"} handler`)}}}if(Q.smil.hasAnimations=Q.smil.animationCount>0,Q.media.hasAudio)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded audio. Browser autoplay policies will block playback in most scenarios."),Q.compatibility.issues.push({type:"AUDIO_AUTOPLAY_BLOCKED",severity:"HIGH",description:"Embedded audio in SVG is blocked by Chrome/Firefox/Safari autoplay policies",affectedBrowsers:["Chrome","Firefox","Safari","Edge"]}),Q.compatibility.recommendations.push("To enable audio playback, embed the SVG in an HTML page that extracts audio dynamically after user interaction","Use JavaScript to extract audio data URI from foreignObject and create Audio element on click","Consider using Web Audio API for more control over audio playback");if(Q.media.hasVideo)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded video. This has limited browser support and autoplay restrictions.");if(Q.smil.hasAnimations)Q.info.push(`SVG contains ${Q.smil.animationCount} SMIL animation elements`),Q.compatibility.issues.push({type:"SMIL_IE_UNSUPPORTED",severity:"LOW",description:"SMIL animations are not supported in IE11",affectedBrowsers:["IE (no support)"]});if(Q.smil.hasInteractiveAnimations){let V=[...new Set(Q.smil.eventTriggers.map((Y)=>Y.event))];if(Q.info.push(`SVG contains interactive SMIL animations triggered by: ${V.join(", ")}`),V.includes("click")||V.includes("mouseover"))Q.compatibility.recommendations.push("Interactive animations (click/hover) work in most browsers but require the SVG to be inline or loaded as <object>/<embed>","Using <img> tag to display SVG will disable all interactivity and animations")}let _={Chrome:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Autoplay blocked without user gesture"},Firefox:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"MEI (Media Engagement Index) affects autoplay"},Safari:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Strict autoplay policy"},Edge:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Chromium-based, same as Chrome"},"IE 11":{smil:"No support",audio:"No support",interactive:"No support",notes:"Use CSS animations or JavaScript"}},U=[{scenario:"Standalone SVG",protocol:"file://",example:"file:///path/to/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"Standalone SVG",protocol:"http://",example:"http://localhost/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"SVG in HTML via <img>",protocol:"any",example:'<img src="sample.svg">',smilWorks:!1,audioWorks:!1,interactiveWorks:!1,notes:"All scripting and interactivity disabled"},{scenario:"SVG in HTML via <object>",protocol:"any",example:'<object data="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"SVG in HTML via <embed>",protocol:"any",example:'<embed src="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"Inline SVG in HTML",protocol:"any",example:"<svg>...</svg> in HTML",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full features, audio needs user gesture"},{scenario:"HTML extracts audio on click",protocol:"file://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"},{scenario:"HTML extracts audio on click",protocol:"http://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"}],M=[{trigger:'begin="click"',description:"Animation starts on click (on animation target)",syntax:'<animate begin="click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Target element must be clickable (not in <defs>)"},{trigger:'begin="elementId.click"',description:"Animation starts when another element is clicked",syntax:'<animate begin="button.click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Referenced element must exist with matching id"},{trigger:'begin="mouseover"',description:"Animation starts on mouse hover",syntax:'<animate begin="mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Often paired with mouseout for hover effects"},{trigger:'begin="elementId.mouseover"',description:"Animation starts when hovering another element",syntax:'<animate begin="trigger.mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Useful for triggering animations on related elements"},{trigger:'begin="mouseout"',description:"Animation starts when mouse leaves",syntax:'<animate begin="mouseout" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Use with mouseover for complete hover cycle"},{trigger:'begin="focus"',description:"Animation starts when element receives focus",syntax:'<animate begin="focus" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Works with focusable elements (links, inputs)"},{trigger:'begin="accessKey(s)"',description:"Animation starts on keyboard shortcut",syntax:'<animate begin="accessKey(s)" .../>',browserSupport:"Limited",notes:"Press Alt+S (Windows) or Ctrl+Opt+S (Mac)"}];if(Q.tables={browserSupport:_,usageScenarios:U,smilEventScenarios:M},K&&(Q.media.hasAudio||Q.media.hasVideo||Q.smil.hasInteractiveAnimations)){if(console.log(`
|
|
21
21
|
`+"=".repeat(80)),console.log("SVG COMPATIBILITY ANALYSIS REPORT"),console.log("=".repeat(80)),console.log(`
|
|
22
|
-
--- SUMMARY ---`),console.log(`SMIL Animations: ${
|
|
22
|
+
--- SUMMARY ---`),console.log(`SMIL Animations: ${Q.smil.animationCount} (${Q.smil.hasInteractiveAnimations?"includes interactive":"time-based only"})`),console.log(`Audio Elements: ${Q.media.hasAudio?"YES":"NO"}`),console.log(`Video Elements: ${Q.media.hasVideo?"YES":"NO"}`),Q.media.hasAudio)console.log(`
|
|
23
23
|
--- AUDIO PLAYBACK WARNING ---`),console.log("This SVG contains embedded audio which will be BLOCKED by browser autoplay policies."),console.log("Audio will NOT play automatically in any browser without user interaction.");console.log(`
|
|
24
|
-
--- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[
|
|
25
|
-
--- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let
|
|
26
|
-
--- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let
|
|
27
|
-
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let
|
|
28
|
-
--- RECOMMENDATIONS ---`);for(let
|
|
24
|
+
--- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[V,Y]of Object.entries(_)){let X=V.padEnd(11),k=Y.smil.padEnd(18),w=Y.audio.padEnd(24),R=Y.interactive.padEnd(11);console.log(`│ ${X} │ ${k} │ ${w} │ ${R} │`)}console.log("└─────────────┴────────────────────┴──────────────────────────┴─────────────┘"),console.log(`
|
|
25
|
+
--- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let Y=V.scenario.substring(0,30).padEnd(30),X=V.protocol.padEnd(9),k=(V.smilWorks?"✅":"❌").padEnd(5),w=(V.audioWorks?"✅":"❌").padEnd(5),R=(V.interactiveWorks?"✅":"❌").padEnd(11);console.log(`│ ${Y} │ ${X} │ ${k} │ ${w} │ ${R} │`)}if(console.log("└────────────────────────────────┴───────────┴───────┴───────┴─────────────┘"),Q.smil.hasInteractiveAnimations){console.log(`
|
|
26
|
+
--- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of M){let Y=V.trigger.padEnd(29),X=V.description.substring(0,42).padEnd(42);console.log(`│ ${Y} │ ${X} │`)}if(console.log("└───────────────────────────────┴────────────────────────────────────────────┘"),Q.smil.eventTriggers.length>0){console.log(`
|
|
27
|
+
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of Q.smil.eventTriggers){let Y=V.targetId?`${V.targetId}.${V.event}`:V.event;console.log(` - <${V.animationElement}> triggered by: ${Y}${V.offset?` ${V.offset}`:""}`)}}}if(Q.compatibility.recommendations.length>0){console.log(`
|
|
28
|
+
--- RECOMMENDATIONS ---`);for(let V of Q.compatibility.recommendations)console.log(` • ${V}`)}console.log(`
|
|
29
29
|
`+"=".repeat(80)+`
|
|
30
|
-
`)}return r.valid=r.errors.length===0,t.setAttribute("data-compatibility-report",JSON.stringify({hasAudio:r.media.hasAudio,hasVideo:r.media.hasVideo,smilCount:r.smil.animationCount,hasInteractive:r.smil.hasInteractiveAnimations,issues:r.compatibility.issues.length})),t._compatibilityReport=r,t}),N5={RENDER_VECTORS:{cat:"display",name:"Vector paths/shapes",critical:!0},RENDER_TEXT:{cat:"display",name:"Text rendering",critical:!0},RENDER_GRADIENTS:{cat:"display",name:"Gradients (linear/radial)",critical:!1},RENDER_PATTERNS:{cat:"display",name:"Pattern fills",critical:!1},RENDER_OPACITY:{cat:"display",name:"Opacity/transparency",critical:!1},RENDER_BLENDMODES:{cat:"display",name:"Blend modes",critical:!1},RENDER_TRANSFORMS:{cat:"display",name:"Transforms",critical:!0},FONTS_EMBEDDED:{cat:"fonts",name:"Embedded fonts (data-uri)",critical:!1},FONTS_SYSTEM:{cat:"fonts",name:"System fonts",critical:!1},FONTS_WEB_SAME:{cat:"fonts",name:"Web fonts (same-origin)",critical:!1},FONTS_WEB_CROSS:{cat:"fonts",name:"Web fonts (cross-origin)",critical:!1},IMAGES_EMBEDDED:{cat:"images",name:"Embedded images (data-uri)",critical:!1},IMAGES_LOCAL:{cat:"images",name:"Local images",critical:!1},IMAGES_REMOTE_SAME:{cat:"images",name:"Remote images (same-origin)",critical:!1},IMAGES_REMOTE_CROSS:{cat:"images",name:"Remote images (cross-origin)",critical:!1},FILTERS_BASIC:{cat:"effects",name:"Basic filters (blur, shadow)",critical:!1},FILTERS_COMPLEX:{cat:"effects",name:"Complex filters (lighting, turbulence)",critical:!1},MASKS:{cat:"effects",name:"Mask elements",critical:!1},CLIP_PATHS:{cat:"effects",name:"Clip paths",critical:!1},SMIL_TIMED:{cat:"animation",name:"SMIL time-based animation",critical:!1},SMIL_CLICK:{cat:"animation",name:"SMIL click-triggered",critical:!1},SMIL_HOVER:{cat:"animation",name:"SMIL mouseover-triggered",critical:!1},SMIL_FOCUS:{cat:"animation",name:"SMIL focus-triggered",critical:!1},SMIL_ACCESSKEY:{cat:"animation",name:"SMIL accessKey-triggered",critical:!1},SMIL_SYNCBASE:{cat:"animation",name:"SMIL syncbase (anim.begin)",critical:!1},CSS_KEYFRAMES:{cat:"animation",name:"CSS @keyframes animation",critical:!1},CSS_TRANSITIONS:{cat:"animation",name:"CSS transitions",critical:!1},CSS_HOVER:{cat:"animation",name:"CSS :hover effects",critical:!1},SCRIPT_INLINE:{cat:"scripting",name:"Inline <script>",critical:!1},SCRIPT_EXTERNAL:{cat:"scripting",name:'External <script src="">',critical:!1},SCRIPT_MODULE:{cat:"scripting",name:"ES modules in SVG",critical:!1},EVENT_ONCLICK:{cat:"events",name:"onclick handler",critical:!1},EVENT_ONDBLCLICK:{cat:"events",name:"ondblclick handler",critical:!1},EVENT_ONMOUSEDOWN:{cat:"events",name:"onmousedown handler",critical:!1},EVENT_ONMOUSEUP:{cat:"events",name:"onmouseup handler",critical:!1},EVENT_ONMOUSEOVER:{cat:"events",name:"onmouseover handler",critical:!1},EVENT_ONMOUSEOUT:{cat:"events",name:"onmouseout handler",critical:!1},EVENT_ONMOUSEMOVE:{cat:"events",name:"onmousemove handler",critical:!1},EVENT_ONFOCUS:{cat:"events",name:"onfocus handler",critical:!1},EVENT_ONBLUR:{cat:"events",name:"onblur handler",critical:!1},EVENT_ONLOAD:{cat:"events",name:"onload handler",critical:!1},EVENT_ONERROR:{cat:"events",name:"onerror handler",critical:!1},EVENT_ONSCROLL:{cat:"events",name:"onscroll handler",critical:!1},EVENT_ONWHEEL:{cat:"events",name:"onwheel handler",critical:!1},EVENT_ONTOUCH:{cat:"events",name:"touch events",critical:!1},EVENT_ONKEYBOARD:{cat:"events",name:"keyboard events",critical:!1},LINK_INTERNAL:{cat:"links",name:"Internal anchor links",critical:!1},LINK_EXTERNAL:{cat:"links",name:"External hyperlinks",critical:!1},LINK_TARGET:{cat:"links",name:"Link target attribute",critical:!1},LINK_DOWNLOAD:{cat:"links",name:"Download attribute",critical:!1},FOREIGNOBJECT_BASIC:{cat:"html",name:"foreignObject rendering",critical:!1},FOREIGNOBJECT_HTML:{cat:"html",name:"HTML in foreignObject",critical:!1},FOREIGNOBJECT_FORM:{cat:"html",name:"Forms in foreignObject",critical:!1},FOREIGNOBJECT_INPUT:{cat:"html",name:"Input elements in foreignObject",critical:!1},FOREIGNOBJECT_CANVAS:{cat:"html",name:"Canvas in foreignObject",critical:!1},FOREIGNOBJECT_VIDEO:{cat:"html",name:"Video in foreignObject",critical:!1},FOREIGNOBJECT_IFRAME:{cat:"html",name:"iframe in foreignObject",critical:!1},AUDIO_EMBEDDED:{cat:"media",name:"Embedded audio (data-uri)",critical:!1},AUDIO_LOCAL:{cat:"media",name:"Local audio files",critical:!1},AUDIO_REMOTE:{cat:"media",name:"Remote audio files",critical:!1},AUDIO_AUTOPLAY:{cat:"media",name:"Audio autoplay",critical:!1},AUDIO_CONTROLS:{cat:"media",name:"Audio controls visible",critical:!1},VIDEO_EMBEDDED:{cat:"media",name:"Embedded video (data-uri)",critical:!1},VIDEO_LOCAL:{cat:"media",name:"Local video files",critical:!1},VIDEO_REMOTE:{cat:"media",name:"Remote video files",critical:!1},VIDEO_AUTOPLAY:{cat:"media",name:"Video autoplay",critical:!1},USE_INTERNAL:{cat:"sprites",name:"Internal <use> references",critical:!1},USE_EXTERNAL_SAME:{cat:"sprites",name:"External <use> (same-origin)",critical:!1},USE_EXTERNAL_CROSS:{cat:"sprites",name:"External <use> (cross-origin)",critical:!1},USE_SHADOW_DOM:{cat:"sprites",name:"Shadow DOM styling of <use>",critical:!1},MAP_BASIC:{cat:"maps",name:"SVG as image map",critical:!1},MAP_COORDS:{cat:"maps",name:"Clickable regions",critical:!1},A11Y_ARIA:{cat:"accessibility",name:"ARIA attributes",critical:!1},A11Y_ROLE:{cat:"accessibility",name:"Role attributes",critical:!1},A11Y_TITLE:{cat:"accessibility",name:"Title/desc for screen readers",critical:!1},A11Y_TABINDEX:{cat:"accessibility",name:"Tab navigation",critical:!1},META_DATA_ATTRS:{cat:"metadata",name:"data-* attributes",critical:!1},META_CLASS:{cat:"metadata",name:"class attribute styling",critical:!1},META_ID:{cat:"metadata",name:"id references",critical:!0},EXT_CSS_LINK:{cat:"external",name:"External CSS via <?xml-stylesheet?>",critical:!1},EXT_CSS_IMPORT:{cat:"external",name:"@import in <style>",critical:!1},EXT_XLINK:{cat:"external",name:"xlink:href references",critical:!1}},bo={STANDALONE_BROWSER:{id:"standalone-browser",name:"Standalone (Browser)",type:"browser"},HTML_PAGE:{id:"html-page",name:"HTML Page",type:"browser"},ELECTRON:{id:"electron",name:"Electron App",type:"browser"},WEBVIEW_IOS:{id:"webview-ios",name:"iOS WKWebView",type:"mobile"},WEBVIEW_ANDROID:{id:"webview-android",name:"Android WebView",type:"mobile"},CAIRO:{id:"cairo",name:"Cairo/librsvg",type:"renderer"},INKSCAPE:{id:"inkscape",name:"Inkscape",type:"renderer"},IMAGEMAGICK:{id:"imagemagick",name:"ImageMagick",type:"renderer"},BATIK:{id:"batik",name:"Apache Batik",type:"renderer"},RESVG:{id:"resvg",name:"resvg",type:"renderer"},QT_SVG:{id:"qt-svg",name:"Qt SVG",type:"renderer"},SKIA:{id:"skia",name:"Skia (Chrome/Flutter)",type:"renderer"}},Po={FILE:{id:"file",name:"file://",protocol:"file"},HTTP:{id:"http",name:"http://",protocol:"http"},HTTPS:{id:"https",name:"https://",protocol:"https"},DATA_URI:{id:"data-uri",name:"data: URI",protocol:"data"},BLOB_URL:{id:"blob-url",name:"blob: URL",protocol:"blob"}},So={INLINE:{id:"inline",name:"Inline in HTML",location:"inline"},BASE64:{id:"base64",name:"Base64 encoded",location:"embedded"},LOCAL_SAME:{id:"local-same",name:"Local (same dir)",location:"local"},LOCAL_ABS:{id:"local-abs",name:"Local (absolute)",location:"local"},REMOTE_SAME:{id:"remote-same",name:"Remote (same-origin)",location:"remote"},REMOTE_CROSS:{id:"remote-cross",name:"Remote (cross-origin)",location:"cross"},REMOTE_CORS:{id:"remote-cors",name:"Remote (cross+CORS)",location:"cors"}},et={DIRECT:{id:"direct",name:"Direct SVG file",html:!1},IMG:{id:"img",name:'<img src="">',html:!0},PICTURE:{id:"picture",name:"<picture><source>",html:!0},OBJECT:{id:"object",name:'<object data="">',html:!0},EMBED:{id:"embed",name:'<embed src="">',html:!0},IFRAME:{id:"iframe",name:'<iframe src="">',html:!0},INLINE_SVG:{id:"inline-svg",name:"<svg>...</svg>",html:!0},CSS_BG:{id:"css-bg",name:"CSS background-image",html:!0},CSS_MASK:{id:"css-mask",name:"CSS mask-image",html:!0},CSS_CONTENT:{id:"css-content",name:"CSS content: url()",html:!0},CSS_LIST:{id:"css-list",name:"CSS list-style-image",html:!0},CSS_BORDER:{id:"css-border",name:"CSS border-image",html:!0},CANVAS_DRAW:{id:"canvas-draw",name:"canvas.drawImage()",html:!0},SCRIPT_INNER:{id:"script-inner",name:"innerHTML assignment",html:!0},SCRIPT_DOM:{id:"script-dom",name:"DOM createElement",html:!0},SCRIPT_FETCH:{id:"script-fetch",name:"fetch + parse",html:!0}},To={NA:{id:"n/a",name:"N/A (not script)",script:!1},INLINE_SCRIPT:{id:"inline-script",name:"Inline <script>",script:!0},SAME_ORIGIN:{id:"same-origin",name:"Same-origin script",script:!0},CROSS_CORS:{id:"cross-cors",name:"Cross-origin (CORS)",script:!0},CROSS_NO_CORS:{id:"cross-no-cors",name:"Cross-origin (no CORS)",script:!0}},it={CHROME:{id:"chrome",name:"Chrome",engine:"blink"},FIREFOX:{id:"firefox",name:"Firefox",engine:"gecko"},SAFARI:{id:"safari",name:"Safari",engine:"webkit"},EDGE:{id:"edge",name:"Edge",engine:"blink"},IE11:{id:"ie11",name:"IE 11",engine:"trident"},SAFARI_IOS:{id:"safari-ios",name:"Safari iOS",engine:"webkit"},CHROME_ANDROID:{id:"chrome-android",name:"Chrome Android",engine:"blink"},SAMSUNG:{id:"samsung",name:"Samsung Internet",engine:"blink"}},b={WORKS:"✅",PARTIAL:"⚠️",BLOCKED:"❌",DEPENDS:"❓",NA:"➖"},H0={RENDER_VECTORS:{default:b.WORKS,exceptions:{}},RENDER_TEXT:{default:b.WORKS,exceptions:{"renderer:imagemagick":{status:b.PARTIAL,note:"Font substitution may occur"},"renderer:batik":{status:b.PARTIAL,note:"Limited font support"}}},RENDER_GRADIENTS:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.PARTIAL,note:"Some gradient types unsupported"}}},RENDER_PATTERNS:{default:b.WORKS,exceptions:{"renderer:resvg":{status:b.PARTIAL,note:"Limited pattern support"}}},RENDER_OPACITY:{default:b.WORKS,exceptions:{}},RENDER_BLENDMODES:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No blend mode support"},"renderer:cairo":{status:b.PARTIAL,note:"Limited blend modes"}}},FONTS_EMBEDDED:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No embedded fonts in img context",browsers:"all"},"syntax:css-bg":{status:b.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"syntax:css-mask":{status:b.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"renderer:imagemagick":{status:b.BLOCKED,note:"Cannot process embedded fonts"}}},FONTS_SYSTEM:{default:b.WORKS,exceptions:{}},FONTS_WEB_SAME:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources in img"},"syntax:css-bg":{status:b.BLOCKED,note:"No external resources in CSS bg"},"load:file":{status:b.PARTIAL,note:"May fail due to local file restrictions"},"renderer:*":{status:b.BLOCKED,note:"Renderers cannot fetch web fonts"}}},FONTS_WEB_CROSS:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources"},"syntax:css-*":{status:b.BLOCKED,note:"No external resources in CSS"},"storage:remote-cors":{status:b.WORKS,note:"Works with CORS headers"},"renderer:*":{status:b.BLOCKED,note:"Renderers cannot fetch fonts"}}},IMAGES_EMBEDDED:{default:b.WORKS,exceptions:{}},IMAGES_LOCAL:{default:b.WORKS,exceptions:{"load:http":{status:b.BLOCKED,note:"Cannot load file:// from http://"},"load:https":{status:b.BLOCKED,note:"Cannot load file:// from https://"},"syntax:img":{status:b.BLOCKED,note:"No external resources in img"}}},IMAGES_REMOTE_SAME:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources in img"},"load:file":{status:b.BLOCKED,note:"Cannot fetch http from file://"}}},IMAGES_REMOTE_CROSS:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources in img"},"storage:remote-cors":{status:b.WORKS,note:"Works with CORS"},"load:file":{status:b.BLOCKED,note:"CORS not applicable"}}},FILTERS_BASIC:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.PARTIAL,note:"Limited filter support"}}},FILTERS_COMPLEX:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"Complex filters unsupported"},"renderer:resvg":{status:b.PARTIAL,note:"Some filters unsupported"},"renderer:qt-svg":{status:b.PARTIAL,note:"Limited filter primitives"}}},MASKS:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"SVG masks not supported"}}},CLIP_PATHS:{default:b.WORKS,exceptions:{}},SMIL_TIMED:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"syntax:img":{status:b.PARTIAL,note:"May animate, no interaction",browsers:["chrome","firefox"]},"syntax:css-bg":{status:b.PARTIAL,note:"May animate, varies by browser"},"renderer:*":{status:b.BLOCKED,note:"Static render, no animation"}}},SMIL_CLICK:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"syntax:img":{status:b.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:b.BLOCKED,note:"No interaction in CSS context"},"syntax:canvas-draw":{status:b.BLOCKED,note:"Rasterized, no interaction"},"renderer:*":{status:b.BLOCKED,note:"No interaction in renderers"}}},SMIL_HOVER:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"syntax:img":{status:b.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:b.BLOCKED,note:"No interaction in CSS context"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},SMIL_FOCUS:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"syntax:img":{status:b.BLOCKED,note:"No interaction"},"syntax:css-*":{status:b.BLOCKED,note:"No interaction"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},SMIL_ACCESSKEY:{default:b.PARTIAL,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"browser:chrome":{status:b.PARTIAL,note:"Limited accessKey support"},"syntax:img":{status:b.BLOCKED,note:"No keyboard in img context"},"syntax:css-*":{status:b.BLOCKED,note:"No keyboard in CSS context"},"renderer:*":{status:b.BLOCKED,note:"No keyboard"}}},SMIL_SYNCBASE:{default:b.WORKS,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No SMIL support"},"syntax:img":{status:b.PARTIAL,note:"Sync works if animation plays"},"renderer:*":{status:b.BLOCKED,note:"No animation"}}},CSS_KEYFRAMES:{default:b.WORKS,exceptions:{"syntax:img":{status:b.WORKS,note:"CSS animations work in img"},"syntax:css-bg":{status:b.WORKS,note:"CSS animations work"},"renderer:*":{status:b.BLOCKED,note:"Static render"}}},CSS_TRANSITIONS:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No interaction for transitions"},"syntax:css-bg":{status:b.BLOCKED,note:"No interaction"},"renderer:*":{status:b.BLOCKED,note:"Static render"}}},CSS_HOVER:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No :hover in img context"},"syntax:css-*":{status:b.BLOCKED,note:"No :hover in CSS context"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},SCRIPT_INLINE:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"Scripts disabled for security"},"syntax:css-*":{status:b.BLOCKED,note:"Scripts disabled in CSS context"},"syntax:canvas-draw":{status:b.BLOCKED,note:"Rasterized, no scripts"},"renderer:*":{status:b.BLOCKED,note:"No script execution"},"display:html-page+syntax:inline-svg":{status:b.WORKS,note:"Runs in page context"},"display:html-page+syntax:object":{status:b.WORKS,note:"Isolated context"},"display:html-page+syntax:embed":{status:b.WORKS,note:"Isolated context"}}},SCRIPT_EXTERNAL:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources"},"syntax:css-*":{status:b.BLOCKED,note:"No external resources"},"load:file":{status:b.PARTIAL,note:"May be blocked by local file restrictions"},"storage:remote-cross":{status:b.BLOCKED,note:"CORS required"},"storage:remote-cors":{status:b.WORKS,note:"Works with CORS"},"renderer:*":{status:b.BLOCKED,note:"No scripts"}}},SCRIPT_MODULE:{default:b.PARTIAL,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No ES modules"},"browser:safari":{status:b.PARTIAL,note:"Limited module support in SVG"},"syntax:img":{status:b.BLOCKED,note:"No scripts"},"syntax:css-*":{status:b.BLOCKED,note:"No scripts"},"renderer:*":{status:b.BLOCKED,note:"No scripts"}}},EVENT_ONCLICK:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events in img context"},"syntax:css-*":{status:b.BLOCKED,note:"No events in CSS context"},"syntax:canvas-draw":{status:b.BLOCKED,note:"Rasterized"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONDBLCLICK:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONMOUSEDOWN:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONMOUSEUP:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOVER:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOUT:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONMOUSEMOVE:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONFOCUS:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:b.BLOCKED,note:"No focus"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONBLUR:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONLOAD:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No scripts/events"},"syntax:css-*":{status:b.BLOCKED,note:"No scripts"},"renderer:*":{status:b.BLOCKED,note:"No scripts"}}},EVENT_ONERROR:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No scripts"},"syntax:css-*":{status:b.BLOCKED,note:"No scripts"},"renderer:*":{status:b.BLOCKED,note:"No scripts"}}},EVENT_ONSCROLL:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No scroll in img"},"syntax:css-*":{status:b.BLOCKED,note:"No scroll"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONWHEEL:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONTOUCH:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No touch events"},"syntax:css-*":{status:b.BLOCKED,note:"No touch"},"display:*-browser":{status:b.NA,note:"No touch on desktop"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},EVENT_ONKEYBOARD:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No keyboard"},"syntax:css-*":{status:b.BLOCKED,note:"No keyboard"},"renderer:*":{status:b.BLOCKED,note:"No events"}}},LINK_INTERNAL:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No links in img"},"syntax:css-*":{status:b.BLOCKED,note:"No links in CSS"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},LINK_EXTERNAL:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No links in img"},"syntax:css-*":{status:b.BLOCKED,note:"No links"},"syntax:object":{status:b.WORKS,note:"Opens in object frame"},"renderer:*":{status:b.BLOCKED,note:"No links"}}},LINK_TARGET:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No links"},"syntax:css-*":{status:b.BLOCKED,note:"No links"},"syntax:object":{status:b.PARTIAL,note:"May not break out of frame"},"renderer:*":{status:b.BLOCKED,note:"No links"}}},LINK_DOWNLOAD:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No links"},"browser:safari":{status:b.PARTIAL,note:"Limited download attr support"},"renderer:*":{status:b.BLOCKED,note:"No links"}}},FOREIGNOBJECT_BASIC:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"foreignObject disabled in img"},"syntax:css-*":{status:b.BLOCKED,note:"foreignObject disabled in CSS"},"syntax:canvas-draw":{status:b.BLOCKED,note:"Security: tainted canvas"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject support"},"renderer:cairo":{status:b.BLOCKED,note:"No foreignObject"},"renderer:resvg":{status:b.BLOCKED,note:"No foreignObject"},"renderer:imagemagick":{status:b.BLOCKED,note:"No foreignObject"}}},FOREIGNOBJECT_HTML:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No HTML rendering"}}},FOREIGNOBJECT_FORM:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"syntax:object":{status:b.PARTIAL,note:"Form submission may be restricted"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No forms"}}},FOREIGNOBJECT_INPUT:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No inputs"}}},FOREIGNOBJECT_CANVAS:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No canvas"}}},FOREIGNOBJECT_VIDEO:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No video"}}},FOREIGNOBJECT_IFRAME:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject"},"syntax:object":{status:b.PARTIAL,note:"Nested contexts may fail"},"browser:ie11":{status:b.BLOCKED,note:"No foreignObject"},"renderer:*":{status:b.BLOCKED,note:"No iframes"}}},AUDIO_EMBEDDED:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg+processing:*-script":{status:b.WORKS,note:"Play on user gesture via JS"},"syntax:script-*":{status:b.WORKS,note:"JS can play on user gesture"}},note:"All browsers block autoplay without user gesture"},AUDIO_LOCAL:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:b.PARTIAL,note:"Needs user gesture"},"load:file":{status:b.PARTIAL,note:"May work locally with gesture"}}},AUDIO_REMOTE:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:b.PARTIAL,note:"Needs user gesture + CORS"},"storage:remote-cors":{status:b.PARTIAL,note:"Needs user gesture"}}},AUDIO_AUTOPLAY:{default:b.BLOCKED,exceptions:{},note:"Autoplay blocked by ALL modern browsers"},AUDIO_CONTROLS:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No foreignObject/audio"},"syntax:css-*":{status:b.BLOCKED,note:"No foreignObject/audio"},"syntax:object":{status:b.PARTIAL,note:"May render controls"}}},VIDEO_EMBEDDED:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:b.PARTIAL,note:"Needs user gesture"},"syntax:script-*":{status:b.WORKS,note:"JS can play on gesture"}}},VIDEO_LOCAL:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:b.PARTIAL,note:"Needs user gesture"}}},VIDEO_REMOTE:{default:b.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:b.PARTIAL,note:"Needs gesture + CORS"}}},VIDEO_AUTOPLAY:{default:b.BLOCKED,exceptions:{"browser:*":{status:b.PARTIAL,note:"May work muted"}},note:"Autoplay only works muted in most browsers"},USE_INTERNAL:{default:b.WORKS,exceptions:{"syntax:img":{status:b.WORKS,note:"Internal refs work"},"syntax:css-*":{status:b.WORKS,note:"Internal refs work"}}},USE_EXTERNAL_SAME:{default:b.PARTIAL,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external refs"},"syntax:css-*":{status:b.BLOCKED,note:"No external refs"},"browser:chrome":{status:b.BLOCKED,note:"External use blocked since Chrome 50"},"browser:firefox":{status:b.BLOCKED,note:"Blocked for security"},"browser:safari":{status:b.PARTIAL,note:"May work same-origin"}},note:"Most browsers block external <use> for security"},USE_EXTERNAL_CROSS:{default:b.BLOCKED,exceptions:{},note:"Cross-origin external <use> blocked by all browsers"},USE_SHADOW_DOM:{default:b.PARTIAL,exceptions:{"browser:ie11":{status:b.BLOCKED,note:"No shadow DOM"},"syntax:img":{status:b.BLOCKED,note:"No styling access"}},note:"Styling shadow DOM from <use> is limited"},MAP_BASIC:{default:b.NA,exceptions:{"syntax:inline-svg":{status:b.WORKS,note:"Can use SVG elements as map"}},note:"Traditional image maps not applicable, use SVG events"},MAP_COORDS:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No events for clickable regions"},"syntax:css-*":{status:b.BLOCKED,note:"No events"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},A11Y_ARIA:{default:b.WORKS,exceptions:{"syntax:img":{status:b.PARTIAL,note:"Only alt text accessible"},"syntax:css-*":{status:b.BLOCKED,note:"No a11y in CSS images"},"renderer:*":{status:b.BLOCKED,note:"No a11y tree"}}},A11Y_ROLE:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"Use alt attribute instead"},"syntax:css-*":{status:b.BLOCKED,note:"No a11y"},"renderer:*":{status:b.BLOCKED,note:"No a11y"}}},A11Y_TITLE:{default:b.WORKS,exceptions:{"syntax:img":{status:b.PARTIAL,note:"May not be read by screen readers"},"syntax:css-*":{status:b.BLOCKED,note:"Not accessible"}}},A11Y_TABINDEX:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:b.BLOCKED,note:"No focus"},"renderer:*":{status:b.BLOCKED,note:"No interaction"}}},META_DATA_ATTRS:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"Not accessible from outside"},"syntax:css-*":{status:b.BLOCKED,note:"Not accessible"}}},META_CLASS:{default:b.WORKS,exceptions:{}},META_ID:{default:b.WORKS,exceptions:{"syntax:img":{status:b.PARTIAL,note:"IDs isolated"}}},EXT_CSS_LINK:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external resources"},"syntax:css-*":{status:b.BLOCKED,note:"No external resources"},"load:file":{status:b.PARTIAL,note:"Local file restrictions"},"renderer:*":{status:b.BLOCKED,note:"No external fetch"}}},EXT_CSS_IMPORT:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No @import"},"syntax:css-*":{status:b.BLOCKED,note:"No @import"},"load:file":{status:b.PARTIAL,note:"May be blocked"},"renderer:*":{status:b.BLOCKED,note:"No external fetch"}}},EXT_XLINK:{default:b.WORKS,exceptions:{"syntax:img":{status:b.BLOCKED,note:"No external xlink"},"syntax:css-*":{status:b.BLOCKED,note:"No external xlink"},"storage:remote-cross":{status:b.BLOCKED,note:"CORS required"}}}},u3={JAVASCRIPT:"javascript",EVENT_HANDLERS:"event_handlers",SMIL_ANIMATIONS:"smil_animations",SMIL_INTERACTIVE:"smil_interactive",CSS_ANIMATIONS:"css_animations",AUDIO:"audio",VIDEO:"video",EXTERNAL_IMAGES:"external_images",EXTERNAL_CSS:"external_css",EXTERNAL_FONTS:"external_fonts",EXTERNAL_SCRIPTS:"external_scripts",EXTERNAL_USE:"external_use",FOREIGN_OBJECT:"foreign_object",IFRAME:"iframe",FILTERS:"filters",MASKS:"masks",CLIP_PATHS:"clip_paths",HYPERLINKS:"hyperlinks",ANCHORS:"anchors"},Ao=p3((t,a={})=>{let e=a.verbose||!1,i=a.printTables!==!1,r=a.includeMetaAnalysis!==!1,l=(w)=>{let G=[],a3=w.toLowerCase(),e3=(o3)=>{if(o3.tagName&&o3.tagName.toLowerCase()===a3)G.push(o3);for(let y3 of o3.children||[])if(y3&&y3.tagName)e3(y3)};return e3(t),G},o=(w,G=[])=>{if(w.tagName)G.push(w);for(let a3 of w.children||[])if(a3&&a3.tagName)o(a3,G);return G},x=(w,...G)=>{for(let a3 of G)if(w.getAttribute(a3))return!0;return!1},p={detected:new Set,details:{}},n=o(t),c=l("script");if(c.length>0){if(p.detected.add(u3.JAVASCRIPT),p.details.javascript={count:c.length,hasExternalSrc:c.some((w)=>w.getAttribute("src")||w.getAttribute("href")||w.getAttribute("xlink:href")),types:c.map((w)=>w.getAttribute("type")||"text/javascript")},p.details.javascript.hasExternalSrc)p.detected.add(u3.EXTERNAL_SCRIPTS)}let s=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove","onbegin","onend","onrepeat"],m=[];for(let w of n){let G=s.filter((a3)=>w.getAttribute(a3));if(G.length>0)m.push({tag:w.tagName,handlers:G})}if(m.length>0)p.detected.add(u3.EVENT_HANDLERS),p.details.eventHandlers={count:m.length,types:[...new Set(m.flatMap((w)=>w.handlers))],elements:m.slice(0,10)};let g=["animate","animatetransform","animatemotion","animatecolor","set"],u=[],y=[];for(let w of g){let G=l(w);u.push(...G);for(let a3 of G){let e3=a3.getAttribute("begin")||"",o3=a3.getAttribute("end")||"",y3=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let N3 of y3)if(e3.includes(N3)||o3.includes(N3))y.push({element:a3.tagName,event:N3,begin:e3,end:o3});if(e3.includes("accessKey(")||o3.includes("accessKey("))y.push({element:a3.tagName,event:"accessKey",begin:e3,end:o3})}}if(u.length>0){if(p.detected.add(u3.SMIL_ANIMATIONS),p.details.smilAnimations={count:u.length,breakdown:{animate:l("animate").length,animateTransform:l("animatetransform").length,animateMotion:l("animatemotion").length,animateColor:l("animatecolor").length,set:l("set").length}},y.length>0)p.detected.add(u3.SMIL_INTERACTIVE),p.details.smilInteractive={count:y.length,triggers:[...new Set(y.map((w)=>w.event))],elements:y.slice(0,10)}}let v=l("style"),E=!1;for(let w of v){let G=w.textContent||"";if(G.includes("@keyframes")||G.includes("animation:")||G.includes("animation-name")||G.includes("transition:")||G.includes("transition-property")){E=!0;break}}for(let w of n){let G=w.getAttribute("style")||"";if(G.includes("animation")||G.includes("transition")){E=!0;break}}if(E)p.detected.add(u3.CSS_ANIMATIONS),p.details.cssAnimations={detected:!0};let C=l("audio"),P=l("video"),S=l("foreignobject");for(let w of S){let G=[],a3=[],e3=(o3)=>{let y3=o3.tagName?.toLowerCase();if(y3==="audio")G.push(o3);if(y3==="video")a3.push(o3);for(let N3 of o3.children||[])if(N3&&N3.tagName)e3(N3)};for(let o3 of w.children||[])if(o3&&o3.tagName)e3(o3);C.push(...G),P.push(...a3)}if(C.length>0)p.detected.add(u3.AUDIO),p.details.audio={count:C.length,hasAutoplay:C.some((w)=>w.hasAttribute("autoplay")),sources:C.map((w)=>({id:w.getAttribute("id"),src:w.getAttribute("src"),isDataUri:(w.getAttribute("src")||"").startsWith("data:"),isExternal:(w.getAttribute("src")||"").startsWith("http")}))};if(P.length>0)p.detected.add(u3.VIDEO),p.details.video={count:P.length,hasAutoplay:P.some((w)=>w.hasAttribute("autoplay"))};let f=l("image"),B=[],R=[];for(let w of f){let G=w.getAttribute("href")||w.getAttribute("xlink:href")||"";if(G.startsWith("http://")||G.startsWith("https://")||G.startsWith("//"))B.push({href:G,element:"image"});else if(G.startsWith("data:"))R.push({type:"data-uri",element:"image"});else if(G&&!G.startsWith("#"))B.push({href:G,element:"image",type:"local"})}if(B.length>0)p.detected.add(u3.EXTERNAL_IMAGES),p.details.externalImages={count:B.length,urls:B.slice(0,5)};let k=l("use"),N=[];for(let w of k){let G=w.getAttribute("href")||w.getAttribute("xlink:href")||"";if(G&&!G.startsWith("#"))N.push({href:G})}if(N.length>0)p.detected.add(u3.EXTERNAL_USE),p.details.externalUse={count:N.length,refs:N.slice(0,5)};let I=!1;for(let w of v){let G=w.textContent||"";if(G.includes("@font-face")&&G.includes("url(")){let a3=G.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(a3){I=!0,p.detected.add(u3.EXTERNAL_FONTS),p.details.externalFonts={detected:!0,sample:a3[1]};break}}}if(S.length>0){if(p.detected.add(u3.FOREIGN_OBJECT),p.details.foreignObject={count:S.length,hasIframe:S.some((w)=>{let G=!1,a3=(e3)=>{if(e3.tagName?.toLowerCase()==="iframe")G=!0;for(let o3 of e3.children||[])if(o3&&o3.tagName)a3(o3)};return a3(w),G})},p.details.foreignObject.hasIframe)p.detected.add(u3.IFRAME)}let d=l("filter"),Y=l("mask"),X=l("clippath");if(d.length>0)p.detected.add(u3.FILTERS),p.details.filters={count:d.length};if(Y.length>0)p.detected.add(u3.MASKS),p.details.masks={count:Y.length};if(X.length>0)p.detected.add(u3.CLIP_PATHS),p.details.clipPaths={count:X.length};let F=l("a");if(F.length>0)p.detected.add(u3.HYPERLINKS),p.details.hyperlinks={count:F.length,hasExternal:F.some((w)=>{return(w.getAttribute("href")||w.getAttribute("xlink:href")||"").startsWith("http")})};let V={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},T={FILE:"file://",HTTP:"http://"},j={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},A={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},z={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},i3={[u3.JAVASCRIPT]:{[A.NONE]:{file:"✅",http:"✅",note:"Full JS execution"},[A.IMG]:{file:"❌",http:"❌",note:"All scripting disabled for security"},[A.OBJECT]:{file:"✅",http:"✅",note:"Isolated JS context"},[A.EMBED]:{file:"✅",http:"✅",note:"Isolated JS context"},[A.INLINE]:{file:"✅",http:"✅",note:"Same JS context as parent page"},[A.CSS]:{file:"❌",http:"❌",note:"CSS image context - no scripts"},[A.SCRIPT]:{file:"✅",http:"✅",note:"JS-generated = full control"}},[u3.EVENT_HANDLERS]:{[A.NONE]:{file:"✅",http:"✅",note:"Full event handling"},[A.IMG]:{file:"❌",http:"❌",note:"No events in img context"},[A.OBJECT]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[A.EMBED]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[A.INLINE]:{file:"✅",http:"✅",note:"Full event handling"},[A.CSS]:{file:"❌",http:"❌",note:"No events in CSS context"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Full event handling"}},[u3.SMIL_ANIMATIONS]:{[A.NONE]:{file:"✅",http:"✅",note:"Full SMIL support"},[A.IMG]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[A.OBJECT]:{file:"✅",http:"✅",note:"Full SMIL support"},[A.EMBED]:{file:"✅",http:"✅",note:"Full SMIL support"},[A.INLINE]:{file:"✅",http:"✅",note:"Full SMIL support"},[A.CSS]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Full SMIL support"}},[u3.SMIL_INTERACTIVE]:{[A.NONE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[A.IMG]:{file:"❌",http:"❌",note:"No interaction in img context"},[A.OBJECT]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[A.EMBED]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[A.INLINE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[A.CSS]:{file:"❌",http:"❌",note:"No interaction in CSS context"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Full interactive SMIL"}},[u3.CSS_ANIMATIONS]:{[A.NONE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[A.IMG]:{file:"✅",http:"✅",note:"CSS animations work in img"},[A.OBJECT]:{file:"✅",http:"✅",note:"Full CSS animation support"},[A.EMBED]:{file:"✅",http:"✅",note:"Full CSS animation support"},[A.INLINE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[A.CSS]:{file:"✅",http:"✅",note:"CSS animations work"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Full CSS animation support"}},[u3.AUDIO]:{[A.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[A.IMG]:{file:"❌",http:"❌",note:"No audio in img context"},[A.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[A.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[A.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[A.CSS]:{file:"❌",http:"❌",note:"No audio in CSS context"},[A.SCRIPT]:{file:"✅",http:"✅",note:"JS can play audio on user gesture"}},[u3.VIDEO]:{[A.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[A.IMG]:{file:"❌",http:"❌",note:"No video in img context"},[A.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[A.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[A.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[A.CSS]:{file:"❌",http:"❌",note:"No video in CSS context"},[A.SCRIPT]:{file:"✅",http:"✅",note:"JS can play video on user gesture"}},[u3.EXTERNAL_IMAGES]:{[A.NONE]:{file:"⚠️",http:"✅",note:"file:// may have CORS issues"},[A.IMG]:{file:"❌",http:"⚠️",note:"Blocked or CORS restricted"},[A.OBJECT]:{file:"⚠️",http:"✅",note:"CORS applies"},[A.EMBED]:{file:"⚠️",http:"✅",note:"CORS applies"},[A.INLINE]:{file:"⚠️",http:"✅",note:"CORS applies"},[A.CSS]:{file:"❌",http:"⚠️",note:"Restricted for security"},[A.SCRIPT]:{file:"⚠️",http:"✅",note:"CORS applies"}},[u3.EXTERNAL_CSS]:{[A.NONE]:{file:"✅",http:"✅",note:"External CSS loaded"},[A.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[A.OBJECT]:{file:"✅",http:"✅",note:"External CSS works"},[A.EMBED]:{file:"✅",http:"✅",note:"External CSS works"},[A.INLINE]:{file:"✅",http:"✅",note:"External CSS works"},[A.CSS]:{file:"❌",http:"❌",note:"No external resources"},[A.SCRIPT]:{file:"✅",http:"✅",note:"External CSS works"}},[u3.EXTERNAL_FONTS]:{[A.NONE]:{file:"✅",http:"✅",note:"External fonts loaded"},[A.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[A.OBJECT]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[A.EMBED]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[A.INLINE]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[A.CSS]:{file:"❌",http:"⚠️",note:"Limited, varies by browser"},[A.SCRIPT]:{file:"✅",http:"✅",note:"External fonts work"}},[u3.EXTERNAL_USE]:{[A.NONE]:{file:"❌",http:"⚠️",note:"Most browsers block external use"},[A.IMG]:{file:"❌",http:"❌",note:"No external use in img"},[A.OBJECT]:{file:"❌",http:"⚠️",note:"Most browsers block"},[A.EMBED]:{file:"❌",http:"⚠️",note:"Most browsers block"},[A.INLINE]:{file:"❌",http:"⚠️",note:"Most browsers block"},[A.CSS]:{file:"❌",http:"❌",note:"No external use"},[A.SCRIPT]:{file:"❌",http:"⚠️",note:"Most browsers block"}},[u3.FOREIGN_OBJECT]:{[A.NONE]:{file:"✅",http:"✅",note:"Full foreignObject support"},[A.IMG]:{file:"❌",http:"❌",note:"foreignObject disabled in img"},[A.OBJECT]:{file:"✅",http:"✅",note:"foreignObject works"},[A.EMBED]:{file:"✅",http:"✅",note:"foreignObject works"},[A.INLINE]:{file:"✅",http:"✅",note:"foreignObject works"},[A.CSS]:{file:"❌",http:"❌",note:"foreignObject disabled"},[A.SCRIPT]:{file:"✅",http:"✅",note:"foreignObject works"}},[u3.HYPERLINKS]:{[A.NONE]:{file:"✅",http:"✅",note:"Links work"},[A.IMG]:{file:"❌",http:"❌",note:"No links in img context"},[A.OBJECT]:{file:"✅",http:"✅",note:"Links work (in iframe-like context)"},[A.EMBED]:{file:"✅",http:"✅",note:"Links work"},[A.INLINE]:{file:"✅",http:"✅",note:"Links work normally"},[A.CSS]:{file:"❌",http:"❌",note:"No links in CSS context"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Links work"}},[u3.FILTERS]:{[A.NONE]:{file:"✅",http:"✅",note:"Full filter support"},[A.IMG]:{file:"✅",http:"✅",note:"Filters work"},[A.OBJECT]:{file:"✅",http:"✅",note:"Filters work"},[A.EMBED]:{file:"✅",http:"✅",note:"Filters work"},[A.INLINE]:{file:"✅",http:"✅",note:"Filters work"},[A.CSS]:{file:"✅",http:"✅",note:"Filters work"},[A.SCRIPT]:{file:"✅",http:"✅",note:"Filters work"}}},K={"GitHub README.md":{syntax:"IMG (implicit)",restrictions:["No JavaScript","No SMIL","No external resources","No foreignObject","No links"],worksFor:["Static SVG","CSS animations (some)","Embedded images (data-uri)"],note:"GitHub sanitizes SVG heavily - only safe static content"},"GitHub Flavored Markdown (GFM)":{syntax:"IMG",restrictions:["Same as GitHub README"],worksFor:["Static SVG only"],note:"GFM renders SVG as images"},"GitLab README.md":{syntax:"IMG (implicit)",restrictions:["Similar to GitHub but slightly more permissive"],worksFor:["Static SVG","Some CSS animations"],note:"GitLab also sanitizes SVG"},"Wikipedia/MediaWiki":{syntax:"IMG (sanitized)",restrictions:["Heavy sanitization","No scripts","No external resources","No animations"],worksFor:["Static vector graphics only"],note:"MediaWiki converts SVG to PNG for display"},"EPUB 3.x":{syntax:"IMG or INLINE",restrictions:["No external resources","Limited JavaScript","No autoplay"],worksFor:["Static SVG","CSS animations","SMIL (in some readers)"],note:"Support varies by e-reader - Apple Books better than Kindle"},"Email (HTML email)":{syntax:"IMG (base64)",restrictions:["Heavily filtered","No scripts","No external resources","No animations"],worksFor:["Static embedded SVG only","Many clients block SVG entirely"],note:"Most email clients block or rasterize SVG"},"Slack/Discord":{syntax:"IMG (auto-converted)",restrictions:["Converted to raster","No interactivity"],worksFor:["Static preview only"],note:"SVG files are typically converted to PNG previews"},"Twitter/X":{syntax:"N/A",restrictions:["SVG not supported as media"],worksFor:["Nothing - upload as PNG"],note:"Twitter does not support SVG uploads"},Notion:{syntax:"EMBED/IMG",restrictions:["Limited - treated as image"],worksFor:["Static SVG"],note:"Notion embeds SVG as images"},Obsidian:{syntax:"INLINE or IMG",restrictions:["Depends on mode and plugins"],worksFor:["Static SVG","Some CSS animations"],note:"Obsidian has good local SVG support"},"Bear Notes":{syntax:"IMG",restrictions:["Image context only"],worksFor:["Static SVG"],note:"Bear treats SVG as images"},"Markdown-it":{syntax:"IMG (default)",restrictions:["Default IMG behavior","Can be configured for INLINE"],worksFor:["Depends on configuration"],note:"Parser library - output depends on implementation"},MDX:{syntax:"INLINE (JSX)",restrictions:["Full React component - depends on framework"],worksFor:["Full SVG when used as component"],note:"MDX can import SVG as React components"},"iOS Safari":{syntax:"ALL",restrictions:["Stricter autoplay policies"],worksFor:["All standard SVG features except auto-audio"],note:"Good SVG support, strict media policies"},"Android WebView":{syntax:"ALL",restrictions:["Varies by Android version"],worksFor:["Most SVG features"],note:"WebView behavior varies significantly"},"Cairo/librsvg":{syntax:"CUSTOM_RENDERER",restrictions:["Limited JS","Limited SMIL","No foreignObject"],worksFor:["Static SVG","Basic filters","CSS styling"],note:"Server-side rendering library - no dynamic features"},Inkscape:{syntax:"CUSTOM_RENDERER",restrictions:["May not run JS","SMIL playback varies"],worksFor:["All static SVG","Partial animation preview"],note:"Full SVG editor with preview capabilities"},ImageMagick:{syntax:"CUSTOM_RENDERER",restrictions:["Rasterizes immediately","No animations","No JS"],worksFor:["Static rasterization only"],note:"Converts SVG to raster - no dynamic features"}},$={timestamp:new Date().toISOString(),features:p,interactivityLevel:"static",bySyntax:{},specialCases:{},recommendations:[],warnings:[]};if(p.detected.has(u3.JAVASCRIPT)||p.detected.has(u3.EVENT_HANDLERS))$.interactivityLevel="scripted";else if(p.detected.has(u3.SMIL_INTERACTIVE))$.interactivityLevel="interactive";else if(p.detected.has(u3.SMIL_ANIMATIONS)||p.detected.has(u3.CSS_ANIMATIONS))$.interactivityLevel="animated";for(let w of Object.values(A)){$.bySyntax[w]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let G of p.detected){let a3=i3[G];if(a3&&a3[w]){let{file:e3,http:o3,note:y3}=a3[w];if(e3==="✅")$.bySyntax[w].file.works.push({feature:G,note:y3});else if(e3==="⚠️")$.bySyntax[w].file.partial.push({feature:G,note:y3});else $.bySyntax[w].file.blocked.push({feature:G,note:y3});if(o3==="✅")$.bySyntax[w].http.works.push({feature:G,note:y3});else if(o3==="⚠️")$.bySyntax[w].http.partial.push({feature:G,note:y3});else $.bySyntax[w].http.blocked.push({feature:G,note:y3})}}}for(let[w,G]of Object.entries(K)){let a3=[],e3=[];for(let o3 of p.detected){let y3={[u3.JAVASCRIPT]:"JavaScript",[u3.EVENT_HANDLERS]:"Event handlers",[u3.SMIL_ANIMATIONS]:"SMIL",[u3.SMIL_INTERACTIVE]:"Interactive SMIL",[u3.CSS_ANIMATIONS]:"CSS animations",[u3.AUDIO]:"Audio",[u3.VIDEO]:"Video",[u3.EXTERNAL_IMAGES]:"External images",[u3.EXTERNAL_USE]:"External use",[u3.FOREIGN_OBJECT]:"foreignObject",[u3.HYPERLINKS]:"Links"}[o3]||o3;if(G.restrictions.some((N3)=>N3.toLowerCase().includes(y3.toLowerCase())||N3.toLowerCase().includes("no "+y3.toLowerCase())))a3.push(y3);else if(G.worksFor.some((N3)=>N3.toLowerCase().includes(y3.toLowerCase())))e3.push(y3)}$.specialCases[w]={syntax:G.syntax,blockedFeatures:a3,workingFeatures:e3,note:G.note,overallCompat:a3.length===0?"✅ Compatible":a3.length<p.detected.size/2?"⚠️ Partial":"❌ Not compatible"}}if(p.detected.has(u3.AUDIO))$.recommendations.push({issue:"Audio playback blocked",solution:"Use SCRIPT syntax with user gesture: embed SVG inline, extract audio data-uri via JavaScript, play on click",example:`document.querySelector('svg').addEventListener('click', () => {
|
|
30
|
+
`)}return Q.valid=Q.errors.length===0,$.setAttribute("data-compatibility-report",JSON.stringify({hasAudio:Q.media.hasAudio,hasVideo:Q.media.hasVideo,smilCount:Q.smil.animationCount,hasInteractive:Q.smil.hasInteractiveAnimations,issues:Q.compatibility.issues.length})),$._compatibilityReport=Q,$}),Q6={RENDER_VECTORS:{cat:"display",name:"Vector paths/shapes",critical:!0},RENDER_TEXT:{cat:"display",name:"Text rendering",critical:!0},RENDER_GRADIENTS:{cat:"display",name:"Gradients (linear/radial)",critical:!1},RENDER_PATTERNS:{cat:"display",name:"Pattern fills",critical:!1},RENDER_OPACITY:{cat:"display",name:"Opacity/transparency",critical:!1},RENDER_BLENDMODES:{cat:"display",name:"Blend modes",critical:!1},RENDER_TRANSFORMS:{cat:"display",name:"Transforms",critical:!0},FONTS_EMBEDDED:{cat:"fonts",name:"Embedded fonts (data-uri)",critical:!1},FONTS_SYSTEM:{cat:"fonts",name:"System fonts",critical:!1},FONTS_WEB_SAME:{cat:"fonts",name:"Web fonts (same-origin)",critical:!1},FONTS_WEB_CROSS:{cat:"fonts",name:"Web fonts (cross-origin)",critical:!1},IMAGES_EMBEDDED:{cat:"images",name:"Embedded images (data-uri)",critical:!1},IMAGES_LOCAL:{cat:"images",name:"Local images",critical:!1},IMAGES_REMOTE_SAME:{cat:"images",name:"Remote images (same-origin)",critical:!1},IMAGES_REMOTE_CROSS:{cat:"images",name:"Remote images (cross-origin)",critical:!1},FILTERS_BASIC:{cat:"effects",name:"Basic filters (blur, shadow)",critical:!1},FILTERS_COMPLEX:{cat:"effects",name:"Complex filters (lighting, turbulence)",critical:!1},MASKS:{cat:"effects",name:"Mask elements",critical:!1},CLIP_PATHS:{cat:"effects",name:"Clip paths",critical:!1},SMIL_TIMED:{cat:"animation",name:"SMIL time-based animation",critical:!1},SMIL_CLICK:{cat:"animation",name:"SMIL click-triggered",critical:!1},SMIL_HOVER:{cat:"animation",name:"SMIL mouseover-triggered",critical:!1},SMIL_FOCUS:{cat:"animation",name:"SMIL focus-triggered",critical:!1},SMIL_ACCESSKEY:{cat:"animation",name:"SMIL accessKey-triggered",critical:!1},SMIL_SYNCBASE:{cat:"animation",name:"SMIL syncbase (anim.begin)",critical:!1},CSS_KEYFRAMES:{cat:"animation",name:"CSS @keyframes animation",critical:!1},CSS_TRANSITIONS:{cat:"animation",name:"CSS transitions",critical:!1},CSS_HOVER:{cat:"animation",name:"CSS :hover effects",critical:!1},SCRIPT_INLINE:{cat:"scripting",name:"Inline <script>",critical:!1},SCRIPT_EXTERNAL:{cat:"scripting",name:'External <script src="">',critical:!1},SCRIPT_MODULE:{cat:"scripting",name:"ES modules in SVG",critical:!1},EVENT_ONCLICK:{cat:"events",name:"onclick handler",critical:!1},EVENT_ONDBLCLICK:{cat:"events",name:"ondblclick handler",critical:!1},EVENT_ONMOUSEDOWN:{cat:"events",name:"onmousedown handler",critical:!1},EVENT_ONMOUSEUP:{cat:"events",name:"onmouseup handler",critical:!1},EVENT_ONMOUSEOVER:{cat:"events",name:"onmouseover handler",critical:!1},EVENT_ONMOUSEOUT:{cat:"events",name:"onmouseout handler",critical:!1},EVENT_ONMOUSEMOVE:{cat:"events",name:"onmousemove handler",critical:!1},EVENT_ONFOCUS:{cat:"events",name:"onfocus handler",critical:!1},EVENT_ONBLUR:{cat:"events",name:"onblur handler",critical:!1},EVENT_ONLOAD:{cat:"events",name:"onload handler",critical:!1},EVENT_ONERROR:{cat:"events",name:"onerror handler",critical:!1},EVENT_ONSCROLL:{cat:"events",name:"onscroll handler",critical:!1},EVENT_ONWHEEL:{cat:"events",name:"onwheel handler",critical:!1},EVENT_ONTOUCH:{cat:"events",name:"touch events",critical:!1},EVENT_ONKEYBOARD:{cat:"events",name:"keyboard events",critical:!1},LINK_INTERNAL:{cat:"links",name:"Internal anchor links",critical:!1},LINK_EXTERNAL:{cat:"links",name:"External hyperlinks",critical:!1},LINK_TARGET:{cat:"links",name:"Link target attribute",critical:!1},LINK_DOWNLOAD:{cat:"links",name:"Download attribute",critical:!1},FOREIGNOBJECT_BASIC:{cat:"html",name:"foreignObject rendering",critical:!1},FOREIGNOBJECT_HTML:{cat:"html",name:"HTML in foreignObject",critical:!1},FOREIGNOBJECT_FORM:{cat:"html",name:"Forms in foreignObject",critical:!1},FOREIGNOBJECT_INPUT:{cat:"html",name:"Input elements in foreignObject",critical:!1},FOREIGNOBJECT_CANVAS:{cat:"html",name:"Canvas in foreignObject",critical:!1},FOREIGNOBJECT_VIDEO:{cat:"html",name:"Video in foreignObject",critical:!1},FOREIGNOBJECT_IFRAME:{cat:"html",name:"iframe in foreignObject",critical:!1},AUDIO_EMBEDDED:{cat:"media",name:"Embedded audio (data-uri)",critical:!1},AUDIO_LOCAL:{cat:"media",name:"Local audio files",critical:!1},AUDIO_REMOTE:{cat:"media",name:"Remote audio files",critical:!1},AUDIO_AUTOPLAY:{cat:"media",name:"Audio autoplay",critical:!1},AUDIO_CONTROLS:{cat:"media",name:"Audio controls visible",critical:!1},VIDEO_EMBEDDED:{cat:"media",name:"Embedded video (data-uri)",critical:!1},VIDEO_LOCAL:{cat:"media",name:"Local video files",critical:!1},VIDEO_REMOTE:{cat:"media",name:"Remote video files",critical:!1},VIDEO_AUTOPLAY:{cat:"media",name:"Video autoplay",critical:!1},USE_INTERNAL:{cat:"sprites",name:"Internal <use> references",critical:!1},USE_EXTERNAL_SAME:{cat:"sprites",name:"External <use> (same-origin)",critical:!1},USE_EXTERNAL_CROSS:{cat:"sprites",name:"External <use> (cross-origin)",critical:!1},USE_SHADOW_DOM:{cat:"sprites",name:"Shadow DOM styling of <use>",critical:!1},MAP_BASIC:{cat:"maps",name:"SVG as image map",critical:!1},MAP_COORDS:{cat:"maps",name:"Clickable regions",critical:!1},A11Y_ARIA:{cat:"accessibility",name:"ARIA attributes",critical:!1},A11Y_ROLE:{cat:"accessibility",name:"Role attributes",critical:!1},A11Y_TITLE:{cat:"accessibility",name:"Title/desc for screen readers",critical:!1},A11Y_TABINDEX:{cat:"accessibility",name:"Tab navigation",critical:!1},META_DATA_ATTRS:{cat:"metadata",name:"data-* attributes",critical:!1},META_CLASS:{cat:"metadata",name:"class attribute styling",critical:!1},META_ID:{cat:"metadata",name:"id references",critical:!0},EXT_CSS_LINK:{cat:"external",name:"External CSS via <?xml-stylesheet?>",critical:!1},EXT_CSS_IMPORT:{cat:"external",name:"@import in <style>",critical:!1},EXT_XLINK:{cat:"external",name:"xlink:href references",critical:!1}},DW={STANDALONE_BROWSER:{id:"standalone-browser",name:"Standalone (Browser)",type:"browser"},HTML_PAGE:{id:"html-page",name:"HTML Page",type:"browser"},ELECTRON:{id:"electron",name:"Electron App",type:"browser"},WEBVIEW_IOS:{id:"webview-ios",name:"iOS WKWebView",type:"mobile"},WEBVIEW_ANDROID:{id:"webview-android",name:"Android WebView",type:"mobile"},CAIRO:{id:"cairo",name:"Cairo/librsvg",type:"renderer"},INKSCAPE:{id:"inkscape",name:"Inkscape",type:"renderer"},IMAGEMAGICK:{id:"imagemagick",name:"ImageMagick",type:"renderer"},BATIK:{id:"batik",name:"Apache Batik",type:"renderer"},RESVG:{id:"resvg",name:"resvg",type:"renderer"},QT_SVG:{id:"qt-svg",name:"Qt SVG",type:"renderer"},SKIA:{id:"skia",name:"Skia (Chrome/Flutter)",type:"renderer"}},hW={FILE:{id:"file",name:"file://",protocol:"file"},HTTP:{id:"http",name:"http://",protocol:"http"},HTTPS:{id:"https",name:"https://",protocol:"https"},DATA_URI:{id:"data-uri",name:"data: URI",protocol:"data"},BLOB_URL:{id:"blob-url",name:"blob: URL",protocol:"blob"}},yW={INLINE:{id:"inline",name:"Inline in HTML",location:"inline"},BASE64:{id:"base64",name:"Base64 encoded",location:"embedded"},LOCAL_SAME:{id:"local-same",name:"Local (same dir)",location:"local"},LOCAL_ABS:{id:"local-abs",name:"Local (absolute)",location:"local"},REMOTE_SAME:{id:"remote-same",name:"Remote (same-origin)",location:"remote"},REMOTE_CROSS:{id:"remote-cross",name:"Remote (cross-origin)",location:"cross"},REMOTE_CORS:{id:"remote-cors",name:"Remote (cross+CORS)",location:"cors"}},JZ={DIRECT:{id:"direct",name:"Direct SVG file",html:!1},IMG:{id:"img",name:'<img src="">',html:!0},PICTURE:{id:"picture",name:"<picture><source>",html:!0},OBJECT:{id:"object",name:'<object data="">',html:!0},EMBED:{id:"embed",name:'<embed src="">',html:!0},IFRAME:{id:"iframe",name:'<iframe src="">',html:!0},INLINE_SVG:{id:"inline-svg",name:"<svg>...</svg>",html:!0},CSS_BG:{id:"css-bg",name:"CSS background-image",html:!0},CSS_MASK:{id:"css-mask",name:"CSS mask-image",html:!0},CSS_CONTENT:{id:"css-content",name:"CSS content: url()",html:!0},CSS_LIST:{id:"css-list",name:"CSS list-style-image",html:!0},CSS_BORDER:{id:"css-border",name:"CSS border-image",html:!0},CANVAS_DRAW:{id:"canvas-draw",name:"canvas.drawImage()",html:!0},SCRIPT_INNER:{id:"script-inner",name:"innerHTML assignment",html:!0},SCRIPT_DOM:{id:"script-dom",name:"DOM createElement",html:!0},SCRIPT_FETCH:{id:"script-fetch",name:"fetch + parse",html:!0}},uW={NA:{id:"n/a",name:"N/A (not script)",script:!1},INLINE_SCRIPT:{id:"inline-script",name:"Inline <script>",script:!0},SAME_ORIGIN:{id:"same-origin",name:"Same-origin script",script:!0},CROSS_CORS:{id:"cross-cors",name:"Cross-origin (CORS)",script:!0},CROSS_NO_CORS:{id:"cross-no-cors",name:"Cross-origin (no CORS)",script:!0}},ZZ={CHROME:{id:"chrome",name:"Chrome",engine:"blink"},FIREFOX:{id:"firefox",name:"Firefox",engine:"gecko"},SAFARI:{id:"safari",name:"Safari",engine:"webkit"},EDGE:{id:"edge",name:"Edge",engine:"blink"},IE11:{id:"ie11",name:"IE 11",engine:"trident"},SAFARI_IOS:{id:"safari-ios",name:"Safari iOS",engine:"webkit"},CHROME_ANDROID:{id:"chrome-android",name:"Chrome Android",engine:"blink"},SAMSUNG:{id:"samsung",name:"Samsung Internet",engine:"blink"}},L={WORKS:"✅",PARTIAL:"⚠️",BLOCKED:"❌",DEPENDS:"❓",NA:"➖"},UJ={RENDER_VECTORS:{default:L.WORKS,exceptions:{}},RENDER_TEXT:{default:L.WORKS,exceptions:{"renderer:imagemagick":{status:L.PARTIAL,note:"Font substitution may occur"},"renderer:batik":{status:L.PARTIAL,note:"Limited font support"}}},RENDER_GRADIENTS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.PARTIAL,note:"Some gradient types unsupported"}}},RENDER_PATTERNS:{default:L.WORKS,exceptions:{"renderer:resvg":{status:L.PARTIAL,note:"Limited pattern support"}}},RENDER_OPACITY:{default:L.WORKS,exceptions:{}},RENDER_BLENDMODES:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No blend mode support"},"renderer:cairo":{status:L.PARTIAL,note:"Limited blend modes"}}},FONTS_EMBEDDED:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No embedded fonts in img context",browsers:"all"},"syntax:css-bg":{status:L.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"syntax:css-mask":{status:L.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"renderer:imagemagick":{status:L.BLOCKED,note:"Cannot process embedded fonts"}}},FONTS_SYSTEM:{default:L.WORKS,exceptions:{}},FONTS_WEB_SAME:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"syntax:css-bg":{status:L.BLOCKED,note:"No external resources in CSS bg"},"load:file":{status:L.PARTIAL,note:"May fail due to local file restrictions"},"renderer:*":{status:L.BLOCKED,note:"Renderers cannot fetch web fonts"}}},FONTS_WEB_CROSS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources in CSS"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS headers"},"renderer:*":{status:L.BLOCKED,note:"Renderers cannot fetch fonts"}}},IMAGES_EMBEDDED:{default:L.WORKS,exceptions:{}},IMAGES_LOCAL:{default:L.WORKS,exceptions:{"load:http":{status:L.BLOCKED,note:"Cannot load file:// from http://"},"load:https":{status:L.BLOCKED,note:"Cannot load file:// from https://"},"syntax:img":{status:L.BLOCKED,note:"No external resources in img"}}},IMAGES_REMOTE_SAME:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"load:file":{status:L.BLOCKED,note:"Cannot fetch http from file://"}}},IMAGES_REMOTE_CROSS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS"},"load:file":{status:L.BLOCKED,note:"CORS not applicable"}}},FILTERS_BASIC:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.PARTIAL,note:"Limited filter support"}}},FILTERS_COMPLEX:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"Complex filters unsupported"},"renderer:resvg":{status:L.PARTIAL,note:"Some filters unsupported"},"renderer:qt-svg":{status:L.PARTIAL,note:"Limited filter primitives"}}},MASKS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"SVG masks not supported"}}},CLIP_PATHS:{default:L.WORKS,exceptions:{}},SMIL_TIMED:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.PARTIAL,note:"May animate, no interaction",browsers:["chrome","firefox"]},"syntax:css-bg":{status:L.PARTIAL,note:"May animate, varies by browser"},"renderer:*":{status:L.BLOCKED,note:"Static render, no animation"}}},SMIL_CLICK:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized, no interaction"},"renderer:*":{status:L.BLOCKED,note:"No interaction in renderers"}}},SMIL_HOVER:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SMIL_FOCUS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SMIL_ACCESSKEY:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"browser:chrome":{status:L.PARTIAL,note:"Limited accessKey support"},"syntax:img":{status:L.BLOCKED,note:"No keyboard in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No keyboard in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No keyboard"}}},SMIL_SYNCBASE:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.PARTIAL,note:"Sync works if animation plays"},"renderer:*":{status:L.BLOCKED,note:"No animation"}}},CSS_KEYFRAMES:{default:L.WORKS,exceptions:{"syntax:img":{status:L.WORKS,note:"CSS animations work in img"},"syntax:css-bg":{status:L.WORKS,note:"CSS animations work"},"renderer:*":{status:L.BLOCKED,note:"Static render"}}},CSS_TRANSITIONS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No interaction for transitions"},"syntax:css-bg":{status:L.BLOCKED,note:"No interaction"},"renderer:*":{status:L.BLOCKED,note:"Static render"}}},CSS_HOVER:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No :hover in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No :hover in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SCRIPT_INLINE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Scripts disabled for security"},"syntax:css-*":{status:L.BLOCKED,note:"Scripts disabled in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized, no scripts"},"renderer:*":{status:L.BLOCKED,note:"No script execution"},"display:html-page+syntax:inline-svg":{status:L.WORKS,note:"Runs in page context"},"display:html-page+syntax:object":{status:L.WORKS,note:"Isolated context"},"display:html-page+syntax:embed":{status:L.WORKS,note:"Isolated context"}}},SCRIPT_EXTERNAL:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources"},"load:file":{status:L.PARTIAL,note:"May be blocked by local file restrictions"},"storage:remote-cross":{status:L.BLOCKED,note:"CORS required"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},SCRIPT_MODULE:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No ES modules"},"browser:safari":{status:L.PARTIAL,note:"Limited module support in SVG"},"syntax:img":{status:L.BLOCKED,note:"No scripts"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONCLICK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No events in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONDBLCLICK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEDOWN:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEUP:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOVER:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOUT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEMOVE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONFOCUS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:L.BLOCKED,note:"No focus"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONBLUR:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONLOAD:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scripts/events"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONERROR:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scripts"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONSCROLL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scroll in img"},"syntax:css-*":{status:L.BLOCKED,note:"No scroll"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONWHEEL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONTOUCH:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No touch events"},"syntax:css-*":{status:L.BLOCKED,note:"No touch"},"display:*-browser":{status:L.NA,note:"No touch on desktop"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONKEYBOARD:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No keyboard"},"syntax:css-*":{status:L.BLOCKED,note:"No keyboard"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},LINK_INTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links in img"},"syntax:css-*":{status:L.BLOCKED,note:"No links in CSS"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},LINK_EXTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links in img"},"syntax:css-*":{status:L.BLOCKED,note:"No links"},"syntax:object":{status:L.WORKS,note:"Opens in object frame"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},LINK_TARGET:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links"},"syntax:css-*":{status:L.BLOCKED,note:"No links"},"syntax:object":{status:L.PARTIAL,note:"May not break out of frame"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},LINK_DOWNLOAD:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links"},"browser:safari":{status:L.PARTIAL,note:"Limited download attr support"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},FOREIGNOBJECT_BASIC:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"foreignObject disabled in img"},"syntax:css-*":{status:L.BLOCKED,note:"foreignObject disabled in CSS"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Security: tainted canvas"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject support"},"renderer:cairo":{status:L.BLOCKED,note:"No foreignObject"},"renderer:resvg":{status:L.BLOCKED,note:"No foreignObject"},"renderer:imagemagick":{status:L.BLOCKED,note:"No foreignObject"}}},FOREIGNOBJECT_HTML:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No HTML rendering"}}},FOREIGNOBJECT_FORM:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"syntax:object":{status:L.PARTIAL,note:"Form submission may be restricted"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No forms"}}},FOREIGNOBJECT_INPUT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No inputs"}}},FOREIGNOBJECT_CANVAS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No canvas"}}},FOREIGNOBJECT_VIDEO:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No video"}}},FOREIGNOBJECT_IFRAME:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"syntax:object":{status:L.PARTIAL,note:"Nested contexts may fail"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No iframes"}}},AUDIO_EMBEDDED:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg+processing:*-script":{status:L.WORKS,note:"Play on user gesture via JS"},"syntax:script-*":{status:L.WORKS,note:"JS can play on user gesture"}},note:"All browsers block autoplay without user gesture"},AUDIO_LOCAL:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"},"load:file":{status:L.PARTIAL,note:"May work locally with gesture"}}},AUDIO_REMOTE:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture + CORS"},"storage:remote-cors":{status:L.PARTIAL,note:"Needs user gesture"}}},AUDIO_AUTOPLAY:{default:L.BLOCKED,exceptions:{},note:"Autoplay blocked by ALL modern browsers"},AUDIO_CONTROLS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject/audio"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject/audio"},"syntax:object":{status:L.PARTIAL,note:"May render controls"}}},VIDEO_EMBEDDED:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"},"syntax:script-*":{status:L.WORKS,note:"JS can play on gesture"}}},VIDEO_LOCAL:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"}}},VIDEO_REMOTE:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs gesture + CORS"}}},VIDEO_AUTOPLAY:{default:L.BLOCKED,exceptions:{"browser:*":{status:L.PARTIAL,note:"May work muted"}},note:"Autoplay only works muted in most browsers"},USE_INTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.WORKS,note:"Internal refs work"},"syntax:css-*":{status:L.WORKS,note:"Internal refs work"}}},USE_EXTERNAL_SAME:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external refs"},"syntax:css-*":{status:L.BLOCKED,note:"No external refs"},"browser:chrome":{status:L.BLOCKED,note:"External use blocked since Chrome 50"},"browser:firefox":{status:L.BLOCKED,note:"Blocked for security"},"browser:safari":{status:L.PARTIAL,note:"May work same-origin"}},note:"Most browsers block external <use> for security"},USE_EXTERNAL_CROSS:{default:L.BLOCKED,exceptions:{},note:"Cross-origin external <use> blocked by all browsers"},USE_SHADOW_DOM:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No shadow DOM"},"syntax:img":{status:L.BLOCKED,note:"No styling access"}},note:"Styling shadow DOM from <use> is limited"},MAP_BASIC:{default:L.NA,exceptions:{"syntax:inline-svg":{status:L.WORKS,note:"Can use SVG elements as map"}},note:"Traditional image maps not applicable, use SVG events"},MAP_COORDS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events for clickable regions"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},A11Y_ARIA:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"Only alt text accessible"},"syntax:css-*":{status:L.BLOCKED,note:"No a11y in CSS images"},"renderer:*":{status:L.BLOCKED,note:"No a11y tree"}}},A11Y_ROLE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Use alt attribute instead"},"syntax:css-*":{status:L.BLOCKED,note:"No a11y"},"renderer:*":{status:L.BLOCKED,note:"No a11y"}}},A11Y_TITLE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"May not be read by screen readers"},"syntax:css-*":{status:L.BLOCKED,note:"Not accessible"}}},A11Y_TABINDEX:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:L.BLOCKED,note:"No focus"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},META_DATA_ATTRS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Not accessible from outside"},"syntax:css-*":{status:L.BLOCKED,note:"Not accessible"}}},META_CLASS:{default:L.WORKS,exceptions:{}},META_ID:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"IDs isolated"}}},EXT_CSS_LINK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources"},"load:file":{status:L.PARTIAL,note:"Local file restrictions"},"renderer:*":{status:L.BLOCKED,note:"No external fetch"}}},EXT_CSS_IMPORT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No @import"},"syntax:css-*":{status:L.BLOCKED,note:"No @import"},"load:file":{status:L.PARTIAL,note:"May be blocked"},"renderer:*":{status:L.BLOCKED,note:"No external fetch"}}},EXT_XLINK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external xlink"},"syntax:css-*":{status:L.BLOCKED,note:"No external xlink"},"storage:remote-cross":{status:L.BLOCKED,note:"CORS required"}}}},X0={JAVASCRIPT:"javascript",EVENT_HANDLERS:"event_handlers",SMIL_ANIMATIONS:"smil_animations",SMIL_INTERACTIVE:"smil_interactive",CSS_ANIMATIONS:"css_animations",AUDIO:"audio",VIDEO:"video",EXTERNAL_IMAGES:"external_images",EXTERNAL_CSS:"external_css",EXTERNAL_FONTS:"external_fonts",EXTERNAL_SCRIPTS:"external_scripts",EXTERNAL_USE:"external_use",FOREIGN_OBJECT:"foreign_object",IFRAME:"iframe",FILTERS:"filters",MASKS:"masks",CLIP_PATHS:"clip_paths",HYPERLINKS:"hyperlinks",ANCHORS:"anchors"},gW=F0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q=J.includeMetaAnalysis!==!1,q=(f)=>{let A=[],e=f.toLowerCase(),$0=(Q0)=>{if(Q0.tagName&&Q0.tagName.toLowerCase()===e)A.push(Q0);for(let V0 of Q0.children||[])if(V0&&V0.tagName)$0(V0)};return $0($),A},H=(f,A=[])=>{if(f.tagName)A.push(f);for(let e of f.children||[])if(e&&e.tagName)H(e,A);return A},W=(f,...A)=>{for(let e of A)if(f.getAttribute(e))return!0;return!1},z={detected:new Set,details:{}},j=H($),G=q("script");if(G.length>0){if(z.detected.add(X0.JAVASCRIPT),z.details.javascript={count:G.length,hasExternalSrc:G.some((f)=>f.getAttribute("src")||f.getAttribute("href")||f.getAttribute("xlink:href")),types:G.map((f)=>f.getAttribute("type")||"text/javascript")},z.details.javascript.hasExternalSrc)z.detected.add(X0.EXTERNAL_SCRIPTS)}let F=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove","onbegin","onend","onrepeat"],_=[];for(let f of j){let A=F.filter((e)=>f.getAttribute(e));if(A.length>0)_.push({tag:f.tagName,handlers:A})}if(_.length>0)z.detected.add(X0.EVENT_HANDLERS),z.details.eventHandlers={count:_.length,types:[...new Set(_.flatMap((f)=>f.handlers))],elements:_.slice(0,10)};let U=["animate","animatetransform","animatemotion","animatecolor","set"],M=[],V=[];for(let f of U){let A=q(f);M.push(...A);for(let e of A){let $0=e.getAttribute("begin")||"",Q0=e.getAttribute("end")||"",V0=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let N0 of V0)if($0.includes(N0)||Q0.includes(N0))V.push({element:e.tagName,event:N0,begin:$0,end:Q0});if($0.includes("accessKey(")||Q0.includes("accessKey("))V.push({element:e.tagName,event:"accessKey",begin:$0,end:Q0})}}if(M.length>0){if(z.detected.add(X0.SMIL_ANIMATIONS),z.details.smilAnimations={count:M.length,breakdown:{animate:q("animate").length,animateTransform:q("animatetransform").length,animateMotion:q("animatemotion").length,animateColor:q("animatecolor").length,set:q("set").length}},V.length>0)z.detected.add(X0.SMIL_INTERACTIVE),z.details.smilInteractive={count:V.length,triggers:[...new Set(V.map((f)=>f.event))],elements:V.slice(0,10)}}let Y=q("style"),X=!1;for(let f of Y){let A=f.textContent||"";if(A.includes("@keyframes")||A.includes("animation:")||A.includes("animation-name")||A.includes("transition:")||A.includes("transition-property")){X=!0;break}}for(let f of j){let A=f.getAttribute("style")||"";if(A.includes("animation")||A.includes("transition")){X=!0;break}}if(X)z.detected.add(X0.CSS_ANIMATIONS),z.details.cssAnimations={detected:!0};let k=q("audio"),w=q("video"),R=q("foreignobject");for(let f of R){let A=[],e=[],$0=(Q0)=>{let V0=Q0.tagName?.toLowerCase();if(V0==="audio")A.push(Q0);if(V0==="video")e.push(Q0);for(let N0 of Q0.children||[])if(N0&&N0.tagName)$0(N0)};for(let Q0 of f.children||[])if(Q0&&Q0.tagName)$0(Q0);k.push(...A),w.push(...e)}if(k.length>0)z.detected.add(X0.AUDIO),z.details.audio={count:k.length,hasAutoplay:k.some((f)=>f.hasAttribute("autoplay")),sources:k.map((f)=>({id:f.getAttribute("id"),src:f.getAttribute("src"),isDataUri:(f.getAttribute("src")||"").startsWith("data:"),isExternal:(f.getAttribute("src")||"").startsWith("http")}))};if(w.length>0)z.detected.add(X0.VIDEO),z.details.video={count:w.length,hasAutoplay:w.some((f)=>f.hasAttribute("autoplay"))};let I=q("image"),P=[],u=[];for(let f of I){let A=f.getAttribute("href")||f.getAttribute("xlink:href")||"";if(A.startsWith("http://")||A.startsWith("https://")||A.startsWith("//"))P.push({href:A,element:"image"});else if(A.startsWith("data:"))u.push({type:"data-uri",element:"image"});else if(A&&!A.startsWith("#"))P.push({href:A,element:"image",type:"local"})}if(P.length>0)z.detected.add(X0.EXTERNAL_IMAGES),z.details.externalImages={count:P.length,urls:P.slice(0,5)};let g=q("use"),b=[];for(let f of g){let A=f.getAttribute("href")||f.getAttribute("xlink:href")||"";if(A&&!A.startsWith("#"))b.push({href:A})}if(b.length>0)z.detected.add(X0.EXTERNAL_USE),z.details.externalUse={count:b.length,refs:b.slice(0,5)};let h=!1;for(let f of Y){let A=f.textContent||"";if(A.includes("@font-face")&&A.includes("url(")){let e=A.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(e){h=!0,z.detected.add(X0.EXTERNAL_FONTS),z.details.externalFonts={detected:!0,sample:e[1]};break}}}if(R.length>0){if(z.detected.add(X0.FOREIGN_OBJECT),z.details.foreignObject={count:R.length,hasIframe:R.some((f)=>{let A=!1,e=($0)=>{if($0.tagName?.toLowerCase()==="iframe")A=!0;for(let Q0 of $0.children||[])if(Q0&&Q0.tagName)e(Q0)};return e(f),A})},z.details.foreignObject.hasIframe)z.detected.add(X0.IFRAME)}let v=q("filter"),E=q("mask"),m=q("clippath");if(v.length>0)z.detected.add(X0.FILTERS),z.details.filters={count:v.length};if(E.length>0)z.detected.add(X0.MASKS),z.details.masks={count:E.length};if(m.length>0)z.detected.add(X0.CLIP_PATHS),z.details.clipPaths={count:m.length};let c=q("a");if(c.length>0)z.detected.add(X0.HYPERLINKS),z.details.hyperlinks={count:c.length,hasExternal:c.some((f)=>{return(f.getAttribute("href")||f.getAttribute("xlink:href")||"").startsWith("http")})};let d={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},N={FILE:"file://",HTTP:"http://"},y={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},B={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},t={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},i={[X0.JAVASCRIPT]:{[B.NONE]:{file:"✅",http:"✅",note:"Full JS execution"},[B.IMG]:{file:"❌",http:"❌",note:"All scripting disabled for security"},[B.OBJECT]:{file:"✅",http:"✅",note:"Isolated JS context"},[B.EMBED]:{file:"✅",http:"✅",note:"Isolated JS context"},[B.INLINE]:{file:"✅",http:"✅",note:"Same JS context as parent page"},[B.CSS]:{file:"❌",http:"❌",note:"CSS image context - no scripts"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS-generated = full control"}},[X0.EVENT_HANDLERS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full event handling"},[B.IMG]:{file:"❌",http:"❌",note:"No events in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[B.EMBED]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[B.INLINE]:{file:"✅",http:"✅",note:"Full event handling"},[B.CSS]:{file:"❌",http:"❌",note:"No events in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full event handling"}},[X0.SMIL_ANIMATIONS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.IMG]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[B.OBJECT]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.EMBED]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.INLINE]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.CSS]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full SMIL support"}},[X0.SMIL_INTERACTIVE]:{[B.NONE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[B.IMG]:{file:"❌",http:"❌",note:"No interaction in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[B.EMBED]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[B.INLINE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[B.CSS]:{file:"❌",http:"❌",note:"No interaction in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full interactive SMIL"}},[X0.CSS_ANIMATIONS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.IMG]:{file:"✅",http:"✅",note:"CSS animations work in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.EMBED]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.INLINE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.CSS]:{file:"✅",http:"✅",note:"CSS animations work"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full CSS animation support"}},[X0.AUDIO]:{[B.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[B.IMG]:{file:"❌",http:"❌",note:"No audio in img context"},[B.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[B.CSS]:{file:"❌",http:"❌",note:"No audio in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS can play audio on user gesture"}},[X0.VIDEO]:{[B.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[B.IMG]:{file:"❌",http:"❌",note:"No video in img context"},[B.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[B.CSS]:{file:"❌",http:"❌",note:"No video in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS can play video on user gesture"}},[X0.EXTERNAL_IMAGES]:{[B.NONE]:{file:"⚠️",http:"✅",note:"file:// may have CORS issues"},[B.IMG]:{file:"❌",http:"⚠️",note:"Blocked or CORS restricted"},[B.OBJECT]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.EMBED]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.INLINE]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.CSS]:{file:"❌",http:"⚠️",note:"Restricted for security"},[B.SCRIPT]:{file:"⚠️",http:"✅",note:"CORS applies"}},[X0.EXTERNAL_CSS]:{[B.NONE]:{file:"✅",http:"✅",note:"External CSS loaded"},[B.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"External CSS works"},[B.EMBED]:{file:"✅",http:"✅",note:"External CSS works"},[B.INLINE]:{file:"✅",http:"✅",note:"External CSS works"},[B.CSS]:{file:"❌",http:"❌",note:"No external resources"},[B.SCRIPT]:{file:"✅",http:"✅",note:"External CSS works"}},[X0.EXTERNAL_FONTS]:{[B.NONE]:{file:"✅",http:"✅",note:"External fonts loaded"},[B.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.EMBED]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.INLINE]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.CSS]:{file:"❌",http:"⚠️",note:"Limited, varies by browser"},[B.SCRIPT]:{file:"✅",http:"✅",note:"External fonts work"}},[X0.EXTERNAL_USE]:{[B.NONE]:{file:"❌",http:"⚠️",note:"Most browsers block external use"},[B.IMG]:{file:"❌",http:"❌",note:"No external use in img"},[B.OBJECT]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.EMBED]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.INLINE]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.CSS]:{file:"❌",http:"❌",note:"No external use"},[B.SCRIPT]:{file:"❌",http:"⚠️",note:"Most browsers block"}},[X0.FOREIGN_OBJECT]:{[B.NONE]:{file:"✅",http:"✅",note:"Full foreignObject support"},[B.IMG]:{file:"❌",http:"❌",note:"foreignObject disabled in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"foreignObject works"},[B.EMBED]:{file:"✅",http:"✅",note:"foreignObject works"},[B.INLINE]:{file:"✅",http:"✅",note:"foreignObject works"},[B.CSS]:{file:"❌",http:"❌",note:"foreignObject disabled"},[B.SCRIPT]:{file:"✅",http:"✅",note:"foreignObject works"}},[X0.HYPERLINKS]:{[B.NONE]:{file:"✅",http:"✅",note:"Links work"},[B.IMG]:{file:"❌",http:"❌",note:"No links in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Links work (in iframe-like context)"},[B.EMBED]:{file:"✅",http:"✅",note:"Links work"},[B.INLINE]:{file:"✅",http:"✅",note:"Links work normally"},[B.CSS]:{file:"❌",http:"❌",note:"No links in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Links work"}},[X0.FILTERS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full filter support"},[B.IMG]:{file:"✅",http:"✅",note:"Filters work"},[B.OBJECT]:{file:"✅",http:"✅",note:"Filters work"},[B.EMBED]:{file:"✅",http:"✅",note:"Filters work"},[B.INLINE]:{file:"✅",http:"✅",note:"Filters work"},[B.CSS]:{file:"✅",http:"✅",note:"Filters work"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Filters work"}}},l={"GitHub README.md":{syntax:"IMG (implicit)",restrictions:["No JavaScript","No SMIL","No external resources","No foreignObject","No links"],worksFor:["Static SVG","CSS animations (some)","Embedded images (data-uri)"],note:"GitHub sanitizes SVG heavily - only safe static content"},"GitHub Flavored Markdown (GFM)":{syntax:"IMG",restrictions:["Same as GitHub README"],worksFor:["Static SVG only"],note:"GFM renders SVG as images"},"GitLab README.md":{syntax:"IMG (implicit)",restrictions:["Similar to GitHub but slightly more permissive"],worksFor:["Static SVG","Some CSS animations"],note:"GitLab also sanitizes SVG"},"Wikipedia/MediaWiki":{syntax:"IMG (sanitized)",restrictions:["Heavy sanitization","No scripts","No external resources","No animations"],worksFor:["Static vector graphics only"],note:"MediaWiki converts SVG to PNG for display"},"EPUB 3.x":{syntax:"IMG or INLINE",restrictions:["No external resources","Limited JavaScript","No autoplay"],worksFor:["Static SVG","CSS animations","SMIL (in some readers)"],note:"Support varies by e-reader - Apple Books better than Kindle"},"Email (HTML email)":{syntax:"IMG (base64)",restrictions:["Heavily filtered","No scripts","No external resources","No animations"],worksFor:["Static embedded SVG only","Many clients block SVG entirely"],note:"Most email clients block or rasterize SVG"},"Slack/Discord":{syntax:"IMG (auto-converted)",restrictions:["Converted to raster","No interactivity"],worksFor:["Static preview only"],note:"SVG files are typically converted to PNG previews"},"Twitter/X":{syntax:"N/A",restrictions:["SVG not supported as media"],worksFor:["Nothing - upload as PNG"],note:"Twitter does not support SVG uploads"},Notion:{syntax:"EMBED/IMG",restrictions:["Limited - treated as image"],worksFor:["Static SVG"],note:"Notion embeds SVG as images"},Obsidian:{syntax:"INLINE or IMG",restrictions:["Depends on mode and plugins"],worksFor:["Static SVG","Some CSS animations"],note:"Obsidian has good local SVG support"},"Bear Notes":{syntax:"IMG",restrictions:["Image context only"],worksFor:["Static SVG"],note:"Bear treats SVG as images"},"Markdown-it":{syntax:"IMG (default)",restrictions:["Default IMG behavior","Can be configured for INLINE"],worksFor:["Depends on configuration"],note:"Parser library - output depends on implementation"},MDX:{syntax:"INLINE (JSX)",restrictions:["Full React component - depends on framework"],worksFor:["Full SVG when used as component"],note:"MDX can import SVG as React components"},"iOS Safari":{syntax:"ALL",restrictions:["Stricter autoplay policies"],worksFor:["All standard SVG features except auto-audio"],note:"Good SVG support, strict media policies"},"Android WebView":{syntax:"ALL",restrictions:["Varies by Android version"],worksFor:["Most SVG features"],note:"WebView behavior varies significantly"},"Cairo/librsvg":{syntax:"CUSTOM_RENDERER",restrictions:["Limited JS","Limited SMIL","No foreignObject"],worksFor:["Static SVG","Basic filters","CSS styling"],note:"Server-side rendering library - no dynamic features"},Inkscape:{syntax:"CUSTOM_RENDERER",restrictions:["May not run JS","SMIL playback varies"],worksFor:["All static SVG","Partial animation preview"],note:"Full SVG editor with preview capabilities"},ImageMagick:{syntax:"CUSTOM_RENDERER",restrictions:["Rasterizes immediately","No animations","No JS"],worksFor:["Static rasterization only"],note:"Converts SVG to raster - no dynamic features"}},q0={timestamp:new Date().toISOString(),features:z,interactivityLevel:"static",bySyntax:{},specialCases:{},recommendations:[],warnings:[]};if(z.detected.has(X0.JAVASCRIPT)||z.detected.has(X0.EVENT_HANDLERS))q0.interactivityLevel="scripted";else if(z.detected.has(X0.SMIL_INTERACTIVE))q0.interactivityLevel="interactive";else if(z.detected.has(X0.SMIL_ANIMATIONS)||z.detected.has(X0.CSS_ANIMATIONS))q0.interactivityLevel="animated";for(let f of Object.values(B)){q0.bySyntax[f]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let A of z.detected){let e=i[A];if(e&&e[f]){let{file:$0,http:Q0,note:V0}=e[f];if($0==="✅")q0.bySyntax[f].file.works.push({feature:A,note:V0});else if($0==="⚠️")q0.bySyntax[f].file.partial.push({feature:A,note:V0});else q0.bySyntax[f].file.blocked.push({feature:A,note:V0});if(Q0==="✅")q0.bySyntax[f].http.works.push({feature:A,note:V0});else if(Q0==="⚠️")q0.bySyntax[f].http.partial.push({feature:A,note:V0});else q0.bySyntax[f].http.blocked.push({feature:A,note:V0})}}}for(let[f,A]of Object.entries(l)){let e=[],$0=[];for(let Q0 of z.detected){let N0={[X0.JAVASCRIPT]:"JavaScript",[X0.EVENT_HANDLERS]:"Event handlers",[X0.SMIL_ANIMATIONS]:"SMIL",[X0.SMIL_INTERACTIVE]:"Interactive SMIL",[X0.CSS_ANIMATIONS]:"CSS animations",[X0.AUDIO]:"Audio",[X0.VIDEO]:"Video",[X0.EXTERNAL_IMAGES]:"External images",[X0.EXTERNAL_USE]:"External use",[X0.FOREIGN_OBJECT]:"foreignObject",[X0.HYPERLINKS]:"Links"}[Q0]||Q0;if(A.restrictions.some((o)=>o.toLowerCase().includes(N0.toLowerCase())||o.toLowerCase().includes("no "+N0.toLowerCase())))e.push(N0);else if(A.worksFor.some((J0)=>J0.toLowerCase().includes(N0.toLowerCase())))$0.push(N0)}q0.specialCases[f]={syntax:A.syntax,blockedFeatures:e,workingFeatures:$0,note:A.note,overallCompat:e.length===0?"✅ Compatible":e.length<z.detected.size/2?"⚠️ Partial":"❌ Not compatible"}}if(z.detected.has(X0.AUDIO))q0.recommendations.push({issue:"Audio playback blocked",solution:"Use SCRIPT syntax with user gesture: embed SVG inline, extract audio data-uri via JavaScript, play on click",example:`document.querySelector('svg').addEventListener('click', () => {
|
|
31
31
|
const audio = new Audio(svgAudioDataUri);
|
|
32
32
|
audio.play();
|
|
33
|
-
});`});if(
|
|
33
|
+
});`});if(z.detected.has(X0.SMIL_INTERACTIVE))q0.recommendations.push({issue:"Interactive SMIL animations",solution:"Use OBJECT, EMBED, or INLINE syntax - avoid IMG and CSS background",example:'<object data="animation.svg" type="image/svg+xml"></object>'});if(z.detected.has(X0.JAVASCRIPT))q0.recommendations.push({issue:"JavaScript in SVG",solution:"Use INLINE syntax for same-page JS context, or OBJECT/EMBED for isolated context",example:"<svg><!-- your SVG with scripts --></svg>"});if(z.detected.has(X0.EXTERNAL_IMAGES)||z.detected.has(X0.EXTERNAL_FONTS)||z.detected.has(X0.EXTERNAL_USE))q0.recommendations.push({issue:"External resources",solution:"Embed resources as data-URIs for maximum compatibility, or ensure CORS headers are set",example:"Use svg-toolbox embedExternalDependencies() to inline all resources"});if(q0.interactivityLevel==="scripted")q0.warnings.push("SVG contains JavaScript - will not work in IMG, CSS, or most markdown contexts");if(z.detected.has(X0.FOREIGN_OBJECT))q0.warnings.push("SVG contains foreignObject - disabled in IMG and CSS contexts");if(z.detected.has(X0.EXTERNAL_USE))q0.warnings.push("External <use> references are blocked by most modern browsers");if(K){console.log(`
|
|
34
34
|
`+"═".repeat(100)),console.log("SVG COMPREHENSIVE COMPATIBILITY MATRIX ANALYSIS"),console.log("═".repeat(100)),console.log(`
|
|
35
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ DETECTED SVG FEATURES"+" ".repeat(76)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log(`│ Interactivity Level: ${
|
|
36
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ 5-AXIS COMPATIBILITY MATRIX"+" ".repeat(70)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ SYNTAX TAG │ PROTOCOL │ WORKS │ PARTIAL │ BLOCKED │"),console.log("├────────────────────┼───────────┼────────────────────────────┼──────────────────┼────────────┤");for(let[
|
|
37
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let
|
|
38
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ SPECIAL ENVIRONMENT COMPATIBILITY"+" ".repeat(63)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ ENVIRONMENT │ COMPAT │ BLOCKED FEATURES"+" ".repeat(43)+"│"),console.log("├───────────────────────────┼────────┼"+"─".repeat(61)+"┤");let
|
|
39
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let
|
|
40
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let
|
|
35
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ DETECTED SVG FEATURES"+" ".repeat(76)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log(`│ Interactivity Level: ${q0.interactivityLevel.toUpperCase().padEnd(75)} │`),console.log("│"+" ".repeat(98)+"│");for(let Q0 of z.detected){let V0=z.details[Q0.replace("_","")]||z.details[Q0]||{},N0=Q0;if(V0.count!==void 0)N0+=` (${V0.count})`;console.log(`│ • ${N0.padEnd(92)} │`)}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
36
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ 5-AXIS COMPATIBILITY MATRIX"+" ".repeat(70)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ SYNTAX TAG │ PROTOCOL │ WORKS │ PARTIAL │ BLOCKED │"),console.log("├────────────────────┼───────────┼────────────────────────────┼──────────────────┼────────────┤");for(let[Q0,V0]of Object.entries(q0.bySyntax)){let N0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[Q0]||Q0;for(let h0 of["file","http"]){let o=V0[h0],J0=o.works.length>0?o.works.length+" features":"-",_0=o.partial.length>0?o.partial.length+" features":"-",Y0=o.blocked.length>0?o.blocked.length+" features":"-";console.log(`│ ${N0.padEnd(18)} │ ${(h0+"://").padEnd(9)} │ ${J0.padEnd(26)} │ ${_0.padEnd(16)} │ ${Y0.padEnd(10)} │`)}}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
37
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let f="inline",A=0;for(let[Q0,V0]of Object.entries(q0.bySyntax)){let N0=V0.http.works.length*3+V0.http.partial.length-V0.http.blocked.length*2;if(N0>A)A=N0,f=Q0}let e={none:"Open SVG file directly in browser",img:'<img src="your-file.svg" alt="description">',object:'<object data="your-file.svg" type="image/svg+xml"></object>',embed:'<embed src="your-file.svg" type="image/svg+xml">',inline:"Copy <svg>...</svg> content directly into HTML",css:'.element { background-image: url("your-file.svg"); }',script:'const svgEl = document.createElementNS("http://www.w3.org/2000/svg", "svg"); ...'};if(console.log(`│ BEST: ${f.toUpperCase().padEnd(91)} │`),console.log(`│ ${e[f].substring(0,96).padEnd(96)} │`),console.log("│"+" ".repeat(98)+"│"),q0.interactivityLevel!=="static")console.log("│ AVOID: IMG and CSS background (no interactivity)"+" ".repeat(49)+"│");console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
38
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ SPECIAL ENVIRONMENT COMPATIBILITY"+" ".repeat(63)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ ENVIRONMENT │ COMPAT │ BLOCKED FEATURES"+" ".repeat(43)+"│"),console.log("├───────────────────────────┼────────┼"+"─".repeat(61)+"┤");let $0=["GitHub README.md","EPUB 3.x","Email (HTML email)","Wikipedia/MediaWiki","MDX","Cairo/librsvg","iOS Safari"];for(let Q0 of $0){let V0=q0.specialCases[Q0];if(V0){let N0=V0.overallCompat.substring(0,6).padEnd(6),h0=V0.blockedFeatures.slice(0,3).join(", ").substring(0,58).padEnd(58);console.log(`│ ${Q0.substring(0,25).padEnd(25)} │ ${N0} │ ${h0} │`)}}if(console.log("└"+"─".repeat(98)+"┘"),q0.warnings.length>0){console.log(`
|
|
39
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of q0.warnings)console.log(`│ • ${Q0.substring(0,94).padEnd(94)} │`);console.log("└"+"─".repeat(98)+"┘")}if(q0.recommendations.length>0){console.log(`
|
|
40
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of q0.recommendations)console.log(`│ Issue: ${Q0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${Q0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(z.detected.has(X0.AUDIO))console.log(`
|
|
41
41
|
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDD0A AUDIO PLAYBACK TRUTH TABLE"+" ".repeat(67)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ METHOD │ FILE:// │ HTTP:// │ USER GESTURE NEEDED │ RESULT │"),console.log("├─────────────────────────────────────┼─────────┼─────────┼─────────────────────┼──────────────┤"),console.log("│ SVG direct (autoplay) │ ❌ │ ❌ │ Yes but no trigger │ BLOCKED │"),console.log("│ SVG in <img> │ ❌ │ ❌ │ N/A │ NO AUDIO │"),console.log("│ SVG in <object> │ ❌ │ ❌ │ Yes but isolated │ BLOCKED │"),console.log("│ SVG inline + SMIL onbegin │ ⚠️ │ ⚠️ │ SMIL click trigger │ MAYBE │"),console.log("│ SVG inline + JS on click │ ✅ │ ✅ │ Yes - click event │ WORKS │"),console.log("│ HTML extracts audio, plays on click │ ✅ │ ✅ │ Yes - click event │ RECOMMENDED │"),console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
42
42
|
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCDD AUDIO SOLUTION CODE EXAMPLE"+" ".repeat(66)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ // In your HTML page: │"),console.log('│ <button id="play">Click to Play SVG Audio</button> │'),console.log('│ <object id="svg" data="your-audio.svg" type="image/svg+xml"></object> │'),console.log("│ │"),console.log("│ <script> │"),console.log('│ document.getElementById("play").addEventListener("click", () => { │'),console.log('│ const svgDoc = document.getElementById("svg").contentDocument; │'),console.log('│ const audioSrc = svgDoc.querySelector("source")?.getAttribute("src"); │'),console.log("│ if (audioSrc) new Audio(audioSrc).play(); │"),console.log("│ }); │"),console.log("│ </script> │"),console.log("└"+"─".repeat(98)+"┘");console.log(`
|
|
43
43
|
`+"═".repeat(100)+`
|
|
44
|
-
`)}return
|
|
44
|
+
`)}return $._compatibilityMatrix=q0,$}),xW=F0(($,J={})=>{let Z=J.printFullMatrix||!1,K=J.groupBySyntax!==!1,Q=J.showOnlyIssues!==!1,q=J.browserDetails!==!1,H=J.filterCapabilities||null,W=(o)=>{let J0=[],_0=o.toLowerCase(),Y0=(B0)=>{if(B0.tagName&&B0.tagName.toLowerCase()===_0)J0.push(B0);for(let I0 of B0.children||[])if(I0&&I0.tagName)Y0(I0)};return Y0($),J0},z=(o,J0=[])=>{if(o.tagName)J0.push(o);for(let _0 of o.children||[])if(_0&&_0.tagName)z(_0,J0);return J0},j=new Set,G={},F=z($);if(F.length>1)j.add("RENDER_VECTORS"),j.add("RENDER_TRANSFORMS");let U=W("text").concat(W("tspan"));if(U.length>0)j.add("RENDER_TEXT"),G.RENDER_TEXT={count:U.length};let M=W("linearGradient"),V=W("radialGradient");if(M.length>0||V.length>0)j.add("RENDER_GRADIENTS"),G.RENDER_GRADIENTS={linear:M.length,radial:V.length};let Y=W("pattern");if(Y.length>0)j.add("RENDER_PATTERNS"),G.RENDER_PATTERNS={count:Y.length};for(let o of F)if(o.getAttribute("opacity")||o.getAttribute("fill-opacity")||o.getAttribute("stroke-opacity")||(o.getAttribute("style")||"").includes("opacity")){j.add("RENDER_OPACITY");break}for(let o of F)if((o.getAttribute("style")||"").includes("mix-blend-mode")||o.getAttribute("mix-blend-mode")){j.add("RENDER_BLENDMODES");break}let X=W("style");for(let o of X){let J0=o.textContent||"";if(J0.includes("@font-face")){if(J0.includes("data:"))j.add("FONTS_EMBEDDED");else if(J0.includes("url(")&&J0.match(/url\s*\(\s*['"]?https?:/))j.add("FONTS_WEB_CROSS");else if(J0.includes("url("))j.add("FONTS_WEB_SAME")}}if(U.length>0)j.add("FONTS_SYSTEM");let k=W("image");for(let o of k){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("data:"))j.add("IMAGES_EMBEDDED");else if(J0.startsWith("http://")||J0.startsWith("https://")){let _0=!0;try{let Y0=new URL(J0),B0=new URL($.documentURI||$.baseURI||"");_0=Y0.origin!==B0.origin}catch(Y0){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Y0.message}`);_0=!0}j.add(_0?"IMAGES_REMOTE_CROSS":"IMAGES_REMOTE_SAME")}else if(J0&&!J0.startsWith("#"))j.add("IMAGES_LOCAL")}G.IMAGES={count:k.length};let w=W("filter");if(w.length>0){j.add("FILTERS_BASIC");for(let o of w){let J0=o.outerHTML||"";if(J0.includes("feTurbulence")||J0.includes("feLighting")||J0.includes("feConvolveMatrix")||J0.includes("feDisplacementMap")){j.add("FILTERS_COMPLEX");break}}G.FILTERS={count:w.length}}let R=W("mask");if(R.length>0)j.add("MASKS"),G.MASKS={count:R.length};let I=W("clippath");if(I.length>0)j.add("CLIP_PATHS"),G.CLIP_PATHS={count:I.length};let P=["animate","animatetransform","animatemotion","animatecolor","set"],u=0,g={timed:0,click:0,hover:0,focus:0,accesskey:0,syncbase:0};for(let o of P){let J0=W(o);u+=J0.length;for(let _0 of J0){let Y0=(_0.getAttribute("begin")||"").toLowerCase(),B0=(_0.getAttribute("end")||"").toLowerCase(),I0=Y0+" "+B0;if(I0.includes("click")||I0.includes("dblclick"))g.click++,j.add("SMIL_CLICK");if(I0.includes("mouseover")||I0.includes("mouseout")||I0.includes("mouseenter")||I0.includes("mouseleave"))g.hover++,j.add("SMIL_HOVER");if(I0.includes("focus")||I0.includes("blur"))g.focus++,j.add("SMIL_FOCUS");if(I0.includes("accesskey("))g.accesskey++,j.add("SMIL_ACCESSKEY");if(I0.match(/\w+\.(begin|end)/))g.syncbase++,j.add("SMIL_SYNCBASE");if(!I0.includes("click")&&!I0.includes("mouse")&&!I0.includes("focus")&&!I0.includes("accesskey"))g.timed++}}if(u>0)j.add("SMIL_TIMED"),G.SMIL={count:u,triggers:g};let b=!1,h=!1,v=!1;for(let o of X){let J0=o.textContent||"";if(J0.includes("@keyframes"))b=!0;if(J0.includes("transition:")||J0.includes("transition-property"))h=!0;if(J0.includes(":hover"))v=!0}if(b)j.add("CSS_KEYFRAMES");if(h)j.add("CSS_TRANSITIONS");if(v)j.add("CSS_HOVER");let E=W("script");if(E.length>0){for(let o of E){let J0=o.getAttribute("src")||o.getAttribute("href")||o.getAttribute("xlink:href"),_0=o.getAttribute("type")||"";if(J0)j.add("SCRIPT_EXTERNAL");else j.add("SCRIPT_INLINE");if(_0==="module")j.add("SCRIPT_MODULE")}G.SCRIPTS={count:E.length}}let m=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove"],c={onclick:"EVENT_ONCLICK",ondblclick:"EVENT_ONDBLCLICK",onmousedown:"EVENT_ONMOUSEDOWN",onmouseup:"EVENT_ONMOUSEUP",onmouseover:"EVENT_ONMOUSEOVER",onmouseout:"EVENT_ONMOUSEOUT",onmousemove:"EVENT_ONMOUSEMOVE",onfocus:"EVENT_ONFOCUS",onblur:"EVENT_ONBLUR",onload:"EVENT_ONLOAD",onerror:"EVENT_ONERROR",onscroll:"EVENT_ONSCROLL",onwheel:"EVENT_ONWHEEL",ontouchstart:"EVENT_ONTOUCH",ontouchend:"EVENT_ONTOUCH",ontouchmove:"EVENT_ONTOUCH",onkeydown:"EVENT_ONKEYBOARD",onkeyup:"EVENT_ONKEYBOARD",onkeypress:"EVENT_ONKEYBOARD"};for(let o of F)for(let J0 of m)if(o.getAttribute(J0)){let _0=c[J0];if(_0)j.add(_0)}let d=W("a");if(d.length>0){for(let o of d){if((o.getAttribute("href")||o.getAttribute("xlink:href")||"").startsWith("#"))j.add("LINK_INTERNAL");else j.add("LINK_EXTERNAL");if(o.getAttribute("target"))j.add("LINK_TARGET");if(o.getAttribute("download"))j.add("LINK_DOWNLOAD")}G.LINKS={count:d.length}}let N=W("foreignobject");if(N.length>0){j.add("FOREIGNOBJECT_BASIC"),j.add("FOREIGNOBJECT_HTML");for(let o of N){let J0=(_0)=>{let Y0=_0.tagName?.toLowerCase();if(Y0==="form")j.add("FOREIGNOBJECT_FORM");if(Y0==="input"||Y0==="textarea"||Y0==="select")j.add("FOREIGNOBJECT_INPUT");if(Y0==="canvas")j.add("FOREIGNOBJECT_CANVAS");if(Y0==="video")j.add("FOREIGNOBJECT_VIDEO");if(Y0==="iframe")j.add("FOREIGNOBJECT_IFRAME");for(let B0 of _0.children||[])if(B0&&B0.tagName)J0(B0)};J0(o)}G.FOREIGNOBJECT={count:N.length}}let y=W("audio"),B=W("video");for(let o of N){let J0=(_0)=>{let Y0=_0.tagName?.toLowerCase();if(Y0==="audio")y.push(_0);if(Y0==="video")B.push(_0);for(let B0 of _0.children||[])if(B0&&B0.tagName)J0(B0)};J0(o)}if(y.length>0){for(let o of y){let J0=o.getAttribute("src")||"",_0=W("source").filter((B0)=>B0.parentNode===o),Y0=J0||(_0.length>0?_0[0].getAttribute("src"):"");if(Y0?.startsWith("data:"))j.add("AUDIO_EMBEDDED");else if(Y0?.startsWith("http"))j.add("AUDIO_REMOTE");else if(Y0)j.add("AUDIO_LOCAL");if(o.hasAttribute("autoplay"))j.add("AUDIO_AUTOPLAY");if(o.hasAttribute("controls"))j.add("AUDIO_CONTROLS")}G.AUDIO={count:y.length}}if(B.length>0){for(let o of B){let J0=o.getAttribute("src")||"";if(J0.startsWith("data:"))j.add("VIDEO_EMBEDDED");else if(J0.startsWith("http"))j.add("VIDEO_REMOTE");else if(J0)j.add("VIDEO_LOCAL");if(o.hasAttribute("autoplay"))j.add("VIDEO_AUTOPLAY")}G.VIDEO={count:B.length}}let t=W("use");if(t.length>0){for(let o of t){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("#"))j.add("USE_INTERNAL");else if(J0.startsWith("http"))j.add("USE_EXTERNAL_CROSS");else if(J0)j.add("USE_EXTERNAL_SAME")}j.add("USE_SHADOW_DOM"),G.USE={count:t.length}}for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("aria-")){j.add("A11Y_ARIA");break}if(o.getAttribute("role"))j.add("A11Y_ROLE");if(o.getAttribute("tabindex"))j.add("A11Y_TABINDEX")}if(W("title").length>0||W("desc").length>0)j.add("A11Y_TITLE");for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("data-")){j.add("META_DATA_ATTRS");break}if(o.getAttribute("class"))j.add("META_CLASS");if(o.getAttribute("id"))j.add("META_ID")}for(let o of X)if((o.textContent||"").includes("@import"))j.add("EXT_CSS_IMPORT");for(let o of F)for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("xlink:")){j.add("EXT_XLINK");break}let i={timestamp:new Date().toISOString(),detectedCapabilities:[...j],capabilityDetails:G,totalCombinations:0,combinationsWithIssues:0,cells:[]},l=(o,J0,_0,Y0,B0,I0)=>{let S=UJ[o];if(!S)return{status:L.DEPENDS,note:"No compatibility data",browsers:[]};let C=S.default,n="",p=[];for(let[s,G0]of Object.entries(S.exceptions||{})){let L0=!1;if(s.startsWith("syntax:")){let C0=s.substring(7);if(C0==="*"||C0===B0.id||C0.includes("*")&&B0.id.startsWith(C0.replace("*","")))L0=!0}else if(s.startsWith("load:")){if(s.substring(5)===_0.id)L0=!0}else if(s.startsWith("storage:")){if(s.substring(8)===Y0.id)L0=!0}else if(s.startsWith("display:")){if(s.substring(8)===J0.id)L0=!0}else if(s.startsWith("renderer:")){let C0=s.substring(9);if(C0==="*"&&J0.type==="renderer")L0=!0;if(C0===J0.id)L0=!0}else if(s.startsWith("browser:")){let C0=s.substring(8);if(C0==="*")for(let E0 of Object.values(ZZ))p.push({browser:E0.name,status:G0.status,note:G0.note});else{let E0=Object.values(ZZ).find((k7)=>k7.id===C0);if(E0)p.push({browser:E0.name,status:G0.status,note:G0.note})}}if(L0)C=G0.status,n=G0.note||""}return{status:C,note:n,browserIssues:p}},q0=Object.values(DW),f=Object.values(hW),A=Object.values(yW),e=Object.values(JZ),$0=Object.values(uW);for(let o of q0)for(let J0 of f)for(let _0 of A)for(let Y0 of e)for(let B0 of $0){if(i.totalCombinations++,B0.script&&!["script-inner","script-dom","script-fetch"].includes(Y0.id))continue;if(o.type==="renderer"&&Y0.html)continue;let I0=[],S={};for(let C of j){if(H){let s=Q6[C];if(s&&!H.includes(s.cat))continue}let n=l(C,o,J0,_0,Y0,B0),p=Q6[C]||{name:C,cat:"unknown"};if(S[C]={name:p.name,category:p.cat,status:n.status,note:n.note,browserIssues:n.browserIssues},n.status!==L.WORKS&&n.status!==L.NA)I0.push({capability:C,name:p.name,category:p.cat,status:n.status,note:n.note,browserIssues:n.browserIssues})}if(I0.length>0||!Q){let C={combination:{display:o.name,displayId:o.id,displayType:o.type,load:J0.name,loadId:J0.id,storage:_0.name,storageId:_0.id,syntax:Y0.name,syntaxId:Y0.id,processing:B0.name,processingId:B0.id},issueCount:I0.length,issues:I0,allCapabilities:S};if(i.cells.push(C),I0.length>0)i.combinationsWithIssues++}}console.log(`
|
|
45
45
|
`+"═".repeat(120)),console.log("╔"+"═".repeat(118)+"╗"),console.log("║"+" FULL COMBINATORIAL SVG COMPATIBILITY MATRIX ".padStart(82).padEnd(118)+"║"),console.log("║"+" ALL AXIS COMBINATIONS × ALL CAPABILITIES × ALL BROWSERS ".padStart(88).padEnd(118)+"║"),console.log("╚"+"═".repeat(118)+"╝"),console.log(`
|
|
46
|
-
┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${
|
|
47
|
-
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let
|
|
48
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let
|
|
49
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${
|
|
50
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let
|
|
51
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ ${
|
|
46
|
+
┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${i.totalCombinations.toString().padEnd(80)} │`),console.log(`│ Combinations with issues: ${i.combinationsWithIssues.toString().padEnd(89)} │`),console.log(`│ Detected capabilities in SVG: ${i.detectedCapabilities.length.toString().padEnd(85)} │`),console.log("└"+"─".repeat(118)+"┘"),console.log(`
|
|
47
|
+
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let Q0={};for(let o of j){let J0=Q6[o]||{cat:"unknown",name:o};if(!Q0[J0.cat])Q0[J0.cat]=[];Q0[J0.cat].push({key:o,name:J0.name})}for(let[o,J0]of Object.entries(Q0)){let _0=o.toUpperCase();console.log(`│ ${_0}:`.padEnd(119)+"│");for(let Y0 of J0){let B0=G[Y0.key.split("_")[0]]||{},I0=` • ${Y0.name}`;if(B0.count!==void 0)I0+=` (${B0.count})`;console.log(`│ ${I0}`.padEnd(119)+"│")}}if(console.log("└"+"─".repeat(118)+"┘"),K){console.log(`
|
|
48
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let J0 of i.cells){let _0=J0.combination.syntaxId;if(!o[_0])o[_0]=[];o[_0].push(J0)}for(let[J0,_0]of Object.entries(o)){let Y0=Object.values(JZ).find((S)=>S.id===J0),B0=Y0?Y0.name:J0;console.log(`
|
|
49
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${B0}`.padEnd(119)+"│"),console.log("├"+"─".repeat(30)+"┬"+"─".repeat(20)+"┬"+"─".repeat(25)+"┬"+"─".repeat(40)+"┤"),console.log("│ CONTEXT COMBINATION │ ISSUES │ BLOCKED CAPABILITIES │ BROWSER-SPECIFIC NOTES │"),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(20)+"┼"+"─".repeat(25)+"┼"+"─".repeat(40)+"┤"),_0.sort((S,C)=>C.issueCount-S.issueCount);let I0=Z?_0:_0.slice(0,20);for(let S of I0){let C=`${(S.combination.displayId||"").substring(0,8)}/${S.combination.loadId}/${(S.combination.storageId||"").substring(0,8)}`,n=S.issueCount.toString(),p=S.issues.filter((G0)=>G0.status===L.BLOCKED).map((G0)=>(G0.name||"").substring(0,15)).slice(0,2).join(", "),s=S.issues.flatMap((G0)=>G0.browserIssues||[]).slice(0,2).map((G0)=>`${G0.browser}: ${G0.note?.substring(0,15)||""}`).join("; ");console.log(`│ ${C.padEnd(28)} │ ${n.padEnd(18)} │ ${(p||"-").substring(0,23).padEnd(23)} │ ${(s||"-").substring(0,38).padEnd(38)} │`)}if(!Z&&_0.length>20)console.log(`│ ... and ${_0.length-20} more combinations`.padEnd(119)+"│");console.log("└"+"─".repeat(30)+"┴"+"─".repeat(20)+"┴"+"─".repeat(25)+"┴"+"─".repeat(40)+"┘")}}console.log(`
|
|
50
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of j){let J0=Q6[o]||{name:o,cat:"unknown"},_0=UJ[o];if(console.log(`
|
|
51
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ ${J0.name} (${J0.cat})`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),!_0)console.log("│ No compatibility data available".padEnd(119)+"│");else if(console.log(`│ Default status: ${_0.default}`.padEnd(119)+"│"),Object.keys(_0.exceptions||{}).length>0){console.log("│ Exceptions:".padEnd(119)+"│");for(let[Y0,B0]of Object.entries(_0.exceptions)){let I0=` ${Y0}: ${B0.status} - ${B0.note||"No details"}`;console.log(`│ ${I0.substring(0,116)}`.padEnd(119)+"│")}}console.log("└"+"─".repeat(118)+"┘")}if(q){console.log(`
|
|
52
52
|
╔`+"═".repeat(118)+"╗"),console.log("║ BROWSER-SPECIFIC COMPATIBILITY QUICK REFERENCE"+" ".repeat(70)+"║"),console.log("╚"+"═".repeat(118)+"╝"),console.log(`
|
|
53
|
-
┌`+"─".repeat(14)+"┬"+"─".repeat(103)+"┐"),console.log("│ BROWSER │ KNOWN LIMITATIONS FOR DETECTED CAPABILITIES"+" ".repeat(58)+"│"),console.log("├"+"─".repeat(14)+"┼"+"─".repeat(103)+"┤");let
|
|
54
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let
|
|
55
|
-
<!-- Isolated: --> <object data="app.svg"></object>`});if([...
|
|
56
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ ${
|
|
57
|
-
`).slice(0,3))console.log(`│ ${
|
|
58
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let
|
|
59
|
-
┌`+"─".repeat(25)+"┬"+"─".repeat(10)+"┬"+"─".repeat(81)+"┐"),console.log("│ EMBEDDING METHOD │ SCORE │ ISSUES"+" ".repeat(74)+"│"),console.log("├"+"─".repeat(25)+"┼"+"─".repeat(10)+"┼"+"─".repeat(81)+"┤");for(let[
|
|
60
|
-
⚠️ No embedding methods available for recommendation.`);else{let
|
|
61
|
-
★ RECOMMENDED: Use "${
|
|
53
|
+
┌`+"─".repeat(14)+"┬"+"─".repeat(103)+"┐"),console.log("│ BROWSER │ KNOWN LIMITATIONS FOR DETECTED CAPABILITIES"+" ".repeat(58)+"│"),console.log("├"+"─".repeat(14)+"┼"+"─".repeat(103)+"┤");let o={Chrome:["Full SMIL support","Autoplay policy","External use blocked"],Firefox:["Good SMIL support","Autoplay policy","External use blocked"],Safari:["Full SMIL support","Strict autoplay","WebKit-specific filters"],"Safari iOS":["Full SMIL","VERY strict autoplay","Touch events only"],Edge:["Same as Chrome (Blink)","Autoplay policy","External use blocked"],"IE 11":["NO SMIL","NO blend modes","Limited filters","NO foreignObject scripting"],"Android WebView":["Varies by version","Autoplay restrictions","Limited CSS animations"]};for(let[J0,_0]of Object.entries(o)){let Y0=_0.filter((B0)=>{let I0=B0.toLowerCase();if(I0.includes("smil")&&[...j].some((S)=>S.startsWith("SMIL_")))return!0;if(I0.includes("autoplay")&&j.has("AUDIO_AUTOPLAY"))return!0;if(I0.includes("blend")&&j.has("RENDER_BLENDMODES"))return!0;if(I0.includes("filter")&&(j.has("FILTERS_BASIC")||j.has("FILTERS_COMPLEX")))return!0;if(I0.includes("foreign")&&[...j].some((S)=>S.startsWith("FOREIGNOBJECT_")))return!0;if(I0.includes("external use")&&(j.has("USE_EXTERNAL_SAME")||j.has("USE_EXTERNAL_CROSS")))return!0;return!1});if(Y0.length>0){let B0=Y0.slice(0,3).join(", ");console.log(`│ ${J0.padEnd(12)} │ ${B0.substring(0,101).padEnd(101)} │`)}}console.log("└"+"─".repeat(14)+"┴"+"─".repeat(103)+"┘")}console.log(`
|
|
54
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let V0=[];if(j.has("AUDIO_AUTOPLAY")||j.has("AUDIO_EMBEDDED")||j.has("AUDIO_LOCAL")||j.has("AUDIO_REMOTE"))V0.push({feature:"Audio Playback",issue:"Browser autoplay policies block automatic audio",bestSyntax:"INLINE-SVG with JavaScript",workaround:"Extract audio data-URI, create Audio object, play on user click gesture",code:"document.querySelector('svg').addEventListener('click', () => new Audio(dataUri).play());"});if(j.has("SMIL_CLICK")||j.has("SMIL_HOVER")||j.has("SMIL_FOCUS")||j.has("SMIL_ACCESSKEY"))V0.push({feature:"Interactive SMIL Animation",issue:"Blocked in <img>, CSS backgrounds, and most renderers",bestSyntax:"<object>, <embed>, <iframe>, or inline <svg>",workaround:"Avoid <img> and CSS embedding for interactive SVGs",code:'<object data="animation.svg" type="image/svg+xml" width="800" height="600"></object>'});if(j.has("SCRIPT_INLINE")||j.has("SCRIPT_EXTERNAL"))V0.push({feature:"JavaScript Execution",issue:"Completely blocked in <img>, CSS contexts, email, most social platforms",bestSyntax:"Inline <svg> or <object>/<embed>/<iframe>",workaround:"For widest compatibility, convert JS interactions to SMIL or CSS",code:`<!-- Inline: --> <div><svg>...</svg></div>
|
|
55
|
+
<!-- Isolated: --> <object data="app.svg"></object>`});if([...j].some((o)=>o.startsWith("FOREIGNOBJECT_")))V0.push({feature:"foreignObject / HTML Content",issue:"Completely ignored in <img>, CSS contexts, most renderers (Cairo, ImageMagick)",bestSyntax:"Inline <svg> or <object>/<embed>",workaround:"For rasterization, use browser screenshot or Puppeteer instead of ImageMagick",code:'<object data="with-html.svg" type="image/svg+xml"></object>'});if(j.has("IMAGES_REMOTE_CROSS")||j.has("FONTS_WEB_CROSS")||j.has("USE_EXTERNAL_CROSS")||j.has("AUDIO_REMOTE"))V0.push({feature:"Cross-Origin Resources",issue:"Blocked without CORS headers, completely blocked in <img> context",bestSyntax:"Any syntax with proper CORS, or embed resources as data-URIs",workaround:"Use embedExternalDependencies() to inline all external resources",code:"await embedExternalDependencies(doc, { embedImages: true, embedFonts: true, embedAudio: true });"});for(let o of V0){console.log(`
|
|
56
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ ${o.feature}`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Issue: ${o.issue}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Best syntax: ${o.bestSyntax}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Workaround: ${o.workaround}`.substring(0,119).padEnd(119)+"│"),console.log("│ Code:".padEnd(119)+"│");for(let J0 of(o.code||"").split(`
|
|
57
|
+
`).slice(0,3))console.log(`│ ${J0}`.substring(0,119).padEnd(119)+"│");console.log("└"+"─".repeat(118)+"┘")}console.log(`
|
|
58
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let N0={};for(let o of e){let J0=100,_0=[];for(let Y0 of j){let B0=Q6[Y0]||{name:Y0,critical:!1},I0=UJ[Y0];if(I0){for(let[S,C]of Object.entries(I0.exceptions||{}))if(S.startsWith("syntax:")){let n=S.substring(7);if(n===o.id||n==="*"||n.includes("*")&&o.id.startsWith(n.replace("*",""))){let p=B0.critical?30:10;J0-=p,_0.push({cap:B0.name,penalty:p,status:C.status})}}}}N0[o.id]={name:o.name,score:Math.max(0,J0),deductions:_0}}let h0=Object.entries(N0).sort((o,J0)=>J0[1].score-o[1].score);console.log(`
|
|
59
|
+
┌`+"─".repeat(25)+"┬"+"─".repeat(10)+"┬"+"─".repeat(81)+"┐"),console.log("│ EMBEDDING METHOD │ SCORE │ ISSUES"+" ".repeat(74)+"│"),console.log("├"+"─".repeat(25)+"┼"+"─".repeat(10)+"┼"+"─".repeat(81)+"┤");for(let[o,J0]of h0){let _0=J0.score===100?"100% ✅":J0.score>=70?`${J0.score}% ⚠️`:`${J0.score}% ❌`,Y0=J0.deductions.slice(0,3).map((B0)=>B0.cap).join(", ")||"None";console.log(`│ ${J0.name.padEnd(23)} │ ${_0.padEnd(8)} │ ${Y0.substring(0,79).padEnd(79)} │`)}if(console.log("└"+"─".repeat(25)+"┴"+"─".repeat(10)+"┴"+"─".repeat(81)+"┘"),h0.length===0)console.log(`
|
|
60
|
+
⚠️ No embedding methods available for recommendation.`);else{let o=h0[0];if(console.log(`
|
|
61
|
+
★ RECOMMENDED: Use "${o[1].name}" for this SVG (score: ${o[1].score}%)`),o[1].score<100)console.log(`
|
|
62
62
|
⚠️ No embedding method achieves 100% compatibility for this SVG.`),console.log(" Consider using embedExternalDependencies() to maximize portability.")}return console.log(`
|
|
63
63
|
`+"═".repeat(120)+`
|
|
64
|
-
`)
|
|
65
|
-
`),console.log("╔"+"═".repeat(160)+"╗"),console.log("║"+" HIERARCHICAL SVG COMPATIBILITY MATRIX - DETAILED ".padStart(105).padEnd(160)+"║"),console.log("║"+` ${
|
|
66
|
-
`);let
|
|
67
|
-
┌`+"─".repeat(120)+"┐"),console.log("│ LEGEND - HOW TO READ CELL CONTENT"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(120)+"┤"),console.log("│ Each cell shows 2 lines:"+" ".repeat(95)+"│"),console.log("│ Line 1: Browser status (C=Chrome F=Firefox S=Safari E=Edge I=IE11 i=iOS A=Android)"+" ".repeat(34)+"│"),console.log("│ Line 2: Functionality issues (codes below)"+" ".repeat(74)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ Status symbols: ✓ = works ⚠ = warning/partial ✗ = blocked/broken"+" ".repeat(49)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ ✅ ALL OK = No issues in this combination"+" ".repeat(78)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FUNCTIONALITY CODES:"+" ".repeat(99)+"│");let
|
|
68
|
-
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let
|
|
69
|
-
┌`+"─".repeat(30)+"┬"+"─".repeat(
|
|
70
|
-
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 3: BROWSER-SPECIFIC ISSUES FOR DETECTED CAPABILITIES ".padStart(90).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let
|
|
71
|
-
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let
|
|
64
|
+
`),$._fullCompatibilityMatrix=i,$});function mW($,J={}){let Z=J.compact!==!1,K=J.showAllCells||!1,Q=[{id:"direct",label:"DIRECT",desc:"SVG file"},{id:"img",label:"IMG",desc:"<img>"},{id:"object",label:"OBJECT",desc:"<object>"},{id:"embed",label:"EMBED",desc:"<embed>"},{id:"inline",label:"INLINE",desc:"<svg>"},{id:"css",label:"CSS",desc:"bg-image"}],q=[{id:"embedded",label:"EMB",desc:"data-uri/inline"},{id:"local",label:"LOC",desc:"local path"},{id:"remote",label:"REM",desc:"http(s) URL"}],H=[{id:"browser",label:"BROWSER",desc:"Desktop browsers"},{id:"mobile",label:"MOBILE",desc:"Mobile WebView"},{id:"renderer",label:"RENDER",desc:"Server-side"}],W=[{id:"file",label:"file://",desc:"Local filesystem"},{id:"http",label:"http(s)://",desc:"Web server"},{id:"data",label:"data:",desc:"Data URI"}],z=[{id:"script",label:"+JS",desc:"With JavaScript"},{id:"noscript",label:"-JS",desc:"No JavaScript"}],j=[{id:"chrome",code:"C",name:"Chrome"},{id:"firefox",code:"F",name:"Firefox"},{id:"safari",code:"S",name:"Safari"},{id:"edge",code:"E",name:"Edge"},{id:"ie11",code:"I",name:"IE11"},{id:"ios",code:"i",name:"iOS Safari"},{id:"android",code:"A",name:"Android"}],G={display:{icon:"D",emoji:"\uD83D\uDCD0",name:"Basic rendering"},animation:{icon:"A",emoji:"\uD83C\uDFAC",name:"SMIL/CSS animation"},scripting:{icon:"J",emoji:"\uD83D\uDCDC",name:"JavaScript"},events:{icon:"E",emoji:"\uD83D\uDDB1️",name:"Event handlers"},media:{icon:"M",emoji:"\uD83D\uDD0A",name:"Audio/Video"},html:{icon:"H",emoji:"\uD83D\uDCC4",name:"foreignObject"},images:{icon:"I",emoji:"\uD83D\uDDBC️",name:"External images"},fonts:{icon:"T",emoji:"\uD83D\uDD24",name:"External fonts"},sprites:{icon:"U",emoji:"\uD83C\uDFAF",name:"use elements"},links:{icon:"L",emoji:"\uD83D\uDD17",name:"Hyperlinks"}},F=Q.length*q.length,_=H.length*W.length*z.length,U=Z?18:28,M=25,V=Z?2:3;console.log(`
|
|
65
|
+
`),console.log("╔"+"═".repeat(160)+"╗"),console.log("║"+" HIERARCHICAL SVG COMPATIBILITY MATRIX - DETAILED ".padStart(105).padEnd(160)+"║"),console.log("║"+` ${F} columns × ${_} rows = ${F*_} cells `.padStart(105).padEnd(160)+"║"),console.log("║"+" Each cell shows: [Browser status] / [Functionality issues] ".padStart(105).padEnd(160)+"║"),console.log("╚"+"═".repeat(160)+"╝"),console.log(`
|
|
66
|
+
`);let Y=q.length*U,X=26+Q.length*(Y+1),k="".padEnd(25)+"│";for(let N of Q){let y=`${N.label} (${N.desc})`;k+=y.padStart(Math.floor(Y/2)+Math.floor(y.length/2)).padEnd(Y)+"│"}console.log("┌"+"─".repeat(25)+"┬"+Q.map(()=>"─".repeat(Y)).join("┬")+"┐"),console.log("│"+"SYNTAX →".padEnd(25)+k.substring(26));let w="".padEnd(25)+"│";for(let N of Q){for(let y of q){let B=`${y.label}`;w+=B.padStart(Math.floor(U/2)+Math.floor(B.length/2)).padEnd(U)}w+="│"}console.log("│"+"STORAGE →".padEnd(25)+w.substring(26));let R="".padEnd(25)+"│";for(let N of Q){for(let y of q)R+="Brws|Func".padStart(Math.floor(U/2)+5).padEnd(U);R+="│"}console.log("│"+"".padEnd(25)+R.substring(26)),console.log("├"+"─".repeat(25)+"┼"+Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼")+"┤");let I=(N,y,B,t,i)=>{let l={browserStatus:{},funcStatus:{},overallStatus:"ok",issueCount:0,browserCount:0};for(let e of j){l.browserStatus[e.id]={};for(let[$0]of Object.entries(G))l.browserStatus[e.id][$0]="ok"}for(let[e]of Object.entries(G))l.funcStatus[e]="ok";if(t==="img"||t==="css"){let e=["animation","scripting","events","html","media","links"];for(let $0 of e){l.funcStatus[$0]="block";for(let Q0 of j)l.browserStatus[Q0.id][$0]="block"}if(B==="remote"){l.funcStatus.images="block",l.funcStatus.fonts="block";for(let $0 of j)l.browserStatus[$0.id].images="block",l.browserStatus[$0.id].fonts="block"}}if(N==="renderer"){let e=["animation","scripting","events","media"];for(let $0 of e){l.funcStatus[$0]="block";for(let Q0 of j)l.browserStatus[Q0.id][$0]="block"}l.funcStatus.html="block";for(let $0 of j)l.browserStatus[$0.id].html="block"}if(i==="noscript"){l.funcStatus.scripting="block",l.funcStatus.events="warn";for(let e of j)l.browserStatus[e.id].scripting="block",l.browserStatus[e.id].events="warn"}if(l.browserStatus.ie11.animation="block",l.browserStatus.ie11.html="block",l.browserStatus.ie11.sprites="warn",$.detectedCapabilities?.some((e)=>e.startsWith("AUDIO_")||e.startsWith("VIDEO_"))){for(let e of j)if(l.browserStatus[e.id].media!=="block")l.browserStatus[e.id].media="warn";l.browserStatus.ios.media="block",l.funcStatus.media="warn"}if(B==="remote"){l.funcStatus.images=l.funcStatus.images==="block"?"block":"warn",l.funcStatus.fonts=l.funcStatus.fonts==="block"?"block":"warn",l.funcStatus.sprites=l.funcStatus.sprites==="block"?"block":"warn";for(let e of j){if(l.browserStatus[e.id].images!=="block")l.browserStatus[e.id].images="warn";if(l.browserStatus[e.id].fonts!=="block")l.browserStatus[e.id].fonts="warn"}}if(y==="file"){if(B==="remote")l.funcStatus.images="warn",l.funcStatus.fonts="warn",l.funcStatus.links="warn"}if(y==="data"){if(B==="remote"||B==="local")l.funcStatus.images="warn",l.funcStatus.fonts="warn"}let q0=!1,f=!1,A=new Set;for(let[e,$0]of Object.entries(l.funcStatus))if($0==="block")q0=!0,l.issueCount++;else if($0==="warn")f=!0,l.issueCount++;for(let e of j)for(let[$0,Q0]of Object.entries(l.browserStatus[e.id]))if(Q0!=="ok")A.add(e.id);return l.browserCount=A.size,l.overallStatus=q0?"block":f?"warn":"ok",l},P=(N,y)=>{let B=[],t={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return B.push("✅ ALL OK".padStart(Math.floor(y/2)+5).padEnd(y)),B.push("".padEnd(y)),B;let i="";for(let q0 of j){let f="ok";for(let[A,e]of Object.entries(N.browserStatus[q0.id]))if(e==="block"){f="block";break}else if(e==="warn"&&f!=="block")f="warn";i+=`${q0.code}${t[f]}`}B.push(i.padStart(Math.floor(y/2)+Math.floor(i.length/2)).padEnd(y));let l="";for(let[q0,f]of Object.entries(G)){let A=N.funcStatus[q0];if(A!=="ok")l+=`${f.icon}${t[A]}`}if(l==="")l="(ok)";return B.push(l.padStart(Math.floor(y/2)+Math.floor(l.length/2)).padEnd(y)),B},u=(N,y)=>{let B={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return"✅".padStart(Math.floor(y/2)+1).padEnd(y);let t=N.overallStatus==="block"?"❌":"⚠️",i=`${N.browserCount}B`,l=`${N.issueCount}F`,q0=`${t}${i}${l}`;return q0.padStart(Math.floor(y/2)+Math.floor(q0.length/2)).padEnd(y)};for(let N of H){let y=Q.map(()=>q.map(()=>" ".repeat(U)).join(" ")).join("│");console.log("│ "+(N.label+":").padEnd(23)+"│"+y+"│");for(let B of W){for(let t of z){let i=[];for(let $0 of Q)for(let Q0 of q){let V0=I(N.id,B.id,Q0.id,$0.id,t.id);i.push(V0)}let l=i.map(($0)=>P($0,U)),f="│"+` ${B.label} ${t.label}`.padEnd(25)+"│",A=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<q.length;Q0++)f+=l[A][0],A++;f+="│"}console.log(f.substring(0,f.length-1));let e="│"+"".padEnd(25)+"│";A=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<q.length;Q0++)e+=l[A][1],A++;e+="│"}if(console.log(e.substring(0,e.length-1)),t!==z[z.length-1]){let $0=Q.map(()=>q.map(()=>"·".repeat(U)).join("·")).join("│");console.log("│"+"·".repeat(25)+"│"+$0+"│")}}if(B!==W[W.length-1]){let t=Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼");console.log("├"+"─".repeat(25)+"┼"+t+"┤")}}if(N!==H[H.length-1]){let B=Q.map(()=>q.map(()=>"═".repeat(U)).join("═")).join("╪");console.log("╞"+"═".repeat(25)+"╪"+B+"╡")}}console.log("└"+"─".repeat(25)+"┴"+Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┴")+"┘"),console.log(`
|
|
67
|
+
┌`+"─".repeat(120)+"┐"),console.log("│ LEGEND - HOW TO READ CELL CONTENT"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(120)+"┤"),console.log("│ Each cell shows 2 lines:"+" ".repeat(95)+"│"),console.log("│ Line 1: Browser status (C=Chrome F=Firefox S=Safari E=Edge I=IE11 i=iOS A=Android)"+" ".repeat(34)+"│"),console.log("│ Line 2: Functionality issues (codes below)"+" ".repeat(74)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ Status symbols: ✓ = works ⚠ = warning/partial ✗ = blocked/broken"+" ".repeat(49)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ ✅ ALL OK = No issues in this combination"+" ".repeat(78)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FUNCTIONALITY CODES:"+" ".repeat(99)+"│");let g="│ ";for(let[N,y]of Object.entries(G))g+=`${y.icon}=${N} `;console.log(g.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FULL FUNCTIONALITY NAMES:"+" ".repeat(94)+"│");let b="│ ";for(let[N,y]of Object.entries(G))b+=`${y.icon}=${y.name} `;if(b.length>120)console.log(b.substring(0,121)+"│"),b="│ "+b.substring(121);console.log(b.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ EXAMPLES:"+" ".repeat(110)+"│"),console.log('│ "C✓F✓S✓E⚠I✗i✗A✓" = Chrome/Firefox/Safari/Android OK, Edge warning, IE11/iOS blocked'+" ".repeat(30)+"│"),console.log('│ "A✗J✗M⚠H✗" = Animation blocked, Scripting blocked, Media warning, HTML blocked'+" ".repeat(37)+"│"),console.log("└"+"─".repeat(120)+"┘"),console.log(`
|
|
68
|
+
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let h=[{id:"images_embedded",label:"Embedded Images (data-uri)",icon:"\uD83D\uDDBC️"},{id:"images_local",label:"Local Images (path)",icon:"\uD83D\uDCC1"},{id:"images_remote",label:"Remote Images (URL)",icon:"\uD83C\uDF10"},{id:"fonts_embedded",label:"Embedded Fonts (data-uri)",icon:"\uD83D\uDD24"},{id:"fonts_local",label:"Local Fonts (path)",icon:"\uD83D\uDCC1"},{id:"fonts_remote",label:"Remote Fonts (URL)",icon:"\uD83C\uDF10"},{id:"css_inline",label:"Inline <style>",icon:"\uD83C\uDFA8"},{id:"css_external",label:"External CSS",icon:"\uD83D\uDCC4"},{id:"scripts_inline",label:"Inline <script>",icon:"\uD83D\uDCDC"},{id:"scripts_external",label:"External Scripts",icon:"\uD83D\uDCE6"},{id:"audio_embedded",label:"Embedded Audio",icon:"\uD83D\uDD0A"},{id:"audio_external",label:"External Audio",icon:"\uD83C\uDFB5"}],v=14,E="".padEnd(30)+"│";for(let N of Q)E+=N.label.padStart(v-1).padEnd(v);E+="│",console.log(`
|
|
69
|
+
┌`+"─".repeat(30)+"┬"+"─".repeat(Q.length*v)+"┐"),console.log("│"+"RESOURCE TYPE".padEnd(30)+E.substring(31)),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(Q.length*v)+"┤");let m=(N,y)=>{if(y==="img"||y==="css"){if(N.includes("external")||N.includes("remote")||N.includes("scripts")||N.includes("audio"))return"❌";if(N.includes("local")&&!N.includes("embedded"))return"⚠️"}if(y==="object"||y==="embed"){if(N.includes("remote")&&!N.includes("embedded"))return"⚠️"}if(N.includes("embedded")||N.includes("inline"))return"✅";if(N.includes("local"))return"⚠️";if(N.includes("remote")||N.includes("external"))return"⚠️";return"✅"};for(let N of h){let y=`│ ${N.icon} ${N.label}`.padEnd(31)+"│";for(let B of Q){let t=m(N.id,B.id);y+=t.padStart(v-1).padEnd(v)}y+="│",console.log(y)}console.log("└"+"─".repeat(30)+"┴"+"─".repeat(Q.length*v)+"┘"),console.log(`
|
|
70
|
+
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 3: BROWSER-SPECIFIC ISSUES FOR DETECTED CAPABILITIES ".padStart(90).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let c={};for(let N of $.detectedCapabilities||[]){let y={RENDER_:"display",FONTS_:"fonts",IMAGES_:"images",FILTERS_:"effects",MASKS:"effects",CLIP_:"effects",SMIL_:"animation",CSS_:"animation",SCRIPT_:"scripting",EVENT_:"events",LINK_:"links",FOREIGNOBJECT_:"html",AUDIO_:"media",VIDEO_:"media",USE_:"sprites",A11Y_:"accessibility",META_:"metadata"};for(let[B,t]of Object.entries(y))if(N.startsWith(B)||N===B.replace("_","")){if(!c[t])c[t]=[];c[t].push(N);break}}console.log(`
|
|
71
|
+
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let d={animation:{Chrome:"Full SMIL support",IE11:"NO SMIL SUPPORT",Safari:"Full support"},media:{ALL:"Autoplay blocked - needs user gesture",iOS:"VERY strict autoplay policy"},html:{IE11:"No scripting in foreignObject",Cairo:"Not rendered",ImageMagick:"Not rendered"},scripting:{IE11:"Limited ES6 support"},effects:{IE11:"Limited filter support, no blend modes"}};for(let[N,y]of Object.entries(c)){let B=d[N]||{},t=Object.entries(B).map(([i,l])=>`${i}: ${l}`).join("; ")||"No known issues";console.log(`│ ${N.toUpperCase().padEnd(18)} │ ${t.substring(0,97).padEnd(97)} │`)}return console.log("└"+"─".repeat(20)+"┴"+"─".repeat(99)+"┘"),console.log(`
|
|
72
72
|
`+"═".repeat(140)+`
|
|
73
|
-
`)
|
|
74
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
75
|
-
viewBox="0 0 ${E} ${C}" preserveAspectRatio="xMinYMin meet" height="${C}" width="100%">
|
|
73
|
+
`),$}function dW($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(t)=>String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Q=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],q=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],H=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],W=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],z=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],j=(t,i,l,q0)=>{let f=[],A=(e)=>f.push({text:e});if(q0==="img"||q0==="css")return A("No scripts"),A("No events"),A("No audio/video"),A("No links"),A("No foreignObject"),A("No external resources"),f;if(l==="nojs")A("No scripts"),A("No event handlers");if(i==="file")A("No remote fonts (Chrome, Safari)"),A("No remote images (Chrome)"),A("No fetch/XHR to remote URLs");if(q0==="object"||q0==="embed"){if(A("No event bubbling to parent"),i==="http")A("No cross-origin script access")}if(t==="desktop"){if(A("No SMIL (IE11 only)"),A("No CSS variables (IE11 only)"),l==="js")A("Audio: blocked until user click/tap event"),A("Audio: once blocked, won't auto-retry")}if(t==="mobile")A("No hover/mouseover events"),A("Audio: blocked until user tap event"),A("Audio: once blocked, won't auto-retry"),A("Video autoplay blocked");return f},G=0;for(let t of q)for(let i of W)for(let l of z)for(let q0 of Q){let f=j(t.id,i.id,l.id,q0.id).length;if(f>G)G=f}let F=130,_=80,U=90,M=F+_+U,V=60,Y=220,X=13,k=Math.max(80,(G+1)*X+25),w=Q.length,R=q.length*W.length*z.length,I=M+w*Y,u=V+R*k+40,g=30,b=40+H.length*g,h=u+b+30,v=1020,E=I+50,m=55+h+v+50,c=`<?xml version="1.0" encoding="UTF-8"?>
|
|
74
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${E} ${m}" preserveAspectRatio="xMinYMin meet" height="${m}" width="100%">
|
|
76
75
|
<title>SVG Compatibility Matrix</title>
|
|
77
|
-
<desc>Browser and functionality compatibility for different SVG embedding methods</desc>
|
|
78
76
|
|
|
79
77
|
<defs>
|
|
80
78
|
<style>
|
|
81
|
-
.title { font: bold
|
|
82
|
-
.subtitle { font: 12px ${
|
|
83
|
-
.col-header { font: bold
|
|
84
|
-
.col-
|
|
85
|
-
.row-
|
|
86
|
-
.row-
|
|
87
|
-
.cell-text { font: 8px ${r}; fill: #333; }
|
|
88
|
-
.cell-ok { fill: #E8F5E9; }
|
|
89
|
-
.cell-warn { fill: #FFF3E0; }
|
|
90
|
-
.cell-block { fill: #FFEBEE; }
|
|
91
|
-
.legend-text { font: 10px ${r}; fill: #333; }
|
|
92
|
-
.grid-line { stroke: #DDD; stroke-width: 1; }
|
|
93
|
-
.grid-line-bold { stroke: #999; stroke-width: 2; }
|
|
94
|
-
${l?`
|
|
95
|
-
.cell-group:hover rect { stroke: #333; stroke-width: 2; }
|
|
96
|
-
.tooltip { pointer-events: none; opacity: 0; transition: opacity 0.2s; }
|
|
97
|
-
.cell-group:hover .tooltip { opacity: 1; }
|
|
98
|
-
`:""}
|
|
99
|
-
</style>
|
|
100
|
-
</defs>
|
|
101
|
-
|
|
102
|
-
<!-- Title -->
|
|
103
|
-
<text x="${E/2}" y="25" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
|
|
104
|
-
<text x="${E/2}" y="42" text-anchor="middle" class="subtitle">
|
|
105
|
-
${y} columns × ${v} rows = ${y*v} combinations
|
|
106
|
-
</text>
|
|
107
|
-
|
|
108
|
-
<g transform="translate(20, 55)">
|
|
109
|
-
`,B=140;for(let d of o){let Y=x.length*e;f+=` <rect x="${B}" y="0" width="${Y}" height="25" fill="#E3F2FD" stroke="#90CAF9"/>
|
|
110
|
-
<text x="${B+Y/2}" y="17" text-anchor="middle" class="col-header">${d.label}</text>
|
|
111
|
-
`;for(let X=0;X<x.length;X++){let F=x[X],V=B+X*e;f+=` <rect x="${V}" y="25" width="${e}" height="20" fill="#F5F5F5" stroke="#DDD"/>
|
|
112
|
-
<text x="${V+e/2}" y="39" text-anchor="middle" class="col-subheader">${F.label}</text>
|
|
113
|
-
`}B+=Y}let R=45;for(let d of p){let Y=n.length*c.length*i;f+=` <rect x="0" y="${R}" width="50" height="${Y}" fill="#E8EAF6" stroke="#9FA8DA"/>
|
|
114
|
-
<text x="25" y="${R+Y/2}" text-anchor="middle" dominant-baseline="middle" class="row-header" transform="rotate(-90, 25, ${R+Y/2})">${d.label}</text>
|
|
115
|
-
`;for(let X of n)for(let F of c){f+=` <rect x="50" y="${R}" width="90" height="${i}" fill="#FAFAFA" stroke="#EEE"/>
|
|
116
|
-
<text x="55" y="${R+i/2-6}" class="row-subheader">${X.label}</text>
|
|
117
|
-
<text x="55" y="${R+i/2+8}" class="row-subheader">${F.label}</text>
|
|
118
|
-
`,B=140;for(let V of o)for(let T of x){let j=S(d.id,X.id,T.id,V.id,F.id),A=`cell-${j.overallStatus}`,z="";for(let K of s){let $="ok";for(let G of m){let a3=j.browserStatus[K.id][G.id];if(a3==="block"){$="block";break}else if(a3==="warn"&&$!=="block")$="warn"}let w=$==="ok"?"✓":$==="warn"?"⚠":"✗";z+=`${K.code}${w}`}let i3="";for(let K of m){let $=j.funcStatus[K.id];if($!=="ok")i3+=`${K.code}${$==="warn"?"⚠":"✗"}`}if(!i3)i3="OK";if(f+=` <g class="cell-group">
|
|
119
|
-
<rect x="${B}" y="${R}" width="${e}" height="${i}" class="${A}" stroke="#DDD"/>
|
|
120
|
-
<text x="${B+e/2}" y="${R+15}" text-anchor="middle" class="cell-text">${z.substring(0,10)}</text>
|
|
121
|
-
<text x="${B+e/2}" y="${R+28}" text-anchor="middle" class="cell-text">${z.substring(10)}</text>
|
|
122
|
-
<text x="${B+e/2}" y="${R+40}" text-anchor="middle" class="cell-text" fill="${P[j.overallStatus]}">${i3.substring(0,8)}</text>
|
|
123
|
-
`,l)f+=` <g class="tooltip" transform="translate(${B+e/2}, ${R-5})">
|
|
124
|
-
<rect x="-60" y="-45" width="120" height="40" fill="#333" rx="4"/>
|
|
125
|
-
<text x="0" y="-30" text-anchor="middle" fill="#FFF" font-size="9">${V.label}/${T.label}</text>
|
|
126
|
-
<text x="0" y="-17" text-anchor="middle" fill="#FFF" font-size="8">${d.label} ${X.label} ${F.label}</text>
|
|
127
|
-
</g>
|
|
128
|
-
`;f+=` </g>
|
|
129
|
-
`,B+=e}R+=i}}let k=80+v*i+20;f+=`
|
|
130
|
-
<!-- Legend -->
|
|
131
|
-
<g transform="translate(0, ${k})">
|
|
132
|
-
<text x="10" y="15" class="col-header">LEGEND</text>
|
|
133
|
-
|
|
134
|
-
<!-- Status colors -->
|
|
135
|
-
<rect x="10" y="25" width="20" height="15" class="cell-ok" stroke="#4CAF50"/>
|
|
136
|
-
<text x="35" y="37" class="legend-text">OK - All features work</text>
|
|
137
|
-
|
|
138
|
-
<rect x="160" y="25" width="20" height="15" class="cell-warn" stroke="#FF9800"/>
|
|
139
|
-
<text x="185" y="37" class="legend-text">Warning - Partial support</text>
|
|
140
|
-
|
|
141
|
-
<rect x="340" y="25" width="20" height="15" class="cell-block" stroke="#F44336"/>
|
|
142
|
-
<text x="365" y="37" class="legend-text">Blocked - Not supported</text>
|
|
143
|
-
|
|
144
|
-
<!-- Browser codes -->
|
|
145
|
-
<text x="10" y="60" class="col-header">BROWSERS:</text>
|
|
146
|
-
`;let N=90;for(let d of s)f+=` <text x="${N}" y="60" class="legend-text"><tspan fill="${d.color}" font-weight="bold">${d.code}</tspan>=${d.name}</text>
|
|
147
|
-
`,N+=85;f+=`
|
|
148
|
-
<!-- Functionality codes -->
|
|
149
|
-
<text x="10" y="80" class="col-header">FUNCTIONS:</text>
|
|
150
|
-
`,N=90;let I=0;for(let d of m){if(N>600)N=90,I++;f+=` <text x="${N}" y="${80+I*18}" class="legend-text"><tspan fill="${d.color}" font-weight="bold">${d.code}</tspan>=${d.name}</text>
|
|
151
|
-
`,N+=100}return f+=` </g>
|
|
152
|
-
</g>
|
|
153
|
-
</svg>`,f}function Bo(t,a={}){let e=a.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",i=(A)=>String(A).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),r=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],l=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],o=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],x=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],p=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],n=(A,z,i3,K)=>{let $=[],w=(G)=>$.push({text:G});if(K==="img"||K==="css")return w("No scripts"),w("No events"),w("No audio/video"),w("No links"),w("No foreignObject"),w("No external resources"),$;if(i3==="nojs")w("No scripts"),w("No event handlers");if(z==="file")w("No remote fonts (Chrome, Safari)"),w("No remote images (Chrome)"),w("No fetch/XHR to remote URLs");if(K==="object"||K==="embed"){if(w("No event bubbling to parent"),z==="http")w("No cross-origin script access")}if(A==="desktop"){if(w("No SMIL (IE11 only)"),w("No CSS variables (IE11 only)"),i3==="js")w("Audio: blocked until user click/tap event"),w("Audio: once blocked, won't auto-retry")}if(A==="mobile")w("No hover/mouseover events"),w("Audio: blocked until user tap event"),w("Audio: once blocked, won't auto-retry"),w("Video autoplay blocked");return $},c=0;for(let A of l)for(let z of x)for(let i3 of p)for(let K of r){let $=n(A.id,z.id,i3.id,K.id).length;if($>c)c=$}let s=130,m=80,g=90,u=s+m+g,y=60,v=220,E=13,C=Math.max(80,(c+1)*E+25),P=r.length,S=l.length*x.length*p.length,f=u+P*v,B=y+S*C+40,R=30,k=40+o.length*R,N=B+k+30,I=1020,d=f+50,Y=55+N+I+50,X=`<?xml version="1.0" encoding="UTF-8"?>
|
|
154
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${d} ${Y}" preserveAspectRatio="xMinYMin meet" height="${Y}" width="100%">
|
|
155
|
-
<title>SVG Compatibility Matrix</title>
|
|
156
|
-
|
|
157
|
-
<defs>
|
|
158
|
-
<style>
|
|
159
|
-
.title { font: bold 20px ${e}; fill: #1a1a1a; }
|
|
160
|
-
.subtitle { font: 12px ${e}; fill: #666; }
|
|
161
|
-
.col-header { font: bold 12px ${e}; fill: #FFF; }
|
|
162
|
-
.col-desc { font: 10px ${e}; fill: rgba(255,255,255,0.85); }
|
|
163
|
-
.row-label { font: 11px ${e}; fill: #333; }
|
|
164
|
-
.row-label-bold { font: bold 11px ${e}; fill: #1a1a1a; }
|
|
79
|
+
.title { font: bold 20px ${Z}; fill: #1a1a1a; }
|
|
80
|
+
.subtitle { font: 12px ${Z}; fill: #666; }
|
|
81
|
+
.col-header { font: bold 12px ${Z}; fill: #FFF; }
|
|
82
|
+
.col-desc { font: 10px ${Z}; fill: rgba(255,255,255,0.85); }
|
|
83
|
+
.row-label { font: 11px ${Z}; fill: #333; }
|
|
84
|
+
.row-label-bold { font: bold 11px ${Z}; fill: #1a1a1a; }
|
|
165
85
|
.cell-ok { fill: #C8E6C9; }
|
|
166
86
|
.cell-warn { fill: #FFF9C4; }
|
|
167
87
|
.cell-bad { fill: #FFCDD2; }
|
|
168
|
-
.ok-text { font: bold 13px ${
|
|
169
|
-
.problem-text { font: 10px ${
|
|
170
|
-
.legend-title { font: bold 11px ${
|
|
171
|
-
.legend-text { font: 10px ${
|
|
88
|
+
.ok-text { font: bold 13px ${Z}; fill: #2E7D32; }
|
|
89
|
+
.problem-text { font: 10px ${Z}; fill: #333; }
|
|
90
|
+
.legend-title { font: bold 11px ${Z}; fill: #333; }
|
|
91
|
+
.legend-text { font: 10px ${Z}; fill: #444; }
|
|
172
92
|
</style>
|
|
173
93
|
</defs>
|
|
174
94
|
|
|
175
|
-
<text x="${
|
|
176
|
-
<text x="${
|
|
95
|
+
<text x="${E/2}" y="24" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
|
|
96
|
+
<text x="${E/2}" y="42" text-anchor="middle" class="subtitle">What problems will your SVG have in each configuration?</text>
|
|
177
97
|
|
|
178
98
|
<g transform="translate(25, 55)">
|
|
179
|
-
`,
|
|
180
|
-
<text x="${
|
|
181
|
-
<text x="${
|
|
182
|
-
`,
|
|
183
|
-
<text x="${
|
|
184
|
-
`;for(let
|
|
185
|
-
<text x="${
|
|
186
|
-
<text x="${
|
|
187
|
-
`,
|
|
188
|
-
<text x="${
|
|
189
|
-
`;for(let
|
|
190
|
-
<text x="${
|
|
191
|
-
`;for(let
|
|
192
|
-
<text x="${
|
|
193
|
-
`,
|
|
194
|
-
`,
|
|
195
|
-
<text x="${
|
|
196
|
-
`;else{let
|
|
197
|
-
`,
|
|
198
|
-
`}
|
|
199
|
-
<text x="0" y="${
|
|
200
|
-
`;let
|
|
201
|
-
<text x="10" y="${
|
|
202
|
-
`;let
|
|
203
|
-
`,
|
|
204
|
-
<g transform="translate(0, ${
|
|
99
|
+
`,d=M;c+=` <rect x="${d}" y="0" width="${Y}" height="${V}" fill="${Q[0].color}" stroke="#1565C0"/>
|
|
100
|
+
<text x="${d+Y/2}" y="25" text-anchor="middle" class="col-header">${K(Q[0].name)}</text>
|
|
101
|
+
<text x="${d+Y/2}" y="42" text-anchor="middle" class="col-desc">${K(Q[0].desc)}</text>
|
|
102
|
+
`,d+=Y;let N=(Q.length-1)*Y;c+=` <rect x="${d}" y="0" width="${N}" height="25" fill="#0D47A1"/>
|
|
103
|
+
<text x="${d+N/2}" y="17" text-anchor="middle" class="col-header">In HTML Page</text>
|
|
104
|
+
`;for(let t=1;t<Q.length;t++){let i=Q[t];c+=` <rect x="${d}" y="25" width="${Y}" height="${V-25}" fill="${i.color}" stroke="#1976D2"/>
|
|
105
|
+
<text x="${d+Y/2}" y="42" text-anchor="middle" class="col-header">${K(i.name)}</text>
|
|
106
|
+
<text x="${d+Y/2}" y="55" text-anchor="middle" class="col-desc">${K(i.desc)}</text>
|
|
107
|
+
`,d+=Y}let y=V;for(let t of q){let i=W.length*z.length*k;c+=` <rect x="0" y="${y}" width="${F}" height="${i}" fill="${t.color}" stroke="#999"/>
|
|
108
|
+
<text x="${F/2}" y="${y+i/2+4}" text-anchor="middle" class="row-label-bold">${K(t.name)}</text>
|
|
109
|
+
`;for(let l of W){let q0=z.length*k;c+=` <rect x="${F}" y="${y}" width="${_}" height="${q0}" fill="${l.color}" stroke="#CCC"/>
|
|
110
|
+
<text x="${F+_/2}" y="${y+q0/2+4}" text-anchor="middle" class="row-label">${K(l.name)}</text>
|
|
111
|
+
`;for(let f of z){c+=` <rect x="${F+_}" y="${y}" width="${U}" height="${k}" fill="${f.color}" stroke="#DDD"/>
|
|
112
|
+
<text x="${F+_+U/2}" y="${y+k/2+4}" text-anchor="middle" class="row-label">${K(f.name)}</text>
|
|
113
|
+
`,d=M;for(let A of Q){let e=j(t.id,l.id,f.id,A.id),$0="cell-ok";if(e.length>=4)$0="cell-bad";else if(e.length>0)$0="cell-warn";if(c+=` <rect x="${d}" y="${y}" width="${Y}" height="${k}" class="${$0}" stroke="#DDD"/>
|
|
114
|
+
`,e.length===0)c+=` <text x="${d+Y/2}" y="${y+k/2-5}" text-anchor="middle" class="ok-text">No issues</text>
|
|
115
|
+
<text x="${d+Y/2}" y="${y+k/2+12}" text-anchor="middle" class="problem-text" style="fill:#388E3C">Everything works</text>
|
|
116
|
+
`;else{let Q0=y+16;for(let V0 of e){let N0=`• ${V0.text||"Unknown issue"}`;c+=` <text x="${d+8}" y="${Q0}" class="problem-text">${K(N0)}</text>
|
|
117
|
+
`,Q0+=X}}d+=Y}y+=k}}c+=` <line x1="0" y1="${y}" x2="${I}" y2="${y}" stroke="#999" stroke-width="2"/>
|
|
118
|
+
`}c+=`
|
|
119
|
+
<text x="0" y="${u}" class="legend-title">SERVER-SIDE SVG RENDERERS (no HTML embedding)</text>
|
|
120
|
+
`;let B=u+20;for(let t of H){c+=` <rect x="0" y="${B}" width="150" height="${g-4}" fill="${t.color}" stroke="#999"/>
|
|
121
|
+
<text x="10" y="${B+18}" class="row-label-bold">${K(t.name)}</text>
|
|
122
|
+
`;let i=t.issues.join(" • ");c+=` <text x="160" y="${B+18}" class="problem-text">${K(i)}</text>
|
|
123
|
+
`,B+=g}return c+=`
|
|
124
|
+
<g transform="translate(0, ${h})">
|
|
205
125
|
<text x="0" y="0" class="legend-title">LEGEND</text>
|
|
206
126
|
|
|
207
127
|
<rect x="0" y="15" width="18" height="14" class="cell-ok" stroke="#4CAF50"/>
|
|
@@ -289,59 +209,59 @@ ${o}
|
|
|
289
209
|
<text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
|
|
290
210
|
</g>
|
|
291
211
|
</g>
|
|
292
|
-
</svg>`,
|
|
293
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
|
|
294
|
-
<title>${
|
|
212
|
+
</svg>`,c}function WK($){let{title:J="Data Table",subtitle:Z="",columns:K=[],rowLevels:Q=[],rowData:q=[],getCellContent:H=()=>({lines:[],status:"ok"}),legend:W=null,additionalSections:z=[],options:j={}}=$,G={fontFamily:j.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:j.minCellWidth||150,maxCellWidth:j.maxCellWidth||300,minCellHeight:j.minCellHeight||60,cellPaddingX:j.cellPaddingX||8,cellPaddingY:j.cellPaddingY||12,titleFontSize:j.titleFontSize||20,subtitleFontSize:j.subtitleFontSize||12,headerFontSize:j.headerFontSize||12,cellFontSize:j.cellFontSize||10,lineHeight:j.lineHeight||13,titleColor:j.titleColor||"#1a1a1a",subtitleColor:j.subtitleColor||"#666",borderColor:j.borderColor||"#DDD",okColor:j.okColor||"#C8E6C9",warnColor:j.warnColor||"#FFF9C4",badColor:j.badColor||"#FFCDD2",okTextColor:j.okTextColor||"#2E7D32",colHeaderHeight:j.colHeaderHeight||60,marginTop:j.marginTop||55,marginLeft:j.marginLeft||25,marginRight:j.marginRight||25,marginBottom:j.marginBottom||50,sectionSpacing:j.sectionSpacing||40,groupHeaderHeight:j.groupHeaderHeight||25,groupHeaderColor:j.groupHeaderColor||"#0D47A1"},F=(f)=>String(f).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),_=(f,A=0,e=[])=>{let $0=[];for(let Q0 of f){let V0=[...e,{level:A,...Q0}];if(Q0.children&&Q0.children.length>0&&A<Q.length-1)$0.push(..._(Q0.children,A+1,V0));else $0.push(V0)}return $0},U=_(q[0]||[]),M=U.length,V=Q.length,Y=Q.map((f,A)=>{if(f.width)return f.width;let e=f.name.length,$0=(Q0,V0)=>{for(let N0 of Q0){if(V0===A)e=Math.max(e,(N0.name||"").length);if(N0.children)$0(N0.children,V0+1)}};return $0(q[0]||[],0),Math.max(60,e*7+20)}),X=Y.reduce((f,A)=>f+A,0),k=0,w=0;for(let f of U)for(let A of K){let $0=H(f,A.id).lines||[];k=Math.max(k,$0.length);for(let Q0 of $0)w=Math.max(w,Q0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,w*6+G.cellPaddingX*2)),I=Math.max(G.minCellHeight,(k+1)*G.lineHeight+G.cellPaddingY*2),P=[],u=null;for(let f=0;f<K.length;f++){let A=K[f];if(A.group)if(!u||u.name!==A.group)u={name:A.group,startIndex:f,count:1,color:A.groupColor||G.groupHeaderColor},P.push(u);else u.count++;else u=null}let g=P.length>0,b=g?G.colHeaderHeight+G.groupHeaderHeight:G.colHeaderHeight,h=X+K.length*R,v=b+M*I,E=0;for(let f of z)E+=G.sectionSpacing+(f.height||100);let m=W?j.legendHeight||200:0,c=h+G.marginLeft+G.marginRight,d=G.marginTop+v+E+(W?G.sectionSpacing+m:0)+G.marginBottom,N=`<?xml version="1.0" encoding="UTF-8"?>
|
|
213
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${d}" preserveAspectRatio="xMinYMin meet" height="${d}" width="100%">
|
|
214
|
+
<title>${F(J)}</title>
|
|
295
215
|
|
|
296
216
|
<defs>
|
|
297
217
|
<style>
|
|
298
|
-
.title { font: bold ${
|
|
299
|
-
.subtitle { font: ${
|
|
300
|
-
.col-header { font: bold ${
|
|
301
|
-
.col-desc { font: ${
|
|
302
|
-
.row-label { font: ${
|
|
303
|
-
.row-label-bold { font: bold ${
|
|
304
|
-
.cell-ok { fill: ${
|
|
305
|
-
.cell-warn { fill: ${
|
|
306
|
-
.cell-bad { fill: ${
|
|
307
|
-
.ok-text { font: bold ${
|
|
308
|
-
.cell-text { font: ${
|
|
309
|
-
.section-title { font: bold ${
|
|
310
|
-
.legend-text { font: ${
|
|
218
|
+
.title { font: bold ${G.titleFontSize}px ${G.fontFamily}; fill: ${G.titleColor}; }
|
|
219
|
+
.subtitle { font: ${G.subtitleFontSize}px ${G.fontFamily}; fill: ${G.subtitleColor}; }
|
|
220
|
+
.col-header { font: bold ${G.headerFontSize}px ${G.fontFamily}; fill: #FFF; }
|
|
221
|
+
.col-desc { font: ${G.cellFontSize}px ${G.fontFamily}; fill: rgba(255,255,255,0.85); }
|
|
222
|
+
.row-label { font: ${G.headerFontSize-1}px ${G.fontFamily}; fill: #333; }
|
|
223
|
+
.row-label-bold { font: bold ${G.headerFontSize-1}px ${G.fontFamily}; fill: #1a1a1a; }
|
|
224
|
+
.cell-ok { fill: ${G.okColor}; }
|
|
225
|
+
.cell-warn { fill: ${G.warnColor}; }
|
|
226
|
+
.cell-bad { fill: ${G.badColor}; }
|
|
227
|
+
.ok-text { font: bold ${G.lineHeight}px ${G.fontFamily}; fill: ${G.okTextColor}; }
|
|
228
|
+
.cell-text { font: ${G.cellFontSize}px ${G.fontFamily}; fill: #333; }
|
|
229
|
+
.section-title { font: bold ${G.headerFontSize}px ${G.fontFamily}; fill: #333; }
|
|
230
|
+
.legend-text { font: ${G.cellFontSize}px ${G.fontFamily}; fill: #444; }
|
|
311
231
|
</style>
|
|
312
232
|
</defs>
|
|
313
233
|
|
|
314
|
-
<text x="${
|
|
315
|
-
${
|
|
316
|
-
|
|
317
|
-
<g transform="translate(${
|
|
318
|
-
`,
|
|
319
|
-
<text x="${
|
|
320
|
-
`}}let
|
|
321
|
-
<text x="${
|
|
322
|
-
`,
|
|
323
|
-
`}let
|
|
324
|
-
<text x="${
|
|
325
|
-
`,
|
|
326
|
-
`,
|
|
327
|
-
`;else{let
|
|
328
|
-
`,
|
|
329
|
-
`}}let
|
|
330
|
-
<text x="0" y="${
|
|
331
|
-
|
|
332
|
-
${
|
|
234
|
+
<text x="${c/2}" y="24" text-anchor="middle" class="title">${F(J)}</text>
|
|
235
|
+
${Z?`<text x="${c/2}" y="42" text-anchor="middle" class="subtitle">${F(Z)}</text>`:""}
|
|
236
|
+
|
|
237
|
+
<g transform="translate(${G.marginLeft}, ${G.marginTop})">
|
|
238
|
+
`,y=X;if(g){let f=0;for(let A=0;A<K.length&&!K[A].group;A++)f++;for(let A of P){let e=X+A.startIndex*R,$0=A.count*R;N+=` <rect x="${e}" y="0" width="${$0}" height="${G.groupHeaderHeight}" fill="${A.color}"/>
|
|
239
|
+
<text x="${e+$0/2}" y="${G.groupHeaderHeight-8}" text-anchor="middle" class="col-header">${F(A.name)}</text>
|
|
240
|
+
`}}let B=g?G.groupHeaderHeight:0,t=g?G.colHeaderHeight:b;for(let f=0;f<K.length;f++){let A=K[f],e=X+f*R,$0=A.group?B:0,Q0=A.group?t:b;if(N+=` <rect x="${e}" y="${$0}" width="${R}" height="${Q0}" fill="${A.color}" stroke="${G.borderColor}"/>
|
|
241
|
+
<text x="${e+R/2}" y="${$0+Q0/2-5}" text-anchor="middle" class="col-header">${F(A.name)}</text>
|
|
242
|
+
`,A.desc)N+=` <text x="${e+R/2}" y="${$0+Q0/2+10}" text-anchor="middle" class="col-desc">${F(A.desc)}</text>
|
|
243
|
+
`}let i=new Map,l=b;for(let f=0;f<U.length;f++){let A=U[f],e=0;for(let $0=0;$0<V;$0++){let Q0=A.find((N0)=>N0.level===$0);if(!Q0){e+=Y[$0];continue}let V0=`${$0}-${Q0.id}`;if(!i.has(V0)){let N0=1;for(let o=f+1;o<U.length;o++){let J0=U[o].find((_0)=>_0.level===$0);if(J0&&J0.id===Q0.id)N0++;else break}let h0=N0*I;N+=` <rect x="${e}" y="${l}" width="${Y[$0]}" height="${h0}" fill="${Q0.color||"#F5F5F5"}" stroke="${G.borderColor}"/>
|
|
244
|
+
<text x="${e+Y[$0]/2}" y="${l+h0/2+4}" text-anchor="middle" class="${$0===0?"row-label-bold":"row-label"}">${F(Q0.name)}</text>
|
|
245
|
+
`,i.set(V0,{y:l,height:h0})}e+=Y[$0]}for(let $0=0;$0<K.length;$0++){let Q0=K[$0],V0=X+$0*R,N0=H(A,Q0.id),h0=N0.lines||[],o=N0.status||"ok";if(N+=` <rect x="${V0}" y="${l}" width="${R}" height="${I}" class="${o==="bad"?"cell-bad":o==="warn"?"cell-warn":"cell-ok"}" stroke="${G.borderColor}"/>
|
|
246
|
+
`,h0.length===0)N+=` <text x="${V0+R/2}" y="${l+I/2}" text-anchor="middle" class="ok-text">No issues</text>
|
|
247
|
+
`;else{let _0=l+G.cellPaddingY+G.lineHeight;for(let Y0 of h0)N+=` <text x="${V0+G.cellPaddingX}" y="${_0}" class="cell-text">${F("• "+Y0)}</text>
|
|
248
|
+
`,_0+=G.lineHeight}}if(l+=I,f<U.length-1){let $0=A[0]?.id,Q0=U[f+1][0]?.id;if($0!==Q0)N+=` <line x1="0" y1="${l}" x2="${h}" y2="${l}" stroke="#999" stroke-width="2"/>
|
|
249
|
+
`}}let q0=v+G.sectionSpacing;for(let f of z){if(f.title)N+=`
|
|
250
|
+
<text x="0" y="${q0}" class="section-title">${F(f.title)}</text>
|
|
251
|
+
`,q0+=20;if(f.content)N+=` <g transform="translate(0, ${q0})">
|
|
252
|
+
${f.content}
|
|
333
253
|
</g>
|
|
334
|
-
`;if(
|
|
335
|
-
`;if(
|
|
336
|
-
`}
|
|
337
|
-
<g transform="translate(0, ${
|
|
338
|
-
${
|
|
254
|
+
`;if(f.items)for(let A of f.items){if(A.rect)N+=` <rect x="${A.rect.x}" y="${q0+A.rect.y}" width="${A.rect.width}" height="${A.rect.height}" fill="${A.rect.fill||"#EEE"}" stroke="${A.rect.stroke||"#999"}"/>
|
|
255
|
+
`;if(A.text)N+=` <text x="${A.text.x}" y="${q0+A.text.y}" class="${A.text.class||"legend-text"}">${F(A.text.content)}</text>
|
|
256
|
+
`}q0+=f.height||100}if(W)N+=`
|
|
257
|
+
<g transform="translate(0, ${q0})">
|
|
258
|
+
${W}
|
|
339
259
|
</g>
|
|
340
|
-
`;return
|
|
341
|
-
</svg>`,
|
|
342
|
-
<text x="10" y="${
|
|
343
|
-
<text x="160" y="${
|
|
344
|
-
`,
|
|
260
|
+
`;return N+=` </g>
|
|
261
|
+
</svg>`,N}function pW($={}){let J=$.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",Z=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0"},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",group:"In HTML Page",groupColor:"#0D47A1"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",group:"In HTML Page"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",group:"In HTML Page"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",group:"In HTML Page"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",group:"In HTML Page"}],K=[{id:"environment",name:"Environment",width:130},{id:"protocol",name:"Protocol",width:80},{id:"script",name:"JavaScript",width:90}],Q=[[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]}]],q=$.getCellContent||((G,F)=>{return{lines:[],status:"ok"}}),H=[{name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],W="",z=0;for(let G of H)W+=`<rect x="0" y="${z}" width="150" height="26" fill="${G.color}" stroke="#999"/>
|
|
262
|
+
<text x="10" y="${z+18}" class="row-label-bold">${G.name}</text>
|
|
263
|
+
<text x="160" y="${z+18}" class="cell-text">${G.issues.join(" • ")}</text>
|
|
264
|
+
`,z+=30;let j=`
|
|
345
265
|
<text x="0" y="0" class="section-title">LEGEND</text>
|
|
346
266
|
|
|
347
267
|
<rect x="0" y="15" width="18" height="14" class="cell-ok" stroke="#4CAF50"/>
|
|
@@ -427,15 +347,15 @@ ${o}
|
|
|
427
347
|
<text x="0" y="963" class="legend-text">2. Set ALL animations AND audio to begin="mySvg.click"</text>
|
|
428
348
|
<text x="0" y="979" class="legend-text">3. User clicks anywhere on SVG → user activation satisfied → audio plays → animations start</text>
|
|
429
349
|
<text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
|
|
430
|
-
`;return W9({title:"SVG Compatibility Matrix",subtitle:"What problems will your SVG have in each configuration?",columns:e,rowLevels:i,rowData:r,getCellContent:l,additionalSections:[{title:"SERVER-SIDE SVG RENDERERS (no HTML embedding)",content:x,height:o.length*30+20}],legend:n,options:{fontFamily:a,minCellWidth:220,legendHeight:1020,...t}})}var z9=p3((t,a={})=>{let e=a.fixInvalidGroupAttrs!==!1,i=a.fixMissingNamespaces!==!1,r=a.fixBrokenRefs!==!1,l=a.fixAnimationTiming!==!1,o=a.verbose||!1,x=[],p=new Set,n=(O)=>{let D=O.getAttribute("id");if(D)p.add(D);for(let W of O.children)if(Z(W))n(W)};n(t);let c=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],s=new Set(["svg","rect","image","foreignObject","use","symbol","pattern","mask","filter","clipPath"]),m=(O)=>{let D=O.tagName.toLowerCase();if(D==="g"&&e){for(let W of c)if(O.hasAttribute(W)){let _=O.getAttribute(W);O.removeAttribute(W),x.push({type:"invalid_attr_removed",element:D,attr:W,value:_,reason:`SVG 1.1: <g> elements do not support '${W}' attribute`})}}for(let W of O.children)if(Z(W))m(W)},g=()=>{if(!i)return;let O=!1,D=(W)=>{for(let _ of W.getAttributeNames())if(_.startsWith("xlink:")){O=!0;return}for(let _ of W.children){if(Z(_))D(_);if(O)return}};if(D(t),O&&!t.hasAttribute("xmlns:xlink"))t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),x.push({type:"namespace_added",namespace:"xmlns:xlink",value:"http://www.w3.org/1999/xlink",reason:"SVG 1.1: xmlns:xlink required when xlink:* attributes are present"})},u=(O)=>{let D=[O,O.replace(/^FRAME(\d+)$/,"FRAME0$1"),O.replace(/^FRAME0(\d+)$/,"FRAME00$1"),O.replace(/^FRAME00(\d+)$/,"FRAME000$1"),O.replace(/^FRAME0+(\d+)$/,"FRAME$1"),O.replace(/^FRAME(\d)$/,"FRAME0000$1"),O.replace(/^FRAME(\d{2})$/,"FRAME000$1"),O.replace(/^FRAME(\d{3})$/,"FRAME00$1"),O.replace(/^FRAME(\d{4})$/,"FRAME0$1")];for(let H of D)if(p.has(H)&&H!==O)return H;let W=null,_=1/0;for(let H of p)if(H.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(H.toLowerCase())){let m3=Math.abs(H.length-O.length);if(m3<_&&m3<=2)_=m3,W=H}return W},y=(O)=>{if(!r)return;for(let D of["href","xlink:href"]){let W=O.getAttribute(D);if(W&&W.startsWith("#")){let _=W.substring(1);if(!p.has(_)){let H=u(_);if(H)O.setAttribute(D,`#${H}`),x.push({type:"ref_fixed",element:O.tagName.toLowerCase(),attr:D,oldValue:W,newValue:`#${H}`,reason:`ID '${_}' not found, fixed to similar ID '${H}'`})}}}if(O.tagName.toLowerCase()==="animate"){let D=O.getAttribute("attributeName");if(D==="href"||D==="xlink:href"){let W=O.getAttribute("values");if(W){let _=W.split(";"),H=!1,m3=_.map((P3)=>{let B3=P3.trim();if(B3.startsWith("#")){let I3=B3.substring(1);if(!p.has(I3)){let A4=u(I3);if(A4)return H=!0,`#${A4}`}}return B3});if(H){let P3=m3.join(";");O.setAttribute("values",P3),x.push({type:"animate_values_fixed",oldValue:W,newValue:P3,reason:"Fixed broken ID references in animate values"})}}}}for(let D of["fill","stroke","clip-path","mask","filter"]){let W=O.getAttribute(D);if(W&&W.startsWith("url(#")){let _=W.match(/url\(#([^)]+)\)/);if(_){let H=_[1];if(!p.has(H)){let m3=u(H);if(m3)O.setAttribute(D,`url(#${m3})`),x.push({type:"url_ref_fixed",element:O.tagName.toLowerCase(),attr:D,oldValue:W,newValue:`url(#${m3})`,reason:`ID '${H}' not found, fixed to similar ID '${m3}'`})}}}}for(let D of O.children)if(Z(D))y(D)},v=(O)=>{if(!l)return;let D=["animate","animateTransform","animateMotion","animateColor","set"],W=O.tagName.toLowerCase();if(D.includes(W)){let _=O.getAttribute("dur"),H=O.getAttribute("repeatCount");if(_==="0"||_==="0s"){if(!O.getAttribute("keyTimes"))x.push({type:"timing_warning",element:W,attr:"dur",value:_,reason:'dur="0" may cause animation to not play'})}let m3=O.getAttribute("begin");if(m3){let P3=m3;if(m3==="0")P3="0s",O.setAttribute("begin",P3),x.push({type:"timing_normalized",element:W,attr:"begin",oldValue:m3,newValue:P3,reason:"Normalized begin value to include time unit"})}}for(let _ of O.children)if(Z(_))v(_)},E=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),C=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),P=(O)=>{let D=O.tagName.toLowerCase();if(E.has(D)){let W=[];for(let _ of Array.from(O.children))if(Z(_)&&C.has(_.tagName.toLowerCase()))W.push(_);if(W.length>0){let _=O.getAttribute("id");if(!_)_=`_fix_${D}_${Math.random().toString(36).substring(2,8)}`,O.setAttribute("id",_),x.push({type:"id_generated",element:D,id:_,reason:"Generated ID for animation targeting after moving animate element"});for(let H of W){if(O.removeChild(H),!H.hasAttribute("href")&&!H.hasAttribute("xlink:href"))H.setAttribute("href",`#${_}`);let m3=O.parentNode;if(m3){let P3=O.nextSibling;if(P3)m3.insertBefore(H,P3);else m3.appendChild(H)}x.push({type:"animation_moved_from_empty_element",element:H.tagName.toLowerCase(),parentElement:D,targetId:_,reason:`SVG 1.1: <${D}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${_}".`})}}}for(let W of Array.from(O.children))if(Z(W))P(W)},S=/^([+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?)(EM|EX|PX|IN|CM|MM|PT|PC|DEG|GRAD|RAD|S|MS|HZ|KHZ|%)$/i,f=new Set(["x","y","width","height","rx","ry","cx","cy","r","fx","fy","x1","y1","x2","y2","dx","dy","textLength","startOffset","stroke-width","stroke-dashoffset","font-size","baseline-shift","kerning","letter-spacing","word-spacing","markerWidth","markerHeight","refX","refY","stdDeviation","radius"]),B=(O)=>{for(let D of O.getAttributeNames()){if(!f.has(D)&&!D.includes("-"))continue;let W=O.getAttribute(D);if(!W)continue;let _=W.match(S);if(_){let[,H,m3]=_,P3=m3.toLowerCase();if(m3!==P3){let B3=H+P3;O.setAttribute(D,B3),x.push({type:"unit_normalized",element:O.tagName.toLowerCase(),attr:D,oldValue:W,newValue:B3,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let D of O.children)if(Z(D))B(D)},R=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,k=new Set(["points","viewBox","preserveAspectRatio","transform","d","values","keyTimes","keySplines","keyPoints","rotate","stroke-dasharray","baseFrequency","kernelMatrix","tableValues","filterRes","stdDeviation","radius","origin"]),N=(O)=>{for(let D of O.getAttributeNames()){if(!k.has(D)&&D!=="style")continue;let W=O.getAttribute(D);if(!W)continue;if(R.test(W)){let _=W.replace(R," ");O.setAttribute(D,_),x.push({type:"whitespace_normalized",element:O.tagName.toLowerCase(),attr:D,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let D of O.children)if(Z(D))N(D)},I=(O)=>{for(let D of O.getAttributeNames()){let W=O.getAttribute(D);if(!W)continue;let _=W,H=!1;if(/\d\.$/.test(_)||/\d\.(?=[,\s;)])/.test(_))_=_.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),H=!0;if(_=_.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),_=_.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),_!==W)H=!0;if(/\.\.+/.test(_))_=_.replace(/\.\.+/g,"."),H=!0;if(H)O.setAttribute(D,_),x.push({type:"number_format_fixed",element:O.tagName.toLowerCase(),attr:D,oldValue:W,newValue:_,reason:"SVG 1.1: Fixed invalid number format"})}for(let D of O.children)if(Z(D))I(D)},d=340000000000000000000000000000000000000,Y=-340000000000000000000000000000000000000,X=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,F=(O)=>{for(let D of O.getAttributeNames()){let W=O.getAttribute(D);if(!W)continue;if(D==="id"||D==="class"||D.startsWith("xmlns")||D==="href"||D==="xlink:href"||D==="style")continue;let _=W.match(X);if(!_)continue;for(let H of _){let m3=parseFloat(H);if(!isFinite(m3))x.push({type:"invalid_number_detected",element:O.tagName.toLowerCase(),attr:D,value:H,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(m3>d||m3<Y)x.push({type:"out_of_range_detected",element:O.tagName.toLowerCase(),attr:D,value:H,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let D of O.children)if(Z(D))F(D)},V=(O)=>{let D=O.tagName,W=D.toLowerCase();if(D.includes(":")||l5.has(D)||g2.has(W));else{let _=h5(D,l5);if(_)x.push({type:"mistyped_element_detected",element:D,suggestion:_,reason:`Unknown element <${D}> - did you mean <${_}>?`});else x.push({type:"unknown_element_detected",element:D,reason:`Unknown element <${D}> - not in SVG 1.1 spec`})}for(let _ of O.children)if(Z(_))V(_)},T=(O)=>{for(let D of O.getAttributeNames()){if(D.startsWith("xmlns")||D.startsWith("data-"))continue;let W=D.toLowerCase();if(o5.has(D)||y2.has(W))continue;if(D.startsWith("-webkit-")||D.startsWith("-moz-")||D.startsWith("-ms-")||D.startsWith("-o-"))continue;if(D.includes(":")&&!D.startsWith("xlink:")&&!D.startsWith("xml:"))continue;let _=h5(D,o5);if(_)x.push({type:"mistyped_attribute_detected",element:O.tagName.toLowerCase(),attr:D,suggestion:_,reason:`Unknown attribute '${D}' on <${O.tagName.toLowerCase()}> - did you mean '${_}'?`})}for(let D of O.children)if(Z(D))T(D)},j={a:["href"],animate:["attributeName"],animateColor:["attributeName"],animateTransform:["attributeName"],circle:["r"],"color-profile":["name"],cursor:["href"],ellipse:["rx","ry"],feBlend:["in2"],feComposite:["in2"],feConvolveMatrix:["kernelMatrix"],feDisplacementMap:["in2"],feFuncA:["type"],feFuncB:["type"],feFuncG:["type"],feFuncR:["type"],feImage:["href"],font:["horiz-adv-x"],"font-face-uri":["href"],foreignObject:["width","height"],hkern:["k"],image:["href","width","height"],mpath:["href"],path:["d"],polygon:["points"],polyline:["points"],rect:["width","height"],script:["type"],set:["attributeName"],stop:["offset"],style:["type"],textPath:["href"],tref:["href"],use:["href"],vkern:["k"]},A=["href","xlink:href"],z=(O)=>{let D=O.tagName.toLowerCase(),W=j[D];if(W){for(let _ of W)if(_==="href"){if(!A.some((H)=>O.hasAttribute(H)))x.push({type:"missing_required_attribute",element:D,attr:_,reason:`Element <${D}> is missing required attribute '${_}' (or 'xlink:href')`})}else if(!O.hasAttribute(_))x.push({type:"missing_required_attribute",element:D,attr:_,reason:`Element <${D}> is missing required attribute '${_}'`})}for(let _ of O.children)if(Z(_))z(_)},i3={circle:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),ellipse:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),line:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),path:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polygon:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polyline:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),rect:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),use:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),image:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),animate:new Set(["desc","title","metadata"]),animatecolor:new Set(["desc","title","metadata"]),animatemotion:new Set(["desc","title","metadata","mpath"]),animatetransform:new Set(["desc","title","metadata"]),set:new Set(["desc","title","metadata"]),lineargradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),radialgradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),filter:new Set(["desc","title","metadata","animate","set","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","feflood","fegaussianblur","feimage","femerge","femorphology","feoffset","fespecularlighting","fetile","feturbulence"]),stop:new Set(["animate","animatecolor","set"])},K=(O)=>{let D=O.tagName.toLowerCase(),W=i3[D];if(W){for(let _ of O.children)if(Z(_)){let H=_.tagName.toLowerCase();if(!H.includes(":")&&!W.has(H))x.push({type:"invalid_child_element",parent:D,child:H,reason:`Element <${H}> is not a valid child of <${D}> per SVG 1.1 DTD`})}}for(let _ of O.children)if(Z(_))K(_)},$={"alignment-baseline":["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"],"clip-rule":["nonzero","evenodd","inherit"],"color-interpolation":["auto","sRGB","linearRGB","inherit"],"color-interpolation-filters":["auto","sRGB","linearRGB","inherit"],"color-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],direction:["ltr","rtl","inherit"],display:["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"],"dominant-baseline":["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"],"fill-rule":["nonzero","evenodd","inherit"],"font-stretch":["normal","wider","narrower","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","inherit"],"font-style":["normal","italic","oblique","inherit"],"font-variant":["normal","small-caps","inherit"],"font-weight":["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900","inherit"],"image-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],overflow:["visible","hidden","scroll","auto","inherit"],"pointer-events":["visiblePainted","visibleFill","visibleStroke","visible","painted","fill","stroke","all","none","inherit"],"shape-rendering":["auto","optimizeSpeed","crispEdges","geometricPrecision","inherit"],"stroke-linecap":["butt","round","square","inherit"],"stroke-linejoin":["miter","round","bevel","inherit"],"text-anchor":["start","middle","end","inherit"],"text-rendering":["auto","optimizeSpeed","optimizeLegibility","geometricPrecision","inherit"],"unicode-bidi":["normal","embed","bidi-override","inherit"],visibility:["visible","hidden","collapse","inherit"],"writing-mode":["lr-tb","rl-tb","tb-rl","lr","rl","tb","inherit"],"xml:space":["default","preserve"],additive:["replace","sum"],accumulate:["none","sum"],calcMode:["discrete","linear","paced","spline"],fill:["freeze","remove"],restart:["always","whenNotActive","never"],attributeType:["CSS","XML","auto"],edgeMode:["duplicate","wrap","none"],operator:["over","in","out","atop","xor","arithmetic","erode","dilate"],mode:["normal","multiply","screen","darken","lighten"],type:["translate","scale","rotate","skewX","skewY","matrix","saturate","hueRotate","luminanceToAlpha","identity","table","discrete","linear","gamma","fractalNoise","turbulence"],spreadMethod:["pad","reflect","repeat"],gradientUnits:["userSpaceOnUse","objectBoundingBox"],patternUnits:["userSpaceOnUse","objectBoundingBox"],patternContentUnits:["userSpaceOnUse","objectBoundingBox"],clipPathUnits:["userSpaceOnUse","objectBoundingBox"],maskUnits:["userSpaceOnUse","objectBoundingBox"],maskContentUnits:["userSpaceOnUse","objectBoundingBox"],filterUnits:["userSpaceOnUse","objectBoundingBox"],primitiveUnits:["userSpaceOnUse","objectBoundingBox"],markerUnits:["strokeWidth","userSpaceOnUse"],method:["align","stretch"],spacing:["auto","exact"],lengthAdjust:["spacing","spacingAndGlyphs"],preserveAspectRatio:["none","xMinYMin","xMidYMin","xMaxYMin","xMinYMid","xMidYMid","xMaxYMid","xMinYMax","xMidYMax","xMaxYMax"],zoomAndPan:["disable","magnify"],externalResourcesRequired:["true","false"]},w=new Set(["preserveAspectRatio"]),G=(O)=>{let D=O.tagName.toLowerCase();for(let W of O.getAttributeNames()){let _=$[W];if(_){let H=O.getAttribute(W);if(w.has(W)&&H)H=H.split(/\s+/)[0];if(W==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(D))continue;if(!_.includes(H)&&H!=="inherit")x.push({type:"invalid_enum_value",element:D,attr:W,value:H,validValues:_.slice(0,5).join(", ")+(_.length>5?"...":""),reason:`Invalid value '${H}' for attribute '${W}' - must be one of: ${_.slice(0,5).join(", ")}${_.length>5?"...":""}`})}}for(let W of O.children)if(Z(W))G(W)},a3={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},"font-size":{min:0,type:"length"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"},width:{min:0,type:"length"},height:{min:0,type:"length"},stdDeviation:{min:0,type:"number"},scale:{type:"number"},baseFrequency:{min:0,type:"number"},numOctaves:{min:1,type:"integer"},seed:{min:0,type:"number"},repeatCount:{min:0,type:"number"}},e3=(O)=>{let D=O.tagName.toLowerCase();for(let W of O.getAttributeNames()){let _=a3[W];if(_){let H=O.getAttribute(W);if(H==="inherit"||H==="none"||H==="indefinite"||H==="auto")continue;let m3=H.match(/^([+-]?\d*\.?\d+)/);if(m3){let P3=parseFloat(m3[1]);if(isNaN(P3))x.push({type:"invalid_numeric_value",element:D,attr:W,value:H,reason:`Invalid numeric value '${H}' for attribute '${W}'`});else{if(_.min!==void 0&&P3<_.min)x.push({type:"numeric_out_of_range",element:D,attr:W,value:H,constraint:`min: ${_.min}`,reason:`Value '${H}' for '${W}' is below minimum (${_.min})`});if(_.max!==void 0&&P3>_.max)x.push({type:"numeric_out_of_range",element:D,attr:W,value:H,constraint:`max: ${_.max}`,reason:`Value '${H}' for '${W}' exceeds maximum (${_.max})`});if(_.type==="integer"&&!Number.isInteger(P3))x.push({type:"invalid_numeric_value",element:D,attr:W,value:H,reason:`Attribute '${W}' requires an integer value, got '${H}'`})}}}}for(let W of O.children)if(Z(W))e3(W)},o3=(O)=>{let D=new Map,W=(_)=>{let H=_.getAttribute("id");if(H){if(!D.has(H))D.set(H,[]);D.get(H).push(_.tagName.toLowerCase())}for(let m3 of _.children)if(Z(m3))W(m3)};W(O);for(let[_,H]of D)if(H.length>1)x.push({type:"duplicate_id",id:_,count:H.length,elements:H.join(", "),reason:`Duplicate ID '${_}' found on ${H.length} elements: ${H.join(", ")}`})},y3=(O)=>{let D=new Set,W=(P3)=>{let B3=P3.getAttribute("id");if(B3)D.add(B3);for(let I3 of P3.children)if(Z(I3))W(I3)};W(O);let _=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,H=/^#(.+)$/,m3=(P3)=>{let B3=P3.tagName.toLowerCase();for(let I3 of P3.getAttributeNames()){let A4=P3.getAttribute(I3),f5;_.lastIndex=0;while((f5=_.exec(A4))!==null){let B4=f5[1];if(!D.has(B4))x.push({type:"broken_reference",element:B3,attr:I3,refId:B4,reason:`Broken reference: url(#${B4}) points to non-existent ID`})}if(I3==="href"||I3==="xlink:href"){let B4=A4.match(H);if(B4){let m5=B4[1];if(!D.has(m5))x.push({type:"broken_reference",element:B3,attr:I3,refId:m5,reason:`Broken reference: ${I3}="#${m5}" points to non-existent ID`})}}}for(let I3 of P3.children)if(Z(I3))m3(I3)};m3(t)},N3=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),Q=new Set(["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"]),J=(O)=>{let D=O.toLowerCase().trim();if(D==="none"||D==="inherit"||D==="currentcolor")return!0;if(N3.has(D))return!0;if(D.startsWith("url("))return!0;if(/^#[0-9a-f]{3}$/.test(D)||/^#[0-9a-f]{6}$/.test(D))return!0;if(/^rgb\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)$/.test(D))return!0;if(/^rgba\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*[\d.]+%?\s*\)$/.test(D))return!0;return!1},c3=(O)=>{let D=O.tagName.toLowerCase();for(let W of O.getAttributeNames())if(Q.has(W)){let _=O.getAttribute(W);if(!J(_))x.push({type:"invalid_color",element:D,attr:W,value:_,reason:`Invalid color value '${_}' for attribute '${W}'`})}for(let W of O.children)if(Z(W))c3(W)},v3=(O)=>{let D=O.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(D)){let H=O.getAttribute("viewBox");if(H){let m3=H.trim().split(/[\s,]+/);if(m3.length!==4)x.push({type:"malformed_viewbox",element:D,value:H,reason:`viewBox must have exactly 4 values (min-x, min-y, width, height), got ${m3.length}`});else{for(let I3=0;I3<m3.length;I3++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(m3[I3])){x.push({type:"malformed_viewbox",element:D,value:H,reason:`viewBox contains invalid number '${m3[I3]}' at position ${I3+1}`});break}let P3=parseFloat(m3[2]),B3=parseFloat(m3[3]);if(isNaN(P3)||isNaN(B3)||P3<0||B3<0)x.push({type:"invalid_viewbox_dimensions",element:D,value:H,reason:`viewBox width and height must be valid non-negative numbers, got ${P3}x${B3}`})}}}let W=O.getAttribute("preserveAspectRatio");if(W){if(!/^(none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax)(\s+(meet|slice))?$/.test(W.trim()))x.push({type:"malformed_preserveaspectratio",element:D,value:W,reason:`Invalid preserveAspectRatio format '${W}'`})}if(["polygon","polyline"].includes(D)){let H=O.getAttribute("points");if(H){let m3=H.trim().split(/[\s,]+/);if(m3.length>0&&m3.length%2!==0)x.push({type:"malformed_points",element:D,value:H.slice(0,50)+(H.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${m3.length}`})}}let _=O.getAttribute("transform");if(_){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(_.trim())){if(!/^[\s\w(),.\-+]+$/.test(_))x.push({type:"malformed_transform",element:D,value:_.slice(0,50)+(_.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let H of O.children)if(Z(H))v3(H)},b3=(O)=>{let D=O.tagName,W=D.toLowerCase();if(D.includes(":")||l5.has(D)||g2.has(W)){for(let H of Array.from(O.children))if(Z(H))b3(H);return}let _=h5(D,l5);if(_){let H=O.ownerDocument.createElement(_);for(let m3 of O.getAttributeNames())H.setAttribute(m3,O.getAttribute(m3));while(O.firstChild)H.appendChild(O.firstChild);if(O.parentNode)O.parentNode.replaceChild(H,O);x.push({type:"element_typo_fixed",oldName:D,newName:_,reason:`Fixed element typo: <${D}> -> <${_}>`});for(let m3 of Array.from(H.children))if(Z(m3))b3(m3)}else for(let H of Array.from(O.children))if(Z(H))b3(H)},A3=(O)=>{for(let D of Array.from(O.getAttributeNames())){if(D.startsWith("xmlns")||D.startsWith("data-"))continue;if(D.startsWith("-webkit-")||D.startsWith("-moz-"))continue;if(D.includes(":")&&!D.startsWith("xlink:")&&!D.startsWith("xml:"))continue;if(o5.has(D)||y2.has(D.toLowerCase()))continue;let W=h5(D,o5);if(W){let _=O.getAttribute(D);O.removeAttribute(D),O.setAttribute(W,_),x.push({type:"attr_typo_fixed",element:O.tagName.toLowerCase(),oldAttr:D,newAttr:W,reason:`Fixed attribute typo: '${D}' -> '${W}'`})}}for(let D of O.children)if(Z(D))A3(D)},L3=(O)=>{let D=new Map,W=new Set,_=(P3)=>{let B3=P3.getAttribute("id");if(B3)D.set(B3,(D.get(B3)||0)+1),W.add(B3);for(let I3 of P3.children)if(Z(I3))_(I3)};_(O);let H=new Set,m3=(P3)=>{let B3=P3.getAttribute("id");if(B3)if(H.has(B3)){let I3=B3,A4=2;while(W.has(I3)||H.has(I3))I3=`${B3}_${A4++}`;P3.setAttribute("id",I3),W.add(I3),H.add(I3),x.push({type:"duplicate_id_renamed",oldId:B3,newId:I3,element:P3.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${B3}' -> '${I3}'`})}else H.add(B3);for(let I3 of P3.children)if(Z(I3))m3(I3)};m3(O)};if(m(t),g(),y(t),v(t),P(t),B(t),N(t),I(t),b3(t),A3(t),L3(t),F(t),z(t),K(t),G(t),e3(t),y3(t),c3(t),v3(t),t.setAttribute("data-fixes-applied",String(x.length)),o&&x.length>0)t.setAttribute("data-fix-report",JSON.stringify(x));return t}),f3={ERROR:"error",WARNING:"warning"},Ro={broken_reference:f3.ERROR,broken_url_reference:f3.ERROR,duplicate_id:f3.ERROR,missing_required_attribute:f3.ERROR,invalid_child_element:f3.ERROR,animation_in_empty_element:f3.ERROR,malformed_viewbox:f3.ERROR,malformed_points:f3.ERROR,malformed_transform:f3.ERROR,invalid_enum_value:f3.ERROR,invalid_numeric_constraint:f3.ERROR,invalid_attr_on_element:f3.WARNING,missing_namespace:f3.WARNING,invalid_timing:f3.WARNING,uppercase_unit:f3.WARNING,invalid_whitespace:f3.WARNING,invalid_number:f3.WARNING,mistyped_element_detected:f3.WARNING,unknown_element_detected:f3.WARNING,mistyped_attribute_detected:f3.WARNING,unknown_attribute_detected:f3.WARNING,invalid_color:f3.WARNING,circular_reference:f3.WARNING,deep_nesting:f3.WARNING,empty_defs:f3.WARNING,gradient_stop_order:f3.WARNING,path_complexity:f3.WARNING,external_resource:f3.WARNING,script_content:f3.WARNING,event_handler:f3.WARNING,missing_title:f3.WARNING,missing_desc:f3.WARNING,invalid_aria:f3.WARNING,missing_lang:f3.WARNING},wo=new Set(["onabort","onactivate","onbegin","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onend","onended","onerror","onfocus","onfocusin","onfocusout","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onrepeat","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting","onwheel"]),Lo=new Set(["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"]),rt=new Set(["img","graphics-document","graphics-object","graphics-symbol","group","list","listitem","none","presentation","application"]);function ko(t){let a={elements:new Map,lines:[]},e=0;a.lines.push(0);for(let E=0;E<t.length;E++)if(t[E]===`
|
|
431
|
-
`)
|
|
432
|
-
`):null,c=ko(x),s,m=[],g=(U)=>{let L=U.match(/line\s*:?\s*(\d+)/i)||U.match(/:(\d+):/);return L?parseInt(L[1],10):1},u=(U)=>{let L=U.match(/column\s*:?\s*(\d+)/i)||U.match(/:\d+:(\d+)/);return L?parseInt(L[1],10):1},y=(U)=>{let L=U,q=[],M="_VALID_ENTITY_",t3=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,x3=L.replace(t3,M+"$1;").replace(/&/g,"&").replace(new RegExp(M,"g"),"&");if(x3!==L)L=x3,q.push("Escaped unencoded ampersands");let l3=L.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(l3!==L)L=l3,q.push("Removed invalid control characters");if(L.charCodeAt(0)===65279)L=L.slice(1),q.push("Removed UTF-8 BOM");let h3=L.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(D3,M3,$3)=>{if(!$3.includes(">"))return`="${M3}<${$3}"`;return D3});if(h3!==L)L=h3,q.push("Escaped < in attribute values");return{fixed:L,appliedFixes:q}};try{s=await F5(t,p)}catch(U){let L=U.message||String(U),q=g(L),M=u(L),{fixed:t3,appliedFixes:x3}=y(x);if(x3.length>0&&t3!==x)try{let{JSDOM:l3}=await import("jsdom");s=new l3(t3,{contentType:"image/svg+xml"}).window.document.documentElement,m.push({type:"parse_recovery",severity:f3.WARNING,reason:`Recovered from parse error. Applied fixes: ${x3.join("; ")}`,line:q,column:M}),m.push({type:"original_parse_error",severity:f3.ERROR,reason:`Original parse error: ${L}`,line:q,column:M})}catch(l3){return{issues:[{type:"parse_error",severity:f3.ERROR,reason:`Failed to parse SVG: ${L}`,line:q,column:M},{type:"recovery_failed",severity:f3.WARNING,reason:`Recovery attempted (${x3.join("; ")}) but still failed: ${l3.message}`,line:q,column:M}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:f3.ERROR,reason:`Failed to parse SVG: ${L}`,line:q,column:M}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let v=[];if(m.length>0)v.push(...m);let E=new Map,C=(U)=>{let L=U.toLowerCase(),q=E.get(L)||0;return E.set(L,q+1),q},P=()=>{E.clear()},S=(U,L,q=null,M=null)=>{let t3;if(q)t3=c.getAttributePosition(L,q,M||0);else t3=c.getElementPosition(L,M||0);let x3=Ro[U.type]||f3.WARNING,l3={...U,severity:x3,line:t3.line,column:t3.column};if(l&&n&&t3.line>0&&t3.line<=n.length)l3.sourceLine=n[t3.line-1];return l3},f=new Set,B=(U)=>{if(!U)return;let L=U.getAttribute("id");if(L)f.add(L);for(let q of U.children)if(Z(q))B(q)};B(s);let R=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],k=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);if(L==="g"){for(let M of R)if(U.hasAttribute(M))v.push(S({type:"invalid_attr_on_element",element:L,attr:M,value:U.getAttribute(M),reason:`SVG 1.1: <g> elements do not support '${M}' attribute`},L,M,q))}for(let M of U.children)if(Z(M))k(M)},N=()=>{let U=!1,L=null,q=null,M=(t3)=>{for(let x3 of t3.getAttributeNames())if(x3.startsWith("xlink:")){U=!0,L=t3.tagName.toLowerCase(),q=x3;return}for(let x3 of t3.children){if(Z(x3))M(x3);if(U)return}};if(M(s),U&&!s.hasAttribute("xmlns:xlink")){let t3=c.getAttributePosition(L,q,0);v.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:t3.line,column:t3.column})}},I=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of["xlink:href","href"]){let t3=U.getAttribute(M);if(t3&&t3.startsWith("#")){let x3=t3.slice(1);if(x3&&!f.has(x3))v.push(S({type:"broken_reference",element:L,attr:M,referencedId:x3,reason:`Reference to non-existent ID '${x3}'`},L,M,q))}}for(let M of U.children)if(Z(M))I(M)},d=["begin","end","dur","repeatDur","min","max"],Y=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),X=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);if(Y.has(L))for(let M of d){let t3=U.getAttribute(M);if(t3){let x3=t3.trim();if(x3!==t3)v.push(S({type:"invalid_timing",element:L,attr:M,value:t3,reason:"Timing value has leading/trailing whitespace"},L,M,q));if(/[;,]/.test(x3)&&!/^[\d\w\s.;,+-]+$/.test(x3))v.push(S({type:"invalid_timing",element:L,attr:M,value:t3,reason:"Timing value may contain invalid characters"},L,M,q))}}for(let M of U.children)if(Z(M))X(M)},F=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),V=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);if(F.has(L)){for(let M of U.children)if(Z(M)){let t3=M.tagName.toLowerCase();if(Y.has(t3))v.push(S({type:"animation_in_empty_element",element:L,child:t3,reason:`Animation element <${t3}> inside <${L}> which has EMPTY content model per SVG 1.1 DTD`},L,null,q))}}for(let M of U.children)if(Z(M))V(M)},T=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,j=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],A=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of j){let t3=U.getAttribute(M);if(t3){let x3=t3.match(T);if(x3)for(let l3 of x3){let h3=l3.replace(/[\d.]+/,"");if(h3!==h3.toLowerCase())v.push(S({type:"uppercase_unit",element:L,attr:M,value:t3,reason:`Unit '${h3}' should be lowercase '${h3.toLowerCase()}'`},L,M,q))}}}for(let M of U.children)if(Z(M))A(M)},z=["points","viewBox","d","values","keyTimes","keySplines","rotate"],i3=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of z){let t3=U.getAttribute(M);if(t3){if(/[\t\n\r]/.test(t3)||/ +/.test(t3))v.push(S({type:"invalid_whitespace",element:L,attr:M,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},L,M,q))}}for(let M of U.children)if(Z(M))i3(M)},K=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","font-size"],$=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of K){let t3=U.getAttribute(M);if(t3){let x3=t3.trim();if(/^0\d/.test(x3.replace(/[a-z%]+$/i,"")))v.push(S({type:"invalid_number",element:L,attr:M,value:t3,reason:"Number has unnecessary leading zeros"},L,M,q));if(/\.$/.test(x3.replace(/[a-z%]+$/i,"")))v.push(S({type:"invalid_number",element:L,attr:M,value:t3,reason:"Number has trailing decimal point"},L,M,q))}}for(let M of U.children)if(Z(M))$(M)},w=(U,L=!1)=>{let q=U.tagName,M=q.toLowerCase(),t3=C(M),x3=q.includes(":"),l3=L||Z6.has(M)||x3;if(!l3){if(!l5.has(q)&&!g2.has(M)){if(!po(M)){let h3=h5(q,l5);if(h3)v.push(S({type:"mistyped_element_detected",element:q,suggestion:h3,reason:`Unknown element <${q}> - did you mean <${h3}>?`},M,null,t3));else v.push(S({type:"unknown_element_detected",element:q,reason:`Unknown element <${q}> - not in SVG 1.1 spec`},M,null,t3))}}}for(let h3 of U.children)if(Z(h3))w(h3,l3)},G=(U,L=!1)=>{let q=U.tagName.toLowerCase(),M=C(q),t3=U.tagName.includes(":"),x3=L||Z6.has(q)||t3;if(!x3)for(let l3 of U.getAttributeNames()){if(l3.startsWith("data-")||l3.startsWith("aria-"))continue;if(l3==="xmlns"||l3.startsWith("xmlns:"))continue;if(l3.includes(":")&&!l3.startsWith("xlink:")&&!l3.startsWith("xml:"))continue;if(co(l3))continue;if(!o5.has(l3)&&!y2.has(l3.toLowerCase())){let h3=h5(l3,o5);if(h3)v.push(S({type:"mistyped_attribute_detected",element:q,attr:l3,suggestion:h3,reason:`Unknown attribute '${l3}' - did you mean '${h3}'?`},q,l3,M));else v.push(S({type:"unknown_attribute_detected",element:q,attr:l3,reason:`Unknown attribute '${l3}' on <${q}> - not in SVG 1.1 spec`},q,l3,M))}}for(let l3 of U.children)if(Z(l3))G(l3,x3)},a3={use:["xlink:href","href"],image:["xlink:href","href"],feImage:["xlink:href","href"],textPath:["xlink:href","href"],mpath:["xlink:href","href"],animate:["attributeName"],animateTransform:["attributeName","type"],animateMotion:[],animateColor:["attributeName"],set:["attributeName"],feBlend:["in2"],feComposite:["in2"],feDisplacementMap:["in2","scale"],feMorphology:["operator"],feTurbulence:["type"],feConvolveMatrix:["kernelMatrix"],feFuncR:["type"],feFuncG:["type"],feFuncB:["type"],feFuncA:["type"],linearGradient:[],radialGradient:[],stop:["offset"]},e3=(U)=>{let L=U.tagName.toLowerCase(),q=C(L),M=a3[L];if(M&&M.length>0){if(M.includes("xlink:href")&&M.includes("href")){if(!U.hasAttribute("xlink:href")&&!U.hasAttribute("href"))v.push(S({type:"missing_required_attribute",element:L,attrs:["href","xlink:href"],reason:`<${L}> requires 'href' or 'xlink:href' attribute`},L,null,q))}else for(let t3 of M)if(!U.hasAttribute(t3))v.push(S({type:"missing_required_attribute",element:L,attr:t3,reason:`<${L}> requires '${t3}' attribute per SVG 1.1 DTD`},L,t3,q))}for(let t3 of U.children)if(Z(t3))e3(t3)},o3={linearGradient:new Set(["stop","animate","animateTransform","set"]),radialGradient:new Set(["stop","animate","animateTransform","set"]),stop:new Set(["animate","set"]),clipPath:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","animate","animateTransform","set","desc","title"]),mask:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","g","defs","image","switch","a","animate","animateTransform","set","desc","title"])},y3=(U)=>{let L=U.tagName.toLowerCase(),q=C(L),M=o3[L];if(M){for(let t3 of U.children)if(Z(t3)){let x3=t3.tagName.toLowerCase();if(!x3.includes(":")&&!M.has(x3))v.push(S({type:"invalid_child_element",element:L,child:x3,reason:`<${x3}> is not a valid child of <${L}> per SVG 1.1 DTD`},L,null,q))}}for(let t3 of U.children)if(Z(t3))y3(t3)},N3={spreadMethod:new Set(["pad","reflect","repeat"]),gradientUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),clipPathUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),filterUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),primitiveUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),markerUnits:new Set(["strokeWidth","userSpaceOnUse"]),"fill-rule":new Set(["nonzero","evenodd","inherit"]),"clip-rule":new Set(["nonzero","evenodd","inherit"]),"stroke-linecap":new Set(["butt","round","square","inherit"]),"stroke-linejoin":new Set(["miter","round","bevel","inherit"]),"text-anchor":new Set(["start","middle","end","inherit"]),"dominant-baseline":new Set(["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"]),"alignment-baseline":new Set(["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"]),visibility:new Set(["visible","hidden","collapse","inherit"]),display:new Set(["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"]),overflow:new Set(["visible","hidden","scroll","auto","inherit"])},Q=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let[M,t3]of Object.entries(N3)){let x3=U.getAttribute(M);if(x3&&!t3.has(x3))v.push(S({type:"invalid_enum_value",element:L,attr:M,value:x3,validValues:[...t3],reason:`Invalid value '${x3}' for '${M}'. Valid values: ${[...t3].join(", ")}`},L,M,q))}for(let M of U.children)if(Z(M))Q(M)},J={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"}},c3=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let[M,t3]of Object.entries(J)){let x3=U.getAttribute(M);if(x3){let l3=parseFloat(x3);if(!isNaN(l3)){if(t3.min!==void 0&&l3<t3.min)v.push(S({type:"invalid_numeric_constraint",element:L,attr:M,value:x3,reason:`Value ${l3} is below minimum ${t3.min}`},L,M,q));if(t3.max!==void 0&&l3>t3.max)v.push(S({type:"invalid_numeric_constraint",element:L,attr:M,value:x3,reason:`Value ${l3} is above maximum ${t3.max}`},L,M,q))}}}for(let M of U.children)if(Z(M))c3(M)},v3=(U)=>{let L=new Map,q=new Map,M=(t3)=>{let x3=t3.tagName.toLowerCase(),l3=C(x3),h3=t3.getAttribute("id");if(h3){if(!L.has(h3))L.set(h3,[]),q.set(h3,{tagName:x3,occIdx:l3});L.get(h3).push(x3)}for(let D3 of t3.children)if(Z(D3))M(D3)};M(U);for(let[t3,x3]of L)if(x3.length>1){let l3=q.get(t3);v.push(S({type:"duplicate_id",id:t3,elements:x3,count:x3.length,reason:`ID '${t3}' is used ${x3.length} times (on ${x3.join(", ")})`},l3.tagName,"id",l3.occIdx))}},b3=/url\(#([^)]+)\)/g,A3=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],L3=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of A3){let t3=U.getAttribute(M);if(t3){let x3;b3.lastIndex=0;while((x3=b3.exec(t3))!==null){let l3=x3[1];if(!f.has(l3))v.push(S({type:"broken_url_reference",element:L,attr:M,referencedId:l3,reason:`url(#${l3}) references non-existent ID`},L,M,q))}}}for(let M of U.children)if(Z(M))L3(M)},O=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","currentcolor","inherit","none","transparent"]),D=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],W=(U)=>{let L=U.toLowerCase().trim();if(O.has(L))return!0;if(/^#[0-9a-f]{3}$/i.test(L))return!0;if(/^#[0-9a-f]{4}$/i.test(L))return!0;if(/^#[0-9a-f]{6}$/i.test(L))return!0;if(/^#[0-9a-f]{8}$/i.test(L))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(L))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(L))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(L))return!0;if(/^url\(#[^)]+\)$/i.test(L))return!0;return!1},_=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of D){let t3=U.getAttribute(M);if(t3&&!W(t3))v.push(S({type:"invalid_color",element:L,attr:M,value:t3,reason:`Invalid color value '${t3}'`},L,M,q))}for(let M of U.children)if(Z(M))_(M)},H=(U)=>{let L=U.tagName.toLowerCase(),q=C(L),M=U.getAttribute("viewBox");if(M){let l3=M.trim().split(/[\s,]+/);if(l3.length!==4||!l3.every((h3)=>!isNaN(parseFloat(h3))))v.push(S({type:"malformed_viewbox",element:L,value:M,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},L,"viewBox",q))}let t3=U.getAttribute("points");if(t3){let l3=t3.trim().split(/[\s,]+/).filter((h3)=>h3);if(l3.length%2!==0||!l3.every((h3)=>!isNaN(parseFloat(h3))))v.push(S({type:"malformed_points",element:L,value:t3.length>50?t3.substring(0,50)+"...":t3,reason:"points must be pairs of numbers"},L,"points",q))}let x3=U.getAttribute("transform");if(x3){let l3=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,h3=x3.trim();while(h3.length>0){let D3=h3.match(l3);if(D3&&D3[0].length>0)h3=h3.substring(D3[0].length);else if(!D3){v.push(S({type:"malformed_transform",element:L,value:x3.length>50?x3.substring(0,50)+"...":x3,reason:`Invalid transform syntax near '${h3.substring(0,20)}'`},L,"transform",q));break}else h3=h3.substring(1)}}if(L==="path"){let l3=U.getAttribute("d");if(l3){let h3=l3.trim();if(h3.length>0){if(!/^[Mm]/.test(h3))v.push(S({type:"malformed_path_data",element:"path",value:l3.length>50?l3.substring(0,50)+"...":l3,reason:"Path data must start with M or m command"},"path","d",q));let D3=h3.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(D3.length>0)v.push(S({type:"malformed_path_data",element:"path",value:l3.length>50?l3.substring(0,50)+"...":l3,reason:`Path data contains invalid characters: '${D3.substring(0,10)}'`},"path","d",q))}}}for(let l3 of U.children)if(Z(l3))H(l3)},m3=()=>{let U=new Map,L=(l3)=>{let h3=l3.getAttribute("id");if(h3)U.set(h3,l3);for(let D3 of l3.children)if(Z(D3))L(D3)};L(s);let q=["href","xlink:href","mask","clip-path","filter","fill","stroke"],M=(l3)=>{if(!l3)return null;let h3=l3.match(/url\(#([^)]+)\)/);if(h3)return h3[1];let D3=l3.match(/^#(.+)$/);if(D3)return D3[1];return null},t3=(l3,h3=new Set)=>{if(h3.has(l3))return!0;let D3=U.get(l3);if(!D3)return!1;h3.add(l3);let M3=(n4)=>{for(let K3 of q){let r6=M(n4.getAttribute(K3));if(r6&&t3(r6,h3))return!0}for(let K3 of n4.children)if(Z(K3)&&M3(K3))return!0;return!1},$3=M3(D3);return h3.delete(l3),$3},x3=["clipPath","mask","filter","symbol","pattern","marker"];for(let[l3,h3]of U){let D3=h3.tagName.toLowerCase();if(x3.includes(D3)){if(t3(l3)){P();let M3=C(D3);v.push(S({type:"circular_reference",element:D3,attr:"id",value:l3,reason:`Circular reference detected: '${l3}' directly or indirectly references itself`},D3,"id",M3))}}}},P3=50,B3=(U,L=0)=>{if(L>P3){let q=U.tagName.toLowerCase(),M=C(q);v.push(S({type:"deep_nesting",element:q,value:String(L),reason:`Element nesting depth (${L}) exceeds ${P3} levels`},q,null,M));return}for(let q of U.children)if(Z(q))B3(q,L+1)},I3=(U)=>{let L=U.tagName.toLowerCase();if(L==="defs"){let q=!1;for(let M of U.childNodes)if(Z(M)){q=!0;break}if(!q){let M=C(L);v.push(S({type:"empty_defs",element:L,reason:"Empty <defs> element (can be removed)"},L,null,M))}}for(let q of U.children)if(Z(q))I3(q)},A4=(U)=>{let L=U.tagName.toLowerCase();if(L==="lineargradient"||L==="radialgradient"){let q=Array.from(U.children).filter((M)=>Z(M)&&M.tagName.toLowerCase()==="stop");if(q.length>=2){let M=-1;for(let t3 of q){let x3=t3.getAttribute("offset")||"0",l3=parseFloat(x3);if(x3.includes("%"))l3=l3/100;if(!isNaN(l3)&&l3<M){let h3=C(L);v.push(S({type:"gradient_stop_order",element:L,reason:`Gradient stops not in ascending offset order (${M} followed by ${l3})`},L,null,h3));break}if(!isNaN(l3))M=l3}}}for(let q of U.children)if(Z(q))A4(q)},f5=1e4,B4=(U)=>{let L=U.tagName.toLowerCase();if(L==="path"){let q=U.getAttribute("d");if(q){let M=q.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(M&&M.length>f5){let t3=C(L);v.push(S({type:"path_complexity",element:L,attr:"d",value:`${M.length} coordinates`,reason:`Path has ${M.length} coordinates (>${f5}), may cause slow rendering`},L,"d",t3))}}}for(let q of U.children)if(Z(q))B4(q)},m5=(U)=>{let L=U.tagName.toLowerCase(),q=C(L),M=["href","xlink:href"];for(let t3 of M){let x3=U.getAttribute(t3);if(x3&&(x3.startsWith("http://")||x3.startsWith("https://")||x3.startsWith("//")))v.push(S({type:"external_resource",element:L,attr:t3,value:x3.length>60?x3.substring(0,60)+"...":x3,reason:"External resource reference detected (potential security/CORS issue)"},L,t3,q))}if(L==="style"&&U.textContent){let t3=U.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(t3)v.push(S({type:"external_resource",element:L,value:t3[1],reason:"External CSS import detected in style element"},L,null,q))}for(let t3 of U.children)if(Z(t3))m5(t3)},a6=(U)=>{let L=U.tagName.toLowerCase();if(L==="script"){let q=C(L);v.push(S({type:"script_content",element:L,reason:"Script element detected (potential security issue in untrusted SVGs)"},L,null,q))}for(let q of U.children)if(Z(q))a6(q)},e6=(U)=>{let L=U.tagName.toLowerCase(),q=C(L);for(let M of U.getAttributeNames())if(wo.has(M.toLowerCase()))v.push(S({type:"event_handler",element:L,attr:M,reason:`Event handler attribute '${M}' detected (potential XSS vector)`},L,M,q));for(let M of U.children)if(Z(M))e6(M)},ne=()=>{let U=!1,L=!1,q=!1,M=s.hasAttribute("lang")||s.hasAttribute("xml:lang"),t3=(D3)=>{for(let M3 of D3.children){if(!Z(M3))continue;let $3=M3.tagName.toLowerCase();if($3==="title")U=!0;if($3==="desc")L=!0;if($3==="text"||$3==="tspan"||$3==="textpath")q=!0;t3(M3)}};if(t3(s),!U)v.push(S({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let x3=0,l3=(D3)=>{x3++;for(let M3 of D3.children)if(Z(M3))l3(M3)};if(l3(s),!L&&x3>10)v.push(S({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${x3} elements)`},"svg",null,0));if(q&&!M)v.push(S({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let h3=(D3)=>{let M3=D3.tagName.toLowerCase(),$3=C(M3);for(let n4 of D3.getAttributeNames()){if(n4.startsWith("aria-")&&!Lo.has(n4.toLowerCase()))v.push(S({type:"invalid_aria",element:M3,attr:n4,reason:`Unknown ARIA attribute '${n4}'`},M3,n4,$3));if(n4==="role"){let K3=D3.getAttribute("role");if(K3&&!rt.has(K3.toLowerCase()))v.push(S({type:"invalid_aria",element:M3,attr:"role",value:K3,reason:`Invalid role value '${K3}' (valid: ${Array.from(rt).slice(0,5).join(", ")}...)`},M3,"role",$3))}if(n4==="aria-hidden"){let K3=D3.getAttribute("aria-hidden");if(K3&&K3!=="true"&&K3!=="false")v.push(S({type:"invalid_aria",element:M3,attr:"aria-hidden",value:K3,reason:`aria-hidden must be 'true' or 'false', got '${K3}'`},M3,"aria-hidden",$3))}}for(let n4 of D3.children)if(Z(n4))h3(n4)};P(),h3(s)};P(),k(s),N(),P(),I(s),P(),X(s),P(),V(s),P(),A(s),P(),i3(s),P(),$(s),P(),w(s),P(),G(s),P(),e3(s),P(),y3(s),P(),Q(s),P(),c3(s),P(),v3(s),P(),L3(s),P(),_(s),P(),H(s),P(),m3(),P(),B3(s),P(),I3(s),P(),A4(s),P(),B4(s),P(),m5(s),P(),a6(s),P(),e6(s),ne(),v.sort((U,L)=>{if(U.line!==L.line)return U.line-L.line;return U.column-L.column});let j5=v;if(e)j5=v.filter((U)=>U.severity===f3.ERROR);let V0=v.filter((U)=>U.severity===f3.ERROR).length,i6=v.filter((U)=>U.severity===f3.WARNING).length,U0={};for(let U of j5)U0[U.type]=(U0[U.type]||0)+1;let t5={issues:j5,isValid:V0===0,hasErrors:V0>0,hasWarnings:i6>0,errorCount:V0,warningCount:i6,issueCount:j5.length,summary:U0};if(i)try{let U=await import("node:fs/promises"),L=await Promise.resolve().then(()=>(v5(),x5)),q;switch(r){case"json":q=JSON.stringify(t5,null,2);break;case"yaml":q=Oo(t5);break;case"xml":q=Vo(t5);break;case"text":default:q=Xo(t5);break}let M=L.normalize(i);await U.writeFile(M,q,"utf8"),t5.outputFile=M}catch(U){t5.exportError=`Failed to write report to '${i}': ${U.message}`}return t5}function Xo(t){let a=["=".repeat(60),"SVG VALIDATION REPORT","=".repeat(60),"",`Status: ${t.isValid?"VALID":"INVALID"}`,`Errors: ${t.errorCount}`,`Warnings: ${t.warningCount}`,`Total Issues: ${t.issueCount}`,""];if(t.issues.length>0){a.push("-".repeat(60)),a.push("ISSUES:"),a.push("-".repeat(60)),a.push("");for(let e of t.issues){let i=e.severity.toUpperCase(),r=`${e.line}:${e.column}`;if(a.push(`[${i}] Line ${r}: ${e.type}`),e.element)a.push(` Element: <${e.element}>`);if(e.attr)a.push(` Attribute: ${e.attr}`);if(e.value)a.push(` Value: ${e.value}`);if(a.push(` ${e.reason}`),e.sourceLine)a.push(` Source: ${e.sourceLine.trim()}`);a.push("")}}a.push("=".repeat(60)),a.push("SUMMARY BY TYPE:"),a.push("-".repeat(60));for(let[e,i]of Object.entries(t.summary))a.push(` ${e}: ${i}`);return a.push("=".repeat(60)),a.join(`
|
|
433
|
-
`)}function
|
|
434
|
-
`)}function
|
|
435
|
-
`)}function
|
|
350
|
+
`;return WK({title:"SVG Compatibility Matrix",subtitle:"What problems will your SVG have in each configuration?",columns:Z,rowLevels:K,rowData:Q,getCellContent:q,additionalSections:[{title:"SERVER-SIDE SVG RENDERERS (no HTML embedding)",content:W,height:H.length*30+20}],legend:j,options:{fontFamily:J,minCellWidth:220,legendHeight:1020,...$}})}var zK=F0(($,J={})=>{let Z=J.fixInvalidGroupAttrs!==!1,K=J.fixMissingNamespaces!==!1,Q=J.fixBrokenRefs!==!1,q=J.fixAnimationTiming!==!1,H=J.verbose||!1,W=[],z=new Set,j=(S)=>{let C=S.getAttribute("id");if(C)z.add(C);for(let n of S.children)if(a(n))j(n)};j($);let G=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],F=new Set(["svg","rect","image","foreignObject","use","symbol","pattern","mask","filter","clipPath"]),_=(S)=>{let C=S.tagName.toLowerCase();if(C==="g"&&Z){for(let n of G)if(S.hasAttribute(n)){let p=S.getAttribute(n);S.removeAttribute(n),W.push({type:"invalid_attr_removed",element:C,attr:n,value:p,reason:`SVG 1.1: <g> elements do not support '${n}' attribute`})}}for(let n of S.children)if(a(n))_(n)},U=()=>{if(!K)return;let S=!1,C=(n)=>{for(let p of n.getAttributeNames())if(p.startsWith("xlink:")){S=!0;return}for(let p of n.children){if(a(p))C(p);if(S)return}};if(C($),S&&!$.hasAttribute("xmlns:xlink"))$.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),W.push({type:"namespace_added",namespace:"xmlns:xlink",value:"http://www.w3.org/1999/xlink",reason:"SVG 1.1: xmlns:xlink required when xlink:* attributes are present"})},M=(S)=>{let C=[S,S.replace(/^FRAME(\d+)$/,"FRAME0$1"),S.replace(/^FRAME0(\d+)$/,"FRAME00$1"),S.replace(/^FRAME00(\d+)$/,"FRAME000$1"),S.replace(/^FRAME0+(\d+)$/,"FRAME$1"),S.replace(/^FRAME(\d)$/,"FRAME0000$1"),S.replace(/^FRAME(\d{2})$/,"FRAME000$1"),S.replace(/^FRAME(\d{3})$/,"FRAME00$1"),S.replace(/^FRAME(\d{4})$/,"FRAME0$1")];for(let s of C)if(z.has(s)&&s!==S)return s;let n=null,p=1/0;for(let s of z)if(s.toLowerCase().includes(S.toLowerCase())||S.toLowerCase().includes(s.toLowerCase())){let G0=Math.abs(s.length-S.length);if(G0<p&&G0<=2)p=G0,n=s}return n},V=(S)=>{if(!Q)return;for(let C of["href","xlink:href"]){let n=S.getAttribute(C);if(n&&n.startsWith("#")){let p=n.substring(1);if(!z.has(p)){let s=M(p);if(s)S.setAttribute(C,`#${s}`),W.push({type:"ref_fixed",element:S.tagName.toLowerCase(),attr:C,oldValue:n,newValue:`#${s}`,reason:`ID '${p}' not found, fixed to similar ID '${s}'`})}}}if(S.tagName.toLowerCase()==="animate"){let C=S.getAttribute("attributeName");if(C==="href"||C==="xlink:href"){let n=S.getAttribute("values");if(n){let p=n.split(";"),s=!1,G0=p.map((L0)=>{let C0=L0.trim();if(C0.startsWith("#")){let E0=C0.substring(1);if(!z.has(E0)){let k7=M(E0);if(k7)return s=!0,`#${k7}`}}return C0});if(s){let L0=G0.join(";");S.setAttribute("values",L0),W.push({type:"animate_values_fixed",oldValue:n,newValue:L0,reason:"Fixed broken ID references in animate values"})}}}}for(let C of["fill","stroke","clip-path","mask","filter"]){let n=S.getAttribute(C);if(n&&n.startsWith("url(#")){let p=n.match(/url\(#([^)]+)\)/);if(p){let s=p[1];if(!z.has(s)){let G0=M(s);if(G0)S.setAttribute(C,`url(#${G0})`),W.push({type:"url_ref_fixed",element:S.tagName.toLowerCase(),attr:C,oldValue:n,newValue:`url(#${G0})`,reason:`ID '${s}' not found, fixed to similar ID '${G0}'`})}}}}for(let C of S.children)if(a(C))V(C)},Y=(S)=>{if(!q)return;let C=["animate","animateTransform","animateMotion","animateColor","set"],n=S.tagName.toLowerCase();if(C.includes(n)){let p=S.getAttribute("dur"),s=S.getAttribute("repeatCount");if(p==="0"||p==="0s"){if(!S.getAttribute("keyTimes"))W.push({type:"timing_warning",element:n,attr:"dur",value:p,reason:'dur="0" may cause animation to not play'})}let G0=S.getAttribute("begin");if(G0){let L0=G0;if(G0==="0")L0="0s",S.setAttribute("begin",L0),W.push({type:"timing_normalized",element:n,attr:"begin",oldValue:G0,newValue:L0,reason:"Normalized begin value to include time unit"})}}for(let p of S.children)if(a(p))Y(p)},X=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),k=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),w=(S)=>{let C=S.tagName.toLowerCase();if(X.has(C)){let n=[];for(let p of Array.from(S.children))if(a(p)&&k.has(p.tagName.toLowerCase()))n.push(p);if(n.length>0){let p=S.getAttribute("id");if(!p)p=`_fix_${C}_${Math.random().toString(36).substring(2,8)}`,S.setAttribute("id",p),W.push({type:"id_generated",element:C,id:p,reason:"Generated ID for animation targeting after moving animate element"});for(let s of n){if(S.removeChild(s),!s.hasAttribute("href")&&!s.hasAttribute("xlink:href"))s.setAttribute("href",`#${p}`);let G0=S.parentNode;if(G0){let L0=S.nextSibling;if(L0)G0.insertBefore(s,L0);else G0.appendChild(s)}W.push({type:"animation_moved_from_empty_element",element:s.tagName.toLowerCase(),parentElement:C,targetId:p,reason:`SVG 1.1: <${C}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${p}".`})}}}for(let n of Array.from(S.children))if(a(n))w(n)},R=/^([+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?)(EM|EX|PX|IN|CM|MM|PT|PC|DEG|GRAD|RAD|S|MS|HZ|KHZ|%)$/i,I=new Set(["x","y","width","height","rx","ry","cx","cy","r","fx","fy","x1","y1","x2","y2","dx","dy","textLength","startOffset","stroke-width","stroke-dashoffset","font-size","baseline-shift","kerning","letter-spacing","word-spacing","markerWidth","markerHeight","refX","refY","stdDeviation","radius"]),P=(S)=>{for(let C of S.getAttributeNames()){if(!I.has(C)&&!C.includes("-"))continue;let n=S.getAttribute(C);if(!n)continue;let p=n.match(R);if(p){let[,s,G0]=p,L0=G0.toLowerCase();if(G0!==L0){let C0=s+L0;S.setAttribute(C,C0),W.push({type:"unit_normalized",element:S.tagName.toLowerCase(),attr:C,oldValue:n,newValue:C0,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let C of S.children)if(a(C))P(C)},u=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,g=new Set(["points","viewBox","preserveAspectRatio","transform","d","values","keyTimes","keySplines","keyPoints","rotate","stroke-dasharray","baseFrequency","kernelMatrix","tableValues","filterRes","stdDeviation","radius","origin"]),b=(S)=>{for(let C of S.getAttributeNames()){if(!g.has(C)&&C!=="style")continue;let n=S.getAttribute(C);if(!n)continue;if(u.test(n)){let p=n.replace(u," ");S.setAttribute(C,p),W.push({type:"whitespace_normalized",element:S.tagName.toLowerCase(),attr:C,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let C of S.children)if(a(C))b(C)},h=(S)=>{for(let C of S.getAttributeNames()){let n=S.getAttribute(C);if(!n)continue;let p=n,s=!1;if(/\d\.$/.test(p)||/\d\.(?=[,\s;)])/.test(p))p=p.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),s=!0;if(p=p.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),p=p.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),p!==n)s=!0;if(/\.\.+/.test(p))p=p.replace(/\.\.+/g,"."),s=!0;if(s)S.setAttribute(C,p),W.push({type:"number_format_fixed",element:S.tagName.toLowerCase(),attr:C,oldValue:n,newValue:p,reason:"SVG 1.1: Fixed invalid number format"})}for(let C of S.children)if(a(C))h(C)},v=340000000000000000000000000000000000000,E=-340000000000000000000000000000000000000,m=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,c=(S)=>{for(let C of S.getAttributeNames()){let n=S.getAttribute(C);if(!n)continue;if(C==="id"||C==="class"||C.startsWith("xmlns")||C==="href"||C==="xlink:href"||C==="style")continue;let p=n.match(m);if(!p)continue;for(let s of p){let G0=parseFloat(s);if(!isFinite(G0))W.push({type:"invalid_number_detected",element:S.tagName.toLowerCase(),attr:C,value:s,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(G0>v||G0<E)W.push({type:"out_of_range_detected",element:S.tagName.toLowerCase(),attr:C,value:s,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let C of S.children)if(a(C))c(C)},d=(S)=>{let C=S.tagName,n=C.toLowerCase();if(C.includes(":")||X$.has(C)||OJ.has(n));else{let p=v$(C,X$);if(p)W.push({type:"mistyped_element_detected",element:C,suggestion:p,reason:`Unknown element <${C}> - did you mean <${p}>?`});else W.push({type:"unknown_element_detected",element:C,reason:`Unknown element <${C}> - not in SVG 1.1 spec`})}for(let p of S.children)if(a(p))d(p)},N=(S)=>{for(let C of S.getAttributeNames()){if(C.startsWith("xmlns")||C.startsWith("data-"))continue;let n=C.toLowerCase();if(k$.has(C)||YJ.has(n))continue;if(C.startsWith("-webkit-")||C.startsWith("-moz-")||C.startsWith("-ms-")||C.startsWith("-o-"))continue;if(C.includes(":")&&!C.startsWith("xlink:")&&!C.startsWith("xml:"))continue;let p=v$(C,k$);if(p)W.push({type:"mistyped_attribute_detected",element:S.tagName.toLowerCase(),attr:C,suggestion:p,reason:`Unknown attribute '${C}' on <${S.tagName.toLowerCase()}> - did you mean '${p}'?`})}for(let C of S.children)if(a(C))N(C)},y={a:["href"],animate:["attributeName"],animateColor:["attributeName"],animateTransform:["attributeName"],circle:["r"],"color-profile":["name"],cursor:["href"],ellipse:["rx","ry"],feBlend:["in2"],feComposite:["in2"],feConvolveMatrix:["kernelMatrix"],feDisplacementMap:["in2"],feFuncA:["type"],feFuncB:["type"],feFuncG:["type"],feFuncR:["type"],feImage:["href"],font:["horiz-adv-x"],"font-face-uri":["href"],foreignObject:["width","height"],hkern:["k"],image:["href","width","height"],mpath:["href"],path:["d"],polygon:["points"],polyline:["points"],rect:["width","height"],script:["type"],set:["attributeName"],stop:["offset"],style:["type"],textPath:["href"],tref:["href"],use:["href"],vkern:["k"]},B=["href","xlink:href"],t=(S)=>{let C=S.tagName.toLowerCase(),n=y[C];if(n){for(let p of n)if(p==="href"){if(!B.some((G0)=>S.hasAttribute(G0)))W.push({type:"missing_required_attribute",element:C,attr:p,reason:`Element <${C}> is missing required attribute '${p}' (or 'xlink:href')`})}else if(!S.hasAttribute(p))W.push({type:"missing_required_attribute",element:C,attr:p,reason:`Element <${C}> is missing required attribute '${p}'`})}for(let p of S.children)if(a(p))t(p)},i={circle:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),ellipse:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),line:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),path:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polygon:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polyline:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),rect:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),use:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),image:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),animate:new Set(["desc","title","metadata"]),animatecolor:new Set(["desc","title","metadata"]),animatemotion:new Set(["desc","title","metadata","mpath"]),animatetransform:new Set(["desc","title","metadata"]),set:new Set(["desc","title","metadata"]),lineargradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),radialgradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),filter:new Set(["desc","title","metadata","animate","set","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","feflood","fegaussianblur","feimage","femerge","femorphology","feoffset","fespecularlighting","fetile","feturbulence"]),stop:new Set(["animate","animatecolor","set"])},l=(S)=>{let C=S.tagName.toLowerCase(),n=i[C];if(n){for(let p of S.children)if(a(p)){let s=p.tagName.toLowerCase();if(!s.includes(":")&&!n.has(s))W.push({type:"invalid_child_element",parent:C,child:s,reason:`Element <${s}> is not a valid child of <${C}> per SVG 1.1 DTD`})}}for(let p of S.children)if(a(p))l(p)},q0={"alignment-baseline":["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"],"clip-rule":["nonzero","evenodd","inherit"],"color-interpolation":["auto","sRGB","linearRGB","inherit"],"color-interpolation-filters":["auto","sRGB","linearRGB","inherit"],"color-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],direction:["ltr","rtl","inherit"],display:["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"],"dominant-baseline":["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"],"fill-rule":["nonzero","evenodd","inherit"],"font-stretch":["normal","wider","narrower","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","inherit"],"font-style":["normal","italic","oblique","inherit"],"font-variant":["normal","small-caps","inherit"],"font-weight":["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900","inherit"],"image-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],overflow:["visible","hidden","scroll","auto","inherit"],"pointer-events":["visiblePainted","visibleFill","visibleStroke","visible","painted","fill","stroke","all","none","inherit"],"shape-rendering":["auto","optimizeSpeed","crispEdges","geometricPrecision","inherit"],"stroke-linecap":["butt","round","square","inherit"],"stroke-linejoin":["miter","round","bevel","inherit"],"text-anchor":["start","middle","end","inherit"],"text-rendering":["auto","optimizeSpeed","optimizeLegibility","geometricPrecision","inherit"],"unicode-bidi":["normal","embed","bidi-override","inherit"],visibility:["visible","hidden","collapse","inherit"],"writing-mode":["lr-tb","rl-tb","tb-rl","lr","rl","tb","inherit"],"xml:space":["default","preserve"],additive:["replace","sum"],accumulate:["none","sum"],calcMode:["discrete","linear","paced","spline"],fill:["freeze","remove"],restart:["always","whenNotActive","never"],attributeType:["CSS","XML","auto"],edgeMode:["duplicate","wrap","none"],operator:["over","in","out","atop","xor","arithmetic","erode","dilate"],mode:["normal","multiply","screen","darken","lighten"],type:["translate","scale","rotate","skewX","skewY","matrix","saturate","hueRotate","luminanceToAlpha","identity","table","discrete","linear","gamma","fractalNoise","turbulence"],spreadMethod:["pad","reflect","repeat"],gradientUnits:["userSpaceOnUse","objectBoundingBox"],patternUnits:["userSpaceOnUse","objectBoundingBox"],patternContentUnits:["userSpaceOnUse","objectBoundingBox"],clipPathUnits:["userSpaceOnUse","objectBoundingBox"],maskUnits:["userSpaceOnUse","objectBoundingBox"],maskContentUnits:["userSpaceOnUse","objectBoundingBox"],filterUnits:["userSpaceOnUse","objectBoundingBox"],primitiveUnits:["userSpaceOnUse","objectBoundingBox"],markerUnits:["strokeWidth","userSpaceOnUse"],method:["align","stretch"],spacing:["auto","exact"],lengthAdjust:["spacing","spacingAndGlyphs"],preserveAspectRatio:["none","xMinYMin","xMidYMin","xMaxYMin","xMinYMid","xMidYMid","xMaxYMid","xMinYMax","xMidYMax","xMaxYMax"],zoomAndPan:["disable","magnify"],externalResourcesRequired:["true","false"]},f=new Set(["preserveAspectRatio"]),A=(S)=>{let C=S.tagName.toLowerCase();for(let n of S.getAttributeNames()){let p=q0[n];if(p){let s=S.getAttribute(n);if(f.has(n)&&s)s=s.split(/\s+/)[0];if(n==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(C))continue;if(!p.includes(s)&&s!=="inherit")W.push({type:"invalid_enum_value",element:C,attr:n,value:s,validValues:p.slice(0,5).join(", ")+(p.length>5?"...":""),reason:`Invalid value '${s}' for attribute '${n}' - must be one of: ${p.slice(0,5).join(", ")}${p.length>5?"...":""}`})}}for(let n of S.children)if(a(n))A(n)},e={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},"font-size":{min:0,type:"length"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"},width:{min:0,type:"length"},height:{min:0,type:"length"},stdDeviation:{min:0,type:"number"},scale:{type:"number"},baseFrequency:{min:0,type:"number"},numOctaves:{min:1,type:"integer"},seed:{min:0,type:"number"},repeatCount:{min:0,type:"number"}},$0=(S)=>{let C=S.tagName.toLowerCase();for(let n of S.getAttributeNames()){let p=e[n];if(p){let s=S.getAttribute(n);if(s==="inherit"||s==="none"||s==="indefinite"||s==="auto")continue;let G0=s.match(/^([+-]?\d*\.?\d+)/);if(G0){let L0=parseFloat(G0[1]);if(isNaN(L0))W.push({type:"invalid_numeric_value",element:C,attr:n,value:s,reason:`Invalid numeric value '${s}' for attribute '${n}'`});else{if(p.min!==void 0&&L0<p.min)W.push({type:"numeric_out_of_range",element:C,attr:n,value:s,constraint:`min: ${p.min}`,reason:`Value '${s}' for '${n}' is below minimum (${p.min})`});if(p.max!==void 0&&L0>p.max)W.push({type:"numeric_out_of_range",element:C,attr:n,value:s,constraint:`max: ${p.max}`,reason:`Value '${s}' for '${n}' exceeds maximum (${p.max})`});if(p.type==="integer"&&!Number.isInteger(L0))W.push({type:"invalid_numeric_value",element:C,attr:n,value:s,reason:`Attribute '${n}' requires an integer value, got '${s}'`})}}}}for(let n of S.children)if(a(n))$0(n)},Q0=(S)=>{let C=new Map,n=(p)=>{let s=p.getAttribute("id");if(s){if(!C.has(s))C.set(s,[]);C.get(s).push(p.tagName.toLowerCase())}for(let G0 of p.children)if(a(G0))n(G0)};n(S);for(let[p,s]of C)if(s.length>1)W.push({type:"duplicate_id",id:p,count:s.length,elements:s.join(", "),reason:`Duplicate ID '${p}' found on ${s.length} elements: ${s.join(", ")}`})},V0=(S)=>{let C=new Set,n=(L0)=>{let C0=L0.getAttribute("id");if(C0)C.add(C0);for(let E0 of L0.children)if(a(E0))n(E0)};n(S);let p=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,s=/^#(.+)$/,G0=(L0)=>{let C0=L0.tagName.toLowerCase();for(let E0 of L0.getAttributeNames()){let k7=L0.getAttribute(E0),y$;p.lastIndex=0;while((y$=p.exec(k7))!==null){let g7=y$[1];if(!C.has(g7))W.push({type:"broken_reference",element:C0,attr:E0,refId:g7,reason:`Broken reference: url(#${g7}) points to non-existent ID`})}if(E0==="href"||E0==="xlink:href"){let g7=k7.match(s);if(g7){let L$=g7[1];if(!C.has(L$))W.push({type:"broken_reference",element:C0,attr:E0,refId:L$,reason:`Broken reference: ${E0}="#${L$}" points to non-existent ID`})}}}for(let E0 of L0.children)if(a(E0))G0(E0)};G0($)},N0=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),h0=new Set(["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"]),o=(S)=>{let C=S.toLowerCase().trim();if(C==="none"||C==="inherit"||C==="currentcolor")return!0;if(N0.has(C))return!0;if(C.startsWith("url("))return!0;if(/^#[0-9a-f]{3}$/.test(C)||/^#[0-9a-f]{6}$/.test(C))return!0;if(/^rgb\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)$/.test(C))return!0;if(/^rgba\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*[\d.]+%?\s*\)$/.test(C))return!0;return!1},J0=(S)=>{let C=S.tagName.toLowerCase();for(let n of S.getAttributeNames())if(h0.has(n)){let p=S.getAttribute(n);if(!o(p))W.push({type:"invalid_color",element:C,attr:n,value:p,reason:`Invalid color value '${p}' for attribute '${n}'`})}for(let n of S.children)if(a(n))J0(n)},_0=(S)=>{let C=S.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(C)){let s=S.getAttribute("viewBox");if(s){let G0=s.trim().split(/[\s,]+/);if(G0.length!==4)W.push({type:"malformed_viewbox",element:C,value:s,reason:`viewBox must have exactly 4 values (min-x, min-y, width, height), got ${G0.length}`});else{for(let E0=0;E0<G0.length;E0++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(G0[E0])){W.push({type:"malformed_viewbox",element:C,value:s,reason:`viewBox contains invalid number '${G0[E0]}' at position ${E0+1}`});break}let L0=parseFloat(G0[2]),C0=parseFloat(G0[3]);if(isNaN(L0)||isNaN(C0)||L0<0||C0<0)W.push({type:"invalid_viewbox_dimensions",element:C,value:s,reason:`viewBox width and height must be valid non-negative numbers, got ${L0}x${C0}`})}}}let n=S.getAttribute("preserveAspectRatio");if(n){if(!/^(none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax)(\s+(meet|slice))?$/.test(n.trim()))W.push({type:"malformed_preserveaspectratio",element:C,value:n,reason:`Invalid preserveAspectRatio format '${n}'`})}if(["polygon","polyline"].includes(C)){let s=S.getAttribute("points");if(s){let G0=s.trim().split(/[\s,]+/);if(G0.length>0&&G0.length%2!==0)W.push({type:"malformed_points",element:C,value:s.slice(0,50)+(s.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${G0.length}`})}}let p=S.getAttribute("transform");if(p){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(p.trim())){if(!/^[\s\w(),.\-+]+$/.test(p))W.push({type:"malformed_transform",element:C,value:p.slice(0,50)+(p.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let s of S.children)if(a(s))_0(s)},Y0=(S)=>{let C=S.tagName,n=C.toLowerCase();if(C.includes(":")||X$.has(C)||OJ.has(n)){for(let s of Array.from(S.children))if(a(s))Y0(s);return}let p=v$(C,X$);if(p){let s=S.ownerDocument.createElement(p);for(let G0 of S.getAttributeNames())s.setAttribute(G0,S.getAttribute(G0));while(S.firstChild)s.appendChild(S.firstChild);if(S.parentNode)S.parentNode.replaceChild(s,S);W.push({type:"element_typo_fixed",oldName:C,newName:p,reason:`Fixed element typo: <${C}> -> <${p}>`});for(let G0 of Array.from(s.children))if(a(G0))Y0(G0)}else for(let s of Array.from(S.children))if(a(s))Y0(s)},B0=(S)=>{for(let C of Array.from(S.getAttributeNames())){if(C.startsWith("xmlns")||C.startsWith("data-"))continue;if(C.startsWith("-webkit-")||C.startsWith("-moz-"))continue;if(C.includes(":")&&!C.startsWith("xlink:")&&!C.startsWith("xml:"))continue;if(k$.has(C)||YJ.has(C.toLowerCase()))continue;let n=v$(C,k$);if(n){let p=S.getAttribute(C);S.removeAttribute(C),S.setAttribute(n,p),W.push({type:"attr_typo_fixed",element:S.tagName.toLowerCase(),oldAttr:C,newAttr:n,reason:`Fixed attribute typo: '${C}' -> '${n}'`})}}for(let C of S.children)if(a(C))B0(C)},I0=(S)=>{let C=new Map,n=new Set,p=(L0)=>{let C0=L0.getAttribute("id");if(C0)C.set(C0,(C.get(C0)||0)+1),n.add(C0);for(let E0 of L0.children)if(a(E0))p(E0)};p(S);let s=new Set,G0=(L0)=>{let C0=L0.getAttribute("id");if(C0)if(s.has(C0)){let E0=C0,k7=2;while(n.has(E0)||s.has(E0))E0=`${C0}_${k7++}`;L0.setAttribute("id",E0),n.add(E0),s.add(E0),W.push({type:"duplicate_id_renamed",oldId:C0,newId:E0,element:L0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${C0}' -> '${E0}'`})}else s.add(C0);for(let E0 of L0.children)if(a(E0))G0(E0)};G0(S)};if(_($),U(),V($),Y($),w($),P($),b($),h($),Y0($),B0($),I0($),c($),t($),l($),A($),$0($),V0($),J0($),_0($),$.setAttribute("data-fixes-applied",String(W.length)),H&&W.length>0)$.setAttribute("data-fix-report",JSON.stringify(W));return $}),A0={ERROR:"error",WARNING:"warning"},cW={broken_reference:A0.ERROR,broken_url_reference:A0.ERROR,duplicate_id:A0.ERROR,missing_required_attribute:A0.ERROR,invalid_child_element:A0.ERROR,animation_in_empty_element:A0.ERROR,malformed_viewbox:A0.ERROR,malformed_points:A0.ERROR,malformed_transform:A0.ERROR,invalid_enum_value:A0.ERROR,invalid_numeric_constraint:A0.ERROR,invalid_attr_on_element:A0.WARNING,missing_namespace:A0.WARNING,invalid_timing:A0.WARNING,uppercase_unit:A0.WARNING,invalid_whitespace:A0.WARNING,invalid_number:A0.WARNING,mistyped_element_detected:A0.WARNING,unknown_element_detected:A0.WARNING,mistyped_attribute_detected:A0.WARNING,unknown_attribute_detected:A0.WARNING,invalid_color:A0.WARNING,circular_reference:A0.WARNING,deep_nesting:A0.WARNING,empty_defs:A0.WARNING,gradient_stop_order:A0.WARNING,path_complexity:A0.WARNING,external_resource:A0.WARNING,script_content:A0.WARNING,event_handler:A0.WARNING,missing_title:A0.WARNING,missing_desc:A0.WARNING,invalid_aria:A0.WARNING,missing_lang:A0.WARNING},nW=new Set(["onabort","onactivate","onbegin","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onend","onended","onerror","onfocus","onfocusin","onfocusout","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onrepeat","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting","onwheel"]),lW=new Set(["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"]),KZ=new Set(["img","graphics-document","graphics-object","graphics-symbol","group","list","listitem","none","presentation","application"]);function sW($){let J={elements:new Map,lines:[]},Z=0;J.lines.push(0);for(let X=0;X<$.length;X++)if($[X]===`
|
|
351
|
+
`)J.lines.push(X+1);let K=[],Q=/<!\[CDATA\[([\s\S]*?)\]\]>/g,q;while((q=Q.exec($))!==null)K.push({start:q.index,end:q.index+q[0].length});let H=/<!--[\s\S]*?-->/g,W;while((W=H.exec($))!==null)K.push({start:W.index,end:W.index+W[0].length});let z=/<script[^>]*>([\s\S]*?)<\/script>/gi,j;while((j=z.exec($))!==null){let X=j.index+j[0].indexOf(">")+1,k=j.index+j[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}let G=/<style[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=G.exec($))!==null){let X=F.index+F[0].indexOf(">")+1,k=F.index+F[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}K.sort((X,k)=>X.start-k.start);let _=(X)=>{for(let k of K){if(X>=k.start&&X<k.end)return!0;if(k.start>X)break}return!1},U=(X)=>{let k=1;for(let I=0;I<J.lines.length;I++){if(J.lines[I]>X){k=I;break}k=I+1}let w=J.lines[k-1]||0,R=X-w+1;return{line:k,column:R}},M=/<([a-zA-Z][a-zA-Z0-9:_-]*)\s*([^>]*?)(\/?)\s*>/g,V=/([a-zA-Z][a-zA-Z0-9:_-]*)\s*=\s*["']([^"']*)["']/g,Y;while((Y=M.exec($))!==null){if(_(Y.index))continue;let X=Y[1].toLowerCase(),k=Y[2],w=Y.index,R=Y.index+Y[0].length,{line:I,column:P}=U(w),u=k?Y[0].indexOf(k):0,g=new Map;V.lastIndex=0;let b;while((b=V.exec(k))!==null){let h=b[1],v=b[2],E=w+u+b.index,m=U(E);g.set(h.toLowerCase(),{name:h,value:v,line:m.line,column:m.column})}if(!J.elements.has(X))J.elements.set(X,[]);J.elements.get(X).push({line:I,column:P,endColumn:P+Y[0].length-1,attrs:g})}return J.getElementPosition=(X,k=0)=>{let w=J.elements.get(X.toLowerCase());if(w&&w[k]){let R=w[k];return{line:R.line,column:R.column}}return{line:1,column:1}},J.getAttributePosition=(X,k,w=0)=>{let R=J.elements.get(X.toLowerCase());if(R&&R[w]){let I=R[w],P=I.attrs.get(k.toLowerCase());if(P)return{line:P.line,column:P.column};return{line:I.line,column:I.column}}return{line:1,column:1}},J}async function oW($,J={}){PW();let Z=J.errorsOnly===!0,K=J.outputFile||null,Q=(J.outputFormat||"json").toLowerCase(),q=J.includeSource===!0,H=["text","json","xml","yaml"];if(K&&!H.includes(Q))throw new Error(`Invalid outputFormat '${Q}'. Must be one of: ${H.join(", ")}`);let W="",z;try{if(z=w$($),z===D0.SVG_STRING)W=$;else if(z===D0.FILE_PATH){let x=await import("node:fs/promises"),r=(await Promise.resolve().then(() => (O$(),V$))).normalize($);try{W=await x.readFile(r,"utf8")}catch(D){throw new Error(`Failed to read file '${$}': ${D.message}`)}}else if(z===D0.URL)try{let x=await fetch($);if(!x.ok)throw new Error(`HTTP ${x.status}: ${x.statusText}`);W=await x.text()}catch(x){throw new Error(`Failed to fetch URL '${$}': ${x.message}`)}else if(z===D0.DOM_ELEMENT)if(typeof XMLSerializer!=="undefined")W=new XMLSerializer().serializeToString($);else if($.outerHTML)W=$.outerHTML;else throw new Error("Cannot serialize DOM element: XMLSerializer not available");else throw new Error(`Unknown input type: ${typeof $}`)}catch(x){return{issues:[{type:"input_error",severity:A0.ERROR,reason:x.message,line:0,column:0}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{input_error:1}}}let j=q?W.split(`
|
|
352
|
+
`):null,G=sW(W),F,_=[],U=(x)=>{let T=x.match(/line\s*:?\s*(\d+)/i)||x.match(/:(\d+):/);return T?parseInt(T[1],10):1},M=(x)=>{let T=x.match(/column\s*:?\s*(\d+)/i)||x.match(/:\d+:(\d+)/);return T?parseInt(T[1],10):1},V=(x)=>{let T=x,r=[],D="_VALID_ENTITY_",Z0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,O0=T.replace(Z0,D+"$1;").replace(/&/g,"&").replace(new RegExp(D,"g"),"&");if(O0!==T)T=O0,r.push("Escaped unencoded ampersands");let T0=T.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(T0!==T)T=T0,r.push("Removed invalid control characters");if(T.charCodeAt(0)===65279)T=T.slice(1),r.push("Removed UTF-8 BOM");let x0=T.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(F7,$7,i0)=>{if(!i0.includes(">"))return`="${$7}<${i0}"`;return F7});if(x0!==T)T=x0,r.push("Escaped < in attribute values");return{fixed:T,appliedFixes:r}};try{F=await W6($,z)}catch(x){let T=x.message||String(x),r=U(T),D=M(T),{fixed:Z0,appliedFixes:z0}=V(W);if(z0.length>0&&Z0!==W)try{let{JSDOM:H0}=await import("jsdom");F=new H0(Z0,{contentType:"image/svg+xml"}).window.document.documentElement,_.push({type:"parse_recovery",severity:A0.WARNING,reason:`Recovered from parse error. Applied fixes: ${z0.join("; ")}`,line:r,column:D}),_.push({type:"original_parse_error",severity:A0.ERROR,reason:`Original parse error: ${T}`,line:r,column:D})}catch(H0){return{issues:[{type:"parse_error",severity:A0.ERROR,reason:`Failed to parse SVG: ${T}`,line:r,column:D},{type:"recovery_failed",severity:A0.WARNING,reason:`Recovery attempted (${z0.join("; ")}) but still failed: ${H0.message}`,line:r,column:D}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:A0.ERROR,reason:`Failed to parse SVG: ${T}`,line:r,column:D}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let Y=[];if(_.length>0)Y.push(..._);let X=new Map,k=(x)=>{let T=x.toLowerCase(),r=X.get(T)||0;return X.set(T,r+1),r},w=()=>{X.clear()},R=(x,T,r=null,D=null)=>{let Z0;if(r)Z0=G.getAttributePosition(T,r,D||0);else Z0=G.getElementPosition(T,D||0);let z0=cW[x.type]||A0.WARNING,H0={...x,severity:z0,line:Z0.line,column:Z0.column};if(q&&j&&Z0.line>0&&Z0.line<=j.length)H0.sourceLine=j[Z0.line-1];return H0},I=new Set,P=(x)=>{if(!x)return;let T=x.getAttribute("id");if(T)I.add(T);for(let r of x.children)if(a(r))P(r)};P(F);let u=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],g=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);if(T==="g"){for(let D of u)if(x.hasAttribute(D))Y.push(R({type:"invalid_attr_on_element",element:T,attr:D,value:x.getAttribute(D),reason:`SVG 1.1: <g> elements do not support '${D}' attribute`},T,D,r))}for(let D of x.children)if(a(D))g(D)},b=()=>{let x=!1,T=null,r=null,D=(Z0)=>{for(let z0 of Z0.getAttributeNames())if(z0.startsWith("xlink:")){x=!0,T=Z0.tagName.toLowerCase(),r=z0;return}for(let z0 of Z0.children){if(a(z0))D(z0);if(x)return}};if(D(F),x&&!F.hasAttribute("xmlns:xlink")){let Z0=G.getAttributePosition(T,r,0);Y.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:Z0.line,column:Z0.column})}},h=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of["xlink:href","href"]){let Z0=x.getAttribute(D);if(Z0&&Z0.startsWith("#")){let z0=Z0.slice(1);if(z0&&!I.has(z0))Y.push(R({type:"broken_reference",element:T,attr:D,referencedId:z0,reason:`Reference to non-existent ID '${z0}'`},T,D,r))}}for(let D of x.children)if(a(D))h(D)},v=["begin","end","dur","repeatDur","min","max"],E=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),m=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);if(E.has(T))for(let D of v){let Z0=x.getAttribute(D);if(Z0){let z0=Z0.trim();if(z0!==Z0)Y.push(R({type:"invalid_timing",element:T,attr:D,value:Z0,reason:"Timing value has leading/trailing whitespace"},T,D,r));if(/[;,]/.test(z0)&&!/^[\d\w\s.;,+-]+$/.test(z0))Y.push(R({type:"invalid_timing",element:T,attr:D,value:Z0,reason:"Timing value may contain invalid characters"},T,D,r))}}for(let D of x.children)if(a(D))m(D)},c=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),d=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);if(c.has(T)){for(let D of x.children)if(a(D)){let Z0=D.tagName.toLowerCase();if(E.has(Z0))Y.push(R({type:"animation_in_empty_element",element:T,child:Z0,reason:`Animation element <${Z0}> inside <${T}> which has EMPTY content model per SVG 1.1 DTD`},T,null,r))}}for(let D of x.children)if(a(D))d(D)},N=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,y=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],B=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of y){let Z0=x.getAttribute(D);if(Z0){let z0=Z0.match(N);if(z0)for(let H0 of z0){let O0=H0.replace(/[\d.]+/,"");if(O0!==O0.toLowerCase())Y.push(R({type:"uppercase_unit",element:T,attr:D,value:Z0,reason:`Unit '${O0}' should be lowercase '${O0.toLowerCase()}'`},T,D,r))}}}for(let D of x.children)if(a(D))B(D)},t=["points","viewBox","d","values","keyTimes","keySplines","rotate"],i=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of t){let Z0=x.getAttribute(D);if(Z0){if(/[\t\n\r]/.test(Z0)||/ +/.test(Z0))Y.push(R({type:"invalid_whitespace",element:T,attr:D,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},T,D,r))}}for(let D of x.children)if(a(D))i(D)},l=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","font-size"],q0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of l){let Z0=x.getAttribute(D);if(Z0){let z0=Z0.trim();if(/^0\d/.test(z0.replace(/[a-z%]+$/i,"")))Y.push(R({type:"invalid_number",element:T,attr:D,value:Z0,reason:"Number has unnecessary leading zeros"},T,D,r));if(/\.$/.test(z0.replace(/[a-z%]+$/i,"")))Y.push(R({type:"invalid_number",element:T,attr:D,value:Z0,reason:"Number has trailing decimal point"},T,D,r))}}for(let D of x.children)if(a(D))q0(D)},f=(x,T=!1)=>{let r=x.tagName,D=r.toLowerCase(),Z0=k(D),z0=r.includes(":"),H0=T||r5.has(D)||z0;if(!H0){if(!X$.has(r)&&!OJ.has(D)){if(!NW(D)){let O0=v$(r,X$);if(O0)Y.push(R({type:"mistyped_element_detected",element:r,suggestion:O0,reason:`Unknown element <${r}> - did you mean <${O0}>?`},D,null,Z0));else Y.push(R({type:"unknown_element_detected",element:r,reason:`Unknown element <${r}> - not in SVG 1.1 spec`},D,null,Z0))}}}for(let O0 of x.children)if(a(O0))f(O0,H0)},A=(x,T=!1)=>{let r=x.tagName.toLowerCase(),D=k(r),Z0=x.tagName.includes(":"),z0=T||r5.has(r)||Z0;if(!z0)for(let H0 of x.getAttributeNames()){if(H0.startsWith("data-")||H0.startsWith("aria-"))continue;if(H0==="xmlns"||H0.startsWith("xmlns:"))continue;if(H0.includes(":")&&!H0.startsWith("xlink:")&&!H0.startsWith("xml:"))continue;if(IW(H0))continue;if(!k$.has(H0)&&!YJ.has(H0.toLowerCase())){let O0=v$(H0,k$);if(O0)Y.push(R({type:"mistyped_attribute_detected",element:r,attr:H0,suggestion:O0,reason:`Unknown attribute '${H0}' - did you mean '${O0}'?`},r,H0,D));else Y.push(R({type:"unknown_attribute_detected",element:r,attr:H0,reason:`Unknown attribute '${H0}' on <${r}> - not in SVG 1.1 spec`},r,H0,D))}}for(let H0 of x.children)if(a(H0))A(H0,z0)},e={use:["xlink:href","href"],image:["xlink:href","href"],feImage:["xlink:href","href"],textPath:["xlink:href","href"],mpath:["xlink:href","href"],animate:["attributeName"],animateTransform:["attributeName","type"],animateMotion:[],animateColor:["attributeName"],set:["attributeName"],feBlend:["in2"],feComposite:["in2"],feDisplacementMap:["in2","scale"],feMorphology:["operator"],feTurbulence:["type"],feConvolveMatrix:["kernelMatrix"],feFuncR:["type"],feFuncG:["type"],feFuncB:["type"],feFuncA:["type"],linearGradient:[],radialGradient:[],stop:["offset"]},$0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T),D=e[T];if(D&&D.length>0){if(D.includes("xlink:href")&&D.includes("href")){if(!x.hasAttribute("xlink:href")&&!x.hasAttribute("href"))Y.push(R({type:"missing_required_attribute",element:T,attrs:["href","xlink:href"],reason:`<${T}> requires 'href' or 'xlink:href' attribute`},T,null,r))}else for(let Z0 of D)if(!x.hasAttribute(Z0))Y.push(R({type:"missing_required_attribute",element:T,attr:Z0,reason:`<${T}> requires '${Z0}' attribute per SVG 1.1 DTD`},T,Z0,r))}for(let Z0 of x.children)if(a(Z0))$0(Z0)},Q0={linearGradient:new Set(["stop","animate","animateTransform","set"]),radialGradient:new Set(["stop","animate","animateTransform","set"]),stop:new Set(["animate","set"]),clipPath:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","animate","animateTransform","set","desc","title"]),mask:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","g","defs","image","switch","a","animate","animateTransform","set","desc","title"])},V0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T),D=Q0[T];if(D){for(let Z0 of x.children)if(a(Z0)){let z0=Z0.tagName.toLowerCase();if(!z0.includes(":")&&!D.has(z0))Y.push(R({type:"invalid_child_element",element:T,child:z0,reason:`<${z0}> is not a valid child of <${T}> per SVG 1.1 DTD`},T,null,r))}}for(let Z0 of x.children)if(a(Z0))V0(Z0)},N0={spreadMethod:new Set(["pad","reflect","repeat"]),gradientUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),clipPathUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),filterUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),primitiveUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),markerUnits:new Set(["strokeWidth","userSpaceOnUse"]),"fill-rule":new Set(["nonzero","evenodd","inherit"]),"clip-rule":new Set(["nonzero","evenodd","inherit"]),"stroke-linecap":new Set(["butt","round","square","inherit"]),"stroke-linejoin":new Set(["miter","round","bevel","inherit"]),"text-anchor":new Set(["start","middle","end","inherit"]),"dominant-baseline":new Set(["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"]),"alignment-baseline":new Set(["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"]),visibility:new Set(["visible","hidden","collapse","inherit"]),display:new Set(["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"]),overflow:new Set(["visible","hidden","scroll","auto","inherit"])},h0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let[D,Z0]of Object.entries(N0)){let z0=x.getAttribute(D);if(z0&&!Z0.has(z0))Y.push(R({type:"invalid_enum_value",element:T,attr:D,value:z0,validValues:[...Z0],reason:`Invalid value '${z0}' for '${D}'. Valid values: ${[...Z0].join(", ")}`},T,D,r))}for(let D of x.children)if(a(D))h0(D)},o={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"}},J0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let[D,Z0]of Object.entries(o)){let z0=x.getAttribute(D);if(z0){let H0=parseFloat(z0);if(!isNaN(H0)){if(Z0.min!==void 0&&H0<Z0.min)Y.push(R({type:"invalid_numeric_constraint",element:T,attr:D,value:z0,reason:`Value ${H0} is below minimum ${Z0.min}`},T,D,r));if(Z0.max!==void 0&&H0>Z0.max)Y.push(R({type:"invalid_numeric_constraint",element:T,attr:D,value:z0,reason:`Value ${H0} is above maximum ${Z0.max}`},T,D,r))}}}for(let D of x.children)if(a(D))J0(D)},_0=(x)=>{let T=new Map,r=new Map,D=(Z0)=>{let z0=Z0.tagName.toLowerCase(),H0=k(z0),O0=Z0.getAttribute("id");if(O0){if(!T.has(O0))T.set(O0,[]),r.set(O0,{tagName:z0,occIdx:H0});T.get(O0).push(z0)}for(let T0 of Z0.children)if(a(T0))D(T0)};D(x);for(let[Z0,z0]of T)if(z0.length>1){let H0=r.get(Z0);Y.push(R({type:"duplicate_id",id:Z0,elements:z0,count:z0.length,reason:`ID '${Z0}' is used ${z0.length} times (on ${z0.join(", ")})`},H0.tagName,"id",H0.occIdx))}},Y0=/url\(#([^)]+)\)/g,B0=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],I0=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of B0){let Z0=x.getAttribute(D);if(Z0){let z0;Y0.lastIndex=0;while((z0=Y0.exec(Z0))!==null){let H0=z0[1];if(!I.has(H0))Y.push(R({type:"broken_url_reference",element:T,attr:D,referencedId:H0,reason:`url(#${H0}) references non-existent ID`},T,D,r))}}}for(let D of x.children)if(a(D))I0(D)},S=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","currentcolor","inherit","none","transparent"]),C=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],n=(x)=>{let T=x.toLowerCase().trim();if(S.has(T))return!0;if(/^#[0-9a-f]{3}$/i.test(T))return!0;if(/^#[0-9a-f]{4}$/i.test(T))return!0;if(/^#[0-9a-f]{6}$/i.test(T))return!0;if(/^#[0-9a-f]{8}$/i.test(T))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(T))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(T))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(T))return!0;if(/^url\(#[^)]+\)$/i.test(T))return!0;return!1},p=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of C){let Z0=x.getAttribute(D);if(Z0&&!n(Z0))Y.push(R({type:"invalid_color",element:T,attr:D,value:Z0,reason:`Invalid color value '${Z0}'`},T,D,r))}for(let D of x.children)if(a(D))p(D)},s=(x)=>{let T=x.tagName.toLowerCase(),r=k(T),D=x.getAttribute("viewBox");if(D){let H0=D.trim().split(/[\s,]+/);if(H0.length!==4||!H0.every((O0)=>!isNaN(parseFloat(O0))))Y.push(R({type:"malformed_viewbox",element:T,value:D,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},T,"viewBox",r))}let Z0=x.getAttribute("points");if(Z0){let H0=Z0.trim().split(/[\s,]+/).filter((O0)=>O0);if(H0.length%2!==0||!H0.every((O0)=>!isNaN(parseFloat(O0))))Y.push(R({type:"malformed_points",element:T,value:Z0.length>50?Z0.substring(0,50)+"...":Z0,reason:"points must be pairs of numbers"},T,"points",r))}let z0=x.getAttribute("transform");if(z0){let H0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,O0=z0.trim();while(O0.length>0){let T0=O0.match(H0);if(T0&&T0[0].length>0)O0=O0.substring(T0[0].length);else if(!T0){Y.push(R({type:"malformed_transform",element:T,value:z0.length>50?z0.substring(0,50)+"...":z0,reason:`Invalid transform syntax near '${O0.substring(0,20)}'`},T,"transform",r));break}else O0=O0.substring(1)}}if(T==="path"){let H0=x.getAttribute("d");if(H0){let O0=H0.trim();if(O0.length>0){if(!/^[Mm]/.test(O0))Y.push(R({type:"malformed_path_data",element:"path",value:H0.length>50?H0.substring(0,50)+"...":H0,reason:"Path data must start with M or m command"},"path","d",r));let T0=O0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(T0.length>0)Y.push(R({type:"malformed_path_data",element:"path",value:H0.length>50?H0.substring(0,50)+"...":H0,reason:`Path data contains invalid characters: '${T0.substring(0,10)}'`},"path","d",r))}}}for(let H0 of x.children)if(a(H0))s(H0)},G0=()=>{let x=new Map,T=(H0)=>{let O0=H0.getAttribute("id");if(O0)x.set(O0,H0);for(let T0 of H0.children)if(a(T0))T(T0)};T(F);let r=["href","xlink:href","mask","clip-path","filter","fill","stroke"],D=(H0)=>{if(!H0)return null;let O0=H0.match(/url\(#([^)]+)\)/);if(O0)return O0[1];let T0=H0.match(/^#(.+)$/);if(T0)return T0[1];return null},Z0=(H0,O0=new Set)=>{if(O0.has(H0))return!0;let T0=x.get(H0);if(!T0)return!1;O0.add(H0);let x0=($7)=>{for(let i0 of r){let nJ=D($7.getAttribute(i0));if(nJ&&Z0(nJ,O0))return!0}for(let i0 of $7.children)if(a(i0)&&x0(i0))return!0;return!1},F7=x0(T0);return O0.delete(H0),F7},z0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[H0,O0]of x){let T0=O0.tagName.toLowerCase();if(z0.includes(T0)){if(Z0(H0)){w();let x0=k(T0);Y.push(R({type:"circular_reference",element:T0,attr:"id",value:H0,reason:`Circular reference detected: '${H0}' directly or indirectly references itself`},T0,"id",x0))}}}},L0=50,C0=(x,T=0)=>{if(T>L0){let r=x.tagName.toLowerCase(),D=k(r);Y.push(R({type:"deep_nesting",element:r,value:String(T),reason:`Element nesting depth (${T}) exceeds ${L0} levels`},r,null,D));return}for(let r of x.children)if(a(r))C0(r,T+1)},E0=(x)=>{let T=x.tagName.toLowerCase();if(T==="defs"){let r=!1;for(let D of x.childNodes)if(a(D)){r=!0;break}if(!r){let D=k(T);Y.push(R({type:"empty_defs",element:T,reason:"Empty <defs> element (can be removed)"},T,null,D))}}for(let r of x.children)if(a(r))E0(r)},k7=(x)=>{let T=x.tagName.toLowerCase();if(T==="lineargradient"||T==="radialgradient"){let r=Array.from(x.children).filter((D)=>a(D)&&D.tagName.toLowerCase()==="stop");if(r.length>=2){let D=-1;for(let Z0 of r){let z0=Z0.getAttribute("offset")||"0",H0=parseFloat(z0);if(z0.includes("%"))H0=H0/100;if(!isNaN(H0)&&H0<D){let O0=k(T);Y.push(R({type:"gradient_stop_order",element:T,reason:`Gradient stops not in ascending offset order (${D} followed by ${H0})`},T,null,O0));break}if(!isNaN(H0))D=H0}}}for(let r of x.children)if(a(r))k7(r)},y$=1e4,g7=(x)=>{let T=x.tagName.toLowerCase();if(T==="path"){let r=x.getAttribute("d");if(r){let D=r.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(D&&D.length>y$){let Z0=k(T);Y.push(R({type:"path_complexity",element:T,attr:"d",value:`${D.length} coordinates`,reason:`Path has ${D.length} coordinates (>${y$}), may cause slow rendering`},T,"d",Z0))}}}for(let r of x.children)if(a(r))g7(r)},L$=(x)=>{let T=x.tagName.toLowerCase(),r=k(T),D=["href","xlink:href"];for(let Z0 of D){let z0=x.getAttribute(Z0);if(z0&&(z0.startsWith("http://")||z0.startsWith("https://")||z0.startsWith("//")))Y.push(R({type:"external_resource",element:T,attr:Z0,value:z0.length>60?z0.substring(0,60)+"...":z0,reason:"External resource reference detected (potential security/CORS issue)"},T,Z0,r))}if(T==="style"&&x.textContent){let Z0=x.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(Z0)Y.push(R({type:"external_resource",element:T,value:Z0[1],reason:"External CSS import detected in style element"},T,null,r))}for(let Z0 of x.children)if(a(Z0))L$(Z0)},dJ=(x)=>{let T=x.tagName.toLowerCase();if(T==="script"){let r=k(T);Y.push(R({type:"script_content",element:T,reason:"Script element detected (potential security issue in untrusted SVGs)"},T,null,r))}for(let r of x.children)if(a(r))dJ(r)},pJ=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of x.getAttributeNames())if(nW.has(D.toLowerCase()))Y.push(R({type:"event_handler",element:T,attr:D,reason:`Event handler attribute '${D}' detected (potential XSS vector)`},T,D,r));for(let D of x.children)if(a(D))pJ(D)},TK=()=>{let x=!1,T=!1,r=!1,D=F.hasAttribute("lang")||F.hasAttribute("xml:lang"),Z0=(T0)=>{for(let x0 of T0.children){if(!a(x0))continue;let F7=x0.tagName.toLowerCase();if(F7==="title")x=!0;if(F7==="desc")T=!0;if(F7==="text"||F7==="tspan"||F7==="textpath")r=!0;Z0(x0)}};if(Z0(F),!x)Y.push(R({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let z0=0,H0=(T0)=>{z0++;for(let x0 of T0.children)if(a(x0))H0(x0)};if(H0(F),!T&&z0>10)Y.push(R({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${z0} elements)`},"svg",null,0));if(r&&!D)Y.push(R({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let O0=(T0)=>{let x0=T0.tagName.toLowerCase(),F7=k(x0);for(let $7 of T0.getAttributeNames()){if($7.startsWith("aria-")&&!lW.has($7.toLowerCase()))Y.push(R({type:"invalid_aria",element:x0,attr:$7,reason:`Unknown ARIA attribute '${$7}'`},x0,$7,F7));if($7==="role"){let i0=T0.getAttribute("role");if(i0&&!KZ.has(i0.toLowerCase()))Y.push(R({type:"invalid_aria",element:x0,attr:"role",value:i0,reason:`Invalid role value '${i0}' (valid: ${Array.from(KZ).slice(0,5).join(", ")}...)`},x0,"role",F7))}if($7==="aria-hidden"){let i0=T0.getAttribute("aria-hidden");if(i0&&i0!=="true"&&i0!=="false")Y.push(R({type:"invalid_aria",element:x0,attr:"aria-hidden",value:i0,reason:`aria-hidden must be 'true' or 'false', got '${i0}'`},x0,"aria-hidden",F7))}}for(let $7 of T0.children)if(a($7))O0($7)};w(),O0(F)};w(),g(F),b(),w(),h(F),w(),m(F),w(),d(F),w(),B(F),w(),i(F),w(),q0(F),w(),f(F),w(),A(F),w(),$0(F),w(),V0(F),w(),h0(F),w(),J0(F),w(),_0(F),w(),I0(F),w(),p(F),w(),s(F),w(),G0(),w(),C0(F),w(),E0(F),w(),k7(F),w(),g7(F),w(),L$(F),w(),dJ(F),w(),pJ(F),TK(),Y.sort((x,T)=>{if(x.line!==T.line)return x.line-T.line;return x.column-T.column});let G6=Y;if(Z)G6=Y.filter((x)=>x.severity===A0.ERROR);let q9=Y.filter((x)=>x.severity===A0.ERROR).length,cJ=Y.filter((x)=>x.severity===A0.WARNING).length,H9={};for(let x of G6)H9[x.type]=(H9[x.type]||0)+1;let z$={issues:G6,isValid:q9===0,hasErrors:q9>0,hasWarnings:cJ>0,errorCount:q9,warningCount:cJ,issueCount:G6.length,summary:H9};if(K)try{let x=await import("node:fs/promises"),T=await Promise.resolve().then(() => (O$(),V$)),r;switch(Q){case"json":r=JSON.stringify(z$,null,2);break;case"yaml":r=rW(z$);break;case"xml":r=aW(z$);break;case"text":default:r=iW(z$);break}let D=T.normalize(K);await x.writeFile(D,r,"utf8"),z$.outputFile=D}catch(x){z$.exportError=`Failed to write report to '${K}': ${x.message}`}return z$}function iW($){let J=["=".repeat(60),"SVG VALIDATION REPORT","=".repeat(60),"",`Status: ${$.isValid?"VALID":"INVALID"}`,`Errors: ${$.errorCount}`,`Warnings: ${$.warningCount}`,`Total Issues: ${$.issueCount}`,""];if($.issues.length>0){J.push("-".repeat(60)),J.push("ISSUES:"),J.push("-".repeat(60)),J.push("");for(let Z of $.issues){let K=Z.severity.toUpperCase(),Q=`${Z.line}:${Z.column}`;if(J.push(`[${K}] Line ${Q}: ${Z.type}`),Z.element)J.push(` Element: <${Z.element}>`);if(Z.attr)J.push(` Attribute: ${Z.attr}`);if(Z.value)J.push(` Value: ${Z.value}`);if(J.push(` ${Z.reason}`),Z.sourceLine)J.push(` Source: ${Z.sourceLine.trim()}`);J.push("")}}J.push("=".repeat(60)),J.push("SUMMARY BY TYPE:"),J.push("-".repeat(60));for(let[Z,K]of Object.entries($.summary))J.push(` ${Z}: ${K}`);return J.push("=".repeat(60)),J.join(`
|
|
353
|
+
`)}function rW($){let J=["validation_result:",` is_valid: ${$.isValid}`,` has_errors: ${$.hasErrors}`,` has_warnings: ${$.hasWarnings}`,` error_count: ${$.errorCount}`,` warning_count: ${$.warningCount}`,` issue_count: ${$.issueCount}`,""," summary:"];for(let[K,Q]of Object.entries($.summary))J.push(` ${K}: ${Q}`);J.push(""),J.push(" issues:");let Z=(K)=>String(K).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");for(let K of $.issues){if(J.push(` - type: ${K.type}`),J.push(` severity: ${K.severity}`),J.push(` line: ${K.line}`),J.push(` column: ${K.column}`),K.element)J.push(` element: "${Z(K.element)}"`);if(K.attr)J.push(` attr: "${Z(K.attr)}"`);if(K.value)J.push(` value: "${Z(K.value)}"`);if(J.push(` reason: "${Z(K.reason)}"`),K.sourceLine)J.push(` source_line: "${Z(K.sourceLine)}"`)}return J.join(`
|
|
354
|
+
`)}function aW($){let J=(K)=>String(K).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Z=['<?xml version="1.0" encoding="UTF-8"?>',"<validation_result>",` <is_valid>${$.isValid}</is_valid>`,` <has_errors>${$.hasErrors}</has_errors>`,` <has_warnings>${$.hasWarnings}</has_warnings>`,` <error_count>${$.errorCount}</error_count>`,` <warning_count>${$.warningCount}</warning_count>`,` <issue_count>${$.issueCount}</issue_count>`," <summary>"];for(let[K,Q]of Object.entries($.summary))Z.push(` <${K}>${Q}</${K}>`);Z.push(" </summary>"),Z.push(" <issues>");for(let K of $.issues){if(Z.push(" <issue>"),Z.push(` <type>${J(K.type)}</type>`),Z.push(` <severity>${J(K.severity)}</severity>`),Z.push(` <line>${K.line}</line>`),Z.push(` <column>${K.column}</column>`),K.element)Z.push(` <element>${J(K.element)}</element>`);if(K.attr)Z.push(` <attr>${J(K.attr)}</attr>`);if(K.value)Z.push(` <value>${J(K.value)}</value>`);if(Z.push(` <reason>${J(K.reason)}</reason>`),K.sourceLine)Z.push(` <source_line>${J(K.sourceLine)}</source_line>`);Z.push(" </issue>")}return Z.push(" </issues>"),Z.push("</validation_result>"),Z.join(`
|
|
355
|
+
`)}function jK($){let J=1;for(let Z of $.children)if(a(Z))J+=jK(Z);return J}var GK=F0(async($,J={})=>{let Z=K7($,{minify:J.minify!==!1}),K=await f$(Z,{precision:J.precision||6,curveSegments:J.curveSegments||20,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,...J});return u0(K.svg)}),FK=F0(($,J={})=>{let Z=$.getElementsByTagName("path");for(let K of Z){let Q=K.getAttribute("d");if(!Q)continue;try{let q=J$(Q),H=I$(q,J.precision||6);K.setAttribute("d",H)}catch(q){console.warn(`Failed to simplify path: ${q.message}`,{pathData:Q.substring(0,100)})}}return $}),_K=F0(($,J={})=>{return d5($,{precision:J.precision??3,removeLinearSplines:J.removeLinearSplines!==!1,optimizeValues:J.optimizeValues!==!1}),$}),UK=F0(($,J={})=>{return p5($,{floatPrecision:J.floatPrecision??J.precision??3,straightCurves:J.straightCurves!==!1,lineShorthands:J.lineShorthands!==!1,convertToZ:J.convertToZ!==!1,utilizeAbsolute:J.utilizeAbsolute!==!1,straightTolerance:J.straightTolerance??0.5}),$}),VK=F0(($,J={})=>{let Z=J.tolerance??1,K=J.algorithm??"douglas-peucker",Q=J.respectStroke!==!1,q=h7($),H=(W)=>{if(W.tagName?.toLowerCase()==="path"){let j=W.getAttribute("d");if(j){let G=Z;if(Q){let U=i$(W),M=o$(W,U,q);if(M.hasStroke&&M.strokeWidth.greaterThan(0)){let V=M.strokeWidth.div(4).toNumber();G=Math.min(Z,V)}}let F=s0(j),_=r9(F,G,K);if(_.simplified){let U=o0(_.commands,J.precision??3);W.setAttribute("d",U)}}}for(let j of W.children||[])H(j)};return H($),$}),OK=F0(($,J={})=>{let Z=(K)=>{let Q=K.getAttribute("transform");if(Q){let q=V7(Q),H=F8(q);K.setAttribute("data-decomposed",JSON.stringify({translateX:H.translateX.toNumber(),translateY:H.translateY.toNumber(),rotation:H.rotation.toNumber(),scaleX:H.scaleX.toNumber(),scaleY:H.scaleY.toNumber(),skewX:H.skewX.toNumber()}))}for(let q of K.children)if(a(q))Z(q)};return Z($),$});function i6($,J){let Z=$.tagName.toLowerCase();try{if(Z==="path"){let K=$.getAttribute("d");if(!K)return null;let Q=J$(K),q=[],H=0,W=0;for(let z of Q)if(z.command==="M"||z.command==="L")H=z.args[0].toNumber(),W=z.args[1].toNumber(),q.push({x:H,y:W});return q}if(Z==="rect"){let K=$.getAttribute("x")||"0",Q=$.getAttribute("y")||"0",q=$.getAttribute("width")||"0",H=$.getAttribute("height")||"0";if(o7(K)||o7(Q)||o7(q)||o7(H))return null;let W=parseFloat(K),z=parseFloat(Q),j=parseFloat(q),G=parseFloat(H);if(isNaN(W)||isNaN(z)||isNaN(j)||isNaN(G))return null;return[{x:W,y:z},{x:W+j,y:z},{x:W+j,y:z+G},{x:W,y:z+G}]}if(Z==="circle"){let K=parseFloat($.getAttribute("cx")||"0"),Q=parseFloat($.getAttribute("cy")||"0"),q=parseFloat($.getAttribute("r")||"0");if(isNaN(K)||isNaN(Q)||isNaN(q))return null;let H=[];for(let W=0;W<J;W++){let z=W/J*2*Math.PI;H.push({x:K+q*Math.cos(z),y:Q+q*Math.sin(z)})}return H}return null}catch(K){return console.warn(`getShapePolygon failed for ${Z}:`,K.message),null}}var tW={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".bmp":"image/bmp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".wav":"audio/wav",".mp3":"audio/mpeg",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".webm":"audio/webm",".mp4":"video/mp4",".ogv":"video/ogg",".mov":"video/quicktime",".css":"text/css",".js":"text/javascript"};function CJ(){return typeof process!=="undefined"&&process.versions?.node}function QZ($){if(!$||typeof $!=="string")return!1;if($.startsWith("#"))return!1;if($.startsWith("data:"))return!1;return!0}function eW($){let J=$.indexOf("#");if(J===-1)return{path:$,fragment:null};return{path:$.substring(0,J),fragment:$.substring(J+1)}}function r6($){let J=($.match(/\.[a-z0-9]+$/i)||[""])[0].toLowerCase();return tW[J]||"application/octet-stream"}function l7($,J){if(!$)return $;if($.match(/^https?:\/\//i))return $;if($.startsWith("data:"))return $;if($.startsWith("file://"))return $;if(!J)return $;if(J.match(/^https?:\/\//i))try{return new URL($,J).href}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);return $}if(CJ())try{let K=(O$(),vK(V$)),Q=J.endsWith("/")?J:K.dirname(J),q=K.resolve(Q,$),H=K.resolve(Q);if(!q.startsWith(H+K.sep)&&q!==H)return console.warn(`Path traversal blocked: ${$} escapes base directory`),$;return q}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);let Q=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked in fallback: ${$}`),$;return Q+$}let Z=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked: ${$}`),$;return Z+$}async function s7($,J="text",Z=30000){if(CJ()&&!$.match(/^https?:\/\//i)){let q=await import("node:fs/promises");return{content:J==="binary"?await q.readFile($):await q.readFile($,"utf8"),contentType:r6($)}}let K=new AbortController,Q=setTimeout(()=>K.abort(),Z);try{let q=await fetch($,{signal:K.signal});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);let H=q.headers.get("content-type")||r6($);return{content:J==="binary"?await q.arrayBuffer():await q.text(),contentType:H}}finally{clearTimeout(Q)}}function q6($,J){let Z;if(CJ())Z=Buffer.from($).toString("base64");else{let K=new Uint8Array($),Q="";for(let q=0;q<K.length;q++)Q+=String.fromCharCode(K[q]);Z=btoa(Q)}return`data:${J};base64,${Z}`}function VJ($){let J=[],Z=[],K=/@import\s+(?:url\(\s*["']?([^"')]+)["']?\s*\)|["']([^"']+)["'])/gi,Q,q=0;while((Q=K.exec($))!==null){if(Q.index===q&&Q[0].length===0){console.error("Regex matched empty string in @import, breaking to prevent infinite loop");break}q=Q.index+Math.max(1,Q[0].length),J.push({url:Q[1]||Q[2],fullMatch:Q[0],index:Q.index})}let H=/url\(\s*["']?([^"')]+)["']?\s*\)/gi,W=0;while((Q=H.exec($))!==null){if(Q.index===W&&Q[0].length===0){console.error("Regex matched empty string in url(), breaking to prevent infinite loop");break}if(W=Q.index+Math.max(1,Q[0].length),$.substring(Math.max(0,Q.index-10),Q.index).includes("@import"))continue;if(Q[1].startsWith("#"))continue;if(Q[1].startsWith("data:"))continue;Z.push({url:Q[1],fullMatch:Q[0],index:Q.index})}return{imports:J,urls:Z}}function MJ($,J,Z=new Map){if(!$)return Z;let K=$.getAttribute?.("id");if(K){let H=J+K;Z.set(K,H),$.setAttribute("id",H)}let Q=["href","xlink:href","fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end"];for(let H of Q){let W=$.getAttribute?.(H);if(!W)continue;if(W.includes("url(#")){let z=W.replace(/url\(#([^)]+)\)/g,(j,G)=>{return`url(#${Z.get(G)||J+G})`});$.setAttribute(H,z)}else if(W.startsWith("#")){let z=W.substring(1);$.setAttribute(H,"#"+(Z.get(z)||J+z))}}let q=$.getAttribute?.("style");if(q&&q.includes("url(#")){let H=q.replace(/url\(#([^)]+)\)/g,(W,z)=>{return`url(#${Z.get(z)||J+z})`});$.setAttribute("style",H)}if($.children)for(let H of $.children)MJ(H,J,Z);return Z}function YK($,J,Z){if(!$){console.warn("setCDATAContent called with null element");return}let K=0,Q=1e4;while($.firstChild&&K++<Q){let H=$.firstChild;if($.removeChild(H),$.firstChild===H){console.error("removeChild failed to remove child in setCDATAContent, breaking to prevent infinite loop");break}}if(K>=Q)console.error(`Safety limit reached in setCDATAContent: ${Q} children processed`);let q=J.includes("<")||J.includes("&")||J.includes("]]>");if(q&&typeof Z.createCDATASection==="function")if(J.includes("]]>")){let H=J.split("]]>");for(let W=0;W<H.length;W++)if(W===0)$.appendChild(Z.createCDATASection(H[W]+"]]"));else if(W===H.length-1)$.appendChild(Z.createCDATASection(">"+H[W]));else $.appendChild(Z.createCDATASection(">"+H[W]+"]]"))}else $.appendChild(Z.createCDATASection(J));else if(q){let H=J.replace(/\]\]>/g,"]]]]><![CDATA[>");$.setAttribute("data-cdata-pending","true"),$.textContent=H}else $.textContent=J}var $z={audio:[".wav",".mp3",".ogg",".webm",".m4a",".aac",".flac"],image:[".png",".jpg",".jpeg",".gif",".svg",".webp",".avif",".ico",".bmp"],video:[".mp4",".webm",".ogv",".avi",".mov"],data:[".json",".xml",".txt",".csv",".tsv"],font:[".woff",".woff2",".ttf",".otf",".eot"]},Jz=Object.values($z).flat();function Zz($){let J=new Set,Z=Jz.map((q)=>q.replace(".","\\.")).join("|"),K=new RegExp(`["'\`]([^"'\`]*(?:${Z}))["'\`]`,"gi"),Q;while((Q=K.exec($))!==null){let q=Q[1];if(q&&!q.startsWith("data:")&&!q.match(/^https?:\/\/(?!localhost)/)&&q.length>0)J.add(q)}return J}function Kz($){if($.size===0)return"";let J={};for(let[Z,K]of $)J[Z]=K;return`
|
|
436
356
|
// ===== EMBEDDED RESOURCES INTERCEPTOR (auto-generated) =====
|
|
437
357
|
(function() {
|
|
438
|
-
var __EMBEDDED_RESOURCES__ = ${JSON.stringify(
|
|
358
|
+
var __EMBEDDED_RESOURCES__ = ${JSON.stringify(J,null,0)};
|
|
439
359
|
|
|
440
360
|
// Helper to normalize paths for lookup
|
|
441
361
|
function normalizePath(url) {
|
|
@@ -569,10 +489,10 @@ ${o}
|
|
|
569
489
|
})();
|
|
570
490
|
// ===== END EMBEDDED RESOURCES INTERCEPTOR =====
|
|
571
491
|
|
|
572
|
-
`}function Wo(t){let a=new Map,e=(r,l)=>{if(!r||!l)return;let o=r.replace(/['"]/g,"").trim().split(",")[0].trim();if(!a.has(o))a.set(o,new Set);let x=a.get(o);for(let p of l)x.add(p)},i=(r)=>{if(!r)return;let l=(r.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),o=l?l[1]:null,x=r.getAttribute?.("font-family"),p=r.getAttribute?.("face"),n=o||x||p,c="";if(r.childNodes){for(let s of r.childNodes)if(s.nodeType===3)c+=s.nodeValue||""}if(n&&c.trim())e(n,c);if(r.tagName==="text"||r.tagName==="tspan"){let s=n;if(!s&&r.parentNode){let m=(r.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);s=m?m[1]:r.parentNode.getAttribute?.("font-family")}if(s&&c.trim())e(s,c)}if(r.children)for(let s of r.children)i(s)};return i(t),a}function zo(t){let a=[...t].sort().join("");return encodeURIComponent(a)}function Ho(t){return t&&(t.includes("fonts.googleapis.com")||t.includes("fonts.gstatic.com"))}function Qo(t){try{let a=new URL(t).searchParams.get("family");if(a)return a.split(":")[0].replace(/\+/g," ")}catch(a){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${a.message}`);let e=t.match(/family=([^&:]+)/);if(e)return e[1].replace(/\+/g," ")}return null}function qo(t,a){if(!a)return t;try{let e=new URL(t);return e.searchParams.set("text",decodeURIComponent(a)),e.toString()}catch(e){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${e.message}`);let i=t.includes("?")?"&":"?";return`${t}${i}text=${a}`}}var q2=p3(async(t,a={})=>{let{basePath:e="",embedImages:i=!0,embedExternalSVGs:r=!0,externalSVGMode:l="extract",embedCSS:o=!0,embedFonts:x=!0,embedScripts:p=!0,embedAudio:n=!1,subsetFonts:c=!0,verbose:s=!1,recursive:m=!0,maxRecursionDepth:g=10,timeout:u=30000,onMissingResource:y="warn",onProgress:v=null,idPrefix:E="ext_",_visitedURLs:C=null}=a,P=C||new Set,S=[],f=new Map,B=0,R=(I)=>{if(!I||!I.attributes)return;let d=["http://www.inkscape.org/namespaces/inkscape","http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","http://ns.adobe.com/AdobeIllustrator/","http://ns.adobe.com/AdobeSVGViewerExtensions/","http://www.bohemiancoding.com/sketch/ns","http://www.figma.com/figma/ns","http://www.serif.com/","http://www.vecta.io/nano"],Y=["http://www.w3.org/2000/svg","http://www.w3.org/1999/xlink","http://www.w3.org/XML/1998/namespace","http://www.w3.org/2000/xmlns/"],X=I.attributes;for(let F=0;F<X.length;F++){let V=X[F];if(V.name.startsWith("xmlns:")){let T=V.name.substring(6),j=V.value;if(d.some((A)=>j.startsWith(A))||!Y.includes(j))f.set(T,j)}}},k=(I,d)=>{let Y=`Failed to fetch resource: ${I} - ${d.message}`;if(y==="fail")throw Error(Y);else if(y==="warn")S.push(Y),console.warn("embedExternalDependencies:",Y);return null};if(i){let I=[...t.getElementsByTagName("image")];if(v)v("images",0,I.length);for(let d=0;d<I.length;d++){let Y=I[d],X=Y.getAttribute("href")||Y.getAttribute("xlink:href");if(!X||!lt(X))continue;try{let F=D4(X,e),{content:V,contentType:T}=await R4(F,"binary",u),j=I5(V,T.split(";")[0]);if(Y.getAttribute("href"))Y.setAttribute("href",j);if(Y.getAttribute("xlink:href"))Y.setAttribute("xlink:href",j)}catch(F){k(X,F)}if(v)v("images",d+1,I.length)}}if(r){let I=[...t.getElementsByTagName("use")];if(v)v("externalSVGs",0,I.length);let d=t.querySelector("defs");if(!d){let Y=t.documentElement||t;if(!Y){if(S.push("Cannot add defs: document has no root SVG element"),v)v("externalSVGs",I.length,I.length)}else if(d=new T3("defs",{},[]),typeof Y.insertBefore==="function"&&Y.firstChild)Y.insertBefore(d,Y.firstChild);else if(typeof Y.appendChild==="function")Y.appendChild(d);else if(Y.children&&Array.isArray(Y.children))Y.children.unshift(d),d.parentNode=Y}if(d)for(let Y=0;Y<I.length;Y++){let X=I[Y],F=X.getAttribute("href")||X.getAttribute("xlink:href");if(!F||!lt(F))continue;let{path:V,fragment:T}=Mo(F);if(!V)continue;let j=D4(V,e);if(P.has(j)){S.push(`Circular reference detected: ${j}`);continue}P.add(j);try{let{content:A}=await R4(j,"text",u),z=_3(A);if(!z){k(V,Error("Failed to parse SVG"));continue}let i3=z.documentElement||z;if(R(i3),m&&g>0)await q2(z,{...a,basePath:j,maxRecursionDepth:g-1,_visitedURLs:P});B++;let K=`${E}${B}_`;if(l==="extract"&&T){let $=z.getElementById(T);if($){let w=$.clone?$.clone():JSON.parse(JSON.stringify($));h2(w,K),d.children.push(w);let G=K+T;if(X.getAttribute("href"))X.setAttribute("href","#"+G);if(X.getAttribute("xlink:href"))X.setAttribute("xlink:href","#"+G)}else k(F,Error(`Fragment #${T} not found in ${V}`))}else{let $=z.documentElement||z;h2($,K);let w=K+"svg";$.setAttribute("id",w),d.children.push($);let G=T?"#"+K+T:"#"+w;if(X.getAttribute("href"))X.setAttribute("href",G);if(X.getAttribute("xlink:href"))X.setAttribute("xlink:href",G)}}catch(A){k(V,A)}if(v)v("externalSVGs",Y+1,I.length)}}if(o||x){let I=[...t.getElementsByTagName("style")];if(v)v("stylesheets",0,I.length);let d=c?Wo(t):null;for(let Y=0;Y<I.length;Y++){let X=I[Y],F=X.textContent||"";if(o){let{imports:V}=Q0(F);for(let T of V.reverse())try{let j=T.url;if(d&&Ho(j)){let $=Qo(j);if($&&d.has($)){let w=zo(d.get($));if(j=qo(j,w),s)console.log(`Font subsetting: ${$} -> ${d.get($).size} chars`)}}let A=D4(j,e),{content:z}=await R4(A,"text",u),i3=z,K=Q0(z).imports;if(K.length>0)for(let $ of K.reverse())try{let w=D4($.url,A),G=await R4(w,"text",u);i3=i3.substring(0,$.index)+G.content+i3.substring($.index+$.fullMatch.length)}catch(w){k($.url,w)}F=F.substring(0,T.index)+i3+F.substring(T.index+T.fullMatch.length)}catch(j){k(T.url,j)}}if(o||x){let{urls:V}=Q0(F);for(let T of V.reverse()){let j=C0(T.url),A=j.startsWith("font/")||j.includes("fontobject");if(A&&!x)continue;if(!A&&!o)continue;try{let z=D4(T.url,e),{content:i3,contentType:K}=await R4(z,"binary",u),$=`url("${I5(i3,K.split(";")[0])}")`;F=F.substring(0,T.index)+$+F.substring(T.index+T.fullMatch.length)}catch(z){k(T.url,z)}}}if(X.textContent=F,v)v("stylesheets",Y+1,I.length)}}if(p){let I=[...t.getElementsByTagName("script")];if(v)v("scripts",0,I.length);for(let d=0;d<I.length;d++){let Y=I[d],X=Y.getAttribute("src")||Y.getAttribute("href")||Y.getAttribute("xlink:href");if(!X)continue;if(X.startsWith("data:"))continue;try{let F=D4(X,e),{content:V}=await R4(F,"text",u);Y.removeAttribute("src"),Y.removeAttribute("href"),Y.removeAttribute("xlink:href"),te(Y,V,t)}catch(F){k(X,F)}if(v)v("scripts",d+1,I.length)}}if(n){let I=[...t.getElementsByTagName("audio")];if(v)v("audio",0,I.length);for(let d=0;d<I.length;d++){let Y=I[d],X=Y.getAttribute("src");if(X&&!X.startsWith("data:"))try{let V=D4(X,e),{content:T,contentType:j}=await R4(V,"binary",u),A=j.split(";")[0]||"audio/mpeg",z=I5(T,A);Y.setAttribute("src",z)}catch(V){k(X,V)}let F=Y.getElementsByTagName("source");for(let V of F){let T=V.getAttribute("src");if(T&&!T.startsWith("data:"))try{let j=D4(T,e),{content:A,contentType:z}=await R4(j,"binary",u),i3=z.split(";")[0]||V.getAttribute("type")||"audio/mpeg",K=I5(A,i3);V.setAttribute("src",K)}catch(j){k(T,j)}}if(v)v("audio",d+1,I.length)}}if(p){let I=[],d=t.getElementsByTagName("script");for(let V of d)if(V.textContent)I.push(V.textContent);let Y=t.getElementsByTagName("style");for(let V of Y)if(V.textContent)I.push(V.textContent);let X=t.getElementsByTagName("foreignObject");for(let V of X){let T=V.textContent||"";if(T)I.push(T)}let F=new Set;for(let V of I){let T=Go(V);for(let j of T)F.add(j)}if(F.size>0){let V=new Map;if(v)v("resources",0,F.size);let T=0;for(let j of F){try{let A=D4(j,e),{content:z,contentType:i3}=await R4(A,"binary",u),K=i3.split(";")[0]||C0(j),$=I5(z,K);if(V.set(j,$),s){let w=(z.length/1024).toFixed(1);console.log(`Embedded resource: ${j} (${w} KB)`)}}catch(A){k(j,A)}if(T++,v)v("resources",T,F.size)}if(V.size>0){let j=jo(V),A=d[0];if(A){let z=A.textContent||"";if(j.includes("<")||j.includes("&")||z.includes("<")||z.includes("&"))A.setAttribute("data-cdata-pending","true");A.textContent=j+z}else{let z=t.createElement("script");z.setAttribute("type","text/javascript"),z.setAttribute("data-cdata-pending","true"),z.textContent=j;let i3=t.documentElement||t;if(i3.firstChild)i3.insertBefore(z,i3.firstChild);else i3.appendChild(z)}if(s)console.log(`Injected resource interceptor for ${V.size} embedded resources`)}}}let N=t.documentElement||t;if(!N.getAttribute("xmlns"))N.setAttribute("xmlns","http://www.w3.org/2000/svg");if(C4(t).includes("xlink:")&&!N.getAttribute("xmlns:xlink"))N.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[I,d]of f){let Y=`xmlns:${I}`;if(!N.getAttribute(Y))N.setAttribute(Y,d)}if(S.length>0)t._embedWarnings=S;return t}),Ko={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp","image/x-icon":".ico","image/tiff":".tiff","audio/mpeg":".mp3","audio/wav":".wav","audio/ogg":".ogg","audio/webm":".webm","audio/aac":".aac","audio/flac":".flac","video/mp4":".mp4","video/webm":".webm","video/ogg":".ogv","video/quicktime":".mov","application/javascript":".js","text/javascript":".js","text/css":".css","font/woff":".woff","font/woff2":".woff2","font/ttf":".ttf","font/otf":".otf","application/font-woff":".woff","application/font-woff2":".woff2","application/x-font-ttf":".ttf","application/x-font-opentype":".otf"};function e5(t){if(!t||!t.startsWith("data:"))return null;let a=t.match(/^data:([^;,]+)?(?:;([^,]+))?,(.*)$/);if(!a)return null;let e=a[1]||"application/octet-stream",i=a[2]||"",r=a[3]||"";return{mimeType:e,encoding:i,data:r}}function i5(t){if(t.encoding==="base64")return Buffer.from(t.data,"base64");try{return decodeURIComponent(t.data)}catch(a){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${a.message}`);return t.data}}function F4(t,a,e,i=null){let r=Ko[a]||".bin";if(i){let o=i.replace(/[^a-zA-Z0-9._-]/g,"_");return`${t}_${o}`}let l="resource";if(a.startsWith("image/"))l="image";else if(a.startsWith("audio/"))l="audio";else if(a.startsWith("video/"))l="video";else if(a.startsWith("font/")||a.includes("font"))l="font";else if(a.includes("javascript"))l="script";else if(a.includes("css"))l="style";return`${t}_${l}_${String(e).padStart(3,"0")}${r}`}async function ae(t,a={}){let e=A5(t),i=await F5(t,e),r=a.outputFormat||(e===Y3.DOM_ELEMENT?h4.DOM_ELEMENT:h4.SVG_STRING),{outputDir:l=null,filenamePrefix:o="resource",extractImages:x=!0,extractFonts:p=!0,extractScripts:n=!0,extractStyles:c=!0,extractAudio:s=!0,extractVideo:m=!0,elementIds:g=null,restoreGoogleFonts:u=!0,dryRun:y=!1,extractOnly:v=!1,onProgress:E=null}=a,C=[],P=[],S=0,f=g?new Set(Array.isArray(g)?g:[g]):null,B=(k)=>{if(!f)return!0;let N=k;while(N&&N.getAttribute){let I=N.getAttribute("id");if(I&&f.has(I))return!0;N=N.parentNode}return!1},R=async(k,N,I)=>{let d=0;if(typeof Buffer<"u"&&Buffer.isBuffer(N))d=N.length;else if(typeof Buffer<"u")d=Buffer.byteLength(N,"utf8");else if(typeof Blob<"u")d=new Blob([N]).size;else d=N.length||0;let Y={filename:k,path:l?`${l}/${k}`:k,mimeType:I,size:d};if(!y&&l)try{let X=await import("node:fs/promises"),F=await Promise.resolve().then(()=>(v5(),x5));await X.mkdir(l,{recursive:!0});let V=F.join(l,k);if(typeof Buffer<"u"&&Buffer.isBuffer(N))await X.writeFile(V,N);else await X.writeFile(V,N,"utf8");Y.path=V,C.push(Y)}catch(X){P.push(`Failed to save ${k}: ${X.message}`),Y.error=X.message}else C.push(Y);return Y};if(x){let k=[...i.getElementsByTagName("image")];if(E)E("images",0,k.length);for(let N=0;N<k.length;N++){let I=k[N];if(!B(I))continue;let d=I.getAttribute("href")||I.getAttribute("xlink:href");if(!d||!d.startsWith("data:"))continue;let Y=e5(d);if(!Y)continue;if(!Y.mimeType.startsWith("image/"))continue;S++;let X=F4(o,Y.mimeType,S),F=i5(Y),V=await R(X,F,Y.mimeType);if(V.type="image",V.elementId=I.getAttribute("id"),!v){let T=`./${X}`;if(I.getAttribute("href"))I.setAttribute("href",T);if(I.getAttribute("xlink:href"))I.setAttribute("xlink:href",T)}if(E)E("images",N+1,k.length)}}if(s){let k=[...i.getElementsByTagName("audio")];if(E)E("audio",0,k.length);for(let N=0;N<k.length;N++){let I=k[N];if(!B(I))continue;let d=I.getAttribute("src");if(d&&d.startsWith("data:")){let X=e5(d);if(X&&X.mimeType.startsWith("audio/")){S++;let F=F4(o,X.mimeType,S),V=i5(X),T=await R(F,V,X.mimeType);if(T.type="audio",T.elementId=I.getAttribute("id"),!v)I.setAttribute("src",`./${F}`)}}let Y=I.getElementsByTagName("source");for(let X of Y){let F=X.getAttribute("src");if(F&&F.startsWith("data:")){let V=e5(F);if(V&&V.mimeType.startsWith("audio/")){S++;let T=F4(o,V.mimeType,S),j=i5(V),A=await R(T,j,V.mimeType);if(A.type="audio",!v)X.setAttribute("src",`./${T}`)}}}if(E)E("audio",N+1,k.length)}}if(m){let k=[...i.getElementsByTagName("video")];if(E)E("video",0,k.length);for(let N=0;N<k.length;N++){let I=k[N];if(!B(I))continue;let d=I.getAttribute("src");if(d&&d.startsWith("data:")){let X=e5(d);if(X&&X.mimeType.startsWith("video/")){S++;let F=F4(o,X.mimeType,S),V=i5(X),T=await R(F,V,X.mimeType);if(T.type="video",T.elementId=I.getAttribute("id"),!v)I.setAttribute("src",`./${F}`)}}let Y=I.getElementsByTagName("source");for(let X of Y){let F=X.getAttribute("src");if(F&&F.startsWith("data:")){let V=e5(F);if(V&&V.mimeType.startsWith("video/")){S++;let T=F4(o,V.mimeType,S),j=i5(V),A=await R(T,j,V.mimeType);if(A.type="video",!v)X.setAttribute("src",`./${T}`)}}}if(E)E("video",N+1,k.length)}}if(n){let k=[...i.getElementsByTagName("script")];if(E)E("scripts",0,k.length);for(let N=0;N<k.length;N++){let I=k[N];if(!B(I))continue;let d=I.getAttribute("href")||I.getAttribute("xlink:href");if(d&&!d.startsWith("data:"))continue;let Y="";if(d&&d.startsWith("data:")){let V=e5(d);if(V){let T=i5(V);Y=typeof T==="string"?T:T.toString("utf8")}}else if(Y=I.textContent||"",I.firstChild&&I.firstChild.nodeType===4)Y=I.firstChild.nodeValue||"";if(!Y.trim())continue;S++;let X=F4(o,"application/javascript",S),F=await R(X,Y,"application/javascript");if(F.type="script",F.elementId=I.getAttribute("id"),!v){let V=0;while(I.firstChild&&V++<1e4){let T=I.firstChild;if(I.removeChild(T),I.firstChild===T)break}if(V>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");I.setAttribute("href",`./${X}`)}if(E)E("scripts",N+1,k.length)}}if(c||p){let k=[...i.getElementsByTagName("style")];if(E)E("styles",0,k.length);for(let N=0;N<k.length;N++){let I=k[N];if(!B(I))continue;let d=I.textContent||"";if(I.firstChild&&I.firstChild.nodeType===4)d=I.firstChild.nodeValue||"";if(!d.trim())continue;let Y=!1;if(p){let X=/@font-face\s*\{[^}]*\}/gi,F=d.match(X)||[];for(let V of F){let T=V.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(T){let j=T[1],A=e5(j);if(A){S++;let z=F4(o,A.mimeType,S),i3=i5(A),K=await R(z,i3,A.mimeType);K.type="font";let $=V.match(/font-family:\s*["']?([^"';]+)["']?/);if($)K.fontFamily=$[1].trim();if(!v)d=d.replace(j,`./${z}`),Y=!0}}}if(u){let V=[],T=/font-family:\s*["']?([^"';,]+)/gi,j;while((j=T.exec(d))!==null){let A=j[1].trim();if(["Roboto","Open Sans","Lato","Montserrat","Oswald","Raleway","Poppins","Source Sans Pro","Ubuntu","Playfair Display","Merriweather","Nunito","PT Sans","Rubik","Work Sans","DM Serif Display","Monofett","Dokdo","Orbitron","Notable","Fira Mono","Fira Code","Inter","Noto Sans","Noto Serif"].some((z)=>A.toLowerCase().includes(z.toLowerCase())))V.push(A)}if(V.length>0&&!v){let A=[...new Set(V)],z=`@import url('https://fonts.googleapis.com/css2?family=${A.map((i3)=>i3.replace(/\s+/g,"+")).join("&family=")}&display=swap');
|
|
573
|
-
`;if(!
|
|
574
|
-
`)}function
|
|
492
|
+
`}function Qz($){let J=new Map,Z=(Q,q)=>{if(!Q||!q)return;let H=Q.replace(/['"]/g,"").trim().split(",")[0].trim();if(!J.has(H))J.set(H,new Set);let W=J.get(H);for(let z of q)W.add(z)},K=(Q)=>{if(!Q)return;let H=(Q.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),W=H?H[1]:null,z=Q.getAttribute?.("font-family"),j=Q.getAttribute?.("face"),G=W||z||j,F="";if(Q.childNodes){for(let _ of Q.childNodes)if(_.nodeType===3)F+=_.nodeValue||""}if(G&&F.trim())Z(G,F);if(Q.tagName==="text"||Q.tagName==="tspan"){let _=G;if(!_&&Q.parentNode){let M=(Q.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);_=M?M[1]:Q.parentNode.getAttribute?.("font-family")}if(_&&F.trim())Z(_,F)}if(Q.children)for(let _ of Q.children)K(_)};return K($),J}function qz($){let J=[...$].sort().join("");return encodeURIComponent(J)}function Hz($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function Wz($){try{let Z=new URL($).searchParams.get("family");if(Z)return Z.split(":")[0].replace(/\+/g," ")}catch(J){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${J.message}`);let Z=$.match(/family=([^&:]+)/);if(Z)return Z[1].replace(/\+/g," ")}return null}function zz($,J){if(!J)return $;try{let Z=new URL($);return Z.searchParams.set("text",decodeURIComponent(J)),Z.toString()}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);let K=$.includes("?")?"&":"?";return`${$}${K}text=${J}`}}var PJ=F0(async($,J={})=>{let{basePath:Z="",embedImages:K=!0,embedExternalSVGs:Q=!0,externalSVGMode:q="extract",embedCSS:H=!0,embedFonts:W=!0,embedScripts:z=!0,embedAudio:j=!1,subsetFonts:G=!0,verbose:F=!1,recursive:_=!0,maxRecursionDepth:U=10,timeout:M=30000,onMissingResource:V="warn",onProgress:Y=null,idPrefix:X="ext_",_visitedURLs:k=null}=J,w=k||new Set,R=[],I=new Map,P=0,u=(v)=>{if(!v||!v.attributes)return;let E=["http://www.inkscape.org/namespaces/inkscape","http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","http://ns.adobe.com/AdobeIllustrator/","http://ns.adobe.com/AdobeSVGViewerExtensions/","http://www.bohemiancoding.com/sketch/ns","http://www.figma.com/figma/ns","http://www.serif.com/","http://www.vecta.io/nano"],m=["http://www.w3.org/2000/svg","http://www.w3.org/1999/xlink","http://www.w3.org/XML/1998/namespace","http://www.w3.org/2000/xmlns/"],c=v.attributes;for(let d=0;d<c.length;d++){let N=c[d];if(N.name.startsWith("xmlns:")){let y=N.name.substring(6),B=N.value;if(E.some((t)=>B.startsWith(t))||!m.includes(B))I.set(y,B)}}},g=(v,E)=>{let m=`Failed to fetch resource: ${v} - ${E.message}`;if(V==="fail")throw new Error(m);else if(V==="warn")R.push(m),console.warn("embedExternalDependencies:",m);return null};if(K){let E=[...$.getElementsByTagName("image")];if(Y)Y("images",0,E.length);for(let m=0;m<E.length;m++){let c=E[m],d=c.getAttribute("href")||c.getAttribute("xlink:href");if(!d||!QZ(d))continue;try{let N=l7(d,Z),{content:y,contentType:B}=await s7(N,"binary",M),t=q6(y,B.split(";")[0]);if(c.getAttribute("href"))c.setAttribute("href",t);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href",t)}catch(N){g(d,N)}if(Y)Y("images",m+1,E.length)}}if(Q){let E=[...$.getElementsByTagName("use")];if(Y)Y("externalSVGs",0,E.length);let m=$.querySelector("defs");if(!m){let c=$.documentElement||$;if(!c){if(R.push("Cannot add defs: document has no root SVG element"),Y)Y("externalSVGs",E.length,E.length)}else if(m=new w0("defs",{},[]),typeof c.insertBefore==="function"&&c.firstChild)c.insertBefore(m,c.firstChild);else if(typeof c.appendChild==="function")c.appendChild(m);else if(c.children&&Array.isArray(c.children))c.children.unshift(m),m.parentNode=c}if(m)for(let c=0;c<E.length;c++){let d=E[c],N=d.getAttribute("href")||d.getAttribute("xlink:href");if(!N||!QZ(N))continue;let{path:y,fragment:B}=eW(N);if(!y)continue;let t=l7(y,Z);if(w.has(t)){R.push(`Circular reference detected: ${t}`);continue}w.add(t);try{let{content:i}=await s7(t,"text",M),l=u0(i);if(!l){g(y,new Error("Failed to parse SVG"));continue}let q0=l.documentElement||l;if(u(q0),_&&U>0)await PJ(l,{...J,basePath:t,maxRecursionDepth:U-1,_visitedURLs:w});P++;let f=`${X}${P}_`;if(q==="extract"&&B){let A=l.getElementById(B);if(A){let e=A.clone?A.clone():JSON.parse(JSON.stringify(A));MJ(e,f),m.children.push(e);let $0=f+B;if(d.getAttribute("href"))d.setAttribute("href","#"+$0);if(d.getAttribute("xlink:href"))d.setAttribute("xlink:href","#"+$0)}else g(N,new Error(`Fragment #${B} not found in ${y}`))}else{let A=l.documentElement||l;MJ(A,f);let e=f+"svg";A.setAttribute("id",e),m.children.push(A);let $0=B?"#"+f+B:"#"+e;if(d.getAttribute("href"))d.setAttribute("href",$0);if(d.getAttribute("xlink:href"))d.setAttribute("xlink:href",$0)}}catch(i){g(y,i)}if(Y)Y("externalSVGs",c+1,E.length)}}if(H||W){let E=[...$.getElementsByTagName("style")];if(Y)Y("stylesheets",0,E.length);let m=G?Qz($):null;for(let c=0;c<E.length;c++){let d=E[c],N=d.textContent||"";if(H){let{imports:y}=VJ(N);for(let B of y.reverse())try{let t=B.url;if(m&&Hz(t)){let A=Wz(t);if(A&&m.has(A)){let e=qz(m.get(A));if(t=zz(t,e),F)console.log(`Font subsetting: ${A} -> ${m.get(A).size} chars`)}}let i=l7(t,Z),{content:l}=await s7(i,"text",M),q0=l,f=VJ(l).imports;if(f.length>0)for(let A of f.reverse())try{let e=l7(A.url,i),$0=await s7(e,"text",M);q0=q0.substring(0,A.index)+$0.content+q0.substring(A.index+A.fullMatch.length)}catch(e){g(A.url,e)}N=N.substring(0,B.index)+q0+N.substring(B.index+B.fullMatch.length)}catch(t){g(B.url,t)}}if(H||W){let{urls:y}=VJ(N);for(let B of y.reverse()){let t=r6(B.url),i=t.startsWith("font/")||t.includes("fontobject");if(i&&!W)continue;if(!i&&!H)continue;try{let l=l7(B.url,Z),{content:q0,contentType:f}=await s7(l,"binary",M),e=`url("${q6(q0,f.split(";")[0])}")`;N=N.substring(0,B.index)+e+N.substring(B.index+B.fullMatch.length)}catch(l){g(B.url,l)}}}if(d.textContent=N,Y)Y("stylesheets",c+1,E.length)}}if(z){let E=[...$.getElementsByTagName("script")];if(Y)Y("scripts",0,E.length);for(let m=0;m<E.length;m++){let c=E[m],d=c.getAttribute("src")||c.getAttribute("href")||c.getAttribute("xlink:href");if(!d)continue;if(d.startsWith("data:"))continue;try{let N=l7(d,Z),{content:y}=await s7(N,"text",M);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),YK(c,y,$)}catch(N){g(d,N)}if(Y)Y("scripts",m+1,E.length)}}if(j){let E=[...$.getElementsByTagName("audio")];if(Y)Y("audio",0,E.length);for(let m=0;m<E.length;m++){let c=E[m],d=c.getAttribute("src");if(d&&!d.startsWith("data:"))try{let y=l7(d,Z),{content:B,contentType:t}=await s7(y,"binary",M),i=t.split(";")[0]||"audio/mpeg",l=q6(B,i);c.setAttribute("src",l)}catch(y){g(d,y)}let N=c.getElementsByTagName("source");for(let y of N){let B=y.getAttribute("src");if(B&&!B.startsWith("data:"))try{let t=l7(B,Z),{content:i,contentType:l}=await s7(t,"binary",M),q0=l.split(";")[0]||y.getAttribute("type")||"audio/mpeg",f=q6(i,q0);y.setAttribute("src",f)}catch(t){g(B,t)}}if(Y)Y("audio",m+1,E.length)}}if(z){let v=[],E=$.getElementsByTagName("script");for(let N of E)if(N.textContent)v.push(N.textContent);let m=$.getElementsByTagName("style");for(let N of m)if(N.textContent)v.push(N.textContent);let c=$.getElementsByTagName("foreignObject");for(let N of c){let y=N.textContent||"";if(y)v.push(y)}let d=new Set;for(let N of v){let y=Zz(N);for(let B of y)d.add(B)}if(d.size>0){let N=new Map;if(Y)Y("resources",0,d.size);let y=0;for(let B of d){try{let t=l7(B,Z),{content:i,contentType:l}=await s7(t,"binary",M),q0=l.split(";")[0]||r6(B),f=q6(i,q0);if(N.set(B,f),F){let A=(i.length/1024).toFixed(1);console.log(`Embedded resource: ${B} (${A} KB)`)}}catch(t){g(B,t)}if(y++,Y)Y("resources",y,d.size)}if(N.size>0){let B=Kz(N),t=E[0];if(t){let i=t.textContent||"";if(B.includes("<")||B.includes("&")||i.includes("<")||i.includes("&"))t.setAttribute("data-cdata-pending","true");t.textContent=B+i}else{let i=$.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("data-cdata-pending","true"),i.textContent=B;let l=$.documentElement||$;if(l.firstChild)l.insertBefore(i,l.firstChild);else l.appendChild(i)}if(F)console.log(`Injected resource interceptor for ${N.size} embedded resources`)}}}let b=$.documentElement||$;if(!b.getAttribute("xmlns"))b.setAttribute("xmlns","http://www.w3.org/2000/svg");if(K7($).includes("xlink:")&&!b.getAttribute("xmlns:xlink"))b.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[v,E]of I){let m=`xmlns:${v}`;if(!b.getAttribute(m))b.setAttribute(m,E)}if(R.length>0)$._embedWarnings=R;return $}),jz={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp","image/x-icon":".ico","image/tiff":".tiff","audio/mpeg":".mp3","audio/wav":".wav","audio/ogg":".ogg","audio/webm":".webm","audio/aac":".aac","audio/flac":".flac","video/mp4":".mp4","video/webm":".webm","video/ogg":".ogv","video/quicktime":".mov","application/javascript":".js","text/javascript":".js","text/css":".css","font/woff":".woff","font/woff2":".woff2","font/ttf":".ttf","font/otf":".otf","application/font-woff":".woff","application/font-woff2":".woff2","application/x-font-ttf":".ttf","application/x-font-opentype":".otf"};function Y$($){if(!$||!$.startsWith("data:"))return null;let J=$.match(/^data:([^;,]+)?(?:;([^,]+))?,(.*)$/);if(!J)return null;let Z=J[1]||"application/octet-stream",K=J[2]||"",Q=J[3]||"";return{mimeType:Z,encoding:K,data:Q}}function M$($){if($.encoding==="base64")return Buffer.from($.data,"base64");try{return decodeURIComponent($.data)}catch(J){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${J.message}`);return $.data}}function W$($,J,Z,K=null){let Q=jz[J]||".bin";if(K){let H=K.replace(/[^a-zA-Z0-9._-]/g,"_");return`${$}_${H}`}let q="resource";if(J.startsWith("image/"))q="image";else if(J.startsWith("audio/"))q="audio";else if(J.startsWith("video/"))q="video";else if(J.startsWith("font/")||J.includes("font"))q="font";else if(J.includes("javascript"))q="script";else if(J.includes("css"))q="style";return`${$}_${q}_${String(Z).padStart(3,"0")}${Q}`}async function MK($,J={}){let Z=w$($),K=await W6($,Z),Q=J.outputFormat||(Z===D0.DOM_ELEMENT?M7.DOM_ELEMENT:M7.SVG_STRING),{outputDir:q=null,filenamePrefix:H="resource",extractImages:W=!0,extractFonts:z=!0,extractScripts:j=!0,extractStyles:G=!0,extractAudio:F=!0,extractVideo:_=!0,elementIds:U=null,restoreGoogleFonts:M=!0,dryRun:V=!1,extractOnly:Y=!1,onProgress:X=null}=J,k=[],w=[],R=0,I=U?new Set(Array.isArray(U)?U:[U]):null,P=(b)=>{if(!I)return!0;let h=b;while(h&&h.getAttribute){let v=h.getAttribute("id");if(v&&I.has(v))return!0;h=h.parentNode}return!1},u=async(b,h,v)=>{let E=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(h))E=h.length;else if(typeof Buffer!=="undefined")E=Buffer.byteLength(h,"utf8");else if(typeof Blob!=="undefined")E=new Blob([h]).size;else E=h.length||0;let m={filename:b,path:q?`${q}/${b}`:b,mimeType:v,size:E};if(!V&&q)try{let c=await import("node:fs/promises"),d=await Promise.resolve().then(() => (O$(),V$));await c.mkdir(q,{recursive:!0});let N=d.join(q,b);if(typeof Buffer!=="undefined"&&Buffer.isBuffer(h))await c.writeFile(N,h);else await c.writeFile(N,h,"utf8");m.path=N,k.push(m)}catch(c){w.push(`Failed to save ${b}: ${c.message}`),m.error=c.message}else k.push(m);return m};if(W){let h=[...K.getElementsByTagName("image")];if(X)X("images",0,h.length);for(let v=0;v<h.length;v++){let E=h[v];if(!P(E))continue;let m=E.getAttribute("href")||E.getAttribute("xlink:href");if(!m||!m.startsWith("data:"))continue;let c=Y$(m);if(!c)continue;if(!c.mimeType.startsWith("image/"))continue;R++;let d=W$(H,c.mimeType,R),N=M$(c),y=await u(d,N,c.mimeType);if(y.type="image",y.elementId=E.getAttribute("id"),!Y){let B=`./${d}`;if(E.getAttribute("href"))E.setAttribute("href",B);if(E.getAttribute("xlink:href"))E.setAttribute("xlink:href",B)}if(X)X("images",v+1,h.length)}}if(F){let h=[...K.getElementsByTagName("audio")];if(X)X("audio",0,h.length);for(let v=0;v<h.length;v++){let E=h[v];if(!P(E))continue;let m=E.getAttribute("src");if(m&&m.startsWith("data:")){let d=Y$(m);if(d&&d.mimeType.startsWith("audio/")){R++;let N=W$(H,d.mimeType,R),y=M$(d),B=await u(N,y,d.mimeType);if(B.type="audio",B.elementId=E.getAttribute("id"),!Y)E.setAttribute("src",`./${N}`)}}let c=E.getElementsByTagName("source");for(let d of c){let N=d.getAttribute("src");if(N&&N.startsWith("data:")){let y=Y$(N);if(y&&y.mimeType.startsWith("audio/")){R++;let B=W$(H,y.mimeType,R),t=M$(y),i=await u(B,t,y.mimeType);if(i.type="audio",!Y)d.setAttribute("src",`./${B}`)}}}if(X)X("audio",v+1,h.length)}}if(_){let h=[...K.getElementsByTagName("video")];if(X)X("video",0,h.length);for(let v=0;v<h.length;v++){let E=h[v];if(!P(E))continue;let m=E.getAttribute("src");if(m&&m.startsWith("data:")){let d=Y$(m);if(d&&d.mimeType.startsWith("video/")){R++;let N=W$(H,d.mimeType,R),y=M$(d),B=await u(N,y,d.mimeType);if(B.type="video",B.elementId=E.getAttribute("id"),!Y)E.setAttribute("src",`./${N}`)}}let c=E.getElementsByTagName("source");for(let d of c){let N=d.getAttribute("src");if(N&&N.startsWith("data:")){let y=Y$(N);if(y&&y.mimeType.startsWith("video/")){R++;let B=W$(H,y.mimeType,R),t=M$(y),i=await u(B,t,y.mimeType);if(i.type="video",!Y)d.setAttribute("src",`./${B}`)}}}if(X)X("video",v+1,h.length)}}if(j){let h=[...K.getElementsByTagName("script")];if(X)X("scripts",0,h.length);for(let v=0;v<h.length;v++){let E=h[v];if(!P(E))continue;let m=E.getAttribute("href")||E.getAttribute("xlink:href");if(m&&!m.startsWith("data:"))continue;let c="";if(m&&m.startsWith("data:")){let y=Y$(m);if(y){let B=M$(y);c=typeof B==="string"?B:B.toString("utf8")}}else if(c=E.textContent||"",E.firstChild&&E.firstChild.nodeType===4)c=E.firstChild.nodeValue||"";if(!c.trim())continue;R++;let d=W$(H,"application/javascript",R),N=await u(d,c,"application/javascript");if(N.type="script",N.elementId=E.getAttribute("id"),!Y){let y=0;while(E.firstChild&&y++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(y>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");E.setAttribute("href",`./${d}`)}if(X)X("scripts",v+1,h.length)}}if(G||z){let h=[...K.getElementsByTagName("style")];if(X)X("styles",0,h.length);for(let v=0;v<h.length;v++){let E=h[v];if(!P(E))continue;let m=E.textContent||"";if(E.firstChild&&E.firstChild.nodeType===4)m=E.firstChild.nodeValue||"";if(!m.trim())continue;let c=!1;if(z){let d=/@font-face\s*\{[^}]*\}/gi,N=m.match(d)||[];for(let y of N){let B=y.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(B){let t=B[1],i=Y$(t);if(i){R++;let l=W$(H,i.mimeType,R),q0=M$(i),f=await u(l,q0,i.mimeType);f.type="font";let A=y.match(/font-family:\s*["']?([^"';]+)["']?/);if(A)f.fontFamily=A[1].trim();if(!Y)m=m.replace(t,`./${l}`),c=!0}}}if(M){let y=[],B=/font-family:\s*["']?([^"';,]+)/gi,t;while((t=B.exec(m))!==null){let i=t[1].trim();if(["Roboto","Open Sans","Lato","Montserrat","Oswald","Raleway","Poppins","Source Sans Pro","Ubuntu","Playfair Display","Merriweather","Nunito","PT Sans","Rubik","Work Sans","DM Serif Display","Monofett","Dokdo","Orbitron","Notable","Fira Mono","Fira Code","Inter","Noto Sans","Noto Serif"].some((q0)=>i.toLowerCase().includes(q0.toLowerCase())))y.push(i)}if(y.length>0&&!Y){let i=[...new Set(y)],l=`@import url('https://fonts.googleapis.com/css2?family=${i.map((q0)=>q0.replace(/\s+/g,"+")).join("&family=")}&display=swap');
|
|
493
|
+
`;if(!m.includes("fonts.googleapis.com"))m=l+m,c=!0,w.push(`Restored Google Fonts import for: ${i.join(", ")}`)}}}if(G&&m.trim()){R++;let d=W$(H,"text/css",R),N=await u(d,m,"text/css");if(N.type="stylesheet",N.elementId=E.getAttribute("id"),!Y){let y=0;while(E.firstChild&&y++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(y>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");E.textContent=`@import url('./${d}');`,c=!0}}else if(c&&!Y){let d=0;while(E.firstChild&&d++<1e4){let N=E.firstChild;if(E.removeChild(N),E.firstChild===N)break}if(d>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");YK(E,m,K)}if(X)X("styles",v+1,h.length)}}if(!Y){if(K._exportedResources=k,w.length>0)K._exportWarnings=w}return{doc:Y?null:z6(K,Q,J),extractedFiles:k,warnings:w,summary:{totalExtracted:k.length,images:k.filter((b)=>b.type==="image").length,audio:k.filter((b)=>b.type==="audio").length,video:k.filter((b)=>b.type==="video").length,scripts:k.filter((b)=>b.type==="script").length,fonts:k.filter((b)=>b.type==="font").length,stylesheets:k.filter((b)=>b.type==="stylesheet").length,totalSize:k.reduce((b,h)=>b+h.size,0)}}}var Gz={MAX_PRECISION:H6,DEFAULT_PRECISION:o6,PRECISION_LEVELS:qZ,formatPrecision:HZ,InputType:D0,OutputFormat:M7,OutputTarget:Y7,detectInputType:w$,detectOutputTarget:kJ,loadInput:W6,generateOutput:z6,saveOutput:WZ,createOperation:F0,cleanupIds:wJ,cleanupNumericValues:a6,cleanupListOfValues:zZ,cleanupAttributes:jZ,cleanupEnableBackground:GZ,removeUnknownsAndDefaults:FZ,removeNonInheritableGroupAttrs:_Z,removeUselessDefs:UZ,removeHiddenElements:t6,removeEmptyText:VZ,removeEmptyContainers:e6,removeDoctype:OZ,removeXMLProcInst:YZ,removeComments:$9,removeMetadata:J9,removeTitle:MZ,removeDesc:XZ,removeEditorsNSData:LJ,removeEmptyAttrs:kZ,removeViewBox:wZ,removeXMLNS:LZ,removeRasterImages:RZ,removeScriptElement:BZ,convertShapesToPath:NZ,convertPathData:IZ,convertTransform:CZ,convertColors:Z9,convertStyleToAttrs:RJ,convertEllipseToCircle:PZ,collapseGroups:AZ,mergePaths:EZ,moveGroupAttrsToElems:TZ,moveElemsAttrsToGroup:bZ,minifyStyles:BJ,inlineStyles:fZ,sortAttrs:SZ,sortDefsChildren:vZ,reusePaths:DZ,removeOffCanvasPath:hZ,removeStyleElement:yZ,removeXlink:uZ,addAttributesToSVGElement:gZ,addClassesToSVGElement:xZ,prefixIds:mZ,removeDimensions:dZ,removeAttributesBySelector:pZ,removeAttrs:cZ,removeElementsByAttr:nZ,presetDefault:NJ,presetNone:IJ,applyPreset:lZ,optimize:sZ,createConfig:oZ,flattenClipPaths:iZ,flattenMasks:rZ,flattenGradients:aZ,flattenPatterns:eZ,flattenFilters:$K,flattenUseElements:JK,imageToPath:ZK,detectCollisions:KK,measureDistance:QK,validateXML:qK,validateSVG:HK,fixInvalidSVG:zK,ValidationSeverity:A0,flattenAll:GK,simplifyPath:FK,decomposeTransform:OK,optimizeAnimationTiming:_K,optimizePaths:UK,simplifyPaths:VK,embedExternalDependencies:PJ,exportEmbeddedResources:MK,convertPathDataAdvanced:l9,parsePathCommands:s0,serializePathCommands:o0,formatPathNumber:u7,douglasPeucker:K6,visvalingamWhyatt:s9,simplifyPolyline:o9,simplifyPolylinePath:r9,isPurePolyline:i9,optimizeKeySplines:m9,optimizeKeyTimes:d9,optimizeAnimationValues:d6,formatSplineValue:Z6,parseKeySplines:p6,serializeKeySplines:g9,isLinearSpline:c6,areAllSplinesLinear:m5,identifyStandardEasing:x9,STANDARD_EASINGS:u9,removeLeadingZero:t9,negativeExtraSpace:e9,convertToRelative:$J,convertToAbsolute:JJ,lineShorthands:ZJ,convertToZ:KJ,straightCurves:QJ,collapseRepeated:qJ,floatPrecision:HJ,removeUselessCommands:WJ,convertCubicToQuadratic:zJ,convertQuadraticToSmooth:jJ,convertCubicToSmooth:GJ,arcShorthands:FJ};var mJ={};x7(mJ,{setPolyfillMinification:()=>uJ,setPolyfillContent:()=>gJ,removePolyfills:()=>Pz,needsPolyfills:()=>Nz,injectPolyfills:()=>xJ,generatePolyfillScript:()=>AK,detectSVG2Features:()=>j6,SVG2_FEATURES:()=>Bz});var Lz=typeof process!=="undefined"&&process.versions&&process.versions.node,Rz=typeof window!=="undefined",SJ="",vJ="",DJ="",hJ="";if(Lz)try{let $=await import("fs"),J=await Promise.resolve().then(() => (PK(),CK)),Z=await Promise.resolve().then(() => (O$(),V$)),K=J.fileURLToPath(import.meta.url),Q=Z.dirname(K);SJ=$.readFileSync(Z.join(Q,"vendor","inkscape-mesh-polyfill.min.js"),"utf-8"),vJ=$.readFileSync(Z.join(Q,"vendor","inkscape-mesh-polyfill.js"),"utf-8"),DJ=$.readFileSync(Z.join(Q,"vendor","inkscape-hatch-polyfill.min.js"),"utf-8"),hJ=$.readFileSync(Z.join(Q,"vendor","inkscape-hatch-polyfill.js"),"utf-8")}catch($){throw new Error(`Failed to load SVG2 polyfill files from vendor/ directory: ${$.message}. Ensure all vendor files are present.`)}else if(Rz)console.warn("SVG2 polyfills: Running in browser mode. Use setPolyfillContent() to provide polyfill scripts.");var yJ=!0;function uJ($){if(typeof $!=="boolean")throw new Error("setPolyfillMinification: minify parameter must be a boolean");yJ=$}function gJ($){if(!$||typeof $!=="object")throw new Error("setPolyfillContent: polyfills parameter must be an object");if($.meshMin!==void 0){if(typeof $.meshMin!=="string")throw new Error("setPolyfillContent: meshMin must be a string");SJ=$.meshMin}if($.meshFull!==void 0){if(typeof $.meshFull!=="string")throw new Error("setPolyfillContent: meshFull must be a string");vJ=$.meshFull}if($.hatchMin!==void 0){if(typeof $.hatchMin!=="string")throw new Error("setPolyfillContent: hatchMin must be a string");DJ=$.hatchMin}if($.hatchFull!==void 0){if(typeof $.hatchFull!=="string")throw new Error("setPolyfillContent: hatchFull must be a string");hJ=$.hatchFull}}var Bz={MESH_GRADIENT:"meshGradient",HATCH:"hatch",CONTEXT_PAINT:"context-paint",AUTO_START_REVERSE:"auto-start-reverse"};function j6($){if(!$||typeof $!=="object")return{meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1};let J={meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1},Z=(K)=>{if(!K)return;let Q=K.tagName?.toLowerCase();if(Q==="meshgradient"){let j=K.getAttribute("id");if(j&&typeof j==="string"&&j.trim()&&!J.meshGradients.includes(j))J.meshGradients.push(j)}if(Q==="hatch"){let j=K.getAttribute("id");if(j&&typeof j==="string"&&j.trim()&&!J.hatches.includes(j))J.hatches.push(j)}let q=K.getAttribute("fill"),H=K.getAttribute("stroke"),W=K.getAttribute("style");if(q==="context-fill"||q==="context-stroke"||H==="context-fill"||H==="context-stroke"||W&&(W.includes("context-fill")||W.includes("context-stroke")))J.contextPaint=!0;if(Q==="style"&&K.textContent){if(K.textContent.includes("context-fill")||K.textContent.includes("context-stroke"))J.contextPaint=!0}if(K.getAttribute("orient")==="auto-start-reverse")J.autoStartReverse=!0;if(K.children&&Array.isArray(K.children))for(let j of K.children)Z(j)};return Z($),J}function Nz($){if(!$)return!1;let J=j6($);return J.meshGradients.length>0||J.hatches.length>0||J.contextPaint||J.autoStartReverse}function Iz(){let $=yJ?SJ:vJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape mesh polyfill not available. Ensure vendor/inkscape-mesh-polyfill files are present.");return $}function Cz(){let $=yJ?DJ:hJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape hatch polyfill not available. Ensure vendor/inkscape-hatch-polyfill files are present.");return $}function AK($){if(!$||typeof $!=="object")throw new Error("generatePolyfillScript: features parameter must be an object");if(!Array.isArray($.meshGradients))throw new Error("generatePolyfillScript: features.meshGradients must be an array");if(!Array.isArray($.hatches))throw new Error("generatePolyfillScript: features.hatches must be an array");if(!$.meshGradients.every((Z)=>typeof Z==="string"))throw new Error("generatePolyfillScript: features.meshGradients must contain only strings");if(!$.hatches.every((Z)=>typeof Z==="string"))throw new Error("generatePolyfillScript: features.hatches must contain only strings");if(typeof $.contextPaint!=="boolean")throw new Error("generatePolyfillScript: features.contextPaint must be a boolean");if(typeof $.autoStartReverse!=="boolean")throw new Error("generatePolyfillScript: features.autoStartReverse must be a boolean");let J=[];if(J.push("/* SVG 2.0 Polyfills - Generated by svg-matrix */"),$.meshGradients.length>0)J.push(Iz());if($.hatches.length>0)J.push(Cz());if(J.length===1)return null;return J.join(`
|
|
494
|
+
`)}function xJ($,J={}){if(!$)return $;let Z=J.features||j6($);if(!J.force&&Z.meshGradients.length===0&&Z.hatches.length===0)return $;let K=AK(Z);if(!K)return $;let Q=$.documentElement||$,q=`
|
|
575
495
|
// <![CDATA[
|
|
576
|
-
${
|
|
496
|
+
${K}
|
|
577
497
|
// ]]>
|
|
578
|
-
`,
|
|
498
|
+
`,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(Q.children))Q.children=[];if(Q.children.length>0){let W=0;for(let z=0;z<Q.children.length;z++)if(Q.children[z]?.tagName==="defs")W=z+1;Q.children.splice(W,0,H)}else Q.children.push(H);return $}function Pz($){if(!$)return $;let J=(Z)=>{if(!Z||!Z.children||!Array.isArray(Z.children))return;Z.children=Z.children.filter((K)=>{if(K?.tagName==="script"){if(K.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((K.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let K of Z.children)if(K)J(K)};return J($),$}O.set({precision:80});var Az="1.2.0";var{parseSVG:Ij,serializeSVG:Cj}=T9,{detectSVG2Features:Pj,injectPolyfills:Aj,setPolyfillMinification:Ej,setPolyfillContent:Tj}=mJ;async function Ez($,J={}){let{loadInput:Z,saveOutput:K,optimize:Q}=K9,q=w$($),H=await Z($,q),W=await Q(H,{precision:J.precision||6,...J});if(J.output)return K(W,J.output,J);return K(W,null,J)}var EK={VERSION:Az,Decimal:O,Matrix:W0,Vector:S0,Transforms2D:L7,Transforms3D:O9,GeometryToPath:n$,...K9,parseSVG:u0,serializeSVG:K7,detectSVG2Features:j6,injectPolyfills:xJ,setPolyfillMinification:uJ,setPolyfillContent:gJ,process:Ez},Sj=EK;if(typeof window!=="undefined")window.SVGM=EK;export{qK as validateXML,oW as validateSVGAsync,HK as validateSVG,QJ as straightCurves,vZ as sortDefsChildren,SZ as sortAttrs,VK as simplifyPaths,FK as simplifyPath,Ej as setPolyfillMinification,Tj as setPolyfillContent,Cj as serializeSVG,WZ as saveOutput,DZ as reusePaths,uZ as removeXlink,YZ as removeXMLProcInst,LZ as removeXMLNS,wZ as removeViewBox,UZ as removeUselessDefs,WJ as removeUselessCommands,FZ as removeUnknownsAndDefaults,MZ as removeTitle,yZ as removeStyleElement,BZ as removeScriptElement,RZ as removeRasterImages,hZ as removeOffCanvasPath,_Z as removeNonInheritableGroupAttrs,J9 as removeMetadata,t9 as removeLeadingZero,t6 as removeHiddenElements,VZ as removeEmptyText,e6 as removeEmptyContainers,kZ as removeEmptyAttrs,nZ as removeElementsByAttr,LJ as removeEditorsNSData,OZ as removeDoctype,dZ as removeDimensions,XZ as removeDesc,$9 as removeComments,cZ as removeAttrs,pZ as removeAttributesBySelector,Ez as process,mW as printHierarchicalMatrix,IJ as presetNone,NJ as presetDefault,mZ as prefixIds,Ij as parseSVG,UK as optimizePaths,_K as optimizeAnimationTiming,sZ as optimize,e9 as negativeExtraSpace,TZ as moveGroupAttrsToElems,bZ as moveElemsAttrsToGroup,BJ as minifyStyles,EZ as mergePaths,QK as measureDistance,W6 as loadInput,ZJ as lineShorthands,fZ as inlineStyles,Aj as injectPolyfills,ZK as imageToPath,z6 as generateOutput,xW as generateFullCompatibilityMatrix,WK as generateFlexibleSVGTable,dW as generateCompatibilityMatrixSVG,pW as generateCompatibilityMatrixFlexible,HZ as formatPrecision,HJ as floatPrecision,JK as flattenUseElements,eZ as flattenPatterns,rZ as flattenMasks,aZ as flattenGradients,$K as flattenFilters,iZ as flattenClipPaths,GK as flattenAll,zK as fixInvalidSVG,MK as exportEmbeddedResources,EW as escapeXml,PJ as embedExternalDependencies,Pj as detectSVG2Features,kJ as detectOutputTarget,w$ as detectInputType,KK as detectCollisions,Sj as default,OK as decomposeTransform,F0 as createOperation,oZ as createConfig,CZ as convertTransform,KJ as convertToZ,$J as convertToRelative,JJ as convertToAbsolute,RJ as convertStyleToAttrs,NZ as convertShapesToPath,jJ as convertQuadraticToSmooth,IZ as convertPathData,PZ as convertEllipseToCircle,GJ as convertCubicToSmooth,zJ as convertCubicToQuadratic,Z9 as convertColors,qJ as collapseRepeated,AZ as collapseGroups,a6 as cleanupNumericValues,zZ as cleanupListOfValues,wJ as cleanupIds,GZ as cleanupEnableBackground,jZ as cleanupAttributes,FJ as arcShorthands,lZ as applyPreset,gW as analyzeCompatibilityMatrix,vW as analyzeCompatibility,xZ as addClassesToSVGElement,gZ as addAttributesToSVGElement,S0 as Vector,A0 as ValidationSeverity,Az as VERSION,O9 as Transforms3D,L7 as Transforms2D,qZ as PRECISION_LEVELS,Y7 as OutputTarget,M7 as OutputFormat,W0 as Matrix,H6 as MAX_PRECISION,D0 as InputType,n$ as GeometryToPath,O as Decimal,o6 as DEFAULT_PRECISION};
|