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