16 lines
125 KiB
JavaScript
16 lines
125 KiB
JavaScript
import{T as Hn,s as Bn,b as mn,e as Ct,h as gn,c as Ot,d as It,g as W,u as wt,U as St,j as ut,k as Et,n as ke,m as Ne,o as Un,t as yt,f as xt,V as Ve,w as Pe}from"./scheduler.Cj2_EUWt.js";import{S as Gn,i as qn}from"./index.BrunZg7c.js";import{bg as $n,bh as pe,aL as Re,aM as Wn,bi as re,bj as jn,bk as Xn,bl as Ie,bm as Yn,a as Qn}from"./state.kJp46Jxq.js";let zt=!0,vn,qt,$t;const Kn=1e3,Jn=150,bn=$n(()=>{zt=!0,vn()},Kn),tr=(t,e)=>{$t==null||$t();const{autoSync:n}=Hn(pe);if(!n)return;vn=e;const r=t>Jn;zt||bn(),zt=!r},er=()=>(qt||(qt=new Promise(t=>{$t=()=>{qt=void 0,t()}})),zt||bn(),zt),zs=()=>qt??Promise.resolve();var nr=function(){var t="",e,n,r,s=[],i={passive:!0};window.addEventListener?(e="addEventListener",n="removeEventListener"):(e="attachEvent",n="detachEvent",t="on"),r="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";function a(f,d){var m=function(g){!g&&(g=window.event);var v={originalEvent:g,target:g.target||g.srcElement,type:"wheel",deltaMode:g.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){g.preventDefault?g.preventDefault():g.returnValue=!1}};return r=="mousewheel"?(v.deltaY=-.025*g.wheelDelta,g.wheelDeltaX&&(v.deltaX=-.025*g.wheelDeltaX)):v.deltaY=g.detail,d(v)};return s.push({element:f,fn:m}),m}function o(f){for(var d=0;d<s.length;d++)if(s[d].element===f)return s[d].fn;return function(){}}function u(f){for(var d=0;d<s.length;d++)if(s[d].element===f)return s.splice(d,1)}function l(f,d,m,g){var v;r==="wheel"?v=m:v=a(f,m),f[e](t+d,v,g?i:!1)}function h(f,d,m,g){var v;r==="wheel"?v=m:v=o(f),f[n](t+d,v,g?i:!1),u(f)}function c(f,d,m){l(f,r,d,m),r=="DOMMouseScroll"&&l(f,"MozMousePixelScroll",d,m)}function p(f,d,m){h(f,r,d,m),r=="DOMMouseScroll"&&h(f,"MozMousePixelScroll",d,m)}return{on:c,off:p}}(),Se={extend:function(t,e){t=t||{};for(var n in e)this.isObject(e[n])?t[n]=this.extend(t[n],e[n]):t[n]=e[n];return t},isElement:function(t){return t instanceof HTMLElement||t instanceof SVGElement||t instanceof SVGSVGElement||t&&typeof t=="object"&&t!==null&&t.nodeType===1&&typeof t.nodeName=="string"},isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},getSvg:function(t){var e,n;if(this.isElement(t))e=t;else if(typeof t=="string"||t instanceof String){if(e=document.querySelector(t),!e)throw new Error("Provided selector did not find any elements. Selector: "+t)}else throw new Error("Provided selector is not an HTML object nor String");if(e.tagName.toLowerCase()==="svg")n=e;else if(e.tagName.toLowerCase()==="object")n=e.contentDocument.documentElement;else if(e.tagName.toLowerCase()==="embed")n=e.getSVGDocument().documentElement;else throw e.tagName.toLowerCase()==="img"?new Error('Cannot script an SVG in an "img" element. Please use an "object" element or an in-line SVG.'):new Error("Cannot get SVG.");return n},proxy:function(t,e){return function(){return t.apply(e,arguments)}},getType:function(t){return Object.prototype.toString.apply(t).replace(/^\[object\s/,"").replace(/\]$/,"")},mouseAndTouchNormalize:function(t,e){if(t.clientX===void 0||t.clientX===null)if(t.clientX=0,t.clientY=0,t.touches!==void 0&&t.touches.length){if(t.touches[0].clientX!==void 0)t.clientX=t.touches[0].clientX,t.clientY=t.touches[0].clientY;else if(t.touches[0].pageX!==void 0){var n=e.getBoundingClientRect();t.clientX=t.touches[0].pageX-n.left,t.clientY=t.touches[0].pageY-n.top}}else t.originalEvent!==void 0&&t.originalEvent.clientX!==void 0&&(t.clientX=t.originalEvent.clientX,t.clientY=t.originalEvent.clientY)},isDblClick:function(t,e){if(t.detail===2)return!0;if(e!=null){var n=t.timeStamp-e.timeStamp,r=Math.sqrt(Math.pow(t.clientX-e.clientX,2)+Math.pow(t.clientY-e.clientY,2));return n<250&&r<10}return!1},now:Date.now||function(){return new Date().getTime()},throttle:function(t,e,n){var r=this,s,i,a,o=null,u=0;n||(n={});var l=function(){u=n.leading===!1?0:r.now(),o=null,a=t.apply(s,i),o||(s=i=null)};return function(){var h=r.now();!u&&n.leading===!1&&(u=h);var c=e-(h-u);return s=this,i=arguments,c<=0||c>e?(clearTimeout(o),o=null,u=h,a=t.apply(s,i),o||(s=i=null)):!o&&n.trailing!==!1&&(o=setTimeout(l,c)),a}},createRequestAnimationFrame:function(t){var e=null;return t!=="auto"&&t<60&&t>1&&(e=Math.floor(1e3/t)),e===null?window.requestAnimationFrame||ze(33):ze(e)}};function ze(t){return function(e){window.setTimeout(e,t)}}var se=Se,yn="unknown";document.documentMode&&(yn="ie");var Ae={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(t){if(t.clientWidth&&t.clientHeight)return{width:t.clientWidth,height:t.clientHeight};if(t.getBoundingClientRect())return t.getBoundingClientRect();throw new Error("Cannot get BoundingClientRect for SVG.")},getOrCreateViewport:function(t,e){var n=null;if(se.isElement(e)?n=e:n=t.querySelector(e),!n){var r=Array.prototype.slice.call(t.childNodes||t.children).filter(function(u){return u.nodeName!=="defs"&&u.nodeName!=="#text"});r.length===1&&r[0].nodeName==="g"&&r[0].getAttribute("transform")===null&&(n=r[0])}if(!n){var s="viewport-"+new Date().toISOString().replace(/\D/g,"");n=document.createElementNS(this.svgNS,"g"),n.setAttribute("id",s);var i=t.childNodes||t.children;if(i&&i.length>0)for(var a=i.length;a>0;a--)i[i.length-a].nodeName!=="defs"&&n.appendChild(i[i.length-a]);t.appendChild(n)}var o=[];return n.getAttribute("class")&&(o=n.getAttribute("class").split(" ")),~o.indexOf("svg-pan-zoom_viewport")||(o.push("svg-pan-zoom_viewport"),n.setAttribute("class",o.join(" "))),n},setupSvgAttributes:function(t){if(t.setAttribute("xmlns",this.svgNS),t.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS),t.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS),t.parentNode!==null){var e=t.getAttribute("style")||"";e.toLowerCase().indexOf("overflow")===-1&&t.setAttribute("style","overflow: hidden; "+e)}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:se.throttle(function(){for(var t=document.querySelectorAll("defs"),e=t.length,n=0;n<e;n++){var r=t[n];r.parentNode.insertBefore(r,r)}},Re?Re.internetExplorerRedisplayInterval:null),setCTM:function(t,e,n){var r=this,s="matrix("+e.a+","+e.b+","+e.c+","+e.d+","+e.e+","+e.f+")";t.setAttributeNS(null,"transform",s),"transform"in t.style?t.style.transform=s:"-ms-transform"in t.style?t.style["-ms-transform"]=s:"-webkit-transform"in t.style&&(t.style["-webkit-transform"]=s),yn==="ie"&&n&&(n.parentNode.insertBefore(n,n),window.setTimeout(function(){r.refreshDefsGlobal()},r.internetExplorerRedisplayInterval))},getEventPoint:function(t,e){var n=e.createSVGPoint();return se.mouseAndTouchNormalize(t,e),n.x=t.clientX,n.y=t.clientY,n},getSvgCenterPoint:function(t,e,n){return this.createSVGPoint(t,e/2,n/2)},createSVGPoint:function(t,e,n){var r=t.createSVGPoint();return r.x=e,r.y=n,r}},j=Ae,rr={enable:function(t){var e=t.svg.querySelector("defs");e||(e=document.createElementNS(j.svgNS,"defs"),t.svg.appendChild(e));var n=e.querySelector("style#svg-pan-zoom-controls-styles");if(!n){var r=document.createElementNS(j.svgNS,"style");r.setAttribute("id","svg-pan-zoom-controls-styles"),r.setAttribute("type","text/css"),r.textContent=".svg-pan-zoom-control { cursor: pointer; fill: black; fill-opacity: 0.333; } .svg-pan-zoom-control:hover { fill-opacity: 0.8; } .svg-pan-zoom-control-background { fill: white; fill-opacity: 0.5; } .svg-pan-zoom-control-background { fill-opacity: 0.8; }",e.appendChild(r)}var s=document.createElementNS(j.svgNS,"g");s.setAttribute("id","svg-pan-zoom-controls"),s.setAttribute("transform","translate("+(t.width-70)+" "+(t.height-76)+") scale(0.75)"),s.setAttribute("class","svg-pan-zoom-control"),s.appendChild(this._createZoomIn(t)),s.appendChild(this._createZoomReset(t)),s.appendChild(this._createZoomOut(t)),t.svg.appendChild(s),t.controlIcons=s},_createZoomIn:function(t){var e=document.createElementNS(j.svgNS,"g");e.setAttribute("id","svg-pan-zoom-zoom-in"),e.setAttribute("transform","translate(30.5 5) scale(0.015)"),e.setAttribute("class","svg-pan-zoom-control"),e.addEventListener("click",function(){t.getPublicInstance().zoomIn()},!1),e.addEventListener("touchstart",function(){t.getPublicInstance().zoomIn()},!1);var n=document.createElementNS(j.svgNS,"rect");n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("width","1500"),n.setAttribute("height","1400"),n.setAttribute("class","svg-pan-zoom-control-background"),e.appendChild(n);var r=document.createElementNS(j.svgNS,"path");return r.setAttribute("d","M1280 576v128q0 26 -19 45t-45 19h-320v320q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-320h-320q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h320v-320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v320h320q26 0 45 19t19 45zM1536 1120v-960 q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5t84.5 -203.5z"),r.setAttribute("class","svg-pan-zoom-control-element"),e.appendChild(r),e},_createZoomReset:function(t){var e=document.createElementNS(j.svgNS,"g");e.setAttribute("id","svg-pan-zoom-reset-pan-zoom"),e.setAttribute("transform","translate(5 35) scale(0.4)"),e.setAttribute("class","svg-pan-zoom-control"),e.addEventListener("click",function(){t.getPublicInstance().reset()},!1),e.addEventListener("touchstart",function(){t.getPublicInstance().reset()},!1);var n=document.createElementNS(j.svgNS,"rect");n.setAttribute("x","2"),n.setAttribute("y","2"),n.setAttribute("width","182"),n.setAttribute("height","58"),n.setAttribute("class","svg-pan-zoom-control-background"),e.appendChild(n);var r=document.createElementNS(j.svgNS,"path");r.setAttribute("d","M33.051,20.632c-0.742-0.406-1.854-0.609-3.338-0.609h-7.969v9.281h7.769c1.543,0,2.701-0.188,3.473-0.562c1.365-0.656,2.048-1.953,2.048-3.891C35.032,22.757,34.372,21.351,33.051,20.632z"),r.setAttribute("class","svg-pan-zoom-control-element"),e.appendChild(r);var s=document.createElementNS(j.svgNS,"path");return s.setAttribute("d","M170.231,0.5H15.847C7.102,0.5,0.5,5.708,0.5,11.84v38.861C0.5,56.833,7.102,61.5,15.847,61.5h154.384c8.745,0,15.269-4.667,15.269-10.798V11.84C185.5,5.708,178.976,0.5,170.231,0.5z M42.837,48.569h-7.969c-0.219-0.766-0.375-1.383-0.469-1.852c-0.188-0.969-0.289-1.961-0.305-2.977l-0.047-3.211c-0.03-2.203-0.41-3.672-1.142-4.406c-0.732-0.734-2.103-1.102-4.113-1.102h-7.05v13.547h-7.055V14.022h16.524c2.361,0.047,4.178,0.344,5.45,0.891c1.272,0.547,2.351,1.352,3.234,2.414c0.731,0.875,1.31,1.844,1.737,2.906s0.64,2.273,0.64,3.633c0,1.641-0.414,3.254-1.242,4.84s-2.195,2.707-4.102,3.363c1.594,0.641,2.723,1.551,3.387,2.73s0.996,2.98,0.996,5.402v2.32c0,1.578,0.063,2.648,0.19,3.211c0.19,0.891,0.635,1.547,1.333,1.969V48.569z M75.579,48.569h-26.18V14.022h25.336v6.117H56.454v7.336h16.781v6H56.454v8.883h19.125V48.569z M104.497,46.331c-2.44,2.086-5.887,3.129-10.34,3.129c-4.548,0-8.125-1.027-10.731-3.082s-3.909-4.879-3.909-8.473h6.891c0.224,1.578,0.662,2.758,1.316,3.539c1.196,1.422,3.246,2.133,6.15,2.133c1.739,0,3.151-0.188,4.236-0.562c2.058-0.719,3.087-2.055,3.087-4.008c0-1.141-0.504-2.023-1.512-2.648c-1.008-0.609-2.607-1.148-4.796-1.617l-3.74-0.82c-3.676-0.812-6.201-1.695-7.576-2.648c-2.328-1.594-3.492-4.086-3.492-7.477c0-3.094,1.139-5.664,3.417-7.711s5.623-3.07,10.036-3.07c3.685,0,6.829,0.965,9.431,2.895c2.602,1.93,3.966,4.73,4.093,8.402h-6.938c-0.128-2.078-1.057-3.555-2.787-4.43c-1.154-0.578-2.587-0.867-4.301-0.867c-1.907,0-3.428,0.375-4.565,1.125c-1.138,0.75-1.706,1.797-1.706,3.141c0,1.234,0.561,2.156,1.682,2.766c0.721,0.406,2.25,0.883,4.589,1.43l6.063,1.43c2.657,0.625,4.648,1.461,5.975,2.508c2.059,1.625,3.089,3.977,3.089,7.055C108.157,41.624,106.937,44.245,104.497,46.331z M139.61,48.569h-26.18V14.022h25.336v6.117h-18.281v7.336h16.781v6h-16.781v8.883h19.125V48.569z M170.337,20.14h-10.336v28.43h-7.266V20.14h-10.383v-6.117h27.984V20.14z"),s.setAttribute("class","svg-pan-zoom-control-element"),e.appendChild(s),e},_createZoomOut:function(t){var e=document.createElementNS(j.svgNS,"g");e.setAttribute("id","svg-pan-zoom-zoom-out"),e.setAttribute("transform","translate(30.5 70) scale(0.015)"),e.setAttribute("class","svg-pan-zoom-control"),e.addEventListener("click",function(){t.getPublicInstance().zoomOut()},!1),e.addEventListener("touchstart",function(){t.getPublicInstance().zoomOut()},!1);var n=document.createElementNS(j.svgNS,"rect");n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("width","1500"),n.setAttribute("height","1400"),n.setAttribute("class","svg-pan-zoom-control-background"),e.appendChild(n);var r=document.createElementNS(j.svgNS,"path");return r.setAttribute("d","M1280 576v128q0 26 -19 45t-45 19h-896q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h896q26 0 45 19t19 45zM1536 1120v-960q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5 t84.5 -203.5z"),r.setAttribute("class","svg-pan-zoom-control-element"),e.appendChild(r),e},disable:function(t){t.controlIcons&&(t.controlIcons.parentNode.removeChild(t.controlIcons),t.controlIcons=null)}},sr=Ae,mt=Se,F=function(t,e){this.init(t,e)};F.prototype.init=function(t,e){this.viewport=t,this.options=e,this.originalState={zoom:1,x:0,y:0},this.activeState={zoom:1,x:0,y:0},this.updateCTMCached=mt.proxy(this.updateCTM,this),this.requestAnimationFrame=mt.createRequestAnimationFrame(this.options.refreshRate),this.viewBox={x:0,y:0,width:0,height:0},this.cacheViewBox();var n=this.processCTM();this.setCTM(n),this.updateCTM()};F.prototype.cacheViewBox=function(){var t=this.options.svg.getAttribute("viewBox");if(t){var e=t.split(/[\s\,]/).filter(function(r){return r}).map(parseFloat);this.viewBox.x=e[0],this.viewBox.y=e[1],this.viewBox.width=e[2],this.viewBox.height=e[3];var n=Math.min(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height);this.activeState.zoom=n,this.activeState.x=(this.options.width-this.viewBox.width*n)/2,this.activeState.y=(this.options.height-this.viewBox.height*n)/2,this.updateCTMOnNextFrame(),this.options.svg.removeAttribute("viewBox")}else this.simpleViewBoxCache()};F.prototype.simpleViewBoxCache=function(){var t=this.viewport.getBBox();this.viewBox.x=t.x,this.viewBox.y=t.y,this.viewBox.width=t.width,this.viewBox.height=t.height};F.prototype.getViewBox=function(){return mt.extend({},this.viewBox)};F.prototype.processCTM=function(){var t=this.getCTM();if(this.options.fit||this.options.contain){var e;this.options.fit?e=Math.min(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height):e=Math.max(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height),t.a=e,t.d=e,t.e=-this.viewBox.x*e,t.f=-this.viewBox.y*e}if(this.options.center){var n=(this.options.width-(this.viewBox.width+this.viewBox.x*2)*t.a)*.5,r=(this.options.height-(this.viewBox.height+this.viewBox.y*2)*t.a)*.5;t.e=n,t.f=r}return this.originalState.zoom=t.a,this.originalState.x=t.e,this.originalState.y=t.f,t};F.prototype.getOriginalState=function(){return mt.extend({},this.originalState)};F.prototype.getState=function(){return mt.extend({},this.activeState)};F.prototype.getZoom=function(){return this.activeState.zoom};F.prototype.getRelativeZoom=function(){return this.activeState.zoom/this.originalState.zoom};F.prototype.computeRelativeZoom=function(t){return t/this.originalState.zoom};F.prototype.getPan=function(){return{x:this.activeState.x,y:this.activeState.y}};F.prototype.getCTM=function(){var t=this.options.svg.createSVGMatrix();return t.a=this.activeState.zoom,t.b=0,t.c=0,t.d=this.activeState.zoom,t.e=this.activeState.x,t.f=this.activeState.y,t};F.prototype.setCTM=function(t){var e=this.isZoomDifferent(t),n=this.isPanDifferent(t);if(e||n){if(e&&(this.options.beforeZoom(this.getRelativeZoom(),this.computeRelativeZoom(t.a))===!1?(t.a=t.d=this.activeState.zoom,e=!1):(this.updateCache(t),this.options.onZoom(this.getRelativeZoom()))),n){var r=this.options.beforePan(this.getPan(),{x:t.e,y:t.f}),s=!1,i=!1;r===!1?(t.e=this.getPan().x,t.f=this.getPan().y,s=i=!0):mt.isObject(r)&&(r.x===!1?(t.e=this.getPan().x,s=!0):mt.isNumber(r.x)&&(t.e=r.x),r.y===!1?(t.f=this.getPan().y,i=!0):mt.isNumber(r.y)&&(t.f=r.y)),s&&i||!this.isPanDifferent(t)?n=!1:(this.updateCache(t),this.options.onPan(this.getPan()))}(e||n)&&this.updateCTMOnNextFrame()}};F.prototype.isZoomDifferent=function(t){return this.activeState.zoom!==t.a};F.prototype.isPanDifferent=function(t){return this.activeState.x!==t.e||this.activeState.y!==t.f};F.prototype.updateCache=function(t){this.activeState.zoom=t.a,this.activeState.x=t.e,this.activeState.y=t.f};F.prototype.pendingUpdate=!1;F.prototype.updateCTMOnNextFrame=function(){this.pendingUpdate||(this.pendingUpdate=!0,this.requestAnimationFrame.call(window,this.updateCTMCached))};F.prototype.updateCTM=function(){var t=this.getCTM();sr.setCTM(this.viewport,t,this.defs),this.pendingUpdate=!1,this.options.onUpdatedCTM&&this.options.onUpdatedCTM(t)};var ir=function(t,e){return new F(t,e)},xn=nr,de=rr,nt=Se,ot=Ae,or=ir,P=function(t,e){this.init(t,e)},ar={viewportSelector:".svg-pan-zoom_viewport",panEnabled:!0,controlIconsEnabled:!1,zoomEnabled:!0,dblClickZoomEnabled:!0,mouseWheelZoomEnabled:!0,preventMouseEventsDefault:!0,zoomScaleSensitivity:.1,minZoom:.5,maxZoom:10,fit:!0,contain:!1,center:!0,refreshRate:"auto",beforeZoom:null,onZoom:null,beforePan:null,onPan:null,customEventsHandler:null,eventsListenerElement:null,onUpdatedCTM:null},wn={passive:!0};P.prototype.init=function(t,e){var n=this;this.svg=t,this.defs=t.querySelector("defs"),ot.setupSvgAttributes(this.svg),this.options=nt.extend(nt.extend({},ar),e),this.state="none";var r=ot.getBoundingClientRectNormalized(t);this.width=r.width,this.height=r.height,this.viewport=or(ot.getOrCreateViewport(this.svg,this.options.viewportSelector),{svg:this.svg,width:this.width,height:this.height,fit:this.options.fit,contain:this.options.contain,center:this.options.center,refreshRate:this.options.refreshRate,beforeZoom:function(i,a){if(n.viewport&&n.options.beforeZoom)return n.options.beforeZoom(i,a)},onZoom:function(i){if(n.viewport&&n.options.onZoom)return n.options.onZoom(i)},beforePan:function(i,a){if(n.viewport&&n.options.beforePan)return n.options.beforePan(i,a)},onPan:function(i){if(n.viewport&&n.options.onPan)return n.options.onPan(i)},onUpdatedCTM:function(i){if(n.viewport&&n.options.onUpdatedCTM)return n.options.onUpdatedCTM(i)}});var s=this.getPublicInstance();s.setBeforeZoom(this.options.beforeZoom),s.setOnZoom(this.options.onZoom),s.setBeforePan(this.options.beforePan),s.setOnPan(this.options.onPan),s.setOnUpdatedCTM(this.options.onUpdatedCTM),this.options.controlIconsEnabled&&de.enable(this),this.lastMouseWheelEventTime=Date.now(),this.setupHandlers()};P.prototype.setupHandlers=function(){var t=this,e=null;if(this.eventListeners={mousedown:function(i){var a=t.handleMouseDown(i,e);return e=i,a},touchstart:function(i){var a=t.handleMouseDown(i,e);return e=i,a},mouseup:function(i){return t.handleMouseUp(i)},touchend:function(i){return t.handleMouseUp(i)},mousemove:function(i){return t.handleMouseMove(i)},touchmove:function(i){return t.handleMouseMove(i)},mouseleave:function(i){return t.handleMouseUp(i)},touchleave:function(i){return t.handleMouseUp(i)},touchcancel:function(i){return t.handleMouseUp(i)}},this.options.customEventsHandler!=null){this.options.customEventsHandler.init({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});var n=this.options.customEventsHandler.haltEventListeners;if(n&&n.length)for(var r=n.length-1;r>=0;r--)this.eventListeners.hasOwnProperty(n[r])&&delete this.eventListeners[n[r]]}for(var s in this.eventListeners)(this.options.eventsListenerElement||this.svg).addEventListener(s,this.eventListeners[s],this.options.preventMouseEventsDefault?!1:wn);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())};P.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var t=this;this.wheelListener=function(n){return t.handleMouseWheel(n)};var e=!this.options.preventMouseEventsDefault;xn.on(this.options.eventsListenerElement||this.svg,this.wheelListener,e),this.options.mouseWheelZoomEnabled=!0}};P.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var t=!this.options.preventMouseEventsDefault;xn.off(this.options.eventsListenerElement||this.svg,this.wheelListener,t),this.options.mouseWheelZoomEnabled=!1}};P.prototype.handleMouseWheel=function(t){if(!(!this.options.zoomEnabled||this.state!=="none")){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1);var e=t.deltaY||1,n=Date.now()-this.lastMouseWheelEventTime,r=3+Math.max(0,30-n);this.lastMouseWheelEventTime=Date.now(),"deltaMode"in t&&t.deltaMode===0&&t.wheelDelta&&(e=t.deltaY===0?0:Math.abs(t.wheelDelta)/t.deltaY),e=-.3<e&&e<.3?e:(e>0?1:-1)*Math.log(Math.abs(e)+10)/r;var s=this.svg.getScreenCTM().inverse(),i=ot.getEventPoint(t,this.svg).matrixTransform(s),a=Math.pow(1+this.options.zoomScaleSensitivity,-1*e);this.zoomAtPoint(a,i)}};P.prototype.zoomAtPoint=function(t,e,n){var r=this.viewport.getOriginalState();n?(t=Math.max(this.options.minZoom*r.zoom,Math.min(this.options.maxZoom*r.zoom,t)),t=t/this.getZoom()):this.getZoom()*t<this.options.minZoom*r.zoom?t=this.options.minZoom*r.zoom/this.getZoom():this.getZoom()*t>this.options.maxZoom*r.zoom&&(t=this.options.maxZoom*r.zoom/this.getZoom());var s=this.viewport.getCTM(),i=e.matrixTransform(s.inverse()),a=this.svg.createSVGMatrix().translate(i.x,i.y).scale(t).translate(-i.x,-i.y),o=s.multiply(a);o.a!==s.a&&this.viewport.setCTM(o)};P.prototype.zoom=function(t,e){this.zoomAtPoint(t,ot.getSvgCenterPoint(this.svg,this.width,this.height),e)};P.prototype.publicZoom=function(t,e){e&&(t=this.computeFromRelativeZoom(t)),this.zoom(t,e)};P.prototype.publicZoomAtPoint=function(t,e,n){if(n&&(t=this.computeFromRelativeZoom(t)),nt.getType(e)!=="SVGPoint")if("x"in e&&"y"in e)e=ot.createSVGPoint(this.svg,e.x,e.y);else throw new Error("Given point is invalid");this.zoomAtPoint(t,e,n)};P.prototype.getZoom=function(){return this.viewport.getZoom()};P.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()};P.prototype.computeFromRelativeZoom=function(t){return t*this.viewport.getOriginalState().zoom};P.prototype.resetZoom=function(){var t=this.viewport.getOriginalState();this.zoom(t.zoom,!0)};P.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())};P.prototype.reset=function(){this.resetZoom(),this.resetPan()};P.prototype.handleDblClick=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.options.controlIconsEnabled){var e=t.target.getAttribute("class")||"";if(e.indexOf("svg-pan-zoom-control")>-1)return!1}var n;t.shiftKey?n=1/((1+this.options.zoomScaleSensitivity)*2):n=(1+this.options.zoomScaleSensitivity)*2;var r=ot.getEventPoint(t,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(n,r)};P.prototype.handleMouseDown=function(t,e){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),nt.mouseAndTouchNormalize(t,this.svg),this.options.dblClickZoomEnabled&&nt.isDblClick(t,e)?this.handleDblClick(t):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=ot.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()))};P.prototype.handleMouseMove=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var e=ot.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()),n=this.firstEventCTM.translate(e.x-this.stateOrigin.x,e.y-this.stateOrigin.y);this.viewport.setCTM(n)}};P.prototype.handleMouseUp=function(t){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&(this.state="none")};P.prototype.fit=function(){var t=this.viewport.getViewBox(),e=Math.min(this.width/t.width,this.height/t.height);this.zoom(e,!0)};P.prototype.contain=function(){var t=this.viewport.getViewBox(),e=Math.max(this.width/t.width,this.height/t.height);this.zoom(e,!0)};P.prototype.center=function(){var t=this.viewport.getViewBox(),e=(this.width-(t.width+t.x*2)*this.getZoom())*.5,n=(this.height-(t.height+t.y*2)*this.getZoom())*.5;this.getPublicInstance().pan({x:e,y:n})};P.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()};P.prototype.pan=function(t){var e=this.viewport.getCTM();e.e=t.x,e.f=t.y,this.viewport.setCTM(e)};P.prototype.panBy=function(t){var e=this.viewport.getCTM();e.e+=t.x,e.f+=t.y,this.viewport.setCTM(e)};P.prototype.getPan=function(){var t=this.viewport.getState();return{x:t.x,y:t.y}};P.prototype.resize=function(){var t=ot.getBoundingClientRectNormalized(this.svg);this.width=t.width,this.height=t.height;var e=this.viewport;e.options.width=this.width,e.options.height=this.height,e.processCTM(),this.options.controlIconsEnabled&&(this.getPublicInstance().disableControlIcons(),this.getPublicInstance().enableControlIcons())};P.prototype.destroy=function(){var t=this;this.beforeZoom=null,this.onZoom=null,this.beforePan=null,this.onPan=null,this.onUpdatedCTM=null,this.options.customEventsHandler!=null&&this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});for(var e in this.eventListeners)(this.options.eventsListenerElement||this.svg).removeEventListener(e,this.eventListeners[e],this.options.preventMouseEventsDefault?!1:wn);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),ht=ht.filter(function(n){return n.svg!==t.svg}),delete this.options,delete this.viewport,delete this.publicInstance,delete this.pi,this.getPublicInstance=function(){return null}};P.prototype.getPublicInstance=function(){var t=this;return this.publicInstance||(this.publicInstance=this.pi={enablePan:function(){return t.options.panEnabled=!0,t.pi},disablePan:function(){return t.options.panEnabled=!1,t.pi},isPanEnabled:function(){return!!t.options.panEnabled},pan:function(e){return t.pan(e),t.pi},panBy:function(e){return t.panBy(e),t.pi},getPan:function(){return t.getPan()},setBeforePan:function(e){return t.options.beforePan=e===null?null:nt.proxy(e,t.publicInstance),t.pi},setOnPan:function(e){return t.options.onPan=e===null?null:nt.proxy(e,t.publicInstance),t.pi},enableZoom:function(){return t.options.zoomEnabled=!0,t.pi},disableZoom:function(){return t.options.zoomEnabled=!1,t.pi},isZoomEnabled:function(){return!!t.options.zoomEnabled},enableControlIcons:function(){return t.options.controlIconsEnabled||(t.options.controlIconsEnabled=!0,de.enable(t)),t.pi},disableControlIcons:function(){return t.options.controlIconsEnabled&&(t.options.controlIconsEnabled=!1,de.disable(t)),t.pi},isControlIconsEnabled:function(){return!!t.options.controlIconsEnabled},enableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!0,t.pi},disableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!1,t.pi},isDblClickZoomEnabled:function(){return!!t.options.dblClickZoomEnabled},enableMouseWheelZoom:function(){return t.enableMouseWheelZoom(),t.pi},disableMouseWheelZoom:function(){return t.disableMouseWheelZoom(),t.pi},isMouseWheelZoomEnabled:function(){return!!t.options.mouseWheelZoomEnabled},setZoomScaleSensitivity:function(e){return t.options.zoomScaleSensitivity=e,t.pi},setMinZoom:function(e){return t.options.minZoom=e,t.pi},setMaxZoom:function(e){return t.options.maxZoom=e,t.pi},setBeforeZoom:function(e){return t.options.beforeZoom=e===null?null:nt.proxy(e,t.publicInstance),t.pi},setOnZoom:function(e){return t.options.onZoom=e===null?null:nt.proxy(e,t.publicInstance),t.pi},zoom:function(e){return t.publicZoom(e,!0),t.pi},zoomBy:function(e){return t.publicZoom(e,!1),t.pi},zoomAtPoint:function(e,n){return t.publicZoomAtPoint(e,n,!0),t.pi},zoomAtPointBy:function(e,n){return t.publicZoomAtPoint(e,n,!1),t.pi},zoomIn:function(){return this.zoomBy(1+t.options.zoomScaleSensitivity),t.pi},zoomOut:function(){return this.zoomBy(1/(1+t.options.zoomScaleSensitivity)),t.pi},getZoom:function(){return t.getRelativeZoom()},setOnUpdatedCTM:function(e){return t.options.onUpdatedCTM=e===null?null:nt.proxy(e,t.publicInstance),t.pi},resetZoom:function(){return t.resetZoom(),t.pi},resetPan:function(){return t.resetPan(),t.pi},reset:function(){return t.reset(),t.pi},fit:function(){return t.fit(),t.pi},contain:function(){return t.contain(),t.pi},center:function(){return t.center(),t.pi},updateBBox:function(){return t.updateBBox(),t.pi},resize:function(){return t.resize(),t.pi},getSizes:function(){return{width:t.width,height:t.height,realZoom:t.getZoom(),viewBox:t.viewport.getViewBox()}},destroy:function(){return t.destroy(),t.pi}}),this.publicInstance};var ht=[],lr=function(t,e){var n=nt.getSvg(t);if(n===null)return null;for(var r=ht.length-1;r>=0;r--)if(ht[r].svg===n)return ht[r].instance.getPublicInstance();return ht.push({svg:n,instance:new P(n,e)}),ht[ht.length-1].instance.getPublicInstance()},ur=lr;const hr=Wn(ur);function me(t,e,n){if(t&&t.length){const[r,s]=e,i=Math.PI/180*n,a=Math.cos(i),o=Math.sin(i);for(const u of t){const[l,h]=u;u[0]=(l-r)*a-(h-s)*o+r,u[1]=(l-r)*o+(h-s)*a+s}}}function cr(t,e,n){const r=[];t.forEach(s=>r.push(...s)),me(r,e,n)}function fr(t,e){return t[0]===e[0]&&t[1]===e[1]}function pr(t,e,n,r=1){const s=n,i=Math.max(e,.1),a=t[0]&&t[0][0]&&typeof t[0][0]=="number"?[t]:t,o=[0,0];if(s)for(const l of a)me(l,o,s);const u=dr(a,i,r);if(s){for(const l of a)me(l,o,-s);cr(u,o,-s)}return u}function dr(t,e,n){const r=[];for(const l of t){const h=[...l];fr(h[0],h[h.length-1])||h.push([h[0][0],h[0][1]]),h.length>2&&r.push(h)}const s=[];e=Math.max(e,.1);const i=[];for(const l of r)for(let h=0;h<l.length-1;h++){const c=l[h],p=l[h+1];if(c[1]!==p[1]){const f=Math.min(c[1],p[1]);i.push({ymin:f,ymax:Math.max(c[1],p[1]),x:f===c[1]?c[0]:p[0],islope:(p[0]-c[0])/(p[1]-c[1])})}}if(i.sort((l,h)=>l.ymin<h.ymin?-1:l.ymin>h.ymin?1:l.x<h.x?-1:l.x>h.x?1:l.ymax===h.ymax?0:(l.ymax-h.ymax)/Math.abs(l.ymax-h.ymax)),!i.length)return s;let a=[],o=i[0].ymin,u=0;for(;a.length||i.length;){if(i.length){let l=-1;for(let c=0;c<i.length&&!(i[c].ymin>o);c++)l=c;i.splice(0,l+1).forEach(c=>{a.push({s:o,edge:c})})}if(a=a.filter(l=>!(l.edge.ymax<=o)),a.sort((l,h)=>l.edge.x===h.edge.x?0:(l.edge.x-h.edge.x)/Math.abs(l.edge.x-h.edge.x)),(n!==1||u%e===0)&&a.length>1)for(let l=0;l<a.length;l=l+2){const h=l+1;if(h>=a.length)break;const c=a[l].edge,p=a[h].edge;s.push([[Math.round(c.x),o],[Math.round(p.x),o]])}o+=n,a.forEach(l=>{l.edge.x=l.edge.x+n*l.edge.islope}),u++}return s}function Zt(t,e){var n;const r=e.hachureAngle+90;let s=e.hachureGap;s<0&&(s=e.strokeWidth*4),s=Math.round(Math.max(s,.1));let i=1;return e.roughness>=1&&(((n=e.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(i=s),pr(t,s,r,i||1)}class Ee{constructor(e){this.helper=e}fillPolygons(e,n){return this._fillPolygons(e,n)}_fillPolygons(e,n){const r=Zt(e,n);return{type:"fillSketch",ops:this.renderLines(r,n)}}renderLines(e,n){const r=[];for(const s of e)r.push(...this.helper.doubleLineOps(s[0][0],s[0][1],s[1][0],s[1][1],n));return r}}function ee(t){const e=t[0],n=t[1];return Math.sqrt(Math.pow(e[0]-n[0],2)+Math.pow(e[1]-n[1],2))}class mr extends Ee{fillPolygons(e,n){let r=n.hachureGap;r<0&&(r=n.strokeWidth*4),r=Math.max(r,.1);const s=Object.assign({},n,{hachureGap:r}),i=Zt(e,s),a=Math.PI/180*n.hachureAngle,o=[],u=r*.5*Math.cos(a),l=r*.5*Math.sin(a);for(const[c,p]of i)ee([c,p])&&o.push([[c[0]-u,c[1]+l],[...p]],[[c[0]+u,c[1]-l],[...p]]);return{type:"fillSketch",ops:this.renderLines(o,n)}}}class gr extends Ee{fillPolygons(e,n){const r=this._fillPolygons(e,n),s=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),i=this._fillPolygons(e,s);return r.ops=r.ops.concat(i.ops),r}}class vr{constructor(e){this.helper=e}fillPolygons(e,n){n=Object.assign({},n,{hachureAngle:0});const r=Zt(e,n);return this.dotsOnLines(r,n)}dotsOnLines(e,n){const r=[];let s=n.hachureGap;s<0&&(s=n.strokeWidth*4),s=Math.max(s,.1);let i=n.fillWeight;i<0&&(i=n.strokeWidth/2);const a=s/4;for(const o of e){const u=ee(o),l=u/s,h=Math.ceil(l)-1,c=u-h*s,p=(o[0][0]+o[1][0])/2-s/4,f=Math.min(o[0][1],o[1][1]);for(let d=0;d<h;d++){const m=f+c+d*s,g=p-a+Math.random()*2*a,v=m-a+Math.random()*2*a,y=this.helper.ellipse(g,v,i,i,n);r.push(...y.ops)}}return{type:"fillSketch",ops:r}}}class br{constructor(e){this.helper=e}fillPolygons(e,n){const r=Zt(e,n);return{type:"fillSketch",ops:this.dashedLine(r,n)}}dashedLine(e,n){const r=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset,s=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap,i=[];return e.forEach(a=>{const o=ee(a),u=Math.floor(o/(r+s)),l=(o+s-u*(r+s))/2;let h=a[0],c=a[1];h[0]>c[0]&&(h=a[1],c=a[0]);const p=Math.atan((c[1]-h[1])/(c[0]-h[0]));for(let f=0;f<u;f++){const d=f*(r+s),m=d+r,g=[h[0]+d*Math.cos(p)+l*Math.cos(p),h[1]+d*Math.sin(p)+l*Math.sin(p)],v=[h[0]+m*Math.cos(p)+l*Math.cos(p),h[1]+m*Math.sin(p)+l*Math.sin(p)];i.push(...this.helper.doubleLineOps(g[0],g[1],v[0],v[1],n))}}),i}}class yr{constructor(e){this.helper=e}fillPolygons(e,n){const r=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,s=n.zigzagOffset<0?r:n.zigzagOffset;n=Object.assign({},n,{hachureGap:r+s});const i=Zt(e,n);return{type:"fillSketch",ops:this.zigzagLines(i,s,n)}}zigzagLines(e,n,r){const s=[];return e.forEach(i=>{const a=ee(i),o=Math.round(a/(2*n));let u=i[0],l=i[1];u[0]>l[0]&&(u=i[1],l=i[0]);const h=Math.atan((l[1]-u[1])/(l[0]-u[0]));for(let c=0;c<o;c++){const p=c*2*n,f=(c+1)*2*n,d=Math.sqrt(2*Math.pow(n,2)),m=[u[0]+p*Math.cos(h),u[1]+p*Math.sin(h)],g=[u[0]+f*Math.cos(h),u[1]+f*Math.sin(h)],v=[m[0]+d*Math.cos(h+Math.PI/4),m[1]+d*Math.sin(h+Math.PI/4)];s.push(...this.helper.doubleLineOps(m[0],m[1],v[0],v[1],r),...this.helper.doubleLineOps(v[0],v[1],g[0],g[1],r))}}),s}}const $={};function xr(t,e){let n=t.fillStyle||"hachure";if(!$[n])switch(n){case"zigzag":$[n]||($[n]=new mr(e));break;case"cross-hatch":$[n]||($[n]=new gr(e));break;case"dots":$[n]||($[n]=new vr(e));break;case"dashed":$[n]||($[n]=new br(e));break;case"zigzag-line":$[n]||($[n]=new yr(e));break;case"hachure":default:n="hachure",$[n]||($[n]=new Ee(e));break}return $[n]}function wr(){return Math.floor(Math.random()*2**31)}class Mn{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}}const Mr=0,ge=1,Sn=2,Ft={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Sr(t){const e=new Array;for(;t!=="";)if(t.match(/^([ \t\r\n,]+)/))t=t.substr(RegExp.$1.length);else if(t.match(/^([aAcChHlLmMqQsStTvVzZ])/))e[e.length]={type:Mr,text:RegExp.$1},t=t.substr(RegExp.$1.length);else if(t.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))e[e.length]={type:ge,text:`${parseFloat(RegExp.$1)}`},t=t.substr(RegExp.$1.length);else return[];return e[e.length]={type:Sn,text:""},e}function ie(t,e){return t.type===e}function _e(t){const e=[],n=Sr(t);let r="BOD",s=0,i=n[s];for(;!ie(i,Sn);){let a=0;const o=[];if(r==="BOD")if(i.text==="M"||i.text==="m")s++,a=Ft[i.text],r=i.text;else return _e("M0,0"+t);else ie(i,ge)?a=Ft[r]:(s++,a=Ft[i.text],r=i.text);if(s+a<n.length){for(let u=s;u<s+a;u++){const l=n[u];if(ie(l,ge))o[o.length]=+l.text;else throw new Error("Param not a number: "+r+","+l.text)}if(typeof Ft[r]=="number"){const u={key:r,data:o};e.push(u),s+=a,i=n[s],r==="M"&&(r="L"),r==="m"&&(r="l")}else throw new Error("Bad segment: "+r)}else throw new Error("Path data ended short")}return e}function An(t){let e=0,n=0,r=0,s=0;const i=[];for(const{key:a,data:o}of t)switch(a){case"M":i.push({key:"M",data:[...o]}),[e,n]=o,[r,s]=o;break;case"m":e+=o[0],n+=o[1],i.push({key:"M",data:[e,n]}),r=e,s=n;break;case"L":i.push({key:"L",data:[...o]}),[e,n]=o;break;case"l":e+=o[0],n+=o[1],i.push({key:"L",data:[e,n]});break;case"C":i.push({key:"C",data:[...o]}),e=o[4],n=o[5];break;case"c":{const u=o.map((l,h)=>h%2?l+n:l+e);i.push({key:"C",data:u}),e=u[4],n=u[5];break}case"Q":i.push({key:"Q",data:[...o]}),e=o[2],n=o[3];break;case"q":{const u=o.map((l,h)=>h%2?l+n:l+e);i.push({key:"Q",data:u}),e=u[2],n=u[3];break}case"A":i.push({key:"A",data:[...o]}),e=o[5],n=o[6];break;case"a":e+=o[5],n+=o[6],i.push({key:"A",data:[o[0],o[1],o[2],o[3],o[4],e,n]});break;case"H":i.push({key:"H",data:[...o]}),e=o[0];break;case"h":e+=o[0],i.push({key:"H",data:[e]});break;case"V":i.push({key:"V",data:[...o]}),n=o[0];break;case"v":n+=o[0],i.push({key:"V",data:[n]});break;case"S":i.push({key:"S",data:[...o]}),e=o[2],n=o[3];break;case"s":{const u=o.map((l,h)=>h%2?l+n:l+e);i.push({key:"S",data:u}),e=u[2],n=u[3];break}case"T":i.push({key:"T",data:[...o]}),e=o[0],n=o[1];break;case"t":e+=o[0],n+=o[1],i.push({key:"T",data:[e,n]});break;case"Z":case"z":i.push({key:"Z",data:[]}),e=r,n=s;break}return i}function En(t){const e=[];let n="",r=0,s=0,i=0,a=0,o=0,u=0;for(const{key:l,data:h}of t){switch(l){case"M":e.push({key:"M",data:[...h]}),[r,s]=h,[i,a]=h;break;case"C":e.push({key:"C",data:[...h]}),r=h[4],s=h[5],o=h[2],u=h[3];break;case"L":e.push({key:"L",data:[...h]}),[r,s]=h;break;case"H":r=h[0],e.push({key:"L",data:[r,s]});break;case"V":s=h[0],e.push({key:"L",data:[r,s]});break;case"S":{let c=0,p=0;n==="C"||n==="S"?(c=r+(r-o),p=s+(s-u)):(c=r,p=s),e.push({key:"C",data:[c,p,...h]}),o=h[0],u=h[1],r=h[2],s=h[3];break}case"T":{const[c,p]=h;let f=0,d=0;n==="Q"||n==="T"?(f=r+(r-o),d=s+(s-u)):(f=r,d=s);const m=r+2*(f-r)/3,g=s+2*(d-s)/3,v=c+2*(f-c)/3,y=p+2*(d-p)/3;e.push({key:"C",data:[m,g,v,y,c,p]}),o=f,u=d,r=c,s=p;break}case"Q":{const[c,p,f,d]=h,m=r+2*(c-r)/3,g=s+2*(p-s)/3,v=f+2*(c-f)/3,y=d+2*(p-d)/3;e.push({key:"C",data:[m,g,v,y,f,d]}),o=c,u=p,r=f,s=d;break}case"A":{const c=Math.abs(h[0]),p=Math.abs(h[1]),f=h[2],d=h[3],m=h[4],g=h[5],v=h[6];c===0||p===0?(e.push({key:"C",data:[r,s,g,v,g,v]}),r=g,s=v):(r!==g||s!==v)&&(_n(r,s,g,v,c,p,f,d,m).forEach(function(C){e.push({key:"C",data:C})}),r=g,s=v);break}case"Z":e.push({key:"Z",data:[]}),r=i,s=a;break}n=l}return e}function Ar(t){return Math.PI*t/180}function kt(t,e,n){const r=t*Math.cos(n)-e*Math.sin(n),s=t*Math.sin(n)+e*Math.cos(n);return[r,s]}function _n(t,e,n,r,s,i,a,o,u,l){const h=Ar(a);let c=[],p=0,f=0,d=0,m=0;if(l)[p,f,d,m]=l;else{[t,e]=kt(t,e,-h),[n,r]=kt(n,r,-h);const k=(t-n)/2,N=(e-r)/2;let R=k*k/(s*s)+N*N/(i*i);R>1&&(R=Math.sqrt(R),s=R*s,i=R*i);const B=o===u?-1:1,D=s*s,q=i*i,K=D*q-D*N*N-q*k*k,Z=D*N*N+q*k*k,L=B*Math.sqrt(Math.abs(K/Z));d=L*s*N/i+(t+n)/2,m=L*-i*k/s+(e+r)/2,p=Math.asin(parseFloat(((e-m)/i).toFixed(9))),f=Math.asin(parseFloat(((r-m)/i).toFixed(9))),t<d&&(p=Math.PI-p),n<d&&(f=Math.PI-f),p<0&&(p=Math.PI*2+p),f<0&&(f=Math.PI*2+f),u&&p>f&&(p=p-Math.PI*2),!u&&f>p&&(f=f-Math.PI*2)}let g=f-p;if(Math.abs(g)>Math.PI*120/180){const k=f,N=n,R=r;u&&f>p?f=p+Math.PI*120/180*1:f=p+Math.PI*120/180*-1,n=d+s*Math.cos(f),r=m+i*Math.sin(f),c=_n(n,r,N,R,s,i,a,0,u,[f,k,d,m])}g=f-p;const v=Math.cos(p),y=Math.sin(p),C=Math.cos(f),M=Math.sin(f),x=Math.tan(g/4),_=4/3*s*x,S=4/3*i*x,T=[t,e],V=[t+_*y,e-S*v],G=[n+_*M,r-S*C],H=[n,r];if(V[0]=2*T[0]-V[0],V[1]=2*T[1]-V[1],l)return[V,G,H].concat(c);{c=[V,G,H].concat(c);const k=[];for(let N=0;N<c.length;N+=3){const R=kt(c[N][0],c[N][1],h),B=kt(c[N+1][0],c[N+1][1],h),D=kt(c[N+2][0],c[N+2][1],h);k.push([R[0],R[1],B[0],B[1],D[0],D[1]])}return k}}const Er={randOffset:kr,randOffsetWithRange:Nr,ellipse:Or,doubleLineOps:Vr};function Cn(t,e,n,r,s){return{type:"path",ops:gt(t,e,n,r,s)}}function Wt(t,e,n){const r=(t||[]).length;if(r>2){const s=[];for(let i=0;i<r-1;i++)s.push(...gt(t[i][0],t[i][1],t[i+1][0],t[i+1][1],n));return e&&s.push(...gt(t[r-1][0],t[r-1][1],t[0][0],t[0][1],n)),{type:"path",ops:s}}else if(r===2)return Cn(t[0][0],t[0][1],t[1][0],t[1][1],n);return{type:"path",ops:[]}}function _r(t,e){return Wt(t,!0,e)}function Cr(t,e,n,r,s){const i=[[t,e],[t+n,e],[t+n,e+r],[t,e+r]];return _r(i,s)}function Le(t,e){if(t.length){const r=typeof t[0][0]=="number"?[t]:t,s=Ht(r[0],1*(1+e.roughness*.2),e),i=e.disableMultiStroke?[]:Ht(r[0],1.5*(1+e.roughness*.22),Fe(e));for(let a=1;a<r.length;a++){const o=r[a];if(o.length){const u=Ht(o,1*(1+e.roughness*.2),e),l=e.disableMultiStroke?[]:Ht(o,1.5*(1+e.roughness*.22),Fe(e));for(const h of u)h.op!=="move"&&s.push(h);for(const h of l)h.op!=="move"&&i.push(h)}}return{type:"path",ops:s.concat(i)}}return{type:"path",ops:[]}}function Or(t,e,n,r,s){const i=On(n,r,s);return ve(t,e,s,i).opset}function On(t,e,n){const r=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(t/2,2)+Math.pow(e/2,2))/2)),s=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),i=Math.PI*2/s;let a=Math.abs(t/2),o=Math.abs(e/2);const u=1-n.curveFitting;return a+=A(a*u,n),o+=A(o*u,n),{increment:i,rx:a,ry:o}}function ve(t,e,n,r){const[s,i]=He(r.increment,t,e,r.rx,r.ry,1,r.increment*Xt(.1,Xt(.4,1,n),n),n);let a=Yt(s,null,n);if(!n.disableMultiStroke&&n.roughness!==0){const[o]=He(r.increment,t,e,r.rx,r.ry,1.5,0,n),u=Yt(o,null,n);a=a.concat(u)}return{estimatedPoints:i,opset:{type:"path",ops:a}}}function De(t,e,n,r,s,i,a,o,u){const l=t,h=e;let c=Math.abs(n/2),p=Math.abs(r/2);c+=A(c*.01,u),p+=A(p*.01,u);let f=s,d=i;for(;f<0;)f+=Math.PI*2,d+=Math.PI*2;d-f>Math.PI*2&&(f=0,d=Math.PI*2);const m=Math.PI*2/u.curveStepCount,g=Math.min(m/2,(d-f)/2),v=Be(g,l,h,c,p,f,d,1,u);if(!u.disableMultiStroke){const y=Be(g,l,h,c,p,f,d,1.5,u);v.push(...y)}return a&&(o?v.push(...gt(l,h,l+c*Math.cos(f),h+p*Math.sin(f),u),...gt(l,h,l+c*Math.cos(d),h+p*Math.sin(d),u)):v.push({op:"lineTo",data:[l,h]},{op:"lineTo",data:[l+c*Math.cos(f),h+p*Math.sin(f)]})),{type:"path",ops:v}}function Ze(t,e){const n=En(An(_e(t))),r=[];let s=[0,0],i=[0,0];for(const{key:a,data:o}of n)switch(a){case"M":{i=[o[0],o[1]],s=[o[0],o[1]];break}case"L":r.push(...gt(i[0],i[1],o[0],o[1],e)),i=[o[0],o[1]];break;case"C":{const[u,l,h,c,p,f]=o;r.push(...Pr(u,l,h,c,p,f,i,e)),i=[p,f];break}case"Z":r.push(...gt(i[0],i[1],s[0],s[1],e)),i=[s[0],s[1]];break}return{type:"path",ops:r}}function oe(t,e){const n=[];for(const r of t)if(r.length){const s=e.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:"move",data:[r[0][0]+A(s,e),r[0][1]+A(s,e)]});for(let a=1;a<i;a++)n.push({op:"lineTo",data:[r[a][0]+A(s,e),r[a][1]+A(s,e)]})}}return{type:"fillPath",ops:n}}function At(t,e){return xr(e,Er).fillPolygons(t,e)}function Tr(t,e,n,r,s,i,a){const o=t,u=e;let l=Math.abs(n/2),h=Math.abs(r/2);l+=A(l*.01,a),h+=A(h*.01,a);let c=s,p=i;for(;c<0;)c+=Math.PI*2,p+=Math.PI*2;p-c>Math.PI*2&&(c=0,p=Math.PI*2);const f=(p-c)/a.curveStepCount,d=[];for(let m=c;m<=p;m=m+f)d.push([o+l*Math.cos(m),u+h*Math.sin(m)]);return d.push([o+l*Math.cos(p),u+h*Math.sin(p)]),d.push([o,u]),At([d],a)}function kr(t,e){return A(t,e)}function Nr(t,e,n){return Xt(t,e,n)}function Vr(t,e,n,r,s){return gt(t,e,n,r,s,!0)}function Fe(t){const e=Object.assign({},t);return e.randomizer=void 0,t.seed&&(e.seed=t.seed+1),e}function Tn(t){return t.randomizer||(t.randomizer=new Mn(t.seed||0)),t.randomizer.next()}function Xt(t,e,n,r=1){return n.roughness*r*(Tn(n)*(e-t)+t)}function A(t,e,n=1){return Xt(-t,t,e,n)}function gt(t,e,n,r,s,i=!1){const a=i?s.disableMultiStrokeFill:s.disableMultiStroke,o=be(t,e,n,r,s,!0,!1);if(a)return o;const u=be(t,e,n,r,s,!0,!0);return o.concat(u)}function be(t,e,n,r,s,i,a){const o=Math.pow(t-n,2)+Math.pow(e-r,2),u=Math.sqrt(o);let l=1;u<200?l=1:u>500?l=.4:l=-.0016668*u+1.233334;let h=s.maxRandomnessOffset||0;h*h*100>o&&(h=u/10);const c=h/2,p=.2+Tn(s)*.2;let f=s.bowing*s.maxRandomnessOffset*(r-e)/200,d=s.bowing*s.maxRandomnessOffset*(t-n)/200;f=A(f,s,l),d=A(d,s,l);const m=[],g=()=>A(c,s,l),v=()=>A(h,s,l),y=s.preserveVertices;return a?m.push({op:"move",data:[t+(y?0:g()),e+(y?0:g())]}):m.push({op:"move",data:[t+(y?0:A(h,s,l)),e+(y?0:A(h,s,l))]}),a?m.push({op:"bcurveTo",data:[f+t+(n-t)*p+g(),d+e+(r-e)*p+g(),f+t+2*(n-t)*p+g(),d+e+2*(r-e)*p+g(),n+(y?0:g()),r+(y?0:g())]}):m.push({op:"bcurveTo",data:[f+t+(n-t)*p+v(),d+e+(r-e)*p+v(),f+t+2*(n-t)*p+v(),d+e+2*(r-e)*p+v(),n+(y?0:v()),r+(y?0:v())]}),m}function Ht(t,e,n){if(!t.length)return[];const r=[];r.push([t[0][0]+A(e,n),t[0][1]+A(e,n)]),r.push([t[0][0]+A(e,n),t[0][1]+A(e,n)]);for(let s=1;s<t.length;s++)r.push([t[s][0]+A(e,n),t[s][1]+A(e,n)]),s===t.length-1&&r.push([t[s][0]+A(e,n),t[s][1]+A(e,n)]);return Yt(r,null,n)}function Yt(t,e,n){const r=t.length,s=[];if(r>3){const i=[],a=1-n.curveTightness;s.push({op:"move",data:[t[1][0],t[1][1]]});for(let o=1;o+2<r;o++){const u=t[o];i[0]=[u[0],u[1]],i[1]=[u[0]+(a*t[o+1][0]-a*t[o-1][0])/6,u[1]+(a*t[o+1][1]-a*t[o-1][1])/6],i[2]=[t[o+1][0]+(a*t[o][0]-a*t[o+2][0])/6,t[o+1][1]+(a*t[o][1]-a*t[o+2][1])/6],i[3]=[t[o+1][0],t[o+1][1]],s.push({op:"bcurveTo",data:[i[1][0],i[1][1],i[2][0],i[2][1],i[3][0],i[3][1]]})}}else r===3?(s.push({op:"move",data:[t[1][0],t[1][1]]}),s.push({op:"bcurveTo",data:[t[1][0],t[1][1],t[2][0],t[2][1],t[2][0],t[2][1]]})):r===2&&s.push(...be(t[0][0],t[0][1],t[1][0],t[1][1],n,!0,!0));return s}function He(t,e,n,r,s,i,a,o){const u=o.roughness===0,l=[],h=[];if(u){t=t/4,h.push([e+r*Math.cos(-t),n+s*Math.sin(-t)]);for(let c=0;c<=Math.PI*2;c=c+t){const p=[e+r*Math.cos(c),n+s*Math.sin(c)];l.push(p),h.push(p)}h.push([e+r*Math.cos(0),n+s*Math.sin(0)]),h.push([e+r*Math.cos(t),n+s*Math.sin(t)])}else{const c=A(.5,o)-Math.PI/2;h.push([A(i,o)+e+.9*r*Math.cos(c-t),A(i,o)+n+.9*s*Math.sin(c-t)]);const p=Math.PI*2+c-.01;for(let f=c;f<p;f=f+t){const d=[A(i,o)+e+r*Math.cos(f),A(i,o)+n+s*Math.sin(f)];l.push(d),h.push(d)}h.push([A(i,o)+e+r*Math.cos(c+Math.PI*2+a*.5),A(i,o)+n+s*Math.sin(c+Math.PI*2+a*.5)]),h.push([A(i,o)+e+.98*r*Math.cos(c+a),A(i,o)+n+.98*s*Math.sin(c+a)]),h.push([A(i,o)+e+.9*r*Math.cos(c+a*.5),A(i,o)+n+.9*s*Math.sin(c+a*.5)])}return[h,l]}function Be(t,e,n,r,s,i,a,o,u){const l=i+A(.1,u),h=[];h.push([A(o,u)+e+.9*r*Math.cos(l-t),A(o,u)+n+.9*s*Math.sin(l-t)]);for(let c=l;c<=a;c=c+t)h.push([A(o,u)+e+r*Math.cos(c),A(o,u)+n+s*Math.sin(c)]);return h.push([e+r*Math.cos(a),n+s*Math.sin(a)]),h.push([e+r*Math.cos(a),n+s*Math.sin(a)]),Yt(h,null,u)}function Pr(t,e,n,r,s,i,a,o){const u=[],l=[o.maxRandomnessOffset||1,(o.maxRandomnessOffset||1)+.3];let h=[0,0];const c=o.disableMultiStroke?1:2,p=o.preserveVertices;for(let f=0;f<c;f++)f===0?u.push({op:"move",data:[a[0],a[1]]}):u.push({op:"move",data:[a[0]+(p?0:A(l[0],o)),a[1]+(p?0:A(l[0],o))]}),h=p?[s,i]:[s+A(l[f],o),i+A(l[f],o)],u.push({op:"bcurveTo",data:[t+A(l[f],o),e+A(l[f],o),n+A(l[f],o),r+A(l[f],o),h[0],h[1]]});return u}function Nt(t){return[...t]}function Ue(t,e=0){const n=t.length;if(n<3)throw new Error("A curve must have at least three points.");const r=[];if(n===3)r.push(Nt(t[0]),Nt(t[1]),Nt(t[2]),Nt(t[2]));else{const s=[];s.push(t[0],t[0]);for(let o=1;o<t.length;o++)s.push(t[o]),o===t.length-1&&s.push(t[o]);const i=[],a=1-e;r.push(Nt(s[0]));for(let o=1;o+2<s.length;o++){const u=s[o];i[0]=[u[0],u[1]],i[1]=[u[0]+(a*s[o+1][0]-a*s[o-1][0])/6,u[1]+(a*s[o+1][1]-a*s[o-1][1])/6],i[2]=[s[o+1][0]+(a*s[o][0]-a*s[o+2][0])/6,s[o+1][1]+(a*s[o][1]-a*s[o+2][1])/6],i[3]=[s[o+1][0],s[o+1][1]],r.push(i[1],i[2],i[3])}}return r}function Rr(t,e){return Math.sqrt(jt(t,e))}function jt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)}function Ir(t,e,n){const r=jt(e,n);if(r===0)return jt(t,e);let s=((t[0]-e[0])*(n[0]-e[0])+(t[1]-e[1])*(n[1]-e[1]))/r;return s=Math.max(0,Math.min(1,s)),jt(t,vt(e,n,s))}function vt(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]}function zr(t,e){const n=t[e+0],r=t[e+1],s=t[e+2],i=t[e+3];let a=3*r[0]-2*n[0]-i[0];a*=a;let o=3*r[1]-2*n[1]-i[1];o*=o;let u=3*s[0]-2*i[0]-n[0];u*=u;let l=3*s[1]-2*i[1]-n[1];return l*=l,a<u&&(a=u),o<l&&(o=l),a+o}function ye(t,e,n,r){const s=r||[];if(zr(t,e)<n){const i=t[e+0];s.length?Rr(s[s.length-1],i)>1&&s.push(i):s.push(i),s.push(t[e+3])}else{const a=t[e+0],o=t[e+1],u=t[e+2],l=t[e+3],h=vt(a,o,.5),c=vt(o,u,.5),p=vt(u,l,.5),f=vt(h,c,.5),d=vt(c,p,.5),m=vt(f,d,.5);ye([a,h,f,m],0,n,s),ye([m,d,p,l],0,n,s)}return s}function Lr(t,e){return Qt(t,0,t.length,e)}function Qt(t,e,n,r,s){const i=s||[],a=t[e],o=t[n-1];let u=0,l=1;for(let h=e+1;h<n-1;++h){const c=Ir(t[h],a,o);c>u&&(u=c,l=h)}return Math.sqrt(u)>r?(Qt(t,e,l+1,r,i),Qt(t,l,n,r,i)):(i.length||i.push(a),i.push(o)),i}function xe(t,e=.15,n){const r=[],s=(t.length-1)/3;for(let i=0;i<s;i++){const a=i*3;ye(t,a,e,r)}return n&&n>0?Qt(r,0,r.length,n):r}function Dr(t,e,n){const r=_e(t),s=En(An(r)),i=[];let a=[],o=[0,0],u=[];const l=()=>{u.length>=4&&a.push(...xe(u,e)),u=[]},h=()=>{l(),a.length&&(i.push(a),a=[])};for(const{key:p,data:f}of s)switch(p){case"M":h(),o=[f[0],f[1]],a.push(o);break;case"L":l(),a.push([f[0],f[1]]);break;case"C":if(!u.length){const d=a.length?a[a.length-1]:o;u.push([d[0],d[1]])}u.push([f[0],f[1]]),u.push([f[2],f[3]]),u.push([f[4],f[5]]);break;case"Z":l(),a.push([o[0],o[1]]);break}if(h(),!n)return i;const c=[];for(const p of i){const f=Lr(p,n);f.length&&c.push(f)}return c}const X="none";class Kt{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return wr()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,n,r){return{shape:e,sets:n||[],options:r||this.defaultOptions}}line(e,n,r,s,i){const a=this._o(i);return this._d("line",[Cn(e,n,r,s,a)],a)}rectangle(e,n,r,s,i){const a=this._o(i),o=[],u=Cr(e,n,r,s,a);if(a.fill){const l=[[e,n],[e+r,n],[e+r,n+s],[e,n+s]];a.fillStyle==="solid"?o.push(oe([l],a)):o.push(At([l],a))}return a.stroke!==X&&o.push(u),this._d("rectangle",o,a)}ellipse(e,n,r,s,i){const a=this._o(i),o=[],u=On(r,s,a),l=ve(e,n,a,u);if(a.fill)if(a.fillStyle==="solid"){const h=ve(e,n,a,u).opset;h.type="fillPath",o.push(h)}else o.push(At([l.estimatedPoints],a));return a.stroke!==X&&o.push(l.opset),this._d("ellipse",o,a)}circle(e,n,r,s){const i=this.ellipse(e,n,r,r,s);return i.shape="circle",i}linearPath(e,n){const r=this._o(n);return this._d("linearPath",[Wt(e,!1,r)],r)}arc(e,n,r,s,i,a,o=!1,u){const l=this._o(u),h=[],c=De(e,n,r,s,i,a,o,!0,l);if(o&&l.fill)if(l.fillStyle==="solid"){const p=Object.assign({},l);p.disableMultiStroke=!0;const f=De(e,n,r,s,i,a,!0,!1,p);f.type="fillPath",h.push(f)}else h.push(Tr(e,n,r,s,i,a,l));return l.stroke!==X&&h.push(c),this._d("arc",h,l)}curve(e,n){const r=this._o(n),s=[],i=Le(e,r);if(r.fill&&r.fill!==X)if(r.fillStyle==="solid"){const a=Le(e,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(a.ops)})}else{const a=[],o=e;if(o.length){const l=typeof o[0][0]=="number"?[o]:o;for(const h of l)h.length<3?a.push(...h):h.length===3?a.push(...xe(Ue([h[0],h[0],h[1],h[2]]),10,(1+r.roughness)/2)):a.push(...xe(Ue(h),10,(1+r.roughness)/2))}a.length&&s.push(At([a],r))}return r.stroke!==X&&s.push(i),this._d("curve",s,r)}polygon(e,n){const r=this._o(n),s=[],i=Wt(e,!0,r);return r.fill&&(r.fillStyle==="solid"?s.push(oe([e],r)):s.push(At([e],r))),r.stroke!==X&&s.push(i),this._d("polygon",s,r)}path(e,n){const r=this._o(n),s=[];if(!e)return this._d("path",s,r);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const i=r.fill&&r.fill!=="transparent"&&r.fill!==X,a=r.stroke!==X,o=!!(r.simplification&&r.simplification<1),u=o?4-4*(r.simplification||1):(1+r.roughness)/2,l=Dr(e,1,u),h=Ze(e,r);if(i)if(r.fillStyle==="solid")if(l.length===1){const c=Ze(e,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));s.push({type:"fillPath",ops:this._mergedShape(c.ops)})}else s.push(oe(l,r));else s.push(At(l,r));return a&&(o?l.forEach(c=>{s.push(Wt(c,!1,r))}):s.push(h)),this._d("path",s,r)}opsToPath(e,n){let r="";for(const s of e.ops){const i=typeof n=="number"&&n>=0?s.data.map(a=>+a.toFixed(n)):s.data;switch(s.op){case"move":r+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":r+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":r+=`L${i[0]} ${i[1]} `;break}}return r.trim()}toPaths(e){const n=e.sets||[],r=e.options||this.defaultOptions,s=[];for(const i of n){let a=null;switch(i.type){case"path":a={d:this.opsToPath(i),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:X};break;case"fillPath":a={d:this.opsToPath(i),stroke:X,strokeWidth:0,fill:r.fill||X};break;case"fillSketch":a=this.fillSketch(i,r);break}a&&s.push(a)}return s}fillSketch(e,n){let r=n.fillWeight;return r<0&&(r=n.strokeWidth/2),{d:this.opsToPath(e),stroke:n.fill||X,strokeWidth:r,fill:X}}_mergedShape(e){return e.filter((n,r)=>r===0?!0:n.op!=="move")}}class Zr{constructor(e,n){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new Kt(n)}draw(e){const n=e.sets||[],r=e.options||this.getDefaultOptions(),s=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(const a of n)switch(a.type){case"path":s.save(),s.strokeStyle=r.stroke==="none"?"transparent":r.stroke,s.lineWidth=r.strokeWidth,r.strokeLineDash&&s.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(s.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(s,a,i),s.restore();break;case"fillPath":{s.save(),s.fillStyle=r.fill||"";const o=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(s,a,i,o),s.restore();break}case"fillSketch":this.fillSketch(s,a,r);break}}fillSketch(e,n,r){let s=r.fillWeight;s<0&&(s=r.strokeWidth/2),e.save(),r.fillLineDash&&e.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(e.lineDashOffset=r.fillLineDashOffset),e.strokeStyle=r.fill||"",e.lineWidth=s,this._drawToContext(e,n,r.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,n,r,s="nonzero"){e.beginPath();for(const i of n.ops){const a=typeof r=="number"&&r>=0?i.data.map(o=>+o.toFixed(r)):i.data;switch(i.op){case"move":e.moveTo(a[0],a[1]);break;case"bcurveTo":e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case"lineTo":e.lineTo(a[0],a[1]);break}}n.type==="fillPath"?e.fill(s):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,n,r,s,i){const a=this.gen.line(e,n,r,s,i);return this.draw(a),a}rectangle(e,n,r,s,i){const a=this.gen.rectangle(e,n,r,s,i);return this.draw(a),a}ellipse(e,n,r,s,i){const a=this.gen.ellipse(e,n,r,s,i);return this.draw(a),a}circle(e,n,r,s){const i=this.gen.circle(e,n,r,s);return this.draw(i),i}linearPath(e,n){const r=this.gen.linearPath(e,n);return this.draw(r),r}polygon(e,n){const r=this.gen.polygon(e,n);return this.draw(r),r}arc(e,n,r,s,i,a,o=!1,u){const l=this.gen.arc(e,n,r,s,i,a,o,u);return this.draw(l),l}curve(e,n){const r=this.gen.curve(e,n);return this.draw(r),r}path(e,n){const r=this.gen.path(e,n);return this.draw(r),r}}const Bt="http://www.w3.org/2000/svg";class Fr{constructor(e,n){this.svg=e,this.gen=new Kt(n)}draw(e){const n=e.sets||[],r=e.options||this.getDefaultOptions(),s=this.svg.ownerDocument||window.document,i=s.createElementNS(Bt,"g"),a=e.options.fixedDecimalPlaceDigits;for(const o of n){let u=null;switch(o.type){case"path":{u=s.createElementNS(Bt,"path"),u.setAttribute("d",this.opsToPath(o,a)),u.setAttribute("stroke",r.stroke),u.setAttribute("stroke-width",r.strokeWidth+""),u.setAttribute("fill","none"),r.strokeLineDash&&u.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&u.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break}case"fillPath":{u=s.createElementNS(Bt,"path"),u.setAttribute("d",this.opsToPath(o,a)),u.setAttribute("stroke","none"),u.setAttribute("stroke-width","0"),u.setAttribute("fill",r.fill||""),(e.shape==="curve"||e.shape==="polygon")&&u.setAttribute("fill-rule","evenodd");break}case"fillSketch":{u=this.fillSketch(s,o,r);break}}u&&i.appendChild(u)}return i}fillSketch(e,n,r){let s=r.fillWeight;s<0&&(s=r.strokeWidth/2);const i=e.createElementNS(Bt,"path");return i.setAttribute("d",this.opsToPath(n,r.fixedDecimalPlaceDigits)),i.setAttribute("stroke",r.fill||""),i.setAttribute("stroke-width",s+""),i.setAttribute("fill","none"),r.fillLineDash&&i.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&i.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,n){return this.gen.opsToPath(e,n)}line(e,n,r,s,i){const a=this.gen.line(e,n,r,s,i);return this.draw(a)}rectangle(e,n,r,s,i){const a=this.gen.rectangle(e,n,r,s,i);return this.draw(a)}ellipse(e,n,r,s,i){const a=this.gen.ellipse(e,n,r,s,i);return this.draw(a)}circle(e,n,r,s){const i=this.gen.circle(e,n,r,s);return this.draw(i)}linearPath(e,n){const r=this.gen.linearPath(e,n);return this.draw(r)}polygon(e,n){const r=this.gen.polygon(e,n);return this.draw(r)}arc(e,n,r,s,i,a,o=!1,u){const l=this.gen.arc(e,n,r,s,i,a,o,u);return this.draw(l)}curve(e,n){const r=this.gen.curve(e,n);return this.draw(r)}path(e,n){const r=this.gen.path(e,n);return this.draw(r)}}const Hr={canvas(t,e){return new Zr(t,e)},svg(t,e){return new Fr(t,e)},generator(t){return new Kt(t)},newSeed(){return Kt.newSeed()}};function Jt(t){"@babel/helpers - typeof";return Jt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jt(t)}var Br=/^\s+/,Ur=/\s+$/;function w(t,e){if(t=t||"",e=e||{},t instanceof w)return t;if(!(this instanceof w))return new w(t,e);var n=Gr(t);this._originalInput=t,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||n.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}w.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),n,r,s,i,a,o;return n=e.r/255,r=e.g/255,s=e.b/255,n<=.03928?i=n/12.92:i=Math.pow((n+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),s<=.03928?o=s/12.92:o=Math.pow((s+.055)/1.055,2.4),.2126*i+.7152*a+.0722*o},setAlpha:function(e){return this._a=kn(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=qe(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=qe(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.v*100);return this._a==1?"hsv("+n+", "+r+"%, "+s+"%)":"hsva("+n+", "+r+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var e=Ge(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Ge(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.l*100);return this._a==1?"hsl("+n+", "+r+"%, "+s+"%)":"hsla("+n+", "+r+"%, "+s+"%, "+this._roundA+")"},toHex:function(e){return $e(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return jr(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(I(this._r,255)*100)+"%",g:Math.round(I(this._g,255)*100)+"%",b:Math.round(I(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(I(this._r,255)*100)+"%, "+Math.round(I(this._g,255)*100)+"%, "+Math.round(I(this._b,255)*100)+"%)":"rgba("+Math.round(I(this._r,255)*100)+"%, "+Math.round(I(this._g,255)*100)+"%, "+Math.round(I(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:os[$e(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var n="#"+We(this._r,this._g,this._b,this._a),r=n,s=this._gradientType?"GradientType = 1, ":"";if(e){var i=w(e);r="#"+We(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+n+",endColorstr="+r+")"},toString:function(e){var n=!!e;e=e||this._format;var r=!1,s=this._a<1&&this._a>=0,i=!n&&s&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return i?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return w(this.toString())},_applyModification:function(e,n){var r=e.apply(null,[this].concat([].slice.call(n)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Kr,arguments)},brighten:function(){return this._applyModification(Jr,arguments)},darken:function(){return this._applyModification(ts,arguments)},desaturate:function(){return this._applyModification(Xr,arguments)},saturate:function(){return this._applyModification(Yr,arguments)},greyscale:function(){return this._applyModification(Qr,arguments)},spin:function(){return this._applyModification(es,arguments)},_applyCombination:function(e,n){return e.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(ss,arguments)},complement:function(){return this._applyCombination(ns,arguments)},monochromatic:function(){return this._applyCombination(is,arguments)},splitcomplement:function(){return this._applyCombination(rs,arguments)},triad:function(){return this._applyCombination(je,[3])},tetrad:function(){return this._applyCombination(je,[4])}};w.fromRatio=function(t,e){if(Jt(t)=="object"){var n={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?n[r]=t[r]:n[r]=Vt(t[r]));t=n}return w(t,e)};function Gr(t){var e={r:0,g:0,b:0},n=1,r=null,s=null,i=null,a=!1,o=!1;return typeof t=="string"&&(t=hs(t)),Jt(t)=="object"&&(at(t.r)&&at(t.g)&&at(t.b)?(e=qr(t.r,t.g,t.b),a=!0,o=String(t.r).substr(-1)==="%"?"prgb":"rgb"):at(t.h)&&at(t.s)&&at(t.v)?(r=Vt(t.s),s=Vt(t.v),e=Wr(t.h,r,s),a=!0,o="hsv"):at(t.h)&&at(t.s)&&at(t.l)&&(r=Vt(t.s),i=Vt(t.l),e=$r(t.h,r,i),a=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=kn(n),{ok:a,format:t.format||o,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}function qr(t,e,n){return{r:I(t,255)*255,g:I(e,255)*255,b:I(n,255)*255}}function Ge(t,e,n){t=I(t,255),e=I(e,255),n=I(n,255);var r=Math.max(t,e,n),s=Math.min(t,e,n),i,a,o=(r+s)/2;if(r==s)i=a=0;else{var u=r-s;switch(a=o>.5?u/(2-r-s):u/(r+s),r){case t:i=(e-n)/u+(e<n?6:0);break;case e:i=(n-t)/u+2;break;case n:i=(t-e)/u+4;break}i/=6}return{h:i,s:a,l:o}}function $r(t,e,n){var r,s,i;t=I(t,360),e=I(e,100),n=I(n,100);function a(l,h,c){return c<0&&(c+=1),c>1&&(c-=1),c<1/6?l+(h-l)*6*c:c<1/2?h:c<2/3?l+(h-l)*(2/3-c)*6:l}if(e===0)r=s=i=n;else{var o=n<.5?n*(1+e):n+e-n*e,u=2*n-o;r=a(u,o,t+1/3),s=a(u,o,t),i=a(u,o,t-1/3)}return{r:r*255,g:s*255,b:i*255}}function qe(t,e,n){t=I(t,255),e=I(e,255),n=I(n,255);var r=Math.max(t,e,n),s=Math.min(t,e,n),i,a,o=r,u=r-s;if(a=r===0?0:u/r,r==s)i=0;else{switch(r){case t:i=(e-n)/u+(e<n?6:0);break;case e:i=(n-t)/u+2;break;case n:i=(t-e)/u+4;break}i/=6}return{h:i,s:a,v:o}}function Wr(t,e,n){t=I(t,360)*6,e=I(e,100),n=I(n,100);var r=Math.floor(t),s=t-r,i=n*(1-e),a=n*(1-s*e),o=n*(1-(1-s)*e),u=r%6,l=[n,a,i,i,o,n][u],h=[o,n,n,a,i,i][u],c=[i,i,o,n,n,a][u];return{r:l*255,g:h*255,b:c*255}}function $e(t,e,n,r){var s=[rt(Math.round(t).toString(16)),rt(Math.round(e).toString(16)),rt(Math.round(n).toString(16))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function jr(t,e,n,r,s){var i=[rt(Math.round(t).toString(16)),rt(Math.round(e).toString(16)),rt(Math.round(n).toString(16)),rt(Nn(r))];return s&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)&&i[3].charAt(0)==i[3].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0):i.join("")}function We(t,e,n,r){var s=[rt(Nn(r)),rt(Math.round(t).toString(16)),rt(Math.round(e).toString(16)),rt(Math.round(n).toString(16))];return s.join("")}w.equals=function(t,e){return!t||!e?!1:w(t).toRgbString()==w(e).toRgbString()};w.random=function(){return w.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function Xr(t,e){e=e===0?0:e||10;var n=w(t).toHsl();return n.s-=e/100,n.s=ne(n.s),w(n)}function Yr(t,e){e=e===0?0:e||10;var n=w(t).toHsl();return n.s+=e/100,n.s=ne(n.s),w(n)}function Qr(t){return w(t).desaturate(100)}function Kr(t,e){e=e===0?0:e||10;var n=w(t).toHsl();return n.l+=e/100,n.l=ne(n.l),w(n)}function Jr(t,e){e=e===0?0:e||10;var n=w(t).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(e/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(e/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(e/100)))),w(n)}function ts(t,e){e=e===0?0:e||10;var n=w(t).toHsl();return n.l-=e/100,n.l=ne(n.l),w(n)}function es(t,e){var n=w(t).toHsl(),r=(n.h+e)%360;return n.h=r<0?360+r:r,w(n)}function ns(t){var e=w(t).toHsl();return e.h=(e.h+180)%360,w(e)}function je(t,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var n=w(t).toHsl(),r=[w(t)],s=360/e,i=1;i<e;i++)r.push(w({h:(n.h+i*s)%360,s:n.s,l:n.l}));return r}function rs(t){var e=w(t).toHsl(),n=e.h;return[w(t),w({h:(n+72)%360,s:e.s,l:e.l}),w({h:(n+216)%360,s:e.s,l:e.l})]}function ss(t,e,n){e=e||6,n=n||30;var r=w(t).toHsl(),s=360/n,i=[w(t)];for(r.h=(r.h-(s*e>>1)+720)%360;--e;)r.h=(r.h+s)%360,i.push(w(r));return i}function is(t,e){e=e||6;for(var n=w(t).toHsv(),r=n.h,s=n.s,i=n.v,a=[],o=1/e;e--;)a.push(w({h:r,s,v:i})),i=(i+o)%1;return a}w.mix=function(t,e,n){n=n===0?0:n||50;var r=w(t).toRgb(),s=w(e).toRgb(),i=n/100,a={r:(s.r-r.r)*i+r.r,g:(s.g-r.g)*i+r.g,b:(s.b-r.b)*i+r.b,a:(s.a-r.a)*i+r.a};return w(a)};w.readability=function(t,e){var n=w(t),r=w(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)};w.isReadable=function(t,e,n){var r=w.readability(t,e),s,i;switch(i=!1,s=cs(n),s.level+s.size){case"AAsmall":case"AAAlarge":i=r>=4.5;break;case"AAlarge":i=r>=3;break;case"AAAsmall":i=r>=7;break}return i};w.mostReadable=function(t,e,n){var r=null,s=0,i,a,o,u;n=n||{},a=n.includeFallbackColors,o=n.level,u=n.size;for(var l=0;l<e.length;l++)i=w.readability(t,e[l]),i>s&&(s=i,r=w(e[l]));return w.isReadable(t,r,{level:o,size:u})||!a?r:(n.includeFallbackColors=!1,w.mostReadable(t,["#fff","#000"],n))};var we=w.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",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",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",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:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},os=w.hexNames=as(we);function as(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function kn(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function I(t,e){ls(t)&&(t="100%");var n=us(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function ne(t){return Math.min(1,Math.max(0,t))}function Y(t){return parseInt(t,16)}function ls(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function us(t){return typeof t=="string"&&t.indexOf("%")!=-1}function rt(t){return t.length==1?"0"+t:""+t}function Vt(t){return t<=1&&(t=t*100+"%"),t}function Nn(t){return Math.round(parseFloat(t)*255).toString(16)}function Xe(t){return Y(t)/255}var tt=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",s="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function at(t){return!!tt.CSS_UNIT.exec(t)}function hs(t){t=t.replace(Br,"").replace(Ur,"").toLowerCase();var e=!1;if(we[t])t=we[t],e=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=tt.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=tt.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=tt.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=tt.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=tt.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=tt.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=tt.hex8.exec(t))?{r:Y(n[1]),g:Y(n[2]),b:Y(n[3]),a:Xe(n[4]),format:e?"name":"hex8"}:(n=tt.hex6.exec(t))?{r:Y(n[1]),g:Y(n[2]),b:Y(n[3]),format:e?"name":"hex"}:(n=tt.hex4.exec(t))?{r:Y(n[1]+""+n[1]),g:Y(n[2]+""+n[2]),b:Y(n[3]+""+n[3]),a:Xe(n[4]+""+n[4]),format:e?"name":"hex8"}:(n=tt.hex3.exec(t))?{r:Y(n[1]+""+n[1]),g:Y(n[2]+""+n[2]),b:Y(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function cs(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),n!=="small"&&n!=="large"&&(n="small"),{level:e,size:n}}/*! *****************************************************************************
|
|
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 Vn=function(t,e){return(Vn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])})(t,e)};function Pn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}Vn(t,e),t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Rn(t){var e="";Array.isArray(t)||(t=[t]);for(var n=0;n<t.length;n++){var r=t[n];if(r.type===b.CLOSE_PATH)e+="z";else if(r.type===b.HORIZ_LINE_TO)e+=(r.relative?"h":"H")+r.x;else if(r.type===b.VERT_LINE_TO)e+=(r.relative?"v":"V")+r.y;else if(r.type===b.MOVE_TO)e+=(r.relative?"m":"M")+r.x+" "+r.y;else if(r.type===b.LINE_TO)e+=(r.relative?"l":"L")+r.x+" "+r.y;else if(r.type===b.CURVE_TO)e+=(r.relative?"c":"C")+r.x1+" "+r.y1+" "+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===b.SMOOTH_CURVE_TO)e+=(r.relative?"s":"S")+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===b.QUAD_TO)e+=(r.relative?"q":"Q")+r.x1+" "+r.y1+" "+r.x+" "+r.y;else if(r.type===b.SMOOTH_QUAD_TO)e+=(r.relative?"t":"T")+r.x+" "+r.y;else{if(r.type!==b.ARC)throw new Error('Unexpected command type "'+r.type+'" at index '+n+".");e+=(r.relative?"a":"A")+r.rX+" "+r.rY+" "+r.xRot+" "+ +r.lArcFlag+" "+ +r.sweepFlag+" "+r.x+" "+r.y}}return e}function Me(t,e){var n=t[0],r=t[1];return[n*Math.cos(e)-r*Math.sin(e),n*Math.sin(e)+r*Math.cos(e)]}function et(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;n++)if(typeof t[n]!="number")throw new Error("assertNumbers arguments["+n+"] is not a number. "+typeof t[n]+" == typeof "+t[n]);return!0}var ct=Math.PI;function ae(t,e,n){t.lArcFlag=t.lArcFlag===0?0:1,t.sweepFlag=t.sweepFlag===0?0:1;var r=t.rX,s=t.rY,i=t.x,a=t.y;r=Math.abs(t.rX),s=Math.abs(t.rY);var o=Me([(e-i)/2,(n-a)/2],-t.xRot/180*ct),u=o[0],l=o[1],h=Math.pow(u,2)/Math.pow(r,2)+Math.pow(l,2)/Math.pow(s,2);1<h&&(r*=Math.sqrt(h),s*=Math.sqrt(h)),t.rX=r,t.rY=s;var c=Math.pow(r,2)*Math.pow(l,2)+Math.pow(s,2)*Math.pow(u,2),p=(t.lArcFlag!==t.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(r,2)*Math.pow(s,2)-c)/c)),f=r*l/s*p,d=-s*u/r*p,m=Me([f,d],t.xRot/180*ct);t.cX=m[0]+(e+i)/2,t.cY=m[1]+(n+a)/2,t.phi1=Math.atan2((l-d)/s,(u-f)/r),t.phi2=Math.atan2((-l-d)/s,(-u-f)/r),t.sweepFlag===0&&t.phi2>t.phi1&&(t.phi2-=2*ct),t.sweepFlag===1&&t.phi2<t.phi1&&(t.phi2+=2*ct),t.phi1*=180/ct,t.phi2*=180/ct}function Ye(t,e,n){et(t,e,n);var r=t*t+e*e-n*n;if(0>r)return[];if(r===0)return[[t*n/(t*t+e*e),e*n/(t*t+e*e)]];var s=Math.sqrt(r);return[[(t*n+e*s)/(t*t+e*e),(e*n-t*s)/(t*t+e*e)],[(t*n-e*s)/(t*t+e*e),(e*n+t*s)/(t*t+e*e)]]}var z,lt=Math.PI/180;function Qe(t,e,n){return(1-n)*t+n*e}function Ke(t,e,n,r){return t+Math.cos(r/180*ct)*e+Math.sin(r/180*ct)*n}function Je(t,e,n,r){var s=1e-6,i=e-t,a=n-e,o=3*i+3*(r-n)-6*a,u=6*(a-i),l=3*i;return Math.abs(o)<s?[-l/u]:function(h,c,p){var f=h*h/4-c;if(f<-p)return[];if(f<=p)return[-h/2];var d=Math.sqrt(f);return[-h/2-d,-h/2+d]}(u/o,l/o,s)}function tn(t,e,n,r,s){var i=1-s;return t*(i*i*i)+e*(3*i*i*s)+n*(3*i*s*s)+r*(s*s*s)}(function(t){function e(){return s(function(o,u,l){return o.relative&&(o.x1!==void 0&&(o.x1+=u),o.y1!==void 0&&(o.y1+=l),o.x2!==void 0&&(o.x2+=u),o.y2!==void 0&&(o.y2+=l),o.x!==void 0&&(o.x+=u),o.y!==void 0&&(o.y+=l),o.relative=!1),o})}function n(){var o=NaN,u=NaN,l=NaN,h=NaN;return s(function(c,p,f){return c.type&b.SMOOTH_CURVE_TO&&(c.type=b.CURVE_TO,o=isNaN(o)?p:o,u=isNaN(u)?f:u,c.x1=c.relative?p-o:2*p-o,c.y1=c.relative?f-u:2*f-u),c.type&b.CURVE_TO?(o=c.relative?p+c.x2:c.x2,u=c.relative?f+c.y2:c.y2):(o=NaN,u=NaN),c.type&b.SMOOTH_QUAD_TO&&(c.type=b.QUAD_TO,l=isNaN(l)?p:l,h=isNaN(h)?f:h,c.x1=c.relative?p-l:2*p-l,c.y1=c.relative?f-h:2*f-h),c.type&b.QUAD_TO?(l=c.relative?p+c.x1:c.x1,h=c.relative?f+c.y1:c.y1):(l=NaN,h=NaN),c})}function r(){var o=NaN,u=NaN;return s(function(l,h,c){if(l.type&b.SMOOTH_QUAD_TO&&(l.type=b.QUAD_TO,o=isNaN(o)?h:o,u=isNaN(u)?c:u,l.x1=l.relative?h-o:2*h-o,l.y1=l.relative?c-u:2*c-u),l.type&b.QUAD_TO){o=l.relative?h+l.x1:l.x1,u=l.relative?c+l.y1:l.y1;var p=l.x1,f=l.y1;l.type=b.CURVE_TO,l.x1=((l.relative?0:h)+2*p)/3,l.y1=((l.relative?0:c)+2*f)/3,l.x2=(l.x+2*p)/3,l.y2=(l.y+2*f)/3}else o=NaN,u=NaN;return l})}function s(o){var u=0,l=0,h=NaN,c=NaN;return function(p){if(isNaN(h)&&!(p.type&b.MOVE_TO))throw new Error("path must start with moveto");var f=o(p,u,l,h,c);return p.type&b.CLOSE_PATH&&(u=h,l=c),p.x!==void 0&&(u=p.relative?u+p.x:p.x),p.y!==void 0&&(l=p.relative?l+p.y:p.y),p.type&b.MOVE_TO&&(h=u,c=l),f}}function i(o,u,l,h,c,p){return et(o,u,l,h,c,p),s(function(f,d,m,g){var v=f.x1,y=f.x2,C=f.relative&&!isNaN(g),M=f.x!==void 0?f.x:C?0:d,x=f.y!==void 0?f.y:C?0:m;function _(Mt){return Mt*Mt}f.type&b.HORIZ_LINE_TO&&u!==0&&(f.type=b.LINE_TO,f.y=f.relative?0:m),f.type&b.VERT_LINE_TO&&l!==0&&(f.type=b.LINE_TO,f.x=f.relative?0:d),f.x!==void 0&&(f.x=f.x*o+x*l+(C?0:c)),f.y!==void 0&&(f.y=M*u+f.y*h+(C?0:p)),f.x1!==void 0&&(f.x1=f.x1*o+f.y1*l+(C?0:c)),f.y1!==void 0&&(f.y1=v*u+f.y1*h+(C?0:p)),f.x2!==void 0&&(f.x2=f.x2*o+f.y2*l+(C?0:c)),f.y2!==void 0&&(f.y2=y*u+f.y2*h+(C?0:p));var S=o*h-u*l;if(f.xRot!==void 0&&(o!==1||u!==0||l!==0||h!==1))if(S===0)delete f.rX,delete f.rY,delete f.xRot,delete f.lArcFlag,delete f.sweepFlag,f.type=b.LINE_TO;else{var T=f.xRot*Math.PI/180,V=Math.sin(T),G=Math.cos(T),H=1/_(f.rX),k=1/_(f.rY),N=_(G)*H+_(V)*k,R=2*V*G*(H-k),B=_(V)*H+_(G)*k,D=N*h*h-R*u*h+B*u*u,q=R*(o*h+u*l)-2*(N*l*h+B*o*u),K=N*l*l-R*o*l+B*o*o,Z=(Math.atan2(q,D-K)+Math.PI)%Math.PI/2,L=Math.sin(Z),st=Math.cos(Z);f.rX=Math.abs(S)/Math.sqrt(D*_(st)+q*L*st+K*_(L)),f.rY=Math.abs(S)/Math.sqrt(D*_(L)-q*L*st+K*_(st)),f.xRot=180*Z/Math.PI}return f.sweepFlag!==void 0&&0>S&&(f.sweepFlag=+!f.sweepFlag),f})}function a(){return function(o){var u={};for(var l in o)u[l]=o[l];return u}}t.ROUND=function(o){function u(l){return Math.round(l*o)/o}return o===void 0&&(o=1e13),et(o),function(l){return l.x1!==void 0&&(l.x1=u(l.x1)),l.y1!==void 0&&(l.y1=u(l.y1)),l.x2!==void 0&&(l.x2=u(l.x2)),l.y2!==void 0&&(l.y2=u(l.y2)),l.x!==void 0&&(l.x=u(l.x)),l.y!==void 0&&(l.y=u(l.y)),l.rX!==void 0&&(l.rX=u(l.rX)),l.rY!==void 0&&(l.rY=u(l.rY)),l}},t.TO_ABS=e,t.TO_REL=function(){return s(function(o,u,l){return o.relative||(o.x1!==void 0&&(o.x1-=u),o.y1!==void 0&&(o.y1-=l),o.x2!==void 0&&(o.x2-=u),o.y2!==void 0&&(o.y2-=l),o.x!==void 0&&(o.x-=u),o.y!==void 0&&(o.y-=l),o.relative=!0),o})},t.NORMALIZE_HVZ=function(o,u,l){return o===void 0&&(o=!0),u===void 0&&(u=!0),l===void 0&&(l=!0),s(function(h,c,p,f,d){if(isNaN(f)&&!(h.type&b.MOVE_TO))throw new Error("path must start with moveto");return u&&h.type&b.HORIZ_LINE_TO&&(h.type=b.LINE_TO,h.y=h.relative?0:p),l&&h.type&b.VERT_LINE_TO&&(h.type=b.LINE_TO,h.x=h.relative?0:c),o&&h.type&b.CLOSE_PATH&&(h.type=b.LINE_TO,h.x=h.relative?f-c:f,h.y=h.relative?d-p:d),h.type&b.ARC&&(h.rX===0||h.rY===0)&&(h.type=b.LINE_TO,delete h.rX,delete h.rY,delete h.xRot,delete h.lArcFlag,delete h.sweepFlag),h})},t.NORMALIZE_ST=n,t.QT_TO_C=r,t.INFO=s,t.SANITIZE=function(o){o===void 0&&(o=0),et(o);var u=NaN,l=NaN,h=NaN,c=NaN;return s(function(p,f,d,m,g){var v=Math.abs,y=!1,C=0,M=0;if(p.type&b.SMOOTH_CURVE_TO&&(C=isNaN(u)?0:f-u,M=isNaN(l)?0:d-l),p.type&(b.CURVE_TO|b.SMOOTH_CURVE_TO)?(u=p.relative?f+p.x2:p.x2,l=p.relative?d+p.y2:p.y2):(u=NaN,l=NaN),p.type&b.SMOOTH_QUAD_TO?(h=isNaN(h)?f:2*f-h,c=isNaN(c)?d:2*d-c):p.type&b.QUAD_TO?(h=p.relative?f+p.x1:p.x1,c=p.relative?d+p.y1:p.y2):(h=NaN,c=NaN),p.type&b.LINE_COMMANDS||p.type&b.ARC&&(p.rX===0||p.rY===0||!p.lArcFlag)||p.type&b.CURVE_TO||p.type&b.SMOOTH_CURVE_TO||p.type&b.QUAD_TO||p.type&b.SMOOTH_QUAD_TO){var x=p.x===void 0?0:p.relative?p.x:p.x-f,_=p.y===void 0?0:p.relative?p.y:p.y-d;C=isNaN(h)?p.x1===void 0?C:p.relative?p.x:p.x1-f:h-f,M=isNaN(c)?p.y1===void 0?M:p.relative?p.y:p.y1-d:c-d;var S=p.x2===void 0?0:p.relative?p.x:p.x2-f,T=p.y2===void 0?0:p.relative?p.y:p.y2-d;v(x)<=o&&v(_)<=o&&v(C)<=o&&v(M)<=o&&v(S)<=o&&v(T)<=o&&(y=!0)}return p.type&b.CLOSE_PATH&&v(f-m)<=o&&v(d-g)<=o&&(y=!0),y?[]:p})},t.MATRIX=i,t.ROTATE=function(o,u,l){u===void 0&&(u=0),l===void 0&&(l=0),et(o,u,l);var h=Math.sin(o),c=Math.cos(o);return i(c,h,-h,c,u-u*c+l*h,l-u*h-l*c)},t.TRANSLATE=function(o,u){return u===void 0&&(u=0),et(o,u),i(1,0,0,1,o,u)},t.SCALE=function(o,u){return u===void 0&&(u=o),et(o,u),i(o,0,0,u,0,0)},t.SKEW_X=function(o){return et(o),i(1,0,Math.atan(o),1,0,0)},t.SKEW_Y=function(o){return et(o),i(1,Math.atan(o),0,1,0,0)},t.X_AXIS_SYMMETRY=function(o){return o===void 0&&(o=0),et(o),i(-1,0,0,1,o,0)},t.Y_AXIS_SYMMETRY=function(o){return o===void 0&&(o=0),et(o),i(1,0,0,-1,0,o)},t.A_TO_C=function(){return s(function(o,u,l){return b.ARC===o.type?function(h,c,p){var f,d,m,g;h.cX||ae(h,c,p);for(var v=Math.min(h.phi1,h.phi2),y=Math.max(h.phi1,h.phi2)-v,C=Math.ceil(y/90),M=new Array(C),x=c,_=p,S=0;S<C;S++){var T=Qe(h.phi1,h.phi2,S/C),V=Qe(h.phi1,h.phi2,(S+1)/C),G=V-T,H=4/3*Math.tan(G*lt/4),k=[Math.cos(T*lt)-H*Math.sin(T*lt),Math.sin(T*lt)+H*Math.cos(T*lt)],N=k[0],R=k[1],B=[Math.cos(V*lt),Math.sin(V*lt)],D=B[0],q=B[1],K=[D+H*Math.sin(V*lt),q-H*Math.cos(V*lt)],Z=K[0],L=K[1];M[S]={relative:h.relative,type:b.CURVE_TO};var st=function(Mt,Tt){var Te=Me([Mt*h.rX,Tt*h.rY],h.xRot),Zn=Te[0],Fn=Te[1];return[h.cX+Zn,h.cY+Fn]};f=st(N,R),M[S].x1=f[0],M[S].y1=f[1],d=st(Z,L),M[S].x2=d[0],M[S].y2=d[1],m=st(D,q),M[S].x=m[0],M[S].y=m[1],h.relative&&(M[S].x1-=x,M[S].y1-=_,M[S].x2-=x,M[S].y2-=_,M[S].x-=x,M[S].y-=_),x=(g=[M[S].x,M[S].y])[0],_=g[1]}return M}(o,o.relative?0:u,o.relative?0:l):o})},t.ANNOTATE_ARCS=function(){return s(function(o,u,l){return o.relative&&(u=0,l=0),b.ARC===o.type&&ae(o,u,l),o})},t.CLONE=a,t.CALCULATE_BOUNDS=function(){var o=function(p){var f={};for(var d in p)f[d]=p[d];return f},u=e(),l=r(),h=n(),c=s(function(p,f,d){var m=h(l(u(o(p))));function g(L){L>c.maxX&&(c.maxX=L),L<c.minX&&(c.minX=L)}function v(L){L>c.maxY&&(c.maxY=L),L<c.minY&&(c.minY=L)}if(m.type&b.DRAWING_COMMANDS&&(g(f),v(d)),m.type&b.HORIZ_LINE_TO&&g(m.x),m.type&b.VERT_LINE_TO&&v(m.y),m.type&b.LINE_TO&&(g(m.x),v(m.y)),m.type&b.CURVE_TO){g(m.x),v(m.y);for(var y=0,C=Je(f,m.x1,m.x2,m.x);y<C.length;y++)0<(Z=C[y])&&1>Z&&g(tn(f,m.x1,m.x2,m.x,Z));for(var M=0,x=Je(d,m.y1,m.y2,m.y);M<x.length;M++)0<(Z=x[M])&&1>Z&&v(tn(d,m.y1,m.y2,m.y,Z))}if(m.type&b.ARC){g(m.x),v(m.y),ae(m,f,d);for(var _=m.xRot/180*Math.PI,S=Math.cos(_)*m.rX,T=Math.sin(_)*m.rX,V=-Math.sin(_)*m.rY,G=Math.cos(_)*m.rY,H=m.phi1<m.phi2?[m.phi1,m.phi2]:-180>m.phi2?[m.phi2+360,m.phi1+360]:[m.phi2,m.phi1],k=H[0],N=H[1],R=function(L){var st=L[0],Mt=L[1],Tt=180*Math.atan2(Mt,st)/Math.PI;return Tt<k?Tt+360:Tt},B=0,D=Ye(V,-S,0).map(R);B<D.length;B++)(Z=D[B])>k&&Z<N&&g(Ke(m.cX,S,V,Z));for(var q=0,K=Ye(G,-T,0).map(R);q<K.length;q++){var Z;(Z=K[q])>k&&Z<N&&v(Ke(m.cY,T,G,Z))}}return p});return c.minX=1/0,c.maxX=-1/0,c.minY=1/0,c.maxY=-1/0,c}})(z||(z={}));var J,In=function(){function t(){}return t.prototype.round=function(e){return this.transform(z.ROUND(e))},t.prototype.toAbs=function(){return this.transform(z.TO_ABS())},t.prototype.toRel=function(){return this.transform(z.TO_REL())},t.prototype.normalizeHVZ=function(e,n,r){return this.transform(z.NORMALIZE_HVZ(e,n,r))},t.prototype.normalizeST=function(){return this.transform(z.NORMALIZE_ST())},t.prototype.qtToC=function(){return this.transform(z.QT_TO_C())},t.prototype.aToC=function(){return this.transform(z.A_TO_C())},t.prototype.sanitize=function(e){return this.transform(z.SANITIZE(e))},t.prototype.translate=function(e,n){return this.transform(z.TRANSLATE(e,n))},t.prototype.scale=function(e,n){return this.transform(z.SCALE(e,n))},t.prototype.rotate=function(e,n,r){return this.transform(z.ROTATE(e,n,r))},t.prototype.matrix=function(e,n,r,s,i,a){return this.transform(z.MATRIX(e,n,r,s,i,a))},t.prototype.skewX=function(e){return this.transform(z.SKEW_X(e))},t.prototype.skewY=function(e){return this.transform(z.SKEW_Y(e))},t.prototype.xSymmetry=function(e){return this.transform(z.X_AXIS_SYMMETRY(e))},t.prototype.ySymmetry=function(e){return this.transform(z.Y_AXIS_SYMMETRY(e))},t.prototype.annotateArcs=function(){return this.transform(z.ANNOTATE_ARCS())},t}(),fs=function(t){return t===" "||t===" "||t==="\r"||t===`
|
|
`},en=function(t){return 48<=t.charCodeAt(0)&&t.charCodeAt(0)<=57},ps=function(t){function e(){var n=t.call(this)||this;return n.curNumber="",n.curCommandType=-1,n.curCommandRelative=!1,n.canParseCommandOrComma=!0,n.curNumberHasExp=!1,n.curNumberHasExpDigits=!1,n.curNumberHasDecimal=!1,n.curArgs=[],n}return Pn(e,t),e.prototype.finish=function(n){if(n===void 0&&(n=[]),this.parse(" ",n),this.curArgs.length!==0||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return n},e.prototype.parse=function(n,r){var s=this;r===void 0&&(r=[]);for(var i=function(c){r.push(c),s.curArgs.length=0,s.canParseCommandOrComma=!0},a=0;a<n.length;a++){var o=n[a],u=!(this.curCommandType!==b.ARC||this.curArgs.length!==3&&this.curArgs.length!==4||this.curNumber.length!==1||this.curNumber!=="0"&&this.curNumber!=="1"),l=en(o)&&(this.curNumber==="0"&&o==="0"||u);if(!en(o)||l)if(o!=="e"&&o!=="E")if(o!=="-"&&o!=="+"||!this.curNumberHasExp||this.curNumberHasExpDigits)if(o!=="."||this.curNumberHasExp||this.curNumberHasDecimal||u){if(this.curNumber&&this.curCommandType!==-1){var h=Number(this.curNumber);if(isNaN(h))throw new SyntaxError("Invalid number ending at "+a);if(this.curCommandType===b.ARC){if(this.curArgs.length===0||this.curArgs.length===1){if(0>h)throw new SyntaxError('Expected positive number, got "'+h+'" 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(h),this.curArgs.length===ds[this.curCommandType]&&(b.HORIZ_LINE_TO===this.curCommandType?i({type:b.HORIZ_LINE_TO,relative:this.curCommandRelative,x:h}):b.VERT_LINE_TO===this.curCommandType?i({type:b.VERT_LINE_TO,relative:this.curCommandRelative,y:h}):this.curCommandType===b.MOVE_TO||this.curCommandType===b.LINE_TO||this.curCommandType===b.SMOOTH_QUAD_TO?(i({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),b.MOVE_TO===this.curCommandType&&(this.curCommandType=b.LINE_TO)):this.curCommandType===b.CURVE_TO?i({type:b.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===b.SMOOTH_CURVE_TO?i({type:b.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===b.QUAD_TO?i({type:b.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===b.ARC&&i({type:b.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(!fs(o))if(o===","&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if(o!=="+"&&o!=="-"&&o!==".")if(l)this.curNumber=o,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 "'+o+'" at index '+a+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,o!=="z"&&o!=="Z")if(o==="h"||o==="H")this.curCommandType=b.HORIZ_LINE_TO,this.curCommandRelative=o==="h";else if(o==="v"||o==="V")this.curCommandType=b.VERT_LINE_TO,this.curCommandRelative=o==="v";else if(o==="m"||o==="M")this.curCommandType=b.MOVE_TO,this.curCommandRelative=o==="m";else if(o==="l"||o==="L")this.curCommandType=b.LINE_TO,this.curCommandRelative=o==="l";else if(o==="c"||o==="C")this.curCommandType=b.CURVE_TO,this.curCommandRelative=o==="c";else if(o==="s"||o==="S")this.curCommandType=b.SMOOTH_CURVE_TO,this.curCommandRelative=o==="s";else if(o==="q"||o==="Q")this.curCommandType=b.QUAD_TO,this.curCommandRelative=o==="q";else if(o==="t"||o==="T")this.curCommandType=b.SMOOTH_QUAD_TO,this.curCommandRelative=o==="t";else{if(o!=="a"&&o!=="A")throw new SyntaxError('Unexpected character "'+o+'" at index '+a+".");this.curCommandType=b.ARC,this.curCommandRelative=o==="a"}else r.push({type:b.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=o,this.curNumberHasDecimal=o==="."}else this.curNumber+=o,this.curNumberHasDecimal=!0;else this.curNumber+=o;else this.curNumber+=o,this.curNumberHasExp=!0;else this.curNumber+=o,this.curNumberHasExpDigits=this.curNumberHasExp}return r},e.prototype.transform=function(n){return Object.create(this,{parse:{value:function(r,s){s===void 0&&(s=[]);for(var i=0,a=Object.getPrototypeOf(this).parse.call(this,r);i<a.length;i++){var o=a[i],u=n(o);Array.isArray(u)?s.push.apply(s,u):s.push(u)}return s}}})},e}(In),b=function(t){function e(n){var r=t.call(this)||this;return r.commands=typeof n=="string"?e.parse(n):n,r}return Pn(e,t),e.prototype.encode=function(){return e.encode(this.commands)},e.prototype.getBounds=function(){var n=z.CALCULATE_BOUNDS();return this.transform(n),n},e.prototype.transform=function(n){for(var r=[],s=0,i=this.commands;s<i.length;s++){var a=n(i[s]);Array.isArray(a)?r.push.apply(r,a):r.push(a)}return this.commands=r,this},e.encode=function(n){return Rn(n)},e.parse=function(n){var r=new ps,s=[];return r.parse(n,s),r.finish(s),s},e.CLOSE_PATH=1,e.MOVE_TO=2,e.HORIZ_LINE_TO=4,e.VERT_LINE_TO=8,e.LINE_TO=16,e.CURVE_TO=32,e.SMOOTH_CURVE_TO=64,e.QUAD_TO=128,e.SMOOTH_QUAD_TO=256,e.ARC=512,e.LINE_COMMANDS=e.LINE_TO|e.HORIZ_LINE_TO|e.VERT_LINE_TO,e.DRAWING_COMMANDS=e.HORIZ_LINE_TO|e.VERT_LINE_TO|e.LINE_TO|e.CURVE_TO|e.SMOOTH_CURVE_TO|e.QUAD_TO|e.SMOOTH_QUAD_TO|e.ARC,e}(In),ds=((J={})[b.MOVE_TO]=2,J[b.LINE_TO]=2,J[b.HORIZ_LINE_TO]=1,J[b.VERT_LINE_TO]=1,J[b.CLOSE_PATH]=0,J[b.QUAD_TO]=4,J[b.SMOOTH_QUAD_TO]=2,J[b.CURVE_TO]=6,J[b.SMOOTH_CURVE_TO]=4,J[b.ARC]=7,J),ft;function dt(t){if(t.children!==void 0)return t.children;let e,n=0;const r=t.childNodes,s=[];for(;e=r[n++];)e.nodeType===1&&s.push(e);return s}function Ce(t){const e=t.parentNode;return e&&e.nodeType===Node.ELEMENT_NODE?e:null}function le(t,e){for(;e.firstChild;)t.append(e.firstChild);return t}function _t(t){if(t===null)return null;const e=/url\('#?(.*?)'\)/.exec(t)||/url\("#?(.*?)"\)/.exec(t)||/url\(#?(.*?)\)/.exec(t);return e&&e.length>1?e[1]:null}(function(t){t[t.SVG=0]="SVG",t[t.CANVAS=1]="CANVAS"})(ft||(ft={}));const Lt="data-sketchy-clip-path",ms=/[acsqt]/i;function Oe(t){if(t.svgSketchDefs)return t.svgSketchDefs;const e=t.svgSketch,n=document.createElementNS("http://www.w3.org/2000/svg","defs");return e.childElementCount>0?e.insertBefore(n,e.firstElementChild):e.appendChild(n),t.svgSketchDefs=n,n}function nn(t){const e=t.getAttribute("points");if(!e)return[];let n;n=e.indexOf(" ")>0?/\s+/g:/,/g;const r=e.split(n),s=[];for(let i=0;i<r.length;i++){const a=r[i],o=a.split(",");if(o.length===2)s.push({x:parseFloat(o[0]),y:parseFloat(o[1])});else{const u=i+1;u<r.length&&(s.push({x:parseFloat(a),y:parseFloat(r[u])}),i=u)}}return s}function Q(t,e,n){let r=n;const s=e.getAttribute(Lt),i=t.pencilFilter&&e.tagName!=="text";if(!(r.tagName==="g"&&r.attributes.length===0)&&(s||i)){const a=document.createElementNS("http://www.w3.org/2000/svg","g");a.appendChild(r),r=a}s&&(r.setAttribute("clip-path",`url(#${s})`),e.removeAttribute(Lt)),i&&r.setAttribute("filter","url(#pencilTextureFilter)"),t.svgSketch.appendChild(r)}function Ut(t,e,n){return ms.test(e)&&(n=n?Object.assign(Object.assign({},n),{preserveVertices:!0}):{preserveVertices:!0}),t.rc.path(e,n)}function U(t,e,n,r){let s;if(s=r?e.getAttribute(n):getComputedStyle(e)[n]||e.getAttribute(n),!s){let i=Ce(e);const a=r;let o=a;return a&&a.referenced===e&&(i=a.root,o=a.parentContext),!i||i===t.sourceSvg?void 0:U(t,i,n,o)}return s}function zn(t,e,n,r){let s;if(s=r?e.getAttribute("opacity"):getComputedStyle(e).opacity||e.getAttribute("opacity"),s){let u=1;u=s.indexOf("%")!==-1?Math.min(1,Math.max(0,parseFloat(s.substring(0,s.length-1))/100)):Math.min(1,Math.max(0,parseFloat(s))),n*=u}let i=Ce(e);const a=r;let o=a;return a&&a.referenced===e&&(i=a.root,o=a.parentContext),i&&i!==t.sourceSvg?zn(t,i,n,o):n}function bt(t,e,n){const{fillId:r,strokeId:s}=function(i,a){function o(u){const l=a.getAttribute(u);if(l&&l.indexOf("url")!==-1){const h=_t(l);if(h&&i.idElements[h]instanceof SVGPatternElement)return h}return null}return{fillId:o("fill"),strokeId:o("stroke")}}(t,e);if(r!==null||s!==null){const i=n();i.setAttribute("fill",r!==null?`url(#${r})`:"none"),i.setAttribute("stroke",s!==null?`url(#${s})`:"none");const a=U(t,e,"stroke-width",t.useElementContext);i.setAttribute("stroke-width",a??"0"),Q(t,e,i),rn(t,r),rn(t,s)}}function rn(t,e){if(e===null)return;const n=Oe(t),r=`#${e}`;if(!n.querySelector(r)){const s=t.sourceSvg.querySelector(r);if(s){if(!t.sketchPatterns)return void n.appendChild(s.cloneNode(!0));const i=function(o,u,l){const h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.appendChild(u);const c=Object.assign(Object.assign({},o),{sourceSvg:h,svgSketch:document.createElementNS("http://www.w3.org/2000/svg","svg"),roughConfig:Object.assign(Object.assign({},o.roughConfig),l)});return c.processElement(c,u,null),le(document.createElementNS("http://www.w3.org/2000/svg","g"),c.svgSketch)}(t,le(document.createElementNS("http://www.w3.org/2000/svg","g"),s.cloneNode(!0)),{fillStyle:"solid",roughness:.5}),a=s.cloneNode();n.appendChild(le(a,i))}}}const gs=/^([+-]?(?:\d+|\d*\.\d+(?:[eE][+-]?\d+)?))([a-z]*|%)$/,sn={in:96,cm:96/2.54,mm:96/25.4,pt:96/72,pc:16,px:1},vs=Math.sqrt(2);function Pt(t,e,n,r){const{value:s,unit:i}=ue(n);return function(a){return!!sn[a]}(i)?function(a,o){var u;const l=(u=sn[o])!==null&&u!==void 0?u:1;return a*l}(s,i):function(a,o,u,l,h){var c;const p=(c=a.viewBox)!==null&&c!==void 0?c:{w:0,h:0};if(h==="%")return function(f,d,{w:m,h:g}={w:0,h:0}){const v=d/100;return f==="x"?v*m:f==="y"?v*g:v*(Math.sqrt(m*m+g*g)/vs)}(u,l,p);if(h==="vw"||h==="vh"||h==="vmin"||h==="vmax")return function(f,d,{w:m,h:g}={w:0,h:0}){var v,y;const C=f/100,M=(v=window.innerWidth)!==null&&v!==void 0?v:m,x=(y=window.innerHeight)!==null&&y!==void 0?y:g;if(d==="vw")return C*M;if(d==="vh")return C*x;if(d==="vmin")return C*Math.min(M,x);if(d==="vmax")return C*Math.max(M,x);throw new Error(`Not a viewport length unit: ${d}`)}(l,h,p);if(h==="em"||h==="ex"||h==="ch"||h==="rem")return function(f,d,m,g){var v;if(g==="rem"){const x=document.documentElement,_=ue(getComputedStyle(x).fontSize);return m*(_.unit==="px"?_.value:16)}if(g==="ch"){const x=function(_){const S=Ce(_);if(!S)return 1;const T=document.createElementNS("http://www.w3.org/2000/svg","text");T.style.visibility="hidden",T.appendChild(document.createTextNode("0")),S.appendChild(T);const V=T.getBBox();return S.removeChild(T),V.width}(d);return m*x}const y=(v=U(f,d,"font-size",f.useElementContext))!==null&&v!==void 0?v:"16px",C=ue(y),M=C.unit==="px"?C.value:16;if(g==="em")return m*M;if(g==="ex")return m*M*.5;throw new Error(`Not a font relative unit: ${g}`)}(a,o,l,h);throw new Error(`Unsupported relative length unit: ${h}`)}(t,e,r,s,i)}function ue(t){const e=t.match(gs);if(e===null||e.length!==3)throw new Error(`Cannot parse dimension: ${t}`);return{value:parseFloat(e[1]),unit:e[2].toLowerCase()||"px"}}function Rt(t){if(!t)return!0;const e=t.matrix;return!e||e.a===1&&e.b===0&&e.c===0&&e.d===1&&e.e===0&&e.f===0}function he(t){if(!t)return!0;const e=t.matrix;return!e||e.a===1&&e.b===0&&e.c===0&&e.d===1}function E(t,e){if(!e)return t;const n=e.matrix;return{x:n.a*t.x+n.c*t.y+n.e,y:n.b*t.x+n.d*t.y+n.f}}function on(t){return t.transform&&t.transform.baseVal.numberOfItems>0?t.transform.baseVal.consolidate():null}function Dt(t,e,n){if(!n)return on(e);const r=on(e);if(r){const s=r.matrix,i=n.matrix.multiply(s);return t.sourceSvg.createSVGTransformFromMatrix(i)}return n}function pt(t,e,n){if(e&&e.matrix&&!Rt(e)){const r=e.matrix;n.transform.baseVal.numberOfItems>0?n.transform.baseVal.getItem(0).setMatrix(r):n.transform.baseVal.appendItem(e)}}function an(t){var e;let n=t.getAttribute("stop-color");if(!n){const r=(e=t.getAttribute("style"))!==null&&e!==void 0?e:"",s=/stop-color:\s?(.*);?/.exec(r);s&&s.length>1&&(n=s[1])}return w(n||"white")}function ln(t){const e=t.length;let n=0,r=0,s=0,i=0;return t.forEach(a=>{const o=a.toRgb();n+=o.r*o.r,r+=o.g*o.g,s+=o.b*o.b,i+=o.a}),w({r:Math.sqrt(n/e),g:Math.sqrt(r/e),b:Math.sqrt(s/e),a:i/e})}function bs(t){const e=t.getAttribute("offset");return e?e.indexOf("%")?parseFloat(e.substring(0,e.length-1)):100*parseFloat(e):0}function ys(t,e){if(t.roughConfig.fillStyle==="solid")return{angle:0,gap:0,weight:0};const{width:n,height:r}=e.getBoundingClientRect(),s=n/r,i=Math.sqrt(n*r),{angle:a,gap:o,weight:u}=function(l){const h={angle:{normal:[-30,-50],horizontal:[-30,-50],vertical:[-30,-50]},weight:{normal:[.5,3],small:[.5,3]},gap:{normal:[3,5],small:[3,5]}},c={angle:{normal:[-30,-50],horizontal:[-50,-75],vertical:[-30,-15]},weight:{normal:[1,3],small:[.5,1.7]},gap:{normal:[2,5],small:[1,3]}};switch(l){default:return c;case"zigzag":case"zigzag-line":return Object.assign(Object.assign({},c),{weight:{normal:[.5,3],small:[.5,2]},gap:{normal:[2,6],small:[2,5]}});case"cross-hatch":return Object.assign(Object.assign({},c),{weight:{normal:[1,3],small:[.5,1.3]},gap:{normal:[4,8],small:[2,5]}});case"dots":return h}}(t.roughConfig.fillStyle);return{angle:xs(t,a,s),gap:ws(t,o,i),weight:Ms(t,u,i)}}function xs({rng:t},{normal:e,horizontal:n,vertical:r},s){if(isFinite(s)){if(s<.25)return t.next(n);if(s>6)return t.next(r)}return t.next(e)}function ws({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function Ms({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function it(t,e,n){var r;const s=(r=t.roughConfig.fixedDecimalPlaceDigits)!==null&&r!==void 0?r:15,i=Object.assign({},t.roughConfig);let a=1;if(!Rt(n)){const m=n.matrix,g=m.a*m.d-m.c*m.b;a=Math.sqrt(Math.abs(g))}const o=zn(t,e,1,t.useElementContext),u=U(t,e,"fill",t.useElementContext)||"black",l=o*un(e,"fill-opacity");if(u)if(u.indexOf("url")!==-1){const m=hn(t,u,l);m!=="none"?i.fill=m:delete i.fill}else if(u==="none")delete i.fill;else{const m=w(u);m.setAlpha(l),i.fill=m.toString()}const h=U(t,e,"stroke",t.useElementContext),c=o*un(e,"stroke-opacity");if(h)if(h.indexOf("url")!==-1)i.stroke=hn(t,h,c);else if(h==="none")i.stroke="none";else{const m=w(h);m.setAlpha(c),i.stroke=m.toString()}else i.stroke="none";const p=U(t,e,"stroke-width",t.useElementContext);if(p){const m=Pt(t,e,p,"stroke-width")*a;i.strokeWidth=parseFloat(m.toFixed(s))}else i.strokeWidth=1;const f=U(t,e,"stroke-dasharray",t.useElementContext);f&&f!=="none"&&(i.strokeLineDash=f.split(/[\s,]+/).filter(m=>m.length>0).map(m=>{const g=Pt(t,e,m,"stroke-dasharray")*a;return Math.max(.5,parseFloat(g.toFixed(s)))}));const d=U(t,e,"stroke-dashoffset",t.useElementContext);if(d){const m=Pt(t,e,d,"stroke-dashoffset")*a;i.strokeLineDashOffset=parseFloat(m.toFixed(s))}if(i.fill&&i.stroke==="none"&&(i.stroke=i.fill,i.strokeWidth=1),t.randomize){const{angle:m,gap:g,weight:v}=ys(t,e);i.hachureAngle=m,i.hachureGap=Math.round(g),i.fillWeight=parseFloat(v.toFixed(s)),i.disableMultiStroke===void 0&&(i.disableMultiStroke=t.rng.next()>.3)}return i}function un(t,e){const n=getComputedStyle(t)[e]||t.getAttribute(e);return n?n.indexOf("%")!==-1?Math.min(1,Math.max(0,parseFloat(n.substring(0,n.length-1))/100)):Math.min(1,Math.max(0,parseFloat(n))):1}function hn(t,e,n){const r=_t(e);if(!r)return"none";const s=t.idElements[r];if(!s)return"none";if(typeof s=="string")return s;if(s instanceof SVGLinearGradientElement||s instanceof SVGRadialGradientElement){const i=function(a,o){const u=Array.prototype.slice.apply(a.querySelectorAll("stop"));if(u.length===0)return"transparent";if(u.length===1){const l=an(u[0]);return l.setAlpha(o),l.toString()}{const h=[];let c=null;for(let f=0;f<u.length;f++){const d=an(u[f]),m=bs(u[f]),g=c?ln([c,d]):d;let v=Math.max(1,m/10|0);for(;v>0;)h.push(g),v--;c=d}const p=ln(h);return p.setAlpha(o),p.toString()}}(s,n);return t.idElements[r]=i,i}return"none"}function O(t){return`${t.x},${t.y}`}function Gt(t,e,n,r){if(n.length===0)return;const s=n[0],i=n[n.length-1],a=_t(e.getAttribute("marker-start")),o=a?t.idElements[a]:null;if(o&&n.length>1){let p=o.orientAngle.baseVal.value;const f=n[1],d=o.getAttribute("orient");if(d==="auto"||d==="auto-start-reverse"){const y=d==="auto"?0:180,C=n[n.length-2];cn(n)?p=fe(C,i,f)-y:p=te({x:1,y:0},{x:f.x-s.x,y:f.y-s.y})-y}const m=t.sourceSvg.createSVGMatrix().translate(s.x,s.y).rotate(p).scale(ce(t,o,e)),g=r?r.matrix.multiply(m):m,v=t.sourceSvg.createSVGTransformFromMatrix(g);t.processElement(t,o,v)}const u=_t(e.getAttribute("marker-end")),l=u?t.idElements[u]:null;if(l){let p=l.orientAngle.baseVal.value;if(n.length>1){const g=l.getAttribute("orient");if(g==="auto"||g==="auto-start-reverse"){const v=n[n.length-2];cn(n)?p=fe(v,i,n[1]):p=te({x:1,y:0},{x:i.x-v.x,y:i.y-v.y})}}const f=t.sourceSvg.createSVGMatrix().translate(i.x,i.y).rotate(p).scale(ce(t,l,e)),d=r?r.matrix.multiply(f):f,m=t.sourceSvg.createSVGTransformFromMatrix(d);t.processElement(t,l,m)}const h=_t(e.getAttribute("marker-mid")),c=h?t.idElements[h]:null;if(c&&n.length>2)for(let p=0;p<n.length;p++){const f=n[p];if(p===0||p===n.length-1)continue;let d=c.orientAngle.baseVal.value;const m=c.getAttribute("orient");(m==="auto"||m==="auto-start-reverse")&&(d=fe(n[p-1],f,n[p+1]));const g=t.sourceSvg.createSVGMatrix().translate(f.x,f.y).rotate(d).scale(ce(t,c,e)),v=r?r.matrix.multiply(g):g,y=t.sourceSvg.createSVGTransformFromMatrix(v);t.processElement(t,c,y)}}function ce(t,e,n){const r=e.getAttribute("markerUnits");let s=1;if(!r||r==="strokeWidth"){const i=U(t,n,"stroke-width");i&&(s=Pt(t,n,i,"stroke-width"))}return s}function cn(t){return e=t[0],n=t[t.length-1],e.x===n.x&&e.y===n.y;var e,n}function fe(t,e,n){const r={x:n.x-e.x,y:n.y-e.y},s=te(r,{x:t.x-e.x,y:t.y-e.y}),i=e.x+1,a=e.y,o=te(r,{x:i-e.x,y:a-e.y});return((u=s)-180*Math.sign(u))/2-o;var u}function te(t,e){const n=Math.atan2(t.y,t.x),r=Math.atan2(e.y,e.x)-n,s=-Math.sign(r)*Math.PI*2,i=Math.abs(s+r)<Math.abs(r)?s+r:r;return Math.round(360*i/(2*Math.PI))}function fn(t,e,{x:n,y:r,w:s,h:i}){bt(t,e,()=>{const a=document.createElementNS("http://www.w3.org/2000/svg","rect");return a.x.baseVal.value=n,a.y.baseVal.value=r,a.width.baseVal.value=s,a.height.baseVal.value=i,a})}function Ss(t,e,n,r){const s=_t(n);if(!s)return;const i=t.idElements[s];if(!i)return;const a=Oe(t),o=`${s}_${a.childElementCount}`,u=document.createElementNS("http://www.w3.org/2000/svg","clipPath");u.id=o,function(c,p){if(c.tagName!=="g")return void c.setAttribute(Lt,p);const f=[],d=dt(c);for(let m=d.length-1;m>=0;m--)f.push(d[m]);for(;f.length>0;){const m=f.pop();m.setAttribute(Lt,p);const g=dt(m);for(let v=g.length-1;v>=0;v--)f.push(g[v])}}(e,o);const l=[],h=dt(i);for(let c=h.length-1;c>=0;c--){const p=h[c],f=Dt(t,p,r);l.push({element:p,transform:f})}for(;l.length>0;){const{element:c,transform:p}=l.pop();try{As(t,c,u,p)}catch(d){console.error(d)}if(c.tagName==="defs"||c.tagName==="svg"||c.tagName==="clipPath"||c.tagName==="text")continue;const f=dt(c);for(let d=f.length-1;d>=0;d--){const m=f[d],g=Dt(t,m,p);l.push({element:m,transform:g})}}u.childNodes.length>0&&a.appendChild(u)}function As(t,e,n,r){switch(e.tagName){case"rect":(function(s,i,a,o){const u=i.x.baseVal.value,l=i.y.baseVal.value,h=i.width.baseVal.value,c=i.height.baseVal.value;if(h===0||c===0)return;const p=i.hasAttribute("rx")?i.rx.baseVal.value:null,f=i.hasAttribute("ry")?i.ry.baseVal.value:null,d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.x.baseVal.value=u,d.y.baseVal.value=l,d.width.baseVal.value=h,d.height.baseVal.value=c,p&&(d.rx.baseVal.value=p),f&&(d.ry.baseVal.value=f),pt(0,o,d),a.appendChild(d)})(0,e,n,r);break;case"circle":(function(s,i,a,o){const u=i.cx.baseVal.value,l=i.cy.baseVal.value,h=i.r.baseVal.value;if(h===0)return;const c=document.createElementNS("http://www.w3.org/2000/svg","circle");c.cx.baseVal.value=u,c.cy.baseVal.value=l,c.r.baseVal.value=h,pt(0,o,c),a.appendChild(c)})(0,e,n,r);break;case"ellipse":(function(s,i,a,o){const u=i.cx.baseVal.value,l=i.cy.baseVal.value,h=i.rx.baseVal.value,c=i.ry.baseVal.value;if(h===0||c===0)return;const p=document.createElementNS("http://www.w3.org/2000/svg","ellipse");p.cx.baseVal.value=u,p.cy.baseVal.value=l,p.rx.baseVal.value=h,p.ry.baseVal.value=c,pt(0,o,p),a.appendChild(p)})(0,e,n,r);break;case"polygon":(function(s,i,a,o){const u=document.createElementNS("http://www.w3.org/2000/svg","polygon");u.setAttribute("points",i.getAttribute("points")),pt(0,o,u),a.appendChild(u)})(0,e,n,r);break;case"path":(function(s,i,a,o){const u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",i.getAttribute("d")),pt(0,o,u),a.appendChild(u)})(0,e,n,r)}}function Es(t,e,n){const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","text-container"),pt(0,n,r);const s=e.cloneNode(!0);s.transform.baseVal.numberOfItems>0&&s.transform.baseVal.clear(),s.removeAttribute("clip-path");const{cssFont:i,fontSize:a}=function(l,h,c=!1){const p={};let f="";const d=U(l,h,"font-style",l.useElementContext);d&&(f+=c?`font-style: ${d};`:d,p.fontStyle=d);const m=U(l,h,"font-weight",l.useElementContext);m&&(f+=c?`font-weight: ${m};`:` ${m}`,p.fontWeight=m);const g=U(l,h,"font-size",l.useElementContext);if(g&&(f+=c?`font-size: ${g};`:` ${g}`,p.fontSize=g),l.fontFamily)f+=c?`font-family: ${l.fontFamily};`:` ${l.fontFamily}`,p.fontFamiliy=l.fontFamily;else{const v=U(l,h,"font-family",l.useElementContext);v&&(f+=c?`font-family: ${v};`:` ${v}`,p.fontFamiliy=v)}return f=f.trim(),Object.assign(Object.assign({},p),{cssFont:f})}(t,e,!0);if(s.setAttribute("style",function(...l){let h="";l=l.filter(c=>c!==null);for(const c of l)h.length>0&&h[h.length-1]!==";"&&(h+=";"),h+=c;return h}(s.getAttribute("style"),i)),pn(t,e,s),s.childElementCount>0){const l=dt(s),h=dt(e);for(let c=0;c<l.length;c++){const p=l[c];p instanceof SVGTSpanElement&&pn(t,h[c],p)}}r.appendChild(s),Q(t,e,r);const o=t.fontFamily!==null,u=s.hasAttribute(Lt);o&&u&&a&&function(l,h,c,p){const{width:f,height:d}=h.getBBox();if(f<=0||d<=0)return;const m=Pt(l,c,p,"font-size");Ln(l,{w:f,h:d},c,m)}(t,e,s,a)}function Ln(t,e,n,r){const{w:s}=function({svgSketch:a,svgSketchIsInDOM:o},u){const l="visibility:hidden;position:absolute;left:-100%;top-100%;",h=a.getAttribute("style");h?a.setAttribute("style",`${h};${l}`):a.setAttribute("style",l);const c=document.body,p=a.parentElement;o||c.appendChild(a);const{width:f,height:d}=u.getBBox();return o||(c.removeChild(a),p&&p.appendChild(a)),h?a.setAttribute("style",h):a.removeAttribute("style"),{w:f,h:d}}(t,n);if(s<e.w||r<=1)return;const i=r-1;n.style.fontSize=`${i}px`,Ln(t,e,n,i)}function pn(t,e,n){const r=U(t,e,"stroke"),s=r?U(t,e,"stroke-width"):null,i=U(t,e,"fill"),a=U(t,e,"dominant-baseline"),o=U(t,e,"text-anchor",t.useElementContext);r&&n.setAttribute("stroke",r),s&&n.setAttribute("stroke-width",s),i&&n.setAttribute("fill",i),o&&n.setAttribute("text-anchor",o),a&&n.setAttribute("dominant-baseline",a)}function Dn(t,e,n,r,s){var i,a;const o=[],u={x:0,y:0,w:r??0,h:s??0};if(e instanceof SVGSVGElement||e instanceof SVGSymbolElement||e instanceof SVGMarkerElement){let l=0,h=0;if(e instanceof SVGSymbolElement)l=parseFloat((i=e.getAttribute("x"))!==null&&i!==void 0?i:"")||0,h=parseFloat((a=e.getAttribute("y"))!==null&&a!==void 0?a:"")||0,r=r??(parseFloat(e.getAttribute("width"))||void 0),s=s??(parseFloat(e.getAttribute("height"))||void 0);else if(e instanceof SVGMarkerElement){const d=e.getAttribute("markerWidth"),m=e.getAttribute("markerHeight");r=d!==null?parseFloat(d):3,s=m!==null?parseFloat(m):3}else e!==t.sourceSvg&&(l=e.x.baseVal.value,h=e.y.baseVal.value);let c=t.sourceSvg.createSVGMatrix();if(e.getAttribute("viewBox")){const{x:d,y:m,width:g,height:v}=e.viewBox.baseVal;if(u.x=d,u.y=m,u.w=g,u.h=v,r!==void 0&&s!==void 0){const y=r/g,C=s/v,M=l+.5*r,x=h+.5*s,_=d+.5*g,S=m+.5*v;c=c.translate(M,x),c=e.getAttribute("preserveAspectRatio")==="none"?c.scaleNonUniform(y,C):c.scale(Math.min(y,C)),c=c.translate(-_,-S)}}else c=c.translate(l,h);e instanceof SVGMarkerElement&&(c=c.translate(-e.refX.baseVal.value,-e.refY.baseVal.value));const p=n?n.matrix.multiply(c):c;n=t.sourceSvg.createSVGTransformFromMatrix(p);const f=dt(e);for(let d=f.length-1;d>=0;d--){const m=f[d];if(m instanceof SVGSymbolElement||m instanceof SVGMarkerElement)continue;const g=Dt(t,m,n);o.push({element:m,transform:g,viewBox:u})}}else o.push({element:e,transform:n,viewBox:u});for(;o.length>0;){const{element:l,transform:h,viewBox:c}=o.pop();try{t.viewBox=c,_s(t,l,h)}catch(f){console.error(f)}if(l.tagName==="defs"||l.tagName==="symbol"||l.tagName==="marker"||l.tagName==="svg"||l.tagName==="clipPath")continue;const p=dt(l);for(let f=p.length-1;f>=0;f--){const d=p[f],m=Dt(t,d,h);o.push({element:d,transform:m,viewBox:c})}}}function _s(t,e,n){if(function(s){const i=s.style;return!!i&&(i.display==="none"||i.visibility==="hidden")}(e))return;const r=e.getAttribute("clip-path");switch(r&&Ss(t,e,r,n),e.tagName){case"svg":case"symbol":(function(s,i,a){let o=parseFloat(i.getAttribute("width")),u=parseFloat(i.getAttribute("height"));(isNaN(o)||isNaN(u))&&(o=u=void 0),Dn(s,i,a,o,u)})(t,e,n);break;case"rect":(function(s,i,a){const o=i.x.baseVal.value,u=i.y.baseVal.value,l=i.width.baseVal.value,h=i.height.baseVal.value;if(l===0||h===0)return;let c=i.hasAttribute("rx")?Math.min(Math.max(0,i.rx.baseVal.value),l/2):null,p=i.hasAttribute("ry")?Math.min(Math.max(0,i.ry.baseVal.value),h/2):null;c===null&&p===null||(c=c===null?p:c,p=p===null?c:p);const f=E({x:o,y:u},a),d=E({x:o+l,y:u+h},a),m=d.x-f.x,g=d.y-f.y,v={x:f.x,y:f.y,w:m,h:g};if(!Rt(a)&&!he(a)||c||p){let y="";if(c!==null&&p!==null){const M=1.3333333333333333*(Math.sqrt(2)-1),x=E({x:o+c,y:u},a);y+=`M ${O(x)}`,y+=`L ${O(E({x:o+l-c,y:u},a))}`;const _=E({x:o+l-c+M*c,y:u},a),S=E({x:o+l,y:u+M*p},a),T=E({x:o+l,y:u+p},a);y+=`C ${O(_)} ${O(S)} ${O(T)}`,y+=`L ${O(E({x:o+l,y:u+h-p},a))}`;const V=E({x:o+l,y:u+h-p+M*p},a),G=E({x:o+l-M*c,y:u+h},a),H=E({x:o+l-c,y:u+h},a);y+=`C ${O(V)} ${O(G)} ${O(H)}`,y+=`L ${O(E({x:o+c,y:u+h},a))}`;const k=E({x:o+c-M*c,y:u+h},a),N=E({x:o,y:u+h-M*p},a),R=E({x:o,y:u+h-p},a);y+=`C ${O(k)} ${O(N)} ${O(R)}`,y+=`L ${O(E({x:o,y:u+p},a))}`;const B=E({x:o,y:u+M*p},a),D=E({x:o+M*c,y:u},a);y+=`C ${O(B)} ${O(D)} ${O(x)}`,y+="z"}else{const M=E({x:o,y:u},a),x=E({x:o+l,y:u},a),_=E({x:o+l,y:u+h},a),S=E({x:o,y:u+h},a);y+=`M ${O(M)}`,y+=`L ${O(x)}`,y+=`L ${O(_)}`,y+=`L ${O(S)}`,y+="z"}const C=Ut(s,y,it(s,i,a));fn(s,i,v),Q(s,i,C)}else{const y=s.rc.rectangle(v.x,v.y,v.w,v.h,it(s,i,a));fn(s,i,v),Q(s,i,y)}})(t,e,n);break;case"path":(function(s,i,a){const o=i.getAttribute("d"),u=new b(o).toAbs().transform(z.NORMALIZE_HVZ()).transform(z.NORMALIZE_ST()),l=new b(u.commands.map(d=>Object.assign({},d)));a&&l.transform(z.MATRIX(a.matrix.a,a.matrix.b,a.matrix.c,a.matrix.d,a.matrix.e,a.matrix.f));const h=Rn(l.commands);if(h.indexOf("undefined")!==-1)return void console.error("broken path data");const c=Ut(s,h,it(s,i,a));bt(s,i,()=>{const d=document.createElementNS("http://www.w3.org/2000/svg","path");return d.setAttribute("d",h),d}),Q(s,i,c);const p=[];let f;u.commands.forEach(d=>{switch(d.type){case b.MOVE_TO:{const m={x:d.x,y:d.y};p.push(m),f=m;break}case b.LINE_TO:case b.QUAD_TO:case b.SMOOTH_QUAD_TO:case b.CURVE_TO:case b.SMOOTH_CURVE_TO:case b.ARC:p.push({x:d.x,y:d.y});break;case b.HORIZ_LINE_TO:p.push({x:d.x,y:0});break;case b.VERT_LINE_TO:p.push({x:0,y:d.y});break;case b.CLOSE_PATH:f&&p.push(f)}}),Gt(s,i,p,a)})(t,e,n);break;case"use":(function(s,i,a){let o=i.href.baseVal;o.startsWith("#")&&(o=o.substring(1));const u=s.idElements[o];if(u){let l,h;i.getAttribute("width")&&i.getAttribute("height")&&(l=i.width.baseVal.value,h=i.height.baseVal.value);const c=i.x.baseVal.value,p=i.y.baseVal.value;let f=s.sourceSvg.createSVGMatrix().translate(c,p);f=a?a.matrix.multiply(f):f;const d=s.sourceSvg.createSVGTransformFromMatrix(f);if(s.useElementContext){const m={root:i,referenced:u,parentContext:Object.assign({},s.useElementContext)};s.useElementContext=m}else s.useElementContext={root:i,referenced:u,parentContext:null};s.processElement(s,u,Dt(s,u,d),l,h),s.useElementContext.parentContext?s.useElementContext=s.useElementContext.parentContext:s.useElementContext=null}})(t,e,n);break;case"line":(function(s,i,a){const o={x:i.x1.baseVal.value,y:i.y1.baseVal.value},u={x:i.x2.baseVal.value,y:i.y2.baseVal.value},{x:l,y:h}=E(o,a),{x:c,y:p}=E(u,a);if(l===c&&h===p)return;const f=s.rc.line(l,h,c,p,it(s,i,a));bt(s,i,()=>{const d=document.createElementNS("http://www.w3.org/2000/svg","line");return d.x1.baseVal.value=l,d.y1.baseVal.value=h,d.x2.baseVal.value=c,d.y2.baseVal.value=p,d}),Q(s,i,f),Gt(s,i,[o,u],a)})(t,e,n);break;case"circle":(function(s,i,a){const o=i.cx.baseVal.value,u=i.cy.baseVal.value,l=i.r.baseVal.value;if(l===0)return;const h=E({x:o,y:u},a),c=E({x:o+l,y:u+l},a).x-h.x;let p;if(Rt(a)||he(a))p=s.rc.circle(h.x,h.y,2*c,Object.assign(Object.assign({},it(s,i,a)),{preserveVertices:!0}));else{const f=1.3333333333333333*(Math.sqrt(2)-1),d=E({x:o+l,y:u},a),m=E({x:o,y:u+l},a),g=E({x:o-l,y:u},a),v=E({x:o,y:u-l},a),y=E({x:o+l,y:u+f*l},a),C=E({x:o+f*l,y:u+l},a),M=E({x:o-l,y:u+f*l},a),x=E({x:o-f*l,y:u-l},a),_=E({x:o+l,y:u-f*l},a);p=Ut(s,`M ${O(d)} C ${O(y)} ${O(C)} ${O(m)} S ${O(M)} ${O(g)} S ${O(x)} ${O(v)} S ${O(_)} ${O(d)}z`,it(s,i,a))}bt(s,i,()=>{const f=document.createElementNS("http://www.w3.org/2000/svg","circle");return f.cx.baseVal.value=h.x,f.cy.baseVal.value=h.y,f.r.baseVal.value=c,f}),Q(s,i,p)})(t,e,n);break;case"ellipse":(function(s,i,a){const o=i.cx.baseVal.value,u=i.cy.baseVal.value,l=i.rx.baseVal.value,h=i.ry.baseVal.value;if(l===0||h===0)return;const c=E({x:o,y:u},a),p=E({x:o+l,y:u+h},a),f=p.x-c.x,d=p.y-c.y;let m;if(Rt(a)||he(a))m=s.rc.ellipse(c.x,c.y,2*f,2*d,Object.assign(Object.assign({},it(s,i,a)),{preserveVertices:!0}));else{const g=1.3333333333333333*(Math.sqrt(2)-1),v=E({x:o+l,y:u},a),y=E({x:o,y:u+h},a),C=E({x:o-l,y:u},a),M=E({x:o,y:u-h},a),x=E({x:o+l,y:u+g*h},a),_=E({x:o+g*l,y:u+h},a),S=E({x:o-l,y:u+g*h},a),T=E({x:o-g*l,y:u-h},a),V=E({x:o+l,y:u-g*h},a);m=Ut(s,`M ${O(v)} C ${O(x)} ${O(_)} ${O(y)} S ${O(S)} ${O(C)} S ${O(T)} ${O(M)} S ${O(V)} ${O(v)}z`,it(s,i,a))}bt(s,i,()=>{const g=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return g.cx.baseVal.value=c.x,g.cy.baseVal.value=c.y,g.rx.baseVal.value=f,g.ry.baseVal.value=d,g}),Q(s,i,m)})(t,e,n);break;case"polyline":(function(s,i,a){const o=nn(i),u=o.map(h=>{const c=E(h,a);return[c.x,c.y]}),l=it(s,i,a);if(bt(s,i,()=>{const h=document.createElementNS("http://www.w3.org/2000/svg","polyline");return h.setAttribute("points",u.join(" ")),h}),l.fill&&l.fill!=="none"){const h=Object.assign(Object.assign({},l),{stroke:"none"});Q(s,i,s.rc.polygon(u,h))}Q(s,i,s.rc.linearPath(u,l)),Gt(s,i,o,a)})(t,e,n);break;case"polygon":(function(s,i,a){const o=nn(i),u=o.map(h=>{const c=E(h,a);return[c.x,c.y]}),l=s.rc.polygon(u,it(s,i,a));bt(s,i,()=>{const h=document.createElementNS("http://www.w3.org/2000/svg","polygon");return h.setAttribute("points",u.join(" ")),h}),Q(s,i,l),o.length>0&&(o.push(o[0]),Gt(s,i,o,a))})(t,e,n);break;case"text":Es(t,e,n);break;case"image":(function(s,i,a){const o=i.href.baseVal,u=i.x.baseVal.value,l=i.y.baseVal.value;let h,c;if(i.getAttribute("width")&&i.getAttribute("height")&&(h=i.width.baseVal.value,c=i.height.baseVal.value),o.startsWith("data:")&&o.indexOf("image/svg+xml")!==-1){const p=/^data:([^,]*),(.*)/.exec(o);if(p&&p.length>2){const f=p[1];let d=p[2];const m=f.indexOf("base64")!==-1,g=f.indexOf("utf8")!==-1;m&&(d=atob(d)),g||(d=decodeURIComponent(d));const v=new DOMParser().parseFromString(d,"image/svg+xml").firstChild;let y=s.sourceSvg.createSVGMatrix().translate(u,l);y=a?a.matrix.multiply(y):y,s.processElement(s,v,s.sourceSvg.createSVGTransformFromMatrix(y),h,c)}}else{const p=i.cloneNode(),f=document.createElementNS("http://www.w3.org/2000/svg","g");pt(0,a,f),f.appendChild(p),Q(s,i,f)}})(t,e,n);break;case"foreignObject":(function(s,i,a){const o=i.cloneNode(!0),u=document.createElementNS("http://www.w3.org/2000/svg","g"),l=["color","font-family","font-size","font-style","font-variant","font-weight"],h=getComputedStyle(i);for(const c of l)u.style.setProperty(c,h.getPropertyValue(c));o.transform.baseVal.clear(),pt(0,a,u),u.appendChild(o),Q(s,o,u)})(t,e,n)}}class Cs{constructor(e){this.rng=e?new Mn(e):null}next(e){var n,r;const s=(r=(n=this.rng)===null||n===void 0?void 0:n.next())!==null&&r!==void 0?r:Math.random();if(e){const i=e[0];return s*(e[1]-i)+i}return s}}class Os{set svg(e){this.$svg!==e&&(this.$svg=e,this.sourceSvgChanged())}get svg(){return this.$svg}set outputType(e){if(this.$outputType!==e){if(e===ft.CANVAS&&this.outputElement instanceof SVGSVGElement||e===ft.SVG&&this.outputElement instanceof HTMLCanvasElement)throw new Error(`Output format ${e} incompatible with given output element ${this.outputElement.tagName}`);this.$outputType=e}}get outputType(){return this.$outputType}set roughConfig(e){e.fixedDecimalPlaceDigits===void 0&&(e.fixedDecimalPlaceDigits=3),this.$roughConfig=e}get roughConfig(){return this.$roughConfig}constructor(e,n=ft.SVG,r={}){if(this.backgroundColor=null,this.fontFamily="Comic Sans MS, cursive",this.randomize=!0,this.seed=null,this.sketchPatterns=!0,this.pencilFilter=!1,this.width=0,this.height=0,this.$roughConfig={},this.idElements={},this.lastResult=null,!e)throw new Error("No target provided");const s=typeof e=="string"?document.querySelector(e):e;if(!s)throw new Error("Could not find target in document");this.roughConfig=r,this.outputElement=s,s instanceof HTMLCanvasElement?this.$outputType=ft.CANVAS:s instanceof SVGSVGElement?this.$outputType=ft.SVG:this.$outputType=n}sketch(e=!1){var n,r;if(!this.svg)return Promise.resolve(null);e&&this.sourceSvgChanged();const s=this.prepareRenderContainer(),i=this.createRenderContext(s);if(this.pencilFilter&&Oe(i).appendChild(function(){const a=document.createElementNS("http://www.w3.org/2000/svg","filter");a.setAttribute("id","pencilTextureFilter"),a.setAttribute("x","0%"),a.setAttribute("y","0%"),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("filterUnits","objectBoundingBox");const o=document.createElementNS("http://www.w3.org/2000/svg","feTurbulence");o.setAttribute("type","fractalNoise"),o.setAttribute("baseFrequency","2"),o.setAttribute("numOctaves","5"),o.setAttribute("stitchTiles","stitch"),o.setAttribute("result","f1"),a.appendChild(o);const u=document.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");u.setAttribute("type","matrix"),u.setAttribute("values","0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -1.5 1.5"),u.setAttribute("result","f2"),a.appendChild(u);const l=document.createElementNS("http://www.w3.org/2000/svg","feComposite");return l.setAttribute("operator","in"),l.setAttribute("in","SourceGraphic"),l.setAttribute("in2","f2"),l.setAttribute("result","f3"),a.appendChild(l),a}()),i.processElement(i,this.svg,null,this.width,this.height),this.outputElement instanceof SVGSVGElement)return Promise.resolve(this.outputElement);if(this.outputElement instanceof HTMLCanvasElement)return this.drawToCanvas(i,this.outputElement);if((r=(n=this.lastResult)===null||n===void 0?void 0:n.parentNode)===null||r===void 0||r.removeChild(this.lastResult),this.outputType===ft.SVG){const a=i.svgSketch;return this.outputElement.appendChild(a),this.lastResult=a,Promise.resolve(a)}{const a=document.createElement("canvas");return this.outputElement.appendChild(a),this.lastResult=a,this.drawToCanvas(i,a)}}createRenderContext(e){if(!this.svg)throw new Error("No source SVG set yet.");let n=this.roughConfig;return this.seed!==null&&(n=Object.assign({seed:this.seed},n)),{rc:Hr.svg(e,{options:n}),roughConfig:this.roughConfig,fontFamily:this.fontFamily,pencilFilter:this.pencilFilter,randomize:this.randomize,rng:new Cs(this.seed),sketchPatterns:this.sketchPatterns,idElements:this.idElements,sourceSvg:this.svg,svgSketch:e,svgSketchIsInDOM:document.body.contains(e),styleSheets:Array.from(this.svg.querySelectorAll("style")).map(r=>r.sheet).filter(r=>r!==null),processElement:Dn}}drawToCanvas(e,n){n.width=this.width,n.height=this.height;const r=n.getContext("2d");return r.clearRect(0,0,this.width,this.height),new Promise(s=>{const i=new XMLSerializer().serializeToString(e.svgSketch),a=new Image;a.onload=function(){r.drawImage(this,0,0),s(n)},a.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(i)}`})}prepareRenderContainer(){let e,n;for(e=this.outputElement instanceof SVGSVGElement?this.outputElement:document.createElementNS("http://www.w3.org/2000/svg","svg"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");e.firstChild;)e.removeChild(e.firstChild);return e.setAttribute("width",this.width.toString()),e.setAttribute("height",this.height.toString()),this.backgroundColor&&(n=document.createElementNS("http://www.w3.org/2000/svg","rect"),n.width.baseVal.value=this.width,n.height.baseVal.value=this.height,n.setAttribute("fill",this.backgroundColor),e.appendChild(n)),e.setAttribute("stroke-linecap","round"),e}sourceSvgChanged(){const e=this.$svg;if(e){const n=this.roughConfig.fixedDecimalPlaceDigits;this.width=parseFloat(this.coerceSize(e,"width",300).toFixed(n)),this.height=parseFloat(this.coerceSize(e,"height",150).toFixed(n)),this.collectElementsWithID()}}collectElementsWithID(){this.idElements={};const e=Array.prototype.slice.apply(this.svg.querySelectorAll("*[id]"));for(const n of e){const r=n.getAttribute("id");r&&(this.idElements[r]=n)}}coerceSize(e,n,r){let s=r;const i=e.hasAttribute("viewBox");return e.hasAttribute(n)?s=e[n].baseVal.unitType===SVGLength.SVG_LENGTHTYPE_PERCENTAGE&&i?e.viewBox.baseVal[n]:e[n].baseVal.value:i&&(s=e.viewBox.baseVal[n]),s}}function dn(t){let e,n,r,s;function i(u,l){return u[5].autoSync?ks:Ts}let a=i(t),o=a(t);return{c(){e=Ct("div"),n=yt("Diagram out of sync. "),r=Ct("br"),s=mn(),o.c(),this.h()},l(u){e=Ot(u,"DIV",{class:!0,id:!0});var l=It(e);n=xt(l,"Diagram out of sync. "),r=Ot(l,"BR",{}),s=gn(l),o.l(l),l.forEach(W),this.h()},h(){wt(e,"class","font-monotext-yellow-600 absolute z-10 w-full bg-base-100 bg-opacity-80 p-2 text-left"),wt(e,"id","errorContainer")},m(u,l){ut(u,e,l),Et(e,n),Et(e,r),Et(e,s),o.m(e,null)},p(u,l){a!==(a=i(u))&&(o.d(1),o=a(u),o&&(o.c(),o.m(e,null)))},d(u){u&&W(e),o.d()}}}function Ts(t){let e,n,r,s,i,a,o;return{c(){e=yt("Press "),n=Ct("i"),r=yt(" (Sync button) or "),s=Ct("kbd"),i=yt(Ie),a=yt(" + Enter"),o=yt(" to sync."),this.h()},l(u){e=xt(u,"Press "),n=Ot(u,"I",{class:!0}),It(n).forEach(W),r=xt(u," (Sync button) or "),s=Ot(u,"KBD",{});var l=It(s);i=xt(l,Ie),a=xt(l," + Enter"),l.forEach(W),o=xt(u," to sync."),this.h()},h(){wt(n,"class","fas fa-sync")},m(u,l){ut(u,e,l),ut(u,n,l),ut(u,r,l),ut(u,s,l),Et(s,i),Et(s,a),ut(u,o,l)},d(u){u&&(W(e),W(n),W(r),W(s),W(o))}}}function ks(t){let e;return{c(){e=yt("It will be updated automatically.")},l(n){e=xt(n,"It will be updated automatically.")},m(n,r){ut(n,e,r)},d(n){n&&W(e)}}}function Ns(t){let e,n,r,s=t[3]&&dn(t);return{c(){s&&s.c(),e=mn(),n=Ct("div"),r=Ct("div"),this.h()},l(i){s&&s.l(i),e=gn(i),n=Ot(i,"DIV",{id:!0,class:!0});var a=It(n);r=Ot(a,"DIV",{id:!0,class:!0}),It(r).forEach(W),a.forEach(W),this.h()},h(){wt(r,"id","container"),wt(r,"class","h-full overflow-auto svelte-1ewr4tw"),St(r,"hide",t[4]),wt(n,"id","view"),wt(n,"class","h-full p-2 svelte-1ewr4tw"),St(n,"error",t[2]),St(n,"outOfSync",t[3])},m(i,a){s&&s.m(i,a),ut(i,e,a),ut(i,n,a),Et(n,r),t[6](r),t[7](n)},p(i,[a]){i[3]?s?s.p(i,a):(s=dn(i),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null),a&16&&St(r,"hide",i[4]),a&4&&St(n,"error",i[2]),a&8&&St(n,"outOfSync",i[3])},i:ke,o:ke,d(i){i&&(W(e),W(n)),s&&s.d(i),t[6](null),t[7](null)}}}function Vs(t,e,n){let r,s;Ne(t,pe,x=>n(5,r=x)),Ne(t,re,x=>n(14,s=x));let i="",a="",o,u,l,h=!1,c=!1,p=!1,f=!0,d=r.panZoom,m;const g=()=>{if(!m)return;const x=m.getPan(),_=m.getZoom();Yn({pan:x,zoom:_}),Qn("panZoom")},v=x=>{x.panZoom&&(n(4,p=!0),m==null||m.destroy(),m=void 0,Promise.resolve().then(()=>{const _=document.querySelector("#graph-div");if(!_)return;m=hr(_,{onPan:g,onZoom:g,controlIconsEnabled:!0,fit:!0,center:!0});const{pan:S,zoom:T}=x;S!==void 0&&T!==void 0&&Number.isFinite(T)&&(m.zoom(T),m.pan(S)),n(4,p=!1)}))},y=async x=>{var T;const _=Date.now();if(x.error!==void 0){n(2,h=!0);return}n(2,h=!1);try{if(o&&x&&(x.updateDiagram||x.autoSync)){if(x.autoSync||Ve(re,s.updateDiagram=!1,s),n(3,c=!1),f=!0,i===x.code&&a===x.mermaid&&d===x.panZoom&&u===x.rough)return;if(!er()){n(3,c=!0);return}i=x.code,a=x.mermaid,d=x.panZoom,u=x.rough;const V=(T=l.parentElement)==null?void 0:T.scrollTop;delete o.dataset.processed;const{svg:G,bindFunctions:H}=await jn(Object.assign({},JSON.parse(x.mermaid)),i,"graph-div");if(G.length>0){v(x),n(0,o.innerHTML=G,o);const k=document.querySelector("#graph-div");if(!k)throw new Error("graph-div not found");if(x.rough){const N=new Os("#container");N.svg=k,await N.sketch(),k.remove();const R=document.querySelector("#container > svg");if(!R)throw new Error("sketch not found");const B=R.getAttribute("height"),D=R.getAttribute("width");R.setAttribute("height","100%"),R.setAttribute("width","100%"),R.setAttribute("viewBox",`0 0 ${D} ${B}`),R.style.maxWidth="100%"}else k.setAttribute("height","100%"),k.style.maxWidth="100%",H&&H(k)}l.parentElement&&V&&n(1,l.parentElement.scrollTop=V,l),n(2,h=!1)}else f?f=!1:(i!==x.code||a!==x.mermaid)&&n(3,c=!0)}catch(V){console.error("view fail",V),n(2,h=!0)}const S=Date.now()-_;Xn({code:i,renderTime:S,isRough:x.rough}),tr(S,()=>{Ve(re,s.updateDiagram=!0,s)})};Un(()=>{pe.subscribe(x=>{y(x)}),window.addEventListener("resize",()=>{r.panZoom&&m&&m.resize()})});function C(x){Pe[x?"unshift":"push"](()=>{o=x,n(0,o)})}function M(x){Pe[x?"unshift":"push"](()=>{l=x,n(1,l)})}return[o,l,h,c,p,r,C,M]}class Ls extends Gn{constructor(e){super(),qn(this,e,Vs,Ns,Bn,{})}}export{Ls as V,zs as w};
|