-
Notifications
You must be signed in to change notification settings - Fork 1
/
svg-sketch.min.js
2 lines (2 loc) · 46.6 KB
/
svg-sketch.min.js
1
2
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SvgSketch=t()}}(function(){return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){var r=e[s][1][t];return o(r?r:t)},u,u.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e){function r(){return this instanceof r?(this.events=[],void 0):new r}function n(t){return t.deleted?!1:"text"===t.type?!!t.args.value:"path"===t.type?!!t.args.d.match(/a|l/i):Object.keys(t.args||{}).length+Object.keys(t.layout||{}).length>0}var o=t("shallow-copy"),i=t("xtend"),s=t("color");e.exports=r,r.validEvent=n,r.prototype.push=function(t){var e=this.events.push(t);return e},r.prototype.pop=function(){var t=this.events.pop();return t},r.prototype.toJSON=function(){function t(t){var e=o(t.args);return e&&["stroke","fill"].forEach(function(t){e[t]&&(e[t]=s(e[t]).rgbaString())}),{type:t.type,id:t.id,args:e,layout:t.layout,pathId:t.path?t.path.id:void 0}}function e(t){function e(e){return e.id===t.pathId}if(t.pathId){var r=l.normalized.filter(e)[0];r&&(t.deleted=!0,r.args=i(r.args,t.args),r.deleted="delete"===t.type)}}function r(t,e){function r(t,r){return e[r]&&(t[r]=e[r]),t}return"style"===e.type&&"style"===a&&t.pop(),n(e)?(a=e.type,t.push(["type","args","layout"].reduce(r,{})),t):t}var a,l=this;return this.normalized=this.events.map(t),this.normalized.forEach(e),this.normalized.reduce(r,[])}},{color:7,"shallow-copy":16,xtend:18}],2:[function(t,e){function r(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}var n=t("color-name"),o={};for(var i in n)n.hasOwnProperty(i)&&(o[n[i]]=i);var s=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var a in s)if(s.hasOwnProperty(a)){if(!("channels"in s[a]))throw new Error("missing channels property: "+a);if(!("labels"in s[a]))throw new Error("missing channel labels property: "+a);if(s[a].labels.length!==s[a].channels)throw new Error("channel and label counts mismatch: "+a);var l=s[a].channels,h=s[a].labels;delete s[a].channels,delete s[a].labels,Object.defineProperty(s[a],"channels",{value:l}),Object.defineProperty(s[a],"labels",{value:h})}s.rgb.hsl=function(t){var e,r,n,o=t[0]/255,i=t[1]/255,s=t[2]/255,a=Math.min(o,i,s),l=Math.max(o,i,s),h=l-a;return l===a?e=0:o===l?e=(i-s)/h:i===l?e=2+(s-o)/h:s===l&&(e=4+(o-i)/h),e=Math.min(60*e,360),0>e&&(e+=360),n=(a+l)/2,r=l===a?0:.5>=n?h/(l+a):h/(2-l-a),[e,100*r,100*n]},s.rgb.hsv=function(t){var e,r,n,o=t[0],i=t[1],s=t[2],a=Math.min(o,i,s),l=Math.max(o,i,s),h=l-a;return r=0===l?0:1e3*(h/l)/10,l===a?e=0:o===l?e=(i-s)/h:i===l?e=2+(s-o)/h:s===l&&(e=4+(o-i)/h),e=Math.min(60*e,360),0>e&&(e+=360),n=1e3*(l/255)/10,[e,r,n]},s.rgb.hwb=function(t){var e=t[0],r=t[1],n=t[2],o=s.rgb.hsl(t)[0],i=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[o,100*i,100*n]},s.rgb.cmyk=function(t){var e,r,n,o,i=t[0]/255,s=t[1]/255,a=t[2]/255;return o=Math.min(1-i,1-s,1-a),e=(1-i-o)/(1-o)||0,r=(1-s-o)/(1-o)||0,n=(1-a-o)/(1-o)||0,[100*e,100*r,100*n,100*o]},s.rgb.keyword=function(t){var e=o[t];if(e)return e;var i,s=1/0;for(var a in n)if(n.hasOwnProperty(a)){var l=n[a],h=r(t,l);s>h&&(s=h,i=a)}return i},s.keyword.rgb=function(t){return n[t]},s.rgb.xyz=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var o=.4124*e+.3576*r+.1805*n,i=.2126*e+.7152*r+.0722*n,s=.0193*e+.1192*r+.9505*n;return[100*o,100*i,100*s]},s.rgb.lab=function(t){var e,r,n,o=s.rgb.xyz(t),i=o[0],a=o[1],l=o[2];return i/=95.047,a/=100,l/=108.883,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,e=116*a-16,r=500*(i-a),n=200*(a-l),[e,r,n]},s.hsl.rgb=function(t){var e,r,n,o,i,s=t[0]/360,a=t[1]/100,l=t[2]/100;if(0===a)return i=255*l,[i,i,i];r=.5>l?l*(1+a):l+a-l*a,e=2*l-r,o=[0,0,0];for(var h=0;3>h;h++)n=s+1/3*-(h-1),0>n&&n++,n>1&&n--,i=1>6*n?e+6*(r-e)*n:1>2*n?r:2>3*n?e+6*(r-e)*(2/3-n):e,o[h]=255*i;return o},s.hsl.hsv=function(t){var e,r,n=t[0],o=t[1]/100,i=t[2]/100,s=o,a=Math.max(i,.01);return i*=2,o*=1>=i?i:2-i,s*=1>=a?a:2-a,r=(i+o)/2,e=0===i?2*s/(a+s):2*o/(i+o),[n,100*e,100*r]},s.hsv.rgb=function(t){var e=t[0]/60,r=t[1]/100,n=t[2]/100,o=Math.floor(e)%6,i=e-Math.floor(e),s=255*n*(1-r),a=255*n*(1-r*i),l=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},s.hsv.hsl=function(t){var e,r,n,o=t[0],i=t[1]/100,s=t[2]/100,a=Math.max(s,.01);return n=(2-i)*s,e=(2-i)*a,r=i*a,r/=1>=e?e:2-e,r=r||0,n/=2,[o,100*r,100*n]},s.hwb.rgb=function(t){var e,r,n,o,i=t[0]/360,s=t[1]/100,a=t[2]/100,l=s+a;l>1&&(s/=l,a/=l),e=Math.floor(6*i),r=1-a,n=6*i-e,0!==(1&e)&&(n=1-n),o=s+n*(r-s);var h,u,c;switch(e){default:case 6:case 0:h=r,u=o,c=s;break;case 1:h=o,u=r,c=s;break;case 2:h=s,u=r,c=o;break;case 3:h=s,u=o,c=r;break;case 4:h=o,u=s,c=r;break;case 5:h=r,u=s,c=o}return[255*h,255*u,255*c]},s.cmyk.rgb=function(t){var e,r,n,o=t[0]/100,i=t[1]/100,s=t[2]/100,a=t[3]/100;return e=1-Math.min(1,o*(1-a)+a),r=1-Math.min(1,i*(1-a)+a),n=1-Math.min(1,s*(1-a)+a),[255*e,255*r,255*n]},s.xyz.rgb=function(t){var e,r,n,o=t[0]/100,i=t[1]/100,s=t[2]/100;return e=3.2406*o+-1.5372*i+s*-.4986,r=o*-.9689+1.8758*i+.0415*s,n=.0557*o+i*-.204+1.057*s,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,e=Math.min(Math.max(0,e),1),r=Math.min(Math.max(0,r),1),n=Math.min(Math.max(0,n),1),[255*e,255*r,255*n]},s.xyz.lab=function(t){var e,r,n,o=t[0],i=t[1],s=t[2];return o/=95.047,i/=100,s/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,e=116*i-16,r=500*(o-i),n=200*(i-s),[e,r,n]},s.lab.xyz=function(t){var e,r,n,o=t[0],i=t[1],s=t[2];r=(o+16)/116,e=i/500+r,n=r-s/200;var a=Math.pow(r,3),l=Math.pow(e,3),h=Math.pow(n,3);return r=a>.008856?a:(r-16/116)/7.787,e=l>.008856?l:(e-16/116)/7.787,n=h>.008856?h:(n-16/116)/7.787,e*=95.047,r*=100,n*=108.883,[e,r,n]},s.lab.lch=function(t){var e,r,n,o=t[0],i=t[1],s=t[2];return e=Math.atan2(s,i),r=360*e/2/Math.PI,0>r&&(r+=360),n=Math.sqrt(i*i+s*s),[o,n,r]},s.lch.lab=function(t){var e,r,n,o=t[0],i=t[1],s=t[2];return n=2*(s/360)*Math.PI,e=i*Math.cos(n),r=i*Math.sin(n),[o,e,r]},s.rgb.ansi16=function(t){var e=t[0],r=t[1],n=t[2],o=1 in arguments?arguments[1]:s.rgb.hsv(t)[2];if(o=Math.round(o/50),0===o)return 30;var i=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return 2===o&&(i+=60),i},s.hsv.ansi16=function(t){return s.rgb.ansi16(s.hsv.rgb(t),t[2])},s.rgb.ansi256=function(t){var e=t[0],r=t[1],n=t[2];if(e===r&&r===n)return 8>e?16:e>248?231:Math.round(24*((e-8)/247))+232;var o=16+36*Math.round(5*(e/255))+6*Math.round(5*(r/255))+Math.round(5*(n/255));return o},s.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=255*(e/10.5),[e,e,e];var r=.5*(~~(t>50)+1),n=255*(1&e)*r,o=255*(1&e>>1)*r,i=255*(1&e>>2)*r;return[n,o,i]},s.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}t-=16;var r,n=255*(Math.floor(t/36)/5),o=255*(Math.floor((r=t%36)/6)/5),i=255*(r%6/5);return[n,o,i]},s.rgb.hex=function(t){var e=((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2])),r=e.toString(16).toUpperCase();return"000000".substring(r.length)+r},s.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var r=e[0];3===e[0].length&&(r=r.split("").map(function(t){return t+t}).join(""));var n=parseInt(r,16),o=255&n>>16,i=255&n>>8,s=255&n;return[o,i,s]},s.rgb.hcg=function(t){var e,r,n=t[0]/255,o=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,o),i),a=Math.min(Math.min(n,o),i),l=s-a;return e=1>l?a/(1-l):0,r=0>=l?0:s===n?(o-i)/l%6:s===o?2+(i-n)/l:4+(n-o)/l+4,r/=6,r%=1,[360*r,100*l,100*e]},s.hsl.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1,o=0;return n=.5>r?2*e*r:2*e*(1-r),1>n&&(o=(r-.5*n)/(1-n)),[t[0],100*n,100*o]},s.hsv.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=e*r,o=0;return 1>n&&(o=(r-n)/(1-n)),[t[0],100*n,100*o]},s.hcg.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100;if(0===r)return[255*n,255*n,255*n];var o=[0,0,0],i=6*(e%1),s=i%1,a=1-s,l=0;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-r)*n,[255*(r*o[0]+l),255*(r*o[1]+l),255*(r*o[2]+l)]},s.hcg.hsv=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e),o=0;return n>0&&(o=e/n),[t[0],100*o,100*n]},s.hcg.hsl=function(t){var e=t[1]/100,r=t[2]/100,n=r*(1-e)+.5*e,o=0;return n>0&&.5>n?o=e/(2*n):n>=.5&&1>n&&(o=e/(2*(1-n))),[t[0],100*o,100*n]},s.hcg.hwb=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],100*(n-e),100*(1-n)]},s.hwb.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1-r,o=n-e,i=0;return 1>o&&(i=(n-o)/(1-o)),[t[0],100*o,100*i]},s.apple.rgb=function(t){return[255*(t[0]/65535),255*(t[1]/65535),255*(t[2]/65535)]},s.rgb.apple=function(t){return[65535*(t[0]/255),65535*(t[1]/255),65535*(t[2]/255)]},s.gray.rgb=function(t){return[255*(t[0]/100),255*(t[0]/100),255*(t[0]/100)]},s.gray.hsl=s.gray.hsv=function(t){return[0,0,t[0]]},s.gray.hwb=function(t){return[0,100,t[0]]},s.gray.cmyk=function(t){return[0,0,0,t[0]]},s.gray.lab=function(t){return[t[0],0,0]},s.gray.hex=function(t){var e=255&Math.round(255*(t[0]/100)),r=(e<<16)+(e<<8)+e,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n},s.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[100*(e/255)]}},{"color-name":5}],3:[function(t,e){function r(t){var e=function(e){return void 0===e||null===e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}function n(t){var e=function(e){if(void 0===e||null===e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var r=t(e);if("object"==typeof r)for(var n=r.length,o=0;n>o;o++)r[o]=Math.round(r[o]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}var o=t("./conversions"),i=t("./route"),s={},a=Object.keys(o);a.forEach(function(t){s[t]={},Object.defineProperty(s[t],"channels",{value:o[t].channels}),Object.defineProperty(s[t],"labels",{value:o[t].labels});var e=i(t),a=Object.keys(e);a.forEach(function(o){var i=e[o];s[t][o]=n(i),s[t][o].raw=r(i)})}),e.exports=s},{"./conversions":2,"./route":4}],4:[function(t,e){function r(){for(var t={},e=a.length,r=0;e>r;r++)t[a[r]]={distance:-1,parent:null};return t}function n(t){var e=r(),n=[t];for(e[t].distance=0;n.length;)for(var o=n.pop(),i=Object.keys(s[o]),a=i.length,l=0;a>l;l++){var h=i[l],u=e[h];-1===u.distance&&(u.distance=e[o].distance+1,u.parent=o,n.unshift(h))}return e}function o(t,e){return function(r){return e(t(r))}}function i(t,e){for(var r=[e[t].parent,t],n=s[e[t].parent][t],i=e[t].parent;e[i].parent;)r.unshift(e[i].parent),n=o(s[e[i].parent][i],n),i=e[i].parent;return n.conversion=r,n}var s=t("./conversions"),a=Object.keys(s);e.exports=function(t){for(var e=n(t),r={},o=Object.keys(e),s=o.length,a=0;s>a;a++){var l=o[a],h=e[l];null!==h.parent&&(r[l]=i(l,e))}return r}},{"./conversions":2}],5:[function(t,e){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],6:[function(t,e){function r(t,e,r){return Math.min(Math.max(e,t),r)}function n(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var o=t("color-name"),i=t("simple-swizzle"),s={};for(var a in o)o.hasOwnProperty(a)&&(s[o[a]]=a);var l=e.exports={to:{}};l.get=function(t){var e,r,n=t.substring(0,3).toLowerCase();switch(n){case"hsl":e=l.get.hsl(t),r="hsl";break;case"hwb":e=l.get.hwb(t),r="hwb";break;default:e=l.get.rgb(t),r="rgb"}return e?{model:r,value:e}:null},l.get.rgb=function(t){if(!t)return null;var e,n,i=/^#([a-fA-F0-9]{3})$/,s=/^#([a-fA-F0-9]{6})$/,a=/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,l=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,h=/(\D+)/,u=[0,0,0,1];if(e=t.match(i))for(e=e[1],n=0;3>n;n++)u[n]=parseInt(e[n]+e[n],16);else if(e=t.match(s))for(e=e[1],n=0;3>n;n++){var c=2*n;u[n]=parseInt(e.slice(c,c+2),16)}else if(e=t.match(a)){for(n=0;3>n;n++)u[n]=parseInt(e[n+1],0);e[4]&&(u[3]=parseFloat(e[4]))}else if(e=t.match(l)){for(n=0;3>n;n++)u[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(u[3]=parseFloat(e[4]))}else if(e=t.match(h))return"transparent"===e[1]?[0,0,0,0]:(u=o[e[1]])?(u[3]=1,u):null;for(n=0;n<u.length;n++)u[n]=r(u[n],0,255);return u[3]=r(u[3],0,1),u},l.get.hsl=function(t){if(!t)return null;var e=/^hsla?\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,n=t.match(e);if(n){var o=parseFloat(n[4]),i=(parseFloat(n[1])%360+360)%360,s=r(parseFloat(n[2]),0,100),a=r(parseFloat(n[3]),0,100),l=r(isNaN(o)?1:o,0,1);return[i,s,a,l]}return null},l.get.hwb=function(t){if(!t)return null;var e=/^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,n=t.match(e);if(n){var o=parseFloat(n[4]),i=(parseFloat(n[1])%360+360)%360,s=r(parseFloat(n[2]),0,100),a=r(parseFloat(n[3]),0,100),l=r(isNaN(o)?1:o,0,1);return[i,s,a,l]}return null},l.to.hex=function(t){return"#"+n(t[0])+n(t[1])+n(t[2])},l.to.rgb=function(){var t=i(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},l.to.rgb.percent=function(){var t=i(arguments),e=Math.round(100*(t[0]/255)),r=Math.round(100*(t[1]/255)),n=Math.round(100*(t[2]/255));return t.length<4||1===t[3]?"rgb("+e+"%, "+r+"%, "+n+"%)":"rgba("+e+"%, "+r+"%, "+n+"%, "+t[3]+")"},l.to.hsl=function(){var t=i(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},l.to.hwb=function(){var t=i(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},l.to.keyword=function(t){return s[t.slice(0,3)]}},{"color-name":5,"simple-swizzle":17}],7:[function(t,e){"use strict";function r(t,e){if(!(this instanceof r))return new r(t,e);if(e&&e in f&&(e=null),e&&!(e in u))throw new Error("Unknown model: "+e);var n,o;if(t)if(t instanceof r)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=h.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,o=u[this.model].channels,this.color=i.value.slice(0,o),this.valpha="number"==typeof i.value[o]?i.value[o]:1}else if(t.length){this.model=e||"rgb",o=u[this.model].channels;var s=c.call(t,0,o);this.color=l(s,o),this.valpha="number"==typeof t[o]?t[o]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[255&t>>16,255&t>>8,255&t],this.valpha=1;else{this.valpha=1;var a=Object.keys(t);"alpha"in t&&(a.splice(a.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var v=a.sort().join("");if(!(v in p))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=p[v];var g=u[this.model].labels,m=[];for(n=0;n<g.length;n++)m.push(t[g[n]]);this.color=l(m)}else this.model="rgb",this.color=[0,0,0],this.valpha=1;if(d[this.model])for(o=u[this.model].channels,n=0;o>n;n++){var y=d[this.model][n];y&&(this.color[n]=y(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function n(t,e){return Number(t.toFixed(e))}function o(t){return function(e){return n(e,t)}}function i(t,e,r){return t=Array.isArray(t)?t:[t],t.forEach(function(t){(d[t]||(d[t]=[]))[e]=r}),t=t[0],function(n){var o;return arguments.length?(r&&(n=r(n)),o=this[t](),o.color[e]=n,o):(o=this[t]().color[e],r&&(o=r(o)),o)}}function s(t){return function(e){return Math.max(0,Math.min(t,e))}}function a(t){return Array.isArray(t)?t:[t]}function l(t,e){for(var r=0;e>r;r++)"number"!=typeof t[r]&&(t[r]=0);return t}var h=t("color-string"),u=t("color-convert"),c=[].slice,f=["keyword","gray","hex"],p={};Object.keys(u).forEach(function(t){p[c.call(u[t].labels).sort().join("")]=t});var d={};r.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in h.to?this:this.rgb();e=e.round("number"==typeof t?t:1);var r=1===e.valpha?e.color:e.color.concat(this.valpha);return h.to[e.model](r)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),r=1===e.valpha?e.color:e.color.concat(this.valpha);return h.to.rgb.percent(r)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=u[this.model].channels,r=u[this.model].labels,n=0;e>n;n++)t[r[n]]=this.color[n];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new r(this.color.map(o(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new r(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:i("rgb",0,s(255)),green:i("rgb",1,s(255)),blue:i("rgb",2,s(255)),hue:i(["hsl","hsv","hsl","hwb","hcg"],0,function(t){return(t%360+360)%360}),saturationl:i("hsl",1,s(100)),lightness:i("hsl",2,s(100)),saturationv:i("hsv",1,s(100)),value:i("hsv",2,s(100)),chroma:i("hcg",1,s(100)),gray:i("hcg",2,s(100)),white:i("hwb",1,s(100)),wblack:i("hwb",2,s(100)),cyan:i("cmyk",0,s(100)),magenta:i("cmyk",1,s(100)),yellow:i("cmyk",2,s(100)),black:i("cmyk",3,s(100)),x:i("xyz",0,s(100)),y:i("xyz",1,s(100)),z:i("xyz",2,s(100)),l:i("lab",0,s(100)),a:i("lab",1),b:i("lab",2),keyword:function(t){return arguments.length?new r(t):u[this.model].keyword(this.color)},hex:function(t){return arguments.length?new r(t):h.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],r=0;r<t.length;r++){var n=t[r]/255;e[r]=.03928>=n?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),r=t.luminosity();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.rgb().color,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=this.rgb(),e=0;3>e;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return r.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),r=e.color[0];return r=(r+t)%360,r=0>r?360+r:r,e.color[0]=r,e},mix:function(t,e){var n=this.rgb(),o=t.rgb(),i=void 0===e?.5:e,s=2*i-1,a=n.alpha()-o.alpha(),l=((-1===s*a?s:(s+a)/(1+s*a))+1)/2,h=1-l;return r.rgb(l*n.red()+h*o.red(),l*n.green()+h*o.green(),l*n.blue()+h*o.blue(),n.alpha()*i+o.alpha()*(1-i))}},Object.keys(u).forEach(function(t){if(-1===f.indexOf(t)){var e=u[t].channels;r.prototype[t]=function(){if(this.model===t)return new r(this);if(arguments.length)return new r(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new r(a(u[this.model][t].raw(this.color)).concat(n),t)},r[t]=function(n){return"number"==typeof n&&(n=l(c.call(arguments),e)),new r(n,t)}}}),e.exports=r},{"color-convert":3,"color-string":6}],8:[function(t,e){function r(t){if("string"!=typeof t)throw new TypeError("String expected");var e=/<([\w:]+)/.exec(t);if(!e)throw new Error("No elements were generated.");var r=e[1];if("body"==r){var i=document.createElement("html");return i.innerHTML=t,[i.removeChild(i.lastChild)]}var s=o[r]||o._default,a=s[0],l=s[1],h=s[2],i=document.createElement("div");for(i.innerHTML=l+t+h;a--;)i=i.lastChild;return n(i.children)}function n(t){for(var e=[];t.length;)e.push(t[0].parentNode.removeChild(t[0]));return e}e.exports=r;var o={option:[1,'<select multiple="multiple">',"</select>"],optgroup:[1,'<select multiple="multiple">',"</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tbody:[1,"<table>","</table>"],tfoot:[1,"<table>","</table>"],colgroup:[1,"<table>","</table>"],caption:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],th:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]}},{}],9:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function o(t){return"number"==typeof t}function i(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,o,a,l,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(i(r))for(a=Array.prototype.slice.call(arguments,1),h=r.slice(),o=h.length,l=0;o>l;l++)h[l].apply(this,a);return!0},r.prototype.addListener=function(t,e){var o;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned&&(o=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,o&&o>0&&this._events[t].length>o&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),o||(o=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var o=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,o,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,o=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){o=a;break}if(0>o)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],10:[function(t,e){function r(t,e){e||(e={});var r="object"==typeof t?[t]:a(t);return l||(l=document.createElement("div")),o(h(e),function(t){var i=e[t];o(r,function(e){var r=e.parentNode;if(":first"===t)n(e,i);else if(/:first$/.test(t)){var o=t.replace(/:first$/,"");r&&r.removeChild(e),l.appendChild(e);var s=l.querySelector(o);l.removeChild(e),r&&r.appendChild(e),s&&n(s,i)}else{r&&r.removeChild(e),l.appendChild(e);var a=e.parentNode.querySelectorAll(t);if(l.removeChild(e),r&&r.appendChild(e),0===a.length)return;for(var h=0;h<a.length;h++)n(a[h],i)}})}),1===r.length?r[0]:r}function n(t,e){if(i(e))t.innerHTML="",t.appendChild(e);else if(u(e)){for(var n=0;n<e.length;n++){var a=r(t.cloneNode(!0),e[n]);t.parentNode.insertBefore(a,t)}t.parentNode.removeChild(t)}else e&&"object"==typeof e?o(h(e),function(r){if("_text"===r)s(t,e[r]);else if("_html"===r&&i(e[r]))t.innerHTML="",t.appendChild(e[r]);else if("_html"===r)t.innerHTML=e[r];else if(e[r]&&"object"==typeof e[r]){var n=e[r];n.append?t.setAttribute(r,t.getAttribute(r)+n.append):n.prepend&&t.setAttribute(r,n.prepend+t.getAttribute(r))}else t.setAttribute(r,e[r])}):s(t,e)}function o(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r<t.length;r++)e(t[r],r)}function i(t){return t&&"object"==typeof t&&t.childNodes&&("function"==typeof t.appendChild||"object"==typeof t.appendChild)}function s(t,e){t.innerHTML="";var r=document.createTextNode(String(e));t.appendChild(r)}var a=t("domify");e.exports=r;var l=null,h=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},u=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{domify:8}],11:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],12:[function(t,e){function r(t,e){if(e=e||{},void 0===t)throw new Error(s);var r=e.prepend===!0?"prepend":"append",a=void 0!==e.container?e.container:document.querySelector("head"),l=o.indexOf(a);-1===l&&(l=o.push(a)-1,i[l]={});var h;return void 0!==i[l]&&void 0!==i[l][r]?h=i[l][r]:(h=i[l][r]=n(),"prepend"===r?a.insertBefore(h,a.childNodes[0]):a.appendChild(h)),65279===t.charCodeAt(0)&&(t=t.substr(1,t.length)),h.styleSheet?h.styleSheet.cssText+=t:h.textContent+=t,h}function n(){var t=document.createElement("style");return t.setAttribute("type","text/css"),t}var o=[],i=[],s="insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).";e.exports=r,e.exports.insertCss=r},{}],13:[function(t,e){"use strict";e.exports=function(t){return t&&"string"!=typeof t?t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name):!1
}},{}],14:[function(t,e,r){!function(t){function e(t,e){for(var r=0,n=t.length-1;n>=0;n--){var o=t[n];"."===o?t.splice(n,1):".."===o?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}var o=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(t){return o.exec(t).slice(1)};r.resolve=function(){for(var r="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){var s=i>=0?arguments[i]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(r=s+"/"+r,o="/"===s.charAt(0))}return r=e(n(r.split("/"),function(t){return!!t}),!o).join("/"),(o?"/":"")+r||"."},r.normalize=function(t){var o=r.isAbsolute(t),i="/"===s(t,-1);return t=e(n(t.split("/"),function(t){return!!t}),!o).join("/"),t||o||(t="."),t&&i&&(t+="/"),(o?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(n(t,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var o=n(t.split("/")),i=n(e.split("/")),s=Math.min(o.length,i.length),a=s,l=0;s>l;l++)if(o[l]!==i[l]){a=l;break}for(var h=[],l=a;l<o.length;l++)h.push("..");return h=h.concat(i.slice(a)),h.join("/")},r.sep="/",r.delimiter=":",r.dirname=function(t){var e=i(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},r.basename=function(t,e){var r=i(t)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},r.extname=function(t){return i(t)[3]};var s="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return 0>e&&(e=t.length+e),t.substr(e,r)}}.call(this,t("_process"))},{_process:15}],15:[function(t,e){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(t){if(u===setTimeout)return setTimeout(t,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function i(t){if(c===clearTimeout)return clearTimeout(t);if((c===n||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(t);try{return c(t)}catch(e){try{return c.call(null,t)}catch(e){return c.call(this,t)}}}function s(){v&&p&&(v=!1,p.length?d=p.concat(d):g=-1,d.length&&a())}function a(){if(!v){var t=o(s);v=!0;for(var e=d.length;e;){for(p=d,d=[];++g<e;)p&&p[g].run();g=-1,e=d.length}p=null,v=!1,i(t)}}function l(t,e){this.fun=t,this.array=e}function h(){}var u,c,f=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:r}catch(t){u=r}try{c="function"==typeof clearTimeout?clearTimeout:n}catch(t){c=n}}();var p,d=[],v=!1,g=-1;f.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];d.push(new l(t,e)),1!==d.length||v||o(a)},l.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=h,f.addListener=h,f.once=h,f.off=h,f.removeListener=h,f.removeAllListeners=h,f.emit=h,f.binding=function(){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},{}],16:[function(t,e){e.exports=function(t){if(!t||"object"!=typeof t)return t;var e;if(n(t)){var o=t.length;e=Array(o);for(var i=0;o>i;i++)e[i]=t[i]}else{var s=r(t);e={};for(var i=0,a=s.length;a>i;i++){var l=s[i];e[l]=t[l]}}return e};var r=Object.keys||function(t){var e=[];for(var r in t)({}).hasOwnProperty.call(t,r)&&e.push(r);return e},n=Array.isArray||function(t){return"[object Array]"==={}.toString.call(t)}},{}],17:[function(t,e){"use strict";var r=t("is-arrayish"),n=Array.prototype.concat,o=Array.prototype.slice,i=e.exports=function(t){for(var e=[],i=0,s=t.length;s>i;i++){var a=t[i];r(a)?e=n.call(e,o.call(a)):e.push(a)}return e};i.wrap=function(t){return function(){return t(i(arguments))}}},{"is-arrayish":13}],18:[function(t,e){function r(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var o in r)n.call(r,o)&&(t[o]=r[o])}return t}e.exports=r;var n=Object.prototype.hasOwnProperty},{}],19:[function(t,e){function r(t){return this instanceof r?(this.idSequence=++p,u(".svg-widget {\n height: 100%;\n}\n\n.svg-widget .grid {\n border: solid 2px #F7F8A6;\n}\n\n.svg-widget svg *:not(.grid):not(text):not(tspan) {\n stroke-width: 1px;\n}\n\n.svg-widget svg text {\n stroke-width: 0;\n fill: none;\n margin: 0;\n padding: 0;\n}\n\n.svg-widget svg[data-control=move] *:not(.grid):hover,\n.svg-widget svg[data-control=rubber] *:not(.grid):hover {\n cursor: move;\n stroke-width: 2px;\n}\n\n.svg-widget svg[data-control=text] text:hover {\n cursor: pointer;\n}\n\n.svg-widget .anchor {\n display: none;\n}\n\n.svg-widget svg[data-control=move] .anchor,\n.svg-widget svg[data-control=text] .anchor,\n.svg-widget svg[data-control=rubber] .anchor {\n fill: rgba(213, 236, 24, 0.2);\n stroke: rgb(14, 14, 14);\n display: block;\n}\n"),this.html='<div class="svg-widget">\n <svg height="100%" width="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" shape-rendering="auto" preserveAspectRatio="xMidYMid meet">\n <defs>\n <pattern id="smallGrid" width="8" height="8" patternUnits="userSpaceOnUse">\n <path d="M 8 0 L 0 0 0 8" fill="none" stroke="#ccc" stroke-width="0.5" />\n </pattern>\n <pattern id="grid" width="80" height="80" patternUnits="userSpaceOnUse">\n <rect class="smallGrid" width="80" height="80" fill="url(#smallGrid)" stroke="#ddd" />\n <path d="M 80 0 L 0 0 0 80" fill="none" stroke="#bbb" stroke-width="0.5"/>\n </pattern>\n </defs>\n <rect class="grid" width="100%" height="100%" fill="url(#grid)"/>\n </svg>\n</div>\n',this.DEFAULT_STYLE={fill:"rgba(0, 0, 0, 0)",stroke:"rgba(0, 0, 0, 1)"},this.opt=t||{},this._resetStyle(),this.fonts={"default":{"font-family":"Arial","letter-spacing":0,"font-weight":"normal"}},this.fonts.Normal=h(this.fonts.default,{"font-size":11,"letter-spacing":0}),this.fonts.Heading=h(this.fonts.default,{"font-size":22,"font-weight":"bold","letter-spacing":0}),this.font=l(this.fonts.default),this.deleted=[],this.listeners={mousedown:this._down.bind(this),touchstart:this._down.bind(this),mouseup:this._up.bind(this),touchend:this._up.bind(this),mousemove:this._move.bind(this),touchmove:this._move.bind(this),anchorselect:this._anchorSelect.bind(this)},this.eventStream=new a,void 0):new r(t)}function n(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}var o=t("hyperglue"),i=t("events").EventEmitter,s=t("inherits"),a=t("./event_stream"),l=t("shallow-copy"),h=t("xtend"),u=t("insert-css"),c=t("color");t("path");var f=a.validEvent,p=0;e.exports=r,s(r,i),r.prototype.appendTo=function(t){return this.el?this:(this.el=t.appendChild(o(this.html,{"#grid":{id:"grid-"+this.idSequence},".grid":{fill:"url(#grid-"+this.idSequence+")"},"#smallGrid":{id:"smallGrid-"+this.idSequence},".smallGrid":{fill:"url(#smallGrid-"+this.idSequence+")"}})).children[0],this.controls={},this._eventListeners("addEventListener"),this)},r.prototype.registerControl=function(t,e){function r(t){i.eventStream.push(t),i._redraw([t])}function n(t){i._redraw([t])}function o(t){i.eventStream.push({type:"delete",target:t.target,args:{},path:t.path}),i._redraw(i.eventStream.events.slice(-1))}var i=this;if(e&&"undefined"!=typeof e.emit){i.controls[t]=e;var s=i.controls[t];s.on&&(s.on("createEvent",r),s.on("updateEvent",n),s.on("deletePath",o),s.on("closeToPath",i._pathSelected.bind(i)))}},r.prototype.remove=function(){if(this.el){var t=this.el.parentNode;this._eventListeners("removeEventListener"),t.parentNode.removeChild(t),this.el=null}},r.prototype._triggerEventsChanged=function d(){d.timer&&(clearTimeout(d.timer),d.timer=null),d.timer=setTimeout(function(){this.emit("eventStream",this.eventStream.toJSON())}.bind(this),300)},r.prototype.setEvents=function(t){for(this._resetStyle();this.eventStream.events.length;)this._deleteEvent();this.eventStream.events=t,this._redraw(),this._init(t)},r.prototype._deleteEvent=function(){var t=this.eventStream.events.pop();t.el&&t.el.parentNode&&(t.el.parentNode.removeChild(t.el),t.el=null)},r.prototype._resetEvents=function(){this._resetStyle(),this._redraw(),this._init(this.eventStream.events)},r.prototype.setControl=function(t){if("grid"===t)return this._grid();if("undo"===t)return this.undo();if("redo"===t)return this.redo();if(this.el.setAttribute("data-control",t),this.control=this.controls[t],this.emit("changeControl",t),!this.control)throw new Error("control "+t+" not supported");this.opt.anchor&&((this.opt.anchor.exclude||/undo|redo|grid/).test(t)||this._removeAnchorElements(),(this.opt.anchor.include||/rubber|move|text/).test(t)&&this._addAnchorElements(t))},r.prototype._init=function(t){function e(t){function e(e){var r=e.control;r.matchEvent&&r.matchEvent(t)&&(i=e.controlName)}return"style"===t.type?(o=t.args,t.args.stroke&&(n=t.args.stroke),void 0):(r().forEach(e),void 0)}function r(){return Object.keys(s.controls).map(function(t){return{controlName:t,control:s.controls[t]}})}var n,o,i,s=this;this.silent=!0,t.forEach(e),this.emit("changeStyle",o||s.style),this.emit("changeColor",n||s.DEFAULT_STYLE.stroke),i&&s.setControl(i),this.silent=!1},r.prototype._eventListeners=function(t){var e=this;Object.keys(this.listeners).forEach(function(r){e.el[t](r,e.listeners[r])})},r.prototype._down=function(t){this.emit("drawing"),this.control&&this.control.ondown&&this.control.ondown(t)},r.prototype._move=function(t){this.control&&this.control.onmove&&this.control.onmove(t)},r.prototype._up=function(t){this.control&&this.control.onup&&this.control.onup(t)},r.prototype._pathSelected=function(t){function e(t){return t.id===n}if(this.emit("drawing"),this.control&&this.control.onpathselected){var r=t.target,n=+r.getAttribute("data-id"),o=this.eventStream.events.filter(e);if(o.length)return this.control.onpathselected({path:o[0],e:t})}},r.prototype._resetStyle=function(){this.style=l(this.DEFAULT_STYLE)},r.prototype._redraw=function v(t){function e(t){if("style"===t.type)return i.style=h(i.DEFAULT_STYLE,t.args),void 0;var e=t.el||function(){if(t.target)return t.target;var e=i.el.appendChild(n(t.type));return t.el=e,e.setAttribute("data-id",++v.id),t.id=v.id,e.addEventListener("mousedown",i._pathSelected.bind(i)),e.addEventListener("touchstart",i._pathSelected.bind(i)),e}();for(var s in t.args)"value"!==s&&e.setAttribute(s,t.args[s]);if("move"!==t.type&&t.args.value)if(e.innerHTML="",t.layout&&t.layout.style&&t.layout.style.width){var a=new RegExp(".{0,"+(0|t.layout.style.width/5)+"}","g");t.args.value.match(a).forEach(function(r,o){if(0===o)e.textContent=r;else{var i=n("tspan");i.setAttribute("dy","1.1em"),i.setAttribute("x",t.args.x),i.textContent=r,e.appendChild(i)}})}else e.textContent=t.args.value;if("delete"===t.type)e.style.display="none";else if(!t.target){var u=l(i.style);"text"===t.type&&(u.fill=u.stroke),o(e,u),r(t,e)}}function r(t,e){t.layout&&t.layout.class&&e.setAttribute("class",t.layout.class),t.layout&&t.layout.font&&i.fonts[t.layout.font.name]&&(i.font=l(i.fonts[t.layout.font.name]),t.layout.font.size&&(i.font["font-size"]=t.layout.font.size));for(var r in i.font)e.setAttribute(r,i.font[r]);t.layout&&t.layout.rotate&&e.setAttribute("transform","rotate("+t.layout.rotate.deg+" "+t.args.x+" "+t.args.y+")")}function o(t,e){function r(t,r){return t+r+":"+e[r]+";"}t.setAttribute("style",Object.keys(e).reduce(r,""))}if(this.el){var i=this;t=t||i.eventStream.events,v.id=v.id||0,i._triggerEventsChanged(),t.forEach(e),this._addAnchorElements()}},r.prototype.resize=function(t,e){this.el&&this.el.setAttribute("viewBox","0 0 "+t+" "+e)},r.prototype.setColor=function(t){c(this.style.stroke).rgbaString()!==c(t).rgbaString()&&this.setStyle({stroke:c(t).rgbaString()})},r.prototype.setStyle=function(t){var e=h(this.DEFAULT_STYLE,t),r={type:"style",args:e};this.silent||this.eventStream.push(r),this._redraw([r])},r.prototype.undo=function(){var t=this.eventStream.pop();t&&(this.deleted.push(t),t.el&&(t.el.style.display="none")),this._resetEvents()},r.prototype.redo=function(){var t=this.deleted.pop();t&&(this.eventStream.push(t),t.el&&(t.el.style.display="block")),this._resetEvents()},r.prototype.setGridStyle=function(t){if(t=t||this.gridStyle){this.gridStyle=t;var e=this.el.querySelector(".grid");Object.keys(t).forEach(function(r){e.setAttribute(r,t[r])})}},r.prototype._grid=function(){var t=this.el.querySelector(".grid"),e="url(#grid-"+this.idSequence+")",r=t.getAttribute("fill");r="transparent"===r?e:"transparent",t.setAttribute("fill",r),this.el.setAttribute("data-grid",r===e),this.setGridStyle()},r.prototype._anchorSelect=function(t){var e=t.target.getAttribute("data-anchor-id"),r=this.el.querySelector('[data-id="'+e+'"]');t.stopPropagation(),this._pathSelected({target:r,stopPropagation:t.stopPropagation.bind(t)})},r.prototype._removeAnchorElements=function(){function t(t){t.removeEventListener("mousedown",r.listeners.anchorselect),t.removeEventListener("touchstart",r.listeners.anchorselect),t.parentNode.removeChild(t)}function e(t){delete t.anchorEl}var r=this;[].forEach.call(this.el.querySelectorAll(".anchor"),t),this.eventStream.events.forEach(e)},r.prototype._addAnchorElements=function g(t){function e(e){if(e.el){var o=(this.opt.anchor.position||r)(e);if(o.filter(Boolean).length&&("text"!==t||(e.target||e.el).nodeName.match(/text/i))){var i=e.anchorEl;i||(i=n("ellipse"),i.addEventListener("mousedown",this.listeners.anchorselect),i.addEventListener("touchstart",this.listeners.anchorselect),e.anchorEl=i,this.el.appendChild(i));var s=(e.target||e.el).getAttribute("data-id");i.style.display=(e.target||e.el).style.display,i.setAttribute("cx",o[0]),i.setAttribute("cy",o[1]),i.setAttribute("rx",this.opt.anchor.size||14),i.setAttribute("ry",this.opt.anchor.size||14),i.setAttribute("data-anchor-id",s),i.setAttribute("class","anchor")}}}function r(t){function e(){var t=/\d+\.?\d*\s*,\s*\d+\.?\d*/g,e=o.d.match(t)[0].split(",").map(Number);return[e[0],e[1]]}var r=t.target||t.el,n=r.attributes,o=[].reduce.call(n,function(t,e){return t[e.name]=e.value,t},{});return"text"===t.type&&(o.value=r.textContent),f({args:o,type:t.type})?"ellipse"===t.type?[o.cx-o.rx,o.cy]:"path"===t.type?e():[o.x,o.y]:[]}t&&(g.control=t),t=g.control,t&&this.opt.anchor&&this.eventStream.events.forEach(e.bind(this))},r.prototype.setClipboard=function(t){this.copied=t},r.prototype.copy=function(){this.copied=this.eventStream.toJSON(),this.emit("copy",this.copied)},r.prototype.cut=function(){this.copy(),this._removeAllEvents(),this._resetEvents()},r.prototype._removeAllEvents=function(){function t(t){t.el&&"delete"!==t.type&&e.eventStream.push({type:"delete",target:t.el,args:{},path:t})}var e=this;this.eventStream.events.forEach(t),this._removeAnchorElements()},r.prototype.paste=function(t){var e;try{var r=t.clipboardData.getData("text");e=JSON.parse(r)}catch(n){}(e||this.copied)&&(this._removeAllEvents(),Array.prototype.push.apply(this.eventStream.events,e||this.copied),this._resetEvents())}},{"./event_stream":1,color:7,events:9,hyperglue:10,inherits:11,"insert-css":12,path:14,"shallow-copy":16,xtend:18}]},{},[19])(19)});