UNPKG

svg-to-gcode

Version:
10 lines 672 kB
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();function Zy(e,t){for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1}function di(e){return e==null?"":(e&&e.replace&&e.match(/\&/)&&(e=e.replace(/\&lt\;/g,"<"),e=e.replace(/\&gt\;/g,">"),e=e.replace(/\&quot\;/g,'"'),e=e.replace(/\&apos\;/g,"'"),e=e.replace(/\&amp\;/g,"&")),e)}function Wd(e){for(var t in e)return t;return null}function ml(e){var t=0;for(var r in e)t++;return t}function Se(e,t){for(var r=0;r<e.attributes.length;r++)if(e.attributes[r].name==t)return e.attributes[r].value;return"0"}class Jy{constructor(t=null,r={}){t&&(this.svg=t,this.options={preserveDocumentNode:!0,preserveAttributes:!1,preserveWhitespace:!1,lowerCase:!1,forceArrays:!1,...r,attribsKey:"_Attribs",dataKey:"_Data"},this.regex={patTag:/([^<]*?)<([^>]+)>/g,patSpecialTag:/^\s*([\!\?])/,patPITag:/^\s*\?/,patCommentTag:/^\s*\!--/,patDTDTag:/^\s*\!DOCTYPE/,patCDATATag:/^\s*\!\s*\[\s*CDATA/,patStandardTag:/^\s*(\/?)([\w\-\:\.]+)\s*([\s\S]*)$/,patSelfClosing:/\/\s*$/,patAttrib:new RegExp(`([\\w\\-\\:\\.]+)\\s*=\\s*([\\"\\'])([^\\2]*?)\\2`,"g"),patPINode:/^\s*\?\s*([\w\-\:]+)\s*(.*)$/,patEndComment:/--$/,patNextClose:/([^>]*?)>/g,patExternalDTDNode:new RegExp('^\\s*\\!DOCTYPE\\s+([\\w\\-\\:]+)\\s+(SYSTEM|PUBLIC)\\s+\\"([^\\"]+)\\"'),patInlineDTDNode:/^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[/,patEndDTD:/\]$/,patDTDNode:/^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[(.*)\]/,patEndCDATA:/\]\]$/,patCDATANode:/^\s*\!\s*\[\s*CDATA\s*\[([^]*)\]\]/},this.tree={},this.errors=[],this.piNodeList=[],this.dtdNodeList=[],this.documentNodeName="",this.regex.patTag.lastIndex=0,this.parse())}parse(t,r){let n=0;t||(t=this.tree),r||(r=null);let a=!1,i=null;for(;i=this.regex.patTag.exec(this.svg);){let u=i[1],l=i[2];if(u.match(/\S/)&&(typeof t[this.options.dataKey]<"u"?t[this.options.dataKey]+=" ":t[this.options.dataKey]="",t[this.options.dataKey]+=this.options.preserveWhitespace?di(u):di(u).trim()),l.match(this.regex.patSpecialTag)){if(l.match(/^\s*\?/))l=this.parsePINode(l);else if(l.match(/^\s*\!--/))l=this.parseCommentNode(l);else if(l.match(/^\s*\!DOCTYPE/))l=this.parseCDATANode(l),typeof t[this.options.dataKey]<"u"?t[this.options.dataKey]+=" ":t[this.options.dataKey]="",t[this.options.dataKey]+=this.preserveWhitespace?di(l):di(l).trim();else{this.throwParseError("Malformed special tag",l);break}if(l==null)break;continue}else{let o=l.match(this.regex.patStandardTag);if(!o){this.throwParseError("Malformed tag",l);break}let c=o[1],f=this.options.lowerCase?o[2].toLowerCase():o[2],h=o[3];if(c)if(f==(r||"")){a=!0;break}else{this.throwParseError("Mismatched closing tag (expected </"+r+">)",l);break}else{const p=!!h.match(this.regex.patSelfClosing);let m={},b=m;this.options.preserveAttributes&&(m[this.options.attribsKey]={},b=m[this.options.attribsKey]);var s=["rect","polygon","ellipse","circle","path","line","polyline"];for(Zy(s,f)&&(b.indexNodeXML=n,n++),this.regex.patAttrib.lastIndex=0;o=this.regex.patAttrib.exec(h);){let C=this.options.lowerCase?o[1].toLowerCase():o[1];b[C]=di(o[3])}if(this.options.preserveAttributes&&!ml(b)&&delete m[this.options.attribsKey],!p&&(this.parse(m,f),this.error()))break;let k=ml(m);if(typeof m[this.options.dataKey]<"u"&&k==1?m=m[this.options.dataKey]:k||(m=""),typeof t[f]<"u")if(Array.isArray(t[f]))t[f].push(m);else{let C=t[f];t[f]=[C,m]}else this.options.forceArrays&&t!==this.tree?t[f]=[m]:t[f]=m;if(this.error()||t===this.tree)break}}}if(r&&!a&&this.throwParseError("Missing closing tag (expected </"+r+">)",r),t==this.tree){if(typeof this.tree[this.dataKey]<"u"&&delete this.tree[this.dataKey],ml(this.tree)>1){this.throwParseError("Only one top-level node is allowed in document",Wd(this.tree));return}this.documentNodeName=Wd(this.tree),this.documentNodeName&&!this.preserveDocumentNode&&(this.tree=this.tree[this.documentNodeName])}}throwParseError(t,r){var n=this.text.substring(0,this.patTag.lastIndex),a=n.match(/\n/g),i=(a?a.length:0)+1;throw i-=r.match(/\n/)?r.match(/\n/g).length:0,this.errors.push({type:"Parse",key:t,text:"<"+r+">",line:i}),new Error(this.getLastError())}error(){return this.errors.length}getLastError(){return this.error()?this.getError(this.errors[this.errors.length-1]):""}parsePINode(t){return t.match(this.regex.patPINode)?(this.piNodeList.push(t),t):(this.throwParseError("Malformed processor instruction",t),null)}parseCommentNode(t){var r=null;for(this.regex.patNextClose.lastIndex=this.regex.patTag.lastIndex;!t.match(this.regex.patEndComment);)if(r=this.regex.patNextClose.exec(this.text))t+=">"+r[1];else return this.throwParseError("Unclosed comment tag",t),null;return this.regex.patTag.lastIndex=this.regex.patNextClose.lastIndex,t}getTree(){return this.tree}}function ev(e){const t={rect:[],polygon:[],ellipse:[],circle:[],path:[],line:[],polylines:[]},r={childNodes:[]},n=(i,s)=>{i.forEach(u=>{Vd(u,s).forEach(o=>r.childNodes.push(o))})};return e.g&&(Cm(e.g,t),Object.entries(t).forEach(([i,s])=>n(s,i))),[{name:"rect",data:e.rect},{name:"polygon",data:e.polygon},{name:"ellipse",data:e.ellipse},{name:"circle",data:e.circle},{name:"path",data:e.path},{name:"line",data:e.line},{name:"polyline",data:e.polyline}].forEach(({name:i,data:s})=>{s&&Vd(s,i).forEach(l=>r.childNodes.push(l))}),r.childNodes.sort((i,s)=>i.indexNodeXML-s.indexNodeXML),r}function Cm(e,t){if(!e)return;const r=(n,a)=>{for(const i in n)i in a?a[i].push(n[i]):i==="g"&&Cm(n[i],a)};return Array.isArray(e)?e.forEach(n=>r(n,t)):r(e,t),t}function Vd(e,t){let r=[];const n=(i,s)=>{const u=[{name:"fill",value:i.fill},{name:"stroke",value:i.stroke},{name:"stroke-miterlimit",value:i["stroke-miterlimit"]},{name:"transform",value:i.transform},{name:"stroke-width",value:i["stroke-width"]}];let l=[];switch(s){case"rect":l=[{name:"x",value:i.x},{name:"y",value:i.y},{name:"width",value:i.width},{name:"height",value:i.height}];break;case"polygon":l=[{name:"points",value:treePolygons.points}];break;case"ellipse":l=[{name:"cx",value:i.cx},{name:"cy",value:i.cy},{name:"rx",value:i.rx},{name:"ry",value:i.ry}];break;case"circle":l=[{name:"cx",value:i.cx},{name:"cy",value:i.cy},{name:"r",value:i.r}];break;case"polyline":l=[{name:"points",value:i.points},{name:"stroke-linecap",value:i["stroke-linecap"]},{name:"stroke-linejoin",value:i["stroke-linejoin"]}];break;case"path":l=[{name:"d",value:i.d}];break;case"line":l=[{name:"x1",value:i.x1},{name:"x2",value:i.x2},{name:"y1",value:i.y1},{name:"y2",value:i.y2}];break}return{childNodes:[],tagName:s,indexNodeXML:i.indexNodeXML,attributes:[...l,...u]}};let a=[];return e.length?(e.forEach(i=>a.push(i)),a.forEach(i=>{Array.isArray(i)?i.forEach(s=>a.push(s)):r.push(n(i,t))})):r.push(n(e,t)),r}function kt(e,t){this.x=e||0,this.y=t||0}kt.prototype={set:function(e,t){return this.x=e,this.y=t,this},zero:function(){return this.x=0,this.y=0,this},negate:function(e=!1){return e?new kt(-this.x,-this.y):(this.x=-this.x,this.y=-this.y,this)},add:function(e,t=!1){return t?new kt(this.x+e.x,this.y+e.y):(this.x+=e.x,this.y+=e.y,this)},subtract:function(e,t=!1){return t?new kt(this.x-e.x,this.y-e.y):(this.x-=e.x,this.y-=e.y,this)},multiply:function(e,t=!1){let r,n;return e.x!==void 0?(r=e.x,n=e.y):r=n=e,t?new kt(this.x*(r===0?1:r),this.y*(n===0?1:n)):(this.x*=r===0?1:r,this.y*=n===0?1:n,this)},rotate:function(e,t=!1,r=!1){let n=this.x,a=this.y;const i=t?-1:1;let s,u;e.s!==void 0?(u=e.s,s=e.c):(u=Math.sin(e),s=Math.cos(e));let l=s*n-i*u*a,o=i*u*n+s*a;return r?new kt(l,o):(this.set(l,o),this)},length:function(){var e=this.x,t=this.y;return Math.sqrt(e*e+t*t)},lengthSquared:function(){var e=this.x,t=this.y;return e*e+t*t},distance:function(e){return this.subtract(e,!0).length()},distanceSquared:function(e){var t=this.subtract(e,!0);return t*t},normalize:function(){let e=this.length();if(e<Number.MIN_VALUE)return 0;let t=1/e;return this.x*=t,this.y*=t,e},equal:function(e,t=void 0){return t===void 0?this.x===e.x&&this.y===e.y:this.x===e&&this.y===t},abs:function(){return new kt(Math.abs(this.x),Math.abs(this.y))},min:function(e,t=!1){let r=this.x,n=this.y,a=e.x,i=e.y,s=r<a?r:a,u=n<i?n:i;return t?new kt(s,u):(this.set(s,u),this)},max:function(e,t=!1){let r=this.x,n=this.y,a=e.x,i=e.y,s=r>a?r:a,u=n>i?n:i;return t?new kt(s,u):(this.set(s,u),this)},isValid:function(){return isFinite(this.x)&&isFinite(this.y)},skew:function(e){const t=e.x*Math.PI/180,r=e.y*Math.PI/180,n=this.x+this.y*Math.tan(t),a=this.y+this.x*Math.tan(r);return new kt(n,a)}};class Xd{constructor(t){this.tolerance=t.tolerance,this.tolerance_squared=Math.pow(this.tolerance,2)}parse(t,r){let n=0,a=0,i="",s,u,l=[],o=this.parseCommands(t);const c=this.matrixGetScale(r.xformToWorld);let f=this.tolerance_squared;c!==0&&(f/=Math.pow(c,2));const h=()=>o.length>0&&typeof o[0]=="number",p=()=>{if(o.length>0)return o.shift();throw new Error("in addPath: not enough parameters")},m=v=>{for(l.length>0&&(r.path.push(l),l=[]),i===""&&v&&(n=p(),a=p(),l.push([n,a]));h();)n=v?n+p():p(),a=v?a+p():p(),l.push([n,a])},b=v=>{for(;h();)n=v?n+p():p(),a=v?a+p():p(),l.push([n,a])},k=v=>{for(;h();)n=v?n+p():p(),l.push([n,a])},C=v=>{for(;h();)a=v?a+p():p(),l.push([n,a])},$=v=>{for(;h();){let S=v?n+p():p(),N=v?a+p():p(),x=v?n+p():p(),M=v?a+p():p(),D=v?n+p():p(),B=v?a+p():p();l.push([n,a]),this.addCubicBezier(l,n,a,S,N,x,M,D,B,0,f),l.push([D,B]),n=D,a=B,s=x,u=M}},L=v=>{for(;h();){let S=i.match(/[CcSs]/)?n-(s-n):n,N=i.match(/[CcSs]/)?a-(u-a):a,x=v?n+p():p(),M=v?a+p():p(),D=v?n+p():p(),B=v?a+p():p();l.push([n,a]),this.addCubicBezier(l,n,a,S,N,x,M,D,B,0,f),l.push([D,B]),n=D,a=B,s=x,u=M}},E=v=>{for(;h();){let S=v?n+p():p(),N=v?a+p():p(),x=v?n+p():p(),M=v?a+p():p();l.push([n,a]),this.addQuadraticBezier(l,n,a,S,N,x,M,0,f),l.push([x,M]),n=x,a=M}},w=v=>{for(;h();){let S=i.match(/[CcSs]/)?n-(s-n):n,N=i.match(/[CcSs]/)?a-(u-a):a,x=v?n+p():p(),M=v?a+p():p();l.push([n,a]),this.addQuadraticBezier(l,n,a,S,N,x,M,0,f),l.push([x,M]),n=x,a=M,s=x,u=M}},O=v=>{for(;h();){let S=p(),N=p(),x=p(),M=p(),D=p(),B=v?n+p():p(),q=v?a+p():p();this.addArc(l,n,a,S,N,x,M,D,B,q,f),n=B,a=q}},R=()=>{l.length>0&&(r.path.push(l),n=l[l.length-1][0],a=l[l.length-1][1],l=[])};for(;o.length>0;){let v=p();const S=v.toLowerCase()===v;switch(v.toUpperCase()){case"M":m(S);break;case"L":b(S);break;case"H":k(S);break;case"V":C(S);break;case"C":$(S);break;case"S":L(S);break;case"Q":E(S);break;case"T":w(S);break;case"A":O(S);break;case"Z":l.length>0&&l.push(l[0]);break}i=v}R()}parseCommands(t){if(typeof t=="string"){let r=t.match(/([A-Za-z]|-?[0-9]+\.?[0-9]*(?:e-?[0-9]*)?)/g);return r.forEach((n,a)=>{const i=parseFloat(n);isNaN(i)||(r[a]=i)}),r}return t}addCubicBezier(t,r,n,a,i,s,u,l,o,c,f){if(c>18)return;let h=(r+a)/2,p=(n+i)/2,m=(a+s)/2,b=(i+u)/2,k=(s+l)/2,C=(u+o)/2,$=(h+m)/2,L=(p+b)/2,E=(m+k)/2,w=(b+C)/2,O=($+E)/2,R=(L+w)/2,v=l-r,S=o-n,N=Math.abs((a-l)*S-(i-o)*v),x=Math.abs((s-l)*S-(u-o)*v);if(Math.pow(N+x,2)<5*f*(v*v+S*S)){t.push([l,o]);return}this.addCubicBezier(t,r,n,h,p,$,L,O,R,c++,f),this.addCubicBezier(t,O,R,E,w,k,C,l,o,c++,f)}addQuadraticBezier(t,r,n,a,i,s,u,l,o){if(l>18)return;let c=(r+a)/2,f=(n+i)/2,h=(a+s)/2,p=(i+u)/2,m=(c+h)/2,b=(f+p)/2,k=s-r,C=u-n,$=Math.abs((a-s)*C-(i-u)*k);if($*$<=5*o*(k*k+C*C)){t.push([m,b]);return}this.addQuadraticBezier(t,r,n,c,f,m,b,l++,o),this.addQuadraticBezier(t,m,b,h,p,s,u,l++,o)}addArc(t,r,n,a,i,s,u,l,o,c,f){let h=Math.cos(s),p=Math.sin(s),m=.5*(r-o),b=.5*(n-c),k=h*m+p*b,C=-p*m+h*b,$=(Math.pow(a*i,2)-Math.pow(a*C,2)-Math.pow(i*k,2))/(Math.pow(a*C,2)+Math.pow(i*k,2));$<0&&($=0),$=Math.sqrt($),u==l&&($=-$);let L=$*a*C/i,E=-$*i*k/a,w=h*L-p*E+(r+o)/2,O=p*L+h*E+(n+c)/2;const R=(X,V)=>{let ie=Math.acos((X[0]*V[0]+X[1]*V[1])/Math.sqrt((Math.pow(X[0],2)+Math.pow(X[1],2))*(Math.pow(V[0],2)+Math.pow(V[1],2))));return(X[0]*V[1]>X[1]*V[0]?1:-1)*ie},v=X=>{let V=R([1,0],[(k-L)/a,(C-E)/i]),ie=R([(k-L)/a,(C-E)/i],[(-k-L)/a,(-C-E)/i]);l&&ie<0&&(ie+=Math.PI*2),!l&&ie>0&&(ie-=Math.PI*2);let ve=V+ie*X,xe=Math.cos(ve),oe=Math.sin(ve);return[h*a*xe-p*i*oe+w,p*a*xe+h*i*oe+O]},S=(X,V)=>Math.pow(V[0]-X[0],2)+Math.pow(V[1]-X[1],2),N=(X,V)=>[(V[0]+X[0])/2,(V[1]+X[1])/2];function x(X,V,ie,ve,xe,oe){if(xe>18)return;let fe=V-X,y=X+.5*fe,g=v(X+.25*fe),I=v(y),A=v(X+.75*fe);S(g,N(ie,I))>oe&&x(X,y,ie,I,xe+1,oe),t.push(I),S(A,N(I,ve))>oe&&x(y,V,I,ve,xe+1,oe)}let M=0,D=1,B=v(M),q=v(D);t.push(B),x(M,D,B,q,0,f),t.push(q)}matrixGetScale(t){let r=Math.sqrt(t[0]*t[0]+t[1]*t[1]),n=Math.sqrt(t[2]*t[2]+t[3]*t[3]);return r>n?r:n}}const ro={SVGAttributeMapping:{DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,id:(e,t)=>e.id=t,transform:function(e,t){for(var r=[],n=t.match(/[a-z]+\s*\([^)]*\)/ig),a=0;a<n.length;a++){const[l,o]=n[a].split(/\(|\)/);let c=o.split(/[\s,]+/).map(parseFloat);for(var i=0;i<c.length;i++)isNaN(c[i]);if(l=="translate"){if(c.length>2)throw new Error("translate skipped; invalid num of params");const[f,h]=c.length===1?[c[0],c[0]]:c;r.push([1,0,0,1,f,h])}else if(l=="rotate")if(c.length==3){var s=c[0]*this.DEG_TO_RAD;r.push([1,0,0,1,c[1],c[2]]),r.push([Math.cos(s),Math.sin(s),-Math.sin(s),Math.cos(s),0,0]),r.push([1,0,0,1,-c[1],-c[2]])}else if(c.length==1){var s=c[0]*this.DEG_TO_RAD;r.push([Math.cos(s),Math.sin(s),-Math.sin(s),Math.cos(s),0,0])}else throw new Error("rotate skipped; invalid num of params");else if(l=="scale")if(c.length==1)r.push([c[0],0,0,c[0],0,0]);else if(c.length==2)r.push([c[0],0,0,c[1],0,0]);else throw new Error("scale skipped; invalid num of params");else if(l=="matrix")c.length==6&&r.push(c);else if(l=="skewX")if(c.length==1){var s=c[0]*this.DEG_TO_RAD;r.push([1,0,Math.tan(s),1,0,0])}else throw new Error("skewX skipped; invalid num of params");else if(l=="skewY")if(c.length==1){var s=c[0]*this.DEG_TO_RAD;r.push([1,Math.tan(s),0,1,0,0])}else throw new Error("skewY skipped; invalid num of params")}let u=[1,0,0,1,0,0];for(var a=0;a<r.length;a++)u=this.matrixMult(u,r[a]);e.xform=u},style:(e,t)=>{t.split(";").forEach(n=>{const[a,i]=n.split(":").map(s=>s.trim());(void 0)[a]&&(void 0)[a](e,i)})},opacity:(e,t)=>e.opacity=parseFloat(t),display:(e,t)=>e.display=t,visibility:(e,t)=>e.visibility=t,fill:function(e,t){e.fill=this.__parseColor(t,e.color)},stroke:function(e,t){e.stroke=this.__parseColor(t,e.color)},color:function(e,t){t!="inherit"&&(e.color=this.__parseColor(t,e.color))},"fill-opacity":(e,t)=>e.fillOpacity=Math.min(1,Math.max(0,parseFloat(t))),"stroke-opacity":(e,t)=>e.strokeOpacity=Math.min(1,Math.max(0,parseFloat(t))),__parseColor:function(e,t){if(e.charAt(0)==="#"&&e.length===4)return e.slice(1).split("").map(n=>n+n).join("").match(/../g).map(n=>parseInt(n,16));if(e.startsWith("rgb(")||e.startsWith("rgba(")){const r=e.startsWith("rgb(");return e.slice(r?4:5,-1).split(",").map((i,s)=>{const u=i.trim();return u.endsWith("%")?Math.round(parseFloat(u.slice(0,-1))*(r?2.55:.01)):s===3?Math.max(0,Math.min(1,parseFloat(u))):parseInt(u)})}else return e.startsWith("url(")?[0,0,0]:e==="currentColor"||e==="none"||e==="freeze"||e==="remove"?e==="currentColor"?t:e==="none"?"none":null:e},matrixMult:function(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}},SVGTagMapping:{svg:function(e,t,r){t.fill="black",t.stroke="none"},polygon:function(e,t,r){const n=this.__getPolyPath(e).concat("z");r.parse(n,t)},polyline:function(e,t,r){const n=this.__getPolyPath(e);r.parse(n,t)},__getPolyPath:function(e){let t=Se(e,"points").toString().split(/[\s,]+/).map(parseFloat);if(t.length%2!==0)throw new Error("in __getPolyPath: odd number of verteces");return["M",...t]},rect:function(e,t,r){let n=Se(e,"width").includes("%")?t.viewBox[2]:Se(e,"width"),a=Se(e,"height").includes("%")?t.viewBox[3]:Se(e,"height"),i=this.parseUnit(n)||0,s=this.parseUnit(a)||0,u=this.parseUnit(Se(e,"x"))||0,l=this.parseUnit(Se(e,"y"))||0,o=this.parseUnit(Se(e,"rx"))||0,c=this.parseUnit(Se(e,"ry"))||null;if(o==null||c==null){const f=["M",u,l,"h",i,"v",s,"h",-i,"z"];r.parse(f,t)}else o<0&&(o*=-1),c<0&&(c*=-1),d=["M",u+o,l,"h",i-2*o,"c",o,0,o,c,o,c,"v",s-c,"c","0.0",c,-o,c,-o,c,"h",-i+2*o,"c",-o,"0.0",-o,-c,-o,-c,"v",-s+c,"c","0.0","0.0","0.0",-c,o,-c,"z"],r.parse(d,t)},line:function(e,t,r){let n=this.parseUnit(Se(e,"x1"))||0,a=this.parseUnit(Se(e,"y1"))||0,i=this.parseUnit(Se(e,"x2"))||0,s=this.parseUnit(Se(e,"y2"))||0;const u=["M",n,a,"L",i,s];r.parse(u,t)},circle:function(e,t,r){let n=this.parseUnit(Se(e,"r")),a=this.parseUnit(Se(e,"cx"))||0,i=this.parseUnit(Se(e,"cy"))||0;if(n>0){const s=["M",a-n,i,"A",n,n,0,0,0,a,i+n,"A",n,n,0,0,0,a+n,i,"A",n,n,0,0,0,a,i-n,"A",n,n,0,0,0,a-n,i,"Z"];r.parse(s,t)}},ellipse:function(e,t,r){let n=this.parseUnit(Se(e,"rx")),a=this.parseUnit(Se(e,"ry")),i=this.parseUnit(Se(e,"cx"))||0,s=this.parseUnit(Se(e,"cy"))||0;if(n>0&&a>0){const u=["M",i-n,s,"A",n,a,0,0,0,i,s+a,"A",n,a,0,0,0,i+n,s,"A",n,a,0,0,0,i,s-a,"A",n,a,0,0,0,i-n,s,"Z"];r.parse(u,t)}},path:function(e,t,r){let n=Se(e,"d");r.parse(n,t)},parseUnit:function(e){if(!e)return null;let t=e.toLowerCase();const r={cm:37.79527559,mm:3.779527559,in:96,pt:1.25,pc:15},n=t.match(/[a-z]+$/i),a=n&&r[n[0]]||1;return parseFloat(t)*a}}};let no;const tv={boundarys:{},style:{},tolerance:.01,parser:null,parse:function(e,t){return no=!0,this.tolerance_squared=Math.pow(this.tolerance,2),this.boundarys.allcolors=[],this.parser=new Xd({tolerance:t.tolerance}),this.parseChildren(e,t.bedSize),no=!1,this.boundarys},parseChildren:function(e,t){let r=no?(no=!1,e):r,n=[[r,{}]],a={stroke:"#FFFFFF",xformToWorld:[1,0,0,1,0,0],viewBox:r.viewBox};for(let i=0;i<n.length;i++){let s=n[i][0],u=n[i][1];if(s.childNodes.forEach(l=>n.push([l,a])),s.tagName){let l={path:[],xform:[1,0,0,1,0,0],fill:u.fill,stroke:u.stroke,strokeWidth:1,viewBox:r.viewBox};const o=s.attributes[s.attributes.length-1].value;l.strokeWidth=o||1,s.attributes&&s.attributes.forEach(c=>{c.name&&c.value&&ro.SVGAttributeMapping[c.name]&&ro.SVGAttributeMapping[c.name](l,c.value)}),l.xformToWorld=this.matrixMult(u.xformToWorld,l.xform),ro.SVGTagMapping[s.tagName]&&ro.SVGTagMapping[s.tagName](s,l,this.parser),l.path.forEach(c=>{c.forEach((f,h)=>{const p=new kt(f[0]*l.xformToWorld[0]+f[1]*l.xformToWorld[2]+l.xformToWorld[4],f[0]*l.xformToWorld[1]+f[1]*l.xformToWorld[3]+l.xformToWorld[5]);c[h]=p}),this.boundarys.allcolors.push(c)})}}},matrixMult:function(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]},matrixApply:function(e,t){return[e[0]*t[0]+e[2]*t[1]+e[4],e[1]*t[0]+e[3]*t[1]+e[5]]},newPathParser:function(e){return new Xd({tolerance:.01})}};let _t=function(e){let t=e/96*25.4;t.toString().indexOf(".")===-1&&(t=t.toString()+".0");let r=t.toString().split("."),n=r[1].substring(0,3);return parseFloat(r[0]+"."+n)};function rv(e,t){let r=[];r.push("G0 F"+t.seekRate),r.push(t.start),r.push("G90 G21");let n=tv.parse(e,{tolerance:t.tolerance}).allcolors;if(n=n.filter(s=>{let u={x:1/0,y:1/0,x2:-1/0,y2:-1/0,area:0};if(s.forEach(l=>{l.x<u.x&&(u.x=l.x),l.y<u.y&&(u.y=l.y),l.x>u.x2&&(u.x2=l.x),l.y>u.y2&&(u.y2=l.y)}),u.area=(1+u.x2-u.x)*(1+u.y2-u.y),s.bounds=u,u.area>t.minArea)return s}),t.pathPlanning==="sortByArea")n.sort(function(s,u){return s.bounds.area<u.bounds.area?-1:1});else{const s=[];let u=n[0];for(s.push(u);n.length>1;){n=n.filter(o=>o!==u);const l=u[u.length-1];u=n.reduce((o,c)=>{const f=Math.sqrt((c[0].x-l.x)**2+(c[0].y-l.y)**2),h=Math.sqrt((o[0].x-l.x)**2+(o[0].y-l.y)**2);return f<h?c:o}),s.push(u)}n=s}const a=e.viewBox[3],i=(s,u)=>t.bedSize.width>=s&&t.bedSize.height>u&&(t.ignoreNegative?!(s<0||u<0):!0);for(let s=0;s<n.length;s++){let u=n[s];const l=n[s+1]||null,o=l!==null?_t(l[0].x):-1,c=l!==null?_t(a-l[0].y):-1,f=_t(u[u.length-1].x),h=_t(a-u[u.length-1].y),p=o===f&&c===h;let m=!1;const b=_t(u[0].x),k=_t(a-u[0].y);t.bedSize?i(b,k)?(r.push(`G0 X-${b} Y${k}`),r.push(t.colorCommandOn4)):m=!0:(r.push(`G0 X-${b} Y${k}`),r.push(t.colorCommandOn4)),u.forEach(C=>{const $=_t(C.x),L=_t(a-C.y);t.bedSize?i($,L)?(m&&(r.push(`G0 X-${$} Y${L}`),r.push(t.colorCommandOn4),m=!1),r.push(`G1 X-${$} Y${L}`)):r[r.length-1]!==t.colorCommandOff4&&(r.push(t.colorCommandOff4),m=!0):r.push(`G1 X-${_t(C.x)} Y${_t(a-C.y)}`)}),!p&&r[r.length-1]!==t.colorCommandOff4&&r.push(t.colorCommandOff4)}return r.push(t.end),r.join(` `)}const nv="modulepreload",av=function(e){return"/"+e},Yd={},iv=function(t,r,n){let a=Promise.resolve();if(r&&r.length>0){const i=document.getElementsByTagName("link"),s=document.querySelector("meta[property=csp-nonce]"),u=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));a=Promise.all(r.map(l=>{if(l=av(l),l in Yd)return;Yd[l]=!0;const o=l.endsWith(".css"),c=o?'[rel="stylesheet"]':"";if(!!n)for(let p=i.length-1;p>=0;p--){const m=i[p];if(m.href===l&&(!o||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${c}`))return;const h=document.createElement("link");if(h.rel=o?"stylesheet":nv,o||(h.as="script",h.crossOrigin=""),h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),o)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}return a.then(()=>t()).catch(i=>{const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i})};var Y=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $m(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),r}function sv(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var vf={};const ov={},uv=Object.freeze(Object.defineProperty({__proto__:null,default:ov},Symbol.toStringTag,{value:"Module"})),uu=$m(uv);var Am={},Em={},Tm={};(function(e){(function(t){t.parser=function(y,g){return new n(y,g)},t.SAXParser=n,t.MAX_BUFFER_LENGTH=64*1024;var r=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function n(y,g){if(!(this instanceof n))return new n(y,g);var I=this;i(I),I.q=I.c="",I.bufferCheckPosition=t.MAX_BUFFER_LENGTH,I.opt=g||{},I.opt.lowercase=I.opt.lowercase||I.opt.lowercasetags,I.looseCase=I.opt.lowercase?"toLowerCase":"toUpperCase",I.tags=[],I.closed=I.closedRoot=I.sawRoot=!1,I.tag=I.error=null,I.strict=!!y,I.noscript=!!(y||I.opt.noscript),I.state=w.BEGIN,I.strictEntities=I.opt.strictEntities,I.ENTITIES=I.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),I.attribList=[],I.opt.xmlns&&(I.ns=Object.create(f)),I.trackPosition=I.opt.position!==!1,I.trackPosition&&(I.position=I.line=I.column=0),R(I,"onready")}Object.create||(Object.create=function(y){function g(){}g.prototype=y;var I=new g;return I}),Object.keys||(Object.keys=function(y){var g=[];for(var I in y)y.hasOwnProperty(I)&&g.push(I);return g});function a(y){for(var g=Math.max(t.MAX_BUFFER_LENGTH,10),I=0,A=0,Le=r.length;A<Le;A++){var Re=y[r[A]].length;if(Re>g)switch(r[A]){case"textNode":S(y);break;case"cdata":v(y,"oncdata",y.cdata),y.cdata="";break;case"script":v(y,"onscript",y.script),y.script="";break;default:x(y,"Max buffer length exceeded: "+r[A])}I=Math.max(I,Re)}var Be=t.MAX_BUFFER_LENGTH-I;y.bufferCheckPosition=Be+y.position}function i(y){for(var g=0,I=r.length;g<I;g++)y[r[g]]=""}function s(y){S(y),y.cdata!==""&&(v(y,"oncdata",y.cdata),y.cdata=""),y.script!==""&&(v(y,"onscript",y.script),y.script="")}n.prototype={end:function(){M(this)},write:fe,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var u="[CDATA[",l="DOCTYPE",o="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/xmlns/",f={xml:o,xmlns:c},h=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function k(y){return y===" "||y===` `||y==="\r"||y===" "}function C(y){return y==='"'||y==="'"}function $(y){return y===">"||k(y)}function L(y,g){return y.test(g)}function E(y,g){return!L(y,g)}var w=0;t.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(y){var g=t.ENTITIES[y],I=typeof g=="number"?String.fromCharCode(g):g;t.ENTITIES[y]=I});for(var O in t.STATE)t.STATE[t.STATE[O]]=O;w=t.STATE;function R(y,g,I){y[g]&&y[g](I)}function v(y,g,I){y.textNode&&S(y),R(y,g,I)}function S(y){y.textNode=N(y.opt,y.textNode),y.textNode&&R(y,"ontext",y.textNode),y.textNode=""}function N(y,g){return y.trim&&(g=g.trim()),y.normalize&&(g=g.replace(/\s+/g," ")),g}function x(y,g){S(y);const I=g+` Line: `+y.line+` Column: `+y.column+` Char: `+y.c,A=new Error(I);return A.reason=g,A.line=y.line,A.column=y.column,y.error=A,R(y,"onerror",A),y}function M(y){return y.sawRoot&&!y.closedRoot&&D(y,"Unclosed root tag"),y.state!==w.BEGIN&&y.state!==w.BEGIN_WHITESPACE&&y.state!==w.TEXT&&x(y,"Unexpected end"),S(y),y.c="",y.closed=!0,R(y,"onend"),n.call(y,y.strict,y.opt),y}function D(y,g){if(typeof y!="object"||!(y instanceof n))throw new Error("bad call to strictFail");y.strict&&x(y,g)}function B(y){y.strict||(y.tagName=y.tagName[y.looseCase]());var g=y.tags[y.tags.length-1]||y,I=y.tag={name:y.tagName,attributes:{}};y.opt.xmlns&&(I.ns=g.ns),y.attribList.length=0,v(y,"onopentagstart",I)}function q(y,g){var I=y.indexOf(":"),A=I<0?["",y]:y.split(":"),Le=A[0],Re=A[1];return g&&y==="xmlns"&&(Le="xmlns",Re=""),{prefix:Le,local:Re}}function X(y){if(y.strict||(y.attribName=y.attribName[y.looseCase]()),y.attribList.indexOf(y.attribName)!==-1||y.tag.attributes.hasOwnProperty(y.attribName)){y.attribName=y.attribValue="";return}if(y.opt.xmlns){var g=q(y.attribName,!0),I=g.prefix,A=g.local;if(I==="xmlns")if(A==="xml"&&y.attribValue!==o)D(y,"xml: prefix must be bound to "+o+` Actual: `+y.attribValue);else if(A==="xmlns"&&y.attribValue!==c)D(y,"xmlns: prefix must be bound to "+c+` Actual: `+y.attribValue);else{var Le=y.tag,Re=y.tags[y.tags.length-1]||y;Le.ns===Re.ns&&(Le.ns=Object.create(Re.ns)),Le.ns[A]=y.attribValue}y.attribList.push([y.attribName,y.attribValue])}else y.tag.attributes[y.attribName]=y.attribValue,v(y,"onattribute",{name:y.attribName,value:y.attribValue});y.attribName=y.attribValue=""}function V(y,g){if(y.opt.xmlns){var I=y.tag,A=q(y.tagName);I.prefix=A.prefix,I.local=A.local,I.uri=I.ns[A.prefix]||"",I.prefix&&!I.uri&&(D(y,"Unbound namespace prefix: "+JSON.stringify(y.tagName)),I.uri=A.prefix);var Le=y.tags[y.tags.length-1]||y;I.ns&&Le.ns!==I.ns&&Object.keys(I.ns).forEach(function(Hd){v(y,"onopennamespace",{prefix:Hd,uri:I.ns[Hd]})});for(var Re=0,Be=y.attribList.length;Re<Be;Re++){var It=y.attribList[Re],Rt=It[0],hl=It[1],fi=q(Rt,!0),Qt=fi.prefix,Qy=fi.local,Gd=Qt===""?"":I.ns[Qt]||"",pl={name:Rt,value:hl,prefix:Qt,local:Qy,uri:Gd};Qt&&Qt!=="xmlns"&&!Gd&&(D(y,"Unbound namespace prefix: "+JSON.stringify(Qt)),pl.uri=Qt),y.tag.attributes[Rt]=pl,v(y,"onattribute",pl)}y.attribList.length=0}y.tag.isSelfClosing=!!g,y.sawRoot=!0,y.tags.push(y.tag),v(y,"onopentag",y.tag),g||(!y.noscript&&y.tagName.toLowerCase()==="script"?y.state=w.SCRIPT:y.state=w.TEXT,y.tag=null,y.tagName=""),y.attribName=y.attribValue="",y.attribList.length=0}function ie(y){if(!y.tagName){D(y,"Weird empty close tag."),y.textNode+="</>",y.state=w.TEXT;return}if(y.script){if(y.tagName!=="script"){y.script+="</"+y.tagName+">",y.tagName="",y.state=w.SCRIPT;return}v(y,"onscript",y.script),y.script=""}var g=y.tags.length,I=y.tagName;y.strict||(I=I[y.looseCase]());for(var A=I;g--;){var Le=y.tags[g];if(Le.name!==A)D(y,"Unexpected close tag");else break}if(g<0){D(y,"Unmatched closing tag: "+y.tagName),y.textNode+="</"+y.tagName+">",y.state=w.TEXT;return}y.tagName=I;for(var Re=y.tags.length;Re-- >g;){var Be=y.tag=y.tags.pop();y.tagName=y.tag.name,v(y,"onclosetag",y.tagName);var It={};for(var Rt in Be.ns)It[Rt]=Be.ns[Rt];var hl=y.tags[y.tags.length-1]||y;y.opt.xmlns&&Be.ns!==hl.ns&&Object.keys(Be.ns).forEach(function(fi){var Qt=Be.ns[fi];v(y,"onclosenamespace",{prefix:fi,uri:Qt})})}g===0&&(y.closedRoot=!0),y.tagName=y.attribValue=y.attribName="",y.attribList.length=0,y.state=w.TEXT}function ve(y){var g=y.entity,I=g.toLowerCase(),A,Le="";return y.ENTITIES[g]?y.ENTITIES[g]:y.ENTITIES[I]?y.ENTITIES[I]:(g=I,g.charAt(0)==="#"&&(g.charAt(1)==="x"?(g=g.slice(2),A=parseInt(g,16),Le=A.toString(16)):(g=g.slice(1),A=parseInt(g,10),Le=A.toString(10))),g=g.replace(/^0+/,""),isNaN(A)||Le.toLowerCase()!==g?(D(y,"Invalid character entity"),"&"+y.entity+";"):String.fromCodePoint(A))}function xe(y,g){g==="<"?(y.state=w.OPEN_WAKA,y.startTagPosition=y.position):k(g)||(D(y,"Non-whitespace before first tag."),y.textNode=g,y.state=w.TEXT)}function oe(y,g){var I="";return g<y.length&&(I=y.charAt(g)),I}function fe(y){var g=this;if(this.error)throw this.error;if(g.closed)return x(g,"Cannot write after close. Assign an onready handler.");if(y===null)return M(g);typeof y=="object"&&(y=y.toString());for(var I=0,A="";A=oe(y,I++),g.c=A,!!A;)switch(g.trackPosition&&(g.position++,A===` `?(g.line++,g.column=0):g.column++),g.state){case w.BEGIN:if(g.state=w.BEGIN_WHITESPACE,A==="\uFEFF")continue;xe(g,A);continue;case w.BEGIN_WHITESPACE:xe(g,A);continue;case w.TEXT:if(g.sawRoot&&!g.closedRoot){for(var Le=I-1;A&&A!=="<"&&A!=="&";)A=oe(y,I++),A&&g.trackPosition&&(g.position++,A===` `?(g.line++,g.column=0):g.column++);g.textNode+=y.substring(Le,I-1)}A==="<"&&!(g.sawRoot&&g.closedRoot&&!g.strict)?(g.state=w.OPEN_WAKA,g.startTagPosition=g.position):(!k(A)&&(!g.sawRoot||g.closedRoot)&&D(g,"Text data outside of root node."),A==="&"?g.state=w.TEXT_ENTITY:g.textNode+=A);continue;case w.SCRIPT:A==="<"?g.state=w.SCRIPT_ENDING:g.script+=A;continue;case w.SCRIPT_ENDING:A==="/"?g.state=w.CLOSE_TAG:(g.script+="<"+A,g.state=w.SCRIPT);continue;case w.OPEN_WAKA:if(A==="!")g.state=w.SGML_DECL,g.sgmlDecl="";else if(!k(A))if(L(h,A))g.state=w.OPEN_TAG,g.tagName=A;else if(A==="/")g.state=w.CLOSE_TAG,g.tagName="";else if(A==="?")g.state=w.PROC_INST,g.procInstName=g.procInstBody="";else{if(D(g,"Unencoded <"),g.startTagPosition+1<g.position){var Re=g.position-g.startTagPosition;A=new Array(Re).join(" ")+A}g.textNode+="<"+A,g.state=w.TEXT}continue;case w.SGML_DECL:(g.sgmlDecl+A).toUpperCase()===u?(v(g,"onopencdata"),g.state=w.CDATA,g.sgmlDecl="",g.cdata=""):g.sgmlDecl+A==="--"?(g.state=w.COMMENT,g.comment="",g.sgmlDecl=""):(g.sgmlDecl+A).toUpperCase()===l?(g.state=w.DOCTYPE,(g.doctype||g.sawRoot)&&D(g,"Inappropriately located doctype declaration"),g.doctype="",g.sgmlDecl=""):A===">"?(v(g,"onsgmldeclaration",g.sgmlDecl),g.sgmlDecl="",g.state=w.TEXT):(C(A)&&(g.state=w.SGML_DECL_QUOTED),g.sgmlDecl+=A);continue;case w.SGML_DECL_QUOTED:A===g.q&&(g.state=w.SGML_DECL,g.q=""),g.sgmlDecl+=A;continue;case w.DOCTYPE:A===">"?(g.state=w.TEXT,v(g,"ondoctype",g.doctype),g.doctype=!0):(g.doctype+=A,A==="["?g.state=w.DOCTYPE_DTD:C(A)&&(g.state=w.DOCTYPE_QUOTED,g.q=A));continue;case w.DOCTYPE_QUOTED:g.doctype+=A,A===g.q&&(g.q="",g.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:g.doctype+=A,A==="]"?g.state=w.DOCTYPE:C(A)&&(g.state=w.DOCTYPE_DTD_QUOTED,g.q=A);continue;case w.DOCTYPE_DTD_QUOTED:g.doctype+=A,A===g.q&&(g.state=w.DOCTYPE_DTD,g.q="");continue;case w.COMMENT:A==="-"?g.state=w.COMMENT_ENDING:g.comment+=A;continue;case w.COMMENT_ENDING:A==="-"?(g.state=w.COMMENT_ENDED,g.comment=N(g.opt,g.comment),g.comment&&v(g,"oncomment",g.comment),g.comment=""):(g.comment+="-"+A,g.state=w.COMMENT);continue;case w.COMMENT_ENDED:A!==">"?(D(g,"Malformed comment"),g.comment+="--"+A,g.state=w.COMMENT):g.state=w.TEXT;continue;case w.CDATA:A==="]"?g.state=w.CDATA_ENDING:g.cdata+=A;continue;case w.CDATA_ENDING:A==="]"?g.state=w.CDATA_ENDING_2:(g.cdata+="]"+A,g.state=w.CDATA);continue;case w.CDATA_ENDING_2:A===">"?(g.cdata&&v(g,"oncdata",g.cdata),v(g,"onclosecdata"),g.cdata="",g.state=w.TEXT):A==="]"?g.cdata+="]":(g.cdata+="]]"+A,g.state=w.CDATA);continue;case w.PROC_INST:A==="?"?g.state=w.PROC_INST_ENDING:k(A)?g.state=w.PROC_INST_BODY:g.procInstName+=A;continue;case w.PROC_INST_BODY:if(!g.procInstBody&&k(A))continue;A==="?"?g.state=w.PROC_INST_ENDING:g.procInstBody+=A;continue;case w.PROC_INST_ENDING:A===">"?(v(g,"onprocessinginstruction",{name:g.procInstName,body:g.procInstBody}),g.procInstName=g.procInstBody="",g.state=w.TEXT):(g.procInstBody+="?"+A,g.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:L(p,A)?g.tagName+=A:(B(g),A===">"?V(g):A==="/"?g.state=w.OPEN_TAG_SLASH:(k(A)||D(g,"Invalid character in tag name"),g.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:A===">"?(V(g,!0),ie(g)):(D(g,"Forward-slash in opening tag not followed by >"),g.state=w.ATTRIB);continue;case w.ATTRIB:if(k(A))continue;A===">"?V(g):A==="/"?g.state=w.OPEN_TAG_SLASH:L(h,A)?(g.attribName=A,g.attribValue="",g.state=w.ATTRIB_NAME):D(g,"Invalid attribute name");continue;case w.ATTRIB_NAME:A==="="?g.state=w.ATTRIB_VALUE:A===">"?(D(g,"Attribute without value"),g.attribValue=g.attribName,X(g),V(g)):k(A)?g.state=w.ATTRIB_NAME_SAW_WHITE:L(p,A)?g.attribName+=A:D(g,"Invalid attribute name");continue;case w.ATTRIB_NAME_SAW_WHITE:if(A==="=")g.state=w.ATTRIB_VALUE;else{if(k(A))continue;D(g,"Attribute without value"),g.tag.attributes[g.attribName]="",g.attribValue="",v(g,"onattribute",{name:g.attribName,value:""}),g.attribName="",A===">"?V(g):L(h,A)?(g.attribName=A,g.state=w.ATTRIB_NAME):(D(g,"Invalid attribute name"),g.state=w.ATTRIB)}continue;case w.ATTRIB_VALUE:if(k(A))continue;C(A)?(g.q=A,g.state=w.ATTRIB_VALUE_QUOTED):(D(g,"Unquoted attribute value"),g.state=w.ATTRIB_VALUE_UNQUOTED,g.attribValue=A);continue;case w.ATTRIB_VALUE_QUOTED:if(A!==g.q){A==="&"?g.state=w.ATTRIB_VALUE_ENTITY_Q:g.attribValue+=A;continue}X(g),g.q="",g.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:k(A)?g.state=w.ATTRIB:A===">"?V(g):A==="/"?g.state=w.OPEN_TAG_SLASH:L(h,A)?(D(g,"No whitespace between attributes"),g.attribName=A,g.attribValue="",g.state=w.ATTRIB_NAME):D(g,"Invalid attribute name");continue;case w.ATTRIB_VALUE_UNQUOTED:if(!$(A)){A==="&"?g.state=w.ATTRIB_VALUE_ENTITY_U:g.attribValue+=A;continue}X(g),A===">"?V(g):g.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(g.tagName)A===">"?ie(g):L(p,A)?g.tagName+=A:g.script?(g.script+="</"+g.tagName,g.tagName="",g.state=w.SCRIPT):(k(A)||D(g,"Invalid tagname in closing tag"),g.state=w.CLOSE_TAG_SAW_WHITE);else{if(k(A))continue;E(h,A)?g.script?(g.script+="</"+A,g.state=w.SCRIPT):D(g,"Invalid tagname in closing tag."):g.tagName=A}continue;case w.CLOSE_TAG_SAW_WHITE:if(k(A))continue;A===">"?ie(g):D(g,"Invalid characters in closing tag");continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var Be,It;switch(g.state){case w.TEXT_ENTITY:Be=w.TEXT,It="textNode";break;case w.ATTRIB_VALUE_ENTITY_Q:Be=w.ATTRIB_VALUE_QUOTED,It="attribValue";break;case w.ATTRIB_VALUE_ENTITY_U:Be=w.ATTRIB_VALUE_UNQUOTED,It="attribValue";break}if(A===";"){var Rt=ve(g);g.state===w.TEXT_ENTITY&&!t.ENTITIES[g.entity]&&Rt!=="&"+g.entity+";"?y=y.slice(0,I)+Rt+y.slice(I):g[It]+=Rt,g.entity="",g.state=Be}else L(g.entity.length?b:m,A)?g.entity+=A:(D(g,"Invalid character in entity name"),g[It]+="&"+g.entity+A,g.entity="",g.state=Be);continue;default:throw new Error(g,"Unknown state: "+g.state)}return g.position>=g.bufferCheckPosition&&a(g),g}})(e)})(Tm);var ye={};(function(e){e.elemsGroups={animation:new Set(["animate","animateColor","animateMotion","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","meshGradient","pattern","radialGradient","solidColor"]),nonRendering:new Set(["clipPath","filter","linearGradient","marker","mask","pattern","radialGradient","solidColor","symbol"]),container:new Set(["a","defs","foreignObject","g","marker","mask","missing-glyph","pattern","svg","switch","symbol"]),textContent:new Set(["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","text","textPath","tref","tspan"]),textContentChild:new Set(["altGlyph","textPath","tref","tspan"]),lightSource:new Set(["feDiffuseLighting","feDistantLight","fePointLight","feSpecularLighting","feSpotLight"]),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"])},e.textElems=new Set([...e.elemsGroups.textContent,"pre","title"]),e.pathElems=new Set(["glyph","missing-glyph","path"]),e.attrsGroups={animationAddition:new Set(["additive","accumulate"]),animationAttributeTarget:new Set(["attributeType","attributeName"]),animationEvent:new Set(["onbegin","onend","onrepeat","onload"]),animationTiming:new Set(["begin","dur","end","fill","max","min","repeatCount","repeatDur","restart"]),animationValue:new Set(["by","calcMode","from","keySplines","keyTimes","to","values"]),conditionalProcessing:new Set(["requiredExtensions","requiredFeatures","systemLanguage"]),core:new Set(["id","tabindex","xml:base","xml:lang","xml:space"]),graphicalEvent:new Set(["onactivate","onclick","onfocusin","onfocusout","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup"]),presentation:new Set(["alignment-baseline","baseline-shift","clip-path","clip-rule","clip","color-interpolation-filters","color-interpolation","color-profile","color-rendering","color","cursor","direction","display","dominant-baseline","enable-background","fill-opacity","fill-rule","fill","filter","flood-color","flood-opacity","font-family","font-size-adjust","font-size","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","stroke","text-anchor","text-decoration","text-overflow","text-rendering","transform-origin","transform","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"]),xlink:new Set(["xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type"]),documentEvent:new Set(["onabort","onerror","onresize","onscroll","onunload","onzoom"]),documentElementEvent:new Set(["oncopy","oncut","onpaste"]),globalEvent:new Set(["oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"]),filterPrimitive:new Set(["x","y","width","height","result"]),transferFunction:new Set(["amplitude","exponent","intercept","offset","slope","tableValues","type"])},e.attrsGroupsDefaults={core:{"xml:space":"default"},presentation:{clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none",opacity:"1","stop-color":"#000","stop-opacity":"1","fill-opacity":"1","fill-rule":"nonzero",fill:"#000",stroke:"none","stroke-width":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0","stroke-opacity":"1","paint-order":"normal","vector-effect":"none",display:"inline",visibility:"visible","marker-start":"none","marker-mid":"none","marker-end":"none","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none",kerning:"auto","letter-spacing":"normal","word-spacing":"normal","text-decoration":"none","text-anchor":"start","text-overflow":"clip","writing-mode":"lr-tb","glyph-orientation-vertical":"auto","glyph-orientation-horizontal":"0deg",direction:"ltr","unicode-bidi":"normal","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline"},transferFunction:{slope:"1",intercept:"0",amplitude:"1",exponent:"1",offset:"0"}},e.elems={a:{attrsGroups:new Set(["conditionalProcessing","core","graphicalEvent","presentation","xlink"]),attrs:new Set(["class","externalResourcesRequired","style","target","transform"]),defaults:{target:"_self"},contentGroups:new Set(["animation","descriptive","paintServer","shape","structural"]),content:new Set(["a","altGlyphDef","clipPath","color-profile","cursor","filter","font-face","font","foreignObject","image","marker","mask","pattern","script","style","switch","text","view","tspan"])},altGlyph:{attrsGroups:new Set(["conditionalProcessing","core","graphicalEvent","presentation","xlink"]),attrs:new Set(["class","dx","dy","externalResourcesRequired","format","glyphRef","rotate","style","x","y"])},altGlyphDef:{attrsGroups:new Set(["core"]),content:new Set(["glyphRef"])},altGlyphItem:{attrsGroups:new Set(["core"]),content:new Set(["glyphRef","altGlyphItem"])},animate:{attrsGroups:new Set(["animationAddition","animationAttributeTarget","animationEvent","animationTiming","animationValue","conditionalProcessing","core","presentation","xlink"]),attrs:new Set(["externalResourcesRequired"]),contentGroups:new Set(["descriptive"])},animateColor:{attrsGroups:new Set(["animationAddition","animationAttributeTarget","animationEvent","animationTiming","animationValue","conditionalProcessing","core","presentation","xlink"]),attrs:new Set(["externalResourcesRequired"]),contentGroups:new Set(["descriptive"])},animateMotion:{attrsGroups:new Set(["animationAddition","animationEvent","animationTiming","animationValue","conditionalProcessing","core","xlink"]),attrs:new Set(["externalResourcesRequired","keyPoints","origin","path","rotate"]),defaults:{rotate:"0"},contentGroups:new Set(["descriptive"]),content:new Set(["mpath"])},animateTransform:{attrsGroups:new Set(["animationAddition","animationAttributeTarget","animationEvent","animationTiming","animationValue","conditionalProcessing","core","xlink"]),attrs:new Set(["externalResourcesRequired","type"]),contentGroups:new Set(["descriptive"])},circle:{attrsGroups:new Set(["conditionalProcessing","core","graphicalEvent","presentation"]),attrs:new Set(["class","cx","cy","externalResourcesRequired","r","style","transform"]),defaults:{cx:"0",cy:"0"},contentGroups:new Set(["animation","descriptive"])},clipPath:{attrsGroups:new Set(["conditionalProcessing","core","presentation"]),attrs:new Set(["class","clipPathUnits","externalResourcesRequired","style","transform"]),defaults:{clipPathUnits:"userSpaceOnUse"},contentGroups:new Set(["animation","descriptive","shape"]),content:new Set(["text","use"])},"color-profile":{attrsGroups:new Set(["core","xlink"]),attrs:new Set(["local","name","rendering-intent"]),defaults:{name:"sRGB","rendering-intent":"auto"},contentGroups:new Set(["descriptive"])},cursor:{attrsGroups:new Set(["core","conditionalProcessing","xlink"]),attrs:new Set(["externalResourcesRequired","x","y"]),defaults:{x:"0",y:"0"},contentGroups:new Set(["descriptive"])},defs:{attrsGroups:new Set(["conditionalProcessing","core","graphicalEvent","presentation"]),attrs:new Set(["class","externalResourcesRequired","style","transform"]),contentGroups:new Set(["animation","descriptive","paintServer","shape","structural"]),content:new Set(["a","altGlyphDef","clipPath","color-profile","cursor","filter","font-face","font","foreignObject","image","marker","mask","pattern","script","style","switch","text","view"])},desc:{attrsGroups:new Set(["core"]),attrs:new Set(["class","style"])},ellipse:{attrsGroups:new Set(["conditionalProcessing","core","graphicalEvent","presentation"]),attrs:new Set(["class","cx","cy","externalResourcesRequired","rx","ry","style","transform"]),defaults:{cx:"0",cy:"0"},contentGroups:new Set(["animation","descriptive"])},feBlend:{attrsGroups:new Set(["core","presentation","filterPrimitive"]),attrs:new Set(["class","style","in","in2","mode"]),defaults:{mode:"normal"},content:new Set(["animate","set"])},feColorMatrix:{attrsGroups:new Set(["core","presentation","filterPrimitive"]),attrs:new Set(["class","style","in","type","values"]),defaults:{type:"matrix"},content:new Set(["animate","set"])},feComponentTransfer:{attrsGroups:new Set(["core","presentation","filterPrimitive"]),attrs:new Set(["class","style","in"]),content:new Set(["feFuncA","feFuncB","feFunc