fabric.js/dist/all.min.js

168 lines
81 KiB
JavaScript

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