@emasoft/svg-matrix 1.0.34 → 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/README.md +58 -2
- 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 +125 -205
- package/dist/svgm.min.js +115 -195
- package/dist/version.json +5 -5
- package/package.json +6 -1
- package/scripts/postinstall.js +72 -41
- package/scripts/test-postinstall.js +18 -16
- package/scripts/version-sync.js +144 -49
- 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 +6 -4
- 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 +177 -87
- package/src/svgm-lib.js +10 -6
- 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,157 +1,77 @@
|
|
|
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 L6=9000000000000000,e7=1e9,z9="0123456789abcdef",_$="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",U$="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",W9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-L6,maxE:L6,crypto:!1},e8,m7,P0=!0,M$="[DecimalError] ",t7=M$+"Invalid argument: ",$J=M$+"Precision limit exceeded",JJ=M$+"crypto unavailable",ZJ="[object Decimal]",t0=Math.floor,c0=Math.pow,cK=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,nK=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,lK=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,KJ=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,I7=1e7,R0=7,sK=9007199254740991,oK=_$.length-1,j9=U$.length-1,K0={toStringTag:ZJ};K0.absoluteValue=K0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return Y0($)};K0.ceil=function(){return Y0(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,z=($=new q.constructor($)).d,j=q.s,W=$.s;if(!H||!z)return!j||!W?NaN:j!==W?j:H===z?0:!H^j<0?1:-1;if(!H[0]||!z[0])return H[0]?j:z[0]?-W:0;if(j!==W)return j;if(q.e!==$.e)return q.e>$.e^j<0?1:-1;K=H.length,Q=z.length;for(J=0,Z=K<Q?K:Q;J<Z;++J)if(H[J]!==z[J])return H[J]>z[J]^j<0?1:-1;return K===Q?0:K>Q^j<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=iK(K,WJ(K,Z)),K.precision=$,K.rounding=J,Y0(m7==2||m7==3?Z.neg():Z,$,J,!0)};K0.cubeRoot=K0.cbrt=function(){var $,J,Z,K,Q,q,H,z,j,W,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(P0=!1,q=G.s*c0(G.s*G,0.3333333333333333),!q||Math.abs(q)==1/0){if(Z=r0(G.d),$=G.e,q=($-Z.length+1)%3)Z+=q==1||q==-2?"0":"00";if(q=c0(Z,0.3333333333333333),$=t0(($+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(z=K,j=z.times(z).times(z),W=j.plus(G),K=v0(W.plus(G).times(z),W.plus(j),H+2,1),r0(z.d).slice(0,H)===(Z=r0(K.d)).slice(0,H))if(Z=Z.slice(H-3,H+1),Z=="9999"||!Q&&Z=="4999"){if(!Q){if(Y0(z,$+1,0),z.times(z).times(z).eq(G)){K=z;break}}H+=4,Q=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")Y0(K,$+1,1),J=!K.times(K).times(K).eq(G);break}return P0=!0,Y0(K,$,F.rounding,J)};K0.decimalPlaces=K0.dp=function(){var $,J=this.d,Z=NaN;if(J){if($=J.length-1,Z=($-t0(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 Y0(v0(J,new Z($),0,1,1),Z.precision,Z.rounding)};K0.equals=K0.eq=function($){return this.cmp($)===0};K0.floor=function(){return Y0(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,z=new H(1);if(!q.isFinite())return new H(q.s?1/0:NaN);if(q.isZero())return z;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/Y$(4,$)).toString();else $=16,J="2.3283064365386962890625e-10";q=R6(H,1,q.times(J),new H(1),!0);var j,W=$,G=new H(8);for(;W--;)j=q.times(q),q=z.minus(j.times(G.minus(j.times(G))));return Y0(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=R6(q,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/Y$(5,$)),Q=R6(q,2,Q,Q,!0);var H,z=new q(5),j=new q(16),W=new q(20);for(;$--;)H=Q.times(Q),Q=Q.times(z.plus(H.times(j.times(H).plus(W))))}return q.precision=J,q.rounding=Z,Y0(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()?T7(J,K,Q):new J(0):new J(NaN);if($.isZero())return T7(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 Y0(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 $=T7(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,z,j,W=this,G=W.constructor,F=G.precision,_=G.rounding;if(!W.isFinite()){if(!W.s)return new G(NaN);if(F+4<=j9)return H=T7(G,F+4,_).times(0.5),H.s=W.s,H}else if(W.isZero())return new G(W);else if(W.abs().eq(1)&&F+4<=j9)return H=T7(G,F+4,_).times(0.25),H.s=W.s,H;G.precision=z=F+10,G.rounding=1,Z=Math.min(28,z/R0+2|0);for($=Z;$;--$)W=W.div(W.times(W).plus(1).sqrt().plus(1));P0=!1,J=Math.ceil(z/R0),K=1,j=W.times(W),H=new G(W),Q=W;for(;$!==-1;)if(Q=Q.times(j),q=H.minus(Q.div(K+=2)),Q=Q.times(j),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,Y0(H,G.precision=F,G.rounding=_,!0)};K0.isFinite=function(){return!!this.d};K0.isInteger=K0.isInt=function(){return!!this.d&&t0(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,z,j,W=this,G=W.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=W.d,W.s<0||!Z||!Z[0]||W.eq(1))return new G(Z&&!Z[0]?-1/0:W.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,z=F+U,H=a7(W,z),K=J?V$(G,z+10):a7($,z),j=v0(H,K,z,1),u6(j.d,Q=F,_))do if(z+=10,H=a7(W,z),K=J?V$(G,z+10):a7($,z),j=v0(H,K,z,1),!q){if(+r0(j.d).slice(Q+1,Q+15)+1==100000000000000)j=Y0(j,F+1,0);break}while(u6(j.d,Q+=10,_));return P0=!0,Y0(j,F,_)};K0.minus=K0.sub=function($){var J,Z,K,Q,q,H,z,j,W,G,F,_,U=this,Y=U.constructor;if($=new Y($),!U.d||!$.d){if(!U.s||!$.s)$=new Y(NaN);else if(U.d)$.s=-$.s;else $=new Y($.d||U.s!==$.s?U:NaN);return $}if(U.s!=$.s)return $.s=-$.s,U.plus($);if(W=U.d,_=$.d,z=Y.precision,j=Y.rounding,!W[0]||!_[0]){if(_[0])$.s=-$.s;else if(W[0])$=new Y(U);else return new Y(j===3?-0:0);return P0?Y0($,z,j):$}if(Z=t0($.e/R0),G=t0(U.e/R0),W=W.slice(),q=G-Z,q){if(F=q<0,F)J=W,q=-q,H=_.length;else J=_,Z=G,H=W.length;if(K=Math.max(Math.ceil(z/R0),H)+2,q>K)q=K,J.length=1;J.reverse();for(K=q;K--;)J.push(0);J.reverse()}else{if(K=W.length,H=_.length,F=K<H,F)H=K;for(K=0;K<H;K++)if(W[K]!=_[K]){F=W[K]<_[K];break}q=0}if(F)J=W,W=_,_=J,$.s=-$.s;H=W.length;for(K=_.length-H;K>0;--K)W[H++]=0;for(K=_.length;K>q;){if(W[--K]<_[K]){for(Q=K;Q&&W[--Q]===0;)W[Q]=I7-1;--W[Q],W[K]+=I7}W[K]-=_[K]}for(;W[--H]===0;)W.pop();for(;W[0]===0;W.shift())--Z;if(!W[0])return new Y(j===3?-0:0);return $.d=W,$.e=O$(W,Z),P0?Y0($,z,j):$};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 Y0(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,Y0($)};K0.plus=K0.add=function($){var J,Z,K,Q,q,H,z,j,W,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(W=F.d,G=$.d,z=_.precision,j=_.rounding,!W[0]||!G[0]){if(!G[0])$=new _(F);return P0?Y0($,z,j):$}if(q=t0(F.e/R0),K=t0($.e/R0),W=W.slice(),Q=q-K,Q){if(Q<0)Z=W,Q=-Q,H=G.length;else Z=G,K=q,H=W.length;if(q=Math.ceil(z/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=W.length,Q=G.length,H-Q<0)Q=H,Z=G,G=W,W=Z;for(J=0;Q;)J=(W[--Q]=W[Q]+G[Q]+J)/I7|0,W[Q]%=I7;if(J)W.unshift(J),++K;for(H=W.length;W[--H]==0;)W.pop();return $.d=W,$.e=O$(W,K),P0?Y0($,z,j):$};K0.precision=K0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(t7+$);if(Z.d){if(J=QJ(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};K0.round=function(){var $=this,J=$.constructor;return Y0(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=aK(K,WJ(K,Z)),K.precision=$,K.rounding=J,Y0(m7>2?Z.neg():Z,$,J,!0)};K0.squareRoot=K0.sqrt=function(){var $,J,Z,K,Q,q,H=this,z=H.d,j=H.e,W=H.s,G=H.constructor;if(W!==1||!z||!z[0])return new G(!W||W<0&&(!z||z[0])?NaN:z?H:1/0);if(P0=!1,W=Math.sqrt(+H),W==0||W==1/0){if(J=r0(z),(J.length+j)%2==0)J+="0";if(W=Math.sqrt(J),j=t0((j+1)/2)-(j<0||j%2),W==1/0)J="5e"+j;else J=W.toExponential(),J=J.slice(0,J.indexOf("e")+1)+j;K=new G(J)}else K=new G(W.toString());Z=(j=G.precision)+3;for(;;)if(q=K,K=q.plus(v0(H,q,Z+2,1)).times(0.5),r0(q.d).slice(0,Z)===(J=r0(K.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!Q&&J=="4999"){if(!Q){if(Y0(q,j+1,0),q.times(q).eq(H)){K=q;break}}Z+=4,Q=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")Y0(K,j+1,1),$=!K.times(K).eq(H);break}return P0=!0,Y0(K,j,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,Y0(m7==2||m7==4?Z.neg():Z,$,J,!0)};K0.times=K0.mul=function($){var J,Z,K,Q,q,H,z,j,W,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=t0(G.e/R0)+t0($.e/R0),j=_.length,W=U.length,j<W)q=_,_=U,U=q,H=j,j=W,W=H;q=[],H=j+W;for(K=H;K--;)q.push(0);for(K=W;--K>=0;){J=0;for(Q=j+K;Q>K;)z=q[Q]+U[K]*_[Q-K-1]+J,q[Q--]=z%I7|0,J=z/I7|0;q[Q]=(q[Q]+J)%I7|0}for(;!q[--H];)q.pop();if(J)++Z;else q.shift();return $.d=q,$.e=O$(q,Z),P0?Y0($,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(K7($,0,e7),J===void 0)J=K.rounding;else K7(J,0,8);return Y0(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(K7($,0,e7),J===void 0)J=Q.rounding;else K7(J,0,8);K=Y0(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(K7($,0,e7),J===void 0)J=q.rounding;else K7(J,0,8);K=Y0(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,z,j,W,G,F,_,U=this,Y=U.d,V=U.constructor;if(!Y)return new V(U);if(W=Z=new V(1),K=j=new V(0),J=new V(K),q=J.e=QJ(Y)-U.e-1,H=q%R0,J.d[0]=c0(10,H<0?R0+H:H),$==null)$=q>0?J:W;else{if(z=new V($),!z.isInt()||z.lt(W))throw Error(t7+z);$=z.gt(J)?q>0?J:W:z}P0=!1,z=new V(r0(Y)),G=V.precision,V.precision=q=Y.length*R0*2;for(;;){if(F=v0(z,J,0,1,1),Q=Z.plus(F.times(K)),Q.cmp($)==1)break;Z=K,K=Q,Q=W,W=j.plus(F.times(Q)),j=Q,Q=J,J=z.minus(F.times(Q)),z=Q}return Q=v0($.minus(Z),K,0,1,1),j=j.plus(Q.times(W)),Z=Z.plus(Q.times(K)),j.s=W.s=U.s,_=v0(W,K,q,1).minus(U).abs().cmp(v0(j,Z,q,1).minus(U).abs())<1?[W,K]:[j,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 K7(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,Y0(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,z=this,j=z.constructor,W=+($=new j($));if(!z.d||!$.d||!z.d[0]||!$.d[0])return new j(c0(+z,W));if(z=new j(z),z.eq(1))return z;if(K=j.precision,q=j.rounding,$.eq(1))return Y0(z,K,q);if(J=t0($.e/R0),J>=$.d.length-1&&(Z=W<0?-W:W)<=sK)return Q=qJ(j,z,Z,K),$.s<0?new j(1).div(Q):Y0(Q,K,q);if(H=z.s,H<0){if(J<$.d.length-1)return new j(NaN);if(($.d[J]&1)==0)H=1;if(z.e==0&&z.d[0]==1&&z.d.length==1)return z.s=H,z}if(Z=c0(+z,W),J=Z==0||!isFinite(Z)?t0(W*(Math.log("0."+r0(z.d))/Math.LN10+z.e+1)):new j(Z+"").e,J>j.maxE+1||J<j.minE-1)return new j(J>0?H/0:0);if(P0=!1,j.rounding=z.s=1,Z=Math.min(12,(J+"").length),Q=G9($.times(a7(z,K+Z)),K),Q.d){if(Q=Y0(Q,K+5,1),u6(Q.d,K,q)){if(J=K+10,Q=Y0(G9($.times(a7(z,J+Z)),J),J+5,1),+r0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=Y0(Q,K+1,0)}}return Q.s=H,P0=!0,j.rounding=q,Y0(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(K7($,1,e7),J===void 0)J=Q.rounding;else K7(J,0,8);K=Y0(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(K7($,1,e7),J===void 0)J=K.rounding;else K7(J,0,8);return Y0(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 Y0(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 r0($){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 K7($,J,Z){if($!==~~$||$<J||$>Z)throw Error(t7+$)}function u6($,J,Z,K){var Q,q,H,z;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=c0(10,R0-J),z=$[Q]%q|0,K==null)if(J<3){if(J==0)z=z/100|0;else if(J==1)z=z/10|0;H=Z<4&&z==99999||Z>3&&z==49999||z==50000||z==0}else H=(Z<4&&z+1==q||Z>3&&z+1==q/2)&&($[Q+1]/q/100|0)==c0(10,J-2)-1||(z==q/2||z==0)&&($[Q+1]/q/100|0)==0;else if(J<4){if(J==0)z=z/1000|0;else if(J==1)z=z/100|0;else if(J==2)z=z/10|0;H=(K||Z<4)&&z==9999||!K&&Z>3&&z==4999}else H=((K||Z<4)&&z+1==q||!K&&Z>3&&z+1==q/2)&&($[Q+1]/q/1000|0)==c0(10,J-3)-1;return H}function G$($,J,Z){var K,Q=[0],q,H=0,z=$.length;for(;H<z;){for(q=Q.length;q--;)Q[q]*=J;Q[0]+=z9.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 iK($,J){var Z,K,Q;if(J.isZero())return J;if(K=J.d.length,K<32)Z=Math.ceil(K/3),Q=(1/Y$(4,Z)).toString();else Z=16,Q="2.3283064365386962890625e-10";$.precision+=Z,J=R6($,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,z=0,j=K.length;for(K=K.slice();j--;)H=K[j]*Q+z,K[j]=H%q|0,z=H/q|0;if(z)K.unshift(z);return K}function J(K,Q,q,H){var z,j;if(q!=H)j=q>H?1:-1;else for(z=j=0;z<q;z++)if(K[z]!=Q[z]){j=K[z]>Q[z]?1:-1;break}return j}function Z(K,Q,q,H){var z=0;for(;q--;)K[q]-=z,z=K[q]<Q[q]?1:0,K[q]=z*H+K[q]-Q[q];for(;!K[0]&&K.length>1;)K.shift()}return function(K,Q,q,H,z,j){var W,G,F,_,U,Y,V,O,X,k,w,R,I,C,v,g,T,u,S,A,y=K.constructor,p=K.s==Q.s?1:-1,m=K.d,B=Q.d;if(!m||!m[0]||!B||!B[0])return new y(!K.s||!Q.s||(m?B&&m[0]==B[0]:!B)?NaN:m&&m[0]==0||!B?p*0:p/0);if(j)U=1,G=K.e-Q.e;else j=I7,U=R0,G=t0(K.e/U)-t0(Q.e/U);S=B.length,T=m.length,X=new y(p),k=X.d=[];for(F=0;B[F]==(m[F]||0);F++);if(B[F]>(m[F]||0))G--;if(q==null)C=q=y.precision,H=y.rounding;else if(z)C=q+(K.e-Q.e)+1;else C=q;if(C<0)k.push(1),Y=!0;else{if(C=C/U+2|0,F=0,S==1){_=0,B=B[0],C++;for(;(F<T||_)&&C--;F++)v=_*j+(m[F]||0),k[F]=v/B|0,_=v%B|0;Y=_||F<T}else{if(_=j/(B[0]+1)|0,_>1)B=$(B,_,j),m=$(m,_,j),S=B.length,T=m.length;g=S,w=m.slice(0,S),R=w.length;for(;R<S;)w[R++]=0;if(A=B.slice(),A.unshift(0),u=B[0],B[1]>=j/2)++u;do{if(_=0,W=J(B,w,S,R),W<0){if(I=w[0],S!=R)I=I*j+(w[1]||0);if(_=I/u|0,_>1){if(_>=j)_=j-1;if(V=$(B,_,j),O=V.length,R=w.length,W=J(V,w,O,R),W==1)_--,Z(V,S<O?A:B,O,j)}else{if(_==0)W=_=1;V=B.slice()}if(O=V.length,O<R)V.unshift(0);if(Z(w,V,R,j),W==-1){if(R=w.length,W=J(B,w,S,R),W<1)_++,Z(w,S<R?A:B,R,j)}R=w.length}else if(W===0)_++,w=[0];if(k[F++]=_,W&&w[0])w[R++]=m[g]||0;else w=[m[g]],R=1}while((g++<T||w[0]!==void 0)&&C--);Y=w[0]!==void 0}if(!k[0])k.shift()}if(U==1)X.e=G,e8=Y;else{for(F=1,_=k[0];_>=10;_/=10)F++;X.e=F+G*U-1,Y0(X,z?q+X.e+1:q,H,Y)}return X}}();function Y0($,J,Z,K){var Q,q,H,z,j,W,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(Q=1,z=F[0];z>=10;z/=10)Q++;if(q=J-Q,q<0)q+=R0,H=J,G=F[_=0],j=G/c0(10,Q-H-1)%10|0;else if(_=Math.ceil((q+1)/R0),z=F.length,_>=z)if(K){for(;z++<=_;)F.push(0);G=j=0,Q=1,q%=R0,H=q-R0+1}else break $;else{G=z=F[_];for(Q=1;z>=10;z/=10)Q++;q%=R0,H=q-R0+Q,j=H<0?0:G/c0(10,Q-H-1)%10|0}if(K=K||J<0||F[_+1]!==void 0||(H<0?G:G%c0(10,Q-H-1)),W=Z<4?(j||K)&&(Z==0||Z==($.s<0?3:2)):j>5||j==5&&(Z==4||K||Z==6&&(q>0?H>0?G/c0(10,Q-H):0:F[_-1])%10&1||Z==($.s<0?8:7)),J<1||!F[0]){if(F.length=0,W)J-=$.e+1,F[0]=c0(10,(R0-J%R0)%R0),$.e=-J||0;else F[0]=$.e=0;return $}if(q==0)F.length=_,z=1,_--;else F.length=_+1,z=c0(10,R0-q),F[_]=H>0?(G/c0(10,Q-H)%c0(10,H)|0)*z:0;if(W)for(;;)if(_==0){for(q=1,H=F[0];H>=10;H/=10)q++;H=F[0]+=z;for(z=1;H>=10;H/=10)z++;if(q!=z){if($.e++,F[0]==I7)F[0]=1}break}else{if(F[_]+=z,F[_]!=I7)break;F[_--]=0,z=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 zJ($);var K,Q=$.e,q=r0($.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 O$($,J){var Z=$[0];for(J*=R0;Z>=10;Z/=10)J++;return J}function V$($,J,Z){if(J>oK){if(P0=!0,Z)$.precision=Z;throw Error($J)}return Y0(new $(_$),J,1,!0)}function T7($,J,Z){if(J>j9)throw Error($J);return Y0(new $(U$),J,Z,!0)}function QJ($){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 qJ($,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),a8(q.d,H))Q=!0}if(Z=t0(Z/2),Z===0){if(Z=q.d.length-1,Q&&q.d[Z]===0)++q.d[Z];break}J=J.times(J),a8(J.d,H)}return P0=!0,q}function r8($){return $.d[$.d.length-1]&1}function HJ($,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,z,j,W=0,G=0,F=0,_=$.constructor,U=_.rounding,Y=_.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,j=Y;else j=J;z=new _(0.03125);while($.e>-2)$=$.times(z),F+=5;K=Math.log(c0(2,F))/Math.LN10*2+5|0,j+=K,Z=q=H=new _(1),_.precision=j;for(;;){if(q=Y0(q.times($),j,1),Z=Z.times(++G),z=H.plus(v0(q,Z,j,1)),r0(z.d).slice(0,j)===r0(H.d).slice(0,j)){Q=F;while(Q--)H=Y0(H.times(H),j,1);if(J==null)if(W<3&&u6(H.d,j-K,U,W))_.precision=j+=10,Z=q=z=new _(1),G=0,W++;else return Y0(H,_.precision=Y,U,P0=!0);else return _.precision=Y,H}H=z}}function a7($,J){var Z,K,Q,q,H,z,j,W,G,F,_,U=1,Y=10,V=$,O=V.d,X=V.constructor,k=X.rounding,w=X.precision;if(V.s<0||!O||!O[0]||!V.e&&O[0]==1&&O.length==1)return new X(O&&!O[0]?-1/0:V.s!=1?NaN:O?0:V);if(J==null)P0=!1,G=w;else G=J;if(X.precision=G+=Y,Z=r0(O),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=r0(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 W=V$(X,G+2,w).times(q+""),V=a7(new X(K+"."+Z.slice(1)),G-Y).plus(W),X.precision=w,J==null?Y0(V,w,k,P0=!0):V;F=V,j=H=V=v0(V.minus(1),V.plus(1),G,1),_=Y0(V.times(V),G,1),Q=3;for(;;){if(H=Y0(H.times(_),G,1),W=j.plus(v0(H,new X(Q),G,1)),r0(W.d).slice(0,G)===r0(j.d).slice(0,G)){if(j=j.times(2),q!==0)j=j.plus(V$(X,G+2,w).times(q+""));if(j=v0(j,new X(U),G,1),J==null)if(u6(j.d,G-Y,k,z))X.precision=G+=Y,W=H=V=v0(F.minus(1),F.plus(1),G,1),_=Y0(V.times(V),G,1),Q=z=1;else return Y0(j,X.precision=w,k,P0=!0);else return X.precision=w,j}j=W,Q+=2}}function zJ($){return String($.s*$.s/0)}function F$($,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 rK($,J){var Z,K,Q,q,H,z,j,W,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),KJ.test(J))return F$($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(nK.test(J))Z=16,J=J.toLowerCase();else if(cK.test(J))Z=2;else if(lK.test(J))Z=8;else throw Error(t7+J);if(q=J.search(/p/i),q>0)j=+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(".",""),z=J.length,q=z-q,Q=qJ(K,new K(Z),q,q*2);W=G$(J,Z,I7),G=W.length-1;for(q=G;W[q]===0;--q)W.pop();if(q<0)return new K($.s*0);if($.e=O$(W,G),$.d=W,P0=!1,H)$=v0($,Q,z*4);if(j)$=$.times(Math.abs(j)<54?c0(2,j):g6.pow(2,j));return P0=!0,$}function aK($,J){var Z,K=J.d.length;if(K<3)return J.isZero()?J:R6($,2,J,J);Z=1.4*Math.sqrt(K),Z=Z>16?16:Z|0,J=J.times(1/Y$(5,Z)),J=R6($,2,J,J);var Q,q=new $(5),H=new $(16),z=new $(20);for(;Z--;)Q=J.times(J),J=J.times(q.plus(Q.times(H.times(Q).minus(z))));return J}function R6($,J,Z,K,Q){var q,H,z,j,W=1,G=$.precision,F=Math.ceil(G/R0);P0=!1,j=Z.times(Z),z=new $(K);for(;;){if(H=v0(z.times(j),new $(J++*J++),G,1),z=Q?K.plus(H):K.minus(H),K=v0(H.times(j),new $(J++*J++),G,1),H=z.plus(K),H.d[F]!==void 0){for(q=F;H.d[q]===z.d[q]&&q--;);if(q==-1)break}q=z,z=K,K=H,H=q,W++}return P0=!0,H.d.length=F+1,H}function Y$($,J){var Z=$;while(--J)Z*=$;return Z}function WJ($,J){var Z,K=J.s<0,Q=T7($,$.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=r8(Z)?K?2:3:K?4:1,J;m7=r8(Z)?K?1:4:K?3:2}return J.minus(Q).abs()}function F9($,J,Z,K){var Q,q,H,z,j,W,G,F,_,U=$.constructor,Y=Z!==void 0;if(Y)if(K7(Z,1,e7),K===void 0)K=U.rounding;else K7(K,0,8);else Z=U.precision,K=U.rounding;if(!$.isFinite())G=zJ($);else{if(G=f7($),H=G.indexOf("."),Y){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=G$(f7(_),10,Q),_.e=_.d.length;F=G$(G,10,Q),q=j=F.length;for(;F[--j]==0;)F.pop();if(!F[0])G=Y?"0p+0":"0";else{if(H<0)q--;else $=new U($),$.d=F,$.e=q,$=v0($,_,Z,K,0,Q),F=$.d,q=$.e,W=e8;if(H=F[Z],z=Q/2,W=W||F[Z+1]!==void 0,W=K<4?(H!==void 0||W)&&(K===0||K===($.s<0?3:2)):H>z||H===z&&(K===4||W||K===6&&F[Z-1]&1||K===($.s<0?8:7)),F.length=Z,W){for(;++F[--Z]>Q-1;)if(F[Z]=0,!Z)++q,F.unshift(1)}for(j=F.length;!F[j-1];--j);for(H=0,G="";H<j;H++)G+=z9.charAt(F[H]);if(Y){if(j>1)if(J==16||J==8){H=J==16?4:3;for(--j;j%H;j++)G+="0";F=G$(G,Q,J);for(j=F.length;!F[j-1];--j);for(H=1,G="1.";H<j;H++)G+=z9.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>j)for(q-=j;q--;)G+="0";else if(q<j)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 a8($,J){if($.length>J)return $.length=J,!0}function tK($){return new this($).abs()}function eK($){return new this($).acos()}function $Q($){return new this($).acosh()}function JQ($,J){return new this($).plus(J)}function ZQ($){return new this($).asin()}function KQ($){return new this($).asinh()}function QQ($){return new this($).atan()}function qQ($){return new this($).atanh()}function HQ($,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=T7(this,q,1).times(J.s>0?0.25:0.75),Z.s=$.s;else if(!J.d||$.isZero())Z=J.s<0?T7(this,K,Q):new this(0),Z.s=$.s;else if(!$.d||J.isZero())Z=T7(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=T7(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 zQ($){return new this($).cbrt()}function WQ($){return Y0($=new this($),$.e+1,2)}function jQ($,J,Z){return new this($).clamp(J,Z)}function GQ($){if(!$||typeof $!=="object")throw Error(M$+"Object expected");var J,Z,K,Q=$.defaults===!0,q=["precision",1,e7,"rounding",0,8,"toExpNeg",-L6,0,"toExpPos",0,L6,"maxE",0,L6,"minE",-L6,0,"modulo",0,9];for(J=0;J<q.length;J+=3){if(Z=q[J],Q)this[Z]=W9[Z];if((K=$[Z])!==void 0)if(t0(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]=W9[Z];if((K=$[Z])!==void 0)if(K===!0||K===!1||K===0||K===1)if(K)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[Z]=!0;else throw Error(JJ);else this[Z]=!1;else throw Error(t7+Z+": "+K);return this}function FQ($){return new this($).cos()}function _Q($){return new this($).cosh()}function jJ($){var J,Z,K;function Q(q){var H,z,j,W=this;if(!(W instanceof Q))return new Q(q);if(W.constructor=Q,t8(q)){if(W.s=q.s,P0)if(!q.d||q.e>Q.maxE)W.e=NaN,W.d=null;else if(q.e<Q.minE)W.e=0,W.d=[0];else W.e=q.e,W.d=q.d.slice();else W.e=q.e,W.d=q.d?q.d.slice():q.d;return}if(j=typeof q,j==="number"){if(q===0){W.s=1/q<0?-1:1,W.e=0,W.d=[0];return}if(q<0)q=-q,W.s=-1;else W.s=1;if(q===~~q&&q<1e7){for(H=0,z=q;z>=10;z/=10)H++;if(P0)if(H>Q.maxE)W.e=NaN,W.d=null;else if(H<Q.minE)W.e=0,W.d=[0];else W.e=H,W.d=[q];else W.e=H,W.d=[q];return}if(q*0!==0){if(!q)W.s=NaN;W.e=NaN,W.d=null;return}return F$(W,q.toString())}if(j==="string"){if((z=q.charCodeAt(0))===45)q=q.slice(1),W.s=-1;else{if(z===43)q=q.slice(1);W.s=1}return KJ.test(q)?F$(W,q):rK(W,q)}if(j==="bigint"){if(q<0)q=-q,W.s=-1;else W.s=1;return F$(W,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=GQ,Q.clone=jJ,Q.isDecimal=t8,Q.abs=tK,Q.acos=eK,Q.acosh=$Q,Q.add=JQ,Q.asin=ZQ,Q.asinh=KQ,Q.atan=QQ,Q.atanh=qQ,Q.atan2=HQ,Q.cbrt=zQ,Q.ceil=WQ,Q.clamp=jQ,Q.cos=FQ,Q.cosh=_Q,Q.div=UQ,Q.exp=VQ,Q.floor=MQ,Q.hypot=OQ,Q.ln=YQ,Q.log=XQ,Q.log10=wQ,Q.log2=kQ,Q.max=LQ,Q.min=RQ,Q.mod=BQ,Q.mul=NQ,Q.pow=IQ,Q.random=CQ,Q.round=PQ,Q.sign=AQ,Q.sin=EQ,Q.sinh=TQ,Q.sqrt=fQ,Q.sub=bQ,Q.sum=SQ,Q.tan=vQ,Q.tanh=DQ,Q.trunc=hQ,$===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 UQ($,J){return new this($).div(J)}function VQ($){return new this($).exp()}function MQ($){return Y0($=new this($),$.e+1,3)}function OQ(){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 t8($){return $ instanceof g6||$&&$.toStringTag===ZJ||!1}function YQ($){return new this($).ln()}function XQ($,J){return new this($).log(J)}function kQ($){return new this($).log(2)}function wQ($){return new this($).log(10)}function LQ(){return HJ(this,arguments,-1)}function RQ(){return HJ(this,arguments,1)}function BQ($,J){return new this($).mod(J)}function NQ($,J){return new this($).mul(J)}function IQ($,J){return new this($).pow(J)}function CQ($){var J,Z,K,Q,q=0,H=new this(1),z=[];if($===void 0)$=this.precision;else K7($,1,e7);if(K=Math.ceil($/R0),!this.crypto)for(;q<K;)z[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 z[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 z.push(Q%1e7),q+=4;q=K/4}else throw Error(JJ);if(K=z[--q],$%=R0,K&&$)Q=c0(10,R0-$),z[q]=(K/Q|0)*Q;for(;z[q]===0;q--)z.pop();if(q<0)Z=0,z=[0];else{Z=-1;for(;z[0]===0;Z-=R0)z.shift();for(K=1,Q=z[0];Q>=10;Q/=10)K++;if(K<R0)Z-=R0-K}return H.e=Z,H.d=z,H}function PQ($){return Y0($=new this($),$.e+1,this.rounding)}function AQ($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function EQ($){return new this($).sin()}function TQ($){return new this($).sinh()}function fQ($){return new this($).sqrt()}function bQ($,J){return new this($).sub(J)}function SQ(){var $=0,J=arguments,Z=new this(J[$]);P0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return P0=!0,Y0(Z,this.precision,this.rounding)}function vQ($){return new this($).tan()}function DQ($){return new this($).tanh()}function hQ($){return Y0($=new this($),$.e+1,1)}K0[Symbol.for("nodejs.util.inspect.custom")]=K0.toString;K0[Symbol.toStringTag]="Decimal";var g6=K0.constructor=jJ(W9);_$=new g6(_$);U$=new g6(U$);var M=g6;var _9=($)=>{if($===null||$===void 0)throw Error(`Cannot convert ${$===null?"null":"undefined"} to Decimal`);if($ instanceof M)return $;try{return new M($)}catch(J){throw Error(`Invalid numeric value: ${J.message}`)}};class S0{constructor($){if(!Array.isArray($))throw Error("Vector requires array");if($.length===0)throw Error("Vector requires at least one component");try{this.data=$.map((J,Z)=>{if(J===null||J===void 0)throw Error(`Vector component at index ${Z} is ${J===null?"null":"undefined"}`);return _9(J)})}catch(J){throw Error(`Vector constructor failed: ${J.message}`)}this.length=this.data.length}static from($){if($===null||$===void 0)throw Error(`Vector.from: argument is ${$===null?"null":"undefined"}`);return new S0($)}clone(){return new S0(this.data.map(($)=>new M($)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map(($)=>$.toNumber())}toStringArray(){return this.data.map(($)=>$.toString())}add($){if(!$||!($ instanceof S0))throw Error("add: argument must be a Vector");if(this.length!==$.length)throw 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 Error("sub: argument must be a Vector");if(this.length!==$.length)throw 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 Error(`scale: scalar is ${$===null?"null":"undefined"}`);let J;try{J=_9($)}catch(Z){throw 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 Error("dot: argument must be a Vector");if(this.length!==$.length)throw Error(`dot: dimension mismatch (${this.length} vs ${$.length})`);return this.data.reduce((J,Z,K)=>J.plus(Z.mul($.data[K])),new M(0))}outer($){if(!$||!($ instanceof S0))throw Error("outer: argument must be a Vector");if(this.length===0||$.length===0)throw 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,z)=>this.data[q].mul($.data[z])))}cross($){if(!$||!($ instanceof S0))throw Error("cross: argument must be a Vector");if(this.length!==3||$.length!==3)throw 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 M(0);for(let J of this.data)$=$.plus(J.mul(J));return $.sqrt()}normalize(){let $=this.norm();if($.isZero())throw Error("Cannot normalize zero vector");return this.scale(new M(1).div($))}angleBetween($){if(!$||!($ instanceof S0))throw Error("angleBetween: argument must be a Vector");if(this.length!==$.length)throw Error(`angleBetween: dimension mismatch (${this.length} vs ${$.length})`);let J=this.dot($),Z=this.norm(),K=$.norm();if(Z.isZero()||K.isZero())throw 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 M(Math.acos(H))}projectOnto($){if(!$||!($ instanceof S0))throw Error("projectOnto: argument must be a Vector");if(this.length!==$.length)throw Error(`projectOnto: dimension mismatch (${this.length} vs ${$.length})`);let J=$.dot($);if(J.isZero())throw Error("projectOnto: cannot project onto zero vector");let Z=this.dot($).div(J);return $.scale(Z)}orthogonal(){if(this.norm().isZero())throw 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},(z,j)=>new M(j===J?1:0)),K=new S0(Z),Q=K.projectOnto(this),q=K.sub(Q);if(!q.norm().isZero())return q.normalize()}throw Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo($){if(!$||!($ instanceof S0))throw Error("isOrthogonalTo: argument must be a Vector");if(this.length!==$.length)throw Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${$.length})`);return this.dot($).isZero()}distance($){if(!$||!($ instanceof S0))throw Error("distance: argument must be a Vector");if(this.length!==$.length)throw 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 Error("equals: tolerance cannot be null");let Z;try{if(Z=_9(J),Z.isNaN())throw Error("equals: tolerance cannot be NaN");if(Z.isNegative())throw Error("equals: tolerance must be non-negative")}catch(K){throw 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 B6=($)=>{if($==null)throw Error("Cannot convert null or undefined to Decimal");return $ instanceof M?$:new M($)};class z0{constructor($){if(!Array.isArray($)||$.length===0)throw Error("Matrix requires non-empty 2D array");if(!Array.isArray($[0])||$[0].length===0)throw Error("Matrix rows must be non-empty arrays");let J=$[0].length;for(let Z of $)if(!Array.isArray(Z)||Z.length!==J)throw Error("All rows must have same length");this.data=$.map((Z)=>Z.map((K)=>B6(K))),this.rows=$.length,this.cols=J}static from($){return new z0($)}static zeros($,J){if(!Number.isInteger($)||$<=0)throw Error("rows must be a positive integer");if(!Number.isInteger(J)||J<=0)throw Error("cols must be a positive integer");let Z=Array.from({length:$},()=>Array.from({length:J},()=>new M(0)));return new z0(Z)}static identity($){if(!Number.isInteger($)||$<=0)throw Error("size must be a positive integer");let J=Array.from({length:$},(Z,K)=>Array.from({length:$},(Q,q)=>K===q?new M(1):new M(0)));return new z0(J)}clone(){return new z0(this.data.map(($)=>$.map((J)=>new M(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 Error("applyToVector expects Vector or array");if(this.cols!==J.length)throw Error("shape mismatch: matrix cols must equal vector length");let Z=[];for(let K=0;K<this.rows;K++){let Q=new M(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 z0){if(this.rows!==$.rows||this.cols!==$.cols)throw Error("shape mismatch: matrices must have same dimensions");return new z0(this.data.map((J,Z)=>J.map((K,Q)=>K.plus($.data[Z][Q]))))}else{let J=B6($);return new z0(this.data.map((Z)=>Z.map((K)=>K.plus(J))))}}sub($){if($ instanceof z0){if(this.rows!==$.rows||this.cols!==$.cols)throw Error("shape mismatch: matrices must have same dimensions");return new z0(this.data.map((J,Z)=>J.map((K,Q)=>K.minus($.data[Z][Q]))))}else{let J=B6($);return new z0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof z0){if(this.cols!==$.rows)throw Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let J=Array.from({length:this.rows},()=>Array.from({length:$.cols},()=>new M(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 z0(J)}else{let J=B6($);return new z0(this.data.map((Z)=>Z.map((K)=>K.mul(J))))}}div($){let J=B6($);if(J.isZero())throw Error("Cannot divide by zero");return new z0(this.data.map((Z)=>Z.map((K)=>K.div(J))))}negate(){return new z0(this.data.map(($)=>$.map((J)=>J.negated())))}transpose(){let $=Array.from({length:this.cols},(J,Z)=>Array.from({length:this.rows},(K,Q)=>new M(this.data[Q][Z])));return new z0($)}trace(){if(!this.isSquare())throw Error("Trace only defined for square matrices");let $=new M(0);for(let J=0;J<this.rows;J++)$=$.plus(this.data[J][J]);return $}equals($,J=0){if(!($ instanceof z0))return!1;if(this.rows!==$.rows||this.cols!==$.cols)return!1;let Z=B6(J);if(Z.isNegative()||!Z.isFinite())throw 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 Error("LU decomposition requires square matrix");let $=this.rows,J=this.data.map((H)=>H.map((z)=>new M(z))),Z=Array.from({length:$},(H,z)=>z),K=Array.from({length:$},()=>Array.from({length:$},()=>new M(0)));for(let H=0;H<$;H++)K[H][H]=new M(1);for(let H=0;H<$;H++){let z=H,j=J[H][H].abs();for(let W=H+1;W<$;W++){let G=J[W][H].abs();if(G.greaterThan(j))j=G,z=W}if(J[z][H].isZero())throw Error("Singular matrix: LU decomposition failed");if(z!==H){let W=J[H];J[H]=J[z],J[z]=W;let G=Z[H];Z[H]=Z[z],Z[z]=G;for(let F=0;F<H;F++){let _=K[H][F];K[H][F]=K[z][F],K[z][F]=_}}for(let W=H+1;W<$;W++){let G=J[W][H].div(J[H][H]);K[W][H]=G;for(let F=H;F<$;F++)J[W][F]=J[W][F].minus(G.mul(J[H][F]))}}let Q=Array.from({length:$},(H,z)=>Array.from({length:$},(j,W)=>W<z?new M(0):J[z][W])),q=z0.zeros($,$);for(let H=0;H<$;H++)q.data[H][Z[H]]=new M(1);return{L:new z0(K),U:new z0(Q),P:q}}determinant(){if(!this.isSquare())throw Error("Determinant only defined for square matrices");let $=this.rows,{L:J,U:Z,P:K}=this.lu(),Q=new M(1);for(let z=0;z<$;z++)Q=Q.mul(Z.data[z][z]);let q=[];for(let z=0;z<$;z++)for(let j=0;j<$;j++)if(K.data[z][j].equals(1))q.push(j);let H=0;for(let z=0;z<q.length;z++)for(let j=z+1;j<q.length;j++)if(q[z]>q[j])H++;if(H%2===1)Q=Q.negated();return Q}inverse(){if(!this.isSquare())throw Error("Inverse only defined for square matrices");let $=this.rows,J=Array.from({length:$},(K,Q)=>Array.from({length:2*$},(q,H)=>H<$?new M(this.data[Q][H]):H-$===Q?new M(1):new M(0)));for(let K=0;K<$;K++){let Q=K,q=J[K][K].abs();for(let z=K+1;z<$;z++){let j=J[z][K].abs();if(j.greaterThan(q))q=j,Q=z}if(J[Q][K].isZero())throw Error("Singular matrix: inverse does not exist");if(Q!==K){let z=J[K];J[K]=J[Q],J[Q]=z}let H=J[K][K];for(let z=0;z<2*$;z++)J[K][z]=J[K][z].div(H);for(let z=0;z<$;z++){if(z===K)continue;let j=J[z][K];if(j.isZero())continue;for(let W=0;W<2*$;W++)J[z][W]=J[z][W].minus(j.mul(J[K][W]))}}let Z=J.map((K)=>K.slice($));return new z0(Z)}solve($){let J;if($ instanceof S0)J=$;else if(Array.isArray($))J=S0.from($);else throw Error("b must be Vector or array");if(!this.isSquare())throw Error("solve() only implemented for square matrices");let Z=this.rows;if(J.length!==Z)throw Error("dimension mismatch: b length must equal matrix rows");let K=Array.from({length:Z},(q,H)=>Array.from({length:Z+1},(z,j)=>new M(j<Z?this.data[H][j]:J.data[H])));for(let q=0;q<Z;q++){let H=q,z=K[q][q].abs();for(let j=q+1;j<Z;j++){let W=K[j][q].abs();if(W.greaterThan(z))z=W,H=j}if(K[H][q].isZero())throw Error("Singular matrix: no unique solution");if(H!==q){let j=K[q];K[q]=K[H],K[H]=j}for(let j=q+1;j<Z;j++){let W=K[j][q].div(K[q][q]);if(W.isZero())continue;for(let G=q;G<Z+1;G++)K[j][G]=K[j][G].minus(W.mul(K[q][G]))}}let Q=Array.from({length:Z},()=>new M(0));for(let q=Z-1;q>=0;q--){if(K[q][q].isZero())throw Error("Zero diagonal element in back substitution: system is singular");let H=new M(0);for(let z=q+1;z<Z;z++)H=H.plus(K[q][z].mul(Q[z]));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 M(H))),K=z0.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 z=new M(0);for(let F of H)z=z.plus(F.mul(F));if(z=z.sqrt(),z.isZero())continue;let j=H[0].isNegative()?new M(-1):new M(1),W=H.slice();W[0]=W[0].plus(j.mul(z));let G=new M(0);for(let F of W)G=G.plus(F.mul(F));if(G=G.sqrt(),G.isZero())continue;for(let F=0;F<W.length;F++)W[F]=W[F].div(G);for(let F=q;F<J;F++){let _=new M(0);for(let U=0;U<W.length;U++)_=_.plus(W[U].mul(Z[q+U][F]));for(let U=0;U<W.length;U++)Z[q+U][F]=Z[q+U][F].minus(new M(2).mul(W[U]).mul(_))}for(let F=0;F<$;F++){let _=new M(0);for(let U=0;U<W.length;U++)_=_.plus(W[U].mul(K[q+U][F]));for(let U=0;U<W.length;U++)K[q+U][F]=K[q+U][F].minus(new M(2).mul(W[U]).mul(_))}}let Q=Array.from({length:$},(q,H)=>Array.from({length:J},(z,j)=>H<=j?Z[H][j]:new M(0)));return{Q:new z0(K).transpose(),R:new z0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw Error("Matrix exponential requires square matrix");let Z=z0.identity(J),K=$.maxIter||120;if(!Number.isInteger(K)||K<=0)throw Error("maxIter must be a positive integer");let Q=new M($.tolerance||"1e-40");if(Q.isNegative()||Q.isZero()||!Q.isFinite())throw Error("tolerance must be positive and finite");let H=((F)=>{let _=new M(0);for(let U=0;U<F.rows;U++){let Y=new M(0);for(let V=0;V<F.cols;V++)Y=Y.plus(F.data[U][V].abs());if(Y.greaterThan(_))_=Y}return _})(this),z=0;if(H.greaterThan(new M(1))){let F=H.toNumber();if(!isFinite(F))throw Error("Matrix norm too large for exponential computation");if(z=Math.max(0,Math.ceil(Math.log2(F))),z>50)throw Error(`Matrix norm too large: requires ${z} scaling steps (max 50 allowed)`)}let j=this;if(z>0)j=this.mul(new M(1).div(new M(2).pow(z)));let W=Z.clone(),G=Z.clone();for(let F=1;F<K;F++){W=W.mul(j).mul(new M(1).div(F)),G=G.add(W);let _=new M(0);for(let U=0;U<W.rows;U++)for(let Y=0;Y<W.cols;Y++)_=_.plus(W.data[U][Y].abs());if(_.lessThan(Q))break}for(let F=0;F<z;F++)G=G.mul(G);return G}}var w7={};x7(w7,{translation:()=>i0,stretchAlongAxis:()=>yQ,skew:()=>X$,scale:()=>k7,rotateAroundPoint:()=>U9,rotate:()=>W6,reflectY:()=>gQ,reflectX:()=>uQ,reflectOrigin:()=>xQ,applyTransform:()=>p0});var Q7=($)=>{if($ instanceof M){if(!$.isFinite())throw Error(`Value must be finite (got ${$.toString()})`);return $}try{let J=new M($);if(!J.isFinite())throw Error(`Value must be finite (got ${$})`);return J}catch(J){throw Error(`Invalid numeric value: "${$}" (${J.message})`)}};function $7($,J){if($===void 0||$===null)throw Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof M))throw Error(`${J} must be a number, string, or Decimal`);if(typeof $==="number"&&!isFinite($))throw Error(`${J} must be a finite number (got ${$})`);if($ instanceof M&&!$.isFinite())throw Error(`${J} must be a finite Decimal (got ${$.toString()})`)}function i0($,J){return $7($,"tx"),$7(J,"ty"),z0.from([[new M(1),new M(0),Q7($)],[new M(0),new M(1),Q7(J)],[new M(0),new M(0),new M(1)]])}function k7($,J=null){if($7($,"sx"),J!==null)$7(J,"sy");let Z=J===null?$:J,K=Q7($),Q=Q7(Z);if(K.isZero()||Q.isZero())throw Error("Scale factors cannot be zero (creates singular matrix)");return z0.from([[K,new M(0),new M(0)],[new M(0),Q,new M(0)],[new M(0),new M(0),new M(1)]])}function W6($){$7($,"theta");let Z=Q7($).toNumber(),K=Math.PI,Q=Z-2*K*Math.floor((Z+K)/(2*K));if(!isFinite(Q))throw Error(`Angle normalization failed for theta=${$} (too large or invalid)`);let q=new M(Math.cos(Q)),H=new M(Math.sin(Q));if(!q.isFinite()||!H.isFinite())throw Error(`Trigonometric computation failed for theta=${$} (produced non-finite values)`);return z0.from([[q,H.negated(),new M(0)],[H,q,new M(0)],[new M(0),new M(0),new M(1)]])}function U9($,J,Z){$7($,"theta"),$7(J,"px"),$7(Z,"py");let K=Q7(J),Q=Q7(Z);return i0(K,Q).mul(W6($)).mul(i0(K.negated(),Q.negated()))}function X$($,J){$7($,"ax"),$7(J,"ay");let Z=Q7($),K=Q7(J);if(new M(1).minus(Z.mul(K)).lessThanOrEqualTo(0))throw Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${Z.mul(K).toString()}, must be < 1)`);return z0.from([[new M(1),Z,new M(0)],[K,new M(1),new M(0)],[new M(0),new M(0),new M(1)]])}function yQ($,J,Z){$7($,"ux"),$7(J,"uy"),$7(Z,"k");let K=Q7($),Q=Q7(J),q=Q7(Z);if(q.isZero())throw Error("Stretch factor k cannot be zero (creates singular matrix)");let H=K.mul(K).plus(Q.mul(Q));if(H.isZero())throw Error("Axis vector (ux, uy) cannot be zero");let z=H.minus(1).abs(),j=new M(0.000001);if(z.greaterThan(j))throw 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 W=new M(1),G=q.minus(W),F=W.plus(G.mul(K.mul(K))),_=G.mul(K.mul(Q)),U=G.mul(Q.mul(K)),Y=W.plus(G.mul(Q.mul(Q)));return z0.from([[F,_,new M(0)],[U,Y,new M(0)],[new M(0),new M(0),new M(1)]])}function p0($,J,Z){if(!$||typeof $.mul!=="function")throw 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 Error("applyTransform: matrix must be 3x3");$7(J,"x"),$7(Z,"y");let K=z0.from([[Q7(J)],[Q7(Z)],[new M(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 Error("applyTransform: matrix multiplication produced invalid result");let q=Q.data[0][0],H=Q.data[1][0],z=Q.data[2][0];if(z.isZero())throw Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[q.div(z),H.div(z)]}function uQ(){return z0.from([[new M(1),new M(0),new M(0)],[new M(0),new M(-1),new M(0)],[new M(0),new M(0),new M(1)]])}function gQ(){return z0.from([[new M(-1),new M(0),new M(0)],[new M(0),new M(1),new M(0)],[new M(0),new M(0),new M(1)]])}function xQ(){return z0.from([[new M(-1),new M(0),new M(0)],[new M(0),new M(-1),new M(0)],[new M(0),new M(0),new M(1)]])}var M9={};x7(M9,{translation:()=>V9,scale:()=>mQ,rotateZ:()=>cQ,rotateY:()=>pQ,rotateX:()=>dQ,rotateAroundPoint:()=>nQ,rotateAroundAxis:()=>GJ,reflectYZ:()=>iQ,reflectXZ:()=>oQ,reflectXY:()=>sQ,reflectOrigin:()=>rQ,applyTransform:()=>lQ});var n0=($)=>{if($ instanceof M)return $;try{let J=new M($);if(!J.isFinite())throw Error(`Value must be finite, got ${$}`);return J}catch(J){throw Error(`Invalid numeric value: ${$}`)}};function g0($,J){if($===void 0||$===null)throw Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof M))throw Error(`${J} must be a number, string, or Decimal`)}function k$($){let J=$.toNumber();if(!Number.isFinite(J))throw 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"),z0.from([[new M(1),new M(0),new M(0),n0($)],[new M(0),new M(1),new M(0),n0(J)],[new M(0),new M(0),new M(1),n0(Z)],[new M(0),new M(0),new M(0),new M(1)]])}function mQ($,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=n0($),H=n0(K),z=n0(Q);if(q.isZero()||H.isZero()||z.isZero());return z0.from([[q,new M(0),new M(0),new M(0)],[new M(0),H,new M(0),new M(0)],[new M(0),new M(0),z,new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function dQ($){g0($,"theta");let J=n0($),Z=k$(J),K=new M(Math.cos(Z)),Q=new M(Math.sin(Z));return z0.from([[new M(1),new M(0),new M(0),new M(0)],[new M(0),K,Q.negated(),new M(0)],[new M(0),Q,K,new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function pQ($){g0($,"theta");let J=n0($),Z=k$(J),K=new M(Math.cos(Z)),Q=new M(Math.sin(Z));return z0.from([[K,new M(0),Q,new M(0)],[new M(0),new M(1),new M(0),new M(0)],[Q.negated(),new M(0),K,new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function cQ($){g0($,"theta");let J=n0($),Z=k$(J),K=new M(Math.cos(Z)),Q=new M(Math.sin(Z));return z0.from([[K,Q.negated(),new M(0),new M(0)],[Q,K,new M(0),new M(0)],[new M(0),new M(0),new M(1),new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function GJ($,J,Z,K){g0($,"ux"),g0(J,"uy"),g0(Z,"uz"),g0(K,"theta");let Q=[n0($),n0(J),n0(Z)],q=Q[0].mul(Q[0]).plus(Q[1].mul(Q[1])).plus(Q[2].mul(Q[2])).sqrt();if(q.isZero())throw 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=n0(K),z=k$(H),j=new M(Math.cos(z)),W=new M(Math.sin(z)),G=new M(1),F=Q[0].mul(Q[0]),_=Q[1].mul(Q[1]),U=Q[2].mul(Q[2]),Y=F.plus(j.mul(G.minus(F))),V=Q[0].mul(Q[1]).mul(G.minus(j)).minus(Q[2].mul(W)),O=Q[0].mul(Q[2]).mul(G.minus(j)).plus(Q[1].mul(W)),X=Q[1].mul(Q[0]).mul(G.minus(j)).plus(Q[2].mul(W)),k=_.plus(j.mul(G.minus(_))),w=Q[1].mul(Q[2]).mul(G.minus(j)).minus(Q[0].mul(W)),R=Q[2].mul(Q[0]).mul(G.minus(j)).minus(Q[1].mul(W)),I=Q[2].mul(Q[1]).mul(G.minus(j)).plus(Q[0].mul(W)),C=U.plus(j.mul(G.minus(U)));return z0.from([[Y,V,O,new M(0)],[X,k,w,new M(0)],[R,I,C,new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function nQ($,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 z=n0(Q),j=n0(q),W=n0(H);return V9(z,j,W).mul(GJ($,J,Z,K)).mul(V9(z.negated(),j.negated(),W.negated()))}function lQ($,J,Z,K){if(!($ instanceof z0))throw Error("M must be a Matrix instance");if($.rows!==4||$.cols!==4)throw Error(`M must be a 4x4 matrix, got ${$.rows}x${$.cols}`);g0(J,"x"),g0(Z,"y"),g0(K,"z");let Q=z0.from([[n0(J)],[n0(Z)],[n0(K)],[new M(1)]]),q=$.mul(Q),H=q.data[0][0],z=q.data[1][0],j=q.data[2][0],W=q.data[3][0];if(W.isZero())throw Error("Perspective division by zero: transformation results in point at infinity");return[H.div(W),z.div(W),j.div(W)]}function sQ(){return z0.from([[new M(1),new M(0),new M(0),new M(0)],[new M(0),new M(1),new M(0),new M(0)],[new M(0),new M(0),new M(-1),new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function oQ(){return z0.from([[new M(1),new M(0),new M(0),new M(0)],[new M(0),new M(-1),new M(0),new M(0)],[new M(0),new M(0),new M(1),new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function iQ(){return z0.from([[new M(-1),new M(0),new M(0),new M(0)],[new M(0),new M(1),new M(0),new M(0)],[new M(0),new M(0),new M(1),new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}function rQ(){return z0.from([[new M(-1),new M(0),new M(0),new M(0)],[new M(0),new M(-1),new M(0),new M(0)],[new M(0),new M(0),new M(-1),new M(0)],[new M(0),new M(0),new M(0),new M(1)]])}var K9={};x7(K9,{validateXML:()=>VK,validateSVGAsync:()=>hz,validateSVG:()=>MK,straightCurves:()=>Q8,sortDefsChildren:()=>pZ,sortAttrs:()=>dZ,simplifyPaths:()=>BK,simplifyPath:()=>wK,saveOutput:()=>OZ,reusePaths:()=>cZ,removeXlink:()=>sZ,removeXMLProcInst:()=>IZ,removeXMLNS:()=>TZ,removeViewBox:()=>EZ,removeUselessDefs:()=>RZ,removeUselessCommands:()=>z8,removeUnknownsAndDefaults:()=>wZ,removeTitle:()=>CZ,removeStyleElement:()=>lZ,removeScriptElement:()=>bZ,removeRasterImages:()=>fZ,removeOffCanvasPath:()=>nZ,removeNonInheritableGroupAttrs:()=>LZ,removeMetadata:()=>J9,removeLeadingZero:()=>t9,removeHiddenElements:()=>t$,removeEmptyText:()=>BZ,removeEmptyContainers:()=>e$,removeEmptyAttrs:()=>AZ,removeElementsByAttr:()=>$K,removeEditorsNSData:()=>L8,removeDoctype:()=>NZ,removeDimensions:()=>aZ,removeDesc:()=>PZ,removeComments:()=>$9,removeAttrs:()=>eZ,removeAttributesBySelector:()=>tZ,printHierarchicalMatrix:()=>Az,presetNone:()=>I8,presetDefault:()=>N8,prefixIds:()=>rZ,optimizePaths:()=>RK,optimizeAnimationTiming:()=>LK,optimize:()=>ZK,negativeExtraSpace:()=>e9,moveGroupAttrsToElems:()=>gZ,moveElemsAttrsToGroup:()=>xZ,minifyStyles:()=>B8,mergePaths:()=>uZ,measureDistance:()=>UK,loadInput:()=>H$,lineShorthands:()=>Z8,inlineStyles:()=>mZ,imageToPath:()=>FK,generateOutput:()=>z$,generateFullCompatibilityMatrix:()=>Pz,generateFlexibleSVGTable:()=>OK,generateCompatibilityMatrixSVG_legacy:()=>Ez,generateCompatibilityMatrixSVG:()=>Tz,generateCompatibilityMatrixFlexible:()=>fz,formatPrecision:()=>MZ,floatPrecision:()=>H8,flattenUseElements:()=>GK,flattenPatterns:()=>WK,flattenMasks:()=>qK,flattenGradients:()=>HK,flattenFilters:()=>jK,flattenClipPaths:()=>QK,flattenAll:()=>kK,fixInvalidSVG:()=>YK,exportEmbeddedResources:()=>CK,escapeXml:()=>Oz,embedExternalDependencies:()=>P8,detectOutputTarget:()=>k8,detectInputType:()=>k6,detectCollisions:()=>_K,default:()=>tz,decomposeTransform:()=>NK,createOperation:()=>F0,createConfig:()=>KK,convertTransform:()=>DZ,convertToZ:()=>K8,convertToRelative:()=>$8,convertToAbsolute:()=>J8,convertStyleToAttrs:()=>R8,convertShapesToPath:()=>SZ,convertQuadraticToSmooth:()=>j8,convertPathData:()=>vZ,convertEllipseToCircle:()=>hZ,convertCubicToSmooth:()=>G8,convertCubicToQuadratic:()=>W8,convertColors:()=>Z9,collapseRepeated:()=>q8,collapseGroups:()=>yZ,cleanupNumericValues:()=>a$,cleanupListOfValues:()=>YZ,cleanupIds:()=>w8,cleanupEnableBackground:()=>kZ,cleanupAttributes:()=>XZ,arcShorthands:()=>F8,applyPreset:()=>JK,analyzeCompatibilityMatrix:()=>Cz,analyzeCompatibility:()=>Lz,addClassesToSVGElement:()=>iZ,addAttributesToSVGElement:()=>oZ,ValidationSeverity:()=>A0,PRECISION_LEVELS:()=>VZ,OutputTarget:()=>M7,OutputFormat:()=>O7,MAX_PRECISION:()=>q$,InputType:()=>D0,DEFAULT_PRECISION:()=>o$});M.set({precision:80});var TW=new M("1e-40"),fW=new M("1e-10");M.set({precision:80});var y0=($)=>$ instanceof M?$:new M($),tQ=new M("1e-40"),eQ=new M("1e-30");function $q($,J){if($==null)throw TypeError("translationMatrix: tx parameter is required");if(J==null)throw TypeError("translationMatrix: ty parameter is required");return z0.from([[1,0,y0($)],[0,1,y0(J)],[0,0,1]])}function Jq($){if($==null)throw TypeError("rotationMatrix: angle parameter is required");let J=y0($),Z=M.cos(J),K=M.sin(J);return z0.from([[Z,K.neg(),0],[K,Z,0],[0,0,1]])}function Zq($,J){if($==null)throw TypeError("scaleMatrix: sx parameter is required");if(J==null)throw TypeError("scaleMatrix: sy parameter is required");return z0.from([[y0($),0,0],[0,y0(J),0],[0,0,1]])}function Kq($){if($==null)throw TypeError("skewXMatrix: angle parameter is required");let J=M.tan(y0($));return z0.from([[1,J,0],[0,1,0],[0,0,1]])}function Qq($){if($==null)throw TypeError("skewYMatrix: angle parameter is required");let J=M.tan(y0($));return z0.from([[1,0,0],[J,1,0],[0,0,1]])}function qq($){if(!$)throw TypeError("extractLinearPart: matrix parameter is required");if(!$.data)throw TypeError("extractLinearPart: matrix must have data property");if($.rows<2||$.cols<2)throw 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 Hq($){if(!$)throw TypeError("extractTranslation: matrix parameter is required");if(!$.data)throw TypeError("extractTranslation: matrix must have data property");if($.rows<2||$.cols<3)throw RangeError("extractTranslation: matrix must be at least 2x3");let J=$.data;return{tx:J[0][2],ty:J[1][2]}}function FJ($){if(!$)throw TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:K,d:Q}=qq($),{tx:q,ty:H}=Hq($),z=J.mul(Q).minus(Z.mul(K)),j=J.mul(J).plus(Z.mul(Z)).sqrt();if(j.abs().lessThan(tQ))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 W=z.div(j);if(W.abs().greaterThan(new M("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(z.lessThan(0))j=j.neg(),W=W.neg();let G=M.atan2(Z,J),F=M.cos(G),_=M.sin(G),U=J.mul(F).plus(Z.mul(_)),Y=K.mul(F).plus(Q.mul(_)),V,O=new M("1e-30");if(U.abs().greaterThan(O)){let I=Y.div(U);if(I.abs().greaterThan(new M("1e10")))V=y0(0);else V=M.atan(I)}else V=y0(0);let X=y0(0),k=zq({translateX:q,translateY:H,rotation:G,scaleX:j,scaleY:W,skewX:V,skewY:y0(0)}),w=Wq($,k),R=w.lessThan(eQ);return{translateX:q,translateY:H,rotation:G,scaleX:j,scaleY:W,skewX:V,skewY:X,verified:R,maxError:w}}function zq($){if(!$)throw TypeError("composeTransform: components parameter is required");if($.translateX==null)throw TypeError("composeTransform: components.translateX is required");if($.translateY==null)throw TypeError("composeTransform: components.translateY is required");if($.rotation==null)throw TypeError("composeTransform: components.rotation is required");if($.scaleX==null)throw TypeError("composeTransform: components.scaleX is required");if($.scaleY==null)throw TypeError("composeTransform: components.scaleY is required");if($.skewX==null)throw TypeError("composeTransform: components.skewX is required");let{translateX:J,translateY:Z,rotation:K,scaleX:Q,scaleY:q,skewX:H,skewY:z=0}=$,j=$q(J,Z),W=Jq(K),G=Kq(H),F=Qq(z),_=Zq(Q,q);return j.mul(W).mul(F).mul(G).mul(_)}function Wq($,J){if(!$)throw TypeError("matrixMaxDifference: m1 parameter is required");if(!J)throw TypeError("matrixMaxDifference: m2 parameter is required");if(!$.data)throw TypeError("matrixMaxDifference: m1 must have data property");if(!J.data)throw TypeError("matrixMaxDifference: m2 must have data property");if($.rows!==J.rows||$.cols!==J.cols)throw 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}M.set({precision:80});var _7=($)=>$ instanceof M?$:new M($),m0=new M("1e-40"),_J=100;function b7($,J){if($==null)throw TypeError("point: x coordinate cannot be null or undefined");if(J==null)throw TypeError("point: y coordinate cannot be null or undefined");return{x:_7($),y:_7(J)}}function Gq($,J){if(!$||$.x==null||$.y==null)throw TypeError("vectorAdd: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw 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 TypeError("vectorSub: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("vectorSub: second vector must have x and y properties");return{x:$.x.minus(J.x),y:$.y.minus(J.y)}}function m6($){if(!$||$.x==null||$.y==null)throw TypeError("vectorNeg: vector must have x and y properties");return{x:$.x.neg(),y:$.y.neg()}}function Y9($,J){if(!$||$.x==null||$.y==null)throw TypeError("vectorScale: vector must have x and y properties");if(J==null)throw TypeError("vectorScale: scale factor cannot be null or undefined");let Z=_7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function q7($,J){if(!$||$.x==null||$.y==null)throw TypeError("dot: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("dot: second vector must have x and y properties");return $.x.mul(J.x).plus($.y.mul(J.y))}function x6($,J){if(!$||$.x==null||$.y==null)throw TypeError("cross: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("cross: second vector must have x and y properties");return $.x.mul(J.y).minus($.y.mul(J.x))}function F7($){if(!$||$.x==null||$.y==null)throw TypeError("magnitudeSquared: vector must have x and y properties");return $.x.mul($.x).plus($.y.mul($.y))}function j6($){if(!$||$.x==null||$.y==null)throw TypeError("magnitude: vector must have x and y properties");return F7($).sqrt()}function Fq($){if(!$||$.x==null||$.y==null)throw TypeError("normalize: vector must have x and y properties");let J=j6($);if(J.lessThan(m0))return{x:_7(0),y:_7(0)};return{x:$.x.div(J),y:$.y.div(J)}}function $6($,J,Z){if(!$||$.x==null||$.y==null)throw TypeError("tripleProduct: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("tripleProduct: second vector must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw TypeError("tripleProduct: third vector must have x and y properties");let K=q7($,Z),Q=q7(J,Z);return d0(Y9(J,K),Y9($,Q))}function UJ($,J){if(!Array.isArray($))throw TypeError("supportPoint: polygon must be an array");if(!J||J.x==null||J.y==null)throw TypeError("supportPoint: direction must have x and y properties");if($.length===0)throw TypeError("supportPoint: polygon cannot be empty");if(!$[0]||$[0].x==null||$[0].y==null)throw TypeError("supportPoint: polygon[0] must have x and y properties");let Z=q7($[0],J),K=$[0];for(let Q=1;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw TypeError(`supportPoint: polygon[${Q}] must have x and y properties`);let q=q7($[Q],J);if(q.greaterThan(Z))Z=q,K=$[Q]}return K}function VJ($,J,Z){if(!Array.isArray($))throw TypeError("minkowskiSupport: polygonA must be an array");if(!Array.isArray(J))throw TypeError("minkowskiSupport: polygonB must be an array");if(!Z||Z.x==null||Z.y==null)throw TypeError("minkowskiSupport: direction must have x and y properties");let K=UJ($,Z),Q=UJ(J,m6(Z));return d0(K,Q)}function _q($,J){if(!Array.isArray($))throw TypeError("processLineSimplex: simplex must be an array");if($.length!==2)throw TypeError("processLineSimplex: simplex must have exactly 2 points");if(!J||J.x==null||J.y==null)throw TypeError("processLineSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw TypeError("processLineSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw TypeError("processLineSimplex: simplex[1] must have x and y properties");let Z=$[0],K=$[1],Q=d0(K,Z),q=m6(Z),H=F7(Q);if(H.lessThan(m0)){if(F7(Z).lessThan(m0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}let z=$6(Q,q,Q);if(F7(z).lessThan(m0)){let j=q7(Q,q);if(j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(H))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}return{contains:!1,newDirection:z}}function Uq($,J){if(!Array.isArray($))throw TypeError("processTriangleSimplex: simplex must be an array");if($.length!==3)throw TypeError("processTriangleSimplex: simplex must have exactly 3 points");if(!J||J.x==null||J.y==null)throw TypeError("processTriangleSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw TypeError("processTriangleSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw TypeError("processTriangleSimplex: simplex[1] must have x and y properties");if(!$[2]||$[2].x==null||$[2].y==null)throw 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),z=m6(Z),j=F7(q),W=F7(H);if(j.lessThan(m0))return{contains:!1,newDirection:$6(H,z,H),newSimplex:[Z,Q]};if(W.lessThan(m0))return{contains:!1,newDirection:$6(q,z,q),newSimplex:[Z,K]};let G=$6(H,q,q),F=$6(q,H,H);if(F7(G).lessThan(m0)&&F7(F).lessThan(m0)){let _=d0(Q,K),U=F7(_);if(U.greaterThan(j)&&U.greaterThan(W))return{contains:!1,newDirection:$6(_,m6(K),_),newSimplex:[K,Q]};else if(j.greaterThan(W))return{contains:!1,newDirection:$6(q,z,q),newSimplex:[Z,K]};else return{contains:!1,newDirection:$6(H,z,H),newSimplex:[Z,Q]}}if(q7(G,z).greaterThan(m0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(q7(F,z).greaterThan(m0))return{contains:!1,newDirection:F,newSimplex:[Z,Q]};return{contains:!0,newDirection:J,newSimplex:$}}function YJ($,J){if(!Array.isArray($))throw TypeError("gjkIntersects: polygonA must be an array");if(!Array.isArray(J))throw 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 TypeError("gjkIntersects: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw TypeError("gjkIntersects: polygonB[0] must have x and y properties");return{intersects:j6(d0($[0],J[0])).lessThan(m0),iterations:1,simplex:[],verified:!0}}let Z=d0(w$(J),w$($));if(F7(Z).lessThan(m0))Z=b7(1,0);let K=[VJ($,J,Z)];if(Z=m6(K[0]),F7(K[0]).lessThan(m0))return{intersects:!0,iterations:1,simplex:K,verified:O9($,J)};for(let Q=0;Q<_J;Q++){let q=VJ($,J,Z);if(q7(q,Z).lessThanOrEqualTo(_7(0)))return{intersects:!1,iterations:Q+1,simplex:K,verified:!0};if(K.unshift(q),K.length===2){let H=_q(K,Z);if(H.contains)return{intersects:!0,iterations:Q+1,simplex:K,verified:O9($,J)};Z=H.newDirection}else if(K.length===3){let H=Uq(K,Z);if(H.contains)return{intersects:!0,iterations:Q+1,simplex:H.newSimplex,verified:O9($,J)};K=H.newSimplex,Z=H.newDirection}if(F7(Z).lessThan(m0))return{intersects:!1,iterations:Q+1,simplex:K,verified:!1};Z=Fq(Z)}return{intersects:!1,iterations:_J,simplex:K,verified:!1}}function w$($){if(!Array.isArray($))throw TypeError("centroid: polygon must be an array");if($.length===0)throw TypeError("centroid: polygon cannot be empty");let J=_7(0),Z=_7(0);for(let Q=0;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw TypeError(`centroid: polygon[${Q}] must have x and y properties`);J=J.plus($[Q].x),Z=Z.plus($[Q].y)}let K=_7($.length);return{x:J.div(K),y:Z.div(K)}}function MJ($,J){if(!$||$.x==null||$.y==null)throw TypeError("pointInConvexPolygon: point must have x and y properties");if(!Array.isArray(J))throw 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 TypeError(`pointInConvexPolygon: polygon[${K}] must have x and y properties`);if(!q||q.x==null||q.y==null)throw TypeError(`pointInConvexPolygon: polygon[${(K+1)%J.length}] must have x and y properties`);let H=d0(q,Q),z=d0($,Q),j=x6(H,z);if(j.abs().lessThan(m0))continue;let W=j.greaterThan(0);if(Z===null)Z=W;else if(Z!==W)return!1}return!0}function O9($,J){if(!Array.isArray($))throw TypeError("verifyIntersection: polygonA must be an array");if(!Array.isArray(J))throw TypeError("verifyIntersection: polygonB must be an array");for(let Z=0;Z<$.length;Z++){if(!$[Z]||$[Z].x==null||$[Z].y==null)throw TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(MJ($[Z],J))return!0}for(let Z=0;Z<J.length;Z++){if(!J[Z]||J[Z].x==null||J[Z].y==null)throw TypeError(`verifyIntersection: polygonB[${Z}] must have x and y properties`);if(MJ(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 TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(!Q||Q.x==null||Q.y==null)throw TypeError(`verifyIntersection: polygonA[${(Z+1)%$.length}] must have x and y properties`);for(let q=0;q<J.length;q++){let H=J[q],z=J[(q+1)%J.length];if(!H||H.x==null||H.y==null)throw TypeError(`verifyIntersection: polygonB[${q}] must have x and y properties`);if(!z||z.x==null||z.y==null)throw TypeError(`verifyIntersection: polygonB[${(q+1)%J.length}] must have x and y properties`);if(Vq(K,Q,H,z))return!0}}return!1}function Vq($,J,Z,K){if(!$||$.x==null||$.y==null)throw TypeError("segmentsIntersect: a1 must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("segmentsIntersect: a2 must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw TypeError("segmentsIntersect: b1 must have x and y properties");if(!K||K.x==null||K.y==null)throw TypeError("segmentsIntersect: b2 must have x and y properties");let Q=d0(J,$),q=d0(K,Z),H=x6(Q,q);if(H.abs().lessThan(m0)){let G=d0(Z,$);if(x6(Q,G).abs().lessThan(m0)){let F=q7(Q,Q);if(F.lessThan(m0)){let X=q7(q,q);if(X.lessThan(m0))return j6(G).lessThan(m0);let k=q7(G,q).div(X);return k.greaterThanOrEqualTo(0)&&k.lessThanOrEqualTo(1)}let _=q7(G,Q).div(F),U=d0(K,$),Y=q7(U,Q).div(F),V=M.min(_,Y);return M.max(_,Y).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let z=d0(Z,$),j=x6(z,q).div(H),W=x6(z,Q).div(H);return j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)&&W.greaterThanOrEqualTo(0)&&W.lessThanOrEqualTo(1)}function Mq($,J){if(!Array.isArray($))throw TypeError("gjkDistance: polygonA must be an array");if(!Array.isArray(J))throw TypeError("gjkDistance: polygonB must be an array");if($.length===0)throw TypeError("gjkDistance: polygonA cannot be empty");if(J.length===0)throw TypeError("gjkDistance: polygonB cannot be empty");if(YJ($,J).intersects)return{distance:_7(0),closestA:w$($),closestB:w$(J),verified:!0};if(!$[0]||$[0].x==null||$[0].y==null)throw TypeError("gjkDistance: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw TypeError("gjkDistance: polygonB[0] must have x and y properties");let K=_7(1/0),Q=$[0],q=J[0];for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);for(let W=0;W<J.length;W++){if(!J[W]||J[W].x==null||J[W].y==null)throw TypeError(`gjkDistance: polygonB[${W}] must have x and y properties`);let G=j6(d0($[j],J[W]));if(G.lessThan(K))K=G,Q=$[j],q=J[W]}}for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);for(let W=0;W<J.length;W++){let G=J[W],F=J[(W+1)%J.length];if(!G||G.x==null||G.y==null)throw TypeError(`gjkDistance: polygonB[${W}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw TypeError(`gjkDistance: polygonB[${(W+1)%J.length}] must have x and y properties`);let _=OJ($[j],G,F),U=j6(d0($[j],_));if(U.lessThan(K))K=U,Q=$[j],q=_}}for(let j=0;j<J.length;j++){if(!J[j]||J[j].x==null||J[j].y==null)throw TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);for(let W=0;W<$.length;W++){let G=$[W],F=$[(W+1)%$.length];if(!G||G.x==null||G.y==null)throw TypeError(`gjkDistance: polygonA[${W}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw TypeError(`gjkDistance: polygonA[${(W+1)%$.length}] must have x and y properties`);let _=OJ(J[j],G,F),U=j6(d0(J[j],_));if(U.lessThan(K))K=U,Q=_,q=J[j]}}let z=j6(d0(Q,q)).minus(K).abs().lessThan(m0);return{distance:K,closestA:Q,closestB:q,verified:z}}function OJ($,J,Z){if(!$||$.x==null||$.y==null)throw TypeError("closestPointOnSegment: pt must have x and y properties");if(!J||J.x==null||J.y==null)throw TypeError("closestPointOnSegment: a must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw TypeError("closestPointOnSegment: b must have x and y properties");let K=d0(Z,J),Q=d0($,J),q=F7(K);if(q.lessThan(m0))return J;let H=q7(Q,K).div(q);return H=M.max(_7(0),M.min(_7(1),H)),Gq(J,Y9(K,H))}function L$($,J){if(!Array.isArray($))throw TypeError("polygonsOverlap: polygonA must be an array");if(!Array.isArray(J))throw TypeError("polygonsOverlap: polygonB must be an array");let Z=$.map((q,H)=>{if(!q||q.x==null||q.y==null)throw TypeError(`polygonsOverlap: polygonA[${H}] must have x and y properties`);return b7(q.x,q.y)}),K=J.map((q,H)=>{if(!q||q.x==null||q.y==null)throw TypeError(`polygonsOverlap: polygonB[${H}] must have x and y properties`);return b7(q.x,q.y)}),Q=YJ(Z,K);return{overlaps:Q.intersects,verified:Q.verified}}function XJ($,J){if(!Array.isArray($))throw TypeError("polygonsDistance: polygonA must be an array");if(!Array.isArray(J))throw TypeError("polygonsDistance: polygonB must be an array");let Z=$.map((q,H)=>{if(!q||q.x==null||q.y==null)throw TypeError(`polygonsDistance: polygonA[${H}] must have x and y properties`);return b7(q.x,q.y)}),K=J.map((q,H)=>{if(!q||q.x==null||q.y==null)throw TypeError(`polygonsDistance: polygonB[${H}] must have x and y properties`);return b7(q.x,q.y)}),Q=Mq(Z,K);return{distance:Q.distance,closestA:Q.closestA,closestB:Q.closestB,verified:Q.verified}}M.set({precision:80});var hW=new M("1e-40"),yW=new M("1e-10");M.set({precision:80});var xW=new M("1e-40"),mW=new M("1e-30");M.set({precision:80});var j0=($)=>$ instanceof M?$:new M($),cW=new M("1e-40"),kq=new M("1e-10");function RJ($){if(typeof $!=="string")throw Error("ViewBox must be a string");let J=$.trim().split(/[\s,]+/).filter((Z)=>Z.length>0);if(J.length!==4)throw 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 Error("ViewBox width and height must be positive");let H=`${Z.toString()} ${K.toString()} ${Q.toString()} ${q.toString()}`,z=J.join(" ");return{x:Z,y:K,width:Q,height:q,verified:H===z}}catch(Z){throw Error(`Invalid viewBox values: ${Z.message}`)}}function wq($,J,Z,K){if($==null||J==null||Z==null||K==null)throw Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let Q=j0($),q=j0(J),H=j0(Z),z=j0(K);if(H.lessThan(Q))throw Error(`createBBox: maxX (${H}) must be >= minX (${Q})`);if(z.lessThan(q))throw Error(`createBBox: maxY (${z}) must be >= minY (${q})`);return{minX:Q,minY:q,maxX:H,maxY:z,width:H.minus(Q),height:z.minus(q)}}function kJ($,J,Z,K,Q,q,H,z,j=20){if($==null||J==null||Z==null||K==null||Q==null||q==null||H==null||z==null)throw Error("sampleCubicBezier: all coordinate parameters must be provided");if(j==null||j<=0)throw Error("sampleCubicBezier: samples must be a positive number");let W=[];for(let G=0;G<=j;G++){let F=j0(G).div(j),_=j0(1).minus(F),U=F.mul(F),Y=U.mul(F),V=_.mul(_),O=V.mul(_),X=O.mul($).plus(j0(3).mul(V).mul(F).mul(Z)).plus(j0(3).mul(_).mul(U).mul(Q)).plus(Y.mul(H)),k=O.mul(J).plus(j0(3).mul(V).mul(F).mul(K)).plus(j0(3).mul(_).mul(U).mul(q)).plus(Y.mul(z));W.push({x:X,y:k})}return W}function wJ($,J,Z,K,Q,q,H=20){if($==null||J==null||Z==null||K==null||Q==null||q==null)throw Error("sampleQuadraticBezier: all coordinate parameters must be provided");if(H==null||H<=0)throw Error("sampleQuadraticBezier: samples must be a positive number");let z=[];for(let j=0;j<=H;j++){let W=j0(j).div(H),G=j0(1).minus(W),F=G.mul(G),_=W.mul(W),U=F.mul($).plus(j0(2).mul(G).mul(W).mul(Z)).plus(_.mul(Q)),Y=F.mul(J).plus(j0(2).mul(G).mul(W).mul(K)).plus(_.mul(q));z.push({x:U,y:Y})}return z}function Lq($,J,Z=kq){if(!$||typeof $!=="object"||$.x==null||$.y==null)throw Error("pointInBBox: pt must be an object with x and y properties");if(!J||typeof J!=="object")throw Error("pointInBBox: bbox must be a bounding box object");if(J.minX==null||J.minY==null||J.maxX==null||J.maxY==null)throw 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 BJ($){if(!$||$.length===0)throw 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),z=j0(0),j=j0(0),W=j0(0),G=j0(0),F=null,_=[];for(let V of $){if(!V||typeof V!=="object"||!V.type||typeof V.type!=="string")throw Error("pathBoundingBox: each command must be an object with a string type property");let O=V.type.toUpperCase(),X=V.type===V.type.toLowerCase();switch(O){case"M":{if(V.x==null||V.y==null)throw 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,z=q,j=H,J=M.min(J,q),Z=M.min(Z,H),K=M.max(K,q),Q=M.max(Q,H),_.push({x:q,y:H}),W=q,G=H,F="M"}break;case"L":{if(V.x==null||V.y==null)throw 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=M.min(J,k),Z=M.min(Z,w),K=M.max(K,k),Q=M.max(Q,w),_.push({x:k,y:w}),q=k,H=w,W=q,G=H,F="L"}break;case"H":{if(V.x==null)throw Error("pathBoundingBox: H command requires x property");let k=X?q.plus(j0(V.x)):j0(V.x);J=M.min(J,k),K=M.max(K,k),_.push({x:k,y:H}),q=k,W=q,G=H,F="H"}break;case"V":{if(V.y==null)throw Error("pathBoundingBox: V command requires y property");let k=X?H.plus(j0(V.y)):j0(V.y);Z=M.min(Z,k),Q=M.max(Q,k),_.push({x:q,y:k}),H=k,W=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 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),C=X?q.plus(j0(V.x)):j0(V.x),v=X?H.plus(j0(V.y)):j0(V.y),g=kJ(q,H,k,w,R,I,C,v,20);for(let T of g)J=M.min(J,T.x),Z=M.min(Z,T.y),K=M.max(K,T.x),Q=M.max(Q,T.y),_.push(T);W=R,G=I,q=C,H=v,F="C"}break;case"S":{if(V.x2==null||V.y2==null||V.x==null||V.y==null)throw 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),C,v;if(F==="C"||F==="S")C=q.mul(2).minus(W),v=H.mul(2).minus(G);else C=q,v=H;let g=kJ(q,H,C,v,k,w,R,I,20);for(let T of g)J=M.min(J,T.x),Z=M.min(Z,T.y),K=M.max(K,T.x),Q=M.max(Q,T.y),_.push(T);W=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 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),C=wJ(q,H,k,w,R,I,20);for(let v of C)J=M.min(J,v.x),Z=M.min(Z,v.y),K=M.max(K,v.x),Q=M.max(Q,v.y),_.push(v);W=k,G=w,q=R,H=I,F="Q"}break;case"T":{if(V.x==null||V.y==null)throw 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(W),I=H.mul(2).minus(G);else R=q,I=H;let C=wJ(q,H,R,I,k,w,20);for(let v of C)J=M.min(J,v.x),Z=M.min(Z,v.y),K=M.max(K,v.x),Q=M.max(Q,v.y),_.push(v);W=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 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=M.min(J,q,k),Z=M.min(Z,H,w),K=M.max(K,q,k),Q=M.max(Q,H,w),_.push({x:q,y:H},{x:k,y:w});else{J=M.min(J,q,k),Z=M.min(Z,H,w),K=M.max(K,q,k),Q=M.max(Q,H,w);let C=q.plus(k).div(2),v=H.plus(w).div(2);J=M.min(J,C.minus(R)),Z=M.min(Z,v.minus(I)),K=M.max(K,C.plus(R)),Q=M.max(Q,v.plus(I));let g=20;for(let T=0;T<=g;T++){let u=j0(T).div(g),S=q.plus(k.minus(q).mul(u)),A=H.plus(w.minus(H).mul(u));_.push({x:S,y:A})}}q=k,H=w,W=q,G=H,F="A"}break;case"Z":q=z,H=j,W=q,G=H,F="Z";break;default:throw Error(`pathBoundingBox: unknown path command type: ${O}`)}}if(!J.isFinite()||!Z.isFinite()||!K.isFinite()||!Q.isFinite())throw Error("Invalid bounding box: no valid coordinates found");let U=wq(J,Z,K,Q),Y=!0;for(let V of _)if(!Lq(V,U)){Y=!1;break}return{...U,verified:Y}}function LJ($){if(!$||typeof $!=="object")throw Error("bboxToPolygon: bbox must be a bounding box object");if($.minX==null||$.minY==null||$.maxX==null||$.maxY==null)throw Error("bboxToPolygon: bbox must have minX, minY, maxX, maxY properties");return[b7($.minX,$.minY),b7($.maxX,$.minY),b7($.maxX,$.maxY),b7($.minX,$.maxY)]}function NJ($,J){if(!J||typeof J!=="object")throw Error("bboxIntersectsViewBox: viewBox must be an object");if(J.x==null||J.y==null||J.width==null||J.height==null)throw Error("bboxIntersectsViewBox: viewBox must have x, y, width, height properties");let Z=LJ($),K=LJ({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),Q=L$(Z,K);return{intersects:Q.overlaps,verified:Q.verified}}var J7={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function Bq($){if(typeof $!=="string"||!$.trim())throw Error("Selector must be a non-empty string");let J=$.trim(),Z=[],K=Nq(J);for(let Q of K){if(!Q.trim())continue;let q=Iq(Q.trim());Z.push(...q)}return Z}function Nq($){if(typeof $!=="string")throw Error("Selector must be a string");let J=[],Z="",K=0,Q=0,q=!1,H=null;for(let j=0;j<$.length;j++){let W=$[j],G=j>0?$[j-1]:null;if((W==='"'||W==="'")&&G!=="\\"){if(!q)q=!0,H=W;else if(W===H)q=!1,H=null}if(!q){if(W==="["&&G!=="\\")K++;else if(W==="]"&&G!=="\\"){if(K--,K<0)throw Error(`Unbalanced brackets at position ${j}`)}else if(W==="("&&G!=="\\")Q++;else if(W===")"&&G!=="\\"){if(Q--,Q<0)throw Error(`Unbalanced parentheses at position ${j}`)}}if(!q&&K===0&&Q===0){if(W===">"||W==="+"||W==="~"){let F=Z.trim();if(F)J.push(F);Z="";continue}else if(W===" "){let F=Z.trim();if(F){J.push(F),Z="";continue}else continue}}Z+=W}if(q)throw Error("Unclosed quote in selector");if(K!==0)throw Error("Unclosed brackets in selector");if(Q!==0)throw Error("Unclosed parentheses in selector");let z=Z.trim();if(z)J.push(z);return J}function Iq($){if(typeof $!=="string")throw 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 Error(`Invalid ID selector at position ${Z}`);J.push({type:J7.ID,value:Q[1]}),Z+=Q[0].length}else if(K==="."){let Q=$.slice(Z).match(/^\.([a-zA-Z_-][\w-]*)/);if(!Q)throw Error(`Invalid class selector at position ${Z}`);J.push({type:J7.CLASS,value:Q[1]}),Z+=Q[0].length}else if(K==="["){let Q=Cq($,Z);if(Q===-1)throw Error(`Unclosed attribute selector at position ${Z}`);let q=$.slice(Z+1,Q);J.push({type:J7.ATTRIBUTE,value:q}),Z=Q+1}else if(K===":")if(Z+1<$.length&&$[Z+1]===":"){let Q=$.slice(Z).match(/^::([\w-]+)/);if(!Q)throw Error(`Invalid pseudo-element at position ${Z}`);J.push({type:J7.PSEUDO_ELEMENT,value:Q[1]}),Z+=Q[0].length}else{let Q=$.slice(Z).match(/^:([\w-]+)/);if(!Q)throw Error(`Invalid pseudo-class at position ${Z}`);let q=Q[1];if(Z+=Q[0].length,Z<$.length&&$[Z]==="("){let j=Pq($,Z);if(j===-1)throw Error(`Unclosed pseudo-class function at position ${Z}`);q+=$.slice(Z,j+1),Z=j+1}let z=["before","after","first-line","first-letter"].includes(q);J.push({type:z?J7.PSEUDO_ELEMENT:J7.PSEUDO_CLASS,value:q})}else if(K==="*"){let Q=Z+1;if(Q<$.length&&$[Q]==="|"){if(Q++,Q<$.length&&$[Q]==="*")Q++}J.push({type:J7.UNIVERSAL,value:"*"}),Z=Q}else if(/[a-zA-Z]/.test(K)){let Q=$.slice(Z).match(/^([a-zA-Z][\w-]*)/);if(!Q)throw Error(`Invalid type selector at position ${Z}`);let q=Q[1],H=Z+Q[0].length;if(H<$.length&&$[H]==="|"){H++;let z=$.slice(H).match(/^([a-zA-Z*][\w-]*)/);if(z)q=z[1],H+=z[0].length}J.push({type:J7.TYPE,value:q}),Z=H}else if(K===">"||K==="+"||K==="~"||K===" ")Z++;else throw Error(`Unexpected character '${K}' at position ${Z}`)}return J}function Cq($,J){if(typeof $!=="string")throw Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw 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],z=q>0?$[q-1]:null;if((H==='"'||H==="'")&&z!=="\\"){if(!K)K=!0,Q=H;else if(H===Q)K=!1,Q=null}if(!K){if(H==="["&&z!=="\\")Z++;if(H==="]"&&z!=="\\"){if(Z--,Z===0)return q}}}return-1}function Pq($,J){if(typeof $!=="string")throw Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw 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],z=q>0?$[q-1]:null;if((H==='"'||H==="'")&&z!=="\\"){if(!K)K=!0,Q=H;else if(H===Q)K=!1,Q=null}if(!K){if(H==="("&&z!=="\\")Z++;if(H===")"&&z!=="\\"){if(Z--,Z===0)return q}}}return-1}function R$($){let J=typeof $==="string"?Bq($):$;if(!Array.isArray(J))throw 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 Error("Invalid component: must have a 'type' property");switch(q.type){case J7.ID:Z++;break;case J7.CLASS:case J7.ATTRIBUTE:K++;break;case J7.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 z=H.match(/^(\w+)\(/)[1],j=H.slice(z.length+1,-1);if(j.trim()){let W=Aq(j),G=[0,0,0];for(let F of W)if(F.trim()){let _=R$(F.trim());if(B$(_,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 z=H.match(/^([\w-]+)\(/)[1],W=H.slice(z.length+1,-1).match(/\s+of\s+(.+)$/);if(W){let G=W[1].trim(),F=R$(G);Z+=F[0],K+=F[1],Q+=F[2]}K++;break}K++;break}case J7.TYPE:case J7.PSEUDO_ELEMENT:Q++;break;case J7.UNIVERSAL:break;default:break}}return[Z,K,Q]}function Aq($){if(typeof $!=="string")throw Error("selectorList 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],W=z>0?$[z-1]:null;if((j==='"'||j==="'")&&W!=="\\"){if(!q)q=!0,H=j;else if(j===H)q=!1,H=null}if(!q){if(j==="(")K++;if(j===")")K--;if(j==="[")Q++;if(j==="]")Q--;if(j===","&&K===0&&Q===0){J.push(Z),Z="";continue}}Z+=j}if(Z)J.push(Z);return J}function B$($,J){if(!Array.isArray($)||$.length!==3)throw Error("spec1 must be an array of 3 numbers");if(!Array.isArray(J)||J.length!==3)throw 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 Error(`spec1[${Z}] must be a non-negative finite number`);if(typeof J[Z]!=="number"||!Number.isFinite(J[Z])||J[Z]<0)throw 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 c6={};x7(c6,{transformPathData:()=>bq,transformArcParams:()=>PJ,rectToPathData:()=>A$,polylineToPathData:()=>d6,polygonToPathData:()=>T$,pathToCubics:()=>Sq,pathToAbsolute:()=>p6,pathArrayToString:()=>N6,parsePathData:()=>J6,lineToPathData:()=>E$,getKappaForArc:()=>CJ,getKappa:()=>N$,ellipseToPathDataHP:()=>I$,ellipseToPathData:()=>P$,convertElementToPath:()=>k9,circleToPathDataHP:()=>X9,circleToPathData:()=>C$});var b0=($)=>$ instanceof M?$:new M($);function N$(){let $=new M(2),J=new M(3);return new M(4).mul($.sqrt().minus(1)).div(J)}function CJ($){if($==null)throw Error("getKappaForArc: thetaRadians parameter is required");let J=b0($);if(!J.isFinite())throw Error("getKappaForArc: thetaRadians must be finite");if(J.isZero()||J.isNegative())throw Error("getKappaForArc: thetaRadians must be positive");let Z=new M(4),K=new M(3);return Z.div(K).mul(M.tan(J.div(Z)))}function X9($,J,Z,K=8,Q=6){if($==null||J==null||Z==null)throw Error("circleToPathDataHP: cx, cy, and r parameters are required");let q=b0(Z);if(!q.isFinite()||q.isNegative())throw Error("circleToPathDataHP: radius must be finite and non-negative");if(q.isZero())return"";if(!Number.isFinite(K)||K<=0)throw Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(Q)||Q<0)throw Error("circleToPathDataHP: precision must be non-negative");return I$($,J,Z,Z,K,Q)}function I$($,J,Z,K,Q=8,q=6){if($==null||J==null||Z==null||K==null)throw Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<=0)throw Error("ellipseToPathDataHP: arcs must be a positive number");if(!Number.isFinite(q)||q<0)throw Error("ellipseToPathDataHP: precision must be non-negative");let H=Q;if(H%4!==0)H=Math.ceil(H/4)*4;let z=b0($),j=b0(J),W=b0(Z),G=b0(K);if(!W.isFinite()||W.isNegative())throw Error("ellipseToPathDataHP: rx must be finite and non-negative");if(!G.isFinite()||G.isNegative())throw Error("ellipseToPathDataHP: ry must be finite and non-negative");if(W.isZero()||G.isZero())return"";let F=(X)=>G6(X,q),Y=M.acos(-1).mul(2).div(H),V=CJ(Y),O=[];for(let X=0;X<H;X++){let k=Y.mul(X),w=Y.mul(X+1),R=M.cos(k),I=M.sin(k),C=M.cos(w),v=M.sin(w),g=z.plus(W.mul(R)),T=j.plus(G.mul(I)),u=z.plus(W.mul(C)),S=j.plus(G.mul(v)),A=I.neg(),y=R,p=v.neg(),m=C,B=g.plus(V.mul(W).mul(A)),h=T.plus(V.mul(G).mul(y)),N=u.minus(V.mul(W).mul(p)),n=S.minus(V.mul(G).mul(m));if(X===0)O.push(`M${F(g)} ${F(T)}`);O.push(`C${F(B)} ${F(h)} ${F(N)} ${F(n)} ${F(u)} ${F(S)}`)}return O.push("Z"),O.join(" ")}function G6($,J=6){if($==null)throw Error("formatNumber: value parameter is required");if(!Number.isFinite(J)||J<0)throw Error("formatNumber: precision must be non-negative");let Z=b0($);if(!Z.isFinite())throw Error("formatNumber: value must be finite");let K=Z.toFixed(J);if(K.includes("."))K=K.replace(/\.?0+$/,"");return K}function C$($,J,Z,K=6){if($==null||J==null||Z==null)throw Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(K)||K<0)throw Error("circleToPathData: precision must be non-negative");let Q=b0($),q=b0(J),H=b0(Z);if(!H.isFinite()||H.isNegative())throw Error("circleToPathData: radius must be finite and non-negative");if(H.isZero())return"";let z=N$().mul(H),j=Q.plus(H),W=q,G=j,F=W.minus(z),_=Q.plus(z),U=q.minus(H),Y=Q,V=q.minus(H),O=Q.minus(z),X=V,k=Q.minus(H),w=q.minus(z),R=Q.minus(H),I=q,C=R,v=q.plus(z),g=Q.minus(z),T=q.plus(H),u=Q,S=q.plus(H),A=Q.plus(z),y=S,p=j,m=q.plus(z),B=(h)=>G6(h,K);return`M${B(j)} ${B(W)}C${B(G)} ${B(F)} ${B(_)} ${B(U)} ${B(Y)} ${B(V)}C${B(O)} ${B(X)} ${B(k)} ${B(w)} ${B(R)} ${B(I)}C${B(C)} ${B(v)} ${B(g)} ${B(T)} ${B(u)} ${B(S)}C${B(A)} ${B(y)} ${B(p)} ${B(m)} ${B(j)} ${B(W)}Z`}function P$($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<0)throw Error("ellipseToPathData: precision must be non-negative");let q=b0($),H=b0(J),z=b0(Z),j=b0(K);if(!z.isFinite()||z.isNegative())throw Error("ellipseToPathData: rx must be finite and non-negative");if(!j.isFinite()||j.isNegative())throw Error("ellipseToPathData: ry must be finite and non-negative");if(z.isZero()||j.isZero())return"";let W=N$(),G=W.mul(z),F=W.mul(j),_=q.plus(z),U=H,Y=_,V=U.minus(F),O=q.plus(G),X=H.minus(j),k=q,w=H.minus(j),R=q.minus(G),I=w,C=q.minus(z),v=H.minus(F),g=q.minus(z),T=H,u=g,S=H.plus(F),A=q.minus(G),y=H.plus(j),p=q,m=H.plus(j),B=q.plus(G),h=m,N=_,n=H.plus(F),o=(s)=>G6(s,Q);return`M${o(_)} ${o(U)}C${o(Y)} ${o(V)} ${o(O)} ${o(X)} ${o(k)} ${o(w)}C${o(R)} ${o(I)} ${o(C)} ${o(v)} ${o(g)} ${o(T)}C${o(u)} ${o(S)} ${o(A)} ${o(y)} ${o(p)} ${o(m)}C${o(B)} ${o(h)} ${o(N)} ${o(n)} ${o(_)} ${o(U)}Z`}function A$($,J,Z,K,Q=0,q=null,H=!1,z=6){if($==null||J==null||Z==null||K==null)throw Error("rectToPathData: x, y, width, and height parameters are required");if(!Number.isFinite(z)||z<0)throw Error("rectToPathData: precision must be non-negative");let j=b0($),W=b0(J),G=b0(Z),F=b0(K);if(!j.isFinite())throw Error("rectToPathData: x must be finite");if(!W.isFinite())throw Error("rectToPathData: y must be finite");if(!G.isFinite()||G.isNegative())throw Error("rectToPathData: width must be finite and non-negative");if(!F.isFinite()||F.isNegative())throw Error("rectToPathData: height must be finite and non-negative");if(G.isZero()||F.isZero())return"";let _=b0(Q||0),U=q!==null?b0(q):_;if(!_.isFinite()||_.isNegative())throw Error("rectToPathData: rx must be finite and non-negative");if(!U.isFinite()||U.isNegative())throw Error("rectToPathData: ry must be finite and non-negative");let Y=G.div(2),V=F.div(2);if(_.gt(Y))_=Y;if(U.gt(V))U=V;let O=(A)=>G6(A,z);if(_.isZero()||U.isZero()){let A=j.plus(G),y=W.plus(F);return`M${O(j)} ${O(W)}H${O(A)}V${O(y)}H${O(j)}Z`}let X=j,k=j.plus(G),w=W,R=W.plus(F),I=X.plus(_),C=k.minus(_),v=w.plus(U),g=R.minus(U);if(H)return`M${O(I)} ${O(w)}L${O(C)} ${O(w)}A${O(_)} ${O(U)} 0 0 1 ${O(k)} ${O(v)}L${O(k)} ${O(g)}A${O(_)} ${O(U)} 0 0 1 ${O(C)} ${O(R)}L${O(I)} ${O(R)}A${O(_)} ${O(U)} 0 0 1 ${O(X)} ${O(g)}L${O(X)} ${O(v)}A${O(_)} ${O(U)} 0 0 1 ${O(I)} ${O(w)}Z`;let T=N$(),u=T.mul(_),S=T.mul(U);return`M${O(I)} ${O(w)}L${O(C)} ${O(w)}C${O(C.plus(u))} ${O(w)} ${O(k)} ${O(v.minus(S))} ${O(k)} ${O(v)}L${O(k)} ${O(g)}C${O(k)} ${O(g.plus(S))} ${O(C.plus(u))} ${O(R)} ${O(C)} ${O(R)}L${O(I)} ${O(R)}C${O(I.minus(u))} ${O(R)} ${O(X)} ${O(g.plus(S))} ${O(X)} ${O(g)}L${O(X)} ${O(v)}C${O(X)} ${O(v.minus(S))} ${O(I.minus(u))} ${O(w)} ${O(I)} ${O(w)}Z`}function E$($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(Q)||Q<0)throw Error("lineToPathData: precision must be non-negative");let q=b0($),H=b0(J),z=b0(Z),j=b0(K);if(!q.isFinite()||!H.isFinite()||!z.isFinite()||!j.isFinite())throw Error("lineToPathData: all coordinates must be finite");let W=(G)=>G6(G,Q);return`M${W(q)} ${W(H)}L${W(z)} ${W(j)}`}function Tq($){if($==null)return[];if(Array.isArray($))try{return $.map(([q,H])=>[b0(q),b0(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(b0(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 d6($,J=6){if(!Number.isFinite(J)||J<0)throw Error("polylineToPathData: precision must be non-negative");let Z=Tq($);if(Z.length===0)return"";let K=(z)=>G6(z,J),[Q,q]=Z[0],H=`M${K(Q)} ${K(q)}`;for(let z=1;z<Z.length;z++){let[j,W]=Z[z];H+=`L${K(j)} ${K(W)}`}return H}function T$($,J=6){if(!Number.isFinite(J)||J<0)throw Error("polygonToPathData: precision must be non-negative");let Z=d6($,J);return Z?Z+" Z":""}var fq={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 J6($){if($==null)throw Error("parsePathData: pathData parameter is required");if(typeof $!=="string")throw 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,z=[];if(q.length>0)for(let W of q.matchAll(H))try{z.push(b0(W[0]))}catch(G){continue}let j=fq[Q];if(j===0||z.length===0)J.push({command:Q,args:[]});else for(let W=0;W<z.length;W+=j){let G=z.slice(W,W+j);if(G.length===j){let F=Q;if(W>0&&(Q==="M"||Q==="m"))F=Q==="M"?"L":"l";J.push({command:F,args:G})}}}return J}function N6($,J=6){if($==null)throw Error("pathArrayToString: commands parameter is required");if(!Array.isArray($))throw Error("pathArrayToString: commands must be an array");if(!Number.isFinite(J)||J<0)throw Error("pathArrayToString: precision must be non-negative");return $.map((Z)=>{if(!Z||typeof Z.command!=="string"||!Array.isArray(Z.args))throw Error("pathArrayToString: each command must have 'command' (string) and 'args' (array) properties");let{command:K,args:Q}=Z,q=Q.map((H)=>G6(H,J)).join(" ");return q.length>0?`${K} ${q}`:K}).join(" ")}function p6($){if($==null)throw Error("pathToAbsolute: pathData parameter is required");let J=J6($),Z=[],K=new M(0),Q=new M(0),q=new M(0),H=new M(0),z=new M(0),j=new M(0),W="";for(let{command:G,args:F}of J){let _=G===G.toLowerCase(),U=G.toUpperCase();if(U==="M"){if(F.length<2)continue;let Y=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=Y,Q=V,q=Y,H=V,Z.push({command:"M",args:[Y,V]}),W="M"}else if(U==="L"){if(F.length<2)continue;let Y=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=Y,Q=V,Z.push({command:"L",args:[Y,V]}),W="L"}else if(U==="H"){if(F.length<1)continue;let Y=_?K.plus(F[0]):F[0];K=Y,Z.push({command:"L",args:[Y,Q]}),W="H"}else if(U==="V"){if(F.length<1)continue;let Y=_?Q.plus(F[0]):F[0];Q=Y,Z.push({command:"L",args:[K,Y]}),W="V"}else if(U==="C"){if(F.length<6)continue;let Y=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],O=_?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];z=O,j=X,K=k,Q=w,Z.push({command:"C",args:[Y,V,O,X,k,w]}),W="C"}else if(U==="S"){if(F.length<4)continue;let Y,V;if(W==="C"||W==="S")Y=K.mul(2).minus(z),V=Q.mul(2).minus(j);else Y=K,V=Q;let O=_?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];z=O,j=X,K=k,Q=w,Z.push({command:"C",args:[Y,V,O,X,k,w]}),W="S"}else if(U==="Q"){if(F.length<4)continue;let Y=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],O=_?K.plus(F[2]):F[2],X=_?Q.plus(F[3]):F[3];z=Y,j=V,K=O,Q=X,Z.push({command:"Q",args:[Y,V,O,X]}),W="Q"}else if(U==="T"){if(F.length<2)continue;let Y,V;if(W==="Q"||W==="T")Y=K.mul(2).minus(z),V=Q.mul(2).minus(j);else Y=K,V=Q;let O=_?K.plus(F[0]):F[0],X=_?Q.plus(F[1]):F[1];z=Y,j=V,K=O,Q=X,Z.push({command:"Q",args:[Y,V,O,X]}),W="T"}else if(U==="A"){if(F.length<7)continue;let Y=_?K.plus(F[5]):F[5],V=_?Q.plus(F[6]):F[6];K=Y,Q=V,Z.push({command:"A",args:[F[0],F[1],F[2],F[3],F[4],Y,V]}),W="A"}else if(U==="Z")K=q,Q=H,Z.push({command:"Z",args:[]}),W="Z";else Z.push({command:G,args:F}),W=G}return N6(Z)}function PJ($,J,Z,K,Q,q,H,z){if($==null||J==null||Z==null||K==null||Q==null||q==null||H==null)throw Error("transformArcParams: all parameters (rx, ry, xAxisRotation, largeArc, sweep, endX, endY) are required");if(z==null)throw Error("transformArcParams: matrix parameter is required");if(!z.data||!Array.isArray(z.data)||z.data.length!==3)throw Error("transformArcParams: matrix must be 3x3");if(!Array.isArray(z.data[0])||z.data[0].length<2||!Array.isArray(z.data[1])||z.data[1].length<2||!Array.isArray(z.data[2])||z.data[2].length<1)throw Error("transformArcParams: matrix must have valid 3x3 structure");let j=b0($),W=b0(J),G=b0(Z),F=b0(q),_=b0(H),U=z0.from([[F],[_],[new M(1)]]),Y=z.mul(U),V=Y.data[2][0];if(V.isZero())throw Error("transformArcParams: division by zero in homogeneous coordinate transformation");let O=Y.data[0][0].div(V),X=Y.data[1][0].div(V),k=z.data[0][0],w=z.data[0][1],R=z.data[1][0],I=z.data[1][1],v=k.mul(I).minus(w.mul(R)).isNegative()?Q===1?0:1:Q,g=G.mul(new M(Math.PI)).div(180),T=M.cos(g),u=M.sin(g),S=j.mul(T),A=j.mul(u),y=W.mul(u).neg(),p=W.mul(T),m=k.mul(S).plus(w.mul(A)),B=R.mul(S).plus(I.mul(A)),h=k.mul(y).plus(w.mul(p)),N=R.mul(y).plus(I.mul(p)),n=M.sqrt(m.mul(m).plus(B.mul(B))),o=M.sqrt(h.mul(h).plus(N.mul(N))),q0=M.atan2(B,m).mul(180).div(new M(Math.PI));return[n,o,q0,K,v,O,X]}function bq($,J,Z=6){if($==null)throw Error("transformPathData: pathData parameter is required");if(J==null)throw Error("transformPathData: matrix parameter is required");if(!J.data||!Array.isArray(J.data)||J.data.length!==3)throw 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 Error("transformPathData: matrix must have valid 3x3 structure");if(!Number.isFinite(Z)||Z<0)throw Error("transformPathData: precision must be non-negative");let K=p6($),Q=J6(K),q=[];for(let{command:H,args:z}of Q)if(H==="M"||H==="L"){if(z.length<2)continue;let j=z0.from([[z[0]],[z[1]],[new M(1)]]),W=J.mul(j),G=W.data[2][0];if(G.isZero())throw Error("transformPathData: division by zero in homogeneous coordinate transformation");let F=W.data[0][0].div(G),_=W.data[1][0].div(G);q.push({command:H,args:[F,_]})}else if(H==="C"){if(z.length<6)continue;let j=[];for(let W=0;W<6;W+=2){let G=z0.from([[z[W]],[z[W+1]],[new M(1)]]),F=J.mul(G),_=F.data[2][0];if(_.isZero())throw Error("transformPathData: division by zero in homogeneous coordinate transformation");j.push(F.data[0][0].div(_)),j.push(F.data[1][0].div(_))}q.push({command:H,args:j})}else if(H==="A"){if(z.length<7)continue;let[j,W,G,F,_,U,Y]=PJ(z[0],z[1],z[2],z[3],z[4],z[5],z[6],J);q.push({command:H,args:[j,W,G,F,_,U,Y]})}else q.push({command:H,args:z});return N6(q,Z)}function IJ($,J,Z,K,Q,q){if($==null||J==null||Z==null||K==null||Q==null||q==null)throw Error("quadraticToCubic: all parameters (x0, y0, x1, y1, x2, y2) are required");let H=new M(2).div(3),z=$.plus(H.mul(Z.minus($))),j=J.plus(H.mul(K.minus(J))),W=Q.plus(H.mul(Z.minus(Q))),G=q.plus(H.mul(K.minus(q)));return[z,j,W,G,Q,q]}function Sq($){if($==null)throw Error("pathToCubics: pathData parameter is required");let J=p6($),Z=J6(J),K=[],Q=new M(0),q=new M(0),H=new M(0),z=new M(0),j="";for(let{command:W,args:G}of Z)if(W==="M"){if(G.length<2)continue;Q=G[0],q=G[1],K.push({command:"M",args:[Q,q]}),j="M"}else if(W==="L"){if(G.length<2)continue;let F=G[0],_=G[1];K.push({command:"C",args:[Q,q,F,_,F,_]}),Q=F,q=_,j="L"}else if(W==="C"){if(G.length<6)continue;let[F,_,U,Y,V,O]=G;K.push({command:"C",args:[F,_,U,Y,V,O]}),H=U,z=Y,Q=V,q=O,j="C"}else if(W==="S"){if(G.length<4)continue;let F,_;if(j==="C"||j==="S")F=Q.mul(2).minus(H),_=q.mul(2).minus(z);else F=Q,_=q;let[U,Y,V,O]=G;K.push({command:"C",args:[F,_,U,Y,V,O]}),H=U,z=Y,Q=V,q=O,j="S"}else if(W==="Q"){if(G.length<4)continue;let[F,_,U,Y]=G,V=IJ(Q,q,F,_,U,Y);K.push({command:"C",args:V}),H=F,z=_,Q=U,q=Y,j="Q"}else if(W==="T"){if(G.length<2)continue;let F,_;if(j==="Q"||j==="T")F=Q.mul(2).minus(H),_=q.mul(2).minus(z);else F=Q,_=q;let[U,Y]=G,V=IJ(Q,q,F,_,U,Y);K.push({command:"C",args:V}),H=F,z=_,Q=U,q=Y,j="T"}else if(W==="Z")K.push({command:"Z",args:[]}),j="Z";else K.push({command:W,args:G}),j=W;return N6(K)}function k9($,J=6){if($==null)throw Error("convertElementToPath: element parameter is required");if(!Number.isFinite(J)||J<0)throw Error("convertElementToPath: precision must be non-negative");let Z=(Q,q=0)=>{let H=$.getAttribute?$.getAttribute(Q):$[Q];return vq(H!==void 0&&H!==null?H:q)},K=($.tagName||$.type||"").toLowerCase();if(K==="circle")return C$(Z("cx",0),Z("cy",0),Z("r",0),J);else if(K==="ellipse")return P$(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(K==="rect")return A$(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 E$(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(K==="polyline")return d6(Z("points",""),J);else if(K==="polygon")return T$(Z("points",""),J);return null}function vq($){if($==null)return 0;if(typeof $==="string"){let Z=parseFloat($);return isNaN(Z)?0:Z}if(typeof $==="number")return isNaN($)?0:$;if($ instanceof M)return $.toNumber();let J=Number($);return isNaN(J)?0:J}M.set({precision:80});function AJ($,J,Z){return w9($,J,Z,Z)}function w9($,J,Z,K){let Q=(R)=>new M(R),q=Q($),H=Q(J),z=Q(Z),j=Q(K);if(!z.isFinite()||!j.isFinite()||!q.isFinite()||!H.isFinite())throw Error("Ellipse parameters must be finite");if(z.eq(0)||j.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(z.lt(0)||j.lt(0))throw Error("Ellipse radii must be non-negative");let W=Q("0.5522847498307936"),G=z.mul(W),F=j.mul(W),_=q.plus(z),U=H,Y=q,V=H.minus(j),O=q.minus(z),X=H,k=q,w=H.plus(j);return[`M ${_.toFixed(6)} ${U.toFixed(6)}`,`C ${_.toFixed(6)} ${U.minus(F).toFixed(6)} ${Y.plus(G).toFixed(6)} ${V.toFixed(6)} ${Y.toFixed(6)} ${V.toFixed(6)}`,`C ${Y.minus(G).toFixed(6)} ${V.toFixed(6)} ${O.toFixed(6)} ${X.minus(F).toFixed(6)} ${O.toFixed(6)} ${X.toFixed(6)}`,`C ${O.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 EJ($,J,Z,K,Q=0,q=null){let H=(O)=>new M(O),z=H($),j=H(J),W=H(Z),G=H(K);if(W.lte(0)||G.lte(0))throw Error("Rectangle dimensions must be positive");if(!W.isFinite()||!G.isFinite()||!z.isFinite()||!j.isFinite())throw Error("Rectangle parameters must be finite");let F=H(Q),_=q!==null?H(q):F;if(F.lt(0)||_.lt(0))throw Error("Rectangle corner radii must be non-negative");let U=W.div(2),Y=G.div(2);if(F.gt(U))F=U;if(_.gt(Y))_=Y;if(!(F.gt(0)||_.gt(0)))return[`M ${z.toFixed(6)} ${j.toFixed(6)}`,`L ${z.plus(W).toFixed(6)} ${j.toFixed(6)}`,`L ${z.plus(W).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${z.toFixed(6)} ${j.plus(G).toFixed(6)}`,"Z"].join(" ");return[`M ${z.plus(F).toFixed(6)} ${j.toFixed(6)}`,`L ${z.plus(W).minus(F).toFixed(6)} ${j.toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${z.plus(W).toFixed(6)} ${j.plus(_).toFixed(6)}`,`L ${z.plus(W).toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${z.plus(W).minus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${z.plus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${z.toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`L ${z.toFixed(6)} ${j.plus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${z.plus(F).toFixed(6)} ${j.toFixed(6)}`].join(" ")}function TJ($,J,Z,K){let Q=(W)=>new M(W),q=Q($),H=Q(J),z=Q(Z),j=Q(K);if(!q.isFinite()||!H.isFinite()||!z.isFinite()||!j.isFinite())throw Error("lineToPath: all parameters must be finite");return`M ${q.toFixed(6)} ${H.toFixed(6)} L ${z.toFixed(6)} ${j.toFixed(6)}`}function fJ($){let J=SJ($);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 bJ($){let J=SJ($);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 SJ($){if(!$)return[];let J;try{if(Array.isArray($))J=$.flat().map((K)=>new M(K).toFixed(6));else if(typeof $==="string")J=$.trim().split(/[\s,]+/).filter((K)=>K.length>0).map((K)=>new M(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 Dq($,J,Z,K,Q,q,H,z){let j=(Q0)=>new M(Q0),W=j("1e-16");if(!z||!z.data||!Array.isArray(z.data)||z.data.length<3)throw Error("transformArc: invalid matrix");let G=j($),F=j(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:j(q).toNumber(),y:j(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 Y=z.data[0][0],V=z.data[1][0],O=z.data[0][1],X=z.data[1][1],k=z.data[0][2],w=z.data[1][2],R=j(q),I=j(H),C=Y.mul(R).plus(O.mul(I)).plus(k),v=V.mul(R).plus(X.mul(I)).plus(w),g=j(Z).mul(j(Math.PI)).div(180),T=M.sin(g),u=M.cos(g),S=Y.mul(G).mul(u).plus(O.mul(G).mul(T)),A=V.mul(G).mul(u).plus(X.mul(G).mul(T)),y=Y.mul(F.neg()).mul(T).plus(O.mul(F).mul(u)),p=V.mul(F.neg()).mul(T).plus(X.mul(F).mul(u)),m=S.mul(S).plus(y.mul(y)),B=A.mul(A).plus(p.mul(p)),h=S.mul(A).plus(y.mul(p)).mul(2),N=m.minus(B),n,o,s;if(h.abs().lt(W))n=j(0),o=m,s=B;else if(N.abs().lt(W))o=m.plus(h.mul("0.5")),s=m.minus(h.mul("0.5")),n=j(Math.PI).div(4);else{let Q0=j(1).plus(h.mul(h).div(N.mul(N))).sqrt();o=m.plus(B).plus(Q0.mul(N)).div(2),s=m.plus(B).minus(Q0.mul(N)).div(2),n=M.atan(h.div(N)).div(2)}if(o.lt(0))o=j(0);if(s.lt(0))s=j(0);let q0=o.sqrt(),f=s.sqrt();if(N.lte(0)){let Q0=q0;q0=f,f=Q0}if(f.gt(q0)){let Q0=q0;q0=f,f=Q0,n=n.plus(j(Math.PI).div(2))}let E=Y.mul(X).minus(V.mul(O)),t=U;if(E.lt(0))t=U?0:1;let e=n.mul(180).div(j(Math.PI));while(e.lt(0))e=e.plus(180);while(e.gte(180))e=e.minus(180);return{rx:q0.toNumber(),ry:f.toNumber(),xAxisRotation:e.toNumber(),largeArcFlag:_,sweepFlag:t,x:C.toNumber(),y:v.toNumber()}}function hq($,J){if(!$||typeof $!=="string")return console.warn("parseTransformFunction: invalid function name"),z0.identity(3);if(!J||!Array.isArray(J))return console.warn("parseTransformFunction: invalid arguments array"),z0.identity(3);let Z=(K)=>new M(K);switch($.toLowerCase()){case"translate":{let K=J[0]!==void 0?J[0]:0,Q=J[1]!==void 0?J[1]:0;return i0(K,Q)}case"scale":{let K=J[0]!==void 0?J[0]:1,Q=J[1]!==void 0?J[1]:K;return k7(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"),W6(Q);let q=J[1],H=J[2];return U9(Q,q,H)}return W6(Q)}case"skewx":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),q=M.tan(Q);return X$(q,0)}case"skewy":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),q=M.tan(Q);return X$(0,q)}case"matrix":{if(J.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${J.length}`),z0.identity(3);let[K,Q,q,H,z,j]=J.slice(0,6).map((W)=>Z(W!==void 0?W:0));return z0.from([[K,q,z],[Q,H,j],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),z0.identity(3)}}function U7($){if(!$||$.trim()==="")return z0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,K=z0.identity(3);while((Z=J.exec($))!==null){let Q=Z[1],H=Z[2].split(/[\s,]+/).filter((j)=>j.length>0).map((j)=>{let W=parseFloat(j);if(isNaN(W))return console.warn(`parseTransformAttribute: invalid numeric argument "${j}" in ${Q}(), using 0`),0;return W}),z=hq(Q,H);K=K.mul(z)}return K}function L7($,J,Z){if(!$||!$.data||!Array.isArray($.data))throw Error("applyToPoint: invalid CTM matrix");let K=(H)=>new M(H);try{let H=K(J),z=K(Z);if(!H.isFinite()||!z.isFinite())throw Error("applyToPoint: coordinates must be finite")}catch(H){throw Error(`applyToPoint: invalid coordinates - ${H.message}`)}let[Q,q]=p0($,J,Z);return{x:Q,y:q}}function vJ($,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 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),z=$.data[0][2].toFixed(Z),j=$.data[1][2].toFixed(Z);return`matrix(${K}, ${Q}, ${q}, ${H}, ${z}, ${j})`}catch(K){throw Error(`toSVGMatrix: invalid matrix elements - ${K.message}`)}}function I6($,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 M(U),z=yq($);if(z.length===0)return"";let j=[],W=H(0),G=H(0),F=H(0),_=H(0);for(let{cmd:U,args:Y}of z){let V=U===U.toLowerCase();switch(U.toUpperCase()){case"M":{let X=[];if(Y.length%2!==0)console.warn(`transformPathData: M command has ${Y.length} args, expected multiple of 2`);for(let k=0;k+1<Y.length;k+=2){let w=H(Y[k]),R=H(Y[k+1]);if(V)w=w.plus(W),R=R.plus(G);let I=L7(J,w,R);if(X.push(I.x.toFixed(q),I.y.toFixed(q)),W=w,G=R,k===0)F=w,_=R}j.push((K?"M":U)+" "+X.join(" "));break}case"L":{let X=[];if(Y.length%2!==0)console.warn(`transformPathData: L command has ${Y.length} args, expected multiple of 2`);for(let k=0;k+1<Y.length;k+=2){let w=H(Y[k]),R=H(Y[k+1]);if(V)w=w.plus(W),R=R.plus(G);let I=L7(J,w,R);X.push(I.x.toFixed(q),I.y.toFixed(q)),W=w,G=R}j.push((K?"L":U)+" "+X.join(" "));break}case"H":{if(Y.length<1){console.warn("transformPathData: H command requires at least 1 argument");break}for(let X=0;X<Y.length;X++){let k=H(Y[X]);if(V)k=k.plus(W);let R=L7(J,k,G);j.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),W=k}break}case"V":{if(Y.length<1){console.warn("transformPathData: V command requires at least 1 argument");break}for(let X=0;X<Y.length;X++){let k=W,w=H(Y[X]);if(V)w=w.plus(G);let R=L7(J,k,w);j.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),G=w}break}case"C":{let X=[];if(Y.length%6!==0)console.warn(`transformPathData: C command has ${Y.length} args, expected multiple of 6`);for(let k=0;k+5<Y.length;k+=6){let w=H(Y[k]),R=H(Y[k+1]),I=H(Y[k+2]),C=H(Y[k+3]),v=H(Y[k+4]),g=H(Y[k+5]);if(V)w=w.plus(W),R=R.plus(G),I=I.plus(W),C=C.plus(G),v=v.plus(W),g=g.plus(G);let T=L7(J,w,R),u=L7(J,I,C),S=L7(J,v,g);X.push(T.x.toFixed(q),T.y.toFixed(q),u.x.toFixed(q),u.y.toFixed(q),S.x.toFixed(q),S.y.toFixed(q)),W=v,G=g}j.push((K?"C":U)+" "+X.join(" "));break}case"S":{let X=[];if(Y.length%4!==0)console.warn(`transformPathData: S command has ${Y.length} args, expected multiple of 4`);for(let k=0;k+3<Y.length;k+=4){let w=H(Y[k]),R=H(Y[k+1]),I=H(Y[k+2]),C=H(Y[k+3]);if(V)w=w.plus(W),R=R.plus(G),I=I.plus(W),C=C.plus(G);let v=L7(J,w,R),g=L7(J,I,C);X.push(v.x.toFixed(q),v.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),W=I,G=C}j.push((K?"S":U)+" "+X.join(" "));break}case"Q":{let X=[];if(Y.length%4!==0)console.warn(`transformPathData: Q command has ${Y.length} args, expected multiple of 4`);for(let k=0;k+3<Y.length;k+=4){let w=H(Y[k]),R=H(Y[k+1]),I=H(Y[k+2]),C=H(Y[k+3]);if(V)w=w.plus(W),R=R.plus(G),I=I.plus(W),C=C.plus(G);let v=L7(J,w,R),g=L7(J,I,C);X.push(v.x.toFixed(q),v.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),W=I,G=C}j.push((K?"Q":U)+" "+X.join(" "));break}case"T":{let X=[];if(Y.length%2!==0)console.warn(`transformPathData: T command has ${Y.length} args, expected multiple of 2`);for(let k=0;k+1<Y.length;k+=2){let w=H(Y[k]),R=H(Y[k+1]);if(V)w=w.plus(W),R=R.plus(G);let I=L7(J,w,R);X.push(I.x.toFixed(q),I.y.toFixed(q)),W=w,G=R}j.push((K?"T":U)+" "+X.join(" "));break}case"A":{let X=[];if(Y.length%7!==0)console.warn(`transformPathData: Arc command has ${Y.length} args, expected multiple of 7`);for(let k=0;k+6<Y.length;k+=7){let w=Y[k],R=Y[k+1],I=Y[k+2],C=Y[k+3],v=Y[k+4],g=H(Y[k+5]),T=H(Y[k+6]);if(V)g=g.plus(W),T=T.plus(G);let u=Dq(w,R,I,C,v,g.toNumber(),T.toNumber(),J);X.push(u.rx.toFixed(q),u.ry.toFixed(q),u.xAxisRotation.toFixed(q),u.largeArcFlag,u.sweepFlag,u.x.toFixed(q),u.y.toFixed(q)),W=g,G=T}j.push((K?"A":U)+" "+X.join(" "));break}case"Z":{j.push("Z"),W=F,G=_;break}default:j.push(U+" "+Y.join(" "))}}return j.join(" ")}function yq($){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((z)=>z.length>0).map((z)=>{let j=parseFloat(z);if(isNaN(j))return console.warn(`parsePathCommands: invalid number '${z}'`),0;return j}):[];J.push({cmd:Q,args:H})}return J}var P7={};x7(P7,{sign:()=>L9,segmentIntersection:()=>b$,reversePolygon:()=>I9,polygonUnion:()=>F6,polygonIntersection:()=>S7,polygonDifference:()=>mJ,polygonArea:()=>n6,pointsEqual:()=>d7,pointOnSegment:()=>R9,pointInPolygon:()=>C7,point:()=>f0,lineSegmentIntersection:()=>gJ,isCounterClockwise:()=>N9,isConvex:()=>P9,ensureCCW:()=>S$,dot:()=>uJ,default:()=>dq,cross:()=>p7,convexHull:()=>C9,clipPolygonSH:()=>B9,boundingBox:()=>c7,bboxIntersects:()=>l6});M.set({precision:80});var R7=($)=>$ instanceof M?$:new M($),V7=new M("1e-40");function f0($,J){if($===null||$===void 0)throw Error("point: x coordinate is required");if(J===null||J===void 0)throw Error("point: y coordinate is required");return{x:R7($),y:R7(J)}}function d7($,J,Z=V7){if(!$||typeof $!=="object"||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 Error("pointsEqual: p2 must be a point with x and y properties");if(!Z||typeof Z.abs!=="function")throw 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 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 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 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 uJ($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 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 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 Error("sign: val must be a Decimal instance");if($.abs().lt(V7))return 0;return $.lt(0)?-1:1}function b$($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 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 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 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),z=K.y.minus(Z.y),j=Q.mul(z).minus(q.mul(H));if(j.abs().lt(V7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(z).minus(G.mul(H)).div(j),_=W.mul(q).minus(G.mul(Q)).div(j),U=R7(0),Y=R7(1);if(F.gte(U)&&F.lte(Y)&&_.gte(U)&&_.lte(Y))return{x:$.x.plus(Q.mul(F)),y:$.y.plus(q.mul(F)),t:F,s:_};return null}function gJ($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 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 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 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),z=K.y.minus(Z.y),j=Q.mul(z).minus(q.mul(H));if(j.abs().lt(V7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(q).minus(G.mul(Q)).div(j);if(F.gte(0)&&F.lte(1))return{x:Z.x.plus(H.mul(F)),y:Z.y.plus(z.mul(F)),s:F};return null}function C7($,J){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw Error("pointInPolygon: pt must have x and y properties");if(!Array.isArray(J))throw 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 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 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 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 Error("pointOnSegment: segment point b must have x and y properties");if(p7(J,Z,$).abs().gt(V7))return!1;let Q=M.min(J.x,Z.x),q=M.max(J.x,Z.x),H=M.min(J.y,Z.y),z=M.max(J.y,Z.y);return $.x.gte(Q.minus(V7))&&$.x.lte(q.plus(V7))&&$.y.gte(H.minus(V7))&&$.y.lte(z.plus(V7))}function B9($,J){if(!Array.isArray($))throw Error("clipPolygonSH: subject must be an array");if(!Array.isArray(J))throw 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 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 Error(`clipPolygonSH: clip[${Q}] must have x and y properties`);let Z=$.map((Q)=>f0(Q.x,Q.y)),K=J.map((Q)=>f0(Q.x,Q.y));K=S$(K);for(let Q=0;Q<K.length;Q++){if(Z.length===0)return[];let q=K[Q],H=K[(Q+1)%K.length],z=Z;Z=[];for(let j=0;j<z.length;j++){let W=z[j],G=z[(j+z.length-1)%z.length],F=hJ(W,q,H),_=hJ(G,q,H);if(F){if(!_){let U=yJ(G,W,q,H);if(U)Z.push(U)}Z.push(W)}else if(_){let U=yJ(G,W,q,H);if(U)Z.push(U)}}}return Z}function hJ($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 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 Error("isInsideEdge: edgeEnd must have x and y properties");return p7(J,Z,$).gte(0)}function yJ($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw 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 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 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 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),z=K.y.minus(Z.y),j=Q.mul(z).minus(q.mul(H));if(j.abs().lt(V7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(z).minus(G.mul(H)).div(j);return{x:$.x.plus(Q.mul(F)),y:$.y.plus(q.mul(F))}}function n6($){if(!Array.isArray($))throw Error("polygonArea: polygon must be an array");let J=$.length;if(J<3)return R7(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 Error(`polygonArea: polygon[${K}] must have x and y properties`);let Z=R7(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 Error("isCounterClockwise: polygon must be an array");return n6($).gt(0)}function I9($){if(!Array.isArray($))throw Error("reversePolygon: polygon must be an array");return[...$].reverse()}function S$($){if(!Array.isArray($))throw Error("ensureCCW: polygon must be an array");if(!N9($))return I9($);return $}function C9($){if(!Array.isArray($))throw 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 Error(`convexHull: points[${H}] must have x and y properties`);return $.map((H)=>f0(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 Error(`convexHull: points[${H}] must have x and y properties`);let J=$.map((H)=>f0(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,z)=>{let j=p7(K,H,z);if(j.abs().lt(V7)){let G=H.x.minus(K.x).pow(2).plus(H.y.minus(K.y).pow(2)),F=z.x.minus(K.x).pow(2).plus(z.y.minus(K.y).pow(2)),_=G.minus(F);if(_.abs().lt(V7))return 0;return _.lt(0)?-1:1}return-L9(j)}),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 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 Error("boundingBox: polygon[0] must have x and y properties");let J=R7($[0].x),Z=R7($[0].y),K=R7($[0].x),Q=R7($[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 Error(`boundingBox: polygon[${q}] must have x and y properties`);let z=R7(H.x),j=R7(H.y);if(z.lt(J))J=z;if(j.lt(Z))Z=j;if(z.gt(K))K=z;if(j.gt(Q))Q=j}return{minX:J,minY:Z,maxX:K,maxY:Q}}function l6($,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 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 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 S7($,J){if(!Array.isArray($))throw Error("polygonIntersection: subject must be an array");if(!Array.isArray(J))throw 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 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 Error(`polygonIntersection: clip[${H}] must have x and y properties`);let Z=$.map((H)=>f0(H.x,H.y)),K=J.map((H)=>f0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!l6(Q,q))return[];if(P9(K)){let H=B9(Z,S$(K));return H.length>=3?[H]:[]}return uq(Z,K)}function P9($){if(!Array.isArray($))throw 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 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],z=p7(Q,q,H),j=z.gt(0)?1:z.lt(0)?-1:0;if(j!==0){if(Z===0)Z=j;else if(Z!==j)return!1}}return!0}function uq($,J){if(!Array.isArray($)||!Array.isArray(J))throw Error("generalPolygonIntersection: both arguments must be arrays");let Z=[];for(let j=0;j<$.length;j++){let W=$[j],G=$[(j+1)%$.length];for(let F=0;F<J.length;F++){let _=J[F],U=J[(F+1)%J.length],Y=b$(W,G,_,U);if(Y)Z.push(f0(Y.x,Y.y))}}let K=$.filter((j)=>C7(j,J)>=0),Q=J.filter((j)=>C7(j,$)>=0),q=[...Z,...K,...Q];if(q.length<3)return[];let H=gq(q);if(H.length<3)return[];let z=C9(H);return z.length>=3?[z]:[]}function gq($){if(!Array.isArray($))throw 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 F6($,J){if(!Array.isArray($))throw Error("polygonUnion: polygon1 must be an array");if(!Array.isArray(J))throw 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 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 Error(`polygonUnion: polygon2[${H}] must have x and y properties`);let Z=$.map((H)=>f0(H.x,H.y)),K=J.map((H)=>f0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!l6(Q,q))return[Z,K];return xq(Z,K)}function xq($,J){if(!Array.isArray($)||!Array.isArray(J))throw Error("traceBoundaryUnion: both arguments must be arrays");let Z=xJ($,J);if(Z.length===0){let V=C7($[0],J),O=C7(J[0],$);if(V>0)return[J];else if(O>0)return[$];else return[$,J]}let K=f$($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),Q=f$(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,z=-1;for(let V=0;V<K.length;V++){let O=K[V];if(O.intersectionId===void 0&&C7(O,J)<0){z=V;break}}if(z===-1){H=2;for(let V=0;V<Q.length;V++){let O=Q[V];if(O.intersectionId===void 0&&C7(O,$)<0){z=V;break}}}if(z===-1){let V=n6($).abs(),O=n6(J).abs();return V.gt(O)?[$]:[J]}let j=[],W=H===1,G=z,F=new Set,_=(K.length+Q.length)*3,U=0,Y=`${H}-${z}`;while(U<_){U++;let V=W?K:Q,O=W?Q:K,X=V[G];if(j.length===0||!d7(j[j.length-1],X))j.push(f0(X.x,X.y));let k=(G+1)%V.length,w=V[k];if(w.intersectionId!==void 0&&!F.has(w.intersectionId)){j.push(f0(w.x,w.y)),F.add(w.intersectionId);let I=q.get(w.intersectionId),C=W?I.idx2:I.idx1;W=!W,G=(C+1)%O.length}else G=k;if(`${W?1:2}-${G}`===Y)break}if(j.length>1&&d7(j[0],j[j.length-1]))j.pop();return j.length>=3?[j]:[]}function xJ($,J){if(!Array.isArray($)||!Array.isArray(J))throw 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 z=0;z<J.length;z++){let j=J[z],W=J[(z+1)%J.length],G=b$(q,H,j,W);if(G)Z.push({id:K++,point:f0(G.x,G.y),edge1:Q,edge2:z,t1:G.t,t2:G.s})}}return Z}function f$($,J){if(!Array.isArray($))throw Error("augmentPolygon: polygon must be an array");if(!Array.isArray(J))throw 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 mJ($,J){if(!Array.isArray($))throw Error("polygonDifference: polygon1 must be an array");if(!Array.isArray(J))throw 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 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 Error(`polygonDifference: polygon2[${H}] must have x and y properties`);let Z=$.map((H)=>f0(H.x,H.y)),K=J.map((H)=>f0(H.x,H.y)),Q=c7(Z),q=c7(K);if(!l6(Q,q))return[Z];return mq(Z,K)}function mq($,J){if(!Array.isArray($)||!Array.isArray(J))throw Error("traceBoundaryDifference: both arguments must be arrays");let Z=xJ($,J);if(Z.length===0)if(C7($[0],J)>0)return[];else return[$];let K=f$($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),Q=f$(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 Y=K[U];if(Y.intersectionId===void 0&&C7(Y,J)<0){H=U;break}}if(H===-1)return[];let z=[],j=!0,W=H,G=new Set,F=(K.length+Q.length)*3,_=0;while(_<F){_++;let Y=(j?K:Q)[W];if(z.length===0||!d7(z[z.length-1],Y))z.push(f0(Y.x,Y.y));let V=`${j?1:2}-${W}`;if(G.has(V))break;if(G.add(V),j){let O=(W+1)%K.length,X=K[O];if(X.intersectionId!==void 0){let k=K[(O+1)%K.length];if(C7(k,J)>0){let R=q.get(X.intersectionId);z.push(f0(X.x,X.y)),j=!1,W=(R.idx2-1+Q.length)%Q.length}else W=O}else W=O}else{let O=(W-1+Q.length)%Q.length,X=Q[O];if(X.intersectionId!==void 0){let k=q.get(X.intersectionId);z.push(f0(X.x,X.y)),j=!0,W=(k.idx1+1)%K.length}else W=O}if(j&&W===H)break}if(z.length>1&&d7(z[0],z[z.length-1]))z.pop();return z.length>=3?[z]:[]}var dq={point:f0,pointsEqual:d7,cross:p7,dot:uJ,sign:L9,segmentIntersection:b$,lineSegmentIntersection:gJ,pointInPolygon:C7,pointOnSegment:R9,clipPolygonSH:B9,polygonArea:n6,isCounterClockwise:N9,reversePolygon:I9,ensureCCW:S$,isConvex:P9,convexHull:C9,boundingBox:c7,bboxIntersects:l6,polygonIntersection:S7,polygonUnion:F6,polygonDifference:mJ,EPSILON:V7};M.set({precision:80});var v$=($)=>$ instanceof M?$:new M($),n7=new M("1e-40"),{point:Z6,pointsEqual:aW,cross:A9,polygonArea:tW,polygonIntersection:eW,polygonUnion:$4,polygonDifference:J4,isCounterClockwise:Z4,ensureCCW:K4,segmentIntersection:Q4}=P7,K6={NONZERO:"nonzero",EVENODD:"evenodd"};function D$($,J,Z=K6.NONZERO){if(!$||typeof $!=="object")throw Error("pointInPolygonWithRule: pt must be an object with x, y properties");if($.x===void 0||$.x===null||$.y===void 0||$.y===null)throw Error("pointInPolygonWithRule: pt must have x and y properties");if(!Array.isArray(J))throw 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],z=J[(q+1)%K];if(pq($,H,z))return 0;if(H.y.lte($.y)){if(z.y.gt($.y)){if(A9(H,z,$).gt(0))Q++}}else if(z.y.lte($.y)){if(A9(H,z,$).lt(0))Q--}}if(Z===K6.EVENODD)return Math.abs(Q)%2===1?1:-1;else return Q!==0?1:-1}function pq($,J,Z){if(!$||!J||!Z)throw 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 Error("pointOnSegment: all points must have x and y properties");if(A9(J,Z,$).abs().gt(n7))return!1;let Q=M.min(J.x,Z.x),q=M.max(J.x,Z.x),H=M.min(J.y,Z.y),z=M.max(J.y,Z.y);return $.x.gte(Q.minus(n7))&&$.x.lte(q.plus(n7))&&$.y.gte(H.minus(n7))&&$.y.lte(z.plus(n7))}function dJ($,J,Z={}){if(!Array.isArray($))throw Error("offsetPolygon: polygon must be an array");if(J===void 0||J===null)throw Error("offsetPolygon: distance must be defined");if(!Z||typeof Z!=="object")throw Error("offsetPolygon: options must be an object");let K=v$(J);if(K.lte(0))throw Error("offsetPolygon: distance must be positive");let Q=Z.linejoin||"miter",q=v$(Z.miterLimit||4);if($.length<3)return{outer:[],inner:[]};let H=$.length,z=[],j=[];for(let W=0;W<H;W++){let G=$[(W-1+H)%H],F=$[W],_=$[(W+1)%H],U=F.x.minus(G.x),Y=F.y.minus(G.y),V=_.x.minus(F.x),O=_.y.minus(F.y),X=U.pow(2).plus(Y.pow(2)).sqrt(),k=V.pow(2).plus(O.pow(2)).sqrt();if(X.lt(n7)||k.lt(n7))continue;let w=Y.div(X),R=U.neg().div(X),I=O.div(k),C=V.neg().div(k),v=w.plus(I).div(2),g=R.plus(C).div(2),T=v.pow(2).plus(g.pow(2)).sqrt();if(T.lt(n7))v=w,g=R;else v=v.div(T),g=g.div(T);let u=w.times(I).plus(R.times(C)),S=v$(1).minus(u).div(2).sqrt(),A=K;if(S.gt(n7)){let y=K.div(S);if(Q==="miter"&&y.lte(K.times(q)))A=y;else if(Q==="bevel"||y.gt(K.times(q))){let p=Z6(F.x.plus(w.times(K)),F.y.plus(R.times(K))),m=Z6(F.x.plus(I.times(K)),F.y.plus(C.times(K)));z.push(p,m);let B=Z6(F.x.minus(w.times(K)),F.y.minus(R.times(K))),h=Z6(F.x.minus(I.times(K)),F.y.minus(C.times(K)));j.push(B,h);continue}else if(Q==="round"){let p=Math.atan2(R.toNumber(),w.toNumber()),B=Math.atan2(C.toNumber(),I.toNumber())-p;if(B<-Math.PI)B+=2*Math.PI;if(B>Math.PI)B-=2*Math.PI;let h=Math.max(2,Math.ceil(Math.abs(B)/(Math.PI/8)));for(let N=0;N<=h;N++){let n=p+B*(N/h);z.push(Z6(F.x.plus(K.times(Math.cos(n))),F.y.plus(K.times(Math.sin(n))))),j.push(Z6(F.x.minus(K.times(Math.cos(n))),F.y.minus(K.times(Math.sin(n)))))}continue}}z.push(Z6(F.x.plus(v.times(A)),F.y.plus(g.times(A)))),j.push(Z6(F.x.minus(v.times(A)),F.y.minus(g.times(A))))}return{outer:z,inner:j.reverse()}}function E9($,J){if(!Array.isArray($))throw Error("strokeToFilledPolygon: polygon must be an array");if(!J||typeof J!=="object")throw Error("strokeToFilledPolygon: strokeProps must be an object");if(J.width===void 0||J.width===null)throw Error("strokeToFilledPolygon: strokeProps must have width property");let Z=v$(J.width).div(2);if(Z.lte(0))throw Error("strokeToFilledPolygon: width must be positive");return dJ($,Z,J).outer}M.set({precision:80});var v7=($)=>$ instanceof M?$:new M($),cq={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 h${constructor($,J={},Z=null){if(!$)throw Error("SVGRenderingContext: element parameter is required");if(J!==null&&typeof J!=="object")throw 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=v7(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"&&v7(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 Error("_extractProperties: inherited must be an object or null");let Z={...cq,...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 Error(`_parseDashArray: invalid dash value '${K}'`);if(Q<0)throw Error(`_parseDashArray: dash values must be non-negative, got ${Q}`);Z.push(v7(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 v7(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return v7(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return v7(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 Error("expandBBoxForStroke: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw 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 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 Error("expandBBoxForMarkers: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw 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 Error("expandBBoxForMarkers: bbox properties must be Decimal instances");if(!this.hasMarkers)return $;let Z=v7(0);if(J){if(typeof J!=="object")throw 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 Error(`expandBBoxForMarkers: invalid marker size '${q}'`);return v7(H)});if(Q.length>0)Z=M.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 Error("expandBBoxForFilter: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw 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 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 Error("expandBBoxForFilter: filterDef must be an object");if(J.x!==void 0){let q=parseFloat(J.x);if(isNaN(q)||!isFinite(q))throw Error(`expandBBoxForFilter: invalid filterDef.x value '${J.x}'`);K=v7(q).abs()}if(J.y!==void 0){let q=parseFloat(J.y);if(isNaN(q)||!isFinite(q))throw Error(`expandBBoxForFilter: invalid filterDef.y value '${J.y}'`);Q=v7(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 Error("getRenderedBBox: geometryBBox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw Error("getRenderedBBox: geometryBBox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function")throw Error("getRenderedBBox: geometryBBox properties must be Decimal instances");if(J!==null&&typeof J!=="object")throw 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 Error("getFilledArea: polygon must be an array");if($.length===0)throw 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 Error("isPointInRenderedArea: point must be an object");if($.x===void 0||$.y===void 0)throw Error("isPointInRenderedArea: point must have x and y properties");if(!Array.isArray(J))throw Error("isPointInRenderedArea: polygon must be an array");if(J.length===0)throw Error("isPointInRenderedArea: polygon must not be empty");if(this.hasFill){let Z=this.fillRule==="evenodd"?K6.EVENODD:K6.NONZERO;if(D$($,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(D$($,Z,K6.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof h$))throw 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 s6($,J={},Z=null){if(!$)throw Error("createRenderingContext: element parameter is required");return new h$($,J,Z)}function o6($){if(!$)throw 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:()=>Z7,parseUrlReference:()=>h7,parseSVG:()=>u0,findElementsWithAttribute:()=>A7,default:()=>sq,buildDefsMap:()=>D7,SVGElement:()=>w0});M.set({precision:80});function lJ($,J){if(!$||!J)throw Error("setOwnerDocument: element and document are required");if(!$.children||!Array.isArray($.children))throw Error("setOwnerDocument: element must have a children array");$.ownerDocument=J;for(let Z of $.children)if(Z instanceof w0)lJ(Z,J)}function u0($){if(typeof $!=="string")throw Error("parseSVG: input must be a string");if($.trim().length===0)throw Error("parseSVG: input cannot be empty");let J=$.trim(),Z=oJ(J,0);if(!Z.element)throw Error("Failed to parse SVG: no root element found");let K=new sJ(Z.element);return lJ(Z.element,K),Z.element}class sJ{constructor($=null){this.documentElement=$}createElement($){if(!$||typeof $!=="string")throw 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 Error("createElementNS: namespace must be a string");return this.createElement(J)}}class w0{constructor($,J={},Z=[],K=""){if(!$||typeof $!=="string")throw Error("SVGElement: tagName must be a non-empty string");if(J!==null&&typeof J!=="object")throw Error("SVGElement: attributes must be an object");if(!Array.isArray(Z))throw Error("SVGElement: children must be an array");if(typeof K!=="string")throw 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 Error("getAttribute: name must be a string");return this._attributes[$]??null}setAttribute($,J){if(typeof $!=="string")throw 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 Error("hasAttribute: name must be a string");return $ in this._attributes}removeAttribute($){if(typeof $!=="string")throw Error("removeAttribute: name must be a string");delete this._attributes[$]}getAttributeNames(){return Object.keys(this._attributes)}getElementsByTagName($){if(typeof $!=="string")throw 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 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 Error("querySelector: selector must be a string");return this.querySelectorAll($)[0]||null}querySelectorAll($){if(typeof $!=="string")throw Error("querySelectorAll: selector must be a string");let J=[],Z=pJ($),K=(Q)=>{for(let q of Q.children)if(q instanceof w0){if(cJ(q,Z))J.push(q);K(q)}};return K(this),J}matches($){if(typeof $!=="string")throw Error("matches: selector must be a string");let J=pJ($);return cJ(this,J)}cloneNode($=!0){if(typeof $!=="boolean")throw 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 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 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 Error("insertBefore: newChild cannot be null or undefined");if(J===null||J===void 0)throw 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 Error("replaceChild: newChild cannot be null or undefined");if(J===null||J===void 0)throw 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 Error("serialize: indent must be a non-negative finite number");if(typeof J!=="boolean")throw Error("serialize: minify must be a boolean");let Z=J?"":" ".repeat($),K=this._attributes["data-cdata-pending"]==="true",Q=Object.entries(this._attributes).filter(([W])=>W!=="data-cdata-pending").map(([W,G])=>`${W}="${nq(G)}"`).join(" "),q=Q?" "+Q:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${q}/>`;let H=J?"":`
|
|
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
|
-
]]>`+H+
|
|
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
|
-
`)+$.serialize(0,Z)}var
|
|
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
|
-
`;oq(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<i6.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<i6.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<i6.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<i6.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 aq=U7;M.set({precision:80});var U0=($)=>$ instanceof M?$:new M($),tJ=20;function Q6($,J=tJ){if(typeof $!=="string")throw Error("pathToPolygon: pathData must be a string");if(typeof J!=="number"||J<=0||!Number.isFinite(J))throw 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),z=tq($);if(!Array.isArray(z))throw Error("pathToPolygon: parsePathCommands must return an array");for(let j of z){let{type:W,args:G}=j;if(!Array.isArray(G))throw Error(`pathToPolygon: command args must be an array for command ${W}`);switch(W){case"M":if(G.length<2)throw Error(`pathToPolygon: M command requires 2 arguments, got ${G.length}`);K=U0(G[0]),Q=U0(G[1]),q=K,H=Q,Z.push(f0(K,Q));break;case"m":if(G.length<2)throw 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(f0(K,Q));break;case"L":if(G.length<2)throw Error(`pathToPolygon: L command requires 2 arguments, got ${G.length}`);K=U0(G[0]),Q=U0(G[1]),Z.push(f0(K,Q));break;case"l":if(G.length<2)throw Error(`pathToPolygon: l command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),Z.push(f0(K,Q));break;case"H":if(G.length<1)throw Error(`pathToPolygon: H command requires 1 argument, got ${G.length}`);K=U0(G[0]),Z.push(f0(K,Q));break;case"h":if(G.length<1)throw Error(`pathToPolygon: h command requires 1 argument, got ${G.length}`);K=K.plus(G[0]),Z.push(f0(K,Q));break;case"V":if(G.length<1)throw Error(`pathToPolygon: V command requires 1 argument, got ${G.length}`);Q=U0(G[0]),Z.push(f0(K,Q));break;case"v":if(G.length<1)throw Error(`pathToPolygon: v command requires 1 argument, got ${G.length}`);Q=Q.plus(G[0]),Z.push(f0(K,Q));break;case"C":if(G.length<6)throw Error(`pathToPolygon: C command requires 6 arguments, got ${G.length}`);iJ(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 Error(`pathToPolygon: c command requires 6 arguments, got ${G.length}`);iJ(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 Error(`pathToPolygon: Q command requires 4 arguments, got ${G.length}`);rJ(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 Error(`pathToPolygon: q command requires 4 arguments, got ${G.length}`);rJ(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 Error(`pathToPolygon: A command requires 7 arguments, got ${G.length}`);aJ(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 Error(`pathToPolygon: a command requires 7 arguments, got ${G.length}`);aJ(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 eq(Z)}function tq($){if(typeof $!=="string")throw 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,z=q.length>0?Array.from(q.matchAll(H),(j)=>Number(j[0])):[];J.push({type:Q,args:z})}return J}function iJ($,J,Z,K,Q,q,H,z,j,W){if(!Array.isArray($))throw Error("sampleCubicBezier: points must be an array");if(typeof W!=="number"||W<=0||!Number.isFinite(W))throw Error(`sampleCubicBezier: samples must be a positive finite number, got ${W}`);if(!(J instanceof M)||!(Z instanceof M)||!(K instanceof M)||!(Q instanceof M)||!(q instanceof M)||!(H instanceof M)||!(z instanceof M)||!(j instanceof M))throw Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let G=1;G<=W;G++){let F=U0(G).div(W),_=U0(1).minus(F),U=_.mul(_),Y=U.mul(_),V=F.mul(F),O=V.mul(F),X=Y.mul(J).plus(U0(3).mul(U).mul(F).mul(K)).plus(U0(3).mul(_).mul(V).mul(q)).plus(O.mul(z)),k=Y.mul(Z).plus(U0(3).mul(U).mul(F).mul(Q)).plus(U0(3).mul(_).mul(V).mul(H)).plus(O.mul(j));$.push(f0(X,k))}}function rJ($,J,Z,K,Q,q,H,z){if(!Array.isArray($))throw Error("sampleQuadraticBezier: points must be an array");if(typeof z!=="number"||z<=0||!Number.isFinite(z))throw Error(`sampleQuadraticBezier: samples must be a positive finite number, got ${z}`);if(!(J instanceof M)||!(Z instanceof M)||!(K instanceof M)||!(Q instanceof M)||!(q instanceof M)||!(H instanceof M))throw Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let j=1;j<=z;j++){let W=U0(j).div(z),G=U0(1).minus(W),F=G.mul(G),_=W.mul(W),U=F.mul(J).plus(U0(2).mul(G).mul(W).mul(K)).plus(_.mul(q)),Y=F.mul(Z).plus(U0(2).mul(G).mul(W).mul(Q)).plus(_.mul(H));$.push(f0(U,Y))}}function aJ($,J,Z,K,Q,q,H,z,j,W,G){if(!Array.isArray($))throw Error("sampleArc: points must be an array");if(typeof G!=="number"||G<=0||!Number.isFinite(G))throw Error(`sampleArc: samples must be a positive finite number, got ${G}`);if(!(J instanceof M)||!(Z instanceof M)||!(K instanceof M)||!(Q instanceof M)||!(q instanceof M)||!(j instanceof M)||!(W instanceof M))throw Error("sampleArc: all coordinate and angle parameters must be Decimal instances");if(typeof H!=="number"||H!==0&&H!==1)throw Error(`sampleArc: largeArc must be 0 or 1, got ${H}`);if(typeof z!=="number"||z!==0&&z!==1)throw Error(`sampleArc: sweep must be 0 or 1, got ${z}`);if(K.eq(0)||Q.eq(0)){$.push(f0(j,W));return}let F=K.abs(),_=Q.abs(),U=q.mul(Math.PI).div(180),Y=U.cos(),V=U.sin(),O=J.minus(j).div(2),X=Z.minus(W).div(2),k=Y.mul(O).plus(V.mul(X)),w=Y.mul(X).minus(V.mul(O)),R=F.mul(F),I=_.mul(_),C=k.mul(k),v=w.mul(w),g=C.div(R).plus(v.div(I));if(g.gt(1)){let e=g.sqrt();F=F.mul(e),_=_.mul(e),R=F.mul(F),I=_.mul(_)}let T=R.mul(I).minus(R.mul(v)).minus(I.mul(C));if(T=T.div(R.mul(v).plus(I.mul(C))),T.lt(0))T=U0(0);if(T=T.sqrt(),H===z)T=T.neg();let u=T.mul(K).mul(w).div(Q),S=T.neg().mul(Q).mul(k).div(K),A=J.plus(j).div(2),y=Z.plus(W).div(2),p=Y.mul(u).minus(V.mul(S)).plus(A),m=V.mul(u).plus(Y.mul(S)).plus(y),B=k.minus(u).div(K),h=w.minus(S).div(Q),N=k.neg().minus(u).div(K),n=w.neg().minus(S).div(Q),o=B.mul(B).plus(h.mul(h)).sqrt();if(o.eq(0)){u$.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(f0(j,W));return}let s=M.acos(B.div(o));if(h.lt(0))s=s.neg();let q0=o.mul(N.mul(N).plus(n.mul(n)).sqrt());if(q0.eq(0)){u$.warn("sampleArc: degenerate arc - zero length, treating as single point"),$.push(f0(j,W));return}let f=M.acos(B.mul(N).plus(h.mul(n)).div(q0));if(B.mul(n).minus(h.mul(N)).lt(0))f=f.neg();let E=U0(Math.PI),t=E.mul(2);if(z&&f.lt(0))f=f.plus(t);else if(!z&&f.gt(0))f=f.minus(t);for(let e=1;e<=G;e++){let Q0=U0(e).div(G),V0=s.plus(f.mul(Q0)),N0=V0.cos(),h0=V0.sin(),r=Y.mul(K.mul(N0)).minus(V.mul(Q.mul(h0))).plus(p),J0=V.mul(K.mul(N0)).plus(Y.mul(Q.mul(h0))).plus(m);$.push(f0(r,J0))}}function eq($){if(!Array.isArray($))throw 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 C6($,J=null,Z=tJ,K=4){if(!$||typeof $!=="object")throw Error("shapeToPolygon: element must be an object");if(!$.type||typeof $.type!=="string")throw Error("shapeToPolygon: element.type must be a string");if(typeof Z!=="number"||Z<=0||!Number.isFinite(Z))throw Error(`shapeToPolygon: samples must be a positive finite number, got ${Z}`);if(typeof K!=="number"||K<=0||!Number.isFinite(K))throw Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${K}`);if(J!==null&&!(J instanceof z0))throw 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=AJ(U0($.cx||0),U0($.cy||0),U0($.r||0));break;case"ellipse":if(K>4)Q=I$($.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=EJ(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=TJ(U0($.x1||0),U0($.y1||0),U0($.x2||0),U0($.y2||0));break;case"polygon":Q=fJ($.points||"");break;case"polyline":Q=bJ($.points||"");break;case"path":Q=$.d||"";break;default:return[]}if($.transform){let q=aq($.transform);if(!(q instanceof z0))throw Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof q}`);Q=I6(Q,q)}if(J)Q=I6(Q,J);return Q6(Q,Z)}function f9($,J=6){if(!Array.isArray($))throw Error("polygonToPathData: polygon must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw Error(`polygonToPathData: precision must be a non-negative finite number, got ${J}`);if($.length<2)return"";let Z=(Q)=>(Q instanceof M?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"}M.set({precision:80});M.set({precision:80});var eJ=($)=>$ instanceof M?$:new M($),$5=-0.1,J5=-0.1,Z5=1.2,K5=1.2,g$={LUMINANCE:"luminance",ALPHA:"alpha"};function Q5($){if(!$)throw Error("parseMaskElement: maskElement is required");if(!$.getAttribute)throw 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 $H($,J,Z,K=20){if(!$)throw Error("maskChildToPolygon: child is required");if(!J)throw Error("maskChildToPolygon: targetBBox is required");if(!Z)throw Error("maskChildToPolygon: contentUnits is required");if(typeof K!=="number"||K<=0)throw 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 Error("maskChildToPolygon: targetBBox must have numeric x, y, width, height properties");if(J.width<0||J.height<0)throw Error("maskChildToPolygon: targetBBox width and height cannot be negative");let Q={type:$.type,...$,transform:$.transform},q=C6(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:eJ(J.x).plus(H.x.mul(J.width)),y:eJ(J.y).plus(H.y.mul(J.height))}))}return q}function JH($){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),z=parseInt(J[3],10);if(isNaN(q)||isNaN(H)||isNaN(z))return 0;let j=Math.max(0,Math.min(255,q))/255,W=Math.max(0,Math.min(255,H))/255,G=Math.max(0,Math.min(255,z))/255,F=0.2126*j+0.7152*W+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),z=parseInt(q.slice(2,4),16),j=parseInt(q.slice(4,6),16);if(isNaN(H)||isNaN(z)||isNaN(j))return 0;let W=0.2126*(H/255)+0.7152*(z/255)+0.0722*(j/255);return isNaN(W)?0:W}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 ZH($,J){if(!$)throw Error("getMaskChildOpacity: child is required");if(!J)throw Error("getMaskChildOpacity: maskType is required");if(J!==g$.LUMINANCE&&J!==g$.ALPHA)throw 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===g$.ALPHA)return Q;let q=JH($.fill),H=Q*q;return isNaN(H)?0:H}function KH($,J,Z={}){if(!$)throw Error("resolveMask: maskData is required");if(!J)throw Error("resolveMask: targetBBox is required");if(!Array.isArray($.children))throw Error("resolveMask: maskData.children must be an array");let{samples:K=20}=Z;if(typeof K!=="number"||K<=0)throw Error("resolveMask: samples must be a positive number");let Q=$.maskType||g$.LUMINANCE,q=[];for(let H of $.children){if(!H)continue;let z=$H(H,J,$.maskContentUnits,K);if(z.length>=3){let j=ZH(H,Q);q.push({polygon:z,opacity:j})}}return q}function QH($,J,Z=0.5,K={}){if(!$)throw Error("maskToClipPath: maskData is required");if(!J)throw Error("maskToClipPath: targetBBox is required");if(typeof Z!=="number"||Z<0||Z>1)throw Error("maskToClipPath: opacityThreshold must be a number between 0 and 1");let Q=KH($,J,K),q=[];for(let{polygon:H,opacity:z}of Q)if(z>=Z&&H&&H.length>=3)if(q.length===0)q=H;else{let j=F6(q,H);if(j.length>0&&j[0].length>=3)q=j[0]}return q}function q5($,J,Z={}){if(!$)throw Error("maskToPathData: maskData is required");if(!J)throw Error("maskToPathData: targetBBox is required");let K=QH($,J,0.5,Z);if(K.length<3)return"";let Q="",q=0;for(let H=0;H<K.length;H++){let z=K[H];if(!z||z.x===void 0||z.y===void 0)continue;let j=Number(z.x),W=Number(z.y);if(isNaN(j)||isNaN(W)||!isFinite(j)||!isFinite(W))continue;let G=j.toFixed(6),F=W.toFixed(6);Q+=q===0?`M ${G} ${F}`:` L ${G} ${F}`,q++}if(q>=3)Q+=" Z";else return"";return Q}M.set({precision:80});function H5($){if(!$)throw Error("parseUseElement: useElement is required");let J=$.getAttribute("href")||$.getAttribute("xlink:href")||"",Z=J.startsWith("#")?J.slice(1):J;if(!Z)throw 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 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 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 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:W5($)}}function z5($){if(!$)throw 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 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(x$(Q));return K}function x$($){if(!$||!$.tagName)throw Error("parseChildElement: element with tagName is required");let J=$.tagName.toLowerCase(),Z={type:J,id:$.getAttribute("id")||null,transform:$.getAttribute("transform")||null,style:W5($)},K=(Q,q="0")=>{let H=parseFloat($.getAttribute(Q)||q);if(isNaN(H)||!isFinite(H))throw 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(x$(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 W5($){if(!$)throw 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 HH($,J,Z,K="xMidYMid meet"){if(!$||!J||!Z)return z0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return z0.identity(3);let{width:Q,height:q,x:H,y:z}=$;if(!isFinite(Q)||!isFinite(q)||!isFinite(H)||!isFinite(z)||Q<=0||q<=0)return z0.identity(3);let j=K.trim().split(/\s+/),W=j[0]||"xMidYMid",G=j[1]||"meet";if(W==="none"){let k=J/Q,w=Z/q;return i0(-H*k,-z*w).mul(k7(k,w))}let F=J/Q,_=Z/q,U;if(G==="slice")U=Math.max(F,_);else U=Math.min(F,_);let Y=-H*U,V=-z*U,O=Q*U,X=q*U;if(W.includes("xMid"))Y+=(J-O)/2;else if(W.includes("xMax"))Y+=J-O;if(W.includes("YMid"))V+=(Z-X)/2;else if(W.includes("YMax"))V+=Z-X;return i0(Y,V).mul(k7(U,U))}function S9($,J,Z={}){if(!$||!$.href)throw Error("resolveUse: useData with href property is required");if(!J)throw Error("resolveUse: defs map is required");if(typeof $.x!=="number"||isNaN($.x)||!isFinite($.x))throw Error("resolveUse: useData.x must be a valid finite number");if(typeof $.y!=="number"||isNaN($.y)||!isFinite($.y))throw Error("resolveUse: useData.y must be a valid finite number");if($.width!==null&&(typeof $.width!=="number"||isNaN($.width)||!isFinite($.width)||$.width<=0))throw 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 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 Error("resolveUse: useData.style must be null, undefined, or a valid non-array object")}if($.transform!==null&&$.transform!==void 0&&typeof $.transform!=="string")throw Error("resolveUse: useData.transform must be null, undefined, or a string");if(Z&&typeof Z!=="object")throw 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 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=i0($.x,$.y);if($.transform){let W=U7($.transform);H=H.mul(W)}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 Error("resolveUse: target.viewBoxParsed must have finite x, y and positive finite width, height");let W=$.width!==null?$.width:q.viewBoxParsed.width,G=$.height!==null?$.height:q.viewBoxParsed.height;H=HH(q.viewBoxParsed,W,G,q.preserveAspectRatio||"xMidYMid meet").mul(H)}let z=[],j=q.children&&Array.isArray(q.children)&&q.children.length>0?q.children:[q];for(let W of j)if(W.type==="use"){if(K<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${W.href}', skipping nested resolution`);continue}let G=S9(W,J,{maxDepth:K-1,_visited:Q});if(G)z.push(G)}else z.push({element:W,transform:z0.identity(3)});return Q.delete($.href),{element:q,transform:H,children:z,inheritedStyle:$.style}}function j5($,J=20){let Z=[];if(!$)return Z;if(typeof J!=="number"||J<=0||!isFinite(J))throw 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 z of H)z.polygon=z.polygon.map((j)=>{let[W,G]=p0($.transform,j.x,j.y);return{x:W,y:G}}),Z.push(z)}else{let H=zH(q,Q,J);if(H.length>=3)Z.push({polygon:H,style:WH($.inheritedStyle,q.style)})}}return Z}function zH($,J,Z=20){if(!$)throw Error("elementToPolygon: element is required");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw Error("elementToPolygon: samples must be a positive finite number");let K=C6($,null,Z);if(J&&K.length>0)K=K.map((Q)=>{let[q,H]=p0(J,Q.x,Q.y);return{x:q,y:H}});return K}function WH($,J){if(!J||typeof J!=="object"||Array.isArray(J))throw Error("mergeStyles: element must be a valid non-array object");let Z={...J};if($!==null&&$!==void 0){if(typeof $!=="object"||Array.isArray($))throw 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 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 z=Q[H],j=Number(z.x),W=Number(z.y);if(isNaN(j)||isNaN(W))continue;q+=H===0?`M ${j.toFixed(6)} ${W.toFixed(6)}`:` L ${j.toFixed(6)} ${W.toFixed(6)}`}q+=" Z",K.push(q)}return K.join(" ")}M.set({precision:80});var H7=($)=>$ instanceof M?$:new M($);function F5($){if(!$)throw Error("parsePatternElement: patternElement is required");if(typeof $.getAttribute!=="function")throw 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 GH($,J){if(!$)throw Error("getPatternTile: patternData is required");if(!J)throw Error("getPatternTile: targetBBox is required");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw 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 Error("getPatternTile: patternData must have numeric x, y, width, and height properties");if($.patternUnits==="objectBoundingBox")return{x:H7(J.x).plus(H7($.x).mul(J.width)),y:H7(J.y).plus(H7($.y).mul(J.height)),width:H7($.width).mul(J.width),height:H7($.height).mul(J.height)};return{x:H7($.x),y:H7($.y),width:H7($.width),height:H7($.height)}}function FH($,J,Z){if(!$)throw Error("getPatternContentTransform: patternData is required");if(!J)throw Error("getPatternContentTransform: tile is required");if(!Z)throw Error("getPatternContentTransform: targetBBox is required");if(!J.width||!J.height)throw 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 Error("getPatternContentTransform: targetBBox must have numeric x, y, width, and height properties");let K=z0.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 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 Error("getPatternContentTransform: tile width and height must be non-zero when viewBox is present");if(Q.width===0||Q.height===0)throw Error("getPatternContentTransform: viewBox width and height must be non-zero");let z=q/Q.width,j=H/Q.height,W=Math.min(z,j);if(!isFinite(W))throw Error("getPatternContentTransform: computed scale is not finite");let G=(q-Q.width*W)/2,F=(H-Q.height*W)/2;K=K.mul(i0(G-Q.x*W,F-Q.y*W)),K=K.mul(k7(W,W))}if($.patternContentUnits==="objectBoundingBox"){if(Z.width===0||Z.height===0)throw Error("getPatternContentTransform: targetBBox width and height must be non-zero when patternContentUnits is objectBoundingBox");K=K.mul(i0(Z.x,Z.y)),K=K.mul(k7(Z.width,Z.height))}return K}function _H($,J=null,Z=20){if(!$)throw Error("patternChildToPolygon: child is required");if(!$.type)throw Error("patternChildToPolygon: child must have a type property");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw Error("patternChildToPolygon: samples must be a positive finite number");let K={type:$.type,...$,transform:$.transform},Q=C6(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 Error("patternChildToPolygon: invalid polygon point - must have numeric x and y properties");let[H,z]=p0(J,q.x,q.y);return{x:H,y:z}});return Q}function UH($,J){if(!$)throw Error("getTilePositions: tile is required");if(!J)throw Error("getTilePositions: coverBBox is required");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw 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 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 Error("getTilePositions: tile dimensions must be finite numbers");if(q<=0||H<=0)return Z;let z=Math.floor((J.x-K)/q),j=Math.ceil((J.x+J.width-K)/q),W=Math.floor((J.y-Q)/H),G=Math.ceil((J.y+J.height-Q)/H);if(!isFinite(z)||!isFinite(j)||!isFinite(W)||!isFinite(G))throw Error("getTilePositions: computed tile indices are not finite");for(let F=z;F<j;F++)for(let _=W;_<G;_++)Z.push({x:H7(K).plus(H7(q).mul(F)),y:H7(Q).plus(H7(H).mul(_))});return Z}function VH($,J,Z={}){if(!$)throw Error("resolvePattern: patternData is required");if(!J)throw Error("resolvePattern: targetBBox is required");if(!Array.isArray($.children))throw Error("resolvePattern: patternData.children must be an array");let{samples:K=20,maxTiles:Q=1000}=Z,q=[],H=GH($,J);if(Number(H.width)<=0||Number(H.height)<=0)return q;let z=FH($,H,J),j=OH($.patternTransform),G=UH(H,J).slice(0,Q);for(let F of G){let _=i0(F.x,F.y);for(let U of $.children){let Y=j.mul(_.mul(z)),V=_H(U,Y,K);if(V.length>=3)q.push({polygon:V,fill:U.fill,stroke:U.stroke,strokeWidth:U.strokeWidth,opacity:U.opacity})}}return q}function MH($,J,Z={}){if(!$)throw Error("patternToClipPath: patternData is required");if(!J)throw Error("patternToClipPath: targetBBox is required");let K=VH($,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 z=F6(Q,q);if(Array.isArray(z)&&z.length>0&&Array.isArray(z[0])&&z[0].length>=3)Q=z[0]}return Q}function _5($,J,Z={}){if(!$)throw Error("patternToPathData: patternData is required");if(!J)throw Error("patternToPathData: targetBBox is required");let K=MH($,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 Error("patternToPathData: invalid polygon point - must have numeric x and y properties");if(!isFinite(H.x)||!isFinite(H.y))throw Error("patternToPathData: polygon point coordinates must be finite numbers");let z=Number(H.x).toFixed(6),j=Number(H.y).toFixed(6);Q+=q===0?`M ${z} ${j}`:` L ${z} ${j}`}return Q+=" Z",Q}function OH($){if(!$)return z0.identity(3);return(void 0)($)}M.set({precision:80});function v9($,J,Z,K=1,Q=!1){if(!$)throw Error("getMarkerTransform: markerDef is required");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw Error("getMarkerTransform: position must be an object with x and y numeric properties");if(typeof Z!=="number"||isNaN(Z)||!isFinite(Z))throw Error("getMarkerTransform: tangentAngle must be a valid finite number");if(typeof K!=="number"||isNaN(K)||K<=0)throw Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:q,markerHeight:H,refX:z,refY:j,orient:W,markerUnits:G,viewBox:F}=$;if(typeof q!=="number"||q<=0)throw Error("getMarkerTransform: markerDef.markerWidth must be a positive number");if(typeof H!=="number"||H<=0)throw Error("getMarkerTransform: markerDef.markerHeight must be a positive number");if(typeof z!=="number"||!isFinite(z))throw Error("getMarkerTransform: markerDef.refX must be a finite number");if(typeof j!=="number"||!isFinite(j))throw Error("getMarkerTransform: markerDef.refY must be a finite number");let _=z0.identity(3),U=i0(J.x,J.y);_=_.mul(U);let Y=0;if(W==="auto")Y=Z;else if(W==="auto-start-reverse")Y=Q?Z+Math.PI:Z;else if(typeof W==="number")Y=W*(Math.PI/180);if(Y!==0){let k=W6(Y);_=_.mul(k)}let V=1,O=1;if(G==="strokeWidth")V=K,O=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 C=Math.min(R,I);V*=C,O*=C;let v=i0(-F.x,-F.y);_=_.mul(v)}}}if(V!==1||O!==1){let k=k7(V,O);_=_.mul(k)}let X=i0(-z,-j);return _=_.mul(X),_}function XH($){if(typeof $!=="string")throw Error("getPathVertices: pathData must be a string");let J=[],Z=0,K=0,Q=0,q=0,H=U5($);for(let z=0;z<H.length;z++){let j=H[z],W=Z,G=K;switch(j.type){case"M":if(Z=j.x,K=j.y,Q=Z,q=K,J.length>0){let F=J[J.length-1],_=Math.atan2(K-G,Z-W);F.tangentOut=_}J.push({x:Z,y:K,tangentIn:0,tangentOut:0,index:J.length});break;case"L":{Z=j.x,K=j.y;let F=Z-W,_=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=j.x,K=j.y;let F=j.x1-W,_=j.y1-G,U=F===0&&_===0?Math.atan2(j.y2-G,j.x2-W):Math.atan2(_,F),Y=Z-j.x2,V=K-j.y2,O=Y===0&&V===0?Math.atan2(K-j.y1,Z-j.x1):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:O,tangentOut:O,index:J.length});break}case"Q":{Z=j.x,K=j.y;let F=j.x1-W,_=j.y1-G,U=F===0&&_===0?Math.atan2(K-G,Z-W):Math.atan2(_,F),Y=Z-j.x1,V=K-j.y1,O=Y===0&&V===0?Math.atan2(K-G,Z-W):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:O,tangentOut:O,index:J.length});break}case"A":{Z=j.x,K=j.y;let F=Z-W,_=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-W,_=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 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 z=0,j=0,W=0,G=(F,_)=>{if(F>=q.length)throw Error(`parsePathCommands: missing ${_} parameter at token ${F}`);let U=parseFloat(q[F]);if(isNaN(U)||!isFinite(U))throw Error(`parsePathCommands: invalid ${_} value "${q[F]}" at token ${F}`);return U};while(z<q.length){let F=q[z];switch(F.toUpperCase()){case"M":{let _=G(z+1,"M.x"),U=G(z+2,"M.y");J.push({type:"M",x:F==="M"?_:j+_,y:F==="M"?U:W+U}),j=J[J.length-1].x,W=J[J.length-1].y,z+=3;break}case"L":{let _=G(z+1,"L.x"),U=G(z+2,"L.y");J.push({type:"L",x:F==="L"?_:j+_,y:F==="L"?U:W+U}),j=J[J.length-1].x,W=J[J.length-1].y,z+=3;break}case"H":{let _=G(z+1,"H.x");J.push({type:"L",x:F==="H"?_:j+_,y:W}),j=J[J.length-1].x,z+=2;break}case"V":{let _=G(z+1,"V.y");J.push({type:"L",x:j,y:F==="V"?_:W+_}),W=J[J.length-1].y,z+=2;break}case"C":{let _=G(z+1,"C.x1"),U=G(z+2,"C.y1"),Y=G(z+3,"C.x2"),V=G(z+4,"C.y2"),O=G(z+5,"C.x"),X=G(z+6,"C.y");J.push({type:"C",x1:F==="C"?_:j+_,y1:F==="C"?U:W+U,x2:F==="C"?Y:j+Y,y2:F==="C"?V:W+V,x:F==="C"?O:j+O,y:F==="C"?X:W+X}),j=J[J.length-1].x,W=J[J.length-1].y,z+=7;break}case"Q":{let _=G(z+1,"Q.x1"),U=G(z+2,"Q.y1"),Y=G(z+3,"Q.x"),V=G(z+4,"Q.y");J.push({type:"Q",x1:F==="Q"?_:j+_,y1:F==="Q"?U:W+U,x:F==="Q"?Y:j+Y,y:F==="Q"?V:W+V}),j=J[J.length-1].x,W=J[J.length-1].y,z+=5;break}case"A":{let _=G(z+1,"A.rx"),U=G(z+2,"A.ry"),Y=G(z+3,"A.rotation");if(z+4>=q.length||z+5>=q.length)throw Error("parsePathCommands: missing arc flag parameters");let V=parseInt(q[z+4],10),O=parseInt(q[z+5],10);if(isNaN(V)||isNaN(O))throw Error("parsePathCommands: invalid arc flag values");let X=G(z+6,"A.x"),k=G(z+7,"A.y");J.push({type:"A",rx:_,ry:U,xAxisRotation:Y,largeArcFlag:V,sweepFlag:O,x:F==="A"?X:j+X,y:F==="A"?k:W+k}),j=J[J.length-1].x,W=J[J.length-1].y,z+=8;break}case"Z":J.push({type:"Z"}),z+=1;break;default:z+=1}}return J}function V5($,J){if(!$)throw Error("resolveMarkers: pathElement is required");if(!J||typeof J!=="object")throw 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",z=parseFloat(H);if(isNaN(z)||z<=0)throw Error("resolveMarkers: stroke-width must be a positive number");let j=$.getAttribute("d")||"",W=XH(j);if(W.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(_&&W.length>0){let U=W[0],Y=W.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:v9(_,{x:U.x,y:U.y},Y,z,!0),type:"start",vertex:U})}}if(Q&&W.length>2){let F=G(Q),_=F?J[F]:null;if(_)for(let U=1;U<W.length-1;U++){let Y=W[U],V=Y.tangentIn,X=Y.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:Y.x,y:Y.y},transform:v9(_,{x:Y.x,y:Y.y},k,z,!1),type:"mid",vertex:Y})}}if(q){let F=G(q),_=F?J[F]:null;if(_&&W.length>0){let U=W[W.length-1],Y=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:v9(_,{x:U.x,y:U.y},Y,z,!1),type:"end",vertex:U})}}return Z}function kH($,J={}){if(!$)throw Error("markerToPolygons: markerInstance is required");if(!$.markerDef)throw Error("markerToPolygons: markerInstance.markerDef is required");if(!$.transform)throw Error("markerToPolygons: markerInstance.transform is required");let{precision:Z=2,curveSegments:K=10}=J;if(typeof Z!=="number"||Z<0)throw Error("markerToPolygons: precision must be a non-negative number");if(typeof K!=="number"||K<=0)throw Error("markerToPolygons: curveSegments must be a positive number");let Q=[],{markerDef:q,transform:H}=$;if(!Array.isArray(q.children))throw Error("markerToPolygons: markerDef.children must be an array");for(let z of q.children){let j=[];switch(z.type){case"path":j=wH(z.d,K);break;case"rect":j=[{x:z.x,y:z.y},{x:z.x+z.width,y:z.y},{x:z.x+z.width,y:z.y+z.height},{x:z.x,y:z.y+z.height}];break;case"circle":j=LH(z.cx,z.cy,z.r,K*4);break;case"ellipse":j=RH(z.cx,z.cy,z.rx,z.ry,K*4);break;case"line":j=[{x:z.x1,y:z.y1},{x:z.x2,y:z.y2}];break;case"polygon":case"polyline":j=BH(z.points);break;default:break}if(j.length>0){let W=j.map((G)=>{let F=p0(H,G.x,G.y);return{x:parseFloat(F[0].toFixed(Z)),y:parseFloat(F[1].toFixed(Z))}});Q.push(W)}}return Q}function wH($,J=10){if(typeof $!=="string")throw Error("pathToPoints: pathData must be a string");if(typeof J!=="number"||J<=0)throw 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 z=1;z<=J;z++){let j=z/J,W=1-j,G=W*W*W*Q+3*W*W*j*H.x1+3*W*j*j*H.x2+j*j*j*H.x,F=W*W*W*q+3*W*W*j*H.y1+3*W*j*j*H.y2+j*j*j*H.y;Z.push({x:G,y:F})}Q=H.x,q=H.y;break;case"Q":for(let z=1;z<=J;z++){let j=z/J,W=1-j,G=W*W*Q+2*W*j*H.x1+j*j*H.x,F=W*W*q+2*W*j*H.y1+j*j*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 LH($,J,Z,K=32){if(typeof $!=="number"||!isFinite($))throw Error("circleToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw Error("circleToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw Error("circleToPoints: r must be a non-negative finite number");if(typeof K!=="number"||K<=0)throw 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 RH($,J,Z,K,Q=32){if(typeof $!=="number"||!isFinite($))throw Error("ellipseToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw Error("ellipseToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw Error("ellipseToPoints: rx must be a non-negative finite number");if(typeof K!=="number"||!isFinite(K)||K<0)throw Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof Q!=="number"||Q<=0)throw Error("ellipseToPoints: segments must be a positive number");let q=[];for(let H=0;H<Q;H++){let z=H/Q*2*Math.PI;q.push({x:$+Z*Math.cos(z),y:J+K*Math.sin(z)})}return q}function BH($){if(typeof $!=="string")throw 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 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 M5($,J=2){if(!Array.isArray($))throw Error("markersToPathData: markerInstances must be an array");if(typeof J!=="number"||J<0)throw Error("markersToPathData: precision must be a non-negative number");let Z=[];for(let K of $){let Q=kH(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 z=1;z<q.length;z++){let j=q[z];Z.push(`L ${j.x.toFixed(J)} ${j.y.toFixed(J)}`)}Z.push("Z")}}return Z.join(" ")}M.set({precision:80});var k0=($)=>$ instanceof M?$:new M($),a0=new M(0),A6=new M(1);function E6(){let $=M.precision;if($<20)throw Error(`Decimal precision (${$}) is too low for verification. Minimum required: 20`);let J=Math.max(1,$-10);return new M(10).pow(-J)}function k5($,J,Z){let K=E6();if(!$)return{valid:!1,error:new M(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};if(J==null||Z==null)return{valid:!1,error:new M(1/0),tolerance:K,message:"Coordinates x or y are null or undefined"};let Q=k0(J),q=k0(Z);try{let[H,z]=p0($,Q,q),j=$.inverse();if(!j)return{valid:!1,error:new M(1/0),tolerance:K,message:"Matrix is not invertible (determinant = 0)",details:{determinant:$.determinant()}};let[W,G]=p0(j,H,z),F=Q.minus(W).abs(),_=q.minus(G).abs(),U=M.max(F,_),Y=U.lessThan(K);return{valid:Y,error:U,tolerance:K,message:Y?`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:z.toString()},recovered:{x:W.toString(),y:G.toString()},errorX:F.toExponential(),errorY:_.toExponential()}}}catch(H){return{valid:!1,error:new M(1/0),tolerance:K,message:`Verification error: ${H.message}`}}}function D9($){let J=E6();if(!$)return{valid:!1,error:new M(1/0),tolerance:J,message:"Matrix parameter is null or undefined"};try{let Z=$.inverse();if(!Z)return{valid:!1,error:new M(1/0),tolerance:J,message:"Matrix is singular (not invertible)",details:{determinant:$.determinant().toString()}};let K=$.mul(Z),Q=$.rows,q=a0,H=[];for(let j=0;j<Q;j++)for(let W=0;W<Q;W++){let G=j===W?A6:a0,F=K.data[j][W],_=F.minus(G).abs();if(_.greaterThan(q))q=_;if(_.greaterThanOrEqualTo(J))H.push({row:j,col:W,expected:G.toString(),actual:F.toString(),error:_.toExponential()})}let z=q.lessThan(J);return{valid:z,error:q,tolerance:J,message:z?`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 M(1/0),tolerance:J,message:`Verification error: ${Z.message}`}}}function O5($,J,Z=null){let K=E6(),Q=Z||new M("1e-6");if(!$||!Array.isArray($))return{valid:!1,error:a0,tolerance:K,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:a0,tolerance:K,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:a0,tolerance:K,message:"Polygons must have at least 3 vertices"};try{let q=!0,H=[],z=a0;for(let j=0;j<$.length;j++){let W=$[j];if(!CH(W,J)){let G=IH(W,J);if(G.greaterThan(z))z=G;if(G.greaterThan(Q))q=!1,H.push({index:j,x:W.x.toString(),y:W.y.toString(),distanceOutside:G.toExponential()})}}return{valid:q,error:z,tolerance:Q,message:q?`All inner polygon points are inside or within tolerance (max outside: ${z.toExponential()})`:`${H.length} points exceed tolerance distance outside outer polygon`,details:{innerVertices:$.length,outerVertices:J.length,maxOutsideDistance:z.toExponential(),outsidePoints:H.slice(0,5)}}}catch(q){return{valid:!1,error:new M(1/0),tolerance:K,message:`Verification error: ${q.message}`}}}function IH($,J){if(!$||$.x==null||$.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw Error("Invalid polygon parameter: must be non-empty array of points");let Z=new M(1/0),K=k0($.x),Q=k0($.y);for(let q=0;q<J.length;q++){let H=(q+1)%J.length,z=J[q],j=J[H],W=k0(z.x),G=k0(z.y),F=k0(j.x),_=k0(j.y),U=F.minus(W),Y=_.minus(G),V=U.times(U).plus(Y.times(Y)),O;if(V.isZero())O=R5($,z);else{let X=M.max(a0,M.min(A6,K.minus(W).times(U).plus(Q.minus(G).times(Y)).div(V))),k=W.plus(X.times(U)),w=G.plus(X.times(Y));O=K.minus(k).pow(2).plus(Q.minus(w).pow(2)).sqrt()}if(O.lessThan(Z))Z=O}return Z}function w5($,J,Z){let K=E6();if(!$||!Array.isArray($))return{valid:!1,error:a0,tolerance:K,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:a0,tolerance:K,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:a0,tolerance:K,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:a0,tolerance:K,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:Z.length}};try{let Q=O5(Z,$),q=O5(Z,J),H=r6($),z=r6(J),j=r6(Z),W=M.min(H,z),G=j.lessThanOrEqualTo(W.times(A6.plus(K))),F=Q.valid&&q.valid&&G;return{valid:F,error:F?a0:A6,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:z.toString(),intersectionArea:j.toString(),areaValid:G}}}catch(Q){return{valid:!1,error:new M(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function L5($,J,Z){let K=E6();if(!$||typeof $!=="object")return{valid:!1,error:new M(1/0),tolerance:K,message:"Original gradient parameter must be an object"};if(!J||typeof J!=="object")return{valid:!1,error:new M(1/0),tolerance:K,message:"Baked gradient parameter must be an object"};if(!Z)return{valid:!1,error:new M(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};try{let[Q,q]=p0(Z,k0($.x1||0),k0($.y1||0)),[H,z]=p0(Z,k0($.x2||1),k0($.y2||0)),j=k0(J.x1).minus(Q).abs(),W=k0(J.y1).minus(q).abs(),G=k0(J.x2).minus(H).abs(),F=k0(J.y2).minus(z).abs(),_=M.max(j,W,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:z.toString()},actual:J}}}catch(Q){return{valid:!1,error:new M(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function r6($){if(!$||!Array.isArray($))throw Error("Invalid polygon parameter: must be an array");if($.length<3)return a0;let J=a0,Z=$.length;for(let K=0;K<Z;K++){let Q=(K+1)%Z,q=k0($[K].x),H=k0($[K].y),z=k0($[Q].x),j=k0($[Q].y);J=J.plus(q.times(j).minus(z.times(H)))}return J.abs().div(2)}function CH($,J){if(!$||$.x==null||$.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw 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,z=Q-1;H<Q;z=H++){let j=k0(J[H].x),W=k0(J[H].y),G=k0(J[z].x),F=k0(J[z].y);if(PH($,J[H],J[z]))return!0;if(W.greaterThan(K)!==F.greaterThan(K)&&Z.lessThan(G.minus(j).times(K.minus(W)).div(F.minus(W)).plus(j)))q=!q}return q}function PH($,J,Z){if(!$||$.x==null||$.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw Error("Invalid segStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw Error("Invalid segEnd parameter: must have x and y properties");let K=E6(),Q=k0($.x),q=k0($.y),H=k0(J.x),z=k0(J.y),j=k0(Z.x),W=k0(Z.y),G=M.min(H,j).minus(K),F=M.max(H,j).plus(K),_=M.min(z,W).minus(K),U=M.max(z,W).plus(K);if(Q.lessThan(G)||Q.greaterThan(F)||q.lessThan(_)||q.greaterThan(U))return!1;let Y=j.minus(H).times(q.minus(z)).minus(W.minus(z).times(Q.minus(H))).abs(),V=R5(J,Z);return Y.div(V.plus(K)).lessThan(K)}function R5($,J){if(!$||$.x==null||$.y==null)throw Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw 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 z=0;z<$.length;z++){let j=$[z],W=$[(z+1)%$.length],G=!Y5(j,Q,q),F=!Y5(W,Q,q);if(G){if(H.push(j),!F)H.push(X5(j,W,Q,q))}else if(F)H.push(X5(j,W,Q,q))}if(H.length>=3)Z.push(H)}return Z}function N5($,J,Z=[],K="1e-10"){let Q=K instanceof M?K:new M(K),q=Z||[];if(!$||!Array.isArray($))return{valid:!1,error:new M(1/0),tolerance:Q,message:"Original polygon parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:new M(1/0),tolerance:Q,message:"Clipped polygon parameter must be an array"};try{let H=r6($),z=J.length>=3?r6(J):a0,j=H.minus(z),W=z.lessThanOrEqualTo(H.times(A6.plus(Q))),G=j.greaterThanOrEqualTo(a0.minus(Q.times(H))),F=H.isZero()?A6:z.div(H),_=a0,U=W&&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:z.toString(),outsideArea:j.toString(),areaRatio:F.toFixed(6),fragmentCount:q.length,clippedValid:W,outsideValid:G}}}catch(H){return{valid:!1,error:new M(1/0),tolerance:Q,message:`E2E verification error: ${H.message}`}}}function Y5($,J,Z){if(!$||$.x==null||$.y==null)throw Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw Error("Invalid edgeStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw 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(),z=k0(Z.x).toNumber(),j=k0(Z.y).toNumber();return(z-q)*(Q-H)-(j-H)*(K-q)>=0}function X5($,J,Z,K){if(!$||$.x==null||$.y==null)throw Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw Error("Invalid p2 parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw Error("Invalid p3 parameter: must have x and y properties");if(!K||K.x==null||K.y==null)throw Error("Invalid p4 parameter: must have x and y properties");let Q=k0($.x).toNumber(),q=k0($.y).toNumber(),H=k0(J.x).toNumber(),z=k0(J.y).toNumber(),j=k0(Z.x).toNumber(),W=k0(Z.y).toNumber(),G=k0(K.x).toNumber(),F=k0(K.y).toNumber(),_=(Q-H)*(W-F)-(q-z)*(j-G);if(Math.abs(_)<0.0000000001)return{x:k0((Q+H)/2),y:k0((q+z)/2)};let U=((Q-j)*(W-F)-(q-W)*(j-G))/_;return{x:k0(Q+U*(H-Q)),y:k0(q+U*(z-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"],EH=["begin","end"],TH=["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 a6($){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 f5($){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 fH($){if(!$||typeof $!=="object"||!($ instanceof w0))throw TypeError("collectElementReferences: el must be a valid SVGElement");if(typeof $.getAttributeNames!=="function")throw 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 TypeError("collectElementReferences: getAttributeNames must return an array");for(let q of Q){let H=$.getAttribute(q);if(!H)continue;if(I5.includes(q)){let z=P5(H);if(z)if(K)J.animation.add(z);else J.static.add(z)}if(C5.includes(q)||q==="style"){let z=h9(H);if(z)J.static.add(z);if(q==="style")a6(H).forEach((j)=>J.css.add(j))}if(EH.includes(q))T5(H).forEach((z)=>J.animation.add(z));if(TH.includes(q))E5(H).forEach((z)=>J.animation.add(z));if(!C5.includes(q)&&H.includes("url(")){let z=h9(H);if(z)J.static.add(z)}}if(Z==="animatemotion"){if(typeof $.getElementsByTagName!=="function")throw TypeError("collectElementReferences: el must have getElementsByTagName method");let q=$.getElementsByTagName("mpath");if(!q||typeof q[Symbol.iterator]!=="function")throw TypeError("collectElementReferences: getElementsByTagName must return an iterable");for(let H of q){if(!H||typeof H.getAttribute!=="function")continue;for(let z of I5){let j=H.getAttribute(z),W=P5(j);if(W)J.animation.add(W)}}}return J}function b5($){if(!$||typeof $!=="object"||!($ instanceof w0))throw 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,z)=>{if(J.all.add(q),J[H].add(q),!J.details.has(q))J.details.set(q,{sources:[],type:H});else{let j=J.details.get(q);if(Z[H]>Z[j.type])j.type=H}J.details.get(q).sources.push(z)},Q=(q,H="")=>{let z=q.tagName?.toLowerCase()||"",j=H?`${H}>${z}`:z,W=q.getAttribute("id"),G=W?`${z}#${W}`:j,F=fH(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)),z==="style"){let _=q.textContent||"";a6(_).forEach((U)=>K(U,"css","<style>"))}if(z==="script"){let _=q.textContent||"";f5(_).forEach((U)=>K(U,"js","<script>"))}if(q.children&&typeof q.children[Symbol.iterator]==="function"){for(let _ of q.children)if(_ instanceof w0)Q(_,j)}};return Q($),J}M.set({precision:80});var B7=($)=>$ instanceof M?$:new M($),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 f6($,J={}){if($===null||$===void 0)throw Error("flattenSVG: svgString parameter is required");if(typeof $!=="string")throw Error(`flattenSVG: svgString must be a string, got ${typeof $}`);if($.trim().length===0)throw 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 Error("Root element must be <svg>");let q=D7(Q),H=Z.removeUnusedDefs?mH(Q):null;if(Z.resolveUse){let j=SH(Q,q,Z);K.useResolved=j.count,K.errors.push(...j.errors),q=D7(Q)}if(Z.resolveMarkers){let j=vH(Q,q,Z);K.markersResolved=j.count,K.errors.push(...j.errors)}if(Z.resolvePatterns){let j=DH(Q,q,Z);K.patternsResolved=j.count,K.errors.push(...j.errors)}if(Z.resolveMasks){let j=hH(Q,q,Z);K.masksResolved=j.count,K.errors.push(...j.errors)}if(Z.resolveClipPaths){let j=yH(Q,q,Z,K);K.clipPathsApplied=j.count,K.errors.push(...j.errors)}if(Z.flattenTransforms){let j=uH(Q,Z,K);K.transformsFlattened=j.count,K.errors.push(...j.errors)}if(Z.bakeGradients){let j=xH(Q,Z,K);K.gradientsProcessed=j.count,K.errors.push(...j.errors)}if(Z.removeUnusedDefs&&H){let j=dH(Q,H);K.defsRemoved=j.count}return{svg:Z7(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 SH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("resolveAllUseElements: invalid root element");if(!J||!(J instanceof Map))throw Error("resolveAllUseElements: defsMap must be a Map");if(!Z||typeof Z!=="object")throw Error("resolveAllUseElements: opts must be an object");let K=[],Q=0,q=$.getElementsByTagName("use"),H={};for(let[z,j]of J.entries())if(j.tagName.toLowerCase()==="symbol")H[z]=z5(j),H[z].type="symbol";else H[z]=x$(j);for(let z of[...q])try{let j=z.getAttribute("href")||z.getAttribute("xlink:href");if(!j)continue;let W=j.replace(/^#/,""),G=J.get(W);if(!G){K.push(`use: referenced element #${W} not found`);continue}let F=y9(G),_=y9(z);if(F||_){let O=G.cloneNode(!0),X=parseFloat(z.getAttribute("x")||"0"),k=parseFloat(z.getAttribute("y")||"0");if(isNaN(X)||isNaN(k)){K.push(`use: invalid x/y coordinates for element #${W}`);continue}let w=z.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 C=t6(z);for(let[g,T]of Object.entries(C))if(T&&!I.hasAttribute(g))I.setAttribute(g,T);if(G.tagName.toLowerCase()==="symbol"){for(let g of O.children||[])if(g&&g.tagName)I.appendChild(g.cloneNode(!0))}else O.removeAttribute("id"),I.appendChild(O);for(let g of z.children||[])if(g&&g.tagName){let T=g.tagName.toLowerCase();if(h5.has(T))I.appendChild(g.cloneNode(!0))}if(z.parentNode)z.parentNode.replaceChild(I,z),Q++;continue}let U=H5(z),Y=S9(U,H,{samples:Z.curveSegments});if(!Y){K.push(`use: failed to resolve #${W}`);continue}let V=G5(Y,Z.curveSegments);if(V){let O=new w0("path",{d:V,...t6(z)});if(Y.style){for(let[X,k]of Object.entries(Y.style))if(k&&!O.hasAttribute(X))O.setAttribute(X,k)}if(z.parentNode)z.parentNode.replaceChild(O,z),Q++}}catch(j){K.push(`use: ${j.message}`)}return{count:Q,errors:K}}function vH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("resolveAllMarkers: invalid root element");if(!J||!(J instanceof Map))throw Error("resolveAllMarkers: defsMap must be a Map");if(!Z||typeof Z!=="object")throw 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 z=A7($,H);for(let j of z){if(j.tagName!=="path"&&j.tagName!=="line"&&j.tagName!=="polyline"&&j.tagName!=="polygon")continue;try{let W=V5(j,Object.fromEntries(J));if(!W||W.length===0)continue;let G=M5(W,Z.precision);if(G){let F=new w0("path",{d:G,fill:j.getAttribute("stroke")||"currentColor"});if(j.parentNode){let _=j.nextSibling;if(_)j.parentNode.insertBefore(F,_);else j.parentNode.appendChild(F);Q++}}for(let F of q)j.removeAttribute(F)}catch(W){K.push(`marker: ${W.message}`)}}}return{count:Q,errors:K}}function DH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("resolveAllPatterns: invalid root element");if(!J||!(J instanceof Map))throw Error("resolveAllPatterns: defsMap must be a Map");if(!Z||typeof Z!=="object")throw Error("resolveAllPatterns: opts must be an object");let K=[],Q=0,q=A7($,"fill");for(let H of q){let z=H.getAttribute("fill");if(!z||!z.includes("url("))continue;let j=h7(z);if(!j)continue;let W=J.get(j);if(!W||W.tagName.toLowerCase()!=="pattern")continue;try{let G=W.getAttribute("patternUnits")||"objectBoundingBox",F=W.getAttribute("patternContentUnits")||"userSpaceOnUse",_=W.getAttribute("patternTransform");if(G!=="objectBoundingBox")K.push(`pattern ${j}: non-default patternUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`pattern ${j}: non-default patternContentUnits="${F}" may cause rendering issues`);if(_)K.push(`pattern ${j}: patternTransform present - complex transformation may cause rendering issues`);let U=u5(H);if(!U)continue;let Y=F5(W),V=_5(Y,U,{samples:Z.curveSegments});if(V){let O=new w0("g",{}),X=new w0("path",{d:V,fill:"#000"});if(O.appendChild(X),H.setAttribute("fill","none"),H.setAttribute("stroke",H.getAttribute("stroke")||"none"),H.parentNode)H.parentNode.insertBefore(O,H),Q++}}catch(G){K.push(`pattern: ${G.message}`)}}return{count:Q,errors:K}}function hH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("resolveAllMasks: invalid root element");if(!J||!(J instanceof Map))throw Error("resolveAllMasks: defsMap must be a Map");if(!Z||typeof Z!=="object")throw Error("resolveAllMasks: opts must be an object");let K=[],Q=0,q=A7($,"mask");for(let H of q){let z=H.getAttribute("mask");if(!z||!z.includes("url("))continue;let j=h7(z);if(!j)continue;let W=J.get(j);if(!W||W.tagName.toLowerCase()!=="mask")continue;try{let G=W.getAttribute("maskUnits")||"objectBoundingBox",F=W.getAttribute("maskContentUnits")||"userSpaceOnUse";if(G!=="objectBoundingBox")K.push(`mask ${j}: non-default maskUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`mask ${j}: non-default maskContentUnits="${F}" may cause rendering issues`);let _=u5(H);if(!_)continue;let U=Q5(W),Y=q5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(Y){let V=T6(H,Z.precision);if(V){let O=Q6(V,Z.curveSegments),X=Q6(Y,Z.curveSegments),k=g5(O,X);if(k&&k.length>2){let w=f9(k,Z.precision);H.setAttribute("d",w),H.removeAttribute("mask"),Q++}}}}catch(G){K.push(`mask: ${G.message}`)}}return{count:Q,errors:K}}function yH($,J,Z,K){if(!$||!$.getElementsByTagName)throw Error("applyAllClipPaths: invalid root element");if(!J||!(J instanceof Map))throw Error("applyAllClipPaths: defsMap must be a Map");if(!Z||typeof Z!=="object")throw Error("applyAllClipPaths: opts must be an object");if(!K||typeof K!=="object")throw 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=A7($,"clip-path");for(let z of H){let j=z.getAttribute("clip-path");if(!j||!j.includes("url("))continue;let W=h7(j);if(!W)continue;let G=J.get(W),F=G?G.tagName.toLowerCase():"";if(!G||F!=="clippath")continue;try{if((G.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")Q.push(`clipPath ${W}: objectBoundingBox units require bbox-relative coordinate transformation`);let U=T6(z,Z.precision);if(!U)continue;let Y="";if(G.children&&G.children.length>0){for(let I of G.children)if(I&&I.tagName){let C=T6(I,Z.precision);if(C)Y+=(Y?" ":"")+C}}if(!Y)continue;let V=Z.clipSegments||64,O=Q6(U,V),X=Q6(Y,V),k=g5(O,X),w=O.map((I)=>({x:I.x instanceof M?I.x:B7(I.x),y:I.y instanceof M?I.y:B7(I.y)})),R=X.map((I)=>({x:I.x instanceof M?I.x:B7(I.x),y:I.y instanceof M?I.y:B7(I.y)}));if(k&&k.length>2){let I=k.map((u)=>({x:u.x instanceof M?u.x:B7(u.x),y:u.y instanceof M?u.y:B7(u.y)})),C=w5(w,R,I);if(K.verifications.polygons.push({element:z.tagName,clipPathId:W,...C}),C.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let v=B5(w,R);K.clipOutsideFragments.push({elementId:z.getAttribute("id")||`clip-${q}`,clipPathId:W,fragments:v,visible:!1});let g=Z.e2eTolerance||"1e-10",T=N5(w,I,v,g);if(K.verifications.e2e.push({element:z.tagName,clipPathId:W,type:"clip-area-conservation",...T}),T.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1}if(k&&k.length>2){let I=f9(k,Z.precision),C=z;if(z.tagName==="path")z.setAttribute("d",I);else{let v=new w0("path",{d:I,...t6(z)});if(z.parentNode)z.parentNode.replaceChild(v,z),C=v}C.removeAttribute("clip-path"),q++}}catch(_){Q.push(`clipPath: ${_.message}`)}}return{count:q,errors:Q}}function uH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("flattenAllTransforms: invalid root element");if(!J||typeof J!=="object")throw Error("flattenAllTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw Error("flattenAllTransforms: stats must be an object");let K=[],Q=0,q=A7($,"transform");for(let H of q){let z=H.getAttribute("transform");if(!z)continue;try{let j=U7(z),W=D9(j);if(Z.verifications.matrices.push({element:H.tagName,transform:z,...W}),W.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;let G=T6(H,J.precision);if(!G){if(H.tagName==="g")gH(H,j,J,Z),H.removeAttribute("transform"),Q++;continue}let F=[],_=Q6(G,4);if(_&&_.length>0)F=_.slice(0,4).map((V)=>({x:V.x instanceof M?V.x:B7(V.x),y:V.y instanceof M?V.y:B7(V.y)}));let U=I6(G,j,{precision:J.precision});for(let V=0;V<F.length;V++){let O=F[V],X=k5(j,O.x,O.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 Y=H;if(H.tagName==="path")H.setAttribute("d",U);else{let V=new w0("path",{d:U,...t6(H)});for(let O of pH(H.tagName))V.removeAttribute(O);if(H.parentNode)H.parentNode.replaceChild(V,H),Y=V}Y.removeAttribute("transform"),Q++}catch(j){K.push(`transform: ${j.message}`)}}return{count:Q,errors:K}}function gH($,J,Z,K){if(!$||!$.children)throw Error("propagateTransformToChildren: invalid group element");if(!J||!J.data)throw Error("propagateTransformToChildren: invalid matrix");if(!Z||typeof Z!=="object")throw Error("propagateTransformToChildren: opts must be an object");if(!K||typeof K!=="object")throw 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=U7(q),z=J.mul(H);Q.setAttribute("transform",S5(z))}else Q.setAttribute("transform",S5(J))}else{let q=T6(Q,Z.precision);if(q){let H=Q.getAttribute("transform"),z=J;if(H){let F=U7(H);z=J.mul(F)}let j=D9(z);if(K.verifications.matrices.push({element:Q.tagName,context:"group-propagation",...j}),j.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let W=I6(q,z,{precision:Z.precision}),G=Q;if(Q.tagName==="path")Q.setAttribute("d",W);else{let F=new w0("path",{d:W,...t6(Q)});$.replaceChild(F,Q),G=F}G.removeAttribute("transform")}}}}function xH($,J,Z){if(!$||!$.getElementsByTagName)throw Error("bakeAllGradientTransforms: invalid root element");if(!J||typeof J!=="object")throw Error("bakeAllGradientTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw Error("bakeAllGradientTransforms: stats must be an object");let K=[],Q=0,q=$.getElementsByTagName("linearGradient");for(let z of q){let j=z.getAttribute("gradientTransform");if(!j)continue;try{let W=U7(j),G=parseFloat(z.getAttribute("x1")||"0"),F=parseFloat(z.getAttribute("y1")||"0"),_=parseFloat(z.getAttribute("x2")||"1"),U=parseFloat(z.getAttribute("y2")||"0");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)){K.push(`linearGradient: invalid coordinate values for gradient ${z.getAttribute("id")||"unknown"}`);continue}let[Y,V]=p0(W,G,F),[O,X]=p0(W,_,U),k=L5({x1:G,y1:F,x2:_,y2:U},{x1:Y.toNumber(),y1:V.toNumber(),x2:O.toNumber(),y2:X.toNumber()},W);if(Z.verifications.gradients.push({gradientId:z.getAttribute("id")||"unknown",type:"linear",...k}),k.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;z.setAttribute("x1",Y.toFixed(J.precision)),z.setAttribute("y1",V.toFixed(J.precision)),z.setAttribute("x2",O.toFixed(J.precision)),z.setAttribute("y2",X.toFixed(J.precision)),z.removeAttribute("gradientTransform"),Q++}catch(W){K.push(`linearGradient: ${W.message}`)}}let H=$.getElementsByTagName("radialGradient");for(let z of H){let j=z.getAttribute("gradientTransform");if(!j)continue;try{let W=U7(j),G=parseFloat(z.getAttribute("cx")||"0.5"),F=parseFloat(z.getAttribute("cy")||"0.5"),_=parseFloat(z.getAttribute("fx")||G.toString()),U=parseFloat(z.getAttribute("fy")||F.toString()),Y=parseFloat(z.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(Y)){K.push(`radialGradient: invalid coordinate/radius values for gradient ${z.getAttribute("id")||"unknown"}`);continue}if(Y<=0){K.push(`radialGradient: radius must be positive for gradient ${z.getAttribute("id")||"unknown"}`);continue}let[V,O]=p0(W,G,F),[X,k]=p0(W,_,U),w=W.data[0][0].toNumber()*W.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=Y*R;z.setAttribute("cx",V.toFixed(J.precision)),z.setAttribute("cy",O.toFixed(J.precision)),z.setAttribute("fx",X.toFixed(J.precision)),z.setAttribute("fy",k.toFixed(J.precision)),z.setAttribute("r",I.toFixed(J.precision)),z.removeAttribute("gradientTransform"),Q++}catch(W){K.push(`radialGradient: ${W.message}`)}}return{count:Q,errors:K}}function mH($){if(!$||!$.getElementsByTagName)throw 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)a6(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=h7(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 dH($,J){if(!$||!$.getElementsByTagName)throw Error("removeUnusedDefinitions: invalid root element");if(!J||!(J instanceof Set))throw 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 z of q.children||[])if(z&&z.tagName&&K(z))return!0;return!1}let Q=$.getElementsByTagName("defs");for(let q of Q)for(let H of[...q.children])if(H&&H.tagName){let z=H.tagName.toLowerCase();if(y5.has(z))continue;if(!K(H))q.removeChild(H),Z++}return{count:Z}}function T6($,J){if(!$||!$.tagName)return null;if(typeof J!=="number"||isNaN(J)||J<0)throw 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 z=parseFloat(H);if(isNaN(z))throw Error(`getElementPathData: invalid numeric value "${H}" for attribute "${Q}"`);return z};switch(Z){case"rect":{let q=$.getAttribute("ry")!==null?K("ry"):null;return A$(K("x"),K("y"),K("width"),K("height"),K("rx"),q,!1,J)}case"circle":return C$(K("cx"),K("cy"),K("r"),J);case"ellipse":return P$(K("cx"),K("cy"),K("rx"),K("ry"),J);case"line":return E$(K("x1"),K("y1"),K("x2"),K("y2"),J);case"polyline":return d6($.getAttribute("points")||"",J);case"polygon":return T$($.getAttribute("points")||"",J);default:return null}}function u5($){if(!$||!$.tagName)return null;let J=T6($,6);if(!J)return null;try{let Z=Q6(J,10);if(!Z||Z.length===0)return null;let K=1/0,Q=1/0,q=-1/0,H=-1/0;for(let z of Z){if(!z||z.x===void 0&&z.y===void 0)continue;let j=z.x instanceof M?z.x.toNumber():typeof z.x==="number"?z.x:0,W=z.y instanceof M?z.y.toNumber():typeof z.y==="number"?z.y:0;if(isNaN(j)||isNaN(W))continue;if(j<K)K=j;if(W<Q)Q=W;if(j>q)q=j;if(W>H)H=W}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 t6($){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 pH($){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 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 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 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(P7&&S7)try{return S7($,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 z=0;z<Q.length;z++){let j=Q[z],W=Q[(z+1)%Q.length],G=v5(j,q,H),F=v5(W,q,H);if(G){if(Z.push(j),!F)Z.push(D5(j,W,q,H))}else if(F)Z.push(D5(j,W,q,H))}}return Z}function v5($,J,Z){if(!$||$.x===void 0&&$.y===void 0)throw Error("isInsideEdge: invalid point");if(!J||J.x===void 0&&J.y===void 0)throw Error("isInsideEdge: invalid edgeStart");if(!Z||Z.x===void 0&&Z.y===void 0)throw Error("isInsideEdge: invalid edgeEnd");let K=$.x instanceof M?$.x.toNumber():$.x||0,Q=$.y instanceof M?$.y.toNumber():$.y||0,q=J.x instanceof M?J.x.toNumber():J.x||0,H=J.y instanceof M?J.y.toNumber():J.y||0,z=Z.x instanceof M?Z.x.toNumber():Z.x||0,j=Z.y instanceof M?Z.y.toNumber():Z.y||0;return(z-q)*(Q-H)-(j-H)*(K-q)>=0}function D5($,J,Z,K){if(!$||$.x===void 0&&$.y===void 0)throw Error("lineIntersect: invalid p1");if(!J||J.x===void 0&&J.y===void 0)throw Error("lineIntersect: invalid p2");if(!Z||Z.x===void 0&&Z.y===void 0)throw Error("lineIntersect: invalid p3");if(!K||K.x===void 0&&K.y===void 0)throw Error("lineIntersect: invalid p4");let Q=$.x instanceof M?$.x.toNumber():$.x||0,q=$.y instanceof M?$.y.toNumber():$.y||0,H=J.x instanceof M?J.x.toNumber():J.x||0,z=J.y instanceof M?J.y.toNumber():J.y||0,j=Z.x instanceof M?Z.x.toNumber():Z.x||0,W=Z.y instanceof M?Z.y.toNumber():Z.y||0,G=K.x instanceof M?K.x.toNumber():K.x||0,F=K.y instanceof M?K.y.toNumber():K.y||0,_=(Q-H)*(W-F)-(q-z)*(j-G);if(Math.abs(_)<0.0000000001)return{x:B7((Q+H)/2),y:B7((q+z)/2)};let U=((Q-j)*(W-F)-(q-W)*(j-G))/_;return{x:B7(Q+U*(H-Q)),y:B7(q+U*(z-q))}}var _6=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 e6={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 $$={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"])};M.set({precision:20,rounding:M.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 J$($,J=3){if($===null||$===void 0)throw Error("formatSplineValue: value parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw Error("formatSplineValue: precision must be a non-negative finite number");let Z=typeof $==="number"?$:parseFloat($);if(!Number.isFinite(Z))throw Error(`formatSplineValue: value must be a finite number, got ${$}`);let q=new M($).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 d$($){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 Error(`parseKeySplines: invalid spline "${Z}", expected 4 values, got ${K.length}`);return K})}function g9($,J=3){if(!Array.isArray($))throw Error("serializeKeySplines: splines must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw Error("serializeKeySplines: precision must be a non-negative finite number");return $.map((Z,K)=>{if(!Array.isArray(Z))throw Error(`serializeKeySplines: spline at index ${K} must be an array`);if(Z.length!==4)throw Error(`serializeKeySplines: spline at index ${K} must have exactly 4 values, got ${Z.length}`);return Z.map((Q)=>J$(Q,J)).join(" ")}).join("; ")}function p$($,J=0.001){if(!Array.isArray($)||$.length!==4)return!1;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw 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=d$($);if(J.length===0)return!1;return J.every((Z)=>p$(Z))}function x9($,J=0.01){if(!Array.isArray($)||$.length!==4)return null;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw 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=d$($);if(Q.length===0)return{value:null,allLinear:!1,standardEasings:[]};let q=Q.every((j)=>p$(j)),H=Q.map((j)=>x9(j)).filter(Boolean);if(q&&K)return{value:null,allLinear:!0,standardEasings:H};return{value:g9(Q,Z),allLinear:q,standardEasings:H}}function cH($){if(!$||typeof $!=="string")return[];return $.split(";").map((J)=>parseFloat(J.trim())).filter((J)=>Number.isFinite(J))}function nH($,J=3){if(!Array.isArray($))throw Error("serializeKeyTimes: times must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw Error("serializeKeyTimes: precision must be a non-negative finite number");if($.length===0)return"";return $.map((Z)=>J$(Z,J)).join("; ")}function d9($,J=3){if($===null||$===void 0)throw Error("optimizeKeyTimes: keyTimes parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw Error("optimizeKeyTimes: precision must be a non-negative finite number");let Z=cH($);if(Z.length===0)return $;return nH(Z,J)}function m$($,J=3){if(!$||typeof $!=="string")return $;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw 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((j)=>j).map((j)=>{let W=parseFloat(j);if(!Number.isFinite(W))return j;return J$(W,J)}).join(" ")}).join("; ")}function lH($,J={}){if(!$||typeof $!=="object")throw Error("optimizeElementTiming: el parameter must be a valid element");if(typeof $.getAttribute!=="function"||typeof $.setAttribute!=="function"||typeof $.removeAttribute!=="function")throw 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 Error("optimizeElementTiming: options.precision must be a non-negative finite number");let q=[],H=!1,z=$.getAttribute("keySplines");if(z){let W=m9(z,{precision:Z,removeLinear:K});if(W.allLinear&&K){if($.getAttribute("calcMode")==="spline")$.setAttribute("calcMode","linear"),$.removeAttribute("keySplines"),q.push('Converted linear splines to calcMode="linear"'),H=!0}else if(W.value&&W.value!==z)$.setAttribute("keySplines",W.value),q.push(`keySplines: "${z}" -> "${W.value}"`),H=!0}let j=$.getAttribute("keyTimes");if(j){let W=d9(j,Z);if(W!==j)$.setAttribute("keyTimes",W),q.push(`keyTimes: "${j}" -> "${W}"`),H=!0}if(Q){let W=$.getAttribute("values");if(W){let G=m$(W,Z);if(G!==W)$.setAttribute("values",G),q.push(`values: "${W}" -> "${G}"`),H=!0}}for(let W of["from","to","by"]){let G=$.getAttribute(W);if(G){let F=m$(G,Z);if(F!==G)$.setAttribute(W,F),q.push(`${W}: "${G}" -> "${F}"`),H=!0}}return{modified:H,changes:q}}var sH=["animate","animatetransform","animatemotion","animatecolor","set"];function d5($,J={}){if(!$||typeof $!=="object")throw Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let Z=0,K=0,Q=[],q=(H)=>{if(!H||typeof H!=="object")return;let z=H.tagName?.toLowerCase();if(!z)return;if(sH.includes(z)){let W=lH(H,J);if(W.modified)Z++,K+=W.changes.length,Q.push({element:z,id:H.getAttribute("id")||null,changes:W.changes})}let j=H.children||[];for(let W of j)q(W)};return q($),{elementsModified:Z,totalChanges:K,details:Q}}M.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 oH($){if(typeof $!=="string")throw 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 l0($){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 j=q.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g);if(j&&j.length>=2){J.push({command:"M",args:[parseFloat(j[0]),parseFloat(j[1])]});for(let W=2;W+1<j.length;W+=2)J.push({command:"L",args:[parseFloat(j[W]),parseFloat(j[W+1])]})}continue}let H;if(Q==="A"||Q==="a"){if(H=oH(q),H===null){console.warn(`Invalid arc command with malformed flags - skipping: ${Q}${q}`);continue}for(let j=0;j<H.length;j+=7)if(j+6<H.length)H[j]=Math.abs(H[j]),H[j+1]=Math.abs(H[j+1])}else{let j=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;H=[];let W;while((W=j.exec(q))!==null)H.push(parseFloat(W[0]))}let z=c9[Q];if(z===void 0){console.warn(`Unknown SVG path command '${Q}' - skipping`);continue}if(z===0||H.length===0)J.push({command:Q,args:[]});else for(let j=0;j<H.length;j+=z){let W=H.slice(j,j+z);if(W.length===z){let G=j>0&&(Q==="M"||Q==="m")?Q==="M"?"L":"l":Q;J.push({command:G,args:W})}else if(W.length>0)console.warn(`Incomplete ${Q} command: expected ${z} args, got ${W.length} - remaining args dropped`)}}return J}function y7($,J=3){if(typeof $!=="number")throw TypeError(`formatNumber: num must be a number, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw 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 N7($,J,Z){if(!$||typeof $!=="object")throw TypeError(`toAbsolute: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`toAbsolute: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("toAbsolute: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw TypeError(`toAbsolute: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw 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 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 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 RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${H.length}`);H[0]+=J;break;case"v":if(H.length<1)throw RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${H.length}`);H[0]+=Z;break;case"c":if(H.length<6)throw 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 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 RangeError(`toAbsolute: command ${K} requires at least 7 args, got ${H.length}`);H[5]+=J,H[6]+=Z;break;default:throw TypeError(`toAbsolute: unsupported command '${K}' for conversion`)}return{command:q,args:H}}function n9($,J,Z){if(!$||typeof $!=="object")throw TypeError(`toRelative: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`toRelative: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("toRelative: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw TypeError(`toRelative: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw 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 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 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 RangeError(`toRelative: command ${K} requires at least 1 arg, got ${H.length}`);H[0]-=J;break;case"V":if(H.length<1)throw RangeError(`toRelative: command ${K} requires at least 1 arg, got ${H.length}`);H[0]-=Z;break;case"C":if(H.length<6)throw 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 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 RangeError(`toRelative: command ${K} requires at least 7 args, got ${H.length}`);H[5]-=J,H[6]-=Z;break;default:throw TypeError(`toRelative: unsupported command '${K}' for conversion`)}return{command:q,args:H}}function iH($,J,Z,K=0.000001){if(!$||typeof $!=="object")throw TypeError(`lineToHV: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`lineToHV: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("lineToHV: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw TypeError(`lineToHV: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw TypeError(`lineToHV: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw 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 RangeError(`lineToHV: command ${Q} requires at least 2 args, got ${q.length}`);let H=Q==="L",z=H?q[0]:J+q[0],j=H?q[1]:Z+q[1];if(Math.abs(j-Z)<K)return H?{command:"H",args:[z]}:{command:"h",args:[z-J]};if(Math.abs(z-J)<K)return H?{command:"V",args:[j]}:{command:"v",args:[j-Z]};return null}function rH($,J,Z,K,Q,q=0.000001){if(!$||typeof $!=="object")throw TypeError(`lineToZ: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`lineToZ: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("lineToZ: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw TypeError(`lineToZ: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw TypeError(`lineToZ: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K))throw TypeError(`lineToZ: startX must be a finite number, got ${K}`);if(typeof Q!=="number"||!isFinite(Q))throw TypeError(`lineToZ: startY must be a finite number, got ${Q}`);if(typeof q!=="number"||!isFinite(q)||q<0)throw TypeError(`lineToZ: tolerance must be a non-negative finite number, got ${q}`);let{command:H,args:z}=$;if(H!=="L"&&H!=="l")return!1;if(z.length<2)throw RangeError(`lineToZ: command ${H} requires at least 2 args, got ${z.length}`);let j=H==="L",W=j?z[0]:J+z[0],G=j?z[1]:Z+z[1];return Math.abs(W-K)<q&&Math.abs(G-Q)<q}function aH($,J,Z,K,Q,q,H,z,j=0.5){let W={x0:$,y0:J,cp1x:Z,cp1y:K,cp2x:Q,cp2y:q,x3:H,y3:z,tolerance:j};for(let[Y,V]of Object.entries(W))if(typeof V!=="number"||!isFinite(V))throw TypeError(`isCurveStraight: ${Y} must be a finite number, got ${V}`);if(j<0)throw TypeError(`isCurveStraight: tolerance must be non-negative, got ${j}`);let G=(H-$)**2+(z-J)**2;if(G<0.0000000001){let Y=Math.sqrt((Z-$)**2+(K-J)**2),V=Math.sqrt((Q-$)**2+(q-J)**2);return Math.max(Y,V)<j}let F=Math.sqrt(G),_=Math.abs((z-J)*Z-(H-$)*K+H*J-z*$)/F,U=Math.abs((z-J)*Q-(H-$)*q+H*J-z*$)/F;return Math.max(_,U)<j}function tH($,J,Z,K=0.5){if(!$||typeof $!=="object")throw TypeError(`straightCurveToLine: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`straightCurveToLine: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("straightCurveToLine: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw TypeError(`straightCurveToLine: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw TypeError(`straightCurveToLine: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw 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 RangeError(`straightCurveToLine: command ${Q} requires at least 6 args, got ${q.length}`);let H=Q==="C",z=H?q[0]:J+q[0],j=H?q[1]:Z+q[1],W=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(aH(J,Z,z,j,W,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 TypeError(`serializeCommand: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw TypeError(`serializeCommand: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw TypeError("serializeCommand: cmd.args must be an array");if(J!==null&&typeof J!=="string")throw TypeError(`serializeCommand: prevCommand must be a string or null, got ${typeof J}`);if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw TypeError(`serializeCommand: precision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw 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 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=[y7(q[0],Z),y7(q[1],Z),y7(q[2],Z),q[3]?"1":"0",q[4]?"1":"0",y7(q[5],Z),y7(q[6],Z)].join(" ");return{str:Q+F,lastArgHadDecimal:F.includes(".")}}if(q.length===0)throw RangeError(`serializeCommand: command ${Q} has empty args array (only Z/z should have no args)`);let H=q.map((F)=>y7(F,Z)),z="";for(let F=0;F<H.length;F++){let _=H[F];if(F===0)z=_;else{let Y=H[F-1].includes(".");if(_.startsWith("-"))z+=_;else if(_.startsWith(".")&&Y)z+=_;else z+=" "+_}}let W=(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+z,lastArgHadDecimal:W};else{let F=H[0]||"";if(F.startsWith("-"))return{str:z,lastArgHadDecimal:W};else if(F.startsWith(".")&&K)return{str:z,lastArgHadDecimal:W};else return{str:" "+z,lastArgHadDecimal:W}}}function s0($,J=3){if(!Array.isArray($))throw TypeError(`serializePath: commands must be an array, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw 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:z}=p9(q,K,J,Q);Z+=H,K=q.command,Q=z}return Z}function l9($,J={}){if(typeof $!=="string")throw TypeError(`convertPathData: d must be a string, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw 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:z=0.5}=J;if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw TypeError(`convertPathData: floatPrecision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof K}`);if(typeof Q!=="boolean")throw TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof Q}`);if(typeof q!=="boolean")throw TypeError(`convertPathData: convertToZ must be a boolean, got ${typeof q}`);if(typeof H!=="boolean")throw TypeError(`convertPathData: utilizeAbsolute must be a boolean, got ${typeof H}`);if(typeof z!=="number"||!isFinite(z)||z<0)throw TypeError(`convertPathData: straightTolerance must be a non-negative finite number, got ${z}`);let j=$.length,W=l0($);if(W.length===0)return{d:$,originalLength:j,optimizedLength:j,savings:0};let G=0,F=0,_=0,U=0,Y=[];for(let O=0;O<W.length;O++){let X=W[O];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=tH(X,G,F,z);if(w)X=w}if(Q&&(X.command==="L"||X.command==="l")){let w=iH(X,G,F);if(w)X=w}if(q&&(X.command==="L"||X.command==="l")){if(rH(X,G,F,_,U))X={command:"z",args:[]}}if(H&&X.command!=="Z"&&X.command!=="z"){let w=N7(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}Y.push(X);let k=N7(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=s0(Y,Z);return{d:V,originalLength:j,optimizedLength:V.length,savings:j-V.length}}function p5($,J={}){if(!$||typeof $!=="object")throw TypeError(`optimizeDocumentPaths: root must be a DOM element object, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw 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 j=H.getAttribute("d");if(j){let W=l9(j,J);if(W.savings>0)H.setAttribute("d",W.d),Z++,K+=W.savings,Q.push({id:H.getAttribute("id")||null,originalLength:W.originalLength,optimizedLength:W.optimizedLength,savings:W.savings})}}for(let j of H.children||[])q(j)};return q($),{pathsOptimized:Z,totalSavings:K,details:Q}}function c5($,J,Z){if(!$||typeof $.x!=="number"||typeof $.y!=="number")throw TypeError("perpendicularDistance: point must be an object with numeric x and y properties");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw TypeError("perpendicularDistance: lineStart must be an object with numeric x and y properties");if(!Z||typeof Z.x!=="number"||typeof Z.y!=="number")throw 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 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 j=$.x-J.x,W=$.y-J.y;return Math.sqrt(j*j+W*W)}let H=Math.abs(Q*$.x-K*$.y+Z.x*J.y-Z.y*J.x),z=Math.sqrt(q);return H/z}function Z$($,J){if(!Array.isArray($))throw TypeError("douglasPeucker: points must be an array");if($.length===0)throw RangeError("douglasPeucker: points array cannot be empty");for(let H=0;H<$.length;H++){let z=$[H];if(!z||typeof z!=="object")throw TypeError(`douglasPeucker: point at index ${H} must be an object`);if(typeof z.x!=="number"||!Number.isFinite(z.x))throw TypeError(`douglasPeucker: point at index ${H} must have a finite numeric x property`);if(typeof z.y!=="number"||!Number.isFinite(z.y))throw TypeError(`douglasPeucker: point at index ${H} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw TypeError("douglasPeucker: tolerance must be a finite number");if(J<0)throw RangeError("douglasPeucker: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw RangeError("douglasPeucker: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if($.length<=2)return $;if($.length>1e4)return eH($,J);let Z=0,K=0,Q=$[0],q=$[$.length-1];for(let H=1;H<$.length-1;H++){let z=c5($[H],Q,q);if(z>Z)Z=z,K=H}if(Z>J){let H=Z$($.slice(0,K+1),J),z=Z$($.slice(K),J);return H.slice(0,-1).concat(z)}else return[Q,q]}function eH($,J){if($.length<=2)return $;let Z=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,z=Q,j=$[Q],W=$[q];for(let G=Q+1;G<q;G++){let F=c5($[G],j,W);if(F>H)H=F,z=G}if(H>J)Z[z]=!0,K.push([Q,z]),K.push([z,q])}return $.filter((Q,q)=>Z[q])}function s9($,J){if(!Array.isArray($))throw TypeError("visvalingamWhyatt: points must be an array");if($.length===0)throw RangeError("visvalingamWhyatt: points array cannot be empty");for(let z=0;z<$.length;z++){let j=$[z];if(!j||typeof j!=="object")throw TypeError(`visvalingamWhyatt: point at index ${z} must be an object`);if(typeof j.x!=="number"||!Number.isFinite(j.x))throw TypeError(`visvalingamWhyatt: point at index ${z} must have a finite numeric x property`);if(typeof j.y!=="number"||!Number.isFinite(j.y))throw TypeError(`visvalingamWhyatt: point at index ${z} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw TypeError("visvalingamWhyatt: minArea must be a finite number");if(J<0)throw RangeError("visvalingamWhyatt: minArea cannot be negative");if($.length<=2)return $;let Z=(z,j,W)=>{return Math.abs((j.x-z.x)*(W.y-z.y)-(W.x-z.x)*(j.y-z.y))/2},K=$.map((z,j)=>({...z,index:j})),Q=Array(K.length).fill(1/0);for(let z=1;z<K.length-1;z++)Q[z]=Z(K[z-1],K[z],K[z+1]);let q=Array(K.length).fill(!0),H=K.length;while(H>2){let z=1/0,j=-1;for(let F=1;F<K.length-1;F++)if(q[F]&&Q[F]<z)z=Q[F],j=F;if(z>=J||j===-1)break;q[j]=!1,H--;let W=j-1;while(W>=0&&!q[W])W--;let G=j+1;while(G<K.length&&!q[G])G++;if(W>0){let F=W-1;while(F>=0&&!q[F])F--;if(F>=0&&G<K.length)Q[W]=Z(K[F],K[W],K[G])}if(G<K.length-1){let F=G+1;while(F<K.length&&!q[F])F++;if(F<K.length&&W>=0)Q[G]=Z(K[W],K[G],K[F])}}return K.filter((z,j)=>q[j])}function o9($,J,Z="douglas-peucker"){if(!Array.isArray($))throw TypeError("simplifyPolyline: points must be an array");if($.length===0)throw RangeError("simplifyPolyline: points array cannot be empty");if(typeof J!=="number"||!Number.isFinite(J))throw TypeError("simplifyPolyline: tolerance must be a finite number");if(J<0)throw RangeError("simplifyPolyline: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw RangeError("simplifyPolyline: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(typeof Z!=="string")throw TypeError("simplifyPolyline: algorithm must be a string");let K=["douglas-peucker","visvalingam"];if(!K.includes(Z))throw RangeError(`simplifyPolyline: algorithm must be one of: ${K.join(", ")}`);if(Z==="visvalingam")return s9($,J*J);return Z$($,J)}function $z($){if(!Array.isArray($))throw 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 TypeError("extractPolylinePoints: each command must be an object");if(typeof H.command!=="string")throw TypeError('extractPolylinePoints: each command must have a string "command" property');if(!Array.isArray(H.args))throw TypeError('extractPolylinePoints: each command must have an "args" array');let{command:z,args:j}=H,W=(F)=>{if(j.length<F)throw RangeError(`extractPolylinePoints: command "${z}" requires at least ${F} arguments, got ${j.length}`)},G=(F)=>{if(typeof j[F]!=="number"||!Number.isFinite(j[F]))throw TypeError(`extractPolylinePoints: command "${z}" argument at index ${F} must be a finite number, got ${j[F]}`)};switch(z){case"M":W(2),G(0),G(1),Z=j[0],K=j[1],Q=Z,q=K,J.push({x:Z,y:K});break;case"m":W(2),G(0),G(1),Z+=j[0],K+=j[1],Q=Z,q=K,J.push({x:Z,y:K});break;case"L":W(2),G(0),G(1),Z=j[0],K=j[1],J.push({x:Z,y:K});break;case"l":W(2),G(0),G(1),Z+=j[0],K+=j[1],J.push({x:Z,y:K});break;case"H":W(1),G(0),Z=j[0],J.push({x:Z,y:K});break;case"h":W(1),G(0),Z+=j[0],J.push({x:Z,y:K});break;case"V":W(1),G(0),K=j[0],J.push({x:Z,y:K});break;case"v":W(1),G(0),K+=j[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":W(6),G(4),G(5),Z=j[4],K=j[5];break;case"c":W(6),G(4),G(5),Z+=j[4],K+=j[5];break;case"S":case"Q":W(4),G(2),G(3),Z=j[2],K=j[3];break;case"s":case"q":W(4),G(2),G(3),Z+=j[2],K+=j[3];break;case"T":W(2),G(0),G(1),Z=j[0],K=j[1];break;case"t":W(2),G(0),G(1),Z+=j[0],K+=j[1];break;case"A":W(7),G(5),G(6),Z=j[5],K=j[6];break;case"a":W(7),G(5),G(6),Z+=j[5],K+=j[6];break;default:break}}return J}function Jz($,J=!1){if(!Array.isArray($))throw TypeError("rebuildPathFromPoints: points must be an array");if($.length===0)return[];if(typeof J!=="boolean")throw TypeError("rebuildPathFromPoints: closed must be a boolean");for(let K=0;K<$.length;K++){let Q=$[K];if(!Q||typeof Q!=="object")throw TypeError(`rebuildPathFromPoints: point at index ${K} must be an object`);if(typeof Q.x!=="number"||!Number.isFinite(Q.x))throw TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric x property`);if(typeof Q.y!=="number"||!Number.isFinite(Q.y))throw 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 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 TypeError("simplifyPath: commands must be an array");if(typeof J!=="number"||!Number.isFinite(J))throw TypeError("simplifyPath: tolerance must be a finite number");if(J<0)throw RangeError("simplifyPath: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw 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=$z($),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 W=K[0],G=K[K.length-1];if(Math.abs(G.x-W.x)<0.0000000001&&Math.abs(G.y-W.y)<0.0000000001)K=K.slice(0,-1)}let H=o9(K,J,Z),z=H.length;if(z>=Q)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};return{commands:Jz(H,q),simplified:!0,originalPoints:Q,simplifiedPoints:z}}function z7($){if(typeof $!=="string")throw TypeError("Path d must be a string")}function W7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw TypeError(`Precision must be a finite non-negative number, got ${$}`)}function q6($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw TypeError(`Tolerance must be a finite non-negative number, got ${$}`)}function j7($,J=0){if(!$||typeof $!=="object")throw TypeError("Command must be an object");if(typeof $.command!=="string")throw TypeError("Command must have a string 'command' property");if(!Array.isArray($.args))throw TypeError("Command must have an array 'args' property");if($.args.length<J)throw 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 TypeError(`Command ${$.command} arg[${Z}] must be a finite number, got ${$.args[Z]}`)}function t9($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((Q)=>j7(Q));let K=Z.map((Q)=>({command:Q.command,args:Q.args.map((q)=>{let H=y7(q,J),z=parseFloat(H);if(!Number.isFinite(z))throw Error(`Invalid numeric value encountered: ${H}`);return z})}));return s0(K,J)}function e9($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;return Z.forEach((K)=>j7(K)),s0(Z,J)}function $8($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((j)=>j7(j));let K=0,Q=0,q=0,H=0,z=[];for(let j of Z){let W=n9(j,K,Q);z.push(W);let G=N7(j,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 s0(z,J)}function J8($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((j)=>j7(j));let K=0,Q=0,q=0,H=0,z=[];for(let j of Z){let W=N7(j,K,Q);switch(z.push(W),W.command){case"M":K=W.args[0],Q=W.args[1],q=K,H=Q;break;case"L":case"T":K=W.args[0],Q=W.args[1];break;case"H":K=W.args[0];break;case"V":Q=W.args[0];break;case"C":K=W.args[4],Q=W.args[5];break;case"S":case"Q":K=W.args[2],Q=W.args[3];break;case"A":K=W.args[5],Q=W.args[6];break;case"Z":K=q,Q=H;break;default:break}}return s0(z,J)}function Z8($,J=0.000001,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((W)=>j7(W));let Q=0,q=0,H=0,z=0,j=[];for(let W of K){let G=W;if(W.command==="L"||W.command==="l"){let _=W.command==="L",U=_?W.args[0]:Q+W.args[0],Y=_?W.args[1]:q+W.args[1];if(Math.abs(Y-q)<J)G=_?{command:"H",args:[U]}:{command:"h",args:[U-Q]};else if(Math.abs(U-Q)<J)G=_?{command:"V",args:[Y]}:{command:"v",args:[Y-q]}}j.push(G);let F=N7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,z=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=z;break;default:break}}return s0(j,Z)}function K8($,J=0.000001,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((W)=>j7(W));let Q=0,q=0,H=0,z=0,j=[];for(let W=0;W<K.length;W++){let G=K[W],F=G;if(G.command==="L"||G.command==="l"){let U=G.command==="L",Y=U?G.args[0]:Q+G.args[0],V=U?G.args[1]:q+G.args[1];if((W===K.length-1||K[W+1].command==="M"||K[W+1].command==="m")&&Math.abs(Y-H)<J&&Math.abs(V-z)<J)F={command:"z",args:[]}}j.push(F);let _=N7(F,Q,q);switch(_.command){case"M":Q=_.args[0],q=_.args[1],H=Q,z=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=z;break;default:break}}return s0(j,Z)}function b6(...$){for(let J=0;J<$.length;J++)if(typeof $[J]!=="number"||!Number.isFinite($[J]))throw TypeError(`Coordinate at position ${J} must be a finite number, got ${$[J]}`)}function n5($){if(typeof $!=="number"||!Number.isFinite($))throw TypeError(`Parameter t must be a finite number, got ${$}`);if($<0||$>1)throw RangeError(`Parameter t must be in range [0, 1], got ${$}`)}function c$($,J,Z,K,Q,q,H,z,j){n5($),b6(J,Z,K,Q,q,H,z,j);let W=1-$,G=W*W,F=G*W,_=$*$,U=_*$;return{x:F*J+3*G*$*K+3*W*_*q+U*z,y:F*Z+3*G*$*Q+3*W*_*H+U*j}}function a9($,J,Z,K,Q,q){b6($,J,Z,K,Q,q);let H=Q-Z,z=q-K,j=H*H+z*z;if(j<0.0000000001)return Math.sqrt(($-Z)**2+(J-K)**2);let W=Math.max(0,Math.min(1,(($-Z)*H+(J-K)*z)/j)),G=Z+W*H,F=K+W*z;return Math.sqrt(($-G)**2+(J-F)**2)}function Zz($,J,Z,K,Q,q,H,z){b6($,J,Z,K,Q,q,H,z);let j=0,W=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let G of W){let F=c$(G,$,J,Z,K,Q,q,H,z),_=a9(F.x,F.y,$,J,H,z);if(_>j)j=_}for(let G=0;G<W.length-1;G++){let F=(W[G]+W[G+1])/2,_=c$(F,$,J,Z,K,Q,q,H,z),U=a9(_.x,_.y,$,J,H,z);if(U>j)j=U}for(let G of[0.05,0.95]){let F=c$(G,$,J,Z,K,Q,q,H,z),_=a9(F.x,F.y,$,J,H,z);if(_>j)j=_}return j}function Kz($,J,Z,K,Q,q,H,z,j){return Zz($,J,Z,K,Q,q,H,z)<=j}function Q8($,J=0.5,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((W)=>j7(W));let Q=0,q=0,H=0,z=0,j=[];for(let W of K){let G=W;if(W.command==="C"||W.command==="c"){let _=W.command==="C",U=_?W.args[0]:Q+W.args[0],Y=_?W.args[1]:q+W.args[1],V=_?W.args[2]:Q+W.args[2],O=_?W.args[3]:q+W.args[3],X=_?W.args[4]:Q+W.args[4],k=_?W.args[5]:q+W.args[5];if(Kz(Q,q,U,Y,V,O,X,k,J))G=_?{command:"L",args:[X,k]}:{command:"l",args:[X-Q,k-q]}}j.push(G);let F=N7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,z=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=z;break;default:break}}return s0(j,Z)}function q8($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;return Z.forEach((K)=>j7(K)),s0(Z,J)}function H8($,J=3){if(z7($),W7(J),J>15)throw RangeError(`Precision ${J} is too large (max 15)`);let Z=l0($);if(Z.length===0)return $;Z.forEach((q)=>j7(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 s0(Q,J)}function z8($,J=0.000001,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((W)=>j7(W));let Q=0,q=0,H=0,z=0,j=[];for(let W of K){let G=N7(W,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(j.push(W),G.command){case"M":Q=G.args[0],q=G.args[1],H=Q,z=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=z;break;default:break}}return s0(j,Z)}function Qz($,J,Z,K,Q,q,H){n5($),b6(J,Z,K,Q,q,H);let z=1-$,j=z*z,W=$*$;return{x:j*J+2*z*$*K+W*q,y:j*Z+2*z*$*Q+W*H}}function qz($,J,Z,K,Q,q,H,z,j,W){b6($,J,Z,K,Q,q,H,z,j,W);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=c$(_,$,J,Z,K,Q,q,H,z),Y=Qz(_,$,J,j,W,H,z),V=Math.sqrt((U.x-Y.x)**2+(U.y-Y.y)**2);if(V>G)G=V}return G}function Hz($,J,Z,K,Q,q,H,z,j){b6($,J,Z,K,Q,q,H,z),q6(j);let W=(3*(Z+Q)-$-H)/4,G=(3*(K+q)-J-z)/4;if(qz($,J,Z,K,Q,q,H,z,W,G)<=j)return{cpx:W,cpy:G};return null}function W8($,J=0.5,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((W)=>j7(W));let Q=0,q=0,H=0,z=0,j=[];for(let W of K){let G=W;if(W.command==="C"||W.command==="c"){let _=W.command==="C",U=_?W.args[0]:Q+W.args[0],Y=_?W.args[1]:q+W.args[1],V=_?W.args[2]:Q+W.args[2],O=_?W.args[3]:q+W.args[3],X=_?W.args[4]:Q+W.args[4],k=_?W.args[5]:q+W.args[5],w=Hz(Q,q,U,Y,V,O,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]}}j.push(G);let F=N7(G,Q,q);switch(F.command){case"M":Q=F.args[0],q=F.args[1],H=Q,z=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=z;break;default:break}}return s0(j,Z)}function j8($,J=0.000001,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((F)=>j7(F));let Q=0,q=0,H=0,z=0,j=null,W=null,G=[];for(let F of K){let _=F,U=N7(F,Q,q);if(U.command==="Q"&&j!==null){let Y=2*Q-j,V=2*q-W;if(Math.abs(U.args[0]-Y)<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")j=U.args[0],W=U.args[1];else if(U.command==="T")if(j!==null)j=2*Q-j,W=2*q-W;else j=Q,W=q;else j=null,W=null;switch(U.command){case"M":Q=U.args[0],q=U.args[1],H=Q,z=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=z;break;default:break}}return s0(G,Z)}function G8($,J=0.000001,Z=3){z7($),q6(J),W7(Z);let K=l0($);if(K.length===0)return $;K.forEach((F)=>j7(F));let Q=0,q=0,H=0,z=0,j=null,W=null,G=[];for(let F of K){let _=F,U=N7(F,Q,q);if(U.command==="C"&&j!==null){let Y=2*Q-j,V=2*q-W;if(Math.abs(U.args[0]-Y)<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")j=U.args[2],W=U.args[3];else if(U.command==="S")j=U.args[0],W=U.args[1];else j=null,W=null;switch(U.command){case"M":Q=U.args[0],q=U.args[1],H=Q,z=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=z;break;default:break}}return s0(G,Z)}function F8($,J=3){z7($),W7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((Q)=>j7(Q));let K=Z.map((Q)=>{if(Q.command==="A"||Q.command==="a"){let q=[...Q.args];if(q.length!==7)throw 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 s0(K,J)}var Y6=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"]),M8=new Set([...Y6].map(($)=>$.toLowerCase())),X6=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"]),O8=new Set([...X6].map(($)=>$.toLowerCase())),jz=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),Gz=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"]),Fz=($)=>{if(!$||typeof $!=="string")return!1;return jz.has($.toLowerCase())},_z=($)=>{if(!$||typeof $!=="string")return!1;let J=$.toLowerCase();return Gz.has(J)||J.startsWith("aria-")||J.startsWith("data-")},qZ=new Set(["foreignobject","script","style","title","desc","metadata"]),l$=new Map,Uz=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw Error("Both parameters must be strings");let Z=`${$}|${J}`;if(l$.has(Z))return l$.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 z=$[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]+z)}let Q=K[J.length][$.length];return l$.set(Z,Q),Q},Vz=()=>l$.clear(),S6=($,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 z of J){let j=Uz(Q,z.toLowerCase());if(j>0&&j<H)H=j,q=z}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 Mz($,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 HZ($){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,"'"),z=(K+Q).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),j=z?" "+z:"";return`<${Z}${j}><![CDATA[
|
|
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
18
|
${H}
|
|
19
|
-
]]></${Z}>`})}var s$=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,q$=80,o$=6,VZ={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};M.set({precision:q$,rounding:M.ROUND_HALF_UP});var X8=($)=>$ instanceof M?$:new M($);function $0($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function MZ($,J=o$){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=o$;if(Z>q$)Z=q$;let Q=X8($).toFixed(Z);if(Q.includes("."))return Q.replace(/\.?0+$/,"");return Q}function Oz($){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"},O7={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},M7={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function k8($){if($===null||$===void 0)return M7.STRING;if(typeof $==="object"&&$.nodeType)return M7.DOM_UPDATE;if(typeof $==="string"){let J=$.trim();if(typeof document<"u"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return M7.DOM_REPLACE;if(J.includes("/")||J.includes("\\")||/\.\w+$/.test(J))return M7.FILE;if(J.toLowerCase()==="download")return M7.DOWNLOAD}return M7.STRING}async function OZ($,J=null,Z={}){let K=k8(J),Q;if(typeof $==="string")Q=$;else Q=z$($,O7.SVG_STRING,Z);switch(K){case M7.STRING:return Q;case M7.FILE:{if(typeof process<"u"&&process.versions?.node){let q=await import("fs"),z=(await Promise.resolve().then(() => (V6(),U6))).dirname(J);if(z&&z!=="."&&!q.existsSync(z))q.mkdirSync(z,{recursive:!0});q.writeFileSync(J,Q,"utf8");return}throw Error("File saving requires Node.js environment")}case M7.DOM_REPLACE:{if(typeof document>"u")throw Error("DOM operations require browser environment");let q=document.querySelector(J);if(!q)throw Error(`No element found for selector: ${J}`);q.innerHTML=Q;return}case M7.DOM_UPDATE:{if(typeof document>"u")throw Error("DOM operations require browser environment");if(J.tagName?.toLowerCase()==="svg"){let z=new DOMParser().parseFromString(Q,"image/svg+xml").documentElement;while(J.attributes.length>0)J.removeAttribute(J.attributes[0].name);for(let j of z.attributes)J.setAttribute(j.name,j.value);J.innerHTML=z.innerHTML}else J.innerHTML=Q;return}case M7.DOWNLOAD:{if(typeof document>"u"||typeof Blob>"u")throw Error("Download requires browser environment");let q=new Blob([Q],{type:"image/svg+xml"}),H=URL.createObjectURL(q),z=document.createElement("a");z.href=H,z.download=Z.filename||"output.svg",document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(H);return}default:return Q}}function k6($){if($===null||$===void 0)throw 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<"u"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return D0.CSS_SELECTOR;else return D0.FILE_PATH}if(typeof HTMLObjectElement<"u"&&$ instanceof HTMLObjectElement)return D0.OBJECT_ELEMENT;if(typeof HTMLEmbedElement<"u"&&$ instanceof HTMLEmbedElement)return D0.EMBED_ELEMENT;if(typeof HTMLIFrameElement<"u"&&$ instanceof HTMLIFrameElement)return D0.IFRAME_ELEMENT;if($0($))return D0.DOM_ELEMENT;if($&&$.nodeType===9)return D0.XML_DOCUMENT;return D0.SVG_STRING}async function H$($,J){switch(J){case D0.SVG_STRING:return u0($);case D0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer<"u"){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<"u"){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<"u"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),K=Z($,"utf8");return u0(K)}throw Error("File loading requires Node.js environment");case D0.URL:if(typeof fetch<"u"){let K=await(await fetch($)).text();return u0(K)}throw Error("URL loading requires fetch API");case D0.CSS_SELECTOR:if(typeof document<"u"){let Z=document.querySelector($);if(!Z)throw 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 Error(`Element "${$}" is not an SVG and contains no SVG`)}throw 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 Error("HTMLObjectElement: SVG content not accessible (cross-origin or security error)")}throw 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 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 Error("HTMLIFrameElement: SVG content not accessible (cross-origin)")}throw Error("HTMLIFrameElement: No SVG content found");default:throw Error(`Unknown input type: ${J}`)}}function z$($,J,Z={}){switch(J){case O7.SVG_STRING:{let K=Z7($,{minify:Z.minify!==!1});return HZ(K)}case O7.DOM_ELEMENT:return $;case O7.XML_DOCUMENT:return $;default:{let K=Z7($,{minify:Z.minify!==!1});return HZ(K)}}}function F0($){return async function(J,Z={}){let K=k6(J),Q=await H$(J,K),q=Z.outputFormat||(K===D0.DOM_ELEMENT?O7.DOM_ELEMENT:O7.SVG_STRING),H=await $(Q,Z);return z$(H,q,Z)}}var w8=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,C=Array.from($.querySelectorAll("style")).some((v)=>v.textContent&&v.textContent.trim().length>0);if(I||C)return $}let z=(I)=>{if(q.includes(I))return!0;if(H.some((C)=>I.startsWith(C)))return!0;return!1},j=(I)=>{try{return decodeURI(I)}catch(C){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${C.message}`);return I}},W=b5($),G=new Set;for(let I of W.all)G.add(I),G.add(j(I));let F=new Map,_=(I)=>{let C=I.getAttribute("id");if(C){if(!F.has(C))F.set(C,I)}for(let v of I.children)if($0(v))_(v)};_($);let U=new Set,Y=new Set,V=(I)=>{let C=I.getAttribute("id");if(C){if(U.has(C))Y.add(C);U.add(C)}for(let v of I.children)if($0(v))V(v)};V($);let O=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 C=I.getAttribute("id");if(C){if(Y.has(C)){if(O.has(C)){I.removeAttribute("id");return}O.add(C)}let v=j(C),g=G.has(C)||G.has(v);if(z(C));else if(!g&&K)I.removeAttribute("id");else if(Z&&g){let T=w();if(X.set(C,T),v!==C)X.set(v,T);I.setAttribute("id",T)}}for(let v of I.children)if($0(v))R(v)};if(R($),Z){let I=(g)=>{let T=(u)=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let u of g.getAttributeNames()){let S=g.getAttribute(u);if(S&&S.includes("url(#")){for(let[A,y]of X){let p=T(A);S=S.replace(new RegExp(`url\\(#${p}\\)`,"g"),`url(#${y})`);let m=T(encodeURI(A));S=S.replace(new RegExp(`url\\(#${m}\\)`,"g"),`url(#${y})`)}g.setAttribute(u,S)}if((u==="href"||u==="xlink:href")&&S?.startsWith("#")){let A=S.substring(1),y=j(A);if(X.has(A))g.setAttribute(u,`#${X.get(A)}`);else if(X.has(y))g.setAttribute(u,`#${X.get(y)}`)}if((u==="begin"||u==="end")&&S){for(let[A,y]of X){let p=T(A);S=S.replace(new RegExp(`^${p}\\.`,"g"),`${y}.`),S=S.replace(new RegExp(`;${p}\\.`,"g"),`;${y}.`)}g.setAttribute(u,S)}if((u==="values"||u==="from"||u==="to"||u==="by")&&S){for(let[A,y]of X){let p=T(A);S=S.replace(new RegExp(`#${p}([;\\s]|$)`,"g"),`#${y}$1`)}g.setAttribute(u,S)}}for(let u of g.children)if($0(u))I(u)};I($);let C=(g)=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),v=$.getElementsByTagName("style");for(let g of v){let T=g.textContent;if(!T)continue;for(let[u,S]of X){let A=C(u);T=T.replace(new RegExp(`#${A}([^\\w-]|$)`,"g"),`#${S}$1`),T=T.replace(new RegExp(`url\\(#${A}\\)`,"g"),`url(#${S})`)}g.textContent=T}}return $}),a$=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let W=X8(H).toDecimalPlaces(Z).toString();if(W.includes("."))W=W.replace(/0+$/,""),W=W.replace(/\.$/,"");return W},Q=(q)=>{for(let H of q.getAttributeNames()){let z=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(z))continue;q.setAttribute(H,K(z))}if(H==="d"&&z){let j=z.replace(s$,(W)=>K(W));q.setAttribute("d",j)}if(H==="transform"&&z){let j=z.replace(s$,(W)=>K(W));q.setAttribute("transform",j)}if(H==="points"&&z){let j=z.replace(s$,(W)=>K(W));q.setAttribute("points",j)}}for(let H of q.children)if($0(H))Q(H)};return Q($),$}),YZ=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let j=X8(H).toDecimalPlaces(Z).toString();if(j.includes("."))j=j.replace(/0+$/,""),j=j.replace(/\.$/,"");return j},Q=(q)=>{for(let H of["points"]){let z=q.getAttribute(H);if(z){let j=z.replace(s$,K);q.setAttribute(H,j)}}for(let H of q.children)if($0(H))Q(H)};return Q($),$}),XZ=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($0(H))Q(H)};return Q($),$}),kZ=F0(($,J={})=>{let Z=(K)=>{if(K.hasAttribute("enable-background"))K.removeAttribute("enable-background");for(let Q of K.children)if($0(Q))Z(Q)};return Z($),$}),wZ=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 z=q.matchAll(/xlink:href="#([^"]+)"/g);for(let X of z)Q.add(X[1]);let j=q.matchAll(/\shref="#([^"]+)"/g);for(let X of j)Q.add(X[1]);let W={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)=>W[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"}},Y=(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&&$0(w)){let R=w.getAttribute(k);if(R!==null)return R;w=w.parentNode}return null},O=(X,k={})=>{if(X.tagName==="foreignObject")return;if(X.tagName.includes(":"))return;if(!X.getAttribute("id")){for(let[v,g]of Object.entries(_))if(!Y(v)&&X.getAttribute(v)===g)X.removeAttribute(v);let C=U[X.tagName.toLowerCase()]||{};for(let[v,g]of Object.entries(C))if(!Y(v)&&X.getAttribute(v)===g)X.removeAttribute(v);if(!Z){for(let v of X.getAttributeNames())if(_6.has(v)&&!Y(v)){let g=X.getAttribute(v),T=V(X,v);if(T!==null&&g===T)X.removeAttribute(v)}}}let w={...k};for(let C of _6){let v=X.getAttribute(C);if(v!==null)w[C]=v}let R=X.tagName.toLowerCase(),I=$$[R]||$$[G(R)];for(let C of[...X.children])if($0(C)){if(C.tagName.includes(":"))continue;let v=C.tagName.toLowerCase(),g=C.getAttribute("id"),T=K&&g,u=(S)=>{let A=S.getAttribute("id");if(A&&Q.has(A))return!0;for(let y of S.children||[])if($0(y)&&u(y))return!0;return!1};if(!F.includes(v)){if(!u(C)&&!T){X.removeChild(C);continue}}if(I&&!I.has(v)&&!I.has(G(v))){if(!u(C)&&!T){X.removeChild(C);continue}}O(C,w)}};return O($,{}),$}),LZ=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($0(q))K(q)};return K($),$}),RZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of[...Z])if(K.children.length===0){if(K.parentNode)K.parentNode.removeChild(K)}return $}),t$=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 Y of U)Q.add(Y[1])}if((F==="href"||F==="xlink:href")&&_&&_.startsWith("#"))Q.add(_.substring(1))}for(let F of G.children)if($0(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},z=(G)=>{for(let F of G.children){if(!$0(F))continue;let _=F.tagName?.toLowerCase();if(e6.animation.has(_))return!0;if(z(F))return!0}return!1},j=(G)=>{let F=G.getAttribute("id");if(F&&(Q.has(F)||K))return!0;for(let _ of G.children){if(!$0(_))continue;if(j(_))return!0}return!1},W=(G,F=!1)=>{let _=G.tagName.toLowerCase(),U=F||_==="defs",Y=G.getAttribute("display"),V=G.getAttribute("visibility"),O=parseFloat(G.getAttribute("opacity")||"1");if(Y==="none"||V==="hidden"||O===0){if(!Z&&j(G));else if(!Z&&_==="marker");else if(!Z&&(G.getAttribute("marker-start")||G.getAttribute("marker-mid")||G.getAttribute("marker-end")));else if(!Z&&U&&e6.nonRendering.has(_));else if(!Z&&e6.animation.has(_));else if(!Z&&z(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($0(k))W(k,U)};return W($),$}),BZ=F0(($,J={})=>{let Z=$.getElementsByTagName("text"),K=(H)=>{let z=H.textContent||"";if(H.children)for(let j of H.children)z+=K(j);return z},Q=(H,z)=>{if(!z||z.length===0)return!1;return(H.getAttributeNames?H.getAttributeNames():[]).some((W)=>z.some((G)=>W.startsWith(G+":")))},q=J.preserveNamespaces||[];for(let H of[...Z]){let z=K(H),j=!z||z.trim()==="",W=Q(H,q);if(j&&!W){if(H.parentNode)H.parentNode.removeChild(H)}}return $}),e$=F0(($,J={})=>{let Z=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],K=$.querySelectorAll("script").length>0,Q=new Set,q=(z)=>{for(let j of z.getAttributeNames?z.getAttributeNames():[]){let W=z.getAttribute(j);if(W&&W.includes("url(#")){let G=W.matchAll(/url\(#([^)]+)\)/g);for(let F of G)Q.add(F[1])}if((j==="href"||j==="xlink:href")&&W&&W.startsWith("#"))Q.add(W.substring(1))}for(let j of z.children||[])if($0(j))q(j)};q($);let H=(z)=>{for(let G of[...z.children])if($0(G))H(G);let j=z.tagName?.toLowerCase();if(!Z.includes(z.tagName)&&!Z.includes(j))return;if(z.getAttribute("href")||z.getAttribute("xlink:href"))return;let W=z.getAttribute("id");if(W&&(Q.has(W)||K))return;if(z.children.length===0){if(z.parentNode)z.parentNode.removeChild(z)}};return H($),$}),NZ=F0(($,J={})=>{return $}),IZ=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 $}),CZ=F0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),PZ=F0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),L8=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((W)=>!K.has(W));if(Q.length===0)return $;let q=(W)=>{for(let G of[...W.children])if($0(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(Q.includes(_)){W.removeChild(G);continue}}q(G)}};q($);let H=(W)=>{for(let G of[...W.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(Q.includes(_))W.removeAttribute(G)}}for(let G of W.children)if($0(G))H(G)};H($);let z=new Set,j=(W)=>{for(let F of W.getAttributeNames()){if(F.startsWith("xmlns:"))continue;let _=F.indexOf(":");if(_>0){let U=F.substring(0,_);z.add(U)}}let G=W.tagName.indexOf(":");if(G>0)z.add(W.tagName.substring(0,G));for(let F of W.children)if($0(F))j(F)};j($);for(let W of Q){let G=`xmlns:${W}`;if($.hasAttribute(G)&&!z.has(W))$.removeAttribute(G)}return $}),AZ=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($0(Q))Z(Q)};return Z($),$}),EZ=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),z=parseFloat(K);if(isNaN(H)||isNaN(z)||q.some((W)=>isNaN(W)))return $;let j=0.000001;if(q.length===4&&Math.abs(q[0])<j&&Math.abs(q[1])<j&&Math.abs(q[2]-H)<j&&Math.abs(q[3]-z)<j)$.removeAttribute("viewBox")}return $}),TZ=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 z of H.getAttributeNames())if(z.startsWith("xlink:")){Q=!0;return}for(let z of H.children){if($0(z))q(z);if(Q)return}};if(q($),!Q)$.removeAttribute("xmlns:xlink")}return $.removeAttribute("xmlns:svg"),$}),fZ=F0(($,J={})=>{let Z=$.querySelectorAll("script").length>0,K=new Set,Q=(H)=>{for(let z of H.getAttributeNames()){let j=H.getAttribute(z);if(j&&j.includes("url(#")){let W=j.matchAll(/url\(#([^)]+)\)/g);for(let G of W)K.add(G[1])}if((z==="href"||z==="xlink:href")&&j&&j.startsWith("#"))K.add(j.substring(1))}for(let z of H.children)if($0(z))Q(z)};Q($);let q=$.getElementsByTagName("image");for(let H of[...q]){let z=H.getAttribute("id");if(z&&(K.has(z)||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 z=q.getAttribute(H);if(z&&z.includes("url(#")){let j=z.matchAll(/url\(#([^)]+)\)/g);for(let W of j)Z.add(W[1])}if((H==="href"||H==="xlink:href")&&z&&z.startsWith("#"))Z.add(z.substring(1))}for(let H of q.children)if($0(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 $}),SZ=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 j=parseFloat(H.getAttribute("x")||"0"),W=parseFloat(H.getAttribute("y")||"0"),G=parseFloat(H.getAttribute("width")||"0"),F=parseFloat(H.getAttribute("height")||"0");if(isNaN(j)||isNaN(W)||isNaN(G)||isNaN(F)){for(let _ of[...H.children])if($0(_))q(_);return}}if(H.tagName==="rect"&&!K){let j=parseFloat(H.getAttribute("rx")||"0"),W=parseFloat(H.getAttribute("ry")||"0");if(isNaN(j)||isNaN(W)||j>0||W>0){for(let G of[...H.children])if($0(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($0(G))q(G);return}}let z=k9(H,Z);if(z){let j=new w0("path",{d:z});for(let W of H.getAttributeNames())if(!W.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let G=H.getAttribute(W);if(G!==null)j.setAttribute(W,G)}for(let W of[...H.children])j.appendChild(W);if(H.parentNode)H.parentNode.replaceChild(j,H)}}for(let z of[...H.children])if($0(z))q(z)};return q($),$}),vZ=F0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=new Set,q=(z)=>{for(let j of["href","xlink:href"]){let W=z.getAttribute(j);if(W&&W.startsWith("#"))Q.add(W.substring(1))}for(let j of z.children)if($0(j))q(j)};q($);let H=$.getElementsByTagName("path");for(let z of H){let j=z.getAttribute("d");if(!j)continue;let W=z.getAttribute("id");if(!K&&W&&Q.has(W))continue;if(!K&&z.getAttribute("style"))continue;let G=z.getAttribute("stroke-linecap"),F=G&&G!=="butt";if((j.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!K&&z.getAttribute("marker-mid"))continue;let U=p6(j);z.setAttribute("d",U)}return $}),DZ=F0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=(q)=>{let H=q.getAttribute("transform");if(H){let z=U7(H),j=vJ(z,Z);if(!K&&j.length>=H.length);else if(!K&&q.getAttribute("stroke")&&q.getAttribute("stroke")!=="none"){let W=z.data[0][0].toNumber(),G=z.data[0][1].toNumber(),F=z.data[1][0].toNumber(),_=z.data[1][1].toNumber(),U=W*_-G*F,Y=Math.abs(W-_)<0.000001&&Math.abs(G+F)<0.000001,V=0.0000000001;if(!Y&&Math.abs(U)>0.0000000001);else q.setAttribute("transform",j)}else q.setAttribute("transform",j)}for(let z of q.children)if($0(z))Q(z)};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 z=q.match(/^#([0-9a-f]{6})$/i);if(z){let j=z[1];if(j[0]===j[1]&&j[2]===j[3]&&j[4]===j[5])return`#${j[0]}${j[2]}${j[4]}`}return q},Q=(q)=>{for(let H of Z){let z=q.getAttribute(H);if(z)q.setAttribute(H,K(z))}for(let H of q.children)if($0(H))Q(H)};return Q($),$}),R8=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 z=H.split(";").map((W)=>W.trim()).filter((W)=>W),j=[];for(let W of z){let G=W.indexOf(":");if(G===-1)continue;let F=W.substring(0,G).trim(),_=W.substring(G+1).trim();if(F&&_){if(!F.startsWith("-")&&K.has(F))q.setAttribute(F,_);else if(Z&&F.startsWith("-"))j.push(W)}}if(j.length>0)q.setAttribute("style",j.join("; "));else q.removeAttribute("style")}for(let z of q.children)if($0(z))Q(z)};return Q($),$}),hZ=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 z of K.getAttributeNames()){let j=K.getAttribute(z);if(z==="rx"||z==="ry")H.setAttribute("r",j);else H.setAttribute(z,j)}for(let z of[...K.children])H.appendChild(z);if(K.parentNode)K.parentNode.replaceChild(H,K)}}return $}),yZ=F0(($,J={})=>{let Z=J.force||!1,K=(Q,q=!1,H=!1)=>{let z=Q.tagName.toLowerCase(),j=H||z==="switch";for(let W of[...Q.children])if($0(W))K(W,!1,j);if(z!=="g")return;if(!Z&&(q||j))return;if(!Z&&Q.getAttribute("filter"))return;if(Q.children.length===1){let W=Q.children[0];if(!$0(W))return;if(!Z&&W.getAttribute("id"))return;let G=Array.from(Q.children).some((U)=>$0(U)&&e6.animation.has(U.tagName.toLowerCase()));if(!Z&&G)return;let F=Q.getAttributeNames(),_=F.some((U)=>{if(_6.has(U))return!1;return W.hasAttribute(U)});if(!Z&&_)return;if(F.length===0){if(Q.parentNode)Q.parentNode.replaceChild(W,Q)}else{let U=!0;for(let Y of F){if(!_6.has(Y)&&Y!=="class"&&Y!=="style"){U=!1;break}if(W.hasAttribute(Y)){U=!1;break}}if(U&&Q.parentNode){for(let Y of F){let V=Q.getAttribute(Y);if(V!==null)W.setAttribute(Y,V)}Q.parentNode.replaceChild(W,Q)}}}};return K($,!0),$}),uZ=F0(($,J={})=>{let Z=J.force||!1,K=(q)=>q&&q.includes("url("),Q=(q)=>{let H=[...q.children].filter((z)=>$0(z)&&z.tagName==="path");for(let z=0;z<H.length-1;z++){let j=H[z],W=H[z+1];if(!Z&&(j.children.length>0||W.children.length>0))continue;let F=["marker-start","marker-mid","marker-end"].some((Y)=>j.getAttribute(Y)||W.getAttribute(Y));if(!Z&&F)continue;if(!Z&&(j.getAttribute("clip-path")||j.getAttribute("mask")||W.getAttribute("clip-path")||W.getAttribute("mask")))continue;if(!Z){let Y=j.getAttribute("fill"),V=j.getAttribute("stroke"),O=W.getAttribute("fill"),X=W.getAttribute("stroke");if(K(Y)||K(V)||K(O)||K(X))continue}if(!Z){let Y=j.getAttribute("fill-rule")||"nonzero",V=W.getAttribute("fill-rule")||"nonzero";if(Y!==V)continue}if(!Z&&(j.getAttribute("filter")||W.getAttribute("filter")))continue;let _=j.getAttributeNames().filter((Y)=>Y!=="d").sort(),U=W.getAttributeNames().filter((Y)=>Y!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let Y=!0;for(let V of _)if(j.getAttribute(V)!==W.getAttribute(V)){Y=!1;break}if(Y){let V=j.getAttribute("d"),O=W.getAttribute("d");if(j.setAttribute("d",`${V} ${O}`),W.parentNode)W.parentNode.removeChild(W);H.splice(z+1,1),z--}}}for(let z of q.children)if($0(z))Q(z)};return Q($),$}),gZ=F0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g")for(let Q of[...K.getAttributeNames()]){if(!_6.has(Q))continue;let q=K.getAttribute(Q);if(q){for(let H of K.children)if($0(H)&&!H.hasAttribute(Q))H.setAttribute(Q,q);K.removeAttribute(Q)}}for(let Q of K.children)if($0(Q))Z(Q)};return Z($),$}),xZ=F0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g"&&K.children.length>1)for(let Q of _6){let q=null,H=!0;for(let z of K.children){if(!$0(z))continue;let j=z.getAttribute(Q);if(!j){H=!1;break}if(q===null)q=j;else if(q!==j){H=!1;break}}if(H&&q){K.setAttribute(Q,q);for(let z of K.children)if($0(z))z.removeAttribute(Q)}}for(let Q of K.children)if($0(Q))Z(Q)};return Z($),$}),B8=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("]]>"),z="",j="";if(H){let W=q.match(/^(\s*<!\[CDATA\[\s*)/),G=q.match(/(\s*\]\]>\s*)$/);if(W)z="<![CDATA[",q=q.replace(/^\s*<!\[CDATA\[\s*/,"");if(G)j="]]>",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(),z||j)q=z+q+j;Q.textContent=q}return $}),mZ=F0(($,J={})=>{let Z=J.onlyMatchedOnce!==!1,K=J.removeStyleElement!==!1,Q=$.getElementsByTagName("style"),q=[];for(let H of Q){let z=H.getAttribute("type");if(z&&z!=="text/css")continue;let j=H.textContent;if(!j||!j.trim())continue;if(j.includes("@media")||j.includes("@keyframes")||j.includes("@supports")||j.includes("@font-face"))continue;let W=j.match(/([^{]+)\{([^}]+)\}/g)||[],G=[];for(let U of W){let Y=U.match(/([^{]+)\{([^}]+)\}/);if(!Y)continue;let V=Y[1].trim(),O=Y[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=R$(V)}catch(w){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${w.message}`);q.push(U);continue}G.push({selector:V,declarations:O,specificity:k,originalRule:U})}G.sort((U,Y)=>B$(U.specificity,Y.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:Y,specificity:V,originalRule:O}of G)try{let X=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&X.length>1){q.push(O);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),C=k.getAttribute("style")||"";if(C&&I.size===0){let g=C.split(";");for(let T of g){let u=T.indexOf(":");if(u>0){let S=T.substring(0,u).trim(),A=T.substring(u+1).trim(),y=A.includes("!important");if(y)A=A.replace(/\s*!important\s*/g,"").trim();I.set(S,{specificity:[1,0,0,0],isImportant:y,value:A})}}}let v=Y.split(";");for(let g of v){let T=g.indexOf(":");if(T<=0)continue;let u=g.substring(0,T).trim(),S=g.substring(T+1).trim(),A=S.includes("!important");if(A)S=S.replace(/\s*!important\s*/g,"").trim();let y=I.get(u);if(y){let p=B$(V,y.specificity);if(p<0){if(A&&!y.isImportant)I.set(u,{specificity:V,isImportant:A,value:S})}else if(p===0){if(A||!y.isImportant)I.set(u,{specificity:V,isImportant:A,value:S})}else if(!y.isImportant||A)I.set(u,{specificity:V,isImportant:A,value:S})}else I.set(u,{specificity:V,isImportant:A,value:S})}}}catch(X){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${X.message}`);q.push(O)}for(let U of _){let Y=F.get(U),V=[];for(let[O,{value:X,isImportant:k}]of Y)if(k)V.push(`${O}: ${X} !important`);else V.push(`${O}: ${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 $}),dZ=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,z]of q)K.setAttribute(H,z);for(let H of K.children)if($0(H))Z(H)};return Z($),$}),pZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of Z){let Q=[...K.children].filter((q)=>$0(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 $}),cZ=F0(($,J={})=>{let Z=J.threshold||2,K=$.getElementsByTagName("path"),Q=new Map;for(let z of K){let j=z.getAttribute("d");if(j){if(!Q.has(j))Q.set(j,[]);Q.get(j).push(z)}}let q=$.querySelector("defs");if(!q)if(q=new w0("defs",{}),$.firstChild)$.insertBefore(q,$.firstChild);else $.appendChild(q);let H=0;for(let[z,j]of Q)if(j.length>=Z){let W=`path${H++}`,G=new w0("path",{id:W,d:z});q.appendChild(G);for(let F of j){let _=new w0("use",{href:`#${W}`});for(let U of F.getAttributeNames())if(U!=="d"){let Y=F.getAttribute(U);if(Y!==null)_.setAttribute(U,Y)}for(let U of[...F.children])_.appendChild(U);if(F.parentNode)F.parentNode.replaceChild(_,F)}}return $}),nZ=F0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let K=RJ(Z);if(!K)return $;let Q=D7($),q=$.getElementsByTagName("path");for(let H of[...q]){let z=H.getAttribute("d");if(!z)continue;try{let j=J6(z),W=BJ(j);if(!W)continue;let G=o6(H),_=s6(H,G,Q).getRenderedBBox(W),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!NJ(U,K)){if(H.parentNode)H.parentNode.removeChild(H)}}catch(j){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${j.message}`)}}return $}),lZ=F0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),sZ=F0(($,J={})=>{let Z={new:"_blank",replace:"_self"},K=!1,Q=(q)=>{for(let H of[...q.getAttributeNames()])if(H.startsWith("xlink:")){let z=H.substring(6),j=q.getAttribute(H);if(z==="href")K=!0;else if(z==="show"){if(!q.hasAttribute("target")){let W=Z[j];if(W)q.setAttribute("target",W)}q.removeAttribute(H)}else if(z==="title"){if(!(q.querySelector&&q.querySelector("title"))&&j){let G=new w0("title",{},[],j);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(z))q.removeAttribute(H);else K=!0}for(let H of q.children)if($0(H))Q(H)};if(Q($),!K)$.removeAttribute("xmlns:xlink");return $}),oZ=F0(($,J={})=>{let Z=J.attributes||{};for(let[K,Q]of Object.entries(Z))$.setAttribute(K,Q);return $}),iZ=F0(($,J={})=>{let Z=J.classes||[],K=$.getAttribute("class")||"",Q=K?`${K} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",Q.trim()),$}),rZ=F0(($,J={})=>{let Z=J.prefix||"svg",K=new Map,Q=new Map,q=(W)=>W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=(W)=>{let G=W.getAttribute("id");if(G){let F=`${Z}${G}`;K.set(G,F),W.setAttribute("id",F)}for(let F of W.children)if($0(F))H(F)};if(H($),J.prefixClassNames!==!1){let W=(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($0(U))W(U)};W($);let G=(F)=>{let _=F.getAttribute("class");if(_){let U=_.split(/\s+/).map((Y)=>Q.get(Y)||Y).join(" ");F.setAttribute("class",U)}for(let U of F.children)if($0(U))G(U)};G($)}let z=$.getElementsByTagName("style");for(let W of z){let G=W.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`)}W.textContent=G}let j=(W)=>{for(let G of W.getAttributeNames()){let F=W.getAttribute(G);if(F&&F.includes("url(#")){for(let[_,U]of K){let Y=q(_);F=F.replace(new RegExp(`url\\(#${Y}\\)`,"g"),`url(#${U})`)}W.setAttribute(G,F)}if((G==="href"||G==="xlink:href")&&F?.startsWith("#")){let _=F.substring(1);if(K.has(_))W.setAttribute(G,`#${K.get(_)}`)}if(G==="begin"||G==="end"){for(let[_,U]of K){let Y=q(_);F=F.replace(new RegExp(`(^|;|\\s)${Y}\\.`,"g"),`$1${U}.`)}W.setAttribute(G,F)}if(G==="values"||G==="from"||G==="to"||G==="by"){for(let[_,U]of K){let Y=q(_);F=F.replace(new RegExp(`#${Y}([;\\s]|$)`,"g"),`#${U}$1`)}W.setAttribute(G,F)}}for(let G of W.children)if($0(G))j(G)};return j($),$}),aZ=F0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),tZ=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 $}),eZ=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($0(H))Q(H)};return Q($),$}),$K=F0(($,J={})=>{let{name:Z,value:K}=J;if(!Z)return $;let Q=(q)=>{for(let H of[...q.children]){if(!$0(H))continue;let z=H.getAttribute(Z);if(K===void 0){if(z!==null){q.removeChild(H);continue}}else if(z===K){q.removeChild(H);continue}Q(H)}};return Q($),$}),N8=F0(async($,J={})=>{let Z={...J,outputFormat:O7.DOM_ELEMENT},K=$;return K=await J9(K,Z),K=await $9(K,Z),K=await e$(K,Z),K=await t$(K,Z),K=await a$(K,Z),K=await Z9(K,Z),K=await R8(K,Z),K=await L8(K,Z),K=await w8(K,Z),K=await B8(K,Z),K}),I8=F0(($,J={})=>{return $}),JK=F0(async($,J={})=>{let Z=J.preset||"default",K={...J,outputFormat:O7.DOM_ELEMENT};switch(Z){case"default":return await N8($,K);case"none":return await I8($,K);default:return $}}),ZK=F0(async($,J={})=>{let Z=J.config||{},K={...J,outputFormat:O7.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 a$(Q,K);if(Z.convertColors!==!1)Q=await Z9(Q,K);if(Z.removeHiddenElements!==!1)Q=await t$(Q,K);if(Z.removeEmptyContainers!==!1)Q=await e$(Q,K);return Q});function KK($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var QK=F0(async($,J={})=>{let Z=Z7($,{minify:J.minify!==!1}),K=await f6(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),qK=F0(async($,J={})=>{let Z=Z7($,{minify:J.minify!==!1}),K=await f6(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),HK=F0(($,J={})=>{let Z=D7($),K=(W)=>{let G=Z.get(W);if(!G)return null;let F=G.getAttribute("href")||G.getAttribute("xlink:href");return F?.startsWith("#")?F.substring(1):null},Q=(W,G)=>{let F=W.getAttribute("gradientUnits")||"objectBoundingBox",_=W.getAttribute("gradientTransform");if(Mz(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=A7($,"fill");for(let W of q){let G=W.getAttribute("fill");if(G&&G.includes("url(")){let F=h7(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 Y=zZ(_,J.position||0.5);W.setAttribute("fill",Y)}}else W.setAttribute("fill",J.fallbackColor||"#808080")}}let H=A7($,"stroke");for(let W of H){let G=W.getAttribute("stroke");if(G&&G.includes("url(")){let F=h7(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 Y=zZ(_,J.position||0.5);W.setAttribute("stroke",Y)}}else W.setAttribute("stroke",J.fallbackColor||"#808080")}}let z=[...$.querySelectorAll("linearGradient, radialGradient")],j=(W)=>W.replace(/["\\]/g,"\\$&");for(let W of z){let G=W.getAttribute("id"),F=G?j(G):"";if(!(G&&([...$.querySelectorAll(`[fill*="url(#${F})"]`)].length>0||[...$.querySelectorAll(`[stroke*="url(#${F})"]`)].length>0))&&W.parentNode)W.parentNode.removeChild(W)}return $});function zZ($,J=0.5){let Z=[...$.children].filter((z)=>z.tagName&&z.tagName.toLowerCase()==="stop");if(Z.length===0)return"#808080";if(Z.length===1)return WZ(Z[0]);let K=Z.map((z)=>{let j=z.getAttribute("offset")||"0";if(j.endsWith("%"))j=parseFloat(j)/100;else j=parseFloat(j);return j=isNaN(j)?0:Math.max(0,Math.min(1,j)),{offset:j,color:WZ(z),opacity:Yz(z)}});K.sort((z,j)=>z.offset-j.offset);let Q=null,q=null;for(let z=0;z<K.length;z++){let j=K[z];if(j.offset<=J)Q=j;if(j.offset>=J&&!q){q=j;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 kz(Q.color,q.color,H)}function WZ($){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 Xz(J)}function Yz($){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 Xz($){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 zK(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 kz($,J,Z){let K=(U)=>{let Y=U.replace("#","");if(Y.length===3)Y=Y[0]+Y[0]+Y[1]+Y[1]+Y[2]+Y[2];let V=parseInt(Y.slice(0,2),16),O=parseInt(Y.slice(2,4),16),X=parseInt(Y.slice(4,6),16);if(isNaN(V)||isNaN(O)||isNaN(X))return[0,0,0];return[V,O,X]},[Q,q,H]=K($),[z,j,W]=K(J),G=Math.round(Q+(z-Q)*Z),F=Math.round(q+(j-q)*Z),_=Math.round(H+(W-H)*Z);return zK(G,F,_)}function zK($,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 WK=F0(async($,J={})=>{let Z=Z7($,{minify:J.minify!==!1}),K=await f6(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),jK=F0(($,J={})=>{let Z=(Q)=>{if(Q.hasAttribute("filter"))Q.removeAttribute("filter");for(let q of Q.children)if($0(q))Z(q)};Z($);let K=$.getElementsByTagName("filter");for(let Q of[...K])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),GK=F0(async($,J={})=>{let Z=Z7($,{minify:J.minify!==!1}),K=await f6(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),FK=F0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let K of[...Z])K.setAttribute("data-trace-needed","true");return $}),_K=F0(($,J={})=>{let{samples:Z=10,includeStroke:K=!0,includeFillOnly:Q=!1}=J,q=[...$.getElementsByTagName("path"),...$.getElementsByTagName("rect"),...$.getElementsByTagName("circle"),...$.getElementsByTagName("ellipse")],H=D7($),z=[];for(let j=0;j<q.length;j++)for(let W=j+1;W<q.length;W++){let G=q[j],F=q[W],_=i$(G,Z),U=i$(F,Z);if(!_||!U)continue;let Y=o6(G),V=o6(F),O=s6(G,Y,H),X=s6(F,V,H);if(K&&!Q){if(O.hasStroke){let w=O.getStrokeExtent().toNumber();_=jZ(_,w)}if(X.hasStroke){let w=X.getStrokeExtent().toNumber();U=jZ(U,w)}}if(L$(_,U).overlaps)z.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:O.hasStroke?O.strokeWidth.toNumber():0,stroke2:X.hasStroke?X.strokeWidth.toNumber():0,fillRule1:O.fillRule,fillRule2:X.fillRule})}if(z.length>0)$.setAttribute("data-collisions",JSON.stringify(z));return $});function jZ($,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,z=Math.sqrt(q*q+H*H);if(z<0.0001)return Q;let j=(z+J)/z;return{x:Z+q*j,y:K+H*j}})}var UK=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=i$(Q,J.samples||10),z=i$(q,J.samples||10);if(H&&z){let j=XJ(H,z);$.setAttribute("data-distance",j.distance.toString())}return $}),VK=F0(($,J={})=>{let Z=[],K=[],Q=new Set,q=new Set,H=(j)=>{if(j.tagName.includes(":")){let W=j.tagName.split(":")[0];Q.add(W)}for(let W of j.getAttributeNames()){let G=j.getAttribute(W);if(W==="xmlns")q.add("");else if(W.startsWith("xmlns:")){let F=W.substring(6);q.add(F)}if(W.includes(":")&&!W.startsWith("xmlns:")){let F=W.split(":")[0];Q.add(F)}if(G&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(G))Z.push(`Invalid XML characters in attribute '${W}' of <${j.tagName}>`)}if(j.textContent&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(j.textContent))Z.push(`Invalid XML characters in text content of <${j.tagName}>`);for(let W of j.children)if($0(W))H(W)};H($);for(let j of Q)if(j&&!q.has(j))Z.push(`Unbound namespace prefix: '${j}' - SVGO would produce invalid XML here`);let z={valid:Z.length===0,errors:Z,warnings:K,namespacesUsed:[...Q],namespacesDeclared:[...q]};return $.setAttribute("data-xml-validation",JSON.stringify(z)),$}),MK=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,Y,V]=F.map(parseFloat);if(Y<0||V<0)Z.push("Invalid viewBox: width and height must be non-negative")}}let z={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},j={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},W=(F,_=0)=>{if(!F||!F.tagName){K.push(`Element at depth ${_} has no tagName property`);return}let U=F.tagName.toLowerCase(),Y=F.tagName;if(j[Y])Z.push(`Invalid SVG 2.0 element: <${Y}> must be lowercase <${j[Y]}> per SVG 2.0 specification`);if(U==="meshgradient"){let V=F.getAttribute("id");if(z.meshGradients.push(V||null),z.needsPolyfills=!0,!V)K.push("<meshgradient> element without 'id' attribute may be difficult to reference")}if(U==="hatch"){let V=F.getAttribute("id");if(z.hatches.push(V||null),z.needsPolyfills=!0,!V)K.push("<hatch> element without 'id' attribute may be difficult to reference")}if(U==="solidcolor"){let V=F.getAttribute("id");if(z.solidColors.push(V||null),z.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 O=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!O||O.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"),O=F.getAttribute("height");if(V!==null&&!o7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(O!==null&&!o7(O)&&parseFloat(O)<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"),O=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(O!==null&&parseFloat(O)<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 O=V.substring(1);if(!$.getElementById(O))K.push(`<use> references non-existent ID: '${O}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let O=F.getAttribute(V);if(O&&O.startsWith("url(#")){let X=O.match(/url\(#([^)]+)\)/);if(X){let k=X[1];if(!$.getElementById(k))K.push(`<${F.tagName}> ${V} references non-existent ID: '${k}'`)}}}if($$[U]){let V=$$[U];for(let O of F.children)if($0(O)){let X=O.tagName.toLowerCase();if(!V.has(X))K.push(`<${X}> is not a standard child of <${U}>`)}}for(let V of F.children)if($0(V))W(V,_+1)};if(W($),z.needsPolyfills){let F=[];if(z.meshGradients.length>0)F.push(`meshgradient (${z.meshGradients.length} found)`);if(z.hatches.length>0)F.push(`hatch (${z.hatches.length} found)`);if(z.solidColors.length>0)F.push(`solidcolor (${z.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:XK($),svg2Features:z};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 $}),wz=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"]),Lz=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 O=[],X=V.toLowerCase(),k=(w)=>{if(w.tagName&&w.tagName.toLowerCase()===X)O.push(w);for(let R of w.children||[])if(R&&R.tagName)k(R)};return k($),O},H=(V,O=[])=>{if(V.tagName)O.push(V);for(let X of V.children||[])if(X&&X.tagName)H(X,O);return O},z=q("audio");if(z.length>0)Q.media.hasAudio=!0,Q.media.audioElements=z.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src"),hasSource:q("source").filter((O)=>O.parentNode===V).length>0}));let j=q("video");if(j.length>0)Q.media.hasVideo=!0,Q.media.videoElements=j.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src")}));let W=q("foreignObject");for(let V of W){let O=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 C of R.children||[])if(C&&C.tagName)w(C)};for(let R of O)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 O of["src","href","xlink:href"]){let X=V.getAttribute(O);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 O=q(V),X=O.length;Q.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=X,Q.smil.animationCount+=X;for(let k of O){let w=k.getAttribute("begin")||"",R=k.getAttribute("end")||"",I=(g,T)=>{let u=g.split(";").map((S)=>S.trim()).filter(Boolean);for(let S of u){let A=S.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(A){let[,y,p,m]=A;if(wz.has(p))Q.smil.hasInteractiveAnimations=!0,Q.smil.eventTriggers.push({animationElement:V,animationId:k.getAttribute("id"),attribute:T,event:p,targetId:y||null,offset:m?.trim()||null,parentId:k.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(S)||S==="indefinite")Q.smil.timingTriggers.push({animationElement:V,value:S});else if(/\.(begin|end)/.test(S))Q.smil.timingTriggers.push({animationElement:V,value:S,type:"syncbase"})}};if(w)I(w,"begin");if(R)I(R,"end");let C=k.getAttribute("onbegin"),v=k.getAttribute("onend");if(C||v){if(Q.smil.hasInteractiveAnimations=!0,C?.includes("play()")||v?.includes("play()"))Q.info.push(`Animation uses JavaScript to trigger audio playback via ${C?"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((O)=>O.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"}],Y=[{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:Y},K&&(Q.media.hasAudio||Q.media.hasVideo||Q.smil.hasInteractiveAnimations)){if(console.log(`
|
|
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
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[V,
|
|
25
|
-
--- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let
|
|
26
|
-
--- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of
|
|
27
|
-
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of Q.smil.eventTriggers){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
28
|
--- RECOMMENDATIONS ---`);for(let V of Q.compatibility.recommendations)console.log(` • ${V}`)}console.log(`
|
|
29
29
|
`+"=".repeat(80)+`
|
|
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,$}),K$={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}},Rz={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"}},Bz={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"}},Nz={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"}},GZ={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}},Iz={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}},FZ={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:"➖"},U8={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"},Cz=F0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q=J.includeMetaAnalysis!==!1,q=(f)=>{let E=[],t=f.toLowerCase(),e=(Q0)=>{if(Q0.tagName&&Q0.tagName.toLowerCase()===t)E.push(Q0);for(let V0 of Q0.children||[])if(V0&&V0.tagName)e(V0)};return e($),E},H=(f,E=[])=>{if(f.tagName)E.push(f);for(let t of f.children||[])if(t&&t.tagName)H(t,E);return E},z=(f,...E)=>{for(let t of E)if(f.getAttribute(t))return!0;return!1},j={detected:new Set,details:{}},W=H($),G=q("script");if(G.length>0){if(j.detected.add(X0.JAVASCRIPT),j.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")},j.details.javascript.hasExternalSrc)j.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 W){let E=F.filter((t)=>f.getAttribute(t));if(E.length>0)_.push({tag:f.tagName,handlers:E})}if(_.length>0)j.detected.add(X0.EVENT_HANDLERS),j.details.eventHandlers={count:_.length,types:[...new Set(_.flatMap((f)=>f.handlers))],elements:_.slice(0,10)};let U=["animate","animatetransform","animatemotion","animatecolor","set"],Y=[],V=[];for(let f of U){let E=q(f);Y.push(...E);for(let t of E){let e=t.getAttribute("begin")||"",Q0=t.getAttribute("end")||"",V0=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let N0 of V0)if(e.includes(N0)||Q0.includes(N0))V.push({element:t.tagName,event:N0,begin:e,end:Q0});if(e.includes("accessKey(")||Q0.includes("accessKey("))V.push({element:t.tagName,event:"accessKey",begin:e,end:Q0})}}if(Y.length>0){if(j.detected.add(X0.SMIL_ANIMATIONS),j.details.smilAnimations={count:Y.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)j.detected.add(X0.SMIL_INTERACTIVE),j.details.smilInteractive={count:V.length,triggers:[...new Set(V.map((f)=>f.event))],elements:V.slice(0,10)}}let O=q("style"),X=!1;for(let f of O){let E=f.textContent||"";if(E.includes("@keyframes")||E.includes("animation:")||E.includes("animation-name")||E.includes("transition:")||E.includes("transition-property")){X=!0;break}}for(let f of W){let E=f.getAttribute("style")||"";if(E.includes("animation")||E.includes("transition")){X=!0;break}}if(X)j.detected.add(X0.CSS_ANIMATIONS),j.details.cssAnimations={detected:!0};let k=q("audio"),w=q("video"),R=q("foreignobject");for(let f of R){let E=[],t=[],e=(Q0)=>{let V0=Q0.tagName?.toLowerCase();if(V0==="audio")E.push(Q0);if(V0==="video")t.push(Q0);for(let N0 of Q0.children||[])if(N0&&N0.tagName)e(N0)};for(let Q0 of f.children||[])if(Q0&&Q0.tagName)e(Q0);k.push(...E),w.push(...t)}if(k.length>0)j.detected.add(X0.AUDIO),j.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)j.detected.add(X0.VIDEO),j.details.video={count:w.length,hasAutoplay:w.some((f)=>f.hasAttribute("autoplay"))};let I=q("image"),C=[],v=[];for(let f of I){let E=f.getAttribute("href")||f.getAttribute("xlink:href")||"";if(E.startsWith("http://")||E.startsWith("https://")||E.startsWith("//"))C.push({href:E,element:"image"});else if(E.startsWith("data:"))v.push({type:"data-uri",element:"image"});else if(E&&!E.startsWith("#"))C.push({href:E,element:"image",type:"local"})}if(C.length>0)j.detected.add(X0.EXTERNAL_IMAGES),j.details.externalImages={count:C.length,urls:C.slice(0,5)};let g=q("use"),T=[];for(let f of g){let E=f.getAttribute("href")||f.getAttribute("xlink:href")||"";if(E&&!E.startsWith("#"))T.push({href:E})}if(T.length>0)j.detected.add(X0.EXTERNAL_USE),j.details.externalUse={count:T.length,refs:T.slice(0,5)};let u=!1;for(let f of O){let E=f.textContent||"";if(E.includes("@font-face")&&E.includes("url(")){let t=E.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(t){u=!0,j.detected.add(X0.EXTERNAL_FONTS),j.details.externalFonts={detected:!0,sample:t[1]};break}}}if(R.length>0){if(j.detected.add(X0.FOREIGN_OBJECT),j.details.foreignObject={count:R.length,hasIframe:R.some((f)=>{let E=!1,t=(e)=>{if(e.tagName?.toLowerCase()==="iframe")E=!0;for(let Q0 of e.children||[])if(Q0&&Q0.tagName)t(Q0)};return t(f),E})},j.details.foreignObject.hasIframe)j.detected.add(X0.IFRAME)}let S=q("filter"),A=q("mask"),y=q("clippath");if(S.length>0)j.detected.add(X0.FILTERS),j.details.filters={count:S.length};if(A.length>0)j.detected.add(X0.MASKS),j.details.masks={count:A.length};if(y.length>0)j.detected.add(X0.CLIP_PATHS),j.details.clipPaths={count:y.length};let p=q("a");if(p.length>0)j.detected.add(X0.HYPERLINKS),j.details.hyperlinks={count:p.length,hasExternal:p.some((f)=>{return(f.getAttribute("href")||f.getAttribute("xlink:href")||"").startsWith("http")})};let m={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},B={FILE:"file://",HTTP:"http://"},h={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},N={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},n={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},o={[X0.JAVASCRIPT]:{[N.NONE]:{file:"✅",http:"✅",note:"Full JS execution"},[N.IMG]:{file:"❌",http:"❌",note:"All scripting disabled for security"},[N.OBJECT]:{file:"✅",http:"✅",note:"Isolated JS context"},[N.EMBED]:{file:"✅",http:"✅",note:"Isolated JS context"},[N.INLINE]:{file:"✅",http:"✅",note:"Same JS context as parent page"},[N.CSS]:{file:"❌",http:"❌",note:"CSS image context - no scripts"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS-generated = full control"}},[X0.EVENT_HANDLERS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full event handling"},[N.IMG]:{file:"❌",http:"❌",note:"No events in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[N.EMBED]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[N.INLINE]:{file:"✅",http:"✅",note:"Full event handling"},[N.CSS]:{file:"❌",http:"❌",note:"No events in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full event handling"}},[X0.SMIL_ANIMATIONS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.IMG]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[N.OBJECT]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.EMBED]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.INLINE]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.CSS]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full SMIL support"}},[X0.SMIL_INTERACTIVE]:{[N.NONE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[N.IMG]:{file:"❌",http:"❌",note:"No interaction in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[N.EMBED]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[N.INLINE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[N.CSS]:{file:"❌",http:"❌",note:"No interaction in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full interactive SMIL"}},[X0.CSS_ANIMATIONS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.IMG]:{file:"✅",http:"✅",note:"CSS animations work in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.EMBED]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.INLINE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.CSS]:{file:"✅",http:"✅",note:"CSS animations work"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full CSS animation support"}},[X0.AUDIO]:{[N.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[N.IMG]:{file:"❌",http:"❌",note:"No audio in img context"},[N.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[N.CSS]:{file:"❌",http:"❌",note:"No audio in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS can play audio on user gesture"}},[X0.VIDEO]:{[N.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[N.IMG]:{file:"❌",http:"❌",note:"No video in img context"},[N.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[N.CSS]:{file:"❌",http:"❌",note:"No video in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS can play video on user gesture"}},[X0.EXTERNAL_IMAGES]:{[N.NONE]:{file:"⚠️",http:"✅",note:"file:// may have CORS issues"},[N.IMG]:{file:"❌",http:"⚠️",note:"Blocked or CORS restricted"},[N.OBJECT]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.EMBED]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.INLINE]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.CSS]:{file:"❌",http:"⚠️",note:"Restricted for security"},[N.SCRIPT]:{file:"⚠️",http:"✅",note:"CORS applies"}},[X0.EXTERNAL_CSS]:{[N.NONE]:{file:"✅",http:"✅",note:"External CSS loaded"},[N.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"External CSS works"},[N.EMBED]:{file:"✅",http:"✅",note:"External CSS works"},[N.INLINE]:{file:"✅",http:"✅",note:"External CSS works"},[N.CSS]:{file:"❌",http:"❌",note:"No external resources"},[N.SCRIPT]:{file:"✅",http:"✅",note:"External CSS works"}},[X0.EXTERNAL_FONTS]:{[N.NONE]:{file:"✅",http:"✅",note:"External fonts loaded"},[N.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.EMBED]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.INLINE]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.CSS]:{file:"❌",http:"⚠️",note:"Limited, varies by browser"},[N.SCRIPT]:{file:"✅",http:"✅",note:"External fonts work"}},[X0.EXTERNAL_USE]:{[N.NONE]:{file:"❌",http:"⚠️",note:"Most browsers block external use"},[N.IMG]:{file:"❌",http:"❌",note:"No external use in img"},[N.OBJECT]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.EMBED]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.INLINE]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.CSS]:{file:"❌",http:"❌",note:"No external use"},[N.SCRIPT]:{file:"❌",http:"⚠️",note:"Most browsers block"}},[X0.FOREIGN_OBJECT]:{[N.NONE]:{file:"✅",http:"✅",note:"Full foreignObject support"},[N.IMG]:{file:"❌",http:"❌",note:"foreignObject disabled in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"foreignObject works"},[N.EMBED]:{file:"✅",http:"✅",note:"foreignObject works"},[N.INLINE]:{file:"✅",http:"✅",note:"foreignObject works"},[N.CSS]:{file:"❌",http:"❌",note:"foreignObject disabled"},[N.SCRIPT]:{file:"✅",http:"✅",note:"foreignObject works"}},[X0.HYPERLINKS]:{[N.NONE]:{file:"✅",http:"✅",note:"Links work"},[N.IMG]:{file:"❌",http:"❌",note:"No links in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Links work (in iframe-like context)"},[N.EMBED]:{file:"✅",http:"✅",note:"Links work"},[N.INLINE]:{file:"✅",http:"✅",note:"Links work normally"},[N.CSS]:{file:"❌",http:"❌",note:"No links in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Links work"}},[X0.FILTERS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full filter support"},[N.IMG]:{file:"✅",http:"✅",note:"Filters work"},[N.OBJECT]:{file:"✅",http:"✅",note:"Filters work"},[N.EMBED]:{file:"✅",http:"✅",note:"Filters work"},[N.INLINE]:{file:"✅",http:"✅",note:"Filters work"},[N.CSS]:{file:"✅",http:"✅",note:"Filters work"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Filters work"}}},s={"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:j,interactivityLevel:"static",bySyntax:{},specialCases:{},recommendations:[],warnings:[]};if(j.detected.has(X0.JAVASCRIPT)||j.detected.has(X0.EVENT_HANDLERS))q0.interactivityLevel="scripted";else if(j.detected.has(X0.SMIL_INTERACTIVE))q0.interactivityLevel="interactive";else if(j.detected.has(X0.SMIL_ANIMATIONS)||j.detected.has(X0.CSS_ANIMATIONS))q0.interactivityLevel="animated";for(let f of Object.values(N)){q0.bySyntax[f]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let E of j.detected){let t=o[E];if(t&&t[f]){let{file:e,http:Q0,note:V0}=t[f];if(e==="✅")q0.bySyntax[f].file.works.push({feature:E,note:V0});else if(e==="⚠️")q0.bySyntax[f].file.partial.push({feature:E,note:V0});else q0.bySyntax[f].file.blocked.push({feature:E,note:V0});if(Q0==="✅")q0.bySyntax[f].http.works.push({feature:E,note:V0});else if(Q0==="⚠️")q0.bySyntax[f].http.partial.push({feature:E,note:V0});else q0.bySyntax[f].http.blocked.push({feature:E,note:V0})}}}for(let[f,E]of Object.entries(s)){let t=[],e=[];for(let Q0 of j.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(E.restrictions.some((r)=>r.toLowerCase().includes(N0.toLowerCase())||r.toLowerCase().includes("no "+N0.toLowerCase())))t.push(N0);else if(E.worksFor.some((J0)=>J0.toLowerCase().includes(N0.toLowerCase())))e.push(N0)}q0.specialCases[f]={syntax:E.syntax,blockedFeatures:t,workingFeatures:e,note:E.note,overallCompat:t.length===0?"✅ Compatible":t.length<j.detected.size/2?"⚠️ Partial":"❌ Not compatible"}}if(j.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', () => {
|
|
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: ${q0.interactivityLevel.toUpperCase().padEnd(75)} │`),console.log("│"+" ".repeat(98)+"│");for(let Q0 of
|
|
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
|
|
37
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let f="inline",
|
|
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
|
|
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
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(
|
|
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 $._compatibilityMatrix=q0,$}),
|
|
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 Q0={};for(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: ${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((
|
|
50
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let
|
|
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[
|
|
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 V0=[];if(
|
|
55
|
-
<!-- Isolated: --> <object data="app.svg"></object>`});if([...
|
|
56
|
-
┌`+"─".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 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
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
|
|
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 "${
|
|
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
|
-
`),$._fullCompatibilityMatrix=
|
|
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
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
|
|
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[
|
|
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(Q.length*
|
|
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
|
|
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
|
-
`),$}function
|
|
74
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
75
|
-
viewBox="0 0 ${X} ${k}" preserveAspectRatio="xMinYMin meet" height="${k}" width="100%">
|
|
76
|
-
<title>SVG Compatibility Matrix</title>
|
|
77
|
-
<desc>Browser and functionality compatibility for different SVG embedding methods</desc>
|
|
78
|
-
|
|
79
|
-
<defs>
|
|
80
|
-
<style>
|
|
81
|
-
.title { font: bold 18px ${Q}; fill: #333; }
|
|
82
|
-
.subtitle { font: 12px ${Q}; fill: #666; }
|
|
83
|
-
.col-header { font: bold 11px ${Q}; fill: #333; }
|
|
84
|
-
.col-subheader { font: 10px ${Q}; fill: #555; }
|
|
85
|
-
.row-header { font: bold 10px ${Q}; fill: #333; }
|
|
86
|
-
.row-subheader { font: 9px ${Q}; fill: #555; }
|
|
87
|
-
.cell-text { font: 8px ${Q}; fill: #333; }
|
|
88
|
-
.cell-ok { fill: #E8F5E9; }
|
|
89
|
-
.cell-warn { fill: #FFF3E0; }
|
|
90
|
-
.cell-block { fill: #FFEBEE; }
|
|
91
|
-
.legend-text { font: 10px ${Q}; fill: #333; }
|
|
92
|
-
.grid-line { stroke: #DDD; stroke-width: 1; }
|
|
93
|
-
.grid-line-bold { stroke: #999; stroke-width: 2; }
|
|
94
|
-
${q?`
|
|
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="${X/2}" y="25" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
|
|
104
|
-
<text x="${X/2}" y="42" text-anchor="middle" class="subtitle">
|
|
105
|
-
${V} columns × ${O} rows = ${V*O} combinations
|
|
106
|
-
</text>
|
|
107
|
-
|
|
108
|
-
<g transform="translate(20, 55)">
|
|
109
|
-
`,C=140;for(let S of H){let A=z.length*Z;I+=` <rect x="${C}" y="0" width="${A}" height="25" fill="#E3F2FD" stroke="#90CAF9"/>
|
|
110
|
-
<text x="${C+A/2}" y="17" text-anchor="middle" class="col-header">${S.label}</text>
|
|
111
|
-
`;for(let y=0;y<z.length;y++){let p=z[y],m=C+y*Z;I+=` <rect x="${m}" y="25" width="${Z}" height="20" fill="#F5F5F5" stroke="#DDD"/>
|
|
112
|
-
<text x="${m+Z/2}" y="39" text-anchor="middle" class="col-subheader">${p.label}</text>
|
|
113
|
-
`}C+=A}let v=45;for(let S of j){let y=W.length*G.length*K;I+=` <rect x="0" y="${v}" width="50" height="${y}" fill="#E8EAF6" stroke="#9FA8DA"/>
|
|
114
|
-
<text x="25" y="${v+y/2}" text-anchor="middle" dominant-baseline="middle" class="row-header" transform="rotate(-90, 25, ${v+y/2})">${S.label}</text>
|
|
115
|
-
`;for(let p of W)for(let m of G){I+=` <rect x="50" y="${v}" width="90" height="${K}" fill="#FAFAFA" stroke="#EEE"/>
|
|
116
|
-
<text x="55" y="${v+K/2-6}" class="row-subheader">${p.label}</text>
|
|
117
|
-
<text x="55" y="${v+K/2+8}" class="row-subheader">${m.label}</text>
|
|
118
|
-
`,C=140;for(let B of H)for(let h of z){let N=R(S.id,p.id,h.id,B.id,m.id),n=`cell-${N.overallStatus}`,o="";for(let q0 of F){let f="ok";for(let t of _){let e=N.browserStatus[q0.id][t.id];if(e==="block"){f="block";break}else if(e==="warn"&&f!=="block")f="warn"}let E=f==="ok"?"✓":f==="warn"?"⚠":"✗";o+=`${q0.code}${E}`}let s="";for(let q0 of _){let f=N.funcStatus[q0.id];if(f!=="ok")s+=`${q0.code}${f==="warn"?"⚠":"✗"}`}if(!s)s="OK";if(I+=` <g class="cell-group">
|
|
119
|
-
<rect x="${C}" y="${v}" width="${Z}" height="${K}" class="${n}" stroke="#DDD"/>
|
|
120
|
-
<text x="${C+Z/2}" y="${v+15}" text-anchor="middle" class="cell-text">${o.substring(0,10)}</text>
|
|
121
|
-
<text x="${C+Z/2}" y="${v+28}" text-anchor="middle" class="cell-text">${o.substring(10)}</text>
|
|
122
|
-
<text x="${C+Z/2}" y="${v+40}" text-anchor="middle" class="cell-text" fill="${w[N.overallStatus]}">${s.substring(0,8)}</text>
|
|
123
|
-
`,q)I+=` <g class="tooltip" transform="translate(${C+Z/2}, ${v-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">${B.label}/${h.label}</text>
|
|
126
|
-
<text x="0" y="-17" text-anchor="middle" fill="#FFF" font-size="8">${S.label} ${p.label} ${m.label}</text>
|
|
127
|
-
</g>
|
|
128
|
-
`;I+=` </g>
|
|
129
|
-
`,C+=Z}v+=K}}let g=80+O*K+20;I+=`
|
|
130
|
-
<!-- Legend -->
|
|
131
|
-
<g transform="translate(0, ${g})">
|
|
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 T=90;for(let S of F)I+=` <text x="${T}" y="60" class="legend-text"><tspan fill="${S.color}" font-weight="bold">${S.code}</tspan>=${S.name}</text>
|
|
147
|
-
`,T+=85;I+=`
|
|
148
|
-
<!-- Functionality codes -->
|
|
149
|
-
<text x="10" y="80" class="col-header">FUNCTIONS:</text>
|
|
150
|
-
`,T=90;let u=0;for(let S of _){if(T>600)T=90,u++;I+=` <text x="${T}" y="${80+u*18}" class="legend-text"><tspan fill="${S.color}" font-weight="bold">${S.code}</tspan>=${S.name}</text>
|
|
151
|
-
`,T+=100}return I+=` </g>
|
|
152
|
-
</g>
|
|
153
|
-
</svg>`,I}function Tz($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(n)=>String(n).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"]}],z=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],j=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],W=(n,o,s,q0)=>{let f=[],E=(t)=>f.push({text:t});if(q0==="img"||q0==="css")return E("No scripts"),E("No events"),E("No audio/video"),E("No links"),E("No foreignObject"),E("No external resources"),f;if(s==="nojs")E("No scripts"),E("No event handlers");if(o==="file")E("No remote fonts (Chrome, Safari)"),E("No remote images (Chrome)"),E("No fetch/XHR to remote URLs");if(q0==="object"||q0==="embed"){if(E("No event bubbling to parent"),o==="http")E("No cross-origin script access")}if(n==="desktop"){if(E("No SMIL (IE11 only)"),E("No CSS variables (IE11 only)"),s==="js")E("Audio: blocked until user click/tap event"),E("Audio: once blocked, won't auto-retry")}if(n==="mobile")E("No hover/mouseover events"),E("Audio: blocked until user tap event"),E("Audio: once blocked, won't auto-retry"),E("Video autoplay blocked");return f},G=0;for(let n of q)for(let o of z)for(let s of j)for(let q0 of Q){let f=W(n.id,o.id,s.id,q0.id).length;if(f>G)G=f}let F=130,_=80,U=90,Y=F+_+U,V=60,O=220,X=13,k=Math.max(80,(G+1)*X+25),w=Q.length,R=q.length*z.length*j.length,I=Y+w*O,v=V+R*k+40,g=30,T=40+H.length*g,u=v+T+30,S=1020,A=I+50,y=55+u+S+50,p=`<?xml version="1.0" encoding="UTF-8"?>
|
|
154
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${A} ${y}" preserveAspectRatio="xMinYMin meet" height="${y}" 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%">
|
|
155
75
|
<title>SVG Compatibility Matrix</title>
|
|
156
76
|
|
|
157
77
|
<defs>
|
|
@@ -172,36 +92,36 @@ ${H}
|
|
|
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="${F/2}" y="${
|
|
189
|
-
`;for(let
|
|
190
|
-
<text x="${F+_/2}" y="${
|
|
191
|
-
`;for(let f of
|
|
192
|
-
<text x="${F+_+U/2}" y="${
|
|
193
|
-
`,
|
|
194
|
-
`,
|
|
195
|
-
<text x="${
|
|
196
|
-
`;else{let Q0=
|
|
197
|
-
`,Q0+=X}}
|
|
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,8 +209,8 @@ ${H}
|
|
|
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 ${
|
|
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%">
|
|
294
214
|
<title>${F(J)}</title>
|
|
295
215
|
|
|
296
216
|
<defs>
|
|
@@ -311,37 +231,37 @@ ${H}
|
|
|
311
231
|
</style>
|
|
312
232
|
</defs>
|
|
313
233
|
|
|
314
|
-
<text x="${
|
|
315
|
-
${Z?`<text x="${
|
|
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>`:""}
|
|
316
236
|
|
|
317
237
|
<g transform="translate(${G.marginLeft}, ${G.marginTop})">
|
|
318
|
-
`,
|
|
319
|
-
<text x="${
|
|
320
|
-
`}}let
|
|
321
|
-
<text x="${
|
|
322
|
-
`,
|
|
323
|
-
`}let
|
|
324
|
-
<text x="${
|
|
325
|
-
`,
|
|
326
|
-
`,h0.length===0)
|
|
327
|
-
`;else{let _0=
|
|
328
|
-
`,_0+=G.lineHeight}}if(
|
|
329
|
-
`}}let q0=
|
|
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+=`
|
|
330
250
|
<text x="0" y="${q0}" class="section-title">${F(f.title)}</text>
|
|
331
|
-
`,q0+=20;if(f.content)
|
|
251
|
+
`,q0+=20;if(f.content)N+=` <g transform="translate(0, ${q0})">
|
|
332
252
|
${f.content}
|
|
333
253
|
</g>
|
|
334
|
-
`;if(f.items)for(let
|
|
335
|
-
`;if(
|
|
336
|
-
`}q0+=f.height||100}if(
|
|
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+=`
|
|
337
257
|
<g transform="translate(0, ${q0})">
|
|
338
|
-
${
|
|
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,12 +347,12 @@ ${H}
|
|
|
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 OK({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:z,height:H.length*30+20}],legend:W,options:{fontFamily:J,minCellWidth:220,legendHeight:1020,...$}})}var YK=F0(($,J={})=>{let Z=J.fixInvalidGroupAttrs!==!1,K=J.fixMissingNamespaces!==!1,Q=J.fixBrokenRefs!==!1,q=J.fixAnimationTiming!==!1,H=J.verbose||!1,z=[],j=new Set,W=(D)=>{let P=D.getAttribute("id");if(P)j.add(P);for(let l of D.children)if($0(l))W(l)};W($);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"]),_=(D)=>{let P=D.tagName.toLowerCase();if(P==="g"&&Z){for(let l of G)if(D.hasAttribute(l)){let c=D.getAttribute(l);D.removeAttribute(l),z.push({type:"invalid_attr_removed",element:P,attr:l,value:c,reason:`SVG 1.1: <g> elements do not support '${l}' attribute`})}}for(let l of D.children)if($0(l))_(l)},U=()=>{if(!K)return;let D=!1,P=(l)=>{for(let c of l.getAttributeNames())if(c.startsWith("xlink:")){D=!0;return}for(let c of l.children){if($0(c))P(c);if(D)return}};if(P($),D&&!$.hasAttribute("xmlns:xlink"))$.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),z.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"})},Y=(D)=>{let P=[D,D.replace(/^FRAME(\d+)$/,"FRAME0$1"),D.replace(/^FRAME0(\d+)$/,"FRAME00$1"),D.replace(/^FRAME00(\d+)$/,"FRAME000$1"),D.replace(/^FRAME0+(\d+)$/,"FRAME$1"),D.replace(/^FRAME(\d)$/,"FRAME0000$1"),D.replace(/^FRAME(\d{2})$/,"FRAME000$1"),D.replace(/^FRAME(\d{3})$/,"FRAME00$1"),D.replace(/^FRAME(\d{4})$/,"FRAME0$1")];for(let i of P)if(j.has(i)&&i!==D)return i;let l=null,c=1/0;for(let i of j)if(i.toLowerCase().includes(D.toLowerCase())||D.toLowerCase().includes(i.toLowerCase())){let G0=Math.abs(i.length-D.length);if(G0<c&&G0<=2)c=G0,l=i}return l},V=(D)=>{if(!Q)return;for(let P of["href","xlink:href"]){let l=D.getAttribute(P);if(l&&l.startsWith("#")){let c=l.substring(1);if(!j.has(c)){let i=Y(c);if(i)D.setAttribute(P,`#${i}`),z.push({type:"ref_fixed",element:D.tagName.toLowerCase(),attr:P,oldValue:l,newValue:`#${i}`,reason:`ID '${c}' not found, fixed to similar ID '${i}'`})}}}if(D.tagName.toLowerCase()==="animate"){let P=D.getAttribute("attributeName");if(P==="href"||P==="xlink:href"){let l=D.getAttribute("values");if(l){let c=l.split(";"),i=!1,G0=c.map((L0)=>{let C0=L0.trim();if(C0.startsWith("#")){let E0=C0.substring(1);if(!j.has(E0)){let X7=Y(E0);if(X7)return i=!0,`#${X7}`}}return C0});if(i){let L0=G0.join(";");D.setAttribute("values",L0),z.push({type:"animate_values_fixed",oldValue:l,newValue:L0,reason:"Fixed broken ID references in animate values"})}}}}for(let P of["fill","stroke","clip-path","mask","filter"]){let l=D.getAttribute(P);if(l&&l.startsWith("url(#")){let c=l.match(/url\(#([^)]+)\)/);if(c){let i=c[1];if(!j.has(i)){let G0=Y(i);if(G0)D.setAttribute(P,`url(#${G0})`),z.push({type:"url_ref_fixed",element:D.tagName.toLowerCase(),attr:P,oldValue:l,newValue:`url(#${G0})`,reason:`ID '${i}' not found, fixed to similar ID '${G0}'`})}}}}for(let P of D.children)if($0(P))V(P)},O=(D)=>{if(!q)return;let P=["animate","animateTransform","animateMotion","animateColor","set"],l=D.tagName.toLowerCase();if(P.includes(l)){let c=D.getAttribute("dur"),i=D.getAttribute("repeatCount");if(c==="0"||c==="0s"){if(!D.getAttribute("keyTimes"))z.push({type:"timing_warning",element:l,attr:"dur",value:c,reason:'dur="0" may cause animation to not play'})}let G0=D.getAttribute("begin");if(G0){let L0=G0;if(G0==="0")L0="0s",D.setAttribute("begin",L0),z.push({type:"timing_normalized",element:l,attr:"begin",oldValue:G0,newValue:L0,reason:"Normalized begin value to include time unit"})}}for(let c of D.children)if($0(c))O(c)},X=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),k=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),w=(D)=>{let P=D.tagName.toLowerCase();if(X.has(P)){let l=[];for(let c of Array.from(D.children))if($0(c)&&k.has(c.tagName.toLowerCase()))l.push(c);if(l.length>0){let c=D.getAttribute("id");if(!c)c=`_fix_${P}_${Math.random().toString(36).substring(2,8)}`,D.setAttribute("id",c),z.push({type:"id_generated",element:P,id:c,reason:"Generated ID for animation targeting after moving animate element"});for(let i of l){if(D.removeChild(i),!i.hasAttribute("href")&&!i.hasAttribute("xlink:href"))i.setAttribute("href",`#${c}`);let G0=D.parentNode;if(G0){let L0=D.nextSibling;if(L0)G0.insertBefore(i,L0);else G0.appendChild(i)}z.push({type:"animation_moved_from_empty_element",element:i.tagName.toLowerCase(),parentElement:P,targetId:c,reason:`SVG 1.1: <${P}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${c}".`})}}}for(let l of Array.from(D.children))if($0(l))w(l)},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"]),C=(D)=>{for(let P of D.getAttributeNames()){if(!I.has(P)&&!P.includes("-"))continue;let l=D.getAttribute(P);if(!l)continue;let c=l.match(R);if(c){let[,i,G0]=c,L0=G0.toLowerCase();if(G0!==L0){let C0=i+L0;D.setAttribute(P,C0),z.push({type:"unit_normalized",element:D.tagName.toLowerCase(),attr:P,oldValue:l,newValue:C0,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let P of D.children)if($0(P))C(P)},v=/[\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"]),T=(D)=>{for(let P of D.getAttributeNames()){if(!g.has(P)&&P!=="style")continue;let l=D.getAttribute(P);if(!l)continue;if(v.test(l)){let c=l.replace(v," ");D.setAttribute(P,c),z.push({type:"whitespace_normalized",element:D.tagName.toLowerCase(),attr:P,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let P of D.children)if($0(P))T(P)},u=(D)=>{for(let P of D.getAttributeNames()){let l=D.getAttribute(P);if(!l)continue;let c=l,i=!1;if(/\d\.$/.test(c)||/\d\.(?=[,\s;)])/.test(c))c=c.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),i=!0;if(c=c.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),c=c.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),c!==l)i=!0;if(/\.\.+/.test(c))c=c.replace(/\.\.+/g,"."),i=!0;if(i)D.setAttribute(P,c),z.push({type:"number_format_fixed",element:D.tagName.toLowerCase(),attr:P,oldValue:l,newValue:c,reason:"SVG 1.1: Fixed invalid number format"})}for(let P of D.children)if($0(P))u(P)},S=340000000000000000000000000000000000000,A=-340000000000000000000000000000000000000,y=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,p=(D)=>{for(let P of D.getAttributeNames()){let l=D.getAttribute(P);if(!l)continue;if(P==="id"||P==="class"||P.startsWith("xmlns")||P==="href"||P==="xlink:href"||P==="style")continue;let c=l.match(y);if(!c)continue;for(let i of c){let G0=parseFloat(i);if(!isFinite(G0))z.push({type:"invalid_number_detected",element:D.tagName.toLowerCase(),attr:P,value:i,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(G0>S||G0<A)z.push({type:"out_of_range_detected",element:D.tagName.toLowerCase(),attr:P,value:i,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let P of D.children)if($0(P))p(P)},m=(D)=>{let P=D.tagName,l=P.toLowerCase();if(P.includes(":")||Y6.has(P)||M8.has(l));else{let c=S6(P,Y6);if(c)z.push({type:"mistyped_element_detected",element:P,suggestion:c,reason:`Unknown element <${P}> - did you mean <${c}>?`});else z.push({type:"unknown_element_detected",element:P,reason:`Unknown element <${P}> - not in SVG 1.1 spec`})}for(let c of D.children)if($0(c))m(c)},B=(D)=>{for(let P of D.getAttributeNames()){if(P.startsWith("xmlns")||P.startsWith("data-"))continue;let l=P.toLowerCase();if(X6.has(P)||O8.has(l))continue;if(P.startsWith("-webkit-")||P.startsWith("-moz-")||P.startsWith("-ms-")||P.startsWith("-o-"))continue;if(P.includes(":")&&!P.startsWith("xlink:")&&!P.startsWith("xml:"))continue;let c=S6(P,X6);if(c)z.push({type:"mistyped_attribute_detected",element:D.tagName.toLowerCase(),attr:P,suggestion:c,reason:`Unknown attribute '${P}' on <${D.tagName.toLowerCase()}> - did you mean '${c}'?`})}for(let P of D.children)if($0(P))B(P)},h={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"]},N=["href","xlink:href"],n=(D)=>{let P=D.tagName.toLowerCase(),l=h[P];if(l){for(let c of l)if(c==="href"){if(!N.some((G0)=>D.hasAttribute(G0)))z.push({type:"missing_required_attribute",element:P,attr:c,reason:`Element <${P}> is missing required attribute '${c}' (or 'xlink:href')`})}else if(!D.hasAttribute(c))z.push({type:"missing_required_attribute",element:P,attr:c,reason:`Element <${P}> is missing required attribute '${c}'`})}for(let c of D.children)if($0(c))n(c)},o={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"])},s=(D)=>{let P=D.tagName.toLowerCase(),l=o[P];if(l){for(let c of D.children)if($0(c)){let i=c.tagName.toLowerCase();if(!i.includes(":")&&!l.has(i))z.push({type:"invalid_child_element",parent:P,child:i,reason:`Element <${i}> is not a valid child of <${P}> per SVG 1.1 DTD`})}}for(let c of D.children)if($0(c))s(c)},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"]),E=(D)=>{let P=D.tagName.toLowerCase();for(let l of D.getAttributeNames()){let c=q0[l];if(c){let i=D.getAttribute(l);if(f.has(l)&&i)i=i.split(/\s+/)[0];if(l==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(P))continue;if(!c.includes(i)&&i!=="inherit")z.push({type:"invalid_enum_value",element:P,attr:l,value:i,validValues:c.slice(0,5).join(", ")+(c.length>5?"...":""),reason:`Invalid value '${i}' for attribute '${l}' - must be one of: ${c.slice(0,5).join(", ")}${c.length>5?"...":""}`})}}for(let l of D.children)if($0(l))E(l)},t={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"}},e=(D)=>{let P=D.tagName.toLowerCase();for(let l of D.getAttributeNames()){let c=t[l];if(c){let i=D.getAttribute(l);if(i==="inherit"||i==="none"||i==="indefinite"||i==="auto")continue;let G0=i.match(/^([+-]?\d*\.?\d+)/);if(G0){let L0=parseFloat(G0[1]);if(isNaN(L0))z.push({type:"invalid_numeric_value",element:P,attr:l,value:i,reason:`Invalid numeric value '${i}' for attribute '${l}'`});else{if(c.min!==void 0&&L0<c.min)z.push({type:"numeric_out_of_range",element:P,attr:l,value:i,constraint:`min: ${c.min}`,reason:`Value '${i}' for '${l}' is below minimum (${c.min})`});if(c.max!==void 0&&L0>c.max)z.push({type:"numeric_out_of_range",element:P,attr:l,value:i,constraint:`max: ${c.max}`,reason:`Value '${i}' for '${l}' exceeds maximum (${c.max})`});if(c.type==="integer"&&!Number.isInteger(L0))z.push({type:"invalid_numeric_value",element:P,attr:l,value:i,reason:`Attribute '${l}' requires an integer value, got '${i}'`})}}}}for(let l of D.children)if($0(l))e(l)},Q0=(D)=>{let P=new Map,l=(c)=>{let i=c.getAttribute("id");if(i){if(!P.has(i))P.set(i,[]);P.get(i).push(c.tagName.toLowerCase())}for(let G0 of c.children)if($0(G0))l(G0)};l(D);for(let[c,i]of P)if(i.length>1)z.push({type:"duplicate_id",id:c,count:i.length,elements:i.join(", "),reason:`Duplicate ID '${c}' found on ${i.length} elements: ${i.join(", ")}`})},V0=(D)=>{let P=new Set,l=(L0)=>{let C0=L0.getAttribute("id");if(C0)P.add(C0);for(let E0 of L0.children)if($0(E0))l(E0)};l(D);let c=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,i=/^#(.+)$/,G0=(L0)=>{let C0=L0.tagName.toLowerCase();for(let E0 of L0.getAttributeNames()){let X7=L0.getAttribute(E0),h6;c.lastIndex=0;while((h6=c.exec(X7))!==null){let g7=h6[1];if(!P.has(g7))z.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=X7.match(i);if(g7){let w6=g7[1];if(!P.has(w6))z.push({type:"broken_reference",element:C0,attr:E0,refId:w6,reason:`Broken reference: ${E0}="#${w6}" points to non-existent ID`})}}}for(let E0 of L0.children)if($0(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"]),r=(D)=>{let P=D.toLowerCase().trim();if(P==="none"||P==="inherit"||P==="currentcolor")return!0;if(N0.has(P))return!0;if(P.startsWith("url("))return!0;if(/^#[0-9a-f]{3}$/.test(P)||/^#[0-9a-f]{6}$/.test(P))return!0;if(/^rgb\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)$/.test(P))return!0;if(/^rgba\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*[\d.]+%?\s*\)$/.test(P))return!0;return!1},J0=(D)=>{let P=D.tagName.toLowerCase();for(let l of D.getAttributeNames())if(h0.has(l)){let c=D.getAttribute(l);if(!r(c))z.push({type:"invalid_color",element:P,attr:l,value:c,reason:`Invalid color value '${c}' for attribute '${l}'`})}for(let l of D.children)if($0(l))J0(l)},_0=(D)=>{let P=D.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(P)){let i=D.getAttribute("viewBox");if(i){let G0=i.trim().split(/[\s,]+/);if(G0.length!==4)z.push({type:"malformed_viewbox",element:P,value:i,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])){z.push({type:"malformed_viewbox",element:P,value:i,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)z.push({type:"invalid_viewbox_dimensions",element:P,value:i,reason:`viewBox width and height must be valid non-negative numbers, got ${L0}x${C0}`})}}}let l=D.getAttribute("preserveAspectRatio");if(l){if(!/^(none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax)(\s+(meet|slice))?$/.test(l.trim()))z.push({type:"malformed_preserveaspectratio",element:P,value:l,reason:`Invalid preserveAspectRatio format '${l}'`})}if(["polygon","polyline"].includes(P)){let i=D.getAttribute("points");if(i){let G0=i.trim().split(/[\s,]+/);if(G0.length>0&&G0.length%2!==0)z.push({type:"malformed_points",element:P,value:i.slice(0,50)+(i.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${G0.length}`})}}let c=D.getAttribute("transform");if(c){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(c.trim())){if(!/^[\s\w(),.\-+]+$/.test(c))z.push({type:"malformed_transform",element:P,value:c.slice(0,50)+(c.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let i of D.children)if($0(i))_0(i)},O0=(D)=>{let P=D.tagName,l=P.toLowerCase();if(P.includes(":")||Y6.has(P)||M8.has(l)){for(let i of Array.from(D.children))if($0(i))O0(i);return}let c=S6(P,Y6);if(c){let i=D.ownerDocument.createElement(c);for(let G0 of D.getAttributeNames())i.setAttribute(G0,D.getAttribute(G0));while(D.firstChild)i.appendChild(D.firstChild);if(D.parentNode)D.parentNode.replaceChild(i,D);z.push({type:"element_typo_fixed",oldName:P,newName:c,reason:`Fixed element typo: <${P}> -> <${c}>`});for(let G0 of Array.from(i.children))if($0(G0))O0(G0)}else for(let i of Array.from(D.children))if($0(i))O0(i)},B0=(D)=>{for(let P of Array.from(D.getAttributeNames())){if(P.startsWith("xmlns")||P.startsWith("data-"))continue;if(P.startsWith("-webkit-")||P.startsWith("-moz-"))continue;if(P.includes(":")&&!P.startsWith("xlink:")&&!P.startsWith("xml:"))continue;if(X6.has(P)||O8.has(P.toLowerCase()))continue;let l=S6(P,X6);if(l){let c=D.getAttribute(P);D.removeAttribute(P),D.setAttribute(l,c),z.push({type:"attr_typo_fixed",element:D.tagName.toLowerCase(),oldAttr:P,newAttr:l,reason:`Fixed attribute typo: '${P}' -> '${l}'`})}}for(let P of D.children)if($0(P))B0(P)},I0=(D)=>{let P=new Map,l=new Set,c=(L0)=>{let C0=L0.getAttribute("id");if(C0)P.set(C0,(P.get(C0)||0)+1),l.add(C0);for(let E0 of L0.children)if($0(E0))c(E0)};c(D);let i=new Set,G0=(L0)=>{let C0=L0.getAttribute("id");if(C0)if(i.has(C0)){let E0=C0,X7=2;while(l.has(E0)||i.has(E0))E0=`${C0}_${X7++}`;L0.setAttribute("id",E0),l.add(E0),i.add(E0),z.push({type:"duplicate_id_renamed",oldId:C0,newId:E0,element:L0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${C0}' -> '${E0}'`})}else i.add(C0);for(let E0 of L0.children)if($0(E0))G0(E0)};G0(D)};if(_($),U(),V($),O($),w($),C($),T($),u($),O0($),B0($),I0($),p($),n($),s($),E($),e($),V0($),J0($),_0($),$.setAttribute("data-fixes-applied",String(z.length)),H&&z.length>0)$.setAttribute("data-fix-report",JSON.stringify(z));return $}),A0={ERROR:"error",WARNING:"warning"},bz={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},Sz=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"]),vz=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"]),_Z=new Set(["img","graphics-document","graphics-object","graphics-symbol","group","list","listitem","none","presentation","application"]);function Dz($){let J={elements:new Map,lines:[]},Z=0;J.lines.push(0);for(let X=0;X<$.length;X++)if($[X]===`
|
|
431
|
-
`)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,
|
|
432
|
-
`):null,G=Dz(z),F,_=[],U=(d)=>{let b=d.match(/line\s*:?\s*(\d+)/i)||d.match(/:(\d+):/);return b?parseInt(b[1],10):1},Y=(d)=>{let b=d.match(/column\s*:?\s*(\d+)/i)||d.match(/:\d+:(\d+)/);return b?parseInt(b[1],10):1},V=(d)=>{let b=d,a=[],x="_VALID_ENTITY_",Z0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,M0=b.replace(Z0,x+"$1;").replace(/&/g,"&").replace(new RegExp(x,"g"),"&");if(M0!==b)b=M0,a.push("Escaped unencoded ampersands");let T0=b.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(T0!==b)b=T0,a.push("Removed invalid control characters");if(b.charCodeAt(0)===65279)b=b.slice(1),a.push("Removed UTF-8 BOM");let x0=b.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(G7,e0,o0)=>{if(!o0.includes(">"))return`="${e0}<${o0}"`;return G7});if(x0!==b)b=x0,a.push("Escaped < in attribute values");return{fixed:b,appliedFixes:a}};try{F=await H$($,j)}catch(d){let b=d.message||String(d),a=U(b),x=Y(b),{fixed:Z0,appliedFixes:W0}=V(z);if(W0.length>0&&Z0!==z)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: ${W0.join("; ")}`,line:a,column:x}),_.push({type:"original_parse_error",severity:A0.ERROR,reason:`Original parse error: ${b}`,line:a,column:x})}catch(H0){return{issues:[{type:"parse_error",severity:A0.ERROR,reason:`Failed to parse SVG: ${b}`,line:a,column:x},{type:"recovery_failed",severity:A0.WARNING,reason:`Recovery attempted (${W0.join("; ")}) but still failed: ${H0.message}`,line:a,column:x}],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: ${b}`,line:a,column:x}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let O=[];if(_.length>0)O.push(..._);let X=new Map,k=(d)=>{let b=d.toLowerCase(),a=X.get(b)||0;return X.set(b,a+1),a},w=()=>{X.clear()},R=(d,b,a=null,x=null)=>{let Z0;if(a)Z0=G.getAttributePosition(b,a,x||0);else Z0=G.getElementPosition(b,x||0);let W0=bz[d.type]||A0.WARNING,H0={...d,severity:W0,line:Z0.line,column:Z0.column};if(q&&W&&Z0.line>0&&Z0.line<=W.length)H0.sourceLine=W[Z0.line-1];return H0},I=new Set,C=(d)=>{if(!d)return;let b=d.getAttribute("id");if(b)I.add(b);for(let a of d.children)if($0(a))C(a)};C(F);let v=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],g=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);if(b==="g"){for(let x of v)if(d.hasAttribute(x))O.push(R({type:"invalid_attr_on_element",element:b,attr:x,value:d.getAttribute(x),reason:`SVG 1.1: <g> elements do not support '${x}' attribute`},b,x,a))}for(let x of d.children)if($0(x))g(x)},T=()=>{let d=!1,b=null,a=null,x=(Z0)=>{for(let W0 of Z0.getAttributeNames())if(W0.startsWith("xlink:")){d=!0,b=Z0.tagName.toLowerCase(),a=W0;return}for(let W0 of Z0.children){if($0(W0))x(W0);if(d)return}};if(x(F),d&&!F.hasAttribute("xmlns:xlink")){let Z0=G.getAttributePosition(b,a,0);O.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:Z0.line,column:Z0.column})}},u=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of["xlink:href","href"]){let Z0=d.getAttribute(x);if(Z0&&Z0.startsWith("#")){let W0=Z0.slice(1);if(W0&&!I.has(W0))O.push(R({type:"broken_reference",element:b,attr:x,referencedId:W0,reason:`Reference to non-existent ID '${W0}'`},b,x,a))}}for(let x of d.children)if($0(x))u(x)},S=["begin","end","dur","repeatDur","min","max"],A=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),y=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);if(A.has(b))for(let x of S){let Z0=d.getAttribute(x);if(Z0){let W0=Z0.trim();if(W0!==Z0)O.push(R({type:"invalid_timing",element:b,attr:x,value:Z0,reason:"Timing value has leading/trailing whitespace"},b,x,a));if(/[;,]/.test(W0)&&!/^[\d\w\s.;,+-]+$/.test(W0))O.push(R({type:"invalid_timing",element:b,attr:x,value:Z0,reason:"Timing value may contain invalid characters"},b,x,a))}}for(let x of d.children)if($0(x))y(x)},p=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),m=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);if(p.has(b)){for(let x of d.children)if($0(x)){let Z0=x.tagName.toLowerCase();if(A.has(Z0))O.push(R({type:"animation_in_empty_element",element:b,child:Z0,reason:`Animation element <${Z0}> inside <${b}> which has EMPTY content model per SVG 1.1 DTD`},b,null,a))}}for(let x of d.children)if($0(x))m(x)},B=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,h=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],N=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of h){let Z0=d.getAttribute(x);if(Z0){let W0=Z0.match(B);if(W0)for(let H0 of W0){let M0=H0.replace(/[\d.]+/,"");if(M0!==M0.toLowerCase())O.push(R({type:"uppercase_unit",element:b,attr:x,value:Z0,reason:`Unit '${M0}' should be lowercase '${M0.toLowerCase()}'`},b,x,a))}}}for(let x of d.children)if($0(x))N(x)},n=["points","viewBox","d","values","keyTimes","keySplines","rotate"],o=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of n){let Z0=d.getAttribute(x);if(Z0){if(/[\t\n\r]/.test(Z0)||/ +/.test(Z0))O.push(R({type:"invalid_whitespace",element:b,attr:x,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},b,x,a))}}for(let x of d.children)if($0(x))o(x)},s=["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=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of s){let Z0=d.getAttribute(x);if(Z0){let W0=Z0.trim();if(/^0\d/.test(W0.replace(/[a-z%]+$/i,"")))O.push(R({type:"invalid_number",element:b,attr:x,value:Z0,reason:"Number has unnecessary leading zeros"},b,x,a));if(/\.$/.test(W0.replace(/[a-z%]+$/i,"")))O.push(R({type:"invalid_number",element:b,attr:x,value:Z0,reason:"Number has trailing decimal point"},b,x,a))}}for(let x of d.children)if($0(x))q0(x)},f=(d,b=!1)=>{let a=d.tagName,x=a.toLowerCase(),Z0=k(x),W0=a.includes(":"),H0=b||qZ.has(x)||W0;if(!H0){if(!Y6.has(a)&&!M8.has(x)){if(!Fz(x)){let M0=S6(a,Y6);if(M0)O.push(R({type:"mistyped_element_detected",element:a,suggestion:M0,reason:`Unknown element <${a}> - did you mean <${M0}>?`},x,null,Z0));else O.push(R({type:"unknown_element_detected",element:a,reason:`Unknown element <${a}> - not in SVG 1.1 spec`},x,null,Z0))}}}for(let M0 of d.children)if($0(M0))f(M0,H0)},E=(d,b=!1)=>{let a=d.tagName.toLowerCase(),x=k(a),Z0=d.tagName.includes(":"),W0=b||qZ.has(a)||Z0;if(!W0)for(let H0 of d.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(_z(H0))continue;if(!X6.has(H0)&&!O8.has(H0.toLowerCase())){let M0=S6(H0,X6);if(M0)O.push(R({type:"mistyped_attribute_detected",element:a,attr:H0,suggestion:M0,reason:`Unknown attribute '${H0}' - did you mean '${M0}'?`},a,H0,x));else O.push(R({type:"unknown_attribute_detected",element:a,attr:H0,reason:`Unknown attribute '${H0}' on <${a}> - not in SVG 1.1 spec`},a,H0,x))}}for(let H0 of d.children)if($0(H0))E(H0,W0)},t={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"]},e=(d)=>{let b=d.tagName.toLowerCase(),a=k(b),x=t[b];if(x&&x.length>0){if(x.includes("xlink:href")&&x.includes("href")){if(!d.hasAttribute("xlink:href")&&!d.hasAttribute("href"))O.push(R({type:"missing_required_attribute",element:b,attrs:["href","xlink:href"],reason:`<${b}> requires 'href' or 'xlink:href' attribute`},b,null,a))}else for(let Z0 of x)if(!d.hasAttribute(Z0))O.push(R({type:"missing_required_attribute",element:b,attr:Z0,reason:`<${b}> requires '${Z0}' attribute per SVG 1.1 DTD`},b,Z0,a))}for(let Z0 of d.children)if($0(Z0))e(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=(d)=>{let b=d.tagName.toLowerCase(),a=k(b),x=Q0[b];if(x){for(let Z0 of d.children)if($0(Z0)){let W0=Z0.tagName.toLowerCase();if(!W0.includes(":")&&!x.has(W0))O.push(R({type:"invalid_child_element",element:b,child:W0,reason:`<${W0}> is not a valid child of <${b}> per SVG 1.1 DTD`},b,null,a))}}for(let Z0 of d.children)if($0(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=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let[x,Z0]of Object.entries(N0)){let W0=d.getAttribute(x);if(W0&&!Z0.has(W0))O.push(R({type:"invalid_enum_value",element:b,attr:x,value:W0,validValues:[...Z0],reason:`Invalid value '${W0}' for '${x}'. Valid values: ${[...Z0].join(", ")}`},b,x,a))}for(let x of d.children)if($0(x))h0(x)},r={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=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let[x,Z0]of Object.entries(r)){let W0=d.getAttribute(x);if(W0){let H0=parseFloat(W0);if(!isNaN(H0)){if(Z0.min!==void 0&&H0<Z0.min)O.push(R({type:"invalid_numeric_constraint",element:b,attr:x,value:W0,reason:`Value ${H0} is below minimum ${Z0.min}`},b,x,a));if(Z0.max!==void 0&&H0>Z0.max)O.push(R({type:"invalid_numeric_constraint",element:b,attr:x,value:W0,reason:`Value ${H0} is above maximum ${Z0.max}`},b,x,a))}}}for(let x of d.children)if($0(x))J0(x)},_0=(d)=>{let b=new Map,a=new Map,x=(Z0)=>{let W0=Z0.tagName.toLowerCase(),H0=k(W0),M0=Z0.getAttribute("id");if(M0){if(!b.has(M0))b.set(M0,[]),a.set(M0,{tagName:W0,occIdx:H0});b.get(M0).push(W0)}for(let T0 of Z0.children)if($0(T0))x(T0)};x(d);for(let[Z0,W0]of b)if(W0.length>1){let H0=a.get(Z0);O.push(R({type:"duplicate_id",id:Z0,elements:W0,count:W0.length,reason:`ID '${Z0}' is used ${W0.length} times (on ${W0.join(", ")})`},H0.tagName,"id",H0.occIdx))}},O0=/url\(#([^)]+)\)/g,B0=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],I0=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of B0){let Z0=d.getAttribute(x);if(Z0){let W0;O0.lastIndex=0;while((W0=O0.exec(Z0))!==null){let H0=W0[1];if(!I.has(H0))O.push(R({type:"broken_url_reference",element:b,attr:x,referencedId:H0,reason:`url(#${H0}) references non-existent ID`},b,x,a))}}}for(let x of d.children)if($0(x))I0(x)},D=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"]),P=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],l=(d)=>{let b=d.toLowerCase().trim();if(D.has(b))return!0;if(/^#[0-9a-f]{3}$/i.test(b))return!0;if(/^#[0-9a-f]{4}$/i.test(b))return!0;if(/^#[0-9a-f]{6}$/i.test(b))return!0;if(/^#[0-9a-f]{8}$/i.test(b))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(b))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(b))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(b))return!0;if(/^url\(#[^)]+\)$/i.test(b))return!0;return!1},c=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of P){let Z0=d.getAttribute(x);if(Z0&&!l(Z0))O.push(R({type:"invalid_color",element:b,attr:x,value:Z0,reason:`Invalid color value '${Z0}'`},b,x,a))}for(let x of d.children)if($0(x))c(x)},i=(d)=>{let b=d.tagName.toLowerCase(),a=k(b),x=d.getAttribute("viewBox");if(x){let H0=x.trim().split(/[\s,]+/);if(H0.length!==4||!H0.every((M0)=>!isNaN(parseFloat(M0))))O.push(R({type:"malformed_viewbox",element:b,value:x,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},b,"viewBox",a))}let Z0=d.getAttribute("points");if(Z0){let H0=Z0.trim().split(/[\s,]+/).filter((M0)=>M0);if(H0.length%2!==0||!H0.every((M0)=>!isNaN(parseFloat(M0))))O.push(R({type:"malformed_points",element:b,value:Z0.length>50?Z0.substring(0,50)+"...":Z0,reason:"points must be pairs of numbers"},b,"points",a))}let W0=d.getAttribute("transform");if(W0){let H0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,M0=W0.trim();while(M0.length>0){let T0=M0.match(H0);if(T0&&T0[0].length>0)M0=M0.substring(T0[0].length);else if(!T0){O.push(R({type:"malformed_transform",element:b,value:W0.length>50?W0.substring(0,50)+"...":W0,reason:`Invalid transform syntax near '${M0.substring(0,20)}'`},b,"transform",a));break}else M0=M0.substring(1)}}if(b==="path"){let H0=d.getAttribute("d");if(H0){let M0=H0.trim();if(M0.length>0){if(!/^[Mm]/.test(M0))O.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",a));let T0=M0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(T0.length>0)O.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",a))}}}for(let H0 of d.children)if($0(H0))i(H0)},G0=()=>{let d=new Map,b=(H0)=>{let M0=H0.getAttribute("id");if(M0)d.set(M0,H0);for(let T0 of H0.children)if($0(T0))b(T0)};b(F);let a=["href","xlink:href","mask","clip-path","filter","fill","stroke"],x=(H0)=>{if(!H0)return null;let M0=H0.match(/url\(#([^)]+)\)/);if(M0)return M0[1];let T0=H0.match(/^#(.+)$/);if(T0)return T0[1];return null},Z0=(H0,M0=new Set)=>{if(M0.has(H0))return!0;let T0=d.get(H0);if(!T0)return!1;M0.add(H0);let x0=(e0)=>{for(let o0 of a){let n8=x(e0.getAttribute(o0));if(n8&&Z0(n8,M0))return!0}for(let o0 of e0.children)if($0(o0)&&x0(o0))return!0;return!1},G7=x0(T0);return M0.delete(H0),G7},W0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[H0,M0]of d){let T0=M0.tagName.toLowerCase();if(W0.includes(T0)){if(Z0(H0)){w();let x0=k(T0);O.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=(d,b=0)=>{if(b>L0){let a=d.tagName.toLowerCase(),x=k(a);O.push(R({type:"deep_nesting",element:a,value:String(b),reason:`Element nesting depth (${b}) exceeds ${L0} levels`},a,null,x));return}for(let a of d.children)if($0(a))C0(a,b+1)},E0=(d)=>{let b=d.tagName.toLowerCase();if(b==="defs"){let a=!1;for(let x of d.childNodes)if($0(x)){a=!0;break}if(!a){let x=k(b);O.push(R({type:"empty_defs",element:b,reason:"Empty <defs> element (can be removed)"},b,null,x))}}for(let a of d.children)if($0(a))E0(a)},X7=(d)=>{let b=d.tagName.toLowerCase();if(b==="lineargradient"||b==="radialgradient"){let a=Array.from(d.children).filter((x)=>$0(x)&&x.tagName.toLowerCase()==="stop");if(a.length>=2){let x=-1;for(let Z0 of a){let W0=Z0.getAttribute("offset")||"0",H0=parseFloat(W0);if(W0.includes("%"))H0=H0/100;if(!isNaN(H0)&&H0<x){let M0=k(b);O.push(R({type:"gradient_stop_order",element:b,reason:`Gradient stops not in ascending offset order (${x} followed by ${H0})`},b,null,M0));break}if(!isNaN(H0))x=H0}}}for(let a of d.children)if($0(a))X7(a)},h6=1e4,g7=(d)=>{let b=d.tagName.toLowerCase();if(b==="path"){let a=d.getAttribute("d");if(a){let x=a.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(x&&x.length>h6){let Z0=k(b);O.push(R({type:"path_complexity",element:b,attr:"d",value:`${x.length} coordinates`,reason:`Path has ${x.length} coordinates (>${h6}), may cause slow rendering`},b,"d",Z0))}}}for(let a of d.children)if($0(a))g7(a)},w6=(d)=>{let b=d.tagName.toLowerCase(),a=k(b),x=["href","xlink:href"];for(let Z0 of x){let W0=d.getAttribute(Z0);if(W0&&(W0.startsWith("http://")||W0.startsWith("https://")||W0.startsWith("//")))O.push(R({type:"external_resource",element:b,attr:Z0,value:W0.length>60?W0.substring(0,60)+"...":W0,reason:"External resource reference detected (potential security/CORS issue)"},b,Z0,a))}if(b==="style"&&d.textContent){let Z0=d.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(Z0)O.push(R({type:"external_resource",element:b,value:Z0[1],reason:"External CSS import detected in style element"},b,null,a))}for(let Z0 of d.children)if($0(Z0))w6(Z0)},d8=(d)=>{let b=d.tagName.toLowerCase();if(b==="script"){let a=k(b);O.push(R({type:"script_content",element:b,reason:"Script element detected (potential security issue in untrusted SVGs)"},b,null,a))}for(let a of d.children)if($0(a))d8(a)},p8=(d)=>{let b=d.tagName.toLowerCase(),a=k(b);for(let x of d.getAttributeNames())if(Sz.has(x.toLowerCase()))O.push(R({type:"event_handler",element:b,attr:x,reason:`Event handler attribute '${x}' detected (potential XSS vector)`},b,x,a));for(let x of d.children)if($0(x))p8(x)},gK=()=>{let d=!1,b=!1,a=!1,x=F.hasAttribute("lang")||F.hasAttribute("xml:lang"),Z0=(T0)=>{for(let x0 of T0.children){if(!$0(x0))continue;let G7=x0.tagName.toLowerCase();if(G7==="title")d=!0;if(G7==="desc")b=!0;if(G7==="text"||G7==="tspan"||G7==="textpath")a=!0;Z0(x0)}};if(Z0(F),!d)O.push(R({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let W0=0,H0=(T0)=>{W0++;for(let x0 of T0.children)if($0(x0))H0(x0)};if(H0(F),!b&&W0>10)O.push(R({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${W0} elements)`},"svg",null,0));if(a&&!x)O.push(R({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let M0=(T0)=>{let x0=T0.tagName.toLowerCase(),G7=k(x0);for(let e0 of T0.getAttributeNames()){if(e0.startsWith("aria-")&&!vz.has(e0.toLowerCase()))O.push(R({type:"invalid_aria",element:x0,attr:e0,reason:`Unknown ARIA attribute '${e0}'`},x0,e0,G7));if(e0==="role"){let o0=T0.getAttribute("role");if(o0&&!_Z.has(o0.toLowerCase()))O.push(R({type:"invalid_aria",element:x0,attr:"role",value:o0,reason:`Invalid role value '${o0}' (valid: ${Array.from(_Z).slice(0,5).join(", ")}...)`},x0,"role",G7))}if(e0==="aria-hidden"){let o0=T0.getAttribute("aria-hidden");if(o0&&o0!=="true"&&o0!=="false")O.push(R({type:"invalid_aria",element:x0,attr:"aria-hidden",value:o0,reason:`aria-hidden must be 'true' or 'false', got '${o0}'`},x0,"aria-hidden",G7))}}for(let e0 of T0.children)if($0(e0))M0(e0)};w(),M0(F)};w(),g(F),T(),w(),u(F),w(),y(F),w(),m(F),w(),N(F),w(),o(F),w(),q0(F),w(),f(F),w(),E(F),w(),e(F),w(),V0(F),w(),h0(F),w(),J0(F),w(),_0(F),w(),I0(F),w(),c(F),w(),i(F),w(),G0(),w(),C0(F),w(),E0(F),w(),X7(F),w(),g7(F),w(),w6(F),w(),d8(F),w(),p8(F),gK(),O.sort((d,b)=>{if(d.line!==b.line)return d.line-b.line;return d.column-b.column});let j$=O;if(Z)j$=O.filter((d)=>d.severity===A0.ERROR);let q9=O.filter((d)=>d.severity===A0.ERROR).length,c8=O.filter((d)=>d.severity===A0.WARNING).length,H9={};for(let d of j$)H9[d.type]=(H9[d.type]||0)+1;let z6={issues:j$,isValid:q9===0,hasErrors:q9>0,hasWarnings:c8>0,errorCount:q9,warningCount:c8,issueCount:j$.length,summary:H9};if(K)try{let d=await import("node:fs/promises"),b=await Promise.resolve().then(() => (V6(),U6)),a;switch(Q){case"json":a=JSON.stringify(z6,null,2);break;case"yaml":a=uz(z6);break;case"xml":a=gz(z6);break;case"text":default:a=yz(z6);break}let x=b.normalize(K);await d.writeFile(x,a,"utf8"),z6.outputFile=x}catch(d){z6.exportError=`Failed to write report to '${K}': ${d.message}`}return z6}function yz($){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(`
|
|
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
358
|
var __EMBEDDED_RESOURCES__ = ${JSON.stringify(J,null,0)};
|
|
@@ -569,10 +489,10 @@ ${H}
|
|
|
569
489
|
})();
|
|
570
490
|
// ===== END EMBEDDED RESOURCES INTERCEPTOR =====
|
|
571
491
|
|
|
572
|
-
`}function lz($){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 z=J.get(H);for(let j of q)z.add(j)},K=(Q)=>{if(!Q)return;let H=(Q.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),z=H?H[1]:null,j=Q.getAttribute?.("font-family"),W=Q.getAttribute?.("face"),G=z||j||W,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 Y=(Q.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);_=Y?Y[1]:Q.parentNode.getAttribute?.("font-family")}if(_&&F.trim())Z(_,F)}if(Q.children)for(let _ of Q.children)K(_)};return K($),J}function sz($){let J=[...$].sort().join("");return encodeURIComponent(J)}function oz($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function iz($){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 rz($,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 P8=F0(async($,J={})=>{let{basePath:Z="",embedImages:K=!0,embedExternalSVGs:Q=!0,externalSVGMode:q="extract",embedCSS:H=!0,embedFonts:z=!0,embedScripts:j=!0,embedAudio:W=!1,subsetFonts:G=!0,verbose:F=!1,recursive:_=!0,maxRecursionDepth:U=10,timeout:Y=30000,onMissingResource:V="warn",onProgress:O=null,idPrefix:X="ext_",_visitedURLs:k=null}=J,w=k||new Set,R=[],I=new Map,C=0,v=(S)=>{if(!S||!S.attributes)return;let A=["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/"],p=S.attributes;for(let m=0;m<p.length;m++){let B=p[m];if(B.name.startsWith("xmlns:")){let h=B.name.substring(6),N=B.value;if(A.some((n)=>N.startsWith(n))||!y.includes(N))I.set(h,N)}}},g=(S,A)=>{let y=`Failed to fetch resource: ${S} - ${A.message}`;if(V==="fail")throw Error(y);else if(V==="warn")R.push(y),console.warn("embedExternalDependencies:",y);return null};if(K){let A=[...$.getElementsByTagName("image")];if(O)O("images",0,A.length);for(let y=0;y<A.length;y++){let p=A[y],m=p.getAttribute("href")||p.getAttribute("xlink:href");if(!m||!UZ(m))continue;try{let B=l7(m,Z),{content:h,contentType:N}=await s7(B,"binary",Y),n=Q$(h,N.split(";")[0]);if(p.getAttribute("href"))p.setAttribute("href",n);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href",n)}catch(B){g(m,B)}if(O)O("images",y+1,A.length)}}if(Q){let A=[...$.getElementsByTagName("use")];if(O)O("externalSVGs",0,A.length);let y=$.querySelector("defs");if(!y){let p=$.documentElement||$;if(!p){if(R.push("Cannot add defs: document has no root SVG element"),O)O("externalSVGs",A.length,A.length)}else if(y=new w0("defs",{},[]),typeof p.insertBefore==="function"&&p.firstChild)p.insertBefore(y,p.firstChild);else if(typeof p.appendChild==="function")p.appendChild(y);else if(p.children&&Array.isArray(p.children))p.children.unshift(y),y.parentNode=p}if(y)for(let p=0;p<A.length;p++){let m=A[p],B=m.getAttribute("href")||m.getAttribute("xlink:href");if(!B||!UZ(B))continue;let{path:h,fragment:N}=mz(B);if(!h)continue;let n=l7(h,Z);if(w.has(n)){R.push(`Circular reference detected: ${n}`);continue}w.add(n);try{let{content:o}=await s7(n,"text",Y),s=u0(o);if(!s){g(h,Error("Failed to parse SVG"));continue}let q0=s.documentElement||s;if(v(q0),_&&U>0)await P8(s,{...J,basePath:n,maxRecursionDepth:U-1,_visitedURLs:w});C++;let f=`${X}${C}_`;if(q==="extract"&&N){let E=s.getElementById(N);if(E){let t=E.clone?E.clone():JSON.parse(JSON.stringify(E));Y8(t,f),y.children.push(t);let e=f+N;if(m.getAttribute("href"))m.setAttribute("href","#"+e);if(m.getAttribute("xlink:href"))m.setAttribute("xlink:href","#"+e)}else g(B,Error(`Fragment #${N} not found in ${h}`))}else{let E=s.documentElement||s;Y8(E,f);let t=f+"svg";E.setAttribute("id",t),y.children.push(E);let e=N?"#"+f+N:"#"+t;if(m.getAttribute("href"))m.setAttribute("href",e);if(m.getAttribute("xlink:href"))m.setAttribute("xlink:href",e)}}catch(o){g(h,o)}if(O)O("externalSVGs",p+1,A.length)}}if(H||z){let A=[...$.getElementsByTagName("style")];if(O)O("stylesheets",0,A.length);let y=G?lz($):null;for(let p=0;p<A.length;p++){let m=A[p],B=m.textContent||"";if(H){let{imports:h}=V8(B);for(let N of h.reverse())try{let n=N.url;if(y&&oz(n)){let E=iz(n);if(E&&y.has(E)){let t=sz(y.get(E));if(n=rz(n,t),F)console.log(`Font subsetting: ${E} -> ${y.get(E).size} chars`)}}let o=l7(n,Z),{content:s}=await s7(o,"text",Y),q0=s,f=V8(s).imports;if(f.length>0)for(let E of f.reverse())try{let t=l7(E.url,o),e=await s7(t,"text",Y);q0=q0.substring(0,E.index)+e.content+q0.substring(E.index+E.fullMatch.length)}catch(t){g(E.url,t)}B=B.substring(0,N.index)+q0+B.substring(N.index+N.fullMatch.length)}catch(n){g(N.url,n)}}if(H||z){let{urls:h}=V8(B);for(let N of h.reverse()){let n=r$(N.url),o=n.startsWith("font/")||n.includes("fontobject");if(o&&!z)continue;if(!o&&!H)continue;try{let s=l7(N.url,Z),{content:q0,contentType:f}=await s7(s,"binary",Y),t=`url("${Q$(q0,f.split(";")[0])}")`;B=B.substring(0,N.index)+t+B.substring(N.index+N.fullMatch.length)}catch(s){g(N.url,s)}}}if(m.textContent=B,O)O("stylesheets",p+1,A.length)}}if(j){let A=[...$.getElementsByTagName("script")];if(O)O("scripts",0,A.length);for(let y=0;y<A.length;y++){let p=A[y],m=p.getAttribute("src")||p.getAttribute("href")||p.getAttribute("xlink:href");if(!m)continue;if(m.startsWith("data:"))continue;try{let B=l7(m,Z),{content:h}=await s7(B,"text",Y);p.removeAttribute("src"),p.removeAttribute("href"),p.removeAttribute("xlink:href"),IK(p,h,$)}catch(B){g(m,B)}if(O)O("scripts",y+1,A.length)}}if(W){let A=[...$.getElementsByTagName("audio")];if(O)O("audio",0,A.length);for(let y=0;y<A.length;y++){let p=A[y],m=p.getAttribute("src");if(m&&!m.startsWith("data:"))try{let h=l7(m,Z),{content:N,contentType:n}=await s7(h,"binary",Y),o=n.split(";")[0]||"audio/mpeg",s=Q$(N,o);p.setAttribute("src",s)}catch(h){g(m,h)}let B=p.getElementsByTagName("source");for(let h of B){let N=h.getAttribute("src");if(N&&!N.startsWith("data:"))try{let n=l7(N,Z),{content:o,contentType:s}=await s7(n,"binary",Y),q0=s.split(";")[0]||h.getAttribute("type")||"audio/mpeg",f=Q$(o,q0);h.setAttribute("src",f)}catch(n){g(N,n)}}if(O)O("audio",y+1,A.length)}}if(j){let S=[],A=$.getElementsByTagName("script");for(let B of A)if(B.textContent)S.push(B.textContent);let y=$.getElementsByTagName("style");for(let B of y)if(B.textContent)S.push(B.textContent);let p=$.getElementsByTagName("foreignObject");for(let B of p){let h=B.textContent||"";if(h)S.push(h)}let m=new Set;for(let B of S){let h=cz(B);for(let N of h)m.add(N)}if(m.size>0){let B=new Map;if(O)O("resources",0,m.size);let h=0;for(let N of m){try{let n=l7(N,Z),{content:o,contentType:s}=await s7(n,"binary",Y),q0=s.split(";")[0]||r$(N),f=Q$(o,q0);if(B.set(N,f),F){let E=(o.length/1024).toFixed(1);console.log(`Embedded resource: ${N} (${E} KB)`)}}catch(n){g(N,n)}if(h++,O)O("resources",h,m.size)}if(B.size>0){let N=nz(B),n=A[0];if(n){let o=n.textContent||"";if(N.includes("<")||N.includes("&")||o.includes("<")||o.includes("&"))n.setAttribute("data-cdata-pending","true");n.textContent=N+o}else{let o=$.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("data-cdata-pending","true"),o.textContent=N;let s=$.documentElement||$;if(s.firstChild)s.insertBefore(o,s.firstChild);else s.appendChild(o)}if(F)console.log(`Injected resource interceptor for ${B.size} embedded resources`)}}}let T=$.documentElement||$;if(!T.getAttribute("xmlns"))T.setAttribute("xmlns","http://www.w3.org/2000/svg");if(Z7($).includes("xlink:")&&!T.getAttribute("xmlns:xlink"))T.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[S,A]of I){let y=`xmlns:${S}`;if(!T.getAttribute(y))T.setAttribute(y,A)}if(R.length>0)$._embedWarnings=R;return $}),az={"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 M6($){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 O6($){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 H6($,J,Z,K=null){let Q=az[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 CK($,J={}){let Z=k6($),K=await H$($,Z),Q=J.outputFormat||(Z===D0.DOM_ELEMENT?O7.DOM_ELEMENT:O7.SVG_STRING),{outputDir:q=null,filenamePrefix:H="resource",extractImages:z=!0,extractFonts:j=!0,extractScripts:W=!0,extractStyles:G=!0,extractAudio:F=!0,extractVideo:_=!0,elementIds:U=null,restoreGoogleFonts:Y=!0,dryRun:V=!1,extractOnly:O=!1,onProgress:X=null}=J,k=[],w=[],R=0,I=U?new Set(Array.isArray(U)?U:[U]):null,C=(T)=>{if(!I)return!0;let u=T;while(u&&u.getAttribute){let S=u.getAttribute("id");if(S&&I.has(S))return!0;u=u.parentNode}return!1},v=async(T,u,S)=>{let A=0;if(typeof Buffer<"u"&&Buffer.isBuffer(u))A=u.length;else if(typeof Buffer<"u")A=Buffer.byteLength(u,"utf8");else if(typeof Blob<"u")A=new Blob([u]).size;else A=u.length||0;let y={filename:T,path:q?`${q}/${T}`:T,mimeType:S,size:A};if(!V&&q)try{let p=await import("node:fs/promises"),m=await Promise.resolve().then(() => (V6(),U6));await p.mkdir(q,{recursive:!0});let B=m.join(q,T);if(typeof Buffer<"u"&&Buffer.isBuffer(u))await p.writeFile(B,u);else await p.writeFile(B,u,"utf8");y.path=B,k.push(y)}catch(p){w.push(`Failed to save ${T}: ${p.message}`),y.error=p.message}else k.push(y);return y};if(z){let u=[...K.getElementsByTagName("image")];if(X)X("images",0,u.length);for(let S=0;S<u.length;S++){let A=u[S];if(!C(A))continue;let y=A.getAttribute("href")||A.getAttribute("xlink:href");if(!y||!y.startsWith("data:"))continue;let p=M6(y);if(!p)continue;if(!p.mimeType.startsWith("image/"))continue;R++;let m=H6(H,p.mimeType,R),B=O6(p),h=await v(m,B,p.mimeType);if(h.type="image",h.elementId=A.getAttribute("id"),!O){let N=`./${m}`;if(A.getAttribute("href"))A.setAttribute("href",N);if(A.getAttribute("xlink:href"))A.setAttribute("xlink:href",N)}if(X)X("images",S+1,u.length)}}if(F){let u=[...K.getElementsByTagName("audio")];if(X)X("audio",0,u.length);for(let S=0;S<u.length;S++){let A=u[S];if(!C(A))continue;let y=A.getAttribute("src");if(y&&y.startsWith("data:")){let m=M6(y);if(m&&m.mimeType.startsWith("audio/")){R++;let B=H6(H,m.mimeType,R),h=O6(m),N=await v(B,h,m.mimeType);if(N.type="audio",N.elementId=A.getAttribute("id"),!O)A.setAttribute("src",`./${B}`)}}let p=A.getElementsByTagName("source");for(let m of p){let B=m.getAttribute("src");if(B&&B.startsWith("data:")){let h=M6(B);if(h&&h.mimeType.startsWith("audio/")){R++;let N=H6(H,h.mimeType,R),n=O6(h),o=await v(N,n,h.mimeType);if(o.type="audio",!O)m.setAttribute("src",`./${N}`)}}}if(X)X("audio",S+1,u.length)}}if(_){let u=[...K.getElementsByTagName("video")];if(X)X("video",0,u.length);for(let S=0;S<u.length;S++){let A=u[S];if(!C(A))continue;let y=A.getAttribute("src");if(y&&y.startsWith("data:")){let m=M6(y);if(m&&m.mimeType.startsWith("video/")){R++;let B=H6(H,m.mimeType,R),h=O6(m),N=await v(B,h,m.mimeType);if(N.type="video",N.elementId=A.getAttribute("id"),!O)A.setAttribute("src",`./${B}`)}}let p=A.getElementsByTagName("source");for(let m of p){let B=m.getAttribute("src");if(B&&B.startsWith("data:")){let h=M6(B);if(h&&h.mimeType.startsWith("video/")){R++;let N=H6(H,h.mimeType,R),n=O6(h),o=await v(N,n,h.mimeType);if(o.type="video",!O)m.setAttribute("src",`./${N}`)}}}if(X)X("video",S+1,u.length)}}if(W){let u=[...K.getElementsByTagName("script")];if(X)X("scripts",0,u.length);for(let S=0;S<u.length;S++){let A=u[S];if(!C(A))continue;let y=A.getAttribute("href")||A.getAttribute("xlink:href");if(y&&!y.startsWith("data:"))continue;let p="";if(y&&y.startsWith("data:")){let h=M6(y);if(h){let N=O6(h);p=typeof N==="string"?N:N.toString("utf8")}}else if(p=A.textContent||"",A.firstChild&&A.firstChild.nodeType===4)p=A.firstChild.nodeValue||"";if(!p.trim())continue;R++;let m=H6(H,"application/javascript",R),B=await v(m,p,"application/javascript");if(B.type="script",B.elementId=A.getAttribute("id"),!O){let h=0;while(A.firstChild&&h++<1e4){let N=A.firstChild;if(A.removeChild(N),A.firstChild===N)break}if(h>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");A.setAttribute("href",`./${m}`)}if(X)X("scripts",S+1,u.length)}}if(G||j){let u=[...K.getElementsByTagName("style")];if(X)X("styles",0,u.length);for(let S=0;S<u.length;S++){let A=u[S];if(!C(A))continue;let y=A.textContent||"";if(A.firstChild&&A.firstChild.nodeType===4)y=A.firstChild.nodeValue||"";if(!y.trim())continue;let p=!1;if(j){let m=/@font-face\s*\{[^}]*\}/gi,B=y.match(m)||[];for(let h of B){let N=h.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(N){let n=N[1],o=M6(n);if(o){R++;let s=H6(H,o.mimeType,R),q0=O6(o),f=await v(s,q0,o.mimeType);f.type="font";let E=h.match(/font-family:\s*["']?([^"';]+)["']?/);if(E)f.fontFamily=E[1].trim();if(!O)y=y.replace(n,`./${s}`),p=!0}}}if(Y){let h=[],N=/font-family:\s*["']?([^"';,]+)/gi,n;while((n=N.exec(y))!==null){let o=n[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)=>o.toLowerCase().includes(q0.toLowerCase())))h.push(o)}if(h.length>0&&!O){let o=[...new Set(h)],s=`@import url('https://fonts.googleapis.com/css2?family=${o.map((q0)=>q0.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
|
-
`,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
|
|
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};
|