@emasoft/svg-matrix 1.3.4 → 1.3.6
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 +56 -0
- package/bin/svg-matrix.js +67 -3
- package/bin/svglinter.cjs +84 -0
- package/bin/svgm.js +37 -0
- package/dist/svg-matrix.global.min.js +2 -2
- package/dist/svg-matrix.min.js +2 -2
- package/dist/svg-toolbox.global.min.js +110 -110
- package/dist/svg-toolbox.min.js +110 -110
- package/dist/svgm.min.js +112 -112
- package/dist/version.json +8 -8
- package/package.json +1 -1
- package/src/animation-optimization.js +29 -0
- package/src/index.js +2 -2
- package/src/inkscape-support.js +768 -0
- package/src/svg-matrix-lib.js +2 -2
- package/src/svg-toolbox-lib.js +2 -2
- package/src/svg-toolbox.js +290 -3
- package/src/svg-validation-data.js +1 -0
- package/src/svgm-lib.js +2 -2
package/dist/svgm.min.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
/*! svg-matrix v1.3.
|
|
2
|
-
var
|
|
3
|
-
`,"\t"],
|
|
1
|
+
/*! svg-matrix v1.3.6 | MIT License | https://github.com/Emasoft/svg-matrix */
|
|
2
|
+
var mQ=Object.create;var{getPrototypeOf:dQ,defineProperty:g$,getOwnPropertyNames:$8,getOwnPropertyDescriptor:pQ}=Object,J8=Object.prototype.hasOwnProperty;var t7=($,J,Z)=>{Z=$!=null?mQ(dQ($)):{};let Q=J||!$||!$.__esModule?g$(Z,"default",{value:$,enumerable:!0}):Z;for(let K of $8($))if(!J8.call(Q,K))g$(Q,K,{get:()=>$[K],enumerable:!0});return Q},eJ=new WeakMap,cQ=($)=>{var J=eJ.get($),Z;if(J)return J;if(J=g$({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")$8($).map((Q)=>!J8.call(J,Q)&&g$(J,Q,{get:()=>$[Q],enumerable:!(Z=pQ($,Q))||Z.enumerable}));return eJ.set($,J),J};var d7=($,J)=>{for(var Z in J)g$($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(Q)=>J[Z]=()=>Q})};var Z8=($,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 Y$={};d7(Y$,{win32:()=>MJ,toNamespacedPath:()=>TW,sep:()=>hW,resolve:()=>CW,relative:()=>EW,posix:()=>j$,parse:()=>DW,normalize:()=>IW,join:()=>AW,isAbsolute:()=>PW,format:()=>vW,extname:()=>SW,dirname:()=>bW,delimiter:()=>yW,default:()=>NW,basename:()=>fW});var VW,ZZ,OW,YW,MW,XW,kW=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),LW=($,J,Z,Q)=>{if(J&&typeof J=="object"||typeof J=="function")for(let K of YW(J))!XW.call($,K)&&K!==Z&&ZZ($,K,{get:()=>J[K],enumerable:!(Q=OW(J,K))||Q.enumerable});return $},wW=($,J,Z)=>(Z=$!=null?VW(MW($)):{},LW(J||!$||!$.__esModule?ZZ(Z,"default",{value:$,enumerable:!0}):Z,$)),RW,QZ,c0,BW,JZ=function($){return $},KZ=function(){throw new Error("Not implemented")},j$,MJ,NW,CW,IW,PW,AW,EW,TW,bW,fW,SW,vW,DW,hW,yW;var M$=Z8(()=>{VW=Object.create,ZZ=Object.defineProperty,OW=Object.getOwnPropertyDescriptor,YW=Object.getOwnPropertyNames,MW=Object.getPrototypeOf,XW=Object.prototype.hasOwnProperty,RW=kW(($,J)=>{function Z(H){if(typeof H!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(H))}function Q(H,W){for(var j="",z=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(j.length<2||z!==2||j.charCodeAt(j.length-1)!==46||j.charCodeAt(j.length-2)!==46){if(j.length>2){var Y=j.lastIndexOf("/");if(Y!==j.length-1){Y===-1?(j="",z=0):(j=j.slice(0,Y),z=j.length-1-j.lastIndexOf("/")),G=U,F=0;continue}}else if(j.length===2||j.length===1){j="",z=0,G=U,F=0;continue}}W&&(j.length>0?j+="/..":j="..",z=2)}else j.length>0?j+="/"+H.slice(G+1,U):j=H.slice(G+1,U),z=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return j}function K(H,W){var j=W.dir||W.root,z=W.base||(W.name||"")+(W.ext||"");return j?j===W.root?j+z:j+H+z:z}var q={resolve:function(){for(var H="",W=!1,j,z=arguments.length-1;z>=-1&&!W;z--){var G;z>=0?G=arguments[z]:(j===void 0&&(j=process.cwd()),G=j),Z(G),G.length!==0&&(H=G+"/"+H,W=G.charCodeAt(0)===47)}return H=Q(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,j=H.charCodeAt(H.length-1)===47;return H=Q(H,!W),H.length===0&&!W&&(H="."),H.length>0&&j&&(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 j=arguments[W];Z(j),j.length>0&&(H===void 0?H=j:H+="/"+j)}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 j=1;j<H.length&&H.charCodeAt(j)===47;++j);for(var z=H.length,G=z-j,F=1;F<W.length&&W.charCodeAt(F)===47;++F);for(var _=W.length,U=_-F,Y=G<U?G:U,V=-1,M=0;M<=Y;++M){if(M===Y){if(U>Y){if(W.charCodeAt(F+M)===47)return W.slice(F+M+1);if(M===0)return W.slice(F+M)}else G>Y&&(H.charCodeAt(j+M)===47?V=M:M===0&&(V=0));break}var X=H.charCodeAt(j+M),k=W.charCodeAt(F+M);if(X!==k)break;X===47&&(V=M)}var L="";for(M=j+V+1;M<=z;++M)(M===z||H.charCodeAt(M)===47)&&(L.length===0?L+="..":L+="/..");return L.length>0?L+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),j=W===47,z=-1,G=!0,F=H.length-1;F>=1;--F)if(W=H.charCodeAt(F),W===47){if(!G){z=F;break}}else G=!1;return z===-1?j?"/":".":j&&z===1?"//":H.slice(0,z)},basename:function(H,W){if(W!==void 0&&typeof W!="string")throw new TypeError('"ext" argument must be a string');Z(H);var j=0,z=-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 Y=H.charCodeAt(F);if(Y===47){if(!G){j=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(Y===W.charCodeAt(_)?--_===-1&&(z=F):(_=-1,z=U))}return j===z?z=U:z===-1&&(z=H.length),H.slice(j,z)}else{for(F=H.length-1;F>=0;--F)if(H.charCodeAt(F)===47){if(!G){j=F+1;break}}else z===-1&&(G=!1,z=F+1);return z===-1?"":H.slice(j,z)}},extname:function(H){Z(H);for(var W=-1,j=0,z=-1,G=!0,F=0,_=H.length-1;_>=0;--_){var U=H.charCodeAt(_);if(U===47){if(!G){j=_+1;break}continue}z===-1&&(G=!1,z=_+1),U===46?W===-1?W=_:F!==1&&(F=1):W!==-1&&(F=-1)}return W===-1||z===-1||F===0||F===1&&W===z-1&&W===j+1?"":H.slice(W,z)},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 K("/",H)},parse:function(H){Z(H);var W={root:"",dir:"",base:"",ext:"",name:""};if(H.length===0)return W;var j=H.charCodeAt(0),z=j===47,G;z?(W.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,Y=!0,V=H.length-1,M=0;V>=G;--V){if(j=H.charCodeAt(V),j===47){if(!Y){_=V+1;break}continue}U===-1&&(Y=!1,U=V+1),j===46?F===-1?F=V:M!==1&&(M=1):F!==-1&&(M=-1)}return F===-1||U===-1||M===0||M===1&&F===U-1&&F===_+1?U!==-1&&(_===0&&z?W.base=W.name=H.slice(1,U):W.base=W.name=H.slice(_,U)):(_===0&&z?(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):z&&(W.dir="/"),W},sep:"/",delimiter:":",win32:null,posix:null};q.posix=q,J.exports=q}),QZ=wW(RW()),c0=QZ,BW=QZ;c0.parse??=KZ;BW.parse??=KZ;j$={resolve:c0.resolve.bind(c0),normalize:c0.normalize.bind(c0),isAbsolute:c0.isAbsolute.bind(c0),join:c0.join.bind(c0),relative:c0.relative.bind(c0),toNamespacedPath:JZ,dirname:c0.dirname.bind(c0),basename:c0.basename.bind(c0),extname:c0.extname.bind(c0),format:c0.format.bind(c0),parse:c0.parse.bind(c0),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:JZ},MJ={sep:"\\",delimiter:";",win32:void 0,...j$,posix:j$};j$.win32=MJ.win32=MJ;j$.posix=j$;NW=j$,{resolve:CW,normalize:IW,isAbsolute:PW,join:AW,relative:EW,toNamespacedPath:TW,dirname:bW,basename:fW,extname:SW,format:vW,parse:DW,sep:hW,delimiter:yW}=j$});var hQ={};d7(hQ,{resolveObject:()=>DQ,resolve:()=>vQ,parse:()=>y$,format:()=>SQ,default:()=>hz,Url:()=>L7,URLSearchParams:()=>bQ,URL:()=>hJ});function yJ($){return typeof $=="string"}function fQ($){return typeof $=="object"&&$!==null}function q9($){return $===null}function Pz($){return $==null}function L7(){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 y$($,J,Z){if($&&fQ($)&&$ instanceof L7)return $;var Q=new L7;return Q.parse($,J,Z),Q}function SQ($){return yJ($)&&($=y$($)),$ instanceof L7?$.format():L7.prototype.format.call($)}function vQ($,J){return y$($,!1,!0).resolve(J)}function DQ($,J){return $?y$($,!1,!0).resolveObject(J):J}var hJ,bQ,Az,Ez,Tz,bz,fz,SJ,AQ,EQ,Sz=255,TQ,vz,Dz,vJ,h$,DJ,hz;var yQ=Z8(()=>{({URL:hJ,URLSearchParams:bQ}=globalThis);Az=/^([a-z0-9.+-]+:)/i,Ez=/:[0-9]*$/,Tz=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,bz=["<",">",'"',"`"," ","\r",`
|
|
3
|
+
`,"\t"],fz=["{","}","|","\\","^","`"].concat(bz),SJ=["'"].concat(fz),AQ=["%","/","?",";","#"].concat(SJ),EQ=["/","?","#"],TQ=/^[+a-z0-9A-Z_-]{0,63}$/,vz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Dz={javascript:!0,"javascript:":!0},vJ={javascript:!0,"javascript:":!0},h$={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},DJ={parse($){var J=decodeURIComponent;return($+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(Z,Q,K){var q=Q.split("="),H=J(q[0]||""),W=J(q[1]||""),j=Z[H];return Z[H]=j===void 0?W:[].concat(j,W),Z},{})},stringify($){var J=encodeURIComponent;return Object.keys($||{}).reduce(function(Z,Q){return[].concat($[Q]).forEach(function(K){Z.push(J(Q)+"="+J(K))}),Z},[]).join("&").replace(/\s/g,"+")}};L7.prototype.parse=function($,J,Z){if(!yJ($))throw new TypeError("Parameter 'url' must be a string, not "+typeof $);var Q=$.indexOf("?"),K=Q!==-1&&Q<$.indexOf("#")?"?":"#",q=$.split(K),H=/\\/g;q[0]=q[0].replace(H,"/"),$=q.join(K);var W=$;if(W=W.trim(),!Z&&$.split("#").length===1){var j=Tz.exec(W);if(j)return this.path=W,this.href=W,this.pathname=j[1],j[2]?(this.search=j[2],J?this.query=DJ.parse(this.search.substr(1)):this.query=this.search.substr(1)):J&&(this.search="",this.query={}),this}var z=Az.exec(W);if(z){z=z[0];var G=z.toLowerCase();this.protocol=G,W=W.substr(z.length)}if(Z||z||W.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=W.substr(0,2)==="//";F&&!(z&&vJ[z])&&(W=W.substr(2),this.slashes=!0)}if(!vJ[z]&&(F||z&&!h$[z])){for(var _=-1,U=0;U<EQ.length;U++){var Y=W.indexOf(EQ[U]);Y!==-1&&(_===-1||Y<_)&&(_=Y)}var V,M;_===-1?M=W.lastIndexOf("@"):M=W.lastIndexOf("@",_),M!==-1&&(V=W.slice(0,M),W=W.slice(M+1),this.auth=decodeURIComponent(V)),_=-1;for(var U=0;U<AQ.length;U++){var Y=W.indexOf(AQ[U]);Y!==-1&&(_===-1||Y<_)&&(_=Y)}_===-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,L=k.length;U<L;U++){var R=k[U];if(!!R&&!R.match(TQ)){for(var B="",I=0,h=R.length;I<h;I++)R.charCodeAt(I)>127?B+="x":B+=R[I];if(!B.match(TQ)){var g=k.slice(0,U),f=k.slice(U+1),x=R.match(vz);x&&(g.push(x[1]),f.unshift(x[2])),f.length&&(W="/"+f.join(".")+W),this.hostname=g.join(".");break}}}this.hostname.length>Sz?this.hostname="":this.hostname=this.hostname.toLowerCase(),X||(this.hostname=new hJ(`https://${this.hostname}`).hostname);var D=this.port?":"+this.port:"",T=this.hostname||"";this.host=T+D,this.href+=this.host,X&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),W[0]!=="/"&&(W="/"+W))}if(!Dz[G])for(var U=0,L=SJ.length;U<L;U++){var d=SJ[U];if(W.indexOf(d)!==-1){var c=encodeURIComponent(d);c===d&&(c=escape(d)),W=W.split(d).join(c)}}var p=W.indexOf("#");p!==-1&&(this.hash=W.substr(p),W=W.slice(0,p));var C=W.indexOf("?");if(C!==-1?(this.search=W.substr(C),this.query=W.substr(C+1),J&&(this.query=DJ.parse(this.query)),W=W.slice(0,C)):J&&(this.search="",this.query={}),W&&(this.pathname=W),h$[G]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var D=this.pathname||"",y=this.search||"";this.path=D+y}return this.href=this.format(),this};L7.prototype.format=function(){var $=this.auth||"";$&&($=encodeURIComponent($),$=$.replace(/%3A/i,":"),$+="@");var J=this.protocol||"",Z=this.pathname||"",Q=this.hash||"",K=!1,q="";this.host?K=$+this.host:this.hostname&&(K=$+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(K+=":"+this.port)),this.query&&fQ(this.query)&&Object.keys(this.query).length&&(q=DJ.stringify(this.query));var H=this.search||q&&"?"+q||"";return J&&J.substr(-1)!==":"&&(J+=":"),this.slashes||(!J||h$[J])&&K!==!1?(K="//"+(K||""),Z&&Z.charAt(0)!=="/"&&(Z="/"+Z)):K||(K=""),Q&&Q.charAt(0)!=="#"&&(Q="#"+Q),H&&H.charAt(0)!=="?"&&(H="?"+H),Z=Z.replace(/[?#]/g,function(W){return encodeURIComponent(W)}),H=H.replace("#","%23"),J+K+Z+H+Q};L7.prototype.resolve=function($){return this.resolveObject(y$($,!1,!0)).format()};L7.prototype.resolveObject=function($){if(yJ($)){var J=new L7;J.parse($,!1,!0),$=J}for(var Z=new L7,Q=Object.keys(this),K=0;K<Q.length;K++){var q=Q[K];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 j=H[W];j!=="protocol"&&(Z[j]=$[j])}return h$[Z.protocol]&&Z.hostname&&!Z.pathname&&(Z.path=Z.pathname="/"),Z.href=Z.format(),Z}if($.protocol&&$.protocol!==Z.protocol){if(!h$[$.protocol]){for(var z=Object.keys($),G=0;G<z.length;G++){var F=z[G];Z[F]=$[F]}return Z.href=Z.format(),Z}if(Z.protocol=$.protocol,!$.host&&!vJ[$.protocol]){for(var L=($.pathname||"").split("/");L.length&&!($.host=L.shift()););$.host||($.host=""),$.hostname||($.hostname=""),L[0]!==""&&L.unshift(""),L.length<2&&L.unshift(""),Z.pathname=L.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 Y=Z.pathname&&Z.pathname.charAt(0)==="/",V=$.host||$.pathname&&$.pathname.charAt(0)==="/",M=V||Y||Z.host&&$.pathname,X=M,k=Z.pathname&&Z.pathname.split("/")||[],L=$.pathname&&$.pathname.split("/")||[],R=Z.protocol&&!h$[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&&(L[0]===""?L[0]=$.host:L.unshift($.host)),$.host=null),M=M&&(L[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=L;else if(L.length)k||(k=[]),k.pop(),k=k.concat(L),Z.search=$.search,Z.query=$.query;else if(!Pz($.search)){if(R){Z.hostname=Z.host=k.shift();var B=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;B&&(Z.auth=B.shift(),Z.host=Z.hostname=B.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 I=k.slice(-1)[0],h=(Z.host||$.host||k.length>1)&&(I==="."||I==="..")||I==="",g=0,f=k.length;f>=0;f--)I=k[f],I==="."?k.splice(f,1):I===".."?(k.splice(f,1),g++):g&&(k.splice(f,1),g--);if(!M&&!X)for(;g--;g)k.unshift("..");M&&k[0]!==""&&(!k[0]||k[0].charAt(0)!=="/")&&k.unshift(""),h&&k.join("/").substr(-1)!=="/"&&k.push("");var x=k[0]===""||k[0]&&k[0].charAt(0)==="/";if(R){Z.hostname=Z.host=x?"":k.length?k.shift():"";var B=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;B&&(Z.auth=B.shift(),Z.host=Z.hostname=B.shift())}return M=M||Z.host&&k.length,M&&!x&&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};L7.prototype.parseHost=function(){var $=this.host,J=Ez.exec($);J&&(J=J[0],J!==":"&&(this.port=J.substr(1)),$=$.substr(0,$.length-J.length)),$&&(this.hostname=$)};hz={parse:y$,resolve:vQ,resolveObject:DQ,format:SQ,Url:L7,URL:hJ,URLSearchParams:bQ}});/*!
|
|
4
4
|
* decimal.js v10.6.0
|
|
5
5
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
6
6
|
* https://github.com/MikeMcl/decimal.js
|
|
7
7
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
8
8
|
* MIT Licence
|
|
9
|
-
*/var R$=9000000000000000,e7=1e9,H9="0123456789abcdef",_6="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",U6="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",W9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-R$,maxE:R$,crypto:!1},tJ,m7,P0=!0,O6="[DecimalError] ",t7=O6+"Invalid argument: ",eJ=O6+"Precision limit exceeded",$8=O6+"crypto unavailable",J8="[object Decimal]",e0=Math.floor,n0=Math.pow,SK=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,vK=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,DK=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Z8=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,I7=1e7,R0=7,hK=9007199254740991,yK=_6.length-1,z9=U6.length-1,K0={toStringTag:J8};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,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=uK(K,W8(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,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(Y0(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")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=($-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 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,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/Y6(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 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=B$(q,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/Y6(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,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()?E7(J,K,Q):new J(0):new J(NaN);if($.isZero())return E7(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 $=E7(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<=z9)return H=E7(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<=z9)return H=E7(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,Y0(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?V6(G,W+10):a7($,W),z=v0(H,K,W,1),u$(z.d,Q=F,_))do if(W+=10,H=a7(j,W),K=J?V6(G,W+10):a7($,W),z=v0(H,K,W,1),!q){if(+a0(z.d).slice(Q+1,Q+15)+1==100000000000000)z=Y0(z,F+1,0);break}while(u$(z.d,Q+=10,_));return P0=!0,Y0(z,F,_)};K0.minus=K0.sub=function($){var J,Z,K,Q,q,H,W,z,j,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(j=U.d,_=$.d,W=Y.precision,z=Y.rounding,!j[0]||!_[0]){if(_[0])$.s=-$.s;else if(j[0])$=new Y(U);else return new Y(z===3?-0:0);return P0?Y0($,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]=I7-1;--j[Q],j[K]+=I7}j[K]-=_[K]}for(;j[--H]===0;)j.pop();for(;j[0]===0;j.shift())--Z;if(!j[0])return new Y(z===3?-0:0);return $.d=j,$.e=M6(j,Z),P0?Y0($,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 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 j9(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,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?Y0($,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)/I7|0,j[Q]%=I7;if(J)j.unshift(J),++K;for(H=j.length;j[--H]==0;)j.pop();return $.d=j,$.e=M6(j,K),P0?Y0($,W,z):$};K0.precision=K0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(t7+$);if(Z.d){if(J=K8(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=xK(K,W8(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,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(Y0(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")Y0(K,z+1,1),$=!K.times(K).eq(H);break}return P0=!0,Y0(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,Y0(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%I7|0,J=W/I7|0;q[Q]=(q[Q]+J)%I7|0}for(;!q[--H];)q.pop();if(J)++Z;else q.shift();return $.d=q,$.e=M6(q,Z),P0?Y0($,F.precision,F.rounding):$};K0.toBinary=function($,J){return G9(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 Y0(Z,$+Z.e+1,J)};K0.toExponential=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=T7(K,!0);else{if(q7($,0,e7),J===void 0)J=Q.rounding;else q7(J,0,8);K=Y0(new Q(K),$+1,J),Z=T7(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=T7(Q);else{if(q7($,0,e7),J===void 0)J=q.rounding;else q7(J,0,8);K=Y0(new q(Q),$+Q.e+1,J),Z=T7(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,Y=U.d,V=U.constructor;if(!Y)return new V(U);if(j=Z=new V(1),K=z=new V(0),J=new V(K),q=J.e=K8(Y)-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(Y)),G=V.precision,V.precision=q=Y.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 G9(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,Y0(Z);else $.s=Z.s,Z=$;return Z};K0.toNumber=function(){return+this};K0.toOctal=function($,J){return G9(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 Y0(W,K,q);if(J=e0($.e/R0),J>=$.d.length-1&&(Z=j<0?-j:j)<=hK)return Q=Q8(z,W,Z,K),$.s<0?new z(1).div(Q):Y0(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=j9($.times(a7(W,K+Z)),K),Q.d){if(Q=Y0(Q,K+5,1),u$(Q.d,K,q)){if(J=K+10,Q=Y0(j9($.times(a7(W,J+Z)),J),J+5,1),+a0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=Y0(Q,K+1,0)}}return Q.s=H,P0=!0,z.rounding=q,Y0(Q,K,q)};K0.toPrecision=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=T7(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=Y0(new Q(K),$,J),Z=T7(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 Y0(new K(Z),$,J)};K0.toString=function(){var $=this,J=$.constructor,Z=T7($,$.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=T7($,$.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 u$($,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 G6($,J,Z){var K,Q=[0],q,H=0,W=$.length;for(;H<W;){for(q=Q.length;q--;)Q[q]*=J;Q[0]+=H9.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 uK($,J){var Z,K,Q;if(J.isZero())return J;if(K=J.d.length,K<32)Z=Math.ceil(K/3),Q=(1/Y6(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,Y,V,M,X,k,w,R,I,P,h,u,b,g,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=I7,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),Y=!0;else{if(P=P/U+2|0,F=0,v==1){_=0,N=N[0],P++;for(;(F<b||_)&&P--;F++)h=_*z+(d[F]||0),k[F]=h/N|0,_=h%N|0;Y=_||F<b}else{if(_=z/(N[0]+1)|0,_>1)N=$(N,_,z),d=$(d,_,z),v=N.length,b=d.length;u=v,w=d.slice(0,v),R=w.length;for(;R<v;)w[R++]=0;if(E=N.slice(),E.unshift(0),g=N[0],N[1]>=z/2)++g;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/g|0,_>1){if(_>=z)_=z-1;if(V=$(N,_,z),M=V.length,R=w.length,j=J(V,w,M,R),j==1)_--,Z(V,v<M?E:N,M,z)}else{if(_==0)j=_=1;V=N.slice()}if(M=V.length,M<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[u]||0;else w=[d[u]],R=1}while((u++<b||w[0]!==void 0)&&P--);Y=w[0]!==void 0}if(!k[0])k.shift()}if(U==1)X.e=G,tJ=Y;else{for(F=1,_=k[0];_>=10;_/=10)F++;X.e=F+G*U-1,Y0(X,W?q+X.e+1:q,H,Y)}return X}}();function Y0($,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]==I7)F[0]=1}break}else{if(F[_]+=W,F[_]!=I7)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 T7($,J,Z){if(!$.isFinite())return H8($);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 V6($,J,Z){if(J>yK){if(P0=!0,Z)$.precision=Z;throw Error(eJ)}return Y0(new $(_6),J,1,!0)}function E7($,J,Z){if(J>z9)throw Error(eJ);return Y0(new $(U6),J,Z,!0)}function K8($){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),rJ(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),rJ(J.d,H)}return P0=!0,q}function iJ($){return $.d[$.d.length-1]&1}function q8($,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 j9($,J){var Z,K,Q,q,H,W,z,j=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,z=Y;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=Y0(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=Y0(H.times(H),z,1);if(J==null)if(j<3&&u$(H.d,z-K,U,j))_.precision=z+=10,Z=q=W=new _(1),G=0,j++;else return Y0(H,_.precision=Y,U,P0=!0);else return _.precision=Y,H}H=W}}function a7($,J){var Z,K,Q,q,H,W,z,j,G,F,_,U=1,Y=10,V=$,M=V.d,X=V.constructor,k=X.rounding,w=X.precision;if(V.s<0||!M||!M[0]||!V.e&&M[0]==1&&M.length==1)return new X(M&&!M[0]?-1/0:V.s!=1?NaN:M?0:V);if(J==null)P0=!1,G=w;else G=J;if(X.precision=G+=Y,Z=a0(M),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=V6(X,G+2,w).times(q+""),V=a7(new X(K+"."+Z.slice(1)),G-Y).plus(j),X.precision=w,J==null?Y0(V,w,k,P0=!0):V;F=V,z=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),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(V6(X,G+2,w).times(q+""));if(z=v0(z,new X(U),G,1),J==null)if(u$(z.d,G-Y,k,W))X.precision=G+=Y,j=H=V=v0(F.minus(1),F.plus(1),G,1),_=Y0(V.times(V),G,1),Q=W=1;else return Y0(z,X.precision=w,k,P0=!0);else return X.precision=w,z}z=j,Q+=2}}function H8($){return String($.s*$.s/0)}function F6($,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 gK($,J){var Z,K,Q,q,H,W,z,j,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),Z8.test(J))return F6($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(vK.test(J))Z=16,J=J.toLowerCase();else if(SK.test(J))Z=2;else if(DK.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=G6(J,Z,I7),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):g$.pow(2,z));return P0=!0,$}function xK($,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/Y6(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 Y6($,J){var Z=$;while(--J)Z*=$;return Z}function W8($,J){var Z,K=J.s<0,Q=E7($,$.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=iJ(Z)?K?2:3:K?4:1,J;m7=iJ(Z)?K?1:4:K?3:2}return J.minus(Q).abs()}function G9($,J,Z,K){var Q,q,H,W,z,j,G,F,_,U=$.constructor,Y=Z!==void 0;if(Y)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=H8($);else{if(G=T7($),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=G6(T7(_),10,Q),_.e=_.d.length;F=G6(G,10,Q),q=z=F.length;for(;F[--z]==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,j=tJ;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+=H9.charAt(F[H]);if(Y){if(z>1)if(J==16||J==8){H=J==16?4:3;for(--z;z%H;z++)G+="0";F=G6(G,Q,J);for(z=F.length;!F[z-1];--z);for(H=1,G="1.";H<z;H++)G+=H9.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 rJ($,J){if($.length>J)return $.length=J,!0}function mK($){return new this($).abs()}function dK($){return new this($).acos()}function pK($){return new this($).acosh()}function cK($,J){return new this($).plus(J)}function nK($){return new this($).asin()}function lK($){return new this($).asinh()}function sK($){return new this($).atan()}function oK($){return new this($).atanh()}function iK($,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=E7(this,q,1).times(J.s>0?0.25:0.75),Z.s=$.s;else if(!J.d||$.isZero())Z=J.s<0?E7(this,K,Q):new this(0),Z.s=$.s;else if(!$.d||J.isZero())Z=E7(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=E7(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 rK($){return new this($).cbrt()}function aK($){return Y0($=new this($),$.e+1,2)}function tK($,J,Z){return new this($).clamp(J,Z)}function eK($){if(!$||typeof $!=="object")throw Error(O6+"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]=W9[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]=W9[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($8);else this[Z]=!1;else throw Error(t7+Z+": "+K);return this}function $Q($){return new this($).cos()}function JQ($){return new this($).cosh()}function z8($){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,aJ(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 F6(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 Z8.test(q)?F6(j,q):gK(j,q)}if(z==="bigint"){if(q<0)q=-q,j.s=-1;else j.s=1;return F6(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=eK,Q.clone=z8,Q.isDecimal=aJ,Q.abs=mK,Q.acos=dK,Q.acosh=pK,Q.add=cK,Q.asin=nK,Q.asinh=lK,Q.atan=sK,Q.atanh=oK,Q.atan2=iK,Q.cbrt=rK,Q.ceil=aK,Q.clamp=tK,Q.cos=$Q,Q.cosh=JQ,Q.div=ZQ,Q.exp=KQ,Q.floor=QQ,Q.hypot=qQ,Q.ln=HQ,Q.log=WQ,Q.log10=jQ,Q.log2=zQ,Q.max=GQ,Q.min=FQ,Q.mod=_Q,Q.mul=UQ,Q.pow=VQ,Q.random=OQ,Q.round=MQ,Q.sign=YQ,Q.sin=XQ,Q.sinh=kQ,Q.sqrt=wQ,Q.sub=LQ,Q.sum=RQ,Q.tan=BQ,Q.tanh=NQ,Q.trunc=IQ,$===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 ZQ($,J){return new this($).div(J)}function KQ($){return new this($).exp()}function QQ($){return Y0($=new this($),$.e+1,3)}function qQ(){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 aJ($){return $ instanceof g$||$&&$.toStringTag===J8||!1}function HQ($){return new this($).ln()}function WQ($,J){return new this($).log(J)}function zQ($){return new this($).log(2)}function jQ($){return new this($).log(10)}function GQ(){return q8(this,arguments,-1)}function FQ(){return q8(this,arguments,1)}function _Q($,J){return new this($).mod(J)}function UQ($,J){return new this($).mul(J)}function VQ($,J){return new this($).pow(J)}function OQ($){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($8);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 MQ($){return Y0($=new this($),$.e+1,this.rounding)}function YQ($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function XQ($){return new this($).sin()}function kQ($){return new this($).sinh()}function wQ($){return new this($).sqrt()}function LQ($,J){return new this($).sub(J)}function RQ(){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 BQ($){return new this($).tan()}function NQ($){return new this($).tanh()}function IQ($){return Y0($=new this($),$.e+1,1)}K0[Symbol.for("nodejs.util.inspect.custom")]=K0.toString;K0[Symbol.toStringTag]="Decimal";var g$=K0.constructor=z8(W9);_6=new g$(_6);U6=new g$(U6);var O=g$;var F9=($)=>{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 F9(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=F9($)}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=F9(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 z0{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 z0($)}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 z0(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 z0(J)}clone(){return new z0(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 z0){if(this.rows!==$.rows||this.cols!==$.cols)throw new 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=N$($);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 new 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=N$($);return new z0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof z0){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 z0(J)}else{let J=N$($);return new z0(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 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 O(this.data[Q][Z])));return new z0($)}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 z0))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=z0.zeros($,$);for(let H=0;H<$;H++)q.data[H][Z[H]]=new O(1);return{L:new z0(K),U:new z0(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 z0(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=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 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 z0(K).transpose(),R:new z0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=z0.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 Y=new O(0);for(let V=0;V<F.cols;V++)Y=Y.plus(F.data[U][V].abs());if(Y.greaterThan(_))_=Y}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 Y=0;Y<j.cols;Y++)_=_.plus(j.data[U][Y].abs());if(_.lessThan(Q))break}for(let F=0;F<W;F++)G=G.mul(G);return G}}var b7={};x7(b7,{translation:()=>l0,stretchAlongAxis:()=>CQ,skew:()=>X6,scale:()=>U7,rotateAroundPoint:()=>_9,rotate:()=>j$,reflectY:()=>AQ,reflectX:()=>PQ,reflectOrigin:()=>EQ,applyTransform:()=>c0});var H7=($)=>{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 l0($,J){return J7($,"tx"),J7(J,"ty"),z0.from([[new O(1),new O(0),H7($)],[new O(0),new O(1),H7(J)],[new O(0),new O(0),new O(1)]])}function U7($,J=null){if(J7($,"sx"),J!==null)J7(J,"sy");let Z=J===null?$:J,K=H7($),Q=H7(Z);if(K.isZero()||Q.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return z0.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=H7($).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 z0.from([[q,H.negated(),new O(0)],[H,q,new O(0)],[new O(0),new O(0),new O(1)]])}function _9($,J,Z){J7($,"theta"),J7(J,"px"),J7(Z,"py");let K=H7(J),Q=H7(Z);return l0(K,Q).mul(j$($)).mul(l0(K.negated(),Q.negated()))}function X6($,J){J7($,"ax"),J7(J,"ay");let Z=H7($),K=H7(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 z0.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 CQ($,J,Z){J7($,"ux"),J7(J,"uy"),J7(Z,"k");let K=H7($),Q=H7(J),q=H7(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)),Y=j.plus(G.mul(Q.mul(Q)));return z0.from([[F,_,new O(0)],[U,Y,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=z0.from([[H7(J)],[H7(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 PQ(){return z0.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 AQ(){return z0.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 EQ(){return z0.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 V9={};x7(V9,{translation:()=>U9,scale:()=>TQ,rotateZ:()=>SQ,rotateY:()=>fQ,rotateX:()=>bQ,rotateAroundPoint:()=>vQ,rotateAroundAxis:()=>j8,reflectYZ:()=>uQ,reflectXZ:()=>yQ,reflectXY:()=>hQ,reflectOrigin:()=>gQ,applyTransform:()=>DQ});var s0=($)=>{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 k6($){let J=$.toNumber();if(!Number.isFinite(J))throw new Error(`Angle must be finite, got ${$}`);if(Math.abs(J)<=6.283185307179586)return J;return J%6.283185307179586}function U9($,J,Z){return g0($,"tx"),g0(J,"ty"),g0(Z,"tz"),z0.from([[new O(1),new O(0),new O(0),s0($)],[new O(0),new O(1),new O(0),s0(J)],[new O(0),new O(0),new O(1),s0(Z)],[new O(0),new O(0),new O(0),new O(1)]])}function TQ($,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=s0($),H=s0(K),W=s0(Q);return z0.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 bQ($){g0($,"theta");let J=s0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return z0.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 fQ($){g0($,"theta");let J=s0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return z0.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 SQ($){g0($,"theta");let J=s0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return z0.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 j8($,J,Z,K){g0($,"ux"),g0(J,"uy"),g0(Z,"uz"),g0(K,"theta");let Q=[s0($),s0(J),s0(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=s0(K),W=k6(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]),Y=F.plus(z.mul(G.minus(F))),V=Q[0].mul(Q[1]).mul(G.minus(z)).minus(Q[2].mul(j)),M=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 z0.from([[Y,V,M,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 vQ($,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=s0(Q),z=s0(q),j=s0(H);return U9(W,z,j).mul(j8($,J,Z,K)).mul(U9(W.negated(),z.negated(),j.negated()))}function DQ($,J,Z,K){if(!($ instanceof z0))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=z0.from([[s0(J)],[s0(Z)],[s0(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 hQ(){return z0.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 yQ(){return z0.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 uQ(){return z0.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 z0.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 Z9={};x7(Z9,{validateXML:()=>KK,validateSVGAsync:()=>oW,validateSVG:()=>QK,straightCurves:()=>KJ,sortDefsChildren:()=>fZ,sortAttrs:()=>bZ,simplifyPaths:()=>_K,simplifyPath:()=>jK,saveOutput:()=>qZ,reusePaths:()=>SZ,removeXlink:()=>hZ,removeXMLProcInst:()=>VZ,removeXMLNS:()=>kZ,removeViewBox:()=>XZ,removeUselessDefs:()=>FZ,removeUselessCommands:()=>HJ,removeUnknownsAndDefaults:()=>jZ,removeTitle:()=>OZ,removeStyleElement:()=>DZ,removeScriptElement:()=>LZ,removeRasterImages:()=>wZ,removeOffCanvasPath:()=>vZ,removeNonInheritableGroupAttrs:()=>GZ,removeMetadata:()=>$9,removeLeadingZero:()=>a9,removeHiddenElements:()=>a6,removeEmptyText:()=>_Z,removeEmptyContainers:()=>t6,removeEmptyAttrs:()=>YZ,removeElementsByAttr:()=>pZ,removeEditorsNSData:()=>wJ,removeDoctype:()=>UZ,removeDimensions:()=>xZ,removeDesc:()=>MZ,removeComments:()=>e6,removeAttrs:()=>dZ,removeAttributesBySelector:()=>mZ,printHierarchicalMatrix:()=>mW,presetNone:()=>NJ,presetDefault:()=>BJ,prefixIds:()=>gZ,optimizePaths:()=>FK,optimizeAnimationTiming:()=>GK,optimize:()=>nZ,negativeExtraSpace:()=>t9,moveGroupAttrsToElems:()=>AZ,moveElemsAttrsToGroup:()=>EZ,minifyStyles:()=>RJ,mergePaths:()=>PZ,measureDistance:()=>ZK,loadInput:()=>H6,lineShorthands:()=>JJ,inlineStyles:()=>TZ,imageToPath:()=>$K,generateOutput:()=>W6,generateFullCompatibilityMatrix:()=>xW,generateFlexibleSVGTable:()=>qK,generateCompatibilityMatrixSVG:()=>dW,generateCompatibilityMatrixFlexible:()=>pW,formatPrecision:()=>QZ,floatPrecision:()=>qJ,flattenUseElements:()=>eZ,flattenPatterns:()=>aZ,flattenMasks:()=>oZ,flattenGradients:()=>iZ,flattenFilters:()=>tZ,flattenClipPaths:()=>sZ,flattenAll:()=>zK,fixInvalidSVG:()=>HK,exportEmbeddedResources:()=>OK,escapeXml:()=>EW,embedExternalDependencies:()=>CJ,detectOutputTarget:()=>XJ,detectInputType:()=>w$,detectCollisions:()=>JK,default:()=>Gz,decomposeTransform:()=>UK,createOperation:()=>F0,createConfig:()=>lZ,convertTransform:()=>NZ,convertToZ:()=>ZJ,convertToRelative:()=>e9,convertToAbsolute:()=>$J,convertStyleToAttrs:()=>LJ,convertShapesToPath:()=>RZ,convertQuadraticToSmooth:()=>zJ,convertPathData:()=>BZ,convertEllipseToCircle:()=>IZ,convertCubicToSmooth:()=>jJ,convertCubicToQuadratic:()=>WJ,convertColors:()=>J9,collapseRepeated:()=>QJ,collapseGroups:()=>CZ,cleanupNumericValues:()=>r6,cleanupListOfValues:()=>HZ,cleanupIds:()=>kJ,cleanupEnableBackground:()=>zZ,cleanupAttributes:()=>WZ,arcShorthands:()=>GJ,applyPreset:()=>cZ,analyzeCompatibilityMatrix:()=>gW,analyzeCompatibility:()=>vW,addClassesToSVGElement:()=>uZ,addAttributesToSVGElement:()=>yZ,ValidationSeverity:()=>A0,PRECISION_LEVELS:()=>KZ,OutputTarget:()=>Y7,OutputFormat:()=>X7,MAX_PRECISION:()=>q6,InputType:()=>D0,DEFAULT_PRECISION:()=>s6});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($),mQ=new O("1e-40"),dQ=new O("1e-30");function pQ($,J){if($==null)throw new TypeError("translationMatrix: tx parameter is required");if(J==null)throw new TypeError("translationMatrix: ty parameter is required");return z0.from([[1,0,y0($)],[0,1,y0(J)],[0,0,1]])}function cQ($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=y0($),Z=O.cos(J),K=O.sin(J);return z0.from([[Z,K.neg(),0],[K,Z,0],[0,0,1]])}function nQ($,J){if($==null)throw new TypeError("scaleMatrix: sx parameter is required");if(J==null)throw new TypeError("scaleMatrix: sy parameter is required");return z0.from([[y0($),0,0],[0,y0(J),0],[0,0,1]])}function lQ($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=O.tan(y0($));return z0.from([[1,J,0],[0,1,0],[0,0,1]])}function sQ($){if($==null)throw new TypeError("skewYMatrix: angle parameter is required");let J=O.tan(y0($));return z0.from([[1,0,0],[J,1,0],[0,0,1]])}function oQ($){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 iQ($){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 G8($){if(!$)throw new TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:K,d:Q}=oQ($),{tx:q,ty:H}=iQ($),W=J.mul(Q).minus(Z.mul(K)),z=J.mul(J).plus(Z.mul(Z)).sqrt();if(z.abs().lessThan(mQ))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;if(z.lessThan(0))G=O.atan2(Z.neg(),J.neg());else G=O.atan2(Z,J);let F=O.cos(G),_=O.sin(G),U=J.mul(F).plus(Z.mul(_)),Y=K.mul(F).plus(Q.mul(_)),V,M=new O("1e-30");if(U.abs().greaterThan(M)){let I=Y.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=rQ({translateX:q,translateY:H,rotation:G,scaleX:z,scaleY:j,skewX:V,skewY:y0(0)}),w=aQ($,k),R=w.lessThan(dQ);return{translateX:q,translateY:H,rotation:G,scaleX:z,scaleY:j,skewX:V,skewY:X,verified:R,maxError:w}}function rQ($){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=pQ(J,Z),j=cQ(K),G=lQ(H),F=sQ(W),_=nQ(Q,q);return z.mul(j).mul(F).mul(G).mul(_)}function aQ($,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 O7=($)=>$ instanceof O?$:new O($),m0=new O("1e-40"),F8=100;function f7($,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:O7($),y:O7(J)}}function eQ($,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 m$($){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=O7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function W7($,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 x$($,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 V7($){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 V7($).sqrt()}function $q($){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:O7(0),y:O7(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=W7($,Z),Q=W7(J,Z);return d0(M9(J,K),M9($,Q))}function _8($,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=W7($[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=W7($[Q],J);if(q.greaterThan(Z))Z=q,K=$[Q]}return K}function U8($,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=_8($,Z),Q=_8(J,m$(Z));return d0(K,Q)}function Jq($,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=m$(Z),H=V7(Q);if(H.lessThan(m0)){if(V7(Z).lessThan(m0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}let W=$$(Q,q,Q);if(V7(W).lessThan(m0)){let z=W7(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 Zq($,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=m$(Z),z=V7(q),j=V7(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(V7(G).lessThan(m0)&&V7(F).lessThan(m0)){let _=d0(Q,K),U=V7(_);if(U.greaterThan(z)&&U.greaterThan(j))return{contains:!1,newDirection:$$(_,m$(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(W7(G,W).greaterThan(m0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(W7(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(w6(J),w6($));if(V7(Z).lessThan(m0))Z=f7(1,0);let K=[U8($,J,Z)];if(Z=m$(K[0]),V7(K[0]).lessThan(m0))return{intersects:!0,iterations:1,simplex:K,verified:O9($,J)};for(let Q=0;Q<F8;Q++){let q=U8($,J,Z);if(W7(q,Z).lessThanOrEqualTo(O7(0)))return{intersects:!1,iterations:Q+1,simplex:K,verified:!0};if(K.unshift(q),K.length===2){let H=Jq(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=Zq(K,Z);if(H.contains)return{intersects:!0,iterations:Q+1,simplex:H.newSimplex,verified:O9($,J)};K=H.newSimplex,Z=H.newDirection}if(V7(Z).lessThan(m0))return{intersects:!1,iterations:Q+1,simplex:K,verified:!1};Z=$q(Z)}return{intersects:!1,iterations:F8,simplex:K,verified:!1}}function w6($){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=O7(0),Z=O7(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=O7($.length);return{x:J.div(K),y:Z.div(K)}}function V8($,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=x$(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 O9($,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(V8($[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(V8(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(Kq(K,Q,H,W))return!0}}return!1}function Kq($,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=x$(Q,q);if(H.abs().lessThan(m0)){let G=d0(Z,$);if(x$(Q,G).abs().lessThan(m0)){let F=W7(Q,Q);if(F.lessThan(m0)){let X=W7(q,q);if(X.lessThan(m0))return G$(G).lessThan(m0);let k=W7(G,q).div(X);return k.greaterThanOrEqualTo(0)&&k.lessThanOrEqualTo(1)}let _=W7(G,Q).div(F),U=d0(K,$),Y=W7(U,Q).div(F),V=O.min(_,Y);return O.max(_,Y).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let W=d0(Z,$),z=x$(W,q).div(H),j=x$(W,Q).div(H);return z.greaterThanOrEqualTo(0)&&z.lessThanOrEqualTo(1)&&j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)}function Qq($,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:O7(0),closestA:w6($),closestB:w6(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=O7(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 _=O8($[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 _=O8(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 O8($,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=V7(K);if(q.lessThan(m0))return J;let H=W7(Q,K).div(q);return H=O.max(O7(0),O.min(O7(1),H)),eQ(J,M9(K,H))}function L6($,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 f7(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 f7(q.x,q.y)}),Q=M8(Z,K);return{overlaps:Q.intersects,verified:Q.verified}}function Y8($,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 f7(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 f7(q.x,q.y)}),Q=Qq(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"),zq=new O("1e-10");function L8($){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 jq($,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 X8($,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),Y=U.mul(F),V=_.mul(_),M=V.mul(_),X=M.mul($).plus(j0(3).mul(V).mul(F).mul(Z)).plus(j0(3).mul(_).mul(U).mul(Q)).plus(Y.mul(H)),k=M.mul(J).plus(j0(3).mul(V).mul(F).mul(K)).plus(j0(3).mul(_).mul(U).mul(q)).plus(Y.mul(W));j.push({x:X,y:k})}return j}function k8($,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)),Y=F.mul(J).plus(j0(2).mul(G).mul(j).mul(K)).plus(_.mul(q));W.push({x:U,y:Y})}return W}function Gq($,J,Z=zq){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 R8($){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 M=V.type.toUpperCase(),X=V.type===V.type.toLowerCase();switch(M){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),h=X?H.plus(j0(V.y)):j0(V.y),u=X8(q,H,k,w,R,I,P,h,20);for(let b of u)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=h,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,h;if(F==="C"||F==="S")P=q.mul(2).minus(j),h=H.mul(2).minus(G);else P=q,h=H;let u=X8(q,H,P,h,k,w,R,I,20);for(let b of u)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=k8(q,H,k,w,R,I,20);for(let h of P)J=O.min(J,h.x),Z=O.min(Z,h.y),K=O.max(K,h.x),Q=O.max(Q,h.y),_.push(h);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=k8(q,H,R,I,k,w,20);for(let h of P)J=O.min(J,h.x),Z=O.min(Z,h.y),K=O.max(K,h.x),Q=O.max(Q,h.y),_.push(h);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,q.minus(R),k.minus(R)),Z=O.min(Z,H,w,H.minus(I),w.minus(I)),K=O.max(K,q,k,q.plus(R),k.plus(R)),Q=O.max(Q,H,w,H.plus(I),w.plus(I));let P=20;for(let h=0;h<=P;h++){let u=j0(h).div(P),b=q.plus(k.minus(q).mul(u)),g=H.plus(w.minus(H).mul(u));_.push({x:b,y:g})}}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: ${M}`)}}if(!J.isFinite()||!Z.isFinite()||!K.isFinite()||!Q.isFinite())throw new Error("Invalid bounding box: no valid coordinates found");let U=jq(J,Z,K,Q),Y=!0;for(let V of _)if(!Gq(V,U)){Y=!1;break}return{...U,verified:Y}}function w8($){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[f7($.minX,$.minY),f7($.maxX,$.minY),f7($.maxX,$.maxY),f7($.minX,$.maxY)]}function B8($,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=w8($),K=w8({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),Q=L6(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 _q($){if(typeof $!=="string"||!$.trim())throw new Error("Selector must be a non-empty string");let J=$.trim(),Z=[],K=Uq(J);for(let Q of K){if(!Q.trim())continue;let q=Vq(Q.trim());Z.push(...q)}return Z}function Uq($){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 Vq($){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=Oq($,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=Mq($,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 Oq($,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 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 R6($){let J=typeof $==="string"?_q($):$;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=Yq(z),G=[0,0,0];for(let F of j)if(F.trim()){let _=R6(F.trim());if(B6(_,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=R6(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 Yq($){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 B6($,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 c$={};x7(c$,{transformPathData:()=>Lq,transformArcParams:()=>C8,rectToPathData:()=>A6,polylineToPathData:()=>d$,polygonToPathData:()=>T6,pathToCubics:()=>Rq,pathToAbsolute:()=>p$,pathArrayToString:()=>I$,parsePathData:()=>J$,lineToPathData:()=>E6,getKappaForArc:()=>I8,getKappa:()=>N6,ellipseToPathDataHP:()=>I6,ellipseToPathData:()=>P6,convertElementToPath:()=>X9,circleToPathDataHP:()=>Y9,circleToPathData:()=>C6});var f0=($)=>$ instanceof O?$:new O($);function N6(){let $=new O(2),J=new O(3);return new O(4).mul($.sqrt().minus(1)).div(J)}function I8($){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 Y9($,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 I6($,J,Z,Z,K,Q)}function I6($,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),Y=O.acos(-1).mul(2).div(H),V=I8(Y),M=[];for(let X=0;X<H;X++){let k=Y.mul(X),w=Y.mul(X+1),R=O.cos(k),I=O.sin(k),P=O.cos(w),h=O.sin(w),u=W.plus(j.mul(R)),b=z.plus(G.mul(I)),g=W.plus(j.mul(P)),v=z.plus(G.mul(h)),E=I.neg(),m=R,c=h.neg(),d=P,N=u.plus(V.mul(j).mul(E)),y=b.plus(V.mul(G).mul(m)),B=g.minus(V.mul(j).mul(c)),t=v.minus(V.mul(G).mul(d));if(X===0)M.push(`M${F(u)} ${F(b)}`);M.push(`C${F(N)} ${F(y)} ${F(B)} ${F(t)} ${F(g)} ${F(v)}`)}return M.push("Z"),M.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 C6($,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=N6().mul(H),z=Q.plus(H),j=q,G=z,F=j.minus(W),_=Q.plus(W),U=q.minus(H),Y=Q,V=q.minus(H),M=Q.minus(W),X=V,k=Q.minus(H),w=q.minus(W),R=Q.minus(H),I=q,P=R,h=q.plus(W),u=Q.minus(W),b=q.plus(H),g=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(Y)} ${N(V)}C${N(M)} ${N(X)} ${N(k)} ${N(w)} ${N(R)} ${N(I)}C${N(P)} ${N(h)} ${N(u)} ${N(b)} ${N(g)} ${N(v)}C${N(E)} ${N(m)} ${N(c)} ${N(d)} ${N(z)} ${N(j)}Z`}function P6($,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=N6(),G=j.mul(W),F=j.mul(z),_=q.plus(W),U=H,Y=_,V=U.minus(F),M=q.plus(G),X=H.minus(z),k=q,w=H.minus(z),R=q.minus(G),I=w,P=q.minus(W),h=H.minus(F),u=q.minus(W),b=H,g=u,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(Y)} ${i(V)} ${i(M)} ${i(X)} ${i(k)} ${i(w)}C${i(R)} ${i(I)} ${i(P)} ${i(h)} ${i(u)} ${i(b)}C${i(g)} ${i(v)} ${i(E)} ${i(m)} ${i(c)} ${i(d)}C${i(N)} ${i(y)} ${i(B)} ${i(t)} ${i(_)} ${i(U)}Z`}function A6($,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 Y=G.div(2),V=F.div(2);if(_.gt(Y))_=Y;if(U.gt(V))U=V;let M=(E)=>F$(E,W);if(_.isZero()||U.isZero()){let E=z.plus(G),m=j.plus(F);return`M${M(z)} ${M(j)}H${M(E)}V${M(m)}H${M(z)}Z`}let X=z,k=z.plus(G),w=j,R=j.plus(F),I=X.plus(_),P=k.minus(_),h=w.plus(U),u=R.minus(U);if(H)return`M${M(I)} ${M(w)}L${M(P)} ${M(w)}A${M(_)} ${M(U)} 0 0 1 ${M(k)} ${M(h)}L${M(k)} ${M(u)}A${M(_)} ${M(U)} 0 0 1 ${M(P)} ${M(R)}L${M(I)} ${M(R)}A${M(_)} ${M(U)} 0 0 1 ${M(X)} ${M(u)}L${M(X)} ${M(h)}A${M(_)} ${M(U)} 0 0 1 ${M(I)} ${M(w)}Z`;let b=N6(),g=b.mul(_),v=b.mul(U);return`M${M(I)} ${M(w)}L${M(P)} ${M(w)}C${M(P.plus(g))} ${M(w)} ${M(k)} ${M(h.minus(v))} ${M(k)} ${M(h)}L${M(k)} ${M(u)}C${M(k)} ${M(u.plus(v))} ${M(P.plus(g))} ${M(R)} ${M(P)} ${M(R)}L${M(I)} ${M(R)}C${M(I.minus(g))} ${M(R)} ${M(X)} ${M(u.plus(v))} ${M(X)} ${M(u)}L${M(X)} ${M(h)}C${M(X)} ${M(h.minus(v))} ${M(I.minus(g))} ${M(w)} ${M(I)} ${M(w)}Z`}function E6($,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 kq($){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 d$($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polylineToPathData: precision must be non-negative");let Z=kq($);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 T6($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polygonToPathData: precision must be non-negative");let Z=d$($,J);return Z?Z+" Z":""}var wq={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=wq[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 p$($){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 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]}),j="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]}),j="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]}),j="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]}),j="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],M=_?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=M,z=X,K=k,Q=w,Z.push({command:"C",args:[Y,V,M,X,k,w]}),j="C"}else if(U==="S"){if(F.length<4)continue;let Y,V;if(j==="C"||j==="S")Y=K.mul(2).minus(W),V=Q.mul(2).minus(z);else Y=K,V=Q;let M=_?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=M,z=X,K=k,Q=w,Z.push({command:"C",args:[Y,V,M,X,k,w]}),j="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],M=_?K.plus(F[2]):F[2],X=_?Q.plus(F[3]):F[3];W=Y,z=V,K=M,Q=X,Z.push({command:"Q",args:[Y,V,M,X]}),j="Q"}else if(U==="T"){if(F.length<2)continue;let Y,V;if(j==="Q"||j==="T")Y=K.mul(2).minus(W),V=Q.mul(2).minus(z);else Y=K,V=Q;let M=_?K.plus(F[0]):F[0],X=_?Q.plus(F[1]):F[1];W=Y,z=V,K=M,Q=X,Z.push({command:"Q",args:[Y,V,M,X]}),j="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]}),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 C8($,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=z0.from([[F],[_],[new O(1)]]),Y=W.mul(U),V=Y.data[2][0];if(V.isZero())throw new Error("transformArcParams: division by zero in homogeneous coordinate transformation");let M=Y.data[0][0].div(V),X=Y.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],h=k.mul(I).minus(w.mul(R)).isNegative()?Q===1?0:1:Q,u=G.mul(new O(Math.PI)).div(180),b=O.cos(u),g=O.sin(u),v=z.mul(b),E=z.mul(g),m=j.mul(g).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,h,M,X]}function Lq($,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=p$($),Q=J$(K),q=[];for(let{command:H,args:W}of Q)if(H==="M"||H==="L"){if(W.length<2)continue;let z=z0.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=z0.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,Y]=C8(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,Y]})}else q.push({command:H,args:W});return I$(q,Z)}function N8($,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 Rq($){if($==null)throw new Error("pathToCubics: pathData parameter is required");let J=p$($),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,Y,V,M]=G;K.push({command:"C",args:[F,_,U,Y,V,M]}),H=U,W=Y,Q=V,q=M,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,Y,V,M]=G;K.push({command:"C",args:[F,_,U,Y,V,M]}),H=U,W=Y,Q=V,q=M,z="S"}else if(j==="Q"){if(G.length<4)continue;let[F,_,U,Y]=G,V=N8(Q,q,F,_,U,Y);K.push({command:"C",args:V}),H=F,W=_,Q=U,q=Y,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,Y]=G,V=N8(Q,q,F,_,U,Y);K.push({command:"C",args:V}),H=F,W=_,Q=U,q=Y,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 X9($,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 Bq(H!==void 0&&H!==null?H:q)},K=($.tagName||$.type||"").toLowerCase();if(K==="circle")return C6(Z("cx",0),Z("cy",0),Z("r",0),J);else if(K==="ellipse")return P6(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(K==="rect")return A6(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 E6(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(K==="polyline")return d$(Z("points",""),J);else if(K==="polygon")return T6(Z("points",""),J);return null}function Bq($){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 P8($,J,Z){return k9($,J,Z,Z)}function k9($,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,Y=q,V=H.minus(z),M=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)} ${Y.plus(G).toFixed(6)} ${V.toFixed(6)} ${Y.toFixed(6)} ${V.toFixed(6)}`,`C ${Y.minus(G).toFixed(6)} ${V.toFixed(6)} ${M.toFixed(6)} ${X.minus(F).toFixed(6)} ${M.toFixed(6)} ${X.toFixed(6)}`,`C ${M.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 A8($,J,Z,K,Q=0,q=null){let H=(M)=>new O(M),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),Y=G.div(2);if(F.gt(U))F=U;if(_.gt(Y))_=Y;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 E8($,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 T8($){let J=f8($);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 b8($){let J=f8($);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 f8($){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 Nq($,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 Y=W.data[0][0],V=W.data[1][0],M=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=Y.mul(R).plus(M.mul(I)).plus(k),h=V.mul(R).plus(X.mul(I)).plus(w),u=z(Z).mul(z(Math.PI)).div(180),b=O.sin(u),g=O.cos(u),v=Y.mul(G).mul(g).plus(M.mul(G).mul(b)),E=V.mul(G).mul(g).plus(X.mul(G).mul(b)),m=Y.mul(F.neg()).mul(b).plus(M.mul(F).mul(g)),c=V.mul(F.neg()).mul(b).plus(X.mul(F).mul(g)),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=Y.mul(X).minus(V.mul(M)),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:h.toNumber()}}function Iq($,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 O(K);switch($.toLowerCase()){case"translate":{let K=J[0]!==void 0?J[0]:0,Q=J[1]!==void 0?J[1]:0;return l0(K,Q)}case"scale":{let K=J[0]!==void 0?J[0]:1,Q=J[1]!==void 0?J[1]:K;return U7(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 _9(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 X6(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 X6(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,W,z]=J.slice(0,6).map((j)=>Z(j!==void 0?j:0));return z0.from([[K,q,W],[Q,H,z],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),z0.identity(3)}}function K7($){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((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=Iq(Q,H);K=K.mul(W)}return K}function L7($,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 S8($,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=Cq($);if(W.length===0)return"";let z=[],j=H(0),G=H(0),F=H(0),_=H(0);for(let{cmd:U,args:Y}of W){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(j),R=R.plus(G);let I=L7(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(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(j),R=R.plus(G);let I=L7(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(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(j);let R=L7(J,k,G);z.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),j=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=j,w=H(Y[X]);if(V)w=w.plus(G);let R=L7(J,k,w);z.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]),P=H(Y[k+3]),h=H(Y[k+4]),u=H(Y[k+5]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G),h=h.plus(j),u=u.plus(G);let b=L7(J,w,R),g=L7(J,I,P),v=L7(J,h,u);X.push(b.x.toFixed(q),b.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q),v.x.toFixed(q),v.y.toFixed(q)),j=h,G=u}z.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]),P=H(Y[k+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G);let h=L7(J,w,R),u=L7(J,I,P);X.push(h.x.toFixed(q),h.y.toFixed(q),u.x.toFixed(q),u.y.toFixed(q)),j=I,G=P}z.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]),P=H(Y[k+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G);let h=L7(J,w,R),u=L7(J,I,P);X.push(h.x.toFixed(q),h.y.toFixed(q),u.x.toFixed(q),u.y.toFixed(q)),j=I,G=P}z.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(j),R=R.plus(G);let I=L7(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(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],P=Y[k+3],h=Y[k+4],u=H(Y[k+5]),b=H(Y[k+6]);if(V)u=u.plus(j),b=b.plus(G);let g=Nq(w,R,I,P,h,u.toNumber(),b.toNumber(),J);X.push(g.rx.toFixed(q),g.ry.toFixed(q),g.xAxisRotation.toFixed(q),g.largeArcFlag,g.sweepFlag,g.x.toFixed(q),g.y.toFixed(q)),j=u,G=b}z.push((K?"A":U)+" "+X.join(" "));break}case"Z":{z.push("Z"),j=F,G=_;break}default:z.push(U+" "+Y.join(" "))}}return z.join(" ")}function Cq($){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 v7={};x7(v7,{sign:()=>w9,segmentIntersection:()=>f6,reversePolygon:()=>N9,polygonUnion:()=>_$,polygonIntersection:()=>S7,polygonDifference:()=>x8,polygonArea:()=>n$,pointsEqual:()=>d7,pointOnSegment:()=>L9,pointInPolygon:()=>C7,point:()=>b0,lineSegmentIntersection:()=>u8,isCounterClockwise:()=>B9,isConvex:()=>C9,ensureCCW:()=>S6,dot:()=>y8,default:()=>bq,cross:()=>p7,convexHull:()=>I9,clipPolygonSH:()=>R9,boundingBox:()=>c7,bboxIntersects:()=>l$});O.set({precision:80});var R7=($)=>$ instanceof O?$:new O($),M7=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:R7($),y:R7(J)}}function d7($,J,Z=M7){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 y8($,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 w9($){if($===null||$===void 0||typeof $.abs!=="function")throw new Error("sign: val must be a Decimal instance");if($.abs().lt(M7))return 0;return $.lt(0)?-1:1}function f6($,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(M7))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=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 u8($,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(M7))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 C7($,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(L9($,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 L9($,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(M7))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(M7))&&$.x.lte(q.plus(M7))&&$.y.gte(H.minus(M7))&&$.y.lte(W.plus(M7))}function R9($,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=S6(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=D8(j,q,H),_=D8(G,q,H);if(F){if(!_){let U=h8(G,j,q,H);if(U)Z.push(U)}Z.push(j)}else if(_){let U=h8(G,j,q,H);if(U)Z.push(U)}}}return Z}function D8($,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 h8($,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(M7))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 n$($){if(!Array.isArray($))throw new 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 new 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 B9($){if(!Array.isArray($))throw new Error("isCounterClockwise: polygon must be an array");return n$($).gt(0)}function N9($){if(!Array.isArray($))throw new Error("reversePolygon: polygon must be an array");return[...$].reverse()}function S6($){if(!Array.isArray($))throw new Error("ensureCCW: polygon must be an array");if(!B9($))return N9($);return $}function I9($){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(M7)){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(M7))return 0;return _.lt(0)?-1:1}return-w9(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=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 new Error(`boundingBox: polygon[${q}] must have x and y properties`);let W=R7(H.x),z=R7(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 l$($,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 S7($,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(!l$(Q,q))return[];if(C9(K)){let H=R9(Z,S6(K));return H.length>=3?[H]:[]}return Pq(Z,K)}function C9($){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 Pq($,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],Y=f6(j,G,_,U);if(Y)Z.push(b0(Y.x,Y.y))}}let K=$.filter((z)=>C7(z,J)>=0),Q=J.filter((z)=>C7(z,$)>=0),q=[...Z,...K,...Q];if(q.length<3)return[];let H=Aq(q);if(H.length<3)return[];let W=I9(H);return W.length>=3?[W]:[]}function Aq($){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(!l$(Q,q))return[Z,K];return Eq(Z,K)}function Eq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryUnion: both arguments must be arrays");let Z=g8($,J);if(Z.length===0){let V=C7($[0],J),M=C7(J[0],$);if(V>0)return[J];else if(M>0)return[$];else return[$,J]}let K=b6($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),Q=b6(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 M=K[V];if(M.intersectionId===void 0&&C7(M,J)<0){W=V;break}}if(W===-1){H=2;for(let V=0;V<Q.length;V++){let M=Q[V];if(M.intersectionId===void 0&&C7(M,$)<0){W=V;break}}}if(W===-1){let V=n$($).abs(),M=n$(J).abs();return V.gt(M)?[$]:[J]}let z=[],j=H===1,G=W,F=new Set,_=(K.length+Q.length)*3,U=0,Y=`${H}-${W}`;while(U<_){U++;let V=j?K:Q,M=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)%M.length}else G=k;if(`${j?1:2}-${G}`===Y)break}if(z.length>1&&d7(z[0],z[z.length-1]))z.pop();return z.length>=3?[z]:[]}function g8($,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=f6(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 b6($,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 x8($,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(!l$(Q,q))return[Z];return Tq(Z,K)}function Tq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryDifference: both arguments must be arrays");let Z=g8($,J);if(Z.length===0)if(C7($[0],J)>0)return[];else return[$];let K=b6($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),Q=b6(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 W=[],z=!0,j=H,G=new Set,F=(K.length+Q.length)*3,_=0;while(_<F){_++;let Y=(z?K:Q)[j];if(W.length===0||!d7(W[W.length-1],Y))W.push(b0(Y.x,Y.y));let V=`${z?1:2}-${j}`;if(G.has(V))break;if(G.add(V),z){let M=(j+1)%K.length,X=K[M];if(X.intersectionId!==void 0){let k=K[(M+1)%K.length];if(C7(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=M}else j=M}else{let M=(j-1+Q.length)%Q.length,X=Q[M];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=M}if(z&&j===H)break}if(W.length>1&&d7(W[0],W[W.length-1]))W.pop();return W.length>=3?[W]:[]}var bq={point:b0,pointsEqual:d7,cross:p7,dot:y8,sign:w9,segmentIntersection:f6,lineSegmentIntersection:u8,pointInPolygon:C7,pointOnSegment:L9,clipPolygonSH:R9,polygonArea:n$,isCounterClockwise:B9,reversePolygon:N9,ensureCCW:S6,isConvex:C9,convexHull:I9,boundingBox:c7,bboxIntersects:l$,polygonIntersection:S7,polygonUnion:_$,polygonDifference:x8,EPSILON:M7};O.set({precision:80});var v6=($)=>$ instanceof O?$:new O($),n7=new O("1e-40"),{point:Z$,cross:P9,polygonIntersection:j4,polygonUnion:G4,polygonDifference:F4}=v7,K$={NONZERO:"nonzero",EVENODD:"evenodd"};function D6($,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(fq($,H,W))return 0;if(H.y.lte($.y)){if(W.y.gt($.y)){if(P9(H,W,$).gt(0))Q++}}else if(W.y.lte($.y)){if(P9(H,W,$).lt(0))Q--}}if(Z===K$.EVENODD)return Math.abs(Q)%2===1?1:-1;else return Q!==0?1:-1}function fq($,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(P9(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 Sq($,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=v6(J);if(K.lte(0))throw new Error("offsetPolygon: distance must be positive");let Q=Z.linejoin||"miter",q=v6(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),Y=F.y.minus(G.y),V=_.x.minus(F.x),M=_.y.minus(F.y),X=U.pow(2).plus(Y.pow(2)).sqrt(),k=V.pow(2).plus(M.pow(2)).sqrt();if(X.lt(n7)||k.lt(n7))continue;let w=Y.div(X),R=U.neg().div(X),I=M.div(k),P=V.neg().div(k),h=w.plus(I).div(2),u=R.plus(P).div(2),b=h.pow(2).plus(u.pow(2)).sqrt();if(b.lt(n7))h=w,u=R;else h=h.div(b),u=u.div(b);let g=w.times(I).plus(R.times(P)),v=v6(1).minus(g).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(h.times(E)),F.y.plus(u.times(E)))),z.push(Z$(F.x.minus(h.times(E)),F.y.minus(u.times(E))))}return{outer:W,inner:z.reverse()}}function A9($,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=v6(J.width).div(2);if(Z.lte(0))throw new Error("strokeToFilledPolygon: width must be positive");return Sq($,Z,J).outer}O.set({precision:80});var D7=($)=>$ instanceof O?$:new O($),vq={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 h6{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={...vq,...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=A9($,{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(D6($,J,Z)>=0)return!0}if(this.hasStroke){let Z=A9(J,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0){if(D6($,Z,K$.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof h6))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 s$($,J={},Z=null){if(!$)throw new Error("createRenderingContext: element parameter is required");return new h6($,J,Z)}function o$($){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 E9={};x7(E9,{serializeSVG:()=>Q7,parseUrlReference:()=>y7,parseSVG:()=>u0,findElementsWithAttribute:()=>P7,default:()=>yq,buildDefsMap:()=>h7,SVGElement:()=>w0});function c8($,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)c8(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=l8(J,0);if(!Z.element)throw new Error("Failed to parse SVG: no root element found");let K=new n8(Z.element);return c8(Z.element,K),Z.element}class n8{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=m8($),K=(Q)=>{for(let q of Q.children)if(q instanceof w0){if(d8(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=m8($);return d8(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}="${Dq(G)}"`).join(" "),q=Q?" "+Q:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${q}/>`;let H=J?"":`
|
|
10
|
-
`,W=this.children.map((
|
|
9
|
+
*/var N$=9000000000000000,Z$=1e9,z9="0123456789abcdef",V6="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",O6="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",j9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-N$,maxE:N$,crypto:!1},H8,p7,A0=!0,M6="[DecimalError] ",J$=M6+"Invalid argument: ",W8=M6+"Precision limit exceeded",z8=M6+"crypto unavailable",j8="[object Decimal]",$7=Math.floor,l0=Math.pow,nQ=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,lQ=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,sQ=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,G8=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,I7=1e7,R0=7,oQ=9007199254740991,iQ=V6.length-1,G9=O6.length-1,Q0={toStringTag:j8};Q0.absoluteValue=Q0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return M0($)};Q0.ceil=function(){return M0(new this.constructor(this),this.e+1,2)};Q0.clampedTo=Q0.clamp=function($,J){var Z,Q=this,K=Q.constructor;if($=new K($),J=new K(J),!$.s||!J.s)return new K(NaN);if($.gt(J))throw Error(J$+J);return Z=Q.cmp($),Z<0?$:Q.cmp(J)>0?J:new K(Q)};Q0.comparedTo=Q0.cmp=function($){var J,Z,Q,K,q=this,H=q.d,W=($=new q.constructor($)).d,j=q.s,z=$.s;if(!H||!W)return!j||!z?NaN:j!==z?j:H===W?0:!H^j<0?1:-1;if(!H[0]||!W[0])return H[0]?j:W[0]?-z:0;if(j!==z)return j;if(q.e!==$.e)return q.e>$.e^j<0?1:-1;Q=H.length,K=W.length;for(J=0,Z=Q<K?Q:K;J<Z;++J)if(H[J]!==W[J])return H[J]>W[J]^j<0?1:-1;return Q===K?0:Q>K^j<0?1:-1};Q0.cosine=Q0.cos=function(){var $,J,Z=this,Q=Z.constructor;if(!Z.d)return new Q(NaN);if(!Z.d[0])return new Q(1);return $=Q.precision,J=Q.rounding,Q.precision=$+Math.max(Z.e,Z.sd())+R0,Q.rounding=1,Z=rQ(Q,O8(Q,Z)),Q.precision=$,Q.rounding=J,M0(p7==2||p7==3?Z.neg():Z,$,J,!0)};Q0.cubeRoot=Q0.cbrt=function(){var $,J,Z,Q,K,q,H,W,j,z,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(A0=!1,q=G.s*l0(G.s*G,0.3333333333333333),!q||Math.abs(q)==1/0){if(Z=t0(G.d),$=G.e,q=($-Z.length+1)%3)Z+=q==1||q==-2?"0":"00";if(q=l0(Z,0.3333333333333333),$=$7(($+1)/3)-($%3==($<0?-1:2)),q==1/0)Z="5e"+$;else Z=q.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+$;Q=new F(Z),Q.s=G.s}else Q=new F(q.toString());H=($=F.precision)+3;for(;;)if(W=Q,j=W.times(W).times(W),z=j.plus(G),Q=D0(z.plus(G).times(W),z.plus(j),H+2,1),t0(W.d).slice(0,H)===(Z=t0(Q.d)).slice(0,H))if(Z=Z.slice(H-3,H+1),Z=="9999"||!K&&Z=="4999"){if(!K){if(M0(W,$+1,0),W.times(W).times(W).eq(G)){Q=W;break}}H+=4,K=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")M0(Q,$+1,1),J=!Q.times(Q).times(Q).eq(G);break}return A0=!0,M0(Q,$,F.rounding,J)};Q0.decimalPlaces=Q0.dp=function(){var $,J=this.d,Z=NaN;if(J){if($=J.length-1,Z=($-$7(this.e/R0))*R0,$=J[$],$)for(;$%10==0;$/=10)Z--;if(Z<0)Z=0}return Z};Q0.dividedBy=Q0.div=function($){return D0(this,new this.constructor($))};Q0.dividedToIntegerBy=Q0.divToInt=function($){var J=this,Z=J.constructor;return M0(D0(J,new Z($),0,1,1),Z.precision,Z.rounding)};Q0.equals=Q0.eq=function($){return this.cmp($)===0};Q0.floor=function(){return M0(new this.constructor(this),this.e+1,3)};Q0.greaterThan=Q0.gt=function($){return this.cmp($)>0};Q0.greaterThanOrEqualTo=Q0.gte=function($){var J=this.cmp($);return J==1||J===0};Q0.hyperbolicCosine=Q0.cosh=function(){var $,J,Z,Q,K,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,Q=H.rounding,H.precision=Z+Math.max(q.e,q.sd())+4,H.rounding=1,K=q.d.length,K<32)$=Math.ceil(K/3),J=(1/k6(4,$)).toString();else $=16,J="2.3283064365386962890625e-10";q=C$(H,1,q.times(J),new H(1),!0);var j,z=$,G=new H(8);for(;z--;)j=q.times(q),q=W.minus(j.times(G.minus(j.times(G))));return M0(q,H.precision=Z,H.rounding=Q,!0)};Q0.hyperbolicSine=Q0.sinh=function(){var $,J,Z,Q,K=this,q=K.constructor;if(!K.isFinite()||K.isZero())return new q(K);if(J=q.precision,Z=q.rounding,q.precision=J+Math.max(K.e,K.sd())+4,q.rounding=1,Q=K.d.length,Q<3)K=C$(q,2,K,K,!0);else{$=1.4*Math.sqrt(Q),$=$>16?16:$|0,K=K.times(1/k6(5,$)),K=C$(q,2,K,K,!0);var H,W=new q(5),j=new q(16),z=new q(20);for(;$--;)H=K.times(K),K=K.times(W.plus(H.times(j.times(H).plus(z))))}return q.precision=J,q.rounding=Z,M0(K,J,Z,!0)};Q0.hyperbolicTangent=Q0.tanh=function(){var $,J,Z=this,Q=Z.constructor;if(!Z.isFinite())return new Q(Z.s);if(Z.isZero())return new Q(Z);return $=Q.precision,J=Q.rounding,Q.precision=$+7,Q.rounding=1,D0(Z.sinh(),Z.cosh(),Q.precision=$,Q.rounding=J)};Q0.inverseCosine=Q0.acos=function(){var $=this,J=$.constructor,Z=$.abs().cmp(1),Q=J.precision,K=J.rounding;if(Z!==-1)return Z===0?$.isNeg()?b7(J,Q,K):new J(0):new J(NaN);if($.isZero())return b7(J,Q+4,K).times(0.5);return J.precision=Q+6,J.rounding=1,$=new J(1).minus($).div($.plus(1)).sqrt().atan(),J.precision=Q,J.rounding=K,$.times(2)};Q0.inverseHyperbolicCosine=Q0.acosh=function(){var $,J,Z=this,Q=Z.constructor;if(Z.lte(1))return new Q(Z.eq(1)?0:NaN);if(!Z.isFinite())return new Q(Z);return $=Q.precision,J=Q.rounding,Q.precision=$+Math.max(Math.abs(Z.e),Z.sd())+4,Q.rounding=1,A0=!1,Z=Z.times(Z).minus(1).sqrt().plus(Z),A0=!0,Q.precision=$,Q.rounding=J,Z.ln()};Q0.inverseHyperbolicSine=Q0.asinh=function(){var $,J,Z=this,Q=Z.constructor;if(!Z.isFinite()||Z.isZero())return new Q(Z);return $=Q.precision,J=Q.rounding,Q.precision=$+2*Math.max(Math.abs(Z.e),Z.sd())+6,Q.rounding=1,A0=!1,Z=Z.times(Z).plus(1).sqrt().plus(Z),A0=!0,Q.precision=$,Q.rounding=J,Z.ln()};Q0.inverseHyperbolicTangent=Q0.atanh=function(){var $,J,Z,Q,K=this,q=K.constructor;if(!K.isFinite())return new q(NaN);if(K.e>=0)return new q(K.abs().eq(1)?K.s/0:K.isZero()?K:NaN);if($=q.precision,J=q.rounding,Q=K.sd(),Math.max(Q,$)<2*-K.e-1)return M0(new q(K),$,J,!0);return q.precision=Z=Q-K.e,K=D0(K.plus(1),new q(1).minus(K),Z+$,1),q.precision=$+4,q.rounding=1,K=K.ln(),q.precision=$,q.rounding=J,K.times(0.5)};Q0.inverseSine=Q0.asin=function(){var $,J,Z,Q,K=this,q=K.constructor;if(K.isZero())return new q(K);if(J=K.abs().cmp(1),Z=q.precision,Q=q.rounding,J!==-1){if(J===0)return $=b7(q,Z+4,Q).times(0.5),$.s=K.s,$;return new q(NaN)}return q.precision=Z+6,q.rounding=1,K=K.div(new q(1).minus(K.times(K)).sqrt().plus(1)).atan(),q.precision=Z,q.rounding=Q,K.times(2)};Q0.inverseTangent=Q0.atan=function(){var $,J,Z,Q,K,q,H,W,j,z=this,G=z.constructor,F=G.precision,_=G.rounding;if(!z.isFinite()){if(!z.s)return new G(NaN);if(F+4<=G9)return H=b7(G,F+4,_).times(0.5),H.s=z.s,H}else if(z.isZero())return new G(z);else if(z.abs().eq(1)&&F+4<=G9)return H=b7(G,F+4,_).times(0.25),H.s=z.s,H;G.precision=W=F+10,G.rounding=1,Z=Math.min(28,W/R0+2|0);for($=Z;$;--$)z=z.div(z.times(z).plus(1).sqrt().plus(1));A0=!1,J=Math.ceil(W/R0),Q=1,j=z.times(z),H=new G(z),K=z;for(;$!==-1;)if(K=K.times(j),q=H.minus(K.div(Q+=2)),K=K.times(j),H=q.plus(K.div(Q+=2)),H.d[J]!==void 0)for($=J;H.d[$]===q.d[$]&&$--;);if(Z)H=H.times(2<<Z-1);return A0=!0,M0(H,G.precision=F,G.rounding=_,!0)};Q0.isFinite=function(){return!!this.d};Q0.isInteger=Q0.isInt=function(){return!!this.d&&$7(this.e/R0)>this.d.length-2};Q0.isNaN=function(){return!this.s};Q0.isNegative=Q0.isNeg=function(){return this.s<0};Q0.isPositive=Q0.isPos=function(){return this.s>0};Q0.isZero=function(){return!!this.d&&this.d[0]===0};Q0.lessThan=Q0.lt=function($){return this.cmp($)<0};Q0.lessThanOrEqualTo=Q0.lte=function($){return this.cmp($)<1};Q0.logarithm=Q0.log=function($){var J,Z,Q,K,q,H,W,j,z=this,G=z.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=z.d,z.s<0||!Z||!Z[0]||z.eq(1))return new G(Z&&!Z[0]?-1/0:z.s!=1?NaN:Z?0:1/0);if(J)if(Z.length>1)q=!0;else{for(K=Z[0];K%10===0;)K/=10;q=K!==1}if(A0=!1,W=F+U,H=$$(z,W),Q=J?Y6(G,W+10):$$($,W),j=D0(H,Q,W,1),x$(j.d,K=F,_))do if(W+=10,H=$$(z,W),Q=J?Y6(G,W+10):$$($,W),j=D0(H,Q,W,1),!q){if(+t0(j.d).slice(K+1,K+15)+1==100000000000000)j=M0(j,F+1,0);break}while(x$(j.d,K+=10,_));return A0=!0,M0(j,F,_)};Q0.minus=Q0.sub=function($){var J,Z,Q,K,q,H,W,j,z,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(z=U.d,_=$.d,W=Y.precision,j=Y.rounding,!z[0]||!_[0]){if(_[0])$.s=-$.s;else if(z[0])$=new Y(U);else return new Y(j===3?-0:0);return A0?M0($,W,j):$}if(Z=$7($.e/R0),G=$7(U.e/R0),z=z.slice(),q=G-Z,q){if(F=q<0,F)J=z,q=-q,H=_.length;else J=_,Z=G,H=z.length;if(Q=Math.max(Math.ceil(W/R0),H)+2,q>Q)q=Q,J.length=1;J.reverse();for(Q=q;Q--;)J.push(0);J.reverse()}else{if(Q=z.length,H=_.length,F=Q<H,F)H=Q;for(Q=0;Q<H;Q++)if(z[Q]!=_[Q]){F=z[Q]<_[Q];break}q=0}if(F)J=z,z=_,_=J,$.s=-$.s;H=z.length;for(Q=_.length-H;Q>0;--Q)z[H++]=0;for(Q=_.length;Q>q;){if(z[--Q]<_[Q]){for(K=Q;K&&z[--K]===0;)z[K]=I7-1;--z[K],z[Q]+=I7}z[Q]-=_[Q]}for(;z[--H]===0;)z.pop();for(;z[0]===0;z.shift())--Z;if(!z[0])return new Y(j===3?-0:0);return $.d=z,$.e=X6(z,Z),A0?M0($,W,j):$};Q0.modulo=Q0.mod=function($){var J,Z=this,Q=Z.constructor;if($=new Q($),!Z.d||!$.s||$.d&&!$.d[0])return new Q(NaN);if(!$.d||Z.d&&!Z.d[0])return M0(new Q(Z),Q.precision,Q.rounding);if(A0=!1,Q.modulo==9)J=D0(Z,$.abs(),0,3,1),J.s*=$.s;else J=D0(Z,$,0,Q.modulo,1);return J=J.times($),A0=!0,Z.minus(J)};Q0.naturalExponential=Q0.exp=function(){return F9(this)};Q0.naturalLogarithm=Q0.ln=function(){return $$(this)};Q0.negated=Q0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,M0($)};Q0.plus=Q0.add=function($){var J,Z,Q,K,q,H,W,j,z,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(z=F.d,G=$.d,W=_.precision,j=_.rounding,!z[0]||!G[0]){if(!G[0])$=new _(F);return A0?M0($,W,j):$}if(q=$7(F.e/R0),Q=$7($.e/R0),z=z.slice(),K=q-Q,K){if(K<0)Z=z,K=-K,H=G.length;else Z=G,Q=q,H=z.length;if(q=Math.ceil(W/R0),H=q>H?q+1:H+1,K>H)K=H,Z.length=1;Z.reverse();for(;K--;)Z.push(0);Z.reverse()}if(H=z.length,K=G.length,H-K<0)K=H,Z=G,G=z,z=Z;for(J=0;K;)J=(z[--K]=z[K]+G[K]+J)/I7|0,z[K]%=I7;if(J)z.unshift(J),++Q;for(H=z.length;z[--H]==0;)z.pop();return $.d=z,$.e=X6(z,Q),A0?M0($,W,j):$};Q0.precision=Q0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(J$+$);if(Z.d){if(J=F8(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};Q0.round=function(){var $=this,J=$.constructor;return M0(new J($),$.e+1,J.rounding)};Q0.sine=Q0.sin=function(){var $,J,Z=this,Q=Z.constructor;if(!Z.isFinite())return new Q(NaN);if(Z.isZero())return new Q(Z);return $=Q.precision,J=Q.rounding,Q.precision=$+Math.max(Z.e,Z.sd())+R0,Q.rounding=1,Z=tQ(Q,O8(Q,Z)),Q.precision=$,Q.rounding=J,M0(p7>2?Z.neg():Z,$,J,!0)};Q0.squareRoot=Q0.sqrt=function(){var $,J,Z,Q,K,q,H=this,W=H.d,j=H.e,z=H.s,G=H.constructor;if(z!==1||!W||!W[0])return new G(!z||z<0&&(!W||W[0])?NaN:W?H:1/0);if(A0=!1,z=Math.sqrt(+H),z==0||z==1/0){if(J=t0(W),(J.length+j)%2==0)J+="0";if(z=Math.sqrt(J),j=$7((j+1)/2)-(j<0||j%2),z==1/0)J="5e"+j;else J=z.toExponential(),J=J.slice(0,J.indexOf("e")+1)+j;Q=new G(J)}else Q=new G(z.toString());Z=(j=G.precision)+3;for(;;)if(q=Q,Q=q.plus(D0(H,q,Z+2,1)).times(0.5),t0(q.d).slice(0,Z)===(J=t0(Q.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!K&&J=="4999"){if(!K){if(M0(q,j+1,0),q.times(q).eq(H)){Q=q;break}}Z+=4,K=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")M0(Q,j+1,1),$=!Q.times(Q).eq(H);break}return A0=!0,M0(Q,j,G.rounding,$)};Q0.tangent=Q0.tan=function(){var $,J,Z=this,Q=Z.constructor;if(!Z.isFinite())return new Q(NaN);if(Z.isZero())return new Q(Z);return $=Q.precision,J=Q.rounding,Q.precision=$+10,Q.rounding=1,Z=Z.sin(),Z.s=1,Z=D0(Z,new Q(1).minus(Z.times(Z)).sqrt(),$+10,0),Q.precision=$,Q.rounding=J,M0(p7==2||p7==4?Z.neg():Z,$,J,!0)};Q0.times=Q0.mul=function($){var J,Z,Q,K,q,H,W,j,z,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=$7(G.e/R0)+$7($.e/R0),j=_.length,z=U.length,j<z)q=_,_=U,U=q,H=j,j=z,z=H;q=[],H=j+z;for(Q=H;Q--;)q.push(0);for(Q=z;--Q>=0;){J=0;for(K=j+Q;K>Q;)W=q[K]+U[Q]*_[K-Q-1]+J,q[K--]=W%I7|0,J=W/I7|0;q[K]=(q[K]+J)%I7|0}for(;!q[--H];)q.pop();if(J)++Z;else q.shift();return $.d=q,$.e=X6(q,Z),A0?M0($,F.precision,F.rounding):$};Q0.toBinary=function($,J){return _9(this,2,$,J)};Q0.toDecimalPlaces=Q0.toDP=function($,J){var Z=this,Q=Z.constructor;if(Z=new Q(Z),$===void 0)return Z;if(W7($,0,Z$),J===void 0)J=Q.rounding;else W7(J,0,8);return M0(Z,$+Z.e+1,J)};Q0.toExponential=function($,J){var Z,Q=this,K=Q.constructor;if($===void 0)Z=f7(Q,!0);else{if(W7($,0,Z$),J===void 0)J=K.rounding;else W7(J,0,8);Q=M0(new K(Q),$+1,J),Z=f7(Q,!0,$+1)}return Q.isNeg()&&!Q.isZero()?"-"+Z:Z};Q0.toFixed=function($,J){var Z,Q,K=this,q=K.constructor;if($===void 0)Z=f7(K);else{if(W7($,0,Z$),J===void 0)J=q.rounding;else W7(J,0,8);Q=M0(new q(K),$+K.e+1,J),Z=f7(Q,!1,$+Q.e+1)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};Q0.toFraction=function($){var J,Z,Q,K,q,H,W,j,z,G,F,_,U=this,Y=U.d,V=U.constructor;if(!Y)return new V(U);if(z=Z=new V(1),Q=j=new V(0),J=new V(Q),q=J.e=F8(Y)-U.e-1,H=q%R0,J.d[0]=l0(10,H<0?R0+H:H),$==null)$=q>0?J:z;else{if(W=new V($),!W.isInt()||W.lt(z))throw Error(J$+W);$=W.gt(J)?q>0?J:z:W}A0=!1,W=new V(t0(Y)),G=V.precision,V.precision=q=Y.length*R0*2;for(;;){if(F=D0(W,J,0,1,1),K=Z.plus(F.times(Q)),K.cmp($)==1)break;Z=Q,Q=K,K=z,z=j.plus(F.times(K)),j=K,K=J,J=W.minus(F.times(K)),W=K}return K=D0($.minus(Z),Q,0,1,1),j=j.plus(K.times(z)),Z=Z.plus(K.times(Q)),j.s=z.s=U.s,_=D0(z,Q,q,1).minus(U).abs().cmp(D0(j,Z,q,1).minus(U).abs())<1?[z,Q]:[j,Z],V.precision=G,A0=!0,_};Q0.toHexadecimal=Q0.toHex=function($,J){return _9(this,16,$,J)};Q0.toNearest=function($,J){var Z=this,Q=Z.constructor;if(Z=new Q(Z),$==null){if(!Z.d)return Z;$=new Q(1),J=Q.rounding}else{if($=new Q($),J===void 0)J=Q.rounding;else W7(J,0,8);if(!Z.d)return $.s?Z:$;if(!$.d){if($.s)$.s=Z.s;return $}}if($.d[0])A0=!1,Z=D0(Z,$,0,J,1).times($),A0=!0,M0(Z);else $.s=Z.s,Z=$;return Z};Q0.toNumber=function(){return+this};Q0.toOctal=function($,J){return _9(this,8,$,J)};Q0.toPower=Q0.pow=function($){var J,Z,Q,K,q,H,W=this,j=W.constructor,z=+($=new j($));if(!W.d||!$.d||!W.d[0]||!$.d[0])return new j(l0(+W,z));if(W=new j(W),W.eq(1))return W;if(Q=j.precision,q=j.rounding,$.eq(1))return M0(W,Q,q);if(J=$7($.e/R0),J>=$.d.length-1&&(Z=z<0?-z:z)<=oQ)return K=_8(j,W,Z,Q),$.s<0?new j(1).div(K):M0(K,Q,q);if(H=W.s,H<0){if(J<$.d.length-1)return new j(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=l0(+W,z),J=Z==0||!isFinite(Z)?$7(z*(Math.log("0."+t0(W.d))/Math.LN10+W.e+1)):new j(Z+"").e,J>j.maxE+1||J<j.minE-1)return new j(J>0?H/0:0);if(A0=!1,j.rounding=W.s=1,Z=Math.min(12,(J+"").length),K=F9($.times($$(W,Q+Z)),Q),K.d){if(K=M0(K,Q+5,1),x$(K.d,Q,q)){if(J=Q+10,K=M0(F9($.times($$(W,J+Z)),J),J+5,1),+t0(K.d).slice(Q+1,Q+15)+1==100000000000000)K=M0(K,Q+1,0)}}return K.s=H,A0=!0,j.rounding=q,M0(K,Q,q)};Q0.toPrecision=function($,J){var Z,Q=this,K=Q.constructor;if($===void 0)Z=f7(Q,Q.e<=K.toExpNeg||Q.e>=K.toExpPos);else{if(W7($,1,Z$),J===void 0)J=K.rounding;else W7(J,0,8);Q=M0(new K(Q),$,J),Z=f7(Q,$<=Q.e||Q.e<=K.toExpNeg,$)}return Q.isNeg()&&!Q.isZero()?"-"+Z:Z};Q0.toSignificantDigits=Q0.toSD=function($,J){var Z=this,Q=Z.constructor;if($===void 0)$=Q.precision,J=Q.rounding;else if(W7($,1,Z$),J===void 0)J=Q.rounding;else W7(J,0,8);return M0(new Q(Z),$,J)};Q0.toString=function(){var $=this,J=$.constructor,Z=f7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()&&!$.isZero()?"-"+Z:Z};Q0.truncated=Q0.trunc=function(){return M0(new this.constructor(this),this.e+1,1)};Q0.valueOf=Q0.toJSON=function(){var $=this,J=$.constructor,Z=f7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()?"-"+Z:Z};function t0($){var J,Z,Q,K=$.length-1,q="",H=$[0];if(K>0){q+=H;for(J=1;J<K;J++){if(Q=$[J]+"",Z=R0-Q.length,Z)q+=e7(Z);q+=Q}if(H=$[J],Q=H+"",Z=R0-Q.length,Z)q+=e7(Z)}else if(H===0)return"0";for(;H%10===0;)H/=10;return q+H}function W7($,J,Z){if($!==~~$||$<J||$>Z)throw Error(J$+$)}function x$($,J,Z,Q){var K,q,H,W;for(q=$[0];q>=10;q/=10)--J;if(--J<0)J+=R0,K=0;else K=Math.ceil((J+1)/R0),J%=R0;if(q=l0(10,R0-J),W=$[K]%q|0,Q==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)&&($[K+1]/q/100|0)==l0(10,J-2)-1||(W==q/2||W==0)&&($[K+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=(Q||Z<4)&&W==9999||!Q&&Z>3&&W==4999}else H=((Q||Z<4)&&W+1==q||!Q&&Z>3&&W+1==q/2)&&($[K+1]/q/1000|0)==l0(10,J-3)-1;return H}function _6($,J,Z){var Q,K=[0],q,H=0,W=$.length;for(;H<W;){for(q=K.length;q--;)K[q]*=J;K[0]+=z9.indexOf($.charAt(H++));for(Q=0;Q<K.length;Q++)if(K[Q]>Z-1){if(K[Q+1]===void 0)K[Q+1]=0;K[Q+1]+=K[Q]/Z|0,K[Q]%=Z}}return K.reverse()}function rQ($,J){var Z,Q,K;if(J.isZero())return J;if(Q=J.d.length,Q<32)Z=Math.ceil(Q/3),K=(1/k6(4,Z)).toString();else Z=16,K="2.3283064365386962890625e-10";$.precision+=Z,J=C$($,1,J.times(K),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 D0=function(){function $(Q,K,q){var H,W=0,j=Q.length;for(Q=Q.slice();j--;)H=Q[j]*K+W,Q[j]=H%q|0,W=H/q|0;if(W)Q.unshift(W);return Q}function J(Q,K,q,H){var W,j;if(q!=H)j=q>H?1:-1;else for(W=j=0;W<q;W++)if(Q[W]!=K[W]){j=Q[W]>K[W]?1:-1;break}return j}function Z(Q,K,q,H){var W=0;for(;q--;)Q[q]-=W,W=Q[q]<K[q]?1:0,Q[q]=W*H+Q[q]-K[q];for(;!Q[0]&&Q.length>1;)Q.shift()}return function(Q,K,q,H,W,j){var z,G,F,_,U,Y,V,M,X,k,L,R,B,I,h,g,f,x,D,T,d=Q.constructor,c=Q.s==K.s?1:-1,p=Q.d,C=K.d;if(!p||!p[0]||!C||!C[0])return new d(!Q.s||!K.s||(p?C&&p[0]==C[0]:!C)?NaN:p&&p[0]==0||!C?c*0:c/0);if(j)U=1,G=Q.e-K.e;else j=I7,U=R0,G=$7(Q.e/U)-$7(K.e/U);D=C.length,f=p.length,X=new d(c),k=X.d=[];for(F=0;C[F]==(p[F]||0);F++);if(C[F]>(p[F]||0))G--;if(q==null)I=q=d.precision,H=d.rounding;else if(W)I=q+(Q.e-K.e)+1;else I=q;if(I<0)k.push(1),Y=!0;else{if(I=I/U+2|0,F=0,D==1){_=0,C=C[0],I++;for(;(F<f||_)&&I--;F++)h=_*j+(p[F]||0),k[F]=h/C|0,_=h%C|0;Y=_||F<f}else{if(_=j/(C[0]+1)|0,_>1)C=$(C,_,j),p=$(p,_,j),D=C.length,f=p.length;g=D,L=p.slice(0,D),R=L.length;for(;R<D;)L[R++]=0;if(T=C.slice(),T.unshift(0),x=C[0],C[1]>=j/2)++x;do{if(_=0,z=J(C,L,D,R),z<0){if(B=L[0],D!=R)B=B*j+(L[1]||0);if(_=B/x|0,_>1){if(_>=j)_=j-1;if(V=$(C,_,j),M=V.length,R=L.length,z=J(V,L,M,R),z==1)_--,Z(V,D<M?T:C,M,j)}else{if(_==0)z=_=1;V=C.slice()}if(M=V.length,M<R)V.unshift(0);if(Z(L,V,R,j),z==-1){if(R=L.length,z=J(C,L,D,R),z<1)_++,Z(L,D<R?T:C,R,j)}R=L.length}else if(z===0)_++,L=[0];if(k[F++]=_,z&&L[0])L[R++]=p[g]||0;else L=[p[g]],R=1}while((g++<f||L[0]!==void 0)&&I--);Y=L[0]!==void 0}if(!k[0])k.shift()}if(U==1)X.e=G,H8=Y;else{for(F=1,_=k[0];_>=10;_/=10)F++;X.e=F+G*U-1,M0(X,W?q+X.e+1:q,H,Y)}return X}}();function M0($,J,Z,Q){var K,q,H,W,j,z,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(K=1,W=F[0];W>=10;W/=10)K++;if(q=J-K,q<0)q+=R0,H=J,G=F[_=0],j=G/l0(10,K-H-1)%10|0;else if(_=Math.ceil((q+1)/R0),W=F.length,_>=W)if(Q){for(;W++<=_;)F.push(0);G=j=0,K=1,q%=R0,H=q-R0+1}else break $;else{G=W=F[_];for(K=1;W>=10;W/=10)K++;q%=R0,H=q-R0+K,j=H<0?0:G/l0(10,K-H-1)%10|0}if(Q=Q||J<0||F[_+1]!==void 0||(H<0?G:G%l0(10,K-H-1)),z=Z<4?(j||Q)&&(Z==0||Z==($.s<0?3:2)):j>5||j==5&&(Z==4||Q||Z==6&&(q>0?H>0?G/l0(10,K-H):0:F[_-1])%10&1||Z==($.s<0?8:7)),J<1||!F[0]){if(F.length=0,z)J-=$.e+1,F[0]=l0(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=l0(10,R0-q),F[_]=H>0?(G/l0(10,K-H)%l0(10,H)|0)*W:0;if(z)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]==I7)F[0]=1}break}else{if(F[_]+=W,F[_]!=I7)break;F[_--]=0,W=1}for(q=F.length;F[--q]===0;)F.pop()}if(A0){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 V8($);var Q,K=$.e,q=t0($.d),H=q.length;if(J){if(Z&&(Q=Z-H)>0)q=q.charAt(0)+"."+q.slice(1)+e7(Q);else if(H>1)q=q.charAt(0)+"."+q.slice(1);q=q+($.e<0?"e":"e+")+$.e}else if(K<0){if(q="0."+e7(-K-1)+q,Z&&(Q=Z-H)>0)q+=e7(Q)}else if(K>=H){if(q+=e7(K+1-H),Z&&(Q=Z-K-1)>0)q=q+"."+e7(Q)}else{if((Q=K+1)<H)q=q.slice(0,Q)+"."+q.slice(Q);if(Z&&(Q=Z-H)>0){if(K+1===H)q+=".";q+=e7(Q)}}return q}function X6($,J){var Z=$[0];for(J*=R0;Z>=10;Z/=10)J++;return J}function Y6($,J,Z){if(J>iQ){if(A0=!0,Z)$.precision=Z;throw Error(W8)}return M0(new $(V6),J,1,!0)}function b7($,J,Z){if(J>G9)throw Error(W8);return M0(new $(O6),J,Z,!0)}function F8($){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 e7($){var J="";for(;$--;)J+="0";return J}function _8($,J,Z,Q){var K,q=new $(1),H=Math.ceil(Q/R0+4);A0=!1;for(;;){if(Z%2){if(q=q.times(J),K8(q.d,H))K=!0}if(Z=$7(Z/2),Z===0){if(Z=q.d.length-1,K&&q.d[Z]===0)++q.d[Z];break}J=J.times(J),K8(J.d,H)}return A0=!0,q}function Q8($){return $.d[$.d.length-1]&1}function U8($,J,Z){var Q,K,q=new $(J[0]),H=0;for(;++H<J.length;){if(K=new $(J[H]),!K.s){q=K;break}if(Q=q.cmp(K),Q===Z||Q===0&&q.s===Z)q=K}return q}function F9($,J){var Z,Q,K,q,H,W,j,z=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)A0=!1,j=Y;else j=J;W=new _(0.03125);while($.e>-2)$=$.times(W),F+=5;Q=Math.log(l0(2,F))/Math.LN10*2+5|0,j+=Q,Z=q=H=new _(1),_.precision=j;for(;;){if(q=M0(q.times($),j,1),Z=Z.times(++G),W=H.plus(D0(q,Z,j,1)),t0(W.d).slice(0,j)===t0(H.d).slice(0,j)){K=F;while(K--)H=M0(H.times(H),j,1);if(J==null)if(z<3&&x$(H.d,j-Q,U,z))_.precision=j+=10,Z=q=W=new _(1),G=0,z++;else return M0(H,_.precision=Y,U,A0=!0);else return _.precision=Y,H}H=W}}function $$($,J){var Z,Q,K,q,H,W,j,z,G,F,_,U=1,Y=10,V=$,M=V.d,X=V.constructor,k=X.rounding,L=X.precision;if(V.s<0||!M||!M[0]||!V.e&&M[0]==1&&M.length==1)return new X(M&&!M[0]?-1/0:V.s!=1?NaN:M?0:V);if(J==null)A0=!1,G=L;else G=J;if(X.precision=G+=Y,Z=t0(M),Q=Z.charAt(0),Math.abs(q=V.e)<1500000000000000){while(Q<7&&Q!=1||Q==1&&Z.charAt(1)>3)V=V.times($),Z=t0(V.d),Q=Z.charAt(0),U++;if(q=V.e,Q>1)V=new X("0."+Z),q++;else V=new X(Q+"."+Z.slice(1))}else return z=Y6(X,G+2,L).times(q+""),V=$$(new X(Q+"."+Z.slice(1)),G-Y).plus(z),X.precision=L,J==null?M0(V,L,k,A0=!0):V;F=V,j=H=V=D0(V.minus(1),V.plus(1),G,1),_=M0(V.times(V),G,1),K=3;for(;;){if(H=M0(H.times(_),G,1),z=j.plus(D0(H,new X(K),G,1)),t0(z.d).slice(0,G)===t0(j.d).slice(0,G)){if(j=j.times(2),q!==0)j=j.plus(Y6(X,G+2,L).times(q+""));if(j=D0(j,new X(U),G,1),J==null)if(x$(j.d,G-Y,k,W))X.precision=G+=Y,z=H=V=D0(F.minus(1),F.plus(1),G,1),_=M0(V.times(V),G,1),K=W=1;else return M0(j,X.precision=L,k,A0=!0);else return X.precision=L,j}j=z,K+=2}}function V8($){return String($.s*$.s/0)}function U6($,J){var Z,Q,K;if((Z=J.indexOf("."))>-1)J=J.replace(".","");if((Q=J.search(/e/i))>0){if(Z<0)Z=Q;Z+=+J.slice(Q+1),J=J.substring(0,Q)}else if(Z<0)Z=J.length;for(Q=0;J.charCodeAt(Q)===48;Q++);for(K=J.length;J.charCodeAt(K-1)===48;--K);if(J=J.slice(Q,K),J){if(K-=Q,$.e=Z=Z-Q-1,$.d=[],Q=(Z+1)%R0,Z<0)Q+=R0;if(Q<K){if(Q)$.d.push(+J.slice(0,Q));for(K-=R0;Q<K;)$.d.push(+J.slice(Q,Q+=R0));J=J.slice(Q),Q=R0-J.length}else Q-=K;for(;Q--;)J+="0";if($.d.push(+J),A0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function aQ($,J){var Z,Q,K,q,H,W,j,z,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),G8.test(J))return U6($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(lQ.test(J))Z=16,J=J.toLowerCase();else if(nQ.test(J))Z=2;else if(sQ.test(J))Z=8;else throw Error(J$+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,Q=$.constructor,H)J=J.replace(".",""),W=J.length,q=W-q,K=_8(Q,new Q(Z),q,q*2);z=_6(J,Z,I7),G=z.length-1;for(q=G;z[q]===0;--q)z.pop();if(q<0)return new Q($.s*0);if($.e=X6(z,G),$.d=z,A0=!1,H)$=D0($,K,W*4);if(j)$=$.times(Math.abs(j)<54?l0(2,j):m$.pow(2,j));return A0=!0,$}function tQ($,J){var Z,Q=J.d.length;if(Q<3)return J.isZero()?J:C$($,2,J,J);Z=1.4*Math.sqrt(Q),Z=Z>16?16:Z|0,J=J.times(1/k6(5,Z)),J=C$($,2,J,J);var K,q=new $(5),H=new $(16),W=new $(20);for(;Z--;)K=J.times(J),J=J.times(q.plus(K.times(H.times(K).minus(W))));return J}function C$($,J,Z,Q,K){var q,H,W,j,z=1,G=$.precision,F=Math.ceil(G/R0);A0=!1,j=Z.times(Z),W=new $(Q);for(;;){if(H=D0(W.times(j),new $(J++*J++),G,1),W=K?Q.plus(H):Q.minus(H),Q=D0(H.times(j),new $(J++*J++),G,1),H=W.plus(Q),H.d[F]!==void 0){for(q=F;H.d[q]===W.d[q]&&q--;);if(q==-1)break}q=W,W=Q,Q=H,H=q,z++}return A0=!0,H.d.length=F+1,H}function k6($,J){var Z=$;while(--J)Z*=$;return Z}function O8($,J){var Z,Q=J.s<0,K=b7($,$.precision,1),q=K.times(0.5);if(J=J.abs(),J.lte(q))return p7=Q?4:1,J;if(Z=J.divToInt(K),Z.isZero())p7=Q?3:2;else{if(J=J.minus(Z.times(K)),J.lte(q))return p7=Q8(Z)?Q?2:3:Q?4:1,J;p7=Q8(Z)?Q?1:4:Q?3:2}return J.minus(K).abs()}function _9($,J,Z,Q){var K,q,H,W,j,z,G,F,_,U=$.constructor,Y=Z!==void 0;if(Y)if(W7(Z,1,Z$),Q===void 0)Q=U.rounding;else W7(Q,0,8);else Z=U.precision,Q=U.rounding;if(!$.isFinite())G=V8($);else{if(G=f7($),H=G.indexOf("."),Y){if(K=2,J==16)Z=Z*4-3;else if(J==8)Z=Z*3-2}else K=J;if(H>=0)G=G.replace(".",""),_=new U(1),_.e=G.length-H,_.d=_6(f7(_),10,K),_.e=_.d.length;F=_6(G,10,K),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,$=D0($,_,Z,Q,0,K),F=$.d,q=$.e,z=H8;if(H=F[Z],W=K/2,z=z||F[Z+1]!==void 0,z=Q<4?(H!==void 0||z)&&(Q===0||Q===($.s<0?3:2)):H>W||H===W&&(Q===4||z||Q===6&&F[Z-1]&1||Q===($.s<0?8:7)),F.length=Z,z){for(;++F[--Z]>K-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=_6(G,K,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 K8($,J){if($.length>J)return $.length=J,!0}function eQ($){return new this($).abs()}function $K($){return new this($).acos()}function JK($){return new this($).acosh()}function ZK($,J){return new this($).plus(J)}function QK($){return new this($).asin()}function KK($){return new this($).asinh()}function qK($){return new this($).atan()}function HK($){return new this($).atanh()}function WK($,J){$=new this($),J=new this(J);var Z,Q=this.precision,K=this.rounding,q=Q+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,Q,K):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(D0($,J,q,1)),J=b7(this,q,1),this.precision=Q,this.rounding=K,Z=$.s<0?Z.minus(J):Z.plus(J);else Z=this.atan(D0($,J,q,1));return Z}function zK($){return new this($).cbrt()}function jK($){return M0($=new this($),$.e+1,2)}function GK($,J,Z){return new this($).clamp(J,Z)}function FK($){if(!$||typeof $!=="object")throw Error(M6+"Object expected");var J,Z,Q,K=$.defaults===!0,q=["precision",1,Z$,"rounding",0,8,"toExpNeg",-N$,0,"toExpPos",0,N$,"maxE",0,N$,"minE",-N$,0,"modulo",0,9];for(J=0;J<q.length;J+=3){if(Z=q[J],K)this[Z]=j9[Z];if((Q=$[Z])!==void 0)if($7(Q)===Q&&Q>=q[J+1]&&Q<=q[J+2])this[Z]=Q;else throw Error(J$+Z+": "+Q)}if(Z="crypto",K)this[Z]=j9[Z];if((Q=$[Z])!==void 0)if(Q===!0||Q===!1||Q===0||Q===1)if(Q)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[Z]=!0;else throw Error(z8);else this[Z]=!1;else throw Error(J$+Z+": "+Q);return this}function _K($){return new this($).cos()}function UK($){return new this($).cosh()}function Y8($){var J,Z,Q;function K(q){var H,W,j,z=this;if(!(z instanceof K))return new K(q);if(z.constructor=K,q8(q)){if(z.s=q.s,A0)if(!q.d||q.e>K.maxE)z.e=NaN,z.d=null;else if(q.e<K.minE)z.e=0,z.d=[0];else z.e=q.e,z.d=q.d.slice();else z.e=q.e,z.d=q.d?q.d.slice():q.d;return}if(j=typeof q,j==="number"){if(q===0){z.s=1/q<0?-1:1,z.e=0,z.d=[0];return}if(q<0)q=-q,z.s=-1;else z.s=1;if(q===~~q&&q<1e7){for(H=0,W=q;W>=10;W/=10)H++;if(A0)if(H>K.maxE)z.e=NaN,z.d=null;else if(H<K.minE)z.e=0,z.d=[0];else z.e=H,z.d=[q];else z.e=H,z.d=[q];return}if(q*0!==0){if(!q)z.s=NaN;z.e=NaN,z.d=null;return}return U6(z,q.toString())}if(j==="string"){if((W=q.charCodeAt(0))===45)q=q.slice(1),z.s=-1;else{if(W===43)q=q.slice(1);z.s=1}return G8.test(q)?U6(z,q):aQ(z,q)}if(j==="bigint"){if(q<0)q=-q,z.s=-1;else z.s=1;return U6(z,q.toString())}throw Error(J$+q)}if(K.prototype=Q0,K.ROUND_UP=0,K.ROUND_DOWN=1,K.ROUND_CEIL=2,K.ROUND_FLOOR=3,K.ROUND_HALF_UP=4,K.ROUND_HALF_DOWN=5,K.ROUND_HALF_EVEN=6,K.ROUND_HALF_CEIL=7,K.ROUND_HALF_FLOOR=8,K.EUCLID=9,K.config=K.set=FK,K.clone=Y8,K.isDecimal=q8,K.abs=eQ,K.acos=$K,K.acosh=JK,K.add=ZK,K.asin=QK,K.asinh=KK,K.atan=qK,K.atanh=HK,K.atan2=WK,K.cbrt=zK,K.ceil=jK,K.clamp=GK,K.cos=_K,K.cosh=UK,K.div=VK,K.exp=OK,K.floor=YK,K.hypot=MK,K.ln=XK,K.log=kK,K.log10=wK,K.log2=LK,K.max=RK,K.min=BK,K.mod=NK,K.mul=CK,K.pow=IK,K.random=PK,K.round=AK,K.sign=EK,K.sin=TK,K.sinh=bK,K.sqrt=fK,K.sub=SK,K.sum=vK,K.tan=DK,K.tanh=hK,K.trunc=yK,$===void 0)$={};if($){if($.defaults!==!0){Q=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(J=0;J<Q.length;)if(!$.hasOwnProperty(Z=Q[J++]))$[Z]=this[Z]}}return K.config($),K}function VK($,J){return new this($).div(J)}function OK($){return new this($).exp()}function YK($){return M0($=new this($),$.e+1,3)}function MK(){var $,J,Z=new this(0);A0=!1;for($=0;$<arguments.length;)if(J=new this(arguments[$++]),!J.d){if(J.s)return A0=!0,new this(1/0);Z=J}else if(Z.d)Z=Z.plus(J.times(J));return A0=!0,Z.sqrt()}function q8($){return $ instanceof m$||$&&$.toStringTag===j8||!1}function XK($){return new this($).ln()}function kK($,J){return new this($).log(J)}function LK($){return new this($).log(2)}function wK($){return new this($).log(10)}function RK(){return U8(this,arguments,-1)}function BK(){return U8(this,arguments,1)}function NK($,J){return new this($).mod(J)}function CK($,J){return new this($).mul(J)}function IK($,J){return new this($).pow(J)}function PK($){var J,Z,Q,K,q=0,H=new this(1),W=[];if($===void 0)$=this.precision;else W7($,1,Z$);if(Q=Math.ceil($/R0),!this.crypto)for(;q<Q;)W[q++]=Math.random()*1e7|0;else if(crypto.getRandomValues){J=crypto.getRandomValues(new Uint32Array(Q));for(;q<Q;)if(K=J[q],K>=4290000000)J[q]=crypto.getRandomValues(new Uint32Array(1))[0];else W[q++]=K%1e7}else if(crypto.randomBytes){J=crypto.randomBytes(Q*=4);for(;q<Q;)if(K=J[q]+(J[q+1]<<8)+(J[q+2]<<16)+((J[q+3]&127)<<24),K>=2140000000)crypto.randomBytes(4).copy(J,q);else W.push(K%1e7),q+=4;q=Q/4}else throw Error(z8);if(Q=W[--q],$%=R0,Q&&$)K=l0(10,R0-$),W[q]=(Q/K|0)*K;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(Q=1,K=W[0];K>=10;K/=10)Q++;if(Q<R0)Z-=R0-Q}return H.e=Z,H.d=W,H}function AK($){return M0($=new this($),$.e+1,this.rounding)}function EK($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function TK($){return new this($).sin()}function bK($){return new this($).sinh()}function fK($){return new this($).sqrt()}function SK($,J){return new this($).sub(J)}function vK(){var $=0,J=arguments,Z=new this(J[$]);A0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return A0=!0,M0(Z,this.precision,this.rounding)}function DK($){return new this($).tan()}function hK($){return new this($).tanh()}function yK($){return M0($=new this($),$.e+1,1)}Q0[Symbol.for("nodejs.util.inspect.custom")]=Q0.toString;Q0[Symbol.toStringTag]="Decimal";var m$=Q0.constructor=Y8(j9);V6=new m$(V6);O6=new m$(O6);var O=m$;var U9=($)=>{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 v0{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 U9(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 v0($)}clone(){return new v0(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 v0))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 v0(this.data.map((J,Z)=>J.plus($.data[Z])))}sub($){if(!$||!($ instanceof v0))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 v0(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=U9($)}catch(Z){throw new Error(`scale: invalid scalar - ${Z.message}`)}return new v0(this.data.map((Z)=>Z.mul(J)))}negate(){return new v0(this.data.map(($)=>$.negated()))}dot($){if(!$||!($ instanceof v0))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,Q)=>J.plus(Z.mul($.data[Q])),new O(0))}outer($){if(!$||!($ instanceof v0))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},(K,q)=>Array.from({length:Z},(H,W)=>this.data[q].mul($.data[W])))}cross($){if(!$||!($ instanceof v0))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,Q]=this.data,[K,q,H]=$.data;return new v0([Z.mul(H).minus(Q.mul(q)),Q.mul(K).minus(J.mul(H)),J.mul(q).minus(Z.mul(K))])}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 v0))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(),Q=$.norm();if(Z.isZero()||Q.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let q=J.div(Z.mul(Q)).toNumber(),H=Math.min(1,Math.max(-1,q));return new O(Math.acos(H))}projectOnto($){if(!$||!($ instanceof v0))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 v0([this.data[1].negated(),this.data[0]]);for(let J=0;J<this.length;J++){let Z=Array.from({length:this.length},(W,j)=>new O(j===J?1:0)),Q=new v0(Z),K=Q.projectOnto(this),q=Q.sub(K);if(!q.norm().isZero())return q.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo($){if(!$||!($ instanceof v0))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 v0))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 v0))return!1;if($.length!==this.length)return!1;if(J===null)throw new Error("equals: tolerance cannot be null");let Z;try{if(Z=U9(J),Z.isNaN())throw new Error("equals: tolerance cannot be NaN");if(Z.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(Q){throw new Error(`equals: invalid tolerance - ${Q.message}`)}for(let Q=0;Q<this.length;Q++)if(this.data[Q].minus($.data[Q]).abs().greaterThan(Z))return!1;return!0}}var I$=($)=>{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((Q)=>I$(Q))),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,Q)=>Array.from({length:$},(K,q)=>Q===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 v0)J=$;else if(Array.isArray($))J=v0.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 Q=0;Q<this.rows;Q++){let K=new O(0);for(let q=0;q<this.cols;q++)K=K.plus(this.data[Q][q].mul(J.data[q]));Z.push(K)}return new v0(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((Q,K)=>Q.plus($.data[Z][K]))))}else{let J=I$($);return new W0(this.data.map((Z)=>Z.map((Q)=>Q.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((Q,K)=>Q.minus($.data[Z][K]))))}else{let J=I$($);return new W0(this.data.map((Z)=>Z.map((Q)=>Q.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 Q=0;Q<this.cols;Q++){let K=this.data[Z][Q];if(K.isZero())continue;for(let q=0;q<$.cols;q++)J[Z][q]=J[Z][q].plus(K.mul($.data[Q][q]))}return new W0(J)}else{let J=I$($);return new W0(this.data.map((Z)=>Z.map((Q)=>Q.mul(J))))}}div($){let J=I$($);if(J.isZero())throw new Error("Cannot divide by zero");return new W0(this.data.map((Z)=>Z.map((Q)=>Q.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},(Q,K)=>new O(this.data[K][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=I$(J);if(Z.isNegative()||!Z.isFinite())throw new Error("tolerance must be non-negative and finite");for(let Q=0;Q<this.rows;Q++)for(let K=0;K<this.cols;K++)if(this.data[Q][K].minus($.data[Q][K]).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),Q=Array.from({length:$},()=>Array.from({length:$},()=>new O(0)));for(let H=0;H<$;H++)Q[H][H]=new O(1);for(let H=0;H<$;H++){let W=H,j=J[H][H].abs();for(let z=H+1;z<$;z++){let G=J[z][H].abs();if(G.greaterThan(j))j=G,W=z}if(J[W][H].isZero())throw new Error("Singular matrix: LU decomposition failed");if(W!==H){let z=J[H];J[H]=J[W],J[W]=z;let G=Z[H];Z[H]=Z[W],Z[W]=G;for(let F=0;F<H;F++){let _=Q[H][F];Q[H][F]=Q[W][F],Q[W][F]=_}}for(let z=H+1;z<$;z++){let G=J[z][H].div(J[H][H]);Q[z][H]=G;for(let F=H;F<$;F++)J[z][F]=J[z][F].minus(G.mul(J[H][F]))}}let K=Array.from({length:$},(H,W)=>Array.from({length:$},(j,z)=>z<W?new O(0):J[W][z])),q=W0.zeros($,$);for(let H=0;H<$;H++)q.data[H][Z[H]]=new O(1);return{L:new W0(Q),U:new W0(K),P:q}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let $=this.rows,{L:J,U:Z,P:Q}=this.lu(),K=new O(1);for(let W=0;W<$;W++)K=K.mul(Z.data[W][W]);let q=[];for(let W=0;W<$;W++)for(let j=0;j<$;j++)if(Q.data[W][j].equals(1))q.push(j);let H=0;for(let W=0;W<q.length;W++)for(let j=W+1;j<q.length;j++)if(q[W]>q[j])H++;if(H%2===1)K=K.negated();return K}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let $=this.rows,J=Array.from({length:$},(Q,K)=>Array.from({length:2*$},(q,H)=>H<$?new O(this.data[K][H]):H-$===K?new O(1):new O(0)));for(let Q=0;Q<$;Q++){let K=Q,q=J[Q][Q].abs();for(let W=Q+1;W<$;W++){let j=J[W][Q].abs();if(j.greaterThan(q))q=j,K=W}if(J[K][Q].isZero())throw new Error("Singular matrix: inverse does not exist");if(K!==Q){let W=J[Q];J[Q]=J[K],J[K]=W}let H=J[Q][Q];for(let W=0;W<2*$;W++)J[Q][W]=J[Q][W].div(H);for(let W=0;W<$;W++){if(W===Q)continue;let j=J[W][Q];if(j.isZero())continue;for(let z=0;z<2*$;z++)J[W][z]=J[W][z].minus(j.mul(J[Q][z]))}}let Z=J.map((Q)=>Q.slice($));return new W0(Z)}solve($){let J;if($ instanceof v0)J=$;else if(Array.isArray($))J=v0.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 Q=Array.from({length:Z},(q,H)=>Array.from({length:Z+1},(W,j)=>new O(j<Z?this.data[H][j]:J.data[H])));for(let q=0;q<Z;q++){let H=q,W=Q[q][q].abs();for(let j=q+1;j<Z;j++){let z=Q[j][q].abs();if(z.greaterThan(W))W=z,H=j}if(Q[H][q].isZero())throw new Error("Singular matrix: no unique solution");if(H!==q){let j=Q[q];Q[q]=Q[H],Q[H]=j}for(let j=q+1;j<Z;j++){let z=Q[j][q].div(Q[q][q]);if(z.isZero())continue;for(let G=q;G<Z+1;G++)Q[j][G]=Q[j][G].minus(z.mul(Q[q][G]))}}let K=Array.from({length:Z},()=>new O(0));for(let q=Z-1;q>=0;q--){if(Q[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(Q[q][W].mul(K[W]));K[q]=Q[q][Z].minus(H).div(Q[q][q])}return new v0(K)}qr(){let $=this.rows,J=this.cols,Z=this.data.map((q)=>q.map((H)=>new O(H))),Q=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 j=H[0].isNegative()?new O(-1):new O(1),z=H.slice();z[0]=z[0].plus(j.mul(W));let G=new O(0);for(let F of z)G=G.plus(F.mul(F));if(G=G.sqrt(),G.isZero())continue;for(let F=0;F<z.length;F++)z[F]=z[F].div(G);for(let F=q;F<J;F++){let _=new O(0);for(let U=0;U<z.length;U++)_=_.plus(z[U].mul(Z[q+U][F]));for(let U=0;U<z.length;U++)Z[q+U][F]=Z[q+U][F].minus(new O(2).mul(z[U]).mul(_))}for(let F=0;F<$;F++){let _=new O(0);for(let U=0;U<z.length;U++)_=_.plus(z[U].mul(Q[q+U][F]));for(let U=0;U<z.length;U++)Q[q+U][F]=Q[q+U][F].minus(new O(2).mul(z[U]).mul(_))}}let K=Array.from({length:$},(q,H)=>Array.from({length:J},(W,j)=>H<=j?Z[H][j]:new O(0)));return{Q:new W0(Q).transpose(),R:new W0(K)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=W0.identity(J),Q=$.maxIter||120;if(!Number.isInteger(Q)||Q<=0)throw new Error("maxIter must be a positive integer");let K=new O($.tolerance||"1e-40");if(K.isNegative()||K.isZero()||!K.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 Y=new O(0);for(let V=0;V<F.cols;V++)Y=Y.plus(F.data[U][V].abs());if(Y.greaterThan(_))_=Y}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 j=this;if(W>0)j=this.mul(new O(1).div(new O(2).pow(W)));let z=Z.clone(),G=Z.clone();for(let F=1;F<Q;F++){z=z.mul(j).mul(new O(1).div(F)),G=G.add(z);let _=new O(0);for(let U=0;U<z.rows;U++)for(let Y=0;Y<z.cols;Y++)_=_.plus(z.data[U][Y].abs());if(_.lessThan(K))break}for(let F=0;F<W;F++)G=G.mul(G);return G}}var S7={};d7(S7,{translation:()=>s0,stretchAlongAxis:()=>uK,skew:()=>L6,scale:()=>V7,rotateAroundPoint:()=>V9,rotate:()=>F$,reflectY:()=>xK,reflectX:()=>gK,reflectOrigin:()=>mK,applyTransform:()=>n0});var z7=($)=>{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 Z7($,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 s0($,J){return Z7($,"tx"),Z7(J,"ty"),W0.from([[new O(1),new O(0),z7($)],[new O(0),new O(1),z7(J)],[new O(0),new O(0),new O(1)]])}function V7($,J=null){if(Z7($,"sx"),J!==null)Z7(J,"sy");let Z=J===null?$:J,Q=z7($),K=z7(Z);if(Q.isZero()||K.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return W0.from([[Q,new O(0),new O(0)],[new O(0),K,new O(0)],[new O(0),new O(0),new O(1)]])}function F$($){Z7($,"theta");let Z=z7($).toNumber(),Q=Math.PI,K=Z-2*Q*Math.floor((Z+Q)/(2*Q));if(!isFinite(K))throw new Error(`Angle normalization failed for theta=${$} (too large or invalid)`);let q=new O(Math.cos(K)),H=new O(Math.sin(K));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 V9($,J,Z){Z7($,"theta"),Z7(J,"px"),Z7(Z,"py");let Q=z7(J),K=z7(Z);return s0(Q,K).mul(F$($)).mul(s0(Q.negated(),K.negated()))}function L6($,J){Z7($,"ax"),Z7(J,"ay");let Z=z7($),Q=z7(J);if(new O(1).minus(Z.mul(Q)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${Z.mul(Q).toString()}, must be < 1)`);return W0.from([[new O(1),Z,new O(0)],[Q,new O(1),new O(0)],[new O(0),new O(0),new O(1)]])}function uK($,J,Z){Z7($,"ux"),Z7(J,"uy"),Z7(Z,"k");let Q=z7($),K=z7(J),q=z7(Z);if(q.isZero())throw new Error("Stretch factor k cannot be zero (creates singular matrix)");let H=Q.mul(Q).plus(K.mul(K));if(H.isZero())throw new Error("Axis vector (ux, uy) cannot be zero");let W=H.minus(1).abs(),j=new O(0.000001);if(W.greaterThan(j))throw new Error(`Axis vector (ux, uy) must be normalized (||u|| = 1). Current magnitude squared: ${H.toString()}, expected: 1. Use normalized vector: (${Q.div(H.sqrt()).toString()}, ${K.div(H.sqrt()).toString()})`);let z=new O(1),G=q.minus(z),F=z.plus(G.mul(Q.mul(Q))),_=G.mul(Q.mul(K)),U=G.mul(K.mul(Q)),Y=z.plus(G.mul(K.mul(K)));return W0.from([[F,_,new O(0)],[U,Y,new O(0)],[new O(0),new O(0),new O(1)]])}function n0($,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");Z7(J,"x"),Z7(Z,"y");let Q=W0.from([[z7(J)],[z7(Z)],[new O(1)]]),K=$.mul(Q);if(!K||!K.data||!Array.isArray(K.data)||K.data.length!==3||!K.data[0]||!K.data[0][0]||!K.data[1]||!K.data[1][0]||!K.data[2]||!K.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let q=K.data[0][0],H=K.data[1][0],W=K.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 gK(){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 xK(){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 mK(){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 Y9={};d7(Y9,{translation:()=>O9,scale:()=>dK,rotateZ:()=>nK,rotateY:()=>cK,rotateX:()=>pK,rotateAroundPoint:()=>lK,rotateAroundAxis:()=>M8,reflectYZ:()=>rK,reflectXZ:()=>iK,reflectXY:()=>oK,reflectOrigin:()=>aK,applyTransform:()=>sK});var o0=($)=>{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 m0($,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;return J%6.283185307179586}function O9($,J,Z){return m0($,"tx"),m0(J,"ty"),m0(Z,"tz"),W0.from([[new O(1),new O(0),new O(0),o0($)],[new O(0),new O(1),new O(0),o0(J)],[new O(0),new O(0),new O(1),o0(Z)],[new O(0),new O(0),new O(0),new O(1)]])}function dK($,J=null,Z=null){if(m0($,"sx"),J!==null)m0(J,"sy");if(Z!==null)m0(Z,"sz");let Q=J===null?$:J,K=Z===null?$:Z,q=o0($),H=o0(Q),W=o0(K);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 pK($){m0($,"theta");let J=o0($),Z=w6(J),Q=new O(Math.cos(Z)),K=new O(Math.sin(Z));return W0.from([[new O(1),new O(0),new O(0),new O(0)],[new O(0),Q,K.negated(),new O(0)],[new O(0),K,Q,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function cK($){m0($,"theta");let J=o0($),Z=w6(J),Q=new O(Math.cos(Z)),K=new O(Math.sin(Z));return W0.from([[Q,new O(0),K,new O(0)],[new O(0),new O(1),new O(0),new O(0)],[K.negated(),new O(0),Q,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function nK($){m0($,"theta");let J=o0($),Z=w6(J),Q=new O(Math.cos(Z)),K=new O(Math.sin(Z));return W0.from([[Q,K.negated(),new O(0),new O(0)],[K,Q,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 M8($,J,Z,Q){m0($,"ux"),m0(J,"uy"),m0(Z,"uz"),m0(Q,"theta");let K=[o0($),o0(J),o0(Z)],q=K[0].mul(K[0]).plus(K[1].mul(K[1])).plus(K[2].mul(K[2])).sqrt();if(q.isZero())throw new Error("Rotation axis cannot be zero vector (ux=0, uy=0, uz=0)");K[0]=K[0].div(q),K[1]=K[1].div(q),K[2]=K[2].div(q);let H=o0(Q),W=w6(H),j=new O(Math.cos(W)),z=new O(Math.sin(W)),G=new O(1),F=K[0].mul(K[0]),_=K[1].mul(K[1]),U=K[2].mul(K[2]),Y=F.plus(j.mul(G.minus(F))),V=K[0].mul(K[1]).mul(G.minus(j)).minus(K[2].mul(z)),M=K[0].mul(K[2]).mul(G.minus(j)).plus(K[1].mul(z)),X=K[1].mul(K[0]).mul(G.minus(j)).plus(K[2].mul(z)),k=_.plus(j.mul(G.minus(_))),L=K[1].mul(K[2]).mul(G.minus(j)).minus(K[0].mul(z)),R=K[2].mul(K[0]).mul(G.minus(j)).minus(K[1].mul(z)),B=K[2].mul(K[1]).mul(G.minus(j)).plus(K[0].mul(z)),I=U.plus(j.mul(G.minus(U)));return W0.from([[Y,V,M,new O(0)],[X,k,L,new O(0)],[R,B,I,new O(0)],[new O(0),new O(0),new O(0),new O(1)]])}function lK($,J,Z,Q,K,q,H){m0($,"ux"),m0(J,"uy"),m0(Z,"uz"),m0(Q,"theta"),m0(K,"px"),m0(q,"py"),m0(H,"pz");let W=o0(K),j=o0(q),z=o0(H);return O9(W,j,z).mul(M8($,J,Z,Q)).mul(O9(W.negated(),j.negated(),z.negated()))}function sK($,J,Z,Q){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}`);m0(J,"x"),m0(Z,"y"),m0(Q,"z");let K=W0.from([[o0(J)],[o0(Z)],[o0(Q)],[new O(1)]]),q=$.mul(K),H=q.data[0][0],W=q.data[1][0],j=q.data[2][0],z=q.data[3][0];if(z.isZero())throw new Error("Perspective division by zero: transformation results in point at infinity");return[H.div(z),W.div(z),j.div(z)]}function oK(){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 iK(){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 rK(){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 aK(){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={};d7(K9,{validateXML:()=>OQ,validateSVGAsync:()=>Gz,validateSVG:()=>YQ,straightCurves:()=>jJ,sortDefsChildren:()=>cZ,sortAttrs:()=>pZ,simplifyPaths:()=>NQ,simplifyPath:()=>wQ,saveOutput:()=>YZ,reusePaths:()=>nZ,removeXlink:()=>oZ,removeXMLProcInst:()=>CZ,removeXMLNS:()=>bZ,removeViewBox:()=>TZ,removeUselessDefs:()=>RZ,removeUselessCommands:()=>_J,removeUnknownsAndDefaults:()=>LZ,removeTitle:()=>IZ,removeStyleElement:()=>sZ,removeScriptElement:()=>SZ,removeRasterImages:()=>fZ,removeOffCanvasPath:()=>lZ,removeNonInheritableGroupAttrs:()=>wZ,removeMetadata:()=>Z9,removeLeadingZero:()=>QJ,removeHiddenElements:()=>e6,removeEmptyText:()=>BZ,removeEmptyContainers:()=>$9,removeEmptyAttrs:()=>AZ,removeElementsByAttr:()=>JQ,removeEditorsNSData:()=>IJ,removeDoctype:()=>NZ,removeDimensions:()=>tZ,removeDesc:()=>PZ,removeComments:()=>J9,removeAttrs:()=>$Q,removeAttributesBySelector:()=>eZ,printHierarchicalMatrix:()=>Qz,presetNone:()=>TJ,presetDefault:()=>EJ,prefixIds:()=>aZ,optimizePaths:()=>BQ,optimizeAnimationTiming:()=>RQ,optimize:()=>QQ,negativeExtraSpace:()=>KJ,moveGroupAttrsToElems:()=>xZ,moveElemsAttrsToGroup:()=>mZ,minifyStyles:()=>AJ,mergePaths:()=>gZ,measureDistance:()=>VQ,loadInput:()=>z6,lineShorthands:()=>WJ,inlineStyles:()=>dZ,imageToPath:()=>_Q,generateOutput:()=>j6,generateFullCompatibilityMatrix:()=>Zz,generateFlexibleSVGTable:()=>MQ,generateCompatibilityMatrixSVG:()=>Kz,generateCompatibilityMatrixFlexible:()=>qz,formatPrecision:()=>OZ,floatPrecision:()=>FJ,flattenUseElements:()=>FQ,flattenPatterns:()=>jQ,flattenMasks:()=>HQ,flattenGradients:()=>WQ,flattenFilters:()=>GQ,flattenClipPaths:()=>qQ,flattenAll:()=>LQ,fixInvalidSVG:()=>XQ,exportEmbeddedResources:()=>PQ,escapeXml:()=>nW,embedExternalDependencies:()=>fJ,detectOutputTarget:()=>NJ,detectInputType:()=>R$,detectCollisions:()=>UQ,default:()=>Iz,decomposeTransform:()=>CQ,createOperation:()=>F0,createConfig:()=>KQ,convertTransform:()=>hZ,convertToZ:()=>zJ,convertToRelative:()=>qJ,convertToPlainSVG:()=>EZ,convertToAbsolute:()=>HJ,convertStyleToAttrs:()=>PJ,convertShapesToPath:()=>vZ,convertQuadraticToSmooth:()=>VJ,convertPathData:()=>DZ,convertEllipseToCircle:()=>yZ,convertCubicToSmooth:()=>OJ,convertCubicToQuadratic:()=>UJ,convertColors:()=>Q9,collapseRepeated:()=>GJ,collapseGroups:()=>uZ,cleanupNumericValues:()=>t6,cleanupListOfValues:()=>MZ,cleanupIds:()=>CJ,cleanupEnableBackground:()=>kZ,cleanupAttributes:()=>XZ,arcShorthands:()=>YJ,applyPreset:()=>ZQ,analyzeCompatibilityMatrix:()=>Jz,analyzeCompatibility:()=>rW,addClassesToSVGElement:()=>rZ,addAttributesToSVGElement:()=>iZ,ValidationSeverity:()=>B0,PRECISION_LEVELS:()=>VZ,OutputTarget:()=>X7,OutputFormat:()=>k7,MAX_PRECISION:()=>W6,InputType:()=>h0,DEFAULT_PRECISION:()=>i6});O.set({precision:80});var K4=new O("1e-40"),q4=new O("1e-10");O.set({precision:80});var g0=($)=>$ instanceof O?$:new O($),eK=new O("1e-40"),$q=new O("1e-30");function Jq($,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,g0($)],[0,1,g0(J)],[0,0,1]])}function Zq($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=g0($),Z=O.cos(J),Q=O.sin(J);return W0.from([[Z,Q.neg(),0],[Q,Z,0],[0,0,1]])}function Qq($,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([[g0($),0,0],[0,g0(J),0],[0,0,1]])}function Kq($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=O.tan(g0($));return W0.from([[1,J,0],[0,1,0],[0,0,1]])}function qq($){if($==null)throw new TypeError("skewYMatrix: angle parameter is required");let J=O.tan(g0($));return W0.from([[1,0,0],[J,1,0],[0,0,1]])}function Hq($){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 Wq($){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 X8($){if(!$)throw new TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:Q,d:K}=Hq($),{tx:q,ty:H}=Wq($),W=J.mul(K).minus(Z.mul(Q)),j=J.mul(J).plus(Z.mul(Z)).sqrt();if(j.abs().lessThan(eK))return{translateX:q,translateY:H,rotation:g0(0),scaleX:g0(0),scaleY:g0(0),skewX:g0(0),skewY:g0(0),verified:!1,maxError:g0("Infinity"),singular:!0};let z=W.div(j);if(z.abs().greaterThan(new O("1e40")))return{translateX:q,translateY:H,rotation:g0(0),scaleX:g0(0),scaleY:g0(0),skewX:g0(0),skewY:g0(0),verified:!1,maxError:g0("Infinity"),singular:!0};if(W.lessThan(0))j=j.neg(),z=z.neg();let G;if(j.lessThan(0))G=O.atan2(Z.neg(),J.neg());else G=O.atan2(Z,J);let F=O.cos(G),_=O.sin(G),U=J.mul(F).plus(Z.mul(_)),Y=Q.mul(F).plus(K.mul(_)),V,M=new O("1e-30");if(U.abs().greaterThan(M)){let B=Y.div(U);if(B.abs().greaterThan(new O("1e10")))V=g0(0);else V=O.atan(B)}else V=g0(0);let X=g0(0),k=zq({translateX:q,translateY:H,rotation:G,scaleX:j,scaleY:z,skewX:V,skewY:g0(0)}),L=jq($,k),R=L.lessThan($q);return{translateX:q,translateY:H,rotation:G,scaleX:j,scaleY:z,skewX:V,skewY:X,verified:R,maxError:L}}function zq($){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:Q,scaleX:K,scaleY:q,skewX:H,skewY:W=0}=$,j=Jq(J,Z),z=Zq(Q),G=Kq(H),F=qq(W),_=Qq(K,q);return j.mul(z).mul(F).mul(G).mul(_)}function jq($,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=g0(0);for(let Q=0;Q<$.rows;Q++)for(let K=0;K<$.cols;K++){let q=$.data[Q][K].minus(J.data[Q][K]).abs();if(q.greaterThan(Z))Z=q}return Z}O.set({precision:80});var Y7=($)=>$ instanceof O?$:new O($),d0=new O("1e-40"),k8=100;function v7($,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:Y7($),y:Y7(J)}}function Fq($,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 p0($,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 p$($){if(!$||$.x==null||$.y==null)throw new TypeError("vectorNeg: vector must have x and y properties");return{x:$.x.neg(),y:$.y.neg()}}function X9($,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=Y7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function j7($,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 d$($,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 O7($){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 _$($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitude: vector must have x and y properties");return O7($).sqrt()}function _q($){if(!$||$.x==null||$.y==null)throw new TypeError("normalize: vector must have x and y properties");let J=_$($);if(J.lessThan(d0))return{x:Y7(0),y:Y7(0)};return{x:$.x.div(J),y:$.y.div(J)}}function Q$($,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 Q=j7($,Z),K=j7(J,Z);return p0(X9(J,Q),X9($,K))}function L8($,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=j7($[0],J),Q=$[0];for(let K=1;K<$.length;K++){if(!$[K]||$[K].x==null||$[K].y==null)throw new TypeError(`supportPoint: polygon[${K}] must have x and y properties`);let q=j7($[K],J);if(q.greaterThan(Z))Z=q,Q=$[K]}return Q}function w8($,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 Q=L8($,Z),K=L8(J,p$(Z));return p0(Q,K)}function Uq($,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],Q=$[1],K=p0(Q,Z),q=p$(Z),H=O7(K);if(H.lessThan(d0)){if(O7(Z).lessThan(d0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}let W=Q$(K,q,K);if(O7(W).lessThan(d0)){let j=j7(K,q);if(j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(H))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}return{contains:!1,newDirection:W}}function Vq($,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],Q=$[1],K=$[2],q=p0(Q,Z),H=p0(K,Z),W=p$(Z),j=O7(q),z=O7(H);if(j.lessThan(d0))return{contains:!1,newDirection:Q$(H,W,H),newSimplex:[Z,K]};if(z.lessThan(d0))return{contains:!1,newDirection:Q$(q,W,q),newSimplex:[Z,Q]};let G=Q$(H,q,q),F=Q$(q,H,H);if(O7(G).lessThan(d0)&&O7(F).lessThan(d0)){let _=p0(K,Q),U=O7(_);if(U.greaterThan(j)&&U.greaterThan(z))return{contains:!1,newDirection:Q$(_,p$(Q),_),newSimplex:[Q,K]};else if(j.greaterThan(z))return{contains:!1,newDirection:Q$(q,W,q),newSimplex:[Z,Q]};else return{contains:!1,newDirection:Q$(H,W,H),newSimplex:[Z,K]}}if(j7(G,W).greaterThan(d0))return{contains:!1,newDirection:G,newSimplex:[Z,Q]};if(j7(F,W).greaterThan(d0))return{contains:!1,newDirection:F,newSimplex:[Z,K]};return{contains:!0,newDirection:J,newSimplex:$}}function N8($,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:_$(p0($[0],J[0])).lessThan(d0),iterations:1,simplex:[],verified:!0}}let Z=p0(R6(J),R6($));if(O7(Z).lessThan(d0))Z=v7(1,0);let Q=[w8($,J,Z)];if(Z=p$(Q[0]),O7(Q[0]).lessThan(d0))return{intersects:!0,iterations:1,simplex:Q,verified:M9($,J)};for(let K=0;K<k8;K++){let q=w8($,J,Z);if(j7(q,Z).lessThanOrEqualTo(Y7(0)))return{intersects:!1,iterations:K+1,simplex:Q,verified:!0};if(Q.unshift(q),Q.length===2){let H=Uq(Q,Z);if(H.contains)return{intersects:!0,iterations:K+1,simplex:Q,verified:M9($,J)};Z=H.newDirection}else if(Q.length===3){let H=Vq(Q,Z);if(H.contains)return{intersects:!0,iterations:K+1,simplex:H.newSimplex,verified:M9($,J)};Q=H.newSimplex,Z=H.newDirection}if(O7(Z).lessThan(d0))return{intersects:!1,iterations:K+1,simplex:Q,verified:!1};Z=_q(Z)}return{intersects:!1,iterations:k8,simplex:Q,verified:!1}}function R6($){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=Y7(0),Z=Y7(0);for(let K=0;K<$.length;K++){if(!$[K]||$[K].x==null||$[K].y==null)throw new TypeError(`centroid: polygon[${K}] must have x and y properties`);J=J.plus($[K].x),Z=Z.plus($[K].y)}let Q=Y7($.length);return{x:J.div(Q),y:Z.div(Q)}}function R8($,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 Q=0;Q<J.length;Q++){let K=J[Q],q=J[(Q+1)%J.length];if(!K||K.x==null||K.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${Q}] must have x and y properties`);if(!q||q.x==null||q.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${(Q+1)%J.length}] must have x and y properties`);let H=p0(q,K),W=p0($,K),j=d$(H,W);if(j.abs().lessThan(d0))continue;let z=j.greaterThan(0);if(Z===null)Z=z;else if(Z!==z)return!1}return!0}function M9($,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(R8($[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(R8(J[Z],$))return!0}for(let Z=0;Z<$.length;Z++){let Q=$[Z],K=$[(Z+1)%$.length];if(!Q||Q.x==null||Q.y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(!K||K.x==null||K.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(Oq(Q,K,H,W))return!0}}return!1}function Oq($,J,Z,Q){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(!Q||Q.x==null||Q.y==null)throw new TypeError("segmentsIntersect: b2 must have x and y properties");let K=p0(J,$),q=p0(Q,Z),H=d$(K,q);if(H.abs().lessThan(d0)){let G=p0(Z,$);if(d$(K,G).abs().lessThan(d0)){let F=j7(K,K);if(F.lessThan(d0)){let X=j7(q,q);if(X.lessThan(d0))return _$(G).lessThan(d0);let k=j7(G,q).div(X);return k.greaterThanOrEqualTo(0)&&k.lessThanOrEqualTo(1)}let _=j7(G,K).div(F),U=p0(Q,$),Y=j7(U,K).div(F),V=O.min(_,Y);return O.max(_,Y).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let W=p0(Z,$),j=d$(W,q).div(H),z=d$(W,K).div(H);return j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)&&z.greaterThanOrEqualTo(0)&&z.lessThanOrEqualTo(1)}function Yq($,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(N8($,J).intersects)return{distance:Y7(0),closestA:R6($),closestB:R6(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 Q=Y7(1/0),K=$[0],q=J[0];for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);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`);let G=_$(p0($[j],J[z]));if(G.lessThan(Q))Q=G,K=$[j],q=J[z]}}for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);for(let z=0;z<J.length;z++){let G=J[z],F=J[(z+1)%J.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonB[${z}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonB[${(z+1)%J.length}] must have x and y properties`);let _=B8($[j],G,F),U=_$(p0($[j],_));if(U.lessThan(Q))Q=U,K=$[j],q=_}}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`);for(let z=0;z<$.length;z++){let G=$[z],F=$[(z+1)%$.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonA[${z}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonA[${(z+1)%$.length}] must have x and y properties`);let _=B8(J[j],G,F),U=_$(p0(J[j],_));if(U.lessThan(Q))Q=U,K=_,q=J[j]}}let W=_$(p0(K,q)).minus(Q).abs().lessThan(d0);return{distance:Q,closestA:K,closestB:q,verified:W}}function B8($,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 Q=p0(Z,J),K=p0($,J),q=O7(Q);if(q.lessThan(d0))return J;let H=j7(K,Q).div(q);return H=O.max(Y7(0),O.min(Y7(1),H)),Fq(J,X9(Q,H))}function B6($,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 v7(q.x,q.y)}),Q=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 v7(q.x,q.y)}),K=N8(Z,Q);return{overlaps:K.intersects,verified:K.verified}}function C8($,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 v7(q.x,q.y)}),Q=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 v7(q.x,q.y)}),K=Yq(Z,Q);return{distance:K.distance,closestA:K.closestA,closestB:K.closestB,verified:K.verified}}O.set({precision:80});var G4=new O("1e-40"),F4=new O("1e-10");O.set({precision:80});var V4=new O("1e-40"),O4=new O("1e-30");O.set({precision:80});var G0=($)=>$ instanceof O?$:new O($),X4=new O("1e-40"),Lq=new O("1e-10");function E8($){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=G0(J[0]),Q=G0(J[1]),K=G0(J[2]),q=G0(J[3]);if(K.lessThanOrEqualTo(0)||q.lessThanOrEqualTo(0))throw new Error("ViewBox width and height must be positive");let H=`${Z.toString()} ${Q.toString()} ${K.toString()} ${q.toString()}`,W=J.join(" ");return{x:Z,y:Q,width:K,height:q,verified:H===W}}catch(Z){throw new Error(`Invalid viewBox values: ${Z.message}`)}}function wq($,J,Z,Q){if($==null||J==null||Z==null||Q==null)throw new Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let K=G0($),q=G0(J),H=G0(Z),W=G0(Q);if(H.lessThan(K))throw new Error(`createBBox: maxX (${H}) must be >= minX (${K})`);if(W.lessThan(q))throw new Error(`createBBox: maxY (${W}) must be >= minY (${q})`);return{minX:K,minY:q,maxX:H,maxY:W,width:H.minus(K),height:W.minus(q)}}function I8($,J,Z,Q,K,q,H,W,j=20){if($==null||J==null||Z==null||Q==null||K==null||q==null||H==null||W==null)throw new Error("sampleCubicBezier: all coordinate parameters must be provided");if(j==null||j<=0)throw new Error("sampleCubicBezier: samples must be a positive number");let z=[];for(let G=0;G<=j;G++){let F=G0(G).div(j),_=G0(1).minus(F),U=F.mul(F),Y=U.mul(F),V=_.mul(_),M=V.mul(_),X=M.mul($).plus(G0(3).mul(V).mul(F).mul(Z)).plus(G0(3).mul(_).mul(U).mul(K)).plus(Y.mul(H)),k=M.mul(J).plus(G0(3).mul(V).mul(F).mul(Q)).plus(G0(3).mul(_).mul(U).mul(q)).plus(Y.mul(W));z.push({x:X,y:k})}return z}function P8($,J,Z,Q,K,q,H=20){if($==null||J==null||Z==null||Q==null||K==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 j=0;j<=H;j++){let z=G0(j).div(H),G=G0(1).minus(z),F=G.mul(G),_=z.mul(z),U=F.mul($).plus(G0(2).mul(G).mul(z).mul(Z)).plus(_.mul(K)),Y=F.mul(J).plus(G0(2).mul(G).mul(z).mul(Q)).plus(_.mul(q));W.push({x:U,y:Y})}return W}function Rq($,J,Z=Lq){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 T8($){if(!$||$.length===0)throw new Error("pathBoundingBox: path commands array is empty");let J=G0(1/0),Z=G0(1/0),Q=G0(-1/0),K=G0(-1/0),q=G0(0),H=G0(0),W=G0(0),j=G0(0),z=G0(0),G=G0(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 M=V.type.toUpperCase(),X=V.type===V.type.toLowerCase();switch(M){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(G0(V.x)):G0(V.x),L=X?H.plus(G0(V.y)):G0(V.y);q=k,H=L,W=q,j=H,J=O.min(J,q),Z=O.min(Z,H),Q=O.max(Q,q),K=O.max(K,H),_.push({x:q,y:H}),z=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(G0(V.x)):G0(V.x),L=X?H.plus(G0(V.y)):G0(V.y);J=O.min(J,k),Z=O.min(Z,L),Q=O.max(Q,k),K=O.max(K,L),_.push({x:k,y:L}),q=k,H=L,z=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(G0(V.x)):G0(V.x);J=O.min(J,k),Q=O.max(Q,k),_.push({x:k,y:H}),q=k,z=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(G0(V.y)):G0(V.y);Z=O.min(Z,k),K=O.max(K,k),_.push({x:q,y:k}),H=k,z=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(G0(V.x1)):G0(V.x1),L=X?H.plus(G0(V.y1)):G0(V.y1),R=X?q.plus(G0(V.x2)):G0(V.x2),B=X?H.plus(G0(V.y2)):G0(V.y2),I=X?q.plus(G0(V.x)):G0(V.x),h=X?H.plus(G0(V.y)):G0(V.y),g=I8(q,H,k,L,R,B,I,h,20);for(let f of g)J=O.min(J,f.x),Z=O.min(Z,f.y),Q=O.max(Q,f.x),K=O.max(K,f.y),_.push(f);z=R,G=B,q=I,H=h,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(G0(V.x2)):G0(V.x2),L=X?H.plus(G0(V.y2)):G0(V.y2),R=X?q.plus(G0(V.x)):G0(V.x),B=X?H.plus(G0(V.y)):G0(V.y),I,h;if(F==="C"||F==="S")I=q.mul(2).minus(z),h=H.mul(2).minus(G);else I=q,h=H;let g=I8(q,H,I,h,k,L,R,B,20);for(let f of g)J=O.min(J,f.x),Z=O.min(Z,f.y),Q=O.max(Q,f.x),K=O.max(K,f.y),_.push(f);z=k,G=L,q=R,H=B,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(G0(V.x1)):G0(V.x1),L=X?H.plus(G0(V.y1)):G0(V.y1),R=X?q.plus(G0(V.x)):G0(V.x),B=X?H.plus(G0(V.y)):G0(V.y),I=P8(q,H,k,L,R,B,20);for(let h of I)J=O.min(J,h.x),Z=O.min(Z,h.y),Q=O.max(Q,h.x),K=O.max(K,h.y),_.push(h);z=k,G=L,q=R,H=B,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(G0(V.x)):G0(V.x),L=X?H.plus(G0(V.y)):G0(V.y),R,B;if(F==="Q"||F==="T")R=q.mul(2).minus(z),B=H.mul(2).minus(G);else R=q,B=H;let I=P8(q,H,R,B,k,L,20);for(let h of I)J=O.min(J,h.x),Z=O.min(Z,h.y),Q=O.max(Q,h.x),K=O.max(K,h.y),_.push(h);z=R,G=B,q=k,H=L,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(G0(V.x)):G0(V.x),L=X?H.plus(G0(V.y)):G0(V.y),R=G0(V.rx).abs(),B=G0(V.ry).abs();if(R.isZero()||B.isZero())J=O.min(J,q,k),Z=O.min(Z,H,L),Q=O.max(Q,q,k),K=O.max(K,H,L),_.push({x:q,y:H},{x:k,y:L});else{J=O.min(J,q,k,q.minus(R),k.minus(R)),Z=O.min(Z,H,L,H.minus(B),L.minus(B)),Q=O.max(Q,q,k,q.plus(R),k.plus(R)),K=O.max(K,H,L,H.plus(B),L.plus(B));let I=20;for(let h=0;h<=I;h++){let g=G0(h).div(I),f=q.plus(k.minus(q).mul(g)),x=H.plus(L.minus(H).mul(g));_.push({x:f,y:x})}}q=k,H=L,z=q,G=H,F="A"}break;case"Z":q=W,H=j,z=q,G=H,F="Z";break;default:throw new Error(`pathBoundingBox: unknown path command type: ${M}`)}}if(!J.isFinite()||!Z.isFinite()||!Q.isFinite()||!K.isFinite())throw new Error("Invalid bounding box: no valid coordinates found");let U=wq(J,Z,Q,K),Y=!0;for(let V of _)if(!Rq(V,U)){Y=!1;break}return{...U,verified:Y}}function A8($){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[v7($.minX,$.minY),v7($.maxX,$.minY),v7($.maxX,$.maxY),v7($.minX,$.maxY)]}function b8($,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=A8($),Q=A8({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),K=B6(Z,Q);return{intersects:K.overlaps,verified:K.verified}}var Q7={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function Nq($){if(typeof $!=="string"||!$.trim())throw new Error("Selector must be a non-empty string");let J=$.trim(),Z=[],Q=Cq(J);for(let K of Q){if(!K.trim())continue;let q=Iq(K.trim());Z.push(...q)}return Z}function Cq($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z="",Q=0,K=0,q=!1,H=null;for(let j=0;j<$.length;j++){let z=$[j],G=j>0?$[j-1]:null;if((z==='"'||z==="'")&&G!=="\\"){if(!q)q=!0,H=z;else if(z===H)q=!1,H=null}if(!q){if(z==="["&&G!=="\\")Q++;else if(z==="]"&&G!=="\\"){if(Q--,Q<0)throw new Error(`Unbalanced brackets at position ${j}`)}else if(z==="("&&G!=="\\")K++;else if(z===")"&&G!=="\\"){if(K--,K<0)throw new Error(`Unbalanced parentheses at position ${j}`)}}if(!q&&Q===0&&K===0){if(z===">"||z==="+"||z==="~"){let F=Z.trim();if(F)J.push(F);Z="";continue}else if(z===" "){let F=Z.trim();if(F){J.push(F),Z="";continue}else continue}}Z+=z}if(q)throw new Error("Unclosed quote in selector");if(Q!==0)throw new Error("Unclosed brackets in selector");if(K!==0)throw new Error("Unclosed parentheses in selector");let W=Z.trim();if(W)J.push(W);return J}function Iq($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z=0;while(Z<$.length){let Q=$[Z];if(Q==="#"){let K=$.slice(Z).match(/^#([a-zA-Z_-][\w-]*)/);if(!K)throw new Error(`Invalid ID selector at position ${Z}`);J.push({type:Q7.ID,value:K[1]}),Z+=K[0].length}else if(Q==="."){let K=$.slice(Z).match(/^\.([a-zA-Z_-][\w-]*)/);if(!K)throw new Error(`Invalid class selector at position ${Z}`);J.push({type:Q7.CLASS,value:K[1]}),Z+=K[0].length}else if(Q==="["){let K=Pq($,Z);if(K===-1)throw new Error(`Unclosed attribute selector at position ${Z}`);let q=$.slice(Z+1,K);J.push({type:Q7.ATTRIBUTE,value:q}),Z=K+1}else if(Q===":")if(Z+1<$.length&&$[Z+1]===":"){let K=$.slice(Z).match(/^::([\w-]+)/);if(!K)throw new Error(`Invalid pseudo-element at position ${Z}`);J.push({type:Q7.PSEUDO_ELEMENT,value:K[1]}),Z+=K[0].length}else{let K=$.slice(Z).match(/^:([\w-]+)/);if(!K)throw new Error(`Invalid pseudo-class at position ${Z}`);let q=K[1];if(Z+=K[0].length,Z<$.length&&$[Z]==="("){let j=Aq($,Z);if(j===-1)throw new Error(`Unclosed pseudo-class function at position ${Z}`);q+=$.slice(Z,j+1),Z=j+1}let W=["before","after","first-line","first-letter"].includes(q);J.push({type:W?Q7.PSEUDO_ELEMENT:Q7.PSEUDO_CLASS,value:q})}else if(Q==="*"){let K=Z+1;if(K<$.length&&$[K]==="|"){if(K++,K<$.length&&$[K]==="*")K++}J.push({type:Q7.UNIVERSAL,value:"*"}),Z=K}else if(/[a-zA-Z]/.test(Q)){let K=$.slice(Z).match(/^([a-zA-Z][\w-]*)/);if(!K)throw new Error(`Invalid type selector at position ${Z}`);let q=K[1],H=Z+K[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:Q7.TYPE,value:q}),Z=H}else if(Q===">"||Q==="+"||Q==="~"||Q===" ")Z++;else throw new Error(`Unexpected character '${Q}' at position ${Z}`)}return J}function Pq($,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,Q=!1,K=null;for(let q=J;q<$.length;q++){let H=$[q],W=q>0?$[q-1]:null;if((H==='"'||H==="'")&&W!=="\\"){if(!Q)Q=!0,K=H;else if(H===K)Q=!1,K=null}if(!Q){if(H==="["&&W!=="\\")Z++;if(H==="]"&&W!=="\\"){if(Z--,Z===0)return q}}}return-1}function Aq($,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,Q=!1,K=null;for(let q=J;q<$.length;q++){let H=$[q],W=q>0?$[q-1]:null;if((H==='"'||H==="'")&&W!=="\\"){if(!Q)Q=!0,K=H;else if(H===K)Q=!1,K=null}if(!Q){if(H==="("&&W!=="\\")Z++;if(H===")"&&W!=="\\"){if(Z--,Z===0)return q}}}return-1}function N6($){let J=typeof $==="string"?Nq($):$;if(!Array.isArray(J))throw new Error("Selector must be a string or an array of components");let Z=0,Q=0,K=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 Q7.ID:Z++;break;case Q7.CLASS:case Q7.ATTRIBUTE:Q++;break;case Q7.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],j=H.slice(W.length+1,-1);if(j.trim()){let z=Eq(j),G=[0,0,0];for(let F of z)if(F.trim()){let _=N6(F.trim());if(C6(_,G)>0)G=_}Z+=G[0],Q+=G[1],K+=G[2]}break}if((H.startsWith("nth-child(")||H.startsWith("nth-last-child("))&&H.endsWith(")")){let W=H.match(/^([\w-]+)\(/)[1],z=H.slice(W.length+1,-1).match(/\s+of\s+(.+)$/);if(z){let G=z[1].trim(),F=N6(G);Z+=F[0],Q+=F[1],K+=F[2]}Q++;break}Q++;break}case Q7.TYPE:case Q7.PSEUDO_ELEMENT:K++;break;case Q7.UNIVERSAL:break;default:break}}return[Z,Q,K]}function Eq($){if(typeof $!=="string")throw new Error("selectorList must be a string");let J=[],Z="",Q=0,K=0,q=!1,H=null;for(let W=0;W<$.length;W++){let j=$[W],z=W>0?$[W-1]:null;if((j==='"'||j==="'")&&z!=="\\"){if(!q)q=!0,H=j;else if(j===H)q=!1,H=null}if(!q){if(j==="(")Q++;if(j===")")Q--;if(j==="[")K++;if(j==="]")K--;if(j===","&&Q===0&&K===0){J.push(Z),Z="";continue}}Z+=j}if(Z)J.push(Z);return J}function C6($,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 l$={};d7(l$,{transformPathData:()=>Sq,transformArcParams:()=>v8,rectToPathData:()=>T6,polylineToPathData:()=>c$,polygonToPathData:()=>f6,pathToCubics:()=>vq,pathToAbsolute:()=>n$,pathArrayToString:()=>P$,parsePathData:()=>K$,lineToPathData:()=>b6,getKappaForArc:()=>S8,getKappa:()=>I6,ellipseToPathDataHP:()=>P6,ellipseToPathData:()=>E6,convertElementToPath:()=>L9,circleToPathDataHP:()=>k9,circleToPathData:()=>A6});var S0=($)=>$ 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 S8($){if($==null)throw new Error("getKappaForArc: thetaRadians parameter is required");let J=S0($);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),Q=new O(3);return Z.div(Q).mul(O.tan(J.div(Z)))}function k9($,J,Z,Q=8,K=6){if($==null||J==null||Z==null)throw new Error("circleToPathDataHP: cx, cy, and r parameters are required");let q=S0(Z);if(!q.isFinite()||q.isNegative())throw new Error("circleToPathDataHP: radius must be finite and non-negative");if(q.isZero())return"";if(!Number.isFinite(Q)||Q<=0)throw new Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(K)||K<0)throw new Error("circleToPathDataHP: precision must be non-negative");return P6($,J,Z,Z,Q,K)}function P6($,J,Z,Q,K=8,q=6){if($==null||J==null||Z==null||Q==null)throw new Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(K)||K<=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=K;if(H%4!==0)H=Math.ceil(H/4)*4;let W=S0($),j=S0(J),z=S0(Z),G=S0(Q);if(!z.isFinite()||z.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(z.isZero()||G.isZero())return"";let F=(X)=>U$(X,q),Y=O.acos(-1).mul(2).div(H),V=S8(Y),M=[];for(let X=0;X<H;X++){let k=Y.mul(X),L=Y.mul(X+1),R=O.cos(k),B=O.sin(k),I=O.cos(L),h=O.sin(L),g=W.plus(z.mul(R)),f=j.plus(G.mul(B)),x=W.plus(z.mul(I)),D=j.plus(G.mul(h)),T=B.neg(),d=R,c=h.neg(),p=I,C=g.plus(V.mul(z).mul(T)),y=f.plus(V.mul(G).mul(d)),N=x.minus(V.mul(z).mul(c)),e=D.minus(V.mul(G).mul(p));if(X===0)M.push(`M${F(g)} ${F(f)}`);M.push(`C${F(C)} ${F(y)} ${F(N)} ${F(e)} ${F(x)} ${F(D)}`)}return M.push("Z"),M.join(" ")}function U$($,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=S0($);if(!Z.isFinite())throw new Error("formatNumber: value must be finite");let Q=Z.toFixed(J);if(Q.includes("."))Q=Q.replace(/\.?0+$/,"");return Q}function A6($,J,Z,Q=6){if($==null||J==null||Z==null)throw new Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("circleToPathData: precision must be non-negative");let K=S0($),q=S0(J),H=S0(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),j=K.plus(H),z=q,G=j,F=z.minus(W),_=K.plus(W),U=q.minus(H),Y=K,V=q.minus(H),M=K.minus(W),X=V,k=K.minus(H),L=q.minus(W),R=K.minus(H),B=q,I=R,h=q.plus(W),g=K.minus(W),f=q.plus(H),x=K,D=q.plus(H),T=K.plus(W),d=D,c=j,p=q.plus(W),C=(y)=>U$(y,Q);return`M${C(j)} ${C(z)}C${C(G)} ${C(F)} ${C(_)} ${C(U)} ${C(Y)} ${C(V)}C${C(M)} ${C(X)} ${C(k)} ${C(L)} ${C(R)} ${C(B)}C${C(I)} ${C(h)} ${C(g)} ${C(f)} ${C(x)} ${C(D)}C${C(T)} ${C(d)} ${C(c)} ${C(p)} ${C(j)} ${C(z)}Z`}function E6($,J,Z,Q,K=6){if($==null||J==null||Z==null||Q==null)throw new Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(K)||K<0)throw new Error("ellipseToPathData: precision must be non-negative");let q=S0($),H=S0(J),W=S0(Z),j=S0(Q);if(!W.isFinite()||W.isNegative())throw new Error("ellipseToPathData: rx must be finite and non-negative");if(!j.isFinite()||j.isNegative())throw new Error("ellipseToPathData: ry must be finite and non-negative");if(W.isZero()||j.isZero())return"";let z=I6(),G=z.mul(W),F=z.mul(j),_=q.plus(W),U=H,Y=_,V=U.minus(F),M=q.plus(G),X=H.minus(j),k=q,L=H.minus(j),R=q.minus(G),B=L,I=q.minus(W),h=H.minus(F),g=q.minus(W),f=H,x=g,D=H.plus(F),T=q.minus(G),d=H.plus(j),c=q,p=H.plus(j),C=q.plus(G),y=p,N=_,e=H.plus(F),r=(s)=>U$(s,K);return`M${r(_)} ${r(U)}C${r(Y)} ${r(V)} ${r(M)} ${r(X)} ${r(k)} ${r(L)}C${r(R)} ${r(B)} ${r(I)} ${r(h)} ${r(g)} ${r(f)}C${r(x)} ${r(D)} ${r(T)} ${r(d)} ${r(c)} ${r(p)}C${r(C)} ${r(y)} ${r(N)} ${r(e)} ${r(_)} ${r(U)}Z`}function T6($,J,Z,Q,K=0,q=null,H=!1,W=6){if($==null||J==null||Z==null||Q==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 j=S0($),z=S0(J),G=S0(Z),F=S0(Q);if(!j.isFinite())throw new Error("rectToPathData: x must be finite");if(!z.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 _=S0(K||0),U=q!==null?S0(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 Y=G.div(2),V=F.div(2);if(_.gt(Y))_=Y;if(U.gt(V))U=V;let M=(T)=>U$(T,W);if(_.isZero()||U.isZero()){let T=j.plus(G),d=z.plus(F);return`M${M(j)} ${M(z)}H${M(T)}V${M(d)}H${M(j)}Z`}let X=j,k=j.plus(G),L=z,R=z.plus(F),B=X.plus(_),I=k.minus(_),h=L.plus(U),g=R.minus(U);if(H)return`M${M(B)} ${M(L)}L${M(I)} ${M(L)}A${M(_)} ${M(U)} 0 0 1 ${M(k)} ${M(h)}L${M(k)} ${M(g)}A${M(_)} ${M(U)} 0 0 1 ${M(I)} ${M(R)}L${M(B)} ${M(R)}A${M(_)} ${M(U)} 0 0 1 ${M(X)} ${M(g)}L${M(X)} ${M(h)}A${M(_)} ${M(U)} 0 0 1 ${M(B)} ${M(L)}Z`;let f=I6(),x=f.mul(_),D=f.mul(U);return`M${M(B)} ${M(L)}L${M(I)} ${M(L)}C${M(I.plus(x))} ${M(L)} ${M(k)} ${M(h.minus(D))} ${M(k)} ${M(h)}L${M(k)} ${M(g)}C${M(k)} ${M(g.plus(D))} ${M(I.plus(x))} ${M(R)} ${M(I)} ${M(R)}L${M(B)} ${M(R)}C${M(B.minus(x))} ${M(R)} ${M(X)} ${M(g.plus(D))} ${M(X)} ${M(g)}L${M(X)} ${M(h)}C${M(X)} ${M(h.minus(D))} ${M(B.minus(x))} ${M(L)} ${M(B)} ${M(L)}Z`}function b6($,J,Z,Q,K=6){if($==null||J==null||Z==null||Q==null)throw new Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(K)||K<0)throw new Error("lineToPathData: precision must be non-negative");let q=S0($),H=S0(J),W=S0(Z),j=S0(Q);if(!q.isFinite()||!H.isFinite()||!W.isFinite()||!j.isFinite())throw new Error("lineToPathData: all coordinates must be finite");let z=(G)=>U$(G,K);return`M${z(q)} ${z(H)}L${z(W)} ${z(j)}`}function bq($){if($==null)return[];if(Array.isArray($))try{return $.map(([q,H])=>[S0(q),S0(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=[],Q=J.split(/[\s,]+/).filter((q)=>q.length>0);for(let q of Q)try{Z.push(S0(q))}catch(H){continue}let K=[];for(let q=0;q<Z.length;q+=2)if(q+1<Z.length)K.push([Z[q],Z[q+1]]);return K}function c$($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polylineToPathData: precision must be non-negative");let Z=bq($);if(Z.length===0)return"";let Q=(W)=>U$(W,J),[K,q]=Z[0],H=`M${Q(K)} ${Q(q)}`;for(let W=1;W<Z.length;W++){let[j,z]=Z[W];H+=`L${Q(j)} ${Q(z)}`}return H}function f6($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polygonToPathData: precision must be non-negative");let Z=c$($,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 K$($){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,Q;while((Q=Z.exec($))!==null){let K=Q[1],q=Q[2].trim(),H=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,W=[];if(q.length>0)for(let z of q.matchAll(H))try{W.push(S0(z[0]))}catch(G){continue}let j=fq[K];if(j===0||W.length===0)J.push({command:K,args:[]});else for(let z=0;z<W.length;z+=j){let G=W.slice(z,z+j);if(G.length===j){let F=K;if(z>0&&(K==="M"||K==="m"))F=K==="M"?"L":"l";J.push({command:F,args:G})}}}return J}function P$($,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:Q,args:K}=Z,q=K.map((H)=>U$(H,J)).join(" ");return q.length>0?`${Q} ${q}`:Q}).join(" ")}function n$($){if($==null)throw new Error("pathToAbsolute: pathData parameter is required");let J=K$($),Z=[],Q=new O(0),K=new O(0),q=new O(0),H=new O(0),W=new O(0),j=new O(0),z="";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=_?Q.plus(F[0]):F[0],V=_?K.plus(F[1]):F[1];Q=Y,K=V,q=Y,H=V,Z.push({command:"M",args:[Y,V]}),z="M"}else if(U==="L"){if(F.length<2)continue;let Y=_?Q.plus(F[0]):F[0],V=_?K.plus(F[1]):F[1];Q=Y,K=V,Z.push({command:"L",args:[Y,V]}),z="L"}else if(U==="H"){if(F.length<1)continue;let Y=_?Q.plus(F[0]):F[0];Q=Y,Z.push({command:"L",args:[Y,K]}),z="H"}else if(U==="V"){if(F.length<1)continue;let Y=_?K.plus(F[0]):F[0];K=Y,Z.push({command:"L",args:[Q,Y]}),z="V"}else if(U==="C"){if(F.length<6)continue;let Y=_?Q.plus(F[0]):F[0],V=_?K.plus(F[1]):F[1],M=_?Q.plus(F[2]):F[2],X=_?K.plus(F[3]):F[3],k=_?Q.plus(F[4]):F[4],L=_?K.plus(F[5]):F[5];W=M,j=X,Q=k,K=L,Z.push({command:"C",args:[Y,V,M,X,k,L]}),z="C"}else if(U==="S"){if(F.length<4)continue;let Y,V;if(z==="C"||z==="S")Y=Q.mul(2).minus(W),V=K.mul(2).minus(j);else Y=Q,V=K;let M=_?Q.plus(F[0]):F[0],X=_?K.plus(F[1]):F[1],k=_?Q.plus(F[2]):F[2],L=_?K.plus(F[3]):F[3];W=M,j=X,Q=k,K=L,Z.push({command:"C",args:[Y,V,M,X,k,L]}),z="S"}else if(U==="Q"){if(F.length<4)continue;let Y=_?Q.plus(F[0]):F[0],V=_?K.plus(F[1]):F[1],M=_?Q.plus(F[2]):F[2],X=_?K.plus(F[3]):F[3];W=Y,j=V,Q=M,K=X,Z.push({command:"Q",args:[Y,V,M,X]}),z="Q"}else if(U==="T"){if(F.length<2)continue;let Y,V;if(z==="Q"||z==="T")Y=Q.mul(2).minus(W),V=K.mul(2).minus(j);else Y=Q,V=K;let M=_?Q.plus(F[0]):F[0],X=_?K.plus(F[1]):F[1];W=Y,j=V,Q=M,K=X,Z.push({command:"Q",args:[Y,V,M,X]}),z="T"}else if(U==="A"){if(F.length<7)continue;let Y=_?Q.plus(F[5]):F[5],V=_?K.plus(F[6]):F[6];Q=Y,K=V,Z.push({command:"A",args:[F[0],F[1],F[2],F[3],F[4],Y,V]}),z="A"}else if(U==="Z")Q=q,K=H,Z.push({command:"Z",args:[]}),z="Z";else Z.push({command:G,args:F}),z=G}return P$(Z)}function v8($,J,Z,Q,K,q,H,W){if($==null||J==null||Z==null||Q==null||K==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 j=S0($),z=S0(J),G=S0(Z),F=S0(q),_=S0(H),U=W0.from([[F],[_],[new O(1)]]),Y=W.mul(U),V=Y.data[2][0];if(V.isZero())throw new Error("transformArcParams: division by zero in homogeneous coordinate transformation");let M=Y.data[0][0].div(V),X=Y.data[1][0].div(V),k=W.data[0][0],L=W.data[0][1],R=W.data[1][0],B=W.data[1][1],h=k.mul(B).minus(L.mul(R)).isNegative()?K===1?0:1:K,g=G.mul(new O(Math.PI)).div(180),f=O.cos(g),x=O.sin(g),D=j.mul(f),T=j.mul(x),d=z.mul(x).neg(),c=z.mul(f),p=k.mul(D).plus(L.mul(T)),C=R.mul(D).plus(B.mul(T)),y=k.mul(d).plus(L.mul(c)),N=R.mul(d).plus(B.mul(c)),e=O.sqrt(p.mul(p).plus(C.mul(C))),r=O.sqrt(y.mul(y).plus(N.mul(N))),q0=O.atan2(C,p).mul(180).div(new O(Math.PI));return[e,r,q0,Q,h,M,X]}function Sq($,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 Q=n$($),K=K$(Q),q=[];for(let{command:H,args:W}of K)if(H==="M"||H==="L"){if(W.length<2)continue;let j=W0.from([[W[0]],[W[1]],[new O(1)]]),z=J.mul(j),G=z.data[2][0];if(G.isZero())throw new Error("transformPathData: division by zero in homogeneous coordinate transformation");let F=z.data[0][0].div(G),_=z.data[1][0].div(G);q.push({command:H,args:[F,_]})}else if(H==="C"){if(W.length<6)continue;let j=[];for(let z=0;z<6;z+=2){let G=W0.from([[W[z]],[W[z+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");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(W.length<7)continue;let[j,z,G,F,_,U,Y]=v8(W[0],W[1],W[2],W[3],W[4],W[5],W[6],J);q.push({command:H,args:[j,z,G,F,_,U,Y]})}else q.push({command:H,args:W});return P$(q,Z)}function f8($,J,Z,Q,K,q){if($==null||J==null||Z==null||Q==null||K==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($))),j=J.plus(H.mul(Q.minus(J))),z=K.plus(H.mul(Z.minus(K))),G=q.plus(H.mul(Q.minus(q)));return[W,j,z,G,K,q]}function vq($){if($==null)throw new Error("pathToCubics: pathData parameter is required");let J=n$($),Z=K$(J),Q=[],K=new O(0),q=new O(0),H=new O(0),W=new O(0),j="";for(let{command:z,args:G}of Z)if(z==="M"){if(G.length<2)continue;K=G[0],q=G[1],Q.push({command:"M",args:[K,q]}),j="M"}else if(z==="L"){if(G.length<2)continue;let F=G[0],_=G[1];Q.push({command:"C",args:[K,q,F,_,F,_]}),K=F,q=_,j="L"}else if(z==="C"){if(G.length<6)continue;let[F,_,U,Y,V,M]=G;Q.push({command:"C",args:[F,_,U,Y,V,M]}),H=U,W=Y,K=V,q=M,j="C"}else if(z==="S"){if(G.length<4)continue;let F,_;if(j==="C"||j==="S")F=K.mul(2).minus(H),_=q.mul(2).minus(W);else F=K,_=q;let[U,Y,V,M]=G;Q.push({command:"C",args:[F,_,U,Y,V,M]}),H=U,W=Y,K=V,q=M,j="S"}else if(z==="Q"){if(G.length<4)continue;let[F,_,U,Y]=G,V=f8(K,q,F,_,U,Y);Q.push({command:"C",args:V}),H=F,W=_,K=U,q=Y,j="Q"}else if(z==="T"){if(G.length<2)continue;let F,_;if(j==="Q"||j==="T")F=K.mul(2).minus(H),_=q.mul(2).minus(W);else F=K,_=q;let[U,Y]=G,V=f8(K,q,F,_,U,Y);Q.push({command:"C",args:V}),H=F,W=_,K=U,q=Y,j="T"}else if(z==="Z")Q.push({command:"Z",args:[]}),j="Z";else Q.push({command:z,args:G}),j=z;return P$(Q)}function L9($,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=(K,q=0)=>{let H=$.getAttribute?$.getAttribute(K):$[K];return Dq(H!==void 0&&H!==null?H:q)},Q=($.tagName||$.type||"").toLowerCase();if(Q==="circle")return A6(Z("cx",0),Z("cy",0),Z("r",0),J);else if(Q==="ellipse")return E6(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(Q==="rect")return T6(Z("x",0),Z("y",0),Z("width",0),Z("height",0),Z("rx",0),Z("ry",null),!1,J);else if(Q==="line")return b6(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(Q==="polyline")return c$(Z("points",""),J);else if(Q==="polygon")return f6(Z("points",""),J);return null}function Dq($){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 D8($,J,Z){return w9($,J,Z,Z)}function w9($,J,Z,Q){let K=(R)=>new O(R),q=K($),H=K(J),W=K(Z),j=K(Q);if(!W.isFinite()||!j.isFinite()||!q.isFinite()||!H.isFinite())throw new Error("Ellipse parameters must be finite");if(W.eq(0)||j.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(W.lt(0)||j.lt(0))throw new Error("Ellipse radii must be non-negative");let z=K("0.5522847498307936"),G=W.mul(z),F=j.mul(z),_=q.plus(W),U=H,Y=q,V=H.minus(j),M=q.minus(W),X=H,k=q,L=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)} ${M.toFixed(6)} ${X.minus(F).toFixed(6)} ${M.toFixed(6)} ${X.toFixed(6)}`,`C ${M.toFixed(6)} ${X.plus(F).toFixed(6)} ${k.minus(G).toFixed(6)} ${L.toFixed(6)} ${k.toFixed(6)} ${L.toFixed(6)}`,`C ${k.plus(G).toFixed(6)} ${L.toFixed(6)} ${_.toFixed(6)} ${U.plus(F).toFixed(6)} ${_.toFixed(6)} ${U.toFixed(6)}`,"Z"].join(" ")}function h8($,J,Z,Q,K=0,q=null){let H=(M)=>new O(M),W=H($),j=H(J),z=H(Z),G=H(Q);if(z.lte(0)||G.lte(0))throw new Error("Rectangle dimensions must be positive");if(!z.isFinite()||!G.isFinite()||!W.isFinite()||!j.isFinite())throw new Error("Rectangle parameters must be finite");let F=H(K),_=q!==null?H(q):F;if(F.lt(0)||_.lt(0))throw new Error("Rectangle corner radii must be non-negative");let U=z.div(2),Y=G.div(2);if(F.gt(U))F=U;if(_.gt(Y))_=Y;if(!(F.gt(0)||_.gt(0)))return[`M ${W.toFixed(6)} ${j.toFixed(6)}`,`L ${W.plus(z).toFixed(6)} ${j.toFixed(6)}`,`L ${W.plus(z).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${W.toFixed(6)} ${j.plus(G).toFixed(6)}`,"Z"].join(" ");return[`M ${W.plus(F).toFixed(6)} ${j.toFixed(6)}`,`L ${W.plus(z).minus(F).toFixed(6)} ${j.toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(z).toFixed(6)} ${j.plus(_).toFixed(6)}`,`L ${W.plus(z).toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(z).minus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${W.plus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`L ${W.toFixed(6)} ${j.plus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${W.plus(F).toFixed(6)} ${j.toFixed(6)}`].join(" ")}function y8($,J,Z,Q){let K=(z)=>new O(z),q=K($),H=K(J),W=K(Z),j=K(Q);if(!q.isFinite()||!H.isFinite()||!W.isFinite()||!j.isFinite())throw new Error("lineToPath: all parameters must be finite");return`M ${q.toFixed(6)} ${H.toFixed(6)} L ${W.toFixed(6)} ${j.toFixed(6)}`}function u8($){let J=x8($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let Q=1;Q<J.length;Q++)Z+=` L ${J[Q][0]} ${J[Q][1]}`;return Z+" Z"}function g8($){let J=x8($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let Q=1;Q<J.length;Q++)Z+=` L ${J[Q][0]} ${J[Q][1]}`;return Z}function x8($){if(!$)return[];let J;try{if(Array.isArray($))J=$.flat().map((Q)=>new O(Q).toFixed(6));else if(typeof $==="string")J=$.trim().split(/[\s,]+/).filter((Q)=>Q.length>0).map((Q)=>new O(Q).toFixed(6));else return console.warn("parsePointPairs: invalid input type"),[]}catch(Q){return console.warn(`parsePointPairs: parse error - ${Q.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 Q=0;Q+1<J.length;Q+=2)Z.push([J[Q],J[Q+1]]);return Z}function hq($,J,Z,Q,K,q,H,W){let j=(K0)=>new O(K0),z=j("1e-16");if(!W||!W.data||!Array.isArray(W.data)||W.data.length<3)throw new 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:Q,sweepFlag:K,x:j(q).toNumber(),y:j(H).toNumber()};let _=Q;if(typeof _!=="number"||_!==0&&_!==1)console.warn(`transformArc: largeArcFlag must be 0 or 1, got ${Q}`),_=_?1:0;let U=K;if(typeof U!=="number"||U!==0&&U!==1)console.warn(`transformArc: sweepFlag must be 0 or 1, got ${K}`),U=U?1:0;let Y=W.data[0][0],V=W.data[1][0],M=W.data[0][1],X=W.data[1][1],k=W.data[0][2],L=W.data[1][2],R=j(q),B=j(H),I=Y.mul(R).plus(M.mul(B)).plus(k),h=V.mul(R).plus(X.mul(B)).plus(L),g=j(Z).mul(j(Math.PI)).div(180),f=O.sin(g),x=O.cos(g),D=Y.mul(G).mul(x).plus(M.mul(G).mul(f)),T=V.mul(G).mul(x).plus(X.mul(G).mul(f)),d=Y.mul(F.neg()).mul(f).plus(M.mul(F).mul(x)),c=V.mul(F.neg()).mul(f).plus(X.mul(F).mul(x)),p=D.mul(D).plus(d.mul(d)),C=T.mul(T).plus(c.mul(c)),y=D.mul(T).plus(d.mul(c)).mul(2),N=p.minus(C),e,r,s;if(y.abs().lt(z))e=j(0),r=p,s=C;else if(N.abs().lt(z))r=p.plus(y.mul("0.5")),s=p.minus(y.mul("0.5")),e=j(Math.PI).div(4);else{let K0=j(1).plus(y.mul(y).div(N.mul(N))).sqrt();r=p.plus(C).plus(K0.mul(N)).div(2),s=p.plus(C).minus(K0.mul(N)).div(2),e=O.atan(y.div(N)).div(2)}if(r.lt(0))r=j(0);if(s.lt(0))s=j(0);let q0=r.sqrt(),v=s.sqrt();if(N.lte(0)){let K0=q0;q0=v,v=K0}if(v.gt(q0)){let K0=q0;q0=v,v=K0,e=e.plus(j(Math.PI).div(2))}let E=Y.mul(X).minus(V.mul(M)),t=U;if(E.lt(0))t=U?0:1;let $0=e.mul(180).div(j(Math.PI));while($0.lt(0))$0=$0.plus(180);while($0.gte(180))$0=$0.minus(180);return{rx:q0.toNumber(),ry:v.toNumber(),xAxisRotation:$0.toNumber(),largeArcFlag:_,sweepFlag:t,x:I.toNumber(),y:h.toNumber()}}function yq($,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=(Q)=>new O(Q);switch($.toLowerCase()){case"translate":{let Q=J[0]!==void 0?J[0]:0,K=J[1]!==void 0?J[1]:0;return s0(Q,K)}case"scale":{let Q=J[0]!==void 0?J[0]:1,K=J[1]!==void 0?J[1]:Q;return V7(Q,K)}case"rotate":{let Q=J[0]!==void 0?J[0]:0,K=Z(Q).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"),F$(K);let q=J[1],H=J[2];return V9(K,q,H)}return F$(K)}case"skewx":{let Q=J[0]!==void 0?J[0]:0,K=Z(Q).mul(Z(Math.PI)).div(180),q=O.tan(K);return L6(q,0)}case"skewy":{let Q=J[0]!==void 0?J[0]:0,K=Z(Q).mul(Z(Math.PI)).div(180),q=O.tan(K);return L6(0,q)}case"matrix":{if(J.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${J.length}`),W0.identity(3);let[Q,K,q,H,W,j]=J.slice(0,6).map((z)=>Z(z!==void 0?z:0));return W0.from([[Q,q,W],[K,H,j],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),W0.identity(3)}}function K7($){if(!$||$.trim()==="")return W0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,Q=W0.identity(3);while((Z=J.exec($))!==null){let K=Z[1],H=Z[2].split(/[\s,]+/).filter((j)=>j.length>0).map((j)=>{let z=parseFloat(j);if(isNaN(z))return console.warn(`parseTransformAttribute: invalid numeric argument "${j}" in ${K}(), using 0`),0;return z}),W=yq(K,H);Q=Q.mul(W)}return Q}function R7($,J,Z){if(!$||!$.data||!Array.isArray($.data))throw new Error("applyToPoint: invalid CTM matrix");let Q=(H)=>new O(H);try{let H=Q(J),W=Q(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[K,q]=n0($,J,Z);return{x:K,y:q}}function m8($,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 Q=$.data[0][0].toFixed(Z),K=$.data[1][0].toFixed(Z),q=$.data[0][1].toFixed(Z),H=$.data[1][1].toFixed(Z),W=$.data[0][2].toFixed(Z),j=$.data[1][2].toFixed(Z);return`matrix(${Q}, ${K}, ${q}, ${H}, ${W}, ${j})`}catch(Q){throw new Error(`toSVGMatrix: invalid matrix elements - ${Q.message}`)}}function A$($,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:Q=!0,precision:K=6}=Z,q=K;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=uq($);if(W.length===0)return"";let j=[],z=H(0),G=H(0),F=H(0),_=H(0);for(let{cmd:U,args:Y}of W){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 L=H(Y[k]),R=H(Y[k+1]);if(V)L=L.plus(z),R=R.plus(G);let B=R7(J,L,R);if(X.push(B.x.toFixed(q),B.y.toFixed(q)),z=L,G=R,k===0)F=L,_=R}j.push((Q?"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 L=H(Y[k]),R=H(Y[k+1]);if(V)L=L.plus(z),R=R.plus(G);let B=R7(J,L,R);X.push(B.x.toFixed(q),B.y.toFixed(q)),z=L,G=R}j.push((Q?"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(z);let R=R7(J,k,G);j.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),z=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=z,L=H(Y[X]);if(V)L=L.plus(G);let R=R7(J,k,L);j.push("L "+R.x.toFixed(q)+" "+R.y.toFixed(q)),G=L}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 L=H(Y[k]),R=H(Y[k+1]),B=H(Y[k+2]),I=H(Y[k+3]),h=H(Y[k+4]),g=H(Y[k+5]);if(V)L=L.plus(z),R=R.plus(G),B=B.plus(z),I=I.plus(G),h=h.plus(z),g=g.plus(G);let f=R7(J,L,R),x=R7(J,B,I),D=R7(J,h,g);X.push(f.x.toFixed(q),f.y.toFixed(q),x.x.toFixed(q),x.y.toFixed(q),D.x.toFixed(q),D.y.toFixed(q)),z=h,G=g}j.push((Q?"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 L=H(Y[k]),R=H(Y[k+1]),B=H(Y[k+2]),I=H(Y[k+3]);if(V)L=L.plus(z),R=R.plus(G),B=B.plus(z),I=I.plus(G);let h=R7(J,L,R),g=R7(J,B,I);X.push(h.x.toFixed(q),h.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),z=B,G=I}j.push((Q?"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 L=H(Y[k]),R=H(Y[k+1]),B=H(Y[k+2]),I=H(Y[k+3]);if(V)L=L.plus(z),R=R.plus(G),B=B.plus(z),I=I.plus(G);let h=R7(J,L,R),g=R7(J,B,I);X.push(h.x.toFixed(q),h.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),z=B,G=I}j.push((Q?"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 L=H(Y[k]),R=H(Y[k+1]);if(V)L=L.plus(z),R=R.plus(G);let B=R7(J,L,R);X.push(B.x.toFixed(q),B.y.toFixed(q)),z=L,G=R}j.push((Q?"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 L=Y[k],R=Y[k+1],B=Y[k+2],I=Y[k+3],h=Y[k+4],g=H(Y[k+5]),f=H(Y[k+6]);if(V)g=g.plus(z),f=f.plus(G);let x=hq(L,R,B,I,h,g.toNumber(),f.toNumber(),J);X.push(x.rx.toFixed(q),x.ry.toFixed(q),x.xAxisRotation.toFixed(q),x.largeArcFlag,x.sweepFlag,x.x.toFixed(q),x.y.toFixed(q)),z=g,G=f}j.push((Q?"A":U)+" "+X.join(" "));break}case"Z":{j.push("Z"),z=F,G=_;break}default:j.push(U+" "+Y.join(" "))}}return j.join(" ")}function uq($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,Q;while((Q=Z.exec($))!==null){let K=Q[1],q=Q[2].trim(),H=q.length>0?q.split(/[\s,]+/).filter((W)=>W.length>0).map((W)=>{let j=parseFloat(W);if(isNaN(j))return console.warn(`parsePathCommands: invalid number '${W}'`),0;return j}):[];J.push({cmd:K,args:H})}return J}var h7={};d7(h7,{sign:()=>R9,segmentIntersection:()=>v6,reversePolygon:()=>I9,polygonUnion:()=>V$,polygonIntersection:()=>D7,polygonDifference:()=>o8,polygonArea:()=>s$,pointsEqual:()=>c7,pointOnSegment:()=>B9,pointInPolygon:()=>P7,point:()=>f0,lineSegmentIntersection:()=>l8,isCounterClockwise:()=>C9,isConvex:()=>A9,ensureCCW:()=>D6,dot:()=>n8,default:()=>pq,cross:()=>n7,convexHull:()=>P9,clipPolygonSH:()=>N9,boundingBox:()=>l7,bboxIntersects:()=>o$});O.set({precision:80});var B7=($)=>$ instanceof O?$:new O($),M7=new O("1e-40");function f0($,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 c7($,J,Z=M7){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 n7($,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 Q=J.x.minus($.x),K=J.y.minus($.y),q=Z.x.minus($.x),H=Z.y.minus($.y);return Q.mul(H).minus(K.mul(q))}function n8($,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 Q=J.x.minus($.x),K=J.y.minus($.y),q=Z.x.minus($.x),H=Z.y.minus($.y);return Q.mul(q).plus(K.mul(H))}function R9($){if($===null||$===void 0||typeof $.abs!=="function")throw new Error("sign: val must be a Decimal instance");if($.abs().lt(M7))return 0;return $.lt(0)?-1:1}function v6($,J,Z,Q){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(!Q||Q.x===null||Q.x===void 0||Q.y===null||Q.y===void 0)throw new Error("segmentIntersection: point d must have x and y properties");let K=J.x.minus($.x),q=J.y.minus($.y),H=Q.x.minus(Z.x),W=Q.y.minus(Z.y),j=K.mul(W).minus(q.mul(H));if(j.abs().lt(M7))return null;let z=Z.x.minus($.x),G=Z.y.minus($.y),F=z.mul(W).minus(G.mul(H)).div(j),_=z.mul(q).minus(G.mul(K)).div(j),U=B7(0),Y=B7(1);if(F.gte(U)&&F.lte(Y)&&_.gte(U)&&_.lte(Y))return{x:$.x.plus(K.mul(F)),y:$.y.plus(q.mul(F)),t:F,s:_};return null}function l8($,J,Z,Q){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(!Q||Q.x===null||Q.x===void 0||Q.y===null||Q.y===void 0)throw new Error("lineSegmentIntersection: segB must have x and y properties");let K=J.x.minus($.x),q=J.y.minus($.y),H=Q.x.minus(Z.x),W=Q.y.minus(Z.y),j=K.mul(W).minus(q.mul(H));if(j.abs().lt(M7))return null;let z=Z.x.minus($.x),G=Z.y.minus($.y),F=z.mul(q).minus(G.mul(K)).div(j);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 K=0;K<Z;K++)if(!J[K]||J[K].x===null||J[K].x===void 0||J[K].y===null||J[K].y===void 0)throw new Error(`pointInPolygon: polygon[${K}] must have x and y properties`);let Q=0;for(let K=0;K<Z;K++){let q=J[K],H=J[(K+1)%Z];if(B9($,q,H))return 0;if(q.y.lte($.y)){if(H.y.gt($.y)){if(n7(q,H,$).gt(0))Q++}}else if(H.y.lte($.y)){if(n7(q,H,$).lt(0))Q--}}return Q!==0?1:-1}function B9($,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(n7(J,Z,$).abs().gt(M7))return!1;let K=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(K.minus(M7))&&$.x.lte(q.plus(M7))&&$.y.gte(H.minus(M7))&&$.y.lte(W.plus(M7))}function N9($,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 K=0;K<$.length;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`clipPolygonSH: subject[${K}] must have x and y properties`);for(let K=0;K<J.length;K++)if(!J[K]||J[K].x===null||J[K].x===void 0||J[K].y===null||J[K].y===void 0)throw new Error(`clipPolygonSH: clip[${K}] must have x and y properties`);let Z=$.map((K)=>f0(K.x,K.y)),Q=J.map((K)=>f0(K.x,K.y));Q=D6(Q);for(let K=0;K<Q.length;K++){if(Z.length===0)return[];let q=Q[K],H=Q[(K+1)%Q.length],W=Z;Z=[];for(let j=0;j<W.length;j++){let z=W[j],G=W[(j+W.length-1)%W.length],F=p8(z,q,H),_=p8(G,q,H);if(F){if(!_){let U=c8(G,z,q,H);if(U)Z.push(U)}Z.push(z)}else if(_){let U=c8(G,z,q,H);if(U)Z.push(U)}}}return Z}function p8($,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 n7(J,Z,$).gte(0)}function c8($,J,Z,Q){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(!Q||Q.x===null||Q.x===void 0||Q.y===null||Q.y===void 0)throw new Error("lineIntersection: point d must have x and y properties");let K=J.x.minus($.x),q=J.y.minus($.y),H=Q.x.minus(Z.x),W=Q.y.minus(Z.y),j=K.mul(W).minus(q.mul(H));if(j.abs().lt(M7))return null;let z=Z.x.minus($.x),G=Z.y.minus($.y),F=z.mul(W).minus(G.mul(H)).div(j);return{x:$.x.plus(K.mul(F)),y:$.y.plus(q.mul(F))}}function s$($){if(!Array.isArray($))throw new Error("polygonArea: polygon must be an array");let J=$.length;if(J<3)return B7(0);for(let Q=0;Q<J;Q++)if(!$[Q]||$[Q].x===null||$[Q].x===void 0||$[Q].y===null||$[Q].y===void 0)throw new Error(`polygonArea: polygon[${Q}] must have x and y properties`);let Z=B7(0);for(let Q=0;Q<J;Q++){let K=$[Q],q=$[(Q+1)%J];Z=Z.plus(K.x.mul(q.y).minus(q.x.mul(K.y)))}return Z.div(2)}function C9($){if(!Array.isArray($))throw new Error("isCounterClockwise: polygon must be an array");return s$($).gt(0)}function I9($){if(!Array.isArray($))throw new Error("reversePolygon: polygon must be an array");return[...$].reverse()}function D6($){if(!Array.isArray($))throw new Error("ensureCCW: polygon must be an array");if(!C9($))return I9($);return $}function P9($){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)=>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 new 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 Q=J[0],K=J.slice(1).sort((H,W)=>{let j=n7(Q,H,W);if(j.abs().lt(M7)){let G=H.x.minus(Q.x).pow(2).plus(H.y.minus(Q.y).pow(2)),F=W.x.minus(Q.x).pow(2).plus(W.y.minus(Q.y).pow(2)),_=G.minus(F);if(_.abs().lt(M7))return 0;return _.lt(0)?-1:1}return-R9(j)}),q=[Q];for(let H of K){while(q.length>1&&n7(q[q.length-2],q[q.length-1],H).lte(0))q.pop();q.push(H)}return q}function l7($){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),Q=B7($[0].x),K=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),j=B7(H.y);if(W.lt(J))J=W;if(j.lt(Z))Z=j;if(W.gt(Q))Q=W;if(j.gt(K))K=j}return{minX:J,minY:Z,maxX:Q,maxY:K}}function o$($,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 D7($,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)=>f0(H.x,H.y)),Q=J.map((H)=>f0(H.x,H.y)),K=l7(Z),q=l7(Q);if(!o$(K,q))return[];if(A9(Q)){let H=N9(Z,D6(Q));return H.length>=3?[H]:[]}return gq(Z,Q)}function A9($){if(!Array.isArray($))throw new Error("isConvex: polygon must be an array");let J=$.length;if(J<3)return!1;for(let Q=0;Q<J;Q++)if(!$[Q]||$[Q].x===null||$[Q].x===void 0||$[Q].y===null||$[Q].y===void 0)throw new Error(`isConvex: polygon[${Q}] must have x and y properties`);let Z=0;for(let Q=0;Q<J;Q++){let K=$[Q],q=$[(Q+1)%J],H=$[(Q+2)%J],W=n7(K,q,H),j=W.gt(0)?1:W.lt(0)?-1:0;if(j!==0){if(Z===0)Z=j;else if(Z!==j)return!1}}return!0}function gq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("generalPolygonIntersection: both arguments must be arrays");let Z=[];for(let j=0;j<$.length;j++){let z=$[j],G=$[(j+1)%$.length];for(let F=0;F<J.length;F++){let _=J[F],U=J[(F+1)%J.length],Y=v6(z,G,_,U);if(Y)Z.push(f0(Y.x,Y.y))}}let Q=$.filter((j)=>P7(j,J)>=0),K=J.filter((j)=>P7(j,$)>=0),q=[...Z,...Q,...K];if(q.length<3)return[];let H=xq(q);if(H.length<3)return[];let W=P9(H);return W.length>=3?[W]:[]}function xq($){if(!Array.isArray($))throw new Error("removeDuplicatePoints: points must be an array");let J=[];for(let Z of $){let Q=!1;for(let K of J)if(c7(Z,K)){Q=!0;break}if(!Q)J.push(Z)}return J}function V$($,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)=>f0(H.x,H.y)),Q=J.map((H)=>f0(H.x,H.y)),K=l7(Z),q=l7(Q);if(!o$(K,q))return[Z,Q];return mq(Z,Q)}function mq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryUnion: both arguments must be arrays");let Z=s8($,J);if(Z.length===0){let V=P7($[0],J),M=P7(J[0],$);if(V>0)return[J];else if(M>0)return[$];else return[$,J]}let Q=S6($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),K=S6(J,Z.map((V)=>({edgeIndex:V.edge2,t:V.t2,point:V.point,intersectionId:V.id}))),q=new Map;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).idx1=V}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).idx2=V}let H=1,W=-1;for(let V=0;V<Q.length;V++){let M=Q[V];if(M.intersectionId===void 0&&P7(M,J)<0){W=V;break}}if(W===-1){H=2;for(let V=0;V<K.length;V++){let M=K[V];if(M.intersectionId===void 0&&P7(M,$)<0){W=V;break}}}if(W===-1){let V=s$($).abs(),M=s$(J).abs();return V.gt(M)?[$]:[J]}let j=[],z=H===1,G=W,F=new Set,_=(Q.length+K.length)*3,U=0,Y=`${H}-${W}`;while(U<_){U++;let V=z?Q:K,M=z?K:Q,X=V[G];if(j.length===0||!c7(j[j.length-1],X))j.push(f0(X.x,X.y));let k=(G+1)%V.length,L=V[k];if(L.intersectionId!==void 0&&!F.has(L.intersectionId)){j.push(f0(L.x,L.y)),F.add(L.intersectionId);let B=q.get(L.intersectionId),I=z?B.idx2:B.idx1;z=!z,G=(I+1)%M.length}else G=k;if(`${z?1:2}-${G}`===Y)break}if(j.length>1&&c7(j[0],j[j.length-1]))j.pop();return j.length>=3?[j]:[]}function s8($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("findAllIntersections: both arguments must be arrays");let Z=[],Q=0;for(let K=0;K<$.length;K++){let q=$[K],H=$[(K+1)%$.length];for(let W=0;W<J.length;W++){let j=J[W],z=J[(W+1)%J.length],G=v6(q,H,j,z);if(G)Z.push({id:Q++,point:f0(G.x,G.y),edge1:K,edge2:W,t1:G.t,t2:G.s})}}return Z}function S6($,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 K of J){if(!Z.has(K.edgeIndex))Z.set(K.edgeIndex,[]);Z.get(K.edgeIndex).push(K)}for(let K of Z.values())K.sort((q,H)=>q.t.minus(H.t).toNumber());let Q=[];for(let K=0;K<$.length;K++)if(Q.push({...$[K]}),Z.has(K))for(let q of Z.get(K))Q.push({x:q.point.x,y:q.point.y,intersectionId:q.intersectionId});return Q}function o8($,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)=>f0(H.x,H.y)),Q=J.map((H)=>f0(H.x,H.y)),K=l7(Z),q=l7(Q);if(!o$(K,q))return[Z];return dq(Z,Q)}function dq($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryDifference: both arguments must be arrays");let Z=s8($,J);if(Z.length===0)if(P7($[0],J)>0)return[];else return[$];let Q=S6($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),K=S6(J,Z.map((U)=>({edgeIndex:U.edge2,t:U.t2,point:U.point,intersectionId:U.id}))),q=new Map;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).idx1=U}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).idx2=U}let H=-1;for(let U=0;U<Q.length;U++){let Y=Q[U];if(Y.intersectionId===void 0&&P7(Y,J)<0){H=U;break}}if(H===-1)return[];let W=[],j=!0,z=H,G=new Set,F=(Q.length+K.length)*3,_=0;while(_<F){_++;let Y=(j?Q:K)[z];if(W.length===0||!c7(W[W.length-1],Y))W.push(f0(Y.x,Y.y));let V=`${j?1:2}-${z}`;if(G.has(V))break;if(G.add(V),j){let M=(z+1)%Q.length,X=Q[M];if(X.intersectionId!==void 0){let k=Q[(M+1)%Q.length];if(P7(k,J)>0){let R=q.get(X.intersectionId);W.push(f0(X.x,X.y)),j=!1,z=(R.idx2-1+K.length)%K.length}else z=M}else z=M}else{let M=(z-1+K.length)%K.length,X=K[M];if(X.intersectionId!==void 0){let k=q.get(X.intersectionId);W.push(f0(X.x,X.y)),j=!0,z=(k.idx1+1)%Q.length}else z=M}if(j&&z===H)break}if(W.length>1&&c7(W[0],W[W.length-1]))W.pop();return W.length>=3?[W]:[]}var pq={point:f0,pointsEqual:c7,cross:n7,dot:n8,sign:R9,segmentIntersection:v6,lineSegmentIntersection:l8,pointInPolygon:P7,pointOnSegment:B9,clipPolygonSH:N9,polygonArea:s$,isCounterClockwise:C9,reversePolygon:I9,ensureCCW:D6,isConvex:A9,convexHull:P9,boundingBox:l7,bboxIntersects:o$,polygonIntersection:D7,polygonUnion:V$,polygonDifference:o8,EPSILON:M7};O.set({precision:80});var h6=($)=>$ instanceof O?$:new O($),s7=new O("1e-40"),{point:q$,cross:E9,polygonIntersection:C4,polygonUnion:I4,polygonDifference:P4}=h7,H$={NONZERO:"nonzero",EVENODD:"evenodd"};function y6($,J,Z=H$.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 Q=J.length;if(Q<3)return-1;let K=0;for(let q=0;q<Q;q++){let H=J[q],W=J[(q+1)%Q];if(cq($,H,W))return 0;if(H.y.lte($.y)){if(W.y.gt($.y)){if(E9(H,W,$).gt(0))K++}}else if(W.y.lte($.y)){if(E9(H,W,$).lt(0))K--}}if(Z===H$.EVENODD)return Math.abs(K)%2===1?1:-1;else return K!==0?1:-1}function cq($,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(E9(J,Z,$).abs().gt(s7))return!1;let K=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(K.minus(s7))&&$.x.lte(q.plus(s7))&&$.y.gte(H.minus(s7))&&$.y.lte(W.plus(s7))}function nq($,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 Q=h6(J);if(Q.lte(0))throw new Error("offsetPolygon: distance must be positive");let K=Z.linejoin||"miter",q=h6(Z.miterLimit||4);if($.length<3)return{outer:[],inner:[]};let H=$.length,W=[],j=[];for(let z=0;z<H;z++){let G=$[(z-1+H)%H],F=$[z],_=$[(z+1)%H],U=F.x.minus(G.x),Y=F.y.minus(G.y),V=_.x.minus(F.x),M=_.y.minus(F.y),X=U.pow(2).plus(Y.pow(2)).sqrt(),k=V.pow(2).plus(M.pow(2)).sqrt();if(X.lt(s7)||k.lt(s7))continue;let L=Y.div(X),R=U.neg().div(X),B=M.div(k),I=V.neg().div(k),h=L.plus(B).div(2),g=R.plus(I).div(2),f=h.pow(2).plus(g.pow(2)).sqrt();if(f.lt(s7))h=L,g=R;else h=h.div(f),g=g.div(f);let x=L.times(B).plus(R.times(I)),D=h6(1).minus(x).div(2).sqrt(),T=Q;if(D.gt(s7)){let d=Q.div(D);if(K==="miter"&&d.lte(Q.times(q)))T=d;else if(K==="bevel"||d.gt(Q.times(q))){let c=q$(F.x.plus(L.times(Q)),F.y.plus(R.times(Q))),p=q$(F.x.plus(B.times(Q)),F.y.plus(I.times(Q)));W.push(c,p);let C=q$(F.x.minus(L.times(Q)),F.y.minus(R.times(Q))),y=q$(F.x.minus(B.times(Q)),F.y.minus(I.times(Q)));j.push(C,y);continue}else if(K==="round"){let c=Math.atan2(R.toNumber(),L.toNumber()),C=Math.atan2(I.toNumber(),B.toNumber())-c;if(C<-Math.PI)C+=2*Math.PI;if(C>Math.PI)C-=2*Math.PI;let y=Math.max(2,Math.ceil(Math.abs(C)/(Math.PI/8)));for(let N=0;N<=y;N++){let e=c+C*(N/y);W.push(q$(F.x.plus(Q.times(Math.cos(e))),F.y.plus(Q.times(Math.sin(e))))),j.push(q$(F.x.minus(Q.times(Math.cos(e))),F.y.minus(Q.times(Math.sin(e)))))}continue}}W.push(q$(F.x.plus(h.times(T)),F.y.plus(g.times(T)))),j.push(q$(F.x.minus(h.times(T)),F.y.minus(g.times(T))))}return{outer:W,inner:j.reverse()}}function T9($,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=h6(J.width).div(2);if(Z.lte(0))throw new Error("strokeToFilledPolygon: width must be positive");return nq($,Z,J).outer}O.set({precision:80});var y7=($)=>$ instanceof O?$:new O($),lq={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 u6{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=y7(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"&&y7(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={...lq,...J||{}};if($&&$.getAttributeNames)for(let K of $.getAttributeNames()){let q=$.getAttribute(K);if(q!==null&&q!==void 0)Z[K]=q}if(Z.style){let K=this._parseStyleAttribute(Z.style);Object.assign(Z,K)}let Q=["stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity"];for(let K of Q)if(typeof Z[K]==="string"){let q=parseFloat(Z[K]);if(!isNaN(q))Z[K]=q}return Z}_parseStyleAttribute($){let J={};if(!$)return J;let Z=$.split(";");for(let Q of Z){if(!Q.includes(":"))continue;let[K,q]=Q.split(":").map((H)=>H.trim());if(K&&q)J[K]=q}return J}_parseDashArray($){if(!$||$==="none")return null;let J=$.toString().split(/[\s,]+/).filter((Q)=>Q),Z=[];for(let Q of J){let K=parseFloat(Q);if(isNaN(K)||!isFinite(K))throw new Error(`_parseDashArray: invalid dash value '${Q}'`);if(K<0)throw new Error(`_parseDashArray: dash values must be non-negative, got ${K}`);Z.push(y7(K))}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 y7(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return y7(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return y7(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=y7(0);if(J){if(typeof J!=="object")throw new Error("expandBBoxForMarkers: markerSizes must be an object");let K=[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 y7(H)});if(K.length>0)Z=O.max(...K)}else Z=this.strokeWidth.times(3);if(Z.lte(0))return $;let Q=Z.div(2);return{x:$.x.minus(Q),y:$.y.minus(Q),width:$.width.plus(Q.times(2)),height:$.height.plus(Q.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 Q=$.width.times("0.1"),K=$.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}'`);Q=y7(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}'`);K=y7(q).abs()}}return{x:$.x.minus(Q),y:$.y.minus(K),width:$.width.plus(Q.times(2)),height:$.height.plus(K.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=T9($,{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"?H$.EVENODD:H$.NONZERO;if(y6($,J,Z)>=0)return!0}if(this.hasStroke){let Z=T9(J,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0){if(y6($,Z,H$.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof u6))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 i$($,J={},Z=null){if(!$)throw new Error("createRenderingContext: element parameter is required");return new u6($,J,Z)}function r$($){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 Q=$.parentNode;while(Q&&Q.tagName){for(let K of Z)if(J[K]===void 0){let q=Q.getAttribute?Q.getAttribute(K):null;if(q!==null&&q!==void 0)J[K]=q}Q=Q.parentNode}return J}var b9={};d7(b9,{serializeSVG:()=>q7,parseUrlReference:()=>g7,parseSVG:()=>x0,findElementsWithAttribute:()=>A7,default:()=>iq,buildDefsMap:()=>u7,SVGElement:()=>w0});function t8($,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)t8(Z,J)}function x0($){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=$5(J,0);if(!Z.element)throw new Error("Failed to parse SVG: no root element found");let Q=new e8(Z.element);return t8(Z.element,Q),Z.element}class e8{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=[],Q=""){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 Q!=="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=Q,this.parentNode=null,this.ownerDocument=null;for(let K of Z)if(K instanceof w0)K.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=[],Q=(K)=>{for(let q of K.children)if(q instanceof w0){if(q.tagName.toLowerCase()===J||J==="*")Z.push(q);Q(q)}};return Q(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 Q of Z.children)if(Q instanceof w0){let K=J(Q);if(K)return K}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=i8($),Q=(K)=>{for(let q of K.children)if(q instanceof w0){if(r8(q,Z))J.push(q);Q(q)}};return Q(this),J}matches($){if(typeof $!=="string")throw new Error("matches: selector must be a string");let J=i8($);return r8(this,J)}cloneNode($=!0){if(typeof $!=="boolean")throw new Error("cloneNode: deep must be a boolean");let J=$?this.children.map((Q)=>Q instanceof w0?Q.cloneNode(!0):Q):[],Z=new w0(this.tagName,{...this._attributes},J,this.textContent);if(this.ownerDocument){let Q=(K,q)=>{K.ownerDocument=q;for(let H of K.children)if(H instanceof w0)Q(H,q)};Q(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 Q=Z.indexOf(":");if(Q>0){let K=Z.slice(0,Q).trim(),q=Z.slice(Q+1).trim();if(K&&q)J[K]=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($),Q=this._attributes["data-cdata-pending"]==="true",K=Object.entries(this._attributes).filter(([z])=>z!=="data-cdata-pending").map(([z,G])=>`${z}="${sq(G)}"`).join(" "),q=K?" "+K:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${q}/>`;let H=J?"":`
|
|
10
|
+
`,W=this.children.map((z)=>z instanceof w0?z.serialize($+1,J):g6(z)).join(H),j="";if(this.textContent&&this.children.length>0)if(Q)j=`<![CDATA[
|
|
11
11
|
${this.textContent}
|
|
12
|
-
]]>`+H+W;else
|
|
12
|
+
]]>`+H+W;else j=g6(this.textContent)+H+W;else if(this.textContent)if(Q)j=`<![CDATA[
|
|
13
13
|
${this.textContent}
|
|
14
|
-
]]>`;else
|
|
15
|
-
`)}}function
|
|
16
|
-
`)+$.serialize(0,Z)}var
|
|
14
|
+
]]>`;else j=g6(this.textContent);else j=W;if(this.children.length===0)return`${Z}<${this.tagName}${q}>${j}</${this.tagName}>`;return`${Z}<${this.tagName}${q}>${H}${j}${H}${Z}</${this.tagName}>`}get outerHTML(){return this.serialize(0)}get innerHTML(){return this.children.map(($)=>$ instanceof w0?$.serialize(0):g6($)).join(`
|
|
15
|
+
`)}}function $5($,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 Q=J;while(Q<$.length){let Y=$.slice(Q).match(/^(\s+)/);if(Y){Q+=Y[1].length;continue}if($.slice(Q,Q+4)==="<!--"){let V=$.indexOf("-->",Q+4);if(V===-1)break;Q=V+3;continue}if($.slice(Q,Q+9)==="<![CDATA["){let V=$.indexOf("]]>",Q+9);if(V===-1)break;Q=V+3;continue}if($.slice(Q,Q+2)==="<?"){let V=$.indexOf("?>",Q+2);if(V===-1)break;Q=V+2;continue}if($.slice(Q,Q+9).toUpperCase()==="<!DOCTYPE"){let V=0,M=Q+9;while(M<$.length){if($[M]==="[")V++;else if($[M]==="]")V--;else if($[M]===">"&&V===0){Q=M+1;break}M++}if(M>=$.length)break;continue}break}if(Q>=$.length||$[Q]!=="<")return{element:null,endPos:Q};let K=$.slice(Q).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!K)return{element:null,endPos:Q};let q=K[1];Q+=K[0].length;let H={};while(Q<$.length){let Y=$.slice(Q).match(/^(\s+)/);if(Y)Q+=Y[1].length;if($[Q]===">"){Q++;break}if($.slice(Q,Q+2)==="/>")return Q+=2,{element:new w0(q,H,[]),endPos:Q};let V=$.slice(Q).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let M=V[1],X=V[2]!==void 0?V[2]:V[3];H[M]=oq(X),Q+=V[0].length}else{let M=$.slice(Q).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(M)H[M[1]]="",Q+=M[0].length;else Q++}}let W=[],j="",z=`</${q}>`;while(Q<$.length){if($.slice(Q,Q+z.length).toLowerCase()===z.toLowerCase()){Q+=z.length;break}if($[Q]==="<"&&$[Q+1]!=="/"){if($.slice(Q,Q+9)==="<![CDATA["){let X=$.indexOf("]]>",Q+9);if(X!==-1){j+=$.slice(Q+9,X),Q=X+3;continue}}if($.slice(Q,Q+4)==="<!--"){let X=$.indexOf("-->",Q+4);if(X!==-1){Q=X+3;continue}}let Y=H["xml:space"],M=$5($,Q,Y==="preserve"?!0:Y==="default"?!1:Z);if(M.element)W.push(M.element),Q=M.endPos;else Q++}else if($[Q]==="<"&&$[Q+1]==="/"){let Y=$.slice(Q).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(Y&&Y[1].toLowerCase()===q.toLowerCase()){Q+=Y[0].length;break}Q++}else{let Y=$.indexOf("<",Q);if(Y===-1)j+=$.slice(Q),Q=$.length;else j+=$.slice(Q,Y),Q=Y}}let G=new w0(q,H,W,""),F=H["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?a8(j):a8(j.trim());return G.textContent=U,{element:G,endPos:Q}}function i8($){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=[],Q=J.split(/\s*,\s*/);for(let K of Q){let q={tag:null,id:null,classes:[],attrs:[]},H=K,W=H.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(W)q.tag=W[1].toLowerCase(),H=H.slice(W[0].length);let j=H.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(j)q.id=j[1],H=H.replace(j[0],"");let z=H.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of z)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 r8($,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 Q=($.getAttribute("class")||"").split(/\s+/).filter((K)=>K.length>0);for(let K of Z.classes)if(!Q.includes(K))return!1;for(let K of Z.attrs){if(!$.hasAttribute(K.name))return!1;if(K.value!==void 0&&$.getAttribute(K.name)!==K.value)return!1}return!0})}function g6($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function sq($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function oq($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let Q=parseInt(Z,16);if(!Number.isFinite(Q))return"�";if(Q===0||Q>=1&&Q<=8||Q>=11&&Q<=12||Q>=14&&Q<=31||Q===65534||Q===65535||Q>1114111||Q>=55296&&Q<=57343)return"�";return String.fromCodePoint(Q)}).replace(/&#(\d+);/g,(J,Z)=>{let Q=parseInt(Z,10);if(!Number.isFinite(Q))return"�";if(Q===0||Q>=1&&Q<=8||Q>=11&&Q<=12||Q>=14&&Q<=31||Q===65534||Q===65535||Q>1114111||Q>=55296&&Q<=57343)return"�";return String.fromCodePoint(Q)}).replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function a8($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let Q=parseInt(Z,16);if(!Number.isFinite(Q))return"�";if(Q===0||Q>=1&&Q<=8||Q>=11&&Q<=12||Q>=14&&Q<=31||Q===65534||Q===65535||Q>1114111||Q>=55296&&Q<=57343)return"�";return String.fromCodePoint(Q)}).replace(/&#(\d+);/g,(J,Z)=>{let Q=parseInt(Z,10);if(!Number.isFinite(Q))return"�";if(Q===0||Q>=1&&Q<=8||Q>=11&&Q<=12||Q>=14&&Q<=31||Q===65534||Q===65535||Q>1114111||Q>=55296&&Q<=57343)return"�";return String.fromCodePoint(Q)}).replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function u7($){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=(Q)=>{let K=Q.getAttribute("id");if(K)J.set(K,Q);for(let q of Q.children)if(q instanceof w0)Z(q)};return Z($),J}function A7($,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=[],Q=(K)=>{if(K.hasAttribute(J))Z.push(K);for(let q of K.children)if(q instanceof w0)Q(q)};return Q($),Z}function g7($){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 q7($,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?"":`
|
|
16
|
+
`)+$.serialize(0,Z)}var iq={parseSVG:x0,SVGElement:w0,buildDefsMap:u7,findElementsWithAttribute:A7,parseUrlReference:g7,serializeSVG:q7};var{appendFileSync:rq}=(()=>({}));var aq=100,tq=5000,a$={SILENT:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},f9={level:a$.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,Q)=>{if(typeof Q==="object"&&Q!==null){if(J.has(Q))return"[Circular]";J.add(Q)}return Q})}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>=aq)this.flush();if(!this._flushTimer)this._flushTimer=setInterval(()=>this.flush(),tq),this._flushTimer.unref()},flush(){if(!this.logToFile||this._buffer.length===0)return;try{let $=this._buffer.join(`
|
|
17
17
|
`)+`
|
|
18
|
-
`;uq(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<i$.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<i$.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<i$.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<i$.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 mq=K7;O.set({precision:80});var U0=($)=>$ instanceof O?$:new O($),r8=20;function Q$($,J=r8){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=dq($);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}`);s8(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}`);s8(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}`);o8(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}`);o8(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}`);i8(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}`);i8(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 pq(Z)}function dq($){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 s8($,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(_),Y=U.mul(_),V=F.mul(F),M=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(M.mul(W)),k=Y.mul(Z).plus(U0(3).mul(U).mul(F).mul(Q)).plus(U0(3).mul(_).mul(V).mul(H)).plus(M.mul(z));$.push(b0(X,k))}}function o8($,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)),Y=F.mul(Z).plus(U0(2).mul(G).mul(j).mul(Q)).plus(_.mul(H));$.push(b0(U,Y))}}function i8($,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),Y=U.cos(),V=U.sin(),M=J.minus(z).div(2),X=Z.minus(j).div(2),k=Y.mul(M).plus(V.mul(X)),w=Y.mul(X).minus(V.mul(M)),R=F.mul(F),I=_.mul(_),P=k.mul(k),h=w.mul(w),u=P.div(R).plus(h.div(I));if(u.gt(1)){let $0=u.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),I=_.mul(_)}let b=R.mul(I).minus(R.mul(h)).minus(I.mul(P));if(b=b.div(R.mul(h).plus(I.mul(P))),b.lt(0))b=U0(0);if(b=b.sqrt(),H===W)b=b.neg();let g=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=Y.mul(g).minus(V.mul(v)).plus(E),d=V.mul(g).plus(Y.mul(v)).plus(m),N=k.minus(g).div(K),y=w.minus(v).div(Q),B=k.neg().minus(g).div(K),t=w.neg().minus(v).div(Q),i=N.mul(N).plus(y.mul(y)).sqrt();if(i.eq(0)){T9.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)){T9.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=Y.mul(K.mul(N0)).minus(V.mul(Q.mul(h0))).plus(c),J0=V.mul(K.mul(N0)).plus(Y.mul(Q.mul(h0))).plus(d);$.push(b0(o,J0))}}function pq($){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=r8,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 z0))throw new Error("shapeToPolygon: ctm must be null or a Matrix instance");let Q;switch($.type){case"circle":if(K>4)Q=Y9($.cx||0,$.cy||0,$.r||0,K,10);else Q=P8(U0($.cx||0),U0($.cy||0),U0($.r||0));break;case"ellipse":if(K>4)Q=I6($.cx||0,$.cy||0,$.rx||0,$.ry||0,K,10);else Q=k9(U0($.cx||0),U0($.cy||0),U0($.rx||0),U0($.ry||0));break;case"rect":Q=A8(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=E8(U0($.x1||0),U0($.y1||0),U0($.x2||0),U0($.y2||0));break;case"polygon":Q=T8($.points||"");break;case"polyline":Q=b8($.points||"");break;case"path":Q=$.d||"";break;default:return[]}if($.transform){let q=mq($.transform);if(!(q instanceof z0))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 a8=($)=>$ instanceof O?$:new O($),t8=-0.1,e8=-0.1,$5=1.2,J5=1.2,g6={LUMINANCE:"luminance",ALPHA:"alpha"};function Z5($){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,t8):t8,J.y=J.y!==null?Z(J.y,e8):e8,J.width=J.width!==null?Z(J.width,$5):$5,J.height=J.height!==null?Z(J.height,J5):J5;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:a8(J.x).plus(H.x.mul(J.width)),y:a8(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!==g6.LUMINANCE&&J!==g6.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===g6.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||g6.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 K5($,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 Q5($){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:H5($)}}function q5($){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(x6(Q));return K}function x6($){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:H5($)},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(x6(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 H5($){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 z0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return z0.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 z0.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 l0(-H*k,-W*w).mul(U7(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=-W*U,M=Q*U,X=q*U;if(j.includes("xMid"))Y+=(J-M)/2;else if(j.includes("xMax"))Y+=J-M;if(j.includes("YMid"))V+=(Z-X)/2;else if(j.includes("YMax"))V+=Z-X;return l0(Y,V).mul(U7(U,U))}function f9($,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=l0($.x,$.y);if($.transform){let j=K7($.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=f9(j,J,{maxDepth:K-1,_visited:Q});if(G)W.push(G)}else W.push({element:j,transform:z0.identity(3)});return Q.delete($.href),{element:q,transform:H,children:W,inheritedStyle:$.style}}function W5($,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=W5(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 z5($,J=20){if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("resolvedUseToPathData: samples must be a positive finite number");let Z=W5($,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 z7=($)=>$ instanceof O?$:new O($);function j5($){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:z7(J.x).plus(z7($.x).mul(J.width)),y:z7(J.y).plus(z7($.y).mul(J.height)),width:z7($.width).mul(J.width),height:z7($.height).mul(J.height)};return{x:z7($.x),y:z7($.y),width:z7($.width),height:z7($.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=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 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(l0(G-Q.x*j,F-Q.y*j)),K=K.mul(U7(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(l0(Z.x,Z.y)),K=K.mul(U7(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:z7(K).plus(z7(q).mul(F)),y:z7(Q).plus(z7(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 _=l0(F.x,F.y);for(let U of $.children){let Y=z.mul(_.mul(W)),V=KH(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 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 G5($,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 z0.identity(3);return K7($)}O.set({precision:80});function S9($,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 _=z0.identity(3),U=l0(J.x,J.y);_=_.mul(U);let Y=0;if(j==="auto")Y=Z;else if(j==="auto-start-reverse")Y=Q?Z+Math.PI:Z;else if(typeof j==="number")Y=j*(Math.PI/180);if(Y!==0){let w=j$(Y);_=_.mul(w)}let V=1,M=1;if(G==="strokeWidth")V=K,M=K;let X=!1,k=1;if(F){let{width:w,height:R}=F;if(w>0&&R>0&&isFinite(w)&&isFinite(R)){let I=q/w,P=H/R;if(isFinite(I)&&isFinite(P))k=Math.min(I,P),X=!0,V*=k,M*=k}}if(X){let w=(W-F.x)*k,R=(z-F.y)*k,I=l0(-w,-R);if(_=_.mul(I),V!==1||M!==1){let h=U7(V,M);_=_.mul(h)}let P=l0(-F.x,-F.y);_=_.mul(P)}else{if(V!==1||M!==1){let R=U7(V,M);_=_.mul(R)}let w=l0(-W,-z);_=_.mul(w)}return _}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=F5($);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),Y=Z-z.x2,V=K-z.y2,M=Y===0&&V===0?Math.atan2(K-z.y1,Z-z.x1):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:M,tangentOut:M,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),Y=Z-z.x1,V=K-z.y1,M=Y===0&&V===0?Math.atan2(K-G,Z-j):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:M,tangentOut:M,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 F5($){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"),Y=G(W+3,"C.x2"),V=G(W+4,"C.y2"),M=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"?Y:z+Y,y2:F==="C"?V:j+V,x:F==="C"?M:z+M,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"),Y=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"?Y:z+Y,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"),Y=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),M=parseInt(q[W+5],10);if(isNaN(V)||isNaN(M))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:Y,largeArcFlag:V,sweepFlag:M,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 _5($,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],Y=j.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:S9(_,{x:U.x,y:U.y},Y,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 Y=j[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:S9(_,{x:Y.x,y:Y.y},k,W,!1),type:"mid",vertex:Y})}}if(q){let F=G(q),_=F?J[F]:null;if(_&&j.length>0){let U=j[j.length-1],Y=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:S9(_,{x:U.x,y:U.y},Y,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=F5($),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 U5($,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),A$=new O(1);function E$(){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 Y5($,J,Z){let K=E$();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,_),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: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 v9($){let J=E$();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?A$: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 V5($,J,Z=null){let K=E$(),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(!YH(j,J)){let G=MH(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 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=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),Y=_.minus(G),V=U.times(U).plus(Y.times(Y)),M;if(V.isZero())M=w5($,W);else{let X=O.max(t0,O.min(A$,K.minus(j).times(U).plus(Q.minus(G).times(Y)).div(V))),k=j.plus(X.times(U)),w=G.plus(X.times(Y));M=K.minus(k).pow(2).plus(Q.minus(w).pow(2)).sqrt()}if(M.lessThan(Z))Z=M}return Z}function X5($,J,Z){let K=E$();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=V5(Z,$),q=V5(Z,J),H=r$($),W=r$(J),z=r$(Z),j=O.min(H,W),G=z.lessThanOrEqualTo(j.times(A$.plus(K))),F=Q.valid&&q.valid&&G;return{valid:F,error:F?t0:A$,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 k5($,J,Z){let K=E$();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 r$($){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 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=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=E$(),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 Y=z.minus(H).times(q.minus(W)).minus(j.minus(W).times(Q.minus(H))).abs(),V=w5(J,Z);return Y.div(V.plus(K)).lessThan(K)}function w5($,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 L5($,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=!O5(z,Q,q),F=!O5(j,Q,q);if(G){if(H.push(z),!F)H.push(M5(z,j,Q,q))}else if(F)H.push(M5(z,j,Q,q))}if(H.length>=3)Z.push(H)}return Z}function R5($,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=r$($),W=J.length>=3?r$(J):t0,z=H.minus(W),j=W.lessThanOrEqualTo(H.times(A$.plus(Q))),G=z.greaterThanOrEqualTo(t0.minus(Q.times(H))),F=H.isZero()?A$: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 O5($,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 M5($,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 C5=["animate","animateTransform","animateMotion","animateColor","set"],B5=["href","xlink:href"],N5=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],wH=["begin","end"],LH=["values","from","to","by"];function D9($){if(!$||typeof $!=="string")return null;let J=$.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return J&&J[1]?J[1]:null}function I5($){if(!$||typeof $!=="string")return null;if($.startsWith("#")){let J=$.substring(1);return J&&!J.startsWith("#")?J:null}return null}function P5($){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=D9(Q);if(q)J.push(q)}return J}function A5($){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+(?:\.\d+)?[a-z]*)?/);if(q)J.push(q[1])}return J}function a$($){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 E5($){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=C5.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(B5.includes(q)){let W=I5(H);if(W)if(K)J.animation.add(W);else J.static.add(W)}if(N5.includes(q)||q==="style"){let W=D9(H);if(W)J.static.add(W);if(q==="style")a$(H).forEach((z)=>J.css.add(z))}if(wH.includes(q))A5(H).forEach((W)=>J.animation.add(W));if(LH.includes(q))P5(H).forEach((W)=>J.animation.add(W));if(!N5.includes(q)&&H.includes("url(")){let W=D9(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 B5){let z=H.getAttribute(W),j=I5(z);if(j)J.animation.add(j)}}}return J}function T5($){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||"";a$(_).forEach((U)=>K(U,"css","<style>"))}if(W==="script"){let _=q.textContent||"";E5(_).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 B7=($)=>$ 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 b$($,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:Q7(Q),stats:K}}catch(Q){return K.errors.push(`Pipeline error: ${Q.message}`),{svg:$,stats:K}}}var v5=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),D5=new Set(["foreignobject","audio","video","iframe","script","style",...v5]);function h9($){if(!$)return!1;let J=$.tagName?.toLowerCase();if(D5.has(J))return!0;for(let Z of $.children||[])if(Z&&Z.tagName&&h9(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]=q5(z),H[W].type="symbol";else H[W]=x6(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=h9(G),_=h9(W);if(F||_){let M=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 u=`translate(${X}, ${k})`;R=R?`${R} ${u}`:u}let I=new w0("g",{});if(R)I.setAttribute("transform",R);let P=t$(W);for(let[u,b]of Object.entries(P))if(b&&!I.hasAttribute(u))I.setAttribute(u,b);if(G.tagName.toLowerCase()==="symbol"){for(let u of M.children||[])if(u&&u.tagName)I.appendChild(u.cloneNode(!0))}else M.removeAttribute("id"),I.appendChild(M);for(let u of W.children||[])if(u&&u.tagName){let b=u.tagName.toLowerCase();if(v5.has(b))I.appendChild(u.cloneNode(!0))}if(W.parentNode)W.parentNode.replaceChild(I,W),Q++;continue}let U=Q5(W),Y=f9(U,H,{samples:Z.curveSegments});if(!Y){K.push(`use: failed to resolve #${j}`);continue}let V=z5(Y,Z.curveSegments);if(V){let M=new w0("path",{d:V,...t$(W)});if(Y.style){for(let[X,k]of Object.entries(Y.style))if(k&&!M.hasAttribute(X))M.setAttribute(X,k)}if(W.parentNode)W.parentNode.replaceChild(M,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=P7($,H);for(let z of W){if(z.tagName!=="path"&&z.tagName!=="line"&&z.tagName!=="polyline"&&z.tagName!=="polygon")continue;try{let j=_5(z,Object.fromEntries(J));if(!j||j.length===0)continue;let G=U5(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=P7($,"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=h5(H);if(!U)continue;let Y=j5(j),V=G5(Y,U,{samples:Z.curveSegments});if(V){let M=new w0("g",{}),X=new w0("path",{d:V,fill:"#000"});if(M.appendChild(X),H.setAttribute("fill","none"),H.setAttribute("stroke",H.getAttribute("stroke")||"none"),H.parentNode)H.parentNode.insertBefore(M,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=P7($,"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 _=h5(H);if(!_)continue;let U=Z5(j),Y=K5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(Y){let V=T$(H,Z.precision);if(V){let M=Q$(V,Z.curveSegments),X=Q$(Y,Z.curveSegments),k=y5(M,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=P7($,"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=T$(W,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 P=T$(I,Z.precision);if(P)Y+=(Y?" ":"")+P}}if(!Y)continue;let V=Z.clipSegments||64,M=Q$(U,V),X=Q$(Y,V),k=y5(M,X),w=M.map((I)=>({x:I.x instanceof O?I.x:B7(I.x),y:I.y instanceof O?I.y:B7(I.y)})),R=X.map((I)=>({x:I.x instanceof O?I.x:B7(I.x),y:I.y instanceof O?I.y:B7(I.y)}));if(k&&k.length>2){let I=k.map((g)=>({x:g.x instanceof O?g.x:B7(g.x),y:g.y instanceof O?g.y:B7(g.y)})),P=X5(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 h=L5(w,R);K.clipOutsideFragments.push({elementId:W.getAttribute("id")||`clip-${q}`,clipPathId:j,fragments:h,visible:!1});let u=Z.e2eTolerance||"1e-10",b=R5(w,I,h,u);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 h=new w0("path",{d:I,...t$(W)});if(W.parentNode)W.parentNode.replaceChild(h,W),P=h}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=P7($,"transform");for(let H of q){let W=H.getAttribute("transform");if(!W)continue;try{let z=K7(W),j=v9(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=T$(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:B7(V.x),y:V.y instanceof O?V.y:B7(V.y)}));let U=C$(G,z,{precision:J.precision});for(let V=0;V<F.length;V++){let M=F[V],X=Y5(z,M.x,M.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,...t$(H)});for(let M of vH(H.tagName))V.removeAttribute(M);if(H.parentNode)H.parentNode.replaceChild(V,H),Y=V}Y.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=K7(q),W=J.mul(H);Q.setAttribute("transform",b5(W))}else Q.setAttribute("transform",b5(J))}else{let q=T$(Q,Z.precision);if(q){let H=Q.getAttribute("transform"),W=J;if(H){let F=K7(H);W=J.mul(F)}let z=v9(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,...t$(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=K7(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[Y,V]=c0(j,G,F),[M,X]=c0(j,_,U),k=k5({x1:G,y1:F,x2:_,y2:U},{x1:Y.toNumber(),y1:V.toNumber(),x2:M.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",Y.toFixed(J.precision)),W.setAttribute("y1",V.toFixed(J.precision)),W.setAttribute("x2",M.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=K7(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()),Y=parseFloat(W.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(Y)){K.push(`radialGradient: invalid coordinate/radius values for gradient ${W.getAttribute("id")||"unknown"}`);continue}if(Y<=0){K.push(`radialGradient: radius must be positive for gradient ${W.getAttribute("id")||"unknown"}`);continue}let[V,M]=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=Y*R;W.setAttribute("cx",V.toFixed(J.precision)),W.setAttribute("cy",M.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)a$(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(D5.has(W))continue;if(!K(H))q.removeChild(H),Z++}return{count:Z}}function T$($,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 A6(K("x"),K("y"),K("width"),K("height"),K("rx"),q,!1,J)}case"circle":return C6(K("cx"),K("cy"),K("r"),J);case"ellipse":return P6(K("cx"),K("cy"),K("rx"),K("ry"),J);case"line":return E6(K("x1"),K("y1"),K("x2"),K("y2"),J);case"polyline":return d$($.getAttribute("points")||"",J);case"polygon":return T6($.getAttribute("points")||"",J);default:return null}}function h5($){if(!$||!$.tagName)return null;let J=T$($,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 t$($){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 b5($){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 y5($,J){if(!$||$.length<3||!J||J.length<3)return $;if(v7&&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 W=0;W<Q.length;W++){let z=Q[W],j=Q[(W+1)%Q.length],G=f5(z,q,H),F=f5(j,q,H);if(G){if(Z.push(z),!F)Z.push(S5(z,j,q,H))}else if(F)Z.push(S5(z,j,q,H))}}return Z}function f5($,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 S5($,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:B7((Q+H)/2),y:B7((q+W)/2)};let U=((Q-z)*(j-F)-(q-j)*(z-G))/_;return{x:B7(Q+U*(H-Q)),y:B7(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 e$={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 $6={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"])},u5={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 y9={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 J6($,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+$/,""),q=q.replace(/\.$/,"");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 d6($){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 u9($,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)=>J6(Q,J)).join(" ")}).join("; ")}function p6($,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 g5($){let J=d6($);if(J.length===0)return!1;return J.every((Z)=>p6(Z))}function g9($,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(y9))if($.every((q,H)=>Math.abs(q-K[H])<J))return Z;return null}function x9($,J={}){let Z=J.precision??3,K=J.removeLinear!==!1,Q=d6($);if(Q.length===0)return{value:null,allLinear:!1,standardEasings:[]};let q=Q.every((z)=>p6(z)),H=Q.map((z)=>g9(z)).filter(Boolean);if(q&&K)return{value:null,allLinear:!0,standardEasings:H};return{value:u9(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)=>J6(Z,J)).join("; ")}function m9($,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 m6($,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 J6(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=x9(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=m9(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=m6(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=m6(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 x5($,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}}var p9={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 o0($){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=p9[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 N7($,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(p9[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 c9($,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(p9[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[Y,V]of Object.entries(j))if(typeof V!=="number"||!isFinite(V))throw new TypeError(`isCurveStraight: ${Y} 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 Y=Math.sqrt((Z-$)**2+(K-J)**2),V=Math.sqrt((Q-$)**2+(q-J)**2);return Math.max(Y,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 d9($,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 Y=H[F-1].includes(".");if(_.startsWith("-"))W+=_;else if(_.startsWith(".")&&Y)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 i0($,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}=d9(q,K,J,Q);Z+=H,K=q.command,Q=W}return Z}function n9($,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=o0($);if(j.length===0)return{d:$,originalLength:z,optimizedLength:z,savings:0};let G=0,F=0,_=0,U=0,Y=[];for(let M=0;M<j.length;M++){let X=j[M];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=N7(X,G,F),R=c9(X,G,F),I=d9(w,null,Z);X=d9(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=i0(Y,Z);return{d:V,originalLength:z,optimizedLength:V.length,savings:z-V.length}}function m5($,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=n9(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 d5($,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 Z6($,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=d5($[H],Q,q);if(W>Z)Z=W,K=H}if(Z>J){let H=Z6($.slice(0,K+1),J),W=Z6($.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=d5($[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 l9($,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 s9($,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 l9($,J*J);return Z6($,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 o9($){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 i9($,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(!o9($)||$.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=s9(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 j7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function G7($){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 F7($,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 a9($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;Z.forEach((Q)=>F7(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 i0(K,J)}function t9($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;return Z.forEach((K)=>F7(K)),i0(Z,J)}function e9($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;Z.forEach((z)=>F7(z));let K=0,Q=0,q=0,H=0,W=[];for(let z of Z){let j=c9(z,K,Q);W.push(j);let G=N7(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 i0(W,J)}function $J($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;Z.forEach((z)=>F7(z));let K=0,Q=0,q=0,H=0,W=[];for(let z of Z){let j=N7(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 i0(W,J)}function JJ($,J=0.000001,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((j)=>F7(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],Y=_?j.args[1]:q+j.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]}}z.push(G);let F=N7(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 i0(z,Z)}function ZJ($,J=0.000001,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((j)=>F7(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",Y=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(Y-H)<J&&Math.abs(V-W)<J)F={command:"z",args:[]}}z.push(F);let _=N7(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 i0(z,Z)}function f$(...$){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 p5($){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 c6($,J,Z,K,Q,q,H,W,z){p5($),f$(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 r9($,J,Z,K,Q,q){f$($,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){f$($,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=c6(G,$,J,Z,K,Q,q,H,W),_=r9(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,_=c6(F,$,J,Z,K,Q,q,H,W),U=r9(_.x,_.y,$,J,H,W);if(U>z)z=U}for(let G of[0.05,0.95]){let F=c6(G,$,J,Z,K,Q,q,H,W),_=r9(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 KJ($,J=0.5,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((j)=>F7(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],Y=_?j.args[1]:q+j.args[1],V=_?j.args[2]:Q+j.args[2],M=_?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,Y,V,M,X,k,J))G=_?{command:"L",args:[X,k]}:{command:"l",args:[X-Q,k-q]}}z.push(G);let F=N7(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 i0(z,Z)}function QJ($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;return Z.forEach((K)=>F7(K)),i0(Z,J)}function qJ($,J=3){if(j7($),G7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=o0($);if(Z.length===0)return $;Z.forEach((q)=>F7(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 i0(Q,J)}function HJ($,J=0.000001,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((j)=>F7(j));let Q=0,q=0,H=0,W=0,z=[];for(let j of K){let G=N7(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 i0(z,Z)}function iH($,J,Z,K,Q,q,H){p5($),f$(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){f$($,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=c6(_,$,J,Z,K,Q,q,H,W),Y=iH(_,$,J,z,j,H,W),V=Math.sqrt((U.x-Y.x)**2+(U.y-Y.y)**2);if(V>G)G=V}return G}function aH($,J,Z,K,Q,q,H,W,z){f$($,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 WJ($,J=0.5,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((j)=>F7(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],Y=_?j.args[1]:q+j.args[1],V=_?j.args[2]:Q+j.args[2],M=_?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,Y,V,M,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=N7(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 i0(z,Z)}function zJ($,J=0.000001,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((F)=>F7(F));let Q=0,q=0,H=0,W=0,z=null,j=null,G=[];for(let F of K){let _=F,U=N7(F,Q,q);if(U.command==="Q"&&z!==null){let Y=2*Q-z,V=2*q-j;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")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 i0(G,Z)}function jJ($,J=0.000001,Z=3){j7($),q$(J),G7(Z);let K=o0($);if(K.length===0)return $;K.forEach((F)=>F7(F));let Q=0,q=0,H=0,W=0,z=null,j=null,G=[];for(let F of K){let _=F,U=N7(F,Q,q);if(U.command==="C"&&z!==null){let Y=2*Q-z,V=2*q-j;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")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 i0(G,Z)}function GJ($,J=3){j7($),G7(J);let Z=o0($);if(Z.length===0)return $;Z.forEach((Q)=>F7(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 i0(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"]),VJ=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"]),OJ=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-")},o5=new Set(["foreignobject","script","style","title","desc","metadata"]),n6=new Map,CW=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw new Error("Both parameters must be strings");let Z=`${$}|${J}`;if(n6.has(Z))return n6.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 n6.set(Z,Q),Q},PW=()=>n6.clear(),S$=($,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 i5($){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
|
+
`;rq(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<a$.ERROR)return;let Z=this._format("ERROR",$),Q=J.length?" "+J.map((K)=>this._safeStringify(K)).join(" "):"";console.error(Z,...J),this._bufferWrite(Z+Q),this.flush()},warn($,...J){if(this.level<a$.WARN)return;let Z=this._format("WARN",$),Q=J.length?" "+J.map((K)=>this._safeStringify(K)).join(" "):"";console.warn(Z,...J),this._bufferWrite(Z+Q)},info($,...J){if(this.level<a$.INFO)return;let Z=this._format("INFO",$),Q=J.length?" "+J.map((K)=>this._safeStringify(K)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+Q)},debug($,...J){if(this.level<a$.DEBUG)return;let Z=this._format("DEBUG",$),Q=J.length?" "+J.map((K)=>this._safeStringify(K)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+Q)},shutdown(){if(this._flushTimer)clearInterval(this._flushTimer),this._flushTimer=null;this.flush()}};var eq=K7;O.set({precision:80});var U0=($)=>$ instanceof O?$:new O($),K5=20;function W$($,J=K5){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=[],Q=U0(0),K=U0(0),q=U0(0),H=U0(0),W=$H($);if(!Array.isArray(W))throw new Error("pathToPolygon: parsePathCommands must return an array");for(let j of W){let{type:z,args:G}=j;if(!Array.isArray(G))throw new Error(`pathToPolygon: command args must be an array for command ${z}`);switch(z){case"M":if(G.length<2)throw new Error(`pathToPolygon: M command requires 2 arguments, got ${G.length}`);Q=U0(G[0]),K=U0(G[1]),q=Q,H=K,Z.push(f0(Q,K));break;case"m":if(G.length<2)throw new Error(`pathToPolygon: m command requires 2 arguments, got ${G.length}`);Q=Q.plus(G[0]),K=K.plus(G[1]),q=Q,H=K,Z.push(f0(Q,K));break;case"L":if(G.length<2)throw new Error(`pathToPolygon: L command requires 2 arguments, got ${G.length}`);Q=U0(G[0]),K=U0(G[1]),Z.push(f0(Q,K));break;case"l":if(G.length<2)throw new Error(`pathToPolygon: l command requires 2 arguments, got ${G.length}`);Q=Q.plus(G[0]),K=K.plus(G[1]),Z.push(f0(Q,K));break;case"H":if(G.length<1)throw new Error(`pathToPolygon: H command requires 1 argument, got ${G.length}`);Q=U0(G[0]),Z.push(f0(Q,K));break;case"h":if(G.length<1)throw new Error(`pathToPolygon: h command requires 1 argument, got ${G.length}`);Q=Q.plus(G[0]),Z.push(f0(Q,K));break;case"V":if(G.length<1)throw new Error(`pathToPolygon: V command requires 1 argument, got ${G.length}`);K=U0(G[0]),Z.push(f0(Q,K));break;case"v":if(G.length<1)throw new Error(`pathToPolygon: v command requires 1 argument, got ${G.length}`);K=K.plus(G[0]),Z.push(f0(Q,K));break;case"C":if(G.length<6)throw new Error(`pathToPolygon: C command requires 6 arguments, got ${G.length}`);J5(Z,Q,K,U0(G[0]),U0(G[1]),U0(G[2]),U0(G[3]),U0(G[4]),U0(G[5]),J),Q=U0(G[4]),K=U0(G[5]);break;case"c":if(G.length<6)throw new Error(`pathToPolygon: c command requires 6 arguments, got ${G.length}`);J5(Z,Q,K,Q.plus(G[0]),K.plus(G[1]),Q.plus(G[2]),K.plus(G[3]),Q.plus(G[4]),K.plus(G[5]),J),Q=Q.plus(G[4]),K=K.plus(G[5]);break;case"Q":if(G.length<4)throw new Error(`pathToPolygon: Q command requires 4 arguments, got ${G.length}`);Z5(Z,Q,K,U0(G[0]),U0(G[1]),U0(G[2]),U0(G[3]),J),Q=U0(G[2]),K=U0(G[3]);break;case"q":if(G.length<4)throw new Error(`pathToPolygon: q command requires 4 arguments, got ${G.length}`);Z5(Z,Q,K,Q.plus(G[0]),K.plus(G[1]),Q.plus(G[2]),K.plus(G[3]),J),Q=Q.plus(G[2]),K=K.plus(G[3]);break;case"A":if(G.length<7)throw new Error(`pathToPolygon: A command requires 7 arguments, got ${G.length}`);Q5(Z,Q,K,U0(G[0]),U0(G[1]),U0(G[2]),G[3],G[4],U0(G[5]),U0(G[6]),J),Q=U0(G[5]),K=U0(G[6]);break;case"a":if(G.length<7)throw new Error(`pathToPolygon: a command requires 7 arguments, got ${G.length}`);Q5(Z,Q,K,U0(G[0]),U0(G[1]),U0(G[2]),G[3],G[4],Q.plus(G[5]),K.plus(G[6]),J),Q=Q.plus(G[5]),K=K.plus(G[6]);break;case"Z":case"z":Q=q,K=H;break;default:break}}return JH(Z)}function $H($){if(typeof $!=="string")throw new Error(`parsePathCommands: pathData must be a string, got ${typeof $}`);let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,Q;while((Q=Z.exec($))!==null){let K=Q[1],q=Q[2].trim(),H=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,W=q.length>0?Array.from(q.matchAll(H),(j)=>Number(j[0])):[];J.push({type:K,args:W})}return J}function J5($,J,Z,Q,K,q,H,W,j,z){if(!Array.isArray($))throw new Error("sampleCubicBezier: points must be an array");if(typeof z!=="number"||z<=0||!Number.isFinite(z))throw new Error(`sampleCubicBezier: samples must be a positive finite number, got ${z}`);if(!(J instanceof O)||!(Z instanceof O)||!(Q instanceof O)||!(K instanceof O)||!(q instanceof O)||!(H instanceof O)||!(W instanceof O)||!(j instanceof O))throw new Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let G=1;G<=z;G++){let F=U0(G).div(z),_=U0(1).minus(F),U=_.mul(_),Y=U.mul(_),V=F.mul(F),M=V.mul(F),X=Y.mul(J).plus(U0(3).mul(U).mul(F).mul(Q)).plus(U0(3).mul(_).mul(V).mul(q)).plus(M.mul(W)),k=Y.mul(Z).plus(U0(3).mul(U).mul(F).mul(K)).plus(U0(3).mul(_).mul(V).mul(H)).plus(M.mul(j));$.push(f0(X,k))}}function Z5($,J,Z,Q,K,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)||!(Q instanceof O)||!(K instanceof O)||!(q instanceof O)||!(H instanceof O))throw new Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let j=1;j<=W;j++){let z=U0(j).div(W),G=U0(1).minus(z),F=G.mul(G),_=z.mul(z),U=F.mul(J).plus(U0(2).mul(G).mul(z).mul(Q)).plus(_.mul(q)),Y=F.mul(Z).plus(U0(2).mul(G).mul(z).mul(K)).plus(_.mul(H));$.push(f0(U,Y))}}function Q5($,J,Z,Q,K,q,H,W,j,z,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)||!(Q instanceof O)||!(K instanceof O)||!(q instanceof O)||!(j instanceof O)||!(z 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(Q.eq(0)||K.eq(0)){$.push(f0(j,z));return}let F=Q.abs(),_=K.abs(),U=q.mul(Math.PI).div(180),Y=U.cos(),V=U.sin(),M=J.minus(j).div(2),X=Z.minus(z).div(2),k=Y.mul(M).plus(V.mul(X)),L=Y.mul(X).minus(V.mul(M)),R=F.mul(F),B=_.mul(_),I=k.mul(k),h=L.mul(L),g=I.div(R).plus(h.div(B));if(g.gt(1)){let $0=g.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),B=_.mul(_)}let f=R.mul(B).minus(R.mul(h)).minus(B.mul(I));if(f=f.div(R.mul(h).plus(B.mul(I))),f.lt(0))f=U0(0);if(f=f.sqrt(),H===W)f=f.neg();let x=f.mul(Q).mul(L).div(K),D=f.neg().mul(K).mul(k).div(Q),T=J.plus(j).div(2),d=Z.plus(z).div(2),c=Y.mul(x).minus(V.mul(D)).plus(T),p=V.mul(x).plus(Y.mul(D)).plus(d),C=k.minus(x).div(Q),y=L.minus(D).div(K),N=k.neg().minus(x).div(Q),e=L.neg().minus(D).div(K),r=C.mul(C).plus(y.mul(y)).sqrt();if(r.eq(0)){f9.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(f0(j,z));return}let s=O.acos(C.div(r));if(y.lt(0))s=s.neg();let q0=r.mul(N.mul(N).plus(e.mul(e)).sqrt());if(q0.eq(0)){f9.warn("sampleArc: degenerate arc - zero length, treating as single point"),$.push(f0(j,z));return}let v=O.acos(C.mul(N).plus(y.mul(e)).div(q0));if(C.mul(e).minus(y.mul(N)).lt(0))v=v.neg();let E=U0(Math.PI),t=E.mul(2);if(W&&v.lt(0))v=v.plus(t);else if(!W&&v.gt(0))v=v.minus(t);for(let $0=1;$0<=G;$0++){let K0=U0($0).div(G),V0=s.plus(v.mul(K0)),C0=V0.cos(),y0=V0.sin(),o=Y.mul(Q.mul(C0)).minus(V.mul(K.mul(y0))).plus(c),Z0=V.mul(Q.mul(C0)).plus(Y.mul(K.mul(y0))).plus(p);$.push(f0(o,Z0))}}function JH($){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(!c7($[Z],J[J.length-1]))J.push($[Z]);return J}function E$($,J=null,Z=K5,Q=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 Q!=="number"||Q<=0||!Number.isFinite(Q))throw new Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${Q}`);if(J!==null&&!(J instanceof W0))throw new Error("shapeToPolygon: ctm must be null or a Matrix instance");let K;switch($.type){case"circle":if(Q>4)K=k9($.cx||0,$.cy||0,$.r||0,Q,10);else K=D8(U0($.cx||0),U0($.cy||0),U0($.r||0));break;case"ellipse":if(Q>4)K=P6($.cx||0,$.cy||0,$.rx||0,$.ry||0,Q,10);else K=w9(U0($.cx||0),U0($.cy||0),U0($.rx||0),U0($.ry||0));break;case"rect":K=h8(U0($.x||0),U0($.y||0),U0($.width||0),U0($.height||0),U0($.rx||0),$.ry!==void 0?U0($.ry):null);break;case"line":K=y8(U0($.x1||0),U0($.y1||0),U0($.x2||0),U0($.y2||0));break;case"polygon":K=u8($.points||"");break;case"polyline":K=g8($.points||"");break;case"path":K=$.d||"";break;default:return[]}if($.transform){let q=eq($.transform);if(!(q instanceof W0))throw new Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof q}`);K=A$(K,q)}if(J)K=A$(K,J);return W$(K,Z)}function S9($,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=(K)=>(K instanceof O?K:U0(K)).toFixed(J).replace(/\.?0+$/,""),Q=`M ${Z($[0].x)} ${Z($[0].y)}`;for(let K=1;K<$.length;K++)Q+=` L ${Z($[K].x)} ${Z($[K].y)}`;return Q+" Z"}O.set({precision:80});O.set({precision:80});var q5=($)=>$ instanceof O?$:new O($),H5=-0.1,W5=-0.1,z5=1.2,j5=1.2,m6={LUMINANCE:"luminance",ALPHA:"alpha"};function G5($){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=(Q,K)=>{let q=parseFloat(Q);return isNaN(q)?K:q};if(J.maskUnits==="objectBoundingBox")J.x=J.x!==null?Z(J.x,H5):H5,J.y=J.y!==null?Z(J.y,W5):W5,J.width=J.width!==null?Z(J.width,z5):z5,J.height=J.height!==null?Z(J.height,j5):j5;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 Q of $.children){if(!Q.tagName)continue;let K=Q.tagName.toLowerCase(),q={type:K,fill:Q.getAttribute("fill")||Q.style?.fill||"black",fillOpacity:Z(Q.getAttribute("fill-opacity")||Q.style?.fillOpacity||"1",1),opacity:Z(Q.getAttribute("opacity")||Q.style?.opacity||"1",1),transform:Q.getAttribute("transform")||null};switch(K){case"rect":q.x=Z(Q.getAttribute("x")||"0",0),q.y=Z(Q.getAttribute("y")||"0",0),q.width=Z(Q.getAttribute("width")||"0",0),q.height=Z(Q.getAttribute("height")||"0",0),q.rx=Z(Q.getAttribute("rx")||"0",0),q.ry=Z(Q.getAttribute("ry")||"0",0);break;case"circle":q.cx=Z(Q.getAttribute("cx")||"0",0),q.cy=Z(Q.getAttribute("cy")||"0",0),q.r=Z(Q.getAttribute("r")||"0",0);break;case"ellipse":q.cx=Z(Q.getAttribute("cx")||"0",0),q.cy=Z(Q.getAttribute("cy")||"0",0),q.rx=Z(Q.getAttribute("rx")||"0",0),q.ry=Z(Q.getAttribute("ry")||"0",0);break;case"path":q.d=Q.getAttribute("d")||"";break;case"polygon":q.points=Q.getAttribute("points")||"";break;case"polyline":q.points=Q.getAttribute("points")||"";break;case"g":if(q.children=[],Q.children){for(let H of Q.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 QH($,J,Z,Q=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 Q!=="number"||Q<=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 K={type:$.type,...$,transform:$.transform},q=E$(K,null,Q);if(!Array.isArray(q))return[];if(Z==="objectBoundingBox"&&q.length>0){if(J.width===0||J.height===0)return[];q=q.map((H)=>({x:q5(J.x).plus(H.x.mul(J.width)),y:q5(J.y).plus(H.y.mul(J.height))}))}return q}function KH($){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 j=Math.max(0,Math.min(255,q))/255,z=Math.max(0,Math.min(255,H))/255,G=Math.max(0,Math.min(255,W))/255,F=0.2126*j+0.7152*z+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),j=parseInt(q.slice(4,6),16);if(isNaN(H)||isNaN(W)||isNaN(j))return 0;let z=0.2126*(H/255)+0.7152*(W/255)+0.0722*(j/255);return isNaN(z)?0:z}let Q={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},K=$.toLowerCase();if(Q[K]!==void 0)return Q[K];return 0}function qH($,J){if(!$)throw new Error("getMaskChildOpacity: child is required");if(!J)throw new Error("getMaskChildOpacity: maskType is required");if(J!==m6.LUMINANCE&&J!==m6.ALPHA)throw new Error('getMaskChildOpacity: maskType must be "luminance" or "alpha"');let Z=typeof $.fillOpacity==="number"&&!isNaN($.fillOpacity)?$.fillOpacity:1,Q=typeof $.opacity==="number"&&!isNaN($.opacity)?$.opacity:1,K=Z*Q;if(J===m6.ALPHA)return K;let q=KH($.fill),H=K*q;return isNaN(H)?0:H}function HH($,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:Q=20}=Z;if(typeof Q!=="number"||Q<=0)throw new Error("resolveMask: samples must be a positive number");let K=$.maskType||m6.LUMINANCE,q=[];for(let H of $.children){if(!H)continue;let W=QH(H,J,$.maskContentUnits,Q);if(W.length>=3){let j=qH(H,K);q.push({polygon:W,opacity:j})}}return q}function WH($,J,Z=0.5,Q={}){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 K=HH($,J,Q),q=[];for(let{polygon:H,opacity:W}of K)if(W>=Z&&H&&H.length>=3)if(q.length===0)q=H;else{let j=V$(q,H);if(j.length>0&&j[0].length>=3)q=j[0]}return q}function F5($,J,Z={}){if(!$)throw new Error("maskToPathData: maskData is required");if(!J)throw new Error("maskToPathData: targetBBox is required");let Q=WH($,J,0.5,Z);if(Q.length<3)return"";let K="",q=0;for(let H=0;H<Q.length;H++){let W=Q[H];if(!W||W.x===void 0||W.y===void 0)continue;let j=Number(W.x),z=Number(W.y);if(isNaN(j)||isNaN(z)||!isFinite(j)||!isFinite(z))continue;let G=j.toFixed(6),F=z.toFixed(6);K+=q===0?`M ${G} ${F}`:` L ${G} ${F}`,q++}if(q>=3)K+=" Z";else return"";return K}O.set({precision:80});function _5($){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 Q=parseFloat($.getAttribute("x")||"0"),K=parseFloat($.getAttribute("y")||"0");if(isNaN(Q)||isNaN(K)||!isFinite(Q)||!isFinite(K))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:Q,y:K,width:q,height:H,transform:$.getAttribute("transform")||null,style:V5($)}}function U5($){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 Q={id:$.getAttribute("id")||"",viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",children:[],refX:J,refY:Z};if(Q.viewBox){let K=Q.viewBox.trim().split(/[\s,]+/).map(Number);if(K.length===4&&K.every((q)=>!isNaN(q)&&isFinite(q)))Q.viewBoxParsed={x:K[0],y:K[1],width:K[2],height:K[3]}}for(let K of $.children)Q.children.push(d6(K));return Q}function d6($){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:V5($)},Q=(K,q="0")=>{let H=parseFloat($.getAttribute(K)||q);if(isNaN(H)||!isFinite(H))throw new Error(`parseChildElement: ${K} must be a valid finite number in ${J} element`);return H};switch(J){case"rect":Z.x=Q("x"),Z.y=Q("y"),Z.width=Q("width"),Z.height=Q("height"),Z.rx=Q("rx"),Z.ry=Q("ry");break;case"circle":Z.cx=Q("cx"),Z.cy=Q("cy"),Z.r=Q("r");break;case"ellipse":Z.cx=Q("cx"),Z.cy=Q("cy"),Z.rx=Q("rx"),Z.ry=Q("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=Q("x1"),Z.y1=Q("y1"),Z.x2=Q("x2"),Z.y2=Q("y2");break;case"g":Z.children=[];for(let K of $.children)Z.children.push(d6(K));break;case"use":Z.href=($.getAttribute("href")||$.getAttribute("xlink:href")||"").replace("#",""),Z.x=Q("x"),Z.y=Q("y"),Z.width=$.getAttribute("width")?Q("width"):null,Z.height=$.getAttribute("height")?Q("height"):null;break;default:break}return Z}function V5($){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 jH($,J,Z,Q="xMidYMid meet"){if(!$||!J||!Z)return W0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return W0.identity(3);let{width:K,height:q,x:H,y:W}=$;if(!isFinite(K)||!isFinite(q)||!isFinite(H)||!isFinite(W)||K<=0||q<=0)return W0.identity(3);let j=Q.trim().split(/\s+/),z=j[0]||"xMidYMid",G=j[1]||"meet";if(z==="none"){let k=J/K,L=Z/q;return s0(-H*k,-W*L).mul(V7(k,L))}let F=J/K,_=Z/q,U;if(G==="slice")U=Math.max(F,_);else U=Math.min(F,_);let Y=-H*U,V=-W*U,M=K*U,X=q*U;if(z.includes("xMid"))Y+=(J-M)/2;else if(z.includes("xMax"))Y+=J-M;if(z.includes("YMid"))V+=(Z-X)/2;else if(z.includes("YMax"))V+=Z-X;return s0(Y,V).mul(V7(U,U))}function v9($,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:Q=10,_visited:K=new Set}=Z;if(typeof Q!=="number"||Q<=0||!isFinite(Q))throw new Error("resolveUse: maxDepth must be a positive finite number");if(K.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;K.add($.href);let H=s0($.x,$.y);if($.transform){let z=K7($.transform);H=H.mul(z)}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 z=$.width!==null?$.width:q.viewBoxParsed.width,G=$.height!==null?$.height:q.viewBoxParsed.height;H=jH(q.viewBoxParsed,z,G,q.preserveAspectRatio||"xMidYMid meet").mul(H)}let W=[],j=q.children&&Array.isArray(q.children)&&q.children.length>0?q.children:[q];for(let z of j)if(z.type==="use"){if(Q<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${z.href}', skipping nested resolution`);continue}let G=v9(z,J,{maxDepth:Q-1,_visited:K});if(G)W.push(G)}else W.push({element:z,transform:W0.identity(3)});return K.delete($.href),{element:q,transform:H,children:W,inheritedStyle:$.style}}function O5($,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 Q of $.children){if(!Q||!Q.transform)continue;let K=$.transform.mul(Q.transform),q=Q.element;if(Q.children){let H=O5(Q,J);for(let W of H)W.polygon=W.polygon.map((j)=>{let[z,G]=n0($.transform,j.x,j.y);return{x:z,y:G}}),Z.push(W)}else{let H=GH(q,K,J);if(H.length>=3)Z.push({polygon:H,style:FH($.inheritedStyle,q.style)})}}return Z}function GH($,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 Q=E$($,null,Z);if(J&&Q.length>0)Q=Q.map((K)=>{let[q,H]=n0(J,K.x,K.y);return{x:q,y:H}});return Q}function FH($,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[Q,K]of Object.entries($||{}))if(K!==null&&(Z[Q]===null||Z[Q]===void 0))Z[Q]=K;return Z}function Y5($,J=20){if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("resolvedUseToPathData: samples must be a positive finite number");let Z=O5($,J),Q=[];for(let{polygon:K}of Z)if(K.length>=3){let q="";for(let H=0;H<K.length;H++){let W=K[H],j=Number(W.x),z=Number(W.y);if(isNaN(j)||isNaN(z))continue;q+=H===0?`M ${j.toFixed(6)} ${z.toFixed(6)}`:` L ${j.toFixed(6)} ${z.toFixed(6)}`}q+=" Z",Q.push(q)}return Q.join(" ")}O.set({precision:80});var G7=($)=>$ instanceof O?$:new O($);function M5($){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=(Q,K)=>{if(Q===null||Q===void 0)return K;let q=parseFloat(Q);return isNaN(q)?K: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 Q=J.viewBox.trim().split(/[\s,]+/).map(Number);if(Q.length===4&&Q.every((K)=>!isNaN(K)&&isFinite(K)))J.viewBoxParsed={x:Q[0],y:Q[1],width:Q[2],height:Q[3]}}if($.children&&typeof $.children[Symbol.iterator]==="function")for(let Q of $.children){if(!Q||typeof Q.getAttribute!=="function")continue;let K=Q.tagName?Q.tagName.toLowerCase():"";if(!K)continue;let q={type:K,fill:Q.getAttribute("fill")||"black",stroke:Q.getAttribute("stroke")||"none",strokeWidth:Z(Q.getAttribute("stroke-width"),1),opacity:Z(Q.getAttribute("opacity"),1),transform:Q.getAttribute("transform")||null};switch(K){case"rect":q.x=Z(Q.getAttribute("x"),0),q.y=Z(Q.getAttribute("y"),0),q.width=Z(Q.getAttribute("width"),0),q.height=Z(Q.getAttribute("height"),0),q.rx=Z(Q.getAttribute("rx"),0),q.ry=Z(Q.getAttribute("ry"),0);break;case"circle":q.cx=Z(Q.getAttribute("cx"),0),q.cy=Z(Q.getAttribute("cy"),0),q.r=Z(Q.getAttribute("r"),0);break;case"ellipse":q.cx=Z(Q.getAttribute("cx"),0),q.cy=Z(Q.getAttribute("cy"),0),q.rx=Z(Q.getAttribute("rx"),0),q.ry=Z(Q.getAttribute("ry"),0);break;case"path":q.d=Q.getAttribute("d")||"";break;case"polygon":q.points=Q.getAttribute("points")||"";break;case"polyline":q.points=Q.getAttribute("points")||"";break;case"line":q.x1=Z(Q.getAttribute("x1"),0),q.y1=Z(Q.getAttribute("y1"),0),q.x2=Z(Q.getAttribute("x2"),0),q.y2=Z(Q.getAttribute("y2"),0);break;case"use":q.href=Q.getAttribute("href")||Q.getAttribute("xlink:href")||"",q.x=Z(Q.getAttribute("x"),0),q.y=Z(Q.getAttribute("y"),0);break;case"g":if(q.children=[],Q.children&&typeof Q.children[Symbol.iterator]==="function"){for(let H of Q.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 UH($,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:G7(J.x).plus(G7($.x).mul(J.width)),y:G7(J.y).plus(G7($.y).mul(J.height)),width:G7($.width).mul(J.width),height:G7($.height).mul(J.height)};return{x:G7($.x),y:G7($.y),width:G7($.width),height:G7($.height)}}function VH($,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 Q=W0.identity(3);if($.viewBoxParsed){let K=$.viewBoxParsed;if(typeof K.x!=="number"||typeof K.y!=="number"||typeof K.width!=="number"||typeof K.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(K.width===0||K.height===0)throw new Error("getPatternContentTransform: viewBox width and height must be non-zero");let W=q/K.width,j=H/K.height,z=Math.min(W,j);if(!isFinite(z))throw new Error("getPatternContentTransform: computed scale is not finite");let G=(q-K.width*z)/2,F=(H-K.height*z)/2;Q=Q.mul(s0(G-K.x*z,F-K.y*z)),Q=Q.mul(V7(z,z))}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");Q=Q.mul(s0(Z.x,Z.y)),Q=Q.mul(V7(Z.width,Z.height))}return Q}function OH($,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 Q={type:$.type,...$,transform:$.transform},K=E$(Q,null,Z);if(!Array.isArray(K))return[];if(J&&K.length>0)K=K.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]=n0(J,q.x,q.y);return{x:H,y:W}});return K}function YH($,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=[],Q=Number($.x),K=Number($.y),q=Number($.width),H=Number($.height);if(!isFinite(Q)||!isFinite(K)||!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-Q)/q),j=Math.ceil((J.x+J.width-Q)/q),z=Math.floor((J.y-K)/H),G=Math.ceil((J.y+J.height-K)/H);if(!isFinite(W)||!isFinite(j)||!isFinite(z)||!isFinite(G))throw new Error("getTilePositions: computed tile indices are not finite");for(let F=W;F<j;F++)for(let _=z;_<G;_++)Z.push({x:G7(Q).plus(G7(q).mul(F)),y:G7(K).plus(G7(H).mul(_))});return Z}function MH($,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:Q=20,maxTiles:K=1000}=Z,q=[],H=UH($,J);if(Number(H.width)<=0||Number(H.height)<=0)return q;let W=VH($,H,J),j=kH($.patternTransform),G=YH(H,J).slice(0,K);for(let F of G){let _=s0(F.x,F.y);for(let U of $.children){let Y=j.mul(_.mul(W)),V=OH(U,Y,Q);if(V.length>=3)q.push({polygon:V,fill:U.fill,stroke:U.stroke,strokeWidth:U.strokeWidth,opacity:U.opacity})}}return q}function XH($,J,Z={}){if(!$)throw new Error("patternToClipPath: patternData is required");if(!J)throw new Error("patternToClipPath: targetBBox is required");let Q=MH($,J,Z),K=[];for(let{polygon:q,opacity:H}of Q)if(H>0&&q.length>=3)if(K.length===0)K=q;else{let W=V$(K,q);if(Array.isArray(W)&&W.length>0&&Array.isArray(W[0])&&W[0].length>=3)K=W[0]}return K}function X5($,J,Z={}){if(!$)throw new Error("patternToPathData: patternData is required");if(!J)throw new Error("patternToPathData: targetBBox is required");let Q=XH($,J,Z);if(!Array.isArray(Q))return"";if(Q.length<3)return"";let K="";for(let q=0;q<Q.length;q++){let H=Q[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),j=Number(H.y).toFixed(6);K+=q===0?`M ${W} ${j}`:` L ${W} ${j}`}return K+=" Z",K}function kH($){if(!$)return W0.identity(3);return K7($)}O.set({precision:80});function D9($,J,Z,Q=1,K=!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 Q!=="number"||isNaN(Q)||Q<=0)throw new Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:q,markerHeight:H,refX:W,refY:j,orient:z,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 j!=="number"||!isFinite(j))throw new Error("getMarkerTransform: markerDef.refY must be a finite number");let _=W0.identity(3),U=s0(J.x,J.y);_=_.mul(U);let Y=0;if(z==="auto")Y=Z;else if(z==="auto-start-reverse")Y=K?Z+Math.PI:Z;else if(typeof z==="number")Y=z*(Math.PI/180);if(Y!==0){let L=F$(Y);_=_.mul(L)}let V=1,M=1;if(G==="strokeWidth")V=Q,M=Q;let X=!1,k=1;if(F){let{width:L,height:R}=F;if(L>0&&R>0&&isFinite(L)&&isFinite(R)){let B=q/L,I=H/R;if(isFinite(B)&&isFinite(I))k=Math.min(B,I),X=!0,V*=k,M*=k}}if(X){let L=(W-F.x)*k,R=(j-F.y)*k,B=s0(-L,-R);if(_=_.mul(B),V!==1||M!==1){let h=V7(V,M);_=_.mul(h)}let I=s0(-F.x,-F.y);_=_.mul(I)}else{if(V!==1||M!==1){let R=V7(V,M);_=_.mul(R)}let L=s0(-W,-j);_=_.mul(L)}return _}function wH($){if(typeof $!=="string")throw new Error("getPathVertices: pathData must be a string");let J=[],Z=0,Q=0,K=0,q=0,H=k5($);for(let W=0;W<H.length;W++){let j=H[W],z=Z,G=Q;switch(j.type){case"M":if(Z=j.x,Q=j.y,K=Z,q=Q,J.length>0){let F=J[J.length-1],_=Math.atan2(Q-G,Z-z);F.tangentOut=_}J.push({x:Z,y:Q,tangentIn:0,tangentOut:0,index:J.length});break;case"L":{Z=j.x,Q=j.y;let F=Z-z,_=Q-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:Q,tangentIn:U,tangentOut:U,index:J.length});break}case"C":{Z=j.x,Q=j.y;let F=j.x1-z,_=j.y1-G,U=F===0&&_===0?Math.atan2(j.y2-G,j.x2-z):Math.atan2(_,F),Y=Z-j.x2,V=Q-j.y2,M=Y===0&&V===0?Math.atan2(Q-j.y1,Z-j.x1):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:Q,tangentIn:M,tangentOut:M,index:J.length});break}case"Q":{Z=j.x,Q=j.y;let F=j.x1-z,_=j.y1-G,U=F===0&&_===0?Math.atan2(Q-G,Z-z):Math.atan2(_,F),Y=Z-j.x1,V=Q-j.y1,M=Y===0&&V===0?Math.atan2(Q-G,Z-z):Math.atan2(V,Y);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:Q,tangentIn:M,tangentOut:M,index:J.length});break}case"A":{Z=j.x,Q=j.y;let F=Z-z,_=Q-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:Q,tangentIn:U,tangentOut:U,index:J.length});break}case"Z":{Z=K,Q=q;let F=Z-z,_=Q-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 k5($){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(),Q=/[MmLlHhVvCcSsQqTtAaZz]/,K=/-?(?:\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(Q.test(Z[H]))q.push(Z[H]),H++;else{K.lastIndex=H;let F=K.exec(Z);if(F&&F.index===H)q.push(F[0]),H=K.lastIndex;else H++}}let W=0,j=0,z=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"?_:j+_,y:F==="M"?U:z+U}),j=J[J.length-1].x,z=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"?_:j+_,y:F==="L"?U:z+U}),j=J[J.length-1].x,z=J[J.length-1].y,W+=3;break}case"H":{let _=G(W+1,"H.x");J.push({type:"L",x:F==="H"?_:j+_,y:z}),j=J[J.length-1].x,W+=2;break}case"V":{let _=G(W+1,"V.y");J.push({type:"L",x:j,y:F==="V"?_:z+_}),z=J[J.length-1].y,W+=2;break}case"C":{let _=G(W+1,"C.x1"),U=G(W+2,"C.y1"),Y=G(W+3,"C.x2"),V=G(W+4,"C.y2"),M=G(W+5,"C.x"),X=G(W+6,"C.y");J.push({type:"C",x1:F==="C"?_:j+_,y1:F==="C"?U:z+U,x2:F==="C"?Y:j+Y,y2:F==="C"?V:z+V,x:F==="C"?M:j+M,y:F==="C"?X:z+X}),j=J[J.length-1].x,z=J[J.length-1].y,W+=7;break}case"Q":{let _=G(W+1,"Q.x1"),U=G(W+2,"Q.y1"),Y=G(W+3,"Q.x"),V=G(W+4,"Q.y");J.push({type:"Q",x1:F==="Q"?_:j+_,y1:F==="Q"?U:z+U,x:F==="Q"?Y:j+Y,y:F==="Q"?V:z+V}),j=J[J.length-1].x,z=J[J.length-1].y,W+=5;break}case"A":{let _=G(W+1,"A.rx"),U=G(W+2,"A.ry"),Y=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),M=parseInt(q[W+5],10);if(isNaN(V)||isNaN(M))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:Y,largeArcFlag:V,sweepFlag:M,x:F==="A"?X:j+X,y:F==="A"?k:z+k}),j=J[J.length-1].x,z=J[J.length-1].y,W+=8;break}case"Z":J.push({type:"Z"}),W+=1;break;default:W+=1}}return J}function L5($,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=[],Q=$.getAttribute("marker-start"),K=$.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 j=$.getAttribute("d")||"",z=wH(j);if(z.length===0)return Z;let G=(F)=>{if(!F)return null;let _=F.match(/url\(#([^)]+)\)/);return _?_[1]:null};if(Q){let F=G(Q),_=F?J[F]:null;if(_&&z.length>0){let U=z[0],Y=z.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:D9(_,{x:U.x,y:U.y},Y,W,!0),type:"start",vertex:U})}}if(K&&z.length>2){let F=G(K),_=F?J[F]:null;if(_)for(let U=1;U<z.length-1;U++){let Y=z[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:D9(_,{x:Y.x,y:Y.y},k,W,!1),type:"mid",vertex:Y})}}if(q){let F=G(q),_=F?J[F]:null;if(_&&z.length>0){let U=z[z.length-1],Y=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:D9(_,{x:U.x,y:U.y},Y,W,!1),type:"end",vertex:U})}}return Z}function RH($,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:Q=10}=J;if(typeof Z!=="number"||Z<0)throw new Error("markerToPolygons: precision must be a non-negative number");if(typeof Q!=="number"||Q<=0)throw new Error("markerToPolygons: curveSegments must be a positive number");let K=[],{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 j=[];switch(W.type){case"path":j=BH(W.d,Q);break;case"rect":j=[{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":j=NH(W.cx,W.cy,W.r,Q*4);break;case"ellipse":j=CH(W.cx,W.cy,W.rx,W.ry,Q*4);break;case"line":j=[{x:W.x1,y:W.y1},{x:W.x2,y:W.y2}];break;case"polygon":case"polyline":j=IH(W.points);break;default:break}if(j.length>0){let z=j.map((G)=>{let F=n0(H,G.x,G.y);return{x:parseFloat(F[0].toFixed(Z)),y:parseFloat(F[1].toFixed(Z))}});K.push(z)}}return K}function BH($,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=[],Q=k5($),K=0,q=0;for(let H of Q)switch(H.type){case"M":K=H.x,q=H.y,Z.push({x:K,y:q});break;case"L":K=H.x,q=H.y,Z.push({x:K,y:q});break;case"C":for(let W=1;W<=J;W++){let j=W/J,z=1-j,G=z*z*z*K+3*z*z*j*H.x1+3*z*j*j*H.x2+j*j*j*H.x,F=z*z*z*q+3*z*z*j*H.y1+3*z*j*j*H.y2+j*j*j*H.y;Z.push({x:G,y:F})}K=H.x,q=H.y;break;case"Q":for(let W=1;W<=J;W++){let j=W/J,z=1-j,G=z*z*K+2*z*j*H.x1+j*j*H.x,F=z*z*q+2*z*j*H.y1+j*j*H.y;Z.push({x:G,y:F})}K=H.x,q=H.y;break;case"A":K=H.x,q=H.y,Z.push({x:K,y:q});break;default:break}return Z}function NH($,J,Z,Q=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 Q!=="number"||Q<=0)throw new Error("circleToPoints: segments must be a positive number");let K=[];for(let q=0;q<Q;q++){let H=q/Q*2*Math.PI;K.push({x:$+Z*Math.cos(H),y:J+Z*Math.sin(H)})}return K}function CH($,J,Z,Q,K=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 Q!=="number"||!isFinite(Q)||Q<0)throw new Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof K!=="number"||K<=0)throw new Error("ellipseToPoints: segments must be a positive number");let q=[];for(let H=0;H<K;H++){let W=H/K*2*Math.PI;q.push({x:$+Z*Math.cos(W),y:J+Q*Math.sin(W)})}return q}function IH($){if(typeof $!=="string")throw new Error("parsePoints: pointsStr must be a string");let J=[],Z=$.trim().split(/[\s,]+/).map(Number).filter((Q)=>!isNaN(Q)&&isFinite(Q));if(Z.length%2!==0)throw new Error("parsePoints: pointsStr must contain an even number of valid coordinates");for(let Q=0;Q<Z.length;Q+=2)J.push({x:Z[Q],y:Z[Q+1]});return J}function w5($,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 Q of $){let K=RH(Q,{precision:J});for(let q of K){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 j=q[W];Z.push(`L ${j.x.toFixed(J)} ${j.y.toFixed(J)}`)}Z.push("Z")}}return Z.join(" ")}O.set({precision:80});var L0=($)=>$ instanceof O?$:new O($),e0=new O(0),T$=new O(1);function b$(){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 C5($,J,Z){let Q=b$();if(!$)return{valid:!1,error:new O(1/0),tolerance:Q,message:"Matrix parameter is null or undefined"};if(J==null||Z==null)return{valid:!1,error:new O(1/0),tolerance:Q,message:"Coordinates x or y are null or undefined"};let K=L0(J),q=L0(Z);try{let[H,W]=n0($,K,q),j=$.inverse();if(!j)return{valid:!1,error:new O(1/0),tolerance:Q,message:"Matrix is not invertible (determinant = 0)",details:{determinant:$.determinant()}};let[z,G]=n0(j,H,W),F=K.minus(z).abs(),_=q.minus(G).abs(),U=O.max(F,_),Y=U.lessThan(Q);return{valid:Y,error:U,tolerance:Q,message:Y?`Round-trip verified: error ${U.toExponential()} < tolerance ${Q.toExponential()}`:`Round-trip FAILED: error ${U.toExponential()} >= tolerance ${Q.toExponential()}`,details:{original:{x:K.toString(),y:q.toString()},transformed:{x:H.toString(),y:W.toString()},recovered:{x:z.toString(),y:G.toString()},errorX:F.toExponential(),errorY:_.toExponential()}}}catch(H){return{valid:!1,error:new O(1/0),tolerance:Q,message:`Verification error: ${H.message}`}}}function h9($){let J=b$();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 Q=$.mul(Z),K=$.rows,q=e0,H=[];for(let j=0;j<K;j++)for(let z=0;z<K;z++){let G=j===z?T$:e0,F=Q.data[j][z],_=F.minus(G).abs();if(_.greaterThan(q))q=_;if(_.greaterThanOrEqualTo(J))H.push({row:j,col:z,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:`${K}x${K}`,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 R5($,J,Z=null){let Q=b$(),K=Z||new O("1e-6");if(!$||!Array.isArray($))return{valid:!1,error:e0,tolerance:Q,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:e0,tolerance:Q,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:e0,tolerance:Q,message:"Polygons must have at least 3 vertices"};try{let q=!0,H=[],W=e0;for(let j=0;j<$.length;j++){let z=$[j];if(!EH(z,J)){let G=AH(z,J);if(G.greaterThan(W))W=G;if(G.greaterThan(K))q=!1,H.push({index:j,x:z.x.toString(),y:z.y.toString(),distanceOutside:G.toExponential()})}}return{valid:q,error:W,tolerance:K,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:Q,message:`Verification error: ${q.message}`}}}function AH($,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),Q=L0($.x),K=L0($.y);for(let q=0;q<J.length;q++){let H=(q+1)%J.length,W=J[q],j=J[H],z=L0(W.x),G=L0(W.y),F=L0(j.x),_=L0(j.y),U=F.minus(z),Y=_.minus(G),V=U.times(U).plus(Y.times(Y)),M;if(V.isZero())M=A5($,W);else{let X=O.max(e0,O.min(T$,Q.minus(z).times(U).plus(K.minus(G).times(Y)).div(V))),k=z.plus(X.times(U)),L=G.plus(X.times(Y));M=Q.minus(k).pow(2).plus(K.minus(L).pow(2)).sqrt()}if(M.lessThan(Z))Z=M}return Z}function I5($,J,Z){let Q=b$();if(!$||!Array.isArray($))return{valid:!1,error:e0,tolerance:Q,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:e0,tolerance:Q,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:e0,tolerance:Q,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:e0,tolerance:Q,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:Z.length}};try{let K=R5(Z,$),q=R5(Z,J),H=t$($),W=t$(J),j=t$(Z),z=O.min(H,W),G=j.lessThanOrEqualTo(z.times(T$.plus(Q))),F=K.valid&&q.valid&&G;return{valid:F,error:F?e0:T$,tolerance:Q,message:F?"Intersection verified: contained in both polygons, area valid":`Intersection FAILED: ${!K.valid?"not in poly1, ":""}${!q.valid?"not in poly2, ":""}${!G?"area too large":""}`,details:{containedInPoly1:K.valid,containedInPoly2:q.valid,area1:H.toString(),area2:W.toString(),intersectionArea:j.toString(),areaValid:G}}}catch(K){return{valid:!1,error:new O(1/0),tolerance:Q,message:`Verification error: ${K.message}`}}}function P5($,J,Z){let Q=b$();if(!$||typeof $!=="object")return{valid:!1,error:new O(1/0),tolerance:Q,message:"Original gradient parameter must be an object"};if(!J||typeof J!=="object")return{valid:!1,error:new O(1/0),tolerance:Q,message:"Baked gradient parameter must be an object"};if(!Z)return{valid:!1,error:new O(1/0),tolerance:Q,message:"Matrix parameter is null or undefined"};try{let[K,q]=n0(Z,L0($.x1||0),L0($.y1||0)),[H,W]=n0(Z,L0($.x2||1),L0($.y2||0)),j=L0(J.x1).minus(K).abs(),z=L0(J.y1).minus(q).abs(),G=L0(J.x2).minus(H).abs(),F=L0(J.y2).minus(W).abs(),_=O.max(j,z,G,F),U=_.lessThan(Q);return{valid:U,error:_,tolerance:Q,message:U?`Linear gradient transform verified: max error ${_.toExponential()}`:`Linear gradient transform FAILED: max error ${_.toExponential()}`,details:{expected:{x1:K.toString(),y1:q.toString(),x2:H.toString(),y2:W.toString()},actual:J}}}catch(K){return{valid:!1,error:new O(1/0),tolerance:Q,message:`Verification error: ${K.message}`}}}function t$($){if(!$||!Array.isArray($))throw new Error("Invalid polygon parameter: must be an array");if($.length<3)return e0;let J=e0,Z=$.length;for(let Q=0;Q<Z;Q++){let K=(Q+1)%Z,q=L0($[Q].x),H=L0($[Q].y),W=L0($[K].x),j=L0($[K].y);J=J.plus(q.times(j).minus(W.times(H)))}return J.abs().div(2)}function EH($,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=L0($.x),Q=L0($.y),K=J.length,q=!1;for(let H=0,W=K-1;H<K;W=H++){let j=L0(J[H].x),z=L0(J[H].y),G=L0(J[W].x),F=L0(J[W].y);if(TH($,J[H],J[W]))return!0;if(z.greaterThan(Q)!==F.greaterThan(Q)&&Z.lessThan(G.minus(j).times(Q.minus(z)).div(F.minus(z)).plus(j)))q=!q}return q}function TH($,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 Q=b$(),K=L0($.x),q=L0($.y),H=L0(J.x),W=L0(J.y),j=L0(Z.x),z=L0(Z.y),G=O.min(H,j).minus(Q),F=O.max(H,j).plus(Q),_=O.min(W,z).minus(Q),U=O.max(W,z).plus(Q);if(K.lessThan(G)||K.greaterThan(F)||q.lessThan(_)||q.greaterThan(U))return!1;let Y=j.minus(H).times(q.minus(W)).minus(z.minus(W).times(K.minus(H))).abs(),V=A5(J,Z);return Y.div(V.plus(Q)).lessThan(Q)}function A5($,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=L0(J.x).minus(L0($.x)),Q=L0(J.y).minus(L0($.y));return Z.times(Z).plus(Q.times(Q)).sqrt()}function E5($,J){if(!$||$.length<3||!J||J.length<3)return[];let Z=[];for(let Q=0;Q<J.length;Q++){let K=J[Q],q=J[(Q+1)%J.length],H=[];for(let W=0;W<$.length;W++){let j=$[W],z=$[(W+1)%$.length],G=!B5(j,K,q),F=!B5(z,K,q);if(G){if(H.push(j),!F)H.push(N5(j,z,K,q))}else if(F)H.push(N5(j,z,K,q))}if(H.length>=3)Z.push(H)}return Z}function T5($,J,Z=[],Q="1e-10"){let K=Q instanceof O?Q:new O(Q),q=Z||[];if(!$||!Array.isArray($))return{valid:!1,error:new O(1/0),tolerance:K,message:"Original polygon parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:new O(1/0),tolerance:K,message:"Clipped polygon parameter must be an array"};try{let H=t$($),W=J.length>=3?t$(J):e0,j=H.minus(W),z=W.lessThanOrEqualTo(H.times(T$.plus(K))),G=j.greaterThanOrEqualTo(e0.minus(K.times(H))),F=H.isZero()?T$:W.div(H),_=e0,U=z&&G;return{valid:U,error:_,tolerance:K,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:j.toString(),areaRatio:F.toFixed(6),fragmentCount:q.length,clippedValid:z,outsideValid:G}}}catch(H){return{valid:!1,error:new O(1/0),tolerance:K,message:`E2E verification error: ${H.message}`}}}function B5($,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 Q=L0($.x).toNumber(),K=L0($.y).toNumber(),q=L0(J.x).toNumber(),H=L0(J.y).toNumber(),W=L0(Z.x).toNumber(),j=L0(Z.y).toNumber();return(W-q)*(K-H)-(j-H)*(Q-q)>=0}function N5($,J,Z,Q){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(!Q||Q.x==null||Q.y==null)throw new Error("Invalid p4 parameter: must have x and y properties");let K=L0($.x).toNumber(),q=L0($.y).toNumber(),H=L0(J.x).toNumber(),W=L0(J.y).toNumber(),j=L0(Z.x).toNumber(),z=L0(Z.y).toNumber(),G=L0(Q.x).toNumber(),F=L0(Q.y).toNumber(),_=(K-H)*(z-F)-(q-W)*(j-G);if(Math.abs(_)<0.0000000001)return{x:L0((K+H)/2),y:L0((q+W)/2)};let U=((K-j)*(z-F)-(q-z)*(j-G))/_;return{x:L0(K+U*(H-K)),y:L0(q+U*(W-q))}}var v5=["animate","animateTransform","animateMotion","animateColor","set"],b5=["href","xlink:href"],f5=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],fH=["begin","end"],SH=["values","from","to","by"];function y9($){if(!$||typeof $!=="string")return null;let J=$.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return J&&J[1]?J[1]:null}function S5($){if(!$||typeof $!=="string")return null;if($.startsWith("#")){let J=$.substring(1);return J&&!J.startsWith("#")?J:null}return null}function D5($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let Q of Z){let K=Q.trim();if(K.startsWith("#")){let H=K.substring(1);if(H)J.push(H)}let q=y9(K);if(q)J.push(q)}return J}function h5($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let Q of Z){let q=Q.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+(?:\.\d+)?[a-z]*)?/);if(q)J.push(q[1])}return J}function e$($){if(!$||typeof $!=="string")return[];let J=[],Z=/url\(\s*["']?#([^"')]+)["']?\s*\)/g,Q;while((Q=Z.exec($))!==null)if(Q[1])J.push(Q[1]);return J}function y5($){if(!$||typeof $!=="string")return[];let J=[],Z=/getElementById\(\s*["']([^"']+)["']\s*\)/g,Q;while((Q=Z.exec($))!==null)if(Q[1])J.push(Q[1]);let K=/querySelector(?:All)?\(\s*["']#([^"'#\s]+)["']\s*\)/g;while((Q=K.exec($))!==null)if(Q[1])J.push(Q[1]);return J}function vH($){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()||"",Q=v5.includes(Z),K=$.getAttributeNames();if(!Array.isArray(K))throw new TypeError("collectElementReferences: getAttributeNames must return an array");for(let q of K){let H=$.getAttribute(q);if(!H)continue;if(b5.includes(q)){let W=S5(H);if(W)if(Q)J.animation.add(W);else J.static.add(W)}if(f5.includes(q)||q==="style"){let W=y9(H);if(W)J.static.add(W);if(q==="style")e$(H).forEach((j)=>J.css.add(j))}if(fH.includes(q))h5(H).forEach((W)=>J.animation.add(W));if(SH.includes(q))D5(H).forEach((W)=>J.animation.add(W));if(!f5.includes(q)&&H.includes("url(")){let W=y9(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 b5){let j=H.getAttribute(W),z=S5(j);if(z)J.animation.add(z)}}}return J}function u5($){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},Q=(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 j=J.details.get(q);if(Z[H]>Z[j.type])j.type=H}J.details.get(q).sources.push(W)},K=(q,H="")=>{let W=q.tagName?.toLowerCase()||"",j=H?`${H}>${W}`:W,z=q.getAttribute("id"),G=z?`${W}#${z}`:j,F=vH(q);if(F.static.forEach((_)=>Q(_,"static",G)),F.animation.forEach((_)=>Q(_,"animation",G)),F.css.forEach((_)=>Q(_,"css",G)),F.js.forEach((_)=>Q(_,"js",G)),W==="style"){let _=q.textContent||"";e$(_).forEach((U)=>Q(U,"css","<style>"))}if(W==="script"){let _=q.textContent||"";y5(_).forEach((U)=>Q(U,"js","<script>"))}if(q.children&&typeof q.children[Symbol.iterator]==="function"){for(let _ of q.children)if(_ instanceof w0)K(_,j)}};return K($),J}O.set({precision:80});var N7=($)=>$ instanceof O?$:new O($),DH={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 S$($,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={...DH,...J},Q={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 K=x0($);if(K.tagName.toLowerCase()!=="svg")throw new Error("Root element must be <svg>");let q=u7(K),H=Z.removeUnusedDefs?cH(K):null;if(Z.resolveUse){let j=hH(K,q,Z);Q.useResolved=j.count,Q.errors.push(...j.errors),q=u7(K)}if(Z.resolveMarkers){let j=yH(K,q,Z);Q.markersResolved=j.count,Q.errors.push(...j.errors)}if(Z.resolvePatterns){let j=uH(K,q,Z);Q.patternsResolved=j.count,Q.errors.push(...j.errors)}if(Z.resolveMasks){let j=gH(K,q,Z);Q.masksResolved=j.count,Q.errors.push(...j.errors)}if(Z.resolveClipPaths){let j=xH(K,q,Z,Q);Q.clipPathsApplied=j.count,Q.errors.push(...j.errors)}if(Z.flattenTransforms){let j=mH(K,Z,Q);Q.transformsFlattened=j.count,Q.errors.push(...j.errors)}if(Z.bakeGradients){let j=pH(K,Z,Q);Q.gradientsProcessed=j.count,Q.errors.push(...j.errors)}if(Z.removeUnusedDefs&&H){let j=nH(K,H);Q.defsRemoved=j.count}return{svg:q7(K),stats:Q}}catch(K){return Q.errors.push(`Pipeline error: ${K.message}`),{svg:$,stats:Q}}}var d5=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),p5=new Set(["foreignobject","audio","video","iframe","script","style",...d5]);function u9($){if(!$)return!1;let J=$.tagName?.toLowerCase();if(p5.has(J))return!0;for(let Z of $.children||[])if(Z&&Z.tagName&&u9(Z))return!0;return!1}function hH($,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 Q=[],K=0,q=$.getElementsByTagName("use"),H={};for(let[W,j]of J.entries())if(j.tagName.toLowerCase()==="symbol")H[W]=U5(j),H[W].type="symbol";else H[W]=d6(j);for(let W of[...q])try{let j=W.getAttribute("href")||W.getAttribute("xlink:href");if(!j)continue;let z=j.replace(/^#/,""),G=J.get(z);if(!G){Q.push(`use: referenced element #${z} not found`);continue}let F=u9(G),_=u9(W);if(F||_){let M=G.cloneNode(!0),X=parseFloat(W.getAttribute("x")||"0"),k=parseFloat(W.getAttribute("y")||"0");if(isNaN(X)||isNaN(k)){Q.push(`use: invalid x/y coordinates for element #${z}`);continue}let L=W.getAttribute("transform")||"",R="";if(L)R=L;if(X!==0||k!==0){let g=`translate(${X}, ${k})`;R=R?`${R} ${g}`:g}let B=new w0("g",{});if(R)B.setAttribute("transform",R);let I=$6(W);for(let[g,f]of Object.entries(I))if(f&&!B.hasAttribute(g))B.setAttribute(g,f);if(G.tagName.toLowerCase()==="symbol"){for(let g of M.children||[])if(g&&g.tagName)B.appendChild(g.cloneNode(!0))}else M.removeAttribute("id"),B.appendChild(M);for(let g of W.children||[])if(g&&g.tagName){let f=g.tagName.toLowerCase();if(d5.has(f))B.appendChild(g.cloneNode(!0))}if(W.parentNode)W.parentNode.replaceChild(B,W),K++;continue}let U=_5(W),Y=v9(U,H,{samples:Z.curveSegments});if(!Y){Q.push(`use: failed to resolve #${z}`);continue}let V=Y5(Y,Z.curveSegments);if(V){let M=new w0("path",{d:V,...$6(W)});if(Y.style){for(let[X,k]of Object.entries(Y.style))if(k&&!M.hasAttribute(X))M.setAttribute(X,k)}if(W.parentNode)W.parentNode.replaceChild(M,W),K++}}catch(j){Q.push(`use: ${j.message}`)}return{count:K,errors:Q}}function yH($,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 Q=[],K=0,q=["marker-start","marker-mid","marker-end","marker"];for(let H of q){let W=A7($,H);for(let j of W){if(j.tagName!=="path"&&j.tagName!=="line"&&j.tagName!=="polyline"&&j.tagName!=="polygon")continue;try{let z=L5(j,Object.fromEntries(J));if(!z||z.length===0)continue;let G=w5(z,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);K++}}for(let F of q)j.removeAttribute(F)}catch(z){Q.push(`marker: ${z.message}`)}}}return{count:K,errors:Q}}function uH($,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 Q=[],K=0,q=A7($,"fill");for(let H of q){let W=H.getAttribute("fill");if(!W||!W.includes("url("))continue;let j=g7(W);if(!j)continue;let z=J.get(j);if(!z||z.tagName.toLowerCase()!=="pattern")continue;try{let G=z.getAttribute("patternUnits")||"objectBoundingBox",F=z.getAttribute("patternContentUnits")||"userSpaceOnUse",_=z.getAttribute("patternTransform");if(G!=="objectBoundingBox")Q.push(`pattern ${j}: non-default patternUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")Q.push(`pattern ${j}: non-default patternContentUnits="${F}" may cause rendering issues`);if(_)Q.push(`pattern ${j}: patternTransform present - complex transformation may cause rendering issues`);let U=c5(H);if(!U)continue;let Y=M5(z),V=X5(Y,U,{samples:Z.curveSegments});if(V){let M=new w0("g",{}),X=new w0("path",{d:V,fill:"#000"});if(M.appendChild(X),H.setAttribute("fill","none"),H.setAttribute("stroke",H.getAttribute("stroke")||"none"),H.parentNode)H.parentNode.insertBefore(M,H),K++}}catch(G){Q.push(`pattern: ${G.message}`)}}return{count:K,errors:Q}}function gH($,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 Q=[],K=0,q=A7($,"mask");for(let H of q){let W=H.getAttribute("mask");if(!W||!W.includes("url("))continue;let j=g7(W);if(!j)continue;let z=J.get(j);if(!z||z.tagName.toLowerCase()!=="mask")continue;try{let G=z.getAttribute("maskUnits")||"objectBoundingBox",F=z.getAttribute("maskContentUnits")||"userSpaceOnUse";if(G!=="objectBoundingBox")Q.push(`mask ${j}: non-default maskUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")Q.push(`mask ${j}: non-default maskContentUnits="${F}" may cause rendering issues`);let _=c5(H);if(!_)continue;let U=G5(z),Y=F5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(Y){let V=f$(H,Z.precision);if(V){let M=W$(V,Z.curveSegments),X=W$(Y,Z.curveSegments),k=n5(M,X);if(k&&k.length>2){let L=S9(k,Z.precision);H.setAttribute("d",L),H.removeAttribute("mask"),K++}}}}catch(G){Q.push(`mask: ${G.message}`)}}return{count:K,errors:Q}}function xH($,J,Z,Q){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(!Q||typeof Q!=="object")throw new Error("applyAllClipPaths: stats must be an object");let K=[],q=0;if(!Q.verifications.e2e)Q.verifications.e2e=[];if(!Q.clipOutsideFragments)Q.clipOutsideFragments=[];let H=A7($,"clip-path");for(let W of H){let j=W.getAttribute("clip-path");if(!j||!j.includes("url("))continue;let z=g7(j);if(!z)continue;let G=J.get(z),F=G?G.tagName.toLowerCase():"";if(!G||F!=="clippath")continue;try{if((G.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")K.push(`clipPath ${z}: objectBoundingBox units require bbox-relative coordinate transformation`);let U=f$(W,Z.precision);if(!U)continue;let Y="";if(G.children&&G.children.length>0){for(let B of G.children)if(B&&B.tagName){let I=f$(B,Z.precision);if(I)Y+=(Y?" ":"")+I}}if(!Y)continue;let V=Z.clipSegments||64,M=W$(U,V),X=W$(Y,V),k=n5(M,X),L=M.map((B)=>({x:B.x instanceof O?B.x:N7(B.x),y:B.y instanceof O?B.y:N7(B.y)})),R=X.map((B)=>({x:B.x instanceof O?B.x:N7(B.x),y:B.y instanceof O?B.y:N7(B.y)}));if(k&&k.length>2){let B=k.map((x)=>({x:x.x instanceof O?x.x:N7(x.x),y:x.y instanceof O?x.y:N7(x.y)})),I=I5(L,R,B);if(Q.verifications.polygons.push({element:W.tagName,clipPathId:z,...I}),I.valid)Q.verifications.passed++;else Q.verifications.failed++,Q.verifications.allPassed=!1;let h=E5(L,R);Q.clipOutsideFragments.push({elementId:W.getAttribute("id")||`clip-${q}`,clipPathId:z,fragments:h,visible:!1});let g=Z.e2eTolerance||"1e-10",f=T5(L,B,h,g);if(Q.verifications.e2e.push({element:W.tagName,clipPathId:z,type:"clip-area-conservation",...f}),f.valid)Q.verifications.passed++;else Q.verifications.failed++,Q.verifications.allPassed=!1}if(k&&k.length>2){let B=S9(k,Z.precision),I=W;if(W.tagName==="path")W.setAttribute("d",B);else{let h=new w0("path",{d:B,...$6(W)});if(W.parentNode)W.parentNode.replaceChild(h,W),I=h}I.removeAttribute("clip-path"),q++}}catch(_){K.push(`clipPath: ${_.message}`)}}return{count:q,errors:K}}function mH($,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 Q=[],K=0,q=A7($,"transform");for(let H of q){let W=H.getAttribute("transform");if(!W)continue;try{let j=K7(W),z=h9(j);if(Z.verifications.matrices.push({element:H.tagName,transform:W,...z}),z.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;let G=f$(H,J.precision);if(!G){if(H.tagName==="g")dH(H,j,J,Z),H.removeAttribute("transform"),K++;continue}let F=[],_=W$(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=A$(G,j,{precision:J.precision});for(let V=0;V<F.length;V++){let M=F[V],X=C5(j,M.x,M.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,...$6(H)});for(let M of lH(H.tagName))V.removeAttribute(M);if(H.parentNode)H.parentNode.replaceChild(V,H),Y=V}Y.removeAttribute("transform"),K++}catch(j){Q.push(`transform: ${j.message}`)}}return{count:K,errors:Q}}function dH($,J,Z,Q){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(!Q||typeof Q!=="object")throw new Error("propagateTransformToChildren: stats must be an object");for(let K of[...$.children]){if(!(K&&K.tagName))continue;if(K.tagName==="g"){let q=K.getAttribute("transform");if(q){let H=K7(q),W=J.mul(H);K.setAttribute("transform",g5(W))}else K.setAttribute("transform",g5(J))}else{let q=f$(K,Z.precision);if(q){let H=K.getAttribute("transform"),W=J;if(H){let F=K7(H);W=J.mul(F)}let j=h9(W);if(Q.verifications.matrices.push({element:K.tagName,context:"group-propagation",...j}),j.valid)Q.verifications.passed++;else Q.verifications.failed++,Q.verifications.allPassed=!1;let z=A$(q,W,{precision:Z.precision}),G=K;if(K.tagName==="path")K.setAttribute("d",z);else{let F=new w0("path",{d:z,...$6(K)});$.replaceChild(F,K),G=F}G.removeAttribute("transform")}}}}function pH($,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 Q=[],K=0,q=$.getElementsByTagName("linearGradient");for(let W of q){let j=W.getAttribute("gradientTransform");if(!j)continue;try{let z=K7(j),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)){Q.push(`linearGradient: invalid coordinate values for gradient ${W.getAttribute("id")||"unknown"}`);continue}let[Y,V]=n0(z,G,F),[M,X]=n0(z,_,U),k=P5({x1:G,y1:F,x2:_,y2:U},{x1:Y.toNumber(),y1:V.toNumber(),x2:M.toNumber(),y2:X.toNumber()},z);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",Y.toFixed(J.precision)),W.setAttribute("y1",V.toFixed(J.precision)),W.setAttribute("x2",M.toFixed(J.precision)),W.setAttribute("y2",X.toFixed(J.precision)),W.removeAttribute("gradientTransform"),K++}catch(z){Q.push(`linearGradient: ${z.message}`)}}let H=$.getElementsByTagName("radialGradient");for(let W of H){let j=W.getAttribute("gradientTransform");if(!j)continue;try{let z=K7(j),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()),Y=parseFloat(W.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(Y)){Q.push(`radialGradient: invalid coordinate/radius values for gradient ${W.getAttribute("id")||"unknown"}`);continue}if(Y<=0){Q.push(`radialGradient: radius must be positive for gradient ${W.getAttribute("id")||"unknown"}`);continue}let[V,M]=n0(z,G,F),[X,k]=n0(z,_,U),L=z.data[0][0].toNumber()*z.data[1][1].toNumber();if(Math.abs(L)<0.0000000001){Q.push("radialGradient: matrix determinant too close to zero (degenerate transform)");continue}let R=Math.sqrt(Math.abs(L)),B=Y*R;W.setAttribute("cx",V.toFixed(J.precision)),W.setAttribute("cy",M.toFixed(J.precision)),W.setAttribute("fx",X.toFixed(J.precision)),W.setAttribute("fy",k.toFixed(J.precision)),W.setAttribute("r",B.toFixed(J.precision)),W.removeAttribute("gradientTransform"),K++}catch(z){Q.push(`radialGradient: ${z.message}`)}}return{count:K,errors:Q}}function cH($){if(!$||!$.getElementsByTagName)throw new Error("collectAllReferences: invalid root element");let J=new Set,Z=(Q)=>{if(!Q||!Q.getAttributeNames)return;if(Q.tagName&&Q.tagName.toLowerCase()==="style"){let K=Q.textContent||"";if(K)e$(K).forEach((H)=>J.add(H))}for(let K of Q.getAttributeNames()){let q=Q.getAttribute(K);if(!q)continue;if(q.includes("url(")){let H=g7(q);if(H)J.add(H)}if(K==="href"||K==="xlink:href"){let H=q.replace(/^#/,"");if(H&&H!==q)J.add(H)}}for(let K of Q.children)if(K&&K.tagName)Z(K)};return Z($),J}function nH($,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 Q(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&&Q(W))return!0;return!1}let K=$.getElementsByTagName("defs");for(let q of K)for(let H of[...q.children])if(H&&H.tagName){let W=H.tagName.toLowerCase();if(p5.has(W))continue;if(!Q(H))q.removeChild(H),Z++}return{count:Z}}function f$($,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 Q=(K,q=0)=>{let H=$.getAttribute(K);if(H===null)return q;let W=parseFloat(H);if(isNaN(W))throw new Error(`getElementPathData: invalid numeric value "${H}" for attribute "${K}"`);return W};switch(Z){case"rect":{let q=$.getAttribute("ry")!==null?Q("ry"):null;return T6(Q("x"),Q("y"),Q("width"),Q("height"),Q("rx"),q,!1,J)}case"circle":return A6(Q("cx"),Q("cy"),Q("r"),J);case"ellipse":return E6(Q("cx"),Q("cy"),Q("rx"),Q("ry"),J);case"line":return b6(Q("x1"),Q("y1"),Q("x2"),Q("y2"),J);case"polyline":return c$($.getAttribute("points")||"",J);case"polygon":return f6($.getAttribute("points")||"",J);default:return null}}function c5($){if(!$||!$.tagName)return null;let J=f$($,6);if(!J)return null;try{let Z=W$(J,10);if(!Z||Z.length===0)return null;let Q=1/0,K=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 j=W.x instanceof O?W.x.toNumber():typeof W.x==="number"?W.x:0,z=W.y instanceof O?W.y.toNumber():typeof W.y==="number"?W.y:0;if(isNaN(j)||isNaN(z))continue;if(j<Q)Q=j;if(z<K)K=z;if(j>q)q=j;if(z>H)H=z}if(Q===1/0||q===-1/0||K===1/0||H===-1/0)return null;return{x:Q,y:K,width:q-Q,height:H-K}}catch{return null}}function $6($){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 Q of J){let K=$.getAttribute(Q);if(K!==null)Z[Q]=K}return Z}function lH($){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 g5($){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(),Q=$.data[0][1].toNumber(),K=$.data[1][1].toNumber(),q=$.data[0][2].toNumber(),H=$.data[1][2].toNumber();if(!isFinite(J)||!isFinite(Z)||!isFinite(Q)||!isFinite(K)||!isFinite(q)||!isFinite(H))throw new Error("matrixToTransform: matrix contains non-finite values");return`matrix(${J} ${Z} ${Q} ${K} ${q} ${H})`}function n5($,J){if(!$||$.length<3||!J||J.length<3)return $;if(h7&&D7)try{return D7($,J)}catch(Q){}let Z=[...$];for(let Q=0;Q<J.length;Q++){if(Z.length===0)break;let K=Z;Z=[];let q=J[Q],H=J[(Q+1)%J.length];for(let W=0;W<K.length;W++){let j=K[W],z=K[(W+1)%K.length],G=x5(j,q,H),F=x5(z,q,H);if(G){if(Z.push(j),!F)Z.push(m5(j,z,q,H))}else if(F)Z.push(m5(j,z,q,H))}}return Z}function x5($,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 Q=$.x instanceof O?$.x.toNumber():$.x||0,K=$.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,j=Z.y instanceof O?Z.y.toNumber():Z.y||0;return(W-q)*(K-H)-(j-H)*(Q-q)>=0}function m5($,J,Z,Q){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(!Q||Q.x===void 0&&Q.y===void 0)throw new Error("lineIntersect: invalid p4");let K=$.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,j=Z.x instanceof O?Z.x.toNumber():Z.x||0,z=Z.y instanceof O?Z.y.toNumber():Z.y||0,G=Q.x instanceof O?Q.x.toNumber():Q.x||0,F=Q.y instanceof O?Q.y.toNumber():Q.y||0,_=(K-H)*(z-F)-(q-W)*(j-G);if(Math.abs(_)<0.0000000001)return{x:N7((K+H)/2),y:N7((q+W)/2)};let U=((K-j)*(z-F)-(q-z)*(j-G))/_;return{x:N7(K+U*(H-K)),y:N7(q+U*(W-q))}}var g9="http://www.inkscape.org/namespaces/inkscape",x9="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";var m9={groupmode:{type:"string",values:["layer"],description:"Identifies a group as a layer"},label:{type:"string",description:"Human-readable label for objects/layers"},expanded:{type:"boolean",description:"UI state - whether group is expanded in layers panel"},version:{type:"string",description:"Inkscape version that created/edited the file"},"document-units":{type:"string",values:["px","pt","pc","mm","cm","in"],description:"Default document units"},zoom:{type:"number",description:"Current zoom level"},rotation:{type:"number",description:"Current view rotation in degrees"},cx:{type:"number",description:"View center X coordinate"},cy:{type:"number",description:"View center Y coordinate"},"window-width":{type:"number",description:"Window width in pixels"},"window-height":{type:"number",description:"Window height in pixels"},"window-x":{type:"number",description:"Window X position"},"window-y":{type:"number",description:"Window Y position"},"window-maximized":{type:"boolean",description:"Whether window is maximized"},"current-layer":{type:"string",description:"ID of the currently active layer"},pageopacity:{type:"number",min:0,max:1,description:"Page opacity"},pageshadow:{type:"number",description:"Page shadow intensity"},showpageshadow:{type:"boolean",description:"Whether to show page shadow"},deskcolor:{type:"color",description:"Desk (canvas background) color"},deskopacity:{type:"number",min:0,max:1,description:"Desk opacity"},pagecheckerboard:{type:"boolean",description:"Show checkerboard pattern for transparency"},"desk-color":{type:"color",description:"Desk (canvas background) color (alternate form)"},"desk-opacity":{type:"number",min:0,max:1,description:"Desk opacity (alternate form)"},"desk-checkerboard":{type:"boolean",description:"Show checkerboard pattern (alternate form)"},"clip-to-page":{type:"boolean",description:"Clip rendering to page bounds"},"clip-to-page-rendering":{type:"boolean",description:"Clip rendering to page bounds (rendering mode)"},"antialias-rendering":{type:"boolean",description:"Enable antialiasing in rendering"},margin:{type:"string",description:"Page margin (CSS-like format)"},bleed:{type:"string",description:"Page bleed area"},"page-size":{type:"string",description:"Named page size (A4, Letter, etc.)"},"svg-dpi":{type:"number",description:"DPI for SVG export"},"origin-correction":{type:"string",description:"Origin correction for page positioning"},"y-axis-down":{type:"boolean",description:"Y axis direction (true=down, false=up)"},lockguides:{type:"boolean",description:"Lock all guides from editing"},color:{type:"color",description:"Guide color"},locked:{type:"boolean",description:"Object is locked from editing"},pinned:{type:"boolean",description:"Object is pinned in place"},collect:{type:"string",values:["always","never"],description:"Garbage collection behavior for defs"},"highlight-color":{type:"color",description:"Highlight color for object selection"},swatch:{type:"boolean",description:"Gradient is a color swatch"},"transform-center-x":{type:"number",description:"Custom rotation center X offset"},"transform-center-y":{type:"number",description:"Custom rotation center Y offset"},"path-effect":{type:"string",description:"Reference to inkscape:path-effect element (#id or #id;#id2)"},"original-d":{type:"string",description:"Original path data before LPE application"},original:{type:"string",description:"Original element reference"},"connector-type":{type:"string",values:["polyline","orthogonal"],description:"Connector line type"},"connector-curvature":{type:"number",description:"Connector curve amount"},"connector-spacing":{type:"number",description:"Spacing around connectors"},"connector-avoid":{type:"boolean",description:"Other connectors avoid this object"},"connection-points":{type:"string",description:"Custom connection point definitions"},"connection-start":{type:"string",description:"Start connection point reference"},"connection-end":{type:"string",description:"End connection point reference"},"connection-start-point":{type:"string",description:"Child-object reference for start connection"},"connection-end-point":{type:"string",description:"Child-object reference for end connection"},perspectiveID:{type:"string",description:"Reference to perspective element"},"box3d-perspectiveID":{type:"string",description:"Reference to perspective element (3D box alternate)"},"box3d-perspective-id":{type:"string",description:"Reference to perspective element (hyphenated form)"},corner0:{type:"string",description:"3D box corner 0 coordinates"},corner7:{type:"string",description:"3D box corner 7 coordinates"},box3dsidetype:{type:"string",description:"3D box side type"},persp3d:{type:"string",description:"3D perspective definition"},vp_x:{type:"string",description:"X vanishing point"},vp_y:{type:"string",description:"Y vanishing point"},vp_z:{type:"string",description:"Z vanishing point"},"persp3d-origin":{type:"string",description:"Perspective origin point"},flatsided:{type:"boolean",description:"Polygon has flat sides (not star)"},rounded:{type:"number",description:"Corner rounding amount"},randomized:{type:"number",description:"Random vertex displacement"},radius:{type:"number",description:"Shape radius"},href:{type:"string",description:"Inkscape-specific href reference"},"font-specification":{type:"string",description:"Full font specification string (fontconfig format)"},"font-spec":{type:"string",description:"Full font specification (alternate form)"},srcNoMarkup:{type:"string",description:"Text source without markup"},srcPango:{type:"string",description:"Text source in Pango markup"},dstShape:{type:"string",description:"Text flow destination shape"},dstPath:{type:"string",description:"Text flow destination path"},dstBox:{type:"string",description:"Text flow destination box"},dstColumn:{type:"string",description:"Text flow column settings"},excludeShape:{type:"string",description:"Shapes to exclude from text flow"},layoutOptions:{type:"string",description:"Text layout options"},"auto-region":{type:"boolean",description:"Auto-create text flow region"},"export-filename":{type:"string",description:"Default export filename"},"export-xdpi":{type:"number",description:"Export X DPI"},"export-ydpi":{type:"number",description:"Export Y DPI"},"spray-origin":{type:"string",description:"Spray tool origin reference"},"tiled-clone-of":{type:"string",description:"Source element for tiled clone"},"tile-cx":{type:"number",description:"Tile clone center X"},"tile-cy":{type:"number",description:"Tile clone center Y"},"tile-w":{type:"number",description:"Tile clone width"},"tile-h":{type:"number",description:"Tile clone height"},"tile-x0":{type:"number",description:"Tile origin X coordinate"},"tile-y0":{type:"number",description:"Tile origin Y coordinate"},"grid-bbox":{type:"boolean",description:"Show grid bounding box"},"grid-points":{type:"boolean",description:"Show grid points"},"guide-bbox":{type:"boolean",description:"Show guide bounding box"},"guide-points":{type:"boolean",description:"Show guide points"},"object-bbox":{type:"boolean",description:"Show object bounding box"},"object-nodes":{type:"boolean",description:"Show object nodes"},"object-paths":{type:"boolean",description:"Show object paths"},"object-points":{type:"boolean",description:"Show object points"},marker:{type:"string",description:"Marker reference"},stockid:{type:"string",description:"Stock marker/pattern ID"},isstock:{type:"boolean",description:"Element is a stock resource (pattern, symbol, etc.)"},menu:{type:"string",description:"Menu category for stock resources"},"menu-tooltip":{type:"string",description:"Tooltip text for stock resource menu item"},dataloss:{type:"boolean",description:"Indicates data loss on save"},has_abs_tolerance:{type:"boolean",description:"Has absolute tolerance"},output_extension:{type:"string",description:"Output extension ID"},offset:{type:"number",description:"Offset distance for offset paths"},"-inkscape-stroke":{type:"string",values:["hairline"],description:"Inkscape stroke rendering mode"}},d9={docname:{type:"string",description:"Document filename"},docbase:{type:"string",description:"Document base directory (absolute path)"},version:{type:"string",description:"Sodipodi version that saved the document"},modified:{type:"boolean",description:"Internal: document modified since last save"},type:{type:"string",values:["arc","star","spiral","inkscape:offset"],description:"Sodipodi shape type"},insensitive:{type:"boolean",description:"Object cannot be selected with mouse"},nonprintable:{type:"boolean",description:"Object should not be printed"},cx:{type:"number",description:"Arc center X"},cy:{type:"number",description:"Arc center Y"},rx:{type:"number",description:"Arc radius X"},ry:{type:"number",description:"Arc radius Y"},start:{type:"number",description:"Arc start angle (radians)"},end:{type:"number",description:"Arc end angle (radians)"},open:{type:"boolean",description:"Arc is open (not closed)"},"arc-type":{type:"string",values:["arc","slice","chord"],description:"Arc rendering type"},star:{type:"boolean",description:"Shape is a star (vs polygon)"},sides:{type:"number",min:3,description:"Number of polygon/star sides"},r1:{type:"number",description:"Star outer radius"},r2:{type:"number",description:"Star inner radius"},arg1:{type:"number",description:"Star angle argument 1 (radians)"},arg2:{type:"number",description:"Star angle argument 2 (radians)"},spiral:{type:"boolean",description:"Shape is a spiral"},expansion:{type:"number",description:"Spiral expansion rate"},revolution:{type:"number",description:"Number of spiral revolutions"},radius:{type:"number",description:"Spiral radius"},argument:{type:"number",description:"Spiral argument (start angle in radians)"},t0:{type:"number",min:0,max:1,description:"Spiral start parameter (0-1)"},original:{type:"string",description:"Original path or element reference"},nodetypes:{type:"string",pattern:/^[csza]+$/,description:"Path node types (c=corner, s=smooth, z=symmetric, a=auto)"},absref:{type:"string",description:"Absolute native path to external resource"},role:{type:"string",values:["line"],description:"Text span role (line = separate line)"},linespacing:{type:"string",description:"Line spacing (percentage like '125%' or absolute)"}},sH=["namedview","guide"],oH=["path-effect","perspective","page","clipboard","grid","box3dside"],l5=["flowRoot","flowPara","flowRegion","flowSpan","flowDiv","flowLine"];function iH($,J){let Z=m9[$];if(!Z)return{valid:!0};if(Z.values&&!Z.values.includes(J))return{valid:!1,error:`Invalid value "${J}" for inkscape:${$}. Expected: ${Z.values.join(", ")}`};if(Z.type==="number"){let Q=parseFloat(J);if(isNaN(Q))return{valid:!1,error:`inkscape:${$} must be a number`};if(Z.min!==void 0&&Q<Z.min)return{valid:!1,error:`inkscape:${$} must be >= ${Z.min}`};if(Z.max!==void 0&&Q>Z.max)return{valid:!1,error:`inkscape:${$} must be <= ${Z.max}`}}if(Z.type==="boolean"){if(J==="true"||J==="false")return{valid:!0};let Q=parseInt(J,10);if(isNaN(Q)||String(Q)!==J)return{valid:!1,error:`inkscape:${$} must be a boolean (true/false) or integer`}}if(Z.pattern&&!Z.pattern.test(J))return{valid:!1,error:`inkscape:${$} has invalid format`};return{valid:!0}}function rH($,J){let Z=d9[$];if(!Z)return{valid:!0};if(Z.values&&!Z.values.includes(J))return{valid:!1,error:`Invalid value "${J}" for sodipodi:${$}. Expected: ${Z.values.join(", ")}`};if(Z.type==="number"){let Q=parseFloat(J);if(isNaN(Q))return{valid:!1,error:`sodipodi:${$} must be a number`};if(Z.min!==void 0&&Q<Z.min)return{valid:!1,error:`sodipodi:${$} must be >= ${Z.min}`};if(Z.max!==void 0&&Q>Z.max)return{valid:!1,error:`sodipodi:${$} must be <= ${Z.max}`}}if(Z.pattern&&!Z.pattern.test(J))return{valid:!1,error:`sodipodi:${$} has invalid format`};return{valid:!0}}function s5($){if(!$)return{isInkscape:!1,hasFlowText:!1};let J=$.documentElement||$;if(!J||typeof J.getAttribute!=="function")return{isInkscape:!1,hasFlowText:!1};let Z=J.getAttribute("xmlns:inkscape")===g9,Q=J.getAttribute("xmlns:sodipodi")===x9,K=J.getAttribute("inkscape:version"),q=!1,H=(W)=>{if(!W)return;if(l5.includes(W.tagName)){q=!0;return}if(W.children&&Array.isArray(W.children)){for(let j of W.children)if(H(j),q)return}};return H(J),{isInkscape:Z||Q||!!K,version:K||void 0,hasFlowText:q}}var H7={ERROR:"error",WARNING:"warning",INFO:"info"};function o5($,J={}){let{strict:Z=!1,warnFlowText:Q=!0,checkPolyfillNeeds:K=!0}=J,q=[],H=new Set,W=!1,j=!1,z=!1,G=s5($);W=G.hasFlowText;let F=(V,M,X,k,L)=>{q.push({severity:V,type:M,element:X,attribute:k,message:L})},_=$.documentElement||$;if(_&&typeof _.getAttribute==="function"){let V=_.getAttribute("xmlns:inkscape"),M=_.getAttribute("xmlns:sodipodi");if(V&&V!==g9)F(H7.ERROR,"invalid_namespace_uri","svg","xmlns:inkscape",`Invalid Inkscape namespace URI. Expected: ${g9}, got: ${V}`);if(M&&M!==x9)F(H7.ERROR,"invalid_namespace_uri","svg","xmlns:sodipodi",`Invalid Sodipodi namespace URI. Expected: ${x9}, got: ${M}`)}let U=(V)=>{if(!V||typeof V.getAttributeNames!=="function")return;let M=V.tagName||"unknown";if(K){let X=M.toLowerCase();if(X==="meshgradient"||X==="meshrow"||X==="meshpatch")j=!0;if(X==="hatch"||X==="hatchpath")z=!0;if(l5.includes(M))W=!0}if(M.startsWith("sodipodi:")){let X=M.substring(9);if(!sH.includes(X))F(H7.ERROR,"unknown_sodipodi_element",M,null,`Unknown sodipodi element: ${M} - not in Sodipodi namespace schema`)}if(M.startsWith("inkscape:")){let X=M.substring(9);if(!oH.includes(X))F(H7.ERROR,"unknown_inkscape_element",M,null,`Unknown inkscape element: ${M} - not in Inkscape namespace schema`)}for(let X of V.getAttributeNames()){let k=V.getAttribute(X);if(X.startsWith("inkscape:")){let L=X.substring(9),R=iH(L,k);if(!R.valid)F(H7.ERROR,"invalid_inkscape_attribute",M,X,R.error);else if(Z&&!m9[L])F(H7.ERROR,"unknown_inkscape_attribute",M,X,`Unknown inkscape attribute: ${X} - not in Inkscape namespace schema`)}if(X.startsWith("sodipodi:")){let L=X.substring(9),R=rH(L,k);if(!R.valid)F(H7.ERROR,"invalid_sodipodi_attribute",M,X,R.error);else if(Z&&!d9[L])F(H7.ERROR,"unknown_sodipodi_attribute",M,X,`Unknown sodipodi attribute: ${X} - not in Sodipodi namespace schema`)}if(X==="style"&&k.includes("-inkscape-stroke"))H.add("hairlineStroke")}if(V.children&&Array.isArray(V.children))for(let X of V.children)U(X);else if(V.childNodes){for(let X of V.childNodes)if(X.nodeType===1)U(X)}};if(U(_),j)H.add("meshGradient");if(z)H.add("hatchPaint");if(W&&Q)F(H7.WARNING,"flowtext_compatibility","flowRoot",null,"SVG contains flowRoot elements (SVG 1.2 draft). These are not supported by browsers and should be converted to regular text.");let Y={errors:q.filter((V)=>V.severity===H7.ERROR).length,warnings:q.filter((V)=>V.severity===H7.WARNING).length,info:q.filter((V)=>V.severity===H7.INFO).length};return{isValid:Y.errors===0,isInkscape:G.isInkscape,version:G.version,issues:q,summary:Y,polyfillsNeeded:[...H],hasFlowText:W}}var O$=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 J6={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 Z6={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"])},i5={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 p9={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 Q6($,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+$/,""),q=q.replace(/\.$/,"");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 c6($){if(!$||typeof $!=="string")return[];return $.split(";").map((Z)=>Z.trim()).filter((Z)=>Z).map((Z)=>{let Q=Z.split(/[\s,]+/).map((K)=>parseFloat(K)).filter((K)=>Number.isFinite(K));if(Q.length!==4)throw new Error(`parseKeySplines: invalid spline "${Z}", expected 4 values, got ${Q.length}`);return Q})}function c9($,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,Q)=>{if(!Array.isArray(Z))throw new Error(`serializeKeySplines: spline at index ${Q} must be an array`);if(Z.length!==4)throw new Error(`serializeKeySplines: spline at index ${Q} must have exactly 4 values, got ${Z.length}`);return Z.map((K)=>Q6(K,J)).join(" ")}).join("; ")}function n6($,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,Q,K,q]=$;if(!Number.isFinite(Z)||!Number.isFinite(Q)||!Number.isFinite(K)||!Number.isFinite(q))return!1;return Math.abs(Z)<J&&Math.abs(Q)<J&&Math.abs(K-1)<J&&Math.abs(q-1)<J}function r5($){let J=c6($);if(J.length===0)return!1;return J.every((Z)=>n6(Z))}function n9($,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,Q]of Object.entries(p9))if($.every((q,H)=>Math.abs(q-Q[H])<J))return Z;return null}function l9($,J={}){let Z=J.precision??3,Q=J.removeLinear!==!1,K=c6($);if(K.length===0)return{value:null,allLinear:!1,standardEasings:[]};let q=K.every((j)=>n6(j)),H=K.map((j)=>n9(j)).filter(Boolean);if(q&&Q)return{value:null,allLinear:!0,standardEasings:H};return{value:c9(K,Z),allLinear:q,standardEasings:H}}function aH($){if(!$||typeof $!=="string")return[];return $.split(";").map((J)=>parseFloat(J.trim())).filter((J)=>Number.isFinite(J))}function tH($,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)=>Q6(Z,J)).join("; ")}function s9($,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=aH($);if(Z.length===0)return $;return tH(Z,J)}function p6($,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");if($.startsWith("data:"))return $;let Z=$.split(";");if(Z.length===0)return $;return Z.map((K)=>{let q=K.trim();if(q.startsWith("#")||q.includes("url("))return q;if(q.startsWith("data:"))return q;if(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\s*\(/i.test(q))return q;if(/^[MmZzLlHhVvCcSsQqTtAa][\s\d.,+-]+/.test(q))return q;if(/^(['"]?[\w\s-]+['"]?,\s*)+['"]?[\w\s-]+['"]?$/.test(q))return q;return q.split(/[\s,]+/).filter((j)=>j).map((j)=>{let z=parseFloat(j);if(!Number.isFinite(z))return j;return Q6(z,J)}).join(" ")}).join("; ")}function eH($,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,Q=J.removeLinearSplines!==!1,K=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 z=l9(W,{precision:Z,removeLinear:Q});if(z.allLinear&&Q){if($.getAttribute("calcMode")==="spline")$.setAttribute("calcMode","linear"),$.removeAttribute("keySplines"),q.push('Converted linear splines to calcMode="linear"'),H=!0}else if(z.value&&z.value!==W)$.setAttribute("keySplines",z.value),q.push(`keySplines: "${W}" -> "${z.value}"`),H=!0}let j=$.getAttribute("keyTimes");if(j){let z=s9(j,Z);if(z!==j)$.setAttribute("keyTimes",z),q.push(`keyTimes: "${j}" -> "${z}"`),H=!0}if(K){let z=$.getAttribute("values");if(z){let G=p6(z,Z);if(G!==z)$.setAttribute("values",G),q.push(`values: "${z}" -> "${G}"`),H=!0}}for(let z of["from","to","by"]){let G=$.getAttribute(z);if(G){let F=p6(G,Z);if(F!==G)$.setAttribute(z,F),q.push(`${z}: "${G}" -> "${F}"`),H=!0}}return{modified:H,changes:q}}var $W=["animate","animatetransform","animatemotion","animatecolor","set"];function a5($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let Z=0,Q=0,K=[],q=(H)=>{if(!H||typeof H!=="object")return;let W=H.tagName?.toLowerCase();if(!W)return;if($W.includes(W)){let z=eH(H,J);if(z.modified)Z++,Q+=z.changes.length,K.push({element:W,id:H.getAttribute("id")||null,changes:z.changes})}let j=H.children||[];for(let z of j)q(z)};return q($),{elementsModified:Z,totalChanges:Q,details:K}}var i9={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 JW($){if(typeof $!=="string")throw new TypeError(`parseArcArgs: argsStr must be a string, got ${typeof $}`);let J=[],Z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,Q=0,K=0;while(Q<$.length){while(Q<$.length&&/[\s,]/.test($[Q]))Q++;if(Q>=$.length)break;let q=K%7;if(q===3||q===4)if($[Q]==="0"||$[Q]==="1")J.push($[Q]==="1"?1:0),Q++,K++;else return null;else{Z.lastIndex=Q;let H=Z.exec($);if(H&&H.index===Q)J.push(parseFloat(H[0])),Q=Z.lastIndex,K++;else Q++}}return J}function i0($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,Q;while((Q=Z.exec($))!==null){let K=Q[1],q=Q[2].trim();if(K==="Z"||K==="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 z=2;z+1<j.length;z+=2)J.push({command:"L",args:[parseFloat(j[z]),parseFloat(j[z+1])]})}continue}let H;if(K==="A"||K==="a"){if(H=JW(q),H===null){console.warn(`Invalid arc command with malformed flags - skipping: ${K}${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 z;while((z=j.exec(q))!==null)H.push(parseFloat(z[0]))}let W=i9[K];if(W===void 0){console.warn(`Unknown SVG path command '${K}' - skipping`);continue}if(W===0||H.length===0)J.push({command:K,args:[]});else for(let j=0;j<H.length;j+=W){let z=H.slice(j,j+W);if(z.length===W){let G=j>0&&(K==="M"||K==="m")?K==="M"?"L":"l":K;J.push({command:G,args:z})}else if(z.length>0)console.warn(`Incomplete ${K} command: expected ${W} args, got ${z.length} - remaining args dropped`)}}return J}function x7($,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),K=(Math.round($*Z)/Z).toFixed(J);if(K.includes("."))K=K.replace(/\.?0+$/,"");if(K.startsWith("0."))K=K.substring(1);else if(K.startsWith("-0."))K="-"+K.substring(2);if(K===""||K==="."||K==="-.")K="0";return K}function C7($,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:Q,args:K}=$;if(Q===Q.toUpperCase()){if(i9[Q]===void 0)throw new TypeError(`toAbsolute: unknown command '${Q}'`);return $}let q=Q.toUpperCase(),H=[...K];switch(Q){case"m":case"l":case"t":if(H.length<2)throw new RangeError(`toAbsolute: command ${Q} 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 ${Q} requires at least 1 arg, got ${H.length}`);H[0]+=J;break;case"v":if(H.length<1)throw new RangeError(`toAbsolute: command ${Q} requires at least 1 arg, got ${H.length}`);H[0]+=Z;break;case"c":if(H.length<6)throw new RangeError(`toAbsolute: command ${Q} 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 ${Q} 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 ${Q} requires at least 7 args, got ${H.length}`);H[5]+=J,H[6]+=Z;break;default:throw new TypeError(`toAbsolute: unsupported command '${Q}' for conversion`)}return{command:q,args:H}}function r9($,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:Q,args:K}=$;if(Q===Q.toLowerCase()&&Q!=="z"){if(i9[Q]===void 0)throw new TypeError(`toRelative: unknown command '${Q}'`);return $}if(Q==="Z"||Q==="z")return{command:"z",args:[]};let q=Q.toLowerCase(),H=[...K];switch(Q){case"M":case"L":case"T":if(H.length<2)throw new RangeError(`toRelative: command ${Q} 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 ${Q} requires at least 1 arg, got ${H.length}`);H[0]-=J;break;case"V":if(H.length<1)throw new RangeError(`toRelative: command ${Q} requires at least 1 arg, got ${H.length}`);H[0]-=Z;break;case"C":if(H.length<6)throw new RangeError(`toRelative: command ${Q} 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 ${Q} 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 ${Q} requires at least 7 args, got ${H.length}`);H[5]-=J,H[6]-=Z;break;default:throw new TypeError(`toRelative: unsupported command '${Q}' for conversion`)}return{command:q,args:H}}function ZW($,J,Z,Q=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 Q!=="number"||!isFinite(Q)||Q<0)throw new TypeError(`lineToHV: tolerance must be a non-negative finite number, got ${Q}`);let{command:K,args:q}=$;if(K!=="L"&&K!=="l")return null;if(q.length<2)throw new RangeError(`lineToHV: command ${K} requires at least 2 args, got ${q.length}`);let H=K==="L",W=H?q[0]:J+q[0],j=H?q[1]:Z+q[1];if(Math.abs(j-Z)<Q)return H?{command:"H",args:[W]}:{command:"h",args:[W-J]};if(Math.abs(W-J)<Q)return H?{command:"V",args:[j]}:{command:"v",args:[j-Z]};return null}function QW($,J,Z,Q,K,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 Q!=="number"||!isFinite(Q))throw new TypeError(`lineToZ: startX must be a finite number, got ${Q}`);if(typeof K!=="number"||!isFinite(K))throw new TypeError(`lineToZ: startY must be a finite number, got ${K}`);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 j=H==="L",z=j?W[0]:J+W[0],G=j?W[1]:Z+W[1];return Math.abs(z-Q)<q&&Math.abs(G-K)<q}function KW($,J,Z,Q,K,q,H,W,j=0.5){let z={x0:$,y0:J,cp1x:Z,cp1y:Q,cp2x:K,cp2y:q,x3:H,y3:W,tolerance:j};for(let[Y,V]of Object.entries(z))if(typeof V!=="number"||!isFinite(V))throw new TypeError(`isCurveStraight: ${Y} must be a finite number, got ${V}`);if(j<0)throw new TypeError(`isCurveStraight: tolerance must be non-negative, got ${j}`);let G=(H-$)**2+(W-J)**2;if(G<0.0000000001){let Y=Math.sqrt((Z-$)**2+(Q-J)**2),V=Math.sqrt((K-$)**2+(q-J)**2);return Math.max(Y,V)<j}let F=Math.sqrt(G),_=Math.abs((W-J)*Z-(H-$)*Q+H*J-W*$)/F,U=Math.abs((W-J)*K-(H-$)*q+H*J-W*$)/F;return Math.max(_,U)<j}function qW($,J,Z,Q=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 Q!=="number"||!isFinite(Q)||Q<0)throw new TypeError(`straightCurveToLine: tolerance must be a non-negative finite number, got ${Q}`);let{command:K,args:q}=$;if(K!=="C"&&K!=="c")return null;if(q.length<6)throw new RangeError(`straightCurveToLine: command ${K} requires at least 6 args, got ${q.length}`);let H=K==="C",W=H?q[0]:J+q[0],j=H?q[1]:Z+q[1],z=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(KW(J,Z,W,j,z,G,F,_,Q))return H?{command:"L",args:[F,_]}:{command:"l",args:[F-J,_-Z]};return null}function o9($,J,Z=3,Q=!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 Q!=="boolean")throw new TypeError(`serializeCommand: prevLastArgHadDecimal must be a boolean, got ${typeof Q}`);let{command:K,args:q}=$;if(K==="Z"||K==="z")return{str:"z",lastArgHadDecimal:!1};if(K==="A"||K==="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=[x7(q[0],Z),x7(q[1],Z),x7(q[2],Z),q[3]?"1":"0",q[4]?"1":"0",x7(q[5],Z),x7(q[6],Z)].join(" ");return{str:K+F,lastArgHadDecimal:F.includes(".")}}if(q.length===0)throw new RangeError(`serializeCommand: command ${K} has empty args array (only Z/z should have no args)`);let H=q.map((F)=>x7(F,Z)),W="";for(let F=0;F<H.length;F++){let _=H[F];if(F===0)W=_;else{let Y=H[F-1].includes(".");if(_.startsWith("-"))W+=_;else if(_.startsWith(".")&&Y)W+=_;else W+=" "+_}}let z=(H[H.length-1]||"").includes("."),G=K;if(J==="M"&&K==="L")G="";else if(J==="m"&&K==="l")G="";else if(J===K&&K!=="A"&&K!=="a")G="";if(G)return{str:G+W,lastArgHadDecimal:z};else{let F=H[0]||"";if(F.startsWith("-"))return{str:W,lastArgHadDecimal:z};else if(F.startsWith(".")&&Q)return{str:W,lastArgHadDecimal:z};else return{str:" "+W,lastArgHadDecimal:z}}}function r0($,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="",Q=null,K=!1;for(let q of $){let{str:H,lastArgHadDecimal:W}=o9(q,Q,J,K);Z+=H,Q=q.command,K=W}return Z}function a9($,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:Q=!0,lineShorthands:K=!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 Q!=="boolean")throw new TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof Q}`);if(typeof K!=="boolean")throw new TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof K}`);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 j=$.length,z=i0($);if(z.length===0)return{d:$,originalLength:j,optimizedLength:j,savings:0};let G=0,F=0,_=0,U=0,Y=[];for(let M=0;M<z.length;M++){let X=z[M];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 L=X.command==="A",R=X.args[5],B=X.args[6];X=L?{command:"L",args:[R,B]}:{command:"l",args:[R,B]}}}if(Q&&(X.command==="C"||X.command==="c")){let L=qW(X,G,F,W);if(L)X=L}if(K&&(X.command==="L"||X.command==="l")){let L=ZW(X,G,F);if(L)X=L}if(q&&(X.command==="L"||X.command==="l")){if(QW(X,G,F,_,U))X={command:"z",args:[]}}if(H&&X.command!=="Z"&&X.command!=="z"){let L=C7(X,G,F),R=r9(X,G,F),B=o9(L,null,Z);X=o9(R,null,Z).str.length<B.str.length?R:L}Y.push(X);let k=C7(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=r0(Y,Z);return{d:V,originalLength:j,optimizedLength:V.length,savings:j-V.length}}function t5($,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,Q=0,K=[],q=(H)=>{if(!H||typeof H!=="object")return;if(H.tagName?.toLowerCase()==="path"){let j=H.getAttribute("d");if(j){let z=a9(j,J);if(z.savings>0)H.setAttribute("d",z.d),Z++,Q+=z.savings,K.push({id:H.getAttribute("id")||null,originalLength:z.originalLength,optimizedLength:z.optimizedLength,savings:z.savings})}}for(let j of H.children||[])q(j)};return q($),{pathsOptimized:Z,totalSavings:Q,details:K}}function e5($,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 Q=Z.x-J.x,K=Z.y-J.y,q=Q*Q+K*K;if(q<0.0000000001){let j=$.x-J.x,z=$.y-J.y;return Math.sqrt(j*j+z*z)}let H=Math.abs(K*$.x-Q*$.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 HW($,J);let Z=0,Q=0,K=$[0],q=$[$.length-1];for(let H=1;H<$.length-1;H++){let W=e5($[H],K,q);if(W>Z)Z=W,Q=H}if(Z>J){let H=K6($.slice(0,Q+1),J),W=K6($.slice(Q),J);return H.slice(0,-1).concat(W)}else return[K,q]}function HW($,J){if($.length<=2)return $;let Z=new Array($.length).fill(!1);Z[0]=!0,Z[$.length-1]=!0;let Q=[[0,$.length-1]];while(Q.length>0){let[K,q]=Q.pop();if(q-K<=1)continue;let H=0,W=K,j=$[K],z=$[q];for(let G=K+1;G<q;G++){let F=e5($[G],j,z);if(F>H)H=F,W=G}if(H>J)Z[W]=!0,Q.push([K,W]),Q.push([W,q])}return $.filter((K,q)=>Z[q])}function t9($,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 j=$[W];if(!j||typeof j!=="object")throw new TypeError(`visvalingamWhyatt: point at index ${W} must be an object`);if(typeof j.x!=="number"||!Number.isFinite(j.x))throw new TypeError(`visvalingamWhyatt: point at index ${W} must have a finite numeric x property`);if(typeof j.y!=="number"||!Number.isFinite(j.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,j,z)=>{return Math.abs((j.x-W.x)*(z.y-W.y)-(z.x-W.x)*(j.y-W.y))/2},Q=$.map((W,j)=>({...W,index:j})),K=new Array(Q.length).fill(1/0);for(let W=1;W<Q.length-1;W++)K[W]=Z(Q[W-1],Q[W],Q[W+1]);let q=new Array(Q.length).fill(!0),H=Q.length;while(H>2){let W=1/0,j=-1;for(let F=1;F<Q.length-1;F++)if(q[F]&&K[F]<W)W=K[F],j=F;if(W>=J||j===-1)break;q[j]=!1,H--;let z=j-1;while(z>=0&&!q[z])z--;let G=j+1;while(G<Q.length&&!q[G])G++;if(z>0){let F=z-1;while(F>=0&&!q[F])F--;if(F>=0&&G<Q.length)K[z]=Z(Q[F],Q[z],Q[G])}if(G<Q.length-1){let F=G+1;while(F<Q.length&&!q[F])F++;if(F<Q.length&&z>=0)K[G]=Z(Q[z],Q[G],Q[F])}}return Q.filter((W,j)=>q[j])}function e9($,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 Q=["douglas-peucker","visvalingam"];if(!Q.includes(Z))throw new RangeError(`simplifyPolyline: algorithm must be one of: ${Q.join(", ")}`);if(Z==="visvalingam")return t9($,J*J);return K6($,J)}function WW($){if(!Array.isArray($))throw new TypeError("extractPolylinePoints: commands must be an array");let J=[],Z=0,Q=0,K=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:j}=H,z=(F)=>{if(j.length<F)throw new RangeError(`extractPolylinePoints: command "${W}" requires at least ${F} arguments, got ${j.length}`)},G=(F)=>{if(typeof j[F]!=="number"||!Number.isFinite(j[F]))throw new TypeError(`extractPolylinePoints: command "${W}" argument at index ${F} must be a finite number, got ${j[F]}`)};switch(W){case"M":z(2),G(0),G(1),Z=j[0],Q=j[1],K=Z,q=Q,J.push({x:Z,y:Q});break;case"m":z(2),G(0),G(1),Z+=j[0],Q+=j[1],K=Z,q=Q,J.push({x:Z,y:Q});break;case"L":z(2),G(0),G(1),Z=j[0],Q=j[1],J.push({x:Z,y:Q});break;case"l":z(2),G(0),G(1),Z+=j[0],Q+=j[1],J.push({x:Z,y:Q});break;case"H":z(1),G(0),Z=j[0],J.push({x:Z,y:Q});break;case"h":z(1),G(0),Z+=j[0],J.push({x:Z,y:Q});break;case"V":z(1),G(0),Q=j[0],J.push({x:Z,y:Q});break;case"v":z(1),G(0),Q+=j[0],J.push({x:Z,y:Q});break;case"Z":case"z":if(Z!==K||Q!==q)J.push({x:K,y:q});Z=K,Q=q;break;case"C":z(6),G(4),G(5),Z=j[4],Q=j[5];break;case"c":z(6),G(4),G(5),Z+=j[4],Q+=j[5];break;case"S":case"Q":z(4),G(2),G(3),Z=j[2],Q=j[3];break;case"s":case"q":z(4),G(2),G(3),Z+=j[2],Q+=j[3];break;case"T":z(2),G(0),G(1),Z=j[0],Q=j[1];break;case"t":z(2),G(0),G(1),Z+=j[0],Q+=j[1];break;case"A":z(7),G(5),G(6),Z=j[5],Q=j[6];break;case"a":z(7),G(5),G(6),Z+=j[5],Q+=j[6];break;default:break}}return J}function zW($,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 Q=0;Q<$.length;Q++){let K=$[Q];if(!K||typeof K!=="object")throw new TypeError(`rebuildPathFromPoints: point at index ${Q} must be an object`);if(typeof K.x!=="number"||!Number.isFinite(K.x))throw new TypeError(`rebuildPathFromPoints: point at index ${Q} must have a finite numeric x property`);if(typeof K.y!=="number"||!Number.isFinite(K.y))throw new TypeError(`rebuildPathFromPoints: point at index ${Q} must have a finite numeric y property`)}let Z=[];Z.push({command:"M",args:[$[0].x,$[0].y]});for(let Q=1;Q<$.length;Q++)Z.push({command:"L",args:[$[Q].x,$[Q].y]});if(J)Z.push({command:"Z",args:[]});return Z}function $J($){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 JJ($,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(!$J($)||$.length<3)return{commands:$,simplified:!1,originalPoints:0,simplifiedPoints:0};let Q=WW($),K=Q.length;if(K<3)return{commands:$,simplified:!1,originalPoints:K,simplifiedPoints:K};let q=$[$.length-1].command.toLowerCase()==="z";if(q&&Q.length>1){let z=Q[0],G=Q[Q.length-1];if(Math.abs(G.x-z.x)<0.0000000001&&Math.abs(G.y-z.y)<0.0000000001)Q=Q.slice(0,-1)}let H=e9(Q,J,Z),W=H.length;if(W>=K)return{commands:$,simplified:!1,originalPoints:K,simplifiedPoints:K};return{commands:zW(H,q),simplified:!0,originalPoints:K,simplifiedPoints:W}}function F7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function _7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Precision must be a finite non-negative number, got ${$}`)}function z$($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Tolerance must be a finite non-negative number, got ${$}`)}function U7($,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 QJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((K)=>U7(K));let Q=Z.map((K)=>({command:K.command,args:K.args.map((q)=>{let H=x7(q,J),W=parseFloat(H);if(!Number.isFinite(W))throw new Error(`Invalid numeric value encountered: ${H}`);return W})}));return r0(Q,J)}function KJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;return Z.forEach((Q)=>U7(Q)),r0(Z,J)}function qJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((j)=>U7(j));let Q=0,K=0,q=0,H=0,W=[];for(let j of Z){let z=r9(j,Q,K);W.push(z);let G=C7(j,Q,K);switch(G.command){case"M":Q=G.args[0],K=G.args[1],q=Q,H=K;break;case"L":case"T":Q=G.args[0],K=G.args[1];break;case"H":Q=G.args[0];break;case"V":K=G.args[0];break;case"C":Q=G.args[4],K=G.args[5];break;case"S":case"Q":Q=G.args[2],K=G.args[3];break;case"A":Q=G.args[5],K=G.args[6];break;case"Z":Q=q,K=H;break;default:break}}return r0(W,J)}function HJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((j)=>U7(j));let Q=0,K=0,q=0,H=0,W=[];for(let j of Z){let z=C7(j,Q,K);switch(W.push(z),z.command){case"M":Q=z.args[0],K=z.args[1],q=Q,H=K;break;case"L":case"T":Q=z.args[0],K=z.args[1];break;case"H":Q=z.args[0];break;case"V":K=z.args[0];break;case"C":Q=z.args[4],K=z.args[5];break;case"S":case"Q":Q=z.args[2],K=z.args[3];break;case"A":Q=z.args[5],K=z.args[6];break;case"Z":Q=q,K=H;break;default:break}}return r0(W,J)}function WJ($,J=0.000001,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((z)=>U7(z));let K=0,q=0,H=0,W=0,j=[];for(let z of Q){let G=z;if(z.command==="L"||z.command==="l"){let _=z.command==="L",U=_?z.args[0]:K+z.args[0],Y=_?z.args[1]:q+z.args[1];if(Math.abs(Y-q)<J)G=_?{command:"H",args:[U]}:{command:"h",args:[U-K]};else if(Math.abs(U-K)<J)G=_?{command:"V",args:[Y]}:{command:"v",args:[Y-q]}}j.push(G);let F=C7(G,K,q);switch(F.command){case"M":K=F.args[0],q=F.args[1],H=K,W=q;break;case"L":case"T":K=F.args[0],q=F.args[1];break;case"H":K=F.args[0];break;case"V":q=F.args[0];break;case"C":K=F.args[4],q=F.args[5];break;case"S":case"Q":K=F.args[2],q=F.args[3];break;case"A":K=F.args[5],q=F.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(j,Z)}function zJ($,J=0.000001,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((z)=>U7(z));let K=0,q=0,H=0,W=0,j=[];for(let z=0;z<Q.length;z++){let G=Q[z],F=G;if(G.command==="L"||G.command==="l"){let U=G.command==="L",Y=U?G.args[0]:K+G.args[0],V=U?G.args[1]:q+G.args[1];if((z===Q.length-1||Q[z+1].command==="M"||Q[z+1].command==="m")&&Math.abs(Y-H)<J&&Math.abs(V-W)<J)F={command:"z",args:[]}}j.push(F);let _=C7(F,K,q);switch(_.command){case"M":K=_.args[0],q=_.args[1],H=K,W=q;break;case"L":case"T":K=_.args[0],q=_.args[1];break;case"H":K=_.args[0];break;case"V":q=_.args[0];break;case"C":K=_.args[4],q=_.args[5];break;case"S":case"Q":K=_.args[2],q=_.args[3];break;case"A":K=_.args[5],q=_.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(j,Z)}function v$(...$){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 $Z($){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 l6($,J,Z,Q,K,q,H,W,j){$Z($),v$(J,Z,Q,K,q,H,W,j);let z=1-$,G=z*z,F=G*z,_=$*$,U=_*$;return{x:F*J+3*G*$*Q+3*z*_*q+U*W,y:F*Z+3*G*$*K+3*z*_*H+U*j}}function ZJ($,J,Z,Q,K,q){v$($,J,Z,Q,K,q);let H=K-Z,W=q-Q,j=H*H+W*W;if(j<0.0000000001)return Math.sqrt(($-Z)**2+(J-Q)**2);let z=Math.max(0,Math.min(1,(($-Z)*H+(J-Q)*W)/j)),G=Z+z*H,F=Q+z*W;return Math.sqrt(($-G)**2+(J-F)**2)}function jW($,J,Z,Q,K,q,H,W){v$($,J,Z,Q,K,q,H,W);let j=0,z=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let G of z){let F=l6(G,$,J,Z,Q,K,q,H,W),_=ZJ(F.x,F.y,$,J,H,W);if(_>j)j=_}for(let G=0;G<z.length-1;G++){let F=(z[G]+z[G+1])/2,_=l6(F,$,J,Z,Q,K,q,H,W),U=ZJ(_.x,_.y,$,J,H,W);if(U>j)j=U}for(let G of[0.05,0.95]){let F=l6(G,$,J,Z,Q,K,q,H,W),_=ZJ(F.x,F.y,$,J,H,W);if(_>j)j=_}return j}function GW($,J,Z,Q,K,q,H,W,j){return jW($,J,Z,Q,K,q,H,W)<=j}function jJ($,J=0.5,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((z)=>U7(z));let K=0,q=0,H=0,W=0,j=[];for(let z of Q){let G=z;if(z.command==="C"||z.command==="c"){let _=z.command==="C",U=_?z.args[0]:K+z.args[0],Y=_?z.args[1]:q+z.args[1],V=_?z.args[2]:K+z.args[2],M=_?z.args[3]:q+z.args[3],X=_?z.args[4]:K+z.args[4],k=_?z.args[5]:q+z.args[5];if(GW(K,q,U,Y,V,M,X,k,J))G=_?{command:"L",args:[X,k]}:{command:"l",args:[X-K,k-q]}}j.push(G);let F=C7(G,K,q);switch(F.command){case"M":K=F.args[0],q=F.args[1],H=K,W=q;break;case"L":case"T":K=F.args[0],q=F.args[1];break;case"H":K=F.args[0];break;case"V":q=F.args[0];break;case"C":K=F.args[4],q=F.args[5];break;case"S":case"Q":K=F.args[2],q=F.args[3];break;case"A":K=F.args[5],q=F.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(j,Z)}function GJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;return Z.forEach((Q)=>U7(Q)),r0(Z,J)}function FJ($,J=3){if(F7($),_7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=i0($);if(Z.length===0)return $;Z.forEach((q)=>U7(q));let Q=Math.pow(10,J),K=Z.map((q)=>({command:q.command,args:q.args.map((H)=>Math.round(H*Q)/Q)}));return r0(K,J)}function _J($,J=0.000001,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((z)=>U7(z));let K=0,q=0,H=0,W=0,j=[];for(let z of Q){let G=C7(z,K,q),F=!0;switch(G.command){case"L":case"T":if(Math.abs(G.args[0]-K)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"H":if(Math.abs(G.args[0]-K)<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]-K)<J&&Math.abs(G.args[5]-q)<J&&Math.abs(G.args[0]-K)<J&&Math.abs(G.args[1]-q)<J&&Math.abs(G.args[2]-K)<J&&Math.abs(G.args[3]-q)<J)F=!1;break;case"S":if(Math.abs(G.args[2]-K)<J&&Math.abs(G.args[3]-q)<J&&Math.abs(G.args[0]-K)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"Q":if(Math.abs(G.args[2]-K)<J&&Math.abs(G.args[3]-q)<J&&Math.abs(G.args[0]-K)<J&&Math.abs(G.args[1]-q)<J)F=!1;break;case"A":if(Math.abs(G.args[5]-K)<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(z),G.command){case"M":K=G.args[0],q=G.args[1],H=K,W=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=H,q=W;break;default:break}}return r0(j,Z)}function FW($,J,Z,Q,K,q,H){$Z($),v$(J,Z,Q,K,q,H);let W=1-$,j=W*W,z=$*$;return{x:j*J+2*W*$*Q+z*q,y:j*Z+2*W*$*K+z*H}}function _W($,J,Z,Q,K,q,H,W,j,z){v$($,J,Z,Q,K,q,H,W,j,z);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=l6(_,$,J,Z,Q,K,q,H,W),Y=FW(_,$,J,j,z,H,W),V=Math.sqrt((U.x-Y.x)**2+(U.y-Y.y)**2);if(V>G)G=V}return G}function UW($,J,Z,Q,K,q,H,W,j){v$($,J,Z,Q,K,q,H,W),z$(j);let z=(3*(Z+K)-$-H)/4,G=(3*(Q+q)-J-W)/4;if(_W($,J,Z,Q,K,q,H,W,z,G)<=j)return{cpx:z,cpy:G};return null}function UJ($,J=0.5,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((z)=>U7(z));let K=0,q=0,H=0,W=0,j=[];for(let z of Q){let G=z;if(z.command==="C"||z.command==="c"){let _=z.command==="C",U=_?z.args[0]:K+z.args[0],Y=_?z.args[1]:q+z.args[1],V=_?z.args[2]:K+z.args[2],M=_?z.args[3]:q+z.args[3],X=_?z.args[4]:K+z.args[4],k=_?z.args[5]:q+z.args[5],L=UW(K,q,U,Y,V,M,X,k,J);if(L)G=_?{command:"Q",args:[L.cpx,L.cpy,X,k]}:{command:"q",args:[L.cpx-K,L.cpy-q,X-K,k-q]}}j.push(G);let F=C7(G,K,q);switch(F.command){case"M":K=F.args[0],q=F.args[1],H=K,W=q;break;case"L":case"T":K=F.args[0],q=F.args[1];break;case"H":K=F.args[0];break;case"V":q=F.args[0];break;case"C":K=F.args[4],q=F.args[5];break;case"S":case"Q":K=F.args[2],q=F.args[3];break;case"A":K=F.args[5],q=F.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(j,Z)}function VJ($,J=0.000001,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((F)=>U7(F));let K=0,q=0,H=0,W=0,j=null,z=null,G=[];for(let F of Q){let _=F,U=C7(F,K,q);if(U.command==="Q"&&j!==null){let Y=2*K-j,V=2*q-z;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]-K,U.args[3]-q]}}if(G.push(_),U.command==="Q")j=U.args[0],z=U.args[1];else if(U.command==="T")if(j!==null)j=2*K-j,z=2*q-z;else j=K,z=q;else j=null,z=null;switch(U.command){case"M":K=U.args[0],q=U.args[1],H=K,W=q;break;case"L":case"T":K=U.args[0],q=U.args[1];break;case"H":K=U.args[0];break;case"V":q=U.args[0];break;case"C":K=U.args[4],q=U.args[5];break;case"S":case"Q":K=U.args[2],q=U.args[3];break;case"A":K=U.args[5],q=U.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(G,Z)}function OJ($,J=0.000001,Z=3){F7($),z$(J),_7(Z);let Q=i0($);if(Q.length===0)return $;Q.forEach((F)=>U7(F));let K=0,q=0,H=0,W=0,j=null,z=null,G=[];for(let F of Q){let _=F,U=C7(F,K,q);if(U.command==="C"&&j!==null){let Y=2*K-j,V=2*q-z;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]-K,U.args[3]-q,U.args[4]-K,U.args[5]-q]}}if(G.push(_),U.command==="C")j=U.args[2],z=U.args[3];else if(U.command==="S")j=U.args[0],z=U.args[1];else j=null,z=null;switch(U.command){case"M":K=U.args[0],q=U.args[1],H=K,W=q;break;case"L":case"T":K=U.args[0],q=U.args[1];break;case"H":K=U.args[0];break;case"V":q=U.args[0];break;case"C":K=U.args[4],q=U.args[5];break;case"S":case"Q":K=U.args[2],q=U.args[3];break;case"A":K=U.args[5],q=U.args[6];break;case"Z":K=H,q=W;break;default:break}}return r0(G,Z)}function YJ($,J=3){F7($),_7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((K)=>U7(K));let Q=Z.map((K)=>{if(K.command==="A"||K.command==="a"){let q=[...K.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:K.command,args:q}}return K});return r0(Q,J)}var L$=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"]),LJ=new Set([...L$].map(($)=>$.toLowerCase())),w$=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","filterPrimitiveUnits","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"]),wJ=new Set([...w$].map(($)=>$.toLowerCase())),uW=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),gW=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"]),xW=($)=>{if(!$||typeof $!=="string")return!1;return uW.has($.toLowerCase())},mW=($)=>{if(!$||typeof $!=="string")return!1;let J=$.toLowerCase();return gW.has(J)||J.startsWith("aria-")||J.startsWith("data-")},qZ=new Set(["foreignobject","script","style","title","desc","metadata"]),s6=new Map,dW=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw new Error("Both parameters must be strings");let Z=`${$}|${J}`;if(s6.has(Z))return s6.get(Z);if($.length===0)return J.length;if(J.length===0)return $.length;let Q=[];for(let q=0;q<=J.length;q++)Q[q]=[q];for(let q=0;q<=$.length;q++)Q[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;Q[q][H]=Math.min(Q[q-1][H]+1,Q[q][H-1]+1,Q[q-1][H-1]+W)}let K=Q[J.length][$.length];return s6.set(Z,K),K},pW=()=>s6.clear(),D$=($,J,Z=2)=>{if(!$||typeof $!=="string")return null;if(!J||!(J instanceof Set)||J.size===0)return null;let Q=typeof Z!=="number"||Z<0?2:Z,K=$.toLowerCase(),q=null,H=Q+1;for(let W of J){let j=dW(K,W.toLowerCase());if(j>0&&j<H)H=j,q=W}return q};function r7($){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 cW($,J,Z=100){let Q=new Set,K=$,q=0;while(K!==null&&K!==void 0&&q<Z){if(Q.has(K))return!0;Q.add(K),K=J(K),q++}return q>=Z}function HZ($){if(!$||typeof $!=="string")return $||"";return $.replace(/<(script|style)([^>]*)\sdata-cdata-pending="true"([^>]*)>([\s\S]*?)<\/\1>/gi,(J,Z,Q,K,q)=>{let H=q.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),W=(Q+K).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),j=W?" "+W:"";return`<${Z}${j}><![CDATA[
|
|
19
19
|
${H}
|
|
20
|
-
]]></${Z}>`})}var l6=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,q6=80,s6=6,KZ={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};O.set({precision:q6,rounding:O.ROUND_HALF_UP});var YJ=($)=>$ instanceof O?$:new O($);function a($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function QZ($,J=s6){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=s6;if(Z>q6)Z=q6;let Q=YJ($).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"},X7={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 XJ($){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 qZ($,J=null,Z={}){let K=XJ(J),Q;if(typeof $==="string")Q=$;else Q=W6($,X7.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 H6($,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 W6($,J,Z={}){switch(J){case X7.SVG_STRING:{let K=Q7($,{minify:Z.minify!==!1});return i5(K)}case X7.DOM_ELEMENT:return $;case X7.XML_DOCUMENT:return $;default:{let K=Q7($,{minify:Z.minify!==!1});return i5(K)}}}function F0($){return async function(J,Z={}){let K=w$(J),Q=await H6(J,K),q=Z.outputFormat||(K===D0.DOM_ELEMENT?X7.DOM_ELEMENT:X7.SVG_STRING),H=await $(Q,Z);return W6(H,q,Z)}}var kJ=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((h)=>h.textContent&&h.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=T5($),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 h of I.children)if(a(h))_(h)};_($);let U=new Set,Y=new Set,V=(I)=>{let P=I.getAttribute("id");if(P){if(U.has(P))Y.add(P);U.add(P)}for(let h of I.children)if(a(h))V(h)};V($);let M=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(Y.has(P)){if(M.has(P)){I.removeAttribute("id");return}M.add(P)}let h=z(P),u=G.has(P)||G.has(h);if(W(P));else if(!u&&K)I.removeAttribute("id");else if(Z&&u){let b=w();if(X.set(P,b),h!==P)X.set(h,b);I.setAttribute("id",b)}}for(let h of I.children)if(a(h))R(h)};if(R($),Z){let I=(u)=>{let b=(g)=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let g of u.getAttributeNames()){let v=u.getAttribute(g);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})`)}u.setAttribute(g,v)}if((g==="href"||g==="xlink:href")&&v?.startsWith("#")){let E=v.substring(1),m=z(E);if(X.has(E))u.setAttribute(g,`#${X.get(E)}`);else if(X.has(m))u.setAttribute(g,`#${X.get(m)}`)}if((g==="begin"||g==="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}.`)}u.setAttribute(g,v)}if((g==="values"||g==="from"||g==="to"||g==="by")&&v){for(let[E,m]of X){let c=b(E);v=v.replace(new RegExp(`#${c}([;\\s]|$)`,"g"),`#${m}$1`)}u.setAttribute(g,v)}}for(let g of u.children)if(a(g))I(g)};I($);let P=(u)=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=$.getElementsByTagName("style");for(let u of h){let b=u.textContent;if(!b)continue;for(let[g,v]of X){let E=P(g);b=b.replace(new RegExp(`#${E}([^\\w-]|$)`,"g"),`#${v}$1`),b=b.replace(new RegExp(`url\\(#${E}\\)`,"g"),`url(#${v})`)}u.textContent=b}}return $}),r6=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let j=YJ(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(l6,(j)=>K(j));q.setAttribute("d",z)}if(H==="transform"&&W){let z=W.replace(l6,(j)=>K(j));q.setAttribute("transform",z)}if(H==="points"&&W){let z=W.replace(l6,(j)=>K(j));q.setAttribute("points",z)}}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),HZ=F0(($,J={})=>{let Z=J.precision||6,K=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let z=YJ(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(l6,K);q.setAttribute(H,z)}}for(let H of q.children)if(a(H))Q(H)};return Q($),$}),WZ=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($),$}),zZ=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($),$}),jZ=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"}},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&&a(w)){let R=w.getAttribute(k);if(R!==null)return R;w=w.parentNode}return null},M=(X,k={})=>{if(X.tagName==="foreignObject")return;if(X.tagName.includes(":"))return;if(!X.getAttribute("id")){for(let[h,u]of Object.entries(_))if(!Y(h)&&X.getAttribute(h)===u)X.removeAttribute(h);let P=U[X.tagName.toLowerCase()]||{};for(let[h,u]of Object.entries(P))if(!Y(h)&&X.getAttribute(h)===u)X.removeAttribute(h);if(!Z){for(let h of X.getAttributeNames())if(U$.has(h)&&!Y(h)){let u=X.getAttribute(h),b=V(X,h);if(b!==null&&u===b)X.removeAttribute(h)}}}let w={...k};for(let P of U$){let h=X.getAttribute(P);if(h!==null)w[P]=h}let R=X.tagName.toLowerCase(),I=$6[R]||$6[G(R)];for(let P of[...X.children])if(a(P)){if(P.tagName.includes(":"))continue;let h=P.tagName.toLowerCase(),u=P.getAttribute("id"),b=K&&u,g=(v)=>{let E=v.getAttribute("id");if(E&&Q.has(E))return!0;for(let m of v.children||[])if(a(m)&&g(m))return!0;return!1};if(!F.includes(h)){if(!g(P)&&!b){X.removeChild(P);continue}}if(I&&!I.has(h)&&!I.has(G(h))){if(!g(P)&&!b){X.removeChild(P);continue}}M(P,w)}};return M($,{}),$}),GZ=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($),$}),FZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of[...Z])if(K.children.length===0){if(K.parentNode)K.parentNode.removeChild(K)}return $}),a6=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(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(e$.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",Y=G.getAttribute("display"),V=G.getAttribute("visibility"),M=parseFloat(G.getAttribute("opacity")||"1");if(Y==="none"||V==="hidden"||M===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&&e$.nonRendering.has(_));else if(!Z&&e$.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($),$}),_Z=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 $}),t6=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($),$}),UZ=F0(($,J={})=>{return $}),VZ=F0(($,J={})=>{return $}),e6=F0(($,J={})=>{return $}),$9=F0(($,J={})=>{if(J.preserveVendor)return $;let Z=$.getElementsByTagName("metadata");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),OZ=F0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),MZ=F0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),wJ=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 $}),YZ=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($),$}),XZ=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 $}),kZ=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"),$}),wZ=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 $}),LZ=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 $}),RZ=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=X9(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($),$}),BZ=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=p$(z);W.setAttribute("d",U)}return $}),NZ=F0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=(q)=>{let H=q.getAttribute("transform");if(H){let W=K7(H),z=S8(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,Y=Math.abs(j-_)<0.000001&&Math.abs(G+F)<0.000001,V=0.0000000001;if(!Y&&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($),$}),J9=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($),$}),LJ=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($),$}),IZ=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 $}),CZ=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)&&e$.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 Y of F){if(!U$.has(Y)&&Y!=="class"&&Y!=="style"){U=!1;break}if(j.hasAttribute(Y)){U=!1;break}}if(U&&Q.parentNode){for(let Y of F){let V=Q.getAttribute(Y);if(V!==null)j.setAttribute(Y,V)}Q.parentNode.replaceChild(j,Q)}}}};return K($,!0),$}),PZ=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((Y)=>z.getAttribute(Y)||j.getAttribute(Y));if(!Z&&F)continue;if(!Z&&(z.getAttribute("clip-path")||z.getAttribute("mask")||j.getAttribute("clip-path")||j.getAttribute("mask")))continue;if(!Z){let Y=z.getAttribute("fill"),V=z.getAttribute("stroke"),M=j.getAttribute("fill"),X=j.getAttribute("stroke");if(K(Y)||K(V)||K(M)||K(X))continue}if(!Z){let Y=z.getAttribute("fill-rule")||"nonzero",V=j.getAttribute("fill-rule")||"nonzero";if(Y!==V)continue}if(!Z&&(z.getAttribute("filter")||j.getAttribute("filter")))continue;let _=z.getAttributeNames().filter((Y)=>Y!=="d").sort(),U=j.getAttributeNames().filter((Y)=>Y!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let Y=!0;for(let V of _)if(z.getAttribute(V)!==j.getAttribute(V)){Y=!1;break}if(Y){let V=z.getAttribute("d"),M=j.getAttribute("d");if(z.setAttribute("d",`${V} ${M}`),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($),$}),AZ=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($),$}),EZ=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($),$}),RJ=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 $}),TZ=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 Y=U.match(/([^{]+)\{([^}]+)\}/);if(!Y)continue;let V=Y[1].trim(),M=Y[2].trim(),X=!1;for(let w of u5.preventInlining)if(V.includes(w)){X=!0;break}if(X){q.push(U);continue}let k;try{k=R6(V)}catch(w){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${w.message}`);q.push(U);continue}G.push({selector:V,declarations:M,specificity:k,originalRule:U})}G.sort((U,Y)=>B6(U.specificity,Y.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:Y,specificity:V,originalRule:M}of G)try{let X=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&X.length>1){q.push(M);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 u=P.split(";");for(let b of u){let g=b.indexOf(":");if(g>0){let v=b.substring(0,g).trim(),E=b.substring(g+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 h=Y.split(";");for(let u of h){let b=u.indexOf(":");if(b<=0)continue;let g=u.substring(0,b).trim(),v=u.substring(b+1).trim(),E=v.includes("!important");if(E)v=v.replace(/\s*!important\s*/g,"").trim();let m=I.get(g);if(m){let c=B6(V,m.specificity);if(c<0){if(E&&!m.isImportant)I.set(g,{specificity:V,isImportant:E,value:v})}else if(c===0){if(E||!m.isImportant)I.set(g,{specificity:V,isImportant:E,value:v})}else if(!m.isImportant||E)I.set(g,{specificity:V,isImportant:E,value:v})}else I.set(g,{specificity:V,isImportant:E,value:v})}}}catch(X){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${X.message}`);q.push(M)}for(let U of _){let Y=F.get(U),V=[];for(let[M,{value:X,isImportant:k}]of Y)if(k)V.push(`${M}: ${X} !important`);else V.push(`${M}: ${X}`);U.setAttribute("style",V.join("; "))}if(K&&H.parentNode)if(q.length>0)H.textContent=q.join(`
|
|
21
|
-
`);else H.parentNode.removeChild(H)}return $}),bZ=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($),$}),fZ=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 $}),SZ=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 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 $}),vZ=F0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let K=L8(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=R8(z);if(!j)continue;let G=o$(H),_=s$(H,G,Q).getRenderedBBox(j),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!B8(U,K)){if(H.parentNode)H.parentNode.removeChild(H)}}catch(z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${z.message}`)}}return $}),DZ=F0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),hZ=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 $}),yZ=F0(($,J={})=>{let Z=J.attributes||{};for(let[K,Q]of Object.entries(Z))$.setAttribute(K,Q);return $}),uZ=F0(($,J={})=>{let Z=J.classes||[],K=$.getAttribute("class")||"",Q=K?`${K} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",Q.trim()),$}),gZ=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((Y)=>Q.get(Y)||Y).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 Y=q(_);F=F.replace(new RegExp(`url\\(#${Y}\\)`,"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 Y=q(_);F=F.replace(new RegExp(`(^|;|\\s)${Y}\\.`,"g"),`$1${U}.`)}j.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`)}j.setAttribute(G,F)}}for(let G of j.children)if(a(G))z(G)};return z($),$}),xZ=F0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),mZ=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 $}),dZ=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($),$}),pZ=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($),$}),BJ=F0(async($,J={})=>{let Z={...J,outputFormat:X7.DOM_ELEMENT},K=$;return K=await $9(K,Z),K=await e6(K,Z),K=await t6(K,Z),K=await a6(K,Z),K=await r6(K,Z),K=await J9(K,Z),K=await LJ(K,Z),K=await wJ(K,Z),K=await kJ(K,Z),K=await RJ(K,Z),K}),NJ=F0(($,J={})=>{return $}),cZ=F0(async($,J={})=>{let Z=J.preset||"default",K={...J,outputFormat:X7.DOM_ELEMENT};switch(Z){case"default":return await BJ($,K);case"none":return await NJ($,K);default:return $}}),nZ=F0(async($,J={})=>{let Z=J.config||{},K={...J,outputFormat:X7.DOM_ELEMENT},Q=$;if(Z.removeMetadata!==!1)Q=await $9(Q,K);if(Z.removeComments!==!1)Q=await e6(Q,K);if(Z.cleanupNumericValues!==!1)Q=await r6(Q,K);if(Z.convertColors!==!1)Q=await J9(Q,K);if(Z.removeHiddenElements!==!1)Q=await a6(Q,K);if(Z.removeEmptyContainers!==!1)Q=await t6(Q,K);return Q});function lZ($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var sZ=F0(async($,J={})=>{let Z=Q7($,{minify:J.minify!==!1}),K=await b$(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),oZ=F0(async($,J={})=>{let Z=Q7($,{minify:J.minify!==!1}),K=await b$(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),iZ=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=P7($,"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 Y=r5(_,J.position||0.5);j.setAttribute("fill",Y)}}else j.setAttribute("fill",J.fallbackColor||"#808080")}}let H=P7($,"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 Y=r5(_,J.position||0.5);j.setAttribute("stroke",Y)}}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 r5($,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 a5(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:a5(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 a5($){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 rZ(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 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),M=parseInt(Y.slice(2,4),16),X=parseInt(Y.slice(4,6),16);if(isNaN(V)||isNaN(M)||isNaN(X))return[0,0,0];return[V,M,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 rZ(G,F,_)}function rZ($,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 aZ=F0(async($,J={})=>{let Z=Q7($,{minify:J.minify!==!1}),K=await b$(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),tZ=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 $}),eZ=F0(async($,J={})=>{let Z=Q7($,{minify:J.minify!==!1}),K=await b$(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return u0(K.svg)}),$K=F0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let K of[...Z])K.setAttribute("data-trace-needed","true");return $}),JK=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],_=o6(G,Z),U=o6(F,Z);if(!_||!U)continue;let Y=o$(G),V=o$(F),M=s$(G,Y,H),X=s$(F,V,H);if(K&&!Q){if(M.hasStroke){let w=M.getStrokeExtent().toNumber();_=t5(_,w)}if(X.hasStroke){let w=X.getStrokeExtent().toNumber();U=t5(U,w)}}if(L6(_,U).overlaps)W.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:M.hasStroke?M.strokeWidth.toNumber():0,stroke2:X.hasStroke?X.strokeWidth.toNumber():0,fillRule1:M.fillRule,fillRule2:X.fillRule})}if(W.length>0)$.setAttribute("data-collisions",JSON.stringify(W));return $});function t5($,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 ZK=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=o6(Q,J.samples||10),W=o6(q,J.samples||10);if(H&&W){let z=Y8(H,W);$.setAttribute("data-distance",z.distance.toString())}return $}),KK=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)),$}),QK=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 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(),Y=F.tagName;if(z[Y])Z.push(`Invalid SVG 2.0 element: <${Y}> must be lowercase <${z[Y]}> 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 M=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!M||M.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"),M=F.getAttribute("height");if(V!==null&&!o7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(M!==null&&!o7(M)&&parseFloat(M)<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"),M=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(M!==null&&parseFloat(M)<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 M=V.substring(1);if(!$.getElementById(M))K.push(`<use> references non-existent ID: '${M}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let M=F.getAttribute(V);if(M&&M.startsWith("url(#")){let X=M.match(/url\(#([^)]+)\)/);if(X){let k=X[1];if(!$.getElementById(k))K.push(`<${F.tagName}> ${V} references non-existent ID: '${k}'`)}}}if($6[U]){let V=$6[U];for(let M of F.children)if(a(M)){let X=M.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:WK($),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 M=[],X=V.toLowerCase(),k=(w)=>{if(w.tagName&&w.tagName.toLowerCase()===X)M.push(w);for(let R of w.children||[])if(R&&R.tagName)k(R)};return k($),M},H=(V,M=[])=>{if(V.tagName)M.push(V);for(let X of V.children||[])if(X&&X.tagName)H(X,M);return M},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((M)=>M.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 M=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 M)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 M of["src","href","xlink:href"]){let X=V.getAttribute(M);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 M=q(V),X=M.length;Q.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=X,Q.smil.animationCount+=X;for(let k of M){let w=k.getAttribute("begin")||"",R=k.getAttribute("end")||"",I=(u,b)=>{let g=u.split(";").map((v)=>v.trim()).filter(Boolean);for(let v of g){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"),h=k.getAttribute("onend");if(P||h){if(Q.smil.hasInteractiveAnimations=!0,P?.includes("play()")||h?.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((M)=>M.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(`
|
|
20
|
+
]]></${Z}>`})}var o6=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,W6=80,i6=6,VZ={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};O.set({precision:W6,rounding:O.ROUND_HALF_UP});var BJ=($)=>$ instanceof O?$:new O($);function i($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function OZ($,J=i6){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=i6;if(Z>W6)Z=W6;let K=BJ($).toFixed(Z);if(K.includes("."))return K.replace(/\.?0+$/,"");return K}function nW($){if($===null||$===void 0)return"";return String($).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var h0={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"},k7={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},X7={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function NJ($){if($===null||$===void 0)return X7.STRING;if(typeof $==="object"&&$.nodeType)return X7.DOM_UPDATE;if(typeof $==="string"){let J=$.trim();if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return X7.DOM_REPLACE;if(J.includes("/")||J.includes("\\")||/\.\w+$/.test(J))return X7.FILE;if(J.toLowerCase()==="download")return X7.DOWNLOAD}return X7.STRING}async function YZ($,J=null,Z={}){let Q=NJ(J),K;if(typeof $==="string")K=$;else K=j6($,k7.SVG_STRING,Z);switch(Q){case X7.STRING:return K;case X7.FILE:{if(typeof process!=="undefined"&&process.versions?.node){let q=await import("fs"),W=(await Promise.resolve().then(() => (M$(),Y$))).dirname(J);if(W&&W!=="."&&!q.existsSync(W))q.mkdirSync(W,{recursive:!0});q.writeFileSync(J,K,"utf8");return}throw new Error("File saving requires Node.js environment")}case X7.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=K;return}case X7.DOM_UPDATE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");if(J.tagName?.toLowerCase()==="svg"){let W=new DOMParser().parseFromString(K,"image/svg+xml").documentElement;while(J.attributes.length>0)J.removeAttribute(J.attributes[0].name);for(let j of W.attributes)J.setAttribute(j.name,j.value);J.innerHTML=W.innerHTML}else J.innerHTML=K;return}case X7.DOWNLOAD:{if(typeof document==="undefined"||typeof Blob==="undefined")throw new Error("Download requires browser environment");let q=new Blob([K],{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 K}}function R$($){if($===null||$===void 0)throw new Error("Input cannot be null or undefined");if(typeof $==="string"){let J=$.trim();if(J.startsWith("<"))return h0.SVG_STRING;else if($.startsWith("http://")||$.startsWith("https://"))return h0.URL;else if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return h0.CSS_SELECTOR;else return h0.FILE_PATH}if(typeof HTMLObjectElement!=="undefined"&&$ instanceof HTMLObjectElement)return h0.OBJECT_ELEMENT;if(typeof HTMLEmbedElement!=="undefined"&&$ instanceof HTMLEmbedElement)return h0.EMBED_ELEMENT;if(typeof HTMLIFrameElement!=="undefined"&&$ instanceof HTMLIFrameElement)return h0.IFRAME_ELEMENT;if(i($))return h0.DOM_ELEMENT;if($&&$.nodeType===9)return h0.XML_DOCUMENT;return h0.SVG_STRING}async function z6($,J){switch(J){case h0.SVG_STRING:return x0($);case h0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer!=="undefined"){let Q=new XMLSerializer().serializeToString($);return x0(Q)}return $;case h0.XML_DOCUMENT:{let Z=$.documentElement||$;if(Z&&typeof Z.serialize==="function")return Z;if(typeof XMLSerializer!=="undefined"){let K=new XMLSerializer().serializeToString(Z);return x0(K)}return Z}case h0.FILE_PATH:{let Q=(()=>({})).readFileSync($,"utf8");return x0(Q)}if(typeof process!=="undefined"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),Q=Z($,"utf8");return x0(Q)}throw new Error("File loading requires Node.js environment");case h0.URL:if(typeof fetch!=="undefined"){let Q=await(await fetch($)).text();return x0(Q)}throw new Error("URL loading requires fetch API");case h0.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 x0(new XMLSerializer().serializeToString(Z));let Q=Z.querySelector("svg");if(Q)return x0(new XMLSerializer().serializeToString(Q));throw new Error(`Element "${$}" is not an SVG and contains no SVG`)}throw new Error("CSS selector requires browser environment");case h0.OBJECT_ELEMENT:try{if($.contentDocument&&$.contentDocument.documentElement){let Z=$.contentDocument.documentElement;if(Z.tagName.toLowerCase()==="svg")return x0(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 h0.EMBED_ELEMENT:if(typeof $.getSVGDocument==="function"){let Z=$.getSVGDocument();if(Z&&Z.documentElement)return x0(new XMLSerializer().serializeToString(Z.documentElement))}throw new Error("HTMLEmbedElement: SVG content not accessible");case h0.IFRAME_ELEMENT:try{let Z=$.contentDocument;if(Z&&Z.documentElement){let Q=Z.documentElement;if(Q.tagName.toLowerCase()==="svg")return x0(new XMLSerializer().serializeToString(Q))}}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 j6($,J,Z={}){switch(J){case k7.SVG_STRING:{let Q=q7($,{minify:Z.minify!==!1});return HZ(Q)}case k7.DOM_ELEMENT:return $;case k7.XML_DOCUMENT:return $;default:{let Q=q7($,{minify:Z.minify!==!1});return HZ(Q)}}}function F0($){return async function(J,Z={}){let Q=R$(J),K=await z6(J,Q),q=Z.outputFormat||(Q===h0.DOM_ELEMENT?k7.DOM_ELEMENT:k7.SVG_STRING),H=await $(K,Z);return j6(H,q,Z)}}var CJ=F0(($,J={})=>{let Z=J.minify!==!1,Q=J.remove!==!1,K=J.force||!1,q=J.preserve||[],H=J.preservePrefixes||[];if(!K){let B=$.querySelectorAll("script").length>0,I=Array.from($.querySelectorAll("style")).some((h)=>h.textContent&&h.textContent.trim().length>0);if(B||I)return $}let W=(B)=>{if(q.includes(B))return!0;if(H.some((I)=>B.startsWith(I)))return!0;return!1},j=(B)=>{try{return decodeURI(B)}catch(I){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${I.message}`);return B}},z=u5($),G=new Set;for(let B of z.all)G.add(B),G.add(j(B));let F=new Map,_=(B)=>{let I=B.getAttribute("id");if(I){if(!F.has(I))F.set(I,B)}for(let h of B.children)if(i(h))_(h)};_($);let U=new Set,Y=new Set,V=(B)=>{let I=B.getAttribute("id");if(I){if(U.has(I))Y.add(I);U.add(I)}for(let h of B.children)if(i(h))V(h)};V($);let M=new Set,X=new Map,k=0,L=()=>{let B;do B=`a${k++}`;while(G.has(B)&&!F.has(B));return B},R=(B)=>{let I=B.getAttribute("id");if(I){if(Y.has(I)){if(M.has(I)){B.removeAttribute("id");return}M.add(I)}let h=j(I),g=G.has(I)||G.has(h);if(W(I));else if(!g&&Q)B.removeAttribute("id");else if(Z&&g){let f=L();if(X.set(I,f),h!==I)X.set(h,f);B.setAttribute("id",f)}}for(let h of B.children)if(i(h))R(h)};if(R($),Z){let B=(g)=>{let f=(x)=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let x of g.getAttributeNames()){let D=g.getAttribute(x);if(D&&D.includes("url(#")){for(let[T,d]of X){let c=f(T);D=D.replace(new RegExp(`url\\(#${c}\\)`,"g"),`url(#${d})`);let p=f(encodeURI(T));D=D.replace(new RegExp(`url\\(#${p}\\)`,"g"),`url(#${d})`)}g.setAttribute(x,D)}if((x==="href"||x==="xlink:href")&&D?.startsWith("#")){let T=D.substring(1),d=j(T);if(X.has(T))g.setAttribute(x,`#${X.get(T)}`);else if(X.has(d))g.setAttribute(x,`#${X.get(d)}`)}if((x==="begin"||x==="end")&&D){for(let[T,d]of X){let c=f(T);D=D.replace(new RegExp(`^${c}\\.`,"g"),`${d}.`),D=D.replace(new RegExp(`;${c}\\.`,"g"),`;${d}.`)}g.setAttribute(x,D)}if((x==="values"||x==="from"||x==="to"||x==="by")&&D){for(let[T,d]of X){let c=f(T);D=D.replace(new RegExp(`#${c}([;\\s]|$)`,"g"),`#${d}$1`)}g.setAttribute(x,D)}}for(let x of g.children)if(i(x))B(x)};B($);let I=(g)=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=$.getElementsByTagName("style");for(let g of h){let f=g.textContent;if(!f)continue;for(let[x,D]of X){let T=I(x);f=f.replace(new RegExp(`#${T}([^\\w-]|$)`,"g"),`#${D}$1`),f=f.replace(new RegExp(`url\\(#${T}\\)`,"g"),`url(#${D})`)}g.textContent=f}}return $}),t6=F0(($,J={})=>{let Z=J.precision||6,Q=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let z=BJ(H).toDecimalPlaces(Z).toString();if(z.includes("."))z=z.replace(/0+$/,""),z=z.replace(/\.$/,"");return z},K=(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(r7(W))continue;q.setAttribute(H,Q(W))}if(H==="d"&&W){let j=W.replace(o6,(z)=>Q(z));q.setAttribute("d",j)}if(H==="transform"&&W){let j=W.replace(o6,(z)=>Q(z));q.setAttribute("transform",j)}if(H==="points"&&W){let j=W.replace(o6,(z)=>Q(z));q.setAttribute("points",j)}}for(let H of q.children)if(i(H))K(H)};return K($),$}),MZ=F0(($,J={})=>{let Z=J.precision||6,Q=(q)=>{let H=parseFloat(q);if(isNaN(H))return q;let j=BJ(H).toDecimalPlaces(Z).toString();if(j.includes("."))j=j.replace(/0+$/,""),j=j.replace(/\.$/,"");return j},K=(q)=>{for(let H of["points"]){let W=q.getAttribute(H);if(W){let j=W.replace(o6,Q);q.setAttribute(H,j)}}for(let H of q.children)if(i(H))K(H)};return K($),$}),XZ=F0(($,J={})=>{let Z=["data-name","data-id","class"],Q=["xmlns:serif"],K=(q)=>{for(let H of Z)if(q.hasAttribute(H))q.removeAttribute(H);if(!J.preserveVendor){for(let H of Q)if(q.hasAttribute(H))q.removeAttribute(H)}for(let H of q.children)if(i(H))K(H)};return K($),$}),kZ=F0(($,J={})=>{let Z=(Q)=>{if(Q.hasAttribute("enable-background"))Q.removeAttribute("enable-background");for(let K of Q.children)if(i(K))Z(K)};return Z($),$}),LZ=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(")}),Q=$.querySelectorAll("script").length>0,K=new Set,q=$.outerHTML||"",H=q.matchAll(/url\(#([^)]+)\)/g);for(let X of H)K.add(X[1]);let W=q.matchAll(/xlink:href="#([^"]+)"/g);for(let X of W)K.add(X[1]);let j=q.matchAll(/\shref="#([^"]+)"/g);for(let X of j)K.add(X[1]);let z={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)=>z[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 L=X.parentNode;while(L&&i(L)){let R=L.getAttribute(k);if(R!==null)return R;L=L.parentNode}return null},M=(X,k={})=>{if(X.tagName==="foreignObject")return;if(X.tagName.includes(":"))return;if(!X.getAttribute("id")){for(let[h,g]of Object.entries(_))if(!Y(h)&&X.getAttribute(h)===g)X.removeAttribute(h);let I=U[X.tagName.toLowerCase()]||{};for(let[h,g]of Object.entries(I))if(!Y(h)&&X.getAttribute(h)===g)X.removeAttribute(h);if(!Z){for(let h of X.getAttributeNames())if(O$.has(h)&&!Y(h)){let g=X.getAttribute(h),f=V(X,h);if(f!==null&&g===f)X.removeAttribute(h)}}}let L={...k};for(let I of O$){let h=X.getAttribute(I);if(h!==null)L[I]=h}let R=X.tagName.toLowerCase(),B=Z6[R]||Z6[G(R)];for(let I of[...X.children])if(i(I)){if(I.tagName.includes(":"))continue;let h=I.tagName.toLowerCase(),g=I.getAttribute("id"),f=Q&&g,x=(D)=>{let T=D.getAttribute("id");if(T&&K.has(T))return!0;for(let d of D.children||[])if(i(d)&&x(d))return!0;return!1};if(!F.includes(h)){if(!x(I)&&!f){X.removeChild(I);continue}}if(B&&!B.has(h)&&!B.has(G(h))){if(!x(I)&&!f){X.removeChild(I);continue}}M(I,L)}};return M($,{}),$}),wZ=F0(($,J={})=>{let Z=["x","y","width","height","viewBox"],Q=(K)=>{if(K.tagName==="g"){for(let q of Z)if(K.hasAttribute(q))K.removeAttribute(q)}for(let q of K.children)if(i(q))Q(q)};return Q($),$}),RZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let Q of[...Z])if(Q.children.length===0){if(Q.parentNode)Q.parentNode.removeChild(Q)}return $}),e6=F0(($,J={})=>{let Z=J.force||!1,Q=$.querySelectorAll("script").length>0,K=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)K.add(Y[1])}if((F==="href"||F==="xlink:href")&&_&&_.startsWith("#"))K.add(_.substring(1))}for(let F of G.children)if(i(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(!i(F))continue;let _=F.tagName?.toLowerCase();if(J6.animation.has(_))return!0;if(W(F))return!0}return!1},j=(G)=>{let F=G.getAttribute("id");if(F&&(K.has(F)||Q))return!0;for(let _ of G.children){if(!i(_))continue;if(j(_))return!0}return!1},z=(G,F=!1)=>{let _=G.tagName.toLowerCase(),U=F||_==="defs",Y=G.getAttribute("display"),V=G.getAttribute("visibility"),M=parseFloat(G.getAttribute("opacity")||"1");if(Y==="none"||V==="hidden"||M===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&&J6.nonRendering.has(_));else if(!Z&&J6.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(i(k))z(k,U)};return z($),$}),BZ=F0(($,J={})=>{let Z=$.getElementsByTagName("text"),Q=(H)=>{let W=H.textContent||"";if(H.children)for(let j of H.children)W+=Q(j);return W},K=(H,W)=>{if(!W||W.length===0)return!1;return(H.getAttributeNames?H.getAttributeNames():[]).some((z)=>W.some((G)=>z.startsWith(G+":")))},q=J.preserveNamespaces||[];for(let H of[...Z]){let W=Q(H),j=!W||W.trim()==="",z=K(H,q);if(j&&!z){if(H.parentNode)H.parentNode.removeChild(H)}}return $}),$9=F0(($,J={})=>{let Z=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],Q=$.querySelectorAll("script").length>0,K=new Set,q=(W)=>{for(let j of W.getAttributeNames?W.getAttributeNames():[]){let z=W.getAttribute(j);if(z&&z.includes("url(#")){let G=z.matchAll(/url\(#([^)]+)\)/g);for(let F of G)K.add(F[1])}if((j==="href"||j==="xlink:href")&&z&&z.startsWith("#"))K.add(z.substring(1))}for(let j of W.children||[])if(i(j))q(j)};q($);let H=(W)=>{for(let G of[...W.children])if(i(G))H(G);let j=W.tagName?.toLowerCase();if(!Z.includes(W.tagName)&&!Z.includes(j))return;if(W.getAttribute("href")||W.getAttribute("xlink:href"))return;let z=W.getAttribute("id");if(z&&(K.has(z)||Q))return;if(W.children.length===0){if(W.parentNode)W.parentNode.removeChild(W)}};return H($),$}),NZ=F0(($,J={})=>{return $}),CZ=F0(($,J={})=>{return $}),J9=F0(($,J={})=>{return $}),Z9=F0(($,J={})=>{if(J.preserveVendor)return $;let Z=$.getElementsByTagName("metadata");for(let Q of[...Z])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),IZ=F0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let Q of[...Z])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),PZ=F0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let Q of[...Z])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),IJ=F0(($,J={})=>{if(J.preserveVendor===!0)return $;let Z=J.preserveNamespaces||[],Q=new Set(Z);if(Q.has("sodipodi"))Q.add("inkscape");if(Q.has("inkscape"))Q.add("sodipodi");let K=["inkscape","sodipodi","illustrator","sketch","ai","serif","vectornator","figma"].filter((z)=>!Q.has(z));if(K.length===0)return $;let q=(z)=>{for(let G of[...z.children])if(i(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(K.includes(_)){z.removeChild(G);continue}}q(G)}};q($);let H=(z)=>{for(let G of[...z.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(K.includes(_))z.removeAttribute(G)}}for(let G of z.children)if(i(G))H(G)};H($);let W=new Set,j=(z)=>{for(let F of z.getAttributeNames()){if(F.startsWith("xmlns:"))continue;let _=F.indexOf(":");if(_>0){let U=F.substring(0,_);W.add(U)}}let G=z.tagName.indexOf(":");if(G>0)W.add(z.tagName.substring(0,G));for(let F of z.children)if(i(F))j(F)};j($);for(let z of K){let G=`xmlns:${z}`;if($.hasAttribute(G)&&!W.has(z))$.removeAttribute(G)}return $}),AZ=F0(($,J={})=>{let Z=(Q)=>{for(let K of[...Q.getAttributeNames()]){let q=Q.getAttribute(K);if(q===""||q===null)Q.removeAttribute(K)}for(let K of Q.children)if(i(K))Z(K)};return Z($),$}),EZ=F0(($,J={})=>{let{removeFlowText:Z=!0,removeEmptyDefs:Q=!0,removeEmptyGroups:K=!1}=J,q=["inkscape","sodipodi"],H=["flowRoot","flowPara","flowRegion","flowSpan","flowDiv","flowLine"],W=(z)=>{for(let G of[...z.children])if(i(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(q.includes(_)){z.removeChild(G);continue}}W(G)}};if(W($),Z){let z=(G)=>{for(let F of[...G.children])if(i(F)){if(H.includes(F.tagName)){G.removeChild(F);continue}z(F)}};z($)}let j=(z)=>{for(let G of[...z.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(q.includes(_))z.removeAttribute(G)}}for(let G of z.children)if(i(G))j(G)};j($);for(let z of q)$.removeAttribute(`xmlns:${z}`);if(Q){let z=(G)=>{for(let F of[...G.children])if(i(F))if(F.tagName==="defs"&&F.children.length===0)G.removeChild(F);else z(F)};z($)}if(K){let z=(G)=>{let F=!0;while(F){F=!1;for(let _ of[...G.children])if(i(_))if(_.tagName==="g"&&_.children.length===0){let U=_.hasAttribute("id"),Y=_.hasAttribute("class");if(!U&&!Y)G.removeChild(_),F=!0}else z(_)}};z($)}return $}),TZ=F0(($,J={})=>{let Z=$.getAttribute("width"),Q=$.getAttribute("height"),K=$.getAttribute("viewBox");if(r7(Z)||r7(Q))return $;if(Z&&Q&&K){let q=K.split(/[\s,]+/).map(parseFloat),H=parseFloat(Z),W=parseFloat(Q);if(isNaN(H)||isNaN(W)||q.some((z)=>isNaN(z)))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]-W)<j)$.removeAttribute("viewBox")}return $}),bZ=F0(($,J={})=>{let Z=J.preserveSvgNamespace!==!1,Q=J.removeXlinkNamespace!==!1;if(J.preserveVendor){if(!Z)$.removeAttribute("xmlns");return $}if(!Z)$.removeAttribute("xmlns");if(Q){let K=!1,q=(H)=>{for(let W of H.getAttributeNames())if(W.startsWith("xlink:")){K=!0;return}for(let W of H.children){if(i(W))q(W);if(K)return}};if(q($),!K)$.removeAttribute("xmlns:xlink")}return $.removeAttribute("xmlns:svg"),$}),fZ=F0(($,J={})=>{let Z=$.querySelectorAll("script").length>0,Q=new Set,K=(H)=>{for(let W of H.getAttributeNames()){let j=H.getAttribute(W);if(j&&j.includes("url(#")){let z=j.matchAll(/url\(#([^)]+)\)/g);for(let G of z)Q.add(G[1])}if((W==="href"||W==="xlink:href")&&j&&j.startsWith("#"))Q.add(j.substring(1))}for(let W of H.children)if(i(W))K(W)};K($);let q=$.getElementsByTagName("image");for(let H of[...q]){let W=H.getAttribute("id");if(W&&(Q.has(W)||Z))continue;if(H.parentNode)H.parentNode.removeChild(H)}return $}),SZ=F0(($,J={})=>{let Z=new Set,Q=(q)=>{for(let H of q.getAttributeNames()){let W=q.getAttribute(H);if(W&&W.includes("url(#")){let j=W.matchAll(/url\(#([^)]+)\)/g);for(let z of j)Z.add(z[1])}if((H==="href"||H==="xlink:href")&&W&&W.startsWith("#"))Z.add(W.substring(1))}for(let H of q.children)if(i(H))Q(H)};Q($);let K=$.getElementsByTagName("script");for(let q of[...K]){let H=q.getAttribute("id");if(!H||!Z.has(H)){if(q.parentNode)q.parentNode.removeChild(q)}}return $}),vZ=F0(($,J={})=>{let Z=J.precision||6,Q=J.convertRoundedRects||!1,K=["rect","circle","ellipse","line","polyline","polygon"],q=(H)=>{if(K.includes(H.tagName)){if(H.tagName==="rect"){let j=parseFloat(H.getAttribute("x")||"0"),z=parseFloat(H.getAttribute("y")||"0"),G=parseFloat(H.getAttribute("width")||"0"),F=parseFloat(H.getAttribute("height")||"0");if(isNaN(j)||isNaN(z)||isNaN(G)||isNaN(F)){for(let _ of[...H.children])if(i(_))q(_);return}}if(H.tagName==="rect"&&!Q){let j=parseFloat(H.getAttribute("rx")||"0"),z=parseFloat(H.getAttribute("ry")||"0");if(isNaN(j)||isNaN(z)||j>0||z>0){for(let G of[...H.children])if(i(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(i(G))q(G);return}}let W=L9(H,Z);if(W){let j=new w0("path",{d:W});for(let z of H.getAttributeNames())if(!z.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let G=H.getAttribute(z);if(G!==null)j.setAttribute(z,G)}for(let z of[...H.children])j.appendChild(z);if(H.parentNode)H.parentNode.replaceChild(j,H)}}for(let W of[...H.children])if(i(W))q(W)};return q($),$}),DZ=F0(($,J={})=>{let Z=J.precision||6,Q=J.force||!1,K=new Set,q=(W)=>{for(let j of["href","xlink:href"]){let z=W.getAttribute(j);if(z&&z.startsWith("#"))K.add(z.substring(1))}for(let j of W.children)if(i(j))q(j)};q($);let H=$.getElementsByTagName("path");for(let W of H){let j=W.getAttribute("d");if(!j)continue;let z=W.getAttribute("id");if(!Q&&z&&K.has(z))continue;if(!Q&&W.getAttribute("style"))continue;let G=W.getAttribute("stroke-linecap"),F=G&&G!=="butt";if((j.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!Q&&W.getAttribute("marker-mid"))continue;let U=n$(j);W.setAttribute("d",U)}return $}),hZ=F0(($,J={})=>{let Z=J.precision||6,Q=J.force||!1,K=(q)=>{let H=q.getAttribute("transform");if(H){let W=K7(H),j=m8(W,Z);if(!Q&&j.length>=H.length);else if(!Q&&q.getAttribute("stroke")&&q.getAttribute("stroke")!=="none"){let z=W.data[0][0].toNumber(),G=W.data[0][1].toNumber(),F=W.data[1][0].toNumber(),_=W.data[1][1].toNumber(),U=z*_-G*F,Y=Math.abs(z-_)<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 W of q.children)if(i(W))K(W)};return K($),$}),Q9=F0(($,J={})=>{let Z=["fill","stroke","stop-color","flood-color","lighting-color"],Q=(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 j=W[1];if(j[0]===j[1]&&j[2]===j[3]&&j[4]===j[5])return`#${j[0]}${j[2]}${j[4]}`}return q},K=(q)=>{for(let H of Z){let W=q.getAttribute(H);if(W)q.setAttribute(H,Q(W))}for(let H of q.children)if(i(H))K(H)};return K($),$}),PJ=F0(($,J={})=>{let Z=J.preserveVendor||!1,Q=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"]),K=(q)=>{let H=q.getAttribute("style");if(H){let W=H.split(";").map((z)=>z.trim()).filter((z)=>z),j=[];for(let z of W){let G=z.indexOf(":");if(G===-1)continue;let F=z.substring(0,G).trim(),_=z.substring(G+1).trim();if(F&&_){if(!F.startsWith("-")&&Q.has(F))q.setAttribute(F,_);else if(Z&&F.startsWith("-"))j.push(z)}}if(j.length>0)q.setAttribute("style",j.join("; "));else q.removeAttribute("style")}for(let W of q.children)if(i(W))K(W)};return K($),$}),yZ=F0(($,J={})=>{let Z=$.getElementsByTagName("ellipse");for(let Q of[...Z]){let K=parseFloat(Q.getAttribute("rx")||"0"),q=parseFloat(Q.getAttribute("ry")||"0");if(isNaN(K)||isNaN(q))continue;if(Math.abs(K-q)<0.001){let H=new w0("circle",{});for(let W of Q.getAttributeNames()){let j=Q.getAttribute(W);if(W==="rx"||W==="ry")H.setAttribute("r",j);else H.setAttribute(W,j)}for(let W of[...Q.children])H.appendChild(W);if(Q.parentNode)Q.parentNode.replaceChild(H,Q)}}return $}),uZ=F0(($,J={})=>{let Z=J.force||!1,Q=(K,q=!1,H=!1)=>{let W=K.tagName.toLowerCase(),j=H||W==="switch";for(let z of[...K.children])if(i(z))Q(z,!1,j);if(W!=="g")return;if(!Z&&(q||j))return;if(!Z&&K.getAttribute("filter"))return;if(K.children.length===1){let z=K.children[0];if(!i(z))return;if(!Z&&z.getAttribute("id"))return;let G=Array.from(K.children).some((U)=>i(U)&&J6.animation.has(U.tagName.toLowerCase()));if(!Z&&G)return;let F=K.getAttributeNames(),_=F.some((U)=>{if(O$.has(U))return!1;return z.hasAttribute(U)});if(!Z&&_)return;if(F.length===0){if(K.parentNode)K.parentNode.replaceChild(z,K)}else{let U=!0;for(let Y of F){if(!O$.has(Y)&&Y!=="class"&&Y!=="style"){U=!1;break}if(z.hasAttribute(Y)){U=!1;break}}if(U&&K.parentNode){for(let Y of F){let V=K.getAttribute(Y);if(V!==null)z.setAttribute(Y,V)}K.parentNode.replaceChild(z,K)}}}};return Q($,!0),$}),gZ=F0(($,J={})=>{let Z=J.force||!1,Q=(q)=>q&&q.includes("url("),K=(q)=>{let H=[...q.children].filter((W)=>i(W)&&W.tagName==="path");for(let W=0;W<H.length-1;W++){let j=H[W],z=H[W+1];if(!Z&&(j.children.length>0||z.children.length>0))continue;let F=["marker-start","marker-mid","marker-end"].some((Y)=>j.getAttribute(Y)||z.getAttribute(Y));if(!Z&&F)continue;if(!Z&&(j.getAttribute("clip-path")||j.getAttribute("mask")||z.getAttribute("clip-path")||z.getAttribute("mask")))continue;if(!Z){let Y=j.getAttribute("fill"),V=j.getAttribute("stroke"),M=z.getAttribute("fill"),X=z.getAttribute("stroke");if(Q(Y)||Q(V)||Q(M)||Q(X))continue}if(!Z){let Y=j.getAttribute("fill-rule")||"nonzero",V=z.getAttribute("fill-rule")||"nonzero";if(Y!==V)continue}if(!Z&&(j.getAttribute("filter")||z.getAttribute("filter")))continue;let _=j.getAttributeNames().filter((Y)=>Y!=="d").sort(),U=z.getAttributeNames().filter((Y)=>Y!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let Y=!0;for(let V of _)if(j.getAttribute(V)!==z.getAttribute(V)){Y=!1;break}if(Y){let V=j.getAttribute("d"),M=z.getAttribute("d");if(j.setAttribute("d",`${V} ${M}`),z.parentNode)z.parentNode.removeChild(z);H.splice(W+1,1),W--}}}for(let W of q.children)if(i(W))K(W)};return K($),$}),xZ=F0(($,J={})=>{let Z=(Q)=>{if(Q.tagName==="g")for(let K of[...Q.getAttributeNames()]){if(!O$.has(K))continue;let q=Q.getAttribute(K);if(q){for(let H of Q.children)if(i(H)&&!H.hasAttribute(K))H.setAttribute(K,q);Q.removeAttribute(K)}}for(let K of Q.children)if(i(K))Z(K)};return Z($),$}),mZ=F0(($,J={})=>{let Z=(Q)=>{if(Q.tagName==="g"&&Q.children.length>1)for(let K of O$){let q=null,H=!0;for(let W of Q.children){if(!i(W))continue;let j=W.getAttribute(K);if(!j){H=!1;break}if(q===null)q=j;else if(q!==j){H=!1;break}}if(H&&q){Q.setAttribute(K,q);for(let W of Q.children)if(i(W))W.removeAttribute(K)}}for(let K of Q.children)if(i(K))Z(K)};return Z($),$}),AJ=F0(($,J={})=>{if($.getElementsByTagName("script").length>0&&!J.force)return $;let Q=$.getElementsByTagName("style");for(let K of Q){let q=K.textContent;if(!q||!q.trim())continue;let H=q.includes("<![CDATA[")||q.includes("]]>"),W="",j="";if(H){let z=q.match(/^(\s*<!\[CDATA\[\s*)/),G=q.match(/(\s*\]\]>\s*)$/);if(z)W="<![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(),W||j)q=W+q+j;K.textContent=q}return $}),dZ=F0(($,J={})=>{let Z=J.onlyMatchedOnce!==!1,Q=J.removeStyleElement!==!1,K=$.getElementsByTagName("style"),q=[];for(let H of K){let W=H.getAttribute("type");if(W&&W!=="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 z=j.match(/([^{]+)\{([^}]+)\}/g)||[],G=[];for(let U of z){let Y=U.match(/([^{]+)\{([^}]+)\}/);if(!Y)continue;let V=Y[1].trim(),M=Y[2].trim(),X=!1;for(let L of i5.preventInlining)if(V.includes(L)){X=!0;break}if(X){q.push(U);continue}let k;try{k=N6(V)}catch(L){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${L.message}`);q.push(U);continue}G.push({selector:V,declarations:M,specificity:k,originalRule:U})}G.sort((U,Y)=>C6(U.specificity,Y.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:Y,specificity:V,originalRule:M}of G)try{let X=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&X.length>1){q.push(M);continue}for(let k of X){let L=k,R=!1;while(L){if(L.tagName==="foreignObject"){R=!0;break}L=L.parentNode}if(R)continue;if(!F.has(k))F.set(k,new Map),_.add(k);let B=F.get(k),I=k.getAttribute("style")||"";if(I&&B.size===0){let g=I.split(";");for(let f of g){let x=f.indexOf(":");if(x>0){let D=f.substring(0,x).trim(),T=f.substring(x+1).trim(),d=T.includes("!important");if(d)T=T.replace(/\s*!important\s*/g,"").trim();B.set(D,{specificity:[1,0,0,0],isImportant:d,value:T})}}}let h=Y.split(";");for(let g of h){let f=g.indexOf(":");if(f<=0)continue;let x=g.substring(0,f).trim(),D=g.substring(f+1).trim(),T=D.includes("!important");if(T)D=D.replace(/\s*!important\s*/g,"").trim();let d=B.get(x);if(d){let c=C6(V,d.specificity);if(c<0){if(T&&!d.isImportant)B.set(x,{specificity:V,isImportant:T,value:D})}else if(c===0){if(T||!d.isImportant)B.set(x,{specificity:V,isImportant:T,value:D})}else if(!d.isImportant||T)B.set(x,{specificity:V,isImportant:T,value:D})}else B.set(x,{specificity:V,isImportant:T,value:D})}}}catch(X){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${X.message}`);q.push(M)}for(let U of _){let Y=F.get(U),V=[];for(let[M,{value:X,isImportant:k}]of Y)if(k)V.push(`${M}: ${X} !important`);else V.push(`${M}: ${X}`);U.setAttribute("style",V.join("; "))}if(Q&&H.parentNode)if(q.length>0)H.textContent=q.join(`
|
|
21
|
+
`);else H.parentNode.removeChild(H)}return $}),pZ=F0(($,J={})=>{let Z=(Q)=>{let K=Q.getAttributeNames().sort(),q=K.map((H)=>[H,Q.getAttribute(H)]);for(let H of K)Q.removeAttribute(H);for(let[H,W]of q)Q.setAttribute(H,W);for(let H of Q.children)if(i(H))Z(H)};return Z($),$}),cZ=F0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let Q of Z){let K=[...Q.children].filter((q)=>i(q));K.sort((q,H)=>q.tagName.localeCompare(H.tagName));for(let q of[...Q.children])Q.removeChild(q);for(let q of K)Q.appendChild(q)}return $}),nZ=F0(($,J={})=>{let Z=J.threshold||2,Q=$.getElementsByTagName("path"),K=new Map;for(let W of Q){let j=W.getAttribute("d");if(j){if(!K.has(j))K.set(j,[]);K.get(j).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,j]of K)if(j.length>=Z){let z=`path${H++}`,G=new w0("path",{id:z,d:W});q.appendChild(G);for(let F of j){let _=new w0("use",{href:`#${z}`});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 $}),lZ=F0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let Q=E8(Z);if(!Q)return $;let K=u7($),q=$.getElementsByTagName("path");for(let H of[...q]){let W=H.getAttribute("d");if(!W)continue;try{let j=K$(W),z=T8(j);if(!z)continue;let G=r$(H),_=i$(H,G,K).getRenderedBBox(z),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!b8(U,Q)){if(H.parentNode)H.parentNode.removeChild(H)}}catch(j){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${j.message}`)}}return $}),sZ=F0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let Q of[...Z])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),oZ=F0(($,J={})=>{let Z={new:"_blank",replace:"_self"},Q=!1,K=(q)=>{for(let H of[...q.getAttributeNames()])if(H.startsWith("xlink:")){let W=H.substring(6),j=q.getAttribute(H);if(W==="href")Q=!0;else if(W==="show"){if(!q.hasAttribute("target")){let z=Z[j];if(z)q.setAttribute("target",z)}q.removeAttribute(H)}else if(W==="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(W))q.removeAttribute(H);else Q=!0}for(let H of q.children)if(i(H))K(H)};if(K($),!Q)$.removeAttribute("xmlns:xlink");return $}),iZ=F0(($,J={})=>{let Z=J.attributes||{};for(let[Q,K]of Object.entries(Z))$.setAttribute(Q,K);return $}),rZ=F0(($,J={})=>{let Z=J.classes||[],Q=$.getAttribute("class")||"",K=Q?`${Q} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",K.trim()),$}),aZ=F0(($,J={})=>{let Z=J.prefix||"svg",Q=new Map,K=new Map,q=(z)=>z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=(z)=>{let G=z.getAttribute("id");if(G){let F=`${Z}${G}`;Q.set(G,F),z.setAttribute("id",F)}for(let F of z.children)if(i(F))H(F)};if(H($),J.prefixClassNames!==!1){let z=(F)=>{let _=F.getAttribute("class");if(_){for(let U of _.split(/\s+/))if(U&&!K.has(U))K.set(U,`${Z}${U}`)}for(let U of F.children)if(i(U))z(U)};z($);let G=(F)=>{let _=F.getAttribute("class");if(_){let U=_.split(/\s+/).map((Y)=>K.get(Y)||Y).join(" ");F.setAttribute("class",U)}for(let U of F.children)if(i(U))G(U)};G($)}let W=$.getElementsByTagName("style");for(let z of W){let G=z.textContent;if(!G)continue;for(let[F,_]of Q){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 K){let U=q(F);G=G.replace(new RegExp(`\\.${U}([^\\w-]|$)`,"g"),`.${_}$1`)}z.textContent=G}let j=(z)=>{for(let G of z.getAttributeNames()){let F=z.getAttribute(G);if(F&&F.includes("url(#")){for(let[_,U]of Q){let Y=q(_);F=F.replace(new RegExp(`url\\(#${Y}\\)`,"g"),`url(#${U})`)}z.setAttribute(G,F)}if((G==="href"||G==="xlink:href")&&F?.startsWith("#")){let _=F.substring(1);if(Q.has(_))z.setAttribute(G,`#${Q.get(_)}`)}if(G==="begin"||G==="end"){for(let[_,U]of Q){let Y=q(_);F=F.replace(new RegExp(`(^|;|\\s)${Y}\\.`,"g"),`$1${U}.`)}z.setAttribute(G,F)}if(G==="values"||G==="from"||G==="to"||G==="by"){for(let[_,U]of Q){let Y=q(_);F=F.replace(new RegExp(`#${Y}([;\\s]|$)`,"g"),`#${U}$1`)}z.setAttribute(G,F)}}for(let G of z.children)if(i(G))j(G)};return j($),$}),tZ=F0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),eZ=F0(($,J={})=>{let Z=J.selector||"*",Q=J.attributes||[];try{let K=$.querySelectorAll(Z);for(let q of K)for(let H of Q)if(q.hasAttribute(H))q.removeAttribute(H)}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`)}return $}),$Q=F0(($,J={})=>{let Z=J.pattern?new RegExp(J.pattern):null,Q=J.attrs||[],K=(q)=>{for(let H of[...q.getAttributeNames()])if(Q.includes(H)||Z&&Z.test(H))q.removeAttribute(H);for(let H of q.children)if(i(H))K(H)};return K($),$}),JQ=F0(($,J={})=>{let{name:Z,value:Q}=J;if(!Z)return $;let K=(q)=>{for(let H of[...q.children]){if(!i(H))continue;let W=H.getAttribute(Z);if(Q===void 0){if(W!==null){q.removeChild(H);continue}}else if(W===Q){q.removeChild(H);continue}K(H)}};return K($),$}),EJ=F0(async($,J={})=>{let Z={...J,outputFormat:k7.DOM_ELEMENT},Q=$;return Q=await Z9(Q,Z),Q=await J9(Q,Z),Q=await $9(Q,Z),Q=await e6(Q,Z),Q=await t6(Q,Z),Q=await Q9(Q,Z),Q=await PJ(Q,Z),Q=await IJ(Q,Z),Q=await CJ(Q,Z),Q=await AJ(Q,Z),Q}),TJ=F0(($,J={})=>{return $}),ZQ=F0(async($,J={})=>{let Z=J.preset||"default",Q={...J,outputFormat:k7.DOM_ELEMENT};switch(Z){case"default":return await EJ($,Q);case"none":return await TJ($,Q);default:return $}}),QQ=F0(async($,J={})=>{let Z=J.config||{},Q={...J,outputFormat:k7.DOM_ELEMENT},K=$;if(Z.removeMetadata!==!1)K=await Z9(K,Q);if(Z.removeComments!==!1)K=await J9(K,Q);if(Z.cleanupNumericValues!==!1)K=await t6(K,Q);if(Z.convertColors!==!1)K=await Q9(K,Q);if(Z.removeHiddenElements!==!1)K=await e6(K,Q);if(Z.removeEmptyContainers!==!1)K=await $9(K,Q);return K});function KQ($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var qQ=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),Q=await S$(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return x0(Q.svg)}),HQ=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),Q=await S$(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return x0(Q.svg)}),WQ=F0(($,J={})=>{let Z=u7($),Q=(z)=>{let G=Z.get(z);if(!G)return null;let F=G.getAttribute("href")||G.getAttribute("xlink:href");return F?.startsWith("#")?F.substring(1):null},K=(z,G)=>{let F=z.getAttribute("gradientUnits")||"objectBoundingBox",_=z.getAttribute("gradientTransform");if(cW(G,Q)){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 z of q){let G=z.getAttribute("fill");if(G&&G.includes("url(")){let F=g7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!K(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let Y=WZ(_,J.position||0.5);z.setAttribute("fill",Y)}}else z.setAttribute("fill",J.fallbackColor||"#808080")}}let H=A7($,"stroke");for(let z of H){let G=z.getAttribute("stroke");if(G&&G.includes("url(")){let F=g7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!K(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let Y=WZ(_,J.position||0.5);z.setAttribute("stroke",Y)}}else z.setAttribute("stroke",J.fallbackColor||"#808080")}}let W=[...$.querySelectorAll("linearGradient, radialGradient")],j=(z)=>z.replace(/["\\]/g,"\\$&");for(let z of W){let G=z.getAttribute("id"),F=G?j(G):"";if(!(G&&([...$.querySelectorAll(`[fill*="url(#${F})"]`)].length>0||[...$.querySelectorAll(`[stroke*="url(#${F})"]`)].length>0))&&z.parentNode)z.parentNode.removeChild(z)}return $});function WZ($,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 zZ(Z[0]);let Q=Z.map((W)=>{let j=W.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:zZ(W),opacity:lW(W)}});Q.sort((W,j)=>W.offset-j.offset);let K=null,q=null;for(let W=0;W<Q.length;W++){let j=Q[W];if(j.offset<=J)K=j;if(j.offset>=J&&!q){q=j;break}}if(!K)return Q[0].color;if(!q)return Q[Q.length-1].color;if(K.offset===q.offset)return K.color;let H=(J-K.offset)/(q.offset-K.offset);return oW(K.color,q.color,H)}function zZ($){let J=$.getAttribute("stop-color");if(!J){let Z=$.getAttribute("style");if(Z){let Q=Z.match(/stop-color\s*:\s*([^;]+)/i);if(Q)J=Q[1].trim()}}if(!J)J="#000000";return sW(J)}function lW($){let J=$.getAttribute("stop-opacity");if(!J){let Q=$.getAttribute("style");if(Q){let K=Q.match(/stop-opacity\s*:\s*([^;]+)/i);if(K)J=K[1].trim()}}let Z=J?parseFloat(J):1;return isNaN(Z)?1:Z}function sW($){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 Q=J.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(Q){let K=parseInt(Q[1],10),q=parseInt(Q[2],10),H=parseInt(Q[3],10);return zQ(K,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 oW($,J,Z){let Q=(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),M=parseInt(Y.slice(2,4),16),X=parseInt(Y.slice(4,6),16);if(isNaN(V)||isNaN(M)||isNaN(X))return[0,0,0];return[V,M,X]},[K,q,H]=Q($),[W,j,z]=Q(J),G=Math.round(K+(W-K)*Z),F=Math.round(q+(j-q)*Z),_=Math.round(H+(z-H)*Z);return zQ(G,F,_)}function zQ($,J,Z){let Q=(K)=>{return Math.max(0,Math.min(255,Math.round(K))).toString(16).padStart(2,"0")};return"#"+Q($)+Q(J)+Q(Z)}var jQ=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),Q=await S$(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return x0(Q.svg)}),GQ=F0(($,J={})=>{let Z=(K)=>{if(K.hasAttribute("filter"))K.removeAttribute("filter");for(let q of K.children)if(i(q))Z(q)};Z($);let Q=$.getElementsByTagName("filter");for(let K of[...Q])if(K.parentNode)K.parentNode.removeChild(K);return $}),FQ=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),Q=await S$(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return x0(Q.svg)}),_Q=F0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let Q of[...Z])Q.setAttribute("data-trace-needed","true");return $}),UQ=F0(($,J={})=>{let{samples:Z=10,includeStroke:Q=!0,includeFillOnly:K=!1}=J,q=[...$.getElementsByTagName("path"),...$.getElementsByTagName("rect"),...$.getElementsByTagName("circle"),...$.getElementsByTagName("ellipse")],H=u7($),W=[];for(let j=0;j<q.length;j++)for(let z=j+1;z<q.length;z++){let G=q[j],F=q[z],_=r6(G,Z),U=r6(F,Z);if(!_||!U)continue;let Y=r$(G),V=r$(F),M=i$(G,Y,H),X=i$(F,V,H);if(Q&&!K){if(M.hasStroke){let L=M.getStrokeExtent().toNumber();_=jZ(_,L)}if(X.hasStroke){let L=X.getStrokeExtent().toNumber();U=jZ(U,L)}}if(B6(_,U).overlaps)W.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:M.hasStroke?M.strokeWidth.toNumber():0,stroke2:X.hasStroke?X.strokeWidth.toNumber():0,fillRule1:M.fillRule,fillRule2:X.fillRule})}if(W.length>0)$.setAttribute("data-collisions",JSON.stringify(W));return $});function jZ($,J){if(J<=0||!$||$.length===0)return $;let Z=0,Q=0;for(let K of $)Z+=K.x,Q+=K.y;return Z/=$.length,Q/=$.length,$.map((K)=>{let q=K.x-Z,H=K.y-Q,W=Math.sqrt(q*q+H*H);if(W<0.0001)return K;let j=(W+J)/W;return{x:Z+q*j,y:Q+H*j}})}var VQ=F0(($,J={})=>{let{id1:Z,id2:Q}=J;if(!Z||!Q)return $;let K=$.getElementById(Z),q=$.getElementById(Q);if(!K||!q)return $;let H=r6(K,J.samples||10),W=r6(q,J.samples||10);if(H&&W){let j=C8(H,W);$.setAttribute("data-distance",j.distance.toString())}return $}),OQ=F0(($,J={})=>{let Z=[],Q=[],K=new Set,q=new Set,H=(j)=>{if(j.tagName.includes(":")){let z=j.tagName.split(":")[0];K.add(z)}for(let z of j.getAttributeNames()){let G=j.getAttribute(z);if(z==="xmlns")q.add("");else if(z.startsWith("xmlns:")){let F=z.substring(6);q.add(F)}if(z.includes(":")&&!z.startsWith("xmlns:")){let F=z.split(":")[0];K.add(F)}if(G&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(G))Z.push(`Invalid XML characters in attribute '${z}' 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 z of j.children)if(i(z))H(z)};H($);for(let j of K)if(j&&!q.has(j))Z.push(`Unbound namespace prefix: '${j}' - SVGO would produce invalid XML here`);let W={valid:Z.length===0,errors:Z,warnings:Q,namespacesUsed:[...K],namespacesDeclared:[...q]};return $.setAttribute("data-xml-validation",JSON.stringify(W)),$}),YQ=F0(($,J={})=>{let Z=[],Q=[],K=J.version||"1.1";if($.tagName!=="svg")Z.push("Root element must be <svg>");let q=$.getAttribute("xmlns");if(!q)Q.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 W={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},j={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},z=(F,_=0)=>{if(!F||!F.tagName){Q.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(W.meshGradients.push(V||null),W.needsPolyfills=!0,!V)Q.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)Q.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)Q.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 M=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!M||M.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"),M=F.getAttribute("height");if(V!==null&&!r7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(M!==null&&!r7(M)&&parseFloat(M)<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"),M=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(M!==null&&parseFloat(M)<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 M=V.substring(1);if(!$.getElementById(M))Q.push(`<use> references non-existent ID: '${M}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let M=F.getAttribute(V);if(M&&M.startsWith("url(#")){let X=M.match(/url\(#([^)]+)\)/);if(X){let k=X[1];if(!$.getElementById(k))Q.push(`<${F.tagName}> ${V} references non-existent ID: '${k}'`)}}}if(Z6[U]){let V=Z6[U];for(let M of F.children)if(i(M)){let X=M.tagName.toLowerCase();if(!V.has(X))Q.push(`<${X}> is not a standard child of <${U}>`)}}for(let V of F.children)if(i(V))z(V,_+1)};if(z($),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)`);Q.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:K,errors:Z,warnings:Q,elementsChecked:kQ($),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 $}),iW=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"]),rW=F0(($,J={})=>{let Z=J.verbose||!1,Q=J.printTables!==!1,K={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 M=[],X=V.toLowerCase(),k=(L)=>{if(L.tagName&&L.tagName.toLowerCase()===X)M.push(L);for(let R of L.children||[])if(R&&R.tagName)k(R)};return k($),M},H=(V,M=[])=>{if(V.tagName)M.push(V);for(let X of V.children||[])if(X&&X.tagName)H(X,M);return M},W=q("audio");if(W.length>0)K.media.hasAudio=!0,K.media.audioElements=W.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src"),hasSource:q("source").filter((M)=>M.parentNode===V).length>0}));let j=q("video");if(j.length>0)K.media.hasVideo=!0,K.media.videoElements=j.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src")}));let z=q("foreignObject");for(let V of z){let M=V.children||[],X=!1,k=[],L=(R)=>{let B=R.tagName?.toLowerCase();if(B==="audio"||B==="video")X=!0,k.push({type:B,id:R.getAttribute("id"),src:R.getAttribute("src")});for(let I of R.children||[])if(I&&I.tagName)L(I)};for(let R of M)if(R&&R.tagName)L(R);if(X)K.media.hasAudio=!0,K.media.foreignObjectWithMedia.push({id:V.getAttribute("id"),media:k}),K.media.mediaEmbedMethod="foreignObject"}let G=H($);for(let V of G)for(let M of["src","href","xlink:href"]){let X=V.getAttribute(M);if(X&&X.startsWith("data:audio/"))K.media.hasAudio=!0,K.media.mediaEmbedMethod="data-uri";if(X&&X.startsWith("data:video/"))K.media.hasVideo=!0,K.media.mediaEmbedMethod="data-uri"}let F=["animate","animateTransform","animateMotion","animateColor","set"];for(let V of F){let M=q(V),X=M.length;K.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=X,K.smil.animationCount+=X;for(let k of M){let L=k.getAttribute("begin")||"",R=k.getAttribute("end")||"",B=(g,f)=>{let x=g.split(";").map((D)=>D.trim()).filter(Boolean);for(let D of x){let T=D.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(T){let[,d,c,p]=T;if(iW.has(c))K.smil.hasInteractiveAnimations=!0,K.smil.eventTriggers.push({animationElement:V,animationId:k.getAttribute("id"),attribute:f,event:c,targetId:d||null,offset:p?.trim()||null,parentId:k.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(D)||D==="indefinite")K.smil.timingTriggers.push({animationElement:V,value:D});else if(/\.(begin|end)/.test(D))K.smil.timingTriggers.push({animationElement:V,value:D,type:"syncbase"})}};if(L)B(L,"begin");if(R)B(R,"end");let I=k.getAttribute("onbegin"),h=k.getAttribute("onend");if(I||h){if(K.smil.hasInteractiveAnimations=!0,I?.includes("play()")||h?.includes("play()"))K.info.push(`Animation uses JavaScript to trigger audio playback via ${I?"onbegin":"onend"} handler`)}}}if(K.smil.hasAnimations=K.smil.animationCount>0,K.media.hasAudio)K.compatibility.worksInAllBrowsers=!1,K.warnings.push("SVG contains embedded audio. Browser autoplay policies will block playback in most scenarios."),K.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"]}),K.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(K.media.hasVideo)K.compatibility.worksInAllBrowsers=!1,K.warnings.push("SVG contains embedded video. This has limited browser support and autoplay restrictions.");if(K.smil.hasAnimations)K.info.push(`SVG contains ${K.smil.animationCount} SMIL animation elements`),K.compatibility.issues.push({type:"SMIL_IE_UNSUPPORTED",severity:"LOW",description:"SMIL animations are not supported in IE11",affectedBrowsers:["IE (no support)"]});if(K.smil.hasInteractiveAnimations){let V=[...new Set(K.smil.eventTriggers.map((M)=>M.event))];if(K.info.push(`SVG contains interactive SMIL animations triggered by: ${V.join(", ")}`),V.includes("click")||V.includes("mouseover"))K.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(K.tables={browserSupport:_,usageScenarios:U,smilEventScenarios:Y},Q&&(K.media.hasAudio||K.media.hasVideo||K.smil.hasInteractiveAnimations)){if(console.log(`
|
|
22
22
|
`+"=".repeat(80)),console.log("SVG COMPATIBILITY ANALYSIS REPORT"),console.log("=".repeat(80)),console.log(`
|
|
23
|
-
--- SUMMARY ---`),console.log(`SMIL Animations: ${
|
|
23
|
+
--- SUMMARY ---`),console.log(`SMIL Animations: ${K.smil.animationCount} (${K.smil.hasInteractiveAnimations?"includes interactive":"time-based only"})`),console.log(`Audio Elements: ${K.media.hasAudio?"YES":"NO"}`),console.log(`Video Elements: ${K.media.hasVideo?"YES":"NO"}`),K.media.hasAudio)console.log(`
|
|
24
24
|
--- 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(`
|
|
25
|
-
--- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[V,M]of Object.entries(_)){let X=V.padEnd(11),k=M.smil.padEnd(18),
|
|
26
|
-
--- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let M=V.scenario.substring(0,30).padEnd(30),X=V.protocol.padEnd(9),k=(V.smilWorks?"✅":"❌").padEnd(5),
|
|
27
|
-
--- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of Y){let M=V.trigger.padEnd(29),X=V.description.substring(0,42).padEnd(42);console.log(`│ ${M} │ ${X} │`)}if(console.log("└───────────────────────────────┴────────────────────────────────────────────┘"),
|
|
28
|
-
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of
|
|
29
|
-
--- RECOMMENDATIONS ---`);for(let V of
|
|
25
|
+
--- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[V,M]of Object.entries(_)){let X=V.padEnd(11),k=M.smil.padEnd(18),L=M.audio.padEnd(24),R=M.interactive.padEnd(11);console.log(`│ ${X} │ ${k} │ ${L} │ ${R} │`)}console.log("└─────────────┴────────────────────┴──────────────────────────┴─────────────┘"),console.log(`
|
|
26
|
+
--- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let M=V.scenario.substring(0,30).padEnd(30),X=V.protocol.padEnd(9),k=(V.smilWorks?"✅":"❌").padEnd(5),L=(V.audioWorks?"✅":"❌").padEnd(5),R=(V.interactiveWorks?"✅":"❌").padEnd(11);console.log(`│ ${M} │ ${X} │ ${k} │ ${L} │ ${R} │`)}if(console.log("└────────────────────────────────┴───────────┴───────┴───────┴─────────────┘"),K.smil.hasInteractiveAnimations){console.log(`
|
|
27
|
+
--- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of Y){let M=V.trigger.padEnd(29),X=V.description.substring(0,42).padEnd(42);console.log(`│ ${M} │ ${X} │`)}if(console.log("└───────────────────────────────┴────────────────────────────────────────────┘"),K.smil.eventTriggers.length>0){console.log(`
|
|
28
|
+
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of K.smil.eventTriggers){let M=V.targetId?`${V.targetId}.${V.event}`:V.event;console.log(` - <${V.animationElement}> triggered by: ${M}${V.offset?` ${V.offset}`:""}`)}}}if(K.compatibility.recommendations.length>0){console.log(`
|
|
29
|
+
--- RECOMMENDATIONS ---`);for(let V of K.compatibility.recommendations)console.log(` • ${V}`)}console.log(`
|
|
30
30
|
`+"=".repeat(80)+`
|
|
31
|
-
`)}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,$}),K6={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"}},e5={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}},$Z={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:"➖"},_J={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"],Y=[],V=[];for(let f of U){let A=q(f);Y.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(Y.length>0){if(z.detected.add(X0.SMIL_ANIMATIONS),z.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)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 M=q("style"),X=!1;for(let f of M){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=[],h=[];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:"))h.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 u=q("use"),b=[];for(let f of u){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 g=!1;for(let f of M){let A=f.textContent||"";if(A.includes("@font-face")&&A.includes("url(")){let e=A.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(e){g=!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
|
+
`)}return K.valid=K.errors.length===0,$.setAttribute("data-compatibility-report",JSON.stringify({hasAudio:K.media.hasAudio,hasVideo:K.media.hasVideo,smilCount:K.smil.animationCount,hasInteractive:K.smil.hasInteractiveAnimations,issues:K.compatibility.issues.length})),$._compatibilityReport=K,$}),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}},aW={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"}},tW={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"}},eW={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}},$z={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"}},w={WORKS:"✅",PARTIAL:"⚠️",BLOCKED:"❌",DEPENDS:"❓",NA:"➖"},XJ={RENDER_VECTORS:{default:w.WORKS,exceptions:{}},RENDER_TEXT:{default:w.WORKS,exceptions:{"renderer:imagemagick":{status:w.PARTIAL,note:"Font substitution may occur"},"renderer:batik":{status:w.PARTIAL,note:"Limited font support"}}},RENDER_GRADIENTS:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.PARTIAL,note:"Some gradient types unsupported"}}},RENDER_PATTERNS:{default:w.WORKS,exceptions:{"renderer:resvg":{status:w.PARTIAL,note:"Limited pattern support"}}},RENDER_OPACITY:{default:w.WORKS,exceptions:{}},RENDER_BLENDMODES:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No blend mode support"},"renderer:cairo":{status:w.PARTIAL,note:"Limited blend modes"}}},FONTS_EMBEDDED:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No embedded fonts in img context",browsers:"all"},"syntax:css-bg":{status:w.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"syntax:css-mask":{status:w.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"renderer:imagemagick":{status:w.BLOCKED,note:"Cannot process embedded fonts"}}},FONTS_SYSTEM:{default:w.WORKS,exceptions:{}},FONTS_WEB_SAME:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources in img"},"syntax:css-bg":{status:w.BLOCKED,note:"No external resources in CSS bg"},"load:file":{status:w.PARTIAL,note:"May fail due to local file restrictions"},"renderer:*":{status:w.BLOCKED,note:"Renderers cannot fetch web fonts"}}},FONTS_WEB_CROSS:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources"},"syntax:css-*":{status:w.BLOCKED,note:"No external resources in CSS"},"storage:remote-cors":{status:w.WORKS,note:"Works with CORS headers"},"renderer:*":{status:w.BLOCKED,note:"Renderers cannot fetch fonts"}}},IMAGES_EMBEDDED:{default:w.WORKS,exceptions:{}},IMAGES_LOCAL:{default:w.WORKS,exceptions:{"load:http":{status:w.BLOCKED,note:"Cannot load file:// from http://"},"load:https":{status:w.BLOCKED,note:"Cannot load file:// from https://"},"syntax:img":{status:w.BLOCKED,note:"No external resources in img"}}},IMAGES_REMOTE_SAME:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources in img"},"load:file":{status:w.BLOCKED,note:"Cannot fetch http from file://"}}},IMAGES_REMOTE_CROSS:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources in img"},"storage:remote-cors":{status:w.WORKS,note:"Works with CORS"},"load:file":{status:w.BLOCKED,note:"CORS not applicable"}}},FILTERS_BASIC:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.PARTIAL,note:"Limited filter support"}}},FILTERS_COMPLEX:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"Complex filters unsupported"},"renderer:resvg":{status:w.PARTIAL,note:"Some filters unsupported"},"renderer:qt-svg":{status:w.PARTIAL,note:"Limited filter primitives"}}},MASKS:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"SVG masks not supported"}}},CLIP_PATHS:{default:w.WORKS,exceptions:{}},SMIL_TIMED:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"syntax:img":{status:w.PARTIAL,note:"May animate, no interaction",browsers:["chrome","firefox"]},"syntax:css-bg":{status:w.PARTIAL,note:"May animate, varies by browser"},"renderer:*":{status:w.BLOCKED,note:"Static render, no animation"}}},SMIL_CLICK:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"syntax:img":{status:w.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:w.BLOCKED,note:"No interaction in CSS context"},"syntax:canvas-draw":{status:w.BLOCKED,note:"Rasterized, no interaction"},"renderer:*":{status:w.BLOCKED,note:"No interaction in renderers"}}},SMIL_HOVER:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"syntax:img":{status:w.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:w.BLOCKED,note:"No interaction in CSS context"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},SMIL_FOCUS:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"syntax:img":{status:w.BLOCKED,note:"No interaction"},"syntax:css-*":{status:w.BLOCKED,note:"No interaction"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},SMIL_ACCESSKEY:{default:w.PARTIAL,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"browser:chrome":{status:w.PARTIAL,note:"Limited accessKey support"},"syntax:img":{status:w.BLOCKED,note:"No keyboard in img context"},"syntax:css-*":{status:w.BLOCKED,note:"No keyboard in CSS context"},"renderer:*":{status:w.BLOCKED,note:"No keyboard"}}},SMIL_SYNCBASE:{default:w.WORKS,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No SMIL support"},"syntax:img":{status:w.PARTIAL,note:"Sync works if animation plays"},"renderer:*":{status:w.BLOCKED,note:"No animation"}}},CSS_KEYFRAMES:{default:w.WORKS,exceptions:{"syntax:img":{status:w.WORKS,note:"CSS animations work in img"},"syntax:css-bg":{status:w.WORKS,note:"CSS animations work"},"renderer:*":{status:w.BLOCKED,note:"Static render"}}},CSS_TRANSITIONS:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No interaction for transitions"},"syntax:css-bg":{status:w.BLOCKED,note:"No interaction"},"renderer:*":{status:w.BLOCKED,note:"Static render"}}},CSS_HOVER:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No :hover in img context"},"syntax:css-*":{status:w.BLOCKED,note:"No :hover in CSS context"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},SCRIPT_INLINE:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"Scripts disabled for security"},"syntax:css-*":{status:w.BLOCKED,note:"Scripts disabled in CSS context"},"syntax:canvas-draw":{status:w.BLOCKED,note:"Rasterized, no scripts"},"renderer:*":{status:w.BLOCKED,note:"No script execution"},"display:html-page+syntax:inline-svg":{status:w.WORKS,note:"Runs in page context"},"display:html-page+syntax:object":{status:w.WORKS,note:"Isolated context"},"display:html-page+syntax:embed":{status:w.WORKS,note:"Isolated context"}}},SCRIPT_EXTERNAL:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources"},"syntax:css-*":{status:w.BLOCKED,note:"No external resources"},"load:file":{status:w.PARTIAL,note:"May be blocked by local file restrictions"},"storage:remote-cross":{status:w.BLOCKED,note:"CORS required"},"storage:remote-cors":{status:w.WORKS,note:"Works with CORS"},"renderer:*":{status:w.BLOCKED,note:"No scripts"}}},SCRIPT_MODULE:{default:w.PARTIAL,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No ES modules"},"browser:safari":{status:w.PARTIAL,note:"Limited module support in SVG"},"syntax:img":{status:w.BLOCKED,note:"No scripts"},"syntax:css-*":{status:w.BLOCKED,note:"No scripts"},"renderer:*":{status:w.BLOCKED,note:"No scripts"}}},EVENT_ONCLICK:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events in img context"},"syntax:css-*":{status:w.BLOCKED,note:"No events in CSS context"},"syntax:canvas-draw":{status:w.BLOCKED,note:"Rasterized"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONDBLCLICK:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONMOUSEDOWN:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONMOUSEUP:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOVER:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOUT:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONMOUSEMOVE:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONFOCUS:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:w.BLOCKED,note:"No focus"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONBLUR:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONLOAD:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No scripts/events"},"syntax:css-*":{status:w.BLOCKED,note:"No scripts"},"renderer:*":{status:w.BLOCKED,note:"No scripts"}}},EVENT_ONERROR:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No scripts"},"syntax:css-*":{status:w.BLOCKED,note:"No scripts"},"renderer:*":{status:w.BLOCKED,note:"No scripts"}}},EVENT_ONSCROLL:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No scroll in img"},"syntax:css-*":{status:w.BLOCKED,note:"No scroll"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONWHEEL:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONTOUCH:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No touch events"},"syntax:css-*":{status:w.BLOCKED,note:"No touch"},"display:*-browser":{status:w.NA,note:"No touch on desktop"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},EVENT_ONKEYBOARD:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No keyboard"},"syntax:css-*":{status:w.BLOCKED,note:"No keyboard"},"renderer:*":{status:w.BLOCKED,note:"No events"}}},LINK_INTERNAL:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No links in img"},"syntax:css-*":{status:w.BLOCKED,note:"No links in CSS"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},LINK_EXTERNAL:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No links in img"},"syntax:css-*":{status:w.BLOCKED,note:"No links"},"syntax:object":{status:w.WORKS,note:"Opens in object frame"},"renderer:*":{status:w.BLOCKED,note:"No links"}}},LINK_TARGET:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No links"},"syntax:css-*":{status:w.BLOCKED,note:"No links"},"syntax:object":{status:w.PARTIAL,note:"May not break out of frame"},"renderer:*":{status:w.BLOCKED,note:"No links"}}},LINK_DOWNLOAD:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No links"},"browser:safari":{status:w.PARTIAL,note:"Limited download attr support"},"renderer:*":{status:w.BLOCKED,note:"No links"}}},FOREIGNOBJECT_BASIC:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"foreignObject disabled in img"},"syntax:css-*":{status:w.BLOCKED,note:"foreignObject disabled in CSS"},"syntax:canvas-draw":{status:w.BLOCKED,note:"Security: tainted canvas"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject support"},"renderer:cairo":{status:w.BLOCKED,note:"No foreignObject"},"renderer:resvg":{status:w.BLOCKED,note:"No foreignObject"},"renderer:imagemagick":{status:w.BLOCKED,note:"No foreignObject"}}},FOREIGNOBJECT_HTML:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No HTML rendering"}}},FOREIGNOBJECT_FORM:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"syntax:object":{status:w.PARTIAL,note:"Form submission may be restricted"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No forms"}}},FOREIGNOBJECT_INPUT:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No inputs"}}},FOREIGNOBJECT_CANVAS:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No canvas"}}},FOREIGNOBJECT_VIDEO:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No video"}}},FOREIGNOBJECT_IFRAME:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject"},"syntax:object":{status:w.PARTIAL,note:"Nested contexts may fail"},"browser:ie11":{status:w.BLOCKED,note:"No foreignObject"},"renderer:*":{status:w.BLOCKED,note:"No iframes"}}},AUDIO_EMBEDDED:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg+processing:*-script":{status:w.WORKS,note:"Play on user gesture via JS"},"syntax:script-*":{status:w.WORKS,note:"JS can play on user gesture"}},note:"All browsers block autoplay without user gesture"},AUDIO_LOCAL:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:w.PARTIAL,note:"Needs user gesture"},"load:file":{status:w.PARTIAL,note:"May work locally with gesture"}}},AUDIO_REMOTE:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:w.PARTIAL,note:"Needs user gesture + CORS"},"storage:remote-cors":{status:w.PARTIAL,note:"Needs user gesture"}}},AUDIO_AUTOPLAY:{default:w.BLOCKED,exceptions:{},note:"Autoplay blocked by ALL modern browsers"},AUDIO_CONTROLS:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No foreignObject/audio"},"syntax:css-*":{status:w.BLOCKED,note:"No foreignObject/audio"},"syntax:object":{status:w.PARTIAL,note:"May render controls"}}},VIDEO_EMBEDDED:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:w.PARTIAL,note:"Needs user gesture"},"syntax:script-*":{status:w.WORKS,note:"JS can play on gesture"}}},VIDEO_LOCAL:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:w.PARTIAL,note:"Needs user gesture"}}},VIDEO_REMOTE:{default:w.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:w.PARTIAL,note:"Needs gesture + CORS"}}},VIDEO_AUTOPLAY:{default:w.BLOCKED,exceptions:{"browser:*":{status:w.PARTIAL,note:"May work muted"}},note:"Autoplay only works muted in most browsers"},USE_INTERNAL:{default:w.WORKS,exceptions:{"syntax:img":{status:w.WORKS,note:"Internal refs work"},"syntax:css-*":{status:w.WORKS,note:"Internal refs work"}}},USE_EXTERNAL_SAME:{default:w.PARTIAL,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external refs"},"syntax:css-*":{status:w.BLOCKED,note:"No external refs"},"browser:chrome":{status:w.BLOCKED,note:"External use blocked since Chrome 50"},"browser:firefox":{status:w.BLOCKED,note:"Blocked for security"},"browser:safari":{status:w.PARTIAL,note:"May work same-origin"}},note:"Most browsers block external <use> for security"},USE_EXTERNAL_CROSS:{default:w.BLOCKED,exceptions:{},note:"Cross-origin external <use> blocked by all browsers"},USE_SHADOW_DOM:{default:w.PARTIAL,exceptions:{"browser:ie11":{status:w.BLOCKED,note:"No shadow DOM"},"syntax:img":{status:w.BLOCKED,note:"No styling access"}},note:"Styling shadow DOM from <use> is limited"},MAP_BASIC:{default:w.NA,exceptions:{"syntax:inline-svg":{status:w.WORKS,note:"Can use SVG elements as map"}},note:"Traditional image maps not applicable, use SVG events"},MAP_COORDS:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No events for clickable regions"},"syntax:css-*":{status:w.BLOCKED,note:"No events"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},A11Y_ARIA:{default:w.WORKS,exceptions:{"syntax:img":{status:w.PARTIAL,note:"Only alt text accessible"},"syntax:css-*":{status:w.BLOCKED,note:"No a11y in CSS images"},"renderer:*":{status:w.BLOCKED,note:"No a11y tree"}}},A11Y_ROLE:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"Use alt attribute instead"},"syntax:css-*":{status:w.BLOCKED,note:"No a11y"},"renderer:*":{status:w.BLOCKED,note:"No a11y"}}},A11Y_TITLE:{default:w.WORKS,exceptions:{"syntax:img":{status:w.PARTIAL,note:"May not be read by screen readers"},"syntax:css-*":{status:w.BLOCKED,note:"Not accessible"}}},A11Y_TABINDEX:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:w.BLOCKED,note:"No focus"},"renderer:*":{status:w.BLOCKED,note:"No interaction"}}},META_DATA_ATTRS:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"Not accessible from outside"},"syntax:css-*":{status:w.BLOCKED,note:"Not accessible"}}},META_CLASS:{default:w.WORKS,exceptions:{}},META_ID:{default:w.WORKS,exceptions:{"syntax:img":{status:w.PARTIAL,note:"IDs isolated"}}},EXT_CSS_LINK:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external resources"},"syntax:css-*":{status:w.BLOCKED,note:"No external resources"},"load:file":{status:w.PARTIAL,note:"Local file restrictions"},"renderer:*":{status:w.BLOCKED,note:"No external fetch"}}},EXT_CSS_IMPORT:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No @import"},"syntax:css-*":{status:w.BLOCKED,note:"No @import"},"load:file":{status:w.PARTIAL,note:"May be blocked"},"renderer:*":{status:w.BLOCKED,note:"No external fetch"}}},EXT_XLINK:{default:w.WORKS,exceptions:{"syntax:img":{status:w.BLOCKED,note:"No external xlink"},"syntax:css-*":{status:w.BLOCKED,note:"No external xlink"},"storage:remote-cross":{status:w.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"},Jz=F0(($,J={})=>{let Z=J.verbose||!1,Q=J.printTables!==!1,K=J.includeMetaAnalysis!==!1,q=(v)=>{let E=[],t=v.toLowerCase(),$0=(K0)=>{if(K0.tagName&&K0.tagName.toLowerCase()===t)E.push(K0);for(let V0 of K0.children||[])if(V0&&V0.tagName)$0(V0)};return $0($),E},H=(v,E=[])=>{if(v.tagName)E.push(v);for(let t of v.children||[])if(t&&t.tagName)H(t,E);return E},W=(v,...E)=>{for(let t of E)if(v.getAttribute(t))return!0;return!1},j={detected:new Set,details:{}},z=H($),G=q("script");if(G.length>0){if(j.detected.add(X0.JAVASCRIPT),j.details.javascript={count:G.length,hasExternalSrc:G.some((v)=>v.getAttribute("src")||v.getAttribute("href")||v.getAttribute("xlink:href")),types:G.map((v)=>v.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 v of z){let E=F.filter((t)=>v.getAttribute(t));if(E.length>0)_.push({tag:v.tagName,handlers:E})}if(_.length>0)j.detected.add(X0.EVENT_HANDLERS),j.details.eventHandlers={count:_.length,types:[...new Set(_.flatMap((v)=>v.handlers))],elements:_.slice(0,10)};let U=["animate","animatetransform","animatemotion","animatecolor","set"],Y=[],V=[];for(let v of U){let E=q(v);Y.push(...E);for(let t of E){let $0=t.getAttribute("begin")||"",K0=t.getAttribute("end")||"",V0=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let C0 of V0)if($0.includes(C0)||K0.includes(C0))V.push({element:t.tagName,event:C0,begin:$0,end:K0});if($0.includes("accessKey(")||K0.includes("accessKey("))V.push({element:t.tagName,event:"accessKey",begin:$0,end:K0})}}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((v)=>v.event))],elements:V.slice(0,10)}}let M=q("style"),X=!1;for(let v of M){let E=v.textContent||"";if(E.includes("@keyframes")||E.includes("animation:")||E.includes("animation-name")||E.includes("transition:")||E.includes("transition-property")){X=!0;break}}for(let v of z){let E=v.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"),L=q("video"),R=q("foreignobject");for(let v of R){let E=[],t=[],$0=(K0)=>{let V0=K0.tagName?.toLowerCase();if(V0==="audio")E.push(K0);if(V0==="video")t.push(K0);for(let C0 of K0.children||[])if(C0&&C0.tagName)$0(C0)};for(let K0 of v.children||[])if(K0&&K0.tagName)$0(K0);k.push(...E),L.push(...t)}if(k.length>0)j.detected.add(X0.AUDIO),j.details.audio={count:k.length,hasAutoplay:k.some((v)=>v.hasAttribute("autoplay")),sources:k.map((v)=>({id:v.getAttribute("id"),src:v.getAttribute("src"),isDataUri:(v.getAttribute("src")||"").startsWith("data:"),isExternal:(v.getAttribute("src")||"").startsWith("http")}))};if(L.length>0)j.detected.add(X0.VIDEO),j.details.video={count:L.length,hasAutoplay:L.some((v)=>v.hasAttribute("autoplay"))};let B=q("image"),I=[],h=[];for(let v of B){let E=v.getAttribute("href")||v.getAttribute("xlink:href")||"";if(E.startsWith("http://")||E.startsWith("https://")||E.startsWith("//"))I.push({href:E,element:"image"});else if(E.startsWith("data:"))h.push({type:"data-uri",element:"image"});else if(E&&!E.startsWith("#"))I.push({href:E,element:"image",type:"local"})}if(I.length>0)j.detected.add(X0.EXTERNAL_IMAGES),j.details.externalImages={count:I.length,urls:I.slice(0,5)};let g=q("use"),f=[];for(let v of g){let E=v.getAttribute("href")||v.getAttribute("xlink:href")||"";if(E&&!E.startsWith("#"))f.push({href:E})}if(f.length>0)j.detected.add(X0.EXTERNAL_USE),j.details.externalUse={count:f.length,refs:f.slice(0,5)};let x=!1;for(let v of M){let E=v.textContent||"";if(E.includes("@font-face")&&E.includes("url(")){let t=E.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(t){x=!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((v)=>{let E=!1,t=($0)=>{if($0.tagName?.toLowerCase()==="iframe")E=!0;for(let K0 of $0.children||[])if(K0&&K0.tagName)t(K0)};return t(v),E})},j.details.foreignObject.hasIframe)j.detected.add(X0.IFRAME)}let D=q("filter"),T=q("mask"),d=q("clippath");if(D.length>0)j.detected.add(X0.FILTERS),j.details.filters={count:D.length};if(T.length>0)j.detected.add(X0.MASKS),j.details.masks={count:T.length};if(d.length>0)j.detected.add(X0.CLIP_PATHS),j.details.clipPaths={count:d.length};let c=q("a");if(c.length>0)j.detected.add(X0.HYPERLINKS),j.details.hyperlinks={count:c.length,hasExternal:c.some((v)=>{return(v.getAttribute("href")||v.getAttribute("xlink:href")||"").startsWith("http")})};let p={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},C={FILE:"file://",HTTP:"http://"},y={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},N={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},e={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},r={[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 v of Object.values(N)){q0.bySyntax[v]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let E of j.detected){let t=r[E];if(t&&t[v]){let{file:$0,http:K0,note:V0}=t[v];if($0==="✅")q0.bySyntax[v].file.works.push({feature:E,note:V0});else if($0==="⚠️")q0.bySyntax[v].file.partial.push({feature:E,note:V0});else q0.bySyntax[v].file.blocked.push({feature:E,note:V0});if(K0==="✅")q0.bySyntax[v].http.works.push({feature:E,note:V0});else if(K0==="⚠️")q0.bySyntax[v].http.partial.push({feature:E,note:V0});else q0.bySyntax[v].http.blocked.push({feature:E,note:V0})}}}for(let[v,E]of Object.entries(s)){let t=[],$0=[];for(let K0 of j.detected){let C0={[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"}[K0]||K0;if(E.restrictions.some((o)=>o.toLowerCase().includes(C0.toLowerCase())||o.toLowerCase().includes("no "+C0.toLowerCase())))t.push(C0);else if(E.worksFor.some((Z0)=>Z0.toLowerCase().includes(C0.toLowerCase())))$0.push(C0)}q0.specialCases[v]={syntax:E.syntax,blockedFeatures:t,workingFeatures:$0,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', () => {
|
|
32
32
|
const audio = new Audio(svgAudioDataUri);
|
|
33
33
|
audio.play();
|
|
34
|
-
});`});if(
|
|
34
|
+
});`});if(j.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(j.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(j.detected.has(X0.EXTERNAL_IMAGES)||j.detected.has(X0.EXTERNAL_FONTS)||j.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(j.detected.has(X0.FOREIGN_OBJECT))q0.warnings.push("SVG contains foreignObject - disabled in IMG and CSS contexts");if(j.detected.has(X0.EXTERNAL_USE))q0.warnings.push("External <use> references are blocked by most modern browsers");if(Q){console.log(`
|
|
35
35
|
`+"═".repeat(100)),console.log("SVG COMPREHENSIVE COMPATIBILITY MATRIX ANALYSIS"),console.log("═".repeat(100)),console.log(`
|
|
36
|
-
┌`+"─".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
|
|
37
|
-
┌`+"─".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[
|
|
38
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let
|
|
39
|
-
┌`+"─".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
|
|
40
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let
|
|
41
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let
|
|
36
|
+
┌`+"─".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 K0 of j.detected){let V0=j.details[K0.replace("_","")]||j.details[K0]||{},C0=K0;if(V0.count!==void 0)C0+=` (${V0.count})`;console.log(`│ • ${C0.padEnd(92)} │`)}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
37
|
+
┌`+"─".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[K0,V0]of Object.entries(q0.bySyntax)){let C0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[K0]||K0;for(let y0 of["file","http"]){let o=V0[y0],Z0=o.works.length>0?o.works.length+" features":"-",_0=o.partial.length>0?o.partial.length+" features":"-",O0=o.blocked.length>0?o.blocked.length+" features":"-";console.log(`│ ${C0.padEnd(18)} │ ${(y0+"://").padEnd(9)} │ ${Z0.padEnd(26)} │ ${_0.padEnd(16)} │ ${O0.padEnd(10)} │`)}}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
38
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let v="inline",E=0;for(let[K0,V0]of Object.entries(q0.bySyntax)){let C0=V0.http.works.length*3+V0.http.partial.length-V0.http.blocked.length*2;if(C0>E)E=C0,v=K0}let t={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: ${v.toUpperCase().padEnd(91)} │`),console.log(`│ ${t[v].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(`
|
|
39
|
+
┌`+"─".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 K0 of $0){let V0=q0.specialCases[K0];if(V0){let C0=V0.overallCompat.substring(0,6).padEnd(6),y0=V0.blockedFeatures.slice(0,3).join(", ").substring(0,58).padEnd(58);console.log(`│ ${K0.substring(0,25).padEnd(25)} │ ${C0} │ ${y0} │`)}}if(console.log("└"+"─".repeat(98)+"┘"),q0.warnings.length>0){console.log(`
|
|
40
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let K0 of q0.warnings)console.log(`│ • ${K0.substring(0,94).padEnd(94)} │`);console.log("└"+"─".repeat(98)+"┘")}if(q0.recommendations.length>0){console.log(`
|
|
41
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let K0 of q0.recommendations)console.log(`│ Issue: ${K0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${K0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(j.detected.has(X0.AUDIO))console.log(`
|
|
42
42
|
┌`+"─".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(`
|
|
43
43
|
┌`+"─".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(`
|
|
44
44
|
`+"═".repeat(100)+`
|
|
45
|
-
`)}return $._compatibilityMatrix=q0,$}),
|
|
45
|
+
`)}return $._compatibilityMatrix=q0,$}),Zz=F0(($,J={})=>{let Z=J.printFullMatrix||!1,Q=J.groupBySyntax!==!1,K=J.showOnlyIssues!==!1,q=J.browserDetails!==!1,H=J.filterCapabilities||null,W=(o)=>{let Z0=[],_0=o.toLowerCase(),O0=(N0)=>{if(N0.tagName&&N0.tagName.toLowerCase()===_0)Z0.push(N0);for(let I0 of N0.children||[])if(I0&&I0.tagName)O0(I0)};return O0($),Z0},j=(o,Z0=[])=>{if(o.tagName)Z0.push(o);for(let _0 of o.children||[])if(_0&&_0.tagName)j(_0,Z0);return Z0},z=new Set,G={},F=j($);if(F.length>1)z.add("RENDER_VECTORS"),z.add("RENDER_TRANSFORMS");let U=W("text").concat(W("tspan"));if(U.length>0)z.add("RENDER_TEXT"),G.RENDER_TEXT={count:U.length};let Y=W("linearGradient"),V=W("radialGradient");if(Y.length>0||V.length>0)z.add("RENDER_GRADIENTS"),G.RENDER_GRADIENTS={linear:Y.length,radial:V.length};let M=W("pattern");if(M.length>0)z.add("RENDER_PATTERNS"),G.RENDER_PATTERNS={count:M.length};for(let o of F)if(o.getAttribute("opacity")||o.getAttribute("fill-opacity")||o.getAttribute("stroke-opacity")||(o.getAttribute("style")||"").includes("opacity")){z.add("RENDER_OPACITY");break}for(let o of F)if((o.getAttribute("style")||"").includes("mix-blend-mode")||o.getAttribute("mix-blend-mode")){z.add("RENDER_BLENDMODES");break}let X=W("style");for(let o of X){let Z0=o.textContent||"";if(Z0.includes("@font-face")){if(Z0.includes("data:"))z.add("FONTS_EMBEDDED");else if(Z0.includes("url(")&&Z0.match(/url\s*\(\s*['"]?https?:/))z.add("FONTS_WEB_CROSS");else if(Z0.includes("url("))z.add("FONTS_WEB_SAME")}}if(U.length>0)z.add("FONTS_SYSTEM");let k=W("image");for(let o of k){let Z0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(Z0.startsWith("data:"))z.add("IMAGES_EMBEDDED");else if(Z0.startsWith("http://")||Z0.startsWith("https://")){let _0=!0;try{let O0=new URL(Z0),N0=new URL($.documentURI||$.baseURI||"");_0=O0.origin!==N0.origin}catch(O0){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${O0.message}`);_0=!0}z.add(_0?"IMAGES_REMOTE_CROSS":"IMAGES_REMOTE_SAME")}else if(Z0&&!Z0.startsWith("#"))z.add("IMAGES_LOCAL")}G.IMAGES={count:k.length};let L=W("filter");if(L.length>0){z.add("FILTERS_BASIC");for(let o of L){let Z0=o.outerHTML||"";if(Z0.includes("feTurbulence")||Z0.includes("feLighting")||Z0.includes("feConvolveMatrix")||Z0.includes("feDisplacementMap")){z.add("FILTERS_COMPLEX");break}}G.FILTERS={count:L.length}}let R=W("mask");if(R.length>0)z.add("MASKS"),G.MASKS={count:R.length};let B=W("clippath");if(B.length>0)z.add("CLIP_PATHS"),G.CLIP_PATHS={count:B.length};let I=["animate","animatetransform","animatemotion","animatecolor","set"],h=0,g={timed:0,click:0,hover:0,focus:0,accesskey:0,syncbase:0};for(let o of I){let Z0=W(o);h+=Z0.length;for(let _0 of Z0){let O0=(_0.getAttribute("begin")||"").toLowerCase(),N0=(_0.getAttribute("end")||"").toLowerCase(),I0=O0+" "+N0;if(I0.includes("click")||I0.includes("dblclick"))g.click++,z.add("SMIL_CLICK");if(I0.includes("mouseover")||I0.includes("mouseout")||I0.includes("mouseenter")||I0.includes("mouseleave"))g.hover++,z.add("SMIL_HOVER");if(I0.includes("focus")||I0.includes("blur"))g.focus++,z.add("SMIL_FOCUS");if(I0.includes("accesskey("))g.accesskey++,z.add("SMIL_ACCESSKEY");if(I0.match(/\w+\.(begin|end)/))g.syncbase++,z.add("SMIL_SYNCBASE");if(!I0.includes("click")&&!I0.includes("mouse")&&!I0.includes("focus")&&!I0.includes("accesskey"))g.timed++}}if(h>0)z.add("SMIL_TIMED"),G.SMIL={count:h,triggers:g};let f=!1,x=!1,D=!1;for(let o of X){let Z0=o.textContent||"";if(Z0.includes("@keyframes"))f=!0;if(Z0.includes("transition:")||Z0.includes("transition-property"))x=!0;if(Z0.includes(":hover"))D=!0}if(f)z.add("CSS_KEYFRAMES");if(x)z.add("CSS_TRANSITIONS");if(D)z.add("CSS_HOVER");let T=W("script");if(T.length>0){for(let o of T){let Z0=o.getAttribute("src")||o.getAttribute("href")||o.getAttribute("xlink:href"),_0=o.getAttribute("type")||"";if(Z0)z.add("SCRIPT_EXTERNAL");else z.add("SCRIPT_INLINE");if(_0==="module")z.add("SCRIPT_MODULE")}G.SCRIPTS={count:T.length}}let d=["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 Z0 of d)if(o.getAttribute(Z0)){let _0=c[Z0];if(_0)z.add(_0)}let p=W("a");if(p.length>0){for(let o of p){if((o.getAttribute("href")||o.getAttribute("xlink:href")||"").startsWith("#"))z.add("LINK_INTERNAL");else z.add("LINK_EXTERNAL");if(o.getAttribute("target"))z.add("LINK_TARGET");if(o.getAttribute("download"))z.add("LINK_DOWNLOAD")}G.LINKS={count:p.length}}let C=W("foreignobject");if(C.length>0){z.add("FOREIGNOBJECT_BASIC"),z.add("FOREIGNOBJECT_HTML");for(let o of C){let Z0=(_0)=>{let O0=_0.tagName?.toLowerCase();if(O0==="form")z.add("FOREIGNOBJECT_FORM");if(O0==="input"||O0==="textarea"||O0==="select")z.add("FOREIGNOBJECT_INPUT");if(O0==="canvas")z.add("FOREIGNOBJECT_CANVAS");if(O0==="video")z.add("FOREIGNOBJECT_VIDEO");if(O0==="iframe")z.add("FOREIGNOBJECT_IFRAME");for(let N0 of _0.children||[])if(N0&&N0.tagName)Z0(N0)};Z0(o)}G.FOREIGNOBJECT={count:C.length}}let y=W("audio"),N=W("video");for(let o of C){let Z0=(_0)=>{let O0=_0.tagName?.toLowerCase();if(O0==="audio")y.push(_0);if(O0==="video")N.push(_0);for(let N0 of _0.children||[])if(N0&&N0.tagName)Z0(N0)};Z0(o)}if(y.length>0){for(let o of y){let Z0=o.getAttribute("src")||"",_0=W("source").filter((N0)=>N0.parentNode===o),O0=Z0||(_0.length>0?_0[0].getAttribute("src"):"");if(O0?.startsWith("data:"))z.add("AUDIO_EMBEDDED");else if(O0?.startsWith("http"))z.add("AUDIO_REMOTE");else if(O0)z.add("AUDIO_LOCAL");if(o.hasAttribute("autoplay"))z.add("AUDIO_AUTOPLAY");if(o.hasAttribute("controls"))z.add("AUDIO_CONTROLS")}G.AUDIO={count:y.length}}if(N.length>0){for(let o of N){let Z0=o.getAttribute("src")||"";if(Z0.startsWith("data:"))z.add("VIDEO_EMBEDDED");else if(Z0.startsWith("http"))z.add("VIDEO_REMOTE");else if(Z0)z.add("VIDEO_LOCAL");if(o.hasAttribute("autoplay"))z.add("VIDEO_AUTOPLAY")}G.VIDEO={count:N.length}}let e=W("use");if(e.length>0){for(let o of e){let Z0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(Z0.startsWith("#"))z.add("USE_INTERNAL");else if(Z0.startsWith("http"))z.add("USE_EXTERNAL_CROSS");else if(Z0)z.add("USE_EXTERNAL_SAME")}z.add("USE_SHADOW_DOM"),G.USE={count:e.length}}for(let o of F){for(let Z0 of o.getAttributeNames?.()||[])if(Z0.startsWith("aria-")){z.add("A11Y_ARIA");break}if(o.getAttribute("role"))z.add("A11Y_ROLE");if(o.getAttribute("tabindex"))z.add("A11Y_TABINDEX")}if(W("title").length>0||W("desc").length>0)z.add("A11Y_TITLE");for(let o of F){for(let Z0 of o.getAttributeNames?.()||[])if(Z0.startsWith("data-")){z.add("META_DATA_ATTRS");break}if(o.getAttribute("class"))z.add("META_CLASS");if(o.getAttribute("id"))z.add("META_ID")}for(let o of X)if((o.textContent||"").includes("@import"))z.add("EXT_CSS_IMPORT");for(let o of F)for(let Z0 of o.getAttributeNames?.()||[])if(Z0.startsWith("xlink:")){z.add("EXT_XLINK");break}let r={timestamp:new Date().toISOString(),detectedCapabilities:[...z],capabilityDetails:G,totalCombinations:0,combinationsWithIssues:0,cells:[]},s=(o,Z0,_0,O0,N0,I0)=>{let S=XJ[o];if(!S)return{status:w.DEPENDS,note:"No compatibility data",browsers:[]};let P=S.default,n="",m=[];for(let[l,z0]of Object.entries(S.exceptions||{})){let k0=!1;if(l.startsWith("syntax:")){let E0=l.substring(7);if(E0==="*"||E0===N0.id||E0.includes("*")&&N0.id.startsWith(E0.replace("*","")))k0=!0}else if(l.startsWith("load:")){if(l.substring(5)===_0.id)k0=!0}else if(l.startsWith("storage:")){if(l.substring(8)===O0.id)k0=!0}else if(l.startsWith("display:")){if(l.substring(8)===Z0.id)k0=!0}else if(l.startsWith("renderer:")){let E0=l.substring(9);if(E0==="*"&&Z0.type==="renderer")k0=!0;if(E0===Z0.id)k0=!0}else if(l.startsWith("browser:")){let E0=l.substring(8);if(E0==="*")for(let T0 of Object.values(FZ))m.push({browser:T0.name,status:z0.status,note:z0.note});else{let T0=Object.values(FZ).find((w7)=>w7.id===E0);if(T0)m.push({browser:T0.name,status:z0.status,note:z0.note})}}if(k0)P=z0.status,n=z0.note||""}return{status:P,note:n,browserIssues:m}},q0=Object.values(aW),v=Object.values(tW),E=Object.values(eW),t=Object.values(GZ),$0=Object.values($z);for(let o of q0)for(let Z0 of v)for(let _0 of E)for(let O0 of t)for(let N0 of $0){if(r.totalCombinations++,N0.script&&!["script-inner","script-dom","script-fetch"].includes(O0.id))continue;if(o.type==="renderer"&&O0.html)continue;let I0=[],S={};for(let P of z){if(H){let l=q6[P];if(l&&!H.includes(l.cat))continue}let n=s(P,o,Z0,_0,O0,N0),m=q6[P]||{name:P,cat:"unknown"};if(S[P]={name:m.name,category:m.cat,status:n.status,note:n.note,browserIssues:n.browserIssues},n.status!==w.WORKS&&n.status!==w.NA)I0.push({capability:P,name:m.name,category:m.cat,status:n.status,note:n.note,browserIssues:n.browserIssues})}if(I0.length>0||!K){let P={combination:{display:o.name,displayId:o.id,displayType:o.type,load:Z0.name,loadId:Z0.id,storage:_0.name,storageId:_0.id,syntax:O0.name,syntaxId:O0.id,processing:N0.name,processingId:N0.id},issueCount:I0.length,issues:I0,allCapabilities:S};if(r.cells.push(P),I0.length>0)r.combinationsWithIssues++}}console.log(`
|
|
46
46
|
`+"═".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(`
|
|
47
|
-
┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${
|
|
48
|
-
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let
|
|
49
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let
|
|
50
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${
|
|
51
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of
|
|
52
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ ${
|
|
47
|
+
┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${r.totalCombinations.toString().padEnd(80)} │`),console.log(`│ Combinations with issues: ${r.combinationsWithIssues.toString().padEnd(89)} │`),console.log(`│ Detected capabilities in SVG: ${r.detectedCapabilities.length.toString().padEnd(85)} │`),console.log("└"+"─".repeat(118)+"┘"),console.log(`
|
|
48
|
+
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let K0={};for(let o of z){let Z0=q6[o]||{cat:"unknown",name:o};if(!K0[Z0.cat])K0[Z0.cat]=[];K0[Z0.cat].push({key:o,name:Z0.name})}for(let[o,Z0]of Object.entries(K0)){let _0=o.toUpperCase();console.log(`│ ${_0}:`.padEnd(119)+"│");for(let O0 of Z0){let N0=G[O0.key.split("_")[0]]||{},I0=` • ${O0.name}`;if(N0.count!==void 0)I0+=` (${N0.count})`;console.log(`│ ${I0}`.padEnd(119)+"│")}}if(console.log("└"+"─".repeat(118)+"┘"),Q){console.log(`
|
|
49
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let Z0 of r.cells){let _0=Z0.combination.syntaxId;if(!o[_0])o[_0]=[];o[_0].push(Z0)}for(let[Z0,_0]of Object.entries(o)){let O0=Object.values(GZ).find((S)=>S.id===Z0),N0=O0?O0.name:Z0;console.log(`
|
|
50
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${N0}`.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,P)=>P.issueCount-S.issueCount);let I0=Z?_0:_0.slice(0,20);for(let S of I0){let P=`${(S.combination.displayId||"").substring(0,8)}/${S.combination.loadId}/${(S.combination.storageId||"").substring(0,8)}`,n=S.issueCount.toString(),m=S.issues.filter((z0)=>z0.status===w.BLOCKED).map((z0)=>(z0.name||"").substring(0,15)).slice(0,2).join(", "),l=S.issues.flatMap((z0)=>z0.browserIssues||[]).slice(0,2).map((z0)=>`${z0.browser}: ${z0.note?.substring(0,15)||""}`).join("; ");console.log(`│ ${P.padEnd(28)} │ ${n.padEnd(18)} │ ${(m||"-").substring(0,23).padEnd(23)} │ ${(l||"-").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(`
|
|
51
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of z){let Z0=q6[o]||{name:o,cat:"unknown"},_0=XJ[o];if(console.log(`
|
|
52
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ ${Z0.name} (${Z0.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[O0,N0]of Object.entries(_0.exceptions)){let I0=` ${O0}: ${N0.status} - ${N0.note||"No details"}`;console.log(`│ ${I0.substring(0,116)}`.padEnd(119)+"│")}}console.log("└"+"─".repeat(118)+"┘")}if(q){console.log(`
|
|
53
53
|
╔`+"═".repeat(118)+"╗"),console.log("║ BROWSER-SPECIFIC COMPATIBILITY QUICK REFERENCE"+" ".repeat(70)+"║"),console.log("╚"+"═".repeat(118)+"╝"),console.log(`
|
|
54
|
-
┌`+"─".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[
|
|
55
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let V0=[];if(
|
|
56
|
-
<!-- Isolated: --> <object data="app.svg"></object>`});if([...
|
|
57
|
-
┌`+"─".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
|
|
58
|
-
`).slice(0,3))console.log(`│ ${
|
|
59
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let
|
|
60
|
-
┌`+"─".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,
|
|
61
|
-
⚠️ No embedding methods available for recommendation.`);else{let o=
|
|
54
|
+
┌`+"─".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[Z0,_0]of Object.entries(o)){let O0=_0.filter((N0)=>{let I0=N0.toLowerCase();if(I0.includes("smil")&&[...z].some((S)=>S.startsWith("SMIL_")))return!0;if(I0.includes("autoplay")&&z.has("AUDIO_AUTOPLAY"))return!0;if(I0.includes("blend")&&z.has("RENDER_BLENDMODES"))return!0;if(I0.includes("filter")&&(z.has("FILTERS_BASIC")||z.has("FILTERS_COMPLEX")))return!0;if(I0.includes("foreign")&&[...z].some((S)=>S.startsWith("FOREIGNOBJECT_")))return!0;if(I0.includes("external use")&&(z.has("USE_EXTERNAL_SAME")||z.has("USE_EXTERNAL_CROSS")))return!0;return!1});if(O0.length>0){let N0=O0.slice(0,3).join(", ");console.log(`│ ${Z0.padEnd(12)} │ ${N0.substring(0,101).padEnd(101)} │`)}}console.log("└"+"─".repeat(14)+"┴"+"─".repeat(103)+"┘")}console.log(`
|
|
55
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let V0=[];if(z.has("AUDIO_AUTOPLAY")||z.has("AUDIO_EMBEDDED")||z.has("AUDIO_LOCAL")||z.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(z.has("SMIL_CLICK")||z.has("SMIL_HOVER")||z.has("SMIL_FOCUS")||z.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(z.has("SCRIPT_INLINE")||z.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>
|
|
56
|
+
<!-- Isolated: --> <object data="app.svg"></object>`});if([...z].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(z.has("IMAGES_REMOTE_CROSS")||z.has("FONTS_WEB_CROSS")||z.has("USE_EXTERNAL_CROSS")||z.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(`
|
|
57
|
+
┌`+"─".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 Z0 of(o.code||"").split(`
|
|
58
|
+
`).slice(0,3))console.log(`│ ${Z0}`.substring(0,119).padEnd(119)+"│");console.log("└"+"─".repeat(118)+"┘")}console.log(`
|
|
59
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let C0={};for(let o of t){let Z0=100,_0=[];for(let O0 of z){let N0=q6[O0]||{name:O0,critical:!1},I0=XJ[O0];if(I0){for(let[S,P]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 m=N0.critical?30:10;Z0-=m,_0.push({cap:N0.name,penalty:m,status:P.status})}}}}C0[o.id]={name:o.name,score:Math.max(0,Z0),deductions:_0}}let y0=Object.entries(C0).sort((o,Z0)=>Z0[1].score-o[1].score);console.log(`
|
|
60
|
+
┌`+"─".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,Z0]of y0){let _0=Z0.score===100?"100% ✅":Z0.score>=70?`${Z0.score}% ⚠️`:`${Z0.score}% ❌`,O0=Z0.deductions.slice(0,3).map((N0)=>N0.cap).join(", ")||"None";console.log(`│ ${Z0.name.padEnd(23)} │ ${_0.padEnd(8)} │ ${O0.substring(0,79).padEnd(79)} │`)}if(console.log("└"+"─".repeat(25)+"┴"+"─".repeat(10)+"┴"+"─".repeat(81)+"┘"),y0.length===0)console.log(`
|
|
61
|
+
⚠️ No embedding methods available for recommendation.`);else{let o=y0[0];if(console.log(`
|
|
62
62
|
★ RECOMMENDED: Use "${o[1].name}" for this SVG (score: ${o[1].score}%)`),o[1].score<100)console.log(`
|
|
63
63
|
⚠️ No embedding method achieves 100% compatibility for this SVG.`),console.log(" Consider using embedExternalDependencies() to maximize portability.")}return console.log(`
|
|
64
64
|
`+"═".repeat(120)+`
|
|
65
|
-
`),$._fullCompatibilityMatrix=
|
|
65
|
+
`),$._fullCompatibilityMatrix=r,$});function Qz($,J={}){let Z=J.compact!==!1,Q=J.showAllCells||!1,K=[{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"}],j=[{id:"script",label:"+JS",desc:"With JavaScript"},{id:"noscript",label:"-JS",desc:"No JavaScript"}],z=[{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=K.length*q.length,_=H.length*W.length*j.length,U=Z?18:28,Y=25,V=Z?2:3;console.log(`
|
|
66
66
|
`),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(`
|
|
67
|
-
`);let M=q.length*U,X=26+
|
|
68
|
-
┌`+"─".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
|
|
69
|
-
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let
|
|
70
|
-
┌`+"─".repeat(30)+"┬"+"─".repeat(
|
|
71
|
-
`),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
|
|
72
|
-
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let
|
|
67
|
+
`);let M=q.length*U,X=26+K.length*(M+1),k="".padEnd(25)+"│";for(let C of K){let y=`${C.label} (${C.desc})`;k+=y.padStart(Math.floor(M/2)+Math.floor(y.length/2)).padEnd(M)+"│"}console.log("┌"+"─".repeat(25)+"┬"+K.map(()=>"─".repeat(M)).join("┬")+"┐"),console.log("│"+"SYNTAX →".padEnd(25)+k.substring(26));let L="".padEnd(25)+"│";for(let C of K){for(let y of q){let N=`${y.label}`;L+=N.padStart(Math.floor(U/2)+Math.floor(N.length/2)).padEnd(U)}L+="│"}console.log("│"+"STORAGE →".padEnd(25)+L.substring(26));let R="".padEnd(25)+"│";for(let C of K){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)+"┼"+K.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼")+"┤");let B=(C,y,N,e,r)=>{let s={browserStatus:{},funcStatus:{},overallStatus:"ok",issueCount:0,browserCount:0};for(let t of z){s.browserStatus[t.id]={};for(let[$0]of Object.entries(G))s.browserStatus[t.id][$0]="ok"}for(let[t]of Object.entries(G))s.funcStatus[t]="ok";if(e==="img"||e==="css"){let t=["animation","scripting","events","html","media","links"];for(let $0 of t){s.funcStatus[$0]="block";for(let K0 of z)s.browserStatus[K0.id][$0]="block"}if(N==="remote"){s.funcStatus.images="block",s.funcStatus.fonts="block";for(let $0 of z)s.browserStatus[$0.id].images="block",s.browserStatus[$0.id].fonts="block"}}if(C==="renderer"){let t=["animation","scripting","events","media"];for(let $0 of t){s.funcStatus[$0]="block";for(let K0 of z)s.browserStatus[K0.id][$0]="block"}s.funcStatus.html="block";for(let $0 of z)s.browserStatus[$0.id].html="block"}if(r==="noscript"){s.funcStatus.scripting="block",s.funcStatus.events="warn";for(let t of z)s.browserStatus[t.id].scripting="block",s.browserStatus[t.id].events="warn"}if(s.browserStatus.ie11.animation="block",s.browserStatus.ie11.html="block",s.browserStatus.ie11.sprites="warn",$.detectedCapabilities?.some((t)=>t.startsWith("AUDIO_")||t.startsWith("VIDEO_"))){for(let t of z)if(s.browserStatus[t.id].media!=="block")s.browserStatus[t.id].media="warn";s.browserStatus.ios.media="block",s.funcStatus.media="warn"}if(N==="remote"){s.funcStatus.images=s.funcStatus.images==="block"?"block":"warn",s.funcStatus.fonts=s.funcStatus.fonts==="block"?"block":"warn",s.funcStatus.sprites=s.funcStatus.sprites==="block"?"block":"warn";for(let t of z){if(s.browserStatus[t.id].images!=="block")s.browserStatus[t.id].images="warn";if(s.browserStatus[t.id].fonts!=="block")s.browserStatus[t.id].fonts="warn"}}if(y==="file"){if(N==="remote")s.funcStatus.images="warn",s.funcStatus.fonts="warn",s.funcStatus.links="warn"}if(y==="data"){if(N==="remote"||N==="local")s.funcStatus.images="warn",s.funcStatus.fonts="warn"}let q0=!1,v=!1,E=new Set;for(let[t,$0]of Object.entries(s.funcStatus))if($0==="block")q0=!0,s.issueCount++;else if($0==="warn")v=!0,s.issueCount++;for(let t of z)for(let[$0,K0]of Object.entries(s.browserStatus[t.id]))if(K0!=="ok")E.add(t.id);return s.browserCount=E.size,s.overallStatus=q0?"block":v?"warn":"ok",s},I=(C,y)=>{let N=[],e={ok:"✓",warn:"⚠",block:"✗"};if(C.overallStatus==="ok")return N.push("✅ ALL OK".padStart(Math.floor(y/2)+5).padEnd(y)),N.push("".padEnd(y)),N;let r="";for(let q0 of z){let v="ok";for(let[E,t]of Object.entries(C.browserStatus[q0.id]))if(t==="block"){v="block";break}else if(t==="warn"&&v!=="block")v="warn";r+=`${q0.code}${e[v]}`}N.push(r.padStart(Math.floor(y/2)+Math.floor(r.length/2)).padEnd(y));let s="";for(let[q0,v]of Object.entries(G)){let E=C.funcStatus[q0];if(E!=="ok")s+=`${v.icon}${e[E]}`}if(s==="")s="(ok)";return N.push(s.padStart(Math.floor(y/2)+Math.floor(s.length/2)).padEnd(y)),N},h=(C,y)=>{let N={ok:"✓",warn:"⚠",block:"✗"};if(C.overallStatus==="ok")return"✅".padStart(Math.floor(y/2)+1).padEnd(y);let e=C.overallStatus==="block"?"❌":"⚠️",r=`${C.browserCount}B`,s=`${C.issueCount}F`,q0=`${e}${r}${s}`;return q0.padStart(Math.floor(y/2)+Math.floor(q0.length/2)).padEnd(y)};for(let C of H){let y=K.map(()=>q.map(()=>" ".repeat(U)).join(" ")).join("│");console.log("│ "+(C.label+":").padEnd(23)+"│"+y+"│");for(let N of W){for(let e of j){let r=[];for(let $0 of K)for(let K0 of q){let V0=B(C.id,N.id,K0.id,$0.id,e.id);r.push(V0)}let s=r.map(($0)=>I($0,U)),v="│"+` ${N.label} ${e.label}`.padEnd(25)+"│",E=0;for(let $0=0;$0<K.length;$0++){for(let K0=0;K0<q.length;K0++)v+=s[E][0],E++;v+="│"}console.log(v.substring(0,v.length-1));let t="│"+"".padEnd(25)+"│";E=0;for(let $0=0;$0<K.length;$0++){for(let K0=0;K0<q.length;K0++)t+=s[E][1],E++;t+="│"}if(console.log(t.substring(0,t.length-1)),e!==j[j.length-1]){let $0=K.map(()=>q.map(()=>"·".repeat(U)).join("·")).join("│");console.log("│"+"·".repeat(25)+"│"+$0+"│")}}if(N!==W[W.length-1]){let e=K.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼");console.log("├"+"─".repeat(25)+"┼"+e+"┤")}}if(C!==H[H.length-1]){let N=K.map(()=>q.map(()=>"═".repeat(U)).join("═")).join("╪");console.log("╞"+"═".repeat(25)+"╪"+N+"╡")}}console.log("└"+"─".repeat(25)+"┴"+K.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┴")+"┘"),console.log(`
|
|
68
|
+
┌`+"─".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[C,y]of Object.entries(G))g+=`${y.icon}=${C} `;console.log(g.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FULL FUNCTIONALITY NAMES:"+" ".repeat(94)+"│");let f="│ ";for(let[C,y]of Object.entries(G))f+=`${y.icon}=${y.name} `;if(f.length>120)console.log(f.substring(0,121)+"│"),f="│ "+f.substring(121);console.log(f.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(`
|
|
69
|
+
`),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let x=[{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"}],D=14,T="".padEnd(30)+"│";for(let C of K)T+=C.label.padStart(D-1).padEnd(D);T+="│",console.log(`
|
|
70
|
+
┌`+"─".repeat(30)+"┬"+"─".repeat(K.length*D)+"┐"),console.log("│"+"RESOURCE TYPE".padEnd(30)+T.substring(31)),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(K.length*D)+"┤");let d=(C,y)=>{if(y==="img"||y==="css"){if(C.includes("external")||C.includes("remote")||C.includes("scripts")||C.includes("audio"))return"❌";if(C.includes("local")&&!C.includes("embedded"))return"⚠️"}if(y==="object"||y==="embed"){if(C.includes("remote")&&!C.includes("embedded"))return"⚠️"}if(C.includes("embedded")||C.includes("inline"))return"✅";if(C.includes("local"))return"⚠️";if(C.includes("remote")||C.includes("external"))return"⚠️";return"✅"};for(let C of x){let y=`│ ${C.icon} ${C.label}`.padEnd(31)+"│";for(let N of K){let e=d(C.id,N.id);y+=e.padStart(D-1).padEnd(D)}y+="│",console.log(y)}console.log("└"+"─".repeat(30)+"┴"+"─".repeat(K.length*D)+"┘"),console.log(`
|
|
71
|
+
`),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 C 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[N,e]of Object.entries(y))if(C.startsWith(N)||C===N.replace("_","")){if(!c[e])c[e]=[];c[e].push(C);break}}console.log(`
|
|
72
|
+
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let p={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[C,y]of Object.entries(c)){let N=p[C]||{},e=Object.entries(N).map(([r,s])=>`${r}: ${s}`).join("; ")||"No known issues";console.log(`│ ${C.toUpperCase().padEnd(18)} │ ${e.substring(0,97).padEnd(97)} │`)}return console.log("└"+"─".repeat(20)+"┴"+"─".repeat(99)+"┘"),console.log(`
|
|
73
73
|
`+"═".repeat(140)+`
|
|
74
|
-
`),$}function
|
|
75
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${
|
|
74
|
+
`),$}function Kz($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",Q=(e)=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),K=[{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"}],j=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],z=(e,r,s,q0)=>{let v=[],E=(t)=>v.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"),v;if(s==="nojs")E("No scripts"),E("No event handlers");if(r==="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"),r==="http")E("No cross-origin script access")}if(e==="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(e==="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 v},G=0;for(let e of q)for(let r of W)for(let s of j)for(let q0 of K){let v=z(e.id,r.id,s.id,q0.id).length;if(v>G)G=v}let F=130,_=80,U=90,Y=F+_+U,V=60,M=220,X=13,k=Math.max(80,(G+1)*X+25),L=K.length,R=q.length*W.length*j.length,B=Y+L*M,h=V+R*k+40,g=30,f=40+H.length*g,x=h+f+30,D=1020,T=B+50,d=55+x+D+50,c=`<?xml version="1.0" encoding="UTF-8"?>
|
|
75
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${T} ${d}" preserveAspectRatio="xMinYMin meet" height="${d}" width="100%">
|
|
76
76
|
<title>SVG Compatibility Matrix</title>
|
|
77
77
|
|
|
78
78
|
<defs>
|
|
@@ -93,36 +93,36 @@ ${H}
|
|
|
93
93
|
</style>
|
|
94
94
|
</defs>
|
|
95
95
|
|
|
96
|
-
<text x="${
|
|
97
|
-
<text x="${
|
|
96
|
+
<text x="${T/2}" y="24" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
|
|
97
|
+
<text x="${T/2}" y="42" text-anchor="middle" class="subtitle">What problems will your SVG have in each configuration?</text>
|
|
98
98
|
|
|
99
99
|
<g transform="translate(25, 55)">
|
|
100
|
-
`,
|
|
101
|
-
<text x="${
|
|
102
|
-
<text x="${
|
|
103
|
-
`,
|
|
104
|
-
<text x="${
|
|
105
|
-
`;for(let
|
|
106
|
-
<text x="${
|
|
107
|
-
<text x="${
|
|
108
|
-
`,
|
|
109
|
-
<text x="${F/2}" y="${y+
|
|
110
|
-
`;for(let
|
|
111
|
-
<text x="${F+_/2}" y="${y+q0/2+4}" text-anchor="middle" class="row-label">${
|
|
112
|
-
`;for(let
|
|
113
|
-
<text x="${F+_+U/2}" y="${y+k/2+4}" text-anchor="middle" class="row-label">${
|
|
114
|
-
`,
|
|
115
|
-
`,
|
|
116
|
-
<text x="${
|
|
117
|
-
`;else{let
|
|
118
|
-
`,
|
|
100
|
+
`,p=Y;c+=` <rect x="${p}" y="0" width="${M}" height="${V}" fill="${K[0].color}" stroke="#1565C0"/>
|
|
101
|
+
<text x="${p+M/2}" y="25" text-anchor="middle" class="col-header">${Q(K[0].name)}</text>
|
|
102
|
+
<text x="${p+M/2}" y="42" text-anchor="middle" class="col-desc">${Q(K[0].desc)}</text>
|
|
103
|
+
`,p+=M;let C=(K.length-1)*M;c+=` <rect x="${p}" y="0" width="${C}" height="25" fill="#0D47A1"/>
|
|
104
|
+
<text x="${p+C/2}" y="17" text-anchor="middle" class="col-header">In HTML Page</text>
|
|
105
|
+
`;for(let e=1;e<K.length;e++){let r=K[e];c+=` <rect x="${p}" y="25" width="${M}" height="${V-25}" fill="${r.color}" stroke="#1976D2"/>
|
|
106
|
+
<text x="${p+M/2}" y="42" text-anchor="middle" class="col-header">${Q(r.name)}</text>
|
|
107
|
+
<text x="${p+M/2}" y="55" text-anchor="middle" class="col-desc">${Q(r.desc)}</text>
|
|
108
|
+
`,p+=M}let y=V;for(let e of q){let r=W.length*j.length*k;c+=` <rect x="0" y="${y}" width="${F}" height="${r}" fill="${e.color}" stroke="#999"/>
|
|
109
|
+
<text x="${F/2}" y="${y+r/2+4}" text-anchor="middle" class="row-label-bold">${Q(e.name)}</text>
|
|
110
|
+
`;for(let s of W){let q0=j.length*k;c+=` <rect x="${F}" y="${y}" width="${_}" height="${q0}" fill="${s.color}" stroke="#CCC"/>
|
|
111
|
+
<text x="${F+_/2}" y="${y+q0/2+4}" text-anchor="middle" class="row-label">${Q(s.name)}</text>
|
|
112
|
+
`;for(let v of j){c+=` <rect x="${F+_}" y="${y}" width="${U}" height="${k}" fill="${v.color}" stroke="#DDD"/>
|
|
113
|
+
<text x="${F+_+U/2}" y="${y+k/2+4}" text-anchor="middle" class="row-label">${Q(v.name)}</text>
|
|
114
|
+
`,p=Y;for(let E of K){let t=z(e.id,s.id,v.id,E.id),$0="cell-ok";if(t.length>=4)$0="cell-bad";else if(t.length>0)$0="cell-warn";if(c+=` <rect x="${p}" y="${y}" width="${M}" height="${k}" class="${$0}" stroke="#DDD"/>
|
|
115
|
+
`,t.length===0)c+=` <text x="${p+M/2}" y="${y+k/2-5}" text-anchor="middle" class="ok-text">No issues</text>
|
|
116
|
+
<text x="${p+M/2}" y="${y+k/2+12}" text-anchor="middle" class="problem-text" style="fill:#388E3C">Everything works</text>
|
|
117
|
+
`;else{let K0=y+16;for(let V0 of t){let C0=`• ${V0.text||"Unknown issue"}`;c+=` <text x="${p+8}" y="${K0}" class="problem-text">${Q(C0)}</text>
|
|
118
|
+
`,K0+=X}}p+=M}y+=k}}c+=` <line x1="0" y1="${y}" x2="${B}" y2="${y}" stroke="#999" stroke-width="2"/>
|
|
119
119
|
`}c+=`
|
|
120
120
|
<text x="0" y="${h}" class="legend-title">SERVER-SIDE SVG RENDERERS (no HTML embedding)</text>
|
|
121
|
-
`;let
|
|
122
|
-
<text x="10" y="${
|
|
123
|
-
`;let
|
|
124
|
-
`,
|
|
125
|
-
<g transform="translate(0, ${
|
|
121
|
+
`;let N=h+20;for(let e of H){c+=` <rect x="0" y="${N}" width="150" height="${g-4}" fill="${e.color}" stroke="#999"/>
|
|
122
|
+
<text x="10" y="${N+18}" class="row-label-bold">${Q(e.name)}</text>
|
|
123
|
+
`;let r=e.issues.join(" • ");c+=` <text x="160" y="${N+18}" class="problem-text">${Q(r)}</text>
|
|
124
|
+
`,N+=g}return c+=`
|
|
125
|
+
<g transform="translate(0, ${x})">
|
|
126
126
|
<text x="0" y="0" class="legend-title">LEGEND</text>
|
|
127
127
|
|
|
128
128
|
<rect x="0" y="15" width="18" height="14" class="cell-ok" stroke="#4CAF50"/>
|
|
@@ -210,8 +210,8 @@ ${H}
|
|
|
210
210
|
<text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
|
|
211
211
|
</g>
|
|
212
212
|
</g>
|
|
213
|
-
</svg>`,c}function
|
|
214
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${
|
|
213
|
+
</svg>`,c}function MQ($){let{title:J="Data Table",subtitle:Z="",columns:Q=[],rowLevels:K=[],rowData:q=[],getCellContent:H=()=>({lines:[],status:"ok"}),legend:W=null,additionalSections:j=[],options:z={}}=$,G={fontFamily:z.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:z.minCellWidth||150,maxCellWidth:z.maxCellWidth||300,minCellHeight:z.minCellHeight||60,cellPaddingX:z.cellPaddingX||8,cellPaddingY:z.cellPaddingY||12,titleFontSize:z.titleFontSize||20,subtitleFontSize:z.subtitleFontSize||12,headerFontSize:z.headerFontSize||12,cellFontSize:z.cellFontSize||10,lineHeight:z.lineHeight||13,titleColor:z.titleColor||"#1a1a1a",subtitleColor:z.subtitleColor||"#666",borderColor:z.borderColor||"#DDD",okColor:z.okColor||"#C8E6C9",warnColor:z.warnColor||"#FFF9C4",badColor:z.badColor||"#FFCDD2",okTextColor:z.okTextColor||"#2E7D32",colHeaderHeight:z.colHeaderHeight||60,marginTop:z.marginTop||55,marginLeft:z.marginLeft||25,marginRight:z.marginRight||25,marginBottom:z.marginBottom||50,sectionSpacing:z.sectionSpacing||40,groupHeaderHeight:z.groupHeaderHeight||25,groupHeaderColor:z.groupHeaderColor||"#0D47A1"},F=(v)=>String(v).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),_=(v,E=0,t=[])=>{let $0=[];for(let K0 of v){let V0=[...t,{level:E,...K0}];if(K0.children&&K0.children.length>0&&E<K.length-1)$0.push(..._(K0.children,E+1,V0));else $0.push(V0)}return $0},U=_(q[0]||[]),Y=U.length,V=K.length,M=K.map((v,E)=>{if(v.width)return v.width;let t=v.name.length,$0=(K0,V0)=>{for(let C0 of K0){if(V0===E)t=Math.max(t,(C0.name||"").length);if(C0.children)$0(C0.children,V0+1)}};return $0(q[0]||[],0),Math.max(60,t*7+20)}),X=M.reduce((v,E)=>v+E,0),k=0,L=0;for(let v of U)for(let E of Q){let $0=H(v,E.id).lines||[];k=Math.max(k,$0.length);for(let K0 of $0)L=Math.max(L,K0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,L*6+G.cellPaddingX*2)),B=Math.max(G.minCellHeight,(k+1)*G.lineHeight+G.cellPaddingY*2),I=[],h=null;for(let v=0;v<Q.length;v++){let E=Q[v];if(E.group)if(!h||h.name!==E.group)h={name:E.group,startIndex:v,count:1,color:E.groupColor||G.groupHeaderColor},I.push(h);else h.count++;else h=null}let g=I.length>0,f=g?G.colHeaderHeight+G.groupHeaderHeight:G.colHeaderHeight,x=X+Q.length*R,D=f+Y*B,T=0;for(let v of j)T+=G.sectionSpacing+(v.height||100);let d=W?z.legendHeight||200:0,c=x+G.marginLeft+G.marginRight,p=G.marginTop+D+T+(W?G.sectionSpacing+d:0)+G.marginBottom,C=`<?xml version="1.0" encoding="UTF-8"?>
|
|
214
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${p}" preserveAspectRatio="xMinYMin meet" height="${p}" width="100%">
|
|
215
215
|
<title>${F(J)}</title>
|
|
216
216
|
|
|
217
217
|
<defs>
|
|
@@ -236,33 +236,33 @@ ${H}
|
|
|
236
236
|
${Z?`<text x="${c/2}" y="42" text-anchor="middle" class="subtitle">${F(Z)}</text>`:""}
|
|
237
237
|
|
|
238
238
|
<g transform="translate(${G.marginLeft}, ${G.marginTop})">
|
|
239
|
-
`,y=X;if(
|
|
240
|
-
<text x="${
|
|
241
|
-
`}}let
|
|
242
|
-
<text x="${
|
|
243
|
-
`,
|
|
244
|
-
`}let
|
|
245
|
-
<text x="${
|
|
246
|
-
`,
|
|
247
|
-
`,
|
|
248
|
-
`;else{let _0=
|
|
249
|
-
`,_0+=G.lineHeight}}if(
|
|
250
|
-
`}}let q0=
|
|
251
|
-
<text x="0" y="${q0}" class="section-title">${F(
|
|
252
|
-
`,q0+=20;if(
|
|
253
|
-
${
|
|
239
|
+
`,y=X;if(g){let v=0;for(let E=0;E<Q.length&&!Q[E].group;E++)v++;for(let E of I){let t=X+E.startIndex*R,$0=E.count*R;C+=` <rect x="${t}" y="0" width="${$0}" height="${G.groupHeaderHeight}" fill="${E.color}"/>
|
|
240
|
+
<text x="${t+$0/2}" y="${G.groupHeaderHeight-8}" text-anchor="middle" class="col-header">${F(E.name)}</text>
|
|
241
|
+
`}}let N=g?G.groupHeaderHeight:0,e=g?G.colHeaderHeight:f;for(let v=0;v<Q.length;v++){let E=Q[v],t=X+v*R,$0=E.group?N:0,K0=E.group?e:f;if(C+=` <rect x="${t}" y="${$0}" width="${R}" height="${K0}" fill="${E.color}" stroke="${G.borderColor}"/>
|
|
242
|
+
<text x="${t+R/2}" y="${$0+K0/2-5}" text-anchor="middle" class="col-header">${F(E.name)}</text>
|
|
243
|
+
`,E.desc)C+=` <text x="${t+R/2}" y="${$0+K0/2+10}" text-anchor="middle" class="col-desc">${F(E.desc)}</text>
|
|
244
|
+
`}let r=new Map,s=f;for(let v=0;v<U.length;v++){let E=U[v],t=0;for(let $0=0;$0<V;$0++){let K0=E.find((C0)=>C0.level===$0);if(!K0){t+=M[$0];continue}let V0=`${$0}-${K0.id}`;if(!r.has(V0)){let C0=1;for(let o=v+1;o<U.length;o++){let Z0=U[o].find((_0)=>_0.level===$0);if(Z0&&Z0.id===K0.id)C0++;else break}let y0=C0*B;C+=` <rect x="${t}" y="${s}" width="${M[$0]}" height="${y0}" fill="${K0.color||"#F5F5F5"}" stroke="${G.borderColor}"/>
|
|
245
|
+
<text x="${t+M[$0]/2}" y="${s+y0/2+4}" text-anchor="middle" class="${$0===0?"row-label-bold":"row-label"}">${F(K0.name)}</text>
|
|
246
|
+
`,r.set(V0,{y:s,height:y0})}t+=M[$0]}for(let $0=0;$0<Q.length;$0++){let K0=Q[$0],V0=X+$0*R,C0=H(E,K0.id),y0=C0.lines||[],o=C0.status||"ok";if(C+=` <rect x="${V0}" y="${s}" width="${R}" height="${B}" class="${o==="bad"?"cell-bad":o==="warn"?"cell-warn":"cell-ok"}" stroke="${G.borderColor}"/>
|
|
247
|
+
`,y0.length===0)C+=` <text x="${V0+R/2}" y="${s+B/2}" text-anchor="middle" class="ok-text">No issues</text>
|
|
248
|
+
`;else{let _0=s+G.cellPaddingY+G.lineHeight;for(let O0 of y0)C+=` <text x="${V0+G.cellPaddingX}" y="${_0}" class="cell-text">${F("• "+O0)}</text>
|
|
249
|
+
`,_0+=G.lineHeight}}if(s+=B,v<U.length-1){let $0=E[0]?.id,K0=U[v+1][0]?.id;if($0!==K0)C+=` <line x1="0" y1="${s}" x2="${x}" y2="${s}" stroke="#999" stroke-width="2"/>
|
|
250
|
+
`}}let q0=D+G.sectionSpacing;for(let v of j){if(v.title)C+=`
|
|
251
|
+
<text x="0" y="${q0}" class="section-title">${F(v.title)}</text>
|
|
252
|
+
`,q0+=20;if(v.content)C+=` <g transform="translate(0, ${q0})">
|
|
253
|
+
${v.content}
|
|
254
254
|
</g>
|
|
255
|
-
`;if(
|
|
256
|
-
`;if(
|
|
257
|
-
`}q0+=
|
|
255
|
+
`;if(v.items)for(let E of v.items){if(E.rect)C+=` <rect x="${E.rect.x}" y="${q0+E.rect.y}" width="${E.rect.width}" height="${E.rect.height}" fill="${E.rect.fill||"#EEE"}" stroke="${E.rect.stroke||"#999"}"/>
|
|
256
|
+
`;if(E.text)C+=` <text x="${E.text.x}" y="${q0+E.text.y}" class="${E.text.class||"legend-text"}">${F(E.text.content)}</text>
|
|
257
|
+
`}q0+=v.height||100}if(W)C+=`
|
|
258
258
|
<g transform="translate(0, ${q0})">
|
|
259
259
|
${W}
|
|
260
260
|
</g>
|
|
261
|
-
`;return
|
|
262
|
-
</svg>`,
|
|
263
|
-
<text x="10" y="${
|
|
264
|
-
<text x="160" y="${
|
|
265
|
-
`,
|
|
261
|
+
`;return C+=` </g>
|
|
262
|
+
</svg>`,C}function qz($={}){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"}],Q=[{id:"environment",name:"Environment",width:130},{id:"protocol",name:"Protocol",width:80},{id:"script",name:"JavaScript",width:90}],K=[[{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="",j=0;for(let G of H)W+=`<rect x="0" y="${j}" width="150" height="26" fill="${G.color}" stroke="#999"/>
|
|
263
|
+
<text x="10" y="${j+18}" class="row-label-bold">${G.name}</text>
|
|
264
|
+
<text x="160" y="${j+18}" class="cell-text">${G.issues.join(" • ")}</text>
|
|
265
|
+
`,j+=30;let z=`
|
|
266
266
|
<text x="0" y="0" class="section-title">LEGEND</text>
|
|
267
267
|
|
|
268
268
|
<rect x="0" y="15" width="18" height="14" class="cell-ok" stroke="#4CAF50"/>
|
|
@@ -348,12 +348,12 @@ ${H}
|
|
|
348
348
|
<text x="0" y="963" class="legend-text">2. Set ALL animations AND audio to begin="mySvg.click"</text>
|
|
349
349
|
<text x="0" y="979" class="legend-text">3. User clicks anywhere on SVG → user activation satisfied → audio plays → animations start</text>
|
|
350
350
|
<text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
|
|
351
|
-
`;return qK({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 HK=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"})},Y=(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=Y(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 w7=Y(E0);if(w7)return s=!0,`#${w7}`}}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=Y(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)},M=(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))M(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)},h=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,u=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(!u.has(C)&&C!=="style")continue;let n=S.getAttribute(C);if(!n)continue;if(h.test(n)){let p=n.replace(h," ");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)},g=(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))g(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)||VJ.has(n));else{let p=S$(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)||OJ.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=S$(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 w7=L0.getAttribute(E0),h$;p.lastIndex=0;while((h$=p.exec(w7))!==null){let g7=h$[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=w7.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)},M0=(S)=>{let C=S.tagName,n=C.toLowerCase();if(C.includes(":")||X$.has(C)||VJ.has(n)){for(let s of Array.from(S.children))if(a(s))M0(s);return}let p=S$(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))M0(G0)}else for(let s of Array.from(S.children))if(a(s))M0(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)||OJ.has(C.toLowerCase()))continue;let n=S$(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,w7=2;while(n.has(E0)||s.has(E0))E0=`${C0}_${w7++}`;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($),M($),w($),P($),b($),g($),M0($),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"]),JZ=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]===`
|
|
352
|
-
`)J.lines.push(X+1);let
|
|
353
|
-
`):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},Y=(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,(_7,$7,r0)=>{if(!r0.includes(">"))return`="${$7}<${r0}"`;return _7});if(x0!==T)T=x0,r.push("Escaped < in attribute values");return{fixed:T,appliedFixes:r}};try{F=await H6($,z)}catch(x){let T=x.message||String(x),r=U(T),D=Y(T),{fixed:Z0,appliedFixes:W0}=V(W);if(W0.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: ${W0.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 (${W0.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 M=[];if(_.length>0)M.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 W0=cW[x.type]||A0.WARNING,H0={...x,severity:W0,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 h=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],u=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);if(T==="g"){for(let D of h)if(x.hasAttribute(D))M.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))u(D)},b=()=>{let x=!1,T=null,r=null,D=(Z0)=>{for(let W0 of Z0.getAttributeNames())if(W0.startsWith("xlink:")){x=!0,T=Z0.tagName.toLowerCase(),r=W0;return}for(let W0 of Z0.children){if(a(W0))D(W0);if(x)return}};if(D(F),x&&!F.hasAttribute("xmlns:xlink")){let Z0=G.getAttributePosition(T,r,0);M.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:Z0.line,column:Z0.column})}},g=(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 W0=Z0.slice(1);if(W0&&!I.has(W0))M.push(R({type:"broken_reference",element:T,attr:D,referencedId:W0,reason:`Reference to non-existent ID '${W0}'`},T,D,r))}}for(let D of x.children)if(a(D))g(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 W0=Z0.trim();if(W0!==Z0)M.push(R({type:"invalid_timing",element:T,attr:D,value:Z0,reason:"Timing value has leading/trailing whitespace"},T,D,r));if(/[;,]/.test(W0)&&!/^[\d\w\s.;,+-]+$/.test(W0))M.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))M.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 W0=Z0.match(N);if(W0)for(let H0 of W0){let O0=H0.replace(/[\d.]+/,"");if(O0!==O0.toLowerCase())M.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))M.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 W0=Z0.trim();if(/^0\d/.test(W0.replace(/[a-z%]+$/i,"")))M.push(R({type:"invalid_number",element:T,attr:D,value:Z0,reason:"Number has unnecessary leading zeros"},T,D,r));if(/\.$/.test(W0.replace(/[a-z%]+$/i,"")))M.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),W0=r.includes(":"),H0=T||o5.has(D)||W0;if(!H0){if(!X$.has(r)&&!VJ.has(D)){if(!NW(D)){let O0=S$(r,X$);if(O0)M.push(R({type:"mistyped_element_detected",element:r,suggestion:O0,reason:`Unknown element <${r}> - did you mean <${O0}>?`},D,null,Z0));else M.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(":"),W0=T||o5.has(r)||Z0;if(!W0)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)&&!OJ.has(H0.toLowerCase())){let O0=S$(H0,k$);if(O0)M.push(R({type:"mistyped_attribute_detected",element:r,attr:H0,suggestion:O0,reason:`Unknown attribute '${H0}' - did you mean '${O0}'?`},r,H0,D));else M.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,W0)},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"))M.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))M.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 W0=Z0.tagName.toLowerCase();if(!W0.includes(":")&&!D.has(W0))M.push(R({type:"invalid_child_element",element:T,child:W0,reason:`<${W0}> 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 W0=x.getAttribute(D);if(W0&&!Z0.has(W0))M.push(R({type:"invalid_enum_value",element:T,attr:D,value:W0,validValues:[...Z0],reason:`Invalid value '${W0}' 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 W0=x.getAttribute(D);if(W0){let H0=parseFloat(W0);if(!isNaN(H0)){if(Z0.min!==void 0&&H0<Z0.min)M.push(R({type:"invalid_numeric_constraint",element:T,attr:D,value:W0,reason:`Value ${H0} is below minimum ${Z0.min}`},T,D,r));if(Z0.max!==void 0&&H0>Z0.max)M.push(R({type:"invalid_numeric_constraint",element:T,attr:D,value:W0,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 W0=Z0.tagName.toLowerCase(),H0=k(W0),O0=Z0.getAttribute("id");if(O0){if(!T.has(O0))T.set(O0,[]),r.set(O0,{tagName:W0,occIdx:H0});T.get(O0).push(W0)}for(let T0 of Z0.children)if(a(T0))D(T0)};D(x);for(let[Z0,W0]of T)if(W0.length>1){let H0=r.get(Z0);M.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))}},M0=/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 W0;M0.lastIndex=0;while((W0=M0.exec(Z0))!==null){let H0=W0[1];if(!I.has(H0))M.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))M.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))))M.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))))M.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 W0=x.getAttribute("transform");if(W0){let H0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,O0=W0.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){M.push(R({type:"malformed_transform",element:T,value:W0.length>50?W0.substring(0,50)+"...":W0,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))M.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)M.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 r0 of r){let cJ=D($7.getAttribute(r0));if(cJ&&Z0(cJ,O0))return!0}for(let r0 of $7.children)if(a(r0)&&x0(r0))return!0;return!1},_7=x0(T0);return O0.delete(H0),_7},W0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[H0,O0]of x){let T0=O0.tagName.toLowerCase();if(W0.includes(T0)){if(Z0(H0)){w();let x0=k(T0);M.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);M.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);M.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)},w7=(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 W0=Z0.getAttribute("offset")||"0",H0=parseFloat(W0);if(W0.includes("%"))H0=H0/100;if(!isNaN(H0)&&H0<D){let O0=k(T);M.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))w7(r)},h$=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>h$){let Z0=k(T);M.push(R({type:"path_complexity",element:T,attr:"d",value:`${D.length} coordinates`,reason:`Path has ${D.length} coordinates (>${h$}), 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 W0=x.getAttribute(Z0);if(W0&&(W0.startsWith("http://")||W0.startsWith("https://")||W0.startsWith("//")))M.push(R({type:"external_resource",element:T,attr:Z0,value:W0.length>60?W0.substring(0,60)+"...":W0,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)M.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)},mJ=(x)=>{let T=x.tagName.toLowerCase();if(T==="script"){let r=k(T);M.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))mJ(r)},dJ=(x)=>{let T=x.tagName.toLowerCase(),r=k(T);for(let D of x.getAttributeNames())if(nW.has(D.toLowerCase()))M.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))dJ(D)},AK=()=>{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 _7=x0.tagName.toLowerCase();if(_7==="title")x=!0;if(_7==="desc")T=!0;if(_7==="text"||_7==="tspan"||_7==="textpath")r=!0;Z0(x0)}};if(Z0(F),!x)M.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(a(x0))H0(x0)};if(H0(F),!T&&W0>10)M.push(R({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${W0} elements)`},"svg",null,0));if(r&&!D)M.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(),_7=k(x0);for(let $7 of T0.getAttributeNames()){if($7.startsWith("aria-")&&!lW.has($7.toLowerCase()))M.push(R({type:"invalid_aria",element:x0,attr:$7,reason:`Unknown ARIA attribute '${$7}'`},x0,$7,_7));if($7==="role"){let r0=T0.getAttribute("role");if(r0&&!JZ.has(r0.toLowerCase()))M.push(R({type:"invalid_aria",element:x0,attr:"role",value:r0,reason:`Invalid role value '${r0}' (valid: ${Array.from(JZ).slice(0,5).join(", ")}...)`},x0,"role",_7))}if($7==="aria-hidden"){let r0=T0.getAttribute("aria-hidden");if(r0&&r0!=="true"&&r0!=="false")M.push(R({type:"invalid_aria",element:x0,attr:"aria-hidden",value:r0,reason:`aria-hidden must be 'true' or 'false', got '${r0}'`},x0,"aria-hidden",_7))}}for(let $7 of T0.children)if(a($7))O0($7)};w(),O0(F)};w(),u(F),b(),w(),g(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(),w7(F),w(),g7(F),w(),L$(F),w(),mJ(F),w(),dJ(F),AK(),M.sort((x,T)=>{if(x.line!==T.line)return x.line-T.line;return x.column-T.column});let j6=M;if(Z)j6=M.filter((x)=>x.severity===A0.ERROR);let Q9=M.filter((x)=>x.severity===A0.ERROR).length,pJ=M.filter((x)=>x.severity===A0.WARNING).length,q9={};for(let x of j6)q9[x.type]=(q9[x.type]||0)+1;let z$={issues:j6,isValid:Q9===0,hasErrors:Q9>0,hasWarnings:pJ>0,errorCount:Q9,warningCount:pJ,issueCount:j6.length,summary:q9};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(`
|
|
354
|
-
`)}function
|
|
355
|
-
`)}function
|
|
356
|
-
`)}function
|
|
351
|
+
`;return MQ({title:"SVG Compatibility Matrix",subtitle:"What problems will your SVG have in each configuration?",columns:Z,rowLevels:Q,rowData:K,getCellContent:q,additionalSections:[{title:"SERVER-SIDE SVG RENDERERS (no HTML embedding)",content:W,height:H.length*30+20}],legend:z,options:{fontFamily:J,minCellWidth:220,legendHeight:1020,...$}})}var XQ=F0(($,J={})=>{let Z=J.fixInvalidGroupAttrs!==!1,Q=J.fixMissingNamespaces!==!1,K=J.fixBrokenRefs!==!1,q=J.fixAnimationTiming!==!1,H=J.verbose||!1,W=[],j=new Set,z=(S)=>{let P=S.getAttribute("id");if(P)j.add(P);for(let n of S.children)if(i(n))z(n)};z($);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 P=S.tagName.toLowerCase();if(P==="g"&&Z){for(let n of G)if(S.hasAttribute(n)){let m=S.getAttribute(n);S.removeAttribute(n),W.push({type:"invalid_attr_removed",element:P,attr:n,value:m,reason:`SVG 1.1: <g> elements do not support '${n}' attribute`})}}for(let n of S.children)if(i(n))_(n)},U=()=>{if(!Q)return;let S=!1,P=(n)=>{for(let m of n.getAttributeNames())if(m.startsWith("xlink:")){S=!0;return}for(let m of n.children){if(i(m))P(m);if(S)return}};if(P($),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"})},Y=(S)=>{let P=[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 l of P)if(j.has(l)&&l!==S)return l;let n=null,m=1/0;for(let l of j)if(l.toLowerCase().includes(S.toLowerCase())||S.toLowerCase().includes(l.toLowerCase())){let z0=Math.abs(l.length-S.length);if(z0<m&&z0<=2)m=z0,n=l}return n},V=(S)=>{if(!K)return;for(let P of["href","xlink:href"]){let n=S.getAttribute(P);if(n&&n.startsWith("#")){let m=n.substring(1);if(!j.has(m)){let l=Y(m);if(l)S.setAttribute(P,`#${l}`),W.push({type:"ref_fixed",element:S.tagName.toLowerCase(),attr:P,oldValue:n,newValue:`#${l}`,reason:`ID '${m}' not found, fixed to similar ID '${l}'`})}}}if(S.tagName.toLowerCase()==="animate"){let P=S.getAttribute("attributeName");if(P==="href"||P==="xlink:href"){let n=S.getAttribute("values");if(n){let m=n.split(";"),l=!1,z0=m.map((k0)=>{let E0=k0.trim();if(E0.startsWith("#")){let T0=E0.substring(1);if(!j.has(T0)){let w7=Y(T0);if(w7)return l=!0,`#${w7}`}}return E0});if(l){let k0=z0.join(";");S.setAttribute("values",k0),W.push({type:"animate_values_fixed",oldValue:n,newValue:k0,reason:"Fixed broken ID references in animate values"})}}}}for(let P of["fill","stroke","clip-path","mask","filter"]){let n=S.getAttribute(P);if(n&&n.startsWith("url(#")){let m=n.match(/url\(#([^)]+)\)/);if(m){let l=m[1];if(!j.has(l)){let z0=Y(l);if(z0)S.setAttribute(P,`url(#${z0})`),W.push({type:"url_ref_fixed",element:S.tagName.toLowerCase(),attr:P,oldValue:n,newValue:`url(#${z0})`,reason:`ID '${l}' not found, fixed to similar ID '${z0}'`})}}}}for(let P of S.children)if(i(P))V(P)},M=(S)=>{if(!q)return;let P=["animate","animateTransform","animateMotion","animateColor","set"],n=S.tagName.toLowerCase();if(P.includes(n)){let m=S.getAttribute("dur"),l=S.getAttribute("repeatCount");if(m==="0"||m==="0s"){if(!S.getAttribute("keyTimes"))W.push({type:"timing_warning",element:n,attr:"dur",value:m,reason:'dur="0" may cause animation to not play'})}let z0=S.getAttribute("begin");if(z0){let k0=z0;if(z0==="0")k0="0s",S.setAttribute("begin",k0),W.push({type:"timing_normalized",element:n,attr:"begin",oldValue:z0,newValue:k0,reason:"Normalized begin value to include time unit"})}}for(let m of S.children)if(i(m))M(m)},X=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),k=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),L=(S)=>{let P=S.tagName.toLowerCase();if(X.has(P)){let n=[];for(let m of Array.from(S.children))if(i(m)&&k.has(m.tagName.toLowerCase()))n.push(m);if(n.length>0){let m=S.getAttribute("id");if(!m)m=`_fix_${P}_${Math.random().toString(36).substring(2,8)}`,S.setAttribute("id",m),W.push({type:"id_generated",element:P,id:m,reason:"Generated ID for animation targeting after moving animate element"});for(let l of n){if(S.removeChild(l),!l.hasAttribute("href")&&!l.hasAttribute("xlink:href"))l.setAttribute("href",`#${m}`);let z0=S.parentNode;if(z0){let k0=S.nextSibling;if(k0)z0.insertBefore(l,k0);else z0.appendChild(l)}W.push({type:"animation_moved_from_empty_element",element:l.tagName.toLowerCase(),parentElement:P,targetId:m,reason:`SVG 1.1: <${P}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${m}".`})}}}for(let n of Array.from(S.children))if(i(n))L(n)},R=/^([+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?)(EM|EX|PX|IN|CM|MM|PT|PC|DEG|GRAD|RAD|S|MS|HZ|KHZ|%)$/i,B=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"]),I=(S)=>{for(let P of S.getAttributeNames()){if(!B.has(P)&&!P.includes("-"))continue;let n=S.getAttribute(P);if(!n)continue;let m=n.match(R);if(m){let[,l,z0]=m,k0=z0.toLowerCase();if(z0!==k0){let E0=l+k0;S.setAttribute(P,E0),W.push({type:"unit_normalized",element:S.tagName.toLowerCase(),attr:P,oldValue:n,newValue:E0,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let P of S.children)if(i(P))I(P)},h=/[\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"]),f=(S)=>{for(let P of S.getAttributeNames()){if(!g.has(P)&&P!=="style")continue;let n=S.getAttribute(P);if(!n)continue;if(h.test(n)){let m=n.replace(h," ");S.setAttribute(P,m),W.push({type:"whitespace_normalized",element:S.tagName.toLowerCase(),attr:P,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let P of S.children)if(i(P))f(P)},x=(S)=>{for(let P of S.getAttributeNames()){let n=S.getAttribute(P);if(!n)continue;let m=n,l=!1;if(/\d\.$/.test(m)||/\d\.(?=[,\s;)])/.test(m))m=m.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),l=!0;if(m=m.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),m=m.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),m!==n)l=!0;if(/\.\.+/.test(m))m=m.replace(/\.\.+/g,"."),l=!0;if(l)S.setAttribute(P,m),W.push({type:"number_format_fixed",element:S.tagName.toLowerCase(),attr:P,oldValue:n,newValue:m,reason:"SVG 1.1: Fixed invalid number format"})}for(let P of S.children)if(i(P))x(P)},D=340000000000000000000000000000000000000,T=-340000000000000000000000000000000000000,d=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,c=(S)=>{for(let P of S.getAttributeNames()){let n=S.getAttribute(P);if(!n)continue;if(P==="id"||P==="class"||P.startsWith("xmlns")||P==="href"||P==="xlink:href"||P==="style")continue;let m=n.match(d);if(!m)continue;for(let l of m){let z0=parseFloat(l);if(!isFinite(z0))W.push({type:"invalid_number_detected",element:S.tagName.toLowerCase(),attr:P,value:l,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(z0>D||z0<T)W.push({type:"out_of_range_detected",element:S.tagName.toLowerCase(),attr:P,value:l,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let P of S.children)if(i(P))c(P)},p=(S)=>{let P=S.tagName,n=P.toLowerCase();if(P.includes(":")||L$.has(P)||LJ.has(n));else{let m=D$(P,L$);if(m)W.push({type:"mistyped_element_detected",element:P,suggestion:m,reason:`Unknown element <${P}> - did you mean <${m}>?`});else W.push({type:"unknown_element_detected",element:P,reason:`Unknown element <${P}> - not in SVG 1.1 spec`})}for(let m of S.children)if(i(m))p(m)},C=(S)=>{for(let P of S.getAttributeNames()){if(P.startsWith("xmlns")||P.startsWith("data-"))continue;let n=P.toLowerCase();if(w$.has(P)||wJ.has(n))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 m=D$(P,w$);if(m)W.push({type:"mistyped_attribute_detected",element:S.tagName.toLowerCase(),attr:P,suggestion:m,reason:`Unknown attribute '${P}' on <${S.tagName.toLowerCase()}> - did you mean '${m}'?`})}for(let P of S.children)if(i(P))C(P)},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"]},N=["href","xlink:href"],e=(S)=>{let P=S.tagName.toLowerCase(),n=y[P];if(n){for(let m of n)if(m==="href"){if(!N.some((z0)=>S.hasAttribute(z0)))W.push({type:"missing_required_attribute",element:P,attr:m,reason:`Element <${P}> is missing required attribute '${m}' (or 'xlink:href')`})}else if(P==="stop"&&m==="offset"){let l=S.parentNode,z0=!1;while(l&&l.tagName){let k0=l.tagName.toLowerCase();if(k0==="meshpatch"||k0==="meshgradient"){z0=!0;break}l=l.parentNode}if(!z0&&!S.hasAttribute(m))W.push({type:"missing_required_attribute",element:P,attr:m,reason:`Element <${P}> is missing required attribute '${m}'`})}else if(!S.hasAttribute(m))W.push({type:"missing_required_attribute",element:P,attr:m,reason:`Element <${P}> is missing required attribute '${m}'`})}for(let m of S.children)if(i(m))e(m)},r={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=(S)=>{let P=S.tagName.toLowerCase(),n=r[P];if(n){for(let m of S.children)if(i(m)){let l=m.tagName.toLowerCase();if(!l.includes(":")&&!n.has(l))W.push({type:"invalid_child_element",parent:P,child:l,reason:`Element <${l}> is not a valid child of <${P}> per SVG 1.1 DTD`})}}for(let m of S.children)if(i(m))s(m)},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"],filterPrimitiveUnits:["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"]},v=new Set(["preserveAspectRatio"]),E=(S)=>{let P=S.tagName.toLowerCase();for(let n of S.getAttributeNames()){let m=q0[n];if(m){let l=S.getAttribute(n);if(v.has(n)&&l)l=l.split(/\s+/)[0];if(n==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(P))continue;if(!m.includes(l)&&l!=="inherit")W.push({type:"invalid_enum_value",element:P,attr:n,value:l,validValues:m.slice(0,5).join(", ")+(m.length>5?"...":""),reason:`Invalid value '${l}' for attribute '${n}' - must be one of: ${m.slice(0,5).join(", ")}${m.length>5?"...":""}`})}}for(let n of S.children)if(i(n))E(n)},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"}},$0=(S)=>{let P=S.tagName.toLowerCase();for(let n of S.getAttributeNames()){let m=t[n];if(m){let l=S.getAttribute(n);if(l==="inherit"||l==="none"||l==="indefinite"||l==="auto")continue;let z0=l.match(/^([+-]?\d*\.?\d+)/);if(z0){let k0=parseFloat(z0[1]);if(isNaN(k0))W.push({type:"invalid_numeric_value",element:P,attr:n,value:l,reason:`Invalid numeric value '${l}' for attribute '${n}'`});else{if(m.min!==void 0&&k0<m.min)W.push({type:"numeric_out_of_range",element:P,attr:n,value:l,constraint:`min: ${m.min}`,reason:`Value '${l}' for '${n}' is below minimum (${m.min})`});if(m.max!==void 0&&k0>m.max)W.push({type:"numeric_out_of_range",element:P,attr:n,value:l,constraint:`max: ${m.max}`,reason:`Value '${l}' for '${n}' exceeds maximum (${m.max})`});if(m.type==="integer"&&!Number.isInteger(k0))W.push({type:"invalid_numeric_value",element:P,attr:n,value:l,reason:`Attribute '${n}' requires an integer value, got '${l}'`})}}}}for(let n of S.children)if(i(n))$0(n)},K0=(S)=>{let P=new Map,n=(m)=>{let l=m.getAttribute("id");if(l){if(!P.has(l))P.set(l,[]);P.get(l).push(m.tagName.toLowerCase())}for(let z0 of m.children)if(i(z0))n(z0)};n(S);for(let[m,l]of P)if(l.length>1)W.push({type:"duplicate_id",id:m,count:l.length,elements:l.join(", "),reason:`Duplicate ID '${m}' found on ${l.length} elements: ${l.join(", ")}`})},V0=(S)=>{let P=new Set,n=(k0)=>{let E0=k0.getAttribute("id");if(E0)P.add(E0);for(let T0 of k0.children)if(i(T0))n(T0)};n(S);let m=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,l=/^#(.+)$/,z0=(k0)=>{let E0=k0.tagName.toLowerCase();for(let T0 of k0.getAttributeNames()){let w7=k0.getAttribute(T0),u$;m.lastIndex=0;while((u$=m.exec(w7))!==null){let m7=u$[1];if(!P.has(m7))W.push({type:"broken_reference",element:E0,attr:T0,refId:m7,reason:`Broken reference: url(#${m7}) points to non-existent ID`})}if(T0==="href"||T0==="xlink:href"){let m7=w7.match(l);if(m7){let B$=m7[1];if(!P.has(B$))W.push({type:"broken_reference",element:E0,attr:T0,refId:B$,reason:`Broken reference: ${T0}="#${B$}" points to non-existent ID`})}}}for(let T0 of k0.children)if(i(T0))z0(T0)};z0($)},C0=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"]),y0=new Set(["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"]),o=(S)=>{let P=S.toLowerCase().trim();if(P==="none"||P==="inherit"||P==="currentcolor")return!0;if(C0.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},Z0=(S)=>{let P=S.tagName.toLowerCase();for(let n of S.getAttributeNames())if(y0.has(n)){let m=S.getAttribute(n);if(!o(m))W.push({type:"invalid_color",element:P,attr:n,value:m,reason:`Invalid color value '${m}' for attribute '${n}'`})}for(let n of S.children)if(i(n))Z0(n)},_0=(S)=>{let P=S.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(P)){let l=S.getAttribute("viewBox");if(l){let z0=l.trim().split(/[\s,]+/);if(z0.length!==4)W.push({type:"malformed_viewbox",element:P,value:l,reason:`viewBox must have exactly 4 values (min-x, min-y, width, height), got ${z0.length}`});else{for(let T0=0;T0<z0.length;T0++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(z0[T0])){W.push({type:"malformed_viewbox",element:P,value:l,reason:`viewBox contains invalid number '${z0[T0]}' at position ${T0+1}`});break}let k0=parseFloat(z0[2]),E0=parseFloat(z0[3]);if(isNaN(k0)||isNaN(E0)||k0<0||E0<0)W.push({type:"invalid_viewbox_dimensions",element:P,value:l,reason:`viewBox width and height must be valid non-negative numbers, got ${k0}x${E0}`})}}}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:P,value:n,reason:`Invalid preserveAspectRatio format '${n}'`})}if(["polygon","polyline"].includes(P)){let l=S.getAttribute("points");if(l){let z0=l.trim().split(/[\s,]+/);if(z0.length>0&&z0.length%2!==0)W.push({type:"malformed_points",element:P,value:l.slice(0,50)+(l.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${z0.length}`})}}let m=S.getAttribute("transform");if(m){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(m.trim())){if(!/^[\s\w(),.\-+]+$/.test(m))W.push({type:"malformed_transform",element:P,value:m.slice(0,50)+(m.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let l of S.children)if(i(l))_0(l)},O0=(S)=>{let P=S.tagName,n=P.toLowerCase();if(P.includes(":")||L$.has(P)||LJ.has(n)){for(let l of Array.from(S.children))if(i(l))O0(l);return}let m=D$(P,L$);if(m){let l=S.ownerDocument.createElement(m);for(let z0 of S.getAttributeNames())l.setAttribute(z0,S.getAttribute(z0));while(S.firstChild)l.appendChild(S.firstChild);if(S.parentNode)S.parentNode.replaceChild(l,S);W.push({type:"element_typo_fixed",oldName:P,newName:m,reason:`Fixed element typo: <${P}> -> <${m}>`});for(let z0 of Array.from(l.children))if(i(z0))O0(z0)}else for(let l of Array.from(S.children))if(i(l))O0(l)},N0=(S)=>{for(let P of Array.from(S.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(w$.has(P)||wJ.has(P.toLowerCase()))continue;let n=D$(P,w$);if(n){let m=S.getAttribute(P);S.removeAttribute(P),S.setAttribute(n,m),W.push({type:"attr_typo_fixed",element:S.tagName.toLowerCase(),oldAttr:P,newAttr:n,reason:`Fixed attribute typo: '${P}' -> '${n}'`})}}for(let P of S.children)if(i(P))N0(P)},I0=(S)=>{let P=new Map,n=new Set,m=(k0)=>{let E0=k0.getAttribute("id");if(E0)P.set(E0,(P.get(E0)||0)+1),n.add(E0);for(let T0 of k0.children)if(i(T0))m(T0)};m(S);let l=new Set,z0=(k0)=>{let E0=k0.getAttribute("id");if(E0)if(l.has(E0)){let T0=E0,w7=2;while(n.has(T0)||l.has(T0))T0=`${E0}_${w7++}`;k0.setAttribute("id",T0),n.add(T0),l.add(T0),W.push({type:"duplicate_id_renamed",oldId:E0,newId:T0,element:k0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${E0}' -> '${T0}'`})}else l.add(E0);for(let T0 of k0.children)if(i(T0))z0(T0)};z0(S)};if(_($),U(),V($),M($),L($),I($),f($),x($),O0($),N0($),I0($),c($),e($),s($),E($),$0($),V0($),Z0($),_0($),$.setAttribute("data-fixes-applied",String(W.length)),H&&W.length>0)$.setAttribute("data-fix-report",JSON.stringify(W));return $}),B0={ERROR:"error",WARNING:"warning"},Hz={broken_reference:B0.ERROR,broken_url_reference:B0.ERROR,duplicate_id:B0.ERROR,missing_required_attribute:B0.ERROR,invalid_child_element:B0.ERROR,animation_in_empty_element:B0.ERROR,malformed_viewbox:B0.ERROR,malformed_points:B0.ERROR,malformed_transform:B0.ERROR,invalid_enum_value:B0.ERROR,invalid_numeric_constraint:B0.ERROR,invalid_attr_on_element:B0.WARNING,missing_namespace:B0.WARNING,invalid_timing:B0.WARNING,uppercase_unit:B0.WARNING,invalid_whitespace:B0.WARNING,invalid_number:B0.WARNING,mistyped_element_detected:B0.WARNING,unknown_element_detected:B0.WARNING,mistyped_attribute_detected:B0.WARNING,unknown_attribute_detected:B0.WARNING,invalid_color:B0.WARNING,circular_reference:B0.WARNING,deep_nesting:B0.WARNING,empty_defs:B0.WARNING,gradient_stop_order:B0.WARNING,path_complexity:B0.WARNING,external_resource:B0.WARNING,script_content:B0.WARNING,event_handler:B0.WARNING,missing_title:B0.WARNING,missing_desc:B0.WARNING,invalid_aria:B0.WARNING,missing_lang:B0.WARNING},Wz=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"]),zz=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 jz($){let J={elements:new Map,lines:[]},Z=0;J.lines.push(0);for(let X=0;X<$.length;X++)if($[X]===`
|
|
352
|
+
`)J.lines.push(X+1);let Q=[],K=/<!\[CDATA\[([\s\S]*?)\]\]>/g,q;while((q=K.exec($))!==null)Q.push({start:q.index,end:q.index+q[0].length});let H=/<!--[\s\S]*?-->/g,W;while((W=H.exec($))!==null)Q.push({start:W.index,end:W.index+W[0].length});let j=/<script[^>]*>([\s\S]*?)<\/script>/gi,z;while((z=j.exec($))!==null){let X=z.index+z[0].indexOf(">")+1,k=z.index+z[0].lastIndexOf("<");if(k>X)Q.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)Q.push({start:X,end:k})}Q.sort((X,k)=>X.start-k.start);let _=(X)=>{for(let k of Q){if(X>=k.start&&X<k.end)return!0;if(k.start>X)break}return!1},U=(X)=>{let k=1;for(let B=0;B<J.lines.length;B++){if(J.lines[B]>X){k=B;break}k=B+1}let L=J.lines[k-1]||0,R=X-L+1;return{line:k,column:R}},Y=/<([a-zA-Z][a-zA-Z0-9:_-]*)\s*([^>]*?)(\/?)\s*>/g,V=/([a-zA-Z][a-zA-Z0-9:_-]*)\s*=\s*["']([^"']*)["']/g,M;while((M=Y.exec($))!==null){if(_(M.index))continue;let X=M[1].toLowerCase(),k=M[2],L=M.index,R=M.index+M[0].length,{line:B,column:I}=U(L),h=k?M[0].indexOf(k):0,g=new Map;V.lastIndex=0;let f;while((f=V.exec(k))!==null){let x=f[1],D=f[2],T=L+h+f.index,d=U(T);g.set(x.toLowerCase(),{name:x,value:D,line:d.line,column:d.column})}if(!J.elements.has(X))J.elements.set(X,[]);J.elements.get(X).push({line:B,column:I,endColumn:I+M[0].length-1,attrs:g})}return J.getElementPosition=(X,k=0)=>{let L=J.elements.get(X.toLowerCase());if(L&&L[k]){let R=L[k];return{line:R.line,column:R.column}}return{line:1,column:1}},J.getAttributePosition=(X,k,L=0)=>{let R=J.elements.get(X.toLowerCase());if(R&&R[L]){let B=R[L],I=B.attrs.get(k.toLowerCase());if(I)return{line:I.line,column:I.column};return{line:B.line,column:B.column}}return{line:1,column:1}},J}async function Gz($,J={}){pW();let Z=J.errorsOnly===!0,Q=J.outputFile||null,K=(J.outputFormat||"json").toLowerCase(),q=J.includeSource===!0,H=J.validateInkscape===!0,W=J.inkscapeStrict===!0,j=["text","json","xml","yaml"];if(Q&&!j.includes(K))throw new Error(`Invalid outputFormat '${K}'. Must be one of: ${j.join(", ")}`);let z="",G;try{if(G=R$($),G===h0.SVG_STRING)z=$;else if(G===h0.FILE_PATH){let b=await import("node:fs/promises"),a=(await Promise.resolve().then(() => (M$(),Y$))).normalize($);try{z=await b.readFile(a,"utf8")}catch(u){throw new Error(`Failed to read file '${$}': ${u.message}`)}}else if(G===h0.URL)try{let b=await fetch($);if(!b.ok)throw new Error(`HTTP ${b.status}: ${b.statusText}`);z=await b.text()}catch(b){throw new Error(`Failed to fetch URL '${$}': ${b.message}`)}else if(G===h0.DOM_ELEMENT)if(typeof XMLSerializer!=="undefined")z=new XMLSerializer().serializeToString($);else if($.outerHTML)z=$.outerHTML;else throw new Error("Cannot serialize DOM element: XMLSerializer not available");else throw new Error(`Unknown input type: ${typeof $}`)}catch(b){return{issues:[{type:"input_error",severity:B0.ERROR,reason:b.message,line:0,column:0}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{input_error:1}}}let F=q?z.split(`
|
|
353
|
+
`):null,_=jz(z),U,Y=[],V=(b)=>{let A=b.match(/line\s*:?\s*(\d+)/i)||b.match(/:(\d+):/);return A?parseInt(A[1],10):1},M=(b)=>{let A=b.match(/column\s*:?\s*(\d+)/i)||b.match(/:\d+:(\d+)/);return A?parseInt(A[1],10):1},X=(b)=>{let A=b,a=[],u="_VALID_ENTITY_",J0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,Y0=A.replace(J0,u+"$1;").replace(/&/g,"&").replace(new RegExp(u,"g"),"&");if(Y0!==A)A=Y0,a.push("Escaped unencoded ampersands");let b0=A.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(b0!==A)A=b0,a.push("Removed invalid control characters");if(A.charCodeAt(0)===65279)A=A.slice(1),a.push("Removed UTF-8 BOM");let P0=A.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(u0,J7,a0)=>{if(!a0.includes(">"))return`="${J7}<${a0}"`;return u0});if(P0!==A)A=P0,a.push("Escaped < in attribute values");return{fixed:A,appliedFixes:a}};try{U=await z6($,G)}catch(b){let A=b.message||String(b),a=V(A),u=M(A),{fixed:J0,appliedFixes:H0}=X(z);if(H0.length>0&&J0!==z)try{let{JSDOM:j0}=await import("jsdom");U=new j0(J0,{contentType:"image/svg+xml"}).window.document.documentElement,Y.push({type:"parse_recovery",severity:B0.WARNING,reason:`Recovered from parse error. Applied fixes: ${H0.join("; ")}`,line:a,column:u}),Y.push({type:"original_parse_error",severity:B0.ERROR,reason:`Original parse error: ${A}`,line:a,column:u})}catch(j0){return{issues:[{type:"parse_error",severity:B0.ERROR,reason:`Failed to parse SVG: ${A}`,line:a,column:u},{type:"recovery_failed",severity:B0.WARNING,reason:`Recovery attempted (${H0.join("; ")}) but still failed: ${j0.message}`,line:a,column:u}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:B0.ERROR,reason:`Failed to parse SVG: ${A}`,line:a,column:u}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let k=[];if(Y.length>0)k.push(...Y);let L=new Map,R=(b)=>{let A=b.toLowerCase(),a=L.get(A)||0;return L.set(A,a+1),a},B=()=>{L.clear()},I=(b,A,a=null,u=null)=>{let J0;if(a)J0=_.getAttributePosition(A,a,u||0);else J0=_.getElementPosition(A,u||0);let H0=Hz[b.type]||B0.WARNING,j0={...b,severity:H0,line:J0.line,column:J0.column};if(q&&F&&J0.line>0&&J0.line<=F.length)j0.sourceLine=F[J0.line-1];return j0},h=new Set,g=(b)=>{if(!b)return;let A=b.getAttribute("id");if(A)h.add(A);for(let a of b.children)if(i(a))g(a)};g(U);let f=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],x=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);if(A==="g"){for(let u of f)if(b.hasAttribute(u))k.push(I({type:"invalid_attr_on_element",element:A,attr:u,value:b.getAttribute(u),reason:`SVG 1.1: <g> elements do not support '${u}' attribute`},A,u,a))}for(let u of b.children)if(i(u))x(u)},D=()=>{let b=!1,A=null,a=null,u=(J0)=>{for(let H0 of J0.getAttributeNames())if(H0.startsWith("xlink:")){b=!0,A=J0.tagName.toLowerCase(),a=H0;return}for(let H0 of J0.children){if(i(H0))u(H0);if(b)return}};if(u(U),b&&!U.hasAttribute("xmlns:xlink")){let J0=_.getAttributePosition(A,a,0);k.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:J0.line,column:J0.column})}},T=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of["xlink:href","href"]){let J0=b.getAttribute(u);if(J0&&J0.startsWith("#")){let H0=J0.slice(1);if(H0&&!h.has(H0))k.push(I({type:"broken_reference",element:A,attr:u,referencedId:H0,reason:`Reference to non-existent ID '${H0}'`},A,u,a))}}for(let u of b.children)if(i(u))T(u)},d=["begin","end","dur","repeatDur","min","max"],c=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),p=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);if(c.has(A))for(let u of d){let J0=b.getAttribute(u);if(J0){let H0=J0.trim();if(H0!==J0)k.push(I({type:"invalid_timing",element:A,attr:u,value:J0,reason:"Timing value has leading/trailing whitespace"},A,u,a));if(/[;,]/.test(H0)&&!/^[\d\w\s.;,+-]+$/.test(H0))k.push(I({type:"invalid_timing",element:A,attr:u,value:J0,reason:"Timing value may contain invalid characters"},A,u,a))}}for(let u of b.children)if(i(u))p(u)},C=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),y=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);if(C.has(A)){for(let u of b.children)if(i(u)){let J0=u.tagName.toLowerCase();if(c.has(J0))k.push(I({type:"animation_in_empty_element",element:A,child:J0,reason:`Animation element <${J0}> inside <${A}> which has EMPTY content model per SVG 1.1 DTD`},A,null,a))}}for(let u of b.children)if(i(u))y(u)},N=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,e=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],r=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of e){let J0=b.getAttribute(u);if(J0){let H0=J0.match(N);if(H0)for(let j0 of H0){let Y0=j0.replace(/[\d.]+/,"");if(Y0!==Y0.toLowerCase())k.push(I({type:"uppercase_unit",element:A,attr:u,value:J0,reason:`Unit '${Y0}' should be lowercase '${Y0.toLowerCase()}'`},A,u,a))}}}for(let u of b.children)if(i(u))r(u)},s=["points","viewBox","d","values","keyTimes","keySplines","rotate"],q0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of s){let J0=b.getAttribute(u);if(J0){if(/[\t\n\r]/.test(J0)||/ +/.test(J0))k.push(I({type:"invalid_whitespace",element:A,attr:u,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},A,u,a))}}for(let u of b.children)if(i(u))q0(u)},v=["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"],E=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of v){let J0=b.getAttribute(u);if(J0){let H0=J0.trim();if(/^0\d/.test(H0.replace(/[a-z%]+$/i,"")))k.push(I({type:"invalid_number",element:A,attr:u,value:J0,reason:"Number has unnecessary leading zeros"},A,u,a));if(/\.$/.test(H0.replace(/[a-z%]+$/i,"")))k.push(I({type:"invalid_number",element:A,attr:u,value:J0,reason:"Number has trailing decimal point"},A,u,a))}}for(let u of b.children)if(i(u))E(u)},t=(b,A=!1)=>{let a=b.tagName,u=a.toLowerCase(),J0=R(u),H0=a.includes(":"),j0=b.namespaceURI&&b.namespaceURI!=="http://www.w3.org/2000/svg",Y0=b.getAttribute?b.getAttribute("xmlns"):null,b0=Y0&&Y0!=="http://www.w3.org/2000/svg",P0=A||qZ.has(u)||H0||j0||b0;if(!P0){if(!L$.has(a)&&!LJ.has(u)){if(!xW(u)){let u0=D$(a,L$);if(u0)k.push(I({type:"mistyped_element_detected",element:a,suggestion:u0,reason:`Unknown element <${a}> - did you mean <${u0}>?`},u,null,J0));else k.push(I({type:"unknown_element_detected",element:a,reason:`Unknown element <${a}> - not in SVG 1.1 spec`},u,null,J0))}}}for(let u0 of b.children)if(i(u0))t(u0,P0)},$0=(b,A=!1)=>{let a=b.tagName.toLowerCase(),u=R(a),J0=b.tagName.includes(":"),H0=b.namespaceURI&&b.namespaceURI!=="http://www.w3.org/2000/svg",j0=b.getAttribute?b.getAttribute("xmlns"):null,Y0=j0&&j0!=="http://www.w3.org/2000/svg",b0=A||qZ.has(a)||J0||H0||Y0;if(!b0)for(let P0 of b.getAttributeNames()){if(P0.startsWith("data-")||P0.startsWith("aria-"))continue;if(P0==="xmlns"||P0.startsWith("xmlns:"))continue;if(P0.includes(":")&&!P0.startsWith("xlink:")&&!P0.startsWith("xml:"))continue;if(mW(P0))continue;if(!w$.has(P0)&&!wJ.has(P0.toLowerCase())){let u0=D$(P0,w$);if(u0)k.push(I({type:"mistyped_attribute_detected",element:a,attr:P0,suggestion:u0,reason:`Unknown attribute '${P0}' - did you mean '${u0}'?`},a,P0,u));else k.push(I({type:"unknown_attribute_detected",element:a,attr:P0,reason:`Unknown attribute '${P0}' on <${a}> - not in SVG 1.1 spec`},a,P0,u))}}for(let P0 of b.children)if(i(P0))$0(P0,b0)},K0={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"]},V0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A),u=K0[A];if(u&&u.length>0)if(u.includes("xlink:href")&&u.includes("href")){if(!b.hasAttribute("xlink:href")&&!b.hasAttribute("href"))k.push(I({type:"missing_required_attribute",element:A,attrs:["href","xlink:href"],reason:`<${A}> requires 'href' or 'xlink:href' attribute`},A,null,a))}else for(let J0 of u){if(A==="stop"&&J0==="offset"){let H0=b.parentNode,j0=!1;while(H0&&H0.tagName){let Y0=H0.tagName.toLowerCase();if(Y0==="meshpatch"||Y0==="meshgradient"){j0=!0;break}H0=H0.parentNode}if(j0)continue}if(!b.hasAttribute(J0))k.push(I({type:"missing_required_attribute",element:A,attr:J0,reason:`<${A}> requires '${J0}' attribute per SVG 1.1 DTD`},A,J0,a))}for(let J0 of b.children)if(i(J0))V0(J0)},C0={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"])},y0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A),u=C0[A];if(u){for(let J0 of b.children)if(i(J0)){let H0=J0.tagName.toLowerCase();if(!H0.includes(":")&&!u.has(H0))k.push(I({type:"invalid_child_element",element:A,child:H0,reason:`<${H0}> is not a valid child of <${A}> per SVG 1.1 DTD`},A,null,a))}}for(let J0 of b.children)if(i(J0))y0(J0)},o={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"]),filterPrimitiveUnits: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"])},Z0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let[u,J0]of Object.entries(o)){let H0=b.getAttribute(u);if(H0&&!J0.has(H0))k.push(I({type:"invalid_enum_value",element:A,attr:u,value:H0,validValues:[...J0],reason:`Invalid value '${H0}' for '${u}'. Valid values: ${[...J0].join(", ")}`},A,u,a))}for(let u of b.children)if(i(u))Z0(u)},_0={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"}},O0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let[u,J0]of Object.entries(_0)){let H0=b.getAttribute(u);if(H0){let j0=parseFloat(H0);if(!isNaN(j0)){if(J0.min!==void 0&&j0<J0.min)k.push(I({type:"invalid_numeric_constraint",element:A,attr:u,value:H0,reason:`Value ${j0} is below minimum ${J0.min}`},A,u,a));if(J0.max!==void 0&&j0>J0.max)k.push(I({type:"invalid_numeric_constraint",element:A,attr:u,value:H0,reason:`Value ${j0} is above maximum ${J0.max}`},A,u,a))}}}for(let u of b.children)if(i(u))O0(u)},N0=(b)=>{let A=new Map,a=new Map,u=(J0)=>{let H0=J0.tagName.toLowerCase(),j0=R(H0),Y0=J0.getAttribute("id");if(Y0){if(!A.has(Y0))A.set(Y0,[]),a.set(Y0,{tagName:H0,occIdx:j0});A.get(Y0).push(H0)}for(let b0 of J0.children)if(i(b0))u(b0)};u(b);for(let[J0,H0]of A)if(H0.length>1){let j0=a.get(J0);k.push(I({type:"duplicate_id",id:J0,elements:H0,count:H0.length,reason:`ID '${J0}' is used ${H0.length} times (on ${H0.join(", ")})`},j0.tagName,"id",j0.occIdx))}},I0=/url\(#([^)]+)\)/g,S=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],P=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of S){let J0=b.getAttribute(u);if(J0){let H0;I0.lastIndex=0;while((H0=I0.exec(J0))!==null){let j0=H0[1];if(!h.has(j0))k.push(I({type:"broken_url_reference",element:A,attr:u,referencedId:j0,reason:`url(#${j0}) references non-existent ID`},A,u,a))}}}for(let u of b.children)if(i(u))P(u)},n=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"]),m=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],l=(b)=>{let A=b.toLowerCase().trim();if(n.has(A))return!0;if(/^#[0-9a-f]{3}$/i.test(A))return!0;if(/^#[0-9a-f]{4}$/i.test(A))return!0;if(/^#[0-9a-f]{6}$/i.test(A))return!0;if(/^#[0-9a-f]{8}$/i.test(A))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(A))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^url\(#[^)]+\)$/i.test(A))return!0;return!1},z0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of m){let J0=b.getAttribute(u);if(J0&&!l(J0))k.push(I({type:"invalid_color",element:A,attr:u,value:J0,reason:`Invalid color value '${J0}'`},A,u,a))}for(let u of b.children)if(i(u))z0(u)},k0=(b)=>{let A=b.tagName.toLowerCase(),a=R(A),u=b.getAttribute("viewBox");if(u){let j0=u.trim().split(/[\s,]+/);if(j0.length!==4||!j0.every((Y0)=>!isNaN(parseFloat(Y0))))k.push(I({type:"malformed_viewbox",element:A,value:u,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},A,"viewBox",a))}let J0=b.getAttribute("points");if(J0){let j0=J0.trim().split(/[\s,]+/).filter((Y0)=>Y0);if(j0.length%2!==0||!j0.every((Y0)=>!isNaN(parseFloat(Y0))))k.push(I({type:"malformed_points",element:A,value:J0.length>50?J0.substring(0,50)+"...":J0,reason:"points must be pairs of numbers"},A,"points",a))}let H0=b.getAttribute("transform");if(H0){let j0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,Y0=H0.trim();while(Y0.length>0){let b0=Y0.match(j0);if(b0&&b0[0].length>0)Y0=Y0.substring(b0[0].length);else if(!b0){k.push(I({type:"malformed_transform",element:A,value:H0.length>50?H0.substring(0,50)+"...":H0,reason:`Invalid transform syntax near '${Y0.substring(0,20)}'`},A,"transform",a));break}else Y0=Y0.substring(1)}}if(A==="path"){let j0=b.getAttribute("d");if(j0){let Y0=j0.trim();if(Y0.length>0){if(!/^[Mm]/.test(Y0))k.push(I({type:"malformed_path_data",element:"path",value:j0.length>50?j0.substring(0,50)+"...":j0,reason:"Path data must start with M or m command"},"path","d",a));let b0=Y0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(b0.length>0)k.push(I({type:"malformed_path_data",element:"path",value:j0.length>50?j0.substring(0,50)+"...":j0,reason:`Path data contains invalid characters: '${b0.substring(0,10)}'`},"path","d",a))}}}for(let j0 of b.children)if(i(j0))k0(j0)},E0=()=>{let b=new Map,A=(j0)=>{let Y0=j0.getAttribute("id");if(Y0)b.set(Y0,j0);for(let b0 of j0.children)if(i(b0))A(b0)};A(U);let a=["href","xlink:href","mask","clip-path","filter","fill","stroke"],u=(j0)=>{if(!j0)return null;let Y0=j0.match(/url\(#([^)]+)\)/);if(Y0)return Y0[1];let b0=j0.match(/^#(.+)$/);if(b0)return b0[1];return null},J0=(j0,Y0=new Set)=>{if(Y0.has(j0))return!0;let b0=b.get(j0);if(!b0)return!1;Y0.add(j0);let P0=(J7)=>{for(let a0 of a){let tJ=u(J7.getAttribute(a0));if(tJ&&J0(tJ,Y0))return!0}for(let a0 of J7.children)if(i(a0)&&P0(a0))return!0;return!1},u0=P0(b0);return Y0.delete(j0),u0},H0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[j0,Y0]of b){let b0=Y0.tagName.toLowerCase();if(H0.includes(b0)){if(J0(j0)){B();let P0=R(b0);k.push(I({type:"circular_reference",element:b0,attr:"id",value:j0,reason:`Circular reference detected: '${j0}' directly or indirectly references itself`},b0,"id",P0))}}}},T0=50,w7=(b,A=0)=>{if(A>T0){let a=b.tagName.toLowerCase(),u=R(a);k.push(I({type:"deep_nesting",element:a,value:String(A),reason:`Element nesting depth (${A}) exceeds ${T0} levels`},a,null,u));return}for(let a of b.children)if(i(a))w7(a,A+1)},u$=(b)=>{let A=b.tagName.toLowerCase();if(A==="defs"){let a=!1;for(let u of b.childNodes)if(i(u)){a=!0;break}if(!a){let u=R(A);k.push(I({type:"empty_defs",element:A,reason:"Empty <defs> element (can be removed)"},A,null,u))}}for(let a of b.children)if(i(a))u$(a)},m7=(b)=>{let A=b.tagName.toLowerCase();if(A==="lineargradient"||A==="radialgradient"){let a=Array.from(b.children).filter((u)=>i(u)&&u.tagName.toLowerCase()==="stop");if(a.length>=2){let u=-1;for(let J0 of a){let H0=J0.getAttribute("offset")||"0",j0=parseFloat(H0);if(H0.includes("%"))j0=j0/100;if(!isNaN(j0)&&j0<u){let Y0=R(A);k.push(I({type:"gradient_stop_order",element:A,reason:`Gradient stops not in ascending offset order (${u} followed by ${j0})`},A,null,Y0));break}if(!isNaN(j0))u=j0}}}for(let a of b.children)if(i(a))m7(a)},B$=1e4,sJ=(b)=>{let A=b.tagName.toLowerCase();if(A==="path"){let a=b.getAttribute("d");if(a){let u=a.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(u&&u.length>B$){let J0=R(A);k.push(I({type:"path_complexity",element:A,attr:"d",value:`${u.length} coordinates`,reason:`Path has ${u.length} coordinates (>${B$}), may cause slow rendering`},A,"d",J0))}}}for(let a of b.children)if(i(a))sJ(a)},oJ=(b)=>{let A=b.tagName.toLowerCase(),a=R(A),u=["href","xlink:href"];for(let J0 of u){let H0=b.getAttribute(J0);if(H0&&(H0.startsWith("http://")||H0.startsWith("https://")||H0.startsWith("//")))k.push(I({type:"external_resource",element:A,attr:J0,value:H0.length>60?H0.substring(0,60)+"...":H0,reason:"External resource reference detected (potential security/CORS issue)"},A,J0,a))}if(A==="style"&&b.textContent){let J0=b.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(J0)k.push(I({type:"external_resource",element:A,value:J0[1],reason:"External CSS import detected in style element"},A,null,a))}for(let J0 of b.children)if(i(J0))oJ(J0)},iJ=(b)=>{let A=b.tagName.toLowerCase();if(A==="script"){let a=R(A);k.push(I({type:"script_content",element:A,reason:"Script element detected (potential security issue in untrusted SVGs)"},A,null,a))}for(let a of b.children)if(i(a))iJ(a)},rJ=(b)=>{let A=b.tagName.toLowerCase(),a=R(A);for(let u of b.getAttributeNames())if(Wz.has(u.toLowerCase()))k.push(I({type:"event_handler",element:A,attr:u,reason:`Event handler attribute '${u}' detected (potential XSS vector)`},A,u,a));for(let u of b.children)if(i(u))rJ(u)},xQ=()=>{let b=!1,A=!1,a=!1,u=U.hasAttribute("lang")||U.hasAttribute("xml:lang"),J0=(b0)=>{for(let P0 of b0.children){if(!i(P0))continue;let u0=P0.tagName.toLowerCase();if(u0==="title")b=!0;if(u0==="desc")A=!0;if(u0==="text"||u0==="tspan"||u0==="textpath")a=!0;J0(P0)}};if(J0(U),!b)k.push(I({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let H0=0,j0=(b0)=>{H0++;for(let P0 of b0.children)if(i(P0))j0(P0)};if(j0(U),!A&&H0>10)k.push(I({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${H0} elements)`},"svg",null,0));if(a&&!u)k.push(I({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let Y0=(b0)=>{let P0=b0.tagName.toLowerCase(),u0=R(P0);for(let J7 of b0.getAttributeNames()){if(J7.startsWith("aria-")&&!zz.has(J7.toLowerCase()))k.push(I({type:"invalid_aria",element:P0,attr:J7,reason:`Unknown ARIA attribute '${J7}'`},P0,J7,u0));if(J7==="role"){let a0=b0.getAttribute("role");if(a0&&!_Z.has(a0.toLowerCase()))k.push(I({type:"invalid_aria",element:P0,attr:"role",value:a0,reason:`Invalid role value '${a0}' (valid: ${Array.from(_Z).slice(0,5).join(", ")}...)`},P0,"role",u0))}if(J7==="aria-hidden"){let a0=b0.getAttribute("aria-hidden");if(a0&&a0!=="true"&&a0!=="false")k.push(I({type:"invalid_aria",element:P0,attr:"aria-hidden",value:a0,reason:`aria-hidden must be 'true' or 'false', got '${a0}'`},P0,"aria-hidden",u0))}}for(let J7 of b0.children)if(i(J7))Y0(J7)};B(),Y0(U)};B(),x(U),D(),B(),T(U),B(),p(U),B(),y(U),B(),r(U),B(),q0(U),B(),E(U),B(),t(U),B(),$0(U),B(),V0(U),B(),y0(U),B(),Z0(U),B(),O0(U),B(),N0(U),B(),P(U),B(),z0(U),B(),k0(U),B(),E0(),B(),w7(U),B(),u$(U),B(),m7(U),B(),sJ(U),B(),oJ(U),B(),iJ(U),B(),rJ(U),xQ();let E7=null;if(H&&U){E7=o5(U,{strict:!0,warnFlowText:!0,checkPolyfillNeeds:!0});for(let b of E7.issues){let A=B0.INFO;if(b.severity===H7.ERROR)A=B0.ERROR;else if(b.severity===H7.WARNING)A=B0.WARNING;k.push({type:`inkscape-${b.type}`,reason:b.message,severity:A,line:b.line||1,column:b.column||1,element:b.element||null,attribute:b.attribute||null,context:b.context||null})}}k.sort((b,A)=>{if(b.line!==A.line)return b.line-A.line;return b.column-A.column});let F6=k;if(Z)F6=k.filter((b)=>b.severity===B0.ERROR);let H9=k.filter((b)=>b.severity===B0.ERROR).length,aJ=k.filter((b)=>b.severity===B0.WARNING).length,W9={};for(let b of F6)W9[b.type]=(W9[b.type]||0)+1;let a7={issues:F6,isValid:H9===0,hasErrors:H9>0,hasWarnings:aJ>0,errorCount:H9,warningCount:aJ,issueCount:F6.length,summary:W9};if(E7)a7.inkscape={isInkscapeDocument:E7.isInkscape,inkscapeVersion:E7.version||null,polyfillsNeeded:E7.polyfillsNeeded||[],hasFlowText:E7.hasFlowText||!1,inkscapeIssueCount:E7.issues.length,inkscapeErrorCount:E7.summary.errors,inkscapeWarningCount:E7.summary.warnings};if(Q)try{let b=await import("node:fs/promises"),A=await Promise.resolve().then(() => (M$(),Y$)),a;switch(K){case"json":a=JSON.stringify(a7,null,2);break;case"yaml":a=_z(a7);break;case"xml":a=Uz(a7);break;case"text":default:a=Fz(a7);break}let u=A.normalize(Q);await b.writeFile(u,a,"utf8"),a7.outputFile=u}catch(b){a7.exportError=`Failed to write report to '${Q}': ${b.message}`}return a7}function Fz($){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 Q=Z.severity.toUpperCase(),K=`${Z.line}:${Z.column}`;if(J.push(`[${Q}] Line ${K}: ${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,Q]of Object.entries($.summary))J.push(` ${Z}: ${Q}`);return J.push("=".repeat(60)),J.join(`
|
|
354
|
+
`)}function _z($){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[Q,K]of Object.entries($.summary))J.push(` ${Q}: ${K}`);J.push(""),J.push(" issues:");let Z=(Q)=>String(Q).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");for(let Q of $.issues){if(J.push(` - type: ${Q.type}`),J.push(` severity: ${Q.severity}`),J.push(` line: ${Q.line}`),J.push(` column: ${Q.column}`),Q.element)J.push(` element: "${Z(Q.element)}"`);if(Q.attr)J.push(` attr: "${Z(Q.attr)}"`);if(Q.value)J.push(` value: "${Z(Q.value)}"`);if(J.push(` reason: "${Z(Q.reason)}"`),Q.sourceLine)J.push(` source_line: "${Z(Q.sourceLine)}"`)}return J.join(`
|
|
355
|
+
`)}function Uz($){let J=(Q)=>String(Q).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[Q,K]of Object.entries($.summary))Z.push(` <${Q}>${K}</${Q}>`);Z.push(" </summary>"),Z.push(" <issues>");for(let Q of $.issues){if(Z.push(" <issue>"),Z.push(` <type>${J(Q.type)}</type>`),Z.push(` <severity>${J(Q.severity)}</severity>`),Z.push(` <line>${Q.line}</line>`),Z.push(` <column>${Q.column}</column>`),Q.element)Z.push(` <element>${J(Q.element)}</element>`);if(Q.attr)Z.push(` <attr>${J(Q.attr)}</attr>`);if(Q.value)Z.push(` <value>${J(Q.value)}</value>`);if(Z.push(` <reason>${J(Q.reason)}</reason>`),Q.sourceLine)Z.push(` <source_line>${J(Q.sourceLine)}</source_line>`);Z.push(" </issue>")}return Z.push(" </issues>"),Z.push("</validation_result>"),Z.join(`
|
|
356
|
+
`)}function kQ($){let J=1;for(let Z of $.children)if(i(Z))J+=kQ(Z);return J}var LQ=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),Q=await S$(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 x0(Q.svg)}),wQ=F0(($,J={})=>{let Z=$.getElementsByTagName("path");for(let Q of Z){let K=Q.getAttribute("d");if(!K)continue;try{let q=K$(K),H=P$(q,J.precision||6);Q.setAttribute("d",H)}catch(q){console.warn(`Failed to simplify path: ${q.message}`,{pathData:K.substring(0,100)})}}return $}),RQ=F0(($,J={})=>{return a5($,{precision:J.precision??3,removeLinearSplines:J.removeLinearSplines!==!1,optimizeValues:J.optimizeValues!==!1}),$}),BQ=F0(($,J={})=>{return t5($,{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}),$}),NQ=F0(($,J={})=>{let Z=J.tolerance??1,Q=J.algorithm??"douglas-peucker",K=J.respectStroke!==!1,q=u7($),H=(W)=>{if(W.tagName?.toLowerCase()==="path"){let z=W.getAttribute("d");if(z){let G=Z;if(K){let U=r$(W),Y=i$(W,U,q);if(Y.hasStroke&&Y.strokeWidth.greaterThan(0)){let V=Y.strokeWidth.div(4).toNumber();G=Math.min(Z,V)}}let F=i0(z),_=JJ(F,G,Q);if(_.simplified){let U=r0(_.commands,J.precision??3);W.setAttribute("d",U)}}}for(let z of W.children||[])H(z)};return H($),$}),CQ=F0(($,J={})=>{let Z=(Q)=>{let K=Q.getAttribute("transform");if(K){let q=K7(K),H=X8(q);Q.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 Q.children)if(i(q))Z(q)};return Z($),$});function r6($,J){let Z=$.tagName.toLowerCase();try{if(Z==="path"){let Q=$.getAttribute("d");if(!Q)return null;let K=K$(Q),q=[],H=0,W=0;for(let j of K)if(j.command==="M"||j.command==="L")H=j.args[0].toNumber(),W=j.args[1].toNumber(),q.push({x:H,y:W});return q}if(Z==="rect"){let Q=$.getAttribute("x")||"0",K=$.getAttribute("y")||"0",q=$.getAttribute("width")||"0",H=$.getAttribute("height")||"0";if(r7(Q)||r7(K)||r7(q)||r7(H))return null;let W=parseFloat(Q),j=parseFloat(K),z=parseFloat(q),G=parseFloat(H);if(isNaN(W)||isNaN(j)||isNaN(z)||isNaN(G))return null;return[{x:W,y:j},{x:W+z,y:j},{x:W+z,y:j+G},{x:W,y:j+G}]}if(Z==="circle"){let Q=parseFloat($.getAttribute("cx")||"0"),K=parseFloat($.getAttribute("cy")||"0"),q=parseFloat($.getAttribute("r")||"0");if(isNaN(Q)||isNaN(K)||isNaN(q))return null;let H=[];for(let W=0;W<J;W++){let j=W/J*2*Math.PI;H.push({x:Q+q*Math.cos(j),y:K+q*Math.sin(j)})}return H}return null}catch(Q){return console.warn(`getShapePolygon failed for ${Z}:`,Q.message),null}}var Vz={".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 bJ(){return typeof process!=="undefined"&&process.versions?.node}function UZ($){if(!$||typeof $!=="string")return!1;if($.startsWith("#"))return!1;if($.startsWith("data:"))return!1;return!0}function Oz($){let J=$.indexOf("#");if(J===-1)return{path:$,fragment:null};return{path:$.substring(0,J),fragment:$.substring(J+1)}}function a6($){let J=($.match(/\.[a-z0-9]+$/i)||[""])[0].toLowerCase();return Vz[J]||"application/octet-stream"}function o7($,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(Q){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Q.message}`);return $}if(bJ())try{let Q=(M$(),cQ(Y$)),K=J.endsWith("/")?J:Q.dirname(J),q=Q.resolve(K,$),H=Q.resolve(K);if(!q.startsWith(H+Q.sep)&&q!==H)return console.warn(`Path traversal blocked: ${$} escapes base directory`),$;return q}catch(Q){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Q.message}`);let K=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked in fallback: ${$}`),$;return K+$}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 i7($,J="text",Z=30000){if(bJ()&&!$.match(/^https?:\/\//i)){let q=await import("node:fs/promises");return{content:J==="binary"?await q.readFile($):await q.readFile($,"utf8"),contentType:a6($)}}let Q=new AbortController,K=setTimeout(()=>Q.abort(),Z);try{let q=await fetch($,{signal:Q.signal});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);let H=q.headers.get("content-type")||a6($);return{content:J==="binary"?await q.arrayBuffer():await q.text(),contentType:H}}finally{clearTimeout(K)}}function H6($,J){let Z;if(bJ())Z=Buffer.from($).toString("base64");else{let Q=new Uint8Array($),K="";for(let q=0;q<Q.length;q++)K+=String.fromCharCode(Q[q]);Z=btoa(K)}return`data:${J};base64,${Z}`}function kJ($){let J=[],Z=[],Q=/@import\s+(?:url\(\s*["']?([^"')]+)["']?\s*\)|["']([^"']+)["'])/gi,K,q=0;while((K=Q.exec($))!==null){if(K.index===q&&K[0].length===0){console.error("Regex matched empty string in @import, breaking to prevent infinite loop");break}q=K.index+Math.max(1,K[0].length),J.push({url:K[1]||K[2],fullMatch:K[0],index:K.index})}let H=/url\(\s*["']?([^"')]+)["']?\s*\)/gi,W=0;while((K=H.exec($))!==null){if(K.index===W&&K[0].length===0){console.error("Regex matched empty string in url(), breaking to prevent infinite loop");break}if(W=K.index+Math.max(1,K[0].length),$.substring(Math.max(0,K.index-10),K.index).includes("@import"))continue;if(K[1].startsWith("#"))continue;if(K[1].startsWith("data:"))continue;Z.push({url:K[1],fullMatch:K[0],index:K.index})}return{imports:J,urls:Z}}function RJ($,J,Z=new Map){if(!$)return Z;let Q=$.getAttribute?.("id");if(Q){let H=J+Q;Z.set(Q,H),$.setAttribute("id",H)}let K=["href","xlink:href","fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end"];for(let H of K){let W=$.getAttribute?.(H);if(!W)continue;if(W.includes("url(#")){let j=W.replace(/url\(#([^)]+)\)/g,(z,G)=>{return`url(#${Z.get(G)||J+G})`});$.setAttribute(H,j)}else if(W.startsWith("#")){let j=W.substring(1);$.setAttribute(H,"#"+(Z.get(j)||J+j))}}let q=$.getAttribute?.("style");if(q&&q.includes("url(#")){let H=q.replace(/url\(#([^)]+)\)/g,(W,j)=>{return`url(#${Z.get(j)||J+j})`});$.setAttribute("style",H)}if($.children)for(let H of $.children)RJ(H,J,Z);return Z}function IQ($,J,Z){if(!$){console.warn("setCDATAContent called with null element");return}let Q=0,K=1e4;while($.firstChild&&Q++<K){let H=$.firstChild;if($.removeChild(H),$.firstChild===H){console.error("removeChild failed to remove child in setCDATAContent, breaking to prevent infinite loop");break}}if(Q>=K)console.error(`Safety limit reached in setCDATAContent: ${K} 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 Yz={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"]},Mz=Object.values(Yz).flat();function Xz($){let J=new Set,Z=Mz.map((q)=>q.replace(".","\\.")).join("|"),Q=new RegExp(`["'\`]([^"'\`]*(?:${Z}))["'\`]`,"gi"),K;while((K=Q.exec($))!==null){let q=K[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,Q]of $)J[Z]=Q;return`
|
|
357
357
|
// ===== EMBEDDED RESOURCES INTERCEPTOR (auto-generated) =====
|
|
358
358
|
(function() {
|
|
359
359
|
var __EMBEDDED_RESOURCES__ = ${JSON.stringify(J,null,0)};
|
|
@@ -490,10 +490,10 @@ ${H}
|
|
|
490
490
|
})();
|
|
491
491
|
// ===== END EMBEDDED RESOURCES INTERCEPTOR =====
|
|
492
492
|
|
|
493
|
-
`}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 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 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 CJ=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:Y=30000,onMissingResource:V="warn",onProgress:M=null,idPrefix:X="ext_",_visitedURLs:k=null}=J,w=k||new Set,R=[],I=new Map,P=0,h=(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)}}},u=(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(M)M("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||!ZZ(d))continue;try{let N=l7(d,Z),{content:y,contentType:B}=await s7(N,"binary",Y),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){u(d,N)}if(M)M("images",m+1,E.length)}}if(Q){let E=[...$.getElementsByTagName("use")];if(M)M("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"),M)M("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||!ZZ(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",Y),l=u0(i);if(!l){u(y,new Error("Failed to parse SVG"));continue}let q0=l.documentElement||l;if(h(q0),_&&U>0)await CJ(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 u(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){u(y,i)}if(M)M("externalSVGs",c+1,E.length)}}if(H||W){let E=[...$.getElementsByTagName("style")];if(M)M("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}=UJ(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",Y),q0=l,f=UJ(l).imports;if(f.length>0)for(let A of f.reverse())try{let e=l7(A.url,i),$0=await s7(e,"text",Y);q0=q0.substring(0,A.index)+$0.content+q0.substring(A.index+A.fullMatch.length)}catch(e){u(A.url,e)}N=N.substring(0,B.index)+q0+N.substring(B.index+B.fullMatch.length)}catch(t){u(B.url,t)}}if(H||W){let{urls:y}=UJ(N);for(let B of y.reverse()){let t=i6(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",Y),e=`url("${Q6(q0,f.split(";")[0])}")`;N=N.substring(0,B.index)+e+N.substring(B.index+B.fullMatch.length)}catch(l){u(B.url,l)}}}if(d.textContent=N,M)M("stylesheets",c+1,E.length)}}if(z){let E=[...$.getElementsByTagName("script")];if(M)M("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",Y);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),VK(c,y,$)}catch(N){u(d,N)}if(M)M("scripts",m+1,E.length)}}if(j){let E=[...$.getElementsByTagName("audio")];if(M)M("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",Y),i=t.split(";")[0]||"audio/mpeg",l=Q6(B,i);c.setAttribute("src",l)}catch(y){u(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",Y),q0=l.split(";")[0]||y.getAttribute("type")||"audio/mpeg",f=Q6(i,q0);y.setAttribute("src",f)}catch(t){u(B,t)}}if(M)M("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(M)M("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",Y),q0=l.split(";")[0]||i6(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){u(B,t)}if(y++,M)M("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(Q7($).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 M$($){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 Y$($){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 OK($,J={}){let Z=w$($),K=await H6($,Z),Q=J.outputFormat||(Z===D0.DOM_ELEMENT?X7.DOM_ELEMENT:X7.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:Y=!0,dryRun:V=!1,extractOnly:M=!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 g=b;while(g&&g.getAttribute){let v=g.getAttribute("id");if(v&&I.has(v))return!0;g=g.parentNode}return!1},h=async(b,g,v)=>{let E=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(g))E=g.length;else if(typeof Buffer!=="undefined")E=Buffer.byteLength(g,"utf8");else if(typeof Blob!=="undefined")E=new Blob([g]).size;else E=g.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(g))await c.writeFile(N,g);else await c.writeFile(N,g,"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 g=[...K.getElementsByTagName("image")];if(X)X("images",0,g.length);for(let v=0;v<g.length;v++){let E=g[v];if(!P(E))continue;let m=E.getAttribute("href")||E.getAttribute("xlink:href");if(!m||!m.startsWith("data:"))continue;let c=M$(m);if(!c)continue;if(!c.mimeType.startsWith("image/"))continue;R++;let d=W$(H,c.mimeType,R),N=Y$(c),y=await h(d,N,c.mimeType);if(y.type="image",y.elementId=E.getAttribute("id"),!M){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,g.length)}}if(F){let g=[...K.getElementsByTagName("audio")];if(X)X("audio",0,g.length);for(let v=0;v<g.length;v++){let E=g[v];if(!P(E))continue;let m=E.getAttribute("src");if(m&&m.startsWith("data:")){let d=M$(m);if(d&&d.mimeType.startsWith("audio/")){R++;let N=W$(H,d.mimeType,R),y=Y$(d),B=await h(N,y,d.mimeType);if(B.type="audio",B.elementId=E.getAttribute("id"),!M)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=M$(N);if(y&&y.mimeType.startsWith("audio/")){R++;let B=W$(H,y.mimeType,R),t=Y$(y),i=await h(B,t,y.mimeType);if(i.type="audio",!M)d.setAttribute("src",`./${B}`)}}}if(X)X("audio",v+1,g.length)}}if(_){let g=[...K.getElementsByTagName("video")];if(X)X("video",0,g.length);for(let v=0;v<g.length;v++){let E=g[v];if(!P(E))continue;let m=E.getAttribute("src");if(m&&m.startsWith("data:")){let d=M$(m);if(d&&d.mimeType.startsWith("video/")){R++;let N=W$(H,d.mimeType,R),y=Y$(d),B=await h(N,y,d.mimeType);if(B.type="video",B.elementId=E.getAttribute("id"),!M)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=M$(N);if(y&&y.mimeType.startsWith("video/")){R++;let B=W$(H,y.mimeType,R),t=Y$(y),i=await h(B,t,y.mimeType);if(i.type="video",!M)d.setAttribute("src",`./${B}`)}}}if(X)X("video",v+1,g.length)}}if(j){let g=[...K.getElementsByTagName("script")];if(X)X("scripts",0,g.length);for(let v=0;v<g.length;v++){let E=g[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=M$(m);if(y){let B=Y$(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 h(d,c,"application/javascript");if(N.type="script",N.elementId=E.getAttribute("id"),!M){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,g.length)}}if(G||z){let g=[...K.getElementsByTagName("style")];if(X)X("styles",0,g.length);for(let v=0;v<g.length;v++){let E=g[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=M$(t);if(i){R++;let l=W$(H,i.mimeType,R),q0=Y$(i),f=await h(l,q0,i.mimeType);f.type="font";let A=y.match(/font-family:\s*["']?([^"';]+)["']?/);if(A)f.fontFamily=A[1].trim();if(!M)m=m.replace(t,`./${l}`),c=!0}}}if(Y){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&&!M){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');
|
|
494
|
-
`;if(!
|
|
495
|
-
`)}function
|
|
493
|
+
`}function Lz($){let J=new Map,Z=(K,q)=>{if(!K||!q)return;let H=K.replace(/['"]/g,"").trim().split(",")[0].trim();if(!J.has(H))J.set(H,new Set);let W=J.get(H);for(let j of q)W.add(j)},Q=(K)=>{if(!K)return;let H=(K.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),W=H?H[1]:null,j=K.getAttribute?.("font-family"),z=K.getAttribute?.("face"),G=W||j||z,F="";if(K.childNodes){for(let _ of K.childNodes)if(_.nodeType===3)F+=_.nodeValue||""}if(G&&F.trim())Z(G,F);if(K.tagName==="text"||K.tagName==="tspan"){let _=G;if(!_&&K.parentNode){let Y=(K.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);_=Y?Y[1]:K.parentNode.getAttribute?.("font-family")}if(_&&F.trim())Z(_,F)}if(K.children)for(let _ of K.children)Q(_)};return Q($),J}function wz($){let J=[...$].sort().join("");return encodeURIComponent(J)}function Rz($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function Bz($){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 Nz($,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 Q=$.includes("?")?"&":"?";return`${$}${Q}text=${J}`}}var fJ=F0(async($,J={})=>{let{basePath:Z="",embedImages:Q=!0,embedExternalSVGs:K=!0,externalSVGMode:q="extract",embedCSS:H=!0,embedFonts:W=!0,embedScripts:j=!0,embedAudio:z=!1,subsetFonts:G=!0,verbose:F=!1,recursive:_=!0,maxRecursionDepth:U=10,timeout:Y=30000,onMissingResource:V="warn",onProgress:M=null,idPrefix:X="ext_",_visitedURLs:k=null}=J,L=k||new Set,R=[],B=new Map,I=0,h=(D)=>{if(!D||!D.attributes)return;let T=["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"],d=["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=D.attributes;for(let p=0;p<c.length;p++){let C=c[p];if(C.name.startsWith("xmlns:")){let y=C.name.substring(6),N=C.value;if(T.some((e)=>N.startsWith(e))||!d.includes(N))B.set(y,N)}}},g=(D,T)=>{let d=`Failed to fetch resource: ${D} - ${T.message}`;if(V==="fail")throw new Error(d);else if(V==="warn")R.push(d),console.warn("embedExternalDependencies:",d);return null};if(Q){let T=[...$.getElementsByTagName("image")];if(M)M("images",0,T.length);for(let d=0;d<T.length;d++){let c=T[d],p=c.getAttribute("href")||c.getAttribute("xlink:href");if(!p||!UZ(p))continue;try{let C=o7(p,Z),{content:y,contentType:N}=await i7(C,"binary",Y),e=H6(y,N.split(";")[0]);if(c.getAttribute("href"))c.setAttribute("href",e);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href",e)}catch(C){g(p,C)}if(M)M("images",d+1,T.length)}}if(K){let T=[...$.getElementsByTagName("use")];if(M)M("externalSVGs",0,T.length);let d=$.querySelector("defs");if(!d){let c=$.documentElement||$;if(!c){if(R.push("Cannot add defs: document has no root SVG element"),M)M("externalSVGs",T.length,T.length)}else if(d=new w0("defs",{},[]),typeof c.insertBefore==="function"&&c.firstChild)c.insertBefore(d,c.firstChild);else if(typeof c.appendChild==="function")c.appendChild(d);else if(c.children&&Array.isArray(c.children))c.children.unshift(d),d.parentNode=c}if(d)for(let c=0;c<T.length;c++){let p=T[c],C=p.getAttribute("href")||p.getAttribute("xlink:href");if(!C||!UZ(C))continue;let{path:y,fragment:N}=Oz(C);if(!y)continue;let e=o7(y,Z);if(L.has(e)){R.push(`Circular reference detected: ${e}`);continue}L.add(e);try{let{content:r}=await i7(e,"text",Y),s=x0(r);if(!s){g(y,new Error("Failed to parse SVG"));continue}let q0=s.documentElement||s;if(h(q0),_&&U>0)await fJ(s,{...J,basePath:e,maxRecursionDepth:U-1,_visitedURLs:L});I++;let v=`${X}${I}_`;if(q==="extract"&&N){let E=s.getElementById(N);if(E){let t=E.clone?E.clone():JSON.parse(JSON.stringify(E));RJ(t,v),d.children.push(t);let $0=v+N;if(p.getAttribute("href"))p.setAttribute("href","#"+$0);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href","#"+$0)}else g(C,new Error(`Fragment #${N} not found in ${y}`))}else{let E=s.documentElement||s;RJ(E,v);let t=v+"svg";E.setAttribute("id",t),d.children.push(E);let $0=N?"#"+v+N:"#"+t;if(p.getAttribute("href"))p.setAttribute("href",$0);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href",$0)}}catch(r){g(y,r)}if(M)M("externalSVGs",c+1,T.length)}}if(H||W){let T=[...$.getElementsByTagName("style")];if(M)M("stylesheets",0,T.length);let d=G?Lz($):null;for(let c=0;c<T.length;c++){let p=T[c],C=p.textContent||"";if(H){let{imports:y}=kJ(C);for(let N of y.reverse())try{let e=N.url;if(d&&Rz(e)){let E=Bz(e);if(E&&d.has(E)){let t=wz(d.get(E));if(e=Nz(e,t),F)console.log(`Font subsetting: ${E} -> ${d.get(E).size} chars`)}}let r=o7(e,Z),{content:s}=await i7(r,"text",Y),q0=s,v=kJ(s).imports;if(v.length>0)for(let E of v.reverse())try{let t=o7(E.url,r),$0=await i7(t,"text",Y);q0=q0.substring(0,E.index)+$0.content+q0.substring(E.index+E.fullMatch.length)}catch(t){g(E.url,t)}C=C.substring(0,N.index)+q0+C.substring(N.index+N.fullMatch.length)}catch(e){g(N.url,e)}}if(H||W){let{urls:y}=kJ(C);for(let N of y.reverse()){let e=a6(N.url),r=e.startsWith("font/")||e.includes("fontobject");if(r&&!W)continue;if(!r&&!H)continue;try{let s=o7(N.url,Z),{content:q0,contentType:v}=await i7(s,"binary",Y),t=`url("${H6(q0,v.split(";")[0])}")`;C=C.substring(0,N.index)+t+C.substring(N.index+N.fullMatch.length)}catch(s){g(N.url,s)}}}if(p.textContent=C,M)M("stylesheets",c+1,T.length)}}if(j){let T=[...$.getElementsByTagName("script")];if(M)M("scripts",0,T.length);for(let d=0;d<T.length;d++){let c=T[d],p=c.getAttribute("src")||c.getAttribute("href")||c.getAttribute("xlink:href");if(!p)continue;if(p.startsWith("data:"))continue;try{let C=o7(p,Z),{content:y}=await i7(C,"text",Y);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),IQ(c,y,$)}catch(C){g(p,C)}if(M)M("scripts",d+1,T.length)}}if(z){let T=[...$.getElementsByTagName("audio")];if(M)M("audio",0,T.length);for(let d=0;d<T.length;d++){let c=T[d],p=c.getAttribute("src");if(p&&!p.startsWith("data:"))try{let y=o7(p,Z),{content:N,contentType:e}=await i7(y,"binary",Y),r=e.split(";")[0]||"audio/mpeg",s=H6(N,r);c.setAttribute("src",s)}catch(y){g(p,y)}let C=c.getElementsByTagName("source");for(let y of C){let N=y.getAttribute("src");if(N&&!N.startsWith("data:"))try{let e=o7(N,Z),{content:r,contentType:s}=await i7(e,"binary",Y),q0=s.split(";")[0]||y.getAttribute("type")||"audio/mpeg",v=H6(r,q0);y.setAttribute("src",v)}catch(e){g(N,e)}}if(M)M("audio",d+1,T.length)}}if(j){let D=[],T=$.getElementsByTagName("script");for(let C of T)if(C.textContent)D.push(C.textContent);let d=$.getElementsByTagName("style");for(let C of d)if(C.textContent)D.push(C.textContent);let c=$.getElementsByTagName("foreignObject");for(let C of c){let y=C.textContent||"";if(y)D.push(y)}let p=new Set;for(let C of D){let y=Xz(C);for(let N of y)p.add(N)}if(p.size>0){let C=new Map;if(M)M("resources",0,p.size);let y=0;for(let N of p){try{let e=o7(N,Z),{content:r,contentType:s}=await i7(e,"binary",Y),q0=s.split(";")[0]||a6(N),v=H6(r,q0);if(C.set(N,v),F){let E=(r.length/1024).toFixed(1);console.log(`Embedded resource: ${N} (${E} KB)`)}}catch(e){g(N,e)}if(y++,M)M("resources",y,p.size)}if(C.size>0){let N=kz(C),e=T[0];if(e){let r=e.textContent||"";if(N.includes("<")||N.includes("&")||r.includes("<")||r.includes("&"))e.setAttribute("data-cdata-pending","true");e.textContent=N+r}else{let r=$.createElement("script");r.setAttribute("type","text/javascript"),r.setAttribute("data-cdata-pending","true"),r.textContent=N;let s=$.documentElement||$;if(s.firstChild)s.insertBefore(r,s.firstChild);else s.appendChild(r)}if(F)console.log(`Injected resource interceptor for ${C.size} embedded resources`)}}}let f=$.documentElement||$;if(!f.getAttribute("xmlns"))f.setAttribute("xmlns","http://www.w3.org/2000/svg");if(q7($).includes("xlink:")&&!f.getAttribute("xmlns:xlink"))f.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[D,T]of B){let d=`xmlns:${D}`;if(!f.getAttribute(d))f.setAttribute(d,T)}if(R.length>0)$._embedWarnings=R;return $}),Cz={"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 X$($){if(!$||!$.startsWith("data:"))return null;let J=$.match(/^data:([^;,]+)?(?:;([^,]+))?,(.*)$/);if(!J)return null;let Z=J[1]||"application/octet-stream",Q=J[2]||"",K=J[3]||"";return{mimeType:Z,encoding:Q,data:K}}function k$($){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 G$($,J,Z,Q=null){let K=Cz[J]||".bin";if(Q){let H=Q.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")}${K}`}async function PQ($,J={}){let Z=R$($),Q=await z6($,Z),K=J.outputFormat||(Z===h0.DOM_ELEMENT?k7.DOM_ELEMENT:k7.SVG_STRING),{outputDir:q=null,filenamePrefix:H="resource",extractImages:W=!0,extractFonts:j=!0,extractScripts:z=!0,extractStyles:G=!0,extractAudio:F=!0,extractVideo:_=!0,elementIds:U=null,restoreGoogleFonts:Y=!0,dryRun:V=!1,extractOnly:M=!1,onProgress:X=null}=J,k=[],L=[],R=0,B=U?new Set(Array.isArray(U)?U:[U]):null,I=(f)=>{if(!B)return!0;let x=f;while(x&&x.getAttribute){let D=x.getAttribute("id");if(D&&B.has(D))return!0;x=x.parentNode}return!1},h=async(f,x,D)=>{let T=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))T=x.length;else if(typeof Buffer!=="undefined")T=Buffer.byteLength(x,"utf8");else if(typeof Blob!=="undefined")T=new Blob([x]).size;else T=x.length||0;let d={filename:f,path:q?`${q}/${f}`:f,mimeType:D,size:T};if(!V&&q)try{let c=await import("node:fs/promises"),p=await Promise.resolve().then(() => (M$(),Y$));await c.mkdir(q,{recursive:!0});let C=p.join(q,f);if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))await c.writeFile(C,x);else await c.writeFile(C,x,"utf8");d.path=C,k.push(d)}catch(c){L.push(`Failed to save ${f}: ${c.message}`),d.error=c.message}else k.push(d);return d};if(W){let x=[...Q.getElementsByTagName("image")];if(X)X("images",0,x.length);for(let D=0;D<x.length;D++){let T=x[D];if(!I(T))continue;let d=T.getAttribute("href")||T.getAttribute("xlink:href");if(!d||!d.startsWith("data:"))continue;let c=X$(d);if(!c)continue;if(!c.mimeType.startsWith("image/"))continue;R++;let p=G$(H,c.mimeType,R),C=k$(c),y=await h(p,C,c.mimeType);if(y.type="image",y.elementId=T.getAttribute("id"),!M){let N=`./${p}`;if(T.getAttribute("href"))T.setAttribute("href",N);if(T.getAttribute("xlink:href"))T.setAttribute("xlink:href",N)}if(X)X("images",D+1,x.length)}}if(F){let x=[...Q.getElementsByTagName("audio")];if(X)X("audio",0,x.length);for(let D=0;D<x.length;D++){let T=x[D];if(!I(T))continue;let d=T.getAttribute("src");if(d&&d.startsWith("data:")){let p=X$(d);if(p&&p.mimeType.startsWith("audio/")){R++;let C=G$(H,p.mimeType,R),y=k$(p),N=await h(C,y,p.mimeType);if(N.type="audio",N.elementId=T.getAttribute("id"),!M)T.setAttribute("src",`./${C}`)}}let c=T.getElementsByTagName("source");for(let p of c){let C=p.getAttribute("src");if(C&&C.startsWith("data:")){let y=X$(C);if(y&&y.mimeType.startsWith("audio/")){R++;let N=G$(H,y.mimeType,R),e=k$(y),r=await h(N,e,y.mimeType);if(r.type="audio",!M)p.setAttribute("src",`./${N}`)}}}if(X)X("audio",D+1,x.length)}}if(_){let x=[...Q.getElementsByTagName("video")];if(X)X("video",0,x.length);for(let D=0;D<x.length;D++){let T=x[D];if(!I(T))continue;let d=T.getAttribute("src");if(d&&d.startsWith("data:")){let p=X$(d);if(p&&p.mimeType.startsWith("video/")){R++;let C=G$(H,p.mimeType,R),y=k$(p),N=await h(C,y,p.mimeType);if(N.type="video",N.elementId=T.getAttribute("id"),!M)T.setAttribute("src",`./${C}`)}}let c=T.getElementsByTagName("source");for(let p of c){let C=p.getAttribute("src");if(C&&C.startsWith("data:")){let y=X$(C);if(y&&y.mimeType.startsWith("video/")){R++;let N=G$(H,y.mimeType,R),e=k$(y),r=await h(N,e,y.mimeType);if(r.type="video",!M)p.setAttribute("src",`./${N}`)}}}if(X)X("video",D+1,x.length)}}if(z){let x=[...Q.getElementsByTagName("script")];if(X)X("scripts",0,x.length);for(let D=0;D<x.length;D++){let T=x[D];if(!I(T))continue;let d=T.getAttribute("href")||T.getAttribute("xlink:href");if(d&&!d.startsWith("data:"))continue;let c="";if(d&&d.startsWith("data:")){let y=X$(d);if(y){let N=k$(y);c=typeof N==="string"?N:N.toString("utf8")}}else if(c=T.textContent||"",T.firstChild&&T.firstChild.nodeType===4)c=T.firstChild.nodeValue||"";if(!c.trim())continue;R++;let p=G$(H,"application/javascript",R),C=await h(p,c,"application/javascript");if(C.type="script",C.elementId=T.getAttribute("id"),!M){let y=0;while(T.firstChild&&y++<1e4){let N=T.firstChild;if(T.removeChild(N),T.firstChild===N)break}if(y>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");T.setAttribute("href",`./${p}`)}if(X)X("scripts",D+1,x.length)}}if(G||j){let x=[...Q.getElementsByTagName("style")];if(X)X("styles",0,x.length);for(let D=0;D<x.length;D++){let T=x[D];if(!I(T))continue;let d=T.textContent||"";if(T.firstChild&&T.firstChild.nodeType===4)d=T.firstChild.nodeValue||"";if(!d.trim())continue;let c=!1;if(j){let p=/@font-face\s*\{[^}]*\}/gi,C=d.match(p)||[];for(let y of C){let N=y.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(N){let e=N[1],r=X$(e);if(r){R++;let s=G$(H,r.mimeType,R),q0=k$(r),v=await h(s,q0,r.mimeType);v.type="font";let E=y.match(/font-family:\s*["']?([^"';]+)["']?/);if(E)v.fontFamily=E[1].trim();if(!M)d=d.replace(e,`./${s}`),c=!0}}}if(Y){let y=[],N=/font-family:\s*["']?([^"';,]+)/gi,e;while((e=N.exec(d))!==null){let r=e[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)=>r.toLowerCase().includes(q0.toLowerCase())))y.push(r)}if(y.length>0&&!M){let r=[...new Set(y)],s=`@import url('https://fonts.googleapis.com/css2?family=${r.map((q0)=>q0.replace(/\s+/g,"+")).join("&family=")}&display=swap');
|
|
494
|
+
`;if(!d.includes("fonts.googleapis.com"))d=s+d,c=!0,L.push(`Restored Google Fonts import for: ${r.join(", ")}`)}}}if(G&&d.trim()){R++;let p=G$(H,"text/css",R),C=await h(p,d,"text/css");if(C.type="stylesheet",C.elementId=T.getAttribute("id"),!M){let y=0;while(T.firstChild&&y++<1e4){let N=T.firstChild;if(T.removeChild(N),T.firstChild===N)break}if(y>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");T.textContent=`@import url('./${p}');`,c=!0}}else if(c&&!M){let p=0;while(T.firstChild&&p++<1e4){let C=T.firstChild;if(T.removeChild(C),T.firstChild===C)break}if(p>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");IQ(T,d,Q)}if(X)X("styles",D+1,x.length)}}if(!M){if(Q._exportedResources=k,L.length>0)Q._exportWarnings=L}return{doc:M?null:j6(Q,K,J),extractedFiles:k,warnings:L,summary:{totalExtracted:k.length,images:k.filter((f)=>f.type==="image").length,audio:k.filter((f)=>f.type==="audio").length,video:k.filter((f)=>f.type==="video").length,scripts:k.filter((f)=>f.type==="script").length,fonts:k.filter((f)=>f.type==="font").length,stylesheets:k.filter((f)=>f.type==="stylesheet").length,totalSize:k.reduce((f,x)=>f+x.size,0)}}}var Iz={MAX_PRECISION:W6,DEFAULT_PRECISION:i6,PRECISION_LEVELS:VZ,formatPrecision:OZ,InputType:h0,OutputFormat:k7,OutputTarget:X7,detectInputType:R$,detectOutputTarget:NJ,loadInput:z6,generateOutput:j6,saveOutput:YZ,createOperation:F0,cleanupIds:CJ,cleanupNumericValues:t6,cleanupListOfValues:MZ,cleanupAttributes:XZ,cleanupEnableBackground:kZ,removeUnknownsAndDefaults:LZ,removeNonInheritableGroupAttrs:wZ,removeUselessDefs:RZ,removeHiddenElements:e6,removeEmptyText:BZ,removeEmptyContainers:$9,removeDoctype:NZ,removeXMLProcInst:CZ,removeComments:J9,removeMetadata:Z9,removeTitle:IZ,removeDesc:PZ,removeEditorsNSData:IJ,removeEmptyAttrs:AZ,removeViewBox:TZ,removeXMLNS:bZ,removeRasterImages:fZ,removeScriptElement:SZ,convertToPlainSVG:EZ,convertShapesToPath:vZ,convertPathData:DZ,convertTransform:hZ,convertColors:Q9,convertStyleToAttrs:PJ,convertEllipseToCircle:yZ,collapseGroups:uZ,mergePaths:gZ,moveGroupAttrsToElems:xZ,moveElemsAttrsToGroup:mZ,minifyStyles:AJ,inlineStyles:dZ,sortAttrs:pZ,sortDefsChildren:cZ,reusePaths:nZ,removeOffCanvasPath:lZ,removeStyleElement:sZ,removeXlink:oZ,addAttributesToSVGElement:iZ,addClassesToSVGElement:rZ,prefixIds:aZ,removeDimensions:tZ,removeAttributesBySelector:eZ,removeAttrs:$Q,removeElementsByAttr:JQ,presetDefault:EJ,presetNone:TJ,applyPreset:ZQ,optimize:QQ,createConfig:KQ,flattenClipPaths:qQ,flattenMasks:HQ,flattenGradients:WQ,flattenPatterns:jQ,flattenFilters:GQ,flattenUseElements:FQ,imageToPath:_Q,detectCollisions:UQ,measureDistance:VQ,validateXML:OQ,validateSVG:YQ,fixInvalidSVG:XQ,ValidationSeverity:B0,flattenAll:LQ,simplifyPath:wQ,decomposeTransform:CQ,optimizeAnimationTiming:RQ,optimizePaths:BQ,simplifyPaths:NQ,embedExternalDependencies:fJ,exportEmbeddedResources:PQ,convertPathDataAdvanced:a9,parsePathCommands:i0,serializePathCommands:r0,formatPathNumber:x7,douglasPeucker:K6,visvalingamWhyatt:t9,simplifyPolyline:e9,simplifyPolylinePath:JJ,isPurePolyline:$J,optimizeKeySplines:l9,optimizeKeyTimes:s9,optimizeAnimationValues:p6,formatSplineValue:Q6,parseKeySplines:c6,serializeKeySplines:c9,isLinearSpline:n6,areAllSplinesLinear:r5,identifyStandardEasing:n9,STANDARD_EASINGS:p9,removeLeadingZero:QJ,negativeExtraSpace:KJ,convertToRelative:qJ,convertToAbsolute:HJ,lineShorthands:WJ,convertToZ:zJ,straightCurves:jJ,collapseRepeated:GJ,floatPrecision:FJ,removeUselessCommands:_J,convertCubicToQuadratic:UJ,convertQuadraticToSmooth:VJ,convertCubicToSmooth:OJ,arcShorthands:YJ};var lJ={};d7(lJ,{setPolyfillMinification:()=>pJ,setPolyfillContent:()=>cJ,removePolyfills:()=>pz,needsPolyfills:()=>xz,injectPolyfills:()=>nJ,generatePolyfillScript:()=>uQ,detectSVG2Features:()=>G6,SVG2_FEATURES:()=>gz});var yz=typeof process!=="undefined"&&process.versions&&process.versions.node,uz=typeof window!=="undefined",uJ="",gJ="",xJ="",mJ="";if(yz)try{let $=await import("fs"),J=await Promise.resolve().then(() => (yQ(),hQ)),Z=await Promise.resolve().then(() => (M$(),Y$)),Q=J.fileURLToPath(import.meta.url),K=Z.dirname(Q);uJ=$.readFileSync(Z.join(K,"vendor","inkscape-mesh-polyfill.min.js"),"utf-8"),gJ=$.readFileSync(Z.join(K,"vendor","inkscape-mesh-polyfill.js"),"utf-8"),xJ=$.readFileSync(Z.join(K,"vendor","inkscape-hatch-polyfill.min.js"),"utf-8"),mJ=$.readFileSync(Z.join(K,"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(uz)console.warn("SVG2 polyfills: Running in browser mode. Use setPolyfillContent() to provide polyfill scripts.");var dJ=!0;function pJ($){if(typeof $!=="boolean")throw new Error("setPolyfillMinification: minify parameter must be a boolean");dJ=$}function cJ($){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");uJ=$.meshMin}if($.meshFull!==void 0){if(typeof $.meshFull!=="string")throw new Error("setPolyfillContent: meshFull must be a string");gJ=$.meshFull}if($.hatchMin!==void 0){if(typeof $.hatchMin!=="string")throw new Error("setPolyfillContent: hatchMin must be a string");xJ=$.hatchMin}if($.hatchFull!==void 0){if(typeof $.hatchFull!=="string")throw new Error("setPolyfillContent: hatchFull must be a string");mJ=$.hatchFull}}var gz={MESH_GRADIENT:"meshGradient",HATCH:"hatch",CONTEXT_PAINT:"context-paint",AUTO_START_REVERSE:"auto-start-reverse"};function G6($){if(!$||typeof $!=="object")return{meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1};let J={meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1},Z=(Q)=>{if(!Q)return;let K=Q.tagName?.toLowerCase();if(K==="meshgradient"){let z=Q.getAttribute("id");if(z&&typeof z==="string"&&z.trim()&&!J.meshGradients.includes(z))J.meshGradients.push(z)}if(K==="hatch"){let z=Q.getAttribute("id");if(z&&typeof z==="string"&&z.trim()&&!J.hatches.includes(z))J.hatches.push(z)}let q=Q.getAttribute("fill"),H=Q.getAttribute("stroke"),W=Q.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(K==="style"&&Q.textContent){if(Q.textContent.includes("context-fill")||Q.textContent.includes("context-stroke"))J.contextPaint=!0}if(Q.getAttribute("orient")==="auto-start-reverse")J.autoStartReverse=!0;if(Q.children&&Array.isArray(Q.children))for(let z of Q.children)Z(z)};return Z($),J}function xz($){if(!$)return!1;let J=G6($);return J.meshGradients.length>0||J.hatches.length>0||J.contextPaint||J.autoStartReverse}function mz(){let $=dJ?uJ:gJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape mesh polyfill not available. Ensure vendor/inkscape-mesh-polyfill files are present.");return $}function dz(){let $=dJ?xJ:mJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape hatch polyfill not available. Ensure vendor/inkscape-hatch-polyfill files are present.");return $}function uQ($){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(mz());if($.hatches.length>0)J.push(dz());if(J.length===1)return null;return J.join(`
|
|
495
|
+
`)}function nJ($,J={}){if(!$)return $;let Z=J.features||G6($);if(!J.force&&Z.meshGradients.length===0&&Z.hatches.length===0)return $;let Q=uQ(Z);if(!Q)return $;let K=$.documentElement||$,q=`
|
|
496
496
|
// <![CDATA[
|
|
497
|
-
${
|
|
497
|
+
${Q}
|
|
498
498
|
// ]]>
|
|
499
|
-
`,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(
|
|
499
|
+
`,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(K.children))K.children=[];if(K.children.length>0){let W=0;for(let j=0;j<K.children.length;j++)if(K.children[j]?.tagName==="defs")W=j+1;K.children.splice(W,0,H)}else K.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((Q)=>{if(Q?.tagName==="script"){if(Q.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((Q.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let Q of Z.children)if(Q)J(Q)};return J($),$}O.set({precision:80});var cz="1.3.6";var{parseSVG:vj,serializeSVG:Dj}=b9,{detectSVG2Features:hj,injectPolyfills:yj,setPolyfillMinification:uj,setPolyfillContent:gj}=lJ;async function nz($,J={}){let{loadInput:Z,saveOutput:Q,optimize:K}=K9,q=R$($),H=await Z($,q),W=await K(H,{precision:J.precision||6,...J});if(J.output)return Q(W,J.output,J);return Q(W,null,J)}var gQ={VERSION:cz,Decimal:O,Matrix:W0,Vector:v0,Transforms2D:S7,Transforms3D:Y9,GeometryToPath:l$,...K9,parseSVG:x0,serializeSVG:q7,detectSVG2Features:G6,injectPolyfills:nJ,setPolyfillMinification:pJ,setPolyfillContent:cJ,process:nz},dj=gQ;if(typeof window!=="undefined")window.SVGM=gQ;export{OQ as validateXML,Gz as validateSVGAsync,YQ as validateSVG,jJ as straightCurves,cZ as sortDefsChildren,pZ as sortAttrs,NQ as simplifyPaths,wQ as simplifyPath,uj as setPolyfillMinification,gj as setPolyfillContent,Dj as serializeSVG,YZ as saveOutput,nZ as reusePaths,oZ as removeXlink,CZ as removeXMLProcInst,bZ as removeXMLNS,TZ as removeViewBox,RZ as removeUselessDefs,_J as removeUselessCommands,LZ as removeUnknownsAndDefaults,IZ as removeTitle,sZ as removeStyleElement,SZ as removeScriptElement,fZ as removeRasterImages,lZ as removeOffCanvasPath,wZ as removeNonInheritableGroupAttrs,Z9 as removeMetadata,QJ as removeLeadingZero,e6 as removeHiddenElements,BZ as removeEmptyText,$9 as removeEmptyContainers,AZ as removeEmptyAttrs,JQ as removeElementsByAttr,IJ as removeEditorsNSData,NZ as removeDoctype,tZ as removeDimensions,PZ as removeDesc,J9 as removeComments,$Q as removeAttrs,eZ as removeAttributesBySelector,nz as process,Qz as printHierarchicalMatrix,TJ as presetNone,EJ as presetDefault,aZ as prefixIds,vj as parseSVG,BQ as optimizePaths,RQ as optimizeAnimationTiming,QQ as optimize,KJ as negativeExtraSpace,xZ as moveGroupAttrsToElems,mZ as moveElemsAttrsToGroup,AJ as minifyStyles,gZ as mergePaths,VQ as measureDistance,z6 as loadInput,WJ as lineShorthands,dZ as inlineStyles,yj as injectPolyfills,_Q as imageToPath,j6 as generateOutput,Zz as generateFullCompatibilityMatrix,MQ as generateFlexibleSVGTable,Kz as generateCompatibilityMatrixSVG,qz as generateCompatibilityMatrixFlexible,OZ as formatPrecision,FJ as floatPrecision,FQ as flattenUseElements,jQ as flattenPatterns,HQ as flattenMasks,WQ as flattenGradients,GQ as flattenFilters,qQ as flattenClipPaths,LQ as flattenAll,XQ as fixInvalidSVG,PQ as exportEmbeddedResources,nW as escapeXml,fJ as embedExternalDependencies,hj as detectSVG2Features,NJ as detectOutputTarget,R$ as detectInputType,UQ as detectCollisions,dj as default,CQ as decomposeTransform,F0 as createOperation,KQ as createConfig,hZ as convertTransform,zJ as convertToZ,qJ as convertToRelative,EZ as convertToPlainSVG,HJ as convertToAbsolute,PJ as convertStyleToAttrs,vZ as convertShapesToPath,VJ as convertQuadraticToSmooth,DZ as convertPathData,yZ as convertEllipseToCircle,OJ as convertCubicToSmooth,UJ as convertCubicToQuadratic,Q9 as convertColors,GJ as collapseRepeated,uZ as collapseGroups,t6 as cleanupNumericValues,MZ as cleanupListOfValues,CJ as cleanupIds,kZ as cleanupEnableBackground,XZ as cleanupAttributes,YJ as arcShorthands,ZQ as applyPreset,Jz as analyzeCompatibilityMatrix,rW as analyzeCompatibility,rZ as addClassesToSVGElement,iZ as addAttributesToSVGElement,v0 as Vector,B0 as ValidationSeverity,cz as VERSION,Y9 as Transforms3D,S7 as Transforms2D,VZ as PRECISION_LEVELS,X7 as OutputTarget,k7 as OutputFormat,W0 as Matrix,W6 as MAX_PRECISION,h0 as InputType,l$ as GeometryToPath,O as Decimal,i6 as DEFAULT_PRECISION};
|