Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
modules/chart_engine/static/lib/d3-sankey.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// https://github.com/d3/d3-sankey v0.12.3 Copyright 2019 Mike Bostock
|
| 2 |
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-shape"],t):t((n=n||self).d3=n.d3||{},n.d3,n.d3)}(this,function(n,t,e){"use strict";function o(n){return n.target.depth}function r(n,t){return n.sourceLinks.length?n.depth:t-1}function i(n){return function(){return n}}function s(n,t){return u(n.source,t.source)||n.index-t.index}function f(n,t){return u(n.target,t.target)||n.index-t.index}function u(n,t){return n.y0-t.y0}function c(n){return n.value}function l(n){return n.index}function a(n){return n.nodes}function d(n){return n.links}function h(n,t){const e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function g({nodes:n}){for(const t of n){let n=t.y0,e=n;for(const e of t.sourceLinks)e.y0=n+e.width/2,n+=e.width;for(const n of t.targetLinks)n.y1=e+n.width/2,e+=n.width}}function y(n){return[n.source.x1,n.y0]}function k(n){return[n.target.x0,n.y1]}n.sankey=function(){let n,e,o,y=0,k=0,L=1,p=1,w=24,x=8,m=l,v=r,M=a,b=d,S=6;function z(){const r={nodes:M.apply(null,arguments),links:b.apply(null,arguments)};return function({nodes:n,links:t}){for(const[t,e]of n.entries())e.index=t,e.sourceLinks=[],e.targetLinks=[];const e=new Map(n.map((t,e)=>[m(t,e,n),t]));for(const[n,o]of t.entries()){o.index=n;let{source:t,target:r}=o;"object"!=typeof t&&(t=o.source=h(e,t)),"object"!=typeof r&&(r=o.target=h(e,r)),t.sourceLinks.push(o),r.targetLinks.push(o)}if(null!=o)for(const{sourceLinks:t,targetLinks:e}of n)t.sort(o),e.sort(o)}(r),function({nodes:n}){for(const e of n)e.value=void 0===e.fixedValue?Math.max(t.sum(e.sourceLinks,c),t.sum(e.targetLinks,c)):e.fixedValue}(r),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.depth=r;for(const{target:t}of n.sourceLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(r),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.height=r;for(const{source:t}of n.targetLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(r),function(o){const r=function({nodes:n}){const o=t.max(n,n=>n.depth)+1,r=(L-y-w)/(o-1),i=new Array(o);for(const t of n){const n=Math.max(0,Math.min(o-1,Math.floor(v.call(null,t,o))));t.layer=n,t.x0=y+n*r,t.x1=t.x0+w,i[n]?i[n].push(t):i[n]=[t]}if(e)for(const n of i)n.sort(e);return i}(o);n=Math.min(x,(p-k)/(t.max(r,n=>n.length)-1)),function(e){const o=t.min(e,e=>(p-k-(e.length-1)*n)/t.sum(e,c));for(const t of e){let e=k;for(const r of t){r.y0=e,r.y1=e+r.value*o,e=r.y1+n;for(const n of r.sourceLinks)n.width=n.value*o}e=(p-e+n)/(t.length+1);for(let n=0;n<t.length;++n){const o=t[n];o.y0+=e*(n+1),o.y1+=e*(n+1)}V(t)}}(r);for(let n=0;n<S;++n){const t=Math.pow(.99,n),e=Math.max(1-t,(n+1)/S);E(r,t,e),j(r,t,e)}}(r),g(r),r}function j(n,t,o){for(let r=1,i=n.length;r<i;++r){const i=n[r];for(const n of i){let e=0,o=0;for(const{source:t,value:r}of n.targetLinks){let i=r*(n.layer-t.layer);e+=_(t,n)*i,o+=i}if(!(o>0))continue;let r=(e/o-n.y0)*t;n.y0+=r,n.y1+=r,P(n)}void 0===e&&i.sort(u),q(i,o)}}function E(n,t,o){for(let r=n.length-2;r>=0;--r){const i=n[r];for(const n of i){let e=0,o=0;for(const{target:t,value:r}of n.sourceLinks){let i=r*(t.layer-n.layer);e+=C(n,t)*i,o+=i}if(!(o>0))continue;let r=(e/o-n.y0)*t;n.y0+=r,n.y1+=r,P(n)}void 0===e&&i.sort(u),q(i,o)}}function q(t,e){const o=t.length>>1,r=t[o];H(t,r.y0-n,o-1,e),A(t,r.y1+n,o+1,e),H(t,p,t.length-1,e),A(t,k,0,e)}function A(t,e,o,r){for(;o<t.length;++o){const i=t[o],s=(e-i.y0)*r;s>1e-6&&(i.y0+=s,i.y1+=s),e=i.y1+n}}function H(t,e,o,r){for(;o>=0;--o){const i=t[o],s=(i.y1-e)*r;s>1e-6&&(i.y0-=s,i.y1-=s),e=i.y0-n}}function P({sourceLinks:n,targetLinks:t}){if(void 0===o){for(const{source:{sourceLinks:n}}of t)n.sort(f);for(const{target:{targetLinks:t}}of n)t.sort(s)}}function V(n){if(void 0===o)for(const{sourceLinks:t,targetLinks:e}of n)t.sort(f),e.sort(s)}function _(t,e){let o=t.y0-(t.sourceLinks.length-1)*n/2;for(const{target:r,width:i}of t.sourceLinks){if(r===e)break;o+=i+n}for(const{source:n,width:r}of e.targetLinks){if(n===t)break;o-=r}return o}function C(t,e){let o=e.y0-(e.targetLinks.length-1)*n/2;for(const{source:r,width:i}of e.targetLinks){if(r===t)break;o+=i+n}for(const{target:n,width:r}of t.sourceLinks){if(n===e)break;o-=r}return o}return z.update=function(n){return g(n),n},z.nodeId=function(n){return arguments.length?(m="function"==typeof n?n:i(n),z):m},z.nodeAlign=function(n){return arguments.length?(v="function"==typeof n?n:i(n),z):v},z.nodeSort=function(n){return arguments.length?(e=n,z):e},z.nodeWidth=function(n){return arguments.length?(w=+n,z):w},z.nodePadding=function(t){return arguments.length?(x=n=+t,z):x},z.nodes=function(n){return arguments.length?(M="function"==typeof n?n:i(n),z):M},z.links=function(n){return arguments.length?(b="function"==typeof n?n:i(n),z):b},z.linkSort=function(n){return arguments.length?(o=n,z):o},z.size=function(n){return arguments.length?(y=k=0,L=+n[0],p=+n[1],z):[L-y,p-k]},z.extent=function(n){return arguments.length?(y=+n[0][0],L=+n[1][0],k=+n[0][1],p=+n[1][1],z):[[y,k],[L,p]]},z.iterations=function(n){return arguments.length?(S=+n,z):S},z},n.sankeyCenter=function(n){return n.targetLinks.length?n.depth:n.sourceLinks.length?t.min(n.sourceLinks,o)-1:0},n.sankeyJustify=r,n.sankeyLeft=function(n){return n.depth},n.sankeyLinkHorizontal=function(){return e.linkHorizontal().source(y).target(k)},n.sankeyRight=function(n,t){return t-1-n.height},Object.defineProperty(n,"__esModule",{value:!0})});
|
modules/chart_engine/static/lib/d3-voronoi-map.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-polygon"),require("d3-timer"),require("d3-dispatch"),require("d3-weighted-voronoi")):"function"==typeof define&&define.amd?define(["exports","d3-polygon","d3-timer","d3-dispatch","d3-weighted-voronoi"],n):n(t.d3=t.d3||{},t.d3,t.d3,t.d3,t.d3)}(this,function(t,n,e,r,i){"use strict";function o(){this.growthChangesLength=p,this.totalAvailableArea=NaN,this.lastAreaError=NaN,this.lastGrowth=NaN,this.growthChanges=[],this.growthChangeWeights=h(this.growthChangesLength),this.growthChangeWeightsSum=s(this.growthChangeWeights)}function a(t,n){return t>=n?1:-1}function h(t){for(var n=3,e=1,r=1,i=n,o=[],a=0;a<t;a++)o.push(i),i-=e,i<r&&(i=r);return o}function s(t){for(var n=0,e=0;e<t.length;e++)n+=t[e];return n}function g(){function t(t,a,s,l){var c,f,p=!1;for(r!==l.clip()&&(r=l.clip(),i=l.extent(),p=!0),p&&e(),c=o+g*l.prng()(),f=h+u*l.prng()();!n.polygonContains(r,[c,f]);)c=o+g*l.prng()(),f=h+u*l.prng()();return[c,f]}function e(){o=i[0][0],a=i[1][0],h=i[0][1],s=i[1][1],g=a-o,u=s-h}var r,i,o,a,h,s,g,u;return t}function u(){function t(t,n,r,i){var h=!1;return o!==i.clip()&&(o=i.clip(),h|=!0),a!==r&&(a=r,h|=!0),h&&e(),[s[0]+Math.cos(l+n*u)*g+.001*(i.prng()()-.5),s[1]+Math.sin(l+n*u)*g+.001*(i.prng()()-.5)]}function e(){s=n.polygonCentroid(o),g=r(s,o)/2,h=a.length,u=2*Math.PI/h}function r(t,n){for(var e,r=1/0,o=0,a=n[n.length-1],h=n[o];o<n.length;)e=i(t,a,h),e<r&&(r=e),o++,a=h,h=n[o];return r}function i(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1],h=e[0],s=e[1],g=r-o,u=i-a,l=h-o,c=s-a,f=g*l+u*c,p=l*l+c*c,w=-1;0!=p&&(w=f/p);var d,v;w<0?(d=o,v=a):w>1?(d=h,v=s):(d=o+w*l,v=a+w*c);var C=r-d,y=i-v;return Math.sqrt(C*C+y*y)}var o,a,h,s,g,u,l=0;return t.startAngle=function(n){return arguments.length?(l=n,t):l},t}function l(){function t(t,n,o,a){var s=!1;return r!==a.clip()&&(r=a.clip(),s|=!0),i!==o&&(i=o,s|=!0),s&&e(),h}function e(){o=i.length,a=n.polygonArea(r),h=a/o/2}var r,i,o,a,h;return t}function c(t){this.message=t,this.stack=(new Error).stack}function f(t){function a(t){return Math.pow(t,2)}function h(t,n){return a(n.x-t.x)+a(n.y-t.y)}function s(){u(),U.call("tick",P),k&&(T.stop(),U.call("end",P))}function u(){k||(Q&&f(),W=d(W,K.ratio()),b++,E=A(W),K.add(E),L=E<N,k=L||b>=V)}function f(){m(),M=t.length,x=Math.abs(n.polygonArea(J.clip())),N=z*x,K.clear().totalArea(x),b=0,L=!1,W=p(t,P),k=!1,Q=!1}function p(t,n){var e,r,i=t.reduce(function(t,n){return Math.max(t,R(n))},-(1/0)),o=i*_;return e=t.map(function(t,e,r){return{index:e,weight:Math.max(R(t),o),initialPosition:B(t,e,r,n),initialWeight:H(t,e,r,n),originalData:t}}),r=w(e,n),Y(r),J(r)}function w(t,e){var r,i=t.reduce(function(t,n){return t+=n.weight},0);return t.map(function(t,o,a){return r=t.initialPosition,n.polygonContains(J.clip(),r)||(r=q(t,o,a,e)),{index:t.index,targetedArea:x*t.weight/i,data:t,x:r[0],y:r[1],weight:t.initialWeight}})}function d(t,n){var e;if(v(t,n),e=t.map(function(t){return t.site.originalObject}),t=J(e),t.length<M)throw new c("at least 1 site has no area, which is not supposed to arise");if(C(t,n),e=t.map(function(t){return t.site.originalObject}),t=J(e),t.length<M)throw new c("at least 1 site has no area, which is not supposed to arise");return t}function v(t,e){var r,i,o,a,h,s,g,u=[],l=.5;r=l*e,i=1-r;for(var c=0;c<M;c++)o=t[c],a=o.site.originalObject,h=n.polygonCentroid(o),s=h[0]-a.x,g=h[1]-a.y,s*=i,g*=i,a.x+=s,a.y+=g,u.push(a);Y(u)}function C(t,e){var r,i,o,a,h,s,g=[],u=.1;r=u*e;for(var l=0;l<M;l++)i=t[l],o=i.site.originalObject,a=n.polygonArea(i),h=o.targetedArea/a,h=Math.max(h,1-u+r),h=Math.min(h,1+u-r),s=o.weight*h,s=Math.max(s,F),o.weight=s,g.push(o);Y(g)}function y(t){var n,e,r,i,o,a,s,g=0;do{if(g>X)throw new c("handleOverweighted1 is looping too much");n=!1;for(var u=0;u<M;u++){e=t[u];for(var l=u+1;l<M;l++)if(r=t[l],e.weight>r.weight?(i=e,o=r):(i=r,o=e),a=h(e,r),a<i.weight-o.weight){s=i.weight-o.weight-a,o.weight+=s+F,n=!0,g++;break}if(n)break}}while(n)}function A(t){for(var e,r,i,o=0,a=0;a<M;a++)e=t[a],r=e.site.originalObject,i=n.polygonArea(e),o+=Math.abs(r.targetedArea-i);return o}function m(){Y=y}var M,x,N,b,W,E,L,k,P,j=.01,O=50,G=.01,I=Math.random,q=g(),S=l(),F=(g(),1e-10),R=function(t){return t.weight},z=j,V=O,_=G,D=I,B=q,H=S,J=i.weightedVoronoi(),K=new o,Q=!0,T=e.timer(s),U=r.dispatch("tick","end");const X=1e3;var Y;return P={tick:u,restart:function(){return T.restart(s),P},stop:function(){return T.stop(),P},weight:function(t){return arguments.length?(R=t,Q=!0,P):R},convergenceRatio:function(t){return arguments.length?(z=t,Q=!0,P):z},maxIterationCount:function(t){return arguments.length?(V=t,P):V},minWeightRatio:function(t){return arguments.length?(_=t,Q=!0,P):_},clip:function(t){return arguments.length?(J.clip(t),Q=!0,P):J.clip()},extent:function(t){return arguments.length?(J.extent(t),Q=!0,P):J.extent()},size:function(t){return arguments.length?(J.size(t),Q=!0,P):J.size()},prng:function(t){return arguments.length?(D=t,Q=!0,P):D},initialPosition:function(t){return arguments.length?(B=t,Q=!0,P):B},initialWeight:function(t){return arguments.length?(H=t,Q=!0,P):H},state:function(){return Q&&f(),{ended:k,iterationCount:b,convergenceRatio:E/x,polygons:W}},on:function(t,n){return 1===arguments.length?U.on(t):(U.on(t,n),P)}}}var p=10;o.prototype.reset=function(){return this.lastAreaError=NaN,this.lastGrowth=NaN,this.growthChanges=[],this.growthChangesLength=p,this.growthChangeWeights=h(this.growthChangesLength),this.growthChangeWeightsSum=s(this.growthChangeWeights),this.totalAvailableArea=NaN,this},o.prototype.clear=function(){return this.lastAreaError=NaN,this.lastGrowth=NaN,this.growthChanges=[],this},o.prototype.length=function(t){return arguments.length?(parseInt(t)>0?(this.growthChangesLength=Math.floor(parseInt(t)),this.growthChangeWeights=h(this.growthChangesLength),this.growthChangeWeightsSum=s(this.growthChangeWeights)):console.warn("FlickeringMitigation.length() accepts only positive integers; unable to handle "+t),this):this.growthChangesLength},o.prototype.totalArea=function(t){return arguments.length?(parseFloat(t)>0?this.totalAvailableArea=parseFloat(t):console.warn("FlickeringMitigation.totalArea() accepts only positive numbers; unable to handle "+t),this):this.totalAvailableArea},o.prototype.add=function(t){var n,e;return n=this.lastAreaError,this.lastAreaError=t,isNaN(n)||(e=this.lastGrowth,this.lastGrowth=a(this.lastAreaError,n)),isNaN(e)||this.growthChanges.unshift(this.lastGrowth!=e),this.growthChanges.length>this.growthChangesLength&&this.growthChanges.pop(),this},o.prototype.ratio=function(){var t,n=0;if(this.growthChanges.length<this.growthChangesLength)return 0;if(this.lastAreaError>this.totalAvailableArea/10)return 0;for(var e=0;e<this.growthChangesLength;e++)this.growthChanges[e]&&(n+=this.growthChangeWeights[e]);return t=n/this.growthChangeWeightsSum},c.prototype.name="d3VoronoiMapError",c.prototype=new Error,t.voronoiMapSimulation=f,t.voronoiMapInitialPositionRandom=g,t.voronoiMapInitialPositionPie=u,t.d3VoronoiMapError=c,Object.defineProperty(t,"__esModule",{value:!0})});
|
modules/chart_engine/static/lib/d3-weighted-voronoi.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("d3-array"),require("d3-polygon")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-polygon"],i):i(t.d3=t.d3||{},t.d3,t.d3)}(this,function(t,i,n){"use strict";function e(t){return t<=C&&t>=-C}function s(t,i){return t.x*i.x+t.y*i.y+t.z*i.z}function o(t,i){return e(t.x*i.y-t.y*i.x)&&e(t.y*i.z-t.z*i.y)&&e(t.z*i.x-t.x*i.z)}function r(t){var i,n,e,s,o,r,u,c;if(e=t[t.length-2],s=t[t.length-1],o=t[0],r=h(e,s),u=h(s,o),n=l(r,u),i=Math.sign(n),e=s,s=o,o=t[1],r=u,u=h(s,o),n=l(r,u),Math.sign(n)===i){for(c=2;c<t.length-1;c++)if(e=s,s=o,o=t[c],r=u,u=h(s,o),n=l(r,u),Math.sign(n)!==i)return;return i}}function h(t,i){return[i[0]-t[0],i[1]-t[1]]}function l(t,i){return t[0]*i[1]-t[1]*i[0]}function u(t,i){this.face=t,this.vert=i,this.nextf=null,this.prevf=null,this.nextv=null,this.prevv=null}function c(t){this.forFace=t,this.head=null}function a(t,i,n,e,s,o){this.x=t,this.y=i,this.weight=C,this.index=0,this.conflicts=new c((!1)),this.neighbours=null,this.nonClippedPolygon=null,this.polygon=null,this.originalObject=null,this.isDummy=!1,void 0!==s&&(this.originalObject=s),void 0!=o&&(this.isDummy=o),null!=e&&(this.weight=e),null!=n?this.z=n:this.z=this.projectZ(this.x,this.y,this.weight)}function f(t){var i=t.verts[0],n=t.verts[1],e=t.verts[2];this.a=i.y*(n.z-e.z)+n.y*(e.z-i.z)+e.y*(i.z-n.z),this.b=i.z*(n.x-e.x)+n.z*(e.x-i.x)+e.z*(i.x-n.x),this.c=i.x*(n.y-e.y)+n.x*(e.y-i.y)+e.x*(i.y-n.y),this.d=-1*(i.x*(n.y*e.z-e.y*n.z)+n.x*(e.y*i.z-i.y*e.z)+e.x*(i.y*n.z-n.y*i.z))}function p(t,i){this.x=t,this.y=i}function d(t,i,n){this.x=t,this.y=i,this.z=n}function v(t,i,n){this.next=null,this.prev=null,this.twin=null,this.orig=t,this.dest=i,this.iFace=n}function g(t){this.message=t,this.stack=(new Error).stack}function y(t,i,n,e){this.conflicts=new c((!0)),this.verts=[t,i,n],this.marked=!1;var s=t.subtract(i).crossproduct(i.subtract(n));this.normal=new d((-s.x),(-s.y),(-s.z)),this.normal.normalize(),this.createEdges(),this.dualPoint=null,void 0!=e&&this.orient(e)}function x(){this.points=[],this.facets=[],this.created=[],this.horizon=[],this.visible=[],this.current=0}function w(t,i){for(var n,e,s,o,r,h,l,u=b(i),c=-1,a=t.length-b(t),f=t[a-1];++c<a;){for(n=i.slice(),i.length=0,o=t[c],r=n[(s=n.length-u)-1],e=-1;++e<s;)h=n[e],z(h,f,o)?(z(r,f,o)||(l=m(r,h,f,o),isFinite(l[0])&&i.push(l)),i.push(h)):z(r,f,o)&&(l=m(r,h,f,o),isFinite(l[0])&&i.push(l)),r=h;u&&i.push(i[0]),f=o}return i}function z(t,i,n){return(n[0]-i[0])*(t[1]-i[1])<(n[1]-i[1])*(t[0]-i[0])}function m(t,i,n,e){var s=t[0],o=n[0],r=i[0]-s,h=e[0]-o,l=t[1],u=n[1],c=i[1]-l,a=e[1]-u,f=(h*(l-u)-a*(s-o))/(a*r-h*c);return[s+f*r,l+f*c]}function b(t){var i=t[0],n=t[t.length-1];return!(i[0]-n[0]||i[1]-n[1])}function k(t){var i=[],n=t,e=t.dest,s=e.originalObject,o=[];do{n=n.twin.prev;var r=n.orig.originalObject;r.isDummy||o.push(r);var h=n.iFace;h.isVisibleFromBelow()&&i.push(h)}while(n!==t);return s.neighbours=o,i}function F(t,i,e){var s=new x;s.clear(),s.init(i,t);for(var o=s.compute(t),r=[],h=[],l=o.length,u=0;u<l;u++){var c=o[u];if(c.isVisibleFromBelow())for(var a=0;a<3;a++){var f=c.edges[a],p=f.dest,d=p.originalObject;if(!h[p.index]){if(h[p.index]=!0,d.isDummy)continue;for(var v=k(f),g=[],y=null,z=null,m=1,b=1,F=0;F<v.length;F++){var P=v[F].getDualPoint(),E=P.x,j=P.y;null!==y&&(m=y-E,b=z-j,m<0&&(m=-m),b<0&&(b=-b)),(m>C||b>C)&&(g.push([E,j]),y=E,z=j)}if(d.nonClippedPolygon=g.reverse(),!d.isDummy&&n.polygonLength(d.nonClippedPolygon)>0){var q=w(e,d.nonClippedPolygon);d.polygon=q,q.site=d,q.length>0&&r.push(q)}}}}return r}function P(){function t(t){var i;return i=t.map(function(t){return new a(s(t),o(t),null,h(t),t,(!1))}),F(i,e(),l)}function e(){var t,i,n,e,s,o,r,h,l,c,f=[],p=[];t=u[0][0],i=u[1][0],n=u[0][1],e=u[1][1],s=i-t,o=e-n,r=t-s,h=i+s,l=n-o,c=e+o,f[0]=[r,l],f[1]=[r,c],f[2]=[h,c],f[3]=[h,l];for(var d=0;d<4;d++)p.push(new a(f[d][0],f[d][1],null,C,new a(f[d][0],f[d][1],null,C,null,(!0)),(!0)));return p}var s=function(t){return t.x},o=function(t){return t.y},h=function(t){return t.weight},l=[[0,0],[0,1],[1,1],[1,0]],u=[[0,0],[1,1]],c=[1,1];return t.x=function(i){return arguments.length?(s=i,t):s},t.y=function(i){return arguments.length?(o=i,t):o},t.weight=function(i){return arguments.length?(h=i,t):h},t.clip=function(e){var s,o,h;return arguments.length?(o=i.extent(e.map(function(t){return t[0]})),h=i.extent(e.map(function(t){return t[1]})),s=r(e),l=void 0===s?n.polygonHull(e):1===s?e.reverse():e,u=[[o[0],h[0]],[o[1],h[1]]],c=[o[1]-o[0],h[1]-h[0]],t):l},t.extent=function(i){return arguments.length?(l=[i[0],[i[0][0],i[1][1]],i[1],[i[1][0],i[0][1]]],u=i,c=[i[1][0]-i[0][0],i[1][1]-i[0][1]],t):u},t.size=function(i){return arguments.length?(l=[[0,0],[0,i[1]],[i[0],i[1]],[i[0],0]],u=[[0,0],i],c=i,t):c},t}var C=1e-10;c.prototype.add=function(t){null===this.head?this.head=t:this.forFace?(this.head.prevv=t,t.nextv=this.head,this.head=t):(this.head.prevf=t,t.nextf=this.head,this.head=t)},c.prototype.isEmpty=function(){return null===this.head},c.prototype.fill=function(t){if(!this.forFace){var i=this.head;do t.push(i.face),i.face.marked=!0,i=i.nextf;while(null!==i)}},c.prototype.removeAll=function(){if(this.forFace){var t=this.head;do null===t.prevf?null===t.nextf?t.vert.conflicts.head=null:(t.nextf.prevf=null,t.vert.conflicts.head=t.nextf):(null!=t.nextf&&(t.nextf.prevf=t.prevf),t.prevf.nextf=t.nextf),t=t.nextv,null!=t&&(t.prevv=null);while(null!=t)}else{var t=this.head;do null==t.prevv?null==t.nextv?t.face.conflicts.head=null:(t.nextv.prevv=null,t.face.conflicts.head=t.nextv):(null!=t.nextv&&(t.nextv.prevv=t.prevv),t.prevv.nextv=t.nextv),t=t.nextf,null!=t&&(t.prevf=null);while(null!=t)}},c.prototype.getVertices=function(){for(var t=[],i=this.head;null!==i;)t.push(i.vert),i=i.nextv;return t},a.prototype.projectZ=function(t,i,n){return t*t+i*i-n},a.prototype.setWeight=function(t){this.weight=t,this.z=this.projectZ(this.x,this.y,this.weight)},a.prototype.subtract=function(t){return new a(t.x-this.x,t.y-this.y,t.z-this.z)},a.prototype.crossproduct=function(t){return new a(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)},a.prototype.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},f.prototype.getNormZPlane=function(){return[-1*(this.a/this.c),-1*(this.b/this.c),-1*(this.d/this.c)]},f.prototype.getDualPointMappedToPlane=function(){var t=this.getNormZPlane(),i=new p(t[0]/2,t[1]/2);return i},d.prototype.negate=function(){this.x*=-1,this.y*=-1,this.z*=-1},d.prototype.normalize=function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);t>0&&(this.x/=t,this.y/=t,this.z/=t)},v.prototype.isHorizon=function(){return null!==this.twin&&!this.iFace.marked&&this.twin.iFace.marked},v.prototype.findHorizon=function(t){if(this.isHorizon()){if(t.length>0&&this===t[0])return;t.push(this),this.next.findHorizon(t)}else null!==this.twin&&this.twin.next.findHorizon(t)},v.prototype.isEqual=function(t,i){return this.orig.equals(t)&&this.dest.equals(i)||this.orig.equals(i)&&this.dest.equals(t)},g.prototype.name="d3WeightedVoronoiError",g.prototype=new Error,y.prototype.getDualPoint=function(){if(null==this.dualPoint){var t=new f(this);this.dualPoint=t.getDualPointMappedToPlane()}return this.dualPoint},y.prototype.isVisibleFromBelow=function(){return this.normal.z<-1.4259414393190911e-9},y.prototype.createEdges=function(){this.edges=[],this.edges[0]=new v(this.verts[0],this.verts[1],this),this.edges[1]=new v(this.verts[1],this.verts[2],this),this.edges[2]=new v(this.verts[2],this.verts[0],this),this.edges[0].next=this.edges[1],this.edges[0].prev=this.edges[2],this.edges[1].next=this.edges[2],this.edges[1].prev=this.edges[0],this.edges[2].next=this.edges[0],this.edges[2].prev=this.edges[1]},y.prototype.orient=function(t){if(!(s(this.normal,t)<s(this.normal,this.verts[0]))){var i=this.verts[1];this.verts[1]=this.verts[2],this.verts[2]=i,this.normal.negate(),this.createEdges()}},y.prototype.getEdge=function(t,i){for(var n=0;n<3;n++)if(this.edges[n].isEqual(t,i))return this.edges[n];return null},y.prototype.link=function(t,i,n){if(t instanceof y){var e=t.getEdge(i,n);if(null===e)throw new g("when linking, twin is null");var s=this.getEdge(i,n);if(null===s)throw new g("when linking, twin is null");e.twin=s,s.twin=e}else{var e=t,s=this.getEdge(e.orig,e.dest);e.twin=s,s.twin=e}},y.prototype.conflict=function(t){return s(this.normal,t)>s(this.normal,this.verts[0])+C},y.prototype.getHorizon=function(){for(var t=0;t<3;t++)if(null!==this.edges[t].twin&&this.edges[t].twin.isHorizon())return this.edges[t];return null},y.prototype.removeConflict=function(){this.conflicts.removeAll()},x.prototype.init=function(t,i){this.points=[];for(var n=0;n<i.length;n++)this.points[n]=new a(i[n].x,i[n].y,i[n].z,null,i[n],(!1));this.points=this.points.concat(t)},x.prototype.permutate=function(){for(var t=this.points.length,i=t-1;i>0;i--){var n=Math.floor(Math.random()*i),e=this.points[n];e.index=i;var s=this.points[i];s.index=n,this.points.splice(n,1,s),this.points.splice(i,1,e)}},x.prototype.prep=function(){if(this.points.length<=3)throw new g("Less than 4 points");for(var t=0;t<this.points.length;t++)this.points[t].index=t;var i,n,r,h,l,u,c,a;i=this.points[0],n=this.points[1],r=h=null;for(var t=2;t<this.points.length;t++)if(!o(i,this.points[t])||!o(n,this.points[t])){r=this.points[t],r.index=2,this.points[2].index=t,this.points.splice(t,1,this.points[2]),this.points.splice(2,1,r);break}if(null===r)throw new g("Not enough non-planar Points (v2 is null)");a=new y(i,n,r);for(var t=3;t<this.points.length;t++)if(!e(s(a.normal,a.verts[0])-s(a.normal,this.points[t]))){h=this.points[t],h.index=3,this.points[3].index=t,this.points.splice(t,1,this.points[3]),this.points.splice(3,1,h);break}if(null===h)throw new g("Not enough non-planar Points (v3 is null)");a.orient(h),l=new y(i,r,h,n),u=new y(i,n,h,r),c=new y(n,r,h,i),this.addFacet(a),this.addFacet(l),this.addFacet(u),this.addFacet(c),a.link(l,i,r),a.link(u,i,n),a.link(c,n,r),l.link(u,i,h),l.link(c,r,h),u.link(c,h,n),this.current=4;for(var f,t=this.current;t<this.points.length;t++)f=this.points[t],a.conflict(f)&&this.addConflict(a,f),l.conflict(f)&&this.addConflict(l,f),u.conflict(f)&&this.addConflict(u,f),c.conflict(f)&&this.addConflict(c,f)},x.prototype.addConflicts=function(t,i,n){var e,s,o,r,h=t.conflicts.getVertices(),l=i.conflicts.getVertices(),u=[];for(o=r=0;o<h.length||r<l.length;)o<h.length&&r<l.length?(e=h[o],s=l[r],e.index===s.index?(u.push(e),o++,r++):e.index>s.index?(u.push(e),o++):(u.push(s),r++)):o<h.length?u.push(h[o++]):u.push(l[r++]);for(var o=u.length-1;o>=0;o--)e=u[o],n.conflict(e)&&this.addConflict(n,e)},x.prototype.addConflict=function(t,i){var n=new u(t,i);t.conflicts.add(n),i.conflicts.add(n)},x.prototype.removeConflict=function(t){t.removeConflict();var i=t.index;if(t.index=-1,i===this.facets.length-1)return void this.facets.splice(this.facets.length-1,1);if(!(i>=this.facets.length||i<0)){var n=this.facets.splice(this.facets.length-1,1);n[0].index=i,this.facets.splice(i,1,n[0])}},x.prototype.addFacet=function(t){t.index=this.facets.length,this.facets.push(t)},x.prototype.compute=function(){for(this.prep();this.current<this.points.length;){var t=this.points[this.current];if(t.conflicts.isEmpty())this.current++;else{this.created=[],this.horizon=[],this.visible=[],t.conflicts.fill(this.visible);for(var i,n=0;n<this.visible.length;n++)if(i=this.visible[n].getHorizon(),null!==i){i.findHorizon(this.horizon);break}for(var e=null,s=null,o=0;o<this.horizon.length;o++){var r=this.horizon[o],h=new y(t,r.orig,r.dest,r.twin.next.dest);h.conflicts=new c((!0)),this.addFacet(h),this.created.push(h),this.addConflicts(r.iFace,r.twin.iFace,h),h.link(r),null!==e&&h.link(e,t,r.orig),e=h,null===s&&(s=h)}if(null!==s&&null!==e&&e.link(s,t,this.horizon[0].orig),0!=this.created.length){for(var l=0;l<this.visible.length;l++)this.removeConflict(this.visible[l]);this.current++,this.created=[]}}}return this.facets},x.prototype.clear=function(){this.points=[],this.facets=[],this.created=[],this.horizon=[],this.visible=[],this.current=0},t.weightedVoronoi=P,t.d3WeightedVoronoiError=g,Object.defineProperty(t,"__esModule",{value:!0})});
|
modules/chart_engine/static/lib/svg2roughjs.umd.min.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).svg2roughjs={})}(this,(function(t){"use strict";function e(t,e,n){if(t&&t.length){const[r,s]=e,a=Math.PI/180*n,i=Math.cos(a),o=Math.sin(a);for(const e of t){const[t,n]=e;e[0]=(t-r)*i-(n-s)*o+r,e[1]=(t-r)*o+(n-s)*i+s}}}function n(t,e){return t[0]===e[0]&&t[1]===e[1]}function r(t,r,s,a=1){const i=s,o=Math.max(r,.1),l=t[0]&&t[0][0]&&"number"==typeof t[0][0]?[t]:t,h=[0,0];if(i)for(const t of l)e(t,h,i);const u=function(t,e,r){const s=[];for(const e of t){const t=[...e];n(t[0],t[t.length-1])||t.push([t[0][0],t[0][1]]),t.length>2&&s.push(t)}const a=[];e=Math.max(e,.1);const i=[];for(const t of s)for(let e=0;e<t.length-1;e++){const n=t[e],r=t[e+1];if(n[1]!==r[1]){const t=Math.min(n[1],r[1]);i.push({ymin:t,ymax:Math.max(n[1],r[1]),x:t===n[1]?n[0]:r[0],islope:(r[0]-n[0])/(r[1]-n[1])})}}if(i.sort(((t,e)=>t.ymin<e.ymin?-1:t.ymin>e.ymin?1:t.x<e.x?-1:t.x>e.x?1:t.ymax===e.ymax?0:(t.ymax-e.ymax)/Math.abs(t.ymax-e.ymax))),!i.length)return a;let o=[],l=i[0].ymin,h=0;for(;o.length||i.length;){if(i.length){let t=-1;for(let e=0;e<i.length&&!(i[e].ymin>l);e++)t=e;i.splice(0,t+1).forEach((t=>{o.push({s:l,edge:t})}))}if(o=o.filter((t=>!(t.edge.ymax<=l))),o.sort(((t,e)=>t.edge.x===e.edge.x?0:(t.edge.x-e.edge.x)/Math.abs(t.edge.x-e.edge.x))),(1!==r||h%e==0)&&o.length>1)for(let t=0;t<o.length;t+=2){const e=t+1;if(e>=o.length)break;const n=o[t].edge,r=o[e].edge;a.push([[Math.round(n.x),l],[Math.round(r.x),l]])}l+=r,o.forEach((t=>{t.edge.x=t.edge.x+r*t.edge.islope})),h++}return a}(l,o,a);if(i){for(const t of l)e(t,h,-i);!function(t,n,r){const s=[];t.forEach((t=>s.push(...t))),e(s,n,r)}(u,h,-i)}return u}function s(t,e){var n;const s=e.hachureAngle+90;let a=e.hachureGap;a<0&&(a=4*e.strokeWidth),a=Math.round(Math.max(a,.1));let i=1;return e.roughness>=1&&((null===(n=e.randomizer)||void 0===n?void 0:n.next())||Math.random())>.7&&(i=a),r(t,a,s,i||1)}class a{constructor(t){this.helper=t}fillPolygons(t,e){return this._fillPolygons(t,e)}_fillPolygons(t,e){const n=s(t,e);return{type:"fillSketch",ops:this.renderLines(n,e)}}renderLines(t,e){const n=[];for(const r of t)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],e));return n}}function i(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 o extends a{fillPolygons(t,e){let n=e.hachureGap;n<0&&(n=4*e.strokeWidth),n=Math.max(n,.1);const r=s(t,Object.assign({},e,{hachureGap:n})),a=Math.PI/180*e.hachureAngle,o=[],l=.5*n*Math.cos(a),h=.5*n*Math.sin(a);for(const[t,e]of r)i([t,e])&&o.push([[t[0]-l,t[1]+h],[...e]],[[t[0]+l,t[1]-h],[...e]]);return{type:"fillSketch",ops:this.renderLines(o,e)}}}class l extends a{fillPolygons(t,e){const n=this._fillPolygons(t,e),r=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),s=this._fillPolygons(t,r);return n.ops=n.ops.concat(s.ops),n}}class h{constructor(t){this.helper=t}fillPolygons(t,e){const n=s(t,e=Object.assign({},e,{hachureAngle:0}));return this.dotsOnLines(n,e)}dotsOnLines(t,e){const n=[];let r=e.hachureGap;r<0&&(r=4*e.strokeWidth),r=Math.max(r,.1);let s=e.fillWeight;s<0&&(s=e.strokeWidth/2);const a=r/4;for(const o of t){const t=i(o),l=t/r,h=Math.ceil(l)-1,u=t-h*r,c=(o[0][0]+o[1][0])/2-r/4,f=Math.min(o[0][1],o[1][1]);for(let t=0;t<h;t++){const i=f+u+t*r,o=c-a+2*Math.random()*a,l=i-a+2*Math.random()*a,h=this.helper.ellipse(o,l,s,s,e);n.push(...h.ops)}}return{type:"fillSketch",ops:n}}}class u{constructor(t){this.helper=t}fillPolygons(t,e){const n=s(t,e);return{type:"fillSketch",ops:this.dashedLine(n,e)}}dashedLine(t,e){const n=e.dashOffset<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashOffset,r=e.dashGap<0?e.hachureGap<0?4*e.strokeWidth:e.hachureGap:e.dashGap,s=[];return t.forEach((t=>{const a=i(t),o=Math.floor(a/(n+r)),l=(a+r-o*(n+r))/2;let h=t[0],u=t[1];h[0]>u[0]&&(h=t[1],u=t[0]);const c=Math.atan((u[1]-h[1])/(u[0]-h[0]));for(let t=0;t<o;t++){const a=t*(n+r),i=a+n,o=[h[0]+a*Math.cos(c)+l*Math.cos(c),h[1]+a*Math.sin(c)+l*Math.sin(c)],u=[h[0]+i*Math.cos(c)+l*Math.cos(c),h[1]+i*Math.sin(c)+l*Math.sin(c)];s.push(...this.helper.doubleLineOps(o[0],o[1],u[0],u[1],e))}})),s}}class c{constructor(t){this.helper=t}fillPolygons(t,e){const n=e.hachureGap<0?4*e.strokeWidth:e.hachureGap,r=e.zigzagOffset<0?n:e.zigzagOffset,a=s(t,e=Object.assign({},e,{hachureGap:n+r}));return{type:"fillSketch",ops:this.zigzagLines(a,r,e)}}zigzagLines(t,e,n){const r=[];return t.forEach((t=>{const s=i(t),a=Math.round(s/(2*e));let o=t[0],l=t[1];o[0]>l[0]&&(o=t[1],l=t[0]);const h=Math.atan((l[1]-o[1])/(l[0]-o[0]));for(let t=0;t<a;t++){const s=2*t*e,a=2*(t+1)*e,i=Math.sqrt(2*Math.pow(e,2)),l=[o[0]+s*Math.cos(h),o[1]+s*Math.sin(h)],u=[o[0]+a*Math.cos(h),o[1]+a*Math.sin(h)],c=[l[0]+i*Math.cos(h+Math.PI/4),l[1]+i*Math.sin(h+Math.PI/4)];r.push(...this.helper.doubleLineOps(l[0],l[1],c[0],c[1],n),...this.helper.doubleLineOps(c[0],c[1],u[0],u[1],n))}})),r}}const f={};class p{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}}const d=0,g=1,m=2,y={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 b(t,e){return t.type===e}function v(t){const e=[],n=function(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:d,text:RegExp.$1},t=t.substr(RegExp.$1.length);else{if(!t.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];e[e.length]={type:g,text:`${parseFloat(RegExp.$1)}`},t=t.substr(RegExp.$1.length)}return e[e.length]={type:m,text:""},e}(t);let r="BOD",s=0,a=n[s];for(;!b(a,m);){let i=0;const o=[];if("BOD"===r){if("M"!==a.text&&"m"!==a.text)return v("M0,0"+t);s++,i=y[a.text],r=a.text}else b(a,g)?i=y[r]:(s++,i=y[a.text],r=a.text);if(!(s+i<n.length))throw new Error("Path data ended short");for(let t=s;t<s+i;t++){const e=n[t];if(!b(e,g))throw new Error("Param not a number: "+r+","+e.text);o[o.length]=+e.text}if("number"!=typeof y[r])throw new Error("Bad segment: "+r);{const t={key:r,data:o};e.push(t),s+=i,a=n[s],"M"===r&&(r="L"),"m"===r&&(r="l")}}return e}function x(t){let e=0,n=0,r=0,s=0;const a=[];for(const{key:i,data:o}of t)switch(i){case"M":a.push({key:"M",data:[...o]}),[e,n]=o,[r,s]=o;break;case"m":e+=o[0],n+=o[1],a.push({key:"M",data:[e,n]}),r=e,s=n;break;case"L":a.push({key:"L",data:[...o]}),[e,n]=o;break;case"l":e+=o[0],n+=o[1],a.push({key:"L",data:[e,n]});break;case"C":a.push({key:"C",data:[...o]}),e=o[4],n=o[5];break;case"c":{const t=o.map(((t,r)=>r%2?t+n:t+e));a.push({key:"C",data:t}),e=t[4],n=t[5];break}case"Q":a.push({key:"Q",data:[...o]}),e=o[2],n=o[3];break;case"q":{const t=o.map(((t,r)=>r%2?t+n:t+e));a.push({key:"Q",data:t}),e=t[2],n=t[3];break}case"A":a.push({key:"A",data:[...o]}),e=o[5],n=o[6];break;case"a":e+=o[5],n+=o[6],a.push({key:"A",data:[o[0],o[1],o[2],o[3],o[4],e,n]});break;case"H":a.push({key:"H",data:[...o]}),e=o[0];break;case"h":e+=o[0],a.push({key:"H",data:[e]});break;case"V":a.push({key:"V",data:[...o]}),n=o[0];break;case"v":n+=o[0],a.push({key:"V",data:[n]});break;case"S":a.push({key:"S",data:[...o]}),e=o[2],n=o[3];break;case"s":{const t=o.map(((t,r)=>r%2?t+n:t+e));a.push({key:"S",data:t}),e=t[2],n=t[3];break}case"T":a.push({key:"T",data:[...o]}),e=o[0],n=o[1];break;case"t":e+=o[0],n+=o[1],a.push({key:"T",data:[e,n]});break;case"Z":case"z":a.push({key:"Z",data:[]}),e=r,n=s}return a}function M(t){const e=[];let n="",r=0,s=0,a=0,i=0,o=0,l=0;for(const{key:h,data:u}of t){switch(h){case"M":e.push({key:"M",data:[...u]}),[r,s]=u,[a,i]=u;break;case"C":e.push({key:"C",data:[...u]}),r=u[4],s=u[5],o=u[2],l=u[3];break;case"L":e.push({key:"L",data:[...u]}),[r,s]=u;break;case"H":r=u[0],e.push({key:"L",data:[r,s]});break;case"V":s=u[0],e.push({key:"L",data:[r,s]});break;case"S":{let t=0,a=0;"C"===n||"S"===n?(t=r+(r-o),a=s+(s-l)):(t=r,a=s),e.push({key:"C",data:[t,a,...u]}),o=u[0],l=u[1],r=u[2],s=u[3];break}case"T":{const[t,a]=u;let i=0,h=0;"Q"===n||"T"===n?(i=r+(r-o),h=s+(s-l)):(i=r,h=s);const c=r+2*(i-r)/3,f=s+2*(h-s)/3,p=t+2*(i-t)/3,d=a+2*(h-a)/3;e.push({key:"C",data:[c,f,p,d,t,a]}),o=i,l=h,r=t,s=a;break}case"Q":{const[t,n,a,i]=u,h=r+2*(t-r)/3,c=s+2*(n-s)/3,f=a+2*(t-a)/3,p=i+2*(n-i)/3;e.push({key:"C",data:[h,c,f,p,a,i]}),o=t,l=n,r=a,s=i;break}case"A":{const t=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],i=u[3],o=u[4],l=u[5],h=u[6];if(0===t||0===n)e.push({key:"C",data:[r,s,l,h,l,h]}),r=l,s=h;else if(r!==l||s!==h){A(r,s,l,h,t,n,a,i,o).forEach((function(t){e.push({key:"C",data:t})})),r=l,s=h}break}case"Z":e.push({key:"Z",data:[]}),r=a,s=i}n=h}return e}function w(t,e,n){return[t*Math.cos(n)-e*Math.sin(n),t*Math.sin(n)+e*Math.cos(n)]}function A(t,e,n,r,s,a,i,o,l,h){const u=(c=i,Math.PI*c/180);var c;let f=[],p=0,d=0,g=0,m=0;if(h)[p,d,g,m]=h;else{[t,e]=w(t,e,-u),[n,r]=w(n,r,-u);const i=(t-n)/2,h=(e-r)/2;let c=i*i/(s*s)+h*h/(a*a);c>1&&(c=Math.sqrt(c),s*=c,a*=c);const f=s*s,y=a*a,b=f*y-f*h*h-y*i*i,v=f*h*h+y*i*i,x=(o===l?-1:1)*Math.sqrt(Math.abs(b/v));g=x*s*h/a+(t+n)/2,m=x*-a*i/s+(e+r)/2,p=Math.asin(parseFloat(((e-m)/a).toFixed(9))),d=Math.asin(parseFloat(((r-m)/a).toFixed(9))),t<g&&(p=Math.PI-p),n<g&&(d=Math.PI-d),p<0&&(p=2*Math.PI+p),d<0&&(d=2*Math.PI+d),l&&p>d&&(p-=2*Math.PI),!l&&d>p&&(d-=2*Math.PI)}let y=d-p;if(Math.abs(y)>120*Math.PI/180){const t=d,e=n,o=r;d=l&&d>p?p+120*Math.PI/180*1:p+120*Math.PI/180*-1,f=A(n=g+s*Math.cos(d),r=m+a*Math.sin(d),e,o,s,a,i,0,l,[d,t,g,m])}y=d-p;const b=Math.cos(p),v=Math.sin(p),x=Math.cos(d),M=Math.sin(d),_=Math.tan(y/4),O=4/3*s*_,S=4/3*a*_,E=[t,e],C=[t+O*v,e-S*b],T=[n+O*M,r-S*x],k=[n,r];if(C[0]=2*E[0]-C[0],C[1]=2*E[1]-C[1],h)return[C,T,k].concat(f);{f=[C,T,k].concat(f);const t=[];for(let e=0;e<f.length;e+=3){const n=w(f[e][0],f[e][1],u),r=w(f[e+1][0],f[e+1][1],u),s=w(f[e+2][0],f[e+2][1],u);t.push([n[0],n[1],r[0],r[1],s[0],s[1]])}return t}}const _={randOffset:function(t,e){return $(t,e)},randOffsetWithRange:function(t,e,n){return F(t,e,n)},ellipse:function(t,e,n,r,s){const a=T(n,r,s);return k(t,e,s,a).opset},doubleLineOps:function(t,e,n,r,s){return H(t,e,n,r,s,!0)}};function O(t,e,n,r,s){return{type:"path",ops:H(t,e,n,r,s)}}function S(t,e,n){const r=(t||[]).length;if(r>2){const s=[];for(let e=0;e<r-1;e++)s.push(...H(t[e][0],t[e][1],t[e+1][0],t[e+1][1],n));return e&&s.push(...H(t[r-1][0],t[r-1][1],t[0][0],t[0][1],n)),{type:"path",ops:s}}return 2===r?O(t[0][0],t[0][1],t[1][0],t[1][1],n):{type:"path",ops:[]}}function E(t,e,n,r,s){return function(t,e){return S(t,!0,e)}([[t,e],[t+n,e],[t+n,e+r],[t,e+r]],s)}function C(t,e){if(t.length){const n="number"==typeof t[0][0]?[t]:t,r=U(n[0],1*(1+.2*e.roughness),e),s=e.disableMultiStroke?[]:U(n[0],1.5*(1+.22*e.roughness),L(e));for(let t=1;t<n.length;t++){const a=n[t];if(a.length){const t=U(a,1*(1+.2*e.roughness),e),n=e.disableMultiStroke?[]:U(a,1.5*(1+.22*e.roughness),L(e));for(const e of t)"move"!==e.op&&r.push(e);for(const t of n)"move"!==t.op&&s.push(t)}}return{type:"path",ops:r.concat(s)}}return{type:"path",ops:[]}}function T(t,e,n){const r=Math.sqrt(2*Math.PI*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)),a=2*Math.PI/s;let i=Math.abs(t/2),o=Math.abs(e/2);const l=1-n.curveFitting;return i+=$(i*l,n),o+=$(o*l,n),{increment:a,rx:i,ry:o}}function k(t,e,n,r){const[s,a]=z(r.increment,t,e,r.rx,r.ry,1,r.increment*F(.1,F(.4,1,n),n),n);let i=G(s,null,n);if(!n.disableMultiStroke&&0!==n.roughness){const[s]=z(r.increment,t,e,r.rx,r.ry,1.5,0,n),a=G(s,null,n);i=i.concat(a)}return{estimatedPoints:a,opset:{type:"path",ops:i}}}function N(t,e,n,r,s,a,i,o,l){const h=t,u=e;let c=Math.abs(n/2),f=Math.abs(r/2);c+=$(.01*c,l),f+=$(.01*f,l);let p=s,d=a;for(;p<0;)p+=2*Math.PI,d+=2*Math.PI;d-p>2*Math.PI&&(p=0,d=2*Math.PI);const g=2*Math.PI/l.curveStepCount,m=Math.min(g/2,(d-p)/2),y=j(m,h,u,c,f,p,d,1,l);if(!l.disableMultiStroke){const t=j(m,h,u,c,f,p,d,1.5,l);y.push(...t)}return i&&(o?y.push(...H(h,u,h+c*Math.cos(p),u+f*Math.sin(p),l),...H(h,u,h+c*Math.cos(d),u+f*Math.sin(d),l)):y.push({op:"lineTo",data:[h,u]},{op:"lineTo",data:[h+c*Math.cos(p),u+f*Math.sin(p)]})),{type:"path",ops:y}}function V(t,e){const n=M(x(v(t))),r=[];let s=[0,0],a=[0,0];for(const{key:t,data:i}of n)switch(t){case"M":a=[i[0],i[1]],s=[i[0],i[1]];break;case"L":r.push(...H(a[0],a[1],i[0],i[1],e)),a=[i[0],i[1]];break;case"C":{const[t,n,s,o,l,h]=i;r.push(...q(t,n,s,o,l,h,a,e)),a=[l,h];break}case"Z":r.push(...H(a[0],a[1],s[0],s[1],e)),a=[s[0],s[1]]}return{type:"path",ops:r}}function R(t,e){const n=[];for(const r of t)if(r.length){const t=e.maxRandomnessOffset||0,s=r.length;if(s>2){n.push({op:"move",data:[r[0][0]+$(t,e),r[0][1]+$(t,e)]});for(let a=1;a<s;a++)n.push({op:"lineTo",data:[r[a][0]+$(t,e),r[a][1]+$(t,e)]})}}return{type:"fillPath",ops:n}}function I(t,e){return function(t,e){let n=t.fillStyle||"hachure";if(!f[n])switch(n){case"zigzag":f[n]||(f[n]=new o(e));break;case"cross-hatch":f[n]||(f[n]=new l(e));break;case"dots":f[n]||(f[n]=new h(e));break;case"dashed":f[n]||(f[n]=new u(e));break;case"zigzag-line":f[n]||(f[n]=new c(e));break;default:n="hachure",f[n]||(f[n]=new a(e))}return f[n]}(e,_).fillPolygons(t,e)}function L(t){const e=Object.assign({},t);return e.randomizer=void 0,t.seed&&(e.seed=t.seed+1),e}function P(t){return t.randomizer||(t.randomizer=new p(t.seed||0)),t.randomizer.next()}function F(t,e,n,r=1){return n.roughness*r*(P(n)*(e-t)+t)}function $(t,e,n=1){return F(-t,t,e,n)}function H(t,e,n,r,s,a=!1){const i=a?s.disableMultiStrokeFill:s.disableMultiStroke,o=D(t,e,n,r,s,!0,!1);if(i)return o;const l=D(t,e,n,r,s,!0,!0);return o.concat(l)}function D(t,e,n,r,s,a,i){const o=Math.pow(t-n,2)+Math.pow(e-r,2),l=Math.sqrt(o);let h=1;h=l<200?1:l>500?.4:-.0016668*l+1.233334;let u=s.maxRandomnessOffset||0;u*u*100>o&&(u=l/10);const c=u/2,f=.2+.2*P(s);let p=s.bowing*s.maxRandomnessOffset*(r-e)/200,d=s.bowing*s.maxRandomnessOffset*(t-n)/200;p=$(p,s,h),d=$(d,s,h);const g=[],m=()=>$(c,s,h),y=()=>$(u,s,h),b=s.preserveVertices;return i?g.push({op:"move",data:[t+(b?0:m()),e+(b?0:m())]}):g.push({op:"move",data:[t+(b?0:$(u,s,h)),e+(b?0:$(u,s,h))]}),i?g.push({op:"bcurveTo",data:[p+t+(n-t)*f+m(),d+e+(r-e)*f+m(),p+t+2*(n-t)*f+m(),d+e+2*(r-e)*f+m(),n+(b?0:m()),r+(b?0:m())]}):g.push({op:"bcurveTo",data:[p+t+(n-t)*f+y(),d+e+(r-e)*f+y(),p+t+2*(n-t)*f+y(),d+e+2*(r-e)*f+y(),n+(b?0:y()),r+(b?0:y())]}),g}function U(t,e,n){if(!t.length)return[];const r=[];r.push([t[0][0]+$(e,n),t[0][1]+$(e,n)]),r.push([t[0][0]+$(e,n),t[0][1]+$(e,n)]);for(let s=1;s<t.length;s++)r.push([t[s][0]+$(e,n),t[s][1]+$(e,n)]),s===t.length-1&&r.push([t[s][0]+$(e,n),t[s][1]+$(e,n)]);return G(r,null,n)}function G(t,e,n){const r=t.length,s=[];if(r>3){const e=[],a=1-n.curveTightness;s.push({op:"move",data:[t[1][0],t[1][1]]});for(let n=1;n+2<r;n++){const r=t[n];e[0]=[r[0],r[1]],e[1]=[r[0]+(a*t[n+1][0]-a*t[n-1][0])/6,r[1]+(a*t[n+1][1]-a*t[n-1][1])/6],e[2]=[t[n+1][0]+(a*t[n][0]-a*t[n+2][0])/6,t[n+1][1]+(a*t[n][1]-a*t[n+2][1])/6],e[3]=[t[n+1][0],t[n+1][1]],s.push({op:"bcurveTo",data:[e[1][0],e[1][1],e[2][0],e[2][1],e[3][0],e[3][1]]})}}else 3===r?(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]]})):2===r&&s.push(...D(t[0][0],t[0][1],t[1][0],t[1][1],n,0,!0));return s}function z(t,e,n,r,s,a,i,o){const l=[],h=[];if(0===o.roughness){t/=4,h.push([e+r*Math.cos(-t),n+s*Math.sin(-t)]);for(let a=0;a<=2*Math.PI;a+=t){const t=[e+r*Math.cos(a),n+s*Math.sin(a)];l.push(t),h.push(t)}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 u=$(.5,o)-Math.PI/2;h.push([$(a,o)+e+.9*r*Math.cos(u-t),$(a,o)+n+.9*s*Math.sin(u-t)]);const c=2*Math.PI+u-.01;for(let i=u;i<c;i+=t){const t=[$(a,o)+e+r*Math.cos(i),$(a,o)+n+s*Math.sin(i)];l.push(t),h.push(t)}h.push([$(a,o)+e+r*Math.cos(u+2*Math.PI+.5*i),$(a,o)+n+s*Math.sin(u+2*Math.PI+.5*i)]),h.push([$(a,o)+e+.98*r*Math.cos(u+i),$(a,o)+n+.98*s*Math.sin(u+i)]),h.push([$(a,o)+e+.9*r*Math.cos(u+.5*i),$(a,o)+n+.9*s*Math.sin(u+.5*i)])}return[h,l]}function j(t,e,n,r,s,a,i,o,l){const h=a+$(.1,l),u=[];u.push([$(o,l)+e+.9*r*Math.cos(h-t),$(o,l)+n+.9*s*Math.sin(h-t)]);for(let a=h;a<=i;a+=t)u.push([$(o,l)+e+r*Math.cos(a),$(o,l)+n+s*Math.sin(a)]);return u.push([e+r*Math.cos(i),n+s*Math.sin(i)]),u.push([e+r*Math.cos(i),n+s*Math.sin(i)]),G(u,0,l)}function q(t,e,n,r,s,a,i,o){const l=[],h=[o.maxRandomnessOffset||1,(o.maxRandomnessOffset||1)+.3];let u=[0,0];const c=o.disableMultiStroke?1:2,f=o.preserveVertices;for(let p=0;p<c;p++)0===p?l.push({op:"move",data:[i[0],i[1]]}):l.push({op:"move",data:[i[0]+(f?0:$(h[0],o)),i[1]+(f?0:$(h[0],o))]}),u=f?[s,a]:[s+$(h[p],o),a+$(h[p],o)],l.push({op:"bcurveTo",data:[t+$(h[p],o),e+$(h[p],o),n+$(h[p],o),r+$(h[p],o),u[0],u[1]]});return l}function W(t){return[...t]}function X(t,e=0){const n=t.length;if(n<3)throw new Error("A curve must have at least three points.");const r=[];if(3===n)r.push(W(t[0]),W(t[1]),W(t[2]),W(t[2]));else{const n=[];n.push(t[0],t[0]);for(let e=1;e<t.length;e++)n.push(t[e]),e===t.length-1&&n.push(t[e]);const s=[],a=1-e;r.push(W(n[0]));for(let t=1;t+2<n.length;t++){const e=n[t];s[0]=[e[0],e[1]],s[1]=[e[0]+(a*n[t+1][0]-a*n[t-1][0])/6,e[1]+(a*n[t+1][1]-a*n[t-1][1])/6],s[2]=[n[t+1][0]+(a*n[t][0]-a*n[t+2][0])/6,n[t+1][1]+(a*n[t][1]-a*n[t+2][1])/6],s[3]=[n[t+1][0],n[t+1][1]],r.push(s[1],s[2],s[3])}}return r}function Y(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)}function Q(t,e,n){const r=Y(e,n);if(0===r)return Y(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)),Y(t,Z(e,n,s))}function Z(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]}function B(t,e,n,r){const s=r||[];if(function(t,e){const n=t[e+0],r=t[e+1],s=t[e+2],a=t[e+3];let i=3*r[0]-2*n[0]-a[0];i*=i;let o=3*r[1]-2*n[1]-a[1];o*=o;let l=3*s[0]-2*a[0]-n[0];l*=l;let h=3*s[1]-2*a[1]-n[1];return h*=h,i<l&&(i=l),o<h&&(o=h),i+o}(t,e)<n){const n=t[e+0];if(s.length){(a=s[s.length-1],i=n,Math.sqrt(Y(a,i)))>1&&s.push(n)}else s.push(n);s.push(t[e+3])}else{const r=.5,a=t[e+0],i=t[e+1],o=t[e+2],l=t[e+3],h=Z(a,i,r),u=Z(i,o,r),c=Z(o,l,r),f=Z(h,u,r),p=Z(u,c,r),d=Z(f,p,r);B([a,h,f,d],0,n,s),B([d,p,c,l],0,n,s)}var a,i;return s}function K(t,e){return J(t,0,t.length,e)}function J(t,e,n,r,s){const a=s||[],i=t[e],o=t[n-1];let l=0,h=1;for(let r=e+1;r<n-1;++r){const e=Q(t[r],i,o);e>l&&(l=e,h=r)}return Math.sqrt(l)>r?(J(t,e,h+1,r,a),J(t,h,n,r,a)):(a.length||a.push(i),a.push(o)),a}function tt(t,e=.15,n){const r=[],s=(t.length-1)/3;for(let n=0;n<s;n++){B(t,3*n,e,r)}return n&&n>0?J(r,0,r.length,n):r}const et="none";class nt{constructor(t){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=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,e,n){return{shape:t,sets:e||[],options:n||this.defaultOptions}}line(t,e,n,r,s){const a=this._o(s);return this._d("line",[O(t,e,n,r,a)],a)}rectangle(t,e,n,r,s){const a=this._o(s),i=[],o=E(t,e,n,r,a);if(a.fill){const s=[[t,e],[t+n,e],[t+n,e+r],[t,e+r]];"solid"===a.fillStyle?i.push(R([s],a)):i.push(I([s],a))}return a.stroke!==et&&i.push(o),this._d("rectangle",i,a)}ellipse(t,e,n,r,s){const a=this._o(s),i=[],o=T(n,r,a),l=k(t,e,a,o);if(a.fill)if("solid"===a.fillStyle){const n=k(t,e,a,o).opset;n.type="fillPath",i.push(n)}else i.push(I([l.estimatedPoints],a));return a.stroke!==et&&i.push(l.opset),this._d("ellipse",i,a)}circle(t,e,n,r){const s=this.ellipse(t,e,n,n,r);return s.shape="circle",s}linearPath(t,e){const n=this._o(e);return this._d("linearPath",[S(t,!1,n)],n)}arc(t,e,n,r,s,a,i=!1,o){const l=this._o(o),h=[],u=N(t,e,n,r,s,a,i,!0,l);if(i&&l.fill)if("solid"===l.fillStyle){const i=Object.assign({},l);i.disableMultiStroke=!0;const o=N(t,e,n,r,s,a,!0,!1,i);o.type="fillPath",h.push(o)}else h.push(function(t,e,n,r,s,a,i){const o=t,l=e;let h=Math.abs(n/2),u=Math.abs(r/2);h+=$(.01*h,i),u+=$(.01*u,i);let c=s,f=a;for(;c<0;)c+=2*Math.PI,f+=2*Math.PI;f-c>2*Math.PI&&(c=0,f=2*Math.PI);const p=(f-c)/i.curveStepCount,d=[];for(let t=c;t<=f;t+=p)d.push([o+h*Math.cos(t),l+u*Math.sin(t)]);return d.push([o+h*Math.cos(f),l+u*Math.sin(f)]),d.push([o,l]),I([d],i)}(t,e,n,r,s,a,l));return l.stroke!==et&&h.push(u),this._d("arc",h,l)}curve(t,e){const n=this._o(e),r=[],s=C(t,n);if(n.fill&&n.fill!==et)if("solid"===n.fillStyle){const e=C(t,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(e.ops)})}else{const e=[],s=t;if(s.length){const t="number"==typeof s[0][0]?[s]:s;for(const r of t)r.length<3?e.push(...r):3===r.length?e.push(...tt(X([r[0],r[0],r[1],r[2]]),10,(1+n.roughness)/2)):e.push(...tt(X(r),10,(1+n.roughness)/2))}e.length&&r.push(I([e],n))}return n.stroke!==et&&r.push(s),this._d("curve",r,n)}polygon(t,e){const n=this._o(e),r=[],s=S(t,!0,n);return n.fill&&("solid"===n.fillStyle?r.push(R([t],n)):r.push(I([t],n))),n.stroke!==et&&r.push(s),this._d("polygon",r,n)}path(t,e){const n=this._o(e),r=[];if(!t)return this._d("path",r,n);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const s=n.fill&&"transparent"!==n.fill&&n.fill!==et,a=n.stroke!==et,i=!!(n.simplification&&n.simplification<1),o=function(t,e,n){const r=M(x(v(t))),s=[];let a=[],i=[0,0],o=[];const l=()=>{o.length>=4&&a.push(...tt(o,e)),o=[]},h=()=>{l(),a.length&&(s.push(a),a=[])};for(const{key:t,data:e}of r)switch(t){case"M":h(),i=[e[0],e[1]],a.push(i);break;case"L":l(),a.push([e[0],e[1]]);break;case"C":if(!o.length){const t=a.length?a[a.length-1]:i;o.push([t[0],t[1]])}o.push([e[0],e[1]]),o.push([e[2],e[3]]),o.push([e[4],e[5]]);break;case"Z":l(),a.push([i[0],i[1]])}if(h(),!n)return s;const u=[];for(const t of s){const e=K(t,n);e.length&&u.push(e)}return u}(t,1,i?4-4*(n.simplification||1):(1+n.roughness)/2),l=V(t,n);if(s)if("solid"===n.fillStyle)if(1===o.length){const e=V(t,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(e.ops)})}else r.push(R(o,n));else r.push(I(o,n));return a&&(i?o.forEach((t=>{r.push(S(t,!1,n))})):r.push(l)),this._d("path",r,n)}opsToPath(t,e){let n="";for(const r of t.ops){const t="number"==typeof e&&e>=0?r.data.map((t=>+t.toFixed(e))):r.data;switch(r.op){case"move":n+=`M${t[0]} ${t[1]} `;break;case"bcurveTo":n+=`C${t[0]} ${t[1]}, ${t[2]} ${t[3]}, ${t[4]} ${t[5]} `;break;case"lineTo":n+=`L${t[0]} ${t[1]} `}}return n.trim()}toPaths(t){const e=t.sets||[],n=t.options||this.defaultOptions,r=[];for(const t of e){let e=null;switch(t.type){case"path":e={d:this.opsToPath(t),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:et};break;case"fillPath":e={d:this.opsToPath(t),stroke:et,strokeWidth:0,fill:n.fill||et};break;case"fillSketch":e=this.fillSketch(t,n)}e&&r.push(e)}return r}fillSketch(t,e){let n=e.fillWeight;return n<0&&(n=e.strokeWidth/2),{d:this.opsToPath(t),stroke:e.fill||et,strokeWidth:n,fill:et}}_mergedShape(t){return t.filter(((t,e)=>0===e||"move"!==t.op))}}class rt{constructor(t,e){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new nt(e)}draw(t){const e=t.sets||[],n=t.options||this.getDefaultOptions(),r=this.ctx,s=t.options.fixedDecimalPlaceDigits;for(const a of e)switch(a.type){case"path":r.save(),r.strokeStyle="none"===n.stroke?"transparent":n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,s),r.restore();break;case"fillPath":{r.save(),r.fillStyle=n.fill||"";const e="curve"===t.shape||"polygon"===t.shape||"path"===t.shape?"evenodd":"nonzero";this._drawToContext(r,a,s,e),r.restore();break}case"fillSketch":this.fillSketch(r,a,n)}}fillSketch(t,e,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),t.save(),n.fillLineDash&&t.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(t.lineDashOffset=n.fillLineDashOffset),t.strokeStyle=n.fill||"",t.lineWidth=r,this._drawToContext(t,e,n.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,e,n,r="nonzero"){t.beginPath();for(const r of e.ops){const e="number"==typeof n&&n>=0?r.data.map((t=>+t.toFixed(n))):r.data;switch(r.op){case"move":t.moveTo(e[0],e[1]);break;case"bcurveTo":t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]);break;case"lineTo":t.lineTo(e[0],e[1])}}"fillPath"===e.type?t.fill(r):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,e,n,r,s){const a=this.gen.line(t,e,n,r,s);return this.draw(a),a}rectangle(t,e,n,r,s){const a=this.gen.rectangle(t,e,n,r,s);return this.draw(a),a}ellipse(t,e,n,r,s){const a=this.gen.ellipse(t,e,n,r,s);return this.draw(a),a}circle(t,e,n,r){const s=this.gen.circle(t,e,n,r);return this.draw(s),s}linearPath(t,e){const n=this.gen.linearPath(t,e);return this.draw(n),n}polygon(t,e){const n=this.gen.polygon(t,e);return this.draw(n),n}arc(t,e,n,r,s,a,i=!1,o){const l=this.gen.arc(t,e,n,r,s,a,i,o);return this.draw(l),l}curve(t,e){const n=this.gen.curve(t,e);return this.draw(n),n}path(t,e){const n=this.gen.path(t,e);return this.draw(n),n}}const st="http://www.w3.org/2000/svg";class at{constructor(t,e){this.svg=t,this.gen=new nt(e)}draw(t){const e=t.sets||[],n=t.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,s=r.createElementNS(st,"g"),a=t.options.fixedDecimalPlaceDigits;for(const i of e){let e=null;switch(i.type){case"path":e=r.createElementNS(st,"path"),e.setAttribute("d",this.opsToPath(i,a)),e.setAttribute("stroke",n.stroke),e.setAttribute("stroke-width",n.strokeWidth+""),e.setAttribute("fill","none"),n.strokeLineDash&&e.setAttribute("stroke-dasharray",n.strokeLineDash.join(" ").trim()),n.strokeLineDashOffset&&e.setAttribute("stroke-dashoffset",`${n.strokeLineDashOffset}`);break;case"fillPath":e=r.createElementNS(st,"path"),e.setAttribute("d",this.opsToPath(i,a)),e.setAttribute("stroke","none"),e.setAttribute("stroke-width","0"),e.setAttribute("fill",n.fill||""),"curve"!==t.shape&&"polygon"!==t.shape||e.setAttribute("fill-rule","evenodd");break;case"fillSketch":e=this.fillSketch(r,i,n)}e&&s.appendChild(e)}return s}fillSketch(t,e,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);const s=t.createElementNS(st,"path");return s.setAttribute("d",this.opsToPath(e,n.fixedDecimalPlaceDigits)),s.setAttribute("stroke",n.fill||""),s.setAttribute("stroke-width",r+""),s.setAttribute("fill","none"),n.fillLineDash&&s.setAttribute("stroke-dasharray",n.fillLineDash.join(" ").trim()),n.fillLineDashOffset&&s.setAttribute("stroke-dashoffset",`${n.fillLineDashOffset}`),s}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,e){return this.gen.opsToPath(t,e)}line(t,e,n,r,s){const a=this.gen.line(t,e,n,r,s);return this.draw(a)}rectangle(t,e,n,r,s){const a=this.gen.rectangle(t,e,n,r,s);return this.draw(a)}ellipse(t,e,n,r,s){const a=this.gen.ellipse(t,e,n,r,s);return this.draw(a)}circle(t,e,n,r){const s=this.gen.circle(t,e,n,r);return this.draw(s)}linearPath(t,e){const n=this.gen.linearPath(t,e);return this.draw(n)}polygon(t,e){const n=this.gen.polygon(t,e);return this.draw(n)}arc(t,e,n,r,s,a,i=!1,o){const l=this.gen.arc(t,e,n,r,s,a,i,o);return this.draw(l)}curve(t,e){const n=this.gen.curve(t,e);return this.draw(n)}path(t,e){const n=this.gen.path(t,e);return this.draw(n)}}var it,ot={canvas:(t,e)=>new rt(t,e),svg:(t,e)=>new at(t,e),generator:t=>new nt(t),newSeed:()=>nt.newSeed()};function lt(t){if(void 0!==t.children)return t.children;let e,n=0;const r=t.childNodes,s=[];for(;e=r[n++];)1===e.nodeType&&s.push(e);return s}function ht(t){const e=t.parentNode;return e&&e.nodeType===Node.ELEMENT_NODE?e:null}function ut(t,e){for(;e.firstChild;)t.append(e.firstChild);return t}function ct(t){if(null===t)return null;const e=/url\('#?(.*?)'\)/.exec(t)||/url\("#?(.*?)"\)/.exec(t)||/url\(#?(.*?)\)/.exec(t);return e&&e.length>1?e[1]:null}t.OutputType=void 0,(it=t.OutputType||(t.OutputType={}))[it.SVG=0]="SVG",it[it.CANVAS=1]="CANVAS";const ft="data-sketchy-clip-path",pt=/[acsqt]/i;function dt(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 gt(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 t=0;t<r.length;t++){const e=r[t],n=e.split(",");if(2===n.length)s.push({x:parseFloat(n[0]),y:parseFloat(n[1])});else{const n=t+1;n<r.length&&(s.push({x:parseFloat(e),y:parseFloat(r[n])}),t=n)}}return s}function mt(t,e,n){let r=n;const s=e.getAttribute(ft),a=t.pencilFilter&&"text"!==e.tagName;if(!("g"===r.tagName&&0===r.attributes.length)&&(s||a)){const t=document.createElementNS("http://www.w3.org/2000/svg","g");t.appendChild(r),r=t}s&&(r.setAttribute("clip-path",`url(#${s})`),e.removeAttribute(ft)),a&&r.setAttribute("filter","url(#pencilTextureFilter)"),t.svgSketch.appendChild(r)}function yt(t,e,n){return pt.test(e)&&(n=n?Object.assign(Object.assign({},n),{preserveVertices:!0}):{preserveVertices:!0}),t.rc.path(e,n)}function bt(t,e,n,r){let s;if(s=r?e.getAttribute(n):getComputedStyle(e)[n]||e.getAttribute(n),!s){let s=ht(e);const a=r;let i=a;if(a&&a.referenced===e&&(s=a.root,i=a.parentContext),!s||s===t.sourceSvg)return;return bt(t,s,n,i)}return s}function vt(t,e,n,r){let s;if(s=r?e.getAttribute("opacity"):getComputedStyle(e).opacity||e.getAttribute("opacity"),s){let t=1;t=-1!==s.indexOf("%")?Math.min(1,Math.max(0,parseFloat(s.substring(0,s.length-1))/100)):Math.min(1,Math.max(0,parseFloat(s))),n*=t}let a=ht(e);const i=r;let o=i;return i&&i.referenced===e&&(a=i.root,o=i.parentContext),a&&a!==t.sourceSvg?vt(t,a,n,o):n}function xt(t,e,n){const{fillId:r,strokeId:s}=function(t,e){function n(n){const r=e.getAttribute(n);if(r&&-1!==r.indexOf("url")){const e=ct(r);if(e){if(t.idElements[e]instanceof SVGPatternElement)return e}}return null}return{fillId:n("fill"),strokeId:n("stroke")}}(t,e);if(null!==r||null!==s){const a=n();a.setAttribute("fill",null!==r?`url(#${r})`:"none"),a.setAttribute("stroke",null!==s?`url(#${s})`:"none");const i=bt(t,e,"stroke-width",t.useElementContext);a.setAttribute("stroke-width",null!=i?i:"0"),mt(t,e,a),Mt(t,r),Mt(t,s)}}function Mt(t,e){if(null===e)return;const n=dt(t),r=`#${e}`;if(!n.querySelector(r)){const e=t.sourceSvg.querySelector(r);if(e){if(!t.sketchPatterns)return void n.appendChild(e.cloneNode(!0));const r=function(t,e,n){const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.appendChild(e);const s=Object.assign(Object.assign({},t),{sourceSvg:r,svgSketch:document.createElementNS("http://www.w3.org/2000/svg","svg"),roughConfig:Object.assign(Object.assign({},t.roughConfig),n)});return s.processElement(s,e,null),ut(document.createElementNS("http://www.w3.org/2000/svg","g"),s.svgSketch)}(t,ut(document.createElementNS("http://www.w3.org/2000/svg","g"),e.cloneNode(!0)),{fillStyle:"solid",roughness:.5}),s=e.cloneNode();n.appendChild(ut(s,r))}}}function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}var At=/^\s+/,_t=/\s+$/;function Ot(t,e){if(e=e||{},(t=t||"")instanceof Ot)return t;if(!(this instanceof Ot))return new Ot(t,e);var n=function(t){var e={r:0,g:0,b:0},n=1,r=null,s=null,a=null,i=!1,o=!1;"string"==typeof t&&(t=function(t){t=t.replace(At,"").replace(_t,"").toLowerCase();var e,n=!1;if(Gt[t])t=Gt[t],n=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=ee.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=ee.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=ee.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=ee.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=ee.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=ee.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=ee.hex8.exec(t))return{r:Xt(e[1]),g:Xt(e[2]),b:Xt(e[3]),a:Bt(e[4]),format:n?"name":"hex8"};if(e=ee.hex6.exec(t))return{r:Xt(e[1]),g:Xt(e[2]),b:Xt(e[3]),format:n?"name":"hex"};if(e=ee.hex4.exec(t))return{r:Xt(e[1]+""+e[1]),g:Xt(e[2]+""+e[2]),b:Xt(e[3]+""+e[3]),a:Bt(e[4]+""+e[4]),format:n?"name":"hex8"};if(e=ee.hex3.exec(t))return{r:Xt(e[1]+""+e[1]),g:Xt(e[2]+""+e[2]),b:Xt(e[3]+""+e[3]),format:n?"name":"hex"};return!1}(t));"object"==wt(t)&&(ne(t.r)&&ne(t.g)&&ne(t.b)?(e=function(t,e,n){return{r:255*qt(t,255),g:255*qt(e,255),b:255*qt(n,255)}}(t.r,t.g,t.b),i=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):ne(t.h)&&ne(t.s)&&ne(t.v)?(r=Qt(t.s),s=Qt(t.v),e=function(t,e,n){t=6*qt(t,360),e=qt(e,100),n=qt(n,100);var r=Math.floor(t),s=t-r,a=n*(1-e),i=n*(1-s*e),o=n*(1-(1-s)*e),l=r%6,h=[n,i,a,a,o,n][l],u=[o,n,n,i,a,a][l],c=[a,a,o,n,n,i][l];return{r:255*h,g:255*u,b:255*c}}(t.h,r,s),i=!0,o="hsv"):ne(t.h)&&ne(t.s)&&ne(t.l)&&(r=Qt(t.s),a=Qt(t.l),e=function(t,e,n){var r,s,a;function i(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=qt(t,360),e=qt(e,100),n=qt(n,100),0===e)r=s=a=n;else{var o=n<.5?n*(1+e):n+e-n*e,l=2*n-o;r=i(l,o,t+1/3),s=i(l,o,t),a=i(l,o,t-1/3)}return{r:255*r,g:255*s,b:255*a}}(t.h,r,a),i=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a));return n=jt(n),{ok:i,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}}(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}function St(t,e,n){t=qt(t,255),e=qt(e,255),n=qt(n,255);var r,s,a=Math.max(t,e,n),i=Math.min(t,e,n),o=(a+i)/2;if(a==i)r=s=0;else{var l=a-i;switch(s=o>.5?l/(2-a-i):l/(a+i),a){case t:r=(e-n)/l+(e<n?6:0);break;case e:r=(n-t)/l+2;break;case n:r=(t-e)/l+4}r/=6}return{h:r,s:s,l:o}}function Et(t,e,n){t=qt(t,255),e=qt(e,255),n=qt(n,255);var r,s,a=Math.max(t,e,n),i=Math.min(t,e,n),o=a,l=a-i;if(s=0===a?0:l/a,a==i)r=0;else{switch(a){case t:r=(e-n)/l+(e<n?6:0);break;case e:r=(n-t)/l+2;break;case n:r=(t-e)/l+4}r/=6}return{h:r,s:s,v:o}}function Ct(t,e,n,r){var s=[Yt(Math.round(t).toString(16)),Yt(Math.round(e).toString(16)),Yt(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 Tt(t,e,n,r){return[Yt(Zt(r)),Yt(Math.round(t).toString(16)),Yt(Math.round(e).toString(16)),Yt(Math.round(n).toString(16))].join("")}function kt(t,e){e=0===e?0:e||10;var n=Ot(t).toHsl();return n.s-=e/100,n.s=Wt(n.s),Ot(n)}function Nt(t,e){e=0===e?0:e||10;var n=Ot(t).toHsl();return n.s+=e/100,n.s=Wt(n.s),Ot(n)}function Vt(t){return Ot(t).desaturate(100)}function Rt(t,e){e=0===e?0:e||10;var n=Ot(t).toHsl();return n.l+=e/100,n.l=Wt(n.l),Ot(n)}function It(t,e){e=0===e?0:e||10;var n=Ot(t).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-e/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-e/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-e/100*255))),Ot(n)}function Lt(t,e){e=0===e?0:e||10;var n=Ot(t).toHsl();return n.l-=e/100,n.l=Wt(n.l),Ot(n)}function Pt(t,e){var n=Ot(t).toHsl(),r=(n.h+e)%360;return n.h=r<0?360+r:r,Ot(n)}function Ft(t){var e=Ot(t).toHsl();return e.h=(e.h+180)%360,Ot(e)}function $t(t,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var n=Ot(t).toHsl(),r=[Ot(t)],s=360/e,a=1;a<e;a++)r.push(Ot({h:(n.h+a*s)%360,s:n.s,l:n.l}));return r}function Ht(t){var e=Ot(t).toHsl(),n=e.h;return[Ot(t),Ot({h:(n+72)%360,s:e.s,l:e.l}),Ot({h:(n+216)%360,s:e.s,l:e.l})]}function Dt(t,e,n){e=e||6,n=n||30;var r=Ot(t).toHsl(),s=360/n,a=[Ot(t)];for(r.h=(r.h-(s*e>>1)+720)%360;--e;)r.h=(r.h+s)%360,a.push(Ot(r));return a}function Ut(t,e){e=e||6;for(var n=Ot(t).toHsv(),r=n.h,s=n.s,a=n.v,i=[],o=1/e;e--;)i.push(Ot({h:r,s:s,v:a})),a=(a+o)%1;return i}Ot.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 t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,r=this.toRgb();return t=r.r/255,e=r.g/255,n=r.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=jt(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Et(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Et(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),r=Math.round(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=St(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=St(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),r=Math.round(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Ct(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,s){var a=[Yt(Math.round(t).toString(16)),Yt(Math.round(e).toString(16)),Yt(Math.round(n).toString(16)),Yt(Zt(r))];if(s&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1))return a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0);return a.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"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(100*qt(this._r,255))+"%",g:Math.round(100*qt(this._g,255))+"%",b:Math.round(100*qt(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%)":"rgba("+Math.round(100*qt(this._r,255))+"%, "+Math.round(100*qt(this._g,255))+"%, "+Math.round(100*qt(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(zt[Ct(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+Tt(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var s=Ot(t);n="#"+Tt(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Ot(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(Rt,arguments)},brighten:function(){return this._applyModification(It,arguments)},darken:function(){return this._applyModification(Lt,arguments)},desaturate:function(){return this._applyModification(kt,arguments)},saturate:function(){return this._applyModification(Nt,arguments)},greyscale:function(){return this._applyModification(Vt,arguments)},spin:function(){return this._applyModification(Pt,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(Dt,arguments)},complement:function(){return this._applyCombination(Ft,arguments)},monochromatic:function(){return this._applyCombination(Ut,arguments)},splitcomplement:function(){return this._applyCombination(Ht,arguments)},triad:function(){return this._applyCombination($t,[3])},tetrad:function(){return this._applyCombination($t,[4])}},Ot.fromRatio=function(t,e){if("object"==wt(t)){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:Qt(t[r]));t=n}return Ot(t,e)},Ot.equals=function(t,e){return!(!t||!e)&&Ot(t).toRgbString()==Ot(e).toRgbString()},Ot.random=function(){return Ot.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Ot.mix=function(t,e,n){n=0===n?0:n||50;var r=Ot(t).toRgb(),s=Ot(e).toRgb(),a=n/100;return Ot({r:(s.r-r.r)*a+r.r,g:(s.g-r.g)*a+r.g,b:(s.b-r.b)*a+r.b,a:(s.a-r.a)*a+r.a})},Ot.readability=function(t,e){var n=Ot(t),r=Ot(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},Ot.isReadable=function(t,e,n){var r,s,a=Ot.readability(t,e);switch(s=!1,(r=function(t){var e,n;e=((t=t||{level:"AA",size:"small"}).level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA");"small"!==n&&"large"!==n&&(n="small");return{level:e,size:n}}(n)).level+r.size){case"AAsmall":case"AAAlarge":s=a>=4.5;break;case"AAlarge":s=a>=3;break;case"AAAsmall":s=a>=7}return s},Ot.mostReadable=function(t,e,n){var r,s,a,i,o=null,l=0;s=(n=n||{}).includeFallbackColors,a=n.level,i=n.size;for(var h=0;h<e.length;h++)(r=Ot.readability(t,e[h]))>l&&(l=r,o=Ot(e[h]));return Ot.isReadable(t,o,{level:a,size:i})||!s?o:(n.includeFallbackColors=!1,Ot.mostReadable(t,["#fff","#000"],n))};var Gt=Ot.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"},zt=Ot.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(Gt);function jt(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function qt(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(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 Wt(t){return Math.min(1,Math.max(0,t))}function Xt(t){return parseInt(t,16)}function Yt(t){return 1==t.length?"0"+t:""+t}function Qt(t){return t<=1&&(t=100*t+"%"),t}function Zt(t){return Math.round(255*parseFloat(t)).toString(16)}function Bt(t){return Xt(t)/255}var Kt,Jt,te,ee=(Jt="[\\s|\\(]+("+(Kt="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+Kt+")[,|\\s]+("+Kt+")\\s*\\)?",te="[\\s|\\(]+("+Kt+")[,|\\s]+("+Kt+")[,|\\s]+("+Kt+")[,|\\s]+("+Kt+")\\s*\\)?",{CSS_UNIT:new RegExp(Kt),rgb:new RegExp("rgb"+Jt),rgba:new RegExp("rgba"+te),hsl:new RegExp("hsl"+Jt),hsla:new RegExp("hsla"+te),hsv:new RegExp("hsv"+Jt),hsva:new RegExp("hsva"+te),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 ne(t){return!!ee.CSS_UNIT.exec(t)}const re=/^([+-]?(?:\d+|\d*\.\d+(?:[eE][+-]?\d+)?))([a-z]*|%)$/,se={in:96,cm:96/2.54,mm:96/25.4,pt:96/72,pc:16,px:1},ae=Math.sqrt(2);function ie(t,e,n,r){const{value:s,unit:a}=oe(n);return function(t){return!!se[t]}(a)?function(t,e){var n;const r=null!==(n=se[e])&&void 0!==n?n:1;return t*r}(s,a):function(t,e,n,r,s){var a;const i=null!==(a=t.viewBox)&&void 0!==a?a:{w:0,h:0};if("%"===s)return function(t,e,{w:n,h:r}={w:0,h:0}){const s=e/100;if("x"===t)return s*n;if("y"===t)return s*r;return s*(Math.sqrt(n*n+r*r)/ae)}(n,r,i);if("vw"===s||"vh"===s||"vmin"===s||"vmax"===s)return function(t,e,{w:n,h:r}={w:0,h:0}){var s,a;const i=t/100,o=null!==(s=window.innerWidth)&&void 0!==s?s:n,l=null!==(a=window.innerHeight)&&void 0!==a?a:r;if("vw"===e)return i*o;if("vh"===e)return i*l;if("vmin"===e)return i*Math.min(o,l);if("vmax"===e)return i*Math.max(o,l);throw new Error(`Not a viewport length unit: ${e}`)}(r,s,i);if("em"===s||"ex"===s||"ch"===s||"rem"===s)return function(t,e,n,r){var s;if("rem"===r){const t=document.documentElement,e=oe(getComputedStyle(t).fontSize);return n*("px"===e.unit?e.value:16)}if("ch"===r){const t=function(t){const e=ht(t);if(!e)return 1;const n=document.createElementNS("http://www.w3.org/2000/svg","text");n.style.visibility="hidden",n.appendChild(document.createTextNode("0")),e.appendChild(n);const r=n.getBBox();return e.removeChild(n),r.width}(e);return n*t}const a=null!==(s=bt(t,e,"font-size",t.useElementContext))&&void 0!==s?s:"16px",i=oe(a),o="px"===i.unit?i.value:16;if("em"===r)return n*o;if("ex"===r)return n*o*.5;throw new Error(`Not a font relative unit: ${r}`)}(t,e,r,s);throw new Error(`Unsupported relative length unit: ${s}`)}(t,e,r,s,a)}function oe(t){const e=t.match(re);if(null===e||3!==e.length)throw new Error(`Cannot parse dimension: ${t}`);return{value:parseFloat(e[1]),unit:e[2].toLowerCase()||"px"}}function le(t){if(!t)return!0;const e=t.matrix;return!e||1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f}function he(t){if(!t)return!0;const e=t.matrix;return!e||1===e.a&&0===e.b&&0===e.c&&1===e.d}function ue(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 ce(t){return t.transform&&t.transform.baseVal.numberOfItems>0?t.transform.baseVal.consolidate():null}function fe(t,e,n){if(!n)return ce(e);const r=ce(e);if(r){const e=r.matrix,s=n.matrix.multiply(e);return t.sourceSvg.createSVGTransformFromMatrix(s)}return n}function pe(t,e,n){if(e&&e.matrix&&!le(e)){const t=e.matrix;n.transform.baseVal.numberOfItems>0?n.transform.baseVal.getItem(0).setMatrix(t):n.transform.baseVal.appendItem(e)}}function de(t){var e;let n=t.getAttribute("stop-color");if(!n){const r=null!==(e=t.getAttribute("style"))&&void 0!==e?e:"",s=/stop-color:\s?(.*);?/.exec(r);s&&s.length>1&&(n=s[1])}return Ot(n||"white")}function ge(t){const e=t.length;let n=0,r=0,s=0,a=0;return t.forEach((t=>{const e=t.toRgb();n+=e.r*e.r,r+=e.g*e.g,s+=e.b*e.b,a+=e.a})),Ot({r:Math.sqrt(n/e),g:Math.sqrt(r/e),b:Math.sqrt(s/e),a:a/e})}function me(t){const e=t.getAttribute("offset");return e?e.indexOf("%")?parseFloat(e.substring(0,e.length-1)):100*parseFloat(e):0}function ye(t,e){if("solid"===t.roughConfig.fillStyle)return{angle:0,gap:0,weight:0};const{width:n,height:r}=e.getBoundingClientRect(),s=n/r,a=Math.sqrt(n*r),{angle:i,gap:o,weight:l}=function(t){const e={angle:{normal:[-30,-50],horizontal:[-30,-50],vertical:[-30,-50]},weight:{normal:[.5,3],small:[.5,3]},gap:{normal:[3,5],small:[3,5]}},n={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(t){default:return n;case"zigzag":case"zigzag-line":return Object.assign(Object.assign({},n),{weight:{normal:[.5,3],small:[.5,2]},gap:{normal:[2,6],small:[2,5]}});case"cross-hatch":return Object.assign(Object.assign({},n),{weight:{normal:[1,3],small:[.5,1.3]},gap:{normal:[4,8],small:[2,5]}});case"dots":return e}}(t.roughConfig.fillStyle);return{angle:be(t,i,s),gap:ve(t,o,a),weight:xe(t,l,a)}}function be({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 ve({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function xe({rng:t},{normal:e,small:n},r){return r<45?t.next(n):t.next(e)}function Me(t,e,n){var r;const s=null!==(r=t.roughConfig.fixedDecimalPlaceDigits)&&void 0!==r?r:15,a=Object.assign({},t.roughConfig);let i=1;if(!le(n)){const t=n.matrix,e=t.a*t.d-t.c*t.b;i=Math.sqrt(Math.abs(e))}const o=vt(t,e,1,t.useElementContext),l=bt(t,e,"fill",t.useElementContext)||"black",h=o*we(e,"fill-opacity");if(l)if(-1!==l.indexOf("url")){const e=Ae(t,l,h);"none"!==e?a.fill=e:delete a.fill}else if("none"===l)delete a.fill;else{const t=Ot(l);t.setAlpha(h),a.fill=t.toString()}const u=bt(t,e,"stroke",t.useElementContext),c=o*we(e,"stroke-opacity");if(u)if(-1!==u.indexOf("url"))a.stroke=Ae(t,u,c);else if("none"===u)a.stroke="none";else{const t=Ot(u);t.setAlpha(c),a.stroke=t.toString()}else a.stroke="none";const f=bt(t,e,"stroke-width",t.useElementContext);if(f){const n=ie(t,e,f,"stroke-width")*i;a.strokeWidth=parseFloat(n.toFixed(s))}else a.strokeWidth=1;const p=bt(t,e,"stroke-dasharray",t.useElementContext);p&&"none"!==p&&(a.strokeLineDash=p.split(/[\s,]+/).filter((t=>t.length>0)).map((n=>{const r=ie(t,e,n,"stroke-dasharray")*i;return Math.max(.5,parseFloat(r.toFixed(s)))})));const d=bt(t,e,"stroke-dashoffset",t.useElementContext);if(d){const n=ie(t,e,d,"stroke-dashoffset")*i;a.strokeLineDashOffset=parseFloat(n.toFixed(s))}if(a.fill&&"none"===a.stroke&&(a.stroke=a.fill,a.strokeWidth=1),t.randomize){const{angle:n,gap:r,weight:i}=ye(t,e);a.hachureAngle=n,a.hachureGap=Math.round(r),a.fillWeight=parseFloat(i.toFixed(s)),void 0===a.disableMultiStroke&&(a.disableMultiStroke=t.rng.next()>.3)}return a}function we(t,e){const n=getComputedStyle(t)[e]||t.getAttribute(e);return n?-1!==n.indexOf("%")?Math.min(1,Math.max(0,parseFloat(n.substring(0,n.length-1))/100)):Math.min(1,Math.max(0,parseFloat(n))):1}function Ae(t,e,n){const r=ct(e);if(!r)return"none";const s=t.idElements[r];if(!s)return"none";if("string"==typeof s)return s;if(s instanceof SVGLinearGradientElement||s instanceof SVGRadialGradientElement){const e=function(t,e){const n=Array.prototype.slice.apply(t.querySelectorAll("stop"));if(0===n.length)return"transparent";if(1===n.length){const t=de(n[0]);return t.setAlpha(e),t.toString()}{const t=10,r=[];let s=null;for(let e=0;e<n.length;e++){const a=de(n[e]),i=me(n[e]),o=s?ge([s,a]):a;let l=Math.max(1,i/t|0);for(;l>0;)r.push(o),l--;s=a}const a=ge(r);return a.setAlpha(e),a.toString()}}(s,n);return t.idElements[r]=e,e}return"none"}function _e(t){return`${t.x},${t.y}`}
|
| 2 |
+
/*! *****************************************************************************
|
| 3 |
+
Copyright (c) Microsoft Corporation.
|
| 4 |
+
|
| 5 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 6 |
+
purpose with or without fee is hereby granted.
|
| 7 |
+
|
| 8 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
| 9 |
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
| 10 |
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
| 11 |
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
| 12 |
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
| 13 |
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
| 14 |
+
PERFORMANCE OF THIS SOFTWARE.
|
| 15 |
+
***************************************************************************** */
|
| 16 |
+
var Oe=function(t,e){return(Oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function Se(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}Oe(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function Ee(t){var e="";Array.isArray(t)||(t=[t]);for(var n=0;n<t.length;n++){var r=t[n];if(r.type===je.CLOSE_PATH)e+="z";else if(r.type===je.HORIZ_LINE_TO)e+=(r.relative?"h":"H")+r.x;else if(r.type===je.VERT_LINE_TO)e+=(r.relative?"v":"V")+r.y;else if(r.type===je.MOVE_TO)e+=(r.relative?"m":"M")+r.x+" "+r.y;else if(r.type===je.LINE_TO)e+=(r.relative?"l":"L")+r.x+" "+r.y;else if(r.type===je.CURVE_TO)e+=(r.relative?"c":"C")+r.x1+" "+r.y1+" "+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===je.SMOOTH_CURVE_TO)e+=(r.relative?"s":"S")+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===je.QUAD_TO)e+=(r.relative?"q":"Q")+r.x1+" "+r.y1+" "+r.x+" "+r.y;else if(r.type===je.SMOOTH_QUAD_TO)e+=(r.relative?"t":"T")+r.x+" "+r.y;else{if(r.type!==je.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 Ce(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 Te(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;n++)if("number"!=typeof t[n])throw new Error("assertNumbers arguments["+n+"] is not a number. "+typeof t[n]+" == typeof "+t[n]);return!0}var ke=Math.PI;function Ne(t,e,n){t.lArcFlag=0===t.lArcFlag?0:1,t.sweepFlag=0===t.sweepFlag?0:1;var r=t.rX,s=t.rY,a=t.x,i=t.y;r=Math.abs(t.rX),s=Math.abs(t.rY);var o=Ce([(e-a)/2,(n-i)/2],-t.xRot/180*ke),l=o[0],h=o[1],u=Math.pow(l,2)/Math.pow(r,2)+Math.pow(h,2)/Math.pow(s,2);1<u&&(r*=Math.sqrt(u),s*=Math.sqrt(u)),t.rX=r,t.rY=s;var c=Math.pow(r,2)*Math.pow(h,2)+Math.pow(s,2)*Math.pow(l,2),f=(t.lArcFlag!==t.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(r,2)*Math.pow(s,2)-c)/c)),p=r*h/s*f,d=-s*l/r*f,g=Ce([p,d],t.xRot/180*ke);t.cX=g[0]+(e+a)/2,t.cY=g[1]+(n+i)/2,t.phi1=Math.atan2((h-d)/s,(l-p)/r),t.phi2=Math.atan2((-h-d)/s,(-l-p)/r),0===t.sweepFlag&&t.phi2>t.phi1&&(t.phi2-=2*ke),1===t.sweepFlag&&t.phi2<t.phi1&&(t.phi2+=2*ke),t.phi1*=180/ke,t.phi2*=180/ke}function Ve(t,e,n){Te(t,e,n);var r=t*t+e*e-n*n;if(0>r)return[];if(0===r)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 Re,Ie=Math.PI/180;function Le(t,e,n){return(1-n)*t+n*e}function Pe(t,e,n,r){return t+Math.cos(r/180*ke)*e+Math.sin(r/180*ke)*n}function Fe(t,e,n,r){var s=1e-6,a=e-t,i=n-e,o=3*a+3*(r-n)-6*i,l=6*(i-a),h=3*a;return Math.abs(o)<s?[-h/l]:function(t,e,n){var r=t*t/4-e;if(r<-n)return[];if(r<=n)return[-t/2];var s=Math.sqrt(r);return[-t/2-s,-t/2+s]}(l/o,h/o,s)}function $e(t,e,n,r,s){var a=1-s;return t*(a*a*a)+e*(3*a*a*s)+n*(3*a*s*s)+r*(s*s*s)}!function(t){function e(){return s((function(t,e,n){return t.relative&&(void 0!==t.x1&&(t.x1+=e),void 0!==t.y1&&(t.y1+=n),void 0!==t.x2&&(t.x2+=e),void 0!==t.y2&&(t.y2+=n),void 0!==t.x&&(t.x+=e),void 0!==t.y&&(t.y+=n),t.relative=!1),t}))}function n(){var t=NaN,e=NaN,n=NaN,r=NaN;return s((function(s,a,i){return s.type&je.SMOOTH_CURVE_TO&&(s.type=je.CURVE_TO,t=isNaN(t)?a:t,e=isNaN(e)?i:e,s.x1=s.relative?a-t:2*a-t,s.y1=s.relative?i-e:2*i-e),s.type&je.CURVE_TO?(t=s.relative?a+s.x2:s.x2,e=s.relative?i+s.y2:s.y2):(t=NaN,e=NaN),s.type&je.SMOOTH_QUAD_TO&&(s.type=je.QUAD_TO,n=isNaN(n)?a:n,r=isNaN(r)?i:r,s.x1=s.relative?a-n:2*a-n,s.y1=s.relative?i-r:2*i-r),s.type&je.QUAD_TO?(n=s.relative?a+s.x1:s.x1,r=s.relative?i+s.y1:s.y1):(n=NaN,r=NaN),s}))}function r(){var t=NaN,e=NaN;return s((function(n,r,s){if(n.type&je.SMOOTH_QUAD_TO&&(n.type=je.QUAD_TO,t=isNaN(t)?r:t,e=isNaN(e)?s:e,n.x1=n.relative?r-t:2*r-t,n.y1=n.relative?s-e:2*s-e),n.type&je.QUAD_TO){t=n.relative?r+n.x1:n.x1,e=n.relative?s+n.y1:n.y1;var a=n.x1,i=n.y1;n.type=je.CURVE_TO,n.x1=((n.relative?0:r)+2*a)/3,n.y1=((n.relative?0:s)+2*i)/3,n.x2=(n.x+2*a)/3,n.y2=(n.y+2*i)/3}else t=NaN,e=NaN;return n}))}function s(t){var e=0,n=0,r=NaN,s=NaN;return function(a){if(isNaN(r)&&!(a.type&je.MOVE_TO))throw new Error("path must start with moveto");var i=t(a,e,n,r,s);return a.type&je.CLOSE_PATH&&(e=r,n=s),void 0!==a.x&&(e=a.relative?e+a.x:a.x),void 0!==a.y&&(n=a.relative?n+a.y:a.y),a.type&je.MOVE_TO&&(r=e,s=n),i}}function a(t,e,n,r,a,i){return Te(t,e,n,r,a,i),s((function(s,o,l,h){var u=s.x1,c=s.x2,f=s.relative&&!isNaN(h),p=void 0!==s.x?s.x:f?0:o,d=void 0!==s.y?s.y:f?0:l;function g(t){return t*t}s.type&je.HORIZ_LINE_TO&&0!==e&&(s.type=je.LINE_TO,s.y=s.relative?0:l),s.type&je.VERT_LINE_TO&&0!==n&&(s.type=je.LINE_TO,s.x=s.relative?0:o),void 0!==s.x&&(s.x=s.x*t+d*n+(f?0:a)),void 0!==s.y&&(s.y=p*e+s.y*r+(f?0:i)),void 0!==s.x1&&(s.x1=s.x1*t+s.y1*n+(f?0:a)),void 0!==s.y1&&(s.y1=u*e+s.y1*r+(f?0:i)),void 0!==s.x2&&(s.x2=s.x2*t+s.y2*n+(f?0:a)),void 0!==s.y2&&(s.y2=c*e+s.y2*r+(f?0:i));var m=t*r-e*n;if(void 0!==s.xRot&&(1!==t||0!==e||0!==n||1!==r))if(0===m)delete s.rX,delete s.rY,delete s.xRot,delete s.lArcFlag,delete s.sweepFlag,s.type=je.LINE_TO;else{var y=s.xRot*Math.PI/180,b=Math.sin(y),v=Math.cos(y),x=1/g(s.rX),M=1/g(s.rY),w=g(v)*x+g(b)*M,A=2*b*v*(x-M),_=g(b)*x+g(v)*M,O=w*r*r-A*e*r+_*e*e,S=A*(t*r+e*n)-2*(w*n*r+_*t*e),E=w*n*n-A*t*n+_*t*t,C=(Math.atan2(S,O-E)+Math.PI)%Math.PI/2,T=Math.sin(C),k=Math.cos(C);s.rX=Math.abs(m)/Math.sqrt(O*g(k)+S*T*k+E*g(T)),s.rY=Math.abs(m)/Math.sqrt(O*g(T)-S*T*k+E*g(k)),s.xRot=180*C/Math.PI}return void 0!==s.sweepFlag&&0>m&&(s.sweepFlag=+!s.sweepFlag),s}))}t.ROUND=function(t){function e(e){return Math.round(e*t)/t}return void 0===t&&(t=1e13),Te(t),function(t){return void 0!==t.x1&&(t.x1=e(t.x1)),void 0!==t.y1&&(t.y1=e(t.y1)),void 0!==t.x2&&(t.x2=e(t.x2)),void 0!==t.y2&&(t.y2=e(t.y2)),void 0!==t.x&&(t.x=e(t.x)),void 0!==t.y&&(t.y=e(t.y)),void 0!==t.rX&&(t.rX=e(t.rX)),void 0!==t.rY&&(t.rY=e(t.rY)),t}},t.TO_ABS=e,t.TO_REL=function(){return s((function(t,e,n){return t.relative||(void 0!==t.x1&&(t.x1-=e),void 0!==t.y1&&(t.y1-=n),void 0!==t.x2&&(t.x2-=e),void 0!==t.y2&&(t.y2-=n),void 0!==t.x&&(t.x-=e),void 0!==t.y&&(t.y-=n),t.relative=!0),t}))},t.NORMALIZE_HVZ=function(t,e,n){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===n&&(n=!0),s((function(r,s,a,i,o){if(isNaN(i)&&!(r.type&je.MOVE_TO))throw new Error("path must start with moveto");return e&&r.type&je.HORIZ_LINE_TO&&(r.type=je.LINE_TO,r.y=r.relative?0:a),n&&r.type&je.VERT_LINE_TO&&(r.type=je.LINE_TO,r.x=r.relative?0:s),t&&r.type&je.CLOSE_PATH&&(r.type=je.LINE_TO,r.x=r.relative?i-s:i,r.y=r.relative?o-a:o),r.type&je.ARC&&(0===r.rX||0===r.rY)&&(r.type=je.LINE_TO,delete r.rX,delete r.rY,delete r.xRot,delete r.lArcFlag,delete r.sweepFlag),r}))},t.NORMALIZE_ST=n,t.QT_TO_C=r,t.INFO=s,t.SANITIZE=function(t){void 0===t&&(t=0),Te(t);var e=NaN,n=NaN,r=NaN,a=NaN;return s((function(s,i,o,l,h){var u=Math.abs,c=!1,f=0,p=0;if(s.type&je.SMOOTH_CURVE_TO&&(f=isNaN(e)?0:i-e,p=isNaN(n)?0:o-n),s.type&(je.CURVE_TO|je.SMOOTH_CURVE_TO)?(e=s.relative?i+s.x2:s.x2,n=s.relative?o+s.y2:s.y2):(e=NaN,n=NaN),s.type&je.SMOOTH_QUAD_TO?(r=isNaN(r)?i:2*i-r,a=isNaN(a)?o:2*o-a):s.type&je.QUAD_TO?(r=s.relative?i+s.x1:s.x1,a=s.relative?o+s.y1:s.y2):(r=NaN,a=NaN),s.type&je.LINE_COMMANDS||s.type&je.ARC&&(0===s.rX||0===s.rY||!s.lArcFlag)||s.type&je.CURVE_TO||s.type&je.SMOOTH_CURVE_TO||s.type&je.QUAD_TO||s.type&je.SMOOTH_QUAD_TO){var d=void 0===s.x?0:s.relative?s.x:s.x-i,g=void 0===s.y?0:s.relative?s.y:s.y-o;f=isNaN(r)?void 0===s.x1?f:s.relative?s.x:s.x1-i:r-i,p=isNaN(a)?void 0===s.y1?p:s.relative?s.y:s.y1-o:a-o;var m=void 0===s.x2?0:s.relative?s.x:s.x2-i,y=void 0===s.y2?0:s.relative?s.y:s.y2-o;u(d)<=t&&u(g)<=t&&u(f)<=t&&u(p)<=t&&u(m)<=t&&u(y)<=t&&(c=!0)}return s.type&je.CLOSE_PATH&&u(i-l)<=t&&u(o-h)<=t&&(c=!0),c?[]:s}))},t.MATRIX=a,t.ROTATE=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0),Te(t,e,n);var r=Math.sin(t),s=Math.cos(t);return a(s,r,-r,s,e-e*s+n*r,n-e*r-n*s)},t.TRANSLATE=function(t,e){return void 0===e&&(e=0),Te(t,e),a(1,0,0,1,t,e)},t.SCALE=function(t,e){return void 0===e&&(e=t),Te(t,e),a(t,0,0,e,0,0)},t.SKEW_X=function(t){return Te(t),a(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return Te(t),a(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),Te(t),a(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),Te(t),a(1,0,0,-1,0,t)},t.A_TO_C=function(){return s((function(t,e,n){return je.ARC===t.type?function(t,e,n){var r,s,a,i;t.cX||Ne(t,e,n);for(var o=Math.min(t.phi1,t.phi2),l=Math.max(t.phi1,t.phi2)-o,h=Math.ceil(l/90),u=new Array(h),c=e,f=n,p=0;p<h;p++){var d=Le(t.phi1,t.phi2,p/h),g=Le(t.phi1,t.phi2,(p+1)/h),m=g-d,y=4/3*Math.tan(m*Ie/4),b=[Math.cos(d*Ie)-y*Math.sin(d*Ie),Math.sin(d*Ie)+y*Math.cos(d*Ie)],v=b[0],x=b[1],M=[Math.cos(g*Ie),Math.sin(g*Ie)],w=M[0],A=M[1],_=[w+y*Math.sin(g*Ie),A-y*Math.cos(g*Ie)],O=_[0],S=_[1];u[p]={relative:t.relative,type:je.CURVE_TO};var E=function(e,n){var r=Ce([e*t.rX,n*t.rY],t.xRot),s=r[0],a=r[1];return[t.cX+s,t.cY+a]};r=E(v,x),u[p].x1=r[0],u[p].y1=r[1],s=E(O,S),u[p].x2=s[0],u[p].y2=s[1],a=E(w,A),u[p].x=a[0],u[p].y=a[1],t.relative&&(u[p].x1-=c,u[p].y1-=f,u[p].x2-=c,u[p].y2-=f,u[p].x-=c,u[p].y-=f),c=(i=[u[p].x,u[p].y])[0],f=i[1]}return u}(t,t.relative?0:e,t.relative?0:n):t}))},t.ANNOTATE_ARCS=function(){return s((function(t,e,n){return t.relative&&(e=0,n=0),je.ARC===t.type&&Ne(t,e,n),t}))},t.CLONE=function(){return function(t){var e={};for(var n in t)e[n]=t[n];return e}},t.CALCULATE_BOUNDS=function(){var t=e(),a=r(),i=n(),o=s((function(e,n,r){var s=i(a(t(function(t){var e={};for(var n in t)e[n]=t[n];return e}(e))));function l(t){t>o.maxX&&(o.maxX=t),t<o.minX&&(o.minX=t)}function h(t){t>o.maxY&&(o.maxY=t),t<o.minY&&(o.minY=t)}if(s.type&je.DRAWING_COMMANDS&&(l(n),h(r)),s.type&je.HORIZ_LINE_TO&&l(s.x),s.type&je.VERT_LINE_TO&&h(s.y),s.type&je.LINE_TO&&(l(s.x),h(s.y)),s.type&je.CURVE_TO){l(s.x),h(s.y);for(var u=0,c=Fe(n,s.x1,s.x2,s.x);u<c.length;u++)0<(E=c[u])&&1>E&&l($e(n,s.x1,s.x2,s.x,E));for(var f=0,p=Fe(r,s.y1,s.y2,s.y);f<p.length;f++)0<(E=p[f])&&1>E&&h($e(r,s.y1,s.y2,s.y,E))}if(s.type&je.ARC){l(s.x),h(s.y),Ne(s,n,r);for(var d=s.xRot/180*Math.PI,g=Math.cos(d)*s.rX,m=Math.sin(d)*s.rX,y=-Math.sin(d)*s.rY,b=Math.cos(d)*s.rY,v=s.phi1<s.phi2?[s.phi1,s.phi2]:-180>s.phi2?[s.phi2+360,s.phi1+360]:[s.phi2,s.phi1],x=v[0],M=v[1],w=function(t){var e=t[0],n=t[1],r=180*Math.atan2(n,e)/Math.PI;return r<x?r+360:r},A=0,_=Ve(y,-g,0).map(w);A<_.length;A++)(E=_[A])>x&&E<M&&l(Pe(s.cX,g,y,E));for(var O=0,S=Ve(b,-m,0).map(w);O<S.length;O++){var E;(E=S[O])>x&&E<M&&h(Pe(s.cY,m,b,E))}}return e}));return o.minX=1/0,o.maxX=-1/0,o.minY=1/0,o.maxY=-1/0,o}}(Re||(Re={}));var He,De=function(){function t(){}return t.prototype.round=function(t){return this.transform(Re.ROUND(t))},t.prototype.toAbs=function(){return this.transform(Re.TO_ABS())},t.prototype.toRel=function(){return this.transform(Re.TO_REL())},t.prototype.normalizeHVZ=function(t,e,n){return this.transform(Re.NORMALIZE_HVZ(t,e,n))},t.prototype.normalizeST=function(){return this.transform(Re.NORMALIZE_ST())},t.prototype.qtToC=function(){return this.transform(Re.QT_TO_C())},t.prototype.aToC=function(){return this.transform(Re.A_TO_C())},t.prototype.sanitize=function(t){return this.transform(Re.SANITIZE(t))},t.prototype.translate=function(t,e){return this.transform(Re.TRANSLATE(t,e))},t.prototype.scale=function(t,e){return this.transform(Re.SCALE(t,e))},t.prototype.rotate=function(t,e,n){return this.transform(Re.ROTATE(t,e,n))},t.prototype.matrix=function(t,e,n,r,s,a){return this.transform(Re.MATRIX(t,e,n,r,s,a))},t.prototype.skewX=function(t){return this.transform(Re.SKEW_X(t))},t.prototype.skewY=function(t){return this.transform(Re.SKEW_Y(t))},t.prototype.xSymmetry=function(t){return this.transform(Re.X_AXIS_SYMMETRY(t))},t.prototype.ySymmetry=function(t){return this.transform(Re.Y_AXIS_SYMMETRY(t))},t.prototype.annotateArcs=function(){return this.transform(Re.ANNOTATE_ARCS())},t}(),Ue=function(t){return" "===t||"\t"===t||"\r"===t||"\n"===t},Ge=function(t){return"0".charCodeAt(0)<=t.charCodeAt(0)&&t.charCodeAt(0)<="9".charCodeAt(0)},ze=function(t){function e(){var e=t.call(this)||this;return e.curNumber="",e.curCommandType=-1,e.curCommandRelative=!1,e.canParseCommandOrComma=!0,e.curNumberHasExp=!1,e.curNumberHasExpDigits=!1,e.curNumberHasDecimal=!1,e.curArgs=[],e}return Se(e,t),e.prototype.finish=function(t){if(void 0===t&&(t=[]),this.parse(" ",t),0!==this.curArgs.length||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t},e.prototype.parse=function(t,e){var n=this;void 0===e&&(e=[]);for(var r=function(t){e.push(t),n.curArgs.length=0,n.canParseCommandOrComma=!0},s=0;s<t.length;s++){var a=t[s],i=!(this.curCommandType!==je.ARC||3!==this.curArgs.length&&4!==this.curArgs.length||1!==this.curNumber.length||"0"!==this.curNumber&&"1"!==this.curNumber),o=Ge(a)&&("0"===this.curNumber&&"0"===a||i);if(!Ge(a)||o)if("e"!==a&&"E"!==a)if("-"!==a&&"+"!==a||!this.curNumberHasExp||this.curNumberHasExpDigits)if("."!==a||this.curNumberHasExp||this.curNumberHasDecimal||i){if(this.curNumber&&-1!==this.curCommandType){var l=Number(this.curNumber);if(isNaN(l))throw new SyntaxError("Invalid number ending at "+s);if(this.curCommandType===je.ARC)if(0===this.curArgs.length||1===this.curArgs.length){if(0>l)throw new SyntaxError('Expected positive number, got "'+l+'" at index "'+s+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+s+'"');this.curArgs.push(l),this.curArgs.length===qe[this.curCommandType]&&(je.HORIZ_LINE_TO===this.curCommandType?r({type:je.HORIZ_LINE_TO,relative:this.curCommandRelative,x:l}):je.VERT_LINE_TO===this.curCommandType?r({type:je.VERT_LINE_TO,relative:this.curCommandRelative,y:l}):this.curCommandType===je.MOVE_TO||this.curCommandType===je.LINE_TO||this.curCommandType===je.SMOOTH_QUAD_TO?(r({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),je.MOVE_TO===this.curCommandType&&(this.curCommandType=je.LINE_TO)):this.curCommandType===je.CURVE_TO?r({type:je.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===je.SMOOTH_CURVE_TO?r({type:je.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===je.QUAD_TO?r({type:je.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===je.ARC&&r({type:je.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(!Ue(a))if(","===a&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==a&&"-"!==a&&"."!==a)if(o)this.curNumber=a,this.curNumberHasDecimal=!1;else{if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+s+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+a+'" at index '+s+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==a&&"Z"!==a)if("h"===a||"H"===a)this.curCommandType=je.HORIZ_LINE_TO,this.curCommandRelative="h"===a;else if("v"===a||"V"===a)this.curCommandType=je.VERT_LINE_TO,this.curCommandRelative="v"===a;else if("m"===a||"M"===a)this.curCommandType=je.MOVE_TO,this.curCommandRelative="m"===a;else if("l"===a||"L"===a)this.curCommandType=je.LINE_TO,this.curCommandRelative="l"===a;else if("c"===a||"C"===a)this.curCommandType=je.CURVE_TO,this.curCommandRelative="c"===a;else if("s"===a||"S"===a)this.curCommandType=je.SMOOTH_CURVE_TO,this.curCommandRelative="s"===a;else if("q"===a||"Q"===a)this.curCommandType=je.QUAD_TO,this.curCommandRelative="q"===a;else if("t"===a||"T"===a)this.curCommandType=je.SMOOTH_QUAD_TO,this.curCommandRelative="t"===a;else{if("a"!==a&&"A"!==a)throw new SyntaxError('Unexpected character "'+a+'" at index '+s+".");this.curCommandType=je.ARC,this.curCommandRelative="a"===a}else e.push({type:je.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=a,this.curNumberHasDecimal="."===a}else this.curNumber+=a,this.curNumberHasDecimal=!0;else this.curNumber+=a;else this.curNumber+=a,this.curNumberHasExp=!0;else this.curNumber+=a,this.curNumberHasExpDigits=this.curNumberHasExp}return e},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(e,n){void 0===n&&(n=[]);for(var r=0,s=Object.getPrototypeOf(this).parse.call(this,e);r<s.length;r++){var a=s[r],i=t(a);Array.isArray(i)?n.push.apply(n,i):n.push(i)}return n}}})},e}(De),je=function(t){function e(n){var r=t.call(this)||this;return r.commands="string"==typeof n?e.parse(n):n,r}return Se(e,t),e.prototype.encode=function(){return e.encode(this.commands)},e.prototype.getBounds=function(){var t=Re.CALCULATE_BOUNDS();return this.transform(t),t},e.prototype.transform=function(t){for(var e=[],n=0,r=this.commands;n<r.length;n++){var s=t(r[n]);Array.isArray(s)?e.push.apply(e,s):e.push(s)}return this.commands=e,this},e.encode=function(t){return Ee(t)},e.parse=function(t){var e=new ze,n=[];return e.parse(t,n),e.finish(n),n},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}(De),qe=((He={})[je.MOVE_TO]=2,He[je.LINE_TO]=2,He[je.HORIZ_LINE_TO]=1,He[je.VERT_LINE_TO]=1,He[je.CLOSE_PATH]=0,He[je.QUAD_TO]=4,He[je.SMOOTH_QUAD_TO]=2,He[je.CURVE_TO]=6,He[je.SMOOTH_CURVE_TO]=4,He[je.ARC]=7,He);function We(t,e,n,r){if(0===n.length)return;const s=n[0],a=n[n.length-1],i=ct(e.getAttribute("marker-start")),o=i?t.idElements[i]:null;if(o&&n.length>1){let i=o.orientAngle.baseVal.value;const l=n[1],h=o.getAttribute("orient");if("auto"===h||"auto-start-reverse"===h){const t="auto"===h?0:180,e=n[n.length-2];if(Ye(n))i=Qe(e,a,l)-t;else{i=Ze({x:1,y:0},{x:l.x-s.x,y:l.y-s.y})-t}}const u=t.sourceSvg.createSVGMatrix().translate(s.x,s.y).rotate(i).scale(Xe(t,o,e)),c=r?r.matrix.multiply(u):u,f=t.sourceSvg.createSVGTransformFromMatrix(c);t.processElement(t,o,f)}const l=ct(e.getAttribute("marker-end")),h=l?t.idElements[l]:null;if(h){let s=h.orientAngle.baseVal.value;if(n.length>1){const t=h.getAttribute("orient");if("auto"===t||"auto-start-reverse"===t){const t=n[n.length-2];if(Ye(n)){s=Qe(t,a,n[1])}else{s=Ze({x:1,y:0},{x:a.x-t.x,y:a.y-t.y})}}}const i=t.sourceSvg.createSVGMatrix().translate(a.x,a.y).rotate(s).scale(Xe(t,h,e)),o=r?r.matrix.multiply(i):i,l=t.sourceSvg.createSVGTransformFromMatrix(o);t.processElement(t,h,l)}const u=ct(e.getAttribute("marker-mid")),c=u?t.idElements[u]:null;if(c&&n.length>2)for(let s=0;s<n.length;s++){const a=n[s];if(0===s||s===n.length-1)continue;let i=c.orientAngle.baseVal.value;const o=c.getAttribute("orient");if("auto"===o||"auto-start-reverse"===o){i=Qe(n[s-1],a,n[s+1])}const l=t.sourceSvg.createSVGMatrix().translate(a.x,a.y).rotate(i).scale(Xe(t,c,e)),h=r?r.matrix.multiply(l):l,u=t.sourceSvg.createSVGTransformFromMatrix(h);t.processElement(t,c,u)}}function Xe(t,e,n){const r=e.getAttribute("markerUnits");let s=1;if(!r||"strokeWidth"===r){const e=bt(t,n,"stroke-width");e&&(s=ie(t,n,e,"stroke-width"))}return s}function Ye(t){return e=t[0],n=t[t.length-1],e.x===n.x&&e.y===n.y;var e,n}function Qe(t,e,n){const r={x:n.x-e.x,y:n.y-e.y},s=Ze(r,{x:t.x-e.x,y:t.y-e.y}),a=e.x+1,i=e.y,o=Ze(r,{x:a-e.x,y:i-e.y});return((l=s)-180*Math.sign(l))/2-o;var l}function Ze(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,a=Math.abs(s+r)<Math.abs(r)?s+r:r;return Math.round(360*a/(2*Math.PI))}function Be(t,e,{x:n,y:r,w:s,h:a}){xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","rect");return t.x.baseVal.value=n,t.y.baseVal.value=r,t.width.baseVal.value=s,t.height.baseVal.value=a,t}))}function Ke(t,e,n,r){const s=ct(n);if(!s)return;const a=t.idElements[s];if(!a)return;const i=dt(t),o=`${s}_${i.childElementCount}`,l=document.createElementNS("http://www.w3.org/2000/svg","clipPath");l.id=o,function(t,e){if("g"!==t.tagName)return void t.setAttribute(ft,e);const n=[],r=lt(t);for(let t=r.length-1;t>=0;t--)n.push(r[t]);for(;n.length>0;){const t=n.pop();t.setAttribute(ft,e);const r=lt(t);for(let t=r.length-1;t>=0;t--)n.push(r[t])}}(e,o);const h=[],u=lt(a);for(let e=u.length-1;e>=0;e--){const n=u[e],s=fe(t,n,r);h.push({element:n,transform:s})}for(;h.length>0;){const{element:e,transform:n}=h.pop();try{Je(t,e,l,n)}catch(t){console.error(t)}if("defs"===e.tagName||"svg"===e.tagName||"clipPath"===e.tagName||"text"===e.tagName)continue;const r=lt(e);for(let e=r.length-1;e>=0;e--){const s=r[e],a=fe(t,s,n);h.push({element:s,transform:a})}}l.childNodes.length>0&&i.appendChild(l)}function Je(t,e,n,r){switch(e.tagName){case"rect":!function(t,e,n,r){const s=e.x.baseVal.value,a=e.y.baseVal.value,i=e.width.baseVal.value,o=e.height.baseVal.value;if(0===i||0===o)return;const l=e.hasAttribute("rx")?e.rx.baseVal.value:null,h=e.hasAttribute("ry")?e.ry.baseVal.value:null,u=document.createElementNS("http://www.w3.org/2000/svg","rect");u.x.baseVal.value=s,u.y.baseVal.value=a,u.width.baseVal.value=i,u.height.baseVal.value=o,l&&(u.rx.baseVal.value=l),h&&(u.ry.baseVal.value=h),pe(0,r,u),n.appendChild(u)}(0,e,n,r);break;case"circle":!function(t,e,n,r){const s=e.cx.baseVal.value,a=e.cy.baseVal.value,i=e.r.baseVal.value;if(0===i)return;const o=document.createElementNS("http://www.w3.org/2000/svg","circle");o.cx.baseVal.value=s,o.cy.baseVal.value=a,o.r.baseVal.value=i,pe(0,r,o),n.appendChild(o)}(0,e,n,r);break;case"ellipse":!function(t,e,n,r){const s=e.cx.baseVal.value,a=e.cy.baseVal.value,i=e.rx.baseVal.value,o=e.ry.baseVal.value;if(0===i||0===o)return;const l=document.createElementNS("http://www.w3.org/2000/svg","ellipse");l.cx.baseVal.value=s,l.cy.baseVal.value=a,l.rx.baseVal.value=i,l.ry.baseVal.value=o,pe(0,r,l),n.appendChild(l)}(0,e,n,r);break;case"polygon":!function(t,e,n,r){const s=document.createElementNS("http://www.w3.org/2000/svg","polygon");s.setAttribute("points",e.getAttribute("points")),pe(0,r,s),n.appendChild(s)}(0,e,n,r);break;case"path":!function(t,e,n,r){const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",e.getAttribute("d")),pe(0,r,s),n.appendChild(s)}(0,e,n,r)}}function tn(t,e,n){const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","text-container"),pe(0,n,r);const s=e.cloneNode(!0);s.transform.baseVal.numberOfItems>0&&s.transform.baseVal.clear(),s.removeAttribute("clip-path");const{cssFont:a,fontSize:i}=function(t,e,n=!1){const r={};let s="";const a=bt(t,e,"font-style",t.useElementContext);a&&(s+=n?`font-style: ${a};`:a,r.fontStyle=a);const i=bt(t,e,"font-weight",t.useElementContext);i&&(s+=n?`font-weight: ${i};`:` ${i}`,r.fontWeight=i);const o=bt(t,e,"font-size",t.useElementContext);o&&(s+=n?`font-size: ${o};`:` ${o}`,r.fontSize=o);if(t.fontFamily)s+=n?`font-family: ${t.fontFamily};`:` ${t.fontFamily}`,r.fontFamiliy=t.fontFamily;else{const a=bt(t,e,"font-family",t.useElementContext);a&&(s+=n?`font-family: ${a};`:` ${a}`,r.fontFamiliy=a)}return s=s.trim(),Object.assign(Object.assign({},r),{cssFont:s})}(t,e,!0);if(s.setAttribute("style",function(...t){let e="";t=t.filter((t=>null!==t));for(const n of t)e.length>0&&";"!==e[e.length-1]&&(e+=";"),e+=n;return e}(s.getAttribute("style"),a)),nn(t,e,s),s.childElementCount>0){const n=lt(s),r=lt(e);for(let e=0;e<n.length;e++){const s=n[e];s instanceof SVGTSpanElement&&nn(t,r[e],s)}}r.appendChild(s),mt(t,e,r);const o=null!==t.fontFamily,l=s.hasAttribute(ft);o&&l&&i&&function(t,e,n,r){const{width:s,height:a}=e.getBBox();if(s<=0||a<=0)return;const i=ie(t,n,r,"font-size");en(t,{w:s,h:a},n,i)}(t,e,s,i)}function en(t,e,n,r){const{w:s}=function({svgSketch:t,svgSketchIsInDOM:e},n){const r="visibility:hidden;position:absolute;left:-100%;top-100%;",s=t.getAttribute("style");s?t.setAttribute("style",`${s};${r}`):t.setAttribute("style",r);const a=document.body,i=t.parentElement;e||a.appendChild(t);const{width:o,height:l}=n.getBBox();return e||(a.removeChild(t),i&&i.appendChild(t)),s?t.setAttribute("style",s):t.removeAttribute("style"),{w:o,h:l}}(t,n);if(s<e.w)return;if(r<=1)return;const a=r-1;n.style.fontSize=`${a}px`,en(t,e,n,a)}function nn(t,e,n){const r=bt(t,e,"stroke"),s=r?bt(t,e,"stroke-width"):null,a=bt(t,e,"fill"),i=bt(t,e,"dominant-baseline"),o=bt(t,e,"text-anchor",t.useElementContext);r&&n.setAttribute("stroke",r),s&&n.setAttribute("stroke-width",s),a&&n.setAttribute("fill",a),o&&n.setAttribute("text-anchor",o),i&&n.setAttribute("dominant-baseline",i)}function rn(t,e,n,r,s){var a,i;const o=[],l={x:0,y:0,w:null!=r?r:0,h:null!=s?s:0};if(e instanceof SVGSVGElement||e instanceof SVGSymbolElement||e instanceof SVGMarkerElement){let h=0,u=0;if(e instanceof SVGSymbolElement)h=parseFloat(null!==(a=e.getAttribute("x"))&&void 0!==a?a:"")||0,u=parseFloat(null!==(i=e.getAttribute("y"))&&void 0!==i?i:"")||0,r=null!=r?r:parseFloat(e.getAttribute("width"))||void 0,s=null!=s?s:parseFloat(e.getAttribute("height"))||void 0;else if(e instanceof SVGMarkerElement){const t=e.getAttribute("markerWidth"),n=e.getAttribute("markerHeight");r=null!==t?parseFloat(t):3,s=null!==n?parseFloat(n):3}else e!==t.sourceSvg&&(h=e.x.baseVal.value,u=e.y.baseVal.value);let c=t.sourceSvg.createSVGMatrix();if(e.getAttribute("viewBox")){const{x:t,y:n,width:a,height:i}=e.viewBox.baseVal;if(l.x=t,l.y=n,l.w=a,l.h=i,void 0!==r&&void 0!==s){const o=r/a,l=s/i,f=h+.5*r,p=u+.5*s,d=t+.5*a,g=n+.5*i;c=c.translate(f,p),c="none"===e.getAttribute("preserveAspectRatio")?c.scaleNonUniform(o,l):c.scale(Math.min(o,l)),c=c.translate(-d,-g)}}else c=c.translate(h,u);e instanceof SVGMarkerElement&&(c=c.translate(-e.refX.baseVal.value,-e.refY.baseVal.value));const f=n?n.matrix.multiply(c):c;n=t.sourceSvg.createSVGTransformFromMatrix(f);const p=lt(e);for(let e=p.length-1;e>=0;e--){const r=p[e];if(r instanceof SVGSymbolElement||r instanceof SVGMarkerElement)continue;const s=fe(t,r,n);o.push({element:r,transform:s,viewBox:l})}}else o.push({element:e,transform:n,viewBox:l});for(;o.length>0;){const{element:e,transform:n,viewBox:r}=o.pop();try{t.viewBox=r,sn(t,e,n)}catch(t){console.error(t)}if("defs"===e.tagName||"symbol"===e.tagName||"marker"===e.tagName||"svg"===e.tagName||"clipPath"===e.tagName)continue;const s=lt(e);for(let e=s.length-1;e>=0;e--){const a=s[e],i=fe(t,a,n);o.push({element:a,transform:i,viewBox:r})}}}function sn(t,e,n){if(function(t){const e=t.style;return!!e&&("none"===e.display||"hidden"===e.visibility)}(e))return;const r=e.getAttribute("clip-path");switch(r&&Ke(t,e,r,n),e.tagName){case"svg":case"symbol":!function(t,e,n){let r=parseFloat(e.getAttribute("width")),s=parseFloat(e.getAttribute("height"));(isNaN(r)||isNaN(s))&&(r=s=void 0),rn(t,e,n,r,s)}(t,e,n);break;case"rect":!function(t,e,n){const r=e.x.baseVal.value,s=e.y.baseVal.value,a=e.width.baseVal.value,i=e.height.baseVal.value;if(0===a||0===i)return;let o=e.hasAttribute("rx")?Math.min(Math.max(0,e.rx.baseVal.value),a/2):null,l=e.hasAttribute("ry")?Math.min(Math.max(0,e.ry.baseVal.value),i/2):null;null===o&&null===l||(o=null===o?l:o,l=null===l?o:l);const h=ue({x:r,y:s},n),u=ue({x:r+a,y:s+i},n),c=u.x-h.x,f=u.y-h.y,p={x:h.x,y:h.y,w:c,h:f};if(!le(n)&&!he(n)||o||l){let h="";if(null!==o&&null!==l){const t=4/3*(Math.sqrt(2)-1),e=ue({x:r+o,y:s},n);h+=`M ${_e(e)}`,h+=`L ${_e(ue({x:r+a-o,y:s},n))}`;const u=ue({x:r+a-o+t*o,y:s},n),c=ue({x:r+a,y:s+t*l},n),f=ue({x:r+a,y:s+l},n);h+=`C ${_e(u)} ${_e(c)} ${_e(f)}`,h+=`L ${_e(ue({x:r+a,y:s+i-l},n))}`;const p=ue({x:r+a,y:s+i-l+t*l},n),d=ue({x:r+a-t*o,y:s+i},n),g=ue({x:r+a-o,y:s+i},n);h+=`C ${_e(p)} ${_e(d)} ${_e(g)}`,h+=`L ${_e(ue({x:r+o,y:s+i},n))}`;const m=ue({x:r+o-t*o,y:s+i},n),y=ue({x:r,y:s+i-t*l},n),b=ue({x:r,y:s+i-l},n);h+=`C ${_e(m)} ${_e(y)} ${_e(b)}`,h+=`L ${_e(ue({x:r,y:s+l},n))}`;const v=ue({x:r,y:s+t*l},n),x=ue({x:r+t*o,y:s},n);h+=`C ${_e(v)} ${_e(x)} ${_e(e)}`,h+="z"}else{const t=ue({x:r,y:s},n),e=ue({x:r+a,y:s},n),o=ue({x:r+a,y:s+i},n),l=ue({x:r,y:s+i},n);h+=`M ${_e(t)}`,h+=`L ${_e(e)}`,h+=`L ${_e(o)}`,h+=`L ${_e(l)}`,h+="z"}const u=yt(t,h,Me(t,e,n));Be(t,e,p),mt(t,e,u)}else{const r=t.rc.rectangle(p.x,p.y,p.w,p.h,Me(t,e,n));Be(t,e,p),mt(t,e,r)}}(t,e,n);break;case"path":!function(t,e,n){const r=e.getAttribute("d"),s=new je(r).toAbs().transform(Re.NORMALIZE_HVZ()).transform(Re.NORMALIZE_ST()),a=new je(s.commands.map((t=>Object.assign({},t))));n&&a.transform(Re.MATRIX(n.matrix.a,n.matrix.b,n.matrix.c,n.matrix.d,n.matrix.e,n.matrix.f));const i=Ee(a.commands);if(-1!==i.indexOf("undefined"))return void console.error("broken path data");const o=yt(t,i,Me(t,e,n));xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",i),t})),mt(t,e,o);const l=[];let h;s.commands.forEach((t=>{switch(t.type){case je.MOVE_TO:{const e={x:t.x,y:t.y};l.push(e),h=e;break}case je.LINE_TO:case je.QUAD_TO:case je.SMOOTH_QUAD_TO:case je.CURVE_TO:case je.SMOOTH_CURVE_TO:case je.ARC:l.push({x:t.x,y:t.y});break;case je.HORIZ_LINE_TO:l.push({x:t.x,y:0});break;case je.VERT_LINE_TO:l.push({x:0,y:t.y});break;case je.CLOSE_PATH:h&&l.push(h)}})),We(t,e,l,n)}(t,e,n);break;case"use":!function(t,e,n){let r=e.href.baseVal;r.startsWith("#")&&(r=r.substring(1));const s=t.idElements[r];if(s){let r,a;e.getAttribute("width")&&e.getAttribute("height")&&(r=e.width.baseVal.value,a=e.height.baseVal.value);const i=e.x.baseVal.value,o=e.y.baseVal.value;let l=t.sourceSvg.createSVGMatrix().translate(i,o);l=n?n.matrix.multiply(l):l;const h=t.sourceSvg.createSVGTransformFromMatrix(l);if(t.useElementContext){const n={root:e,referenced:s,parentContext:Object.assign({},t.useElementContext)};t.useElementContext=n}else t.useElementContext={root:e,referenced:s,parentContext:null};t.processElement(t,s,fe(t,s,h),r,a),t.useElementContext.parentContext?t.useElementContext=t.useElementContext.parentContext:t.useElementContext=null}}(t,e,n);break;case"line":!function(t,e,n){const r={x:e.x1.baseVal.value,y:e.y1.baseVal.value},s={x:e.x2.baseVal.value,y:e.y2.baseVal.value},{x:a,y:i}=ue(r,n),{x:o,y:l}=ue(s,n);if(a===o&&i===l)return;const h=t.rc.line(a,i,o,l,Me(t,e,n));xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","line");return t.x1.baseVal.value=a,t.y1.baseVal.value=i,t.x2.baseVal.value=o,t.y2.baseVal.value=l,t})),mt(t,e,h),We(t,e,[r,s],n)}(t,e,n);break;case"circle":!function(t,e,n){const r=e.cx.baseVal.value,s=e.cy.baseVal.value,a=e.r.baseVal.value;if(0===a)return;const i=ue({x:r,y:s},n),o=ue({x:r+a,y:s+a},n).x-i.x;let l;if(le(n)||he(n))l=t.rc.circle(i.x,i.y,2*o,Object.assign(Object.assign({},Me(t,e,n)),{preserveVertices:!0}));else{const i=4/3*(Math.sqrt(2)-1),o=ue({x:r+a,y:s},n),h=ue({x:r,y:s+a},n),u=ue({x:r-a,y:s},n),c=ue({x:r,y:s-a},n),f=ue({x:r+a,y:s+i*a},n),p=ue({x:r+i*a,y:s+a},n),d=ue({x:r-a,y:s+i*a},n),g=ue({x:r-i*a,y:s-a},n),m=ue({x:r+a,y:s-i*a},n);l=yt(t,`M ${_e(o)} C ${_e(f)} ${_e(p)} ${_e(h)} S ${_e(d)} ${_e(u)} S ${_e(g)} ${_e(c)} S ${_e(m)} ${_e(o)}z`,Me(t,e,n))}xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","circle");return t.cx.baseVal.value=i.x,t.cy.baseVal.value=i.y,t.r.baseVal.value=o,t})),mt(t,e,l)}(t,e,n);break;case"ellipse":!function(t,e,n){const r=e.cx.baseVal.value,s=e.cy.baseVal.value,a=e.rx.baseVal.value,i=e.ry.baseVal.value;if(0===a||0===i)return;const o=ue({x:r,y:s},n),l=ue({x:r+a,y:s+i},n),h=l.x-o.x,u=l.y-o.y;let c;if(le(n)||he(n))c=t.rc.ellipse(o.x,o.y,2*h,2*u,Object.assign(Object.assign({},Me(t,e,n)),{preserveVertices:!0}));else{const o=4/3*(Math.sqrt(2)-1),l=ue({x:r+a,y:s},n),h=ue({x:r,y:s+i},n),u=ue({x:r-a,y:s},n),f=ue({x:r,y:s-i},n),p=ue({x:r+a,y:s+o*i},n),d=ue({x:r+o*a,y:s+i},n),g=ue({x:r-a,y:s+o*i},n),m=ue({x:r-o*a,y:s-i},n),y=ue({x:r+a,y:s-o*i},n);c=yt(t,`M ${_e(l)} C ${_e(p)} ${_e(d)} ${_e(h)} S ${_e(g)} ${_e(u)} S ${_e(m)} ${_e(f)} S ${_e(y)} ${_e(l)}z`,Me(t,e,n))}xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return t.cx.baseVal.value=o.x,t.cy.baseVal.value=o.y,t.rx.baseVal.value=h,t.ry.baseVal.value=u,t})),mt(t,e,c)}(t,e,n);break;case"polyline":!function(t,e,n){const r=gt(e),s=r.map((t=>{const e=ue(t,n);return[e.x,e.y]})),a=Me(t,e,n);if(xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","polyline");return t.setAttribute("points",s.join(" ")),t})),a.fill&&"none"!==a.fill){const n=Object.assign(Object.assign({},a),{stroke:"none"});mt(t,e,t.rc.polygon(s,n))}mt(t,e,t.rc.linearPath(s,a)),We(t,e,r,n)}(t,e,n);break;case"polygon":!function(t,e,n){const r=gt(e),s=r.map((t=>{const e=ue(t,n);return[e.x,e.y]})),a=t.rc.polygon(s,Me(t,e,n));xt(t,e,(()=>{const t=document.createElementNS("http://www.w3.org/2000/svg","polygon");return t.setAttribute("points",s.join(" ")),t})),mt(t,e,a),r.length>0&&(r.push(r[0]),We(t,e,r,n))}(t,e,n);break;case"text":tn(t,e,n);break;case"image":!function(t,e,n){const r=e.href.baseVal,s=e.x.baseVal.value,a=e.y.baseVal.value;let i,o;if(e.getAttribute("width")&&e.getAttribute("height")&&(i=e.width.baseVal.value,o=e.height.baseVal.value),r.startsWith("data:")&&-1!==r.indexOf("image/svg+xml")){const e=/^data:([^,]*),(.*)/.exec(r);if(e&&e.length>2){const r=e[1];let l=e[2];const h=-1!==r.indexOf("base64"),u=-1!==r.indexOf("utf8");h&&(l=atob(l)),u||(l=decodeURIComponent(l));const c=(new DOMParser).parseFromString(l,"image/svg+xml").firstChild;let f=t.sourceSvg.createSVGMatrix().translate(s,a);f=n?n.matrix.multiply(f):f,t.processElement(t,c,t.sourceSvg.createSVGTransformFromMatrix(f),i,o)}}else{const r=e.cloneNode(),s=document.createElementNS("http://www.w3.org/2000/svg","g");pe(0,n,s),s.appendChild(r),mt(t,e,s)}}(t,e,n);break;case"foreignObject":!function(t,e,n){const r=e.cloneNode(!0),s=document.createElementNS("http://www.w3.org/2000/svg","g"),a=["color","font-family","font-size","font-style","font-variant","font-weight"],i=getComputedStyle(e);for(const t of a)s.style.setProperty(t,i.getPropertyValue(t));r.transform.baseVal.clear(),pe(0,n,s),s.appendChild(r),mt(t,r,s)}(t,e,n)}}class an{constructor(t){this.rng=t?new p(t):null}next(t){var e,n;const r=null!==(n=null===(e=this.rng)||void 0===e?void 0:e.next())&&void 0!==n?n:Math.random();if(t){const e=t[0];return r*(t[1]-e)+e}return r}}t.Svg2Roughjs=class{set svg(t){this.$svg!==t&&(this.$svg=t,this.sourceSvgChanged())}get svg(){return this.$svg}set outputType(e){if(this.$outputType===e)return;if(e===t.OutputType.CANVAS&&this.outputElement instanceof SVGSVGElement||e===t.OutputType.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(t){void 0===t.fixedDecimalPlaceDigits&&(t.fixedDecimalPlaceDigits=3),this.$roughConfig=t}get roughConfig(){return this.$roughConfig}constructor(e,n=t.OutputType.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="string"==typeof e?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=t.OutputType.CANVAS:s instanceof SVGSVGElement?this.$outputType=t.OutputType.SVG:this.$outputType=n}sketch(e=!1){var n,r;if(!this.svg)return Promise.resolve(null);e&&this.sourceSvgChanged();const s=this.prepareRenderContainer(),a=this.createRenderContext(s);if(this.pencilFilter){dt(a).appendChild(function(){const t=document.createElementNS("http://www.w3.org/2000/svg","filter");t.setAttribute("id","pencilTextureFilter"),t.setAttribute("x","0%"),t.setAttribute("y","0%"),t.setAttribute("width","100%"),t.setAttribute("height","100%"),t.setAttribute("filterUnits","objectBoundingBox");const e=document.createElementNS("http://www.w3.org/2000/svg","feTurbulence");e.setAttribute("type","fractalNoise"),e.setAttribute("baseFrequency","2"),e.setAttribute("numOctaves","5"),e.setAttribute("stitchTiles","stitch"),e.setAttribute("result","f1"),t.appendChild(e);const n=document.createElementNS("http://www.w3.org/2000/svg","feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 -1.5 1.5"),n.setAttribute("result","f2"),t.appendChild(n);const r=document.createElementNS("http://www.w3.org/2000/svg","feComposite");return r.setAttribute("operator","in"),r.setAttribute("in","SourceGraphic"),r.setAttribute("in2","f2"),r.setAttribute("result","f3"),t.appendChild(r),t}())}if(a.processElement(a,this.svg,null,this.width,this.height),this.outputElement instanceof SVGSVGElement)return Promise.resolve(this.outputElement);if(this.outputElement instanceof HTMLCanvasElement)return this.drawToCanvas(a,this.outputElement);if(null===(r=null===(n=this.lastResult)||void 0===n?void 0:n.parentNode)||void 0===r||r.removeChild(this.lastResult),this.outputType===t.OutputType.SVG){const t=a.svgSketch;return this.outputElement.appendChild(t),this.lastResult=t,Promise.resolve(t)}{const t=document.createElement("canvas");return this.outputElement.appendChild(t),this.lastResult=t,this.drawToCanvas(a,t)}}createRenderContext(t){if(!this.svg)throw new Error("No source SVG set yet.");let e=this.roughConfig;return null!==this.seed&&(e=Object.assign({seed:this.seed},e)),{rc:ot.svg(t,{options:e}),roughConfig:this.roughConfig,fontFamily:this.fontFamily,pencilFilter:this.pencilFilter,randomize:this.randomize,rng:new an(this.seed),sketchPatterns:this.sketchPatterns,idElements:this.idElements,sourceSvg:this.svg,svgSketch:t,svgSketchIsInDOM:document.body.contains(t),styleSheets:Array.from(this.svg.querySelectorAll("style")).map((t=>t.sheet)).filter((t=>null!==t)),processElement:rn}}drawToCanvas(t,e){e.width=this.width,e.height=this.height;const n=e.getContext("2d");return n.clearRect(0,0,this.width,this.height),new Promise((r=>{const s=(new XMLSerializer).serializeToString(t.svgSketch),a=new Image;a.onload=function(){n.drawImage(this,0,0),r(e)},a.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(s)}`}))}prepareRenderContainer(){let t,e;for(t=this.outputElement instanceof SVGSVGElement?this.outputElement:document.createElementNS("http://www.w3.org/2000/svg","svg"),t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");t.firstChild;)t.removeChild(t.firstChild);return t.setAttribute("width",this.width.toString()),t.setAttribute("height",this.height.toString()),this.backgroundColor&&(e=document.createElementNS("http://www.w3.org/2000/svg","rect"),e.width.baseVal.value=this.width,e.height.baseVal.value=this.height,e.setAttribute("fill",this.backgroundColor),t.appendChild(e)),t.setAttribute("stroke-linecap","round"),t}sourceSvgChanged(){const t=this.$svg;if(t){const e=this.roughConfig.fixedDecimalPlaceDigits;this.width=parseFloat(this.coerceSize(t,"width",300).toFixed(e)),this.height=parseFloat(this.coerceSize(t,"height",150).toFixed(e)),this.collectElementsWithID()}}collectElementsWithID(){this.idElements={};const t=Array.prototype.slice.apply(this.svg.querySelectorAll("*[id]"));for(const e of t){const t=e.getAttribute("id");t&&(this.idElements[t]=e)}}coerceSize(t,e,n){let r=n;const s=t.hasAttribute("viewBox");return t.hasAttribute(e)?r=t[e].baseVal.unitType===SVGLength.SVG_LENGTHTYPE_PERCENTAGE&&s?t.viewBox.baseVal[e]:t[e].baseVal.value:s&&(r=t.viewBox.baseVal[e]),r}}}));
|
| 17 |
+
//# sourceMappingURL=svg2roughjs.umd.min.js.map
|