@leapfrog/interactive-canvas 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{interactive-canvas.impl.d.ts → abstract-interactive-canvas.d.ts} +340 -305
- package/dist/dimensions/pixel-canvas-dimensions.d.ts +13 -13
- package/dist/dimensions/print-6-col-canvas-dimensions.d.ts +18 -18
- package/dist/dimensions/print-8-col-canvas-dimensions.d.ts +18 -18
- package/dist/font/font-library.d.ts +27 -22
- package/dist/font/font-library.interface.d.ts +24 -20
- package/dist/font/font.interface.d.ts +20 -20
- package/dist/font/unknown-font.d.ts +6 -6
- package/dist/headless-interactive-canvas.d.ts +9 -0
- package/dist/index.d.ts +49 -47
- package/dist/interactive-canvas.d.ts +8 -0
- package/dist/interactive-canvas.es.js +3193 -0
- package/dist/interactive-canvas.interface.d.ts +267 -221
- package/dist/interactive-canvas.js +3222 -34
- package/dist/layout/abstract-layout-manager.d.ts +17 -18
- package/dist/layout/advanced-layout-manager.d.ts +15 -15
- package/dist/layout/function/pin-to-bottom.layout-function.d.ts +4 -4
- package/dist/layout/function/redraw-all.layout-function.d.ts +4 -4
- package/dist/layout/function/reposition-borders.layout-function.d.ts +4 -4
- package/dist/layout/function/reposition-cutoffs.layout-function.d.ts +4 -4
- package/dist/layout/function/resize-canvas.layout-function.d.ts +4 -4
- package/dist/layout/function/stack-objects.layout-function.d.ts +11 -11
- package/dist/layout/function/update-object-dimensions.layout-function.d.ts +4 -4
- package/dist/layout/layout-manager.enum.d.ts +5 -5
- package/dist/layout/layout-manager.interface.d.ts +13 -13
- package/dist/layout/standard-layout-manager.d.ts +35 -36
- package/dist/mutator/mutable-background-color.interface.d.ts +15 -15
- package/dist/mutator/mutable-color.interface.d.ts +6 -6
- package/dist/mutator/mutable-image.interface.d.ts +28 -28
- package/dist/mutator/mutable-position.interface.d.ts +33 -33
- package/dist/mutator/mutable-text-style.interface.d.ts +163 -149
- package/dist/mutator/mutable-text.interface.d.ts +40 -40
- package/dist/object/abstract-canvas-object.d.ts +155 -155
- package/dist/object/canvas-object-data.d.ts +23 -23
- package/dist/object/canvas-object.interface.d.ts +96 -96
- package/dist/object/impl/border.d.ts +59 -60
- package/dist/object/impl/cutoff.d.ts +59 -60
- package/dist/object/impl/horizontal-rule.d.ts +88 -89
- package/dist/object/impl/image.d.ts +81 -82
- package/dist/object/impl/rectangle.d.ts +58 -59
- package/dist/object/impl/text.d.ts +264 -255
- package/dist/object/impl/vertical-rule.d.ts +88 -89
- package/dist/profile/canvas-profile.interface.d.ts +22 -22
- package/dist/profile/default-canvas-profile.d.ts +23 -23
- package/dist/types/canvas-dimension-restrictions.interface.d.ts +14 -14
- package/dist/types/canvas-dimensions.interface.d.ts +21 -21
- package/dist/types/canvas-state.interface.d.ts +11 -11
- package/dist/types/dimension-restrictions.interface.d.ts +6 -6
- package/dist/types/image-type.enum.d.ts +6 -6
- package/dist/types/margin.interface.d.ts +6 -6
- package/dist/types/object-dimensions.interface.d.ts +23 -23
- package/dist/types/object-type.enum.d.ts +10 -10
- package/dist/types/overflow.interface.d.ts +4 -4
- package/dist/types/position.interface.d.ts +6 -6
- package/dist/types/rect.interface.d.ts +6 -6
- package/dist/types/selection-data.interface.d.ts +19 -19
- package/dist/types/text-alignment.interface.d.ts +1 -1
- package/package.json +7 -9
- package/readme.md +11 -0
- package/dist/interactive-canvas.js.map +0 -1
- package/dist/interactive-canvas.nomin.js +0 -57494
|
@@ -1,34 +1,3222 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/(function(){var o="Expected a function",s="__lodash_placeholder__",a=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],c="[object Arguments]",u="[object Array]",h="[object Boolean]",l="[object Date]",f="[object Error]",d="[object Function]",p="[object GeneratorFunction]",g="[object Map]",v="[object Number]",y="[object Object]",m="[object RegExp]",b="[object Set]",_="[object String]",x="[object Symbol]",w="[object WeakMap]",C="[object ArrayBuffer]",S="[object DataView]",T="[object Float32Array]",O="[object Float64Array]",j="[object Int8Array]",P="[object Int16Array]",E="[object Int32Array]",k="[object Uint8Array]",A="[object Uint16Array]",D="[object Uint32Array]",M=/\b__p \+= '';/g,I=/\b(__p \+=) '' \+/g,F=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,L=/[&<>"']/g,B=RegExp(R.source),W=RegExp(L.source),U=/<%-([\s\S]+?)%>/g,Y=/<%([\s\S]+?)%>/g,N=/<%=([\s\S]+?)%>/g,z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,X=/^\w*$/,V=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,H=/[\\^$.*+?()[\]{}|]/g,G=RegExp(H.source),$=/^\s+|\s+$/g,q=/^\s+/,K=/\s+$/,J=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Z=/\{\n\/\* \[wrapped with (.+)\] \*/,Q=/,? & /,tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,et=/\\(\\)?/g,it=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,nt=/\w*$/,rt=/^[-+]0x[0-9a-f]+$/i,ot=/^0b[01]+$/i,st=/^\[object .+?Constructor\]$/,at=/^0o[0-7]+$/i,ct=/^(?:0|[1-9]\d*)$/,ut=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ht=/($^)/,lt=/['\n\r\u2028\u2029\\]/g,ft="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",dt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pt="[\\ud800-\\udfff]",gt="["+dt+"]",vt="["+ft+"]",yt="\\d+",mt="[\\u2700-\\u27bf]",bt="[a-z\\xdf-\\xf6\\xf8-\\xff]",_t="[^\\ud800-\\udfff"+dt+yt+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",xt="\\ud83c[\\udffb-\\udfff]",wt="[^\\ud800-\\udfff]",Ct="(?:\\ud83c[\\udde6-\\uddff]){2}",St="[\\ud800-\\udbff][\\udc00-\\udfff]",Tt="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Ot="(?:"+bt+"|"+_t+")",jt="(?:"+Tt+"|"+_t+")",Pt="(?:"+vt+"|"+xt+")"+"?",Et="[\\ufe0e\\ufe0f]?"+Pt+("(?:\\u200d(?:"+[wt,Ct,St].join("|")+")[\\ufe0e\\ufe0f]?"+Pt+")*"),kt="(?:"+[mt,Ct,St].join("|")+")"+Et,At="(?:"+[wt+vt+"?",vt,Ct,St,pt].join("|")+")",Dt=RegExp("['’]","g"),Mt=RegExp(vt,"g"),It=RegExp(xt+"(?="+xt+")|"+At+Et,"g"),Ft=RegExp([Tt+"?"+bt+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[gt,Tt,"$"].join("|")+")",jt+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[gt,Tt+Ot,"$"].join("|")+")",Tt+"?"+Ot+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Tt+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",yt,kt].join("|"),"g"),Rt=RegExp("[\\u200d\\ud800-\\udfff"+ft+"\\ufe0e\\ufe0f]"),Lt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Bt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Wt=-1,Ut={};Ut[T]=Ut[O]=Ut[j]=Ut[P]=Ut[E]=Ut[k]=Ut["[object Uint8ClampedArray]"]=Ut[A]=Ut[D]=!0,Ut[c]=Ut[u]=Ut[C]=Ut[h]=Ut[S]=Ut[l]=Ut[f]=Ut[d]=Ut[g]=Ut[v]=Ut[y]=Ut[m]=Ut[b]=Ut[_]=Ut[w]=!1;var Yt={};Yt[c]=Yt[u]=Yt[C]=Yt[S]=Yt[h]=Yt[l]=Yt[T]=Yt[O]=Yt[j]=Yt[P]=Yt[E]=Yt[g]=Yt[v]=Yt[y]=Yt[m]=Yt[b]=Yt[_]=Yt[x]=Yt[k]=Yt["[object Uint8ClampedArray]"]=Yt[A]=Yt[D]=!0,Yt[f]=Yt[d]=Yt[w]=!1;var Nt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},zt=parseFloat,Xt=parseInt,Vt="object"==typeof t&&t&&t.Object===Object&&t,Ht="object"==typeof self&&self&&self.Object===Object&&self,Gt=Vt||Ht||Function("return this")(),$t=e&&!e.nodeType&&e,qt=$t&&"object"==typeof n&&n&&!n.nodeType&&n,Kt=qt&&qt.exports===$t,Jt=Kt&&Vt.process,Zt=function(){try{var t=qt&&qt.require&&qt.require("util").types;return t||Jt&&Jt.binding&&Jt.binding("util")}catch(t){}}(),Qt=Zt&&Zt.isArrayBuffer,te=Zt&&Zt.isDate,ee=Zt&&Zt.isMap,ie=Zt&&Zt.isRegExp,ne=Zt&&Zt.isSet,re=Zt&&Zt.isTypedArray;function oe(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function se(t,e,i,n){for(var r=-1,o=null==t?0:t.length;++r<o;){var s=t[r];e(n,s,i(s),t)}return n}function ae(t,e){for(var i=-1,n=null==t?0:t.length;++i<n&&!1!==e(t[i],i,t););return t}function ce(t,e){for(var i=null==t?0:t.length;i--&&!1!==e(t[i],i,t););return t}function ue(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(!e(t[i],i,t))return!1;return!0}function he(t,e){for(var i=-1,n=null==t?0:t.length,r=0,o=[];++i<n;){var s=t[i];e(s,i,t)&&(o[r++]=s)}return o}function le(t,e){return!!(null==t?0:t.length)&&xe(t,e,0)>-1}function fe(t,e,i){for(var n=-1,r=null==t?0:t.length;++n<r;)if(i(e,t[n]))return!0;return!1}function de(t,e){for(var i=-1,n=null==t?0:t.length,r=Array(n);++i<n;)r[i]=e(t[i],i,t);return r}function pe(t,e){for(var i=-1,n=e.length,r=t.length;++i<n;)t[r+i]=e[i];return t}function ge(t,e,i,n){var r=-1,o=null==t?0:t.length;for(n&&o&&(i=t[++r]);++r<o;)i=e(i,t[r],r,t);return i}function ve(t,e,i,n){var r=null==t?0:t.length;for(n&&r&&(i=t[--r]);r--;)i=e(i,t[r],r,t);return i}function ye(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}var me=Te("length");function be(t,e,i){var n;return i(t,(function(t,i,r){if(e(t,i,r))return n=i,!1})),n}function _e(t,e,i,n){for(var r=t.length,o=i+(n?1:-1);n?o--:++o<r;)if(e(t[o],o,t))return o;return-1}function xe(t,e,i){return e==e?function(t,e,i){var n=i-1,r=t.length;for(;++n<r;)if(t[n]===e)return n;return-1}(t,e,i):_e(t,Ce,i)}function we(t,e,i,n){for(var r=i-1,o=t.length;++r<o;)if(n(t[r],e))return r;return-1}function Ce(t){return t!=t}function Se(t,e){var i=null==t?0:t.length;return i?Pe(t,e)/i:NaN}function Te(t){return function(e){return null==e?void 0:e[t]}}function Oe(t){return function(e){return null==t?void 0:t[e]}}function je(t,e,i,n,r){return r(t,(function(t,r,o){i=n?(n=!1,t):e(i,t,r,o)})),i}function Pe(t,e){for(var i,n=-1,r=t.length;++n<r;){var o=e(t[n]);void 0!==o&&(i=void 0===i?o:i+o)}return i}function Ee(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}function ke(t){return function(e){return t(e)}}function Ae(t,e){return de(e,(function(e){return t[e]}))}function De(t,e){return t.has(e)}function Me(t,e){for(var i=-1,n=t.length;++i<n&&xe(e,t[i],0)>-1;);return i}function Ie(t,e){for(var i=t.length;i--&&xe(e,t[i],0)>-1;);return i}function Fe(t,e){for(var i=t.length,n=0;i--;)t[i]===e&&++n;return n}var Re=Oe({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Le=Oe({"&":"&","<":"<",">":">",'"':""","'":"'"});function Be(t){return"\\"+Nt[t]}function We(t){return Rt.test(t)}function Ue(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i}function Ye(t,e){return function(i){return t(e(i))}}function Ne(t,e){for(var i=-1,n=t.length,r=0,o=[];++i<n;){var a=t[i];a!==e&&a!==s||(t[i]=s,o[r++]=i)}return o}function ze(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i}function Xe(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=[t,t]})),i}function Ve(t){return We(t)?function(t){var e=It.lastIndex=0;for(;It.test(t);)++e;return e}(t):me(t)}function He(t){return We(t)?function(t){return t.match(It)||[]}(t):function(t){return t.split("")}(t)}var Ge=Oe({"&":"&","<":"<",">":">",""":'"',"'":"'"});var $e=function t(e){var i,n=(e=null==e?Gt:$e.defaults(Gt.Object(),e,$e.pick(Gt,Bt))).Array,r=e.Date,ft=e.Error,dt=e.Function,pt=e.Math,gt=e.Object,vt=e.RegExp,yt=e.String,mt=e.TypeError,bt=n.prototype,_t=dt.prototype,xt=gt.prototype,wt=e["__core-js_shared__"],Ct=_t.toString,St=xt.hasOwnProperty,Tt=0,Ot=(i=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||""))?"Symbol(src)_1."+i:"",jt=xt.toString,Pt=Ct.call(gt),Et=Gt._,kt=vt("^"+Ct.call(St).replace(H,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),At=Kt?e.Buffer:void 0,It=e.Symbol,Rt=e.Uint8Array,Nt=At?At.allocUnsafe:void 0,Vt=Ye(gt.getPrototypeOf,gt),Ht=gt.create,$t=xt.propertyIsEnumerable,qt=bt.splice,Jt=It?It.isConcatSpreadable:void 0,Zt=It?It.iterator:void 0,me=It?It.toStringTag:void 0,Oe=function(){try{var t=Qr(gt,"defineProperty");return t({},"",{}),t}catch(t){}}(),qe=e.clearTimeout!==Gt.clearTimeout&&e.clearTimeout,Ke=r&&r.now!==Gt.Date.now&&r.now,Je=e.setTimeout!==Gt.setTimeout&&e.setTimeout,Ze=pt.ceil,Qe=pt.floor,ti=gt.getOwnPropertySymbols,ei=At?At.isBuffer:void 0,ii=e.isFinite,ni=bt.join,ri=Ye(gt.keys,gt),oi=pt.max,si=pt.min,ai=r.now,ci=e.parseInt,ui=pt.random,hi=bt.reverse,li=Qr(e,"DataView"),fi=Qr(e,"Map"),di=Qr(e,"Promise"),pi=Qr(e,"Set"),gi=Qr(e,"WeakMap"),vi=Qr(gt,"create"),yi=gi&&new gi,mi={},bi=jo(li),_i=jo(fi),xi=jo(di),wi=jo(pi),Ci=jo(gi),Si=It?It.prototype:void 0,Ti=Si?Si.valueOf:void 0,Oi=Si?Si.toString:void 0;function ji(t){if(Xs(t)&&!Ms(t)&&!(t instanceof Ai)){if(t instanceof ki)return t;if(St.call(t,"__wrapped__"))return Po(t)}return new ki(t)}var Pi=function(){function t(){}return function(e){if(!zs(e))return{};if(Ht)return Ht(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function Ei(){}function ki(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}function Ai(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Di(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Mi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Ii(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Fi(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Ii;++e<i;)this.add(t[e])}function Ri(t){var e=this.__data__=new Mi(t);this.size=e.size}function Li(t,e){var i=Ms(t),n=!i&&Ds(t),r=!i&&!n&&Ls(t),o=!i&&!n&&!r&&Zs(t),s=i||n||r||o,a=s?Ee(t.length,yt):[],c=a.length;for(var u in t)!e&&!St.call(t,u)||s&&("length"==u||r&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||so(u,c))||a.push(u);return a}function Bi(t){var e=t.length;return e?t[Rn(0,e-1)]:void 0}function Wi(t,e){return So(yr(t),$i(e,0,t.length))}function Ui(t){return So(yr(t))}function Yi(t,e,i){(void 0!==i&&!Es(t[e],i)||void 0===i&&!(e in t))&&Hi(t,e,i)}function Ni(t,e,i){var n=t[e];St.call(t,e)&&Es(n,i)&&(void 0!==i||e in t)||Hi(t,e,i)}function zi(t,e){for(var i=t.length;i--;)if(Es(t[i][0],e))return i;return-1}function Xi(t,e,i,n){return Qi(t,(function(t,r,o){e(n,t,i(t),o)})),n}function Vi(t,e){return t&&mr(e,_a(e),t)}function Hi(t,e,i){"__proto__"==e&&Oe?Oe(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function Gi(t,e){for(var i=-1,r=e.length,o=n(r),s=null==t;++i<r;)o[i]=s?void 0:ga(t,e[i]);return o}function $i(t,e,i){return t==t&&(void 0!==i&&(t=t<=i?t:i),void 0!==e&&(t=t>=e?t:e)),t}function qi(t,e,i,n,r,o){var s,a=1&e,u=2&e,f=4&e;if(i&&(s=r?i(t,n,r,o):i(t)),void 0!==s)return s;if(!zs(t))return t;var w=Ms(t);if(w){if(s=function(t){var e=t.length,i=new t.constructor(e);e&&"string"==typeof t[0]&&St.call(t,"index")&&(i.index=t.index,i.input=t.input);return i}(t),!a)return yr(t,s)}else{var M=io(t),I=M==d||M==p;if(Ls(t))return lr(t,a);if(M==y||M==c||I&&!r){if(s=u||I?{}:ro(t),!a)return u?function(t,e){return mr(t,eo(t),e)}(t,function(t,e){return t&&mr(e,xa(e),t)}(s,t)):function(t,e){return mr(t,to(t),e)}(t,Vi(s,t))}else{if(!Yt[M])return r?t:{};s=function(t,e,i){var n=t.constructor;switch(e){case C:return fr(t);case h:case l:return new n(+t);case S:return function(t,e){var i=e?fr(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case T:case O:case j:case P:case E:case k:case"[object Uint8ClampedArray]":case A:case D:return dr(t,i);case g:return new n;case v:case _:return new n(t);case m:return function(t){var e=new t.constructor(t.source,nt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case b:return new n;case x:return r=t,Ti?gt(Ti.call(r)):{}}var r}(t,M,a)}}o||(o=new Ri);var F=o.get(t);if(F)return F;o.set(t,s),qs(t)?t.forEach((function(n){s.add(qi(n,e,i,n,t,o))})):Vs(t)&&t.forEach((function(n,r){s.set(r,qi(n,e,i,r,t,o))}));var R=w?void 0:(f?u?Hr:Vr:u?xa:_a)(t);return ae(R||t,(function(n,r){R&&(n=t[r=n]),Ni(s,r,qi(n,e,i,r,t,o))})),s}function Ki(t,e,i){var n=i.length;if(null==t)return!n;for(t=gt(t);n--;){var r=i[n],o=e[r],s=t[r];if(void 0===s&&!(r in t)||!o(s))return!1}return!0}function Ji(t,e,i){if("function"!=typeof t)throw new mt(o);return _o((function(){t.apply(void 0,i)}),e)}function Zi(t,e,i,n){var r=-1,o=le,s=!0,a=t.length,c=[],u=e.length;if(!a)return c;i&&(e=de(e,ke(i))),n?(o=fe,s=!1):e.length>=200&&(o=De,s=!1,e=new Fi(e));t:for(;++r<a;){var h=t[r],l=null==i?h:i(h);if(h=n||0!==h?h:0,s&&l==l){for(var f=u;f--;)if(e[f]===l)continue t;c.push(h)}else o(e,l,n)||c.push(h)}return c}ji.templateSettings={escape:U,evaluate:Y,interpolate:N,variable:"",imports:{_:ji}},ji.prototype=Ei.prototype,ji.prototype.constructor=ji,ki.prototype=Pi(Ei.prototype),ki.prototype.constructor=ki,Ai.prototype=Pi(Ei.prototype),Ai.prototype.constructor=Ai,Di.prototype.clear=function(){this.__data__=vi?vi(null):{},this.size=0},Di.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Di.prototype.get=function(t){var e=this.__data__;if(vi){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return St.call(e,t)?e[t]:void 0},Di.prototype.has=function(t){var e=this.__data__;return vi?void 0!==e[t]:St.call(e,t)},Di.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=vi&&void 0===e?"__lodash_hash_undefined__":e,this},Mi.prototype.clear=function(){this.__data__=[],this.size=0},Mi.prototype.delete=function(t){var e=this.__data__,i=zi(e,t);return!(i<0)&&(i==e.length-1?e.pop():qt.call(e,i,1),--this.size,!0)},Mi.prototype.get=function(t){var e=this.__data__,i=zi(e,t);return i<0?void 0:e[i][1]},Mi.prototype.has=function(t){return zi(this.__data__,t)>-1},Mi.prototype.set=function(t,e){var i=this.__data__,n=zi(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Ii.prototype.clear=function(){this.size=0,this.__data__={hash:new Di,map:new(fi||Mi),string:new Di}},Ii.prototype.delete=function(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e},Ii.prototype.get=function(t){return Jr(this,t).get(t)},Ii.prototype.has=function(t){return Jr(this,t).has(t)},Ii.prototype.set=function(t,e){var i=Jr(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this},Fi.prototype.add=Fi.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Fi.prototype.has=function(t){return this.__data__.has(t)},Ri.prototype.clear=function(){this.__data__=new Mi,this.size=0},Ri.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Ri.prototype.get=function(t){return this.__data__.get(t)},Ri.prototype.has=function(t){return this.__data__.has(t)},Ri.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Mi){var n=i.__data__;if(!fi||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ii(n)}return i.set(t,e),this.size=i.size,this};var Qi=xr(cn),tn=xr(un,!0);function en(t,e){var i=!0;return Qi(t,(function(t,n,r){return i=!!e(t,n,r)})),i}function nn(t,e,i){for(var n=-1,r=t.length;++n<r;){var o=t[n],s=e(o);if(null!=s&&(void 0===a?s==s&&!Js(s):i(s,a)))var a=s,c=o}return c}function rn(t,e){var i=[];return Qi(t,(function(t,n,r){e(t,n,r)&&i.push(t)})),i}function on(t,e,i,n,r){var o=-1,s=t.length;for(i||(i=oo),r||(r=[]);++o<s;){var a=t[o];e>0&&i(a)?e>1?on(a,e-1,i,n,r):pe(r,a):n||(r[r.length]=a)}return r}var sn=wr(),an=wr(!0);function cn(t,e){return t&&sn(t,e,_a)}function un(t,e){return t&&an(t,e,_a)}function hn(t,e){return he(e,(function(e){return Us(t[e])}))}function ln(t,e){for(var i=0,n=(e=ar(e,t)).length;null!=t&&i<n;)t=t[Oo(e[i++])];return i&&i==n?t:void 0}function fn(t,e,i){var n=e(t);return Ms(t)?n:pe(n,i(t))}function dn(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":me&&me in gt(t)?function(t){var e=St.call(t,me),i=t[me];try{t[me]=void 0;var n=!0}catch(t){}var r=jt.call(t);n&&(e?t[me]=i:delete t[me]);return r}(t):function(t){return jt.call(t)}(t)}function pn(t,e){return t>e}function gn(t,e){return null!=t&&St.call(t,e)}function vn(t,e){return null!=t&&e in gt(t)}function yn(t,e,i){for(var r=i?fe:le,o=t[0].length,s=t.length,a=s,c=n(s),u=1/0,h=[];a--;){var l=t[a];a&&e&&(l=de(l,ke(e))),u=si(l.length,u),c[a]=!i&&(e||o>=120&&l.length>=120)?new Fi(a&&l):void 0}l=t[0];var f=-1,d=c[0];t:for(;++f<o&&h.length<u;){var p=l[f],g=e?e(p):p;if(p=i||0!==p?p:0,!(d?De(d,g):r(h,g,i))){for(a=s;--a;){var v=c[a];if(!(v?De(v,g):r(t[a],g,i)))continue t}d&&d.push(g),h.push(p)}}return h}function mn(t,e,i){var n=null==(t=vo(t,e=ar(e,t)))?t:t[Oo(Wo(e))];return null==n?void 0:oe(n,t,i)}function bn(t){return Xs(t)&&dn(t)==c}function _n(t,e,i,n,r){return t===e||(null==t||null==e||!Xs(t)&&!Xs(e)?t!=t&&e!=e:function(t,e,i,n,r,o){var s=Ms(t),a=Ms(e),d=s?u:io(t),p=a?u:io(e),w=(d=d==c?y:d)==y,T=(p=p==c?y:p)==y,O=d==p;if(O&&Ls(t)){if(!Ls(e))return!1;s=!0,w=!1}if(O&&!w)return o||(o=new Ri),s||Zs(t)?zr(t,e,i,n,r,o):function(t,e,i,n,r,o,s){switch(i){case S:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case C:return!(t.byteLength!=e.byteLength||!o(new Rt(t),new Rt(e)));case h:case l:case v:return Es(+t,+e);case f:return t.name==e.name&&t.message==e.message;case m:case _:return t==e+"";case g:var a=Ue;case b:var c=1&n;if(a||(a=ze),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var d=zr(a(t),a(e),n,r,o,s);return s.delete(t),d;case x:if(Ti)return Ti.call(t)==Ti.call(e)}return!1}(t,e,d,i,n,r,o);if(!(1&i)){var j=w&&St.call(t,"__wrapped__"),P=T&&St.call(e,"__wrapped__");if(j||P){var E=j?t.value():t,k=P?e.value():e;return o||(o=new Ri),r(E,k,i,n,o)}}if(!O)return!1;return o||(o=new Ri),function(t,e,i,n,r,o){var s=1&i,a=Vr(t),c=a.length,u=Vr(e).length;if(c!=u&&!s)return!1;var h=c;for(;h--;){var l=a[h];if(!(s?l in e:St.call(e,l)))return!1}var f=o.get(t);if(f&&o.get(e))return f==e;var d=!0;o.set(t,e),o.set(e,t);var p=s;for(;++h<c;){l=a[h];var g=t[l],v=e[l];if(n)var y=s?n(v,g,l,e,t,o):n(g,v,l,t,e,o);if(!(void 0===y?g===v||r(g,v,i,n,o):y)){d=!1;break}p||(p="constructor"==l)}if(d&&!p){var m=t.constructor,b=e.constructor;m==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof m&&m instanceof m&&"function"==typeof b&&b instanceof b||(d=!1)}return o.delete(t),o.delete(e),d}(t,e,i,n,r,o)}(t,e,i,n,_n,r))}function xn(t,e,i,n){var r=i.length,o=r,s=!n;if(null==t)return!o;for(t=gt(t);r--;){var a=i[r];if(s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++r<o;){var c=(a=i[r])[0],u=t[c],h=a[1];if(s&&a[2]){if(void 0===u&&!(c in t))return!1}else{var l=new Ri;if(n)var f=n(u,h,c,t,e,l);if(!(void 0===f?_n(h,u,3,n,l):f))return!1}}return!0}function wn(t){return!(!zs(t)||(e=t,Ot&&Ot in e))&&(Us(t)?kt:st).test(jo(t));var e}function Cn(t){return"function"==typeof t?t:null==t?Ha:"object"==typeof t?Ms(t)?En(t[0],t[1]):Pn(t):ec(t)}function Sn(t){if(!lo(t))return ri(t);var e=[];for(var i in gt(t))St.call(t,i)&&"constructor"!=i&&e.push(i);return e}function Tn(t){if(!zs(t))return function(t){var e=[];if(null!=t)for(var i in gt(t))e.push(i);return e}(t);var e=lo(t),i=[];for(var n in t)("constructor"!=n||!e&&St.call(t,n))&&i.push(n);return i}function On(t,e){return t<e}function jn(t,e){var i=-1,r=Fs(t)?n(t.length):[];return Qi(t,(function(t,n,o){r[++i]=e(t,n,o)})),r}function Pn(t){var e=Zr(t);return 1==e.length&&e[0][2]?po(e[0][0],e[0][1]):function(i){return i===t||xn(i,t,e)}}function En(t,e){return co(t)&&fo(e)?po(Oo(t),e):function(i){var n=ga(i,t);return void 0===n&&n===e?va(i,t):_n(e,n,3)}}function kn(t,e,i,n,r){t!==e&&sn(e,(function(o,s){if(r||(r=new Ri),zs(o))!function(t,e,i,n,r,o,s){var a=mo(t,i),c=mo(e,i),u=s.get(c);if(u)return void Yi(t,i,u);var h=o?o(a,c,i+"",t,e,s):void 0,l=void 0===h;if(l){var f=Ms(c),d=!f&&Ls(c),p=!f&&!d&&Zs(c);h=c,f||d||p?Ms(a)?h=a:Rs(a)?h=yr(a):d?(l=!1,h=lr(c,!0)):p?(l=!1,h=dr(c,!0)):h=[]:Gs(c)||Ds(c)?(h=a,Ds(a)?h=sa(a):zs(a)&&!Us(a)||(h=ro(c))):l=!1}l&&(s.set(c,h),r(h,c,n,o,s),s.delete(c));Yi(t,i,h)}(t,e,s,i,kn,n,r);else{var a=n?n(mo(t,s),o,s+"",t,e,r):void 0;void 0===a&&(a=o),Yi(t,s,a)}}),xa)}function An(t,e){var i=t.length;if(i)return so(e+=e<0?i:0,i)?t[e]:void 0}function Dn(t,e,i){var n=-1;return e=de(e.length?e:[Ha],ke(Kr())),function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t}(jn(t,(function(t,i,r){return{criteria:de(e,(function(e){return e(t)})),index:++n,value:t}})),(function(t,e){return function(t,e,i){var n=-1,r=t.criteria,o=e.criteria,s=r.length,a=i.length;for(;++n<s;){var c=pr(r[n],o[n]);if(c){if(n>=a)return c;var u=i[n];return c*("desc"==u?-1:1)}}return t.index-e.index}(t,e,i)}))}function Mn(t,e,i){for(var n=-1,r=e.length,o={};++n<r;){var s=e[n],a=ln(t,s);i(a,s)&&Yn(o,ar(s,t),a)}return o}function In(t,e,i,n){var r=n?we:xe,o=-1,s=e.length,a=t;for(t===e&&(e=yr(e)),i&&(a=de(t,ke(i)));++o<s;)for(var c=0,u=e[o],h=i?i(u):u;(c=r(a,h,c,n))>-1;)a!==t&&qt.call(a,c,1),qt.call(t,c,1);return t}function Fn(t,e){for(var i=t?e.length:0,n=i-1;i--;){var r=e[i];if(i==n||r!==o){var o=r;so(r)?qt.call(t,r,1):Qn(t,r)}}return t}function Rn(t,e){return t+Qe(ui()*(e-t+1))}function Ln(t,e){var i="";if(!t||e<1||e>9007199254740991)return i;do{e%2&&(i+=t),(e=Qe(e/2))&&(t+=t)}while(e);return i}function Bn(t,e){return xo(go(t,e,Ha),t+"")}function Wn(t){return Bi(Ea(t))}function Un(t,e){var i=Ea(t);return So(i,$i(e,0,i.length))}function Yn(t,e,i,n){if(!zs(t))return t;for(var r=-1,o=(e=ar(e,t)).length,s=o-1,a=t;null!=a&&++r<o;){var c=Oo(e[r]),u=i;if(r!=s){var h=a[c];void 0===(u=n?n(h,c,a):void 0)&&(u=zs(h)?h:so(e[r+1])?[]:{})}Ni(a,c,u),a=a[c]}return t}var Nn=yi?function(t,e){return yi.set(t,e),t}:Ha,zn=Oe?function(t,e){return Oe(t,"toString",{configurable:!0,enumerable:!1,value:za(e),writable:!0})}:Ha;function Xn(t){return So(Ea(t))}function Vn(t,e,i){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(i=i>o?o:i)<0&&(i+=o),o=e>i?0:i-e>>>0,e>>>=0;for(var s=n(o);++r<o;)s[r]=t[r+e];return s}function Hn(t,e){var i;return Qi(t,(function(t,n,r){return!(i=e(t,n,r))})),!!i}function Gn(t,e,i){var n=0,r=null==t?n:t.length;if("number"==typeof e&&e==e&&r<=2147483647){for(;n<r;){var o=n+r>>>1,s=t[o];null!==s&&!Js(s)&&(i?s<=e:s<e)?n=o+1:r=o}return r}return $n(t,e,Ha,i)}function $n(t,e,i,n){e=i(e);for(var r=0,o=null==t?0:t.length,s=e!=e,a=null===e,c=Js(e),u=void 0===e;r<o;){var h=Qe((r+o)/2),l=i(t[h]),f=void 0!==l,d=null===l,p=l==l,g=Js(l);if(s)var v=n||p;else v=u?p&&(n||f):a?p&&f&&(n||!d):c?p&&f&&!d&&(n||!g):!d&&!g&&(n?l<=e:l<e);v?r=h+1:o=h}return si(o,4294967294)}function qn(t,e){for(var i=-1,n=t.length,r=0,o=[];++i<n;){var s=t[i],a=e?e(s):s;if(!i||!Es(a,c)){var c=a;o[r++]=0===s?0:s}}return o}function Kn(t){return"number"==typeof t?t:Js(t)?NaN:+t}function Jn(t){if("string"==typeof t)return t;if(Ms(t))return de(t,Jn)+"";if(Js(t))return Oi?Oi.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Zn(t,e,i){var n=-1,r=le,o=t.length,s=!0,a=[],c=a;if(i)s=!1,r=fe;else if(o>=200){var u=e?null:Lr(t);if(u)return ze(u);s=!1,r=De,c=new Fi}else c=e?[]:a;t:for(;++n<o;){var h=t[n],l=e?e(h):h;if(h=i||0!==h?h:0,s&&l==l){for(var f=c.length;f--;)if(c[f]===l)continue t;e&&c.push(l),a.push(h)}else r(c,l,i)||(c!==a&&c.push(l),a.push(h))}return a}function Qn(t,e){return null==(t=vo(t,e=ar(e,t)))||delete t[Oo(Wo(e))]}function tr(t,e,i,n){return Yn(t,e,i(ln(t,e)),n)}function er(t,e,i,n){for(var r=t.length,o=n?r:-1;(n?o--:++o<r)&&e(t[o],o,t););return i?Vn(t,n?0:o,n?o+1:r):Vn(t,n?o+1:0,n?r:o)}function ir(t,e){var i=t;return i instanceof Ai&&(i=i.value()),ge(e,(function(t,e){return e.func.apply(e.thisArg,pe([t],e.args))}),i)}function nr(t,e,i){var r=t.length;if(r<2)return r?Zn(t[0]):[];for(var o=-1,s=n(r);++o<r;)for(var a=t[o],c=-1;++c<r;)c!=o&&(s[o]=Zi(s[o]||a,t[c],e,i));return Zn(on(s,1),e,i)}function rr(t,e,i){for(var n=-1,r=t.length,o=e.length,s={};++n<r;){var a=n<o?e[n]:void 0;i(s,t[n],a)}return s}function or(t){return Rs(t)?t:[]}function sr(t){return"function"==typeof t?t:Ha}function ar(t,e){return Ms(t)?t:co(t,e)?[t]:To(aa(t))}var cr=Bn;function ur(t,e,i){var n=t.length;return i=void 0===i?n:i,!e&&i>=n?t:Vn(t,e,i)}var hr=qe||function(t){return Gt.clearTimeout(t)};function lr(t,e){if(e)return t.slice();var i=t.length,n=Nt?Nt(i):new t.constructor(i);return t.copy(n),n}function fr(t){var e=new t.constructor(t.byteLength);return new Rt(e).set(new Rt(t)),e}function dr(t,e){var i=e?fr(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function pr(t,e){if(t!==e){var i=void 0!==t,n=null===t,r=t==t,o=Js(t),s=void 0!==e,a=null===e,c=e==e,u=Js(e);if(!a&&!u&&!o&&t>e||o&&s&&c&&!a&&!u||n&&s&&c||!i&&c||!r)return 1;if(!n&&!o&&!u&&t<e||u&&i&&r&&!n&&!o||a&&i&&r||!s&&r||!c)return-1}return 0}function gr(t,e,i,r){for(var o=-1,s=t.length,a=i.length,c=-1,u=e.length,h=oi(s-a,0),l=n(u+h),f=!r;++c<u;)l[c]=e[c];for(;++o<a;)(f||o<s)&&(l[i[o]]=t[o]);for(;h--;)l[c++]=t[o++];return l}function vr(t,e,i,r){for(var o=-1,s=t.length,a=-1,c=i.length,u=-1,h=e.length,l=oi(s-c,0),f=n(l+h),d=!r;++o<l;)f[o]=t[o];for(var p=o;++u<h;)f[p+u]=e[u];for(;++a<c;)(d||o<s)&&(f[p+i[a]]=t[o++]);return f}function yr(t,e){var i=-1,r=t.length;for(e||(e=n(r));++i<r;)e[i]=t[i];return e}function mr(t,e,i,n){var r=!i;i||(i={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=n?n(i[a],t[a],a,i,t):void 0;void 0===c&&(c=t[a]),r?Hi(i,a,c):Ni(i,a,c)}return i}function br(t,e){return function(i,n){var r=Ms(i)?se:Xi,o=e?e():{};return r(i,t,Kr(n,2),o)}}function _r(t){return Bn((function(e,i){var n=-1,r=i.length,o=r>1?i[r-1]:void 0,s=r>2?i[2]:void 0;for(o=t.length>3&&"function"==typeof o?(r--,o):void 0,s&&ao(i[0],i[1],s)&&(o=r<3?void 0:o,r=1),e=gt(e);++n<r;){var a=i[n];a&&t(e,a,n,o)}return e}))}function xr(t,e){return function(i,n){if(null==i)return i;if(!Fs(i))return t(i,n);for(var r=i.length,o=e?r:-1,s=gt(i);(e?o--:++o<r)&&!1!==n(s[o],o,s););return i}}function wr(t){return function(e,i,n){for(var r=-1,o=gt(e),s=n(e),a=s.length;a--;){var c=s[t?a:++r];if(!1===i(o[c],c,o))break}return e}}function Cr(t){return function(e){var i=We(e=aa(e))?He(e):void 0,n=i?i[0]:e.charAt(0),r=i?ur(i,1).join(""):e.slice(1);return n[t]()+r}}function Sr(t){return function(e){return ge(Ua(Da(e).replace(Dt,"")),t,"")}}function Tr(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var i=Pi(t.prototype),n=t.apply(i,e);return zs(n)?n:i}}function Or(t){return function(e,i,n){var r=gt(e);if(!Fs(e)){var o=Kr(i,3);e=_a(e),i=function(t){return o(r[t],t,r)}}var s=t(e,i,n);return s>-1?r[o?e[s]:s]:void 0}}function jr(t){return Xr((function(e){var i=e.length,n=i,r=ki.prototype.thru;for(t&&e.reverse();n--;){var s=e[n];if("function"!=typeof s)throw new mt(o);if(r&&!a&&"wrapper"==$r(s))var a=new ki([],!0)}for(n=a?n:i;++n<i;){var c=$r(s=e[n]),u="wrapper"==c?Gr(s):void 0;a=u&&uo(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?a[$r(u[0])].apply(a,u[3]):1==s.length&&uo(s)?a[c]():a.thru(s)}return function(){var t=arguments,n=t[0];if(a&&1==t.length&&Ms(n))return a.plant(n).value();for(var r=0,o=i?e[r].apply(this,t):n;++r<i;)o=e[r].call(this,o);return o}}))}function Pr(t,e,i,r,o,s,a,c,u,h){var l=128&e,f=1&e,d=2&e,p=24&e,g=512&e,v=d?void 0:Tr(t);return function y(){for(var m=arguments.length,b=n(m),_=m;_--;)b[_]=arguments[_];if(p)var x=qr(y),w=Fe(b,x);if(r&&(b=gr(b,r,o,p)),s&&(b=vr(b,s,a,p)),m-=w,p&&m<h){var C=Ne(b,x);return Fr(t,e,Pr,y.placeholder,i,b,C,c,u,h-m)}var S=f?i:this,T=d?S[t]:t;return m=b.length,c?b=yo(b,c):g&&m>1&&b.reverse(),l&&u<m&&(b.length=u),this&&this!==Gt&&this instanceof y&&(T=v||Tr(T)),T.apply(S,b)}}function Er(t,e){return function(i,n){return function(t,e,i,n){return cn(t,(function(t,r,o){e(n,i(t),r,o)})),n}(i,t,e(n),{})}}function kr(t,e){return function(i,n){var r;if(void 0===i&&void 0===n)return e;if(void 0!==i&&(r=i),void 0!==n){if(void 0===r)return n;"string"==typeof i||"string"==typeof n?(i=Jn(i),n=Jn(n)):(i=Kn(i),n=Kn(n)),r=t(i,n)}return r}}function Ar(t){return Xr((function(e){return e=de(e,ke(Kr())),Bn((function(i){var n=this;return t(e,(function(t){return oe(t,n,i)}))}))}))}function Dr(t,e){var i=(e=void 0===e?" ":Jn(e)).length;if(i<2)return i?Ln(e,t):e;var n=Ln(e,Ze(t/Ve(e)));return We(e)?ur(He(n),0,t).join(""):n.slice(0,t)}function Mr(t){return function(e,i,r){return r&&"number"!=typeof r&&ao(e,i,r)&&(i=r=void 0),e=ia(e),void 0===i?(i=e,e=0):i=ia(i),function(t,e,i,r){for(var o=-1,s=oi(Ze((e-t)/(i||1)),0),a=n(s);s--;)a[r?s:++o]=t,t+=i;return a}(e,i,r=void 0===r?e<i?1:-1:ia(r),t)}}function Ir(t){return function(e,i){return"string"==typeof e&&"string"==typeof i||(e=oa(e),i=oa(i)),t(e,i)}}function Fr(t,e,i,n,r,o,s,a,c,u){var h=8&e;e|=h?32:64,4&(e&=~(h?64:32))||(e&=-4);var l=[t,e,r,h?o:void 0,h?s:void 0,h?void 0:o,h?void 0:s,a,c,u],f=i.apply(void 0,l);return uo(t)&&bo(f,l),f.placeholder=n,wo(f,t,e)}function Rr(t){var e=pt[t];return function(t,i){if(t=oa(t),(i=null==i?0:si(na(i),292))&&ii(t)){var n=(aa(t)+"e").split("e");return+((n=(aa(e(n[0]+"e"+(+n[1]+i)))+"e").split("e"))[0]+"e"+(+n[1]-i))}return e(t)}}var Lr=pi&&1/ze(new pi([,-0]))[1]==1/0?function(t){return new pi(t)}:Ja;function Br(t){return function(e){var i=io(e);return i==g?Ue(e):i==b?Xe(e):function(t,e){return de(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Wr(t,e,i,r,a,c,u,h){var l=2&e;if(!l&&"function"!=typeof t)throw new mt(o);var f=r?r.length:0;if(f||(e&=-97,r=a=void 0),u=void 0===u?u:oi(na(u),0),h=void 0===h?h:na(h),f-=a?a.length:0,64&e){var d=r,p=a;r=a=void 0}var g=l?void 0:Gr(t),v=[t,e,i,r,a,d,p,c,u,h];if(g&&function(t,e){var i=t[1],n=e[1],r=i|n,o=r<131,a=128==n&&8==i||128==n&&256==i&&t[7].length<=e[8]||384==n&&e[7].length<=e[8]&&8==i;if(!o&&!a)return t;1&n&&(t[2]=e[2],r|=1&i?0:4);var c=e[3];if(c){var u=t[3];t[3]=u?gr(u,c,e[4]):c,t[4]=u?Ne(t[3],s):e[4]}(c=e[5])&&(u=t[5],t[5]=u?vr(u,c,e[6]):c,t[6]=u?Ne(t[5],s):e[6]);(c=e[7])&&(t[7]=c);128&n&&(t[8]=null==t[8]?e[8]:si(t[8],e[8]));null==t[9]&&(t[9]=e[9]);t[0]=e[0],t[1]=r}(v,g),t=v[0],e=v[1],i=v[2],r=v[3],a=v[4],!(h=v[9]=void 0===v[9]?l?0:t.length:oi(v[9]-f,0))&&24&e&&(e&=-25),e&&1!=e)y=8==e||16==e?function(t,e,i){var r=Tr(t);return function o(){for(var s=arguments.length,a=n(s),c=s,u=qr(o);c--;)a[c]=arguments[c];var h=s<3&&a[0]!==u&&a[s-1]!==u?[]:Ne(a,u);if((s-=h.length)<i)return Fr(t,e,Pr,o.placeholder,void 0,a,h,void 0,void 0,i-s);var l=this&&this!==Gt&&this instanceof o?r:t;return oe(l,this,a)}}(t,e,h):32!=e&&33!=e||a.length?Pr.apply(void 0,v):function(t,e,i,r){var o=1&e,s=Tr(t);return function e(){for(var a=-1,c=arguments.length,u=-1,h=r.length,l=n(h+c),f=this&&this!==Gt&&this instanceof e?s:t;++u<h;)l[u]=r[u];for(;c--;)l[u++]=arguments[++a];return oe(f,o?i:this,l)}}(t,e,i,r);else var y=function(t,e,i){var n=1&e,r=Tr(t);return function e(){var o=this&&this!==Gt&&this instanceof e?r:t;return o.apply(n?i:this,arguments)}}(t,e,i);return wo((g?Nn:bo)(y,v),t,e)}function Ur(t,e,i,n){return void 0===t||Es(t,xt[i])&&!St.call(n,i)?e:t}function Yr(t,e,i,n,r,o){return zs(t)&&zs(e)&&(o.set(e,t),kn(t,e,void 0,Yr,o),o.delete(e)),t}function Nr(t){return Gs(t)?void 0:t}function zr(t,e,i,n,r,o){var s=1&i,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t);if(u&&o.get(e))return u==e;var h=-1,l=!0,f=2&i?new Fi:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var d=t[h],p=e[h];if(n)var g=s?n(p,d,h,e,t,o):n(d,p,h,t,e,o);if(void 0!==g){if(g)continue;l=!1;break}if(f){if(!ye(e,(function(t,e){if(!De(f,e)&&(d===t||r(d,t,i,n,o)))return f.push(e)}))){l=!1;break}}else if(d!==p&&!r(d,p,i,n,o)){l=!1;break}}return o.delete(t),o.delete(e),l}function Xr(t){return xo(go(t,void 0,Io),t+"")}function Vr(t){return fn(t,_a,to)}function Hr(t){return fn(t,xa,eo)}var Gr=yi?function(t){return yi.get(t)}:Ja;function $r(t){for(var e=t.name+"",i=mi[e],n=St.call(mi,e)?i.length:0;n--;){var r=i[n],o=r.func;if(null==o||o==t)return r.name}return e}function qr(t){return(St.call(ji,"placeholder")?ji:t).placeholder}function Kr(){var t=ji.iteratee||Ga;return t=t===Ga?Cn:t,arguments.length?t(arguments[0],arguments[1]):t}function Jr(t,e){var i,n,r=t.__data__;return("string"==(n=typeof(i=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?r["string"==typeof e?"string":"hash"]:r.map}function Zr(t){for(var e=_a(t),i=e.length;i--;){var n=e[i],r=t[n];e[i]=[n,r,fo(r)]}return e}function Qr(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return wn(i)?i:void 0}var to=ti?function(t){return null==t?[]:(t=gt(t),he(ti(t),(function(e){return $t.call(t,e)})))}:rc,eo=ti?function(t){for(var e=[];t;)pe(e,to(t)),t=Vt(t);return e}:rc,io=dn;function no(t,e,i){for(var n=-1,r=(e=ar(e,t)).length,o=!1;++n<r;){var s=Oo(e[n]);if(!(o=null!=t&&i(t,s)))break;t=t[s]}return o||++n!=r?o:!!(r=null==t?0:t.length)&&Ns(r)&&so(s,r)&&(Ms(t)||Ds(t))}function ro(t){return"function"!=typeof t.constructor||lo(t)?{}:Pi(Vt(t))}function oo(t){return Ms(t)||Ds(t)||!!(Jt&&t&&t[Jt])}function so(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&ct.test(t))&&t>-1&&t%1==0&&t<e}function ao(t,e,i){if(!zs(i))return!1;var n=typeof e;return!!("number"==n?Fs(i)&&so(e,i.length):"string"==n&&e in i)&&Es(i[e],t)}function co(t,e){if(Ms(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!Js(t))||(X.test(t)||!z.test(t)||null!=e&&t in gt(e))}function uo(t){var e=$r(t),i=ji[e];if("function"!=typeof i||!(e in Ai.prototype))return!1;if(t===i)return!0;var n=Gr(i);return!!n&&t===n[0]}(li&&io(new li(new ArrayBuffer(1)))!=S||fi&&io(new fi)!=g||di&&"[object Promise]"!=io(di.resolve())||pi&&io(new pi)!=b||gi&&io(new gi)!=w)&&(io=function(t){var e=dn(t),i=e==y?t.constructor:void 0,n=i?jo(i):"";if(n)switch(n){case bi:return S;case _i:return g;case xi:return"[object Promise]";case wi:return b;case Ci:return w}return e});var ho=wt?Us:oc;function lo(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||xt)}function fo(t){return t==t&&!zs(t)}function po(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in gt(i)))}}function go(t,e,i){return e=oi(void 0===e?t.length-1:e,0),function(){for(var r=arguments,o=-1,s=oi(r.length-e,0),a=n(s);++o<s;)a[o]=r[e+o];o=-1;for(var c=n(e+1);++o<e;)c[o]=r[o];return c[e]=i(a),oe(t,this,c)}}function vo(t,e){return e.length<2?t:ln(t,Vn(e,0,-1))}function yo(t,e){for(var i=t.length,n=si(e.length,i),r=yr(t);n--;){var o=e[n];t[n]=so(o,i)?r[o]:void 0}return t}function mo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var bo=Co(Nn),_o=Je||function(t,e){return Gt.setTimeout(t,e)},xo=Co(zn);function wo(t,e,i){var n=e+"";return xo(t,function(t,e){var i=e.length;if(!i)return t;var n=i-1;return e[n]=(i>1?"& ":"")+e[n],e=e.join(i>2?", ":" "),t.replace(J,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return ae(a,(function(i){var n="_."+i[0];e&i[1]&&!le(t,n)&&t.push(n)})),t.sort()}(function(t){var e=t.match(Z);return e?e[1].split(Q):[]}(n),i)))}function Co(t){var e=0,i=0;return function(){var n=ai(),r=16-(n-i);if(i=n,r>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function So(t,e){var i=-1,n=t.length,r=n-1;for(e=void 0===e?n:e;++i<e;){var o=Rn(i,r),s=t[o];t[o]=t[i],t[i]=s}return t.length=e,t}var To=function(t){var e=Cs(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(V,(function(t,i,n,r){e.push(n?r.replace(et,"$1"):i||t)})),e}));function Oo(t){if("string"==typeof t||Js(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function jo(t){if(null!=t){try{return Ct.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Po(t){if(t instanceof Ai)return t.clone();var e=new ki(t.__wrapped__,t.__chain__);return e.__actions__=yr(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Eo=Bn((function(t,e){return Rs(t)?Zi(t,on(e,1,Rs,!0)):[]})),ko=Bn((function(t,e){var i=Wo(e);return Rs(i)&&(i=void 0),Rs(t)?Zi(t,on(e,1,Rs,!0),Kr(i,2)):[]})),Ao=Bn((function(t,e){var i=Wo(e);return Rs(i)&&(i=void 0),Rs(t)?Zi(t,on(e,1,Rs,!0),void 0,i):[]}));function Do(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var r=null==i?0:na(i);return r<0&&(r=oi(n+r,0)),_e(t,Kr(e,3),r)}function Mo(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var r=n-1;return void 0!==i&&(r=na(i),r=i<0?oi(n+r,0):si(r,n-1)),_e(t,Kr(e,3),r,!0)}function Io(t){return(null==t?0:t.length)?on(t,1):[]}function Fo(t){return t&&t.length?t[0]:void 0}var Ro=Bn((function(t){var e=de(t,or);return e.length&&e[0]===t[0]?yn(e):[]})),Lo=Bn((function(t){var e=Wo(t),i=de(t,or);return e===Wo(i)?e=void 0:i.pop(),i.length&&i[0]===t[0]?yn(i,Kr(e,2)):[]})),Bo=Bn((function(t){var e=Wo(t),i=de(t,or);return(e="function"==typeof e?e:void 0)&&i.pop(),i.length&&i[0]===t[0]?yn(i,void 0,e):[]}));function Wo(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}var Uo=Bn(Yo);function Yo(t,e){return t&&t.length&&e&&e.length?In(t,e):t}var No=Xr((function(t,e){var i=null==t?0:t.length,n=Gi(t,e);return Fn(t,de(e,(function(t){return so(t,i)?+t:t})).sort(pr)),n}));function zo(t){return null==t?t:hi.call(t)}var Xo=Bn((function(t){return Zn(on(t,1,Rs,!0))})),Vo=Bn((function(t){var e=Wo(t);return Rs(e)&&(e=void 0),Zn(on(t,1,Rs,!0),Kr(e,2))})),Ho=Bn((function(t){var e=Wo(t);return e="function"==typeof e?e:void 0,Zn(on(t,1,Rs,!0),void 0,e)}));function Go(t){if(!t||!t.length)return[];var e=0;return t=he(t,(function(t){if(Rs(t))return e=oi(t.length,e),!0})),Ee(e,(function(e){return de(t,Te(e))}))}function $o(t,e){if(!t||!t.length)return[];var i=Go(t);return null==e?i:de(i,(function(t){return oe(e,void 0,t)}))}var qo=Bn((function(t,e){return Rs(t)?Zi(t,e):[]})),Ko=Bn((function(t){return nr(he(t,Rs))})),Jo=Bn((function(t){var e=Wo(t);return Rs(e)&&(e=void 0),nr(he(t,Rs),Kr(e,2))})),Zo=Bn((function(t){var e=Wo(t);return e="function"==typeof e?e:void 0,nr(he(t,Rs),void 0,e)})),Qo=Bn(Go);var ts=Bn((function(t){var e=t.length,i=e>1?t[e-1]:void 0;return i="function"==typeof i?(t.pop(),i):void 0,$o(t,i)}));function es(t){var e=ji(t);return e.__chain__=!0,e}function is(t,e){return e(t)}var ns=Xr((function(t){var e=t.length,i=e?t[0]:0,n=this.__wrapped__,r=function(e){return Gi(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Ai&&so(i)?((n=n.slice(i,+i+(e?1:0))).__actions__.push({func:is,args:[r],thisArg:void 0}),new ki(n,this.__chain__).thru((function(t){return e&&!t.length&&t.push(void 0),t}))):this.thru(r)}));var rs=br((function(t,e,i){St.call(t,i)?++t[i]:Hi(t,i,1)}));var os=Or(Do),ss=Or(Mo);function as(t,e){return(Ms(t)?ae:Qi)(t,Kr(e,3))}function cs(t,e){return(Ms(t)?ce:tn)(t,Kr(e,3))}var us=br((function(t,e,i){St.call(t,i)?t[i].push(e):Hi(t,i,[e])}));var hs=Bn((function(t,e,i){var r=-1,o="function"==typeof e,s=Fs(t)?n(t.length):[];return Qi(t,(function(t){s[++r]=o?oe(e,t,i):mn(t,e,i)})),s})),ls=br((function(t,e,i){Hi(t,i,e)}));function fs(t,e){return(Ms(t)?de:jn)(t,Kr(e,3))}var ds=br((function(t,e,i){t[i?0:1].push(e)}),(function(){return[[],[]]}));var ps=Bn((function(t,e){if(null==t)return[];var i=e.length;return i>1&&ao(t,e[0],e[1])?e=[]:i>2&&ao(e[0],e[1],e[2])&&(e=[e[0]]),Dn(t,on(e,1),[])})),gs=Ke||function(){return Gt.Date.now()};function vs(t,e,i){return e=i?void 0:e,Wr(t,128,void 0,void 0,void 0,void 0,e=t&&null==e?t.length:e)}function ys(t,e){var i;if("function"!=typeof e)throw new mt(o);return t=na(t),function(){return--t>0&&(i=e.apply(this,arguments)),t<=1&&(e=void 0),i}}var ms=Bn((function(t,e,i){var n=1;if(i.length){var r=Ne(i,qr(ms));n|=32}return Wr(t,n,e,i,r)})),bs=Bn((function(t,e,i){var n=3;if(i.length){var r=Ne(i,qr(bs));n|=32}return Wr(e,n,t,i,r)}));function _s(t,e,i){var n,r,s,a,c,u,h=0,l=!1,f=!1,d=!0;if("function"!=typeof t)throw new mt(o);function p(e){var i=n,o=r;return n=r=void 0,h=e,a=t.apply(o,i)}function g(t){return h=t,c=_o(y,e),l?p(t):a}function v(t){var i=t-u;return void 0===u||i>=e||i<0||f&&t-h>=s}function y(){var t=gs();if(v(t))return m(t);c=_o(y,function(t){var i=e-(t-u);return f?si(i,s-(t-h)):i}(t))}function m(t){return c=void 0,d&&n?p(t):(n=r=void 0,a)}function b(){var t=gs(),i=v(t);if(n=arguments,r=this,u=t,i){if(void 0===c)return g(u);if(f)return hr(c),c=_o(y,e),p(u)}return void 0===c&&(c=_o(y,e)),a}return e=oa(e)||0,zs(i)&&(l=!!i.leading,s=(f="maxWait"in i)?oi(oa(i.maxWait)||0,e):s,d="trailing"in i?!!i.trailing:d),b.cancel=function(){void 0!==c&&hr(c),h=0,n=u=r=c=void 0},b.flush=function(){return void 0===c?a:m(gs())},b}var xs=Bn((function(t,e){return Ji(t,1,e)})),ws=Bn((function(t,e,i){return Ji(t,oa(e)||0,i)}));function Cs(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new mt(o);var i=function(){var n=arguments,r=e?e.apply(this,n):n[0],o=i.cache;if(o.has(r))return o.get(r);var s=t.apply(this,n);return i.cache=o.set(r,s)||o,s};return i.cache=new(Cs.Cache||Ii),i}function Ss(t){if("function"!=typeof t)throw new mt(o);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Cs.Cache=Ii;var Ts=cr((function(t,e){var i=(e=1==e.length&&Ms(e[0])?de(e[0],ke(Kr())):de(on(e,1),ke(Kr()))).length;return Bn((function(n){for(var r=-1,o=si(n.length,i);++r<o;)n[r]=e[r].call(this,n[r]);return oe(t,this,n)}))})),Os=Bn((function(t,e){return Wr(t,32,void 0,e,Ne(e,qr(Os)))})),js=Bn((function(t,e){return Wr(t,64,void 0,e,Ne(e,qr(js)))})),Ps=Xr((function(t,e){return Wr(t,256,void 0,void 0,void 0,e)}));function Es(t,e){return t===e||t!=t&&e!=e}var ks=Ir(pn),As=Ir((function(t,e){return t>=e})),Ds=bn(function(){return arguments}())?bn:function(t){return Xs(t)&&St.call(t,"callee")&&!$t.call(t,"callee")},Ms=n.isArray,Is=Qt?ke(Qt):function(t){return Xs(t)&&dn(t)==C};function Fs(t){return null!=t&&Ns(t.length)&&!Us(t)}function Rs(t){return Xs(t)&&Fs(t)}var Ls=ei||oc,Bs=te?ke(te):function(t){return Xs(t)&&dn(t)==l};function Ws(t){if(!Xs(t))return!1;var e=dn(t);return e==f||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!Gs(t)}function Us(t){if(!zs(t))return!1;var e=dn(t);return e==d||e==p||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Ys(t){return"number"==typeof t&&t==na(t)}function Ns(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function zs(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Xs(t){return null!=t&&"object"==typeof t}var Vs=ee?ke(ee):function(t){return Xs(t)&&io(t)==g};function Hs(t){return"number"==typeof t||Xs(t)&&dn(t)==v}function Gs(t){if(!Xs(t)||dn(t)!=y)return!1;var e=Vt(t);if(null===e)return!0;var i=St.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Ct.call(i)==Pt}var $s=ie?ke(ie):function(t){return Xs(t)&&dn(t)==m};var qs=ne?ke(ne):function(t){return Xs(t)&&io(t)==b};function Ks(t){return"string"==typeof t||!Ms(t)&&Xs(t)&&dn(t)==_}function Js(t){return"symbol"==typeof t||Xs(t)&&dn(t)==x}var Zs=re?ke(re):function(t){return Xs(t)&&Ns(t.length)&&!!Ut[dn(t)]};var Qs=Ir(On),ta=Ir((function(t,e){return t<=e}));function ea(t){if(!t)return[];if(Fs(t))return Ks(t)?He(t):yr(t);if(Zt&&t[Zt])return function(t){for(var e,i=[];!(e=t.next()).done;)i.push(e.value);return i}(t[Zt]());var e=io(t);return(e==g?Ue:e==b?ze:Ea)(t)}function ia(t){return t?(t=oa(t))===1/0||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function na(t){var e=ia(t),i=e%1;return e==e?i?e-i:e:0}function ra(t){return t?$i(na(t),0,4294967295):0}function oa(t){if("number"==typeof t)return t;if(Js(t))return NaN;if(zs(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=zs(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace($,"");var i=ot.test(t);return i||at.test(t)?Xt(t.slice(2),i?2:8):rt.test(t)?NaN:+t}function sa(t){return mr(t,xa(t))}function aa(t){return null==t?"":Jn(t)}var ca=_r((function(t,e){if(lo(e)||Fs(e))mr(e,_a(e),t);else for(var i in e)St.call(e,i)&&Ni(t,i,e[i])})),ua=_r((function(t,e){mr(e,xa(e),t)})),ha=_r((function(t,e,i,n){mr(e,xa(e),t,n)})),la=_r((function(t,e,i,n){mr(e,_a(e),t,n)})),fa=Xr(Gi);var da=Bn((function(t,e){t=gt(t);var i=-1,n=e.length,r=n>2?e[2]:void 0;for(r&&ao(e[0],e[1],r)&&(n=1);++i<n;)for(var o=e[i],s=xa(o),a=-1,c=s.length;++a<c;){var u=s[a],h=t[u];(void 0===h||Es(h,xt[u])&&!St.call(t,u))&&(t[u]=o[u])}return t})),pa=Bn((function(t){return t.push(void 0,Yr),oe(Ca,void 0,t)}));function ga(t,e,i){var n=null==t?void 0:ln(t,e);return void 0===n?i:n}function va(t,e){return null!=t&&no(t,e,vn)}var ya=Er((function(t,e,i){null!=e&&"function"!=typeof e.toString&&(e=jt.call(e)),t[e]=i}),za(Ha)),ma=Er((function(t,e,i){null!=e&&"function"!=typeof e.toString&&(e=jt.call(e)),St.call(t,e)?t[e].push(i):t[e]=[i]}),Kr),ba=Bn(mn);function _a(t){return Fs(t)?Li(t):Sn(t)}function xa(t){return Fs(t)?Li(t,!0):Tn(t)}var wa=_r((function(t,e,i){kn(t,e,i)})),Ca=_r((function(t,e,i,n){kn(t,e,i,n)})),Sa=Xr((function(t,e){var i={};if(null==t)return i;var n=!1;e=de(e,(function(e){return e=ar(e,t),n||(n=e.length>1),e})),mr(t,Hr(t),i),n&&(i=qi(i,7,Nr));for(var r=e.length;r--;)Qn(i,e[r]);return i}));var Ta=Xr((function(t,e){return null==t?{}:function(t,e){return Mn(t,e,(function(e,i){return va(t,i)}))}(t,e)}));function Oa(t,e){if(null==t)return{};var i=de(Hr(t),(function(t){return[t]}));return e=Kr(e),Mn(t,i,(function(t,i){return e(t,i[0])}))}var ja=Br(_a),Pa=Br(xa);function Ea(t){return null==t?[]:Ae(t,_a(t))}var ka=Sr((function(t,e,i){return e=e.toLowerCase(),t+(i?Aa(e):e)}));function Aa(t){return Wa(aa(t).toLowerCase())}function Da(t){return(t=aa(t))&&t.replace(ut,Re).replace(Mt,"")}var Ma=Sr((function(t,e,i){return t+(i?"-":"")+e.toLowerCase()})),Ia=Sr((function(t,e,i){return t+(i?" ":"")+e.toLowerCase()})),Fa=Cr("toLowerCase");var Ra=Sr((function(t,e,i){return t+(i?"_":"")+e.toLowerCase()}));var La=Sr((function(t,e,i){return t+(i?" ":"")+Wa(e)}));var Ba=Sr((function(t,e,i){return t+(i?" ":"")+e.toUpperCase()})),Wa=Cr("toUpperCase");function Ua(t,e,i){return t=aa(t),void 0===(e=i?void 0:e)?function(t){return Lt.test(t)}(t)?function(t){return t.match(Ft)||[]}(t):function(t){return t.match(tt)||[]}(t):t.match(e)||[]}var Ya=Bn((function(t,e){try{return oe(t,void 0,e)}catch(t){return Ws(t)?t:new ft(t)}})),Na=Xr((function(t,e){return ae(e,(function(e){e=Oo(e),Hi(t,e,ms(t[e],t))})),t}));function za(t){return function(){return t}}var Xa=jr(),Va=jr(!0);function Ha(t){return t}function Ga(t){return Cn("function"==typeof t?t:qi(t,1))}var $a=Bn((function(t,e){return function(i){return mn(i,t,e)}})),qa=Bn((function(t,e){return function(i){return mn(t,i,e)}}));function Ka(t,e,i){var n=_a(e),r=hn(e,n);null!=i||zs(e)&&(r.length||!n.length)||(i=e,e=t,t=this,r=hn(e,_a(e)));var o=!(zs(i)&&"chain"in i&&!i.chain),s=Us(t);return ae(r,(function(i){var n=e[i];t[i]=n,s&&(t.prototype[i]=function(){var e=this.__chain__;if(o||e){var i=t(this.__wrapped__),r=i.__actions__=yr(this.__actions__);return r.push({func:n,args:arguments,thisArg:t}),i.__chain__=e,i}return n.apply(t,pe([this.value()],arguments))})})),t}function Ja(){}var Za=Ar(de),Qa=Ar(ue),tc=Ar(ye);function ec(t){return co(t)?Te(Oo(t)):function(t){return function(e){return ln(e,t)}}(t)}var ic=Mr(),nc=Mr(!0);function rc(){return[]}function oc(){return!1}var sc=kr((function(t,e){return t+e}),0),ac=Rr("ceil"),cc=kr((function(t,e){return t/e}),1),uc=Rr("floor");var hc,lc=kr((function(t,e){return t*e}),1),fc=Rr("round"),dc=kr((function(t,e){return t-e}),0);return ji.after=function(t,e){if("function"!=typeof e)throw new mt(o);return t=na(t),function(){if(--t<1)return e.apply(this,arguments)}},ji.ary=vs,ji.assign=ca,ji.assignIn=ua,ji.assignInWith=ha,ji.assignWith=la,ji.at=fa,ji.before=ys,ji.bind=ms,ji.bindAll=Na,ji.bindKey=bs,ji.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ms(t)?t:[t]},ji.chain=es,ji.chunk=function(t,e,i){e=(i?ao(t,e,i):void 0===e)?1:oi(na(e),0);var r=null==t?0:t.length;if(!r||e<1)return[];for(var o=0,s=0,a=n(Ze(r/e));o<r;)a[s++]=Vn(t,o,o+=e);return a},ji.compact=function(t){for(var e=-1,i=null==t?0:t.length,n=0,r=[];++e<i;){var o=t[e];o&&(r[n++]=o)}return r},ji.concat=function(){var t=arguments.length;if(!t)return[];for(var e=n(t-1),i=arguments[0],r=t;r--;)e[r-1]=arguments[r];return pe(Ms(i)?yr(i):[i],on(e,1))},ji.cond=function(t){var e=null==t?0:t.length,i=Kr();return t=e?de(t,(function(t){if("function"!=typeof t[1])throw new mt(o);return[i(t[0]),t[1]]})):[],Bn((function(i){for(var n=-1;++n<e;){var r=t[n];if(oe(r[0],this,i))return oe(r[1],this,i)}}))},ji.conforms=function(t){return function(t){var e=_a(t);return function(i){return Ki(i,t,e)}}(qi(t,1))},ji.constant=za,ji.countBy=rs,ji.create=function(t,e){var i=Pi(t);return null==e?i:Vi(i,e)},ji.curry=function t(e,i,n){var r=Wr(e,8,void 0,void 0,void 0,void 0,void 0,i=n?void 0:i);return r.placeholder=t.placeholder,r},ji.curryRight=function t(e,i,n){var r=Wr(e,16,void 0,void 0,void 0,void 0,void 0,i=n?void 0:i);return r.placeholder=t.placeholder,r},ji.debounce=_s,ji.defaults=da,ji.defaultsDeep=pa,ji.defer=xs,ji.delay=ws,ji.difference=Eo,ji.differenceBy=ko,ji.differenceWith=Ao,ji.drop=function(t,e,i){var n=null==t?0:t.length;return n?Vn(t,(e=i||void 0===e?1:na(e))<0?0:e,n):[]},ji.dropRight=function(t,e,i){var n=null==t?0:t.length;return n?Vn(t,0,(e=n-(e=i||void 0===e?1:na(e)))<0?0:e):[]},ji.dropRightWhile=function(t,e){return t&&t.length?er(t,Kr(e,3),!0,!0):[]},ji.dropWhile=function(t,e){return t&&t.length?er(t,Kr(e,3),!0):[]},ji.fill=function(t,e,i,n){var r=null==t?0:t.length;return r?(i&&"number"!=typeof i&&ao(t,e,i)&&(i=0,n=r),function(t,e,i,n){var r=t.length;for((i=na(i))<0&&(i=-i>r?0:r+i),(n=void 0===n||n>r?r:na(n))<0&&(n+=r),n=i>n?0:ra(n);i<n;)t[i++]=e;return t}(t,e,i,n)):[]},ji.filter=function(t,e){return(Ms(t)?he:rn)(t,Kr(e,3))},ji.flatMap=function(t,e){return on(fs(t,e),1)},ji.flatMapDeep=function(t,e){return on(fs(t,e),1/0)},ji.flatMapDepth=function(t,e,i){return i=void 0===i?1:na(i),on(fs(t,e),i)},ji.flatten=Io,ji.flattenDeep=function(t){return(null==t?0:t.length)?on(t,1/0):[]},ji.flattenDepth=function(t,e){return(null==t?0:t.length)?on(t,e=void 0===e?1:na(e)):[]},ji.flip=function(t){return Wr(t,512)},ji.flow=Xa,ji.flowRight=Va,ji.fromPairs=function(t){for(var e=-1,i=null==t?0:t.length,n={};++e<i;){var r=t[e];n[r[0]]=r[1]}return n},ji.functions=function(t){return null==t?[]:hn(t,_a(t))},ji.functionsIn=function(t){return null==t?[]:hn(t,xa(t))},ji.groupBy=us,ji.initial=function(t){return(null==t?0:t.length)?Vn(t,0,-1):[]},ji.intersection=Ro,ji.intersectionBy=Lo,ji.intersectionWith=Bo,ji.invert=ya,ji.invertBy=ma,ji.invokeMap=hs,ji.iteratee=Ga,ji.keyBy=ls,ji.keys=_a,ji.keysIn=xa,ji.map=fs,ji.mapKeys=function(t,e){var i={};return e=Kr(e,3),cn(t,(function(t,n,r){Hi(i,e(t,n,r),t)})),i},ji.mapValues=function(t,e){var i={};return e=Kr(e,3),cn(t,(function(t,n,r){Hi(i,n,e(t,n,r))})),i},ji.matches=function(t){return Pn(qi(t,1))},ji.matchesProperty=function(t,e){return En(t,qi(e,1))},ji.memoize=Cs,ji.merge=wa,ji.mergeWith=Ca,ji.method=$a,ji.methodOf=qa,ji.mixin=Ka,ji.negate=Ss,ji.nthArg=function(t){return t=na(t),Bn((function(e){return An(e,t)}))},ji.omit=Sa,ji.omitBy=function(t,e){return Oa(t,Ss(Kr(e)))},ji.once=function(t){return ys(2,t)},ji.orderBy=function(t,e,i,n){return null==t?[]:(Ms(e)||(e=null==e?[]:[e]),Ms(i=n?void 0:i)||(i=null==i?[]:[i]),Dn(t,e,i))},ji.over=Za,ji.overArgs=Ts,ji.overEvery=Qa,ji.overSome=tc,ji.partial=Os,ji.partialRight=js,ji.partition=ds,ji.pick=Ta,ji.pickBy=Oa,ji.property=ec,ji.propertyOf=function(t){return function(e){return null==t?void 0:ln(t,e)}},ji.pull=Uo,ji.pullAll=Yo,ji.pullAllBy=function(t,e,i){return t&&t.length&&e&&e.length?In(t,e,Kr(i,2)):t},ji.pullAllWith=function(t,e,i){return t&&t.length&&e&&e.length?In(t,e,void 0,i):t},ji.pullAt=No,ji.range=ic,ji.rangeRight=nc,ji.rearg=Ps,ji.reject=function(t,e){return(Ms(t)?he:rn)(t,Ss(Kr(e,3)))},ji.remove=function(t,e){var i=[];if(!t||!t.length)return i;var n=-1,r=[],o=t.length;for(e=Kr(e,3);++n<o;){var s=t[n];e(s,n,t)&&(i.push(s),r.push(n))}return Fn(t,r),i},ji.rest=function(t,e){if("function"!=typeof t)throw new mt(o);return Bn(t,e=void 0===e?e:na(e))},ji.reverse=zo,ji.sampleSize=function(t,e,i){return e=(i?ao(t,e,i):void 0===e)?1:na(e),(Ms(t)?Wi:Un)(t,e)},ji.set=function(t,e,i){return null==t?t:Yn(t,e,i)},ji.setWith=function(t,e,i,n){return n="function"==typeof n?n:void 0,null==t?t:Yn(t,e,i,n)},ji.shuffle=function(t){return(Ms(t)?Ui:Xn)(t)},ji.slice=function(t,e,i){var n=null==t?0:t.length;return n?(i&&"number"!=typeof i&&ao(t,e,i)?(e=0,i=n):(e=null==e?0:na(e),i=void 0===i?n:na(i)),Vn(t,e,i)):[]},ji.sortBy=ps,ji.sortedUniq=function(t){return t&&t.length?qn(t):[]},ji.sortedUniqBy=function(t,e){return t&&t.length?qn(t,Kr(e,2)):[]},ji.split=function(t,e,i){return i&&"number"!=typeof i&&ao(t,e,i)&&(e=i=void 0),(i=void 0===i?4294967295:i>>>0)?(t=aa(t))&&("string"==typeof e||null!=e&&!$s(e))&&!(e=Jn(e))&&We(t)?ur(He(t),0,i):t.split(e,i):[]},ji.spread=function(t,e){if("function"!=typeof t)throw new mt(o);return e=null==e?0:oi(na(e),0),Bn((function(i){var n=i[e],r=ur(i,0,e);return n&&pe(r,n),oe(t,this,r)}))},ji.tail=function(t){var e=null==t?0:t.length;return e?Vn(t,1,e):[]},ji.take=function(t,e,i){return t&&t.length?Vn(t,0,(e=i||void 0===e?1:na(e))<0?0:e):[]},ji.takeRight=function(t,e,i){var n=null==t?0:t.length;return n?Vn(t,(e=n-(e=i||void 0===e?1:na(e)))<0?0:e,n):[]},ji.takeRightWhile=function(t,e){return t&&t.length?er(t,Kr(e,3),!1,!0):[]},ji.takeWhile=function(t,e){return t&&t.length?er(t,Kr(e,3)):[]},ji.tap=function(t,e){return e(t),t},ji.throttle=function(t,e,i){var n=!0,r=!0;if("function"!=typeof t)throw new mt(o);return zs(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),_s(t,e,{leading:n,maxWait:e,trailing:r})},ji.thru=is,ji.toArray=ea,ji.toPairs=ja,ji.toPairsIn=Pa,ji.toPath=function(t){return Ms(t)?de(t,Oo):Js(t)?[t]:yr(To(aa(t)))},ji.toPlainObject=sa,ji.transform=function(t,e,i){var n=Ms(t),r=n||Ls(t)||Zs(t);if(e=Kr(e,4),null==i){var o=t&&t.constructor;i=r?n?new o:[]:zs(t)&&Us(o)?Pi(Vt(t)):{}}return(r?ae:cn)(t,(function(t,n,r){return e(i,t,n,r)})),i},ji.unary=function(t){return vs(t,1)},ji.union=Xo,ji.unionBy=Vo,ji.unionWith=Ho,ji.uniq=function(t){return t&&t.length?Zn(t):[]},ji.uniqBy=function(t,e){return t&&t.length?Zn(t,Kr(e,2)):[]},ji.uniqWith=function(t,e){return e="function"==typeof e?e:void 0,t&&t.length?Zn(t,void 0,e):[]},ji.unset=function(t,e){return null==t||Qn(t,e)},ji.unzip=Go,ji.unzipWith=$o,ji.update=function(t,e,i){return null==t?t:tr(t,e,sr(i))},ji.updateWith=function(t,e,i,n){return n="function"==typeof n?n:void 0,null==t?t:tr(t,e,sr(i),n)},ji.values=Ea,ji.valuesIn=function(t){return null==t?[]:Ae(t,xa(t))},ji.without=qo,ji.words=Ua,ji.wrap=function(t,e){return Os(sr(e),t)},ji.xor=Ko,ji.xorBy=Jo,ji.xorWith=Zo,ji.zip=Qo,ji.zipObject=function(t,e){return rr(t||[],e||[],Ni)},ji.zipObjectDeep=function(t,e){return rr(t||[],e||[],Yn)},ji.zipWith=ts,ji.entries=ja,ji.entriesIn=Pa,ji.extend=ua,ji.extendWith=ha,Ka(ji,ji),ji.add=sc,ji.attempt=Ya,ji.camelCase=ka,ji.capitalize=Aa,ji.ceil=ac,ji.clamp=function(t,e,i){return void 0===i&&(i=e,e=void 0),void 0!==i&&(i=(i=oa(i))==i?i:0),void 0!==e&&(e=(e=oa(e))==e?e:0),$i(oa(t),e,i)},ji.clone=function(t){return qi(t,4)},ji.cloneDeep=function(t){return qi(t,5)},ji.cloneDeepWith=function(t,e){return qi(t,5,e="function"==typeof e?e:void 0)},ji.cloneWith=function(t,e){return qi(t,4,e="function"==typeof e?e:void 0)},ji.conformsTo=function(t,e){return null==e||Ki(t,e,_a(e))},ji.deburr=Da,ji.defaultTo=function(t,e){return null==t||t!=t?e:t},ji.divide=cc,ji.endsWith=function(t,e,i){t=aa(t),e=Jn(e);var n=t.length,r=i=void 0===i?n:$i(na(i),0,n);return(i-=e.length)>=0&&t.slice(i,r)==e},ji.eq=Es,ji.escape=function(t){return(t=aa(t))&&W.test(t)?t.replace(L,Le):t},ji.escapeRegExp=function(t){return(t=aa(t))&&G.test(t)?t.replace(H,"\\$&"):t},ji.every=function(t,e,i){var n=Ms(t)?ue:en;return i&&ao(t,e,i)&&(e=void 0),n(t,Kr(e,3))},ji.find=os,ji.findIndex=Do,ji.findKey=function(t,e){return be(t,Kr(e,3),cn)},ji.findLast=ss,ji.findLastIndex=Mo,ji.findLastKey=function(t,e){return be(t,Kr(e,3),un)},ji.floor=uc,ji.forEach=as,ji.forEachRight=cs,ji.forIn=function(t,e){return null==t?t:sn(t,Kr(e,3),xa)},ji.forInRight=function(t,e){return null==t?t:an(t,Kr(e,3),xa)},ji.forOwn=function(t,e){return t&&cn(t,Kr(e,3))},ji.forOwnRight=function(t,e){return t&&un(t,Kr(e,3))},ji.get=ga,ji.gt=ks,ji.gte=As,ji.has=function(t,e){return null!=t&&no(t,e,gn)},ji.hasIn=va,ji.head=Fo,ji.identity=Ha,ji.includes=function(t,e,i,n){t=Fs(t)?t:Ea(t),i=i&&!n?na(i):0;var r=t.length;return i<0&&(i=oi(r+i,0)),Ks(t)?i<=r&&t.indexOf(e,i)>-1:!!r&&xe(t,e,i)>-1},ji.indexOf=function(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var r=null==i?0:na(i);return r<0&&(r=oi(n+r,0)),xe(t,e,r)},ji.inRange=function(t,e,i){return e=ia(e),void 0===i?(i=e,e=0):i=ia(i),function(t,e,i){return t>=si(e,i)&&t<oi(e,i)}(t=oa(t),e,i)},ji.invoke=ba,ji.isArguments=Ds,ji.isArray=Ms,ji.isArrayBuffer=Is,ji.isArrayLike=Fs,ji.isArrayLikeObject=Rs,ji.isBoolean=function(t){return!0===t||!1===t||Xs(t)&&dn(t)==h},ji.isBuffer=Ls,ji.isDate=Bs,ji.isElement=function(t){return Xs(t)&&1===t.nodeType&&!Gs(t)},ji.isEmpty=function(t){if(null==t)return!0;if(Fs(t)&&(Ms(t)||"string"==typeof t||"function"==typeof t.splice||Ls(t)||Zs(t)||Ds(t)))return!t.length;var e=io(t);if(e==g||e==b)return!t.size;if(lo(t))return!Sn(t).length;for(var i in t)if(St.call(t,i))return!1;return!0},ji.isEqual=function(t,e){return _n(t,e)},ji.isEqualWith=function(t,e,i){var n=(i="function"==typeof i?i:void 0)?i(t,e):void 0;return void 0===n?_n(t,e,void 0,i):!!n},ji.isError=Ws,ji.isFinite=function(t){return"number"==typeof t&&ii(t)},ji.isFunction=Us,ji.isInteger=Ys,ji.isLength=Ns,ji.isMap=Vs,ji.isMatch=function(t,e){return t===e||xn(t,e,Zr(e))},ji.isMatchWith=function(t,e,i){return i="function"==typeof i?i:void 0,xn(t,e,Zr(e),i)},ji.isNaN=function(t){return Hs(t)&&t!=+t},ji.isNative=function(t){if(ho(t))throw new ft("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return wn(t)},ji.isNil=function(t){return null==t},ji.isNull=function(t){return null===t},ji.isNumber=Hs,ji.isObject=zs,ji.isObjectLike=Xs,ji.isPlainObject=Gs,ji.isRegExp=$s,ji.isSafeInteger=function(t){return Ys(t)&&t>=-9007199254740991&&t<=9007199254740991},ji.isSet=qs,ji.isString=Ks,ji.isSymbol=Js,ji.isTypedArray=Zs,ji.isUndefined=function(t){return void 0===t},ji.isWeakMap=function(t){return Xs(t)&&io(t)==w},ji.isWeakSet=function(t){return Xs(t)&&"[object WeakSet]"==dn(t)},ji.join=function(t,e){return null==t?"":ni.call(t,e)},ji.kebabCase=Ma,ji.last=Wo,ji.lastIndexOf=function(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var r=n;return void 0!==i&&(r=(r=na(i))<0?oi(n+r,0):si(r,n-1)),e==e?function(t,e,i){for(var n=i+1;n--;)if(t[n]===e)return n;return n}(t,e,r):_e(t,Ce,r,!0)},ji.lowerCase=Ia,ji.lowerFirst=Fa,ji.lt=Qs,ji.lte=ta,ji.max=function(t){return t&&t.length?nn(t,Ha,pn):void 0},ji.maxBy=function(t,e){return t&&t.length?nn(t,Kr(e,2),pn):void 0},ji.mean=function(t){return Se(t,Ha)},ji.meanBy=function(t,e){return Se(t,Kr(e,2))},ji.min=function(t){return t&&t.length?nn(t,Ha,On):void 0},ji.minBy=function(t,e){return t&&t.length?nn(t,Kr(e,2),On):void 0},ji.stubArray=rc,ji.stubFalse=oc,ji.stubObject=function(){return{}},ji.stubString=function(){return""},ji.stubTrue=function(){return!0},ji.multiply=lc,ji.nth=function(t,e){return t&&t.length?An(t,na(e)):void 0},ji.noConflict=function(){return Gt._===this&&(Gt._=Et),this},ji.noop=Ja,ji.now=gs,ji.pad=function(t,e,i){t=aa(t);var n=(e=na(e))?Ve(t):0;if(!e||n>=e)return t;var r=(e-n)/2;return Dr(Qe(r),i)+t+Dr(Ze(r),i)},ji.padEnd=function(t,e,i){t=aa(t);var n=(e=na(e))?Ve(t):0;return e&&n<e?t+Dr(e-n,i):t},ji.padStart=function(t,e,i){t=aa(t);var n=(e=na(e))?Ve(t):0;return e&&n<e?Dr(e-n,i)+t:t},ji.parseInt=function(t,e,i){return i||null==e?e=0:e&&(e=+e),ci(aa(t).replace(q,""),e||0)},ji.random=function(t,e,i){if(i&&"boolean"!=typeof i&&ao(t,e,i)&&(e=i=void 0),void 0===i&&("boolean"==typeof e?(i=e,e=void 0):"boolean"==typeof t&&(i=t,t=void 0)),void 0===t&&void 0===e?(t=0,e=1):(t=ia(t),void 0===e?(e=t,t=0):e=ia(e)),t>e){var n=t;t=e,e=n}if(i||t%1||e%1){var r=ui();return si(t+r*(e-t+zt("1e-"+((r+"").length-1))),e)}return Rn(t,e)},ji.reduce=function(t,e,i){var n=Ms(t)?ge:je,r=arguments.length<3;return n(t,Kr(e,4),i,r,Qi)},ji.reduceRight=function(t,e,i){var n=Ms(t)?ve:je,r=arguments.length<3;return n(t,Kr(e,4),i,r,tn)},ji.repeat=function(t,e,i){return e=(i?ao(t,e,i):void 0===e)?1:na(e),Ln(aa(t),e)},ji.replace=function(){var t=arguments,e=aa(t[0]);return t.length<3?e:e.replace(t[1],t[2])},ji.result=function(t,e,i){var n=-1,r=(e=ar(e,t)).length;for(r||(r=1,t=void 0);++n<r;){var o=null==t?void 0:t[Oo(e[n])];void 0===o&&(n=r,o=i),t=Us(o)?o.call(t):o}return t},ji.round=fc,ji.runInContext=t,ji.sample=function(t){return(Ms(t)?Bi:Wn)(t)},ji.size=function(t){if(null==t)return 0;if(Fs(t))return Ks(t)?Ve(t):t.length;var e=io(t);return e==g||e==b?t.size:Sn(t).length},ji.snakeCase=Ra,ji.some=function(t,e,i){var n=Ms(t)?ye:Hn;return i&&ao(t,e,i)&&(e=void 0),n(t,Kr(e,3))},ji.sortedIndex=function(t,e){return Gn(t,e)},ji.sortedIndexBy=function(t,e,i){return $n(t,e,Kr(i,2))},ji.sortedIndexOf=function(t,e){var i=null==t?0:t.length;if(i){var n=Gn(t,e);if(n<i&&Es(t[n],e))return n}return-1},ji.sortedLastIndex=function(t,e){return Gn(t,e,!0)},ji.sortedLastIndexBy=function(t,e,i){return $n(t,e,Kr(i,2),!0)},ji.sortedLastIndexOf=function(t,e){if(null==t?0:t.length){var i=Gn(t,e,!0)-1;if(Es(t[i],e))return i}return-1},ji.startCase=La,ji.startsWith=function(t,e,i){return t=aa(t),i=null==i?0:$i(na(i),0,t.length),e=Jn(e),t.slice(i,i+e.length)==e},ji.subtract=dc,ji.sum=function(t){return t&&t.length?Pe(t,Ha):0},ji.sumBy=function(t,e){return t&&t.length?Pe(t,Kr(e,2)):0},ji.template=function(t,e,i){var n=ji.templateSettings;i&&ao(t,e,i)&&(e=void 0),t=aa(t),e=ha({},e,n,Ur);var r,o,s=ha({},e.imports,n.imports,Ur),a=_a(s),c=Ae(s,a),u=0,h=e.interpolate||ht,l="__p += '",f=vt((e.escape||ht).source+"|"+h.source+"|"+(h===N?it:ht).source+"|"+(e.evaluate||ht).source+"|$","g"),d="//# sourceURL="+(St.call(e,"sourceURL")?(e.sourceURL+"").replace(/[\r\n]/g," "):"lodash.templateSources["+ ++Wt+"]")+"\n";t.replace(f,(function(e,i,n,s,a,c){return n||(n=s),l+=t.slice(u,c).replace(lt,Be),i&&(r=!0,l+="' +\n__e("+i+") +\n'"),a&&(o=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+e.length,e})),l+="';\n";var p=St.call(e,"variable")&&e.variable;p||(l="with (obj) {\n"+l+"\n}\n"),l=(o?l.replace(M,""):l).replace(I,"$1").replace(F,"$1;"),l="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var g=Ya((function(){return dt(a,d+"return "+l).apply(void 0,c)}));if(g.source=l,Ws(g))throw g;return g},ji.times=function(t,e){if((t=na(t))<1||t>9007199254740991)return[];var i=4294967295,n=si(t,4294967295);t-=4294967295;for(var r=Ee(n,e=Kr(e));++i<t;)e(i);return r},ji.toFinite=ia,ji.toInteger=na,ji.toLength=ra,ji.toLower=function(t){return aa(t).toLowerCase()},ji.toNumber=oa,ji.toSafeInteger=function(t){return t?$i(na(t),-9007199254740991,9007199254740991):0===t?t:0},ji.toString=aa,ji.toUpper=function(t){return aa(t).toUpperCase()},ji.trim=function(t,e,i){if((t=aa(t))&&(i||void 0===e))return t.replace($,"");if(!t||!(e=Jn(e)))return t;var n=He(t),r=He(e);return ur(n,Me(n,r),Ie(n,r)+1).join("")},ji.trimEnd=function(t,e,i){if((t=aa(t))&&(i||void 0===e))return t.replace(K,"");if(!t||!(e=Jn(e)))return t;var n=He(t);return ur(n,0,Ie(n,He(e))+1).join("")},ji.trimStart=function(t,e,i){if((t=aa(t))&&(i||void 0===e))return t.replace(q,"");if(!t||!(e=Jn(e)))return t;var n=He(t);return ur(n,Me(n,He(e))).join("")},ji.truncate=function(t,e){var i=30,n="...";if(zs(e)){var r="separator"in e?e.separator:r;i="length"in e?na(e.length):i,n="omission"in e?Jn(e.omission):n}var o=(t=aa(t)).length;if(We(t)){var s=He(t);o=s.length}if(i>=o)return t;var a=i-Ve(n);if(a<1)return n;var c=s?ur(s,0,a).join(""):t.slice(0,a);if(void 0===r)return c+n;if(s&&(a+=c.length-a),$s(r)){if(t.slice(a).search(r)){var u,h=c;for(r.global||(r=vt(r.source,aa(nt.exec(r))+"g")),r.lastIndex=0;u=r.exec(h);)var l=u.index;c=c.slice(0,void 0===l?a:l)}}else if(t.indexOf(Jn(r),a)!=a){var f=c.lastIndexOf(r);f>-1&&(c=c.slice(0,f))}return c+n},ji.unescape=function(t){return(t=aa(t))&&B.test(t)?t.replace(R,Ge):t},ji.uniqueId=function(t){var e=++Tt;return aa(t)+e},ji.upperCase=Ba,ji.upperFirst=Wa,ji.each=as,ji.eachRight=cs,ji.first=Fo,Ka(ji,(hc={},cn(ji,(function(t,e){St.call(ji.prototype,e)||(hc[e]=t)})),hc),{chain:!1}),ji.VERSION="4.17.15",ae(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){ji[t].placeholder=ji})),ae(["drop","take"],(function(t,e){Ai.prototype[t]=function(i){i=void 0===i?1:oi(na(i),0);var n=this.__filtered__&&!e?new Ai(this):this.clone();return n.__filtered__?n.__takeCount__=si(i,n.__takeCount__):n.__views__.push({size:si(i,4294967295),type:t+(n.__dir__<0?"Right":"")}),n},Ai.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),ae(["filter","map","takeWhile"],(function(t,e){var i=e+1,n=1==i||3==i;Ai.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Kr(t,3),type:i}),e.__filtered__=e.__filtered__||n,e}})),ae(["head","last"],(function(t,e){var i="take"+(e?"Right":"");Ai.prototype[t]=function(){return this[i](1).value()[0]}})),ae(["initial","tail"],(function(t,e){var i="drop"+(e?"":"Right");Ai.prototype[t]=function(){return this.__filtered__?new Ai(this):this[i](1)}})),Ai.prototype.compact=function(){return this.filter(Ha)},Ai.prototype.find=function(t){return this.filter(t).head()},Ai.prototype.findLast=function(t){return this.reverse().find(t)},Ai.prototype.invokeMap=Bn((function(t,e){return"function"==typeof t?new Ai(this):this.map((function(i){return mn(i,t,e)}))})),Ai.prototype.reject=function(t){return this.filter(Ss(Kr(t)))},Ai.prototype.slice=function(t,e){t=na(t);var i=this;return i.__filtered__&&(t>0||e<0)?new Ai(i):(t<0?i=i.takeRight(-t):t&&(i=i.drop(t)),void 0!==e&&(i=(e=na(e))<0?i.dropRight(-e):i.take(e-t)),i)},Ai.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Ai.prototype.toArray=function(){return this.take(4294967295)},cn(Ai.prototype,(function(t,e){var i=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),r=ji[n?"take"+("last"==e?"Right":""):e],o=n||/^find/.test(e);r&&(ji.prototype[e]=function(){var e=this.__wrapped__,s=n?[1]:arguments,a=e instanceof Ai,c=s[0],u=a||Ms(e),h=function(t){var e=r.apply(ji,pe([t],s));return n&&l?e[0]:e};u&&i&&"function"==typeof c&&1!=c.length&&(a=u=!1);var l=this.__chain__,f=!!this.__actions__.length,d=o&&!l,p=a&&!f;if(!o&&u){e=p?e:new Ai(this);var g=t.apply(e,s);return g.__actions__.push({func:is,args:[h],thisArg:void 0}),new ki(g,l)}return d&&p?t.apply(this,s):(g=this.thru(h),d?n?g.value()[0]:g.value():g)})})),ae(["pop","push","shift","sort","splice","unshift"],(function(t){var e=bt[t],i=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);ji.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var r=this.value();return e.apply(Ms(r)?r:[],t)}return this[i]((function(i){return e.apply(Ms(i)?i:[],t)}))}})),cn(Ai.prototype,(function(t,e){var i=ji[e];if(i){var n=i.name+"";St.call(mi,n)||(mi[n]=[]),mi[n].push({name:e,func:i})}})),mi[Pr(void 0,2).name]=[{name:"wrapper",func:void 0}],Ai.prototype.clone=function(){var t=new Ai(this.__wrapped__);return t.__actions__=yr(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=yr(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=yr(this.__views__),t},Ai.prototype.reverse=function(){if(this.__filtered__){var t=new Ai(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Ai.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,i=Ms(t),n=e<0,r=i?t.length:0,o=function(t,e,i){var n=-1,r=i.length;for(;++n<r;){var o=i[n],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=si(e,t+s);break;case"takeRight":t=oi(t,e-s)}}return{start:t,end:e}}(0,r,this.__views__),s=o.start,a=o.end,c=a-s,u=n?a:s-1,h=this.__iteratees__,l=h.length,f=0,d=si(c,this.__takeCount__);if(!i||!n&&r==c&&d==c)return ir(t,this.__actions__);var p=[];t:for(;c--&&f<d;){for(var g=-1,v=t[u+=e];++g<l;){var y=h[g],m=y.iteratee,b=y.type,_=m(v);if(2==b)v=_;else if(!_){if(1==b)continue t;break t}}p[f++]=v}return p},ji.prototype.at=ns,ji.prototype.chain=function(){return es(this)},ji.prototype.commit=function(){return new ki(this.value(),this.__chain__)},ji.prototype.next=function(){void 0===this.__values__&&(this.__values__=ea(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?void 0:this.__values__[this.__index__++]}},ji.prototype.plant=function(t){for(var e,i=this;i instanceof Ei;){var n=Po(i);n.__index__=0,n.__values__=void 0,e?r.__wrapped__=n:e=n;var r=n;i=i.__wrapped__}return r.__wrapped__=t,e},ji.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Ai){var e=t;return this.__actions__.length&&(e=new Ai(this)),(e=e.reverse()).__actions__.push({func:is,args:[zo],thisArg:void 0}),new ki(e,this.__chain__)}return this.thru(zo)},ji.prototype.toJSON=ji.prototype.valueOf=ji.prototype.value=function(){return ir(this.__wrapped__,this.__actions__)},ji.prototype.first=ji.prototype.head,Zt&&(ji.prototype[Zt]=function(){return this}),ji}();Gt._=$e,void 0===(r=function(){return $e}.call(e,i,e,n))||(n.exports=r)}).call(this)}).call(this,i(8),i(31)(t))},function(t,e,i){var n,r;n=[i,e,i(3),i(0),i(6),i(1),i(17)],void 0===(r=function(t,e,i,n,r,o,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractCanvasObject=void 0;var a=function(){function t(t,e,n,r){var o=this;this.canvas=e,this.fabricObject=n,this.data=r||new s.CanvasObjectData(t,this.fabricObject.id),this.dimensions$=new i.BehaviorSubject(new c(this.fabricObject,this.canvas)),this.updatePinToBottomDistance(),this.canvas.getProfile$().subscribe((function(t){return o.onProfileChange(t)})),this.canvas.getLayoutManager$().subscribe((function(t){return o.onLayoutManagerChange(t)})),this.fabricObject.on("moving",(function(t){return o.onMove(t)})),this.fabricObject.on("rotating",(function(t){return o.onRotate(t)})),this.fabricObject.on("scaling",(function(t){return o.onScale(t)}))}return t.prototype.getId=function(){return this.data.id},t.prototype.getType=function(){return this.data.type},t.prototype.getDescription=function(){switch(this.data.type){case n.ObjectType.BORDER:return"Border";case n.ObjectType.CUTOFF:return"Bottom Border";case n.ObjectType.IMAGE:return"Image";case n.ObjectType.LIBRARY_IMAGE:return"Library Image";case n.ObjectType.RECTANGLE:return"Rectangle";case n.ObjectType.TEXT:return"Text";default:return"Field"}},t.prototype.setSortCaption=function(t){this.data.sortCaption=t},t.prototype.isSortCaption=function(){return this.data.sortCaption},t.prototype.getDimensions=function(){return this.dimensions$.value},t.prototype.getDimensions$=function(){return this.dimensions$},t.prototype.getMargin=function(){return this.data.margin||{top:0,right:0,bottom:0,left:0}},t.prototype.setMargin=function(t){if(t){var e=r.oc(this.data).margin({top:0,right:0,bottom:0,left:0});null!=t.top&&(e.top=t.top||0),null!=t.right&&(e.right=t.right||0),null!=t.bottom&&(e.bottom=t.bottom||0),null!=t.left&&(e.left=t.left||0),this.data.margin=e,this.canvas.notifyObjectListChanged()}},t.prototype.getColumnWidthPercent=function(){return Math.max(Math.min(r.oc(this.data).columnWidthPercent(100),100),0)},t.prototype.setColumnWidthPercent=function(t){this.data.columnWidthPercent=t,this.canvas.notifyObjectListChanged()},t.prototype.bringForward=function(){this.fabricObject.bringForward(),this.canvas.syncObjectList()},t.prototype.bringToFront=function(){this.fabricObject.bringToFront(),this.canvas.syncObjectList()},t.prototype.sendBackward=function(){this.fabricObject.sendBackwards(),this.canvas.syncObjectList()},t.prototype.sendToBack=function(){this.fabricObject.sendToBack(),this.canvas.syncObjectList()},t.prototype.moveUp=function(){this.sendBackward()},t.prototype.moveDown=function(){this.bringForward()},t.prototype.delete=function(){this.canvas.removeObject(this),this.onDelete()},t.prototype.persist=function(){return o.clone(this.data)},t.prototype.isPinToBottom=function(){return this.data.pinToBottom},t.prototype.setPinToBottom=function(t){void 0===t&&(t=!0),this.updatePinToBottomDistance(),this.data.pinToBottom=t,this.canvas.onObjectListChange(),this.updateFabricObjectBehavior()},t.prototype.getFabricObjectInternal=function(){return this.fabricObject},t.prototype.setPosition=function(t){var e=this.getDimensions().scale;null!=t.top&&this.fabricObject.set({top:t.top}),null!=t.left&&this.fabricObject.set({left:t.left}),null!=t.width&&this.fabricObject.set({width:t.width/e.x}),null!=t.height&&this.fabricObject.set({height:t.height/e.y})},t.prototype.setCoords=function(){this.fabricObject.setCoords()},t.prototype.updateDimensions=function(){this.setCoords();var t=new c(this.fabricObject,this.canvas);this.dimensions$.next(t)},t.prototype.getBoundingBox=function(){return this.fabricObject.getBoundingRect(!0,!0)},t.prototype.moveToPinnedPosition=function(){this.data.pinToBottom&&this.setPosition({top:this.canvas.getDimensions().heightPx-this.pinToBottomDistance})},t.prototype.updatePinToBottomDistance=function(){this.pinToBottomDistance=this.canvas.getDimensions().heightPx-this.getDimensions().top.px},t.prototype.redraw=function(){this.canvas.redraw()},t.prototype.onProfileChange=function(t){this.updateFabricObjectBehavior(),this.redraw()},t.prototype.onLayoutManagerChange=function(t){this.updateFabricObjectBehavior(),this.redraw()},t.prototype.onMove=function(t){this.canvas.getProfile().allowObjectsToLeaveCanvas||this.preventLeavingCanvas(),this.updateDimensions()},t.prototype.onRotate=function(t){t.e.shiftKey?this.fabricObject.set({snapAngle:0}):this.fabricObject.set({snapAngle:45}),this.updateDimensions()},t.prototype.onScale=function(t){this.updateDimensions()},t.prototype.onDelete=function(){},t.prototype.preventLeavingCanvas=function(){var t=this.getCanvasOverflow();if(t.hasOverflow){var e=t.left||-t.right,i=t.top||-t.bottom;this.fabricObject.set({top:this.fabricObject.top+i,left:this.fabricObject.left+e}),this.redraw()}},t.prototype.getCanvasOverflow=function(){var t=this.getBoundingBox(),e=this.canvas.getDimensions(),i=Math.max(0,0-t.top),n=Math.max(0,t.left+t.width-e.widthPx),r=Math.max(0,t.top+t.height-e.heightPx),o=Math.max(0,0-t.left);return{top:i,right:n,bottom:r,left:o,hasOverflow:i>0||n>0||r>0||o>0}},t.prototype.centerHorizontallyInternal=function(){var t=this.canvas.getDimensions().widthPx,e=this.getDimensions().width.px;this.fabricObject.set({left:(t-e)/2-.5}),this.updateDimensions(),this.redraw()},t.prototype.centerVerticallyInternal=function(){var t=this.canvas.getDimensions().heightPx,e=this.getDimensions().height.px;this.fabricObject.set({top:(t-e)/2-.5}),this.redraw(),this.updateDimensions()},t.prototype.nudgeInternal=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.fabricObject.set({top:this.getDimensions().top.px+e,left:this.getDimensions().left.px+t}),this.redraw(),this.updateDimensions()},t.prototype.updateFabricObjectBehavior=function(){var t=!this.canvas.getLayoutManager().isEnforcedPositioning,e=this.canvas.getProfile(),i={allowMove:t&&e.allowMove&&!this.isPinToBottom(),allowRotate:t&&e.allowRotate&&!this.isPinToBottom(),allowScale:t&&e.allowScale&&!this.isPinToBottom()};this.fabricObject.set({lockMovementX:!i.allowMove,lockMovementY:!i.allowMove,lockScalingX:!i.allowScale,lockScalingY:!i.allowScale,lockScalingFlip:!0,lockRotation:!i.allowRotate}),this.fabricObject.setControlsVisibility({tl:i.allowScale,tr:i.allowScale,br:i.allowScale,bl:i.allowScale,ml:i.allowScale,mt:i.allowScale,mr:i.allowScale,mb:i.allowScale,mtr:i.allowRotate})},t}();e.AbstractCanvasObject=a;var c=function(t,e){var i=e.getDimensions().widthPxToMm,n=e.getDimensions().heightPxToMm;this.top={px:t.top,mm:n(t.top)},this.left={px:t.left,mm:i(t.left)};var r=t.width*t.scaleX,o=t.height*t.scaleY;this.width={px:r,mm:i(r)},this.height={px:o,mm:n(o)},this.scale={x:t.scaleX,y:t.scaleY},this.angle=t.angle}}.apply(e,n))||(t.exports=r)},function(t,e,i){"use strict";i.r(e),i.d(e,"Observable",(function(){return C})),i.d(e,"ConnectableObservable",(function(){return D})),i.d(e,"GroupedObservable",(function(){return I})),i.d(e,"observable",(function(){return b})),i.d(e,"Subject",(function(){return P})),i.d(e,"BehaviorSubject",(function(){return R})),i.d(e,"ReplaySubject",(function(){return et})),i.d(e,"AsyncSubject",(function(){return nt})),i.d(e,"asapScheduler",(function(){return lt})),i.d(e,"asyncScheduler",(function(){return ft})),i.d(e,"queueScheduler",(function(){return Y})),i.d(e,"animationFrameScheduler",(function(){return pt})),i.d(e,"VirtualTimeScheduler",(function(){return gt})),i.d(e,"VirtualAction",(function(){return vt})),i.d(e,"Scheduler",(function(){return W})),i.d(e,"Subscription",(function(){return d})),i.d(e,"Subscriber",(function(){return v})),i.d(e,"Notification",(function(){return Z})),i.d(e,"NotificationKind",(function(){return V})),i.d(e,"pipe",(function(){return x})),i.d(e,"noop",(function(){return yt})),i.d(e,"identity",(function(){return _})),i.d(e,"isObservable",(function(){return mt})),i.d(e,"ArgumentOutOfRangeError",(function(){return bt})),i.d(e,"EmptyError",(function(){return _t})),i.d(e,"ObjectUnsubscribedError",(function(){return T})),i.d(e,"UnsubscriptionError",(function(){return f})),i.d(e,"TimeoutError",(function(){return xt})),i.d(e,"bindCallback",(function(){return Tt})),i.d(e,"bindNodeCallback",(function(){return Pt})),i.d(e,"combineLatest",(function(){return Yt})),i.d(e,"concat",(function(){return Kt})),i.d(e,"defer",(function(){return Jt})),i.d(e,"empty",(function(){return z})),i.d(e,"forkJoin",(function(){return Zt})),i.d(e,"from",(function(){return Vt})),i.d(e,"fromEvent",(function(){return te})),i.d(e,"fromEventPattern",(function(){return ee})),i.d(e,"generate",(function(){return ie})),i.d(e,"iif",(function(){return re})),i.d(e,"interval",(function(){return se})),i.d(e,"merge",(function(){return ce})),i.d(e,"never",(function(){return he})),i.d(e,"of",(function(){return q})),i.d(e,"onErrorResumeNext",(function(){return le})),i.d(e,"pairs",(function(){return fe})),i.d(e,"partition",(function(){return me})),i.d(e,"race",(function(){return be})),i.d(e,"range",(function(){return we})),i.d(e,"throwError",(function(){return K})),i.d(e,"timer",(function(){return Se})),i.d(e,"using",(function(){return Oe})),i.d(e,"zip",(function(){return je})),i.d(e,"scheduled",(function(){return Xt})),i.d(e,"EMPTY",(function(){return N})),i.d(e,"NEVER",(function(){return ue})),i.d(e,"config",(function(){return a}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function r(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function o(t){return"function"==typeof t}var s=!1,a={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack;s=t},get useDeprecatedSynchronousErrorHandling(){return s}};function c(t){setTimeout((function(){throw t}),0)}var u={closed:!0,next:function(t){},error:function(t){if(a.useDeprecatedSynchronousErrorHandling)throw t;c(t)},complete:function(){}},h=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var f=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),d=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var i=this._parentOrParents,n=this._unsubscribe,r=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,i instanceof t)i.remove(this);else if(null!==i)for(var s=0;s<i.length;++s){i[s].remove(this)}if(o(n))try{n.call(this)}catch(t){e=t instanceof f?p(t.errors):[t]}if(h(r)){s=-1;for(var a=r.length;++s<a;){var c=r[s];if(l(c))try{c.unsubscribe()}catch(t){e=e||[],t instanceof f?e=e.concat(p(t.errors)):e.push(t)}}}if(e)throw new f(e)}},t.prototype.add=function(e){var i=e;if(!e)return t.EMPTY;switch(typeof e){case"function":i=new t(e);case"object":if(i===this||i.closed||"function"!=typeof i.unsubscribe)return i;if(this.closed)return i.unsubscribe(),i;if(!(i instanceof t)){var n=i;(i=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var r=i._parentOrParents;if(null===r)i._parentOrParents=this;else if(r instanceof t){if(r===this)return i;i._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return i;r.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[i]:o.push(i),i},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var i=e.indexOf(t);-1!==i&&e.splice(i,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function p(t){return t.reduce((function(t,e){return t.concat(e instanceof f?e.errors:e)}),[])}var g=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),v=function(t){function e(i,n,r){var o=t.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=u;break;case 1:if(!i){o.destination=u;break}if("object"==typeof i){i instanceof e?(o.syncErrorThrowable=i.syncErrorThrowable,o.destination=i,i.add(o)):(o.syncErrorThrowable=!0,o.destination=new y(o,i));break}default:o.syncErrorThrowable=!0,o.destination=new y(o,i,n,r)}return o}return r(e,t),e.prototype[g]=function(){return this},e.create=function(t,i,n){var r=new e(t,i,n);return r.syncErrorThrowable=!1,r},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(d),y=function(t){function e(e,i,n,r){var s,a=t.call(this)||this;a._parentSubscriber=e;var c=a;return o(i)?s=i:i&&(s=i.next,n=i.error,r=i.complete,i!==u&&(o((c=Object.create(i)).unsubscribe)&&a.add(c.unsubscribe.bind(c)),c.unsubscribe=a.unsubscribe.bind(a))),a._context=c,a._next=s,a._error=n,a._complete=r,a}return r(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;a.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,i=a.useDeprecatedSynchronousErrorHandling;if(this._error)i&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)i?(e.syncErrorValue=t,e.syncErrorThrown=!0):c(t),this.unsubscribe();else{if(this.unsubscribe(),i)throw t;c(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var i=function(){return t._complete.call(t._context)};a.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,i),this.unsubscribe()):(this.__tryOrUnsub(i),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),a.useDeprecatedSynchronousErrorHandling)throw t;c(t)}},e.prototype.__tryOrSetError=function(t,e,i){if(!a.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,i)}catch(e){return a.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(c(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(v);function m(t){for(;t;){var e=t,i=e.closed,n=e.destination,r=e.isStopped;if(i||r)return!1;t=n&&n instanceof v?n:null}return!0}var b=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function _(t){return t}function x(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return w(t)}function w(t){return 0===t.length?_:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var C=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var i=new t;return i.source=this,i.operator=e,i},t.prototype.subscribe=function(t,e,i){var n=this.operator,r=function(t,e,i){if(t){if(t instanceof v)return t;if(t[g])return t[g]()}return t||e||i?new v(t,e,i):new v(u)}(t,e,i);if(n?r.add(n.call(r,this.source)):r.add(this.source||a.useDeprecatedSynchronousErrorHandling&&!r.syncErrorThrowable?this._subscribe(r):this._trySubscribe(r)),a.useDeprecatedSynchronousErrorHandling&&r.syncErrorThrowable&&(r.syncErrorThrowable=!1,r.syncErrorThrown))throw r.syncErrorValue;return r},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){a.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),m(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var i=this;return new(e=S(e))((function(e,n){var r;r=i.subscribe((function(e){try{t(e)}catch(t){n(t),r&&r.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[b]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:w(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=S(t))((function(t,i){var n;e.subscribe((function(t){return n=t}),(function(t){return i(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function S(t){if(t||(t=a.Promise||Promise),!t)throw new Error("no Promise impl found");return t}var T=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),O=function(t){function e(e,i){var n=t.call(this)||this;return n.subject=e,n.subscriber=i,n.closed=!1,n}return r(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var i=e.indexOf(this.subscriber);-1!==i&&e.splice(i,1)}}},e}(d),j=function(t){function e(e){var i=t.call(this,e)||this;return i.destination=e,i}return r(e,t),e}(v),P=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r(e,t),e.prototype[g]=function(){return new j(this)},e.prototype.lift=function(t){var e=new E(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new T;if(!this.isStopped)for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].next(t)},e.prototype.error=function(t){if(this.closed)throw new T;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new T;this.isStopped=!0;for(var t=this.observers,e=t.length,i=t.slice(),n=0;n<e;n++)i[n].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new T;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new T;return this.hasError?(t.error(this.thrownError),d.EMPTY):this.isStopped?(t.complete(),d.EMPTY):(this.observers.push(t),new O(this,t))},e.prototype.asObservable=function(){var t=new C;return t.source=this,t},e.create=function(t,e){return new E(t,e)},e}(C),E=function(t){function e(e,i){var n=t.call(this)||this;return n.destination=e,n.source=i,n}return r(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):d.EMPTY},e}(P);var k=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var i=this.connectable;i._refCount++;var n=new A(t,i),r=e.subscribe(n);return n.closed||(n.connection=i.connect()),r},t}(),A=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return r(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var i=this.connection,n=t._connection;this.connection=null,!n||i&&n!==i||n.unsubscribe()}}else this.connection=null},e}(v),D=function(t){function e(e,i){var n=t.call(this)||this;return n.source=e,n.subjectFactory=i,n._refCount=0,n._isComplete=!1,n}return r(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new d).add(this.source.subscribe(new M(this.getSubject(),this))),t.closed&&(this._connection=null,t=d.EMPTY)),t},e.prototype.refCount=function(){return(t=this).lift(new k(t));var t},e}(C),M=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return r(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(j);var I=function(t){function e(e,i,n){var r=t.call(this)||this;return r.key=e,r.groupSubject=i,r.refCountSubscription=n,r}return r(e,t),e.prototype._subscribe=function(t){var e=new d,i=this.refCountSubscription,n=this.groupSubject;return i&&!i.closed&&e.add(new F(i)),e.add(n.subscribe(t)),e},e}(C),F=function(t){function e(e){var i=t.call(this)||this;return i.parent=e,e.count++,i}return r(e,t),e.prototype.unsubscribe=function(){var e=this.parent;e.closed||this.closed||(t.prototype.unsubscribe.call(this),e.count-=1,0===e.count&&e.attemptedToUnsubscribe&&e.unsubscribe())},e}(d),R=function(t){function e(e){var i=t.call(this)||this;return i._value=e,i}return r(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var i=t.prototype._subscribe.call(this,e);return i&&!i.closed&&e.next(this._value),i},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new T;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(P),L=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n.pending=!1,n}return r(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var i=this.id,n=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(n,i,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,i){return void 0===i&&(i=0),setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,e,i){if(void 0===i&&(i=0),null!==i&&this.delay===i&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,e);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var i=!1,n=void 0;try{this.work(t)}catch(t){i=!0,n=!!t&&t||new Error(t)}if(i)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,i=e.actions,n=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&i.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,i){return t.call(this)||this}return r(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(d)),B=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return r(e,t),e.prototype.schedule=function(e,i){return void 0===i&&(i=0),i>0?t.prototype.schedule.call(this,e,i):(this.delay=i,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,i){return i>0||this.closed?t.prototype.execute.call(this,e,i):this._execute(e,i)},e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,i,n):e.flush(this)},e}(L),W=function(){function t(e,i){void 0===i&&(i=t.now),this.SchedulerAction=e,this.now=i}return t.prototype.schedule=function(t,e,i){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(i,e)},t.now=function(){return Date.now()},t}(),U=function(t){function e(i,n){void 0===n&&(n=W.now);var r=t.call(this,i,(function(){return e.delegate&&e.delegate!==r?e.delegate.now():n()}))||this;return r.actions=[],r.active=!1,r.scheduled=void 0,r}return r(e,t),e.prototype.schedule=function(i,n,r){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(i,n,r):t.prototype.schedule.call(this,i,n,r)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var i;this.active=!0;do{if(i=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,i){for(;t=e.shift();)t.unsubscribe();throw i}}},e}(W),Y=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(U))(B),N=new C((function(t){return t.complete()}));function z(t){return t?function(t){return new C((function(e){return t.schedule((function(){return e.complete()}))}))}(t):N}function X(t){return t&&"function"==typeof t.schedule}var V,H=function(t){return function(e){for(var i=0,n=t.length;i<n&&!e.closed;i++)e.next(t[i]);e.complete()}};function G(t,e){return new C((function(i){var n=new d,r=0;return n.add(e.schedule((function(){r!==t.length?(i.next(t[r++]),i.closed||n.add(this.schedule())):i.complete()}))),n}))}function $(t,e){return e?G(t,e):new C(H(t))}function q(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return X(i)?(t.pop(),G(t,i)):$(t)}function K(t,e){return new C(e?function(i){return e.schedule(J,0,{error:t,subscriber:i})}:function(e){return e.error(t)})}function J(t){var e=t.error;t.subscriber.error(e)}V||(V={});var Z=function(){function t(t,e,i){this.kind=t,this.value=e,this.error=i,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,i){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return i&&i()}},t.prototype.accept=function(t,e,i){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,i)},t.prototype.toObservable=function(){switch(this.kind){case"N":return q(this.value);case"E":return K(this.error);case"C":return z()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}();var Q=function(t){function e(e,i,n){void 0===n&&(n=0);var r=t.call(this,e)||this;return r.scheduler=i,r.delay=n,r}return r(e,t),e.dispatch=function(t){var e=t.notification,i=t.destination;e.observe(i),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new tt(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(Z.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(Z.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(Z.createComplete()),this.unsubscribe()},e}(v),tt=function(){return function(t,e){this.notification=t,this.destination=e}}(),et=function(t){function e(e,i,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===i&&(i=Number.POSITIVE_INFINITY);var r=t.call(this)||this;return r.scheduler=n,r._events=[],r._infiniteTimeWindow=!1,r._bufferSize=e<1?1:e,r._windowTime=i<1?1:i,i===Number.POSITIVE_INFINITY?(r._infiniteTimeWindow=!0,r.next=r.nextInfiniteTimeWindow):r.next=r.nextTimeWindow,r}return r(e,t),e.prototype.nextInfiniteTimeWindow=function(e){var i=this._events;i.push(e),i.length>this._bufferSize&&i.shift(),t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this._events.push(new it(this._getNow(),e)),this._trimBufferThenGetEvents(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,i=this._infiniteTimeWindow,n=i?this._events:this._trimBufferThenGetEvents(),r=this.scheduler,o=n.length;if(this.closed)throw new T;if(this.isStopped||this.hasError?e=d.EMPTY:(this.observers.push(t),e=new O(this,t)),r&&t.add(t=new Q(t,r)),i)for(var s=0;s<o&&!t.closed;s++)t.next(n[s]);else for(s=0;s<o&&!t.closed;s++)t.next(n[s].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||Y).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,i=this._windowTime,n=this._events,r=n.length,o=0;o<r&&!(t-n[o].time<i);)o++;return r>e&&(o=Math.max(o,r-e)),o>0&&n.splice(0,o),n},e}(P),it=function(){return function(t,e){this.time=t,this.value=e}}(),nt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.value=null,e.hasNext=!1,e.hasCompleted=!1,e}return r(e,t),e.prototype._subscribe=function(e){return this.hasError?(e.error(this.thrownError),d.EMPTY):this.hasCompleted&&this.hasNext?(e.next(this.value),e.complete(),d.EMPTY):t.prototype._subscribe.call(this,e)},e.prototype.next=function(t){this.hasCompleted||(this.value=t,this.hasNext=!0)},e.prototype.error=function(e){this.hasCompleted||t.prototype.error.call(this,e)},e.prototype.complete=function(){this.hasCompleted=!0,this.hasNext&&t.prototype.next.call(this,this.value),t.prototype.complete.call(this)},e}(P),rt=1,ot=function(){return Promise.resolve()}(),st={};function at(t){return t in st&&(delete st[t],!0)}var ct=function(t){var e=rt++;return st[e]=!0,ot.then((function(){return at(e)&&t()})),e},ut=function(t){at(t)},ht=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return r(e,t),e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,i,n):(e.actions.push(this),e.scheduled||(e.scheduled=ct(e.flush.bind(e,null))))},e.prototype.recycleAsyncId=function(e,i,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,i,n);0===e.actions.length&&(ut(i),e.scheduled=void 0)},e}(L),lt=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,i=this.actions,n=-1,r=i.length;t=t||i.shift();do{if(e=t.execute(t.state,t.delay))break}while(++n<r&&(t=i.shift()));if(this.active=!1,e){for(;++n<r&&(t=i.shift());)t.unsubscribe();throw e}},e}(U))(ht),ft=new U(L),dt=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return r(e,t),e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,i,n):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(null)}))))},e.prototype.recycleAsyncId=function(e,i,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,i,n);0===e.actions.length&&(cancelAnimationFrame(i),e.scheduled=void 0)},e}(L),pt=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,i=this.actions,n=-1,r=i.length;t=t||i.shift();do{if(e=t.execute(t.state,t.delay))break}while(++n<r&&(t=i.shift()));if(this.active=!1,e){for(;++n<r&&(t=i.shift());)t.unsubscribe();throw e}},e}(U))(dt),gt=function(t){function e(e,i){void 0===e&&(e=vt),void 0===i&&(i=Number.POSITIVE_INFINITY);var n=t.call(this,e,(function(){return n.frame}))||this;return n.maxFrames=i,n.frame=0,n.index=-1,n}return r(e,t),e.prototype.flush=function(){for(var t,e,i=this.actions,n=this.maxFrames;(e=i[0])&&e.delay<=n&&(i.shift(),this.frame=e.delay,!(t=e.execute(e.state,e.delay))););if(t){for(;e=i.shift();)e.unsubscribe();throw t}},e.frameTimeFactor=10,e}(U),vt=function(t){function e(e,i,n){void 0===n&&(n=e.index+=1);var r=t.call(this,e,i)||this;return r.scheduler=e,r.work=i,r.index=n,r.active=!0,r.index=e.index=n,r}return r(e,t),e.prototype.schedule=function(i,n){if(void 0===n&&(n=0),!this.id)return t.prototype.schedule.call(this,i,n);this.active=!1;var r=new e(this.scheduler,this.work);return this.add(r),r.schedule(i,n)},e.prototype.requestAsyncId=function(t,i,n){void 0===n&&(n=0),this.delay=t.frame+n;var r=t.actions;return r.push(this),r.sort(e.sortActions),!0},e.prototype.recycleAsyncId=function(t,e,i){void 0===i&&(i=0)},e.prototype._execute=function(e,i){if(!0===this.active)return t.prototype._execute.call(this,e,i)},e.sortActions=function(t,e){return t.delay===e.delay?t.index===e.index?0:t.index>e.index?1:-1:t.delay>e.delay?1:-1},e}(L);function yt(){}function mt(t){return!!t&&(t instanceof C||"function"==typeof t.lift&&"function"==typeof t.subscribe)}var bt=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),_t=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}(),xt=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}();function wt(t,e){return function(i){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new Ct(t,e))}}var Ct=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new St(t,this.project,this.thisArg))},t}(),St=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.project=i,r.count=0,r.thisArg=n||r,r}return r(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(v);function Tt(t,e,i){if(e){if(!X(e))return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return Tt(t,i).apply(void 0,n).pipe(wt((function(t){return h(t)?e.apply(void 0,t):e(t)})))};i=e}return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r,o=this,s={context:o,subject:r,callbackFunc:t,scheduler:i};return new C((function(n){if(i){var a={args:e,subscriber:n,params:s};return i.schedule(Ot,0,a)}if(!r){r=new nt;try{t.apply(o,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.next(t.length<=1?t[0]:t),r.complete()}]))}catch(t){m(r)?r.error(t):console.warn(t)}}return r.subscribe(n)}))}}function Ot(t){var e=this,i=t.args,n=t.subscriber,r=t.params,o=r.callbackFunc,s=r.context,a=r.scheduler,c=r.subject;if(!c){c=r.subject=new nt;try{o.apply(s,i.concat([function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.length<=1?t[0]:t;e.add(a.schedule(jt,0,{value:n,subject:c}))}]))}catch(t){c.error(t)}}this.add(c.subscribe(n))}function jt(t){var e=t.value,i=t.subject;i.next(e),i.complete()}function Pt(t,e,i){if(e){if(!X(e))return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return Pt(t,i).apply(void 0,n).pipe(wt((function(t){return h(t)?e.apply(void 0,t):e(t)})))};i=e}return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r={subject:void 0,args:e,callbackFunc:t,scheduler:i,context:this};return new C((function(n){var o=r.context,s=r.subject;if(i)return i.schedule(Et,0,{params:r,subscriber:n,context:o});if(!s){s=r.subject=new nt;try{t.apply(o,e.concat([function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t.shift();i?s.error(i):(s.next(t.length<=1?t[0]:t),s.complete())}]))}catch(t){m(s)?s.error(t):console.warn(t)}}return s.subscribe(n)}))}}function Et(t){var e=this,i=t.params,n=t.subscriber,r=t.context,o=i.callbackFunc,s=i.args,a=i.scheduler,c=i.subject;if(!c){c=i.subject=new nt;try{o.apply(r,s.concat([function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t.shift();if(n)e.add(a.schedule(At,0,{err:n,subject:c}));else{var r=t.length<=1?t[0]:t;e.add(a.schedule(kt,0,{value:r,subject:c}))}}]))}catch(t){this.add(a.schedule(At,0,{err:t,subject:c}))}}this.add(c.subscribe(n))}function kt(t){var e=t.value,i=t.subject;i.next(e),i.complete()}function At(t){var e=t.err;t.subject.error(e)}var Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(v),Mt=function(t){function e(e,i,n){var r=t.call(this)||this;return r.parent=e,r.outerValue=i,r.outerIndex=n,r.index=0,r}return r(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(v);function It(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var Ft=It(),Rt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function Lt(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var Bt=function(t){if(t&&"function"==typeof t[b])return n=t,function(t){var e=n[b]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(Rt(t))return H(t);if(Lt(t))return i=t,function(t){return i.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,c),t};if(t&&"function"==typeof t[Ft])return e=t,function(t){for(var i=e[Ft]();;){var n=i.next();if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof i.return&&t.add((function(){i.return&&i.return()})),t};var e,i,n,r=l(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+r+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};function Wt(t,e,i,n,r){if(void 0===r&&(r=new Mt(t,i,n)),!r.closed)return e instanceof C?e.subscribe(r):Bt(e)(r)}var Ut={};function Yt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=null,n=null;return X(t[t.length-1])&&(n=t.pop()),"function"==typeof t[t.length-1]&&(i=t.pop()),1===t.length&&h(t[0])&&(t=t[0]),$(t,n).lift(new Nt(i))}var Nt=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new zt(t,this.resultSelector))},t}(),zt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.resultSelector=i,n.active=0,n.values=[],n.observables=[],n}return r(e,t),e.prototype._next=function(t){this.values.push(Ut),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var i=0;i<e;i++){var n=t[i];this.add(Wt(this,n,n,i))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,i,n,r){var o=this.values,s=o[i],a=this.toRespond?s===Ut?--this.toRespond:this.toRespond:0;o[i]=e,0===a&&(this.resultSelector?this._tryResultSelector(o):this.destination.next(o.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(Dt);function Xt(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[b]}(t))return function(t,e){return new C((function(i){var n=new d;return n.add(e.schedule((function(){var r=t[b]();n.add(r.subscribe({next:function(t){n.add(e.schedule((function(){return i.next(t)})))},error:function(t){n.add(e.schedule((function(){return i.error(t)})))},complete:function(){n.add(e.schedule((function(){return i.complete()})))}}))}))),n}))}(t,e);if(Lt(t))return function(t,e){return new C((function(i){var n=new d;return n.add(e.schedule((function(){return t.then((function(t){n.add(e.schedule((function(){i.next(t),n.add(e.schedule((function(){return i.complete()})))})))}),(function(t){n.add(e.schedule((function(){return i.error(t)})))}))}))),n}))}(t,e);if(Rt(t))return G(t,e);if(function(t){return t&&"function"==typeof t[Ft]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new C((function(i){var n,r=new d;return r.add((function(){n&&"function"==typeof n.return&&n.return()})),r.add(e.schedule((function(){n=t[Ft](),r.add(e.schedule((function(){if(!i.closed){var t,e;try{var r=n.next();t=r.value,e=r.done}catch(t){return void i.error(t)}e?i.complete():(i.next(t),this.schedule())}})))}))),r}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}function Vt(t,e){return e?Xt(t,e):t instanceof C?t:new C(Bt(t))}var Ht=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new Gt(t,this.project,this.concurrent))},t}(),Gt=function(t){function e(e,i,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e)||this;return r.project=i,r.concurrent=n,r.hasCompleted=!1,r.buffer=[],r.active=0,r.index=0,r}return r(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e,t,i)},e.prototype._innerSub=function(t,e,i){var n=new Mt(this,e,i),r=this.destination;r.add(n);var o=Wt(this,t,void 0,void 0,n);o!==n&&r.add(o)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyComplete=function(t){var e=this.buffer;this.remove(t),this.active--,e.length>0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(Dt);function $t(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),function t(e,i,n){return void 0===n&&(n=Number.POSITIVE_INFINITY),"function"==typeof i?function(r){return r.pipe(t((function(t,n){return Vt(e(t,n)).pipe(wt((function(e,r){return i(t,e,n,r)})))}),n))}:("number"==typeof i&&(n=i),function(t){return t.lift(new Ht(e,n))})}(_,t)}function qt(){return $t(1)}function Kt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return qt()(q.apply(void 0,t))}function Jt(t){return new C((function(e){var i;try{i=t()}catch(t){return void e.error(t)}return(i?Vt(i):z()).subscribe(e)}))}function Zt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){var i=t[0];if(h(i))return Qt(i,null);if(l(i)&&Object.getPrototypeOf(i)===Object.prototype){var n=Object.keys(i);return Qt(n.map((function(t){return i[t]})),n)}}if("function"==typeof t[t.length-1]){var r=t.pop();return Qt(t=1===t.length&&h(t[0])?t[0]:t,null).pipe(wt((function(t){return r.apply(void 0,t)})))}return Qt(t,null)}function Qt(t,e){return new C((function(i){var n=t.length;if(0!==n)for(var r=new Array(n),o=0,s=0,a=function(a){var c=Vt(t[a]),u=!1;i.add(c.subscribe({next:function(t){u||(u=!0,s++),r[a]=t},error:function(t){return i.error(t)},complete:function(){++o!==n&&u||(s===n&&i.next(e?e.reduce((function(t,e,i){return t[e]=r[i],t}),{}):r),i.complete())}}))},c=0;c<n;c++)a(c);else i.complete()}))}function te(t,e,i,n){return o(i)&&(n=i,i=void 0),n?te(t,e,i).pipe(wt((function(t){return h(t)?n.apply(void 0,t):n(t)}))):new C((function(n){!function t(e,i,n,r,o){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(e)){var a=e;e.addEventListener(i,n,o),s=function(){return a.removeEventListener(i,n,o)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(e)){var c=e;e.on(i,n),s=function(){return c.off(i,n)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(e)){var u=e;e.addListener(i,n),s=function(){return u.removeListener(i,n)}}else{if(!e||!e.length)throw new TypeError("Invalid event target");for(var h=0,l=e.length;h<l;h++)t(e[h],i,n,r,o)}r.add(s)}(t,e,(function(t){arguments.length>1?n.next(Array.prototype.slice.call(arguments)):n.next(t)}),n,i)}))}function ee(t,e,i){return i?ee(t,e).pipe(wt((function(t){return h(t)?i.apply(void 0,t):i(t)}))):new C((function(i){var n,r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.next(1===t.length?t[0]:t)};try{n=t(r)}catch(t){return void i.error(t)}if(o(e))return function(){return e(r,n)}}))}function ie(t,e,i,n,r){var o,s;if(1==arguments.length){var a=t;s=a.initialState,e=a.condition,i=a.iterate,o=a.resultSelector||_,r=a.scheduler}else void 0===n||X(n)?(s=t,o=_,r=n):(s=t,o=n);return new C((function(t){var n=s;if(r)return r.schedule(ne,0,{subscriber:t,iterate:i,condition:e,resultSelector:o,state:n});for(;;){if(e){var a=void 0;try{a=e(n)}catch(e){return void t.error(e)}if(!a){t.complete();break}}var c=void 0;try{c=o(n)}catch(e){return void t.error(e)}if(t.next(c),t.closed)break;try{n=i(n)}catch(e){return void t.error(e)}}}))}function ne(t){var e=t.subscriber,i=t.condition;if(!e.closed){if(t.needIterate)try{t.state=t.iterate(t.state)}catch(t){return void e.error(t)}else t.needIterate=!0;if(i){var n=void 0;try{n=i(t.state)}catch(t){return void e.error(t)}if(!n)return void e.complete();if(e.closed)return}var r;try{r=t.resultSelector(t.state)}catch(t){return void e.error(t)}if(!e.closed&&(e.next(r),!e.closed))return this.schedule(t)}}function re(t,e,i){return void 0===e&&(e=N),void 0===i&&(i=N),Jt((function(){return t()?e:i}))}function oe(t){return!h(t)&&t-parseFloat(t)+1>=0}function se(t,e){return void 0===t&&(t=0),void 0===e&&(e=ft),(!oe(t)||t<0)&&(t=0),e&&"function"==typeof e.schedule||(e=ft),new C((function(i){return i.add(e.schedule(ae,t,{subscriber:i,counter:0,period:t})),i}))}function ae(t){var e=t.subscriber,i=t.counter,n=t.period;e.next(i),this.schedule({subscriber:e,counter:i+1,period:n},n)}function ce(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=Number.POSITIVE_INFINITY,n=null,r=t[t.length-1];return X(r)?(n=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(i=t.pop())):"number"==typeof r&&(i=t.pop()),null===n&&1===t.length&&t[0]instanceof C?t[0]:$t(i)($(t,n))}var ue=new C(yt);function he(){return ue}function le(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return N;var i=t[0],n=t.slice(1);return 1===t.length&&h(i)?le.apply(void 0,i):new C((function(t){var e=function(){return t.add(le.apply(void 0,n).subscribe(t))};return Vt(i).subscribe({next:function(e){t.next(e)},error:e,complete:e})}))}function fe(t,e){return new C(e?function(i){var n=Object.keys(t),r=new d;return r.add(e.schedule(de,0,{keys:n,index:0,subscriber:i,subscription:r,obj:t})),r}:function(e){for(var i=Object.keys(t),n=0;n<i.length&&!e.closed;n++){var r=i[n];t.hasOwnProperty(r)&&e.next([r,t[r]])}e.complete()})}function de(t){var e=t.keys,i=t.index,n=t.subscriber,r=t.subscription,o=t.obj;if(!n.closed)if(i<e.length){var s=e[i];n.next([s,o[s]]),r.add(this.schedule({keys:e,index:i+1,subscriber:n,subscription:r,obj:o}))}else n.complete()}function pe(t,e){function i(){return!i.pred.apply(i.thisArg,arguments)}return i.pred=t,i.thisArg=e,i}function ge(t,e){return function(i){return i.lift(new ve(t,e))}}var ve=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new ye(t,this.predicate,this.thisArg))},t}(),ye=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.thisArg=n,r.count=0,r}return r(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(v);function me(t,e,i){return[ge(e,i)(new C(Bt(t))),ge(pe(e,i))(new C(Bt(t)))]}function be(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(1===t.length){if(!h(t[0]))return t[0];t=t[0]}return $(t,void 0).lift(new _e)}var _e=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new xe(t))},t}(),xe=function(t){function e(e){var i=t.call(this,e)||this;return i.hasFirst=!1,i.observables=[],i.subscriptions=[],i}return r(e,t),e.prototype._next=function(t){this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{for(var i=0;i<e&&!this.hasFirst;i++){var n=t[i],r=Wt(this,n,n,i);this.subscriptions&&this.subscriptions.push(r),this.add(r)}this.observables=null}},e.prototype.notifyNext=function(t,e,i,n,r){if(!this.hasFirst){this.hasFirst=!0;for(var o=0;o<this.subscriptions.length;o++)if(o!==i){var s=this.subscriptions[o];s.unsubscribe(),this.remove(s)}this.subscriptions=null}this.destination.next(e)},e}(Dt);function we(t,e,i){return void 0===t&&(t=0),new C((function(n){void 0===e&&(e=t,t=0);var r=0,o=t;if(i)return i.schedule(Ce,0,{index:r,count:e,start:t,subscriber:n});for(;;){if(r++>=e){n.complete();break}if(n.next(o++),n.closed)break}}))}function Ce(t){var e=t.start,i=t.index,n=t.count,r=t.subscriber;i>=n?r.complete():(r.next(e),r.closed||(t.index=i+1,t.start=e+1,this.schedule(t)))}function Se(t,e,i){void 0===t&&(t=0);var n=-1;return oe(e)?n=Number(e)<1?1:Number(e):X(e)&&(i=e),X(i)||(i=ft),new C((function(e){var r=oe(t)?t:+t-i.now();return i.schedule(Te,r,{index:0,period:n,subscriber:e})}))}function Te(t){var e=t.index,i=t.period,n=t.subscriber;if(n.next(e),!n.closed){if(-1===i)return n.complete();t.index=e+1,this.schedule(t,i)}}function Oe(t,e){return new C((function(i){var n,r;try{n=t()}catch(t){return void i.error(t)}try{r=e(n)}catch(t){return void i.error(t)}var o=(r?Vt(r):N).subscribe(i);return function(){o.unsubscribe(),n&&n.unsubscribe()}}))}function je(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return"function"==typeof i&&t.pop(),$(t,void 0).lift(new Pe(i))}var Pe=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new Ee(t,this.resultSelector))},t}(),Ee=function(t){function e(e,i,n){void 0===n&&(n=Object.create(null));var r=t.call(this,e)||this;return r.iterators=[],r.active=0,r.resultSelector="function"==typeof i?i:null,r.values=n,r}return r(e,t),e.prototype._next=function(t){var e=this.iterators;h(t)?e.push(new Ae(t)):"function"==typeof t[Ft]?e.push(new ke(t[Ft]())):e.push(new De(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var i=0;i<e;i++){var n=t[i];if(n.stillUnsubscribed)this.destination.add(n.subscribe(n,i));else this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,i=this.destination,n=0;n<e;n++){if("function"==typeof(s=t[n]).hasValue&&!s.hasValue())return}var r=!1,o=[];for(n=0;n<e;n++){var s,a=(s=t[n]).next();if(s.hasCompleted()&&(r=!0),a.done)return void i.complete();o.push(a.value)}this.resultSelector?this._tryresultSelector(o):i.next(o),r&&i.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(v),ke=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return t&&t.done},t}(),Ae=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[Ft]=function(){return this},t.prototype.next=function(t){var e=this.index++,i=this.array;return e<this.length?{value:i[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),De=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.parent=i,r.observable=n,r.stillUnsubscribed=!0,r.buffer=[],r.isComplete=!1,r}return r(e,t),e.prototype[Ft]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t,e,i,n,r){this.buffer.push(e),this.parent.checkIterators()},e.prototype.subscribe=function(t,e){return Wt(this,this.observable,this,e)},e}(Dt)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LayoutManager=void 0,function(t){t.LEGACY="LEGACY",t.STANDARD="STANDARD",t.ADVANCED="ADVANCED"}(e.LayoutManager||(e.LayoutManager={}))}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AbstractLayoutManager=void 0;var i=function(){function t(t){this.isEnforcedPositioning=!1,this.enterTextEditImmediatelyOnSelect=!1,this.canvas=t}return t.prototype.getCanvas=function(){return this.canvas},t.prototype.onInit=function(){},t.prototype.onProfileChange=function(t){},t.prototype.onCanvasDimensionsChange=function(){},t.prototype.onTextChange=function(){},t.prototype.onObjectListChange=function(){},t.prototype.onMarginChange=function(){},t}();e.AbstractLayoutManager=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.oc=function t(e){return new Proxy((function(t){return null==e?t:e}),{get:function(e,i){var n=e();return t("object"==typeof n?n[i]:void 0)}})}},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PixelCanvasDimensions=void 0;var i=function(){function t(t,e){this.widthUnit="px",this.heightUnit="px",this.width=t,this.widthPx=t,this.height=e,this.heightPx=e}return t.prototype.withSize=function(e,i){return new t(e,i)},t.prototype.widthPxToMm=function(t){},t.prototype.heightPxToMm=function(t){},t}();e.PixelCanvasDimensions=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){var n,r;n=[i,e,i(1),i(10)],void 0===(r=function(t,e,i,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FontLibrary=e.UNKNOWN_FONT=void 0,e.UNKNOWN_FONT=new n.UnknownFont;var r=function(){function t(){this._fonts={}}return t.prototype.registerFont=function(t){this._fonts[t.family]=t},t.prototype.getFonts=function(){return i.values(this._fonts)},t.prototype.getFont=function(t){return this._fonts[t]||e.UNKNOWN_FONT},t}();e.FontLibrary=r}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(11)],void 0===(r=function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UnknownFont=void 0;var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.family="_Unknown_",e.normalWeight=400,e.boldWeight=700,e}return s(e,t),e}(i.Font);e.UnknownFont=n}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Font=void 0;var i=function(){function t(){}return t.prototype.isBold=function(t){return t===this.boldWeight},t}();e.Font=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(5),i(13),i(14),i(15),i(34),i(35),i(4)],void 0===(r=function(t,e,i,n,r,o,a,c,u){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AdvancedLayoutManager=void 0;var h=function(t){function e(e){var i=t.call(this,e)||this;return i.key=u.LayoutManager.ADVANCED,i.pinToBottom=new a.PinToBottomLayoutFunction,i.redrawAll=new n.RedrawAllLayoutFunction,i.repositionBorders=new o.RepositionBordersLayoutFunction,i.repositionCutoffs=new r.RepositionCutoffsLayoutFunction,i.resizeCanvas=new c.ResizeCanvasLayoutFunction,i}return s(e,t),e.prototype.onCanvasDimensionsChange=function(){this.pinToBottom.execute(this.canvas),this.repositionCutoffs.execute(this.canvas),this.repositionBorders.execute(this.canvas),this.redrawAll.execute(this.canvas)},e.prototype.onTextChange=function(){this.resizeCanvas.execute(this.canvas)},e.prototype.onObjectListChange=function(){this.redrawAll.execute(this.canvas)},e}(i.AbstractLayoutManager);e.AdvancedLayoutManager=h}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RedrawAllLayoutFunction=void 0;var i=function(){function t(){}return t.prototype.execute=function(t){t.getObjectsInternal().forEach((function(t){return t.setCoords()})),t.redraw()},t}();e.RedrawAllLayoutFunction=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r;n=[i,e,i(0)],void 0===(r=function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RepositionCutoffsLayoutFunction=void 0;var n=function(){function t(){}return t.prototype.execute=function(t){t.getObjectsByTypeInternal(i.ObjectType.CUTOFF).forEach((function(t){return t.updatePosition()}))},t}();e.RepositionCutoffsLayoutFunction=n}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r;n=[i,e,i(0)],void 0===(r=function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RepositionBordersLayoutFunction=void 0;var n=function(){function t(){}return t.prototype.execute=function(t){t.getObjectsByTypeInternal(i.ObjectType.BORDER).forEach((function(t){return t.updatePosition()}))},t}();e.RepositionBordersLayoutFunction=n}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(5),i(37),i(38),i(15),i(13),i(14),i(4)],void 0===(r=function(t,e,i,n,r,o,a,c,u){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StandardLayoutManager=void 0;var h=function(t){function e(e){var i=t.call(this,e)||this;return i.key=u.LayoutManager.STANDARD,i.isEnforcedPositioning=!0,i.enterTextEditImmediatelyOnSelect=!0,i.redrawAll=new a.RedrawAllLayoutFunction,i.repositionCutoffs=new c.RepositionCutoffsLayoutFunction,i.repositionBorders=new o.RepositionBordersLayoutFunction,i.stackObjects=new r.StackObjectsLayoutFunction,i.updateObjectDimensions=new n.UpdateObjectDimensionsLayoutFunction,i}return s(e,t),e.prototype.onInit=function(){this.stackAndRedraw()},e.prototype.onProfileChange=function(t){this.canvas.setMultiSelect(!1),this.redrawAll.execute(this.canvas)},e.prototype.onTextChange=function(){this.stackAndRedraw()},e.prototype.onObjectListChange=function(){this.stackAndRedraw()},e.prototype.onMarginChange=function(){this.stackAndRedraw()},e.prototype.stackAndRedraw=function(){this.stackObjects.execute(this.canvas),this.repositionCutoffs.execute(this.canvas),this.repositionBorders.execute(this.canvas),this.updateObjectDimensions.execute(this.canvas),this.redrawAll.execute(this.canvas)},e}(i.AbstractLayoutManager);e.StandardLayoutManager=h}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CanvasObjectData=void 0;var i=function(t,e){this.id=e,this.type=t};e.CanvasObjectData=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(3),i(0),i(2)],void 0===(r=function(t,e,i,n,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Border=void 0;var o=function(t){function e(e,r,o){var s=t.call(this,n.ObjectType.BORDER,e,r,o)||this;return s.strokeWidth$=new i.BehaviorSubject(0),s.canvas=e,s.strokeWidth$.next(s.fabricObject.strokeWidth),s.updatePosition(),s}return s(e,t),e.prototype.getColor=function(){return this.fabricObject.stroke},e.prototype.setColor=function(t){this.fabricObject.set({stroke:t}),this.data.color=t,this.redraw()},e.prototype.getStrokeWidth=function(){return this.fabricObject.strokeWidth},e.prototype.getStrokeWidth$=function(){return this.strokeWidth$},e.prototype.setStrokeWidth=function(t){this.strokeWidth$.next(t),this.data.strokeWidth=t,this.updatePosition(),this.canvas.onMarginChange(),this.redraw()},e.prototype.updatePosition=function(){this.fabricObject.set({strokeWidth:this.strokeWidth$.value,top:0,left:0,width:this.canvas.getDimensions().widthPx-this.strokeWidth$.value,height:this.canvas.getDimensions().heightPx-this.strokeWidth$.value})},e.prototype.updateFabricObjectBehavior=function(){t.prototype.updateFabricObjectBehavior.call(this),this.fabricObject.set({lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockScalingFlip:!0}),this.fabricObject.setControlsVisibility({tl:!1,tr:!1,br:!1,bl:!1,ml:!1,mt:!1,mr:!1,mb:!1,mtr:!1}),this.redraw()},e}(r.AbstractCanvasObject);e.Border=o}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(3),i(0),i(2)],void 0===(r=function(t,e,i,n,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Cutoff=void 0;var o=function(t){function e(e,r,o){var s=t.call(this,n.ObjectType.CUTOFF,e,r,o)||this;return s.strokeWidth$=new i.BehaviorSubject(0),s.canvas=e,s.strokeWidth$.next(s.fabricObject.height),s.updatePosition(),s.fabricObject.set({strokeWidth:0}),s}return s(e,t),e.prototype.getColor=function(){return this.fabricObject.fill},e.prototype.setColor=function(t){this.fabricObject.set({fill:t,stroke:t}),this.data.color=t,this.redraw()},e.prototype.getStrokeWidth=function(){return this.fabricObject.height},e.prototype.getStrokeWidth$=function(){return this.strokeWidth$},e.prototype.setStrokeWidth=function(t){this.strokeWidth$.next(t),this.data.strokeWidth=t,this.updatePosition(),this.canvas.onMarginChange(),this.redraw()},e.prototype.updatePosition=function(){this.fabricObject.set({top:this.canvas.getDimensions().heightPx-this.strokeWidth$.value,left:0,width:this.canvas.getDimensions().widthPx,height:this.strokeWidth$.value})},e.prototype.updateFabricObjectBehavior=function(){this.fabricObject.set({lockMovementX:!0,lockMovementY:!0,lockScalingX:!0,lockScalingY:!0,lockScalingFlip:!0}),this.fabricObject.setControlsVisibility({tl:!1,tr:!1,br:!1,bl:!1,ml:!1,mt:!1,mr:!1,mb:!1,mtr:!1}),this.redraw()},e}(r.AbstractCanvasObject);e.Cutoff=o}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(3),i(0),i(2)],void 0===(r=function(t,e,i,n,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HorizontalRule=void 0;var o=function(t){function e(e,r,o){var s=t.call(this,n.ObjectType.HORIZONTAL_RULE,e,r,o)||this;return s.strokeWidth$=new i.BehaviorSubject(2),s.canvas=e,s.strokeWidth$.next(s.getDimensions().height.px),s.fabricObject.set({strokeWidth:0}),s}return s(e,t),e.prototype.getStrokeWidth=function(){return this.fabricObject.height},e.prototype.getStrokeWidth$=function(){return this.strokeWidth$},e.prototype.setStrokeWidth=function(t){this.strokeWidth$.next(t),this.data.strokeWidth=t,this.setPosition({height:t}),this.canvas.notifyObjectListChanged(),this.redraw()},e.prototype.getColor=function(){return this.fabricObject.fill},e.prototype.setColor=function(t){this.fabricObject.set({fill:t,stroke:t}),this.data.color=t,this.redraw()},e.prototype.centerHorizontally=function(){t.prototype.centerHorizontallyInternal.call(this)},e.prototype.centerVertically=function(){t.prototype.centerVerticallyInternal.call(this)},e.prototype.setHeight=function(t){this.setPosition({height:t}),this.canvas.notifyObjectListChanged()},e.prototype.nudgeUp=function(){t.prototype.nudgeInternal.call(this,0,-1)},e.prototype.nudgeDown=function(){t.prototype.nudgeInternal.call(this,0,1)},e.prototype.nudgeLeft=function(){t.prototype.nudgeInternal.call(this,-1,0)},e.prototype.nudgeRight=function(){t.prototype.nudgeInternal.call(this,1,0)},e}(r.AbstractCanvasObject);e.HorizontalRule=o}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(0),i(2),i(3)],void 0===(r=function(t,e,i,n,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Image=void 0;var o=function(t){function e(e,n,o){var s=t.call(this,i.ObjectType.IMAGE,e,n,o)||this;return s.DEFAULT_RESTRICTIONS={minWidth:1,minHeight:1},s.canvas=e,s.imageUrl$=new r.BehaviorSubject(s.fabricObject.getSrc()),s.data.imagePath=s.imageUrl$.value,s.layoutWidth=s.getBoundingBox().width,s}return s(e,t),e.prototype.getImageUrl=function(){return this.imageUrl$.value},e.prototype.getImageUrl$=function(){return this.imageUrl$},e.prototype.setImageUrl=function(t){this.setCanvasImage(t),this.data.imagePath=t,this.imageUrl$.next(t),this.canvas.notifyObjectListChanged()},e.prototype.setImageWidth=function(t,e){void 0===e&&(e=this.DEFAULT_RESTRICTIONS);var i=Math.max(e.minWidth,this.getMinWidthBasedOnMinHeight(e.minHeight)),n=Math.min(e.maxWidth,this.getMaxWidthBasedOnMaxHeight(e.maxHeight));t<i?t=i:t>n&&(t=n);var r=t/this.fabricObject.width;return this.fabricObject.set({scaleX:r,scaleY:r}),this.setCoords(),this.canvas.notifyObjectListChanged(),t},e.prototype.centerHorizontally=function(){t.prototype.centerHorizontallyInternal.call(this)},e.prototype.centerVertically=function(){t.prototype.centerVerticallyInternal.call(this)},e.prototype.setHeight=function(t){this.setPosition({height:t}),this.canvas.notifyObjectListChanged()},e.prototype.nudgeUp=function(){t.prototype.nudgeInternal.call(this,0,-1)},e.prototype.nudgeDown=function(){t.prototype.nudgeInternal.call(this,0,1)},e.prototype.nudgeLeft=function(){t.prototype.nudgeInternal.call(this,-1,0)},e.prototype.nudgeRight=function(){t.prototype.nudgeInternal.call(this,1,0)},e.prototype.setPosition=function(e){if(this.canvas.getLayoutManager().isEnforcedPositioning){if(null!=e.top&&this.fabricObject.set({top:e.top}),null!=e.width&&(this.layoutWidth=e.width),null!=e.height){var i=this.fabricObject.height,n=e.height/i;this.fabricObject.set({scaleX:n,scaleY:n}),this.setCoords()}null==e.left&&null==e.width&&null==e.height||this.centerHorizontallyInLayoutWidth(e.left||0)}else t.prototype.setPosition.call(this,e)},e.prototype.centerHorizontallyInLayoutWidth=function(t){var e=this.getBoundingBox().width;this.fabricObject.set({left:t+this.layoutWidth/2-e/2})},e.prototype.setCanvasImage=function(t){var e=this,i=this.canvas.getDimensions().widthPx/2;this.fabricObject.setSrc(t,(function(t){var n=1,r=n*t.width;r>i&&(n=i/r),t.set({scaleX:n,scaleY:n}),t.setCoords(),e.redraw()}),{crossOrigin:"anonymous"})},e.prototype.getMinWidthBasedOnMinHeight=function(t){if(!t)return 0;var e=t/this.fabricObject.height;return this.getBoundingBox().width*e},e.prototype.getMaxWidthBasedOnMaxHeight=function(t){if(!t)return 1/0;var e=t/this.fabricObject.height;return this.getBoundingBox().width*e},e}(n.AbstractCanvasObject);e.Image=o}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(0),i(2)],void 0===(r=function(t,e,i,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Rectangle=void 0;var r=function(t){function e(e,n,r){var o=t.call(this,i.ObjectType.RECTANGLE,e,n,r)||this;return o.canvas=e,o.fabricObject.set({strokeWidth:0}),o}return s(e,t),e.prototype.getColor=function(){return this.fabricObject.fill},e.prototype.setColor=function(t){this.fabricObject.set({fill:t,stroke:t}),this.data.color=t,this.redraw()},e.prototype.centerHorizontally=function(){t.prototype.centerHorizontallyInternal.call(this)},e.prototype.centerVertically=function(){t.prototype.centerVerticallyInternal.call(this)},e.prototype.setHeight=function(t){this.setPosition({height:t}),this.canvas.notifyObjectListChanged()},e.prototype.nudgeUp=function(){t.prototype.nudgeInternal.call(this,0,-1)},e.prototype.nudgeDown=function(){t.prototype.nudgeInternal.call(this,0,1)},e.prototype.nudgeLeft=function(){t.prototype.nudgeInternal.call(this,-1,0)},e.prototype.nudgeRight=function(){t.prototype.nudgeInternal.call(this,1,0)},e}(n.AbstractCanvasObject);e.Rectangle=r}.apply(e,n))||(t.exports=r)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(3),i(0),i(1),i(2),i(24)],void 0===(r=function(t,e,i,n,r,o,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Text=void 0;var c=function(t){function e(e,r,o){var s=t.call(this,n.ObjectType.TEXT,e,r,o)||this;return s.canvas=e,s.fontLibrary=e.getFontLibrary(),s.baseComponentHeight=s.fabricObject.height,s.text$=new i.BehaviorSubject(s.fabricObject.text),s.data.userText=s.fabricObject.text,s.textSelection$=new i.BehaviorSubject(new u(s.fabricObject,s.fontLibrary)),s.fabricObject.set({strokeWidth:0}),s.fabricObject.on("changed",(function(){return s.onTextChange()})),s.fabricObject.on("selection:changed",(function(){return s.onSelectionChange()})),s.applyBulletListMonkeyPatches(),s}return s(e,t),e.prototype.getText=function(){return this.text$.value},e.prototype.getText$=function(){return this.text$},e.prototype.setText=function(t){var e=this.fabricObject.getStyleAtPosition(0,!0);this.fabricObject.set({text:t}),this.data.userText=this.fabricObject.text,this.text$.next(t),this.fabricObject.setSelectionStyles(e,0,t.length),this.redraw()},e.prototype.replaceText=function(t,e){var i=this.getText().indexOf(t);this.fabricObject.insertChars(e,null,i,i+t.length),this.redraw(),this.data.userText=this.fabricObject.text,this.text$.next(this.fabricObject.text)},e.prototype.getColor=function(){return this.textSelection$.value.fill},e.prototype.setColor=function(t){this.hasTextSelection()?this.fabricObject.setSelectionStyles({fill:t}):this.fabricObject.set({fill:t}),this.data.color=t,this.updateTextSelection(),this.redraw()},e.prototype.getTextSelection=function(){return this.textSelection$.value},e.prototype.getTextSelection$=function(){return this.textSelection$},e.prototype.setTextAlign=function(t){this.fabricObject.set({textAlign:t}),this.redraw(),this.updateTextSelection()},e.prototype.setCharSpacing=function(t){this.fabricObject.set({charSpacing:t}),this.redraw(),this.updateTextSelection()},e.prototype.setLineHeight=function(t){this.fabricObject.set({lineHeight:t}),this.redraw(),this.updateTextSelection()},e.prototype.setBold=function(t){if(void 0===t&&(t=!0),this.hasTextSelection())for(var e=this.textSelection$.value.start,i=0;i<this.textSelection$.value.length;i++){var n=this.fabricObject.getStyleAtPosition(e+i,!0),r=this.fontLibrary.getFont(n.fontFamily),o=t?r.boldWeight:r.normalWeight;this.fabricObject.setSelectionStyles({fontWeight:o},e+i,e+i+1)}else{r=this.fontLibrary.getFont(this.fabricObject.fontFamily),o=t?r.boldWeight:r.normalWeight;this.fabricObject.set({fontWeight:o})}this.redraw(),this.updateTextSelection()},e.prototype.setItalic=function(t){void 0===t&&(t=!0),this.hasTextSelection()?this.fabricObject.setSelectionStyles({fontStyle:t?"italic":""}):this.fabricObject.set({fontStyle:t?"italic":""}),this.redraw(),this.updateTextSelection()},e.prototype.setStrikethrough=function(t){void 0===t&&(t=!0),this.hasTextSelection()?this.fabricObject.setSelectionStyles({linethrough:t}):this.fabricObject.set({linethrough:t}),this.redraw(),this.updateTextSelection()},e.prototype.setUnderline=function(t){void 0===t&&(t=!0),this.fabricObject.setSelectionStyles({underline:t}),this.redraw(),this.updateTextSelection()},e.prototype.setFont=function(t){this.hasTextSelection()?this.fabricObject.setSelectionStyles({fontFamily:t.family,fontWeight:t.normalWeight}):this.fabricObject.set({fontFamily:t.family,fontWeight:t.normalWeight}),this.redraw(),this.updateTextSelection()},e.prototype.setFontSize=function(t){this.hasTextSelection()?this.fabricObject.setSelectionStyles({fontSize:t}):this.fabricObject.set({fontSize:t}),this.redraw(),this.updateTextSelection()},e.prototype.setTextBackgroundColor=function(t){this.hasTextSelection()?this.fabricObject.setSelectionStyles({textBackgroundColor:t}):this.fabricObject.set({textBackgroundColor:t}),this.redraw(),this.updateTextSelection()},e.prototype.centerHorizontally=function(){t.prototype.centerHorizontallyInternal.call(this)},e.prototype.centerVertically=function(){t.prototype.centerVerticallyInternal.call(this)},e.prototype.setHeight=function(t){},e.prototype.nudgeUp=function(){t.prototype.nudgeInternal.call(this,0,-1)},e.prototype.nudgeDown=function(){t.prototype.nudgeInternal.call(this,0,1)},e.prototype.nudgeLeft=function(){t.prototype.nudgeInternal.call(this,-1,0)},e.prototype.nudgeRight=function(){t.prototype.nudgeInternal.call(this,1,0)},e.prototype.getBackgroundColor=function(){return this.fabricObject.backgroundColor},e.prototype.setBackgroundColor=function(t){this.fabricObject.set({backgroundColor:t}),this.redraw()},e.prototype.setPrefillType=function(t){this.data.prefillType=t},e.prototype.getPrefillType=function(){return this.data.prefillType},e.prototype.isResizeCanvas=function(){return this.data.resizeCanvas},e.prototype.setResizeCanvas=function(t){this.baseComponentHeight=this.fabricObject.height,this.data.resizeCanvas=t},e.prototype.focus=function(){this.fabricObject.hiddenTextarea.focus()},e.prototype.isEditing=function(){return this.fabricObject.isEditing},e.prototype.enterEditing=function(){this.isEditing()||(this.fabricObject.enterEditing(),this.focus(),this.selectAllText(),this.redraw())},e.prototype.selectAllText=function(){this.fabricObject.selectAll()},e.prototype.isBulleted=function(){return this.data.bulleted||!1},e.prototype.enableBullets=function(){this.fabricObject.objectCaching=!1,this.fabricObject._bullets=this.fabricObject._bullets||{},this.data.bulleted=!0,this.notifyCanvasOfTextChanges(),this.redraw()},e.prototype.disableBullets=function(){this.removeBullets(),this.data.bulleted=!1,this.notifyCanvasOfTextChanges(),this.redraw()},e.prototype.getSizeIncreaseSinceCreation=function(){return Math.max(0,this.fabricObject.height-this.baseComponentHeight)},e.prototype.removeBullets=function(){var t=this;if(this.data.bulleted){var e=this.fabricObject._bullets;delete this.fabricObject._bullets,r.each(e,(function(e){return t.canvas.removeFabricObject(e)})),this.fabricObject.objectCaching=!0}},e.prototype.applyBulletListMonkeyPatches=function(){this.data.bulleted&&this.enableBullets();var t=this.fabricObject._render;this.fabricObject._render=function(e){var i=this;if(i._bullets){var n=i._bullets,o={};r.each(i._textLines,(function(t,e){if(t.length&&0===i._styleMap[e].offset)if(n[e])o[e]=n[e];else{var r={left:0,top:0,radius:2,fill:i.fill,scaleX:i.scaleX,scaleY:i.scaleY,strokeWidth:0,lockMovementX:!0,lockMovementY:!0,hasControls:!1,selectable:!1,excludeFromJson:!0};o[e]=new a.fabric.Circle(r)}}));var s=i.canvas,c=!1;s.renderOnAddRemove=!1,r.each(o,(function(t){s.contains(t)||(s.add(t),c=!0)})),r.each(n,(function(t,e){o[e]||(s.remove(t),c=!0)})),s.renderOnAddRemove=!0,i._bullets=o,c&&setTimeout(s.renderAll.bind(s))}t.apply(i,[e])};var e=this.fabricObject._renderTextLine;this.fabricObject._renderTextLine=function(t,i,n,r,o,s){var a=this._bullets;if(a&&a[s]){var c=a[s],u=this.left+(r-this._getLeftOffset()-10)*this.scaleX;c.left!==u&&c.set({left:u});var h=this.top+this.height/2+o-(this.getValueOfPropertyAt(s,0,"fontSize")+6)/2;c.top!==h&&c.set({top:h}),c.fill!==this.fill&&c.set({fill:this.fill})}e.apply(this,[t,i,n,r,o,s])}},e.prototype.updateFabricObjectBehavior=function(){t.prototype.updateFabricObjectBehavior.call(this);var e=this.canvas.getProfile(),i=!this.canvas.getLayoutManager().isEnforcedPositioning;this.fabricObject.set({lockScalingY:!0,lockScalingX:this.isPinToBottom(),lockScalingFlip:!0}),this.fabricObject.setControlsVisibility({tl:!1,tr:!1,br:!1,bl:!1,ml:i&&e.allowScale&&!this.isPinToBottom(),mt:!1,mr:i&&e.allowScale&&!this.isPinToBottom(),mb:!1}),this.redraw()},e.prototype.onTextChange=function(){this.data.userText=this.fabricObject.text,this.text$.next(this.fabricObject.text),this.getBoundingBox().width>this.canvas.getDimensions().widthPx&&(this.fabricObject.set({left:0,width:this.canvas.getDimensions().widthPx}),this.redraw())},e.prototype.onDelete=function(){this.removeBullets()},e.prototype.onSelectionChange=function(){this.updateTextSelection()},e.prototype.hasTextSelection=function(){return this.canvas.getSelection().isText&&this.textSelection$.value.length>0},e.prototype.updateTextSelection=function(){this.textSelection$.next(new u(this.fabricObject,this.fontLibrary)),this.notifyCanvasOfTextChanges()},e.prototype.notifyCanvasOfTextChanges=function(){this.canvas.onTextChange()},e}(o.AbstractCanvasObject);e.Text=c;var u=function(t,e){this.fabricObject=t,this.fontLibrary=e,this.start=this.fabricObject.selectionStart,this.end=this.fabricObject.selectionEnd,this.length=this.end-this.start;var i=this.fabricObject.get2DCursorLocation();this.lineIndex=i.lineIndex,this.charIndex=i.charIndex;var n=this.fabricObject.getCompleteStyleDeclaration(this.lineIndex,this.charIndex),r=this.length>0;this.font=r?this.fontLibrary.getFont(n.fontFamily):this.fontLibrary.getFont(this.fabricObject.fontFamily),this.fontSize=r?n.fontSize:this.fabricObject.fontSize,this.fontWeight=r?n.fontWeight:this.fabricObject.fontWeight,this.bold=this.font.isBold(this.fontWeight),this.italic=r?"italic"===n.fontStyle:"italic"===this.fabricObject.fontStyle,this.underline=r?n.underline:this.fabricObject.underline,this.strikethrough=r?n.linethrough:this.fabricObject.linethrough,this.overline=r?n.overline:this.fabricObject.overline,this.textBackgroundColor=r?n.textBackgroundColor:this.fabricObject.textBackgroundColor,this.textAlign=this.fabricObject.textAlign,this.charSpacing=this.fabricObject.charSpacing,this.lineHeight=this.fabricObject.lineHeight,this.fill=n.fill,this.stroke=n.stroke,this.strokeWidth=n.strokeWidth}}.apply(e,n))||(t.exports=r)},function(t,e,i){(function(t){
|
|
25
|
-
|
|
26
|
-
var n,r,o,s,a,c,u,h,l,f,d,p,g,v,y,m,b,_,x,w,C,S=S||{version:"3.6.3"};if(e.fabric=S,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?S.document=document:S.document=document.implementation.createHTMLDocument(""),S.window=window;else{var T=new(i(50).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;S.document=T.document,S.jsdomImplForWrapper=i(51).implForWrapper,S.nodeCanvas=i(52).Canvas,S.window=T,DOMParser=S.window.DOMParser}function O(t,e){var i=t.canvas,n=e.targetCanvas,r=n.getContext("2d");r.translate(0,n.height),r.scale(1,-1);var o=i.height-n.height;r.drawImage(i,0,o,n.width,n.height,0,0,n.width,n.height)}function j(t,e){var i=e.targetCanvas.getContext("2d"),n=e.destinationWidth,r=e.destinationHeight,o=n*r*4,s=new Uint8Array(this.imageBuffer,0,o),a=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,n,r,t.RGBA,t.UNSIGNED_BYTE,s);var c=new ImageData(a,n,r);i.putImageData(c,0,0)}S.isTouchSupported="ontouchstart"in S.window||"ontouchstart"in S.document||S.window&&S.window.navigator&&S.window.navigator.maxTouchPoints>0,S.isLikelyNode=void 0!==t&&"undefined"==typeof window,S.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],S.DPI=96,S.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",S.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,S.reNonWord=/[ \n\.,;!\?\-]/,S.fontPaths={},S.iMatrix=[1,0,0,1,0,0],S.svgNS="http://www.w3.org/2000/svg",S.perfLimitSizeTotal=2097152,S.maxCacheSideLimit=4096,S.minCacheSideLimit=256,S.charWidthsCache={},S.textureSize=2048,S.disableStyleCopyPaste=!1,S.enableGLFiltering=!0,S.devicePixelRatio=S.window.devicePixelRatio||S.window.webkitDevicePixelRatio||S.window.mozDevicePixelRatio||1,S.browserShadowBlurConstant=1,S.arcToSegmentsCache={},S.boundsOfCurveCache={},S.cachesBoundsOfCurve=!0,S.forceGLPutImageData=!1,S.initFilterBackend=function(){return S.enableGLFiltering&&S.isWebglSupported&&S.isWebglSupported(S.textureSize)?(console.log("max texture size: "+S.maxTextureSize),new S.WebglFilterBackend({tileSize:S.textureSize})):S.Canvas2dFilterBackend?new S.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=S),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:S.util.array.fill(i,!1)}}function e(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this}function i(e,i){if(!this.__eventListeners)return this;if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var n in e)t.call(this,n,e[n]);else t.call(this,e,i);return this}function n(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var n=0,r=i.length;n<r;n++)i[n]&&i[n].call(this,e||{});return this.__eventListeners[t]=i.filter((function(t){return!1!==t})),this}S.Observable={observe:e,stopObserving:i,fire:n,on:e,off:i,trigger:n}}(),S.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(t,e,i){var n=this._objects;return i?n[e]=t:n.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,n=0,r=arguments.length;n<r;n++)-1!==(t=e.indexOf(arguments[n]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[n]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),n=0,r=i.length;n<r;n++)t.call(e,i[n],n,i);return this},getObjects:function(t){return void 0===t?this._objects.concat():this._objects.filter((function(e){return e.type===t}))},item:function(t){return this._objects[t]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(t){return this._objects.indexOf(t)>-1},complexity:function(){return this._objects.reduce((function(t,e){return t+=e.complexity?e.complexity():0}),0)}},S.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof S.Gradient||this.set(e,new S.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof S.Pattern?i&&i():this.set(e,new S.Pattern(t,i))},_initClipping:function(t){if(t.clipTo&&"string"==typeof t.clipTo){var e=S.util.getFunctionBody(t.clipTo);void 0!==e&&(this.clipTo=new Function("ctx",e))}},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):"function"==typeof e&&"clipTo"!==t?this._set(t,e(this.get(t))):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},n=e,r=Math.sqrt,o=Math.atan2,s=Math.pow,a=Math.PI/180,c=Math.PI/2,S.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/c){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/c){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*a},radiansToDegrees:function(t){return t/a},rotatePoint:function(t,e,i){t.subtractEquals(e);var n=S.util.rotateVector(t,i);return new S.Point(n.x,n.y).addEquals(e)},rotateVector:function(t,e){var i=S.util.sin(e),n=S.util.cos(e);return{x:t.x*n-t.y*i,y:t.x*i+t.y*n}},transformPoint:function(t,e,i){return i?new S.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new S.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i<t.length;i++)t[i]=S.util.transformPoint(t[i],e);var n=[t[0].x,t[1].x,t[2].x,t[3].x],r=S.util.array.min(n),o=S.util.array.max(n)-r,s=[t[0].y,t[1].y,t[2].y,t[3].y],a=S.util.array.min(s);return{left:r,top:a,width:o,height:S.util.array.max(s)-a}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],n=S.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-n.x,i[5]=-n.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),n=parseFloat(t);switch(e||(e=S.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return n*S.DPI/25.4;case"cm":return n*S.DPI/2.54;case"in":return n*S.DPI;case"pt":return n*S.DPI/72;case"pc":return n*S.DPI/72*12;case"em":return n*e;default:return n}},falseFunction:function(){return!1},getKlass:function(t,e){return t=S.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),S.util.resolveNamespace(e)[t]},getSvgAttributes:function(t){var e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":e=e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":e=e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":e=e.concat(["offset","stop-color","stop-opacity"])}return e},resolveNamespace:function(t){if(!t)return S;var e,i=t.split("."),r=i.length,o=n||S.window;for(e=0;e<r;++e)o=o[i[e]];return o},loadImage:function(t,e,i,n){if(t){var r=S.util.createImage(),o=function(){e&&e.call(i,r),r=r.onload=r.onerror=null};r.onload=o,r.onerror=function(){S.log("Error loading "+r.src),e&&e.call(i,null,!0),r=r.onload=r.onerror=null},0!==t.indexOf("data")&&n&&(r.crossOrigin=n),"data:image/svg"===t.substring(0,14)&&(r.onload=null,S.util.loadImageInDom(r,o)),r.src=t}else e&&e.call(i,t)},loadImageInDom:function(t,e){var i=S.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),S.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,n){var r=[],o=0,s=(t=t||[]).length;function a(){++o===s&&e&&e(r.filter((function(t){return t})))}s?t.forEach((function(t,e){t&&t.type?S.util.getKlass(t.type,i).fromObject(t,(function(i,o){o||(r[e]=i),n&&n(t,i,o),a()})):a()})):e&&e(r)},enlivenPatterns:function(t,e){function i(){++r===o&&e&&e(n)}var n=[],r=0,o=(t=t||[]).length;o?t.forEach((function(t,e){t&&t.source?new S.Pattern(t,(function(t){n[e]=t,i()})):(n[e]=t,i())})):e&&e(n)},groupSVGElements:function(t,e,i){var n;return t&&1===t.length?t[0]:(e&&(e.width&&e.height?e.centerPoint={x:e.width/2,y:e.height/2}:(delete e.width,delete e.height)),n=new S.Group(t,e),void 0!==i&&(n.sourcePath=i),n)},populateWithProperties:function(t,e,i){if(i&&"[object Array]"===Object.prototype.toString.call(i))for(var n=0,r=i.length;n<r;n++)i[n]in t&&(e[i[n]]=t[i[n]])},drawDashedLine:function(t,e,i,n,s,a){var c=n-e,u=s-i,h=r(c*c+u*u),l=o(u,c),f=a.length,d=0,p=!0;for(t.save(),t.translate(e,i),t.moveTo(0,0),t.rotate(l),e=0;h>e;)(e+=a[d++%f])>h&&(e=h),t[p?"lineTo":"moveTo"](e,0),p=!p;t.restore()},createCanvasElement:function(){return S.document.createElement("canvas")},copyCanvasElement:function(t){var e=S.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return S.document.createElement("img")},clipContext:function(t,e){e.save(),e.beginPath(),t.clipTo(e),e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var e=o(t[1],t[0]),i=s(t[0],2)+s(t[1],2),n=r(i),c=(t[0]*t[3]-t[2]*t[1])/n,u=o(t[0]*t[2]+t[1]*t[3],i);return{angle:e/a,scaleX:n,scaleY:c,skewX:u/a,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return S.iMatrix.concat();var e=S.util.degreesToRadians(t.angle),i=S.util.cos(e),n=S.util.sin(e);return[i,n,-n,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,n=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],r=S.util.multiplyTransformMatrices,o=S.util.degreesToRadians;return t.skewX&&(n=r(n,[1,0,Math.tan(o(t.skewX)),1],!0)),t.skewY&&(n=r(n,[1,Math.tan(o(t.skewY)),0,1],!0)),n},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=S.util.multiplyTransformMatrices;return t.angle&&(e=i(e,S.util.calcRotateMatrix(t))),(t.scaleX||t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,S.util.calcDimensionsMatrix(t))),e},customTransformMatrix:function(t,e,i){return S.util.composeMatrix({scaleX:t,scaleY:e,skewX:i})},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,n){n>0&&(e>n?e-=n:e=0,i>n?i-=n:i=0);var r,o=!0,s=t.getImageData(e,i,2*n||1,2*n||1),a=s.data.length;for(r=3;r<a&&!1!=(o=s.data[r]<=0);r+=4);return s=null,o},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",n=t.split(" ");return n&&n.length&&("meet"!==(i=n.pop())&&"slice"!==i?(e=i,i="meet"):n.length&&(e=n.pop())),{meetOrSlice:i,alignX:"none"!==e?e.slice(1,4):"none",alignY:"none"!==e?e.slice(5,8):"none"}},clearFabricFontCache:function(t){(t=(t||"").toLowerCase())?S.charWidthsCache[t]&&delete S.charWidthsCache[t]:S.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),n=Math.floor(e/i);return{x:Math.floor(i),y:n}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))},findScaleToFit:function(t,e){return Math.min(e.width/t.width,e.height/t.height)},findScaleToCover:function(t,e){return Math.max(e.width/t.width,e.height/t.height)},matrixToSVG:function(t){return"matrix("+t.map((function(t){return S.util.toFixed(t,S.Object.NUM_FRACTION_DIGITS)})).join(" ")+")"}},function(){var t=Array.prototype.join;function e(e,r,o,s,a,c,u){var h=t.call(arguments);if(S.arcToSegmentsCache[h])return S.arcToSegmentsCache[h];var l=Math.PI,f=u*l/180,d=S.util.sin(f),p=S.util.cos(f),g=0,v=0,y=-p*e*.5-d*r*.5,m=-p*r*.5+d*e*.5,b=(o=Math.abs(o))*o,_=(s=Math.abs(s))*s,x=m*m,w=y*y,C=b*_-b*x-_*w,T=0;if(C<0){var O=Math.sqrt(1-C/(b*_));o*=O,s*=O}else T=(a===c?-1:1)*Math.sqrt(C/(b*x+_*w));var j=T*o*m/s,P=-T*s*y/o,E=p*j-d*P+.5*e,k=d*j+p*P+.5*r,A=n(1,0,(y-j)/o,(m-P)/s),D=n((y-j)/o,(m-P)/s,(-y-j)/o,(-m-P)/s);0===c&&D>0?D-=2*l:1===c&&D<0&&(D+=2*l);for(var M=Math.ceil(Math.abs(D/l*2)),I=[],F=D/M,R=8/3*Math.sin(F/4)*Math.sin(F/4)/Math.sin(F/2),L=A+F,B=0;B<M;B++)I[B]=i(A,L,p,d,o,s,E,k,R,g,v),g=I[B][4],v=I[B][5],A=L,L+=F;return S.arcToSegmentsCache[h]=I,I}function i(t,e,i,n,r,o,s,a,c,u,h){var l=S.util.cos(t),f=S.util.sin(t),d=S.util.cos(e),p=S.util.sin(e),g=i*r*d-n*o*p+s,v=n*r*d+i*o*p+a;return[u+c*(-i*r*f-n*o*l),h+c*(-n*r*f+i*o*l),g+c*(i*r*p+n*o*d),v+c*(n*r*p-i*o*d),g,v]}function n(t,e,i,n){var r=Math.atan2(e,t),o=Math.atan2(n,i);return o>=r?o-r:2*Math.PI-(r-o)}function r(e,i,n,r,o,s,a,c){var u;if(S.cachesBoundsOfCurve&&(u=t.call(arguments),S.boundsOfCurveCache[u]))return S.boundsOfCurveCache[u];var h,l,f,d,p,g,v,y,m=Math.sqrt,b=Math.min,_=Math.max,x=Math.abs,w=[],C=[[],[]];l=6*e-12*n+6*o,h=-3*e+9*n-9*o+3*a,f=3*n-3*e;for(var T=0;T<2;++T)if(T>0&&(l=6*i-12*r+6*s,h=-3*i+9*r-9*s+3*c,f=3*r-3*i),x(h)<1e-12){if(x(l)<1e-12)continue;0<(d=-f/l)&&d<1&&w.push(d)}else(v=l*l-4*f*h)<0||(0<(p=(-l+(y=m(v)))/(2*h))&&p<1&&w.push(p),0<(g=(-l-y)/(2*h))&&g<1&&w.push(g));for(var O,j,P,E=w.length,k=E;E--;)O=(P=1-(d=w[E]))*P*P*e+3*P*P*d*n+3*P*d*d*o+d*d*d*a,C[0][E]=O,j=P*P*P*i+3*P*P*d*r+3*P*d*d*s+d*d*d*c,C[1][E]=j;C[0][k]=e,C[1][k]=i,C[0][k+1]=a,C[1][k+1]=c;var A=[{x:b.apply(null,C[0]),y:b.apply(null,C[1])},{x:_.apply(null,C[0]),y:_.apply(null,C[1])}];return S.cachesBoundsOfCurve&&(S.boundsOfCurveCache[u]=A),A}S.util.drawArc=function(t,i,n,r){for(var o=r[0],s=r[1],a=r[2],c=r[3],u=r[4],h=[[],[],[],[]],l=e(r[5]-i,r[6]-n,o,s,c,u,a),f=0,d=l.length;f<d;f++)h[f][0]=l[f][0]+i,h[f][1]=l[f][1]+n,h[f][2]=l[f][2]+i,h[f][3]=l[f][3]+n,h[f][4]=l[f][4]+i,h[f][5]=l[f][5]+n,t.bezierCurveTo.apply(t,h[f])},S.util.getBoundsOfArc=function(t,i,n,o,s,a,c,u,h){for(var l,f=0,d=0,p=[],g=e(u-t,h-i,n,o,a,c,s),v=0,y=g.length;v<y;v++)l=r(f,d,g[v][0],g[v][1],g[v][2],g[v][3],g[v][4],g[v][5]),p.push({x:l[0].x+t,y:l[0].y+i}),p.push({x:l[1].x+t,y:l[1].y+i}),f=g[v][4],d=g[v][5];return p},S.util.getBoundsOfCurve=r}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var n=t.length-1,r=e?t[n][e]:t[n];if(e)for(;n--;)i(t[n][e],r)&&(r=t[n][e]);else for(;n--;)i(t[n],r)&&(r=t[n]);return r}}S.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var n=t.call(arguments,2),r=[],o=0,s=e.length;o<s;o++)r[o]=n.length?e[o][i].apply(e[o],n):e[o][i].call(e[o]);return r},min:function(t,i){return e(t,i,(function(t,e){return t<e}))},max:function(t,i){return e(t,i,(function(t,e){return t>=e}))}}}(),function(){function t(e,i,n){if(n)if(!S.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var r=0,o=i.length;r<o;r++)e[r]=t({},i[r],n)}else if(i&&"object"==typeof i)for(var s in i)"canvas"===s?e[s]=t({},i[s]):i.hasOwnProperty(s)&&(e[s]=t({},i[s],n));else e=i;else for(var s in i)e[s]=i[s];return e}S.util.object={extend:t,clone:function(e,i){return t({},e,i)}},S.util.object.extend(S.util,S.Observable)}(),function(){function t(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var n=t.charCodeAt(e+1);if(56320>n||n>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1}S.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")},graphemeSplit:function(e){var i,n=0,r=[];for(n=0;n<e.length;n++)!1!==(i=t(e,n))&&r.push(i);return r}}}(),function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),n=function(t,e,n){for(var r in e)r in t.prototype&&"function"==typeof t.prototype[r]&&(e[r]+"").indexOf("callSuper")>-1?t.prototype[r]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=n;var r=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return r}}(r):t.prototype[r]=e[r],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function r(){}function o(e){for(var i=null,n=this;n.constructor.superclass;){var r=n.constructor.superclass.prototype[e];if(n[e]!==r){i=r;break}n=n.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):console.log("tried to callSuper "+e+", method not found in prototype chain",this)}S.util.createClass=function(){var i=null,s=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof s[0]&&(i=s.shift()),a.superclass=i,a.subclasses=[],i&&(r.prototype=i.prototype,a.prototype=new r,i.subclasses.push(a));for(var c=0,u=s.length;c<u;c++)n(a,s[c],i);return a.prototype.initialize||(a.prototype.initialize=e),a.prototype.constructor=a,a.prototype.callSuper=o,a}}(),u=!!S.document.createElement("div").attachEvent,S.util.addListener=function(t,e,i,n){t&&t.addEventListener(e,i,!u&&n)},S.util.removeListener=function(t,e,i,n){t&&t.removeEventListener(e,i,!u&&n)},S.util.getPointer=function(t){var e=t.target,i=S.util.getScrollLeftTop(e),n=function(t){var e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return{x:n.clientX+i.left,y:n.clientY+i.top}},h=S.document.createElement("div"),l="string"==typeof h.style.opacity,f="string"==typeof h.style.filter,d=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,p=function(t){return t},l?p=function(t,e){return t.style.opacity=e,t}:f&&(p=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),d.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(d,e)):i.filter+=" alpha(opacity="+100*e+")",t}),S.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?p(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var n in e)"opacity"===n?p(t,e[n]):i["float"===n||"cssFloat"===n?void 0===i.styleFloat?"cssFloat":"styleFloat":n]=e[n];return t},function(){var t=Array.prototype.slice;var e,i,n,r,o=function(e){return t.call(e,0)};try{e=o(S.document.childNodes)instanceof Array}catch(t){}function s(t,e){var i=S.document.createElement(t);for(var n in e)"class"===n?i.className=e[n]:"for"===n?i.htmlFor=e[n]:i.setAttribute(n,e[n]);return i}function a(t){for(var e=0,i=0,n=S.document.documentElement,r=S.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===S.document?(e=r.scrollLeft||n.scrollLeft||0,i=r.scrollTop||n.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}e||(o=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),i=S.document.defaultView&&S.document.defaultView.getComputedStyle?function(t,e){var i=S.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},n=S.document.documentElement.style,r="userSelect"in n?"userSelect":"MozUserSelect"in n?"MozUserSelect":"WebkitUserSelect"in n?"WebkitUserSelect":"KhtmlUserSelect"in n?"KhtmlUserSelect":"",S.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=S.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},S.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},S.util.getScript=function(t,e){var i=S.document.getElementsByTagName("head")[0],n=S.document.createElement("script"),r=!0;n.onload=n.onreadystatechange=function(t){if(r){if("string"==typeof this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)return;r=!1,e(t||S.window.event),n=n.onload=n.onreadystatechange=null}},n.src=t,i.appendChild(n)},S.util.getById=function(t){return"string"==typeof t?S.document.getElementById(t):t},S.util.toArray=o,S.util.makeElement=s,S.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},S.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=s(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},S.util.getScrollLeftTop=a,S.util.getElementOffset=function(t){var e,n,r=t&&t.ownerDocument,o={left:0,top:0},s={left:0,top:0},c={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!r)return s;for(var u in c)s[c[u]]+=parseInt(i(t,u),10)||0;return e=r.documentElement,void 0!==t.getBoundingClientRect&&(o=t.getBoundingClientRect()),n=a(t),{left:o.left+n.left-(e.clientLeft||0)+s.left,top:o.top+n.top-(e.clientTop||0)+s.top}},S.util.getElementStyle=i,S.util.getNodeCanvas=function(t){var e=S.jsdomImplForWrapper(t);return e._canvas||e._image},S.util.cleanUpJsdomNode=function(t){if(S.isLikelyNode){var e=S.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}S.util.request=function(e,i){i||(i={});var n=i.method?i.method.toUpperCase():"GET",r=i.onComplete||function(){},o=new S.window.XMLHttpRequest,s=i.body||i.parameters;return o.onreadystatechange=function(){4===o.readyState&&(r(o),o.onreadystatechange=t)},"GET"===n&&(s=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),o.open(n,e,!0),"POST"!==n&&"PUT"!==n||o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(s),o}}(),S.log=console.log,S.warn=console.warn,function(){function t(){return!1}function e(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e}var i=S.window.requestAnimationFrame||S.window.webkitRequestAnimationFrame||S.window.mozRequestAnimationFrame||S.window.oRequestAnimationFrame||S.window.msRequestAnimationFrame||function(t){return S.window.setTimeout(t,1e3/60)},n=S.window.cancelAnimationFrame||S.window.clearTimeout;function r(){return i.apply(S.window,arguments)}S.util.animate=function(i){r((function(n){i||(i={});var o,s=n||+new Date,a=i.duration||500,c=s+a,u=i.onChange||t,h=i.abort||t,l=i.onComplete||t,f=i.easing||e,d="startValue"in i?i.startValue:0,p="endValue"in i?i.endValue:100,g=i.byValue||p-d;i.onStart&&i.onStart(),function t(e){var i=(o=e||+new Date)>c?a:o-s,n=i/a,v=f(i,d,g,a),y=Math.abs((v-d)/g);if(!h())return o>c?(u(p,1,1),void l(p,1,1)):(u(v,y,n),void r(t));l(p,1,1)}(s)}))},S.util.requestAnimFrame=r,S.util.cancelAnimFrame=function(){return n.apply(S.window,arguments)}}(),S.util.animateColor=function(t,e,i,n){var r=new S.Color(t).getSource(),o=new S.Color(e).getSource();n=n||{},S.util.animate(S.util.object.extend(n,{duration:i||500,startValue:r,endValue:o,byValue:o,easing:function(t,e,i,r){var o,s,a,c,u=n.colorEasing?n.colorEasing(t,r):1-Math.cos(t/r*(Math.PI/2));return o=e,s=i,a=u,c="rgba("+parseInt(o[0]+a*(s[0]-o[0]),10)+","+parseInt(o[1]+a*(s[1]-o[1]),10)+","+parseInt(o[2]+a*(s[2]-o[2]),10),c+=","+(o&&s?parseFloat(o[3]+a*(s[3]-o[3])):1),c+=")"}}))},function(){function t(t,e,i,n){return t<Math.abs(e)?(t=e,n=i/4):n=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:n}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,r){return i-n(r-t,0,i,r)+e}function n(t,e,i,n){return(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}S.util.ease={easeInQuad:function(t,e,i,n){return i*(t/=n)*t+e},easeOutQuad:function(t,e,i,n){return-i*(t/=n)*(t-2)+e},easeInOutQuad:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,n){return i*(t/=n)*t*t+e},easeOutCubic:function(t,e,i,n){return i*((t=t/n-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,n){return i*(t/=n)*t*t*t+e},easeOutQuart:function(t,e,i,n){return-i*((t=t/n-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,n){return i*(t/=n)*t*t*t*t+e},easeOutQuint:function(t,e,i,n){return i*((t=t/n-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,n){return(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,n){return-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,n){return i*Math.sin(t/n*(Math.PI/2))+e},easeInOutSine:function(t,e,i,n){return-i/2*(Math.cos(Math.PI*t/n)-1)+e},easeInExpo:function(t,e,i,n){return 0===t?e:i*Math.pow(2,10*(t/n-1))+e},easeOutExpo:function(t,e,i,n){return t===n?e+i:i*(1-Math.pow(2,-10*t/n))+e},easeInOutExpo:function(t,e,i,n){return 0===t?e:t===n?e+i:(t/=n/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,n){return-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOutCirc:function(t,e,i,n){return i*Math.sqrt(1-(t=t/n-1)*t)+e},easeInOutCirc:function(t,e,i,n){return(t/=n/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,n,r,o){var s=0;return 0===i?n:1===(i/=o)?n+r:(s||(s=.3*o),-e(t(r,r,s,1.70158),i,o)+n)},easeOutElastic:function(e,i,n,r){var o=0;if(0===e)return i;if(1===(e/=r))return i+n;o||(o=.3*r);var s=t(n,n,o,1.70158);return s.a*Math.pow(2,-10*e)*Math.sin((e*r-s.s)*(2*Math.PI)/s.p)+s.c+i},easeInOutElastic:function(i,n,r,o){var s=0;if(0===i)return n;if(2===(i/=o/2))return n+r;s||(s=o*(.3*1.5));var a=t(r,r,s,1.70158);return i<1?-.5*e(a,i,o)+n:a.a*Math.pow(2,-10*(i-=1))*Math.sin((i*o-a.s)*(2*Math.PI)/a.p)*.5+a.c+n},easeInBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*(t/=n)*t*((r+1)*t-r)+e},easeOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),i*((t=t/n-1)*t*((r+1)*t+r)+1)+e},easeInOutBack:function(t,e,i,n,r){return void 0===r&&(r=1.70158),(t/=n/2)<1?i/2*(t*t*((1+(r*=1.525))*t-r))+e:i/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInBounce:i,easeOutBounce:n,easeInOutBounce:function(t,e,r,o){return t<o/2?.5*i(2*t,0,r,o)+e:.5*n(2*t-o,0,r,o)+.5*r+e}}}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,o=e.util.parseUnit,s=e.util.multiplyTransformMatrices,a={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform"},c={stroke:"strokeOpacity",fill:"fillOpacity"};function u(t){return t in a?a[t]:t}function h(t,i,n,r){var a,c="[object Array]"===Object.prototype.toString.call(i);if("fill"!==t&&"stroke"!==t||"none"!==i)if("vector-effect"===t)i="non-scaling-stroke"===i;else if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)i=n&&n.transformMatrix?s(n.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,n&&!1===n.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),n&&void 0!==n.opacity&&(i*=n.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=o(i,r)/r*1e3;else if("paintFirst"===t){var u=i.indexOf("fill"),h=i.indexOf("stroke");i="fill";(u>-1&&h>-1&&h<u||-1===u&&h>-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t)return i;a=c?i.map(o):o(i,r)}else i="";return!c&&isNaN(a)?i:a}function l(t){return new RegExp("^("+t.join("|")+")\\b","i")}function f(t,e){var i,n,r,o,s=[];for(r=0,o=e.length;r<o;r++)i=e[r],n=t.getElementsByTagName(i),s=s.concat(Array.prototype.slice.call(n));return s}function d(t,e){var i,n=!0;return(i=p(t,e.pop()))&&e.length&&(n=function(t,e){var i,n=!0;for(;t.parentNode&&1===t.parentNode.nodeType&&e.length;)n&&(i=e.pop()),t=t.parentNode,n=p(t,i);return 0===e.length}(t,e)),i&&n&&0===e.length}function p(t,e){var i,n,r=t.nodeName,o=t.getAttribute("class"),s=t.getAttribute("id");if(i=new RegExp("^"+r,"i"),e=e.replace(i,""),s&&e.length&&(i=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),o&&e.length)for(n=(o=o.split(" ")).length;n--;)i=new RegExp("\\."+o[n]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function g(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var n,r,o,s=t.getElementsByTagName("*");for(r=0,o=s.length;r<o;r++)if(e===(n=s[r]).getAttribute("id"))return n}e.svgValidTagNamesRegEx=l(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=l(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=l(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=l(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,n){t[n]=Math.tan(e.util.degreesToRadians(i[0]))}var i=e.iMatrix,n=e.reNum,r="(?:\\s+,?\\s*|,\\s*)",o="(?:"+("(?:(matrix)\\s*\\(\\s*("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")"+r+"("+n+")\\s*\\))")+"|"+("(?:(translate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(scale)\\s*\\(\\s*("+n+")(?:"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(rotate)\\s*\\(\\s*("+n+")(?:"+r+"("+n+")"+r+"("+n+"))?\\s*\\))")+"|"+("(?:(skewX)\\s*\\(\\s*("+n+")\\s*\\))")+"|"+("(?:(skewY)\\s*\\(\\s*("+n+")\\s*\\))")+")",s=new RegExp("^\\s*(?:"+("(?:"+o+"(?:"+r+"*"+o+")*)")+"?)\\s*$"),a=new RegExp(o,"g");return function(n){var r=i.concat(),c=[];if(!n||n&&!s.test(n))return r;n.replace(a,(function(n){var s=new RegExp(o).exec(n).filter((function(t){return!!t})),a=s[1],u=s.slice(2).map(parseFloat);switch(a){case"translate":!function(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}(r,u);break;case"rotate":u[0]=e.util.degreesToRadians(u[0]),function(t,i){var n=e.util.cos(i[0]),r=e.util.sin(i[0]),o=0,s=0;3===i.length&&(o=i[1],s=i[2]),t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=o-(n*o-r*s),t[5]=s-(r*o+n*s)}(r,u);break;case"scale":!function(t,e){var i=e[0],n=2===e.length?e[1]:e[0];t[0]=i,t[3]=n}(r,u);break;case"skewX":t(r,u,2);break;case"skewY":t(r,u,1);break;case"matrix":r=u}c.push(r.concat()),r=i.concat()}));for(var u=c[0];c.length>1;)c.shift(),u=e.util.multiplyTransformMatrices(u,c[0]);return u}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){var i,n,r,s,a,c,u=t.getAttribute("viewBox"),h=1,l=1,f=t.getAttribute("width"),d=t.getAttribute("height"),p=t.getAttribute("x")||0,g=t.getAttribute("y")||0,y=t.getAttribute("preserveAspectRatio")||"",m=!u||!e.svgViewBoxElementsRegEx.test(t.nodeName)||!(u=u.match(v)),b=!f||!d||"100%"===f||"100%"===d,_=m&&b,x={},w="",C=0,S=0;if(x.width=0,x.height=0,x.toBeParsed=_,_)return x;if(m)return x.width=o(f),x.height=o(d),x;if(i=-parseFloat(u[1]),n=-parseFloat(u[2]),r=parseFloat(u[3]),s=parseFloat(u[4]),x.minX=i,x.minY=n,x.viewBoxWidth=r,x.viewBoxHeight=s,b?(x.width=r,x.height=s):(x.width=o(f),x.height=o(d),h=x.width/r,l=x.height/s),"none"!==(y=e.util.parsePreserveAspectRatioAttribute(y)).alignX&&("meet"===y.meetOrSlice&&(l=h=h>l?l:h),"slice"===y.meetOrSlice&&(l=h=h>l?h:l),C=x.width-r*h,S=x.height-s*h,"Mid"===y.alignX&&(C/=2),"Mid"===y.alignY&&(S/=2),"Min"===y.alignX&&(C=0),"Min"===y.alignY&&(S=0)),1===h&&1===l&&0===i&&0===n&&0===p&&0===g)return x;if((p||g)&&(w=" translate("+o(p)+" "+o(g)+") "),a=w+" matrix("+h+" 0 0 "+l+" "+(i*h+C)+" "+(n*l+S)+") ",x.viewboxTransform=e.parseTransformAttribute(a),"svg"===t.nodeName){for(c=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)c.appendChild(t.firstChild);t.appendChild(c)}else a=(c=t).getAttribute("transform")+a;return c.setAttribute("transform",a),x}function m(t,e){var i=g(t,e.getAttribute("xlink:href").substr(1));if(i&&i.getAttribute("xlink:href")&&m(t,i),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){i&&!e.hasAttribute(t)&&i.hasAttribute(t)&&e.setAttribute(t,i.getAttribute(t))})),!e.children.length)for(var n=i.cloneNode(!0);n.firstChild;)e.appendChild(n.firstChild);e.removeAttribute("xlink:href")}e.parseSVGDocument=function(t,i,r,o){if(t){!function(t){for(var i=f(t,["use","svg:use"]),n=0;i.length&&n<i.length;){var r,o,s,a,c=i[n],u=(c.getAttribute("xlink:href")||c.getAttribute("href")).substr(1),h=c.getAttribute("x")||0,l=c.getAttribute("y")||0,d=g(t,u).cloneNode(!0),p=(d.getAttribute("transform")||"")+" translate("+h+", "+l+")",v=i.length,m=e.svgNS;if(y(d),/^svg$/i.test(d.nodeName)){var b=d.ownerDocument.createElementNS(m,"g");for(o=0,a=(s=d.attributes).length;o<a;o++)r=s.item(o),b.setAttributeNS(m,r.nodeName,r.nodeValue);for(;d.firstChild;)b.appendChild(d.firstChild);d=b}for(o=0,a=(s=c.attributes).length;o<a;o++)"x"!==(r=s.item(o)).nodeName&&"y"!==r.nodeName&&"xlink:href"!==r.nodeName&&"href"!==r.nodeName&&("transform"===r.nodeName?p=r.nodeValue+" "+p:d.setAttribute(r.nodeName,r.nodeValue));d.setAttribute("transform",p),d.setAttribute("instantiated_by_use","1"),d.removeAttribute("id"),c.parentNode.replaceChild(d,c),i.length===v&&n++}}(t);var s,a,c=e.Object.__uid++,u=y(t),h=e.util.toArray(t.getElementsByTagName("*"));if(u.crossOrigin=o&&o.crossOrigin,u.svgUid=c,0===h.length&&e.isLikelyNode){var l=[];for(s=0,a=(h=t.selectNodes('//*[name(.)!="svg"]')).length;s<a;s++)l[s]=h[s];h=l}var d=h.filter((function(t){return y(t),e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))&&!function(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}(t,e.svgInvalidAncestorsRegEx)}));if(!d||d&&!d.length)i&&i([],{});else{var p={};h.filter((function(t){return"clipPath"===t.nodeName.replace("svg:","")})).forEach((function(t){var i=t.getAttribute("id");p[i]=e.util.toArray(t.getElementsByTagName("*")).filter((function(t){return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))}))})),e.gradientDefs[c]=e.getGradientDefs(t),e.cssRules[c]=e.getCSSRules(t),e.clipPaths[c]=p,e.parseElements(d,(function(t,n){i&&(i(t,u,n,h),delete e.gradientDefs[c],delete e.cssRules[c],delete e.clipPaths[c])}),n(u),r,o)}}};var b=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(b);if(i){var n=i[1],r=i[3],s=i[4],a=i[5],c=i[6];n&&(e.fontStyle=n),r&&(e.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),s&&(e.fontSize=o(s)),c&&(e.fontFamily=c),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i=f(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),n=0,r={};for(n=i.length;n--;)(e=i[n]).getAttribute("xlink:href")&&m(t,e),r[e.getAttribute("id")]=e;return r},parseAttributes:function(t,n,s){if(t){var a,l,f,p={};void 0===s&&(s=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(p=e.parseAttributes(t.parentNode,n,s));var g=n.reduce((function(e,i){return(a=t.getAttribute(i))&&(e[i]=a),e}),{}),v=i(function(t,i){var n={};for(var r in e.cssRules[i])if(d(t,r.split(" ")))for(var o in e.cssRules[i][r])n[o]=e.cssRules[i][r][o];return n}(t,s),e.parseStyleAttribute(t));g=i(g,v),v["clip-path"]&&t.setAttribute("clip-path",v["clip-path"]),l=f=p.fontSize||e.Text.DEFAULT_SVG_FONT_SIZE,g["font-size"]&&(g["font-size"]=l=o(g["font-size"],f));var y,m,b={};for(var _ in g)m=h(y=u(_),g[_],p,l),b[y]=m;b&&b.font&&e.parseFontDeclaration(b.font,b);var x=i(p,b);return e.svgValidParentsRegEx.test(t.nodeName)?x:function(t){for(var i in c)if(void 0!==t[c[i]]&&""!==t[i]){if(void 0===t[i]){if(!e.Object.prototype[i])continue;t[i]=e.Object.prototype[i]}if(0!==t[i].indexOf("url(")){var n=new e.Color(t[i]);t[i]=n.setAlpha(r(n.getAlpha()*t[c[i]],2)).toRgba()}}return t}(x)}},parseElements:function(t,i,n,r,o){new e.ElementsParser(t,i,n,r,o).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){var i,n;t.replace(/;\s*$/,"").split(";").forEach((function(t){var r=t.split(":");i=r[0].trim().toLowerCase(),n=r[1].trim(),e[i]=n}))}(i,e):function(t,e){var i,n;for(var r in t)void 0!==t[r]&&(i=r.toLowerCase(),n=t[r],e[i]=n)}(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;var e,i,n=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)n.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return n},getCSSRules:function(t){var i,n,r=t.getElementsByTagName("style"),o={};for(i=0,n=r.length;i<n;i++){var s=r[i].textContent||"";""!==(s=s.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&s.match(/[^{]*\{[\s\S]*?\}/g).map((function(t){return t.trim()})).forEach((function(t){var r=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),s={},a=r[2].trim().replace(/;$/,"").split(/\s*;\s*/);for(i=0,n=a.length;i<n;i++){var c=a[i].split(/\s*:\s*/),u=c[0],h=c[1];s[u]=h}(t=r[1]).split(",").forEach((function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(o[t]?e.util.object.extend(o[t],s):o[t]=e.util.object.clone(s))}))}))}return o},loadSVGFromURL:function(t,i,n,r){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var o=t.responseXML;o&&!o.documentElement&&e.window.ActiveXObject&&t.responseText&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));if(!o||!o.documentElement)return i&&i(null),!1;e.parseSVGDocument(o.documentElement,(function(t,e,n,r){i&&i(t,e,n,r)}),n,r)}})},loadSVGFromString:function(t,i,n,r){var o;if(t=t.trim(),void 0!==e.window.DOMParser){var s=new e.window.DOMParser;s&&s.parseFromString&&(o=s.parseFromString(t,"text/xml"))}else e.window.ActiveXObject&&((o=new ActiveXObject("Microsoft.XMLDOM")).async="false",o.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,"")));e.parseSVGDocument(o.documentElement,(function(t,e,n,r){i(t,e,n,r)}),n,r)}})}(e),S.ElementsParser=function(t,e,i,n,r,o){this.elements=t,this.callback=e,this.options=i,this.reviver=n,this.svgUid=i&&i.svgUid||0,this.parsingOptions=r,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=o},(g=S.ElementsParser.prototype).parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},g.createObjects=function(){var t=this;this.elements.forEach((function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)}))},g.findTag=function(t){return S[S.util.string.capitalize(t.tagName.replace("svg:",""))]},g.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){S.log(t)}else this.checkIfDone()},g.createCallback=function(t,e){var i=this;return function(n){var r;i.resolveGradient(n,e,"fill"),i.resolveGradient(n,e,"stroke"),n instanceof S.Image&&n._originalElement&&(r=n.parsePreserveAspectRatioAttribute(e)),n._removeTransformMatrix(r),i.resolveClipPath(n,e),i.reviver&&i.reviver(e,n),i.instances[t]=n,i.checkIfDone()}},g.extractPropertyDefinition=function(t,e,i){var n=t[e],r=this.regexUrl;if(r.test(n)){r.lastIndex=0;var o=r.exec(n)[1];return r.lastIndex=0,S[i][this.svgUid][o]}},g.resolveGradient=function(t,e,i){var n=this.extractPropertyDefinition(t,i,"gradientDefs");if(n){var r=e.getAttribute(i+"-opacity"),o=S.Gradient.fromElement(n,t,r,this.options);t.set(i,o)}},g.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},g.resolveClipPath=function(t,e){var i,n,r,o,s=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(s){r=[],n=S.util.invertTransform(t.calcTransformMatrix());for(var a=s[0].parentNode,c=e;c.parentNode&&c.getAttribute("clip-path")!==t.clipPath;)c=c.parentNode;c.parentNode.appendChild(a);for(var u=0;u<s.length;u++)i=s[u],this.findTag(i).fromElement(i,this.createClipPathCallback(t,r),this.options);s=1===r.length?r[0]:new S.Group(r),o=S.util.multiplyTransformMatrices(n,s.calcTransformMatrix()),s.clipPath&&this.resolveClipPath(s,c);var h=S.util.qrDecompose(o);s.flipX=!1,s.flipY=!1,s.set("scaleX",h.scaleX),s.set("scaleY",h.scaleY),s.angle=h.angle,s.skewX=h.skewX,s.skewY=0,s.setPositionByOrigin({x:h.translateX,y:h.translateY},"center","center"),t.clipPath=s}else delete t.clipPath},g.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter((function(t){return null!=t})),this.callback(this.instances,this.elements))},function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t,e){this.x=t,this.y=e}e.Point?e.warn("fabric.Point is already defined"):(e.Point=i,i.prototype={type:"point",constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,n,r,o){var s,a=(o.x-r.x)*(t.y-r.y)-(o.y-r.y)*(t.x-r.x),c=(n.x-t.x)*(t.y-r.y)-(n.y-t.y)*(t.x-r.x),u=(o.y-r.y)*(n.x-t.x)-(o.x-r.x)*(n.y-t.y);if(0!==u){var h=a/u,l=c/u;0<=h&&h<=1&&0<=l&&l<=1?(s=new i("Intersection")).appendPoint(new e.Point(t.x+h*(n.x-t.x),t.y+h*(n.y-t.y))):s=new i}else s=new i(0===a||0===c?"Coincident":"Parallel");return s},e.Intersection.intersectLinePolygon=function(t,e,n){var r,o,s,a,c=new i,u=n.length;for(a=0;a<u;a++)r=n[a],o=n[(a+1)%u],s=i.intersectLineLine(t,e,r,o),c.appendPoints(s.points);return c.points.length>0&&(c.status="Intersection"),c},e.Intersection.intersectPolygonPolygon=function(t,e){var n,r=new i,o=t.length;for(n=0;n<o;n++){var s=t[n],a=t[(n+1)%o],c=i.intersectLinePolygon(s,a,e);r.appendPoints(c.points)}return r.points.length>0&&(r.status="Intersection"),r},e.Intersection.intersectPolygonRectangle=function(t,n,r){var o=n.min(r),s=n.max(r),a=new e.Point(s.x,o.y),c=new e.Point(o.x,s.y),u=i.intersectLinePolygon(o,a,t),h=i.intersectLinePolygon(a,s,t),l=i.intersectLinePolygon(s,c,t),f=i.intersectLinePolygon(c,o,t),d=new i;return d.appendPoints(u.points),d.appendPoints(h.points),d.appendPoints(l.points),d.appendPoints(f.points),d.points.length>0&&(d.status="Intersection"),d})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function n(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,n){t/=255,i/=255,n/=255;var r,o,s,a=e.util.array.max([t,i,n]),c=e.util.array.min([t,i,n]);if(s=(a+c)/2,a===c)r=o=0;else{var u=a-c;switch(o=s>.5?u/(2-a-c):u/(a+c),a){case t:r=(i-n)/u+(i<n?6:0);break;case i:r=(n-t)/u+2;break;case n:r=(t-i)/u+4}r/=6}return[Math.round(360*r),Math.round(100*o),Math.round(100*s)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,n=this.getSource();return t=1===(t=n[0].toString(16)).length?"0"+t:t,e=1===(e=n[1].toString(16)).length?"0"+e:e,i=1===(i=n[2].toString(16)).length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t,e=this.getSource();return t=1===(t=(t=Math.round(255*e[3])).toString(16)).length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),n=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,n]),this},overlayWith:function(t){t instanceof i||(t=new i(t));var e,n=[],r=this.getAlpha(),o=this.getSource(),s=t.getSource();for(e=0;e<3;e++)n.push(Math.round(.5*o[e]+.5*s[e]));return n[3]=r,this.setSource(n),this}},e.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,e.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,e.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,e.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},e.Color.fromRgb=function(t){return i.fromSource(i.sourceFromRgb(t))},e.Color.sourceFromRgb=function(t){var e=t.match(i.reRGBa);if(e){var n=parseInt(e[1],10)/(/%$/.test(e[1])?100:1)*(/%$/.test(e[1])?255:1),r=parseInt(e[2],10)/(/%$/.test(e[2])?100:1)*(/%$/.test(e[2])?255:1),o=parseInt(e[3],10)/(/%$/.test(e[3])?100:1)*(/%$/.test(e[3])?255:1);return[parseInt(n,10),parseInt(r,10),parseInt(o,10),e[4]?parseFloat(e[4]):1]}},e.Color.fromRgba=i.fromRgb,e.Color.fromHsl=function(t){return i.fromSource(i.sourceFromHsl(t))},e.Color.sourceFromHsl=function(t){var e=t.match(i.reHSLa);if(e){var r,o,s,a=(parseFloat(e[1])%360+360)%360/360,c=parseFloat(e[2])/(/%$/.test(e[2])?100:1),u=parseFloat(e[3])/(/%$/.test(e[3])?100:1);if(0===c)r=o=s=u;else{var h=u<=.5?u*(c+1):u+c-u*c,l=2*u-h;r=n(l,h,a+1/3),o=n(l,h,a),s=n(l,h,a-1/3)}return[Math.round(255*r),Math.round(255*o),Math.round(255*s),e[4]?parseFloat(e[4]):1]}},e.Color.fromHsla=i.fromHsl,e.Color.fromHex=function(t){return i.fromSource(i.sourceFromHex(t))},e.Color.sourceFromHex=function(t){if(t.match(i.reHex)){var e=t.slice(t.indexOf("#")+1),n=3===e.length||4===e.length,r=8===e.length||4===e.length,o=n?e.charAt(0)+e.charAt(0):e.substring(0,2),s=n?e.charAt(1)+e.charAt(1):e.substring(2,4),a=n?e.charAt(2)+e.charAt(2):e.substring(4,6),c=r?n?e.charAt(3)+e.charAt(3):e.substring(6,8):"FF";return[parseInt(o,16),parseInt(s,16),parseInt(a,16),parseFloat((parseInt(c,16)/255).toFixed(2))]}},e.Color.fromSource=function(t){var e=new i;return e.setSource(t),e})}(e),function(){function t(t,e){var i,n,r,o,s=t.getAttribute("style"),a=t.getAttribute("offset")||0;if(a=(a=parseFloat(a)/(/%$/.test(a)?100:1))<0?0:a>1?1:a,s){var c=s.split(/\s*;\s*/);for(""===c[c.length-1]&&c.pop(),o=c.length;o--;){var u=c[o].split(/\s*:\s*/),h=u[0].trim(),l=u[1].trim();"stop-color"===h?i=l:"stop-opacity"===h&&(r=l)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),r||(r=t.getAttribute("stop-opacity")),n=(i=new S.Color(i)).getAlpha(),r=isNaN(parseFloat(r))?1:parseFloat(r),r*=n*e,{offset:a,color:i.toRgb(),opacity:r}}var e=S.util.object.clone;function i(t,e,i,n){var r,o;Object.keys(e).forEach((function(t){"Infinity"===(r=e[t])?o=1:"-Infinity"===r?o=0:(o=parseFloat(e[t],10),"string"==typeof r&&/^(\d+\.\d+)%|(\d+)%$/.test(r)&&(o*=.01,"pixels"===n&&("x1"!==t&&"x2"!==t&&"r2"!==t||(o*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(o*=i.viewBoxHeight||i.height)))),e[t]=o}))}S.Gradient=S.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+S.Object.__uid++:this.id=S.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new S.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return S.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var n,r,o,s,a=e(this.coords,!0),c=(i=i||{},e(this.colorStops,!0)),u=a.r1>a.r2,h=this.gradientTransform?this.gradientTransform.concat():S.iMatrix.concat(),l=-this.offsetX,f=-this.offsetY,d=!!i.additionalTransform,p="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(c.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===p?(l/=t.width,f/=t.height):(l+=t.width/2,f+=t.height/2),"path"===t.type&&(l-=t.pathOffset.x,f-=t.pathOffset.y),h[4]-=l,h[5]-=f,s='id="SVGID_'+this.id+'" gradientUnits="'+p+'"',s+=' gradientTransform="'+(d?i.additionalTransform+" ":"")+S.util.matrixToSVG(h)+'" ',"linear"===this.type?o=["<linearGradient ",s,' x1="',a.x1,'" y1="',a.y1,'" x2="',a.x2,'" y2="',a.y2,'">\n']:"radial"===this.type&&(o=["<radialGradient ",s,' cx="',u?a.x1:a.x2,'" cy="',u?a.y1:a.y2,'" r="',u?a.r1:a.r2,'" fx="',u?a.x2:a.x1,'" fy="',u?a.y2:a.y1,'">\n']),"radial"===this.type){if(u)for((c=c.concat()).reverse(),n=0,r=c.length;n<r;n++)c[n].offset=1-c[n].offset;var g=Math.min(a.r1,a.r2);if(g>0){var v=g/Math.max(a.r1,a.r2);for(n=0,r=c.length;n<r;n++)c[n].offset+=v*(1-c[n].offset)}}for(n=0,r=c.length;n<r;n++){var y=c[n];o.push("<stop ",'offset="',100*y.offset+"%",'" style="stop-color:',y.color,void 0!==y.opacity?";stop-opacity: "+y.opacity:";",'"/>\n')}return o.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),o.join("")},toLive:function(t,e){var i,n,r,o=S.util.object.clone(this.coords),s=o.x1,a=o.y1,c=o.x2,u=o.y2,h=this.colorStops;if(this.type){for(e instanceof S.Text&&"percentage"===this.gradientUnits&&(s*=e.width,a*=e.height,c*=e.width,u*=e.height),"linear"===this.type?i=t.createLinearGradient(s,a,c,u):"radial"===this.type&&(i=t.createRadialGradient(s,a,o.r1,c,u,o.r2)),n=0,r=h.length;n<r;n++){var l=h[n].color,f=h[n].opacity,d=h[n].offset;void 0!==f&&(l=new S.Color(l).setAlpha(f).toRgba()),i.addColorStop(d,l)}return i}}}),S.util.object.extend(S.Gradient,{fromElement:function(e,n,r,o){var s=parseFloat(r)/(/%$/.test(r)?100:1);s=s<0?0:s>1?1:s,isNaN(s)&&(s=1);var a,c,u,h,l=e.getElementsByTagName("stop"),f="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",d=e.getAttribute("gradientTransform")||"",p=[],g=0,v=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(a="linear",c=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(a="radial",c=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),u=l.length;u--;)p.push(t(l[u],s));return h=S.parseTransformAttribute(d),i(n,c,o,f),"pixels"===f&&(g=-n.left,v=-n.top),new S.Gradient({id:e.getAttribute("id"),type:a,coords:c,colorStops:p,gradientUnits:f,gradientTransform:h,offsetX:g,offsetY:v})},forObject:function(t,e){return e||(e={}),i(t,e.coords,e.gradientUnits,{viewBoxWidth:100,viewBoxHeight:100}),new S.Gradient(e)}})}(),function(){"use strict";var t=S.util.toFixed;S.Pattern=S.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=S.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else if(void 0!==S.util.getFunctionBody(t.source))this.source=new Function(S.util.getFunctionBody(t.source)),e&&e(this);else{var i=this;this.source=S.util.createImage(),S.util.loadImage(t.source,(function(t){i.source=t,e&&e(i)}),null,this.crossOrigin)}},toObject:function(e){var i,n,r=S.Object.NUM_FRACTION_DIGITS;return"function"==typeof this.source?i=String(this.source):"string"==typeof this.source.src?i=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(i=this.source.toDataURL()),n={type:"pattern",source:i,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:t(this.offsetX,r),offsetY:t(this.offsetY,r),patternTransform:this.patternTransform?this.patternTransform.concat():null},S.util.populateWithProperties(this,n,e),n},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,n=e.height/t.height,r=this.offsetX/t.width,o=this.offsetY/t.height,s="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(n=1,o&&(n+=Math.abs(o))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,r&&(i+=Math.abs(r))),e.src?s=e.src:e.toDataURL&&(s=e.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+r+'" y="'+o+'" width="'+i+'" height="'+n+'">\n<image x="0" y="0" width="'+e.width+'" height="'+e.height+'" xlink:href="'+s+'"></image>\n</pattern>\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e="function"==typeof this.source?this.source():this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}})}(),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),n=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseInt(n[1],10)||0,offsetY:parseInt(n[2],10)||0,blur:parseInt(n[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var n=40,r=40,o=e.Object.NUM_FRACTION_DIGITS,s=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=new e.Color(this.color);return t.width&&t.height&&(n=100*i((Math.abs(s.x)+this.blur)/t.width,o)+20,r=100*i((Math.abs(s.y)+this.blur)/t.height,o)+20),t.flipX&&(s.x*=-1),t.flipY&&(s.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+r+'%" height="'+(100+2*r)+'%" x="-'+n+'%" width="'+(100+2*n)+'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,o)+'"></feGaussianBlur>\n\t<feOffset dx="'+i(s.x,o)+'" dy="'+i(s.y,o)+'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="'+a.toRgb()+'" flood-opacity="'+a.getAlpha()+'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){"use strict";if(S.StaticCanvas)S.warn("fabric.StaticCanvas is already defined.");else{var t=S.util.object.extend,e=S.util.getElementOffset,i=S.util.removeFromArray,n=S.util.toFixed,r=S.util.transformPoint,o=S.util.invertTransform,s=S.util.getNodeCanvas,a=S.util.createCanvasElement,c=new Error("Could not initialize `canvas` element");S.StaticCanvas=S.util.createClass(S.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:S.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,onBeforeScaleRotate:function(){},enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this._setImageSmoothing(),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return 1!==S.devicePixelRatio&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?S.devicePixelRatio:1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=S.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},_setImageSmoothing:function(){var t=this.getContext();t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(t,e,i,n){return"string"==typeof e?S.util.loadImage(e,(function(e){if(e){var r=new S.Image(e,n);this[t]=r,r.canvas=this}i&&i(e)}),this,n&&n.crossOrigin):(n&&e.setOptions(n),this[t]=e,e&&(e.canvas=this),i&&i(e)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=a();if(!t)throw c;if(t.style||(t.style={}),void 0===t.getContext)throw c;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=S.util.getById(t)||this._createCanvasElement(),S.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var n in e=e||{},t)i=t[n],e.cssOnly||(this._setBackstoreDimension(n,t[n]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(n,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(),this._initRetinaScaling(),this._setImageSmoothing(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,n,r=this._activeObject;for(this.viewportTransform=t,i=0,n=this._objects.length;i<n;i++)(e=this._objects[i]).group||e.setCoords(!1,!0);return r&&"activeSelection"===r.type&&r.setCoords(!1,!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(t,e){var i=t,n=this.viewportTransform.slice(0);t=r(t,o(this.viewportTransform)),n[0]=e,n[3]=e;var s=r(t,n);return n[4]+=i.x-s.x,n[5]+=i.y-s.y,this.setViewportTransform(n)},setZoom:function(t){return this.zoomToPoint(new S.Point(0,0),t),this},absolutePan:function(t){var e=this.viewportTransform.slice(0);return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)},relativePan:function(t){return this.absolutePan(new S.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(t){this.stateful&&t.setupState(),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added")},_onObjectRemoved:function(t){this.fire("object:removed",{target:t}),t.fire("removed"),delete t.canvas},clearContext:function(t){return t.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var t=this.contextContainer;return this.renderCanvas(t,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=S.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var t={},e=this.width,i=this.height,n=o(this.viewportTransform);return t.tl=r({x:0,y:0},n),t.br=r({x:e,y:i},n),t.tr=new S.Point(t.br.x,t.tl.y),t.bl=new S.Point(t.tl.x,t.br.y),this.vptCoords=t,t},cancelRequestedRender:function(){this.isRendering&&(S.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(t,e){var i=this.viewportTransform,n=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(t),this.fire("before:render",{ctx:t}),this.clipTo&&S.util.clipContext(this,t),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.clipTo&&t.restore(),n&&(n.canvas=this,n.shouldCache(),n._transformDone=!0,n.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t)),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render",{ctx:t})},drawClipPathOnCanvas:function(t){var e=this.viewportTransform,i=this.clipPath;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t.globalCompositeOperation="destination-in",i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},_renderObjects:function(t,e){var i,n;for(i=0,n=e.length;i<n;++i)e[i]&&e[i].render(t)},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"],n=this[e+"Image"],r=this.viewportTransform,o=this[e+"Vpt"];if(i||n){if(i){t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=i.toLive?i.toLive(t,this):i,o&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);var s=i.gradientTransform||i.patternTransform;s&&t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),t.fill(),t.restore()}n&&(t.save(),o&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.render(t),t.restore())}},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},centerObjectH:function(t){return this._centerObject(t,new S.Point(this.getCenter().left,t.getCenterPoint().y))},centerObjectV:function(t){return this._centerObject(t,new S.Point(t.getCenterPoint().x,this.getCenter().top))},centerObject:function(t){var e=this.getCenter();return this._centerObject(t,new S.Point(e.left,e.top))},viewportCenterObject:function(t){var e=this.getVpCenter();return this._centerObject(t,e)},viewportCenterObjectH:function(t){var e=this.getVpCenter();return this._centerObject(t,new S.Point(e.x,t.getCenterPoint().y)),this},viewportCenterObjectV:function(t){var e=this.getVpCenter();return this._centerObject(t,new S.Point(t.getCenterPoint().x,e.y))},getVpCenter:function(){var t=this.getCenter(),e=o(this.viewportTransform);return r({x:t.left,y:t.top},e)},_centerObject:function(t,e){return t.setPositionByOrigin(e,"center","center"),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var n=this.clipPath,r={version:S.version,objects:this._toObjects(e,i)};return n&&(r.clipPath=this._toObject(this.clipPath,e,i)),t(r,this.__serializeBgOverlay(e,i)),S.util.populateWithProperties(this,r,i),r},_toObjects:function(t,e){return this._objects.filter((function(t){return!t.excludeFromExport})).map((function(i){return this._toObject(i,t,e)}),this)},_toObject:function(t,e,i){var n;this.includeDefaultValues||(n=t.includeDefaultValues,t.includeDefaultValues=!1);var r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=n),r},__serializeBgOverlay:function(t,e){var i={},n=this.backgroundImage,r=this.overlayImage;return this.backgroundColor&&(i.background=this.backgroundColor.toObject?this.backgroundColor.toObject(e):this.backgroundColor),this.overlayColor&&(i.overlay=this.overlayColor.toObject?this.overlayColor.toObject(e):this.overlayColor),n&&!n.excludeFromExport&&(i.backgroundImage=this._toObject(n,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,t,e)),i},svgViewportTransformation:!0,toSVG:function(t,e){t||(t={}),t.reviver=e;var i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'+this.clipPath.clipPathId+')" >\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("</g>\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i,r=e.width||this.width,o=e.height||this.height,s='viewBox="0 0 '+this.width+" "+this.height+'" ',a=S.Object.NUM_FRACTION_DIGITS;e.viewBox?s='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,s='viewBox="'+n(-i[4]/i[0],a)+" "+n(-i[5]/i[3],a)+" "+n(this.width/i[0],a)+" "+n(this.height/i[3],a)+'" '),t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',r,'" ','height="',o,'" ',s,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",S.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+S.Object.__uid++,'<clipPath id="'+e.clipPathId+'" >\n'+this.clipPath.toClipPathSVG(t.reviver)+"</clipPath>\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var n=t[e+"Vpt"],r=t.viewportTransform,o={width:t.width/(n?r[0]:1),height:t.height/(n?r[3]:1)};return i.toSVG(o,{additionalTransform:n?S.util.matrixToSVG(r):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,n,r,o,s,a,c="",u={},h=S.fontPaths,l=[];for(this._objects.forEach((function t(e){l.push(e),e._objects&&e._objects.forEach(t)})),s=0,a=l.length;s<a;s++)if(e=(t=l[s]).fontFamily,-1!==t.type.indexOf("text")&&!u[e]&&h[e]&&(u[e]=!0,t.styles))for(r in i=t.styles)for(o in n=i[r])!u[e=n[o].fontFamily]&&h[e]&&(u[e]=!0);for(var f in u)c+=["\t\t@font-face {\n","\t\t\tfont-family: '",f,"';\n","\t\t\tsrc: url('",h[f],"');\n","\t\t}\n"].join("");return c&&(c=['\t<style type="text/css">',"<![CDATA[\n",c,"]]>","</style>\n"].join("")),c},_setSVGObjects:function(t,e){var i,n,r,o=this._objects;for(n=0,r=o.length;n<r;n++)(i=o[n]).excludeFromExport||this._setSVGObject(t,i,e)},_setSVGObject:function(t,e,i){t.push(e.toSVG(i))},_setSVGBgOverlayImage:function(t,e,i){this[e]&&!this[e].excludeFromExport&&this[e].toSVG&&t.push(this[e].toSVG(i))},_setSVGBgOverlayColor:function(t,e){var i=this[e+"Color"],n=this.viewportTransform,r=this.width,o=this.height;if(i)if(i.toLive){var s=i.repeat,a=S.util.invertTransform(n),c=this[e+"Vpt"]?S.util.matrixToSVG(a):"";t.push('<rect transform="'+c+" translate(",r/2,",",o/2,')"',' x="',i.offsetX-r/2,'" y="',i.offsetY-o/2,'" ','width="',"repeat-y"===s||"no-repeat"===s?i.source.width:r,'" height="',"repeat-x"===s||"no-repeat"===s?i.source.height:o,'" fill="url(#SVGID_'+i.id+')"',"></rect>\n")}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',"></rect>\n")},sendToBack:function(t){if(!t)return this;var e,n,r,o=this._activeObject;if(t===o&&"activeSelection"===t.type)for(e=(r=o._objects).length;e--;)n=r[e],i(this._objects,n),this._objects.unshift(n);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,n,r,o=this._activeObject;if(t===o&&"activeSelection"===t.type)for(r=o._objects,e=0;e<r.length;e++)n=r[e],i(this._objects,n),this._objects.push(n);else i(this._objects,t),this._objects.push(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(t,e){if(!t)return this;var n,r,o,s,a,c=this._activeObject,u=0;if(t===c&&"activeSelection"===t.type)for(a=c._objects,n=0;n<a.length;n++)r=a[n],(o=this._objects.indexOf(r))>0+u&&(s=o-1,i(this._objects,r),this._objects.splice(s,0,r)),u++;else 0!==(o=this._objects.indexOf(t))&&(s=this._findNewLowerIndex(t,o,e),i(this._objects,t),this._objects.splice(s,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var n,r;if(i)for(n=e,r=e-1;r>=0;--r){if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e-1;return n},bringForward:function(t,e){if(!t)return this;var n,r,o,s,a,c=this._activeObject,u=0;if(t===c&&"activeSelection"===t.type)for(n=(a=c._objects).length;n--;)r=a[n],(o=this._objects.indexOf(r))<this._objects.length-1-u&&(s=o+1,i(this._objects,r),this._objects.splice(s,0,r)),u++;else(o=this._objects.indexOf(t))!==this._objects.length-1&&(s=this._findNewUpperIndex(t,o,e),i(this._objects,t),this._objects.splice(s,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(t,e,i){var n,r,o;if(i)for(n=e,r=e+1,o=this._objects.length;r<o;++r){if(t.intersectsWithObject(this._objects[r])||t.isContainedWithinObject(this._objects[r])||this._objects[r].isContainedWithinObject(t)){n=r;break}}else n=e+1;return n},moveTo:function(t,e){return i(this._objects,t),this._objects.splice(e,0,t),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(S.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,S.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),t(S.StaticCanvas.prototype,S.Observable),t(S.StaticCanvas.prototype,S.Collection),t(S.StaticCanvas.prototype,S.DataURLExporter),t(S.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=a();if(!e||!e.getContext)return null;var i=e.getContext("2d");if(!i)return null;switch(t){case"setLineDash":return void 0!==i.setLineDash;default:return null}}}),S.StaticCanvas.prototype.toJSON=S.StaticCanvas.prototype.toObject,S.isLikelyNode&&(S.StaticCanvas.prototype.createPNGStream=function(){var t=s(this.lowerCanvasEl);return t&&t.createPNGStream()},S.StaticCanvas.prototype.createJPEGStream=function(t){var e=s(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),S.BaseBrush=S.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,setShadow:function(t){return this.shadow=new S.Shadow(t),this},_setBrushStyles:function(){var t=this.canvas.contextTop;t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,S.StaticCanvas.supports("setLineDash")&&t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,n=t.getZoom();t&&t._isRetinaScaling()&&(n*=S.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*n,i.shadowOffsetX=e.offsetX*n,i.shadowOffsetY=e.offsetY*n}},needsFullRender:function(){return new S.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}}),S.PencilBrush=S.util.createClass(S.BaseBrush,{decimate:.4,initialize:function(t){this.canvas=t,this._points=[]},_drawSegment:function(t,e,i){var n=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,n.x,n.y),n},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&this._captureDrawingPath(t)&&this._points.length>1)if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,n=i.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(r,i[n-2],i[n-1],!0),r.stroke(),r.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new S.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(),this._setShadow()},_captureDrawingPath:function(t){var e=new S.Point(t.x,t.y);return this._addPoint(e)},_render:function(){var t,e,i=this.canvas.contextTop,n=this._points[0],r=this._points[1];if(this._saveAndTransform(i),i.beginPath(),2===this._points.length&&n.x===r.x&&n.y===r.y){var o=this.width/1e3;n=new S.Point(n.x,n.y),r=new S.Point(r.x,r.y),n.x-=o,r.x+=o}for(i.moveTo(n.x,n.y),t=1,e=this._points.length;t<e;t++)this._drawSegment(i,n,r),n=this._points[t],r=this._points[t+1];i.lineTo(n.x,n.y),i.stroke(),i.restore()},convertPointsToSVGPath:function(t){var e,i=[],n=this.width/1e3,r=new S.Point(t[0].x,t[0].y),o=new S.Point(t[1].x,t[1].y),s=t.length,a=1,c=0,u=s>2;for(u&&(a=t[2].x<o.x?-1:t[2].x===o.x?0:1,c=t[2].y<o.y?-1:t[2].y===o.y?0:1),i.push("M ",r.x-a*n," ",r.y-c*n," "),e=1;e<s;e++){if(!r.eq(o)){var h=r.midPointFrom(o);i.push("Q ",r.x," ",r.y," ",h.x," ",h.y," ")}r=t[e],e+1<t.length&&(o=t[e+1])}return u&&(a=r.x>t[e-2].x?1:r.x===t[e-2].x?0:-1,c=r.y>t[e-2].y?1:r.y===t[e-2].y?0:-1),i.push("L ",r.x+a*n," ",r.y+c*n),i},createPath:function(t){var e=new S.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.setShadow(this.shadow)),e},decimatePoints:function(t,e){if(t.length<=2)return t;var i,n=this.canvas.getZoom(),r=Math.pow(e/n,2),o=t.length-1,s=t[0],a=[s];for(i=1;i<o;i++)Math.pow(s.x-t[i].x,2)+Math.pow(s.y-t[i].y,2)>=r&&(s=t[i],a.push(s));return 1===a.length&&a.push(new S.Point(a[0].x,a[0].y)),a},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points).join("");if("M 0 0 Q 0 0 0 0 L 0 0"!==t){var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}else this.canvas.requestRenderAll()}}),S.CircleBrush=S.util.createClass(S.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,n=this.points;for(this._saveAndTransform(i),t=0,e=n.length;t<e;t++)this.dot(i,n[t]);i.restore()},onMouseMove:function(t){this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(t),this._render()):this.drawDot(t)},onMouseUp:function(){var t,e,i=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var n=[];for(t=0,e=this.points.length;t<e;t++){var r=this.points[t],o=new S.Circle({radius:r.radius,left:r.x,top:r.y,originX:"center",originY:"center",fill:r.fill});this.shadow&&o.setShadow(this.shadow),n.push(o)}var s=new S.Group(n);s.canvas=this.canvas,this.canvas.add(s),this.canvas.fire("path:created",{path:s}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=i,this.canvas.requestRenderAll()},addPoint:function(t){var e=new S.Point(t.x,t.y),i=S.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,n=new S.Color(this.color).setAlpha(S.util.getRandomInt(0,100)/100).toRgba();return e.radius=i,e.fill=n,this.points.push(e),e}}),S.SprayBrush=S.util.createClass(S.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(t){this.canvas=t,this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.render(this.sprayChunkPoints)},onMouseMove:function(t){this.addSprayChunk(t),this.render(this.sprayChunkPoints)},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,n=this.sprayChunks.length;i<n;i++)for(var r=this.sprayChunks[i],o=0,s=r.length;o<s;o++){var a=new S.Rect({width:r[o].width,height:r[o].width,left:r[o].x+1,top:r[o].y+1,originX:"center",originY:"center",fill:this.color});e.push(a)}this.optimizeOverlapping&&(e=this._getOptimizedRects(e));var c=new S.Group(e);this.shadow&&c.setShadow(this.shadow),this.canvas.add(c),this.canvas.fire("path:created",{path:c}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.requestRenderAll()},_getOptimizedRects:function(t){var e,i,n,r={};for(i=0,n=t.length;i<n;i++)r[e=t[i].left+""+t[i].top]||(r[e]=t[i]);var o=[];for(e in r)o.push(r[e]);return o},render:function(t){var e,i,n=this.canvas.contextTop;for(n.fillStyle=this.color,this._saveAndTransform(n),e=0,i=t.length;e<i;e++){var r=t[e];void 0!==r.opacity&&(n.globalAlpha=r.opacity),n.fillRect(r.x,r.y,r.width,r.width)}n.restore()},_render:function(){var t,e,i=this.canvas.contextTop;for(i.fillStyle=this.color,this._saveAndTransform(i),t=0,e=this.sprayChunks.length;t<e;t++)this.render(this.sprayChunks[t]);i.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];var e,i,n,r,o=this.width/2;for(r=0;r<this.density;r++){e=S.util.getRandomInt(t.x-o,t.x+o),i=S.util.getRandomInt(t.y-o,t.y+o),n=this.dotWidthVariance?S.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var s=new S.Point(e,i);s.width=n,this.randomOpacity&&(s.opacity=S.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(s)}this.sprayChunks.push(this.sprayChunkPoints)}}),S.PatternBrush=S.util.createClass(S.PencilBrush,{getPatternSrc:function(){var t=S.util.createCanvasElement(),e=t.getContext("2d");return t.width=t.height=25,e.fillStyle=this.color,e.beginPath(),e.arc(10,10,10,0,2*Math.PI,!1),e.closePath(),e.fill(),t},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles"),this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(t){var e=this.callSuper("createPath",t),i=e._getLeftTopCoords().scalarAdd(e.strokeWidth/2);return e.stroke=new S.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-i.x,offsetY:-i.y}),e}}),function(){var t=S.util.getPointer,e=S.util.degreesToRadians,i=S.util.radiansToDegrees,n=Math.atan2,r=Math.abs,o=S.StaticCanvas.supports("setLineDash");for(var s in S.Canvas=S.util.createClass(S.StaticCanvas,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e),this._initInteractive(),this._createCacheCanvas()},uniScaleTransform:!1,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=S.PencilBrush&&new S.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t,e,i,n=this.getActiveObjects();if(n.length>0&&!this.preserveObjectStacking){e=[],i=[];for(var r=0,o=this._objects.length;r<o;r++)t=this._objects[r],-1===n.indexOf(t)?e.push(t):i.push(t);n.length>1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&this.renderTopLayer(this.contextTop);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_resetCurrentTransform:function(){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,skewX:t.original.skewX,skewY:t.original.skewY,left:t.original.left,top:t.original.top}),this._shouldCenterTransform(t.target)?("center"!==t.originX&&("right"===t.originX?t.mouseXSign=-1:t.mouseXSign=1),"center"!==t.originY&&("bottom"===t.originY?t.mouseYSign=-1:t.mouseYSign=1),t.originX="center",t.originY="center"):(t.originX=t.original.originX,t.originY=t.original.originY)},containsPoint:function(t,e,i){var n,r=i||this.getPointer(t,!0);return n=e.group&&e.group===this._activeObject&&"activeSelection"===e.group.type?this._normalizePointer(e.group,r):{x:r.x,y:r.y},e.containsPoint(n)||e._findTargetCorner(r)},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),n=S.util.invertTransform(i),r=this.restorePointerVpt(e);return S.util.transformPoint(r,n)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var n=this._normalizePointer(t,{x:e,y:i}),r=Math.max(t.cacheTranslationX+n.x*t.zoomX,0),o=Math.max(t.cacheTranslationY+n.y*t.zoomY,0);return S.util.isTransparent(t._cacheContext,Math.round(r),Math.round(o),this.targetFindTolerance)}var s=this.contextCache,a=t.selectionBackgroundColor,c=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(s),s.save(),s.transform(c[0],c[1],c[2],c[3],c[4],c[5]),t.render(s),s.restore(),t===this._activeObject&&t._renderControls(s,{hasBorders:!1,transparentCorners:!1},{hasBorders:!1}),t.selectionBackgroundColor=a,S.util.isTransparent(s,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return"[object Array]"===Object.prototype.toString.call(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),n=this._activeObject;return!e||e&&n&&i.length>1&&-1===i.indexOf(e)&&n!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&n&&n!==e},_shouldCenterTransform:function(t){if(t){var e,i=this._currentTransform;return"scale"===i.action||"scaleX"===i.action||"scaleY"===i.action?e=this.centeredScaling||t.centeredScaling:"rotate"===i.action&&(e=this.centeredRotation||t.centeredRotation),e?!i.altKey:i.altKey}},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i){if(!e||!t)return"drag";switch(e){case"mtr":return"rotate";case"ml":case"mr":return i[this.altActionKey]?"skewY":"scaleX";case"mt":case"mb":return i[this.altActionKey]?"skewX":"scaleY";default:return"scale"}},_setupCurrentTransform:function(t,i,n){if(i){var r=this.getPointer(t),o=i._findTargetCorner(this.getPointer(t,!0)),s=this._getActionFromCorner(n,o,t,i),a=this._getOriginFromCorner(i,o);this._currentTransform={target:i,action:s,corner:o,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:a.x,originY:a.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:e(i.angle),width:i.width*i.scaleX,mouseXSign:1,mouseYSign:1,shiftKey:t.shiftKey,altKey:t[this.centeredKey],original:S.util.saveObjectTransform(i)},this._currentTransform.original.originX=a.x,this._currentTransform.original.originY=a.y,this._resetCurrentTransform(),this._beforeTransform(t)}},_translateObject:function(t,e){var i=this._currentTransform,n=i.target,r=t-i.offsetX,o=e-i.offsetY,s=!n.get("lockMovementX")&&n.left!==r,a=!n.get("lockMovementY")&&n.top!==o;return s&&n.set("left",r),a&&n.set("top",o),s||a},_changeSkewTransformOrigin:function(t,e,i){var n="originX",r={0:"center"},o=e.target.skewX,s="left",a="right",c="mt"===e.corner||"ml"===e.corner?1:-1,u=1;t=t>0?1:-1,"y"===i&&(o=e.target.skewY,s="top",a="bottom",n="originY"),r[-1]=s,r[1]=a,e.target.flipX&&(u*=-1),e.target.flipY&&(u*=-1),0===o?(e.skewSign=-c*t*u,e[n]=r[-t]):(o=o>0?1:-1,e.skewSign=o,e[n]=r[o*c*u])},_skewObject:function(t,e,i){var n,r=this._currentTransform,o=r.target,s=o.get("lockSkewingX"),a=o.get("lockSkewingY");if(s&&"x"===i||a&&"y"===i)return!1;var c,u,h=o.getCenterPoint(),l=o.toLocalPoint(new S.Point(t,e),"center","center")[i],f=o.toLocalPoint(new S.Point(r.lastX,r.lastY),"center","center")[i],d=o._getTransformedDimensions();return this._changeSkewTransformOrigin(l-f,r,i),c=o.toLocalPoint(new S.Point(t,e),r.originX,r.originY)[i],u=o.translateToOriginPoint(h,r.originX,r.originY),n=this._setObjectSkew(c,r,i,d),r.lastX=t,r.lastY=e,o.setPositionByOrigin(u,r.originX,r.originY),n},_setObjectSkew:function(t,e,i,n){var r,o,s,a,c,u,h,l,f,d,p=e.target,g=e.skewSign;return"x"===i?(c="y",u="Y",h="X",f=0,d=p.skewY):(c="x",u="X",h="Y",f=p.skewX,d=0),a=p._getTransformedDimensions(f,d),(l=2*Math.abs(t)-a[i])<=2?r=0:(r=g*Math.atan(l/p["scale"+h]/(a[c]/p["scale"+u])),r=S.util.radiansToDegrees(r)),o=p["skew"+h]!==r,p.set("skew"+h,r),0!==p["skew"+u]&&(s=p._getTransformedDimensions(),r=n[c]/s[c]*p["scale"+u],p.set("scale"+u,r)),o},_scaleObject:function(t,e,i){var n=this._currentTransform,r=n.target,o=r.lockScalingX,s=r.lockScalingY,a=r.lockScalingFlip;if(o&&s)return!1;var c,u=r.translateToOriginPoint(r.getCenterPoint(),n.originX,n.originY),h=r.toLocalPoint(new S.Point(t,e),n.originX,n.originY),l=r._getTransformedDimensions();return this._setLocalMouse(h,n),c=this._setObjectScale(h,n,o,s,i,a,l),r.setPositionByOrigin(u,n.originX,n.originY),c},_setObjectScale:function(t,e,i,n,r,o,s){var a=e.target,c=!1,u=!1,h=!1,l=t.x*a.scaleX/s.x,f=t.y*a.scaleY/s.y,d=a.scaleX!==l,p=a.scaleY!==f;if(e.newScaleX=l,e.newScaleY=f,S.Textbox&&"x"===r&&a instanceof S.Textbox){var g=a.width*(t.x/s.x);return g>=a.getMinWidth()&&(h=g!==a.width,a.set("width",g),h)}return o&&l<=0&&l<a.scaleX&&(c=!0,t.x=0),o&&f<=0&&f<a.scaleY&&(u=!0,t.y=0),"equally"!==r||i||n?r?"x"!==r||a.get("lockUniScaling")?"y"!==r||a.get("lockUniScaling")||u||n||a.set("scaleY",f)&&(h=p):c||i||a.set("scaleX",l)&&(h=d):(c||i||a.set("scaleX",l)&&(h=h||d),u||n||a.set("scaleY",f)&&(h=h||p)):h=this._scaleObjectEqually(t,a,e,s),c||u||this._flipObject(e,r),h},_scaleObjectEqually:function(t,e,i,n){var r,o,s,a=t.y+t.x,c=n.y*i.original.scaleY/e.scaleY+n.x*i.original.scaleX/e.scaleX,u=t.x<0?-1:1,h=t.y<0?-1:1;return o=u*Math.abs(i.original.scaleX*a/c),s=h*Math.abs(i.original.scaleY*a/c),r=o!==e.scaleX||s!==e.scaleY,e.set("scaleX",o),e.set("scaleY",s),r},_flipObject:function(t,e){t.newScaleX<0&&"y"!==e&&("left"===t.originX?t.originX="right":"right"===t.originX&&(t.originX="left")),t.newScaleY<0&&"x"!==e&&("top"===t.originY?t.originY="bottom":"bottom"===t.originY&&(t.originY="top"))},_setLocalMouse:function(t,e){var i=e.target,n=this.getZoom(),o=i.padding/n;"right"===e.originX?t.x*=-1:"center"===e.originX&&(t.x*=2*e.mouseXSign,t.x<0&&(e.mouseXSign=-e.mouseXSign)),"bottom"===e.originY?t.y*=-1:"center"===e.originY&&(t.y*=2*e.mouseYSign,t.y<0&&(e.mouseYSign=-e.mouseYSign)),r(t.x)>o?t.x<0?t.x+=o:t.x-=o:t.x=0,r(t.y)>o?t.y<0?t.y+=o:t.y-=o:t.y=0},_rotateObject:function(t,e){var r=this._currentTransform,o=r.target,s=o.translateToOriginPoint(o.getCenterPoint(),r.originX,r.originY);if(o.lockRotation)return!1;var a=n(r.ey-s.y,r.ex-s.x),c=n(e-s.y,t-s.x),u=i(c-a+r.theta),h=!0;if(o.snapAngle>0){var l=o.snapAngle,f=o.snapThreshold||l,d=Math.ceil(u/l)*l,p=Math.floor(u/l)*l;Math.abs(u-p)<f?u=p:Math.abs(u-d)<f&&(u=d)}return u<0&&(u=360+u),u%=360,o.angle===u?h=!1:(o.angle=u,o.setPositionByOrigin(s,r.originX,r.originY)),h},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=e.left,n=e.top,s=r(i),a=r(n);if(this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(e.ex-(i>0?0:-i),e.ey-(n>0?0:-n),s,a)),this.selectionLineWidth&&this.selectionBorderColor)if(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,this.selectionDashArray.length>1&&!o){var c=e.ex+.5-(i>0?0:s),u=e.ey+.5-(n>0?0:a);t.beginPath(),S.util.drawDashedLine(t,c,u,c+s,u,this.selectionDashArray),S.util.drawDashedLine(t,c,u+a-1,c+s,u+a-1,this.selectionDashArray),S.util.drawDashedLine(t,c,u,c,u+a,this.selectionDashArray),S.util.drawDashedLine(t,c+s-1,u,c+s-1,u+a,this.selectionDashArray),t.closePath(),t.stroke()}else S.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(e.ex+.5-(i>0?0:s),e.ey+.5-(n>0?0:a),s,a)},findTarget:function(t,e){if(!this.skipTargetFind){var i,n,r=this.getPointer(t,!0),o=this._activeObject,s=this.getActiveObjects();if(this.targets=[],s.length>1&&!e&&o===this._searchPossibleTargets([o],r))return o;if(1===s.length&&o._findTargetCorner(r))return o;if(1===s.length&&o===this._searchPossibleTargets([o],r)){if(!this.preserveObjectStacking)return o;i=o,n=this.targets,this.targets=[]}var a=this._searchPossibleTargets(this._objects,r);return t[this.altSelectionKey]&&a&&i&&a!==i&&(a=i,this.targets=n),a}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&this.containsPoint(null,e,t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,n,r=t.length;r--;){var o=t[r],s=o.group&&"activeSelection"!==o.group.type?this._normalizePointer(o.group,e):e;if(this._checkTarget(s,o,e)){(i=t[r]).subTargetCheck&&i instanceof S.Group&&(n=this._searchPossibleTargets(i._objects,e))&&this.targets.push(n);break}}return i},restorePointerVpt:function(t){return S.util.transformPoint(t,S.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var n,r=t(e),o=this.upperCanvasEl,s=o.getBoundingClientRect(),a=s.width||0,c=s.height||0;a&&c||("top"in s&&"bottom"in s&&(c=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(a=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,i||(r=this.restorePointerVpt(r));var u=this.getRetinaScaling();return 1!==u&&(r.x/=u,r.y/=u),n=0===a||0===c?{width:1,height:1}:{width:o.width/a,height:o.height/c},{x:r.x*n.width,y:r.y*n.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),S.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=S.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),S.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),S.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;S.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,S.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,n=this.getActiveObjects(),r=[],o=[],s={e:e};t.forEach((function(t){-1===n.indexOf(t)&&(i=!0,t.fire("deselected",s),o.push(t))})),n.forEach((function(e){-1===t.indexOf(e)&&(i=!0,e.fire("selected",s),r.push(e))})),t.length>0&&n.length>0?(s.selected=r,s.deselected=o,s.updated=r[0]||o[0],s.target=this._activeObject,i&&this.fire("selection:updated",s)):n.length>0?(1===n.length&&(s.target=r[0],this.fire("object:selected",s)),s.selected=r,s.target=this._activeObject,this.fire("selection:created",s)):t.length>0&&(s.deselected=o,this.fire("selection:cleared",s))},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&(!!this._discardActiveObject(e,t)&&(!t.onSelect({e:e})&&(this._activeObject=t,!0)))},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){S.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,S.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(t),r=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,n),r},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),this._activeObject.realizeTransform(t),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var n=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,n)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),S.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),S.StaticCanvas)"prototype"!==s&&(S.Canvas[s]=S.StaticCanvas[s])}(),function(){var t={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},e=S.util.addListener,i=S.util.removeListener,n={passive:!1};function r(t,e){return t.button&&t.button===e-1}S.util.object.extend(S.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(e,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var i=this.upperCanvasEl,r=this._getEventPrefix();t(S.window,"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,r+"move",this._onMouseMove,n),t(i,r+"out",this._onMouseOut),t(i,r+"enter",this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,n),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](i,"gesture",this._onGesture),eventjs[e](i,"drag",this._onDrag),eventjs[e](i,"orientation",this._onOrientationChange),eventjs[e](i,"shake",this._onShake),eventjs[e](i,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(i,"remove");var t=this._getEventPrefix();i(S.document,t+"up",this._onMouseUp),i(S.document,"touchend",this._onTouchEnd,n),i(S.document,t+"move",this._onMouseMove,n),i(S.document,"touchmove",this._onMouseMove,n)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._simpleEventHandler.bind(this,"drop"),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(n){i.fire("mouse:out",{target:e,e:t}),n&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this.currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||(!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId))},_onTouchStart:function(t){t.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),this._resetTransformEventData();var r=this.upperCanvasEl,o=this._getEventPrefix();e(S.document,"touchend",this._onTouchEnd,n),e(S.document,"touchmove",this._onMouseMove,n),i(r,o+"down",this._onMouseDown)},_onMouseDown:function(t){this.__onMouseDown(t),this._resetTransformEventData();var r=this.upperCanvasEl,o=this._getEventPrefix();i(r,o+"move",this._onMouseMove,n),e(S.document,o+"up",this._onMouseUp),e(S.document,o+"move",this._onMouseMove,n)},_onTouchEnd:function(t){if(!(t.touches.length>0)){this.__onMouseUp(t),this._resetTransformEventData(),this.mainTouchId=null;var r=this._getEventPrefix();i(S.document,"touchend",this._onTouchEnd,n),i(S.document,"touchmove",this._onMouseMove,n);var o=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){e(o.upperCanvasEl,r+"down",o._onMouseDown),o._willAddMouseDown=0}),400)}},_onMouseUp:function(t){this.__onMouseUp(t),this._resetTransformEventData();var r=this.upperCanvasEl,o=this._getEventPrefix();this._isMainEvent(t)&&(i(S.document,o+"up",this._onMouseUp),i(S.document,o+"move",this._onMouseMove,n),e(r,o+"move",this._onMouseMove,n))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,n=this._groupSelector,o=!1,s=!n||0===n.left&&0===n.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),!r(t,3))return r(t,2)?(this.fireMiddleClick&&this._handleEvent(t,"up",2,s),void this._resetTransformEventData()):void(this.isDrawingMode&&this._isCurrentlyDrawing?this._onMouseUpInDrawingMode(t):this._isMainEvent(t)&&(i&&(this._finalizeCurrentTransform(t),o=i.actionPerformed),s||(this._maybeGroupObjects(t),o||(o=this._shouldRender(e))),e&&(e.isMoving=!1),this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,s),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),o?this.requestRenderAll():s||this.renderTop()));this.fireRightClick&&this._handleEvent(t,"up",3,s)},_simpleEventHandler:function(t,e){var i=this.findTarget(e),n=this.targets,r={e:e,target:i,subTargets:n};if(this.fire(t,r),i&&i.fire(t,r),!n)return i;for(var o=0;o<n.length;o++)n[o].fire(t,r);return i},_handleEvent:function(t,e,i,n){var r=this._target,o=this.targets||[],s={e:t,target:r,subTargets:o,button:i||1,isClick:n||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};this.fire("mouse:"+e,s),r&&r.fire("mouse"+e,s);for(var a=0;a<o.length;a++)o[a].fire("mouse"+e,s)},_finalizeCurrentTransform:function(t){var e,i=this._currentTransform,n=i.target,r={e:t,target:n,transform:i};n._scaling&&(n._scaling=!1),n.setCoords(),(i.actionPerformed||this.stateful&&n.hasStateChanged())&&(i.actionPerformed&&(e=this._addEventOptions(r,i),this._fire(e,r)),this._fire("modified",r))},_addEventOptions:function(t,e){var i,n;switch(e.action){case"scaleX":i="scaled",n="x";break;case"scaleY":i="scaled",n="y";break;case"skewX":i="skewed",n="x";break;case"skewY":i="skewed",n="y";break;case"scale":i="scaled",n="equally";break;case"rotate":i="rotated";break;case"drag":i="moved"}return t.by=n,i},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(t).requestRenderAll(),this.clipTo&&S.util.clipContext(this,this.contextTop);var e=this.getPointer(t);this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down")},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=this.getPointer(t);this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")},_onMouseUpInDrawingMode:function(t){this.clipTo&&this.contextTop.restore();var e=this.getPointer(t);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:t,pointer:e}),this._handleEvent(t,"up")},__onMouseDown:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"down:before");var e=this._target;if(r(t,3))this.fireRightClick&&this._handleEvent(t,"down",3);else if(r(t,2))this.fireMiddleClick&&this._handleEvent(t,"down",2);else if(this.isDrawingMode)this._onMouseDownInDrawingMode(t);else if(this._isMainEvent(t)&&!this._currentTransform){var i=this._pointer;this._previousPointer=i;var n=this._shouldRender(e),o=this._shouldGroup(t,e);if(this._shouldClearSelection(t,e)?this.discardActiveObject(t):o&&(this._handleGrouping(t,e),e=this._activeObject),!this.selection||e&&(e.selectable||e.isEditing||e===this._activeObject)||(this._groupSelector={ex:i.x,ey:i.y,top:0,left:0}),e){var s=e===this._activeObject;e.selectable&&this.setActiveObject(e,t),e!==this._activeObject||!e.__corner&&o||this._setupCurrentTransform(t,e,s)}this._handleEvent(t,"down"),(n||o)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(t){this._resetTransformEventData(),this._pointer=this.getPointer(t,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)||null},_beforeTransform:function(t){var e=this._currentTransform;this.stateful&&e.target.saveState(),this.fire("before:transform",{e:t,transform:e}),e.corner&&this.onBeforeScaleRotate(e.target)},__onMouseMove:function(t){var e,i;if(this._handleEvent(t,"move:before"),this._cacheTransformEventData(t),this.isDrawingMode)this._onMouseMoveInDrawingMode(t);else if(this._isMainEvent(t)){var n=this._groupSelector;n?(i=this._pointer,n.left=i.x-n.ex,n.top=i.y-n.ey,this.renderTop()):this._currentTransform?this._transformObject(t):(e=this.findTarget(t)||null,this._setCursorFromEvent(t,e),this._fireOverOutEvents(e,t)),this._handleEvent(t,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(t,e){var i=this._hoveredTarget,n=this._hoveredTargets,r=this.targets,o=Math.max(n.length,r.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var s=0;s<o;s++)this.fireSyntheticInOutEvents(r[s],e,{oldTarget:n[s],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(t,e){var i=this._draggedoverTarget,n=this._hoveredTargets,r=this.targets,o=Math.max(n.length,r.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"dragleave",evtIn:"dragenter"});for(var s=0;s<o;s++)this.fireSyntheticInOutEvents(r[s],e,{oldTarget:n[s],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=t},fireSyntheticInOutEvents:function(t,e,i){var n,r,o,s=i.oldTarget,a=s!==t,c=i.canvasEvtIn,u=i.canvasEvtOut;a&&(n={e:e,target:t,previousTarget:s},r={e:e,target:s,nextTarget:t}),o=t&&a,s&&a&&(u&&this.fire(u,r),s.fire(i.evtOut,r)),o&&(c&&this.fire(c,n),t.fire(i.evtIn,n))},__onMouseWheel:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=!1,i.target.isMoving=!0,i.shiftKey=t.shiftKey,i.altKey=t[this.centeredKey],this._beforeScaleTransform(t,i),this._performTransformAction(t,i,e),i.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(t,e,i){var n=i.x,r=i.y,o=e.action,s=!1,a={target:e.target,e:t,transform:e,pointer:i};"rotate"===o?(s=this._rotateObject(n,r))&&this._fire("rotating",a):"scale"===o?(s=this._onScale(t,e,n,r))&&this._fire("scaling",a):"scaleX"===o?(s=this._scaleObject(n,r,"x"))&&this._fire("scaling",a):"scaleY"===o?(s=this._scaleObject(n,r,"y"))&&this._fire("scaling",a):"skewX"===o?(s=this._skewObject(n,r,"x"))&&this._fire("skewing",a):"skewY"===o?(s=this._skewObject(n,r,"y"))&&this._fire("skewing",a):(s=this._translateObject(n,r))&&(this._fire("moving",a),this.setCursor(a.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||s},_fire:function(t,e){this.fire("object:"+t,e),e.target.fire(t,e)},_beforeScaleTransform:function(t,e){if("scale"===e.action||"scaleX"===e.action||"scaleY"===e.action){var i=this._shouldCenterTransform(e.target);(i&&("center"!==e.originX||"center"!==e.originY)||!i&&"center"===e.originX&&"center"===e.originY)&&(this._resetCurrentTransform(),e.reset=!0)}},_onScale:function(t,e,i,n){return this._isUniscalePossible(t,e.target)?(e.currentAction="scale",this._scaleObject(i,n)):(e.reset||"scale"!==e.currentAction||this._resetCurrentTransform(),e.currentAction="scaleEqually",this._scaleObject(i,n,"equally"))},_isUniscalePossible:function(t,e){return(t[this.uniScaleKey]||this.uniScaleTransform)&&!e.get("lockUniScaling")},_setCursorFromEvent:function(t,e){if(!e)return this.setCursor(this.defaultCursor),!1;var i=e.hoverCursor||this.hoverCursor,n=this._activeObject&&"activeSelection"===this._activeObject.type?this._activeObject:null,r=(!n||!n.contains(e))&&e._findTargetCorner(this.getPointer(t,!0));r?this.setCursor(this.getCornerCursor(r,e,t)):(e.subTargetCheck&&this.targets.concat().reverse().map((function(t){i=t.hoverCursor||i})),this.setCursor(i))},getCornerCursor:function(e,i,n){return this.actionIsDisabled(e,i,n)?this.notAllowedCursor:e in t?this._getRotatedCornerCursor(e,i,n):"mtr"===e&&i.hasRotatingPoint?this.rotationCursor:this.defaultCursor},actionIsDisabled:function(t,e,i){return"mt"===t||"mb"===t?i[this.altActionKey]?e.lockSkewingX:e.lockScalingY:"ml"===t||"mr"===t?i[this.altActionKey]?e.lockSkewingY:e.lockScalingX:"mtr"===t?e.lockRotation:this._isUniscalePossible(i,e)?e.lockScalingX&&e.lockScalingY:e.lockScalingX||e.lockScalingY},_getRotatedCornerCursor:function(e,i,n){var r=Math.round(i.angle%360/45);return r<0&&(r+=8),r+=t[e],n[this.altActionKey]&&t[e]%2==0&&(r+=2),r%=8,this.cursorMap[r]}})}(),v=Math.min,y=Math.max,S.util.object.extend(S.Canvas.prototype,{_shouldGroup:function(t,e){var i=this._activeObject;return i&&this._isSelectionKeyPressed(t)&&e&&e.selectable&&this.selection&&(i!==e||"activeSelection"===i.type)&&!e.onSelect({e:t})},_handleGrouping:function(t,e){var i=this._activeObject;i.__corner||(e!==i||(e=this.findTarget(t,!0))&&e.selectable)&&(i&&"activeSelection"===i.type?this._updateActiveSelection(e,t):this._createActiveSelection(e,t))},_updateActiveSelection:function(t,e){var i=this._activeObject,n=i._objects.slice(0);i.contains(t)?(i.removeWithUpdate(t),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat(),1===i.size()&&this._setActiveObject(i.item(0),e)):(i.addWithUpdate(t),this._hoveredTarget=i,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(n,e)},_createActiveSelection:function(t,e){var i=this.getActiveObjects(),n=this._createGroup(t);this._hoveredTarget=n,this._setActiveObject(n,e),this._fireSelectionEvents(i,e)},_createGroup:function(t){var e=this._objects,i=e.indexOf(this._activeObject)<e.indexOf(t)?[this._activeObject,t]:[t,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new S.ActiveSelection(i,{canvas:this})},_groupSelectedObjects:function(t){var e,i=this._collectObjects(t);1===i.length?this.setActiveObject(i[0],t):i.length>1&&(e=new S.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],n=this._groupSelector.ex,r=this._groupSelector.ey,o=n+this._groupSelector.left,s=r+this._groupSelector.top,a=new S.Point(v(n,o),v(r,s)),c=new S.Point(y(n,o),y(r,s)),u=!this.selectionFullyContained,h=n===o&&r===s,l=this._objects.length;l--&&!((e=this._objects[l])&&e.selectable&&e.visible&&(u&&e.intersectsWithRect(a,c)||e.isContainedWithinRect(a,c)||u&&e.containsPoint(a)||u&&e.containsPoint(c))&&(i.push(e),h)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),S.util.object.extend(S.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,n=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),r=this.toCanvasElement(n,t);return S.util.toDataURL(r,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,n=(e.height||this.height)*t,r=this.getZoom(),o=this.width,s=this.height,a=r*t,c=this.viewportTransform,u=(c[4]-(e.left||0))*t,h=(c[5]-(e.top||0))*t,l=this.interactive,f=[a,0,0,a,u,h],d=this.enableRetinaScaling,p=S.util.createCanvasElement(),g=this.contextTop;return p.width=i,p.height=n,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=f,this.width=i,this.height=n,this.calcViewportBoundaries(),this.renderCanvas(p.getContext("2d"),this._objects),this.viewportTransform=c,this.width=o,this.height=s,this.calcViewportBoundaries(),this.interactive=l,this.enableRetinaScaling=d,this.contextTop=g,p}}),S.util.object.extend(S.StaticCanvas.prototype,{loadFromDatalessJSON:function(t,e,i){return this.loadFromJSON(t,e,i)},loadFromJSON:function(t,e,i){if(t){var n="string"==typeof t?JSON.parse(t):S.util.object.clone(t),r=this,o=n.clipPath,s=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete n.clipPath,this._enlivenObjects(n.objects,(function(t){r.clear(),r._setBgOverlay(n,(function(){o?r._enlivenObjects([o],(function(i){r.clipPath=i[0],r.__setupCanvas.call(r,n,t,s,e)})):r.__setupCanvas.call(r,n,t,s,e)}))}),i),this}},__setupCanvas:function(t,e,i,n){var r=this;e.forEach((function(t,e){r.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),n&&n()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var n=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,n),this.__setBgOverlay("overlayImage",t.overlayImage,i,n),this.__setBgOverlay("backgroundColor",t.background,i,n),this.__setBgOverlay("overlayColor",t.overlay,i,n)}else e&&e()},__setBgOverlay:function(t,e,i,n){var r=this;if(!e)return i[t]=!0,void(n&&n());"backgroundImage"===t||"overlayImage"===t?S.util.enlivenObjects([e],(function(e){r[t]=e[0],i[t]=!0,n&&n()})):this["set"+S.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,n&&n()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?S.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(n){i(n.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=S.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new S.Canvas(e);i.clipTo=this.clipTo,this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r=e.util.toFixed,o=e.util.string.capitalize,s=e.util.degreesToRadians,a=e.StaticCanvas.supports("setLineDash"),c=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",borderDashArray:null,cornerColor:"rgba(102,153,255,0.5)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,hasRotatingPoint:!0,rotatingPointOffset:40,perPixelTargetFind:!1,includeDefaultValues:!0,clipTo:null,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockUniScaling:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:c,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow clipTo visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,n=t.width,r=t.height,o=e.maxCacheSideLimit,s=e.minCacheSideLimit;if(n<=o&&r<=o&&n*r<=i)return n<s&&(t.width=s),r<s&&(t.height=s),t;var a=n/r,c=e.util.limitDimsByArea(a,i),u=e.util.capValue,h=u(s,c.x,o),l=u(s,c.y,o);return n>h&&(t.zoomX/=n/h,t.width=h,t.capped=!0),r>l&&(t.zoomY/=r/l,t.height=l,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,n=e.y*t.scaleY/this.scaleY;return{width:i+2,height:n+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:n}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,n=t._currentTransform.action;if(this===i&&n.slice&&"scale"===n.slice(0,5))return!1}var r,o,s=this._cacheCanvas,a=this._limitCacheSize(this._getCacheCanvasDimensions()),c=e.minCacheSideLimit,u=a.width,h=a.height,l=a.zoomX,f=a.zoomY,d=u!==this.cacheWidth||h!==this.cacheHeight,p=this.zoomX!==l||this.zoomY!==f,g=d||p,v=0,y=0,m=!1;if(d){var b=this._cacheCanvas.width,_=this._cacheCanvas.height,x=u>b||h>_;m=x||(u<.9*b||h<.9*_)&&b>c&&_>c,x&&!a.capped&&(u>c||h>c)&&(v=.1*u,y=.1*h)}return!!g&&(m?(s.width=Math.ceil(u+v),s.height=Math.ceil(h+y)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,s.width,s.height)),r=a.x/2,o=a.y/2,this.cacheTranslationX=Math.round(s.width/2-r)+r,this.cacheTranslationY=Math.round(s.height/2-o)+o,this.cacheWidth=u,this.cacheHeight=h,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(l,f),this.zoomX=l,this.zoomY=f,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initClipping(t),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e;e=this.group&&!this.group._transformDone?this.calcTransformMatrix():this.calcOwnMatrix(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,n={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,transformMatrix:this.transformMatrix?this.transformMatrix.concat():null,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};return this.clipPath&&(n.clipPath=this.clipPath.toObject(t),n.clipPath.inverted=this.clipPath.inverted,n.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,n,t),this.includeDefaultValues||(n=this._removeDefaultValues(n)),n},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],"[object Array]"===Object.prototype.toString.call(t[e])&&"[object Array]"===Object.prototype.toString.call(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#<fabric."+o(this.type)+">"},getObjectScaling:function(){var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var n=this.canvas.getZoom(),r=this.canvas.getRetinaScaling();e*=n*r,i*=n*r}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var n="scaleX"===t||"scaleY"===t,r=this[t]!==i,o=!1;return n&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,r&&(o=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,o&&this.group.set("dirty",!0)):o&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||0===this.width&&0===this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.transformMatrix&&t.transform.apply(t,this.transformMatrix),this.clipTo&&e.util.clipContext(this,t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),this.clipTo&&t.restore(),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t){var i=this.clipPath;if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var n=e.util.invertTransform(this.calcTransformMatrix());t.transform(n[0],n[1],n[2],n[3],n[4],n[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):(this._renderBackground(t),this._setStrokeStyles(t,this),this._setFillStyles(t,this)),this._render(t),this._drawClipPath(t),this.fill=i,this.stroke=n},_drawClipPath:function(t){var e=this.clipPath;e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){e.stroke&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,t.strokeStyle=e.stroke.toLive?e.stroke.toLive(t,this):e.stroke)},_setFillStyles:function(t,e){e.fill&&(t.fillStyle=e.fill.toLive?e.fill.toLive(t,this):e.fill)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e,i){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),a?t.setLineDash(e):i&&i(t))},_renderControls:function(t,i){var n,r,o,a=this.getViewportTransform(),c=this.calcTransformMatrix();r=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,o=void 0!==i.hasControls?i.hasControls:this.hasControls,c=e.util.multiplyTransformMatrices(a,c),n=e.util.qrDecompose(c),t.save(),t.translate(n.translateX,n.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),i.forActiveSelection?(t.rotate(s(n.angle)),r&&this.drawBordersInGroup(t,n,i)):(t.rotate(s(this.angle)),r&&this.drawBorders(t,i)),o&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,n=this.shadow,r=this.canvas,o=r&&r.viewportTransform[0]||1,s=r&&r.viewportTransform[3]||1;i=n.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),r&&r._isRetinaScaling()&&(o*=e.devicePixelRatio,s*=e.devicePixelRatio),t.shadowColor=n.color,t.shadowBlur=n.blur*e.browserShadowBlurConstant*(o+s)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=n.offsetX*o*i.scaleX,t.shadowOffsetY=n.offsetY*s*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,n=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,n,r):t.transform(1,0,0,1,n,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:n,offsetY:r}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._applyPatternGradientTransform(t,this.fill),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray,this._renderDashedStroke),this.stroke.toLive&&"percentage"===this.stroke.gradientUnits?this._applyPatternForTransformedGradient(t,this.stroke):this._applyPatternGradientTransform(t,this.stroke),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var n,r=this._limitCacheSize(this._getCacheCanvasDimensions()),o=e.util.createCanvasElement(),s=this.canvas.getRetinaScaling(),a=r.x/this.scaleX/s,c=r.y/this.scaleY/s;o.width=a,o.height=c,(n=o.getContext("2d")).beginPath(),n.moveTo(0,0),n.lineTo(a,0),n.lineTo(a,c),n.lineTo(0,c),n.closePath(),n.translate(a/2,c/2),n.scale(r.zoomX/this.scaleX/s,r.zoomY/this.scaleY/s),this._applyPatternGradientTransform(n,i),n.fillStyle=i.toLive(t),n.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(s*this.scaleX/r.zoomX,s*this.scaleY/r.zoomY),t.strokeStyle=n.createPattern(o,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var n=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(n,t):e.Object._fromObject("Object",n,t)},cloneAsImage:function(t,i){var n=this.toCanvasElement(i);return t&&t(new e.Image(n)),this},toCanvasElement:function(t){t||(t={});var i=e.util,n=i.saveObjectTransform(this),r=this.group,o=this.shadow,s=Math.abs,a=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var c,u,h,l,f=e.util.createCanvasElement(),d=this.getBoundingRect(!0,!0),p=this.shadow,g={x:0,y:0};p&&(u=p.blur,c=p.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),g.x=2*Math.round(s(p.offsetX)+u)*s(c.scaleX),g.y=2*Math.round(s(p.offsetY)+u)*s(c.scaleY)),h=d.width+g.x,l=d.height+g.y,f.width=Math.ceil(h),f.height=Math.ceil(l);var v=new e.StaticCanvas(f,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(v.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(v.width/2,v.height/2),"center","center");var y=this.canvas;v.add(this);var m=v.toCanvasElement(a||1,t);return this.shadow=o,this.set("canvas",y),r&&(this.group=r),this.set(n).setCoords(),v._objects=[],v.dispose(),v=null,m},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},setGradient:function(t,i){i||(i={});var n={colorStops:[]};return n.type=i.type||(i.r1||i.r2?"radial":"linear"),n.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},n.gradientUnits=i.gradientUnits||"pixels",(i.r1||i.r2)&&(n.coords.r1=i.r1,n.coords.r2=i.r2),n.gradientTransform=i.gradientTransform,e.Gradient.prototype.addColorStop.call(n,i.colorStops),this.set(t,e.Gradient.forObject(this,n))},setPatternFill:function(t,i){return this.set("fill",new e.Pattern(t,i))},setShadow:function(t){return this.set("shadow",t?new e.Shadow(t):null)},setColor:function(t){return this.set("fill",t),this},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var n=new e.Point(i.x,i.y),r=this._getLeftTopCoords();return this.angle&&(n=e.util.rotatePoint(n,r,s(-this.angle))),{x:n.x-r.x,y:n.y-r.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object._fromObject=function(t,i,r,o){var s=e[t];i=n(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjects([i.clipPath],(function(t){i.clipPath=t[0];var e=o?new s(i[o],i):new s(i);r&&r(e)}))}))},e.Object.__uid=0)}(e),m=S.util.degreesToRadians,b={left:-.5,center:0,right:.5},_={top:-.5,center:0,bottom:.5},S.util.object.extend(S.Object.prototype,{translateToGivenOrigin:function(t,e,i,n,r){var o,s,a,c=t.x,u=t.y;return"string"==typeof e?e=b[e]:e-=.5,"string"==typeof n?n=b[n]:n-=.5,"string"==typeof i?i=_[i]:i-=.5,"string"==typeof r?r=_[r]:r-=.5,s=r-i,((o=n-e)||s)&&(a=this._getTransformedDimensions(),c=t.x+o*a.x,u=t.y+s*a.y),new S.Point(c,u)},translateToCenterPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?S.util.rotatePoint(n,t,m(this.angle)):n},translateToOriginPoint:function(t,e,i){var n=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?S.util.rotatePoint(n,t,m(this.angle)):n},getCenterPoint:function(){var t=new S.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var n,r,o=this.getCenterPoint();return n=void 0!==e&&void 0!==i?this.translateToGivenOrigin(o,"center","center",e,i):new S.Point(this.left,this.top),r=new S.Point(t.x,t.y),this.angle&&(r=S.util.rotatePoint(r,o,-m(this.angle))),r.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var n=this.translateToCenterPoint(t,e,i),r=this.translateToOriginPoint(n,this.originX,this.originY);this.set("left",r.x),this.set("top",r.y)},adjustPosition:function(t){var e,i,n=m(this.angle),r=this.getScaledWidth(),o=S.util.cos(n)*r,s=S.util.sin(n)*r;e="string"==typeof this.originX?b[this.originX]:this.originX-.5,i="string"==typeof t?b[t]:t-.5,this.left+=o*(i-e),this.top+=s*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=S.util.degreesToRadians,e=S.util.multiplyTransformMatrices,i=S.util.transformPoint;S.util.object.extend(S.Object.prototype,{oCoords:null,aCoords:null,ownMatrixCache:null,matrixCache:null,getCoords:function(t,e){this.oCoords||this.setCoords();var i=t?this.aCoords:this.oCoords;return function(t){return[new S.Point(t.tl.x,t.tl.y),new S.Point(t.tr.x,t.tr.y),new S.Point(t.br.x,t.br.y),new S.Point(t.bl.x,t.bl.y)]}(e?this.calcCoords(t):i)},intersectsWithRect:function(t,e,i,n){var r=this.getCoords(i,n);return"Intersection"===S.Intersection.intersectPolygonRectangle(r,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===S.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var n=this.getCoords(e,i),r=0,o=t._getImageLines(i?t.calcCoords(e):e?t.aCoords:t.oCoords);r<4;r++)if(!t.containsPoint(n[r],o))return!1;return!0},isContainedWithinRect:function(t,e,i,n){var r=this.getBoundingRect(i,n);return r.left>=t.x&&r.left+r.width<=e.x&&r.top>=t.y&&r.top+r.height<=e.y},containsPoint:function(t,e,i,n){e=e||this._getImageLines(n?this.calcCoords(i):i?this.aCoords:this.oCoords);var r=this._findCrossPoints(t,e);return 0!==r&&r%2==1},isOnScreen:function(t){if(!this.canvas)return!1;for(var e,i=this.canvas.vptCoords.tl,n=this.canvas.vptCoords.br,r=this.getCoords(!0,t),o=0;o<4;o++)if((e=r[o]).x<=n.x&&e.x>=i.x&&e.y<=n.y&&e.y>=i.y)return!0;return!!this.intersectsWithRect(i,n,!0,t)||this._containsCenterOfCanvas(i,n,t)},_containsCenterOfCanvas:function(t,e,i){var n={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(n,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,n,r,o=0;for(var s in e)if(!((r=e[s]).o.y<t.y&&r.d.y<t.y||r.o.y>=t.y&&r.d.y>=t.y||(r.o.x===r.d.x&&r.o.x>=t.x?n=r.o.x:(0,i=(r.d.y-r.o.y)/(r.d.x-r.o.x),n=-(t.y-0*t.x-(r.o.y-i*r.o.x))/(0-i)),n>=t.x&&(o+=1),2!==o)))break;return o},getBoundingRect:function(t,e){var i=this.getCoords(t,e);return S.util.makeBoundingBoxFromPoints(i)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t},scale:function(t){return this._set("scaleX",t),this._set("scaleY",t),this.setCoords()},scaleToWidth:function(t,e){var i=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(t/this.width/i)},scaleToHeight:function(t,e){var i=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(t/this.height/i)},calcCoords:function(n){var r=this._calcRotateMatrix(),o=this._calcTranslateMatrix(),s=e(o,r),a=this.getViewportTransform(),c=n?s:e(a,s),u=this._getTransformedDimensions(),h=u.x/2,l=u.y/2,f=i({x:-h,y:-l},c),d=i({x:h,y:-l},c),p=i({x:-h,y:l},c),g=i({x:h,y:l},c);if(!n){var v=this.padding,y=t(this.angle),m=S.util.cos(y),b=S.util.sin(y),_=m*v,x=b*v,w=_+x,C=_-x;v&&(f.x-=C,f.y-=w,d.x+=w,d.y-=C,p.x-=w,p.y+=C,g.x+=C,g.y+=w);var T=new S.Point((f.x+p.x)/2,(f.y+p.y)/2),O=new S.Point((d.x+f.x)/2,(d.y+f.y)/2),j=new S.Point((g.x+d.x)/2,(g.y+d.y)/2),P=new S.Point((g.x+p.x)/2,(g.y+p.y)/2),E=new S.Point(O.x+b*this.rotatingPointOffset,O.y-m*this.rotatingPointOffset)}var k={tl:f,tr:d,br:g,bl:p};return n||(k.ml=T,k.mt=O,k.mr=j,k.mb=P,k.mtr=E),k},setCoords:function(t,e){return this.oCoords=this.calcCoords(t),e||(this.aCoords=this.calcCoords(!0)),t||this._setCornerCoords&&this._setCornerCoords(),this},_calcRotateMatrix:function(){return S.util.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var t=this.getCenterPoint();return[1,0,0,1,t.x,t.y]},transformMatrixKey:function(t){var e="";return!t&&this.group&&(e=this.group.transformMatrixKey(t)+"_"),e+this.top+"_"+this.left+"_"+this.scaleX+"_"+this.scaleY+"_"+this.skewX+"_"+this.skewY+"_"+this.angle+"_"+this.originX+"_"+this.originY+"_"+this.width+"_"+this.height+"_"+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(t){if(t)return this.calcOwnMatrix();var i=this.transformMatrixKey(),n=this.matrixCache||(this.matrixCache={});if(n.key===i)return n.value;var r=this.calcOwnMatrix();return this.group&&(r=e(this.group.calcTransformMatrix(),r)),n.key=i,n.value=r,r},calcOwnMatrix:function(){var t=this.transformMatrixKey(!0),e=this.ownMatrixCache||(this.ownMatrixCache={});if(e.key===t)return e.value;var i=this._calcTranslateMatrix();return this.translateX=i[4],this.translateY=i[5],e.key=t,e.value=S.util.composeMatrix(this),e.value},_calcDimensionsTransformMatrix:function(t,e,i){return S.util.calcDimensionsMatrix({skewX:t,skewY:e,scaleX:this.scaleX*(i&&this.flipX?-1:1),scaleY:this.scaleY*(i&&this.flipY?-1:1)})},_getNonTransformedDimensions:function(){var t=this.strokeWidth;return{x:this.width+t,y:this.height+t}},_getTransformedDimensions:function(t,e){void 0===t&&(t=this.skewX),void 0===e&&(e=this.skewY);var i,n,r=this._getNonTransformedDimensions(),o=0===t&&0===e;if(this.strokeUniform?(i=this.width,n=this.height):(i=r.x,n=r.y),o)return this._finalizeDimensions(i*this.scaleX,n*this.scaleY);var s=[{x:-(i/=2),y:-(n/=2)},{x:i,y:-n},{x:-i,y:n},{x:i,y:n}],a=S.util.calcDimensionsMatrix({scaleX:this.scaleX,scaleY:this.scaleY,skewX:t,skewY:e}),c=S.util.makeBoundingBoxFromPoints(s,a);return this._finalizeDimensions(c.width,c.height)},_finalizeDimensions:function(t,e){return this.strokeUniform?{x:t+this.strokeWidth,y:e+this.strokeWidth}:{x:t,y:e}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform(),e=this._getTransformedDimensions();return S.util.transformPoint(e,t,!0).scalarAdd(2*this.padding)}})}(),S.util.object.extend(S.Object.prototype,{sendToBack:function(){return this.group?S.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?S.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(t){return this.group?S.StaticCanvas.prototype.sendBackwards.call(this.group,this,t):this.canvas&&this.canvas.sendBackwards(this,t),this},bringForward:function(t){return this.group?S.StaticCanvas.prototype.bringForward.call(this.group,this,t):this.canvas&&this.canvas.bringForward(this,t),this},moveTo:function(t){return this.group&&"activeSelection"!==this.group.type?S.StaticCanvas.prototype.moveTo.call(this.group,this,t):this.canvas&&this.canvas.moveTo(this,t),this}}),function(){function t(t,e){if(e){if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new S.Color(e),n=t+": "+i.toRgb()+"; ",r=i.getAlpha();return 1!==r&&(n+=t+"-opacity: "+r.toString()+"; "),n}return t+": none; "}var e=S.util.toFixed;S.util.object.extend(S.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule?this.fillRule:"nonzero",n=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):"none",o=this.strokeDashOffset?this.strokeDashOffset:"0",s=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",c=this.strokeMiterLimit?this.strokeMiterLimit:"4",u=void 0!==this.opacity?this.opacity:"1",h=this.visible?"":" visibility: hidden;",l=e?"":this.getSvgFilter(),f=t("fill",this.fill);return[t("stroke",this.stroke),"stroke-width: ",n,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",s,"; ","stroke-dashoffset: ",o,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",c,"; ",f,"fill-rule: ",i,"; ","opacity: ",u,";",l,h].join("")},getSvgSpanStyles:function(e,i){var n=e.fontFamily?"font-family: "+(-1===e.fontFamily.indexOf("'")&&-1===e.fontFamily.indexOf('"')?"'"+e.fontFamily+"'":e.fontFamily)+"; ":"",r=e.strokeWidth?"stroke-width: "+e.strokeWidth+"; ":"",o=(n=n,e.fontSize?"font-size: "+e.fontSize+"px; ":""),s=e.fontStyle?"font-style: "+e.fontStyle+"; ":"",a=e.fontWeight?"font-weight: "+e.fontWeight+"; ":"",c=e.fill?t("fill",e.fill):"",u=e.stroke?t("stroke",e.stroke):"",h=this.getSvgTextDecoration(e);return h&&(h="text-decoration: "+h+"; "),[u,r,n,o,s,a,h,c,e.deltaY?"baseline-shift: "+-e.deltaY+"; ":"",i?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(t){return["overline","underline","line-through"].filter((function(e){return t[e.replace("-","")]})).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(t,e){var i=t?this.calcTransformMatrix():this.calcOwnMatrix();return'transform="'+S.util.matrixToSVG(i)+(e||"")+this.getSvgTransformMatrix()+'" '},getSvgTransformMatrix:function(){return this.transformMatrix?" "+S.util.matrixToSVG(this.transformMatrix):""},_setSVGBg:function(t){if(this.backgroundColor){var i=S.Object.NUM_FRACTION_DIGITS;t.push("\t\t<rect ",this._getFillAttributes(this.backgroundColor),' x="',e(-this.width/2,i),'" y="',e(-this.height/2,i),'" width="',e(this.width,i),'" height="',e(this.height,i),'"></rect>\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}).reviver,n=e.additionalTransform||"",r=[this.getSvgTransform(!0,n),this.getSvgCommons()].join(""),o=t.indexOf("COMMON_PARTS");return t[o]=r,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,n,r=(e=e||{}).noStyle,o=e.reviver,s=r?"":'style="'+this.getSvgStyles()+'" ',a=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",c=this.clipPath,u=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=c&&c.absolutePositioned,l=this.stroke,f=this.fill,d=this.shadow,p=[],g=t.indexOf("COMMON_PARTS"),v=e.additionalTransform;return c&&(c.clipPathId="CLIPPATH_"+S.Object.__uid++,n='<clipPath id="'+c.clipPathId+'" >\n'+c.toClipPathSVG(o)+"</clipPath>\n"),h&&p.push("<g ",a,this.getSvgCommons()," >\n"),p.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons()," >\n"),i=[s,u,r?"":this.addPaintOrder()," ",v?'transform="'+v+'" ':""].join(""),t[g]=i,f&&f.toLive&&p.push(f.toSVG(this)),l&&l.toLive&&p.push(l.toSVG(this)),d&&p.push(d.toSVG(this)),c&&p.push(n),p.push(t.join("")),p.push("</g>\n"),h&&p.push("</g>\n"),o?o(p.join("")):p.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=S.util.object.extend;function e(e,i,n){var r={};n.forEach((function(t){r[t]=e[t]})),t(e[i],r,!0)}S.util.object.extend(S.Object.prototype,{hasStateChanged:function(t){var e="_"+(t=t||"stateProperties");return Object.keys(this[e]).length<this[t].length||!function t(e,i,n){if(e===i)return!0;if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(var r=0,o=e.length;r<o;r++)if(!t(e[r],i[r]))return!1;return!0}if(e&&"object"==typeof e){var s,a=Object.keys(e);if(!i||"object"!=typeof i||!n&&a.length!==Object.keys(i).length)return!1;for(r=0,o=a.length;r<o;r++)if("canvas"!==(s=a[r])&&!t(e[s],i[s]))return!1;return!0}}(this[e],this,!0)},saveState:function(t){var i=t&&t.propertySet||"stateProperties",n="_"+i;return this[n]?(e(this,n,this[i]),t&&t.stateProperties&&e(this,n,t.stateProperties),this):this.setupState(t)},setupState:function(t){var e=(t=t||{}).propertySet||"stateProperties";return t.propertySet=e,this["_"+e]={},this.saveState(t),this}})}(),function(){var t=S.util.degreesToRadians;S.util.object.extend(S.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(t){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var e,i,n=t.x,r=t.y;for(var o in this.__corner=0,this.oCoords)if(this.isControlVisible(o)&&("mtr"!==o||this.hasRotatingPoint)&&(!this.get("lockUniScaling")||"mt"!==o&&"mr"!==o&&"mb"!==o&&"ml"!==o)&&(i=this._getImageLines(this.oCoords[o].corner),0!==(e=this._findCrossPoints({x:n,y:r},i))&&e%2==1))return this.__corner=o,o;return!1},_setCornerCoords:function(){var e,i,n=this.oCoords,r=t(45-this.angle),o=.707106*this.cornerSize,s=o*S.util.cos(r),a=o*S.util.sin(r);for(var c in n)e=n[c].x,i=n[c].y,n[c].corner={tl:{x:e-a,y:i-s},tr:{x:e+s,y:i-a},bl:{x:e-s,y:i+a},br:{x:e+a,y:i+s}}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),n=this._calculateCurrentDimensions(),r=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/r[0],1/r[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-n.x/2,-n.y/2,n.x,n.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=this.borderScaleFactor,r=i.x+n,o=i.y+n,s=void 0!==e.hasRotatingPoint?e.hasRotatingPoint:this.hasRotatingPoint,a=void 0!==e.hasControls?e.hasControls:this.hasControls,c=void 0!==e.rotatingPointOffset?e.rotatingPointOffset:this.rotatingPointOffset;if(t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray,null),t.strokeRect(-r/2,-o/2,r,o),s&&this.isControlVisible("mtr")&&a){var u=-o/2;t.beginPath(),t.moveTo(0,u),t.lineTo(0,u-c),t.stroke()}return t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var n={x:this.width,y:this.height},r=S.util.composeMatrix({scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX}),o=S.util.transformPoint(n,r),s=this.strokeWidth,a=this.borderScaleFactor,c=o.x+s*(this.strokeUniform?this.canvas.getZoom():e.scaleX)+a,u=o.y+s*(this.strokeUniform?this.canvas.getZoom():e.scaleY)+a;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray,null),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-c/2,-u/2,c,u),t.restore(),this},drawControls:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),n=i.x,r=i.y,o=e.cornerSize||this.cornerSize,s=-(n+o)/2,a=-(r+o)/2,c=void 0!==e.transparentCorners?e.transparentCorners:this.transparentCorners,u=void 0!==e.hasRotatingPoint?e.hasRotatingPoint:this.hasRotatingPoint,h=c?"stroke":"fill";return t.save(),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray,null),this._drawControl("tl",t,h,s,a,e),this._drawControl("tr",t,h,s+n,a,e),this._drawControl("bl",t,h,s,a+r,e),this._drawControl("br",t,h,s+n,a+r,e),this.get("lockUniScaling")||(this._drawControl("mt",t,h,s+n/2,a,e),this._drawControl("mb",t,h,s+n/2,a+r,e),this._drawControl("mr",t,h,s+n,a+r/2,e),this._drawControl("ml",t,h,s,a+r/2,e)),u&&this._drawControl("mtr",t,h,s+n/2,a-this.rotatingPointOffset,e),t.restore(),this},_drawControl:function(t,e,i,n,r,o){if(o=o||{},this.isControlVisible(t)){var s=this.cornerSize,a=!this.transparentCorners&&this.cornerStrokeColor;switch(o.cornerStyle||this.cornerStyle){case"circle":e.beginPath(),e.arc(n+s/2,r+s/2,s/2,0,2*Math.PI,!1),e[i](),a&&e.stroke();break;default:this.transparentCorners||e.clearRect(n,r,s,s),e[i+"Rect"](n,r,s,s),a&&e.strokeRect(n,r,s,s)}}},isControlVisible:function(t){return this._getControlsVisibility()[t]},setControlVisible:function(t,e){return this._getControlsVisibility()[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},_getControlsVisibility:function(){return this._controlsVisibility||(this._controlsVisibility={tl:!0,tr:!0,br:!0,bl:!0,ml:!0,mt:!0,mr:!0,mb:!0,mtr:!0}),this._controlsVisibility},onDeselect:function(){},onSelect:function(){}})}(),S.util.object.extend(S.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,o=this;return S.util.animate({startValue:t.left,endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),o.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}}),this},fxCenterObjectV:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,o=this;return S.util.animate({startValue:t.top,endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),o.requestRenderAll(),r()},onComplete:function(){t.setCoords(),n()}}),this},fxRemove:function(t,e){var i=function(){},n=(e=e||{}).onComplete||i,r=e.onChange||i,o=this;return S.util.animate({startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),o.requestRenderAll(),r()},onComplete:function(){o.remove(t),n()}}),this}}),S.util.object.extend(S.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[];for(t in arguments[0])i.push(t);for(var n=0,r=i.length;n<r;n++)t=i[n],e=n!==r-1,this._animate(t,arguments[0][t],arguments[1],e)}else this._animate.apply(this,arguments);return this},_animate:function(t,e,i,n){var r,o=this;e=e.toString(),i=i?S.util.object.clone(i):{},~t.indexOf(".")&&(r=t.split("."));var s=r?this.get(r[0])[r[1]]:this.get(t);"from"in i||(i.from=s),e=~e.indexOf("=")?s+parseFloat(e.replace("=","")):parseFloat(e),S.util.animate({startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(){return i.abort.call(o)},onChange:function(e,s,a){r?o[r[0]][r[1]]=e:o.set(t,e),n||i.onChange&&i.onChange(e,s,a)},onComplete:function(t,e,r){n||(o.setCoords(),i.onComplete&&i.onComplete(t,e,r))}})}}),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.object.clone,r={x1:1,x2:1,y1:1,y2:1},o=e.StaticCanvas.supports("setLineDash");function s(t,e){var i=t.origin,n=t.axis1,r=t.axis2,o=t.dimension,s=e.nearest,a=e.center,c=e.farthest;return function(){switch(this.get(i)){case s:return Math.min(this.get(n),this.get(r));case a:return Math.min(this.get(n),this.get(r))+.5*this.get(o);case c:return Math.max(this.get(n),this.get(r))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==r[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){if(t.beginPath(),!this.strokeDashArray||this.strokeDashArray&&o){var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2)}t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_renderDashedStroke:function(t){var i=this.calcLinePoints();t.beginPath(),e.util.drawDashedLine(t,i.x1,i.y1,i.x2,i.y2,this.strokeDashArray),t.closePath()},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,n=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:n,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',t.x1,'" y1="',t.y1,'" x2="',t.x2,'" y2="',t.y2,'" />\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,n,r){r=r||{};var o=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),s=[o.x1||0,o.y1||0,o.x2||0,o.y2||0];n(new e.Line(s,i(o,r)))},e.Line.fromObject=function(t,i){var r=n(t,!0);r.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",r,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.PI;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:2*i,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,n=(this.endAngle-this.startAngle)%(2*i);if(0===n)t=["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',this.radius,'" />\n'];else{var r=e.util.cos(this.startAngle)*this.radius,o=e.util.sin(this.startAngle)*this.radius,s=e.util.cos(this.endAngle)*this.radius,a=e.util.sin(this.endAngle)*this.radius,c=n>i?"1":"0";t=['<path d="M '+r+" "+o," A "+this.radius+" "+this.radius," 0 ",+c+" 1"," "+s+" "+a,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,this.startAngle,this.endAngle,!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var n,r=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(n=r)&&n.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");r.left=(r.left||0)-r.radius,r.top=(r.top||0)-r.radius,i(new e.Circle(r))},e.Circle.fromObject=function(t,i){return e.Object._fromObject("Circle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_renderDashedStroke:function(t){var i=this.width/2,n=this.height/2;t.beginPath(),e.util.drawDashedLine(t,-i,n,0,-n,this.strokeDashArray),e.util.drawDashedLine(t,0,-n,i,n,this.strokeDashArray),e.util.drawDashedLine(t,i,n,-i,n,this.strokeDashArray),t.closePath()},_toSVG:function(){var t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',[-t+" "+e,"0 "+-e,t+" "+e].join(","),'" />']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,'" />\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var n=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);n.left=(n.left||0)-n.rx,n.top=(n.top||0)-n.ry,i(new e.Ellipse(n))},e.Ellipse.fromObject=function(t,i){return e.Object._fromObject("Ellipse",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,n=this.width,r=this.height,o=-this.width/2,s=-this.height/2,a=0!==e||0!==i,c=.4477152502;t.beginPath(),t.moveTo(o+e,s),t.lineTo(o+n-e,s),a&&t.bezierCurveTo(o+n-c*e,s,o+n,s+c*i,o+n,s+i),t.lineTo(o+n,s+r-i),a&&t.bezierCurveTo(o+n,s+r-c*i,o+n-c*e,s+r,o+n-e,s+r),t.lineTo(o+e,s+r),a&&t.bezierCurveTo(o+c*e,s+r,o,s+r-c*i,o,s+r-i),t.lineTo(o,s+i),a&&t.bezierCurveTo(o,s+c*i,o+c*e,s,o+e,s),t.closePath(),this._renderPaintInOrder(t)},_renderDashedStroke:function(t){var i=-this.width/2,n=-this.height/2,r=this.width,o=this.height;t.beginPath(),e.util.drawDashedLine(t,i,n,i+r,n,this.strokeDashArray),e.util.drawDashedLine(t,i+r,n,i+r,n+o,this.strokeDashArray),e.util.drawDashedLine(t,i+r,n+o,i,n+o,this.strokeDashArray),e.util.drawDashedLine(t,i,n+o,i,n,this.strokeDashArray),t.closePath()},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<rect ","COMMON_PARTS",'x="',-this.width/2,'" y="',-this.height/2,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,'" />\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,n,r){if(!t)return n(null);r=r||{};var o=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);o.left=o.left||0,o.top=o.top||0,o.height=o.height||0,o.width=o.width||0;var s=new e.Rect(i(r?e.util.object.clone(r):{},o));s.visible=s.visible&&s.width>0&&s.height>0,n(s)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.util.array.min,r=e.util.array.max,o=e.util.toFixed;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t);this.width=i.width,this.height=i.height,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2,y:i.top-this.strokeWidth/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2,y:i.top+this.height/2}},_calcDimensions:function(){var t=this.points,e=n(t,"x")||0,i=n(t,"y")||0;return{left:e,top:i,width:(r(t,"x")||0)-e,height:(r(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,n=this.pathOffset.y,r=e.Object.NUM_FRACTION_DIGITS,s=0,a=this.points.length;s<a;s++)t.push(o(this.points[s].x-i,r),",",o(this.points[s].y-n,r)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',t.join(""),'" />\n']},commonRender:function(t){var e,i=this.points.length,n=this.pathOffset.x,r=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-n,this.points[0].y-r);for(var o=0;o<i;o++)e=this.points[o],t.lineTo(e.x-n,e.y-r);return!0},_render:function(t){this.commonRender(t)&&this._renderPaintInOrder(t)},_renderDashedStroke:function(t){var i,n;t.beginPath();for(var r=0,o=this.points.length;r<o;r++)i=this.points[r],n=this.points[r+1]||i,e.util.drawDashedLine(t,i.x,i.y,n.x,n.y,this.strokeDashArray)},complexity:function(){return this.get("points").length}}),e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polyline.fromElementGenerator=function(t){return function(n,r,o){if(!n)return r(null);o||(o={});var s=e.parsePointsAttribute(n.getAttribute("points")),a=e.parseAttributes(n,e[t].ATTRIBUTE_NAMES);a.fromSVG=!0,r(new e[t](s,i(a,o)))}},e.Polyline.fromElement=e.Polyline.fromElementGenerator("Polyline"),e.Polyline.fromObject=function(t,i){return e.Object._fromObject("Polyline",t,i,"points")})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Polygon?e.warn("fabric.Polygon is already defined"):(e.Polygon=e.util.createClass(e.Polyline,{type:"polygon",_render:function(t){this.commonRender(t)&&(t.closePath(),this._renderPaintInOrder(t))},_renderDashedStroke:function(t){this.callSuper("_renderDashedStroke",t),t.closePath()}}),e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polygon.fromElement=e.Polyline.fromElementGenerator("Polygon"),e.Polygon.fromObject=function(t,i){return e.Object._fromObject("Polygon",t,i,"points")})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,n=e.util.array.max,r=e.util.object.extend,o=Object.prototype.toString,s=e.util.drawArc,a=e.util.toFixed,c={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},u={m:"l",M:"L"};e.Path?e.warn("fabric.Path is already defined"):(e.Path=e.util.createClass(e.Object,{type:"path",path:null,cacheProperties:e.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:e.Object.prototype.stateProperties.concat("path"),initialize:function(t,i){i=i||{},this.callSuper("initialize",i),t||(t=[]);var n="[object Array]"===o.call(t);this.path=n?t:t.match&&t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi),this.path&&(n||(this.path=this._parsePath()),e.Polyline.prototype._setPositionDimensions.call(this,i))},_renderPathCommands:function(t){var e,i,n,r=null,o=0,a=0,c=0,u=0,h=0,l=0,f=-this.pathOffset.x,d=-this.pathOffset.y;t.beginPath();for(var p=0,g=this.path.length;p<g;++p){switch((e=this.path[p])[0]){case"l":c+=e[1],u+=e[2],t.lineTo(c+f,u+d);break;case"L":c=e[1],u=e[2],t.lineTo(c+f,u+d);break;case"h":c+=e[1],t.lineTo(c+f,u+d);break;case"H":c=e[1],t.lineTo(c+f,u+d);break;case"v":u+=e[1],t.lineTo(c+f,u+d);break;case"V":u=e[1],t.lineTo(c+f,u+d);break;case"m":o=c+=e[1],a=u+=e[2],t.moveTo(c+f,u+d);break;case"M":o=c=e[1],a=u=e[2],t.moveTo(c+f,u+d);break;case"c":i=c+e[5],n=u+e[6],h=c+e[3],l=u+e[4],t.bezierCurveTo(c+e[1]+f,u+e[2]+d,h+f,l+d,i+f,n+d),c=i,u=n;break;case"C":c=e[5],u=e[6],h=e[3],l=e[4],t.bezierCurveTo(e[1]+f,e[2]+d,h+f,l+d,c+f,u+d);break;case"s":i=c+e[3],n=u+e[4],null===r[0].match(/[CcSs]/)?(h=c,l=u):(h=2*c-h,l=2*u-l),t.bezierCurveTo(h+f,l+d,c+e[1]+f,u+e[2]+d,i+f,n+d),h=c+e[1],l=u+e[2],c=i,u=n;break;case"S":i=e[3],n=e[4],null===r[0].match(/[CcSs]/)?(h=c,l=u):(h=2*c-h,l=2*u-l),t.bezierCurveTo(h+f,l+d,e[1]+f,e[2]+d,i+f,n+d),c=i,u=n,h=e[1],l=e[2];break;case"q":i=c+e[3],n=u+e[4],h=c+e[1],l=u+e[2],t.quadraticCurveTo(h+f,l+d,i+f,n+d),c=i,u=n;break;case"Q":i=e[3],n=e[4],t.quadraticCurveTo(e[1]+f,e[2]+d,i+f,n+d),c=i,u=n,h=e[1],l=e[2];break;case"t":i=c+e[1],n=u+e[2],null===r[0].match(/[QqTt]/)?(h=c,l=u):(h=2*c-h,l=2*u-l),t.quadraticCurveTo(h+f,l+d,i+f,n+d),c=i,u=n;break;case"T":i=e[1],n=e[2],null===r[0].match(/[QqTt]/)?(h=c,l=u):(h=2*c-h,l=2*u-l),t.quadraticCurveTo(h+f,l+d,i+f,n+d),c=i,u=n;break;case"a":s(t,c+f,u+d,[e[1],e[2],e[3],e[4],e[5],e[6]+c+f,e[7]+u+d]),c+=e[6],u+=e[7];break;case"A":s(t,c+f,u+d,[e[1],e[2],e[3],e[4],e[5],e[6]+f,e[7]+d]),c=e[6],u=e[7];break;case"z":case"Z":c=o,u=a,t.closePath()}r=e}},_render:function(t){this._renderPathCommands(t),this._renderPaintInOrder(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){return r(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["<path ","COMMON_PARTS",'d="',this.path.map((function(t){return t.join(" ")})).join(" "),'" stroke-linecap="round" ',"/>\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+a(-this.pathOffset.x,t)+", "+a(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_parsePath:function(){for(var t,i,n,r,o,s=[],a=[],h=e.rePathCommand,l=0,f=this.path.length;l<f;l++){for(r=(t=this.path[l]).slice(1).trim(),a.length=0;n=h.exec(r);)a.push(n[0]);o=[t.charAt(0)];for(var d=0,p=a.length;d<p;d++)i=parseFloat(a[d]),isNaN(i)||o.push(i);var g=o[0],v=c[g.toLowerCase()],y=u[g]||g;if(o.length-1>v)for(var m=1,b=o.length;m<b;m+=v)s.push([g].concat(o.slice(m,m+v))),g=y;else s.push(o)}return s},_calcDimensions:function(){for(var t,r,o,s,a=[],c=[],u=null,h=0,l=0,f=0,d=0,p=0,g=0,v=0,y=this.path.length;v<y;++v){switch((t=this.path[v])[0]){case"l":f+=t[1],d+=t[2],s=[];break;case"L":f=t[1],d=t[2],s=[];break;case"h":f+=t[1],s=[];break;case"H":f=t[1],s=[];break;case"v":d+=t[1],s=[];break;case"V":d=t[1],s=[];break;case"m":h=f+=t[1],l=d+=t[2],s=[];break;case"M":h=f=t[1],l=d=t[2],s=[];break;case"c":r=f+t[5],o=d+t[6],p=f+t[3],g=d+t[4],s=e.util.getBoundsOfCurve(f,d,f+t[1],d+t[2],p,g,r,o),f=r,d=o;break;case"C":p=t[3],g=t[4],s=e.util.getBoundsOfCurve(f,d,t[1],t[2],p,g,t[5],t[6]),f=t[5],d=t[6];break;case"s":r=f+t[3],o=d+t[4],null===u[0].match(/[CcSs]/)?(p=f,g=d):(p=2*f-p,g=2*d-g),s=e.util.getBoundsOfCurve(f,d,p,g,f+t[1],d+t[2],r,o),p=f+t[1],g=d+t[2],f=r,d=o;break;case"S":r=t[3],o=t[4],null===u[0].match(/[CcSs]/)?(p=f,g=d):(p=2*f-p,g=2*d-g),s=e.util.getBoundsOfCurve(f,d,p,g,t[1],t[2],r,o),f=r,d=o,p=t[1],g=t[2];break;case"q":r=f+t[3],o=d+t[4],p=f+t[1],g=d+t[2],s=e.util.getBoundsOfCurve(f,d,p,g,p,g,r,o),f=r,d=o;break;case"Q":p=t[1],g=t[2],s=e.util.getBoundsOfCurve(f,d,p,g,p,g,t[3],t[4]),f=t[3],d=t[4];break;case"t":r=f+t[1],o=d+t[2],null===u[0].match(/[QqTt]/)?(p=f,g=d):(p=2*f-p,g=2*d-g),s=e.util.getBoundsOfCurve(f,d,p,g,p,g,r,o),f=r,d=o;break;case"T":r=t[1],o=t[2],null===u[0].match(/[QqTt]/)?(p=f,g=d):(p=2*f-p,g=2*d-g),s=e.util.getBoundsOfCurve(f,d,p,g,p,g,r,o),f=r,d=o;break;case"a":s=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6]+f,t[7]+d),f+=t[6],d+=t[7];break;case"A":s=e.util.getBoundsOfArc(f,d,t[1],t[2],t[3],t[4],t[5],t[6],t[7]),f=t[6],d=t[7];break;case"z":case"Z":f=h,d=l}u=t,s.forEach((function(t){a.push(t.x),c.push(t.y)})),a.push(f),c.push(d)}var m=i(a)||0,b=i(c)||0;return{left:m,top:b,width:(n(a)||0)-m,height:(n(c)||0)-b}}}),e.Path.fromObject=function(t,i){if("string"==typeof t.sourcePath){var n=t.sourcePath;e.loadSVGFromURL(n,(function(e){var n=e[0];n.setOptions(t),i&&i(n)}))}else e.Object._fromObject("Path",t,i,"path")},e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]),e.Path.fromElement=function(t,i,n){var o=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);o.fromSVG=!0,i(new e.Path(o.d,r(o,n)))})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,n=e.util.array.max;e.Group||(e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,e,i){e=e||{},this._objects=[],i&&this.callSuper("initialize",e),this._objects=t||[];for(var n=this._objects.length;n--;)this._objects[n].group=this;if(i)this._updateObjectsACoords();else{var r=e&&e.centerPoint;void 0!==e.originX&&(this.originX=e.originX),void 0!==e.originY&&(this.originY=e.originY),r||this._calcBounds(),this._updateObjectsCoords(r),delete e.centerPoint,this.callSuper("initialize",e)}this.setCoords()},_updateObjectsACoords:function(){for(var t=this._objects.length;t--;)this._objects[t].setCoords(!0,!0)},_updateObjectsCoords:function(t){t=t||this.getCenterPoint();for(var e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],t)},_updateObjectCoords:function(t,e){var i=t.left,n=t.top;t.set({left:i-e.x,top:n-e.y}),t.group=this,t.setCoords(!0,!0)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var n=this._objects.length;if(this.useSetOnGroup)for(;n--;)this._objects[n].setOnGroup(t,i);if("canvas"===t)for(;n--;)this._objects[n]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,n=this._objects.map((function(e){var n=e.includeDefaultValues;e.includeDefaultValues=i;var r=e.toObject(t);return e.includeDefaultValues=n,r})),r=e.Object.prototype.toObject.call(this,t);return r.objects=n,r},toDatalessObject:function(t){var i,n=this.sourcePath;if(n)i=n;else{var r=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=r;var n=e.toDatalessObject(t);return e.includeDefaultValues=i,n}))}var o=e.Object.prototype.toDatalessObject.call(this,t);return o.objects=i,o},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,n=this._objects.length;i<n;i++)if(this._objects[i].willDrawShadow())return this.ownCaching=!1,!1;return t},willDrawShadow:function(){if(e.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,i=this._objects.length;t<i;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var e=0,i=this._objects.length;e<i;e++)this._objects[e].render(t);this._drawClipPath(t)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var e=0,i=this._objects.length;e<i;e++)if(this._objects[e].isCacheDirty(!0)){if(this._cacheCanvas){var n=this.cacheWidth/this.zoomX,r=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-n/2,-r/2,n,r)}return!0}return!1},_restoreObjectsState:function(){return this._objects.forEach(this._restoreObjectState,this),this},realizeTransform:function(t){var i=t.calcTransformMatrix(),n=e.util.qrDecompose(i),r=new e.Point(n.translateX,n.translateY);return t.flipX=!1,t.flipY=!1,t.set("scaleX",n.scaleX),t.set("scaleY",n.scaleY),t.skewX=n.skewX,t.skewY=n.skewY,t.angle=n.angle,t.setPositionByOrigin(r,"center","center"),t},_restoreObjectState:function(t){return this.realizeTransform(t),t.setCoords(),delete t.group,this},destroy:function(){return this._objects.forEach((function(t){t.set("dirty",!0)})),this._restoreObjectsState()},toActiveSelection:function(){if(this.canvas){var t=this._objects,i=this.canvas;this._objects=[];var n=this.toObject();delete n.objects;var r=new e.ActiveSelection([]);return r.set(n),r.type="activeSelection",i.remove(this),t.forEach((function(t){t.group=r,t.dirty=!0,i.add(t)})),r.canvas=i,r._objects=t,i._activeObject=r,r.setCoords(),r}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){return this.forEachObject((function(t){t.setCoords(!0,!0)})),this},_calcBounds:function(t){for(var e,i,n,r=[],o=[],s=["tr","br","bl","tl"],a=0,c=this._objects.length,u=s.length;a<c;++a)for((e=this._objects[a]).setCoords(!0),n=0;n<u;n++)i=s[n],r.push(e.oCoords[i].x),o.push(e.oCoords[i].y);this._getBounds(r,o,t)},_getBounds:function(t,r,o){var s=new e.Point(i(t),i(r)),a=new e.Point(n(t),n(r)),c=s.y||0,u=s.x||0,h=a.x-s.x||0,l=a.y-s.y||0;this.width=h,this.height=l,o||this.setPositionByOrigin({x:u,y:c},"left","top")},_toSVG:function(t){for(var e=["<g ","COMMON_PARTS"," >\n"],i=0,n=this._objects.length;i<n;i++)e.push("\t\t",this._objects[i].toSVG(t));return e.push("</g>\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,n=this._objects.length;i<n;i++)e.push("\t",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}}),e.Group.fromObject=function(t,i){var n=t.objects,r=e.util.object.clone(t,!0);delete r.objects,"string"!=typeof n?e.util.enlivenObjects(n,(function(n){e.util.enlivenObjects([t.clipPath],(function(r){var o=e.util.object.clone(t,!0);o.clipPath=r[0],delete o.objects,i&&i(new e.Group(n,o,!0))}))})):e.loadSVGFromURL(n,(function(o){var s=e.util.groupSVGElements(o,t,n);s.set(r),i&&i(s)}))})}(e),function(t){"use strict";var e=t.fabric||(t.fabric={});e.ActiveSelection||(e.ActiveSelection=e.util.createClass(e.Group,{type:"activeSelection",initialize:function(t,i){i=i||{},this._objects=t||[];for(var n=this._objects.length;n--;)this._objects[n].group=this;i.originX&&(this.originX=i.originX),i.originY&&(this.originY=i.originY),this._calcBounds(),this._updateObjectsCoords(),e.Object.prototype.initialize.call(this,i),this.setCoords()},toGroup:function(){var t=this._objects.concat();this._objects=[];var i=e.Object.prototype.toObject.call(this),n=new e.Group([]);if(delete i.type,n.set(i),t.forEach((function(t){t.canvas.remove(t),t.group=n})),n._objects=t,!this.canvas)return n;var r=this.canvas;return r.add(n),r._activeObject=n,n.setCoords(),n},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),void 0===i.hasRotatingPoint&&(i.hasRotatingPoint=!1),i.forActiveSelection=!0;for(var n=0,r=this._objects.length;n<r;n++)this._objects[n]._renderControls(t,i);t.restore()}}),e.ActiveSelection.fromObject=function(t,i){e.util.enlivenObjects(t.objects,(function(n){delete t.objects,i&&i(new e.ActiveSelection(n,t,!0))}))})}(e),function(t){"use strict";var e=S.util.object.extend;t.fabric||(t.fabric={}),t.fabric.Image?S.warn("fabric.Image is already defined."):(S.Image=S.util.createClass(S.Object,{type:"image",crossOrigin:"",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:S.Object.prototype.stateProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,initialize:function(t,e){e||(e={}),this.filters=[],this.cacheKey="texture"+S.Object.__uid++,this.callSuper("initialize",e),this._initElement(t,e)},getElement:function(){return this._element||{}},setElement:function(t,e){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=t,this._originalElement=t,this._initConfig(e),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(t){var e=S.filterBackend;e&&e.evictCachesForKey&&e.evictCachesForKey(t)},dispose:function(){this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(function(t){S.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this))},setCrossOrigin:function(t){return this.crossOrigin=t,this._element.crossOrigin=t,this},getOriginalSize:function(){var t=this.getElement();return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}},_stroke:function(t){if(this.stroke&&0!==this.strokeWidth){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}},_renderDashedStroke:function(t){var e=-this.width/2,i=-this.height/2,n=this.width,r=this.height;t.save(),this._setStrokeStyles(t,this),t.beginPath(),S.util.drawDashedLine(t,e,i,e+n,i,this.strokeDashArray),S.util.drawDashedLine(t,e+n,i,e+n,i+r,this.strokeDashArray),S.util.drawDashedLine(t,e+n,i+r,e,i+r,this.strokeDashArray),S.util.drawDashedLine(t,e,i+r,e,i,this.strokeDashArray),t.closePath(),t.restore()},toObject:function(t){var i=[];this.filters.forEach((function(t){t&&i.push(t.toObject())}));var n=e(this.callSuper("toObject",["crossOrigin","cropX","cropY"].concat(t)),{src:this.getSrc(),filters:i});return this.resizeFilter&&(n.resizeFilter=this.resizeFilter.toObject()),n},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var t,e=[],i=[],n=-this.width/2,r=-this.height/2,o="";if(this.hasCrop()){var s=S.Object.__uid++;e.push('<clipPath id="imageCrop_'+s+'">\n','\t<rect x="'+n+'" y="'+r+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+s+')" '}if(i.push("\t<image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',n-this.cropX,'" y="',r-this.cropY,'" width="',this._element.width||this._element.naturalWidth,'" height="',this._element.height||this._element.height,'"',o,"></image>\n"),this.stroke||this.strokeDashArray){var a=this.fill;this.fill=null,t=["\t<rect ",'x="',n,'" y="',r,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'],this.fill=a}return e="fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return S.util.loadImage(t,(function(t){this.setElement(t,i),this._setWidthHeight(),e&&e(this)}),this,i&&i.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),n=i.scaleX,r=i.scaleY,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||n>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=n,void(this._lastScaleY=r);S.filterBackend||(S.filterBackend=S.initFilterBackend());var s=S.util.createCanvasElement(),a=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,c=o.width,u=o.height;s.width=c,s.height=u,this._element=s,this._lastScaleX=t.scaleX=n,this._lastScaleY=t.scaleY=r,S.filterBackend.applyFilters([t],o,c,u,this._element,a),this._filterScalingX=s.width/this._originalElement.width,this._filterScalingY=s.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,n=e.naturalHeight||e.height;if(this._element===this._originalElement){var r=S.util.createCanvasElement();r.width=i,r.height=n,this._element=r,this._filteredEl=r}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,n),this._lastScaleX=1,this._lastScaleY=1;return S.filterBackend||(S.filterBackend=S.initFilterBackend()),S.filterBackend.applyFilters(t,this._originalElement,i,n,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element,i=this.width,n=this.height,r=Math.min(e.naturalWidth||e.width,i*this._filterScalingX),o=Math.min(e.naturalHeight||e.height,n*this._filterScalingY),s=-i/2,a=-n/2,c=Math.max(0,this.cropX*this._filterScalingX),u=Math.max(0,this.cropY*this._filterScalingY);e&&t.drawImage(e,c,u,r,o,s,a,i,n)},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(S.util.getById(t),e),S.util.addClass(this.getElement(),S.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t),this._element&&this.crossOrigin&&(this._element.crossOrigin=this.crossOrigin)},_initFilters:function(t,e){t&&t.length?S.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=S.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,n=this._element.height,r=1,o=1,s=0,a=0,c=0,u=0,h=this.width,l=this.height,f={width:h,height:l};return!e||"none"===e.alignX&&"none"===e.alignY?(r=h/i,o=l/n):("meet"===e.meetOrSlice&&(t=(h-i*(r=o=S.util.findScaleToFit(this._element,f)))/2,"Min"===e.alignX&&(s=-t),"Max"===e.alignX&&(s=t),t=(l-n*o)/2,"Min"===e.alignY&&(a=-t),"Max"===e.alignY&&(a=t)),"slice"===e.meetOrSlice&&(t=i-h/(r=o=S.util.findScaleToCover(this._element,f)),"Mid"===e.alignX&&(c=t/2),"Max"===e.alignX&&(c=t),t=n-l/o,"Mid"===e.alignY&&(u=t/2),"Max"===e.alignY&&(u=t),i=h/r,n=l/o)),{width:i,height:n,scaleX:r,scaleY:o,offsetLeft:s,offsetTop:a,cropX:c,cropY:u}}}),S.Image.CSS_CANVAS="canvas-img",S.Image.prototype.getSvgSrc=S.Image.prototype.getSrc,S.Image.fromObject=function(t,e){var i=S.util.object.clone(t);S.util.loadImage(i.src,(function(t,n){n?e&&e(null,n):S.Image.prototype._initFilters.call(i,i.filters,(function(n){i.filters=n||[],S.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(n){i.resizeFilter=n[0],S.util.enlivenObjects([i.clipPath],(function(n){i.clipPath=n[0];var r=new S.Image(t,i);e(r)}))}))}))}),null,i.crossOrigin)},S.Image.fromURL=function(t,e,i){S.util.loadImage(t,(function(t){e&&e(new S.Image(t,i))}),null,i&&i.crossOrigin)},S.Image.ATTRIBUTE_NAMES=S.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin".split(" ")),S.Image.fromElement=function(t,i,n){var r=S.parseAttributes(t,S.Image.ATTRIBUTE_NAMES);S.Image.fromURL(r["xlink:href"],i,e(n?S.util.object.clone(n):{},r))})}(e),S.util.object.extend(S.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten()),this},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,n=t.onChange||e,r=this;return S.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){r.rotate(t),n()},onComplete:function(){r.setCoords(),i()}}),this}}),S.util.object.extend(S.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound}),this}}),function(){"use strict";function t(t,e){var i="precision "+e+" float;\nvoid main(){}",n=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(n,i),t.compileShader(n),!!t.getShaderParameter(n,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}S.isWebglSupported=function(e){if(S.isLikelyNode)return!1;e=e||S.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),n=i.getContext("webgl")||i.getContext("experimental-webgl"),r=!1;if(n){S.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),r=S.maxTextureSize>=e;for(var o=["highp","mediump","lowp"],s=0;s<3;s++)if(t(n,o[s])){S.webGlPrecision=o[s];break}}return this.isSupported=r,r},S.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,n=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var r="undefined"!=typeof ArrayBuffer,o="undefined"!=typeof Uint8ClampedArray;if(n&&i&&r&&o){var s=S.util.createCanvasElement(),a=new ArrayBuffer(t*e*4);if(S.forceGLPutImageData)return this.imageBuffer=a,void(this.copyGLTo2D=j);var c,u,h={imageBuffer:a,destinationWidth:t,destinationHeight:e,targetCanvas:s};s.width=t,s.height=e,c=window.performance.now(),O.call(h,this.gl,h),u=window.performance.now()-c,c=window.performance.now(),j.call(h,this.gl,h),u>window.performance.now()-c?(this.imageBuffer=a,this.copyGLTo2D=j):this.copyGLTo2D=O}},createWebGLCanvas:function(t,e){var i=S.util.createCanvasElement();i.width=t,i.height=e;var n={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},r=i.getContext("webgl",n);r||(r=i.getContext("experimental-webgl",n)),r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)},applyFilters:function(t,e,i,n,r,o){var s,a=this.gl;o&&(s=this.getCachedTexture(o,e));var c={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:n,destinationWidth:i,destinationHeight:n,context:a,sourceTexture:this.createTexture(a,i,n,!s&&e),targetTexture:this.createTexture(a,i,n),originalTexture:s||this.createTexture(a,i,n,!s&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach((function(t){t&&t.applyTo(c)})),function(t){var e=t.targetCanvas,i=e.width,n=e.height,r=t.destinationWidth,o=t.destinationHeight;i===r&&n===o||(e.width=r,e.height=o)}(c),this.copyGLTo2D(a,c),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(c.sourceTexture),a.deleteTexture(c.targetTexture),a.deleteFramebuffer(u),r.getContext("2d").setTransform(1,0,0,1,0,0),c},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:O,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var n=t.getParameter(i.UNMASKED_RENDERER_WEBGL),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);n&&(e.renderer=n.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){"use strict";var t=function(){};function e(){}S.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,n,r){var o=r.getContext("2d");o.drawImage(e,0,0,i,n);var s={sourceWidth:i,sourceHeight:n,imageData:o.getImageData(0,0,i,n),originalEl:e,originalImageData:o.getImageData(0,0,i,n),canvasEl:r,ctx:o,filterBackend:this};return t.forEach((function(t){t.applyTo(s)})),s.imageData.width===i&&s.imageData.height===n||(r.width=s.imageData.width,r.height=s.imageData.height),o.putImageData(s.imageData,0,0),s}}}(),S.Image=S.Image||{},S.Image.filters=S.Image.filters||{},S.Image.filters.BaseFilter=S.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==S.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+S.webGlPrecision+" float"));var n=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var r=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var o=t.createProgram();if(t.attachShader(o,n),t.attachShader(o,r),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(o));var s=this.getAttributeLocations(t,o),a=this.getUniformLocations(t,o)||{};return a.uStepW=t.getUniformLocation(o,"uStepW"),a.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:s,uniformLocations:a}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var n=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,n=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(n.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(n,e,i)),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t.targetTexture,0)):(n.bindFramebuffer(n.FRAMEBUFFER,null),n.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=S.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),S.Image.filters.BaseFilter.fromObject=function(t,e){var i=new S.Image.filters[t.type](t);return e&&e(i),i},function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.ColorMatrix=n(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,n,r,o,s=t.imageData.data,a=s.length,c=this.matrix,u=this.colorsOnly;for(o=0;o<a;o+=4)e=s[o],i=s[o+1],n=s[o+2],u?(s[o]=e*c[0]+i*c[1]+n*c[2]+255*c[4],s[o+1]=e*c[5]+i*c[6]+n*c[7]+255*c[9],s[o+2]=e*c[10]+i*c[11]+n*c[12]+255*c[14]):(r=s[o+3],s[o]=e*c[0]+i*c[1]+n*c[2]+r*c[3]+255*c[4],s[o+1]=e*c[5]+i*c[6]+n*c[7]+r*c[8]+255*c[9],s[o+2]=e*c[10]+i*c[11]+n*c[12]+r*c[13]+255*c[14],s[o+3]=e*c[15]+i*c[16]+n*c[17]+r*c[18]+255*c[19])},getUniformLocations:function(t,e){return{uColorMatrix:t.getUniformLocation(e,"uColorMatrix"),uConstants:t.getUniformLocation(e,"uConstants")}},sendUniformData:function(t,e){var i=this.matrix,n=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,n),t.uniform4fv(e.uConstants,r)}}),e.Image.filters.ColorMatrix.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Brightness=n(i.BaseFilter,{type:"Brightness",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",brightness:0,mainParameter:"brightness",applyTo2d:function(t){if(0!==this.brightness){var e,i=t.imageData.data,n=i.length,r=Math.round(255*this.brightness);for(e=0;e<n;e+=4)i[e]=i[e]+r,i[e+1]=i[e+1]+r,i[e+2]=i[e+2]+r}},getUniformLocations:function(t,e){return{uBrightness:t.getUniformLocation(e,"uBrightness")}},sendUniformData:function(t,e){t.uniform1f(e.uBrightness,this.brightness)}}),e.Image.filters.Brightness.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters,r=e.util.createClass;n.Convolute=r(n.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_3_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_5_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_5_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_7_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_7_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_9_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_9_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}"},retrieveShader:function(t){var e=Math.sqrt(this.matrix.length),i=this.type+"_"+e+"_"+(this.opaque?1:0),n=this.fragmentSource[i];return t.programCache.hasOwnProperty(i)||(t.programCache[i]=this.createProgram(t.context,n)),t.programCache[i]},applyTo2d:function(t){var e,i,n,r,o,s,a,c,u,h,l,f,d,p=t.imageData,g=p.data,v=this.matrix,y=Math.round(Math.sqrt(v.length)),m=Math.floor(y/2),b=p.width,_=p.height,x=t.ctx.createImageData(b,_),w=x.data,C=this.opaque?1:0;for(l=0;l<_;l++)for(h=0;h<b;h++){for(o=4*(l*b+h),e=0,i=0,n=0,r=0,d=0;d<y;d++)for(f=0;f<y;f++)s=h+f-m,(a=l+d-m)<0||a>=_||s<0||s>=b||(c=4*(a*b+s),u=v[d*y+f],e+=g[c]*u,i+=g[c+1]*u,n+=g[c+2]*u,C||(r+=g[c+3]*u));w[o]=e,w[o+1]=i,w[o+2]=n,w[o+3]=C?g[o+3]:r}t.imageData=x},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Grayscale=n(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,n=t.imageData.data,r=n.length,o=this.mode;for(e=0;e<r;e+=4)"average"===o?i=(n[e]+n[e+1]+n[e+2])/3:"lightness"===o?i=(Math.min(n[e],n[e+1],n[e+2])+Math.max(n[e],n[e+1],n[e+2]))/2:"luminosity"===o&&(i=.21*n[e]+.72*n[e+1]+.07*n[e+2]),n[e]=i,n[e+1]=i,n[e+2]=i},retrieveShader:function(t){var e=this.type+"_"+this.mode;if(!t.programCache.hasOwnProperty(e)){var i=this.fragmentSource[this.mode];t.programCache[e]=this.createProgram(t.context,i)}return t.programCache[e]},getUniformLocations:function(t,e){return{uMode:t.getUniformLocation(e,"uMode")}},sendUniformData:function(t,e){t.uniform1i(e.uMode,1)},isNeutralState:function(){return!1}}),e.Image.filters.Grayscale.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Invert=n(i.BaseFilter,{type:"Invert",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",invert:!0,mainParameter:"invert",applyTo2d:function(t){var e,i=t.imageData.data,n=i.length;for(e=0;e<n;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(t,e){return{uInvert:t.getUniformLocation(e,"uInvert")}},sendUniformData:function(t,e){t.uniform1i(e.uInvert,this.invert)}}),e.Image.filters.Invert.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters,r=e.util.createClass;n.Noise=r(n.BaseFilter,{type:"Noise",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",mainParameter:"noise",noise:0,applyTo2d:function(t){if(0!==this.noise){var e,i,n=t.imageData.data,r=n.length,o=this.noise;for(e=0,r=n.length;e<r;e+=4)i=(.5-Math.random())*o,n[e]+=i,n[e+1]+=i,n[e+2]+=i}},getUniformLocations:function(t,e){return{uNoise:t.getUniformLocation(e,"uNoise"),uSeed:t.getUniformLocation(e,"uSeed")}},sendUniformData:function(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}}),e.Image.filters.Noise.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Pixelate=n(i.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",applyTo2d:function(t){var e,i,n,r,o,s,a,c,u,h,l,f=t.imageData,d=f.data,p=f.height,g=f.width;for(i=0;i<p;i+=this.blocksize)for(n=0;n<g;n+=this.blocksize)for(r=d[e=4*i*g+4*n],o=d[e+1],s=d[e+2],a=d[e+3],h=Math.min(i+this.blocksize,p),l=Math.min(n+this.blocksize,g),c=i;c<h;c++)for(u=n;u<l;u++)d[e=4*c*g+4*u]=r,d[e+1]=o,d[e+2]=s,d[e+3]=a},isNeutralState:function(){return 1===this.blocksize},getUniformLocations:function(t,e){return{uBlocksize:t.getUniformLocation(e,"uBlocksize"),uStepW:t.getUniformLocation(e,"uStepW"),uStepH:t.getUniformLocation(e,"uStepH")}},sendUniformData:function(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}),e.Image.filters.Pixelate.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,n=e.Image.filters,r=e.util.createClass;n.RemoveColor=r(n.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",distance:.02,useAlpha:!1,applyTo2d:function(t){var i,n,r,o,s=t.imageData.data,a=255*this.distance,c=new e.Color(this.color).getSource(),u=[c[0]-a,c[1]-a,c[2]-a],h=[c[0]+a,c[1]+a,c[2]+a];for(i=0;i<s.length;i+=4)n=s[i],r=s[i+1],o=s[i+2],n>u[0]&&r>u[1]&&o>u[2]&&n<h[0]&&r<h[1]&&o<h[2]&&(s[i+3]=0)},getUniformLocations:function(t,e){return{uLow:t.getUniformLocation(e,"uLow"),uHigh:t.getUniformLocation(e,"uHigh")}},sendUniformData:function(t,i){var n=new e.Color(this.color).getSource(),r=parseFloat(this.distance),o=[0+n[0]/255-r,0+n[1]/255-r,0+n[2]/255-r,1],s=[n[0]/255+r,n[1]/255+r,n[2]/255+r,1];t.uniform4fv(i.uLow,o),t.uniform4fv(i.uHigh,s)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),e.Image.filters.RemoveColor.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass,r={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var o in r)i[o]=n(i.ColorMatrix,{type:o,matrix:r[o],mainParameter:!1,colorsOnly:!0}),e.Image.filters[o].fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric,i=e.Image.filters,n=e.util.createClass;i.BlendColor=n(i.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",diff:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",tint:"gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n"},buildSource:function(t){return"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,n,r,o,s,a,c,u=t.imageData.data,h=u.length,l=1-this.alpha;i=(c=new e.Color(this.color).getSource())[0]*this.alpha,n=c[1]*this.alpha,r=c[2]*this.alpha;for(var f=0;f<h;f+=4)switch(o=u[f],s=u[f+1],a=u[f+2],this.mode){case"multiply":u[f]=o*i/255,u[f+1]=s*n/255,u[f+2]=a*r/255;break;case"screen":u[f]=255-(255-o)*(255-i)/255,u[f+1]=255-(255-s)*(255-n)/255,u[f+2]=255-(255-a)*(255-r)/255;break;case"add":u[f]=o+i,u[f+1]=s+n,u[f+2]=a+r;break;case"diff":case"difference":u[f]=Math.abs(o-i),u[f+1]=Math.abs(s-n),u[f+2]=Math.abs(a-r);break;case"subtract":u[f]=o-i,u[f+1]=s-n,u[f+2]=a-r;break;case"darken":u[f]=Math.min(o,i),u[f+1]=Math.min(s,n),u[f+2]=Math.min(a,r);break;case"lighten":u[f]=Math.max(o,i),u[f+1]=Math.max(s,n),u[f+2]=Math.max(a,r);break;case"overlay":u[f]=i<128?2*o*i/255:255-2*(255-o)*(255-i)/255,u[f+1]=n<128?2*s*n/255:255-2*(255-s)*(255-n)/255,u[f+2]=r<128?2*a*r/255:255-2*(255-a)*(255-r)/255;break;case"exclusion":u[f]=i+o-2*i*o/255,u[f+1]=n+s-2*n*s/255,u[f+2]=r+a-2*r*a/255;break;case"tint":u[f]=i+o*l,u[f+1]=n+s*l,u[f+2]=r+a*l}},getUniformLocations:function(t,e){return{uColor:t.getUniformLocation(e,"uColor")}},sendUniformData:function(t,i){var n=new e.Color(this.color).getSource();n[0]=this.alpha*n[0]/255,n[1]=this.alpha*n[1]/255,n[2]=this.alpha*n[2]/255,n[3]=this.alpha,t.uniform4fv(i.uColor,n)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendColor.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric,i=e.Image.filters,n=e.util.createClass;i.BlendImage=n(i.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:{multiply:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",mask:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}"},retrieveShader:function(t){var e=this.type+"_"+this.mode,i=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(e)||(t.programCache[e]=this.createProgram(t.context,i)),t.programCache[e]},applyToWebGL:function(t){var e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(e,e.TEXTURE1)},createTexture:function(t,e){return t.getCachedTexture(e.cacheKey,e._element)},calculateMatrix:function(){var t=this.image,e=t._element.width,i=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]},applyTo2d:function(t){var i,n,r,o,s,a,c,u,h,l,f,d=t.imageData,p=t.filterBackend.resources,g=d.data,v=g.length,y=d.width,m=d.height,b=this.image;p.blendImage||(p.blendImage=e.util.createCanvasElement()),l=(h=p.blendImage).getContext("2d"),h.width!==y||h.height!==m?(h.width=y,h.height=m):l.clearRect(0,0,y,m),l.setTransform(b.scaleX,0,0,b.scaleY,b.left,b.top),l.drawImage(b._element,0,0,y,m),f=l.getImageData(0,0,y,m).data;for(var _=0;_<v;_+=4)switch(s=g[_],a=g[_+1],c=g[_+2],u=g[_+3],i=f[_],n=f[_+1],r=f[_+2],o=f[_+3],this.mode){case"multiply":g[_]=s*i/255,g[_+1]=a*n/255,g[_+2]=c*r/255,g[_+3]=u*o/255;break;case"mask":g[_+3]=o}},getUniformLocations:function(t,e){return{uTransformMatrix:t.getUniformLocation(e,"uTransformMatrix"),uImage:t.getUniformLocation(e,"uImage")}},sendUniformData:function(t,e){var i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendImage.fromObject=function(t,i){e.Image.fromObject(t.image,(function(n){var r=e.util.object.clone(t);r.image=n,i(new e.Image.filters.BlendImage(r))}))}}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.pow,n=Math.floor,r=Math.sqrt,o=Math.abs,s=Math.round,a=Math.sin,c=Math.ceil,u=e.Image.filters,h=e.util.createClass;u.Resize=h(u.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(t,e){return{uDelta:t.getUniformLocation(e,"uDelta"),uTaps:t.getUniformLocation(e,"uTaps")}},sendUniformData:function(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)},retrieveShader:function(t){var e=this.getFilterWindow(),i=this.type+"_"+e;if(!t.programCache.hasOwnProperty(i)){var n=this.generateShader(e);t.programCache[i]=this.createProgram(t.context,n)}return t.programCache[i]},getFilterWindow:function(){var t=this.tempScale;return Math.ceil(this.lanczosLobes/t)},getTaps:function(){for(var t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),n=new Array(i),r=1;r<=i;r++)n[r-1]=t(r*e);return n},generateShader:function(t){for(var e=new Array(t),i=this.fragmentSourceTOP,n=1;n<=t;n++)e[n-1]=n+".0 * uDelta";return i+="uniform float uTaps["+t+"];\n",i+="void main() {\n",i+=" vec4 color = texture2D(uTexture, vTexCoord);\n",i+=" float sum = 1.0;\n",e.forEach((function(t,e){i+=" color += texture2D(uTexture, vTexCoord + "+t+") * uTaps["+e+"];\n",i+=" color += texture2D(uTexture, vTexCoord - "+t+") * uTaps["+e+"];\n",i+=" sum += 2.0 * uTaps["+e+"];\n"})),i+=" gl_FragColor = color / sum;\n",i+="}"},fragmentSourceTOP:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",applyTo:function(t){t.webgl?(t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceHeight=t.destinationHeight):this.applyTo2d(t)},isNeutralState:function(){return 1===this.scaleX&&1===this.scaleY},lanczosCreate:function(t){return function(e){if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return a(e)/e*a(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;var r,o=e.width,a=e.height,c=s(o*i),u=s(a*n);"sliceHack"===this.resizeType?r=this.sliceByTwo(t,o,a,c,u):"hermite"===this.resizeType?r=this.hermiteFastResize(t,o,a,c,u):"bilinear"===this.resizeType?r=this.bilinearFiltering(t,o,a,c,u):"lanczos"===this.resizeType&&(r=this.lanczosResize(t,o,a,c,u)),t.imageData=r},sliceByTwo:function(t,i,r,o,s){var a,c,u=t.imageData,h=!1,l=!1,f=.5*i,d=.5*r,p=e.filterBackend.resources,g=0,v=0,y=i,m=0;for(p.sliceByTwo||(p.sliceByTwo=document.createElement("canvas")),((a=p.sliceByTwo).width<1.5*i||a.height<r)&&(a.width=1.5*i,a.height=r),(c=a.getContext("2d")).clearRect(0,0,1.5*i,r),c.putImageData(u,0,0),o=n(o),s=n(s);!h||!l;)i=f,r=d,o<n(.5*f)?f=n(.5*f):(f=o,h=!0),s<n(.5*d)?d=n(.5*d):(d=s,l=!0),c.drawImage(a,g,v,i,r,y,m,f,d),g=y,v=m,m+=d;return c.getImageData(g,v,o,s)},lanczosResize:function(t,e,s,a,u){var h=t.imageData.data,l=t.ctx.createImageData(a,u),f=l.data,d=this.lanczosCreate(this.lanczosLobes),p=this.rcpScaleX,g=this.rcpScaleY,v=2/this.rcpScaleX,y=2/this.rcpScaleY,m=c(p*this.lanczosLobes/2),b=c(g*this.lanczosLobes/2),_={},x={},w={};return function t(c){var C,S,T,O,j,P,E,k,A,D,M;for(x.x=(c+.5)*p,w.x=n(x.x),C=0;C<u;C++){for(x.y=(C+.5)*g,w.y=n(x.y),j=0,P=0,E=0,k=0,A=0,S=w.x-m;S<=w.x+m;S++)if(!(S<0||S>=e)){D=n(1e3*o(S-x.x)),_[D]||(_[D]={});for(var I=w.y-b;I<=w.y+b;I++)I<0||I>=s||(M=n(1e3*o(I-x.y)),_[D][M]||(_[D][M]=d(r(i(D*v,2)+i(M*y,2))/1e3)),(T=_[D][M])>0&&(j+=T,P+=T*h[O=4*(I*e+S)],E+=T*h[O+1],k+=T*h[O+2],A+=T*h[O+3]))}f[O=4*(C*a+c)]=P/j,f[O+1]=E/j,f[O+2]=k/j,f[O+3]=A/j}return++c<a?t(c):l}(0)},bilinearFiltering:function(t,e,i,r,o){var s,a,c,u,h,l,f,d,p,g=0,v=this.rcpScaleX,y=this.rcpScaleY,m=4*(e-1),b=t.imageData.data,_=t.ctx.createImageData(r,o),x=_.data;for(c=0;c<o;c++)for(u=0;u<r;u++)for(h=v*u-(s=n(v*u)),l=y*c-(a=n(y*c)),p=4*(a*e+s),f=0;f<4;f++)d=b[p+f]*(1-h)*(1-l)+b[p+4+f]*h*(1-l)+b[p+m+f]*l*(1-h)+b[p+m+4+f]*h*l,x[g++]=d;return _},hermiteFastResize:function(t,e,i,s,a){for(var u=this.rcpScaleX,h=this.rcpScaleY,l=c(u/2),f=c(h/2),d=t.imageData.data,p=t.ctx.createImageData(s,a),g=p.data,v=0;v<a;v++)for(var y=0;y<s;y++){for(var m=4*(y+v*s),b=0,_=0,x=0,w=0,C=0,S=0,T=0,O=(v+.5)*h,j=n(v*h);j<(v+1)*h;j++)for(var P=o(O-(j+.5))/f,E=(y+.5)*u,k=P*P,A=n(y*u);A<(y+1)*u;A++){var D=o(E-(A+.5))/l,M=r(k+D*D);M>1&&M<-1||(b=2*M*M*M-3*M*M+1)>0&&(T+=b*d[(D=4*(A+j*e))+3],x+=b,d[D+3]<255&&(b=b*d[D+3]/250),w+=b*d[D],C+=b*d[D+1],S+=b*d[D+2],_+=b)}g[m]=w/_,g[m+1]=C/_,g[m+2]=S/_,g[m+3]=T/x}return p},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Contrast=n(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,n=i.length,r=Math.floor(255*this.contrast),o=259*(r+255)/(255*(259-r));for(e=0;e<n;e+=4)i[e]=o*(i[e]-128)+128,i[e+1]=o*(i[e+1]-128)+128,i[e+2]=o*(i[e+2]-128)+128}},getUniformLocations:function(t,e){return{uContrast:t.getUniformLocation(e,"uContrast")}},sendUniformData:function(t,e){t.uniform1f(e.uContrast,this.contrast)}}),e.Image.filters.Contrast.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Saturation=n(i.BaseFilter,{type:"Saturation",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",saturation:0,mainParameter:"saturation",applyTo2d:function(t){if(0!==this.saturation){var e,i,n=t.imageData.data,r=n.length,o=-this.saturation;for(e=0;e<r;e+=4)i=Math.max(n[e],n[e+1],n[e+2]),n[e]+=i!==n[e]?(i-n[e])*o:0,n[e+1]+=i!==n[e+1]?(i-n[e+1])*o:0,n[e+2]+=i!==n[e+2]?(i-n[e+2])*o:0}},getUniformLocations:function(t,e){return{uSaturation:t.getUniformLocation(e,"uSaturation")}},sendUniformData:function(t,e){t.uniform1f(e.uSaturation,-this.saturation)}}),e.Image.filters.Saturation.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Blur=n(i.BaseFilter,{type:"Blur",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var i,n,r=t.filterBackend.resources,o=t.imageData.width,s=t.imageData.height;r.blurLayer1||(r.blurLayer1=e.util.createCanvasElement(),r.blurLayer2=e.util.createCanvasElement()),i=r.blurLayer1,n=r.blurLayer2,i.width===o&&i.height===s||(n.width=i.width=o,n.height=i.height=s);var a,c,u,h,l=i.getContext("2d"),f=n.getContext("2d"),d=.06*this.blur*.5;for(l.putImageData(t.imageData,0,0),f.clearRect(0,0,o,s),h=-15;h<=15;h++)u=d*(c=h/15)*o+(a=(Math.random()-.5)/4),f.globalAlpha=1-Math.abs(c),f.drawImage(i,u,a),l.drawImage(n,0,0),f.globalAlpha=1,f.clearRect(0,0,n.width,n.height);for(h=-15;h<=15;h++)u=d*(c=h/15)*s+(a=(Math.random()-.5)/4),f.globalAlpha=1-Math.abs(c),f.drawImage(i,a,u),l.drawImage(n,0,0),f.globalAlpha=1,f.clearRect(0,0,n.width,n.height);t.ctx.drawImage(i,0,0);var p=t.ctx.getImageData(0,0,i.width,i.height);return l.globalAlpha=1,l.clearRect(0,0,i.width,i.height),p},getUniformLocations:function(t,e){return{delta:t.getUniformLocation(e,"uDelta")}},sendUniformData:function(t,e){var i=this.chooseRightDelta();t.uniform2fv(e.delta,i)},chooseRightDelta:function(){var t,e=1,i=[0,0];return this.horizontal?this.aspectRatio>1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Gamma=n(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,n=this.gamma,r=i.length,o=1/n[0],s=1/n[1],a=1/n[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,r=256;e<r;e++)this.rVals[e]=255*Math.pow(e/255,o),this.gVals[e]=255*Math.pow(e/255,s),this.bVals[e]=255*Math.pow(e/255,a);for(e=0,r=i.length;e<r;e+=4)i[e]=this.rVals[i[e]],i[e+1]=this.gVals[i[e+1]],i[e+2]=this.bVals[i[e+2]]},getUniformLocations:function(t,e){return{uGamma:t.getUniformLocation(e,"uGamma")}},sendUniformData:function(t,e){t.uniform3fv(e.uGamma,this.gamma)}}),e.Image.filters.Gamma.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.Composed=n(i.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach((function(e){e.applyTo(t)}))},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map((function(t){return t.toObject()}))})},isNeutralState:function(){return!this.subFilters.some((function(t){return!t.isNeutralState()}))}}),e.Image.filters.Composed.fromObject=function(t,i){var n=(t.subFilters||[]).map((function(t){return new e.Image.filters[t.type](t)})),r=new e.Image.filters.Composed({subFilters:n});return i&&i(r),r}}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.Image.filters,n=e.util.createClass;i.HueRotation=n(i.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,i=e.util.cos(t),n=e.util.sin(t),r=Math.sqrt(1/3)*n,o=1-i;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=i+o/3,this.matrix[1]=1/3*o-r,this.matrix[2]=1/3*o+r,this.matrix[5]=1/3*o+r,this.matrix[6]=i+1/3*o,this.matrix[7]=1/3*o-r,this.matrix[10]=1/3*o-r,this.matrix[11]=1/3*o+r,this.matrix[12]=i+1/3*o},isNeutralState:function(t){return this.calculateMatrix(),i.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),i.BaseFilter.prototype.applyTo.call(this,t)}}),e.Image.filters.HueRotation.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.clone;e.Text?e.warn("fabric.Text is already defined"):(e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:e.Object.prototype.stateProperties.concat("fontFamily","fontWeight","fontSize","text","underline","overline","linethrough","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing","styles"),cacheProperties:e.Object.prototype.cacheProperties.concat("fontFamily","fontWeight","fontSize","text","underline","overline","linethrough","textAlign","fontStyle","lineHeight","textBackgroundColor","charSpacing","styles"),stroke:null,shadow:null,_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,e){this.styles=e&&e.styles||{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",e),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},getMeasuringContext:function(){return e._measuringContext||(e._measuringContext=this.canvas&&this.canvas.contextCache||e.util.createCanvasElement().getContext("2d")),e._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var t,e,i,n,r,o,s,a=0,c=this._textLines.length;a<c;a++)if(("justify"===this.textAlign||a!==c-1&&!this.isEndOfWrapping(a))&&(n=0,r=this._textLines[a],(e=this.getLineWidth(a))<this.width&&(s=this.textLines[a].match(this._reSpacesAndTabs)))){i=s.length,t=(this.width-e)/i;for(var u=0,h=r.length;u<=h;u++)o=this.__charBounds[a][u],this._reSpaceAndTab.test(r[u])?(o.width+=t,o.kernedWidth+=t,o.left+=n,n+=t):o.left+=n}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){t.textBaseline="alphabetic",t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;e<i;e++){var n=this.getLineWidth(e);n>t&&(t=n)}return t},_renderTextLine:function(t,e,i,n,r,o){this._renderChars(t,e,i,n,r,o)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,n,r,o,s,a=0,c=t.fillStyle,u=this._getLeftOffset(),h=this._getTopOffset(),l=0,f=0,d=0,p=this._textLines.length;d<p;d++)if(e=this.getHeightOfLine(d),this.textBackgroundColor||this.styleHas("textBackgroundColor",d)){n=this._textLines[d],i=this._getLineLeftOffset(d),f=0,l=0,r=this.getValueOfPropertyAt(d,0,"textBackgroundColor");for(var g=0,v=n.length;g<v;g++)o=this.__charBounds[d][g],(s=this.getValueOfPropertyAt(d,g,"textBackgroundColor"))!==r?(t.fillStyle=r,r&&t.fillRect(u+i+l,h+a,f,e/this.lineHeight),l=o.left,f=o.width,r=s):f+=o.kernedWidth;s&&(t.fillStyle=s,t.fillRect(u+i+l,h+a,f,e/this.lineHeight)),a+=e}else a+=e;t.fillStyle=c,this._removeShadow(t)}},getFontCache:function(t){var i=t.fontFamily.toLowerCase();e.charWidthsCache[i]||(e.charWidthsCache[i]={});var n=e.charWidthsCache[i],r=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return n[r]||(n[r]={}),n[r]},_applyCharStyles:function(t,e,i,n,r){this._setFillStyles(e,r),this._setStrokeStyles(e,r),e.font=this._getFontDeclaration(r)},_measureChar:function(t,e,i,n){var r,o,s,a,c=this.getFontCache(e),u=i+t,h=this._getFontDeclaration(e)===this._getFontDeclaration(n),l=e.fontSize/this.CACHE_FONT_SIZE;if(i&&void 0!==c[i]&&(s=c[i]),void 0!==c[t]&&(a=r=c[t]),h&&void 0!==c[u]&&(a=(o=c[u])-s),void 0===r||void 0===s||void 0===o){var f=this.getMeasuringContext();this._setTextStyles(f,e,!0)}return void 0===r&&(a=r=f.measureText(t).width,c[t]=r),void 0===s&&h&&i&&(s=f.measureText(i).width,c[i]=s),h&&void 0===o&&(o=f.measureText(u).width,c[u]=o,a=o-s),{width:r*l,kernedWidth:a*l}},getHeightOfChar:function(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")},measureLine:function(t){var e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e},_measureLine:function(t){var e,i,n,r,o=0,s=this._textLines[t],a=new Array(s.length);for(this.__charBounds[t]=a,e=0;e<s.length;e++)i=s[e],r=this._getGraphemeBox(i,t,e,n),a[e]=r,o+=r.kernedWidth,n=i;return a[e]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize},{width:o,numOfSpaces:0}},_getGraphemeBox:function(t,e,i,n,r){var o,s=this.getCompleteStyleDeclaration(e,i),a=n?this.getCompleteStyleDeclaration(e,i-1):{},c=this._measureChar(t,s,n,a),u=c.kernedWidth,h=c.width;0!==this.charSpacing&&(h+=o=this._getWidthOfCharSpacing(),u+=o);var l={width:h,left:0,height:s.fontSize,kernedWidth:u,deltaY:s.deltaY};if(i>0&&!r){var f=this.__charBounds[e][i-1];l.left=f.left+f.width+c.kernedWidth-c.width}return l},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),n=1,r=e.length;n<r;n++)i=Math.max(this.getHeightOfChar(t,n),i);return this.__lineHeights[t]=i*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,e=0,i=0,n=this._textLines.length;i<n;i++)t=this.getHeightOfLine(i),e+=i===n-1?t/this.lineHeight:t;return e},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return t.transform(1,0,0,1,i,n),{offsetX:i,offsetY:n}},_renderTextCommon:function(t,e){t.save();for(var i=0,n=this._getLeftOffset(),r=this._getTopOffset(),o=this._applyPatternGradientTransform(t,"fillText"===e?this.fill:this.stroke),s=0,a=this._textLines.length;s<a;s++){var c=this.getHeightOfLine(s),u=c/this.lineHeight,h=this._getLineLeftOffset(s);this._renderTextLine(e,t,this._textLines[s],n+h-o.offsetX,r+i+u-o.offsetY,s),i+=c}t.restore()},_renderTextFill:function(t){(this.fill||this.styleHas("fill"))&&this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,e,i,n,r,o){var s,a,c,u,h=this.getHeightOfLine(o),l=-1!==this.textAlign.indexOf("justify"),f="",d=0,p=!l&&0===this.charSpacing&&this.isEmptyStyles(o);if(e.save(),r-=h*this._fontSizeFraction/this.lineHeight,p)return this._renderChar(t,e,o,0,this.textLines[o],n,r,h),void e.restore();for(var g=0,v=i.length-1;g<=v;g++)u=g===v||this.charSpacing,f+=i[g],c=this.__charBounds[o][g],0===d?(n+=c.kernedWidth-c.width,d+=c.width):d+=c.kernedWidth,l&&!u&&this._reSpaceAndTab.test(i[g])&&(u=!0),u||(s=s||this.getCompleteStyleDeclaration(o,g),a=this.getCompleteStyleDeclaration(o,g+1),u=this._hasStyleChanged(s,a)),u&&(this._renderChar(t,e,o,g,f,n,r,h),f="",s=a,n+=d,d=0);e.restore()},_renderChar:function(t,e,i,n,r,o,s){var a=this._getStyleDeclaration(i,n),c=this.getCompleteStyleDeclaration(i,n),u="fillText"===t&&c.fill,h="strokeText"===t&&c.stroke&&c.strokeWidth;(h||u)&&(a&&e.save(),this._applyCharStyles(t,e,i,n,c),a&&a.textBackgroundColor&&this._removeShadow(e),a&&a.deltaY&&(s+=a.deltaY),u&&e.fillText(r,o,s),h&&e.strokeText(r,o,s),a&&e.restore())},setSuperscript:function(t,e){return this._setScript(t,e,this.superscript)},setSubscript:function(t,e){return this._setScript(t,e,this.subscript)},_setScript:function(t,e,i){var n=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"fontSize"),o=this.getValueOfPropertyAt(n.lineIndex,n.charIndex,"deltaY"),s={fontSize:r*i.size,deltaY:o+r*i.baseline};return this.setSelectionStyles(s,t,e),this},_hasStyleChanged:function(t,e){return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.deltaY!==e.deltaY},_hasStyleChangedForSvg:function(t,e){return this._hasStyleChanged(t,e)||t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough},_getLineLeftOffset:function(t){var e=this.getLineWidth(t);return"center"===this.textAlign?(this.width-e)/2:"right"===this.textAlign?this.width-e:"justify-center"===this.textAlign&&this.isEndOfWrapping(t)?(this.width-e)/2:"justify-right"===this.textAlign&&this.isEndOfWrapping(t)?this.width-e:0},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){return this.__lineWidths[t]?this.__lineWidths[t]:(e=""===this._textLines[t]?0:this.measureLine(t).width,this.__lineWidths[t]=e,e);var e},_getWidthOfCharSpacing:function(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,e,i){var n=this._getStyleDeclaration(t,e);return n&&void 0!==n[i]?n[i]:this[i]},_renderTextDecoration:function(t,e){if(this[e]||this.styleHas(e)){for(var i,n,r,o,s,a,c,u,h,l,f,d,p,g,v,y,m=this._getLeftOffset(),b=this._getTopOffset(),_=this._getWidthOfCharSpacing(),x=0,w=this._textLines.length;x<w;x++)if(i=this.getHeightOfLine(x),this[e]||this.styleHas(e,x)){c=this._textLines[x],g=i/this.lineHeight,o=this._getLineLeftOffset(x),l=0,f=0,u=this.getValueOfPropertyAt(x,0,e),y=this.getValueOfPropertyAt(x,0,"fill"),h=b+g*(1-this._fontSizeFraction),n=this.getHeightOfChar(x,0),s=this.getValueOfPropertyAt(x,0,"deltaY");for(var C=0,S=c.length;C<S;C++)d=this.__charBounds[x][C],p=this.getValueOfPropertyAt(x,C,e),v=this.getValueOfPropertyAt(x,C,"fill"),r=this.getHeightOfChar(x,C),a=this.getValueOfPropertyAt(x,C,"deltaY"),(p!==u||v!==y||r!==n||a!==s)&&f>0?(t.fillStyle=y,u&&y&&t.fillRect(m+o+l,h+this.offsets[e]*n+s,f,this.fontSize/15),l=d.left,f=d.width,u=p,y=v,n=r,s=a):f+=d.kernedWidth;t.fillStyle=v,p&&v&&t.fillRect(m+o+l,h+this.offsets[e]*n+s,f-_,this.fontSize/15),b+=i}else b+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var n=t||this,r=this.fontFamily,o=e.Text.genericFonts.indexOf(r.toLowerCase())>-1,s=void 0===r||r.indexOf("'")>-1||r.indexOf(",")>-1||r.indexOf('"')>-1||o?n.fontFamily:'"'+n.fontFamily+'"';return[e.isLikelyNode?n.fontWeight:n.fontStyle,e.isLikelyNode?n.fontStyle:n.fontWeight,i?this.CACHE_FONT_SIZE+"px":n.fontSize+"px",s].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),n=new Array(i.length),r=["\n"],o=[],s=0;s<i.length;s++)n[s]=e.util.string.graphemeSplit(i[s]),o=o.concat(n[s],r);return o.pop(),{_unwrappedLines:n,lines:i,graphemeText:o,graphemeLines:n}},toObject:function(t){var e=["text","fontSize","fontWeight","fontFamily","fontStyle","lineHeight","underline","overline","linethrough","textAlign","textBackgroundColor","charSpacing"].concat(t),n=this.callSuper("toObject",e);return n.styles=i(this.styles,!0),n},set:function(t,e){this.callSuper("set",t,e);var i=!1;if("object"==typeof t)for(var n in t)i=i||-1!==this._dimensionAffectingProps.indexOf(n);else i=-1!==this._dimensionAffectingProps.indexOf(t);return i&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),e.Text.DEFAULT_SVG_FONT_SIZE=16,e.Text.fromElement=function(t,n,r){if(!t)return n(null);var o=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES),s=o.textAnchor||"left";if((r=e.util.object.extend(r?i(r):{},o)).top=r.top||0,r.left=r.left||0,o.textDecoration){var a=o.textDecoration;-1!==a.indexOf("underline")&&(r.underline=!0),-1!==a.indexOf("overline")&&(r.overline=!0),-1!==a.indexOf("line-through")&&(r.linethrough=!0),delete r.textDecoration}"dx"in o&&(r.left+=o.dx),"dy"in o&&(r.top+=o.dy),"fontSize"in r||(r.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE);var c="";"textContent"in t?c=t.textContent:"firstChild"in t&&null!==t.firstChild&&"data"in t.firstChild&&null!==t.firstChild.data&&(c=t.firstChild.data),c=c.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var u=r.strokeWidth;r.strokeWidth=0;var h=new e.Text(c,r),l=h.getScaledHeight()/h.height,f=((h.height+h.strokeWidth)*h.lineHeight-h.height)*l,d=h.getScaledHeight()+f,p=0;"center"===s&&(p=h.getScaledWidth()/2),"right"===s&&(p=h.getScaledWidth()),h.set({left:h.left-p,top:h.top-(d-h.fontSize*(.07+h._fontSizeFraction))/h.lineHeight,strokeWidth:void 0!==u?u:1}),n(h)},e.Text.fromObject=function(t,i){return e.Object._fromObject("Text",t,i,"text")},e.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],e.util.createAccessors&&e.util.createAccessors(e.Text))}(e),S.util.object.extend(S.Text.prototype,{isEmptyStyles:function(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;var e=void 0===t?this.styles:{line:this.styles[t]};for(var i in e)for(var n in e[i])for(var r in e[i][n])return!1;return!0},styleHas:function(t,e){if(!this.styles||!t||""===t)return!1;if(void 0!==e&&!this.styles[e])return!1;var i=void 0===e?this.styles:{0:this.styles[e]};for(var n in i)for(var r in i[n])if(void 0!==i[n][r][t])return!0;return!1},cleanStyle:function(t){if(!this.styles||!t||""===t)return!1;var e,i,n=this.styles,r=0,o=!0,s=0;for(var a in n){for(var c in e=0,n[a]){var u;r++,(u=n[a][c]).hasOwnProperty(t)?(i?u[t]!==i&&(o=!1):i=u[t],u[t]===this[t]&&delete u[t]):o=!1,0!==Object.keys(u).length?e++:delete n[a][c]}0===e&&delete n[a]}for(var h=0;h<this._textLines.length;h++)s+=this._textLines[h].length;o&&r===s&&(this[t]=i,this.removeStyle(t))},removeStyle:function(t){if(this.styles&&t&&""!==t){var e,i,n,r=this.styles;for(i in r){for(n in e=r[i])delete e[n][t],0===Object.keys(e[n]).length&&delete e[n];0===Object.keys(e).length&&delete r[i]}}},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);this._getLineStyle(i.lineIndex)||this._setLineStyle(i.lineIndex),this._getStyleDeclaration(i.lineIndex,i.charIndex)||this._setStyleDeclaration(i.lineIndex,i.charIndex,{}),S.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},get2DCursorLocation:function(t,e){void 0===t&&(t=this.selectionStart);for(var i=e?this._unwrappedTextLines:this._textLines,n=i.length,r=0;r<n;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-1].length:t}},getSelectionStyles:function(t,e,i){void 0===t&&(t=this.selectionStart||0),void 0===e&&(e=this.selectionEnd||t);for(var n=[],r=t;r<e;r++)n.push(this.getStyleAtPosition(r,i));return n},getStyleAtPosition:function(t,e){var i=this.get2DCursorLocation(t);return(e?this.getCompleteStyleDeclaration(i.lineIndex,i.charIndex):this._getStyleDeclaration(i.lineIndex,i.charIndex))||{}},setSelectionStyles:function(t,e,i){void 0===e&&(e=this.selectionStart||0),void 0===i&&(i=this.selectionEnd||e);for(var n=e;n<i;n++)this._extendStyles(n,t);return this._forceClearCache=!0,this},_getStyleDeclaration:function(t,e){var i=this.styles&&this.styles[t];return i?i[e]:null},getCompleteStyleDeclaration:function(t,e){for(var i,n=this._getStyleDeclaration(t,e)||{},r={},o=0;o<this._styleProperties.length;o++)r[i=this._styleProperties[o]]=void 0===n[i]?this[i]:n[i];return r},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return!!this.styles[t]},_setLineStyle:function(t){this.styles[t]={}},_deleteLineStyle:function(t){delete this.styles[t]}}),function(){function t(t){t.textDecoration&&(t.textDecoration.indexOf("underline")>-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}S.IText=S.util.createClass(S.Text,S.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,caching:!0,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this.transformMatrix&&e.transform.apply(e,this.transformMatrix),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:n.left,topOffset:n.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,n,r,o=0,s=0,a=this.get2DCursorLocation(t);n=a.charIndex,i=a.lineIndex;for(var c=0;c<i;c++)o+=this.getHeightOfLine(c);e=this._getLineLeftOffset(i);var u=this.__charBounds[i][n];return u&&(s=u.left),0!==this.charSpacing&&n===this._textLines[i].length&&(s-=this._getWidthOfCharSpacing()),r={top:o,left:e+(s>0?s:0)},this.cursorOffsetCache=r,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),n=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(n,r,"fontSize"),s=this.scaleX*this.canvas.getZoom(),a=this.cursorWidth/s,c=t.topOffset,u=this.getValueOfPropertyAt(n,r,"deltaY");c+=(1-this._fontSizeFraction)*this.getHeightOfLine(n)/this.lineHeight-o*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.getValueOfPropertyAt(n,r,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-a/2,c+t.top+u,a,o)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,n=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,r=-1!==this.textAlign.indexOf("justify"),o=this.get2DCursorLocation(i),s=this.get2DCursorLocation(n),a=o.lineIndex,c=s.lineIndex,u=o.charIndex<0?0:o.charIndex,h=s.charIndex<0?0:s.charIndex,l=a;l<=c;l++){var f,d=this._getLineLeftOffset(l)||0,p=this.getHeightOfLine(l),g=0,v=0;if(l===a&&(g=this.__charBounds[a][u].left),l>=a&&l<c)v=r&&!this.isEndOfWrapping(l)?this.width:this.getLineWidth(l)||5;else if(l===c)if(0===h)v=this.__charBounds[c][h].left;else{var y=this._getWidthOfCharSpacing();v=this.__charBounds[c][h-1].left+this.__charBounds[c][h-1].width-y}f=p,(this.lineHeight<1||l===c&&this.lineHeight>1)&&(p/=this.lineHeight),this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",e.fillRect(t.left+d+g,t.top+t.topOffset+p,v-g,1)):(e.fillStyle=this.selectionColor,e.fillRect(t.left+d+g,t.top+t.topOffset,v-g,p)),t.topOffset+=f}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),S.IText.fromObject=function(e,i){if(t(e),e.styles)for(var n in e.styles)for(var r in e.styles[n])t(e.styles[n][r]);S.Object._fromObject("IText",e,i,"text")}}(),x=S.util.object.clone,S.util.object.extend(S.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],S.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,n){var r;return r={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){r.isAborted||t[n]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return r.isAborted}}),r},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},findLineBoundaryLeft:function(t){for(var e=0,i=t-1;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},searchWordBoundary:function(t,e){for(var i=this._text,n=this._reSpace.test(i[t])?t-1:t,r=i[n],o=S.reNonWord;!o.test(r)&&n>0&&n<i.length;)r=i[n+=e];return o.test(r)&&(n+=1===e?0:1),n},selectWord:function(t){t=t||this.selectionStart;var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(t){t=t||this.selectionStart;var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(t){if(!this.isEditing&&this.editable)return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(t),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(t){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.selected=!1,t.isEditing&&t.exitEditing()}))},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(t){if(this.__isMousedown&&this.isEditing){var e=this.getSelectionStartFromPointer(t.e),i=this.selectionStart,n=this.selectionEnd;(e===this.__selectionStartOnMouseDown&&i!==n||i!==e&&n!==e)&&(e>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var n=i.slice(0,t),r=S.util.string.graphemeSplit(n).length;if(t===e)return{selectionStart:r,selectionEnd:r};var o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+S.util.string.graphemeSplit(o).length}},fromGraphemeToStringSelection:function(t,e,i){var n=i.slice(0,t).join("").length;return t===e?{selectionStart:n,selectionEnd:n}:{selectionStart:n,selectionEnd:n+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),n=i.lineIndex,r=i.charIndex,o=this.getValueOfPropertyAt(n,r,"fontSize")*this.lineHeight,s=e.leftOffset,a=this.calcTransformMatrix(),c={x:e.left+s,y:e.top+e.topOffset+o},u=this.canvas.getRetinaScaling(),h=this.canvas.upperCanvasEl,l=h.width/u,f=h.height/u,d=l-o,p=f-o,g=h.clientWidth/l,v=h.clientHeight/f;return c=S.util.transformPoint(c,a),(c=S.util.transformPoint(c,this.canvas.viewportTransform)).x*=g,c.y*=v,c.x<0&&(c.x=0),c.x>d&&(c.x=d),c.y<0&&(c.y=0),c.y>p&&(c.y=p),c.x+=this.canvas._offset.left,c.y+=this.canvas._offset.top,{left:c.x+"px",top:c.y+"px",fontSize:o+"px",charHeight:o}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,n,r=this.get2DCursorLocation(t,!0),o=this.get2DCursorLocation(e,!0),s=r.lineIndex,a=r.charIndex,c=o.lineIndex,u=o.charIndex;if(s!==c){if(this.styles[s])for(i=a;i<this._unwrappedTextLines[s].length;i++)delete this.styles[s][i];if(this.styles[c])for(i=u;i<this._unwrappedTextLines[c].length;i++)(n=this.styles[c][i])&&(this.styles[s]||(this.styles[s]={}),this.styles[s][a+i-u]=n);for(i=s+1;i<=c;i++)delete this.styles[i];this.shiftLineStyles(c,s-c)}else if(this.styles[s]){n=this.styles[s];var h,l,f=u-a;for(i=a;i<u;i++)delete n[i];for(l in this.styles[s])(h=parseInt(l,10))>=u&&(n[h-f]=n[l],delete n[l])}},shiftLineStyles:function(t,e){var i=x(this.styles);for(var n in this.styles){var r=parseInt(n,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,n){var r,o={},s=!1;for(var a in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(r=this.styles[t][0===e?e:e-1]),this.styles[t]){var c=parseInt(a,10);c>=e&&(s=!0,o[c-e]=this.styles[t][a],delete this.styles[t][a])}for(s?this.styles[t+i]=o:delete this.styles[t+i];i>1;)i--,n&&n[i]?this.styles[t+i]={0:x(n[i])}:r?this.styles[t+i]={0:x(r)}:delete this.styles[t+i];this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,n){this.styles||(this.styles={});var r=this.styles[t],o=r?x(r):{};for(var s in i||(i=1),o){var a=parseInt(s,10);a>=e&&(r[a+i]=o[a],o[a-i]||delete r[a])}if(this._forceClearCache=!0,n)for(;i--;)Object.keys(n[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=x(n[i]));else if(r)for(var c=r[e?e-1:1];c&&i--;)this.styles[t][e+i]=x(c)},insertNewStyleBlock:function(t,e,i){for(var n=this.get2DCursorLocation(e,!0),r=[0],o=0,s=0;s<t.length;s++)"\n"===t[s]?r[++o]=0:r[o]++;for(r[0]>0&&(this.insertCharStyleObject(n.lineIndex,n.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),o&&this.insertNewlineStyleObject(n.lineIndex,n.charIndex+r[0],o),s=1;s<o;s++)r[s]>0?this.insertCharStyleObject(n.lineIndex+s,0,r[s],i):i&&(this.styles[n.lineIndex+s][0]=i[0]),i=i&&i.slice(r[s]+1);r[s]>0&&this.insertCharStyleObject(n.lineIndex+s,0,r[s],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?"right"===this._selectionDirection?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection="right":"left"===this._selectionDirection&&(this._selectionDirection="right",this.selectionStart=e),this.selectionEnd=i)},setSelectionInBoundaries:function(){var t=this.text.length;this.selectionStart>t?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),S.util.object.extend(S.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&this.setCursorByClick(t.e),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,n,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e=this.getLocalPointer(t),i=0,n=0,r=0,o=0,s=0,a=0,c=this._textLines.length;a<c&&r<=e.y;a++)r+=this.getHeightOfLine(a)*this.scaleY,s=a,a>0&&(o+=this._textLines[a-1].length+this.missingNewlineOffset(a-1));n=this._getLineLeftOffset(s)*this.scaleX;for(var u=0,h=this._textLines[s].length;u<h&&(i=n,(n+=this.__charBounds[s][u].kernedWidth*this.scaleX)<=e.x);u++)o++;return this._getNewSelectionStartFromOffset(e,i,n,o,h)},_getNewSelectionStartFromOffset:function(t,e,i,n,r){var o=t.x-e,s=i-t.x,a=n+(s>o||s<0?0:1);return this.flipX&&(a=r-a),a>this._text.length&&(a=this._text.length),a}}),S.util.object.extend(S.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=S.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; paddingーtop: "+t.fontSize+";",S.document.body.appendChild(this.hiddenTextarea),S.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),S.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),S.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),S.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),S.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),S.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),S.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),S.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),S.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(S.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing&&!this.inCompositionMode){if(t.keyCode in this.keysMap)this[this.keysMap[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,n,r=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,o=this._text.length,s=r.length,a=s-o;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var c=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),u=this.selectionStart>c.selectionStart;this.selectionStart!==this.selectionEnd?(i=this._text.slice(this.selectionStart,this.selectionEnd),a+=this.selectionEnd-this.selectionStart):s<o&&(i=u?this._text.slice(this.selectionEnd+a,this.selectionEnd):this._text.slice(this.selectionStart,this.selectionStart-a)),n=r.slice(c.selectionEnd-a,c.selectionEnd),i&&i.length&&(this.selectionStart!==this.selectionEnd?this.removeStyleFromTo(this.selectionStart,this.selectionEnd):u?this.removeStyleFromTo(this.selectionEnd-i.length,this.selectionEnd):this.removeStyleFromTo(this.selectionEnd,this.selectionEnd+i.length)),n.length&&(e&&n.join("")===S.copiedText&&!S.disableStyleCopyPaste?this.insertNewStyleBlock(n,this.selectionStart,S.copiedTextStyle):this.insertNewStyleBlock(n,this.selectionStart)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(t){this.compositionStart=t.target.selectionStart,this.compositionEnd=t.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(S.copiedText=this.getSelectedText(),S.disableStyleCopyPaste?S.copiedTextStyle=null:S.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(t){return t&&t.clipboardData||S.window.clipboardData},_getWidthBeforeCursor:function(t,e){var i,n=this._getLineLeftOffset(t);return e>0&&(n+=(i=this.__charBounds[t][e-1]).left+i.width),n},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(r===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var o=n.charIndex,s=this._getWidthBeforeCursor(r,o),a=this._getIndexOnLine(r+1,s);return this._textLines[r].slice(o).length+a+1+this.missingNewlineOffset(r)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),n=this.get2DCursorLocation(i),r=n.lineIndex;if(0===r||t.metaKey||33===t.keyCode)return-i;var o=n.charIndex,s=this._getWidthBeforeCursor(r,o),a=this._getIndexOnLine(r-1,s),c=this._textLines[r].slice(0,o),u=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+a-c.length+(1-u)},_getIndexOnLine:function(t,e){for(var i,n,r=this._textLines[t],o=this._getLineLeftOffset(t),s=0,a=0,c=r.length;a<c;a++)if((o+=i=this.__charBounds[t][a].width)>e){n=!0;var u=o-i,h=o,l=Math.abs(u-e);s=Math.abs(h-e)<l?a:a-1;break}return n||(s=r.length-1),s},moveCursorDown:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var n;if(t.altKey)n=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;n=this["findLineBoundary"+i](this[e])}if(void 0!==typeof n&&this[e]!==n)return this[e]=n,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,n){void 0===n&&(n=i),n>i&&this.removeStyleFromTo(i,n);var r=S.util.string.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[].concat(this._text.slice(0,i),r,this._text.slice(n)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),w=S.util.toFixed,C=/ +/g,S.util.object.extend(S.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",e?'text-decoration="'+e+'" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",t.textSpans.join(""),"</text>\n"]},_getSVGTextAndBg:function(t,e){var i,n=[],r=[],o=t;this._setSVGBg(r);for(var s=0,a=this._textLines.length;s<a;s++)i=this._getLineLeftOffset(s),(this.textBackgroundColor||this.styleHas("textBackgroundColor",s))&&this._setSVGTextLineBg(r,s,e+i,o),this._setSVGTextLineText(n,s,e+i,o),o+=this.getHeightOfLine(s);return{textSpans:n,textBgRects:r}},_createTextCharSpan:function(t,e,i,n){var r=t!==t.trim()||t.match(C),o=this.getSvgSpanStyles(e,r),s=o?'style="'+o+'"':"",a=e.deltaY,c="",u=S.Object.NUM_FRACTION_DIGITS;return a&&(c=' dy="'+w(a,u)+'" '),['<tspan x="',w(i,u),'" y="',w(n,u),'" ',c,s,">",S.util.string.escapeXml(t),"</tspan>"].join("")},_setSVGTextLineText:function(t,e,i,n){var r,o,s,a,c,u=this.getHeightOfLine(e),h=-1!==this.textAlign.indexOf("justify"),l="",f=0,d=this._textLines[e];n+=u*(1-this._fontSizeFraction)/this.lineHeight;for(var p=0,g=d.length-1;p<=g;p++)c=p===g||this.charSpacing,l+=d[p],s=this.__charBounds[e][p],0===f?(i+=s.kernedWidth-s.width,f+=s.width):f+=s.kernedWidth,h&&!c&&this._reSpaceAndTab.test(d[p])&&(c=!0),c||(r=r||this.getCompleteStyleDeclaration(e,p),o=this.getCompleteStyleDeclaration(e,p+1),c=this._hasStyleChangedForSvg(r,o)),c&&(a=this._getStyleDeclaration(e,p)||{},t.push(this._createTextCharSpan(l,a,i,n)),l="",r=o,i+=f,f=0)},_pushTextBgRect:function(t,e,i,n,r,o){var s=S.Object.NUM_FRACTION_DIGITS;t.push("\t\t<rect ",this._getFillAttributes(e),' x="',w(i,s),'" y="',w(n,s),'" width="',w(r,s),'" height="',w(o,s),'"></rect>\n')},_setSVGTextLineBg:function(t,e,i,n){for(var r,o,s=this._textLines[e],a=this.getHeightOfLine(e)/this.lineHeight,c=0,u=0,h=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),l=0,f=s.length;l<f;l++)r=this.__charBounds[e][l],(o=this.getValueOfPropertyAt(e,l,"textBackgroundColor"))!==h?(h&&this._pushTextBgRect(t,h,i+u,n,c,a),u=r.left,c=r.width,h=o):c+=r.kernedWidth;o&&this._pushTextBgRect(t,o,i+u,n,c,a)},_getFillAttributes:function(t){var e=t&&"string"==typeof t?new S.Color(t):"";return e&&e.getSource()&&1!==e.getAlpha()?'opacity="'+e.getAlpha()+'" fill="'+e.setAlpha(1).toRgb()+'"':'fill="'+t+'"'},_getSVGLineTopOffset:function(t){for(var e,i=0,n=0;n<t;n++)i+=this.getHeightOfLine(n);return e=this.getHeightOfLine(n),{lineTop:i,offset:(this._fontSizeMult-this._fontSizeFraction)*e/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(t){return S.Object.prototype.getSvgStyles.call(this,t)+" white-space: pre;"}}),function(t){"use strict";var e=t.fabric||(t.fabric={});e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:e.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,n=0,r={},o=0;o<t.graphemeLines.length;o++)"\n"===t.graphemeText[n]&&o>0?(i=0,n++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[n])&&o>0&&(i++,n++),r[o]={line:e,offset:i},n+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[i];n&&(i=n.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,n=0,r=!1,o=this._styleMap[t],s=this._styleMap[t+1];for(var a in o&&(t=o.line,n=o.offset),s&&(r=s.line===t,e=s.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var c in i[a])if(c>=n&&(!r||c<e))for(var u in i[a][c])return!1;return!0},_getStyleDeclaration:function(t,e){if(this._styleMap&&!this.isWrapping){var i=this._styleMap[t];if(!i)return null;t=i.line,e=i.offset+e}return this.callSuper("_getStyleDeclaration",t,e)},_setStyleDeclaration:function(t,e,i){var n=this._styleMap[t];t=n.line,e=n.offset+e,this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line,e=i.offset+e,delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return!!this.styles[e.line]},_setLineStyle:function(t){var e=this._styleMap[t];this.styles[e.line]={}},_wrapText:function(t,e){var i,n=[];for(this.isWrapping=!0,i=0;i<t.length;i++)n=n.concat(this._wrapLine(t[i],i,e));return this.isWrapping=!1,n},_measureWord:function(t,e,i){var n,r=0;i=i||0;for(var o=0,s=t.length;o<s;o++){r+=this._getGraphemeBox(t[o],e,o+i,n,!0).kernedWidth,n=t[o]}return r},_wrapLine:function(t,i,n,r){var o=0,s=this.splitByGrapheme,a=[],c=[],u=s?e.util.string.graphemeSplit(t):t.split(this._wordJoiners),h="",l=0,f=s?"":" ",d=0,p=0,g=0,v=!0,y=s?0:this._getWidthOfCharSpacing();r=r||0;0===u.length&&u.push([]),n-=r;for(var m=0;m<u.length;m++)h=s?u[m]:e.util.string.graphemeSplit(u[m]),d=this._measureWord(h,i,l),l+=h.length,(o+=p+d-y)>=n&&!v?(a.push(c),c=[],o=d,v=!0):o+=y,v||s||c.push(f),c=c.concat(h),p=this._measureWord([f],i,l),l++,v=!1,d>g&&(g=d);return m&&a.push(c),g+r>this.dynamicMinWidth&&(this.dynamicMinWidth=g-y+r),a},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),n=this._wrapText(i.lines,this.width),r=new Array(n.length),o=0;o<n.length;o++)r[o]=n[o].join("");return i.lines=r,i.graphemeLines=n,i},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var t={};for(var e in this._styleMap)this._textLines[e]&&(t[this._styleMap[e].line]=1);for(var e in this.styles)t[e]||delete this.styles[e]},toObject:function(t){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(t))}}),e.Textbox.fromObject=function(t,i){return e.Object._fromObject("Textbox",t,i,"text")}}(e)}).call(this,i(46).Buffer)},function(t,e,i){var n,r,o,s=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)},function(t,e){function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});n=[i,e,i(3),i(0),i(2)],void 0===(r=function(t,e,i,n,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.VerticalRule=void 0;var o=function(t){function e(e,r,o){var s=t.call(this,n.ObjectType.VERTICAL_RULE,e,r,o)||this;return s.strokeWidth$=new i.BehaviorSubject(2),s.canvas=e,s.strokeWidth$.next(s.getDimensions().width.px),s.fabricObject.set({strokeWidth:0}),s}return s(e,t),e.prototype.getStrokeWidth=function(){return this.fabricObject.width},e.prototype.getStrokeWidth$=function(){return this.strokeWidth$},e.prototype.setStrokeWidth=function(t){this.strokeWidth$.next(t),this.data.strokeWidth=t,this.setPosition({width:t}),this.canvas.notifyObjectListChanged(),this.redraw()},e.prototype.getColor=function(){return this.fabricObject.fill},e.prototype.setColor=function(t){this.fabricObject.set({fill:t,stroke:t}),this.data.color=t,this.redraw()},e.prototype.centerHorizontally=function(){t.prototype.centerHorizontallyInternal.call(this)},e.prototype.centerVertically=function(){t.prototype.centerVerticallyInternal.call(this)},e.prototype.setHeight=function(t){this.setPosition({height:t}),this.canvas.notifyObjectListChanged()},e.prototype.nudgeUp=function(){t.prototype.nudgeInternal.call(this,0,-1)},e.prototype.nudgeDown=function(){t.prototype.nudgeInternal.call(this,0,1)},e.prototype.nudgeLeft=function(){t.prototype.nudgeInternal.call(this,-1,0)},e.prototype.nudgeRight=function(){t.prototype.nudgeInternal.call(this,1,0)},e}(r.AbstractCanvasObject);e.VerticalRule=o}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultCanvasProfile=void 0;var i=function(){this.allowMultiSelect=!1,this.enterTextEditImmediatelyOnSelect=!0,this.allowObjectsToLeaveCanvas=!1,this.allowMove=!1,this.allowRotate=!1,this.allowScale=!1,this.defaultFont="Lato",this.defaultFontSize=8,this.defaultFontColor="#000000",this.defaultLineHeight=1.8,this.defaultCharacterSpacing=0,this.defaultTextAlignment="left",this.defaultBorderColor="#000000",this.defaultBorderWidth=1,this.defaultCutoffColor="#000000",this.defaultCutoffWidth=1};e.DefaultCanvasProfile=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectType=void 0,function(t){t.TEXT="TEXT",t.BORDER="BORDER",t.IMAGE="IMAGE",t.RECTANGLE="RECTANGLE",t.LIBRARY_IMAGE="LIBRARY_IMAGE",t.CUTOFF="CUTOFF",t.VERTICAL_RULE="VERTICAL_RULE",t.HORIZONTAL_RULE="HORIZONTAL_RULE"}(e.ObjectType||(e.ObjectType={}))}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r;n=[i,e,i(1)],void 0===(r=function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Print6ColCanvasDimensions=void 0;var n=function(){function t(t,e){this.widthUnit="column(s)",this.heightUnit="cm",this.width=t,this.gutterCount=Math.max(0,t-1),this.gutterTotalMm=3*this.gutterCount,this.columnsTotalMm=41*t,this.widthMm=Math.max(0,this.columnsTotalMm+this.gutterTotalMm),this.widthPx=i.round(3.937*this.widthMm),this.height=e,this.heightMm=Math.max(0,10*e),this.heightPx=i.round(3.937*this.heightMm)}return t.prototype.withSize=function(e,i){return new t(e,i)},t.prototype.widthPxToMm=function(t){return t/3.937},t.prototype.heightPxToMm=function(t){return t/3.937},t}();e.Print6ColCanvasDimensions=n}.apply(e,n))||(t.exports=r)},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,i){var n,r;n=[i,e,i(1)],void 0===(r=function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Print8ColCanvasDimensions=void 0;var n=function(){function t(t,e){this.widthUnit="column(s)",this.heightUnit="cm",this.width=t,this.gutterCount=Math.max(0,t-1),this.gutterTotalMm=2.1053*this.gutterCount,this.columnsTotalMm=30.8772*t,this.widthMm=Math.max(0,this.columnsTotalMm+this.gutterTotalMm),this.widthPx=i.round(3.937*this.widthMm),this.height=e,this.heightMm=Math.max(0,10*e),this.heightPx=i.round(3.937*this.heightMm)}return t.prototype.withSize=function(e,i){return new t(e,i)},t.prototype.widthPxToMm=function(t){return t/3.937},t.prototype.heightPxToMm=function(t){return t/3.937},t}();e.Print8ColCanvasDimensions=n}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PinToBottomLayoutFunction=void 0;var i=function(){function t(){}return t.prototype.execute=function(t){t.getObjectsInternal().forEach((function(t){return t.moveToPinnedPosition()}))},t}();e.PinToBottomLayoutFunction=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r;n=[i,e,i(1),i(0)],void 0===(r=function(t,e,i,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ResizeCanvasLayoutFunction=void 0;var r=function(){function t(){}return t.prototype.execute=function(t){if(!t.getLayoutManager().isEnforcedPositioning){for(var e=t.getDimensions(),r=t.getBaseDimensions(),o=i.default(t.getObjectsByTypeInternal(n.ObjectType.TEXT)).filter((function(t){return t.isResizeCanvas()})).reduce((function(t,e){return t+e.getSizeIncreaseSinceCreation()}),0),s=r.withSize(e.width,0);s.heightPx<o;)s=s.withSize(s.width,s.height+1);var a=s.withSize(s.width,r.height+s.height);e.height!==a.height&&t.setDimensions(a),t.getObjectsInternal().forEach((function(t){return t.setCoords()})),t.redraw()}},t}();e.ResizeCanvasLayoutFunction=r}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UpdateObjectDimensionsLayoutFunction=void 0;var i=function(){function t(){}return t.prototype.execute=function(t){t.getObjectsInternal().forEach((function(t){return t.updateDimensions()}))},t}();e.UpdateObjectDimensionsLayoutFunction=i}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r;n=[i,e,i(1),i(1),i(6),i(0)],void 0===(r=function(t,e,i,n,r,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StackObjectsLayoutFunction=void 0;var s=function(){function t(){}return t.prototype.execute=function(t){var e=t.getMargin(),n=t.getDimensions(),r=t.getObjectsByTypesInternal(o.ObjectType.TEXT,o.ObjectType.IMAGE,o.ObjectType.RECTANGLE,o.ObjectType.VERTICAL_RULE,o.ObjectType.HORIZONTAL_RULE),s=i(r).partition((function(t){return t.isPinToBottom()})).value(),a=s[0],c=s[1],u=n.widthPx-e.right-e.left;this.applyWidths(r,u);var h=this.getRows(c),l=this.getRows(a),f=e.top+h.totalHeight+l.totalHeight+e.bottom;this.adjustCanvasSize(t,f),this.layoutFooter(l,t),this.layoutBody(h,t,l.totalHeight)},t.prototype.layoutFooter=function(t,e){var i=e.getDimensions(),s=e.getMargin(),a=i.widthPx-s.left-s.right,c=i.heightPx-s.bottom-t.totalHeight,u=0;n.each(t.rows,(function(t){n.each(t.objects,(function(e){var i=u/100*a,n=r.oc(e.getMargin()).left(0),h=s.left+i+n;e.getType()===o.ObjectType.VERTICAL_RULE&&e.setPosition({height:t.height}),e.setPosition({top:c+r.oc(e.getMargin()).top(0),left:h}),u+=e.getColumnWidthPercent()})),u=0,c+=t.height}))},t.prototype.layoutBody=function(t,e,i){for(var n=e.getDimensions(),s=e.getMargin(),a=n.widthPx-s.left-s.right,c=(n.heightPx-s.top-s.bottom-i-t.totalHeight)/this.countSpaces(t),u=s.top,h=0,l=0;l<t.rows.length;l++){for(var f=t.rows[l],d=t.rows[l+1],p=0,g=f.objects;p<g.length;p++){var v=g[p],y=h/100*a,m=r.oc(v.getMargin()).left(0),b=s.left+y+m;v.getType()===o.ObjectType.TEXT&&v.isBulleted()&&(b+=15),v.getType()===o.ObjectType.VERTICAL_RULE&&v.setPosition({height:f.height}),v.setPosition({top:u+r.oc(v.getMargin()).top(0),left:b}),h+=v.getColumnWidthPercent()}h=0,u+=f.height;var _=1===f.objects.length&&f.objects[0].getType()===o.ObjectType.HORIZONTAL_RULE,x=1===r.oc(d).objects.length()&&r.oc(d).objects()[0].getType()===o.ObjectType.HORIZONTAL_RULE;_||x||(u+=c)}},t.prototype.applyWidths=function(t,e){i(t).forEach((function(t){var i=t.getColumnWidthPercent()/100*e-r.oc(t.getMargin()).left(0)-r.oc(t.getMargin()).right(0);t.getType()!==o.ObjectType.VERTICAL_RULE&&(t.getType()===o.ObjectType.TEXT&&t.isBulleted()&&(i-=15),t.setPosition({width:i}),t.updateDimensions())}))},t.prototype.adjustCanvasSize=function(t,e){for(var i=t.getDimensions(),n=t.getDimensions().withSize(i.width,1);n.heightPx<e;)n=n.withSize(i.width,n.height+1);i.height!==n.height&&t.setDimensions(n)},t.prototype.getRows=function(t){var e=this,i={totalHeight:0,rows:[]},r=0,s={objects:[],height:1};return n.each(t,(function(t){var n=t.getColumnWidthPercent(),a=e.getObjectHeight(t);r+n>100&&(i.rows.push(s),s={objects:[],height:1},r=0),s.objects.push(t),t.getType()!==o.ObjectType.VERTICAL_RULE&&(s.height=Math.max(s.height,a)),r+=n})),s.objects.length&&i.rows.push(s),i.totalHeight=n.reduce(i.rows,(function(t,e){return t+e.height}),0),i},t.prototype.getObjectHeight=function(t){return t.getBoundingBox().height+r.oc(t.getMargin()).top(0)+r.oc(t.getMargin()).bottom(0)},t.prototype.countSpaces=function(t){for(var e=0,i=0;i<t.rows.length-1;i++){var n=t.rows[i],s=t.rows[i+1],a=1===n.objects.length&&n.objects[0].getType()===o.ObjectType.HORIZONTAL_RULE,c=1===r.oc(s).objects.length()&&r.oc(s).objects()[0].getType()===o.ObjectType.HORIZONTAL_RULE;a||c||e++}return e},t}();e.StackObjectsLayoutFunction=s}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutableBackgroundColor=void 0,e.isMutableBackgroundColor=function(t){return"setBackgroundColor"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutableColor=void 0,e.isMutableColor=function(t){return"setColor"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutableImage=void 0,e.isMutableImage=function(t){return"setImageUrl"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutablePosition=void 0,e.isMutablePosition=function(t){return"centerHorizontally"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutableText=void 0,e.isMutableText=function(t){return"setText"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isMutableTextStyle=void 0,e.isMutableTextStyle=function(t){return"getTextSelection"in t}}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){"use strict";(function(t){
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var n=i(47),r=i(48),o=i(49);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,i);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return u(this,t,e,i)}function u(t,e,i,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,i,n){if(e.byteLength,i<0||e.byteLength<i)throw new RangeError("'offset' is out of bounds");if(e.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===i&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,i):new Uint8Array(e,i,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=f(t,e);return t}(t,e,i,n):"string"==typeof e?function(t,e,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(e,i),r=(t=a(t,n)).write(e,i);r!==n&&(t=t.slice(0,r));return t}(t,e,i):function(t,e){if(c.isBuffer(e)){var i=0|d(e.length);return 0===(t=a(t,i)).length||e.copy(t,0,0,i),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):f(t,e);if("Buffer"===e.type&&o(e.data))return f(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(h(e),t=a(t,e<0?0:0|d(e)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function f(t,e){var i=e.length<0?0:0|d(e.length);t=a(t,i);for(var n=0;n<i;n+=1)t[n]=255&e[n];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Y(t).length;default:if(n)return U(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,i);case"utf8":case"utf-8":return O(this,e,i);case"ascii":return j(this,e,i);case"latin1":case"binary":return P(this,e,i);case"base64":return T(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function y(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,i/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){var h=-1;for(o=i;o<a;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(i+c>a&&(i=a-c),o=i;o>=0;o--){for(var l=!0,f=0;f<c;f++)if(u(t,o+f)!==u(e,f)){l=!1;break}if(l)return o}return-1}function b(t,e,i,n){i=Number(i)||0;var r=t.length-i;n?(n=Number(n))>r&&(n=r):n=r;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[i+s]=a}return s}function _(t,e,i,n){return N(U(e,t.length-i),t,i,n)}function x(t,e,i,n){return N(function(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}(e),t,i,n)}function w(t,e,i,n){return x(t,e,i,n)}function C(t,e,i,n){return N(Y(e),t,i,n)}function S(t,e,i,n){return N(function(t,e){for(var i,n,r,o=[],s=0;s<t.length&&!((e-=2)<0);++s)i=t.charCodeAt(s),n=i>>8,r=i%256,o.push(r),o.push(n);return o}(e,t.length-i),t,i,n)}function T(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function O(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r<i;){var o,s,a,c,u=t[r],h=null,l=u>239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[r+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=t[r+1],s=t[r+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=t[r+1],s=t[r+2],a=t[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),r+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n<e;)i+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return i}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,i){return u(null,t,e,i)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,i){return function(t,e,i,n){return h(e),e<=0?a(t,e):void 0!==i?"string"==typeof n?a(t,e).fill(i,n):a(t,e).fill(i):a(t,e)}(null,t,e,i)},c.allocUnsafe=function(t){return l(null,t)},c.allocUnsafeSlow=function(t){return l(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var i=t.length,n=e.length,r=0,o=Math.min(i,n);r<o;++r)if(t[r]!==e[r]){i=t[r],n=e[r];break}return i<n?-1:n<i?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var i;if(void 0===e)for(e=0,i=0;i<t.length;++i)e+=t[i].length;var n=c.allocUnsafe(e),r=0;for(i=0;i<t.length;++i){var s=t[i];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,r),r+=s.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,i,n,r){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var o=(r>>>=0)-(n>>>=0),s=(i>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,r),h=t.slice(e,i),l=0;l<a;++l)if(u[l]!==h[l]){o=u[l],s=h[l];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,i){return-1!==this.indexOf(t,e,i)},c.prototype.indexOf=function(t,e,i){return y(this,t,e,i,!0)},c.prototype.lastIndexOf=function(t,e,i){return y(this,t,e,i,!1)},c.prototype.write=function(t,e,i,n){if(void 0===e)n="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)n=e,i=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var r=this.length-e;if((void 0===i||i>r)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,i);case"utf8":case"utf-8":return _(this,t,e,i);case"ascii":return x(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return C(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(127&t[r]);return n}function P(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;r<i;++r)n+=String.fromCharCode(t[r]);return n}function E(t,e,i){var n=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>n)&&(i=n);for(var r="",o=e;o<i;++o)r+=W(t[o]);return r}function k(t,e,i){for(var n=t.slice(e,i),r="",o=0;o<n.length;o+=2)r+=String.fromCharCode(n[o]+256*n[o+1]);return r}function A(t,e,i){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>i)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,i,n,r,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(i+n>t.length)throw new RangeError("Index out of range")}function M(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,o=Math.min(t.length-i,2);r<o;++r)t[i+r]=(e&255<<8*(n?r:1-r))>>>8*(n?r:1-r)}function I(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,o=Math.min(t.length-i,4);r<o;++r)t[i+r]=e>>>8*(n?r:3-r)&255}function F(t,e,i,n,r,o){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function R(t,e,i,n,o){return o||F(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,o){return o||F(t,0,i,8),r.write(t,e,i,n,52,8),i+8}c.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(i=this.subarray(t,e)).__proto__=c.prototype;else{var r=e-t;i=new c(r,void 0);for(var o=0;o<r;++o)i[o]=this[o+t]}return i},c.prototype.readUIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n},c.prototype.readUIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t+--e],r=1;e>0&&(r*=256);)n+=this[t+--e]*r;return n},c.prototype.readUInt8=function(t,e){return e||A(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||A(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||A(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=this[t],r=1,o=0;++o<e&&(r*=256);)n+=this[t+o]*r;return n>=(r*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||A(t,e,this.length);for(var n=e,r=1,o=this[t+--n];n>0&&(r*=256);)o+=this[t+--n]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||A(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(t,e){e||A(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(t,e){return e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||A(t,4,this.length),r.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||A(t,8,this.length),r.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,o=0;for(this[e]=255&t;++o<i&&(r*=256);)this[e+o]=t/r&255;return e+i},c.prototype.writeUIntBE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||D(this,t,e,i,Math.pow(2,8*i)-1,0);var r=i-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+i},c.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=0,s=1,a=0;for(this[e]=255&t;++o<i&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);D(this,t,e,i,r-1,-r)}var o=i-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+i},c.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,i){return R(this,t,e,!0,i)},c.prototype.writeFloatBE=function(t,e,i){return R(this,t,e,!1,i)},c.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},c.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},c.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-i&&(n=t.length-e+i);var r,o=n-i;if(this===t&&i<e&&e<n)for(r=o-1;r>=0;--r)t[r+e]=this[r+i];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(r=0;r<o;++r)t[r+e]=this[r+i];else Uint8Array.prototype.set.call(t,this.subarray(i,i+o),e);return o},c.prototype.fill=function(t,e,i,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===t.length){var r=t.charCodeAt(0);r<256&&(t=r)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;var o;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(o=e;o<i;++o)this[o]=t;else{var s=c.isBuffer(t)?t:U(new c(t,n).toString()),a=s.length;for(o=0;o<i-e;++o)this[o+e]=s[o%a]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function U(t,e){var i;e=e||1/0;for(var n=t.length,r=null,o=[],s=0;s<n;++s){if((i=t.charCodeAt(s))>55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,i,n){for(var r=0;r<n&&!(r+i>=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,i){return 3*(e+i)/4-i}(0,s,a)),h=0,l=a>0?s-4:s;for(i=0;i<l;i+=4)e=r[t.charCodeAt(i)]<<18|r[t.charCodeAt(i+1)]<<12|r[t.charCodeAt(i+2)]<<6|r[t.charCodeAt(i+3)],c[h++]=e>>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,c[h++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=0,a=i-r;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],r[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function h(t,e,i){for(var r,o,s=[],a=e;a<i;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=r)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,c=(1<<a)-1,u=c>>1,h=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=f,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,i,n,r,o){var s,a,c,u=8*o-r-1,h=(1<<u)-1,l=h>>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*c-1)*Math.pow(2,r),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),s=0));r>=8;t[i+d]=255&a,d+=p,a/=256,r-=8);for(s=s<<r|a,u+=r;u>0;t[i+d]=255&s,d+=p,s/=256,u-=8);t[i+d-p]|=128*g}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){},function(t,e){},function(t,e){},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ImageType=void 0,function(t){t.DEFAULT="DEFAULT",t.BACKGROUND="BACKGROUND",t.LOGO="LOGO",t.PHOTO="PHOTO"}(e.ImageType||(e.ImageType={}))}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)},function(t,e,i){var n,r,o=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},a=this&&this.__spreadArrays||function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n};n=[i,e,i(3),i(1),i(1),i(19),i(22),i(18),i(21),i(23),i(12),i(4),i(16),i(6),i(25),i(20),i(9),i(29),i(26),i(7),i(24)],void 0===(r=function(t,e,i,n,r,c,u,h,l,f,d,p,g,v,y,m,b,_,x,w,C){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InteractiveCanvas=void 0;var S=function(){function t(t,e){var n=this;this.devicePixelRatio=e,this.fontLibrary=new b.FontLibrary,this.dimensionChangeRejections$=new i.Subject,this.IMAGE_CAPTURE_COEFFICIENT=this.calculateImageCaptureCoefficient(),this.fabricCanvas=new C.fabric.Canvas(t),this.baseDimensions=new w.PixelCanvasDimensions(this.fabricCanvas.width,this.fabricCanvas.height);this.dimensions$=new i.BehaviorSubject(this.baseDimensions),this.dimensionRestrictions$=new i.BehaviorSubject({width:{min:1},height:{min:1}}),this.zoom$=new i.BehaviorSubject(1),this.profile$=new i.BehaviorSubject(new x.DefaultCanvasProfile),this.layoutManager$=new i.BehaviorSubject(new d.AdvancedLayoutManager(this)),this.backgroundColor$=new i.BehaviorSubject(this.fabricCanvas.backgroundColor),this.objects$=new i.BehaviorSubject([]),this.selection$=new i.BehaviorSubject(new T([])),this.fabricCanvas.on("selection:updated",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:created",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("selection:cleared",(function(){return n.onFabricSelectionChanged()})),this.fabricCanvas.on("text:editing:entered",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:editing:exited",(function(){return n.onTextEditing()})),this.fabricCanvas.on("text:changed",(function(){return n.onTextChange()})),this.fabricCanvas.stateful=!0,this.fabricCanvas.preserveObjectStacking=!0,this.fabricCanvas.perPixelTargetFind=!0,this.fabricCanvas.targetFindTolerance=10,this.setBackgroundColor("#FFFFFF")}return t.prototype.getFontLibrary=function(){return this.fontLibrary},t.prototype.getProfile=function(){return this.profile$.value},t.prototype.getProfile$=function(){return this.profile$},t.prototype.setProfile=function(t){this.profile$.next(t),this.onProfileChanged(t),this.redraw()},t.prototype.getLayoutManager=function(){return this.layoutManager$.value},t.prototype.getLayoutManager$=function(){return this.layoutManager$},t.prototype.setLayoutManager=function(t){t===p.LayoutManager.STANDARD?this.layoutManager$.next(new g.StandardLayoutManager(this)):this.layoutManager$.next(new d.AdvancedLayoutManager(this)),this.layoutManager$.value.onInit()},t.prototype.getBackgroundColor=function(){return this.backgroundColor$.value},t.prototype.getBackgroundColor$=function(){return this.backgroundColor$},t.prototype.setBackgroundColor=function(t){void 0===t&&(t="White"),this.fabricCanvas.setBackgroundColor(t,(function(){})),this.fabricCanvas.renderAll(),this.backgroundColor$.next(t)},t.prototype.getDimensions=function(){return this.dimensions$.value},t.prototype.getBaseDimensions=function(){return this.baseDimensions},t.prototype.getDimensions$=function(){return this.dimensions$},t.prototype.setDimensions=function(t){if(this.dimensionsExceedRestrictions(t))return console.debug("Requested canvas dimensions exceed current restrictions",t,this.dimensionRestrictions$.value),void this.dimensionChangeRejections$.next(t);this.updateCanvasDimensions(t,this.zoom$.value),this.dimensions$.next(t),this.onDimensionsChange(),this.notifyObjectListChanged()},t.prototype.setBaseDimensions=function(t){this.baseDimensions=t,this.setDimensions(t),this.notifyObjectListChanged()},t.prototype.getDimensionChangeRejections$=function(){return this.dimensionChangeRejections$},t.prototype.getDimensionsRestrictions=function(){return this.dimensionRestrictions$.value},t.prototype.getDimensionsRestrictions$=function(){return this.dimensionRestrictions$},t.prototype.setDimensionRestrictions=function(t){this.dimensionRestrictions$.next(t)},t.prototype.getMargin=function(){var t=this.getObjectsByTypeInternal(_.ObjectType.BORDER).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0),e=this.getObjectsByTypeInternal(_.ObjectType.CUTOFF).map((function(t){return t.getStrokeWidth()})).reduce((function(t,e){return Math.max(t,e)}),0);return{top:t,right:t,bottom:Math.max(e,t),left:t}},t.prototype.getZoom=function(){return this.zoom$.value},t.prototype.getZoom$=function(){return this.zoom$},t.prototype.setZoom=function(t){this.updateCanvasDimensions(this.dimensions$.value,t),this.zoom$.next(t)},t.prototype.getObjects=function(){return this.objects$.value},t.prototype.getObjectsInternal=function(){return this.objects$.value},t.prototype.getObjectsByTypeInternal=function(t){return n(this.getObjectsInternal()).filter((function(e){return e.getType()===t})).value()},t.prototype.getObjectsByTypesInternal=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this.getObjectsInternal()).filter((function(e){return n(t).includes(e.getType())})).value()},t.prototype.getObjects$=function(){return this.objects$},t.prototype.removeObject=function(t){var e=this.findFabricObject(t.getId());this.fabricCanvas.remove(e),this.objects$.next(n(this.objects$.value).filter((function(e){return e.getId()!==t.getId()})).value()),this.onObjectListChange()},t.prototype.addImageObject=function(t){return o(this,void 0,void 0,(function(){var e,i,n=this;return s(this,(function(r){switch(r.label){case 0:return 2,e=this.dimensions$.value.widthPx/2,i={crossOrigin:"anonymous"},[4,new Promise((function(r){C.fabric.Image.fromURL(t,(function(t){var i=n.randomId(),o=1,s=o*t.width;s>e&&(o=e/s),t.set({id:i,scaleX:o,scaleY:o}),n.fabricCanvas.add(t);var a=new l.Image(n,t);n.trackNewObject(a),n.fabricCanvas.setActiveObject(t),n.syncObjectList(),r(a)}),i)}))];case 1:return[2,r.sent()]}}))}))},t.prototype.addTextObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a,c,u;return s(this,(function(s){return t=this.profile$.value,e=this.randomId(),i=t.defaultFontSize,n=this.getDimensions().widthPx,r=this.getLowestTextPoint(),o=Math.min(r,this.getDimensions().heightPx-i),a={id:e,top:o,left:5,width:n-10,fill:t.defaultFontColor,fontSize:i,fontFamily:t.defaultFont,textAlign:t.defaultTextAlignment,multiLine:!0,lineHeight:t.defaultLineHeight,charSpacing:t.defaultCharacterSpacing},c=new C.fabric.Textbox("Text goes here",a),this.fabricCanvas.add(c),u=new f.Text(this,c),this.trackNewObject(u),this.fabricCanvas.setActiveObject(c),this.syncObjectList(),[2,u]}))}))},t.prototype.addRectangleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a;return s(this,(function(s){return t=this.getDimensions().widthPx,e=this.getDimensions().heightPx,i=t/2,n=e/2,r={id:this.randomId(),width:t/2,height:2,top:e/2-n/2,left:t/2-i/2,fill:"#000000"},o=new C.fabric.Rect(r),this.fabricCanvas.add(o),a=new u.Rectangle(this,o),this.trackNewObject(a),this.fabricCanvas.setActiveObject(o),this.syncObjectList(),[2,a]}))}))},t.prototype.addCutoffObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r,o,a;return s(this,(function(s){return t=this.profile$.value,e=t.defaultCutoffWidth,i=this.getDimensions().widthPx,n=this.getDimensions().heightPx,r={id:this.randomId(),width:i,height:e,top:n-e,left:0,fill:t.defaultCutoffColor},o=new C.fabric.Rect(r),this.fabricCanvas.add(o),a=new c.Cutoff(this,o),this.trackNewObject(a),this.fabricCanvas.setActiveObject(o),this.syncObjectList(),[2,a]}))}))},t.prototype.addBorderObject=function(){return o(this,void 0,void 0,(function(){var t,e,i,n,r;return s(this,(function(o){return t=this.profile$.value,e=t.defaultBorderWidth,i={id:this.randomId(),fill:null,stroke:t.defaultBorderColor,strokeWidth:e},n=new C.fabric.Rect(i),this.fabricCanvas.add(n),r=new h.Border(this,n),this.trackNewObject(r),this.fabricCanvas.setActiveObject(n),this.syncObjectList(),[2,r]}))}))},t.prototype.addVerticalRuleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i;return s(this,(function(n){return t={id:this.randomId(),width:2,height:10,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t),this.fabricCanvas.add(e),i=new y.VerticalRule(this,e),this.trackNewObject(i),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),[2,i]}))}))},t.prototype.addHorizontalRuleObject=function(){return o(this,void 0,void 0,(function(){var t,e,i;return s(this,(function(n){return t={id:this.randomId(),width:10,height:2,top:0,left:0,fill:"#000000"},e=new C.fabric.Rect(t),this.fabricCanvas.add(e),i=new m.HorizontalRule(this,e),this.trackNewObject(i),this.fabricCanvas.setActiveObject(e),this.syncObjectList(),[2,i]}))}))},t.prototype.setPrefillData=function(t){n(this.getObjectsByTypeInternal(_.ObjectType.TEXT)).each((function(e){var i=e.getPrefillType();null!==i&&e.setText(t[i]||"")}))},t.prototype.distributeObjectsVertically=function(){for(var t=this.getMargin(),e=this.getDimensions().heightPx,i=n(this.getObjectsByTypesInternal(_.ObjectType.TEXT,_.ObjectType.IMAGE)).sortBy((function(t){return t.getBoundingBox().top})).value(),r=n.reduce(i,(function(t,e){return t+e.getBoundingBox().height}),0),o=(e-t.top-t.bottom-r)/(i.length-1),s=t.top,a=0,c=i;a<c.length;a++){var u=c[a],h=u.getBoundingBox().height;u.setPosition({top:s}),u.setCoords(),s+=h+o}this.redraw()},t.prototype.getSelection=function(){return this.selection$.value},t.prototype.getSelection$=function(){return this.selection$},t.prototype.select=function(t){var e=this.findObject(t.getId());e?(this.fabricCanvas.setActiveObject(e.getFabricObjectInternal()),this.fabricCanvas.renderAll()):console.error("Attempted to select unknown object",t)},t.prototype.clearSelection=function(){this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll()},t.prototype.setMultiSelect=function(t){this.fabricCanvas.selection=t,this.fabricCanvas.selectionKey=t?"shiftKey":null},t.prototype.clear=function(){this.fabricCanvas.clear(),this.setBackgroundColor("#FFFFFF"),this.objects$.next([])},t.prototype.save=function(){var t=n(this.objects$.value).map((function(t){return t.persist()})).value(),e=this.fabricCanvas.toJSON(["id"]),i={dimensions:this.dimensions$.value,canvasJson:JSON.stringify(e),objects:t,backgroundColor:this.backgroundColor$.value};return console.debug("Saving canvas state",i),i},t.prototype.load=function(t){return o(this,void 0,void 0,(function(){var e,i=this;return s(this,(function(n){switch(n.label){case 0:return console.debug("Loading canvas state",t),this.setBaseDimensions(t.dimensions),null==t.canvasJson?[3,2]:(e=JSON.parse(t.canvasJson),[4,new Promise((function(t){i.fabricCanvas.loadFromJSON(e,(function(){return t()}))}))]);case 1:n.sent(),n.label=2;case 2:return this.setBackgroundColor(t.backgroundColor),this.bindFields(t.objects),this.removePersistedBullets(),this.layoutManager$.value.onInit(),[2]}}))}))},t.prototype.removePersistedBullets=function(){var t=this,e=this.fabricCanvas.getObjects();r.each(e,(function(e){"circle"===e.type&&t.removeFabricObject(e)}))},t.prototype.toSvg=function(){var t=this,e={width:r.round(this.dimensions$.value.widthMm,1)+"mm",height:r.round(this.dimensions$.value.heightMm,1)+"mm",suppressPreamble:!0,encoding:null};return this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toSVG(e)}))},t.prototype.toImage=function(){var t=this,e={format:"png",multiplier:this.IMAGE_CAPTURE_COEFFICIENT,enableRetinaScaling:!0};console.debug("Capturing canvas image",e);var i=this.executeWithNormalizedCanvas((function(){return t.fabricCanvas.toDataURL(e)}));return n.replace(i,/^data:.*;base64,/,"")},t.prototype.redraw=function(){this.fabricCanvas.renderAll()},t.prototype.syncObjectList=function(){var t=this,e=n(this.fabricCanvas.getObjects()).map((function(e){return t.findObject(e.id)})).filter((function(t){return void 0!==t})).value();this.objects$.next(e),this.onObjectListChange()},t.prototype.onTextChange=function(){this.layoutManager$.value.onTextChange()},t.prototype.onObjectListChange=function(){this.layoutManager$.value.onObjectListChange()},t.prototype.onDimensionsChange=function(){this.layoutManager$.value.onCanvasDimensionsChange()},t.prototype.onMarginChange=function(){this.layoutManager$.value.onMarginChange()},t.prototype.notifyObjectListChanged=function(){this.onObjectListChange()},t.prototype.removeFabricObject=function(t){this.fabricCanvas.remove(t)},t.prototype.bindFields=function(t){var e=this;console.debug("Binding fields",t);var i=n(t).flatMap((function(t){try{return[e.bindField(t)]}catch(e){return console.error("Could not bind field",e,t),[]}})).value();console.debug("Bound fields",i),this.objects$.next(i)},t.prototype.bindField=function(t){console.debug("Binding field",t);var e=this.findFabricObject(t.id);switch(t.type){case _.ObjectType.TEXT:return new f.Text(this,e,t);case _.ObjectType.RECTANGLE:return new u.Rectangle(this,e,t);case _.ObjectType.BORDER:return new h.Border(this,e,t);case _.ObjectType.CUTOFF:return new c.Cutoff(this,e,t);case _.ObjectType.IMAGE:case _.ObjectType.LIBRARY_IMAGE:return new l.Image(this,e,t);case _.ObjectType.HORIZONTAL_RULE:return new m.HorizontalRule(this,e,t);case _.ObjectType.VERTICAL_RULE:return new y.VerticalRule(this,e,t);default:throw new Error("Unknown field type: ["+t.type+"]")}},t.prototype.findFabricObject=function(t){var e=this.fabricCanvas.getObjects(),i=n.find(e,(function(e){return e.id==t}));if(!i)throw new Error("Cannot find fabric object with id ["+t+"]");return i},t.prototype.findObject=function(t){return n.find(this.objects$.value,(function(e){return e.getId()==t}))},t.prototype.executeWithNormalizedCanvas=function(t){var e;this.updateCanvasDimensions(this.dimensions$.value,1);try{e=t()}finally{this.updateCanvasDimensions(this.dimensions$.value,this.zoom$.value)}return e},t.prototype.updateCanvasDimensions=function(t,e){var i=t.widthPx*e,n=t.heightPx*e;console.debug("Updating canvas dimensions: zoom: "+e+", width: "+i+", height: "+n),this.fabricCanvas.setZoom(e),this.fabricCanvas.setDimensions({width:i,height:n})},t.prototype.calculateImageCaptureCoefficient=function(){var t=this.devicePixelRatio||1;return n.round(2/t,3)},t.prototype.onProfileChanged=function(t){this.setMultiSelect(t.allowMultiSelect),this.layoutManager$.value.onProfileChange(t),console.debug("Canvas profile set",t)},t.prototype.onFabricSelectionChanged=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());console.debug("Selection changed",t),this.selection$.next(new T(t)),this.enterTextSelectionModeIfRequired()},t.prototype.onTextEditing=function(){var t=this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());this.selection$.next(new T(t))},t.prototype.getFieldByCanvasObject=function(t){return t?n.find(this.objects$.value,(function(e){return e.getId()==t.id})):null},t.prototype.getFieldsByCanvasObject=function(t){var e=this;return n(t).map((function(t){return e.getFieldByCanvasObject(t)})).reject((function(t){return!t})).value()},t.prototype.randomId=function(){var t=Math.floor(999*Math.random())+0;return(new Date).getTime()+""+t},t.prototype.getLowestTextPoint=function(){return n(this.objects$.value).filter((function(t){return t.getType()===_.ObjectType.TEXT})).map((function(t){return t.getDimensions().top.px+t.getDimensions().height.px})).reduce((function(t,e){return Math.max(t,e)}),0)},t.prototype.trackNewObject=function(t){this.objects$.next(a(this.objects$.value,[t]))},t.prototype.enterTextSelectionModeIfRequired=function(){(this.profile$.value.enterTextEditImmediatelyOnSelect||this.layoutManager$.value.enterTextEditImmediatelyOnSelect)&&(this.selection$.value&&this.selection$.value.objects[0]&&this.selection$.value.objects[0].getType()===_.ObjectType.TEXT&&this.selection$.value.objects[0].enterEditing())},t.prototype.dimensionsExceedRestrictions=function(t){var e=this.dimensionRestrictions$.value;return null!=v.oc(e).height.min()&&t.height<v.oc(e).height.min()||null!=v.oc(e).height.max()&&t.height>v.oc(e).height.max()||null!=v.oc(e).width.min()&&t.width<v.oc(e).width.min()||null!=v.oc(e).width.max()&&t.width>v.oc(e).width.max()||null!=v.oc(e).volume.min()&&t.height*t.width<v.oc(e).volume.min()||null!=v.oc(e).volume.max()&&t.height*t.width>v.oc(e).volume.max()},t}();e.InteractiveCanvas=S;var T=function(t){this.objects=t,this.empty=this.objects.length<1;var e=this.objects[0];this.isText=e&&e.getType()===_.ObjectType.TEXT&&e.isEditing()}}.apply(e,n))||(t.exports=r)},function(t,e,i){var n;void 0===(n=function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}.apply(e,[i,e]))||(t.exports=n)}])}));
|
|
34
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _ = require('lodash');
|
|
6
|
+
var tsOptchain = require('ts-optchain');
|
|
7
|
+
var rxjs = require('rxjs');
|
|
8
|
+
var fabric = require('fabric');
|
|
9
|
+
|
|
10
|
+
var PixelCanvasDimensions = /** @class */ (function () {
|
|
11
|
+
function PixelCanvasDimensions(width, height) {
|
|
12
|
+
this.widthUnit = "px";
|
|
13
|
+
this.heightUnit = "px";
|
|
14
|
+
this.width = width;
|
|
15
|
+
this.widthPx = width;
|
|
16
|
+
this.height = height;
|
|
17
|
+
this.heightPx = height;
|
|
18
|
+
}
|
|
19
|
+
PixelCanvasDimensions.prototype.withSize = function (width, height) {
|
|
20
|
+
return new PixelCanvasDimensions(width, height);
|
|
21
|
+
};
|
|
22
|
+
PixelCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
23
|
+
return void 0;
|
|
24
|
+
};
|
|
25
|
+
PixelCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
26
|
+
return void 0;
|
|
27
|
+
};
|
|
28
|
+
return PixelCanvasDimensions;
|
|
29
|
+
}());
|
|
30
|
+
|
|
31
|
+
var COLUMN_WIDTH_MM = 41;
|
|
32
|
+
var GUTTER_WIDTH_MM = 3;
|
|
33
|
+
var PIXELS_PER_MM = 3.937;
|
|
34
|
+
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
35
|
+
function Print6ColCanvasDimensions(width, height) {
|
|
36
|
+
this.widthUnit = "column(s)";
|
|
37
|
+
this.heightUnit = "cm";
|
|
38
|
+
this.width = width;
|
|
39
|
+
this.gutterCount = Math.max(0, width - 1);
|
|
40
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
41
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
42
|
+
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
43
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
44
|
+
this.height = height;
|
|
45
|
+
this.heightMm = Math.max(0, height * 10);
|
|
46
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
47
|
+
}
|
|
48
|
+
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
49
|
+
return new Print6ColCanvasDimensions(width, height);
|
|
50
|
+
};
|
|
51
|
+
Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
52
|
+
return px / PIXELS_PER_MM;
|
|
53
|
+
};
|
|
54
|
+
Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
55
|
+
return px / PIXELS_PER_MM;
|
|
56
|
+
};
|
|
57
|
+
return Print6ColCanvasDimensions;
|
|
58
|
+
}());
|
|
59
|
+
|
|
60
|
+
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
61
|
+
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
62
|
+
var PIXELS_PER_MM$1 = 3.937;
|
|
63
|
+
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
64
|
+
function Print8ColCanvasDimensions(width, height) {
|
|
65
|
+
this.widthUnit = "column(s)";
|
|
66
|
+
this.heightUnit = "cm";
|
|
67
|
+
this.width = width;
|
|
68
|
+
this.gutterCount = Math.max(0, width - 1);
|
|
69
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
70
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
71
|
+
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
72
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
|
|
73
|
+
this.height = height;
|
|
74
|
+
this.heightMm = Math.max(0, height * 10);
|
|
75
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
|
|
76
|
+
}
|
|
77
|
+
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
78
|
+
return new Print8ColCanvasDimensions(width, height);
|
|
79
|
+
};
|
|
80
|
+
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
81
|
+
return px / PIXELS_PER_MM$1;
|
|
82
|
+
};
|
|
83
|
+
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
84
|
+
return px / PIXELS_PER_MM$1;
|
|
85
|
+
};
|
|
86
|
+
return Print8ColCanvasDimensions;
|
|
87
|
+
}());
|
|
88
|
+
|
|
89
|
+
/*! *****************************************************************************
|
|
90
|
+
Copyright (c) Microsoft Corporation.
|
|
91
|
+
|
|
92
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
93
|
+
purpose with or without fee is hereby granted.
|
|
94
|
+
|
|
95
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
96
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
97
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
98
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
99
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
100
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
101
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
102
|
+
***************************************************************************** */
|
|
103
|
+
/* global Reflect, Promise */
|
|
104
|
+
|
|
105
|
+
var extendStatics = function(d, b) {
|
|
106
|
+
extendStatics = Object.setPrototypeOf ||
|
|
107
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
108
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
109
|
+
return extendStatics(d, b);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
function __extends(d, b) {
|
|
113
|
+
extendStatics(d, b);
|
|
114
|
+
function __() { this.constructor = d; }
|
|
115
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
119
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
120
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
121
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
122
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
123
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
124
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function __generator(thisArg, body) {
|
|
129
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
130
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
131
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
132
|
+
function step(op) {
|
|
133
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
134
|
+
while (_) try {
|
|
135
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
136
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
137
|
+
switch (op[0]) {
|
|
138
|
+
case 0: case 1: t = op; break;
|
|
139
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
140
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
141
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
142
|
+
default:
|
|
143
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
144
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
145
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
146
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
147
|
+
if (t[2]) _.ops.pop();
|
|
148
|
+
_.trys.pop(); continue;
|
|
149
|
+
}
|
|
150
|
+
op = body.call(thisArg, _);
|
|
151
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
152
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function __spreadArrays() {
|
|
157
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
158
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
159
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
160
|
+
r[k] = a[j];
|
|
161
|
+
return r;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var Font = /** @class */ (function () {
|
|
165
|
+
function Font() {
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @override
|
|
169
|
+
* @inheritDoc
|
|
170
|
+
*/
|
|
171
|
+
Font.prototype.isBold = function (fontWeight) {
|
|
172
|
+
return fontWeight === this.boldWeight;
|
|
173
|
+
};
|
|
174
|
+
return Font;
|
|
175
|
+
}());
|
|
176
|
+
|
|
177
|
+
var UnknownFont = /** @class */ (function (_super) {
|
|
178
|
+
__extends(UnknownFont, _super);
|
|
179
|
+
function UnknownFont() {
|
|
180
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
181
|
+
_this.family = "_Unknown_";
|
|
182
|
+
_this.normalWeight = 400;
|
|
183
|
+
_this.boldWeight = 700;
|
|
184
|
+
return _this;
|
|
185
|
+
}
|
|
186
|
+
return UnknownFont;
|
|
187
|
+
}(Font));
|
|
188
|
+
|
|
189
|
+
var UNKNOWN_FONT = new UnknownFont();
|
|
190
|
+
var FontLibrary = /** @class */ (function () {
|
|
191
|
+
function FontLibrary() {
|
|
192
|
+
this._fonts = {};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @override
|
|
196
|
+
* @inheritDoc
|
|
197
|
+
*/
|
|
198
|
+
FontLibrary.prototype.registerFont = function (font) {
|
|
199
|
+
this._fonts[font.family] = font;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* @override
|
|
203
|
+
* @inheritDoc
|
|
204
|
+
*/
|
|
205
|
+
FontLibrary.prototype.registerFonts = function (fonts) {
|
|
206
|
+
var _this = this;
|
|
207
|
+
_.each(fonts, function (font) { return _this._fonts[font.family] = font; });
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* @override
|
|
211
|
+
* @inheritDoc
|
|
212
|
+
*/
|
|
213
|
+
FontLibrary.prototype.getFonts = function () {
|
|
214
|
+
return _.values(this._fonts);
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* @override
|
|
218
|
+
* @inheritDoc
|
|
219
|
+
*/
|
|
220
|
+
FontLibrary.prototype.getFont = function (family) {
|
|
221
|
+
return this._fonts[family] || UNKNOWN_FONT;
|
|
222
|
+
};
|
|
223
|
+
return FontLibrary;
|
|
224
|
+
}());
|
|
225
|
+
|
|
226
|
+
var AbstractLayoutManager = /** @class */ (function () {
|
|
227
|
+
function AbstractLayoutManager(canvas) {
|
|
228
|
+
this.isEnforcedPositioning = false;
|
|
229
|
+
this.enterTextEditImmediatelyOnSelect = false;
|
|
230
|
+
this.canvas = canvas;
|
|
231
|
+
}
|
|
232
|
+
AbstractLayoutManager.prototype.getCanvas = function () {
|
|
233
|
+
return this.canvas;
|
|
234
|
+
};
|
|
235
|
+
AbstractLayoutManager.prototype.onInit = function () {
|
|
236
|
+
//noop
|
|
237
|
+
};
|
|
238
|
+
AbstractLayoutManager.prototype.onProfileChange = function (profile) {
|
|
239
|
+
//noop
|
|
240
|
+
};
|
|
241
|
+
AbstractLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
242
|
+
//noop
|
|
243
|
+
};
|
|
244
|
+
AbstractLayoutManager.prototype.onTextChange = function () {
|
|
245
|
+
//noop
|
|
246
|
+
};
|
|
247
|
+
AbstractLayoutManager.prototype.onObjectListChange = function () {
|
|
248
|
+
//noop
|
|
249
|
+
};
|
|
250
|
+
AbstractLayoutManager.prototype.onMarginChange = function () {
|
|
251
|
+
//noop
|
|
252
|
+
};
|
|
253
|
+
return AbstractLayoutManager;
|
|
254
|
+
}());
|
|
255
|
+
|
|
256
|
+
var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
257
|
+
function RedrawAllLayoutFunction() {
|
|
258
|
+
}
|
|
259
|
+
RedrawAllLayoutFunction.prototype.execute = function (canvas) {
|
|
260
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
261
|
+
canvas.redraw();
|
|
262
|
+
};
|
|
263
|
+
return RedrawAllLayoutFunction;
|
|
264
|
+
}());
|
|
265
|
+
|
|
266
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
267
|
+
function RepositionCutoffsLayoutFunction() {
|
|
268
|
+
}
|
|
269
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
270
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
271
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
272
|
+
};
|
|
273
|
+
return RepositionCutoffsLayoutFunction;
|
|
274
|
+
}());
|
|
275
|
+
|
|
276
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
277
|
+
function RepositionBordersLayoutFunction() {
|
|
278
|
+
}
|
|
279
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
280
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
281
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
282
|
+
};
|
|
283
|
+
return RepositionBordersLayoutFunction;
|
|
284
|
+
}());
|
|
285
|
+
|
|
286
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
287
|
+
function PinToBottomLayoutFunction() {
|
|
288
|
+
}
|
|
289
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
290
|
+
canvas.getObjectsInternal()
|
|
291
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
292
|
+
};
|
|
293
|
+
return PinToBottomLayoutFunction;
|
|
294
|
+
}());
|
|
295
|
+
|
|
296
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
297
|
+
function ResizeCanvasLayoutFunction() {
|
|
298
|
+
}
|
|
299
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
300
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
301
|
+
return;
|
|
302
|
+
var currentDimensions = canvas.getDimensions();
|
|
303
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
304
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
305
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
306
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
307
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
308
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
309
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
310
|
+
}
|
|
311
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
312
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
313
|
+
canvas.setDimensions(targetHeight);
|
|
314
|
+
}
|
|
315
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
316
|
+
canvas.redraw();
|
|
317
|
+
};
|
|
318
|
+
return ResizeCanvasLayoutFunction;
|
|
319
|
+
}());
|
|
320
|
+
|
|
321
|
+
(function (LayoutManager) {
|
|
322
|
+
LayoutManager["LEGACY"] = "LEGACY";
|
|
323
|
+
LayoutManager["STANDARD"] = "STANDARD";
|
|
324
|
+
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
325
|
+
})(exports.LayoutManager || (exports.LayoutManager = {}));
|
|
326
|
+
|
|
327
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
328
|
+
__extends(AdvancedLayoutManager, _super);
|
|
329
|
+
function AdvancedLayoutManager(canvas) {
|
|
330
|
+
var _this = _super.call(this, canvas) || this;
|
|
331
|
+
_this.key = exports.LayoutManager.ADVANCED;
|
|
332
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
333
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
334
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
335
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
336
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
337
|
+
return _this;
|
|
338
|
+
}
|
|
339
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
340
|
+
this.pinToBottom.execute(this.canvas);
|
|
341
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
342
|
+
this.repositionBorders.execute(this.canvas);
|
|
343
|
+
this.redrawAll.execute(this.canvas);
|
|
344
|
+
};
|
|
345
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
346
|
+
this.resizeCanvas.execute(this.canvas);
|
|
347
|
+
};
|
|
348
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
349
|
+
this.redrawAll.execute(this.canvas);
|
|
350
|
+
};
|
|
351
|
+
return AdvancedLayoutManager;
|
|
352
|
+
}(AbstractLayoutManager));
|
|
353
|
+
|
|
354
|
+
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
355
|
+
function UpdateObjectDimensionsLayoutFunction() {
|
|
356
|
+
}
|
|
357
|
+
UpdateObjectDimensionsLayoutFunction.prototype.execute = function (canvas) {
|
|
358
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.updateDimensions(); });
|
|
359
|
+
};
|
|
360
|
+
return UpdateObjectDimensionsLayoutFunction;
|
|
361
|
+
}());
|
|
362
|
+
|
|
363
|
+
var MIN_MAGNITUDE = 1;
|
|
364
|
+
var BULLET_MARGIN = 15;
|
|
365
|
+
var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
366
|
+
function StackObjectsLayoutFunction() {
|
|
367
|
+
}
|
|
368
|
+
StackObjectsLayoutFunction.prototype.execute = function (canvas) {
|
|
369
|
+
var canvasMargin = canvas.getMargin();
|
|
370
|
+
var canvasDimensions = canvas.getDimensions();
|
|
371
|
+
var allObjects = canvas.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.IMAGE, exports.ObjectType.RECTANGLE, exports.ObjectType.VERTICAL_RULE, exports.ObjectType.HORIZONTAL_RULE);
|
|
372
|
+
var objects = _(allObjects)
|
|
373
|
+
.partition(function (object) { return object.isPinToBottom(); })
|
|
374
|
+
.value();
|
|
375
|
+
var footerObjects = objects[0];
|
|
376
|
+
var bodyObjects = objects[1];
|
|
377
|
+
var bodyWidth = canvasDimensions.widthPx - canvasMargin.right - canvasMargin.left;
|
|
378
|
+
//Make one pass and set the widths of all elements. This will force objects with dynamic heights (like text) to take on their necessary height before trying to lay them out.
|
|
379
|
+
this.applyWidths(allObjects, bodyWidth);
|
|
380
|
+
var bodyRows = this.getRows(bodyObjects);
|
|
381
|
+
var footerRows = this.getRows(footerObjects);
|
|
382
|
+
var minimumHeight = canvasMargin.top + bodyRows.totalHeight + footerRows.totalHeight + canvasMargin.bottom;
|
|
383
|
+
this.adjustCanvasSize(canvas, minimumHeight);
|
|
384
|
+
this.layoutFooter(footerRows, canvas);
|
|
385
|
+
this.layoutBody(bodyRows, canvas, footerRows.totalHeight);
|
|
386
|
+
};
|
|
387
|
+
StackObjectsLayoutFunction.prototype.layoutFooter = function (footerRows, canvas) {
|
|
388
|
+
var canvasDimensions = canvas.getDimensions();
|
|
389
|
+
var canvasMargin = canvas.getMargin();
|
|
390
|
+
var layoutAreaWidth = canvasDimensions.widthPx - canvasMargin.left - canvasMargin.right;
|
|
391
|
+
var nextObjectTop = canvasDimensions.heightPx - canvasMargin.bottom - footerRows.totalHeight;
|
|
392
|
+
var currentColumnWidthPercent = 0;
|
|
393
|
+
_.each(footerRows.rows, function (row) {
|
|
394
|
+
_.each(row.objects, function (object) {
|
|
395
|
+
var columnOffset = currentColumnWidthPercent / 100 * layoutAreaWidth;
|
|
396
|
+
var objectMargin = tsOptchain.oc(object.getMargin()).left(0);
|
|
397
|
+
var left = canvasMargin.left + columnOffset + objectMargin;
|
|
398
|
+
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
399
|
+
object.setPosition({ height: row.height });
|
|
400
|
+
object.setPosition({
|
|
401
|
+
top: nextObjectTop + tsOptchain.oc(object.getMargin()).top(0),
|
|
402
|
+
left: left
|
|
403
|
+
});
|
|
404
|
+
currentColumnWidthPercent += object.getColumnWidthPercent();
|
|
405
|
+
});
|
|
406
|
+
currentColumnWidthPercent = 0;
|
|
407
|
+
nextObjectTop += row.height;
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
StackObjectsLayoutFunction.prototype.layoutBody = function (bodyRows, canvas, footerHeight) {
|
|
411
|
+
var canvasDimensions = canvas.getDimensions();
|
|
412
|
+
var canvasMargin = canvas.getMargin();
|
|
413
|
+
var workableWidth = canvasDimensions.widthPx - canvasMargin.left - canvasMargin.right;
|
|
414
|
+
var workableHeight = canvasDimensions.heightPx - canvasMargin.top - canvasMargin.bottom - footerHeight;
|
|
415
|
+
var leftoverSpace = workableHeight - bodyRows.totalHeight;
|
|
416
|
+
var spacesRequired = this.countSpaces(bodyRows);
|
|
417
|
+
var spaceSize = leftoverSpace / spacesRequired;
|
|
418
|
+
var nextObjectTop = canvasMargin.top;
|
|
419
|
+
var currentColumnWidthPercent = 0;
|
|
420
|
+
for (var i = 0; i < bodyRows.rows.length; i++) {
|
|
421
|
+
var row = bodyRows.rows[i];
|
|
422
|
+
var nextRow = bodyRows.rows[i + 1];
|
|
423
|
+
for (var _i = 0, _a = row.objects; _i < _a.length; _i++) {
|
|
424
|
+
var object = _a[_i];
|
|
425
|
+
var columnOffset = currentColumnWidthPercent / 100 * workableWidth;
|
|
426
|
+
var objectMargin = tsOptchain.oc(object.getMargin()).left(0);
|
|
427
|
+
var objectLeft = canvasMargin.left + columnOffset + objectMargin;
|
|
428
|
+
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
429
|
+
objectLeft += BULLET_MARGIN;
|
|
430
|
+
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
431
|
+
object.setPosition({ height: row.height });
|
|
432
|
+
object.setPosition({
|
|
433
|
+
top: nextObjectTop + tsOptchain.oc(object.getMargin()).top(0),
|
|
434
|
+
left: objectLeft
|
|
435
|
+
});
|
|
436
|
+
currentColumnWidthPercent += object.getColumnWidthPercent();
|
|
437
|
+
}
|
|
438
|
+
currentColumnWidthPercent = 0;
|
|
439
|
+
nextObjectTop += row.height;
|
|
440
|
+
var thisRowIsHR = row.objects.length === 1 && row.objects[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
441
|
+
var nextRowIsHR = tsOptchain.oc(nextRow).objects.length() === 1 && tsOptchain.oc(nextRow).objects()[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
442
|
+
if (!thisRowIsHR && !nextRowIsHR) {
|
|
443
|
+
nextObjectTop += spaceSize;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
StackObjectsLayoutFunction.prototype.applyWidths = function (objects, layoutWidth) {
|
|
448
|
+
_(objects).forEach(function (object) {
|
|
449
|
+
var targetWidth = object.getColumnWidthPercent() / 100 * layoutWidth;
|
|
450
|
+
var actualWidth = targetWidth - tsOptchain.oc(object.getMargin()).left(0) - tsOptchain.oc(object.getMargin()).right(0);
|
|
451
|
+
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
452
|
+
return;
|
|
453
|
+
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
454
|
+
actualWidth -= BULLET_MARGIN;
|
|
455
|
+
object.setPosition({
|
|
456
|
+
width: actualWidth
|
|
457
|
+
});
|
|
458
|
+
object.updateDimensions();
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
462
|
+
var dimensions = canvas.getDimensions();
|
|
463
|
+
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
|
|
464
|
+
while (targetDimensions.heightPx < requiredHeight) {
|
|
465
|
+
targetDimensions = targetDimensions.withSize(dimensions.width, targetDimensions.height + 1);
|
|
466
|
+
}
|
|
467
|
+
if (dimensions.height !== targetDimensions.height) {
|
|
468
|
+
canvas.setDimensions(targetDimensions);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
StackObjectsLayoutFunction.prototype.getRows = function (objectsToLayout) {
|
|
472
|
+
var _this = this;
|
|
473
|
+
var result = { totalHeight: 0, rows: [] };
|
|
474
|
+
var currentWidth = 0;
|
|
475
|
+
var row = { objects: [], height: 1 };
|
|
476
|
+
_.each(objectsToLayout, function (object) {
|
|
477
|
+
var nextWidth = object.getColumnWidthPercent();
|
|
478
|
+
var objectHeight = _this.getObjectHeight(object);
|
|
479
|
+
if (currentWidth + nextWidth > 100) {
|
|
480
|
+
result.rows.push(row);
|
|
481
|
+
row = { objects: [], height: 1 };
|
|
482
|
+
currentWidth = 0;
|
|
483
|
+
}
|
|
484
|
+
row.objects.push(object);
|
|
485
|
+
if (object.getType() !== exports.ObjectType.VERTICAL_RULE)
|
|
486
|
+
row.height = Math.max(row.height, objectHeight);
|
|
487
|
+
currentWidth += nextWidth;
|
|
488
|
+
});
|
|
489
|
+
if (row.objects.length)
|
|
490
|
+
result.rows.push(row);
|
|
491
|
+
result.totalHeight = _.reduce(result.rows, function (x, y) { return x + y.height; }, 0);
|
|
492
|
+
return result;
|
|
493
|
+
};
|
|
494
|
+
StackObjectsLayoutFunction.prototype.getObjectHeight = function (element) {
|
|
495
|
+
return element.getBoundingBox().height
|
|
496
|
+
+ tsOptchain.oc(element.getMargin()).top(0)
|
|
497
|
+
+ tsOptchain.oc(element.getMargin()).bottom(0);
|
|
498
|
+
};
|
|
499
|
+
StackObjectsLayoutFunction.prototype.countSpaces = function (rows) {
|
|
500
|
+
var count = 0;
|
|
501
|
+
for (var i = 0; i < rows.rows.length - 1; i++) {
|
|
502
|
+
var row = rows.rows[i];
|
|
503
|
+
var nextRow = rows.rows[i + 1];
|
|
504
|
+
var thisRowIsHR = row.objects.length === 1 && row.objects[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
505
|
+
var nextRowIsHR = tsOptchain.oc(nextRow).objects.length() === 1 && tsOptchain.oc(nextRow).objects()[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
506
|
+
if (!thisRowIsHR && !nextRowIsHR) {
|
|
507
|
+
count++;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return count;
|
|
511
|
+
};
|
|
512
|
+
return StackObjectsLayoutFunction;
|
|
513
|
+
}());
|
|
514
|
+
|
|
515
|
+
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
516
|
+
__extends(StandardLayoutManager, _super);
|
|
517
|
+
function StandardLayoutManager(canvas) {
|
|
518
|
+
var _this = _super.call(this, canvas) || this;
|
|
519
|
+
_this.key = exports.LayoutManager.STANDARD;
|
|
520
|
+
_this.isEnforcedPositioning = true;
|
|
521
|
+
_this.enterTextEditImmediatelyOnSelect = true;
|
|
522
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
523
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
524
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
525
|
+
_this.stackObjects = new StackObjectsLayoutFunction();
|
|
526
|
+
_this.updateObjectDimensions = new UpdateObjectDimensionsLayoutFunction();
|
|
527
|
+
return _this;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* @override
|
|
531
|
+
*/
|
|
532
|
+
StandardLayoutManager.prototype.onInit = function () {
|
|
533
|
+
this.stackAndRedraw();
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* @override
|
|
537
|
+
*/
|
|
538
|
+
StandardLayoutManager.prototype.onProfileChange = function (profile) {
|
|
539
|
+
this.canvas.setMultiSelect(false);
|
|
540
|
+
this.redrawAll.execute(this.canvas);
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* @override
|
|
544
|
+
*/
|
|
545
|
+
StandardLayoutManager.prototype.onTextChange = function () {
|
|
546
|
+
this.stackAndRedraw();
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* @override
|
|
550
|
+
*/
|
|
551
|
+
StandardLayoutManager.prototype.onObjectListChange = function () {
|
|
552
|
+
this.stackAndRedraw();
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* @override
|
|
556
|
+
*/
|
|
557
|
+
StandardLayoutManager.prototype.onMarginChange = function () {
|
|
558
|
+
this.stackAndRedraw();
|
|
559
|
+
};
|
|
560
|
+
StandardLayoutManager.prototype.stackAndRedraw = function () {
|
|
561
|
+
this.stackObjects.execute(this.canvas);
|
|
562
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
563
|
+
this.repositionBorders.execute(this.canvas);
|
|
564
|
+
this.updateObjectDimensions.execute(this.canvas);
|
|
565
|
+
this.redrawAll.execute(this.canvas);
|
|
566
|
+
};
|
|
567
|
+
return StandardLayoutManager;
|
|
568
|
+
}(AbstractLayoutManager));
|
|
569
|
+
|
|
570
|
+
function isMutableBackgroundColor(object) {
|
|
571
|
+
return "setBackgroundColor" in object;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function isMutableColor(object) {
|
|
575
|
+
return "setColor" in object;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function isMutableImage(object) {
|
|
579
|
+
return "setImageUrl" in object;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function isMutablePosition(object) {
|
|
583
|
+
return "centerHorizontally" in object;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function isMutableText(object) {
|
|
587
|
+
return "setText" in object;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function isMutableTextStyle(object) {
|
|
591
|
+
return "getTextSelection" in object;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Data for a persisted canvas object.
|
|
596
|
+
*/
|
|
597
|
+
var CanvasObjectData = /** @class */ (function () {
|
|
598
|
+
function CanvasObjectData(type, id) {
|
|
599
|
+
this.id = id;
|
|
600
|
+
this.type = type;
|
|
601
|
+
}
|
|
602
|
+
return CanvasObjectData;
|
|
603
|
+
}());
|
|
604
|
+
|
|
605
|
+
var ROTATION_SNAP_ANGLE = 45;
|
|
606
|
+
var AbstractCanvasObject = /** @class */ (function () {
|
|
607
|
+
/**
|
|
608
|
+
* Create a new instance.
|
|
609
|
+
* @param type Object type.
|
|
610
|
+
* @param canvas Interactive canvas that the field will be rendered on.
|
|
611
|
+
* @param fabricObject The fabric object to bind this field to.
|
|
612
|
+
* @param data Existing persisted field data to load from, if applicable.
|
|
613
|
+
*/
|
|
614
|
+
function AbstractCanvasObject(type, canvas, fabricObject, data) {
|
|
615
|
+
var _this = this;
|
|
616
|
+
this.canvas = canvas;
|
|
617
|
+
this.fabricObject = fabricObject;
|
|
618
|
+
this.data = data ? data : new CanvasObjectData(type, this.fabricObject.id);
|
|
619
|
+
this.dimensions$ = new rxjs.BehaviorSubject(new FieldDimensions(this.fabricObject, this.canvas));
|
|
620
|
+
this.updatePinToBottomDistance();
|
|
621
|
+
this.canvas.getProfile$().subscribe(function (profile) { return _this.onProfileChange(profile); });
|
|
622
|
+
this.canvas.getLayoutManager$().subscribe(function (layoutManager) { return _this.onLayoutManagerChange(layoutManager); });
|
|
623
|
+
this.fabricObject.on("moving", function (e) { return _this.onMove(e); });
|
|
624
|
+
this.fabricObject.on("rotating", function (e) { return _this.onRotate(e); });
|
|
625
|
+
this.fabricObject.on("scaling", function (e) { return _this.onScale(e); });
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* @override
|
|
629
|
+
* @inheritDoc
|
|
630
|
+
*/
|
|
631
|
+
AbstractCanvasObject.prototype.getId = function () {
|
|
632
|
+
return this.data.id;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* @override
|
|
636
|
+
* @inheritDoc
|
|
637
|
+
*/
|
|
638
|
+
AbstractCanvasObject.prototype.getType = function () {
|
|
639
|
+
return this.data.type;
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* @override
|
|
643
|
+
* @inheritDoc
|
|
644
|
+
*/
|
|
645
|
+
AbstractCanvasObject.prototype.getDescription = function () {
|
|
646
|
+
switch (this.data.type) {
|
|
647
|
+
case exports.ObjectType.BORDER:
|
|
648
|
+
return "Border";
|
|
649
|
+
case exports.ObjectType.CUTOFF:
|
|
650
|
+
return "Bottom Border";
|
|
651
|
+
case exports.ObjectType.IMAGE:
|
|
652
|
+
return "Image";
|
|
653
|
+
case exports.ObjectType.LIBRARY_IMAGE:
|
|
654
|
+
return "Library Image";
|
|
655
|
+
case exports.ObjectType.RECTANGLE:
|
|
656
|
+
return "Rectangle";
|
|
657
|
+
case exports.ObjectType.TEXT:
|
|
658
|
+
return "Text";
|
|
659
|
+
default:
|
|
660
|
+
return "Field";
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* @override
|
|
665
|
+
* @inheritDoc
|
|
666
|
+
*/
|
|
667
|
+
AbstractCanvasObject.prototype.setSortCaption = function (value) {
|
|
668
|
+
this.data.sortCaption = value;
|
|
669
|
+
};
|
|
670
|
+
/**
|
|
671
|
+
* @override
|
|
672
|
+
* @inheritDoc
|
|
673
|
+
*/
|
|
674
|
+
AbstractCanvasObject.prototype.isSortCaption = function () {
|
|
675
|
+
return this.data.sortCaption;
|
|
676
|
+
};
|
|
677
|
+
/**
|
|
678
|
+
* @override
|
|
679
|
+
* @inheritDoc
|
|
680
|
+
*/
|
|
681
|
+
AbstractCanvasObject.prototype.getDimensions = function () {
|
|
682
|
+
return this.dimensions$.value;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* @override
|
|
686
|
+
* @inheritDoc
|
|
687
|
+
*/
|
|
688
|
+
AbstractCanvasObject.prototype.getDimensions$ = function () {
|
|
689
|
+
return this.dimensions$;
|
|
690
|
+
};
|
|
691
|
+
/**
|
|
692
|
+
* @override
|
|
693
|
+
* @inheritDoc
|
|
694
|
+
*/
|
|
695
|
+
AbstractCanvasObject.prototype.getMargin = function () {
|
|
696
|
+
return this.data.margin || {
|
|
697
|
+
top: 0,
|
|
698
|
+
right: 0,
|
|
699
|
+
bottom: 0,
|
|
700
|
+
left: 0
|
|
701
|
+
};
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* @override
|
|
705
|
+
* @inheritDoc
|
|
706
|
+
*/
|
|
707
|
+
AbstractCanvasObject.prototype.setMargin = function (margin) {
|
|
708
|
+
if (!margin)
|
|
709
|
+
return;
|
|
710
|
+
var newMargin = tsOptchain.oc(this.data).margin({
|
|
711
|
+
top: 0,
|
|
712
|
+
right: 0,
|
|
713
|
+
bottom: 0,
|
|
714
|
+
left: 0
|
|
715
|
+
});
|
|
716
|
+
if (margin.top != undefined)
|
|
717
|
+
newMargin.top = margin.top || 0;
|
|
718
|
+
if (margin.right != undefined)
|
|
719
|
+
newMargin.right = margin.right || 0;
|
|
720
|
+
if (margin.bottom != undefined)
|
|
721
|
+
newMargin.bottom = margin.bottom || 0;
|
|
722
|
+
if (margin.left != undefined)
|
|
723
|
+
newMargin.left = margin.left || 0;
|
|
724
|
+
this.data.margin = newMargin;
|
|
725
|
+
this.canvas.notifyObjectListChanged();
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* @override
|
|
729
|
+
* @inheritDoc
|
|
730
|
+
*/
|
|
731
|
+
AbstractCanvasObject.prototype.getColumnWidthPercent = function () {
|
|
732
|
+
return Math.max(Math.min(tsOptchain.oc(this.data).columnWidthPercent(100), 100), 0);
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* @override
|
|
736
|
+
* @inheritDoc
|
|
737
|
+
*/
|
|
738
|
+
AbstractCanvasObject.prototype.setColumnWidthPercent = function (percent) {
|
|
739
|
+
this.data.columnWidthPercent = percent;
|
|
740
|
+
this.canvas.notifyObjectListChanged();
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* @override
|
|
744
|
+
* @inheritDoc
|
|
745
|
+
*/
|
|
746
|
+
AbstractCanvasObject.prototype.bringForward = function () {
|
|
747
|
+
this.fabricObject.bringForward();
|
|
748
|
+
this.canvas.syncObjectList();
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* @override
|
|
752
|
+
* @inheritDoc
|
|
753
|
+
*/
|
|
754
|
+
AbstractCanvasObject.prototype.bringToFront = function () {
|
|
755
|
+
this.fabricObject.bringToFront();
|
|
756
|
+
this.canvas.syncObjectList();
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* @override
|
|
760
|
+
* @inheritDoc
|
|
761
|
+
*/
|
|
762
|
+
AbstractCanvasObject.prototype.sendBackward = function () {
|
|
763
|
+
this.fabricObject.sendBackwards();
|
|
764
|
+
this.canvas.syncObjectList();
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* @override
|
|
768
|
+
* @inheritDoc
|
|
769
|
+
*/
|
|
770
|
+
AbstractCanvasObject.prototype.sendToBack = function () {
|
|
771
|
+
this.fabricObject.sendToBack();
|
|
772
|
+
this.canvas.syncObjectList();
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* @override
|
|
776
|
+
* @inheritDoc
|
|
777
|
+
*/
|
|
778
|
+
AbstractCanvasObject.prototype.moveUp = function () {
|
|
779
|
+
this.sendBackward();
|
|
780
|
+
};
|
|
781
|
+
/**
|
|
782
|
+
* @override
|
|
783
|
+
* @inheritDoc
|
|
784
|
+
*/
|
|
785
|
+
AbstractCanvasObject.prototype.moveDown = function () {
|
|
786
|
+
this.bringForward();
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* @override
|
|
790
|
+
* @inheritDoc
|
|
791
|
+
*/
|
|
792
|
+
AbstractCanvasObject.prototype.delete = function () {
|
|
793
|
+
this.canvas.removeObject(this);
|
|
794
|
+
this.onDelete();
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* @override
|
|
798
|
+
* @inheritDoc
|
|
799
|
+
*/
|
|
800
|
+
AbstractCanvasObject.prototype.persist = function () {
|
|
801
|
+
return _.clone(this.data);
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* @override
|
|
805
|
+
* @inheritDoc
|
|
806
|
+
*/
|
|
807
|
+
AbstractCanvasObject.prototype.isPinToBottom = function () {
|
|
808
|
+
return this.data.pinToBottom;
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* @override
|
|
812
|
+
* @inheritDoc
|
|
813
|
+
*/
|
|
814
|
+
AbstractCanvasObject.prototype.setPinToBottom = function (value) {
|
|
815
|
+
if (value === void 0) { value = true; }
|
|
816
|
+
this.updatePinToBottomDistance();
|
|
817
|
+
this.data.pinToBottom = value;
|
|
818
|
+
this.canvas.notifyObjectListChanged();
|
|
819
|
+
this.updateFabricObjectBehavior();
|
|
820
|
+
};
|
|
821
|
+
/**
|
|
822
|
+
* Get the underlying fabric object.
|
|
823
|
+
* (Internal use only, do not expose this outside the canvas module).
|
|
824
|
+
*/
|
|
825
|
+
AbstractCanvasObject.prototype.getFabricObjectInternal = function () {
|
|
826
|
+
return this.fabricObject;
|
|
827
|
+
};
|
|
828
|
+
AbstractCanvasObject.prototype.setPosition = function (position) {
|
|
829
|
+
var scale = this.getDimensions().scale;
|
|
830
|
+
if (position.top != undefined)
|
|
831
|
+
this.fabricObject.set({ top: position.top });
|
|
832
|
+
if (position.left != undefined)
|
|
833
|
+
this.fabricObject.set({ left: position.left });
|
|
834
|
+
if (position.width != undefined)
|
|
835
|
+
this.fabricObject.set({ width: position.width / scale.x });
|
|
836
|
+
if (position.height != undefined)
|
|
837
|
+
this.fabricObject.set({ height: position.height / scale.y });
|
|
838
|
+
};
|
|
839
|
+
AbstractCanvasObject.prototype.setCoords = function () {
|
|
840
|
+
this.fabricObject.setCoords();
|
|
841
|
+
};
|
|
842
|
+
AbstractCanvasObject.prototype.updateDimensions = function () {
|
|
843
|
+
this.setCoords();
|
|
844
|
+
var dimensions = new FieldDimensions(this.fabricObject, this.canvas);
|
|
845
|
+
this.dimensions$.next(dimensions);
|
|
846
|
+
};
|
|
847
|
+
AbstractCanvasObject.prototype.getBoundingBox = function () {
|
|
848
|
+
var absolute = true;
|
|
849
|
+
var calculate = true;
|
|
850
|
+
return this.fabricObject.getBoundingRect(absolute, calculate);
|
|
851
|
+
};
|
|
852
|
+
AbstractCanvasObject.prototype.moveToPinnedPosition = function () {
|
|
853
|
+
if (this.data.pinToBottom) {
|
|
854
|
+
this.setPosition({
|
|
855
|
+
top: this.canvas.getDimensions().heightPx - this.pinToBottomDistance
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
AbstractCanvasObject.prototype.updatePinToBottomDistance = function () {
|
|
860
|
+
this.pinToBottomDistance = this.canvas.getDimensions().heightPx - this.getDimensions().top.px;
|
|
861
|
+
};
|
|
862
|
+
AbstractCanvasObject.prototype.redraw = function () {
|
|
863
|
+
this.canvas.redraw();
|
|
864
|
+
};
|
|
865
|
+
// noinspection JSUnusedLocalSymbols
|
|
866
|
+
AbstractCanvasObject.prototype.onProfileChange = function (profile) {
|
|
867
|
+
this.updateFabricObjectBehavior();
|
|
868
|
+
this.redraw();
|
|
869
|
+
};
|
|
870
|
+
// noinspection JSUnusedLocalSymbols
|
|
871
|
+
AbstractCanvasObject.prototype.onLayoutManagerChange = function (layoutManager) {
|
|
872
|
+
this.updateFabricObjectBehavior();
|
|
873
|
+
this.redraw();
|
|
874
|
+
};
|
|
875
|
+
// noinspection JSUnusedLocalSymbols
|
|
876
|
+
AbstractCanvasObject.prototype.onMove = function (event) {
|
|
877
|
+
if (!this.canvas.getProfile().allowObjectsToLeaveCanvas) {
|
|
878
|
+
this.preventLeavingCanvas();
|
|
879
|
+
}
|
|
880
|
+
this.updateDimensions();
|
|
881
|
+
};
|
|
882
|
+
AbstractCanvasObject.prototype.onRotate = function (event) {
|
|
883
|
+
if (event.e.shiftKey) {
|
|
884
|
+
this.fabricObject.set({ snapAngle: 0 });
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
this.fabricObject.set({ snapAngle: ROTATION_SNAP_ANGLE });
|
|
888
|
+
}
|
|
889
|
+
this.updateDimensions();
|
|
890
|
+
};
|
|
891
|
+
// noinspection JSUnusedLocalSymbols
|
|
892
|
+
AbstractCanvasObject.prototype.onScale = function (event) {
|
|
893
|
+
this.updateDimensions();
|
|
894
|
+
};
|
|
895
|
+
AbstractCanvasObject.prototype.onDelete = function () {
|
|
896
|
+
//no-op
|
|
897
|
+
};
|
|
898
|
+
AbstractCanvasObject.prototype.preventLeavingCanvas = function () {
|
|
899
|
+
var overflow = this.getCanvasOverflow();
|
|
900
|
+
if (overflow.hasOverflow) {
|
|
901
|
+
var adjustX = overflow.left || -overflow.right;
|
|
902
|
+
var adjustY = overflow.top || -overflow.bottom;
|
|
903
|
+
this.fabricObject.set({
|
|
904
|
+
top: this.fabricObject.top + adjustY,
|
|
905
|
+
left: this.fabricObject.left + adjustX
|
|
906
|
+
});
|
|
907
|
+
this.redraw();
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
AbstractCanvasObject.prototype.getCanvasOverflow = function () {
|
|
911
|
+
var bound = this.getBoundingBox();
|
|
912
|
+
var canvasDimensions = this.canvas.getDimensions();
|
|
913
|
+
var top = Math.max(0, 0 - bound.top);
|
|
914
|
+
var right = Math.max(0, bound.left + bound.width - canvasDimensions.widthPx);
|
|
915
|
+
var bottom = Math.max(0, bound.top + bound.height - canvasDimensions.heightPx);
|
|
916
|
+
var left = Math.max(0, 0 - bound.left);
|
|
917
|
+
return {
|
|
918
|
+
top: top,
|
|
919
|
+
right: right,
|
|
920
|
+
bottom: bottom,
|
|
921
|
+
left: left,
|
|
922
|
+
hasOverflow: top > 0 || right > 0 || bottom > 0 || left > 0
|
|
923
|
+
};
|
|
924
|
+
};
|
|
925
|
+
AbstractCanvasObject.prototype.centerHorizontallyInternal = function () {
|
|
926
|
+
var canvasWidth = this.canvas.getDimensions().widthPx;
|
|
927
|
+
var objectWidth = this.getDimensions().width.px;
|
|
928
|
+
this.fabricObject.set({ left: ((canvasWidth - objectWidth) / 2) - 0.5 });
|
|
929
|
+
this.updateDimensions();
|
|
930
|
+
this.redraw();
|
|
931
|
+
};
|
|
932
|
+
AbstractCanvasObject.prototype.centerVerticallyInternal = function () {
|
|
933
|
+
var canvasHeight = this.canvas.getDimensions().heightPx;
|
|
934
|
+
var objectHeight = this.getDimensions().height.px;
|
|
935
|
+
this.fabricObject.set({ top: ((canvasHeight - objectHeight) / 2) - 0.5 });
|
|
936
|
+
this.redraw();
|
|
937
|
+
this.updateDimensions();
|
|
938
|
+
};
|
|
939
|
+
AbstractCanvasObject.prototype.nudgeInternal = function (x, y) {
|
|
940
|
+
if (x === void 0) { x = 0; }
|
|
941
|
+
if (y === void 0) { y = 0; }
|
|
942
|
+
this.fabricObject.set({
|
|
943
|
+
top: this.getDimensions().top.px + y,
|
|
944
|
+
left: this.getDimensions().left.px + x
|
|
945
|
+
});
|
|
946
|
+
this.redraw();
|
|
947
|
+
this.updateDimensions();
|
|
948
|
+
};
|
|
949
|
+
AbstractCanvasObject.prototype.updateFabricObjectBehavior = function () {
|
|
950
|
+
var allowManualPositioning = !this.canvas.getLayoutManager().isEnforcedPositioning;
|
|
951
|
+
var profile = this.canvas.getProfile();
|
|
952
|
+
var options = {
|
|
953
|
+
allowMove: allowManualPositioning && profile.allowMove && !this.isPinToBottom(),
|
|
954
|
+
allowRotate: allowManualPositioning && profile.allowRotate && !this.isPinToBottom(),
|
|
955
|
+
allowScale: allowManualPositioning && profile.allowScale && !this.isPinToBottom()
|
|
956
|
+
};
|
|
957
|
+
this.fabricObject.set({
|
|
958
|
+
lockMovementX: !options.allowMove,
|
|
959
|
+
lockMovementY: !options.allowMove,
|
|
960
|
+
lockScalingX: !options.allowScale,
|
|
961
|
+
lockScalingY: !options.allowScale,
|
|
962
|
+
lockScalingFlip: true,
|
|
963
|
+
lockRotation: !options.allowRotate
|
|
964
|
+
});
|
|
965
|
+
this.fabricObject.setControlsVisibility({
|
|
966
|
+
tl: options.allowScale,
|
|
967
|
+
tr: options.allowScale,
|
|
968
|
+
br: options.allowScale,
|
|
969
|
+
bl: options.allowScale,
|
|
970
|
+
ml: options.allowScale,
|
|
971
|
+
mt: options.allowScale,
|
|
972
|
+
mr: options.allowScale,
|
|
973
|
+
mb: options.allowScale,
|
|
974
|
+
mtr: options.allowRotate
|
|
975
|
+
});
|
|
976
|
+
};
|
|
977
|
+
return AbstractCanvasObject;
|
|
978
|
+
}());
|
|
979
|
+
var FieldDimensions = /** @class */ (function () {
|
|
980
|
+
function FieldDimensions(fabricObject, canvas) {
|
|
981
|
+
var widthPxToMmFunction = canvas.getDimensions().widthPxToMm;
|
|
982
|
+
var heightPxToMmFunction = canvas.getDimensions().heightPxToMm;
|
|
983
|
+
this.top = { px: fabricObject.top, mm: heightPxToMmFunction(fabricObject.top) };
|
|
984
|
+
this.left = { px: fabricObject.left, mm: widthPxToMmFunction(fabricObject.left) };
|
|
985
|
+
var widthPx = fabricObject.width * fabricObject.scaleX;
|
|
986
|
+
var heightPx = fabricObject.height * fabricObject.scaleY;
|
|
987
|
+
this.width = { px: widthPx, mm: widthPxToMmFunction(widthPx) };
|
|
988
|
+
this.height = { px: heightPx, mm: heightPxToMmFunction(heightPx) };
|
|
989
|
+
this.scale = { x: fabricObject.scaleX, y: fabricObject.scaleY };
|
|
990
|
+
this.angle = fabricObject.angle;
|
|
991
|
+
}
|
|
992
|
+
return FieldDimensions;
|
|
993
|
+
}());
|
|
994
|
+
|
|
995
|
+
var Border = /** @class */ (function (_super) {
|
|
996
|
+
__extends(Border, _super);
|
|
997
|
+
function Border(canvas, fabricObject, persistedField) {
|
|
998
|
+
var _this = _super.call(this, exports.ObjectType.BORDER, canvas, fabricObject, persistedField) || this;
|
|
999
|
+
_this.strokeWidth$ = new rxjs.BehaviorSubject(0);
|
|
1000
|
+
_this.canvas = canvas;
|
|
1001
|
+
_this.strokeWidth$.next(_this.fabricObject.strokeWidth);
|
|
1002
|
+
_this.updatePosition();
|
|
1003
|
+
return _this;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* @override
|
|
1007
|
+
* @inheritDoc
|
|
1008
|
+
*/
|
|
1009
|
+
Border.prototype.getColor = function () {
|
|
1010
|
+
return this.fabricObject.stroke;
|
|
1011
|
+
};
|
|
1012
|
+
/**
|
|
1013
|
+
* @override
|
|
1014
|
+
* @inheritDoc
|
|
1015
|
+
*/
|
|
1016
|
+
Border.prototype.setColor = function (color) {
|
|
1017
|
+
this.fabricObject.set({ stroke: color });
|
|
1018
|
+
this.data.color = color;
|
|
1019
|
+
this.redraw();
|
|
1020
|
+
};
|
|
1021
|
+
/**
|
|
1022
|
+
* @override
|
|
1023
|
+
* @inheritDoc
|
|
1024
|
+
*/
|
|
1025
|
+
Border.prototype.getStrokeWidth = function () {
|
|
1026
|
+
return this.fabricObject.strokeWidth;
|
|
1027
|
+
};
|
|
1028
|
+
/**
|
|
1029
|
+
* @override
|
|
1030
|
+
* @inheritDoc
|
|
1031
|
+
*/
|
|
1032
|
+
Border.prototype.getStrokeWidth$ = function () {
|
|
1033
|
+
return this.strokeWidth$;
|
|
1034
|
+
};
|
|
1035
|
+
/**
|
|
1036
|
+
* @override
|
|
1037
|
+
* @inheritDoc
|
|
1038
|
+
*/
|
|
1039
|
+
Border.prototype.setStrokeWidth = function (width) {
|
|
1040
|
+
this.strokeWidth$.next(width);
|
|
1041
|
+
this.data.strokeWidth = width;
|
|
1042
|
+
this.updatePosition();
|
|
1043
|
+
this.canvas.notifyMarginChanged();
|
|
1044
|
+
this.redraw();
|
|
1045
|
+
};
|
|
1046
|
+
Border.prototype.updatePosition = function () {
|
|
1047
|
+
this.fabricObject.set({
|
|
1048
|
+
strokeWidth: this.strokeWidth$.value,
|
|
1049
|
+
top: 0,
|
|
1050
|
+
left: 0,
|
|
1051
|
+
width: this.canvas.getDimensions().widthPx - this.strokeWidth$.value,
|
|
1052
|
+
height: this.canvas.getDimensions().heightPx - this.strokeWidth$.value
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
/**
|
|
1056
|
+
* @override
|
|
1057
|
+
* @inheritDoc
|
|
1058
|
+
*/
|
|
1059
|
+
Border.prototype.updateFabricObjectBehavior = function () {
|
|
1060
|
+
_super.prototype.updateFabricObjectBehavior.call(this);
|
|
1061
|
+
this.fabricObject.set({
|
|
1062
|
+
lockMovementX: true,
|
|
1063
|
+
lockMovementY: true,
|
|
1064
|
+
lockScalingX: true,
|
|
1065
|
+
lockScalingY: true,
|
|
1066
|
+
lockScalingFlip: true
|
|
1067
|
+
});
|
|
1068
|
+
this.fabricObject.setControlsVisibility({
|
|
1069
|
+
tl: false,
|
|
1070
|
+
tr: false,
|
|
1071
|
+
br: false,
|
|
1072
|
+
bl: false,
|
|
1073
|
+
ml: false,
|
|
1074
|
+
mt: false,
|
|
1075
|
+
mr: false,
|
|
1076
|
+
mb: false,
|
|
1077
|
+
mtr: false
|
|
1078
|
+
});
|
|
1079
|
+
this.redraw();
|
|
1080
|
+
};
|
|
1081
|
+
return Border;
|
|
1082
|
+
}(AbstractCanvasObject));
|
|
1083
|
+
|
|
1084
|
+
var Cutoff = /** @class */ (function (_super) {
|
|
1085
|
+
__extends(Cutoff, _super);
|
|
1086
|
+
function Cutoff(canvas, fabricObject, persistedField) {
|
|
1087
|
+
var _this = _super.call(this, exports.ObjectType.CUTOFF, canvas, fabricObject, persistedField) || this;
|
|
1088
|
+
_this.strokeWidth$ = new rxjs.BehaviorSubject(0);
|
|
1089
|
+
_this.canvas = canvas;
|
|
1090
|
+
_this.strokeWidth$.next(_this.fabricObject.height);
|
|
1091
|
+
_this.updatePosition();
|
|
1092
|
+
_this.fabricObject.set({ strokeWidth: 0 });
|
|
1093
|
+
return _this;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* @override
|
|
1097
|
+
* @inheritDoc
|
|
1098
|
+
*/
|
|
1099
|
+
Cutoff.prototype.getColor = function () {
|
|
1100
|
+
return this.fabricObject.fill;
|
|
1101
|
+
};
|
|
1102
|
+
/**
|
|
1103
|
+
* @override
|
|
1104
|
+
* @inheritDoc
|
|
1105
|
+
*/
|
|
1106
|
+
Cutoff.prototype.setColor = function (color) {
|
|
1107
|
+
this.fabricObject.set({ fill: color, stroke: color });
|
|
1108
|
+
this.data.color = color;
|
|
1109
|
+
this.redraw();
|
|
1110
|
+
};
|
|
1111
|
+
/**
|
|
1112
|
+
* @override
|
|
1113
|
+
* @inheritDoc
|
|
1114
|
+
*/
|
|
1115
|
+
Cutoff.prototype.getStrokeWidth = function () {
|
|
1116
|
+
// noinspection JSSuspiciousNameCombination
|
|
1117
|
+
return this.fabricObject.height;
|
|
1118
|
+
};
|
|
1119
|
+
/**
|
|
1120
|
+
* @override
|
|
1121
|
+
* @inheritDoc
|
|
1122
|
+
*/
|
|
1123
|
+
Cutoff.prototype.getStrokeWidth$ = function () {
|
|
1124
|
+
return this.strokeWidth$;
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* @override
|
|
1128
|
+
* @inheritDoc
|
|
1129
|
+
*/
|
|
1130
|
+
Cutoff.prototype.setStrokeWidth = function (width) {
|
|
1131
|
+
this.strokeWidth$.next(width);
|
|
1132
|
+
this.data.strokeWidth = width;
|
|
1133
|
+
this.updatePosition();
|
|
1134
|
+
this.canvas.notifyMarginChanged();
|
|
1135
|
+
this.redraw();
|
|
1136
|
+
};
|
|
1137
|
+
Cutoff.prototype.updatePosition = function () {
|
|
1138
|
+
this.fabricObject.set({
|
|
1139
|
+
top: this.canvas.getDimensions().heightPx - this.strokeWidth$.value,
|
|
1140
|
+
left: 0,
|
|
1141
|
+
width: this.canvas.getDimensions().widthPx,
|
|
1142
|
+
height: this.strokeWidth$.value
|
|
1143
|
+
});
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* @override
|
|
1147
|
+
* @inheritDoc
|
|
1148
|
+
*/
|
|
1149
|
+
Cutoff.prototype.updateFabricObjectBehavior = function () {
|
|
1150
|
+
this.fabricObject.set({
|
|
1151
|
+
lockMovementX: true,
|
|
1152
|
+
lockMovementY: true,
|
|
1153
|
+
lockScalingX: true,
|
|
1154
|
+
lockScalingY: true,
|
|
1155
|
+
lockScalingFlip: true
|
|
1156
|
+
});
|
|
1157
|
+
this.fabricObject.setControlsVisibility({
|
|
1158
|
+
tl: false,
|
|
1159
|
+
tr: false,
|
|
1160
|
+
br: false,
|
|
1161
|
+
bl: false,
|
|
1162
|
+
ml: false,
|
|
1163
|
+
mt: false,
|
|
1164
|
+
mr: false,
|
|
1165
|
+
mb: false,
|
|
1166
|
+
mtr: false
|
|
1167
|
+
});
|
|
1168
|
+
this.redraw();
|
|
1169
|
+
};
|
|
1170
|
+
return Cutoff;
|
|
1171
|
+
}(AbstractCanvasObject));
|
|
1172
|
+
|
|
1173
|
+
var HorizontalRule = /** @class */ (function (_super) {
|
|
1174
|
+
__extends(HorizontalRule, _super);
|
|
1175
|
+
function HorizontalRule(canvas, fabricObject, persistedField) {
|
|
1176
|
+
var _this = _super.call(this, exports.ObjectType.HORIZONTAL_RULE, canvas, fabricObject, persistedField) || this;
|
|
1177
|
+
_this.strokeWidth$ = new rxjs.BehaviorSubject(2);
|
|
1178
|
+
_this.canvas = canvas;
|
|
1179
|
+
_this.strokeWidth$.next(_this.getDimensions().height.px);
|
|
1180
|
+
_this.fabricObject.set({ strokeWidth: 0 });
|
|
1181
|
+
return _this;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* @override
|
|
1185
|
+
* @inheritDoc
|
|
1186
|
+
*/
|
|
1187
|
+
HorizontalRule.prototype.getStrokeWidth = function () {
|
|
1188
|
+
// noinspection JSSuspiciousNameCombination
|
|
1189
|
+
return this.fabricObject.height;
|
|
1190
|
+
};
|
|
1191
|
+
/**
|
|
1192
|
+
* @override
|
|
1193
|
+
* @inheritDoc
|
|
1194
|
+
*/
|
|
1195
|
+
HorizontalRule.prototype.getStrokeWidth$ = function () {
|
|
1196
|
+
return this.strokeWidth$;
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* @override
|
|
1200
|
+
* @inheritDoc
|
|
1201
|
+
*/
|
|
1202
|
+
HorizontalRule.prototype.setStrokeWidth = function (value) {
|
|
1203
|
+
this.strokeWidth$.next(value);
|
|
1204
|
+
this.data.strokeWidth = value;
|
|
1205
|
+
this.setPosition({ height: value });
|
|
1206
|
+
this.canvas.notifyObjectListChanged();
|
|
1207
|
+
this.redraw();
|
|
1208
|
+
};
|
|
1209
|
+
/**
|
|
1210
|
+
* @override
|
|
1211
|
+
* @inheritDoc
|
|
1212
|
+
*/
|
|
1213
|
+
HorizontalRule.prototype.getColor = function () {
|
|
1214
|
+
return this.fabricObject.fill;
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* @override
|
|
1218
|
+
* @inheritDoc
|
|
1219
|
+
*/
|
|
1220
|
+
HorizontalRule.prototype.setColor = function (color) {
|
|
1221
|
+
this.fabricObject.set({ fill: color, stroke: color });
|
|
1222
|
+
this.data.color = color;
|
|
1223
|
+
this.redraw();
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* @override
|
|
1227
|
+
* @inheritDoc
|
|
1228
|
+
*/
|
|
1229
|
+
HorizontalRule.prototype.centerHorizontally = function () {
|
|
1230
|
+
_super.prototype.centerHorizontallyInternal.call(this);
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* @override
|
|
1234
|
+
* @inheritDoc
|
|
1235
|
+
*/
|
|
1236
|
+
HorizontalRule.prototype.centerVertically = function () {
|
|
1237
|
+
_super.prototype.centerVerticallyInternal.call(this);
|
|
1238
|
+
};
|
|
1239
|
+
/**
|
|
1240
|
+
* @override
|
|
1241
|
+
* @inheritDoc
|
|
1242
|
+
*/
|
|
1243
|
+
HorizontalRule.prototype.setHeight = function (height) {
|
|
1244
|
+
this.setPosition({ height: height });
|
|
1245
|
+
this.canvas.notifyObjectListChanged();
|
|
1246
|
+
};
|
|
1247
|
+
/**
|
|
1248
|
+
* @override
|
|
1249
|
+
* @inheritDoc
|
|
1250
|
+
*/
|
|
1251
|
+
HorizontalRule.prototype.nudgeUp = function () {
|
|
1252
|
+
_super.prototype.nudgeInternal.call(this, 0, -1);
|
|
1253
|
+
};
|
|
1254
|
+
/**
|
|
1255
|
+
* @override
|
|
1256
|
+
* @inheritDoc
|
|
1257
|
+
*/
|
|
1258
|
+
HorizontalRule.prototype.nudgeDown = function () {
|
|
1259
|
+
_super.prototype.nudgeInternal.call(this, 0, +1);
|
|
1260
|
+
};
|
|
1261
|
+
/**
|
|
1262
|
+
* @override
|
|
1263
|
+
* @inheritDoc
|
|
1264
|
+
*/
|
|
1265
|
+
HorizontalRule.prototype.nudgeLeft = function () {
|
|
1266
|
+
_super.prototype.nudgeInternal.call(this, -1, 0);
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
* @override
|
|
1270
|
+
* @inheritDoc
|
|
1271
|
+
*/
|
|
1272
|
+
HorizontalRule.prototype.nudgeRight = function () {
|
|
1273
|
+
_super.prototype.nudgeInternal.call(this, +1, 0);
|
|
1274
|
+
};
|
|
1275
|
+
return HorizontalRule;
|
|
1276
|
+
}(AbstractCanvasObject));
|
|
1277
|
+
|
|
1278
|
+
var Image = /** @class */ (function (_super) {
|
|
1279
|
+
__extends(Image, _super);
|
|
1280
|
+
function Image(canvas, fabricObject, persistedField) {
|
|
1281
|
+
var _this = _super.call(this, exports.ObjectType.IMAGE, canvas, fabricObject, persistedField) || this;
|
|
1282
|
+
_this.DEFAULT_RESTRICTIONS = {
|
|
1283
|
+
minWidth: 1,
|
|
1284
|
+
minHeight: 1
|
|
1285
|
+
};
|
|
1286
|
+
_this.canvas = canvas;
|
|
1287
|
+
_this.imageUrl$ = new rxjs.BehaviorSubject(_this.fabricObject.getSrc());
|
|
1288
|
+
_this.data.imagePath = _this.imageUrl$.value;
|
|
1289
|
+
_this.layoutWidth = _this.getBoundingBox().width;
|
|
1290
|
+
return _this;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* @override
|
|
1294
|
+
* @inheritDoc
|
|
1295
|
+
*/
|
|
1296
|
+
Image.prototype.getImageUrl = function () {
|
|
1297
|
+
return this.imageUrl$.value;
|
|
1298
|
+
};
|
|
1299
|
+
/**
|
|
1300
|
+
* @override
|
|
1301
|
+
* @inheritDoc
|
|
1302
|
+
*/
|
|
1303
|
+
Image.prototype.getImageUrl$ = function () {
|
|
1304
|
+
return this.imageUrl$;
|
|
1305
|
+
};
|
|
1306
|
+
/**
|
|
1307
|
+
* @override
|
|
1308
|
+
* @inheritDoc
|
|
1309
|
+
*/
|
|
1310
|
+
Image.prototype.setImageUrl = function (url) {
|
|
1311
|
+
this.setCanvasImage(url);
|
|
1312
|
+
this.data.imagePath = url;
|
|
1313
|
+
this.imageUrl$.next(url);
|
|
1314
|
+
this.canvas.notifyObjectListChanged();
|
|
1315
|
+
};
|
|
1316
|
+
/**
|
|
1317
|
+
* @override
|
|
1318
|
+
* @inheritDoc
|
|
1319
|
+
*/
|
|
1320
|
+
Image.prototype.setImageWidth = function (px, sizeRestrictions) {
|
|
1321
|
+
if (sizeRestrictions === void 0) { sizeRestrictions = this.DEFAULT_RESTRICTIONS; }
|
|
1322
|
+
var minWidth = Math.max(sizeRestrictions.minWidth, this.getMinWidthBasedOnMinHeight(sizeRestrictions.minHeight));
|
|
1323
|
+
var maxWidth = Math.min(sizeRestrictions.maxWidth, this.getMaxWidthBasedOnMaxHeight(sizeRestrictions.maxHeight));
|
|
1324
|
+
if (px < minWidth) {
|
|
1325
|
+
px = minWidth;
|
|
1326
|
+
}
|
|
1327
|
+
else if (px > maxWidth) {
|
|
1328
|
+
px = maxWidth;
|
|
1329
|
+
}
|
|
1330
|
+
var premultipliedWidth = this.fabricObject.width;
|
|
1331
|
+
var newScale = px / premultipliedWidth;
|
|
1332
|
+
this.fabricObject.set({ scaleX: newScale, scaleY: newScale });
|
|
1333
|
+
this.setCoords();
|
|
1334
|
+
this.canvas.notifyObjectListChanged();
|
|
1335
|
+
return px;
|
|
1336
|
+
};
|
|
1337
|
+
/**
|
|
1338
|
+
* @override
|
|
1339
|
+
* @inheritDoc
|
|
1340
|
+
*/
|
|
1341
|
+
Image.prototype.centerHorizontally = function () {
|
|
1342
|
+
_super.prototype.centerHorizontallyInternal.call(this);
|
|
1343
|
+
};
|
|
1344
|
+
/**
|
|
1345
|
+
* @override
|
|
1346
|
+
* @inheritDoc
|
|
1347
|
+
*/
|
|
1348
|
+
Image.prototype.centerVertically = function () {
|
|
1349
|
+
_super.prototype.centerVerticallyInternal.call(this);
|
|
1350
|
+
};
|
|
1351
|
+
/**
|
|
1352
|
+
* @override
|
|
1353
|
+
* @inheritDoc
|
|
1354
|
+
*/
|
|
1355
|
+
Image.prototype.setHeight = function (height) {
|
|
1356
|
+
this.setPosition({ height: height });
|
|
1357
|
+
this.canvas.notifyObjectListChanged();
|
|
1358
|
+
};
|
|
1359
|
+
/**
|
|
1360
|
+
* @override
|
|
1361
|
+
* @inheritDoc
|
|
1362
|
+
*/
|
|
1363
|
+
Image.prototype.nudgeUp = function () {
|
|
1364
|
+
_super.prototype.nudgeInternal.call(this, 0, -1);
|
|
1365
|
+
};
|
|
1366
|
+
/**
|
|
1367
|
+
* @override
|
|
1368
|
+
* @inheritDoc
|
|
1369
|
+
*/
|
|
1370
|
+
Image.prototype.nudgeDown = function () {
|
|
1371
|
+
_super.prototype.nudgeInternal.call(this, 0, +1);
|
|
1372
|
+
};
|
|
1373
|
+
/**
|
|
1374
|
+
* @override
|
|
1375
|
+
* @inheritDoc
|
|
1376
|
+
*/
|
|
1377
|
+
Image.prototype.nudgeLeft = function () {
|
|
1378
|
+
_super.prototype.nudgeInternal.call(this, -1, 0);
|
|
1379
|
+
};
|
|
1380
|
+
/**
|
|
1381
|
+
* @override
|
|
1382
|
+
* @inheritDoc
|
|
1383
|
+
*/
|
|
1384
|
+
Image.prototype.nudgeRight = function () {
|
|
1385
|
+
_super.prototype.nudgeInternal.call(this, +1, 0);
|
|
1386
|
+
};
|
|
1387
|
+
/**
|
|
1388
|
+
* @override
|
|
1389
|
+
* @inheritDoc
|
|
1390
|
+
*/
|
|
1391
|
+
Image.prototype.setPosition = function (position) {
|
|
1392
|
+
if (this.canvas.getLayoutManager().isEnforcedPositioning) {
|
|
1393
|
+
if (position.top != undefined)
|
|
1394
|
+
this.fabricObject.set({ top: position.top });
|
|
1395
|
+
if (position.width != undefined) {
|
|
1396
|
+
this.layoutWidth = position.width;
|
|
1397
|
+
}
|
|
1398
|
+
if (position.height != undefined) {
|
|
1399
|
+
var premultipliedHeight = this.fabricObject.height;
|
|
1400
|
+
var newScale = position.height / premultipliedHeight;
|
|
1401
|
+
this.fabricObject.set({ scaleX: newScale, scaleY: newScale });
|
|
1402
|
+
this.setCoords();
|
|
1403
|
+
}
|
|
1404
|
+
if (position.left != undefined || position.width != undefined || position.height != undefined) {
|
|
1405
|
+
this.centerHorizontallyInLayoutWidth(position.left || 0);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
else {
|
|
1409
|
+
_super.prototype.setPosition.call(this, position);
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
Image.prototype.centerHorizontallyInLayoutWidth = function (left) {
|
|
1413
|
+
var imageWidth = this.getBoundingBox().width;
|
|
1414
|
+
this.fabricObject.set({ left: left + (this.layoutWidth / 2) - (imageWidth / 2) });
|
|
1415
|
+
};
|
|
1416
|
+
Image.prototype.setCanvasImage = function (url) {
|
|
1417
|
+
var _this = this;
|
|
1418
|
+
var imageOptions = { crossOrigin: "anonymous" };
|
|
1419
|
+
//Don't let the image be more than half the canvas in size.
|
|
1420
|
+
var maxSizeScale = 2;
|
|
1421
|
+
var maxWidth = this.canvas.getDimensions().widthPx / maxSizeScale;
|
|
1422
|
+
this.fabricObject.setSrc(url, function (img) {
|
|
1423
|
+
var newScale = 1;
|
|
1424
|
+
var curWidth = newScale * img.width;
|
|
1425
|
+
if (curWidth > maxWidth) {
|
|
1426
|
+
newScale = maxWidth / curWidth;
|
|
1427
|
+
}
|
|
1428
|
+
img.set({
|
|
1429
|
+
scaleX: newScale,
|
|
1430
|
+
scaleY: newScale
|
|
1431
|
+
});
|
|
1432
|
+
img.setCoords();
|
|
1433
|
+
_this.redraw();
|
|
1434
|
+
}, imageOptions);
|
|
1435
|
+
};
|
|
1436
|
+
Image.prototype.getMinWidthBasedOnMinHeight = function (minHeight) {
|
|
1437
|
+
if (!minHeight) {
|
|
1438
|
+
return 0;
|
|
1439
|
+
}
|
|
1440
|
+
var premultipliedHeight = this.fabricObject.height;
|
|
1441
|
+
var newScale = minHeight / premultipliedHeight;
|
|
1442
|
+
return this.getBoundingBox().width * newScale;
|
|
1443
|
+
};
|
|
1444
|
+
Image.prototype.getMaxWidthBasedOnMaxHeight = function (maxHeight) {
|
|
1445
|
+
if (!maxHeight) {
|
|
1446
|
+
return Infinity;
|
|
1447
|
+
}
|
|
1448
|
+
var premultipliedHeight = this.fabricObject.height;
|
|
1449
|
+
var newScale = maxHeight / premultipliedHeight;
|
|
1450
|
+
return this.getBoundingBox().width * newScale;
|
|
1451
|
+
};
|
|
1452
|
+
return Image;
|
|
1453
|
+
}(AbstractCanvasObject));
|
|
1454
|
+
|
|
1455
|
+
var Rectangle = /** @class */ (function (_super) {
|
|
1456
|
+
__extends(Rectangle, _super);
|
|
1457
|
+
function Rectangle(canvas, fabricObject, persistedField) {
|
|
1458
|
+
var _this = _super.call(this, exports.ObjectType.RECTANGLE, canvas, fabricObject, persistedField) || this;
|
|
1459
|
+
_this.canvas = canvas;
|
|
1460
|
+
_this.fabricObject.set({ strokeWidth: 0 });
|
|
1461
|
+
return _this;
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* @override
|
|
1465
|
+
* @inheritDoc
|
|
1466
|
+
*/
|
|
1467
|
+
Rectangle.prototype.getColor = function () {
|
|
1468
|
+
return this.fabricObject.fill;
|
|
1469
|
+
};
|
|
1470
|
+
/**
|
|
1471
|
+
* @override
|
|
1472
|
+
* @inheritDoc
|
|
1473
|
+
*/
|
|
1474
|
+
Rectangle.prototype.setColor = function (color) {
|
|
1475
|
+
this.fabricObject.set({ fill: color, stroke: color });
|
|
1476
|
+
this.data.color = color;
|
|
1477
|
+
this.redraw();
|
|
1478
|
+
};
|
|
1479
|
+
/**
|
|
1480
|
+
* @override
|
|
1481
|
+
* @inheritDoc
|
|
1482
|
+
*/
|
|
1483
|
+
Rectangle.prototype.centerHorizontally = function () {
|
|
1484
|
+
_super.prototype.centerHorizontallyInternal.call(this);
|
|
1485
|
+
};
|
|
1486
|
+
/**
|
|
1487
|
+
* @override
|
|
1488
|
+
* @inheritDoc
|
|
1489
|
+
*/
|
|
1490
|
+
Rectangle.prototype.centerVertically = function () {
|
|
1491
|
+
_super.prototype.centerVerticallyInternal.call(this);
|
|
1492
|
+
};
|
|
1493
|
+
/**
|
|
1494
|
+
* @override
|
|
1495
|
+
* @inheritDoc
|
|
1496
|
+
*/
|
|
1497
|
+
Rectangle.prototype.setHeight = function (height) {
|
|
1498
|
+
this.setPosition({ height: height });
|
|
1499
|
+
this.canvas.notifyObjectListChanged();
|
|
1500
|
+
};
|
|
1501
|
+
/**
|
|
1502
|
+
* @override
|
|
1503
|
+
* @inheritDoc
|
|
1504
|
+
*/
|
|
1505
|
+
Rectangle.prototype.nudgeUp = function () {
|
|
1506
|
+
_super.prototype.nudgeInternal.call(this, 0, -1);
|
|
1507
|
+
};
|
|
1508
|
+
/**
|
|
1509
|
+
* @override
|
|
1510
|
+
* @inheritDoc
|
|
1511
|
+
*/
|
|
1512
|
+
Rectangle.prototype.nudgeDown = function () {
|
|
1513
|
+
_super.prototype.nudgeInternal.call(this, 0, +1);
|
|
1514
|
+
};
|
|
1515
|
+
/**
|
|
1516
|
+
* @override
|
|
1517
|
+
* @inheritDoc
|
|
1518
|
+
*/
|
|
1519
|
+
Rectangle.prototype.nudgeLeft = function () {
|
|
1520
|
+
_super.prototype.nudgeInternal.call(this, -1, 0);
|
|
1521
|
+
};
|
|
1522
|
+
/**
|
|
1523
|
+
* @override
|
|
1524
|
+
* @inheritDoc
|
|
1525
|
+
*/
|
|
1526
|
+
Rectangle.prototype.nudgeRight = function () {
|
|
1527
|
+
_super.prototype.nudgeInternal.call(this, +1, 0);
|
|
1528
|
+
};
|
|
1529
|
+
return Rectangle;
|
|
1530
|
+
}(AbstractCanvasObject));
|
|
1531
|
+
|
|
1532
|
+
var Text = /** @class */ (function (_super) {
|
|
1533
|
+
__extends(Text, _super);
|
|
1534
|
+
function Text(canvas, fabricObject, persistedField) {
|
|
1535
|
+
var _this = _super.call(this, exports.ObjectType.TEXT, canvas, fabricObject, persistedField) || this;
|
|
1536
|
+
_this.canvas = canvas;
|
|
1537
|
+
_this.fontLibrary = canvas.getFontLibrary();
|
|
1538
|
+
_this.baseComponentHeight = _this.fabricObject.height;
|
|
1539
|
+
_this.text$ = new rxjs.BehaviorSubject(_this.fabricObject.text);
|
|
1540
|
+
_this.data.userText = _this.fabricObject.text;
|
|
1541
|
+
_this.textSelection$ = new rxjs.BehaviorSubject(new TextSelection(_this.fabricObject, _this.fontLibrary));
|
|
1542
|
+
_this.fabricObject.set({ strokeWidth: 0 });
|
|
1543
|
+
_this.fabricObject.on("changed", function () { return _this.onTextChange(); });
|
|
1544
|
+
_this.fabricObject.on("selection:changed", function () { return _this.onSelectionChange(); });
|
|
1545
|
+
_this.applyBulletListMonkeyPatches();
|
|
1546
|
+
return _this;
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* @override
|
|
1550
|
+
* @inheritDoc
|
|
1551
|
+
*/
|
|
1552
|
+
Text.prototype.getText = function () {
|
|
1553
|
+
return this.text$.value;
|
|
1554
|
+
};
|
|
1555
|
+
/**
|
|
1556
|
+
* @override
|
|
1557
|
+
* @inheritDoc
|
|
1558
|
+
*/
|
|
1559
|
+
Text.prototype.getText$ = function () {
|
|
1560
|
+
return this.text$;
|
|
1561
|
+
};
|
|
1562
|
+
/**
|
|
1563
|
+
* @override
|
|
1564
|
+
* @inheritDoc
|
|
1565
|
+
*/
|
|
1566
|
+
Text.prototype.setText = function (text) {
|
|
1567
|
+
var style = this.fabricObject.getStyleAtPosition(0, true);
|
|
1568
|
+
this.fabricObject.set({ text: text });
|
|
1569
|
+
this.data.userText = this.fabricObject.text;
|
|
1570
|
+
this.text$.next(text);
|
|
1571
|
+
this.fabricObject.setSelectionStyles(style, 0, text.length);
|
|
1572
|
+
this.redraw();
|
|
1573
|
+
};
|
|
1574
|
+
/**
|
|
1575
|
+
* @override
|
|
1576
|
+
* @inheritDoc
|
|
1577
|
+
*/
|
|
1578
|
+
Text.prototype.replaceText = function (target, replacement) {
|
|
1579
|
+
var start = this.getText().indexOf(target);
|
|
1580
|
+
this.fabricObject.insertChars(replacement, null, start, start + target.length);
|
|
1581
|
+
this.redraw();
|
|
1582
|
+
this.data.userText = this.fabricObject.text;
|
|
1583
|
+
this.text$.next(this.fabricObject.text);
|
|
1584
|
+
};
|
|
1585
|
+
/**
|
|
1586
|
+
* @override
|
|
1587
|
+
* @inheritDoc
|
|
1588
|
+
*/
|
|
1589
|
+
Text.prototype.getColor = function () {
|
|
1590
|
+
return this.textSelection$.value.fill;
|
|
1591
|
+
};
|
|
1592
|
+
/**
|
|
1593
|
+
* @override
|
|
1594
|
+
* @inheritDoc
|
|
1595
|
+
*/
|
|
1596
|
+
Text.prototype.setColor = function (color) {
|
|
1597
|
+
if (this.hasTextSelection()) {
|
|
1598
|
+
this.fabricObject.setSelectionStyles({ fill: color });
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
this.fabricObject.set({ fill: color });
|
|
1602
|
+
}
|
|
1603
|
+
this.data.color = color;
|
|
1604
|
+
this.updateTextSelection();
|
|
1605
|
+
this.redraw();
|
|
1606
|
+
};
|
|
1607
|
+
/**
|
|
1608
|
+
* @override
|
|
1609
|
+
* @inheritDoc
|
|
1610
|
+
*/
|
|
1611
|
+
Text.prototype.getTextSelection = function () {
|
|
1612
|
+
return this.textSelection$.value;
|
|
1613
|
+
};
|
|
1614
|
+
/**
|
|
1615
|
+
* @override
|
|
1616
|
+
* @inheritDoc
|
|
1617
|
+
*/
|
|
1618
|
+
Text.prototype.getTextSelection$ = function () {
|
|
1619
|
+
return this.textSelection$;
|
|
1620
|
+
};
|
|
1621
|
+
/**
|
|
1622
|
+
* @override
|
|
1623
|
+
* @inheritDoc
|
|
1624
|
+
*/
|
|
1625
|
+
Text.prototype.setTextAlign = function (alignment) {
|
|
1626
|
+
this.fabricObject.set({ textAlign: alignment });
|
|
1627
|
+
this.redraw();
|
|
1628
|
+
this.updateTextSelection();
|
|
1629
|
+
};
|
|
1630
|
+
/**
|
|
1631
|
+
* @override
|
|
1632
|
+
* @inheritDoc
|
|
1633
|
+
*/
|
|
1634
|
+
Text.prototype.setCharSpacing = function (spacing) {
|
|
1635
|
+
this.fabricObject.set({ charSpacing: spacing });
|
|
1636
|
+
this.redraw();
|
|
1637
|
+
this.updateTextSelection();
|
|
1638
|
+
};
|
|
1639
|
+
/**
|
|
1640
|
+
* @override
|
|
1641
|
+
* @inheritDoc
|
|
1642
|
+
*/
|
|
1643
|
+
Text.prototype.setLineHeight = function (height) {
|
|
1644
|
+
this.fabricObject.set({ lineHeight: height });
|
|
1645
|
+
this.redraw();
|
|
1646
|
+
this.updateTextSelection();
|
|
1647
|
+
};
|
|
1648
|
+
/**
|
|
1649
|
+
* @override
|
|
1650
|
+
* @inheritDoc
|
|
1651
|
+
*/
|
|
1652
|
+
Text.prototype.setBold = function (bold) {
|
|
1653
|
+
if (bold === void 0) { bold = true; }
|
|
1654
|
+
if (this.hasTextSelection()) {
|
|
1655
|
+
var start = this.textSelection$.value.start;
|
|
1656
|
+
for (var i = 0; i < this.textSelection$.value.length; i++) {
|
|
1657
|
+
var style = this.fabricObject.getStyleAtPosition(start + i, true);
|
|
1658
|
+
var font = this.fontLibrary.getFont(style.fontFamily);
|
|
1659
|
+
var fontWeight = bold ? font.boldWeight : font.normalWeight;
|
|
1660
|
+
this.fabricObject.setSelectionStyles({ fontWeight: fontWeight }, start + i, start + i + 1);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
else {
|
|
1664
|
+
var font = this.fontLibrary.getFont(this.fabricObject.fontFamily);
|
|
1665
|
+
var fontWeight = bold ? font.boldWeight : font.normalWeight;
|
|
1666
|
+
this.fabricObject.set({ fontWeight: fontWeight });
|
|
1667
|
+
}
|
|
1668
|
+
this.redraw();
|
|
1669
|
+
this.updateTextSelection();
|
|
1670
|
+
};
|
|
1671
|
+
/**
|
|
1672
|
+
* @override
|
|
1673
|
+
* @inheritDoc
|
|
1674
|
+
*/
|
|
1675
|
+
Text.prototype.setBoldRegion = function (start, end, bold) {
|
|
1676
|
+
if (bold === void 0) { bold = true; }
|
|
1677
|
+
if (start > end)
|
|
1678
|
+
throw Error("Bad region specified: [" + start + " - " + end + "]");
|
|
1679
|
+
for (var i = start; i < end; i++) {
|
|
1680
|
+
var style = this.fabricObject.getStyleAtPosition(i, true);
|
|
1681
|
+
var font = this.fontLibrary.getFont(style.fontFamily);
|
|
1682
|
+
style.fontWeight = bold ? font.boldWeight : font.normalWeight;
|
|
1683
|
+
this.fabricObject.setSelectionStyles(style, i, i + 1);
|
|
1684
|
+
}
|
|
1685
|
+
this.redraw();
|
|
1686
|
+
};
|
|
1687
|
+
/**
|
|
1688
|
+
* @override
|
|
1689
|
+
* @inheritDoc
|
|
1690
|
+
*/
|
|
1691
|
+
Text.prototype.setItalic = function (italic) {
|
|
1692
|
+
if (italic === void 0) { italic = true; }
|
|
1693
|
+
if (this.hasTextSelection()) {
|
|
1694
|
+
this.fabricObject.setSelectionStyles({ fontStyle: italic ? "italic" : "" });
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
this.fabricObject.set({ fontStyle: italic ? "italic" : "" });
|
|
1698
|
+
}
|
|
1699
|
+
this.redraw();
|
|
1700
|
+
this.updateTextSelection();
|
|
1701
|
+
};
|
|
1702
|
+
/**
|
|
1703
|
+
* @override
|
|
1704
|
+
* @inheritDoc
|
|
1705
|
+
*/
|
|
1706
|
+
Text.prototype.setItalicRegion = function (start, end, italic) {
|
|
1707
|
+
if (italic === void 0) { italic = true; }
|
|
1708
|
+
if (start > end)
|
|
1709
|
+
throw Error("Bad region specified: [" + start + " - " + end + "]");
|
|
1710
|
+
this.fabricObject.setSelectionStyles({ fontStyle: italic ? "italic" : "" }, start, end);
|
|
1711
|
+
this.redraw();
|
|
1712
|
+
};
|
|
1713
|
+
/**
|
|
1714
|
+
* @override
|
|
1715
|
+
* @inheritDoc
|
|
1716
|
+
*/
|
|
1717
|
+
Text.prototype.setStrikethrough = function (strikethrough) {
|
|
1718
|
+
if (strikethrough === void 0) { strikethrough = true; }
|
|
1719
|
+
if (this.hasTextSelection()) {
|
|
1720
|
+
this.fabricObject.setSelectionStyles({ linethrough: strikethrough });
|
|
1721
|
+
}
|
|
1722
|
+
else {
|
|
1723
|
+
this.fabricObject.set({ linethrough: strikethrough });
|
|
1724
|
+
}
|
|
1725
|
+
this.redraw();
|
|
1726
|
+
this.updateTextSelection();
|
|
1727
|
+
};
|
|
1728
|
+
/**
|
|
1729
|
+
* @override
|
|
1730
|
+
* @inheritDoc
|
|
1731
|
+
*/
|
|
1732
|
+
Text.prototype.setUnderline = function (underline) {
|
|
1733
|
+
if (underline === void 0) { underline = true; }
|
|
1734
|
+
this.fabricObject.setSelectionStyles({ underline: underline });
|
|
1735
|
+
this.redraw();
|
|
1736
|
+
this.updateTextSelection();
|
|
1737
|
+
};
|
|
1738
|
+
/**
|
|
1739
|
+
* @override
|
|
1740
|
+
* @inheritDoc
|
|
1741
|
+
*/
|
|
1742
|
+
Text.prototype.setFont = function (font) {
|
|
1743
|
+
if (this.hasTextSelection()) {
|
|
1744
|
+
this.fabricObject.setSelectionStyles({ fontFamily: font.family, fontWeight: font.normalWeight });
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
this.fabricObject.set({ fontFamily: font.family, fontWeight: font.normalWeight });
|
|
1748
|
+
}
|
|
1749
|
+
this.redraw();
|
|
1750
|
+
this.updateTextSelection();
|
|
1751
|
+
};
|
|
1752
|
+
/**
|
|
1753
|
+
* @override
|
|
1754
|
+
* @inheritDoc
|
|
1755
|
+
*/
|
|
1756
|
+
Text.prototype.setFontSize = function (fontSize) {
|
|
1757
|
+
if (this.hasTextSelection()) {
|
|
1758
|
+
this.fabricObject.setSelectionStyles({ fontSize: fontSize });
|
|
1759
|
+
}
|
|
1760
|
+
else {
|
|
1761
|
+
this.fabricObject.set({ fontSize: fontSize });
|
|
1762
|
+
}
|
|
1763
|
+
this.redraw();
|
|
1764
|
+
this.updateTextSelection();
|
|
1765
|
+
};
|
|
1766
|
+
/**
|
|
1767
|
+
* @override
|
|
1768
|
+
* @inheritDoc
|
|
1769
|
+
*/
|
|
1770
|
+
Text.prototype.setTextBackgroundColor = function (color) {
|
|
1771
|
+
if (this.hasTextSelection()) {
|
|
1772
|
+
this.fabricObject.setSelectionStyles({ textBackgroundColor: color });
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
this.fabricObject.set({ textBackgroundColor: color });
|
|
1776
|
+
}
|
|
1777
|
+
this.redraw();
|
|
1778
|
+
this.updateTextSelection();
|
|
1779
|
+
};
|
|
1780
|
+
/**
|
|
1781
|
+
* @override
|
|
1782
|
+
* @inheritDoc
|
|
1783
|
+
*/
|
|
1784
|
+
Text.prototype.centerHorizontally = function () {
|
|
1785
|
+
_super.prototype.centerHorizontallyInternal.call(this);
|
|
1786
|
+
};
|
|
1787
|
+
/**
|
|
1788
|
+
* @override
|
|
1789
|
+
* @inheritDoc
|
|
1790
|
+
*/
|
|
1791
|
+
Text.prototype.centerVertically = function () {
|
|
1792
|
+
_super.prototype.centerVerticallyInternal.call(this);
|
|
1793
|
+
};
|
|
1794
|
+
/**
|
|
1795
|
+
* @override
|
|
1796
|
+
* @inheritDoc
|
|
1797
|
+
*/
|
|
1798
|
+
Text.prototype.setHeight = function (height) {
|
|
1799
|
+
//no-op
|
|
1800
|
+
};
|
|
1801
|
+
/**
|
|
1802
|
+
* @override
|
|
1803
|
+
* @inheritDoc
|
|
1804
|
+
*/
|
|
1805
|
+
Text.prototype.nudgeUp = function () {
|
|
1806
|
+
_super.prototype.nudgeInternal.call(this, 0, -1);
|
|
1807
|
+
};
|
|
1808
|
+
/**
|
|
1809
|
+
* @override
|
|
1810
|
+
* @inheritDoc
|
|
1811
|
+
*/
|
|
1812
|
+
Text.prototype.nudgeDown = function () {
|
|
1813
|
+
_super.prototype.nudgeInternal.call(this, 0, +1);
|
|
1814
|
+
};
|
|
1815
|
+
/**
|
|
1816
|
+
* @override
|
|
1817
|
+
* @inheritDoc
|
|
1818
|
+
*/
|
|
1819
|
+
Text.prototype.nudgeLeft = function () {
|
|
1820
|
+
_super.prototype.nudgeInternal.call(this, -1, 0);
|
|
1821
|
+
};
|
|
1822
|
+
/**
|
|
1823
|
+
* @override
|
|
1824
|
+
* @inheritDoc
|
|
1825
|
+
*/
|
|
1826
|
+
Text.prototype.nudgeRight = function () {
|
|
1827
|
+
_super.prototype.nudgeInternal.call(this, +1, 0);
|
|
1828
|
+
};
|
|
1829
|
+
/**
|
|
1830
|
+
* @override
|
|
1831
|
+
* @inheritDoc
|
|
1832
|
+
*/
|
|
1833
|
+
Text.prototype.getBackgroundColor = function () {
|
|
1834
|
+
return this.fabricObject.backgroundColor;
|
|
1835
|
+
};
|
|
1836
|
+
/**
|
|
1837
|
+
* @override
|
|
1838
|
+
* @inheritDoc
|
|
1839
|
+
*/
|
|
1840
|
+
Text.prototype.setBackgroundColor = function (color) {
|
|
1841
|
+
this.fabricObject.set({ backgroundColor: color });
|
|
1842
|
+
this.redraw();
|
|
1843
|
+
};
|
|
1844
|
+
/**
|
|
1845
|
+
* @override
|
|
1846
|
+
* @inheritDoc
|
|
1847
|
+
*/
|
|
1848
|
+
Text.prototype.setPrefillType = function (prefillType) {
|
|
1849
|
+
this.data.prefillType = prefillType;
|
|
1850
|
+
};
|
|
1851
|
+
/**
|
|
1852
|
+
* @override
|
|
1853
|
+
* @inheritDoc
|
|
1854
|
+
*/
|
|
1855
|
+
Text.prototype.getPrefillType = function () {
|
|
1856
|
+
return this.data.prefillType;
|
|
1857
|
+
};
|
|
1858
|
+
/**
|
|
1859
|
+
* @override
|
|
1860
|
+
* @inheritDoc
|
|
1861
|
+
*/
|
|
1862
|
+
Text.prototype.isResizeCanvas = function () {
|
|
1863
|
+
return this.data.resizeCanvas;
|
|
1864
|
+
};
|
|
1865
|
+
/**
|
|
1866
|
+
* @override
|
|
1867
|
+
* @inheritDoc
|
|
1868
|
+
*/
|
|
1869
|
+
Text.prototype.setResizeCanvas = function (value) {
|
|
1870
|
+
this.baseComponentHeight = this.fabricObject.height;
|
|
1871
|
+
this.data.resizeCanvas = value;
|
|
1872
|
+
};
|
|
1873
|
+
/**
|
|
1874
|
+
* @override
|
|
1875
|
+
* @inheritDoc
|
|
1876
|
+
*/
|
|
1877
|
+
Text.prototype.focus = function () {
|
|
1878
|
+
this.fabricObject.hiddenTextarea.focus();
|
|
1879
|
+
};
|
|
1880
|
+
/**
|
|
1881
|
+
* @override
|
|
1882
|
+
* @inheritDoc
|
|
1883
|
+
*/
|
|
1884
|
+
Text.prototype.isEditing = function () {
|
|
1885
|
+
return this.fabricObject.isEditing;
|
|
1886
|
+
};
|
|
1887
|
+
/**
|
|
1888
|
+
* @override
|
|
1889
|
+
* @inheritDoc
|
|
1890
|
+
*/
|
|
1891
|
+
Text.prototype.enterEditing = function () {
|
|
1892
|
+
if (!this.isEditing()) {
|
|
1893
|
+
this.fabricObject.enterEditing();
|
|
1894
|
+
this.focus();
|
|
1895
|
+
this.selectAllText();
|
|
1896
|
+
this.redraw();
|
|
1897
|
+
}
|
|
1898
|
+
};
|
|
1899
|
+
/**
|
|
1900
|
+
* @override
|
|
1901
|
+
* @inheritDoc
|
|
1902
|
+
*/
|
|
1903
|
+
Text.prototype.selectAllText = function () {
|
|
1904
|
+
this.fabricObject.selectAll();
|
|
1905
|
+
};
|
|
1906
|
+
/**
|
|
1907
|
+
* @override
|
|
1908
|
+
* @inheritDoc
|
|
1909
|
+
*/
|
|
1910
|
+
Text.prototype.isBulleted = function () {
|
|
1911
|
+
return this.data.bulleted || false;
|
|
1912
|
+
};
|
|
1913
|
+
/**
|
|
1914
|
+
* @override
|
|
1915
|
+
* @inheritDoc
|
|
1916
|
+
*/
|
|
1917
|
+
Text.prototype.enableBullets = function () {
|
|
1918
|
+
this.fabricObject["objectCaching"] = false;
|
|
1919
|
+
this.fabricObject["_bullets"] = this.fabricObject["_bullets"] || {};
|
|
1920
|
+
this.data.bulleted = true;
|
|
1921
|
+
this.notifyCanvasOfTextChanges();
|
|
1922
|
+
this.redraw();
|
|
1923
|
+
};
|
|
1924
|
+
/**
|
|
1925
|
+
* @override
|
|
1926
|
+
* @inheritDoc
|
|
1927
|
+
*/
|
|
1928
|
+
Text.prototype.disableBullets = function () {
|
|
1929
|
+
this.removeBullets();
|
|
1930
|
+
this.data.bulleted = false;
|
|
1931
|
+
this.notifyCanvasOfTextChanges();
|
|
1932
|
+
this.redraw();
|
|
1933
|
+
};
|
|
1934
|
+
Text.prototype.getSizeIncreaseSinceCreation = function () {
|
|
1935
|
+
return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
|
|
1936
|
+
};
|
|
1937
|
+
Text.prototype.removeBullets = function () {
|
|
1938
|
+
var _this = this;
|
|
1939
|
+
if (this.data.bulleted) {
|
|
1940
|
+
var bullets = this.fabricObject["_bullets"];
|
|
1941
|
+
delete this.fabricObject["_bullets"];
|
|
1942
|
+
_.each(bullets, function (bullet) { return _this.canvas.removeFabricObject(bullet); });
|
|
1943
|
+
this.fabricObject["objectCaching"] = true;
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
Text.prototype.applyBulletListMonkeyPatches = function () {
|
|
1947
|
+
if (this.data.bulleted)
|
|
1948
|
+
this.enableBullets();
|
|
1949
|
+
var originalRender = this.fabricObject["_render"];
|
|
1950
|
+
this.fabricObject["_render"] = function (ctx) {
|
|
1951
|
+
var _this = this;
|
|
1952
|
+
var fabricText = this;
|
|
1953
|
+
if (fabricText["_bullets"]) {
|
|
1954
|
+
// Determine list of active bullets
|
|
1955
|
+
var currentBullets_1 = fabricText["_bullets"];
|
|
1956
|
+
var activeBullets_1 = {};
|
|
1957
|
+
_.each(fabricText._textLines, function (textLine, lineIndex) {
|
|
1958
|
+
if (textLine.length) {
|
|
1959
|
+
// Start of real lines will have offset 0 in styleMap
|
|
1960
|
+
var styleMap = fabricText._styleMap[lineIndex];
|
|
1961
|
+
if (styleMap.offset === 0) {
|
|
1962
|
+
if (currentBullets_1[lineIndex]) {
|
|
1963
|
+
// Reuse existing bullet for this line
|
|
1964
|
+
activeBullets_1[lineIndex] = currentBullets_1[lineIndex];
|
|
1965
|
+
}
|
|
1966
|
+
else {
|
|
1967
|
+
// Create new bullet for this line
|
|
1968
|
+
var options = {
|
|
1969
|
+
left: 0,
|
|
1970
|
+
top: 0,
|
|
1971
|
+
radius: 2,
|
|
1972
|
+
fill: fabricText.fill,
|
|
1973
|
+
scaleX: fabricText.scaleX,
|
|
1974
|
+
scaleY: fabricText.scaleY,
|
|
1975
|
+
strokeWidth: 0,
|
|
1976
|
+
lockMovementX: true,
|
|
1977
|
+
lockMovementY: true,
|
|
1978
|
+
hasControls: false,
|
|
1979
|
+
selectable: false,
|
|
1980
|
+
excludeFromJson: true
|
|
1981
|
+
};
|
|
1982
|
+
activeBullets_1[lineIndex] = new _this.canvas.fabric.Circle(options);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
// Add/Remove bullets from canvas
|
|
1988
|
+
var canvas_1 = fabricText.canvas;
|
|
1989
|
+
var canvasDirty_1 = false;
|
|
1990
|
+
canvas_1.renderOnAddRemove = false;
|
|
1991
|
+
_.each(activeBullets_1, function (bullet) {
|
|
1992
|
+
if (!canvas_1.contains(bullet)) {
|
|
1993
|
+
canvas_1.add(bullet);
|
|
1994
|
+
canvasDirty_1 = true;
|
|
1995
|
+
}
|
|
1996
|
+
});
|
|
1997
|
+
_.each(currentBullets_1, function (bullet, key) {
|
|
1998
|
+
if (!activeBullets_1[key]) {
|
|
1999
|
+
canvas_1.remove(bullet);
|
|
2000
|
+
canvasDirty_1 = true;
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2003
|
+
canvas_1.renderOnAddRemove = true;
|
|
2004
|
+
fabricText["_bullets"] = activeBullets_1;
|
|
2005
|
+
if (canvasDirty_1) {
|
|
2006
|
+
// Fabric doesn't like it when you add new things within render so use a sneaky timeout to delay render
|
|
2007
|
+
setTimeout(canvas_1.renderAll.bind(canvas_1));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
originalRender.apply(fabricText, [ctx]);
|
|
2011
|
+
};
|
|
2012
|
+
var originalRenderTextLine = this.fabricObject["_renderTextLine"];
|
|
2013
|
+
this.fabricObject["_renderTextLine"] = function (method, ctx, line, left, top, lineIndex) {
|
|
2014
|
+
var fabricText = this;
|
|
2015
|
+
var bullets = fabricText._bullets;
|
|
2016
|
+
if (bullets && bullets[lineIndex]) {
|
|
2017
|
+
var bullet = bullets[lineIndex];
|
|
2018
|
+
var bulletIndent = 10;
|
|
2019
|
+
var bulletLeft = fabricText.left + (left - fabricText._getLeftOffset() - bulletIndent) * fabricText.scaleX;
|
|
2020
|
+
if (bullet.left !== bulletLeft) {
|
|
2021
|
+
bullet.set({ left: bulletLeft });
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* What an out-and-out mess... this calculation is a joke, and the bulletOffset is just an approximation of values that look ok for
|
|
2025
|
+
* the font sizes we use. The 'top' value provided is actutally the... bottom? of the line... and not the line... the bottom of where
|
|
2026
|
+
* the font is rendered... subtracting the `fabricText.getHeightOfLine(lineIndex)` line hieght doesn't give you the top, because the
|
|
2027
|
+
* line height is actually the height of the font plus the excess line height added via the text line-height property.
|
|
2028
|
+
* I couldn't figure out how to get the actual top of the line in two days of trying to understand this ridiculous library.
|
|
2029
|
+
* So, here... bullets. That sort of work... sometimes.
|
|
2030
|
+
*/
|
|
2031
|
+
var textOriginTop = fabricText.top + (fabricText.height / 2);
|
|
2032
|
+
var fontSize = this.getValueOfPropertyAt(lineIndex, 0, "fontSize");
|
|
2033
|
+
var bulletOffset = ((fontSize + 6) / 2);
|
|
2034
|
+
var bulletTop = textOriginTop + top - bulletOffset;
|
|
2035
|
+
if (bullet.top !== bulletTop) {
|
|
2036
|
+
bullet.set({ top: bulletTop });
|
|
2037
|
+
}
|
|
2038
|
+
if (bullet.fill !== fabricText.fill) {
|
|
2039
|
+
bullet.set({ fill: fabricText.fill });
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
originalRenderTextLine.apply(fabricText, [method, ctx, line, left, top, lineIndex]);
|
|
2043
|
+
};
|
|
2044
|
+
};
|
|
2045
|
+
/**
|
|
2046
|
+
* @override
|
|
2047
|
+
* @inheritDoc
|
|
2048
|
+
*/
|
|
2049
|
+
Text.prototype.updateFabricObjectBehavior = function () {
|
|
2050
|
+
_super.prototype.updateFabricObjectBehavior.call(this);
|
|
2051
|
+
var profile = this.canvas.getProfile();
|
|
2052
|
+
var allowManualPositioning = !this.canvas.getLayoutManager().isEnforcedPositioning;
|
|
2053
|
+
this.fabricObject.set({
|
|
2054
|
+
lockScalingY: true,
|
|
2055
|
+
lockScalingX: this.isPinToBottom(),
|
|
2056
|
+
lockScalingFlip: true
|
|
2057
|
+
});
|
|
2058
|
+
this.fabricObject.setControlsVisibility({
|
|
2059
|
+
tl: false,
|
|
2060
|
+
tr: false,
|
|
2061
|
+
br: false,
|
|
2062
|
+
bl: false,
|
|
2063
|
+
ml: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
|
|
2064
|
+
mt: false,
|
|
2065
|
+
mr: allowManualPositioning && profile.allowScale && !this.isPinToBottom(),
|
|
2066
|
+
mb: false
|
|
2067
|
+
});
|
|
2068
|
+
this.redraw();
|
|
2069
|
+
};
|
|
2070
|
+
Text.prototype.onTextChange = function () {
|
|
2071
|
+
this.data.userText = this.fabricObject.text;
|
|
2072
|
+
this.text$.next(this.fabricObject.text);
|
|
2073
|
+
if (this.getBoundingBox().width > this.canvas.getDimensions().widthPx) {
|
|
2074
|
+
this.fabricObject.set({ left: 0, width: this.canvas.getDimensions().widthPx });
|
|
2075
|
+
this.redraw();
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
Text.prototype.onDelete = function () {
|
|
2079
|
+
this.removeBullets();
|
|
2080
|
+
};
|
|
2081
|
+
Text.prototype.onSelectionChange = function () {
|
|
2082
|
+
this.updateTextSelection();
|
|
2083
|
+
};
|
|
2084
|
+
Text.prototype.hasTextSelection = function () {
|
|
2085
|
+
return this.canvas.getSelection().isText && this.textSelection$.value.length > 0;
|
|
2086
|
+
};
|
|
2087
|
+
Text.prototype.updateTextSelection = function () {
|
|
2088
|
+
this.textSelection$.next(new TextSelection(this.fabricObject, this.fontLibrary));
|
|
2089
|
+
this.notifyCanvasOfTextChanges();
|
|
2090
|
+
};
|
|
2091
|
+
Text.prototype.notifyCanvasOfTextChanges = function () {
|
|
2092
|
+
this.canvas.notifyTextChanged();
|
|
2093
|
+
};
|
|
2094
|
+
return Text;
|
|
2095
|
+
}(AbstractCanvasObject));
|
|
2096
|
+
var TextSelection = /** @class */ (function () {
|
|
2097
|
+
function TextSelection(fabricObject, fontLibrary) {
|
|
2098
|
+
this.fabricObject = fabricObject;
|
|
2099
|
+
this.fontLibrary = fontLibrary;
|
|
2100
|
+
this.start = this.fabricObject.selectionStart;
|
|
2101
|
+
this.end = this.fabricObject.selectionEnd;
|
|
2102
|
+
this.length = this.end - this.start;
|
|
2103
|
+
var cursorLoc = this.fabricObject.get2DCursorLocation();
|
|
2104
|
+
this.lineIndex = cursorLoc.lineIndex;
|
|
2105
|
+
this.charIndex = cursorLoc.charIndex;
|
|
2106
|
+
var style = this.fabricObject.getCompleteStyleDeclaration(this.lineIndex, this.charIndex);
|
|
2107
|
+
var hasSelection = this.length > 0;
|
|
2108
|
+
this.font = hasSelection ? this.fontLibrary.getFont(style.fontFamily) : this.fontLibrary.getFont(this.fabricObject.fontFamily);
|
|
2109
|
+
this.fontSize = hasSelection ? style.fontSize : this.fabricObject.fontSize;
|
|
2110
|
+
this.fontWeight = hasSelection ? style.fontWeight : this.fabricObject.fontWeight;
|
|
2111
|
+
this.bold = this.font.isBold(this.fontWeight);
|
|
2112
|
+
this.italic = hasSelection ? style.fontStyle === "italic" : this.fabricObject.fontStyle === "italic";
|
|
2113
|
+
this.underline = hasSelection ? style.underline : this.fabricObject.underline;
|
|
2114
|
+
this.strikethrough = hasSelection ? style.linethrough : this.fabricObject.linethrough;
|
|
2115
|
+
this.overline = hasSelection ? style.overline : this.fabricObject.overline;
|
|
2116
|
+
this.textBackgroundColor = hasSelection ? style.textBackgroundColor : this.fabricObject.textBackgroundColor;
|
|
2117
|
+
this.textAlign = this.fabricObject.textAlign;
|
|
2118
|
+
this.charSpacing = this.fabricObject.charSpacing;
|
|
2119
|
+
this.lineHeight = this.fabricObject.lineHeight;
|
|
2120
|
+
this.fill = style.fill;
|
|
2121
|
+
this.stroke = style.stroke;
|
|
2122
|
+
this.strokeWidth = style.strokeWidth;
|
|
2123
|
+
}
|
|
2124
|
+
return TextSelection;
|
|
2125
|
+
}());
|
|
2126
|
+
|
|
2127
|
+
var VerticalRule = /** @class */ (function (_super) {
|
|
2128
|
+
__extends(VerticalRule, _super);
|
|
2129
|
+
function VerticalRule(canvas, fabricObject, persistedField) {
|
|
2130
|
+
var _this = _super.call(this, exports.ObjectType.VERTICAL_RULE, canvas, fabricObject, persistedField) || this;
|
|
2131
|
+
_this.strokeWidth$ = new rxjs.BehaviorSubject(2);
|
|
2132
|
+
_this.canvas = canvas;
|
|
2133
|
+
_this.strokeWidth$.next(_this.getDimensions().width.px);
|
|
2134
|
+
_this.fabricObject.set({ strokeWidth: 0 });
|
|
2135
|
+
return _this;
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* @override
|
|
2139
|
+
* @inheritDoc
|
|
2140
|
+
*/
|
|
2141
|
+
VerticalRule.prototype.getStrokeWidth = function () {
|
|
2142
|
+
return this.fabricObject.width;
|
|
2143
|
+
};
|
|
2144
|
+
/**
|
|
2145
|
+
* @override
|
|
2146
|
+
* @inheritDoc
|
|
2147
|
+
*/
|
|
2148
|
+
VerticalRule.prototype.getStrokeWidth$ = function () {
|
|
2149
|
+
return this.strokeWidth$;
|
|
2150
|
+
};
|
|
2151
|
+
/**
|
|
2152
|
+
* @override
|
|
2153
|
+
* @inheritDoc
|
|
2154
|
+
*/
|
|
2155
|
+
VerticalRule.prototype.setStrokeWidth = function (width) {
|
|
2156
|
+
this.strokeWidth$.next(width);
|
|
2157
|
+
this.data.strokeWidth = width;
|
|
2158
|
+
this.setPosition({ width: width });
|
|
2159
|
+
this.canvas.notifyObjectListChanged();
|
|
2160
|
+
this.redraw();
|
|
2161
|
+
};
|
|
2162
|
+
/**
|
|
2163
|
+
* @override
|
|
2164
|
+
* @inheritDoc
|
|
2165
|
+
*/
|
|
2166
|
+
VerticalRule.prototype.getColor = function () {
|
|
2167
|
+
return this.fabricObject.fill;
|
|
2168
|
+
};
|
|
2169
|
+
/**
|
|
2170
|
+
* @override
|
|
2171
|
+
* @inheritDoc
|
|
2172
|
+
*/
|
|
2173
|
+
VerticalRule.prototype.setColor = function (color) {
|
|
2174
|
+
this.fabricObject.set({ fill: color, stroke: color });
|
|
2175
|
+
this.data.color = color;
|
|
2176
|
+
this.redraw();
|
|
2177
|
+
};
|
|
2178
|
+
/**
|
|
2179
|
+
* @override
|
|
2180
|
+
* @inheritDoc
|
|
2181
|
+
*/
|
|
2182
|
+
VerticalRule.prototype.centerHorizontally = function () {
|
|
2183
|
+
_super.prototype.centerHorizontallyInternal.call(this);
|
|
2184
|
+
};
|
|
2185
|
+
/**
|
|
2186
|
+
* @override
|
|
2187
|
+
* @inheritDoc
|
|
2188
|
+
*/
|
|
2189
|
+
VerticalRule.prototype.centerVertically = function () {
|
|
2190
|
+
_super.prototype.centerVerticallyInternal.call(this);
|
|
2191
|
+
};
|
|
2192
|
+
/**
|
|
2193
|
+
* @override
|
|
2194
|
+
* @inheritDoc
|
|
2195
|
+
*/
|
|
2196
|
+
VerticalRule.prototype.setHeight = function (height) {
|
|
2197
|
+
this.setPosition({ height: height });
|
|
2198
|
+
this.canvas.notifyObjectListChanged();
|
|
2199
|
+
};
|
|
2200
|
+
/**
|
|
2201
|
+
* @override
|
|
2202
|
+
* @inheritDoc
|
|
2203
|
+
*/
|
|
2204
|
+
VerticalRule.prototype.nudgeUp = function () {
|
|
2205
|
+
_super.prototype.nudgeInternal.call(this, 0, -1);
|
|
2206
|
+
};
|
|
2207
|
+
/**
|
|
2208
|
+
* @override
|
|
2209
|
+
* @inheritDoc
|
|
2210
|
+
*/
|
|
2211
|
+
VerticalRule.prototype.nudgeDown = function () {
|
|
2212
|
+
_super.prototype.nudgeInternal.call(this, 0, +1);
|
|
2213
|
+
};
|
|
2214
|
+
/**
|
|
2215
|
+
* @override
|
|
2216
|
+
* @inheritDoc
|
|
2217
|
+
*/
|
|
2218
|
+
VerticalRule.prototype.nudgeLeft = function () {
|
|
2219
|
+
_super.prototype.nudgeInternal.call(this, -1, 0);
|
|
2220
|
+
};
|
|
2221
|
+
/**
|
|
2222
|
+
* @override
|
|
2223
|
+
* @inheritDoc
|
|
2224
|
+
*/
|
|
2225
|
+
VerticalRule.prototype.nudgeRight = function () {
|
|
2226
|
+
_super.prototype.nudgeInternal.call(this, +1, 0);
|
|
2227
|
+
};
|
|
2228
|
+
return VerticalRule;
|
|
2229
|
+
}(AbstractCanvasObject));
|
|
2230
|
+
|
|
2231
|
+
/**
|
|
2232
|
+
* Profile with as many features disabled as possible.
|
|
2233
|
+
*/
|
|
2234
|
+
var DefaultCanvasProfile = /** @class */ (function () {
|
|
2235
|
+
function DefaultCanvasProfile() {
|
|
2236
|
+
this.allowMultiSelect = false;
|
|
2237
|
+
this.enterTextEditImmediatelyOnSelect = true;
|
|
2238
|
+
this.allowObjectsToLeaveCanvas = false;
|
|
2239
|
+
this.allowMove = false;
|
|
2240
|
+
this.allowRotate = false;
|
|
2241
|
+
this.allowScale = false;
|
|
2242
|
+
this.defaultFont = "Lato";
|
|
2243
|
+
this.defaultFontSize = 8;
|
|
2244
|
+
this.defaultFontColor = "#000000";
|
|
2245
|
+
this.defaultLineHeight = 1.8;
|
|
2246
|
+
this.defaultCharacterSpacing = 0;
|
|
2247
|
+
this.defaultTextAlignment = "left";
|
|
2248
|
+
this.defaultBorderColor = "#000000";
|
|
2249
|
+
this.defaultBorderWidth = 1;
|
|
2250
|
+
this.defaultCutoffColor = "#000000";
|
|
2251
|
+
this.defaultCutoffWidth = 1;
|
|
2252
|
+
}
|
|
2253
|
+
return DefaultCanvasProfile;
|
|
2254
|
+
}());
|
|
2255
|
+
|
|
2256
|
+
(function (ImageType) {
|
|
2257
|
+
ImageType["DEFAULT"] = "DEFAULT";
|
|
2258
|
+
ImageType["BACKGROUND"] = "BACKGROUND";
|
|
2259
|
+
ImageType["LOGO"] = "LOGO";
|
|
2260
|
+
ImageType["PHOTO"] = "PHOTO";
|
|
2261
|
+
})(exports.ImageType || (exports.ImageType = {}));
|
|
2262
|
+
|
|
2263
|
+
(function (ObjectType) {
|
|
2264
|
+
ObjectType["TEXT"] = "TEXT";
|
|
2265
|
+
ObjectType["BORDER"] = "BORDER";
|
|
2266
|
+
ObjectType["IMAGE"] = "IMAGE";
|
|
2267
|
+
ObjectType["RECTANGLE"] = "RECTANGLE";
|
|
2268
|
+
ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
|
|
2269
|
+
ObjectType["CUTOFF"] = "CUTOFF";
|
|
2270
|
+
ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
|
|
2271
|
+
ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
|
|
2272
|
+
})(exports.ObjectType || (exports.ObjectType = {}));
|
|
2273
|
+
|
|
2274
|
+
var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
2275
|
+
function AbstractInteractiveCanvas(fabric, fabricCanvas, devicePixelRatio) {
|
|
2276
|
+
this.fabric = fabric;
|
|
2277
|
+
this.fabricCanvas = fabricCanvas;
|
|
2278
|
+
this.devicePixelRatio = devicePixelRatio;
|
|
2279
|
+
this.fontLibrary = new FontLibrary();
|
|
2280
|
+
this.dimensionChangeRejections$ = new rxjs.Subject();
|
|
2281
|
+
this.IMAGE_CAPTURE_COEFFICIENT = this.calculateImageCaptureCoefficient();
|
|
2282
|
+
this.baseDimensions = new PixelCanvasDimensions(this.fabricCanvas.width, this.fabricCanvas.height);
|
|
2283
|
+
var baseRestrictions = { width: { min: 1 }, height: { min: 1 } };
|
|
2284
|
+
//Initialize properties
|
|
2285
|
+
this.dimensions$ = new rxjs.BehaviorSubject(this.baseDimensions);
|
|
2286
|
+
this.dimensionRestrictions$ = new rxjs.BehaviorSubject(baseRestrictions);
|
|
2287
|
+
this.zoom$ = new rxjs.BehaviorSubject(1);
|
|
2288
|
+
this.profile$ = new rxjs.BehaviorSubject(new DefaultCanvasProfile());
|
|
2289
|
+
this.layoutManager$ = new rxjs.BehaviorSubject(new AdvancedLayoutManager(this));
|
|
2290
|
+
this.backgroundColor$ = new rxjs.BehaviorSubject(this.fabricCanvas.backgroundColor);
|
|
2291
|
+
this.objects$ = new rxjs.BehaviorSubject([]);
|
|
2292
|
+
this.selection$ = new rxjs.BehaviorSubject(new SelectionData([]));
|
|
2293
|
+
//Configure canvas behaviour
|
|
2294
|
+
this.fabricCanvas.stateful = true;
|
|
2295
|
+
this.fabricCanvas.preserveObjectStacking = true;
|
|
2296
|
+
this.fabricCanvas.perPixelTargetFind = true;
|
|
2297
|
+
this.fabricCanvas.targetFindTolerance = 10;
|
|
2298
|
+
this.setBackgroundColor("#FFFFFF");
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* @override
|
|
2302
|
+
* @inheritDoc
|
|
2303
|
+
*/
|
|
2304
|
+
AbstractInteractiveCanvas.prototype.getFontLibrary = function () {
|
|
2305
|
+
return this.fontLibrary;
|
|
2306
|
+
};
|
|
2307
|
+
/**
|
|
2308
|
+
* @override
|
|
2309
|
+
* @inheritDoc
|
|
2310
|
+
*/
|
|
2311
|
+
AbstractInteractiveCanvas.prototype.getProfile = function () {
|
|
2312
|
+
return this.profile$.value;
|
|
2313
|
+
};
|
|
2314
|
+
/**
|
|
2315
|
+
* @override
|
|
2316
|
+
* @inheritDoc
|
|
2317
|
+
*/
|
|
2318
|
+
AbstractInteractiveCanvas.prototype.getProfile$ = function () {
|
|
2319
|
+
return this.profile$;
|
|
2320
|
+
};
|
|
2321
|
+
/**
|
|
2322
|
+
* @override
|
|
2323
|
+
* @inheritDoc
|
|
2324
|
+
*/
|
|
2325
|
+
AbstractInteractiveCanvas.prototype.setProfile = function (profile) {
|
|
2326
|
+
this.profile$.next(profile);
|
|
2327
|
+
this.onProfileChanged(profile);
|
|
2328
|
+
this.redraw();
|
|
2329
|
+
};
|
|
2330
|
+
/**
|
|
2331
|
+
* @override
|
|
2332
|
+
* @inheritDoc
|
|
2333
|
+
*/
|
|
2334
|
+
AbstractInteractiveCanvas.prototype.getLayoutManager = function () {
|
|
2335
|
+
return this.layoutManager$.value;
|
|
2336
|
+
};
|
|
2337
|
+
/**
|
|
2338
|
+
* @override
|
|
2339
|
+
* @inheritDoc
|
|
2340
|
+
*/
|
|
2341
|
+
AbstractInteractiveCanvas.prototype.getLayoutManager$ = function () {
|
|
2342
|
+
return this.layoutManager$;
|
|
2343
|
+
};
|
|
2344
|
+
/**
|
|
2345
|
+
* @override
|
|
2346
|
+
* @inheritDoc
|
|
2347
|
+
*/
|
|
2348
|
+
AbstractInteractiveCanvas.prototype.setLayoutManager = function (layoutManager) {
|
|
2349
|
+
if (layoutManager === exports.LayoutManager.STANDARD) {
|
|
2350
|
+
this.layoutManager$.next(new StandardLayoutManager(this));
|
|
2351
|
+
}
|
|
2352
|
+
else {
|
|
2353
|
+
this.layoutManager$.next(new AdvancedLayoutManager(this));
|
|
2354
|
+
}
|
|
2355
|
+
this.layoutManager$.value.onInit();
|
|
2356
|
+
};
|
|
2357
|
+
/**
|
|
2358
|
+
* @override
|
|
2359
|
+
* @inheritDoc
|
|
2360
|
+
*/
|
|
2361
|
+
AbstractInteractiveCanvas.prototype.getBackgroundColor = function () {
|
|
2362
|
+
return this.backgroundColor$.value;
|
|
2363
|
+
};
|
|
2364
|
+
/**
|
|
2365
|
+
* @override
|
|
2366
|
+
* @inheritDoc
|
|
2367
|
+
*/
|
|
2368
|
+
AbstractInteractiveCanvas.prototype.getBackgroundColor$ = function () {
|
|
2369
|
+
return this.backgroundColor$;
|
|
2370
|
+
};
|
|
2371
|
+
/**
|
|
2372
|
+
* @override
|
|
2373
|
+
* @inheritDoc
|
|
2374
|
+
*/
|
|
2375
|
+
AbstractInteractiveCanvas.prototype.setBackgroundColor = function (color) {
|
|
2376
|
+
if (color === void 0) { color = "White"; }
|
|
2377
|
+
this.fabricCanvas.setBackgroundColor(color, function () {
|
|
2378
|
+
});
|
|
2379
|
+
this.fabricCanvas.renderAll();
|
|
2380
|
+
this.backgroundColor$.next(color);
|
|
2381
|
+
};
|
|
2382
|
+
/**
|
|
2383
|
+
* @override
|
|
2384
|
+
* @inheritDoc
|
|
2385
|
+
*/
|
|
2386
|
+
AbstractInteractiveCanvas.prototype.getDimensions = function () {
|
|
2387
|
+
return this.dimensions$.value;
|
|
2388
|
+
};
|
|
2389
|
+
/**
|
|
2390
|
+
* @override
|
|
2391
|
+
* @inheritDoc
|
|
2392
|
+
*/
|
|
2393
|
+
AbstractInteractiveCanvas.prototype.getBaseDimensions = function () {
|
|
2394
|
+
return this.baseDimensions;
|
|
2395
|
+
};
|
|
2396
|
+
/**
|
|
2397
|
+
* @override
|
|
2398
|
+
* @inheritDoc
|
|
2399
|
+
*/
|
|
2400
|
+
AbstractInteractiveCanvas.prototype.getDimensions$ = function () {
|
|
2401
|
+
return this.dimensions$;
|
|
2402
|
+
};
|
|
2403
|
+
/**
|
|
2404
|
+
* @override
|
|
2405
|
+
* @inheritDoc
|
|
2406
|
+
*/
|
|
2407
|
+
AbstractInteractiveCanvas.prototype.setDimensions = function (dimensions) {
|
|
2408
|
+
if (this.dimensionsExceedRestrictions(dimensions)) {
|
|
2409
|
+
console.debug("Requested canvas dimensions exceed current restrictions", dimensions, this.dimensionRestrictions$.value);
|
|
2410
|
+
this.dimensionChangeRejections$.next(dimensions);
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
this.updateCanvasDimensions(dimensions, this.zoom$.value);
|
|
2414
|
+
this.dimensions$.next(dimensions);
|
|
2415
|
+
this.onDimensionsChange();
|
|
2416
|
+
this.notifyObjectListChanged();
|
|
2417
|
+
};
|
|
2418
|
+
/**
|
|
2419
|
+
* @override
|
|
2420
|
+
* @inheritDoc
|
|
2421
|
+
*/
|
|
2422
|
+
AbstractInteractiveCanvas.prototype.setBaseDimensions = function (dimensions) {
|
|
2423
|
+
this.baseDimensions = dimensions;
|
|
2424
|
+
this.setDimensions(dimensions);
|
|
2425
|
+
this.notifyObjectListChanged();
|
|
2426
|
+
};
|
|
2427
|
+
/**
|
|
2428
|
+
* @override
|
|
2429
|
+
* @inheritDoc
|
|
2430
|
+
*/
|
|
2431
|
+
AbstractInteractiveCanvas.prototype.getDimensionChangeRejections$ = function () {
|
|
2432
|
+
return this.dimensionChangeRejections$;
|
|
2433
|
+
};
|
|
2434
|
+
/**
|
|
2435
|
+
* @override
|
|
2436
|
+
* @inheritDoc
|
|
2437
|
+
*/
|
|
2438
|
+
AbstractInteractiveCanvas.prototype.getDimensionsRestrictions = function () {
|
|
2439
|
+
return this.dimensionRestrictions$.value;
|
|
2440
|
+
};
|
|
2441
|
+
/**
|
|
2442
|
+
* @override
|
|
2443
|
+
* @inheritDoc
|
|
2444
|
+
*/
|
|
2445
|
+
AbstractInteractiveCanvas.prototype.getDimensionsRestrictions$ = function () {
|
|
2446
|
+
return this.dimensionRestrictions$;
|
|
2447
|
+
};
|
|
2448
|
+
/**
|
|
2449
|
+
* @override
|
|
2450
|
+
* @inheritDoc
|
|
2451
|
+
*/
|
|
2452
|
+
AbstractInteractiveCanvas.prototype.setDimensionRestrictions = function (restrictions) {
|
|
2453
|
+
this.dimensionRestrictions$.next(restrictions);
|
|
2454
|
+
};
|
|
2455
|
+
AbstractInteractiveCanvas.prototype.getMargin = function () {
|
|
2456
|
+
var borderWidth = this.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
2457
|
+
.map(function (border) { return border.getStrokeWidth(); })
|
|
2458
|
+
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2459
|
+
var cutoffWidth = this.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
2460
|
+
.map(function (border) { return border.getStrokeWidth(); })
|
|
2461
|
+
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2462
|
+
// noinspection JSSuspiciousNameCombination
|
|
2463
|
+
return {
|
|
2464
|
+
top: borderWidth,
|
|
2465
|
+
right: borderWidth,
|
|
2466
|
+
bottom: Math.max(cutoffWidth, borderWidth),
|
|
2467
|
+
left: borderWidth
|
|
2468
|
+
};
|
|
2469
|
+
};
|
|
2470
|
+
/**
|
|
2471
|
+
* @override
|
|
2472
|
+
* @inheritDoc
|
|
2473
|
+
*/
|
|
2474
|
+
AbstractInteractiveCanvas.prototype.getZoom = function () {
|
|
2475
|
+
return this.zoom$.value;
|
|
2476
|
+
};
|
|
2477
|
+
/**
|
|
2478
|
+
* @override
|
|
2479
|
+
* @inheritDoc
|
|
2480
|
+
*/
|
|
2481
|
+
AbstractInteractiveCanvas.prototype.getZoom$ = function () {
|
|
2482
|
+
return this.zoom$;
|
|
2483
|
+
};
|
|
2484
|
+
/**
|
|
2485
|
+
* @override
|
|
2486
|
+
* @inheritDoc
|
|
2487
|
+
*/
|
|
2488
|
+
AbstractInteractiveCanvas.prototype.setZoom = function (zoom) {
|
|
2489
|
+
this.updateCanvasDimensions(this.dimensions$.value, zoom);
|
|
2490
|
+
this.zoom$.next(zoom);
|
|
2491
|
+
};
|
|
2492
|
+
/**
|
|
2493
|
+
* @override
|
|
2494
|
+
* @inheritDoc
|
|
2495
|
+
*/
|
|
2496
|
+
AbstractInteractiveCanvas.prototype.getObjects = function () {
|
|
2497
|
+
return this.objects$.value;
|
|
2498
|
+
};
|
|
2499
|
+
/**
|
|
2500
|
+
* Get the list of objects directly.
|
|
2501
|
+
*/
|
|
2502
|
+
AbstractInteractiveCanvas.prototype.getObjectsInternal = function () {
|
|
2503
|
+
return this.objects$.value;
|
|
2504
|
+
};
|
|
2505
|
+
/**
|
|
2506
|
+
* @override
|
|
2507
|
+
* @inheritDoc
|
|
2508
|
+
*/
|
|
2509
|
+
AbstractInteractiveCanvas.prototype.getObjectsByTypeInternal = function (type) {
|
|
2510
|
+
return _(this.getObjectsInternal())
|
|
2511
|
+
.filter(function (object) { return object.getType() === type; })
|
|
2512
|
+
.value();
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* @override
|
|
2516
|
+
* @inheritDoc
|
|
2517
|
+
*/
|
|
2518
|
+
AbstractInteractiveCanvas.prototype.getObjectsByTypesInternal = function () {
|
|
2519
|
+
var types = [];
|
|
2520
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2521
|
+
types[_i] = arguments[_i];
|
|
2522
|
+
}
|
|
2523
|
+
return _(this.getObjectsInternal())
|
|
2524
|
+
.filter(function (object) { return _(types).includes(object.getType()); })
|
|
2525
|
+
.value();
|
|
2526
|
+
};
|
|
2527
|
+
/**
|
|
2528
|
+
* @override
|
|
2529
|
+
* @inheritDoc
|
|
2530
|
+
*/
|
|
2531
|
+
AbstractInteractiveCanvas.prototype.getObjects$ = function () {
|
|
2532
|
+
return this.objects$;
|
|
2533
|
+
};
|
|
2534
|
+
/**
|
|
2535
|
+
* @override
|
|
2536
|
+
* @inheritDoc
|
|
2537
|
+
*/
|
|
2538
|
+
AbstractInteractiveCanvas.prototype.removeObject = function (target) {
|
|
2539
|
+
var concreteObject = this.findFabricObject(target.getId());
|
|
2540
|
+
this.fabricCanvas.remove(concreteObject);
|
|
2541
|
+
this.objects$.next(_(this.objects$.value)
|
|
2542
|
+
.filter(function (object) { return object.getId() !== target.getId(); })
|
|
2543
|
+
.value());
|
|
2544
|
+
this.onObjectListChange();
|
|
2545
|
+
};
|
|
2546
|
+
/**
|
|
2547
|
+
* @override
|
|
2548
|
+
* @inheritDoc
|
|
2549
|
+
*/
|
|
2550
|
+
AbstractInteractiveCanvas.prototype.addImageObject = function (imageUrl) {
|
|
2551
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2552
|
+
var maxSizeScale, maxWidth, options;
|
|
2553
|
+
var _this = this;
|
|
2554
|
+
return __generator(this, function (_a) {
|
|
2555
|
+
switch (_a.label) {
|
|
2556
|
+
case 0:
|
|
2557
|
+
maxSizeScale = 2;
|
|
2558
|
+
maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
|
|
2559
|
+
options = { crossOrigin: "anonymous" };
|
|
2560
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
2561
|
+
_this.fabric.Image.fromURL(imageUrl, function (fabricImage) {
|
|
2562
|
+
var id = _this.randomId();
|
|
2563
|
+
var newScale = 1;
|
|
2564
|
+
var curWidth = newScale * fabricImage.width;
|
|
2565
|
+
if (curWidth > maxWidth) {
|
|
2566
|
+
newScale = maxWidth / curWidth;
|
|
2567
|
+
}
|
|
2568
|
+
fabricImage.set({
|
|
2569
|
+
id: id,
|
|
2570
|
+
scaleX: newScale,
|
|
2571
|
+
scaleY: newScale
|
|
2572
|
+
});
|
|
2573
|
+
_this.fabricCanvas.add(fabricImage);
|
|
2574
|
+
var object = new Image(_this, fabricImage);
|
|
2575
|
+
_this.trackNewObject(object);
|
|
2576
|
+
_this.selectFabricObject(fabricImage);
|
|
2577
|
+
_this.syncObjectList();
|
|
2578
|
+
resolve(object);
|
|
2579
|
+
}, options);
|
|
2580
|
+
})];
|
|
2581
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
2582
|
+
}
|
|
2583
|
+
});
|
|
2584
|
+
});
|
|
2585
|
+
};
|
|
2586
|
+
/**
|
|
2587
|
+
* @override
|
|
2588
|
+
* @inheritDoc
|
|
2589
|
+
*/
|
|
2590
|
+
AbstractInteractiveCanvas.prototype.addTextObject = function () {
|
|
2591
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2592
|
+
var profile, id, fontSizePx, canvasWidthPx, lowestTextPointPx, topPx, textOptions, fabricTextbox, object;
|
|
2593
|
+
return __generator(this, function (_a) {
|
|
2594
|
+
profile = this.profile$.value;
|
|
2595
|
+
id = this.randomId();
|
|
2596
|
+
fontSizePx = profile.defaultFontSize;
|
|
2597
|
+
canvasWidthPx = this.getDimensions().widthPx;
|
|
2598
|
+
lowestTextPointPx = this.getLowestTextPoint();
|
|
2599
|
+
topPx = Math.min(lowestTextPointPx, this.getDimensions().heightPx - fontSizePx);
|
|
2600
|
+
textOptions = {
|
|
2601
|
+
id: id,
|
|
2602
|
+
top: topPx,
|
|
2603
|
+
left: 5,
|
|
2604
|
+
width: canvasWidthPx - 10,
|
|
2605
|
+
fill: profile.defaultFontColor,
|
|
2606
|
+
fontSize: fontSizePx,
|
|
2607
|
+
fontFamily: profile.defaultFont,
|
|
2608
|
+
textAlign: profile.defaultTextAlignment,
|
|
2609
|
+
multiLine: true,
|
|
2610
|
+
lineHeight: profile.defaultLineHeight,
|
|
2611
|
+
charSpacing: profile.defaultCharacterSpacing
|
|
2612
|
+
};
|
|
2613
|
+
fabricTextbox = new this.fabric.Textbox("Text goes here", textOptions);
|
|
2614
|
+
this.fabricCanvas.add(fabricTextbox);
|
|
2615
|
+
object = new Text(this, fabricTextbox);
|
|
2616
|
+
this.trackNewObject(object);
|
|
2617
|
+
this.selectFabricObject(fabricTextbox);
|
|
2618
|
+
this.syncObjectList();
|
|
2619
|
+
return [2 /*return*/, object];
|
|
2620
|
+
});
|
|
2621
|
+
});
|
|
2622
|
+
};
|
|
2623
|
+
/**
|
|
2624
|
+
* @override
|
|
2625
|
+
* @inheritDoc
|
|
2626
|
+
*/
|
|
2627
|
+
AbstractInteractiveCanvas.prototype.addRectangleObject = function () {
|
|
2628
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2629
|
+
var canvasWidth, canvasHeight, rectWidth, rectHeight, rectangleOptions, fabricRect, object;
|
|
2630
|
+
return __generator(this, function (_a) {
|
|
2631
|
+
canvasWidth = this.getDimensions().widthPx;
|
|
2632
|
+
canvasHeight = this.getDimensions().heightPx;
|
|
2633
|
+
rectWidth = canvasWidth / 2;
|
|
2634
|
+
rectHeight = canvasHeight / 2;
|
|
2635
|
+
rectangleOptions = {
|
|
2636
|
+
id: this.randomId(),
|
|
2637
|
+
width: canvasWidth / 2,
|
|
2638
|
+
height: 2,
|
|
2639
|
+
top: canvasHeight / 2 - rectHeight / 2,
|
|
2640
|
+
left: canvasWidth / 2 - rectWidth / 2,
|
|
2641
|
+
fill: "#000000"
|
|
2642
|
+
};
|
|
2643
|
+
fabricRect = new this.fabric.Rect(rectangleOptions);
|
|
2644
|
+
this.fabricCanvas.add(fabricRect);
|
|
2645
|
+
object = new Rectangle(this, fabricRect);
|
|
2646
|
+
this.trackNewObject(object);
|
|
2647
|
+
this.selectFabricObject(fabricRect);
|
|
2648
|
+
this.syncObjectList();
|
|
2649
|
+
return [2 /*return*/, object];
|
|
2650
|
+
});
|
|
2651
|
+
});
|
|
2652
|
+
};
|
|
2653
|
+
/**
|
|
2654
|
+
* @override
|
|
2655
|
+
* @inheritDoc
|
|
2656
|
+
*/
|
|
2657
|
+
AbstractInteractiveCanvas.prototype.addCutoffObject = function () {
|
|
2658
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2659
|
+
var profile, initialThickness, canvasWidth, canvasHeight, rectangleOptions, fabricRect, object;
|
|
2660
|
+
return __generator(this, function (_a) {
|
|
2661
|
+
profile = this.profile$.value;
|
|
2662
|
+
initialThickness = profile.defaultCutoffWidth;
|
|
2663
|
+
canvasWidth = this.getDimensions().widthPx;
|
|
2664
|
+
canvasHeight = this.getDimensions().heightPx;
|
|
2665
|
+
rectangleOptions = {
|
|
2666
|
+
id: this.randomId(),
|
|
2667
|
+
width: canvasWidth,
|
|
2668
|
+
height: initialThickness,
|
|
2669
|
+
top: canvasHeight - initialThickness,
|
|
2670
|
+
left: 0,
|
|
2671
|
+
fill: profile.defaultCutoffColor
|
|
2672
|
+
};
|
|
2673
|
+
fabricRect = new this.fabric.Rect(rectangleOptions);
|
|
2674
|
+
this.fabricCanvas.add(fabricRect);
|
|
2675
|
+
object = new Cutoff(this, fabricRect);
|
|
2676
|
+
this.trackNewObject(object);
|
|
2677
|
+
this.selectFabricObject(fabricRect);
|
|
2678
|
+
this.syncObjectList();
|
|
2679
|
+
return [2 /*return*/, object];
|
|
2680
|
+
});
|
|
2681
|
+
});
|
|
2682
|
+
};
|
|
2683
|
+
/**
|
|
2684
|
+
* @override
|
|
2685
|
+
* @inheritDoc
|
|
2686
|
+
*/
|
|
2687
|
+
AbstractInteractiveCanvas.prototype.addBorderObject = function () {
|
|
2688
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2689
|
+
var profile, initialThickness, rectangleOptions, fabricRect, object;
|
|
2690
|
+
return __generator(this, function (_a) {
|
|
2691
|
+
profile = this.profile$.value;
|
|
2692
|
+
initialThickness = profile.defaultBorderWidth;
|
|
2693
|
+
rectangleOptions = {
|
|
2694
|
+
id: this.randomId(),
|
|
2695
|
+
fill: null,
|
|
2696
|
+
stroke: profile.defaultBorderColor,
|
|
2697
|
+
strokeWidth: initialThickness
|
|
2698
|
+
};
|
|
2699
|
+
fabricRect = new this.fabric.Rect(rectangleOptions);
|
|
2700
|
+
this.fabricCanvas.add(fabricRect);
|
|
2701
|
+
object = new Border(this, fabricRect);
|
|
2702
|
+
this.trackNewObject(object);
|
|
2703
|
+
this.selectFabricObject(fabricRect);
|
|
2704
|
+
this.syncObjectList();
|
|
2705
|
+
return [2 /*return*/, object];
|
|
2706
|
+
});
|
|
2707
|
+
});
|
|
2708
|
+
};
|
|
2709
|
+
/**
|
|
2710
|
+
* @override
|
|
2711
|
+
* @inheritDoc
|
|
2712
|
+
*/
|
|
2713
|
+
AbstractInteractiveCanvas.prototype.addVerticalRuleObject = function () {
|
|
2714
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2715
|
+
var rectOptions, fabricRect, object;
|
|
2716
|
+
return __generator(this, function (_a) {
|
|
2717
|
+
rectOptions = {
|
|
2718
|
+
id: this.randomId(),
|
|
2719
|
+
width: 2,
|
|
2720
|
+
height: 10,
|
|
2721
|
+
top: 0,
|
|
2722
|
+
left: 0,
|
|
2723
|
+
fill: "#000000"
|
|
2724
|
+
};
|
|
2725
|
+
fabricRect = new this.fabric.Rect(rectOptions);
|
|
2726
|
+
this.fabricCanvas.add(fabricRect);
|
|
2727
|
+
object = new VerticalRule(this, fabricRect);
|
|
2728
|
+
this.trackNewObject(object);
|
|
2729
|
+
this.selectFabricObject(fabricRect);
|
|
2730
|
+
this.syncObjectList();
|
|
2731
|
+
return [2 /*return*/, object];
|
|
2732
|
+
});
|
|
2733
|
+
});
|
|
2734
|
+
};
|
|
2735
|
+
/**
|
|
2736
|
+
* @override
|
|
2737
|
+
* @inheritDoc
|
|
2738
|
+
*/
|
|
2739
|
+
AbstractInteractiveCanvas.prototype.addHorizontalRuleObject = function () {
|
|
2740
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2741
|
+
var rectOptions, fabricRect, object;
|
|
2742
|
+
return __generator(this, function (_a) {
|
|
2743
|
+
rectOptions = {
|
|
2744
|
+
id: this.randomId(),
|
|
2745
|
+
width: 10,
|
|
2746
|
+
height: 2,
|
|
2747
|
+
top: 0,
|
|
2748
|
+
left: 0,
|
|
2749
|
+
fill: "#000000"
|
|
2750
|
+
};
|
|
2751
|
+
fabricRect = new this.fabric.Rect(rectOptions);
|
|
2752
|
+
this.fabricCanvas.add(fabricRect);
|
|
2753
|
+
object = new HorizontalRule(this, fabricRect);
|
|
2754
|
+
this.trackNewObject(object);
|
|
2755
|
+
this.selectFabricObject(fabricRect);
|
|
2756
|
+
this.syncObjectList();
|
|
2757
|
+
return [2 /*return*/, object];
|
|
2758
|
+
});
|
|
2759
|
+
});
|
|
2760
|
+
};
|
|
2761
|
+
/**
|
|
2762
|
+
* @override
|
|
2763
|
+
* @inheritDoc
|
|
2764
|
+
*/
|
|
2765
|
+
AbstractInteractiveCanvas.prototype.setPrefillData = function (data) {
|
|
2766
|
+
_(this.getObjectsByTypeInternal(exports.ObjectType.TEXT)).each(function (object) {
|
|
2767
|
+
var prefillType = object.getPrefillType();
|
|
2768
|
+
if (prefillType !== null) {
|
|
2769
|
+
object.setText(data[prefillType] || "");
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
};
|
|
2773
|
+
/**
|
|
2774
|
+
* @override
|
|
2775
|
+
* @inheritDoc
|
|
2776
|
+
*/
|
|
2777
|
+
AbstractInteractiveCanvas.prototype.distributeObjectsVertically = function () {
|
|
2778
|
+
var margin = this.getMargin();
|
|
2779
|
+
var canvasHeight = this.getDimensions().heightPx;
|
|
2780
|
+
var objectsToLayout = _(this.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.IMAGE))
|
|
2781
|
+
.sortBy(function (x) { return x.getBoundingBox().top; })
|
|
2782
|
+
.value();
|
|
2783
|
+
var objectsHeight = _.reduce(objectsToLayout, function (total, element) { return total + element.getBoundingBox().height; }, 0);
|
|
2784
|
+
var workableHeight = canvasHeight - margin.top - margin.bottom;
|
|
2785
|
+
var requiredPadding = workableHeight - objectsHeight;
|
|
2786
|
+
var spaceBetween = requiredPadding / (objectsToLayout.length - 1);
|
|
2787
|
+
var nextElementTop = margin.top;
|
|
2788
|
+
for (var _i = 0, objectsToLayout_1 = objectsToLayout; _i < objectsToLayout_1.length; _i++) {
|
|
2789
|
+
var element = objectsToLayout_1[_i];
|
|
2790
|
+
var elementHeight = element.getBoundingBox().height;
|
|
2791
|
+
element.setPosition({
|
|
2792
|
+
top: nextElementTop
|
|
2793
|
+
});
|
|
2794
|
+
element.setCoords();
|
|
2795
|
+
nextElementTop += elementHeight + spaceBetween;
|
|
2796
|
+
}
|
|
2797
|
+
this.redraw();
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* @override
|
|
2801
|
+
* @inheritDoc
|
|
2802
|
+
*/
|
|
2803
|
+
AbstractInteractiveCanvas.prototype.getSelection = function () {
|
|
2804
|
+
return this.selection$.value;
|
|
2805
|
+
};
|
|
2806
|
+
/**
|
|
2807
|
+
* @override
|
|
2808
|
+
* @inheritDoc
|
|
2809
|
+
*/
|
|
2810
|
+
AbstractInteractiveCanvas.prototype.getSelection$ = function () {
|
|
2811
|
+
return this.selection$;
|
|
2812
|
+
};
|
|
2813
|
+
/**
|
|
2814
|
+
* @override
|
|
2815
|
+
* @inheritDoc
|
|
2816
|
+
*/
|
|
2817
|
+
AbstractInteractiveCanvas.prototype.select = function (object) {
|
|
2818
|
+
var concreteField = this.findObject(object.getId());
|
|
2819
|
+
if (!concreteField) {
|
|
2820
|
+
console.error("Attempted to select unknown object", object);
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
this.selectFabricObject(concreteField.getFabricObjectInternal());
|
|
2824
|
+
this.fabricCanvas.renderAll();
|
|
2825
|
+
};
|
|
2826
|
+
/**
|
|
2827
|
+
* @override
|
|
2828
|
+
* @inheritDoc
|
|
2829
|
+
*/
|
|
2830
|
+
AbstractInteractiveCanvas.prototype.clearSelection = function () {
|
|
2831
|
+
this.fabricCanvas.discardActiveObject();
|
|
2832
|
+
this.fabricCanvas.renderAll();
|
|
2833
|
+
};
|
|
2834
|
+
AbstractInteractiveCanvas.prototype.setMultiSelect = function (value) {
|
|
2835
|
+
this.fabricCanvas.selection = value;
|
|
2836
|
+
this.fabricCanvas.selectionKey = value ? "shiftKey" : null;
|
|
2837
|
+
};
|
|
2838
|
+
/**
|
|
2839
|
+
* @override
|
|
2840
|
+
* @inheritDoc
|
|
2841
|
+
*/
|
|
2842
|
+
AbstractInteractiveCanvas.prototype.clear = function () {
|
|
2843
|
+
this.fabricCanvas.clear();
|
|
2844
|
+
this.setBackgroundColor("#FFFFFF");
|
|
2845
|
+
this.objects$.next([]);
|
|
2846
|
+
};
|
|
2847
|
+
/**
|
|
2848
|
+
* @override
|
|
2849
|
+
* @inheritDoc
|
|
2850
|
+
*/
|
|
2851
|
+
AbstractInteractiveCanvas.prototype.save = function () {
|
|
2852
|
+
var objects = _(this.objects$.value)
|
|
2853
|
+
.map(function (x) { return x.persist(); })
|
|
2854
|
+
.value();
|
|
2855
|
+
var includedProperties = ["id"];
|
|
2856
|
+
var json = this.fabricCanvas.toJSON(includedProperties);
|
|
2857
|
+
var state = {
|
|
2858
|
+
dimensions: this.dimensions$.value,
|
|
2859
|
+
canvasJson: JSON.stringify(json),
|
|
2860
|
+
objects: objects,
|
|
2861
|
+
backgroundColor: this.backgroundColor$.value
|
|
2862
|
+
};
|
|
2863
|
+
console.debug("Saving canvas state", state);
|
|
2864
|
+
return state;
|
|
2865
|
+
};
|
|
2866
|
+
/**
|
|
2867
|
+
* @override
|
|
2868
|
+
* @inheritDoc
|
|
2869
|
+
*/
|
|
2870
|
+
AbstractInteractiveCanvas.prototype.load = function (canvasState) {
|
|
2871
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2872
|
+
var json_1;
|
|
2873
|
+
var _this = this;
|
|
2874
|
+
return __generator(this, function (_a) {
|
|
2875
|
+
switch (_a.label) {
|
|
2876
|
+
case 0:
|
|
2877
|
+
console.debug("Loading canvas state", canvasState);
|
|
2878
|
+
this.setBaseDimensions(canvasState.dimensions);
|
|
2879
|
+
if (!(canvasState.canvasJson != undefined)) return [3 /*break*/, 2];
|
|
2880
|
+
json_1 = JSON.parse(canvasState.canvasJson);
|
|
2881
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
2882
|
+
_this.fabricCanvas.loadFromJSON(json_1, function () { return resolve(); });
|
|
2883
|
+
})];
|
|
2884
|
+
case 1:
|
|
2885
|
+
_a.sent();
|
|
2886
|
+
_a.label = 2;
|
|
2887
|
+
case 2:
|
|
2888
|
+
this.setBackgroundColor(canvasState.backgroundColor);
|
|
2889
|
+
this.bindFields(canvasState.objects);
|
|
2890
|
+
this.removePersistedBullets();
|
|
2891
|
+
this.layoutManager$.value.onInit();
|
|
2892
|
+
return [2 /*return*/];
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
});
|
|
2896
|
+
};
|
|
2897
|
+
/**
|
|
2898
|
+
* Another hack for bullet points... because they use canvas objects to render the bullets, they get saved when the canvas is persisted... and then loaded into a new canvas, but there's
|
|
2899
|
+
* nothing linking them to the field that needs bullets, so they end up duplicating every time the canvas is saved/loaded. Since we don't use circles for anything else, this just
|
|
2900
|
+
* deletes all circles on canvas load.
|
|
2901
|
+
*/
|
|
2902
|
+
AbstractInteractiveCanvas.prototype.removePersistedBullets = function () {
|
|
2903
|
+
var _this = this;
|
|
2904
|
+
var objects = this.fabricCanvas.getObjects();
|
|
2905
|
+
_.each(objects, function (object) {
|
|
2906
|
+
if (object.type === "circle")
|
|
2907
|
+
_this.removeFabricObject(object);
|
|
2908
|
+
});
|
|
2909
|
+
};
|
|
2910
|
+
/**
|
|
2911
|
+
* @override
|
|
2912
|
+
* @inheritDoc
|
|
2913
|
+
*/
|
|
2914
|
+
AbstractInteractiveCanvas.prototype.toSvg = function () {
|
|
2915
|
+
var _this = this;
|
|
2916
|
+
var widthInMm = _.round(this.dimensions$.value.widthMm, 1) + "mm";
|
|
2917
|
+
var heightInMm = _.round(this.dimensions$.value.heightMm, 1) + "mm";
|
|
2918
|
+
var options = {
|
|
2919
|
+
width: widthInMm,
|
|
2920
|
+
height: heightInMm,
|
|
2921
|
+
suppressPreamble: true,
|
|
2922
|
+
encoding: null
|
|
2923
|
+
};
|
|
2924
|
+
return this.executeWithNormalizedCanvas(function () { return _this.fabricCanvas.toSVG(options); });
|
|
2925
|
+
};
|
|
2926
|
+
/**
|
|
2927
|
+
* @override
|
|
2928
|
+
* @inheritDoc
|
|
2929
|
+
*/
|
|
2930
|
+
AbstractInteractiveCanvas.prototype.toImage = function () {
|
|
2931
|
+
var _this = this;
|
|
2932
|
+
var options = {
|
|
2933
|
+
format: "png",
|
|
2934
|
+
multiplier: this.IMAGE_CAPTURE_COEFFICIENT,
|
|
2935
|
+
enableRetinaScaling: true
|
|
2936
|
+
};
|
|
2937
|
+
console.debug("Capturing canvas image", options);
|
|
2938
|
+
var base64 = this.executeWithNormalizedCanvas(function () { return _this.fabricCanvas.toDataURL(options); });
|
|
2939
|
+
return _.replace(base64, /^data:.*;base64,/, "");
|
|
2940
|
+
};
|
|
2941
|
+
/**
|
|
2942
|
+
* @override
|
|
2943
|
+
* @inheritDoc
|
|
2944
|
+
*/
|
|
2945
|
+
AbstractInteractiveCanvas.prototype.createPNGStream = function () {
|
|
2946
|
+
return this.fabricCanvas.createPNGStream();
|
|
2947
|
+
};
|
|
2948
|
+
/**
|
|
2949
|
+
* Redraw the canvas.
|
|
2950
|
+
*/
|
|
2951
|
+
AbstractInteractiveCanvas.prototype.redraw = function () {
|
|
2952
|
+
this.fabricCanvas.renderAll();
|
|
2953
|
+
};
|
|
2954
|
+
AbstractInteractiveCanvas.prototype.syncObjectList = function () {
|
|
2955
|
+
var _this = this;
|
|
2956
|
+
var newObjectList = _(this.fabricCanvas.getObjects())
|
|
2957
|
+
.map(function (obj) { return _this.findObject(obj.id); })
|
|
2958
|
+
.filter(function (x) { return x !== undefined; })
|
|
2959
|
+
.value();
|
|
2960
|
+
this.objects$.next(newObjectList);
|
|
2961
|
+
this.onObjectListChange();
|
|
2962
|
+
};
|
|
2963
|
+
/**
|
|
2964
|
+
* @override
|
|
2965
|
+
* @inheritDoc
|
|
2966
|
+
*/
|
|
2967
|
+
AbstractInteractiveCanvas.prototype.notifyObjectListChanged = function () {
|
|
2968
|
+
this.onObjectListChange();
|
|
2969
|
+
};
|
|
2970
|
+
/**
|
|
2971
|
+
* @override
|
|
2972
|
+
* @inheritDoc
|
|
2973
|
+
*/
|
|
2974
|
+
AbstractInteractiveCanvas.prototype.notifyTextChanged = function () {
|
|
2975
|
+
this.onTextChange();
|
|
2976
|
+
};
|
|
2977
|
+
/**
|
|
2978
|
+
* @override
|
|
2979
|
+
* @inheritDoc
|
|
2980
|
+
*/
|
|
2981
|
+
AbstractInteractiveCanvas.prototype.notifyMarginChanged = function () {
|
|
2982
|
+
this.onMarginChange();
|
|
2983
|
+
};
|
|
2984
|
+
AbstractInteractiveCanvas.prototype.removeFabricObject = function (obj) {
|
|
2985
|
+
this.fabricCanvas.remove(obj);
|
|
2986
|
+
};
|
|
2987
|
+
AbstractInteractiveCanvas.prototype.selectFabricObject = function (object) {
|
|
2988
|
+
this.fabricCanvas.setActiveObject(object);
|
|
2989
|
+
};
|
|
2990
|
+
AbstractInteractiveCanvas.prototype.onTextChange = function () {
|
|
2991
|
+
this.layoutManager$.value.onTextChange();
|
|
2992
|
+
};
|
|
2993
|
+
AbstractInteractiveCanvas.prototype.onObjectListChange = function () {
|
|
2994
|
+
this.layoutManager$.value.onObjectListChange();
|
|
2995
|
+
};
|
|
2996
|
+
AbstractInteractiveCanvas.prototype.onDimensionsChange = function () {
|
|
2997
|
+
this.layoutManager$.value.onCanvasDimensionsChange();
|
|
2998
|
+
};
|
|
2999
|
+
AbstractInteractiveCanvas.prototype.onMarginChange = function () {
|
|
3000
|
+
this.layoutManager$.value.onMarginChange();
|
|
3001
|
+
};
|
|
3002
|
+
AbstractInteractiveCanvas.prototype.bindFields = function (persistedFields) {
|
|
3003
|
+
var _this = this;
|
|
3004
|
+
console.debug("Binding fields", persistedFields);
|
|
3005
|
+
var bound = _(persistedFields)
|
|
3006
|
+
.flatMap(function (field) {
|
|
3007
|
+
try {
|
|
3008
|
+
return [_this.bindField(field)];
|
|
3009
|
+
}
|
|
3010
|
+
catch (e) {
|
|
3011
|
+
console.error("Could not bind field", e, field);
|
|
3012
|
+
return []; //skip
|
|
3013
|
+
}
|
|
3014
|
+
})
|
|
3015
|
+
.value();
|
|
3016
|
+
console.debug("Bound fields", bound);
|
|
3017
|
+
this.objects$.next(bound);
|
|
3018
|
+
};
|
|
3019
|
+
AbstractInteractiveCanvas.prototype.bindField = function (persistedField) {
|
|
3020
|
+
console.debug("Binding field", persistedField);
|
|
3021
|
+
var fabricObject = this.findFabricObject(persistedField.id);
|
|
3022
|
+
switch (persistedField.type) {
|
|
3023
|
+
case exports.ObjectType.TEXT:
|
|
3024
|
+
return new Text(this, fabricObject, persistedField);
|
|
3025
|
+
case exports.ObjectType.RECTANGLE:
|
|
3026
|
+
return new Rectangle(this, fabricObject, persistedField);
|
|
3027
|
+
case exports.ObjectType.BORDER:
|
|
3028
|
+
return new Border(this, fabricObject, persistedField);
|
|
3029
|
+
case exports.ObjectType.CUTOFF:
|
|
3030
|
+
return new Cutoff(this, fabricObject, persistedField);
|
|
3031
|
+
case exports.ObjectType.IMAGE:
|
|
3032
|
+
case exports.ObjectType.LIBRARY_IMAGE:
|
|
3033
|
+
return new Image(this, fabricObject, persistedField);
|
|
3034
|
+
case exports.ObjectType.HORIZONTAL_RULE:
|
|
3035
|
+
return new HorizontalRule(this, fabricObject, persistedField);
|
|
3036
|
+
case exports.ObjectType.VERTICAL_RULE:
|
|
3037
|
+
return new VerticalRule(this, fabricObject, persistedField);
|
|
3038
|
+
default:
|
|
3039
|
+
throw new Error("Unknown field type: [" + persistedField.type + "]");
|
|
3040
|
+
}
|
|
3041
|
+
};
|
|
3042
|
+
AbstractInteractiveCanvas.prototype.findFabricObject = function (id) {
|
|
3043
|
+
var objects = this.fabricCanvas.getObjects();
|
|
3044
|
+
var fabricObject = _.find(objects, function (o) { return o.id == id; });
|
|
3045
|
+
if (!fabricObject) {
|
|
3046
|
+
throw new Error("Cannot find fabric object with id [" + id + "]");
|
|
3047
|
+
}
|
|
3048
|
+
return fabricObject;
|
|
3049
|
+
};
|
|
3050
|
+
AbstractInteractiveCanvas.prototype.findObject = function (id) {
|
|
3051
|
+
//Don't use strict compare here. fabric ids are numbers while ad builder ids are strings... mostly.
|
|
3052
|
+
return _.find(this.objects$.value, function (object) { return object.getId() == id; });
|
|
3053
|
+
};
|
|
3054
|
+
/**
|
|
3055
|
+
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
3056
|
+
* the previous values.
|
|
3057
|
+
* @param func Function to execute.
|
|
3058
|
+
*/
|
|
3059
|
+
AbstractInteractiveCanvas.prototype.executeWithNormalizedCanvas = function (func) {
|
|
3060
|
+
this.updateCanvasDimensions(this.dimensions$.value, 1);
|
|
3061
|
+
var response;
|
|
3062
|
+
try {
|
|
3063
|
+
response = func();
|
|
3064
|
+
}
|
|
3065
|
+
finally {
|
|
3066
|
+
this.updateCanvasDimensions(this.dimensions$.value, this.zoom$.value);
|
|
3067
|
+
}
|
|
3068
|
+
return response;
|
|
3069
|
+
};
|
|
3070
|
+
/**
|
|
3071
|
+
* Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
|
|
3072
|
+
*/
|
|
3073
|
+
AbstractInteractiveCanvas.prototype.updateCanvasDimensions = function (dims, zoom) {
|
|
3074
|
+
var width = dims.widthPx * zoom;
|
|
3075
|
+
var height = dims.heightPx * zoom;
|
|
3076
|
+
console.debug("Updating canvas dimensions: zoom: " + zoom + ", width: " + width + ", height: " + height);
|
|
3077
|
+
this.fabricCanvas.setZoom(zoom);
|
|
3078
|
+
this.fabricCanvas.setDimensions({
|
|
3079
|
+
width: width,
|
|
3080
|
+
height: height
|
|
3081
|
+
});
|
|
3082
|
+
};
|
|
3083
|
+
AbstractInteractiveCanvas.prototype.onProfileChanged = function (profile) {
|
|
3084
|
+
this.setMultiSelect(profile.allowMultiSelect);
|
|
3085
|
+
this.layoutManager$.value.onProfileChange(profile);
|
|
3086
|
+
console.debug("Canvas profile set", profile);
|
|
3087
|
+
};
|
|
3088
|
+
AbstractInteractiveCanvas.prototype.getFieldByCanvasObject = function (object) {
|
|
3089
|
+
if (!object) {
|
|
3090
|
+
return null;
|
|
3091
|
+
}
|
|
3092
|
+
return _.find(this.objects$.value, function (field) { return field.getId() == object.id; });
|
|
3093
|
+
};
|
|
3094
|
+
AbstractInteractiveCanvas.prototype.getFieldsByCanvasObject = function (objects) {
|
|
3095
|
+
var _this = this;
|
|
3096
|
+
return _(objects)
|
|
3097
|
+
.map(function (obj) { return _this.getFieldByCanvasObject(obj); })
|
|
3098
|
+
.reject(function (x) { return !x; })
|
|
3099
|
+
.value();
|
|
3100
|
+
};
|
|
3101
|
+
AbstractInteractiveCanvas.prototype.calculateImageCaptureCoefficient = function () {
|
|
3102
|
+
var precision = 3;
|
|
3103
|
+
var devicePixelRatio = this.devicePixelRatio || 1;
|
|
3104
|
+
return _.round(2 / devicePixelRatio, precision);
|
|
3105
|
+
};
|
|
3106
|
+
AbstractInteractiveCanvas.prototype.randomId = function () {
|
|
3107
|
+
var min = 0;
|
|
3108
|
+
var max = 999;
|
|
3109
|
+
var id = Math.floor(Math.random() * (max - min)) + min;
|
|
3110
|
+
return (new Date()).getTime() + "" + id;
|
|
3111
|
+
};
|
|
3112
|
+
AbstractInteractiveCanvas.prototype.getLowestTextPoint = function () {
|
|
3113
|
+
return _(this.objects$.value)
|
|
3114
|
+
.filter(function (object) { return object.getType() === exports.ObjectType.TEXT; })
|
|
3115
|
+
.map(function (text) { return text.getDimensions().top.px + text.getDimensions().height.px; })
|
|
3116
|
+
.reduce(function (x, y) { return Math.max(x, y); }, 0);
|
|
3117
|
+
};
|
|
3118
|
+
AbstractInteractiveCanvas.prototype.trackNewObject = function (object) {
|
|
3119
|
+
this.objects$.next(__spreadArrays(this.objects$.value, [object]));
|
|
3120
|
+
};
|
|
3121
|
+
AbstractInteractiveCanvas.prototype.dimensionsExceedRestrictions = function (dimensions) {
|
|
3122
|
+
var restrictions = this.dimensionRestrictions$.value;
|
|
3123
|
+
return tsOptchain.oc(restrictions).height.min() != undefined && dimensions.height < tsOptchain.oc(restrictions).height.min()
|
|
3124
|
+
|| tsOptchain.oc(restrictions).height.max() != undefined && dimensions.height > tsOptchain.oc(restrictions).height.max()
|
|
3125
|
+
|| tsOptchain.oc(restrictions).width.min() != undefined && dimensions.width < tsOptchain.oc(restrictions).width.min()
|
|
3126
|
+
|| tsOptchain.oc(restrictions).width.max() != undefined && dimensions.width > tsOptchain.oc(restrictions).width.max()
|
|
3127
|
+
|| tsOptchain.oc(restrictions).volume.min() != undefined && dimensions.height * dimensions.width < tsOptchain.oc(restrictions).volume.min()
|
|
3128
|
+
|| tsOptchain.oc(restrictions).volume.max() != undefined && dimensions.height * dimensions.width > tsOptchain.oc(restrictions).volume.max();
|
|
3129
|
+
};
|
|
3130
|
+
return AbstractInteractiveCanvas;
|
|
3131
|
+
}());
|
|
3132
|
+
var SelectionData = /** @class */ (function () {
|
|
3133
|
+
function SelectionData(objects) {
|
|
3134
|
+
this.objects = objects;
|
|
3135
|
+
this.empty = this.objects.length < 1;
|
|
3136
|
+
var selectedObject = this.objects[0];
|
|
3137
|
+
this.isText = selectedObject
|
|
3138
|
+
&& selectedObject.getType() === exports.ObjectType.TEXT
|
|
3139
|
+
&& selectedObject.isEditing();
|
|
3140
|
+
}
|
|
3141
|
+
return SelectionData;
|
|
3142
|
+
}());
|
|
3143
|
+
|
|
3144
|
+
var HeadlessInteractiveCanvas = /** @class */ (function (_super) {
|
|
3145
|
+
__extends(HeadlessInteractiveCanvas, _super);
|
|
3146
|
+
function HeadlessInteractiveCanvas() {
|
|
3147
|
+
return _super.call(this, fabric.fabric, new fabric.fabric.StaticCanvas(null, { width: 640, height: 480 }), null) || this;
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
* @override
|
|
3151
|
+
*/
|
|
3152
|
+
HeadlessInteractiveCanvas.prototype.selectFabricObject = function (object) {
|
|
3153
|
+
//no-op
|
|
3154
|
+
};
|
|
3155
|
+
return HeadlessInteractiveCanvas;
|
|
3156
|
+
}(AbstractInteractiveCanvas));
|
|
3157
|
+
|
|
3158
|
+
var InteractiveCanvas = /** @class */ (function (_super) {
|
|
3159
|
+
__extends(InteractiveCanvas, _super);
|
|
3160
|
+
function InteractiveCanvas(elementId, devicePixelRatio) {
|
|
3161
|
+
var _this = _super.call(this, window['fabric'], new window['fabric'].Canvas(elementId), devicePixelRatio) || this;
|
|
3162
|
+
_this.devicePixelRatio = devicePixelRatio;
|
|
3163
|
+
//Initialize watchers
|
|
3164
|
+
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3165
|
+
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
3166
|
+
_this.fabricCanvas.on("selection:cleared", function () { return _this.onFabricSelectionChanged(); });
|
|
3167
|
+
_this.fabricCanvas.on("text:editing:entered", function () { return _this.onTextEditing(); });
|
|
3168
|
+
_this.fabricCanvas.on("text:editing:exited", function () { return _this.onTextEditing(); });
|
|
3169
|
+
_this.fabricCanvas.on("text:changed", function () { return _this.onTextChange(); });
|
|
3170
|
+
return _this;
|
|
3171
|
+
}
|
|
3172
|
+
InteractiveCanvas.prototype.onFabricSelectionChanged = function () {
|
|
3173
|
+
var selected = this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());
|
|
3174
|
+
console.debug("Selection changed", selected);
|
|
3175
|
+
this.selection$.next(new SelectionData(selected));
|
|
3176
|
+
this.enterTextSelectionModeIfRequired();
|
|
3177
|
+
};
|
|
3178
|
+
InteractiveCanvas.prototype.enterTextSelectionModeIfRequired = function () {
|
|
3179
|
+
if (!this.profile$.value.enterTextEditImmediatelyOnSelect && !this.layoutManager$.value.enterTextEditImmediatelyOnSelect)
|
|
3180
|
+
return;
|
|
3181
|
+
if (!this.selection$.value || !this.selection$.value.objects[0] || this.selection$.value.objects[0].getType() !== exports.ObjectType.TEXT)
|
|
3182
|
+
return;
|
|
3183
|
+
var text = this.selection$.value.objects[0];
|
|
3184
|
+
text.enterEditing();
|
|
3185
|
+
};
|
|
3186
|
+
InteractiveCanvas.prototype.onTextEditing = function () {
|
|
3187
|
+
var selected = this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());
|
|
3188
|
+
this.selection$.next(new SelectionData(selected));
|
|
3189
|
+
};
|
|
3190
|
+
return InteractiveCanvas;
|
|
3191
|
+
}(AbstractInteractiveCanvas));
|
|
3192
|
+
|
|
3193
|
+
exports.AbstractCanvasObject = AbstractCanvasObject;
|
|
3194
|
+
exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
|
|
3195
|
+
exports.AbstractLayoutManager = AbstractLayoutManager;
|
|
3196
|
+
exports.AdvancedLayoutManager = AdvancedLayoutManager;
|
|
3197
|
+
exports.Border = Border;
|
|
3198
|
+
exports.CanvasObjectData = CanvasObjectData;
|
|
3199
|
+
exports.Cutoff = Cutoff;
|
|
3200
|
+
exports.DefaultCanvasProfile = DefaultCanvasProfile;
|
|
3201
|
+
exports.Font = Font;
|
|
3202
|
+
exports.FontLibrary = FontLibrary;
|
|
3203
|
+
exports.HeadlessInteractiveCanvas = HeadlessInteractiveCanvas;
|
|
3204
|
+
exports.HorizontalRule = HorizontalRule;
|
|
3205
|
+
exports.Image = Image;
|
|
3206
|
+
exports.InteractiveCanvas = InteractiveCanvas;
|
|
3207
|
+
exports.PixelCanvasDimensions = PixelCanvasDimensions;
|
|
3208
|
+
exports.Print6ColCanvasDimensions = Print6ColCanvasDimensions;
|
|
3209
|
+
exports.Print8ColCanvasDimensions = Print8ColCanvasDimensions;
|
|
3210
|
+
exports.Rectangle = Rectangle;
|
|
3211
|
+
exports.SelectionData = SelectionData;
|
|
3212
|
+
exports.StandardLayoutManager = StandardLayoutManager;
|
|
3213
|
+
exports.Text = Text;
|
|
3214
|
+
exports.UNKNOWN_FONT = UNKNOWN_FONT;
|
|
3215
|
+
exports.UnknownFont = UnknownFont;
|
|
3216
|
+
exports.VerticalRule = VerticalRule;
|
|
3217
|
+
exports.isMutableBackgroundColor = isMutableBackgroundColor;
|
|
3218
|
+
exports.isMutableColor = isMutableColor;
|
|
3219
|
+
exports.isMutableImage = isMutableImage;
|
|
3220
|
+
exports.isMutablePosition = isMutablePosition;
|
|
3221
|
+
exports.isMutableText = isMutableText;
|
|
3222
|
+
exports.isMutableTextStyle = isMutableTextStyle;
|