react-sketch-whiteboard
Version:
Sketch Element for React based applications, backed-up by fabricjs as its core
3 lines • 361 kB
JavaScript
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=29)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}},function(t,e,i){t.exports=i(19)()},function(t,e,i){var n=i(14),r=i(15);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?r(t):e}},function(t,e){function i(e){return t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},i(e)}t.exports=i},function(t,e,i){var n=i(16);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},function(t,e,i){(function(t){
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
var n=n||{version:"3.5.1"};if(e.fabric=n,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?n.document=document:n.document=document.implementation.createHTMLDocument(""),n.window=window;else{var r=new(i(26).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;n.document=r.document,n.jsdomImplForWrapper=i(27).implForWrapper,n.nodeCanvas=i(28).Canvas,n.window=r,DOMParser=n.window.DOMParser}function o(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var o=i.height-n.height;r.drawImage(i,0,o,n.width,n.height,0,0,n.width,n.height)}function s(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,o=n*r*4,s=new Uint8Array(this.imageBuffer,0,o),a=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,s);var h=new ImageData(a,n,r);i.putImageData(h,0,0)}n.isTouchSupported="ontouchstart"in n.window||"ontouchstart"in n.document||n.window&&n.window.navigator&&n.window.navigator.maxTouchPoints>0,n.isLikelyNode=void 0!==t&&"undefined"==typeof window,n.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],n.DPI=96,n.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",n.fontPaths={},n.iMatrix=[1,0,0,1,0,0],n.perfLimitSizeTotal=2097152,n.maxCacheSideLimit=4096,n.minCacheSideLimit=256,n.charWidthsCache={},n.textureSize=2048,n.disableStyleCopyPaste=!1,n.enableGLFiltering=!0,n.devicePixelRatio=n.window.devicePixelRatio||n.window.webkitDevicePixelRatio||n.window.mozDevicePixelRatio||1,n.browserShadowBlurConstant=1,n.arcToSegmentsCache={},n.boundsOfCurveCache={},n.cachesBoundsOfCurve=!0,n.forceGLPutImageData=!1,n.initFilterBackend=function(){return n.enableGLFiltering&&n.isWebglSupported&&n.isWebglSupported(n.textureSize)?(console.log("max texture size: "+n.maxTextureSize),new n.WebglFilterBackend({tileSize:n.textureSize})):n.Canvas2dFilterBackend?new n.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=n),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:n.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(!this.__eventListeners)return this;if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var n in e)t.call(this,n,e[n]);else t.call(this,e,i);return this}function r(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n<r;n++)i[n]&&i[n].call(this,e||{});return this.__eventListeners[t]=i.filter(function(t){return!1!==t}),this}n.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}}(),n.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(t,e,i){var n=this._objects;return i?n[e]=t:n.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,n=0,r=arguments.length;n<r;n++)-1!==(t=e.indexOf(arguments[n]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[n]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),n=0,r=i.length;n<r;n++)t.call(e,i[n],n,i);return this},getObjects:function(t){return void 0===t?this._objects.concat():this._objects.filter(function(e){return e.type===t})},item:function(t){return this._objects[t]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(t){return this._objects.indexOf(t)>-1},complexity:function(){return this._objects.reduce(function(t,e){return t+(e.complexity?e.complexity():0)},0)}},n.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof n.Gradient||this.set(e,new n.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof n.Pattern?i&&i():this.set(e,new n.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=n.util.getFunctionBody(t.clipTo);void 0!==e&&(this.clipTo=new Function("ctx",e))}},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},function(t){var e=Math.sqrt,i=Math.atan2,r=Math.pow,o=Math.PI/180,s=Math.PI/2;n.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/s){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/s){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*o},radiansToDegrees:function(t){return t/o},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=n.util.rotateVector(t,i);return new n.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=n.util.sin(e),r=n.util.cos(e);return{x:t.x*r-t.y*i,y:t.x*i+t.y*r}},transformPoint:function(t,e,i){return i?new n.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new n.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i<t.length;i++)t[i]=n.util.transformPoint(t[i],e);var r=[t[0].x,t[1].x,t[2].x,t[3].x],o=n.util.array.min(r),s=n.util.array.max(r)-o,a=[t[0].y,t[1].y,t[2].y,t[3].y],h=n.util.array.min(a);return{left:o,top:h,width:s,height:n.util.array.max(a)-h}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=n.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-r.x,i[5]=-r.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);switch(e||(e=n.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*n.DPI/25.4;case"cm":return r*n.DPI/2.54;case"in":return r*n.DPI;case"pt":return r*n.DPI/72;case"pc":return r*n.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=n.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),n.util.resolveNamespace(e)[t]},getSvgAttributes:function(t){var e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":e=e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":e=e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":e=e.concat(["offset","stop-color","stop-opacity"])}return e},resolveNamespace:function(e){if(!e)return n;var i,r=e.split("."),o=r.length,s=t||n.window;for(i=0;i<o;++i)s=s[r[i]];return s},loadImage:function(t,e,i,r){if(t){var o=n.util.createImage(),s=function(){e&&e.call(i,o),o=o.onload=o.onerror=null};o.onload=s,o.onerror=function(){n.log("Error loading "+o.src),e&&e.call(i,null,!0),o=o.onload=o.onerror=null},0!==t.indexOf("data")&&r&&(o.crossOrigin=r),"data:image/svg"===t.substring(0,14)&&(o.onload=null,n.util.loadImageInDom(o,s)),o.src=t}else e&&e.call(i,t)},loadImageInDom:function(t,e){var i=n.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),n.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,r){var o=[],s=0,a=(t=t||[]).length;function h(){++s===a&&e&&e(o.filter(function(t){return t}))}a?t.forEach(function(t,e){t&&t.type?n.util.getKlass(t.type,i).fromObject(t,function(i,n){n||(o[e]=i),r&&r(t,i,n),h()}):h()}):e&&e(o)},enlivenPatterns:function(t,e){function i(){++o===s&&e&&e(r)}var r=[],o=0,s=(t=t||[]).length;s?t.forEach(function(t,e){t&&t.source?new n.Pattern(t,function(t){r[e]=t,i()}):(r[e]=t,i())}):e&&e(r)},groupSVGElements:function(t,e,i){var r;return t&&1===t.length?t[0]:(e&&(e.width&&e.height?e.centerPoint={x:e.width/2,y:e.height/2}:(delete e.width,delete e.height)),r=new n.Group(t,e),void 0!==i&&(r.sourcePath=i),r)},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var n=0,r=i.length;n<r;n++)i[n]in t&&(e[i[n]]=t[i[n]])},drawDashedLine:function(t,n,r,o,s,a){var h=o-n,c=s-r,l=e(h*h+c*c),u=i(c,h),f=a.length,d=0,g=!0;for(t.save(),t.translate(n,r),t.moveTo(0,0),t.rotate(u),n=0;l>n;)(n+=a[d++%f])>l&&(n=l),t[g?"lineTo":"moveTo"](n,0),g=!g;t.restore()},createCanvasElement:function(){return n.document.createElement("canvas")},copyCanvasElement:function(t){var e=n.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return n.document.createElement("img")},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var n=i(t[1],t[0]),s=r(t[0],2)+r(t[1],2),a=e(s),h=(t[0]*t[3]-t[2]*t[1])/a,c=i(t[0]*t[2]+t[1]*t[3],s);return{angle:n/o,scaleX:a,scaleY:h,skewX:c/o,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return n.iMatrix.concat();var e=n.util.degreesToRadians(t.angle),i=n.util.cos(e),r=n.util.sin(e);return[i,r,-r,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,r=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],o=n.util.multiplyTransformMatrices,s=n.util.degreesToRadians;return t.skewX&&(r=o(r,[1,0,Math.tan(s(t.skewX)),1],!0)),t.skewY&&(r=o(r,[1,Math.tan(s(t.skewY)),0,1],!0)),r},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=n.util.multiplyTransformMatrices;return t.angle&&(e=i(e,n.util.calcRotateMatrix(t))),(t.scaleX||t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,n.util.calcDimensionsMatrix(t))),e},customTransformMatrix:function(t,e,i){return n.util.composeMatrix({scaleX:t,scaleY:e,skewX:i})},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,n){n>0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,o=!0,s=t.getImageData(e,i,2*n||1,2*n||1),a=s.data.length;for(r=3;r<a&&!1!=(o=s.data[r]<=0);r+=4);return s=null,o},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",n=t.split(" ");return n&&n.length&&("meet"!==(i=n.pop())&&"slice"!==i?(e=i,i="meet"):n.length&&(e=n.pop())),{meetOrSlice:i,alignX:"none"!==e?e.slice(1,4):"none",alignY:"none"!==e?e.slice(5,8):"none"}},clearFabricFontCache:function(t){(t=(t||"").toLowerCase())?n.charWidthsCache[t]&&delete n.charWidthsCache[t]:n.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),n=Math.floor(e/i);return{x:Math.floor(i),y:n}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))},findScaleToFit:function(t,e){return Math.min(e.width/t.width,e.height/t.height)},findScaleToCover:function(t,e){return Math.max(e.width/t.width,e.height/t.height)},matrixToSVG:function(t){return"matrix("+t.map(function(t){return n.util.toFixed(t,n.Object.NUM_FRACTION_DIGITS)}).join(" ")+")"}}}(e),function(){var t=Array.prototype.join;function e(e,o,s,a,h,c,l){var u=t.call(arguments);if(n.arcToSegmentsCache[u])return n.arcToSegmentsCache[u];var f=Math.PI,d=l*f/180,g=n.util.sin(d),p=n.util.cos(d),v=0,m=0,_=-p*e*.5-g*o*.5,y=-p*o*.5+g*e*.5,b=(s=Math.abs(s))*s,x=(a=Math.abs(a))*a,C=y*y,S=_*_,w=b*x-b*C-x*S,T=0;if(w<0){var O=Math.sqrt(1-w/(b*x));s*=O,a*=O}else T=(h===c?-1:1)*Math.sqrt(w/(b*C+x*S));var k=T*s*y/a,P=-T*a*_/s,E=p*k-g*P+.5*e,j=g*k+p*P+.5*o,A=r(1,0,(_-k)/s,(y-P)/a),D=r((_-k)/s,(y-P)/a,(-_-k)/s,(-y-P)/a);0===c&&D>0?D-=2*f:1===c&&D<0&&(D+=2*f);for(var M=Math.ceil(Math.abs(D/f*2)),F=[],L=D/M,I=8/3*Math.sin(L/4)*Math.sin(L/4)/Math.sin(L/2),R=A+L,B=0;B<M;B++)F[B]=i(A,R,p,g,s,a,E,j,I,v,m),v=F[B][4],m=F[B][5],A=R,R+=L;return n.arcToSegmentsCache[u]=F,F}function i(t,e,i,r,o,s,a,h,c,l,u){var f=n.util.cos(t),d=n.util.sin(t),g=n.util.cos(e),p=n.util.sin(e),v=i*o*g-r*s*p+a,m=r*o*g+i*s*p+h;return[l+c*(-i*o*d-r*s*f),u+c*(-r*o*d+i*s*f),v+c*(i*o*p+r*s*g),m+c*(r*o*p-i*s*g),v,m]}function r(t,e,i,n){var r=Math.atan2(e,t),o=Math.atan2(n,i);return o>=r?o-r:2*Math.PI-(r-o)}function o(e,i,r,o,s,a,h,c){var l;if(n.cachesBoundsOfCurve&&(l=t.call(arguments),n.boundsOfCurveCache[l]))return n.boundsOfCurveCache[l];var u,f,d,g,p,v,m,_,y=Math.sqrt,b=Math.min,x=Math.max,C=Math.abs,S=[],w=[[],[]];f=6*e-12*r+6*s,u=-3*e+9*r-9*s+3*h,d=3*r-3*e;for(var T=0;T<2;++T)if(T>0&&(f=6*i-12*o+6*a,u=-3*i+9*o-9*a+3*c,d=3*o-3*i),C(u)<1e-12){if(C(f)<1e-12)continue;0<(g=-d/f)&&g<1&&S.push(g)}else(m=f*f-4*d*u)<0||(0<(p=(-f+(_=y(m)))/(2*u))&&p<1&&S.push(p),0<(v=(-f-_)/(2*u))&&v<1&&S.push(v));for(var O,k,P,E=S.length,j=E;E--;)O=(P=1-(g=S[E]))*P*P*e+3*P*P*g*r+3*P*g*g*s+g*g*g*h,w[0][E]=O,k=P*P*P*i+3*P*P*g*o+3*P*g*g*a+g*g*g*c,w[1][E]=k;w[0][j]=e,w[1][j]=i,w[0][j+1]=h,w[1][j+1]=c;var A=[{x:b.apply(null,w[0]),y:b.apply(null,w[1])},{x:x.apply(null,w[0]),y:x.apply(null,w[1])}];return n.cachesBoundsOfCurve&&(n.boundsOfCurveCache[l]=A),A}n.util.drawArc=function(t,i,n,r){for(var o=r[0],s=r[1],a=r[2],h=r[3],c=r[4],l=[[],[],[],[]],u=e(r[5]-i,r[6]-n,o,s,h,c,a),f=0,d=u.length;f<d;f++)l[f][0]=u[f][0]+i,l[f][1]=u[f][1]+n,l[f][2]=u[f][2]+i,l[f][3]=u[f][3]+n,l[f][4]=u[f][4]+i,l[f][5]=u[f][5]+n,t.bezierCurveTo.apply(t,l[f])},n.util.getBoundsOfArc=function(t,i,n,r,s,a,h,c,l){for(var u,f=0,d=0,g=[],p=e(c-t,l-i,n,r,a,h,s),v=0,m=p.length;v<m;v++)u=o(f,d,p[v][0],p[v][1],p[v][2],p[v][3],p[v][4],p[v][5]),g.push({x:u[0].x+t,y:u[0].y+i}),g.push({x:u[1].x+t,y:u[1].y+i}),f=p[v][4],d=p[v][5];return g},n.util.getBoundsOfCurve=o}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var n=t.length-1,r=e?t[n][e]:t[n];if(e)for(;n--;)i(t[n][e],r)&&(r=t[n][e]);else for(;n--;)i(t[n],r)&&(r=t[n]);return r}}n.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var n=t.call(arguments,2),r=[],o=0,s=e.length;o<s;o++)r[o]=n.length?e[o][i].apply(e[o],n):e[o][i].call(e[o]);return r},min:function(t,i){return e(t,i,function(t,e){return t<e})},max:function(t,i){return e(t,i,function(t,e){return t>=e})}}}(),function(){function t(e,i,r){if(r)if(!n.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var o=0,s=i.length;o<s;o++)e[o]=t({},i[o],r)}else if(i&&"object"==typeof i)for(var a in i)"canvas"===a?e[a]=t({},i[a]):i.hasOwnProperty(a)&&(e[a]=t({},i[a],r));else e=i;else for(var a in i)e[a]=i[a];return e}n.util.object={extend:t,clone:function(e,i){return t({},e,i)}},n.util.object.extend(n.util,n.Observable)}(),function(){function t(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}n.util.string={camelize:function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n<e.length;n++)!1!==(i=t(e,n))&&r.push(i);return r}}}(),function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),r=function(t,e,n){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function o(){}function s(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}n.util.createClass=function(){var i=null,n=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof n[0]&&(i=n.shift()),a.superclass=i,a.subclasses=[],i&&(o.prototype=i.prototype,a.prototype=new o,i.subclasses.push(a));for(var h=0,c=n.length;h<c;h++)r(a,n[h],i);return a.prototype.initialize||(a.prototype.initialize=e),a.prototype.constructor=a,a.prototype.callSuper=s,a}}(),function(){var t=!!n.document.createElement("div").attachEvent;n.util.addListener=function(e,i,n,r){e&&e.addEventListener(i,n,!t&&r)},n.util.removeListener=function(e,i,n,r){e&&e.removeEventListener(i,n,!t&&r)},n.util.getPointer=function(t){var e=t.target,i=n.util.getScrollLeftTop(e),r=function(t){var e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return{x:r.clientX+i.left,y:r.clientY+i.top}}}(),function(){var t=n.document.createElement("div"),e="string"==typeof t.style.opacity,i="string"==typeof t.style.filter,r=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,o=function(t){return t};e?o=function(t,e){return t.style.opacity=e,t}:i&&(o=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),r.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(r,e)):i.filter+=" alpha(opacity="+100*e+")",t}),n.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?o(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?o(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t}}(),function(){var t,e,i=Array.prototype.slice,r=function(t){return i.call(t,0)};try{t=r(n.document.childNodes)instanceof Array}catch(i){}function o(t,e){var i=n.document.createElement(t);for(var r in e)"class"===r?i.className=e[r]:"for"===r?i.htmlFor=e[r]:i.setAttribute(r,e[r]);return i}function s(t){for(var e=0,i=0,r=n.document.documentElement,o=n.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===n.document?(e=o.scrollLeft||r.scrollLeft||0,i=o.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(r=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=n.document.defaultView&&n.document.defaultView.getComputedStyle?function(t,e){var i=n.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},function(){var t=n.document.documentElement.style,e="userSelect"in t?"userSelect":"MozUserSelect"in t?"MozUserSelect":"WebkitUserSelect"in t?"WebkitUserSelect":"KhtmlUserSelect"in t?"KhtmlUserSelect":"";n.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=n.util.falseFunction),e?t.style[e]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},n.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),e?t.style[e]="":"string"==typeof t.unselectable&&(t.unselectable=""),t}}(),n.util.getScript=function(t,e){var i=n.document.getElementsByTagName("head")[0],r=n.document.createElement("script"),o=!0;r.onload=r.onreadystatechange=function(t){if(o){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;o=!1,e(t||n.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)},n.util.getById=function(t){return"string"==typeof t?n.document.getElementById(t):t},n.util.toArray=r,n.util.makeElement=o,n.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},n.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=o(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},n.util.getScrollLeftTop=s,n.util.getElementOffset=function(t){var i,n,r=t&&t.ownerDocument,o={left:0,top:0},a={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return a;for(var c in h)a[h[c]]+=parseInt(e(t,c),10)||0;return i=r.documentElement,void 0!==t.getBoundingClientRect&&(o=t.getBoundingClientRect()),n=s(t),{left:o.left+n.left-(i.clientLeft||0)+a.left,top:o.top+n.top-(i.clientTop||0)+a.top}},n.util.getElementStyle=e,n.util.getNodeCanvas=function(t){var e=n.jsdomImplForWrapper(t);return e._canvas||e._image},n.util.cleanUpJsdomNode=function(t){if(n.isLikelyNode){var e=n.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}n.util.request=function(e,i){i||(i={});var r=i.method?i.method.toUpperCase():"GET",o=i.onComplete||function(){},s=new n.window.XMLHttpRequest,a=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(o(s),s.onreadystatechange=t)},"GET"===r&&(a=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(r,e,!0),"POST"!==r&&"PUT"!==r||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a),s}}(),n.log=function(){},n.warn=function(){},"undefined"!=typeof console&&["log","warn"].forEach(function(t){void 0!==console[t]&&"function"==typeof console[t].apply&&(n[t]=function(){return console[t].apply(console,arguments)})}),function(){function t(){return!1}function e(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}var i=n.window.requestAnimationFrame||n.window.webkitRequestAnimationFrame||n.window.mozRequestAnimationFrame||n.window.oRequestAnimationFrame||n.window.msRequestAnimationFrame||function(t){return n.window.setTimeout(t,1e3/60)},r=n.window.cancelAnimationFrame||n.window.clearTimeout;function o(){return i.apply(n.window,arguments)}n.util.animate=function(i){o(function(n){i||(i={});var r,s=n||+new Date,a=i.duration||500,h=s+a,c=i.onChange||t,l=i.abort||t,u=i.onComplete||t,f=i.easing||e,d="startValue"in i?i.startValue:0,g="endValue"in i?i.endValue:100,p=i.byValue||g-d;i.onStart&&i.onStart(),function t(e){var i=(r=e||+new Date)>h?a:r-s,n=i/a,v=f(i,d,p,a),m=Math.abs((v-d)/p);if(!l())return r>h?(c(g,1,1),void u(g,1,1)):(c(v,m,n),void o(t));u(g,1,1)}(s)})},n.util.requestAnimFrame=o,n.util.cancelAnimFrame=function(){return r.apply(n.window,arguments)}}(),n.util.animateColor=function(t,e,i,r){var o=new n.Color(t).getSource(),s=new n.Color(e).getSource();r=r||{},n.util.animate(n.util.object.extend(r,{duration:i||500,startValue:o,endValue:s,byValue:s,easing:function(t,e,i,n){return function(t,e,i){var n="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(n+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}(e,i,r.colorEasing?r.colorEasing(t,n):1-Math.cos(t/n*(Math.PI/2)))}}))},function(){function t(t,e,i,n){return t<Math.abs(e)?(t=e,n=i/4):n=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:n}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,n){return i-r(n-t,0,i,n)+e}function r(t,e,i,n){return(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}n.util.ease={easeInQuad:function(t,e,i,n){return i*(t/=n)*t+e},easeOutQuad:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},easeInOutQuad:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,n){return i*(t/=n)*t*t+e},easeOutCubic:function(t,e,i,n){return i*((t=t/n-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,n){return i*(t/=n)*t*t*t+e},easeOutQuart:function(t,e,i,n){return-i*((t=t/n-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},easeOutQuint:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,n){return i*Math.sin(t/n*(Math.PI/2))+e},easeInOutSine:function(t,e,i,n){return-i/2*(Math.cos(Math.PI*t/n)-1)+e},easeInExpo:function(t,e,i,n){return 0===t?e:i*Math.pow(2,10*(t/n-1))+e},easeOutExpo:function(t,e,i,n){return t===n?e+i:i*(1-Math.pow(2,-10*t/n))+e},easeInOutExpo:function(t,e,i,n){return 0===t?e:t===n?e+i:(t/=n/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,n){return-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOutCirc:function(t,e,i,n){return i*Math.sqrt(1-(t=t/n-1)*t)+e},easeInOutCirc:function(t,e,i,n){return(t/=n/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,n,r,o){var s=0;return 0===i?n:1==(i/=o)?n+r:(s||(s=.3*o),-e(t(r,r,s,1.70158),i,o)+n)},easeOutElastic:function(e,i,n,r){var o=0,s=n;if(0===e)return i;if(1==(e/=r))return i+n;o||(o=.3*r);var a=t(s,n,o,1.70158);return a.a*Math.pow(2,-10*e)*Math.sin((e*r-a.s)*(2*Math.PI)/a.p)+a.c+i},easeInOutElastic:function(i,n,r,o){var s=0,a=r;if(0===i)return n;if(2==(i/=o/2))return n+r;s||(s=o*(.3*1.5));var h=t(a,r,s,1.70158);return i<1?-.5*e(h,i,o)+n:h.a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-h.s)*(2*Math.PI)/h.p)*.5+h.c+n},easeInBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*(t/=n)*t*((r+1)*t-r)+e},easeOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},easeInOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInBounce:i,easeOutBounce:r,easeInOutBounce:function(t,e,n,o){return t<o/2?.5*i(2*t,0,n,o)+e:.5*r(2*t-o,0,n,o)+.5*n+e}}}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,o=e.util.parseUnit,s=e.util.multiplyTransformMatrices,a={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform"},h={stroke:"strokeOpacity",fill:"fillOpacity"};function c(t){return t in a?a[t]:t}function l(t,i,n,r){var a,h="[object Array]"===Object.prototype.toString.call(i);if("fill"!==t&&"stroke"!==t||"none"!==i)if("vector-effect"===t)i="non-scaling-stroke"===i;else if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)i=n&&n.transformMatrix?s(n.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,n&&!1===n.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),n&&void 0!==n.opacity&&(i*=n.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=o(i,r)/r*1e3;else if("paintFirst"===t){var c=i.indexOf("fill"),l=i.indexOf("stroke");i="fill",c>-1&&l>-1&&l<c?i="stroke":-1===c&&l>-1&&(i="stroke")}else{if("href"===t||"xlink:href"===t)return i;a=h?i.map(o):o(i,r)}else i="";return!h&&isNaN(a)?i:a}function u(t){return new RegExp("^("+t.join("|")+")\\b","i")}function f(t,e){var i,n,r,o,s=[];for(r=0,o=e.length;r<o;r++)i=e[r],n=t.getElementsByTagName(i),s=s.concat(Array.prototype.slice.call(n));return s}function d(t,e){var i,n=!0;return(i=g(t,e.pop()))&&e.length&&(n=function(t,e){for(var i,n=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)n&&(i=e.pop()),n=g(t=t.parentNode,i);return 0===e.length}(t,e)),i&&n&&0===e.length}function g(t,e){var i,n,r=t.nodeName,o=t.getAttribute("class"),s=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),s&&e.length&&(i=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),o&&e.length)for(n=(o=o.split(" ")).length;n--;)i=new RegExp("\\."+o[n]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function p(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var n,r,o,s=t.getElementsByTagName("*");for(r=0,o=s.length;r<o;r++)if(e===(n=s[r]).getAttribute("id"))return n}e.svgValidTagNamesRegEx=u(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=u(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=u(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=u(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,n){t[n]=Math.tan(e.util.degreesToRadians(i[0]))}var i=e.iMatrix,n=e.reNum,r="(?:\\s+,?\\s*|,\\s*)",o="(?:(?:(matrix)\\s*\\(\\s*("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")\\s*\\))|(?:(translate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))|(?:(scale)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))|(?:(rotate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+")"+r+"("+n+"))?\\s*\\))|(?:(skewX)\\s*\\(\\s*("+n+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+n+")\\s*\\)))",s=new RegExp("^\\s*(?:(?:"+o+"(?:"+r+"*"+o+")*)?)\\s*$"),a=new RegExp(o,"g");return function(n){var r=i.concat(),h=[];if(!n||n&&!s.test(n))return r;n.replace(a,function(n){var s=new RegExp(o).exec(n).filter(function(t){return!!t}),a=s[1],c=s.slice(2).map(parseFloat);switch(a){case"translate":!function(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}(r,c);break;case"rotate":c[0]=e.util.degreesToRadians(c[0]),function(t,i){var n=e.util.cos(i[0]),r=e.util.sin(i[0]),o=0,s=0;3===i.length&&(o=i[1],s=i[2]),t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=o-(n*o-r*s),t[5]=s-(r*o+n*s)}(r,c);break;case"scale":!function(t,e){var i=e[0],n=2===e.length?e[1]:e[0];t[0]=i,t[3]=n}(r,c);break;case"skewX":t(r,c,2);break;case"skewY":t(r,c,1);break;case"matrix":r=c}h.push(r.concat()),r=i.concat()});for(var c=h[0];h.length>1;)h.shift(),c=e.util.multiplyTransformMatrices(c,h[0]);return c}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function m(t){var i,n,r,s,a,h,c=t.getAttribute("viewBox"),l=1,u=1,f=t.getAttribute("width"),d=t.getAttribute("height"),g=t.getAttribute("x")||0,p=t.getAttribute("y")||0,m=t.getAttribute("preserveAspectRatio")||"",_=!c||!e.svgViewBoxElementsRegEx.test(t.nodeName)||!(c=c.match(v)),y=!f||!d||"100%"===f||"100%"===d,b=_&&y,x={},C="",S=0,w=0;if(x.width=0,x.height=0,x.toBeParsed=b,b)return x;if(_)return x.width=o(f),x.height=o(d),x;if(i=-parseFloat(c[1]),n=-parseFloat(c[2]),r=parseFloat(c[3]),s=parseFloat(c[4]),x.minX=i,x.minY=n,x.viewBoxWidth=r,x.viewBoxHeight=s,y?(x.width=r,x.height=s):(x.width=o(f),x.height=o(d),l=x.width/r,u=x.height/s),"none"!==(m=e.util.parsePreserveAspectRatioAttribute(m)).alignX&&("meet"===m.meetOrSlice&&(u=l=l>u?u:l),"slice"===m.meetOrSlice&&(u=l=l>u?l:u),S=x.width-r*l,w=x.height-s*l,"Mid"===m.alignX&&(S/=2),"Mid"===m.alignY&&(w/=2),"Min"===m.alignX&&(S=0),"Min"===m.alignY&&(w=0)),1===l&&1===u&&0===i&&0===n&&0===g&&0===p)return x;if((g||p)&&(C=" translate("+o(g)+" "+o(p)+") "),a=C+" matrix("+l+" 0 0 "+u+" "+(i*l+S)+" "+(n*u+w)+") ",x.viewboxTransform=e.parseTransformAttribute(a),"svg"===t.nodeName){for(h=t.ownerDocument.createElement("g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else a=(h=t).getAttribute("transform")+a;return h.setAttribute("transform",a),x}function _(t,e){var i=p(t,e.getAttribute("xlink:href").substr(1));if(i&&i.getAttribute("xlink:href")&&_(t,i),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach(function(t){i&&!e.hasAttribute(t)&&i.hasAttribute(t)&&e.setAttribute(t,i.getAttribute(t))}),!e.children.length)for(var n=i.cloneNode(!0);n.firstChild;)e.appendChild(n.firstChild);e.removeAttribute("xlink:href")}e.parseSVGDocument=function(t,i,r,o){if(t){!function(t){for(var e=f(t,["use","svg:use"]),i=0;e.length&&i<e.length;){var n,r,o,s,a=e[i],h=(a.getAttribute("xlink:href")||a.getAttribute("href")).substr(1),c=a.getAttribute("x")||0,l=a.getAttribute("y")||0,u=p(t,h).cloneNode(!0),d=(u.getAttribute("transform")||"")+" translate("+c+", "+l+")",g=e.length;if(m(u),/^svg$/i.test(u.nodeName)){var v=u.ownerDocument.createElement("g");for(r=0,s=(o=u.attributes).length;r<s;r++)n=o.item(r),v.setAttribute(n.nodeName,n.nodeValue);for(;u.firstChild;)v.appendChild(u.firstChild);u=v}for(r=0,s=(o=a.attributes).length;r<s;r++)"x"!==(n=o.item(r)).nodeName&&"y"!==n.nodeName&&"xlink:href"!==n.nodeName&&"href"!==n.nodeName&&("transform"===n.nodeName?d=n.nodeValue+" "+d:u.setAttribute(n.nodeName,n.nodeValue));u.setAttribute("transform",d),u.setAttribute("instantiated_by_use","1"),u.removeAttribute("id"),a.parentNode.replaceChild(u,a),e.length===g&&i++}}(t);var s,a,h=e.Object.__uid++,c=m(t),l=e.util.toArray(t.getElementsByTagName("*"));if(c.crossOrigin=o&&o.crossOrigin,c.svgUid=h,0===l.length&&e.isLikelyNode){var u=[];for(s=0,a=(l=t.selectNodes('//*[name(.)!="svg"]')).length;s<a;s++)u[s]=l[s];l=u}var d=l.filter(function(t){return m(t),e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))&&!function(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}(t,e.svgInvalidAncestorsRegEx)});if(!d||d&&!d.length)i&&i([],{});else{var g={};l.filter(function(t){return"clipPath"===t.nodeName.replace("svg:","")}).forEach(function(t){var i=t.getAttribute("id");g[i]=e.util.toArray(t.getElementsByTagName("*")).filter(function(t){return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))})}),e.gradientDefs[h]=e.getGradientDefs(t),e.cssRules[h]=e.getCSSRules(t),e.clipPaths[h]=g,e.parseElements(d,function(t,n){i&&(i(t,c,n,l),delete e.gradientDefs[h],delete e.cssRules[h],delete e.clipPaths[h])},n(c),r,o)}}};var y=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(y);if(i){var n=i[1],r=i[3],s=i[4],a=i[5],h=i[6];n&&(e.fontStyle=n),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),s&&(e.fontSize=o(s)),h&&(e.fontFamily=h),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i=f(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),n=0,r={};for(n=i.length;n--;)(e=i[n]).getAttribute("xlink:href")&&_(t,e),r[e.getAttribute("id")]=e;return r},parseAttributes:function(t,n,s){if(t){var a,u,f,g={};void 0===s&&(s=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(g=e.parseAttributes(t.parentNode,n,s));var p=n.reduce(function(e,i){return(a=t.getAttribute(i))&&(e[i]=a),e},{});p=i(p,i(function(t,i){var n={};for(var r in e.cssRules[i])if(d(t,r.split(" ")))for(var o in e.cssRules[i][r])n[o]=e.cssRules[i][r][o];return n}(t,s),e.parseStyleAttribute(t))),u=f=g.fontSize||e.Text.DEFAULT_SVG_FONT_SIZE,p["font-size"]&&(p["font-size"]=u=o(p["font-size"],f));var v,m,_={};for(var y in p)m=l(v=c(y),p[y],g,u),_[v]=m;_&&_.font&&e.parseFontDeclaration(_.font,_);var b=i(g,_);return e.svgValidParentsRegEx.test(t.nodeName)?b:function(t){for(var i in h)if(void 0!==t[h[i]]&&""!==t[i]){if(void 0===t[i]){if(!e.Object.prototype[i])continue;t[i]=e.Object.prototype[i]}if(0!==t[i].indexOf("url(")){var n=new e.Color(t[i]);t[i]=n.setAlpha(r(n.getAlpha()*t[h[i]],2)).toRgba()}}return t}(b)}},parseElements:function(t,i,n,r,o){new e.ElementsParser(t,i,n,r,o).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){var i,n;t.replace(/;\s*$/,"").split(";").forEach(function(t){var r=t.split(":");i=r[0].trim().toLowerCase(),n=r[1].trim(),e[i]=n})}(i,e):function(t,e){var i,n;for(var r in t)void 0!==t[r]&&(i=r.toLowerCase(),n=t[r],e[i]=n)}(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;var e,i,n=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n},getCSSRules:function(t){var i,n,r=t.getElementsByTagName("style"),o={};for(i=0,n=r.length;i<n;i++){var s=r[i].textContent||r[i].text;""!==(s=s.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&s.match(/[^{]*\{[\s\S]*?\}/g).map(function(t){return t.trim()}).forEach(function(t){var r=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),s={},a=r[2].trim().replace(/;$/,"").split(/\s*;\s*/);for(i=0,n=a.length;i<n;i++){var h=a[i].split(/\s*:\s*/),c=h[0],l=h[1];s[c]=l}(t=r[1]).split(",").forEach(function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(o[t]?e.util.object.extend(o[t],s):o[t]=e.util.object.clone(s))})})}return o},loadSVGFromURL:function(t,i,n,r){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var o=t.responseXML;if(o&&!o.documentElement&&e.window.ActiveXObject&&t.responseText&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),!o||!o.documentElement)return i&&i(null),!1;e.parseSVGDocument(o.documentElement,function(t,e,n,r){i&&i(t,e,n,r)},n,r)}})},loadSVGFromString:function(t,i,n,r){var o;if(t=t.trim(),void 0!==e.window.DOMParser){var s=new e.window.DOMParser;s&&s.parseFromString&&(o=s.parseFromString(t,"text/xml"))}else e.window.ActiveXObject&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));e.parseSVGDocument(o.documentElement,function(t,e,n,r){i(t,e,n,r)},n,r)}})}(e),n.ElementsParser=function(t,e,i,n,r){this.elements=t,this.callback=e,this.options=i,this.reviver=n,this.svgUid=i&&i.svgUid||0,this.parsingOptions=r,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g},function(t){t.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},t.createObjects=function(){var t=this;this.elements.forEach(function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)})},t.findTag=function(t){return n[n.util.string.capitalize(t.tagName.replace("svg:",""))]},t.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){n.log(t)}else this.checkIfDone()},t.createCallback=function(t,e){var i=this;return function(r){var o;i.resolveGradient(r,e,"fill"),i.resolveGradient(r,e,"stroke"),r instanceof n.Image&&r._originalElement&&(o=r.parsePreserveAspectRatioAttribute(e)),r._removeTransformMatrix(o),i.resolveClipPath(r),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},t.extractPropertyDefinition=function(t,e,i){var r=t[e];if(/^url\(/.test(r)){var o=this.regexUrl.exec(r)[1];return this.regexUrl.lastIndex=0,n[i][this.svgUid][o]}},t.resolveGradient=function(t,e,i){var r=this.extractPropertyDefinition(t,i,"gradientDefs");if(r){var o=e.getAttribute(i+"-opacity"),s=n.Gradient.fromElement(r,t,o,this.options);t.set(i,s)}},t.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},t.resolveClipPath=function(t){var e,i,r,o,s=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(s){r=[],i=n.util.invertTransform(t.calcTransformMatrix());for(var a=0;a<s.length;a++)e=s[a],this.findTag(e).fromElement(e,this.createClipPathCallback(t,r),this.options);s=1===r.length?r[0]:new n.Group(r),o=n.util.multiplyTransformMatrices(i,s.calcTransformMatrix()),s.clipPath&&this.resolveClipPath(s);var h=n.util.qrDecompose(o);s.flipX=!1,s.flipY=!1,s.set("scaleX",h.scaleX),s.set("scaleY",h.scaleY),s.angle=h.angle,s.skewX=h.skewX,s.skewY=0,s.setPositionByOrigin({x:h.translateX,y:h.translateY},"center","center"),t.clipPath=s}},t.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances,this.elements))}}(n.ElementsParser.prototype),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t,e){this.x=t,this.y=e}e.Point?e.warn("fabric.Point is already defined"):(e.Point=i,i.prototype={type:"point",constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,o){var s,a=(o.x-r.x)*(t.y-r.y)-(o.y-r.y)*(t.x-r.x),h=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),c=(o.y-r.y)*(n.x-t.x)-(o.x-r.x)*(n.y-t.y);if(0!==c){var l=a/c,u=h/c;0<=l&&l<=1&&0<=u&&u<=1?(s=new i("Intersection")).appendPoint(new e.Point(t.x+l*(n.x-t.x),t.y+l*(n.y-t.y))):s=new i}else s=new i(0===a||0===h?"Coincident":"Parallel");return s},e.Intersection.intersectLinePolygon=function(t,e,n){var r,o,s,a,h=new i,c=n.length;for(a=0;a<c;a++)r=n[a],o=n[(a+1)%c],s=i.intersectLineLine(t,e,r,o),h.appendPoints(s.points);return h.points.length>0&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,o=t.length;for(n=0;n<o;n++){var s=t[n],a=t[(n+1)%o],h=i.intersectLinePolygon(s,a,e);r.appendPoints(h.points)}return r.points.length>0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var o=n.min(r),s=n.max(r),a=new e.Point(s.x,o.y),h=new e.Point(o.x,s.y),c=i.intersectLinePolygon(o,a,t),l=i.intersectLinePolygon(a,s,t),u=i.intersectLinePolygon(s,h,t),f=i.intersectLinePolygon(h,o,t),d=new i;return d.appendPoints(c.points),d.appendPoints(l.points),d.appendPoints(u.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,o,s,a=e.util.array.max([t,i,n]),h=e.util.array.min([t,i,n]);if(s=(a+h)/2,a===h)r=o=0;else{var c=a-h;switch(o=s>.5?c/(2-a-h):c/(a+h),a){case t:r=(i-n)/c+(i<n?6:0);break;case i:r=(n-t)/c+2;break;case n:r=(t-i)/c+4}r/=6}return[Math.round(360*r),Math.round(100*o),Math.round(100*s)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,n=this.getSource();return t=1===(t=n[0].toString(16)).length?"0"+t:t,e=1===(e=n[1].toString(16)).length?"0"+e:e,i=1===(i=n[2].toString(16)).length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t,e=this.getSource();return t=1===(t=(t=Math.round(255*e[3])).toString(16)).length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource(