UNPKG

react-fabricjs

Version:
3 lines 381 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-fabricjs"]=e(require("react")):t["react-fabricjs"]=e(t.React)}(this,function(__WEBPACK_EXTERNAL_MODULE_2__){return function(t){function e(r){if(i[r])return i[r].exports;var n=i[r]={exports:{},id:r,loaded:!1};return t[r].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}(function(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))switch(typeof t[e]){case"function":break;case"object":t[e]=function(e){var i=e.slice(1),r=t[e[0]];return function(t,e,n){r.apply(this,[t,e,n].concat(i))}}(t[e]);break;default:t[e]=t[t[e]]}return t}([function(t,e,i){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e.color=e.imageFilter=e.Itext=e.Text=e.Image=e.Triangle=e.Rect=e.Polyline=e.Polygon=e.PathGroup=e.Path=e.Line=e.Ellipse=e.Circle=e.Canvas=e.StaticCanvas=void 0;var n=i(14),o=r(n),s=i(25),a=r(s),c=i(31),h=r(c),l=i(32),u=r(l),f=i(33),p=r(f),d=i(17),g=r(d),b=i(34),v=r(b),y=i(35),m=r(y),_=i(36),w=r(_),x=i(37),S=r(x),C=i(38),O=r(C),j=i(28),T=r(j),P=i(15),k=r(P),E=i(27),A=r(E),M=i(29),L=r(M),I=i(26),D=r(I);e["default"]={StaticCanvas:o["default"],Canvas:a["default"],Circle:h["default"],Ellipse:u["default"],Line:p["default"],Path:g["default"],PathGroup:v["default"],Polygon:m["default"],Polyline:w["default"],Rect:S["default"],Triangle:O["default"],Image:T["default"],Text:k["default"],Itext:A["default"],imageFilter:L["default"],color:D["default"]};e.StaticCanvas=o["default"],e.Canvas=a["default"],e.Circle=h["default"],e.Ellipse=u["default"],e.Line=p["default"],e.Path=g["default"],e.PathGroup=v["default"],e.Polygon=m["default"],e.Polyline=w["default"],e.Rect=S["default"],e.Triangle=O["default"],e.Image=T["default"],e.Text=k["default"],e.Itext=A["default"],e.imageFilter=L["default"],e.color=D["default"]},function(module,exports,__webpack_require__){(function(Buffer,process){/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ var fabric=fabric||{version:"1.6.0-rc.1"};exports.fabric=fabric,"undefined"!=typeof document&&"undefined"!=typeof window?(fabric.document=document,fabric.window=window,window.fabric=fabric):(fabric.document=__webpack_require__(60).jsdom("<!DOCTYPE html><html><head></head><body></body></html>"),fabric.document.createWindow?fabric.window=fabric.document.createWindow():fabric.window=fabric.document.parentWindow),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode="undefined"!=typeof Buffer&&"undefined"==typeof window,fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id"],fabric.DPI=96,fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)",fabric.devicePixelRatio=fabric.window.devicePixelRatio||fabric.window.webkitDevicePixelRatio||fabric.window.mozDevicePixelRatio||1,function(){function t(t,e){this.__eventListeners[t]&&(e?fabric.util.removeFromArray(this.__eventListeners[t],e):this.__eventListeners[t].length=0)}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){if(0===arguments.length)this.__eventListeners={};else if(1===arguments.length&&"object"==typeof arguments[0])for(var r in e)t.call(this,r,e[r]);else t.call(this,e,i);return this}}function r(t,e){if(this.__eventListeners){var i=this.__eventListeners[t];if(i){for(var r=0,n=i.length;r<n;r++)i[r].call(this,e||{});return this}}}fabric.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}}(),fabric.Collection={add:function(){this._objects.push.apply(this._objects,arguments);for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.renderAll(),this},insertAt:function(t,e,i){var r=this.getObjects();return i?r[e]=t:r.splice(e,0,t),this._onObjectAdded(t),this.renderOnAddRemove&&this.renderAll(),this},remove:function(){for(var t,e=this.getObjects(),i=0,r=arguments.length;i<r;i++)t=e.indexOf(arguments[i]),t!==-1&&(e.splice(t,1),this._onObjectRemoved(arguments[i]));return this.renderOnAddRemove&&this.renderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),r=i.length;r--;)t.call(e,i[r],r,i);return this},getObjects:function(t){return"undefined"==typeof t?this._objects:this._objects.filter(function(e){return e.type===t})},item:function(t){return this.getObjects()[t]},isEmpty:function(){return 0===this.getObjects().length},size:function(){return this.getObjects().length},contains:function(t){return this.getObjects().indexOf(t)>-1},complexity:function(){return this.getObjects().reduce(function(t,e){return t+=e.complexity?e.complexity():0},0)}},function(t){var e=Math.sqrt,i=Math.atan2,r=Math.PI/180;fabric.util={removeFromArray:function(t,e){var i=t.indexOf(e);return i!==-1&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*r},radiansToDegrees:function(t){return t/r},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=Math.sin(i),n=Math.cos(i),o=t.x*n-t.y*r,s=t.x*r+t.y*n;return new fabric.Point(o,s).addEquals(e)},transformPoint:function(t,e,i){return i?new fabric.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new fabric.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},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=fabric.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=fabric.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=fabric.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),fabric.util.resolveNamespace(e)[t]},resolveNamespace:function(e){if(!e)return fabric;for(var i=e.split("."),r=i.length,n=t||fabric.window,o=0;o<r;++o)n=n[i[o]];return n},loadImage:function(t,e,i,r){if(!t)return void(e&&e.call(i,t));var n=fabric.util.createImage();n.onload=function(){e&&e.call(i,n),n=n.onload=n.onerror=null},n.onerror=function(){fabric.log("Error loading "+n.src),e&&e.call(i,null,!0),n=n.onload=n.onerror=null},0!==t.indexOf("data")&&"undefined"!=typeof r&&(n.crossOrigin=r),n.src=t},enlivenObjects:function(t,e,i,r){function n(){++s===a&&e&&e(o)}t=t||[];var o=[],s=0,a=t.length;return a?void t.forEach(function(t,e){if(!t||!t.type)return void n();var s=fabric.util.getKlass(t.type,i);s.async?s.fromObject(t,function(i,s){s||(o[e]=i,r&&r(t,o[e])),n()}):(o[e]=s.fromObject(t),r&&r(t,o[e]),n())}):void(e&&e(o))},groupSVGElements:function(t,e,i){var r;return r=new fabric.PathGroup(t,e),"undefined"!=typeof i&&r.setSourcePath(i),r},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var r=0,n=i.length;r<n;r++)i[r]in t&&(e[i[r]]=t[i[r]])},drawDashedLine:function(t,r,n,o,s,a){var c=o-r,h=s-n,l=e(c*c+h*h),u=i(h,c),f=a.length,p=0,d=!0;for(t.save(),t.translate(r,n),t.moveTo(0,0),t.rotate(u),r=0;l>r;)r+=a[p++%f],r>l&&(r=l),t[d?"lineTo":"moveTo"](r,0),d=!d;t.restore()},createCanvasElement:function(t){return t||(t=fabric.document.createElement("canvas")),t.getContext||"undefined"==typeof G_vmlCanvasManager||G_vmlCanvasManager.initElement(t),t},createImage:function(){return fabric.isLikelyNode?new(__webpack_require__(13).Image):fabric.document.createElement("img")},createAccessors:function(t){for(var e=t.prototype,i=e.stateProperties.length;i--;){var r=e.stateProperties[i],n=r.charAt(0).toUpperCase()+r.slice(1),o="set"+n,s="get"+n;e[s]||(e[s]=function(t){return new Function('return this.get("'+t+'")')}(r)),e[o]||(e[o]=function(t){return new Function("value",'return this.set("'+t+'", value)')}(r))}},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e){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],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,r){r>0&&(e>r?e-=r:e=0,i>r?i-=r:i=0);for(var n=!0,o=t.getImageData(e,i,2*r||1,2*r||1),s=3,a=o.data.length;s<a;s+=4){var c=o.data[s];if(n=c<=0,n===!1)break}return o=null,n}}}(exports),function(){function t(t,r,o,s,c,h,l){var u=a.call(arguments);if(n[u])return n[u];var f=Math.PI,p=l*f/180,d=Math.sin(p),g=Math.cos(p),b=0,v=0;o=Math.abs(o),s=Math.abs(s);var y=-g*t*.5-d*r*.5,m=-g*r*.5+d*t*.5,_=o*o,w=s*s,x=m*m,S=y*y,C=_*w-_*x-w*S,O=0;if(C<0){var j=Math.sqrt(1-C/(_*w));o*=j,s*=j}else O=(c===h?-1:1)*Math.sqrt(C/(_*x+w*S));var T=O*o*m/s,P=-O*s*y/o,k=g*T-d*P+.5*t,E=d*T+g*P+.5*r,A=i(1,0,(y-T)/o,(m-P)/s),M=i((y-T)/o,(m-P)/s,(-y-T)/o,(-m-P)/s);0===h&&M>0?M-=2*f:1===h&&M<0&&(M+=2*f);for(var L=Math.ceil(Math.abs(M/f*2)),I=[],D=M/L,R=8/3*Math.sin(D/4)*Math.sin(D/4)/Math.sin(D/2),B=A+D,F=0;F<L;F++)I[F]=e(A,B,g,d,o,s,k,E,R,b,v),b=I[F][4],v=I[F][5],A=B,B+=D;return n[u]=I,I}function e(t,e,i,r,n,s,c,h,l,u,f){var p=a.call(arguments);if(o[p])return o[p];var d=Math.cos(t),g=Math.sin(t),b=Math.cos(e),v=Math.sin(e),y=i*n*b-r*s*v+c,m=r*n*b+i*s*v+h,_=u+l*(-i*n*g-r*s*d),w=f+l*(-r*n*g+i*s*d),x=y+l*(i*n*v+r*s*b),S=m+l*(r*n*v-i*s*b);return o[p]=[_,w,x,S,y,m],o[p]}function i(t,e,i,r){var n=Math.atan2(e,t),o=Math.atan2(r,i);return o>=n?o-n:2*Math.PI-(n-o)}function r(t,e,i,r,n,o,c,h){var l=a.call(arguments);if(s[l])return s[l];var u,f,p,d,g,b,v,y,m=Math.sqrt,_=Math.min,w=Math.max,x=Math.abs,S=[],C=[[],[]];f=6*t-12*i+6*n,u=-3*t+9*i-9*n+3*c,p=3*i-3*t;for(var O=0;O<2;++O)if(O>0&&(f=6*e-12*r+6*o,u=-3*e+9*r-9*o+3*h,p=3*r-3*e),x(u)<1e-12){if(x(f)<1e-12)continue;d=-p/f,0<d&&d<1&&S.push(d)}else v=f*f-4*p*u,v<0||(y=m(v),g=(-f+y)/(2*u),0<g&&g<1&&S.push(g),b=(-f-y)/(2*u),0<b&&b<1&&S.push(b));for(var j,T,P,k=S.length,E=k;k--;)d=S[k],P=1-d,j=P*P*P*t+3*P*P*d*i+3*P*d*d*n+d*d*d*c,C[0][k]=j,T=P*P*P*e+3*P*P*d*r+3*P*d*d*o+d*d*d*h,C[1][k]=T;C[0][E]=t,C[1][E]=e,C[0][E+1]=c,C[1][E+1]=h;var A=[{x:_.apply(null,C[0]),y:_.apply(null,C[1])},{x:w.apply(null,C[0]),y:w.apply(null,C[1])}];return s[l]=A,A}var n={},o={},s={},a=Array.prototype.join;fabric.util.drawArc=function(e,i,r,n){for(var o=n[0],s=n[1],a=n[2],c=n[3],h=n[4],l=n[5],u=n[6],f=[[],[],[],[]],p=t(l-i,u-r,o,s,c,h,a),d=0,g=p.length;d<g;d++)f[d][0]=p[d][0]+i,f[d][1]=p[d][1]+r,f[d][2]=p[d][2]+i,f[d][3]=p[d][3]+r,f[d][4]=p[d][4]+i,f[d][5]=p[d][5]+r,e.bezierCurveTo.apply(e,f[d])},fabric.util.getBoundsOfArc=function(e,i,n,o,s,a,c,h,l){for(var u=0,f=0,p=[],d=[],g=t(h-e,l-i,n,o,a,c,s),b=[[],[]],v=0,y=g.length;v<y;v++)p=r(u,f,g[v][0],g[v][1],g[v][2],g[v][3],g[v][4],g[v][5]),b[0].x=p[0].x+e,b[0].y=p[0].y+i,b[1].x=p[1].x+e,b[1].y=p[1].y+i,d.push(b[0]),d.push(b[1]),u=g[v][4],f=g[v][5];return d},fabric.util.getBoundsOfCurve=r}(),function(){function t(t,e){for(var i=n.call(arguments,2),r=[],o=0,s=t.length;o<s;o++)r[o]=i.length?t[o][e].apply(t[o],i):t[o][e].call(t[o]);return r}function e(t,e){return r(t,e,function(t,e){return t>=e})}function i(t,e){return r(t,e,function(t,e){return t<e})}function r(t,e,i){if(t&&0!==t.length){var r=t.length-1,n=e?t[r][e]:t[r];if(e)for(;r--;)i(t[r][e],n)&&(n=t[r][e]);else for(;r--;)i(t[r],n)&&(n=t[r]);return n}}var n=Array.prototype.slice;Array.prototype.indexOf||(Array.prototype.indexOf=function(t){if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if(0===i)return-1;var r=0;if(arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:0!==r&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=i)return-1;for(var n=r>=0?r:Math.max(i-Math.abs(r),0);n<i;n++)if(n in e&&e[n]===t)return n;return-1}),Array.prototype.forEach||(Array.prototype.forEach=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)i in this&&t.call(e,this[i],i,this)}),Array.prototype.map||(Array.prototype.map=function(t,e){for(var i=[],r=0,n=this.length>>>0;r<n;r++)r in this&&(i[r]=t.call(e,this[r],r,this));return i}),Array.prototype.every||(Array.prototype.every=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&!t.call(e,this[i],i,this))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++)if(i in this&&t.call(e,this[i],i,this))return!0;return!1}),Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var i,r=[],n=0,o=this.length>>>0;n<o;n++)n in this&&(i=this[n],t.call(e,i,n,this)&&r.push(i));return r}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var e,i=this.length>>>0,r=0;if(arguments.length>1)e=arguments[1];else for(;;){if(r in this){e=this[r++];break}if(++r>=i)throw new TypeError}for(;r<i;r++)r in this&&(e=t.call(null,e,this[r],r,this));return e}),fabric.util.array={invoke:t,min:i,max:e}}(),function(){function t(t,e){for(var i in e)t[i]=e[i];return t}function e(e){return t({},e)}fabric.util.object={extend:t,clone:e}}(),function(){function t(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})}function e(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())}function i(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:t,capitalize:e,escapeXml:i}}(),function(){var t=Array.prototype.slice,e=Function.prototype.apply,i=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var n,o=this,s=t.call(arguments,1);return n=s.length?function(){return e.call(o,this instanceof i?this:r,s.concat(t.call(arguments)))}:function(){return e.call(o,this instanceof i?this:r,arguments)},i.prototype=this.prototype,n.prototype=new i,n})}(),function(){function t(){}function e(t){var e=this.constructor.superclass.prototype[t];return arguments.length>1?e.apply(this,r.call(arguments,1)):e.call(this)}function i(){function i(){this.initialize.apply(this,arguments)}var o=null,a=r.call(arguments,0);"function"==typeof a[0]&&(o=a.shift()),i.superclass=o,i.subclasses=[],o&&(t.prototype=o.prototype,i.prototype=new t,o.subclasses.push(i));for(var c=0,h=a.length;c<h;c++)s(i,a[c],o);return i.prototype.initialize||(i.prototype.initialize=n),i.prototype.constructor=i,i.prototype.callSuper=e,i}var r=Array.prototype.slice,n=function(){},o=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),s=function(t,e,i){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 r=this.constructor.superclass;this.constructor.superclass=i;var n=e[t].apply(this,arguments);if(this.constructor.superclass=r,"initialize"!==t)return n}}(r):t.prototype[r]=e[r],o&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};fabric.util.createClass=i}(),function(){function t(t){var e,i,r=Array.prototype.slice.call(arguments,1),n=r.length;for(i=0;i<n;i++)if(e=typeof t[r[i]],!/^(?:function|object|unknown)$/.test(e))return!1;return!0}function e(t,e){return{handler:e,wrappedHandler:i(t,e)}}function i(t,e){return function(i){e.call(s(t),i||fabric.window.event)}}function r(t,e){return function(i){if(g[t]&&g[t][e])for(var r=g[t][e],n=0,o=r.length;n<o;n++)r[n].call(this,i||fabric.window.event)}}function n(t){t||(t=fabric.window.event);var e=t.target||(typeof t.srcElement!==c?t.srcElement:null),i=fabric.util.getScrollLeftTop(e);return{x:b(t)+i.left,y:v(t)+i.top}}function o(t,e,i){var r="touchend"===t.type?"changedTouches":"touches";return t[r]&&t[r][0]?t[r][0][e]-(t[r][0][e]-t[r][0][i])||t[i]:t[i]}var s,a,c="unknown",h=function(){var t=0;return function(e){return e.__uniqueID||(e.__uniqueID="uniqueID__"+t++)}}();!function(){var t={};s=function(e){return t[e]},a=function(e,i){t[e]=i}}();var l,u,f=t(fabric.document.documentElement,"addEventListener","removeEventListener")&&t(fabric.window,"addEventListener","removeEventListener"),p=t(fabric.document.documentElement,"attachEvent","detachEvent")&&t(fabric.window,"attachEvent","detachEvent"),d={},g={};f?(l=function(t,e,i){t.addEventListener(e,i,!1)},u=function(t,e,i){t.removeEventListener(e,i,!1)}):p?(l=function(t,i,r){var n=h(t);a(n,t),d[n]||(d[n]={}),d[n][i]||(d[n][i]=[]);var o=e(n,r);d[n][i].push(o),t.attachEvent("on"+i,o.wrappedHandler)},u=function(t,e,i){var r,n=h(t);if(d[n]&&d[n][e])for(var o=0,s=d[n][e].length;o<s;o++)r=d[n][e][o],r&&r.handler===i&&(t.detachEvent("on"+e,r.wrappedHandler),d[n][e][o]=null)}):(l=function(t,e,i){var n=h(t);if(g[n]||(g[n]={}),!g[n][e]){g[n][e]=[];var o=t["on"+e];o&&g[n][e].push(o),t["on"+e]=r(n,e)}g[n][e].push(i)},u=function(t,e,i){var r=h(t);if(g[r]&&g[r][e])for(var n=g[r][e],o=0,s=n.length;o<s;o++)n[o]===i&&n.splice(o,1)}),fabric.util.addListener=l,fabric.util.removeListener=u;var b=function(t){return typeof t.clientX!==c?t.clientX:0},v=function(t){return typeof t.clientY!==c?t.clientY:0};fabric.isTouchSupported&&(b=function(t){return o(t,"pageX","clientX")},v=function(t){return o(t,"pageY","clientY")}),fabric.util.getPointer=n,fabric.util.object.extend(fabric.util,fabric.Observable)}(),function(){function t(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 r in e)if("opacity"===r)o(t,e[r]);else{var n="float"===r||"cssFloat"===r?"undefined"==typeof i.styleFloat?"cssFloat":"styleFloat":r;i[n]=e[r]}return t}var e=fabric.document.createElement("div"),i="string"==typeof e.style.opacity,r="string"==typeof e.style.filter,n=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,o=function(t){return t};i?o=function(t,e){return t.style.opacity=e,t}:r&&(o=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),n.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(n,e)):i.filter+=" alpha(opacity="+100*e+")",t}),fabric.util.setStyle=t}(),function(){function t(t){return"string"==typeof t?fabric.document.getElementById(t):t}function e(t,e){var i=fabric.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 i(t,e){t&&(" "+t.className+" ").indexOf(" "+e+" ")===-1&&(t.className+=(t.className?" ":"")+e)}function r(t,i,r){return"string"==typeof i&&(i=e(i,r)),t.parentNode&&t.parentNode.replaceChild(i,t),i.appendChild(t),i}function n(t){for(var e=0,i=0,r=fabric.document.documentElement,n=fabric.document.body||{scrollLeft:0,scrollTop:0};t&&t.parentNode&&(t=t.parentNode,t===fabric.document?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==fabric.util.getElementStyle(t,"position")););return{left:e,top:i}}function o(t){var e,i,r=t&&t.ownerDocument,o={left:0,top:0},s={left:0,top:0},a={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return s;for(var c in a)s[a[c]]+=parseInt(l(t,c),10)||0;return e=r.documentElement,"undefined"!=typeof t.getBoundingClientRect&&(o=t.getBoundingClientRect()),i=n(t),{left:o.left+i.left-(e.clientLeft||0)+s.left,top:o.top+i.top-(e.clientTop||0)+s.top}}var s,a=Array.prototype.slice,c=function(t){return a.call(t,0)};try{s=c(fabric.document.childNodes)instanceof Array}catch(h){}s||(c=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e});var l;l=fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?function(t,e){var i=fabric.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(){function t(t){return"undefined"!=typeof t.onselectstart&&(t.onselectstart=fabric.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t}function e(t){return"undefined"!=typeof t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t}var i=fabric.document.documentElement.style,r="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=t,fabric.util.makeElementSelectable=e}(),function(){function t(t,e){var i=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),n=!0;r.onload=r.onreadystatechange=function(t){if(n){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;n=!1,e(t||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=t,i.appendChild(r)}fabric.util.getScript=t}(),fabric.util.getById=t,fabric.util.toArray=c,fabric.util.makeElement=e,fabric.util.addClass=i,fabric.util.wrapElement=r,fabric.util.getScrollLeftTop=n,fabric.util.getElementOffset=o,fabric.util.getElementStyle=l}(),function(){function t(t,e){return t+(/\?/.test(t)?"&":"?")+e}function e(){}function i(i,n){n||(n={});var o,s=n.method?n.method.toUpperCase():"GET",a=n.onComplete||function(){},c=r();return c.onreadystatechange=function(){4===c.readyState&&(a(c),c.onreadystatechange=e)},"GET"===s&&(o=null,"string"==typeof n.parameters&&(i=t(i,n.parameters))),c.open(s,i,!0),"POST"!==s&&"PUT"!==s||c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.send(o),c}var r=function(){for(var t=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],e=t.length;e--;)try{var i=t[e]();if(i)return t[e]}catch(r){}}();fabric.util.request=i}(),fabric.log=function(){},fabric.warn=function(){},"undefined"!=typeof console&&["log","warn"].forEach(function(t){"undefined"!=typeof console[t]&&"function"==typeof console[t].apply&&(fabric[t]=function(){return console[t].apply(console,arguments)})}),function(){function t(t){e(function(i){t||(t={});var r,n=i||+new Date,o=t.duration||500,s=n+o,a=t.onChange||function(){},c=t.abort||function(){return!1},h=t.easing||function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},l="startValue"in t?t.startValue:0,u="endValue"in t?t.endValue:100,f=t.byValue||u-l;t.onStart&&t.onStart(),function p(i){r=i||+new Date;var u=r>s?o:r-n;return c()?void(t.onComplete&&t.onComplete()):(a(h(u,l,f,o)),r>s?void(t.onComplete&&t.onComplete()):void e(p))}(n)})}function e(){return i.apply(fabric.window,arguments)}var i=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(t){fabric.window.setTimeout(t,1e3/60)};fabric.util.animate=t,fabric.util.requestAnimFrame=e}(),function(){function t(t,e,i,r){return t<Math.abs(e)?(t=e,r=i/4):r=i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:r}}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,r){return i*((t=t/r-1)*t*t+1)+e}function r(t,e,i,r){return t/=r/2,t<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}function n(t,e,i,r){return i*(t/=r)*t*t*t+e}function o(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e}function s(t,e,i,r){return t/=r/2,t<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}function a(t,e,i,r){return i*(t/=r)*t*t*t*t+e}function c(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e}function h(t,e,i,r){return t/=r/2,t<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}function l(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}function u(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e}function f(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e}function p(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e}function d(t,e,i,r){return t===r?e+i:i*(-Math.pow(2,-10*t/r)+1)+e}function g(t,e,i,r){return 0===t?e:t===r?e+i:(t/=r/2,t<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e)}function b(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e}function v(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e}function y(t,e,i,r){return t/=r/2,t<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}function m(i,r,n,o){var s=1.70158,a=0,c=n;if(0===i)return r;if(i/=o,1===i)return r+n;a||(a=.3*o);var h=t(c,n,a,s);return-e(h,i,o)+r}function _(e,i,r,n){var o=1.70158,s=0,a=r;if(0===e)return i;if(e/=n,1===e)return i+r;s||(s=.3*n);var c=t(a,r,s,o);return c.a*Math.pow(2,-10*e)*Math.sin((e*n-c.s)*(2*Math.PI)/c.p)+c.c+i}function w(i,r,n,o){var s=1.70158,a=0,c=n;if(0===i)return r;if(i/=o/2,2===i)return r+n;a||(a=o*(.3*1.5));var h=t(c,n,a,s);return i<1?-.5*e(h,i,o)+r:h.a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-h.s)*(2*Math.PI)/h.p)*.5+h.c+r}function x(t,e,i,r,n){return void 0===n&&(n=1.70158),i*(t/=r)*t*((n+1)*t-n)+e}function S(t,e,i,r,n){return void 0===n&&(n=1.70158),i*((t=t/r-1)*t*((n+1)*t+n)+1)+e}function C(t,e,i,r,n){return void 0===n&&(n=1.70158),t/=r/2,t<1?i/2*(t*t*(((n*=1.525)+1)*t-n))+e:i/2*((t-=2)*t*(((n*=1.525)+1)*t+n)+2)+e}function O(t,e,i,r){return i-j(r-t,0,i,r)+e}function j(t,e,i,r){return(t/=r)<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}function T(t,e,i,r){return t<r/2?.5*O(2*t,0,i,r)+e:.5*j(2*t-r,0,i,r)+.5*i+e}fabric.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return t/=r/2,t<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:i,easeInOutCubic:r,easeInQuart:n,easeOutQuart:o,easeInOutQuart:s,easeInQuint:a,easeOutQuint:c,easeInOutQuint:h,easeInSine:l,easeOutSine:u,easeInOutSine:f,easeInExpo:p,easeOutExpo:d,easeInOutExpo:g,easeInCirc:b,easeOutCirc:v,easeInOutCirc:y,easeInElastic:m,easeOutElastic:_,easeInOutElastic:w,easeInBack:x,easeOutBack:S,easeInOutBack:C,easeInBounce:O,easeOutBounce:j,easeInOutBounce:T}}(),function(t){"use strict";function e(t){return t in j?j[t]:t}function i(t,e,i,r){var n,o="[object Array]"===Object.prototype.toString.call(e);return"fill"!==t&&"stroke"!==t||"none"!==e?"strokeDashArray"===t?e=e.replace(/,/g," ").split(/\s+/).map(function(t){return parseFloat(t)}):"transformMatrix"===t?e=i&&i.transformMatrix?w(i.transformMatrix,g.parseTransformAttribute(e)):g.parseTransformAttribute(e):"visible"===t?(e="none"!==e&&"hidden"!==e,i&&i.visible===!1&&(e=!1)):"originX"===t?e="start"===e?"left":"end"===e?"right":"center":n=o?e.map(_):_(e,r):e="",!o&&isNaN(n)?e:n}function r(t){for(var e in T)if(t[e]&&"undefined"!=typeof t[T[e]]&&0!==t[e].indexOf("url(")){var i=new g.Color(t[e]);t[e]=i.setAlpha(m(i.getAlpha()*t[T[e]],2)).toRgba()}return t}function n(t,r){var n,o;t.replace(/;\s*$/,"").split(";").forEach(function(t){var s=t.split(":");n=e(s[0].trim().toLowerCase()),o=i(n,s[1].trim()),r[n]=o})}function o(t,r){var n,o;for(var s in t)"undefined"!=typeof t[s]&&(n=e(s.toLowerCase()),o=i(n,t[s]),r[n]=o)}function s(t,e){var i={};for(var r in g.cssRules[e])if(a(t,r.split(" ")))for(var n in g.cssRules[e][r])i[n]=g.cssRules[e][r][n];return i}function a(t,e){var i,r=!0;return i=h(t,e.pop()),i&&e.length&&(r=c(t,e)),i&&r&&0===e.length}function c(t,e){for(var i,r=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)r&&(i=e.pop()),t=t.parentNode,r=h(t,i);return 0===e.length}function h(t,e){var i,r=t.nodeName,n=t.getAttribute("class"),o=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),o&&e.length&&(i=new RegExp("#"+o+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),n&&e.length){n=n.split(" ");for(var s=n.length;s--;)i=new RegExp("\\."+n[s]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")}return 0===e.length}function l(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var r,n,o,s=t.getElementsByTagName("*");for(n=0;n<s.length;n++)if(r=s[n],o===r.getAttribute("id"))return r}function u(t){for(var e=t.getElementsByTagName("use"),i=0;e.length&&i<e.length;){var r,n,o,s,a,c=e[i],h=c.getAttribute("xlink:href").substr(1),u=c.getAttribute("x")||0,p=c.getAttribute("y")||0,d=l(t,h).cloneNode(!0),g=(d.getAttribute("transform")||"")+" translate("+u+", "+p+")",b=e.length;if(f(d),/^svg$/i.test(d.nodeName)){var v=d.ownerDocument.createElement("g");for(o=0,s=d.attributes,a=s.length;o<a;o++)n=s.item(o),v.setAttribute(n.nodeName,n.nodeValue);for(;null!=d.firstChild;)v.appendChild(d.firstChild);d=v}for(o=0,s=c.attributes,a=s.length;o<a;o++)n=s.item(o),"x"!==n.nodeName&&"y"!==n.nodeName&&"xlink:href"!==n.nodeName&&("transform"===n.nodeName?g=n.nodeValue+" "+g:d.setAttribute(n.nodeName,n.nodeValue));d.setAttribute("transform",g),d.setAttribute("instantiated_by_use","1"),d.removeAttribute("id"),r=c.parentNode,r.replaceChild(d,c),e.length===b&&i++}}function f(t){var e,i,r,n,o=t.getAttribute("viewBox"),s=1,a=1,c=0,h=0,l=t.getAttribute("width"),u=t.getAttribute("height"),f=!o||!S.test(t.tagName)||!(o=o.match(P)),p=!l||!u||"100%"===l||"100%"===u,d=f&&p,g={};if(g.width=0,g.height=0,g.toBeParsed=d,d)return g;if(f)return g.width=_(l),g.height=_(u),g;if(c=-parseFloat(o[1]),h=-parseFloat(o[2]),e=parseFloat(o[3]),i=parseFloat(o[4]),p?(g.width=e,g.height=i):(g.width=_(l),g.height=_(u),s=g.width/e,a=g.height/i),a=s=s>a?a:s,1===s&&1===a&&0===c&&0===h)return g;if(r=" matrix("+s+" 0 0 "+a+" "+c*s+" "+h*a+") ","svg"===t.tagName){for(n=t.ownerDocument.createElement("g");null!=t.firstChild;)n.appendChild(t.firstChild);t.appendChild(n)}else n=t,r=n.getAttribute("transform")+r;return n.setAttribute("transform",r),g}function p(t){var e=t.objects,i=t.options;return e=e.map(function(t){return g[v(t.type)].fromObject(t)}),{objects:e,options:i}}function d(t,e,i){e[i]&&e[i].toSVG&&t.push('<pattern x="0" y="0" id="',i,'Pattern" ','width="',e[i].source.width,'" height="',e[i].source.height,'" patternUnits="userSpaceOnUse">','<image x="0" y="0" ','width="',e[i].source.width,'" height="',e[i].source.height,'" xlink:href="',e[i].source.src,'"></image></pattern>')}var g=t.fabric||(t.fabric={}),b=g.util.object.extend,v=g.util.string.capitalize,y=g.util.object.clone,m=g.util.toFixed,_=g.util.parseUnit,w=g.util.multiplyTransformMatrices,x=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/i,S=/^(symbol|image|marker|pattern|view|svg)$/i,C=/^(?:pattern|defs|symbol|metadata)$/i,O=/^(symbol|g|a|svg)$/i,j={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","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"originX"},T={stroke:"strokeOpacity",fill:"fillOpacity"};g.cssRules={},g.gradientDefs={},g.parseTransformAttribute=function(){function t(t,e){var i=e[0];t[0]=Math.cos(i),t[1]=Math.sin(i),t[2]=-Math.sin(i),t[3]=Math.cos(i)}function e(t,e){var i=e[0],r=2===e.length?e[1]:e[0];t[0]=i,t[3]=r}function i(t,e){t[2]=Math.tan(g.util.degreesToRadians(e[0]))}function r(t,e){t[1]=Math.tan(g.util.degreesToRadians(e[0]))}function n(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}var o=[1,0,0,1,0,0],s=g.reNum,a="(?:\\s+,?\\s*|,\\s*)",c="(?:(skewX)\\s*\\(\\s*("+s+")\\s*\\))",h="(?:(skewY)\\s*\\(\\s*("+s+")\\s*\\))",l="(?:(rotate)\\s*\\(\\s*("+s+")(?:"+a+"("+s+")"+a+"("+s+"))?\\s*\\))",u="(?:(scale)\\s*\\(\\s*("+s+")(?:"+a+"("+s+"))?\\s*\\))",f="(?:(translate)\\s*\\(\\s*("+s+")(?:"+a+"("+s+"))?\\s*\\))",p="(?:(matrix)\\s*\\(\\s*("+s+")"+a+"("+s+")"+a+"("+s+")"+a+"("+s+")"+a+"("+s+")"+a+"("+s+")\\s*\\))",d="(?:"+p+"|"+f+"|"+u+"|"+l+"|"+c+"|"+h+")",b="(?:"+d+"(?:"+a+d+")*)",v="^\\s*(?:"+b+"?)\\s*$",y=new RegExp(v),m=new RegExp(d,"g");return function(s){var a=o.concat(),c=[];if(!s||s&&!y.test(s))return a;s.replace(m,function(s){var h=new RegExp(d).exec(s).filter(function(t){return""!==t&&null!=t}),l=h[1],u=h.slice(2).map(parseFloat);switch(l){case"translate":n(a,u);break;case"rotate":u[0]=g.util.degreesToRadians(u[0]),t(a,u);break;case"scale":e(a,u);break;case"skewX":i(a,u);break;case"skewY":r(a,u);break;case"matrix":a=u}c.push(a.concat()),a=o.concat()});for(var h=c[0];c.length>1;)c.shift(),h=g.util.multiplyTransformMatrices(h,c[0]);return h}}();var P=new RegExp("^\\s*("+g.reNum+"+)\\s*,?\\s*("+g.reNum+"+)\\s*,?\\s*("+g.reNum+"+)\\s*,?\\s*("+g.reNum+"+)\\s*$");g.parseSVGDocument=function(){function t(t,e){for(;t&&(t=t.parentNode);)if(e.test(t.nodeName)&&!t.getAttribute("instantiated_by_use"))return!0;return!1}return function(e,i,r){if(e){u(e);var n=new Date,o=g.Object.__uid++,s=f(e),a=g.util.toArray(e.getElementsByTagName("*"));if(s.svgUid=o,0===a.length&&g.isLikelyNode){a=e.selectNodes('//*[name(.)!="svg"]');for(var c=[],h=0,l=a.length;h<l;h++)c[h]=a[h];a=c}var p=a.filter(function(e){return f(e),x.test(e.tagName)&&!t(e,C)});if(!p||p&&!p.length)return void(i&&i([],{}));g.gradientDefs[o]=g.getGradientDefs(e),g.cssRules[o]=g.getCSSRules(e),g.parseElements(p,function(t){g.documentParsingTime=new Date-n,i&&i(t,s)},y(s),r)}}}();var k={has:function(t,e){e(!1)},get:function(){},set:function(){}},E=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+g.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+g.reNum+"))?\\s+(.*)");b(g,{parseFontDeclaration:function(t,e){var i=t.match(E);if(i){var r=i[1],n=i[3],o=i[4],s=i[5],a=i[6]; r&&(e.fontStyle=r),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),o&&(e.fontSize=_(o)),a&&(e.fontFamily=a),s&&(e.lineHeight="normal"===s?1:s)}},getGradientDefs:function(t){var e,i,r,n,o=t.getElementsByTagName("linearGradient"),s=t.getElementsByTagName("radialGradient"),a=0,c=[],h={},l={};for(c.length=o.length+s.length,i=o.length;i--;)c[a++]=o[i];for(i=s.length;i--;)c[a++]=s[i];for(;a--;)e=c[a],n=e.getAttribute("xlink:href"),r=e.getAttribute("id"),n&&(l[r]=n.substr(1)),h[r]=e;for(r in l){var u=h[l[r]].cloneNode(!0);for(e=h[r];u.firstChild;)e.appendChild(u.firstChild)}return h},parseAttributes:function(t,n,o){if(t){var a,c,h={};"undefined"==typeof o&&(o=t.getAttribute("svgUid")),t.parentNode&&O.test(t.parentNode.nodeName)&&(h=g.parseAttributes(t.parentNode,n,o)),c=h&&h.fontSize||t.getAttribute("font-size")||g.Text.DEFAULT_SVG_FONT_SIZE;var l=n.reduce(function(r,n){return a=t.getAttribute(n),a&&(n=e(n),a=i(n,a,h,c),r[n]=a),r},{});return l=b(l,b(s(t,o),g.parseStyleAttribute(t))),l.font&&g.parseFontDeclaration(l.font,l),r(b(h,l))}},parseElements:function(t,e,i,r){new g.ElementsParser(t,e,i,r).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?n(i,e):o(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;t=t.replace(/,/g," ").trim(),t=t.split(/\s+/);var e,i,r=[];for(e=0,i=t.length;e<i;e+=2)r.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return r},getCSSRules:function(t){for(var r,n=t.getElementsByTagName("style"),o={},s=0,a=n.length;s<a;s++){var c=n[s].textContent;c=c.replace(/\/\*[\s\S]*?\*\//g,""),""!==c.trim()&&(r=c.match(/[^{]*\{[\s\S]*?\}/g),r=r.map(function(t){return t.trim()}),r.forEach(function(t){for(var r=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),n={},s=r[2].trim(),a=s.replace(/;$/,"").split(/\s*;\s*/),c=0,h=a.length;c<h;c++){var l=a[c].split(/\s*:\s*/),u=e(l[0]),f=i(u,l[1],l[0]);n[u]=f}t=r[1],t.split(",").forEach(function(t){t=t.replace(/^svg/i,"").trim(),""!==t&&(o[t]=g.util.object.clone(n))})}))}return o},loadSVGFromURL:function(t,e,i){function r(r){var n=r.responseXML;n&&!n.documentElement&&g.window.ActiveXObject&&r.responseText&&(n=new ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(r.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))),n&&n.documentElement&&g.parseSVGDocument(n.documentElement,function(i,r){k.set(t,{objects:g.util.array.invoke(i,"toObject"),options:r}),e(i,r)},i)}t=t.replace(/^\n\s*/,"").trim(),k.has(t,function(i){i?k.get(t,function(t){var i=p(t);e(i.objects,i.options)}):new g.util.request(t,{method:"get",onComplete:r})})},loadSVGFromString:function(t,e,i){t=t.trim();var r;if("undefined"!=typeof DOMParser){var n=new DOMParser;n&&n.parseFromString&&(r=n.parseFromString(t,"text/xml"))}else g.window.ActiveXObject&&(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));g.parseSVGDocument(r.documentElement,function(t,i){e(t,i)},i)},createSVGFontFacesMarkup:function(t){for(var e="",i=0,r=t.length;i<r;i++)"text"===t[i].type&&t[i].path&&(e+=["@font-face {","font-family: ",t[i].fontFamily,"; ","src: url('",t[i].path,"')","}"].join(""));return e&&(e=['<style type="text/css">',"<![CDATA[",e,"]]>","</style>"].join("")),e},createSVGRefElementsMarkup:function(t){var e=[];return d(e,t,"backgroundColor"),d(e,t,"overlayColor"),e.join("")}})}(exports),fabric.ElementsParser=function(t,e,i,r){this.elements=t,this.callback=e,this.options=i,this.reviver=r,this.svgUid=i&&i.svgUid||0},fabric.ElementsParser.prototype.parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},fabric.ElementsParser.prototype.createObjects=function(){for(var t=0,e=this.elements.length;t<e;t++)this.elements[t].setAttribute("svgUid",this.svgUid),function(t,e){setTimeout(function(){t.createObject(t.elements[e],e)},0)}(this,t)},fabric.ElementsParser.prototype.createObject=function(t,e){var i=fabric[fabric.util.string.capitalize(t.tagName)];if(i&&i.fromElement)try{this._createObject(i,t,e)}catch(r){fabric.log(r)}else this.checkIfDone()},fabric.ElementsParser.prototype._createObject=function(t,e,i){if(t.async)t.fromElement(e,this.createCallback(i,e),this.options);else{var r=t.fromElement(e,this.options);this.resolveGradient(r,"fill"),this.resolveGradient(r,"stroke"),this.reviver&&this.reviver(e,r),this.instances[i]=r,this.checkIfDone()}},fabric.ElementsParser.prototype.createCallback=function(t,e){var i=this;return function(r){i.resolveGradient(r,"fill"),i.resolveGradient(r,"stroke"),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},fabric.ElementsParser.prototype.resolveGradient=function(t,e){var i=t.get(e);if(/^url\(/.test(i)){var r=i.slice(5,i.length-1);fabric.gradientDefs[this.svgUid][r]&&t.set(e,fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],t))}},fabric.ElementsParser.prototype.checkIfDone=function(){0===--this.numElements&&(this.instances=this.instances.filter(function(t){return null!=t}),this.callback(this.instances))},function(t){"use strict";function e(t,e){this.x=t,this.y=e}var i=t.fabric||(t.fabric={});return i.Point?void i.warn("fabric.Point is already defined"):(i.Point=e,void(e.prototype={constructor:e,add:function(t){return new e(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 e(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new e(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 e(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new e(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new e(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,i){return new e(this.x+(t.x-this.x)*i,this.y+(t.y-this.y)*i)},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 new e(this.x+(t.x-this.x)/2,this.y+(t.y-this.y)/2)},min:function(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){this.x=t,this.y=e},setFromPoint:function(t){this.x=t.x,this.y=t.y},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}}))}(exports),function(t){"use strict";function e(t){this.status=t,this.points=[]}var i=t.fabric||(t.fabric={});return i.Intersection?void i.warn("fabric.Intersection is already defined"):(i.Intersection=e,i.Intersection.prototype={appendPoint:function(t){this.points.push(t)},appendPoints:function(t){this.points=this.points.concat(t)}},i.Intersection.intersectLineLine=function(t,r,n,o){var s,a=(o.x-n.x)*(t.y-n.y)-(o.y-n.y)*(t.x-n.x),c=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),h=(o.y-n.y)*(r.x-t.x)-(o.x-n.x)*(r.y-t.y);if(0!==h){var l=a/h,u=c/h;0<=l&&l<=1&&0<=u&&u<=1?(s=new e("Intersection"),s.points.push(new i.Point(t.x+l*(r.x-t.x),t.y+l*(r.y-t.y)))):s=new e}else s=new e(0===a||0===c?"Coincident":"Parallel");return s},i.Intersection.intersectLinePolygon=function(t,i,r){for(var n=new e,o=r.length,s=0;s<o;s++){var a=r[s],c=r[(s+1)%o],h=e.intersectLineLine(t,i,a,c);n.appendPoints(h.points)}return n.points.length>0&&(n.status="Intersection"),n},i.Intersection.intersectPolygonPolygon=function(t,i){for(var r=new e,n=t.length,o=0;o<n;o++){var s=t[o],a=t[(o+1)%n],c=e.intersectLinePolygon(s,a,i);r.appendPoints(c.points)}return r.points.length>0&&(r.status="Intersection"),r},void(i.Intersection.intersectPolygonRectangle=function(t,r,n){var o=r.min(n),s=r.max(n),a=new i.Point(s.x,o.y),c=new i.Point(o.x,s.y),h=e.intersectLinePolygon(o,a,t),l=e.intersectLinePolygon(a,s,t),u=e.intersectLinePolygon(s,c,t),f=e.intersectLinePolygon(c,o,t),p=new e;return p.appendPoints(h.points),p.appendPoints(l.points),p.appendPoints(u.points),p.appendPoints(f.points),p.points.length>0&&(p.status="Intersection"),p}))}(exports),function(t){"use strict";function e(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function i(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}var r=t.fabric||(t.fabric={});return r.Color?void r.warn("fabric.Color is already defined."):(r.Color=e,r.Color.prototype={_tryParsingColor:function(t){var i;return t in e.colorNameMap&&(t=e.colorNameMap[t]),"transparent"===t?void this.setSource([255,255,255,0]):(i=e.sourceFromHex(t),i||(i=e.sourceFromRgb(t)),i||(i=e.sourceFromHsl(t)),void(i&&this.setSource(i)))},_rgbToHsl:function(t,e,i){t/=255,e/=255,i/=255;var n,o,s,a=r.util.array.max([t,e,i]),c=r.util.array.min([t,e,i]);if(s=(a+c)/2,a===c)n=o=0;else{var h=a-c;switch(o=s>.5?h/(2-a-c):h/(a+c),a){case t:n=(e-i)/h+(e<i?6:0);break;case e:n=(i-t)/h+2;break;case i:n=(t-e)/h+4}n/=6}return[Math.round(360*n),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,r=this.getSource();return t=r[0].toString(16),t=1===t.length?"0"+t:t,e=r[1].toString(16),e=1===e.length?"0"+e:e,i=r[2].toString(16),i=1===i.length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.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([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),r=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,r]),this},overlayWith:function(t){t instanceof e||(t=new e(t));for(var i=[],r=this.getAlpha(),n=.5,o=this.getSource(),s=t.getSource(),a=0;a<3;a++)i.push(Math.round(o[a]*(1-n)+s[a]*n));return i[3]=r,this.setSource(i),this}},r.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,r.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/,r.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i,r.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"},r.Color.fromRgb=function(t){return e.fromSource(e.sourceFromRgb(t))},r.Color.sourceFromRgb=function(t){var i=t.match(e.reRGBa);if(i){var r=parseInt(i[1],10)/(/%$/.test(i[1])?100:1)*(/%$/.test(i[1])?255:1),n=parseInt(i[2],10)/(/%$/.test(i[2])?100:1)*(/%$/.test(i[2])?255:1),o=parseInt(i[3],10)/(/%$/.test(i[3])?100:1)*(/%$/.test(i[3])?255:1);return[parseInt(r,10),parseInt(n,10),parseInt(o,10),i[4]?parseFloat(i[4]):1]}},r.Color.fromRgba=e.fromRgb,r.Color.fromHsl=function(t){return e.fromSource(e.sourceFromHsl(t))},r.Color.sourceFromHsl=function(t){var r=t.match(e.reHSLa);if(r){var n,o,s,a=(parseFloat(r[1])%360+360)%360/360,c=parseFloat(r[2])/(/%$/.test(r[2])?100:1),h=parseFloat(r[3])/(/%$/.test(r[3])?100:1);if(0===c)n=o=s=h;else{var l=h<=.5?h*(c+1):h+c-h*c,u=2*h-l;n=i(u,l,a+1/3),o=i(u,l,a),s=i(u,l,a-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*s),r[4]?parseFloat(r[4]):1]}},r.Color.fromHsla=e.fromHsl,r.Color.fromHex=function(t){return e.fromSource(e.sourceFromHex(t))},r.Color.sourceFromHex=function(t){if(t.match(e.reHex)){var i=t.slice(t.indexOf("#")+1),r=3===i.length,n=r?i.charAt(0)+i.charAt(0):i.substring(0,2),o=r?i.charAt(1)+i.charAt(1):i.substring(2,4),s=r?i.charAt(2)+i.charAt(2):i.substring(4,6);return[parseInt(n,16),parseInt(o,16),parseInt(s,16),1]}},void(r.Color.fromSource=function(t){var i=new e;return i.setSource(t),i}))}(exports),function(){function t(t){var e,i,r,n=t.getAttribute("style"),o=t.getAttribute("offset");if(o=parseFloat(o)/(/%$/.test(o)?100:1),o=o<0?0:o>1?1:o,n){var s=n.split(/\s*;\s*/);""===s[s.length-1]&&s.pop();for(var a=s.length;a--;){var c=s[a].split(/\s*:\s*/),h=c[0].trim(),l=c[1].trim();"stop-color"===h?e=l:"stop-opacity"===h&&(r=l)}}return e||(e=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),e=new fabric.Color(e),i=e.getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=i,{offset:o,color:e.toRgb(),opacity:r}}function e(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}function i(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}function r(t,e,i){var r,n=0,o=1,s="";for(var a in e)r=parseFloat(e[a],10),o="string"==typeof e[a]&&/^\d+%$/.test(e[a])?.01:1,"x1"===a||"x2"===a||"r2"===a?(o*="objectBoundingBox"===i?t.width:1,n="objectBoundingBox"===i?t.left||0:0):"y1"!==a&&"y2"!==a||(o*="objectBoundingBox"===i?t.height:1,n="objectBoundingBox"===i?t.top||0:0),e[a]=r*o+n;if("ellipse"===t.type&&null!==e.r2&&"objectBoundingBox"===i&&t.rx!==t.ry){var c=t.ry/t.rx;s=" scale(1, "+c+")",e.y1&&(e.y1/=c),e.y2&&(e.y2/=c)}return s}fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,initialize:function(t){t||(t={});var e={};this.id=fabric.Object.__uid++,this.type=t.type||"linear",e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice(),t.gradientTransform&&(this.gradientTransform=t.gradientTransform),this.offsetX=t.offsetX||this.offsetX,this.offsetY=t.offsetY||this.offsetY},addColorStop:function(t){for(var e in t){var i=new fabric.Color(t[e]);this.colorStops.push({offset:e,color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(){return{type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(t){var e,i,r=fabric.util.object.clone(this.coords);if(this.colorStops.sort(function(t,e){return t.offset-e.offset}),!t.group||"path-group"!==t.group.type)for(var n in r)"x1"===n||"x2"===n||"r2"===n?r[n]+=this.offsetX-t.width/2:"y1"!==n&&"y2"!==n||(r[n]+=this.offsetY-t.height/2);i='id="SVGID_'+this.id+'" gradientUnits="userSpaceOnUse"',this.gradientTransform&&(i+=' gradientTransform="matrix('+this.gradientTransform.join(" ")+')" '),"linear"===this.type?e=["<linearGradient ",i,' x1="',r.x1,'" y1="',r.y1,'" x2="',r.x2,'" y2="',r.y2,'">\n']:"radial"===this.type&&(e=["<radialGradient ",i,' cx="',r.x2,'" cy="',r.y2,'" r="',r.r2,'" fx="',r.x1,'" fy="',r.y1,'">\n']);for(var o=0;o<this.colorStops.length;o++)e.push("<stop ",'offset="',100*this.colorStops[o].offset+"%",'" style="stop-color:',this.colorStops[o].color,null!=this.colorStops[o].opacity?";stop-opacity: "+this.colorStops[o].opacity:";",'"/>\n');return e.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),e.join(""