formatSvgToImg.d901fb5a.js 113 KB

123456789101112131415
  1. import{b5 as We}from"./index.40f4b64d.js";const ne={"Acoustic Grand Piano":"\u5927\u94A2\u7434","Bright Acoustic Piano":"\u660E\u4EAE\u7684\u94A2\u7434","Electric Grand Piano":"\u7535\u94A2\u7434","Rhodes Piano":"\u67D4\u548C\u7684\u7535\u94A2\u7434","Chorused Piano":"\u52A0\u5408\u5531\u6548\u679C\u7684\u7535\u94A2\u7434",Harpsichord:"\u7FBD\u7BA1\u952E\u7434",Clavichord:"\u79D1\u62C9\u7EF4\u79D1\u7279\u7434",Celesta:"\u94A2\u7247\u7434","Music box":"\u516B\u97F3\u76D2",Vibraphone:"\u98A4\u97F3\u7434",Marimba:"\u9A6C\u6797\u5DF4",Xylophone:"\u6728\u7434","Tubular Bells":"\u7BA1\u949F",Dulcimer:"\u5927\u626C\u7434","Hammond Organ":"\u51FB\u6746\u98CE\u7434","Percussive Organ":"\u6253\u51FB\u5F0F\u98CE\u7434","Rock Organ":"\u6447\u6EDA\u98CE\u7434","Church Organ":"\u6559\u5802\u98CE\u7434","Reed Organ":"\u7C27\u7BA1\u98CE\u7434",Accordian:"\u624B\u98CE\u7434",Harmonica:"\u53E3\u7434","Tango Accordian":"\u63A2\u6208\u624B\u98CE\u7434","Acoustic Guitar":"\u94A2\u5F26\u5409\u4ED6","Electric Guitar":"\u95F7\u97F3\u7535\u5409\u4ED6","Overdriven Guitar":"\u52A0\u9A71\u52A8\u6548\u679C\u7684\u7535\u5409\u4ED6","Distortion Guitar":"\u52A0\u5931\u771F\u6548\u679C\u7684\u7535\u5409\u4ED6","Guitar Harmonics":"\u5409\u4ED6\u548C\u97F3","Acoustic Bass":"\u5927\u8D1D\u53F8","Electric Bass":"\u7535\u8D1D\u53F8","Fretless Bass":"\u65E0\u54C1\u8D1D\u53F8","Slap Bass":"\u638C\u51FB","Synth Bass":"\u7535\u5B50\u5408\u6210",Violin:"\u5C0F\u63D0\u7434",Viola:"\u4E2D\u63D0\u7434",Cello:"\u5927\u63D0\u7434",Contrabass:"\u4F4E\u97F3\u5927\u63D0\u7434","Tremolo Strings":"\u5F26\u4E50\u7FA4\u98A4\u97F3\u97F3\u8272","Pizzicato Strings":"\u5F26\u4E50\u7FA4\u62E8\u5F26\u97F3\u8272","Orchestral Harp":"\u7AD6\u7434",Timpani:"\u5B9A\u97F3\u9F13","String Ensemble":"\u5F26\u4E50\u5408\u594F\u97F3\u8272","Synth Strings":"\u5408\u6210\u5F26\u4E50\u5408\u594F\u97F3\u8272","Choir Aahs":"\u4EBA\u58F0\u5408\u5531","Voice Oohs":"\u4EBA\u58F0","Synth Voice":"\u5408\u6210\u4EBA\u58F0","Orchestra Hit":"\u7BA1\u5F26\u4E50\u6572\u51FB\u9F50\u594F",Trumpet:"\u5C0F\u53F7",Trombone:"\u957F\u53F7",Tuba:"\u5927\u53F7","Muted Trumpet":"\u52A0\u5F31\u97F3\u5668\u5C0F\u53F7","French Horn":"\u6CD5\u56FD\u53F7","Brass Section":"\u94DC\u7BA1\u7EC4","Synth Brass":"\u5408\u6210\u94DC\u7BA1\u97F3\u8272","Soprano Sax":"\u9AD8\u97F3\u8428\u514B\u65AF\u98CE","Alto Sax":"\u4E2D\u97F3\u8428\u514B\u65AF\u98CE","Tenor Sax":"\u6B21\u4E2D\u97F3\u8428\u514B\u65AF\u98CE","Baritone Sax":"\u4F4E\u97F3\u8428\u514B\u65AF\u98CE",Oboe:"\u53CC\u7C27\u7BA1","English Horn":"\u82F1\u56FD\u7BA1",Bassoon:"\u5DF4\u677E",Clarinet:"\u5355\u7C27\u7BA1",Piccolo:"\u77ED\u7B1B",Flute:"\u957F\u7B1B",Recorder:"\u7AD6\u7B1B","Pan Flute":"\u6392\u7BAB","Bottle Blow":"\u74F6\u6728\u7BA1",Whistle:"\u53E3\u54E8\u58F0",Ocarina:"\u5965\u5361\u96F7\u90A3",Lead:"\u5408\u6210\u4E3B\u97F3","Lead lead":"\u5408\u6210\u4E3B\u97F3","Pad age":"\u5408\u6210\u97F3\u8272",Pad:"\u5408\u6210\u97F3\u8272",FX:"\u5408\u6210\u6548\u679C \u79D1\u5E7B",Sitar:"\u897F\u5854\u5C14",Banjo:"\u73ED\u5353\u7434",Shamisen:"\u4E09\u6627\u7EBF",Koto:"\u5341\u4E09\u5F26\u7B5D",Kalimba:"\u5361\u6797\u5DF4",Bagpipe:"\u98CE\u7B1B",Fiddle:"\u6C11\u65CF\u63D0\u7434",Shanai:"\u5C71\u5948","Tinkle Bell":"\u53EE\u5F53\u94C3",Agogo:"\u963F\u54E5\u54E5\u94C3","Steel Drums":"\u94A2\u9F13","Taiko Drum":"\u592A\u9F13","Melodic Tom":"\u901A\u901A\u9F13","Synth Drum":"\u5408\u6210\u9F13","Reverse Cymbal":"\u94DC\u94B9","Guitar Fret Noise":"\u5409\u4ED6\u6362\u628A\u6742\u97F3","Breath Noise":"\u547C\u5438\u58F0",Seashore:"\u6D77\u6D6A\u58F0","Bird Tweet":"\u9E1F\u9E23","Telephone Ring":"\u7535\u8BDD\u94C3",Helicopter:"\u76F4\u5347\u673A",Applause:"\u9F13\u638C\u58F0",Gunshot:"\u67AA\u58F0","Acoustic Bass Drum":"\u5927\u9F13","Bass Drum":"\u5927\u9F13","Side Stick":"\u5C0F\u9F13\u9F13\u8FB9","Acoustic Snare":"\u5C0F\u9F13","Hand Clap":"\u62CD\u624B","Electric Snare":"\u5C0F\u9F13","Low Floor Tom":"\u4F4E\u97F3\u9F13","Closed Hi-Hat":"\u95ED\u5408\u94B9","High Floor Tom":"\u4F4E\u97F3\u9F13","Pedal Hi-Hat":"\u811A\u8E0F\u94B9","Low Tom":"\u4E2D\u97F3\u9F13","Open Hi-Hat":"\u5F3A\u97F3\u94B9","Low-Mid Tom":"\u4E2D\u97F3\u9F13","Hi Mid Tom":"\u9AD8\u97F3\u9F13","Crash Cymbal":"\u5F3A\u97F3\u94B9","High Tom":"\u9AD8\u97F3\u9F13","Ride Cymbal":"\u6253\u70B9\u94B9","Chinese Cymbal":"\u94B9","Ride Bell":"\u5706\u94C3",Tambourine:"\u94C3\u9F13","Splash Cymbal":"\u5C0F\u94B9\u94DC\u94B9",Cowbell:"\u725B\u94C3","Vibra-Slap":"\u98A4\u97F3\u5668","Hi Bongo":"\u9AD8\u97F3\u90A6\u52A0\u9F13","Low Bongo":"\u4F4E\u97F3\u90A6\u52A0\u9F13","Mute Hi Conga":"\u5F31\u97F3\u9AD8\u97F3\u5EB7\u52A0\u9F13","Open Hi Conga":"\u5F3A\u97F3\u9AD8\u97F3\u5EB7\u52A0\u9F13","Low Conga":"\u4F4E\u97F3\u5EB7\u52A0\u9F13","High Timbale":"\u9AD8\u97F3\u5929\u5DF4\u9F13","Low Timbale":"\u4F4E\u97F3\u5929\u5DF4\u9F13","High Agogo":"\u9AD8\u97F3\u963F\u54E5\u54E5","Low Agogo":"\u4F4E\u97F3\u963F\u54E5\u54E5",Cabasa:"\u4E32\u73E0",Maracas:"\u6C99\u94C3","Short Whistle":"\u77ED\u53E3\u54E8","Long Whistle":"\u957F\u53E3\u54E8","Short Guiro":"\u77ED\u522E\u58F6","Long Guiro":"\u957F\u522E\u58F6",Claves:"\u6886\u5B50","Hi Wood Block":"\u9AD8\u97F3\u6728\u5757","Low Wood Block":"\u4F4E\u97F3\u6728\u5757","Mute Triangle":"\u5F31\u97F3\u4E09\u89D2\u94C1","Open Triangle":"\u5F3A\u97F3\u4E09\u89D2\u94C1","Hulusi flute":"\u846B\u82A6\u4E1D",Melodica:"\u53E3\u98CE\u7434","Snare Drum":"\u5C0F\u519B\u9F13",Cymbal:"\u9572",Cymbals:"\u9572","Horn in F":"\u5706\u53F7",Triangle:"\u4E09\u89D2\u94C1",Vibrato:"\u98A4\u97F3\u7434","Suspend Cymbal":"\u540A\u9572","Tom-Toms":"\u55F5\u55F5\u9F13",Bell:"\u94C3\u94DB",Bells:"\u94C3\u94DB","Alto Clarinet":"\u4E2D\u97F3\u5355\u7C27\u7BA1","Soprano Saxophone":"\u9AD8\u97F3\u8428\u514B\u65AF\u98CE","Alto Saxophone":"\u4E2D\u97F3\u8428\u514B\u65AF\u98CE","Tenor Saxophone":"\u6B21\u4E2D\u97F3\u8428\u514B\u65AF\u98CE","Baritone Saxophone":"\u4F4E\u97F3\u8428\u514B\u65AF\u98CE",Cornet:"\u77ED\u53F7",Euphonium:"\u4E0A\u4F4E\u97F3\u53F7","crash cymbals":"\u5BF9\u9572","Suspend cymbals":"\u540A\u9572",Castanets:"\u54CD\u677F"},Vs=h=>{const t=h.replace(/ /g," ").toLocaleLowerCase(),e=Object.keys(ne);for(let i=0;i<e.length;i++)if(e[i].replace(/ /g," ").toLocaleLowerCase()===t)return ne[e[i]]||"";for(let i=0;i<e.length;i++){const s=e[i].replace(/ /g," ").toLocaleLowerCase();if(t.includes(s))return ne[e[i]]||""}return""};var Xt={exports:{}},Et={exports:{}};(function(){var h,t,e,i,s,r;typeof performance!="undefined"&&performance!==null&&performance.now?Et.exports=function(){return performance.now()}:typeof process!="undefined"&&process!==null&&process.hrtime?(Et.exports=function(){return(h()-s)/1e6},t=process.hrtime,h=function(){var a;return a=t(),a[0]*1e9+a[1]},i=h(),r=process.uptime()*1e9,s=i-r):Date.now?(Et.exports=function(){return Date.now()-e},e=Date.now()):(Et.exports=function(){return new Date().getTime()-e},e=new Date().getTime())}).call(We);var oi=Et.exports,st=typeof window=="undefined"?We:window,_t=["moz","webkit"],At="AnimationFrame",St=st["request"+At],Pt=st["cancel"+At]||st["cancelRequest"+At];for(var wt=0;!St&&wt<_t.length;wt++)St=st[_t[wt]+"Request"+At],Pt=st[_t[wt]+"Cancel"+At]||st[_t[wt]+"CancelRequest"+At];if(!St||!Pt){var ae=0,Ee=0,gt=[],ui=1e3/60;St=function(h){if(gt.length===0){var t=oi(),e=Math.max(0,ui-(t-ae));ae=e+t,setTimeout(function(){var i=gt.slice(0);gt.length=0;for(var s=0;s<i.length;s++)if(!i[s].cancelled)try{i[s].callback(ae)}catch(r){setTimeout(function(){throw r},0)}},Math.round(e))}return gt.push({handle:++Ee,callback:h,cancelled:!1}),Ee},Pt=function(h){for(var t=0;t<gt.length;t++)gt[t].handle===h&&(gt[t].cancelled=!0)}}Xt.exports=function(h){return St.call(st,h)};Xt.exports.cancel=function(){Pt.apply(st,arguments)};Xt.exports.polyfill=function(h){h||(h=st),h.requestAnimationFrame=St,h.cancelAnimationFrame=Pt};var oe=Xt.exports,ce=function(h){this.ok=!1,this.alpha=1,h.charAt(0)=="#"&&(h=h.substr(1,6)),h=h.replace(/ /g,""),h=h.toLowerCase();var t={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};h=t[h]||h;for(var e=[{re:/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,example:["rgba(123, 234, 45, 0.8)","rgba(255,234,245,1.0)"],process:function(o){return[parseInt(o[1]),parseInt(o[2]),parseInt(o[3]),parseFloat(o[4])]}},{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(o){return[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]}},{re:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,example:["#00ff00","336699"],process:function(o){return[parseInt(o[1],16),parseInt(o[2],16),parseInt(o[3],16)]}},{re:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,example:["#fb0","f0f"],process:function(o){return[parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16),parseInt(o[3]+o[3],16)]}}],i=0;i<e.length;i++){var s=e[i].re,r=e[i].process,a=s.exec(h);if(a){var n=r(a);this.r=n[0],this.g=n[1],this.b=n[2],n.length>3&&(this.alpha=n[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var o=this.r.toString(16),u=this.g.toString(16),l=this.b.toString(16);return o.length==1&&(o="0"+o),u.length==1&&(u="0"+u),l.length==1&&(l="0"+l),"#"+o+u+l},this.getHelpXML=function(){for(var o=new Array,u=0;u<e.length;u++)for(var l=e[u].example,f=0;f<l.length;f++)o[o.length]=l[f];for(var g in t)o[o.length]=g;var c=document.createElement("ul");c.setAttribute("id","rgbcolor-examples");for(var u=0;u<o.length;u++)try{var d=document.createElement("li"),p=new RGBColor(o[u]),y=document.createElement("div");y.style.cssText="margin: 3px; border: 1px solid black; background:"+p.toHex()+"; color:"+p.toHex(),y.appendChild(document.createTextNode("test"));var x=document.createTextNode(" "+o[u]+" -> "+p.toRGB()+" -> "+p.toHex());d.appendChild(y),d.appendChild(x),c.appendChild(d)}catch{}return c}};/*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation.
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted.
  5. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  6. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  7. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  8. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  9. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  10. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  11. PERFORMANCE OF THIS SOFTWARE.
  12. ***************************************************************************** */var Ge=function(h,t){return(Ge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])})(h,t)};function qe(h,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=h}Ge(h,t),h.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function hi(h){var t="";Array.isArray(h)||(h=[h]);for(var e=0;e<h.length;e++){var i=h[e];if(i.type===m.CLOSE_PATH)t+="z";else if(i.type===m.HORIZ_LINE_TO)t+=(i.relative?"h":"H")+i.x;else if(i.type===m.VERT_LINE_TO)t+=(i.relative?"v":"V")+i.y;else if(i.type===m.MOVE_TO)t+=(i.relative?"m":"M")+i.x+" "+i.y;else if(i.type===m.LINE_TO)t+=(i.relative?"l":"L")+i.x+" "+i.y;else if(i.type===m.CURVE_TO)t+=(i.relative?"c":"C")+i.x1+" "+i.y1+" "+i.x2+" "+i.y2+" "+i.x+" "+i.y;else if(i.type===m.SMOOTH_CURVE_TO)t+=(i.relative?"s":"S")+i.x2+" "+i.y2+" "+i.x+" "+i.y;else if(i.type===m.QUAD_TO)t+=(i.relative?"q":"Q")+i.x1+" "+i.y1+" "+i.x+" "+i.y;else if(i.type===m.SMOOTH_QUAD_TO)t+=(i.relative?"t":"T")+i.x+" "+i.y;else{if(i.type!==m.ARC)throw new Error('Unexpected command type "'+i.type+'" at index '+e+".");t+=(i.relative?"a":"A")+i.rX+" "+i.rY+" "+i.xRot+" "+ +i.lArcFlag+" "+ +i.sweepFlag+" "+i.x+" "+i.y}}return t}function fe(h,t){var e=h[0],i=h[1];return[e*Math.cos(t)-i*Math.sin(t),e*Math.sin(t)+i*Math.cos(t)]}function K(){for(var h=[],t=0;t<arguments.length;t++)h[t]=arguments[t];for(var e=0;e<h.length;e++)if(typeof h[e]!="number")throw new Error("assertNumbers arguments["+e+"] is not a number. "+typeof h[e]+" == typeof "+h[e]);return!0}var at=Math.PI;function ue(h,t,e){h.lArcFlag=h.lArcFlag===0?0:1,h.sweepFlag=h.sweepFlag===0?0:1;var i=h.rX,s=h.rY,r=h.x,a=h.y;i=Math.abs(h.rX),s=Math.abs(h.rY);var n=fe([(t-r)/2,(e-a)/2],-h.xRot/180*at),o=n[0],u=n[1],l=Math.pow(o,2)/Math.pow(i,2)+Math.pow(u,2)/Math.pow(s,2);1<l&&(i*=Math.sqrt(l),s*=Math.sqrt(l)),h.rX=i,h.rY=s;var f=Math.pow(i,2)*Math.pow(u,2)+Math.pow(s,2)*Math.pow(o,2),g=(h.lArcFlag!==h.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(i,2)*Math.pow(s,2)-f)/f)),c=i*u/s*g,d=-s*o/i*g,p=fe([c,d],h.xRot/180*at);h.cX=p[0]+(t+r)/2,h.cY=p[1]+(e+a)/2,h.phi1=Math.atan2((u-d)/s,(o-c)/i),h.phi2=Math.atan2((-u-d)/s,(-o-c)/i),h.sweepFlag===0&&h.phi2>h.phi1&&(h.phi2-=2*at),h.sweepFlag===1&&h.phi2<h.phi1&&(h.phi2+=2*at),h.phi1*=180/at,h.phi2*=180/at}function Pe(h,t,e){K(h,t,e);var i=h*h+t*t-e*e;if(0>i)return[];if(i===0)return[[h*e/(h*h+t*t),t*e/(h*h+t*t)]];var s=Math.sqrt(i);return[[(h*e+t*s)/(h*h+t*t),(t*e-h*s)/(h*h+t*t)],[(h*e-t*s)/(h*h+t*t),(t*e+h*s)/(h*h+t*t)]]}var D,et=Math.PI/180;function Me(h,t,e){return(1-e)*h+e*t}function Fe(h,t,e,i){return h+Math.cos(i/180*at)*t+Math.sin(i/180*at)*e}function Ne(h,t,e,i){var s=1e-6,r=t-h,a=e-t,n=3*r+3*(i-e)-6*a,o=6*(a-r),u=3*r;return Math.abs(n)<s?[-u/o]:function(l,f,g){g===void 0&&(g=1e-6);var c=l*l/4-f;if(c<-g)return[];if(c<=g)return[-l/2];var d=Math.sqrt(c);return[-l/2-d,-l/2+d]}(o/n,u/n,s)}function Oe(h,t,e,i,s){var r=1-s;return h*(r*r*r)+t*(3*r*r*s)+e*(3*r*s*s)+i*(s*s*s)}(function(h){function t(){return s(function(n,o,u){return n.relative&&(n.x1!==void 0&&(n.x1+=o),n.y1!==void 0&&(n.y1+=u),n.x2!==void 0&&(n.x2+=o),n.y2!==void 0&&(n.y2+=u),n.x!==void 0&&(n.x+=o),n.y!==void 0&&(n.y+=u),n.relative=!1),n})}function e(){var n=NaN,o=NaN,u=NaN,l=NaN;return s(function(f,g,c){return f.type&m.SMOOTH_CURVE_TO&&(f.type=m.CURVE_TO,n=isNaN(n)?g:n,o=isNaN(o)?c:o,f.x1=f.relative?g-n:2*g-n,f.y1=f.relative?c-o:2*c-o),f.type&m.CURVE_TO?(n=f.relative?g+f.x2:f.x2,o=f.relative?c+f.y2:f.y2):(n=NaN,o=NaN),f.type&m.SMOOTH_QUAD_TO&&(f.type=m.QUAD_TO,u=isNaN(u)?g:u,l=isNaN(l)?c:l,f.x1=f.relative?g-u:2*g-u,f.y1=f.relative?c-l:2*c-l),f.type&m.QUAD_TO?(u=f.relative?g+f.x1:f.x1,l=f.relative?c+f.y1:f.y1):(u=NaN,l=NaN),f})}function i(){var n=NaN,o=NaN;return s(function(u,l,f){if(u.type&m.SMOOTH_QUAD_TO&&(u.type=m.QUAD_TO,n=isNaN(n)?l:n,o=isNaN(o)?f:o,u.x1=u.relative?l-n:2*l-n,u.y1=u.relative?f-o:2*f-o),u.type&m.QUAD_TO){n=u.relative?l+u.x1:u.x1,o=u.relative?f+u.y1:u.y1;var g=u.x1,c=u.y1;u.type=m.CURVE_TO,u.x1=((u.relative?0:l)+2*g)/3,u.y1=((u.relative?0:f)+2*c)/3,u.x2=(u.x+2*g)/3,u.y2=(u.y+2*c)/3}else n=NaN,o=NaN;return u})}function s(n){var o=0,u=0,l=NaN,f=NaN;return function(g){if(isNaN(l)&&!(g.type&m.MOVE_TO))throw new Error("path must start with moveto");var c=n(g,o,u,l,f);return g.type&m.CLOSE_PATH&&(o=l,u=f),g.x!==void 0&&(o=g.relative?o+g.x:g.x),g.y!==void 0&&(u=g.relative?u+g.y:g.y),g.type&m.MOVE_TO&&(l=o,f=u),c}}function r(n,o,u,l,f,g){return K(n,o,u,l,f,g),s(function(c,d,p,y){var x=c.x1,C=c.x2,b=c.relative&&!isNaN(y),v=c.x!==void 0?c.x:b?0:d,E=c.y!==void 0?c.y:b?0:p;function w(Z){return Z*Z}c.type&m.HORIZ_LINE_TO&&o!==0&&(c.type=m.LINE_TO,c.y=c.relative?0:p),c.type&m.VERT_LINE_TO&&u!==0&&(c.type=m.LINE_TO,c.x=c.relative?0:d),c.x!==void 0&&(c.x=c.x*n+E*u+(b?0:f)),c.y!==void 0&&(c.y=v*o+c.y*l+(b?0:g)),c.x1!==void 0&&(c.x1=c.x1*n+c.y1*u+(b?0:f)),c.y1!==void 0&&(c.y1=x*o+c.y1*l+(b?0:g)),c.x2!==void 0&&(c.x2=c.x2*n+c.y2*u+(b?0:f)),c.y2!==void 0&&(c.y2=C*o+c.y2*l+(b?0:g));var S=n*l-o*u;if(c.xRot!==void 0&&(n!==1||o!==0||u!==0||l!==1))if(S===0)delete c.rX,delete c.rY,delete c.xRot,delete c.lArcFlag,delete c.sweepFlag,c.type=m.LINE_TO;else{var F=c.xRot*Math.PI/180,k=Math.sin(F),_=Math.cos(F),z=1/w(c.rX),I=1/w(c.rY),U=w(_)*z+w(k)*I,L=2*k*_*(z-I),R=w(k)*z+w(_)*I,X=U*l*l-L*o*l+R*o*o,H=L*(n*l+o*u)-2*(U*u*l+R*n*o),Q=U*u*u-L*n*u+R*n*n,V=(Math.atan2(H,X-Q)+Math.PI)%Math.PI/2,N=Math.sin(V),Y=Math.cos(V);c.rX=Math.abs(S)/Math.sqrt(X*w(Y)+H*N*Y+Q*w(N)),c.rY=Math.abs(S)/Math.sqrt(X*w(N)-H*N*Y+Q*w(Y)),c.xRot=180*V/Math.PI}return c.sweepFlag!==void 0&&0>S&&(c.sweepFlag=+!c.sweepFlag),c})}function a(){return function(n){var o={};for(var u in n)o[u]=n[u];return o}}h.ROUND=function(n){function o(u){return Math.round(u*n)/n}return n===void 0&&(n=1e13),K(n),function(u){return u.x1!==void 0&&(u.x1=o(u.x1)),u.y1!==void 0&&(u.y1=o(u.y1)),u.x2!==void 0&&(u.x2=o(u.x2)),u.y2!==void 0&&(u.y2=o(u.y2)),u.x!==void 0&&(u.x=o(u.x)),u.y!==void 0&&(u.y=o(u.y)),u.rX!==void 0&&(u.rX=o(u.rX)),u.rY!==void 0&&(u.rY=o(u.rY)),u}},h.TO_ABS=t,h.TO_REL=function(){return s(function(n,o,u){return n.relative||(n.x1!==void 0&&(n.x1-=o),n.y1!==void 0&&(n.y1-=u),n.x2!==void 0&&(n.x2-=o),n.y2!==void 0&&(n.y2-=u),n.x!==void 0&&(n.x-=o),n.y!==void 0&&(n.y-=u),n.relative=!0),n})},h.NORMALIZE_HVZ=function(n,o,u){return n===void 0&&(n=!0),o===void 0&&(o=!0),u===void 0&&(u=!0),s(function(l,f,g,c,d){if(isNaN(c)&&!(l.type&m.MOVE_TO))throw new Error("path must start with moveto");return o&&l.type&m.HORIZ_LINE_TO&&(l.type=m.LINE_TO,l.y=l.relative?0:g),u&&l.type&m.VERT_LINE_TO&&(l.type=m.LINE_TO,l.x=l.relative?0:f),n&&l.type&m.CLOSE_PATH&&(l.type=m.LINE_TO,l.x=l.relative?c-f:c,l.y=l.relative?d-g:d),l.type&m.ARC&&(l.rX===0||l.rY===0)&&(l.type=m.LINE_TO,delete l.rX,delete l.rY,delete l.xRot,delete l.lArcFlag,delete l.sweepFlag),l})},h.NORMALIZE_ST=e,h.QT_TO_C=i,h.INFO=s,h.SANITIZE=function(n){n===void 0&&(n=0),K(n);var o=NaN,u=NaN,l=NaN,f=NaN;return s(function(g,c,d,p,y){var x=Math.abs,C=!1,b=0,v=0;if(g.type&m.SMOOTH_CURVE_TO&&(b=isNaN(o)?0:c-o,v=isNaN(u)?0:d-u),g.type&(m.CURVE_TO|m.SMOOTH_CURVE_TO)?(o=g.relative?c+g.x2:g.x2,u=g.relative?d+g.y2:g.y2):(o=NaN,u=NaN),g.type&m.SMOOTH_QUAD_TO?(l=isNaN(l)?c:2*c-l,f=isNaN(f)?d:2*d-f):g.type&m.QUAD_TO?(l=g.relative?c+g.x1:g.x1,f=g.relative?d+g.y1:g.y2):(l=NaN,f=NaN),g.type&m.LINE_COMMANDS||g.type&m.ARC&&(g.rX===0||g.rY===0||!g.lArcFlag)||g.type&m.CURVE_TO||g.type&m.SMOOTH_CURVE_TO||g.type&m.QUAD_TO||g.type&m.SMOOTH_QUAD_TO){var E=g.x===void 0?0:g.relative?g.x:g.x-c,w=g.y===void 0?0:g.relative?g.y:g.y-d;b=isNaN(l)?g.x1===void 0?b:g.relative?g.x:g.x1-c:l-c,v=isNaN(f)?g.y1===void 0?v:g.relative?g.y:g.y1-d:f-d;var S=g.x2===void 0?0:g.relative?g.x:g.x2-c,F=g.y2===void 0?0:g.relative?g.y:g.y2-d;x(E)<=n&&x(w)<=n&&x(b)<=n&&x(v)<=n&&x(S)<=n&&x(F)<=n&&(C=!0)}return g.type&m.CLOSE_PATH&&x(c-p)<=n&&x(d-y)<=n&&(C=!0),C?[]:g})},h.MATRIX=r,h.ROTATE=function(n,o,u){o===void 0&&(o=0),u===void 0&&(u=0),K(n,o,u);var l=Math.sin(n),f=Math.cos(n);return r(f,l,-l,f,o-o*f+u*l,u-o*l-u*f)},h.TRANSLATE=function(n,o){return o===void 0&&(o=0),K(n,o),r(1,0,0,1,n,o)},h.SCALE=function(n,o){return o===void 0&&(o=n),K(n,o),r(n,0,0,o,0,0)},h.SKEW_X=function(n){return K(n),r(1,0,Math.atan(n),1,0,0)},h.SKEW_Y=function(n){return K(n),r(1,Math.atan(n),0,1,0,0)},h.X_AXIS_SYMMETRY=function(n){return n===void 0&&(n=0),K(n),r(-1,0,0,1,n,0)},h.Y_AXIS_SYMMETRY=function(n){return n===void 0&&(n=0),K(n),r(1,0,0,-1,0,n)},h.A_TO_C=function(){return s(function(n,o,u){return m.ARC===n.type?function(l,f,g){var c,d,p,y;l.cX||ue(l,f,g);for(var x=Math.min(l.phi1,l.phi2),C=Math.max(l.phi1,l.phi2)-x,b=Math.ceil(C/90),v=new Array(b),E=f,w=g,S=0;S<b;S++){var F=Me(l.phi1,l.phi2,S/b),k=Me(l.phi1,l.phi2,(S+1)/b),_=k-F,z=4/3*Math.tan(_*et/4),I=[Math.cos(F*et)-z*Math.sin(F*et),Math.sin(F*et)+z*Math.cos(F*et)],U=I[0],L=I[1],R=[Math.cos(k*et),Math.sin(k*et)],X=R[0],H=R[1],Q=[X+z*Math.sin(k*et),H-z*Math.cos(k*et)],V=Q[0],N=Q[1];v[S]={relative:l.relative,type:m.CURVE_TO};var Y=function(Z,tt){var nt=fe([Z*l.rX,tt*l.rY],l.xRot),yt=nt[0],Nt=nt[1];return[l.cX+yt,l.cY+Nt]};c=Y(U,L),v[S].x1=c[0],v[S].y1=c[1],d=Y(V,N),v[S].x2=d[0],v[S].y2=d[1],p=Y(X,H),v[S].x=p[0],v[S].y=p[1],l.relative&&(v[S].x1-=E,v[S].y1-=w,v[S].x2-=E,v[S].y2-=w,v[S].x-=E,v[S].y-=w),E=(y=[v[S].x,v[S].y])[0],w=y[1]}return v}(n,n.relative?0:o,n.relative?0:u):n})},h.ANNOTATE_ARCS=function(){return s(function(n,o,u){return n.relative&&(o=0,u=0),m.ARC===n.type&&ue(n,o,u),n})},h.CLONE=a,h.CALCULATE_BOUNDS=function(){var n=function(g){var c={};for(var d in g)c[d]=g[d];return c},o=t(),u=i(),l=e(),f=s(function(g,c,d){var p=l(u(o(n(g))));function y(N){N>f.maxX&&(f.maxX=N),N<f.minX&&(f.minX=N)}function x(N){N>f.maxY&&(f.maxY=N),N<f.minY&&(f.minY=N)}if(p.type&m.DRAWING_COMMANDS&&(y(c),x(d)),p.type&m.HORIZ_LINE_TO&&y(p.x),p.type&m.VERT_LINE_TO&&x(p.y),p.type&m.LINE_TO&&(y(p.x),x(p.y)),p.type&m.CURVE_TO){y(p.x),x(p.y);for(var C=0,b=Ne(c,p.x1,p.x2,p.x);C<b.length;C++)0<(V=b[C])&&1>V&&y(Oe(c,p.x1,p.x2,p.x,V));for(var v=0,E=Ne(d,p.y1,p.y2,p.y);v<E.length;v++)0<(V=E[v])&&1>V&&x(Oe(d,p.y1,p.y2,p.y,V))}if(p.type&m.ARC){y(p.x),x(p.y),ue(p,c,d);for(var w=p.xRot/180*Math.PI,S=Math.cos(w)*p.rX,F=Math.sin(w)*p.rX,k=-Math.sin(w)*p.rY,_=Math.cos(w)*p.rY,z=p.phi1<p.phi2?[p.phi1,p.phi2]:-180>p.phi2?[p.phi2+360,p.phi1+360]:[p.phi2,p.phi1],I=z[0],U=z[1],L=function(N){var Y=N[0],Z=N[1],tt=180*Math.atan2(Z,Y)/Math.PI;return tt<I?tt+360:tt},R=0,X=Pe(k,-S,0).map(L);R<X.length;R++)(V=X[R])>I&&V<U&&y(Fe(p.cX,S,k,V));for(var H=0,Q=Pe(_,-F,0).map(L);H<Q.length;H++){var V;(V=Q[H])>I&&V<U&&x(Fe(p.cY,F,_,V))}}return g});return f.minX=1/0,f.maxX=-1/0,f.minY=1/0,f.maxY=-1/0,f}})(D||(D={}));var j,Qe=function(){function h(){}return h.prototype.round=function(t){return this.transform(D.ROUND(t))},h.prototype.toAbs=function(){return this.transform(D.TO_ABS())},h.prototype.toRel=function(){return this.transform(D.TO_REL())},h.prototype.normalizeHVZ=function(t,e,i){return this.transform(D.NORMALIZE_HVZ(t,e,i))},h.prototype.normalizeST=function(){return this.transform(D.NORMALIZE_ST())},h.prototype.qtToC=function(){return this.transform(D.QT_TO_C())},h.prototype.aToC=function(){return this.transform(D.A_TO_C())},h.prototype.sanitize=function(t){return this.transform(D.SANITIZE(t))},h.prototype.translate=function(t,e){return this.transform(D.TRANSLATE(t,e))},h.prototype.scale=function(t,e){return this.transform(D.SCALE(t,e))},h.prototype.rotate=function(t,e,i){return this.transform(D.ROTATE(t,e,i))},h.prototype.matrix=function(t,e,i,s,r,a){return this.transform(D.MATRIX(t,e,i,s,r,a))},h.prototype.skewX=function(t){return this.transform(D.SKEW_X(t))},h.prototype.skewY=function(t){return this.transform(D.SKEW_Y(t))},h.prototype.xSymmetry=function(t){return this.transform(D.X_AXIS_SYMMETRY(t))},h.prototype.ySymmetry=function(t){return this.transform(D.Y_AXIS_SYMMETRY(t))},h.prototype.annotateArcs=function(){return this.transform(D.ANNOTATE_ARCS())},h}(),li=function(h){return h===" "||h===" "||h==="\r"||h===`
  13. `},Ve=function(h){return"0".charCodeAt(0)<=h.charCodeAt(0)&&h.charCodeAt(0)<="9".charCodeAt(0)},ci=function(h){function t(){var e=h.call(this)||this;return e.curNumber="",e.curCommandType=-1,e.curCommandRelative=!1,e.canParseCommandOrComma=!0,e.curNumberHasExp=!1,e.curNumberHasExpDigits=!1,e.curNumberHasDecimal=!1,e.curArgs=[],e}return qe(t,h),t.prototype.finish=function(e){if(e===void 0&&(e=[]),this.parse(" ",e),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return e},t.prototype.parse=function(e,i){var s=this;i===void 0&&(i=[]);for(var r=function(f){i.push(f),s.curArgs.length=0,s.canParseCommandOrComma=!0},a=0;a<e.length;a++){var n=e[a],o=!(this.curCommandType!==m.ARC||this.curArgs.length!==3&&this.curArgs.length!==4||this.curNumber.length!==1||this.curNumber!=="0"&&this.curNumber!=="1"),u=Ve(n)&&(this.curNumber==="0"&&n==="0"||o);if(!Ve(n)||u)if(n!=="e"&&n!=="E")if(n!=="-"&&n!=="+"||!this.curNumberHasExp||this.curNumberHasExpDigits)if(n!=="."||this.curNumberHasExp||this.curNumberHasDecimal||o){if(this.curNumber&&this.curCommandType!==-1){var l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError("Invalid number ending at "+a);if(this.curCommandType===m.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>l)throw new SyntaxError('Expected positive number, got "'+l+'" at index "'+a+'"')}else if((this.curArgs.length===3||this.curArgs.length===4)&&this.curNumber!=="0"&&this.curNumber!=="1")throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+a+'"')}this.curArgs.push(l),this.curArgs.length===fi[this.curCommandType]&&(m.HORIZ_LINE_TO===this.curCommandType?r({type:m.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):m.VERT_LINE_TO===this.curCommandType?r({type:m.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===m.MOVE_TO||this.curCommandType===m.LINE_TO||this.curCommandType===m.SMOOTH_QUAD_TO?(r({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),m.MOVE_TO===this.curCommandType&&(this.curCommandType=m.LINE_TO)):this.curCommandType===m.CURVE_TO?r({type:m.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===m.SMOOTH_CURVE_TO?r({type:m.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===m.QUAD_TO?r({type:m.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===m.ARC&&r({type:m.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!li(n))if(n===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(n!=="+"&&n!=="-"&&n!==".")if(u)this.curNumber=n,this.curNumberHasDecimal=!1;else{if(this.curArgs.length!==0)throw new SyntaxError("Unterminated command at index "+a+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+n+'" at index '+a+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,n!=="z"&&n!=="Z")if(n==="h"||n==="H")this.curCommandType=m.HORIZ_LINE_TO,this.curCommandRelative=n==="h";else if(n==="v"||n==="V")this.curCommandType=m.VERT_LINE_TO,this.curCommandRelative=n==="v";else if(n==="m"||n==="M")this.curCommandType=m.MOVE_TO,this.curCommandRelative=n==="m";else if(n==="l"||n==="L")this.curCommandType=m.LINE_TO,this.curCommandRelative=n==="l";else if(n==="c"||n==="C")this.curCommandType=m.CURVE_TO,this.curCommandRelative=n==="c";else if(n==="s"||n==="S")this.curCommandType=m.SMOOTH_CURVE_TO,this.curCommandRelative=n==="s";else if(n==="q"||n==="Q")this.curCommandType=m.QUAD_TO,this.curCommandRelative=n==="q";else if(n==="t"||n==="T")this.curCommandType=m.SMOOTH_QUAD_TO,this.curCommandRelative=n==="t";else{if(n!=="a"&&n!=="A")throw new SyntaxError('Unexpected character "'+n+'" at index '+a+".");this.curCommandType=m.ARC,this.curCommandRelative=n==="a"}else i.push({type:m.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=n,this.curNumberHasDecimal=n==="."}else this.curNumber+=n,this.curNumberHasDecimal=!0;else this.curNumber+=n;else this.curNumber+=n,this.curNumberHasExp=!0;else this.curNumber+=n,this.curNumberHasExpDigits=this.curNumberHasExp}return i},t.prototype.transform=function(e){return Object.create(this,{parse:{value:function(i,s){s===void 0&&(s=[]);for(var r=0,a=Object.getPrototypeOf(this).parse.call(this,i);r<a.length;r++){var n=a[r],o=e(n);Array.isArray(o)?s.push.apply(s,o):s.push(o)}return s}}})},t}(Qe),m=function(h){function t(e){var i=h.call(this)||this;return i.commands=typeof e=="string"?t.parse(e):e,i}return qe(t,h),t.prototype.encode=function(){return t.encode(this.commands)},t.prototype.getBounds=function(){var e=D.CALCULATE_BOUNDS();return this.transform(e),e},t.prototype.transform=function(e){for(var i=[],s=0,r=this.commands;s<r.length;s++){var a=e(r[s]);Array.isArray(a)?i.push.apply(i,a):i.push(a)}return this.commands=i,this},t.encode=function(e){return hi(e)},t.parse=function(e){var i=new ci,s=[];return i.parse(e,s),i.finish(s),s},t.CLOSE_PATH=1,t.MOVE_TO=2,t.HORIZ_LINE_TO=4,t.VERT_LINE_TO=8,t.LINE_TO=16,t.CURVE_TO=32,t.SMOOTH_CURVE_TO=64,t.QUAD_TO=128,t.SMOOTH_QUAD_TO=256,t.ARC=512,t.LINE_COMMANDS=t.LINE_TO|t.HORIZ_LINE_TO|t.VERT_LINE_TO,t.DRAWING_COMMANDS=t.HORIZ_LINE_TO|t.VERT_LINE_TO|t.LINE_TO|t.CURVE_TO|t.SMOOTH_CURVE_TO|t.QUAD_TO|t.SMOOTH_QUAD_TO|t.ARC,t}(Qe),fi=((j={})[m.MOVE_TO]=2,j[m.LINE_TO]=2,j[m.HORIZ_LINE_TO]=1,j[m.VERT_LINE_TO]=1,j[m.CLOSE_PATH]=0,j[m.QUAD_TO]=4,j[m.SMOOTH_QUAD_TO]=2,j[m.CURVE_TO]=6,j[m.SMOOTH_CURVE_TO]=4,j[m.ARC]=7,j);function Ut(h){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ut=function(t){return typeof t}:Ut=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(h)}function gi(h,t){if(!(h instanceof t))throw new TypeError("Cannot call a class as a function")}var di=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],pi=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function mi(h,t,e,i,s){if(typeof h=="string"&&(h=document.getElementById(h)),!h||Ut(h)!=="object"||!("getContext"in h))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var r=h.getContext("2d");try{return r.getImageData(t,e,i,s)}catch(a){throw new Error("unable to access image data: "+a)}}function yi(h,t,e,i,s,r){if(!(isNaN(r)||r<1)){r|=0;var a=mi(h,t,e,i,s);a=xi(a,t,e,i,s,r),h.getContext("2d").putImageData(a,t,e)}}function xi(h,t,e,i,s,r){for(var a=h.data,n=2*r+1,o=i-1,u=s-1,l=r+1,f=l*(l+1)/2,g=new ke,c=g,d,p=1;p<n;p++)c=c.next=new ke,p===l&&(d=c);c.next=g;for(var y=null,x=null,C=0,b=0,v=di[r],E=pi[r],w=0;w<s;w++){c=g;for(var S=a[b],F=a[b+1],k=a[b+2],_=a[b+3],z=0;z<l;z++)c.r=S,c.g=F,c.b=k,c.a=_,c=c.next;for(var I=0,U=0,L=0,R=0,X=l*S,H=l*F,Q=l*k,V=l*_,N=f*S,Y=f*F,Z=f*k,tt=f*_,nt=1;nt<l;nt++){var yt=b+((o<nt?o:nt)<<2),Nt=a[yt],ye=a[yt+1],xe=a[yt+2],be=a[yt+3],Ot=l-nt;N+=(c.r=Nt)*Ot,Y+=(c.g=ye)*Ot,Z+=(c.b=xe)*Ot,tt+=(c.a=be)*Ot,I+=Nt,U+=ye,L+=xe,R+=be,c=c.next}y=g,x=d;for(var qt=0;qt<i;qt++){var Qt=tt*v>>E;if(a[b+3]=Qt,Qt!==0){var $t=255/Qt;a[b]=(N*v>>E)*$t,a[b+1]=(Y*v>>E)*$t,a[b+2]=(Z*v>>E)*$t}else a[b]=a[b+1]=a[b+2]=0;N-=X,Y-=H,Z-=Q,tt-=V,X-=y.r,H-=y.g,Q-=y.b,V-=y.a;var ht=qt+r+1;ht=C+(ht<o?ht:o)<<2,I+=y.r=a[ht],U+=y.g=a[ht+1],L+=y.b=a[ht+2],R+=y.a=a[ht+3],N+=I,Y+=U,Z+=L,tt+=R,y=y.next;var Vt=x,ve=Vt.r,Ae=Vt.g,Ce=Vt.b,Se=Vt.a;X+=ve,H+=Ae,Q+=Ce,V+=Se,I-=ve,U-=Ae,L-=Ce,R-=Se,x=x.next,b+=4}C+=i}for(var xt=0;xt<i;xt++){b=xt<<2;var lt=a[b],ct=a[b+1],ft=a[b+2],G=a[b+3],Zt=l*lt,jt=l*ct,Kt=l*ft,Jt=l*G,kt=f*lt,Rt=f*ct,Bt=f*ft,Dt=f*G;c=g;for(var Te=0;Te<l;Te++)c.r=lt,c.g=ct,c.b=ft,c.a=G,c=c.next;for(var we=i,te=0,ee=0,ie=0,se=0,Lt=1;Lt<=r;Lt++){b=we+xt<<2;var It=l-Lt;kt+=(c.r=lt=a[b])*It,Rt+=(c.g=ct=a[b+1])*It,Bt+=(c.b=ft=a[b+2])*It,Dt+=(c.a=G=a[b+3])*It,se+=lt,te+=ct,ee+=ft,ie+=G,c=c.next,Lt<u&&(we+=i)}b=xt,y=g,x=d;for(var re=0;re<s;re++){var q=b<<2;a[q+3]=G=Dt*v>>E,G>0?(G=255/G,a[q]=(kt*v>>E)*G,a[q+1]=(Rt*v>>E)*G,a[q+2]=(Bt*v>>E)*G):a[q]=a[q+1]=a[q+2]=0,kt-=Zt,Rt-=jt,Bt-=Kt,Dt-=Jt,Zt-=y.r,jt-=y.g,Kt-=y.b,Jt-=y.a,q=xt+((q=re+l)<u?q:u)*i<<2,kt+=se+=y.r=a[q],Rt+=te+=y.g=a[q+1],Bt+=ee+=y.b=a[q+2],Dt+=ie+=y.a=a[q+3],y=y.next,Zt+=lt=x.r,jt+=ct=x.g,Kt+=ft=x.b,Jt+=G=x.a,se-=lt,te-=ct,ee-=ft,ie-=G,x=x.next,b+=i}}return h}var ke=function h(){gi(this,h),this.r=0,this.g=0,this.b=0,this.a=0,this.next=null};function bi(){let{DOMParser:h}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t={window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:h,createCanvas(e,i){return new OffscreenCanvas(e,i)},async createImage(e){const s=await(await fetch(e)).blob();return await createImageBitmap(s)}};return(typeof globalThis.DOMParser!="undefined"||typeof h=="undefined")&&Reflect.deleteProperty(t,"DOMParser"),t}function vi(h){let{DOMParser:t,canvas:e,fetch:i}=h;return{window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:t,fetch:i,createCanvas:e.createCanvas,createImage:e.loadImage}}var Ai=Object.freeze({__proto__:null,offscreen:bi,node:vi});function Tt(h){return h.replace(/(?!\u3000)\s+/gm," ")}function Ci(h){return h.replace(/^[\n \t]+/,"")}function Si(h){return h.replace(/[\n \t]+$/,"")}function $(h){const t=h.match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm);return t?t.map(parseFloat):[]}function Ti(h){const t=$(h);return[t[0]||0,t[1]||0,t[2]||0,t[3]||0,t[4]||0,t[5]||0]}const wi=/^[A-Z-]+$/;function Ei(h){return wi.test(h)?h.toLowerCase():h}function $e(h){const t=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(h);return t&&(t[2]||t[3]||t[4])||""}function Pi(h){if(!h.startsWith("rgb"))return h;let t=3;return h.replace(/\d+(\.\d+)?/g,(i,s)=>t--&&s?String(Math.round(parseFloat(i))):i)}const Mi=/(\[[^\]]+\])/g,Fi=/(#[^\s+>~.[:]+)/g,Ni=/(\.[^\s+>~.[:]+)/g,Oi=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,Vi=/(:[\w-]+\([^)]*\))/gi,ki=/(:[^\s+>~.[:]+)/g,Ri=/([^\s+>~.[:]+)/g;function dt(h,t){const e=t.exec(h);return e?[h.replace(t," "),e.length]:[h,0]}function Bi(h){const t=[0,0,0];let e=h.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[e,i]=dt(e,Mi),t[1]+=i,[e,i]=dt(e,Fi),t[0]+=i,[e,i]=dt(e,Ni),t[1]+=i,[e,i]=dt(e,Oi),t[2]+=i,[e,i]=dt(e,Vi),t[1]+=i,[e,i]=dt(e,ki),t[1]+=i,e=e.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[e,i]=dt(e,Ri),t[2]+=i,t.join("")}const Ct=1e-8;function Re(h){return Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))}function ge(h,t){return(h[0]*t[0]+h[1]*t[1])/(Re(h)*Re(t))}function Be(h,t){return(h[0]*t[1]<h[1]*t[0]?-1:1)*Math.acos(ge(h,t))}function De(h){return h*h*h}function Le(h){return 3*h*h*(1-h)}function Ie(h){return 3*h*(1-h)*(1-h)}function _e(h){return(1-h)*(1-h)*(1-h)}function ze(h){return h*h}function He(h){return 2*h*(1-h)}function Ue(h){return(1-h)*(1-h)}class A{static empty(t){return new A(t,"EMPTY","")}split(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:" ";const{document:e,name:i}=this;return Tt(this.getString()).trim().split(t).map(s=>new A(e,i,s))}hasValue(t){const e=this.value;return e!==null&&e!==""&&(t||e!==0)&&typeof e!="undefined"}isString(t){const{value:e}=this,i=typeof e=="string";return!i||!t?i:t.test(e)}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;const t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return typeof t=="undefined"||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return typeof t=="undefined"?0:parseFloat(t);const{value:e}=this;let i=parseFloat(e);return this.isString(/%$/)&&(i/=100),i}getString(t){return typeof t=="undefined"||this.hasValue()?typeof this.value=="undefined"?"":String(this.value):String(t)}getColor(t){let e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=Pi(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!this.hasValue())return 0;const[i,s]=typeof t=="boolean"?[void 0,t]:[t],{viewPort:r}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(r.computeSize("x"),r.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(r.computeSize("x"),r.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*r.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*r.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return this.getNumber()*15;case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case(this.isString(/%$/)&&s):return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*r.computeSize(i);default:{const a=this.getNumber();return e&&a<1?a*r.computeSize(i):a}}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():this.getNumber()*1e3:0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){const t=this.getString(),e=/#([^)'"]+)/.exec(t),i=(e==null?void 0:e[1])||t;return this.document.definitions[i]}getFillStyleDefinition(t,e){let i=this.getDefinition();if(!i)return null;if(typeof i.createGradient=="function"&&"getBoundingBox"in t)return i.createGradient(this.document.ctx,t,e);if(typeof i.createPattern=="function"){if(i.getHrefAttribute().hasValue()){const s=i.getAttribute("patternTransform");i=i.getHrefAttribute().getDefinition(),i&&s.hasValue()&&i.getAttribute("patternTransform",!0).setValue(s.value)}if(i)return i.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){if(!this.hasValue())return null;const t=this.getString();return A.textBaselineMapping[t]||null}addOpacity(t){let e=this.getColor();const i=e.length;let s=0;for(let r=0;r<i&&(e[r]===","&&s++,s!==3);r++);if(t.hasValue()&&this.isString()&&s!==3){const r=new ce(e);r.ok&&(r.alpha=t.getNumber(),e=r.toRGBA())}return new A(this.document,this.name,e)}constructor(t,e,i){this.document=t,this.name=e,this.value=i,this.isNormalizedColor=!1}}A.textBaselineMapping={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};class Mt{clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getRoot(){const[t]=this.viewPorts;return t||Xe()}getCurrent(){const{viewPorts:t}=this,e=t[t.length-1];return e||Xe()}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return typeof t=="number"?t:t==="x"?this.width:t==="y"?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}constructor(){this.viewPorts=[]}}Mt.DEFAULT_VIEWPORT_WIDTH=800;Mt.DEFAULT_VIEWPORT_HEIGHT=600;function Xe(){return{width:Mt.DEFAULT_VIEWPORT_WIDTH,height:Mt.DEFAULT_VIEWPORT_HEIGHT}}class O{static parse(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const[i=e,s=e]=$(t);return new O(i,s)}static parseScale(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;const[i=e,s=i]=$(t);return new O(i,s)}static parsePath(t){const e=$(t),i=e.length,s=[];for(let r=0;r<i;r+=2)s.push(new O(e[r],e[r+1]));return s}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){const{x:e,y:i}=this,s=e*t[0]+i*t[2]+t[4],r=e*t[1]+i*t[3]+t[5];this.x=s,this.y=r}constructor(t,e){this.x=t,this.y=e}}class Di{isWorking(){return this.working}start(){if(this.working)return;const{screen:t,onClick:e,onMouseMove:i}=this,s=t.ctx.canvas;s.onclick=e,s.onmousemove=i,this.working=!0}stop(){if(!this.working)return;const t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(!this.working)return;const{screen:t,events:e,eventElements:i}=this,{style:s}=t.ctx.canvas;let r;s&&(s.cursor=""),e.forEach((a,n)=>{let{run:o}=a;for(r=i[n];r;)o(r),r=r.parent}),this.events=[],this.eventElements=[]}checkPath(t,e){if(!this.working||!e)return;const{events:i,eventElements:s}=this;i.forEach((r,a)=>{let{x:n,y:o}=r;!s[a]&&e.isPointInPath&&e.isPointInPath(n,o)&&(s[a]=t)})}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:s}=this;i.forEach((r,a)=>{let{x:n,y:o}=r;!s[a]&&e.isPointInBox(n,o)&&(s[a]=t)})}mapXY(t,e){const{window:i,ctx:s}=this.screen,r=new O(t,e);let a=s.canvas;for(;a;)r.x-=a.offsetLeft,r.y-=a.offsetTop,a=a.offsetParent;return i!=null&&i.scrollX&&(r.x+=i.scrollX),i!=null&&i.scrollY&&(r.y+=i.scrollY),r}onClick(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:i,run(s){s.onClick&&s.onClick()}})}onMouseMove(t){const{x:e,y:i}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:i,run(s){s.onMouseMove&&s.onMouseMove()}})}constructor(t){this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}}const Ze=typeof window!="undefined"?window:null,je=typeof fetch!="undefined"?fetch.bind(void 0):void 0;class rt{wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;const t=this.waits.every(e=>e());return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){let{document:e,ctx:i,aspectRatio:s,width:r,desiredWidth:a,height:n,desiredHeight:o,minX:u=0,minY:l=0,refX:f,refY:g,clip:c=!1,clipX:d=0,clipY:p=0}=t;const y=Tt(s).replace(/^defer\s/,""),[x,C]=y.split(" "),b=x||"xMidYMid",v=C||"meet",E=r/a,w=n/o,S=Math.min(E,w),F=Math.max(E,w);let k=a,_=o;v==="meet"&&(k*=S,_*=S),v==="slice"&&(k*=F,_*=F);const z=new A(e,"refX",f),I=new A(e,"refY",g),U=z.hasValue()&&I.hasValue();if(U&&i.translate(-S*z.getPixels("x"),-S*I.getPixels("y")),c){const L=S*d,R=S*p;i.beginPath(),i.moveTo(L,R),i.lineTo(r,R),i.lineTo(r,n),i.lineTo(L,n),i.closePath(),i.clip()}if(!U){const L=v==="meet"&&S===w,R=v==="slice"&&F===w,X=v==="meet"&&S===E,H=v==="slice"&&F===E;b.startsWith("xMid")&&(L||R)&&i.translate(r/2-k/2,0),b.endsWith("YMid")&&(X||H)&&i.translate(0,n/2-_/2),b.startsWith("xMax")&&(L||R)&&i.translate(r-k,0),b.endsWith("YMax")&&(X||H)&&i.translate(0,n-_)}switch(!0){case b==="none":i.scale(E,w);break;case v==="meet":i.scale(S,S);break;case v==="slice":i.scale(F,F);break}i.translate(-u,-l)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:s=!1,ignoreDimensions:r=!1,ignoreClear:a=!1,forceRedraw:n,scaleWidth:o,scaleHeight:u,offsetX:l,offsetY:f}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{mouse:g}=this,c=1e3/rt.FRAMERATE;if(this.isReadyLock=!1,this.frameDuration=c,this.readyPromise=new Promise(C=>{this.resolveReady=C}),this.isReady()&&this.render(t,r,a,o,u,l,f),!e)return;let d=Date.now(),p=d,y=0;const x=()=>{d=Date.now(),y=d-p,y>=c&&(p=d-y%c,this.shouldUpdate(s,n)&&(this.render(t,r,a,o,u,l,f),g.runEvents())),this.intervalId=oe(x)};i||g.start(),this.intervalId=oe(x)}stop(){this.intervalId&&(oe.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){const{frameDuration:i}=this;if(this.animations.reduce((r,a)=>a.update(i)||r,!1))return!0}return!!(typeof e=="function"&&e()||!this.isReadyLock&&this.isReady()||this.mouse.hasEvents())}render(t,e,i,s,r,a,n){const{viewPort:o,ctx:u,isFirstRender:l}=this,f=u.canvas;o.clear(),f.width&&f.height&&o.setCurrent(f.width,f.height);const g=t.getStyle("width"),c=t.getStyle("height");!e&&(l||typeof s!="number"&&typeof r!="number")&&(g.hasValue()&&(f.width=g.getPixels("x"),f.style&&(f.style.width="".concat(f.width,"px"))),c.hasValue()&&(f.height=c.getPixels("y"),f.style&&(f.style.height="".concat(f.height,"px"))));let d=f.clientWidth||f.width,p=f.clientHeight||f.height;if(e&&g.hasValue()&&c.hasValue()&&(d=g.getPixels("x"),p=c.getPixels("y")),o.setCurrent(d,p),typeof a=="number"&&t.getAttribute("x",!0).setValue(a),typeof n=="number"&&t.getAttribute("y",!0).setValue(n),typeof s=="number"||typeof r=="number"){const y=$(t.getAttribute("viewBox").getString());let x=0,C=0;if(typeof s=="number"){const v=t.getStyle("width");v.hasValue()?x=v.getPixels("x")/s:y[2]&&!isNaN(y[2])&&(x=y[2]/s)}if(typeof r=="number"){const v=t.getStyle("height");v.hasValue()?C=v.getPixels("y")/r:y[3]&&!isNaN(y[3])&&(C=y[3]/r)}x||(x=C),C||(C=x),t.getAttribute("width",!0).setValue(s),t.getAttribute("height",!0).setValue(r);const b=t.getStyle("transform",!0,!0);b.setValue("".concat(b.getString()," scale(").concat(1/x,", ").concat(1/C,")"))}i||u.clearRect(0,0,d,p),t.render(u),l&&(this.isFirstRender=!1)}constructor(t,{fetch:e=je,window:i=Ze}={}){if(this.ctx=t,this.viewPort=new Mt,this.mouse=new Di(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=i,!e)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");this.fetch=e}}rt.defaultWindow=Ze;rt.defaultFetch=je;rt.FRAMERATE=30;rt.MAX_VIRTUAL_PIXELS=3e4;const{defaultFetch:Li}=rt,Ii=typeof DOMParser!="undefined"?DOMParser:void 0;class he{async parse(t){return t.startsWith("<")?this.parseFromString(t):this.load(t)}parseFromString(t){const e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch{return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){const e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent||"Unknown parse error");return t}async load(t){const i=await(await this.fetch(t)).text();return this.parseFromString(i)}constructor({fetch:t=Li,DOMParser:e=Ii}={}){if(!t)throw new Error("Can't find 'fetch' in 'globalThis', please provide it via options");if(!e)throw new Error("Can't find 'DOMParser' in 'globalThis', please provide it via options");this.fetch=t,this.DOMParser=e}}class _i{apply(t){const{x:e,y:i}=this.point;t.translate(e||0,i||0)}unapply(t){const{x:e,y:i}=this.point;t.translate(-1*e||0,-1*i||0)}applyToPoint(t){const{x:e,y:i}=this.point;t.applyTransform([1,0,0,1,e||0,i||0])}constructor(t,e){this.type="translate",this.point=O.parse(e)}}class zi{apply(t){const{cx:e,cy:i,originX:s,originY:r,angle:a}=this,n=e+s.getPixels("x"),o=i+r.getPixels("y");t.translate(n,o),t.rotate(a.getRadians()),t.translate(-n,-o)}unapply(t){const{cx:e,cy:i,originX:s,originY:r,angle:a}=this,n=e+s.getPixels("x"),o=i+r.getPixels("y");t.translate(n,o),t.rotate(-1*a.getRadians()),t.translate(-n,-o)}applyToPoint(t){const{cx:e,cy:i,angle:s}=this,r=s.getRadians();t.applyTransform([1,0,0,1,e||0,i||0]),t.applyTransform([Math.cos(r),Math.sin(r),-Math.sin(r),Math.cos(r),0,0]),t.applyTransform([1,0,0,1,-e||0,-i||0])}constructor(t,e,i){this.type="rotate";const s=$(e);this.angle=new A(t,"angle",s[0]),this.originX=i[0],this.originY=i[1],this.cx=s[1]||0,this.cy=s[2]||0}}class Hi{apply(t){const{scale:{x:e,y:i},originX:s,originY:r}=this,a=s.getPixels("x"),n=r.getPixels("y");t.translate(a,n),t.scale(e,i||e),t.translate(-a,-n)}unapply(t){const{scale:{x:e,y:i},originX:s,originY:r}=this,a=s.getPixels("x"),n=r.getPixels("y");t.translate(a,n),t.scale(1/e,1/i||e),t.translate(-a,-n)}applyToPoint(t){const{x:e,y:i}=this.scale;t.applyTransform([e||0,0,0,i||0,0,0])}constructor(t,e,i){this.type="scale";const s=O.parseScale(e);(s.x===0||s.y===0)&&(s.x=Ct,s.y=Ct),this.scale=s,this.originX=i[0],this.originY=i[1]}}class Ke{apply(t){const{originX:e,originY:i,matrix:s}=this,r=e.getPixels("x"),a=i.getPixels("y");t.translate(r,a),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),t.translate(-r,-a)}unapply(t){const{originX:e,originY:i,matrix:s}=this,r=s[0],a=s[2],n=s[4],o=s[1],u=s[3],l=s[5],f=0,g=0,c=1,d=1/(r*(u*c-l*g)-a*(o*c-l*f)+n*(o*g-u*f)),p=e.getPixels("x"),y=i.getPixels("y");t.translate(p,y),t.transform(d*(u*c-l*g),d*(l*f-o*c),d*(n*g-a*c),d*(r*c-n*f),d*(a*l-n*u),d*(n*o-r*l)),t.translate(-p,-y)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){this.type="matrix",this.matrix=Ti(e),this.originX=i[0],this.originY=i[1]}}class Je extends Ke{constructor(t,e,i){super(t,e,i),this.type="skew",this.angle=new A(t,"angle",e)}}class Ui extends Je{constructor(t,e,i){super(t,e,i),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class Xi extends Je{constructor(t,e,i){super(t,e,i),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}function Yi(h){return Tt(h).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}function Wi(h){const[t="",e=""]=h.split("(");return[t.trim(),e.trim().replace(")","")]}class pt{static fromElement(t,e){const i=e.getStyle("transform",!1,!0);if(i.hasValue()){const[s,r=s]=e.getStyle("transform-origin",!1,!0).split();if(s&&r){const a=[s,r];return new pt(t,i.getString(),a)}}return null}apply(t){this.transforms.forEach(e=>e.apply(t))}unapply(t){this.transforms.forEach(e=>e.unapply(t))}applyToPoint(t){this.transforms.forEach(e=>e.applyToPoint(t))}constructor(t,e,i){this.document=t,this.transforms=[],Yi(e).forEach(r=>{if(r==="none")return;const[a,n]=Wi(r),o=pt.transformTypes[a];o&&this.transforms.push(new o(this.document,n,i))})}}pt.transformTypes={translate:_i,rotate:zi,scale:Hi,matrix:Ke,skewX:Ui,skewY:Xi};class M{getAttribute(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const i=this.attributes[t];if(!i&&e){const s=new A(this.document,t,"");return this.attributes[t]=s,s}return i||A.empty(this.document)}getHrefAttribute(){let t;for(const e in this.attributes)if(e==="href"||e.endsWith(":href")){t=this.attributes[e];break}return t||A.empty(this.document)}getStyle(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const s=this.styles[t];if(s)return s;const r=this.getAttribute(t);if(r.hasValue())return this.styles[t]=r,r;if(!i){const{parent:a}=this;if(a){const n=a.getStyle(t);if(n.hasValue())return n}}if(e){const a=new A(this.document,t,"");return this.styles[t]=a,a}return A.empty(this.document)}render(t){if(!(this.getStyle("display").getString()==="none"||this.getStyle("visibility").getString()==="hidden")){if(t.save(),this.getStyle("mask").hasValue()){const e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if(this.getStyle("filter").getValue("none")!=="none"){const e=this.getStyle("filter").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){const e=pt.fromElement(this.document,this);e&&e.apply(t);const i=this.getStyle("clip-path",!1,!0);if(i.hasValue()){const s=i.getDefinition();s&&s.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach(e=>{e.render(t)})}addChild(t){const e=t instanceof M?t:this.document.createElement(t);e.parent=this,M.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e;const{node:i}=this;if(typeof i.matches=="function")return i.matches(t);const s=(e=i.getAttribute)===null||e===void 0?void 0:e.call(i,"class");return!s||s===""?!1:s.split(" ").some(r=>".".concat(r)===t)}addStylesFromStyleDefinition(){const{styles:t,stylesSpecificity:e}=this.document;let i;for(const s in t)if(!s.startsWith("@")&&this.matchesSelector(s)){const r=t[s],a=e[s];if(r)for(const n in r){let o=this.stylesSpecificity[n];typeof o=="undefined"&&(o="000"),a&&a>=o&&(i=r[n],i&&(this.styles[n]=i),this.stylesSpecificity[n]=a)}}}removeStyles(t,e){return e.reduce((s,r)=>{const a=t.getStyle(r);if(!a.hasValue())return s;const n=a.getString();return a.setValue(""),[...s,[r,n]]},[])}restoreStyles(t,e){e.forEach(i=>{let[s,r]=i;t.getStyle(s,!0).setValue(r)})}isFirstChild(){var t;return((t=this.parent)===null||t===void 0?void 0:t.children.indexOf(this))===0}constructor(t,e,i=!1){if(this.document=t,this.node=e,this.captureTextNodes=i,this.type="",this.attributes={},this.styles={},this.stylesSpecificity={},this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],!e||e.nodeType!==1)return;Array.from(e.attributes).forEach(a=>{const n=Ei(a.nodeName);this.attributes[n]=new A(t,n,a.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()&&this.getAttribute("style").getString().split(";").map(n=>n.trim()).forEach(n=>{if(!n)return;const[o,u]=n.split(":").map(l=>l.trim());o&&(this.styles[o]=new A(t,o,u))});const{definitions:s}=t,r=this.getAttribute("id");r.hasValue()&&(s[r.getString()]||(s[r.getString()]=this)),Array.from(e.childNodes).forEach(a=>{if(a.nodeType===1)this.addChild(a);else if(i&&(a.nodeType===3||a.nodeType===4)){const n=t.createTextNode(a);n.getText().length>0&&this.addChild(n)}})}}M.ignoreChildTypes=["title"];class Gi extends M{constructor(t,e,i){super(t,e,i)}}function qi(h){const t=h.trim();return/^('|")/.test(t)?t:'"'.concat(t,'"')}function Qi(h){return typeof process=="undefined"?h:h.trim().split(",").map(qi).join(",")}function $i(h){if(!h)return"";const t=h.trim().toLowerCase();switch(t){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return t;default:return/^oblique\s+(-|)\d+deg$/.test(t)?t:""}}function Zi(h){if(!h)return"";const t=h.trim().toLowerCase();switch(t){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return t;default:return/^[\d.]+$/.test(t)?t:""}}class W{static parse(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e=arguments.length>1?arguments[1]:void 0,i="",s="",r="",a="",n="";const o=Tt(t).trim().split(" "),u={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return o.forEach(l=>{switch(!0){case(!u.fontStyle&&W.styles.includes(l)):l!=="inherit"&&(i=l),u.fontStyle=!0;break;case(!u.fontVariant&&W.variants.includes(l)):l!=="inherit"&&(s=l),u.fontStyle=!0,u.fontVariant=!0;break;case(!u.fontWeight&&W.weights.includes(l)):l!=="inherit"&&(r=l),u.fontStyle=!0,u.fontVariant=!0,u.fontWeight=!0;break;case!u.fontSize:l!=="inherit"&&(a=l.split("/")[0]||""),u.fontStyle=!0,u.fontVariant=!0,u.fontWeight=!0,u.fontSize=!0;break;default:l!=="inherit"&&(n+=l)}}),new W(i,s,r,a,n,e)}toString(){return[$i(this.fontStyle),this.fontVariant,Zi(this.fontWeight),this.fontSize,Qi(this.fontFamily)].join(" ").trim()}constructor(t,e,i,s,r,a){const n=a?typeof a=="string"?W.parse(a):a:{};this.fontFamily=r||n.fontFamily,this.fontSize=s||n.fontSize,this.fontStyle=t||n.fontStyle,this.fontWeight=i||n.fontWeight,this.fontVariant=e||n.fontVariant}}W.styles="normal|italic|oblique|inherit";W.variants="normal|small-caps|inherit";W.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class J{get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){typeof t!="undefined"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),typeof e!="undefined"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,0)}addY(t){this.addPoint(0,t)}addBoundingBox(t){if(!t)return;const{x1:e,y1:i,x2:s,y2:r}=t;this.addPoint(e,i),this.addPoint(s,r)}sumCubic(t,e,i,s,r){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*i+3*(1-t)*Math.pow(t,2)*s+Math.pow(t,3)*r}bezierCurveAdd(t,e,i,s,r){const a=6*e-12*i+6*s,n=-3*e+9*i-9*s+3*r,o=3*i-3*e;if(n===0){if(a===0)return;const g=-o/a;0<g&&g<1&&(t?this.addX(this.sumCubic(g,e,i,s,r)):this.addY(this.sumCubic(g,e,i,s,r)));return}const u=Math.pow(a,2)-4*o*n;if(u<0)return;const l=(-a+Math.sqrt(u))/(2*n);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,i,s,r)):this.addY(this.sumCubic(l,e,i,s,r)));const f=(-a-Math.sqrt(u))/(2*n);0<f&&f<1&&(t?this.addX(this.sumCubic(f,e,i,s,r)):this.addY(this.sumCubic(f,e,i,s,r)))}addBezierCurve(t,e,i,s,r,a,n,o){this.addPoint(t,e),this.addPoint(n,o),this.bezierCurveAdd(!0,t,i,r,n),this.bezierCurveAdd(!1,e,s,a,o)}addQuadraticCurve(t,e,i,s,r,a){const n=t+.6666666666666666*(i-t),o=e+2/3*(s-e),u=n+1/3*(r-t),l=o+1/3*(a-e);this.addBezierCurve(t,e,n,u,o,l,r,a)}isPointInBox(t,e){const{x1:i,y1:s,x2:r,y2:a}=this;return i<=t&&t<=r&&s<=e&&e<=a}constructor(t=Number.NaN,e=Number.NaN,i=Number.NaN,s=Number.NaN){this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.addPoint(t,e),this.addPoint(i,s)}}class mt extends M{calculateOpacity(){let t=1,e=this;for(;e;){const i=e.getStyle("opacity",!1,!0);i.hasValue(!0)&&(t*=i.getNumber()),e=e.parent}return t}setContext(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!e){const i=this.getStyle("fill"),s=this.getStyle("fill-opacity"),r=this.getStyle("stroke"),a=this.getStyle("stroke-opacity");if(i.isUrlDefinition()){const c=i.getFillStyleDefinition(this,s);c&&(t.fillStyle=c)}else if(i.hasValue()){i.getString()==="currentColor"&&i.setValue(this.getStyle("color").getColor());const c=i.getColor();c!=="inherit"&&(t.fillStyle=c==="none"?"rgba(0,0,0,0)":c)}if(s.hasValue()){const c=new A(this.document,"fill",t.fillStyle).addOpacity(s).getColor();t.fillStyle=c}if(r.isUrlDefinition()){const c=r.getFillStyleDefinition(this,a);c&&(t.strokeStyle=c)}else if(r.hasValue()){r.getString()==="currentColor"&&r.setValue(this.getStyle("color").getColor());const c=r.getString();c!=="inherit"&&(t.strokeStyle=c==="none"?"rgba(0,0,0,0)":c)}if(a.hasValue()){const c=new A(this.document,"stroke",t.strokeStyle).addOpacity(a).getString();t.strokeStyle=c}const n=this.getStyle("stroke-width");if(n.hasValue()){const c=n.getPixels();t.lineWidth=c||Ct}const o=this.getStyle("stroke-linecap"),u=this.getStyle("stroke-linejoin"),l=this.getStyle("stroke-miterlimit"),f=this.getStyle("stroke-dasharray"),g=this.getStyle("stroke-dashoffset");if(o.hasValue()&&(t.lineCap=o.getString()),u.hasValue()&&(t.lineJoin=u.getString()),l.hasValue()&&(t.miterLimit=l.getNumber()),f.hasValue()&&f.getString()!=="none"){const c=$(f.getString());typeof t.setLineDash!="undefined"?t.setLineDash(c):typeof t.webkitLineDash!="undefined"?t.webkitLineDash=c:typeof t.mozDash!="undefined"&&!(c.length===1&&c[0]===0)&&(t.mozDash=c);const d=g.getPixels();typeof t.lineDashOffset!="undefined"?t.lineDashOffset=d:typeof t.webkitLineDashOffset!="undefined"?t.webkitLineDashOffset=d:typeof t.mozDashOffset!="undefined"&&(t.mozDashOffset=d)}}if(this.modifiedEmSizeStack=!1,typeof t.font!="undefined"){const i=this.getStyle("font"),s=this.getStyle("font-style"),r=this.getStyle("font-variant"),a=this.getStyle("font-weight"),n=this.getStyle("font-size"),o=this.getStyle("font-family"),u=new W(s.getString(),r.getString(),a.getString(),n.hasValue()?"".concat(n.getPixels(!0),"px"):"",o.getString(),W.parse(i.getString(),t.font));s.setValue(u.fontStyle),r.setValue(u.fontVariant),a.setValue(u.fontWeight),n.setValue(u.fontSize),o.setValue(u.fontFamily),t.font=u.toString(),n.isPixels()&&(this.document.emSize=n.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}constructor(...t){super(...t),this.modifiedEmSizeStack=!1}}class ut extends mt{setContext(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;super.setContext(t,e);const i=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();i&&(t.textBaseline=i)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if(this.type!=="text")return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);let e=null;return this.children.forEach((i,s)=>{const r=this.getChildBoundingBox(t,this,this,s);e?e.addBoundingBox(r):e=r}),e}getFontSize(){const{document:t,parent:e}=this,i=W.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(i)}getTElementBoundingBox(t){const e=this.getFontSize();return new J(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,i){const s=e[i];let r;if(t.isArabic){var a;const n=e.length,o=e[i-1],u=e[i+1];let l="isolated";(i===0||o===" ")&&i<n-1&&u!==" "&&(l="terminal"),i>0&&o!==" "&&i<n-1&&u!==" "&&(l="medial"),i>0&&o!==" "&&(i===n-1||u===" ")&&(l="initial"),r=((a=t.arabicGlyphs[s])===null||a===void 0?void 0:a[l])||t.glyphs[s]}else r=t.glyphs[s];return r||(r=t.missingGlyph),r}getText(){return""}getTextFromNode(t){const e=t||this.node,i=Array.from(e.parentNode.childNodes),s=i.indexOf(e),r=i.length-1;let a=Tt(e.textContent||"");return s===0&&(a=Ci(a)),s===r&&(a=Si(a)),a}renderChildren(t){if(this.type!=="text"){this.renderTElementChildren(t);return}this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach((i,s)=>{this.renderChild(t,this,this,s)});const{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}renderTElementChildren(t){const{document:e,parent:i}=this,s=this.getText(),r=i.getStyle("font-family").getDefinition();if(r){const{unitsPerEm:o}=r.fontFace,u=W.parse(e.ctx.font),l=i.getStyle("font-size").getNumber(u.fontSize),f=i.getStyle("font-style").getString(u.fontStyle),g=l/o,c=r.isRTL?s.split("").reverse().join(""):s,d=$(i.getAttribute("dx").getString()),p=c.length;for(let y=0;y<p;y++){const x=this.getGlyph(r,c,y);t.translate(this.x,this.y),t.scale(g,-g);const C=t.lineWidth;t.lineWidth=t.lineWidth*o/l,f==="italic"&&t.transform(1,0,.4,1,0,0),x.render(t),f==="italic"&&t.transform(1,0,-.4,1,0,0),t.lineWidth=C,t.scale(1/g,-1/g),t.translate(-this.x,-this.y),this.x+=l*(x.horizAdvX||r.horizAdvX)/o,typeof d[y]!="undefined"&&!isNaN(d[y])&&(this.x+=d[y])}return}const{x:a,y:n}=this;t.fillStyle&&t.fillText(s,a,n),t.strokeStyle&&t.strokeText(s,a,n)}applyAnchoring(){if(this.textChunkStart>=this.leafTexts.length)return;const t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start"),i=!1;let s=0;e==="start"&&!i||e==="end"&&i?s=t.x-this.minX:e==="end"&&!i||e==="start"&&i?s=t.x-this.maxX:s=t.x-(this.minX+this.maxX)/2;for(let r=this.textChunkStart;r<this.leafTexts.length;r++)this.leafTexts[r].x+=s;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}adjustChildCoordinatesRecursive(t){this.children.forEach((e,i)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,i)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,s){const r=i.children[s];r.children.length>0?r.children.forEach((a,n)=>{e.adjustChildCoordinatesRecursiveCore(t,e,r,n)}):this.adjustChildCoordinates(t,e,i,s)}adjustChildCoordinates(t,e,i,s){const r=i.children[s];if(typeof r.measureText!="function")return r;t.save(),r.setContext(t,!0);const a=r.getAttribute("x"),n=r.getAttribute("y"),o=r.getAttribute("dx"),u=r.getAttribute("dy"),l=r.getStyle("font-family").getDefinition(),f=Boolean(l==null?void 0:l.isRTL);s===0&&(a.hasValue()||a.setValue(r.getInheritedAttribute("x")),n.hasValue()||n.setValue(r.getInheritedAttribute("y")),o.hasValue()||o.setValue(r.getInheritedAttribute("dx")),u.hasValue()||u.setValue(r.getInheritedAttribute("dy")));const g=r.measureText(t);return f&&(e.x-=g),a.hasValue()?(e.applyAnchoring(),r.x=a.getPixels("x"),o.hasValue()&&(r.x+=o.getPixels("x"))):(o.hasValue()&&(e.x+=o.getPixels("x")),r.x=e.x),e.x=r.x,f||(e.x+=g),n.hasValue()?(r.y=n.getPixels("y"),u.hasValue()&&(r.y+=u.getPixels("y"))):(u.hasValue()&&(e.y+=u.getPixels("y")),r.y=e.y),e.y=r.y,e.leafTexts.push(r),e.minX=Math.min(e.minX,r.x,r.x+g),e.maxX=Math.max(e.maxX,r.x,r.x+g),r.clearContext(t),t.restore(),r}getChildBoundingBox(t,e,i,s){const r=i.children[s];if(typeof r.getBoundingBox!="function")return null;const a=r.getBoundingBox(t);return a&&r.children.forEach((n,o)=>{const u=e.getChildBoundingBox(t,e,r,o);a.addBoundingBox(u)}),a}renderChild(t,e,i,s){const r=i.children[s];r.render(t),r.children.forEach((a,n)=>{e.renderChild(t,e,r,n)})}measureText(t){const{measureCache:e}=this;if(~e)return e;const i=this.getText(),s=this.measureTargetText(t,i);return this.measureCache=s,s}measureTargetText(t,e){if(!e.length)return 0;const{parent:i}=this,s=i.getStyle("font-family").getDefinition();if(s){const a=this.getFontSize(),n=s.isRTL?e.split("").reverse().join(""):e,o=$(i.getAttribute("dx").getString()),u=n.length;let l=0;for(let f=0;f<u;f++)l+=(this.getGlyph(s,n,f).horizAdvX||s.horizAdvX)*a/s.fontFace.unitsPerEm,typeof o[f]!="undefined"&&!isNaN(o[f])&&(l+=o[f]);return l}if(!t.measureText)return e.length*10;t.save(),this.setContext(t,!0);const{width:r}=t.measureText(e);return this.clearContext(t),t.restore(),r}getInheritedAttribute(t){let e=this;for(;e instanceof ut&&e.isFirstChild()&&e.parent;){const i=e.parent.getAttribute(t);if(i.hasValue(!0))return i.getString("0");e=e.parent}return null}constructor(t,e,i){super(t,e,new.target===ut?!0:i),this.type="text",this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.measureCache=-1}}class Yt extends ut{getText(){return this.text}constructor(t,e,i){super(t,e,new.target===Yt?!0:i),this.type="tspan",this.text=this.children.length>0?"":this.getTextFromNode()}}class ji extends Yt{constructor(...t){super(...t),this.type="textNode"}}class T extends m{reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new O(0,0),this.control=new O(0,0),this.current=new O(0,0),this.points=[],this.angles=[]}isEnd(){const{i:t,commands:e}=this;return t>=e.length-1}next(){const t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"x",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"y";const i=new O(this.command[t],this.command[e]);return this.makeAbsolute(i)}getAsControlPoint(t,e){const i=this.getPoint(t,e);return this.control=i,i}getAsCurrentPoint(t,e){const i=this.getPoint(t,e);return this.current=i,i}getReflectedControlPoint(){const t=this.previousCommand.type;if(t!==m.CURVE_TO&&t!==m.SMOOTH_CURVE_TO&&t!==m.QUAD_TO&&t!==m.SMOOTH_QUAD_TO)return this.current;const{current:{x:e,y:i},control:{x:s,y:r}}=this;return new O(2*e-s,2*i-r)}makeAbsolute(t){if(this.command.relative){const{x:e,y:i}=this.current;t.x+=e,t.y+=i}return t}addMarker(t,e,i){const{points:s,angles:r}=this;i&&r.length>0&&!r[r.length-1]&&(r[r.length-1]=s[s.length-1].angleTo(i)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){const{angles:t}=this,e=t.length;for(let i=0;i<e;i++)if(!t[i]){for(let s=i+1;s<e;s++)if(t[s]){t[i]=t[s];break}}return t}constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),this.control=new O(0,0),this.start=new O(0,0),this.current=new O(0,0),this.command=null,this.commands=this.commands,this.i=-1,this.previousCommand=null,this.points=[],this.angles=[]}}class P extends mt{path(t){const{pathParser:e}=this,i=new J;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case T.MOVE_TO:this.pathM(t,i);break;case T.LINE_TO:this.pathL(t,i);break;case T.HORIZ_LINE_TO:this.pathH(t,i);break;case T.VERT_LINE_TO:this.pathV(t,i);break;case T.CURVE_TO:this.pathC(t,i);break;case T.SMOOTH_CURVE_TO:this.pathS(t,i);break;case T.QUAD_TO:this.pathQ(t,i);break;case T.SMOOTH_QUAD_TO:this.pathT(t,i);break;case T.ARC:this.pathA(t,i);break;case T.CLOSE_PATH:this.pathZ(t,i);break}return i}getBoundingBox(t){return this.path()}getMarkers(){const{pathParser:t}=this,e=t.getMarkerPoints(),i=t.getMarkerAngles();return e.map((r,a)=>[r,i[a]])}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);const e=this.getStyle("fill-rule");t.fillStyle!==""&&(e.getString("inherit")!=="inherit"?t.fill(e.getString()):t.fill()),t.strokeStyle!==""&&(this.getAttribute("vector-effect").getString()==="non-scaling-stroke"?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());const i=this.getMarkers();if(i){const s=i.length-1,r=this.getStyle("marker-start"),a=this.getStyle("marker-mid"),n=this.getStyle("marker-end");if(r.isUrlDefinition()){const o=r.getDefinition(),[u,l]=i[0];o.render(t,u,l)}if(a.isUrlDefinition()){const o=a.getDefinition();for(let u=1;u<s;u++){const[l,f]=i[u];o.render(t,l,f)}}if(n.isUrlDefinition()){const o=n.getDefinition(),[u,l]=i[s];o.render(t,u,l)}}}static pathM(t){const e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){const{pathParser:i}=this,{point:s}=P.pathM(i),{x:r,y:a}=s;i.addMarker(s),e.addPoint(r,a),t&&t.moveTo(r,a)}static pathL(t){const{current:e}=t,i=t.getAsCurrentPoint();return{current:e,point:i}}pathL(t,e){const{pathParser:i}=this,{current:s,point:r}=P.pathL(i),{x:a,y:n}=r;i.addMarker(r,s),e.addPoint(a,n),t&&t.lineTo(a,n)}static pathH(t){const{current:e,command:i}=t,s=new O((i.relative?e.x:0)+i.x,e.y);return t.current=s,{current:e,point:s}}pathH(t,e){const{pathParser:i}=this,{current:s,point:r}=P.pathH(i),{x:a,y:n}=r;i.addMarker(r,s),e.addPoint(a,n),t&&t.lineTo(a,n)}static pathV(t){const{current:e,command:i}=t,s=new O(e.x,(i.relative?e.y:0)+i.y);return t.current=s,{current:e,point:s}}pathV(t,e){const{pathParser:i}=this,{current:s,point:r}=P.pathV(i),{x:a,y:n}=r;i.addMarker(r,s),e.addPoint(a,n),t&&t.lineTo(a,n)}static pathC(t){const{current:e}=t,i=t.getPoint("x1","y1"),s=t.getAsControlPoint("x2","y2"),r=t.getAsCurrentPoint();return{current:e,point:i,controlPoint:s,currentPoint:r}}pathC(t,e){const{pathParser:i}=this,{current:s,point:r,controlPoint:a,currentPoint:n}=P.pathC(i);i.addMarker(n,a,r),e.addBezierCurve(s.x,s.y,r.x,r.y,a.x,a.y,n.x,n.y),t&&t.bezierCurveTo(r.x,r.y,a.x,a.y,n.x,n.y)}static pathS(t){const{current:e}=t,i=t.getReflectedControlPoint(),s=t.getAsControlPoint("x2","y2"),r=t.getAsCurrentPoint();return{current:e,point:i,controlPoint:s,currentPoint:r}}pathS(t,e){const{pathParser:i}=this,{current:s,point:r,controlPoint:a,currentPoint:n}=P.pathS(i);i.addMarker(n,a,r),e.addBezierCurve(s.x,s.y,r.x,r.y,a.x,a.y,n.x,n.y),t&&t.bezierCurveTo(r.x,r.y,a.x,a.y,n.x,n.y)}static pathQ(t){const{current:e}=t,i=t.getAsControlPoint("x1","y1"),s=t.getAsCurrentPoint();return{current:e,controlPoint:i,currentPoint:s}}pathQ(t,e){const{pathParser:i}=this,{current:s,controlPoint:r,currentPoint:a}=P.pathQ(i);i.addMarker(a,r,r),e.addQuadraticCurve(s.x,s.y,r.x,r.y,a.x,a.y),t&&t.quadraticCurveTo(r.x,r.y,a.x,a.y)}static pathT(t){const{current:e}=t,i=t.getReflectedControlPoint();t.control=i;const s=t.getAsCurrentPoint();return{current:e,controlPoint:i,currentPoint:s}}pathT(t,e){const{pathParser:i}=this,{current:s,controlPoint:r,currentPoint:a}=P.pathT(i);i.addMarker(a,r,r),e.addQuadraticCurve(s.x,s.y,r.x,r.y,a.x,a.y),t&&t.quadraticCurveTo(r.x,r.y,a.x,a.y)}static pathA(t){const{current:e,command:i}=t;let{rX:s,rY:r,xRot:a,lArcFlag:n,sweepFlag:o}=i;const u=a*(Math.PI/180),l=t.getAsCurrentPoint(),f=new O(Math.cos(u)*(e.x-l.x)/2+Math.sin(u)*(e.y-l.y)/2,-Math.sin(u)*(e.x-l.x)/2+Math.cos(u)*(e.y-l.y)/2),g=Math.pow(f.x,2)/Math.pow(s,2)+Math.pow(f.y,2)/Math.pow(r,2);g>1&&(s*=Math.sqrt(g),r*=Math.sqrt(g));let c=(n===o?-1:1)*Math.sqrt((Math.pow(s,2)*Math.pow(r,2)-Math.pow(s,2)*Math.pow(f.y,2)-Math.pow(r,2)*Math.pow(f.x,2))/(Math.pow(s,2)*Math.pow(f.y,2)+Math.pow(r,2)*Math.pow(f.x,2)));isNaN(c)&&(c=0);const d=new O(c*s*f.y/r,c*-r*f.x/s),p=new O((e.x+l.x)/2+Math.cos(u)*d.x-Math.sin(u)*d.y,(e.y+l.y)/2+Math.sin(u)*d.x+Math.cos(u)*d.y),y=Be([1,0],[(f.x-d.x)/s,(f.y-d.y)/r]),x=[(f.x-d.x)/s,(f.y-d.y)/r],C=[(-f.x-d.x)/s,(-f.y-d.y)/r];let b=Be(x,C);return ge(x,C)<=-1&&(b=Math.PI),ge(x,C)>=1&&(b=0),{currentPoint:l,rX:s,rY:r,sweepFlag:o,xAxisRotation:u,centp:p,a1:y,ad:b}}pathA(t,e){const{pathParser:i}=this,{currentPoint:s,rX:r,rY:a,sweepFlag:n,xAxisRotation:o,centp:u,a1:l,ad:f}=P.pathA(i),g=1-n?1:-1,c=l+g*(f/2),d=new O(u.x+r*Math.cos(c),u.y+a*Math.sin(c));if(i.addMarkerAngle(d,c-g*Math.PI/2),i.addMarkerAngle(s,c-g*Math.PI),e.addPoint(s.x,s.y),t&&!isNaN(l)&&!isNaN(f)){const p=r>a?r:a,y=r>a?1:r/a,x=r>a?a/r:1;t.translate(u.x,u.y),t.rotate(o),t.scale(y,x),t.arc(0,0,p,l,l+f,Boolean(1-n)),t.scale(1/y,1/x),t.rotate(-o),t.translate(-u.x,-u.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){P.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}constructor(t,e,i){super(t,e,i),this.type="path",this.pathParser=new T(this.getAttribute("d").getString())}}class Ft extends mt{setContext(t){var e;const{document:i}=this,{screen:s,window:r}=i,a=t.canvas;if(s.setDefaults(t),"style"in a&&typeof t.font!="undefined"&&r&&typeof r.getComputedStyle!="undefined"){t.font=r.getComputedStyle(a).getPropertyValue("font");const C=new A(i,"fontSize",W.parse(t.font).fontSize);C.hasValue()&&(i.rootEmSize=C.getPixels("y"),i.emSize=i.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);let{width:n,height:o}=s.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");const u=this.getAttribute("refX"),l=this.getAttribute("refY"),f=this.getAttribute("viewBox"),g=f.hasValue()?$(f.getString()):null,c=!this.root&&this.getStyle("overflow").getValue("hidden")!=="visible";let d=0,p=0,y=0,x=0;g&&(d=g[0],p=g[1]),this.root||(n=this.getStyle("width").getPixels("x"),o=this.getStyle("height").getPixels("y"),this.type==="marker"&&(y=d,x=p,d=0,p=0)),s.viewPort.setCurrent(n,o),this.node&&(!this.parent||((e=this.node.parentNode)===null||e===void 0?void 0:e.nodeName)==="foreignObject")&&this.getStyle("transform",!1,!0).hasValue()&&!this.getStyle("transform-origin",!1,!0).hasValue()&&this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),g&&(n=g[2],o=g[3]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:s.viewPort.width,desiredWidth:n,height:s.viewPort.height,desiredHeight:o,minX:d,minY:p,refX:u.getValue(),refY:l.getValue(),clip:c,clipX:y,clipY:x}),g&&(s.viewPort.removeCurrent(),s.viewPort.setCurrent(n,o))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const s=this.getAttribute("width",!0),r=this.getAttribute("height",!0),a=this.getAttribute("viewBox"),n=this.getAttribute("style"),o=s.getNumber(0),u=r.getNumber(0);if(i)if(typeof i=="string")this.getAttribute("preserveAspectRatio",!0).setValue(i);else{const l=this.getAttribute("preserveAspectRatio");l.hasValue()&&l.setValue(l.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(s.setValue(t),r.setValue(e),a.hasValue()||a.setValue("0 0 ".concat(o||t," ").concat(u||e)),n.hasValue()){const l=this.getStyle("width"),f=this.getStyle("height");l.hasValue()&&l.setValue("".concat(t,"px")),f.hasValue()&&f.setValue("".concat(e,"px"))}}constructor(...t){super(...t),this.type="svg",this.root=!1}}class ti extends P{path(t){const e=this.getAttribute("x").getPixels("x"),i=this.getAttribute("y").getPixels("y"),s=this.getStyle("width",!1,!0).getPixels("x"),r=this.getStyle("height",!1,!0).getPixels("y"),a=this.getAttribute("rx"),n=this.getAttribute("ry");let o=a.getPixels("x"),u=n.getPixels("y");if(a.hasValue()&&!n.hasValue()&&(u=o),n.hasValue()&&!a.hasValue()&&(o=u),o=Math.min(o,s/2),u=Math.min(u,r/2),t){const l=4*((Math.sqrt(2)-1)/3);t.beginPath(),r>0&&s>0&&(t.moveTo(e+o,i),t.lineTo(e+s-o,i),t.bezierCurveTo(e+s-o+l*o,i,e+s,i+u-l*u,e+s,i+u),t.lineTo(e+s,i+r-u),t.bezierCurveTo(e+s,i+r-u+l*u,e+s-o+l*o,i+r,e+s-o,i+r),t.lineTo(e+o,i+r),t.bezierCurveTo(e+o-l*o,i+r,e,i+r-u+l*u,e,i+r-u),t.lineTo(e,i+u),t.bezierCurveTo(e,i+u-l*u,e+o-l*o,i,e+o,i),t.closePath())}return new J(e,i,e+s,i+r)}getMarkers(){return null}constructor(...t){super(...t),this.type="rect"}}class Ki extends P{path(t){const e=this.getAttribute("cx").getPixels("x"),i=this.getAttribute("cy").getPixels("y"),s=this.getAttribute("r").getPixels();return t&&s>0&&(t.beginPath(),t.arc(e,i,s,0,Math.PI*2,!1),t.closePath()),new J(e-s,i-s,e+s,i+s)}getMarkers(){return null}constructor(...t){super(...t),this.type="circle"}}class Ji extends P{path(t){const e=4*((Math.sqrt(2)-1)/3),i=this.getAttribute("rx").getPixels("x"),s=this.getAttribute("ry").getPixels("y"),r=this.getAttribute("cx").getPixels("x"),a=this.getAttribute("cy").getPixels("y");return t&&i>0&&s>0&&(t.beginPath(),t.moveTo(r+i,a),t.bezierCurveTo(r+i,a+e*s,r+e*i,a+s,r,a+s),t.bezierCurveTo(r-e*i,a+s,r-i,a+e*s,r-i,a),t.bezierCurveTo(r-i,a-e*s,r-e*i,a-s,r,a-s),t.bezierCurveTo(r+e*i,a-s,r+i,a-e*s,r+i,a),t.closePath()),new J(r-i,a-s,r+i,a+s)}getMarkers(){return null}constructor(...t){super(...t),this.type="ellipse"}}class ts extends P{getPoints(){return[new O(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new O(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){const[{x:e,y:i},{x:s,y:r}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,i),t.lineTo(s,r)),new J(e,i,s,r)}getMarkers(){const[t,e]=this.getPoints(),i=t.angleTo(e);return[[t,i],[e,i]]}constructor(...t){super(...t),this.type="line"}}class ei extends P{path(t){const{points:e}=this,[{x:i,y:s}]=e,r=new J(i,s);return t&&(t.beginPath(),t.moveTo(i,s)),e.forEach(a=>{let{x:n,y:o}=a;r.addPoint(n,o),t&&t.lineTo(n,o)}),r}getMarkers(){const{points:t}=this,e=t.length-1,i=[];return t.forEach((s,r)=>{r!==e&&i.push([s,s.angleTo(t[r+1])])}),i.length>0&&i.push([t[t.length-1],i[i.length-1][1]]),i}constructor(t,e,i){super(t,e,i),this.type="polyline",this.points=[],this.points=O.parsePath(this.getAttribute("points").getString())}}class es extends ei{path(t){const e=super.path(t),[{x:i,y:s}]=this.points;return t&&(t.lineTo(i,s),t.closePath()),e}constructor(...t){super(...t),this.type="polygon"}}class is extends M{createPattern(t,e,i){const s=this.getStyle("width").getPixels("x",!0),r=this.getStyle("height").getPixels("y",!0),a=new Ft(this.document,null);a.attributes.viewBox=new A(this.document,"viewBox",this.getAttribute("viewBox").getValue()),a.attributes.width=new A(this.document,"width","".concat(s,"px")),a.attributes.height=new A(this.document,"height","".concat(r,"px")),a.attributes.transform=new A(this.document,"transform",this.getAttribute("patternTransform").getValue()),a.children=this.children;const n=this.document.createCanvas(s,r),o=n.getContext("2d"),u=this.getAttribute("x"),l=this.getAttribute("y");u.hasValue()&&l.hasValue()&&o.translate(u.getPixels("x",!0),l.getPixels("y",!0)),i.hasValue()?this.styles["fill-opacity"]=i:Reflect.deleteProperty(this.styles,"fill-opacity");for(let g=-1;g<=1;g++)for(let c=-1;c<=1;c++)o.save(),a.attributes.x=new A(this.document,"x",g*n.width),a.attributes.y=new A(this.document,"y",c*n.height),a.render(o),o.restore();return t.createPattern(n,"repeat")}constructor(...t){super(...t),this.type="pattern"}}class ss extends M{render(t,e,i){if(!e)return;const{x:s,y:r}=e,a=this.getAttribute("orient").getString("auto"),n=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(s,r),a==="auto"&&t.rotate(i),n==="strokeWidth"&&t.scale(t.lineWidth,t.lineWidth),t.save();const o=new Ft(this.document);o.type=this.type,o.attributes.viewBox=new A(this.document,"viewBox",this.getAttribute("viewBox").getValue()),o.attributes.refX=new A(this.document,"refX",this.getAttribute("refX").getValue()),o.attributes.refY=new A(this.document,"refY",this.getAttribute("refY").getValue()),o.attributes.width=new A(this.document,"width",this.getAttribute("markerWidth").getValue()),o.attributes.height=new A(this.document,"height",this.getAttribute("markerHeight").getValue()),o.attributes.overflow=new A(this.document,"overflow",this.getAttribute("overflow").getValue()),o.attributes.fill=new A(this.document,"fill",this.getAttribute("fill").getColor("black")),o.attributes.stroke=new A(this.document,"stroke",this.getAttribute("stroke").getValue("none")),o.children=this.children,o.render(t),t.restore(),n==="strokeWidth"&&t.scale(1/t.lineWidth,1/t.lineWidth),a==="auto"&&t.rotate(-i),t.translate(-s,-r)}constructor(...t){super(...t),this.type="marker"}}class rs extends M{render(){}constructor(...t){super(...t),this.type="defs"}}class de extends mt{getBoundingBox(t){const e=new J;return this.children.forEach(i=>{e.addBoundingBox(i.getBoundingBox(t))}),e}constructor(...t){super(...t),this.type="g"}}class ii extends M{getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,i){let s=this;this.getHrefAttribute().hasValue()&&(s=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(s));const{stops:r}=s,a=this.getGradient(t,e);if(!a)return this.addParentOpacity(i,r[r.length-1].color);if(r.forEach(n=>{a.addColorStop(n.offset,this.addParentOpacity(i,n.color))}),this.getAttribute("gradientTransform").hasValue()){const{document:n}=this,{MAX_VIRTUAL_PIXELS:o}=rt,{viewPort:u}=n.screen,l=u.getRoot(),f=new ti(n);f.attributes.x=new A(n,"x",-o/3),f.attributes.y=new A(n,"y",-o/3),f.attributes.width=new A(n,"width",o),f.attributes.height=new A(n,"height",o);const g=new de(n);g.attributes.transform=new A(n,"transform",this.getAttribute("gradientTransform").getValue()),g.children=[f];const c=new Ft(n);c.attributes.x=new A(n,"x",0),c.attributes.y=new A(n,"y",0),c.attributes.width=new A(n,"width",l.width),c.attributes.height=new A(n,"height",l.height),c.children=[g];const d=n.createCanvas(l.width,l.height),p=d.getContext("2d");return p.fillStyle=a,c.render(p),p.createPattern(d,"no-repeat")}return a}inheritStopContainer(t){this.attributesToInherit.forEach(e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())})}addParentOpacity(t,e){return t.hasValue()?new A(this.document,"color",e).addOpacity(t).getColor():e}constructor(t,e,i){super(t,e,i),this.attributesToInherit=["gradientUnits"],this.stops=[];const{stops:s,children:r}=this;r.forEach(a=>{a.type==="stop"&&s.push(a)})}}class ns extends ii{getGradient(t,e){const i=this.getGradientUnits()==="objectBoundingBox",s=i?e.getBoundingBox(t):null;if(i&&!s)return null;!this.getAttribute("x1").hasValue()&&!this.getAttribute("y1").hasValue()&&!this.getAttribute("x2").hasValue()&&!this.getAttribute("y2").hasValue()&&(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));const r=i?s.x+s.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),a=i?s.y+s.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),n=i?s.x+s.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),o=i?s.y+s.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return r===n&&a===o?null:t.createLinearGradient(r,a,n,o)}constructor(t,e,i){super(t,e,i),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}}class as extends ii{getGradient(t,e){const i=this.getGradientUnits()==="objectBoundingBox",s=e.getBoundingBox(t);if(i&&!s)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");const r=i?s.x+s.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),a=i?s.y+s.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let n=r,o=a;this.getAttribute("fx").hasValue()&&(n=i?s.x+s.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(o=i?s.y+s.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));const u=i?(s.width+s.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),l=this.getAttribute("fr").getPixels();return t.createRadialGradient(n,o,l,r,a,u)}constructor(t,e,i){super(t,e,i),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}}class os extends M{constructor(t,e,i){super(t,e,i),this.type="stop";const s=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),r=this.getStyle("stop-opacity");let a=this.getStyle("stop-color",!0);a.getString()===""&&a.setValue("#000"),r.hasValue()&&(a=a.addOpacity(r)),this.offset=s,this.color=a.getColor()}}class pe extends M{getProperty(){const t=this.getAttribute("attributeType").getString(),e=this.getAttribute("attributeName").getString();return t==="CSS"?this.parent.getStyle(e,!0):this.parent.getAttribute(e,!0)}calcValue(){const{initialUnits:t}=this,{progress:e,from:i,to:s}=this.getProgress();let r=i.getNumber()+(s.getNumber()-i.getNumber())*e;return t==="%"&&(r*=100),"".concat(r).concat(t)}update(t){const{parent:e}=this,i=this.getProperty();if(this.initialValue||(this.initialValue=i.getString(),this.initialUnits=i.getUnits()),this.duration>this.maxDuration){const r=this.getAttribute("fill").getString("remove");if(this.getAttribute("repeatCount").getString()==="indefinite"||this.getAttribute("repeatDur").getString()==="indefinite")this.duration=0;else if(r==="freeze"&&!this.frozen)this.frozen=!0,e&&i&&(e.animationFrozen=!0,e.animationFrozenValue=i.getString());else if(r==="remove"&&!this.removed)return this.removed=!0,e&&i&&i.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0;return!1}this.duration+=t;let s=!1;if(this.begin<this.duration){let r=this.calcValue();const a=this.getAttribute("type");if(a.hasValue()){const n=a.getString();r="".concat(n,"(").concat(r,")")}i.setValue(r),s=!0}return s}getProgress(){const{document:t,values:e}=this;let i=(this.duration-this.begin)/(this.maxDuration-this.begin),s,r;if(e.hasValue()){const a=i*(e.getValue().length-1),n=Math.floor(a),o=Math.ceil(a);let u;u=e.getValue()[n],s=new A(t,"from",u?parseFloat(u):0),u=e.getValue()[o],r=new A(t,"to",u?parseFloat(u):0),i=(a-n)/(o-n)}else s=this.from,r=this.to;return{progress:i,from:s,to:r}}constructor(t,e,i){super(t,e,i),this.type="animate",this.duration=0,this.initialUnits="",this.removed=!1,this.frozen=!1,t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new A(t,"values",null);const s=this.getAttribute("values");s.hasValue()&&this.values.setValue(s.getString().split(";"))}}class us extends pe{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),s=new ce(e.getColor()),r=new ce(i.getColor());if(s.ok&&r.ok){const a=s.r+(r.r-s.r)*t,n=s.g+(r.g-s.g)*t,o=s.b+(r.b-s.b)*t;return"rgb(".concat(Math.floor(a),", ").concat(Math.floor(n),", ").concat(Math.floor(o),")")}return this.getAttribute("from").getColor()}constructor(...t){super(...t),this.type="animateColor"}}class hs extends pe{calcValue(){const{progress:t,from:e,to:i}=this.getProgress(),s=$(e.getString()),r=$(i.getString());return s.map((n,o)=>{const u=r[o];return n+(u-n)*t}).join(" ")}constructor(...t){super(...t),this.type="animateTransform"}}class si extends M{constructor(t,e,i){super(t,e,i),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class me extends P{constructor(t,e,i){super(t,e,i),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class ri extends me{constructor(...t){super(...t),this.type="missing-glyph",this.horizAdvX=0}}class ls extends M{render(){}constructor(t,e,i){super(t,e,i),this.type="font",this.isArabic=!1,this.glyphs={},this.arabicGlyphs={},this.isRTL=!1,this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();const{definitions:s}=t,{children:r}=this;for(const a of r)if(a instanceof si){this.fontFace=a;const n=a.getStyle("font-family");n.hasValue()&&(s[n.getString()]=this)}else if(a instanceof ri)this.missingGlyph=a;else if(a instanceof me)if(a.arabicForm){this.isRTL=!0,this.isArabic=!0;const n=this.arabicGlyphs[a.unicode];typeof n=="undefined"?this.arabicGlyphs[a.unicode]={[a.arabicForm]:a}:n[a.arabicForm]=a}else this.glyphs[a.unicode]=a}}class cs extends ut{getText(){const t=this.getHrefAttribute().getDefinition();if(t){const e=t.children[0];if(e)return e.getText()}return""}constructor(...t){super(...t),this.type="tref"}}class fs extends ut{getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);const{document:e,x:i,y:s}=this,{mouse:r}=e.screen,a=new A(e,"fontSize",W.parse(e.ctx.font).fontSize);r.isWorking()&&r.checkBoundingBox(this,new J(i,s-a.getPixels("y"),i+this.measureText(t),s))}else if(this.children.length>0){const e=new de(this.document);e.children=this.children,e.parent=this,e.render(t)}}onClick(){const{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){const t=this.document.ctx;t.canvas.style.cursor="pointer"}constructor(t,e,i){super(t,e,i),this.type="a";const{childNodes:s}=e,r=s[0],a=s.length>0&&Array.from(s).every(n=>n.nodeType===3);this.hasText=a,this.text=a?this.getTextFromNode(r):""}}class gs extends ut{getText(){return this.text}path(t){const{dataArray:e}=this;t&&t.beginPath(),e.forEach(i=>{let{type:s,points:r}=i;switch(s){case T.LINE_TO:t&&t.lineTo(r[0],r[1]);break;case T.MOVE_TO:t&&t.moveTo(r[0],r[1]);break;case T.CURVE_TO:t&&t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case T.QUAD_TO:t&&t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case T.ARC:{const[a,n,o,u,l,f,g,c]=r,d=o>u?o:u,p=o>u?1:o/u,y=o>u?u/o:1;t&&(t.translate(a,n),t.rotate(g),t.scale(p,y),t.arc(0,0,d,l,l+f,Boolean(1-c)),t.scale(1/p,1/y),t.rotate(-g),t.translate(-a,-n));break}case T.CLOSE_PATH:t&&t.closePath();break}})}renderChildren(t){this.setTextData(t),t.save();const e=this.parent.getStyle("text-decoration").getString(),i=this.getFontSize(),{glyphInfo:s}=this,r=t.fillStyle;e==="underline"&&t.beginPath(),s.forEach((a,n)=>{const{p0:o,p1:u,rotation:l,text:f}=a;t.save(),t.translate(o.x,o.y),t.rotate(l),t.fillStyle&&t.fillText(f,0,0),t.strokeStyle&&t.strokeText(f,0,0),t.restore(),e==="underline"&&(n===0&&t.moveTo(o.x,o.y+i/8),t.lineTo(u.x,u.y+i/5))}),e==="underline"&&(t.lineWidth=i/20,t.strokeStyle=r,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,i,s,r,a,n,o,u){let l=a,f=this.measureText(t,o);o===" "&&e==="justify"&&i<s&&(f+=(s-i)/r),u>-1&&(l+=this.getLetterSpacingAt(u));const g=this.textHeight/20,c=this.getEquidistantPointOnPath(l,g,0),d=this.getEquidistantPointOnPath(l+f,g,0),p={p0:c,p1:d},y=c&&d?Math.atan2(d.y-c.y,d.x-c.x):0;if(n){const x=Math.cos(Math.PI/2+y)*n,C=Math.cos(-y)*n;p.p0={...c,x:c.x+x,y:c.y+C},p.p1={...d,x:d.x+x,y:d.y+C}}return l+=f,{offset:l,segment:p,rotation:y}}measureText(t,e){const{measuresCache:i}=this,s=e||this.getText();if(i.has(s))return i.get(s);const r=this.measureTargetText(t,s);return i.set(s,r),r}setTextData(t){if(this.glyphInfo)return;const e=this.getText(),i=e.split(""),s=e.split(" ").length-1,r=this.parent.getAttribute("dx").split().map(b=>b.getPixels("x")),a=this.parent.getAttribute("dy").getPixels("y"),n=this.parent.getStyle("text-anchor").getString("start"),o=this.getStyle("letter-spacing"),u=this.parent.getStyle("letter-spacing");let l=0;!o.hasValue()||o.getValue()==="inherit"?l=u.getPixels():o.hasValue()&&o.getValue()!=="initial"&&o.getValue()!=="unset"&&(l=o.getPixels());const f=[],g=e.length;this.letterSpacingCache=f;for(let b=0;b<g;b++)f.push(typeof r[b]!="undefined"?r[b]:l);const c=f.reduce((b,v,E)=>E===0?0:b+v||0,0),d=this.measureText(t),p=Math.max(d+c,0);this.textWidth=d,this.textHeight=this.getFontSize(),this.glyphInfo=[];const y=this.getPathLength(),x=this.getStyle("startOffset").getNumber(0)*y;let C=0;(n==="middle"||n==="center")&&(C=-p/2),(n==="end"||n==="right")&&(C=-p),C+=x,i.forEach((b,v)=>{const{offset:E,segment:w,rotation:S}=this.findSegmentToFitChar(t,n,p,y,s,C,a,b,v);C=E,!(!w.p0||!w.p1)&&this.glyphInfo.push({text:i[v],p0:w.p0,p1:w.p1,rotation:S})})}parsePathData(t){if(this.pathLength=-1,!t)return[];const e=[],{pathParser:i}=t;for(i.reset();!i.isEnd();){const{current:s}=i,r=s?s.x:0,a=s?s.y:0,n=i.next();let o=n.type,u=[];switch(n.type){case T.MOVE_TO:this.pathM(i,u);break;case T.LINE_TO:o=this.pathL(i,u);break;case T.HORIZ_LINE_TO:o=this.pathH(i,u);break;case T.VERT_LINE_TO:o=this.pathV(i,u);break;case T.CURVE_TO:this.pathC(i,u);break;case T.SMOOTH_CURVE_TO:o=this.pathS(i,u);break;case T.QUAD_TO:this.pathQ(i,u);break;case T.SMOOTH_QUAD_TO:o=this.pathT(i,u);break;case T.ARC:u=this.pathA(i);break;case T.CLOSE_PATH:P.pathZ(i);break}n.type!==T.CLOSE_PATH?e.push({type:o,points:u,start:{x:r,y:a},pathLength:this.calcLength(r,a,o,u)}):e.push({type:T.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:s}=P.pathM(t).point;e.push(i,s)}pathL(t,e){const{x:i,y:s}=P.pathL(t).point;return e.push(i,s),T.LINE_TO}pathH(t,e){const{x:i,y:s}=P.pathH(t).point;return e.push(i,s),T.LINE_TO}pathV(t,e){const{x:i,y:s}=P.pathV(t).point;return e.push(i,s),T.LINE_TO}pathC(t,e){const{point:i,controlPoint:s,currentPoint:r}=P.pathC(t);e.push(i.x,i.y,s.x,s.y,r.x,r.y)}pathS(t,e){const{point:i,controlPoint:s,currentPoint:r}=P.pathS(t);return e.push(i.x,i.y,s.x,s.y,r.x,r.y),T.CURVE_TO}pathQ(t,e){const{controlPoint:i,currentPoint:s}=P.pathQ(t);e.push(i.x,i.y,s.x,s.y)}pathT(t,e){const{controlPoint:i,currentPoint:s}=P.pathT(t);return e.push(i.x,i.y,s.x,s.y),T.QUAD_TO}pathA(t){let{rX:e,rY:i,sweepFlag:s,xAxisRotation:r,centp:a,a1:n,ad:o}=P.pathA(t);return s===0&&o>0&&(o-=2*Math.PI),s===1&&o<0&&(o+=2*Math.PI),[a.x,a.y,e,i,n,o,r,s]}calcLength(t,e,i,s){let r=0,a=null,n=null,o=0;switch(i){case T.LINE_TO:return this.getLineLength(t,e,s[0],s[1]);case T.CURVE_TO:for(r=0,a=this.getPointOnCubicBezier(0,t,e,s[0],s[1],s[2],s[3],s[4],s[5]),o=.01;o<=1;o+=.01)n=this.getPointOnCubicBezier(o,t,e,s[0],s[1],s[2],s[3],s[4],s[5]),r+=this.getLineLength(a.x,a.y,n.x,n.y),a=n;return r;case T.QUAD_TO:for(r=0,a=this.getPointOnQuadraticBezier(0,t,e,s[0],s[1],s[2],s[3]),o=.01;o<=1;o+=.01)n=this.getPointOnQuadraticBezier(o,t,e,s[0],s[1],s[2],s[3]),r+=this.getLineLength(a.x,a.y,n.x,n.y),a=n;return r;case T.ARC:{r=0;const u=s[4],l=s[5],f=s[4]+l;let g=Math.PI/180;if(Math.abs(u-f)<g&&(g=Math.abs(u-f)),a=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],u,0),l<0)for(o=u-g;o>f;o-=g)n=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],o,0),r+=this.getLineLength(a.x,a.y,n.x,n.y),a=n;else for(o=u+g;o<f;o+=g)n=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],o,0),r+=this.getLineLength(a.x,a.y,n.x,n.y),a=n;return n=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],f,0),r+=this.getLineLength(a.x,a.y,n.x,n.y),r}}return 0}getPointOnLine(t,e,i,s,r){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:e,n=arguments.length>6&&arguments[6]!==void 0?arguments[6]:i;const o=(r-i)/(s-e+Ct);let u=Math.sqrt(t*t/(1+o*o));s<e&&(u*=-1);let l=o*u,f=null;if(s===e)f={x:a,y:n+l};else if((n-i)/(a-e+Ct)===o)f={x:a+u,y:n+l};else{let g=0,c=0;const d=this.getLineLength(e,i,s,r);if(d<Ct)return null;let p=(a-e)*(s-e)+(n-i)*(r-i);p/=d*d,g=e+p*(s-e),c=i+p*(r-i);const y=this.getLineLength(a,n,g,c),x=Math.sqrt(t*t-y*y);u=Math.sqrt(x*x/(1+o*o)),s<e&&(u*=-1),l=o*u,f={x:g+u,y:c+l}}return f}getPointOnPath(t){const e=this.getPathLength();let i=0,s=null;if(t<-5e-5||t-5e-5>e)return null;const{dataArray:r}=this;for(const a of r){if(a&&(a.pathLength<5e-5||i+a.pathLength+5e-5<t)){i+=a.pathLength;continue}const n=t-i;let o=0;switch(a.type){case T.LINE_TO:s=this.getPointOnLine(n,a.start.x,a.start.y,a.points[0],a.points[1],a.start.x,a.start.y);break;case T.ARC:{const u=a.points[4],l=a.points[5],f=a.points[4]+l;if(o=u+n/a.pathLength*l,l<0&&o<f||l>=0&&o>f)break;s=this.getPointOnEllipticalArc(a.points[0],a.points[1],a.points[2],a.points[3],o,a.points[6]);break}case T.CURVE_TO:o=n/a.pathLength,o>1&&(o=1),s=this.getPointOnCubicBezier(o,a.start.x,a.start.y,a.points[0],a.points[1],a.points[2],a.points[3],a.points[4],a.points[5]);break;case T.QUAD_TO:o=n/a.pathLength,o>1&&(o=1),s=this.getPointOnQuadraticBezier(o,a.start.x,a.start.y,a.points[0],a.points[1],a.points[2],a.points[3]);break}if(s)return s;break}return null}getLineLength(t,e,i,s){return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}getPathLength(){return this.pathLength===-1&&(this.pathLength=this.dataArray.reduce((t,e)=>e.pathLength>0?t+e.pathLength:t,0)),this.pathLength}getPointOnCubicBezier(t,e,i,s,r,a,n,o,u){const l=o*De(t)+a*Le(t)+s*Ie(t)+e*_e(t),f=u*De(t)+n*Le(t)+r*Ie(t)+i*_e(t);return{x:l,y:f}}getPointOnQuadraticBezier(t,e,i,s,r,a,n){const o=a*ze(t)+s*He(t)+e*Ue(t),u=n*ze(t)+r*He(t)+i*Ue(t);return{x:o,y:u}}getPointOnEllipticalArc(t,e,i,s,r,a){const n=Math.cos(a),o=Math.sin(a),u={x:i*Math.cos(r),y:s*Math.sin(r)};return{x:t+(u.x*n-u.y*o),y:e+(u.x*o+u.y*n)}}buildEquidistantCache(t,e){const i=this.getPathLength(),s=e||.25,r=t||i/100;if(!this.equidistantCache||this.equidistantCache.step!==r||this.equidistantCache.precision!==s){this.equidistantCache={step:r,precision:s,points:[]};let a=0;for(let n=0;n<=i;n+=s){const o=this.getPointOnPath(n),u=this.getPointOnPath(n+s);!o||!u||(a+=this.getLineLength(o.x,o.y,u.x,u.y),a>=r&&(this.equidistantCache.points.push({x:o.x,y:o.y,distance:n}),a-=r))}}}getEquidistantPointOnPath(t,e,i){if(this.buildEquidistantCache(e,i),t<0||t-this.getPathLength()>5e-5)return null;const s=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[s]||null}constructor(t,e,i){super(t,e,i),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);const s=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(s)}}const ds=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class ps extends mt{async loadImage(t){try{const e=await this.document.createImage(t);this.image=e}catch(e){console.error('Error while loading image "'.concat(t,'":'),e)}this.loaded=!0}async loadSvg(t){const e=ds.exec(t);if(e){const i=e[5];i&&(e[4]==="base64"?this.image=atob(i):this.image=decodeURIComponent(i))}else try{const s=await(await this.document.fetch(t)).text();this.image=s}catch(i){console.error('Error while loading image "'.concat(t,'":'),i)}this.loaded=!0}renderChildren(t){const{document:e,image:i,loaded:s}=this,r=this.getAttribute("x").getPixels("x"),a=this.getAttribute("y").getPixels("y"),n=this.getStyle("width").getPixels("x"),o=this.getStyle("height").getPixels("y");if(!(!s||!i||!n||!o)){if(t.save(),t.translate(r,a),typeof i=="string"){const u=e.canvg.forkString(t,i,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:n,scaleHeight:o}),{documentElement:l}=u.document;l&&(l.parent=this),u.render()}else e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:n,desiredWidth:i.width,height:o,desiredHeight:i.height}),this.loaded&&(!("complete"in i)||i.complete)&&t.drawImage(i,0,0);t.restore()}}getBoundingBox(){const t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),i=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");return new J(t,e,t+i,e+s)}constructor(t,e,i){super(t,e,i),this.type="image",this.loaded=!1;const s=this.getHrefAttribute().getString();if(!s)return;const r=s.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(s);t.images.push(this),r?this.loadSvg(s):this.loadImage(s)}}class ms extends mt{render(t){}constructor(...t){super(...t),this.type="symbol"}}class ys{async load(t,e){try{const{document:i}=this,r=(await i.canvg.parser.load(e)).getElementsByTagName("font");Array.from(r).forEach(a=>{const n=i.createElement(a);i.definitions[t]=n})}catch(i){console.error('Error while loading font "'.concat(e,'":'),i)}this.loaded=!0}constructor(t){this.document=t,this.loaded=!1,t.fonts.push(this)}}class ni extends M{constructor(t,e,i){super(t,e,i),this.type="style",Tt(Array.from(e.childNodes).map(a=>a.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(a=>{const n=a.trim();if(!n)return;const o=n.split("{"),u=o[0].split(","),l=o[1].split(";");u.forEach(f=>{const g=f.trim();if(!g)return;const c=t.styles[g]||{};if(l.forEach(d=>{const p=d.indexOf(":"),y=d.substr(0,p).trim(),x=d.substr(p+1,d.length-p).trim();y&&x&&(c[y]=new A(t,y,x))}),t.styles[g]=c,t.stylesSpecificity[g]=Bi(g),g==="@font-face"){const d=c["font-family"].getString().replace(/"|'/g,"");c.src.getString().split(",").forEach(y=>{if(y.indexOf('format("svg")')>0){const x=$e(y);x&&new ys(t).load(d,x)}})}})})}}ni.parseExternalUrl=$e;class xs extends mt{setContext(t){super.setContext(t);const e=this.getAttribute("x"),i=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),i.hasValue()&&t.translate(0,i.getPixels("y"))}path(t){const{element:e}=this;e&&e.path(t)}renderChildren(t){const{document:e,element:i}=this;if(i){let s=i;if(i.type==="symbol"&&(s=new Ft(e),s.attributes.viewBox=new A(e,"viewBox",i.getAttribute("viewBox").getString()),s.attributes.preserveAspectRatio=new A(e,"preserveAspectRatio",i.getAttribute("preserveAspectRatio").getString()),s.attributes.overflow=new A(e,"overflow",i.getAttribute("overflow").getString()),s.children=i.children,i.styles.opacity=new A(e,"opacity",this.calculateOpacity())),s.type==="svg"){const a=this.getStyle("width",!1,!0),n=this.getStyle("height",!1,!0);a.hasValue()&&(s.attributes.width=new A(e,"width",a.getString())),n.hasValue()&&(s.attributes.height=new A(e,"height",n.getString()))}const r=s.parent;s.parent=this,s.render(t),s.parent=r}}getBoundingBox(t){const{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){const{document:t,element:e}=this;return e?pt.fromElement(t,e):null}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}constructor(...t){super(...t),this.type="use"}}function zt(h,t,e,i,s,r){return h[e*i*4+t*4+r]}function Ht(h,t,e,i,s,r,a){h[e*i*4+t*4+r]=a}function B(h,t,e){return h[t]*e}function it(h,t,e,i){return t+Math.cos(h)*e+Math.sin(h)*i}class ai extends M{apply(t,e,i,s,r){const{includeOpacity:a,matrix:n}=this,o=t.getImageData(0,0,s,r);for(let u=0;u<r;u++)for(let l=0;l<s;l++){const f=zt(o.data,l,u,s,r,0),g=zt(o.data,l,u,s,r,1),c=zt(o.data,l,u,s,r,2),d=zt(o.data,l,u,s,r,3);let p=B(n,0,f)+B(n,1,g)+B(n,2,c)+B(n,3,d)+B(n,4,1),y=B(n,5,f)+B(n,6,g)+B(n,7,c)+B(n,8,d)+B(n,9,1),x=B(n,10,f)+B(n,11,g)+B(n,12,c)+B(n,13,d)+B(n,14,1),C=B(n,15,f)+B(n,16,g)+B(n,17,c)+B(n,18,d)+B(n,19,1);a&&(p=0,y=0,x=0,C*=d/255),Ht(o.data,l,u,s,r,0,p),Ht(o.data,l,u,s,r,1,y),Ht(o.data,l,u,s,r,2,x),Ht(o.data,l,u,s,r,3,C)}t.clearRect(0,0,s,r),t.putImageData(o,0,0)}constructor(t,e,i){super(t,e,i),this.type="feColorMatrix";let s=$(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":{const r=s[0];s=[.213+.787*r,.715-.715*r,.072-.072*r,0,0,.213-.213*r,.715+.285*r,.072-.072*r,0,0,.213-.213*r,.715-.715*r,.072+.928*r,0,0,0,0,0,1,0,0,0,0,0,1];break}case"hueRotate":{const r=s[0]*Math.PI/180;s=[it(r,.213,.787,-.213),it(r,.715,-.715,-.715),it(r,.072,-.072,.928),0,0,it(r,.213,-.213,.143),it(r,.715,.285,.14),it(r,.072,-.072,-.283),0,0,it(r,.213,-.213,-.787),it(r,.715,-.715,.715),it(r,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break}case"luminanceToAlpha":s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1];break}this.matrix=s,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}}class Wt extends M{apply(t,e){const{document:i}=this;let s=this.getAttribute("x").getPixels("x"),r=this.getAttribute("y").getPixels("y"),a=this.getStyle("width").getPixels("x"),n=this.getStyle("height").getPixels("y");if(!a&&!n){const c=new J;this.children.forEach(d=>{c.addBoundingBox(d.getBoundingBox(t))}),s=Math.floor(c.x1),r=Math.floor(c.y1),a=Math.floor(c.width),n=Math.floor(c.height)}const o=this.removeStyles(e,Wt.ignoreStyles),u=i.createCanvas(s+a,r+n),l=u.getContext("2d");i.screen.setDefaults(l),this.renderChildren(l),new ai(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(l,0,0,s+a,r+n);const f=i.createCanvas(s+a,r+n),g=f.getContext("2d");i.screen.setDefaults(g),e.render(g),g.globalCompositeOperation="destination-in",g.fillStyle=l.createPattern(u,"no-repeat"),g.fillRect(0,0,s+a,r+n),t.fillStyle=g.createPattern(f,"no-repeat"),t.fillRect(0,0,s+a,r+n),this.restoreStyles(e,o)}render(t){}constructor(...t){super(...t),this.type="mask"}}Wt.ignoreStyles=["mask","transform","clip-path"];const Ye=()=>{};class bs extends M{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:s,closePath:r}=t;i&&(i.beginPath=Ye,i.closePath=Ye),Reflect.apply(s,t,[]),this.children.forEach(a=>{if(!("path"in a))return;let n="elementTransform"in a?a.elementTransform():null;n||(n=pt.fromElement(e,a)),n&&n.apply(t),a.path(t),i&&(i.closePath=r),n&&n.unapply(t)}),Reflect.apply(r,t,[]),t.clip(),i&&(i.beginPath=s,i.closePath=r)}render(t){}constructor(...t){super(...t),this.type="clipPath"}}class Gt extends M{apply(t,e){const{document:i,children:s}=this,r="getBoundingBox"in e?e.getBoundingBox(t):null;if(!r)return;let a=0,n=0;s.forEach(x=>{const C=x.extraFilterDistance||0;a=Math.max(a,C),n=Math.max(n,C)});const o=Math.floor(r.width),u=Math.floor(r.height),l=o+2*a,f=u+2*n;if(l<1||f<1)return;const g=Math.floor(r.x),c=Math.floor(r.y),d=this.removeStyles(e,Gt.ignoreStyles),p=i.createCanvas(l,f),y=p.getContext("2d");i.screen.setDefaults(y),y.translate(-g+a,-c+n),e.render(y),s.forEach(x=>{typeof x.apply=="function"&&x.apply(y,0,0,l,f)}),t.drawImage(p,0,0,l,f,g-a,c-n,l,f),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),this.type="filter"}}Gt.ignoreStyles=["filter","transform","clip-path"];class vs extends M{apply(t,e,i,s,r){}constructor(t,e,i){super(t,e,i),this.type="feDropShadow",this.addStylesFromStyleDefinition()}}class As extends M{apply(t,e,i,s,r){}constructor(...t){super(...t),this.type="feMorphology"}}class Cs extends M{apply(t,e,i,s,r){}constructor(...t){super(...t),this.type="feComposite"}}class Ss extends M{apply(t,e,i,s,r){const{document:a,blurRadius:n}=this,o=a.window?a.window.document.body:null,u=t.canvas;u.id=a.getUniqueId(),o&&(u.style.display="none",o.appendChild(u)),yi(u,e,i,s,r,n),o&&o.removeChild(u)}constructor(t,e,i){super(t,e,i),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}}class Ts extends M{constructor(...t){super(...t),this.type="title"}}class ws extends M{constructor(...t){super(...t),this.type="desc"}}const Es={svg:Ft,rect:ti,circle:Ki,ellipse:Ji,line:ts,polyline:ei,polygon:es,path:P,pattern:is,marker:ss,defs:rs,linearGradient:ns,radialGradient:as,stop:os,animate:pe,animateColor:us,animateTransform:hs,font:ls,"font-face":si,"missing-glyph":ri,glyph:me,text:ut,tspan:Yt,tref:cs,a:fs,textPath:gs,image:ps,g:de,symbol:ms,style:ni,use:xs,mask:Wt,clipPath:bs,filter:Gt,feDropShadow:vs,feMorphology:As,feComposite:Cs,feColorMatrix:ai,feGaussianBlur:Ss,title:Ts,desc:ws};function Ps(h,t){const e=document.createElement("canvas");return e.width=h,e.height=t,e}async function Ms(h){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const e=document.createElement("img");return t&&(e.crossOrigin="Anonymous"),new Promise((i,s)=>{e.onload=()=>{i(e)},e.onerror=(r,a,n,o,u)=>{s(u)},e.src=h})}const le=12;class ot{bindCreateImage(t,e){return typeof e=="boolean"?(i,s)=>t(i,typeof s=="boolean"?s:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){const{emSizeStack:t}=this;return t[t.length-1]||le}set emSize(t){const{emSizeStack:e}=this;e.push(t)}popEmSize(){const{emSizeStack:t}=this;t.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(t=>t.loaded)}isFontsLoaded(){return this.fonts.every(t=>t.loaded)}createDocumentElement(t){const e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){const e=t.nodeName.replace(/^[^:]+:/,""),i=ot.elementTypes[e];return i?new i(this,t):new Gi(this,t)}createTextNode(t){return new ji(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=le,emSize:i=le,createCanvas:s=ot.createCanvas,createImage:r=ot.createImage,anonymousCrossOrigin:a}={}){this.canvg=t,this.definitions={},this.styles={},this.stylesSpecificity={},this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=i,this.createCanvas=s,this.createImage=this.bindCreateImage(r,a),this.screen.wait(()=>this.isImagesLoaded()),this.screen.wait(()=>this.isFontsLoaded())}}ot.createCanvas=Ps;ot.createImage=Ms;ot.elementTypes=Es;class vt{static async from(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=await new he(i).parse(e);return new vt(t,r,i)}static fromString(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=new he(i).parseFromString(e);return new vt(t,r,i)}fork(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return vt.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return vt.fromString(t,e,{...this.options,...i})}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}async render(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.start({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0,...t}),await this.ready(),this.stop()}start(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{documentElement:e,screen:i,options:s}=this;i.start(e,{enableRedraw:!0,...s,...t})}stop(){this.screen.stop()}resize(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.documentElement.resize(t,e,i)}constructor(t,e,i={}){this.parser=new he(i),this.screen=new rt(t,i),this.options=i;const s=new ot(this,i),r=s.createDocumentElement(e);this.document=s,this.documentElement=r}}window.OffscreenCanvas||(window.OffscreenCanvas=class{constructor(t,e){return this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.canvas.convertToBlob=()=>new Promise(i=>{this.canvas.toBlob(i)}),this.canvas}});const Fs=Ai.offscreen(),Ns=h=>new Promise((t,e)=>{const i=new FileReader;i.onloadend=()=>t(i.result),i.readAsDataURL(h)});let bt=null;const Rs=async(h,t,e)=>{bt||(bt=new OffscreenCanvas(t,e));const i=bt.getContext("2d");let s=await vt.fromString(i,h,Fs);s.resize(t*2,e*2,"xMidYMid meet"),await s.start();const r=await bt.convertToBlob(),a=await Ns(r);return i.clearRect(0,0,bt.width,bt.height),await s.stop(),s=null,a};export{Vs as g,Rs as s};