@emasoft/svg-matrix 1.3.4 → 1.3.5
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/dist/svg-matrix.global.min.js +2 -2
- package/dist/svg-matrix.min.js +2 -2
- package/dist/svg-toolbox.global.min.js +47 -47
- package/dist/svg-toolbox.min.js +47 -47
- package/dist/svgm.min.js +61 -61
- 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/svg-matrix-lib.js +2 -2
- package/src/svg-toolbox-lib.js +2 -2
- package/src/svg-toolbox.js +23 -2
- package/src/svg-validation-data.js +1 -0
- package/src/svgm-lib.js +2 -2
package/dist/svgm.min.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/*! svg-matrix v1.3.
|
|
2
|
-
var EK=Object.create;var{getPrototypeOf:TK,defineProperty:y$,getOwnPropertyNames:lJ,getOwnPropertyDescriptor:bK}=Object,sJ=Object.prototype.hasOwnProperty;var i7=($,J,Z)=>{Z=$!=null?EK(TK($)):{};let K=J||!$||!$.__esModule?y$(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of lJ($))if(!sJ.call(K,Q))y$(K,Q,{get:()=>$[Q],enumerable:!0});return K},nJ=new WeakMap,fK=($)=>{var J=nJ.get($),Z;if(J)return J;if(J=y$({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")lJ($).map((K)=>!sJ.call(J,K)&&y$(J,K,{get:()=>$[K],enumerable:!(Z=bK($,K))||Z.enumerable}));return nJ.set($,J),J};var x7=($,J)=>{for(var Z in J)y$($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var oJ=($,J)=>()=>($&&(J=$($=0)),J);var A7=(($)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy($,{get:(J,Z)=>(typeof require!=="undefined"?require:J)[Z]}):$)(function($){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var V$={};x7(V$,{win32:()=>FJ,toNamespacedPath:()=>VW,sep:()=>wW,resolve:()=>jW,relative:()=>UW,posix:()=>H$,parse:()=>kW,normalize:()=>GW,join:()=>_W,isAbsolute:()=>FW,format:()=>XW,extname:()=>YW,dirname:()=>OW,delimiter:()=>LW,default:()=>zW,basename:()=>MW});var tH,n5,eH,$W,JW,ZW,KW=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),QW=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of $W(J))!ZW.call($,Q)&&Q!==Z&&n5($,Q,{get:()=>J[Q],enumerable:!(K=eH(J,Q))||K.enumerable});return $},qW=($,J,Z)=>(Z=$!=null?tH(JW($)):{},QW(J||!$||!$.__esModule?n5(Z,"default",{value:$,enumerable:!0}):Z,$)),HW,l5,
|
|
3
|
-
`,"\t"],Mz=["{","}","|","\\","^","`"].concat(Oz),PJ=["'"].concat(Mz),MK=["%","/","?",";","#"].concat(PJ),YK=["/","?","#"],XK=/^[+a-z0-9A-Z_-]{0,63}$/,Xz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,kz={javascript:!0,"javascript:":!0},AJ={javascript:!0,"javascript:":!0},v$={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},EJ={parse($){var J=decodeURIComponent;return($+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(Z,K,Q){var q=K.split("="),H=J(q[0]||""),W=J(q[1]||""),z=Z[H];return Z[H]=z===void 0?W:[].concat(z,W),Z},{})},stringify($){var J=encodeURIComponent;return Object.keys($||{}).reduce(function(Z,K){return[].concat($[K]).forEach(function(Q){Z.push(J(K)+"="+J(Q))}),Z},[]).join("&").replace(/\s/g,"+")}};k7.prototype.parse=function($,J,Z){if(!bJ($))throw new TypeError("Parameter 'url' must be a string, not "+typeof $);var K=$.indexOf("?"),Q=K!==-1&&K<$.indexOf("#")?"?":"#",q=$.split(Q),H=/\\/g;q[0]=q[0].replace(H,"/"),$=q.join(Q);var W=$;if(W=W.trim(),!Z&&$.split("#").length===1){var z=Vz.exec(W);if(z)return this.path=W,this.href=W,this.pathname=z[1],z[2]?(this.search=z[2],J?this.query=EJ.parse(this.search.substr(1)):this.query=this.search.substr(1)):J&&(this.search="",this.query={}),this}var j=_z.exec(W);if(j){j=j[0];var G=j.toLowerCase();this.protocol=G,W=W.substr(j.length)}if(Z||j||W.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=W.substr(0,2)==="//";F&&!(j&&AJ[j])&&(W=W.substr(2),this.slashes=!0)}if(!AJ[j]&&(F||j&&!v$[j])){for(var _=-1,U=0;U<YK.length;U++){var Y=W.indexOf(YK[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<MK.length;U++){var Y=W.indexOf(MK[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,w=k.length;U<w;U++){var R=k[U];if(!!R&&!R.match(XK)){for(var I="",P=0,
|
|
1
|
+
/*! svg-matrix v1.3.5 | MIT License | https://github.com/Emasoft/svg-matrix */
|
|
2
|
+
var EK=Object.create;var{getPrototypeOf:TK,defineProperty:y$,getOwnPropertyNames:lJ,getOwnPropertyDescriptor:bK}=Object,sJ=Object.prototype.hasOwnProperty;var i7=($,J,Z)=>{Z=$!=null?EK(TK($)):{};let K=J||!$||!$.__esModule?y$(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of lJ($))if(!sJ.call(K,Q))y$(K,Q,{get:()=>$[Q],enumerable:!0});return K},nJ=new WeakMap,fK=($)=>{var J=nJ.get($),Z;if(J)return J;if(J=y$({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")lJ($).map((K)=>!sJ.call(J,K)&&y$(J,K,{get:()=>$[K],enumerable:!(Z=bK($,K))||Z.enumerable}));return nJ.set($,J),J};var x7=($,J)=>{for(var Z in J)y$($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var oJ=($,J)=>()=>($&&(J=$($=0)),J);var A7=(($)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy($,{get:(J,Z)=>(typeof require!=="undefined"?require:J)[Z]}):$)(function($){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var V$={};x7(V$,{win32:()=>FJ,toNamespacedPath:()=>VW,sep:()=>wW,resolve:()=>jW,relative:()=>UW,posix:()=>H$,parse:()=>kW,normalize:()=>GW,join:()=>_W,isAbsolute:()=>FW,format:()=>XW,extname:()=>YW,dirname:()=>OW,delimiter:()=>LW,default:()=>zW,basename:()=>MW});var tH,n5,eH,$W,JW,ZW,KW=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),QW=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of $W(J))!ZW.call($,Q)&&Q!==Z&&n5($,Q,{get:()=>J[Q],enumerable:!(K=eH(J,Q))||K.enumerable});return $},qW=($,J,Z)=>(Z=$!=null?tH(JW($)):{},QW(J||!$||!$.__esModule?n5(Z,"default",{value:$,enumerable:!0}):Z,$)),HW,l5,c0,WW,c5=function($){return $},s5=function(){throw new Error("Not implemented")},H$,FJ,zW,jW,GW,FW,_W,UW,VW,OW,MW,YW,XW,kW,wW,LW;var O$=oJ(()=>{tH=Object.create,n5=Object.defineProperty,eH=Object.getOwnPropertyDescriptor,$W=Object.getOwnPropertyNames,JW=Object.getPrototypeOf,ZW=Object.prototype.hasOwnProperty,HW=KW(($,J)=>{function Z(H){if(typeof H!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(H))}function K(H,W){for(var z="",j=0,G=-1,F=0,_,U=0;U<=H.length;++U){if(U<H.length)_=H.charCodeAt(U);else{if(_===47)break;_=47}if(_===47){if(!(G===U-1||F===1))if(G!==U-1&&F===2){if(z.length<2||j!==2||z.charCodeAt(z.length-1)!==46||z.charCodeAt(z.length-2)!==46){if(z.length>2){var Y=z.lastIndexOf("/");if(Y!==z.length-1){Y===-1?(z="",j=0):(z=z.slice(0,Y),j=z.length-1-z.lastIndexOf("/")),G=U,F=0;continue}}else if(z.length===2||z.length===1){z="",j=0,G=U,F=0;continue}}W&&(z.length>0?z+="/..":z="..",j=2)}else z.length>0?z+="/"+H.slice(G+1,U):z=H.slice(G+1,U),j=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return z}function Q(H,W){var z=W.dir||W.root,j=W.base||(W.name||"")+(W.ext||"");return z?z===W.root?z+j:z+H+j:j}var q={resolve:function(){for(var H="",W=!1,z,j=arguments.length-1;j>=-1&&!W;j--){var G;j>=0?G=arguments[j]:(z===void 0&&(z=process.cwd()),G=z),Z(G),G.length!==0&&(H=G+"/"+H,W=G.charCodeAt(0)===47)}return H=K(H,!W),W?H.length>0?"/"+H:"/":H.length>0?H:"."},normalize:function(H){if(Z(H),H.length===0)return".";var W=H.charCodeAt(0)===47,z=H.charCodeAt(H.length-1)===47;return H=K(H,!W),H.length===0&&!W&&(H="."),H.length>0&&z&&(H+="/"),W?"/"+H:H},isAbsolute:function(H){return Z(H),H.length>0&&H.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var H,W=0;W<arguments.length;++W){var z=arguments[W];Z(z),z.length>0&&(H===void 0?H=z:H+="/"+z)}return H===void 0?".":q.normalize(H)},relative:function(H,W){if(Z(H),Z(W),H===W||(H=q.resolve(H),W=q.resolve(W),H===W))return"";for(var z=1;z<H.length&&H.charCodeAt(z)===47;++z);for(var j=H.length,G=j-z,F=1;F<W.length&&W.charCodeAt(F)===47;++F);for(var _=W.length,U=_-F,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(z+M)===47?V=M:M===0&&(V=0));break}var X=H.charCodeAt(z+M),k=W.charCodeAt(F+M);if(X!==k)break;X===47&&(V=M)}var w="";for(M=z+V+1;M<=j;++M)(M===j||H.charCodeAt(M)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+W.slice(F+V):(F+=V,W.charCodeAt(F)===47&&++F,W.slice(F))},_makeLong:function(H){return H},dirname:function(H){if(Z(H),H.length===0)return".";for(var W=H.charCodeAt(0),z=W===47,j=-1,G=!0,F=H.length-1;F>=1;--F)if(W=H.charCodeAt(F),W===47){if(!G){j=F;break}}else G=!1;return j===-1?z?"/":".":z&&j===1?"//":H.slice(0,j)},basename:function(H,W){if(W!==void 0&&typeof W!="string")throw new TypeError('"ext" argument must be a string');Z(H);var z=0,j=-1,G=!0,F;if(W!==void 0&&W.length>0&&W.length<=H.length){if(W.length===H.length&&W===H)return"";var _=W.length-1,U=-1;for(F=H.length-1;F>=0;--F){var Y=H.charCodeAt(F);if(Y===47){if(!G){z=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(Y===W.charCodeAt(_)?--_===-1&&(j=F):(_=-1,j=U))}return z===j?j=U:j===-1&&(j=H.length),H.slice(z,j)}else{for(F=H.length-1;F>=0;--F)if(H.charCodeAt(F)===47){if(!G){z=F+1;break}}else j===-1&&(G=!1,j=F+1);return j===-1?"":H.slice(z,j)}},extname:function(H){Z(H);for(var W=-1,z=0,j=-1,G=!0,F=0,_=H.length-1;_>=0;--_){var U=H.charCodeAt(_);if(U===47){if(!G){z=_+1;break}continue}j===-1&&(G=!1,j=_+1),U===46?W===-1?W=_:F!==1&&(F=1):W!==-1&&(F=-1)}return W===-1||j===-1||F===0||F===1&&W===j-1&&W===z+1?"":H.slice(W,j)},format:function(H){if(H===null||typeof H!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof H);return Q("/",H)},parse:function(H){Z(H);var W={root:"",dir:"",base:"",ext:"",name:""};if(H.length===0)return W;var z=H.charCodeAt(0),j=z===47,G;j?(W.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,Y=!0,V=H.length-1,M=0;V>=G;--V){if(z=H.charCodeAt(V),z===47){if(!Y){_=V+1;break}continue}U===-1&&(Y=!1,U=V+1),z===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&&j?W.base=W.name=H.slice(1,U):W.base=W.name=H.slice(_,U)):(_===0&&j?(W.name=H.slice(1,F),W.base=H.slice(1,U)):(W.name=H.slice(_,F),W.base=H.slice(_,U)),W.ext=H.slice(F,U)),_>0?W.dir=H.slice(0,_-1):j&&(W.dir="/"),W},sep:"/",delimiter:":",win32:null,posix:null};q.posix=q,J.exports=q}),l5=qW(HW()),c0=l5,WW=l5;c0.parse??=s5;WW.parse??=s5;H$={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:c5,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:c5},FJ={sep:"\\",delimiter:";",win32:void 0,...H$,posix:H$};H$.win32=FJ.win32=FJ;H$.posix=H$;zW=H$,{resolve:jW,normalize:GW,isAbsolute:FW,join:_W,relative:UW,toNamespacedPath:VW,dirname:OW,basename:MW,extname:YW,format:XW,parse:kW,sep:wW,delimiter:LW}=H$});var NK={};x7(NK,{resolveObject:()=>BK,resolve:()=>RK,parse:()=>D$,format:()=>LK,default:()=>wz,Url:()=>k7,URLSearchParams:()=>kK,URL:()=>TJ});function bJ($){return typeof $=="string"}function wK($){return typeof $=="object"&&$!==null}function K9($){return $===null}function Fz($){return $==null}function k7(){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 D$($,J,Z){if($&&wK($)&&$ instanceof k7)return $;var K=new k7;return K.parse($,J,Z),K}function LK($){return bJ($)&&($=D$($)),$ instanceof k7?$.format():k7.prototype.format.call($)}function RK($,J){return D$($,!1,!0).resolve(J)}function BK($,J){return $?D$($,!1,!0).resolveObject(J):J}var TJ,kK,_z,Uz,Vz,Oz,Mz,PJ,MK,YK,Yz=255,XK,Xz,kz,AJ,v$,EJ,wz;var IK=oJ(()=>{({URL:TJ,URLSearchParams:kK}=globalThis);_z=/^([a-z0-9.+-]+:)/i,Uz=/:[0-9]*$/,Vz=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Oz=["<",">",'"',"`"," ","\r",`
|
|
3
|
+
`,"\t"],Mz=["{","}","|","\\","^","`"].concat(Oz),PJ=["'"].concat(Mz),MK=["%","/","?",";","#"].concat(PJ),YK=["/","?","#"],XK=/^[+a-z0-9A-Z_-]{0,63}$/,Xz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,kz={javascript:!0,"javascript:":!0},AJ={javascript:!0,"javascript:":!0},v$={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},EJ={parse($){var J=decodeURIComponent;return($+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(Z,K,Q){var q=K.split("="),H=J(q[0]||""),W=J(q[1]||""),z=Z[H];return Z[H]=z===void 0?W:[].concat(z,W),Z},{})},stringify($){var J=encodeURIComponent;return Object.keys($||{}).reduce(function(Z,K){return[].concat($[K]).forEach(function(Q){Z.push(J(K)+"="+J(Q))}),Z},[]).join("&").replace(/\s/g,"+")}};k7.prototype.parse=function($,J,Z){if(!bJ($))throw new TypeError("Parameter 'url' must be a string, not "+typeof $);var K=$.indexOf("?"),Q=K!==-1&&K<$.indexOf("#")?"?":"#",q=$.split(Q),H=/\\/g;q[0]=q[0].replace(H,"/"),$=q.join(Q);var W=$;if(W=W.trim(),!Z&&$.split("#").length===1){var z=Vz.exec(W);if(z)return this.path=W,this.href=W,this.pathname=z[1],z[2]?(this.search=z[2],J?this.query=EJ.parse(this.search.substr(1)):this.query=this.search.substr(1)):J&&(this.search="",this.query={}),this}var j=_z.exec(W);if(j){j=j[0];var G=j.toLowerCase();this.protocol=G,W=W.substr(j.length)}if(Z||j||W.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=W.substr(0,2)==="//";F&&!(j&&AJ[j])&&(W=W.substr(2),this.slashes=!0)}if(!AJ[j]&&(F||j&&!v$[j])){for(var _=-1,U=0;U<YK.length;U++){var Y=W.indexOf(YK[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<MK.length;U++){var Y=W.indexOf(MK[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,w=k.length;U<w;U++){var R=k[U];if(!!R&&!R.match(XK)){for(var I="",P=0,y=R.length;P<y;P++)R.charCodeAt(P)>127?I+="x":I+=R[P];if(!I.match(XK)){var g=k.slice(0,U),b=k.slice(U+1),x=R.match(Xz);x&&(g.push(x[1]),b.unshift(x[2])),b.length&&(W="/"+b.join(".")+W),this.hostname=g.join(".");break}}}this.hostname.length>Yz?this.hostname="":this.hostname=this.hostname.toLowerCase(),X||(this.hostname=new TJ(`https://${this.hostname}`).hostname);var D=this.port?":"+this.port:"",E=this.hostname||"";this.host=E+D,this.href+=this.host,X&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),W[0]!=="/"&&(W="/"+W))}if(!kz[G])for(var U=0,w=PJ.length;U<w;U++){var m=PJ[U];if(W.indexOf(m)!==-1){var c=encodeURIComponent(m);c===m&&(c=escape(m)),W=W.split(m).join(c)}}var d=W.indexOf("#");d!==-1&&(this.hash=W.substr(d),W=W.slice(0,d));var N=W.indexOf("?");if(N!==-1?(this.search=W.substr(N),this.query=W.substr(N+1),J&&(this.query=EJ.parse(this.query)),W=W.slice(0,N)):J&&(this.search="",this.query={}),W&&(this.pathname=W),v$[G]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var D=this.pathname||"",u=this.search||"";this.path=D+u}return this.href=this.format(),this};k7.prototype.format=function(){var $=this.auth||"";$&&($=encodeURIComponent($),$=$.replace(/%3A/i,":"),$+="@");var J=this.protocol||"",Z=this.pathname||"",K=this.hash||"",Q=!1,q="";this.host?Q=$+this.host:this.hostname&&(Q=$+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Q+=":"+this.port)),this.query&&wK(this.query)&&Object.keys(this.query).length&&(q=EJ.stringify(this.query));var H=this.search||q&&"?"+q||"";return J&&J.substr(-1)!==":"&&(J+=":"),this.slashes||(!J||v$[J])&&Q!==!1?(Q="//"+(Q||""),Z&&Z.charAt(0)!=="/"&&(Z="/"+Z)):Q||(Q=""),K&&K.charAt(0)!=="#"&&(K="#"+K),H&&H.charAt(0)!=="?"&&(H="?"+H),Z=Z.replace(/[?#]/g,function(W){return encodeURIComponent(W)}),H=H.replace("#","%23"),J+Q+Z+H+K};k7.prototype.resolve=function($){return this.resolveObject(D$($,!1,!0)).format()};k7.prototype.resolveObject=function($){if(bJ($)){var J=new k7;J.parse($,!1,!0),$=J}for(var Z=new k7,K=Object.keys(this),Q=0;Q<K.length;Q++){var q=K[Q];Z[q]=this[q]}if(Z.hash=$.hash,$.href==="")return Z.href=Z.format(),Z;if($.slashes&&!$.protocol){for(var H=Object.keys($),W=0;W<H.length;W++){var z=H[W];z!=="protocol"&&(Z[z]=$[z])}return v$[Z.protocol]&&Z.hostname&&!Z.pathname&&(Z.path=Z.pathname="/"),Z.href=Z.format(),Z}if($.protocol&&$.protocol!==Z.protocol){if(!v$[$.protocol]){for(var j=Object.keys($),G=0;G<j.length;G++){var F=j[G];Z[F]=$[F]}return Z.href=Z.format(),Z}if(Z.protocol=$.protocol,!$.host&&!AJ[$.protocol]){for(var w=($.pathname||"").split("/");w.length&&!($.host=w.shift()););$.host||($.host=""),$.hostname||($.hostname=""),w[0]!==""&&w.unshift(""),w.length<2&&w.unshift(""),Z.pathname=w.join("/")}else Z.pathname=$.pathname;if(Z.search=$.search,Z.query=$.query,Z.host=$.host||"",Z.auth=$.auth,Z.hostname=$.hostname||$.host,Z.port=$.port,Z.pathname||Z.search){var _=Z.pathname||"",U=Z.search||"";Z.path=_+U}return Z.slashes=Z.slashes||$.slashes,Z.href=Z.format(),Z}var 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("/")||[],w=$.pathname&&$.pathname.split("/")||[],R=Z.protocol&&!v$[Z.protocol];if(R&&(Z.hostname="",Z.port=null,Z.host&&(k[0]===""?k[0]=Z.host:k.unshift(Z.host)),Z.host="",$.protocol&&($.hostname=null,$.port=null,$.host&&(w[0]===""?w[0]=$.host:w.unshift($.host)),$.host=null),M=M&&(w[0]===""||k[0]==="")),V)Z.host=$.host||$.host===""?$.host:Z.host,Z.hostname=$.hostname||$.hostname===""?$.hostname:Z.hostname,Z.search=$.search,Z.query=$.query,k=w;else if(w.length)k||(k=[]),k.pop(),k=k.concat(w),Z.search=$.search,Z.query=$.query;else if(!Fz($.search)){if(R){Z.hostname=Z.host=k.shift();var I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return Z.search=$.search,Z.query=$.query,(!K9(Z.pathname)||!K9(Z.search))&&(Z.path=(Z.pathname?Z.pathname:"")+(Z.search?Z.search:"")),Z.href=Z.format(),Z}if(!k.length)return Z.pathname=null,Z.search?Z.path="/"+Z.search:Z.path=null,Z.href=Z.format(),Z;for(var P=k.slice(-1)[0],y=(Z.host||$.host||k.length>1)&&(P==="."||P==="..")||P==="",g=0,b=k.length;b>=0;b--)P=k[b],P==="."?k.splice(b,1):P===".."?(k.splice(b,1),g++):g&&(k.splice(b,1),g--);if(!M&&!X)for(;g--;g)k.unshift("..");M&&k[0]!==""&&(!k[0]||k[0].charAt(0)!=="/")&&k.unshift(""),y&&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 I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return M=M||Z.host&&k.length,M&&!x&&k.unshift(""),k.length?Z.pathname=k.join("/"):(Z.pathname=null,Z.path=null),(!K9(Z.pathname)||!K9(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};k7.prototype.parseHost=function(){var $=this.host,J=Uz.exec($);J&&(J=J[0],J!==":"&&(this.port=J.substr(1)),$=$.substr(0,$.length-J.length)),$&&(this.hostname=$)};wz={parse:D$,resolve:RK,resolveObject:BK,format:LK,Url:k7,URL:TJ,URLSearchParams:kK}});/*!
|
|
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?"":`
|
|
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,A0=!0,O6="[DecimalError] ",t7=O6+"Invalid argument: ",eJ=O6+"Precision limit exceeded",$8=O6+"crypto unavailable",J8="[object Decimal]",$7=Math.floor,l0=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 M0($)};K0.ceil=function(){return M0(new this.constructor(this),this.e+1,2)};K0.clampedTo=K0.clamp=function($,J){var Z,K=this,Q=K.constructor;if($=new Q($),J=new Q(J),!$.s||!J.s)return new Q(NaN);if($.gt(J))throw Error(t7+J);return Z=K.cmp($),Z<0?$:K.cmp(J)>0?J:new Q(K)};K0.comparedTo=K0.cmp=function($){var J,Z,K,Q,q=this,H=q.d,W=($=new q.constructor($)).d,z=q.s,j=$.s;if(!H||!W)return!z||!j?NaN:z!==j?z:H===W?0:!H^z<0?1:-1;if(!H[0]||!W[0])return H[0]?z:W[0]?-j:0;if(z!==j)return z;if(q.e!==$.e)return q.e>$.e^z<0?1:-1;K=H.length,Q=W.length;for(J=0,Z=K<Q?K:Q;J<Z;++J)if(H[J]!==W[J])return H[J]>W[J]^z<0?1:-1;return K===Q?0:K>Q^z<0?1:-1};K0.cosine=K0.cos=function(){var $,J,Z=this,K=Z.constructor;if(!Z.d)return new K(NaN);if(!Z.d[0])return new K(1);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+R0,K.rounding=1,Z=uK(K,W8(K,Z)),K.precision=$,K.rounding=J,M0(m7==2||m7==3?Z.neg():Z,$,J,!0)};K0.cubeRoot=K0.cbrt=function(){var $,J,Z,K,Q,q,H,W,z,j,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(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)+$;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=D0(j.plus(G).times(W),j.plus(z),H+2,1),t0(W.d).slice(0,H)===(Z=t0(K.d)).slice(0,H))if(Z=Z.slice(H-3,H+1),Z=="9999"||!Q&&Z=="4999"){if(!Q){if(M0(W,$+1,0),W.times(W).times(W).eq(G)){K=W;break}}H+=4,Q=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")M0(K,$+1,1),J=!K.times(K).times(K).eq(G);break}return A0=!0,M0(K,$,F.rounding,J)};K0.decimalPlaces=K0.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};K0.dividedBy=K0.div=function($){return D0(this,new this.constructor($))};K0.dividedToIntegerBy=K0.divToInt=function($){var J=this,Z=J.constructor;return M0(D0(J,new Z($),0,1,1),Z.precision,Z.rounding)};K0.equals=K0.eq=function($){return this.cmp($)===0};K0.floor=function(){return M0(new this.constructor(this),this.e+1,3)};K0.greaterThan=K0.gt=function($){return this.cmp($)>0};K0.greaterThanOrEqualTo=K0.gte=function($){var J=this.cmp($);return J==1||J===0};K0.hyperbolicCosine=K0.cosh=function(){var $,J,Z,K,Q,q=this,H=q.constructor,W=new H(1);if(!q.isFinite())return new H(q.s?1/0:NaN);if(q.isZero())return W;if(Z=H.precision,K=H.rounding,H.precision=Z+Math.max(q.e,q.sd())+4,H.rounding=1,Q=q.d.length,Q<32)$=Math.ceil(Q/3),J=(1/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 M0(q,H.precision=Z,H.rounding=K,!0)};K0.hyperbolicSine=K0.sinh=function(){var $,J,Z,K,Q=this,q=Q.constructor;if(!Q.isFinite()||Q.isZero())return new q(Q);if(J=q.precision,Z=q.rounding,q.precision=J+Math.max(Q.e,Q.sd())+4,q.rounding=1,K=Q.d.length,K<3)Q=B$(q,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/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,M0(Q,J,Z,!0)};K0.hyperbolicTangent=K0.tanh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(Z.s);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+7,K.rounding=1,D0(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,A0=!1,Z=Z.times(Z).minus(1).sqrt().plus(Z),A0=!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,A0=!1,Z=Z.times(Z).plus(1).sqrt().plus(Z),A0=!0,K.precision=$,K.rounding=J,Z.ln()};K0.inverseHyperbolicTangent=K0.atanh=function(){var $,J,Z,K,Q=this,q=Q.constructor;if(!Q.isFinite())return new q(NaN);if(Q.e>=0)return new q(Q.abs().eq(1)?Q.s/0:Q.isZero()?Q:NaN);if($=q.precision,J=q.rounding,K=Q.sd(),Math.max(K,$)<2*-Q.e-1)return M0(new q(Q),$,J,!0);return q.precision=Z=K-Q.e,Q=D0(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));A0=!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 A0=!0,M0(H,G.precision=F,G.rounding=_,!0)};K0.isFinite=function(){return!!this.d};K0.isInteger=K0.isInt=function(){return!!this.d&&$7(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(A0=!1,W=F+U,H=a7(j,W),K=J?V6(G,W+10):a7($,W),z=D0(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=D0(H,K,W,1),!q){if(+t0(z.d).slice(Q+1,Q+15)+1==100000000000000)z=M0(z,F+1,0);break}while(u$(z.d,Q+=10,_));return A0=!0,M0(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 A0?M0($,W,z):$}if(Z=$7($.e/R0),G=$7(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),A0?M0($,W,z):$};K0.modulo=K0.mod=function($){var J,Z=this,K=Z.constructor;if($=new K($),!Z.d||!$.s||$.d&&!$.d[0])return new K(NaN);if(!$.d||Z.d&&!Z.d[0])return M0(new K(Z),K.precision,K.rounding);if(A0=!1,K.modulo==9)J=D0(Z,$.abs(),0,3,1),J.s*=$.s;else J=D0(Z,$,0,K.modulo,1);return J=J.times($),A0=!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,M0($)};K0.plus=K0.add=function($){var J,Z,K,Q,q,H,W,z,j,G,F=this,_=F.constructor;if($=new _($),!F.d||!$.d){if(!F.s||!$.s)$=new _(NaN);else if(!F.d)$=new _($.d||F.s===$.s?F:NaN);return $}if(F.s!=$.s)return $.s=-$.s,F.minus($);if(j=F.d,G=$.d,W=_.precision,z=_.rounding,!j[0]||!G[0]){if(!G[0])$=new _(F);return A0?M0($,W,z):$}if(q=$7(F.e/R0),K=$7($.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),A0?M0($,W,z):$};K0.precision=K0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(t7+$);if(Z.d){if(J=K8(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};K0.round=function(){var $=this,J=$.constructor;return M0(new J($),$.e+1,J.rounding)};K0.sine=K0.sin=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+R0,K.rounding=1,Z=xK(K,W8(K,Z)),K.precision=$,K.rounding=J,M0(m7>2?Z.neg():Z,$,J,!0)};K0.squareRoot=K0.sqrt=function(){var $,J,Z,K,Q,q,H=this,W=H.d,z=H.e,j=H.s,G=H.constructor;if(j!==1||!W||!W[0])return new G(!j||j<0&&(!W||W[0])?NaN:W?H:1/0);if(A0=!1,j=Math.sqrt(+H),j==0||j==1/0){if(J=t0(W),(J.length+z)%2==0)J+="0";if(j=Math.sqrt(J),z=$7((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(D0(H,q,Z+2,1)).times(0.5),t0(q.d).slice(0,Z)===(J=t0(K.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!Q&&J=="4999"){if(!Q){if(M0(q,z+1,0),q.times(q).eq(H)){K=q;break}}Z+=4,Q=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")M0(K,z+1,1),$=!K.times(K).eq(H);break}return A0=!0,M0(K,z,G.rounding,$)};K0.tangent=K0.tan=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+10,K.rounding=1,Z=Z.sin(),Z.s=1,Z=D0(Z,new K(1).minus(Z.times(Z)).sqrt(),$+10,0),K.precision=$,K.rounding=J,M0(m7==2||m7==4?Z.neg():Z,$,J,!0)};K0.times=K0.mul=function($){var J,Z,K,Q,q,H,W,z,j,G=this,F=G.constructor,_=G.d,U=($=new F($)).d;if($.s*=G.s,!_||!_[0]||!U||!U[0])return new F(!$.s||_&&!_[0]&&!U||U&&!U[0]&&!_?NaN:!_||!U?$.s/0:$.s*0);if(Z=$7(G.e/R0)+$7($.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),A0?M0($,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(H7($,0,e7),J===void 0)J=K.rounding;else H7(J,0,8);return M0(Z,$+Z.e+1,J)};K0.toExponential=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=T7(K,!0);else{if(H7($,0,e7),J===void 0)J=Q.rounding;else H7(J,0,8);K=M0(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(H7($,0,e7),J===void 0)J=q.rounding;else H7(J,0,8);K=M0(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]=l0(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}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),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=D0($.minus(Z),K,0,1,1),z=z.plus(Q.times(j)),Z=Z.plus(Q.times(K)),z.s=j.s=U.s,_=D0(j,K,q,1).minus(U).abs().cmp(D0(z,Z,q,1).minus(U).abs())<1?[j,K]:[z,Z],V.precision=G,A0=!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 H7(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};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(l0(+W,j));if(W=new z(W),W.eq(1))return W;if(K=z.precision,q=z.rounding,$.eq(1))return M0(W,K,q);if(J=$7($.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):M0(Q,K,q);if(H=W.s,H<0){if(J<$.d.length-1)return new z(NaN);if(($.d[J]&1)==0)H=1;if(W.e==0&&W.d[0]==1&&W.d.length==1)return W.s=H,W}if(Z=l0(+W,j),J=Z==0||!isFinite(Z)?$7(j*(Math.log("0."+t0(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(A0=!1,z.rounding=W.s=1,Z=Math.min(12,(J+"").length),Q=j9($.times(a7(W,K+Z)),K),Q.d){if(Q=M0(Q,K+5,1),u$(Q.d,K,q)){if(J=K+10,Q=M0(j9($.times(a7(W,J+Z)),J),J+5,1),+t0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=M0(Q,K+1,0)}}return Q.s=H,A0=!0,z.rounding=q,M0(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(H7($,1,e7),J===void 0)J=Q.rounding;else H7(J,0,8);K=M0(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(H7($,1,e7),J===void 0)J=K.rounding;else H7(J,0,8);return M0(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 M0(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 t0($){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 H7($,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=l0(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)==l0(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)==l0(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 D0=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,y,g,b,x,D,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=$7(K.e/U)-$7(Q.e/U);D=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,D==1){_=0,N=N[0],P++;for(;(F<b||_)&&P--;F++)y=_*z+(d[F]||0),k[F]=y/N|0,_=y%N|0;Y=_||F<b}else{if(_=z/(N[0]+1)|0,_>1)N=$(N,_,z),d=$(d,_,z),D=N.length,b=d.length;g=D,w=d.slice(0,D),R=w.length;for(;R<D;)w[R++]=0;if(E=N.slice(),E.unshift(0),x=N[0],N[1]>=z/2)++x;do{if(_=0,j=J(N,w,D,R),j<0){if(I=w[0],D!=R)I=I*z+(w[1]||0);if(_=I/x|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,D<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,D,R),j<1)_++,Z(w,D<R?E:N,R,z)}R=w.length}else if(j===0)_++,w=[0];if(k[F++]=_,j&&w[0])w[R++]=d[g]||0;else w=[d[g]],R=1}while((g++<b||w[0]!==void 0)&&P--);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,M0(X,W?q+X.e+1:q,H,Y)}return X}}();function M0($,J,Z,K){var Q,q,H,W,z,j,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(Q=1,W=F[0];W>=10;W/=10)Q++;if(q=J-Q,q<0)q+=R0,H=J,G=F[_=0],z=G/l0(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/l0(10,Q-H-1)%10|0}if(K=K||J<0||F[_+1]!==void 0||(H<0?G:G%l0(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/l0(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]=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,Q-H)%l0(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(A0){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=t0($.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(A0=!0,Z)$.precision=Z;throw Error(eJ)}return M0(new $(_6),J,1,!0)}function E7($,J,Z){if(J>z9)throw Error(eJ);return M0(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);A0=!1;for(;;){if(Z%2){if(q=q.times(J),rJ(q.d,H))Q=!0}if(Z=$7(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 A0=!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)A0=!1,z=Y;else z=J;W=new _(0.03125);while($.e>-2)$=$.times(W),F+=5;K=Math.log(l0(2,F))/Math.LN10*2+5|0,z+=K,Z=q=H=new _(1),_.precision=z;for(;;){if(q=M0(q.times($),z,1),Z=Z.times(++G),W=H.plus(D0(q,Z,z,1)),t0(W.d).slice(0,z)===t0(H.d).slice(0,z)){Q=F;while(Q--)H=M0(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 M0(H,_.precision=Y,U,A0=!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)A0=!1,G=w;else G=J;if(X.precision=G+=Y,Z=t0(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=t0(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?M0(V,w,k,A0=!0):V;F=V,z=H=V=D0(V.minus(1),V.plus(1),G,1),_=M0(V.times(V),G,1),Q=3;for(;;){if(H=M0(H.times(_),G,1),j=z.plus(D0(H,new X(Q),G,1)),t0(j.d).slice(0,G)===t0(z.d).slice(0,G)){if(z=z.times(2),q!==0)z=z.plus(V6(X,G+2,w).times(q+""));if(z=D0(z,new X(U),G,1),J==null)if(u$(z.d,G-Y,k,W))X.precision=G+=Y,j=H=V=D0(F.minus(1),F.plus(1),G,1),_=M0(V.times(V),G,1),Q=W=1;else return M0(z,X.precision=w,k,A0=!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),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 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,A0=!1,H)$=D0($,Q,W*4);if(z)$=$.times(Math.abs(z)<54?l0(2,z):g$.pow(2,z));return A0=!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);A0=!1,z=Z.times(Z),W=new $(K);for(;;){if(H=D0(W.times(z),new $(J++*J++),G,1),W=Q?K.plus(H):K.minus(H),K=D0(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 A0=!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(H7(Z,1,e7),K===void 0)K=U.rounding;else H7(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,$=D0($,_,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(D0($,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(D0($,J,q,1));return Z}function rK($){return new this($).cbrt()}function aK($){return M0($=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($7(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,A0)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(A0)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 M0($=new this($),$.e+1,3)}function qQ(){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 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 H7($,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=l0(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 M0($=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[$]);A0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return A0=!0,M0(Z,this.precision,this.rounding)}function BQ($){return new this($).tan()}function NQ($){return new this($).tanh()}function IQ($){return M0($=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 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 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 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=F9($)}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,K)=>J.plus(Z.mul($.data[K])),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},(Q,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,K]=this.data,[Q,q,H]=$.data;return new v0([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 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(),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 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,z)=>new O(z===J?1:0)),K=new v0(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 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=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 H0{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 H0($)}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 H0(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 H0(J)}clone(){return new H0(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 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 v0(Z)}add($){if($ instanceof H0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new H0(this.data.map((J,Z)=>J.map((K,Q)=>K.plus($.data[Z][Q]))))}else{let J=N$($);return new H0(this.data.map((Z)=>Z.map((K)=>K.plus(J))))}}sub($){if($ instanceof H0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new H0(this.data.map((J,Z)=>J.map((K,Q)=>K.minus($.data[Z][Q]))))}else{let J=N$($);return new H0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof H0){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 H0(J)}else{let J=N$($);return new H0(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 H0(this.data.map((Z)=>Z.map((K)=>K.div(J))))}negate(){return new H0(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 H0($)}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 H0))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=H0.zeros($,$);for(let H=0;H<$;H++)q.data[H][Z[H]]=new O(1);return{L:new H0(K),U:new H0(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 H0(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 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 v0(Q)}qr(){let $=this.rows,J=this.cols,Z=this.data.map((q)=>q.map((H)=>new O(H))),K=H0.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 H0(K).transpose(),R:new H0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=H0.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:()=>s0,stretchAlongAxis:()=>CQ,skew:()=>X6,scale:()=>U7,rotateAroundPoint:()=>_9,rotate:()=>j$,reflectY:()=>AQ,reflectX:()=>PQ,reflectOrigin:()=>EQ,applyTransform:()=>n0});var W7=($)=>{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"),H0.from([[new O(1),new O(0),W7($)],[new O(0),new O(1),W7(J)],[new O(0),new O(0),new O(1)]])}function U7($,J=null){if(Z7($,"sx"),J!==null)Z7(J,"sy");let Z=J===null?$:J,K=W7($),Q=W7(Z);if(K.isZero()||Q.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return H0.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$($){Z7($,"theta");let Z=W7($).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 H0.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){Z7($,"theta"),Z7(J,"px"),Z7(Z,"py");let K=W7(J),Q=W7(Z);return s0(K,Q).mul(j$($)).mul(s0(K.negated(),Q.negated()))}function X6($,J){Z7($,"ax"),Z7(J,"ay");let Z=W7($),K=W7(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 H0.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){Z7($,"ux"),Z7(J,"uy"),Z7(Z,"k");let K=W7($),Q=W7(J),q=W7(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 H0.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 K=H0.from([[W7(J)],[W7(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 H0.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 H0.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 H0.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 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 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 m0($,"tx"),m0(J,"ty"),m0(Z,"tz"),H0.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 TQ($,J=null,Z=null){if(m0($,"sx"),J!==null)m0(J,"sy");if(Z!==null)m0(Z,"sz");let K=J===null?$:J,Q=Z===null?$:Z,q=o0($),H=o0(K),W=o0(Q);return H0.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($){m0($,"theta");let J=o0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return H0.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($){m0($,"theta");let J=o0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return H0.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($){m0($,"theta");let J=o0($),Z=k6(J),K=new O(Math.cos(Z)),Q=new O(Math.sin(Z));return H0.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){m0($,"ux"),m0(J,"uy"),m0(Z,"uz"),m0(K,"theta");let Q=[o0($),o0(J),o0(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=o0(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 H0.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){m0($,"ux"),m0(J,"uy"),m0(Z,"uz"),m0(K,"theta"),m0(Q,"px"),m0(q,"py"),m0(H,"pz");let W=o0(Q),z=o0(q),j=o0(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 H0))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(K,"z");let Q=H0.from([[o0(J)],[o0(Z)],[o0(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 H0.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 H0.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 H0.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 H0.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:()=>E0,PRECISION_LEVELS:()=>KZ,OutputTarget:()=>Y7,OutputFormat:()=>X7,MAX_PRECISION:()=>q6,InputType:()=>h0,DEFAULT_PRECISION:()=>s6});O.set({precision:80});var dz=new O("1e-40"),pz=new O("1e-10");O.set({precision:80});var g0=($)=>$ 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 H0.from([[1,0,g0($)],[0,1,g0(J)],[0,0,1]])}function cQ($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=g0($),Z=O.cos(J),K=O.sin(J);return H0.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 H0.from([[g0($),0,0],[0,g0(J),0],[0,0,1]])}function lQ($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=O.tan(g0($));return H0.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(g0($));return H0.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:g0(0),scaleX:g0(0),scaleY:g0(0),skewX:g0(0),skewY:g0(0),verified:!1,maxError:g0("Infinity"),singular:!0};let j=W.div(z);if(j.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))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=g0(0);else V=O.atan(I)}else V=g0(0);let X=g0(0),k=rQ({translateX:q,translateY:H,rotation:G,scaleX:z,scaleY:j,skewX:V,skewY:g0(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=g0(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($),d0=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 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 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 z7($,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(d0))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=z7($,Z),Q=z7(J,Z);return p0(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=z7($[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=z7($[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 p0(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=p0(K,Z),q=m$(Z),H=V7(Q);if(H.lessThan(d0)){if(V7(Z).lessThan(d0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:q}}let W=$$(Q,q,Q);if(V7(W).lessThan(d0)){let z=z7(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=p0(K,Z),H=p0(Q,Z),W=m$(Z),z=V7(q),j=V7(H);if(z.lessThan(d0))return{contains:!1,newDirection:$$(H,W,H),newSimplex:[Z,Q]};if(j.lessThan(d0))return{contains:!1,newDirection:$$(q,W,q),newSimplex:[Z,K]};let G=$$(H,q,q),F=$$(q,H,H);if(V7(G).lessThan(d0)&&V7(F).lessThan(d0)){let _=p0(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(z7(G,W).greaterThan(d0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(z7(F,W).greaterThan(d0))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$(p0($[0],J[0])).lessThan(d0),iterations:1,simplex:[],verified:!0}}let Z=p0(w6(J),w6($));if(V7(Z).lessThan(d0))Z=f7(1,0);let K=[U8($,J,Z)];if(Z=m$(K[0]),V7(K[0]).lessThan(d0))return{intersects:!0,iterations:1,simplex:K,verified:O9($,J)};for(let Q=0;Q<F8;Q++){let q=U8($,J,Z);if(z7(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(d0))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=p0(q,Q),W=p0($,Q),z=x$(H,W);if(z.abs().lessThan(d0))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=p0(J,$),q=p0(K,Z),H=x$(Q,q);if(H.abs().lessThan(d0)){let G=p0(Z,$);if(x$(Q,G).abs().lessThan(d0)){let F=z7(Q,Q);if(F.lessThan(d0)){let X=z7(q,q);if(X.lessThan(d0))return G$(G).lessThan(d0);let k=z7(G,q).div(X);return k.greaterThanOrEqualTo(0)&&k.lessThanOrEqualTo(1)}let _=z7(G,Q).div(F),U=p0(K,$),Y=z7(U,Q).div(F),V=O.min(_,Y);return O.max(_,Y).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let W=p0(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$(p0($[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$(p0($[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$(p0(J[z],_));if(U.lessThan(K))K=U,Q=_,q=J[z]}}let W=G$(p0(Q,q)).minus(K).abs().lessThan(d0);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=p0(Z,J),Q=p0($,J),q=V7(K);if(q.lessThan(d0))return J;let H=z7(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 z0=($)=>$ 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=z0(J[0]),K=z0(J[1]),Q=z0(J[2]),q=z0(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=z0($),q=z0(J),H=z0(Z),W=z0(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=z0(G).div(z),_=z0(1).minus(F),U=F.mul(F),Y=U.mul(F),V=_.mul(_),M=V.mul(_),X=M.mul($).plus(z0(3).mul(V).mul(F).mul(Z)).plus(z0(3).mul(_).mul(U).mul(Q)).plus(Y.mul(H)),k=M.mul(J).plus(z0(3).mul(V).mul(F).mul(K)).plus(z0(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=z0(z).div(H),G=z0(1).minus(j),F=G.mul(G),_=j.mul(j),U=F.mul($).plus(z0(2).mul(G).mul(j).mul(Z)).plus(_.mul(Q)),Y=F.mul(J).plus(z0(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=z0(1/0),Z=z0(1/0),K=z0(-1/0),Q=z0(-1/0),q=z0(0),H=z0(0),W=z0(0),z=z0(0),j=z0(0),G=z0(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(z0(V.x)):z0(V.x),w=X?H.plus(z0(V.y)):z0(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(z0(V.x)):z0(V.x),w=X?H.plus(z0(V.y)):z0(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(z0(V.x)):z0(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(z0(V.y)):z0(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(z0(V.x1)):z0(V.x1),w=X?H.plus(z0(V.y1)):z0(V.y1),R=X?q.plus(z0(V.x2)):z0(V.x2),I=X?H.plus(z0(V.y2)):z0(V.y2),P=X?q.plus(z0(V.x)):z0(V.x),y=X?H.plus(z0(V.y)):z0(V.y),g=X8(q,H,k,w,R,I,P,y,20);for(let b of g)J=O.min(J,b.x),Z=O.min(Z,b.y),K=O.max(K,b.x),Q=O.max(Q,b.y),_.push(b);j=R,G=I,q=P,H=y,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(z0(V.x2)):z0(V.x2),w=X?H.plus(z0(V.y2)):z0(V.y2),R=X?q.plus(z0(V.x)):z0(V.x),I=X?H.plus(z0(V.y)):z0(V.y),P,y;if(F==="C"||F==="S")P=q.mul(2).minus(j),y=H.mul(2).minus(G);else P=q,y=H;let g=X8(q,H,P,y,k,w,R,I,20);for(let b of g)J=O.min(J,b.x),Z=O.min(Z,b.y),K=O.max(K,b.x),Q=O.max(Q,b.y),_.push(b);j=k,G=w,q=R,H=I,F="S"}break;case"Q":{if(V.x1==null||V.y1==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: Q command requires x1, y1, x, y properties");let k=X?q.plus(z0(V.x1)):z0(V.x1),w=X?H.plus(z0(V.y1)):z0(V.y1),R=X?q.plus(z0(V.x)):z0(V.x),I=X?H.plus(z0(V.y)):z0(V.y),P=k8(q,H,k,w,R,I,20);for(let y of P)J=O.min(J,y.x),Z=O.min(Z,y.y),K=O.max(K,y.x),Q=O.max(Q,y.y),_.push(y);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(z0(V.x)):z0(V.x),w=X?H.plus(z0(V.y)):z0(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 y of P)J=O.min(J,y.x),Z=O.min(Z,y.y),K=O.max(K,y.x),Q=O.max(Q,y.y),_.push(y);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(z0(V.x)):z0(V.x),w=X?H.plus(z0(V.y)):z0(V.y),R=z0(V.rx).abs(),I=z0(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 y=0;y<=P;y++){let g=z0(y).div(P),b=q.plus(k.minus(q).mul(g)),x=H.plus(w.minus(H).mul(g));_.push({x:b,y:x})}}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 K7={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:K7.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:K7.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:K7.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:K7.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?K7.PSEUDO_ELEMENT:K7.PSEUDO_CLASS,value:q})}else if(K==="*"){let Q=Z+1;if(Q<$.length&&$[Q]==="|"){if(Q++,Q<$.length&&$[Q]==="*")Q++}J.push({type:K7.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:K7.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 K7.ID:Z++;break;case K7.CLASS:case K7.ATTRIBUTE:K++;break;case K7.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 K7.TYPE:case K7.PSEUDO_ELEMENT:Q++;break;case K7.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 S0=($)=>$ 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=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),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=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(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=S0($),z=S0(J),j=S0(Z),G=S0(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),y=O.sin(w),g=W.plus(j.mul(R)),b=z.plus(G.mul(I)),x=W.plus(j.mul(P)),D=z.plus(G.mul(y)),E=I.neg(),m=R,c=y.neg(),d=P,N=g.plus(V.mul(j).mul(E)),u=b.plus(V.mul(G).mul(m)),B=x.minus(V.mul(j).mul(c)),t=D.minus(V.mul(G).mul(d));if(X===0)M.push(`M${F(g)} ${F(b)}`);M.push(`C${F(N)} ${F(u)} ${F(B)} ${F(t)} ${F(x)} ${F(D)}`)}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=S0($);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=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=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,y=q.plus(W),g=Q.minus(W),b=q.plus(H),x=Q,D=q.plus(H),E=Q.plus(W),m=D,c=z,d=q.plus(W),N=(u)=>F$(u,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(y)} ${N(g)} ${N(b)} ${N(x)} ${N(D)}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=S0($),H=S0(J),W=S0(Z),z=S0(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),y=H.minus(F),g=q.minus(W),b=H,x=g,D=H.plus(F),E=q.minus(G),m=H.plus(z),c=q,d=H.plus(z),N=q.plus(G),u=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(y)} ${i(g)} ${i(b)}C${i(x)} ${i(D)} ${i(E)} ${i(m)} ${i(c)} ${i(d)}C${i(N)} ${i(u)} ${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=S0($),j=S0(J),G=S0(Z),F=S0(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 _=S0(Q||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=(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(_),y=w.plus(U),g=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(y)}L${M(k)} ${M(g)}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(g)}L${M(X)} ${M(y)}A${M(_)} ${M(U)} 0 0 1 ${M(I)} ${M(w)}Z`;let b=N6(),x=b.mul(_),D=b.mul(U);return`M${M(I)} ${M(w)}L${M(P)} ${M(w)}C${M(P.plus(x))} ${M(w)} ${M(k)} ${M(y.minus(D))} ${M(k)} ${M(y)}L${M(k)} ${M(g)}C${M(k)} ${M(g.plus(D))} ${M(P.plus(x))} ${M(R)} ${M(P)} ${M(R)}L${M(I)} ${M(R)}C${M(I.minus(x))} ${M(R)} ${M(X)} ${M(g.plus(D))} ${M(X)} ${M(g)}L${M(X)} ${M(y)}C${M(X)} ${M(y.minus(D))} ${M(I.minus(x))} ${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=S0($),H=S0(J),W=S0(Z),z=S0(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])=>[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=[],K=J.split(/[\s,]+/).filter((q)=>q.length>0);for(let q of K)try{Z.push(S0(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(S0(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=S0($),j=S0(J),G=S0(Z),F=S0(q),_=S0(H),U=H0.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],y=k.mul(I).minus(w.mul(R)).isNegative()?Q===1?0:1:Q,g=G.mul(new O(Math.PI)).div(180),b=O.cos(g),x=O.sin(g),D=z.mul(b),E=z.mul(x),m=j.mul(x).neg(),c=j.mul(b),d=k.mul(D).plus(w.mul(E)),N=R.mul(D).plus(I.mul(E)),u=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(u.mul(u).plus(B.mul(B))),q0=O.atan2(N,d).mul(180).div(new O(Math.PI));return[t,i,q0,K,y,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=H0.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=H0.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),y=V.mul(R).plus(X.mul(I)).plus(w),g=z(Z).mul(z(Math.PI)).div(180),b=O.sin(g),x=O.cos(g),D=Y.mul(G).mul(x).plus(M.mul(G).mul(b)),E=V.mul(G).mul(x).plus(X.mul(G).mul(b)),m=Y.mul(F.neg()).mul(b).plus(M.mul(F).mul(x)),c=V.mul(F.neg()).mul(b).plus(X.mul(F).mul(x)),d=D.mul(D).plus(m.mul(m)),N=E.mul(E).plus(c.mul(c)),u=D.mul(E).plus(m.mul(c)).mul(2),B=d.minus(N),t,i,l;if(u.abs().lt(j))t=z(0),i=d,l=N;else if(B.abs().lt(j))i=d.plus(u.mul("0.5")),l=d.minus(u.mul("0.5")),t=z(Math.PI).div(4);else{let Q0=z(1).plus(u.mul(u).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(u.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:y.toNumber()}}function Iq($,J){if(!$||typeof $!=="string")return console.warn("parseTransformFunction: invalid function name"),H0.identity(3);if(!J||!Array.isArray(J))return console.warn("parseTransformFunction: invalid arguments array"),H0.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 s0(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}`),H0.identity(3);let[K,Q,q,H,W,z]=J.slice(0,6).map((j)=>Z(j!==void 0?j:0));return H0.from([[K,q,W],[Q,H,z],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),H0.identity(3)}}function Q7($){if(!$||$.trim()==="")return H0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,K=H0.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]=n0($,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]),y=H(Y[k+4]),g=H(Y[k+5]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),P=P.plus(G),y=y.plus(j),g=g.plus(G);let b=L7(J,w,R),x=L7(J,I,P),D=L7(J,y,g);X.push(b.x.toFixed(q),b.y.toFixed(q),x.x.toFixed(q),x.y.toFixed(q),D.x.toFixed(q),D.y.toFixed(q)),j=y,G=g}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 y=L7(J,w,R),g=L7(J,I,P);X.push(y.x.toFixed(q),y.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),j=I,G=P}z.push((K?"S":U)+" "+X.join(" "));break}case"Q":{let X=[];if(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 y=L7(J,w,R),g=L7(J,I,P);X.push(y.x.toFixed(q),y.y.toFixed(q),g.x.toFixed(q),g.y.toFixed(q)),j=I,G=P}z.push((K?"Q":U)+" "+X.join(" "));break}case"T":{let X=[];if(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],y=Y[k+4],g=H(Y[k+5]),b=H(Y[k+6]);if(V)g=g.plus(j),b=b.plus(G);let x=Nq(w,R,I,P,y,g.toNumber(),b.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)),j=g,G=b}z.push((K?"A":U)+" "+X.join(" "));break}case"Z":{z.push("Z"),j=F,G=_;break}default:z.push(U+" "+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:()=>f0,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 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: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)=>f0(Q.x,Q.y)),K=J.map((Q)=>f0(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)=>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 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)=>f0(H.x,H.y)),K=J.map((H)=>f0(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(f0(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)=>f0(H.x,H.y)),K=J.map((H)=>f0(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(f0(X.x,X.y));let k=(G+1)%V.length,w=V[k];if(w.intersectionId!==void 0&&!F.has(w.intersectionId)){z.push(f0(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:f0(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)=>f0(H.x,H.y)),K=J.map((H)=>f0(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(f0(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(f0(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(f0(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:f0,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),y=w.plus(I).div(2),g=R.plus(P).div(2),b=y.pow(2).plus(g.pow(2)).sqrt();if(b.lt(n7))y=w,g=R;else y=y.div(b),g=g.div(b);let x=w.times(I).plus(R.times(P)),D=v6(1).minus(x).div(2).sqrt(),E=K;if(D.gt(n7)){let m=K.div(D);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))),u=Z$(F.x.minus(I.times(K)),F.y.minus(P.times(K)));z.push(N,u);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 u=Math.max(2,Math.ceil(Math.abs(N)/(Math.PI/8)));for(let B=0;B<=u;B++){let t=c+N*(B/u);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(y.times(E)),F.y.plus(g.times(E)))),z.push(Z$(F.x.minus(y.times(E)),F.y.minus(g.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:()=>x0,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 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=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
10
|
`,W=this.children.map((j)=>j instanceof w0?j.serialize($+1,J):y6(j)).join(H),z="";if(this.textContent&&this.children.length>0)if(K)z=`<![CDATA[
|
|
11
11
|
${this.textContent}
|
|
12
12
|
]]>`+H+W;else z=y6(this.textContent)+H+W;else if(this.textContent)if(K)z=`<![CDATA[
|
|
13
13
|
${this.textContent}
|
|
14
14
|
]]>`;else z=y6(this.textContent);else z=W;if(this.children.length===0)return`${Z}<${this.tagName}${q}>${z}</${this.tagName}>`;return`${Z}<${this.tagName}${q}>${H}${z}${H}${Z}</${this.tagName}>`}get outerHTML(){return this.serialize(0)}get innerHTML(){return this.children.map(($)=>$ instanceof w0?$.serialize(0):y6($)).join(`
|
|
15
|
-
`)}}function l8($,J,Z=!1){if(typeof $!=="string")throw new Error("parseElement: str must be a string");if(typeof J!=="number"||!Number.isFinite(J)||J<0)throw new Error("parseElement: pos must be a non-negative finite number");if($.length===0)return{element:null,endPos:0};if(J>=$.length)return{element:null,endPos:J};let K=J;while(K<$.length){let Y=$.slice(K).match(/^(\s+)/);if(Y){K+=Y[1].length;continue}if($.slice(K,K+4)==="<!--"){let V=$.indexOf("-->",K+4);if(V===-1)break;K=V+3;continue}if($.slice(K,K+9)==="<![CDATA["){let V=$.indexOf("]]>",K+9);if(V===-1)break;K=V+3;continue}if($.slice(K,K+2)==="<?"){let V=$.indexOf("?>",K+2);if(V===-1)break;K=V+2;continue}if($.slice(K,K+9).toUpperCase()==="<!DOCTYPE"){let V=0,M=K+9;while(M<$.length){if($[M]==="[")V++;else if($[M]==="]")V--;else if($[M]===">"&&V===0){K=M+1;break}M++}if(M>=$.length)break;continue}break}if(K>=$.length||$[K]!=="<")return{element:null,endPos:K};let Q=$.slice(K).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!Q)return{element:null,endPos:K};let q=Q[1];K+=Q[0].length;let H={};while(K<$.length){let Y=$.slice(K).match(/^(\s+)/);if(Y)K+=Y[1].length;if($[K]===">"){K++;break}if($.slice(K,K+2)==="/>")return K+=2,{element:new w0(q,H,[]),endPos:K};let V=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let M=V[1],X=V[2]!==void 0?V[2]:V[3];H[M]=hq(X),K+=V[0].length}else{let M=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(M)H[M[1]]="",K+=M[0].length;else K++}}let W=[],z="",j=`</${q}>`;while(K<$.length){if($.slice(K,K+j.length).toLowerCase()===j.toLowerCase()){K+=j.length;break}if($[K]==="<"&&$[K+1]!=="/"){if($.slice(K,K+9)==="<![CDATA["){let X=$.indexOf("]]>",K+9);if(X!==-1){z+=$.slice(K+9,X),K=X+3;continue}}if($.slice(K,K+4)==="<!--"){let X=$.indexOf("-->",K+4);if(X!==-1){K=X+3;continue}}let Y=H["xml:space"],M=l8($,K,Y==="preserve"?!0:Y==="default"?!1:Z);if(M.element)W.push(M.element),K=M.endPos;else K++}else if($[K]==="<"&&$[K+1]==="/"){let Y=$.slice(K).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(Y&&Y[1].toLowerCase()===q.toLowerCase()){K+=Y[0].length;break}K++}else{let Y=$.indexOf("<",K);if(Y===-1)z+=$.slice(K),K=$.length;else z+=$.slice(K,Y),K=Y}}let G=new w0(q,H,W,""),F=H["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?p8(z):p8(z.trim());return G.textContent=U,{element:G,endPos:K}}function m8($){if(typeof $!=="string")throw new Error("parseSelector: selector must be a string");let J=$.trim();if(J.length===0)throw new Error("parseSelector: selector cannot be empty");let Z=[],K=J.split(/\s*,\s*/);for(let Q of K){let q={tag:null,id:null,classes:[],attrs:[]},H=Q,W=H.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(W)q.tag=W[1].toLowerCase(),H=H.slice(W[0].length);let z=H.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(z)q.id=z[1],H=H.replace(z[0],"");let j=H.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of j)q.classes.push(F[1]);let G=H.matchAll(/\[([a-zA-Z][a-zA-Z0-9_:-]*)(?:=["']?([^"'\]]+)["']?)?\]/g);for(let F of G)q.attrs.push({name:F[1],value:F[2]});Z.push(q)}return Z}function d8($,J){if(!($ instanceof w0))throw new Error("matchesAllSelectors: el must be an SVGElement");if(!Array.isArray(J))throw new Error("matchesAllSelectors: matchers must be an array");return J.some((Z)=>{if(Z.tag&&$.tagName.toLowerCase()!==Z.tag)return!1;if(Z.id&&$.getAttribute("id")!==Z.id)return!1;let K=($.getAttribute("class")||"").split(/\s+/).filter((Q)=>Q.length>0);for(let Q of Z.classes)if(!K.includes(Q))return!1;for(let Q of Z.attrs){if(!$.hasAttribute(Q.name))return!1;if(Q.value!==void 0&&$.getAttribute(Q.name)!==Q.value)return!1}return!0})}function y6($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Dq($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hq($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function p8($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function h7($){if(!$)throw new Error("buildDefsMap: svgRoot cannot be null or undefined");if(!($ instanceof w0))throw new Error("buildDefsMap: svgRoot must be an SVGElement");let J=new Map,Z=(K)=>{let Q=K.getAttribute("id");if(Q)J.set(Q,K);for(let q of K.children)if(q instanceof w0)Z(q)};return Z($),J}function P7($,J){if(!$)throw new Error("findElementsWithAttribute: root cannot be null or undefined");if(!($ instanceof w0))throw new Error("findElementsWithAttribute: root must be an SVGElement");if(typeof J!=="string")throw new Error("findElementsWithAttribute: attrName must be a string");let Z=[],K=(Q)=>{if(Q.hasAttribute(J))Z.push(Q);for(let q of Q.children)if(q instanceof w0)K(q)};return K($),Z}function y7($){if(!$||typeof $!=="string")return null;let J=$.trim();if(J.length===0)return null;let Z=J.match(/url\(\s*["']?#?([^"')]+)["']?\s*\)/i);return Z?Z[1]:null}function
|
|
16
|
-
`)+$.serialize(0,Z)}var yq={parseSVG:
|
|
15
|
+
`)}}function l8($,J,Z=!1){if(typeof $!=="string")throw new Error("parseElement: str must be a string");if(typeof J!=="number"||!Number.isFinite(J)||J<0)throw new Error("parseElement: pos must be a non-negative finite number");if($.length===0)return{element:null,endPos:0};if(J>=$.length)return{element:null,endPos:J};let K=J;while(K<$.length){let Y=$.slice(K).match(/^(\s+)/);if(Y){K+=Y[1].length;continue}if($.slice(K,K+4)==="<!--"){let V=$.indexOf("-->",K+4);if(V===-1)break;K=V+3;continue}if($.slice(K,K+9)==="<![CDATA["){let V=$.indexOf("]]>",K+9);if(V===-1)break;K=V+3;continue}if($.slice(K,K+2)==="<?"){let V=$.indexOf("?>",K+2);if(V===-1)break;K=V+2;continue}if($.slice(K,K+9).toUpperCase()==="<!DOCTYPE"){let V=0,M=K+9;while(M<$.length){if($[M]==="[")V++;else if($[M]==="]")V--;else if($[M]===">"&&V===0){K=M+1;break}M++}if(M>=$.length)break;continue}break}if(K>=$.length||$[K]!=="<")return{element:null,endPos:K};let Q=$.slice(K).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!Q)return{element:null,endPos:K};let q=Q[1];K+=Q[0].length;let H={};while(K<$.length){let Y=$.slice(K).match(/^(\s+)/);if(Y)K+=Y[1].length;if($[K]===">"){K++;break}if($.slice(K,K+2)==="/>")return K+=2,{element:new w0(q,H,[]),endPos:K};let V=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let M=V[1],X=V[2]!==void 0?V[2]:V[3];H[M]=hq(X),K+=V[0].length}else{let M=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(M)H[M[1]]="",K+=M[0].length;else K++}}let W=[],z="",j=`</${q}>`;while(K<$.length){if($.slice(K,K+j.length).toLowerCase()===j.toLowerCase()){K+=j.length;break}if($[K]==="<"&&$[K+1]!=="/"){if($.slice(K,K+9)==="<![CDATA["){let X=$.indexOf("]]>",K+9);if(X!==-1){z+=$.slice(K+9,X),K=X+3;continue}}if($.slice(K,K+4)==="<!--"){let X=$.indexOf("-->",K+4);if(X!==-1){K=X+3;continue}}let Y=H["xml:space"],M=l8($,K,Y==="preserve"?!0:Y==="default"?!1:Z);if(M.element)W.push(M.element),K=M.endPos;else K++}else if($[K]==="<"&&$[K+1]==="/"){let Y=$.slice(K).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(Y&&Y[1].toLowerCase()===q.toLowerCase()){K+=Y[0].length;break}K++}else{let Y=$.indexOf("<",K);if(Y===-1)z+=$.slice(K),K=$.length;else z+=$.slice(K,Y),K=Y}}let G=new w0(q,H,W,""),F=H["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?p8(z):p8(z.trim());return G.textContent=U,{element:G,endPos:K}}function m8($){if(typeof $!=="string")throw new Error("parseSelector: selector must be a string");let J=$.trim();if(J.length===0)throw new Error("parseSelector: selector cannot be empty");let Z=[],K=J.split(/\s*,\s*/);for(let Q of K){let q={tag:null,id:null,classes:[],attrs:[]},H=Q,W=H.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(W)q.tag=W[1].toLowerCase(),H=H.slice(W[0].length);let z=H.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(z)q.id=z[1],H=H.replace(z[0],"");let j=H.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of j)q.classes.push(F[1]);let G=H.matchAll(/\[([a-zA-Z][a-zA-Z0-9_:-]*)(?:=["']?([^"'\]]+)["']?)?\]/g);for(let F of G)q.attrs.push({name:F[1],value:F[2]});Z.push(q)}return Z}function d8($,J){if(!($ instanceof w0))throw new Error("matchesAllSelectors: el must be an SVGElement");if(!Array.isArray(J))throw new Error("matchesAllSelectors: matchers must be an array");return J.some((Z)=>{if(Z.tag&&$.tagName.toLowerCase()!==Z.tag)return!1;if(Z.id&&$.getAttribute("id")!==Z.id)return!1;let K=($.getAttribute("class")||"").split(/\s+/).filter((Q)=>Q.length>0);for(let Q of Z.classes)if(!K.includes(Q))return!1;for(let Q of Z.attrs){if(!$.hasAttribute(Q.name))return!1;if(Q.value!==void 0&&$.getAttribute(Q.name)!==Q.value)return!1}return!0})}function y6($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Dq($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hq($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function p8($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function h7($){if(!$)throw new Error("buildDefsMap: svgRoot cannot be null or undefined");if(!($ instanceof w0))throw new Error("buildDefsMap: svgRoot must be an SVGElement");let J=new Map,Z=(K)=>{let Q=K.getAttribute("id");if(Q)J.set(Q,K);for(let q of K.children)if(q instanceof w0)Z(q)};return Z($),J}function P7($,J){if(!$)throw new Error("findElementsWithAttribute: root cannot be null or undefined");if(!($ instanceof w0))throw new Error("findElementsWithAttribute: root must be an SVGElement");if(typeof J!=="string")throw new Error("findElementsWithAttribute: attrName must be a string");let Z=[],K=(Q)=>{if(Q.hasAttribute(J))Z.push(Q);for(let q of Q.children)if(q instanceof w0)K(q)};return K($),Z}function y7($){if(!$||typeof $!=="string")return null;let J=$.trim();if(J.length===0)return null;let Z=J.match(/url\(\s*["']?#?([^"')]+)["']?\s*\)/i);return Z?Z[1]:null}function 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 yq={parseSVG:x0,SVGElement:w0,buildDefsMap:h7,findElementsWithAttribute:P7,parseUrlReference:y7,serializeSVG:q7};var{appendFileSync:uq}=(()=>({}));var gq=100,xq=5000,i$={SILENT:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},T9={level:i$.WARN,logToFile:null,timestamps:!1,_buffer:[],_flushTimer:null,_safeStringify($){if($===null)return"null";if($===void 0)return"undefined";if($ instanceof Error)return $.stack||`${$.name}: ${$.message}`;if(typeof $!=="object")return String($);try{let J=new WeakSet;return JSON.stringify($,(Z,K)=>{if(typeof K==="object"&&K!==null){if(J.has(K))return"[Circular]";J.add(K)}return K})}catch{return String($)}},_format($,J){if(typeof $!=="string"||!$)throw new Error("Logger._format: level must be a non-empty string");let Z=this._safeStringify(J);if(this.timestamps)return`[${new Date().toISOString()}] [${$}] ${Z}`;return`[${$}] ${Z}`},_bufferWrite($){if(!this.logToFile)return;if(this._buffer.push($),this._buffer.length>=gq)this.flush();if(!this._flushTimer)this._flushTimer=setInterval(()=>this.flush(),xq),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
|
+
`;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=Q7;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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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(f0(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),y=w.mul(w),g=P.div(R).plus(y.div(I));if(g.gt(1)){let $0=g.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),I=_.mul(_)}let b=R.mul(I).minus(R.mul(y)).minus(I.mul(P));if(b=b.div(R.mul(y).plus(I.mul(P))),b.lt(0))b=U0(0);if(b=b.sqrt(),H===W)b=b.neg();let x=b.mul(K).mul(w).div(Q),D=b.neg().mul(Q).mul(k).div(K),E=J.plus(z).div(2),m=Z.plus(j).div(2),c=Y.mul(x).minus(V.mul(D)).plus(E),d=V.mul(x).plus(Y.mul(D)).plus(m),N=k.minus(x).div(K),u=w.minus(D).div(Q),B=k.neg().minus(x).div(K),t=w.neg().minus(D).div(Q),i=N.mul(N).plus(u.mul(u)).sqrt();if(i.eq(0)){T9.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(f0(z,j));return}let l=O.acos(N.div(i));if(u.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(f0(z,j));return}let f=O.acos(N.mul(B).plus(u.mul(t)).div(q0));if(N.mul(t).minus(u.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(),y0=V0.sin(),o=Y.mul(K.mul(N0)).minus(V.mul(Q.mul(y0))).plus(c),J0=V.mul(K.mul(N0)).plus(Y.mul(Q.mul(y0))).plus(d);$.push(f0(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 H0))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 H0))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 H0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return H0.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 H0.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 s0(-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 s0(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=s0($.x,$.y);if($.transform){let j=Q7($.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:H0.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]=n0($.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]=n0(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 j7=($)=>$ 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:j7(J.x).plus(j7($.x).mul(J.width)),y:j7(J.y).plus(j7($.y).mul(J.height)),width:j7($.width).mul(J.width),height:j7($.height).mul(J.height)};return{x:j7($.x),y:j7($.y),width:j7($.width),height:j7($.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=H0.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(s0(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(s0(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]=n0(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:j7(K).plus(j7(q).mul(F)),y:j7(Q).plus(j7(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 _=s0(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 H0.identity(3);return Q7($)}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 _=H0.identity(3),U=s0(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=s0(-w,-R);if(_=_.mul(I),V!==1||M!==1){let y=U7(V,M);_=_.mul(y)}let P=s0(-F.x,-F.y);_=_.mul(P)}else{if(V!==1||M!==1){let R=U7(V,M);_=_.mul(R)}let w=s0(-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=n0(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($),e0=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]=n0($,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]=n0(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=e0,H=[];for(let z=0;z<Q;z++)for(let j=0;j<Q;j++){let G=z===j?A$:e0,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:e0,tolerance:K,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:e0,tolerance:K,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:e0,tolerance:K,message:"Polygons must have at least 3 vertices"};try{let q=!0,H=[],W=e0;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(e0,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:e0,tolerance:K,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:e0,tolerance:K,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:e0,tolerance:K,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:e0,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?e0: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]=n0(Z,k0($.x1||0),k0($.y1||0)),[H,W]=n0(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 e0;let J=e0,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):e0,z=H.minus(W),j=W.lessThanOrEqualTo(H.times(A$.plus(Q))),G=z.greaterThanOrEqualTo(e0.minus(Q.times(H))),F=H.isZero()?A$:W.div(H),_=e0,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=x0($);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 g=`translate(${X}, ${k})`;R=R?`${R} ${g}`:g}let I=new w0("g",{});if(R)I.setAttribute("transform",R);let P=t$(W);for(let[g,b]of Object.entries(P))if(b&&!I.hasAttribute(g))I.setAttribute(g,b);if(G.tagName.toLowerCase()==="symbol"){for(let g of M.children||[])if(g&&g.tagName)I.appendChild(g.cloneNode(!0))}else M.removeAttribute("id"),I.appendChild(M);for(let g of W.children||[])if(g&&g.tagName){let b=g.tagName.toLowerCase();if(v5.has(b))I.appendChild(g.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((x)=>({x:x.x instanceof O?x.x:B7(x.x),y:x.y instanceof O?x.y:B7(x.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 y=L5(w,R);K.clipOutsideFragments.push({elementId:W.getAttribute("id")||`clip-${q}`,clipPathId:j,fragments:y,visible:!1});let g=Z.e2eTolerance||"1e-10",b=R5(w,I,y,g);if(K.verifications.e2e.push({element:W.tagName,clipPathId:j,type:"clip-area-conservation",...b}),b.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1}if(k&&k.length>2){let I=b9(k,Z.precision),P=W;if(W.tagName==="path")W.setAttribute("d",I);else{let y=new w0("path",{d:I,...t$(W)});if(W.parentNode)W.parentNode.replaceChild(y,W),P=y}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=Q7(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=Q7(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=Q7(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=Q7(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]=n0(j,G,F),[M,X]=n0(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=Q7(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]=n0(j,G,F),[X,k]=n0(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");if($.startsWith("data:"))return $;let Z=$.split(";");if(Z.length===0)return $;return Z.map((Q)=>{let q=Q.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((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 i0($){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 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="",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=i0($);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=r0(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 G7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function F7($){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 _7($,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){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((Q)=>_7(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 r0(K,J)}function t9($,J=3){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;return Z.forEach((K)=>_7(K)),r0(Z,J)}function e9($,J=3){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((z)=>_7(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 r0(W,J)}function $J($,J=3){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((z)=>_7(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 r0(W,J)}function JJ($,J=0.000001,Z=3){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((j)=>_7(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 r0(z,Z)}function ZJ($,J=0.000001,Z=3){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((j)=>_7(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 r0(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){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((j)=>_7(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 r0(z,Z)}function QJ($,J=3){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;return Z.forEach((K)=>_7(K)),r0(Z,J)}function qJ($,J=3){if(G7($),F7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=i0($);if(Z.length===0)return $;Z.forEach((q)=>_7(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 r0(Q,J)}function HJ($,J=0.000001,Z=3){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((j)=>_7(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 r0(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){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((j)=>_7(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 r0(z,Z)}function zJ($,J=0.000001,Z=3){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((F)=>_7(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 r0(G,Z)}function jJ($,J=0.000001,Z=3){G7($),q$(J),F7(Z);let K=i0($);if(K.length===0)return $;K.forEach((F)=>_7(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 r0(G,Z)}function GJ($,J=3){G7($),F7(J);let Z=i0($);if(Z.length===0)return $;Z.forEach((Q)=>_7(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 r0(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","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"]),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[
|
|
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 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 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"},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 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(a($))return h0.DOM_ELEMENT;if($&&$.nodeType===9)return h0.XML_DOCUMENT;return h0.SVG_STRING}async function H6($,J){switch(J){case h0.SVG_STRING:return x0($);case h0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer!=="undefined"){let K=new XMLSerializer().serializeToString($);return x0(K)}return $;case h0.XML_DOCUMENT:{let Z=$.documentElement||$;if(Z&&typeof Z.serialize==="function")return Z;if(typeof XMLSerializer!=="undefined"){let Q=new XMLSerializer().serializeToString(Z);return x0(Q)}return Z}case h0.FILE_PATH:{let K=(()=>({})).readFileSync($,"utf8");return x0(K)}if(typeof process!=="undefined"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),K=Z($,"utf8");return x0(K)}throw new Error("File loading requires Node.js environment");case h0.URL:if(typeof fetch!=="undefined"){let K=await(await fetch($)).text();return x0(K)}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 K=Z.querySelector("svg");if(K)return x0(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 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 K=Z.documentElement;if(K.tagName.toLowerCase()==="svg")return x0(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===h0.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((y)=>y.textContent&&y.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 y of I.children)if(a(y))_(y)};_($);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 y of I.children)if(a(y))V(y)};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 y=z(P),g=G.has(P)||G.has(y);if(W(P));else if(!g&&K)I.removeAttribute("id");else if(Z&&g){let b=w();if(X.set(P,b),y!==P)X.set(y,b);I.setAttribute("id",b)}}for(let y of I.children)if(a(y))R(y)};if(R($),Z){let I=(g)=>{let b=(x)=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let x of g.getAttributeNames()){let D=g.getAttribute(x);if(D&&D.includes("url(#")){for(let[E,m]of X){let c=b(E);D=D.replace(new RegExp(`url\\(#${c}\\)`,"g"),`url(#${m})`);let d=b(encodeURI(E));D=D.replace(new RegExp(`url\\(#${d}\\)`,"g"),`url(#${m})`)}g.setAttribute(x,D)}if((x==="href"||x==="xlink:href")&&D?.startsWith("#")){let E=D.substring(1),m=z(E);if(X.has(E))g.setAttribute(x,`#${X.get(E)}`);else if(X.has(m))g.setAttribute(x,`#${X.get(m)}`)}if((x==="begin"||x==="end")&&D){for(let[E,m]of X){let c=b(E);D=D.replace(new RegExp(`^${c}\\.`,"g"),`${m}.`),D=D.replace(new RegExp(`;${c}\\.`,"g"),`;${m}.`)}g.setAttribute(x,D)}if((x==="values"||x==="from"||x==="to"||x==="by")&&D){for(let[E,m]of X){let c=b(E);D=D.replace(new RegExp(`#${c}([;\\s]|$)`,"g"),`#${m}$1`)}g.setAttribute(x,D)}}for(let x of g.children)if(a(x))I(x)};I($);let P=(g)=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=$.getElementsByTagName("style");for(let g of y){let b=g.textContent;if(!b)continue;for(let[x,D]of X){let E=P(x);b=b.replace(new RegExp(`#${E}([^\\w-]|$)`,"g"),`#${D}$1`),b=b.replace(new RegExp(`url\\(#${E}\\)`,"g"),`url(#${D})`)}g.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[y,g]of Object.entries(_))if(!Y(y)&&X.getAttribute(y)===g)X.removeAttribute(y);let P=U[X.tagName.toLowerCase()]||{};for(let[y,g]of Object.entries(P))if(!Y(y)&&X.getAttribute(y)===g)X.removeAttribute(y);if(!Z){for(let y of X.getAttributeNames())if(U$.has(y)&&!Y(y)){let g=X.getAttribute(y),b=V(X,y);if(b!==null&&g===b)X.removeAttribute(y)}}}let w={...k};for(let P of U$){let y=X.getAttribute(P);if(y!==null)w[P]=y}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 y=P.tagName.toLowerCase(),g=P.getAttribute("id"),b=K&&g,x=(D)=>{let E=D.getAttribute("id");if(E&&Q.has(E))return!0;for(let m of D.children||[])if(a(m)&&x(m))return!0;return!1};if(!F.includes(y)){if(!x(P)&&!b){X.removeChild(P);continue}}if(I&&!I.has(y)&&!I.has(G(y))){if(!x(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=Q7(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 g=P.split(";");for(let b of g){let x=b.indexOf(":");if(x>0){let D=b.substring(0,x).trim(),E=b.substring(x+1).trim(),m=E.includes("!important");if(m)E=E.replace(/\s*!important\s*/g,"").trim();I.set(D,{specificity:[1,0,0,0],isImportant:m,value:E})}}}let y=Y.split(";");for(let g of y){let b=g.indexOf(":");if(b<=0)continue;let x=g.substring(0,b).trim(),D=g.substring(b+1).trim(),E=D.includes("!important");if(E)D=D.replace(/\s*!important\s*/g,"").trim();let m=I.get(x);if(m){let c=B6(V,m.specificity);if(c<0){if(E&&!m.isImportant)I.set(x,{specificity:V,isImportant:E,value:D})}else if(c===0){if(E||!m.isImportant)I.set(x,{specificity:V,isImportant:E,value:D})}else if(!m.isImportant||E)I.set(x,{specificity:V,isImportant:E,value:D})}else I.set(x,{specificity:V,isImportant:E,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(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 x0(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 x0(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 x0(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 x0(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=(g,b)=>{let x=g.split(";").map((D)=>D.trim()).filter(Boolean);for(let D of x){let E=D.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(D)||D==="indefinite")Q.smil.timingTriggers.push({animationElement:V,value:D});else if(/\.(begin|end)/.test(D))Q.smil.timingTriggers.push({animationElement:V,value:D,type:"syncbase"})}};if(w)I(w,"begin");if(R)I(R,"end");let P=k.getAttribute("onbegin"),y=k.getAttribute("onend");if(P||y){if(Q.smil.hasInteractiveAnimations=!0,P?.includes("play()")||y?.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(`
|
|
22
22
|
`+"=".repeat(80)),console.log("SVG COMPATIBILITY ANALYSIS REPORT"),console.log("=".repeat(80)),console.log(`
|
|
23
23
|
--- SUMMARY ---`),console.log(`SMIL Animations: ${Q.smil.animationCount} (${Q.smil.hasInteractiveAnimations?"includes interactive":"time-based only"})`),console.log(`Audio Elements: ${Q.media.hasAudio?"YES":"NO"}`),console.log(`Video Elements: ${Q.media.hasVideo?"YES":"NO"}`),Q.media.hasAudio)console.log(`
|
|
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(`
|
|
@@ -28,50 +28,50 @@ ${H}
|
|
|
28
28
|
--- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of Q.smil.eventTriggers){let M=V.targetId?`${V.targetId}.${V.event}`:V.event;console.log(` - <${V.animationElement}> triggered by: ${M}${V.offset?` ${V.offset}`:""}`)}}}if(Q.compatibility.recommendations.length>0){console.log(`
|
|
29
29
|
--- RECOMMENDATIONS ---`);for(let V of Q.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 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"}}}},Y0={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(Y0.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(Y0.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(Y0.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(Y0.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(Y0.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(Y0.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(Y0.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(Y0.VIDEO),z.details.video={count:w.length,hasAutoplay:w.some((f)=>f.hasAttribute("autoplay"))};let I=q("image"),P=[],y=[];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:"))y.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(Y0.EXTERNAL_IMAGES),z.details.externalImages={count:P.length,urls:P.slice(0,5)};let g=q("use"),b=[];for(let f of g){let A=f.getAttribute("href")||f.getAttribute("xlink:href")||"";if(A&&!A.startsWith("#"))b.push({href:A})}if(b.length>0)z.detected.add(Y0.EXTERNAL_USE),z.details.externalUse={count:b.length,refs:b.slice(0,5)};let x=!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){x=!0,z.detected.add(Y0.EXTERNAL_FONTS),z.details.externalFonts={detected:!0,sample:e[1]};break}}}if(R.length>0){if(z.detected.add(Y0.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(Y0.IFRAME)}let D=q("filter"),E=q("mask"),m=q("clippath");if(D.length>0)z.detected.add(Y0.FILTERS),z.details.filters={count:D.length};if(E.length>0)z.detected.add(Y0.MASKS),z.details.masks={count:E.length};if(m.length>0)z.detected.add(Y0.CLIP_PATHS),z.details.clipPaths={count:m.length};let c=q("a");if(c.length>0)z.detected.add(Y0.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://"},u={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={[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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"}},[Y0.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(Y0.JAVASCRIPT)||z.detected.has(Y0.EVENT_HANDLERS))q0.interactivityLevel="scripted";else if(z.detected.has(Y0.SMIL_INTERACTIVE))q0.interactivityLevel="interactive";else if(z.detected.has(Y0.SMIL_ANIMATIONS)||z.detected.has(Y0.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={[Y0.JAVASCRIPT]:"JavaScript",[Y0.EVENT_HANDLERS]:"Event handlers",[Y0.SMIL_ANIMATIONS]:"SMIL",[Y0.SMIL_INTERACTIVE]:"Interactive SMIL",[Y0.CSS_ANIMATIONS]:"CSS animations",[Y0.AUDIO]:"Audio",[Y0.VIDEO]:"Video",[Y0.EXTERNAL_IMAGES]:"External images",[Y0.EXTERNAL_USE]:"External use",[Y0.FOREIGN_OBJECT]:"foreignObject",[Y0.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(Y0.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(z.detected.has(
|
|
34
|
+
});`});if(z.detected.has(Y0.SMIL_INTERACTIVE))q0.recommendations.push({issue:"Interactive SMIL animations",solution:"Use OBJECT, EMBED, or INLINE syntax - avoid IMG and CSS background",example:'<object data="animation.svg" type="image/svg+xml"></object>'});if(z.detected.has(Y0.JAVASCRIPT))q0.recommendations.push({issue:"JavaScript in SVG",solution:"Use INLINE syntax for same-page JS context, or OBJECT/EMBED for isolated context",example:"<svg><!-- your SVG with scripts --></svg>"});if(z.detected.has(Y0.EXTERNAL_IMAGES)||z.detected.has(Y0.EXTERNAL_FONTS)||z.detected.has(Y0.EXTERNAL_USE))q0.recommendations.push({issue:"External resources",solution:"Embed resources as data-URIs for maximum compatibility, or ensure CORS headers are set",example:"Use svg-toolbox embedExternalDependencies() to inline all resources"});if(q0.interactivityLevel==="scripted")q0.warnings.push("SVG contains JavaScript - will not work in IMG, CSS, or most markdown contexts");if(z.detected.has(Y0.FOREIGN_OBJECT))q0.warnings.push("SVG contains foreignObject - disabled in IMG and CSS contexts");if(z.detected.has(Y0.EXTERNAL_USE))q0.warnings.push("External <use> references are blocked by most modern browsers");if(K){console.log(`
|
|
35
35
|
`+"═".repeat(100)),console.log("SVG COMPREHENSIVE COMPATIBILITY MATRIX ANALYSIS"),console.log("═".repeat(100)),console.log(`
|
|
36
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 Q0 of z.detected){let V0=z.details[Q0.replace("_","")]||z.details[Q0]||{},N0=Q0;if(V0.count!==void 0)N0+=` (${V0.count})`;console.log(`│ • ${N0.padEnd(92)} │`)}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
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[Q0,V0]of Object.entries(q0.bySyntax)){let N0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[Q0]||Q0;for(let
|
|
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[Q0,V0]of Object.entries(q0.bySyntax)){let N0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[Q0]||Q0;for(let y0 of["file","http"]){let o=V0[y0],J0=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(`│ ${N0.padEnd(18)} │ ${(y0+"://").padEnd(9)} │ ${J0.padEnd(26)} │ ${_0.padEnd(16)} │ ${O0.padEnd(10)} │`)}}console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
38
38
|
┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let f="inline",A=0;for(let[Q0,V0]of Object.entries(q0.bySyntax)){let N0=V0.http.works.length*3+V0.http.partial.length-V0.http.blocked.length*2;if(N0>A)A=N0,f=Q0}let e={none:"Open SVG file directly in browser",img:'<img src="your-file.svg" alt="description">',object:'<object data="your-file.svg" type="image/svg+xml"></object>',embed:'<embed src="your-file.svg" type="image/svg+xml">',inline:"Copy <svg>...</svg> content directly into HTML",css:'.element { background-image: url("your-file.svg"); }',script:'const svgEl = document.createElementNS("http://www.w3.org/2000/svg", "svg"); ...'};if(console.log(`│ BEST: ${f.toUpperCase().padEnd(91)} │`),console.log(`│ ${e[f].substring(0,96).padEnd(96)} │`),console.log("│"+" ".repeat(98)+"│"),q0.interactivityLevel!=="static")console.log("│ AVOID: IMG and CSS background (no interactivity)"+" ".repeat(49)+"│");console.log("└"+"─".repeat(98)+"┘"),console.log(`
|
|
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 Q0 of $0){let V0=q0.specialCases[Q0];if(V0){let N0=V0.overallCompat.substring(0,6).padEnd(6),
|
|
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 Q0 of $0){let V0=q0.specialCases[Q0];if(V0){let N0=V0.overallCompat.substring(0,6).padEnd(6),y0=V0.blockedFeatures.slice(0,3).join(", ").substring(0,58).padEnd(58);console.log(`│ ${Q0.substring(0,25).padEnd(25)} │ ${N0} │ ${y0} │`)}}if(console.log("└"+"─".repeat(98)+"┘"),q0.warnings.length>0){console.log(`
|
|
40
40
|
┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of q0.warnings)console.log(`│ • ${Q0.substring(0,94).padEnd(94)} │`);console.log("└"+"─".repeat(98)+"┘")}if(q0.recommendations.length>0){console.log(`
|
|
41
|
-
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of q0.recommendations)console.log(`│ Issue: ${Q0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${Q0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(z.detected.has(
|
|
41
|
+
┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of q0.recommendations)console.log(`│ Issue: ${Q0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${Q0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(z.detected.has(Y0.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,$}),xW=F0(($,J={})=>{let Z=J.printFullMatrix||!1,K=J.groupBySyntax!==!1,Q=J.showOnlyIssues!==!1,q=J.browserDetails!==!1,H=J.filterCapabilities||null,W=(o)=>{let J0=[],_0=o.toLowerCase(),
|
|
45
|
+
`)}return $._compatibilityMatrix=q0,$}),xW=F0(($,J={})=>{let Z=J.printFullMatrix||!1,K=J.groupBySyntax!==!1,Q=J.showOnlyIssues!==!1,q=J.browserDetails!==!1,H=J.filterCapabilities||null,W=(o)=>{let J0=[],_0=o.toLowerCase(),O0=(B0)=>{if(B0.tagName&&B0.tagName.toLowerCase()===_0)J0.push(B0);for(let I0 of B0.children||[])if(I0&&I0.tagName)O0(I0)};return O0($),J0},z=(o,J0=[])=>{if(o.tagName)J0.push(o);for(let _0 of o.children||[])if(_0&&_0.tagName)z(_0,J0);return J0},j=new Set,G={},F=z($);if(F.length>1)j.add("RENDER_VECTORS"),j.add("RENDER_TRANSFORMS");let U=W("text").concat(W("tspan"));if(U.length>0)j.add("RENDER_TEXT"),G.RENDER_TEXT={count:U.length};let Y=W("linearGradient"),V=W("radialGradient");if(Y.length>0||V.length>0)j.add("RENDER_GRADIENTS"),G.RENDER_GRADIENTS={linear:Y.length,radial:V.length};let M=W("pattern");if(M.length>0)j.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")){j.add("RENDER_OPACITY");break}for(let o of F)if((o.getAttribute("style")||"").includes("mix-blend-mode")||o.getAttribute("mix-blend-mode")){j.add("RENDER_BLENDMODES");break}let X=W("style");for(let o of X){let J0=o.textContent||"";if(J0.includes("@font-face")){if(J0.includes("data:"))j.add("FONTS_EMBEDDED");else if(J0.includes("url(")&&J0.match(/url\s*\(\s*['"]?https?:/))j.add("FONTS_WEB_CROSS");else if(J0.includes("url("))j.add("FONTS_WEB_SAME")}}if(U.length>0)j.add("FONTS_SYSTEM");let k=W("image");for(let o of k){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("data:"))j.add("IMAGES_EMBEDDED");else if(J0.startsWith("http://")||J0.startsWith("https://")){let _0=!0;try{let O0=new URL(J0),B0=new URL($.documentURI||$.baseURI||"");_0=O0.origin!==B0.origin}catch(O0){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${O0.message}`);_0=!0}j.add(_0?"IMAGES_REMOTE_CROSS":"IMAGES_REMOTE_SAME")}else if(J0&&!J0.startsWith("#"))j.add("IMAGES_LOCAL")}G.IMAGES={count:k.length};let w=W("filter");if(w.length>0){j.add("FILTERS_BASIC");for(let o of w){let J0=o.outerHTML||"";if(J0.includes("feTurbulence")||J0.includes("feLighting")||J0.includes("feConvolveMatrix")||J0.includes("feDisplacementMap")){j.add("FILTERS_COMPLEX");break}}G.FILTERS={count:w.length}}let R=W("mask");if(R.length>0)j.add("MASKS"),G.MASKS={count:R.length};let I=W("clippath");if(I.length>0)j.add("CLIP_PATHS"),G.CLIP_PATHS={count:I.length};let P=["animate","animatetransform","animatemotion","animatecolor","set"],y=0,g={timed:0,click:0,hover:0,focus:0,accesskey:0,syncbase:0};for(let o of P){let J0=W(o);y+=J0.length;for(let _0 of J0){let O0=(_0.getAttribute("begin")||"").toLowerCase(),B0=(_0.getAttribute("end")||"").toLowerCase(),I0=O0+" "+B0;if(I0.includes("click")||I0.includes("dblclick"))g.click++,j.add("SMIL_CLICK");if(I0.includes("mouseover")||I0.includes("mouseout")||I0.includes("mouseenter")||I0.includes("mouseleave"))g.hover++,j.add("SMIL_HOVER");if(I0.includes("focus")||I0.includes("blur"))g.focus++,j.add("SMIL_FOCUS");if(I0.includes("accesskey("))g.accesskey++,j.add("SMIL_ACCESSKEY");if(I0.match(/\w+\.(begin|end)/))g.syncbase++,j.add("SMIL_SYNCBASE");if(!I0.includes("click")&&!I0.includes("mouse")&&!I0.includes("focus")&&!I0.includes("accesskey"))g.timed++}}if(y>0)j.add("SMIL_TIMED"),G.SMIL={count:y,triggers:g};let b=!1,x=!1,D=!1;for(let o of X){let J0=o.textContent||"";if(J0.includes("@keyframes"))b=!0;if(J0.includes("transition:")||J0.includes("transition-property"))x=!0;if(J0.includes(":hover"))D=!0}if(b)j.add("CSS_KEYFRAMES");if(x)j.add("CSS_TRANSITIONS");if(D)j.add("CSS_HOVER");let E=W("script");if(E.length>0){for(let o of E){let J0=o.getAttribute("src")||o.getAttribute("href")||o.getAttribute("xlink:href"),_0=o.getAttribute("type")||"";if(J0)j.add("SCRIPT_EXTERNAL");else j.add("SCRIPT_INLINE");if(_0==="module")j.add("SCRIPT_MODULE")}G.SCRIPTS={count:E.length}}let m=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove"],c={onclick:"EVENT_ONCLICK",ondblclick:"EVENT_ONDBLCLICK",onmousedown:"EVENT_ONMOUSEDOWN",onmouseup:"EVENT_ONMOUSEUP",onmouseover:"EVENT_ONMOUSEOVER",onmouseout:"EVENT_ONMOUSEOUT",onmousemove:"EVENT_ONMOUSEMOVE",onfocus:"EVENT_ONFOCUS",onblur:"EVENT_ONBLUR",onload:"EVENT_ONLOAD",onerror:"EVENT_ONERROR",onscroll:"EVENT_ONSCROLL",onwheel:"EVENT_ONWHEEL",ontouchstart:"EVENT_ONTOUCH",ontouchend:"EVENT_ONTOUCH",ontouchmove:"EVENT_ONTOUCH",onkeydown:"EVENT_ONKEYBOARD",onkeyup:"EVENT_ONKEYBOARD",onkeypress:"EVENT_ONKEYBOARD"};for(let o of F)for(let J0 of m)if(o.getAttribute(J0)){let _0=c[J0];if(_0)j.add(_0)}let d=W("a");if(d.length>0){for(let o of d){if((o.getAttribute("href")||o.getAttribute("xlink:href")||"").startsWith("#"))j.add("LINK_INTERNAL");else j.add("LINK_EXTERNAL");if(o.getAttribute("target"))j.add("LINK_TARGET");if(o.getAttribute("download"))j.add("LINK_DOWNLOAD")}G.LINKS={count:d.length}}let N=W("foreignobject");if(N.length>0){j.add("FOREIGNOBJECT_BASIC"),j.add("FOREIGNOBJECT_HTML");for(let o of N){let J0=(_0)=>{let O0=_0.tagName?.toLowerCase();if(O0==="form")j.add("FOREIGNOBJECT_FORM");if(O0==="input"||O0==="textarea"||O0==="select")j.add("FOREIGNOBJECT_INPUT");if(O0==="canvas")j.add("FOREIGNOBJECT_CANVAS");if(O0==="video")j.add("FOREIGNOBJECT_VIDEO");if(O0==="iframe")j.add("FOREIGNOBJECT_IFRAME");for(let B0 of _0.children||[])if(B0&&B0.tagName)J0(B0)};J0(o)}G.FOREIGNOBJECT={count:N.length}}let u=W("audio"),B=W("video");for(let o of N){let J0=(_0)=>{let O0=_0.tagName?.toLowerCase();if(O0==="audio")u.push(_0);if(O0==="video")B.push(_0);for(let B0 of _0.children||[])if(B0&&B0.tagName)J0(B0)};J0(o)}if(u.length>0){for(let o of u){let J0=o.getAttribute("src")||"",_0=W("source").filter((B0)=>B0.parentNode===o),O0=J0||(_0.length>0?_0[0].getAttribute("src"):"");if(O0?.startsWith("data:"))j.add("AUDIO_EMBEDDED");else if(O0?.startsWith("http"))j.add("AUDIO_REMOTE");else if(O0)j.add("AUDIO_LOCAL");if(o.hasAttribute("autoplay"))j.add("AUDIO_AUTOPLAY");if(o.hasAttribute("controls"))j.add("AUDIO_CONTROLS")}G.AUDIO={count:u.length}}if(B.length>0){for(let o of B){let J0=o.getAttribute("src")||"";if(J0.startsWith("data:"))j.add("VIDEO_EMBEDDED");else if(J0.startsWith("http"))j.add("VIDEO_REMOTE");else if(J0)j.add("VIDEO_LOCAL");if(o.hasAttribute("autoplay"))j.add("VIDEO_AUTOPLAY")}G.VIDEO={count:B.length}}let t=W("use");if(t.length>0){for(let o of t){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("#"))j.add("USE_INTERNAL");else if(J0.startsWith("http"))j.add("USE_EXTERNAL_CROSS");else if(J0)j.add("USE_EXTERNAL_SAME")}j.add("USE_SHADOW_DOM"),G.USE={count:t.length}}for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("aria-")){j.add("A11Y_ARIA");break}if(o.getAttribute("role"))j.add("A11Y_ROLE");if(o.getAttribute("tabindex"))j.add("A11Y_TABINDEX")}if(W("title").length>0||W("desc").length>0)j.add("A11Y_TITLE");for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("data-")){j.add("META_DATA_ATTRS");break}if(o.getAttribute("class"))j.add("META_CLASS");if(o.getAttribute("id"))j.add("META_ID")}for(let o of X)if((o.textContent||"").includes("@import"))j.add("EXT_CSS_IMPORT");for(let o of F)for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("xlink:")){j.add("EXT_XLINK");break}let i={timestamp:new Date().toISOString(),detectedCapabilities:[...j],capabilityDetails:G,totalCombinations:0,combinationsWithIssues:0,cells:[]},l=(o,J0,_0,O0,B0,I0)=>{let S=_J[o];if(!S)return{status:L.DEPENDS,note:"No compatibility data",browsers:[]};let C=S.default,n="",p=[];for(let[s,G0]of Object.entries(S.exceptions||{})){let L0=!1;if(s.startsWith("syntax:")){let C0=s.substring(7);if(C0==="*"||C0===B0.id||C0.includes("*")&&B0.id.startsWith(C0.replace("*","")))L0=!0}else if(s.startsWith("load:")){if(s.substring(5)===_0.id)L0=!0}else if(s.startsWith("storage:")){if(s.substring(8)===O0.id)L0=!0}else if(s.startsWith("display:")){if(s.substring(8)===J0.id)L0=!0}else if(s.startsWith("renderer:")){let C0=s.substring(9);if(C0==="*"&&J0.type==="renderer")L0=!0;if(C0===J0.id)L0=!0}else if(s.startsWith("browser:")){let C0=s.substring(8);if(C0==="*")for(let T0 of Object.values($Z))p.push({browser:T0.name,status:G0.status,note:G0.note});else{let T0=Object.values($Z).find((w7)=>w7.id===C0);if(T0)p.push({browser:T0.name,status:G0.status,note:G0.note})}}if(L0)C=G0.status,n=G0.note||""}return{status:C,note:n,browserIssues:p}},q0=Object.values(DW),f=Object.values(hW),A=Object.values(yW),e=Object.values(e5),$0=Object.values(uW);for(let o of q0)for(let J0 of f)for(let _0 of A)for(let O0 of e)for(let B0 of $0){if(i.totalCombinations++,B0.script&&!["script-inner","script-dom","script-fetch"].includes(O0.id))continue;if(o.type==="renderer"&&O0.html)continue;let I0=[],S={};for(let C of j){if(H){let s=K6[C];if(s&&!H.includes(s.cat))continue}let n=l(C,o,J0,_0,O0,B0),p=K6[C]||{name:C,cat:"unknown"};if(S[C]={name:p.name,category:p.cat,status:n.status,note:n.note,browserIssues:n.browserIssues},n.status!==L.WORKS&&n.status!==L.NA)I0.push({capability:C,name:p.name,category:p.cat,status:n.status,note:n.note,browserIssues:n.browserIssues})}if(I0.length>0||!Q){let C={combination:{display:o.name,displayId:o.id,displayType:o.type,load:J0.name,loadId:J0.id,storage:_0.name,storageId:_0.id,syntax:O0.name,syntaxId:O0.id,processing:B0.name,processingId:B0.id},issueCount:I0.length,issues:I0,allCapabilities:S};if(i.cells.push(C),I0.length>0)i.combinationsWithIssues++}}console.log(`
|
|
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
47
|
┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${i.totalCombinations.toString().padEnd(80)} │`),console.log(`│ Combinations with issues: ${i.combinationsWithIssues.toString().padEnd(89)} │`),console.log(`│ Detected capabilities in SVG: ${i.detectedCapabilities.length.toString().padEnd(85)} │`),console.log("└"+"─".repeat(118)+"┘"),console.log(`
|
|
48
|
-
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let Q0={};for(let o of j){let J0=K6[o]||{cat:"unknown",name:o};if(!Q0[J0.cat])Q0[J0.cat]=[];Q0[J0.cat].push({key:o,name:J0.name})}for(let[o,J0]of Object.entries(Q0)){let _0=o.toUpperCase();console.log(`│ ${_0}:`.padEnd(119)+"│");for(let
|
|
49
|
-
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let J0 of i.cells){let _0=J0.combination.syntaxId;if(!o[_0])o[_0]=[];o[_0].push(J0)}for(let[J0,_0]of Object.entries(o)){let
|
|
48
|
+
┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let Q0={};for(let o of j){let J0=K6[o]||{cat:"unknown",name:o};if(!Q0[J0.cat])Q0[J0.cat]=[];Q0[J0.cat].push({key:o,name:J0.name})}for(let[o,J0]of Object.entries(Q0)){let _0=o.toUpperCase();console.log(`│ ${_0}:`.padEnd(119)+"│");for(let O0 of J0){let B0=G[O0.key.split("_")[0]]||{},I0=` • ${O0.name}`;if(B0.count!==void 0)I0+=` (${B0.count})`;console.log(`│ ${I0}`.padEnd(119)+"│")}}if(console.log("└"+"─".repeat(118)+"┘"),K){console.log(`
|
|
49
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let J0 of i.cells){let _0=J0.combination.syntaxId;if(!o[_0])o[_0]=[];o[_0].push(J0)}for(let[J0,_0]of Object.entries(o)){let O0=Object.values(e5).find((S)=>S.id===J0),B0=O0?O0.name:J0;console.log(`
|
|
50
50
|
┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${B0}`.padEnd(119)+"│"),console.log("├"+"─".repeat(30)+"┬"+"─".repeat(20)+"┬"+"─".repeat(25)+"┬"+"─".repeat(40)+"┤"),console.log("│ CONTEXT COMBINATION │ ISSUES │ BLOCKED CAPABILITIES │ BROWSER-SPECIFIC NOTES │"),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(20)+"┼"+"─".repeat(25)+"┼"+"─".repeat(40)+"┤"),_0.sort((S,C)=>C.issueCount-S.issueCount);let I0=Z?_0:_0.slice(0,20);for(let S of I0){let C=`${(S.combination.displayId||"").substring(0,8)}/${S.combination.loadId}/${(S.combination.storageId||"").substring(0,8)}`,n=S.issueCount.toString(),p=S.issues.filter((G0)=>G0.status===L.BLOCKED).map((G0)=>(G0.name||"").substring(0,15)).slice(0,2).join(", "),s=S.issues.flatMap((G0)=>G0.browserIssues||[]).slice(0,2).map((G0)=>`${G0.browser}: ${G0.note?.substring(0,15)||""}`).join("; ");console.log(`│ ${C.padEnd(28)} │ ${n.padEnd(18)} │ ${(p||"-").substring(0,23).padEnd(23)} │ ${(s||"-").substring(0,38).padEnd(38)} │`)}if(!Z&&_0.length>20)console.log(`│ ... and ${_0.length-20} more combinations`.padEnd(119)+"│");console.log("└"+"─".repeat(30)+"┴"+"─".repeat(20)+"┴"+"─".repeat(25)+"┴"+"─".repeat(40)+"┘")}}console.log(`
|
|
51
51
|
╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of j){let J0=K6[o]||{name:o,cat:"unknown"},_0=_J[o];if(console.log(`
|
|
52
|
-
┌`+"─".repeat(118)+"┐"),console.log(`│ ${J0.name} (${J0.cat})`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),!_0)console.log("│ No compatibility data available".padEnd(119)+"│");else if(console.log(`│ Default status: ${_0.default}`.padEnd(119)+"│"),Object.keys(_0.exceptions||{}).length>0){console.log("│ Exceptions:".padEnd(119)+"│");for(let[
|
|
52
|
+
┌`+"─".repeat(118)+"┐"),console.log(`│ ${J0.name} (${J0.cat})`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),!_0)console.log("│ No compatibility data available".padEnd(119)+"│");else if(console.log(`│ Default status: ${_0.default}`.padEnd(119)+"│"),Object.keys(_0.exceptions||{}).length>0){console.log("│ Exceptions:".padEnd(119)+"│");for(let[O0,B0]of Object.entries(_0.exceptions)){let I0=` ${O0}: ${B0.status} - ${B0.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[J0,_0]of Object.entries(o)){let
|
|
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[J0,_0]of Object.entries(o)){let O0=_0.filter((B0)=>{let I0=B0.toLowerCase();if(I0.includes("smil")&&[...j].some((S)=>S.startsWith("SMIL_")))return!0;if(I0.includes("autoplay")&&j.has("AUDIO_AUTOPLAY"))return!0;if(I0.includes("blend")&&j.has("RENDER_BLENDMODES"))return!0;if(I0.includes("filter")&&(j.has("FILTERS_BASIC")||j.has("FILTERS_COMPLEX")))return!0;if(I0.includes("foreign")&&[...j].some((S)=>S.startsWith("FOREIGNOBJECT_")))return!0;if(I0.includes("external use")&&(j.has("USE_EXTERNAL_SAME")||j.has("USE_EXTERNAL_CROSS")))return!0;return!1});if(O0.length>0){let B0=O0.slice(0,3).join(", ");console.log(`│ ${J0.padEnd(12)} │ ${B0.substring(0,101).padEnd(101)} │`)}}console.log("└"+"─".repeat(14)+"┴"+"─".repeat(103)+"┘")}console.log(`
|
|
55
55
|
╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let V0=[];if(j.has("AUDIO_AUTOPLAY")||j.has("AUDIO_EMBEDDED")||j.has("AUDIO_LOCAL")||j.has("AUDIO_REMOTE"))V0.push({feature:"Audio Playback",issue:"Browser autoplay policies block automatic audio",bestSyntax:"INLINE-SVG with JavaScript",workaround:"Extract audio data-URI, create Audio object, play on user click gesture",code:"document.querySelector('svg').addEventListener('click', () => new Audio(dataUri).play());"});if(j.has("SMIL_CLICK")||j.has("SMIL_HOVER")||j.has("SMIL_FOCUS")||j.has("SMIL_ACCESSKEY"))V0.push({feature:"Interactive SMIL Animation",issue:"Blocked in <img>, CSS backgrounds, and most renderers",bestSyntax:"<object>, <embed>, <iframe>, or inline <svg>",workaround:"Avoid <img> and CSS embedding for interactive SVGs",code:'<object data="animation.svg" type="image/svg+xml" width="800" height="600"></object>'});if(j.has("SCRIPT_INLINE")||j.has("SCRIPT_EXTERNAL"))V0.push({feature:"JavaScript Execution",issue:"Completely blocked in <img>, CSS contexts, email, most social platforms",bestSyntax:"Inline <svg> or <object>/<embed>/<iframe>",workaround:"For widest compatibility, convert JS interactions to SMIL or CSS",code:`<!-- Inline: --> <div><svg>...</svg></div>
|
|
56
56
|
<!-- Isolated: --> <object data="app.svg"></object>`});if([...j].some((o)=>o.startsWith("FOREIGNOBJECT_")))V0.push({feature:"foreignObject / HTML Content",issue:"Completely ignored in <img>, CSS contexts, most renderers (Cairo, ImageMagick)",bestSyntax:"Inline <svg> or <object>/<embed>",workaround:"For rasterization, use browser screenshot or Puppeteer instead of ImageMagick",code:'<object data="with-html.svg" type="image/svg+xml"></object>'});if(j.has("IMAGES_REMOTE_CROSS")||j.has("FONTS_WEB_CROSS")||j.has("USE_EXTERNAL_CROSS")||j.has("AUDIO_REMOTE"))V0.push({feature:"Cross-Origin Resources",issue:"Blocked without CORS headers, completely blocked in <img> context",bestSyntax:"Any syntax with proper CORS, or embed resources as data-URIs",workaround:"Use embedExternalDependencies() to inline all external resources",code:"await embedExternalDependencies(doc, { embedImages: true, embedFonts: true, embedAudio: true });"});for(let o of V0){console.log(`
|
|
57
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 J0 of(o.code||"").split(`
|
|
58
58
|
`).slice(0,3))console.log(`│ ${J0}`.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 N0={};for(let o of e){let J0=100,_0=[];for(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,J0]of
|
|
61
|
-
⚠️ No embedding methods available for recommendation.`);else{let o=
|
|
59
|
+
╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let N0={};for(let o of e){let J0=100,_0=[];for(let O0 of j){let B0=K6[O0]||{name:O0,critical:!1},I0=_J[O0];if(I0){for(let[S,C]of Object.entries(I0.exceptions||{}))if(S.startsWith("syntax:")){let n=S.substring(7);if(n===o.id||n==="*"||n.includes("*")&&o.id.startsWith(n.replace("*",""))){let p=B0.critical?30:10;J0-=p,_0.push({cap:B0.name,penalty:p,status:C.status})}}}}N0[o.id]={name:o.name,score:Math.max(0,J0),deductions:_0}}let y0=Object.entries(N0).sort((o,J0)=>J0[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,J0]of y0){let _0=J0.score===100?"100% ✅":J0.score>=70?`${J0.score}% ⚠️`:`${J0.score}% ❌`,O0=J0.deductions.slice(0,3).map((B0)=>B0.cap).join(", ")||"None";console.log(`│ ${J0.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
65
|
`),$._fullCompatibilityMatrix=i,$});function mW($,J={}){let Z=J.compact!==!1,K=J.showAllCells||!1,Q=[{id:"direct",label:"DIRECT",desc:"SVG file"},{id:"img",label:"IMG",desc:"<img>"},{id:"object",label:"OBJECT",desc:"<object>"},{id:"embed",label:"EMBED",desc:"<embed>"},{id:"inline",label:"INLINE",desc:"<svg>"},{id:"css",label:"CSS",desc:"bg-image"}],q=[{id:"embedded",label:"EMB",desc:"data-uri/inline"},{id:"local",label:"LOC",desc:"local path"},{id:"remote",label:"REM",desc:"http(s) URL"}],H=[{id:"browser",label:"BROWSER",desc:"Desktop browsers"},{id:"mobile",label:"MOBILE",desc:"Mobile WebView"},{id:"renderer",label:"RENDER",desc:"Server-side"}],W=[{id:"file",label:"file://",desc:"Local filesystem"},{id:"http",label:"http(s)://",desc:"Web server"},{id:"data",label:"data:",desc:"Data URI"}],z=[{id:"script",label:"+JS",desc:"With JavaScript"},{id:"noscript",label:"-JS",desc:"No JavaScript"}],j=[{id:"chrome",code:"C",name:"Chrome"},{id:"firefox",code:"F",name:"Firefox"},{id:"safari",code:"S",name:"Safari"},{id:"edge",code:"E",name:"Edge"},{id:"ie11",code:"I",name:"IE11"},{id:"ios",code:"i",name:"iOS Safari"},{id:"android",code:"A",name:"Android"}],G={display:{icon:"D",emoji:"\uD83D\uDCD0",name:"Basic rendering"},animation:{icon:"A",emoji:"\uD83C\uDFAC",name:"SMIL/CSS animation"},scripting:{icon:"J",emoji:"\uD83D\uDCDC",name:"JavaScript"},events:{icon:"E",emoji:"\uD83D\uDDB1️",name:"Event handlers"},media:{icon:"M",emoji:"\uD83D\uDD0A",name:"Audio/Video"},html:{icon:"H",emoji:"\uD83D\uDCC4",name:"foreignObject"},images:{icon:"I",emoji:"\uD83D\uDDBC️",name:"External images"},fonts:{icon:"T",emoji:"\uD83D\uDD24",name:"External fonts"},sprites:{icon:"U",emoji:"\uD83C\uDFAF",name:"use elements"},links:{icon:"L",emoji:"\uD83D\uDD17",name:"Hyperlinks"}},F=Q.length*q.length,_=H.length*W.length*z.length,U=Z?18:28,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+Q.length*(M+1),k="".padEnd(25)+"│";for(let N of Q){let
|
|
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(Q.length*
|
|
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 N of $.detectedCapabilities||[]){let
|
|
72
|
-
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let d={animation:{Chrome:"Full SMIL support",IE11:"NO SMIL SUPPORT",Safari:"Full support"},media:{ALL:"Autoplay blocked - needs user gesture",iOS:"VERY strict autoplay policy"},html:{IE11:"No scripting in foreignObject",Cairo:"Not rendered",ImageMagick:"Not rendered"},scripting:{IE11:"Limited ES6 support"},effects:{IE11:"Limited filter support, no blend modes"}};for(let[N,
|
|
67
|
+
`);let M=q.length*U,X=26+Q.length*(M+1),k="".padEnd(25)+"│";for(let N of Q){let u=`${N.label} (${N.desc})`;k+=u.padStart(Math.floor(M/2)+Math.floor(u.length/2)).padEnd(M)+"│"}console.log("┌"+"─".repeat(25)+"┬"+Q.map(()=>"─".repeat(M)).join("┬")+"┐"),console.log("│"+"SYNTAX →".padEnd(25)+k.substring(26));let w="".padEnd(25)+"│";for(let N of Q){for(let u of q){let B=`${u.label}`;w+=B.padStart(Math.floor(U/2)+Math.floor(B.length/2)).padEnd(U)}w+="│"}console.log("│"+"STORAGE →".padEnd(25)+w.substring(26));let R="".padEnd(25)+"│";for(let N of Q){for(let u of q)R+="Brws|Func".padStart(Math.floor(U/2)+5).padEnd(U);R+="│"}console.log("│"+"".padEnd(25)+R.substring(26)),console.log("├"+"─".repeat(25)+"┼"+Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼")+"┤");let I=(N,u,B,t,i)=>{let l={browserStatus:{},funcStatus:{},overallStatus:"ok",issueCount:0,browserCount:0};for(let e of j){l.browserStatus[e.id]={};for(let[$0]of Object.entries(G))l.browserStatus[e.id][$0]="ok"}for(let[e]of Object.entries(G))l.funcStatus[e]="ok";if(t==="img"||t==="css"){let e=["animation","scripting","events","html","media","links"];for(let $0 of e){l.funcStatus[$0]="block";for(let Q0 of j)l.browserStatus[Q0.id][$0]="block"}if(B==="remote"){l.funcStatus.images="block",l.funcStatus.fonts="block";for(let $0 of j)l.browserStatus[$0.id].images="block",l.browserStatus[$0.id].fonts="block"}}if(N==="renderer"){let e=["animation","scripting","events","media"];for(let $0 of e){l.funcStatus[$0]="block";for(let Q0 of j)l.browserStatus[Q0.id][$0]="block"}l.funcStatus.html="block";for(let $0 of j)l.browserStatus[$0.id].html="block"}if(i==="noscript"){l.funcStatus.scripting="block",l.funcStatus.events="warn";for(let e of j)l.browserStatus[e.id].scripting="block",l.browserStatus[e.id].events="warn"}if(l.browserStatus.ie11.animation="block",l.browserStatus.ie11.html="block",l.browserStatus.ie11.sprites="warn",$.detectedCapabilities?.some((e)=>e.startsWith("AUDIO_")||e.startsWith("VIDEO_"))){for(let e of j)if(l.browserStatus[e.id].media!=="block")l.browserStatus[e.id].media="warn";l.browserStatus.ios.media="block",l.funcStatus.media="warn"}if(B==="remote"){l.funcStatus.images=l.funcStatus.images==="block"?"block":"warn",l.funcStatus.fonts=l.funcStatus.fonts==="block"?"block":"warn",l.funcStatus.sprites=l.funcStatus.sprites==="block"?"block":"warn";for(let e of j){if(l.browserStatus[e.id].images!=="block")l.browserStatus[e.id].images="warn";if(l.browserStatus[e.id].fonts!=="block")l.browserStatus[e.id].fonts="warn"}}if(u==="file"){if(B==="remote")l.funcStatus.images="warn",l.funcStatus.fonts="warn",l.funcStatus.links="warn"}if(u==="data"){if(B==="remote"||B==="local")l.funcStatus.images="warn",l.funcStatus.fonts="warn"}let q0=!1,f=!1,A=new Set;for(let[e,$0]of Object.entries(l.funcStatus))if($0==="block")q0=!0,l.issueCount++;else if($0==="warn")f=!0,l.issueCount++;for(let e of j)for(let[$0,Q0]of Object.entries(l.browserStatus[e.id]))if(Q0!=="ok")A.add(e.id);return l.browserCount=A.size,l.overallStatus=q0?"block":f?"warn":"ok",l},P=(N,u)=>{let B=[],t={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return B.push("✅ ALL OK".padStart(Math.floor(u/2)+5).padEnd(u)),B.push("".padEnd(u)),B;let i="";for(let q0 of j){let f="ok";for(let[A,e]of Object.entries(N.browserStatus[q0.id]))if(e==="block"){f="block";break}else if(e==="warn"&&f!=="block")f="warn";i+=`${q0.code}${t[f]}`}B.push(i.padStart(Math.floor(u/2)+Math.floor(i.length/2)).padEnd(u));let l="";for(let[q0,f]of Object.entries(G)){let A=N.funcStatus[q0];if(A!=="ok")l+=`${f.icon}${t[A]}`}if(l==="")l="(ok)";return B.push(l.padStart(Math.floor(u/2)+Math.floor(l.length/2)).padEnd(u)),B},y=(N,u)=>{let B={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return"✅".padStart(Math.floor(u/2)+1).padEnd(u);let t=N.overallStatus==="block"?"❌":"⚠️",i=`${N.browserCount}B`,l=`${N.issueCount}F`,q0=`${t}${i}${l}`;return q0.padStart(Math.floor(u/2)+Math.floor(q0.length/2)).padEnd(u)};for(let N of H){let u=Q.map(()=>q.map(()=>" ".repeat(U)).join(" ")).join("│");console.log("│ "+(N.label+":").padEnd(23)+"│"+u+"│");for(let B of W){for(let t of z){let i=[];for(let $0 of Q)for(let Q0 of q){let V0=I(N.id,B.id,Q0.id,$0.id,t.id);i.push(V0)}let l=i.map(($0)=>P($0,U)),f="│"+` ${B.label} ${t.label}`.padEnd(25)+"│",A=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<q.length;Q0++)f+=l[A][0],A++;f+="│"}console.log(f.substring(0,f.length-1));let e="│"+"".padEnd(25)+"│";A=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<q.length;Q0++)e+=l[A][1],A++;e+="│"}if(console.log(e.substring(0,e.length-1)),t!==z[z.length-1]){let $0=Q.map(()=>q.map(()=>"·".repeat(U)).join("·")).join("│");console.log("│"+"·".repeat(25)+"│"+$0+"│")}}if(B!==W[W.length-1]){let t=Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┼");console.log("├"+"─".repeat(25)+"┼"+t+"┤")}}if(N!==H[H.length-1]){let B=Q.map(()=>q.map(()=>"═".repeat(U)).join("═")).join("╪");console.log("╞"+"═".repeat(25)+"╪"+B+"╡")}}console.log("└"+"─".repeat(25)+"┴"+Q.map(()=>q.map(()=>"─".repeat(U)).join("─")).join("┴")+"┘"),console.log(`
|
|
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[N,u]of Object.entries(G))g+=`${u.icon}=${N} `;console.log(g.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FULL FUNCTIONALITY NAMES:"+" ".repeat(94)+"│");let b="│ ";for(let[N,u]of Object.entries(G))b+=`${u.icon}=${u.name} `;if(b.length>120)console.log(b.substring(0,121)+"│"),b="│ "+b.substring(121);console.log(b.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ EXAMPLES:"+" ".repeat(110)+"│"),console.log('│ "C✓F✓S✓E⚠I✗i✗A✓" = Chrome/Firefox/Safari/Android OK, Edge warning, IE11/iOS blocked'+" ".repeat(30)+"│"),console.log('│ "A✗J✗M⚠H✗" = Animation blocked, Scripting blocked, Media warning, HTML blocked'+" ".repeat(37)+"│"),console.log("└"+"─".repeat(120)+"┘"),console.log(`
|
|
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,E="".padEnd(30)+"│";for(let N of Q)E+=N.label.padStart(D-1).padEnd(D);E+="│",console.log(`
|
|
70
|
+
┌`+"─".repeat(30)+"┬"+"─".repeat(Q.length*D)+"┐"),console.log("│"+"RESOURCE TYPE".padEnd(30)+E.substring(31)),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(Q.length*D)+"┤");let m=(N,u)=>{if(u==="img"||u==="css"){if(N.includes("external")||N.includes("remote")||N.includes("scripts")||N.includes("audio"))return"❌";if(N.includes("local")&&!N.includes("embedded"))return"⚠️"}if(u==="object"||u==="embed"){if(N.includes("remote")&&!N.includes("embedded"))return"⚠️"}if(N.includes("embedded")||N.includes("inline"))return"✅";if(N.includes("local"))return"⚠️";if(N.includes("remote")||N.includes("external"))return"⚠️";return"✅"};for(let N of x){let u=`│ ${N.icon} ${N.label}`.padEnd(31)+"│";for(let B of Q){let t=m(N.id,B.id);u+=t.padStart(D-1).padEnd(D)}u+="│",console.log(u)}console.log("└"+"─".repeat(30)+"┴"+"─".repeat(Q.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 N of $.detectedCapabilities||[]){let u={RENDER_:"display",FONTS_:"fonts",IMAGES_:"images",FILTERS_:"effects",MASKS:"effects",CLIP_:"effects",SMIL_:"animation",CSS_:"animation",SCRIPT_:"scripting",EVENT_:"events",LINK_:"links",FOREIGNOBJECT_:"html",AUDIO_:"media",VIDEO_:"media",USE_:"sprites",A11Y_:"accessibility",META_:"metadata"};for(let[B,t]of Object.entries(u))if(N.startsWith(B)||N===B.replace("_","")){if(!c[t])c[t]=[];c[t].push(N);break}}console.log(`
|
|
72
|
+
┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let d={animation:{Chrome:"Full SMIL support",IE11:"NO SMIL SUPPORT",Safari:"Full support"},media:{ALL:"Autoplay blocked - needs user gesture",iOS:"VERY strict autoplay policy"},html:{IE11:"No scripting in foreignObject",Cairo:"Not rendered",ImageMagick:"Not rendered"},scripting:{IE11:"Limited ES6 support"},effects:{IE11:"Limited filter support, no blend modes"}};for(let[N,u]of Object.entries(c)){let B=d[N]||{},t=Object.entries(B).map(([i,l])=>`${i}: ${l}`).join("; ")||"No known issues";console.log(`│ ${N.toUpperCase().padEnd(18)} │ ${t.substring(0,97).padEnd(97)} │`)}return console.log("└"+"─".repeat(20)+"┴"+"─".repeat(99)+"┘"),console.log(`
|
|
73
73
|
`+"═".repeat(140)+`
|
|
74
|
-
`),$}function dW($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(t)=>String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Q=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],q=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],H=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],W=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],z=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],j=(t,i,l,q0)=>{let f=[],A=(e)=>f.push({text:e});if(q0==="img"||q0==="css")return A("No scripts"),A("No events"),A("No audio/video"),A("No links"),A("No foreignObject"),A("No external resources"),f;if(l==="nojs")A("No scripts"),A("No event handlers");if(i==="file")A("No remote fonts (Chrome, Safari)"),A("No remote images (Chrome)"),A("No fetch/XHR to remote URLs");if(q0==="object"||q0==="embed"){if(A("No event bubbling to parent"),i==="http")A("No cross-origin script access")}if(t==="desktop"){if(A("No SMIL (IE11 only)"),A("No CSS variables (IE11 only)"),l==="js")A("Audio: blocked until user click/tap event"),A("Audio: once blocked, won't auto-retry")}if(t==="mobile")A("No hover/mouseover events"),A("Audio: blocked until user tap event"),A("Audio: once blocked, won't auto-retry"),A("Video autoplay blocked");return f},G=0;for(let t of q)for(let i of W)for(let l of z)for(let q0 of Q){let f=j(t.id,i.id,l.id,q0.id).length;if(f>G)G=f}let F=130,_=80,U=90,Y=F+_+U,V=60,M=220,X=13,k=Math.max(80,(G+1)*X+25),w=Q.length,R=q.length*W.length*z.length,I=Y+w*M,
|
|
74
|
+
`),$}function dW($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(t)=>String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Q=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],q=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],H=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],W=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],z=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],j=(t,i,l,q0)=>{let f=[],A=(e)=>f.push({text:e});if(q0==="img"||q0==="css")return A("No scripts"),A("No events"),A("No audio/video"),A("No links"),A("No foreignObject"),A("No external resources"),f;if(l==="nojs")A("No scripts"),A("No event handlers");if(i==="file")A("No remote fonts (Chrome, Safari)"),A("No remote images (Chrome)"),A("No fetch/XHR to remote URLs");if(q0==="object"||q0==="embed"){if(A("No event bubbling to parent"),i==="http")A("No cross-origin script access")}if(t==="desktop"){if(A("No SMIL (IE11 only)"),A("No CSS variables (IE11 only)"),l==="js")A("Audio: blocked until user click/tap event"),A("Audio: once blocked, won't auto-retry")}if(t==="mobile")A("No hover/mouseover events"),A("Audio: blocked until user tap event"),A("Audio: once blocked, won't auto-retry"),A("Video autoplay blocked");return f},G=0;for(let t of q)for(let i of W)for(let l of z)for(let q0 of Q){let f=j(t.id,i.id,l.id,q0.id).length;if(f>G)G=f}let F=130,_=80,U=90,Y=F+_+U,V=60,M=220,X=13,k=Math.max(80,(G+1)*X+25),w=Q.length,R=q.length*W.length*z.length,I=Y+w*M,y=V+R*k+40,g=30,b=40+H.length*g,x=y+b+30,D=1020,E=I+50,m=55+x+D+50,c=`<?xml version="1.0" encoding="UTF-8"?>
|
|
75
75
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${E} ${m}" preserveAspectRatio="xMinYMin meet" height="${m}" width="100%">
|
|
76
76
|
<title>SVG Compatibility Matrix</title>
|
|
77
77
|
|
|
@@ -105,24 +105,24 @@ ${H}
|
|
|
105
105
|
`;for(let t=1;t<Q.length;t++){let i=Q[t];c+=` <rect x="${d}" y="25" width="${M}" height="${V-25}" fill="${i.color}" stroke="#1976D2"/>
|
|
106
106
|
<text x="${d+M/2}" y="42" text-anchor="middle" class="col-header">${K(i.name)}</text>
|
|
107
107
|
<text x="${d+M/2}" y="55" text-anchor="middle" class="col-desc">${K(i.desc)}</text>
|
|
108
|
-
`,d+=M}let
|
|
109
|
-
<text x="${F/2}" y="${
|
|
110
|
-
`;for(let l of W){let q0=z.length*k;c+=` <rect x="${F}" y="${
|
|
111
|
-
<text x="${F+_/2}" y="${
|
|
112
|
-
`;for(let f of z){c+=` <rect x="${F+_}" y="${
|
|
113
|
-
<text x="${F+_+U/2}" y="${
|
|
114
|
-
`,d=Y;for(let A of Q){let e=j(t.id,l.id,f.id,A.id),$0="cell-ok";if(e.length>=4)$0="cell-bad";else if(e.length>0)$0="cell-warn";if(c+=` <rect x="${d}" y="${
|
|
115
|
-
`,e.length===0)c+=` <text x="${d+M/2}" y="${
|
|
116
|
-
<text x="${d+M/2}" y="${
|
|
117
|
-
`;else{let Q0=
|
|
118
|
-
`,Q0+=X}}d+=M}
|
|
108
|
+
`,d+=M}let u=V;for(let t of q){let i=W.length*z.length*k;c+=` <rect x="0" y="${u}" width="${F}" height="${i}" fill="${t.color}" stroke="#999"/>
|
|
109
|
+
<text x="${F/2}" y="${u+i/2+4}" text-anchor="middle" class="row-label-bold">${K(t.name)}</text>
|
|
110
|
+
`;for(let l of W){let q0=z.length*k;c+=` <rect x="${F}" y="${u}" width="${_}" height="${q0}" fill="${l.color}" stroke="#CCC"/>
|
|
111
|
+
<text x="${F+_/2}" y="${u+q0/2+4}" text-anchor="middle" class="row-label">${K(l.name)}</text>
|
|
112
|
+
`;for(let f of z){c+=` <rect x="${F+_}" y="${u}" width="${U}" height="${k}" fill="${f.color}" stroke="#DDD"/>
|
|
113
|
+
<text x="${F+_+U/2}" y="${u+k/2+4}" text-anchor="middle" class="row-label">${K(f.name)}</text>
|
|
114
|
+
`,d=Y;for(let A of Q){let e=j(t.id,l.id,f.id,A.id),$0="cell-ok";if(e.length>=4)$0="cell-bad";else if(e.length>0)$0="cell-warn";if(c+=` <rect x="${d}" y="${u}" width="${M}" height="${k}" class="${$0}" stroke="#DDD"/>
|
|
115
|
+
`,e.length===0)c+=` <text x="${d+M/2}" y="${u+k/2-5}" text-anchor="middle" class="ok-text">No issues</text>
|
|
116
|
+
<text x="${d+M/2}" y="${u+k/2+12}" text-anchor="middle" class="problem-text" style="fill:#388E3C">Everything works</text>
|
|
117
|
+
`;else{let Q0=u+16;for(let V0 of e){let N0=`• ${V0.text||"Unknown issue"}`;c+=` <text x="${d+8}" y="${Q0}" class="problem-text">${K(N0)}</text>
|
|
118
|
+
`,Q0+=X}}d+=M}u+=k}}c+=` <line x1="0" y1="${u}" x2="${I}" y2="${u}" stroke="#999" stroke-width="2"/>
|
|
119
119
|
`}c+=`
|
|
120
|
-
<text x="0" y="${
|
|
121
|
-
`;let B=
|
|
120
|
+
<text x="0" y="${y}" class="legend-title">SERVER-SIDE SVG RENDERERS (no HTML embedding)</text>
|
|
121
|
+
`;let B=y+20;for(let t of H){c+=` <rect x="0" y="${B}" width="150" height="${g-4}" fill="${t.color}" stroke="#999"/>
|
|
122
122
|
<text x="10" y="${B+18}" class="row-label-bold">${K(t.name)}</text>
|
|
123
123
|
`;let i=t.issues.join(" • ");c+=` <text x="160" y="${B+18}" class="problem-text">${K(i)}</text>
|
|
124
|
-
`,B+=
|
|
125
|
-
<g transform="translate(0, ${
|
|
124
|
+
`,B+=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,7 +210,7 @@ ${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 qK($){let{title:J="Data Table",subtitle:Z="",columns:K=[],rowLevels:Q=[],rowData:q=[],getCellContent:H=()=>({lines:[],status:"ok"}),legend:W=null,additionalSections:z=[],options:j={}}=$,G={fontFamily:j.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:j.minCellWidth||150,maxCellWidth:j.maxCellWidth||300,minCellHeight:j.minCellHeight||60,cellPaddingX:j.cellPaddingX||8,cellPaddingY:j.cellPaddingY||12,titleFontSize:j.titleFontSize||20,subtitleFontSize:j.subtitleFontSize||12,headerFontSize:j.headerFontSize||12,cellFontSize:j.cellFontSize||10,lineHeight:j.lineHeight||13,titleColor:j.titleColor||"#1a1a1a",subtitleColor:j.subtitleColor||"#666",borderColor:j.borderColor||"#DDD",okColor:j.okColor||"#C8E6C9",warnColor:j.warnColor||"#FFF9C4",badColor:j.badColor||"#FFCDD2",okTextColor:j.okTextColor||"#2E7D32",colHeaderHeight:j.colHeaderHeight||60,marginTop:j.marginTop||55,marginLeft:j.marginLeft||25,marginRight:j.marginRight||25,marginBottom:j.marginBottom||50,sectionSpacing:j.sectionSpacing||40,groupHeaderHeight:j.groupHeaderHeight||25,groupHeaderColor:j.groupHeaderColor||"#0D47A1"},F=(f)=>String(f).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),_=(f,A=0,e=[])=>{let $0=[];for(let Q0 of f){let V0=[...e,{level:A,...Q0}];if(Q0.children&&Q0.children.length>0&&A<Q.length-1)$0.push(..._(Q0.children,A+1,V0));else $0.push(V0)}return $0},U=_(q[0]||[]),Y=U.length,V=Q.length,M=Q.map((f,A)=>{if(f.width)return f.width;let e=f.name.length,$0=(Q0,V0)=>{for(let N0 of Q0){if(V0===A)e=Math.max(e,(N0.name||"").length);if(N0.children)$0(N0.children,V0+1)}};return $0(q[0]||[],0),Math.max(60,e*7+20)}),X=M.reduce((f,A)=>f+A,0),k=0,w=0;for(let f of U)for(let A of K){let $0=H(f,A.id).lines||[];k=Math.max(k,$0.length);for(let Q0 of $0)w=Math.max(w,Q0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,w*6+G.cellPaddingX*2)),I=Math.max(G.minCellHeight,(k+1)*G.lineHeight+G.cellPaddingY*2),P=[],
|
|
213
|
+
</svg>`,c}function qK($){let{title:J="Data Table",subtitle:Z="",columns:K=[],rowLevels:Q=[],rowData:q=[],getCellContent:H=()=>({lines:[],status:"ok"}),legend:W=null,additionalSections:z=[],options:j={}}=$,G={fontFamily:j.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:j.minCellWidth||150,maxCellWidth:j.maxCellWidth||300,minCellHeight:j.minCellHeight||60,cellPaddingX:j.cellPaddingX||8,cellPaddingY:j.cellPaddingY||12,titleFontSize:j.titleFontSize||20,subtitleFontSize:j.subtitleFontSize||12,headerFontSize:j.headerFontSize||12,cellFontSize:j.cellFontSize||10,lineHeight:j.lineHeight||13,titleColor:j.titleColor||"#1a1a1a",subtitleColor:j.subtitleColor||"#666",borderColor:j.borderColor||"#DDD",okColor:j.okColor||"#C8E6C9",warnColor:j.warnColor||"#FFF9C4",badColor:j.badColor||"#FFCDD2",okTextColor:j.okTextColor||"#2E7D32",colHeaderHeight:j.colHeaderHeight||60,marginTop:j.marginTop||55,marginLeft:j.marginLeft||25,marginRight:j.marginRight||25,marginBottom:j.marginBottom||50,sectionSpacing:j.sectionSpacing||40,groupHeaderHeight:j.groupHeaderHeight||25,groupHeaderColor:j.groupHeaderColor||"#0D47A1"},F=(f)=>String(f).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),_=(f,A=0,e=[])=>{let $0=[];for(let Q0 of f){let V0=[...e,{level:A,...Q0}];if(Q0.children&&Q0.children.length>0&&A<Q.length-1)$0.push(..._(Q0.children,A+1,V0));else $0.push(V0)}return $0},U=_(q[0]||[]),Y=U.length,V=Q.length,M=Q.map((f,A)=>{if(f.width)return f.width;let e=f.name.length,$0=(Q0,V0)=>{for(let N0 of Q0){if(V0===A)e=Math.max(e,(N0.name||"").length);if(N0.children)$0(N0.children,V0+1)}};return $0(q[0]||[],0),Math.max(60,e*7+20)}),X=M.reduce((f,A)=>f+A,0),k=0,w=0;for(let f of U)for(let A of K){let $0=H(f,A.id).lines||[];k=Math.max(k,$0.length);for(let Q0 of $0)w=Math.max(w,Q0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,w*6+G.cellPaddingX*2)),I=Math.max(G.minCellHeight,(k+1)*G.lineHeight+G.cellPaddingY*2),P=[],y=null;for(let f=0;f<K.length;f++){let A=K[f];if(A.group)if(!y||y.name!==A.group)y={name:A.group,startIndex:f,count:1,color:A.groupColor||G.groupHeaderColor},P.push(y);else y.count++;else y=null}let g=P.length>0,b=g?G.colHeaderHeight+G.groupHeaderHeight:G.colHeaderHeight,x=X+K.length*R,D=b+Y*I,E=0;for(let f of z)E+=G.sectionSpacing+(f.height||100);let m=W?j.legendHeight||200:0,c=x+G.marginLeft+G.marginRight,d=G.marginTop+D+E+(W?G.sectionSpacing+m:0)+G.marginBottom,N=`<?xml version="1.0" encoding="UTF-8"?>
|
|
214
214
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${d}" preserveAspectRatio="xMinYMin meet" height="${d}" width="100%">
|
|
215
215
|
<title>${F(J)}</title>
|
|
216
216
|
|
|
@@ -236,18 +236,18 @@ ${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
|
-
`,
|
|
239
|
+
`,u=X;if(g){let f=0;for(let A=0;A<K.length&&!K[A].group;A++)f++;for(let A of P){let e=X+A.startIndex*R,$0=A.count*R;N+=` <rect x="${e}" y="0" width="${$0}" height="${G.groupHeaderHeight}" fill="${A.color}"/>
|
|
240
240
|
<text x="${e+$0/2}" y="${G.groupHeaderHeight-8}" text-anchor="middle" class="col-header">${F(A.name)}</text>
|
|
241
|
-
`}}let B=
|
|
241
|
+
`}}let B=g?G.groupHeaderHeight:0,t=g?G.colHeaderHeight:b;for(let f=0;f<K.length;f++){let A=K[f],e=X+f*R,$0=A.group?B:0,Q0=A.group?t:b;if(N+=` <rect x="${e}" y="${$0}" width="${R}" height="${Q0}" fill="${A.color}" stroke="${G.borderColor}"/>
|
|
242
242
|
<text x="${e+R/2}" y="${$0+Q0/2-5}" text-anchor="middle" class="col-header">${F(A.name)}</text>
|
|
243
243
|
`,A.desc)N+=` <text x="${e+R/2}" y="${$0+Q0/2+10}" text-anchor="middle" class="col-desc">${F(A.desc)}</text>
|
|
244
|
-
`}let i=new Map,l=b;for(let f=0;f<U.length;f++){let A=U[f],e=0;for(let $0=0;$0<V;$0++){let Q0=A.find((N0)=>N0.level===$0);if(!Q0){e+=M[$0];continue}let V0=`${$0}-${Q0.id}`;if(!i.has(V0)){let N0=1;for(let o=f+1;o<U.length;o++){let J0=U[o].find((_0)=>_0.level===$0);if(J0&&J0.id===Q0.id)N0++;else break}let
|
|
245
|
-
<text x="${e+M[$0]/2}" y="${l+
|
|
246
|
-
`,i.set(V0,{y:l,height:
|
|
247
|
-
`,
|
|
248
|
-
`;else{let _0=l+G.cellPaddingY+G.lineHeight;for(let
|
|
249
|
-
`,_0+=G.lineHeight}}if(l+=I,f<U.length-1){let $0=A[0]?.id,Q0=U[f+1][0]?.id;if($0!==Q0)N+=` <line x1="0" y1="${l}" x2="${
|
|
250
|
-
`}}let q0=
|
|
244
|
+
`}let i=new Map,l=b;for(let f=0;f<U.length;f++){let A=U[f],e=0;for(let $0=0;$0<V;$0++){let Q0=A.find((N0)=>N0.level===$0);if(!Q0){e+=M[$0];continue}let V0=`${$0}-${Q0.id}`;if(!i.has(V0)){let N0=1;for(let o=f+1;o<U.length;o++){let J0=U[o].find((_0)=>_0.level===$0);if(J0&&J0.id===Q0.id)N0++;else break}let y0=N0*I;N+=` <rect x="${e}" y="${l}" width="${M[$0]}" height="${y0}" fill="${Q0.color||"#F5F5F5"}" stroke="${G.borderColor}"/>
|
|
245
|
+
<text x="${e+M[$0]/2}" y="${l+y0/2+4}" text-anchor="middle" class="${$0===0?"row-label-bold":"row-label"}">${F(Q0.name)}</text>
|
|
246
|
+
`,i.set(V0,{y:l,height:y0})}e+=M[$0]}for(let $0=0;$0<K.length;$0++){let Q0=K[$0],V0=X+$0*R,N0=H(A,Q0.id),y0=N0.lines||[],o=N0.status||"ok";if(N+=` <rect x="${V0}" y="${l}" width="${R}" height="${I}" class="${o==="bad"?"cell-bad":o==="warn"?"cell-warn":"cell-ok"}" stroke="${G.borderColor}"/>
|
|
247
|
+
`,y0.length===0)N+=` <text x="${V0+R/2}" y="${l+I/2}" text-anchor="middle" class="ok-text">No issues</text>
|
|
248
|
+
`;else{let _0=l+G.cellPaddingY+G.lineHeight;for(let O0 of y0)N+=` <text x="${V0+G.cellPaddingX}" y="${_0}" class="cell-text">${F("• "+O0)}</text>
|
|
249
|
+
`,_0+=G.lineHeight}}if(l+=I,f<U.length-1){let $0=A[0]?.id,Q0=U[f+1][0]?.id;if($0!==Q0)N+=` <line x1="0" y1="${l}" x2="${x}" y2="${l}" stroke="#999" stroke-width="2"/>
|
|
250
|
+
`}}let q0=D+G.sectionSpacing;for(let f of z){if(f.title)N+=`
|
|
251
251
|
<text x="0" y="${q0}" class="section-title">${F(f.title)}</text>
|
|
252
252
|
`,q0+=20;if(f.content)N+=` <g transform="translate(0, ${q0})">
|
|
253
253
|
${f.content}
|
|
@@ -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 K=[],Q=/<!\[CDATA\[([\s\S]*?)\]\]>/g,q;while((q=Q.exec($))!==null)K.push({start:q.index,end:q.index+q[0].length});let H=/<!--[\s\S]*?-->/g,W;while((W=H.exec($))!==null)K.push({start:W.index,end:W.index+W[0].length});let z=/<script[^>]*>([\s\S]*?)<\/script>/gi,j;while((j=z.exec($))!==null){let X=j.index+j[0].indexOf(">")+1,k=j.index+j[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}let G=/<style[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=G.exec($))!==null){let X=F.index+F[0].indexOf(">")+1,k=F.index+F[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}K.sort((X,k)=>X.start-k.start);let _=(X)=>{for(let k of K){if(X>=k.start&&X<k.end)return!0;if(k.start>X)break}return!1},U=(X)=>{let k=1;for(let I=0;I<J.lines.length;I++){if(J.lines[I]>X){k=I;break}k=I+1}let w=J.lines[k-1]||0,R=X-w+1;return{line:k,column:R}},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],w=M.index,R=M.index+M[0].length,{line:I,column:P}=U(w),
|
|
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(`
|
|
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 T0=C0.substring(1);if(!z.has(T0)){let w7=Y(T0);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)},y=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,g=new Set(["points","viewBox","preserveAspectRatio","transform","d","values","keyTimes","keySplines","keyPoints","rotate","stroke-dasharray","baseFrequency","kernelMatrix","tableValues","filterRes","stdDeviation","radius","origin"]),b=(S)=>{for(let C of S.getAttributeNames()){if(!g.has(C)&&C!=="style")continue;let n=S.getAttribute(C);if(!n)continue;if(y.test(n)){let p=n.replace(y," ");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)},x=(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))x(C)},D=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>D||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)},u={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=u[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"],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"]},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 T0 of L0.children)if(a(T0))n(T0)};n(S);let p=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,s=/^#(.+)$/,G0=(L0)=>{let C0=L0.tagName.toLowerCase();for(let T0 of L0.getAttributeNames()){let w7=L0.getAttribute(T0),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:T0,refId:g7,reason:`Broken reference: url(#${g7}) points to non-existent ID`})}if(T0==="href"||T0==="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:T0,refId:L$,reason:`Broken reference: ${T0}="#${L$}" points to non-existent ID`})}}}for(let T0 of L0.children)if(a(T0))G0(T0)};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"]),y0=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(y0.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 T0=0;T0<G0.length;T0++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(G0[T0])){W.push({type:"malformed_viewbox",element:C,value:s,reason:`viewBox contains invalid number '${G0[T0]}' at position ${T0+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)},O0=(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))O0(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))O0(G0)}else for(let s of Array.from(S.children))if(a(s))O0(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 T0 of L0.children)if(a(T0))p(T0)};p(S);let s=new Set,G0=(L0)=>{let C0=L0.getAttribute("id");if(C0)if(s.has(C0)){let T0=C0,w7=2;while(n.has(T0)||s.has(T0))T0=`${C0}_${w7++}`;L0.setAttribute("id",T0),n.add(T0),s.add(T0),W.push({type:"duplicate_id_renamed",oldId:C0,newId:T0,element:L0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${C0}' -> '${T0}'`})}else s.add(C0);for(let T0 of L0.children)if(a(T0))G0(T0)};G0(S)};if(_($),U(),V($),M($),w($),P($),b($),x($),O0($),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 $}),E0={ERROR:"error",WARNING:"warning"},cW={broken_reference:E0.ERROR,broken_url_reference:E0.ERROR,duplicate_id:E0.ERROR,missing_required_attribute:E0.ERROR,invalid_child_element:E0.ERROR,animation_in_empty_element:E0.ERROR,malformed_viewbox:E0.ERROR,malformed_points:E0.ERROR,malformed_transform:E0.ERROR,invalid_enum_value:E0.ERROR,invalid_numeric_constraint:E0.ERROR,invalid_attr_on_element:E0.WARNING,missing_namespace:E0.WARNING,invalid_timing:E0.WARNING,uppercase_unit:E0.WARNING,invalid_whitespace:E0.WARNING,invalid_number:E0.WARNING,mistyped_element_detected:E0.WARNING,unknown_element_detected:E0.WARNING,mistyped_attribute_detected:E0.WARNING,unknown_attribute_detected:E0.WARNING,invalid_color:E0.WARNING,circular_reference:E0.WARNING,deep_nesting:E0.WARNING,empty_defs:E0.WARNING,gradient_stop_order:E0.WARNING,path_complexity:E0.WARNING,external_resource:E0.WARNING,script_content:E0.WARNING,event_handler:E0.WARNING,missing_title:E0.WARNING,missing_desc:E0.WARNING,invalid_aria:E0.WARNING,missing_lang:E0.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 K=[],Q=/<!\[CDATA\[([\s\S]*?)\]\]>/g,q;while((q=Q.exec($))!==null)K.push({start:q.index,end:q.index+q[0].length});let H=/<!--[\s\S]*?-->/g,W;while((W=H.exec($))!==null)K.push({start:W.index,end:W.index+W[0].length});let z=/<script[^>]*>([\s\S]*?)<\/script>/gi,j;while((j=z.exec($))!==null){let X=j.index+j[0].indexOf(">")+1,k=j.index+j[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}let G=/<style[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=G.exec($))!==null){let X=F.index+F[0].indexOf(">")+1,k=F.index+F[0].lastIndexOf("<");if(k>X)K.push({start:X,end:k})}K.sort((X,k)=>X.start-k.start);let _=(X)=>{for(let k of K){if(X>=k.start&&X<k.end)return!0;if(k.start>X)break}return!1},U=(X)=>{let k=1;for(let I=0;I<J.lines.length;I++){if(J.lines[I]>X){k=I;break}k=I+1}let w=J.lines[k-1]||0,R=X-w+1;return{line:k,column:R}},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],w=M.index,R=M.index+M[0].length,{line:I,column:P}=U(w),y=k?M[0].indexOf(k):0,g=new Map;V.lastIndex=0;let b;while((b=V.exec(k))!==null){let x=b[1],D=b[2],E=w+y+b.index,m=U(E);g.set(x.toLowerCase(),{name:x,value:D,line:m.line,column:m.column})}if(!J.elements.has(X))J.elements.set(X,[]);J.elements.get(X).push({line:I,column:P,endColumn:P+M[0].length-1,attrs:g})}return J.getElementPosition=(X,k=0)=>{let w=J.elements.get(X.toLowerCase());if(w&&w[k]){let R=w[k];return{line:R.line,column:R.column}}return{line:1,column:1}},J.getAttributePosition=(X,k,w=0)=>{let R=J.elements.get(X.toLowerCase());if(R&&R[w]){let I=R[w],P=I.attrs.get(k.toLowerCase());if(P)return{line:P.line,column:P.column};return{line:I.line,column:I.column}}return{line:1,column:1}},J}async function oW($,J={}){PW();let Z=J.errorsOnly===!0,K=J.outputFile||null,Q=(J.outputFormat||"json").toLowerCase(),q=J.includeSource===!0,H=["text","json","xml","yaml"];if(K&&!H.includes(Q))throw new Error(`Invalid outputFormat '${Q}'. Must be one of: ${H.join(", ")}`);let W="",z;try{if(z=w$($),z===h0.SVG_STRING)W=$;else if(z===h0.FILE_PATH){let v=await import("node:fs/promises"),r=(await Promise.resolve().then(() => (O$(),V$))).normalize($);try{W=await v.readFile(r,"utf8")}catch(h){throw new Error(`Failed to read file '${$}': ${h.message}`)}}else if(z===h0.URL)try{let v=await fetch($);if(!v.ok)throw new Error(`HTTP ${v.status}: ${v.statusText}`);W=await v.text()}catch(v){throw new Error(`Failed to fetch URL '${$}': ${v.message}`)}else if(z===h0.DOM_ELEMENT)if(typeof XMLSerializer!=="undefined")W=new XMLSerializer().serializeToString($);else if($.outerHTML)W=$.outerHTML;else throw new Error("Cannot serialize DOM element: XMLSerializer not available");else throw new Error(`Unknown input type: ${typeof $}`)}catch(v){return{issues:[{type:"input_error",severity:E0.ERROR,reason:v.message,line:0,column:0}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{input_error:1}}}let j=q?W.split(`
|
|
353
|
+
`):null,G=sW(W),F,_=[],U=(v)=>{let T=v.match(/line\s*:?\s*(\d+)/i)||v.match(/:(\d+):/);return T?parseInt(T[1],10):1},Y=(v)=>{let T=v.match(/column\s*:?\s*(\d+)/i)||v.match(/:\d+:(\d+)/);return T?parseInt(T[1],10):1},V=(v)=>{let T=v,r=[],h="_VALID_ENTITY_",Z0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,X0=T.replace(Z0,h+"$1;").replace(/&/g,"&").replace(new RegExp(h,"g"),"&");if(X0!==T)T=X0,r.push("Escaped unencoded ampersands");let b0=T.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(b0!==T)T=b0,r.push("Removed invalid control characters");if(T.charCodeAt(0)===65279)T=T.slice(1),r.push("Removed UTF-8 BOM");let P0=T.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(u0,J7,a0)=>{if(!a0.includes(">"))return`="${J7}<${a0}"`;return u0});if(P0!==T)T=P0,r.push("Escaped < in attribute values");return{fixed:T,appliedFixes:r}};try{F=await H6($,z)}catch(v){let T=v.message||String(v),r=U(T),h=Y(T),{fixed:Z0,appliedFixes:W0}=V(W);if(W0.length>0&&Z0!==W)try{let{JSDOM:j0}=await import("jsdom");F=new j0(Z0,{contentType:"image/svg+xml"}).window.document.documentElement,_.push({type:"parse_recovery",severity:E0.WARNING,reason:`Recovered from parse error. Applied fixes: ${W0.join("; ")}`,line:r,column:h}),_.push({type:"original_parse_error",severity:E0.ERROR,reason:`Original parse error: ${T}`,line:r,column:h})}catch(j0){return{issues:[{type:"parse_error",severity:E0.ERROR,reason:`Failed to parse SVG: ${T}`,line:r,column:h},{type:"recovery_failed",severity:E0.WARNING,reason:`Recovery attempted (${W0.join("; ")}) but still failed: ${j0.message}`,line:r,column:h}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:E0.ERROR,reason:`Failed to parse SVG: ${T}`,line:r,column:h}],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=(v)=>{let T=v.toLowerCase(),r=X.get(T)||0;return X.set(T,r+1),r},w=()=>{X.clear()},R=(v,T,r=null,h=null)=>{let Z0;if(r)Z0=G.getAttributePosition(T,r,h||0);else Z0=G.getElementPosition(T,h||0);let W0=cW[v.type]||E0.WARNING,j0={...v,severity:W0,line:Z0.line,column:Z0.column};if(q&&j&&Z0.line>0&&Z0.line<=j.length)j0.sourceLine=j[Z0.line-1];return j0},I=new Set,P=(v)=>{if(!v)return;let T=v.getAttribute("id");if(T)I.add(T);for(let r of v.children)if(a(r))P(r)};P(F);let y=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],g=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);if(T==="g"){for(let h of y)if(v.hasAttribute(h))M.push(R({type:"invalid_attr_on_element",element:T,attr:h,value:v.getAttribute(h),reason:`SVG 1.1: <g> elements do not support '${h}' attribute`},T,h,r))}for(let h of v.children)if(a(h))g(h)},b=()=>{let v=!1,T=null,r=null,h=(Z0)=>{for(let W0 of Z0.getAttributeNames())if(W0.startsWith("xlink:")){v=!0,T=Z0.tagName.toLowerCase(),r=W0;return}for(let W0 of Z0.children){if(a(W0))h(W0);if(v)return}};if(h(F),v&&!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})}},x=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of["xlink:href","href"]){let Z0=v.getAttribute(h);if(Z0&&Z0.startsWith("#")){let W0=Z0.slice(1);if(W0&&!I.has(W0))M.push(R({type:"broken_reference",element:T,attr:h,referencedId:W0,reason:`Reference to non-existent ID '${W0}'`},T,h,r))}}for(let h of v.children)if(a(h))x(h)},D=["begin","end","dur","repeatDur","min","max"],E=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),m=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);if(E.has(T))for(let h of D){let Z0=v.getAttribute(h);if(Z0){let W0=Z0.trim();if(W0!==Z0)M.push(R({type:"invalid_timing",element:T,attr:h,value:Z0,reason:"Timing value has leading/trailing whitespace"},T,h,r));if(/[;,]/.test(W0)&&!/^[\d\w\s.;,+-]+$/.test(W0))M.push(R({type:"invalid_timing",element:T,attr:h,value:Z0,reason:"Timing value may contain invalid characters"},T,h,r))}}for(let h of v.children)if(a(h))m(h)},c=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),d=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);if(c.has(T)){for(let h of v.children)if(a(h)){let Z0=h.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 h of v.children)if(a(h))d(h)},N=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,u=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],B=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of u){let Z0=v.getAttribute(h);if(Z0){let W0=Z0.match(N);if(W0)for(let j0 of W0){let X0=j0.replace(/[\d.]+/,"");if(X0!==X0.toLowerCase())M.push(R({type:"uppercase_unit",element:T,attr:h,value:Z0,reason:`Unit '${X0}' should be lowercase '${X0.toLowerCase()}'`},T,h,r))}}}for(let h of v.children)if(a(h))B(h)},t=["points","viewBox","d","values","keyTimes","keySplines","rotate"],i=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of t){let Z0=v.getAttribute(h);if(Z0){if(/[\t\n\r]/.test(Z0)||/ +/.test(Z0))M.push(R({type:"invalid_whitespace",element:T,attr:h,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},T,h,r))}}for(let h of v.children)if(a(h))i(h)},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=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of l){let Z0=v.getAttribute(h);if(Z0){let W0=Z0.trim();if(/^0\d/.test(W0.replace(/[a-z%]+$/i,"")))M.push(R({type:"invalid_number",element:T,attr:h,value:Z0,reason:"Number has unnecessary leading zeros"},T,h,r));if(/\.$/.test(W0.replace(/[a-z%]+$/i,"")))M.push(R({type:"invalid_number",element:T,attr:h,value:Z0,reason:"Number has trailing decimal point"},T,h,r))}}for(let h of v.children)if(a(h))q0(h)},f=(v,T=!1)=>{let r=v.tagName,h=r.toLowerCase(),Z0=k(h),W0=r.includes(":"),j0=v.namespaceURI&&v.namespaceURI!=="http://www.w3.org/2000/svg",X0=v.getAttribute?v.getAttribute("xmlns"):null,b0=X0&&X0!=="http://www.w3.org/2000/svg",P0=T||o5.has(h)||W0||j0||b0;if(!P0){if(!X$.has(r)&&!VJ.has(h)){if(!NW(h)){let u0=S$(r,X$);if(u0)M.push(R({type:"mistyped_element_detected",element:r,suggestion:u0,reason:`Unknown element <${r}> - did you mean <${u0}>?`},h,null,Z0));else M.push(R({type:"unknown_element_detected",element:r,reason:`Unknown element <${r}> - not in SVG 1.1 spec`},h,null,Z0))}}}for(let u0 of v.children)if(a(u0))f(u0,P0)},A=(v,T=!1)=>{let r=v.tagName.toLowerCase(),h=k(r),Z0=v.tagName.includes(":"),W0=v.namespaceURI&&v.namespaceURI!=="http://www.w3.org/2000/svg",j0=v.getAttribute?v.getAttribute("xmlns"):null,X0=j0&&j0!=="http://www.w3.org/2000/svg",b0=T||o5.has(r)||Z0||W0||X0;if(!b0)for(let P0 of v.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(IW(P0))continue;if(!k$.has(P0)&&!OJ.has(P0.toLowerCase())){let u0=S$(P0,k$);if(u0)M.push(R({type:"mistyped_attribute_detected",element:r,attr:P0,suggestion:u0,reason:`Unknown attribute '${P0}' - did you mean '${u0}'?`},r,P0,h));else M.push(R({type:"unknown_attribute_detected",element:r,attr:P0,reason:`Unknown attribute '${P0}' on <${r}> - not in SVG 1.1 spec`},r,P0,h))}}for(let P0 of v.children)if(a(P0))A(P0,b0)},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=(v)=>{let T=v.tagName.toLowerCase(),r=k(T),h=e[T];if(h&&h.length>0){if(h.includes("xlink:href")&&h.includes("href")){if(!v.hasAttribute("xlink:href")&&!v.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 h)if(!v.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 v.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=(v)=>{let T=v.tagName.toLowerCase(),r=k(T),h=Q0[T];if(h){for(let Z0 of v.children)if(a(Z0)){let W0=Z0.tagName.toLowerCase();if(!W0.includes(":")&&!h.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 v.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"]),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"])},y0=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let[h,Z0]of Object.entries(N0)){let W0=v.getAttribute(h);if(W0&&!Z0.has(W0))M.push(R({type:"invalid_enum_value",element:T,attr:h,value:W0,validValues:[...Z0],reason:`Invalid value '${W0}' for '${h}'. Valid values: ${[...Z0].join(", ")}`},T,h,r))}for(let h of v.children)if(a(h))y0(h)},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=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let[h,Z0]of Object.entries(o)){let W0=v.getAttribute(h);if(W0){let j0=parseFloat(W0);if(!isNaN(j0)){if(Z0.min!==void 0&&j0<Z0.min)M.push(R({type:"invalid_numeric_constraint",element:T,attr:h,value:W0,reason:`Value ${j0} is below minimum ${Z0.min}`},T,h,r));if(Z0.max!==void 0&&j0>Z0.max)M.push(R({type:"invalid_numeric_constraint",element:T,attr:h,value:W0,reason:`Value ${j0} is above maximum ${Z0.max}`},T,h,r))}}}for(let h of v.children)if(a(h))J0(h)},_0=(v)=>{let T=new Map,r=new Map,h=(Z0)=>{let W0=Z0.tagName.toLowerCase(),j0=k(W0),X0=Z0.getAttribute("id");if(X0){if(!T.has(X0))T.set(X0,[]),r.set(X0,{tagName:W0,occIdx:j0});T.get(X0).push(W0)}for(let b0 of Z0.children)if(a(b0))h(b0)};h(v);for(let[Z0,W0]of T)if(W0.length>1){let j0=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(", ")})`},j0.tagName,"id",j0.occIdx))}},O0=/url\(#([^)]+)\)/g,B0=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],I0=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of B0){let Z0=v.getAttribute(h);if(Z0){let W0;O0.lastIndex=0;while((W0=O0.exec(Z0))!==null){let j0=W0[1];if(!I.has(j0))M.push(R({type:"broken_url_reference",element:T,attr:h,referencedId:j0,reason:`url(#${j0}) references non-existent ID`},T,h,r))}}}for(let h of v.children)if(a(h))I0(h)},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=(v)=>{let T=v.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=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of C){let Z0=v.getAttribute(h);if(Z0&&!n(Z0))M.push(R({type:"invalid_color",element:T,attr:h,value:Z0,reason:`Invalid color value '${Z0}'`},T,h,r))}for(let h of v.children)if(a(h))p(h)},s=(v)=>{let T=v.tagName.toLowerCase(),r=k(T),h=v.getAttribute("viewBox");if(h){let j0=h.trim().split(/[\s,]+/);if(j0.length!==4||!j0.every((X0)=>!isNaN(parseFloat(X0))))M.push(R({type:"malformed_viewbox",element:T,value:h,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},T,"viewBox",r))}let Z0=v.getAttribute("points");if(Z0){let j0=Z0.trim().split(/[\s,]+/).filter((X0)=>X0);if(j0.length%2!==0||!j0.every((X0)=>!isNaN(parseFloat(X0))))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=v.getAttribute("transform");if(W0){let j0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,X0=W0.trim();while(X0.length>0){let b0=X0.match(j0);if(b0&&b0[0].length>0)X0=X0.substring(b0[0].length);else if(!b0){M.push(R({type:"malformed_transform",element:T,value:W0.length>50?W0.substring(0,50)+"...":W0,reason:`Invalid transform syntax near '${X0.substring(0,20)}'`},T,"transform",r));break}else X0=X0.substring(1)}}if(T==="path"){let j0=v.getAttribute("d");if(j0){let X0=j0.trim();if(X0.length>0){if(!/^[Mm]/.test(X0))M.push(R({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",r));let b0=X0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(b0.length>0)M.push(R({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",r))}}}for(let j0 of v.children)if(a(j0))s(j0)},G0=()=>{let v=new Map,T=(j0)=>{let X0=j0.getAttribute("id");if(X0)v.set(X0,j0);for(let b0 of j0.children)if(a(b0))T(b0)};T(F);let r=["href","xlink:href","mask","clip-path","filter","fill","stroke"],h=(j0)=>{if(!j0)return null;let X0=j0.match(/url\(#([^)]+)\)/);if(X0)return X0[1];let b0=j0.match(/^#(.+)$/);if(b0)return b0[1];return null},Z0=(j0,X0=new Set)=>{if(X0.has(j0))return!0;let b0=v.get(j0);if(!b0)return!1;X0.add(j0);let P0=(J7)=>{for(let a0 of r){let cJ=h(J7.getAttribute(a0));if(cJ&&Z0(cJ,X0))return!0}for(let a0 of J7.children)if(a(a0)&&P0(a0))return!0;return!1},u0=P0(b0);return X0.delete(j0),u0},W0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[j0,X0]of v){let b0=X0.tagName.toLowerCase();if(W0.includes(b0)){if(Z0(j0)){w();let P0=k(b0);M.push(R({type:"circular_reference",element:b0,attr:"id",value:j0,reason:`Circular reference detected: '${j0}' directly or indirectly references itself`},b0,"id",P0))}}}},L0=50,C0=(v,T=0)=>{if(T>L0){let r=v.tagName.toLowerCase(),h=k(r);M.push(R({type:"deep_nesting",element:r,value:String(T),reason:`Element nesting depth (${T}) exceeds ${L0} levels`},r,null,h));return}for(let r of v.children)if(a(r))C0(r,T+1)},T0=(v)=>{let T=v.tagName.toLowerCase();if(T==="defs"){let r=!1;for(let h of v.childNodes)if(a(h)){r=!0;break}if(!r){let h=k(T);M.push(R({type:"empty_defs",element:T,reason:"Empty <defs> element (can be removed)"},T,null,h))}}for(let r of v.children)if(a(r))T0(r)},w7=(v)=>{let T=v.tagName.toLowerCase();if(T==="lineargradient"||T==="radialgradient"){let r=Array.from(v.children).filter((h)=>a(h)&&h.tagName.toLowerCase()==="stop");if(r.length>=2){let h=-1;for(let Z0 of r){let W0=Z0.getAttribute("offset")||"0",j0=parseFloat(W0);if(W0.includes("%"))j0=j0/100;if(!isNaN(j0)&&j0<h){let X0=k(T);M.push(R({type:"gradient_stop_order",element:T,reason:`Gradient stops not in ascending offset order (${h} followed by ${j0})`},T,null,X0));break}if(!isNaN(j0))h=j0}}}for(let r of v.children)if(a(r))w7(r)},h$=1e4,g7=(v)=>{let T=v.tagName.toLowerCase();if(T==="path"){let r=v.getAttribute("d");if(r){let h=r.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(h&&h.length>h$){let Z0=k(T);M.push(R({type:"path_complexity",element:T,attr:"d",value:`${h.length} coordinates`,reason:`Path has ${h.length} coordinates (>${h$}), may cause slow rendering`},T,"d",Z0))}}}for(let r of v.children)if(a(r))g7(r)},L$=(v)=>{let T=v.tagName.toLowerCase(),r=k(T),h=["href","xlink:href"];for(let Z0 of h){let W0=v.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"&&v.textContent){let Z0=v.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 v.children)if(a(Z0))L$(Z0)},mJ=(v)=>{let T=v.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 v.children)if(a(r))mJ(r)},dJ=(v)=>{let T=v.tagName.toLowerCase(),r=k(T);for(let h of v.getAttributeNames())if(nW.has(h.toLowerCase()))M.push(R({type:"event_handler",element:T,attr:h,reason:`Event handler attribute '${h}' detected (potential XSS vector)`},T,h,r));for(let h of v.children)if(a(h))dJ(h)},AK=()=>{let v=!1,T=!1,r=!1,h=F.hasAttribute("lang")||F.hasAttribute("xml:lang"),Z0=(b0)=>{for(let P0 of b0.children){if(!a(P0))continue;let u0=P0.tagName.toLowerCase();if(u0==="title")v=!0;if(u0==="desc")T=!0;if(u0==="text"||u0==="tspan"||u0==="textpath")r=!0;Z0(P0)}};if(Z0(F),!v)M.push(R({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let W0=0,j0=(b0)=>{W0++;for(let P0 of b0.children)if(a(P0))j0(P0)};if(j0(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&&!h)M.push(R({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let X0=(b0)=>{let P0=b0.tagName.toLowerCase(),u0=k(P0);for(let J7 of b0.getAttributeNames()){if(J7.startsWith("aria-")&&!lW.has(J7.toLowerCase()))M.push(R({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&&!JZ.has(a0.toLowerCase()))M.push(R({type:"invalid_aria",element:P0,attr:"role",value:a0,reason:`Invalid role value '${a0}' (valid: ${Array.from(JZ).slice(0,5).join(", ")}...)`},P0,"role",u0))}if(J7==="aria-hidden"){let a0=b0.getAttribute("aria-hidden");if(a0&&a0!=="true"&&a0!=="false")M.push(R({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(a(J7))X0(J7)};w(),X0(F)};w(),g(F),b(),w(),x(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(),y0(F),w(),J0(F),w(),_0(F),w(),I0(F),w(),p(F),w(),s(F),w(),G0(),w(),C0(F),w(),T0(F),w(),w7(F),w(),g7(F),w(),L$(F),w(),mJ(F),w(),dJ(F),AK(),M.sort((v,T)=>{if(v.line!==T.line)return v.line-T.line;return v.column-T.column});let j6=M;if(Z)j6=M.filter((v)=>v.severity===E0.ERROR);let Q9=M.filter((v)=>v.severity===E0.ERROR).length,pJ=M.filter((v)=>v.severity===E0.WARNING).length,q9={};for(let v of j6)q9[v.type]=(q9[v.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 v=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 h=T.normalize(K);await v.writeFile(h,r,"utf8"),z$.outputFile=h}catch(v){z$.exportError=`Failed to write report to '${K}': ${v.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
354
|
`)}function rW($){let J=["validation_result:",` is_valid: ${$.isValid}`,` has_errors: ${$.hasErrors}`,` has_warnings: ${$.hasWarnings}`,` error_count: ${$.errorCount}`,` warning_count: ${$.warningCount}`,` issue_count: ${$.issueCount}`,""," summary:"];for(let[K,Q]of Object.entries($.summary))J.push(` ${K}: ${Q}`);J.push(""),J.push(" issues:");let Z=(K)=>String(K).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");for(let K of $.issues){if(J.push(` - type: ${K.type}`),J.push(` severity: ${K.severity}`),J.push(` line: ${K.line}`),J.push(` column: ${K.column}`),K.element)J.push(` element: "${Z(K.element)}"`);if(K.attr)J.push(` attr: "${Z(K.attr)}"`);if(K.value)J.push(` value: "${Z(K.value)}"`);if(J.push(` reason: "${Z(K.reason)}"`),K.sourceLine)J.push(` source_line: "${Z(K.sourceLine)}"`)}return J.join(`
|
|
355
355
|
`)}function aW($){let J=(K)=>String(K).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Z=['<?xml version="1.0" encoding="UTF-8"?>',"<validation_result>",` <is_valid>${$.isValid}</is_valid>`,` <has_errors>${$.hasErrors}</has_errors>`,` <has_warnings>${$.hasWarnings}</has_warnings>`,` <error_count>${$.errorCount}</error_count>`,` <warning_count>${$.warningCount}</warning_count>`,` <issue_count>${$.issueCount}</issue_count>`," <summary>"];for(let[K,Q]of Object.entries($.summary))Z.push(` <${K}>${Q}</${K}>`);Z.push(" </summary>"),Z.push(" <issues>");for(let K of $.issues){if(Z.push(" <issue>"),Z.push(` <type>${J(K.type)}</type>`),Z.push(` <severity>${J(K.severity)}</severity>`),Z.push(` <line>${K.line}</line>`),Z.push(` <column>${K.column}</column>`),K.element)Z.push(` <element>${J(K.element)}</element>`);if(K.attr)Z.push(` <attr>${J(K.attr)}</attr>`);if(K.value)Z.push(` <value>${J(K.value)}</value>`);if(Z.push(` <reason>${J(K.reason)}</reason>`),K.sourceLine)Z.push(` <source_line>${J(K.sourceLine)}</source_line>`);Z.push(" </issue>")}return Z.push(" </issues>"),Z.push("</validation_result>"),Z.join(`
|
|
356
|
-
`)}function WK($){let J=1;for(let Z of $.children)if(a(Z))J+=WK(Z);return J}var zK=F0(async($,J={})=>{let Z=
|
|
356
|
+
`)}function WK($){let J=1;for(let Z of $.children)if(a(Z))J+=WK(Z);return J}var zK=F0(async($,J={})=>{let Z=q7($,{minify:J.minify!==!1}),K=await b$(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(K.svg)}),jK=F0(($,J={})=>{let Z=$.getElementsByTagName("path");for(let K of Z){let Q=K.getAttribute("d");if(!Q)continue;try{let q=J$(Q),H=I$(q,J.precision||6);K.setAttribute("d",H)}catch(q){console.warn(`Failed to simplify path: ${q.message}`,{pathData:Q.substring(0,100)})}}return $}),GK=F0(($,J={})=>{return x5($,{precision:J.precision??3,removeLinearSplines:J.removeLinearSplines!==!1,optimizeValues:J.optimizeValues!==!1}),$}),FK=F0(($,J={})=>{return m5($,{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}),$}),_K=F0(($,J={})=>{let Z=J.tolerance??1,K=J.algorithm??"douglas-peucker",Q=J.respectStroke!==!1,q=h7($),H=(W)=>{if(W.tagName?.toLowerCase()==="path"){let j=W.getAttribute("d");if(j){let G=Z;if(Q){let U=o$(W),Y=s$(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(j),_=i9(F,G,K);if(_.simplified){let U=r0(_.commands,J.precision??3);W.setAttribute("d",U)}}}for(let j of W.children||[])H(j)};return H($),$}),UK=F0(($,J={})=>{let Z=(K)=>{let Q=K.getAttribute("transform");if(Q){let q=Q7(Q),H=G8(q);K.setAttribute("data-decomposed",JSON.stringify({translateX:H.translateX.toNumber(),translateY:H.translateY.toNumber(),rotation:H.rotation.toNumber(),scaleX:H.scaleX.toNumber(),scaleY:H.scaleY.toNumber(),skewX:H.skewX.toNumber()}))}for(let q of K.children)if(a(q))Z(q)};return Z($),$});function o6($,J){let Z=$.tagName.toLowerCase();try{if(Z==="path"){let K=$.getAttribute("d");if(!K)return null;let Q=J$(K),q=[],H=0,W=0;for(let z of Q)if(z.command==="M"||z.command==="L")H=z.args[0].toNumber(),W=z.args[1].toNumber(),q.push({x:H,y:W});return q}if(Z==="rect"){let K=$.getAttribute("x")||"0",Q=$.getAttribute("y")||"0",q=$.getAttribute("width")||"0",H=$.getAttribute("height")||"0";if(o7(K)||o7(Q)||o7(q)||o7(H))return null;let W=parseFloat(K),z=parseFloat(Q),j=parseFloat(q),G=parseFloat(H);if(isNaN(W)||isNaN(z)||isNaN(j)||isNaN(G))return null;return[{x:W,y:z},{x:W+j,y:z},{x:W+j,y:z+G},{x:W,y:z+G}]}if(Z==="circle"){let K=parseFloat($.getAttribute("cx")||"0"),Q=parseFloat($.getAttribute("cy")||"0"),q=parseFloat($.getAttribute("r")||"0");if(isNaN(K)||isNaN(Q)||isNaN(q))return null;let H=[];for(let W=0;W<J;W++){let z=W/J*2*Math.PI;H.push({x:K+q*Math.cos(z),y:Q+q*Math.sin(z)})}return H}return null}catch(K){return console.warn(`getShapePolygon failed for ${Z}:`,K.message),null}}var tW={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".bmp":"image/bmp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".wav":"audio/wav",".mp3":"audio/mpeg",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".webm":"audio/webm",".mp4":"video/mp4",".ogv":"video/ogg",".mov":"video/quicktime",".css":"text/css",".js":"text/javascript"};function IJ(){return typeof process!=="undefined"&&process.versions?.node}function ZZ($){if(!$||typeof $!=="string")return!1;if($.startsWith("#"))return!1;if($.startsWith("data:"))return!1;return!0}function eW($){let J=$.indexOf("#");if(J===-1)return{path:$,fragment:null};return{path:$.substring(0,J),fragment:$.substring(J+1)}}function i6($){let J=($.match(/\.[a-z0-9]+$/i)||[""])[0].toLowerCase();return tW[J]||"application/octet-stream"}function l7($,J){if(!$)return $;if($.match(/^https?:\/\//i))return $;if($.startsWith("data:"))return $;if($.startsWith("file://"))return $;if(!J)return $;if(J.match(/^https?:\/\//i))try{return new URL($,J).href}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);return $}if(IJ())try{let K=(O$(),fK(V$)),Q=J.endsWith("/")?J:K.dirname(J),q=K.resolve(Q,$),H=K.resolve(Q);if(!q.startsWith(H+K.sep)&&q!==H)return console.warn(`Path traversal blocked: ${$} escapes base directory`),$;return q}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);let Q=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked in fallback: ${$}`),$;return Q+$}let Z=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked: ${$}`),$;return Z+$}async function s7($,J="text",Z=30000){if(IJ()&&!$.match(/^https?:\/\//i)){let q=await import("node:fs/promises");return{content:J==="binary"?await q.readFile($):await q.readFile($,"utf8"),contentType:i6($)}}let K=new AbortController,Q=setTimeout(()=>K.abort(),Z);try{let q=await fetch($,{signal:K.signal});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);let H=q.headers.get("content-type")||i6($);return{content:J==="binary"?await q.arrayBuffer():await q.text(),contentType:H}}finally{clearTimeout(Q)}}function Q6($,J){let Z;if(IJ())Z=Buffer.from($).toString("base64");else{let K=new Uint8Array($),Q="";for(let q=0;q<K.length;q++)Q+=String.fromCharCode(K[q]);Z=btoa(Q)}return`data:${J};base64,${Z}`}function UJ($){let J=[],Z=[],K=/@import\s+(?:url\(\s*["']?([^"')]+)["']?\s*\)|["']([^"']+)["'])/gi,Q,q=0;while((Q=K.exec($))!==null){if(Q.index===q&&Q[0].length===0){console.error("Regex matched empty string in @import, breaking to prevent infinite loop");break}q=Q.index+Math.max(1,Q[0].length),J.push({url:Q[1]||Q[2],fullMatch:Q[0],index:Q.index})}let H=/url\(\s*["']?([^"')]+)["']?\s*\)/gi,W=0;while((Q=H.exec($))!==null){if(Q.index===W&&Q[0].length===0){console.error("Regex matched empty string in url(), breaking to prevent infinite loop");break}if(W=Q.index+Math.max(1,Q[0].length),$.substring(Math.max(0,Q.index-10),Q.index).includes("@import"))continue;if(Q[1].startsWith("#"))continue;if(Q[1].startsWith("data:"))continue;Z.push({url:Q[1],fullMatch:Q[0],index:Q.index})}return{imports:J,urls:Z}}function MJ($,J,Z=new Map){if(!$)return Z;let K=$.getAttribute?.("id");if(K){let H=J+K;Z.set(K,H),$.setAttribute("id",H)}let Q=["href","xlink:href","fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end"];for(let H of Q){let W=$.getAttribute?.(H);if(!W)continue;if(W.includes("url(#")){let z=W.replace(/url\(#([^)]+)\)/g,(j,G)=>{return`url(#${Z.get(G)||J+G})`});$.setAttribute(H,z)}else if(W.startsWith("#")){let z=W.substring(1);$.setAttribute(H,"#"+(Z.get(z)||J+z))}}let q=$.getAttribute?.("style");if(q&&q.includes("url(#")){let H=q.replace(/url\(#([^)]+)\)/g,(W,z)=>{return`url(#${Z.get(z)||J+z})`});$.setAttribute("style",H)}if($.children)for(let H of $.children)MJ(H,J,Z);return Z}function VK($,J,Z){if(!$){console.warn("setCDATAContent called with null element");return}let K=0,Q=1e4;while($.firstChild&&K++<Q){let H=$.firstChild;if($.removeChild(H),$.firstChild===H){console.error("removeChild failed to remove child in setCDATAContent, breaking to prevent infinite loop");break}}if(K>=Q)console.error(`Safety limit reached in setCDATAContent: ${Q} children processed`);let q=J.includes("<")||J.includes("&")||J.includes("]]>");if(q&&typeof Z.createCDATASection==="function")if(J.includes("]]>")){let H=J.split("]]>");for(let W=0;W<H.length;W++)if(W===0)$.appendChild(Z.createCDATASection(H[W]+"]]"));else if(W===H.length-1)$.appendChild(Z.createCDATASection(">"+H[W]));else $.appendChild(Z.createCDATASection(">"+H[W]+"]]"))}else $.appendChild(Z.createCDATASection(J));else if(q){let H=J.replace(/\]\]>/g,"]]]]><![CDATA[>");$.setAttribute("data-cdata-pending","true"),$.textContent=H}else $.textContent=J}var $z={audio:[".wav",".mp3",".ogg",".webm",".m4a",".aac",".flac"],image:[".png",".jpg",".jpeg",".gif",".svg",".webp",".avif",".ico",".bmp"],video:[".mp4",".webm",".ogv",".avi",".mov"],data:[".json",".xml",".txt",".csv",".tsv"],font:[".woff",".woff2",".ttf",".otf",".eot"]},Jz=Object.values($z).flat();function Zz($){let J=new Set,Z=Jz.map((q)=>q.replace(".","\\.")).join("|"),K=new RegExp(`["'\`]([^"'\`]*(?:${Z}))["'\`]`,"gi"),Q;while((Q=K.exec($))!==null){let q=Q[1];if(q&&!q.startsWith("data:")&&!q.match(/^https?:\/\/(?!localhost)/)&&q.length>0)J.add(q)}return J}function Kz($){if($.size===0)return"";let J={};for(let[Z,K]of $)J[Z]=K;return`
|
|
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(!m.includes("fonts.googleapis.com"))m=l+m,c=!0,w.push(`Restored Google Fonts import for: ${i.join(", ")}`)}}}if(G&&m.trim()){R++;let d=W$(H,"text/css",R),N=await
|
|
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,y=(D)=>{if(!D||!D.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=D.attributes;for(let d=0;d<c.length;d++){let N=c[d];if(N.name.startsWith("xmlns:")){let u=N.name.substring(6),B=N.value;if(E.some((t)=>B.startsWith(t))||!m.includes(B))I.set(u,B)}}},g=(D,E)=>{let m=`Failed to fetch resource: ${D} - ${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:u,contentType:B}=await s7(N,"binary",Y),t=Q6(u,B.split(";")[0]);if(c.getAttribute("href"))c.setAttribute("href",t);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href",t)}catch(N){g(d,N)}if(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:u,fragment:B}=eW(N);if(!u)continue;let t=l7(u,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=x0(i);if(!l){g(u,new Error("Failed to parse SVG"));continue}let q0=l.documentElement||l;if(y(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 g(N,new Error(`Fragment #${B} not found in ${u}`))}else{let A=l.documentElement||l;MJ(A,f);let e=f+"svg";A.setAttribute("id",e),m.children.push(A);let $0=B?"#"+f+B:"#"+e;if(d.getAttribute("href"))d.setAttribute("href",$0);if(d.getAttribute("xlink:href"))d.setAttribute("xlink:href",$0)}}catch(i){g(u,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:u}=UJ(N);for(let B of u.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){g(A.url,e)}N=N.substring(0,B.index)+q0+N.substring(B.index+B.fullMatch.length)}catch(t){g(B.url,t)}}if(H||W){let{urls:u}=UJ(N);for(let B of u.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){g(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:u}=await s7(N,"text",Y);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),VK(c,u,$)}catch(N){g(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 u=l7(d,Z),{content:B,contentType:t}=await s7(u,"binary",Y),i=t.split(";")[0]||"audio/mpeg",l=Q6(B,i);c.setAttribute("src",l)}catch(u){g(d,u)}let N=c.getElementsByTagName("source");for(let u of N){let B=u.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]||u.getAttribute("type")||"audio/mpeg",f=Q6(i,q0);u.setAttribute("src",f)}catch(t){g(B,t)}}if(M)M("audio",m+1,E.length)}}if(z){let D=[],E=$.getElementsByTagName("script");for(let N of E)if(N.textContent)D.push(N.textContent);let m=$.getElementsByTagName("style");for(let N of m)if(N.textContent)D.push(N.textContent);let c=$.getElementsByTagName("foreignObject");for(let N of c){let u=N.textContent||"";if(u)D.push(u)}let d=new Set;for(let N of D){let u=Zz(N);for(let B of u)d.add(B)}if(d.size>0){let N=new Map;if(M)M("resources",0,d.size);let u=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){g(B,t)}if(u++,M)M("resources",u,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[D,E]of I){let m=`xmlns:${D}`;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===h0.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 x=b;while(x&&x.getAttribute){let D=x.getAttribute("id");if(D&&I.has(D))return!0;x=x.parentNode}return!1},y=async(b,x,D)=>{let E=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))E=x.length;else if(typeof Buffer!=="undefined")E=Buffer.byteLength(x,"utf8");else if(typeof Blob!=="undefined")E=new Blob([x]).size;else E=x.length||0;let m={filename:b,path:q?`${q}/${b}`:b,mimeType:D,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(x))await c.writeFile(N,x);else await c.writeFile(N,x,"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 x=[...K.getElementsByTagName("image")];if(X)X("images",0,x.length);for(let D=0;D<x.length;D++){let E=x[D];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),u=await y(d,N,c.mimeType);if(u.type="image",u.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",D+1,x.length)}}if(F){let x=[...K.getElementsByTagName("audio")];if(X)X("audio",0,x.length);for(let D=0;D<x.length;D++){let E=x[D];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),u=Y$(d),B=await y(N,u,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 u=M$(N);if(u&&u.mimeType.startsWith("audio/")){R++;let B=W$(H,u.mimeType,R),t=Y$(u),i=await y(B,t,u.mimeType);if(i.type="audio",!M)d.setAttribute("src",`./${B}`)}}}if(X)X("audio",D+1,x.length)}}if(_){let x=[...K.getElementsByTagName("video")];if(X)X("video",0,x.length);for(let D=0;D<x.length;D++){let E=x[D];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),u=Y$(d),B=await y(N,u,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 u=M$(N);if(u&&u.mimeType.startsWith("video/")){R++;let B=W$(H,u.mimeType,R),t=Y$(u),i=await y(B,t,u.mimeType);if(i.type="video",!M)d.setAttribute("src",`./${B}`)}}}if(X)X("video",D+1,x.length)}}if(j){let x=[...K.getElementsByTagName("script")];if(X)X("scripts",0,x.length);for(let D=0;D<x.length;D++){let E=x[D];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 u=M$(m);if(u){let B=Y$(u);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 y(d,c,"application/javascript");if(N.type="script",N.elementId=E.getAttribute("id"),!M){let u=0;while(E.firstChild&&u++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(u>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");E.setAttribute("href",`./${d}`)}if(X)X("scripts",D+1,x.length)}}if(G||z){let x=[...K.getElementsByTagName("style")];if(X)X("styles",0,x.length);for(let D=0;D<x.length;D++){let E=x[D];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 u of N){let B=u.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 y(l,q0,i.mimeType);f.type="font";let A=u.match(/font-family:\s*["']?([^"';]+)["']?/);if(A)f.fontFamily=A[1].trim();if(!M)m=m.replace(t,`./${l}`),c=!0}}}if(Y){let u=[],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())))u.push(i)}if(u.length>0&&!M){let i=[...new Set(u)],l=`@import url('https://fonts.googleapis.com/css2?family=${i.map((q0)=>q0.replace(/\s+/g,"+")).join("&family=")}&display=swap');
|
|
494
|
+
`;if(!m.includes("fonts.googleapis.com"))m=l+m,c=!0,w.push(`Restored Google Fonts import for: ${i.join(", ")}`)}}}if(G&&m.trim()){R++;let d=W$(H,"text/css",R),N=await y(d,m,"text/css");if(N.type="stylesheet",N.elementId=E.getAttribute("id"),!M){let u=0;while(E.firstChild&&u++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(u>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");E.textContent=`@import url('./${d}');`,c=!0}}else if(c&&!M){let d=0;while(E.firstChild&&d++<1e4){let N=E.firstChild;if(E.removeChild(N),E.firstChild===N)break}if(d>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");VK(E,m,K)}if(X)X("styles",D+1,x.length)}}if(!M){if(K._exportedResources=k,w.length>0)K._exportWarnings=w}return{doc:M?null:W6(K,Q,J),extractedFiles:k,warnings:w,summary:{totalExtracted:k.length,images:k.filter((b)=>b.type==="image").length,audio:k.filter((b)=>b.type==="audio").length,video:k.filter((b)=>b.type==="video").length,scripts:k.filter((b)=>b.type==="script").length,fonts:k.filter((b)=>b.type==="font").length,stylesheets:k.filter((b)=>b.type==="stylesheet").length,totalSize:k.reduce((b,x)=>b+x.size,0)}}}var Gz={MAX_PRECISION:q6,DEFAULT_PRECISION:s6,PRECISION_LEVELS:KZ,formatPrecision:QZ,InputType:h0,OutputFormat:X7,OutputTarget:Y7,detectInputType:w$,detectOutputTarget:XJ,loadInput:H6,generateOutput:W6,saveOutput:qZ,createOperation:F0,cleanupIds:kJ,cleanupNumericValues:r6,cleanupListOfValues:HZ,cleanupAttributes:WZ,cleanupEnableBackground:zZ,removeUnknownsAndDefaults:jZ,removeNonInheritableGroupAttrs:GZ,removeUselessDefs:FZ,removeHiddenElements:a6,removeEmptyText:_Z,removeEmptyContainers:t6,removeDoctype:UZ,removeXMLProcInst:VZ,removeComments:e6,removeMetadata:$9,removeTitle:OZ,removeDesc:MZ,removeEditorsNSData:wJ,removeEmptyAttrs:YZ,removeViewBox:XZ,removeXMLNS:kZ,removeRasterImages:wZ,removeScriptElement:LZ,convertShapesToPath:RZ,convertPathData:BZ,convertTransform:NZ,convertColors:J9,convertStyleToAttrs:LJ,convertEllipseToCircle:IZ,collapseGroups:CZ,mergePaths:PZ,moveGroupAttrsToElems:AZ,moveElemsAttrsToGroup:EZ,minifyStyles:RJ,inlineStyles:TZ,sortAttrs:bZ,sortDefsChildren:fZ,reusePaths:SZ,removeOffCanvasPath:vZ,removeStyleElement:DZ,removeXlink:hZ,addAttributesToSVGElement:yZ,addClassesToSVGElement:uZ,prefixIds:gZ,removeDimensions:xZ,removeAttributesBySelector:mZ,removeAttrs:dZ,removeElementsByAttr:pZ,presetDefault:BJ,presetNone:NJ,applyPreset:cZ,optimize:nZ,createConfig:lZ,flattenClipPaths:sZ,flattenMasks:oZ,flattenGradients:iZ,flattenPatterns:aZ,flattenFilters:tZ,flattenUseElements:eZ,imageToPath:$K,detectCollisions:JK,measureDistance:ZK,validateXML:KK,validateSVG:QK,fixInvalidSVG:HK,ValidationSeverity:E0,flattenAll:zK,simplifyPath:jK,decomposeTransform:UK,optimizeAnimationTiming:GK,optimizePaths:FK,simplifyPaths:_K,embedExternalDependencies:CJ,exportEmbeddedResources:OK,convertPathDataAdvanced:n9,parsePathCommands:i0,serializePathCommands:r0,formatPathNumber:u7,douglasPeucker:Z6,visvalingamWhyatt:l9,simplifyPolyline:s9,simplifyPolylinePath:i9,isPurePolyline:o9,optimizeKeySplines:x9,optimizeKeyTimes:m9,optimizeAnimationValues:m6,formatSplineValue:J6,parseKeySplines:d6,serializeKeySplines:u9,isLinearSpline:p6,areAllSplinesLinear:g5,identifyStandardEasing:g9,STANDARD_EASINGS:y9,removeLeadingZero:a9,negativeExtraSpace:t9,convertToRelative:e9,convertToAbsolute:$J,lineShorthands:JJ,convertToZ:ZJ,straightCurves:KJ,collapseRepeated:QJ,floatPrecision:qJ,removeUselessCommands:HJ,convertCubicToQuadratic:WJ,convertQuadraticToSmooth:zJ,convertCubicToSmooth:jJ,arcShorthands:GJ};var xJ={};x7(xJ,{setPolyfillMinification:()=>yJ,setPolyfillContent:()=>uJ,removePolyfills:()=>Pz,needsPolyfills:()=>Nz,injectPolyfills:()=>gJ,generatePolyfillScript:()=>CK,detectSVG2Features:()=>z6,SVG2_FEATURES:()=>Bz});var Lz=typeof process!=="undefined"&&process.versions&&process.versions.node,Rz=typeof window!=="undefined",fJ="",SJ="",vJ="",DJ="";if(Lz)try{let $=await import("fs"),J=await Promise.resolve().then(() => (IK(),NK)),Z=await Promise.resolve().then(() => (O$(),V$)),K=J.fileURLToPath(import.meta.url),Q=Z.dirname(K);fJ=$.readFileSync(Z.join(Q,"vendor","inkscape-mesh-polyfill.min.js"),"utf-8"),SJ=$.readFileSync(Z.join(Q,"vendor","inkscape-mesh-polyfill.js"),"utf-8"),vJ=$.readFileSync(Z.join(Q,"vendor","inkscape-hatch-polyfill.min.js"),"utf-8"),DJ=$.readFileSync(Z.join(Q,"vendor","inkscape-hatch-polyfill.js"),"utf-8")}catch($){throw new Error(`Failed to load SVG2 polyfill files from vendor/ directory: ${$.message}. Ensure all vendor files are present.`)}else if(Rz)console.warn("SVG2 polyfills: Running in browser mode. Use setPolyfillContent() to provide polyfill scripts.");var hJ=!0;function yJ($){if(typeof $!=="boolean")throw new Error("setPolyfillMinification: minify parameter must be a boolean");hJ=$}function uJ($){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");fJ=$.meshMin}if($.meshFull!==void 0){if(typeof $.meshFull!=="string")throw new Error("setPolyfillContent: meshFull must be a string");SJ=$.meshFull}if($.hatchMin!==void 0){if(typeof $.hatchMin!=="string")throw new Error("setPolyfillContent: hatchMin must be a string");vJ=$.hatchMin}if($.hatchFull!==void 0){if(typeof $.hatchFull!=="string")throw new Error("setPolyfillContent: hatchFull must be a string");DJ=$.hatchFull}}var Bz={MESH_GRADIENT:"meshGradient",HATCH:"hatch",CONTEXT_PAINT:"context-paint",AUTO_START_REVERSE:"auto-start-reverse"};function z6($){if(!$||typeof $!=="object")return{meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1};let J={meshGradients:[],hatches:[],contextPaint:!1,autoStartReverse:!1},Z=(K)=>{if(!K)return;let Q=K.tagName?.toLowerCase();if(Q==="meshgradient"){let j=K.getAttribute("id");if(j&&typeof j==="string"&&j.trim()&&!J.meshGradients.includes(j))J.meshGradients.push(j)}if(Q==="hatch"){let j=K.getAttribute("id");if(j&&typeof j==="string"&&j.trim()&&!J.hatches.includes(j))J.hatches.push(j)}let q=K.getAttribute("fill"),H=K.getAttribute("stroke"),W=K.getAttribute("style");if(q==="context-fill"||q==="context-stroke"||H==="context-fill"||H==="context-stroke"||W&&(W.includes("context-fill")||W.includes("context-stroke")))J.contextPaint=!0;if(Q==="style"&&K.textContent){if(K.textContent.includes("context-fill")||K.textContent.includes("context-stroke"))J.contextPaint=!0}if(K.getAttribute("orient")==="auto-start-reverse")J.autoStartReverse=!0;if(K.children&&Array.isArray(K.children))for(let j of K.children)Z(j)};return Z($),J}function Nz($){if(!$)return!1;let J=z6($);return J.meshGradients.length>0||J.hatches.length>0||J.contextPaint||J.autoStartReverse}function Iz(){let $=hJ?fJ:SJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape mesh polyfill not available. Ensure vendor/inkscape-mesh-polyfill files are present.");return $}function Cz(){let $=hJ?vJ:DJ;if(!$||$.trim()==="")throw new Error("svg2-polyfills: Inkscape hatch polyfill not available. Ensure vendor/inkscape-hatch-polyfill files are present.");return $}function CK($){if(!$||typeof $!=="object")throw new Error("generatePolyfillScript: features parameter must be an object");if(!Array.isArray($.meshGradients))throw new Error("generatePolyfillScript: features.meshGradients must be an array");if(!Array.isArray($.hatches))throw new Error("generatePolyfillScript: features.hatches must be an array");if(!$.meshGradients.every((Z)=>typeof Z==="string"))throw new Error("generatePolyfillScript: features.meshGradients must contain only strings");if(!$.hatches.every((Z)=>typeof Z==="string"))throw new Error("generatePolyfillScript: features.hatches must contain only strings");if(typeof $.contextPaint!=="boolean")throw new Error("generatePolyfillScript: features.contextPaint must be a boolean");if(typeof $.autoStartReverse!=="boolean")throw new Error("generatePolyfillScript: features.autoStartReverse must be a boolean");let J=[];if(J.push("/* SVG 2.0 Polyfills - Generated by svg-matrix */"),$.meshGradients.length>0)J.push(Iz());if($.hatches.length>0)J.push(Cz());if(J.length===1)return null;return J.join(`
|
|
495
495
|
`)}function gJ($,J={}){if(!$)return $;let Z=J.features||z6($);if(!J.force&&Z.meshGradients.length===0&&Z.hatches.length===0)return $;let K=CK(Z);if(!K)return $;let Q=$.documentElement||$,q=`
|
|
496
496
|
// <![CDATA[
|
|
497
497
|
${K}
|
|
498
498
|
// ]]>
|
|
499
|
-
`,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(Q.children))Q.children=[];if(Q.children.length>0){let W=0;for(let z=0;z<Q.children.length;z++)if(Q.children[z]?.tagName==="defs")W=z+1;Q.children.splice(W,0,H)}else Q.children.push(H);return $}function Pz($){if(!$)return $;let J=(Z)=>{if(!Z||!Z.children||!Array.isArray(Z.children))return;Z.children=Z.children.filter((K)=>{if(K?.tagName==="script"){if(K.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((K.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let K of Z.children)if(K)J(K)};return J($),$}O.set({precision:80});var Az="1.3.
|
|
499
|
+
`,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(Q.children))Q.children=[];if(Q.children.length>0){let W=0;for(let z=0;z<Q.children.length;z++)if(Q.children[z]?.tagName==="defs")W=z+1;Q.children.splice(W,0,H)}else Q.children.push(H);return $}function Pz($){if(!$)return $;let J=(Z)=>{if(!Z||!Z.children||!Array.isArray(Z.children))return;Z.children=Z.children.filter((K)=>{if(K?.tagName==="script"){if(K.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((K.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let K of Z.children)if(K)J(K)};return J($),$}O.set({precision:80});var Az="1.3.5";var{parseSVG:Vj,serializeSVG:Oj}=E9,{detectSVG2Features:Mj,injectPolyfills:Yj,setPolyfillMinification:Xj,setPolyfillContent:kj}=xJ;async function Ez($,J={}){let{loadInput:Z,saveOutput:K,optimize:Q}=Z9,q=w$($),H=await Z($,q),W=await Q(H,{precision:J.precision||6,...J});if(J.output)return K(W,J.output,J);return K(W,null,J)}var PK={VERSION:Az,Decimal:O,Matrix:H0,Vector:v0,Transforms2D:b7,Transforms3D:V9,GeometryToPath:c$,...Z9,parseSVG:x0,serializeSVG:q7,detectSVG2Features:z6,injectPolyfills:gJ,setPolyfillMinification:yJ,setPolyfillContent:uJ,process:Ez},Rj=PK;if(typeof window!=="undefined")window.SVGM=PK;export{KK as validateXML,oW as validateSVGAsync,QK as validateSVG,KJ as straightCurves,fZ as sortDefsChildren,bZ as sortAttrs,_K as simplifyPaths,jK as simplifyPath,Xj as setPolyfillMinification,kj as setPolyfillContent,Oj as serializeSVG,qZ as saveOutput,SZ as reusePaths,hZ as removeXlink,VZ as removeXMLProcInst,kZ as removeXMLNS,XZ as removeViewBox,FZ as removeUselessDefs,HJ as removeUselessCommands,jZ as removeUnknownsAndDefaults,OZ as removeTitle,DZ as removeStyleElement,LZ as removeScriptElement,wZ as removeRasterImages,vZ as removeOffCanvasPath,GZ as removeNonInheritableGroupAttrs,$9 as removeMetadata,a9 as removeLeadingZero,a6 as removeHiddenElements,_Z as removeEmptyText,t6 as removeEmptyContainers,YZ as removeEmptyAttrs,pZ as removeElementsByAttr,wJ as removeEditorsNSData,UZ as removeDoctype,xZ as removeDimensions,MZ as removeDesc,e6 as removeComments,dZ as removeAttrs,mZ as removeAttributesBySelector,Ez as process,mW as printHierarchicalMatrix,NJ as presetNone,BJ as presetDefault,gZ as prefixIds,Vj as parseSVG,FK as optimizePaths,GK as optimizeAnimationTiming,nZ as optimize,t9 as negativeExtraSpace,AZ as moveGroupAttrsToElems,EZ as moveElemsAttrsToGroup,RJ as minifyStyles,PZ as mergePaths,ZK as measureDistance,H6 as loadInput,JJ as lineShorthands,TZ as inlineStyles,Yj as injectPolyfills,$K as imageToPath,W6 as generateOutput,xW as generateFullCompatibilityMatrix,qK as generateFlexibleSVGTable,dW as generateCompatibilityMatrixSVG,pW as generateCompatibilityMatrixFlexible,QZ as formatPrecision,qJ as floatPrecision,eZ as flattenUseElements,aZ as flattenPatterns,oZ as flattenMasks,iZ as flattenGradients,tZ as flattenFilters,sZ as flattenClipPaths,zK as flattenAll,HK as fixInvalidSVG,OK as exportEmbeddedResources,EW as escapeXml,CJ as embedExternalDependencies,Mj as detectSVG2Features,XJ as detectOutputTarget,w$ as detectInputType,JK as detectCollisions,Rj as default,UK as decomposeTransform,F0 as createOperation,lZ as createConfig,NZ as convertTransform,ZJ as convertToZ,e9 as convertToRelative,$J as convertToAbsolute,LJ as convertStyleToAttrs,RZ as convertShapesToPath,zJ as convertQuadraticToSmooth,BZ as convertPathData,IZ as convertEllipseToCircle,jJ as convertCubicToSmooth,WJ as convertCubicToQuadratic,J9 as convertColors,QJ as collapseRepeated,CZ as collapseGroups,r6 as cleanupNumericValues,HZ as cleanupListOfValues,kJ as cleanupIds,zZ as cleanupEnableBackground,WZ as cleanupAttributes,GJ as arcShorthands,cZ as applyPreset,gW as analyzeCompatibilityMatrix,vW as analyzeCompatibility,uZ as addClassesToSVGElement,yZ as addAttributesToSVGElement,v0 as Vector,E0 as ValidationSeverity,Az as VERSION,V9 as Transforms3D,b7 as Transforms2D,KZ as PRECISION_LEVELS,Y7 as OutputTarget,X7 as OutputFormat,H0 as Matrix,q6 as MAX_PRECISION,h0 as InputType,c$ as GeometryToPath,O as Decimal,s6 as DEFAULT_PRECISION};
|