fabric.js/dist/all.min.js

166 lines
80 KiB
JavaScript

if(typeof console=="undefined")var console={log:function(){},warn:function(){}};if(!this.JSON)this.JSON={};
(function(){function g(h){return h<10?"0"+h:h}function p(h){k.lastIndex=0;return k.test(h)?'"'+h.replace(k,function(o){var q=a[o];return typeof q==="string"?q:"\\u"+("0000"+o.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+h+'"'}function c(h,o){var q,r,t,x,u=e,v,w=o[h];if(w&&typeof w==="object"&&typeof w.toJSON==="function")w=w.toJSON(h);if(typeof d==="function")w=d.call(o,h,w);switch(typeof w){case "string":return p(w);case "number":return isFinite(w)?String(w):"null";case "boolean":case "null":return String(w);
case "object":if(!w)return"null";e+=b;v=[];if(Object.prototype.toString.apply(w)==="[object Array]"){x=w.length;for(q=0;q<x;q+=1)v[q]=c(q,w)||"null";t=v.length===0?"[]":e?"[\n"+e+v.join(",\n"+e)+"\n"+u+"]":"["+v.join(",")+"]";e=u;return t}if(d&&typeof d==="object"){x=d.length;for(q=0;q<x;q+=1){r=d[q];if(typeof r==="string")if(t=c(r,w))v.push(p(r)+(e?": ":":")+t)}}else for(r in w)if(Object.hasOwnProperty.call(w,r))if(t=c(r,w))v.push(p(r)+(e?": ":":")+t);t=v.length===0?"{}":e?"{\n"+e+v.join(",\n"+e)+
"\n"+u+"}":"{"+v.join(",")+"}";e=u;return t}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+g(this.getUTCMonth()+1)+"-"+g(this.getUTCDate())+"T"+g(this.getUTCHours())+":"+g(this.getUTCMinutes())+":"+g(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var m=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
k=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,b,a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},d;if(typeof JSON.stringify!=="function")JSON.stringify=function(h,o,q){var r;b=e="";if(typeof q==="number")for(r=0;r<q;r+=1)b+=" ";else if(typeof q==="string")b=q;if((d=o)&&typeof o!=="function"&&(typeof o!=="object"||typeof o.length!=="number"))throw Error("JSON.stringify");return c("",
{"":h})};if(typeof JSON.parse!=="function")JSON.parse=function(h,o){function q(t,x){var u,v,w=t[x];if(w&&typeof w==="object")for(u in w)if(Object.hasOwnProperty.call(w,u)){v=q(w,u);if(v!==undefined)w[u]=v;else delete w[u]}return o.call(t,x,w)}var r;h=String(h);m.lastIndex=0;if(m.test(h))h=h.replace(m,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(h.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){r=eval("("+h+")");return typeof o==="function"?q({"":r},""):r}throw new SyntaxError("JSON.parse");}})();
(function(){function g(k,e){for(var b in e)k[b]=e[b];return k}function p(k,e){var b=document.createElement(k);for(var a in e)if(a==="class")b.className=e[a];else if(a==="for")b.htmlFor=e[a];else b.setAttribute(a,e[a]);return b}var c=this.fabric||(this.fabric={}),m=Array.prototype.slice;c.util={};(function(){var k=Math.PI/180;c.util.removeFromArray=function(e,b){var a=e.indexOf(b);a!==-1&&e.splice(a,1);return e};c.util.degreesToRadians=function(e){return e*k};c.util.toFixed=function(e,b){return parseFloat(Number(e).toFixed(b))};
c.util.getRandomInt=function(e,b){return Math.floor(Math.random()*(b-e+1))+e};c.util.falseFunction=function(){return false}})();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(k,e){var b=this.length>>>0;e=Number(e)||0;e=Math[e<0?"ceil":"floor"](e);if(e<0)e+=b;for(;e<b;e++)if(e in this&&this[e]===k)return e;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(k,e){for(var b=0,a=this.length>>>0;b<a;b++)b in this&&k.call(e,this[b],b,this)};if(!Array.prototype.map)Array.prototype.map=
function(k,e){for(var b=[],a=0,d=this.length>>>0;a<d;a++)if(a in this)b[a]=k.call(e,this[a],a,this);return b};if(!Array.prototype.every)Array.prototype.every=function(k,e){for(var b=0,a=this.length>>>0;b<a;b++)if(b in this&&!k.call(e,this[b],b,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(k,e){for(var b=0,a=this.length>>>0;b<a;b++)if(b in this&&k.call(e,this[b],b,this))return true;return false};if(!Array.prototype.filter)Array.prototype.filter=function(k,e){for(var b=
[],a,d=0,h=this.length>>>0;d<h;d++)if(d in this){a=this[d];k.call(e,a,d,this)&&b.push(a)}return res};if(!Array.prototype.reduce)Array.prototype.reduce=function(k){var e=this.length>>>0,b=0,a;if(arguments.length>1)a=arguments[1];else{do{if(b in this){a=this[b++];break}if(++b>=e)throw new TypeError;}while(1)}for(;b<e;b++)if(b in this)a=k.call(null,a,this[b],b,this);return a};c.util.array={invoke:function(k,e){for(var b=m.call(arguments,2),a=[],d=0,h=k.length;d<h;d++)a[d]=b.length?k[d][e].apply(k[d],
b):k[d][e].call(k[d]);return a},min:function(k,e){var b=k.length-1,a=e?k[b][e]:k[b];if(e)for(;b--;){if(k[b][e]<a)a=k[b][e]}else for(;b--;)if(k[b]<a)a=k[b];return a},max:function(k,e){var b=k.length-1,a=e?k[b][e]:k[b];if(e)for(;b--;){if(k[b][e]>=a)a=k[b][e]}else for(;b--;)if(k[b]>=a)a=k[b];return a}};c.util.object={extend:g,clone:function(k){return g({},k)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};c.util.string={camelize:function(k){return k.replace(/-+(.)?/g,
function(e,b){return b?b.toUpperCase():""})},capitalize:function(k){return k.charAt(0).toUpperCase()+k.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(k){var e=this,b=Array.prototype.slice.call(arguments,1);return function(){return e.apply(k,b.concat(Array.prototype.slice.call(arguments)))}};(function(){function k(){}var e;e=function(){for(var b in{toString:1})if(b==="toString")return false;return true}()?function(b,a){if(a.toString!==Object.prototype.toString)b.prototype.toString=
a.toString;if(a.valueOf!==Object.prototype.valueOf)b.prototype.valueOf=a.valueOf;for(var d in a)b.prototype[d]=a[d]}:function(b,a){for(var d in a)b.prototype[d]=a[d]};c.util.createClass=function(){function b(){this.initialize.apply(this,arguments)}var a=null,d=m.call(arguments,0);if(typeof d[0]==="function")a=d.shift();b.superclass=a;b.subclasses=[];if(a){k.prototype=a.prototype;b.prototype=new k;a.subclasses.push(b)}a=0;for(var h=d.length;a<h;a++)e(b,d[a]);if(!b.prototype.initialize)b.prototype.initialize=
emptyFunction;return b.prototype.constructor=b}})();(function(){function k(u){var v=Array.prototype.slice.call(arguments,1),w,A,D=v.length;for(A=0;A<D;A++){w=typeof u[v[A]];if(!/^(?:function|object|unknown)$/.test(w))return false}return true}function e(u,v){return function(w){v.call(d(u),w||window.event)}}function b(u,v){return function(w){if(t[u]&&t[u][v])for(var A=t[u][v],D=0,F=A.length;D<F;D++)A[D].call(this,w||window.event)}}var a=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(v){return v.uniqueID};
var u=0;return function(v){return v.__uniqueID||(v.__uniqueID="uniqueID__"+u++)}}(),d,h;(function(){var u={};d=function(v){return u[v]};h=function(v,w){u[v]=w}})();var o=k(document.documentElement,"addEventListener","removeEventListener")&&k(window,"addEventListener","removeEventListener"),q=k(document.documentElement,"attachEvent","detachEvent")&&k(window,"attachEvent","detachEvent"),r={},t={};if(o){addListener=function(u,v,w){u.addEventListener(v,w,false)};removeListener=function(u,v,w){u.removeEventListener(v,
w,false)}}else if(q){addListener=function(u,v,w){var A=a(u);h(A,u);r[A]||(r[A]={});r[A][v]||(r[A][v]=[]);w={handler:w,wrappedHandler:e(A,w)};r[A][v].push(w);u.attachEvent("on"+v,w.wrappedHandler)};removeListener=function(u,v,w){var A=a(u),D;if(r[A]&&r[A][v])for(var F=0,J=r[A][v].length;F<J;F++)if((D=r[A][v][F])&&D.handler===w){u.detachEvent("on"+v,D.wrappedHandler);r[A][v][F]=null}}}else{addListener=function(u,v,w){var A=a(u);t[A]||(t[A]={});if(!t[A][v]){t[A][v]=[];var D=u["on"+v];D&&t[A][v].push(D);
u["on"+v]=b(A,v)}t[A][v].push(w)};removeListener=function(u,v,w){u=a(u);if(t[u]&&t[u][v]){v=t[u][v];u=0;for(var A=v.length;u<A;u++)v[u]===w&&v.splice(u,1)}}}c.util.addListener=addListener;c.util.removeListener=removeListener;var x={};c.util.observeEvent=function(u,v){x[u]||(x[u]=[]);x[u].push(v)};c.util.fireEvent=function(u,v){var w=x[u];if(w)for(var A=0,D=w.length;A<D;A++)w[A]({memo:v})};c.util.getPointer=function(u){var v=document.documentElement,w=document.body||{scrollLeft:0},A=document.documentElement,
D=document.body||{scrollTop:0};return{x:u.pageX||u.clientX+(v.scrollLeft||w.scrollLeft)-(v.clientLeft||0),y:u.pageY||u.clientY+(A.scrollTop||D.scrollTop)-(A.clientTop||0)}}})(this);(function(){var k=document.createElement("div"),e=typeof k.style.filter==="string",b=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,a=function(d){return d};if(typeof k.style.opacity==="string")a=function(d,h){d.style.opacity=h;return d};else if(e)a=function(d,h){var o=d.style;if(d.currentStyle&&!d.currentStyle.hasLayout)o.zoom=
1;if(b.test(o.filter)){h=h>=0.9999?"":"alpha(opacity="+h*100+")";o.filter=o.filter.replace(b,h)}else o.filter+=" alpha(opacity="+h*100+")";return d};c.util.setStyle=function(d,h){var o=d.style;if(typeof h==="string"){d.style.cssText+=";"+h;return h.indexOf("opacity")>-1?a(d,h.match(/opacity:\s*(\d?\.?\d*)/)[1]):d}for(var q in h)if(q==="opacity")a(d,h[q]);else o[q==="float"||q==="cssFloat"?typeof o.styleFloat==="undefined"?"cssFloat":"styleFloat":q]=h[q];return d}})();(function(){var k=document.documentElement.style,
e="userSelect"in k?"userSelect":"MozUserSelect"in k?"MozUserSelect":"WebkitUserSelect"in k?"WebkitUserSelect":"KhtmlUserSelect"in k?"KhtmlUserSelect":"";c.util.makeElementUnselectable=function(b){if(typeof b.onselectstart!=="undefined")b.onselectstart=c.util.falseFunction;if(e)b.style[e]="none";else if(typeof b.unselectable=="string")b.unselectable="on";return b}})();(function(){function k(b,a){e.load(b);a()}c.util.getScript=function(b,a){var d=document.getElementsByTagName("head")[0],h=document.createElement("script"),
o=true;h.type="text/javascript";h.setAttribute("runat","server");h.onload=h.onreadystatechange=function(q){if(o)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){o=false;a(q||window.event);h=h.onload=h.onreadystatechange=null}};h.src=b;d.appendChild(h)};var e=this.Jaxer;if(e&&e.load)c.util.getScript=k})();c.util.getById=function(k){return typeof k==="string"?document.getElementById(k):k};c.util.toArray=function(k){for(var e=[],b=k.length;b--;)e[b]=k[b];
return e};c.util.makeElement=p;c.util.addClass=function(k,e){if((" "+k.className+" ").indexOf(" "+e+" ")===-1)k.className+=(k.className?" ":"")+e};c.util.wrapElement=function(k,e,b){if(typeof e==="string")e=p(e,b);k.parentNode&&k.parentNode.replaceChild(e,k);e.appendChild(k);return e};c.util.getElementOffset=function(k){var e=0,b=0;do{e+=k.offsetTop||0;b+=k.offsetLeft||0;k=k.offsetParent}while(k);return{left:b,top:e}};c.util.animate=function(k){k||(k={});var e=+new Date,b=k.duration||500,a=e+b,d,
h,o=k.onChange||function(){},q=k.easing||function(v){return-Math.cos(v*Math.PI)/2+0.5},r="startValue"in k?k.startValue:0,t="endValue"in k?k.endValue:100,x=r>t;k.onStart&&k.onStart();var u=setInterval(function(){d=+new Date;h=d>a?1:(d-e)/b;o(x?r-(r-t)*q(h):r+(t-r)*q(h));if(d>a){clearInterval(u);k.onComplete&&k.onComplete()}},10)};(function(){function k(){}var e=function(){for(var b=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},
function(){return new XMLHttpRequest}],a=b.length;a--;)try{if(b[a]())return b[a]}catch(d){}}();c.util.request=function(b,a){a||(a={});var d=a.method?a.method.toUpperCase():"GET",h=a.onComplete||function(){},o=e(),q;o.onreadystatechange=function(){if(o.readyState===4){h(o);o.onreadystatechange=k}};if(d==="GET"){q=null;if(typeof a.parameters=="string")b=b+(/\?/.test(b)?"&":"?")+a.parameters}o.open(d,b,true);if(d==="POST"||d==="PUT")o.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
o.send(q);return o}})()})(this);
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.string.capitalize,m=g.util.object.clone,k={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};g.parseTransformAttribute=function(){function e(q,r){var t=r[0];q[0]=Math.cos(t);q[1]=Math.sin(t);q[2]=-Math.sin(t);q[3]=Math.cos(t)}function b(q,r){var t=r.length===2?r[1]:r[0];q[0]=r[0];q[3]=t}function a(q,r){q[4]=r[0];if(r.length===
2)q[5]=r[1]}var d=[1,0,0,1,0,0],h=RegExp("^\\s*(?:(?:(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))(?:(?:\\s+,?\\s*|,\\s*)(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))))*)?)\\s*$"),
o=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))");
return function(q){var r=d.concat();if(!q||q&&!h.test(q))return r;q.replace(o,function(t){var x=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))").exec(t).filter(function(u){return u!==
""&&u!=null});t=x[1];x=x.slice(2).map(parseFloat);switch(t){case "translate":a(r,x);break;case "rotate":e(r,x);break;case "scale":b(r,x);break;case "skewX":r[2]=x[0];break;case "skewY":r[1]=x[0];break;case "matrix":r=x;break}});return r}}();g.parseSVGDocument=function(){var e=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,b=RegExp("^\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*$");
return function(a,d){if(a){var h=g.util.toArray(a.getElementsByTagName("*")).filter(function(u){var v;if(v=e.test(u.tagName)){a:{for(u=u;u&&(u=u.parentNode);)if(u.nodeName==="pattern"){u=true;break a}u=false}v=!u}return v});if(!(!h||h&&!h.length)){var o=a.getAttribute("viewBox"),q=a.getAttribute("width"),r=a.getAttribute("height"),t=null,x=null;if(o&&(o=o.match(b))){parseInt(o[1],10);parseInt(o[2],10);t=parseInt(o[3],10);x=parseInt(o[4],10)}t=q?parseFloat(q):t;x=r?parseFloat(r):x;o={width:t,height:x};
h=g.parseElements(h,m(o));!h||h&&!h.length||d&&d(h,o)}}}}();p(g,{parseAttributes:function(e,b){if(e){var a,d,h={};if(e.parentNode&&/^g$/i.test(e.parentNode.nodeName))h=g.parseAttributes(e.parentNode,b);var o=b.reduce(function(q,r){a=e.getAttribute(r);d=parseFloat(a);if(a){if((r==="fill"||r==="stroke")&&a==="none")a="";if(r==="fill-rule")a=a==="evenodd"?"destination-over":a;if(r==="transform")a=g.parseTransformAttribute(a);if(r in k)r=k[r];q[r]=isNaN(d)?a:d}return q},{});o=p(g.parseStyleAttribute(e),
o);return p(h,o)}},parseElements:function(e,b){var a=e.map(function(d){var h=g[c(d.tagName)];if(h&&h.fromElement)try{return h.fromElement(d,b)}catch(o){console.log(o.message||o)}});return a=a.filter(function(d){return d!=null})},parseStyleAttribute:function(e){var b={};if(e=e.getAttribute("style"))if(typeof e=="string"){e=e.split(";");e.pop();b=e.reduce(function(d,h){var o=h.split(":"),q=o[0].trim();o=o[1].trim();d[q]=o;return d},{})}else for(var a in e)if(typeof e[a]!=="undefined")b[a]=e[a];return b},
parsePointsAttribute:function(e){if(!e)return null;e=e.trim().split(/\s+/);e=e.reduce(function(b,a){a=a.split(",");b.push({x:parseFloat(a[0]),y:parseFloat(a[1])});return b},[]);if(e.length%2!==0)return null;return e}})})();
(function(){function g(c,m){arguments.length>0&&this.init(c,m)}var p=this.fabric||(this.fabric={});if(p.Point)console.warn("fabric.Point is already defined");else{g.prototype={constructor:g,init:function(c,m){this.x=c;this.y=m},add:function(c){return new g(this.x+c.x,this.y+c.y)},addEquals:function(c){this.x+=c.x;this.y+=c.y;return this},scalarAdd:function(c){return new g(this.x+c,this.y+c)},scalarAddEquals:function(c){this.x+=c;this.y+=c;return this},subtract:function(c){return new g(this.x-c.x,
this.y-c.y)},subtractEquals:function(c){this.x-=c.x;this.y-=c.y;return this},scalarSubtract:function(c){return new g(this.x-c,this.y-c)},scalarSubtractEquals:function(c){this.x-=c;this.y-=c;return this},multiply:function(c){return new g(this.x*c,this.y*c)},multiplyEquals:function(c){this.x*=c;this.y*=c;return this},divide:function(c){return new g(this.x/c,this.y/c)},divideEquals:function(c){this.x/=c;this.y/=c;return this},eq:function(c){return this.x==c.x&&this.y==c.y},lt:function(c){return this.x<
c.x&&this.y<c.y},lte:function(c){return this.x<=c.x&&this.y<=c.y},gt:function(c){return this.x>c.x&&this.y>c.y},gte:function(c){return this.x>=c.x&&this.y>=c.y},lerp:function(c,m){return new g(this.x+(c.x-this.x)*m,this.y+(c.y-this.y)*m)},distanceFrom:function(c){var m=this.x-c.x;c=this.y-c.y;return Math.sqrt(m*m+c*c)},min:function(c){return new g(Math.min(this.x,c.x),Math.min(this.y,c.y))},max:function(c){return new g(Math.max(this.x,c.x),Math.max(this.y,c.y))},toString:function(){return this.x+
","+this.y},setXY:function(c,m){this.x=c;this.y=m},setFromPoint:function(c){this.x=c.x;this.y=c.y},swap:function(c){var m=this.x,k=this.y;this.x=c.x;this.y=c.y;c.x=m;c.y=k}};p.Point=g}})();
(function(){function g(c){arguments.length>0&&this.init(c)}var p=this.fabric||(this.fabric={});if(p.Intersection)console.warn("fabric.Intersection is already defined");else{g.prototype.init=function(c){this.status=c;this.points=[]};g.prototype.appendPoint=function(c){this.points.push(c)};g.prototype.appendPoints=function(c){this.points=this.points.concat(c)};g.intersectLineLine=function(c,m,k,e){var b,a=(e.x-k.x)*(c.y-k.y)-(e.y-k.y)*(c.x-k.x);b=(m.x-c.x)*(c.y-k.y)-(m.y-c.y)*(c.x-k.x);k=(e.y-k.y)*
(m.x-c.x)-(e.x-k.x)*(m.y-c.y);if(k!=0){a=a/k;b=b/k;if(0<=a&&a<=1&&0<=b&&b<=1){b=new g("Intersection");b.points.push(new p.Point(c.x+a*(m.x-c.x),c.y+a*(m.y-c.y)))}else b=new g("No Intersection")}else b=a==0||b==0?new g("Coincident"):new g("Parallel");return b};g.intersectLinePolygon=function(c,m,k){for(var e=new g("No Intersection"),b=k.length,a=0;a<b;a++){var d=g.intersectLineLine(c,m,k[a],k[(a+1)%b]);e.appendPoints(d.points)}if(e.points.length>0)e.status="Intersection";return e};g.intersectPolygonPolygon=
function(c,m){for(var k=new g("No Intersection"),e=c.length,b=0;b<e;b++){var a=g.intersectLinePolygon(c[b],c[(b+1)%e],m);k.appendPoints(a.points)}if(k.points.length>0)k.status="Intersection";return k};g.intersectPolygonRectangle=function(c,m,k){var e=m.min(k),b=m.max(k);k=new p.Point(b.x,e.y);var a=new p.Point(e.x,b.y);m=g.intersectLinePolygon(e,k,c);k=g.intersectLinePolygon(k,b,c);b=g.intersectLinePolygon(b,a,c);c=g.intersectLinePolygon(a,e,c);e=new g("No Intersection");e.appendPoints(m.points);
e.appendPoints(k.points);e.appendPoints(b.points);e.appendPoints(c.points);if(e.points.length>0)e.status="Intersection";return e};p.Intersection=g}})();
(function(){function g(c){c?this._tryParsingColor(c):this.setSource([0,0,0,1])}var p=this.fabric||(this.fabric={});if(p.Color)console.warn("fabric.Color is already defined.");else{p.Color=g;g.prototype._tryParsingColor=function(c){var m=g.sourceFromHex(c);m||(m=g.sourceFromRgb(c));m&&this.setSource(m)};g.prototype.getSource=function(){return this._source};g.prototype.setSource=function(c){this._source=c};g.prototype.toRgb=function(){var c=this.getSource();return"rgb("+c[0]+","+c[1]+","+c[2]+")"};
g.prototype.toRgba=function(){var c=this.getSource();return"rgba("+c[0]+","+c[1]+","+c[2]+","+c[3]+")"};g.prototype.toHex=function(){var c=this.getSource(),m=c[0].toString(16);m=m.length==1?"0"+m:m;var k=c[1].toString(16);k=k.length==1?"0"+k:k;c=c[2].toString(16);c=c.length==1?"0"+c:c;return m.toUpperCase()+k.toUpperCase()+c.toUpperCase()};g.prototype.getAlpha=function(){return this.getSource()[3]};g.prototype.setAlpha=function(c){var m=this.getSource();m[3]=c;this.setSource(m);return this};g.prototype.toGrayscale=
function(){var c=this.getSource(),m=parseInt((c[0]*0.3+c[1]*0.59+c[2]*0.11).toFixed(0),10);this.setSource([m,m,m,c[3]]);return this};g.prototype.toBlackWhite=function(c){var m=this.getSource(),k=(m[0]*0.3+m[1]*0.59+m[2]*0.11).toFixed(0);m=m[3];c=c||127;k=Number(k)<Number(c)?0:255;this.setSource([k,k,k,m]);return this};g.prototype.overlayWith=function(c){c=new g(c);var m=[],k=this.getAlpha(),e=this.getSource();c=c.getSource();for(var b=0;b<3;b++)m.push(Math.round(e[b]*0.5+c[b]*0.5));m[4]=k;this.setSource(m);
return this};g.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;g.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;g.fromRgb=function(c){return g.fromSource(g.sourceFromRgb(c))};g.sourceFromRgb=function(c){if(c=c.match(g.reRGBa))return[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10),c[4]?parseFloat(c[4]):1]};g.fromRgba=g.fromRgb;g.fromHex=function(c){return g.fromSource(g.sourceFromHex(c))};g.sourceFromHex=function(c){if(c.match(g.reHex)){var m=c.slice(c.indexOf("#")+
1),k=m.length===3;c=k?m.charAt(0)+m.charAt(0):m.substring(0,2);var e=k?m.charAt(1)+m.charAt(1):m.substring(2,4);m=k?m.charAt(2)+m.charAt(2):m.substring(4,6);return[parseInt(c,16),parseInt(e,16),parseInt(m,16),1]}};g.fromSource=function(c){var m=new g;m.setSource(c);return m}}})();
(function(){if(fabric.Element)console.warn("fabric.Element is already defined.");else{var g=this.window,p=g.document,c=fabric.util.object.extend,m=fabric.util.string.capitalize,k=fabric.util.string.camelize,e=fabric.util.fireEvent,b=fabric.util.getPointer,a=fabric.util.getElementOffset,d=fabric.util.removeFromArray,h=fabric.util.addListener,o=fabric.util.removeListener,q=fabric.util.array.min,r=fabric.util.array.max,t=Math.sqrt,x=Math.pow,u=Math.atan2,v=Math.abs,w=Math.min,A=Math.max,D=Error("Could not initialize `canvas` element"),
F={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"},J=function(){var f=p.createElement("canvas");if(f&&f.getContext)if(f=f.getContext("2d")){try{f.fillStyle="transparent";return true}catch(l){}return false}}();fabric.Element=function(f,l){this._groupSelector=null;this._objects=[];this._activeGroup=this._currentTransform=this._element=this._context=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._config={width:300,
height:150};l=l||{};this._initElement(f);this._initConfig(l);l.overlayImage&&this.setOverlayImage(l.overlayImage);if(l.afterRender)this.afterRender=l.afterRender;this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};c(fabric.Element.prototype,{selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",freeDrawingColor:"rgb(0, 0, 0)",backgroundColor:"transparent",freeDrawingLineWidth:1,selectionLineWidth:1,includeDefaultValues:true,
shouldCacheImages:false,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(){},onFpsUpdate:function(){},calcOffset:function(){this._offset=a(this.getElement());return this},setOverlayImage:function(f,l){if(f){var n=this,s=new Image;s.onload=function(){n.overlayImage=s;l&&l();s=s.onload=null};s.src=f}return this},_initElement:function(f){this._element=fabric.util.getById(f)||p.createElement("canvas");typeof this._element.getContext==="undefined"&&G_vmlCanvasManager.initElement(this._element);
if(typeof this._element.getContext==="undefined")throw D;if(!(this.contextTop=this._element.getContext("2d")))throw D;f=this._element.width||0;var l=this._element.height||0;this._initWrapperElement(f,l);this._setElementStyle(f,l)},_initWrapperElement:function(f,l){var n=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(n,{width:f+"px",height:l+"px"});fabric.util.makeElementUnselectable(n);this.wrapper=n},_setElementStyle:function(f,l){fabric.util.setStyle(this.getElement(),
{position:"absolute",width:f+"px",height:l+"px",left:0,top:0})},_initConfig:function(f){c(this._config,f||{});this._config.width=parseInt(this._element.width,10)||0;this._config.height=parseInt(this._element.height,10)||0;this._element.style.width=this._config.width+"px";this._element.style.height=this._config.height+"px"},_initEvents:function(){var f=this;this._onMouseDown=function(l){f.__onMouseDown(l)};this._onMouseUp=function(l){f.__onMouseUp(l)};this._onMouseMove=function(l){f.__onMouseMove(l)};
this._onResize=function(){f.calcOffset()};h(this._element,"mousedown",this._onMouseDown);h(p,"mousemove",this._onMouseMove);h(p,"mouseup",this._onMouseUp);h(g,"resize",this._onResize)},_createCanvasElement:function(f){var l=p.createElement("canvas");if(l){l.className=f;f=this._element.parentNode.insertBefore(l,this._element);f.width=this.getWidth();f.height=this.getHeight();f.style.width=this.getWidth()+"px";f.style.height=this.getHeight()+"px";f.style.position="absolute";f.style.left=0;f.style.top=
0;typeof l.getContext==="undefined"&&G_vmlCanvasManager.initElement(l);if(typeof l.getContext==="undefined")throw D;fabric.util.makeElementUnselectable(f);return f}},_createCanvasContainer:function(){var f=this._createCanvasElement("canvas-container");this.contextContainerEl=f;this.contextContainer=f.getContext("2d")},_createCanvasBackground:function(){var f=this._createCanvasElement("canvas-container");this._contextBackgroundEl=f;this._contextBackground=f.getContext("2d")},getWidth:function(){return this._config.width},
getHeight:function(){return this._config.height},setWidth:function(f){return this._setDimension("width",f)},setHeight:function(f){return this._setDimension("height",f)},setDimensions:function(f){for(var l in f)this._setDimension(l,f[l]);return this},_setDimension:function(f,l){this.contextContainerEl[f]=l;this.contextContainerEl.style[f]=l+"px";this._contextBackgroundEl[f]=l;this._contextBackgroundEl.style[f]=l+"px";this._element[f]=l;this._element.style[f]=l+"px";this._element.parentNode.style[f]=
l+"px";this._config[f]=l;this.calcOffset();this.renderAll();return this},__onMouseUp:function(f){if(this.isDrawingMode&&this._isCurrentlyDrawing)this._finalizeDrawingPath();else{if(this._currentTransform){var l=this._currentTransform.target;if(l._scaling){e("object:scaled",{target:l});l._scaling=false}for(var n=this._objects.length;n--;)this._objects[n].setCoords();if(l.hasStateChanged()){l.isMoving=false;e("object:modified",{target:l})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(f);
if(n=this.getActiveGroup()){n.hasStateChanged()&&n.containsPoint(this.getPointer(f))&&e("group:modified",{target:n});n.setObjectsCoords();n.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(f,l);this._setCursor("");var s=this;setTimeout(function(){s._setCursorFromEvent(f,l)},50)}},_shouldClearSelection:function(f){var l=this.findTarget(f),n=this.getActiveGroup();return!l||l&&n&&!n.contains(l)&&n!==l&&!f.shiftKey},__onMouseDown:function(f){if(this.isDrawingMode){this._prepareForDrawing(f);
this._captureDrawingPath(f)}else if(!this._currentTransform){var l=this.findTarget(f),n=this.getPointer(f),s=this.getActiveGroup();if(this._shouldClearSelection(f)){this._groupSelector={ex:n.x,ey:n.y,top:0,left:0};this.deactivateAllWithDispatch()}else{l.saveState();l._findTargetCorner(f,this._offset)&&this.onBeforeScaleRotate(l);this._setupCurrentTransform(f,l);if(f.shiftKey&&(s||this.getActiveObject()))this._handleGroupLogic(f,l);else{l!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(l)}}this.renderAll()}},
getElement:function(){return this._element},deactivateAllWithDispatch:function(){var f=this.getActiveGroup();f&&e("before:group:destroyed",{target:f});this.deactivateAll();f&&e("after:group:destroyed");e("selection:cleared");return this},_setupCurrentTransform:function(f,l){var n="drag",s,y=b(f);if(s=l._findTargetCorner(f,this._offset))n=s==="ml"||s==="mr"?"scaleX":s==="mt"||s==="mb"?"scaleY":"rotate";this._currentTransform={target:l,action:n,scaleX:l.scaleX,scaleY:l.scaleY,offsetX:y.x-l.left,offsetY:y.y-
l.top,ex:y.x,ey:y.y,left:l.left,top:l.top,theta:l.theta,width:l.width*l.scaleX};this._currentTransform.original={left:l.left,top:l.top}},_handleGroupLogic:function(f,l){if(l.isType("group")){l=this.findTarget(f,true);if(!l||l.isType("group"))return}var n=this.getActiveGroup();if(n){if(n.contains(l)){n.remove(l);l.setActive(false);n.size()===1&&this.removeActiveGroup()}else n.add(l);e("group:selected",{target:n});n.setActive(true)}else{if(this._activeObject)if(l!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,
l]));n=this.getActiveGroup()}l.setActive(true)}n&&n.saveCoords()},_prepareForDrawing:function(f){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();f=this.getPointer(f);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(f.x);this._freeDrawingYPoints.push(f.y);this.contextTop.beginPath();this.contextTop.moveTo(f.x,f.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=
this.contextTop.lineJoin="round"},_captureDrawingPath:function(f){f=this.getPointer(f);this._freeDrawingXPoints.push(f.x);this._freeDrawingYPoints.push(f.y);this.contextTop.lineTo(f.x,f.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var f=q(this._freeDrawingXPoints),l=q(this._freeDrawingYPoints),n=r(this._freeDrawingXPoints),s=r(this._freeDrawingYPoints),y=[],z=this._freeDrawingXPoints,B=this._freeDrawingYPoints;y.push("M ",
z[0]-f," ",B[0]-l," ");for(var C=1;xPoint=z[C],yPoint=B[C];C++)y.push("L ",xPoint-f," ",yPoint-l," ");y=new fabric.Path(y.join(""));y.fill=null;y.stroke=this.freeDrawingColor;y.strokeWidth=this.freeDrawingLineWidth;this.add(y);y.set("left",f+(n-f)/2).set("top",l+(s-l)/2).setCoords();this.renderAll();e("path:created",{path:y})},__onMouseMove:function(f){if(this.isDrawingMode)this._isCurrentlyDrawing&&this._captureDrawingPath(f);else{var l=this._groupSelector;if(l!==null){var n=b(f);l.left=n.x-this._offset.left-
l.ex;l.top=n.y-this._offset.top-l.ey;this.renderTop()}else if(this._currentTransform){n=b(f);l=n.x;n=n.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){f.shiftKey||this._rotateObject(l,n);this._scaleObject(l,n)}else if(this._currentTransform.action==="scaleX")this._scaleObject(l,n,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(l,n,"y"):this._translateObject(l,n);this.renderAll()}else{n=this._element.style;if(l=this.findTarget(f)){this._setCursorFromEvent(f,
l);l.isActive()&&l.setCornersVisibility&&l.setCornersVisibility(true)}else{for(f=this._objects.length;f--;)this._objects[f].active||this._objects[f].setActive(false);n.cursor="default"}}}},_translateObject:function(f,l){var n=this._currentTransform.target;n.lockHorizontally||n.set("left",f-this._currentTransform.offsetX);n.lockVertically||n.set("top",l-this._currentTransform.offsetY)},_scaleObject:function(f,l,n){var s=this._currentTransform,y=this._offset,z=s.target;if(!z.lockScaling){var B=t(x(s.ey-
s.top-y.top,2)+x(s.ex-s.left-y.left,2));f=t(x(l-s.top-y.top,2)+x(f-s.left-y.left,2));z._scaling=true;if(n)if(n==="x")z.set("scaleX",s.scaleX*f/B);else n==="y"&&z.set("scaleY",s.scaleY*f/B);else{z.set("scaleX",s.scaleX*f/B);z.set("scaleY",s.scaleY*f/B)}}},_rotateObject:function(f,l){var n=this._currentTransform,s=this._offset;if(!n.target.lockRotation){var y=u(n.ey-n.top-s.top,n.ex-n.left-s.left);s=u(l-n.top-s.top,f-n.left-s.left);n.target.set("theta",s-y+n.theta)}},_setCursor:function(f){this._element.style.cursor=
f},_setCursorFromEvent:function(f,l){var n=this._element.style;if(l){var s=this.getActiveGroup();if(s=!!l._findTargetCorner&&(!s||!s.contains(l))&&l._findTargetCorner(f,this._offset))if(s in F)n.cursor=F[s];else{n.cursor="default";return false}else n.cursor="move"}else{n.cursor="default";return false}return true},_draw:function(f,l){l&&l.render(f)},_drawSelection:function(){var f=this._groupSelector,l=f.left,n=f.top,s=v(l),y=v(n);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(f.ex-
(l>0?0:-l),f.ey-(n>0?0:-n),s,y);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(f.ex+0.5-(l>0?0:s),f.ey+0.5-(n>0?0:y),s,y)},_findSelectedObjects:function(){var f=[],l=this._groupSelector.ex,n=this._groupSelector.ey,s=l+this._groupSelector.left,y=n+this._groupSelector.top,z=new fabric.Point(w(l,s),w(n,y));n=new fabric.Point(A(l,s),A(n,y));s=0;for(y=this._objects.length;s<y;++s){l=this._objects[s];if(l.intersectsWithRect(z,
n)||l.isContainedWithinRect(z,n)){l.setActive(true);f.push(l)}}if(f.length===1){this.setActiveObject(f[0]);e("object:selected",{target:f[0]})}else if(f.length>1){f=new fabric.Group(f);this.setActiveGroup(f);f.saveCoords();e("group:selected",{target:f})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);this.renderAll();return this},insertAt:function(f,l){this._objects.splice(l,0,f);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},
clearContext:function(f){f.clearRect(0,0,this._config.width,this._config.height);return this},clear:function(){this._objects.length=0;this.clearContext(this.contextTop);this.clearContext(this.contextContainer);this.renderAll();return this},renderAll:function(f){var l=this._config.width,n=this._config.height,s=f?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);f||this.clearContext(s);if(!J&&this.backgroundColor==="transparent")var y=true;if(!y)s.fillStyle=this.backgroundColor;
s.fillRect(0,0,l,n);f=this._objects.length;l=this.getActiveGroup();n=new Date;if(f)for(y=0;y<f;++y)if(!l||l&&!l.contains(this._objects[y]))this._draw(s,this._objects[y]);l&&this._draw(this.contextTop,l);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this.onFpsUpdate(~~(1E3/(new Date-n)));this.afterRender&&this.afterRender();return this},renderTop:function(){this.clearContext(this.contextTop);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this._groupSelector&&
this._drawSelection();var f=this.getActiveGroup();f&&f.render(this.contextTop);this.afterRender&&this.afterRender();return this},containsPoint:function(f,l){var n=this.getPointer(f),s=this._normalizePointer(l,n);n=s.x;s=s.y;var y=l._getImageLines(l.oCoords);if((n=l._findCrossPoints(n,s,y))&&n%2===1||l._findTargetCorner(f,this._offset))return true;return false},_normalizePointer:function(f,l){var n=this.getActiveGroup(),s=l.x,y=l.y;if(n&&f.type!=="group"&&n.contains(f)){s-=n.left;y-=n.top}return{x:s,
y:y}},findTarget:function(f,l){var n;this.getPointer(f);var s=this.getActiveGroup();if(s&&!l&&this.containsPoint(f,s))return n=s;for(s=this._objects.length;s--;)if(this.containsPoint(f,this._objects[s])){this.relatedTarget=n=this._objects[s];break}return n},toDataURL:function(f){var l;f||(f="png");if(f==="jpeg"||f==="png"){this.renderAll(true);l=this.getElement().toDataURL("image/"+f);this.renderAll()}return l},toDataURLWithMultiplier:function(f,l){var n=this.getWidth(),s=this.getHeight(),y=n*l,z=
s*l,B=this.getActiveObject();this.setWidth(y).setHeight(z);this.contextTop.scale(l,l);B&&this.deactivateAll().renderAll();y=this.toDataURL(f);this.contextTop.scale(1/l,1/l);this.setWidth(n).setHeight(s);B&&this.setActiveObject(B);this.renderAll();return y},getPointer:function(f){f=b(f);return{x:f.x-this._offset.left,y:f.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(f){f.set("left",this.getCenter().left);this.renderAll();return this},
fxCenterObjectH:function(f,l){l=l||{};var n=function(){},s=l.onComplete||n,y=l.onChange||n,z=this;fabric.util.animate({startValue:f.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(B){f.set("left",B);z.renderAll();y()},onComplete:function(){f.setCoords();s()}});return this},centerObjectV:function(f){f.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(f,l){l=l||{};var n=function(){},s=l.onComplete||n,y=l.onChange||n,z=this;
fabric.util.animate({startValue:f.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(B){f.set("top",B);z.renderAll();y()},onComplete:function(){f.setCoords();s()}});return this},straightenObject:function(f){f.straighten();this.renderAll();return this},fxStraightenObject:function(f){f.fxStraighten({onChange:this.renderAll.bind(this)});return this},toDatalessJSON:function(){return this.toDatalessObject()},toObject:function(){return this._toObjectMethod("toObject")},
toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(f){return{objects:this._objects.map(function(l){if(!this.includeDefaultValues){var n=l.includeDefaultValues;l.includeDefaultValues=false}var s=l[f]();if(!this.includeDefaultValues)l.includeDefaultValues=n;return s},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(f,l){if(f){var n=JSON.parse(f);if(!(!n||n&&!n.objects)){this.clear();var s=
this;this._enlivenObjects(n.objects,function(){s.backgroundColor=n.background;l&&l()});return this}}},_enlivenObjects:function(f,l){var n=0,s=f.filter(function(z){return z.type==="image"}).length,y=this;f.forEach(function(z){if(z.type)switch(z.type){case "image":case "font":fabric[m(z.type)].fromObject(z,function(C){y.add(C);++n===s&&l&&l()});break;default:var B=fabric[k(m(z.type))];B&&B.fromObject&&y.add(B.fromObject(z));break}});s===0&&l&&l()},loadFromDatalessJSON:function(f,l){if(f){var n=typeof f===
"string"?JSON.parse(f):f;if(!(!n||n&&!n.objects)){this.clear();this.backgroundColor=n.background;this._enlivenDatalessObjects(n.objects,l)}}},_enlivenDatalessObjects:function(f,l){function n(C,G){s.insertAt(C,G);C.setCoords();++y===z&&l&&l()}var s=this,y=0,z=f.length;z===0&&l&&l();try{f.forEach(function(C,G){var I=C.paths?"paths":"path",H=C[I];delete C[I];if(typeof H!=="string")switch(C.type){case "image":case "text":fabric[m(C.type)].fromObject(C,function(E){n(E,G)});break;default:(I=fabric[k(m(C.type))])&&
I.fromObject&&n(I.fromObject(C),G);break}else if(C.type==="image")s.loadImageFromURL(H,function(E){E.setSourcePath(H);c(E,C);E.setAngle(C.angle);n(E,G)});else if(C.type==="text"){C.path=H;var K=fabric.Text.fromObject(C);fabric.util.getScript(H,function(){Object.prototype.toString.call(g.opera)==="[object Opera]"?setTimeout(function(){n(K,G)},500):n(K,G)})}else s.loadSVGFromURL(H,function(E){E=E.length>1?new fabric.PathGroup(E,C):E[0];E.setSourcePath(H);if(!(E instanceof fabric.PathGroup)){c(E,C);
typeof C.angle!=="undefined"&&E.setAngle(C.angle)}n(E,G)})},this)}catch(B){console.log(B.message)}},loadImageFromURL:function(){var f={};return function(l,n){function s(){var B=p.getElementById(f[l]);B.width&&B.height?n(new fabric.Image(B)):setTimeout(s,50)}var y=this;if(f[l])s();else{var z=new Image;z.onload=function(){z.onload=null;y._resizeImageToFit(z);var B=new fabric.Image(z);n(B)};z.className="canvas-img-clone";z.src=l;if(this.shouldCacheImages)f[l]=Element.identify(z);p.body.appendChild(z)}}}(),
loadSVGFromURL:function(f,l){function n(z){if(z=z.responseXML)(z=z.documentElement)&&fabric.parseSVGDocument(z,function(B,C){y.cache.set(f,{objects:B.invoke("toObject"),options:C});l(B,C)})}function s(){console.log("ERROR!")}var y=this;f=f.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(f,function(z){if(z)y.cache.get(f,function(B){B=y._enlivenCachedObject(B);l(B.objects,B.options)});else new Ajax.Request(f,{method:"get",onComplete:n,onFailure:s})})},_enlivenCachedObject:function(f){var l=
f.objects;f=f.options;l=l.map(function(n){return fabric[m(n.type)].fromObject(n)});return{objects:l,options:f}},remove:function(f){d(this._objects,f);this.renderAll();return f},fxRemove:function(f,l){var n=this;f.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){n.remove(f);typeof l==="function"&&l()}});return this},sendToBack:function(f){d(this._objects,f);this._objects.unshift(f);return this.renderAll()},bringToFront:function(f){d(this._objects,f);this._objects.push(f);return this.renderAll()},
sendBackwards:function(f){var l=this._objects.indexOf(f),n=l;if(l!==0){for(l=l-1;l>=0;--l)if(f.intersectsWithObject(this._objects[l])){n=l;break}d(this._objects,f);this._objects.splice(n,0,f)}return this.renderAll()},bringForward:function(f){var l=this.getObjects(),n=l.indexOf(f),s=n;if(n!==l.length-1){n=n+1;for(var y=this._objects.length;n<y;++n)if(f.intersectsWithObject(l[n])){s=n;break}d(l,f);l.splice(s,0,f)}this.renderAll()},setActiveObject:function(f){this._activeObject&&this._activeObject.setActive(false);
this._activeObject=f;f.setActive(true);this.renderAll();e("object:selected",{target:f});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(f){this._activeGroup=f;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var f=this.getActiveGroup();f&&f.destroy();return this.setActiveGroup(null)},item:function(f){return this.getObjects()[f]},
deactivateAll:function(){for(var f=this.getObjects(),l=0,n=f.length;l<n;l++)f[l].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(f,l){f+=l.complexity?l.complexity():0;return f},0)},dispose:function(){this.clear();o(this.getElement(),"mousedown",this._onMouseDown);o(p,"mouseup",this._onMouseUp);o(p,"mousemove",this._onMouseMove);o(g,"resize",this._onResize);return this},clone:function(f){var l=p.createElement("canvas");
l.width=this.getWidth();l.height=this.getHeight();var n=this.__clone||(this.__clone=new fabric.Element(l));return n.loadFromJSON(JSON.stringify(this.toJSON()),function(){f&&f(n)})},_toDataURL:function(f,l){this.clone(function(n){l(n.toDataURL(f))})},_toDataURLWithMultiplier:function(f,l,n){this.clone(function(s){n(s.toDataURLWithMultiplier(f,l))})},_resizeImageToFit:function(f){var l=f.width||f.offsetWidth,n=this.getWidth()/l;if(l)f.width=l*n},cache:{has:function(f,l){l(false)},get:function(){},set:function(){}}});
fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};c(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(f){var l=f.getContext("2d");f=l.getImageData(0,0,f.width,f.height);var n=f.data,s=f.width,y=f.height,z,B;for(i=0;i<s;i++)for(j=0;j<y;j++){z=i*4*y+j*4;B=(n[z]+n[z+1]+n[z+2])/3;n[z]=B;n[z+1]=B;n[z+2]=B}l.putImageData(f,0,0)},supports:function(f){var l=p.createElement("canvas");
if(!l||!l.getContext)return null;var n=l.getContext("2d");if(!n)return null;switch(f){case "getImageData":return typeof n.getImageData!=="undefined";case "toDataURL":return typeof l.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.object.clone,m=g.util.toFixed,k=g.util.string.capitalize,e=g.util.getPointer,b=Array.prototype.slice;if(!g.Object){g.Object=g.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,FX_TRANSITION:"decel",MIN_SCALE_LIMIT:0.1,stateProperties:"top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix".split(" "),
options:{top:0,left:0,width:100,height:100,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:10,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",overlayFill:null,stroke:null,strokeWidth:1,fillRule:"source-over",borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null},callSuper:function(a){var d=this.constructor.superclass.prototype[a];return arguments.length>1?d.apply(this,b.call(arguments,1)):d.call(this)},
initialize:function(a){this.setOptions(a);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(a){this.options=p(this._getOptions(),a)},_getOptions:function(){return p(c(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var a=this.constructor;if(a)if(a=a.superclass)if((a=a.prototype)&&typeof a._getOptions=="function")return a._getOptions();return{}},_importProperties:function(){this.stateProperties.forEach(function(a){a==="angle"?
this.setAngle(this.options[a]):this[a]=this.options[a]},this)},transform:function(a){a.globalAlpha=this.opacity;a.translate(this.left,this.top);a.rotate(this.theta);a.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var a={type:this.type,left:m(this.left,this.NUM_FRACTION_DIGITS),top:m(this.top,this.NUM_FRACTION_DIGITS),width:m(this.width,this.NUM_FRACTION_DIGITS),height:m(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,
strokeWidth:this.strokeWidth,scaleX:m(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:m(this.scaleY,this.NUM_FRACTION_DIGITS),angle:m(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:m(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var d=g.Object.prototype.options;this.stateProperties.forEach(function(h){a[h]===d[h]&&delete a[h]});
return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#<fabric."+k(this.type)+">"},set:function(a,d){if((a==="scaleX"||a==="scaleY")&&d<this.MIN_SCALE_LIMIT)d=this.MIN_SCALE_LIMIT;if(a==="angle")this.setAngle(d);else this[a]=d;return this},toggle:function(a){var d=this.get(a);typeof d==="boolean"&&this.set(a,!d);return this},setSourcePath:function(a){this.sourcePath=a;return this},get:function(a){return a==="angle"?this.getAngle():
this[a]},render:function(a,d){if(!(this.width===0||this.height===0)){a.save();var h=this.transformMatrix;h&&a.setTransform(h[0],h[1],h[2],h[3],h[4],h[5]);d||this.transform(a);if(this.stroke){a.lineWidth=this.strokeWidth;a.strokeStyle=this.stroke}if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;this._render(a);if(this.active&&!d){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}a.restore()}},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*
this.scaleY},scale:function(a){this.scaleY=this.scaleX=a;return this},scaleToWidth:function(a){return this.scale(a/this.width)},scaleToHeight:function(a){return this.scale(a/this.height)},setOpacity:function(a){this.set("opacity",a);return this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(a){this.theta=a/180*Math.PI;this.angle=a;return this},setCoords:function(){this.currentWidth=this.width*this.scaleX;this.currentHeight=this.height*this.scaleY;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/
2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var a=Math.cos(this._angle+this.theta)*this._hypotenuse,d=Math.sin(this._angle+this.theta)*this._hypotenuse,h=this.theta,o=Math.sin(h);h=Math.cos(h);a={x:this.left-a,y:this.top-d};d={x:a.x+this.currentWidth*h,y:a.y+this.currentWidth*o};var q={x:a.x-this.currentHeight*o,y:a.y+this.currentHeight*h};this.oCoords={tl:a,tr:d,br:{x:d.x-this.currentHeight*o,y:d.y+this.currentHeight*h},bl:q,ml:{x:a.x-this.currentHeight/
2*o,y:a.y+this.currentHeight/2*h},mt:{x:a.x+this.currentWidth/2*h,y:a.y+this.currentWidth/2*o},mr:{x:d.x-this.currentHeight/2*o,y:d.y+this.currentHeight/2*h},mb:{x:q.x+this.currentWidth/2*h,y:q.y+this.currentWidth/2*o}};this._setCornerCoords();return this},drawBorders:function(a){var d=this.options,h=d.padding,o=h*2;a.save();a.globalAlpha=this.isMoving?d.borderOpacityWhenMoving:1;a.strokeStyle=d.borderColor;d=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX);var q=1/(this.scaleY<
this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);a.lineWidth=1/this.borderScaleFactor;a.scale(d,q);d=this.getWidth();q=this.getHeight();a.strokeRect(~~(-(d/2)-h)+0.5,~~(-(q/2)-h)+0.5,~~(d+o),~~(q+o));a.restore();return this},drawCorners:function(a){var d=this.options.cornersize,h=d/2,o=this.options.padding,q=-(this.width/2),r=-(this.height/2),t=d/this.scaleX,x=d/this.scaleY,u=(o+h)/this.scaleY,v=(o+h)/this.scaleX,w=(o+h-d)/this.scaleX;o=(o+h-d)/this.scaleY;a.save();a.globalAlpha=this.isMoving?
this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;d=q-v;h=r-u;a.fillRect(d,h,t,x);d=q+this.width-v;h=r-u;a.fillRect(d,h,t,x);d=q-v;h=r+this.height+o;a.fillRect(d,h,t,x);d=q+this.width+w;h=r+this.height+o;a.fillRect(d,h,t,x);d=q+this.width/2-v;h=r-u;a.fillRect(d,h,t,x);d=q+this.width/2-v;h=r+this.height+o;a.fillRect(d,h,t,x);d=q+this.width+w;h=r+this.height/2-u;a.fillRect(d,h,t,x);d=q-v;h=r+this.height/2-u;a.fillRect(d,h,t,x);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),
a);return new g.Object(this.toObject())},cloneAsImage:function(a){if(g.Image){var d=new Image;d.onload=function(){a&&a(new g.Image(d),h);d=d.onload=null};var h={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);d.src=this.toDataURL()}return this},toDataURL:function(){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();g.util.wrapElement(a,"div");var d=new g.Element(a);d.backgroundColor=
"transparent";d.renderAll();var h=this.clone();h.left=a.width/2;h.top=a.height/2;h.setActive(false);d.add(h);a=d.toDataURL("png");d.dispose();return a},hasStateChanged:function(){return this.stateProperties.some(function(a){return this[a]!==this.originalState[a]},this)},saveState:function(){this.stateProperties.forEach(function(a){this.originalState[a]=this.get(a)},this);return this},intersectsWithRect:function(a,d){var h=this.oCoords,o=new g.Point(h.tl.x,h.tl.y),q=new g.Point(h.tr.x,h.tr.y),r=new g.Point(h.bl.x,
h.bl.y);h=new g.Point(h.br.x,h.br.y);return g.Intersection.intersectPolygonRectangle([o,q,h,r],a,d).status==="Intersection"},intersectsWithObject:function(a){function d(o){return{tl:new g.Point(o.tl.x,o.tl.y),tr:new g.Point(o.tr.x,o.tr.y),bl:new g.Point(o.bl.x,o.bl.y),br:new g.Point(o.br.x,o.br.y)}}var h=d(this.oCoords);a=d(a.oCoords);return g.Intersection.intersectPolygonPolygon([h.tl,h.tr,h.br,h.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,d){var h=this.oCoords,
o=new g.Point(h.tl.x,h.tl.y),q=new g.Point(h.tr.x,h.tr.y),r=new g.Point(h.bl.x,h.bl.y);new g.Point(h.br.x,h.br.y);return o.x>a.x&&q.x<d.x&&o.y>a.y&&r.y<d.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,d){var h=e(a),o=h.x-d.left;h=h.y-d.top;var q;for(var r in this.oCoords){q=this._getImageLines(this.oCoords[r].corner,r);q=this._findCrossPoints(o,h,q);if(q%2==1&&q!=0)return this.__corner=r}return false},_findCrossPoints:function(a,d,h){var o,q,r,t=0;for(var x in h){r=h[x];
if(!(r.o.y<d&&r.d.y<d))if(!(r.o.y>=d&&r.d.y>=d)){if(r.o.x==r.d.x&&r.o.x>=a)o=r.o.x;else{o=(r.d.y-r.o.y)/(r.d.x-r.o.x);q=d-0*a;r=r.o.y-o*r.o.x;o=-(q-r)/(0-o)}if(o>=a)t+=1;if(t==2)break}}return t},_getImageLines:function(a){return{topline:{o:a.tl,d:a.tr},rightline:{o:a.tr,d:a.br},bottomline:{o:a.br,d:a.bl},leftline:{o:a.bl,d:a.tl}}},_setCornerCoords:function(){var a=this.oCoords,d=this.theta,h=this.cornersize*Math.cos(d),o=this.cornersize*Math.sin(d);d=this.cornersize/2;var q=d-o;a.tl.x-=q;a.tl.y-=
d;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+h,y:a.tl.y+o},bl:{x:a.tl.x-o,y:a.tl.y+h}};a.tl.corner.br={x:a.tl.corner.tr.x-o,y:a.tl.corner.tr.y+h};a.tl.x+=q;a.tl.y+=d;a.tr.x+=d;a.tr.y-=d;a.tr.corner={tl:{x:a.tr.x-h,y:a.tr.y-o},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-o,y:a.tr.y+h}};a.tr.corner.bl={x:a.tr.corner.tl.x-o,y:a.tr.corner.tl.y+h};a.tr.x-=d;a.tr.y+=d;a.bl.x-=d;a.bl.y+=d;a.bl.corner={tl:{x:a.bl.x+o,y:a.bl.y-h},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+h,y:a.bl.y+o}};a.bl.corner.tr={x:a.bl.corner.br.x+
o,y:a.bl.corner.br.y-h};a.bl.x+=d;a.bl.y-=d;a.br.x+=d;a.br.y+=d;a.br.corner={tr:{x:a.br.x+o,y:a.br.y-h},bl:{x:a.br.x-h,y:a.br.y-o},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+o,y:a.br.corner.bl.y-h};a.br.x-=d;a.br.y-=d;a.ml.x-=d;a.ml.y-=d;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+h,y:a.ml.y+o},bl:{x:a.ml.x-o,y:a.ml.y+h}};a.ml.corner.br={x:a.ml.corner.tr.x-o,y:a.ml.corner.tr.y+h};a.ml.x+=d;a.ml.y+=d;a.mt.x-=d;a.mt.y-=d;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+h,y:a.mt.y+
o},bl:{x:a.mt.x-o,y:a.mt.y+h}};a.mt.corner.br={x:a.mt.corner.tr.x-o,y:a.mt.corner.tr.y+h};a.mt.x+=d;a.mt.y+=d;a.mr.x-=d;a.mr.y-=d;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+h,y:a.mr.y+o},bl:{x:a.mr.x-o,y:a.mr.y+h}};a.mr.corner.br={x:a.mr.corner.tr.x-o,y:a.mr.corner.tr.y+h};a.mr.x+=d;a.mr.y+=d;a.mb.x-=d;a.mb.y-=d;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+h,y:a.mb.y+o},bl:{x:a.mb.x-o,y:a.mb.y+h}};a.mb.corner.br={x:a.mb.corner.tr.x-o,y:a.mb.corner.tr.y+h};a.mb.x+=d;a.mb.y+=d;a=a.mb.corner;
a.tl.x-=d;a.tl.y-=d;a.tr.x-=d;a.tr.y-=d;a.br.x-=d;a.br.y-=d;a.bl.x-=d;a.bl.y-=d},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new g.Color(a)).toGrayscale().toRgb());return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){this.setAngle(this._getAngleValueForStraighten());return this},fxStraighten:function(a){a=a||{};var d=function(){},h=a.onComplete||d,o=a.onChange||
d,q=this;g.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(r){q.setAngle(r);o()},onComplete:function(){q.setCoords();h()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var d=function(){},h=a.onComplete||d,o=a.onChange||d,q=this;g.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(r){q.set("opacity",r);o()},onComplete:h,onStart:function(){q.setActive(false)}});
return this},_getAngleValueForStraighten:function(){var a=this.get("angle");if(a>-225&&a<=-135)return-180;else if(a>-135&&a<=-45)return-90;else if(a>-45&&a<=45)return 0;else if(a>45&&a<=135)return 90;else if(a>135&&a<=225)return 180;else if(a>225&&a<=315)return 270;else if(a>315)return 360;return 0},toJSON:function(){return this.toObject()}});g.Object.prototype.rotate=g.Object.prototype.setAngle}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend;if(!g.Line){g.Line=g.util.createClass(g.Object,{type:"line",initialize:function(c,m){c||(c=[0,0,0,0]);this.callSuper("initialize",m);this.set("x1",c[0]);this.set("y1",c[1]);this.set("x2",c[2]);this.set("y2",c[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(c){c.beginPath();c.moveTo(-this.width/2,-this.height/2);
c.lineTo(this.width/2,this.height/2);var m=c.strokeStyle;c.strokeStyle=c.fillStyle;c.stroke();c.strokeStyle=m},complexity:function(){return 1},toObject:function(){return p(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});g.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");g.Line.fromElement=function(c,m){var k=g.parseAttributes(c,g.Element.ATTRIBUTE_NAMES);return new g.Line([k.x1||0,k.y1||0,k.x2||0,k.y2||0],p(k,m))};
g.Line.fromObject=function(c){return new g.Line([c.x1,c.y1,c.x2,c.y2],c)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=Math.PI*2,c=g.util.object.extend;if(g.Circle)console.warn("fabric.Circle is already defined.");else{g.Circle=g.util.createClass(g.Object,{type:"circle",initialize:function(m){m=m||{};this.set("radius",m.radius||0);this.callSuper("initialize",m);m=this.get("radius")*2*this.get("scaleX");this.set("width",m).set("height",m)},toObject:function(){return c(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(m){m.beginPath();m.arc(0,
0,this.radius,0,p,false);m.closePath();this.fill&&m.fill();this.stroke&&m.stroke()},complexity:function(){return 1}});g.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");g.Circle.fromElement=function(m,k){var e=g.parseAttributes(m,g.Circle.ATTRIBUTE_NAMES);if(!("radius"in e&&e.radius>0))throw Error("value of `r` attribute is required and can not be negative");return new g.Circle(c(e,k))};g.Circle.fromObject=function(m){return new g.Circle(m)}}})();
(function(){var g=this.fabric||(this.fabric={});if(!g.Triangle){g.Triangle=g.util.createClass(g.Object,{type:"triangle",initialize:function(p){p=p||{};this.callSuper("initialize",p);this.set("width",p.width||100).set("height",p.height||100)},_render:function(p){var c=this.width/2,m=this.height/2;p.beginPath();p.moveTo(-c,m);p.lineTo(0,-m);p.lineTo(c,m);p.closePath();this.fill&&p.fill();this.stroke&&p.stroke()},complexity:function(){return 1}});g.Triangle.fromObject=function(p){return new g.Triangle(p)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend;if(g.Ellipse)console.warn("fabric.Ellipse is already defined.");else{g.Ellipse=g.util.createClass(g.Object,{type:"ellipse",initialize:function(c){c=c||{};this.callSuper("initialize",c);this.set("rx",c.rx||0);this.set("ry",c.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return p(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(c,m){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",c,m)},_render:function(c){c.beginPath();c.save();c.transform(1,0,0,this.ry/this.rx,0,0);c.arc(0,0,this.rx,0,Math.PI*2,false);c.restore();this.stroke&&c.stroke();this.fill&&c.fill()},complexity:function(){return 1}});g.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");g.Ellipse.fromElement=function(c,m){var k=g.parseAttributes(c,g.Ellipse.ATTRIBUTE_NAMES);return new g.Ellipse(p(k,m))};g.Ellipse.fromObject=
function(c){return new g.Ellipse(c)}}})();
(function(){var g=this.fabric||(this.fabric={});if(!g.Rect){g.Rect=g.util.createClass(g.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(p){this.callSuper("initialize",p);this._initRxRy()},_initRxRy:function(){if(this.options.rx&&!this.options.ry)this.options.ry=this.options.rx;else if(this.options.ry&&!this.options.rx)this.options.rx=this.options.ry},_render:function(p){var c=this.options.rx||0,m=this.options.ry||0,k=-this.width/2,e=-this.height/2,b=this.width,a=this.height;p.beginPath();
p.moveTo(k+c,e);p.lineTo(k+b-c,e);p.bezierCurveTo(k+b,e,k+b,e+m,k+b,e+m);p.lineTo(k+b,e+a-m);p.bezierCurveTo(k+b,e+a,k+b-c,e+a,k+b-c,e+a);p.lineTo(k+c,e+a);p.bezierCurveTo(k,e+a,k,e+a-m,k,e+a-m);p.lineTo(k,e+m);p.bezierCurveTo(k,e,k+c,e,k+c,e);p.closePath();this.fill&&p.fill();this.stroke&&p.stroke()},_normalizeLeftTopProperties:function(p){p.left&&this.set("left",p.left+this.getWidth()/2);p.top&&this.set("top",p.top+this.getHeight()/2);return this},complexity:function(){return 1}});g.Rect.ATTRIBUTE_NAMES=
"x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");g.Rect.fromElement=function(p,c){if(!p)return null;var m=g.parseAttributes(p,g.Rect.ATTRIBUTE_NAMES);m=m;m.left=m.left||0;m.top=m.top||0;m=m;var k=new g.Rect(g.util.object.extend(c||{},m));k._normalizeLeftTopProperties(m);return k};g.Rect.fromObject=function(p){return new g.Rect(p)}}})();
(function(){var g=this.fabric||(this.fabric={});if(g.Polyline)console.warn("fabric.Polyline is already defined");else{g.Polyline=g.util.createClass(g.Object,{type:"polyline",initialize:function(c,m){m=m||{};this.set("points",c);this.callSuper("initialize",m);this._calcDimensions()},_calcDimensions:function(){return g.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return g.Polygon.prototype._toOrigin.call(this)},toObject:function(){return g.Polygon.prototype.toObject.call(this)},
_render:function(c){var m;c.beginPath();for(var k=0,e=this.points.length;k<e;k++){m=this.points[k];c.lineTo(m.x,m.y)}this.fill&&c.fill();this.stroke&&c.stroke()},complexity:function(){return this.get("points").length}});var p="fill fill-opacity stroke stroke-width transform".split(" ");g.Polyline.fromElement=function(c,m){if(!c)return null;var k=g.parsePointsAttribute(c.getAttribute("points")),e=g.parseAttributes(c,p);return new g.Polyline(k,g.util.object.extend(e,m))};g.Polyline.fromObject=function(c){return new g.Polyline(c.points,
c)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.array.min,m=g.util.array.max;if(g.Polygon)console.warn("fabric.Polygon is already defined");else{g.Polygon=g.util.createClass(g.Object,{type:"polygon",initialize:function(k,e){e=e||{};this.points=k;this.callSuper("initialize",e);this._calcDimensions()},_calcDimensions:function(){var k=this.points,e=c(k,"x"),b=c(k,"y"),a=m(k,"x");k=m(k,"y");this.width=a-e;this.height=k-b;this.minX=e;this.minY=b},_toOrigin:function(){this.points=this.points.map(function(k){return{x:k.x-
this.minX,y:k.y-this.minY}},this)},toObject:function(){return p(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(k){var e;k.beginPath();for(var b=0,a=this.points.length;b<a;b++){e=this.points[b];k.lineTo(e.x,e.y)}this.fill&&k.fill();if(this.stroke){k.closePath();k.stroke()}},complexity:function(){return this.points.length}});g.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");g.Polygon.fromElement=function(k,e){if(!k)return null;var b=
g.parsePointsAttribute(k.getAttribute("points")),a=g.parseAttributes(k,g.Polygon.ATTRIBUTE_NAMES);return new g.Polygon(b,p(a,e))};g.Polygon.fromObject=function(k){return new g.Polygon(k.points,k)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.array.min,c=g.util.array.max,m=g.util.object.extend;if(g.Path)console.warn("fabric.Path is already defined");else if(g.Object){g.Path=g.util.createClass(g.Object,{type:"path",initialize:function(e,b){b=b||{};this.setOptions(b);this._importProperties();this.originalState={};if(!e)throw Error("`path` argument is required");var a=Object.prototype.toString.call(e)==="[object Array]";if(this.path=a?e:e.match&&e.match(/[a-zA-Z][^a-zA-Z]*/g)){a||this._initializeFromArray(b);
this.setCoords();b.sourcePath&&this.setSourcePath(b.sourcePath)}},_initializeFromArray:function(e){var b="width"in e;e="height"in e;this.path=this._parsePath();if(!b||!e){m(this,this._parseDimensions());if(b)this.width=this.options.width;if(e)this.height=this.options.height}},_render:function(e){for(var b,a=0,d=0,h=0,o=0,q,r,t=-(this.width/2),x=-(this.height/2),u=0,v=this.path.length;u<v;++u){b=this.path[u];switch(b[0]){case "l":a+=b[1];d+=b[2];e.lineTo(a+t,d+x);break;case "L":a=b[1];d=b[2];e.lineTo(a+
t,d+x);break;case "h":a+=b[1];e.lineTo(a+t,d+x);break;case "H":a=b[1];e.lineTo(a+t,d+x);break;case "v":d+=b[1];e.lineTo(a+t,d+x);break;case "V":d=b[1];e.lineTo(a+t,d+x);break;case "m":a+=b[1];d+=b[2];e.moveTo(a+t,d+x);break;case "M":a=b[1];d=b[2];e.moveTo(a+t,d+x);break;case "c":q=a+b[5];r=d+b[6];h=a+b[3];o=d+b[4];e.bezierCurveTo(a+b[1]+t,d+b[2]+x,h+t,o+x,q+t,r+x);a=q;d=r;break;case "C":a=b[5];d=b[6];h=b[3];o=b[4];e.bezierCurveTo(b[1]+t,b[2]+x,h+t,o+x,a+t,d+x);break;case "s":q=a+b[3];r=d+b[4];h=2*
a-h;o=2*d-o;e.bezierCurveTo(h+t,o+x,a+b[1]+t,d+b[2]+x,q+t,r+x);a=q;d=r;break;case "S":q=b[3];r=b[4];h=2*a-h;o=2*d-o;e.bezierCurveTo(h+t,o+x,b[1]+t,b[2]+x,q+t,r+x);a=q;d=r;break;case "q":a+=b[3];d+=b[4];e.quadraticCurveTo(b[1]+t,b[2]+x,a+t,d+x);break;case "Q":a=b[3];d=b[4];h=b[1];o=b[2];e.quadraticCurveTo(h+t,o+x,a+t,d+x);break;case "T":q=a;r=d;a=b[1];d=b[2];h=-h+2*q;o=-o+2*r;e.quadraticCurveTo(h+t,o+x,a+t,d+x);break;case "a":break;case "A":break;case "z":case "Z":e.closePath();break}}},render:function(e,
b){e.save();var a=this.transformMatrix;a&&e.transform(a[0],a[1],a[2],a[3],a[4],a[5]);b||this.transform(e);if(this.overlayFill)e.fillStyle=this.overlayFill;else if(this.fill)e.fillStyle=this.fill;if(this.stroke)e.strokeStyle=this.stroke;e.beginPath();this._render(e);this.fill&&e.fill();if(this.stroke){e.strokeStyle=this.stroke;e.lineWidth=this.strokeWidth;e.lineCap=e.lineJoin="round";e.stroke()}if(!b&&this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toString:function(){return"#<fabric.Path ("+
this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var e=m(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)e.sourcePath=this.sourcePath;if(this.transformMatrix)e.transformMatrix=this.transformMatrix;return e},toDatalessObject:function(){var e=this.toObject();if(this.sourcePath)e.path=this.sourcePath;delete e.sourcePath;return e},complexity:function(){return this.path.length},set:function(e,b){return this.callSuper("set",e,b)},_parsePath:function(){for(var e=
[],b,a,d=0,h=this.path.length;d<h;d++){b=this.path[d];a=b.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);e.push([b.charAt(0)].concat(a.map(parseFloat)))}return e},_parseDimensions:function(){function e(w){if(w[0]==="H")return w[1];return w[w.length-2]}function b(w){if(w[0]==="V")return w[1];return w[w.length-1]}var a=[],d=[],h,o,q=false,r,t;this.path.forEach(function(w,A){if(w[0]!=="H")h=A===0?e(w):e(this.path[A-1]);if(w[0]!=="V")o=A===0?b(w):b(this.path[A-1]);if(w[0]===w[0].toLowerCase())q=
true;r=q?h+e(w):w[0]==="V"?h:e(w);t=q?o+b(w):w[0]==="H"?o:b(w);var D=parseInt(r,10);isNaN(D)||a.push(D);D=parseInt(t,10);isNaN(D)||d.push(D)},this);var x=p(a),u=p(d),v=deltaY=0;x={top:u-deltaY,left:x-v,bottom:c(d)-deltaY,right:c(a)-v};x.width=x.right-x.left;x.height=x.bottom-x.top;return x}});g.Path.fromObject=function(e){return new g.Path(e.path,e)};var k=g.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");g.Path.fromElement=function(e,b){var a=g.parseAttributes(e,
k),d=a.d;delete a.d;return new g.Path(d,m(a,b))}}else console.warn("fabric.Path requires fabric.Object")})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.array.invoke,m=g.Object.prototype.set,k=g.Object.prototype.toObject,e=g.util.string.camelize,b=g.util.string.capitalize;if(g.PathGroup)console.warn("fabric.PathGroup is already defined");else{g.PathGroup=g.util.createClass(g.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(a,d){d=d||{};this.originalState={};this.paths=a;this.setOptions(d);this.initProperties();this.setCoords();d.sourcePath&&this.setSourcePath(d.sourcePath)},
initProperties:function(){this.stateProperties.forEach(function(a){if(a==="fill")this.set(a,this.options[a]);else if(a==="angle")this.setAngle(this.options[a]);else this[a]=this.options[a]},this)},render:function(a){if(this.stub){a.save();this.transform(a);this.stub.render(a,false);if(this.active){this.drawBorders(a);this.drawCorners(a)}}else{a.save();var d=this.transformMatrix;d&&a.transform(d[0],d[1],d[2],d[3],d[4],d[5]);this.transform(a);d=0;for(var h=this.paths.length;d<h;++d)this.paths[d].render(a,
true);if(this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}}a.restore()},set:function(a,d){if((a==="fill"||a==="overlayFill")&&this.isSameColor()){this[a]=d;for(var h=this.paths.length;h--;)this.paths[h].set(a,d)}else m.call(this,a,d);return this},toObject:function(){return p(k.call(this),{paths:c(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var a=this.toObject();if(this.sourcePath)a.paths=this.sourcePath;return a},toString:function(){return"#<fabric.PathGroup ("+
this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var a=this.getObjects()[0].get("fill");return this.getObjects().every(function(d){return d.get("fill")===a})},complexity:function(){return this.paths.reduce(function(a,d){return a+(d&&d.complexity?d.complexity():0)},0)},toGrayscale:function(){for(var a=this.paths.length;a--;)this.paths[a].toGrayscale();return this},getObjects:function(){return this.paths}});g.PathGroup.fromObject=function(a){for(var d=a.paths,
h=0,o=d.length;h<o;h++)if(!(d[h]instanceof g.Object)){var q=e(b(d[h].type));d[h]=g[q].fromObject(d[h])}return new g.PathGroup(d,a)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.array.min,m=g.util.array.max,k=g.util.array.invoke,e=g.util.removeFromArray;if(!g.Group){g.Group=g.util.createClass(g.Object,{type:"group",initialize:function(b,a){this.objects=b||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();a&&p(this,a);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var b=
this.left,a=this.top;this.forEachObject(function(d){var h=d.get("left"),o=d.get("top");d.set("originalLeft",h);d.set("originalTop",o);d.set("left",h-b);d.set("top",o-a);d.setCoords();d.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(b){this._restoreObjectsState();this.objects.push(b);b.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(b){this._restoreObjectsState();
e(this.objects,b);b.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(b,a){if(typeof a=="function")this.set(b,a(this[b]));else if(b==="fill"||b==="opacity"){var d=this.objects.length;for(this[b]=a;d--;)this.objects[d].set(b,a)}else this[b]=a;return this},contains:function(b){return this.objects.indexOf(b)>-1},toObject:function(){return p(this.callSuper("toObject"),{objects:k(this.objects,"clone")})},render:function(b){b.save();
this.transform(b);for(var a=Math.max(this.scaleX,this.scaleY),d=0,h;h=this.objects[d];d++){var o=h.borderScaleFactor;h.borderScaleFactor=a;h.render(b);h.borderScaleFactor=o}this.hideBorders||this.drawBorders(b);this.hideCorners||this.drawCorners(b);b.restore();this.setCoords()},item:function(b){return this.getObjects()[b]},complexity:function(){return this.getObjects().reduce(function(b,a){b+=typeof a.complexity=="function"?a.complexity():0;return b},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,
this);return this},_restoreObjectState:function(b){var a=this.get("left"),d=this.get("top"),h=this.getAngle()*(Math.PI/180);b.get("originalLeft");b.get("originalTop");var o=Math.cos(h)*b.get("top")+Math.sin(h)*b.get("left");h=-Math.sin(h)*b.get("top")+Math.cos(h)*b.get("left");b.setAngle(b.getAngle()+this.getAngle());b.set("left",a+h*this.get("scaleX"));b.set("top",d+o*this.get("scaleY"));b.set("scaleX",b.get("scaleX")*this.get("scaleX"));b.set("scaleY",b.get("scaleY")*this.get("scaleY"));b.setCoords();
b.hideCorners=false;b.setActive(false);b.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(b){b.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(b){this.forEachObject(function(a){a.setActive(b)});
return this},forEachObject:function(b,a){for(var d=this.getObjects(),h=d.length;h--;)b.call(a,d[h],h,d);return this},_setOpacityIfSame:function(){var b=this.getObjects(),a=b[0]?b[0].get("opacity"):1;if(b.every(function(d){return d.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var b=[],a=[],d,h;h=0;for(var o=this.objects.length;h<o;++h){d=this.objects[h];d.setCoords();for(var q in d.oCoords){b.push(d.oCoords[q].x);a.push(d.oCoords[q].y)}}d=c(b);h=m(b);b=c(a);a=m(a);h=h-d;a=a-b;this.width=
h;this.height=a;this.left=d+h/2;this.top=b+a/2},containsPoint:function(b){var a=this.get("width")/2,d=this.get("height")/2,h=this.get("left"),o=this.get("top");return h-a<b.x&&h+a>b.x&&o-d<b.y&&o+d>b.y},toGrayscale:function(){for(var b=this.objects.length;b--;)this.objects[b].toGrayscale()}});g.Group.fromObject=function(b){return new g.Group(b.objects,b)}}})();
(function(){var g=this.fabric||(this.fabric={}),p=g.util.object.extend,c=g.util.object.clone;if(g.Text)console.warn("fabric.Text is already defined");else if(g.Object){g.Text=g.util.createClass(g.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(m,k){this.originalState={};this.initStateProperties();this.text=m;this.setOptions(k);p(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},
initStateProperties:function(){var m;if((m=this.constructor)&&(m=m.superclass)&&(m=m.prototype)&&(m=m.stateProperties)&&m.clone){this.stateProperties=m.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(m){var k=Cufon.textOptions||(Cufon.textOptions={});k.left=this.left;k.top=this.top;k.context=m;k.color=this.fill;var e=this._initDummyElement();
this.transform(m);Cufon.replaceElement(e,{separate:"none",fontFamily:this.fontfamily});this.width=k.width;this.height=k.height},_initDummyElement:function(){var m=document.createElement("div");m.innerHTML=this.text;m.style.fontSize="40px";m.style.fontWeight="400";m.style.fontStyle="normal";m.style.letterSpacing="normal";m.style.color="#000000";m.style.fontWeight="600";m.style.fontFamily="Verdana";return m},render:function(m){m.save();this._render(m);if(this.active){this.drawBorders(m);this.drawCorners(m)}m.restore()},
toObject:function(){return p(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(m){this.set("fill",m);return this},setFontsize:function(m){this.set("fontsize",m);this.setCoords();return this},getText:function(){return this.text},setText:function(m){this.set("text",m);this.setCoords();return this},set:function(m,k){this[m]=k;if(m==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,
"$1"+k+"$3");return this}});g.Text.fromObject=function(m){return new g.Text(m.text,c(m))};g.Text.fromElement=function(){}}else console.warn("fabric.Text requires fabric.Object")})();
(function(){var g=fabric.util.object.extend;if(!this.fabric)this.fabric={};if(this.fabric.Image)console.warn("fabric.Image is already defined.");else if(fabric.Object){fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(p,c){this.callSuper("initialize",c);this._initElement(p);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(p){this._element=
p;return this},getNormalizedSize:function(p,c,m){if(m&&c&&p.width>p.height&&p.width/p.height<c/m){normalizedWidth=~~(p.width*m/p.height);normalizedHeight=m}else if(m&&(p.height==p.width||p.height>p.width||p.height>m)){normalizedWidth=~~(p.width*m/p.height);normalizedHeight=m}else if(c&&c<p.width){normalizedHeight=~~(p.height*c/p.width);normalizedWidth=c}else{normalizedWidth=p.width;normalizedHeight=p.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var p=this.getElement();
return{width:p.width,height:p.height}},setBorderVisibility:function(p){this._resetWidthHeight();this._adjustWidthHeightToBorders(p);this.setCoords()},setCornersVisibility:function(p){this.cornervisibility=!!p},render:function(p,c){p.save();c||this.transform(p);this._render(p);if(this.active&&!c){this.drawBorders(p);this.hideCorners||this.drawCorners(p)}p.restore()},toObject:function(){return g(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},toString:function(){return'#<fabric.Image: { src: "'+
this.getSrc()+'" }>'},clone:function(p){this.constructor.fromObject(this.toObject(),p)},toGrayscale:function(p){if(!this.__isGrayscaled){var c=this.getElement(),m=document.createElement("canvas"),k=document.createElement("img"),e=this;m.width=c.width;m.height=c.height;m.getContext("2d").drawImage(c,0,0);fabric.Element.toGrayscale(m);k.onload=function(){e.setElement(k);p&&p();k.onload=m=c=imageData=null};k.width=c.width;k.height=c.height;k.src=m.toDataURL("image/png");this.__isGrayscaled=true;return this}},
_render:function(p){var c=this.getOriginalSize();p.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.height)},_adjustWidthHeightToBorders:function(p){if(p){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var p=this.getElement();this.set("width",p.width);this.set("height",p.height)},_initElement:function(p){this.setElement(fabric.util.getById(p));fabric.util.addClass(this.getElement(),
fabric.Image.CSS_CANVAS)},_initConfig:function(p){this.setOptions(p);this._setBorder();this._setWidthHeight(p)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var p=2*this.currentBorder;this.width=(this.getElement().width||0)+p;this.height=(this.getElement().height||0)+p},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(p,c){var m=document.createElement("img"),k=p.src;if(p.width)m.width=
p.width;if(p.height)m.height=p.height;m.onload=function(){c&&c(new fabric.Image(m,p));m=m.onload=null};m.src=k};fabric.Image.fromURL=function(p,c,m){var k=document.createElement("img");k.onload=function(){c&&c(new fabric.Image(k,m));k=k.onload=null};k.src=p}}else console.warn("fabric.Object is required for fabric.Image initialization")})();