fabric.js/dist/all.min.js

167 lines
81 KiB
JavaScript

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