import{b6 as Ye}from"./ResizeObserver.es.39b48a47.js";const re={"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",Glockenspiel:"\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\u7BA1","Alto Sax":"\u4E2D\u97F3\u8428\u514B\u65AF\u7BA1","Tenor Sax":"\u6B21\u4E2D\u97F3\u8428\u514B\u65AF\u7BA1","Baritone Sax":"\u4F4E\u97F3\u8428\u514B\u65AF\u7BA1",Oboe:"\u53CC\u7C27\u7BA1","English Horn":"\u82F1\u56FD\u7BA1",Bassoon:"\u5DF4\u677E","Soprano Saxophone":"\u9AD8\u97F3\u8428\u514B\u65AF\u7BA1","Alto Saxophone":"\u4E2D\u97F3\u8428\u514B\u65AF\u7BA1","Tenor Saxophone":"\u6B21\u4E2D\u97F3\u8428\u514B\u65AF\u7BA1","Baritone Saxophone":"\u4E0A\u4F4E\u97F3\u8428\u514B\u65AF\u7BA1",Piccolo:"\u77ED\u7B1B",Flute:"\u957F\u7B1B",Recorder:"\u7AD6\u7B1B","Soprano Recorder":"\u9AD8\u97F3\u7AD6\u7B1B","Pan Flute":"\u6392\u7BAB","Bottle Blow":"\u74F6\u6728\u7BA1",Whistle:"\u53E3\u54E8\u58F0",Ocarina:"\u9676\u7B1B",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",Agogos:"\u963F\u6208\u6208\u94C3","Steel Drums":"\u94A2\u9F13","Taiko Drum":"\u592A\u9F13","Melodic Toms":"\u55F5\u55F5\u9F13","Synth Drums":"\u5408\u6210\u9F13","Reverse Cymbals":"\u53CD\u5411\u9572","Agogo Bells":"\u963F\u6208\u6208\u94C3","Taiko Drums":"\u592A\u9F13",Bongos:"\u90A6\u6208\u9F13","Bongo Bell":"\u90A6\u6208\u94C3",Congas:"\u5EB7\u52A0\u9F13",Guiro:"\u522E\u58F6","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 Drum":"\u5C0F\u9F13\u9F13\u8FB9","Acoustic Snare":"\u5C0F\u9F13","Hand Claps":"\u62CD\u624B","Electric Snare":"\u5C0F\u9F13","Low Floor Tom":"\u4F4E\u97F3\u55F5\u9F13","Closed Hi-Hat":"\u95ED\u5408\u8E29\u9572","High Floor Tom":"\u9AD8\u97F3\u843D\u5730\u55F5\u9F13","Pedal Hi-Hat":"\u811A\u8E0F\u8E29\u9572","Low Tom":"\u4F4E\u97F3\u55F5\u9F13","Open Hi-Hat":"\u5F00\u97F3\u8E29\u9572","Low-Mid Tom":"\u4E2D\u4F4E\u97F3\u55F5\u9F13","Hi Mid Tom":"\u9AD8\u97F3\u9F13","Crash Cymbals":"\u5BF9\u9572","High Tom":"\u9AD8\u97F3\u55F5\u9F13","Ride Cymbals":"\u53EE\u53EE\u9572","Chinese Cymbals":"\u4E2D\u56FD\u9572","Ride Bell":"\u5706\u94C3",Tambourine:"\u94C3\u9F13","Splash Cymbal":"\u6E85\u97F3\u9572",Cowbell:"\u725B\u94C3","Crash Cymbal":"\u5F3A\u97F3\u94B9","Vibra-Slap":"\u98A4\u97F3\u5668","Ride Cymbal":"\u6253\u70B9\u94B9","Hi Bongo":"\u9AD8\u97F3\u90A6\u6208\u9F13","Low Bongo":"\u4F4E\u97F3\u90A6\u6208\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\u6208\u6208\u94C3","Low Agogo":"\u4F4E\u97F3\u963F\u6208\u6208\u94C3",Cabasa:"\u5361\u5DF4\u8428",Maracas:"\u6C99\u9524","Short Whistle":"\u77ED\u53E3\u54E8","Long Whistle":"\u957F\u53E3\u54E8","Short Guiro":"\u77ED\u522E\u58F6","Long Guiro":"\u957F\u522E\u58F6",Claves:"\u54CD\u68D2","Hi Wood Block":"\u9AD8\u97F3\u6728\u9C7C","Low Wood Block":"\u4F4E\u97F3\u6728\u9C7C","Mute Triangle":"\u5F31\u97F3\u4E09\u89D2\u94C1","Open Triangle":"\u5F3A\u97F3\u4E09\u89D2\u94C1","Drum Set":"\u67B6\u5B50\u9F13","Hulusi flute":"\u846B\u82A6\u4E1D",Melodica:"\u53E3\u98CE\u7434","Snare Drum":"\u5C0F\u519B\u9F13","Horn in F":"\u5706\u53F7",Triangle:"\u4E09\u89D2\u94C1",Vibrato:"\u98A4\u97F3\u7434","Suspend Cymbals":"\u540A\u9572","Suspended Cymbals":"\u540A\u9572","Tom-Toms":"\u55F5\u55F5\u9F13",Bell:"\u94C3\u94DB",Bells:"\u94C3\u94DB","Alto Clarinet":"\u4E2D\u97F3\u5355\u7C27\u7BA1","Bass Clarinet":"\u4F4E\u97F3\u5355\u7C27\u7BA1",Clarinet:"\u5355\u7C27\u7BA1",Cornet:"\u77ED\u53F7",Euphonium:"\u4E0A\u4F4E\u97F3\u53F7","crash cymbals":"\u5BF9\u9572",Castanets:"\u54CD\u677F",Shaker:"\u6C99\u9524","Mark tree":"\u97F3\u6811",Chimes:"\u7BA1\u949F","Mark Tree":"\u97F3\u6811","Tom-toms":"\u55F5\u55F5\u9F13","Hi-Hat":"\u8E29\u9572","Sleigh Bells":"\u96EA\u6A47\u94C3",Flexatone:"\u5F39\u97F3\u5668","Brake drum":"\u95F8\u9F13",Gong:"\u9523","concert tom":"\u97F3\u4E50\u4F1A\u55F5\u55F5\u9F13","brake drum":"\u8F66\u8F6E\u9F13","finger cymbal":"\u6307\u94B9","ride cymbal":"\u53EE\u53EE\u9572","Concert Toms":"\u97F3\u4E50\u4F1A\u55F5\u55F5\u9F13",Vibraslap:"\u5F39\u97F3\u5668","Wood Blocks":"\u6728\u9C7C","Temple Blocks":"\u6728\u9C7C","Wood Block":"\u6728\u9C7C","Field Drum":"\u519B\u9F13","Quad-Toms":"\u7B52\u9F13",Quads:"\u7B52\u9F13","Drums set":"\u67B6\u5B50\u9F13","High Bongo":"\u90A6\u6208",Timbales:"\u5929\u5DF4\u9F13","rain stick":"\u96E8\u68D2","String Bass":"\u5F26\u4E50\u4F4E\u97F3","Floor Tom":"\u4FA7\u55F5\u9F13","Brake Drum":"\u95F8\u9F13","Tam-tam":"\u5927\u9523",Cymbal:"\u9572",Cymbals:"\u9572",Whip:"\u4E50\u97AD",whip:"\u4E50\u97AD"},Os=h=>{const t=h.replace(/ /g," ").toLocaleLowerCase(),e=Object.keys(re);for(let i=0;i3&&(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 a=this.r.toString(16),u=this.g.toString(16),l=this.b.toString(16);return a.length==1&&(a="0"+a),u.length==1&&(u="0"+u),l.length==1&&(l="0"+l),"#"+a+u+l},this.getHelpXML=function(){for(var a=new Array,u=0;u "+p.toRGB()+" -> "+p.toHex());d.appendChild(y),d.appendChild(x),c.appendChild(d)}catch{}return c}};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var We=function(h,t){return(We=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 Ge(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}We(h,t),h.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function ui(h){var t="";Array.isArray(h)||(h=[h]);for(var e=0;eh.phi1&&(h.phi2-=2*ot),h.sweepFlag===1&&h.phi2i)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 R,et=Math.PI/180;function Fe(h,t,e){return(1-e)*h+e*t}function Pe(h,t,e,i){return h+Math.cos(i/180*ot)*t+Math.sin(i/180*ot)*e}function Me(h,t,e,i){var s=1e-6,r=t-h,o=e-t,n=3*r+3*(i-e)-6*o,a=6*(o-r),u=3*r;return Math.abs(n)S&&(c.sweepFlag=+!c.sweepFlag),c})}function o(){return function(n){var a={};for(var u in n)a[u]=n[u];return a}}h.ROUND=function(n){function a(u){return Math.round(u*n)/n}return n===void 0&&(n=1e13),K(n),function(u){return u.x1!==void 0&&(u.x1=a(u.x1)),u.y1!==void 0&&(u.y1=a(u.y1)),u.x2!==void 0&&(u.x2=a(u.x2)),u.y2!==void 0&&(u.y2=a(u.y2)),u.x!==void 0&&(u.x=a(u.x)),u.y!==void 0&&(u.y=a(u.y)),u.rX!==void 0&&(u.rX=a(u.rX)),u.rY!==void 0&&(u.rY=a(u.rY)),u}},h.TO_ABS=t,h.TO_REL=function(){return s(function(n,a,u){return n.relative||(n.x1!==void 0&&(n.x1-=a),n.y1!==void 0&&(n.y1-=u),n.x2!==void 0&&(n.x2-=a),n.y2!==void 0&&(n.y2-=u),n.x!==void 0&&(n.x-=a),n.y!==void 0&&(n.y-=u),n.relative=!0),n})},h.NORMALIZE_HVZ=function(n,a,u){return n===void 0&&(n=!0),a===void 0&&(a=!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 a&&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 a=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(a)?0:c-a,v=isNaN(u)?0:d-u),g.type&(m.CURVE_TO|m.SMOOTH_CURVE_TO)?(a=g.relative?c+g.x2:g.x2,u=g.relative?d+g.y2:g.y2):(a=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 w=g.x===void 0?0:g.relative?g.x:g.x-c,E=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,M=g.y2===void 0?0:g.relative?g.y:g.y2-d;x(w)<=n&&x(E)<=n&&x(b)<=n&&x(v)<=n&&x(S)<=n&&x(M)<=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,a,u){a===void 0&&(a=0),u===void 0&&(u=0),K(n,a,u);var l=Math.sin(n),f=Math.cos(n);return r(f,l,-l,f,a-a*f+u*l,u-a*l-u*f)},h.TRANSLATE=function(n,a){return a===void 0&&(a=0),K(n,a),r(1,0,0,1,n,a)},h.SCALE=function(n,a){return a===void 0&&(a=n),K(n,a),r(n,0,0,a,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,a,u){return m.ARC===n.type?function(l,f,g){var c,d,p,y;l.cX||ae(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),w=f,E=g,S=0;Sf.maxX&&(f.maxX=N),Nf.maxY&&(f.maxY=N),NV&&y(Ne(c,p.x1,p.x2,p.x,V));for(var v=0,w=Me(d,p.y1,p.y2,p.y);vV&&x(Ne(d,p.y1,p.y2,p.y,V))}if(p.type&m.ARC){y(p.x),x(p.y),ae(p,c,d);for(var E=p.xRot/180*Math.PI,S=Math.cos(E)*p.rX,M=Math.sin(E)*p.rX,B=-Math.sin(E)*p.rY,_=Math.cos(E)*p.rY,z=p.phi1p.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 ttI&&VI&&Vl)throw new SyntaxError('Expected positive number, got "'+l+'" at index "'+o+'"')}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 "'+o+'"')}this.curArgs.push(l),this.curArgs.length===ci[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(!hi(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 "+o+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+n+'" at index '+o+". 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 '+o+".");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,o=Object.getPrototypeOf(this).parse.call(this,i);r>w;if(o[b+3]=qt,qt!==0){var Qt=255/qt;o[b]=(N*v>>w)*Qt,o[b+1]=(Y*v>>w)*Qt,o[b+2]=(Z*v>>w)*Qt}else o[b]=o[b+1]=o[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=Gt+r+1;ht=C+(ht>w,G>0?(G=255/G,o[q]=(Vt*v>>w)*G,o[q+1]=(Bt*v>>w)*G,o[q+2]=(kt*v>>w)*G):o[q]=o[q+1]=o[q+2]=0,Vt-=$t,Bt-=Zt,kt-=jt,Dt-=Kt,$t-=y.r,Zt-=y.g,jt-=y.b,Kt-=y.a,q=xt+((q=se+l)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 bi(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 vi=Object.freeze({__proto__:null,offscreen:xi,node:bi});function St(h){return h.replace(/(?!\u3000)\s+/gm," ")}function Ai(h){return h.replace(/^[\n \t]+/,"")}function Ci(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 Si(h){const t=$(h);return[t[0]||0,t[1]||0,t[2]||0,t[3]||0,t[4]||0,t[5]||0]}const Ti=/^[A-Z-]+$/;function Ei(h){return Ti.test(h)?h.toLowerCase():h}function Qe(h){const t=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(h);return t&&(t[2]||t[3]||t[4])||""}function wi(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 Fi=/(\[[^\]]+\])/g,Pi=/(#[^\s+>~.[:]+)/g,Mi=/(\.[^\s+>~.[:]+)/g,Ni=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,Oi=/(:[\w-]+\([^)]*\))/gi,Vi=/(:[^\s+>~.[:]+)/g,Bi=/([^\s+>~.[:]+)/g;function dt(h,t){const e=t.exec(h);return e?[h.replace(t," "),e.length]:[h,0]}function ki(h){const t=[0,0,0];let e=h.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),i=0;return[e,i]=dt(e,Fi),t[1]+=i,[e,i]=dt(e,Pi),t[0]+=i,[e,i]=dt(e,Mi),t[1]+=i,[e,i]=dt(e,Ni),t[2]+=i,[e,i]=dt(e,Oi),t[1]+=i,[e,i]=dt(e,Vi),t[1]+=i,e=e.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[e,i]=dt(e,Bi),t[2]+=i,t.join("")}const At=1e-8;function Be(h){return Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))}function fe(h,t){return(h[0]*t[0]+h[1]*t[1])/(Be(h)*Be(t))}function ke(h,t){return(h[0]*t[1]0&&arguments[0]!==void 0?arguments[0]:" ";const{document:e,name:i}=this;return St(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=wi(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 o=this.getNumber();return e&&o<1?o*r.computeSize(i):o}}}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;r1&&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;r0}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((o,n)=>{let{run:a}=o;for(r=i[n];r;)a(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,o)=>{let{x:n,y:a}=r;!s[o]&&e.isPointInPath&&e.isPointInPath(n,a)&&(s[o]=t)})}checkBoundingBox(t,e){if(!this.working||!e)return;const{events:i,eventElements:s}=this;i.forEach((r,o)=>{let{x:n,y:a}=r;!s[o]&&e.isPointInBox(n,a)&&(s[o]=t)})}mapXY(t,e){const{window:i,ctx:s}=this.screen,r=new O(t,e);let o=s.canvas;for(;o;)r.x-=o.offsetLeft,r.y-=o.offsetTop,o=o.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 $e=typeof window!="undefined"?window:null,Ze=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:o,height:n,desiredHeight:a,minX:u=0,minY:l=0,refX:f,refY:g,clip:c=!1,clipX:d=0,clipY:p=0}=t;const y=St(s).replace(/^defer\s/,""),[x,C]=y.split(" "),b=x||"xMidYMid",v=C||"meet",w=r/o,E=n/a,S=Math.min(w,E),M=Math.max(w,E);let B=o,_=a;v==="meet"&&(B*=S,_*=S),v==="slice"&&(B*=M,_*=M);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,k=S*p;i.beginPath(),i.moveTo(L,k),i.lineTo(r,k),i.lineTo(r,n),i.lineTo(L,n),i.closePath(),i.clip()}if(!U){const L=v==="meet"&&S===E,k=v==="slice"&&M===E,X=v==="meet"&&S===w,H=v==="slice"&&M===w;b.startsWith("xMid")&&(L||k)&&i.translate(r/2-B/2,0),b.endsWith("YMid")&&(X||H)&&i.translate(0,n/2-_/2),b.startsWith("xMax")&&(L||k)&&i.translate(r-B,0),b.endsWith("YMax")&&(X||H)&&i.translate(0,n-_)}switch(!0){case b==="none":i.scale(w,E);break;case v==="meet":i.scale(S,S);break;case v==="slice":i.scale(M,M);break}i.translate(-u,-l)}start(t){let{enableRedraw:e=!1,ignoreMouse:i=!1,ignoreAnimation:s=!1,ignoreDimensions:r=!1,ignoreClear:o=!1,forceRedraw:n,scaleWidth:a,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,o,a,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,o,a,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,o)=>o.update(i)||r,!1))return!0}return!!(typeof e=="function"&&e()||!this.isReadyLock&&this.isReady()||this.mouse.hasEvents())}render(t,e,i,s,r,o,n){const{viewPort:a,ctx:u,isFirstRender:l}=this,f=u.canvas;a.clear(),f.width&&f.height&&a.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")),a.setCurrent(d,p),typeof o=="number"&&t.getAttribute("x",!0).setValue(o),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=Ze,window:i=$e}={}){if(this.ctx=t,this.viewPort=new Ft,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=$e;rt.defaultFetch=Ze;rt.FRAMERATE=30;rt.MAX_VIRTUAL_PIXELS=3e4;const{defaultFetch:Ri}=rt,Li=typeof DOMParser!="undefined"?DOMParser:void 0;class ue{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=Ri,DOMParser:e=Li}={}){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 Ii{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 _i{apply(t){const{cx:e,cy:i,originX:s,originY:r,angle:o}=this,n=e+s.getPixels("x"),a=i+r.getPixels("y");t.translate(n,a),t.rotate(o.getRadians()),t.translate(-n,-a)}unapply(t){const{cx:e,cy:i,originX:s,originY:r,angle:o}=this,n=e+s.getPixels("x"),a=i+r.getPixels("y");t.translate(n,a),t.rotate(-1*o.getRadians()),t.translate(-n,-a)}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 zi{apply(t){const{scale:{x:e,y:i},originX:s,originY:r}=this,o=s.getPixels("x"),n=r.getPixels("y");t.translate(o,n),t.scale(e,i||e),t.translate(-o,-n)}unapply(t){const{scale:{x:e,y:i},originX:s,originY:r}=this,o=s.getPixels("x"),n=r.getPixels("y");t.translate(o,n),t.scale(1/e,1/i||e),t.translate(-o,-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=At,s.y=At),this.scale=s,this.originX=i[0],this.originY=i[1]}}class je{apply(t){const{originX:e,originY:i,matrix:s}=this,r=e.getPixels("x"),o=i.getPixels("y");t.translate(r,o),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),t.translate(-r,-o)}unapply(t){const{originX:e,originY:i,matrix:s}=this,r=s[0],o=s[2],n=s[4],a=s[1],u=s[3],l=s[5],f=0,g=0,c=1,d=1/(r*(u*c-l*g)-o*(a*c-l*f)+n*(a*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-a*c),d*(n*g-o*c),d*(r*c-n*f),d*(o*l-n*u),d*(n*a-r*l)),t.translate(-p,-y)}applyToPoint(t){t.applyTransform(this.matrix)}constructor(t,e,i){this.type="matrix",this.matrix=Si(e),this.originX=i[0],this.originY=i[1]}}class Ke extends je{constructor(t,e,i){super(t,e,i),this.type="skew",this.angle=new A(t,"angle",e)}}class Hi extends Ke{constructor(t,e,i){super(t,e,i),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class Ui extends Ke{constructor(t,e,i){super(t,e,i),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}function Xi(h){return St(h).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}function Yi(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 o=[s,r];return new pt(t,i.getString(),o)}}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=[],Xi(e).forEach(r=>{if(r==="none")return;const[o,n]=Yi(r),a=pt.transformTypes[o];a&&this.transforms.push(new a(this.document,n,i))})}}pt.transformTypes={translate:Ii,rotate:_i,scale:zi,matrix:je,skewX:Hi,skewY:Ui};class P{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:o}=this;if(o){const n=o.getStyle(t);if(n.hasValue())return n}}if(e){const o=new A(this.document,t,"");return this.styles[t]=o,o}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 P?t:this.document.createElement(t);e.parent=this,P.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],o=e[s];if(r)for(const n in r){let a=this.stylesSpecificity[n];typeof a=="undefined"&&(a="000"),o&&o>=a&&(i=r[n],i&&(this.styles[n]=i),this.stylesSpecificity[n]=o)}}}removeStyles(t,e){return e.reduce((s,r)=>{const o=t.getStyle(r);if(!o.hasValue())return s;const n=o.getString();return o.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(o=>{const n=Ei(o.nodeName);this.attributes[n]=new A(t,n,o.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue()&&this.getAttribute("style").getString().split(";").map(n=>n.trim()).forEach(n=>{if(!n)return;const[a,u]=n.split(":").map(l=>l.trim());a&&(this.styles[a]=new A(t,a,u))});const{definitions:s}=t,r=this.getAttribute("id");r.hasValue()&&(s[r.getString()]||(s[r.getString()]=this)),Array.from(e.childNodes).forEach(o=>{if(o.nodeType===1)this.addChild(o);else if(i&&(o.nodeType===3||o.nodeType===4)){const n=t.createTextNode(o);n.getText().length>0&&this.addChild(n)}})}}P.ignoreChildTypes=["title"];class Wi extends P{constructor(t,e,i){super(t,e,i)}}function Gi(h){const t=h.trim();return/^('|")/.test(t)?t:'"'.concat(t,'"')}function qi(h){return typeof process=="undefined"?h:h.trim().split(",").map(Gi).join(",")}function Qi(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 $i(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="",o="",n="";const a=St(t).trim().split(" "),u={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return a.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"&&(o=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,o,n,e)}toString(){return[Qi(this.fontStyle),this.fontVariant,$i(this.fontWeight),this.fontSize,qi(this.fontFamily)].join(" ").trim()}constructor(t,e,i,s,r,o){const n=o?typeof o=="string"?W.parse(o):o:{};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),tthis.x2&&(this.x2=t)),typeof e!="undefined"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.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 o=6*e-12*i+6*s,n=-3*e+9*i-9*s+3*r,a=3*i-3*e;if(n===0){if(o===0)return;const g=-a/o;01&&arguments[1]!==void 0?arguments[1]:!1;if(!e){const i=this.getStyle("fill"),s=this.getStyle("fill-opacity"),r=this.getStyle("stroke"),o=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,o);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(o.hasValue()){const c=new A(this.document,"stroke",t.strokeStyle).addOpacity(o).getString();t.strokeStyle=c}const n=this.getStyle("stroke-width");if(n.hasValue()){const c=n.getPixels();t.lineWidth=c||At}const a=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(a.hasValue()&&(t.lineCap=a.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"),o=this.getStyle("font-weight"),n=this.getStyle("font-size"),a=this.getStyle("font-family"),u=new W(s.getString(),r.getString(),o.getString(),n.hasValue()?"".concat(n.getPixels(!0),"px"):"",a.getString(),W.parse(i.getString(),t.font));s.setValue(u.fontStyle),r.setValue(u.fontVariant),o.setValue(u.fontWeight),n.setValue(u.fontSize),a.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 o;const n=e.length,a=e[i-1],u=e[i+1];let l="isolated";(i===0||a===" ")&&i0&&a!==" "&&i0&&a!==" "&&(i===n-1||u===" ")&&(l="initial"),r=((o=t.arabicGlyphs[s])===null||o===void 0?void 0:o[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 o=St(e.textContent||"");return s===0&&(o=Ai(o)),s===r&&(o=Ci(o)),o}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:a}=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/a,c=r.isRTL?s.split("").reverse().join(""):s,d=$(i.getAttribute("dx").getString()),p=c.length;for(let y=0;y=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.adjustChildCoordinatesRecursiveCore(t,this,this,i)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,i,s){const r=i.children[s];r.children.length>0?r.children.forEach((o,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 o=r.getAttribute("x"),n=r.getAttribute("y"),a=r.getAttribute("dx"),u=r.getAttribute("dy"),l=r.getStyle("font-family").getDefinition(),f=Boolean(l==null?void 0:l.isRTL);s===0&&(o.hasValue()||o.setValue(r.getInheritedAttribute("x")),n.hasValue()||n.setValue(r.getInheritedAttribute("y")),a.hasValue()||a.setValue(r.getInheritedAttribute("dx")),u.hasValue()||u.setValue(r.getInheritedAttribute("dy")));const g=r.measureText(t);return f&&(e.x-=g),o.hasValue()?(e.applyAnchoring(),r.x=o.getPixels("x"),a.hasValue()&&(r.x+=a.getPixels("x"))):(a.hasValue()&&(e.x+=a.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 o=r.getBoundingBox(t);return o&&r.children.forEach((n,a)=>{const u=e.getChildBoundingBox(t,e,r,a);o.addBoundingBox(u)}),o}renderChild(t,e,i,s){const r=i.children[s];r.render(t),r.children.forEach((o,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 o=this.getFontSize(),n=s.isRTL?e.split("").reverse().join(""):e,a=$(i.getAttribute("dx").getString()),u=n.length;let l=0;for(let f=0;f0?"":this.getTextFromNode()}}class Zi extends Xt{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[r,i[o]])}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"),o=this.getStyle("marker-mid"),n=this.getStyle("marker-end");if(r.isUrlDefinition()){const a=r.getDefinition(),[u,l]=i[0];a.render(t,u,l)}if(o.isUrlDefinition()){const a=o.getDefinition();for(let u=1;u1&&(s*=Math.sqrt(g),r*=Math.sqrt(g));let c=(n===a?-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=ke([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=ke(x,C);return fe(x,C)<=-1&&(b=Math.PI),fe(x,C)>=1&&(b=0),{currentPoint:l,rX:s,rY:r,sweepFlag:a,xAxisRotation:u,centp:p,a1:y,ad:b}}pathA(t,e){const{pathParser:i}=this,{currentPoint:s,rX:r,rY:o,sweepFlag:n,xAxisRotation:a,centp:u,a1:l,ad:f}=F.pathA(i),g=1-n?1:-1,c=l+g*(f/2),d=new O(u.x+r*Math.cos(c),u.y+o*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>o?r:o,y=r>o?1:r/o,x=r>o?o/r:1;t.translate(u.x,u.y),t.rotate(a),t.scale(y,x),t.arc(0,0,p,l,l+f,Boolean(1-n)),t.scale(1/y,1/x),t.rotate(-a),t.translate(-u.x,-u.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){F.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 Pt extends mt{setContext(t){var e;const{document:i}=this,{screen:s,window:r}=i,o=t.canvas;if(s.setDefaults(t),"style"in o&&typeof t.font!="undefined"&&r&&typeof r.getComputedStyle!="undefined"){t.font=r.getComputedStyle(o).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:a}=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"),a=this.getStyle("height").getPixels("y"),this.type==="marker"&&(y=d,x=p,d=0,p=0)),s.viewPort.setCurrent(n,a),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],a=g[3]),i.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:s.viewPort.width,desiredWidth:n,height:s.viewPort.height,desiredHeight:a,minX:d,minY:p,refX:u.getValue(),refY:l.getValue(),clip:c,clipX:y,clipY:x}),g&&(s.viewPort.removeCurrent(),s.viewPort.setCurrent(n,a))}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),o=this.getAttribute("viewBox"),n=this.getAttribute("style"),a=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),o.hasValue()||o.setValue("0 0 ".concat(a||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 Je extends F{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"),o=this.getAttribute("rx"),n=this.getAttribute("ry");let a=o.getPixels("x"),u=n.getPixels("y");if(o.hasValue()&&!n.hasValue()&&(u=a),n.hasValue()&&!o.hasValue()&&(a=u),a=Math.min(a,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+a,i),t.lineTo(e+s-a,i),t.bezierCurveTo(e+s-a+l*a,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-a+l*a,i+r,e+s-a,i+r),t.lineTo(e+a,i+r),t.bezierCurveTo(e+a-l*a,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+a-l*a,i,e+a,i),t.closePath())}return new J(e,i,e+s,i+r)}getMarkers(){return null}constructor(...t){super(...t),this.type="rect"}}class ji extends F{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 Ki extends F{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"),o=this.getAttribute("cy").getPixels("y");return t&&i>0&&s>0&&(t.beginPath(),t.moveTo(r+i,o),t.bezierCurveTo(r+i,o+e*s,r+e*i,o+s,r,o+s),t.bezierCurveTo(r-e*i,o+s,r-i,o+e*s,r-i,o),t.bezierCurveTo(r-i,o-e*s,r-e*i,o-s,r,o-s),t.bezierCurveTo(r+e*i,o-s,r+i,o-e*s,r+i,o),t.closePath()),new J(r-i,o-s,r+i,o+s)}getMarkers(){return null}constructor(...t){super(...t),this.type="ellipse"}}class Ji extends F{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 ti extends F{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(o=>{let{x:n,y:a}=o;r.addPoint(n,a),t&&t.lineTo(n,a)}),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 ts extends ti{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 es extends P{createPattern(t,e,i){const s=this.getStyle("width").getPixels("x",!0),r=this.getStyle("height").getPixels("y",!0),o=new Pt(this.document,null);o.attributes.viewBox=new A(this.document,"viewBox",this.getAttribute("viewBox").getValue()),o.attributes.width=new A(this.document,"width","".concat(s,"px")),o.attributes.height=new A(this.document,"height","".concat(r,"px")),o.attributes.transform=new A(this.document,"transform",this.getAttribute("patternTransform").getValue()),o.children=this.children;const n=this.document.createCanvas(s,r),a=n.getContext("2d"),u=this.getAttribute("x"),l=this.getAttribute("y");u.hasValue()&&l.hasValue()&&a.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++)a.save(),o.attributes.x=new A(this.document,"x",g*n.width),o.attributes.y=new A(this.document,"y",c*n.height),o.render(a),a.restore();return t.createPattern(n,"repeat")}constructor(...t){super(...t),this.type="pattern"}}class is extends P{render(t,e,i){if(!e)return;const{x:s,y:r}=e,o=this.getAttribute("orient").getString("auto"),n=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(s,r),o==="auto"&&t.rotate(i),n==="strokeWidth"&&t.scale(t.lineWidth,t.lineWidth),t.save();const a=new Pt(this.document);a.type=this.type,a.attributes.viewBox=new A(this.document,"viewBox",this.getAttribute("viewBox").getValue()),a.attributes.refX=new A(this.document,"refX",this.getAttribute("refX").getValue()),a.attributes.refY=new A(this.document,"refY",this.getAttribute("refY").getValue()),a.attributes.width=new A(this.document,"width",this.getAttribute("markerWidth").getValue()),a.attributes.height=new A(this.document,"height",this.getAttribute("markerHeight").getValue()),a.attributes.overflow=new A(this.document,"overflow",this.getAttribute("overflow").getValue()),a.attributes.fill=new A(this.document,"fill",this.getAttribute("fill").getColor("black")),a.attributes.stroke=new A(this.document,"stroke",this.getAttribute("stroke").getValue("none")),a.children=this.children,a.render(t),t.restore(),n==="strokeWidth"&&t.scale(1/t.lineWidth,1/t.lineWidth),o==="auto"&&t.rotate(-i),t.translate(-s,-r)}constructor(...t){super(...t),this.type="marker"}}class ss extends P{render(){}constructor(...t){super(...t),this.type="defs"}}class ge 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 ei extends P{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,o=this.getGradient(t,e);if(!o)return this.addParentOpacity(i,r[r.length-1].color);if(r.forEach(n=>{o.addColorStop(n.offset,this.addParentOpacity(i,n.color))}),this.getAttribute("gradientTransform").hasValue()){const{document:n}=this,{MAX_VIRTUAL_PIXELS:a}=rt,{viewPort:u}=n.screen,l=u.getRoot(),f=new Je(n);f.attributes.x=new A(n,"x",-a/3),f.attributes.y=new A(n,"y",-a/3),f.attributes.width=new A(n,"width",a),f.attributes.height=new A(n,"height",a);const g=new ge(n);g.attributes.transform=new A(n,"transform",this.getAttribute("gradientTransform").getValue()),g.children=[f];const c=new Pt(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=o,c.render(p),p.createPattern(d,"no-repeat")}return o}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(o=>{o.type==="stop"&&s.push(o)})}}class rs extends ei{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"),o=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"),a=i?s.y+s.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return r===n&&o===a?null:t.createLinearGradient(r,o,n,a)}constructor(t,e,i){super(t,e,i),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}}class ns extends ei{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"),o=i?s.y+s.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y");let n=r,a=o;this.getAttribute("fx").hasValue()&&(n=i?s.x+s.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(a=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,a,l,r,o,u)}constructor(t,e,i){super(t,e,i),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}}class os extends P{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 o=this.getStyle("stop-color",!0);o.getString()===""&&o.setValue("#000"),r.hasValue()&&(o=o.addOpacity(r)),this.offset=s,this.color=o.getColor()}}class de extends P{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{const u=r[a];return n+(u-n)*t}).join(" ")}constructor(...t){super(...t),this.type="animateTransform"}}class ii extends P{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 pe extends F{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 si extends pe{constructor(...t){super(...t),this.type="missing-glyph",this.horizAdvX=0}}class hs extends P{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 o of r)if(o instanceof ii){this.fontFace=o;const n=o.getStyle("font-family");n.hasValue()&&(s[n.getString()]=this)}else if(o instanceof si)this.missingGlyph=o;else if(o instanceof pe)if(o.arabicForm){this.isRTL=!0,this.isArabic=!0;const n=this.arabicGlyphs[o.unicode];typeof n=="undefined"?this.arabicGlyphs[o.unicode]={[o.arabicForm]:o}:n[o.arabicForm]=o}else this.glyphs[o.unicode]=o}}class ls 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 cs 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,o=new A(e,"fontSize",W.parse(e.ctx.font).fontSize);r.isWorking()&&r.checkBoundingBox(this,new J(i,s-o.getPixels("y"),i+this.measureText(t),s))}else if(this.children.length>0){const e=new ge(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],o=s.length>0&&Array.from(s).every(n=>n.nodeType===3);this.hasText=o,this.text=o?this.getTextFromNode(r):""}}class fs 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[o,n,a,u,l,f,g,c]=r,d=a>u?a:u,p=a>u?1:a/u,y=a>u?u/a:1;t&&(t.translate(o,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(-o,-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((o,n)=>{const{p0:a,p1:u,rotation:l,text:f}=o;t.save(),t.translate(a.x,a.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(a.x,a.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,o,n,a,u){let l=o,f=this.measureText(t,a);a===" "&&e==="justify"&&i-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")),o=this.parent.getAttribute("dy").getPixels("y"),n=this.parent.getStyle("text-anchor").getString("start"),a=this.getStyle("letter-spacing"),u=this.parent.getStyle("letter-spacing");let l=0;!a.hasValue()||a.getValue()==="inherit"?l=u.getPixels():a.hasValue()&&a.getValue()!=="initial"&&a.getValue()!=="unset"&&(l=a.getPixels());const f=[],g=e.length;this.letterSpacingCache=f;for(let b=0;bw===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:w,segment:E,rotation:S}=this.findSegmentToFitChar(t,n,p,y,s,C,o,b,v);C=w,!(!E.p0||!E.p1)&&this.glyphInfo.push({text:i[v],p0:E.p0,p1:E.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,o=s?s.y:0,n=i.next();let a=n.type,u=[];switch(n.type){case T.MOVE_TO:this.pathM(i,u);break;case T.LINE_TO:a=this.pathL(i,u);break;case T.HORIZ_LINE_TO:a=this.pathH(i,u);break;case T.VERT_LINE_TO:a=this.pathV(i,u);break;case T.CURVE_TO:this.pathC(i,u);break;case T.SMOOTH_CURVE_TO:a=this.pathS(i,u);break;case T.QUAD_TO:this.pathQ(i,u);break;case T.SMOOTH_QUAD_TO:a=this.pathT(i,u);break;case T.ARC:u=this.pathA(i);break;case T.CLOSE_PATH:F.pathZ(i);break}n.type!==T.CLOSE_PATH?e.push({type:a,points:u,start:{x:r,y:o},pathLength:this.calcLength(r,o,a,u)}):e.push({type:T.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){const{x:i,y:s}=F.pathM(t).point;e.push(i,s)}pathL(t,e){const{x:i,y:s}=F.pathL(t).point;return e.push(i,s),T.LINE_TO}pathH(t,e){const{x:i,y:s}=F.pathH(t).point;return e.push(i,s),T.LINE_TO}pathV(t,e){const{x:i,y:s}=F.pathV(t).point;return e.push(i,s),T.LINE_TO}pathC(t,e){const{point:i,controlPoint:s,currentPoint:r}=F.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}=F.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}=F.pathQ(t);e.push(i.x,i.y,s.x,s.y)}pathT(t,e){const{controlPoint:i,currentPoint:s}=F.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:o,a1:n,ad:a}=F.pathA(t);return s===0&&a>0&&(a-=2*Math.PI),s===1&&a<0&&(a+=2*Math.PI),[o.x,o.y,e,i,n,a,r,s]}calcLength(t,e,i,s){let r=0,o=null,n=null,a=0;switch(i){case T.LINE_TO:return this.getLineLength(t,e,s[0],s[1]);case T.CURVE_TO:for(r=0,o=this.getPointOnCubicBezier(0,t,e,s[0],s[1],s[2],s[3],s[4],s[5]),a=.01;a<=1;a+=.01)n=this.getPointOnCubicBezier(a,t,e,s[0],s[1],s[2],s[3],s[4],s[5]),r+=this.getLineLength(o.x,o.y,n.x,n.y),o=n;return r;case T.QUAD_TO:for(r=0,o=this.getPointOnQuadraticBezier(0,t,e,s[0],s[1],s[2],s[3]),a=.01;a<=1;a+=.01)n=this.getPointOnQuadraticBezier(a,t,e,s[0],s[1],s[2],s[3]),r+=this.getLineLength(o.x,o.y,n.x,n.y),o=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)f;a-=g)n=this.getPointOnEllipticalArc(s[0],s[1],s[2],s[3],a,0),r+=this.getLineLength(o.x,o.y,n.x,n.y),o=n;else for(a=u+g;a5&&arguments[5]!==void 0?arguments[5]:e,n=arguments.length>6&&arguments[6]!==void 0?arguments[6]:i;const a=(r-i)/(s-e+At);let u=Math.sqrt(t*t/(1+a*a));se)return null;const{dataArray:r}=this;for(const o of r){if(o&&(o.pathLength<5e-5||i+o.pathLength+5e-5=0&&a>f)break;s=this.getPointOnEllipticalArc(o.points[0],o.points[1],o.points[2],o.points[3],a,o.points[6]);break}case T.CURVE_TO:a=n/o.pathLength,a>1&&(a=1),s=this.getPointOnCubicBezier(a,o.start.x,o.start.y,o.points[0],o.points[1],o.points[2],o.points[3],o.points[4],o.points[5]);break;case T.QUAD_TO:a=n/o.pathLength,a>1&&(a=1),s=this.getPointOnQuadraticBezier(a,o.start.x,o.start.y,o.points[0],o.points[1],o.points[2],o.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,o,n,a,u){const l=a*De(t)+o*Re(t)+s*Le(t)+e*Ie(t),f=u*De(t)+n*Re(t)+r*Le(t)+i*Ie(t);return{x:l,y:f}}getPointOnQuadraticBezier(t,e,i,s,r,o,n){const a=o*_e(t)+s*ze(t)+e*He(t),u=n*_e(t)+r*ze(t)+i*He(t);return{x:a,y:u}}getPointOnEllipticalArc(t,e,i,s,r,o){const n=Math.cos(o),a=Math.sin(o),u={x:i*Math.cos(r),y:s*Math.sin(r)};return{x:t+(u.x*n-u.y*a),y:e+(u.x*a+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 o=0;for(let n=0;n<=i;n+=s){const a=this.getPointOnPath(n),u=this.getPointOnPath(n+s);!a||!u||(o+=this.getLineLength(a.x,a.y,u.x,u.y),o>=r&&(this.equidistantCache.points.push({x:a.x,y:a.y,distance:n}),o-=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 gs=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class ds 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=gs.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"),o=this.getAttribute("y").getPixels("y"),n=this.getStyle("width").getPixels("x"),a=this.getStyle("height").getPixels("y");if(!(!s||!i||!n||!a)){if(t.save(),t.translate(r,o),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:a}),{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:a,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 ps extends mt{render(t){}constructor(...t){super(...t),this.type="symbol"}}class ms{async load(t,e){try{const{document:i}=this,r=(await i.canvg.parser.load(e)).getElementsByTagName("font");Array.from(r).forEach(o=>{const n=i.createElement(o);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 ri extends P{constructor(t,e,i){super(t,e,i),this.type="style",St(Array.from(e.childNodes).map(o=>o.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(o=>{const n=o.trim();if(!n)return;const a=n.split("{"),u=a[0].split(","),l=a[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]=ki(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=Qe(y);x&&new ms(t).load(d,x)}})}})})}}ri.parseExternalUrl=Qe;class ys 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 Pt(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 o=this.getStyle("width",!1,!0),n=this.getStyle("height",!1,!0);o.hasValue()&&(s.attributes.width=new A(e,"width",o.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 _t(h,t,e,i,s,r){return h[e*i*4+t*4+r]}function zt(h,t,e,i,s,r,o){h[e*i*4+t*4+r]=o}function D(h,t,e){return h[t]*e}function it(h,t,e,i){return t+Math.cos(h)*e+Math.sin(h)*i}class ni extends P{apply(t,e,i,s,r){const{includeOpacity:o,matrix:n}=this,a=t.getImageData(0,0,s,r);for(let u=0;u{c.addBoundingBox(d.getBoundingBox(t))}),s=Math.floor(c.x1),r=Math.floor(c.y1),o=Math.floor(c.width),n=Math.floor(c.height)}const a=this.removeStyles(e,Yt.ignoreStyles),u=i.createCanvas(s+o,r+n),l=u.getContext("2d");i.screen.setDefaults(l),this.renderChildren(l),new ni(i,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(l,0,0,s+o,r+n);const f=i.createCanvas(s+o,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+o,r+n),t.fillStyle=g.createPattern(f,"no-repeat"),t.fillRect(0,0,s+o,r+n),this.restoreStyles(e,a)}render(t){}constructor(...t){super(...t),this.type="mask"}}Yt.ignoreStyles=["mask","transform","clip-path"];const Xe=()=>{};class xs extends P{apply(t){const{document:e}=this,i=Reflect.getPrototypeOf(t),{beginPath:s,closePath:r}=t;i&&(i.beginPath=Xe,i.closePath=Xe),Reflect.apply(s,t,[]),this.children.forEach(o=>{if(!("path"in o))return;let n="elementTransform"in o?o.elementTransform():null;n||(n=pt.fromElement(e,o)),n&&n.apply(t),o.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 Wt extends P{apply(t,e){const{document:i,children:s}=this,r="getBoundingBox"in e?e.getBoundingBox(t):null;if(!r)return;let o=0,n=0;s.forEach(x=>{const C=x.extraFilterDistance||0;o=Math.max(o,C),n=Math.max(n,C)});const a=Math.floor(r.width),u=Math.floor(r.height),l=a+2*o,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,Wt.ignoreStyles),p=i.createCanvas(l,f),y=p.getContext("2d");i.screen.setDefaults(y),y.translate(-g+o,-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-o,c-n,l,f),this.restoreStyles(e,d)}render(t){}constructor(...t){super(...t),this.type="filter"}}Wt.ignoreStyles=["filter","transform","clip-path"];class bs extends P{apply(t,e,i,s,r){}constructor(t,e,i){super(t,e,i),this.type="feDropShadow",this.addStylesFromStyleDefinition()}}class vs extends P{apply(t,e,i,s,r){}constructor(...t){super(...t),this.type="feMorphology"}}class As extends P{apply(t,e,i,s,r){}constructor(...t){super(...t),this.type="feComposite"}}class Cs extends P{apply(t,e,i,s,r){const{document:o,blurRadius:n}=this,a=o.window?o.window.document.body:null,u=t.canvas;u.id=o.getUniqueId(),a&&(u.style.display="none",a.appendChild(u)),mi(u,e,i,s,r,n),a&&a.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 Ss extends P{constructor(...t){super(...t),this.type="title"}}class Ts extends P{constructor(...t){super(...t),this.type="desc"}}const Es={svg:Pt,rect:Je,circle:ji,ellipse:Ki,line:Ji,polyline:ti,polygon:ts,path:F,pattern:es,marker:is,defs:ss,linearGradient:rs,radialGradient:ns,stop:os,animate:de,animateColor:as,animateTransform:us,font:hs,"font-face":ii,"missing-glyph":si,glyph:pe,text:ut,tspan:Xt,tref:ls,a:cs,textPath:fs,image:ds,g:ge,symbol:ps,style:ri,use:ys,mask:Yt,clipPath:xs,filter:Wt,feDropShadow:bs,feMorphology:vs,feComposite:As,feColorMatrix:ni,feGaussianBlur:Cs,title:Ss,desc:Ts};function ws(h,t){const e=document.createElement("canvas");return e.width=h,e.height=t,e}async function Fs(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,o,n,a,u)=>{s(u)},e.src=h})}const he=12;class at{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]||he}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=at.elementTypes[e];return i?new i(this,t):new Wi(this,t)}createTextNode(t){return new Zi(this,t)}setViewBox(t){this.screen.setViewBox({document:this,...t})}constructor(t,{rootEmSize:e=he,emSize:i=he,createCanvas:s=at.createCanvas,createImage:r=at.createImage,anonymousCrossOrigin:o}={}){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,o),this.screen.wait(()=>this.isImagesLoaded()),this.screen.wait(()=>this.isFontsLoaded())}}at.createCanvas=ws;at.createImage=Fs;at.elementTypes=Es;class bt{static async from(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=await new ue(i).parse(e);return new bt(t,r,i)}static fromString(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=new ue(i).parseFromString(e);return new bt(t,r,i)}fork(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return bt.from(t,e,{...this.options,...i})}forkString(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return bt.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 ue(i),this.screen=new rt(t,i),this.options=i;const s=new at(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 Ps=vi.offscreen(),Ms=h=>new Promise((t,e)=>{const i=new FileReader;i.onloadend=()=>t(i.result),i.readAsDataURL(h)}),Bs=async(h,t,e)=>{let i=new OffscreenCanvas(t,e);const s=i.getContext("2d");let r=await bt.fromString(s,h,Ps);r.resize(t/1.2,e/1.2,"xMidYMid meet"),await r.start();let o=await i.convertToBlob();const n=await Ms(o);return s.clearRect(0,0,i.width,i.height),i=null,r.stop(),r=null,o=null,n};export{Os as g,Bs as s};