First stab at centering guidelines and snapping to a center (vertical/horizontal).

This commit is contained in:
kangax 2010-10-30 21:47:15 -04:00
parent f497327131
commit 45795824ac
9 changed files with 315 additions and 361 deletions

21
dist/all.js vendored
View file

@ -3671,6 +3671,19 @@ fabric.util.animate = animate;
/* NOOP */
},
/**
* Callback; invoked every time active object is moved
* @method onObjectMove
* @param {fabric.Object} object that's being moved
*/
onObjectMove: null,
/**
* Callback; invoked when a mouseup event occurs, and at the end of all other transformations
* @method onMouseUp
*/
onMouseUp: null,
/**
* Calculates canvas element offset relative to the document
* This method is also attached as "resize" event handler of window
@ -3998,12 +4011,17 @@ fabric.util.animate = animate;
this.renderAll();
this._setCursorFromEvent(e, target);
this._setCursor('');
var _this = this;
setTimeout(function () {
_this._setCursorFromEvent(e, target);
}, 50);
if (this.onMouseUp) {
this.onMouseUp();
}
},
_shouldClearSelection: function (e) {
@ -4331,6 +4349,9 @@ fabric.util.animate = animate;
}
else {
this._translateObject(x, y);
if (this.onObjectMove) {
this.onObjectMove(this._currentTransform.target);
}
}
this.renderAll();
}

View file

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

Binary file not shown.

386
dist/all.min.js vendored
View file

@ -1,196 +1,196 @@
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 m(g){return g<10?"0"+g:g}function o(g){p.lastIndex=0;return p.test(g)?'"'+g.replace(p,function(n){var q=a[n];return typeof q==="string"?q:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+g+'"'}function f(g,n){var q,s,w,y,A=l,u,v=n[g];if(v&&typeof v==="object"&&typeof v.toJSON==="function")v=v.toJSON(g);if(typeof c==="function")v=c.call(n,g,v);switch(typeof v){case "string":return o(v);case "number":return isFinite(v)?String(v):"null";case "boolean":case "null":return String(v);
case "object":if(!v)return"null";l+=e;u=[];if(Object.prototype.toString.apply(v)==="[object Array]"){y=v.length;for(q=0;q<y;q+=1)u[q]=f(q,v)||"null";w=u.length===0?"[]":l?"[\n"+l+u.join(",\n"+l)+"\n"+A+"]":"["+u.join(",")+"]";l=A;return w}if(c&&typeof c==="object"){y=c.length;for(q=0;q<y;q+=1){s=c[q];if(typeof s==="string")if(w=f(s,v))u.push(o(s)+(l?": ":":")+w)}}else for(s in v)if(Object.hasOwnProperty.call(v,s))if(w=f(s,v))u.push(o(s)+(l?": ":":")+w);w=u.length===0?"{}":l?"{\n"+l+u.join(",\n"+l)+
"\n"+A+"}":"{"+u.join(",")+"}";l=A;return w}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+m(this.getUTCMonth()+1)+"-"+m(this.getUTCDate())+"T"+m(this.getUTCHours())+":"+m(this.getUTCMinutes())+":"+m(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,l,e,a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},c;if(typeof JSON.stringify!=="function")JSON.stringify=function(g,n,q){var s;e=l="";if(typeof q==="number")for(s=0;s<q;s+=1)e+=" ";else if(typeof q==="string")e=q;if((c=n)&&typeof n!=="function"&&(typeof n!=="object"||typeof n.length!=="number"))throw Error("JSON.stringify");return f("",
{"":g})};if(typeof JSON.parse!=="function")JSON.parse=function(g,n){function q(w,y){var A,u,v=w[y];if(v&&typeof v==="object")for(A in v)if(Object.hasOwnProperty.call(v,A)){u=q(v,A);if(u!==undefined)v[A]=u;else delete v[A]}return n.call(w,y,v)}var s;g=String(g);h.lastIndex=0;if(h.test(g))g=g.replace(h,function(w){return"\\u"+("0000"+w.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,""))){s=eval("("+g+")");return typeof n==="function"?q({"":s},""):s}throw new SyntaxError("JSON.parse");}})();(function(){var m=document.defaultView;if(m&&m.getComputedStyle)if(m.getComputedStyle(document.documentElement,"")===null)m.getComputedStyle=function(o){return o.style}})();
var Cufon=function(){function m(t){var b=this.face=t.face;this.glyphs=t.glyphs;this.w=t.w;this.baseSize=parseInt(b["units-per-em"],10);this.family=b["font-family"].toLowerCase();this.weight=b["font-weight"];this.style=b["font-style"]||"normal";this.viewBox=function(){var d=b.bbox.split(/\s+/);d={minX:parseInt(d[0],10),minY:parseInt(d[1],10),maxX:parseInt(d[2],10),maxY:parseInt(d[3],10)};d.width=d.maxX-d.minX;d.height=d.maxY-d.minY;d.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")};
return d}();this.ascent=-parseInt(b.ascent,10);this.descent=-parseInt(b.descent,10);this.height=-this.ascent+this.descent}function o(){var t={},b={oblique:"italic",italic:"oblique"};this.add=function(d){(t[d.style]||(t[d.style]={}))[d.weight]=d};this.get=function(d,k){var r=t[d]||t[b[d]]||t.normal||t.italic||t.oblique;if(!r)return null;k={normal:400,bold:700}[k]||parseInt(k,10);if(r[k])return r[k];var x={1:1,99:0}[k%100],z=[],B,C;if(x===undefined)x=k>400;if(k==500)k=400;for(var G in r){G=parseInt(G,
10);if(!B||G<B)B=G;if(!C||G>C)C=G;z.push(G)}if(k<B)k=B;if(k>C)k=C;z.sort(function(F,H){return(x?F>k&&H>k?F<H:F>H:F<k&&H<k?F>H:F<H)?-1:1});return r[z[0]]}}function f(t){var b={},d={};this.get=function(k){return b[k]!=undefined?b[k]:t[k]};this.getSize=function(k,r){return d[k]||(d[k]=new q.Size(this.get(k),r))};this.extend=function(k){for(var r in k)b[r]=k[r];return this}}function h(t,b,d){if(t.addEventListener)t.addEventListener(b,d,false);else t.attachEvent&&t.attachEvent("on"+b,function(){return d.call(t,
window.event)})}function p(t){var b={};return function(d){b.hasOwnProperty(d)||(b[d]=t.apply(null,arguments));return b[d]}}function l(t){return document.getElementsByTagName(t)}function e(){for(var t={},b,d=0,k=arguments.length;d<k;++d)for(b in arguments[d])t[b]=arguments[d][b];return t}function a(t,b,d,k,r,x){var z=k.separate;if(z=="none")return u[k.engine].apply(null,arguments);var B=document.createDocumentFragment(),C=b.split(D[z]),G=z=="words";if(G&&s){/^\s/.test(b)&&C.unshift("");/\s$/.test(b)&&
C.push("")}for(var F=0,H=C.length;F<H;++F)(z=u[k.engine](t,G?q.textAlign(C[F],d,F,H):C[F],d,k,r,x,F<H-1))&&B.appendChild(z);return B}function c(t,b){var d,k,r,x;r=w.get(t);if(!r.options){b.hover&&b.hoverables[t.nodeName.toLowerCase()]&&y.attach(t);r.options=b}for(var z=t.firstChild;z;z=r){r=z.nextSibling;x=false;if(z.nodeType==1){if(!z.firstChild)continue;if(/cufon/.test(z.className))x=true;else{arguments.callee(z,b);continue}}k||(k=q.getStyle(t).extend(b));if(!d)a:{(d=k)||(d=q.getStyle(t));for(var B=
q.quotedList(d.get("fontFamily").toLowerCase()),C=void 0,G=0,F=B.length;G<F;++G){C=B[G];if(v[C]){d=v[C].get(d.get("fontStyle"),d.get("fontWeight"));break a}}d=null}if(d)if(x)u[b.engine](d,null,k,b,z,t);else{x=z.data;if(x!=="")(x=a(d,x,k,b,z,t))?z.parentNode.replaceChild(x,z):z.parentNode.removeChild(z)}}}var g=function(){return g.replace.apply(null,arguments)},n=g.DOM={ready:function(){var t=false,b={loaded:1,complete:1},d=[],k=function(){if(!t){t=true;for(var r;r=d.shift();r());}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",
k,false);window.addEventListener("pageshow",k,false)}!window.opera&&document.readyState&&function(){b[document.readyState]?k():setTimeout(arguments.callee,10)}();document.readyState&&document.createStyleSheet&&function(){try{document.body.doScroll("left");k()}catch(r){setTimeout(arguments.callee,1)}}();h(window,"load",k);return function(r){if(arguments.length)t?r():d.push(r);else k()}}()},q=g.CSS={Size:function(t,b){this.value=parseFloat(t);this.unit=String(t).match(/[a-z%]*$/)[0]||"px";this.convert=
function(d){return d/b*this.value};this.convertFrom=function(d){return d/this.value*b};this.toString=function(){return this.value+this.unit}},getStyle:function(t){return new f(t.style)},quotedList:p(function(t){for(var b=[],d=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,k;k=d.exec(t);)b.push(k[3]||k[1]);return b}),ready:function(){var t=false,b=[],d=Object.prototype.propertyIsEnumerable?l("style"):{length:0},k=l("link");n.ready(function(){for(var r=0,x,z=0,B=k.length;x=k[z],z<B;++z)!x.disabled&&x.rel.toLowerCase()==
"stylesheet"&&++r;if(document.styleSheets.length>=d.length+r)for(t=true;r=b.shift();r());else setTimeout(arguments.callee,10)});return function(r){t?r():b.push(r)}}(),supports:function(t,b){var d=document.createElement("span").style;if(d[t]===undefined)return false;d[t]=b;return d[t]===b},textAlign:function(t,b,d,k){if(b.get("textAlign")=="right"){if(d>0)t=" "+t}else if(d<k-1)t+=" ";return t},textDecoration:function(t,b){b||(b=this.getStyle(t));for(var d={underline:null,overline:null,"line-through":null},
k=t;k.parentNode&&k.parentNode.nodeType==1;){var r=true;for(var x in d)if(!d[x]){if(b.get("textDecoration").indexOf(x)!=-1)d[x]=b.get("color");r=false}if(r)break;b=this.getStyle(k=k.parentNode)}return d},textShadow:p(function(t){if(t=="none")return null;for(var b=[],d={},k,r=0,x=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;k=x.exec(t);)if(k[0]==","){b.push(d);d={};r=0}else if(k[1])d.color=k[1];else d[["offX","offY","blur"][r++]]=k[2];b.push(d);return b}),color:p(function(t){var b={};
b.color=t.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(d,k,r){b.opacity=parseFloat(r);return"rgb("+k+")"});return b}),textTransform:function(t,b){return t[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[b.get("textTransform")]||"toString"]()}},s=" ".split(/\s+/).length==0,w=new function(){var t={},b=0;this.get=function(d){d=d.cufid||(d.cufid=++b);return t[d]||(t[d]={})}},y=new (function(){function t(k){k=k.relatedTarget;var r;if(!(r=!k))r=this.contains?this.contains(k):this.compareDocumentPosition(k)&
16;r||d(this)}function b(){d(this)}function d(k){setTimeout(function(){g.replace(k,w.get(k).options,true)},10)}this.attach=function(k){if(k.onmouseenter===undefined){h(k,"mouseover",t);h(k,"mouseout",t)}else{h(k,"mouseenter",b);h(k,"mouseleave",b)}}}),A=[],u={},v={},E={enableTextDecoration:false,engine:null,hover:false,hoverables:{a:true},printable:true,selector:window.Sizzle||window.jQuery&&function(t){return jQuery(t)}||window.dojo&&dojo.query||window.$$&&function(t){return $$(t)}||window.$&&function(t){return $(t)}||
document.querySelectorAll&&function(t){return document.querySelectorAll(t)}||l,separate:"words",textShadow:"none"},D={words:/\s+/,characters:""};g.now=function(){n.ready();return g};g.refresh=function(){for(var t=A.splice(0,A.length),b=0,d=t.length;b<d;++b)g.replace.apply(null,t[b]);return g};g.registerEngine=function(t,b){if(!b)return g;u[t]=b;return g.set("engine",t)};g.registerFont=function(t){t=new m(t);var b=t.family;v[b]||(v[b]=new o);v[b].add(t);return g.set("fontFamily",'"'+b+'"')};g.replace=
function(t,b,d){b=e(E,b);if(!b.engine)return g;if(typeof b.textShadow=="string")b.textShadow=q.textShadow(b.textShadow);d||A.push(arguments);if(t.nodeType||typeof t=="string")t=[t];q.ready(function(){for(var k=0,r=t.length;k<r;++k){var x=t[k];typeof x=="string"?g.replace(b.selector(x),b,true):c(x,b)}});return g};g.replaceElement=function(t,b){b=e(E,b);if(typeof b.textShadow=="string")b.textShadow=q.textShadow(b.textShadow);return c(t,b)};g.engines=u;g.fonts=v;g.getOptions=function(){return e(E)};
g.set=function(t,b){E[t]=b;return g};return g}();
Cufon.registerEngine("canvas",function(){var m=document.createElement("canvas");if(!(!m||!m.getContext||!m.getContext.apply)){m=null;var o=Cufon.CSS.supports("display","inline-block");m=!o&&(document.compatMode=="BackCompat"||/frameset|transitional/i.test(document.doctype.publicId));var f=document.createElement("style");f.type="text/css";f.appendChild(document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(m?
"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(o?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}"));document.getElementsByTagName("head")[0].appendChild(f);return function(h,p,l,e,a,c){function g(C,G){B.strokeStyle=G;B.beginPath();B.moveTo(0,
C);B.lineTo(z,C);B.stroke()}function n(){for(var C=0,G=x.length;C<G;++C){var F=h.glyphs[x[C]]||h.missingGlyph;if(F){B.beginPath();if(F.d)if(F.code)for(var H=F.code,L=B,I=0,M=H.length;I<M;++I){var K=H[I];L[K.m].apply(L,K.a)}else{H=F;L="m"+F.d;I=B;K=M=0;var N=[],Q=/([mrvxe])([^a-z]*)/g,P=void 0,O=0;a:for(;P=Q.exec(L);++O){var J=P[2].split(",");switch(P[1]){case "v":N[O]={m:"bezierCurveTo",a:[M+~~J[0],K+~~J[1],M+~~J[2],K+~~J[3],M+=~~J[4],K+=~~J[5]]};break;case "r":N[O]={m:"lineTo",a:[M+=~~J[0],K+=~~J[1]]};
break;case "m":N[O]={m:"moveTo",a:[M=~~J[0],K=~~J[1]]};break;case "x":N[O]={m:"closePath"};break;case "e":break a}I[N[O].m].apply(I,N[O].a)}H.code=N}B.fill();B.translate(Number(F.w||h.w)+y,0)}}}var q=p===null,s=h.viewBox,w=l.getSize("fontSize",h.baseSize),y=l.get("letterSpacing");y=y=="normal"?0:w.convertFrom(parseInt(y,10));var A=0,u=0,v=0,E=0,D=e.textShadow,t=[];if(D)for(var b=0,d=D.length;b<d;++b){var k=D[b],r=w.convertFrom(parseFloat(k.offX));k=w.convertFrom(parseFloat(k.offY));t[b]=[r,k];if(k<
A)A=k;if(r>u)u=r;if(k>v)v=k;if(r<E)E=r}var x=Cufon.CSS.textTransform(q?a.alt:p,l).split(""),z=0;k=null;b=0;for(d=x.length;b<d;++b)if(r=h.glyphs[x[b]]||h.missingGlyph)z+=k=Number(r.w||h.w)+y;if(k===null)return null;u+=s.width-k;E+=s.minX;if(q){q=a;b=a.firstChild}else{q=document.createElement("span");q.className="cufon cufon-canvas";q.alt=p;b=document.createElement("canvas");q.appendChild(b);if(e.printable){d=document.createElement("span");d.className="cufon-alt";d.appendChild(document.createTextNode(p));
q.appendChild(d)}}p=q.style;d=b.style;a=w.convert(s.height-A+v);v=Math.ceil(a);a=v/a;b.width=Math.ceil(w.convert(z+u-E)*a);b.height=v;A+=s.minY;d.top=Math.round(w.convert(A-h.ascent))+"px";d.left=Math.round(w.convert(E))+"px";u=Math.ceil(w.convert(z*a));d=u+"px";w=w.convert(h.height);Cufon.textOptions.width=u;Cufon.textOptions.height=w;if(o){p.width=d;p.height=w+"px"}else{p.paddingLeft=d;p.paddingBottom=w-1+"px"}var B=Cufon.textOptions.context||b.getContext("2d");s=v/s.height;B.save();B.scale(s,s);
B.translate(-E-1/s*b.width/2+(Cufon.fonts[h.family].offsetLeft||0),-A-1/s*b.height/2);B.lineWidth=h.face["underline-thickness"];B.save();e=e.enableTextDecoration?Cufon.CSS.textDecoration(c,l):{};e.underline&&g(-h.face["underline-position"],e.underline);e.overline&&g(h.ascent,e.overline);B.fillStyle=Cufon.textOptions.color||l.get("color");if(D){b=0;for(d=D.length;b<d;++b){k=D[b];B.save();B.fillStyle=k.color;B.translate.apply(B,t[b]);n();B.restore()}}n();B.restore();B.restore();e["line-through"]&&g(-h.descent,
e["line-through"]);return q}}}());
Cufon.registerEngine("vml",function(){function m(f,h){if(/px$/i.test(h))return parseFloat(h);var p=f.style.left,l=f.runtimeStyle.left;f.runtimeStyle.left=f.currentStyle.left;f.style.left=h;var e=f.style.pixelLeft;f.style.left=p;f.runtimeStyle.left=l;return e}if(document.namespaces){document.namespaces.cvml==null&&document.namespaces.add("cvml","urn:schemas-microsoft-com:vml");var o=document.createElement("cvml:shape");o.style.behavior="url(#default#VML)";if(o.coordsize){o=null;document.write('<style type="text/css">.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}</style>');
return function(f,h,p,l,e,a,c){var g=h===null;if(g)h=e.alt;var n=f.viewBox,q;if(!(q=p.computedFontSize)){q=Cufon.CSS.Size;var s;s=p.get("fontSize");s=m(a,/(?:em|ex|%)$/i.test(s)?"1em":s);q=p.computedFontSize=new q(s+"px",f.baseSize)}q=q;s=p.computedLSpacing;if(s==undefined){s=p.get("letterSpacing");p.computedLSpacing=s=s=="normal"?0:~~q.convertFrom(m(a,s))}var w;if(g){w=e;e=e.firstChild}else{w=document.createElement("span");w.className="cufon cufon-vml";w.alt=h;e=document.createElement("span");e.className=
"cufon-vml-canvas";w.appendChild(e);if(l.printable){var y=document.createElement("span");y.className="cufon-alt";y.appendChild(document.createTextNode(h));w.appendChild(y)}c||w.appendChild(document.createElement("cvml:shape"))}c=w.style;var A=e.style,u=q.convert(n.height);y=Math.ceil(u);u=y/u;var v=n.minX,E=n.minY;A.height=y;A.top=Math.round(q.convert(E-f.ascent));A.left=Math.round(q.convert(v));c.height=q.convert(f.height)+"px";l.enableTextDecoration&&Cufon.CSS.textDecoration(a,p);a=p.get("color");
h=Cufon.CSS.textTransform(h,p).split("");A=p=0;var D=null,t;l=l.textShadow;for(var b=0,d=0,k=h.length;b<k;++b)if(t=f.glyphs[h[b]]||f.missingGlyph)p+=D=~~(t.w||f.w)+s;if(D===null)return null;t=-v+p+(n.width-D);b=q.convert(t*u);D=Math.round(b);var r=t+","+n.height,x,z="r"+r+"nsnf";for(b=0;b<k;++b)if(t=f.glyphs[h[b]]||f.missingGlyph){if(g){n=e.childNodes[d];n.firstChild&&n.removeChild(n.firstChild)}else{n=document.createElement("cvml:shape");e.appendChild(n)}n.stroked="f";n.coordsize=r;n.coordorigin=
x=v-A+","+E;n.path=(t.d?"m"+t.d+"xe":"")+"m"+x+z;n.fillcolor=a;x=n.style;x.width=D;x.height=y;if(l){x=l[0];var B=l[1],C=Cufon.CSS.color(x.color),G,F=document.createElement("cvml:shadow");F.on="t";F.color=C.color;F.offset=x.offX+","+x.offY;if(B){G=Cufon.CSS.color(B.color);F.type="double";F.color2=G.color;F.offset2=B.offX+","+B.offY}F.opacity=C.opacity||G&&G.opacity||1;n.appendChild(F)}A+=~~(t.w||f.w)+s;++d}c.width=Math.max(Math.ceil(q.convert(p*u)),0);return w}}}}());
(function(){function m(l,e){for(var a in e)l[a]=e[a];return l}function o(l,e){var a=document.createElement(l);for(var c in e)if(c==="class")a.className=e[c];else if(c==="for")a.htmlFor=e[c];else a.setAttribute(c,e[c]);return a}var f=this.fabric||(this.fabric={}),h=Array.prototype.slice,p=Function.prototype.apply;f.util={};(function(){var l=Math.PI/180;f.util.removeFromArray=function(e,a){var c=e.indexOf(a);c!==-1&&e.splice(c,1);return e};f.util.degreesToRadians=function(e){return e*l};f.util.toFixed=
function(e,a){return parseFloat(Number(e).toFixed(a))};f.util.getRandomInt=function(e,a){return Math.floor(Math.random()*(a-e+1))+e};f.util.falseFunction=function(){return false}})();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(l,e){var a=this.length>>>0;e=Number(e)||0;e=Math[e<0?"ceil":"floor"](e);if(e<0)e+=a;for(;e<a;e++)if(e in this&&this[e]===l)return e;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(l,e){for(var a=0,c=this.length>>>0;a<c;a++)a in this&&
l.call(e,this[a],a,this)};if(!Array.prototype.map)Array.prototype.map=function(l,e){for(var a=[],c=0,g=this.length>>>0;c<g;c++)if(c in this)a[c]=l.call(e,this[c],c,this);return a};if(!Array.prototype.every)Array.prototype.every=function(l,e){for(var a=0,c=this.length>>>0;a<c;a++)if(a in this&&!l.call(e,this[a],a,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(l,e){for(var a=0,c=this.length>>>0;a<c;a++)if(a in this&&l.call(e,this[a],a,this))return true;return false};
if(!Array.prototype.filter)Array.prototype.filter=function(l,e){for(var a=[],c,g=0,n=this.length>>>0;g<n;g++)if(g in this){c=this[g];l.call(e,c,g,this)&&a.push(c)}return a};if(!Array.prototype.reduce)Array.prototype.reduce=function(l){var e=this.length>>>0,a=0,c;if(arguments.length>1)c=arguments[1];else{do{if(a in this){c=this[a++];break}if(++a>=e)throw new TypeError;}while(1)}for(;a<e;a++)if(a in this)c=l.call(null,c,this[a],a,this);return c};f.util.array={invoke:function(l,e){for(var a=h.call(arguments,
2),c=[],g=0,n=l.length;g<n;g++)c[g]=a.length?l[g][e].apply(l[g],a):l[g][e].call(l[g]);return c},min:function(l,e){var a=l.length-1,c=e?l[a][e]:l[a];if(e)for(;a--;){if(l[a][e]<c)c=l[a][e]}else for(;a--;)if(l[a]<c)c=l[a];return c},max:function(l,e){var a=l.length-1,c=e?l[a][e]:l[a];if(e)for(;a--;){if(l[a][e]>=c)c=l[a][e]}else for(;a--;)if(l[a]>=c)c=l[a];return c}};f.util.object={extend:m,clone:function(l){return m({},l)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,
"").replace(/[\s\xA0]+$/,"")};f.util.string={camelize:function(l){return l.replace(/-+(.)?/g,function(e,a){return a?a.toUpperCase():""})},capitalize:function(l){return l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(l){var e=this,a=h.call(arguments,1);return a.length?function(){return p.call(e,l,a.concat(h.call(arguments)))}:function(){return p.call(e,l,arguments)}};(function(){function l(){}var e;e=function(){for(var a in{toString:1})if(a===
"toString")return false;return true}()?function(a,c){if(c.toString!==Object.prototype.toString)a.prototype.toString=c.toString;if(c.valueOf!==Object.prototype.valueOf)a.prototype.valueOf=c.valueOf;for(var g in c)a.prototype[g]=c[g]}:function(a,c){for(var g in c)a.prototype[g]=c[g]};f.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var c=null,g=h.call(arguments,0);if(typeof g[0]==="function")c=g.shift();a.superclass=c;a.subclasses=[];if(c){l.prototype=c.prototype;a.prototype=
new l;c.subclasses.push(a)}c=0;for(var n=g.length;c<n;c++)e(a,g[c]);if(!a.prototype.initialize)a.prototype.initialize=emptyFunction;return a.prototype.constructor=a}})();(function(){function l(u){var v=Array.prototype.slice.call(arguments,1),E,D,t=v.length;for(D=0;D<t;D++){E=typeof u[v[D]];if(!/^(?:function|object|unknown)$/.test(E))return false}return true}function e(u,v){return function(E){v.call(g(u),E||window.event)}}function a(u,v){return function(E){if(y[u]&&y[u][v])for(var D=y[u][v],t=0,b=
D.length;t<b;t++)D[t].call(this,E||window.event)}}var c=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(v){return v.uniqueID};var u=0;return function(v){return v.__uniqueID||(v.__uniqueID="uniqueID__"+u++)}}(),g,n;(function(){var u={};g=function(v){return u[v]};n=function(v,E){u[v]=E}})();var q=l(document.documentElement,"addEventListener","removeEventListener")&&l(window,"addEventListener","removeEventListener"),s=l(document.documentElement,"attachEvent","detachEvent")&&
l(window,"attachEvent","detachEvent"),w={},y={};if(q){q=function(u,v,E){u.addEventListener(v,E,false)};s=function(u,v,E){u.removeEventListener(v,E,false)}}else if(s){q=function(u,v,E){var D=c(u);n(D,u);w[D]||(w[D]={});w[D][v]||(w[D][v]=[]);E={handler:E,wrappedHandler:e(D,E)};w[D][v].push(E);u.attachEvent("on"+v,E.wrappedHandler)};s=function(u,v,E){var D=c(u),t;if(w[D]&&w[D][v])for(var b=0,d=w[D][v].length;b<d;b++)if((t=w[D][v][b])&&t.handler===E){u.detachEvent("on"+v,t.wrappedHandler);w[D][v][b]=
null}}}else{q=function(u,v,E){var D=c(u);y[D]||(y[D]={});if(!y[D][v]){y[D][v]=[];var t=u["on"+v];t&&y[D][v].push(t);u["on"+v]=a(D,v)}y[D][v].push(E)};s=function(u,v,E){u=c(u);if(y[u]&&y[u][v]){v=y[u][v];u=0;for(var D=v.length;u<D;u++)v[u]===E&&v.splice(u,1)}}}f.util.addListener=q;f.util.removeListener=s;var A={};f.util.getPointer=function(u){var v=document.documentElement,E=document.body||{scrollLeft:0},D=document.documentElement,t=document.body||{scrollTop:0};return{x:u.pageX||(typeof u.clientX!=
"unknown"?u.clientX:0)+(v.scrollLeft||E.scrollLeft)-(v.clientLeft||0),y:u.pageY||(typeof u.clientY!="unknown"?u.clientY:0)+(D.scrollTop||t.scrollTop)-(D.clientTop||0)}};f.util.observeEvent=function(u,v){A[u]||(A[u]=[]);A[u].push(v)};f.util.fireEvent=function(u,v){var E=A[u];if(E)for(var D=0,t=E.length;D<t;D++)E[D]({memo:v})}})(this);(function(){var l=document.createElement("div"),e=typeof l.style.filter==="string",a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,c=function(g){return g};if(typeof l.style.opacity===
"string")c=function(g,n){g.style.opacity=n;return g};else if(e)c=function(g,n){var q=g.style;if(g.currentStyle&&!g.currentStyle.hasLayout)q.zoom=1;if(a.test(q.filter)){n=n>=0.9999?"":"alpha(opacity="+n*100+")";q.filter=q.filter.replace(a,n)}else q.filter+=" alpha(opacity="+n*100+")";return g};f.util.setStyle=function(g,n){var q=g.style;if(typeof n==="string"){g.style.cssText+=";"+n;return n.indexOf("opacity")>-1?c(g,n.match(/opacity:\s*(\d?\.?\d*)/)[1]):g}for(var s in n)if(s==="opacity")c(g,n[s]);
else q[s==="float"||s==="cssFloat"?typeof q.styleFloat==="undefined"?"cssFloat":"styleFloat":s]=n[s];return g}})();(function(){var l=document.documentElement.style,e="userSelect"in l?"userSelect":"MozUserSelect"in l?"MozUserSelect":"WebkitUserSelect"in l?"WebkitUserSelect":"KhtmlUserSelect"in l?"KhtmlUserSelect":"";f.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=f.util.falseFunction;if(e)a.style[e]="none";else if(typeof a.unselectable=="string")a.unselectable=
"on";return a}})();(function(){function l(a,c){e.load(a);c()}f.util.getScript=function(a,c){var g=document.getElementsByTagName("head")[0],n=document.createElement("script"),q=true;n.type="text/javascript";n.setAttribute("runat","server");n.onload=n.onreadystatechange=function(s){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;c(s||window.event);n=n.onload=n.onreadystatechange=null}};n.src=a;g.appendChild(n)};var e=this.Jaxer;if(e&&e.load)f.util.getScript=
l})();f.util.getById=function(l){return typeof l==="string"?document.getElementById(l):l};f.util.toArray=function(l){for(var e=[],a=l.length;a--;)e[a]=l[a];return e};f.util.makeElement=o;f.util.addClass=function(l,e){if((" "+l.className+" ").indexOf(" "+e+" ")===-1)l.className+=(l.className?" ":"")+e};f.util.wrapElement=function(l,e,a){if(typeof e==="string")e=o(e,a);l.parentNode&&l.parentNode.replaceChild(e,l);e.appendChild(l);return e};f.util.getElementOffset=function(l){var e=0,a=0;do{e+=l.offsetTop||
0;a+=l.offsetLeft||0;l=l.offsetParent}while(l);return{left:a,top:e}};f.util.animate=function(l){l||(l={});var e=+new Date,a=l.duration||500,c=e+a,g,n,q=l.onChange||function(){},s=l.easing||function(v){return-Math.cos(v*Math.PI)/2+0.5},w="startValue"in l?l.startValue:0,y="endValue"in l?l.endValue:100,A=w>y;l.onStart&&l.onStart();var u=setInterval(function(){g=+new Date;n=g>c?1:(g-e)/a;q(A?w-(w-y)*s(n):w+(y-w)*s(n));if(g>c){clearInterval(u);l.onComplete&&l.onComplete()}},10)};(function(){function l(){}
var e=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}],c=a.length;c--;)try{if(a[c]())return a[c]}catch(g){}}();f.util.request=function(a,c){c||(c={});var g=c.method?c.method.toUpperCase():"GET",n=c.onComplete||function(){},q=e(),s;q.onreadystatechange=function(){if(q.readyState===4){n(q);q.onreadystatechange=l}};if(g===
"GET"){s=null;if(typeof c.parameters=="string")a=a+(/\?/.test(a)?"&":"?")+c.parameters}q.open(g,a,true);if(g==="POST"||g==="PUT")q.setRequestHeader("Content-Type","application/x-www-form-urlencoded");q.send(s);return q}})()})(this);
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.string.capitalize,h=m.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"};m.parseTransformAttribute=function(){function l(q,s){var w=s[0];q[0]=Math.cos(w);q[1]=Math.sin(w);q[2]=-Math.sin(w);q[3]=Math.cos(w)}function e(q,s){var w=s.length===2?s[1]:s[0];q[0]=s[0];q[3]=w}function a(q,s){q[4]=s[0];if(s.length===
2)q[5]=s[1]}var c=[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*$"),
n=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 s=c.concat();if(!q||q&&!g.test(q))return s;q.replace(n,function(w){var y=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(w).filter(function(A){return A!==
""&&A!=null});w=y[1];y=y.slice(2).map(parseFloat);switch(w){case "translate":a(s,y);break;case "rotate":l(s,y);break;case "scale":e(s,y);break;case "skewX":s[2]=y[0];break;case "skewY":s[1]=y[0];break;case "matrix":s=y;break}});return s}}();m.parseSVGDocument=function(){var l=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,e=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,c){if(a){var g=m.util.toArray(a.getElementsByTagName("*")).filter(function(A){var u;if(u=l.test(A.tagName)){a:{for(A=A;A&&(A=A.parentNode);)if(A.nodeName==="pattern"){A=true;break a}A=false}u=!A}return u});if(!(!g||g&&!g.length)){var n=a.getAttribute("viewBox"),q=a.getAttribute("width"),s=a.getAttribute("height"),w=null,y=null;if(n&&(n=n.match(e))){parseInt(n[1],10);parseInt(n[2],10);w=parseInt(n[3],10);y=parseInt(n[4],10)}w=q?parseFloat(q):w;y=s?parseFloat(s):y;n={width:w,height:y};
g=m.parseElements(g,h(n));!g||g&&!g.length||c&&c(g,n)}}}}();o(m,{parseAttributes:function(l,e){if(l){var a,c,g={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName))g=m.parseAttributes(l.parentNode,e);var n=e.reduce(function(q,s){a=l.getAttribute(s);c=parseFloat(a);if(a){if((s==="fill"||s==="stroke")&&a==="none")a="";if(s==="fill-rule")a=a==="evenodd"?"destination-over":a;if(s==="transform")a=m.parseTransformAttribute(a);if(s in p)s=p[s];q[s]=isNaN(c)?a:c}return q},{});n=o(m.parseStyleAttribute(l),
n);return o(g,n)}},parseElements:function(l,e){var a=l.map(function(c){var g=m[f(c.tagName)];if(g&&g.fromElement)try{return g.fromElement(c,e)}catch(n){m.log(n.message||n)}});return a=a.filter(function(c){return c!=null})},parseStyleAttribute:function(l){var e={};if(l=l.getAttribute("style"))if(typeof l=="string"){l=l.split(";");l.pop();e=l.reduce(function(c,g){var n=g.split(":"),q=n[0].trim();n=n[1].trim();c[q]=n;return c},{})}else for(var a in l)if(typeof l[a]!=="undefined")e[a]=l[a];return e},
parsePointsAttribute:function(l){if(!l)return null;l=l.trim();var e=l.indexOf(",")>-1;l=l.split(/\s+/);var a=[];if(e){e=0;for(var c=l.length;e<c;e++){var g=l[e].split(",");a.push({x:parseFloat(g[0]),y:parseFloat(g[1])})}}else{e=0;for(c=l.length;e<c;e+=2)a.push({x:parseFloat(l[e]),y:parseFloat(l[e+1])})}return a}})})();
(function(){function m(f,h){arguments.length>0&&this.init(f,h)}var o=this.fabric||(this.fabric={});if(o.Point)o.warn("fabric.Point is already defined");else{o.Point=m;m.prototype={constructor:m,init:function(f,h){this.x=f;this.y=h},add:function(f){return new m(this.x+f.x,this.y+f.y)},addEquals:function(f){this.x+=f.x;this.y+=f.y;return this},scalarAdd:function(f){return new m(this.x+f,this.y+f)},scalarAddEquals:function(f){this.x+=f;this.y+=f;return this},subtract:function(f){return new m(this.x-
f.x,this.y-f.y)},subtractEquals:function(f){this.x-=f.x;this.y-=f.y;return this},scalarSubtract:function(f){return new m(this.x-f,this.y-f)},scalarSubtractEquals:function(f){this.x-=f;this.y-=f;return this},multiply:function(f){return new m(this.x*f,this.y*f)},multiplyEquals:function(f){this.x*=f;this.y*=f;return this},divide:function(f){return new m(this.x/f,this.y/f)},divideEquals:function(f){this.x/=f;this.y/=f;return this},eq:function(f){return this.x==f.x&&this.y==f.y},lt:function(f){return this.x<
f.x&&this.y<f.y},lte:function(f){return this.x<=f.x&&this.y<=f.y},gt:function(f){return this.x>f.x&&this.y>f.y},gte:function(f){return this.x>=f.x&&this.y>=f.y},lerp:function(f,h){return new m(this.x+(f.x-this.x)*h,this.y+(f.y-this.y)*h)},distanceFrom:function(f){var h=this.x-f.x;f=this.y-f.y;return Math.sqrt(h*h+f*f)},min:function(f){return new m(Math.min(this.x,f.x),Math.min(this.y,f.y))},max:function(f){return new m(Math.max(this.x,f.x),Math.max(this.y,f.y))},toString:function(){return this.x+
","+this.y},setXY:function(f,h){this.x=f;this.y=h},setFromPoint:function(f){this.x=f.x;this.y=f.y},swap:function(f){var h=this.x,p=this.y;this.x=f.x;this.y=f.y;f.x=h;f.y=p}}}})();
(function(){function m(f){arguments.length>0&&this.init(f)}var o=this.fabric||(this.fabric={});if(o.Intersection)o.warn("fabric.Intersection is already defined");else{o.Intersection=m;o.Intersection.prototype={init:function(f){this.status=f;this.points=[]},appendPoint:function(f){this.points.push(f)},appendPoints:function(f){this.points=this.points.concat(f)}};o.Intersection.intersectLineLine=function(f,h,p,l){var e,a=(l.x-p.x)*(f.y-p.y)-(l.y-p.y)*(f.x-p.x);e=(h.x-f.x)*(f.y-p.y)-(h.y-f.y)*(f.x-p.x);
p=(l.y-p.y)*(h.x-f.x)-(l.x-p.x)*(h.y-f.y);if(p!=0){a=a/p;e=e/p;if(0<=a&&a<=1&&0<=e&&e<=1){e=new m("Intersection");e.points.push(new o.Point(f.x+a*(h.x-f.x),f.y+a*(h.y-f.y)))}else e=new m("No Intersection")}else e=a==0||e==0?new m("Coincident"):new m("Parallel");return e};o.Intersection.intersectLinePolygon=function(f,h,p){for(var l=new m("No Intersection"),e=p.length,a=0;a<e;a++){var c=m.intersectLineLine(f,h,p[a],p[(a+1)%e]);l.appendPoints(c.points)}if(l.points.length>0)l.status="Intersection";return l};
o.Intersection.intersectPolygonPolygon=function(f,h){for(var p=new m("No Intersection"),l=f.length,e=0;e<l;e++){var a=m.intersectLinePolygon(f[e],f[(e+1)%l],h);p.appendPoints(a.points)}if(p.points.length>0)p.status="Intersection";return p};o.Intersection.intersectPolygonRectangle=function(f,h,p){var l=h.min(p),e=h.max(p);p=new o.Point(e.x,l.y);var a=new o.Point(l.x,e.y);h=m.intersectLinePolygon(l,p,f);p=m.intersectLinePolygon(p,e,f);e=m.intersectLinePolygon(e,a,f);f=m.intersectLinePolygon(a,l,f);
l=new m("No Intersection");l.appendPoints(h.points);l.appendPoints(p.points);l.appendPoints(e.points);l.appendPoints(f.points);if(l.points.length>0)l.status="Intersection";return l}}})();
(function(){function m(f){f?this._tryParsingColor(f):this.setSource([0,0,0,1])}var o=this.fabric||(this.fabric={});if(o.Color)o.warn("fabric.Color is already defined.");else{o.Color=m;o.Color.prototype={_tryParsingColor:function(f){var h=m.sourceFromHex(f);h||(h=m.sourceFromRgb(f));h&&this.setSource(h)},getSource:function(){return this._source},setSource:function(f){this._source=f},toRgb:function(){var f=this.getSource();return"rgb("+f[0]+","+f[1]+","+f[2]+")"},toRgba:function(){var f=this.getSource();
return"rgba("+f[0]+","+f[1]+","+f[2]+","+f[3]+")"},toHex:function(){var f=this.getSource(),h=f[0].toString(16);h=h.length==1?"0"+h:h;var p=f[1].toString(16);p=p.length==1?"0"+p:p;f=f[2].toString(16);f=f.length==1?"0"+f:f;return h.toUpperCase()+p.toUpperCase()+f.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(f){var h=this.getSource();h[3]=f;this.setSource(h);return this},toGrayscale:function(){var f=this.getSource(),h=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),
10);this.setSource([h,h,h,f[3]]);return this},toBlackWhite:function(f){var h=this.getSource(),p=(h[0]*0.3+h[1]*0.59+h[2]*0.11).toFixed(0);h=h[3];f=f||127;p=Number(p)<Number(f)?0:255;this.setSource([p,p,p,h]);return this},overlayWith:function(f){f instanceof m||(f=new m(f));var h=[],p=this.getAlpha(),l=this.getSource();f=f.getSource();for(var e=0;e<3;e++)h.push(Math.round(l[e]*0.5+f[e]*0.5));h[4]=p;this.setSource(h);return this}};o.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
o.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;o.Color.fromRgb=function(f){return m.fromSource(m.sourceFromRgb(f))};o.Color.sourceFromRgb=function(f){if(f=f.match(m.reRGBa))return[parseInt(f[1],10),parseInt(f[2],10),parseInt(f[3],10),f[4]?parseFloat(f[4]):1]};o.Color.fromRgba=m.fromRgb;o.Color.fromHex=function(f){return m.fromSource(m.sourceFromHex(f))};o.Color.sourceFromHex=function(f){if(f.match(m.reHex)){var h=f.slice(f.indexOf("#")+1),p=h.length===3;f=p?h.charAt(0)+h.charAt(0):h.substring(0,2);
var l=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(f,16),parseInt(l,16),parseInt(h,16),1]}};o.Color.fromSource=function(f){var h=new m;h.setSource(f);return h}}})();
(function(){if(fabric.Element)fabric.warn("fabric.Element is already defined.");else{var m=this.window,o=m.document,f=fabric.util.object.extend,h=fabric.util.string.capitalize,p=fabric.util.string.camelize,l=fabric.util.fireEvent,e=fabric.util.getPointer,a=fabric.util.getElementOffset,c=fabric.util.removeFromArray,g=fabric.util.addListener,n=fabric.util.removeListener,q=fabric.util.array.min,s=fabric.util.array.max,w=Math.sqrt,y=Math.pow,A=Math.atan2,u=Math.abs,v=Math.min,E=Math.max,D=Error("Could not initialize `canvas` element"),
t={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(b,d){this._groupSelector=null;this._objects=[];this._activeGroup=this._currentTransform=this._element=this._context=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._config={width:300,height:150};d=d||{};this._initElement(b);this._initConfig(d);d.overlayImage&&this.setOverlayImage(d.overlayImage);if(d.afterRender)this.afterRender=d.afterRender;
this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};f(fabric.Element.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,freeDrawingColor:"rgb(0, 0, 0)",freeDrawingLineWidth: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(b,d){if(b){var k=this,r=new Image;r.onload=function(){k.overlayImage=r;d&&d();r=r.onload=null};r.src=b}return this},_initElement:function(b){this._element=fabric.util.getById(b)||o.createElement("canvas");typeof this._element.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(this._element);if(typeof this._element.getContext==="undefined")throw D;if(!(this.contextTop=this._element.getContext("2d")))throw D;
b=this._element.width||0;var d=this._element.height||0;this._initWrapperElement(b,d);this._setElementStyle(b,d)},_initWrapperElement:function(b,d){var k=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(k,{width:b+"px",height:d+"px"});fabric.util.makeElementUnselectable(k);this.wrapper=k},_setElementStyle:function(b,d){fabric.util.setStyle(this.getElement(),{position:"absolute",width:b+"px",height:d+"px",left:0,top:0})},_initConfig:function(b){f(this._config,
b||{});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 b=this;this._onMouseDown=function(d){b.__onMouseDown(d)};this._onMouseUp=function(d){b.__onMouseUp(d)};this._onMouseMove=function(d){b.__onMouseMove(d)};this._onResize=function(){b.calcOffset()};g(this._element,"mousedown",this._onMouseDown);g(o,"mousemove",
this._onMouseMove);g(o,"mouseup",this._onMouseUp);g(m,"resize",this._onResize)},_createCanvasElement:function(b){var d=o.createElement("canvas");if(d){d.className=b;b=this._element.parentNode.insertBefore(d,this._element);b.width=this.getWidth();b.height=this.getHeight();b.style.width=this.getWidth()+"px";b.style.height=this.getHeight()+"px";b.style.position="absolute";b.style.left=0;b.style.top=0;typeof d.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(d);
if(typeof d.getContext==="undefined")throw D;fabric.util.makeElementUnselectable(b);return b}},_createCanvasContainer:function(){var b=this._createCanvasElement("canvas-container");this.contextContainerEl=b;this.contextContainer=b.getContext("2d")},_createCanvasBackground:function(){var b=this._createCanvasElement("canvas-container");this._contextBackgroundEl=b;this._contextBackground=b.getContext("2d")},getWidth:function(){return this._config.width},getHeight:function(){return this._config.height},
setWidth:function(b){return this._setDimension("width",b)},setHeight:function(b){return this._setDimension("height",b)},setDimensions:function(b){for(var d in b)this._setDimension(d,b[d]);return this},_setDimension:function(b,d){this.contextContainerEl[b]=d;this.contextContainerEl.style[b]=d+"px";this._contextBackgroundEl[b]=d;this._contextBackgroundEl.style[b]=d+"px";this._element[b]=d;this._element.style[b]=d+"px";this._element.parentNode.style[b]=d+"px";this._config[b]=d;this.calcOffset();this.renderAll();
return this},__onMouseUp:function(b){if(this.isDrawingMode&&this._isCurrentlyDrawing)this._finalizeDrawingPath();else{if(this._currentTransform){var d=this._currentTransform.target;if(d._scaling){l("object:scaled",{target:d});d._scaling=false}for(var k=this._objects.length;k--;)this._objects[k].setCoords();if(d.hasStateChanged()){d.isMoving=false;l("object:modified",{target:d})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(b);if(k=this.getActiveGroup()){k.hasStateChanged()&&
k.containsPoint(this.getPointer(b))&&l("group:modified",{target:k});k.setObjectsCoords();k.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(b,d);this._setCursor("");var r=this;setTimeout(function(){r._setCursorFromEvent(b,d)},50)}},_shouldClearSelection:function(b){var d=this.findTarget(b),k=this.getActiveGroup();return!d||d&&k&&!k.contains(d)&&k!==d&&!b.shiftKey},__onMouseDown:function(b){if(this.isDrawingMode){this._prepareForDrawing(b);
this._captureDrawingPath(b)}else if(!this._currentTransform){var d=this.findTarget(b),k=this.getPointer(b),r=this.getActiveGroup();if(this._shouldClearSelection(b)){this._groupSelector={ex:k.x,ey:k.y,top:0,left:0};this.deactivateAllWithDispatch()}else{d.saveState();d._findTargetCorner(b,this._offset)&&this.onBeforeScaleRotate(d);this._setupCurrentTransform(b,d);if(b.shiftKey&&(r||this.getActiveObject()))this._handleGroupLogic(b,d);else{d!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(d)}}this.renderAll()}},
getElement:function(){return this._element},deactivateAllWithDispatch:function(){var b=this.getActiveGroup();b&&l("before:group:destroyed",{target:b});this.deactivateAll();b&&l("after:group:destroyed");l("selection:cleared");return this},_setupCurrentTransform:function(b,d){var k="drag",r,x=e(b);if(r=d._findTargetCorner(b,this._offset))k=r==="ml"||r==="mr"?"scaleX":r==="mt"||r==="mb"?"scaleY":"rotate";this._currentTransform={target:d,action:k,scaleX:d.scaleX,scaleY:d.scaleY,offsetX:x.x-d.left,offsetY:x.y-
d.top,ex:x.x,ey:x.y,left:d.left,top:d.top,theta:d.theta,width:d.width*d.scaleX};this._currentTransform.original={left:d.left,top:d.top}},_handleGroupLogic:function(b,d){if(d.isType("group")){d=this.findTarget(b,true);if(!d||d.isType("group"))return}var k=this.getActiveGroup();if(k){if(k.contains(d)){k.remove(d);d.setActive(false);k.size()===1&&this.removeActiveGroup()}else k.add(d);l("group:selected",{target:k});k.setActive(true)}else{if(this._activeObject)if(d!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,
d]));k=this.getActiveGroup()}d.setActive(true)}k&&k.saveCoords()},_prepareForDrawing:function(b){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();b=this.getPointer(b);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(b.x);this._freeDrawingYPoints.push(b.y);this.contextTop.beginPath();this.contextTop.moveTo(b.x,b.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=
this.contextTop.lineJoin="round"},_captureDrawingPath:function(b){b=this.getPointer(b);this._freeDrawingXPoints.push(b.x);this._freeDrawingYPoints.push(b.y);this.contextTop.lineTo(b.x,b.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var b=q(this._freeDrawingXPoints),d=q(this._freeDrawingYPoints),k=s(this._freeDrawingXPoints),r=s(this._freeDrawingYPoints),x=[],z=this._freeDrawingXPoints,B=this._freeDrawingYPoints;x.push("M ",
z[0]-b," ",B[0]-d," ");for(var C=1;xPoint=z[C],yPoint=B[C];C++)x.push("L ",xPoint-b," ",yPoint-d," ");x=new fabric.Path(x.join(""));x.fill=null;x.stroke=this.freeDrawingColor;x.strokeWidth=this.freeDrawingLineWidth;this.add(x);x.set("left",b+(k-b)/2).set("top",d+(r-d)/2).setCoords();this.renderAll();l("path:created",{path:x})},__onMouseMove:function(b){if(this.isDrawingMode)this._isCurrentlyDrawing&&this._captureDrawingPath(b);else{var d=this._groupSelector;if(d!==null){var k=e(b);d.left=k.x-this._offset.left-
d.ex;d.top=k.y-this._offset.top-d.ey;this.renderTop()}else if(this._currentTransform){k=e(b);d=k.x;k=k.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){b.shiftKey||this._rotateObject(d,k);this._scaleObject(d,k)}else if(this._currentTransform.action==="scaleX")this._scaleObject(d,k,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(d,k,"y"):this._translateObject(d,k);this.renderAll()}else{k=this._element.style;if(d=this.findTarget(b)){this._setCursorFromEvent(b,
d);d.isActive()&&d.setCornersVisibility&&d.setCornersVisibility(true)}else{for(b=this._objects.length;b--;)this._objects[b].active||this._objects[b].setActive(false);k.cursor="default"}}}},_translateObject:function(b,d){var k=this._currentTransform.target;k.lockHorizontally||k.set("left",b-this._currentTransform.offsetX);k.lockVertically||k.set("top",d-this._currentTransform.offsetY)},_scaleObject:function(b,d,k){var r=this._currentTransform,x=this._offset,z=r.target;if(!z.lockScaling){var B=w(y(r.ey-
r.top-x.top,2)+y(r.ex-r.left-x.left,2));b=w(y(d-r.top-x.top,2)+y(b-r.left-x.left,2));z._scaling=true;if(k)if(k==="x")z.set("scaleX",r.scaleX*b/B);else k==="y"&&z.set("scaleY",r.scaleY*b/B);else{z.set("scaleX",r.scaleX*b/B);z.set("scaleY",r.scaleY*b/B)}}},_rotateObject:function(b,d){var k=this._currentTransform,r=this._offset;if(!k.target.lockRotation){var x=A(k.ey-k.top-r.top,k.ex-k.left-r.left);r=A(d-k.top-r.top,b-k.left-r.left);k.target.set("theta",r-x+k.theta)}},_setCursor:function(b){this._element.style.cursor=
b},_setCursorFromEvent:function(b,d){var k=this._element.style;if(d){var r=this.getActiveGroup();if(r=!!d._findTargetCorner&&(!r||!r.contains(d))&&d._findTargetCorner(b,this._offset))if(r in t)k.cursor=t[r];else{k.cursor="default";return false}else k.cursor="move"}else{k.cursor="default";return false}return true},_draw:function(b,d){d&&d.render(b)},_drawSelection:function(){var b=this._groupSelector,d=b.left,k=b.top,r=u(d),x=u(k);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(b.ex-
(d>0?0:-d),b.ey-(k>0?0:-k),r,x);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(b.ex+0.5-(d>0?0:r),b.ey+0.5-(k>0?0:x),r,x)},_findSelectedObjects:function(){var b=[],d=this._groupSelector.ex,k=this._groupSelector.ey,r=d+this._groupSelector.left,x=k+this._groupSelector.top,z=new fabric.Point(v(d,r),v(k,x));k=new fabric.Point(E(d,r),E(k,x));r=0;for(x=this._objects.length;r<x;++r){d=this._objects[r];if(d.intersectsWithRect(z,
k)||d.isContainedWithinRect(z,k)){d.setActive(true);b.push(d)}}if(b.length===1){this.setActiveObject(b[0]);l("object:selected",{target:b[0]})}else if(b.length>1){b=new fabric.Group(b);this.setActiveGroup(b);b.saveCoords();l("group:selected",{target:b})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);this.renderAll();return this},insertAt:function(b,d){this._objects.splice(d,0,b);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},
clearContext:function(b){b.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(b){var d=this._config.width,k=this._config.height,r=b?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);b||this.clearContext(r);r.fillStyle=this.backgroundColor;r.fillRect(0,0,d,k);b=this._objects.length;d=this.getActiveGroup();
k=new Date;if(b)for(var x=0;x<b;++x)if(!d||d&&!d.contains(this._objects[x]))this._draw(r,this._objects[x]);d&&this._draw(this.contextTop,d);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this.onFpsUpdate(~~(1E3/(new Date-k)));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 b=this.getActiveGroup();b&&b.render(this.contextTop);
this.afterRender&&this.afterRender();return this},containsPoint:function(b,d){var k=this.getPointer(b),r=this._normalizePointer(d,k);k=r.x;r=r.y;var x=d._getImageLines(d.oCoords);if((k=d._findCrossPoints(k,r,x))&&k%2===1||d._findTargetCorner(b,this._offset))return true;return false},_normalizePointer:function(b,d){var k=this.getActiveGroup(),r=d.x,x=d.y;if(k&&b.type!=="group"&&k.contains(b)){r-=k.left;x-=k.top}return{x:r,y:x}},findTarget:function(b,d){var k;this.getPointer(b);var r=this.getActiveGroup();
if(r&&!d&&this.containsPoint(b,r))return k=r;for(r=this._objects.length;r--;)if(this.containsPoint(b,this._objects[r])){this.relatedTarget=k=this._objects[r];break}return k},toDataURL:function(b){var d;b||(b="png");if(b==="jpeg"||b==="png"){this.renderAll(true);d=this.getElement().toDataURL("image/"+b);this.renderAll()}return d},toDataURLWithMultiplier:function(b,d){var k=this.getWidth(),r=this.getHeight(),x=k*d,z=r*d,B=this.getActiveObject();this.setWidth(x).setHeight(z);this.contextTop.scale(d,
d);B&&this.deactivateAll().renderAll();x=this.toDataURL(b);this.contextTop.scale(1/d,1/d);this.setWidth(k).setHeight(r);B&&this.setActiveObject(B);this.renderAll();return x},getPointer:function(b){b=e(b);return{x:b.x-this._offset.left,y:b.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(b){b.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(b,d){d=d||{};var k=function(){},r=d.onComplete||
k,x=d.onChange||k,z=this;fabric.util.animate({startValue:b.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(B){b.set("left",B);z.renderAll();x()},onComplete:function(){b.setCoords();r()}});return this},centerObjectV:function(b){b.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(b,d){d=d||{};var k=function(){},r=d.onComplete||k,x=d.onChange||k,z=this;fabric.util.animate({startValue:b.get("top"),endValue:this.getCenter().top,
duration:this.FX_DURATION,onChange:function(B){b.set("top",B);z.renderAll();x()},onComplete:function(){b.setCoords();r()}});return this},straightenObject:function(b){b.straighten();this.renderAll();return this},fxStraightenObject:function(b){b.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(b){return{objects:this._objects.map(function(d){if(!this.includeDefaultValues){var k=d.includeDefaultValues;d.includeDefaultValues=false}var r=d[b]();if(!this.includeDefaultValues)d.includeDefaultValues=k;return r},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(b,d){if(b){var k=JSON.parse(b);if(!(!k||k&&!k.objects)){this.clear();var r=this;this._enlivenObjects(k.objects,function(){r.backgroundColor=k.background;
d&&d()});return this}}},_enlivenObjects:function(b,d){var k=0,r=b.filter(function(z){return z.type==="image"}).length,x=this;b.forEach(function(z,B){if(z.type)switch(z.type){case "image":case "font":fabric[h(z.type)].fromObject(z,function(G){x.insertAt(G,B);++k===r&&d&&d()});break;default:var C=fabric[p(h(z.type))];C&&C.fromObject&&x.insertAt(C.fromObject(z),B);break}});r===0&&d&&d()},loadFromDatalessJSON:function(b,d){if(b){var k=typeof b==="string"?JSON.parse(b):b;if(!(!k||k&&!k.objects)){this.clear();
this.backgroundColor=k.background;this._enlivenDatalessObjects(k.objects,d)}}},_enlivenDatalessObjects:function(b,d){function k(C,G){r.insertAt(C,G);C.setCoords();++x===z&&d&&d()}var r=this,x=0,z=b.length;z===0&&d&&d();try{b.forEach(function(C,G){var F=C.paths?"paths":"path",H=C[F];delete C[F];if(typeof H!=="string")switch(C.type){case "image":case "text":fabric[h(C.type)].fromObject(C,function(I){k(I,G)});break;default:(F=fabric[p(h(C.type))])&&F.fromObject&&k(F.fromObject(C),G);break}else if(C.type===
"image")r.loadImageFromURL(H,function(I){I.setSourcePath(H);f(I,C);I.setAngle(C.angle);k(I,G)});else if(C.type==="text"){C.path=H;var L=fabric.Text.fromObject(C);fabric.util.getScript(H,function(){Object.prototype.toString.call(m.opera)==="[object Opera]"?setTimeout(function(){k(L,G)},500):k(L,G)})}else r.loadSVGFromURL(H,function(I){I=I.length>1?new fabric.PathGroup(I,C):I[0];I.setSourcePath(H);if(!(I instanceof fabric.PathGroup)){f(I,C);typeof C.angle!=="undefined"&&I.setAngle(C.angle)}k(I,G)})},
this)}catch(B){fabric.log(B.message)}},loadImageFromURL:function(){var b={};return function(d,k){function r(){var B=o.getElementById(b[d]);B.width&&B.height?k(new fabric.Image(B)):setTimeout(r,50)}var x=this;if(b[d])r();else{var z=new Image;z.onload=function(){z.onload=null;x._resizeImageToFit(z);var B=new fabric.Image(z);k(B)};z.className="canvas-img-clone";z.src=d;if(this.shouldCacheImages)b[d]=Element.identify(z);o.body.appendChild(z)}}}(),loadSVGFromURL:function(b,d){function k(z){if(z=z.responseXML)(z=
z.documentElement)&&fabric.parseSVGDocument(z,function(B,C){x.cache.set(b,{objects:B.invoke("toObject"),options:C});d(B,C)})}function r(){fabric.log("ERROR!")}var x=this;b=b.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(b,function(z){if(z)x.cache.get(b,function(B){B=x._enlivenCachedObject(B);d(B.objects,B.options)});else new Ajax.Request(b,{method:"get",onComplete:k,onFailure:r})})},_enlivenCachedObject:function(b){var d=b.objects;b=b.options;d=d.map(function(k){return fabric[h(k.type)].fromObject(k)});
return{objects:d,options:b}},remove:function(b){c(this._objects,b);this.renderAll();return b},fxRemove:function(b,d){var k=this;b.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){k.remove(b);typeof d==="function"&&d()}});return this},sendToBack:function(b){c(this._objects,b);this._objects.unshift(b);return this.renderAll()},bringToFront:function(b){c(this._objects,b);this._objects.push(b);return this.renderAll()},sendBackwards:function(b){var d=this._objects.indexOf(b),k=d;if(d!==
0){for(d=d-1;d>=0;--d)if(b.intersectsWithObject(this._objects[d])){k=d;break}c(this._objects,b);this._objects.splice(k,0,b)}return this.renderAll()},bringForward:function(b){var d=this.getObjects(),k=d.indexOf(b),r=k;if(k!==d.length-1){k=k+1;for(var x=this._objects.length;k<x;++k)if(b.intersectsWithObject(d[k])){r=k;break}c(d,b);d.splice(r,0,b)}this.renderAll()},setActiveObject:function(b){this._activeObject&&this._activeObject.setActive(false);this._activeObject=b;b.setActive(true);this.renderAll();
l("object:selected",{target:b});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(b){this._activeGroup=b;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var b=this.getActiveGroup();b&&b.destroy();return this.setActiveGroup(null)},item:function(b){return this.getObjects()[b]},deactivateAll:function(){for(var b=
this.getObjects(),d=0,k=b.length;d<k;d++)b[d].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(b,d){b+=d.complexity?d.complexity():0;return b},0)},dispose:function(){this.clear();n(this.getElement(),"mousedown",this._onMouseDown);n(o,"mouseup",this._onMouseUp);n(o,"mousemove",this._onMouseMove);n(m,"resize",this._onResize);return this},clone:function(b){var d=o.createElement("canvas");d.width=this.getWidth();
d.height=this.getHeight();var k=this.__clone||(this.__clone=new fabric.Element(d));return k.loadFromJSON(JSON.stringify(this.toJSON()),function(){b&&b(k)})},_toDataURL:function(b,d){this.clone(function(k){d(k.toDataURL(b))})},_toDataURLWithMultiplier:function(b,d,k){this.clone(function(r){k(r.toDataURLWithMultiplier(b,d))})},_resizeImageToFit:function(b){var d=b.width||b.offsetWidth,k=this.getWidth()/d;if(d)b.width=d*k},cache:{has:function(b,d){d(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=
function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};f(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(b){var d=b.getContext("2d");b=d.getImageData(0,0,b.width,b.height);var k=b.data,r=b.width,x=b.height,z,B;for(i=0;i<r;i++)for(j=0;j<x;j++){z=i*4*x+j*4;B=(k[z]+k[z+1]+k[z+2])/3;k[z]=B;k[z+1]=B;k[z+2]=B}d.putImageData(b,0,0)},supports:function(b){var d=o.createElement("canvas");typeof G_vmlCanvasManager!=="undefined"&&
G_vmlCanvasManager.initElement(d);if(!d||!d.getContext)return null;var k=d.getContext("2d");if(!k)return null;switch(b){case "getImageData":return typeof k.getImageData!=="undefined";case "toDataURL":return typeof d.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject}})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.object.clone,h=m.util.toFixed,p=m.util.string.capitalize,l=m.util.getPointer,e=Array.prototype.slice;if(!m.Object){m.Object=m.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 c=this.constructor.superclass.prototype[a];return arguments.length>1?c.apply(this,e.call(arguments,1)):c.call(this)},
initialize:function(a){this.setOptions(a);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(a){this.options=o(this._getOptions(),a)},_getOptions:function(){return o(f(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 c=m.Object.prototype.options;this.stateProperties.forEach(function(g){a[g]===c[g]&&delete a[g]});
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,c){if((a==="scaleX"||a==="scaleY")&&c<this.MIN_SCALE_LIMIT)c=this.MIN_SCALE_LIMIT;if(a==="angle")this.setAngle(c);else this[a]=c;return this},toggle:function(a){var c=this.get(a);typeof c==="boolean"&&this.set(a,!c);return this},setSourcePath:function(a){this.sourcePath=a;return this},get:function(a){return a==="angle"?this.getAngle():
this[a]},render:function(a,c){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]);c||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,c);if(this.active&&!c){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}a.restore()}},getWidth:function(){return this.width*this.scaleX},getHeight:function(){return this.height*
(function(){function z(b){return b<10?"0"+b:b}function l(b){m.lastIndex=0;return m.test(b)?'"'+b.replace(m,function(g){var o=e[g];return typeof o==="string"?o:"\\u"+("0000"+g.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+b+'"'}function f(b,g){var o,q,t,A,w=p,B,v=g[b];if(v&&typeof v==="object"&&typeof v.toJSON==="function")v=v.toJSON(b);if(typeof a==="function")v=a.call(g,b,v);switch(typeof v){case "string":return l(v);case "number":return isFinite(v)?String(v):"null";case "boolean":case "null":return String(v);
case "object":if(!v)return"null";p+=h;B=[];if(Object.prototype.toString.apply(v)==="[object Array]"){A=v.length;for(o=0;o<A;o+=1)B[o]=f(o,v)||"null";t=B.length===0?"[]":p?"[\n"+p+B.join(",\n"+p)+"\n"+w+"]":"["+B.join(",")+"]";p=w;return t}if(a&&typeof a==="object"){A=a.length;for(o=0;o<A;o+=1){q=a[o];if(typeof q==="string")if(t=f(q,v))B.push(l(q)+(p?": ":":")+t)}}else for(q in v)if(Object.hasOwnProperty.call(v,q))if(t=f(q,v))B.push(l(q)+(p?": ":":")+t);t=B.length===0?"{}":p?"{\n"+p+B.join(",\n"+p)+
"\n"+w+"}":"{"+B.join(",")+"}";p=w;return t}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+z(this.getUTCMonth()+1)+"-"+z(this.getUTCDate())+"T"+z(this.getUTCHours())+":"+z(this.getUTCMinutes())+":"+z(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var k=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
m=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,p,h,e={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},a;if(typeof JSON.stringify!=="function")JSON.stringify=function(b,g,o){var q;h=p="";if(typeof o==="number")for(q=0;q<o;q+=1)h+=" ";else if(typeof o==="string")h=o;if((a=g)&&typeof g!=="function"&&(typeof g!=="object"||typeof g.length!=="number"))throw Error("JSON.stringify");return f("",
{"":b})};if(typeof JSON.parse!=="function")JSON.parse=function(b,g){function o(t,A){var w,B,v=t[A];if(v&&typeof v==="object")for(w in v)if(Object.hasOwnProperty.call(v,w)){B=o(v,w);if(B!==undefined)v[w]=B;else delete v[w]}return g.call(t,A,v)}var q;b=String(b);k.lastIndex=0;if(k.test(b))b=b.replace(k,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(b.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){q=eval("("+b+")");return typeof g==="function"?o({"":q},""):q}throw new SyntaxError("JSON.parse");}})();(function(){var z=document.defaultView;if(z&&z.getComputedStyle)if(z.getComputedStyle(document.documentElement,"")===null)z.getComputedStyle=function(l){return l.style}})();
var Cufon=function(){function z(r){var s=this.face=r.face;this.glyphs=r.glyphs;this.w=r.w;this.baseSize=parseInt(s["units-per-em"],10);this.family=s["font-family"].toLowerCase();this.weight=s["font-weight"];this.style=s["font-style"]||"normal";this.viewBox=function(){var c=s.bbox.split(/\s+/);c={minX:parseInt(c[0],10),minY:parseInt(c[1],10),maxX:parseInt(c[2],10),maxY:parseInt(c[3],10)};c.width=c.maxX-c.minX;c.height=c.maxY-c.minY;c.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")};
return c}();this.ascent=-parseInt(s.ascent,10);this.descent=-parseInt(s.descent,10);this.height=-this.ascent+this.descent}function l(){var r={},s={oblique:"italic",italic:"oblique"};this.add=function(c){(r[c.style]||(r[c.style]={}))[c.weight]=c};this.get=function(c,d){var n=r[c]||r[s[c]]||r.normal||r.italic||r.oblique;if(!n)return null;d={normal:400,bold:700}[d]||parseInt(d,10);if(n[d])return n[d];var u={1:1,99:0}[d%100],x=[],y,D;if(u===undefined)u=d>400;if(d==500)d=400;for(var E in n){E=parseInt(E,
10);if(!y||E<y)y=E;if(!D||E>D)D=E;x.push(E)}if(d<y)d=y;if(d>D)d=D;x.sort(function(G,H){return(u?G>d&&H>d?G<H:G>H:G<d&&H<d?G>H:G<H)?-1:1});return n[x[0]]}}function f(r){var s={},c={};this.get=function(d){return s[d]!=undefined?s[d]:r[d]};this.getSize=function(d,n){return c[d]||(c[d]=new o.Size(this.get(d),n))};this.extend=function(d){for(var n in d)s[n]=d[n];return this}}function k(r,s,c){if(r.addEventListener)r.addEventListener(s,c,false);else r.attachEvent&&r.attachEvent("on"+s,function(){return c.call(r,
window.event)})}function m(r){var s={};return function(c){s.hasOwnProperty(c)||(s[c]=r.apply(null,arguments));return s[c]}}function p(r){return document.getElementsByTagName(r)}function h(){for(var r={},s,c=0,d=arguments.length;c<d;++c)for(s in arguments[c])r[s]=arguments[c][s];return r}function e(r,s,c,d,n,u){var x=d.separate;if(x=="none")return B[d.engine].apply(null,arguments);var y=document.createDocumentFragment(),D=s.split(F[x]),E=x=="words";if(E&&q){/^\s/.test(s)&&D.unshift("");/\s$/.test(s)&&
D.push("")}for(var G=0,H=D.length;G<H;++G)(x=B[d.engine](r,E?o.textAlign(D[G],c,G,H):D[G],c,d,n,u,G<H-1))&&y.appendChild(x);return y}function a(r,s){var c,d,n,u;n=t.get(r);if(!n.options){s.hover&&s.hoverables[r.nodeName.toLowerCase()]&&A.attach(r);n.options=s}for(var x=r.firstChild;x;x=n){n=x.nextSibling;u=false;if(x.nodeType==1){if(!x.firstChild)continue;if(/cufon/.test(x.className))u=true;else{arguments.callee(x,s);continue}}d||(d=o.getStyle(r).extend(s));if(!c)a:{(c=d)||(c=o.getStyle(r));for(var y=
o.quotedList(c.get("fontFamily").toLowerCase()),D=void 0,E=0,G=y.length;E<G;++E){D=y[E];if(v[D]){c=v[D].get(c.get("fontStyle"),c.get("fontWeight"));break a}}c=null}if(c)if(u)B[s.engine](c,null,d,s,x,r);else{u=x.data;if(u!=="")(u=e(c,u,d,s,x,r))?x.parentNode.replaceChild(u,x):x.parentNode.removeChild(x)}}}var b=function(){return b.replace.apply(null,arguments)},g=b.DOM={ready:function(){var r=false,s={loaded:1,complete:1},c=[],d=function(){if(!r){r=true;for(var n;n=c.shift();n());}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",
d,false);window.addEventListener("pageshow",d,false)}!window.opera&&document.readyState&&function(){s[document.readyState]?d():setTimeout(arguments.callee,10)}();document.readyState&&document.createStyleSheet&&function(){try{document.body.doScroll("left");d()}catch(n){setTimeout(arguments.callee,1)}}();k(window,"load",d);return function(n){if(arguments.length)r?n():c.push(n);else d()}}()},o=b.CSS={Size:function(r,s){this.value=parseFloat(r);this.unit=String(r).match(/[a-z%]*$/)[0]||"px";this.convert=
function(c){return c/s*this.value};this.convertFrom=function(c){return c/this.value*s};this.toString=function(){return this.value+this.unit}},getStyle:function(r){return new f(r.style)},quotedList:m(function(r){for(var s=[],c=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,d;d=c.exec(r);)s.push(d[3]||d[1]);return s}),ready:function(){var r=false,s=[],c=Object.prototype.propertyIsEnumerable?p("style"):{length:0},d=p("link");g.ready(function(){for(var n=0,u,x=0,y=d.length;u=d[x],x<y;++x)!u.disabled&&u.rel.toLowerCase()==
"stylesheet"&&++n;if(document.styleSheets.length>=c.length+n)for(r=true;n=s.shift();n());else setTimeout(arguments.callee,10)});return function(n){r?n():s.push(n)}}(),supports:function(r,s){var c=document.createElement("span").style;if(c[r]===undefined)return false;c[r]=s;return c[r]===s},textAlign:function(r,s,c,d){if(s.get("textAlign")=="right"){if(c>0)r=" "+r}else if(c<d-1)r+=" ";return r},textDecoration:function(r,s){s||(s=this.getStyle(r));for(var c={underline:null,overline:null,"line-through":null},
d=r;d.parentNode&&d.parentNode.nodeType==1;){var n=true;for(var u in c)if(!c[u]){if(s.get("textDecoration").indexOf(u)!=-1)c[u]=s.get("color");n=false}if(n)break;s=this.getStyle(d=d.parentNode)}return c},textShadow:m(function(r){if(r=="none")return null;for(var s=[],c={},d,n=0,u=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;d=u.exec(r);)if(d[0]==","){s.push(c);c={};n=0}else if(d[1])c.color=d[1];else c[["offX","offY","blur"][n++]]=d[2];s.push(c);return s}),color:m(function(r){var s={};
s.color=r.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(c,d,n){s.opacity=parseFloat(n);return"rgb("+d+")"});return s}),textTransform:function(r,s){return r[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[s.get("textTransform")]||"toString"]()}},q=" ".split(/\s+/).length==0,t=new function(){var r={},s=0;this.get=function(c){c=c.cufid||(c.cufid=++s);return r[c]||(r[c]={})}},A=new (function(){function r(d){d=d.relatedTarget;var n;if(!(n=!d))n=this.contains?this.contains(d):this.compareDocumentPosition(d)&
16;n||c(this)}function s(){c(this)}function c(d){setTimeout(function(){b.replace(d,t.get(d).options,true)},10)}this.attach=function(d){if(d.onmouseenter===undefined){k(d,"mouseover",r);k(d,"mouseout",r)}else{k(d,"mouseenter",s);k(d,"mouseleave",s)}}}),w=[],B={},v={},C={enableTextDecoration:false,engine:null,hover:false,hoverables:{a:true},printable:true,selector:window.Sizzle||window.jQuery&&function(r){return jQuery(r)}||window.dojo&&dojo.query||window.$$&&function(r){return $$(r)}||window.$&&function(r){return $(r)}||
document.querySelectorAll&&function(r){return document.querySelectorAll(r)}||p,separate:"words",textShadow:"none"},F={words:/\s+/,characters:""};b.now=function(){g.ready();return b};b.refresh=function(){for(var r=w.splice(0,w.length),s=0,c=r.length;s<c;++s)b.replace.apply(null,r[s]);return b};b.registerEngine=function(r,s){if(!s)return b;B[r]=s;return b.set("engine",r)};b.registerFont=function(r){r=new z(r);var s=r.family;v[s]||(v[s]=new l);v[s].add(r);return b.set("fontFamily",'"'+s+'"')};b.replace=
function(r,s,c){s=h(C,s);if(!s.engine)return b;if(typeof s.textShadow=="string")s.textShadow=o.textShadow(s.textShadow);c||w.push(arguments);if(r.nodeType||typeof r=="string")r=[r];o.ready(function(){for(var d=0,n=r.length;d<n;++d){var u=r[d];typeof u=="string"?b.replace(s.selector(u),s,true):a(u,s)}});return b};b.replaceElement=function(r,s){s=h(C,s);if(typeof s.textShadow=="string")s.textShadow=o.textShadow(s.textShadow);return a(r,s)};b.engines=B;b.fonts=v;b.getOptions=function(){return h(C)};
b.set=function(r,s){C[r]=s;return b};return b}();
Cufon.registerEngine("canvas",function(){var z=document.createElement("canvas");if(!(!z||!z.getContext||!z.getContext.apply)){z=null;var l=Cufon.CSS.supports("display","inline-block");z=!l&&(document.compatMode=="BackCompat"||/frameset|transitional/i.test(document.doctype.publicId));var f=document.createElement("style");f.type="text/css";f.appendChild(document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(z?
"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(l?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}"));document.getElementsByTagName("head")[0].appendChild(f);return function(k,m,p,h,e,a){function b(D,E){y.strokeStyle=E;y.beginPath();y.moveTo(0,
D);y.lineTo(x,D);y.stroke()}function g(){for(var D=0,E=u.length;D<E;++D){var G=k.glyphs[u[D]]||k.missingGlyph;if(G){y.beginPath();if(G.d)if(G.code)for(var H=G.code,J=y,L=0,I=H.length;L<I;++L){var M=H[L];J[M.m].apply(J,M.a)}else{H=G;J="m"+G.d;L=y;M=I=0;var N=[],Q=/([mrvxe])([^a-z]*)/g,P=void 0,O=0;a:for(;P=Q.exec(J);++O){var K=P[2].split(",");switch(P[1]){case "v":N[O]={m:"bezierCurveTo",a:[I+~~K[0],M+~~K[1],I+~~K[2],M+~~K[3],I+=~~K[4],M+=~~K[5]]};break;case "r":N[O]={m:"lineTo",a:[I+=~~K[0],M+=~~K[1]]};
break;case "m":N[O]={m:"moveTo",a:[I=~~K[0],M=~~K[1]]};break;case "x":N[O]={m:"closePath"};break;case "e":break a}L[N[O].m].apply(L,N[O].a)}H.code=N}y.fill();y.translate(Number(G.w||k.w)+A,0)}}}var o=m===null,q=k.viewBox,t=p.getSize("fontSize",k.baseSize),A=p.get("letterSpacing");A=A=="normal"?0:t.convertFrom(parseInt(A,10));var w=0,B=0,v=0,C=0,F=h.textShadow,r=[];if(F)for(var s=0,c=F.length;s<c;++s){var d=F[s],n=t.convertFrom(parseFloat(d.offX));d=t.convertFrom(parseFloat(d.offY));r[s]=[n,d];if(d<
w)w=d;if(n>B)B=n;if(d>v)v=d;if(n<C)C=n}var u=Cufon.CSS.textTransform(o?e.alt:m,p).split(""),x=0;d=null;s=0;for(c=u.length;s<c;++s)if(n=k.glyphs[u[s]]||k.missingGlyph)x+=d=Number(n.w||k.w)+A;if(d===null)return null;B+=q.width-d;C+=q.minX;if(o){o=e;s=e.firstChild}else{o=document.createElement("span");o.className="cufon cufon-canvas";o.alt=m;s=document.createElement("canvas");o.appendChild(s);if(h.printable){c=document.createElement("span");c.className="cufon-alt";c.appendChild(document.createTextNode(m));
o.appendChild(c)}}m=o.style;c=s.style;e=t.convert(q.height-w+v);v=Math.ceil(e);e=v/e;s.width=Math.ceil(t.convert(x+B-C)*e);s.height=v;w+=q.minY;c.top=Math.round(t.convert(w-k.ascent))+"px";c.left=Math.round(t.convert(C))+"px";B=Math.ceil(t.convert(x*e));c=B+"px";t=t.convert(k.height);Cufon.textOptions.width=B;Cufon.textOptions.height=t;if(l){m.width=c;m.height=t+"px"}else{m.paddingLeft=c;m.paddingBottom=t-1+"px"}var y=Cufon.textOptions.context||s.getContext("2d");q=v/q.height;y.save();y.scale(q,q);
y.translate(-C-1/q*s.width/2+(Cufon.fonts[k.family].offsetLeft||0),-w-1/q*s.height/2);y.lineWidth=k.face["underline-thickness"];y.save();h=h.enableTextDecoration?Cufon.CSS.textDecoration(a,p):{};h.underline&&b(-k.face["underline-position"],h.underline);h.overline&&b(k.ascent,h.overline);y.fillStyle=Cufon.textOptions.color||p.get("color");if(F){s=0;for(c=F.length;s<c;++s){d=F[s];y.save();y.fillStyle=d.color;y.translate.apply(y,r[s]);g();y.restore()}}g();y.restore();y.restore();h["line-through"]&&b(-k.descent,
h["line-through"]);return o}}}());
Cufon.registerEngine("vml",function(){function z(f,k){if(/px$/i.test(k))return parseFloat(k);var m=f.style.left,p=f.runtimeStyle.left;f.runtimeStyle.left=f.currentStyle.left;f.style.left=k;var h=f.style.pixelLeft;f.style.left=m;f.runtimeStyle.left=p;return h}if(document.namespaces){document.namespaces.cvml==null&&document.namespaces.add("cvml","urn:schemas-microsoft-com:vml");var l=document.createElement("cvml:shape");l.style.behavior="url(#default#VML)";if(l.coordsize){l=null;document.write('<style type="text/css">.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}</style>');
return function(f,k,m,p,h,e,a){var b=k===null;if(b)k=h.alt;var g=f.viewBox,o;if(!(o=m.computedFontSize)){o=Cufon.CSS.Size;var q;q=m.get("fontSize");q=z(e,/(?:em|ex|%)$/i.test(q)?"1em":q);o=m.computedFontSize=new o(q+"px",f.baseSize)}o=o;q=m.computedLSpacing;if(q==undefined){q=m.get("letterSpacing");m.computedLSpacing=q=q=="normal"?0:~~o.convertFrom(z(e,q))}var t;if(b){t=h;h=h.firstChild}else{t=document.createElement("span");t.className="cufon cufon-vml";t.alt=k;h=document.createElement("span");h.className=
"cufon-vml-canvas";t.appendChild(h);if(p.printable){var A=document.createElement("span");A.className="cufon-alt";A.appendChild(document.createTextNode(k));t.appendChild(A)}a||t.appendChild(document.createElement("cvml:shape"))}a=t.style;var w=h.style,B=o.convert(g.height);A=Math.ceil(B);B=A/B;var v=g.minX,C=g.minY;w.height=A;w.top=Math.round(o.convert(C-f.ascent));w.left=Math.round(o.convert(v));a.height=o.convert(f.height)+"px";p.enableTextDecoration&&Cufon.CSS.textDecoration(e,m);e=m.get("color");
k=Cufon.CSS.textTransform(k,m).split("");w=m=0;var F=null,r;p=p.textShadow;for(var s=0,c=0,d=k.length;s<d;++s)if(r=f.glyphs[k[s]]||f.missingGlyph)m+=F=~~(r.w||f.w)+q;if(F===null)return null;r=-v+m+(g.width-F);s=o.convert(r*B);F=Math.round(s);var n=r+","+g.height,u,x="r"+n+"nsnf";for(s=0;s<d;++s)if(r=f.glyphs[k[s]]||f.missingGlyph){if(b){g=h.childNodes[c];g.firstChild&&g.removeChild(g.firstChild)}else{g=document.createElement("cvml:shape");h.appendChild(g)}g.stroked="f";g.coordsize=n;g.coordorigin=
u=v-w+","+C;g.path=(r.d?"m"+r.d+"xe":"")+"m"+u+x;g.fillcolor=e;u=g.style;u.width=F;u.height=A;if(p){u=p[0];var y=p[1],D=Cufon.CSS.color(u.color),E,G=document.createElement("cvml:shadow");G.on="t";G.color=D.color;G.offset=u.offX+","+u.offY;if(y){E=Cufon.CSS.color(y.color);G.type="double";G.color2=E.color;G.offset2=y.offX+","+y.offY}G.opacity=D.opacity||E&&E.opacity||1;g.appendChild(G)}w+=~~(r.w||f.w)+q;++c}a.width=Math.max(Math.ceil(o.convert(m*B)),0);return t}}}}());
(function(z){function l(h,e){for(var a in e)h[a]=e[a];return h}function f(h,e){var a=document.createElement(h);for(var b in e)if(b==="class")a.className=e[b];else if(b==="for")a.htmlFor=e[b];else a.setAttribute(b,e[b]);return a}var k=z.fabric||(z.fabric={}),m=Array.prototype.slice,p=Function.prototype.apply;k.util={};(function(){var h=Math.PI/180;k.util.removeFromArray=function(e,a){var b=e.indexOf(a);b!==-1&&e.splice(b,1);return e};k.util.degreesToRadians=function(e){return e*h};k.util.toFixed=function(e,
a){return parseFloat(Number(e).toFixed(a))};k.util.getRandomInt=function(e,a){return Math.floor(Math.random()*(a-e+1))+e};k.util.falseFunction=function(){return false}})();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(h,e){var a=this.length>>>0;e=Number(e)||0;e=Math[e<0?"ceil":"floor"](e);if(e<0)e+=a;for(;e<a;e++)if(e in this&&this[e]===h)return e;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(h,e){for(var a=0,b=this.length>>>0;a<b;a++)a in this&&h.call(e,this[a],
a,this)};if(!Array.prototype.map)Array.prototype.map=function(h,e){for(var a=[],b=0,g=this.length>>>0;b<g;b++)if(b in this)a[b]=h.call(e,this[b],b,this);return a};if(!Array.prototype.every)Array.prototype.every=function(h,e){for(var a=0,b=this.length>>>0;a<b;a++)if(a in this&&!h.call(e,this[a],a,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(h,e){for(var a=0,b=this.length>>>0;a<b;a++)if(a in this&&h.call(e,this[a],a,this))return true;return false};if(!Array.prototype.filter)Array.prototype.filter=
function(h,e){for(var a=[],b,g=0,o=this.length>>>0;g<o;g++)if(g in this){b=this[g];h.call(e,b,g,this)&&a.push(b)}return a};if(!Array.prototype.reduce)Array.prototype.reduce=function(h){var e=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>=e)throw new TypeError;}while(1)}for(;a<e;a++)if(a in this)b=h.call(null,b,this[a],a,this);return b};k.util.array={invoke:function(h,e){for(var a=m.call(arguments,2),b=[],g=0,o=h.length;g<o;g++)b[g]=a.length?
h[g][e].apply(h[g],a):h[g][e].call(h[g]);return b},min:function(h,e){var a=h.length-1,b=e?h[a][e]:h[a];if(e)for(;a--;){if(h[a][e]<b)b=h[a][e]}else for(;a--;)if(h[a]<b)b=h[a];return b},max:function(h,e){var a=h.length-1,b=e?h[a][e]:h[a];if(e)for(;a--;){if(h[a][e]>=b)b=h[a][e]}else for(;a--;)if(h[a]>=b)b=h[a];return b}};k.util.object={extend:l,clone:function(h){return l({},h)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")};
k.util.string={camelize:function(h){return h.replace(/-+(.)?/g,function(e,a){return a?a.toUpperCase():""})},capitalize:function(h){return h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(h){var e=this,a=m.call(arguments,1);return a.length?function(){return p.call(e,h,a.concat(m.call(arguments)))}:function(){return p.call(e,h,arguments)}};(function(){function h(){}var e;e=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]};k.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var b=null,g=m.call(arguments,0);if(typeof g[0]==="function")b=g.shift();a.superclass=b;a.subclasses=[];if(b){h.prototype=b.prototype;a.prototype=new h;b.subclasses.push(a)}b=
0;for(var o=g.length;b<o;b++)e(a,g[b]);if(!a.prototype.initialize)a.prototype.initialize=emptyFunction;return a.prototype.constructor=a}})();(function(){function h(v){var C=Array.prototype.slice.call(arguments,1),F,r,s=C.length;for(r=0;r<s;r++){F=typeof v[C[r]];if(!/^(?:function|object|unknown)$/.test(F))return false}return true}function e(v,C){return function(F){C.call(g(v),F||window.event)}}function a(v,C){return function(F){if(w[v]&&w[v][C])for(var r=w[v][C],s=0,c=r.length;s<c;s++)r[s].call(this,
F||window.event)}}var b=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(C){return C.uniqueID};var v=0;return function(C){return C.__uniqueID||(C.__uniqueID="uniqueID__"+v++)}}(),g,o;(function(){var v={};g=function(C){return v[C]};o=function(C,F){v[C]=F}})();var q=h(document.documentElement,"addEventListener","removeEventListener")&&h(window,"addEventListener","removeEventListener"),t=h(document.documentElement,"attachEvent","detachEvent")&&h(window,"attachEvent",
"detachEvent"),A={},w={};if(q){q=function(v,C,F){v.addEventListener(C,F,false)};t=function(v,C,F){v.removeEventListener(C,F,false)}}else if(t){q=function(v,C,F){var r=b(v);o(r,v);A[r]||(A[r]={});A[r][C]||(A[r][C]=[]);F={handler:F,wrappedHandler:e(r,F)};A[r][C].push(F);v.attachEvent("on"+C,F.wrappedHandler)};t=function(v,C,F){var r=b(v),s;if(A[r]&&A[r][C])for(var c=0,d=A[r][C].length;c<d;c++)if((s=A[r][C][c])&&s.handler===F){v.detachEvent("on"+C,s.wrappedHandler);A[r][C][c]=null}}}else{q=function(v,
C,F){var r=b(v);w[r]||(w[r]={});if(!w[r][C]){w[r][C]=[];var s=v["on"+C];s&&w[r][C].push(s);v["on"+C]=a(r,C)}w[r][C].push(F)};t=function(v,C,F){v=b(v);if(w[v]&&w[v][C]){C=w[v][C];v=0;for(var r=C.length;v<r;v++)C[v]===F&&C.splice(v,1)}}}k.util.addListener=q;k.util.removeListener=t;var B={};k.util.getPointer=function(v){var C=document.documentElement,F=document.body||{scrollLeft:0},r=document.documentElement,s=document.body||{scrollTop:0};return{x:v.pageX||(typeof v.clientX!="unknown"?v.clientX:0)+(C.scrollLeft||
F.scrollLeft)-(C.clientLeft||0),y:v.pageY||(typeof v.clientY!="unknown"?v.clientY:0)+(r.scrollTop||s.scrollTop)-(r.clientTop||0)}};k.util.observeEvent=function(v,C){B[v]||(B[v]=[]);B[v].push(C)};k.util.fireEvent=function(v,C){var F=B[v];if(F)for(var r=0,s=F.length;r<s;r++)F[r]({memo:C})}})(this);(function(){var h=document.createElement("div"),e=typeof h.style.filter==="string",a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,b=function(g){return g};if(typeof h.style.opacity==="string")b=function(g,o){g.style.opacity=
o;return g};else if(e)b=function(g,o){var q=g.style;if(g.currentStyle&&!g.currentStyle.hasLayout)q.zoom=1;if(a.test(q.filter)){o=o>=0.9999?"":"alpha(opacity="+o*100+")";q.filter=q.filter.replace(a,o)}else q.filter+=" alpha(opacity="+o*100+")";return g};k.util.setStyle=function(g,o){var q=g.style;if(typeof o==="string"){g.style.cssText+=";"+o;return o.indexOf("opacity")>-1?b(g,o.match(/opacity:\s*(\d?\.?\d*)/)[1]):g}for(var t in o)if(t==="opacity")b(g,o[t]);else q[t==="float"||t==="cssFloat"?typeof q.styleFloat===
"undefined"?"cssFloat":"styleFloat":t]=o[t];return g}})();(function(){var h=document.documentElement.style,e="userSelect"in h?"userSelect":"MozUserSelect"in h?"MozUserSelect":"WebkitUserSelect"in h?"WebkitUserSelect":"KhtmlUserSelect"in h?"KhtmlUserSelect":"";k.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=k.util.falseFunction;if(e)a.style[e]="none";else if(typeof a.unselectable=="string")a.unselectable="on";return a}})();(function(){function h(a,
b){e.load(a);b()}k.util.getScript=function(a,b){var g=document.getElementsByTagName("head")[0],o=document.createElement("script"),q=true;o.type="text/javascript";o.setAttribute("runat","server");o.onload=o.onreadystatechange=function(t){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;b(t||window.event);o=o.onload=o.onreadystatechange=null}};o.src=a;g.appendChild(o)};var e=z.Jaxer;if(e&&e.load)k.util.getScript=h})();k.util.getById=function(h){return typeof h===
"string"?document.getElementById(h):h};k.util.toArray=function(h){for(var e=[],a=h.length;a--;)e[a]=h[a];return e};k.util.makeElement=f;k.util.addClass=function(h,e){if((" "+h.className+" ").indexOf(" "+e+" ")===-1)h.className+=(h.className?" ":"")+e};k.util.wrapElement=function(h,e,a){if(typeof e==="string")e=f(e,a);h.parentNode&&h.parentNode.replaceChild(e,h);e.appendChild(h);return e};k.util.getElementOffset=function(h){var e=0,a=0;do{e+=h.offsetTop||0;a+=h.offsetLeft||0;h=h.offsetParent}while(h);
return{left:a,top:e}};k.util.animate=function(h){h||(h={});var e=+new Date,a=h.duration||500,b=e+a,g,o,q=h.onChange||function(){},t=h.easing||function(C){return-Math.cos(C*Math.PI)/2+0.5},A="startValue"in h?h.startValue:0,w="endValue"in h?h.endValue:100,B=A>w;h.onStart&&h.onStart();var v=setInterval(function(){g=+new Date;o=g>b?1:(g-e)/a;q(B?A-(A-w)*t(o):A+(w-A)*t(o));if(g>b){clearInterval(v);h.onComplete&&h.onComplete()}},10)};(function(){function h(){}var e=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){}}();k.util.request=function(a,b){b||(b={});var g=b.method?b.method.toUpperCase():"GET",o=b.onComplete||function(){},q=e(),t;q.onreadystatechange=function(){if(q.readyState===4){o(q);q.onreadystatechange=h}};if(g==="GET"){t=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(t);return q}})()})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.string.capitalize,m=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 h(q,t){var A=t[0];q[0]=Math.cos(A);q[1]=Math.sin(A);q[2]=-Math.sin(A);q[3]=Math.cos(A)}function e(q,t){var A=t.length===2?t[1]:t[0];q[0]=t[0];q[3]=A}function a(q,t){q[4]=t[0];if(t.length===
2)q[5]=t[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*$"),
o=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))");
return function(q){var t=b.concat();if(!q||q&&!g.test(q))return t;q.replace(o,function(A){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(A).filter(function(B){return B!==
""&&B!=null});A=w[1];w=w.slice(2).map(parseFloat);switch(A){case "translate":a(t,w);break;case "rotate":h(t,w);break;case "scale":e(t,w);break;case "skewX":t[2]=w[0];break;case "skewY":t[1]=w[0];break;case "matrix":t=w;break}});return t}}();l.parseSVGDocument=function(){var h=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,e=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=l.util.toArray(a.getElementsByTagName("*")).filter(function(B){var v;if(v=h.test(B.tagName)){a:{for(B=B;B&&(B=B.parentNode);)if(B.nodeName==="pattern"){B=true;break a}B=false}v=!B}return v});if(!(!g||g&&!g.length)){var o=a.getAttribute("viewBox"),q=a.getAttribute("width"),t=a.getAttribute("height"),A=null,w=null;if(o&&(o=o.match(e))){parseInt(o[1],10);parseInt(o[2],10);A=parseInt(o[3],10);w=parseInt(o[4],10)}A=q?parseFloat(q):A;w=t?parseFloat(t):w;o={width:A,height:w};
g=l.parseElements(g,m(o));!g||g&&!g.length||b&&b(g,o)}}}}();f(l,{parseAttributes:function(h,e){if(h){var a,b,g={};if(h.parentNode&&/^g$/i.test(h.parentNode.nodeName))g=l.parseAttributes(h.parentNode,e);var o=e.reduce(function(q,t){a=h.getAttribute(t);b=parseFloat(a);if(a){if((t==="fill"||t==="stroke")&&a==="none")a="";if(t==="fill-rule")a=a==="evenodd"?"destination-over":a;if(t==="transform")a=l.parseTransformAttribute(a);if(t in p)t=p[t];q[t]=isNaN(b)?a:b}return q},{});o=f(l.parseStyleAttribute(h),
o);return f(g,o)}},parseElements:function(h,e){var a=h.map(function(b){var g=l[k(b.tagName)];if(g&&g.fromElement)try{return g.fromElement(b,e)}catch(o){l.log(o.message||o)}});return a=a.filter(function(b){return b!=null})},parseStyleAttribute:function(h){var e={};if(h=h.getAttribute("style"))if(typeof h=="string"){h=h.split(";");h.pop();e=h.reduce(function(b,g){var o=g.split(":"),q=o[0].trim();o=o[1].trim();b[q]=o;return b},{})}else for(var a in h)if(typeof h[a]!=="undefined")e[a]=h[a];return e},
parsePointsAttribute:function(h){if(!h)return null;h=h.trim();var e=h.indexOf(",")>-1;h=h.split(/\s+/);var a=[];if(e){e=0;for(var b=h.length;e<b;e++){var g=h[e].split(",");a.push({x:parseFloat(g[0]),y:parseFloat(g[1])})}}else{e=0;for(b=h.length;e<b;e+=2)a.push({x:parseFloat(h[e]),y:parseFloat(h[e+1])})}return a}})})(this);
(function(z){function l(f,k){arguments.length>0&&this.init(f,k)}z=z.fabric||(z.fabric={});if(z.Point)z.warn("fabric.Point is already defined");else{z.Point=l;l.prototype={constructor:l,init:function(f,k){this.x=f;this.y=k},add:function(f){return new l(this.x+f.x,this.y+f.y)},addEquals:function(f){this.x+=f.x;this.y+=f.y;return this},scalarAdd:function(f){return new l(this.x+f,this.y+f)},scalarAddEquals:function(f){this.x+=f;this.y+=f;return this},subtract:function(f){return new l(this.x-f.x,this.y-
f.y)},subtractEquals:function(f){this.x-=f.x;this.y-=f.y;return this},scalarSubtract:function(f){return new l(this.x-f,this.y-f)},scalarSubtractEquals:function(f){this.x-=f;this.y-=f;return this},multiply:function(f){return new l(this.x*f,this.y*f)},multiplyEquals:function(f){this.x*=f;this.y*=f;return this},divide:function(f){return new l(this.x/f,this.y/f)},divideEquals:function(f){this.x/=f;this.y/=f;return this},eq:function(f){return this.x==f.x&&this.y==f.y},lt:function(f){return this.x<f.x&&
this.y<f.y},lte:function(f){return this.x<=f.x&&this.y<=f.y},gt:function(f){return this.x>f.x&&this.y>f.y},gte:function(f){return this.x>=f.x&&this.y>=f.y},lerp:function(f,k){return new l(this.x+(f.x-this.x)*k,this.y+(f.y-this.y)*k)},distanceFrom:function(f){var k=this.x-f.x;f=this.y-f.y;return Math.sqrt(k*k+f*f)},min:function(f){return new l(Math.min(this.x,f.x),Math.min(this.y,f.y))},max:function(f){return new l(Math.max(this.x,f.x),Math.max(this.y,f.y))},toString:function(){return this.x+","+this.y},
setXY:function(f,k){this.x=f;this.y=k},setFromPoint:function(f){this.x=f.x;this.y=f.y},swap:function(f){var k=this.x,m=this.y;this.x=f.x;this.y=f.y;f.x=k;f.y=m}}}})(this);
(function(z){function l(k){arguments.length>0&&this.init(k)}var f=z.fabric||(z.fabric={});if(f.Intersection)f.warn("fabric.Intersection is already defined");else{f.Intersection=l;f.Intersection.prototype={init:function(k){this.status=k;this.points=[]},appendPoint:function(k){this.points.push(k)},appendPoints:function(k){this.points=this.points.concat(k)}};f.Intersection.intersectLineLine=function(k,m,p,h){var e,a=(h.x-p.x)*(k.y-p.y)-(h.y-p.y)*(k.x-p.x);e=(m.x-k.x)*(k.y-p.y)-(m.y-k.y)*(k.x-p.x);p=
(h.y-p.y)*(m.x-k.x)-(h.x-p.x)*(m.y-k.y);if(p!=0){a=a/p;e=e/p;if(0<=a&&a<=1&&0<=e&&e<=1){e=new l("Intersection");e.points.push(new f.Point(k.x+a*(m.x-k.x),k.y+a*(m.y-k.y)))}else e=new l("No Intersection")}else e=a==0||e==0?new l("Coincident"):new l("Parallel");return e};f.Intersection.intersectLinePolygon=function(k,m,p){for(var h=new l("No Intersection"),e=p.length,a=0;a<e;a++){var b=l.intersectLineLine(k,m,p[a],p[(a+1)%e]);h.appendPoints(b.points)}if(h.points.length>0)h.status="Intersection";return h};
f.Intersection.intersectPolygonPolygon=function(k,m){for(var p=new l("No Intersection"),h=k.length,e=0;e<h;e++){var a=l.intersectLinePolygon(k[e],k[(e+1)%h],m);p.appendPoints(a.points)}if(p.points.length>0)p.status="Intersection";return p};f.Intersection.intersectPolygonRectangle=function(k,m,p){var h=m.min(p),e=m.max(p);p=new f.Point(e.x,h.y);var a=new f.Point(h.x,e.y);m=l.intersectLinePolygon(h,p,k);p=l.intersectLinePolygon(p,e,k);e=l.intersectLinePolygon(e,a,k);k=l.intersectLinePolygon(a,h,k);
h=new l("No Intersection");h.appendPoints(m.points);h.appendPoints(p.points);h.appendPoints(e.points);h.appendPoints(k.points);if(h.points.length>0)h.status="Intersection";return h}}})(this);
(function(z){function l(f){f?this._tryParsingColor(f):this.setSource([0,0,0,1])}z=z.fabric||(z.fabric={});if(z.Color)z.warn("fabric.Color is already defined.");else{z.Color=l;z.Color.prototype={_tryParsingColor:function(f){var k=l.sourceFromHex(f);k||(k=l.sourceFromRgb(f));k&&this.setSource(k)},getSource:function(){return this._source},setSource:function(f){this._source=f},toRgb:function(){var f=this.getSource();return"rgb("+f[0]+","+f[1]+","+f[2]+")"},toRgba:function(){var f=this.getSource();return"rgba("+
f[0]+","+f[1]+","+f[2]+","+f[3]+")"},toHex:function(){var f=this.getSource(),k=f[0].toString(16);k=k.length==1?"0"+k:k;var m=f[1].toString(16);m=m.length==1?"0"+m:m;f=f[2].toString(16);f=f.length==1?"0"+f:f;return k.toUpperCase()+m.toUpperCase()+f.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(f){var k=this.getSource();k[3]=f;this.setSource(k);return this},toGrayscale:function(){var f=this.getSource(),k=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),10);this.setSource([k,
k,k,f[3]]);return this},toBlackWhite:function(f){var k=this.getSource(),m=(k[0]*0.3+k[1]*0.59+k[2]*0.11).toFixed(0);k=k[3];f=f||127;m=Number(m)<Number(f)?0:255;this.setSource([m,m,m,k]);return this},overlayWith:function(f){f instanceof l||(f=new l(f));var k=[],m=this.getAlpha(),p=this.getSource();f=f.getSource();for(var h=0;h<3;h++)k.push(Math.round(p[h]*0.5+f[h]*0.5));k[4]=m;this.setSource(k);return this}};z.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
z.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;z.Color.fromRgb=function(f){return l.fromSource(l.sourceFromRgb(f))};z.Color.sourceFromRgb=function(f){if(f=f.match(l.reRGBa))return[parseInt(f[1],10),parseInt(f[2],10),parseInt(f[3],10),f[4]?parseFloat(f[4]):1]};z.Color.fromRgba=l.fromRgb;z.Color.fromHex=function(f){return l.fromSource(l.sourceFromHex(f))};z.Color.sourceFromHex=function(f){if(f.match(l.reHex)){var k=f.slice(f.indexOf("#")+1),m=k.length===3;f=m?k.charAt(0)+k.charAt(0):k.substring(0,2);
var p=m?k.charAt(1)+k.charAt(1):k.substring(2,4);k=m?k.charAt(2)+k.charAt(2):k.substring(4,6);return[parseInt(f,16),parseInt(p,16),parseInt(k,16),1]}};z.Color.fromSource=function(f){var k=new l;k.setSource(f);return k}}})(this);
(function(z){if(fabric.Element)fabric.warn("fabric.Element is already defined.");else{var l=z.window,f=l.document,k=fabric.util.object.extend,m=fabric.util.string.capitalize,p=fabric.util.string.camelize,h=fabric.util.fireEvent,e=fabric.util.getPointer,a=fabric.util.getElementOffset,b=fabric.util.removeFromArray,g=fabric.util.addListener,o=fabric.util.removeListener,q=fabric.util.array.min,t=fabric.util.array.max,A=Math.sqrt,w=Math.pow,B=Math.atan2,v=Math.abs,C=Math.min,F=Math.max,r=Error("Could not initialize `canvas` element"),
s={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(c,d){this._groupSelector=null;this._objects=[];this._activeGroup=this._currentTransform=this._element=this._context=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._config={width:300,height:150};d=d||{};this._initElement(c);this._initConfig(d);d.overlayImage&&this.setOverlayImage(d.overlayImage);if(d.afterRender)this.afterRender=d.afterRender;
this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};k(fabric.Element.prototype,{backgroundColor:"rgba(0, 0, 0, 0)",selectionColor:"rgba(100, 100, 255, 0.3)",selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,freeDrawingColor:"rgb(0, 0, 0)",freeDrawingLineWidth:1,includeDefaultValues:true,shouldCacheImages:false,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(){},onFpsUpdate:function(){},onObjectMove:null,onMouseUp:null,
calcOffset:function(){this._offset=a(this.getElement());return this},setOverlayImage:function(c,d){if(c){var n=this,u=new Image;u.onload=function(){n.overlayImage=u;d&&d();u=u.onload=null};u.src=c}return this},_initElement:function(c){this._element=fabric.util.getById(c)||f.createElement("canvas");typeof this._element.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(this._element);if(typeof this._element.getContext==="undefined")throw r;if(!(this.contextTop=
this._element.getContext("2d")))throw r;c=this._element.width||0;var d=this._element.height||0;this._initWrapperElement(c,d);this._setElementStyle(c,d)},_initWrapperElement:function(c,d){var n=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(n,{width:c+"px",height:d+"px"});fabric.util.makeElementUnselectable(n);this.wrapper=n},_setElementStyle:function(c,d){fabric.util.setStyle(this.getElement(),{position:"absolute",width:c+"px",height:d+"px",left:0,
top:0})},_initConfig:function(c){k(this._config,c||{});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 c=this;this._onMouseDown=function(d){c.__onMouseDown(d)};this._onMouseUp=function(d){c.__onMouseUp(d)};this._onMouseMove=function(d){c.__onMouseMove(d)};this._onResize=function(){c.calcOffset()};g(this._element,
"mousedown",this._onMouseDown);g(f,"mousemove",this._onMouseMove);g(f,"mouseup",this._onMouseUp);g(l,"resize",this._onResize)},_createCanvasElement:function(c){var d=f.createElement("canvas");if(d){d.className=c;c=this._element.parentNode.insertBefore(d,this._element);c.width=this.getWidth();c.height=this.getHeight();c.style.width=this.getWidth()+"px";c.style.height=this.getHeight()+"px";c.style.position="absolute";c.style.left=0;c.style.top=0;typeof d.getContext==="undefined"&&typeof G_vmlCanvasManager!==
"undefined"&&G_vmlCanvasManager.initElement(d);if(typeof d.getContext==="undefined")throw r;fabric.util.makeElementUnselectable(c);return c}},_createCanvasContainer:function(){var c=this._createCanvasElement("canvas-container");this.contextContainerEl=c;this.contextContainer=c.getContext("2d")},_createCanvasBackground:function(){var c=this._createCanvasElement("canvas-container");this._contextBackgroundEl=c;this._contextBackground=c.getContext("2d")},getWidth:function(){return this._config.width},
getHeight:function(){return this._config.height},setWidth:function(c){return this._setDimension("width",c)},setHeight:function(c){return this._setDimension("height",c)},setDimensions:function(c){for(var d in c)this._setDimension(d,c[d]);return this},_setDimension:function(c,d){this.contextContainerEl[c]=d;this.contextContainerEl.style[c]=d+"px";this._contextBackgroundEl[c]=d;this._contextBackgroundEl.style[c]=d+"px";this._element[c]=d;this._element.style[c]=d+"px";this._element.parentNode.style[c]=
d+"px";this._config[c]=d;this.calcOffset();this.renderAll();return this},__onMouseUp:function(c){if(this.isDrawingMode&&this._isCurrentlyDrawing)this._finalizeDrawingPath();else{if(this._currentTransform){var d=this._currentTransform.target;if(d._scaling){h("object:scaled",{target:d});d._scaling=false}for(var n=this._objects.length;n--;)this._objects[n].setCoords();if(d.hasStateChanged()){d.isMoving=false;h("object:modified",{target:d})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(c);
if(n=this.getActiveGroup()){n.hasStateChanged()&&n.containsPoint(this.getPointer(c))&&h("group:modified",{target:n});n.setObjectsCoords();n.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(c,d);this._setCursor("");var u=this;setTimeout(function(){u._setCursorFromEvent(c,d)},50);this.onMouseUp&&this.onMouseUp()}},_shouldClearSelection:function(c){var d=this.findTarget(c),n=this.getActiveGroup();return!d||d&&n&&!n.contains(d)&&n!==d&&
!c.shiftKey},__onMouseDown:function(c){if(this.isDrawingMode){this._prepareForDrawing(c);this._captureDrawingPath(c)}else if(!this._currentTransform){var d=this.findTarget(c),n=this.getPointer(c),u=this.getActiveGroup();if(this._shouldClearSelection(c)){this._groupSelector={ex:n.x,ey:n.y,top:0,left:0};this.deactivateAllWithDispatch()}else{d.saveState();d._findTargetCorner(c,this._offset)&&this.onBeforeScaleRotate(d);this._setupCurrentTransform(c,d);if(c.shiftKey&&(u||this.getActiveObject()))this._handleGroupLogic(c,
d);else{d!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(d)}}this.renderAll()}},getElement:function(){return this._element},deactivateAllWithDispatch:function(){var c=this.getActiveGroup();c&&h("before:group:destroyed",{target:c});this.deactivateAll();c&&h("after:group:destroyed");h("selection:cleared");return this},_setupCurrentTransform:function(c,d){var n="drag",u,x=e(c);if(u=d._findTargetCorner(c,this._offset))n=u==="ml"||u==="mr"?"scaleX":u==="mt"||u==="mb"?"scaleY":"rotate";
this._currentTransform={target:d,action:n,scaleX:d.scaleX,scaleY:d.scaleY,offsetX:x.x-d.left,offsetY:x.y-d.top,ex:x.x,ey:x.y,left:d.left,top:d.top,theta:d.theta,width:d.width*d.scaleX};this._currentTransform.original={left:d.left,top:d.top}},_handleGroupLogic:function(c,d){if(d.isType("group")){d=this.findTarget(c,true);if(!d||d.isType("group"))return}var n=this.getActiveGroup();if(n){if(n.contains(d)){n.remove(d);d.setActive(false);n.size()===1&&this.removeActiveGroup()}else n.add(d);h("group:selected",
{target:n});n.setActive(true)}else{if(this._activeObject)if(d!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,d]));n=this.getActiveGroup()}d.setActive(true)}n&&n.saveCoords()},_prepareForDrawing:function(c){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();c=this.getPointer(c);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(c.x);this._freeDrawingYPoints.push(c.y);this.contextTop.beginPath();this.contextTop.moveTo(c.x,
c.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=this.contextTop.lineJoin="round"},_captureDrawingPath:function(c){c=this.getPointer(c);this._freeDrawingXPoints.push(c.x);this._freeDrawingYPoints.push(c.y);this.contextTop.lineTo(c.x,c.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var c=q(this._freeDrawingXPoints),d=q(this._freeDrawingYPoints),
n=t(this._freeDrawingXPoints),u=t(this._freeDrawingYPoints),x=[],y,D,E=this._freeDrawingXPoints,G=this._freeDrawingYPoints;x.push("M ",E[0]-c," ",G[0]-d," ");for(var H=1;y=E[H],D=G[H];H++)x.push("L ",y-c," ",D-d," ");x=new fabric.Path(x.join(""));x.fill=null;x.stroke=this.freeDrawingColor;x.strokeWidth=this.freeDrawingLineWidth;this.add(x);x.set("left",c+(n-c)/2).set("top",d+(u-d)/2).setCoords();this.renderAll();h("path:created",{path:x})},__onMouseMove:function(c){if(this.isDrawingMode)this._isCurrentlyDrawing&&
this._captureDrawingPath(c);else{var d=this._groupSelector;if(d!==null){var n=e(c);d.left=n.x-this._offset.left-d.ex;d.top=n.y-this._offset.top-d.ey;this.renderTop()}else if(this._currentTransform){n=e(c);d=n.x;n=n.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){c.shiftKey||this._rotateObject(d,n);this._scaleObject(d,n)}else if(this._currentTransform.action==="scaleX")this._scaleObject(d,n,"x");else if(this._currentTransform.action==="scaleY")this._scaleObject(d,
n,"y");else{this._translateObject(d,n);this.onObjectMove&&this.onObjectMove(this._currentTransform.target)}this.renderAll()}else{n=this._element.style;if(d=this.findTarget(c)){this._setCursorFromEvent(c,d);d.isActive()&&d.setCornersVisibility&&d.setCornersVisibility(true)}else{for(c=this._objects.length;c--;)this._objects[c].active||this._objects[c].setActive(false);n.cursor="default"}}}},_translateObject:function(c,d){var n=this._currentTransform.target;n.lockHorizontally||n.set("left",c-this._currentTransform.offsetX);
n.lockVertically||n.set("top",d-this._currentTransform.offsetY)},_scaleObject:function(c,d,n){var u=this._currentTransform,x=this._offset,y=u.target;if(!y.lockScaling){var D=A(w(u.ey-u.top-x.top,2)+w(u.ex-u.left-x.left,2));c=A(w(d-u.top-x.top,2)+w(c-u.left-x.left,2));y._scaling=true;if(n)if(n==="x")y.set("scaleX",u.scaleX*c/D);else n==="y"&&y.set("scaleY",u.scaleY*c/D);else{y.set("scaleX",u.scaleX*c/D);y.set("scaleY",u.scaleY*c/D)}}},_rotateObject:function(c,d){var n=this._currentTransform,u=this._offset;
if(!n.target.lockRotation){var x=B(n.ey-n.top-u.top,n.ex-n.left-u.left);u=B(d-n.top-u.top,c-n.left-u.left);n.target.set("theta",u-x+n.theta)}},_setCursor:function(c){this._element.style.cursor=c},_setCursorFromEvent:function(c,d){var n=this._element.style;if(d){var u=this.getActiveGroup();if(u=!!d._findTargetCorner&&(!u||!u.contains(d))&&d._findTargetCorner(c,this._offset))if(u in s)n.cursor=s[u];else{n.cursor="default";return false}else n.cursor="move"}else{n.cursor="default";return false}return true},
_draw:function(c,d){d&&d.render(c)},_drawSelection:function(){var c=this._groupSelector,d=c.left,n=c.top,u=v(d),x=v(n);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(c.ex-(d>0?0:-d),c.ey-(n>0?0:-n),u,x);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(c.ex+0.5-(d>0?0:u),c.ey+0.5-(n>0?0:x),u,x)},_findSelectedObjects:function(){var c=[],d=this._groupSelector.ex,n=this._groupSelector.ey,u=d+this._groupSelector.left,
x=n+this._groupSelector.top,y=new fabric.Point(C(d,u),C(n,x));n=new fabric.Point(F(d,u),F(n,x));u=0;for(x=this._objects.length;u<x;++u){d=this._objects[u];if(d.intersectsWithRect(y,n)||d.isContainedWithinRect(y,n)){d.setActive(true);c.push(d)}}if(c.length===1){this.setActiveObject(c[0]);h("object:selected",{target:c[0]})}else if(c.length>1){c=new fabric.Group(c);this.setActiveGroup(c);c.saveCoords();h("group:selected",{target:c})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,
arguments);this.renderAll();return this},insertAt:function(c,d){this._objects.splice(d,0,c);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},clearContext:function(c){c.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(c){var d=this._config.width,n=
this._config.height,u=c?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);c||this.clearContext(u);u.fillStyle=this.backgroundColor;u.fillRect(0,0,d,n);c=this._objects.length;d=this.getActiveGroup();n=new Date;if(c)for(var x=0;x<c;++x)if(!d||d&&!d.contains(this._objects[x]))this._draw(u,this._objects[x]);d&&this._draw(this.contextTop,d);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 c=this.getActiveGroup();c&&c.render(this.contextTop);this.afterRender&&this.afterRender();return this},containsPoint:function(c,d){var n=this.getPointer(c),u=this._normalizePointer(d,n);n=u.x;u=u.y;var x=d._getImageLines(d.oCoords);if((n=d._findCrossPoints(n,u,x))&&n%2===1||d._findTargetCorner(c,this._offset))return true;
return false},_normalizePointer:function(c,d){var n=this.getActiveGroup(),u=d.x,x=d.y;if(n&&c.type!=="group"&&n.contains(c)){u-=n.left;x-=n.top}return{x:u,y:x}},findTarget:function(c,d){var n;this.getPointer(c);var u=this.getActiveGroup();if(u&&!d&&this.containsPoint(c,u))return n=u;for(u=this._objects.length;u--;)if(this.containsPoint(c,this._objects[u])){this.relatedTarget=n=this._objects[u];break}return n},toDataURL:function(c){var d;c||(c="png");if(c==="jpeg"||c==="png"){this.renderAll(true);
d=this.getElement().toDataURL("image/"+c);this.renderAll()}return d},toDataURLWithMultiplier:function(c,d){var n=this.getWidth(),u=this.getHeight(),x=n*d,y=u*d,D=this.getActiveObject();this.setWidth(x).setHeight(y);this.contextTop.scale(d,d);D&&this.deactivateAll().renderAll();x=this.toDataURL(c);this.contextTop.scale(1/d,1/d);this.setWidth(n).setHeight(u);D&&this.setActiveObject(D);this.renderAll();return x},getPointer:function(c){c=e(c);return{x:c.x-this._offset.left,y:c.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/
2,left:this.getWidth()/2}},centerObjectH:function(c){c.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(c,d){d=d||{};var n=function(){},u=d.onComplete||n,x=d.onChange||n,y=this;fabric.util.animate({startValue:c.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(D){c.set("left",D);y.renderAll();x()},onComplete:function(){c.setCoords();u()}});return this},centerObjectV:function(c){c.set("top",this.getCenter().top);this.renderAll();
return this},fxCenterObjectV:function(c,d){d=d||{};var n=function(){},u=d.onComplete||n,x=d.onChange||n,y=this;fabric.util.animate({startValue:c.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(D){c.set("top",D);y.renderAll();x()},onComplete:function(){c.setCoords();u()}});return this},straightenObject:function(c){c.straighten();this.renderAll();return this},fxStraightenObject:function(c){c.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(c){return{objects:this._objects.map(function(d){if(!this.includeDefaultValues){var n=d.includeDefaultValues;d.includeDefaultValues=false}var u=d[c]();if(!this.includeDefaultValues)d.includeDefaultValues=n;return u},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(c,d){if(c){var n=
JSON.parse(c);if(!(!n||n&&!n.objects)){this.clear();var u=this;this._enlivenObjects(n.objects,function(){u.backgroundColor=n.background;d&&d()});return this}}},_enlivenObjects:function(c,d){var n=0,u=c.filter(function(y){return y.type==="image"}).length,x=this;c.forEach(function(y,D){if(y.type)switch(y.type){case "image":case "font":fabric[m(y.type)].fromObject(y,function(G){x.insertAt(G,D);++n===u&&d&&d()});break;default:var E=fabric[p(m(y.type))];E&&E.fromObject&&x.insertAt(E.fromObject(y),D);break}});
u===0&&d&&d()},loadFromDatalessJSON:function(c,d){if(c){var n=typeof c==="string"?JSON.parse(c):c;if(!(!n||n&&!n.objects)){this.clear();this.backgroundColor=n.background;this._enlivenDatalessObjects(n.objects,d)}}},_enlivenDatalessObjects:function(c,d){function n(E,G){u.insertAt(E,G);E.setCoords();++x===y&&d&&d()}var u=this,x=0,y=c.length;y===0&&d&&d();try{c.forEach(function(E,G){var H=E.paths?"paths":"path",J=E[H];delete E[H];if(typeof J!=="string")switch(E.type){case "image":case "text":fabric[m(E.type)].fromObject(E,
function(I){n(I,G)});break;default:(H=fabric[p(m(E.type))])&&H.fromObject&&n(H.fromObject(E),G);break}else if(E.type==="image")u.loadImageFromURL(J,function(I){I.setSourcePath(J);k(I,E);I.setAngle(E.angle);n(I,G)});else if(E.type==="text"){E.path=J;var L=fabric.Text.fromObject(E);fabric.util.getScript(J,function(){Object.prototype.toString.call(l.opera)==="[object Opera]"?setTimeout(function(){n(L,G)},500):n(L,G)})}else u.loadSVGFromURL(J,function(I){I=I.length>1?new fabric.PathGroup(I,E):I[0];I.setSourcePath(J);
if(!(I instanceof fabric.PathGroup)){k(I,E);typeof E.angle!=="undefined"&&I.setAngle(E.angle)}n(I,G)})},this)}catch(D){fabric.log(D.message)}},loadImageFromURL:function(){var c={};return function(d,n){function u(){var D=f.getElementById(c[d]);D.width&&D.height?n(new fabric.Image(D)):setTimeout(u,50)}var x=this;if(c[d])u();else{var y=new Image;y.onload=function(){y.onload=null;x._resizeImageToFit(y);var D=new fabric.Image(y);n(D)};y.className="canvas-img-clone";y.src=d;if(this.shouldCacheImages)c[d]=
Element.identify(y);f.body.appendChild(y)}}}(),loadSVGFromURL:function(c,d){function n(y){if(y=y.responseXML)(y=y.documentElement)&&fabric.parseSVGDocument(y,function(D,E){x.cache.set(c,{objects:D.invoke("toObject"),options:E});d(D,E)})}function u(){fabric.log("ERROR!")}var x=this;c=c.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(c,function(y){if(y)x.cache.get(c,function(D){D=x._enlivenCachedObject(D);d(D.objects,D.options)});else new Ajax.Request(c,{method:"get",onComplete:n,onFailure:u})})},
_enlivenCachedObject:function(c){var d=c.objects;c=c.options;d=d.map(function(n){return fabric[m(n.type)].fromObject(n)});return{objects:d,options:c}},remove:function(c){b(this._objects,c);this.renderAll();return c},fxRemove:function(c,d){var n=this;c.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){n.remove(c);typeof d==="function"&&d()}});return this},sendToBack:function(c){b(this._objects,c);this._objects.unshift(c);return this.renderAll()},bringToFront:function(c){b(this._objects,
c);this._objects.push(c);return this.renderAll()},sendBackwards:function(c){var d=this._objects.indexOf(c),n=d;if(d!==0){for(d=d-1;d>=0;--d)if(c.intersectsWithObject(this._objects[d])){n=d;break}b(this._objects,c);this._objects.splice(n,0,c)}return this.renderAll()},bringForward:function(c){var d=this.getObjects(),n=d.indexOf(c),u=n;if(n!==d.length-1){n=n+1;for(var x=this._objects.length;n<x;++n)if(c.intersectsWithObject(d[n])){u=n;break}b(d,c);d.splice(u,0,c)}this.renderAll()},setActiveObject:function(c){this._activeObject&&
this._activeObject.setActive(false);this._activeObject=c;c.setActive(true);this.renderAll();h("object:selected",{target:c});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(c){this._activeGroup=c;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var c=this.getActiveGroup();c&&c.destroy();return this.setActiveGroup(null)},
item:function(c){return this.getObjects()[c]},deactivateAll:function(){for(var c=this.getObjects(),d=0,n=c.length;d<n;d++)c[d].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(c,d){c+=d.complexity?d.complexity():0;return c},0)},dispose:function(){this.clear();o(this.getElement(),"mousedown",this._onMouseDown);o(f,"mouseup",this._onMouseUp);o(f,"mousemove",this._onMouseMove);o(l,"resize",this._onResize);
return this},clone:function(c){var d=f.createElement("canvas");d.width=this.getWidth();d.height=this.getHeight();var n=this.__clone||(this.__clone=new fabric.Element(d));return n.loadFromJSON(JSON.stringify(this.toJSON()),function(){c&&c(n)})},_toDataURL:function(c,d){this.clone(function(n){d(n.toDataURL(c))})},_toDataURLWithMultiplier:function(c,d,n){this.clone(function(u){n(u.toDataURLWithMultiplier(c,d))})},_resizeImageToFit:function(c){var d=c.width||c.offsetWidth,n=this.getWidth()/d;if(d)c.width=
d*n},cache:{has:function(c,d){d(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};k(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(c){var d=c.getContext("2d");c=d.getImageData(0,0,c.width,c.height);var n=c.data,u=c.width,x=c.height,y,D;for(i=0;i<u;i++)for(j=0;j<x;j++){y=i*4*x+j*4;D=(n[y]+n[y+1]+n[y+2])/3;n[y]=D;n[y+1]=D;n[y+
2]=D}d.putImageData(c,0,0)},supports:function(c){var d=f.createElement("canvas");typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(d);if(!d||!d.getContext)return null;var n=d.getContext("2d");if(!n)return null;switch(c){case "getImageData":return typeof n.getImageData!=="undefined";case "toDataURL":return typeof d.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.object.clone,m=l.util.toFixed,p=l.util.string.capitalize,h=l.util.getPointer,e=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,e.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=f(this._getOptions(),a)},_getOptions:function(){return f(k(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var a=this.constructor;if(a)if(a=a.superclass)if((a=a.prototype)&&typeof a._getOptions=="function")return a._getOptions();return{}},_importProperties:function(){this.stateProperties.forEach(function(a){a==="angle"?
this.setAngle(this.options[a]):this[a]=this.options[a]},this)},transform:function(a){a.globalAlpha=this.opacity;a.translate(this.left,this.top);a.rotate(this.theta);a.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toObject:function(){var a={type:this.type,left:m(this.left,this.NUM_FRACTION_DIGITS),top:m(this.top,this.NUM_FRACTION_DIGITS),width:m(this.width,this.NUM_FRACTION_DIGITS),height:m(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,
strokeWidth:this.strokeWidth,scaleX:m(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:m(this.scaleY,this.NUM_FRACTION_DIGITS),angle:m(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:m(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var b=l.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."+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 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,c=Math.sin(this._angle+this.theta)*this._hypotenuse,g=this.theta,n=Math.sin(g);g=Math.cos(g);a={x:this.left-a,y:this.top-c};c={x:a.x+this.currentWidth*g,y:a.y+this.currentWidth*n};var q={x:a.x-this.currentHeight*n,y:a.y+this.currentHeight*g};this.oCoords={tl:a,tr:c,br:{x:c.x-this.currentHeight*n,y:c.y+this.currentHeight*g},bl:q,ml:{x:a.x-this.currentHeight/
2*n,y:a.y+this.currentHeight/2*g},mt:{x:a.x+this.currentWidth/2*g,y:a.y+this.currentWidth/2*n},mr:{x:c.x-this.currentHeight/2*n,y:c.y+this.currentHeight/2*g},mb:{x:q.x+this.currentWidth/2*g,y:q.y+this.currentWidth/2*n}};this._setCornerCoords();return this},drawBorders:function(a){var c=this.options,g=c.padding,n=g*2;a.save();a.globalAlpha=this.isMoving?c.borderOpacityWhenMoving:1;a.strokeStyle=c.borderColor;c=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(c,q);c=this.getWidth();q=this.getHeight();a.strokeRect(~~(-(c/2)-g)+0.5,~~(-(q/2)-g)+0.5,~~(c+n),~~(q+n));a.restore();return this},drawCorners:function(a){var c=this.options.cornersize,g=c/2,n=this.options.padding,q=-(this.width/2),s=-(this.height/2),w=c/this.scaleX,y=c/this.scaleY,A=(n+g)/this.scaleY,u=(n+g)/this.scaleX,v=(n+g-c)/this.scaleX;n=(n+g-c)/this.scaleY;a.save();a.globalAlpha=this.isMoving?
this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;c=q-u;g=s-A;a.fillRect(c,g,w,y);c=q+this.width-u;g=s-A;a.fillRect(c,g,w,y);c=q-u;g=s+this.height+n;a.fillRect(c,g,w,y);c=q+this.width+v;g=s+this.height+n;a.fillRect(c,g,w,y);c=q+this.width/2-u;g=s-A;a.fillRect(c,g,w,y);c=q+this.width/2-u;g=s+this.height+n;a.fillRect(c,g,w,y);c=q+this.width+v;g=s+this.height/2-A;a.fillRect(c,g,w,y);c=q-u;g=s+this.height/2-A;a.fillRect(c,g,w,y);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),
a);return new m.Object(this.toObject())},cloneAsImage:function(a){if(m.Image){var c=new Image;c.onload=function(){a&&a(new m.Image(c),g);c=c.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);c.src=this.toDataURL()}return this},toDataURL:function(){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();m.util.wrapElement(a,"div");var c=new m.Element(a);c.backgroundColor=
"transparent";c.renderAll();var g=this.clone();g.left=a.width/2;g.top=a.height/2;g.setActive(false);c.add(g);a=c.toDataURL("png");c.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,c){var g=this.oCoords,n=new m.Point(g.tl.x,g.tl.y),q=new m.Point(g.tr.x,g.tr.y),s=new m.Point(g.bl.x,
g.bl.y);g=new m.Point(g.br.x,g.br.y);return m.Intersection.intersectPolygonRectangle([n,q,g,s],a,c).status==="Intersection"},intersectsWithObject:function(a){function c(n){return{tl:new m.Point(n.tl.x,n.tl.y),tr:new m.Point(n.tr.x,n.tr.y),bl:new m.Point(n.bl.x,n.bl.y),br:new m.Point(n.br.x,n.br.y)}}var g=c(this.oCoords);a=c(a.oCoords);return m.Intersection.intersectPolygonPolygon([g.tl,g.tr,g.br,g.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,c){var g=this.oCoords,
n=new m.Point(g.tl.x,g.tl.y),q=new m.Point(g.tr.x,g.tr.y),s=new m.Point(g.bl.x,g.bl.y);new m.Point(g.br.x,g.br.y);return n.x>a.x&&q.x<c.x&&n.y>a.y&&s.y<c.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,c){var g=l(a),n=g.x-c.left;g=g.y-c.top;var q;for(var s in this.oCoords){q=this._getImageLines(this.oCoords[s].corner,s);q=this._findCrossPoints(n,g,q);if(q%2==1&&q!=0)return this.__corner=s}return false},_findCrossPoints:function(a,c,g){var n,q,s,w=0;for(var y in g){s=g[y];
if(!(s.o.y<c&&s.d.y<c))if(!(s.o.y>=c&&s.d.y>=c)){if(s.o.x==s.d.x&&s.o.x>=a)n=s.o.x;else{n=(s.d.y-s.o.y)/(s.d.x-s.o.x);q=c-0*a;s=s.o.y-n*s.o.x;n=-(q-s)/(0-n)}if(n>=a)w+=1;if(w==2)break}}return w},_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,c=this.theta,g=this.cornersize*Math.cos(c),n=this.cornersize*Math.sin(c);c=this.cornersize/2;var q=c-n;a.tl.x-=q;a.tl.y-=
c;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+g,y:a.tl.y+n},bl:{x:a.tl.x-n,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-n,y:a.tl.corner.tr.y+g};a.tl.x+=q;a.tl.y+=c;a.tr.x+=c;a.tr.y-=c;a.tr.corner={tl:{x:a.tr.x-g,y:a.tr.y-n},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-n,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-n,y:a.tr.corner.tl.y+g};a.tr.x-=c;a.tr.y+=c;a.bl.x-=c;a.bl.y+=c;a.bl.corner={tl:{x:a.bl.x+n,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+n}};a.bl.corner.tr={x:a.bl.corner.br.x+
n,y:a.bl.corner.br.y-g};a.bl.x+=c;a.bl.y-=c;a.br.x+=c;a.br.y+=c;a.br.corner={tr:{x:a.br.x+n,y:a.br.y-g},bl:{x:a.br.x-g,y:a.br.y-n},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+n,y:a.br.corner.bl.y-g};a.br.x-=c;a.br.y-=c;a.ml.x-=c;a.ml.y-=c;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+g,y:a.ml.y+n},bl:{x:a.ml.x-n,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x-n,y:a.ml.corner.tr.y+g};a.ml.x+=c;a.ml.y+=c;a.mt.x-=c;a.mt.y-=c;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+g,y:a.mt.y+
n},bl:{x:a.mt.x-n,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-n,y:a.mt.corner.tr.y+g};a.mt.x+=c;a.mt.y+=c;a.mr.x-=c;a.mr.y-=c;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+g,y:a.mr.y+n},bl:{x:a.mr.x-n,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-n,y:a.mr.corner.tr.y+g};a.mr.x+=c;a.mr.y+=c;a.mb.x-=c;a.mb.y-=c;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+g,y:a.mb.y+n},bl:{x:a.mb.x-n,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-n,y:a.mb.corner.tr.y+g};a.mb.x+=c;a.mb.y+=c;a=a.mb.corner;
a.tl.x-=c;a.tl.y-=c;a.tr.x-=c;a.tr.y-=c;a.br.x-=c;a.br.y-=c;a.bl.x-=c;a.bl.y-=c},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new m.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 c=function(){},g=a.onComplete||c,n=a.onChange||
c,q=this;m.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(s){q.setAngle(s);n()},onComplete:function(){q.setCoords();g()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var c=function(){},g=a.onComplete||c,n=a.onChange||c,q=this;m.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(s){q.set("opacity",s);n()},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()}});m.Object.prototype.rotate=m.Object.prototype.setAngle}})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend;if(m.Line)m.warn("fabric.Line is already defined");else{m.Line=m.util.createClass(m.Object,{type:"line",initialize:function(f,h){f||(f=[0,0,0,0]);this.callSuper("initialize",h);this.set("x1",f[0]);this.set("y1",f[1]);this.set("x2",f[2]);this.set("y2",f[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(f){f.beginPath();
f.moveTo(-this.width/2,-this.height/2);f.lineTo(this.width/2,this.height/2);var h=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=h},complexity:function(){return 1},toObject:function(){return o(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});m.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");m.Line.fromElement=function(f,h){var p=m.parseAttributes(f,m.Line.ATTRIBUTE_NAMES);return new m.Line([p.x1||
0,p.y1||0,p.x2||0,p.y2||0],o(p,h))};m.Line.fromObject=function(f){return new m.Line([f.x1,f.y1,f.x2,f.y2],f)}}})();
(function(){var m=this.fabric||(this.fabric={}),o=Math.PI*2,f=m.util.object.extend;if(m.Circle)m.warn("fabric.Circle is already defined.");else{m.Circle=m.util.createClass(m.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 f(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,o,false);h.closePath();this.fill&&h.fill();this.stroke&&h.stroke()},complexity:function(){return 1}});m.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");m.Circle.fromElement=function(h,p){p||(p={});var l=m.parseAttributes(h,m.Circle.ATTRIBUTE_NAMES);if(!("radius"in l&&l.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in l)l.left-=p.width/2||0;if("top"in l)l.top-=p.height/2||0;return new m.Circle(f(l,
p))};m.Circle.fromObject=function(h){return new m.Circle(h)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Triangle)m.warn("fabric.Triangle is already defined");else{m.Triangle=m.util.createClass(m.Object,{type:"triangle",initialize:function(o){o=o||{};this.callSuper("initialize",o);this.set("width",o.width||100).set("height",o.height||100)},_render:function(o){var f=this.width/2,h=this.height/2;o.beginPath();o.moveTo(-f,h);o.lineTo(0,-h);o.lineTo(f,h);o.closePath();this.fill&&o.fill();this.stroke&&o.stroke()},complexity:function(){return 1}});m.Triangle.fromObject=
function(o){return new m.Triangle(o)}}})();
(function(){var m=this.fabric||(this.fabric={}),o=Math.PI*2,f=m.util.object.extend;if(m.Ellipse)m.warn("fabric.Ellipse is already defined.");else{m.Ellipse=m.util.createClass(m.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 f(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,o,false);h.restore();this.stroke&&h.stroke();this.fill&&h.fill()},complexity:function(){return 1}});m.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Ellipse.fromElement=function(h,p){p||(p={});var l=m.parseAttributes(h,m.Ellipse.ATTRIBUTE_NAMES);if("left"in l)l.left-=p.width/
2||0;if("top"in l)l.top-=p.height/2||0;return new m.Ellipse(f(l,p))};m.Ellipse.fromObject=function(h){return new m.Ellipse(h)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Rect)console.warn("fabric.Rect is already defined");else{m.Rect=m.util.createClass(m.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(o){this.callSuper("initialize",o);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(o){var f=this.options.rx||0,h=this.options.ry||0,p=-this.width/2,l=-this.height/
2,e=this.width,a=this.height;o.beginPath();o.moveTo(p+f,l);o.lineTo(p+e-f,l);o.bezierCurveTo(p+e,l,p+e,l+h,p+e,l+h);o.lineTo(p+e,l+a-h);o.bezierCurveTo(p+e,l+a,p+e-f,l+a,p+e-f,l+a);o.lineTo(p+f,l+a);o.bezierCurveTo(p,l+a,p,l+a-h,p,l+a-h);o.lineTo(p,l+h);o.bezierCurveTo(p,l,p+f,l,p+f,l);o.closePath();this.fill&&o.fill();this.stroke&&o.stroke()},_normalizeLeftTopProperties:function(o){o.left&&this.set("left",o.left+this.getWidth()/2);o.top&&this.set("top",o.top+this.getHeight()/2);return this},complexity:function(){return 1}});
m.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Rect.fromElement=function(o,f){if(!o)return null;var h=m.parseAttributes(o,m.Rect.ATTRIBUTE_NAMES);h=h;h.left=h.left||0;h.top=h.top||0;h=h;var p=new m.Rect(m.util.object.extend(f||{},h));p._normalizeLeftTopProperties(h);return p};m.Rect.fromObject=function(o){return new m.Rect(o)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Polyline)m.warn("fabric.Polyline is already defined");else{m.Polyline=m.util.createClass(m.Object,{type:"polyline",initialize:function(o,f){f=f||{};this.set("points",o);this.callSuper("initialize",f);this._calcDimensions()},_calcDimensions:function(){return m.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return m.Polygon.prototype.toObject.call(this)},_render:function(o){var f;o.beginPath();for(var h=0,p=this.points.length;h<
p;h++){f=this.points[h];o.lineTo(f.x,f.y)}this.fill&&o.fill();this.stroke&&o.stroke()},complexity:function(){return this.get("points").length}});m.Polyline.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");m.Polyline.fromElement=function(o,f){if(!o)return null;f||(f={});for(var h=m.parsePointsAttribute(o.getAttribute("points")),p=m.parseAttributes(o,m.Polyline.ATTRIBUTE_NAMES),l=0,e=h.length;l<e;l++){h[l].x-=f.width/2||0;h[l].y-=f.height/2||0}return new m.Polyline(h,m.util.object.extend(p,
f))};m.Polyline.fromObject=function(o){return new m.Polyline(o.points,o)}}})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.array.min,h=m.util.array.max;if(m.Polygon)m.warn("fabric.Polygon is already defined");else{m.Polygon=m.util.createClass(m.Object,{type:"polygon",initialize:function(p,l){l=l||{};this.points=p;this.callSuper("initialize",l);this._calcDimensions()},_calcDimensions:function(){var p=this.points,l=f(p,"x"),e=f(p,"y"),a=h(p,"x");p=h(p,"y");this.width=a-l;this.height=p-e;this.minX=l;this.minY=e},toObject:function(){return o(this.callSuper("toObject"),
{points:this.points.concat()})},_render:function(p){var l;p.beginPath();for(var e=0,a=this.points.length;e<a;e++){l=this.points[e];p.lineTo(l.x,l.y)}this.fill&&p.fill();if(this.stroke){p.closePath();p.stroke()}},complexity:function(){return this.points.length}});m.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");m.Polygon.fromElement=function(p,l){if(!p)return null;l||(l={});for(var e=m.parsePointsAttribute(p.getAttribute("points")),a=m.parseAttributes(p,m.Polygon.ATTRIBUTE_NAMES),
c=0,g=e.length;c<g;c++){e[c].x-=l.width/2||0;e[c].y-=l.height/2||0}return new m.Polygon(e,o(a,l))};m.Polygon.fromObject=function(p){return new m.Polygon(p.points,p)}}})();
(function(){function m(e){if(e[0]==="H")return e[1];return e[e.length-2]}function o(e){if(e[0]==="V")return e[1];return e[e.length-1]}var f=this.fabric||(this.fabric={}),h=f.util.array.min,p=f.util.array.max,l=f.util.object.extend;if(f.Path)f.warn("fabric.Path is already defined");else if(f.Object){f.Path=f.util.createClass(f.Object,{type:"path",initialize:function(e,a){a=a||{};this.setOptions(a);this._importProperties();this.originalState={};if(!e)throw Error("`path` argument is required");var c=
Object.prototype.toString.call(e)==="[object Array]";if(this.path=c?e:e.match&&e.match(/[a-zA-Z][^a-zA-Z]*/g)){c||this._initializeFromArray(a);this.setCoords();a.sourcePath&&this.setSourcePath(a.sourcePath)}},_initializeFromArray:function(e){var a="width"in e;e="height"in e;this.path=this._parsePath();if(!a||!e){l(this,this._parseDimensions());if(a)this.width=this.options.width;if(e)this.height=this.options.height}},_render:function(e){for(var a,c=0,g=0,n=0,q=0,s,w,y=-(this.width/2),A=-(this.height/
2),u=0,v=this.path.length;u<v;++u){a=this.path[u];switch(a[0]){case "l":c+=a[1];g+=a[2];e.lineTo(c+y,g+A);break;case "L":c=a[1];g=a[2];e.lineTo(c+y,g+A);break;case "h":c+=a[1];e.lineTo(c+y,g+A);break;case "H":c=a[1];e.lineTo(c+y,g+A);break;case "v":g+=a[1];e.lineTo(c+y,g+A);break;case "V":g=a[1];e.lineTo(c+y,g+A);break;case "m":c+=a[1];g+=a[2];e.moveTo(c+y,g+A);break;case "M":c=a[1];g=a[2];e.moveTo(c+y,g+A);break;case "c":s=c+a[5];w=g+a[6];n=c+a[3];q=g+a[4];e.bezierCurveTo(c+a[1]+y,g+a[2]+A,n+y,q+
A,s+y,w+A);c=s;g=w;break;case "C":c=a[5];g=a[6];n=a[3];q=a[4];e.bezierCurveTo(a[1]+y,a[2]+A,n+y,q+A,c+y,g+A);break;case "s":s=c+a[3];w=g+a[4];n=2*c-n;q=2*g-q;e.bezierCurveTo(n+y,q+A,c+a[1]+y,g+a[2]+A,s+y,w+A);c=s;g=w;break;case "S":s=a[3];w=a[4];n=2*c-n;q=2*g-q;e.bezierCurveTo(n+y,q+A,a[1]+y,a[2]+A,s+y,w+A);c=s;g=w;break;case "q":c+=a[3];g+=a[4];e.quadraticCurveTo(a[1]+y,a[2]+A,c+y,g+A);break;case "Q":c=a[3];g=a[4];n=a[1];q=a[2];e.quadraticCurveTo(n+y,q+A,c+y,g+A);break;case "T":s=c;w=g;c=a[1];g=
a[2];n=-n+2*s;q=-q+2*w;e.quadraticCurveTo(n+y,q+A,c+y,g+A);break;case "a":break;case "A":break;case "z":case "Z":e.closePath();break}}},render:function(e,a){e.save();var c=this.transformMatrix;c&&e.transform(c[0],c[1],c[2],c[3],c[4],c[5]);a||this.transform(e);if(this.overlayFill)e.fillStyle=this.overlayFill;else if(this.fill)e.fillStyle=this.fill;if(this.stroke)e.strokeStyle=this.stroke;e.beginPath();this._render(e);this.fill&&e.fill();if(this.stroke){e.strokeStyle=this.stroke;e.lineWidth=this.strokeWidth;
e.lineCap=e.lineJoin="round";e.stroke()}if(!a&&this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var e=l(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)e.sourcePath=this.sourcePath;if(this.transformMatrix)e.transformMatrix=this.transformMatrix;return e},toDatalessObject:function(){var e=this.toObject();if(this.sourcePath)e.path=
this.sourcePath;delete e.sourcePath;return e},complexity:function(){return this.path.length},_parsePath:function(){for(var e=[],a,c,g=0,n=this.path.length;g<n;g++){a=this.path[g];c=a.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);e.push([a.charAt(0)].concat(c.map(parseFloat)))}return e},_parseDimensions:function(){var e=[],a=[],c,g,n=false,q,s;this.path.forEach(function(u,v){if(u[0]!=="H")c=v===0?m(u):m(this.path[v-1]);if(u[0]!=="V")g=v===0?o(u):o(this.path[v-1]);if(u[0]===u[0].toLowerCase())n=
true;q=n?c+m(u):u[0]==="V"?c:m(u);s=n?g+o(u):u[0]==="H"?g:o(u);var E=parseInt(q,10);isNaN(E)||e.push(E);E=parseInt(s,10);isNaN(E)||a.push(E)},this);var w=h(e),y=h(a),A=deltaY=0;w={top:y-deltaY,left:w-A,bottom:p(a)-deltaY,right:p(e)-A};w.width=w.right-w.left;w.height=w.bottom-w.top;return w}});f.Path.fromObject=function(e){return new f.Path(e.path,e)};f.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");f.Path.fromElement=function(e,a){var c=f.parseAttributes(e,
f.Path.ATTRIBUTE_NAMES),g=c.d;delete c.d;return new f.Path(g,l(c,a))}}else f.warn("fabric.Path requires fabric.Object")})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.array.invoke,h=m.Object.prototype.set,p=m.Object.prototype.toObject,l=m.util.string.camelize,e=m.util.string.capitalize;if(m.PathGroup)m.warn("fabric.PathGroup is already defined");else{m.PathGroup=m.util.createClass(m.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(a,c){c=c||{};this.originalState={};this.paths=a;this.setOptions(c);this._initProperties();this.setCoords();c.sourcePath&&this.setSourcePath(c.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 c=this.transformMatrix;c&&a.transform(c[0],c[1],c[2],c[3],c[4],c[5]);this.transform(a);c=0;for(var g=this.paths.length;c<g;++c)this.paths[c].render(a,
true);if(this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}}a.restore()},set:function(a,c){if((a==="fill"||a==="overlayFill")&&this.isSameColor()){this[a]=c;for(var g=this.paths.length;g--;)this.paths[g].set(a,c)}else h.call(this,a,c);return this},toObject:function(){return o(p.call(this),{paths:f(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(c){return c.get("fill")===a})},complexity:function(){return this.paths.reduce(function(a,c){return a+(c&&c.complexity?c.complexity():0)},0)},toGrayscale:function(){for(var a=this.paths.length;a--;)this.paths[a].toGrayscale();return this},getObjects:function(){return this.paths}});m.PathGroup.fromObject=function(a){for(var c=a.paths,
g=0,n=c.length;g<n;g++)if(!(c[g]instanceof m.Object)){var q=l(e(c[g].type));c[g]=m[q].fromObject(c[g])}return new m.PathGroup(c,a)}}})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.array.min,h=m.util.array.max,p=m.util.array.invoke,l=m.util.removeFromArray;if(!m.Group){m.Group=m.util.createClass(m.Object,{type:"group",initialize:function(e,a){this.objects=e||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();a&&o(this,a);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var e=
this.left,a=this.top;this.forEachObject(function(c){var g=c.get("left"),n=c.get("top");c.set("originalLeft",g);c.set("originalTop",n);c.set("left",g-e);c.set("top",n-a);c.setCoords();c.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(e){this._restoreObjectsState();this.objects.push(e);e.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(e){this._restoreObjectsState();
l(this.objects,e);e.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(e,a){if(typeof a=="function")this.set(e,a(this[e]));else if(e==="fill"||e==="opacity"){var c=this.objects.length;for(this[e]=a;c--;)this.objects[c].set(e,a)}else this[e]=a;return this},contains:function(e){return this.objects.indexOf(e)>-1},toObject:function(){return o(this.callSuper("toObject"),{objects:p(this.objects,"clone")})},render:function(e){e.save();
this.transform(e);for(var a=Math.max(this.scaleX,this.scaleY),c=0,g;g=this.objects[c];c++){var n=g.borderScaleFactor;g.borderScaleFactor=a;g.render(e);g.borderScaleFactor=n}this.hideBorders||this.drawBorders(e);this.hideCorners||this.drawCorners(e);e.restore();this.setCoords()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,a){e+=typeof a.complexity=="function"?a.complexity():0;return e},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,
this);return this},_restoreObjectState:function(e){var a=this.get("left"),c=this.get("top"),g=this.getAngle()*(Math.PI/180);e.get("originalLeft");e.get("originalTop");var n=Math.cos(g)*e.get("top")+Math.sin(g)*e.get("left");g=-Math.sin(g)*e.get("top")+Math.cos(g)*e.get("left");e.setAngle(e.getAngle()+this.getAngle());e.set("left",a+g*this.get("scaleX"));e.set("top",c+n*this.get("scaleY"));e.set("scaleX",e.get("scaleX")*this.get("scaleX"));e.set("scaleY",e.get("scaleY")*this.get("scaleY"));e.setCoords();
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,o=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*o};var q={x:a.x-this.currentHeight*o,y:a.y+this.currentHeight*g};this.oCoords={tl:a,tr:b,br:{x:b.x-this.currentHeight*o,y:b.y+this.currentHeight*g},bl:q,ml:{x:a.x-this.currentHeight/
2*o,y:a.y+this.currentHeight/2*g},mt:{x:a.x+this.currentWidth/2*g,y:a.y+this.currentWidth/2*o},mr:{x:b.x-this.currentHeight/2*o,y:b.y+this.currentHeight/2*g},mb:{x:q.x+this.currentWidth/2*g,y:q.y+this.currentWidth/2*o}};this._setCornerCoords();return this},drawBorders:function(a){var b=this.options,g=b.padding,o=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+o),~~(q+o));a.restore();return this},drawCorners:function(a){var b=this.options.cornersize,g=b/2,o=this.options.padding,q=-(this.width/2),t=-(this.height/2),A=b/this.scaleX,w=b/this.scaleY,B=(o+g)/this.scaleY,v=(o+g)/this.scaleX,C=(o+g-b)/this.scaleX;o=(o+g-b)/this.scaleY;a.save();a.globalAlpha=this.isMoving?
this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;b=q-v;g=t-B;a.fillRect(b,g,A,w);b=q+this.width-v;g=t-B;a.fillRect(b,g,A,w);b=q-v;g=t+this.height+o;a.fillRect(b,g,A,w);b=q+this.width+C;g=t+this.height+o;a.fillRect(b,g,A,w);b=q+this.width/2-v;g=t-B;a.fillRect(b,g,A,w);b=q+this.width/2-v;g=t+this.height+o;a.fillRect(b,g,A,w);b=q+this.width+C;g=t+this.height/2-B;a.fillRect(b,g,A,w);b=q-v;g=t+this.height/2-B;a.fillRect(b,g,A,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),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();l.util.wrapElement(a,"div");var b=new l.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,o=new l.Point(g.tl.x,g.tl.y),q=new l.Point(g.tr.x,g.tr.y),t=new l.Point(g.bl.x,
g.bl.y);g=new l.Point(g.br.x,g.br.y);return l.Intersection.intersectPolygonRectangle([o,q,g,t],a,b).status==="Intersection"},intersectsWithObject:function(a){function b(o){return{tl:new l.Point(o.tl.x,o.tl.y),tr:new l.Point(o.tr.x,o.tr.y),bl:new l.Point(o.bl.x,o.bl.y),br:new l.Point(o.br.x,o.br.y)}}var g=b(this.oCoords);a=b(a.oCoords);return l.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,
o=new l.Point(g.tl.x,g.tl.y),q=new l.Point(g.tr.x,g.tr.y),t=new l.Point(g.bl.x,g.bl.y);new l.Point(g.br.x,g.br.y);return o.x>a.x&&q.x<b.x&&o.y>a.y&&t.y<b.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,b){var g=h(a),o=g.x-b.left;g=g.y-b.top;var q;for(var t in this.oCoords){q=this._getImageLines(this.oCoords[t].corner,t);q=this._findCrossPoints(o,g,q);if(q%2==1&&q!=0)return this.__corner=t}return false},_findCrossPoints:function(a,b,g){var o,q,t,A=0;for(var w in g){t=g[w];
if(!(t.o.y<b&&t.d.y<b))if(!(t.o.y>=b&&t.d.y>=b)){if(t.o.x==t.d.x&&t.o.x>=a)o=t.o.x;else{o=(t.d.y-t.o.y)/(t.d.x-t.o.x);q=b-0*a;t=t.o.y-o*t.o.x;o=-(q-t)/(0-o)}if(o>=a)A+=1;if(A==2)break}}return A},_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),o=this.cornersize*Math.sin(b);b=this.cornersize/2;var q=b-o;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+o},bl:{x:a.tl.x-o,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-o,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-o},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-o,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-o,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+o,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+o}};a.bl.corner.tr={x:a.bl.corner.br.x+
o,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+o,y:a.br.y-g},bl:{x:a.br.x-g,y:a.br.y-o},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+o,y:a.br.corner.bl.y-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+o},bl:{x:a.ml.x-o,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x-o,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+
o},bl:{x:a.mt.x-o,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-o,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+o},bl:{x:a.mr.x-o,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-o,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+o},bl:{x:a.mb.x-o,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-o,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 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(){},g=a.onComplete||b,o=a.onChange||
b,q=this;l.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){q.setAngle(t);o()},onComplete:function(){q.setCoords();g()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var b=function(){},g=a.onComplete||b,o=a.onChange||b,q=this;l.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(t){q.set("opacity",t);o()},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()}});l.Object.prototype.rotate=l.Object.prototype.setAngle}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=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(k,m){k||(k=[0,0,0,0]);this.callSuper("initialize",m);this.set("x1",k[0]);this.set("y1",k[1]);this.set("x2",k[2]);this.set("y2",k[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(k){k.beginPath();
k.moveTo(-this.width/2,-this.height/2);k.lineTo(this.width/2,this.height/2);var m=k.strokeStyle;k.strokeStyle=k.fillStyle;k.stroke();k.strokeStyle=m},complexity:function(){return 1},toObject:function(){return f(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});l.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");l.Line.fromElement=function(k,m){var p=l.parseAttributes(k,l.Line.ATTRIBUTE_NAMES);return new l.Line([p.x1||
0,p.y1||0,p.x2||0,p.y2||0],f(p,m))};l.Line.fromObject=function(k){return new l.Line([k.x1,k.y1,k.x2,k.y2],k)}}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=Math.PI*2,k=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(m){m=m||{};this.set("radius",m.radius||0);this.callSuper("initialize",m);m=this.get("radius")*2*this.get("scaleX");this.set("width",m).set("height",m)},toObject:function(){return k(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(m,p){m.beginPath();m.arc(p?this.left:
0,p?this.top:0,this.radius,0,f,false);m.closePath();this.fill&&m.fill();this.stroke&&m.stroke()},complexity:function(){return 1}});l.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");l.Circle.fromElement=function(m,p){p||(p={});var h=l.parseAttributes(m,l.Circle.ATTRIBUTE_NAMES);if(!("radius"in h&&h.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in h)h.left-=p.width/2||0;if("top"in h)h.top-=p.height/2||0;return new l.Circle(k(h,
p))};l.Circle.fromObject=function(m){return new l.Circle(m)}}})(this);
(function(z){var l=z.fabric||(z.fabric={});if(l.Triangle)l.warn("fabric.Triangle is already defined");else{l.Triangle=l.util.createClass(l.Object,{type:"triangle",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("width",f.width||100).set("height",f.height||100)},_render:function(f){var k=this.width/2,m=this.height/2;f.beginPath();f.moveTo(-k,m);f.lineTo(0,-m);f.lineTo(k,m);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return 1}});l.Triangle.fromObject=
function(f){return new l.Triangle(f)}}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=Math.PI*2,k=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(m){m=m||{};this.callSuper("initialize",m);this.set("rx",m.rx||0);this.set("ry",m.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return k(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(m,p){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",m,p)},_render:function(m,p){m.beginPath();m.save();m.transform(1,0,0,this.ry/this.rx,0,0);m.arc(p?this.left:0,p?this.top:0,this.rx,0,f,false);m.restore();this.stroke&&m.stroke();this.fill&&m.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(m,p){p||(p={});var h=l.parseAttributes(m,l.Ellipse.ATTRIBUTE_NAMES);if("left"in h)h.left-=p.width/
2||0;if("top"in h)h.top-=p.height/2||0;return new l.Ellipse(k(h,p))};l.Ellipse.fromObject=function(m){return new l.Ellipse(m)}}})(this);
(function(z){var l=z.fabric||(z.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(f){this.callSuper("initialize",f);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(f){var k=this.options.rx||0,m=this.options.ry||0,p=-this.width/2,h=-this.height/
2,e=this.width,a=this.height;f.beginPath();f.moveTo(p+k,h);f.lineTo(p+e-k,h);f.bezierCurveTo(p+e,h,p+e,h+m,p+e,h+m);f.lineTo(p+e,h+a-m);f.bezierCurveTo(p+e,h+a,p+e-k,h+a,p+e-k,h+a);f.lineTo(p+k,h+a);f.bezierCurveTo(p,h+a,p,h+a-m,p,h+a-m);f.lineTo(p,h+m);f.bezierCurveTo(p,h,p+k,h,p+k,h);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},_normalizeLeftTopProperties:function(f){f.left&&this.set("left",f.left+this.getWidth()/2);f.top&&this.set("top",f.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(f,k){if(!f)return null;var m=l.parseAttributes(f,l.Rect.ATTRIBUTE_NAMES);m=m;m.left=m.left||0;m.top=m.top||0;m=m;var p=new l.Rect(l.util.object.extend(k||{},m));p._normalizeLeftTopProperties(m);return p};l.Rect.fromObject=function(f){return new l.Rect(f)}}})(this);
(function(z){var l=z.fabric||(z.fabric={});if(l.Polyline)l.warn("fabric.Polyline is already defined");else{l.Polyline=l.util.createClass(l.Object,{type:"polyline",initialize:function(f,k){k=k||{};this.set("points",f);this.callSuper("initialize",k);this._calcDimensions()},_calcDimensions:function(){return l.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return l.Polygon.prototype.toObject.call(this)},_render:function(f){var k;f.beginPath();for(var m=0,p=this.points.length;m<p;m++){k=
this.points[m];f.lineTo(k.x,k.y)}this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return this.get("points").length}});l.Polyline.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");l.Polyline.fromElement=function(f,k){if(!f)return null;k||(k={});for(var m=l.parsePointsAttribute(f.getAttribute("points")),p=l.parseAttributes(f,l.Polyline.ATTRIBUTE_NAMES),h=0,e=m.length;h<e;h++){m[h].x-=k.width/2||0;m[h].y-=k.height/2||0}return new l.Polyline(m,l.util.object.extend(p,
k))};l.Polyline.fromObject=function(f){return new l.Polyline(f.points,f)}}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.array.min,m=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,h){h=h||{};this.points=p;this.callSuper("initialize",h);this._calcDimensions()},_calcDimensions:function(){var p=this.points,h=k(p,"x"),e=k(p,"y"),a=m(p,"x");p=m(p,"y");this.width=a-h;this.height=p-e;this.minX=h;this.minY=e},toObject:function(){return f(this.callSuper("toObject"),
{points:this.points.concat()})},_render:function(p){var h;p.beginPath();for(var e=0,a=this.points.length;e<a;e++){h=this.points[e];p.lineTo(h.x,h.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,h){if(!p)return null;h||(h={});for(var e=l.parsePointsAttribute(p.getAttribute("points")),a=l.parseAttributes(p,l.Polygon.ATTRIBUTE_NAMES),
b=0,g=e.length;b<g;b++){e[b].x-=h.width/2||0;e[b].y-=h.height/2||0}return new l.Polygon(e,f(a,h))};l.Polygon.fromObject=function(p){return new l.Polygon(p.points,p)}}})(this);
(function(z){function l(e){if(e[0]==="H")return e[1];return e[e.length-2]}function f(e){if(e[0]==="V")return e[1];return e[e.length-1]}var k=z.fabric||(z.fabric={}),m=k.util.array.min,p=k.util.array.max,h=k.util.object.extend;if(k.Path)k.warn("fabric.Path is already defined");else if(k.Object){k.Path=k.util.createClass(k.Object,{type:"path",initialize:function(e,a){a=a||{};this.setOptions(a);this._importProperties();this.originalState={};if(!e)throw Error("`path` argument is required");var b=Object.prototype.toString.call(e)===
"[object Array]";if(this.path=b?e:e.match&&e.match(/[a-zA-Z][^a-zA-Z]*/g)){b||this._initializeFromArray(a);this.setCoords();a.sourcePath&&this.setSourcePath(a.sourcePath)}},_initializeFromArray:function(e){var a="width"in e;e="height"in e;this.path=this._parsePath();if(!a||!e){h(this,this._parseDimensions());if(a)this.width=this.options.width;if(e)this.height=this.options.height}},_render:function(e){for(var a,b=0,g=0,o=0,q=0,t,A,w=-(this.width/2),B=-(this.height/2),v=0,C=this.path.length;v<C;++v){a=
this.path[v];switch(a[0]){case "l":b+=a[1];g+=a[2];e.lineTo(b+w,g+B);break;case "L":b=a[1];g=a[2];e.lineTo(b+w,g+B);break;case "h":b+=a[1];e.lineTo(b+w,g+B);break;case "H":b=a[1];e.lineTo(b+w,g+B);break;case "v":g+=a[1];e.lineTo(b+w,g+B);break;case "V":g=a[1];e.lineTo(b+w,g+B);break;case "m":b+=a[1];g+=a[2];e.moveTo(b+w,g+B);break;case "M":b=a[1];g=a[2];e.moveTo(b+w,g+B);break;case "c":t=b+a[5];A=g+a[6];o=b+a[3];q=g+a[4];e.bezierCurveTo(b+a[1]+w,g+a[2]+B,o+w,q+B,t+w,A+B);b=t;g=A;break;case "C":b=
a[5];g=a[6];o=a[3];q=a[4];e.bezierCurveTo(a[1]+w,a[2]+B,o+w,q+B,b+w,g+B);break;case "s":t=b+a[3];A=g+a[4];o=2*b-o;q=2*g-q;e.bezierCurveTo(o+w,q+B,b+a[1]+w,g+a[2]+B,t+w,A+B);b=t;g=A;break;case "S":t=a[3];A=a[4];o=2*b-o;q=2*g-q;e.bezierCurveTo(o+w,q+B,a[1]+w,a[2]+B,t+w,A+B);b=t;g=A;break;case "q":b+=a[3];g+=a[4];e.quadraticCurveTo(a[1]+w,a[2]+B,b+w,g+B);break;case "Q":b=a[3];g=a[4];o=a[1];q=a[2];e.quadraticCurveTo(o+w,q+B,b+w,g+B);break;case "T":t=b;A=g;b=a[1];g=a[2];o=-o+2*t;q=-q+2*A;e.quadraticCurveTo(o+
w,q+B,b+w,g+B);break;case "a":break;case "A":break;case "z":case "Z":e.closePath();break}}},render:function(e,a){e.save();var b=this.transformMatrix;b&&e.transform(b[0],b[1],b[2],b[3],b[4],b[5]);a||this.transform(e);if(this.overlayFill)e.fillStyle=this.overlayFill;else if(this.fill)e.fillStyle=this.fill;if(this.stroke)e.strokeStyle=this.stroke;e.beginPath();this._render(e);this.fill&&e.fill();if(this.stroke){e.strokeStyle=this.stroke;e.lineWidth=this.strokeWidth;e.lineCap=e.lineJoin="round";e.stroke()}if(!a&&
this.active){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var e=h(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)e.sourcePath=this.sourcePath;if(this.transformMatrix)e.transformMatrix=this.transformMatrix;return e},toDatalessObject:function(){var e=this.toObject();if(this.sourcePath)e.path=this.sourcePath;delete e.sourcePath;
return e},complexity:function(){return this.path.length},_parsePath:function(){for(var e=[],a,b,g=0,o=this.path.length;g<o;g++){a=this.path[g];b=a.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);e.push([a.charAt(0)].concat(b.map(parseFloat)))}return e},_parseDimensions:function(){var e=[],a=[],b,g,o=false,q,t;this.path.forEach(function(v,C){if(v[0]!=="H")b=C===0?l(v):l(this.path[C-1]);if(v[0]!=="V")g=C===0?f(v):f(this.path[C-1]);if(v[0]===v[0].toLowerCase())o=true;q=o?b+l(v):v[0]==="V"?
b:l(v);t=o?g+f(v):v[0]==="H"?g:f(v);var F=parseInt(q,10);isNaN(F)||e.push(F);F=parseInt(t,10);isNaN(F)||a.push(F)},this);var A=m(e),w=m(a),B=deltaY=0;A={top:w-deltaY,left:A-B,bottom:p(a)-deltaY,right:p(e)-B};A.width=A.right-A.left;A.height=A.bottom-A.top;return A}});k.Path.fromObject=function(e){return new k.Path(e.path,e)};k.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");k.Path.fromElement=function(e,a){var b=k.parseAttributes(e,k.Path.ATTRIBUTE_NAMES),
g=b.d;delete b.d;return new k.Path(g,h(b,a))}}else k.warn("fabric.Path requires fabric.Object")})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.array.invoke,m=l.Object.prototype.set,p=l.Object.prototype.toObject,h=l.util.string.camelize,e=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 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 m.call(this,a,b);return this},toObject:function(){return f(p.call(this),{paths:k(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,
g=0,o=b.length;g<o;g++)if(!(b[g]instanceof l.Object)){var q=h(e(b[g].type));b[g]=l[q].fromObject(b[g])}return new l.PathGroup(b,a)}}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=l.util.array.min,m=l.util.array.max,p=l.util.array.invoke,h=l.util.removeFromArray;if(!l.Group){l.Group=l.util.createClass(l.Object,{type:"group",initialize:function(e,a){this.objects=e||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();a&&f(this,a);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var e=this.left,
a=this.top;this.forEachObject(function(b){var g=b.get("left"),o=b.get("top");b.set("originalLeft",g);b.set("originalTop",o);b.set("left",g-e);b.set("top",o-a);b.setCoords();b.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(e){this._restoreObjectsState();this.objects.push(e);e.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(e){this._restoreObjectsState();
h(this.objects,e);e.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(e,a){if(typeof a=="function")this.set(e,a(this[e]));else if(e==="fill"||e==="opacity"){var b=this.objects.length;for(this[e]=a;b--;)this.objects[b].set(e,a)}else this[e]=a;return this},contains:function(e){return this.objects.indexOf(e)>-1},toObject:function(){return f(this.callSuper("toObject"),{objects:p(this.objects,"clone")})},render:function(e){e.save();
this.transform(e);for(var a=Math.max(this.scaleX,this.scaleY),b=0,g;g=this.objects[b];b++){var o=g.borderScaleFactor;g.borderScaleFactor=a;g.render(e);g.borderScaleFactor=o}this.hideBorders||this.drawBorders(e);this.hideCorners||this.drawCorners(e);e.restore();this.setCoords()},item:function(e){return this.getObjects()[e]},complexity:function(){return this.getObjects().reduce(function(e,a){e+=typeof a.complexity=="function"?a.complexity():0;return e},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,
this);return this},_restoreObjectState:function(e){var a=this.get("left"),b=this.get("top"),g=this.getAngle()*(Math.PI/180);e.get("originalLeft");e.get("originalTop");var o=Math.cos(g)*e.get("top")+Math.sin(g)*e.get("left");g=-Math.sin(g)*e.get("top")+Math.cos(g)*e.get("left");e.setAngle(e.getAngle()+this.getAngle());e.set("left",a+g*this.get("scaleX"));e.set("top",b+o*this.get("scaleY"));e.set("scaleX",e.get("scaleX")*this.get("scaleX"));e.set("scaleY",e.get("scaleY")*this.get("scaleY"));e.setCoords();
e.hideCorners=false;e.setActive(false);e.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(e){e.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(e){this.forEachObject(function(a){a.setActive(e)});
return this},forEachObject:function(e,a){for(var c=this.getObjects(),g=c.length;g--;)e.call(a,c[g],g,c);return this},_setOpacityIfSame:function(){var e=this.getObjects(),a=e[0]?e[0].get("opacity"):1;if(e.every(function(c){return c.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var e=[],a=[],c,g;g=0;for(var n=this.objects.length;g<n;++g){c=this.objects[g];c.setCoords();for(var q in c.oCoords){e.push(c.oCoords[q].x);a.push(c.oCoords[q].y)}}c=f(e);g=h(e);e=f(a);a=h(a);g=g-c;a=a-e;this.width=
g;this.height=a;this.left=c+g/2;this.top=e+a/2},containsPoint:function(e){var a=this.get("width")/2,c=this.get("height")/2,g=this.get("left"),n=this.get("top");return g-a<e.x&&g+a>e.x&&n-c<e.y&&n+c>e.y},toGrayscale:function(){for(var e=this.objects.length;e--;)this.objects[e].toGrayscale()}});m.Group.fromObject=function(e){return new m.Group(e.objects,e)}}})();
(function(){var m=this.fabric||(this.fabric={}),o=m.util.object.extend,f=m.util.object.clone;if(m.Text)m.warn("fabric.Text is already defined");else if(m.Object){m.Text=m.util.createClass(m.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);o(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 l=this._initDummyElement();
this.transform(h);Cufon.replaceElement(l,{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 o(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}});m.Text.fromObject=function(h){return new m.Text(h.text,f(h))};m.Text.fromElement=function(){}}else m.warn("fabric.Text requires fabric.Object")})();
(function(){var m=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(o,f){this.callSuper("initialize",f);this._initElement(o);this._initConfig(f||{})},getElement:function(){return this._element},setElement:function(o){this._element=
o;return this},getNormalizedSize:function(o,f,h){if(h&&f&&o.width>o.height&&o.width/o.height<f/h){normalizedWidth=~~(o.width*h/o.height);normalizedHeight=h}else if(h&&(o.height==o.width||o.height>o.width||o.height>h)){normalizedWidth=~~(o.width*h/o.height);normalizedHeight=h}else if(f&&f<o.width){normalizedHeight=~~(o.height*f/o.width);normalizedWidth=f}else{normalizedWidth=o.width;normalizedHeight=o.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var o=this.getElement();
return{width:o.width,height:o.height}},setBorderVisibility:function(){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(o){this.cornervisibility=!!o},render:function(o,f){o.save();f||this.transform(o);this._render(o);if(this.active&&!f){this.drawBorders(o);this.hideCorners||this.drawCorners(o)}o.restore()},toObject:function(){return m(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},
toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(o){this.constructor.fromObject(this.toObject(),o)},toGrayscale:function(o){if(!this.__isGrayscaled){var f=this.getElement(),h=document.createElement("canvas"),p=document.createElement("img"),l=this;h.width=f.width;h.height=f.height;h.getContext("2d").drawImage(f,0,0);fabric.Element.toGrayscale(h);p.onload=function(){l.setElement(p);o&&o();p.onload=h=f=imageData=null};p.width=f.width;p.height=f.height;p.src=h.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(o){var f=this.getOriginalSize();o.drawImage(this.getElement(),-f.width/2,-f.height/2,f.width,f.height)},_adjustWidthHeightToBorders:function(o){if(o){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var o=this.getElement();this.set("width",o.width);this.set("height",o.height)},_initElement:function(o){this.setElement(fabric.util.getById(o));
fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(o){this.setOptions(o);this._setBorder();this._setWidthHeight(o)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var o=2*this.currentBorder;this.width=(this.getElement().width||0)+o;this.height=(this.getElement().height||0)+o},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(o,f){var h=document.createElement("img"),
p=o.src;if(o.width)h.width=o.width;if(o.height)h.height=o.height;h.onload=function(){f&&f(new fabric.Image(h,o));h=h.onload=null};h.src=p};fabric.Image.fromURL=function(o,f,h){var p=document.createElement("img");p.onload=function(){f&&f(new fabric.Image(p,h));p=p.onload=null};p.src=o}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})();
return this},forEachObject:function(e,a){for(var b=this.getObjects(),g=b.length;g--;)e.call(a,b[g],g,b);return this},_setOpacityIfSame:function(){var e=this.getObjects(),a=e[0]?e[0].get("opacity"):1;if(e.every(function(b){return b.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var e=[],a=[],b,g;g=0;for(var o=this.objects.length;g<o;++g){b=this.objects[g];b.setCoords();for(var q in b.oCoords){e.push(b.oCoords[q].x);a.push(b.oCoords[q].y)}}b=k(e);g=m(e);e=k(a);a=m(a);g=g-b;a=a-e;this.width=
g;this.height=a;this.left=b+g/2;this.top=e+a/2},containsPoint:function(e){var a=this.get("width")/2,b=this.get("height")/2,g=this.get("left"),o=this.get("top");return g-a<e.x&&g+a>e.x&&o-b<e.y&&o+b>e.y},toGrayscale:function(){for(var e=this.objects.length;e--;)this.objects[e].toGrayscale()}});l.Group.fromObject=function(e){return new l.Group(e.objects,e)}}})(this);
(function(z){var l=z.fabric||(z.fabric={}),f=l.util.object.extend,k=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(m,p){this.originalState={};this._initStateProperties();this.text=m;this.setOptions(p);f(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},
_initStateProperties:function(){var m;if((m=this.constructor)&&(m=m.superclass)&&(m=m.prototype)&&(m=m.stateProperties)&&m.clone){this.stateProperties=m.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(m){var p=Cufon.textOptions||(Cufon.textOptions={});p.left=this.left;p.top=this.top;p.context=m;p.color=this.fill;var h=this._initDummyElement();
this.transform(m);Cufon.replaceElement(h,{separate:"none",fontFamily:this.fontfamily});this.width=p.width;this.height=p.height},_initDummyElement:function(){var m=document.createElement("div");m.innerHTML=this.text;m.style.fontSize="40px";m.style.fontWeight="400";m.style.fontStyle="normal";m.style.letterSpacing="normal";m.style.color="#000000";m.style.fontWeight="600";m.style.fontFamily="Verdana";return m},render:function(m){m.save();this._render(m);if(this.active){this.drawBorders(m);this.drawCorners(m)}m.restore()},
toObject:function(){return f(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(m){this.set("fill",m);return this},setFontsize:function(m){this.set("fontsize",m);this.setCoords();return this},getText:function(){return this.text},setText:function(m){this.set("text",m);this.setCoords();return this},set:function(m,p){this[m]=p;if(m==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,
"$1"+p+"$3");return this}});l.Text.fromObject=function(m){return new l.Text(m.text,k(m))};l.Text.fromElement=function(){}}else l.warn("fabric.Text requires fabric.Object")})(this);
(function(z){var l=fabric.util.object.extend;if(!z.fabric)z.fabric={};if(z.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(f,k){this.callSuper("initialize",k);this._initElement(f);this._initConfig(k||{})},getElement:function(){return this._element},setElement:function(f){this._element=
f;return this},getNormalizedSize:function(f,k,m){if(m&&k&&f.width>f.height&&f.width/f.height<k/m){normalizedWidth=~~(f.width*m/f.height);normalizedHeight=m}else if(m&&(f.height==f.width||f.height>f.width||f.height>m)){normalizedWidth=~~(f.width*m/f.height);normalizedHeight=m}else if(k&&k<f.width){normalizedHeight=~~(f.height*k/f.width);normalizedWidth=k}else{normalizedWidth=f.width;normalizedHeight=f.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var f=this.getElement();
return{width:f.width,height:f.height}},setBorderVisibility:function(){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(f){this.cornervisibility=!!f},render:function(f,k){f.save();k||this.transform(f);this._render(f);if(this.active&&!k){this.drawBorders(f);this.hideCorners||this.drawCorners(f)}f.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(f){this.constructor.fromObject(this.toObject(),f)},toGrayscale:function(f){if(!this.__isGrayscaled){var k=this.getElement(),m=document.createElement("canvas"),p=document.createElement("img"),h=this;m.width=k.width;m.height=k.height;m.getContext("2d").drawImage(k,0,0);fabric.Element.toGrayscale(m);p.onload=function(){h.setElement(p);f&&f();p.onload=m=k=imageData=null};p.width=k.width;p.height=k.height;p.src=m.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(f){var k=this.getOriginalSize();f.drawImage(this.getElement(),-k.width/2,-k.height/2,k.width,k.height)},_adjustWidthHeightToBorders:function(f){if(f){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var f=this.getElement();this.set("width",f.width);this.set("height",f.height)},_initElement:function(f){this.setElement(fabric.util.getById(f));
fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(f){this.setOptions(f);this._setBorder();this._setWidthHeight(f)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var f=2*this.currentBorder;this.width=(this.getElement().width||0)+f;this.height=(this.getElement().height||0)+f},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(f,k){var m=document.createElement("img"),
p=f.src;if(f.width)m.width=f.width;if(f.height)m.height=f.height;m.onload=function(){k&&k(new fabric.Image(m,f));m=m.onload=null};m.src=p};fabric.Image.fromURL=function(f,k,m){var p=document.createElement("img");p.onload=function(){k&&k(new fabric.Image(p,m));p=p.onload=null};p.src=f}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})(this);

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -223,6 +223,19 @@
/* NOOP */
},
/**
* Callback; invoked every time active object is moved
* @method onObjectMove
* @param {fabric.Object} object that's being moved
*/
onObjectMove: null,
/**
* Callback; invoked when a mouseup event occurs, and at the end of all other transformations
* @method onMouseUp
*/
onMouseUp: null,
/**
* Calculates canvas element offset relative to the document
* This method is also attached as "resize" event handler of window
@ -557,6 +570,7 @@
this.renderAll();
this._setCursorFromEvent(e, target);
// fix for FF
this._setCursor('');
@ -564,6 +578,10 @@
setTimeout(function () {
_this._setCursorFromEvent(e, target);
}, 50);
if (this.onMouseUp) {
this.onMouseUp();
}
},
_shouldClearSelection: function (e) {
@ -897,7 +915,7 @@
var pointer = getPointer(e),
x = pointer.x,
y = pointer.y;
this._currentTransform.target.isMoving = true;
if (this._currentTransform.action === 'rotate') {
@ -917,6 +935,9 @@
}
else {
this._translateObject(x, y);
if (this.onObjectMove) {
this.onObjectMove(this._currentTransform.target);
}
}
// only commit here. when we are actually moving the pictures
this.renderAll();

View file

@ -0,0 +1,74 @@
/**
* Augments canvas by assigning to `onObjectMove` and `onAfterRender`.
* This kind of sucks because other code using those methods will stop functioning.
* Need to fix it by replacing callbacks with pub/sub kind of subscription model.
* (or maybe use existing fabric.util.fireEvent/observeEvent (if it won't be too slow))
*/
function initCenteringGuidelines(canvas) {
var canvasWidth = canvas.getWidth(),
canvasHeight = canvas.getHeight(),
canvasWidthCenter = canvasWidth / 2,
canvasHeightCenter = canvasHeight / 2,
canvasWidthCenterMap = { },
canvasHeightCenterMap = { },
centerLineMargin = 4,
centerLineColor = 'rgba(255,0,241,0.5)',
centerLineWidth = 1,
ctx = canvas.getContext();
for (var i = canvasWidthCenter - centerLineMargin, len = canvasWidthCenter + centerLineMargin; i <= len; i++) {
canvasWidthCenterMap[i] = true;
}
for (var i = canvasHeightCenter - centerLineMargin, len = canvasHeightCenter + centerLineMargin; i <= len; i++) {
canvasHeightCenterMap[i] = true;
}
function showVerticalCenterLine() {
showCenterLine(canvasWidthCenter + 0.5, 0, canvasWidthCenter + 0.5, canvasHeight);
}
function showHorizontalCenterLine() {
showCenterLine(0, canvasHeightCenter + 0.5, canvasWidth, canvasHeightCenter + 0.5);
}
function showCenterLine(x1, y1, x2, y2) {
ctx.save();
ctx.strokeStyle = centerLineColor;
ctx.lineWidth = centerLineWidth;
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
ctx.restore();
}
canvas.onObjectMove = function(object) {
var isInVerticalCenter = object.get('left') in canvasWidthCenterMap,
isInHorizontalCenter = object.get('top') in canvasHeightCenterMap;
if (isInVerticalCenter || isInHorizontalCenter) {
canvas.afterRender = function() {
if (isInHorizontalCenter) {
showHorizontalCenterLine();
}
if (isInVerticalCenter) {
showVerticalCenterLine();
}
};
if (isInHorizontalCenter) {
object.set('top', canvasHeightCenter);
}
if (isInVerticalCenter) {
object.set('left', canvasWidthCenter);
}
}
else {
canvas.afterRender = null;
}
};
canvas.onMouseUp = function() {
canvas.afterRender = null;
canvas.renderAll();
};
}

View file

@ -331,4 +331,6 @@
canvas.calcOffset();
}, 100);
initCenteringGuidelines(canvas);
})(this);

View file

@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Canvas demo</title>
<title>Demo of a Fabric.js — HTML5/Javascript canvas library and an SVG parser</title>
<!--[if lt IE 9]>
<script src="../../lib/excanvas.js" type="text/javascript"></script>
@ -19,7 +19,7 @@
<body>
<div id="body-wrapper">
<h2>
Demo of a <a href="http://github.com/kangax/fabric.js">fabric.js</a> — interactive object model on top of <code>canvas</code> element.
Demo of a <a href="http://github.com/kangax/fabric.js">Fabric.js</a> — interactive object model on top of <code>canvas</code> element.
</h2>
<div id="controls">
@ -150,6 +150,7 @@
</ul>
</div>
</div>
<script src="centering_guidelines.js" type="text/javascript"></script>
<script src="demo.js" type="text/javascript"></script>
</body>
</html>