ding-image-editor 3.15.4 → 3.15.5

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * TOAST UI ImageEditor
3
- * @version 3.15.3
3
+ * @version 3.15.5
4
4
  * @license MIT
5
5
  */
6
6
  !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("tui-color-picker")):"function"==typeof define&&define.amd?define(["tui-color-picker"],e):"object"==typeof exports?exports.tui=e(require("tui-color-picker")):(t.tui=t.tui||{},t.tui.ImageEditor=e(t.tui.colorPicker))}(self,(function(t){return function(){var e={2777:function(t,e,i){
@@ -12,4 +12,4 @@ var n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y,b,x,C,I,_,M,S=S||{version:"4.6.0"};if(e.fabr
12
12
  * @license Licensed under MIT license
13
13
  * See https://github.com/Keyamoon/svgxuse
14
14
  * @version 1.2.6
15
- */,function(){if("undefined"!=typeof window&&window.addEventListener){var t,e,i,n=g()(null),r=function(){clearTimeout(e),e=v()(t,100)},o=function(){},a=function(t){function e(t){var e;return void 0!==t.protocol?e=t:(e=document.createElement("a")).href=t,e.protocol.replace(/:/g,"")+e.host}var i,n,r;return window.XMLHttpRequest&&(i=new XMLHttpRequest,n=e(location),r=e(t),i=void 0===i.withCredentials&&""!==r&&r!==n?XDomainRequest||void 0:XMLHttpRequest),i},s="http://www.w3.org/1999/xlink";t=function(){var t,e,i,c,l,u,h,f,g,d,p=0;function m(){var t;0===(p-=1)&&(o(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1),window.MutationObserver?((t=new MutationObserver(r)).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),o=function(){try{t.disconnect(),window.removeEventListener("resize",r,!1),window.removeEventListener("orientationchange",r,!1)}catch(t){}}):(document.documentElement.addEventListener("DOMSubtreeModified",r,!1),o=function(){document.documentElement.removeEventListener("DOMSubtreeModified",r,!1),window.removeEventListener("resize",r,!1),window.removeEventListener("orientationchange",r,!1)}))}function y(t){return function(){!0!==n[t.base]&&(t.useEl.setAttributeNS(s,"xlink:href","#"+t.hash),t.useEl.hasAttribute("href")&&t.useEl.setAttribute("href","#"+t.hash))}}function b(t){return function(){var e,i=document.body,n=document.createElement("x");t.onload=null,n.innerHTML=t.responseText,(e=n.getElementsByTagName("svg")[0])&&(e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.width=0,e.style.height=0,e.style.overflow="hidden",i.insertBefore(e,i.firstChild)),m()}}function x(t){return function(){t.onerror=null,t.ontimeout=null,m()}}for(o(),g=document.getElementsByTagName("use"),l=0;l<g.length;l+=1){try{e=g[l].getBoundingClientRect()}catch(t){e=!1}t=(f=(c=g[l].getAttribute("href")||g[l].getAttributeNS(s,"href")||g[l].getAttribute("xlink:href"))&&c.split?c.split("#"):["",""])[0],i=f[1],u=e&&0===e.left&&0===e.right&&0===e.top&&0===e.bottom,e&&0===e.width&&0===e.height&&!u?(g[l].hasAttribute("href")&&g[l].setAttributeNS(s,"xlink:href",c),t.length&&(!0!==(d=n[t])&&v()(y({useEl:g[l],base:t,hash:i}),0),void 0===d&&void 0!==(h=a(t))&&(d=new h,n[t]=d,d.onload=b(d),d.onerror=x(d),d.ontimeout=x(d),d.open("GET",t),d.send(),p+=1))):u?t.length&&n[t]&&v()(y({useEl:g[l],base:t,hash:i}),0):void 0===n[t]?n[t]=!0:n[t].onload&&(n[t].abort(),delete n[t].onload,n[t]=!0)}g="",p+=1,m()},i=function(){window.removeEventListener("load",i,!1),e=v()(t,0)},"complete"!==document.readyState?window.addEventListener("load",i,!1):i()}}();var p=n(1845);function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var y=n(184),b=n(662),x=n(7172);var C=n(711);function I(t,e){var i;if(t){if("string"==typeof t)return m(t,e);var n=C(i=Object.prototype.toString.call(t)).call(i,8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?x(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,e):void 0}}function _(t){return function(t){if(p(t))return m(t)}(t)||function(t){if(void 0!==y&&null!=b(t)||null!=t["@@iterator"])return x(t)}(t)||I(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var M=n(7077);function S(t,e,i){return e in t?M(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),M(t,n.key,n)}}function T(t,e,i){return e&&k(t.prototype,e),i&&k(t,i),t}var D=n(4426),A=n.n(D),j=n(9406),O=n.n(j),E=n(8189),L=n.n(E),N=n(3972),P=n.n(N),z=n(2777),B=n(7969),R=n.n(B),F=n(3929),Y=n.n(F),W=n(1690),H=n.n(W),U=n(2278),G=n.n(U),X=n(758),Z=n.n(X),V=n(2461),J=n.n(V);function Q(t,e){return function(t){if(p(t))return t}(t)||function(t,e){var i=null==t?null:void 0!==y&&b(t)||t["@@iterator"];if(null!=i){var n,r,o=[],a=!0,s=!1;try{for(i=i.call(t);!(a=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==i.return||i.return()}finally{if(s)throw r}}return o}}(t,e)||I(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var K,q=n(6397),$=n.n(q),tt=n(7636),et=n.n(tt),it=n(789),nt=n.n(it),rt=n(1391),ot=n.n(rt),at=n(6004),st=n.n(at),ct=n(7928),lt=n.n(ct),ut=["zoomIn","zoomOut","hand"],ht=["history","undo","redo","reset"],ft=["delete","deleteAll"],gt=O()(K=[]).call(K,ut,ht,ft),dt="filter",vt="color",pt=["rect","circle","triangle"],mt="cropzone",yt="vintage",bt="sepia2",xt="removeColor",Ct="colorFilter",It="removeWhite",_t="blendColor",Mt="blend",St=Pi("IMAGE_LOADER","CROPPER","FLIP","ROTATION","FREE_DRAWING","LINE","TEXT","ICON","FILTER","SHAPE","ZOOM","RESIZE"),wt={hasRotatingPoint:!1,hasBorders:!1,lockScalingFlip:!0,lockRotation:!0,lockSkewingX:!0,lockSkewingY:!0},kt="clearObjects",Tt="loadImage",Dt="flip",At="rotate",jt="addObject",Ot="removeObject",Et="applyFilter",Lt="removeFilter",Nt="addIcon",Pt="changeIconColor",zt="addShape",Bt="changeShape",Rt="addText",Ft="changeText",Yt="changeTextStyle",Wt="addImageObject",Ht="resizeCanvasDimension",Ut="setObjectProperties",Gt="setObjectPosition",Xt="changeSelection",Zt="resize",Vt="objectActivated",Jt="objectMoved",Qt="objectScaled",Kt="objectRotated",qt="objectAdded",$t="objectModified",te="textEditing",ee="textChanged",ie="iconCreateResize",ne="iconCreateEnd",re="addText",oe="addObject",ae="addObjectAfter",se="mousedown",ce="redoStackChanged",le="undoStackChanged",ue="selectionCleared",he="selectionCreated",fe="executeCommand",ge="afterUndo",de="afterRedo",ve="zoomChanged",pe="handStarted",me="handStopped",ye="keydown",be="keyup",xe="inputBoxEditingStarted",Ce="inputBoxEditingStopped",Ie="focus",_e="blur",Me=".tui-colorpicker-palette-hex",Se="Load",we="Mask",ke="Mask",Te="Crop",De="Resize",Ae="Filter",je="Filter",Oe="Shape",Ee="Icon",Le="Text",Ne="Text",Pe="Delete",ze="Delete",Be=Pi("NORMAL","CROPPER","FREE_DRAWING","LINE_DRAWING","TEXT","SHAPE","ICON","ZOOM","RESIZE"),Re="text",Fe="crop",Ye="resize",We="shape",He="zoom",Ue="normal",Ge="zoom",Xe="hand",Ze=90,Ve=89,Je=67,Qe=86,Ke=16,qe=8,$e=46,ti=40,ei=38,ii=32,ni=48,ri=57,oi={borderColor:"red",cornerColor:"green",cornerSize:10,originX:"center",originY:"center",transparentCorners:!1},ai="The object is already added.",si="The flipX and flipY setting values are not changed.",ci="Invalid parameters.",li="The executing command state is locked.",ui="The background image is empty.",hi="Invalid image loaded.",fi="The object is not in canvas.",gi="The promise of redo command is reject.",di="The promise of undo command is reject.",vi="Unsupported operation.",pi="Unsupported object type.",mi={"icon-arrow":"M40 12V0l24 24-24 24V36H0V12h40z","icon-arrow-2":"M49,32 H3 V22 h46 l-18,-18 h12 l23,23 L43,50 h-12 l18,-18 z ","icon-arrow-3":"M43.349998,27 L17.354,53 H1.949999 l25.996,-26 L1.949999,1 h15.404 L43.349998,27 z ","icon-star":"M35,54.557999 l-19.912001,10.468 l3.804,-22.172001 l-16.108,-15.7 l22.26,-3.236 L35,3.746 l9.956,20.172001 l22.26,3.236 l-16.108,15.7 l3.804,22.172001 z ","icon-star-2":"M17,31.212 l-7.194,4.08 l-4.728,-6.83 l-8.234,0.524 l-1.328,-8.226 l-7.644,-3.14 l2.338,-7.992 l-5.54,-6.18 l5.54,-6.176 l-2.338,-7.994 l7.644,-3.138 l1.328,-8.226 l8.234,0.522 l4.728,-6.83 L17,-24.312 l7.194,-4.08 l4.728,6.83 l8.234,-0.522 l1.328,8.226 l7.644,3.14 l-2.338,7.992 l5.54,6.178 l-5.54,6.178 l2.338,7.992 l-7.644,3.14 l-1.328,8.226 l-8.234,-0.524 l-4.728,6.83 z ","icon-polygon":"M3,31 L19,3 h32 l16,28 l-16,28 H19 z ","icon-location":"M24 62C8 45.503 0 32.837 0 24 0 10.745 10.745 0 24 0s24 10.745 24 24c0 8.837-8 21.503-24 38zm0-28c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10z","icon-heart":"M49.994999,91.349998 l-6.96,-6.333 C18.324001,62.606995 2.01,47.829002 2.01,29.690998 C2.01,14.912998 13.619999,3.299999 28.401001,3.299999 c8.349,0 16.362,5.859 21.594,12 c5.229,-6.141 13.242001,-12 21.591,-12 c14.778,0 26.390999,11.61 26.390999,26.390999 c0,18.138 -16.314001,32.916 -41.025002,55.374001 l-6.96,6.285 z ","icon-bubble":"M44 48L34 58V48H12C5.373 48 0 42.627 0 36V12C0 5.373 5.373 0 12 0h40c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12h-8z"},yi={realTimeEvent:!0,min:-360,max:360,value:0},bi={min:5,max:30,value:12},xi={realTimeEvent:!0,min:2,max:300,value:3},Ci={realTimeEvent:!0,min:10,max:100,value:50},Ii={tintOpacityRange:{realTimeEvent:!0,min:0,max:1,value:.7,useDecimal:!0},removewhiteDistanceRange:{realTimeEvent:!0,min:0,max:1,value:.2,useDecimal:!0},brightnessRange:{realTimeEvent:!0,min:-1,max:1,value:0,useDecimal:!0},noiseRange:{realTimeEvent:!0,min:0,max:1e3,value:100},pixelateRange:{realTimeEvent:!0,min:2,max:20,value:4},colorfilterThresholdRange:{realTimeEvent:!0,min:0,max:1,value:.2,useDecimal:!0},blurFilterRange:{value:.1}},_i=0,Mi=0,Si=.5,wi=.5,ki={realTimeEvent:!0,min:32},Ti="tui-image-editor-",Di=Math.min,Ai=Math.max,ji=!1,Oi=0;function Ei(t){return t.__fe_id||(Oi+=1,t.__fe_id=Oi),t.__fe_id}function Li(t){return"function"==typeof t}function Ni(t,e,i){if(e>i){var n=[i,e];e=n[0],i=n[1]}return Ai(e,Di(t,i))}function Pi(){for(var t={},e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return H()(i,(function(e){t[e]=e})),t}function zi(t,e){var i,n={},r=e.length,o=0;for(o=0;o<r;o+=1)n[i=e[o]]=t[i];return n}function Bi(t){return $()(t,10)}function Ri(t){return t.replace(/-([a-z])/g,(function(t,e){return e.toUpperCase()}))}function Fi(){return!!(window.File&&window.FileList&&window.FileReader)}function Yi(t,e){var i,n,r,o;4===t.length&&(t=O()(o="".concat(t)).call(o,h()(t).call(t,1,4)));var a=$()(h()(t).call(t,1,3),16),s=$()(h()(t).call(t,3,5),16),c=$()(h()(t).call(t,5,7),16),l=e||1;return O()(i=O()(n=O()(r="rgba(".concat(a,", ")).call(r,s,", ")).call(n,c,", ")).call(i,l,")")}function Wi(t){H()(t,(function(e,i){t[i]=null}))}function Hi(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"."===i.charAt(0)?O()(e=".".concat(Ti).concat(n)).call(e,h()(i).call(i,1)):O()(t="".concat(Ti).concat(n)).call(t,i)}function Ui(t,e){t.customProps=t.customProps||{},R()(t.customProps,e)}function Gi(t,e){var i={};return Z()(e)&&(e=[e]),H()(e,(function(e){i[e]=t.customProps[e]})),i}function Xi(t,e){return o()(t).call(t,e)>=0}function Zi(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return st()(t,"type")||vt}function Vi(t){var e=nt()(t);return(void 0===e?{}:e).source?dt:vt}function Ji(t){return lt()(t.get("type"),pt)>=0}function Qi(t){if(Xi(pt,t))return"Shape";switch(t){case"i-text":return"Text";case"path":case"line":return"Draw";case"activeSelection":return"Group";default:return qi(t)}}function Ki(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.useAlpha,r=void 0===n||n,o=i.mode,a=yt,s=xt,c=_t,l=bt,u=Ct,h=It,f=Mt;switch(t){case a:e=l;break;case s:e=r?u:h;break;case c:e="add"===o?f:o;break;default:e=t}return qi(e)}function qi(t){return t.replace(/[a-z]/,(function(t){return t.toUpperCase()}))}var $i=Pi("UN_IMPLEMENTATION","NO_COMPONENT_NAME"),tn="Should implement a method: ",en="Should set a component name",nn={UN_IMPLEMENTATION:function(t){return tn+t},NO_COMPONENT_NAME:function(){return en}},rn={types:R()({},$i),create:function(t){t=t.toLowerCase();for(var e=nn[t],i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(void 0,n)}},on=rn.create,an=rn.types,sn=function(){function t(e,i){w(this,t),this.name=e.name,this.args=i,this.execute=e.execute,this.undo=e.undo,this.executeCallback=e.executeCallback||null,this.undoCallback=e.undoCallback||null,this.undoData={}}return T(t,[{key:"execute",value:function(){throw new Error(on(an.UN_IMPLEMENTATION,"execute"))}},{key:"undo",value:function(){throw new Error(on(an.UN_IMPLEMENTATION,"undo"))}},{key:"isRedo",get:function(){return J()(this.undoData).length>0}},{key:"setUndoData",value:function(t,e,i){return e&&(t=e),i?e||(e=t):(R()(this.undoData,t),e=null),e}},{key:"setExecuteCallback",value:function(t){return this.executeCallback=t,this}},{key:"setUndoCallback",value:function(t){return this.undoCallback=t,this}}]),t}(),cn=sn,ln={};var un={create:function(t){var e=ln[t];if(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return new cn(e,n)}return null},register:function(t){ln[t.name]=t}},hn=function(){function t(){w(this,t),this._undoStack=[],this._redoStack=[],this._isLocked=!1,this._isSilent=!1}return T(t,[{key:"_invokeExecution",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.lock();var n=t.args;return n||(n=[]),t.execute.apply(t,_(n)).then((function(n){return e._isSilent||(e.pushUndoStack(t),e.fire(i?de:fe,t)),e.unlock(),Li(t.executeCallback)&&t.executeCallback(n),n})).catch((function(t){return e.unlock(),L().reject(t)}))}},{key:"_invokeUndo",value:function(t){var e=this;this.lock();var i=t.args;return i||(i=[]),t.undo.apply(t,_(i)).then((function(i){return e.pushRedoStack(t),e.fire(ge,t),e.unlock(),Li(t.undoCallback)&&t.undoCallback(i),i})).catch((function(t){return e.unlock(),L().reject(t)}))}},{key:"_fireRedoStackChanged",value:function(){this.fire(ce,this._redoStack.length)}},{key:"_fireUndoStackChanged",value:function(){this.fire(le,this._undoStack.length)}},{key:"lock",value:function(){this._isLocked=!0}},{key:"unlock",value:function(){this._isLocked=!1}},{key:"executeSilent",value:function(){var t=this;this._isSilent=!0;for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return this.execute.apply(this,O()(i).call(i,[this._isSilent])).then((function(){t._isSilent=!1}))}},{key:"execute",value:function(){var t=this;if(this._isLocked)return L().reject(li);for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];var r=i[0];return Z()(r)&&(r=un.create.apply(un,i)),this._invokeExecution(r).then((function(e){return t.clearRedoStack(),e}))}},{key:"undo",value:function(){var t,e=this._undoStack.pop(),i="";if(e&&this._isLocked&&(this.pushUndoStack(e,!0),e=null),e)this.isEmptyUndoStack()&&this._fireUndoStackChanged(),t=this._invokeUndo(e);else{var n;if(i=di,this._isLocked)i=O()(n="".concat(i," Because ")).call(n,li);t=L().reject(i)}return t}},{key:"redo",value:function(){var t,e=this._redoStack.pop(),i="";if(e&&this._isLocked&&(this.pushRedoStack(e,!0),e=null),e)this.isEmptyRedoStack()&&this._fireRedoStackChanged(),t=this._invokeExecution(e,!0);else{var n;if(i=gi,this._isLocked)i=O()(n="".concat(i," Because ")).call(n,li);t=L().reject(i)}return t}},{key:"pushUndoStack",value:function(t,e){this._undoStack.push(t),e||this._fireUndoStackChanged()}},{key:"pushRedoStack",value:function(t,e){this._redoStack.push(t),e||this._fireRedoStackChanged()}},{key:"isEmptyRedoStack",value:function(){return 0===this._redoStack.length}},{key:"isEmptyUndoStack",value:function(){return 0===this._undoStack.length}},{key:"clearUndoStack",value:function(){this.isEmptyUndoStack()||(this._undoStack=[],this._fireUndoStackChanged())}},{key:"clearRedoStack",value:function(){this.isEmptyRedoStack()||(this._redoStack=[],this._fireRedoStackChanged())}}]),t}();G().mixin(hn);var fn=hn,gn=n(5214),dn=n.n(gn),vn=n(899),pn=n.n(vn),mn={"common.bi.image":"https://uicdn.toast.com/toastui/img/tui-image-editor-bi.png","common.bisize.width":"251px","common.bisize.height":"21px","common.backgroundImage":"none","common.backgroundColor":"#1e1e1e","common.border":"0px","header.backgroundImage":"none","header.backgroundColor":"transparent","header.border":"0px","loadButton.backgroundColor":"#fff","loadButton.border":"1px solid #ddd","loadButton.color":"#222","loadButton.fontFamily":"'Noto Sans', sans-serif","loadButton.fontSize":"12px","downloadButton.backgroundColor":"#fdba3b","downloadButton.border":"1px solid #fdba3b","downloadButton.color":"#fff","downloadButton.fontFamily":"'Noto Sans', sans-serif","downloadButton.fontSize":"12px","menu.normalIcon.color":"#8a8a8a","menu.activeIcon.color":"#555555","menu.disabledIcon.color":"#434343","menu.hoverIcon.color":"#e9e9e9","submenu.normalIcon.color":"#8a8a8a","submenu.activeIcon.color":"#e9e9e9","menu.iconSize.width":"24px","menu.iconSize.height":"24px","submenu.iconSize.width":"32px","submenu.iconSize.height":"32px","submenu.backgroundColor":"#1e1e1e","submenu.partition.color":"#3c3c3c","submenu.normalLabel.color":"#8a8a8a","submenu.normalLabel.fontWeight":"lighter","submenu.activeLabel.color":"#fff","submenu.activeLabel.fontWeight":"lighter","checkbox.border":"0px","checkbox.backgroundColor":"#fff","range.pointer.color":"#fff","range.bar.color":"#666","range.subbar.color":"#d1d1d1","range.disabledPointer.color":"#414141","range.disabledBar.color":"#282828","range.disabledSubbar.color":"#414141","range.value.color":"#fff","range.value.fontWeight":"lighter","range.value.fontSize":"11px","range.value.border":"1px solid #353535","range.value.backgroundColor":"#151515","range.title.color":"#fff","range.title.fontWeight":"lighter","colorpicker.button.border":"1px solid #1e1e1e","colorpicker.title.color":"#fff"},yn=n(2534),bn=function(){function t(e){var i,n,r,o,a;w(this,t),this.styles=this._changeToObject(R()({},mn,e)),i=this._styleMaker(),r=Q(document.getElementsByTagName("head"),1)[0],o=document.createElement("link"),a=encodeURIComponent(i),n&&(o.id=n),o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href","data:text/css;charset=UTF-8,".concat(a)),r.appendChild(o),this._loadDefaultSvgIcon()}return T(t,[{key:"getStyle",value:function(t){var e=null,i=t.replace(/\..+$/,""),n=this.styles[t];switch(t){case"common.bi":e=this.styles[t].image;break;case"menu.icon":e={active:this.styles["".concat(i,".activeIcon")],normal:this.styles["".concat(i,".normalIcon")],hover:this.styles["".concat(i,".hoverIcon")],disabled:this.styles["".concat(i,".disabledIcon")]};break;case"submenu.icon":e={active:this.styles["".concat(i,".activeIcon")],normal:this.styles["".concat(i,".normalIcon")]};break;case"submenu.label":e={active:this._makeCssText(this.styles["".concat(i,".activeLabel")]),normal:this._makeCssText(this.styles["".concat(i,".normalLabel")])};break;case"submenu.partition":e={vertical:this._makeCssText(R()({},n,{borderLeft:"1px solid ".concat(n.color)})),horizontal:this._makeCssText(R()({},n,{borderBottom:"1px solid ".concat(n.color)}))};break;case"range.disabledPointer":case"range.disabledBar":case"range.disabledSubbar":case"range.pointer":case"range.bar":case"range.subbar":n.backgroundColor=n.color,e=this._makeCssText(n);break;default:e=this._makeCssText(n)}return e}},{key:"_styleMaker",value:function(){var t=this.getStyle("submenu.label"),e=this.getStyle("submenu.partition");return function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y,b,x,C,I,_,M,S,w,k,T,D,A=t.subMenuLabelActive,j=t.subMenuLabelNormal,E=t.subMenuRangeTitle,L=t.submenuPartitionVertical,N=t.submenuPartitionHorizontal,P=t.submenuCheckbox,z=t.submenuRangePointer,B=t.submenuRangeValue,R=t.submenuColorpickerTitle,F=t.submenuColorpickerButton,Y=t.submenuRangeBar,W=t.submenuRangeSubbar,H=t.submenuDisabledRangePointer,U=t.submenuDisabledRangeBar,G=t.submenuDisabledRangeSubbar,X=t.submenuIconSize,Z=t.menuIconSize,V=t.biSize,J=t.menuIconStyle,Q=t.submenuIconStyle;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m=O()(y=O()(b=O()(x=O()(C=O()(I=O()(_=O()(M=O()(S=O()(w=O()(k=O()(T=O()(D='\n .tie-icon-add-button.icon-bubble .tui-image-editor-button[data-icontype="icon-bubble"] label,\n .tie-icon-add-button.icon-heart .tui-image-editor-button[data-icontype="icon-heart"] label,\n .tie-icon-add-button.icon-location .tui-image-editor-button[data-icontype="icon-location"] label,\n .tie-icon-add-button.icon-polygon .tui-image-editor-button[data-icontype="icon-polygon"] label,\n .tie-icon-add-button.icon-star .tui-image-editor-button[data-icontype="icon-star"] label,\n .tie-icon-add-button.icon-star-2 .tui-image-editor-button[data-icontype="icon-star-2"] label,\n .tie-icon-add-button.icon-arrow-3 .tui-image-editor-button[data-icontype="icon-arrow-3"] label,\n .tie-icon-add-button.icon-arrow-2 .tui-image-editor-button[data-icontype="icon-arrow-2"] label,\n .tie-icon-add-button.icon-arrow .tui-image-editor-button[data-icontype="icon-arrow"] label,\n .tie-icon-add-button.icon-bubble .tui-image-editor-button[data-icontype="icon-bubble"] label,\n .tie-draw-line-select-button.line .tui-image-editor-button.line label,\n .tie-draw-line-select-button.free .tui-image-editor-button.free label,\n .tie-flip-button.flipX .tui-image-editor-button.flipX label,\n .tie-flip-button.flipY .tui-image-editor-button.flipY label,\n .tie-flip-button.resetFlip .tui-image-editor-button.resetFlip label,\n .tie-crop-button .tui-image-editor-button.apply.active label,\n .tie-crop-preset-button .tui-image-editor-button.preset.active label,\n .tie-resize-button .tui-image-editor-button.apply.active label,\n .tie-resize-preset-button .tui-image-editor-button.preset.active label,\n .tie-shape-button.rect .tui-image-editor-button.rect label,\n .tie-shape-button.circle .tui-image-editor-button.circle label,\n .tie-shape-button.triangle .tui-image-editor-button.triangle label,\n .tie-text-effect-button .tui-image-editor-button.active label,\n .tie-text-align-button.tie-text-align-left .tui-image-editor-button.left label,\n .tie-text-align-button.tie-text-align-center .tui-image-editor-button.center label,\n .tie-text-align-button.tie-text-align-right .tui-image-editor-button.right label,\n .tie-mask-apply.apply.active .tui-image-editor-button.apply label,\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button:hover > label,\n .tui-image-editor-container .tui-image-editor-checkbox label > span {\n '.concat(A,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button > label,\n .tui-image-editor-container .tui-image-editor-range-wrap.tui-image-editor-newline.short label,\n .tui-image-editor-container .tui-image-editor-range-wrap.tui-image-editor-newline.short label > span {\n ")).call(D,j,"\n }\n .tui-image-editor-container .tui-image-editor-range-wrap label > span {\n ")).call(T,E,"\n }\n .tui-image-editor-container .tui-image-editor-partition > div {\n ")).call(k,L,"\n }\n .tui-image-editor-container.left .tui-image-editor-submenu .tui-image-editor-partition > div,\n .tui-image-editor-container.right .tui-image-editor-submenu .tui-image-editor-partition > div {\n ")).call(w,N,"\n }\n .tui-image-editor-container .tui-image-editor-checkbox label > span:before {\n ")).call(S,P,"\n }\n .tui-image-editor-container .tui-image-editor-checkbox label > input:checked + span:before {\n border: 0;\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-pointer {\n ")).call(M,z,"\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-bar {\n ")).call(_,Y,"\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-subbar {\n ")).call(I,W,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-pointer {\n ")).call(C,H,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-subbar {\n ")).call(x,G,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-bar {\n ")).call(b,U,"\n }\n .tui-image-editor-container .tui-image-editor-range-value {\n ")).call(y,B,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button .color-picker-value + label {\n ")).call(m,R,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button .color-picker-value {\n ")).call(p,F,"\n }\n .tui-image-editor-container .svg_ic-menu {\n ")).call(v,Z,"\n }\n .tui-image-editor-container .svg_ic-submenu {\n ")).call(d,X,"\n }\n .tui-image-editor-container .tui-image-editor-controls-logo > img,\n .tui-image-editor-container .tui-image-editor-header-logo > img {\n ")).call(g,V,"\n }\n .tui-image-editor-menu use.normal.use-default,\n .tui-image-editor-help-menu use.normal.use-default {\n fill-rule: evenodd;\n fill: ")).call(f,J.normal.color,";\n stroke: ")).call(h,J.normal.color,";\n }\n .tui-image-editor-menu use.active.use-default,\n .tui-image-editor-help-menu use.active.use-default {\n fill-rule: evenodd;\n fill: ")).call(u,J.active.color,";\n stroke: ")).call(l,J.active.color,";\n }\n .tui-image-editor-menu use.hover.use-default,\n .tui-image-editor-help-menu use.hover.use-default {\n fill-rule: evenodd;\n fill: ")).call(c,J.hover.color,";\n stroke: ")).call(s,J.hover.color,";\n }\n .tui-image-editor-menu use.disabled.use-default,\n .tui-image-editor-help-menu use.disabled.use-default {\n fill-rule: evenodd;\n fill: ")).call(a,J.disabled.color,";\n stroke: ")).call(o,J.disabled.color,";\n }\n .tui-image-editor-submenu use.normal.use-default {\n fill-rule: evenodd;\n fill: ")).call(r,Q.normal.color,";\n stroke: ")).call(n,Q.normal.color,";\n }\n .tui-image-editor-submenu use.active.use-default {\n fill-rule: evenodd;\n fill: ")).call(i,Q.active.color,";\n stroke: ")).call(e,Q.active.color,";\n }\n")}({subMenuLabelActive:t.active,subMenuLabelNormal:t.normal,submenuPartitionVertical:e.vertical,submenuPartitionHorizontal:e.horizontal,biSize:this.getStyle("common.bisize"),subMenuRangeTitle:this.getStyle("range.title"),submenuRangePointer:this.getStyle("range.pointer"),submenuRangeBar:this.getStyle("range.bar"),submenuRangeSubbar:this.getStyle("range.subbar"),submenuDisabledRangePointer:this.getStyle("range.disabledPointer"),submenuDisabledRangeBar:this.getStyle("range.disabledBar"),submenuDisabledRangeSubbar:this.getStyle("range.disabledSubbar"),submenuRangeValue:this.getStyle("range.value"),submenuColorpickerTitle:this.getStyle("colorpicker.title"),submenuColorpickerButton:this.getStyle("colorpicker.button"),submenuCheckbox:this.getStyle("checkbox"),menuIconSize:this.getStyle("menu.iconSize"),submenuIconSize:this.getStyle("submenu.iconSize"),menuIconStyle:this.getStyle("menu.icon"),submenuIconStyle:this.getStyle("submenu.icon")})}},{key:"_changeToObject",value:function(t){var e={};return H()(t,(function(t,i){var n=Q(i.match(/^(.+)\.([a-z]+)$/i),3),r=n[1],o=n[2];e[r]||(e[r]={}),e[r][o]=t})),e}},{key:"_makeCssText",value:function(t){var e=this,i=[];return H()(t,(function(t,n){var r,a;o()(r=["backgroundImage"]).call(r,n)>-1&&"none"!==t&&(t="url(".concat(t,")")),i.push(O()(a="".concat(e._toUnderScore(n),": ")).call(a,t))})),i.join(";")}},{key:"_toUnderScore",value:function(t){return t.replace(/([A-Z])/g,(function(t,e){return"-".concat(e.toLowerCase())}))}},{key:"_loadDefaultSvgIcon",value:function(){if(!document.getElementById("tui-image-editor-svg-default-icons")){var t=new DOMParser,e=yn.replace(/data:image\/svg\+xml;base64,/,""),i=t.parseFromString(atob(e),"text/xml");document.body.appendChild(i.documentElement)}}},{key:"_makeIconClassName",value:function(t,e){var i=(e?this.getStyle("submenu.icon"):this.getStyle("menu.icon"))[t],n=i.path,r=i.name;return n&&r?t:"".concat(t," use-default")}},{key:"_makeSvgIconPrefix",value:function(t,e){var i,n=(e?this.getStyle("submenu.icon"):this.getStyle("menu.icon"))[t],r=n.path,o=n.name;return r&&o?O()(i="".concat(r,"#")).call(i,o,"-"):"#"}},{key:"_makeSvgItem",value:function(t,e,i){var n=this;return pn()(t).call(t,(function(t){var r,o,a=n._makeSvgIconPrefix(t,i),s=n._toUnderScore(e),c=n._makeIconClassName(t,i);return O()(r=O()(o='<use xlink:href="'.concat(a,"ic-")).call(o,s,'" class="')).call(r,c,'"/>')})).join("")}},{key:"makeMenSvgIconSet",value:function(t,e){var i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return O()(i='<svg class="svg_ic-'.concat(n?"submenu":"menu",'">')).call(i,this._makeSvgItem(t,e,n),"</svg>")}}]),t}(),xn=bn,Cn=n(9146),In=n.n(Cn),_n=n(6623),Mn=n(4230);function Sn(t,e){return Sn=Mn||function(t,e){return t.__proto__=e,t},Sn(t,e)}function wn(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=_n(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Sn(t,e)}var kn=n(3742);function Tn(t){return Tn="function"==typeof y&&"symbol"==typeof kn?function(t){return typeof t}:function(t){return t&&"function"==typeof y&&t.constructor===y&&t!==y.prototype?"symbol":typeof t},Tn(t)}function Dn(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function An(t,e){if(e&&("object"===Tn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Dn(t)}var jn=n(9856);function On(t){return On=Mn?jn:function(t){return t.__proto__||jn(t)},On(t)}var En=n(893),Ln=n.n(En),Nn=n(4858),Pn=n.n(Nn),zn=["#000000","#2a2a2a","#545454","#7e7e7e","#a8a8a8","#d2d2d2","#ffffff","","#ff4040","#ff6518","#ffbb3b","#03bd9e","#00a9ff","#515ce6","#9e5fff","#ff5583"],Bn=function(){function t(e,i){var n=i.defaultColor,r=void 0===n?"#7e7e7e":n,o=i.toggleDirection,a=void 0===o?"up":o,s=i.usageStatistics;w(this,t),this.colorpickerElement=e,this.usageStatistics=s,this._show=!1,this._colorpickerElement=e,this._toggleDirection=a,this._makePickerButtonElement(r),this._makePickerLayerElement(e,e.getAttribute("title")),this._color=r,this.picker=Pn().create({container:this.pickerElement,preset:zn,color:r,usageStatistics:this.usageStatistics}),this._addEvent()}return T(t,[{key:"destroy",value:function(){var t=this;this._removeEvent(),this.picker.destroy(),this.colorpickerElement.innerHTML="",H()(this,(function(e,i){t[i]=null}))}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._changeColorElement(t)}},{key:"_changeColorElement",value:function(t){t?(this.colorElement.classList.remove("transparent"),this.colorElement.style.backgroundColor=t):(this.colorElement.style.backgroundColor="#fff",this.colorElement.classList.add("transparent"))}},{key:"_makePickerButtonElement",value:function(t){this.colorpickerElement.classList.add("tui-image-editor-button"),this.colorElement=document.createElement("div"),this.colorElement.className="color-picker-value",t?this.colorElement.style.backgroundColor=t:this.colorElement.classList.add("transparent")}},{key:"_makePickerLayerElement",value:function(t,e){var i=document.createElement("label"),n=document.createElement("div");this.pickerControl=document.createElement("div"),this.pickerControl.className="color-picker-control",this.pickerElement=document.createElement("div"),this.pickerElement.className="color-picker",i.innerHTML=e,n.className="triangle",this.pickerControl.appendChild(this.pickerElement),this.pickerControl.appendChild(n),t.appendChild(this.pickerControl),t.appendChild(this.colorElement),t.appendChild(i)}},{key:"_addEvent",value:function(){var t,e=this;this.picker.on("selectColor",(function(t){e._changeColorElement(t.color),e._color=t.color,e.fire("change",t.color)})),this.eventHandler={pickerToggle:A()(t=this._pickerToggleEventHandler).call(t,this),pickerHide:function(){return e.hide()}},this.colorpickerElement.addEventListener("click",this.eventHandler.pickerToggle),document.body.addEventListener("click",this.eventHandler.pickerHide)}},{key:"_removeEvent",value:function(){this.colorpickerElement.removeEventListener("click",this.eventHandler.pickerToggle),document.body.removeEventListener("click",this.eventHandler.pickerHide),this.picker.off()}},{key:"_pickerToggleEventHandler",value:function(t){var e=t.target,i=e&&this._isElementInColorPickerControl(e);(!i||i&&this._isPaletteButton(e))&&(this._show=!this._show,this.pickerControl.style.display=this._show?"block":"none",this._setPickerControlPosition(),this.fire("changeShow",this)),t.stopPropagation()}},{key:"_isPaletteButton",value:function(t){return"tui-colorpicker-palette-button"===t.className}},{key:"_isElementInColorPickerControl",value:function(t){for(var e=t;e!==document.body&&e;){if(e===this.pickerControl)return!0;e=e.parentNode}return!1}},{key:"hide",value:function(){this._show=!1,this.pickerControl.style.display="none"}},{key:"_setPickerControlPosition",value:function(){var t=this.pickerControl.style,e=this._colorpickerElement.clientWidth/2+2,i=this.pickerControl.offsetWidth/2-e,n=-1*(this.pickerControl.offsetHeight+10);"down"===this._toggleDirection&&(n=30),t.top="".concat(n,"px"),t.left="-".concat(i,"px")}}]),t}();G().mixin(Bn);var Rn=Bn,Fn=/(-?)([0-9]*)[^0-9]*([0-9]*)/g,Yn=function(){function t(e){var i,n,r,o,a,s,c,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w(this,t),this._value=l.value||0,this.rangeElement=e.slider,this.rangeInputElement=e.input,this._drawRangeElement(),this.rangeWidth=this._getRangeWidth(),this._min=l.min||0,this._max=l.max||100,this._useDecimal=l.useDecimal,this._absMax=-1*this._min+this._max,this.realTimeEvent=l.realTimeEvent||!1,this._userInputTimer=null,this.eventHandler={startChangingSlide:A()(i=this._startChangingSlide).call(i,this),stopChangingSlide:A()(n=this._stopChangingSlide).call(n,this),changeSlide:A()(r=this._changeSlide).call(r,this),changeSlideFinally:A()(o=this._changeSlideFinally).call(o,this),changeInput:A()(a=this._changeInput).call(a,this),changeInputFinally:A()(s=this._changeValueWithInput).call(s,this,!0),changeInputWithArrow:A()(c=this._changeValueWithInputKeyEvent).call(c,this)},this._addClickEvent(),this._addDragEvent(),this._addInputEvent(),this.value=l.value,this.trigger("change")}return T(t,[{key:"destroy",value:function(){var t=this;this._removeClickEvent(),this._removeDragEvent(),this._removeInputEvent(),this.rangeElement.innerHTML="",H()(this,(function(e,i){t[i]=null}))}},{key:"max",get:function(){return this._max},set:function(t){this._max=t,this._absMax=-1*this._min+this._max,this.value=this._value}},{key:"min",get:function(){return this._min},set:function(t){this._min=t,this.max=this._max}},{key:"value",get:function(){return this._value},set:function(t){var e=((t=this._useDecimal?t:Bi(t))-this._min)*this.rangeWidth/this._absMax;this.rangeWidth<e&&(e=this.rangeWidth),this.pointer.style.left="".concat(e,"px"),this.subbar.style.right="".concat(this.rangeWidth-e,"px"),this._value=t,this.rangeInputElement&&(this.rangeInputElement.value=t)}},{key:"trigger",value:function(t){this.fire(t,this._value)}},{key:"_getRangeWidth",value:function(){var t=function(t){return Bi(window.getComputedStyle(t,null).width)};return t(this.rangeElement)-t(this.pointer)}},{key:"_drawRangeElement",value:function(){this.rangeElement.classList.add("tui-image-editor-range"),this.bar=document.createElement("div"),this.bar.className="tui-image-editor-virtual-range-bar",this.subbar=document.createElement("div"),this.subbar.className="tui-image-editor-virtual-range-subbar",this.pointer=document.createElement("div"),this.pointer.className="tui-image-editor-virtual-range-pointer",this.bar.appendChild(this.subbar),this.bar.appendChild(this.pointer),this.rangeElement.appendChild(this.bar)}},{key:"_addInputEvent",value:function(){this.rangeInputElement&&(this.rangeInputElement.addEventListener("keydown",this.eventHandler.changeInputWithArrow),this.rangeInputElement.addEventListener("keydown",this.eventHandler.changeInput),this.rangeInputElement.addEventListener("blur",this.eventHandler.changeInputFinally))}},{key:"_removeInputEvent",value:function(){this.rangeInputElement&&(this.rangeInputElement.removeEventListener("keydown",this.eventHandler.changeInputWithArrow),this.rangeInputElement.removeEventListener("keydown",this.eventHandler.changeInput),this.rangeInputElement.removeEventListener("blur",this.eventHandler.changeInputFinally))}},{key:"_changeValueWithInputKeyEvent",value:function(t){var e,i=t.keyCode,n=t.target;if(!(o()(e=[ei,ti]).call(e,i)<0)){var r=Number(n.value);if(!((r=this._valueUpDownForKeyEvent(r,i))<this._min||r>this._max)){var a=Ni(r,this._min,this.max);this.value=a,this.fire("change",a,!1)}}}},{key:"_valueUpDownForKeyEvent",value:function(t,e){var i=this._useDecimal?.1:1;return e===ei?t+=i:e===ti&&(t-=i),t}},{key:"_changeInput",value:function(t){var e=this;clearTimeout(this._userInputTimer);var i=t.keyCode;i<ni||i>ri?t.preventDefault():this._userInputTimer=v()((function(){e._inputSetValue(t.target.value)}),350)}},{key:"_inputSetValue",value:function(t){var e=this._useDecimal?Number(t):Bi(t);e=Ni(e,this._min,this.max),this.value=e,this.fire("change",e,!0)}},{key:"_changeValueWithInput",value:function(t,e){var i,n=e.keyCode,r=e.target;if(!(o()(i=[ei,ti]).call(i,n)>=0)){var a=this._filterForInputText(r.value),s=!a||isNaN(a);r.value=a,s||this._inputSetValue(a)}}},{key:"_addClickEvent",value:function(){this.rangeElement.addEventListener("click",this.eventHandler.changeSlideFinally)}},{key:"_removeClickEvent",value:function(){this.rangeElement.removeEventListener("click",this.eventHandler.changeSlideFinally)}},{key:"_addDragEvent",value:function(){this.pointer.addEventListener("mousedown",this.eventHandler.startChangingSlide)}},{key:"_removeDragEvent",value:function(){this.pointer.removeEventListener("mousedown",this.eventHandler.startChangingSlide)}},{key:"_changeSlide",value:function(t){var e=t.screenX-this.firstPosition,i=this.firstLeft+e;i=(i=i>this.rangeWidth?this.rangeWidth:i)<0?0:i,this.pointer.style.left="".concat(i,"px"),this.subbar.style.right="".concat(this.rangeWidth-i,"px");var n=i/this.rangeWidth,r=this._absMax*n+this._min,o=this._useDecimal?r:Bi(r);this.value!==o&&(this.value=o,this.realTimeEvent&&this.fire("change",this._value,!1))}},{key:"_changeSlideFinally",value:function(t){if(t.stopPropagation(),"tui-image-editor-range"===t.target.className){var e=t.offsetX/this.rangeWidth,i=this._absMax*e+this._min;this.pointer.style.left="".concat(e*this.rangeWidth,"px"),this.subbar.style.right="".concat((1-e)*this.rangeWidth,"px"),this.value=i,this.fire("change",i,!0)}}},{key:"_startChangingSlide",value:function(t){this.firstPosition=t.screenX,this.firstLeft=Bi(this.pointer.style.left)||0,document.addEventListener("mousemove",this.eventHandler.changeSlide),document.addEventListener("mouseup",this.eventHandler.stopChangingSlide)}},{key:"_stopChangingSlide",value:function(){this.fire("change",this._value,!0),document.removeEventListener("mousemove",this.eventHandler.changeSlide),document.removeEventListener("mouseup",this.eventHandler.stopChangingSlide)}},{key:"_filterForInputText",value:function(t){return t.replace(Fn,"$1$2$3")}}]),t}();G().mixin(Yn);var Wn=Yn,Hn=function(){function t(e,i){var n=i.locale,r=i.name,o=i.makeSvgIcon,a=i.menuBarPosition,s=i.templateHtml,c=i.usageStatistics;w(this,t),this.subMenuElement=e,this.menuBarPosition=a,this.toggleDirection="top"===a?"down":"up",this.colorPickerControls=[],this.usageStatistics=c,this.eventHandler={},this._makeSubMenuElement({locale:n,name:r,makeSvgIcon:o,templateHtml:s})}return T(t,[{key:"selector",value:function(t){return this.subMenuElement.querySelector(t)}},{key:"colorPickerChangeShow",value:function(t){var e;et()(e=this.colorPickerControls).call(e,(function(e){t!==e&&e.hide()}))}},{key:"getButtonType",value:function(t,e){return t.className.match(RegExp("(".concat(e.join("|"),")")))[0]}},{key:"changeClass",value:function(t,e,i){t.classList.remove(e),t.classList.add(i)}},{key:"changeStandbyMode",value:function(){}},{key:"changeStartMode",value:function(){}},{key:"_makeSubMenuElement",value:function(t){var e=t.locale,i=t.name,n=t.iconStyle,r=t.makeSvgIcon,o=t.templateHtml,a=document.createElement("div");a.className="tui-image-editor-menu-".concat(i),a.innerHTML=o({locale:e,iconStyle:n,makeSvgIcon:r}),this.subMenuElement.appendChild(a)}},{key:"_onStartEditingInputBox",value:function(){this.fire(xe)}},{key:"_onStopEditingInputBox",value:function(){this.fire(Ce)}}]),t}();G().mixin(Hn);var Un=Hn,Gn=function(t){var e,i,n,r,o,a,s,c,l=t.locale,u=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-shape-button">\n <div class="tui-image-editor-button rect">\n <div>\n '.concat(u(["normal","active"],"shape-rectangle",!0),"\n </div>\n <label> ")).call(c,l.localize("Rectangle"),' </label>\n </div>\n <div class="tui-image-editor-button circle">\n <div>\n ')).call(s,u(["normal","active"],"shape-circle",!0),"\n </div>\n <label> ")).call(a,l.localize("Circle"),' </label>\n </div>\n <div class="tui-image-editor-button triangle">\n <div>\n ')).call(o,u(["normal","active"],"shape-triangle",!0),"\n </div>\n <label> ")).call(r,l.localize("Triangle"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-shape-color-button">\n <div class="tie-color-fill" title="')).call(n,l.localize("Fill"),'"></div>\n <div class="tie-color-stroke" title="')).call(i,l.localize("Stroke"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,l.localize("Stroke"),'</label>\n <div class="tie-stroke-range"></div>\n <input class="tie-stroke-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function Xn(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Zn={stroke:"#ffbb3b",fill:"",strokeWidth:3},Vn=function(t){wn(i,t);var e=Xn(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"shape",makeSvgIcon:a,menuBarPosition:s,templateHtml:Gn,usageStatistics:c})).type=null,r.options=Zn,r._els={shapeSelectButton:r.selector(".tie-shape-button"),shapeColorButton:r.selector(".tie-shape-color-button"),strokeRange:new Wn({slider:r.selector(".tie-stroke-range"),input:r.selector(".tie-stroke-range-value")},xi),fillColorpicker:new Rn(r.selector(".tie-color-fill"),{defaultColor:"",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),strokeColorpicker:new Rn(r.selector(".tie-color-stroke"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics})},r.colorPickerControls.push(r._els.fillColorpicker),r.colorPickerControls.push(r._els.strokeColorpicker),r.colorPickerInputBoxes=[],r.colorPickerInputBoxes.push(r._els.fillColorpicker.colorpickerElement.querySelector(Me)),r.colorPickerInputBoxes.push(r._els.strokeColorpicker.colorpickerElement.querySelector(Me)),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.strokeRange.destroy(),this._els.fillColorpicker.destroy(),this._els.strokeColorpicker.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a,s=this;this.eventHandler.shapeTypeSelected=A()(e=this._changeShapeHandler).call(e,this),this.actions=t,this._els.shapeSelectButton.addEventListener("click",this.eventHandler.shapeTypeSelected),this._els.strokeRange.on("change",A()(i=this._changeStrokeRangeHandler).call(i,this)),this._els.fillColorpicker.on("change",A()(n=this._changeFillColorHandler).call(n,this)),this._els.strokeColorpicker.on("change",A()(r=this._changeStrokeColorHandler).call(r,this)),this._els.fillColorpicker.on("changeShow",A()(o=this.colorPickerChangeShow).call(o,this)),this._els.strokeColorpicker.on("changeShow",A()(a=this.colorPickerChangeShow).call(a,this)),Ln()(this.colorPickerInputBoxes,(function(t){var e,i;t.addEventListener(Ie,A()(e=s._onStartEditingInputBox).call(e,s)),t.addEventListener(_e,A()(i=s._onStopEditingInputBox).call(i,s))}),this)}},{key:"_removeEvent",value:function(){var t=this;this._els.shapeSelectButton.removeEventListener("click",this.eventHandler.shapeTypeSelected),this._els.strokeRange.off(),this._els.fillColorpicker.off(),this._els.strokeColorpicker.off(),Ln()(this.colorPickerInputBoxes,(function(e){var i,n;e.removeEventListener(Ie,A()(i=t._onStartEditingInputBox).call(i,t)),e.removeEventListener(_e,A()(n=t._onStopEditingInputBox).call(n,t))}),this)}},{key:"setShapeStatus",value:function(t){var e=t.strokeWidth,i=t.strokeColor,n=t.fillColor;this._els.strokeRange.value=e,this._els.strokeColorpicker.color=i,this._els.fillColorpicker.color=n,this.options.stroke=i,this.options.fill=n,this.options.strokeWidth=e,this.actions.setDrawingShape(this.type,{strokeWidth:e})}},{key:"changeStartMode",value:function(){this.actions.stopDrawingMode()}},{key:"changeStandbyMode",value:function(){this.type=null,this.actions.changeSelectableAll(!0),this._els.shapeSelectButton.classList.remove("circle"),this._els.shapeSelectButton.classList.remove("triangle"),this._els.shapeSelectButton.classList.remove("rect")}},{key:"setMaxStrokeValue",value:function(t){var e=t;e<=0&&(e=xi.max),this._els.strokeRange.max=e}},{key:"setStrokeValue",value:function(t){this._els.strokeRange.value=t,this._els.strokeRange.trigger("change")}},{key:"getStrokeValue",value:function(){return this._els.strokeRange.value}},{key:"_changeShapeHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){this.actions.stopDrawingMode(),this.actions.discardSelection();var i=this.getButtonType(e,["circle","triangle","rect"]);if(this.type===i)return void this.changeStandbyMode();this.changeStandbyMode(),this.type=i,t.currentTarget.classList.add(i),this.actions.changeSelectableAll(!1),this.actions.modeChange("shape")}}},{key:"_changeStrokeRangeHandler",value:function(t,e){this.options.strokeWidth=Bi(t),this.actions.changeShape({strokeWidth:t},!e),this.actions.setDrawingShape(this.type,this.options)}},{key:"_changeFillColorHandler",value:function(t){t=t||"transparent",this.options.fill=t,this.actions.changeShape({fill:t})}},{key:"_changeStrokeColorHandler",value:function(t){t=t||"transparent",this.options.stroke=t,this.actions.changeShape({stroke:t})}}]),i}(Un),Jn=Vn,Qn=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y=t.locale,b=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-crop-preset-button">\n <div class="tui-image-editor-button preset preset-none active">\n <div>\n '.concat(b(["normal","active"],"shape-rectangle",!0),"\n </div>\n <label> ")).call(m,y.localize("Custom"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-square">\n <div>\n ')).call(p,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(v,y.localize("Square"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-3-2">\n <div>\n ')).call(d,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(g,y.localize("3:2"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-4-3">\n <div>\n ')).call(f,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(h,y.localize("4:3"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-5-4">\n <div>\n ')).call(u,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(l,y.localize("5:4"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-7-5">\n <div>\n ')).call(c,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(s,y.localize("7:5"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-16-9">\n <div>\n ')).call(a,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(o,y.localize("16:9"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline">\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tie-crop-button action">\n <div class="tui-image-editor-button apply">\n ')).call(r,b(["normal","active"],"apply"),"\n <label>\n ")).call(n,y.localize("Apply"),'\n </label>\n </div>\n <div class="tui-image-editor-button cancel">\n ')).call(i,b(["normal","active"],"cancel"),"\n <label>\n ")).call(e,y.localize("Cancel"),"\n </label>\n </div>\n </li>\n </ul>\n")};function Kn(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var qn=function(t){wn(i,t);var e=Kn(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"crop",makeSvgIcon:a,menuBarPosition:s,templateHtml:Qn,usageStatistics:c})).status="active",r._els={apply:r.selector(".tie-crop-button .apply"),cancel:r.selector(".tie-crop-button .cancel"),preset:r.selector(".tie-crop-preset-button")},r.defaultPresetButton=r._els.preset.querySelector(".preset-none"),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r=A()(e=this._applyEventHandler).call(e,this),o=A()(i=this._cancelEventHandler).call(i,this),a=A()(n=this._cropzonePresetEventHandler).call(n,this);this.eventHandler={apply:r,cancel:o,cropzonePreset:a},this.actions=t,this._els.apply.addEventListener("click",r),this._els.cancel.addEventListener("click",o),this._els.preset.addEventListener("click",a)}},{key:"_removeEvent",value:function(){this._els.apply.removeEventListener("click",this.eventHandler.apply),this._els.cancel.removeEventListener("click",this.eventHandler.cancel),this._els.preset.removeEventListener("click",this.eventHandler.cropzonePreset)}},{key:"_applyEventHandler",value:function(){this.actions.crop(),this._els.apply.classList.remove("active")}},{key:"_cancelEventHandler",value:function(){this.actions.cancel(),this._els.apply.classList.remove("active")}},{key:"_cropzonePresetEventHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button.preset");if(e){var i=Q(e.className.match(/preset-[^\s]+/),1)[0];this._setPresetButtonActive(e),this.actions.preset(i)}}},{key:"changeStartMode",value:function(){this.actions.modeChange("crop")}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode(),this._setPresetButtonActive()}},{key:"changeApplyButtonStatus",value:function(t){t?this._els.apply.classList.add("active"):this._els.apply.classList.remove("active")}},{key:"_setPresetButtonActive",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultPresetButton;H()(this._els.preset.querySelectorAll(".preset"),(function(t){t.classList.remove("active")})),t&&t.classList.add("active")}}]),i}(Un),$n=qn,tr=function(t){var e,i,n,r,o,a,s=t.locale,c=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a='\n <ul class="tui-image-editor-submenu-item">\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-range-wrap tui-image-editor-newline">\n <label class="range">'.concat(s.localize("Width"),'&nbsp;</label>\n <div class="tie-width-range"></div>\n <input class="tie-width-range-value tui-image-editor-range-value" value="0" /> <label>px</label>\n <div class="tui-image-editor-partition tui-image-editor-newline"></div>\n <label class="range">')).call(a,s.localize("Height"),'</label>\n <div class="tie-height-range"></div>\n <input class="tie-height-range-value tui-image-editor-range-value" value="0" /> <label>px</label>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-lock-aspect-ratio">\n <span>')).call(o,s.localize("Lock Aspect Ratio"),'</span>\n </label>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tie-resize-button action">\n <div class="tui-image-editor-button apply">\n ')).call(r,c(["normal","active"],"apply"),"\n <label>\n ")).call(n,s.localize("Apply"),'\n </label>\n </div>\n <div class="tui-image-editor-button cancel">\n ')).call(i,c(["normal","active"],"cancel"),"\n <label>\n ")).call(e,s.localize("Cancel"),"\n </label>\n </div>\n </li>\n </ul>\n")};function er(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ir=function(t){wn(i,t);var e=er(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"resize",makeSvgIcon:a,menuBarPosition:s,templateHtml:tr,usageStatistics:c})).status="active",r._lockState=!1,r._originalDimensions=null,r._els={widthRange:new Wn({slider:r.selector(".tie-width-range"),input:r.selector(".tie-width-range-value")},ki),heightRange:new Wn({slider:r.selector(".tie-height-range"),input:r.selector(".tie-height-range-value")},ki),lockAspectRatio:r.selector(".tie-lock-aspect-ratio"),apply:r.selector(".tie-resize-button .apply"),cancel:r.selector(".tie-resize-button .cancel")},r}return T(i,[{key:"changeStartMode",value:function(){this.actions.modeChange("resize");var t=this.actions.getCurrentDimensions();this._originalDimensions=t,this.setWidthValue(t.width),this.setHeightValue(t.height),this.setLimit({minWidth:ki.min,minHeight:ki.min,maxWidth:t.width,maxHeight:t.height})}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode(),this.actions.reset(!0)}},{key:"setLimit",value:function(t){this._els.widthRange.min=this.calcMinValue(t.minWidth),this._els.heightRange.min=this.calcMinValue(t.minHeight),this._els.widthRange.max=this.calcMaxValue(t.maxWidth),this._els.heightRange.max=this.calcMaxValue(t.maxHeight)}},{key:"calcMaxValue",value:function(t){return t<=0&&(t=ki.max),t}},{key:"calcMinValue",value:function(t){return t<=0&&(t=ki.min),t}},{key:"setWidthValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._els.widthRange.value=t,e&&this._els.widthRange.trigger("change")}},{key:"setHeightValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._els.heightRange.value=t,e&&this._els.heightRange.trigger("change")}},{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o;this._els.widthRange.on("change",A()(e=this._changeWidthRangeHandler).call(e,this)),this._els.heightRange.on("change",A()(i=this._changeHeightRangeHandler).call(i,this)),this._els.lockAspectRatio.addEventListener("change",A()(n=this._changeLockAspectRatio).call(n,this));var a=A()(r=this._applyEventHandler).call(r,this),s=A()(o=this._cancelEventHandler).call(o,this);this.eventHandler={apply:a,cancel:s},this.actions=t,this._els.apply.addEventListener("click",a),this._els.cancel.addEventListener("click",s)}},{key:"_changeWidthRangeHandler",value:function(t){this.actions.preview("width",Bi(t),this._lockState)}},{key:"_changeHeightRangeHandler",value:function(t){this.actions.preview("height",Bi(t),this._lockState)}},{key:"_changeLockAspectRatio",value:function(t){this._lockState=t.target.checked,this.actions.lockAspectRatio(this._lockState)}},{key:"_removeEvent",value:function(){this._els.apply.removeEventListener("click",this.eventHandler.apply),this._els.cancel.removeEventListener("click",this.eventHandler.cancel)}},{key:"_applyEventHandler",value:function(){this.actions.resize(),this._els.apply.classList.remove("active")}},{key:"_cancelEventHandler",value:function(){this.actions.reset(),this._els.cancel.classList.remove("active")}},{key:"changeApplyButtonStatus",value:function(t){t?this._els.apply.classList.add("active"):this._els.apply.classList.remove("active")}}]),i}(Un),nr=ir,rr=function(t){var e,i,n,r,o,a=t.locale,s=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tie-flip-button tui-image-editor-submenu-item">\n <li>\n <div class="tui-image-editor-button flipX">\n <div>\n '.concat(s(["normal","active"],"flip-x",!0),"\n </div>\n <label>\n ")).call(o,a.localize("Flip X"),'\n </label>\n </div>\n <div class="tui-image-editor-button flipY">\n <div>\n ')).call(r,s(["normal","active"],"flip-y",!0),"\n </div>\n <label>\n ")).call(n,a.localize("Flip Y"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tui-image-editor-button resetFlip">\n <div>\n ')).call(i,s(["normal","active"],"flip-reset",!0),"\n </div>\n <label>\n ")).call(e,a.localize("Reset"),"\n </label>\n </div>\n </li>\n </ul>\n")};function or(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ar=function(t){wn(i,t);var e=or(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"flip",makeSvgIcon:a,menuBarPosition:s,templateHtml:rr,usageStatistics:c})).flipStatus=!1,r._els={flipButton:r.selector(".tie-flip-button")},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e;this.eventHandler.changeFlip=A()(e=this._changeFlip).call(e,this),this._actions=t,this._els.flipButton.addEventListener("click",this.eventHandler.changeFlip)}},{key:"_removeEvent",value:function(){this._els.flipButton.removeEventListener("click",this.eventHandler.changeFlip)}},{key:"_changeFlip",value:function(t){var e=this,i=t.target.closest(".tui-image-editor-button");if(i){var n=this.getButtonType(i,["flipX","flipY","resetFlip"]);if(!this.flipStatus&&"resetFlip"===n)return;this._actions.flip(n).then((function(t){var i=e._els.flipButton.classList;e.flipStatus=!1,i.remove("resetFlip"),H()(["flipX","flipY"],(function(n){i.remove(n),t[n]&&(i.add(n),i.add("resetFlip"),e.flipStatus=!0)}))}))}}}]),i}(Un),sr=ar,cr=function(t){var e,i,n=t.locale,r=t.makeSvgIcon;return O()(e=O()(i='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-rotate-button">\n <div class="tui-image-editor-button clockwise">\n <div>\n '.concat(r(["normal","active"],"rotate-clockwise",!0),'\n </div>\n <label> 30 </label>\n </div>\n <div class="tui-image-editor-button counterclockwise">\n <div>\n ')).call(i,r(["normal","active"],"rotate-counterclockwise",!0),'\n </div>\n <label> -30 </label>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,n.localize("Range"),'</label>\n <div class="tie-rotate-range"></div>\n <input class="tie-rotate-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function lr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ur=function(t){wn(i,t);var e=lr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"rotate",makeSvgIcon:a,menuBarPosition:s,templateHtml:cr,usageStatistics:c}))._value=0,r._els={rotateButton:r.selector(".tie-rotate-button"),rotateRange:new Wn({slider:r.selector(".tie-rotate-range"),input:r.selector(".tie-rotate-range-value")},yi)},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.rotateRange.destroy(),Wi(this)}},{key:"setRangeBarAngle",value:function(t,e){var i=e;"rotate"===t&&(i=$()(this._els.rotateRange.value,10)+e),this._setRangeBarRatio(i)}},{key:"_setRangeBarRatio",value:function(t){this._els.rotateRange.value=t}},{key:"addEvent",value:function(t){var e,i;this.eventHandler.rotationAngleChanged=A()(e=this._changeRotateForButton).call(e,this),this.actions=t,this._els.rotateButton.addEventListener("click",this.eventHandler.rotationAngleChanged),this._els.rotateRange.on("change",A()(i=this._changeRotateForRange).call(i,this))}},{key:"_removeEvent",value:function(){this._els.rotateButton.removeEventListener("click",this.eventHandler.rotationAngleChanged),this._els.rotateRange.off()}},{key:"_changeRotateForRange",value:function(t,e){var i=Bi(t);this.actions.setAngle(i,!e),this._value=i}},{key:"_changeRotateForButton",value:function(t){var e=t.target.closest(".tui-image-editor-button"),i=this._els.rotateRange.value;if(e){var n={clockwise:30,counterclockwise:-30}[this.getButtonType(e,["counterclockwise","clockwise"])],r=$()(i,10)+n;r>=-360&&r<=360&&this.actions.rotate(n)}}}]),i}(Un),hr=ur,fr=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d=t.locale,v=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-text-effect-button">\n <div class="tui-image-editor-button bold">\n <div>\n '.concat(v(["normal","active"],"text-bold",!0),"\n </div>\n <label> ")).call(g,d.localize("Bold"),' </label>\n </div>\n <div class="tui-image-editor-button italic">\n <div>\n ')).call(f,v(["normal","active"],"text-italic",!0),"\n </div>\n <label> ")).call(h,d.localize("Italic"),' </label>\n </div>\n <div class="tui-image-editor-button underline">\n <div>\n ')).call(u,v(["normal","active"],"text-underline",!0),"\n </div>\n <label> ")).call(l,d.localize("Underline"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-text-align-button">\n <div class="tui-image-editor-button left">\n <div>\n ')).call(c,v(["normal","active"],"text-align-left",!0),"\n </div>\n <label> ")).call(s,d.localize("Left"),' </label>\n </div>\n <div class="tui-image-editor-button center">\n <div>\n ')).call(a,v(["normal","active"],"text-align-center",!0),"\n </div>\n <label> ")).call(o,d.localize("Center"),' </label>\n </div>\n <div class="tui-image-editor-button right">\n <div>\n ')).call(r,v(["normal","active"],"text-align-right",!0),"\n </div>\n <label> ")).call(n,d.localize("Right"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-text-color" title="')).call(i,d.localize("Color"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,d.localize("Text size"),'</label>\n <div class="tie-text-range"></div>\n <input class="tie-text-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function gr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var dr=function(t){wn(i,t);var e=gr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"text",makeSvgIcon:a,menuBarPosition:s,templateHtml:fr,usageStatistics:c})).effect={bold:!1,italic:!1,underline:!1},r.align="tie-text-align-left",r._els={textEffectButton:r.selector(".tie-text-effect-button"),textAlignButton:r.selector(".tie-text-align-button"),textColorpicker:new Rn(r.selector(".tie-text-color"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),textRange:new Wn({slider:r.selector(".tie-text-range"),input:r.selector(".tie-text-range-value")},Ci)},r.colorPickerInputBox=r._els.textColorpicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.textColorpicker.destroy(),this._els.textRange.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a,s=A()(e=this._setTextEffectHandler).call(e,this),c=A()(i=this._setTextAlignHandler).call(i,this);this.eventHandler={setTextEffect:s,setTextAlign:c},this.actions=t,this._els.textEffectButton.addEventListener("click",s),this._els.textAlignButton.addEventListener("click",c),this._els.textRange.on("change",A()(n=this._changeTextRnageHandler).call(n,this)),this._els.textColorpicker.on("change",A()(r=this._changeColorHandler).call(r,this)),this.colorPickerInputBox.addEventListener(Ie,A()(o=this._onStartEditingInputBox).call(o,this)),this.colorPickerInputBox.addEventListener(_e,A()(a=this._onStopEditingInputBox).call(a,this))}},{key:"_removeEvent",value:function(){var t,e,i=this.eventHandler,n=i.setTextEffect,r=i.setTextAlign;this._els.textEffectButton.removeEventListener("click",n),this._els.textAlignButton.removeEventListener("click",r),this._els.textRange.off(),this._els.textColorpicker.off(),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode()}},{key:"changeStartMode",value:function(){this.actions.modeChange("text")}},{key:"textColor",get:function(){return this._els.textColorpicker.color},set:function(t){this._els.textColorpicker.color=t}},{key:"fontSize",get:function(){return this._els.textRange.value},set:function(t){this._els.textRange.value=t}},{key:"fontStyle",get:function(){return this.effect.italic?"italic":"normal"}},{key:"fontWeight",get:function(){return this.effect.bold?"bold":"normal"}},{key:"underline",get:function(){return this.effect.underline}},{key:"setTextStyleStateOnAction",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=nt()(t),i=t.fontSize,n=t.fontStyle,r=t.fontWeight,o=t.textDecoration,a=t.textAlign;this.textColor=e,this.fontSize=i,this.setEffectState("italic",n),this.setEffectState("bold",r),this.setEffectState("underline",o),this.setAlignState("tie-text-align-".concat(a))}},{key:"setEffectState",value:function(t,e){var i="italic"===e||"bold"===e||"underline"===e,n=this._els.textEffectButton.querySelector(".tui-image-editor-button.".concat(t));this.effect[t]=i,n.classList[i?"add":"remove"]("active")}},{key:"setAlignState",value:function(t){var e=this._els.textAlignButton;e.classList.remove(this.align),e.classList.add(t),this.align=t}},{key:"_setTextEffectHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=Q(e.className.match(/(bold|italic|underline)/),1)[0],n={bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},underline:{textDecoration:"underline"}}[i];this.effect[i]=!this.effect[i],e.classList.toggle("active"),this.actions.changeTextStyle(n)}}},{key:"_setTextAlignHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=this.getButtonType(e,["left","center","right"]),n="tie-text-align-".concat(i);t.currentTarget.classList.remove(this.align),this.align!==n&&t.currentTarget.classList.add(n),this.actions.changeTextStyle({textAlign:i}),this.align=n}}},{key:"_changeTextRnageHandler",value:function(t,e){this.actions.changeTextStyle({fontSize:t},!e)}},{key:"_changeColorHandler",value:function(t){t=t||"transparent",this.actions.changeTextStyle({fill:t})}}]),i}(Un),vr=dr,pr=function(t){var e,i,n,r=t.locale,o=t.makeSvgIcon;return O()(e=O()(i=O()(n='\n <ul class="tui-image-editor-submenu-item">\n <li>\n <div class="tui-image-editor-button">\n <div>\n <input type="file" accept="image/*" class="tie-mask-image-file">\n '.concat(o(["normal","active"],"mask-load",!0),"\n </div>\n <label> ")).call(n,r.localize("Load Mask Image"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tie-mask-apply tui-image-editor-newline apply" style="margin-top: 22px;margin-bottom: 5px">\n <div class="tui-image-editor-button apply">\n ')).call(i,o(["normal","active"],"apply"),"\n <label>\n ")).call(e,r.localize("Apply"),"\n </label>\n </div>\n </li>\n </ul>\n")};function mr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var yr=function(t){wn(i,t);var e=mr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"mask",makeSvgIcon:a,menuBarPosition:s,templateHtml:pr,usageStatistics:c}))._els={applyButton:r.selector(".tie-mask-apply"),maskImageButton:r.selector(".tie-mask-image-file")},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n=A()(e=this._loadMaskFile).call(e,this),r=A()(i=this._applyMask).call(i,this);this.eventHandler={loadMaskFile:n,applyMask:r},this.actions=t,this._els.maskImageButton.addEventListener("change",n),this._els.applyButton.addEventListener("click",r)}},{key:"_removeEvent",value:function(){this._els.maskImageButton.removeEventListener("change",this.eventHandler.loadMaskFile),this._els.applyButton.removeEventListener("click",this.eventHandler.applyMask)}},{key:"_applyMask",value:function(){this.actions.applyFilter(),this._els.applyButton.classList.remove("active")}},{key:"_loadMaskFile",value:function(t){var e;Fi()||alert("This browser does not support file-api");var i=Q(t.target.files,1)[0];i&&(e=P().createObjectURL(i),this.actions.loadImageFromURL(e,i),this._els.applyButton.classList.add("active"))}}]),i}(Un),br=yr,xr=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y,b,x,C=t.locale,I=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m=O()(y=O()(b=O()(x='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-icon-add-button">\n <div class="tui-image-editor-button" data-icontype="icon-arrow">\n <div>\n '.concat(I(["normal","active"],"icon-arrow",!0),"\n </div>\n <label>\n ")).call(x,C.localize("Arrow"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-arrow-2">\n <div>\n ')).call(b,I(["normal","active"],"icon-arrow-2",!0),"\n </div>\n <label>\n ")).call(y,C.localize("Arrow-2"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-arrow-3">\n <div>\n ')).call(m,I(["normal","active"],"icon-arrow-3",!0),"\n </div>\n <label>\n ")).call(p,C.localize("Arrow-3"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-star">\n <div>\n ')).call(v,I(["normal","active"],"icon-star",!0),"\n </div>\n <label>\n ")).call(d,C.localize("Star-1"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-star-2">\n <div>\n ')).call(g,I(["normal","active"],"icon-star-2",!0),"\n </div>\n <label>\n ")).call(f,C.localize("Star-2"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-polygon">\n <div>\n ')).call(h,I(["normal","active"],"icon-polygon",!0),"\n </div>\n <label>\n ")).call(u,C.localize("Polygon"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-location">\n <div>\n ')).call(l,I(["normal","active"],"icon-location",!0),"\n </div>\n <label>\n ")).call(c,C.localize("Location"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-heart">\n <div>\n ')).call(s,I(["normal","active"],"icon-heart",!0),"\n </div>\n <label>\n ")).call(a,C.localize("Heart"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-bubble">\n <div>\n ')).call(o,I(["normal","active"],"icon-bubble",!0),"\n </div>\n <label>\n ")).call(r,C.localize("Bubble"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-icon-add-button">\n <div class="tui-image-editor-button" style="margin:0">\n <div>\n <input type="file" accept="image/*" class="tie-icon-image-file">\n ')).call(n,I(["normal","active"],"icon-load",!0),"\n </div>\n <label>\n ")).call(i,C.localize("Custom icon"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-icon-color" title="')).call(e,C.localize("Color"),'"></div>\n </li>\n </ul>\n')};function Cr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ir=function(t){wn(i,t);var e=Cr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"icon",makeSvgIcon:a,menuBarPosition:s,templateHtml:xr,usageStatistics:c})).iconType=null,r._iconMap={},r._els={registerIconButton:r.selector(".tie-icon-image-file"),addIconButton:r.selector(".tie-icon-add-button"),iconColorpicker:new Rn(r.selector(".tie-icon-color"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics})},r.colorPickerInputBox=r._els.iconColorpicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.iconColorpicker.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a=A()(e=this._registerIconHandler).call(e,this),s=A()(i=this._addIconHandler).call(i,this);this.eventHandler={registerIcon:a,addIcon:s},this.actions=t,this._els.iconColorpicker.on("change",A()(n=this._changeColorHandler).call(n,this)),this._els.registerIconButton.addEventListener("change",a),this._els.addIconButton.addEventListener("click",s),this.colorPickerInputBox.addEventListener(Ie,A()(r=this._onStartEditingInputBox).call(r,this)),this.colorPickerInputBox.addEventListener(_e,A()(o=this._onStopEditingInputBox).call(o,this))}},{key:"_removeEvent",value:function(){var t,e;this._els.iconColorpicker.off(),this._els.registerIconButton.removeEventListener("change",this.eventHandler.registerIcon),this._els.addIconButton.removeEventListener("click",this.eventHandler.addIcon),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"clearIconType",value:function(){this._els.addIconButton.classList.remove(this.iconType),this.iconType=null}},{key:"registerDefaultIcon",value:function(){var t=this;H()(mi,(function(e,i){t.actions.registerDefaultIcons(i,e)}))}},{key:"setIconPickerColor",value:function(t){this._els.iconColorpicker.color=t}},{key:"changeStandbyMode",value:function(){this.clearIconType(),this.actions.cancelAddIcon()}},{key:"_changeColorHandler",value:function(t){t=t||"transparent",this.actions.changeColor(t)}},{key:"_addIconHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=e.getAttribute("data-icontype"),n=this._els.iconColorpicker.color;this.actions.discardSelection(),this.actions.changeSelectableAll(!1),this._els.addIconButton.classList.remove(this.iconType),this._els.addIconButton.classList.add(i),this.iconType===i?this.changeStandbyMode():(this.actions.addIcon(i,n),this.iconType=i)}}},{key:"_registerIconHandler",value:function(t){var e;Fi||alert("This browser does not support file-api");var i=Q(t.target.files,1)[0];i&&(e=P().createObjectURL(i),this.actions.registerCustomIcon(e,i))}}]),i}(Un),_r=Ir,Mr=function(t){var e,i,n,r,o,a=t.locale,s=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-draw-line-select-button">\n <div class="tui-image-editor-button free">\n <div>\n '.concat(s(["normal","active"],"draw-free",!0),"\n </div>\n <label>\n ")).call(o,a.localize("Free"),'\n </label>\n </div>\n <div class="tui-image-editor-button line">\n <div>\n ')).call(r,s(["normal","active"],"draw-line",!0),"\n </div>\n <label>\n ")).call(n,a.localize("Straight"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-draw-color" title="')).call(i,a.localize("Color"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,a.localize("Range"),'</label>\n <div class="tie-draw-range"></div>\n <input class="tie-draw-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function Sr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var wr=function(t){wn(i,t);var e=Sr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"draw",makeSvgIcon:a,menuBarPosition:s,templateHtml:Mr,usageStatistics:c}))._els={lineSelectButton:r.selector(".tie-draw-line-select-button"),drawColorPicker:new Rn(r.selector(".tie-draw-color"),{defaultColor:"#00a9ff",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),drawRange:new Wn({slider:r.selector(".tie-draw-range"),input:r.selector(".tie-draw-range-value")},bi)},r.type=null,r.color=r._els.drawColorPicker.color,r.width=r._els.drawRange.value,r.colorPickerInputBox=r._els.drawColorPicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.drawColorPicker.destroy(),this._els.drawRange.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o;this.eventHandler.changeDrawType=A()(e=this._changeDrawType).call(e,this),this.actions=t,this._els.lineSelectButton.addEventListener("click",this.eventHandler.changeDrawType),this._els.drawColorPicker.on("change",A()(i=this._changeDrawColor).call(i,this)),this._els.drawRange.on("change",A()(n=this._changeDrawRange).call(n,this)),this.colorPickerInputBox.addEventListener(Ie,A()(r=this._onStartEditingInputBox).call(r,this)),this.colorPickerInputBox.addEventListener(_e,A()(o=this._onStopEditingInputBox).call(o,this))}},{key:"_removeEvent",value:function(){var t,e;this._els.lineSelectButton.removeEventListener("click",this.eventHandler.changeDrawType),this._els.drawColorPicker.off(),this._els.drawRange.off(),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"setDrawMode",value:function(){this.actions.setDrawMode(this.type,{width:this.width,color:Yi(this.color,.7)})}},{key:"changeStandbyMode",value:function(){this.type=null,this.actions.stopDrawingMode(),this.actions.changeSelectableAll(!0),this._els.lineSelectButton.classList.remove("free"),this._els.lineSelectButton.classList.remove("line")}},{key:"changeStartMode",value:function(){this.type="free",this._els.lineSelectButton.classList.add("free"),this.setDrawMode()}},{key:"_changeDrawType",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=this.getButtonType(e,["free","line"]);if(this.actions.discardSelection(),this.type===i)return void this.changeStandbyMode();this.changeStandbyMode(),this.type=i,this._els.lineSelectButton.classList.add(i),this.setDrawMode()}}},{key:"_changeDrawColor",value:function(t){this.color=t||"transparent",this.type?this.setDrawMode():this.changeStartMode()}},{key:"_changeDrawRange",value:function(t){this.width=t,this.type?this.setDrawMode():this.changeStartMode()}}]),i}(Un),kr=wr,Tr=n(7065),Dr=n.n(Tr),Ar=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m=t.locale;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p='\n <ul class="tui-image-editor-submenu-item">\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-wrap fixed-width">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-grayscale">\n <span>'.concat(m.localize("Grayscale"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-invert">\n <span>')).call(p,m.localize("Invert"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-sepia">\n <span>')).call(v,m.localize("Sepia"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-vintage">\n <span>')).call(d,m.localize("Sepia2"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-blur">\n <span>')).call(g,m.localize("Blur"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-sharpen">\n <span>')).call(f,m.localize("Sharpen"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-emboss">\n <span>')).call(h,m.localize("Emboss"),'</span>\n </label>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled" style="margin-bottom: 7px;">\n <div class="tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-remove-white">\n <span>')).call(u,m.localize("Remove White"),'</span>\n </label>\n </div>\n </div>\n <div class="tui-image-editor-newline tui-image-editor-range-wrap short">\n <label>')).call(l,m.localize("Distance"),'</label>\n <div class="tie-removewhite-distance-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-brightness">\n <span>')).call(c,m.localize("Brightness"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-brightness-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-noise">\n <span>')).call(s,m.localize("Noise"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-noise-range"></div>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-pixelate">\n <span>')).call(a,m.localize("Pixelate"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-pixelate-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-newline tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-color-filter">\n <span>')).call(o,m.localize("Color Filter"),'</span>\n </label>\n </div>\n </div>\n <div class="tui-image-editor-newline tui-image-editor-range-wrap short">\n <label>')).call(r,m.localize("Threshold"),'</label>\n <div class="tie-colorfilter-threshold-range"></div>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="filter-color-item">\n <div class="tie-filter-tint-color" title="')).call(n,m.localize("Tint"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-tint">\n <span></span>\n </label>\n </div>\n </div>\n <div class="filter-color-item">\n <div class="tie-filter-multiply-color" title="')).call(i,m.localize("Multiply"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-multiply">\n <span></span>\n </label>\n </div>\n </div>\n <div class="filter-color-item">\n <div class="tie-filter-blend-color" title="')).call(e,m.localize("Blend"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-blend">\n <span></span>\n </label>\n </div>\n </div>\n </li>\n </ul>\n')};function jr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Or="130px",Er=["add","diff","subtract","multiply","screen","lighten","darken"],Lr=["grayscale","invert","sepia","vintage","blur","sharpen","emboss","remove-white","brightness","noise","pixelate","color-filter","tint","multiply","blend"],Nr={grayscale:"grayscale",invert:"invert",sepia:"sepia",blur:"blur",sharpen:"sharpen",emboss:"emboss",removeWhite:"removeColor",brightness:"brightness",contrast:"contrast",saturation:"saturation",vintage:"vintage",polaroid:"polaroid",noise:"noise",pixelate:"pixelate",colorFilter:"removeColor",tint:"blendColor",multiply:"blendColor",blend:"blendColor",hue:"hue",gamma:"gamma"},Pr=["removewhiteDistanceRange","colorfilterThresholdRange","pixelateRange","noiseRange","brightnessRange","tintOpacity"],zr=["filterBlendColor","filterMultiplyColor","filterTintColor"],Br=function(t){wn(i,t);var e=jr(i);function i(t,n){var r,o=n.locale,a=n.menuBarPosition,s=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"filter",menuBarPosition:a,templateHtml:Ar,usageStatistics:s})).selectBoxShow=!1,r.checkedMap={},r._makeControlElement(),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._destroyToolInstance(),Wi(this)}},{key:"_removeEvent",value:function(){var t,e=this;H()(Lr,(function(t){var i=e.selector(".tie-".concat(t)),n=Ri(t);i.removeEventListener("change",e.eventHandler[n])})),H()(O()(t=[]).call(t,Pr,zr),(function(t){e._els[t].off()})),this._els.blendType.removeEventListener("change",this.eventHandler.changeBlendFilter),this._els.blendType.removeEventListener("click",this.eventHandler.changeBlendFilter),Ln()(this.colorPickerInputBoxes,(function(t){var i,n;t.removeEventListener(Ie,A()(i=e._onStartEditingInputBox).call(i,e)),t.removeEventListener(_e,A()(n=e._onStopEditingInputBox).call(n,e))}),this)}},{key:"_destroyToolInstance",value:function(){var t,e=this;H()(O()(t=[]).call(t,Pr,zr),(function(t){e._els[t].destroy()}))}},{key:"addEvent",value:function(t){var e,i,n,r=this,o=t.applyFilter,a=function(t){var e;return A()(e=r._changeFilterState).call(e,r,o,t)},s=function(t){return function(e,i){return r._changeFilterState(o,t,i)}};this.eventHandler={changeBlendFilter:a("blend"),blandTypeClick:function(t){return t.stopPropagation()}},H()(Lr,(function(t){var e=r.selector(".tie-".concat(t)),i=Ri(t);r.checkedMap[i]=e,r.eventHandler[i]=a(i),e.addEventListener("change",r.eventHandler[i])})),this._els.removewhiteDistanceRange.on("change",s("removeWhite")),this._els.colorfilterThresholdRange.on("change",s("colorFilter")),this._els.pixelateRange.on("change",s("pixelate")),this._els.noiseRange.on("change",s("noise")),this._els.brightnessRange.on("change",s("brightness")),this._els.filterBlendColor.on("change",this.eventHandler.changeBlendFilter),this._els.filterMultiplyColor.on("change",a("multiply")),this._els.filterTintColor.on("change",a("tint")),this._els.tintOpacity.on("change",s("tint")),this._els.filterMultiplyColor.on("changeShow",A()(e=this.colorPickerChangeShow).call(e,this)),this._els.filterTintColor.on("changeShow",A()(i=this.colorPickerChangeShow).call(i,this)),this._els.filterBlendColor.on("changeShow",A()(n=this.colorPickerChangeShow).call(n,this)),this._els.blendType.addEventListener("change",this.eventHandler.changeBlendFilter),this._els.blendType.addEventListener("click",this.eventHandler.blandTypeClick),Ln()(this.colorPickerInputBoxes,(function(t){var e,i;t.addEventListener(Ie,A()(e=r._onStartEditingInputBox).call(e,r)),t.addEventListener(_e,A()(i=r._onStopEditingInputBox).call(i,r))}),this)}},{key:"setFilterState",value:function(t){var e=t.type,i=t.options,n=t.action,r=this._getFilterNameFromOptions(e,i),o="remove"===n;o||this._setFilterState(r,i),this.checkedMap[r].checked=!o}},{key:"initFilterCheckBoxState",value:function(){H()(this.checkedMap,(function(t){t.checked=!1}),this)}},{key:"_setFilterState",value:function(t,e){"colorFilter"===t?this._els.colorfilterThresholdRange.value=e.distance:"removeWhite"===t?this._els.removewhiteDistanceRange.value=e.distance:"pixelate"===t?this._els.pixelateRange.value=e.blocksize:"brightness"===t?this._els.brightnessRange.value=e.brightness:"noise"===t?this._els.noiseRange.value=e.noise:"tint"===t?(this._els.tintOpacity.value=e.alpha,this._els.filterTintColor.color=e.color):"blend"===t?this._els.filterBlendColor.color=e.color:"multiply"===t&&(this._els.filterMultiplyColor.color=e.color)}},{key:"_getFilterNameFromOptions",value:function(t,e){var i=t;return"removeColor"===t?i=Dr()(e.useAlpha)?"removeWhite":"colorFilter":"blendColor"===t&&(i={add:"blend",multiply:"multiply",tint:"tint"}[e.mode]),i}},{key:"_changeFilterState",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.checkedMap[e].checked,r=Nr[e],o=this.checkedMap[e].closest(".tui-image-editor-checkbox-group");o&&(n?o.classList.remove("tui-image-editor-disabled"):o.classList.add("tui-image-editor-disabled")),t(n,r,this._getFilterOption(e),!i)}},{key:"_getFilterOption",value:function(t){var e={};switch(t){case"removeWhite":e.color="#FFFFFF",e.useAlpha=!1,e.distance=dn()(this._els.removewhiteDistanceRange.value);break;case"colorFilter":e.color="#FFFFFF",e.distance=dn()(this._els.colorfilterThresholdRange.value);break;case"pixelate":e.blocksize=Bi(this._els.pixelateRange.value);break;case"noise":e.noise=Bi(this._els.noiseRange.value);break;case"brightness":e.brightness=dn()(this._els.brightnessRange.value);break;case"blend":e.mode="add",e.color=this._els.filterBlendColor.color,e.mode=this._els.blendType.value;break;case"multiply":e.mode="multiply",e.color=this._els.filterMultiplyColor.color;break;case"tint":e.mode="tint",e.color=this._els.filterTintColor.color,e.alpha=this._els.tintOpacity.value;break;case"blur":e.blur=this._els.blurRange.value}return e}},{key:"_makeControlElement",value:function(){this._els={removewhiteDistanceRange:new Wn({slider:this.selector(".tie-removewhite-distance-range")},Ii.removewhiteDistanceRange),brightnessRange:new Wn({slider:this.selector(".tie-brightness-range")},Ii.brightnessRange),noiseRange:new Wn({slider:this.selector(".tie-noise-range")},Ii.noiseRange),pixelateRange:new Wn({slider:this.selector(".tie-pixelate-range")},Ii.pixelateRange),colorfilterThresholdRange:new Wn({slider:this.selector(".tie-colorfilter-threshold-range")},Ii.colorfilterThresholdRange),filterTintColor:new Rn(this.selector(".tie-filter-tint-color"),{defaultColor:"#03bd9e",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),filterMultiplyColor:new Rn(this.selector(".tie-filter-multiply-color"),{defaultColor:"#515ce6",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),filterBlendColor:new Rn(this.selector(".tie-filter-blend-color"),{defaultColor:"#ffbb3b",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),blurRange:Ii.blurFilterRange},this._els.tintOpacity=this._pickerWithRange(this._els.filterTintColor.pickerControl),this._els.blendType=this._pickerWithSelectbox(this._els.filterBlendColor.pickerControl),this.colorPickerControls.push(this._els.filterTintColor),this.colorPickerControls.push(this._els.filterMultiplyColor),this.colorPickerControls.push(this._els.filterBlendColor),this.colorPickerInputBoxes=[],this.colorPickerInputBoxes.push(this._els.filterTintColor.colorpickerElement.querySelector(Me)),this.colorPickerInputBoxes.push(this._els.filterMultiplyColor.colorpickerElement.querySelector(Me)),this.colorPickerInputBoxes.push(this._els.filterBlendColor.colorpickerElement.querySelector(Me))}},{key:"_pickerWithRange",value:function(t){var e=document.createElement("div"),i=document.createElement("label"),n=document.createElement("div");return n.id="tie-filter-tint-opacity",i.innerHTML="Opacity",e.appendChild(i),e.appendChild(n),t.appendChild(e),t.style.height=Or,new Wn({slider:n},Ii.tintOpacityRange)}},{key:"_pickerWithSelectbox",value:function(t){var e=document.createElement("div"),i=document.createElement("select"),n=document.createElement("ul");return e.className="tui-image-editor-selectlist-wrap",n.className="tui-image-editor-selectlist",e.appendChild(i),e.appendChild(n),this._makeSelectOptionList(i),t.appendChild(e),t.style.height=Or,this._drawSelectOptionList(i,n),this._pickerWithSelectboxForAddEvent(i,n),i}},{key:"_drawSelectOptionList",value:function(t,e){var i=t.querySelectorAll("option");H()(i,(function(t){var i=document.createElement("li");i.innerHTML=t.innerHTML,i.setAttribute("data-item",t.value),e.appendChild(i)}))}},{key:"_pickerWithSelectboxForAddEvent",value:function(t,e){var i=this;e.addEventListener("click",(function(n){var r=n.target.getAttribute("data-item"),o=document.createEvent("HTMLEvents");t.querySelector('[value="'.concat(r,'"]')).selected=!0,o.initEvent("change",!0,!0),t.dispatchEvent(o),i.selectBoxShow=!1,e.style.display="none"})),t.addEventListener("mousedown",(function(n){n.preventDefault(),i.selectBoxShow=!i.selectBoxShow,e.style.display=i.selectBoxShow?"block":"none",e.setAttribute("data-selectitem",t.value),e.querySelector("[data-item='".concat(t.value,"']")).classList.add("active")}))}},{key:"_makeSelectOptionList",value:function(t){H()(Er,(function(e){var i=document.createElement("option");i.setAttribute("value",e),i.innerHTML=e.replace(/^[a-z]/,(function(t){return t.toUpperCase()})),t.appendChild(i)}))}}]),i}(Un),Rr=Br,Fr=n(4383),Yr=n.n(Fr);function Wr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Hr="selected-item",Ur="disabled-item",Gr=function(t){wn(i,t);var e=Wr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon;return w(this,i),r=e.call(this,t,{name:"history"}),t.classList.add("enabled"),r.locale=o,r.makeSvgIcon=a,r._eventHandler={},r._historyIndex=r.getListLength(),r}return T(i,[{key:"add",value:function(t){var e=t.name,i=t.detail;this._hasDisabledItem()&&this.deleteListItemElement(this._historyIndex+1,this.getListLength());var n=function(t){var e,i,n,r=t.locale,o=t.makeSvgIcon,a=t.name,s=t.detail;return O()(e=O()(i=O()(n='\n <div class="tui-image-editor-history-item history">\n <div class="history-item-icon">\n '.concat(o(["normal","active"],"history-".concat(a.toLowerCase()),!0),"\n </div>\n <span>\n ")).call(n,r.localize(a),"\n ")).call(i,s?"(".concat(r.localize(s),")"):"",'\n </span>\n <div class="history-item-checkbox">\n ')).call(e,o(["normal"],"history-check",!0),"\n </div>\n </div>\n")}({locale:this.locale,makeSvgIcon:this.makeSvgIcon,name:e,detail:i}),r=this.makeListItemElement(n);this.pushListItemElement(r),this._historyIndex=this.getListLength()-1,this._selectItem(this._historyIndex)}},{key:"init",value:function(){this.deleteListItemElement(1,this.getListLength()),this._historyIndex=0,this._selectItem(this._historyIndex)}},{key:"clear",value:function(){this.deleteListItemElement(0,this.getListLength()),this._historyIndex=-1}},{key:"prev",value:function(){this._historyIndex-=1,this._selectItem(this._historyIndex)}},{key:"next",value:function(){this._historyIndex+=1,this._selectItem(this._historyIndex)}},{key:"_hasDisabledItem",value:function(){return this.getListLength()-1>this._historyIndex}},{key:"_addHistoryEventListener",value:function(){var t=this;this._eventHandler.history=function(e){return t._clickHistoryItem(e)},this.listElement.addEventListener("click",this._eventHandler.history)}},{key:"_removeHistoryEventListener",value:function(){this.listElement.removeEventListener("click",this._eventHandler.history)}},{key:"_clickHistoryItem",value:function(t){var e=t.target.closest(".".concat("history-item"));if(e){var i=Yr()(e.getAttribute("data-index"),10);if(i!==this._historyIndex){var n=Math.abs(i-this._historyIndex);i<this._historyIndex?this._actions.undo(n):this._actions.redo(n)}}}},{key:"_selectItem",value:function(t){for(var e=0;e<this.getListLength();e+=1)this.removeClass(e,Hr),this.removeClass(e,Ur),e>t&&this.addClass(e,Ur);this.addClass(t,Hr)}},{key:"destroy",value:function(){this.removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){this._actions=t,this._addHistoryEventListener()}},{key:"removeEvent",value:function(){this._removeHistoryEventListener()}}]),i}(function(){function t(e,i){var n=i.name;w(this,t),this.name=n,this.items=[],this.panelElement=this._makePanelElement(),this.listElement=this._makeListElement(),this.panelElement.appendChild(this.listElement),e.appendChild(this.panelElement)}return T(t,[{key:"_makePanelElement",value:function(){var t=document.createElement("div");return t.className="tie-panel-".concat(this.name),t}},{key:"_makeListElement",value:function(){var t=document.createElement("ol");return t.className="".concat(this.name,"-list"),t}},{key:"makeListItemElement",value:function(t){var e=document.createElement("li");return e.innerHTML=t,e.className="".concat(this.name,"-item"),e.setAttribute("data-index",this.items.length),e}},{key:"pushListItemElement",value:function(t){this.listElement.appendChild(t),this.listElement.scrollTop+=t.offsetHeight,this.items.push(t)}},{key:"deleteListItemElement",value:function(t,e){for(var i=this.items,n=t;n<e;n+=1)this.listElement.removeChild(i[n]);s()(i).call(i,t,e-t+1)}},{key:"getListLength",value:function(){return this.items.length}},{key:"addClass",value:function(t,e){this.items[t]&&this.items[t].classList.add(e)}},{key:"removeClass",value:function(t,e){this.items[t]&&this.items[t].classList.remove(e)}},{key:"toggleClass",value:function(t,e){this.items[t]&&this.items[t].classList.toggle(e)}}]),t}()),Xr=Gr,Zr=function(){function t(e){w(this,t),this._locale=e}return T(t,[{key:"localize",value:function(t){return this._locale[t]||t}}]),t}(),Vr=Zr,Jr={Shape:Jn,Crop:$n,Resize:nr,Flip:sr,Rotate:hr,Text:vr,Mask:br,Icon:_r,Draw:kr,Filter:Rr},Qr="1300",Kr="on",qr="zoomIn",$r="hand",to=function(){function t(e,i,n){w(this,t),this.options=this._initializeOption(i),this._actions=n,this.submenu=!1,this.imageSize={},this.uiSize={},this._locale=new Vr(this.options.locale),this.theme=new xn(this.options.theme),this.eventHandler={},this._submenuChangeTransection=!1,this._selectedElement=null,this._mainElement=null,this._editorElementWrap=null,this._editorElement=null,this._menuBarElement=null,this._subMenuElement=null,this._makeUiElement(e),this._setUiSize(),this._initMenuEvent=!1,this._makeSubMenu(),this._attachHistoryEvent(),this._attachZoomEvent()}return T(t,[{key:"destroy",value:function(){this._removeUiEvent(),this._destroyAllMenu(),this._selectedElement.innerHTML="",Wi(this)}},{key:"setUiDefaultSelectionStyle",value:function(t){return R()({applyCropSelectionStyle:!0,applyGroupSelectionStyle:!0,selectionStyle:{cornerStyle:"circle",cornerSize:16,cornerColor:"#fff",cornerStrokeColor:"#fff",transparentCorners:!1,lineWidth:2,borderColor:"#fff"}},t)}},{key:"resizeEditor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.uiSize,i=t.imageSize,n=void 0===i?this.imageSize:i;n!==this.imageSize&&(this.imageSize=n),e&&this._setUiSize(e);var r=this._getCanvasMaxDimension(),o=r.width,a=r.height,s=this._editorElement.style,c=this.options.menuBarPosition;s.height="".concat(a,"px"),s.width="".concat(o,"px"),this._setEditorPosition(c),this._editorElementWrap.style.bottom="0px",this._editorElementWrap.style.top="0px",this._editorElementWrap.style.left="0px",this._editorElementWrap.style.width="100%";var l=this._selectedElement.classList;"top"===c&&this._selectedElement.offsetWidth<Qr?l.add("tui-image-editor-top-optimization"):l.remove("tui-image-editor-top-optimization")}},{key:"toggleZoomButtonStatus",value:function(t){this._buttonElements[t].classList.toggle(Kr),t===qr?this._buttonElements[$r].classList.remove(Kr):this._buttonElements[qr].classList.remove(Kr)}},{key:"offZoomInButtonStatus",value:function(){this._buttonElements[qr].classList.remove(Kr)}},{key:"changeHandButtonStatus",value:function(t){this._buttonElements[$r].classList[t?"add":"remove"](Kr)}},{key:"changeHelpButtonEnabled",value:function(t,e){this._buttonElements[t].classList[e?"add":"remove"]("enabled")}},{key:"_initializeOption",value:function(t){return R()({loadImage:{path:"",name:""},locale:{},menuIconPath:"",menu:["resize","crop","flip","rotate","draw","shape","icon","text","mask","filter"],initMenu:"",uiSize:{width:"100%",height:"100%"},menuBarPosition:"bottom"},t)}},{key:"_setUiSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.uiSize,e=this._selectedElement.style;e.width=t.width,e.height=t.height}},{key:"_makeSubMenu",value:function(){var t=this;H()(this.options.menu,(function(e){var i,n=Jr[e.replace(/^[a-z]/,(function(t){return t.toUpperCase()}))];t._makeMenuElement(e),t._buttonElements[e]=t._menuBarElement.querySelector(".tie-btn-".concat(e)),t[e]=new n(t._subMenuElement,{locale:t._locale,makeSvgIcon:A()(i=t.theme.makeMenSvgIconSet).call(i,t.theme),menuBarPosition:t.options.menuBarPosition,usageStatistics:t.options.usageStatistics})}))}},{key:"_attachHistoryEvent",value:function(){var t,e,i;this.on(fe,A()(t=this._addHistory).call(t,this)),this.on(ge,A()(e=this._selectPrevHistory).call(e,this)),this.on(de,A()(i=this._selectNextHistory).call(i,this))}},{key:"_attachZoomEvent",value:function(){var t=this;this.on(pe,(function(){t.offZoomInButtonStatus(),t.changeHandButtonStatus(!0)})),this.on(me,(function(){return t.changeHandButtonStatus(!1)}))}},{key:"_makeUiElement",value:function(t){var e,i;i=t.nodeType?t:document.querySelector(t);var n,r=(n=i,function(t){return n.querySelector(t)});i.classList.add("tui-image-editor-container"),i.innerHTML=function(t){var e,i,n,r,o,a,s=t.locale,c=t.biImage,l=t.loadButtonStyle,u=t.downloadButtonStyle,h=t.menuBarPosition;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tui-image-editor-help-menu '.concat((a=h,"top"===a?"bottom":"left"===a?"right":"right"===a?"left":"top"),'"></ul>\n <div class="tui-image-editor-controls">\n <div class="tui-image-editor-controls-logo">\n <img src="')).call(o,c,'" />\n </div>\n <ul class="tui-image-editor-menu"></ul>\n\n <div class="tui-image-editor-controls-buttons">\n <div style="')).call(r,l,'">\n ')).call(n,s.localize("Load"),'\n <input type="file" class="tui-image-editor-load-btn" />\n </div>\n <button class="tui-image-editor-download-btn" style="')).call(i,u,'">\n ')).call(e,s.localize("Download"),"\n </button>\n </div>\n </div>\n")}({locale:this._locale,biImage:this.theme.getStyle("common.bi"),loadButtonStyle:this.theme.getStyle("loadButton"),downloadButtonStyle:this.theme.getStyle("downloadButton"),menuBarPosition:this.options.menuBarPosition})+function(t){var e,i,n,r,o,a,s,c=t.locale,l=t.biImage,u=t.commonStyle,h=t.headerStyle,f=t.loadButtonStyle,g=t.downloadButtonStyle,d=t.submenuStyle;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s='\n <div class="tui-image-editor-main-container" style="'.concat(u,'">\n <div class="tui-image-editor-header" style="')).call(s,h,'">\n <div class="tui-image-editor-header-logo">\n <img src="')).call(a,l,'" />\n </div>\n <div class="tui-image-editor-header-buttons">\n <div style="')).call(o,f,'">\n ')).call(r,c.localize("Load"),'\n <input type="file" class="tui-image-editor-load-btn" />\n </div>\n <button class="tui-image-editor-download-btn" style="')).call(n,g,'">\n ')).call(i,c.localize("Download"),'\n </button>\n </div>\n </div>\n <div class="tui-image-editor-main">\n <div class="tui-image-editor-submenu">\n <div class="tui-image-editor-submenu-style" style="')).call(e,d,'"></div>\n </div>\n <div class="tui-image-editor-wrap">\n <div class="tui-image-editor-size-wrap">\n <div class="tui-image-editor-align-wrap">\n <div class="tui-image-editor"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n')}({locale:this._locale,biImage:this.theme.getStyle("common.bi"),commonStyle:this.theme.getStyle("common"),headerStyle:this.theme.getStyle("header"),loadButtonStyle:this.theme.getStyle("loadButton"),downloadButtonStyle:this.theme.getStyle("downloadButton"),submenuStyle:this.theme.getStyle("submenu")}),this._selectedElement=i,this._selectedElement.classList.add(this.options.menuBarPosition),this._mainElement=r(".tui-image-editor-main"),this._editorElementWrap=r(".tui-image-editor-wrap"),this._editorElement=r(".tui-image-editor"),this._helpMenuBarElement=r(".tui-image-editor-help-menu"),this._menuBarElement=r(".tui-image-editor-menu"),this._subMenuElement=r(".tui-image-editor-submenu"),this._buttonElements={download:this._selectedElement.querySelectorAll(".tui-image-editor-download-btn"),load:this._selectedElement.querySelectorAll(".tui-image-editor-load-btn")},this._addHelpMenus(),this._historyMenu=new Xr(this._buttonElements.history,{locale:this._locale,makeSvgIcon:A()(e=this.theme.makeMenSvgIconSet).call(e,this.theme)}),this._activateZoomMenus()}},{key:"_activateZoomMenus",value:function(){var t=this;H()(ut,(function(e){t.changeHelpButtonEnabled(e,!0)}))}},{key:"_makeHelpMenuWithPartition",value:function(){var t;return O()(t=[]).call(t,_(ut),[""],_(ht),[""],_(ft))}},{key:"_addHelpMenus",value:function(){var t=this,e=this._makeHelpMenuWithPartition();H()(e,(function(e){e?(t._makeMenuElement(e,["normal","disabled","hover"],"help"),t._buttonElements[e]=t._helpMenuBarElement.querySelector(".tie-btn-".concat(e))):t._makeMenuPartitionElement()}))}},{key:"_makeMenuPartitionElement",value:function(){var t=document.createElement("li"),e=document.createElement("div");t.className=Hi("item"),e.className=Hi("icpartition"),t.appendChild(e),this._helpMenuBarElement.appendChild(t)}},{key:"_makeMenuElement",value:function(t){var e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["normal","active","hover"],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"normal",o=document.createElement("li"),a=this.theme.makeMenSvgIconSet(n,t);this._addTooltipAttribute(o,t),o.className=O()(e=O()(i="tie-btn-".concat(t," ")).call(i,Hi("item")," ")).call(e,r),o.innerHTML=a,"normal"===r?this._menuBarElement.appendChild(o):this._helpMenuBarElement.appendChild(o)}},{key:"_addHelpActionEvent",value:function(){var t=this;H()(gt,(function(e){t.eventHandler[e]=function(i){return t._actions.main[e](i)},t._buttonElements[e].addEventListener("click",t.eventHandler[e])}))}},{key:"_removeHelpActionEvent",value:function(){var t=this;H()(gt,(function(e){t._buttonElements[e].removeEventListener("click",t.eventHandler[e])}))}},{key:"_addHistory",value:function(t){if(!function(t){return"string"==typeof t?Tt===t:Tt===t.name}(t)){var e="string"==typeof t?{name:t}:function(t){var e,i,n,r=Dt,o=At,a=Rt,s=Et,c=Lt,l=Bt,u=Pt,f=Yt,g=kt,d=Wt,v=Ot,p=Zt,m=t.name,y=t.args;switch(m){case r:n={name:m,detail:"reset"===y[1]?y[1]:h()(e=y[1]).call(e,4)};break;case o:n={name:m,detail:y[2]};break;case s:n={name:Ae,detail:Ki(y[1],y[2])};break;case c:n={name:je,detail:"Remove"};break;case l:n={name:Oe,detail:"Change"};break;case u:n={name:Ee,detail:"Change"};break;case f:n={name:Ne,detail:"Change"};break;case v:n={name:Pe,detail:y[2]};break;case g:n={name:ze,detail:"All"};break;case d:n={name:ke,detail:"Add"};break;case a:n={name:Le};break;case p:n={name:De,detail:O()(i="".concat(~~y[1].width,"x")).call(i,~~y[1].height)};break;default:n={name:m}}return"mask"===y[1]&&(n={name:we,detail:"Apply"}),n}(t);this._historyMenu.add(e)}}},{key:"initHistory",value:function(){this._historyMenu.init()}},{key:"clearHistory",value:function(){this._historyMenu.clear()}},{key:"_selectPrevHistory",value:function(){this._historyMenu.prev()}},{key:"_selectNextHistory",value:function(){this._historyMenu.next()}},{key:"toggleHistoryMenu",value:function(t){t.target.closest(".".concat("tie-panel-history"))||this._buttonElements.history.classList.toggle("opened")}},{key:"_addTooltipAttribute",value:function(t,e){t.setAttribute("tooltip-content",this._locale.localize(e.replace(/^[a-z]/g,(function(t){return t.toUpperCase()}))))}},{key:"_addDownloadEvent",value:function(){var t=this;this.eventHandler.download=function(){return t._actions.main.download()},H()(this._buttonElements.download,(function(e){e.addEventListener("click",t.eventHandler.download)}))}},{key:"_removeDownloadEvent",value:function(){var t=this;H()(this._buttonElements.download,(function(e){e.removeEventListener("click",t.eventHandler.download)}))}},{key:"_addLoadEvent",value:function(){var t=this;this.eventHandler.loadImage=function(e){return t._actions.main.load(e.target.files[0])},H()(this._buttonElements.load,(function(e){e.addEventListener("change",t.eventHandler.loadImage)}))}},{key:"_removeLoadEvent",value:function(){var t=this;H()(this._buttonElements.load,(function(e){e.removeEventListener("change",t.eventHandler.loadImage)}))}},{key:"_addMainMenuEvent",value:function(t){var e=this;this.eventHandler[t]=function(){return e.changeMenu(t)},this._buttonElements[t].addEventListener("click",this.eventHandler[t])}},{key:"_addSubMenuEvent",value:function(t){var e=this;this[t].addEvent(this._actions[t]),this[t].on(xe,(function(){return e.fire(xe)})),this[t].on(Ce,(function(){return e.fire(Ce)}))}},{key:"_addMenuEvent",value:function(){var t=this;H()(this.options.menu,(function(e){t._addMainMenuEvent(e),t._addSubMenuEvent(e)}))}},{key:"_removeMainMenuEvent",value:function(){var t=this;H()(this.options.menu,(function(e){t._buttonElements[e].removeEventListener("click",t.eventHandler[e]),t[e].off(xe),t[e].off(Ce)}))}},{key:"getEditorArea",value:function(){return this._editorElement}},{key:"activeMenuEvent",value:function(){this._initMenuEvent||(this._addHelpActionEvent(),this._addDownloadEvent(),this._addMenuEvent(),this._initMenu(),this._historyMenu.addEvent(this._actions.history),this._initMenuEvent=!0)}},{key:"_removeUiEvent",value:function(){this._removeHelpActionEvent(),this._removeDownloadEvent(),this._removeLoadEvent(),this._removeMainMenuEvent(),this._historyMenu.removeEvent()}},{key:"_destroyAllMenu",value:function(){var t=this;H()(this.options.menu,(function(e){t[e].destroy()})),this._historyMenu.destroy()}},{key:"initCanvas",value:function(){var t=this,e=this._getLoadImage();e.path&&this._actions.main.initLoadImage(e.path,e.name).then((function(){t.activeMenuEvent()})),this._addLoadEvent();var i=document.createElement("div");i.className=Hi("grid-visual");i.innerHTML='<table>\n <tr><td class="dot left-top"></td><td></td><td class="dot right-top"></td></tr>\n <tr><td></td><td></td><td></td></tr>\n <tr><td class="dot left-bottom"></td><td></td><td class="dot right-bottom"></td></tr>\n </table>',this._editorContainerElement=this._editorElement.querySelector(".tui-image-editor-canvas-container"),this._editorContainerElement.appendChild(i)}},{key:"_getLoadImage",value:function(){return this.options.loadImage}},{key:"changeMenu",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this._submenuChangeTransection||(this._submenuChangeTransection=!0,this._changeMenu(t,e,i),this._submenuChangeTransection=!1)}},{key:"_changeMenu",value:function(t,e,i){this.submenu&&(this._buttonElements[this.submenu].classList.remove("active"),this._mainElement.classList.remove("tui-image-editor-menu-".concat(this.submenu)),i&&this._actions.main.discardSelection(),this._actions.main.changeSelectableAll(!0),this[this.submenu].changeStandbyMode()),this.submenu===t&&e?this.submenu=null:(this._buttonElements[t].classList.add("active"),this._mainElement.classList.add("tui-image-editor-menu-".concat(t)),this.submenu=t,this[this.submenu].changeStartMode()),this.resizeEditor()}},{key:"_initMenu",value:function(){if(this.options.initMenu){var t=document.createEvent("MouseEvents");t.initEvent("click",!0,!1),this._buttonElements[this.options.initMenu].dispatchEvent(t)}this.icon&&this.icon.registerDefaultIcon()}},{key:"_getCanvasMaxDimension",value:function(){var t=this._editorContainerElement.style,e=t.maxWidth,i=t.maxHeight;return{width:dn()(e),height:dn()(i)}}},{key:"_setEditorPosition",value:function(t){var e=this._getCanvasMaxDimension(),i=e.width,n=e.height,r=this._editorElement.style,o=0,a=0;this.submenu&&("bottom"===t?o=n>this._editorElementWrap.scrollHeight-150?(n-this._editorElementWrap.scrollHeight)/2:-75:"top"===t?o=n>this._editorElementWrap.offsetHeight-150?75-(n-(this._editorElementWrap.offsetHeight-150))/2:75:"left"===t?a=i>this._editorElementWrap.offsetWidth-248?124-(i-(this._editorElementWrap.offsetWidth-248))/2:124:"right"===t&&(a=i>this._editorElementWrap.scrollWidth-248?(i-this._editorElementWrap.scrollWidth)/2:-124)),r.top="".concat(o,"px"),r.left="".concat(a,"px")}}]),t}();G().mixin(to);var eo=to,io=n(381),no=n.n(io),ro=function(){function t(){w(this,t),this.versionnumber="1.2.4",this.optionpresets={default:{corsenabled:!1,ltres:1,qtres:1,pathomit:8,rightangleenhance:!0,colorsampling:2,numberofcolors:16,mincolorratio:0,colorquantcycles:3,layering:0,strokewidth:1,linefilter:!1,scale:1,roundcoords:1,viewbox:!1,desc:!1,lcpr:0,qcpr:0,blurradius:0,blurdelta:20},posterized1:{colorsampling:0,numberofcolors:2},posterized2:{numberofcolors:4,blurradius:5},curvy:{ltres:.01,linefilter:!0,rightangleenhance:!1},sharp:{qtres:.01,linefilter:!1},detailed:{pathomit:0,roundcoords:2,ltres:.5,qtres:.5,numberofcolors:64},smoothed:{blurradius:5,blurdelta:64},grayscale:{colorsampling:0,colorquantcycles:1,numberofcolors:7},fixedpalette:{colorsampling:0,colorquantcycles:1,numberofcolors:27},randomsampling1:{colorsampling:1,numberofcolors:8},randomsampling2:{colorsampling:1,numberofcolors:64},artistic1:{colorsampling:0,colorquantcycles:1,pathomit:0,blurradius:5,blurdelta:64,ltres:.01,linefilter:!0,numberofcolors:16,strokewidth:2},artistic2:{qtres:.01,colorsampling:0,colorquantcycles:1,numberofcolors:4,strokewidth:0},artistic3:{qtres:10,ltres:10,numberofcolors:8},artistic4:{qtres:10,ltres:10,numberofcolors:64,blurradius:5,blurdelta:256,strokewidth:2},posterized3:{ltres:1,qtres:1,pathomit:20,rightangleenhance:!0,colorsampling:0,numberofcolors:3,mincolorratio:0,colorquantcycles:3,blurradius:3,blurdelta:20,strokewidth:0,linefilter:!1,roundcoords:1,pal:[{r:0,g:0,b:100,a:255},{r:255,g:255,b:255,a:255}]}},this.pathscan_combined_lookup=[[[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[0,1,0,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[0,2,-1,0]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[0,1,0,-1],[0,0,1,0]],[[0,0,1,0],[-1,-1,-1,-1],[0,2,-1,0],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[0,0,1,0],[0,3,0,1],[-1,-1,-1,-1]],[[13,3,0,1],[13,2,-1,0],[7,1,0,-1],[7,0,1,0]],[[-1,-1,-1,-1],[0,1,0,-1],[-1,-1,-1,-1],[0,3,0,1]],[[0,3,0,1],[0,2,-1,0],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[0,3,0,1],[0,2,-1,0],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[0,1,0,-1],[-1,-1,-1,-1],[0,3,0,1]],[[11,1,0,-1],[14,0,1,0],[14,3,0,1],[11,2,-1,0]],[[-1,-1,-1,-1],[0,0,1,0],[0,3,0,1],[-1,-1,-1,-1]],[[0,0,1,0],[-1,-1,-1,-1],[0,2,-1,0],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[0,1,0,-1],[0,0,1,0]],[[0,1,0,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[0,2,-1,0]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1]]],this.gks=[[.27901,.44198,.27901],[.135336,.228569,.272192,.228569,.135336],[.086776,.136394,.178908,.195843,.178908,.136394,.086776],[.063327,.093095,.122589,.144599,.152781,.144599,.122589,.093095,.063327],[.049692,.069304,.089767,.107988,.120651,.125194,.120651,.107988,.089767,.069304,.049692]],this.specpalette=[{r:0,g:0,b:0,a:255},{r:128,g:128,b:128,a:255},{r:0,g:0,b:128,a:255},{r:64,g:64,b:128,a:255},{r:192,g:192,b:192,a:255},{r:255,g:255,b:255,a:255},{r:128,g:128,b:192,a:255},{r:0,g:0,b:192,a:255},{r:128,g:0,b:0,a:255},{r:128,g:64,b:64,a:255},{r:128,g:0,b:128,a:255},{r:168,g:168,b:168,a:255},{r:192,g:128,b:128,a:255},{r:192,g:0,b:0,a:255},{r:255,g:255,b:255,a:255},{r:0,g:128,b:0,a:255}]}return T(t,[{key:"imageToSVG",value:function(t,e,i){var n=this;i=this.checkoptions(i),this.loadImage(t,(function(t){e(n.imagedataToSVG(n.getImgdata(t),i))}),i)}},{key:"imagedataToSVG",value:function(t,e){e=this.checkoptions(e);var i=this.imagedataToTracedata(t,e);return this.getsvgstring(i,e)}},{key:"imageToTracedata",value:function(t,e,i){var n=this;i=this.checkoptions(i),this.loadImage(t,(function(t){e(n.imagedataToTracedata(n.getImgdata(t),i))}),i)}},{key:"imagedataToTracedata",value:function(t,e){e=this.checkoptions(e);var i,n=this.colorquantization(t,e);if(0===e.layering){i={layers:[],palette:n.palette,width:n.array[0].length-2,height:n.array.length-2};for(var r=0;r<n.palette.length;r+=1){var o=this.batchtracepaths(this.internodes(this.pathscan(this.layeringstep(n,r),e.pathomit),e),e.ltres,e.qtres);i.layers.push(o)}}else{var a=this.layering(n);e.layercontainerid&&this.drawLayers(a,this.specpalette,e.scale,e.layercontainerid);var s=this.batchpathscan(a,e.pathomit),c=this.batchinternodes(s,e);i={layers:this.batchtracelayers(c,e.ltres,e.qtres),palette:n.palette,width:t.width,height:t.height}}return i}},{key:"checkoptions",value:function(t){"string"==typeof(t=t||{})&&(t=t.toLowerCase(),t=this.optionpresets[t]?this.optionpresets[t]:{});for(var e=J()(this.optionpresets.default),i=0;i<e.length;i+=1)t.hasOwnProperty(e[i])||(t[e[i]]=this.optionpresets.default[e[i]]);return t}},{key:"colorquantization",value:function(t,e){var i,n,r,o,a,s,c,l,u=[],h=0,f=[],g=t.width*t.height;for(a=0;a<t.height+2;a+=1)for(u[a]=[],o=0;o<t.width+2;o+=1)u[a][o]=-1;for(l=e.pal?e.pal:0===e.colorsampling?this.generatepalette(e.numberofcolors):1===e.colorsampling?this.samplepalette(e.numberofcolors,t):this.samplepalette2(e.numberofcolors,t),e.blurradius>0&&(t=this.blur(t,e.blurradius,e.blurdelta)),c=0;c<e.colorquantcycles;c+=1){if(c>0)for(s=0;s<l.length;s+=1)f[s].n>0&&(l[s]={r:Math.floor(f[s].r/f[s].n),g:Math.floor(f[s].g/f[s].n),b:Math.floor(f[s].b/f[s].n),a:Math.floor(f[s].a/f[s].n)}),f[s].n/g<e.mincolorratio&&c<e.colorquantcycles-1&&(l[s]={r:Math.floor(255*Math.random()),g:Math.floor(255*Math.random()),b:Math.floor(255*Math.random()),a:Math.floor(255*Math.random())});for(o=0;o<l.length;o+=1)f[o]={r:0,g:0,b:0,a:0,n:0};for(a=0;a<t.height;a+=1)for(o=0;o<t.width;o+=1){for(h=4*(a*t.width+o),r=0,n=1024,s=0;s<l.length;s+=1)(i=Math.abs(l[s].r-t.data[h])+Math.abs(l[s].g-t.data[h+1])+Math.abs(l[s].b-t.data[h+2])+Math.abs(l[s].a-t.data[h+3]))<n&&(n=i,r=s);f[r].r+=t.data[h],f[r].g+=t.data[h+1],f[r].b+=t.data[h+2],f[r].a+=t.data[h+3],f[r].n+=1,u[a+1][o+1]=r}}return{array:u,palette:l}}},{key:"samplepalette",value:function(t,e){for(var i,n=[],r=0;r<t;r+=1)i=4*Math.floor(Math.random()*e.data.length/4),n.push({r:e.data[i],g:e.data[i+1],b:e.data[i+2],a:e.data[i+3]});return n}},{key:"samplepalette2",value:function(t,e){for(var i,n=[],r=Math.ceil(Math.sqrt(t)),o=Math.ceil(t/r),a=e.width/(r+1),s=e.height/(o+1),c=0;c<o;c+=1)for(var l=0;l<r&&n.length!==t;l+=1)i=4*Math.floor((c+1)*s*e.width+(l+1)*a),n.push({r:e.data[i],g:e.data[i+1],b:e.data[i+2],a:e.data[i+3]});return n}},{key:"generatepalette",value:function(t){var e,i,n,r=[];if(t<8)for(var o=Math.floor(255/(t-1)),a=0;a<t;a+=1)r.push({r:a*o,g:a*o,b:a*o,a:255});else{var s=Math.floor(Math.pow(t,1/3)),c=Math.floor(255/(s-1)),l=t-s*s*s;for(e=0;e<s;e+=1)for(i=0;i<s;i+=1)for(n=0;n<s;n+=1)r.push({r:e*c,g:i*c,b:n*c,a:255});for(e=0;e<l;e+=1)r.push({r:Math.floor(255*Math.random()),g:Math.floor(255*Math.random()),b:Math.floor(255*Math.random()),a:Math.floor(255*Math.random())})}return r}},{key:"layering",value:function(t){var e,i,n,r,o,a,s,c,l,u,h,f=[],g=0,d=t.array.length,v=t.array[0].length;for(h=0;h<t.palette.length;h+=1)for(f[h]=[],u=0;u<d;u+=1)for(f[h][u]=[],l=0;l<v;l+=1)f[h][u][l]=0;for(u=1;u<d-1;u+=1)for(l=1;l<v-1;l+=1)g=t.array[u][l],e=t.array[u-1][l-1]===g?1:0,i=t.array[u-1][l]===g?1:0,n=t.array[u-1][l+1]===g?1:0,r=t.array[u][l-1]===g?1:0,o=t.array[u][l+1]===g?1:0,a=t.array[u+1][l-1]===g?1:0,s=t.array[u+1][l]===g?1:0,c=t.array[u+1][l+1]===g?1:0,f[g][u+1][l+1]=1+2*o+4*c+8*s,r||(f[g][u+1][l]=2+4*s+8*a),i||(f[g][u][l+1]=0+2*n+4*o+8),e||(f[g][u][l]=0+2*i+4+8*r);return f}},{key:"layeringstep",value:function(t,e){var i,n,r=[],o=t.array.length,a=t.array[0].length;for(n=0;n<o;n+=1)for(r[n]=[],i=0;i<a;i+=1)r[n][i]=0;for(n=1;n<o;n+=1)for(i=1;i<a;i+=1)r[n][i]=(t.array[n-1][i-1]===e?1:0)+(t.array[n-1][i]===e?2:0)+(t.array[n][i-1]===e?8:0)+(t.array[n][i]===e?4:0);return r}},{key:"pathscan",value:function(t,e){for(var i,n=[],r=0,o=0,a=0,s=0,c=t[0].length,l=t.length,u=0,h=!0,f=!1,g=0;g<l;g+=1)for(var d=0;d<c;d+=1)if(4===t[g][d]||11===t[g][d])for(a=d,s=g,n[r]={},n[r].points=[],n[r].boundingbox=[a,s,a,s],n[r].holechildren=[],h=!1,o=0,f=11===t[g][d],u=1;!h;){if(n[r].points[o]={},n[r].points[o].x=a-1,n[r].points[o].y=s-1,n[r].points[o].t=t[s][a],a-1<n[r].boundingbox[0]&&(n[r].boundingbox[0]=a-1),a-1>n[r].boundingbox[2]&&(n[r].boundingbox[2]=a-1),s-1<n[r].boundingbox[1]&&(n[r].boundingbox[1]=s-1),s-1>n[r].boundingbox[3]&&(n[r].boundingbox[3]=s-1),i=this.pathscan_combined_lookup[t[s][a]][u],t[s][a]=i[0],u=i[1],a+=i[2],s+=i[3],a-1===n[r].points[0].x&&s-1===n[r].points[0].y)if(h=!0,n[r].points.length<e)n.pop();else{if(n[r].isholepath=!!f,f){for(var v=0,p=[-1,-1,c+1,l+1],m=0;m<r;m++)!n[m].isholepath&&this.boundingboxincludes(n[m].boundingbox,n[r].boundingbox)&&this.boundingboxincludes(p,n[m].boundingbox)&&(v=m,p=n[m].boundingbox);n[v].holechildren.push(r)}r+=1}o+=1}return n}},{key:"boundingboxincludes",value:function(t,e){return t[0]<e[0]&&t[1]<e[1]&&t[2]>e[2]&&t[3]>e[3]}},{key:"batchpathscan",value:function(t,e){var i=[];for(var n in t)t.hasOwnProperty(n)&&(i[n]=this.pathscan(t[n],e));return i}},{key:"internodes",value:function(t,e){var i,n,r=[],o=0,a=0,s=0,c=0,l=0;for(i=0;i<t.length;i+=1)for(r[i]={},r[i].points=[],r[i].boundingbox=t[i].boundingbox,r[i].holechildren=t[i].holechildren,r[i].isholepath=t[i].isholepath,o=t[i].points.length,n=0;n<o;n+=1)a=(n+1)%o,s=(n+2)%o,c=(n-1+o)%o,l=(n-2+o)%o,e.rightangleenhance&&this.testrightangle(t[i],l,c,n,a,s)&&(r[i].points.length>0&&(r[i].points[r[i].points.length-1].linesegment=this.getdirection(r[i].points[r[i].points.length-1].x,r[i].points[r[i].points.length-1].y,t[i].points[n].x,t[i].points[n].y)),r[i].points.push({x:t[i].points[n].x,y:t[i].points[n].y,linesegment:this.getdirection(t[i].points[n].x,t[i].points[n].y,(t[i].points[n].x+t[i].points[a].x)/2,(t[i].points[n].y+t[i].points[a].y)/2)})),r[i].points.push({x:(t[i].points[n].x+t[i].points[a].x)/2,y:(t[i].points[n].y+t[i].points[a].y)/2,linesegment:this.getdirection((t[i].points[n].x+t[i].points[a].x)/2,(t[i].points[n].y+t[i].points[a].y)/2,(t[i].points[a].x+t[i].points[s].x)/2,(t[i].points[a].y+t[i].points[s].y)/2)});return r}},{key:"testrightangle",value:function(t,e,i,n,r,o){return t.points[n].x===t.points[e].x&&t.points[n].x===t.points[i].x&&t.points[n].y===t.points[r].y&&t.points[n].y===t.points[o].y||t.points[n].y===t.points[e].y&&t.points[n].y===t.points[i].y&&t.points[n].x===t.points[r].x&&t.points[n].x===t.points[o].x}},{key:"getdirection",value:function(t,e,i,n){return t<i?e<n?1:e>n?7:0:t>i?e<n?3:e>n?5:4:e<n?2:e>n?6:8}},{key:"batchinternodes",value:function(t,e){var i=[];for(var n in t)t.hasOwnProperty(n)&&(i[n]=this.internodes(t[n],e));return i}},{key:"tracepath",value:function(t,e,i){var n,r,o,a=0,s={segments:[]};for(s.boundingbox=t.boundingbox,s.holechildren=t.holechildren,s.isholepath=t.isholepath;a<t.points.length;){var c;for(n=t.points[a].linesegment,r=-1,o=a+1;(t.points[o].linesegment===n||t.points[o].linesegment===r||-1===r)&&o<t.points.length-1;)t.points[o].linesegment!==n&&-1===r&&(r=t.points[o].linesegment),o+=1;o===t.points.length-1&&(o=0),s.segments=O()(c=s.segments).call(c,this.fitseq(t,e,i,a,o)),a=o>0?o:t.points.length}return s}},{key:"fitseq",value:function(t,e,i,n,r){var o;if(r>t.points.length||r<0)return[];var a,s,c,l=n,u=0,h=!0,f=r-n;f<0&&(f+=t.points.length);for(var g,d=(t.points[r].x-t.points[n].x)/f,v=(t.points[r].y-t.points[n].y)/f,p=(n+1)%t.points.length;p!=r;)(g=p-n)<0&&(g+=t.points.length),a=t.points[n].x+d*g,s=t.points[n].y+v*g,(c=(t.points[p].x-a)*(t.points[p].x-a)+(t.points[p].y-s)*(t.points[p].y-s))>e&&(h=!1),c>u&&(l=p,u=c),p=(p+1)%t.points.length;if(h)return[{type:"L",x1:t.points[n].x,y1:t.points[n].y,x2:t.points[r].x,y2:t.points[r].y}];var m=l;h=!0,u=0;var y=(m-n)/f,b=(1-y)*(1-y),x=2*(1-y)*y,C=y*y,I=(b*t.points[n].x+C*t.points[r].x-t.points[m].x)/-x,_=(b*t.points[n].y+C*t.points[r].y-t.points[m].y)/-x;for(p=n+1;p!=r;)x=2*(1-(y=(p-n)/f))*y,C=y*y,a=(b=(1-y)*(1-y))*t.points[n].x+x*I+C*t.points[r].x,s=b*t.points[n].y+x*_+C*t.points[r].y,(c=(t.points[p].x-a)*(t.points[p].x-a)+(t.points[p].y-s)*(t.points[p].y-s))>i&&(h=!1),c>u&&(l=p,u=c),p=(p+1)%t.points.length;if(h)return[{type:"Q",x1:t.points[n].x,y1:t.points[n].y,x2:I,y2:_,x3:t.points[r].x,y3:t.points[r].y}];var M=m;return O()(o=this.fitseq(t,e,i,n,M)).call(o,this.fitseq(t,e,i,M,r))}},{key:"batchtracepaths",value:function(t,e,i){var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(this.tracepath(t[r],e,i));return n}},{key:"batchtracelayers",value:function(t,e,i){var n=[];for(var r in t)t.hasOwnProperty(r)&&(n[r]=this.batchtracepaths(t[r],e,i));return n}},{key:"roundtodec",value:function(t,e){return Number(t.toFixed(e))}},{key:"svgpathstring",value:function(t,e,i,n){var r,o,a,s=t.layers[e],c=s[i],l="";if(n.linefilter&&c.segments.length<3)return l;if(l=O()(r="<path ".concat(n.desc?O()(o='desc="l '.concat(e," p ")).call(o,i,'" '):"")).call(r,this.tosvgcolorstr(t.palette[e],n),'d="'),-1===n.roundcoords){var u;for(l+=O()(u="M ".concat(c.segments[0].x1*n.scale," ")).call(u,c.segments[0].y1*n.scale," "),a=0;a<c.segments.length;a++){var h,f,g;if(l+=O()(h=O()(f="".concat(c.segments[a].type," ")).call(f,c.segments[a].x2*n.scale," ")).call(h,c.segments[a].y2*n.scale," "),c.segments[a].hasOwnProperty("x3"))l+=O()(g="".concat(c.segments[a].x3*n.scale," ")).call(g,c.segments[a].y3*n.scale," ")}l+="Z "}else{var d;for(l+=O()(d="M ".concat(this.roundtodec(c.segments[0].x1*n.scale,n.roundcoords)," ")).call(d,this.roundtodec(c.segments[0].y1*n.scale,n.roundcoords)," "),a=0;a<c.segments.length;a++){var v,p,m;if(l+=O()(v=O()(p="".concat(c.segments[a].type," ")).call(p,this.roundtodec(c.segments[a].x2*n.scale,n.roundcoords)," ")).call(v,this.roundtodec(c.segments[a].y2*n.scale,n.roundcoords)," "),c.segments[a].hasOwnProperty("x3"))l+=O()(m="".concat(this.roundtodec(c.segments[a].x3*n.scale,n.roundcoords)," ")).call(m,this.roundtodec(c.segments[a].y3*n.scale,n.roundcoords)," ")}l+="Z "}for(var y=0;y<c.holechildren.length;y++){var b=s[c.holechildren[y]];if(-1===n.roundcoords){var x,C;if(b.segments[b.segments.length-1].hasOwnProperty("x3"))l+=O()(x="M ".concat(b.segments[b.segments.length-1].x3*n.scale," ")).call(x,b.segments[b.segments.length-1].y3*n.scale," ");else l+=O()(C="M ".concat(b.segments[b.segments.length-1].x2*n.scale," ")).call(C,b.segments[b.segments.length-1].y2*n.scale," ");for(a=b.segments.length-1;a>=0;a--){var I,_;if(l+="".concat(b.segments[a].type," "),b.segments[a].hasOwnProperty("x3"))l+=O()(_="".concat(b.segments[a].x2*n.scale," ")).call(_,b.segments[a].y2*n.scale," ");l+=O()(I="".concat(b.segments[a].x1*n.scale," ")).call(I,b.segments[a].y1*n.scale," ")}}else{var M,S;if(b.segments[b.segments.length-1].hasOwnProperty("x3"))l+=O()(M="M ".concat(this.roundtodec(b.segments[b.segments.length-1].x3*n.scale)," ")).call(M,this.roundtodec(b.segments[b.segments.length-1].y3*n.scale)," ");else l+=O()(S="M ".concat(this.roundtodec(b.segments[b.segments.length-1].x2*n.scale)," ")).call(S,this.roundtodec(b.segments[b.segments.length-1].y2*n.scale)," ");for(a=b.segments.length-1;a>=0;a--){var w,k;if(l+="".concat(b.segments[a].type," "),b.segments[a].hasOwnProperty("x3"))l+=O()(k="".concat(this.roundtodec(b.segments[a].x2*n.scale)," ")).call(k,this.roundtodec(b.segments[a].y2*n.scale)," ");l+=O()(w="".concat(this.roundtodec(b.segments[a].x1*n.scale)," ")).call(w,this.roundtodec(b.segments[a].y1*n.scale)," ")}}l+="Z "}if(l+='" />',n.lcpr||n.qcpr){for(a=0;a<c.segments.length;a++){var T,D,A,j,E,L,N,P,z,B,R,F,Y,W,H,U,G;if(c.segments[a].hasOwnProperty("x3")&&n.qcpr)l+=O()(T=O()(D=O()(A='<circle cx="'.concat(c.segments[a].x2*n.scale,'" cy="')).call(A,c.segments[a].y2*n.scale,'" r="')).call(D,n.qcpr,'" fill="cyan" stroke-width="')).call(T,.2*n.qcpr,'" stroke="black" />'),l+=O()(j=O()(E=O()(L='<circle cx="'.concat(c.segments[a].x3*n.scale,'" cy="')).call(L,c.segments[a].y3*n.scale,'" r="')).call(E,n.qcpr,'" fill="white" stroke-width="')).call(j,.2*n.qcpr,'" stroke="black" />'),l+=O()(N=O()(P=O()(z=O()(B='<line x1="'.concat(c.segments[a].x1*n.scale,'" y1="')).call(B,c.segments[a].y1*n.scale,'" x2="')).call(z,c.segments[a].x2*n.scale,'" y2="')).call(P,c.segments[a].y2*n.scale,'" stroke-width="')).call(N,.2*n.qcpr,'" stroke="cyan" />'),l+=O()(R=O()(F=O()(Y=O()(W='<line x1="'.concat(c.segments[a].x2*n.scale,'" y1="')).call(W,c.segments[a].y2*n.scale,'" x2="')).call(Y,c.segments[a].x3*n.scale,'" y2="')).call(F,c.segments[a].y3*n.scale,'" stroke-width="')).call(R,.2*n.qcpr,'" stroke="cyan" />');if(!c.segments[a].hasOwnProperty("x3")&&n.lcpr)l+=O()(H=O()(U=O()(G='<circle cx="'.concat(c.segments[a].x2*n.scale,'" cy="')).call(G,c.segments[a].y2*n.scale,'" r="')).call(U,n.lcpr,'" fill="white" stroke-width="')).call(H,.2*n.lcpr,'" stroke="black" />')}for(y=0;y<c.holechildren.length;y++){b=s[c.holechildren[y]];for(a=0;a<b.segments.length;a++){var X,Z,V,J,Q,K,q,$,tt,et,it,nt,rt,ot,at,st,ct;if(b.segments[a].hasOwnProperty("x3")&&n.qcpr)l+=O()(X=O()(Z=O()(V='<circle cx="'.concat(b.segments[a].x2*n.scale,'" cy="')).call(V,b.segments[a].y2*n.scale,'" r="')).call(Z,n.qcpr,'" fill="cyan" stroke-width="')).call(X,.2*n.qcpr,'" stroke="black" />'),l+=O()(J=O()(Q=O()(K='<circle cx="'.concat(b.segments[a].x3*n.scale,'" cy="')).call(K,b.segments[a].y3*n.scale,'" r="')).call(Q,n.qcpr,'" fill="white" stroke-width="')).call(J,.2*n.qcpr,'" stroke="black" />'),l+=O()(q=O()($=O()(tt=O()(et='<line x1="'.concat(b.segments[a].x1*n.scale,'" y1="')).call(et,b.segments[a].y1*n.scale,'" x2="')).call(tt,b.segments[a].x2*n.scale,'" y2="')).call($,b.segments[a].y2*n.scale,'" stroke-width="')).call(q,.2*n.qcpr,'" stroke="cyan" />'),l+=O()(it=O()(nt=O()(rt=O()(ot='<line x1="'.concat(b.segments[a].x2*n.scale,'" y1="')).call(ot,b.segments[a].y2*n.scale,'" x2="')).call(rt,b.segments[a].x3*n.scale,'" y2="')).call(nt,b.segments[a].y3*n.scale,'" stroke-width="')).call(it,.2*n.qcpr,'" stroke="cyan" />');if(!b.segments[a].hasOwnProperty("x3")&&n.lcpr)l+=O()(at=O()(st=O()(ct='<circle cx="'.concat(b.segments[a].x2*n.scale,'" cy="')).call(ct,b.segments[a].y2*n.scale,'" r="')).call(st,n.lcpr,'" fill="white" stroke-width="')).call(at,.2*n.lcpr,'" stroke="black" />')}}}return l}},{key:"getsvgstring",value:function(t,e){var i,n,r;e=this.checkoptions(e);for(var o=t.width*e.scale,a=t.height*e.scale,s=O()(i="<svg ".concat(e.viewbox?O()(n='viewBox="0 0 '.concat(o," ")).call(n,a,'" '):O()(r='width="'.concat(o,'" height="')).call(r,a,'" '),'version="1.1" xmlns="http://www.w3.org/2000/svg" desc="Created with imagetracer.js version ')).call(i,this.versionnumber,'" >'),c=0;c<t.layers.length;c+=1)for(var l=0;l<t.layers[c].length;l+=1)t.layers[c][l].isholepath||(s+=this.svgpathstring(t,c,l,e));return s+="</svg>"}},{key:"compareNumbers",value:function(t,e){return t-e}},{key:"torgbastr",value:function(t){var e,i,n;return O()(e=O()(i=O()(n="rgba(".concat(t.r,",")).call(n,t.g,",")).call(i,t.b,",")).call(e,t.a,")")}},{key:"tosvgcolorstr",value:function(t,e){var i,n,r,o,a,s,c;return O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c='fill="rgb('.concat(t.r,",")).call(c,t.g,",")).call(s,t.b,')" stroke="rgb(')).call(a,t.r,",")).call(o,t.g,",")).call(r,t.b,')" stroke-width="')).call(n,e.strokewidth,'" opacity="')).call(i,t.a/255,'" ')}},{key:"appendSVGString",value:function(t,e){var i;e?(i=document.getElementById(e))||((i=document.createElement("div")).id=e,document.body.appendChild(i)):(i=document.createElement("div"),document.body.appendChild(i)),i.innerHTML+=t}},{key:"blur",value:function(t,e,i){var n,r,o,a,s,c,l,u,h,f={width:t.width,height:t.height,data:[]};if((e=Math.floor(e))<1)return t;e>5&&(e=5),(i=Math.abs(i))>1024&&(i=1024);var g=this.gks[e-1];for(r=0;r<t.height;r++)for(n=0;n<t.width;n++){for(s=0,c=0,l=0,u=0,h=0,o=-e;o<e+1;o++)n+o>0&&n+o<t.width&&(a=4*(r*t.width+n+o),s+=t.data[a]*g[o+e],c+=t.data[a+1]*g[o+e],l+=t.data[a+2]*g[o+e],u+=t.data[a+3]*g[o+e],h+=g[o+e]);a=4*(r*t.width+n),f.data[a]=Math.floor(s/h),f.data[a+1]=Math.floor(c/h),f.data[a+2]=Math.floor(l/h),f.data[a+3]=Math.floor(u/h)}var d=new Uint8ClampedArray(f.data);for(r=0;r<t.height;r++)for(n=0;n<t.width;n++){for(s=0,c=0,l=0,u=0,h=0,o=-e;o<e+1;o++)r+o>0&&r+o<t.height&&(s+=d[a=4*((r+o)*t.width+n)]*g[o+e],c+=d[a+1]*g[o+e],l+=d[a+2]*g[o+e],u+=d[a+3]*g[o+e],h+=g[o+e]);a=4*(r*t.width+n),f.data[a]=Math.floor(s/h),f.data[a+1]=Math.floor(c/h),f.data[a+2]=Math.floor(l/h),f.data[a+3]=Math.floor(u/h)}for(r=0;r<t.height;r++)for(n=0;n<t.width;n++)a=4*(r*t.width+n),Math.abs(f.data[a]-t.data[a])+Math.abs(f.data[a+1]-t.data[a+1])+Math.abs(f.data[a+2]-t.data[a+2])+Math.abs(f.data[a+3]-t.data[a+3])>i&&(f.data[a]=t.data[a],f.data[a+1]=t.data[a+1],f.data[a+2]=t.data[a+2],f.data[a+3]=t.data[a+3]);return f}},{key:"loadImage",value:function(t,e,i){var n=new Image;i&&i.corsenabled&&(n.crossOrigin="Anonymous"),n.src=t,n.onload=function(){var t=document.createElement("canvas");t.width=n.width,t.height=n.height,t.getContext("2d").drawImage(n,0,0),e(t)}}},{key:"getImgdata",value:function(t){return t.getContext("2d").getImageData(0,0,t.width,t.height)}},{key:"drawLayers",value:function(t,e,i,n){var r,o,a,s,c,l;for(c in i=i||1,n?(l=document.getElementById(n))||((l=document.createElement("div")).id=n,document.body.appendChild(l)):(l=document.createElement("div"),document.body.appendChild(l)),t)if(t.hasOwnProperty(c)){r=t[c][0].length,o=t[c].length;var u=document.createElement("canvas");u.width=r*i,u.height=o*i;var h=u.getContext("2d");for(s=0;s<o;s+=1)for(a=0;a<r;a+=1)h.fillStyle=this.torgbastr(e[t[c][s][a]%e.length]),h.fillRect(a*i,s*i,i,i);l.appendChild(u)}}}],[{key:"tracerDefaultOption",value:function(){return{pathomit:100,ltres:.1,qtres:1,scale:1,strokewidth:5,viewbox:!1,linefilter:!0,desc:!1,rightangleenhance:!1,pal:[{r:0,g:0,b:0,a:255},{r:255,g:255,b:255,a:255}]}}}]),t}(),oo={getActions:function(){return{main:this._mainAction(),shape:this._shapeAction(),crop:this._cropAction(),resize:this._resizeAction(),flip:this._flipAction(),rotate:this._rotateAction(),text:this._textAction(),mask:this._maskAction(),draw:this._drawAction(),icon:this._iconAction(),filter:this._filterAction(),history:this._historyAction()}},_mainAction:function(){var t=this,e=function(){"crop"===t.ui.submenu&&(t.stopDrawingMode(),t.ui.changeMenu("crop"))},i=function(e){var i,n;return i=e,"rotate"===t.ui.submenu&&t.ui.rotate.setRangeBarAngle("setAngle",i),n=e,"filter"===t.ui.submenu&&no()(t.ui).setFilterState(n),e},n=function(){no()(t.ui)&&no()(t.ui).initFilterCheckBoxState()};return R()({initLoadImage:function(i,n){return t.loadImageFromURL(i,n).then((function(n){e(),t.ui.initializeImgUrl=i,t.ui.resizeEditor({imageSize:n}),t.clearUndoStack(),t._invoker.fire(fe,Se)}))},undo:function(){t.isEmptyUndoStack()||(e(),t.deactivateAll(),t.undo().then(i))},redo:function(){t.isEmptyRedoStack()||(e(),t.deactivateAll(),t.redo().then(i))},reset:function(){e(),t.loadImageFromURL(t.ui.initializeImgUrl,"resetImage").then((function(i){e(),n(),t.ui.resizeEditor({imageSize:i}),t.clearUndoStack(),t._initHistory()}))},delete:function(){t.ui.changeHelpButtonEnabled("delete",!1),e(),t.removeActiveObject(),t.activeObjectId=null},deleteAll:function(){e(),t.clearObjects(),t.ui.changeHelpButtonEnabled("delete",!1),t.ui.changeHelpButtonEnabled("deleteAll",!1)},load:function(i){Fi()||alert("This browser does not support file-api"),t.ui.initializeImgUrl=P().createObjectURL(i),t.loadImageFromFile(i).then((function(i){e(),n(),t.clearUndoStack(),t.ui.activeMenuEvent(),t.ui.resizeEditor({imageSize:i}),t._clearHistory(),t._invoker.fire(fe,Se)})).catch((function(t){return L().reject(t)}))},download:function(){var e,i,n=t.toDataURL(),r=t.getImageName();Fi()&&window.saveAs?(i=(e=function(t){var e,i,n,r="";e=t.replace(/data:(image\/.+);base64,/,(function(t,e){return r=e,""}));var o=(e=atob(e)).length;for(i=new Uint8Array(o),n=0;n<o;n+=1)i[n]=e.charCodeAt(n);return new Blob([i],{type:r})}(n)).type.split("/")[1],r.split(".").pop()!==i&&(r+=".".concat(i)),saveAs(e,r)):window.open().document.body.innerHTML="<img src='".concat(n,"'>")},history:function(e){t.ui.toggleHistoryMenu(e)},zoomIn:function(){var e;t.ui.toggleZoomButtonStatus("zoomIn"),t.deactivateAll(),e=t._graphics.getZoomMode(),t.stopDrawingMode(),e!==Ge?(t.startDrawingMode(Be.ZOOM),t._graphics.startZoomInMode()):t._graphics.endZoomInMode()},zoomOut:function(){t._graphics.zoomOut()},hand:function(){var e;t.ui.offZoomInButtonStatus(),t.ui.toggleZoomButtonStatus("hand"),t.deactivateAll(),e=t._graphics.getZoomMode(),t.stopDrawingMode(),e!==Xe?(t.startDrawingMode(Be.ZOOM),t._graphics.startHandMode()):t._graphics.endHandMode()}},this._commonAction())},_iconAction:function(){var t=this;return R()({changeColor:function(e){t.activeObjectId&&t.changeIconColor(t.activeObjectId,e)},addIcon:function(e,i){t.startDrawingMode("ICON"),t.setDrawingIcon(e,i)},cancelAddIcon:function(){t.ui.icon.clearIconType(),t.changeSelectableAll(!0),t.changeCursor("default"),t.stopDrawingMode()},registerDefaultIcons:function(e,i){var n={};n[e]=i,t.registerIcons(n)},registerCustomIcon:function(e,i){(new ro).imageToSVG(e,(function(e){var n=Q(e.match(/path[^>]*d="([^"]*)"/),2)[1],r={};r[i.name]=n,t.registerIcons(r),t.addIcon(i.name,{left:100,top:100})}),ro.tracerDefaultOption())}},this._commonAction())},_drawAction:function(){var t=this;return R()({setDrawMode:function(e,i){t.stopDrawingMode(),"free"===e?t.startDrawingMode("FREE_DRAWING",i):t.startDrawingMode("LINE_DRAWING",i)},setColor:function(e){t.setBrush({color:e})}},this._commonAction())},_maskAction:function(){var t=this;return R()({loadImageFromURL:function(e,i){return t.loadImageFromURL(t.toDataURL(),"FilterImage").then((function(){t.addImageObject(e).then((function(){P().revokeObjectURL(i)})),t._invoker.fire(fe,we)}))},applyFilter:function(){t.applyFilter("mask",{maskObjId:t.activeObjectId})}},this._commonAction())},_textAction:function(){var t=this;return R()({changeTextStyle:function(e,i){t.activeObjectId&&t.changeTextStyle(t.activeObjectId,e,i)}},this._commonAction())},_rotateAction:function(){var t=this;return R()({rotate:function(e,i){t.rotate(e,i),t.ui.resizeEditor(),t.ui.rotate.setRangeBarAngle("rotate",e)},setAngle:function(e,i){t.setAngle(e,i),t.ui.resizeEditor(),t.ui.rotate.setRangeBarAngle("setAngle",e)}},this._commonAction())},_shapeAction:function(){var t=this;return R()({changeShape:function(e,i){t.activeObjectId&&t.changeShape(t.activeObjectId,e,i)},setDrawingShape:function(e){t.setDrawingShape(e)}},this._commonAction())},_cropAction:function(){var t=this;return R()({crop:function(){var e=t.getCropzoneRect();e&&!function(t){var e=t.left,i=t.top,n=t.width,r=t.height;return e===_i&&i===Mi&&n===Si&&r===wi}(e)&&t.crop(e).then((function(){t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("crop"),t._invoker.fire(fe,Te)})).catch((function(t){return L().reject(t)}))},cancel:function(){t.stopDrawingMode(),t.ui.changeMenu("crop")},preset:function(e){switch(e){case"preset-square":t.setCropzoneRect(1);break;case"preset-3-2":t.setCropzoneRect(1.5);break;case"preset-4-3":t.setCropzoneRect(4/3);break;case"preset-5-4":t.setCropzoneRect(5/4);break;case"preset-7-5":t.setCropzoneRect(1.4);break;case"preset-16-9":t.setCropzoneRect(16/9);break;default:t.setCropzoneRect(),t.ui.crop.changeApplyButtonStatus(!1)}}},this._commonAction())},_resizeAction:function(){var t=this;return R()({getCurrentDimensions:function(){return t._graphics.getCurrentDimensions()},preview:function(e,i,n){var r=t._graphics.getCurrentDimensions(),o=function(){return r.width/r.height},a={};switch(e){case"width":a.width=i,a.height=n?i/o():r.height;break;case"height":a.height=i,a.width=n?i*o():r.width;break;default:a=r}t._graphics.resize(a).then((function(){t.ui.resizeEditor()})),n&&(t.ui.resize.setWidthValue(a.width),t.ui.resize.setHeightValue(a.height))},resize:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=t._graphics.getCurrentDimensions()),t.resize(e).then((function(){t._graphics.setOriginalDimensions(e),t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("resize")})).catch((function(t){return L().reject(t)}))},reset:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=t._graphics.getOriginalDimensions();t.ui.resize.setWidthValue(i.width,!0),t.ui.resize.setHeightValue(i.height,!0),t._graphics.resize(i).then((function(){e||(t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("resize"))}))}},this._commonAction())},_flipAction:function(){var t=this;return R()({flip:function(e){return t[e]()}},this._commonAction())},_filterAction:function(){var t=this;return R()({applyFilter:function(e,i,n,r){e?t.applyFilter(i,n,r):t.hasFilter(i)&&t.removeFilter(i)}},this._commonAction())},setReAction:function(){var t=this;this.on({undoStackChanged:function(e){e?(t.ui.changeHelpButtonEnabled("undo",!0),t.ui.changeHelpButtonEnabled("reset",!0)):(t.ui.changeHelpButtonEnabled("undo",!1),t.ui.changeHelpButtonEnabled("reset",!1)),t.ui.resizeEditor()},redoStackChanged:function(e){e?t.ui.changeHelpButtonEnabled("redo",!0):t.ui.changeHelpButtonEnabled("redo",!1),t.ui.resizeEditor()},objectActivated:function(e){var i,n;t.activeObjectId=e.id,t.ui.changeHelpButtonEnabled("delete",!0),t.ui.changeHelpButtonEnabled("deleteAll",!0),"cropzone"===e.type?t.ui.crop.changeApplyButtonStatus(!0):o()(i=["rect","circle","triangle"]).call(i,e.type)>-1?(t.stopDrawingMode(),"shape"!==t.ui.submenu&&t.ui.changeMenu("shape",!1,!1),t.ui.shape.setShapeStatus({strokeColor:e.stroke,strokeWidth:e.strokeWidth,fillColor:nt()(e)}),t.ui.shape.setMaxStrokeValue(Math.min(e.width,e.height))):"path"===e.type||"line"===e.type?"draw"!==t.ui.submenu&&(t.ui.changeMenu("draw",!1,!1),t.ui.draw.changeStandbyMode()):o()(n=["i-text","text"]).call(n,e.type)>-1?("text"!==t.ui.submenu&&t.ui.changeMenu("text",!1,!1),t.ui.text.setTextStyleStateOnAction(e)):"icon"===e.type&&(t.stopDrawingMode(),"icon"!==t.ui.submenu&&t.ui.changeMenu("icon",!1,!1),t.ui.icon.setIconPickerColor(nt()(e)))},addText:function(e){var i=t.ui.text,n=i.textColor,r=i.fontSize,o=i.fontStyle,a=i.fontWeight,s=i.underline;t.addText("Double Click",{position:e.originPosition,styles:{fill:n,fontSize:r,fontFamily:"Noto Sans",fontStyle:o,fontWeight:a,underline:s}}).then((function(){t.changeCursor("default")}))},addObjectAfter:function(e){var i;"icon"===e.type?t.ui.icon.changeStandbyMode():o()(i=["rect","circle","triangle"]).call(i,e.type)>-1&&(t.ui.shape.setMaxStrokeValue(Math.min(e.width,e.height)),t.ui.shape.changeStandbyMode())},objectScaled:function(e){var i,n;if(o()(i=["i-text","text"]).call(i,e.type)>-1)t.ui.text.fontSize=Bi(e.fontSize);else if(o()(n=["rect","circle","triangle"]).call(n,e.type)>=0){var r=e.width,a=e.height,s=t.ui.shape.getStrokeValue();r<s&&t.ui.shape.setStrokeValue(r),a<s&&t.ui.shape.setStrokeValue(a)}},selectionCleared:function(){t.activeObjectId=null,"text"===t.ui.submenu?t.changeCursor("text"):Xi(["draw","crop","resize"],t.ui.submenu)||t.stopDrawingMode()}})},_historyAction:function(){var t=this;return{undo:function(e){return t.undo(e)},redo:function(e){return t.redo(e)}}},_commonAction:function(){var t,e,i,n,r=this,o=Be.TEXT,a=Be.CROPPER,s=Be.SHAPE,c=Be.ZOOM,l=Be.RESIZE;return{modeChange:function(t){switch(t){case Re:r._changeActivateMode(o);break;case Fe:r.startDrawingMode(a);break;case We:r._changeActivateMode(s),r.setDrawingShape(r.ui.shape.type,r.ui.shape.options);break;case He:r.startDrawingMode(c);break;case Ye:r.startDrawingMode(l)}},deactivateAll:A()(t=this.deactivateAll).call(t,this),changeSelectableAll:A()(e=this.changeSelectableAll).call(e,this),discardSelection:A()(i=this.discardSelection).call(i,this),stopDrawingMode:A()(n=this.stopDrawingMode).call(n,this)}},mixin:function(t){R()(t.prototype,this)}},ao=n(7322),so=n.n(ao),co=n(6956),lo=n.n(co),uo=function(){function t(e,i){w(this,t),this.name=e,this.graphics=i}return T(t,[{key:"fire",value:function(){for(var t=this.graphics,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return this.graphics.fire.apply(t,i)}},{key:"setCanvasImage",value:function(t,e){this.graphics.setCanvasImage(t,e)}},{key:"getCanvasElement",value:function(){return this.graphics.getCanvasElement()}},{key:"getCanvas",value:function(){return this.graphics.getCanvas()}},{key:"getCanvasImage",value:function(){return this.graphics.getCanvasImage()}},{key:"getImageName",value:function(){return this.graphics.getImageName()}},{key:"getEditor",value:function(){return this.graphics.getEditor()}},{key:"getName",value:function(){return this.name}},{key:"setImageProperties",value:function(t,e){this.graphics.setImageProperties(t,e)}},{key:"setCanvasCssDimension",value:function(t){this.graphics.setCanvasCssDimension(t)}},{key:"setCanvasBackstoreDimension",value:function(t){this.graphics.setCanvasBackstoreDimension(t)}},{key:"adjustCanvasDimension",value:function(){this.graphics.adjustCanvasDimension()}},{key:"adjustCanvasDimensionBase",value:function(){this.graphics.adjustCanvasDimensionBase()}}]),t}(),ho=uo;function fo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var go={padding:0,crossOrigin:"Anonymous"},vo=function(t){wn(i,t);var e=fo(i);function i(t){return w(this,i),e.call(this,St.IMAGE_LOADER,t)}return T(i,[{key:"load",value:function(t,e){var i,n=this;if(t||e)i=this._setBackgroundImage(e).then((function(e){return n.setCanvasImage(t,e),n.adjustCanvasDimension(),e}));else{var r=this.getCanvas();r.backgroundImage=null,r.renderAll(),i=new(L())((function(t){n.setCanvasImage("",null),t()}))}return i}},{key:"_setBackgroundImage",value:function(t){var e=this;return t?new(L())((function(i,n){var r=e.getCanvas();r.setBackgroundImage(t,(function(){var t=r.backgroundImage;t&&t.getElement()?i(t):n(hi)}),go)})):L().reject(ui)}}]),i}(ho),po=vo,mo=["tl","tr","mt","ml","mr","mb","bl","br"],yo=function(){};function bo(t,e){return t>e?"width":"height"}var xo=z.fabric.util.createClass(z.fabric.Rect,{initialize:function(t,e,i){(e=R()(e,i)).type="cropzone",this.callSuper("initialize",e),this._addEventHandler(),this.canvas=t,this.options=e},canvasEventDelegation:function(t){var e,i="unregistered";return this.canvasEventTrigger[t]!==yo?i="registered":o()(e=[Jt,Qt]).call(e,t)<0&&(i="none"),i},canvasEventRegister:function(t,e){this.canvasEventTrigger[t]=e},_addEventHandler:function(){var t,e,i,n,r;this.canvasEventTrigger=(S(t={},Jt,yo),S(t,Qt,yo),t),this.on({moving:A()(e=this._onMoving).call(e,this),scaling:A()(i=this._onScaling).call(i,this)}),z.fabric.util.addListener(document,"keydown",A()(n=this._onKeyDown).call(n,this)),z.fabric.util.addListener(document,"keyup",A()(r=this._onKeyUp).call(r,this))},_renderCropzone:function(t){var e=this.flipX?-1:1,i=this.flipY?-1:1,n=e/this.scaleX,r=i/this.scaleY;t.scale(n,r),this._fillOuterRect(t,"rgba(0, 0, 0, 0.5)"),this.options.lineWidth?(this._fillInnerRect(t),this._strokeBorder(t,"rgb(255, 255, 255)",{lineWidth:this.options.lineWidth})):(this._strokeBorder(t,"rgb(0, 0, 0)",{lineDashWidth:7}),this._strokeBorder(t,"rgb(255, 255, 255)",{lineDashWidth:7,lineDashOffset:7})),t.scale(1/n,1/r)},_render:function(t){this.callSuper("_render",t),this._renderCropzone(t)},_fillOuterRect:function(t,e){var i=this._getCoordinates(),n=i.x,r=i.y;t.save(),t.fillStyle=e,t.beginPath(),t.moveTo(n[0]-1,r[0]-1),t.lineTo(n[3]+1,r[0]-1),t.lineTo(n[3]+1,r[3]+1),t.lineTo(n[0]-1,r[3]+1),t.lineTo(n[0]-1,r[0]-1),t.closePath(),t.moveTo(n[1],r[1]),t.lineTo(n[1],r[2]),t.lineTo(n[2],r[2]),t.lineTo(n[2],r[1]),t.lineTo(n[1],r[1]),t.closePath(),nt()(t).call(t),t.restore()},_fillInnerRect:function(t){var e=this._getCoordinates(),i=e.x,n=e.y,r=this._caculateInnerPosition(i,(i[2]-i[1])/3),o=this._caculateInnerPosition(n,(n[2]-n[1])/3);t.save(),t.strokeStyle="rgba(255, 255, 255, 0.7)",t.lineWidth=this.options.lineWidth,t.beginPath(),t.moveTo(r[0],o[1]),t.lineTo(r[3],o[1]),t.moveTo(r[0],o[2]),t.lineTo(r[3],o[2]),t.moveTo(r[1],o[0]),t.lineTo(r[1],o[3]),t.moveTo(r[2],o[0]),t.lineTo(r[2],o[3]),t.stroke(),t.closePath(),t.restore()},_caculateInnerPosition:function(t,e){var i=[];return i[0]=t[1],i[1]=t[1]+e,i[2]=t[1]+2*e,i[3]=t[2],i},_getCoordinates:function(){var t,e,i=this.canvas,n=this.width,r=this.height,o=this.left,a=this.top,s=n/2,c=r/2,l=i.getHeight(),u=i.getWidth();return{x:pn()(t=[-(s+o),-s,s,s+(u-o-n)]).call(t,Math.ceil),y:pn()(e=[-(c+a),-c,c,c+(l-a-r)]).call(e,Math.ceil)}},_strokeBorder:function(t,e,i){var n=i.lineDashWidth,r=i.lineDashOffset,o=i.lineWidth,a=this.width/2,s=this.height/2;t.save(),t.strokeStyle=e,t.setLineDash&&t.setLineDash([n,n]),r&&(t.lineDashOffset=r),o&&(t.lineWidth=o),t.beginPath(),t.moveTo(-a,-s),t.lineTo(a,-s),t.lineTo(a,s),t.lineTo(-a,s),t.lineTo(-a,-s),t.stroke(),t.restore()},_onMoving:function(){var t=this.height,e=this.width,i=this.left,n=this.top,r=this.canvas.getWidth()-e,o=this.canvas.getHeight()-t;this.left=Ni(i,0,r),this.top=Ni(n,0,o),this.canvasEventTrigger[Jt](this)},_onScaling:function(t){var e=t.transform.corner,i=this.canvas.getPointer(t.e),n=this._calcScalingSizeFromPointer(i,e);this.scale(1).set(n),this.canvasEventTrigger[Qt](this)},_calcScalingSizeFromPointer:function(t,e){var i=function(t){return o()(mo).call(mo,t)>=0}(e);return i&&this._resizeCropZone(t,e)},adjustRatioCropzoneSize:function(t){var e=t.width,i=t.height,n=t.leftMaker,r=t.topMaker,o=t.maxWidth,a=t.maxHeight,s=t.scaleTo;if(e=o?Ni(e,1,o):e,i=a?Ni(i,1,a):i,!this.presetRatio)return this._withShiftKey&&(e>i?i=e:i>e&&(e=i)),{width:e,height:i,left:n(e),top:r(i)};"width"===s?i=e/this.presetRatio:e=i*this.presetRatio;var c=Math.min(o/e,a/i);if(c<=1){var l,u=Q(pn()(l=[e,i]).call(l,(function(t){return t*c})),2);e=u[0],i=u[1]}return{width:e,height:i,left:n(e),top:r(i)}},_getCropzoneRectInfo:function(){var t=this.canvas,e=t.width,i=t.height,n=this.getBoundingRect(!1,!0),r=n.top,o=n.left,a=n.width,s=n.height;return{rectTop:r,rectLeft:o,rectWidth:a,rectHeight:s,rectRight:o+a,rectBottom:r+s,canvasWidth:e,canvasHeight:i}},_resizeCropZone:function(t,e){var i=t.x,n=t.y,r=this._getCropzoneRectInfo(),o=r.rectWidth,a=r.rectHeight,s=r.rectTop,c=r.rectLeft,l=r.rectBottom,u=r.rectRight,h=r.canvasWidth,f=r.canvasHeight,g={tl:{width:u-i,height:l-n,leftMaker:function(t){return u-t},topMaker:function(t){return l-t},maxWidth:u,maxHeight:l,scaleTo:bo(c-i,s-n)},tr:{width:i-c,height:l-n,leftMaker:function(){return c},topMaker:function(t){return l-t},maxWidth:h-c,maxHeight:l,scaleTo:bo(i-u,s-n)},mt:{width:o,height:l-n,leftMaker:function(){return c},topMaker:function(t){return l-t},maxWidth:h-c,maxHeight:l,scaleTo:"height"},ml:{width:u-i,height:a,leftMaker:function(t){return u-t},topMaker:function(){return s},maxWidth:u,maxHeight:f-s,scaleTo:"width"},mr:{width:i-c,height:a,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:"width"},mb:{width:o,height:n-s,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:"height"},bl:{width:u-i,height:n-s,leftMaker:function(t){return u-t},topMaker:function(){return s},maxWidth:u,maxHeight:f-s,scaleTo:bo(c-i,n-l)},br:{width:i-c,height:n-s,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:bo(i-u,n-l)}};return this.adjustRatioCropzoneSize(g[e])},isValid:function(){return this.left>=0&&this.top>=0&&this.width>0&&this.height>0},_onKeyDown:function(t){t.keyCode===Ke&&(this._withShiftKey=!0)},_onKeyUp:function(t){t.keyCode===Ke&&(this._withShiftKey=!1)}}),Co=xo;function Io(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var _o={presetRatio:null,top:-10,left:-10,height:1,width:1},Mo=function(t){wn(i,t);var e=Io(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.CROPPER,t))._cropzone=null,c._startX=null,c._startY=null,c._withShiftKey=!1,c._listeners={keydown:A()(n=c._onKeyDown).call(n,Dn(c)),keyup:A()(r=c._onKeyUp).call(r,Dn(c)),mousedown:A()(o=c._onFabricMouseDown).call(o,Dn(c)),mousemove:A()(a=c._onFabricMouseMove).call(a,Dn(c)),mouseup:A()(s=c._onFabricMouseUp).call(s,Dn(c))},c}return T(i,[{key:"start",value:function(){if(!this._cropzone){var t=this.getCanvas();t.forEachObject((function(t){t.evented=!1})),this._cropzone=new Co(t,R()({left:0,top:0,width:.5,height:.5,strokeWidth:0,cornerSize:10,cornerColor:"black",fill:"transparent"},wt,this.graphics.cropSelectionStyle)),t.discardActiveObject(),t.add(this._cropzone),t.on("mouse:down",this._listeners.mousedown),t.selection=!1,t.defaultCursor="crosshair",z.fabric.util.addListener(document,"keydown",this._listeners.keydown),z.fabric.util.addListener(document,"keyup",this._listeners.keyup)}}},{key:"end",value:function(){var t=this.getCanvas(),e=this._cropzone;e&&(t.remove(e),t.selection=!0,t.defaultCursor="default",t.off("mouse:down",this._listeners.mousedown),t.forEachObject((function(t){t.evented=!0})),this._cropzone=null,z.fabric.util.removeListener(document,"keydown",this._listeners.keydown),z.fabric.util.removeListener(document,"keyup",this._listeners.keyup))}},{key:"changeVisibility",value:function(t){this._cropzone&&this._cropzone.set({visible:t})}},{key:"_onFabricMouseDown",value:function(t){var e=this.getCanvas();if(!t.target){e.selection=!1;var i=e.getPointer(t.e);this._startX=i.x,this._startY=i.y,e.on({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup})}}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e),n=i.x,r=i.y,o=this._cropzone;Math.abs(n-this._startX)+Math.abs(r-this._startY)>10&&(e.remove(o),o.set(this._calcRectDimensionFromPoint(n,r,o.presetRatio)),e.add(o),e.setActiveObject(o))}},{key:"_calcRectDimensionFromPoint",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.getCanvas(),r=n.getWidth(),o=n.getHeight(),a=this._startX,s=this._startY,c=Ni(t,0,a),l=Ni(e,0,s),u=Ni(t,a,r)-c,h=Ni(e,s,o)-l;return this._withShiftKey&&!i?(u>h?h=u:h>u&&(u=h),a>=t&&(c=a-u),s>=e&&(l=s-h)):i&&(h=u/i,a>=t&&(c=Ni(a-u,0,r)),s>=e&&(l=Ni(s-h,0,o)),l+h>o&&(u=(h=o-l)*i,a>=t&&(c=Ni(a-u,0,r)),s>=e&&(l=Ni(s-h,0,o)))),{left:c,top:l,width:u,height:h}}},{key:"_onFabricMouseUp",value:function(){var t=this._cropzone,e=this._listeners,i=this.getCanvas();i.setActiveObject(t),i.off({"mouse:move":e.mousemove,"mouse:up":e.mouseup})}},{key:"getCroppedImageData",value:function(t){var e=this.getCanvas(),i=e.contains(this._cropzone);if(!t)return null;i&&e.remove(this._cropzone);var n={imageName:this.getImageName(),url:e.toDataURL(t)};return i&&e.add(this._cropzone),n}},{key:"getCropzoneRect",value:function(){var t=this._cropzone;return t.isValid()?{left:t.left,top:t.top,width:t.width,height:t.height}:null}},{key:"setCropzoneRect",value:function(t){var e=this.getCanvas(),i=this._cropzone;e.discardActiveObject(),e.selection=!1,e.remove(i),i.set(t?this._getPresetPropertiesForCropSize(t):_o),e.add(i),e.selection=!0,t&&e.setActiveObject(i)}},{key:"_getPresetPropertiesForCropSize",value:function(t){var e,i,n=this.getCanvas(),r=n.getWidth(),o=n.getHeight(),a=r>=o?r:o,s=function(t,e){return t>e?e/t:1},c=a*t,l=a,u=s(c,r),h=Q(pn()(e=[c,l]).call(e,(function(t){return t*u})),2);c=h[0];var f=s(l=h[1],o),g=Q(pn()(i=[c,l]).call(i,(function(t){return Number((t*f).toFixed(2))})),2);return c=g[0],{presetRatio:t,top:(o-(l=g[1]))/2,left:(r-c)/2,width:c,height:l}}},{key:"_onKeyDown",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!0)}},{key:"_onKeyUp",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!1)}}]),i}(ho),So=Mo;function wo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ko=function(t){wn(i,t);var e=wo(i);function i(t){return w(this,i),e.call(this,St.FLIP,t)}return T(i,[{key:"getCurrentSetting",value:function(){var t=this.getCanvasImage();return{flipX:t.flipX,flipY:t.flipY}}},{key:"set",value:function(t){var e=this.getCurrentSetting(),i=e.flipX!==t.flipX,n=e.flipY!==t.flipY;return i||n?(R()(e,t),this.setImageProperties(e,!0),this._invertAngle(i,n),this._flipObjects(i,n),L().resolve({flipX:e.flipX,flipY:e.flipY,angle:this.getCanvasImage().angle})):L().reject(si)}},{key:"_invertAngle",value:function(t,e){var i=this.getCanvasImage(),n=i.angle;t&&(n*=-1),e&&(n*=-1),i.rotate(dn()(n)).setCoords()}},{key:"_flipObjects",value:function(t,e){var i=this.getCanvas();t&&i.forEachObject((function(t){t.set({angle:dn()(-1*t.angle),flipX:!t.flipX,left:i.width-t.left}).setCoords()})),e&&i.forEachObject((function(t){t.set({angle:dn()(-1*t.angle),flipY:!t.flipY,top:i.height-t.top}).setCoords()})),i.renderAll()}},{key:"reset",value:function(){return this.set({flipX:!1,flipY:!1})}},{key:"flipX",value:function(){var t=this.getCurrentSetting();return this.set({flipX:!t.flipX,flipY:t.flipY})}},{key:"flipY",value:function(){var t=this.getCurrentSetting();return this.set({flipX:t.flipX,flipY:!t.flipY})}}]),i}(ho),To=ko;function Do(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ao=function(t){wn(i,t);var e=Do(i);function i(t){return w(this,i),e.call(this,St.ROTATION,t)}return T(i,[{key:"getCurrentAngle",value:function(){return this.getCanvasImage().angle}},{key:"setAngle",value:function(t){var e=this.getCurrentAngle()%360;t%=360;var i=this.getCanvasImage(),n=i.getCenterPoint();i.set({angle:t}).setCoords(),this.adjustCanvasDimension();var r=i.getCenterPoint();return this._rotateForEachObject(n,r,t-e),L().resolve(t)}},{key:"_rotateForEachObject",value:function(t,e,i){var n=this.getCanvas(),r=t.x-e.x,o=t.y-e.y;n.forEachObject((function(e){var n=e.getCenterPoint(),a=z.fabric.util.degreesToRadians(i),s=z.fabric.util.rotatePoint(n,t,a);e.set({left:s.x-r,top:s.y-o,angle:(e.angle+i)%360}),e.setCoords()})),n.renderAll()}},{key:"rotate",value:function(t){var e=this.getCurrentAngle();return this.setAngle(e+t)}}]),i}(ho),jo=Ao,Oo=n(7567);function Eo(t,e,i,n,r,o,a){try{var s=t[o](a),c=s.value}catch(t){return void i(t)}s.done?e(c):Oo.resolve(c).then(n,r)}var Lo=n(261),No=n.n(Lo);function Po(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var zo=function(t){wn(r,t);var e,i,n=Po(r);function r(t){var e,i,o,a;return w(this,r),(a=n.call(this,St.FREE_DRAWING,t)).width=12,a.oColor=new z.fabric.Color("rgba(0, 0, 0, 0.5)"),a._handlers={mousedown:A()(e=a._onFabricMouseDown).call(e,Dn(a)),mousemove:A()(i=a._onFabricMouseMove).call(i,Dn(a)),mouseup:A()(o=a._onMasikMouseUp).call(o,Dn(a))},a.imageEditor=null,a}return T(r,[{key:"start",value:function(t){if(console.log(t),null!=t&&t.mosaic)this.setMosaic(t);else{var e=this.getCanvas();console.log(e),e.isDrawingMode=!0,this.setBrush(t)}}},{key:"setBrush",value:function(t){var e=this.getCanvas().freeDrawingBrush;t=t||{},this.width=t.width||this.width,t.color&&(this.oColor=new z.fabric.Color(t.color)),e.width=this.width,e.color=this.oColor.toRgba()}},{key:"end",value:function(){var t=this.getCanvas();t.isDrawingMode=!1,t.selection=!0,t.off("mouse:down",this._handlers.mousedown)}},{key:"setMosaic",value:function(t){this.imageEditor=t.imageEditor,this.width=t.width;var e=this.getCanvas();e.selection=!1,e.on("mouse:down",this._handlers.mousedown)}},{key:"_onFabricMouseDown",value:function(){this.getCanvas().on({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=this.width,n=this.width/2,r=e.getPointer(t.e);console.log(r);var o=r.x-n;console.log(o);for(var a=r.y-n,s=e.contextContainer,c=s.getImageData(o,a,i,i),l=c.data,u=0,h=0,f=0,g=0;g<l.length;g+=4)u+=l[g],h+=l[g+1],f+=l[g+2];u=Math.floor(u/(i*i)),h=Math.floor(h/(i*i)),f=Math.floor(f/(i*i));for(var d=0;d<l.length;d+=4)l[d]=u,l[d+1]=h,l[d+2]=f,l[d+3]=255;s.putImageData(c,o,a)}},{key:"_onMasikMouseUp",value:(e=No().mark((function t(){var e,i,n,r,o,a,s;return No().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=document.getElementsByClassName("lower-canvas"),i=Q(e,1),n=i[0],r=n.toDataURL(),t.next=5,fetch(r);case 5:return o=t.sent,t.next=8,o.blob();case 8:a=t.sent,s=P().createObjectURL(a),this.imageEditor.invoke("addImageObject",s),this.getCanvas().off({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup});case 13:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,i=arguments;return new Oo((function(n,r){var o=e.apply(t,i);function a(t){Eo(o,n,r,a,s,"next",t)}function s(t){Eo(o,n,r,a,s,"throw",t)}a(void 0)}))},function(){return i.apply(this,arguments)})}]),r}(ho),Bo=zo,Ro=z.fabric.util.createClass(z.fabric.Line,{type:"line",initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.callSuper("initialize",t,e),this.arrowType=e.arrowType},_render:function(t){var e=this.calcLinePoints(),i={fromX:e.x1,fromY:e.y1,toX:e.x2,toY:e.y2};this.ctx=t,t.lineWidth=this.strokeWidth,this._renderBasicLinePath(i),this._drawDecoratorPath(i),this._renderStroke(t)},_renderBasicLinePath:function(t){var e=t.fromX,i=t.fromY,n=t.toX,r=t.toY;this.ctx.beginPath(),this.ctx.moveTo(e,i),this.ctx.lineTo(n,r)},_drawDecoratorPath:function(t){this._drawDecoratorPathType("head",t),this._drawDecoratorPathType("tail",t)},_drawDecoratorPathType:function(t,e){switch(this.arrowType[t]){case"triangle":this._drawTrianglePath(t,e);break;case"chevron":this._drawChevronPath(t,e)}},_drawTrianglePath:function(t,e){var i=1.7*this.ctx.lineWidth;this._drawChevronPath(t,e,i),this.ctx.closePath()},_drawChevronPath:function(t,e,i){var n=this,r=e.fromX,o=e.fromY,a=e.toX,s=e.toY,c=this.ctx;i||(i=2.7*this.ctx.lineWidth);var l=Q("head"===t?[r,o]:[a,s],2),u=l[0],h=l[1],f=Q("head"===t?[a,s]:[r,o],2),g=f[0],d=f[1],v=180*Math.atan2(d-h,g-u)/Math.PI,p=function(t){return n.getRotatePosition(i,t,{x:u,y:h})};c.moveTo.apply(c,_(p(v+30))),c.lineTo(u,h),c.lineTo.apply(c,_(p(v-30)))},getRotatePosition:function(t,e,i){var n=e*Math.PI/180,r=i.x,o=i.y;return[t*Math.cos(n)+r,t*Math.sin(n)+o]}}),Fo=Ro;function Yo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Wo=function(t){wn(i,t);var e=Yo(i);function i(t){var n,r,o,a;return w(this,i),(a=e.call(this,St.LINE,t))._width=12,a._oColor=new z.fabric.Color("rgba(0, 0, 0, 0.5)"),a._listeners={mousedown:A()(n=a._onFabricMouseDown).call(n,Dn(a)),mousemove:A()(r=a._onFabricMouseMove).call(r,Dn(a)),mouseup:A()(o=a._onFabricMouseUp).call(o,Dn(a))},a}return T(i,[{key:"setHeadOption",value:function(t){var e=t.arrowType,i=void 0===e?{head:null,tail:null}:e;this._arrowType=i}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.getCanvas();e.defaultCursor="crosshair",e.selection=!1,this.setHeadOption(t),this.setBrush(t),e.forEachObject((function(t){t.set({evented:!1})})),e.on({"mouse:down":this._listeners.mousedown})}},{key:"setBrush",value:function(t){var e=this.getCanvas().freeDrawingBrush;t=t||{},this._width=t.width||this._width,t.color&&(this._oColor=new z.fabric.Color(t.color)),e.width=this._width,e.color=this._oColor.toRgba()}},{key:"end",value:function(){var t=this.getCanvas();t.defaultCursor="default",t.selection=!0,t.forEachObject((function(t){t.set({evented:!0})})),t.off("mouse:down",this._listeners.mousedown)}},{key:"_onFabricMouseDown",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e),n=i.x,r=i.y,o=[n,r,n,r];this._line=new Fo(o,{stroke:this._oColor.toRgba(),strokeWidth:this._width,arrowType:this._arrowType,evented:!1}),this._line.set(oi),e.add(this._line),e.on({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup}),this.fire(oe,this._createLineEventObjectProperties())}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e);this._line.set({x2:i.x,y2:i.y}),this._line.setCoords(),e.renderAll()}},{key:"_onFabricMouseUp",value:function(){var t=this.getCanvas();this.fire(qt,this._createLineEventObjectProperties()),this._line=null,t.off({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup})}},{key:"_createLineEventObjectProperties",value:function(){var t=this.graphics.createObjectProperties(this._line),e=this._line,i=e.x1,n=e.x2,r=e.y1,o=e.y2;return R()({},t,{startPosition:{x:i,y:r},endPosition:{x:n,y:o}})}}]),i}(ho),Ho=Wo;function Uo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Go={fill:"#000000",left:0,top:0},Xo={fill:"#000000",fontStyle:"normal",fontWeight:"normal",textAlign:"tie-text-align-left",underline:!1},Zo=function(t){wn(i,t);var e=Uo(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.TEXT,t))._defaultStyles=Go,c._isSelected=!1,c._selectedObj={},c._editingObj={},c._listeners={mousedown:A()(n=c._onFabricMouseDown).call(n,Dn(c)),select:A()(r=c._onFabricSelect).call(r,Dn(c)),selectClear:A()(o=c._onFabricSelectClear).call(o,Dn(c)),scaling:A()(a=c._onFabricScaling).call(a,Dn(c)),textChanged:A()(s=c._onFabricTextChanged).call(s,Dn(c))},c._textarea=null,c._ratio=1,c._lastClickTime=(new Date).getTime(),c._editingObjInfos={},c.isPrevEditing=!1,c}return T(i,[{key:"start",value:function(){var t=this,e=this.getCanvas();e.selection=!1,e.defaultCursor="text",e.on({"mouse:down":this._listeners.mousedown,"selection:created":this._listeners.select,"selection:updated":this._listeners.select,"before:selection:cleared":this._listeners.selectClear,"object:scaling":this._listeners.scaling,"text:changed":this._listeners.textChanged}),e.forEachObject((function(e){"i-text"===e.type&&t.adjustOriginPosition(e,"start")})),this.setCanvasRatio()}},{key:"end",value:function(){var t=this,e=this.getCanvas();e.selection=!0,e.defaultCursor="default",e.forEachObject((function(i){"i-text"===i.type&&(""===i.text?e.remove(i):t.adjustOriginPosition(i,"end"))})),e.off({"mouse:down":this._listeners.mousedown,"selection:created":this._listeners.select,"selection:updated":this._listeners.select,"before:selection:cleared":this._listeners.selectClear,"object:selected":this._listeners.select,"object:scaling":this._listeners.scaling,"text:changed":this._listeners.textChanged})}},{key:"adjustOriginPosition",value:function(t,e){var i="center",n="center";"start"===e&&(i="left",n="top");var r=t.getPointByOrigin(i,n),o=r.x,a=r.y;t.set({left:o,top:a,originX:i,originY:n}),t.setCoords()}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n){var r,o=i.getCanvas(),a=null,s=oi,c=i._defaultStyles;i._setInitPos(e.position),e.styles&&(c=R()(c,e.styles)),Dr()(e.autofocus)||(e.autofocus=!0),a=new z.fabric.IText(t,c),s=R()({},s,{originX:"left",originY:"top"}),a.set(s),a.on({mouseup:A()(r=i._onFabricMouseUp).call(r,i)}),o.add(a),e.autofocus&&(a.enterEditing(),a.selectAll()),o.getActiveObject()||o.setActiveObject(a),i.isPrevEditing=!0,n(i.graphics.createObjectProperties(a))}))}},{key:"change",value:function(t,e){var i=this;return new(L())((function(n){t.set("text",e),i.getCanvas().renderAll(),n()}))}},{key:"setStyle",value:function(t,e){var i=this;return new(L())((function(n){H()(e,(function(i,n){t[n]===i&&"fontSize"!==n&&(e[n]=Xo[n]||"")}),i),"textDecoration"in e&&R()(e,i._getTextDecorationAdaptObject(e.textDecoration)),t.set(e),i.getCanvas().renderAll(),n()}))}},{key:"getText",value:function(t){return t.text}},{key:"setSelectedInfo",value:function(t,e){this._selectedObj=t,this._isSelected=e}},{key:"isSelected",value:function(){return this._isSelected}},{key:"getSelectedObj",value:function(){return this._selectedObj}},{key:"setCanvasRatio",value:function(){var t=this.getCanvasElement(),e=$()(t.style.maxWidth,10),i=t.width;this._ratio=i/e}},{key:"getCanvasRatio",value:function(){return this._ratio}},{key:"_getTextDecorationAdaptObject",value:function(t){return{underline:"underline"===t,linethrough:"line-through"===t,overline:"overline"===t}}},{key:"_setInitPos",value:function(t){t=t||this.getCanvasImage().getCenterPoint(),this._defaultStyles.left=t.x,this._defaultStyles.top=t.y}},{key:"_onInput",value:function(){var t=this.getCanvasRatio(),e=this._editingObj,i=this._textarea.style;i.width="".concat(Math.ceil(e.width/t),"px"),i.height="".concat(Math.ceil(e.height/t),"px")}},{key:"_onKeyDown",value:function(){var t=this,e=this.getCanvasRatio(),i=this._editingObj,n=this._textarea.style;v()((function(){i.text(t._textarea.value),n.width="".concat(Math.ceil(i.width/e),"px"),n.height="".concat(Math.ceil(i.height/e),"px")}),0)}},{key:"_onBlur",value:function(){var t=this.getCanvasRatio(),e=this._editingObj,i=this._editingObjInfos,n=this._textarea.value,r=e.width/t-i.width/t,o=e.height/t-i.height/t;if(1===t&&(r/=2,o/=2),this._textarea.style.display="none",e.set({left:i.left+r,top:i.top+o}),n.length){this.getCanvas().add(e);var a={id:Ei(e),type:e.type,text:n};this.fire(ee,a)}}},{key:"_onScroll",value:function(){this._textarea.scrollLeft=0,this._textarea.scrollTop=0}},{key:"_onFabricScaling",value:function(t){var e=t.target;e.fontSize=e.fontSize*e.scaleY,e.scaleX=1,e.scaleY=1}},{key:"_onFabricTextChanged",value:function(t){this.fire(ee,t.target)}},{key:"_onFabricSelectClear",value:function(t){var e=this.getSelectedObj();this.isPrevEditing=!0,this.setSelectedInfo(t.target,!1),e&&""===e.text&&this.getCanvas().remove(e)}},{key:"_onFabricSelect",value:function(t){this.isPrevEditing=!0,this.setSelectedInfo(t.target,!0)}},{key:"_onFabricMouseDown",value:function(t){var e=t.target;e&&!e.isType("text")||(this.isPrevEditing?this.isPrevEditing=!1:this._fireAddText(t))}},{key:"_fireAddText",value:function(t){var e=t.target,i=t.e||{},n=this.getCanvas().getPointer(i);e||this.fire(re,{originPosition:{x:n.x,y:n.y},clientPosition:{x:i.clientX||0,y:i.clientY||0}})}},{key:"_onFabricMouseUp",value:function(t){var e=t.target,i=(new Date).getTime();this._isDoubleClick(i)&&!e.isEditing&&e.enterEditing(),e.isEditing&&this.fire(te),this._lastClickTime=i}},{key:"_isDoubleClick",value:function(t){return t-this._lastClickTime<500}}]),i}(ho),Vo=Zo;function Jo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Qo={arrow:"M 0 90 H 105 V 120 L 160 60 L 105 0 V 30 H 0 Z",cancel:"M 0 30 L 30 60 L 0 90 L 30 120 L 60 90 L 90 120 L 120 90 L 90 60 L 120 30 L 90 0 L 60 30 L 30 0 Z"},Ko=function(t){wn(i,t);var e=Jo(i);function i(t){var n,r,o,a;return w(this,i),(a=e.call(this,St.ICON,t))._oColor="#000000",a._pathMap=Qo,a._type=null,a._iconColor=null,a._handlers={mousedown:A()(n=a._onFabricMouseDown).call(n,Dn(a)),mousemove:A()(r=a._onFabricMouseMove).call(r,Dn(a)),mouseup:A()(o=a._onFabricMouseUp).call(o,Dn(a))},a}return T(i,[{key:"setStates",value:function(t,e){this._type=t,this._iconColor=e}},{key:"start",value:function(){var t=this.getCanvas();t.selection=!1,t.on("mouse:down",this._handlers.mousedown)}},{key:"end",value:function(){var t=this.getCanvas();t.selection=!0,t.off({"mouse:down":this._handlers.mousedown})}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n,r){var o=i.getCanvas(),a=i._pathMap[t],s=oi,c=a?i._createIcon(a):null;i._icon=c,c||r(ci),c.set(R()({type:"icon",fill:i._oColor},s,e,i.graphics.controlStyle)),o.add(c).setActiveObject(c),n(i.graphics.createObjectProperties(c))}))}},{key:"registerPaths",value:function(t){var e=this;H()(t,(function(t,i){e._pathMap[i]=t}),this)}},{key:"setColor",value:function(t,e){this._oColor=t,e&&"icon"===e.get("type")&&(e.set({fill:this._oColor}),this.getCanvas().renderAll())}},{key:"getColor",value:function(t){return nt()(t)}},{key:"_createIcon",value:function(t){return new z.fabric.Path(t)}},{key:"_onFabricMouseDown",value:function(t){var e=this,i=this.getCanvas();this._startPoint=i.getPointer(t.e);var n=this._startPoint,r=n.x,o=n.y;this.add(this._type,{left:r,top:o,fill:this._iconColor}).then((function(){e.fire(oe,e.graphics.createObjectProperties(e._icon)),i.on("mouse:move",e._handlers.mousemove),i.on("mouse:up",e._handlers.mouseup)}))}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas();if(this._icon){var i=e.getPointer(t.e),n=(i.x-this._startPoint.x)/this._icon.width,r=(i.y-this._startPoint.y)/this._icon.height;this._icon.set({scaleX:Math.abs(2*n),scaleY:Math.abs(2*r)}),this._icon.setCoords(),e.renderAll()}}},{key:"_onFabricMouseUp",value:function(){var t=this.getCanvas();this.fire(qt,this.graphics.createObjectProperties(this._icon)),this._icon=null,t.off("mouse:down",this._handlers.mousedown),t.off("mouse:move",this._handlers.mousemove),t.off("mouse:up",this._handlers.mouseup)}}]),i}(ho),qo=Ko,$o=z.fabric.util.createClass(z.fabric.Image.filters.BlendImage,{applyTo:function(t){if(this.mask){var e=t.canvasEl,i=e.width,n=e.height,r=this._createCanvasOfMask(i,n),o=e.getContext("2d"),a=r.getContext("2d"),s=o.getImageData(0,0,i,n);this._drawMask(a,e,o),this._mapData(a,s,i,n),t.imageData=s}},_createCanvasOfMask:function(t,e){var i=z.fabric.util.createCanvasElement();return i.width=t,i.height=e,i},_drawMask:function(t){var e=this.mask,i=e.getElement(),n=e.angle,r=e.left,o=e.scaleX,a=e.scaleY,s=e.top;t.save(),t.translate(r,s),t.rotate(n*Math.PI/180),t.scale(o,a),t.drawImage(i,-i.width/2,-i.height/2),t.restore()},_mapData:function(t,e,i,n){for(var r=e.data,o=e.height,a=r,s=e.width*o*4,c=t.getImageData(0,0,i,n).data,l=0;l<s;l+=4)a[l+3]=c[l]}}),ta=$o,ea=z.fabric.util.createClass(z.fabric.Image.filters.Convolute,{type:"Sharpen",initialize:function(){this.matrix=[0,-1,0,-1,5,-1,0,-1,0]}}),ia=z.fabric.util.createClass(z.fabric.Image.filters.Convolute,{type:"Emboss",initialize:function(){this.matrix=[1,1,1,1,.7,-1,-1,-1,-1]}}),na=z.fabric.util.createClass(z.fabric.Image.filters.BaseFilter,{type:"ColorFilter",initialize:function(t){t||(t={}),this.color=t.color||"#FFFFFF",this.threshold=t.threshold||45,this.x=t.x||null,this.y=t.y||null},applyTo:function(t){var e,i,n=t.canvasEl,r=n.getContext("2d"),o=r.getImageData(0,0,n.width,n.height),a=o.data,s=this.threshold,c=z.fabric.Color.sourceFromHex(this.color);for(this.x&&this.y&&(c=this._getColor(o,this.x,this.y)),e=0,i=a.length;e<i;e+=4)this._isOutsideThreshold(a[e],c[0],s)||this._isOutsideThreshold(a[e+1],c[1],s)||this._isOutsideThreshold(a[e+2],c[2],s)||(a[e]=a[e+1]=a[e+2]=a[e+3]=0);r.putImageData(o,0,0)},_isOutsideThreshold:function(t,e,i){var n=t-e;return Math.abs(n)>i},_getColor:function(t,e,i){var n=[0,0,0,0],r=t.data,o=4*(t.width*i+e);return n[0]=r[o],n[1]=r[o+1],n[2]=r[o+2],n[3]=r[o+3],n}});function ra(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var oa=z.fabric.Image.filters;oa.Mask=ta,oa.Sharpen=ea,oa.Emboss=ia,oa.ColorFilter=na;var aa,sa,ca,la=function(t){wn(i,t);var e=ra(i);function i(t){return w(this,i),e.call(this,St.FILTER,t)}return T(i,[{key:"add",value:function(t,e){var i=this;return new(L())((function(n,r){var o=i._getSourceImage(),a=i.getCanvas(),s=i._getFilter(o,t);s||(s=i._createFilter(o,t,e)),s||r(ci),i._changeFilterValues(s,e),i._apply(o,(function(){a.renderAll(),n({type:t,action:"add",options:e})}))}))}},{key:"remove",value:function(t){var e=this;return new(L())((function(i,n){var r=e._getSourceImage(),o=e.getCanvas(),a=e.getOptions(t);r.filters.length||n(vi),e._removeFilter(r,t),e._apply(r,(function(){o.renderAll(),i({type:t,action:"remove",options:a})}))}))}},{key:"hasFilter",value:function(t){return!!this._getFilter(this._getSourceImage(),t)}},{key:"getOptions",value:function(t){var e=this._getSourceImage(),i=this._getFilter(e,t);return i?R()({},i.options):null}},{key:"_changeFilterValues",value:function(t,e){H()(e,(function(e,i){Y()(t[i])||(t[i]=e)})),H()(t.options,(function(i,n){Y()(e[n])||(t.options[n]=e[n])}))}},{key:"_apply",value:function(t,e){t.filters.push(),t.applyFilters()&&e()}},{key:"_getSourceImage",value:function(){return this.getCanvasImage()}},{key:"_createFilter",value:function(t,e,i){var n,r=this._getFabricFilterType(e),o=z.fabric.Image.filters[r];return o&&((n=new o(i)).options=i,t.filters.push(n)),n}},{key:"_getFilter",value:function(t,e){var i=null;if(t){var n,r,o=this._getFabricFilterType(e),a=t.filters.length;for(r=0;r<a;r+=1)if((n=t.filters[r]).type===o){i=n;break}}return i}},{key:"_removeFilter",value:function(t,e){var i,n=this._getFabricFilterType(e);t.filters=no()(i=t.filters).call(i,(function(t){return t.type!==n}))}},{key:"_getFabricFilterType",value:function(t){return t.charAt(0).toUpperCase()+h()(t).call(t,1)}}]),i}(ho),ua=la,ha=n(1801),fa=n.n(ha),ga={pixelate:"blocksize",blur:"blur"},da={x:"width",y:"height"},va=(aa=ga,ca={},et()(sa=J()(aa)).call(sa,(function(t){ca[aa[t]]=t})),ca),pa=null;function ma(t){return Q(Gi(t,"patternSourceCanvas").patternSourceCanvas.getObjects(),1)[0]}function ya(t){var e=t.angle,i=t.flipX,n=t.flipY,r=ma(t),o=function(t){var e=Q(Ia(t),4),i=e[0],n=i.x,r=i.y,o=e[1],a=o.x,s=o.y,c=e[2],l=c.x,u=c.y,h=e[3],f=h.x,g=h.y,d=Math.min(n,a,l,f),v=Math.min(r,s,u,g),p=Math.max(n,a,l,f),m=Math.max(r,s,u,g);return{left:d,top:v,right:p,bottom:m,width:p-d,height:m-v}}(t),a=o.right,s=o.bottom,c=o.width,l=o.height,u=(c-t.width)/2,h=(l-t.height)/2,f=t.left-t.width/2-u,g=t.top-t.height/2-h,d=c/2-u,v=l/2-h,p=Math.max(c,l)+Math.max(u,h),m=function(t){var e=t.shapeObj,i=t.left,n=t.top,r=t.width,o=t.height,a=t.cropX,s=t.cropY,c=t.flipX,l=t.flipY,u=t.right,h=t.bottom,f=function(t,i,n,r){return function(t){var e=t.type,i=t.shapeObj,n=t.outDistance,r=t.left,o=t.top,a=t.flipX,s=t.flipY,c=Ia(i),l=function(t,e,i){var n=0,r=0;H()(e,(function(e,i){e[t]<n&&(n=e[t],r=i)}));var o=Q(i[r],2),a=o[0],s=o[1];return{startPointIndex:r,endPointIndex1:a,endPointIndex2:s}}(e,c,[[1,2],[0,3],[0,3],[1,2]]),u=function(t,e,i){var n,r=i.startPointIndex,o=i.endPointIndex1,a=i.endPointIndex2,s="x"===t?180:270;return pn()(n=[o,a]).call(n,(function(t){var i=e[r],n=e[t],o=i.y-n.y,a=i.x-n.x;return 180*Math.atan2(o,a)/Math.PI-s}))}(e,c,l),h=l.startPointIndex,f=function(t){var e=t.outDistance,i=t.startPointIndex,n=t.flipX,r=t.flipY,o=t.reatAngles,a=e*Math.cos(o[0]*Math.PI/180),s=e*Math.cos(o[1]*Math.PI/180),c=2===i||3===i,l={top:c?a:s,left:c?s:a};(function(t,e,i){return(!e&&i||!e&&!i)&&0===t||(e&&i||e&&!i)&&1===t||(!e&&!i||!e&&i)&&2===t||(e&&!i||e&&i)&&3===t})(i,n,r)&&(l.left=-1*l.left);(function(t,e,i){return(e&&!i||!e&&!i)&&0===t||(!e&&!i||e&&!i)&&1===t||(e&&i||!e&&i)&&2===t||(!e&&i||e&&i)&&3===t})(i,n,r)&&(l.top=-1*l.top);return l}({outDistance:n,startPointIndex:h,flipX:a,flipY:s,reatAngles:u});return[r+f.left,o+f.top]}({type:t,outDistance:i,shapeObj:e,flipX:c,flipY:l,left:n,top:r})},g=r,d=o,v=Q(function(t,e){var i=e.left,n=e.top,r=e.width,o=e.height,a=e.cropX,s=e.cropY,c={width:r,height:o};return H()(["x","y"],(function(e){var r="x"===e?a:s,o=c[da[e]],l=pa[da[e]];if(o>l){var u=(o-l)/2;c[da[e]]=l;var h=Q(t(e,u,i,n),2);i=h[0],n=h[1]}if(r<0){var f=Q(t(e,r,i,n),2);i=f[0],n=f[1]}})),[i,n,c.width,c.height]}(f,{left:i,top:n,width:r,height:o,cropX:a,cropY:s}),4);i=v[0],n=v[1],r=v[2],o=v[3];var p=Q(function(t,e){var i=e.left,n=e.top,r=e.insideCanvasRealImageWidth,o=e.insideCanvasRealImageHeight,a=e.right,s=e.bottom,c=e.cropX,l=e.cropY,u=e.originalWidth,h=e.originalHeight,f=r,g=o,d=pa,v=d.width,p=d.height;a>v&&c>0&&(f=u-Math.abs(a-v));s>p&&l>0&&(g=h-Math.abs(s-p));var m={x:(r-f)/2,y:(o-g)/2};return H()(["x","y"],(function(e){var r=m[e];if(r>0){var o=Q(t(e,r,i,n),2);i=o[0],n=o[1]}})),[i,n,f,g]}(f,{left:i,top:n,insideCanvasRealImageWidth:r,insideCanvasRealImageHeight:o,right:u,bottom:h,cropX:a,cropY:s,originalWidth:g,originalHeight:d}),4);return i=p[0],n=p[1],r=p[2],o=p[3],[i,n,r,o]}({shapeObj:t,left:d,top:v,width:c,height:l,cropX:f,cropY:g,flipX:i,flipY:n,right:a,bottom:s}),y=Q(m,4);d=y[0],v=y[1],c=y[2],l=y[3],r.set({angle:i===n?-e:e,left:d,top:v,width:c,height:l,cropX:f,cropY:g,flipX:i,flipY:n}),Ui(r,{fillImageMaxSize:p})}function ba(t){var e;return pn()(e=t.filters).call(e,(function(t){var e=Q(J()(t),1)[0];return S({},va[e],t[e])}))}function xa(t,e,i){var n=_a(Ca(t),t.angle,e);i.add(n);var r={fill:new z.fabric.Pattern({source:i.getElement(),repeat:"no-repeat"})};return Ui(r,{patternSourceCanvas:i}),r}function Ca(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return pa&&!e||(pa=t.toCanvasElement()),pa}function Ia(t){return[t.getPointByOrigin("left","top"),t.getPointByOrigin("right","top"),t.getPointByOrigin("left","bottom"),t.getPointByOrigin("right","bottom")]}function _a(t,e,i){var n,r=new z.fabric.Image(t);return H()(R().apply(void 0,O()(n=[{}]).call(n,_(i))),(function(t,e){var i,n=(i=e).charAt(0).toUpperCase()+h()(i).call(i,1),o=new z.fabric.Image.filters[n](S({},ga[e],t));r.filters.push(o)})),r.applyFilters(),Ui(r,{originalAngle:e,fillImageMaxSize:Math.max(r.width,r.height)}),fa().adjustOriginToCenter(r),r}function Ma(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Sa=R()({strokeWidth:1,stroke:"#000000",fill:"#ffffff",width:1,height:1,rx:0,ry:0},{lockSkewingX:!0,lockSkewingY:!0,bringForward:!0,isRegular:!1});function wa(t,e,i){var n=nt()(t),r=Zi(nt()(t)),o=n;n.color&&(o=n.color);var a=null;if("filter"===r){var s=i();a=xa(e,no()(n),s)}else a={fill:o};return R()({},t,a)}var ka=function(t){wn(i,t);var e=Ma(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.SHAPE,t))._shapeObj=null,c._type="rect",c._options=R()({},Sa),c._isSelected=!1,c._startPoint={},c._withShiftKey=!1,c._handlers={mousedown:A()(n=c._onFabricMouseDown).call(n,Dn(c)),mousemove:A()(r=c._onFabricMouseMove).call(r,Dn(c)),mouseup:A()(o=c._onFabricMouseUp).call(o,Dn(c)),keydown:A()(a=c._onKeyDown).call(a,Dn(c)),keyup:A()(s=c._onKeyUp).call(s,Dn(c))},c}return T(i,[{key:"start",value:function(){var t=this.getCanvas();this._isSelected=!1,t.defaultCursor="crosshair",t.selection=!1,t.uniformScaling=!0,t.on({"mouse:down":this._handlers.mousedown}),z.fabric.util.addListener(document,"keydown",this._handlers.keydown),z.fabric.util.addListener(document,"keyup",this._handlers.keyup)}},{key:"end",value:function(){var t=this.getCanvas();this._isSelected=!1,t.defaultCursor="default",t.selection=!0,t.uniformScaling=!1,t.off({"mouse:down":this._handlers.mousedown}),z.fabric.util.removeListener(document,"keydown",this._handlers.keydown),z.fabric.util.removeListener(document,"keyup",this._handlers.keyup)}},{key:"setStates",value:function(t,e){this._type=t,e&&(this._options=R()(this._options,e))}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n){var r=i.getCanvas(),o=i._extendOptions(e),a=i._createInstance(t,o),s=i.graphics.createObjectProperties(a);i._bindEventOnShape(a),r.add(a).setActiveObject(a),i._resetPositionFillFilter(a),n(s)}))}},{key:"change",value:function(t,e){var i=this;return new(L())((function(n,r){Ji(t)||r(pi);var o="filter"===Zi(nt()(e)),a=i.graphics,s=a.canvasImage,c=a.createStaticCanvas;t.set(o?wa(e,s,c):e),o&&i._resetPositionFillFilter(t),i.getCanvas().renderAll(),n()}))}},{key:"makeFillPropertyForUserEvent",value:function(t){var e=Vi(t),i={};if(e===dt){var n=ba(ma(t));i.type=e,i.filter=n}else i.type=vt,i.color=nt()(t)||"transparent";return i}},{key:"processForCopiedObject",value:function(t,e){if(this._bindEventOnShape(t),"filter"===Vi(t)){var i=ba(ma(e)),n=this.graphics.createStaticCanvas();t.set(xa(this.graphics.canvasImage,i,n)),this._resetPositionFillFilter(t)}}},{key:"_createInstance",value:function(t,e){var i;switch(t){case"rect":i=new z.fabric.Rect(e);break;case"circle":i=new z.fabric.Ellipse(R()({type:"circle"},e));break;case"triangle":i=new z.fabric.Triangle(e);break;default:i={}}return i}},{key:"_extendOptions",value:function(t){var e=oi,i=this.graphics,n=i.canvasImage,r=i.createStaticCanvas;return wa(t=R()({},Sa,this._options,e,t),n,r)}},{key:"_bindEventOnShape",value:function(t){var e=this,i=this.getCanvas();t.on({added:function(){e._shapeObj=this,fa().setOrigins(e._shapeObj)},selected:function(){e._isSelected=!0,e._shapeObj=this,i.uniformScaling=!0,i.defaultCursor="default",fa().setOrigins(e._shapeObj)},deselected:function(){e._isSelected=!1,e._shapeObj=null,i.defaultCursor="crosshair",i.uniformScaling=!1},modified:function(){var t=e._shapeObj;fa().adjustOriginToCenter(t),fa().setOrigins(t)},modifiedInGroup:function(i){e._fillFilterRePositionInGroupSelection(t,i)},moving:function(){e._resetPositionFillFilter(this)},rotating:function(){e._resetPositionFillFilter(this)},scaling:function(t){var n=i.getPointer(t.e),r=e._shapeObj;i.setCursor("crosshair"),fa().resize(r,n,!0),e._resetPositionFillFilter(this)}})}},{key:"_onFabricMouseDown",value:function(t){if(t.target||(this._isSelected=!1,this._shapeObj=!1),!this._isSelected&&!this._shapeObj){var e=this.getCanvas();this._startPoint=e.getPointer(t.e),e.on({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}}},{key:"_onFabricMouseMove",value:function(t){var e=this,i=this.getCanvas(),n=i.getPointer(t.e),r=this._startPoint.x,o=this._startPoint.y,a=r-n.x,s=o-n.y,c=this._shapeObj;c?(this._shapeObj.set({isRegular:this._withShiftKey}),fa().resize(c,n),i.renderAll(),this._resetPositionFillFilter(c)):this.add(this._type,{left:r,top:o,width:a,height:s}).then((function(t){e.fire(oe,t)}))}},{key:"_onFabricMouseUp",value:function(){var t=this,e=this.getCanvas(),i=this._startPoint.x,n=this._startPoint.y,r=this._shapeObj;r?r&&(fa().adjustOriginToCenter(r),this.fire(qt,this.graphics.createObjectProperties(r))):this.add(this._type,{left:i,top:n,width:20,height:20}).then((function(e){t.fire(oe,e)})),e.off({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}},{key:"_onKeyDown",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!0,this._shapeObj&&(this._shapeObj.isRegular=!0))}},{key:"_onKeyUp",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!1,this._shapeObj&&(this._shapeObj.isRegular=!1))}},{key:"_resetPositionFillFilter",value:function(t){if("filter"===Vi(t)){var e=Gi(t,"patternSourceCanvas").patternSourceCanvas,i=Gi(ma(t),"originalAngle").originalAngle;this.graphics.canvasImage.angle!==i&&function(t,e){var i=Gi(t,"patternSourceCanvas").patternSourceCanvas,n=Q(i.getObjects(),1)[0],r=ba(n);i.remove(n);var o=_a(Ca(e,!0),e.angle,r);i.add(o)}(t,this.graphics.canvasImage);var n=t.originX,r=t.originY;fa().adjustOriginToCenter(t),t.width*=t.scaleX,t.height*=t.scaleY,t.rx*=t.scaleX,t.ry*=t.scaleY,t.scaleX=1,t.scaleY=1,ya(t),function(t,e){var i=e.originX,n=e.originY,r=t.getPointByOrigin(i,n),o=r.x,a=r.y;t.set({left:o,top:a,originX:i,originY:n}),t.setCoords()}(t,{originX:n,originY:r}),function(t){var e=Gi(Q(t.getObjects(),1)[0],"fillImageMaxSize").fillImageMaxSize;e=Math.max(1,e),t.setDimensions({width:e,height:e}),t.renderAll()}(e)}}},{key:"_fillFilterRePositionInGroupSelection",value:function(t,e){1===e.scaleX&&1===e.scaleY||e.addWithUpdate();var i=t.angle,n=t.left,r=t.top;z.fabric.util.addTransformToObject(t,e.calcTransformMatrix()),this._resetPositionFillFilter(t),t.set({angle:i,left:n,top:r})}}]),i}(ho);function Ta(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Da={left:0,top:0,width:0,height:0,stroke:"#000000",strokeWidth:0,fill:"#000000",opacity:.4,evented:!1,selectable:!1,hoverCursor:"auto"},Aa=.0045,ja=.003,Oa=.003,Ea=.0066,La=.0044,Na=.003,Pa=ve,za=re,Ba=te,Ra=$t,Fa=ye,Ya=be,Wa=pe,Ha=me,Ua=function(t){wn(i,t);var e=Ta(i);function i(t){var n,r,o,a,s,c,l,u,h,f,g,d,v;w(this,i),(v=e.call(this,St.ZOOM,t)).zoomArea=null,v._startPoint=null,v._centerPoints=[],v.zoomLevel=1,v.zoomMode=Ue,v._listeners={startZoom:A()(n=v._onMouseDownWithZoomMode).call(n,Dn(v)),moveZoom:A()(r=v._onMouseMoveWithZoomMode).call(r,Dn(v)),stopZoom:A()(o=v._onMouseUpWithZoomMode).call(o,Dn(v)),startHand:A()(a=v._onMouseDownWithHandMode).call(a,Dn(v)),moveHand:A()(s=v._onMouseMoveWithHandMode).call(s,Dn(v)),stopHand:A()(c=v._onMouseUpWithHandMode).call(c,Dn(v)),zoomChanged:A()(l=v._changeScrollState).call(l,Dn(v)),keydown:A()(u=v._startHandModeWithSpaceBar).call(u,Dn(v)),keyup:A()(h=v._endHandModeWithSpaceBar).call(h,Dn(v))};var p=v.getCanvas();return v.aspectRatio=p.width/p.height,v._verticalScroll=new z.fabric.Rect(Da),v._horizontalScroll=new z.fabric.Rect(Da),p.on(Pa,v._listeners.zoomChanged),v.graphics.on(za,A()(f=v._startTextEditingHandler).call(f,Dn(v))),v.graphics.on(Ba,A()(g=v._startTextEditingHandler).call(g,Dn(v))),v.graphics.on(Ra,A()(d=v._stopTextEditingHandler).call(d,Dn(v))),v}return T(i,[{key:"attachKeyboardZoomEvents",value:function(){z.fabric.util.addListener(document,Fa,this._listeners.keydown),z.fabric.util.addListener(document,Ya,this._listeners.keyup)}},{key:"detachKeyboardZoomEvents",value:function(){z.fabric.util.removeListener(document,Fa,this._listeners.keydown),z.fabric.util.removeListener(document,Ya,this._listeners.keyup)}},{key:"_startTextEditingHandler",value:function(){this.isTextEditing=!0}},{key:"_stopTextEditingHandler",value:function(){this.isTextEditing=!1}},{key:"_startHandModeWithSpaceBar",value:function(t){this.withSpace||this.isTextEditing||t.keyCode===ii&&(this.withSpace=!0,this.startHandMode())}},{key:"_endHandModeWithSpaceBar",value:function(t){t.keyCode===ii&&(this.withSpace=!1,this.endHandMode())}},{key:"startZoomInMode",value:function(){if(!this.zoomArea){this.endHandMode(),this.zoomMode=Ge;var t=this.getCanvas();this._changeObjectsEventedState(!1),this.zoomArea=new z.fabric.Rect({left:0,top:0,width:.5,height:.5,stroke:"black",strokeWidth:1,fill:"transparent",hoverCursor:"zoom-in"}),t.discardActiveObject(),t.add(this.zoomArea),t.on("mouse:down",this._listeners.startZoom),t.selection=!1,t.defaultCursor="zoom-in"}}},{key:"endZoomInMode",value:function(){this.zoomMode=Ue;var t=this.getCanvas(),e=this._listeners,i=e.startZoom,n=e.moveZoom,r=e.stopZoom;t.selection=!0,t.defaultCursor="auto",t.off({"mouse:down":i,"mouse:move":n,"mouse:up":r}),this._changeObjectsEventedState(!0),t.remove(this.zoomArea),this.zoomArea=null}},{key:"start",value:function(){this.zoomArea=null,this._startPoint=null,this._startHandPoint=null}},{key:"end",value:function(){this.endZoomInMode(),this.endHandMode()}},{key:"startHandMode",value:function(){this.endZoomInMode(),this.zoomMode=Xe;var t=this.getCanvas();this._changeObjectsEventedState(!1),t.discardActiveObject(),t.off("mouse:down",this._listeners.startHand),t.on("mouse:down",this._listeners.startHand),t.selection=!1,t.defaultCursor="grab",t.fire(Wa)}},{key:"endHandMode",value:function(){this.zoomMode=Ue;var t=this.getCanvas();this._changeObjectsEventedState(!0),t.off("mouse:down",this._listeners.startHand),t.selection=!0,t.defaultCursor="auto",this._startHandPoint=null,t.fire(Ha)}},{key:"_onMouseDownWithZoomMode",value:function(t){var e=t.target,i=t.e;if(!e){var n=this.getCanvas();n.selection=!1,this._startPoint=n.getPointer(i),this.zoomArea.set({width:0,height:0});var r=this._listeners,o=r.moveZoom,a=r.stopZoom;n.on({"mouse:move":o,"mouse:up":a})}}},{key:"_onMouseMoveWithZoomMode",value:function(t){var e=t.e,i=this.getCanvas(),n=i.getPointer(e),r=n.x,o=n.y,a=this.zoomArea,s=this._startPoint;Math.abs(r-s.x)+Math.abs(o-s.y)>10&&(i.remove(a),a.set(this._calcRectDimensionFromPoint(r,o)),i.add(a))}},{key:"_calcRectDimensionFromPoint",value:function(t,e){var i=this.getCanvas(),n=i.getWidth(),r=i.getHeight(),o=this._startPoint,a=o.x,s=o.y,c=Math.min,l=c(a,t),u=c(s,e);return{left:l,top:u,width:Ni(t,a,n)-l,height:Ni(e,s,r)-u}}},{key:"_onMouseUpWithZoomMode",value:function(){var t=this.zoomLevel,e=this.zoomArea,i=this._listeners,n=i.moveZoom,r=i.stopZoom,o=this.getCanvas(),a=this._getCenterPoint(),s=a.x,c=a.y;this._isMaxZoomLevel()||(this._centerPoints.push({x:s,y:c,prevZoomLevel:t,zoomLevel:t+1}),t+=1,o.zoomToPoint({x:s,y:c},t),this._fireZoomChanged(o,t),this.zoomLevel=t),o.off({"mouse:move":n,"mouse:up":r}),o.remove(e),this._startPoint=null}},{key:"_getCenterPoint",value:function(){var t=this.zoomArea,e=t.left,i=t.top,n=t.width,r=t.height,o=this._startPoint,a=o.x,s=o.y,c=this.aspectRatio;return n<10&&r<10?{x:a,y:s}:n>r?{x:e+c*r/2,y:i+r/2}:{x:e+n/2,y:i+n/c/2}}},{key:"zoom",value:function(t){for(var e=t.x,i=t.y,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoomLevel,r=this.getCanvas(),o=this._centerPoints,a=o.length-1;a>=0&&!(o[a].zoomLevel<n);a-=1){var s=o.pop(),c=s.x,l=s.y,u=s.prevZoomLevel;r.zoomToPoint({x:c,y:l},u),this.zoomLevel=u}r.zoomToPoint({x:e,y:i},n),this._isDefaultZoomLevel(n)||this._centerPoints.push({x:e,y:i,zoomLevel:n,prevZoomLevel:this.zoomLevel}),this.zoomLevel=n,this._fireZoomChanged(r,n)}},{key:"zoomOut",value:function(){var t=this._centerPoints;if(t.length){var e=this.getCanvas(),i=t.pop(),n=i.x,r=i.y,o=i.prevZoomLevel;this._isDefaultZoomLevel(o)?e.setViewportTransform([1,0,0,1,0,0]):e.zoomToPoint({x:n,y:r},o),this.zoomLevel=o,this._fireZoomChanged(e,this.zoomLevel)}}},{key:"resetZoom",value:function(){var t=this.getCanvas();t.setViewportTransform([1,0,0,1,0,0]),this.zoomLevel=1,this._centerPoints=[],this._fireZoomChanged(t,this.zoomLevel)}},{key:"_isMaxZoomLevel",value:function(){return this.zoomLevel>=5}},{key:"_movePointOfZoom",value:function(t){var e=t.x,i=t.y,n=this._centerPoints;if(n.length){var r=this.getCanvas(),o=this.zoomLevel,a=n.pop(),s=a.x,c=a.y,l=a.prevZoomLevel,u=s-e,h=c-i;r.zoomToPoint({x:s,y:c},l),r.zoomToPoint({x:u,y:h},o),n.push({x:u,y:h,prevZoomLevel:l,zoomLevel:o}),this._fireZoomChanged(r,o)}}},{key:"_onMouseDownWithHandMode",value:function(t){var e=t.target,i=t.e;if(!e){var n=this.getCanvas();if(!(this.zoomLevel<=1)){n.selection=!1,this._startHandPoint=n.getPointer(i);var r=this._listeners,o=r.moveHand,a=r.stopHand;n.on({"mouse:move":o,"mouse:up":a})}}}},{key:"_onMouseMoveWithHandMode",value:function(t){var e=t.e,i=this.getCanvas().getPointer(e),n=i.x,r=i.y,o=n-this._startHandPoint.x,a=r-this._startHandPoint.y;this._movePointOfZoom({x:o,y:a})}},{key:"_onMouseUpWithHandMode",value:function(){var t=this.getCanvas(),e=this._listeners,i=e.moveHand,n=e.stopHand;t.off({"mouse:move":i,"mouse:up":n}),this._startHandPoint=null}},{key:"_changeScrollState",value:function(t){var e=t.viewport,i=t.zoomLevel,n=this.getCanvas();if(n.remove(this._verticalScroll),n.remove(this._horizontalScroll),!this._isDefaultZoomLevel(i)){var r=n.width,o=n.height,a=e.tl,s=e.tr,c=e.bl,l=s.x-a.x,u=c.y-a.y,h=l*l/r,f=u*Ea,g=Ni(a.x+a.x/r*l,a.x,s.x-h),d=u*La,v=u*Na;this._horizontalScroll.set({left:g,top:c.y-f-d,width:h,height:f,rx:v,ry:v});var p=l*Aa,m=u*u/o,y=Ni(a.y+a.y/o*u,s.y,c.y-m),b=l*ja,x=l*Oa;this._verticalScroll.set({left:s.x-p-b,top:y,width:p,height:m,rx:x,ry:x}),this._addScrollBar()}}},{key:"_changeObjectsEventedState",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.getCanvas();e.forEachObject((function(e){e.evented=t}))}},{key:"_addScrollBar",value:function(){var t=this,e=this.getCanvas();e.add(this._horizontalScroll),e.add(this._verticalScroll),this.scrollBarTid&&clearTimeout(this.scrollBarTid),this.scrollBarTid=v()((function(){e.remove(t._horizontalScroll),e.remove(t._verticalScroll)}),3e3)}},{key:"_isDefaultZoomLevel",value:function(t){return 1===t}},{key:"_fireZoomChanged",value:function(t,e){t.fire(Pa,{viewport:t.calcViewportBoundaries(),zoomLevel:e})}},{key:"mode",get:function(){return this.zoomMode}}]),i}(ho),Ga=Ua,Xa=rn.create,Za=rn.types,Va=function(){function t(e){w(this,t),this.name=e}return T(t,[{key:"getName",value:function(){return this.name}},{key:"start",value:function(){throw new Error(Xa(Za.UN_IMPLEMENTATION,"start"))}},{key:"end",value:function(){throw new Error(Xa(Za.UN_IMPLEMENTATION,"stop"))}}]),t}();function Ja(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Qa=function(t){wn(i,t);var e=Ja(i);function i(){return w(this,i),e.call(this,Be.CROPPER)}return T(i,[{key:"start",value:function(t){t.getComponent(St.CROPPER).start()}},{key:"end",value:function(t){t.getComponent(St.CROPPER).end()}}]),i}(Va),Ka=Qa;function qa(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var $a=function(t){wn(i,t);var e=qa(i);function i(){return w(this,i),e.call(this,Be.FREE_DRAWING)}return T(i,[{key:"start",value:function(t,e){t.getComponent(St.FREE_DRAWING).start(e)}},{key:"end",value:function(t){t.getComponent(St.FREE_DRAWING).end()}}]),i}(Va),ts=$a;function es(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var is=function(t){wn(i,t);var e=es(i);function i(){return w(this,i),e.call(this,Be.LINE_DRAWING)}return T(i,[{key:"start",value:function(t,e){t.getComponent(St.LINE).start(e)}},{key:"end",value:function(t){t.getComponent(St.LINE).end()}}]),i}(Va),ns=is;function rs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var os=function(t){wn(i,t);var e=rs(i);function i(){return w(this,i),e.call(this,Be.SHAPE)}return T(i,[{key:"start",value:function(t){t.getComponent(St.SHAPE).start()}},{key:"end",value:function(t){t.getComponent(St.SHAPE).end()}}]),i}(Va),as=os;function ss(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var cs=function(t){wn(i,t);var e=ss(i);function i(){return w(this,i),e.call(this,Be.TEXT)}return T(i,[{key:"start",value:function(t){t.getComponent(St.TEXT).start()}},{key:"end",value:function(t){t.getComponent(St.TEXT).end()}}]),i}(Va),ls=cs;function us(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var hs=function(t){wn(i,t);var e=us(i);function i(){return w(this,i),e.call(this,Be.ICON)}return T(i,[{key:"start",value:function(t){t.getComponent(St.ICON).start()}},{key:"end",value:function(t){t.getComponent(St.ICON).end()}}]),i}(Va),fs=hs;function gs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ds=function(t){wn(i,t);var e=gs(i);function i(){return w(this,i),e.call(this,Be.ZOOM)}return T(i,[{key:"start",value:function(t){t.getComponent(St.ZOOM).start()}},{key:"end",value:function(t){t.getComponent(St.ZOOM).end()}}]),i}(Va),vs=ds,ps=null;function ms(t){ps=t}function ys(t,e){var i,n;"activeSelection"===t.type?i=pn()(n=t.getObjects()).call(n,(function(i){var n=i.angle,r=i.left,o=i.top,a=i.scaleX,s=i.scaleY,c=i.width,l=i.height;z.fabric.util.addTransformToObject(i,t.calcTransformMatrix());var u=e(i);return i.set({angle:n,left:r,top:o,width:c,height:l,scaleX:a,scaleY:s}),u})):i=[e(t)];return i}function bs(t,e,i){return i?{id:t,width:e.width,height:e.height,top:e.top,left:e.left,angle:e.angle,scaleX:e.scaleX,scaleY:e.scaleY}:R()({id:t},e)}function xs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Cs=function(t){wn(i,t);var e=xs(i);function i(t){var n;return w(this,i),(n=e.call(this,St.RESIZE,t))._dimensions=null,n._originalDimensions=null,n}return T(i,[{key:"getCurrentDimensions",value:function(){var t=this.getCanvasImage();if(!this._dimensions&&t){var e=t.width,i=t.height;this._dimensions={width:e,height:i}}return this._dimensions}},{key:"getOriginalDimensions",value:function(){return this._originalDimensions}},{key:"setOriginalDimensions",value:function(t){this._originalDimensions=t}},{key:"resize",value:function(t){var e=this.getCanvasImage(),i=e.width,n=e.height,r=e.scaleX,o=e.scaleY,a=t.width,s=t.height,c={scaleX:a?a/i:r,scaleY:s?s/n:o};return r===c.scaleX&&o===c.scaleY||(e.set(c).setCoords(),this._dimensions={width:e.width*e.scaleX,height:e.height*e.scaleY}),this.adjustCanvasDimensionBase(),L().resolve()}},{key:"start",value:function(){var t=this.getCurrentDimensions();this.setOriginalDimensions(t)}},{key:"end",value:function(){}}]),i}(ho),Is=Cs;function _s(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ms=function(t){wn(i,t);var e=_s(i);function i(){return w(this,i),e.call(this,Be.RESIZE)}return T(i,[{key:"start",value:function(t){t.getComponent(St.RESIZE).start()}},{key:"end",value:function(t){t.getComponent(St.RESIZE).end()}}]),i}(Va),Ss=Ms,ws={cssOnly:!0},ks={backstoreOnly:!0},Ts=function(){function t(e){var i,n,r,o,a,s,c,l,u,h,f,g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=g.cssMaxWidth,v=g.cssMaxHeight;w(this,t),this.canvasImage=null,this.cssMaxWidth=d||1e3,this.cssMaxHeight=v||800,this.cropSelectionStyle={},this.targetObjectForCopyPaste=null,this.imageName="",this._objects={},this._canvas=null,this._drawingMode=Be.NORMAL,this._drawingModeMap={},this._componentMap={},this._handler={onMouseDown:A()(i=this._onMouseDown).call(i,this),onObjectAdded:A()(n=this._onObjectAdded).call(n,this),onObjectRemoved:A()(r=this._onObjectRemoved).call(r,this),onObjectMoved:A()(o=this._onObjectMoved).call(o,this),onObjectScaled:A()(a=this._onObjectScaled).call(a,this),onObjectModified:A()(s=this._onObjectModified).call(s,this),onObjectRotated:A()(c=this._onObjectRotated).call(c,this),onObjectSelected:A()(l=this._onObjectSelected).call(l,this),onPathCreated:A()(u=this._onPathCreated).call(u,this),onSelectionCleared:A()(h=this._onSelectionCleared).call(h,this),onSelectionCreated:A()(f=this._onSelectionCreated).call(f,this)},this._setObjectCachingToFalse(),this._setCanvasElement(e),this._createDrawingModeInstances(),this._createComponents(),this._attachCanvasEvents(),this._attachZoomEvents()}return T(t,[{key:"destroy",value:function(){var t=this._canvas.wrapperEl;this._canvas.clear(),t.parentNode.removeChild(t),this._detachZoomEvents()}},{key:"_attachZoomEvents",value:function(){this.getComponent(St.ZOOM).attachKeyboardZoomEvents()}},{key:"_detachZoomEvents",value:function(){this.getComponent(St.ZOOM).detachKeyboardZoomEvents()}},{key:"deactivateAll",value:function(){return this._canvas.discardActiveObject(),this}},{key:"renderAll",value:function(){return this._canvas.renderAll(),this}},{key:"add",value:function(t){var e,i=[];so()(t)?i=t:i.push(t),(e=this._canvas).add.apply(e,_(i))}},{key:"contains",value:function(t){return this._canvas.contains(t)}},{key:"getObjects",value:function(){var t;return h()(t=this._canvas.getObjects()).call(t)}},{key:"getObject",value:function(t){return this._objects[t]}},{key:"remove",value:function(t){this._canvas.remove(t)}},{key:"removeAll",value:function(t){var e,i=this._canvas,n=h()(e=i.getObjects()).call(e);return i.remove.apply(i,_(this._canvas.getObjects())),t&&i.clear(),n}},{key:"removeObjectById",value:function(t){var e=[],i=this._canvas,n=this.getObject(t);return n&&n.isType("group")&&!n.isEmpty()?(i.discardActiveObject(),n.forEachObject((function(t){e.push(t),i.remove(t)}))):i.contains(n)&&(e.push(n),i.remove(n)),e}},{key:"getObjectId",value:function(t){var e=null;for(e in this._objects)if(this._objects.hasOwnProperty(e)&&t===this._objects[e])return e;return null}},{key:"getActiveObject",value:function(){return this._canvas._activeObject}},{key:"getActiveObjectIdForRemove",value:function(){var t=this.getActiveObject(),e=t.type,i=t.left,n=t.top;if("activeSelection"===e){var r=new z.fabric.Group(_(t.getObjects()),{left:i,top:n});return this._addFabricObject(r)}return this.getObjectId(t)}},{key:"isReadyRemoveObject",value:function(){var t=this.getActiveObject();return t&&!t.isEditing}},{key:"getActiveObjects",value:function(){var t=this._canvas._activeObject;return t&&"activeSelection"===t.type?t:null}},{key:"getActiveSelectionFromObjects",value:function(t){var e=this.getCanvas();return new z.fabric.ActiveSelection(t,{canvas:e})}},{key:"setActiveObject",value:function(t){this._canvas.setActiveObject(t)}},{key:"setCropSelectionStyle",value:function(t){this.cropSelectionStyle=t}},{key:"getComponent",value:function(t){return this._componentMap[t]}},{key:"getDrawingMode",value:function(){return this._drawingMode}},{key:"startDrawingMode",value:function(t,e){if(this._isSameDrawingMode(t))return!0;this.stopDrawingMode();var i=this._getDrawingModeInstance(t);return i&&i.start&&(i.start(this,e),this._drawingMode=t),!!i}},{key:"stopDrawingMode",value:function(){if(!this._isSameDrawingMode(Be.NORMAL)){var t=this._getDrawingModeInstance(this.getDrawingMode());t&&t.end&&t.end(this),this._drawingMode=Be.NORMAL}}},{key:"zoom",value:function(t,e){var i=t.x,n=t.y,r=this.getComponent(St.ZOOM);r.zoom({x:i,y:n},e)}},{key:"getZoomMode",value:function(){return this.getComponent(St.ZOOM).mode}},{key:"startZoomInMode",value:function(){this.getComponent(St.ZOOM).startZoomInMode()}},{key:"endZoomInMode",value:function(){this.getComponent(St.ZOOM).endZoomInMode()}},{key:"zoomOut",value:function(){this.getComponent(St.ZOOM).zoomOut()}},{key:"startHandMode",value:function(){this.getComponent(St.ZOOM).startHandMode()}},{key:"endHandMode",value:function(){this.getComponent(St.ZOOM).endHandMode()}},{key:"resetZoom",value:function(){this.getComponent(St.ZOOM).resetZoom()}},{key:"toDataURL",value:function(t){var e=this.getComponent(St.CROPPER);e.changeVisibility(!1);var i=this._canvas&&this._canvas.toDataURL(t);return e.changeVisibility(!0),i}},{key:"setCanvasImage",value:function(t,e){e&&Ei(e),this.imageName=t,this.canvasImage=e}},{key:"setCssMaxDimension",value:function(t){this.cssMaxWidth=t.width||this.cssMaxWidth,this.cssMaxHeight=t.height||this.cssMaxHeight}},{key:"adjustCanvasDimension",value:function(){this.adjustCanvasDimensionBase(this.canvasImage.scale(1))}},{key:"adjustCanvasDimensionBase",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t||(t=this.canvasImage);var e=t.getBoundingRect(),i=e.width,n=e.height,r=this._calcMaxDimension(i,n);this.setCanvasCssDimension({width:"100%",height:"100%","max-width":"".concat(r.width,"px"),"max-height":"".concat(r.height,"px")}),this.setCanvasBackstoreDimension({width:i,height:n}),this._canvas.centerObject(t)}},{key:"setCanvasCssDimension",value:function(t){this._canvas.setDimensions(t,ws)}},{key:"setCanvasBackstoreDimension",value:function(t){this._canvas.setDimensions(t,ks)}},{key:"setImageProperties",value:function(t,e){var i=this.canvasImage;i&&(i.set(t).setCoords(),e&&this._canvas.renderAll())}},{key:"getCanvasElement",value:function(){return this._canvas.getElement()}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getCanvasImage",value:function(){return this.canvasImage}},{key:"getImageName",value:function(){return this.imageName}},{key:"addImageObject",value:function(t){var e,i=this,n=A()(e=this._callbackAfterLoadingImageObject).call(e,this);return new(L())((function(e){z.fabric.Image.fromURL(t,(function(t){n(t),e(i.createObjectProperties(t))}),{crossOrigin:"Anonymous"})}))}},{key:"getCenter",value:function(){return this._canvas.getCenter()}},{key:"getCropzoneRect",value:function(){return this.getComponent(St.CROPPER).getCropzoneRect()}},{key:"setCropzoneRect",value:function(t){this.getComponent(St.CROPPER).setCropzoneRect(t)}},{key:"getCroppedImageData",value:function(t){return this.getComponent(St.CROPPER).getCroppedImageData(t)}},{key:"setBrush",value:function(t){var e=this._drawingMode,i=St.FREE_DRAWING;e===Be.LINE_DRAWING&&(i=St.LINE),this.getComponent(i).setBrush(t)}},{key:"setDrawingShape",value:function(t,e){this.getComponent(St.SHAPE).setStates(t,e)}},{key:"setIconStyle",value:function(t,e){this.getComponent(St.ICON).setStates(t,e)}},{key:"registerPaths",value:function(t){this.getComponent(St.ICON).registerPaths(t)}},{key:"changeCursor",value:function(t){var e=this.getCanvas();e.defaultCursor=t,e.renderAll()}},{key:"hasFilter",value:function(t){return this.getComponent(St.FILTER).hasFilter(t)}},{key:"setSelectionStyle",value:function(t){R()(oi,t)}},{key:"setObjectProperties",value:function(t,e){var i=this.getObject(t),n=R()({},e);return i.set(n),i.setCoords(),this.getCanvas().renderAll(),n}},{key:"getObjectProperties",value:function(t,e){var i=this.getObject(t),n={};return Z()(e)?n[e]=i[e]:so()(e)?Ln()(e,(function(t){n[t]=i[t]})):lo()(e,(function(t,e){n[e]=i[e]})),n}},{key:"getObjectPosition",value:function(t,e,i){var n=this.getObject(t);return n?n.getPointByOrigin(e,i):null}},{key:"setObjectPosition",value:function(t,e){var i=this.getObject(t),n=e.x,r=e.y,o=e.originX,a=e.originY;if(!i)return!1;var s=i.getPointByOrigin(o,a),c=i.getPointByOrigin("center","center"),l=c.x-s.x,u=c.y-s.y;return i.set({left:n+l,top:r+u}),i.setCoords(),!0}},{key:"getCanvasSize",value:function(){var t=this.getCanvasImage();return{width:t?t.width:0,height:t?t.height:0}}},{key:"createStaticCanvas",value:function(){var t=new z.fabric.StaticCanvas;return t.set({enableRetinaScaling:!1}),t}},{key:"_getDrawingModeInstance",value:function(t){return this._drawingModeMap[t]}},{key:"_setObjectCachingToFalse",value:function(){z.fabric.Object.prototype.objectCaching=!1}},{key:"_setCanvasElement",value:function(t){var e,i;"CANVAS"!==(e=t.nodeType?t:document.querySelector(t)).nodeName.toUpperCase()&&(i=document.createElement("canvas"),e.appendChild(i)),this._canvas=new z.fabric.Canvas(i,{containerClass:"tui-image-editor-canvas-container",enableRetinaScaling:!1})}},{key:"_createDrawingModeInstances",value:function(){this._register(this._drawingModeMap,new Ka),this._register(this._drawingModeMap,new ts),this._register(this._drawingModeMap,new ns),this._register(this._drawingModeMap,new as),this._register(this._drawingModeMap,new ls),this._register(this._drawingModeMap,new fs),this._register(this._drawingModeMap,new vs),this._register(this._drawingModeMap,new Ss)}},{key:"_createComponents",value:function(){this._register(this._componentMap,new po(this)),this._register(this._componentMap,new So(this)),this._register(this._componentMap,new To(this)),this._register(this._componentMap,new jo(this)),this._register(this._componentMap,new Bo(this)),this._register(this._componentMap,new Ho(this)),this._register(this._componentMap,new Vo(this)),this._register(this._componentMap,new qo(this)),this._register(this._componentMap,new ua(this)),this._register(this._componentMap,new ka(this)),this._register(this._componentMap,new Ga(this)),this._register(this._componentMap,new Is(this))}},{key:"_register",value:function(t,e){t[e.getName()]=e}},{key:"_isSameDrawingMode",value:function(t){return this.getDrawingMode()===t}},{key:"_calcMaxDimension",value:function(t,e){var i=this.cssMaxWidth/t,n=this.cssMaxHeight/e,r=Math.min(t,this.cssMaxWidth),o=Math.min(e,this.cssMaxHeight);return i<1&&i<n?(r=t*i,o=e*i):n<1&&n<i&&(r=t*n,o=e*n),{width:Math.floor(r),height:Math.floor(o)}}},{key:"_callbackAfterLoadingImageObject",value:function(t){var e=this.getCanvasImage().getCenterPoint();t.set(oi),t.set({left:e.x,top:e.y,crossOrigin:"Anonymous"}),this.getCanvas().add(t).setActiveObject(t)}},{key:"_attachCanvasEvents",value:function(){var t=this._canvas,e=this._handler;t.on({"mouse:down":e.onMouseDown,"object:added":e.onObjectAdded,"object:removed":e.onObjectRemoved,"object:moving":e.onObjectMoved,"object:scaling":e.onObjectScaled,"object:modified":e.onObjectModified,"object:rotating":e.onObjectRotated,"path:created":e.onPathCreated,"selection:cleared":e.onSelectionCleared,"selection:created":e.onSelectionCreated,"selection:updated":e.onObjectSelected})}},{key:"_onMouseDown",value:function(t){var e=this,i=t.e,n=t.target,r=this._canvas.getPointer(i);if(n){var o=n.type;ms(ys(n,(function(t){return bs(e.getObjectId(t),t,"activeSelection"===o)})))}this.fire(se,i,r)}},{key:"_onObjectAdded",value:function(t){var e=t.target;e.isType("cropzone")||this._addFabricObject(e)}},{key:"_onObjectRemoved",value:function(t){var e=t.target;this._removeFabricObject(Ei(e))}},{key:"_onObjectMoved",value:function(t){var e=this;this._lazyFire(Jt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_onObjectScaled",value:function(t){var e=this;this._lazyFire(Qt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_onObjectModified",value:function(t){var e=t.target;if("activeSelection"===e.type){var i=e.getObjects();et()(i).call(i,(function(t){return t.fire("modifiedInGroup",e)}))}this.fire($t,e,this.getObjectId(e))}},{key:"_onObjectRotated",value:function(t){var e=this;this._lazyFire(Kt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_lazyFire",value:function(t,e,i){var n=this,r=i&&i.canvasEventDelegation?i.canvasEventDelegation(t):"none";"unregistered"===r&&i.canvasEventRegister(t,(function(i){n.fire(t,e(i))})),"none"===r&&this.fire(t,e(i))}},{key:"_onObjectSelected",value:function(t){var e=t.target,i=this.createObjectProperties(e);this.fire(Vt,i)}},{key:"_onPathCreated",value:function(t){var e=t.path.getCenterPoint(),i=e.x,n=e.y;t.path.set(R()({left:i,top:n},oi));var r=this.createObjectProperties(t.path);this.fire(oe,r)}},{key:"_onSelectionCleared",value:function(){this.fire(ue)}},{key:"_onSelectionCreated",value:function(t){var e=t.target,i=this.createObjectProperties(e);this.fire(Vt,i),this.fire(he,t.target)}},{key:"discardSelection",value:function(){this._canvas.discardActiveObject(),this._canvas.renderAll()}},{key:"changeSelectableAll",value:function(t){this._canvas.forEachObject((function(e){e.selectable=t,e.hoverCursor=t?"move":"crosshair"}))}},{key:"createObjectProperties",value:function(t){var e={id:Ei(t),type:t.type};if(R()(e,zi(t,["left","top","width","height","fill","stroke","strokeWidth","opacity","angle"])),Xi(["i-text","text"],t.type))R()(e,this._createTextProperties(t,e));else if(Xi(["rect","triangle","circle"],t.type)){var i=this.getComponent(St.SHAPE);R()(e,{fill:i.makeFillPropertyForUserEvent(t)})}return e}},{key:"_createTextProperties",value:function(t){var e={};return R()(e,zi(t,["text","fontFamily","fontSize","fontStyle","textAlign","textDecoration","fontWeight"])),e}},{key:"_addFabricObject",value:function(t){var e=Ei(t);return this._objects[e]=t,e}},{key:"_removeFabricObject",value:function(t){delete this._objects[t]}},{key:"resetTargetObjectForCopyPaste",value:function(){var t=this.getActiveObject();t&&(this.targetObjectForCopyPaste=t)}},{key:"pasteObject",value:function(){var t=this;if(!this.targetObjectForCopyPaste)return L().resolve([]);var e=this.targetObjectForCopyPaste,i="activeSelection"===e.type?e.getObjects():[e],n=null;return this.discardSelection(),this._cloneObject(i).then((function(e){if(e.length>1)n=t.getActiveSelectionFromObjects(e);else{var i=Q(e,1);n=i[0]}t.targetObjectForCopyPaste=n,t.setActiveObject(n)}))}},{key:"_cloneObject",value:function(t){var e=this,i=pn()(t).call(t,(function(t){return e._cloneObjectItem(t)}));return L().all(i)}},{key:"_cloneObjectItem",value:function(t){var e=this;return this._copyFabricObjectForPaste(t).then((function(t){var i=e.createObjectProperties(t);return e.add(t),e.fire(oe,i),t}))}},{key:"_copyFabricObjectForPaste",value:function(t){var e=this,i=function(t,e){return e?t-10:t+10};return this._copyFabricObject(t).then((function(t){var n=t.left,r=t.top,o=t.width,a=t.height,s=e.getCanvasSize(),c=s.width,l=s.height,u=n+o/2,h=r+a/2;return t.set(R()({left:i(n,u+10>c),top:i(r,h+10>l)},oi)),t}))}},{key:"_copyFabricObject",value:function(t){var e=this;return new(L())((function(i){t.clone((function(n){var r=e.getComponent(St.SHAPE);Ji(n)&&r.processForCopiedObject(n,t),i(n)}))}))}},{key:"getCurrentDimensions",value:function(){return this.getComponent(St.RESIZE).getCurrentDimensions()}},{key:"getOriginalDimensions",value:function(){return this.getComponent(St.RESIZE).getOriginalDimensions()}},{key:"setOriginalDimensions",value:function(t){this.getComponent(St.RESIZE).setOriginalDimensions(t)}},{key:"resize",value:function(t){var e=this.getComponent(St.RESIZE);return e.resize(t)}}]),t}();G().mixin(Ts);var Ds=Ts,As=se,js=Jt,Os=Qt,Es=Vt,Ls=Kt,Ns=qt,Ps=$t,zs=re,Bs=oe,Rs=te,Fs=ee,Ys=ie,Ws=ne,Hs=ue,Us=he,Gs=ae,Xs=function(){function t(e,i){var n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y;if(w(this,t),i=R()({includeUI:!1,usageStatistics:!0},i),this.mode=null,this.activeObjectId=null,i.includeUI){var b=i.includeUI;b.usageStatistics=i.usageStatistics,this.ui=new eo(e,b,this.getActions()),i=this.ui.setUiDefaultSelectionStyle(i)}this._invoker=new fn,this._graphics=new Ds(this.ui?this.ui.getEditorArea():e,{cssMaxWidth:i.cssMaxWidth,cssMaxHeight:i.cssMaxHeight}),this._handlers={keydown:A()(n=this._onKeyDown).call(n,this),mousedown:A()(r=this._onMouseDown).call(r,this),objectActivated:A()(o=this._onObjectActivated).call(o,this),objectMoved:A()(a=this._onObjectMoved).call(a,this),objectScaled:A()(s=this._onObjectScaled).call(s,this),objectRotated:A()(c=this._onObjectRotated).call(c,this),objectAdded:A()(l=this._onObjectAdded).call(l,this),objectModified:A()(u=this._onObjectModified).call(u,this),createdPath:this._onCreatedPath,addText:A()(h=this._onAddText).call(h,this),addObject:A()(f=this._onAddObject).call(f,this),textEditing:A()(g=this._onTextEditing).call(g,this),textChanged:A()(d=this._onTextChanged).call(d,this),iconCreateResize:A()(v=this._onIconCreateResize).call(v,this),iconCreateEnd:A()(p=this._onIconCreateEnd).call(p,this),selectionCleared:A()(m=this._selectionCleared).call(m,this),selectionCreated:A()(y=this._selectionCreated).call(y,this)},this._attachInvokerEvents(),this._attachGraphicsEvents(),this._attachDomEvents(),this._setSelectionStyle(i.selectionStyle,{applyCropSelectionStyle:i.applyCropSelectionStyle,applyGroupSelectionStyle:i.applyGroupSelectionStyle}),i.usageStatistics&&(ji||(ji=!0,ot()("image-editor","UA-129999381-1"))),this.ui&&(this.ui.initCanvas(),this.setReAction(),this._attachColorPickerInputBoxEvents()),z.fabric.enableGLFiltering=!1}return T(t,[{key:"_attachColorPickerInputBoxEvents",value:function(){var t=this;this.ui.on(xe,(function(){t.isColorPickerInputBoxEditing=!0})),this.ui.on(Ce,(function(){t.isColorPickerInputBoxEditing=!1}))}},{key:"_detachColorPickerInputBoxEvents",value:function(){this.ui.off(xe),this.ui.off(Ce)}},{key:"_setSelectionStyle",value:function(t,e){var i=e.applyCropSelectionStyle,n=e.applyGroupSelectionStyle;t&&this._graphics.setSelectionStyle(t),i&&this._graphics.setCropSelectionStyle(t),n&&this.on("selectionCreated",(function(e){"activeSelection"===e.type&&e.set(t)}))}},{key:"_attachInvokerEvents",value:function(){var t,e,i=this,n=le,r=ce,o=fe,a=ge,s=de,c=pe,l=me;if(this._invoker.on(n,A()(t=this.fire).call(t,this,n)),this._invoker.on(r,A()(e=this.fire).call(e,this,r)),this.ui){var u=this._graphics.getCanvas();this._invoker.on(o,(function(t){return i.ui.fire(o,t)})),this._invoker.on(a,(function(t){return i.ui.fire(a,t)})),this._invoker.on(s,(function(t){return i.ui.fire(s,t)})),u.on(c,(function(){return i.ui.fire(c)})),u.on(l,(function(){return i.ui.fire(l)}))}}},{key:"_attachGraphicsEvents",value:function(){var t;this._graphics.on((S(t={},As,this._handlers.mousedown),S(t,js,this._handlers.objectMoved),S(t,Os,this._handlers.objectScaled),S(t,Ls,this._handlers.objectRotated),S(t,Es,this._handlers.objectActivated),S(t,Ns,this._handlers.objectAdded),S(t,Ps,this._handlers.objectModified),S(t,zs,this._handlers.addText),S(t,Bs,this._handlers.addObject),S(t,Rs,this._handlers.textEditing),S(t,Fs,this._handlers.textChanged),S(t,Ys,this._handlers.iconCreateResize),S(t,Ws,this._handlers.iconCreateEnd),S(t,Hs,this._handlers.selectionCleared),S(t,Us,this._handlers.selectionCreated),t))}},{key:"_attachDomEvents",value:function(){document.addEventListener("keydown",this._handlers.keydown)}},{key:"_detachDomEvents",value:function(){document.removeEventListener("keydown",this._handlers.keydown)}},{key:"_onKeyDown",value:function(t){var e=t.ctrlKey,i=t.keyCode,n=t.metaKey;(e||n)&&(i===Je?this._graphics.resetTargetObjectForCopyPaste():i===Qe?(this._graphics.pasteObject(),this.clearRedoStack()):i===Ze?this.undo().catch((function(){})):i===Ve&&this.redo().catch((function(){})));var r=i===qe||i===$e,o=this._graphics.isReadyRemoveObject();!this.isColorPickerInputBoxEditing&&o&&r&&(t.preventDefault(),this.removeActiveObject())}},{key:"removeActiveObject",value:function(){var t=this._graphics.getActiveObjectIdForRemove();this.removeObject(t)}},{key:"_onMouseDown",value:function(t,e){this.fire(se,t,e)}},{key:"_pushAddObjectCommand",value:function(t){var e=un.create(jt,this._graphics,t);this._invoker.pushUndoStack(e)}},{key:"_pushModifyObjectCommand",value:function(t){var e=this,i=t.type,n=ys(t,(function(t){return bs(e._graphics.getObjectId(t),t,"activeSelection"===i)})),r=un.create(Xt,this._graphics,n);r.execute(this._graphics,n),this._invoker.pushUndoStack(r)}},{key:"_onObjectActivated",value:function(t){this.fire(Vt,t)}},{key:"_onObjectMoved",value:function(t){this.fire(Jt,t)}},{key:"_onObjectScaled",value:function(t){this.fire(Qt,t)}},{key:"_onObjectRotated",value:function(t){this.fire(Kt,t)}},{key:"getDrawingMode",value:function(){return this._graphics.getDrawingMode()}},{key:"clearObjects",value:function(){return this.execute(kt)}},{key:"deactivateAll",value:function(){this._graphics.deactivateAll(),this._graphics.renderAll()}},{key:"discardSelection",value:function(){this._graphics.discardSelection()}},{key:"changeSelectableAll",value:function(t){this._graphics.changeSelectableAll(t)}},{key:"_initHistory",value:function(){this.ui&&this.ui.initHistory()}},{key:"_clearHistory",value:function(){this.ui&&this.ui.clearHistory()}},{key:"execute",value:function(t){for(var e,i,n,r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var s=O()(e=[this._graphics]).call(e,o);return(i=this._invoker).execute.apply(i,O()(n=[t]).call(n,_(s)))}},{key:"executeSilent",value:function(t){for(var e,i,n,r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var s=O()(e=[this._graphics]).call(e,o);return(i=this._invoker).executeSilent.apply(i,O()(n=[t]).call(n,_(s)))}},{key:"undo",value:function(){for(var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=L().resolve(),n=0;n<e;n+=1)i=i.then((function(){return t._invoker.undo()}));return i}},{key:"redo",value:function(){for(var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=L().resolve(),n=0;n<e;n+=1)i=i.then((function(){return t._invoker.redo()}));return i}},{key:"zoom",value:function(t){var e=t.x,i=t.y,n=t.zoomLevel;this._graphics.zoom({x:e,y:i},n)}},{key:"resetZoom",value:function(){this._graphics.resetZoom()}},{key:"startHandMode",value:function(){var t=this._graphics.getZoomMode();this.stopDrawingMode(),t!==Xe&&this._graphics.startHandMode()}},{key:"endHandMode",value:function(){var t=this._graphics.getZoomMode();this.stopDrawingMode(),t===Xe&&this._graphics.endHandMode()}},{key:"getCenterPoint",value:function(){return this._graphics.canvasImage.getCenterPoint()}},{key:"loadImageFromFile",value:function(t,e){if(!t)return L().reject(ci);var i=P().createObjectURL(t);return e=e||t.name,this.loadImageFromURL(i,e).then((function(e){return P().revokeObjectURL(t),e}))}},{key:"loadImageFromURL",value:function(t,e){return e&&t?this.execute(Tt,e,t):L().reject(ci)}},{key:"addImageObject",value:function(t){return t?this.execute(Wt,t):L().reject(ci)}},{key:"startDrawingMode",value:function(t,e){return this._graphics.startDrawingMode(t,e)}},{key:"stopDrawingMode",value:function(){this._graphics.stopDrawingMode()}},{key:"crop",value:function(t){var e=this._graphics.getCroppedImageData(t);return e?this.loadImageFromURL(e.url,e.imageName):L().reject(ci)}},{key:"getCropzoneRect",value:function(){return this._graphics.getCropzoneRect()}},{key:"setCropzoneRect",value:function(t){this._graphics.setCropzoneRect(t)}},{key:"_flip",value:function(t){return this.execute(Dt,t)}},{key:"flipX",value:function(){return this._flip("flipX")}},{key:"flipY",value:function(){return this._flip("flipY")}},{key:"resetFlip",value:function(){return this._flip("reset")}},{key:"_rotate",value:function(t,e,i){return i?this.executeSilent(At,t,e):this.execute(At,t,e)}},{key:"rotate",value:function(t,e){return this._rotate("rotate",t,e)}},{key:"setAngle",value:function(t,e){return this._rotate("setAngle",t,e)}},{key:"setBrush",value:function(t){this._graphics.setBrush(t)}},{key:"setDrawingShape",value:function(t,e){this._graphics.setDrawingShape(t,e)}},{key:"setDrawingIcon",value:function(t,e){this._graphics.setIconStyle(t,e)}},{key:"addShape",value:function(t,e){return e=e||{},this._setPositions(e),this.execute(zt,t,e)}},{key:"changeShape",value:function(t,e,i){return this[i?"executeSilent":"execute"](Bt,t,e)}},{key:"addText",value:function(t,e){return t=t||"",e=e||{},this.execute(Rt,t,e)}},{key:"changeText",value:function(t,e){return e=e||"",this.execute(Ft,t,e)}},{key:"changeTextStyle",value:function(t,e,i){return this[i?"executeSilent":"execute"](Yt,t,e)}},{key:"_changeActivateMode",value:function(t){"ICON"!==t&&this.getDrawingMode()!==t&&this.startDrawingMode(t)}},{key:"_onTextChanged",value:function(t){this.fire(ee,t)}},{key:"_onIconCreateResize",value:function(t){this.fire(ie,t)}},{key:"_onIconCreateEnd",value:function(t){this.fire(ne,t)}},{key:"_onTextEditing",value:function(){this.fire(te)}},{key:"_onAddText",value:function(t){this.fire(re,{originPosition:t.originPosition,clientPosition:t.clientPosition})}},{key:"_onAddObject",value:function(t){var e=this._graphics.getObject(t.id);this._invoker.fire(fe,Qi(e.type)),this._pushAddObjectCommand(e)}},{key:"_onObjectAdded",value:function(t){this.fire(Ns,t),this.fire(Gs,t)}},{key:"_onObjectModified",value:function(t){t.type!==mt&&(this._invoker.fire(fe,Qi(t.type)),this._pushModifyObjectCommand(t))}},{key:"_selectionCleared",value:function(){this.fire(Hs)}},{key:"_selectionCreated",value:function(t){this.fire(Us,t)}},{key:"registerIcons",value:function(t){this._graphics.registerPaths(t)}},{key:"changeCursor",value:function(t){this._graphics.changeCursor(t)}},{key:"addIcon",value:function(t,e){return e=e||{},this._setPositions(e),this.execute(Nt,t,e)}},{key:"changeIconColor",value:function(t,e){return this.execute(Pt,t,e)}},{key:"removeObject",value:function(t){var e=this._graphics.getObject(t).type;return this.execute(Ot,t,Qi(e))}},{key:"hasFilter",value:function(t){return this._graphics.hasFilter(t)}},{key:"removeFilter",value:function(t){return this.execute(Lt,t)}},{key:"applyFilter",value:function(t,e,i){return this[i?"executeSilent":"execute"](Et,t,e)}},{key:"toDataURL",value:function(t){return this._graphics.toDataURL(t)}},{key:"getImageName",value:function(){return this._graphics.getImageName()}},{key:"clearUndoStack",value:function(){this._invoker.clearUndoStack()}},{key:"clearRedoStack",value:function(){this._invoker.clearRedoStack()}},{key:"isEmptyUndoStack",value:function(){return this._invoker.isEmptyUndoStack()}},{key:"isEmptyRedoStack",value:function(){return this._invoker.isEmptyRedoStack()}},{key:"resizeCanvasDimension",value:function(t){return t?this.execute(Ht,t):L().reject(ci)}},{key:"destroy",value:function(){var t=this;this.stopDrawingMode(),this._detachDomEvents(),this._graphics.destroy(),this._graphics=null,this.ui&&(this._detachColorPickerInputBoxEvents(),this.ui.destroy()),H()(this,(function(e,i){t[i]=null}),this)}},{key:"_setPositions",value:function(t){var e=this._graphics.getCenter();Y()(t.left)&&(t.left=e.left),Y()(t.top)&&(t.top=e.top)}},{key:"setObjectProperties",value:function(t,e){return this.execute(Ut,t,e)}},{key:"setObjectPropertiesQuietly",value:function(t,e){this._graphics.setObjectProperties(t,e)}},{key:"getObjectProperties",value:function(t,e){return this._graphics.getObject(t)?this._graphics.getObjectProperties(t,e):null}},{key:"getCanvasSize",value:function(){return this._graphics.getCanvasSize()}},{key:"getObjectPosition",value:function(t,e,i){return this._graphics.getObjectPosition(t,e,i)}},{key:"setObjectPosition",value:function(t,e){return this.execute(Gt,t,e)}},{key:"resize",value:function(t){return this.execute(Zt,t)}}]),t}();oo.mixin(Xs),G().mixin(Xs);var Zs=Xs,Vs=St.ICON,Js={name:Nt,execute:function(t,e,i){var n=this;return t.getComponent(Vs).add(e,i).then((function(e){return n.undoData.object=t.getObject(e.id),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(Js);var Qs={name:Wt,execute:function(t,e){var i=this;return t.addImageObject(e).then((function(e){return i.undoData.object=t.getObject(e.id),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(Qs);var Ks={name:jt,execute:function(t,e){return new(L())((function(i,n){t.contains(e)?n(ai):(t.add(e),i(e))}))},undo:function(t,e){return new(L())((function(i,n){t.contains(e)?(t.remove(e),i(e)):n(fi)}))}};un.register(Ks);var qs=St.SHAPE,$s={name:zt,execute:function(t,e,i){var n=this;return t.getComponent(qs).add(e,i).then((function(e){var i=e.id;return n.undoData.object=t.getObject(i),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register($s);var tc=St.TEXT,ec={name:Rt,execute:function(t,e,i){var n=this,r=t.getComponent(tc);if(this.undoData.object){var o=this.undoData.object;return new(L())((function(e,i){t.contains(o)?i(gi):(t.add(o),e(o))}))}return r.add(e,i).then((function(e){var i=e.id,r=t.getObject(i);return n.undoData.object=r,ms(ys(r,(function(){return bs(i,r,!1)}))),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(ec);var ic=St.FILTER,nc=null;var rc={name:Et,execute:function(t,e,i,n){var r=t.getComponent(ic);if("mask"===e){var o=t.getObject(i.maskObjId);if(!o||!o.isType("image"))return L().reject(ci);R()(i,{mask:o}),t.remove(i.mask)}if(!this.isRedo){var a=function(t,e,i){var n={};return"mask"===t&&(n.object=i.mask),n.options=e,n}(e,r.getOptions(e),i);nc=this.setUndoData(a,nc,n)}return r.add(e,i)},undo:function(t,e){var i=t.getComponent(ic);if("mask"===e){var n=this.undoData.object;return t.add(n),t.setActiveObject(n),i.remove(e)}return this.undoData.options?i.add(e,this.undoData.options):i.remove(e)}};un.register(rc);var oc=St.ICON,ac={name:Pt,execute:function(t,e,i){var n=this;return new(L())((function(r,o){var a=t.getComponent(oc),s=t.getObject(e);s||o(fi),n.undoData.object=s,n.undoData.color=a.getColor(s),a.setColor(i,s),r()}))},undo:function(t){var e=t.getComponent(oc),i=this.undoData,n=i.object,r=i.color;return e.setColor(r,n),L().resolve()}};un.register(ac);var sc=St.SHAPE,cc=null;var lc={name:Bt,execute:function(t,e,i,n){var r=t.getComponent(sc),o=t.getObject(e);if(!o)return L().reject(fi);if(!this.isRedo){var a=function(t,e){var i={object:e,options:{}};return lo()(t,(function(t,n){i.options[n]=e[n]})),i}(i,o);cc=this.setUndoData(a,cc,n)}return r.change(o,i)},undo:function(t){var e=t.getComponent(sc),i=this.undoData,n=i.object,r=i.options;return e.change(n,r)}};un.register(lc);var uc=St.TEXT,hc={name:Ft,execute:function(t,e,i){var n=t.getComponent(uc),r=t.getObject(e);return r?(this.undoData.object=r,this.undoData.text=n.getText(r),n.change(r,i)):L().reject(fi)},undo:function(t){var e=t.getComponent(uc),i=this.undoData,n=i.object,r=i.text;return e.change(n,r)}};un.register(hc);var fc=St.TEXT,gc=null;var dc={name:Yt,execute:function(t,e,i,n){var r=t.getComponent(fc),o=t.getObject(e);if(!o)return L().reject(fi);if(!this.isRedo){var a=function(t,e){var i={object:e,styles:{}};return lo()(t,(function(t,n){var r=e[n];i.styles[n]=r})),i}(i,o);gc=this.setUndoData(a,gc,n)}return r.setStyle(o,i)},undo:function(t){var e=t.getComponent(fc),i=this.undoData,n=i.object,r=i.styles;return e.setStyle(n,r)}};un.register(dc);var vc={name:kt,execute:function(t){var e=this;return new(L())((function(i){e.undoData.objects=t.removeAll(),i()}))},undo:function(t){return t.add(this.undoData.objects),L().resolve()}};un.register(vc);var pc=St.FLIP,mc={name:Dt,execute:function(t,e){var i=t.getComponent(pc);return this.undoData.setting=i.getCurrentSetting(),i[e]()},undo:function(t){return t.getComponent(pc).set(this.undoData.setting)}};un.register(mc);var yc=St.IMAGE_LOADER,bc={name:Tt,execute:function(t,e,i){var n,r=t.getComponent(yc),o=r.getCanvasImage(),a=o?o.width:0,s=o?o.height:0,c=no()(n=t.removeAll(!0)).call(n,(function(t){return"cropzone"!==t.type}));return et()(c).call(c,(function(t){t.evented=!0})),this.undoData={name:r.getImageName(),image:o,objects:c},r.load(e,i).then((function(t){return{oldWidth:a,oldHeight:s,newWidth:t.width,newHeight:t.height}}))},undo:function(t){var e=t.getComponent(yc),i=this.undoData,n=i.objects,r=i.name,o=i.image;return t.removeAll(!0),t.add(n),e.load(r,o)}};un.register(bc);var xc=St.FILTER,Cc={name:Lt,execute:function(t,e){var i=t.getComponent(xc);return this.undoData.options=i.getOptions(e),i.remove(e)},undo:function(t,e){var i=t.getComponent(xc),n=this.undoData.options;return i.add(e,n)}};un.register(Cc);var Ic={name:Ot,execute:function(t,e){var i=this;return new(L())((function(n,r){i.undoData.objects=t.removeObjectById(e),i.undoData.objects.length?n():r(fi)}))},undo:function(t){return t.add(this.undoData.objects),L().resolve()}};un.register(Ic);var _c={name:Ht,execute:function(t,e){var i=this;return new(L())((function(n){i.undoData.size={width:t.cssMaxWidth,height:t.cssMaxHeight},t.setCssMaxDimension(e),t.adjustCanvasDimension(),n()}))},undo:function(t){return t.setCssMaxDimension(this.undoData.size),t.adjustCanvasDimension(),L().resolve()}};un.register(_c);var Mc=St.ROTATION,Sc=null;var wc={name:At,execute:function(t,e,i,n){var r=t.getComponent(Mc);if(!this.isRedo){var o=function(t){return{angle:t.getCurrentAngle()}}(r);Sc=this.setUndoData(o,Sc,n)}return r[e](i)},undo:function(t){var e=t.getComponent(Mc),i=Q(this.args,3),n=i[1],r=i[2];return"setAngle"===n?e[n](this.undoData.angle):e.rotate(-r)}};un.register(wc);var kc={name:Ut,execute:function(t,e,i){var n=this,r=t.getObject(e);return r?(this.undoData.props={},lo()(i,(function(t,e){n.undoData.props[e]=r[e]})),t.setObjectProperties(e,i),L().resolve()):L().reject(fi)},undo:function(t,e){var i=this.undoData.props;return t.setObjectProperties(e,i),L().resolve()}};un.register(kc);var Tc={name:Gt,execute:function(t,e,i){return t.getObject(e)?(this.undoData.objectId=e,this.undoData.props=t.getObjectProperties(e,["left","top"]),t.setObjectPosition(e,i),t.renderAll(),L().resolve()):L().reject(fi)},undo:function(t){var e=this.undoData,i=e.objectId,n=e.props;return t.setObjectProperties(i,n),t.renderAll(),L().resolve()}};un.register(Tc);var Dc={name:Xt,execute:function(t,e){return this.isRedo?et()(e).call(e,(function(e){t.setObjectProperties(e.id,e)})):this.undoData=ps,L().resolve()},undo:function(t){var e;return et()(e=this.undoData).call(e,(function(e){t.setObjectProperties(e.id,e)})),L().resolve()}};un.register(Dc);var Ac=St.RESIZE,jc={name:Zt,execute:function(t,e){var i=t.getComponent(Ac),n=i.getOriginalDimensions();return n||(n=i.getCurrentDimensions()),this.undoData.dimensions=n,i.resize(e)},undo:function(t){return t.getComponent(Ac).resize(this.undoData.dimensions)}};un.register(jc);var Oc=Zs}(),r=r.default}()}));
15
+ */,function(){if("undefined"!=typeof window&&window.addEventListener){var t,e,i,n=g()(null),r=function(){clearTimeout(e),e=v()(t,100)},o=function(){},a=function(t){function e(t){var e;return void 0!==t.protocol?e=t:(e=document.createElement("a")).href=t,e.protocol.replace(/:/g,"")+e.host}var i,n,r;return window.XMLHttpRequest&&(i=new XMLHttpRequest,n=e(location),r=e(t),i=void 0===i.withCredentials&&""!==r&&r!==n?XDomainRequest||void 0:XMLHttpRequest),i},s="http://www.w3.org/1999/xlink";t=function(){var t,e,i,c,l,u,h,f,g,d,p=0;function m(){var t;0===(p-=1)&&(o(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1),window.MutationObserver?((t=new MutationObserver(r)).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),o=function(){try{t.disconnect(),window.removeEventListener("resize",r,!1),window.removeEventListener("orientationchange",r,!1)}catch(t){}}):(document.documentElement.addEventListener("DOMSubtreeModified",r,!1),o=function(){document.documentElement.removeEventListener("DOMSubtreeModified",r,!1),window.removeEventListener("resize",r,!1),window.removeEventListener("orientationchange",r,!1)}))}function y(t){return function(){!0!==n[t.base]&&(t.useEl.setAttributeNS(s,"xlink:href","#"+t.hash),t.useEl.hasAttribute("href")&&t.useEl.setAttribute("href","#"+t.hash))}}function b(t){return function(){var e,i=document.body,n=document.createElement("x");t.onload=null,n.innerHTML=t.responseText,(e=n.getElementsByTagName("svg")[0])&&(e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.width=0,e.style.height=0,e.style.overflow="hidden",i.insertBefore(e,i.firstChild)),m()}}function x(t){return function(){t.onerror=null,t.ontimeout=null,m()}}for(o(),g=document.getElementsByTagName("use"),l=0;l<g.length;l+=1){try{e=g[l].getBoundingClientRect()}catch(t){e=!1}t=(f=(c=g[l].getAttribute("href")||g[l].getAttributeNS(s,"href")||g[l].getAttribute("xlink:href"))&&c.split?c.split("#"):["",""])[0],i=f[1],u=e&&0===e.left&&0===e.right&&0===e.top&&0===e.bottom,e&&0===e.width&&0===e.height&&!u?(g[l].hasAttribute("href")&&g[l].setAttributeNS(s,"xlink:href",c),t.length&&(!0!==(d=n[t])&&v()(y({useEl:g[l],base:t,hash:i}),0),void 0===d&&void 0!==(h=a(t))&&(d=new h,n[t]=d,d.onload=b(d),d.onerror=x(d),d.ontimeout=x(d),d.open("GET",t),d.send(),p+=1))):u?t.length&&n[t]&&v()(y({useEl:g[l],base:t,hash:i}),0):void 0===n[t]?n[t]=!0:n[t].onload&&(n[t].abort(),delete n[t].onload,n[t]=!0)}g="",p+=1,m()},i=function(){window.removeEventListener("load",i,!1),e=v()(t,0)},"complete"!==document.readyState?window.addEventListener("load",i,!1):i()}}();var p=n(1845);function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var y=n(184),b=n(662),x=n(7172);var C=n(711);function I(t,e){var i;if(t){if("string"==typeof t)return m(t,e);var n=C(i=Object.prototype.toString.call(t)).call(i,8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?x(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,e):void 0}}function _(t){return function(t){if(p(t))return m(t)}(t)||function(t){if(void 0!==y&&null!=b(t)||null!=t["@@iterator"])return x(t)}(t)||I(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var M=n(7077);function S(t,e,i){return e in t?M(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),M(t,n.key,n)}}function T(t,e,i){return e&&k(t.prototype,e),i&&k(t,i),t}var D=n(4426),A=n.n(D),j=n(9406),O=n.n(j),E=n(8189),L=n.n(E),N=n(3972),P=n.n(N),z=n(2777),B=n(7969),R=n.n(B),F=n(3929),Y=n.n(F),W=n(1690),H=n.n(W),U=n(2278),G=n.n(U),X=n(758),Z=n.n(X),V=n(2461),J=n.n(V);function Q(t,e){return function(t){if(p(t))return t}(t)||function(t,e){var i=null==t?null:void 0!==y&&b(t)||t["@@iterator"];if(null!=i){var n,r,o=[],a=!0,s=!1;try{for(i=i.call(t);!(a=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==i.return||i.return()}finally{if(s)throw r}}return o}}(t,e)||I(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var K,q=n(6397),$=n.n(q),tt=n(7636),et=n.n(tt),it=n(789),nt=n.n(it),rt=n(1391),ot=n.n(rt),at=n(6004),st=n.n(at),ct=n(7928),lt=n.n(ct),ut=["zoomIn","zoomOut","hand"],ht=["history","undo","redo","reset"],ft=["delete","deleteAll"],gt=O()(K=[]).call(K,ut,ht,ft),dt="filter",vt="color",pt=["rect","circle","triangle"],mt="cropzone",yt="vintage",bt="sepia2",xt="removeColor",Ct="colorFilter",It="removeWhite",_t="blendColor",Mt="blend",St=Pi("IMAGE_LOADER","CROPPER","FLIP","ROTATION","FREE_DRAWING","LINE","TEXT","ICON","FILTER","SHAPE","ZOOM","RESIZE"),wt={hasRotatingPoint:!1,hasBorders:!1,lockScalingFlip:!0,lockRotation:!0,lockSkewingX:!0,lockSkewingY:!0},kt="clearObjects",Tt="loadImage",Dt="flip",At="rotate",jt="addObject",Ot="removeObject",Et="applyFilter",Lt="removeFilter",Nt="addIcon",Pt="changeIconColor",zt="addShape",Bt="changeShape",Rt="addText",Ft="changeText",Yt="changeTextStyle",Wt="addImageObject",Ht="resizeCanvasDimension",Ut="setObjectProperties",Gt="setObjectPosition",Xt="changeSelection",Zt="resize",Vt="objectActivated",Jt="objectMoved",Qt="objectScaled",Kt="objectRotated",qt="objectAdded",$t="objectModified",te="textEditing",ee="textChanged",ie="iconCreateResize",ne="iconCreateEnd",re="addText",oe="addObject",ae="addObjectAfter",se="mousedown",ce="redoStackChanged",le="undoStackChanged",ue="selectionCleared",he="selectionCreated",fe="executeCommand",ge="afterUndo",de="afterRedo",ve="zoomChanged",pe="handStarted",me="handStopped",ye="keydown",be="keyup",xe="inputBoxEditingStarted",Ce="inputBoxEditingStopped",Ie="focus",_e="blur",Me=".tui-colorpicker-palette-hex",Se="Load",we="Mask",ke="Mask",Te="Crop",De="Resize",Ae="Filter",je="Filter",Oe="Shape",Ee="Icon",Le="Text",Ne="Text",Pe="Delete",ze="Delete",Be=Pi("NORMAL","CROPPER","FREE_DRAWING","LINE_DRAWING","TEXT","SHAPE","ICON","ZOOM","RESIZE"),Re="text",Fe="crop",Ye="resize",We="shape",He="zoom",Ue="normal",Ge="zoom",Xe="hand",Ze=90,Ve=89,Je=67,Qe=86,Ke=16,qe=8,$e=46,ti=40,ei=38,ii=32,ni=48,ri=57,oi={borderColor:"red",cornerColor:"green",cornerSize:10,originX:"center",originY:"center",transparentCorners:!1},ai="The object is already added.",si="The flipX and flipY setting values are not changed.",ci="Invalid parameters.",li="The executing command state is locked.",ui="The background image is empty.",hi="Invalid image loaded.",fi="The object is not in canvas.",gi="The promise of redo command is reject.",di="The promise of undo command is reject.",vi="Unsupported operation.",pi="Unsupported object type.",mi={"icon-arrow":"M40 12V0l24 24-24 24V36H0V12h40z","icon-arrow-2":"M49,32 H3 V22 h46 l-18,-18 h12 l23,23 L43,50 h-12 l18,-18 z ","icon-arrow-3":"M43.349998,27 L17.354,53 H1.949999 l25.996,-26 L1.949999,1 h15.404 L43.349998,27 z ","icon-star":"M35,54.557999 l-19.912001,10.468 l3.804,-22.172001 l-16.108,-15.7 l22.26,-3.236 L35,3.746 l9.956,20.172001 l22.26,3.236 l-16.108,15.7 l3.804,22.172001 z ","icon-star-2":"M17,31.212 l-7.194,4.08 l-4.728,-6.83 l-8.234,0.524 l-1.328,-8.226 l-7.644,-3.14 l2.338,-7.992 l-5.54,-6.18 l5.54,-6.176 l-2.338,-7.994 l7.644,-3.138 l1.328,-8.226 l8.234,0.522 l4.728,-6.83 L17,-24.312 l7.194,-4.08 l4.728,6.83 l8.234,-0.522 l1.328,8.226 l7.644,3.14 l-2.338,7.992 l5.54,6.178 l-5.54,6.178 l2.338,7.992 l-7.644,3.14 l-1.328,8.226 l-8.234,-0.524 l-4.728,6.83 z ","icon-polygon":"M3,31 L19,3 h32 l16,28 l-16,28 H19 z ","icon-location":"M24 62C8 45.503 0 32.837 0 24 0 10.745 10.745 0 24 0s24 10.745 24 24c0 8.837-8 21.503-24 38zm0-28c5.523 0 10-4.477 10-10s-4.477-10-10-10-10 4.477-10 10 4.477 10 10 10z","icon-heart":"M49.994999,91.349998 l-6.96,-6.333 C18.324001,62.606995 2.01,47.829002 2.01,29.690998 C2.01,14.912998 13.619999,3.299999 28.401001,3.299999 c8.349,0 16.362,5.859 21.594,12 c5.229,-6.141 13.242001,-12 21.591,-12 c14.778,0 26.390999,11.61 26.390999,26.390999 c0,18.138 -16.314001,32.916 -41.025002,55.374001 l-6.96,6.285 z ","icon-bubble":"M44 48L34 58V48H12C5.373 48 0 42.627 0 36V12C0 5.373 5.373 0 12 0h40c6.627 0 12 5.373 12 12v24c0 6.627-5.373 12-12 12h-8z"},yi={realTimeEvent:!0,min:-360,max:360,value:0},bi={min:5,max:30,value:12},xi={realTimeEvent:!0,min:2,max:300,value:3},Ci={realTimeEvent:!0,min:10,max:100,value:50},Ii={tintOpacityRange:{realTimeEvent:!0,min:0,max:1,value:.7,useDecimal:!0},removewhiteDistanceRange:{realTimeEvent:!0,min:0,max:1,value:.2,useDecimal:!0},brightnessRange:{realTimeEvent:!0,min:-1,max:1,value:0,useDecimal:!0},noiseRange:{realTimeEvent:!0,min:0,max:1e3,value:100},pixelateRange:{realTimeEvent:!0,min:2,max:20,value:4},colorfilterThresholdRange:{realTimeEvent:!0,min:0,max:1,value:.2,useDecimal:!0},blurFilterRange:{value:.1}},_i=0,Mi=0,Si=.5,wi=.5,ki={realTimeEvent:!0,min:32},Ti="tui-image-editor-",Di=Math.min,Ai=Math.max,ji=!1,Oi=0;function Ei(t){return t.__fe_id||(Oi+=1,t.__fe_id=Oi),t.__fe_id}function Li(t){return"function"==typeof t}function Ni(t,e,i){if(e>i){var n=[i,e];e=n[0],i=n[1]}return Ai(e,Di(t,i))}function Pi(){for(var t={},e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return H()(i,(function(e){t[e]=e})),t}function zi(t,e){var i,n={},r=e.length,o=0;for(o=0;o<r;o+=1)n[i=e[o]]=t[i];return n}function Bi(t){return $()(t,10)}function Ri(t){return t.replace(/-([a-z])/g,(function(t,e){return e.toUpperCase()}))}function Fi(){return!!(window.File&&window.FileList&&window.FileReader)}function Yi(t,e){var i,n,r,o;4===t.length&&(t=O()(o="".concat(t)).call(o,h()(t).call(t,1,4)));var a=$()(h()(t).call(t,1,3),16),s=$()(h()(t).call(t,3,5),16),c=$()(h()(t).call(t,5,7),16),l=e||1;return O()(i=O()(n=O()(r="rgba(".concat(a,", ")).call(r,s,", ")).call(n,c,", ")).call(i,l,")")}function Wi(t){H()(t,(function(e,i){t[i]=null}))}function Hi(){var t,e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"."===i.charAt(0)?O()(e=".".concat(Ti).concat(n)).call(e,h()(i).call(i,1)):O()(t="".concat(Ti).concat(n)).call(t,i)}function Ui(t,e){t.customProps=t.customProps||{},R()(t.customProps,e)}function Gi(t,e){var i={};return Z()(e)&&(e=[e]),H()(e,(function(e){i[e]=t.customProps[e]})),i}function Xi(t,e){return o()(t).call(t,e)>=0}function Zi(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return st()(t,"type")||vt}function Vi(t){var e=nt()(t);return(void 0===e?{}:e).source?dt:vt}function Ji(t){return lt()(t.get("type"),pt)>=0}function Qi(t){if(Xi(pt,t))return"Shape";switch(t){case"i-text":return"Text";case"path":case"line":return"Draw";case"activeSelection":return"Group";default:return qi(t)}}function Ki(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.useAlpha,r=void 0===n||n,o=i.mode,a=yt,s=xt,c=_t,l=bt,u=Ct,h=It,f=Mt;switch(t){case a:e=l;break;case s:e=r?u:h;break;case c:e="add"===o?f:o;break;default:e=t}return qi(e)}function qi(t){return t.replace(/[a-z]/,(function(t){return t.toUpperCase()}))}var $i=Pi("UN_IMPLEMENTATION","NO_COMPONENT_NAME"),tn="Should implement a method: ",en="Should set a component name",nn={UN_IMPLEMENTATION:function(t){return tn+t},NO_COMPONENT_NAME:function(){return en}},rn={types:R()({},$i),create:function(t){t=t.toLowerCase();for(var e=nn[t],i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return e.apply(void 0,n)}},on=rn.create,an=rn.types,sn=function(){function t(e,i){w(this,t),this.name=e.name,this.args=i,this.execute=e.execute,this.undo=e.undo,this.executeCallback=e.executeCallback||null,this.undoCallback=e.undoCallback||null,this.undoData={}}return T(t,[{key:"execute",value:function(){throw new Error(on(an.UN_IMPLEMENTATION,"execute"))}},{key:"undo",value:function(){throw new Error(on(an.UN_IMPLEMENTATION,"undo"))}},{key:"isRedo",get:function(){return J()(this.undoData).length>0}},{key:"setUndoData",value:function(t,e,i){return e&&(t=e),i?e||(e=t):(R()(this.undoData,t),e=null),e}},{key:"setExecuteCallback",value:function(t){return this.executeCallback=t,this}},{key:"setUndoCallback",value:function(t){return this.undoCallback=t,this}}]),t}(),cn=sn,ln={};var un={create:function(t){var e=ln[t];if(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return new cn(e,n)}return null},register:function(t){ln[t.name]=t}},hn=function(){function t(){w(this,t),this._undoStack=[],this._redoStack=[],this._isLocked=!1,this._isSilent=!1}return T(t,[{key:"_invokeExecution",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.lock();var n=t.args;return n||(n=[]),t.execute.apply(t,_(n)).then((function(n){return e._isSilent||(e.pushUndoStack(t),e.fire(i?de:fe,t)),e.unlock(),Li(t.executeCallback)&&t.executeCallback(n),n})).catch((function(t){return e.unlock(),L().reject(t)}))}},{key:"_invokeUndo",value:function(t){var e=this;this.lock();var i=t.args;return i||(i=[]),t.undo.apply(t,_(i)).then((function(i){return e.pushRedoStack(t),e.fire(ge,t),e.unlock(),Li(t.undoCallback)&&t.undoCallback(i),i})).catch((function(t){return e.unlock(),L().reject(t)}))}},{key:"_fireRedoStackChanged",value:function(){this.fire(ce,this._redoStack.length)}},{key:"_fireUndoStackChanged",value:function(){this.fire(le,this._undoStack.length)}},{key:"lock",value:function(){this._isLocked=!0}},{key:"unlock",value:function(){this._isLocked=!1}},{key:"executeSilent",value:function(){var t=this;this._isSilent=!0;for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return this.execute.apply(this,O()(i).call(i,[this._isSilent])).then((function(){t._isSilent=!1}))}},{key:"execute",value:function(){var t=this;if(this._isLocked)return L().reject(li);for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];var r=i[0];return Z()(r)&&(r=un.create.apply(un,i)),this._invokeExecution(r).then((function(e){return t.clearRedoStack(),e}))}},{key:"undo",value:function(){var t,e=this._undoStack.pop(),i="";if(e&&this._isLocked&&(this.pushUndoStack(e,!0),e=null),e)this.isEmptyUndoStack()&&this._fireUndoStackChanged(),t=this._invokeUndo(e);else{var n;if(i=di,this._isLocked)i=O()(n="".concat(i," Because ")).call(n,li);t=L().reject(i)}return t}},{key:"redo",value:function(){var t,e=this._redoStack.pop(),i="";if(e&&this._isLocked&&(this.pushRedoStack(e,!0),e=null),e)this.isEmptyRedoStack()&&this._fireRedoStackChanged(),t=this._invokeExecution(e,!0);else{var n;if(i=gi,this._isLocked)i=O()(n="".concat(i," Because ")).call(n,li);t=L().reject(i)}return t}},{key:"pushUndoStack",value:function(t,e){this._undoStack.push(t),e||this._fireUndoStackChanged()}},{key:"pushRedoStack",value:function(t,e){this._redoStack.push(t),e||this._fireRedoStackChanged()}},{key:"isEmptyRedoStack",value:function(){return 0===this._redoStack.length}},{key:"isEmptyUndoStack",value:function(){return 0===this._undoStack.length}},{key:"clearUndoStack",value:function(){this.isEmptyUndoStack()||(this._undoStack=[],this._fireUndoStackChanged())}},{key:"clearRedoStack",value:function(){this.isEmptyRedoStack()||(this._redoStack=[],this._fireRedoStackChanged())}}]),t}();G().mixin(hn);var fn=hn,gn=n(5214),dn=n.n(gn),vn=n(899),pn=n.n(vn),mn={"common.bi.image":"https://uicdn.toast.com/toastui/img/tui-image-editor-bi.png","common.bisize.width":"251px","common.bisize.height":"21px","common.backgroundImage":"none","common.backgroundColor":"#1e1e1e","common.border":"0px","header.backgroundImage":"none","header.backgroundColor":"transparent","header.border":"0px","loadButton.backgroundColor":"#fff","loadButton.border":"1px solid #ddd","loadButton.color":"#222","loadButton.fontFamily":"'Noto Sans', sans-serif","loadButton.fontSize":"12px","downloadButton.backgroundColor":"#fdba3b","downloadButton.border":"1px solid #fdba3b","downloadButton.color":"#fff","downloadButton.fontFamily":"'Noto Sans', sans-serif","downloadButton.fontSize":"12px","menu.normalIcon.color":"#8a8a8a","menu.activeIcon.color":"#555555","menu.disabledIcon.color":"#434343","menu.hoverIcon.color":"#e9e9e9","submenu.normalIcon.color":"#8a8a8a","submenu.activeIcon.color":"#e9e9e9","menu.iconSize.width":"24px","menu.iconSize.height":"24px","submenu.iconSize.width":"32px","submenu.iconSize.height":"32px","submenu.backgroundColor":"#1e1e1e","submenu.partition.color":"#3c3c3c","submenu.normalLabel.color":"#8a8a8a","submenu.normalLabel.fontWeight":"lighter","submenu.activeLabel.color":"#fff","submenu.activeLabel.fontWeight":"lighter","checkbox.border":"0px","checkbox.backgroundColor":"#fff","range.pointer.color":"#fff","range.bar.color":"#666","range.subbar.color":"#d1d1d1","range.disabledPointer.color":"#414141","range.disabledBar.color":"#282828","range.disabledSubbar.color":"#414141","range.value.color":"#fff","range.value.fontWeight":"lighter","range.value.fontSize":"11px","range.value.border":"1px solid #353535","range.value.backgroundColor":"#151515","range.title.color":"#fff","range.title.fontWeight":"lighter","colorpicker.button.border":"1px solid #1e1e1e","colorpicker.title.color":"#fff"},yn=n(2534),bn=function(){function t(e){var i,n,r,o,a;w(this,t),this.styles=this._changeToObject(R()({},mn,e)),i=this._styleMaker(),r=Q(document.getElementsByTagName("head"),1)[0],o=document.createElement("link"),a=encodeURIComponent(i),n&&(o.id=n),o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href","data:text/css;charset=UTF-8,".concat(a)),r.appendChild(o),this._loadDefaultSvgIcon()}return T(t,[{key:"getStyle",value:function(t){var e=null,i=t.replace(/\..+$/,""),n=this.styles[t];switch(t){case"common.bi":e=this.styles[t].image;break;case"menu.icon":e={active:this.styles["".concat(i,".activeIcon")],normal:this.styles["".concat(i,".normalIcon")],hover:this.styles["".concat(i,".hoverIcon")],disabled:this.styles["".concat(i,".disabledIcon")]};break;case"submenu.icon":e={active:this.styles["".concat(i,".activeIcon")],normal:this.styles["".concat(i,".normalIcon")]};break;case"submenu.label":e={active:this._makeCssText(this.styles["".concat(i,".activeLabel")]),normal:this._makeCssText(this.styles["".concat(i,".normalLabel")])};break;case"submenu.partition":e={vertical:this._makeCssText(R()({},n,{borderLeft:"1px solid ".concat(n.color)})),horizontal:this._makeCssText(R()({},n,{borderBottom:"1px solid ".concat(n.color)}))};break;case"range.disabledPointer":case"range.disabledBar":case"range.disabledSubbar":case"range.pointer":case"range.bar":case"range.subbar":n.backgroundColor=n.color,e=this._makeCssText(n);break;default:e=this._makeCssText(n)}return e}},{key:"_styleMaker",value:function(){var t=this.getStyle("submenu.label"),e=this.getStyle("submenu.partition");return function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y,b,x,C,I,_,M,S,w,k,T,D,A=t.subMenuLabelActive,j=t.subMenuLabelNormal,E=t.subMenuRangeTitle,L=t.submenuPartitionVertical,N=t.submenuPartitionHorizontal,P=t.submenuCheckbox,z=t.submenuRangePointer,B=t.submenuRangeValue,R=t.submenuColorpickerTitle,F=t.submenuColorpickerButton,Y=t.submenuRangeBar,W=t.submenuRangeSubbar,H=t.submenuDisabledRangePointer,U=t.submenuDisabledRangeBar,G=t.submenuDisabledRangeSubbar,X=t.submenuIconSize,Z=t.menuIconSize,V=t.biSize,J=t.menuIconStyle,Q=t.submenuIconStyle;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m=O()(y=O()(b=O()(x=O()(C=O()(I=O()(_=O()(M=O()(S=O()(w=O()(k=O()(T=O()(D='\n .tie-icon-add-button.icon-bubble .tui-image-editor-button[data-icontype="icon-bubble"] label,\n .tie-icon-add-button.icon-heart .tui-image-editor-button[data-icontype="icon-heart"] label,\n .tie-icon-add-button.icon-location .tui-image-editor-button[data-icontype="icon-location"] label,\n .tie-icon-add-button.icon-polygon .tui-image-editor-button[data-icontype="icon-polygon"] label,\n .tie-icon-add-button.icon-star .tui-image-editor-button[data-icontype="icon-star"] label,\n .tie-icon-add-button.icon-star-2 .tui-image-editor-button[data-icontype="icon-star-2"] label,\n .tie-icon-add-button.icon-arrow-3 .tui-image-editor-button[data-icontype="icon-arrow-3"] label,\n .tie-icon-add-button.icon-arrow-2 .tui-image-editor-button[data-icontype="icon-arrow-2"] label,\n .tie-icon-add-button.icon-arrow .tui-image-editor-button[data-icontype="icon-arrow"] label,\n .tie-icon-add-button.icon-bubble .tui-image-editor-button[data-icontype="icon-bubble"] label,\n .tie-draw-line-select-button.line .tui-image-editor-button.line label,\n .tie-draw-line-select-button.free .tui-image-editor-button.free label,\n .tie-flip-button.flipX .tui-image-editor-button.flipX label,\n .tie-flip-button.flipY .tui-image-editor-button.flipY label,\n .tie-flip-button.resetFlip .tui-image-editor-button.resetFlip label,\n .tie-crop-button .tui-image-editor-button.apply.active label,\n .tie-crop-preset-button .tui-image-editor-button.preset.active label,\n .tie-resize-button .tui-image-editor-button.apply.active label,\n .tie-resize-preset-button .tui-image-editor-button.preset.active label,\n .tie-shape-button.rect .tui-image-editor-button.rect label,\n .tie-shape-button.circle .tui-image-editor-button.circle label,\n .tie-shape-button.triangle .tui-image-editor-button.triangle label,\n .tie-text-effect-button .tui-image-editor-button.active label,\n .tie-text-align-button.tie-text-align-left .tui-image-editor-button.left label,\n .tie-text-align-button.tie-text-align-center .tui-image-editor-button.center label,\n .tie-text-align-button.tie-text-align-right .tui-image-editor-button.right label,\n .tie-mask-apply.apply.active .tui-image-editor-button.apply label,\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button:hover > label,\n .tui-image-editor-container .tui-image-editor-checkbox label > span {\n '.concat(A,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button > label,\n .tui-image-editor-container .tui-image-editor-range-wrap.tui-image-editor-newline.short label,\n .tui-image-editor-container .tui-image-editor-range-wrap.tui-image-editor-newline.short label > span {\n ")).call(D,j,"\n }\n .tui-image-editor-container .tui-image-editor-range-wrap label > span {\n ")).call(T,E,"\n }\n .tui-image-editor-container .tui-image-editor-partition > div {\n ")).call(k,L,"\n }\n .tui-image-editor-container.left .tui-image-editor-submenu .tui-image-editor-partition > div,\n .tui-image-editor-container.right .tui-image-editor-submenu .tui-image-editor-partition > div {\n ")).call(w,N,"\n }\n .tui-image-editor-container .tui-image-editor-checkbox label > span:before {\n ")).call(S,P,"\n }\n .tui-image-editor-container .tui-image-editor-checkbox label > input:checked + span:before {\n border: 0;\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-pointer {\n ")).call(M,z,"\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-bar {\n ")).call(_,Y,"\n }\n .tui-image-editor-container .tui-image-editor-virtual-range-subbar {\n ")).call(I,W,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-pointer {\n ")).call(C,H,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-subbar {\n ")).call(x,G,"\n }\n .tui-image-editor-container .tui-image-editor-disabled .tui-image-editor-virtual-range-bar {\n ")).call(b,U,"\n }\n .tui-image-editor-container .tui-image-editor-range-value {\n ")).call(y,B,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button .color-picker-value + label {\n ")).call(m,R,"\n }\n .tui-image-editor-container .tui-image-editor-submenu .tui-image-editor-button .color-picker-value {\n ")).call(p,F,"\n }\n .tui-image-editor-container .svg_ic-menu {\n ")).call(v,Z,"\n }\n .tui-image-editor-container .svg_ic-submenu {\n ")).call(d,X,"\n }\n .tui-image-editor-container .tui-image-editor-controls-logo > img,\n .tui-image-editor-container .tui-image-editor-header-logo > img {\n ")).call(g,V,"\n }\n .tui-image-editor-menu use.normal.use-default,\n .tui-image-editor-help-menu use.normal.use-default {\n fill-rule: evenodd;\n fill: ")).call(f,J.normal.color,";\n stroke: ")).call(h,J.normal.color,";\n }\n .tui-image-editor-menu use.active.use-default,\n .tui-image-editor-help-menu use.active.use-default {\n fill-rule: evenodd;\n fill: ")).call(u,J.active.color,";\n stroke: ")).call(l,J.active.color,";\n }\n .tui-image-editor-menu use.hover.use-default,\n .tui-image-editor-help-menu use.hover.use-default {\n fill-rule: evenodd;\n fill: ")).call(c,J.hover.color,";\n stroke: ")).call(s,J.hover.color,";\n }\n .tui-image-editor-menu use.disabled.use-default,\n .tui-image-editor-help-menu use.disabled.use-default {\n fill-rule: evenodd;\n fill: ")).call(a,J.disabled.color,";\n stroke: ")).call(o,J.disabled.color,";\n }\n .tui-image-editor-submenu use.normal.use-default {\n fill-rule: evenodd;\n fill: ")).call(r,Q.normal.color,";\n stroke: ")).call(n,Q.normal.color,";\n }\n .tui-image-editor-submenu use.active.use-default {\n fill-rule: evenodd;\n fill: ")).call(i,Q.active.color,";\n stroke: ")).call(e,Q.active.color,";\n }\n")}({subMenuLabelActive:t.active,subMenuLabelNormal:t.normal,submenuPartitionVertical:e.vertical,submenuPartitionHorizontal:e.horizontal,biSize:this.getStyle("common.bisize"),subMenuRangeTitle:this.getStyle("range.title"),submenuRangePointer:this.getStyle("range.pointer"),submenuRangeBar:this.getStyle("range.bar"),submenuRangeSubbar:this.getStyle("range.subbar"),submenuDisabledRangePointer:this.getStyle("range.disabledPointer"),submenuDisabledRangeBar:this.getStyle("range.disabledBar"),submenuDisabledRangeSubbar:this.getStyle("range.disabledSubbar"),submenuRangeValue:this.getStyle("range.value"),submenuColorpickerTitle:this.getStyle("colorpicker.title"),submenuColorpickerButton:this.getStyle("colorpicker.button"),submenuCheckbox:this.getStyle("checkbox"),menuIconSize:this.getStyle("menu.iconSize"),submenuIconSize:this.getStyle("submenu.iconSize"),menuIconStyle:this.getStyle("menu.icon"),submenuIconStyle:this.getStyle("submenu.icon")})}},{key:"_changeToObject",value:function(t){var e={};return H()(t,(function(t,i){var n=Q(i.match(/^(.+)\.([a-z]+)$/i),3),r=n[1],o=n[2];e[r]||(e[r]={}),e[r][o]=t})),e}},{key:"_makeCssText",value:function(t){var e=this,i=[];return H()(t,(function(t,n){var r,a;o()(r=["backgroundImage"]).call(r,n)>-1&&"none"!==t&&(t="url(".concat(t,")")),i.push(O()(a="".concat(e._toUnderScore(n),": ")).call(a,t))})),i.join(";")}},{key:"_toUnderScore",value:function(t){return t.replace(/([A-Z])/g,(function(t,e){return"-".concat(e.toLowerCase())}))}},{key:"_loadDefaultSvgIcon",value:function(){if(!document.getElementById("tui-image-editor-svg-default-icons")){var t=new DOMParser,e=yn.replace(/data:image\/svg\+xml;base64,/,""),i=t.parseFromString(atob(e),"text/xml");document.body.appendChild(i.documentElement)}}},{key:"_makeIconClassName",value:function(t,e){var i=(e?this.getStyle("submenu.icon"):this.getStyle("menu.icon"))[t],n=i.path,r=i.name;return n&&r?t:"".concat(t," use-default")}},{key:"_makeSvgIconPrefix",value:function(t,e){var i,n=(e?this.getStyle("submenu.icon"):this.getStyle("menu.icon"))[t],r=n.path,o=n.name;return r&&o?O()(i="".concat(r,"#")).call(i,o,"-"):"#"}},{key:"_makeSvgItem",value:function(t,e,i){var n=this;return pn()(t).call(t,(function(t){var r,o,a=n._makeSvgIconPrefix(t,i),s=n._toUnderScore(e),c=n._makeIconClassName(t,i);return O()(r=O()(o='<use xlink:href="'.concat(a,"ic-")).call(o,s,'" class="')).call(r,c,'"/>')})).join("")}},{key:"makeMenSvgIconSet",value:function(t,e){var i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return O()(i='<svg class="svg_ic-'.concat(n?"submenu":"menu",'">')).call(i,this._makeSvgItem(t,e,n),"</svg>")}}]),t}(),xn=bn,Cn=n(9146),In=n.n(Cn),_n=n(6623),Mn=n(4230);function Sn(t,e){return Sn=Mn||function(t,e){return t.__proto__=e,t},Sn(t,e)}function wn(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=_n(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Sn(t,e)}var kn=n(3742);function Tn(t){return Tn="function"==typeof y&&"symbol"==typeof kn?function(t){return typeof t}:function(t){return t&&"function"==typeof y&&t.constructor===y&&t!==y.prototype?"symbol":typeof t},Tn(t)}function Dn(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function An(t,e){if(e&&("object"===Tn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return Dn(t)}var jn=n(9856);function On(t){return On=Mn?jn:function(t){return t.__proto__||jn(t)},On(t)}var En=n(893),Ln=n.n(En),Nn=n(4858),Pn=n.n(Nn),zn=["#000000","#2a2a2a","#545454","#7e7e7e","#a8a8a8","#d2d2d2","#ffffff","","#ff4040","#ff6518","#ffbb3b","#03bd9e","#00a9ff","#515ce6","#9e5fff","#ff5583"],Bn=function(){function t(e,i){var n=i.defaultColor,r=void 0===n?"#7e7e7e":n,o=i.toggleDirection,a=void 0===o?"up":o,s=i.usageStatistics;w(this,t),this.colorpickerElement=e,this.usageStatistics=s,this._show=!1,this._colorpickerElement=e,this._toggleDirection=a,this._makePickerButtonElement(r),this._makePickerLayerElement(e,e.getAttribute("title")),this._color=r,this.picker=Pn().create({container:this.pickerElement,preset:zn,color:r,usageStatistics:this.usageStatistics}),this._addEvent()}return T(t,[{key:"destroy",value:function(){var t=this;this._removeEvent(),this.picker.destroy(),this.colorpickerElement.innerHTML="",H()(this,(function(e,i){t[i]=null}))}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._changeColorElement(t)}},{key:"_changeColorElement",value:function(t){t?(this.colorElement.classList.remove("transparent"),this.colorElement.style.backgroundColor=t):(this.colorElement.style.backgroundColor="#fff",this.colorElement.classList.add("transparent"))}},{key:"_makePickerButtonElement",value:function(t){this.colorpickerElement.classList.add("tui-image-editor-button"),this.colorElement=document.createElement("div"),this.colorElement.className="color-picker-value",t?this.colorElement.style.backgroundColor=t:this.colorElement.classList.add("transparent")}},{key:"_makePickerLayerElement",value:function(t,e){var i=document.createElement("label"),n=document.createElement("div");this.pickerControl=document.createElement("div"),this.pickerControl.className="color-picker-control",this.pickerElement=document.createElement("div"),this.pickerElement.className="color-picker",i.innerHTML=e,n.className="triangle",this.pickerControl.appendChild(this.pickerElement),this.pickerControl.appendChild(n),t.appendChild(this.pickerControl),t.appendChild(this.colorElement),t.appendChild(i)}},{key:"_addEvent",value:function(){var t,e=this;this.picker.on("selectColor",(function(t){e._changeColorElement(t.color),e._color=t.color,e.fire("change",t.color)})),this.eventHandler={pickerToggle:A()(t=this._pickerToggleEventHandler).call(t,this),pickerHide:function(){return e.hide()}},this.colorpickerElement.addEventListener("click",this.eventHandler.pickerToggle),document.body.addEventListener("click",this.eventHandler.pickerHide)}},{key:"_removeEvent",value:function(){this.colorpickerElement.removeEventListener("click",this.eventHandler.pickerToggle),document.body.removeEventListener("click",this.eventHandler.pickerHide),this.picker.off()}},{key:"_pickerToggleEventHandler",value:function(t){var e=t.target,i=e&&this._isElementInColorPickerControl(e);(!i||i&&this._isPaletteButton(e))&&(this._show=!this._show,this.pickerControl.style.display=this._show?"block":"none",this._setPickerControlPosition(),this.fire("changeShow",this)),t.stopPropagation()}},{key:"_isPaletteButton",value:function(t){return"tui-colorpicker-palette-button"===t.className}},{key:"_isElementInColorPickerControl",value:function(t){for(var e=t;e!==document.body&&e;){if(e===this.pickerControl)return!0;e=e.parentNode}return!1}},{key:"hide",value:function(){this._show=!1,this.pickerControl.style.display="none"}},{key:"_setPickerControlPosition",value:function(){var t=this.pickerControl.style,e=this._colorpickerElement.clientWidth/2+2,i=this.pickerControl.offsetWidth/2-e,n=-1*(this.pickerControl.offsetHeight+10);"down"===this._toggleDirection&&(n=30),t.top="".concat(n,"px"),t.left="-".concat(i,"px")}}]),t}();G().mixin(Bn);var Rn=Bn,Fn=/(-?)([0-9]*)[^0-9]*([0-9]*)/g,Yn=function(){function t(e){var i,n,r,o,a,s,c,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w(this,t),this._value=l.value||0,this.rangeElement=e.slider,this.rangeInputElement=e.input,this._drawRangeElement(),this.rangeWidth=this._getRangeWidth(),this._min=l.min||0,this._max=l.max||100,this._useDecimal=l.useDecimal,this._absMax=-1*this._min+this._max,this.realTimeEvent=l.realTimeEvent||!1,this._userInputTimer=null,this.eventHandler={startChangingSlide:A()(i=this._startChangingSlide).call(i,this),stopChangingSlide:A()(n=this._stopChangingSlide).call(n,this),changeSlide:A()(r=this._changeSlide).call(r,this),changeSlideFinally:A()(o=this._changeSlideFinally).call(o,this),changeInput:A()(a=this._changeInput).call(a,this),changeInputFinally:A()(s=this._changeValueWithInput).call(s,this,!0),changeInputWithArrow:A()(c=this._changeValueWithInputKeyEvent).call(c,this)},this._addClickEvent(),this._addDragEvent(),this._addInputEvent(),this.value=l.value,this.trigger("change")}return T(t,[{key:"destroy",value:function(){var t=this;this._removeClickEvent(),this._removeDragEvent(),this._removeInputEvent(),this.rangeElement.innerHTML="",H()(this,(function(e,i){t[i]=null}))}},{key:"max",get:function(){return this._max},set:function(t){this._max=t,this._absMax=-1*this._min+this._max,this.value=this._value}},{key:"min",get:function(){return this._min},set:function(t){this._min=t,this.max=this._max}},{key:"value",get:function(){return this._value},set:function(t){var e=((t=this._useDecimal?t:Bi(t))-this._min)*this.rangeWidth/this._absMax;this.rangeWidth<e&&(e=this.rangeWidth),this.pointer.style.left="".concat(e,"px"),this.subbar.style.right="".concat(this.rangeWidth-e,"px"),this._value=t,this.rangeInputElement&&(this.rangeInputElement.value=t)}},{key:"trigger",value:function(t){this.fire(t,this._value)}},{key:"_getRangeWidth",value:function(){var t=function(t){return Bi(window.getComputedStyle(t,null).width)};return t(this.rangeElement)-t(this.pointer)}},{key:"_drawRangeElement",value:function(){this.rangeElement.classList.add("tui-image-editor-range"),this.bar=document.createElement("div"),this.bar.className="tui-image-editor-virtual-range-bar",this.subbar=document.createElement("div"),this.subbar.className="tui-image-editor-virtual-range-subbar",this.pointer=document.createElement("div"),this.pointer.className="tui-image-editor-virtual-range-pointer",this.bar.appendChild(this.subbar),this.bar.appendChild(this.pointer),this.rangeElement.appendChild(this.bar)}},{key:"_addInputEvent",value:function(){this.rangeInputElement&&(this.rangeInputElement.addEventListener("keydown",this.eventHandler.changeInputWithArrow),this.rangeInputElement.addEventListener("keydown",this.eventHandler.changeInput),this.rangeInputElement.addEventListener("blur",this.eventHandler.changeInputFinally))}},{key:"_removeInputEvent",value:function(){this.rangeInputElement&&(this.rangeInputElement.removeEventListener("keydown",this.eventHandler.changeInputWithArrow),this.rangeInputElement.removeEventListener("keydown",this.eventHandler.changeInput),this.rangeInputElement.removeEventListener("blur",this.eventHandler.changeInputFinally))}},{key:"_changeValueWithInputKeyEvent",value:function(t){var e,i=t.keyCode,n=t.target;if(!(o()(e=[ei,ti]).call(e,i)<0)){var r=Number(n.value);if(!((r=this._valueUpDownForKeyEvent(r,i))<this._min||r>this._max)){var a=Ni(r,this._min,this.max);this.value=a,this.fire("change",a,!1)}}}},{key:"_valueUpDownForKeyEvent",value:function(t,e){var i=this._useDecimal?.1:1;return e===ei?t+=i:e===ti&&(t-=i),t}},{key:"_changeInput",value:function(t){var e=this;clearTimeout(this._userInputTimer);var i=t.keyCode;i<ni||i>ri?t.preventDefault():this._userInputTimer=v()((function(){e._inputSetValue(t.target.value)}),350)}},{key:"_inputSetValue",value:function(t){var e=this._useDecimal?Number(t):Bi(t);e=Ni(e,this._min,this.max),this.value=e,this.fire("change",e,!0)}},{key:"_changeValueWithInput",value:function(t,e){var i,n=e.keyCode,r=e.target;if(!(o()(i=[ei,ti]).call(i,n)>=0)){var a=this._filterForInputText(r.value),s=!a||isNaN(a);r.value=a,s||this._inputSetValue(a)}}},{key:"_addClickEvent",value:function(){this.rangeElement.addEventListener("click",this.eventHandler.changeSlideFinally)}},{key:"_removeClickEvent",value:function(){this.rangeElement.removeEventListener("click",this.eventHandler.changeSlideFinally)}},{key:"_addDragEvent",value:function(){this.pointer.addEventListener("mousedown",this.eventHandler.startChangingSlide)}},{key:"_removeDragEvent",value:function(){this.pointer.removeEventListener("mousedown",this.eventHandler.startChangingSlide)}},{key:"_changeSlide",value:function(t){var e=t.screenX-this.firstPosition,i=this.firstLeft+e;i=(i=i>this.rangeWidth?this.rangeWidth:i)<0?0:i,this.pointer.style.left="".concat(i,"px"),this.subbar.style.right="".concat(this.rangeWidth-i,"px");var n=i/this.rangeWidth,r=this._absMax*n+this._min,o=this._useDecimal?r:Bi(r);this.value!==o&&(this.value=o,this.realTimeEvent&&this.fire("change",this._value,!1))}},{key:"_changeSlideFinally",value:function(t){if(t.stopPropagation(),"tui-image-editor-range"===t.target.className){var e=t.offsetX/this.rangeWidth,i=this._absMax*e+this._min;this.pointer.style.left="".concat(e*this.rangeWidth,"px"),this.subbar.style.right="".concat((1-e)*this.rangeWidth,"px"),this.value=i,this.fire("change",i,!0)}}},{key:"_startChangingSlide",value:function(t){this.firstPosition=t.screenX,this.firstLeft=Bi(this.pointer.style.left)||0,document.addEventListener("mousemove",this.eventHandler.changeSlide),document.addEventListener("mouseup",this.eventHandler.stopChangingSlide)}},{key:"_stopChangingSlide",value:function(){this.fire("change",this._value,!0),document.removeEventListener("mousemove",this.eventHandler.changeSlide),document.removeEventListener("mouseup",this.eventHandler.stopChangingSlide)}},{key:"_filterForInputText",value:function(t){return t.replace(Fn,"$1$2$3")}}]),t}();G().mixin(Yn);var Wn=Yn,Hn=function(){function t(e,i){var n=i.locale,r=i.name,o=i.makeSvgIcon,a=i.menuBarPosition,s=i.templateHtml,c=i.usageStatistics;w(this,t),this.subMenuElement=e,this.menuBarPosition=a,this.toggleDirection="top"===a?"down":"up",this.colorPickerControls=[],this.usageStatistics=c,this.eventHandler={},this._makeSubMenuElement({locale:n,name:r,makeSvgIcon:o,templateHtml:s})}return T(t,[{key:"selector",value:function(t){return this.subMenuElement.querySelector(t)}},{key:"colorPickerChangeShow",value:function(t){var e;et()(e=this.colorPickerControls).call(e,(function(e){t!==e&&e.hide()}))}},{key:"getButtonType",value:function(t,e){return t.className.match(RegExp("(".concat(e.join("|"),")")))[0]}},{key:"changeClass",value:function(t,e,i){t.classList.remove(e),t.classList.add(i)}},{key:"changeStandbyMode",value:function(){}},{key:"changeStartMode",value:function(){}},{key:"_makeSubMenuElement",value:function(t){var e=t.locale,i=t.name,n=t.iconStyle,r=t.makeSvgIcon,o=t.templateHtml,a=document.createElement("div");a.className="tui-image-editor-menu-".concat(i),a.innerHTML=o({locale:e,iconStyle:n,makeSvgIcon:r}),this.subMenuElement.appendChild(a)}},{key:"_onStartEditingInputBox",value:function(){this.fire(xe)}},{key:"_onStopEditingInputBox",value:function(){this.fire(Ce)}}]),t}();G().mixin(Hn);var Un=Hn,Gn=function(t){var e,i,n,r,o,a,s,c,l=t.locale,u=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-shape-button">\n <div class="tui-image-editor-button rect">\n <div>\n '.concat(u(["normal","active"],"shape-rectangle",!0),"\n </div>\n <label> ")).call(c,l.localize("Rectangle"),' </label>\n </div>\n <div class="tui-image-editor-button circle">\n <div>\n ')).call(s,u(["normal","active"],"shape-circle",!0),"\n </div>\n <label> ")).call(a,l.localize("Circle"),' </label>\n </div>\n <div class="tui-image-editor-button triangle">\n <div>\n ')).call(o,u(["normal","active"],"shape-triangle",!0),"\n </div>\n <label> ")).call(r,l.localize("Triangle"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-shape-color-button">\n <div class="tie-color-fill" title="')).call(n,l.localize("Fill"),'"></div>\n <div class="tie-color-stroke" title="')).call(i,l.localize("Stroke"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,l.localize("Stroke"),'</label>\n <div class="tie-stroke-range"></div>\n <input class="tie-stroke-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function Xn(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Zn={stroke:"#ffbb3b",fill:"",strokeWidth:3},Vn=function(t){wn(i,t);var e=Xn(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"shape",makeSvgIcon:a,menuBarPosition:s,templateHtml:Gn,usageStatistics:c})).type=null,r.options=Zn,r._els={shapeSelectButton:r.selector(".tie-shape-button"),shapeColorButton:r.selector(".tie-shape-color-button"),strokeRange:new Wn({slider:r.selector(".tie-stroke-range"),input:r.selector(".tie-stroke-range-value")},xi),fillColorpicker:new Rn(r.selector(".tie-color-fill"),{defaultColor:"",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),strokeColorpicker:new Rn(r.selector(".tie-color-stroke"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics})},r.colorPickerControls.push(r._els.fillColorpicker),r.colorPickerControls.push(r._els.strokeColorpicker),r.colorPickerInputBoxes=[],r.colorPickerInputBoxes.push(r._els.fillColorpicker.colorpickerElement.querySelector(Me)),r.colorPickerInputBoxes.push(r._els.strokeColorpicker.colorpickerElement.querySelector(Me)),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.strokeRange.destroy(),this._els.fillColorpicker.destroy(),this._els.strokeColorpicker.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a,s=this;this.eventHandler.shapeTypeSelected=A()(e=this._changeShapeHandler).call(e,this),this.actions=t,this._els.shapeSelectButton.addEventListener("click",this.eventHandler.shapeTypeSelected),this._els.strokeRange.on("change",A()(i=this._changeStrokeRangeHandler).call(i,this)),this._els.fillColorpicker.on("change",A()(n=this._changeFillColorHandler).call(n,this)),this._els.strokeColorpicker.on("change",A()(r=this._changeStrokeColorHandler).call(r,this)),this._els.fillColorpicker.on("changeShow",A()(o=this.colorPickerChangeShow).call(o,this)),this._els.strokeColorpicker.on("changeShow",A()(a=this.colorPickerChangeShow).call(a,this)),Ln()(this.colorPickerInputBoxes,(function(t){var e,i;t.addEventListener(Ie,A()(e=s._onStartEditingInputBox).call(e,s)),t.addEventListener(_e,A()(i=s._onStopEditingInputBox).call(i,s))}),this)}},{key:"_removeEvent",value:function(){var t=this;this._els.shapeSelectButton.removeEventListener("click",this.eventHandler.shapeTypeSelected),this._els.strokeRange.off(),this._els.fillColorpicker.off(),this._els.strokeColorpicker.off(),Ln()(this.colorPickerInputBoxes,(function(e){var i,n;e.removeEventListener(Ie,A()(i=t._onStartEditingInputBox).call(i,t)),e.removeEventListener(_e,A()(n=t._onStopEditingInputBox).call(n,t))}),this)}},{key:"setShapeStatus",value:function(t){var e=t.strokeWidth,i=t.strokeColor,n=t.fillColor;this._els.strokeRange.value=e,this._els.strokeColorpicker.color=i,this._els.fillColorpicker.color=n,this.options.stroke=i,this.options.fill=n,this.options.strokeWidth=e,this.actions.setDrawingShape(this.type,{strokeWidth:e})}},{key:"changeStartMode",value:function(){this.actions.stopDrawingMode()}},{key:"changeStandbyMode",value:function(){this.type=null,this.actions.changeSelectableAll(!0),this._els.shapeSelectButton.classList.remove("circle"),this._els.shapeSelectButton.classList.remove("triangle"),this._els.shapeSelectButton.classList.remove("rect")}},{key:"setMaxStrokeValue",value:function(t){var e=t;e<=0&&(e=xi.max),this._els.strokeRange.max=e}},{key:"setStrokeValue",value:function(t){this._els.strokeRange.value=t,this._els.strokeRange.trigger("change")}},{key:"getStrokeValue",value:function(){return this._els.strokeRange.value}},{key:"_changeShapeHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){this.actions.stopDrawingMode(),this.actions.discardSelection();var i=this.getButtonType(e,["circle","triangle","rect"]);if(this.type===i)return void this.changeStandbyMode();this.changeStandbyMode(),this.type=i,t.currentTarget.classList.add(i),this.actions.changeSelectableAll(!1),this.actions.modeChange("shape")}}},{key:"_changeStrokeRangeHandler",value:function(t,e){this.options.strokeWidth=Bi(t),this.actions.changeShape({strokeWidth:t},!e),this.actions.setDrawingShape(this.type,this.options)}},{key:"_changeFillColorHandler",value:function(t){t=t||"transparent",this.options.fill=t,this.actions.changeShape({fill:t})}},{key:"_changeStrokeColorHandler",value:function(t){t=t||"transparent",this.options.stroke=t,this.actions.changeShape({stroke:t})}}]),i}(Un),Jn=Vn,Qn=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y=t.locale,b=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-crop-preset-button">\n <div class="tui-image-editor-button preset preset-none active">\n <div>\n '.concat(b(["normal","active"],"shape-rectangle",!0),"\n </div>\n <label> ")).call(m,y.localize("Custom"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-square">\n <div>\n ')).call(p,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(v,y.localize("Square"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-3-2">\n <div>\n ')).call(d,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(g,y.localize("3:2"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-4-3">\n <div>\n ')).call(f,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(h,y.localize("4:3"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-5-4">\n <div>\n ')).call(u,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(l,y.localize("5:4"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-7-5">\n <div>\n ')).call(c,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(s,y.localize("7:5"),' </label>\n </div>\n <div class="tui-image-editor-button preset preset-16-9">\n <div>\n ')).call(a,b(["normal","active"],"crop",!0),"\n </div>\n <label> ")).call(o,y.localize("16:9"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline">\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tie-crop-button action">\n <div class="tui-image-editor-button apply">\n ')).call(r,b(["normal","active"],"apply"),"\n <label>\n ")).call(n,y.localize("Apply"),'\n </label>\n </div>\n <div class="tui-image-editor-button cancel">\n ')).call(i,b(["normal","active"],"cancel"),"\n <label>\n ")).call(e,y.localize("Cancel"),"\n </label>\n </div>\n </li>\n </ul>\n")};function Kn(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var qn=function(t){wn(i,t);var e=Kn(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"crop",makeSvgIcon:a,menuBarPosition:s,templateHtml:Qn,usageStatistics:c})).status="active",r._els={apply:r.selector(".tie-crop-button .apply"),cancel:r.selector(".tie-crop-button .cancel"),preset:r.selector(".tie-crop-preset-button")},r.defaultPresetButton=r._els.preset.querySelector(".preset-none"),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r=A()(e=this._applyEventHandler).call(e,this),o=A()(i=this._cancelEventHandler).call(i,this),a=A()(n=this._cropzonePresetEventHandler).call(n,this);this.eventHandler={apply:r,cancel:o,cropzonePreset:a},this.actions=t,this._els.apply.addEventListener("click",r),this._els.cancel.addEventListener("click",o),this._els.preset.addEventListener("click",a)}},{key:"_removeEvent",value:function(){this._els.apply.removeEventListener("click",this.eventHandler.apply),this._els.cancel.removeEventListener("click",this.eventHandler.cancel),this._els.preset.removeEventListener("click",this.eventHandler.cropzonePreset)}},{key:"_applyEventHandler",value:function(){this.actions.crop(),this._els.apply.classList.remove("active")}},{key:"_cancelEventHandler",value:function(){this.actions.cancel(),this._els.apply.classList.remove("active")}},{key:"_cropzonePresetEventHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button.preset");if(e){var i=Q(e.className.match(/preset-[^\s]+/),1)[0];this._setPresetButtonActive(e),this.actions.preset(i)}}},{key:"changeStartMode",value:function(){this.actions.modeChange("crop")}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode(),this._setPresetButtonActive()}},{key:"changeApplyButtonStatus",value:function(t){t?this._els.apply.classList.add("active"):this._els.apply.classList.remove("active")}},{key:"_setPresetButtonActive",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultPresetButton;H()(this._els.preset.querySelectorAll(".preset"),(function(t){t.classList.remove("active")})),t&&t.classList.add("active")}}]),i}(Un),$n=qn,tr=function(t){var e,i,n,r,o,a,s=t.locale,c=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a='\n <ul class="tui-image-editor-submenu-item">\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-range-wrap tui-image-editor-newline">\n <label class="range">'.concat(s.localize("Width"),'&nbsp;</label>\n <div class="tie-width-range"></div>\n <input class="tie-width-range-value tui-image-editor-range-value" value="0" /> <label>px</label>\n <div class="tui-image-editor-partition tui-image-editor-newline"></div>\n <label class="range">')).call(a,s.localize("Height"),'</label>\n <div class="tie-height-range"></div>\n <input class="tie-height-range-value tui-image-editor-range-value" value="0" /> <label>px</label>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-lock-aspect-ratio">\n <span>')).call(o,s.localize("Lock Aspect Ratio"),'</span>\n </label>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-partition tui-image-editor-newline"></li>\n <li class="tie-resize-button action">\n <div class="tui-image-editor-button apply">\n ')).call(r,c(["normal","active"],"apply"),"\n <label>\n ")).call(n,s.localize("Apply"),'\n </label>\n </div>\n <div class="tui-image-editor-button cancel">\n ')).call(i,c(["normal","active"],"cancel"),"\n <label>\n ")).call(e,s.localize("Cancel"),"\n </label>\n </div>\n </li>\n </ul>\n")};function er(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ir=function(t){wn(i,t);var e=er(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"resize",makeSvgIcon:a,menuBarPosition:s,templateHtml:tr,usageStatistics:c})).status="active",r._lockState=!1,r._originalDimensions=null,r._els={widthRange:new Wn({slider:r.selector(".tie-width-range"),input:r.selector(".tie-width-range-value")},ki),heightRange:new Wn({slider:r.selector(".tie-height-range"),input:r.selector(".tie-height-range-value")},ki),lockAspectRatio:r.selector(".tie-lock-aspect-ratio"),apply:r.selector(".tie-resize-button .apply"),cancel:r.selector(".tie-resize-button .cancel")},r}return T(i,[{key:"changeStartMode",value:function(){this.actions.modeChange("resize");var t=this.actions.getCurrentDimensions();this._originalDimensions=t,this.setWidthValue(t.width),this.setHeightValue(t.height),this.setLimit({minWidth:ki.min,minHeight:ki.min,maxWidth:t.width,maxHeight:t.height})}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode(),this.actions.reset(!0)}},{key:"setLimit",value:function(t){this._els.widthRange.min=this.calcMinValue(t.minWidth),this._els.heightRange.min=this.calcMinValue(t.minHeight),this._els.widthRange.max=this.calcMaxValue(t.maxWidth),this._els.heightRange.max=this.calcMaxValue(t.maxHeight)}},{key:"calcMaxValue",value:function(t){return t<=0&&(t=ki.max),t}},{key:"calcMinValue",value:function(t){return t<=0&&(t=ki.min),t}},{key:"setWidthValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._els.widthRange.value=t,e&&this._els.widthRange.trigger("change")}},{key:"setHeightValue",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._els.heightRange.value=t,e&&this._els.heightRange.trigger("change")}},{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o;this._els.widthRange.on("change",A()(e=this._changeWidthRangeHandler).call(e,this)),this._els.heightRange.on("change",A()(i=this._changeHeightRangeHandler).call(i,this)),this._els.lockAspectRatio.addEventListener("change",A()(n=this._changeLockAspectRatio).call(n,this));var a=A()(r=this._applyEventHandler).call(r,this),s=A()(o=this._cancelEventHandler).call(o,this);this.eventHandler={apply:a,cancel:s},this.actions=t,this._els.apply.addEventListener("click",a),this._els.cancel.addEventListener("click",s)}},{key:"_changeWidthRangeHandler",value:function(t){this.actions.preview("width",Bi(t),this._lockState)}},{key:"_changeHeightRangeHandler",value:function(t){this.actions.preview("height",Bi(t),this._lockState)}},{key:"_changeLockAspectRatio",value:function(t){this._lockState=t.target.checked,this.actions.lockAspectRatio(this._lockState)}},{key:"_removeEvent",value:function(){this._els.apply.removeEventListener("click",this.eventHandler.apply),this._els.cancel.removeEventListener("click",this.eventHandler.cancel)}},{key:"_applyEventHandler",value:function(){this.actions.resize(),this._els.apply.classList.remove("active")}},{key:"_cancelEventHandler",value:function(){this.actions.reset(),this._els.cancel.classList.remove("active")}},{key:"changeApplyButtonStatus",value:function(t){t?this._els.apply.classList.add("active"):this._els.apply.classList.remove("active")}}]),i}(Un),nr=ir,rr=function(t){var e,i,n,r,o,a=t.locale,s=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tie-flip-button tui-image-editor-submenu-item">\n <li>\n <div class="tui-image-editor-button flipX">\n <div>\n '.concat(s(["normal","active"],"flip-x",!0),"\n </div>\n <label>\n ")).call(o,a.localize("Flip X"),'\n </label>\n </div>\n <div class="tui-image-editor-button flipY">\n <div>\n ')).call(r,s(["normal","active"],"flip-y",!0),"\n </div>\n <label>\n ")).call(n,a.localize("Flip Y"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tui-image-editor-button resetFlip">\n <div>\n ')).call(i,s(["normal","active"],"flip-reset",!0),"\n </div>\n <label>\n ")).call(e,a.localize("Reset"),"\n </label>\n </div>\n </li>\n </ul>\n")};function or(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ar=function(t){wn(i,t);var e=or(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"flip",makeSvgIcon:a,menuBarPosition:s,templateHtml:rr,usageStatistics:c})).flipStatus=!1,r._els={flipButton:r.selector(".tie-flip-button")},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e;this.eventHandler.changeFlip=A()(e=this._changeFlip).call(e,this),this._actions=t,this._els.flipButton.addEventListener("click",this.eventHandler.changeFlip)}},{key:"_removeEvent",value:function(){this._els.flipButton.removeEventListener("click",this.eventHandler.changeFlip)}},{key:"_changeFlip",value:function(t){var e=this,i=t.target.closest(".tui-image-editor-button");if(i){var n=this.getButtonType(i,["flipX","flipY","resetFlip"]);if(!this.flipStatus&&"resetFlip"===n)return;this._actions.flip(n).then((function(t){var i=e._els.flipButton.classList;e.flipStatus=!1,i.remove("resetFlip"),H()(["flipX","flipY"],(function(n){i.remove(n),t[n]&&(i.add(n),i.add("resetFlip"),e.flipStatus=!0)}))}))}}}]),i}(Un),sr=ar,cr=function(t){var e,i,n=t.locale,r=t.makeSvgIcon;return O()(e=O()(i='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-rotate-button">\n <div class="tui-image-editor-button clockwise">\n <div>\n '.concat(r(["normal","active"],"rotate-clockwise",!0),'\n </div>\n <label> 30 </label>\n </div>\n <div class="tui-image-editor-button counterclockwise">\n <div>\n ')).call(i,r(["normal","active"],"rotate-counterclockwise",!0),'\n </div>\n <label> -30 </label>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,n.localize("Range"),'</label>\n <div class="tie-rotate-range"></div>\n <input class="tie-rotate-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function lr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ur=function(t){wn(i,t);var e=lr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"rotate",makeSvgIcon:a,menuBarPosition:s,templateHtml:cr,usageStatistics:c}))._value=0,r._els={rotateButton:r.selector(".tie-rotate-button"),rotateRange:new Wn({slider:r.selector(".tie-rotate-range"),input:r.selector(".tie-rotate-range-value")},yi)},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.rotateRange.destroy(),Wi(this)}},{key:"setRangeBarAngle",value:function(t,e){var i=e;"rotate"===t&&(i=$()(this._els.rotateRange.value,10)+e),this._setRangeBarRatio(i)}},{key:"_setRangeBarRatio",value:function(t){this._els.rotateRange.value=t}},{key:"addEvent",value:function(t){var e,i;this.eventHandler.rotationAngleChanged=A()(e=this._changeRotateForButton).call(e,this),this.actions=t,this._els.rotateButton.addEventListener("click",this.eventHandler.rotationAngleChanged),this._els.rotateRange.on("change",A()(i=this._changeRotateForRange).call(i,this))}},{key:"_removeEvent",value:function(){this._els.rotateButton.removeEventListener("click",this.eventHandler.rotationAngleChanged),this._els.rotateRange.off()}},{key:"_changeRotateForRange",value:function(t,e){var i=Bi(t);this.actions.setAngle(i,!e),this._value=i}},{key:"_changeRotateForButton",value:function(t){var e=t.target.closest(".tui-image-editor-button"),i=this._els.rotateRange.value;if(e){var n={clockwise:30,counterclockwise:-30}[this.getButtonType(e,["counterclockwise","clockwise"])],r=$()(i,10)+n;r>=-360&&r<=360&&this.actions.rotate(n)}}}]),i}(Un),hr=ur,fr=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d=t.locale,v=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-text-effect-button">\n <div class="tui-image-editor-button bold">\n <div>\n '.concat(v(["normal","active"],"text-bold",!0),"\n </div>\n <label> ")).call(g,d.localize("Bold"),' </label>\n </div>\n <div class="tui-image-editor-button italic">\n <div>\n ')).call(f,v(["normal","active"],"text-italic",!0),"\n </div>\n <label> ")).call(h,d.localize("Italic"),' </label>\n </div>\n <div class="tui-image-editor-button underline">\n <div>\n ')).call(u,v(["normal","active"],"text-underline",!0),"\n </div>\n <label> ")).call(l,d.localize("Underline"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-text-align-button">\n <div class="tui-image-editor-button left">\n <div>\n ')).call(c,v(["normal","active"],"text-align-left",!0),"\n </div>\n <label> ")).call(s,d.localize("Left"),' </label>\n </div>\n <div class="tui-image-editor-button center">\n <div>\n ')).call(a,v(["normal","active"],"text-align-center",!0),"\n </div>\n <label> ")).call(o,d.localize("Center"),' </label>\n </div>\n <div class="tui-image-editor-button right">\n <div>\n ')).call(r,v(["normal","active"],"text-align-right",!0),"\n </div>\n <label> ")).call(n,d.localize("Right"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-text-color" title="')).call(i,d.localize("Color"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,d.localize("Text size"),'</label>\n <div class="tie-text-range"></div>\n <input class="tie-text-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function gr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var dr=function(t){wn(i,t);var e=gr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"text",makeSvgIcon:a,menuBarPosition:s,templateHtml:fr,usageStatistics:c})).effect={bold:!1,italic:!1,underline:!1},r.align="tie-text-align-left",r._els={textEffectButton:r.selector(".tie-text-effect-button"),textAlignButton:r.selector(".tie-text-align-button"),textColorpicker:new Rn(r.selector(".tie-text-color"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),textRange:new Wn({slider:r.selector(".tie-text-range"),input:r.selector(".tie-text-range-value")},Ci)},r.colorPickerInputBox=r._els.textColorpicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.textColorpicker.destroy(),this._els.textRange.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a,s=A()(e=this._setTextEffectHandler).call(e,this),c=A()(i=this._setTextAlignHandler).call(i,this);this.eventHandler={setTextEffect:s,setTextAlign:c},this.actions=t,this._els.textEffectButton.addEventListener("click",s),this._els.textAlignButton.addEventListener("click",c),this._els.textRange.on("change",A()(n=this._changeTextRnageHandler).call(n,this)),this._els.textColorpicker.on("change",A()(r=this._changeColorHandler).call(r,this)),this.colorPickerInputBox.addEventListener(Ie,A()(o=this._onStartEditingInputBox).call(o,this)),this.colorPickerInputBox.addEventListener(_e,A()(a=this._onStopEditingInputBox).call(a,this))}},{key:"_removeEvent",value:function(){var t,e,i=this.eventHandler,n=i.setTextEffect,r=i.setTextAlign;this._els.textEffectButton.removeEventListener("click",n),this._els.textAlignButton.removeEventListener("click",r),this._els.textRange.off(),this._els.textColorpicker.off(),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"changeStandbyMode",value:function(){this.actions.stopDrawingMode()}},{key:"changeStartMode",value:function(){this.actions.modeChange("text")}},{key:"textColor",get:function(){return this._els.textColorpicker.color},set:function(t){this._els.textColorpicker.color=t}},{key:"fontSize",get:function(){return this._els.textRange.value},set:function(t){this._els.textRange.value=t}},{key:"fontStyle",get:function(){return this.effect.italic?"italic":"normal"}},{key:"fontWeight",get:function(){return this.effect.bold?"bold":"normal"}},{key:"underline",get:function(){return this.effect.underline}},{key:"setTextStyleStateOnAction",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=nt()(t),i=t.fontSize,n=t.fontStyle,r=t.fontWeight,o=t.textDecoration,a=t.textAlign;this.textColor=e,this.fontSize=i,this.setEffectState("italic",n),this.setEffectState("bold",r),this.setEffectState("underline",o),this.setAlignState("tie-text-align-".concat(a))}},{key:"setEffectState",value:function(t,e){var i="italic"===e||"bold"===e||"underline"===e,n=this._els.textEffectButton.querySelector(".tui-image-editor-button.".concat(t));this.effect[t]=i,n.classList[i?"add":"remove"]("active")}},{key:"setAlignState",value:function(t){var e=this._els.textAlignButton;e.classList.remove(this.align),e.classList.add(t),this.align=t}},{key:"_setTextEffectHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=Q(e.className.match(/(bold|italic|underline)/),1)[0],n={bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},underline:{textDecoration:"underline"}}[i];this.effect[i]=!this.effect[i],e.classList.toggle("active"),this.actions.changeTextStyle(n)}}},{key:"_setTextAlignHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=this.getButtonType(e,["left","center","right"]),n="tie-text-align-".concat(i);t.currentTarget.classList.remove(this.align),this.align!==n&&t.currentTarget.classList.add(n),this.actions.changeTextStyle({textAlign:i}),this.align=n}}},{key:"_changeTextRnageHandler",value:function(t,e){this.actions.changeTextStyle({fontSize:t},!e)}},{key:"_changeColorHandler",value:function(t){t=t||"transparent",this.actions.changeTextStyle({fill:t})}}]),i}(Un),vr=dr,pr=function(t){var e,i,n,r=t.locale,o=t.makeSvgIcon;return O()(e=O()(i=O()(n='\n <ul class="tui-image-editor-submenu-item">\n <li>\n <div class="tui-image-editor-button">\n <div>\n <input type="file" accept="image/*" class="tie-mask-image-file">\n '.concat(o(["normal","active"],"mask-load",!0),"\n </div>\n <label> ")).call(n,r.localize("Load Mask Image"),' </label>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tie-mask-apply tui-image-editor-newline apply" style="margin-top: 22px;margin-bottom: 5px">\n <div class="tui-image-editor-button apply">\n ')).call(i,o(["normal","active"],"apply"),"\n <label>\n ")).call(e,r.localize("Apply"),"\n </label>\n </div>\n </li>\n </ul>\n")};function mr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var yr=function(t){wn(i,t);var e=mr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"mask",makeSvgIcon:a,menuBarPosition:s,templateHtml:pr,usageStatistics:c}))._els={applyButton:r.selector(".tie-mask-apply"),maskImageButton:r.selector(".tie-mask-image-file")},r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n=A()(e=this._loadMaskFile).call(e,this),r=A()(i=this._applyMask).call(i,this);this.eventHandler={loadMaskFile:n,applyMask:r},this.actions=t,this._els.maskImageButton.addEventListener("change",n),this._els.applyButton.addEventListener("click",r)}},{key:"_removeEvent",value:function(){this._els.maskImageButton.removeEventListener("change",this.eventHandler.loadMaskFile),this._els.applyButton.removeEventListener("click",this.eventHandler.applyMask)}},{key:"_applyMask",value:function(){this.actions.applyFilter(),this._els.applyButton.classList.remove("active")}},{key:"_loadMaskFile",value:function(t){var e;Fi()||alert("This browser does not support file-api");var i=Q(t.target.files,1)[0];i&&(e=P().createObjectURL(i),this.actions.loadImageFromURL(e,i),this._els.applyButton.classList.add("active"))}}]),i}(Un),br=yr,xr=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y,b,x,C=t.locale,I=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p=O()(m=O()(y=O()(b=O()(x='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-icon-add-button">\n <div class="tui-image-editor-button" data-icontype="icon-arrow">\n <div>\n '.concat(I(["normal","active"],"icon-arrow",!0),"\n </div>\n <label>\n ")).call(x,C.localize("Arrow"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-arrow-2">\n <div>\n ')).call(b,I(["normal","active"],"icon-arrow-2",!0),"\n </div>\n <label>\n ")).call(y,C.localize("Arrow-2"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-arrow-3">\n <div>\n ')).call(m,I(["normal","active"],"icon-arrow-3",!0),"\n </div>\n <label>\n ")).call(p,C.localize("Arrow-3"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-star">\n <div>\n ')).call(v,I(["normal","active"],"icon-star",!0),"\n </div>\n <label>\n ")).call(d,C.localize("Star-1"),'\n </label>\n </div>\n <div class="tui-image-editor-button" data-icontype="icon-star-2">\n <div>\n ')).call(g,I(["normal","active"],"icon-star-2",!0),"\n </div>\n <label>\n ")).call(f,C.localize("Star-2"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-polygon">\n <div>\n ')).call(h,I(["normal","active"],"icon-polygon",!0),"\n </div>\n <label>\n ")).call(u,C.localize("Polygon"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-location">\n <div>\n ')).call(l,I(["normal","active"],"icon-location",!0),"\n </div>\n <label>\n ")).call(c,C.localize("Location"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-heart">\n <div>\n ')).call(s,I(["normal","active"],"icon-heart",!0),"\n </div>\n <label>\n ")).call(a,C.localize("Heart"),'\n </label>\n </div>\n\n <div class="tui-image-editor-button" data-icontype="icon-bubble">\n <div>\n ')).call(o,I(["normal","active"],"icon-bubble",!0),"\n </div>\n <label>\n ")).call(r,C.localize("Bubble"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tie-icon-add-button">\n <div class="tui-image-editor-button" style="margin:0">\n <div>\n <input type="file" accept="image/*" class="tie-icon-image-file">\n ')).call(n,I(["normal","active"],"icon-load",!0),"\n </div>\n <label>\n ")).call(i,C.localize("Custom icon"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-icon-color" title="')).call(e,C.localize("Color"),'"></div>\n </li>\n </ul>\n')};function Cr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ir=function(t){wn(i,t);var e=Cr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"icon",makeSvgIcon:a,menuBarPosition:s,templateHtml:xr,usageStatistics:c})).iconType=null,r._iconMap={},r._els={registerIconButton:r.selector(".tie-icon-image-file"),addIconButton:r.selector(".tie-icon-add-button"),iconColorpicker:new Rn(r.selector(".tie-icon-color"),{defaultColor:"#ffbb3b",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics})},r.colorPickerInputBox=r._els.iconColorpicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.iconColorpicker.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o,a=A()(e=this._registerIconHandler).call(e,this),s=A()(i=this._addIconHandler).call(i,this);this.eventHandler={registerIcon:a,addIcon:s},this.actions=t,this._els.iconColorpicker.on("change",A()(n=this._changeColorHandler).call(n,this)),this._els.registerIconButton.addEventListener("change",a),this._els.addIconButton.addEventListener("click",s),this.colorPickerInputBox.addEventListener(Ie,A()(r=this._onStartEditingInputBox).call(r,this)),this.colorPickerInputBox.addEventListener(_e,A()(o=this._onStopEditingInputBox).call(o,this))}},{key:"_removeEvent",value:function(){var t,e;this._els.iconColorpicker.off(),this._els.registerIconButton.removeEventListener("change",this.eventHandler.registerIcon),this._els.addIconButton.removeEventListener("click",this.eventHandler.addIcon),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"clearIconType",value:function(){this._els.addIconButton.classList.remove(this.iconType),this.iconType=null}},{key:"registerDefaultIcon",value:function(){var t=this;H()(mi,(function(e,i){t.actions.registerDefaultIcons(i,e)}))}},{key:"setIconPickerColor",value:function(t){this._els.iconColorpicker.color=t}},{key:"changeStandbyMode",value:function(){this.clearIconType(),this.actions.cancelAddIcon()}},{key:"_changeColorHandler",value:function(t){t=t||"transparent",this.actions.changeColor(t)}},{key:"_addIconHandler",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=e.getAttribute("data-icontype"),n=this._els.iconColorpicker.color;this.actions.discardSelection(),this.actions.changeSelectableAll(!1),this._els.addIconButton.classList.remove(this.iconType),this._els.addIconButton.classList.add(i),this.iconType===i?this.changeStandbyMode():(this.actions.addIcon(i,n),this.iconType=i)}}},{key:"_registerIconHandler",value:function(t){var e;Fi||alert("This browser does not support file-api");var i=Q(t.target.files,1)[0];i&&(e=P().createObjectURL(i),this.actions.registerCustomIcon(e,i))}}]),i}(Un),_r=Ir,Mr=function(t){var e,i,n,r,o,a=t.locale,s=t.makeSvgIcon;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tui-image-editor-submenu-item">\n <li class="tie-draw-line-select-button">\n <div class="tui-image-editor-button free">\n <div>\n '.concat(s(["normal","active"],"draw-free",!0),"\n </div>\n <label>\n ")).call(o,a.localize("Free"),'\n </label>\n </div>\n <div class="tui-image-editor-button line">\n <div>\n ')).call(r,s(["normal","active"],"draw-line",!0),"\n </div>\n <label>\n ")).call(n,a.localize("Straight"),'\n </label>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="tie-draw-color" title="')).call(i,a.localize("Color"),'"></div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-newline tui-image-editor-range-wrap">\n <label class="range">')).call(e,a.localize("Range"),'</label>\n <div class="tie-draw-range"></div>\n <input class="tie-draw-range-value tui-image-editor-range-value" value="0" />\n </li>\n </ul>\n')};function Sr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var wr=function(t){wn(i,t);var e=Sr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon,s=n.menuBarPosition,c=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"draw",makeSvgIcon:a,menuBarPosition:s,templateHtml:Mr,usageStatistics:c}))._els={lineSelectButton:r.selector(".tie-draw-line-select-button"),drawColorPicker:new Rn(r.selector(".tie-draw-color"),{defaultColor:"#00a9ff",toggleDirection:r.toggleDirection,usageStatistics:r.usageStatistics}),drawRange:new Wn({slider:r.selector(".tie-draw-range"),input:r.selector(".tie-draw-range-value")},bi)},r.type=null,r.color=r._els.drawColorPicker.color,r.width=r._els.drawRange.value,r.colorPickerInputBox=r._els.drawColorPicker.colorpickerElement.querySelector(Me),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._els.drawColorPicker.destroy(),this._els.drawRange.destroy(),Wi(this)}},{key:"addEvent",value:function(t){var e,i,n,r,o;this.eventHandler.changeDrawType=A()(e=this._changeDrawType).call(e,this),this.actions=t,this._els.lineSelectButton.addEventListener("click",this.eventHandler.changeDrawType),this._els.drawColorPicker.on("change",A()(i=this._changeDrawColor).call(i,this)),this._els.drawRange.on("change",A()(n=this._changeDrawRange).call(n,this)),this.colorPickerInputBox.addEventListener(Ie,A()(r=this._onStartEditingInputBox).call(r,this)),this.colorPickerInputBox.addEventListener(_e,A()(o=this._onStopEditingInputBox).call(o,this))}},{key:"_removeEvent",value:function(){var t,e;this._els.lineSelectButton.removeEventListener("click",this.eventHandler.changeDrawType),this._els.drawColorPicker.off(),this._els.drawRange.off(),this.colorPickerInputBox.removeEventListener(Ie,A()(t=this._onStartEditingInputBox).call(t,this)),this.colorPickerInputBox.removeEventListener(_e,A()(e=this._onStopEditingInputBox).call(e,this))}},{key:"setDrawMode",value:function(){this.actions.setDrawMode(this.type,{width:this.width,color:Yi(this.color,.7)})}},{key:"changeStandbyMode",value:function(){this.type=null,this.actions.stopDrawingMode(),this.actions.changeSelectableAll(!0),this._els.lineSelectButton.classList.remove("free"),this._els.lineSelectButton.classList.remove("line")}},{key:"changeStartMode",value:function(){this.type="free",this._els.lineSelectButton.classList.add("free"),this.setDrawMode()}},{key:"_changeDrawType",value:function(t){var e=t.target.closest(".tui-image-editor-button");if(e){var i=this.getButtonType(e,["free","line"]);if(this.actions.discardSelection(),this.type===i)return void this.changeStandbyMode();this.changeStandbyMode(),this.type=i,this._els.lineSelectButton.classList.add(i),this.setDrawMode()}}},{key:"_changeDrawColor",value:function(t){this.color=t||"transparent",this.type?this.setDrawMode():this.changeStartMode()}},{key:"_changeDrawRange",value:function(t){this.width=t,this.type?this.setDrawMode():this.changeStartMode()}}]),i}(Un),kr=wr,Tr=n(7065),Dr=n.n(Tr),Ar=function(t){var e,i,n,r,o,a,s,c,l,u,h,f,g,d,v,p,m=t.locale;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c=O()(l=O()(u=O()(h=O()(f=O()(g=O()(d=O()(v=O()(p='\n <ul class="tui-image-editor-submenu-item">\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-wrap fixed-width">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-grayscale">\n <span>'.concat(m.localize("Grayscale"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-invert">\n <span>')).call(p,m.localize("Invert"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-sepia">\n <span>')).call(v,m.localize("Sepia"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-vintage">\n <span>')).call(d,m.localize("Sepia2"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-blur">\n <span>')).call(g,m.localize("Blur"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-sharpen">\n <span>')).call(f,m.localize("Sharpen"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-emboss">\n <span>')).call(h,m.localize("Emboss"),'</span>\n </label>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled" style="margin-bottom: 7px;">\n <div class="tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-remove-white">\n <span>')).call(u,m.localize("Remove White"),'</span>\n </label>\n </div>\n </div>\n <div class="tui-image-editor-newline tui-image-editor-range-wrap short">\n <label>')).call(l,m.localize("Distance"),'</label>\n <div class="tie-removewhite-distance-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-brightness">\n <span>')).call(c,m.localize("Brightness"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-brightness-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-noise">\n <span>')).call(s,m.localize("Noise"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-noise-range"></div>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition only-left-right">\n <div></div>\n </li>\n <li class="tui-image-editor-submenu-align">\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-pixelate">\n <span>')).call(a,m.localize("Pixelate"),'</span>\n </label>\n </div>\n <div class="tui-image-editor-range-wrap short">\n <div class="tie-pixelate-range"></div>\n </div>\n </div>\n <div class="tui-image-editor-checkbox-group tui-image-editor-disabled">\n <div class="tui-image-editor-newline tui-image-editor-checkbox-wrap">\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-color-filter">\n <span>')).call(o,m.localize("Color Filter"),'</span>\n </label>\n </div>\n </div>\n <div class="tui-image-editor-newline tui-image-editor-range-wrap short">\n <label>')).call(r,m.localize("Threshold"),'</label>\n <div class="tie-colorfilter-threshold-range"></div>\n </div>\n </div>\n </li>\n <li class="tui-image-editor-partition">\n <div></div>\n </li>\n <li>\n <div class="filter-color-item">\n <div class="tie-filter-tint-color" title="')).call(n,m.localize("Tint"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-tint">\n <span></span>\n </label>\n </div>\n </div>\n <div class="filter-color-item">\n <div class="tie-filter-multiply-color" title="')).call(i,m.localize("Multiply"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-multiply">\n <span></span>\n </label>\n </div>\n </div>\n <div class="filter-color-item">\n <div class="tie-filter-blend-color" title="')).call(e,m.localize("Blend"),'"></div>\n <div class="tui-image-editor-checkbox">\n <label>\n <input type="checkbox" class="tie-blend">\n <span></span>\n </label>\n </div>\n </div>\n </li>\n </ul>\n')};function jr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Or="130px",Er=["add","diff","subtract","multiply","screen","lighten","darken"],Lr=["grayscale","invert","sepia","vintage","blur","sharpen","emboss","remove-white","brightness","noise","pixelate","color-filter","tint","multiply","blend"],Nr={grayscale:"grayscale",invert:"invert",sepia:"sepia",blur:"blur",sharpen:"sharpen",emboss:"emboss",removeWhite:"removeColor",brightness:"brightness",contrast:"contrast",saturation:"saturation",vintage:"vintage",polaroid:"polaroid",noise:"noise",pixelate:"pixelate",colorFilter:"removeColor",tint:"blendColor",multiply:"blendColor",blend:"blendColor",hue:"hue",gamma:"gamma"},Pr=["removewhiteDistanceRange","colorfilterThresholdRange","pixelateRange","noiseRange","brightnessRange","tintOpacity"],zr=["filterBlendColor","filterMultiplyColor","filterTintColor"],Br=function(t){wn(i,t);var e=jr(i);function i(t,n){var r,o=n.locale,a=n.menuBarPosition,s=n.usageStatistics;return w(this,i),(r=e.call(this,t,{locale:o,name:"filter",menuBarPosition:a,templateHtml:Ar,usageStatistics:s})).selectBoxShow=!1,r.checkedMap={},r._makeControlElement(),r}return T(i,[{key:"destroy",value:function(){this._removeEvent(),this._destroyToolInstance(),Wi(this)}},{key:"_removeEvent",value:function(){var t,e=this;H()(Lr,(function(t){var i=e.selector(".tie-".concat(t)),n=Ri(t);i.removeEventListener("change",e.eventHandler[n])})),H()(O()(t=[]).call(t,Pr,zr),(function(t){e._els[t].off()})),this._els.blendType.removeEventListener("change",this.eventHandler.changeBlendFilter),this._els.blendType.removeEventListener("click",this.eventHandler.changeBlendFilter),Ln()(this.colorPickerInputBoxes,(function(t){var i,n;t.removeEventListener(Ie,A()(i=e._onStartEditingInputBox).call(i,e)),t.removeEventListener(_e,A()(n=e._onStopEditingInputBox).call(n,e))}),this)}},{key:"_destroyToolInstance",value:function(){var t,e=this;H()(O()(t=[]).call(t,Pr,zr),(function(t){e._els[t].destroy()}))}},{key:"addEvent",value:function(t){var e,i,n,r=this,o=t.applyFilter,a=function(t){var e;return A()(e=r._changeFilterState).call(e,r,o,t)},s=function(t){return function(e,i){return r._changeFilterState(o,t,i)}};this.eventHandler={changeBlendFilter:a("blend"),blandTypeClick:function(t){return t.stopPropagation()}},H()(Lr,(function(t){var e=r.selector(".tie-".concat(t)),i=Ri(t);r.checkedMap[i]=e,r.eventHandler[i]=a(i),e.addEventListener("change",r.eventHandler[i])})),this._els.removewhiteDistanceRange.on("change",s("removeWhite")),this._els.colorfilterThresholdRange.on("change",s("colorFilter")),this._els.pixelateRange.on("change",s("pixelate")),this._els.noiseRange.on("change",s("noise")),this._els.brightnessRange.on("change",s("brightness")),this._els.filterBlendColor.on("change",this.eventHandler.changeBlendFilter),this._els.filterMultiplyColor.on("change",a("multiply")),this._els.filterTintColor.on("change",a("tint")),this._els.tintOpacity.on("change",s("tint")),this._els.filterMultiplyColor.on("changeShow",A()(e=this.colorPickerChangeShow).call(e,this)),this._els.filterTintColor.on("changeShow",A()(i=this.colorPickerChangeShow).call(i,this)),this._els.filterBlendColor.on("changeShow",A()(n=this.colorPickerChangeShow).call(n,this)),this._els.blendType.addEventListener("change",this.eventHandler.changeBlendFilter),this._els.blendType.addEventListener("click",this.eventHandler.blandTypeClick),Ln()(this.colorPickerInputBoxes,(function(t){var e,i;t.addEventListener(Ie,A()(e=r._onStartEditingInputBox).call(e,r)),t.addEventListener(_e,A()(i=r._onStopEditingInputBox).call(i,r))}),this)}},{key:"setFilterState",value:function(t){var e=t.type,i=t.options,n=t.action,r=this._getFilterNameFromOptions(e,i),o="remove"===n;o||this._setFilterState(r,i),this.checkedMap[r].checked=!o}},{key:"initFilterCheckBoxState",value:function(){H()(this.checkedMap,(function(t){t.checked=!1}),this)}},{key:"_setFilterState",value:function(t,e){"colorFilter"===t?this._els.colorfilterThresholdRange.value=e.distance:"removeWhite"===t?this._els.removewhiteDistanceRange.value=e.distance:"pixelate"===t?this._els.pixelateRange.value=e.blocksize:"brightness"===t?this._els.brightnessRange.value=e.brightness:"noise"===t?this._els.noiseRange.value=e.noise:"tint"===t?(this._els.tintOpacity.value=e.alpha,this._els.filterTintColor.color=e.color):"blend"===t?this._els.filterBlendColor.color=e.color:"multiply"===t&&(this._els.filterMultiplyColor.color=e.color)}},{key:"_getFilterNameFromOptions",value:function(t,e){var i=t;return"removeColor"===t?i=Dr()(e.useAlpha)?"removeWhite":"colorFilter":"blendColor"===t&&(i={add:"blend",multiply:"multiply",tint:"tint"}[e.mode]),i}},{key:"_changeFilterState",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.checkedMap[e].checked,r=Nr[e],o=this.checkedMap[e].closest(".tui-image-editor-checkbox-group");o&&(n?o.classList.remove("tui-image-editor-disabled"):o.classList.add("tui-image-editor-disabled")),t(n,r,this._getFilterOption(e),!i)}},{key:"_getFilterOption",value:function(t){var e={};switch(t){case"removeWhite":e.color="#FFFFFF",e.useAlpha=!1,e.distance=dn()(this._els.removewhiteDistanceRange.value);break;case"colorFilter":e.color="#FFFFFF",e.distance=dn()(this._els.colorfilterThresholdRange.value);break;case"pixelate":e.blocksize=Bi(this._els.pixelateRange.value);break;case"noise":e.noise=Bi(this._els.noiseRange.value);break;case"brightness":e.brightness=dn()(this._els.brightnessRange.value);break;case"blend":e.mode="add",e.color=this._els.filterBlendColor.color,e.mode=this._els.blendType.value;break;case"multiply":e.mode="multiply",e.color=this._els.filterMultiplyColor.color;break;case"tint":e.mode="tint",e.color=this._els.filterTintColor.color,e.alpha=this._els.tintOpacity.value;break;case"blur":e.blur=this._els.blurRange.value}return e}},{key:"_makeControlElement",value:function(){this._els={removewhiteDistanceRange:new Wn({slider:this.selector(".tie-removewhite-distance-range")},Ii.removewhiteDistanceRange),brightnessRange:new Wn({slider:this.selector(".tie-brightness-range")},Ii.brightnessRange),noiseRange:new Wn({slider:this.selector(".tie-noise-range")},Ii.noiseRange),pixelateRange:new Wn({slider:this.selector(".tie-pixelate-range")},Ii.pixelateRange),colorfilterThresholdRange:new Wn({slider:this.selector(".tie-colorfilter-threshold-range")},Ii.colorfilterThresholdRange),filterTintColor:new Rn(this.selector(".tie-filter-tint-color"),{defaultColor:"#03bd9e",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),filterMultiplyColor:new Rn(this.selector(".tie-filter-multiply-color"),{defaultColor:"#515ce6",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),filterBlendColor:new Rn(this.selector(".tie-filter-blend-color"),{defaultColor:"#ffbb3b",toggleDirection:this.toggleDirection,usageStatistics:this.usageStatistics}),blurRange:Ii.blurFilterRange},this._els.tintOpacity=this._pickerWithRange(this._els.filterTintColor.pickerControl),this._els.blendType=this._pickerWithSelectbox(this._els.filterBlendColor.pickerControl),this.colorPickerControls.push(this._els.filterTintColor),this.colorPickerControls.push(this._els.filterMultiplyColor),this.colorPickerControls.push(this._els.filterBlendColor),this.colorPickerInputBoxes=[],this.colorPickerInputBoxes.push(this._els.filterTintColor.colorpickerElement.querySelector(Me)),this.colorPickerInputBoxes.push(this._els.filterMultiplyColor.colorpickerElement.querySelector(Me)),this.colorPickerInputBoxes.push(this._els.filterBlendColor.colorpickerElement.querySelector(Me))}},{key:"_pickerWithRange",value:function(t){var e=document.createElement("div"),i=document.createElement("label"),n=document.createElement("div");return n.id="tie-filter-tint-opacity",i.innerHTML="Opacity",e.appendChild(i),e.appendChild(n),t.appendChild(e),t.style.height=Or,new Wn({slider:n},Ii.tintOpacityRange)}},{key:"_pickerWithSelectbox",value:function(t){var e=document.createElement("div"),i=document.createElement("select"),n=document.createElement("ul");return e.className="tui-image-editor-selectlist-wrap",n.className="tui-image-editor-selectlist",e.appendChild(i),e.appendChild(n),this._makeSelectOptionList(i),t.appendChild(e),t.style.height=Or,this._drawSelectOptionList(i,n),this._pickerWithSelectboxForAddEvent(i,n),i}},{key:"_drawSelectOptionList",value:function(t,e){var i=t.querySelectorAll("option");H()(i,(function(t){var i=document.createElement("li");i.innerHTML=t.innerHTML,i.setAttribute("data-item",t.value),e.appendChild(i)}))}},{key:"_pickerWithSelectboxForAddEvent",value:function(t,e){var i=this;e.addEventListener("click",(function(n){var r=n.target.getAttribute("data-item"),o=document.createEvent("HTMLEvents");t.querySelector('[value="'.concat(r,'"]')).selected=!0,o.initEvent("change",!0,!0),t.dispatchEvent(o),i.selectBoxShow=!1,e.style.display="none"})),t.addEventListener("mousedown",(function(n){n.preventDefault(),i.selectBoxShow=!i.selectBoxShow,e.style.display=i.selectBoxShow?"block":"none",e.setAttribute("data-selectitem",t.value),e.querySelector("[data-item='".concat(t.value,"']")).classList.add("active")}))}},{key:"_makeSelectOptionList",value:function(t){H()(Er,(function(e){var i=document.createElement("option");i.setAttribute("value",e),i.innerHTML=e.replace(/^[a-z]/,(function(t){return t.toUpperCase()})),t.appendChild(i)}))}}]),i}(Un),Rr=Br,Fr=n(4383),Yr=n.n(Fr);function Wr(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Hr="selected-item",Ur="disabled-item",Gr=function(t){wn(i,t);var e=Wr(i);function i(t,n){var r,o=n.locale,a=n.makeSvgIcon;return w(this,i),r=e.call(this,t,{name:"history"}),t.classList.add("enabled"),r.locale=o,r.makeSvgIcon=a,r._eventHandler={},r._historyIndex=r.getListLength(),r}return T(i,[{key:"add",value:function(t){var e=t.name,i=t.detail;this._hasDisabledItem()&&this.deleteListItemElement(this._historyIndex+1,this.getListLength());var n=function(t){var e,i,n,r=t.locale,o=t.makeSvgIcon,a=t.name,s=t.detail;return O()(e=O()(i=O()(n='\n <div class="tui-image-editor-history-item history">\n <div class="history-item-icon">\n '.concat(o(["normal","active"],"history-".concat(a.toLowerCase()),!0),"\n </div>\n <span>\n ")).call(n,r.localize(a),"\n ")).call(i,s?"(".concat(r.localize(s),")"):"",'\n </span>\n <div class="history-item-checkbox">\n ')).call(e,o(["normal"],"history-check",!0),"\n </div>\n </div>\n")}({locale:this.locale,makeSvgIcon:this.makeSvgIcon,name:e,detail:i}),r=this.makeListItemElement(n);this.pushListItemElement(r),this._historyIndex=this.getListLength()-1,this._selectItem(this._historyIndex)}},{key:"init",value:function(){this.deleteListItemElement(1,this.getListLength()),this._historyIndex=0,this._selectItem(this._historyIndex)}},{key:"clear",value:function(){this.deleteListItemElement(0,this.getListLength()),this._historyIndex=-1}},{key:"prev",value:function(){this._historyIndex-=1,this._selectItem(this._historyIndex)}},{key:"next",value:function(){this._historyIndex+=1,this._selectItem(this._historyIndex)}},{key:"_hasDisabledItem",value:function(){return this.getListLength()-1>this._historyIndex}},{key:"_addHistoryEventListener",value:function(){var t=this;this._eventHandler.history=function(e){return t._clickHistoryItem(e)},this.listElement.addEventListener("click",this._eventHandler.history)}},{key:"_removeHistoryEventListener",value:function(){this.listElement.removeEventListener("click",this._eventHandler.history)}},{key:"_clickHistoryItem",value:function(t){var e=t.target.closest(".".concat("history-item"));if(e){var i=Yr()(e.getAttribute("data-index"),10);if(i!==this._historyIndex){var n=Math.abs(i-this._historyIndex);i<this._historyIndex?this._actions.undo(n):this._actions.redo(n)}}}},{key:"_selectItem",value:function(t){for(var e=0;e<this.getListLength();e+=1)this.removeClass(e,Hr),this.removeClass(e,Ur),e>t&&this.addClass(e,Ur);this.addClass(t,Hr)}},{key:"destroy",value:function(){this.removeEvent(),Wi(this)}},{key:"addEvent",value:function(t){this._actions=t,this._addHistoryEventListener()}},{key:"removeEvent",value:function(){this._removeHistoryEventListener()}}]),i}(function(){function t(e,i){var n=i.name;w(this,t),this.name=n,this.items=[],this.panelElement=this._makePanelElement(),this.listElement=this._makeListElement(),this.panelElement.appendChild(this.listElement),e.appendChild(this.panelElement)}return T(t,[{key:"_makePanelElement",value:function(){var t=document.createElement("div");return t.className="tie-panel-".concat(this.name),t}},{key:"_makeListElement",value:function(){var t=document.createElement("ol");return t.className="".concat(this.name,"-list"),t}},{key:"makeListItemElement",value:function(t){var e=document.createElement("li");return e.innerHTML=t,e.className="".concat(this.name,"-item"),e.setAttribute("data-index",this.items.length),e}},{key:"pushListItemElement",value:function(t){this.listElement.appendChild(t),this.listElement.scrollTop+=t.offsetHeight,this.items.push(t)}},{key:"deleteListItemElement",value:function(t,e){for(var i=this.items,n=t;n<e;n+=1)this.listElement.removeChild(i[n]);s()(i).call(i,t,e-t+1)}},{key:"getListLength",value:function(){return this.items.length}},{key:"addClass",value:function(t,e){this.items[t]&&this.items[t].classList.add(e)}},{key:"removeClass",value:function(t,e){this.items[t]&&this.items[t].classList.remove(e)}},{key:"toggleClass",value:function(t,e){this.items[t]&&this.items[t].classList.toggle(e)}}]),t}()),Xr=Gr,Zr=function(){function t(e){w(this,t),this._locale=e}return T(t,[{key:"localize",value:function(t){return this._locale[t]||t}}]),t}(),Vr=Zr,Jr={Shape:Jn,Crop:$n,Resize:nr,Flip:sr,Rotate:hr,Text:vr,Mask:br,Icon:_r,Draw:kr,Filter:Rr},Qr="1300",Kr="on",qr="zoomIn",$r="hand",to=function(){function t(e,i,n){w(this,t),this.options=this._initializeOption(i),this._actions=n,this.submenu=!1,this.imageSize={},this.uiSize={},this._locale=new Vr(this.options.locale),this.theme=new xn(this.options.theme),this.eventHandler={},this._submenuChangeTransection=!1,this._selectedElement=null,this._mainElement=null,this._editorElementWrap=null,this._editorElement=null,this._menuBarElement=null,this._subMenuElement=null,this._makeUiElement(e),this._setUiSize(),this._initMenuEvent=!1,this._makeSubMenu(),this._attachHistoryEvent(),this._attachZoomEvent()}return T(t,[{key:"destroy",value:function(){this._removeUiEvent(),this._destroyAllMenu(),this._selectedElement.innerHTML="",Wi(this)}},{key:"setUiDefaultSelectionStyle",value:function(t){return R()({applyCropSelectionStyle:!0,applyGroupSelectionStyle:!0,selectionStyle:{cornerStyle:"circle",cornerSize:16,cornerColor:"#fff",cornerStrokeColor:"#fff",transparentCorners:!1,lineWidth:2,borderColor:"#fff"}},t)}},{key:"resizeEditor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.uiSize,i=t.imageSize,n=void 0===i?this.imageSize:i;n!==this.imageSize&&(this.imageSize=n),e&&this._setUiSize(e);var r=this._getCanvasMaxDimension(),o=r.width,a=r.height,s=this._editorElement.style,c=this.options.menuBarPosition;s.height="".concat(a,"px"),s.width="".concat(o,"px"),this._setEditorPosition(c),this._editorElementWrap.style.bottom="0px",this._editorElementWrap.style.top="0px",this._editorElementWrap.style.left="0px",this._editorElementWrap.style.width="100%";var l=this._selectedElement.classList;"top"===c&&this._selectedElement.offsetWidth<Qr?l.add("tui-image-editor-top-optimization"):l.remove("tui-image-editor-top-optimization")}},{key:"toggleZoomButtonStatus",value:function(t){this._buttonElements[t].classList.toggle(Kr),t===qr?this._buttonElements[$r].classList.remove(Kr):this._buttonElements[qr].classList.remove(Kr)}},{key:"offZoomInButtonStatus",value:function(){this._buttonElements[qr].classList.remove(Kr)}},{key:"changeHandButtonStatus",value:function(t){this._buttonElements[$r].classList[t?"add":"remove"](Kr)}},{key:"changeHelpButtonEnabled",value:function(t,e){this._buttonElements[t].classList[e?"add":"remove"]("enabled")}},{key:"_initializeOption",value:function(t){return R()({loadImage:{path:"",name:""},locale:{},menuIconPath:"",menu:["resize","crop","flip","rotate","draw","shape","icon","text","mask","filter"],initMenu:"",uiSize:{width:"100%",height:"100%"},menuBarPosition:"bottom"},t)}},{key:"_setUiSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.uiSize,e=this._selectedElement.style;e.width=t.width,e.height=t.height}},{key:"_makeSubMenu",value:function(){var t=this;H()(this.options.menu,(function(e){var i,n=Jr[e.replace(/^[a-z]/,(function(t){return t.toUpperCase()}))];t._makeMenuElement(e),t._buttonElements[e]=t._menuBarElement.querySelector(".tie-btn-".concat(e)),t[e]=new n(t._subMenuElement,{locale:t._locale,makeSvgIcon:A()(i=t.theme.makeMenSvgIconSet).call(i,t.theme),menuBarPosition:t.options.menuBarPosition,usageStatistics:t.options.usageStatistics})}))}},{key:"_attachHistoryEvent",value:function(){var t,e,i;this.on(fe,A()(t=this._addHistory).call(t,this)),this.on(ge,A()(e=this._selectPrevHistory).call(e,this)),this.on(de,A()(i=this._selectNextHistory).call(i,this))}},{key:"_attachZoomEvent",value:function(){var t=this;this.on(pe,(function(){t.offZoomInButtonStatus(),t.changeHandButtonStatus(!0)})),this.on(me,(function(){return t.changeHandButtonStatus(!1)}))}},{key:"_makeUiElement",value:function(t){var e,i;i=t.nodeType?t:document.querySelector(t);var n,r=(n=i,function(t){return n.querySelector(t)});i.classList.add("tui-image-editor-container"),i.innerHTML=function(t){var e,i,n,r,o,a,s=t.locale,c=t.biImage,l=t.loadButtonStyle,u=t.downloadButtonStyle,h=t.menuBarPosition;return O()(e=O()(i=O()(n=O()(r=O()(o='\n <ul class="tui-image-editor-help-menu '.concat((a=h,"top"===a?"bottom":"left"===a?"right":"right"===a?"left":"top"),'"></ul>\n <div class="tui-image-editor-controls">\n <div class="tui-image-editor-controls-logo">\n <img src="')).call(o,c,'" />\n </div>\n <ul class="tui-image-editor-menu"></ul>\n\n <div class="tui-image-editor-controls-buttons">\n <div style="')).call(r,l,'">\n ')).call(n,s.localize("Load"),'\n <input type="file" class="tui-image-editor-load-btn" />\n </div>\n <button class="tui-image-editor-download-btn" style="')).call(i,u,'">\n ')).call(e,s.localize("Download"),"\n </button>\n </div>\n </div>\n")}({locale:this._locale,biImage:this.theme.getStyle("common.bi"),loadButtonStyle:this.theme.getStyle("loadButton"),downloadButtonStyle:this.theme.getStyle("downloadButton"),menuBarPosition:this.options.menuBarPosition})+function(t){var e,i,n,r,o,a,s,c=t.locale,l=t.biImage,u=t.commonStyle,h=t.headerStyle,f=t.loadButtonStyle,g=t.downloadButtonStyle,d=t.submenuStyle;return O()(e=O()(i=O()(n=O()(r=O()(o=O()(a=O()(s='\n <div class="tui-image-editor-main-container" style="'.concat(u,'">\n <div class="tui-image-editor-header" style="')).call(s,h,'">\n <div class="tui-image-editor-header-logo">\n <img src="')).call(a,l,'" />\n </div>\n <div class="tui-image-editor-header-buttons">\n <div style="')).call(o,f,'">\n ')).call(r,c.localize("Load"),'\n <input type="file" class="tui-image-editor-load-btn" />\n </div>\n <button class="tui-image-editor-download-btn" style="')).call(n,g,'">\n ')).call(i,c.localize("Download"),'\n </button>\n </div>\n </div>\n <div class="tui-image-editor-main">\n <div class="tui-image-editor-submenu">\n <div class="tui-image-editor-submenu-style" style="')).call(e,d,'"></div>\n </div>\n <div class="tui-image-editor-wrap">\n <div class="tui-image-editor-size-wrap">\n <div class="tui-image-editor-align-wrap">\n <div class="tui-image-editor"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n')}({locale:this._locale,biImage:this.theme.getStyle("common.bi"),commonStyle:this.theme.getStyle("common"),headerStyle:this.theme.getStyle("header"),loadButtonStyle:this.theme.getStyle("loadButton"),downloadButtonStyle:this.theme.getStyle("downloadButton"),submenuStyle:this.theme.getStyle("submenu")}),this._selectedElement=i,this._selectedElement.classList.add(this.options.menuBarPosition),this._mainElement=r(".tui-image-editor-main"),this._editorElementWrap=r(".tui-image-editor-wrap"),this._editorElement=r(".tui-image-editor"),this._helpMenuBarElement=r(".tui-image-editor-help-menu"),this._menuBarElement=r(".tui-image-editor-menu"),this._subMenuElement=r(".tui-image-editor-submenu"),this._buttonElements={download:this._selectedElement.querySelectorAll(".tui-image-editor-download-btn"),load:this._selectedElement.querySelectorAll(".tui-image-editor-load-btn")},this._addHelpMenus(),this._historyMenu=new Xr(this._buttonElements.history,{locale:this._locale,makeSvgIcon:A()(e=this.theme.makeMenSvgIconSet).call(e,this.theme)}),this._activateZoomMenus()}},{key:"_activateZoomMenus",value:function(){var t=this;H()(ut,(function(e){t.changeHelpButtonEnabled(e,!0)}))}},{key:"_makeHelpMenuWithPartition",value:function(){var t;return O()(t=[]).call(t,_(ut),[""],_(ht),[""],_(ft))}},{key:"_addHelpMenus",value:function(){var t=this,e=this._makeHelpMenuWithPartition();H()(e,(function(e){e?(t._makeMenuElement(e,["normal","disabled","hover"],"help"),t._buttonElements[e]=t._helpMenuBarElement.querySelector(".tie-btn-".concat(e))):t._makeMenuPartitionElement()}))}},{key:"_makeMenuPartitionElement",value:function(){var t=document.createElement("li"),e=document.createElement("div");t.className=Hi("item"),e.className=Hi("icpartition"),t.appendChild(e),this._helpMenuBarElement.appendChild(t)}},{key:"_makeMenuElement",value:function(t){var e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["normal","active","hover"],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"normal",o=document.createElement("li"),a=this.theme.makeMenSvgIconSet(n,t);this._addTooltipAttribute(o,t),o.className=O()(e=O()(i="tie-btn-".concat(t," ")).call(i,Hi("item")," ")).call(e,r),o.innerHTML=a,"normal"===r?this._menuBarElement.appendChild(o):this._helpMenuBarElement.appendChild(o)}},{key:"_addHelpActionEvent",value:function(){var t=this;H()(gt,(function(e){t.eventHandler[e]=function(i){return t._actions.main[e](i)},t._buttonElements[e].addEventListener("click",t.eventHandler[e])}))}},{key:"_removeHelpActionEvent",value:function(){var t=this;H()(gt,(function(e){t._buttonElements[e].removeEventListener("click",t.eventHandler[e])}))}},{key:"_addHistory",value:function(t){if(!function(t){return"string"==typeof t?Tt===t:Tt===t.name}(t)){var e="string"==typeof t?{name:t}:function(t){var e,i,n,r=Dt,o=At,a=Rt,s=Et,c=Lt,l=Bt,u=Pt,f=Yt,g=kt,d=Wt,v=Ot,p=Zt,m=t.name,y=t.args;switch(m){case r:n={name:m,detail:"reset"===y[1]?y[1]:h()(e=y[1]).call(e,4)};break;case o:n={name:m,detail:y[2]};break;case s:n={name:Ae,detail:Ki(y[1],y[2])};break;case c:n={name:je,detail:"Remove"};break;case l:n={name:Oe,detail:"Change"};break;case u:n={name:Ee,detail:"Change"};break;case f:n={name:Ne,detail:"Change"};break;case v:n={name:Pe,detail:y[2]};break;case g:n={name:ze,detail:"All"};break;case d:n={name:ke,detail:"Add"};break;case a:n={name:Le};break;case p:n={name:De,detail:O()(i="".concat(~~y[1].width,"x")).call(i,~~y[1].height)};break;default:n={name:m}}return"mask"===y[1]&&(n={name:we,detail:"Apply"}),n}(t);this._historyMenu.add(e)}}},{key:"initHistory",value:function(){this._historyMenu.init()}},{key:"clearHistory",value:function(){this._historyMenu.clear()}},{key:"_selectPrevHistory",value:function(){this._historyMenu.prev()}},{key:"_selectNextHistory",value:function(){this._historyMenu.next()}},{key:"toggleHistoryMenu",value:function(t){t.target.closest(".".concat("tie-panel-history"))||this._buttonElements.history.classList.toggle("opened")}},{key:"_addTooltipAttribute",value:function(t,e){t.setAttribute("tooltip-content",this._locale.localize(e.replace(/^[a-z]/g,(function(t){return t.toUpperCase()}))))}},{key:"_addDownloadEvent",value:function(){var t=this;this.eventHandler.download=function(){return t._actions.main.download()},H()(this._buttonElements.download,(function(e){e.addEventListener("click",t.eventHandler.download)}))}},{key:"_removeDownloadEvent",value:function(){var t=this;H()(this._buttonElements.download,(function(e){e.removeEventListener("click",t.eventHandler.download)}))}},{key:"_addLoadEvent",value:function(){var t=this;this.eventHandler.loadImage=function(e){return t._actions.main.load(e.target.files[0])},H()(this._buttonElements.load,(function(e){e.addEventListener("change",t.eventHandler.loadImage)}))}},{key:"_removeLoadEvent",value:function(){var t=this;H()(this._buttonElements.load,(function(e){e.removeEventListener("change",t.eventHandler.loadImage)}))}},{key:"_addMainMenuEvent",value:function(t){var e=this;this.eventHandler[t]=function(){return e.changeMenu(t)},this._buttonElements[t].addEventListener("click",this.eventHandler[t])}},{key:"_addSubMenuEvent",value:function(t){var e=this;this[t].addEvent(this._actions[t]),this[t].on(xe,(function(){return e.fire(xe)})),this[t].on(Ce,(function(){return e.fire(Ce)}))}},{key:"_addMenuEvent",value:function(){var t=this;H()(this.options.menu,(function(e){t._addMainMenuEvent(e),t._addSubMenuEvent(e)}))}},{key:"_removeMainMenuEvent",value:function(){var t=this;H()(this.options.menu,(function(e){t._buttonElements[e].removeEventListener("click",t.eventHandler[e]),t[e].off(xe),t[e].off(Ce)}))}},{key:"getEditorArea",value:function(){return this._editorElement}},{key:"activeMenuEvent",value:function(){this._initMenuEvent||(this._addHelpActionEvent(),this._addDownloadEvent(),this._addMenuEvent(),this._initMenu(),this._historyMenu.addEvent(this._actions.history),this._initMenuEvent=!0)}},{key:"_removeUiEvent",value:function(){this._removeHelpActionEvent(),this._removeDownloadEvent(),this._removeLoadEvent(),this._removeMainMenuEvent(),this._historyMenu.removeEvent()}},{key:"_destroyAllMenu",value:function(){var t=this;H()(this.options.menu,(function(e){t[e].destroy()})),this._historyMenu.destroy()}},{key:"initCanvas",value:function(){var t=this,e=this._getLoadImage();e.path&&this._actions.main.initLoadImage(e.path,e.name).then((function(){t.activeMenuEvent()})),this._addLoadEvent();var i=document.createElement("div");i.className=Hi("grid-visual");i.innerHTML='<table>\n <tr><td class="dot left-top"></td><td></td><td class="dot right-top"></td></tr>\n <tr><td></td><td></td><td></td></tr>\n <tr><td class="dot left-bottom"></td><td></td><td class="dot right-bottom"></td></tr>\n </table>',this._editorContainerElement=this._editorElement.querySelector(".tui-image-editor-canvas-container"),this._editorContainerElement.appendChild(i)}},{key:"_getLoadImage",value:function(){return this.options.loadImage}},{key:"changeMenu",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this._submenuChangeTransection||(this._submenuChangeTransection=!0,this._changeMenu(t,e,i),this._submenuChangeTransection=!1)}},{key:"_changeMenu",value:function(t,e,i){this.submenu&&(this._buttonElements[this.submenu].classList.remove("active"),this._mainElement.classList.remove("tui-image-editor-menu-".concat(this.submenu)),i&&this._actions.main.discardSelection(),this._actions.main.changeSelectableAll(!0),this[this.submenu].changeStandbyMode()),this.submenu===t&&e?this.submenu=null:(this._buttonElements[t].classList.add("active"),this._mainElement.classList.add("tui-image-editor-menu-".concat(t)),this.submenu=t,this[this.submenu].changeStartMode()),this.resizeEditor()}},{key:"_initMenu",value:function(){if(this.options.initMenu){var t=document.createEvent("MouseEvents");t.initEvent("click",!0,!1),this._buttonElements[this.options.initMenu].dispatchEvent(t)}this.icon&&this.icon.registerDefaultIcon()}},{key:"_getCanvasMaxDimension",value:function(){var t=this._editorContainerElement.style,e=t.maxWidth,i=t.maxHeight;return{width:dn()(e),height:dn()(i)}}},{key:"_setEditorPosition",value:function(t){var e=this._getCanvasMaxDimension(),i=e.width,n=e.height,r=this._editorElement.style,o=0,a=0;this.submenu&&("bottom"===t?o=n>this._editorElementWrap.scrollHeight-150?(n-this._editorElementWrap.scrollHeight)/2:-75:"top"===t?o=n>this._editorElementWrap.offsetHeight-150?75-(n-(this._editorElementWrap.offsetHeight-150))/2:75:"left"===t?a=i>this._editorElementWrap.offsetWidth-248?124-(i-(this._editorElementWrap.offsetWidth-248))/2:124:"right"===t&&(a=i>this._editorElementWrap.scrollWidth-248?(i-this._editorElementWrap.scrollWidth)/2:-124)),r.top="".concat(o,"px"),r.left="".concat(a,"px")}}]),t}();G().mixin(to);var eo=to,io=n(381),no=n.n(io),ro=function(){function t(){w(this,t),this.versionnumber="1.2.4",this.optionpresets={default:{corsenabled:!1,ltres:1,qtres:1,pathomit:8,rightangleenhance:!0,colorsampling:2,numberofcolors:16,mincolorratio:0,colorquantcycles:3,layering:0,strokewidth:1,linefilter:!1,scale:1,roundcoords:1,viewbox:!1,desc:!1,lcpr:0,qcpr:0,blurradius:0,blurdelta:20},posterized1:{colorsampling:0,numberofcolors:2},posterized2:{numberofcolors:4,blurradius:5},curvy:{ltres:.01,linefilter:!0,rightangleenhance:!1},sharp:{qtres:.01,linefilter:!1},detailed:{pathomit:0,roundcoords:2,ltres:.5,qtres:.5,numberofcolors:64},smoothed:{blurradius:5,blurdelta:64},grayscale:{colorsampling:0,colorquantcycles:1,numberofcolors:7},fixedpalette:{colorsampling:0,colorquantcycles:1,numberofcolors:27},randomsampling1:{colorsampling:1,numberofcolors:8},randomsampling2:{colorsampling:1,numberofcolors:64},artistic1:{colorsampling:0,colorquantcycles:1,pathomit:0,blurradius:5,blurdelta:64,ltres:.01,linefilter:!0,numberofcolors:16,strokewidth:2},artistic2:{qtres:.01,colorsampling:0,colorquantcycles:1,numberofcolors:4,strokewidth:0},artistic3:{qtres:10,ltres:10,numberofcolors:8},artistic4:{qtres:10,ltres:10,numberofcolors:64,blurradius:5,blurdelta:256,strokewidth:2},posterized3:{ltres:1,qtres:1,pathomit:20,rightangleenhance:!0,colorsampling:0,numberofcolors:3,mincolorratio:0,colorquantcycles:3,blurradius:3,blurdelta:20,strokewidth:0,linefilter:!1,roundcoords:1,pal:[{r:0,g:0,b:100,a:255},{r:255,g:255,b:255,a:255}]}},this.pathscan_combined_lookup=[[[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[0,1,0,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[0,2,-1,0]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[0,1,0,-1],[0,0,1,0]],[[0,0,1,0],[-1,-1,-1,-1],[0,2,-1,0],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[0,0,1,0],[0,3,0,1],[-1,-1,-1,-1]],[[13,3,0,1],[13,2,-1,0],[7,1,0,-1],[7,0,1,0]],[[-1,-1,-1,-1],[0,1,0,-1],[-1,-1,-1,-1],[0,3,0,1]],[[0,3,0,1],[0,2,-1,0],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[0,3,0,1],[0,2,-1,0],[-1,-1,-1,-1],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[0,1,0,-1],[-1,-1,-1,-1],[0,3,0,1]],[[11,1,0,-1],[14,0,1,0],[14,3,0,1],[11,2,-1,0]],[[-1,-1,-1,-1],[0,0,1,0],[0,3,0,1],[-1,-1,-1,-1]],[[0,0,1,0],[-1,-1,-1,-1],[0,2,-1,0],[-1,-1,-1,-1]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[0,1,0,-1],[0,0,1,0]],[[0,1,0,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[0,2,-1,0]],[[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1]]],this.gks=[[.27901,.44198,.27901],[.135336,.228569,.272192,.228569,.135336],[.086776,.136394,.178908,.195843,.178908,.136394,.086776],[.063327,.093095,.122589,.144599,.152781,.144599,.122589,.093095,.063327],[.049692,.069304,.089767,.107988,.120651,.125194,.120651,.107988,.089767,.069304,.049692]],this.specpalette=[{r:0,g:0,b:0,a:255},{r:128,g:128,b:128,a:255},{r:0,g:0,b:128,a:255},{r:64,g:64,b:128,a:255},{r:192,g:192,b:192,a:255},{r:255,g:255,b:255,a:255},{r:128,g:128,b:192,a:255},{r:0,g:0,b:192,a:255},{r:128,g:0,b:0,a:255},{r:128,g:64,b:64,a:255},{r:128,g:0,b:128,a:255},{r:168,g:168,b:168,a:255},{r:192,g:128,b:128,a:255},{r:192,g:0,b:0,a:255},{r:255,g:255,b:255,a:255},{r:0,g:128,b:0,a:255}]}return T(t,[{key:"imageToSVG",value:function(t,e,i){var n=this;i=this.checkoptions(i),this.loadImage(t,(function(t){e(n.imagedataToSVG(n.getImgdata(t),i))}),i)}},{key:"imagedataToSVG",value:function(t,e){e=this.checkoptions(e);var i=this.imagedataToTracedata(t,e);return this.getsvgstring(i,e)}},{key:"imageToTracedata",value:function(t,e,i){var n=this;i=this.checkoptions(i),this.loadImage(t,(function(t){e(n.imagedataToTracedata(n.getImgdata(t),i))}),i)}},{key:"imagedataToTracedata",value:function(t,e){e=this.checkoptions(e);var i,n=this.colorquantization(t,e);if(0===e.layering){i={layers:[],palette:n.palette,width:n.array[0].length-2,height:n.array.length-2};for(var r=0;r<n.palette.length;r+=1){var o=this.batchtracepaths(this.internodes(this.pathscan(this.layeringstep(n,r),e.pathomit),e),e.ltres,e.qtres);i.layers.push(o)}}else{var a=this.layering(n);e.layercontainerid&&this.drawLayers(a,this.specpalette,e.scale,e.layercontainerid);var s=this.batchpathscan(a,e.pathomit),c=this.batchinternodes(s,e);i={layers:this.batchtracelayers(c,e.ltres,e.qtres),palette:n.palette,width:t.width,height:t.height}}return i}},{key:"checkoptions",value:function(t){"string"==typeof(t=t||{})&&(t=t.toLowerCase(),t=this.optionpresets[t]?this.optionpresets[t]:{});for(var e=J()(this.optionpresets.default),i=0;i<e.length;i+=1)t.hasOwnProperty(e[i])||(t[e[i]]=this.optionpresets.default[e[i]]);return t}},{key:"colorquantization",value:function(t,e){var i,n,r,o,a,s,c,l,u=[],h=0,f=[],g=t.width*t.height;for(a=0;a<t.height+2;a+=1)for(u[a]=[],o=0;o<t.width+2;o+=1)u[a][o]=-1;for(l=e.pal?e.pal:0===e.colorsampling?this.generatepalette(e.numberofcolors):1===e.colorsampling?this.samplepalette(e.numberofcolors,t):this.samplepalette2(e.numberofcolors,t),e.blurradius>0&&(t=this.blur(t,e.blurradius,e.blurdelta)),c=0;c<e.colorquantcycles;c+=1){if(c>0)for(s=0;s<l.length;s+=1)f[s].n>0&&(l[s]={r:Math.floor(f[s].r/f[s].n),g:Math.floor(f[s].g/f[s].n),b:Math.floor(f[s].b/f[s].n),a:Math.floor(f[s].a/f[s].n)}),f[s].n/g<e.mincolorratio&&c<e.colorquantcycles-1&&(l[s]={r:Math.floor(255*Math.random()),g:Math.floor(255*Math.random()),b:Math.floor(255*Math.random()),a:Math.floor(255*Math.random())});for(o=0;o<l.length;o+=1)f[o]={r:0,g:0,b:0,a:0,n:0};for(a=0;a<t.height;a+=1)for(o=0;o<t.width;o+=1){for(h=4*(a*t.width+o),r=0,n=1024,s=0;s<l.length;s+=1)(i=Math.abs(l[s].r-t.data[h])+Math.abs(l[s].g-t.data[h+1])+Math.abs(l[s].b-t.data[h+2])+Math.abs(l[s].a-t.data[h+3]))<n&&(n=i,r=s);f[r].r+=t.data[h],f[r].g+=t.data[h+1],f[r].b+=t.data[h+2],f[r].a+=t.data[h+3],f[r].n+=1,u[a+1][o+1]=r}}return{array:u,palette:l}}},{key:"samplepalette",value:function(t,e){for(var i,n=[],r=0;r<t;r+=1)i=4*Math.floor(Math.random()*e.data.length/4),n.push({r:e.data[i],g:e.data[i+1],b:e.data[i+2],a:e.data[i+3]});return n}},{key:"samplepalette2",value:function(t,e){for(var i,n=[],r=Math.ceil(Math.sqrt(t)),o=Math.ceil(t/r),a=e.width/(r+1),s=e.height/(o+1),c=0;c<o;c+=1)for(var l=0;l<r&&n.length!==t;l+=1)i=4*Math.floor((c+1)*s*e.width+(l+1)*a),n.push({r:e.data[i],g:e.data[i+1],b:e.data[i+2],a:e.data[i+3]});return n}},{key:"generatepalette",value:function(t){var e,i,n,r=[];if(t<8)for(var o=Math.floor(255/(t-1)),a=0;a<t;a+=1)r.push({r:a*o,g:a*o,b:a*o,a:255});else{var s=Math.floor(Math.pow(t,1/3)),c=Math.floor(255/(s-1)),l=t-s*s*s;for(e=0;e<s;e+=1)for(i=0;i<s;i+=1)for(n=0;n<s;n+=1)r.push({r:e*c,g:i*c,b:n*c,a:255});for(e=0;e<l;e+=1)r.push({r:Math.floor(255*Math.random()),g:Math.floor(255*Math.random()),b:Math.floor(255*Math.random()),a:Math.floor(255*Math.random())})}return r}},{key:"layering",value:function(t){var e,i,n,r,o,a,s,c,l,u,h,f=[],g=0,d=t.array.length,v=t.array[0].length;for(h=0;h<t.palette.length;h+=1)for(f[h]=[],u=0;u<d;u+=1)for(f[h][u]=[],l=0;l<v;l+=1)f[h][u][l]=0;for(u=1;u<d-1;u+=1)for(l=1;l<v-1;l+=1)g=t.array[u][l],e=t.array[u-1][l-1]===g?1:0,i=t.array[u-1][l]===g?1:0,n=t.array[u-1][l+1]===g?1:0,r=t.array[u][l-1]===g?1:0,o=t.array[u][l+1]===g?1:0,a=t.array[u+1][l-1]===g?1:0,s=t.array[u+1][l]===g?1:0,c=t.array[u+1][l+1]===g?1:0,f[g][u+1][l+1]=1+2*o+4*c+8*s,r||(f[g][u+1][l]=2+4*s+8*a),i||(f[g][u][l+1]=0+2*n+4*o+8),e||(f[g][u][l]=0+2*i+4+8*r);return f}},{key:"layeringstep",value:function(t,e){var i,n,r=[],o=t.array.length,a=t.array[0].length;for(n=0;n<o;n+=1)for(r[n]=[],i=0;i<a;i+=1)r[n][i]=0;for(n=1;n<o;n+=1)for(i=1;i<a;i+=1)r[n][i]=(t.array[n-1][i-1]===e?1:0)+(t.array[n-1][i]===e?2:0)+(t.array[n][i-1]===e?8:0)+(t.array[n][i]===e?4:0);return r}},{key:"pathscan",value:function(t,e){for(var i,n=[],r=0,o=0,a=0,s=0,c=t[0].length,l=t.length,u=0,h=!0,f=!1,g=0;g<l;g+=1)for(var d=0;d<c;d+=1)if(4===t[g][d]||11===t[g][d])for(a=d,s=g,n[r]={},n[r].points=[],n[r].boundingbox=[a,s,a,s],n[r].holechildren=[],h=!1,o=0,f=11===t[g][d],u=1;!h;){if(n[r].points[o]={},n[r].points[o].x=a-1,n[r].points[o].y=s-1,n[r].points[o].t=t[s][a],a-1<n[r].boundingbox[0]&&(n[r].boundingbox[0]=a-1),a-1>n[r].boundingbox[2]&&(n[r].boundingbox[2]=a-1),s-1<n[r].boundingbox[1]&&(n[r].boundingbox[1]=s-1),s-1>n[r].boundingbox[3]&&(n[r].boundingbox[3]=s-1),i=this.pathscan_combined_lookup[t[s][a]][u],t[s][a]=i[0],u=i[1],a+=i[2],s+=i[3],a-1===n[r].points[0].x&&s-1===n[r].points[0].y)if(h=!0,n[r].points.length<e)n.pop();else{if(n[r].isholepath=!!f,f){for(var v=0,p=[-1,-1,c+1,l+1],m=0;m<r;m++)!n[m].isholepath&&this.boundingboxincludes(n[m].boundingbox,n[r].boundingbox)&&this.boundingboxincludes(p,n[m].boundingbox)&&(v=m,p=n[m].boundingbox);n[v].holechildren.push(r)}r+=1}o+=1}return n}},{key:"boundingboxincludes",value:function(t,e){return t[0]<e[0]&&t[1]<e[1]&&t[2]>e[2]&&t[3]>e[3]}},{key:"batchpathscan",value:function(t,e){var i=[];for(var n in t)t.hasOwnProperty(n)&&(i[n]=this.pathscan(t[n],e));return i}},{key:"internodes",value:function(t,e){var i,n,r=[],o=0,a=0,s=0,c=0,l=0;for(i=0;i<t.length;i+=1)for(r[i]={},r[i].points=[],r[i].boundingbox=t[i].boundingbox,r[i].holechildren=t[i].holechildren,r[i].isholepath=t[i].isholepath,o=t[i].points.length,n=0;n<o;n+=1)a=(n+1)%o,s=(n+2)%o,c=(n-1+o)%o,l=(n-2+o)%o,e.rightangleenhance&&this.testrightangle(t[i],l,c,n,a,s)&&(r[i].points.length>0&&(r[i].points[r[i].points.length-1].linesegment=this.getdirection(r[i].points[r[i].points.length-1].x,r[i].points[r[i].points.length-1].y,t[i].points[n].x,t[i].points[n].y)),r[i].points.push({x:t[i].points[n].x,y:t[i].points[n].y,linesegment:this.getdirection(t[i].points[n].x,t[i].points[n].y,(t[i].points[n].x+t[i].points[a].x)/2,(t[i].points[n].y+t[i].points[a].y)/2)})),r[i].points.push({x:(t[i].points[n].x+t[i].points[a].x)/2,y:(t[i].points[n].y+t[i].points[a].y)/2,linesegment:this.getdirection((t[i].points[n].x+t[i].points[a].x)/2,(t[i].points[n].y+t[i].points[a].y)/2,(t[i].points[a].x+t[i].points[s].x)/2,(t[i].points[a].y+t[i].points[s].y)/2)});return r}},{key:"testrightangle",value:function(t,e,i,n,r,o){return t.points[n].x===t.points[e].x&&t.points[n].x===t.points[i].x&&t.points[n].y===t.points[r].y&&t.points[n].y===t.points[o].y||t.points[n].y===t.points[e].y&&t.points[n].y===t.points[i].y&&t.points[n].x===t.points[r].x&&t.points[n].x===t.points[o].x}},{key:"getdirection",value:function(t,e,i,n){return t<i?e<n?1:e>n?7:0:t>i?e<n?3:e>n?5:4:e<n?2:e>n?6:8}},{key:"batchinternodes",value:function(t,e){var i=[];for(var n in t)t.hasOwnProperty(n)&&(i[n]=this.internodes(t[n],e));return i}},{key:"tracepath",value:function(t,e,i){var n,r,o,a=0,s={segments:[]};for(s.boundingbox=t.boundingbox,s.holechildren=t.holechildren,s.isholepath=t.isholepath;a<t.points.length;){var c;for(n=t.points[a].linesegment,r=-1,o=a+1;(t.points[o].linesegment===n||t.points[o].linesegment===r||-1===r)&&o<t.points.length-1;)t.points[o].linesegment!==n&&-1===r&&(r=t.points[o].linesegment),o+=1;o===t.points.length-1&&(o=0),s.segments=O()(c=s.segments).call(c,this.fitseq(t,e,i,a,o)),a=o>0?o:t.points.length}return s}},{key:"fitseq",value:function(t,e,i,n,r){var o;if(r>t.points.length||r<0)return[];var a,s,c,l=n,u=0,h=!0,f=r-n;f<0&&(f+=t.points.length);for(var g,d=(t.points[r].x-t.points[n].x)/f,v=(t.points[r].y-t.points[n].y)/f,p=(n+1)%t.points.length;p!=r;)(g=p-n)<0&&(g+=t.points.length),a=t.points[n].x+d*g,s=t.points[n].y+v*g,(c=(t.points[p].x-a)*(t.points[p].x-a)+(t.points[p].y-s)*(t.points[p].y-s))>e&&(h=!1),c>u&&(l=p,u=c),p=(p+1)%t.points.length;if(h)return[{type:"L",x1:t.points[n].x,y1:t.points[n].y,x2:t.points[r].x,y2:t.points[r].y}];var m=l;h=!0,u=0;var y=(m-n)/f,b=(1-y)*(1-y),x=2*(1-y)*y,C=y*y,I=(b*t.points[n].x+C*t.points[r].x-t.points[m].x)/-x,_=(b*t.points[n].y+C*t.points[r].y-t.points[m].y)/-x;for(p=n+1;p!=r;)x=2*(1-(y=(p-n)/f))*y,C=y*y,a=(b=(1-y)*(1-y))*t.points[n].x+x*I+C*t.points[r].x,s=b*t.points[n].y+x*_+C*t.points[r].y,(c=(t.points[p].x-a)*(t.points[p].x-a)+(t.points[p].y-s)*(t.points[p].y-s))>i&&(h=!1),c>u&&(l=p,u=c),p=(p+1)%t.points.length;if(h)return[{type:"Q",x1:t.points[n].x,y1:t.points[n].y,x2:I,y2:_,x3:t.points[r].x,y3:t.points[r].y}];var M=m;return O()(o=this.fitseq(t,e,i,n,M)).call(o,this.fitseq(t,e,i,M,r))}},{key:"batchtracepaths",value:function(t,e,i){var n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(this.tracepath(t[r],e,i));return n}},{key:"batchtracelayers",value:function(t,e,i){var n=[];for(var r in t)t.hasOwnProperty(r)&&(n[r]=this.batchtracepaths(t[r],e,i));return n}},{key:"roundtodec",value:function(t,e){return Number(t.toFixed(e))}},{key:"svgpathstring",value:function(t,e,i,n){var r,o,a,s=t.layers[e],c=s[i],l="";if(n.linefilter&&c.segments.length<3)return l;if(l=O()(r="<path ".concat(n.desc?O()(o='desc="l '.concat(e," p ")).call(o,i,'" '):"")).call(r,this.tosvgcolorstr(t.palette[e],n),'d="'),-1===n.roundcoords){var u;for(l+=O()(u="M ".concat(c.segments[0].x1*n.scale," ")).call(u,c.segments[0].y1*n.scale," "),a=0;a<c.segments.length;a++){var h,f,g;if(l+=O()(h=O()(f="".concat(c.segments[a].type," ")).call(f,c.segments[a].x2*n.scale," ")).call(h,c.segments[a].y2*n.scale," "),c.segments[a].hasOwnProperty("x3"))l+=O()(g="".concat(c.segments[a].x3*n.scale," ")).call(g,c.segments[a].y3*n.scale," ")}l+="Z "}else{var d;for(l+=O()(d="M ".concat(this.roundtodec(c.segments[0].x1*n.scale,n.roundcoords)," ")).call(d,this.roundtodec(c.segments[0].y1*n.scale,n.roundcoords)," "),a=0;a<c.segments.length;a++){var v,p,m;if(l+=O()(v=O()(p="".concat(c.segments[a].type," ")).call(p,this.roundtodec(c.segments[a].x2*n.scale,n.roundcoords)," ")).call(v,this.roundtodec(c.segments[a].y2*n.scale,n.roundcoords)," "),c.segments[a].hasOwnProperty("x3"))l+=O()(m="".concat(this.roundtodec(c.segments[a].x3*n.scale,n.roundcoords)," ")).call(m,this.roundtodec(c.segments[a].y3*n.scale,n.roundcoords)," ")}l+="Z "}for(var y=0;y<c.holechildren.length;y++){var b=s[c.holechildren[y]];if(-1===n.roundcoords){var x,C;if(b.segments[b.segments.length-1].hasOwnProperty("x3"))l+=O()(x="M ".concat(b.segments[b.segments.length-1].x3*n.scale," ")).call(x,b.segments[b.segments.length-1].y3*n.scale," ");else l+=O()(C="M ".concat(b.segments[b.segments.length-1].x2*n.scale," ")).call(C,b.segments[b.segments.length-1].y2*n.scale," ");for(a=b.segments.length-1;a>=0;a--){var I,_;if(l+="".concat(b.segments[a].type," "),b.segments[a].hasOwnProperty("x3"))l+=O()(_="".concat(b.segments[a].x2*n.scale," ")).call(_,b.segments[a].y2*n.scale," ");l+=O()(I="".concat(b.segments[a].x1*n.scale," ")).call(I,b.segments[a].y1*n.scale," ")}}else{var M,S;if(b.segments[b.segments.length-1].hasOwnProperty("x3"))l+=O()(M="M ".concat(this.roundtodec(b.segments[b.segments.length-1].x3*n.scale)," ")).call(M,this.roundtodec(b.segments[b.segments.length-1].y3*n.scale)," ");else l+=O()(S="M ".concat(this.roundtodec(b.segments[b.segments.length-1].x2*n.scale)," ")).call(S,this.roundtodec(b.segments[b.segments.length-1].y2*n.scale)," ");for(a=b.segments.length-1;a>=0;a--){var w,k;if(l+="".concat(b.segments[a].type," "),b.segments[a].hasOwnProperty("x3"))l+=O()(k="".concat(this.roundtodec(b.segments[a].x2*n.scale)," ")).call(k,this.roundtodec(b.segments[a].y2*n.scale)," ");l+=O()(w="".concat(this.roundtodec(b.segments[a].x1*n.scale)," ")).call(w,this.roundtodec(b.segments[a].y1*n.scale)," ")}}l+="Z "}if(l+='" />',n.lcpr||n.qcpr){for(a=0;a<c.segments.length;a++){var T,D,A,j,E,L,N,P,z,B,R,F,Y,W,H,U,G;if(c.segments[a].hasOwnProperty("x3")&&n.qcpr)l+=O()(T=O()(D=O()(A='<circle cx="'.concat(c.segments[a].x2*n.scale,'" cy="')).call(A,c.segments[a].y2*n.scale,'" r="')).call(D,n.qcpr,'" fill="cyan" stroke-width="')).call(T,.2*n.qcpr,'" stroke="black" />'),l+=O()(j=O()(E=O()(L='<circle cx="'.concat(c.segments[a].x3*n.scale,'" cy="')).call(L,c.segments[a].y3*n.scale,'" r="')).call(E,n.qcpr,'" fill="white" stroke-width="')).call(j,.2*n.qcpr,'" stroke="black" />'),l+=O()(N=O()(P=O()(z=O()(B='<line x1="'.concat(c.segments[a].x1*n.scale,'" y1="')).call(B,c.segments[a].y1*n.scale,'" x2="')).call(z,c.segments[a].x2*n.scale,'" y2="')).call(P,c.segments[a].y2*n.scale,'" stroke-width="')).call(N,.2*n.qcpr,'" stroke="cyan" />'),l+=O()(R=O()(F=O()(Y=O()(W='<line x1="'.concat(c.segments[a].x2*n.scale,'" y1="')).call(W,c.segments[a].y2*n.scale,'" x2="')).call(Y,c.segments[a].x3*n.scale,'" y2="')).call(F,c.segments[a].y3*n.scale,'" stroke-width="')).call(R,.2*n.qcpr,'" stroke="cyan" />');if(!c.segments[a].hasOwnProperty("x3")&&n.lcpr)l+=O()(H=O()(U=O()(G='<circle cx="'.concat(c.segments[a].x2*n.scale,'" cy="')).call(G,c.segments[a].y2*n.scale,'" r="')).call(U,n.lcpr,'" fill="white" stroke-width="')).call(H,.2*n.lcpr,'" stroke="black" />')}for(y=0;y<c.holechildren.length;y++){b=s[c.holechildren[y]];for(a=0;a<b.segments.length;a++){var X,Z,V,J,Q,K,q,$,tt,et,it,nt,rt,ot,at,st,ct;if(b.segments[a].hasOwnProperty("x3")&&n.qcpr)l+=O()(X=O()(Z=O()(V='<circle cx="'.concat(b.segments[a].x2*n.scale,'" cy="')).call(V,b.segments[a].y2*n.scale,'" r="')).call(Z,n.qcpr,'" fill="cyan" stroke-width="')).call(X,.2*n.qcpr,'" stroke="black" />'),l+=O()(J=O()(Q=O()(K='<circle cx="'.concat(b.segments[a].x3*n.scale,'" cy="')).call(K,b.segments[a].y3*n.scale,'" r="')).call(Q,n.qcpr,'" fill="white" stroke-width="')).call(J,.2*n.qcpr,'" stroke="black" />'),l+=O()(q=O()($=O()(tt=O()(et='<line x1="'.concat(b.segments[a].x1*n.scale,'" y1="')).call(et,b.segments[a].y1*n.scale,'" x2="')).call(tt,b.segments[a].x2*n.scale,'" y2="')).call($,b.segments[a].y2*n.scale,'" stroke-width="')).call(q,.2*n.qcpr,'" stroke="cyan" />'),l+=O()(it=O()(nt=O()(rt=O()(ot='<line x1="'.concat(b.segments[a].x2*n.scale,'" y1="')).call(ot,b.segments[a].y2*n.scale,'" x2="')).call(rt,b.segments[a].x3*n.scale,'" y2="')).call(nt,b.segments[a].y3*n.scale,'" stroke-width="')).call(it,.2*n.qcpr,'" stroke="cyan" />');if(!b.segments[a].hasOwnProperty("x3")&&n.lcpr)l+=O()(at=O()(st=O()(ct='<circle cx="'.concat(b.segments[a].x2*n.scale,'" cy="')).call(ct,b.segments[a].y2*n.scale,'" r="')).call(st,n.lcpr,'" fill="white" stroke-width="')).call(at,.2*n.lcpr,'" stroke="black" />')}}}return l}},{key:"getsvgstring",value:function(t,e){var i,n,r;e=this.checkoptions(e);for(var o=t.width*e.scale,a=t.height*e.scale,s=O()(i="<svg ".concat(e.viewbox?O()(n='viewBox="0 0 '.concat(o," ")).call(n,a,'" '):O()(r='width="'.concat(o,'" height="')).call(r,a,'" '),'version="1.1" xmlns="http://www.w3.org/2000/svg" desc="Created with imagetracer.js version ')).call(i,this.versionnumber,'" >'),c=0;c<t.layers.length;c+=1)for(var l=0;l<t.layers[c].length;l+=1)t.layers[c][l].isholepath||(s+=this.svgpathstring(t,c,l,e));return s+="</svg>"}},{key:"compareNumbers",value:function(t,e){return t-e}},{key:"torgbastr",value:function(t){var e,i,n;return O()(e=O()(i=O()(n="rgba(".concat(t.r,",")).call(n,t.g,",")).call(i,t.b,",")).call(e,t.a,")")}},{key:"tosvgcolorstr",value:function(t,e){var i,n,r,o,a,s,c;return O()(i=O()(n=O()(r=O()(o=O()(a=O()(s=O()(c='fill="rgb('.concat(t.r,",")).call(c,t.g,",")).call(s,t.b,')" stroke="rgb(')).call(a,t.r,",")).call(o,t.g,",")).call(r,t.b,')" stroke-width="')).call(n,e.strokewidth,'" opacity="')).call(i,t.a/255,'" ')}},{key:"appendSVGString",value:function(t,e){var i;e?(i=document.getElementById(e))||((i=document.createElement("div")).id=e,document.body.appendChild(i)):(i=document.createElement("div"),document.body.appendChild(i)),i.innerHTML+=t}},{key:"blur",value:function(t,e,i){var n,r,o,a,s,c,l,u,h,f={width:t.width,height:t.height,data:[]};if((e=Math.floor(e))<1)return t;e>5&&(e=5),(i=Math.abs(i))>1024&&(i=1024);var g=this.gks[e-1];for(r=0;r<t.height;r++)for(n=0;n<t.width;n++){for(s=0,c=0,l=0,u=0,h=0,o=-e;o<e+1;o++)n+o>0&&n+o<t.width&&(a=4*(r*t.width+n+o),s+=t.data[a]*g[o+e],c+=t.data[a+1]*g[o+e],l+=t.data[a+2]*g[o+e],u+=t.data[a+3]*g[o+e],h+=g[o+e]);a=4*(r*t.width+n),f.data[a]=Math.floor(s/h),f.data[a+1]=Math.floor(c/h),f.data[a+2]=Math.floor(l/h),f.data[a+3]=Math.floor(u/h)}var d=new Uint8ClampedArray(f.data);for(r=0;r<t.height;r++)for(n=0;n<t.width;n++){for(s=0,c=0,l=0,u=0,h=0,o=-e;o<e+1;o++)r+o>0&&r+o<t.height&&(s+=d[a=4*((r+o)*t.width+n)]*g[o+e],c+=d[a+1]*g[o+e],l+=d[a+2]*g[o+e],u+=d[a+3]*g[o+e],h+=g[o+e]);a=4*(r*t.width+n),f.data[a]=Math.floor(s/h),f.data[a+1]=Math.floor(c/h),f.data[a+2]=Math.floor(l/h),f.data[a+3]=Math.floor(u/h)}for(r=0;r<t.height;r++)for(n=0;n<t.width;n++)a=4*(r*t.width+n),Math.abs(f.data[a]-t.data[a])+Math.abs(f.data[a+1]-t.data[a+1])+Math.abs(f.data[a+2]-t.data[a+2])+Math.abs(f.data[a+3]-t.data[a+3])>i&&(f.data[a]=t.data[a],f.data[a+1]=t.data[a+1],f.data[a+2]=t.data[a+2],f.data[a+3]=t.data[a+3]);return f}},{key:"loadImage",value:function(t,e,i){var n=new Image;i&&i.corsenabled&&(n.crossOrigin="Anonymous"),n.src=t,n.onload=function(){var t=document.createElement("canvas");t.width=n.width,t.height=n.height,t.getContext("2d").drawImage(n,0,0),e(t)}}},{key:"getImgdata",value:function(t){return t.getContext("2d").getImageData(0,0,t.width,t.height)}},{key:"drawLayers",value:function(t,e,i,n){var r,o,a,s,c,l;for(c in i=i||1,n?(l=document.getElementById(n))||((l=document.createElement("div")).id=n,document.body.appendChild(l)):(l=document.createElement("div"),document.body.appendChild(l)),t)if(t.hasOwnProperty(c)){r=t[c][0].length,o=t[c].length;var u=document.createElement("canvas");u.width=r*i,u.height=o*i;var h=u.getContext("2d");for(s=0;s<o;s+=1)for(a=0;a<r;a+=1)h.fillStyle=this.torgbastr(e[t[c][s][a]%e.length]),h.fillRect(a*i,s*i,i,i);l.appendChild(u)}}}],[{key:"tracerDefaultOption",value:function(){return{pathomit:100,ltres:.1,qtres:1,scale:1,strokewidth:5,viewbox:!1,linefilter:!0,desc:!1,rightangleenhance:!1,pal:[{r:0,g:0,b:0,a:255},{r:255,g:255,b:255,a:255}]}}}]),t}(),oo={getActions:function(){return{main:this._mainAction(),shape:this._shapeAction(),crop:this._cropAction(),resize:this._resizeAction(),flip:this._flipAction(),rotate:this._rotateAction(),text:this._textAction(),mask:this._maskAction(),draw:this._drawAction(),icon:this._iconAction(),filter:this._filterAction(),history:this._historyAction()}},_mainAction:function(){var t=this,e=function(){"crop"===t.ui.submenu&&(t.stopDrawingMode(),t.ui.changeMenu("crop"))},i=function(e){var i,n;return i=e,"rotate"===t.ui.submenu&&t.ui.rotate.setRangeBarAngle("setAngle",i),n=e,"filter"===t.ui.submenu&&no()(t.ui).setFilterState(n),e},n=function(){no()(t.ui)&&no()(t.ui).initFilterCheckBoxState()};return R()({initLoadImage:function(i,n){return t.loadImageFromURL(i,n).then((function(n){e(),t.ui.initializeImgUrl=i,t.ui.resizeEditor({imageSize:n}),t.clearUndoStack(),t._invoker.fire(fe,Se)}))},undo:function(){t.isEmptyUndoStack()||(e(),t.deactivateAll(),t.undo().then(i))},redo:function(){t.isEmptyRedoStack()||(e(),t.deactivateAll(),t.redo().then(i))},reset:function(){e(),t.loadImageFromURL(t.ui.initializeImgUrl,"resetImage").then((function(i){e(),n(),t.ui.resizeEditor({imageSize:i}),t.clearUndoStack(),t._initHistory()}))},delete:function(){t.ui.changeHelpButtonEnabled("delete",!1),e(),t.removeActiveObject(),t.activeObjectId=null},deleteAll:function(){e(),t.clearObjects(),t.ui.changeHelpButtonEnabled("delete",!1),t.ui.changeHelpButtonEnabled("deleteAll",!1)},load:function(i){Fi()||alert("This browser does not support file-api"),t.ui.initializeImgUrl=P().createObjectURL(i),t.loadImageFromFile(i).then((function(i){e(),n(),t.clearUndoStack(),t.ui.activeMenuEvent(),t.ui.resizeEditor({imageSize:i}),t._clearHistory(),t._invoker.fire(fe,Se)})).catch((function(t){return L().reject(t)}))},download:function(){var e,i,n=t.toDataURL(),r=t.getImageName();Fi()&&window.saveAs?(i=(e=function(t){var e,i,n,r="";e=t.replace(/data:(image\/.+);base64,/,(function(t,e){return r=e,""}));var o=(e=atob(e)).length;for(i=new Uint8Array(o),n=0;n<o;n+=1)i[n]=e.charCodeAt(n);return new Blob([i],{type:r})}(n)).type.split("/")[1],r.split(".").pop()!==i&&(r+=".".concat(i)),saveAs(e,r)):window.open().document.body.innerHTML="<img src='".concat(n,"'>")},history:function(e){t.ui.toggleHistoryMenu(e)},zoomIn:function(){var e;t.ui.toggleZoomButtonStatus("zoomIn"),t.deactivateAll(),e=t._graphics.getZoomMode(),t.stopDrawingMode(),e!==Ge?(t.startDrawingMode(Be.ZOOM),t._graphics.startZoomInMode()):t._graphics.endZoomInMode()},zoomOut:function(){t._graphics.zoomOut()},hand:function(){var e;t.ui.offZoomInButtonStatus(),t.ui.toggleZoomButtonStatus("hand"),t.deactivateAll(),e=t._graphics.getZoomMode(),t.stopDrawingMode(),e!==Xe?(t.startDrawingMode(Be.ZOOM),t._graphics.startHandMode()):t._graphics.endHandMode()}},this._commonAction())},_iconAction:function(){var t=this;return R()({changeColor:function(e){t.activeObjectId&&t.changeIconColor(t.activeObjectId,e)},addIcon:function(e,i){t.startDrawingMode("ICON"),t.setDrawingIcon(e,i)},cancelAddIcon:function(){t.ui.icon.clearIconType(),t.changeSelectableAll(!0),t.changeCursor("default"),t.stopDrawingMode()},registerDefaultIcons:function(e,i){var n={};n[e]=i,t.registerIcons(n)},registerCustomIcon:function(e,i){(new ro).imageToSVG(e,(function(e){var n=Q(e.match(/path[^>]*d="([^"]*)"/),2)[1],r={};r[i.name]=n,t.registerIcons(r),t.addIcon(i.name,{left:100,top:100})}),ro.tracerDefaultOption())}},this._commonAction())},_drawAction:function(){var t=this;return R()({setDrawMode:function(e,i){t.stopDrawingMode(),"free"===e?t.startDrawingMode("FREE_DRAWING",i):t.startDrawingMode("LINE_DRAWING",i)},setColor:function(e){t.setBrush({color:e})}},this._commonAction())},_maskAction:function(){var t=this;return R()({loadImageFromURL:function(e,i){return t.loadImageFromURL(t.toDataURL(),"FilterImage").then((function(){t.addImageObject(e).then((function(){P().revokeObjectURL(i)})),t._invoker.fire(fe,we)}))},applyFilter:function(){t.applyFilter("mask",{maskObjId:t.activeObjectId})}},this._commonAction())},_textAction:function(){var t=this;return R()({changeTextStyle:function(e,i){t.activeObjectId&&t.changeTextStyle(t.activeObjectId,e,i)}},this._commonAction())},_rotateAction:function(){var t=this;return R()({rotate:function(e,i){t.rotate(e,i),t.ui.resizeEditor(),t.ui.rotate.setRangeBarAngle("rotate",e)},setAngle:function(e,i){t.setAngle(e,i),t.ui.resizeEditor(),t.ui.rotate.setRangeBarAngle("setAngle",e)}},this._commonAction())},_shapeAction:function(){var t=this;return R()({changeShape:function(e,i){t.activeObjectId&&t.changeShape(t.activeObjectId,e,i)},setDrawingShape:function(e){t.setDrawingShape(e)}},this._commonAction())},_cropAction:function(){var t=this;return R()({crop:function(){var e=t.getCropzoneRect();e&&!function(t){var e=t.left,i=t.top,n=t.width,r=t.height;return e===_i&&i===Mi&&n===Si&&r===wi}(e)&&t.crop(e).then((function(){t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("crop"),t._invoker.fire(fe,Te)})).catch((function(t){return L().reject(t)}))},cancel:function(){t.stopDrawingMode(),t.ui.changeMenu("crop")},preset:function(e){switch(e){case"preset-square":t.setCropzoneRect(1);break;case"preset-3-2":t.setCropzoneRect(1.5);break;case"preset-4-3":t.setCropzoneRect(4/3);break;case"preset-5-4":t.setCropzoneRect(5/4);break;case"preset-7-5":t.setCropzoneRect(1.4);break;case"preset-16-9":t.setCropzoneRect(16/9);break;default:t.setCropzoneRect(),t.ui.crop.changeApplyButtonStatus(!1)}}},this._commonAction())},_resizeAction:function(){var t=this;return R()({getCurrentDimensions:function(){return t._graphics.getCurrentDimensions()},preview:function(e,i,n){var r=t._graphics.getCurrentDimensions(),o=function(){return r.width/r.height},a={};switch(e){case"width":a.width=i,a.height=n?i/o():r.height;break;case"height":a.height=i,a.width=n?i*o():r.width;break;default:a=r}t._graphics.resize(a).then((function(){t.ui.resizeEditor()})),n&&(t.ui.resize.setWidthValue(a.width),t.ui.resize.setHeightValue(a.height))},resize:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e||(e=t._graphics.getCurrentDimensions()),t.resize(e).then((function(){t._graphics.setOriginalDimensions(e),t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("resize")})).catch((function(t){return L().reject(t)}))},reset:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=t._graphics.getOriginalDimensions();t.ui.resize.setWidthValue(i.width,!0),t.ui.resize.setHeightValue(i.height,!0),t._graphics.resize(i).then((function(){e||(t.stopDrawingMode(),t.ui.resizeEditor(),t.ui.changeMenu("resize"))}))}},this._commonAction())},_flipAction:function(){var t=this;return R()({flip:function(e){return t[e]()}},this._commonAction())},_filterAction:function(){var t=this;return R()({applyFilter:function(e,i,n,r){e?t.applyFilter(i,n,r):t.hasFilter(i)&&t.removeFilter(i)}},this._commonAction())},setReAction:function(){var t=this;this.on({undoStackChanged:function(e){e?(t.ui.changeHelpButtonEnabled("undo",!0),t.ui.changeHelpButtonEnabled("reset",!0)):(t.ui.changeHelpButtonEnabled("undo",!1),t.ui.changeHelpButtonEnabled("reset",!1)),t.ui.resizeEditor()},redoStackChanged:function(e){e?t.ui.changeHelpButtonEnabled("redo",!0):t.ui.changeHelpButtonEnabled("redo",!1),t.ui.resizeEditor()},objectActivated:function(e){var i,n;t.activeObjectId=e.id,t.ui.changeHelpButtonEnabled("delete",!0),t.ui.changeHelpButtonEnabled("deleteAll",!0),"cropzone"===e.type?t.ui.crop.changeApplyButtonStatus(!0):o()(i=["rect","circle","triangle"]).call(i,e.type)>-1?(t.stopDrawingMode(),"shape"!==t.ui.submenu&&t.ui.changeMenu("shape",!1,!1),t.ui.shape.setShapeStatus({strokeColor:e.stroke,strokeWidth:e.strokeWidth,fillColor:nt()(e)}),t.ui.shape.setMaxStrokeValue(Math.min(e.width,e.height))):"path"===e.type||"line"===e.type?"draw"!==t.ui.submenu&&(t.ui.changeMenu("draw",!1,!1),t.ui.draw.changeStandbyMode()):o()(n=["i-text","text"]).call(n,e.type)>-1?("text"!==t.ui.submenu&&t.ui.changeMenu("text",!1,!1),t.ui.text.setTextStyleStateOnAction(e)):"icon"===e.type&&(t.stopDrawingMode(),"icon"!==t.ui.submenu&&t.ui.changeMenu("icon",!1,!1),t.ui.icon.setIconPickerColor(nt()(e)))},addText:function(e){var i=t.ui.text,n=i.textColor,r=i.fontSize,o=i.fontStyle,a=i.fontWeight,s=i.underline;t.addText("Double Click",{position:e.originPosition,styles:{fill:n,fontSize:r,fontFamily:"Noto Sans",fontStyle:o,fontWeight:a,underline:s}}).then((function(){t.changeCursor("default")}))},addObjectAfter:function(e){var i;"icon"===e.type?t.ui.icon.changeStandbyMode():o()(i=["rect","circle","triangle"]).call(i,e.type)>-1&&(t.ui.shape.setMaxStrokeValue(Math.min(e.width,e.height)),t.ui.shape.changeStandbyMode())},objectScaled:function(e){var i,n;if(o()(i=["i-text","text"]).call(i,e.type)>-1)t.ui.text.fontSize=Bi(e.fontSize);else if(o()(n=["rect","circle","triangle"]).call(n,e.type)>=0){var r=e.width,a=e.height,s=t.ui.shape.getStrokeValue();r<s&&t.ui.shape.setStrokeValue(r),a<s&&t.ui.shape.setStrokeValue(a)}},selectionCleared:function(){t.activeObjectId=null,"text"===t.ui.submenu?t.changeCursor("text"):Xi(["draw","crop","resize"],t.ui.submenu)||t.stopDrawingMode()}})},_historyAction:function(){var t=this;return{undo:function(e){return t.undo(e)},redo:function(e){return t.redo(e)}}},_commonAction:function(){var t,e,i,n,r=this,o=Be.TEXT,a=Be.CROPPER,s=Be.SHAPE,c=Be.ZOOM,l=Be.RESIZE;return{modeChange:function(t){switch(t){case Re:r._changeActivateMode(o);break;case Fe:r.startDrawingMode(a);break;case We:r._changeActivateMode(s),r.setDrawingShape(r.ui.shape.type,r.ui.shape.options);break;case He:r.startDrawingMode(c);break;case Ye:r.startDrawingMode(l)}},deactivateAll:A()(t=this.deactivateAll).call(t,this),changeSelectableAll:A()(e=this.changeSelectableAll).call(e,this),discardSelection:A()(i=this.discardSelection).call(i,this),stopDrawingMode:A()(n=this.stopDrawingMode).call(n,this)}},mixin:function(t){R()(t.prototype,this)}},ao=n(7322),so=n.n(ao),co=n(6956),lo=n.n(co),uo=function(){function t(e,i){w(this,t),this.name=e,this.graphics=i}return T(t,[{key:"fire",value:function(){for(var t=this.graphics,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return this.graphics.fire.apply(t,i)}},{key:"setCanvasImage",value:function(t,e){this.graphics.setCanvasImage(t,e)}},{key:"getCanvasElement",value:function(){return this.graphics.getCanvasElement()}},{key:"getCanvas",value:function(){return this.graphics.getCanvas()}},{key:"getCanvasImage",value:function(){return this.graphics.getCanvasImage()}},{key:"getImageName",value:function(){return this.graphics.getImageName()}},{key:"getEditor",value:function(){return this.graphics.getEditor()}},{key:"getName",value:function(){return this.name}},{key:"setImageProperties",value:function(t,e){this.graphics.setImageProperties(t,e)}},{key:"setCanvasCssDimension",value:function(t){this.graphics.setCanvasCssDimension(t)}},{key:"setCanvasBackstoreDimension",value:function(t){this.graphics.setCanvasBackstoreDimension(t)}},{key:"adjustCanvasDimension",value:function(){this.graphics.adjustCanvasDimension()}},{key:"adjustCanvasDimensionBase",value:function(){this.graphics.adjustCanvasDimensionBase()}}]),t}(),ho=uo;function fo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var go={padding:0,crossOrigin:"Anonymous"},vo=function(t){wn(i,t);var e=fo(i);function i(t){return w(this,i),e.call(this,St.IMAGE_LOADER,t)}return T(i,[{key:"load",value:function(t,e){var i,n=this;if(t||e)i=this._setBackgroundImage(e).then((function(e){return n.setCanvasImage(t,e),n.adjustCanvasDimension(),e}));else{var r=this.getCanvas();r.backgroundImage=null,r.renderAll(),i=new(L())((function(t){n.setCanvasImage("",null),t()}))}return i}},{key:"_setBackgroundImage",value:function(t){var e=this;return t?new(L())((function(i,n){var r=e.getCanvas();r.setBackgroundImage(t,(function(){var t=r.backgroundImage;t&&t.getElement()?i(t):n(hi)}),go)})):L().reject(ui)}}]),i}(ho),po=vo,mo=["tl","tr","mt","ml","mr","mb","bl","br"],yo=function(){};function bo(t,e){return t>e?"width":"height"}var xo=z.fabric.util.createClass(z.fabric.Rect,{initialize:function(t,e,i){(e=R()(e,i)).type="cropzone",this.callSuper("initialize",e),this._addEventHandler(),this.canvas=t,this.options=e},canvasEventDelegation:function(t){var e,i="unregistered";return this.canvasEventTrigger[t]!==yo?i="registered":o()(e=[Jt,Qt]).call(e,t)<0&&(i="none"),i},canvasEventRegister:function(t,e){this.canvasEventTrigger[t]=e},_addEventHandler:function(){var t,e,i,n,r;this.canvasEventTrigger=(S(t={},Jt,yo),S(t,Qt,yo),t),this.on({moving:A()(e=this._onMoving).call(e,this),scaling:A()(i=this._onScaling).call(i,this)}),z.fabric.util.addListener(document,"keydown",A()(n=this._onKeyDown).call(n,this)),z.fabric.util.addListener(document,"keyup",A()(r=this._onKeyUp).call(r,this))},_renderCropzone:function(t){var e=this.flipX?-1:1,i=this.flipY?-1:1,n=e/this.scaleX,r=i/this.scaleY;t.scale(n,r),this._fillOuterRect(t,"rgba(0, 0, 0, 0.5)"),this.options.lineWidth?(this._fillInnerRect(t),this._strokeBorder(t,"rgb(255, 255, 255)",{lineWidth:this.options.lineWidth})):(this._strokeBorder(t,"rgb(0, 0, 0)",{lineDashWidth:7}),this._strokeBorder(t,"rgb(255, 255, 255)",{lineDashWidth:7,lineDashOffset:7})),t.scale(1/n,1/r)},_render:function(t){this.callSuper("_render",t),this._renderCropzone(t)},_fillOuterRect:function(t,e){var i=this._getCoordinates(),n=i.x,r=i.y;t.save(),t.fillStyle=e,t.beginPath(),t.moveTo(n[0]-1,r[0]-1),t.lineTo(n[3]+1,r[0]-1),t.lineTo(n[3]+1,r[3]+1),t.lineTo(n[0]-1,r[3]+1),t.lineTo(n[0]-1,r[0]-1),t.closePath(),t.moveTo(n[1],r[1]),t.lineTo(n[1],r[2]),t.lineTo(n[2],r[2]),t.lineTo(n[2],r[1]),t.lineTo(n[1],r[1]),t.closePath(),nt()(t).call(t),t.restore()},_fillInnerRect:function(t){var e=this._getCoordinates(),i=e.x,n=e.y,r=this._caculateInnerPosition(i,(i[2]-i[1])/3),o=this._caculateInnerPosition(n,(n[2]-n[1])/3);t.save(),t.strokeStyle="rgba(255, 255, 255, 0.7)",t.lineWidth=this.options.lineWidth,t.beginPath(),t.moveTo(r[0],o[1]),t.lineTo(r[3],o[1]),t.moveTo(r[0],o[2]),t.lineTo(r[3],o[2]),t.moveTo(r[1],o[0]),t.lineTo(r[1],o[3]),t.moveTo(r[2],o[0]),t.lineTo(r[2],o[3]),t.stroke(),t.closePath(),t.restore()},_caculateInnerPosition:function(t,e){var i=[];return i[0]=t[1],i[1]=t[1]+e,i[2]=t[1]+2*e,i[3]=t[2],i},_getCoordinates:function(){var t,e,i=this.canvas,n=this.width,r=this.height,o=this.left,a=this.top,s=n/2,c=r/2,l=i.getHeight(),u=i.getWidth();return{x:pn()(t=[-(s+o),-s,s,s+(u-o-n)]).call(t,Math.ceil),y:pn()(e=[-(c+a),-c,c,c+(l-a-r)]).call(e,Math.ceil)}},_strokeBorder:function(t,e,i){var n=i.lineDashWidth,r=i.lineDashOffset,o=i.lineWidth,a=this.width/2,s=this.height/2;t.save(),t.strokeStyle=e,t.setLineDash&&t.setLineDash([n,n]),r&&(t.lineDashOffset=r),o&&(t.lineWidth=o),t.beginPath(),t.moveTo(-a,-s),t.lineTo(a,-s),t.lineTo(a,s),t.lineTo(-a,s),t.lineTo(-a,-s),t.stroke(),t.restore()},_onMoving:function(){var t=this.height,e=this.width,i=this.left,n=this.top,r=this.canvas.getWidth()-e,o=this.canvas.getHeight()-t;this.left=Ni(i,0,r),this.top=Ni(n,0,o),this.canvasEventTrigger[Jt](this)},_onScaling:function(t){var e=t.transform.corner,i=this.canvas.getPointer(t.e),n=this._calcScalingSizeFromPointer(i,e);this.scale(1).set(n),this.canvasEventTrigger[Qt](this)},_calcScalingSizeFromPointer:function(t,e){var i=function(t){return o()(mo).call(mo,t)>=0}(e);return i&&this._resizeCropZone(t,e)},adjustRatioCropzoneSize:function(t){var e=t.width,i=t.height,n=t.leftMaker,r=t.topMaker,o=t.maxWidth,a=t.maxHeight,s=t.scaleTo;if(e=o?Ni(e,1,o):e,i=a?Ni(i,1,a):i,!this.presetRatio)return this._withShiftKey&&(e>i?i=e:i>e&&(e=i)),{width:e,height:i,left:n(e),top:r(i)};"width"===s?i=e/this.presetRatio:e=i*this.presetRatio;var c=Math.min(o/e,a/i);if(c<=1){var l,u=Q(pn()(l=[e,i]).call(l,(function(t){return t*c})),2);e=u[0],i=u[1]}return{width:e,height:i,left:n(e),top:r(i)}},_getCropzoneRectInfo:function(){var t=this.canvas,e=t.width,i=t.height,n=this.getBoundingRect(!1,!0),r=n.top,o=n.left,a=n.width,s=n.height;return{rectTop:r,rectLeft:o,rectWidth:a,rectHeight:s,rectRight:o+a,rectBottom:r+s,canvasWidth:e,canvasHeight:i}},_resizeCropZone:function(t,e){var i=t.x,n=t.y,r=this._getCropzoneRectInfo(),o=r.rectWidth,a=r.rectHeight,s=r.rectTop,c=r.rectLeft,l=r.rectBottom,u=r.rectRight,h=r.canvasWidth,f=r.canvasHeight,g={tl:{width:u-i,height:l-n,leftMaker:function(t){return u-t},topMaker:function(t){return l-t},maxWidth:u,maxHeight:l,scaleTo:bo(c-i,s-n)},tr:{width:i-c,height:l-n,leftMaker:function(){return c},topMaker:function(t){return l-t},maxWidth:h-c,maxHeight:l,scaleTo:bo(i-u,s-n)},mt:{width:o,height:l-n,leftMaker:function(){return c},topMaker:function(t){return l-t},maxWidth:h-c,maxHeight:l,scaleTo:"height"},ml:{width:u-i,height:a,leftMaker:function(t){return u-t},topMaker:function(){return s},maxWidth:u,maxHeight:f-s,scaleTo:"width"},mr:{width:i-c,height:a,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:"width"},mb:{width:o,height:n-s,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:"height"},bl:{width:u-i,height:n-s,leftMaker:function(t){return u-t},topMaker:function(){return s},maxWidth:u,maxHeight:f-s,scaleTo:bo(c-i,n-l)},br:{width:i-c,height:n-s,leftMaker:function(){return c},topMaker:function(){return s},maxWidth:h-c,maxHeight:f-s,scaleTo:bo(i-u,n-l)}};return this.adjustRatioCropzoneSize(g[e])},isValid:function(){return this.left>=0&&this.top>=0&&this.width>0&&this.height>0},_onKeyDown:function(t){t.keyCode===Ke&&(this._withShiftKey=!0)},_onKeyUp:function(t){t.keyCode===Ke&&(this._withShiftKey=!1)}}),Co=xo;function Io(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var _o={presetRatio:null,top:-10,left:-10,height:1,width:1},Mo=function(t){wn(i,t);var e=Io(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.CROPPER,t))._cropzone=null,c._startX=null,c._startY=null,c._withShiftKey=!1,c._listeners={keydown:A()(n=c._onKeyDown).call(n,Dn(c)),keyup:A()(r=c._onKeyUp).call(r,Dn(c)),mousedown:A()(o=c._onFabricMouseDown).call(o,Dn(c)),mousemove:A()(a=c._onFabricMouseMove).call(a,Dn(c)),mouseup:A()(s=c._onFabricMouseUp).call(s,Dn(c))},c}return T(i,[{key:"start",value:function(){if(!this._cropzone){var t=this.getCanvas();t.forEachObject((function(t){t.evented=!1})),this._cropzone=new Co(t,R()({left:0,top:0,width:.5,height:.5,strokeWidth:0,cornerSize:10,cornerColor:"black",fill:"transparent"},wt,this.graphics.cropSelectionStyle)),t.discardActiveObject(),t.add(this._cropzone),t.on("mouse:down",this._listeners.mousedown),t.selection=!1,t.defaultCursor="crosshair",z.fabric.util.addListener(document,"keydown",this._listeners.keydown),z.fabric.util.addListener(document,"keyup",this._listeners.keyup)}}},{key:"end",value:function(){var t=this.getCanvas(),e=this._cropzone;e&&(t.remove(e),t.selection=!0,t.defaultCursor="default",t.off("mouse:down",this._listeners.mousedown),t.forEachObject((function(t){t.evented=!0})),this._cropzone=null,z.fabric.util.removeListener(document,"keydown",this._listeners.keydown),z.fabric.util.removeListener(document,"keyup",this._listeners.keyup))}},{key:"changeVisibility",value:function(t){this._cropzone&&this._cropzone.set({visible:t})}},{key:"_onFabricMouseDown",value:function(t){var e=this.getCanvas();if(!t.target){e.selection=!1;var i=e.getPointer(t.e);this._startX=i.x,this._startY=i.y,e.on({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup})}}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e),n=i.x,r=i.y,o=this._cropzone;Math.abs(n-this._startX)+Math.abs(r-this._startY)>10&&(e.remove(o),o.set(this._calcRectDimensionFromPoint(n,r,o.presetRatio)),e.add(o),e.setActiveObject(o))}},{key:"_calcRectDimensionFromPoint",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.getCanvas(),r=n.getWidth(),o=n.getHeight(),a=this._startX,s=this._startY,c=Ni(t,0,a),l=Ni(e,0,s),u=Ni(t,a,r)-c,h=Ni(e,s,o)-l;return this._withShiftKey&&!i?(u>h?h=u:h>u&&(u=h),a>=t&&(c=a-u),s>=e&&(l=s-h)):i&&(h=u/i,a>=t&&(c=Ni(a-u,0,r)),s>=e&&(l=Ni(s-h,0,o)),l+h>o&&(u=(h=o-l)*i,a>=t&&(c=Ni(a-u,0,r)),s>=e&&(l=Ni(s-h,0,o)))),{left:c,top:l,width:u,height:h}}},{key:"_onFabricMouseUp",value:function(){var t=this._cropzone,e=this._listeners,i=this.getCanvas();i.setActiveObject(t),i.off({"mouse:move":e.mousemove,"mouse:up":e.mouseup})}},{key:"getCroppedImageData",value:function(t){var e=this.getCanvas(),i=e.contains(this._cropzone);if(!t)return null;i&&e.remove(this._cropzone);var n={imageName:this.getImageName(),url:e.toDataURL(t)};return i&&e.add(this._cropzone),n}},{key:"getCropzoneRect",value:function(){var t=this._cropzone;return t.isValid()?{left:t.left,top:t.top,width:t.width,height:t.height}:null}},{key:"setCropzoneRect",value:function(t){var e=this.getCanvas(),i=this._cropzone;e.discardActiveObject(),e.selection=!1,e.remove(i),i.set(t?this._getPresetPropertiesForCropSize(t):_o),e.add(i),e.selection=!0,t&&e.setActiveObject(i)}},{key:"_getPresetPropertiesForCropSize",value:function(t){var e,i,n=this.getCanvas(),r=n.getWidth(),o=n.getHeight(),a=r>=o?r:o,s=function(t,e){return t>e?e/t:1},c=a*t,l=a,u=s(c,r),h=Q(pn()(e=[c,l]).call(e,(function(t){return t*u})),2);c=h[0];var f=s(l=h[1],o),g=Q(pn()(i=[c,l]).call(i,(function(t){return Number((t*f).toFixed(2))})),2);return c=g[0],{presetRatio:t,top:(o-(l=g[1]))/2,left:(r-c)/2,width:c,height:l}}},{key:"_onKeyDown",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!0)}},{key:"_onKeyUp",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!1)}}]),i}(ho),So=Mo;function wo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ko=function(t){wn(i,t);var e=wo(i);function i(t){return w(this,i),e.call(this,St.FLIP,t)}return T(i,[{key:"getCurrentSetting",value:function(){var t=this.getCanvasImage();return{flipX:t.flipX,flipY:t.flipY}}},{key:"set",value:function(t){var e=this.getCurrentSetting(),i=e.flipX!==t.flipX,n=e.flipY!==t.flipY;return i||n?(R()(e,t),this.setImageProperties(e,!0),this._invertAngle(i,n),this._flipObjects(i,n),L().resolve({flipX:e.flipX,flipY:e.flipY,angle:this.getCanvasImage().angle})):L().reject(si)}},{key:"_invertAngle",value:function(t,e){var i=this.getCanvasImage(),n=i.angle;t&&(n*=-1),e&&(n*=-1),i.rotate(dn()(n)).setCoords()}},{key:"_flipObjects",value:function(t,e){var i=this.getCanvas();t&&i.forEachObject((function(t){t.set({angle:dn()(-1*t.angle),flipX:!t.flipX,left:i.width-t.left}).setCoords()})),e&&i.forEachObject((function(t){t.set({angle:dn()(-1*t.angle),flipY:!t.flipY,top:i.height-t.top}).setCoords()})),i.renderAll()}},{key:"reset",value:function(){return this.set({flipX:!1,flipY:!1})}},{key:"flipX",value:function(){var t=this.getCurrentSetting();return this.set({flipX:!t.flipX,flipY:t.flipY})}},{key:"flipY",value:function(){var t=this.getCurrentSetting();return this.set({flipX:t.flipX,flipY:!t.flipY})}}]),i}(ho),To=ko;function Do(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ao=function(t){wn(i,t);var e=Do(i);function i(t){return w(this,i),e.call(this,St.ROTATION,t)}return T(i,[{key:"getCurrentAngle",value:function(){return this.getCanvasImage().angle}},{key:"setAngle",value:function(t){var e=this.getCurrentAngle()%360;t%=360;var i=this.getCanvasImage(),n=i.getCenterPoint();i.set({angle:t}).setCoords(),this.adjustCanvasDimension();var r=i.getCenterPoint();return this._rotateForEachObject(n,r,t-e),L().resolve(t)}},{key:"_rotateForEachObject",value:function(t,e,i){var n=this.getCanvas(),r=t.x-e.x,o=t.y-e.y;n.forEachObject((function(e){var n=e.getCenterPoint(),a=z.fabric.util.degreesToRadians(i),s=z.fabric.util.rotatePoint(n,t,a);e.set({left:s.x-r,top:s.y-o,angle:(e.angle+i)%360}),e.setCoords()})),n.renderAll()}},{key:"rotate",value:function(t){var e=this.getCurrentAngle();return this.setAngle(e+t)}}]),i}(ho),jo=Ao,Oo=n(7567);function Eo(t,e,i,n,r,o,a){try{var s=t[o](a),c=s.value}catch(t){return void i(t)}s.done?e(c):Oo.resolve(c).then(n,r)}var Lo=n(261),No=n.n(Lo);function Po(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var zo=function(t){wn(r,t);var e,i,n=Po(r);function r(t){var e,i,o,a;return w(this,r),(a=n.call(this,St.FREE_DRAWING,t)).width=12,a.oColor=new z.fabric.Color("rgba(0, 0, 0, 0.5)"),a._handlers={mousedown:A()(e=a._onFabricMouseDown).call(e,Dn(a)),mousemove:A()(i=a._onFabricMouseMove).call(i,Dn(a)),mouseup:A()(o=a._onMasikMouseUp).call(o,Dn(a))},a.imageEditor=null,a}return T(r,[{key:"start",value:function(t){if(console.log(t),null!=t&&t.mosaic)this.setMosaic(t);else{var e=this.getCanvas();console.log(e),e.isDrawingMode=!0,this.setBrush(t)}}},{key:"setBrush",value:function(t){var e=this.getCanvas().freeDrawingBrush;t=t||{},this.width=t.width||this.width,t.color&&(this.oColor=new z.fabric.Color(t.color)),e.width=this.width,e.color=this.oColor.toRgba()}},{key:"end",value:function(){var t=this.getCanvas();t.isDrawingMode=!1,t.selection=!0,t.off("mouse:down",this._handlers.mousedown)}},{key:"setMosaic",value:function(t){this.imageEditor=t.imageEditor,this.width=t.width;var e=this.getCanvas();e.selection=!1,e.on("mouse:down",this._handlers.mousedown)}},{key:"_onFabricMouseDown",value:function(){this.getCanvas().on({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=this.width,n=this.width/2,r=e.getPointer(t.e);console.log(r);var o=r.x-n;console.log(o);for(var a=r.y-n,s=e.contextContainer,c=s.getImageData(o,a,i,i),l=c.data,u=0,h=0,f=0,g=0;g<l.length;g+=4)u+=l[g],h+=l[g+1],f+=l[g+2];u=Math.floor(u/(i*i)),h=Math.floor(h/(i*i)),f=Math.floor(f/(i*i));for(var d=0;d<l.length;d+=4)l[d]=u,l[d+1]=h,l[d+2]=f,l[d+3]=255;s.putImageData(c,o,a)}},{key:"_onMasikMouseUp",value:(e=No().mark((function t(){var e,i,n,r,o,a,s;return No().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=document.getElementsByClassName("lower-canvas"),i=Q(e,1),n=i[0],r=n.toDataURL(),t.next=5,fetch(r);case 5:return o=t.sent,t.next=8,o.blob();case 8:a=t.sent,s=P().createObjectURL(a),this.imageEditor.invoke("addImageObject",s),this.getCanvas().off({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup});case 13:case"end":return t.stop()}}),t,this)})),i=function(){var t=this,i=arguments;return new Oo((function(n,r){var o=e.apply(t,i);function a(t){Eo(o,n,r,a,s,"next",t)}function s(t){Eo(o,n,r,a,s,"throw",t)}a(void 0)}))},function(){return i.apply(this,arguments)})}]),r}(ho),Bo=zo,Ro=z.fabric.util.createClass(z.fabric.Line,{type:"line",initialize:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.callSuper("initialize",t,e),this.arrowType=e.arrowType},_render:function(t){var e=this.calcLinePoints(),i={fromX:e.x1,fromY:e.y1,toX:e.x2,toY:e.y2};this.ctx=t,t.lineWidth=this.strokeWidth,this._renderBasicLinePath(i),this._drawDecoratorPath(i),this._renderStroke(t)},_renderBasicLinePath:function(t){var e=t.fromX,i=t.fromY,n=t.toX,r=t.toY;this.ctx.beginPath(),this.ctx.moveTo(e,i),this.ctx.lineTo(n,r)},_drawDecoratorPath:function(t){this._drawDecoratorPathType("head",t),this._drawDecoratorPathType("tail",t)},_drawDecoratorPathType:function(t,e){switch(this.arrowType[t]){case"triangle":this._drawTrianglePath(t,e);break;case"chevron":this._drawChevronPath(t,e)}},_drawTrianglePath:function(t,e){var i=1.7*this.ctx.lineWidth;this._drawChevronPath(t,e,i),this.ctx.closePath()},_drawChevronPath:function(t,e,i){var n=this,r=e.fromX,o=e.fromY,a=e.toX,s=e.toY,c=this.ctx;i||(i=2.7*this.ctx.lineWidth);var l=Q("head"===t?[r,o]:[a,s],2),u=l[0],h=l[1],f=Q("head"===t?[a,s]:[r,o],2),g=f[0],d=f[1],v=180*Math.atan2(d-h,g-u)/Math.PI,p=function(t){return n.getRotatePosition(i,t,{x:u,y:h})};c.moveTo.apply(c,_(p(v+30))),c.lineTo(u,h),c.lineTo.apply(c,_(p(v-30)))},getRotatePosition:function(t,e,i){var n=e*Math.PI/180,r=i.x,o=i.y;return[t*Math.cos(n)+r,t*Math.sin(n)+o]}}),Fo=Ro;function Yo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Wo=function(t){wn(i,t);var e=Yo(i);function i(t){var n,r,o,a;return w(this,i),(a=e.call(this,St.LINE,t))._width=12,a._oColor=new z.fabric.Color("rgba(0, 0, 0, 0.5)"),a._listeners={mousedown:A()(n=a._onFabricMouseDown).call(n,Dn(a)),mousemove:A()(r=a._onFabricMouseMove).call(r,Dn(a)),mouseup:A()(o=a._onFabricMouseUp).call(o,Dn(a))},a}return T(i,[{key:"setHeadOption",value:function(t){var e=t.arrowType,i=void 0===e?{head:null,tail:null}:e;this._arrowType=i}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.getCanvas();e.defaultCursor="crosshair",e.selection=!1,this.setHeadOption(t),this.setBrush(t),e.forEachObject((function(t){t.set({evented:!1})})),e.on({"mouse:down":this._listeners.mousedown})}},{key:"setBrush",value:function(t){var e=this.getCanvas().freeDrawingBrush;t=t||{},this._width=t.width||this._width,t.color&&(this._oColor=new z.fabric.Color(t.color)),e.width=this._width,e.color=this._oColor.toRgba()}},{key:"end",value:function(){var t=this.getCanvas();t.defaultCursor="default",t.selection=!0,t.forEachObject((function(t){t.set({evented:!0})})),t.off("mouse:down",this._listeners.mousedown)}},{key:"_onFabricMouseDown",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e),n=i.x,r=i.y,o=[n,r,n,r];this._line=new Fo(o,{stroke:this._oColor.toRgba(),strokeWidth:this._width,arrowType:this._arrowType,evented:!1}),this._line.set(oi),e.add(this._line),e.on({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup}),this.fire(oe,this._createLineEventObjectProperties())}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas(),i=e.getPointer(t.e);this._line.set({x2:i.x,y2:i.y}),this._line.setCoords(),e.renderAll()}},{key:"_onFabricMouseUp",value:function(){var t=this.getCanvas();this.fire(qt,this._createLineEventObjectProperties()),this._line=null,t.off({"mouse:move":this._listeners.mousemove,"mouse:up":this._listeners.mouseup})}},{key:"_createLineEventObjectProperties",value:function(){var t=this.graphics.createObjectProperties(this._line),e=this._line,i=e.x1,n=e.x2,r=e.y1,o=e.y2;return R()({},t,{startPosition:{x:i,y:r},endPosition:{x:n,y:o}})}}]),i}(ho),Ho=Wo;function Uo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Go={fill:"#000000",left:0,top:0},Xo={fill:"#000000",fontStyle:"normal",fontWeight:"normal",textAlign:"tie-text-align-left",underline:!1},Zo=function(t){wn(i,t);var e=Uo(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.TEXT,t))._defaultStyles=Go,c._isSelected=!1,c._selectedObj={},c._editingObj={},c._listeners={mousedown:A()(n=c._onFabricMouseDown).call(n,Dn(c)),select:A()(r=c._onFabricSelect).call(r,Dn(c)),selectClear:A()(o=c._onFabricSelectClear).call(o,Dn(c)),scaling:A()(a=c._onFabricScaling).call(a,Dn(c)),textChanged:A()(s=c._onFabricTextChanged).call(s,Dn(c))},c._textarea=null,c._ratio=1,c._lastClickTime=(new Date).getTime(),c._editingObjInfos={},c.isPrevEditing=!1,c}return T(i,[{key:"start",value:function(){var t=this,e=this.getCanvas();e.selection=!1,e.defaultCursor="text",e.on({"mouse:down":this._listeners.mousedown,"selection:created":this._listeners.select,"selection:updated":this._listeners.select,"before:selection:cleared":this._listeners.selectClear,"object:scaling":this._listeners.scaling,"text:changed":this._listeners.textChanged}),e.forEachObject((function(e){"i-text"===e.type&&t.adjustOriginPosition(e,"start")})),this.setCanvasRatio()}},{key:"end",value:function(){var t=this,e=this.getCanvas();e.selection=!0,e.defaultCursor="default",e.forEachObject((function(i){"i-text"===i.type&&(""===i.text?e.remove(i):t.adjustOriginPosition(i,"end"))})),e.off({"mouse:down":this._listeners.mousedown,"selection:created":this._listeners.select,"selection:updated":this._listeners.select,"before:selection:cleared":this._listeners.selectClear,"object:selected":this._listeners.select,"object:scaling":this._listeners.scaling,"text:changed":this._listeners.textChanged})}},{key:"adjustOriginPosition",value:function(t,e){var i="center",n="center";"start"===e&&(i="left",n="top");var r=t.getPointByOrigin(i,n),o=r.x,a=r.y;t.set({left:o,top:a,originX:i,originY:n}),t.setCoords()}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n){var r,o=i.getCanvas(),a=null,s=oi,c=i._defaultStyles;i._setInitPos(e.position),e.styles&&(c=R()(c,e.styles)),Dr()(e.autofocus)||(e.autofocus=!0),a=new z.fabric.IText(t,c),s=R()({},s,{originX:"left",originY:"top"}),a.set(s),a.on({mouseup:A()(r=i._onFabricMouseUp).call(r,i)}),o.add(a),e.autofocus&&(a.enterEditing(),a.selectAll()),o.getActiveObject()||o.setActiveObject(a),i.isPrevEditing=!0,n(i.graphics.createObjectProperties(a))}))}},{key:"change",value:function(t,e){var i=this;return new(L())((function(n){t.set("text",e),i.getCanvas().renderAll(),n()}))}},{key:"setStyle",value:function(t,e){var i=this;return new(L())((function(n){H()(e,(function(i,n){t[n]===i&&"fontSize"!==n&&(e[n]=Xo[n]||"")}),i),"textDecoration"in e&&R()(e,i._getTextDecorationAdaptObject(e.textDecoration)),t.set(e),i.getCanvas().renderAll(),n()}))}},{key:"getText",value:function(t){return t.text}},{key:"setSelectedInfo",value:function(t,e){this._selectedObj=t,this._isSelected=e}},{key:"isSelected",value:function(){return this._isSelected}},{key:"getSelectedObj",value:function(){return this._selectedObj}},{key:"setCanvasRatio",value:function(){var t=this.getCanvasElement(),e=$()(t.style.maxWidth,10),i=t.width;this._ratio=i/e}},{key:"getCanvasRatio",value:function(){return this._ratio}},{key:"_getTextDecorationAdaptObject",value:function(t){return{underline:"underline"===t,linethrough:"line-through"===t,overline:"overline"===t}}},{key:"_setInitPos",value:function(t){t=t||this.getCanvasImage().getCenterPoint(),this._defaultStyles.left=t.x,this._defaultStyles.top=t.y}},{key:"_onInput",value:function(){var t=this.getCanvasRatio(),e=this._editingObj,i=this._textarea.style;i.width="".concat(Math.ceil(e.width/t),"px"),i.height="".concat(Math.ceil(e.height/t),"px")}},{key:"_onKeyDown",value:function(){var t=this,e=this.getCanvasRatio(),i=this._editingObj,n=this._textarea.style;v()((function(){i.text(t._textarea.value),n.width="".concat(Math.ceil(i.width/e),"px"),n.height="".concat(Math.ceil(i.height/e),"px")}),0)}},{key:"_onBlur",value:function(){var t=this.getCanvasRatio(),e=this._editingObj,i=this._editingObjInfos,n=this._textarea.value,r=e.width/t-i.width/t,o=e.height/t-i.height/t;if(1===t&&(r/=2,o/=2),this._textarea.style.display="none",e.set({left:i.left+r,top:i.top+o}),n.length){this.getCanvas().add(e);var a={id:Ei(e),type:e.type,text:n};this.fire(ee,a)}}},{key:"_onScroll",value:function(){this._textarea.scrollLeft=0,this._textarea.scrollTop=0}},{key:"_onFabricScaling",value:function(t){var e=t.target;e.fontSize=e.fontSize*e.scaleY,e.scaleX=1,e.scaleY=1}},{key:"_onFabricTextChanged",value:function(t){this.fire(ee,t.target)}},{key:"_onFabricSelectClear",value:function(t){var e=this.getSelectedObj();this.isPrevEditing=!0,this.setSelectedInfo(t.target,!1),e&&""===e.text&&this.getCanvas().remove(e)}},{key:"_onFabricSelect",value:function(t){console.log("ssssssss"),this.isPrevEditing=!0,this.setSelectedInfo(t.target,!0)}},{key:"_onFabricMouseDown",value:function(t){var e=t.target;e&&!e.isType("text")||this._fireAddText(t)}},{key:"_fireAddText",value:function(t){var e=t.target,i=t.e||{},n=this.getCanvas().getPointer(i);e||this.fire(re,{originPosition:{x:n.x,y:n.y},clientPosition:{x:i.clientX||0,y:i.clientY||0}})}},{key:"_onFabricMouseUp",value:function(t){var e=t.target,i=(new Date).getTime();this._isDoubleClick(i)&&!e.isEditing&&e.enterEditing(),e.isEditing&&this.fire(te),this._lastClickTime=i}},{key:"_isDoubleClick",value:function(t){return t-this._lastClickTime<500}}]),i}(ho),Vo=Zo;function Jo(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Qo={arrow:"M 0 90 H 105 V 120 L 160 60 L 105 0 V 30 H 0 Z",cancel:"M 0 30 L 30 60 L 0 90 L 30 120 L 60 90 L 90 120 L 120 90 L 90 60 L 120 30 L 90 0 L 60 30 L 30 0 Z"},Ko=function(t){wn(i,t);var e=Jo(i);function i(t){var n,r,o,a;return w(this,i),(a=e.call(this,St.ICON,t))._oColor="#000000",a._pathMap=Qo,a._type=null,a._iconColor=null,a._handlers={mousedown:A()(n=a._onFabricMouseDown).call(n,Dn(a)),mousemove:A()(r=a._onFabricMouseMove).call(r,Dn(a)),mouseup:A()(o=a._onFabricMouseUp).call(o,Dn(a))},a}return T(i,[{key:"setStates",value:function(t,e){this._type=t,this._iconColor=e}},{key:"start",value:function(){var t=this.getCanvas();t.selection=!1,t.on("mouse:down",this._handlers.mousedown)}},{key:"end",value:function(){var t=this.getCanvas();t.selection=!0,t.off({"mouse:down":this._handlers.mousedown})}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n,r){var o=i.getCanvas(),a=i._pathMap[t],s=oi,c=a?i._createIcon(a):null;i._icon=c,c||r(ci),c.set(R()({type:"icon",fill:i._oColor},s,e,i.graphics.controlStyle)),o.add(c).setActiveObject(c),n(i.graphics.createObjectProperties(c))}))}},{key:"registerPaths",value:function(t){var e=this;H()(t,(function(t,i){e._pathMap[i]=t}),this)}},{key:"setColor",value:function(t,e){this._oColor=t,e&&"icon"===e.get("type")&&(e.set({fill:this._oColor}),this.getCanvas().renderAll())}},{key:"getColor",value:function(t){return nt()(t)}},{key:"_createIcon",value:function(t){return new z.fabric.Path(t)}},{key:"_onFabricMouseDown",value:function(t){var e=this,i=this.getCanvas();this._startPoint=i.getPointer(t.e);var n=this._startPoint,r=n.x,o=n.y;this.add(this._type,{left:r,top:o,fill:this._iconColor}).then((function(){e.fire(oe,e.graphics.createObjectProperties(e._icon)),i.on("mouse:move",e._handlers.mousemove),i.on("mouse:up",e._handlers.mouseup)}))}},{key:"_onFabricMouseMove",value:function(t){var e=this.getCanvas();if(this._icon){var i=e.getPointer(t.e),n=(i.x-this._startPoint.x)/this._icon.width,r=(i.y-this._startPoint.y)/this._icon.height;this._icon.set({scaleX:Math.abs(2*n),scaleY:Math.abs(2*r)}),this._icon.setCoords(),e.renderAll()}}},{key:"_onFabricMouseUp",value:function(){var t=this.getCanvas();this.fire(qt,this.graphics.createObjectProperties(this._icon)),this._icon=null,t.off("mouse:down",this._handlers.mousedown),t.off("mouse:move",this._handlers.mousemove),t.off("mouse:up",this._handlers.mouseup)}}]),i}(ho),qo=Ko,$o=z.fabric.util.createClass(z.fabric.Image.filters.BlendImage,{applyTo:function(t){if(this.mask){var e=t.canvasEl,i=e.width,n=e.height,r=this._createCanvasOfMask(i,n),o=e.getContext("2d"),a=r.getContext("2d"),s=o.getImageData(0,0,i,n);this._drawMask(a,e,o),this._mapData(a,s,i,n),t.imageData=s}},_createCanvasOfMask:function(t,e){var i=z.fabric.util.createCanvasElement();return i.width=t,i.height=e,i},_drawMask:function(t){var e=this.mask,i=e.getElement(),n=e.angle,r=e.left,o=e.scaleX,a=e.scaleY,s=e.top;t.save(),t.translate(r,s),t.rotate(n*Math.PI/180),t.scale(o,a),t.drawImage(i,-i.width/2,-i.height/2),t.restore()},_mapData:function(t,e,i,n){for(var r=e.data,o=e.height,a=r,s=e.width*o*4,c=t.getImageData(0,0,i,n).data,l=0;l<s;l+=4)a[l+3]=c[l]}}),ta=$o,ea=z.fabric.util.createClass(z.fabric.Image.filters.Convolute,{type:"Sharpen",initialize:function(){this.matrix=[0,-1,0,-1,5,-1,0,-1,0]}}),ia=z.fabric.util.createClass(z.fabric.Image.filters.Convolute,{type:"Emboss",initialize:function(){this.matrix=[1,1,1,1,.7,-1,-1,-1,-1]}}),na=z.fabric.util.createClass(z.fabric.Image.filters.BaseFilter,{type:"ColorFilter",initialize:function(t){t||(t={}),this.color=t.color||"#FFFFFF",this.threshold=t.threshold||45,this.x=t.x||null,this.y=t.y||null},applyTo:function(t){var e,i,n=t.canvasEl,r=n.getContext("2d"),o=r.getImageData(0,0,n.width,n.height),a=o.data,s=this.threshold,c=z.fabric.Color.sourceFromHex(this.color);for(this.x&&this.y&&(c=this._getColor(o,this.x,this.y)),e=0,i=a.length;e<i;e+=4)this._isOutsideThreshold(a[e],c[0],s)||this._isOutsideThreshold(a[e+1],c[1],s)||this._isOutsideThreshold(a[e+2],c[2],s)||(a[e]=a[e+1]=a[e+2]=a[e+3]=0);r.putImageData(o,0,0)},_isOutsideThreshold:function(t,e,i){var n=t-e;return Math.abs(n)>i},_getColor:function(t,e,i){var n=[0,0,0,0],r=t.data,o=4*(t.width*i+e);return n[0]=r[o],n[1]=r[o+1],n[2]=r[o+2],n[3]=r[o+3],n}});function ra(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var oa=z.fabric.Image.filters;oa.Mask=ta,oa.Sharpen=ea,oa.Emboss=ia,oa.ColorFilter=na;var aa,sa,ca,la=function(t){wn(i,t);var e=ra(i);function i(t){return w(this,i),e.call(this,St.FILTER,t)}return T(i,[{key:"add",value:function(t,e){var i=this;return new(L())((function(n,r){var o=i._getSourceImage(),a=i.getCanvas(),s=i._getFilter(o,t);s||(s=i._createFilter(o,t,e)),s||r(ci),i._changeFilterValues(s,e),i._apply(o,(function(){a.renderAll(),n({type:t,action:"add",options:e})}))}))}},{key:"remove",value:function(t){var e=this;return new(L())((function(i,n){var r=e._getSourceImage(),o=e.getCanvas(),a=e.getOptions(t);r.filters.length||n(vi),e._removeFilter(r,t),e._apply(r,(function(){o.renderAll(),i({type:t,action:"remove",options:a})}))}))}},{key:"hasFilter",value:function(t){return!!this._getFilter(this._getSourceImage(),t)}},{key:"getOptions",value:function(t){var e=this._getSourceImage(),i=this._getFilter(e,t);return i?R()({},i.options):null}},{key:"_changeFilterValues",value:function(t,e){H()(e,(function(e,i){Y()(t[i])||(t[i]=e)})),H()(t.options,(function(i,n){Y()(e[n])||(t.options[n]=e[n])}))}},{key:"_apply",value:function(t,e){t.filters.push(),t.applyFilters()&&e()}},{key:"_getSourceImage",value:function(){return this.getCanvasImage()}},{key:"_createFilter",value:function(t,e,i){var n,r=this._getFabricFilterType(e),o=z.fabric.Image.filters[r];return o&&((n=new o(i)).options=i,t.filters.push(n)),n}},{key:"_getFilter",value:function(t,e){var i=null;if(t){var n,r,o=this._getFabricFilterType(e),a=t.filters.length;for(r=0;r<a;r+=1)if((n=t.filters[r]).type===o){i=n;break}}return i}},{key:"_removeFilter",value:function(t,e){var i,n=this._getFabricFilterType(e);t.filters=no()(i=t.filters).call(i,(function(t){return t.type!==n}))}},{key:"_getFabricFilterType",value:function(t){return t.charAt(0).toUpperCase()+h()(t).call(t,1)}}]),i}(ho),ua=la,ha=n(1801),fa=n.n(ha),ga={pixelate:"blocksize",blur:"blur"},da={x:"width",y:"height"},va=(aa=ga,ca={},et()(sa=J()(aa)).call(sa,(function(t){ca[aa[t]]=t})),ca),pa=null;function ma(t){return Q(Gi(t,"patternSourceCanvas").patternSourceCanvas.getObjects(),1)[0]}function ya(t){var e=t.angle,i=t.flipX,n=t.flipY,r=ma(t),o=function(t){var e=Q(Ia(t),4),i=e[0],n=i.x,r=i.y,o=e[1],a=o.x,s=o.y,c=e[2],l=c.x,u=c.y,h=e[3],f=h.x,g=h.y,d=Math.min(n,a,l,f),v=Math.min(r,s,u,g),p=Math.max(n,a,l,f),m=Math.max(r,s,u,g);return{left:d,top:v,right:p,bottom:m,width:p-d,height:m-v}}(t),a=o.right,s=o.bottom,c=o.width,l=o.height,u=(c-t.width)/2,h=(l-t.height)/2,f=t.left-t.width/2-u,g=t.top-t.height/2-h,d=c/2-u,v=l/2-h,p=Math.max(c,l)+Math.max(u,h),m=function(t){var e=t.shapeObj,i=t.left,n=t.top,r=t.width,o=t.height,a=t.cropX,s=t.cropY,c=t.flipX,l=t.flipY,u=t.right,h=t.bottom,f=function(t,i,n,r){return function(t){var e=t.type,i=t.shapeObj,n=t.outDistance,r=t.left,o=t.top,a=t.flipX,s=t.flipY,c=Ia(i),l=function(t,e,i){var n=0,r=0;H()(e,(function(e,i){e[t]<n&&(n=e[t],r=i)}));var o=Q(i[r],2),a=o[0],s=o[1];return{startPointIndex:r,endPointIndex1:a,endPointIndex2:s}}(e,c,[[1,2],[0,3],[0,3],[1,2]]),u=function(t,e,i){var n,r=i.startPointIndex,o=i.endPointIndex1,a=i.endPointIndex2,s="x"===t?180:270;return pn()(n=[o,a]).call(n,(function(t){var i=e[r],n=e[t],o=i.y-n.y,a=i.x-n.x;return 180*Math.atan2(o,a)/Math.PI-s}))}(e,c,l),h=l.startPointIndex,f=function(t){var e=t.outDistance,i=t.startPointIndex,n=t.flipX,r=t.flipY,o=t.reatAngles,a=e*Math.cos(o[0]*Math.PI/180),s=e*Math.cos(o[1]*Math.PI/180),c=2===i||3===i,l={top:c?a:s,left:c?s:a};(function(t,e,i){return(!e&&i||!e&&!i)&&0===t||(e&&i||e&&!i)&&1===t||(!e&&!i||!e&&i)&&2===t||(e&&!i||e&&i)&&3===t})(i,n,r)&&(l.left=-1*l.left);(function(t,e,i){return(e&&!i||!e&&!i)&&0===t||(!e&&!i||e&&!i)&&1===t||(e&&i||!e&&i)&&2===t||(!e&&i||e&&i)&&3===t})(i,n,r)&&(l.top=-1*l.top);return l}({outDistance:n,startPointIndex:h,flipX:a,flipY:s,reatAngles:u});return[r+f.left,o+f.top]}({type:t,outDistance:i,shapeObj:e,flipX:c,flipY:l,left:n,top:r})},g=r,d=o,v=Q(function(t,e){var i=e.left,n=e.top,r=e.width,o=e.height,a=e.cropX,s=e.cropY,c={width:r,height:o};return H()(["x","y"],(function(e){var r="x"===e?a:s,o=c[da[e]],l=pa[da[e]];if(o>l){var u=(o-l)/2;c[da[e]]=l;var h=Q(t(e,u,i,n),2);i=h[0],n=h[1]}if(r<0){var f=Q(t(e,r,i,n),2);i=f[0],n=f[1]}})),[i,n,c.width,c.height]}(f,{left:i,top:n,width:r,height:o,cropX:a,cropY:s}),4);i=v[0],n=v[1],r=v[2],o=v[3];var p=Q(function(t,e){var i=e.left,n=e.top,r=e.insideCanvasRealImageWidth,o=e.insideCanvasRealImageHeight,a=e.right,s=e.bottom,c=e.cropX,l=e.cropY,u=e.originalWidth,h=e.originalHeight,f=r,g=o,d=pa,v=d.width,p=d.height;a>v&&c>0&&(f=u-Math.abs(a-v));s>p&&l>0&&(g=h-Math.abs(s-p));var m={x:(r-f)/2,y:(o-g)/2};return H()(["x","y"],(function(e){var r=m[e];if(r>0){var o=Q(t(e,r,i,n),2);i=o[0],n=o[1]}})),[i,n,f,g]}(f,{left:i,top:n,insideCanvasRealImageWidth:r,insideCanvasRealImageHeight:o,right:u,bottom:h,cropX:a,cropY:s,originalWidth:g,originalHeight:d}),4);return i=p[0],n=p[1],r=p[2],o=p[3],[i,n,r,o]}({shapeObj:t,left:d,top:v,width:c,height:l,cropX:f,cropY:g,flipX:i,flipY:n,right:a,bottom:s}),y=Q(m,4);d=y[0],v=y[1],c=y[2],l=y[3],r.set({angle:i===n?-e:e,left:d,top:v,width:c,height:l,cropX:f,cropY:g,flipX:i,flipY:n}),Ui(r,{fillImageMaxSize:p})}function ba(t){var e;return pn()(e=t.filters).call(e,(function(t){var e=Q(J()(t),1)[0];return S({},va[e],t[e])}))}function xa(t,e,i){var n=_a(Ca(t),t.angle,e);i.add(n);var r={fill:new z.fabric.Pattern({source:i.getElement(),repeat:"no-repeat"})};return Ui(r,{patternSourceCanvas:i}),r}function Ca(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return pa&&!e||(pa=t.toCanvasElement()),pa}function Ia(t){return[t.getPointByOrigin("left","top"),t.getPointByOrigin("right","top"),t.getPointByOrigin("left","bottom"),t.getPointByOrigin("right","bottom")]}function _a(t,e,i){var n,r=new z.fabric.Image(t);return H()(R().apply(void 0,O()(n=[{}]).call(n,_(i))),(function(t,e){var i,n=(i=e).charAt(0).toUpperCase()+h()(i).call(i,1),o=new z.fabric.Image.filters[n](S({},ga[e],t));r.filters.push(o)})),r.applyFilters(),Ui(r,{originalAngle:e,fillImageMaxSize:Math.max(r.width,r.height)}),fa().adjustOriginToCenter(r),r}function Ma(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Sa=R()({strokeWidth:1,stroke:"#000000",fill:"#ffffff",width:1,height:1,rx:0,ry:0},{lockSkewingX:!0,lockSkewingY:!0,bringForward:!0,isRegular:!1});function wa(t,e,i){var n=nt()(t),r=Zi(nt()(t)),o=n;n.color&&(o=n.color);var a=null;if("filter"===r){var s=i();a=xa(e,no()(n),s)}else a={fill:o};return R()({},t,a)}var ka=function(t){wn(i,t);var e=Ma(i);function i(t){var n,r,o,a,s,c;return w(this,i),(c=e.call(this,St.SHAPE,t))._shapeObj=null,c._type="rect",c._options=R()({},Sa),c._isSelected=!1,c._startPoint={},c._withShiftKey=!1,c._handlers={mousedown:A()(n=c._onFabricMouseDown).call(n,Dn(c)),mousemove:A()(r=c._onFabricMouseMove).call(r,Dn(c)),mouseup:A()(o=c._onFabricMouseUp).call(o,Dn(c)),keydown:A()(a=c._onKeyDown).call(a,Dn(c)),keyup:A()(s=c._onKeyUp).call(s,Dn(c))},c}return T(i,[{key:"start",value:function(){var t=this.getCanvas();this._isSelected=!1,t.defaultCursor="crosshair",t.selection=!1,t.uniformScaling=!0,t.on({"mouse:down":this._handlers.mousedown}),z.fabric.util.addListener(document,"keydown",this._handlers.keydown),z.fabric.util.addListener(document,"keyup",this._handlers.keyup)}},{key:"end",value:function(){var t=this.getCanvas();this._isSelected=!1,t.defaultCursor="default",t.selection=!0,t.uniformScaling=!1,t.off({"mouse:down":this._handlers.mousedown}),z.fabric.util.removeListener(document,"keydown",this._handlers.keydown),z.fabric.util.removeListener(document,"keyup",this._handlers.keyup)}},{key:"setStates",value:function(t,e){this._type=t,e&&(this._options=R()(this._options,e))}},{key:"add",value:function(t,e){var i=this;return new(L())((function(n){var r=i.getCanvas(),o=i._extendOptions(e),a=i._createInstance(t,o),s=i.graphics.createObjectProperties(a);i._bindEventOnShape(a),r.add(a).setActiveObject(a),i._resetPositionFillFilter(a),n(s)}))}},{key:"change",value:function(t,e){var i=this;return new(L())((function(n,r){Ji(t)||r(pi);var o="filter"===Zi(nt()(e)),a=i.graphics,s=a.canvasImage,c=a.createStaticCanvas;t.set(o?wa(e,s,c):e),o&&i._resetPositionFillFilter(t),i.getCanvas().renderAll(),n()}))}},{key:"makeFillPropertyForUserEvent",value:function(t){var e=Vi(t),i={};if(e===dt){var n=ba(ma(t));i.type=e,i.filter=n}else i.type=vt,i.color=nt()(t)||"transparent";return i}},{key:"processForCopiedObject",value:function(t,e){if(this._bindEventOnShape(t),"filter"===Vi(t)){var i=ba(ma(e)),n=this.graphics.createStaticCanvas();t.set(xa(this.graphics.canvasImage,i,n)),this._resetPositionFillFilter(t)}}},{key:"_createInstance",value:function(t,e){var i;switch(t){case"rect":i=new z.fabric.Rect(e);break;case"circle":i=new z.fabric.Ellipse(R()({type:"circle"},e));break;case"triangle":i=new z.fabric.Triangle(e);break;default:i={}}return i}},{key:"_extendOptions",value:function(t){var e=oi,i=this.graphics,n=i.canvasImage,r=i.createStaticCanvas;return wa(t=R()({},Sa,this._options,e,t),n,r)}},{key:"_bindEventOnShape",value:function(t){var e=this,i=this.getCanvas();t.on({added:function(){e._shapeObj=this,fa().setOrigins(e._shapeObj)},selected:function(){e._isSelected=!0,e._shapeObj=this,i.uniformScaling=!0,i.defaultCursor="default",fa().setOrigins(e._shapeObj)},deselected:function(){e._isSelected=!1,e._shapeObj=null,i.defaultCursor="crosshair",i.uniformScaling=!1},modified:function(){var t=e._shapeObj;fa().adjustOriginToCenter(t),fa().setOrigins(t)},modifiedInGroup:function(i){e._fillFilterRePositionInGroupSelection(t,i)},moving:function(){e._resetPositionFillFilter(this)},rotating:function(){e._resetPositionFillFilter(this)},scaling:function(t){var n=i.getPointer(t.e),r=e._shapeObj;i.setCursor("crosshair"),fa().resize(r,n,!0),e._resetPositionFillFilter(this)}})}},{key:"_onFabricMouseDown",value:function(t){if(t.target||(this._isSelected=!1,this._shapeObj=!1),!this._isSelected&&!this._shapeObj){var e=this.getCanvas();this._startPoint=e.getPointer(t.e),e.on({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}}},{key:"_onFabricMouseMove",value:function(t){var e=this,i=this.getCanvas(),n=i.getPointer(t.e),r=this._startPoint.x,o=this._startPoint.y,a=r-n.x,s=o-n.y,c=this._shapeObj;c?(this._shapeObj.set({isRegular:this._withShiftKey}),fa().resize(c,n),i.renderAll(),this._resetPositionFillFilter(c)):this.add(this._type,{left:r,top:o,width:a,height:s}).then((function(t){e.fire(oe,t)}))}},{key:"_onFabricMouseUp",value:function(){var t=this,e=this.getCanvas(),i=this._startPoint.x,n=this._startPoint.y,r=this._shapeObj;r?r&&(fa().adjustOriginToCenter(r),this.fire(qt,this.graphics.createObjectProperties(r))):this.add(this._type,{left:i,top:n,width:20,height:20}).then((function(e){t.fire(oe,e)})),e.off({"mouse:move":this._handlers.mousemove,"mouse:up":this._handlers.mouseup})}},{key:"_onKeyDown",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!0,this._shapeObj&&(this._shapeObj.isRegular=!0))}},{key:"_onKeyUp",value:function(t){t.keyCode===Ke&&(this._withShiftKey=!1,this._shapeObj&&(this._shapeObj.isRegular=!1))}},{key:"_resetPositionFillFilter",value:function(t){if("filter"===Vi(t)){var e=Gi(t,"patternSourceCanvas").patternSourceCanvas,i=Gi(ma(t),"originalAngle").originalAngle;this.graphics.canvasImage.angle!==i&&function(t,e){var i=Gi(t,"patternSourceCanvas").patternSourceCanvas,n=Q(i.getObjects(),1)[0],r=ba(n);i.remove(n);var o=_a(Ca(e,!0),e.angle,r);i.add(o)}(t,this.graphics.canvasImage);var n=t.originX,r=t.originY;fa().adjustOriginToCenter(t),t.width*=t.scaleX,t.height*=t.scaleY,t.rx*=t.scaleX,t.ry*=t.scaleY,t.scaleX=1,t.scaleY=1,ya(t),function(t,e){var i=e.originX,n=e.originY,r=t.getPointByOrigin(i,n),o=r.x,a=r.y;t.set({left:o,top:a,originX:i,originY:n}),t.setCoords()}(t,{originX:n,originY:r}),function(t){var e=Gi(Q(t.getObjects(),1)[0],"fillImageMaxSize").fillImageMaxSize;e=Math.max(1,e),t.setDimensions({width:e,height:e}),t.renderAll()}(e)}}},{key:"_fillFilterRePositionInGroupSelection",value:function(t,e){1===e.scaleX&&1===e.scaleY||e.addWithUpdate();var i=t.angle,n=t.left,r=t.top;z.fabric.util.addTransformToObject(t,e.calcTransformMatrix()),this._resetPositionFillFilter(t),t.set({angle:i,left:n,top:r})}}]),i}(ho);function Ta(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Da={left:0,top:0,width:0,height:0,stroke:"#000000",strokeWidth:0,fill:"#000000",opacity:.4,evented:!1,selectable:!1,hoverCursor:"auto"},Aa=.0045,ja=.003,Oa=.003,Ea=.0066,La=.0044,Na=.003,Pa=ve,za=re,Ba=te,Ra=$t,Fa=ye,Ya=be,Wa=pe,Ha=me,Ua=function(t){wn(i,t);var e=Ta(i);function i(t){var n,r,o,a,s,c,l,u,h,f,g,d,v;w(this,i),(v=e.call(this,St.ZOOM,t)).zoomArea=null,v._startPoint=null,v._centerPoints=[],v.zoomLevel=1,v.zoomMode=Ue,v._listeners={startZoom:A()(n=v._onMouseDownWithZoomMode).call(n,Dn(v)),moveZoom:A()(r=v._onMouseMoveWithZoomMode).call(r,Dn(v)),stopZoom:A()(o=v._onMouseUpWithZoomMode).call(o,Dn(v)),startHand:A()(a=v._onMouseDownWithHandMode).call(a,Dn(v)),moveHand:A()(s=v._onMouseMoveWithHandMode).call(s,Dn(v)),stopHand:A()(c=v._onMouseUpWithHandMode).call(c,Dn(v)),zoomChanged:A()(l=v._changeScrollState).call(l,Dn(v)),keydown:A()(u=v._startHandModeWithSpaceBar).call(u,Dn(v)),keyup:A()(h=v._endHandModeWithSpaceBar).call(h,Dn(v))};var p=v.getCanvas();return v.aspectRatio=p.width/p.height,v._verticalScroll=new z.fabric.Rect(Da),v._horizontalScroll=new z.fabric.Rect(Da),p.on(Pa,v._listeners.zoomChanged),v.graphics.on(za,A()(f=v._startTextEditingHandler).call(f,Dn(v))),v.graphics.on(Ba,A()(g=v._startTextEditingHandler).call(g,Dn(v))),v.graphics.on(Ra,A()(d=v._stopTextEditingHandler).call(d,Dn(v))),v}return T(i,[{key:"attachKeyboardZoomEvents",value:function(){z.fabric.util.addListener(document,Fa,this._listeners.keydown),z.fabric.util.addListener(document,Ya,this._listeners.keyup)}},{key:"detachKeyboardZoomEvents",value:function(){z.fabric.util.removeListener(document,Fa,this._listeners.keydown),z.fabric.util.removeListener(document,Ya,this._listeners.keyup)}},{key:"_startTextEditingHandler",value:function(){this.isTextEditing=!0}},{key:"_stopTextEditingHandler",value:function(){this.isTextEditing=!1}},{key:"_startHandModeWithSpaceBar",value:function(t){this.withSpace||this.isTextEditing||t.keyCode===ii&&(this.withSpace=!0,this.startHandMode())}},{key:"_endHandModeWithSpaceBar",value:function(t){t.keyCode===ii&&(this.withSpace=!1,this.endHandMode())}},{key:"startZoomInMode",value:function(){if(!this.zoomArea){this.endHandMode(),this.zoomMode=Ge;var t=this.getCanvas();this._changeObjectsEventedState(!1),this.zoomArea=new z.fabric.Rect({left:0,top:0,width:.5,height:.5,stroke:"black",strokeWidth:1,fill:"transparent",hoverCursor:"zoom-in"}),t.discardActiveObject(),t.add(this.zoomArea),t.on("mouse:down",this._listeners.startZoom),t.selection=!1,t.defaultCursor="zoom-in"}}},{key:"endZoomInMode",value:function(){this.zoomMode=Ue;var t=this.getCanvas(),e=this._listeners,i=e.startZoom,n=e.moveZoom,r=e.stopZoom;t.selection=!0,t.defaultCursor="auto",t.off({"mouse:down":i,"mouse:move":n,"mouse:up":r}),this._changeObjectsEventedState(!0),t.remove(this.zoomArea),this.zoomArea=null}},{key:"start",value:function(){this.zoomArea=null,this._startPoint=null,this._startHandPoint=null}},{key:"end",value:function(){this.endZoomInMode(),this.endHandMode()}},{key:"startHandMode",value:function(){this.endZoomInMode(),this.zoomMode=Xe;var t=this.getCanvas();this._changeObjectsEventedState(!1),t.discardActiveObject(),t.off("mouse:down",this._listeners.startHand),t.on("mouse:down",this._listeners.startHand),t.selection=!1,t.defaultCursor="grab",t.fire(Wa)}},{key:"endHandMode",value:function(){this.zoomMode=Ue;var t=this.getCanvas();this._changeObjectsEventedState(!0),t.off("mouse:down",this._listeners.startHand),t.selection=!0,t.defaultCursor="auto",this._startHandPoint=null,t.fire(Ha)}},{key:"_onMouseDownWithZoomMode",value:function(t){var e=t.target,i=t.e;if(!e){var n=this.getCanvas();n.selection=!1,this._startPoint=n.getPointer(i),this.zoomArea.set({width:0,height:0});var r=this._listeners,o=r.moveZoom,a=r.stopZoom;n.on({"mouse:move":o,"mouse:up":a})}}},{key:"_onMouseMoveWithZoomMode",value:function(t){var e=t.e,i=this.getCanvas(),n=i.getPointer(e),r=n.x,o=n.y,a=this.zoomArea,s=this._startPoint;Math.abs(r-s.x)+Math.abs(o-s.y)>10&&(i.remove(a),a.set(this._calcRectDimensionFromPoint(r,o)),i.add(a))}},{key:"_calcRectDimensionFromPoint",value:function(t,e){var i=this.getCanvas(),n=i.getWidth(),r=i.getHeight(),o=this._startPoint,a=o.x,s=o.y,c=Math.min,l=c(a,t),u=c(s,e);return{left:l,top:u,width:Ni(t,a,n)-l,height:Ni(e,s,r)-u}}},{key:"_onMouseUpWithZoomMode",value:function(){var t=this.zoomLevel,e=this.zoomArea,i=this._listeners,n=i.moveZoom,r=i.stopZoom,o=this.getCanvas(),a=this._getCenterPoint(),s=a.x,c=a.y;this._isMaxZoomLevel()||(this._centerPoints.push({x:s,y:c,prevZoomLevel:t,zoomLevel:t+1}),t+=1,o.zoomToPoint({x:s,y:c},t),this._fireZoomChanged(o,t),this.zoomLevel=t),o.off({"mouse:move":n,"mouse:up":r}),o.remove(e),this._startPoint=null}},{key:"_getCenterPoint",value:function(){var t=this.zoomArea,e=t.left,i=t.top,n=t.width,r=t.height,o=this._startPoint,a=o.x,s=o.y,c=this.aspectRatio;return n<10&&r<10?{x:a,y:s}:n>r?{x:e+c*r/2,y:i+r/2}:{x:e+n/2,y:i+n/c/2}}},{key:"zoom",value:function(t){for(var e=t.x,i=t.y,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoomLevel,r=this.getCanvas(),o=this._centerPoints,a=o.length-1;a>=0&&!(o[a].zoomLevel<n);a-=1){var s=o.pop(),c=s.x,l=s.y,u=s.prevZoomLevel;r.zoomToPoint({x:c,y:l},u),this.zoomLevel=u}r.zoomToPoint({x:e,y:i},n),this._isDefaultZoomLevel(n)||this._centerPoints.push({x:e,y:i,zoomLevel:n,prevZoomLevel:this.zoomLevel}),this.zoomLevel=n,this._fireZoomChanged(r,n)}},{key:"zoomOut",value:function(){var t=this._centerPoints;if(t.length){var e=this.getCanvas(),i=t.pop(),n=i.x,r=i.y,o=i.prevZoomLevel;this._isDefaultZoomLevel(o)?e.setViewportTransform([1,0,0,1,0,0]):e.zoomToPoint({x:n,y:r},o),this.zoomLevel=o,this._fireZoomChanged(e,this.zoomLevel)}}},{key:"resetZoom",value:function(){var t=this.getCanvas();t.setViewportTransform([1,0,0,1,0,0]),this.zoomLevel=1,this._centerPoints=[],this._fireZoomChanged(t,this.zoomLevel)}},{key:"_isMaxZoomLevel",value:function(){return this.zoomLevel>=5}},{key:"_movePointOfZoom",value:function(t){var e=t.x,i=t.y,n=this._centerPoints;if(n.length){var r=this.getCanvas(),o=this.zoomLevel,a=n.pop(),s=a.x,c=a.y,l=a.prevZoomLevel,u=s-e,h=c-i;r.zoomToPoint({x:s,y:c},l),r.zoomToPoint({x:u,y:h},o),n.push({x:u,y:h,prevZoomLevel:l,zoomLevel:o}),this._fireZoomChanged(r,o)}}},{key:"_onMouseDownWithHandMode",value:function(t){var e=t.target,i=t.e;if(!e){var n=this.getCanvas();if(!(this.zoomLevel<=1)){n.selection=!1,this._startHandPoint=n.getPointer(i);var r=this._listeners,o=r.moveHand,a=r.stopHand;n.on({"mouse:move":o,"mouse:up":a})}}}},{key:"_onMouseMoveWithHandMode",value:function(t){var e=t.e,i=this.getCanvas().getPointer(e),n=i.x,r=i.y,o=n-this._startHandPoint.x,a=r-this._startHandPoint.y;this._movePointOfZoom({x:o,y:a})}},{key:"_onMouseUpWithHandMode",value:function(){var t=this.getCanvas(),e=this._listeners,i=e.moveHand,n=e.stopHand;t.off({"mouse:move":i,"mouse:up":n}),this._startHandPoint=null}},{key:"_changeScrollState",value:function(t){var e=t.viewport,i=t.zoomLevel,n=this.getCanvas();if(n.remove(this._verticalScroll),n.remove(this._horizontalScroll),!this._isDefaultZoomLevel(i)){var r=n.width,o=n.height,a=e.tl,s=e.tr,c=e.bl,l=s.x-a.x,u=c.y-a.y,h=l*l/r,f=u*Ea,g=Ni(a.x+a.x/r*l,a.x,s.x-h),d=u*La,v=u*Na;this._horizontalScroll.set({left:g,top:c.y-f-d,width:h,height:f,rx:v,ry:v});var p=l*Aa,m=u*u/o,y=Ni(a.y+a.y/o*u,s.y,c.y-m),b=l*ja,x=l*Oa;this._verticalScroll.set({left:s.x-p-b,top:y,width:p,height:m,rx:x,ry:x}),this._addScrollBar()}}},{key:"_changeObjectsEventedState",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.getCanvas();e.forEachObject((function(e){e.evented=t}))}},{key:"_addScrollBar",value:function(){var t=this,e=this.getCanvas();this.scrollBarTid&&clearTimeout(this.scrollBarTid),this.scrollBarTid=v()((function(){e.remove(t._horizontalScroll),e.remove(t._verticalScroll)}),3e3)}},{key:"_isDefaultZoomLevel",value:function(t){return 1===t}},{key:"_fireZoomChanged",value:function(t,e){t.fire(Pa,{viewport:t.calcViewportBoundaries(),zoomLevel:e})}},{key:"mode",get:function(){return this.zoomMode}}]),i}(ho),Ga=Ua,Xa=rn.create,Za=rn.types,Va=function(){function t(e){w(this,t),this.name=e}return T(t,[{key:"getName",value:function(){return this.name}},{key:"start",value:function(){throw new Error(Xa(Za.UN_IMPLEMENTATION,"start"))}},{key:"end",value:function(){throw new Error(Xa(Za.UN_IMPLEMENTATION,"stop"))}}]),t}();function Ja(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Qa=function(t){wn(i,t);var e=Ja(i);function i(){return w(this,i),e.call(this,Be.CROPPER)}return T(i,[{key:"start",value:function(t){t.getComponent(St.CROPPER).start()}},{key:"end",value:function(t){t.getComponent(St.CROPPER).end()}}]),i}(Va),Ka=Qa;function qa(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var $a=function(t){wn(i,t);var e=qa(i);function i(){return w(this,i),e.call(this,Be.FREE_DRAWING)}return T(i,[{key:"start",value:function(t,e){t.getComponent(St.FREE_DRAWING).start(e)}},{key:"end",value:function(t){t.getComponent(St.FREE_DRAWING).end()}}]),i}(Va),ts=$a;function es(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var is=function(t){wn(i,t);var e=es(i);function i(){return w(this,i),e.call(this,Be.LINE_DRAWING)}return T(i,[{key:"start",value:function(t,e){t.getComponent(St.LINE).start(e)}},{key:"end",value:function(t){t.getComponent(St.LINE).end()}}]),i}(Va),ns=is;function rs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var os=function(t){wn(i,t);var e=rs(i);function i(){return w(this,i),e.call(this,Be.SHAPE)}return T(i,[{key:"start",value:function(t){t.getComponent(St.SHAPE).start()}},{key:"end",value:function(t){t.getComponent(St.SHAPE).end()}}]),i}(Va),as=os;function ss(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var cs=function(t){wn(i,t);var e=ss(i);function i(){return w(this,i),e.call(this,Be.TEXT)}return T(i,[{key:"start",value:function(t){t.getComponent(St.TEXT).start()}},{key:"end",value:function(t){t.getComponent(St.TEXT).end()}}]),i}(Va),ls=cs;function us(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var hs=function(t){wn(i,t);var e=us(i);function i(){return w(this,i),e.call(this,Be.ICON)}return T(i,[{key:"start",value:function(t){t.getComponent(St.ICON).start()}},{key:"end",value:function(t){t.getComponent(St.ICON).end()}}]),i}(Va),fs=hs;function gs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var ds=function(t){wn(i,t);var e=gs(i);function i(){return w(this,i),e.call(this,Be.ZOOM)}return T(i,[{key:"start",value:function(t){t.getComponent(St.ZOOM).start()}},{key:"end",value:function(t){t.getComponent(St.ZOOM).end()}}]),i}(Va),vs=ds,ps=null;function ms(t){ps=t}function ys(t,e){var i,n;"activeSelection"===t.type?i=pn()(n=t.getObjects()).call(n,(function(i){var n=i.angle,r=i.left,o=i.top,a=i.scaleX,s=i.scaleY,c=i.width,l=i.height;z.fabric.util.addTransformToObject(i,t.calcTransformMatrix());var u=e(i);return i.set({angle:n,left:r,top:o,width:c,height:l,scaleX:a,scaleY:s}),u})):i=[e(t)];return i}function bs(t,e,i){return i?{id:t,width:e.width,height:e.height,top:e.top,left:e.left,angle:e.angle,scaleX:e.scaleX,scaleY:e.scaleY}:R()({id:t},e)}function xs(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Cs=function(t){wn(i,t);var e=xs(i);function i(t){var n;return w(this,i),(n=e.call(this,St.RESIZE,t))._dimensions=null,n._originalDimensions=null,n}return T(i,[{key:"getCurrentDimensions",value:function(){var t=this.getCanvasImage();if(!this._dimensions&&t){var e=t.width,i=t.height;this._dimensions={width:e,height:i}}return this._dimensions}},{key:"getOriginalDimensions",value:function(){return this._originalDimensions}},{key:"setOriginalDimensions",value:function(t){this._originalDimensions=t}},{key:"resize",value:function(t){var e=this.getCanvasImage(),i=e.width,n=e.height,r=e.scaleX,o=e.scaleY,a=t.width,s=t.height,c={scaleX:a?a/i:r,scaleY:s?s/n:o};return r===c.scaleX&&o===c.scaleY||(e.set(c).setCoords(),this._dimensions={width:e.width*e.scaleX,height:e.height*e.scaleY}),this.adjustCanvasDimensionBase(),L().resolve()}},{key:"start",value:function(){var t=this.getCurrentDimensions();this.setOriginalDimensions(t)}},{key:"end",value:function(){}}]),i}(ho),Is=Cs;function _s(t){var e=function(){if("undefined"==typeof Reflect||!In())return!1;if(In().sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(In()(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=On(t);if(e){var r=On(this).constructor;i=In()(n,arguments,r)}else i=n.apply(this,arguments);return An(this,i)}}var Ms=function(t){wn(i,t);var e=_s(i);function i(){return w(this,i),e.call(this,Be.RESIZE)}return T(i,[{key:"start",value:function(t){t.getComponent(St.RESIZE).start()}},{key:"end",value:function(t){t.getComponent(St.RESIZE).end()}}]),i}(Va),Ss=Ms,ws={cssOnly:!0},ks={backstoreOnly:!0},Ts=function(){function t(e){var i,n,r,o,a,s,c,l,u,h,f,g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=g.cssMaxWidth,v=g.cssMaxHeight;w(this,t),this.canvasImage=null,this.cssMaxWidth=d||1e3,this.cssMaxHeight=v||800,this.cropSelectionStyle={},this.targetObjectForCopyPaste=null,this.imageName="",this._objects={},this._canvas=null,this._drawingMode=Be.NORMAL,this._drawingModeMap={},this._componentMap={},this._zoomLevel=1,this._handler={onMouseDown:A()(i=this._onMouseDown).call(i,this),onObjectAdded:A()(n=this._onObjectAdded).call(n,this),onObjectRemoved:A()(r=this._onObjectRemoved).call(r,this),onObjectMoved:A()(o=this._onObjectMoved).call(o,this),onObjectScaled:A()(a=this._onObjectScaled).call(a,this),onObjectModified:A()(s=this._onObjectModified).call(s,this),onObjectRotated:A()(c=this._onObjectRotated).call(c,this),onObjectSelected:A()(l=this._onObjectSelected).call(l,this),onPathCreated:A()(u=this._onPathCreated).call(u,this),onSelectionCleared:A()(h=this._onSelectionCleared).call(h,this),onSelectionCreated:A()(f=this._onSelectionCreated).call(f,this)},this._setObjectCachingToFalse(),this._setCanvasElement(e),this._createDrawingModeInstances(),this._createComponents(),this._attachCanvasEvents(),this._attachZoomEvents()}return T(t,[{key:"destroy",value:function(){var t=this._canvas.wrapperEl;this._canvas.clear(),t.parentNode.removeChild(t),this._detachZoomEvents()}},{key:"_attachZoomEvents",value:function(){this.getComponent(St.ZOOM).attachKeyboardZoomEvents()}},{key:"_detachZoomEvents",value:function(){this.getComponent(St.ZOOM).detachKeyboardZoomEvents()}},{key:"deactivateAll",value:function(){return this._canvas.discardActiveObject(),this}},{key:"renderAll",value:function(){return this._canvas.renderAll(),this}},{key:"add",value:function(t){var e,i=[];so()(t)?i=t:i.push(t),(e=this._canvas).add.apply(e,_(i))}},{key:"contains",value:function(t){return this._canvas.contains(t)}},{key:"getObjects",value:function(){var t;return h()(t=this._canvas.getObjects()).call(t)}},{key:"getObject",value:function(t){return this._objects[t]}},{key:"remove",value:function(t){this._canvas.remove(t)}},{key:"removeAll",value:function(t){var e,i=this._canvas,n=h()(e=i.getObjects()).call(e);return i.remove.apply(i,_(this._canvas.getObjects())),t&&i.clear(),n}},{key:"removeObjectById",value:function(t){var e=[],i=this._canvas,n=this.getObject(t);return n&&n.isType("group")&&!n.isEmpty()?(i.discardActiveObject(),n.forEachObject((function(t){e.push(t),i.remove(t)}))):i.contains(n)&&(e.push(n),i.remove(n)),e}},{key:"getObjectId",value:function(t){var e=null;for(e in this._objects)if(this._objects.hasOwnProperty(e)&&t===this._objects[e])return e;return null}},{key:"getActiveObject",value:function(){return this._canvas._activeObject}},{key:"getActiveObjectIdForRemove",value:function(){var t=this.getActiveObject(),e=t.type,i=t.left,n=t.top;if("activeSelection"===e){var r=new z.fabric.Group(_(t.getObjects()),{left:i,top:n});return this._addFabricObject(r)}return this.getObjectId(t)}},{key:"isReadyRemoveObject",value:function(){var t=this.getActiveObject();return t&&!t.isEditing}},{key:"getActiveObjects",value:function(){var t=this._canvas._activeObject;return t&&"activeSelection"===t.type?t:null}},{key:"getActiveSelectionFromObjects",value:function(t){var e=this.getCanvas();return new z.fabric.ActiveSelection(t,{canvas:e})}},{key:"setActiveObject",value:function(t){this._canvas.setActiveObject(t)}},{key:"setCropSelectionStyle",value:function(t){this.cropSelectionStyle=t}},{key:"getComponent",value:function(t){return this._componentMap[t]}},{key:"getDrawingMode",value:function(){return this._drawingMode}},{key:"startDrawingMode",value:function(t,e){if(this._isSameDrawingMode(t))return!0;this.stopDrawingMode();var i=this._getDrawingModeInstance(t);return i&&i.start&&(i.start(this,e),this._drawingMode=t),!!i}},{key:"stopDrawingMode",value:function(){if(!this._isSameDrawingMode(Be.NORMAL)){var t=this._getDrawingModeInstance(this.getDrawingMode());t&&t.end&&t.end(this),this._drawingMode=Be.NORMAL}}},{key:"zoom",value:function(t,e){var i=t.x,n=t.y,r=this.getComponent(St.ZOOM);r.zoom({x:i,y:n},e),this._zoomLevel=e}},{key:"getZoomMode",value:function(){return this.getComponent(St.ZOOM).mode}},{key:"startZoomInMode",value:function(){this.getComponent(St.ZOOM).startZoomInMode()}},{key:"endZoomInMode",value:function(){this.getComponent(St.ZOOM).endZoomInMode()}},{key:"zoomOut",value:function(){this.getComponent(St.ZOOM).zoomOut()}},{key:"startHandMode",value:function(){this.getComponent(St.ZOOM).startHandMode()}},{key:"endHandMode",value:function(){this.getComponent(St.ZOOM).endHandMode()}},{key:"resetZoom",value:function(){this.getComponent(St.ZOOM).resetZoom()}},{key:"toDataURL",value:function(t){var e=this.getComponent(St.CROPPER);e.changeVisibility(!1);var i=this._canvas&&this._canvas.toDataURL(t);return e.changeVisibility(!0),i}},{key:"setCanvasImage",value:function(t,e){e&&Ei(e),this.imageName=t,this.canvasImage=e}},{key:"setCssMaxDimension",value:function(t){this.cssMaxWidth=t.width||this.cssMaxWidth,this.cssMaxHeight=t.height||this.cssMaxHeight}},{key:"adjustCanvasDimension",value:function(){this.adjustCanvasDimensionBase(this.canvasImage.scale(1))}},{key:"adjustCanvasDimensionBase",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t||(t=this.canvasImage);var e=t.getBoundingRect(),i=e.width,n=e.height;1!==this._zoomLevel&&(i/=this._zoomLevel,n/=this._zoomLevel),console.log("adjustimage",i,n),console.log("adjustmax",this.cssMaxWidth,this.cssMaxHeight);var r=this._calcMaxDimension(i,n);console.log("maxDimension",r),this.setCanvasCssDimension({width:"100%",height:"100%","max-width":"".concat(r.width,"px"),"max-height":"".concat(r.height,"px")}),this.setCanvasBackstoreDimension({width:i,height:n}),this._canvas.centerObject(t)}},{key:"setCanvasCssDimension",value:function(t){this._canvas.setDimensions(t,ws)}},{key:"setCanvasBackstoreDimension",value:function(t){this._canvas.setDimensions(t,ks)}},{key:"setImageProperties",value:function(t,e){var i=this.canvasImage;i&&(i.set(t).setCoords(),e&&this._canvas.renderAll())}},{key:"getCanvasElement",value:function(){return this._canvas.getElement()}},{key:"getCanvas",value:function(){return this._canvas}},{key:"getCanvasImage",value:function(){return this.canvasImage}},{key:"getImageName",value:function(){return this.imageName}},{key:"addImageObject",value:function(t){var e,i=this,n=A()(e=this._callbackAfterLoadingImageObject).call(e,this);return new(L())((function(e){z.fabric.Image.fromURL(t,(function(t){n(t),e(i.createObjectProperties(t))}),{crossOrigin:"Anonymous"})}))}},{key:"getCenter",value:function(){return this._canvas.getCenter()}},{key:"getCropzoneRect",value:function(){return this.getComponent(St.CROPPER).getCropzoneRect()}},{key:"setCropzoneRect",value:function(t){this.getComponent(St.CROPPER).setCropzoneRect(t)}},{key:"getCroppedImageData",value:function(t){return this.getComponent(St.CROPPER).getCroppedImageData(t)}},{key:"setBrush",value:function(t){var e=this._drawingMode,i=St.FREE_DRAWING;e===Be.LINE_DRAWING&&(i=St.LINE),this.getComponent(i).setBrush(t)}},{key:"setDrawingShape",value:function(t,e){this.getComponent(St.SHAPE).setStates(t,e)}},{key:"setIconStyle",value:function(t,e){this.getComponent(St.ICON).setStates(t,e)}},{key:"registerPaths",value:function(t){this.getComponent(St.ICON).registerPaths(t)}},{key:"changeCursor",value:function(t){var e=this.getCanvas();e.defaultCursor=t,e.renderAll()}},{key:"hasFilter",value:function(t){return this.getComponent(St.FILTER).hasFilter(t)}},{key:"setSelectionStyle",value:function(t){R()(oi,t)}},{key:"setObjectProperties",value:function(t,e){var i=this.getObject(t),n=R()({},e);return i.set(n),i.setCoords(),this.getCanvas().renderAll(),n}},{key:"getObjectProperties",value:function(t,e){var i=this.getObject(t),n={};return Z()(e)?n[e]=i[e]:so()(e)?Ln()(e,(function(t){n[t]=i[t]})):lo()(e,(function(t,e){n[e]=i[e]})),n}},{key:"getObjectPosition",value:function(t,e,i){var n=this.getObject(t);return n?n.getPointByOrigin(e,i):null}},{key:"setObjectPosition",value:function(t,e){var i=this.getObject(t),n=e.x,r=e.y,o=e.originX,a=e.originY;if(!i)return!1;var s=i.getPointByOrigin(o,a),c=i.getPointByOrigin("center","center"),l=c.x-s.x,u=c.y-s.y;return i.set({left:n+l,top:r+u}),i.setCoords(),!0}},{key:"getCanvasSize",value:function(){var t=this.getCanvasImage();return{width:t?t.width:0,height:t?t.height:0}}},{key:"createStaticCanvas",value:function(){var t=new z.fabric.StaticCanvas;return t.set({enableRetinaScaling:!1}),t}},{key:"_getDrawingModeInstance",value:function(t){return this._drawingModeMap[t]}},{key:"_setObjectCachingToFalse",value:function(){z.fabric.Object.prototype.objectCaching=!1}},{key:"_setCanvasElement",value:function(t){var e,i;"CANVAS"!==(e=t.nodeType?t:document.querySelector(t)).nodeName.toUpperCase()&&(i=document.createElement("canvas"),e.appendChild(i)),this._canvas=new z.fabric.Canvas(i,{containerClass:"tui-image-editor-canvas-container",enableRetinaScaling:!1})}},{key:"_createDrawingModeInstances",value:function(){this._register(this._drawingModeMap,new Ka),this._register(this._drawingModeMap,new ts),this._register(this._drawingModeMap,new ns),this._register(this._drawingModeMap,new as),this._register(this._drawingModeMap,new ls),this._register(this._drawingModeMap,new fs),this._register(this._drawingModeMap,new vs),this._register(this._drawingModeMap,new Ss)}},{key:"_createComponents",value:function(){this._register(this._componentMap,new po(this)),this._register(this._componentMap,new So(this)),this._register(this._componentMap,new To(this)),this._register(this._componentMap,new jo(this)),this._register(this._componentMap,new Bo(this)),this._register(this._componentMap,new Ho(this)),this._register(this._componentMap,new Vo(this)),this._register(this._componentMap,new qo(this)),this._register(this._componentMap,new ua(this)),this._register(this._componentMap,new ka(this)),this._register(this._componentMap,new Ga(this)),this._register(this._componentMap,new Is(this))}},{key:"_register",value:function(t,e){t[e.getName()]=e}},{key:"_isSameDrawingMode",value:function(t){return this.getDrawingMode()===t}},{key:"_calcMaxDimension",value:function(t,e){var i=this.cssMaxWidth/t,n=this.cssMaxHeight/e,r=this.cssMaxWidth,o=this.cssMaxHeight;return i<1&&i<n?(r=t*i,o=e*i):n<1&&n<i&&(r=t*n,o=e*n),{width:Math.floor(r),height:Math.floor(o)}}},{key:"_callbackAfterLoadingImageObject",value:function(t){var e=this.getCanvasImage().getCenterPoint();t.set(oi),t.set({left:e.x,top:e.y,crossOrigin:"Anonymous"}),this.getCanvas().add(t).setActiveObject(t)}},{key:"_attachCanvasEvents",value:function(){var t=this._canvas,e=this._handler;t.on({"mouse:down":e.onMouseDown,"object:added":e.onObjectAdded,"object:removed":e.onObjectRemoved,"object:moving":e.onObjectMoved,"object:scaling":e.onObjectScaled,"object:modified":e.onObjectModified,"object:rotating":e.onObjectRotated,"path:created":e.onPathCreated,"selection:cleared":e.onSelectionCleared,"selection:created":e.onSelectionCreated,"selection:updated":e.onObjectSelected})}},{key:"_onMouseDown",value:function(t){var e=this,i=t.e,n=t.target,r=this._canvas.getPointer(i);if(n){var o=n.type;ms(ys(n,(function(t){return bs(e.getObjectId(t),t,"activeSelection"===o)})))}this.fire(se,i,r)}},{key:"_onObjectAdded",value:function(t){var e=t.target;e.isType("cropzone")||this._addFabricObject(e)}},{key:"_onObjectRemoved",value:function(t){var e=t.target;this._removeFabricObject(Ei(e))}},{key:"_onObjectMoved",value:function(t){var e=this;this._lazyFire(Jt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_onObjectScaled",value:function(t){var e=this;this._lazyFire(Qt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_onObjectModified",value:function(t){var e=t.target;if("activeSelection"===e.type){var i=e.getObjects();et()(i).call(i,(function(t){return t.fire("modifiedInGroup",e)}))}this.fire($t,e,this.getObjectId(e))}},{key:"_onObjectRotated",value:function(t){var e=this;this._lazyFire(Kt,(function(t){return e.createObjectProperties(t)}),t.target)}},{key:"_lazyFire",value:function(t,e,i){var n=this,r=i&&i.canvasEventDelegation?i.canvasEventDelegation(t):"none";"unregistered"===r&&i.canvasEventRegister(t,(function(i){n.fire(t,e(i))})),"none"===r&&this.fire(t,e(i))}},{key:"_onObjectSelected",value:function(t){var e=t.target,i=this.createObjectProperties(e);this.fire(Vt,i)}},{key:"_onPathCreated",value:function(t){var e=t.path.getCenterPoint(),i=e.x,n=e.y;t.path.set(R()({left:i,top:n},oi));var r=this.createObjectProperties(t.path);this.fire(oe,r)}},{key:"_onSelectionCleared",value:function(){this.fire(ue)}},{key:"_onSelectionCreated",value:function(t){var e=t.target,i=this.createObjectProperties(e);this.fire(Vt,i),this.fire(he,t.target)}},{key:"discardSelection",value:function(){this._canvas.discardActiveObject(),this._canvas.renderAll()}},{key:"changeSelectableAll",value:function(t){this._canvas.forEachObject((function(e){e.selectable=t,e.hoverCursor=t?"move":"crosshair"}))}},{key:"createObjectProperties",value:function(t){var e={id:Ei(t),type:t.type};if(R()(e,zi(t,["left","top","width","height","fill","stroke","strokeWidth","opacity","angle"])),Xi(["i-text","text"],t.type))R()(e,this._createTextProperties(t,e));else if(Xi(["rect","triangle","circle"],t.type)){var i=this.getComponent(St.SHAPE);R()(e,{fill:i.makeFillPropertyForUserEvent(t)})}return e}},{key:"_createTextProperties",value:function(t){var e={};return R()(e,zi(t,["text","fontFamily","fontSize","fontStyle","textAlign","textDecoration","fontWeight"])),e}},{key:"_addFabricObject",value:function(t){var e=Ei(t);return this._objects[e]=t,e}},{key:"_removeFabricObject",value:function(t){delete this._objects[t]}},{key:"resetTargetObjectForCopyPaste",value:function(){var t=this.getActiveObject();t&&(this.targetObjectForCopyPaste=t)}},{key:"pasteObject",value:function(){var t=this;if(!this.targetObjectForCopyPaste)return L().resolve([]);var e=this.targetObjectForCopyPaste,i="activeSelection"===e.type?e.getObjects():[e],n=null;return this.discardSelection(),this._cloneObject(i).then((function(e){if(e.length>1)n=t.getActiveSelectionFromObjects(e);else{var i=Q(e,1);n=i[0]}t.targetObjectForCopyPaste=n,t.setActiveObject(n)}))}},{key:"_cloneObject",value:function(t){var e=this,i=pn()(t).call(t,(function(t){return e._cloneObjectItem(t)}));return L().all(i)}},{key:"_cloneObjectItem",value:function(t){var e=this;return this._copyFabricObjectForPaste(t).then((function(t){var i=e.createObjectProperties(t);return e.add(t),e.fire(oe,i),t}))}},{key:"_copyFabricObjectForPaste",value:function(t){var e=this,i=function(t,e){return e?t-10:t+10};return this._copyFabricObject(t).then((function(t){var n=t.left,r=t.top,o=t.width,a=t.height,s=e.getCanvasSize(),c=s.width,l=s.height,u=n+o/2,h=r+a/2;return t.set(R()({left:i(n,u+10>c),top:i(r,h+10>l)},oi)),t}))}},{key:"_copyFabricObject",value:function(t){var e=this;return new(L())((function(i){t.clone((function(n){var r=e.getComponent(St.SHAPE);Ji(n)&&r.processForCopiedObject(n,t),i(n)}))}))}},{key:"getCurrentDimensions",value:function(){return this.getComponent(St.RESIZE).getCurrentDimensions()}},{key:"getOriginalDimensions",value:function(){return this.getComponent(St.RESIZE).getOriginalDimensions()}},{key:"setOriginalDimensions",value:function(t){this.getComponent(St.RESIZE).setOriginalDimensions(t)}},{key:"resize",value:function(t){var e=this.getComponent(St.RESIZE);return e.resize(t)}}]),t}();G().mixin(Ts);var Ds=Ts,As=se,js=Jt,Os=Qt,Es=Vt,Ls=Kt,Ns=qt,Ps=$t,zs=re,Bs=oe,Rs=te,Fs=ee,Ys=ie,Ws=ne,Hs=ue,Us=he,Gs=ae,Xs=function(){function t(e,i){var n,r,o,a,s,c,l,u,h,f,g,d,v,p,m,y;if(w(this,t),i=R()({includeUI:!1,usageStatistics:!0},i),this.mode=null,this.activeObjectId=null,i.includeUI){var b=i.includeUI;b.usageStatistics=i.usageStatistics,this.ui=new eo(e,b,this.getActions()),i=this.ui.setUiDefaultSelectionStyle(i)}this._invoker=new fn,this._graphics=new Ds(this.ui?this.ui.getEditorArea():e,{cssMaxWidth:i.cssMaxWidth,cssMaxHeight:i.cssMaxHeight}),this._handlers={keydown:A()(n=this._onKeyDown).call(n,this),mousedown:A()(r=this._onMouseDown).call(r,this),objectActivated:A()(o=this._onObjectActivated).call(o,this),objectMoved:A()(a=this._onObjectMoved).call(a,this),objectScaled:A()(s=this._onObjectScaled).call(s,this),objectRotated:A()(c=this._onObjectRotated).call(c,this),objectAdded:A()(l=this._onObjectAdded).call(l,this),objectModified:A()(u=this._onObjectModified).call(u,this),createdPath:this._onCreatedPath,addText:A()(h=this._onAddText).call(h,this),addObject:A()(f=this._onAddObject).call(f,this),textEditing:A()(g=this._onTextEditing).call(g,this),textChanged:A()(d=this._onTextChanged).call(d,this),iconCreateResize:A()(v=this._onIconCreateResize).call(v,this),iconCreateEnd:A()(p=this._onIconCreateEnd).call(p,this),selectionCleared:A()(m=this._selectionCleared).call(m,this),selectionCreated:A()(y=this._selectionCreated).call(y,this)},this._attachInvokerEvents(),this._attachGraphicsEvents(),this._attachDomEvents(),this._setSelectionStyle(i.selectionStyle,{applyCropSelectionStyle:i.applyCropSelectionStyle,applyGroupSelectionStyle:i.applyGroupSelectionStyle}),i.usageStatistics&&(ji||(ji=!0,ot()("image-editor","UA-129999381-1"))),this.ui&&(this.ui.initCanvas(),this.setReAction(),this._attachColorPickerInputBoxEvents()),z.fabric.enableGLFiltering=!1}return T(t,[{key:"_attachColorPickerInputBoxEvents",value:function(){var t=this;this.ui.on(xe,(function(){t.isColorPickerInputBoxEditing=!0})),this.ui.on(Ce,(function(){t.isColorPickerInputBoxEditing=!1}))}},{key:"_detachColorPickerInputBoxEvents",value:function(){this.ui.off(xe),this.ui.off(Ce)}},{key:"_setSelectionStyle",value:function(t,e){var i=e.applyCropSelectionStyle,n=e.applyGroupSelectionStyle;t&&this._graphics.setSelectionStyle(t),i&&this._graphics.setCropSelectionStyle(t),n&&this.on("selectionCreated",(function(e){"activeSelection"===e.type&&e.set(t)}))}},{key:"_attachInvokerEvents",value:function(){var t,e,i=this,n=le,r=ce,o=fe,a=ge,s=de,c=pe,l=me;if(this._invoker.on(n,A()(t=this.fire).call(t,this,n)),this._invoker.on(r,A()(e=this.fire).call(e,this,r)),this.ui){var u=this._graphics.getCanvas();this._invoker.on(o,(function(t){return i.ui.fire(o,t)})),this._invoker.on(a,(function(t){return i.ui.fire(a,t)})),this._invoker.on(s,(function(t){return i.ui.fire(s,t)})),u.on(c,(function(){return i.ui.fire(c)})),u.on(l,(function(){return i.ui.fire(l)}))}}},{key:"_attachGraphicsEvents",value:function(){var t;this._graphics.on((S(t={},As,this._handlers.mousedown),S(t,js,this._handlers.objectMoved),S(t,Os,this._handlers.objectScaled),S(t,Ls,this._handlers.objectRotated),S(t,Es,this._handlers.objectActivated),S(t,Ns,this._handlers.objectAdded),S(t,Ps,this._handlers.objectModified),S(t,zs,this._handlers.addText),S(t,Bs,this._handlers.addObject),S(t,Rs,this._handlers.textEditing),S(t,Fs,this._handlers.textChanged),S(t,Ys,this._handlers.iconCreateResize),S(t,Ws,this._handlers.iconCreateEnd),S(t,Hs,this._handlers.selectionCleared),S(t,Us,this._handlers.selectionCreated),t))}},{key:"_attachDomEvents",value:function(){document.addEventListener("keydown",this._handlers.keydown)}},{key:"_detachDomEvents",value:function(){document.removeEventListener("keydown",this._handlers.keydown)}},{key:"_onKeyDown",value:function(t){var e=t.ctrlKey,i=t.keyCode,n=t.metaKey;(e||n)&&(i===Je?this._graphics.resetTargetObjectForCopyPaste():i===Qe?(this._graphics.pasteObject(),this.clearRedoStack()):i===Ze?this.undo().catch((function(){})):i===Ve&&this.redo().catch((function(){})));var r=i===qe||i===$e,o=this._graphics.isReadyRemoveObject();!this.isColorPickerInputBoxEditing&&o&&r&&(t.preventDefault(),this.removeActiveObject())}},{key:"removeActiveObject",value:function(){var t=this._graphics.getActiveObjectIdForRemove();this.removeObject(t)}},{key:"_onMouseDown",value:function(t,e){this.fire(se,t,e)}},{key:"_pushAddObjectCommand",value:function(t){var e=un.create(jt,this._graphics,t);this._invoker.pushUndoStack(e)}},{key:"_pushModifyObjectCommand",value:function(t){var e=this,i=t.type,n=ys(t,(function(t){return bs(e._graphics.getObjectId(t),t,"activeSelection"===i)})),r=un.create(Xt,this._graphics,n);r.execute(this._graphics,n),this._invoker.pushUndoStack(r)}},{key:"_onObjectActivated",value:function(t){this.fire(Vt,t)}},{key:"_onObjectMoved",value:function(t){this.fire(Jt,t)}},{key:"_onObjectScaled",value:function(t){this.fire(Qt,t)}},{key:"_onObjectRotated",value:function(t){this.fire(Kt,t)}},{key:"getDrawingMode",value:function(){return this._graphics.getDrawingMode()}},{key:"clearObjects",value:function(){return this.execute(kt)}},{key:"deactivateAll",value:function(){this._graphics.deactivateAll(),this._graphics.renderAll()}},{key:"discardSelection",value:function(){this._graphics.discardSelection()}},{key:"changeSelectableAll",value:function(t){this._graphics.changeSelectableAll(t)}},{key:"_initHistory",value:function(){this.ui&&this.ui.initHistory()}},{key:"_clearHistory",value:function(){this.ui&&this.ui.clearHistory()}},{key:"execute",value:function(t){for(var e,i,n,r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var s=O()(e=[this._graphics]).call(e,o);return(i=this._invoker).execute.apply(i,O()(n=[t]).call(n,_(s)))}},{key:"executeSilent",value:function(t){for(var e,i,n,r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var s=O()(e=[this._graphics]).call(e,o);return(i=this._invoker).executeSilent.apply(i,O()(n=[t]).call(n,_(s)))}},{key:"undo",value:function(){for(var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=L().resolve(),n=0;n<e;n+=1)i=i.then((function(){return t._invoker.undo()}));return i}},{key:"redo",value:function(){for(var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=L().resolve(),n=0;n<e;n+=1)i=i.then((function(){return t._invoker.redo()}));return i}},{key:"zoom",value:function(t){var e=t.x,i=t.y,n=t.zoomLevel;this._graphics.zoom({x:e,y:i},n)}},{key:"resetZoom",value:function(){this._graphics.resetZoom()}},{key:"startHandMode",value:function(){var t=this._graphics.getZoomMode();this.stopDrawingMode(),t!==Xe&&this._graphics.startHandMode()}},{key:"endHandMode",value:function(){var t=this._graphics.getZoomMode();this.stopDrawingMode(),t===Xe&&this._graphics.endHandMode()}},{key:"getCenterPoint",value:function(){return this._graphics.canvasImage.getCenterPoint()}},{key:"loadImageFromFile",value:function(t,e){if(!t)return L().reject(ci);var i=P().createObjectURL(t);return e=e||t.name,this.loadImageFromURL(i,e).then((function(e){return P().revokeObjectURL(t),e}))}},{key:"loadImageFromURL",value:function(t,e){return e&&t?this.execute(Tt,e,t):L().reject(ci)}},{key:"addImageObject",value:function(t){return t?this.execute(Wt,t):L().reject(ci)}},{key:"startDrawingMode",value:function(t,e){return this._graphics.startDrawingMode(t,e)}},{key:"stopDrawingMode",value:function(){this._graphics.stopDrawingMode()}},{key:"crop",value:function(t){var e=this._graphics.getCroppedImageData(t);return e?this.loadImageFromURL(e.url,e.imageName):L().reject(ci)}},{key:"getCropzoneRect",value:function(){return this._graphics.getCropzoneRect()}},{key:"setCropzoneRect",value:function(t){this._graphics.setCropzoneRect(t)}},{key:"_flip",value:function(t){return this.execute(Dt,t)}},{key:"flipX",value:function(){return this._flip("flipX")}},{key:"flipY",value:function(){return this._flip("flipY")}},{key:"resetFlip",value:function(){return this._flip("reset")}},{key:"_rotate",value:function(t,e,i){return i?this.executeSilent(At,t,e):this.execute(At,t,e)}},{key:"rotate",value:function(t,e){return console.log("isSilent",e),this._rotate("rotate",t,e)}},{key:"setAngle",value:function(t,e){return this._rotate("setAngle",t,e)}},{key:"setBrush",value:function(t){this._graphics.setBrush(t)}},{key:"setDrawingShape",value:function(t,e){this._graphics.setDrawingShape(t,e)}},{key:"setDrawingIcon",value:function(t,e){this._graphics.setIconStyle(t,e)}},{key:"addShape",value:function(t,e){return e=e||{},this._setPositions(e),this.execute(zt,t,e)}},{key:"changeShape",value:function(t,e,i){return this[i?"executeSilent":"execute"](Bt,t,e)}},{key:"addText",value:function(t,e){return t=t||"",e=e||{},this.execute(Rt,t,e)}},{key:"changeText",value:function(t,e){return e=e||"",this.execute(Ft,t,e)}},{key:"changeTextStyle",value:function(t,e,i){return this[i?"executeSilent":"execute"](Yt,t,e)}},{key:"_changeActivateMode",value:function(t){"ICON"!==t&&this.getDrawingMode()!==t&&this.startDrawingMode(t)}},{key:"_onTextChanged",value:function(t){this.fire(ee,t)}},{key:"_onIconCreateResize",value:function(t){this.fire(ie,t)}},{key:"_onIconCreateEnd",value:function(t){this.fire(ne,t)}},{key:"_onTextEditing",value:function(){this.fire(te)}},{key:"_onAddText",value:function(t){this.fire(re,{originPosition:t.originPosition,clientPosition:t.clientPosition})}},{key:"_onAddObject",value:function(t){var e=this._graphics.getObject(t.id);this._invoker.fire(fe,Qi(e.type)),this._pushAddObjectCommand(e)}},{key:"_onObjectAdded",value:function(t){this.fire(Ns,t),this.fire(Gs,t)}},{key:"_onObjectModified",value:function(t){t.type!==mt&&(this._invoker.fire(fe,Qi(t.type)),this._pushModifyObjectCommand(t))}},{key:"_selectionCleared",value:function(){this.fire(Hs)}},{key:"_selectionCreated",value:function(t){this.fire(Us,t)}},{key:"registerIcons",value:function(t){this._graphics.registerPaths(t)}},{key:"changeCursor",value:function(t){this._graphics.changeCursor(t)}},{key:"addIcon",value:function(t,e){return e=e||{},this._setPositions(e),this.execute(Nt,t,e)}},{key:"changeIconColor",value:function(t,e){return this.execute(Pt,t,e)}},{key:"removeObject",value:function(t){var e=this._graphics.getObject(t).type;return this.execute(Ot,t,Qi(e))}},{key:"hasFilter",value:function(t){return this._graphics.hasFilter(t)}},{key:"removeFilter",value:function(t){return this.execute(Lt,t)}},{key:"applyFilter",value:function(t,e,i){return this[i?"executeSilent":"execute"](Et,t,e)}},{key:"toDataURL",value:function(t){return this._graphics.toDataURL(t)}},{key:"getImageName",value:function(){return this._graphics.getImageName()}},{key:"clearUndoStack",value:function(){this._invoker.clearUndoStack()}},{key:"clearRedoStack",value:function(){this._invoker.clearRedoStack()}},{key:"isEmptyUndoStack",value:function(){return this._invoker.isEmptyUndoStack()}},{key:"isEmptyRedoStack",value:function(){return this._invoker.isEmptyRedoStack()}},{key:"resizeCanvasDimension",value:function(t){return t?this.execute(Ht,t):L().reject(ci)}},{key:"destroy",value:function(){var t=this;this.stopDrawingMode(),this._detachDomEvents(),this._graphics.destroy(),this._graphics=null,this.ui&&(this._detachColorPickerInputBoxEvents(),this.ui.destroy()),H()(this,(function(e,i){t[i]=null}),this)}},{key:"_setPositions",value:function(t){var e=this._graphics.getCenter();Y()(t.left)&&(t.left=e.left),Y()(t.top)&&(t.top=e.top)}},{key:"setObjectProperties",value:function(t,e){return this.execute(Ut,t,e)}},{key:"setObjectPropertiesQuietly",value:function(t,e){this._graphics.setObjectProperties(t,e)}},{key:"getObjectProperties",value:function(t,e){return this._graphics.getObject(t)?this._graphics.getObjectProperties(t,e):null}},{key:"getCanvasSize",value:function(){return this._graphics.getCanvasSize()}},{key:"getObjectPosition",value:function(t,e,i){return this._graphics.getObjectPosition(t,e,i)}},{key:"setObjectPosition",value:function(t,e){return this.execute(Gt,t,e)}},{key:"resize",value:function(t){return this.execute(Zt,t)}}]),t}();oo.mixin(Xs),G().mixin(Xs);var Zs=Xs,Vs=St.ICON,Js={name:Nt,execute:function(t,e,i){var n=this;return t.getComponent(Vs).add(e,i).then((function(e){return n.undoData.object=t.getObject(e.id),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(Js);var Qs={name:Wt,execute:function(t,e){var i=this;return t.addImageObject(e).then((function(e){return i.undoData.object=t.getObject(e.id),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(Qs);var Ks={name:jt,execute:function(t,e){return new(L())((function(i,n){t.contains(e)?n(ai):(t.add(e),i(e))}))},undo:function(t,e){return new(L())((function(i,n){t.contains(e)?(t.remove(e),i(e)):n(fi)}))}};un.register(Ks);var qs=St.SHAPE,$s={name:zt,execute:function(t,e,i){var n=this;return t.getComponent(qs).add(e,i).then((function(e){var i=e.id;return n.undoData.object=t.getObject(i),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register($s);var tc=St.TEXT,ec={name:Rt,execute:function(t,e,i){var n=this,r=t.getComponent(tc);if(this.undoData.object){var o=this.undoData.object;return new(L())((function(e,i){t.contains(o)?i(gi):(t.add(o),e(o))}))}return r.add(e,i).then((function(e){var i=e.id,r=t.getObject(i);return n.undoData.object=r,ms(ys(r,(function(){return bs(i,r,!1)}))),e}))},undo:function(t){return t.remove(this.undoData.object),L().resolve()}};un.register(ec);var ic=St.FILTER,nc=null;var rc={name:Et,execute:function(t,e,i,n){var r=t.getComponent(ic);if("mask"===e){var o=t.getObject(i.maskObjId);if(!o||!o.isType("image"))return L().reject(ci);R()(i,{mask:o}),t.remove(i.mask)}if(!this.isRedo){var a=function(t,e,i){var n={};return"mask"===t&&(n.object=i.mask),n.options=e,n}(e,r.getOptions(e),i);nc=this.setUndoData(a,nc,n)}return r.add(e,i)},undo:function(t,e){var i=t.getComponent(ic);if("mask"===e){var n=this.undoData.object;return t.add(n),t.setActiveObject(n),i.remove(e)}return this.undoData.options?i.add(e,this.undoData.options):i.remove(e)}};un.register(rc);var oc=St.ICON,ac={name:Pt,execute:function(t,e,i){var n=this;return new(L())((function(r,o){var a=t.getComponent(oc),s=t.getObject(e);s||o(fi),n.undoData.object=s,n.undoData.color=a.getColor(s),a.setColor(i,s),r()}))},undo:function(t){var e=t.getComponent(oc),i=this.undoData,n=i.object,r=i.color;return e.setColor(r,n),L().resolve()}};un.register(ac);var sc=St.SHAPE,cc=null;var lc={name:Bt,execute:function(t,e,i,n){var r=t.getComponent(sc),o=t.getObject(e);if(!o)return L().reject(fi);if(!this.isRedo){var a=function(t,e){var i={object:e,options:{}};return lo()(t,(function(t,n){i.options[n]=e[n]})),i}(i,o);cc=this.setUndoData(a,cc,n)}return r.change(o,i)},undo:function(t){var e=t.getComponent(sc),i=this.undoData,n=i.object,r=i.options;return e.change(n,r)}};un.register(lc);var uc=St.TEXT,hc={name:Ft,execute:function(t,e,i){var n=t.getComponent(uc),r=t.getObject(e);return r?(this.undoData.object=r,this.undoData.text=n.getText(r),n.change(r,i)):L().reject(fi)},undo:function(t){var e=t.getComponent(uc),i=this.undoData,n=i.object,r=i.text;return e.change(n,r)}};un.register(hc);var fc=St.TEXT,gc=null;var dc={name:Yt,execute:function(t,e,i,n){var r=t.getComponent(fc),o=t.getObject(e);if(!o)return L().reject(fi);if(!this.isRedo){var a=function(t,e){var i={object:e,styles:{}};return lo()(t,(function(t,n){var r=e[n];i.styles[n]=r})),i}(i,o);gc=this.setUndoData(a,gc,n)}return r.setStyle(o,i)},undo:function(t){var e=t.getComponent(fc),i=this.undoData,n=i.object,r=i.styles;return e.setStyle(n,r)}};un.register(dc);var vc={name:kt,execute:function(t){var e=this;return new(L())((function(i){e.undoData.objects=t.removeAll(),i()}))},undo:function(t){return t.add(this.undoData.objects),L().resolve()}};un.register(vc);var pc=St.FLIP,mc={name:Dt,execute:function(t,e){var i=t.getComponent(pc);return this.undoData.setting=i.getCurrentSetting(),i[e]()},undo:function(t){return t.getComponent(pc).set(this.undoData.setting)}};un.register(mc);var yc=St.IMAGE_LOADER,bc={name:Tt,execute:function(t,e,i){var n,r=t.getComponent(yc),o=r.getCanvasImage(),a=o?o.width:0,s=o?o.height:0,c=no()(n=t.removeAll(!0)).call(n,(function(t){return"cropzone"!==t.type}));return et()(c).call(c,(function(t){t.evented=!0})),this.undoData={name:r.getImageName(),image:o,objects:c},r.load(e,i).then((function(t){return{oldWidth:a,oldHeight:s,newWidth:t.width,newHeight:t.height}}))},undo:function(t){var e=t.getComponent(yc),i=this.undoData,n=i.objects,r=i.name,o=i.image;return t.removeAll(!0),t.add(n),e.load(r,o)}};un.register(bc);var xc=St.FILTER,Cc={name:Lt,execute:function(t,e){var i=t.getComponent(xc);return this.undoData.options=i.getOptions(e),i.remove(e)},undo:function(t,e){var i=t.getComponent(xc),n=this.undoData.options;return i.add(e,n)}};un.register(Cc);var Ic={name:Ot,execute:function(t,e){var i=this;return new(L())((function(n,r){i.undoData.objects=t.removeObjectById(e),i.undoData.objects.length?n():r(fi)}))},undo:function(t){return t.add(this.undoData.objects),L().resolve()}};un.register(Ic);var _c={name:Ht,execute:function(t,e){var i=this;return new(L())((function(n){i.undoData.size={width:t.cssMaxWidth,height:t.cssMaxHeight},t.setCssMaxDimension(e),t.adjustCanvasDimension(),n()}))},undo:function(t){return t.setCssMaxDimension(this.undoData.size),t.adjustCanvasDimension(),L().resolve()}};un.register(_c);var Mc=St.ROTATION,Sc=null;var wc={name:At,execute:function(t,e,i,n){var r=t.getComponent(Mc);if(!this.isRedo){var o=function(t){return{angle:t.getCurrentAngle()}}(r);Sc=this.setUndoData(o,Sc,n)}return r[e](i)},undo:function(t){var e=t.getComponent(Mc),i=Q(this.args,3),n=i[1],r=i[2];return"setAngle"===n?e[n](this.undoData.angle):e.rotate(-r)}};un.register(wc);var kc={name:Ut,execute:function(t,e,i){var n=this,r=t.getObject(e);return r?(this.undoData.props={},lo()(i,(function(t,e){n.undoData.props[e]=r[e]})),t.setObjectProperties(e,i),L().resolve()):L().reject(fi)},undo:function(t,e){var i=this.undoData.props;return t.setObjectProperties(e,i),L().resolve()}};un.register(kc);var Tc={name:Gt,execute:function(t,e,i){return t.getObject(e)?(this.undoData.objectId=e,this.undoData.props=t.getObjectProperties(e,["left","top"]),t.setObjectPosition(e,i),t.renderAll(),L().resolve()):L().reject(fi)},undo:function(t){var e=this.undoData,i=e.objectId,n=e.props;return t.setObjectProperties(i,n),t.renderAll(),L().resolve()}};un.register(Tc);var Dc={name:Xt,execute:function(t,e){return this.isRedo?et()(e).call(e,(function(e){t.setObjectProperties(e.id,e)})):this.undoData=ps,L().resolve()},undo:function(t){var e;return et()(e=this.undoData).call(e,(function(e){t.setObjectProperties(e.id,e)})),L().resolve()}};un.register(Dc);var Ac=St.RESIZE,jc={name:Zt,execute:function(t,e){var i=t.getComponent(Ac),n=i.getOriginalDimensions();return n||(n=i.getCurrentDimensions()),this.undoData.dimensions=n,i.resize(e)},undo:function(t){return t.getComponent(Ac).resize(this.undoData.dimensions)}};un.register(jc);var Oc=Zs}(),r=r.default}()}));