@syncfusion/ej2-image-editor 20.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +244 -0
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +63 -0
- package/.github/PULL_REQUEST_TEMPLATE/feature.md +39 -0
- package/CHANGELOG.md +18 -0
- package/README.md +6 -0
- package/dist/ej2-image-editor.umd.min.js +11 -0
- package/dist/ej2-image-editor.umd.min.js.map +1 -0
- package/dist/es6/ej2-image-editor.es2015.js +7511 -0
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -0
- package/dist/es6/ej2-image-editor.es5.js +7550 -0
- package/dist/es6/ej2-image-editor.es5.js.map +1 -0
- package/dist/global/ej2-image-editor.min.js +11 -0
- package/dist/global/ej2-image-editor.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/helpers/e2e/imageEditorHelper.d.ts +37 -0
- package/helpers/e2e/imageEditorHelper.js +53 -0
- package/helpers/e2e/index.d.ts +1 -0
- package/helpers/e2e/index.js +8 -0
- package/helpers/e2e/querybuilderHelper.d.ts +37 -0
- package/image-editor.d.ts +4 -0
- package/image-editor.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +74 -0
- package/src/global.js +1 -0
- package/src/image-editor/image-editor-model.d.ts +206 -0
- package/src/image-editor/image-editor.d.ts +961 -0
- package/src/image-editor/image-editor.js +7542 -0
- package/src/image-editor/index.d.ts +5 -0
- package/src/image-editor/index.js +4 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/styles/bootstrap-dark.css +283 -0
- package/styles/bootstrap-dark.scss +1 -0
- package/styles/bootstrap.css +283 -0
- package/styles/bootstrap.scss +1 -0
- package/styles/bootstrap4.css +279 -0
- package/styles/bootstrap4.scss +1 -0
- package/styles/bootstrap5-dark.css +301 -0
- package/styles/bootstrap5-dark.scss +1 -0
- package/styles/bootstrap5.css +301 -0
- package/styles/bootstrap5.scss +1 -0
- package/styles/fabric-dark.css +283 -0
- package/styles/fabric-dark.scss +1 -0
- package/styles/fabric.css +283 -0
- package/styles/fabric.scss +1 -0
- package/styles/fluent-dark.css +290 -0
- package/styles/fluent-dark.scss +1 -0
- package/styles/fluent.css +290 -0
- package/styles/fluent.scss +1 -0
- package/styles/highcontrast-light.css +281 -0
- package/styles/highcontrast-light.scss +1 -0
- package/styles/highcontrast.css +281 -0
- package/styles/highcontrast.scss +1 -0
- package/styles/image-editor/_all.scss +2 -0
- package/styles/image-editor/_bootstrap-dark-definition.scss +10 -0
- package/styles/image-editor/_bootstrap-definition.scss +10 -0
- package/styles/image-editor/_bootstrap4-definition.scss +10 -0
- package/styles/image-editor/_bootstrap5-dark-definition.scss +1 -0
- package/styles/image-editor/_bootstrap5-definition.scss +10 -0
- package/styles/image-editor/_fabric-dark-definition.scss +10 -0
- package/styles/image-editor/_fabric-definition.scss +10 -0
- package/styles/image-editor/_fluent-dark-definition.scss +1 -0
- package/styles/image-editor/_fluent-definition.scss +10 -0
- package/styles/image-editor/_fusionnew-definition.scss +10 -0
- package/styles/image-editor/_highcontrast-definition.scss +10 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +10 -0
- package/styles/image-editor/_layout.scss +204 -0
- package/styles/image-editor/_material-dark-definition.scss +10 -0
- package/styles/image-editor/_material-definition.scss +10 -0
- package/styles/image-editor/_material3-definition.scss +10 -0
- package/styles/image-editor/_tailwind-dark-definition.scss +1 -0
- package/styles/image-editor/_tailwind-definition.scss +10 -0
- package/styles/image-editor/_theme.scss +97 -0
- package/styles/image-editor/bootstrap-dark.css +283 -0
- package/styles/image-editor/bootstrap-dark.scss +12 -0
- package/styles/image-editor/bootstrap.css +283 -0
- package/styles/image-editor/bootstrap.scss +12 -0
- package/styles/image-editor/bootstrap4.css +279 -0
- package/styles/image-editor/bootstrap4.scss +12 -0
- package/styles/image-editor/bootstrap5-dark.css +301 -0
- package/styles/image-editor/bootstrap5-dark.scss +12 -0
- package/styles/image-editor/bootstrap5.css +301 -0
- package/styles/image-editor/bootstrap5.scss +12 -0
- package/styles/image-editor/fabric-dark.css +283 -0
- package/styles/image-editor/fabric-dark.scss +12 -0
- package/styles/image-editor/fabric.css +283 -0
- package/styles/image-editor/fabric.scss +12 -0
- package/styles/image-editor/fluent-dark.css +290 -0
- package/styles/image-editor/fluent-dark.scss +12 -0
- package/styles/image-editor/fluent.css +290 -0
- package/styles/image-editor/fluent.scss +12 -0
- package/styles/image-editor/highcontrast-light.css +281 -0
- package/styles/image-editor/highcontrast-light.scss +12 -0
- package/styles/image-editor/highcontrast.css +281 -0
- package/styles/image-editor/highcontrast.scss +12 -0
- package/styles/image-editor/icons/_bootstrap-dark.scss +218 -0
- package/styles/image-editor/icons/_bootstrap.scss +218 -0
- package/styles/image-editor/icons/_bootstrap4.scss +218 -0
- package/styles/image-editor/icons/_bootstrap5-dark.scss +1 -0
- package/styles/image-editor/icons/_bootstrap5.scss +224 -0
- package/styles/image-editor/icons/_fabric-dark.scss +218 -0
- package/styles/image-editor/icons/_fabric.scss +218 -0
- package/styles/image-editor/icons/_fluent-dark.scss +1 -0
- package/styles/image-editor/icons/_fluent.scss +224 -0
- package/styles/image-editor/icons/_fusionnew.scss +224 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +218 -0
- package/styles/image-editor/icons/_highcontrast.scss +218 -0
- package/styles/image-editor/icons/_material-dark.scss +218 -0
- package/styles/image-editor/icons/_material.scss +218 -0
- package/styles/image-editor/icons/_material3.scss +230 -0
- package/styles/image-editor/icons/_tailwind-dark.scss +1 -0
- package/styles/image-editor/icons/_tailwind.scss +218 -0
- package/styles/image-editor/material-dark.css +299 -0
- package/styles/image-editor/material-dark.scss +12 -0
- package/styles/image-editor/material.css +299 -0
- package/styles/image-editor/material.scss +12 -0
- package/styles/image-editor/tailwind-dark.css +288 -0
- package/styles/image-editor/tailwind-dark.scss +12 -0
- package/styles/image-editor/tailwind.css +288 -0
- package/styles/image-editor/tailwind.scss +12 -0
- package/styles/material-dark.css +299 -0
- package/styles/material-dark.scss +1 -0
- package/styles/material.css +299 -0
- package/styles/material.scss +1 -0
- package/styles/tailwind-dark.css +288 -0
- package/styles/tailwind-dark.scss +1 -0
- package/styles/tailwind.css +288 -0
- package/styles/tailwind.scss +1 -0
- package/tslint.json +111 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* filename: ej2-image-editor.min.js
|
|
3
|
+
* version : 20.3.47
|
|
4
|
+
* Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
|
|
5
|
+
* Use of this code is subject to the terms of our license.
|
|
6
|
+
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
|
+
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
8
|
+
* applicable laws.
|
|
9
|
+
*/
|
|
10
|
+
this.ej=this.ej||{},this.ej.imageeditor=function(t,e,i,s,a,o){"use strict";var r=function(){var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(e,i)};return function(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),n=function(t,e,i,s){var a,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(a=t[n])&&(r=(o<3?a(r):o>3?a(e,i,r):a(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r},h=function(t){function h(e,i){var s=t.call(this,e,i)||this;return s.degree=0,s.isUndoRedo=!1,s.dragCanvas=!1,s.dragElement="",s.keyHistory="",s.flipState="",s.mouseDownPoint={x:0,y:0},s.previousPoint={x:0,y:0},s.dragPoint={startX:0,startY:0,endX:0,endY:0},s.diffPoint={x:0,y:0},s.oldPoint={},s.zoomedImg={startX:0,startY:0,endX:0,endY:0,width:0,height:0},s.objColl=[],s.undoRedoColl=[],s.imgDataColl=[],s.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},s.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,bold:!1,italic:!1,underline:!1},s.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},s.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,bold:!1,italic:!1,underline:!1},s.toolbarHeight=46,s.pannStart={},s.pannEnd={},s.togglePan=!1,s.lastX=0,s.lastY=0,s.dragStart={x:0,y:0},s.dragged=!1,s.factor=1,s.currFlipState="",s.touchEndPoint={},s.flipMethod=!1,s.flipDirection="",s.prevX=0,s.currX=0,s.prevY=0,s.currY=0,s.togglePen=!1,s.rotateMethod=!1,s.isBoldbtn=!1,s.isItalicbtn=!1,s.lastAction="",s.currentToolbar="main",s.textStartPoints={x:0,y:0},s.fontSizeColl=[],s.tempKeyHistory="",s.penDrawColl=[],s.allowDrag=!1,s.textRow=1,s.activeObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[]},s.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1},s.defToolbarItems=[],s.baseImgSrc="",s.isTimer=!1,s.isScreenOriented=!1,s}r(h,t),l=h,h.prototype.preRender=function(){this.element.id=this.element.id||e.getUniqueID("ej2-image-editor"),e.Browser.isDevice&&this.element.classList.add("e-device"),this.themeColl={Bootstrap5:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Bootstrap5Dark:{primaryColor:"#0d6efd",secondaryColor:"#fff"},Tailwind:{primaryColor:"#4f46e5",secondaryColor:"#fff"},TailwindDark:{primaryColor:"#22d3ee",secondaryColor:"#fff"},Fluent:{primaryColor:"#0078d4",secondaryColor:"#fff"},FluentDark:{primaryColor:"#0078d4",secondaryColor:"#fff"},Bootstrap4:{primaryColor:"#007bff",secondaryColor:"#fff"},Bootstrap:{primaryColor:"#317ab9",secondaryColor:"#fff"},BootstrapDark:{primaryColor:"#317ab9",secondaryColor:"#fff"},Material:{primaryColor:"#e3165b",secondaryColor:"#fff"},MaterialDark:{primaryColor:"#00b0ff",secondaryColor:"#fff"},Fabric:{primaryColor:"#0078d6",secondaryColor:"#fff"},FabricDark:{primaryColor:"#0074cc",secondaryColor:"#fff"},Highcontrast:{primaryColor:"#000000",secondaryColor:"#fff"}},this.defaultLocale={Crop:"Crop",ZoomIn:"Zoom In",ZoomOut:"Zoom Out",Transform:"Transform",Annotation:"Annotation",Text:"Add Text",Pen:"Pen",Reset:"Reset",Save:"Save",Select:"Select",RotateLeft:"Rotate Left",RotateRight:"Rotate Right",HorizontalFlip:"Horizontal Flip",VerticalFlip:"Vertical Flip",OK:"OK",Cancel:"Cancel",FillColor:"Fill Color",StrokeColor:"Stroke Color",StrokeWidth:"Stroke Width",FontFamily:"Font Family",FontStyle:"Font Style",FontSize:"Font Size",FontColor:"Font Color",Pan:"Pan",Move:"Move",Load:"Load",Custom:"Custom",Square:"Square",Circle:"Circle",Ellipse:"Ellipse",Rectangle:"Rectangle",Line:"Line",Default:"Default",Bold:"Bold",Italic:"Italic",BoldItalic:"Bold Italic",XSmall:"X-Small",Small:"Small",Medium:"Medium",Large:"Large",XLarge:"X-Large",ABC:"ABC"},this.l10n=new e.L10n("image-editor",this.defaultLocale,this.locale)},h.prototype.render=function(){this.initialize()},h.prototype.getModuleName=function(){return"image-editor"},h.prototype.getPersistData=function(){return this.addOnPersist([])},h.prototype.onPropertyChanged=function(t,i){for(var s=0,a=Object.keys(t);s<a.length;s++)switch(a[s]){case"cssClass":i.cssClass&&e.removeClass([this.element],i.cssClass.split(" ")),t.cssClass&&e.addClass([this.element],t.cssClass.split(" "));break;case"disabled":t.disabled?(this.element.classList.add("e-disabled"),this.unwireEvent()):(this.element.classList.remove("e-disabled"),this.wireEvent());break;case"height":this.element.style.height=t.height;break;case"width":this.element.style.width=t.width;break;case"theme":t.theme&&(this.updateTheme(),this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.fillStyle=this.themeColl[this.theme].secondaryColor)}},h.prototype.destroy=function(){var i=[];this.element.removeAttribute("tabindex"),this.cssClass&&(i=i.concat(this.cssClass.split(" "))),e.removeClass([this.element],i),this.element.getAttribute("class")||this.element.removeAttribute("class"),this.unwireEvent(),t.prototype.destroy.call(this),this.element.innerHTML="",this.trigger("destroyed")},h.prototype.initialize=function(){this.createToolbar(),this.createCanvas(),this.wireEvent(),this.updateContext(this.lowerContext),this.updateContext(this.upperContext),this.pannStart={startX:0,startY:0,width:0,height:0},this.pannEnd={startX:0,startY:0,width:0,height:0},this.cssClass&&e.addClass([this.element],this.cssClass.split(" ")),this.element&&o.createSpinner({target:this.element})},h.prototype.wireEvent=function(){e.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),e.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),e.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),e.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),e.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),e.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(document,"mouseup",this.canvasMouseUpHandler,this),e.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),e.EventHandler.add(this.upperCanvas,"dblclick",this.findTextPoint,this),e.EventHandler.add(this.textBox,"mousedown",this.findTextPoint,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),e.Browser.isIos||"safari"===e.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this))},h.prototype.unwireEvent=function(){e.EventHandler.remove(document,"keydown",this.keyDownEventHandler),e.EventHandler.remove(document,"keypress",this.keyUpEventHandler),e.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),e.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),e.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),e.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),e.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),e.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),e.EventHandler.remove(document,"mouseup",this.canvasMouseUpHandler)},h.prototype.updateTheme=function(){""!==this.theme&&(this.theme=this.toPascalCase(this.theme))},h.prototype.toPascalCase=function(t){for(var e=t.toLowerCase().split("-"),i=0;i<e.length;i++)e[i]=e[i].charAt(0).toUpperCase()+e[i].slice(1);return e.join("")},h.prototype.createCanvas=function(){var t=this.toolbarHeight;this.element.style.width=this.width,this.element.style.height=this.height;var e=this.element.appendChild(this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper",attrs:{style:"height:"+(this.element.offsetHeight-t)+"px; width:"+this.element.offsetWidth+"px; position: relative; overflow: hidden; margin: 0 auto;"}}));this.lowerCanvas=e.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.upperCanvas=e.appendChild(this.createElement("canvas",{id:this.element.id+"_upperCanvas",attrs:{name:"canvasImage"}})),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.textBox=e.appendChild(this.createElement("textarea",{id:this.element.id+"_textBox",attrs:{name:"textBox"}})),this.textBox.setAttribute("spellcheck","false"),this.upperCanvas.width=this.lowerCanvas.width=this.inMemoryCanvas.width=this.element.offsetWidth,this.upperCanvas.height=this.lowerCanvas.height=this.inMemoryCanvas.height=this.element.offsetHeight-this.toolbarHeight,this.upperCanvas.style.position=this.lowerCanvas.style.position=this.textBox.style.position="absolute",this.textBox.style.backgroundColor="transparent",this.textBox.style.display="none",this.textBox.style.resize="none",this.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperCanvas.style.cursor="default",this.upperCanvas.style.display="none",this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d")},h.prototype.createToolbar=function(){var t=this;if(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.length>0){if(this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplate)this.toolbarTemplateFn();else{var a={cssClass:"e-image-upload",align:"Left",type:"Input",template:new i.Uploader({})};e.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(a);var o=document.getElementById(this.element.id+"_toolbarArea"),r=this.createElement("div",{id:this.element.id+"_toolbar"});o.appendChild(r);var n=[{cssClass:"e-image-upload",align:"Left",type:"Input",template:new i.Uploader({selected:function(){e.Browser.isDevice?(t.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(t.element.id+"_toolbar"))&&e.getComponent(document.getElementById(t.element.id+"_toolbar"),"toolbar").destroy(),e.isNullOrUndefined(document.getElementById(t.element.id+"_bottomToolbar"))||e.getComponent(document.getElementById(t.element.id+"_bottomToolbar"),"toolbar").destroy(),t.initToolbarItem(!1,e.Browser.isDevice),t.createBottomToolbar()):(t.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(t.element.id+"_toolbar"))&&e.getComponent(document.getElementById(t.element.id+"_toolbar"),"toolbar").destroy(),t.initToolbarItem(!1,!1))}})}];new s.Toolbar({items:n,width:"100%",created:function(){t.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)},"#"+this.element.id+"_toolbar"),this.createLeftToolbarControls()}e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))||(this.toolbarHeight=document.getElementById(this.element.id+"_toolbar").clientHeight)}else this.toolbarHeight=0},h.prototype.createBottomToolbar=function(){if(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.length>0){if(this.element.appendChild(this.createElement("div",{id:this.element.id+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!this.toolbarTemplate){document.getElementById(this.element.id+"_canvasWrapper").style.height=this.element.offsetHeight-2*this.toolbarHeight-3+"px";var t=document.getElementById(this.element.id+"_bottomToolbarArea"),i=this.createElement("div",{id:this.element.id+"_bottomToolbar"});t.appendChild(i)}this.initBottomToolbar()}},h.prototype.initBottomToolbar=function(){var t=this;if(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.length>0)if(this.toolbarTemplate)this.toolbarTemplateFn();else{var i=this.getMainToolbarItem();new s.Toolbar({items:i,width:"100%",created:function(){t.renderAnnotationBtn(),t.renderCropBtn(),t.renderTransformBtn(),t.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)},"#"+this.element.id+"_bottomToolbar"),this.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(this.element.id+"_bottomToolbar"))&&e.getComponent(this.element.id+"_bottomToolbar","toolbar").refreshOverflow()}},h.prototype.toolbarTemplateFn=function(){var t,e=this.element.id+"_toolbar",i=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];else if(this.isAngular){var s=this.toolbarFn({type:"toolbar"},this,"Template",e);t=3===s[0].nodeType?s[1]:s[0]}else t=this.toolbarFn({type:"toolbar"},this,"Template",e)[0];i.appendChild(t),this.renderReactTemplates()}},h.prototype.templateParser=function(t){if(t)try{return document.querySelectorAll(t).length?e.compile(document.querySelector(t).innerHTML.trim()):e.compile(t)}catch(i){return e.compile(t)}},h.prototype.getLeftToolbarItem=function(t){var s=[];t||(s.push({cssClass:"e-image-upload",align:"Left",type:"Input",template:new i.Uploader({})}),s.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:"Position",align:"Left"})),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("ZoomOut")>-1)&&s.push({id:this.element.id+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("ZoomIn")>-1)&&s.push({id:this.element.id+"_zoomIn",prefixIcon:"e-icons e-zoom-in",cssClass:"top-icon e-inc-zoom",tooltipText:this.l10n.getConstant("ZoomIn"),align:"Left"});for(var a=this.processToolbar("left"),o=0,r=a.length;o<r;o++)s.push(a[o]);return s},h.prototype.getRightToolbarItem=function(t){var i=[];t&&(i.push({id:this.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:this.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Reset")>-1)&&i.push({id:this.element.id+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),t||(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Save")>-1)&&i.push({id:this.element.id+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right",template:'<button id="'+this.element.id+'_saveBtn"></button>'});for(var s=this.processToolbar("right"),a=0,o=s.length;a<o;a++)i.push(s[a]);return i},h.prototype.getMainToolbarItem=function(t){var i=[];(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Crop")>-1)&&i.push({id:this.element.id+"_crop",tooltipText:this.l10n.getConstant("Crop"),align:"Center",template:'<button id="'+this.element.id+'_cropBtn"></button>'}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Annotate")>-1)&&i.push({id:this.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+this.element.id+'_annotationBtn"></button>'}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Transform")>-1)&&i.push({id:this.element.id+"_transform",tooltipText:this.l10n.getConstant("Transform"),align:"Center",template:'<button id="'+this.element.id+'_transformBtn"></button>'});for(var s=this.processToolbar("center"),a=0,o=s.length;a<o;a++)i.push(s[a]);return t&&(i.push({id:this.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:this.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},h.prototype.getZoomToolbarItem=function(){var t=[];return this.factor>1&&(t=[{id:this.element.id+"_pan",prefixIcon:"e-icons e-pan",cssClass:"top-icon e-img-pan",tooltipText:this.l10n.getConstant("Pan"),align:"Left"}]),t},h.prototype.processToolbar=function(t){var i=[];if(this.toolbar)for(var s=0,a=this.toolbar.length;s<a;s++)"object"==typeof this.toolbar[s]&&(e.isNullOrUndefined(this.toolbar[s].align)?"left"===t&&i.push(this.toolbar[s]):this.toolbar[s].align.toLowerCase()===t&&i.push(this.toolbar[s]));return i},h.prototype.processSubToolbar=function(t){var e=[];if(t)for(var i=0,s=t.length;i<s;i++)"object"==typeof t[i]&&(t[i].align="Center",e.push(t[i]));return e},h.prototype.isToolbar=function(){return e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.length>0||!e.isNullOrUndefined(this.toolbarTemplate)},h.prototype.initToolbarItem=function(t,i,a){var o=this;if(this.isToolbar()){var r=this.getLeftToolbarItem(a),n=this.getRightToolbarItem(a),h=this.getMainToolbarItem(t),l=this.getZoomToolbarItem();this.defToolbarItems=i?r.concat(l,n):r.concat(l,h,n),new s.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i||(o.renderAnnotationBtn(),o.renderCropBtn(),o.renderTransformBtn()),o.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"main"})}},"#"+this.element.id+"_toolbar"),this.createLeftToolbarControls();var c=document.querySelector("#"+this.element.id+"_zoomIn");!e.isNullOrUndefined(c)&&this.factor>=8?c.classList.add("e-disabled"):e.isNullOrUndefined(c)||c.classList.remove("e-disabled");var v=document.querySelector("#"+this.element.id+"_zoomOut");e.isNullOrUndefined(v)||1!==this.factor?e.isNullOrUndefined(v)||v.classList.remove("e-disabled"):v.classList.add("e-disabled");var d=document.querySelector("#"+this.element.id+"_pan");e.isNullOrUndefined(d)||1!==this.factor?e.isNullOrUndefined(d)||(d.style.display="block"):d.style.display="none",this.isToolbar()&&!e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))&&e.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow()}},h.prototype.createLeftToolbarControls=function(){if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))){var t=document.getElementById(this.element.id+"_toolbar").querySelector(".e-image-upload");if(t){var i=t.getElementsByTagName("input")[0],s=t.getElementsByTagName("button")[0];s.className="e-tbar-btn e-tbtn-txt e-btn top-icon",s.innerHTML="",s.appendChild(this.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},h.prototype.renderAnnotationBtn=function(){var t=this,i=this,s=[];(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Pen")>-1)&&s.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Line")>-1)&&s.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Rectangle")>-1)&&s.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Ellipse")>-1)&&s.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("Text")>-1)&&s.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"});var o=new a.DropDownButton({items:s,iconCss:"e-icons e-annotation",cssClass:"e-image-popup",open:function(i){t.togglePan&&t.cancelPan(),e.Browser.isDevice&&(i.element.parentElement.style.top=o.element.getBoundingClientRect().top-i.element.parentElement.offsetHeight+"px")},select:function(e){var s,a=!1;switch(void 0!==t.activeObj.shape&&(s=t.activeObj.shape.split("-")),void 0===s&&t.currObjType.isCustomCrop?a=!0:void 0!==s&&"crop"===s[0]&&(a=!0),t.currObjType.isCustomCrop=!1,(a||t.togglePan)&&(t.refreshActiveObj(),t.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.refreshToolbar("main")),e.item.id){case"pen":i.currentToolbar="pen",t.freeHandDraw(!0);break;case"text":i.currentToolbar="text",t.drawShapeText();break;default:i.currentToolbar="shapes",i.drawShape(e.item.id.toLowerCase())}t.updateToolbarItems(t.calcRatio())}});o.appendTo("#"+this.element.id+"_annotationBtn")},h.prototype.renderCropBtn=function(){var t=this,i=[];(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("CustomSelection")>-1)&&i.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("CircleSelection")>-1)&&i.push({text:this.l10n.getConstant("Circle"),id:"ellipse",iconCss:"e-icons e-circle"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("SquareSelection")>-1)&&i.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("RatioSelection")>-1)&&(i.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),i.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),i.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),i.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),i.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"}));var s=new a.DropDownButton({open:function(i){t.togglePan&&t.cancelPan(),e.Browser.isDevice&&(i.element.parentElement.style.top=s.element.getBoundingClientRect().top-i.element.parentElement.offsetHeight+"px")},items:i,select:this.cropSelect.bind(this),iconCss:"e-icons e-select",cssClass:"e-image-popup"});s.appendTo("#"+this.element.id+"_cropBtn")},h.prototype.renderTransformBtn=function(){var t=this,i=[];(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("RotateLeft")>-1)&&i.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("RotateRight")>-1)&&i.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("FlipHorizontal")>-1)&&i.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),(e.isNullOrUndefined(this.toolbar)||!e.isNullOrUndefined(this.toolbar)&&this.toolbar.indexOf("FlipVertical")>-1)&&i.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var s=new a.DropDownButton({open:function(i){if(t.togglePan&&t.cancelPan(),e.Browser.isDevice){var a=i.element.parentElement.offsetHeight;i.element.parentElement.style.display="none",i.element.parentElement.style.top=s.element.getBoundingClientRect().top-a+"px",i.element.parentElement.style.display="block"}},items:i,select:this.transformSelect.bind(this),iconCss:"e-icons e-transform",cssClass:"e-image-popup"});s.appendTo("#"+this.element.id+"_transformBtn")},h.prototype.renderSaveBtn=function(){var t=this,i=e.getInstance(document.getElementById(this.element.id),l),s=[{text:"JPEG",id:"jpeg"},{text:"PNG",id:"png"},{text:"SVG",id:"svg"}];document.getElementById(this.element.id+"_saveBtn")&&new a.DropDownButton({items:s,cssClass:"e-caret-hide e-image-popup",iconCss:"e-icons e-save",select:function(e){t.togglePan&&t.cancelPan(),i.export(e.item.text)}}).appendTo("#"+this.element.id+"_saveBtn")},h.prototype.cropSelect=function(t){var e=t.item.text;this.select(e),this.refreshToolbar("main",!0,!0)},h.prototype.transformSelect=function(t){switch(t.item.id){case"rotateleft":this.rotate(-90);break;case"rotateright":this.rotate(90);break;case"horizontalflip":this.flip("Horizontal");break;case"verticalflip":this.flip("Vertical")}},h.prototype.getShapesToolbarItem=function(t){var i=[];t.indexOf("fillColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:this.element.id+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+this.element.id+'_fillColorBtn"></button>'}),t.indexOf("strokeColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:this.element.id+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+this.element.id+'_borderColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&i.push({id:this.element.id+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:"Stroke Width",align:"Center",type:"Input",template:'<button id="'+this.element.id+'_borderWidthBtn"></button>'});for(var s=this.processSubToolbar(t),a=0,o=s.length;a<o;a++)i.push(s[a]);return e.Browser.isDevice||(i.push({id:this.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:this.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},h.prototype.initShapesToolbarItem=function(t){var i=this,a=this.getLeftToolbarItem(),o=this.getRightToolbarItem(),r=this.getShapesToolbarItem(t),n=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=r:this.defToolbarItems=a.concat(n,r,o);var h=new s.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.createShapeColor(t),i.createShapeBtn(t),e.Browser.isDevice||i.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),e.Browser.isDevice?i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_bottomToolbar"))&&h.refreshOverflow():(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))&&h.refreshOverflow())}});e.Browser.isDevice?h.appendTo("#"+this.element.id+"_bottomToolbar"):h.appendTo("#"+this.element.id+"_toolbar")},h.prototype.createShapeColor=function(t){var s=this,o=this;if(t.indexOf("fillColor")>-1){this.element.querySelector(".e-template.e-fill").appendChild(this.createElement("input",{id:this.element.id+"_shape_fill"}));var r=new i.ColorPicker({modeSwitcher:!1,noColor:!0,value:"",showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",change:function(t){o.activeObj.strokeSettings.fillColor=t.currentValue.hex,o.strokeSettings.fillColor=o.activeObj.strokeSettings.fillColor,o.redrawShape(s.activeObj),""===t.currentValue.rgba?n.element.children[0].classList.add("e-nocolor-item"):(n.element.children[0].classList.remove("e-nocolor-item"),n.element.children[0].style.backgroundColor=t.currentValue.rgba),n.toggle()}},"#"+this.element.id+"_shape_fill"),n=new a.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=s.element.offsetLeft+"px")},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+this.element.id+"_fillColorBtn");r.inline=!0,this.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(t.indexOf("strokeColor")>-1){this.element.querySelector(".e-template.e-stroke").appendChild(this.createElement("input",{id:this.element.id+"_shape_stroke"}));var h=new i.ColorPicker({modeSwitcher:!1,noColor:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",change:function(t){o.activeObj.strokeSettings.strokeColor=t.currentValue.hex,o.strokeSettings.strokeColor=o.activeObj.strokeSettings.strokeColor,o.togglePen||o.redrawShape(s.activeObj),l.element.children[0].style.backgroundColor=t.currentValue.rgba,l.toggle()}},"#"+this.element.id+"_shape_stroke"),l=new a.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=l.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=s.element.offsetLeft+"px")},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview"},"#"+this.element.id+"_borderColorBtn");h.inline=!0,this.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},h.prototype.createShapeBtn=function(t){var i=this,s=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}],o=this.calcRatio();if(t.indexOf("strokeWidth")>-1){var r=document.getElementById(this.element.id+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("Small"),n.className="e-shape-stroke-width",r.appendChild(n);var h=new a.DropDownButton({items:s,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=h.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.activeObj.strokeSettings.strokeWidth=parseInt(t.item.id,10),i.lowerCanvas.width>i.lowerCanvas.height?i.activeObj.strokeSettings.strokeWidth*=(o.width+o.height)/i.factor:i.activeObj.strokeSettings.strokeWidth*=(o.height+o.width)/i.factor,i.strokeSettings.strokeWidth=i.activeObj.strokeSettings.strokeWidth,i.redrawShape(i.activeObj),e.Browser.isDevice?e.isNullOrUndefined(document.getElementById(i.element.id+"_bottomToolbar"))||e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))||e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});h.appendTo("#"+this.element.id+"_borderWidthBtn")}},h.prototype.getTextToolbarItem=function(t){var i=[];t.indexOf("fontFamily")>-1&&i.push({id:this.element.id+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+this.element.id+'_fontFamilyBtn"></button>'}),t.indexOf("fontStyle")>-1&&i.push({id:this.element.id+"_fontStyle",cssClass:"top-icon e-img-font-style",tooltipText:this.l10n.getConstant("FontStyle"),align:"Center",template:'<button id="'+this.element.id+'_fontStyleBtn"></button>'}),t.indexOf("fontSize")>-1&&i.push({id:this.element.id+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+this.element.id+'_fontSizeBtn"></button>'}),t.indexOf("fontColor")>-1&&i.push({cssClass:"top-icon e-text-font-color",id:this.element.id+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+this.element.id+'_fontColorBtn"></button>'});for(var s=this.processSubToolbar(t),a=0,o=s.length;a<o;a++)i.push(s[a]);return e.Browser.isDevice||(i.push({id:this.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:this.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},h.prototype.getFontFamilyItems=function(){return e.Browser.isDevice?[{id:"arial",text:"ABC"},{id:"calibri",text:"ABC"},{id:"georgia",text:"ABC"},{id:"roboto",text:"ABC"},{id:"tahoma",text:"ABC"}]:[{id:"arial",text:"Arial"},{id:"calibri",text:"Calibri"},{id:"georgia",text:"Georgia"},{id:"roboto",text:"Roboto"},{id:"tahoma",text:"Tahoma"}]},h.prototype.getFontSizeItems=function(){return e.Browser.isDevice?[{id:"default",text:this.l10n.getConstant("ABC")},{id:"bold",text:this.l10n.getConstant("ABC")},{id:"italic",text:this.l10n.getConstant("ABC")},{id:"bolditalic",text:this.l10n.getConstant("ABC")}]:[{id:"default",text:this.l10n.getConstant("Default")},{id:"bold",text:this.l10n.getConstant("Bold")},{id:"italic",text:this.l10n.getConstant("Italic")},{id:"bolditalic",text:this.l10n.getConstant("BoldItalic")}]},h.prototype.initTextToolbarItem=function(t){var i=this,a=this.getLeftToolbarItem(),o=this.getRightToolbarItem(),r=this.getTextToolbarItem(t),n=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=r:this.defToolbarItems=a.concat(n,r,o);var h=new s.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.createTextColor(t),i.createTextBtn(t),e.Browser.isDevice||i.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"text"}),e.Browser.isDevice?i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_bottomToolbar"))&&h.refreshOverflow():(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))&&h.refreshOverflow())}});e.Browser.isDevice?h.appendTo("#"+this.element.id+"_bottomToolbar"):h.appendTo("#"+this.element.id+"_toolbar")},h.prototype.createTextColor=function(t){var s=this,o=this;if(t.indexOf("fontColor")>-1){this.element.querySelector(".e-template.e-text-font-color").appendChild(this.createElement("input",{id:this.element.id+"_text_font"}));var r=new i.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",change:function(t){"none"===o.textBox.style.display?(o.strokeSettings.strokeColor=o.activeObj.strokeSettings.strokeColor=t.currentValue.hex,o.togglePen||o.redrawShape(s.activeObj)):"block"===o.textBox.style.display?o.textBox.style.color=t.currentValue.hex:o.togglePen||o.redrawShape(s.activeObj),n.element.children[0].style.backgroundColor=t.currentValue.rgba,n.toggle()}},"#"+this.element.id+"_text_font"),n=new a.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=s.element.offsetLeft+"px")},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview"},"#"+this.element.id+"_fontColorBtn");r.inline=!0,this.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},h.prototype.createTextBtn=function(t){var i=this,s=this.calcRatio();if(t.indexOf("fontFamily")>-1){var o=document.getElementById(this.element.id+"_fontFamilyBtn"),r=document.createElement("span");e.Browser.isDevice?(r.innerHTML="ABC",r.setAttribute("style","font-family: arial")):r.innerHTML="Arial",r.className="e-text-font-family",o.appendChild(r);var n=new a.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(t){t.element.setAttribute("style","font-family:"+t.element.id)},open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var s;s="block"===i.textBox.style.display?i.textBox.style.fontFamily:i.activeObj.textSettings.fontFamily,t.element.querySelector('[id *= "'+s.toLowerCase()+'"]').classList.add("e-selected-btn")},select:function(t){if(r.textContent=t.item.text,e.Browser.isDevice&&r.setAttribute("style","font-family:"+t.item.id),"block"===i.textBox.style.display){var a=i.activeObj.textSettings.fontFamily;i.activeObj.textSettings.fontFamily=i.toPascalCase(t.item.id),i.updateFontStyles();var o=i.upperContext.measureText(i.activeObj.keyHistory).width+.5*i.activeObj.textSettings.fontSize;i.textBox.style.width=e.Browser.isDevice?o+"px":o*((s.width+s.height)/2)+"px",i.textBox.style.fontFamily=i.toPascalCase(t.item.id),i.activeObj.textSettings.fontFamily=a,i.updateFontStyles()}else i.textSettings.fontFamily=i.activeObj.textSettings.fontFamily=i.toPascalCase(t.item.id),i.redrawText(s),i.redrawShape(i.activeObj)}});n.appendTo("#"+this.element.id+"_fontFamilyBtn")}if(t.indexOf("fontStyle")>-1){var h=document.getElementById(this.element.id+"_fontStyleBtn"),l=document.createElement("span");e.Browser.isDevice?l.innerHTML=this.l10n.getConstant("ABC"):l.innerHTML=this.l10n.getConstant("Default"),l.className="e-text-font-style",h.appendChild(l);var c=new a.DropDownButton({items:this.getFontSizeItems(),cssClass:"e-font-style",createPopupOnClick:!0,beforeItemRender:function(t){e.Browser.isDevice&&("bold"===t.element.id?t.element.setAttribute("style","font-weight: bold"):"italic"===t.element.id?t.element.setAttribute("style","font-style: italic"):"bolditalic"===t.element.id&&t.element.setAttribute("style","font-style: italic;font-weight: bold"))},open:function(t){var s="default";"block"===i.textBox.style.display?("bold"===i.textBox.style.fontWeight&&(s="bold"),"italic"===i.textBox.style.fontStyle&&(s=s.replace("default",""),s+="italic")):(i.activeObj.textSettings.bold&&(s="bold"),i.activeObj.textSettings.italic&&(s=s.replace("default",""),s+="italic")),e.Browser.isDevice&&(t.element.parentElement.style.top=c.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px"),t.element.querySelector('[id *= "'+s+'"]').classList.add("e-selected-btn")},select:function(t){e.Browser.isDevice?("bold"===t.item.id?l.setAttribute("style","font-weight: bold"):"italic"===t.item.id?l.setAttribute("style","font-style: italic"):"bolditalic"===t.item.id&&l.setAttribute("style","font-style: italic;font-weight: bold"),i.applyFontStyle(t.item.id,s)):(l.textContent=t.item.text,i.applyFontStyle(t.item.id,s))}});c.appendTo("#"+this.element.id+"_fontStyleBtn")}if(t.indexOf("fontSize")>-1){var v=document.getElementById(this.element.id+"_fontSizeBtn"),d=document.createElement("span"),p=this.getFontSizes();d.innerHTML=p[0].text,d.className="e-text-font-size",v.appendChild(d);var b=new a.DropDownButton({cssClass:"e-font-size",items:p,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=b.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=d.innerHTML;t.element.querySelector('[aria-label *= "'+i+'"]').classList.add("e-selected-btn")},select:function(t){if(d.textContent=t.item.text,"block"===i.textBox.style.display){var e=i.activeObj.textSettings.fontSize;i.activeObj.textSettings.fontSize=parseInt(i.fontSizeColl[parseInt(t.item.text,10)-1].text,10);var a="";"bold"===i.textBox.style.fontWeight&&(a="bold "),"italic"===i.textBox.style.fontStyle&&(a="italic "),"bold"===i.textBox.style.fontWeight&&"italic"===i.textBox.style.fontStyle&&(a="italic bold "),i.upperContext.font=a+i.activeObj.textSettings.fontSize+"px "+i.textBox.style.fontFamily;var o=i.textBox.value.split("\n"),r=i.getMaxText(!0),n=i.upperContext.measureText(r).width+.5*i.activeObj.textSettings.fontSize;i.textBox.style.width=n+"px",i.textBox.style.height=o.length*(i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize)+"px",i.activeObj.textSettings.fontSize=e,i.upperContext.font=i.activeObj.textSettings.fontSize+"px "+i.activeObj.textSettings.fontFamily,i.textBox.style.fontSize=parseInt(i.fontSizeColl[parseInt(t.item.text,10)-1].text,10)+"px","georgia"===i.textBox.style.fontFamily&&(i.textBox.style.width=parseFloat(i.textBox.style.width)+parseFloat(i.textBox.style.fontSize)+"px")}else{i.textSettings.fontSize=i.activeObj.textSettings.fontSize=parseInt(i.fontSizeColl[parseInt(t.item.text,10)-1].text,10),i.upperContext.font=i.activeObj.textSettings.fontSize+"px "+i.activeObj.textSettings.fontFamily;var o=i.activeObj.keyHistory.split("\n"),r=i.getMaxText(),n=i.upperContext.measureText(r).width+.5*i.activeObj.textSettings.fontSize,h=o.length*(i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize);i.setTextSelection(n,h),i.updateActiveObject(s,i.activeObj.activePoint,i.activeObj),i.redrawShape(i.activeObj),i.redrawText(s)}}});b.appendTo("#"+this.element.id+"_fontSizeBtn")}},h.prototype.getFontSizes=function(){var t=[];this.fontSizeColl=[];var e;e=0===this.degree||this.degree%180==0?this.lowerCanvas.width/20:this.lowerCanvas.height/20;for(var i=1;i<=10;i++)this.fontSizeColl.push({text:(i*Math.round(e/2)).toString()}),t.push({text:i.toString()});return t},h.prototype.getTextAreaWidth=function(t){var e=this.activeObj.textSettings.bold,i=this.activeObj.textSettings.italic;switch(t){case"default":this.activeObj.textSettings.bold=!1,this.activeObj.textSettings.italic=!1;break;case"bold":this.activeObj.textSettings.bold=!0,this.activeObj.textSettings.italic=!1;break;case"italic":this.activeObj.textSettings.bold=!1,this.activeObj.textSettings.italic=!0;break;case"bolditalic":this.activeObj.textSettings.bold=!0,this.activeObj.textSettings.italic=!0}this.updateFontStyles();var s=this.upperContext.measureText(this.activeObj.keyHistory).width+.5*this.activeObj.textSettings.fontSize;return this.activeObj.textSettings.bold=e,this.activeObj.textSettings.italic=i,s},h.prototype.applyFontStyle=function(t,i){switch(t){case"default":if("block"===this.textBox.style.display){s=this.getTextAreaWidth(t);this.textBox.style.width=e.Browser.isDevice?s+"px":s*((i.width+i.height)/2)+"px",this.textBox.style.fontWeight="normal",this.textBox.style.fontStyle="normal"}else this.textSettings.bold=this.activeObj.textSettings.bold=!1,this.textSettings.italic=this.activeObj.textSettings.italic=!1,this.redrawText(i);break;case"bold":if("block"===this.textBox.style.display){s=this.getTextAreaWidth(t);this.textBox.style.width=e.Browser.isDevice?s+"px":s*((i.width+i.height)/2)+"px",this.textBox.style.fontWeight="bold",this.textBox.style.fontStyle="normal"}else this.textSettings.bold=this.activeObj.textSettings.bold=!0,this.textSettings.italic=this.activeObj.textSettings.italic=!1,this.redrawText(i);break;case"italic":if("block"===this.textBox.style.display){s=this.getTextAreaWidth(t);this.textBox.style.width=e.Browser.isDevice?s+"px":s*((i.width+i.height)/2)+"px",this.textBox.style.fontWeight="normal",this.textBox.style.fontStyle="italic"}else this.textSettings.bold=this.activeObj.textSettings.bold=!1,this.textSettings.italic=this.activeObj.textSettings.italic=!0,this.redrawText(i);break;case"bolditalic":if("block"===this.textBox.style.display){var s=this.getTextAreaWidth(t);this.textBox.style.width=s/i.width+"px",this.textBox.style.fontWeight="bold",this.textBox.style.fontStyle="italic"}else this.textSettings.bold=this.activeObj.textSettings.bold=!0,this.textSettings.italic=this.activeObj.textSettings.italic=!0,this.redrawText(i)}},h.prototype.initZoomToolbarItem=function(){var t=this,i=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),o=this.getZoomToolbarItem();this.defToolbarItems=i.concat(o,a),new s.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){t.renderSaveBtn(),t.trigger("toolbarCreated",{toolbarType:"zoom"})}},"#"+this.element.id+"_toolbar"),this.createLeftToolbarControls(),this.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))&&e.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow()},h.prototype.defToolbarClicked=function(t){var i,s,a,o=this.calcRatio(),r=t.item.id.replace(this.element.id+"_","").toLowerCase(),n=e.getInstance(document.getElementById(this.element.id),l),h=!1;if(void 0!==this.activeObj.shape&&(a=this.activeObj.shape.split("-")),void 0===a&&this.currObjType.isCustomCrop?h=!0:void 0!==a&&"crop"===a[0]&&(h=!0),!this.disabled)switch(r){case"zoomin":this.togglePen&&(this.currObjType.isZoomed=!0,this.freeHandDraw(!1)),n.zoom(.1),this.togglePan||this.callMainToolbar(!1,!0),this.factor>.95&&this.factor<1.05&&(this.dragCanvas=this.togglePan=!1,this.callMainToolbar(!1,!0)),e.isNullOrUndefined(this.activeObj.activePoint)||0===this.activeObj.activePoint.width?this.refreshToolbar("main"):this.refreshToolbar("main",!0,!0),s=this.element.querySelector(".e-img-pan .e-btn"),!e.isNullOrUndefined(s)&&this.togglePan?s.classList.add("e-selected-btn"):e.isNullOrUndefined(s)||s.classList.remove("e-selected-btn");break;case"zoomout":this.togglePen&&(this.currObjType.isZoomed=!0,this.freeHandDraw(!1)),n.zoom(-.1),this.togglePan||this.callMainToolbar(!1,!0),this.factor>.95&&this.factor<1.05&&(this.dragCanvas=this.togglePan=!1,this.callMainToolbar(!1,!0)),e.isNullOrUndefined(this.activeObj.activePoint)||0===this.activeObj.activePoint.width?this.refreshToolbar("main"):this.refreshToolbar("main",!0,!0),s=this.element.querySelector(".e-img-pan .e-btn"),!e.isNullOrUndefined(s)&&this.togglePan?s.classList.add("e-selected-btn"):e.isNullOrUndefined(s)||s.classList.remove("e-selected-btn");break;case"pan":this.currObjType.isCustomCrop=!1,h&&(this.currObjType.isCustomCrop=!1,this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.refreshToolbar("main")),this.togglePan?this.cancelPan():((s=this.element.querySelector(".e-img-pan .e-btn")).classList.add("e-selected-btn"),n.pan(!0)),i=document.querySelector("#"+this.element.id+"_zoomIn"),!e.isNullOrUndefined(i)&&this.factor>=8?i.classList.add("e-disabled"):e.isNullOrUndefined(i)||i.classList.remove("e-disabled");break;case"cancel":"block"===this.textBox.style.display&&(this.textBox.style.display="none",this.textBox.value="",this.textBox.style.transform="",this.activeObj.strokeSettings=this.tempStrokeSettings,this.activeObj.textSettings=this.tempTextSettings),this.cancelItems();break;case"ok":h?this.crop():this.togglePen?this.freeHandDraw(!1):"block"===this.textBox.style.display?this.redrawActObj():this.applyActObj(),this.callMainToolbar(!1);break;case"text":this.currObjType.isCustomCrop=!1,n.drawShapeText(),this.refreshToolbar(r);break;case"pen":this.currObjType.isCustomCrop=!1,this.freeHandDraw(!0),this.refreshToolbar(r);break;case"reset":n.reset();break;case"load":case"save":case"select":break;case"bold":this.currObjType.isCustomCrop=!1,this.isBoldbtn?(this.activeObj.textSettings.bold=!1,this.isBoldbtn=!1,this.redrawText(o)):(this.activeObj.textSettings.bold=!0,this.isBoldbtn=!0,this.redrawText(o));break;case"italic":if(this.currObjType.isCustomCrop=!1,this.isItalicbtn){this.activeObj.textSettings.italic=!1,this.activeObj.textSettings.bold?this.upperContext.font="bold "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily:this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;var c=this.upperContext.measureText(this.activeObj.keyHistory).width+.5*this.activeObj.textSettings.fontSize,v=this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize;this.setTextSelection(c,v),this.updateActiveObject(o,this.activeObj.activePoint,this.activeObj),this.redrawShape(this.activeObj),this.isItalicbtn=!1}else{this.activeObj.textSettings.italic=!0,this.activeObj.textSettings.bold?this.upperContext.font="italic bold "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily:this.upperContext.font="italic "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;var c=this.upperContext.measureText(this.activeObj.keyHistory).width+.5*this.activeObj.textSettings.fontSize,v=this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize;this.setTextSelection(c,v),this.updateActiveObject(o,this.activeObj.activePoint,this.activeObj),this.redrawShape(this.activeObj),this.isItalicbtn=!0}}this.trigger("toolbarItemClicked",t)},h.prototype.cancelPan=function(){this.applyActObj(),this.element.querySelector(".e-img-pan .e-btn").classList.remove("e-selected-btn"),this.pan(!1)},h.prototype.callMainToolbar=function(t,e){this.factor,this.refreshToolbar("main",t,!1,e)},h.prototype.cancelItems=function(){var t,e=this.calcRatio(),i=!1;void 0!==this.activeObj.shape&&(t=this.activeObj.shape.split("-")),void 0===t&&this.currObjType.isCustomCrop?i=!0:void 0!==t&&"crop"===t[0]&&(i=!0),this.togglePen?(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.togglePen=!1,this.upperCanvas.style.cursor="default",this.penDrawColl=[],this.imageEditorPointsColl=[]):"text"===this.activeObj.shape?(this.activeObj.strokeSettings=this.tempStrokeSettings,this.activeObj.textSettings=this.tempTextSettings,"Enter Text"===this.activeObj.keyHistory&&this.activeObj.activePoint.startX===this.textStartPoints.x&&this.activeObj.activePoint.startY===this.textStartPoints.y?(this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.drawShapeText()):(this.redrawText(e),this.redrawShape(this.activeObj),i||void 0===this.activeObj.topLeftCircle||this.applyActObj(),this.clearSelection()),this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,bold:!1,italic:!1,underline:!1}):"rectangle"===this.activeObj.shape||"ellipse"===this.activeObj.shape||"line"===this.activeObj.shape?(this.activeObj.strokeSettings=this.tempStrokeSettings,this.redrawShape(this.activeObj),this.applyActObj()):(this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height)),this.upperCanvas.style.cursor="default",this.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.callMainToolbar()},h.prototype.gradient=function(t,e){return(e.y-t.y)/(e.x-t.x)},h.prototype.applyPenDraw=function(){if(this.togglePen&&1===this.factor&&!this.currObjType.isZoomed)this.apply(),this.penDrawColl=[],this.imageEditorPointsColl=[];else{var t=this.lowerCanvas.appendChild(this.createElement("canvas",{id:this.element.id+"_tempCanvas",attrs:{name:"canvasImage"}})),e=t.getContext("2d");t.width=this.lowerCanvas.width,t.height=this.lowerCanvas.height,e.drawImage(this.inMemoryCanvas,0,0),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);for(var i=0;i<this.penDrawColl.length;i++){e.lineWidth=2*this.penDrawColl[i].strokeWidth,e.strokeStyle=this.penDrawColl[i].strokeColor;var s=void 0,a=void 0;e.beginPath(),e.moveTo(this.penDrawColl[i].points[0].x,this.penDrawColl[i].points[0].y);var o=0,r=0,n=0,h=0,l=0;a=this.penDrawColl[i].points[0];for(b=1;b<this.penDrawColl[i].points.length;b++){var c=this.penDrawColl[i].points[b];(s=this.penDrawColl[i].points[b+1])?(o=this.gradient(a,s),l=(n=-.3*(s.x-c.x))*o*1):(n=0,l=0),e.bezierCurveTo(a.x-r,a.y-h,c.x+n,c.y+l,c.x,c.y),r=n,h=l,a=c,this.penDrawColl[i].points.length>2&&this.penDrawColl[i].points.shift(),e.stroke()}}this.penDrawColl=[],this.imageEditorPointsColl=[],this.togglePen=!1;for(var v=e.getImageData(0,0,t.width,t.height),d=void 0,p=0;p<this.imgDataColl.length;p++)if("freehanddraw"!==this.imgDataColl[p].operation){d=this.imgDataColl[p];break}this.imgDataColl.splice(0,1,{operation:"freehanddraw",value:v}),this.imgDataColl.splice(1,1,d),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.inMemoryCanvas.width=v.width,this.inMemoryCanvas.height=v.height,this.inMemoryContext.putImageData(v,0,0),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var b=0;b<this.objColl.length;b++)this.apply(this.objColl[b].shape,this.objColl[b]),this.refreshActiveObj();this.currObjType.isZoomed=!1}},h.prototype.refreshToolbar=function(t,i,s,a){var o={toolbarType:t};switch(document.getElementById(this.element.id+"_toolbar")&&this.defToolbarItems.length>0&&e.getComponent(document.getElementById(this.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(this.element.id+"_bottomToolbar")&&this.defToolbarItems.length>0&&document.getElementById(this.element.id+"_bottomToolbar").className.indexOf("e-control")>-1&&e.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),t){case"main":e.Browser.isDevice?s?this.initToolbarItem(!1,!0,!0):this.initToolbarItem(!1,!0):e.Browser.isDevice&&!a||this.initToolbarItem(i,e.Browser.isDevice),e.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":e.Browser.isDevice&&this.initToolbarItem(!1,!0,!0),"line"===this.activeObj.shape?o.toolbarItems=["strokeColor","strokeWidth"]:o.toolbarItems=["fillColor","strokeColor","strokeWidth"],this.trigger("toolbarUpdating",o),this.initShapesToolbarItem(o.toolbarItems);break;case"text":e.Browser.isDevice&&this.initToolbarItem(!1,!0,!0),o.toolbarItems=["fontFamily","fontStyle","fontSize","fontColor"],this.trigger("toolbarUpdating",o),this.initTextToolbarItem(o.toolbarItems);break;case"pen":e.Browser.isDevice&&this.initToolbarItem(!1,!0,!0),o.toolbarItems=["strokeColor","strokeWidth"],this.trigger("toolbarUpdating",o),this.initPenToolbarItem(o.toolbarItems);break;case"pan":this.initZoomToolbarItem()}},h.prototype.getPenToolbarItem=function(t){var i=[];t.indexOf("strokeColor")>-1&&i.push({prefixIcon:"e-icons e-copy",id:this.element.id+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+this.element.id+'_penColorBtn"></button>'}),t.indexOf("strokeWidth")>-1&&i.push({prefixIcon:"e-icons e-copy",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+this.element.id+'_penStrokeWidth"></button>'});for(var s=this.processSubToolbar(t),a=0,o=s.length;a<o;a++)i.push(s[a]);return e.Browser.isDevice||(i.push({id:this.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:this.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},h.prototype.initPenToolbarItem=function(t){var i=this,a=this.getLeftToolbarItem(),o=this.getRightToolbarItem(),r=this.getPenToolbarItem(t),n=this.getZoomToolbarItem();e.Browser.isDevice?this.defToolbarItems=r:this.defToolbarItems=a.concat(n,r,o);var h=new s.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.createPenColor(t),i.createPenBtn(t),e.Browser.isDevice||i.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"pen"}),e.Browser.isDevice?i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))&&h.refreshOverflow():(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))&&h.refreshOverflow())}});e.Browser.isDevice?h.appendTo("#"+this.element.id+"_bottomToolbar"):h.appendTo("#"+this.element.id+"_toolbar")},h.prototype.createPenColor=function(t){var s=this,o=this;if(t.indexOf("strokeColor")>-1){this.element.querySelector(".e-template.e-pen-stroke-color").appendChild(this.createElement("input",{id:this.element.id+"_pen_stroke"}));var r=new i.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(t){o.activeObj.strokeSettings.strokeColor=t.currentValue.hex,o.togglePen||o.redrawShape(s.activeObj),n.element.children[0].style.backgroundColor=t.currentValue.rgba,n.toggle()}},"#"+this.element.id+"_pen_stroke"),n=new a.DropDownButton({open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=n.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px",t.element.parentElement.style.left=s.element.offsetLeft+"px")},target:".e-pen-color",iconCss:"e-dropdownbtn-preview"},"#"+this.element.id+"_penColorBtn");r.inline=!0,this.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},h.prototype.createPenBtn=function(t){var i=this,s=this.calcRatio(),o=[{id:"1",text:this.l10n.getConstant("XSmall")},{id:"2",text:this.l10n.getConstant("Small")},{id:"3",text:this.l10n.getConstant("Medium")},{id:"4",text:this.l10n.getConstant("Large")},{id:"5",text:this.l10n.getConstant("XLarge")}];if(t.indexOf("strokeWidth")>-1){var r=document.getElementById(this.element.id+"_penStrokeWidth"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("Small"),n.className="e-pen-stroke-width",r.appendChild(n);var h=new a.DropDownButton({items:o,open:function(t){e.Browser.isDevice&&(t.element.parentElement.style.top=h.element.getBoundingClientRect().top-t.element.parentElement.offsetHeight+"px");var i=n.innerHTML;t.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){n.textContent=t.item.text,i.setPenStroke(t.item.id,s),e.Browser.isDevice?e.isNullOrUndefined(document.getElementById(i.element.id+"_bottomToolbar"))||e.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow():e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))||e.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}});h.appendTo("#"+this.element.id+"_penStrokeWidth")}},h.prototype.setPenStroke=function(t,e){switch(parseInt(t,10)){case 1:this.penStrokeWidth=.4*(e.width+e.height);break;case 2:this.penStrokeWidth=.8*(e.width+e.height);break;case 3:this.penStrokeWidth=1.2*(e.width+e.height);break;case 4:this.penStrokeWidth=1.6*(e.width+e.height);break;case 5:this.penStrokeWidth=2*(e.width+e.height)}},h.prototype.updateCanvas=function(){this.zoomedImg.width=this.baseImg.width,this.zoomedImg.height=this.baseImg.height,this.lastX=this.baseImg.width/2,this.lastY=this.baseImg.height/2;var t,e=document.querySelector("#"+this.element.id+"_canvasWrapper");t=this.isScreenOriented?parseFloat(e.style.width):this.element.clientWidth;var i=this.calcMaxDimension(this.baseImg.width,this.baseImg.height);this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerCanvas.width=this.upperCanvas.width=this.inMemoryCanvas.width=this.baseImg.width,this.lowerCanvas.height=this.upperCanvas.height=this.inMemoryCanvas.height=this.baseImg.height,this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=i.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=i.height+"px",this.lowerCanvas.style.left=this.upperCanvas.style.left=(t-i.width)/2+1+"px",e&&(this.lowerCanvas.style.top=this.upperCanvas.style.top=(parseFloat(e.style.height)-i.height-1)/2+"px"),this.lowerContext.drawImage(this.baseImg,0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.updateInMemoryCanvas("updateCanvas");for(var s=0,a=this.objColl.length;s<a;s++)this.apply(this.objColl[s].shape,this.objColl[s]);this.isUndoRedo&&""!==this.flipState&&this.flip(this.flipState),this.disabled&&this.element.setAttribute("class","e-disabled"),this.trigger("fileOpened")},h.prototype.imageOnLoad=function(t){var i=this,s=this;s.baseImg.src=s.baseImgSrc=t,this.baseImg.onload=function(){if(i.lowerContext.drawImage(i.baseImg,0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.togglePen){i.lowerCanvas.toBlob(function(t){o.showSpinner(s.element),s.baseImg.src=URL.createObjectURL(t),s.togglePen=!1},"image/png"),i.inMemoryContext.clearRect(0,0,i.inMemoryCanvas.width,i.inMemoryCanvas.height);var t=i.lowerContext.getImageData(0,0,i.lowerCanvas.width,i.lowerCanvas.height);i.inMemoryContext.putImageData(t,0,0);var a=i.imgDataColl[0];i.imgDataColl.splice(0,1,{operation:"freehanddraw",value:t}),i.imgDataColl.splice(1,1,a)}else o.hideSpinner(i.element),i.element.style.opacity="1",i.updateCanvas(),i.isUndoRedo=!1;e.Browser.isDevice?(!i.isToolbar()||e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))||e.isNullOrUndefined(e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar"))||e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),e.isNullOrUndefined(document.getElementById(i.element.id+"_bottomToolbar"))||e.isNullOrUndefined(e.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar"))||e.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar").destroy(),i.initToolbarItem(!1,e.Browser.isDevice),i.createBottomToolbar()):(!i.isToolbar()||e.isNullOrUndefined(document.getElementById(i.element.id+"_toolbar"))||e.isNullOrUndefined(e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar"))||e.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),i.initToolbarItem(!1,!1))}},h.prototype.refreshActiveObj=function(){this.activeObj={},this.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},this.activeObj.flipObjColl=[],this.activeObj.strokeSettings=this.strokeSettings,this.activeObj.textSettings=this.textSettings},h.prototype.redrawText=function(t){this.activeObj.textSettings.bold&&(this.upperContext.font="bold "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily),this.activeObj.textSettings.italic&&(this.upperContext.font="bold "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily),this.activeObj.textSettings.bold&&this.activeObj.textSettings.italic&&(this.upperContext.font="italic bold "+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily),this.activeObj.textSettings.bold||this.activeObj.textSettings.italic||(this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily);var e=this.activeObj.keyHistory.split("\n"),i="block"===this.textBox.style.display?this.getMaxText(!0):this.getMaxText(),s=this.upperContext.measureText(i).width+.5*this.activeObj.textSettings.fontSize,a=e.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize);this.setTextSelection(s,a),this.updateActiveObject(t,this.activeObj.activePoint,this.activeObj),this.redrawShape(this.activeObj)},h.prototype.setTextSelection=function(t,e){var i=this.degree;(i=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree)<0&&(i=360+i);for(var s=0;s<this.activeObj.flipObjColl.length;s++)0===i?"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?this.activeObj.activePoint={startX:this.activeObj.activePoint.endX-t,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.startY+(e||0)}:"vertical"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.startY=this.activeObj.activePoint.endY-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+(t||0),endY:this.activeObj.activePoint.endY}):this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+(t||0),endY:this.activeObj.activePoint.startY+(e||0)}:90===i?"vertical"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.startX=this.activeObj.activePoint.endX-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.endY-t,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY}):"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.startY+(t||0)}):(this.activeObj.activePoint.startX=this.activeObj.activePoint.endX-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.startY+(t||0)}):180===i?"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.startY=this.activeObj.activePoint.endY-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+t,endY:this.activeObj.activePoint.endY}):"vertical"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+e,this.activeObj.activePoint={endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY,startX:this.activeObj.activePoint.endX-(t||0),startY:this.activeObj.activePoint.startY}):this.activeObj.activePoint={endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY,startX:this.activeObj.activePoint.endX-(t||0),startY:this.activeObj.activePoint.endY-(e||0)}:270===i&&("vertical"===this.activeObj.flipObjColl[s].toLowerCase()?this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+e,endY:this.activeObj.activePoint.startY+(t||0)}:"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?(this.activeObj.activePoint.startX=this.activeObj.activePoint.endX-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.endY-(t||0),endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY}):(this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.endY-(t||0),endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY}));0===this.activeObj.flipObjColl.length&&(0===i?this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+(t||0),endY:this.activeObj.activePoint.startY+(e||0)}:90===i?(this.activeObj.activePoint.startX=this.activeObj.activePoint.endX-e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.startY+(t||0)}):180===i?this.activeObj.activePoint={endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY,startX:this.activeObj.activePoint.endX-(t||0),startY:this.activeObj.activePoint.endY-(e||0)}:270===i&&(this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+e,this.activeObj.activePoint={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.endY-(t||0),endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY})),this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,360!==this.degree&&-360!==this.degree||(this.degree=0)},h.prototype.updateUndoRedoColl=function(t,e,i,s){this.undoRedoColl.push({operation:t,value:e,previousObj:i,currentObj:s})},h.prototype.fileSelect=function(t,e){o.showSpinner(this.element),this.element.style.opacity="0.5";var i=e.target.files[0];this.imgDataColl.length>0&&(this.imgDataColl=[],this.reset());var s=window.URL.createObjectURL(i);this.imageOnLoad(s.toString()),t.value=""},h.prototype.findTextPoint=function(t){if("text"===this.activeObj.shape){this.textBox.style.transformOrigin="0 0";var e=void 0,i="";if((e=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree)<0&&(e=360+e),this.activeObj.flipObjColl.length>0)for(var s=0;s<this.activeObj.flipObjColl.length;s++)i+=0!==e&&e%90==0&&180!==e?"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?"scale(-1, 1)":"scale(1, -1)","horizontal"===this.activeObj.flipObjColl[s].toLowerCase()?this.textBox.style.transform="rotate("+e+"deg)"+i:"vertical"===this.activeObj.flipObjColl[s].toLowerCase()&&(this.textBox.style.transform="rotate("+e+"deg)"+i);else this.textBox.style.transform="rotate("+e+"deg)";this.findTextTarget(t)}},h.prototype.getStrokeWidth=function(t){var e;switch(t){case"1":e=this.l10n.getConstant("XSmall");break;case"2":e=this.l10n.getConstant("Small");break;case"3":e=this.l10n.getConstant("Medium");break;case"4":e=this.l10n.getConstant("Large");break;case"5":e=this.l10n.getConstant("XLarge")}return e},h.prototype.updateToolbarItems=function(t){var i=this.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),s=this.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),a=this.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),o=this.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),r=this.element.querySelector(".e-shape-stroke-width"),n=this.element.querySelector(".e-text-font-family"),h=this.element.querySelector(".e-text-font-size"),l=this.element.querySelector(".e-text-font-style");if(i&&(""===this.activeObj.strokeSettings.fillColor?i.classList.add("e-nocolor-item"):(i.classList.remove("e-nocolor-item"),i.style.background=this.activeObj.strokeSettings.fillColor),e.getComponent(this.element.id+"_shape_fill","colorpicker").value=this.activeObj.strokeSettings.fillColor+"ff"),s&&(s.style.background=this.activeObj.strokeSettings.strokeColor,e.getComponent(this.element.id+"_shape_stroke","colorpicker").value=this.activeObj.strokeSettings.strokeColor+"ff"),a&&(a.style.background=this.activeObj.strokeSettings.strokeColor,e.getComponent(this.element.id+"_text_font","colorpicker").value=this.activeObj.strokeSettings.strokeColor+"ff"),o&&(o.style.background=this.activeObj.strokeSettings.strokeColor,e.getComponent(this.element.id+"_pen_stroke","colorpicker").value=this.activeObj.strokeSettings.strokeColor+"ff"),n&&(e.Browser.isDevice?n.setAttribute("style","font-family:"+this.activeObj.textSettings.fontFamily.toLowerCase()):n.textContent=this.activeObj.textSettings.fontFamily),h)for(var c=0;c<this.fontSizeColl.length;c++)if(parseInt(this.fontSizeColl[c].text,10)>=this.activeObj.textSettings.fontSize){h.textContent=(c+1).toString();break}if(l&&(e.Browser.isDevice?this.activeObj.textSettings.bold||this.activeObj.textSettings.italic?this.activeObj.textSettings.bold&&this.activeObj.textSettings.italic?l.setAttribute("style","font-style: italic;font-weight: bold"):this.activeObj.textSettings.bold?l.setAttribute("style","font-weight: bold"):l.setAttribute("style","font-style: italic"):l.setAttribute("style",""):this.activeObj.textSettings.bold||this.activeObj.textSettings.italic?this.activeObj.textSettings.bold&&this.activeObj.textSettings.italic?l.textContent="Bold Italic":this.activeObj.textSettings.bold?l.textContent="Bold":l.textContent="Italic":l.textContent="Default"),r){var v=Math.round(this.activeObj.strokeSettings.strokeWidth/(t.width+t.height)).toString();r.textContent=this.getStrokeWidth(v)}},h.prototype.setTimer=function(t){!this.isTimer&&this.timer>10&&(this.findTextPoint(t),e.Browser.isDevice&&this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height))},h.prototype.touchStartHandler=function(t){t.preventDefault(),this.timer=setTimeout(this.setTimer.bind(this),1e3,t),this.mouseDownEventHandler(t),e.EventHandler.add(this.lowerCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),e.EventHandler.add(this.upperCanvas,"touchend",this.mouseUpEventHandler,this),e.EventHandler.add(this.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},h.prototype.mouseDownEventHandler=function(t){var i=this.calcRatio();if(this.dragCanvas)this.canvasMouseDownHandler(t);else{t.preventDefault();var s=void 0,a=void 0;if("mousedown"===t.type?(s=t.clientX,a=t.clientY):(this.touchEndPoint.x=s=t.touches[0].clientX,this.touchEndPoint.y=a=t.touches[0].clientY),this.redrawActObj(s,a),("crosshair"===this.upperCanvas.style.cursor||e.Browser.isDevice&&this.togglePen)&&(this.togglePen?(this.canvasRatio=this.calcRatio(),e.isNullOrUndefined(this.activeObj.strokeSettings)&&(this.activeObj.strokeSettings=this.strokeSettings),e.isNullOrUndefined(this.penStrokeWidth)&&(this.penStrokeWidth=.8*(i.width+i.height)),this.activeObj.strokeSettings.strokeWidth===.4*(i.width+i.height)&&this.strokeSettings.strokeWidth===.4*(i.width+i.height)&&(this.activeObj.strokeSettings.strokeWidth=this.strokeSettings.strokeWidth=(i.width+i.height)/this.factor*2),this.minStrokeWidth=this.maxStrokeWidth=this.penStrokeWidth,this.velocity=.7,this.upperContext.strokeStyle=this.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=this.activeObj.strokeSettings.strokeColor,this.mouseDownHandler(t,this.upperCanvas,this.pannStart,this.factor)):(this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height)),this.currObjType.isActiveObj=!1,this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0),"crosshair"!==this.upperCanvas.style.cursor&&"touchstart"===t.type.toLowerCase()||this.currObjType.isActiveObj&&"default"!==this.upperCanvas.style.cursor&&!this.togglePen?this.findTarget(s,a,t.type):""!==this.currObjType.shape&&!this.currObjType.isCustomCrop||this.togglePen||"default"===this.upperCanvas.style.cursor||this.setActivePoint(s,a),!e.isNullOrUndefined(this.activeObj)){var o=!1,r=void 0;void 0!==this.activeObj.shape&&(r=this.activeObj.shape.split("-")),void 0===r&&(this.currObjType.isCustomCrop||this.togglePen)?o=!0:void 0!==r&&"crop"===r[0]&&(o=!0),"rectangle"===this.activeObj.shape||"ellipse"===this.activeObj.shape||"line"===this.activeObj.shape?this.refreshToolbar("shapes"):"text"===this.activeObj.shape?this.refreshToolbar("text"):o||this.callMainToolbar(),this.updateToolbarItems(i)}}},h.prototype.mouseMoveEventHandler=function(t){t.preventDefault(),"none"===this.textBox.style.display&&(this.isTimer=!0);var e,i;if("mousemove"===t.type?(e=t.clientX,i=t.clientY):(this.touchEndPoint.x=e=t.touches[0].clientX,this.touchEndPoint.y=i=t.touches[0].clientY),this.canvasMouseMoveHandler(t),(this.currObjType.isActiveObj&&(void 0!==this.activeObj.activePoint||this.objColl.length>0)&&!this.dragCanvas||void 0!==this.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(e,i),this.findTarget(e,i,t.type)),this.currObjType.isDragging){this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height);var s=this.updateActivePoint(e,i);this.drawObject("duplicate",null,s)}},h.prototype.mouseUpEventHandler=function(t){t.preventDefault();var e,i;"mouseup"===t.type?(e=t.clientX,i=t.clientY):(e=this.touchEndPoint.x,i=this.touchEndPoint.y),"touchend"===t.type&&"none"===this.textBox.style.display&&(this.isTimer=!1,this.timer=0);var s=this.upperCanvas.getBoundingClientRect(),a=this.calcRatio();1===this.factor?(e=(e-s.left)*a.width,i=(i-s.top)*a.height):(e=e-s.left+this.pannStart.startX/a.width*this.factor,i=i-s.top+this.pannStart.startY/a.height*this.factor),t.currentTarget===this.upperCanvas&&(this.currObjType.shape=this.currObjType.shape.toLowerCase(),this.togglePen||this.dragCanvas||this.applyCurrActObj(e,i)),this.togglePen&&t.currentTarget===this.upperCanvas?(this.penDrawColl.push({strokeWidth:this.penStrokeWidth,strokeColor:this.activeObj.strokeSettings.strokeColor,points:this.imageEditorPointsColl}),this.imageEditorPointsColl=[]):this.currObjType.shape="",this.dragElement="",this.currObjType.isInitialLine=this.currObjType.isDragging=!1,this.oldPoint.x=void 0,this.oldPoint.y=void 0},h.prototype.keyDownEventHandler=function(t){var i=this,s={},a={fileName:"ImageEditor",fileType:"Png",cancel:!1};switch(t.key){case t.ctrlKey&&"s":this.trigger("beforeSave",a,function(t){a.cancel||i.export(t.fileType,t.fileName)}),t.preventDefault(),t.stopImmediatePropagation();break;case"Delete":s={action:"delete",previousShapeSettings:this.activeObj,currentShapeSettings:null},this.keyHistory="",this.clearSelection(),this.trigger("shapeChanging",s),this.refreshToolbar("main");break;case"Escape":this.togglePan?(this.refreshToolbar(this.currentToolbar),this.pan(!1)):this.cancelItems();break;case"Enter":this.crop();break;default:e.Browser.isDevice&&"block"===this.textBox.style.display&&setTimeout(this.textKeyDown.bind(this),1,t)}},h.prototype.keyUpEventHandler=function(t){setTimeout(this.textKeyDown.bind(this),1,t)},h.prototype.canvasMouseDownHandler=function(t){t.preventDefault();var e=this.calcRatio();"mousedown"===t.type?(this.lastX=t.offsetX||t.pageX-this.lowerCanvas.offsetLeft,this.lastY=t.offsetY||t.pageY-this.lowerCanvas.offsetTop):(this.lastX=t.touches[0].clientX||t.touches[0].pageX-this.lowerCanvas.offsetLeft,this.lastY=t.touches[0].clientY||t.touches[0].pageY-this.lowerCanvas.offsetTop),this.lastX*=e.width,this.lastY*=e.height,(this.dragCanvas||1!==this.factor)&&(this.dragStart=this.lowerContext.transformedPoint(this.lastX,this.lastY),this.dragged=!1)},h.prototype.canvasMouseMoveHandler=function(t){this.dragCanvas&&this.factor>1?this.lowerCanvas.style.cursor="grab":(this.dragCanvas=this.togglePan=!1,this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="default");var e=this.calcRatio();if("mousemove"===t.type?(this.lastX=t.offsetX||t.pageX-this.lowerCanvas.offsetLeft,this.lastY=t.offsetY||t.pageY-this.lowerCanvas.offsetTop):(this.lastX=t.touches[0].clientX||t.touches[0].pageX-this.lowerCanvas.offsetLeft,this.lastY=t.touches[0].clientY||t.touches[0].pageY-this.lowerCanvas.offsetTop),this.lastX*=e.width,this.lastY*=e.height,this.dragged=!0,this.dragStart&&this.dragCanvas){var i=this.lowerContext.transformedPoint(this.lastX,this.lastY),s={startPoint:{x:this.dragStart.x,y:this.dragStart.y},endPoint:{x:i.x,y:i.y}};this.trigger("panning",s);var a=i.x-this.dragStart.x,o=i.y-this.dragStart.y,r=a,n=o;this.lowerContext.translate(a,o),this.upperContext.translate(a,o);var h=this.lowerContext.transformedPoint(0,0),l=this.lowerContext.transformedPoint(this.lowerCanvas.width,this.lowerCanvas.height);a>=0?h.x<1&&(a=0):l.x>this.lowerCanvas.width&&(a=0),o>=0?h.y<1&&(o=0):l.y>this.lowerCanvas.height&&(o=0),this.lowerContext.translate(-r,-n),this.upperContext.translate(-r,-n),this.lowerContext.translate(a,o),this.upperContext.translate(a,o),this.redraw()}},h.prototype.canvasMouseUpHandler=function(t){t.preventDefault(),this.dragStart=null,this.currObjType.isDragging=!1},h.prototype.textKeyDown=function(t){"\r"===String.fromCharCode(t.which)&&(this.textRow+=1),this.textBox.setAttribute("rows",this.textRow.toString()),this.textBox.style.height="auto",this.textBox.style.height=this.textBox.scrollHeight+"px",this.setTextBoxWidth(t),e.Browser.isDevice&&(this.textBox.style.width=parseFloat(this.textBox.style.width)+this.textBox.style.fontSize+"px");var i=this.textBox.value.split("\n");this.textRow=i.length,this.textBox.setAttribute("rows",this.textRow.toString())},h.prototype.adjustToScreen=function(){var t=this;this.applyActObj(),this.refreshActiveObj(),this.imgDataColl.length>0&&(o.showSpinner(this.element),this.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.lowerCanvas.width=this.upperCanvas.width=this.element.offsetWidth,this.lowerCanvas.height=this.upperCanvas.height=this.element.offsetHeight,this.redrawImg(),this.lowerCanvas.toBlob(function(e){t.baseImg.src=URL.createObjectURL(e)},"image/png"),this.defToolbarItems.length>0&&!e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))&&e.getComponent(t.element.id+"_toolbar","toolbar").refreshOverflow()},h.prototype.screenOrientation=function(){e.Browser.isDevice&&(this.isScreenOriented=!0,this.adjustToScreen())},h.prototype.windowResizeHandler=function(){e.Browser.isDevice||this.adjustToScreen()},h.prototype.redrawImg=function(){var t,e=document.querySelector("#"+this.element.id+"_canvasWrapper");t=this.isScreenOriented?parseFloat(e.style.width):this.element.clientWidth;var i=this.calcMaxDimension(this.inMemoryCanvas.width,this.inMemoryCanvas.height);this.lowerCanvas.width=this.upperCanvas.width=this.inMemoryCanvas.width,this.lowerCanvas.height=this.upperCanvas.height=this.inMemoryCanvas.height,this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=i.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=i.height+"px",this.lowerCanvas.style.left=this.upperCanvas.style.left=(t-i.width)/2+1+"px",this.lowerCanvas.style.top=this.upperCanvas.style.top=(this.element.offsetHeight-this.toolbarHeight-i.height)/2+1+"px",this.lowerContext.drawImage(this.inMemoryCanvas,0,0,this.lowerCanvas.width,this.lowerCanvas.height)},h.prototype.updateContext=function(t){var e=this,i=this,s=new DOMMatrix;t.getTransform=function(){return s};var a=[],o=t.save;t.save=function(){return a.push(s.translate(0,0)),o.call(t)};var r=t.restore;t.restore=function(){return s=a.pop(),r.call(t)};var n=t.scale;t.scale=function(a,o){return s=e.scaleNonUniform(s,a,o),i.factor=s.a,n.call(t,a,o)};var h=t.rotate;t.rotate=function(e){return s=s.rotate(180*e/Math.PI),h.call(t,e)};var l=t.translate;t.translate=function(e,i){return s=s.translate(e,i),l.call(t,e,i)};var c=t.transform;t.transform=function(e,i,a,o,r,n){var h=new DOMMatrix;return h.a=e,h.b=i,h.c=a,h.d=o,h.e=r,h.f=n,s=s.multiply(h),c.call(t,e,i,a,o,r,n)};var v=t.setTransform;t.setTransform=function(e,i,a,o,r,n){return s.a=e,s.b=i,s.c=a,s.d=o,s.e=r,s.f=n,v.call(t,e,i,a,o,r,n)};var d=new DOMPoint;t.transformedPoint=function(t,e){return d.x=t,d.y=e,d.matrixTransform(s.inverse())}},h.prototype.scaleNonUniform=function(t,e,i){return t.m11*=e,t.m12*=e,t.m13*=e,t.m14*=e,t.m21*=i,t.m22*=i,t.m23*=i,t.m24*=i,t},h.prototype.zoomImg=function(t){var i=this.lowerContext.transformedPoint(this.lastX,this.lastY),s={zoomPoint:{x:i.x,y:i.y},zoomLevel:t};this.trigger("zooming",s),this.lowerContext.translate(i.x,i.y),this.upperContext.translate(i.x,i.y);var a=Math.pow(1.1,t);this.factor+=a-1,this.lowerContext.scale(a,a),this.upperContext.scale(a,a),this.lowerContext.translate(-i.x,-i.y),this.upperContext.translate(-i.x,-i.y);var o=this.calcRatio();if(e.isNullOrUndefined(this.strokeSettings.strokeWidth)||(this.strokeSettings.strokeWidth=2*(o.width+o.height)/this.factor),this.factor>.99&&this.factor<1.01){this.factor=1,this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var r=0;r<this.objColl.length;r++)this.apply(this.objColl[r].shape,this.objColl[r]),this.refreshActiveObj()}else{if(this.factor>1){var n=this.lowerContext.transformedPoint(0,0),h=this.lowerContext.transformedPoint(this.lowerCanvas.width,this.lowerCanvas.height),l=i.x,c=i.y;n.x<1?l=-l:h.x>this.lowerCanvas.width&&(l=h.x-this.lowerCanvas.width),n.y<1?c=-c:h.y>this.lowerCanvas.height&&(c=h.y-this.lowerCanvas.height),l===i.x&&c===i.y||(l===i.x&&(l=0),c===i.y&&(c=0),this.lowerContext.translate(l,c),this.upperContext.translate(l,c))}this.redraw()}},h.prototype.handleScroll=function(t){var e=t.wheelDelta?t.wheelDelta/40:t.detail?-t.detail:0;return e&&this.zoom(e),t.preventDefault()&&!1},h.prototype.redraw=function(){var t=this.lowerContext.transformedPoint(0,0),e=this.lowerContext.transformedPoint(this.lowerCanvas.width,this.lowerCanvas.height);this.pannStart.startX=t.x,this.pannStart.startY=t.y,this.pannEnd.startX=this.lowerCanvas.width-e.x,this.pannEnd.startY=this.lowerCanvas.height-e.y,this.lowerContext.clearRect(t.x,t.y,e.x-t.x,e.y-t.y),this.upperContext.clearRect(t.x,t.y,e.x-t.x,e.y-t.y),this.lowerContext.save(),this.upperContext.save(),this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.restore(),this.upperContext.restore(),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var i=0;i<this.objColl.length;i++)this.apply(this.objColl[i].shape,this.objColl[i]),this.refreshActiveObj()},h.prototype.applyCurrActObj=function(t,i){var s=!1,a=this.calcRatio(),o=e.extend({},this.activeObj,{},!0);if(1!==this.factor&&(o=this.setCursorForZoomState(o,a,!0)),!e.isNullOrUndefined(o.activePoint)&&((t>=Math.floor(o.activePoint.startX)&&t<=Math.ceil(o.activePoint.endX)&&i>=Math.floor(o.activePoint.startY)&&i<=Math.ceil(o.activePoint.endY)||"text"===o.shape)&&(s=!0),!s&&(void 0===this.activeObj.horTopLine||0===this.activeObj.horTopLine.startX||0===this.activeObj.horTopLine.endX||this.currObjType.isCustomCrop||""===this.currObjType.shape||this.objColl.push(e.extend({},this.activeObj,{},!0)),"text"===this.activeObj.shape||"ellipse"===this.currObjType.shape||"rectangle"===this.currObjType.shape||"line"===this.currObjType.shape))){for(var r=0;r<this.objColl.length;r++)this.apply(this.objColl[r].shape,this.objColl[r]);this.apply("shape")}},h.prototype.updateTextFromTextArea=function(t){this.activeObj.keyHistory=this.textBox.value,this.textBox.style.display="none",this.textBox.value="",this.updateFontStyles();var e=this.upperContext.measureText(this.activeObj.keyHistory).width+.5*this.activeObj.textSettings.fontSize,i=this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize,s=this.activeObj.keyHistory.split("\n");if(s.length>1){i*=s.length;for(var a=[],o=0;o<s.length;o++)a.push(this.upperContext.measureText(s[o]).width+.5*this.activeObj.textSettings.fontSize);e=Math.max.apply(Math,a)}this.setTextSelection(e,i),this.updateActiveObject(t,this.activeObj.activePoint,this.activeObj)},h.prototype.redrawActObj=function(t,e){var i,s=this.calcRatio(),a=this.upperCanvas.getBoundingClientRect();void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),void 0!==this.activeObj.horTopLine&&void 0!==this.activeObj.shape&&"crop"!==i[0]&&("block"===this.textBox.style.display?(this.activeObj.textSettings.fontFamily=this.textBox.style.fontFamily,this.activeObj.strokeSettings.strokeColor=this.textBox.style.color,"bold"===this.textBox.style.fontWeight?this.activeObj.textSettings.bold=!0:this.activeObj.textSettings.bold=!1,"italic"===this.textBox.style.fontStyle?this.activeObj.textSettings.italic=!0:this.activeObj.textSettings.italic=!1,this.activeObj.textSettings.fontSize=parseFloat(this.textBox.style.fontSize)*((s.width+s.height)/2)/this.factor,t&&e?(t-=a.left,e-=a.top,t!==this.activeObj.activePoint.startX/s.width&&e!==this.activeObj.activePoint.startY/s.height&&(this.updateTextFromTextArea(s),this.applyActObj())):(this.updateTextFromTextArea(s),this.apply(this.activeObj.shape,this.activeObj),this.objColl.push(this.activeObj),this.refreshActiveObj(),this.textBox.style.transform="",this.refreshToolbar("main"))):this.applyActObj())},h.prototype.setTextBoxPos=function(t,e,i,s,a,o){var r={x:s,y:a};return 0===e?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left)-t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)-t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):90===e?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):180===e?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):"vertical"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):270===e&&("horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):"vertical"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left)-t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)-t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height)),r},h.prototype.setTextBoxPoints=function(t,e,i,s,a,o){var r={x:s,y:a};return 0===e?"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height)):"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left+t.activePoint.width/o.width),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width,r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top))):90===e?"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height/o.height):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)+t.activePoint.height)):"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top))):180===e?"horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top))):"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top))):270===e&&("horizontal"===t.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top))):"horizontal"===i.toLowerCase()?1===this.factor?(r.x=t.activePoint.startX/o.width+parseFloat(this.lowerCanvas.style.left)+t.activePoint.width/o.width,r.y=t.activePoint.startY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.startX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.startY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)):"vertical"===i.toLowerCase()&&(1===this.factor?(r.x=t.activePoint.endX/o.width+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY/o.height+parseFloat(this.lowerCanvas.style.top)):(r.x=t.activePoint.endX-this.pannStart.startX/o.width*this.factor+parseFloat(this.lowerCanvas.style.left),r.y=t.activePoint.endY-this.pannStart.startY/o.height*this.factor+parseFloat(this.lowerCanvas.style.top)))),r},h.prototype.findTextTarget=function(t){var i,s;"dblclick"===t.type?(i=t.clientX,s=t.clientY):"touchstart"===t.type&&(this.touchEndPoint.x=i=t.touches[0].clientX,this.touchEndPoint.y=s=t.touches[0].clientY);var a,o=this.upperCanvas.getBoundingClientRect(),r=this.calcRatio(),n="";(a=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree)<0&&(a=360+a),n=this.activeObj.shapeFlip===this.currFlipState?"":this.currFlipState;var h;if("block"===this.textBox.style.display)i-=o.left,s-=o.top;else{h=e.extend({},this.activeObj,{},!0);for(l=0;l<this.objColl.length;l++)JSON.stringify(this.activeObj)===JSON.stringify(this.objColl[l])&&this.objColl.splice(l,1);this.lowerContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var l=0;l<this.objColl.length;l++)this.apply(this.objColl[l].shape,this.objColl[l]);this.activeObj=h,this.updateFontStyles(),1===this.factor?(i=(i-o.left)*r.width,s=(s-o.top)*r.height):(i=i-o.left+this.pannStart.startX/r.width*this.factor,s=s-o.top+this.pannStart.startY/r.height*this.factor);var c=e.extend({},this.activeObj,{},!0);if(1!==this.factor&&(c=this.setCursorForZoomState(c,r,!0)),i>=c.activePoint.startX-c.topLeftCircle.radius&&i<=c.activePoint.endX+c.topLeftCircle.radius&&s>=c.activePoint.startY-c.topLeftCircle.radius&&s<=c.activePoint.endY+c.topLeftCircle.radius){if(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),4===c.flipObjColl.length&&(c.flipObjColl=[],n=""),""===n&&c.flipObjColl.length>1&&(n=c.flipObjColl[c.flipObjColl.length-1]),c.flipObjColl.length<=1)i=(v=this.setTextBoxPos(c,a,n,i,s,r)).x,s=v.y;else{var v=this.setTextBoxPoints(c,a,n,i,s,r);i=v.x,s=v.y}this.textBox.style.display="block",this.textBox.style.left=i+"px",this.textBox.style.top=s+"px",this.textBox.style.fontFamily=c.textSettings.fontFamily,this.textBox.style.fontSize=c.textSettings.fontSize/((r.width+r.height)/2)*this.factor+"px",this.textBox.style.color=c.strokeSettings.strokeColor,this.textBox.style.fontWeight=c.textSettings.bold?"bold":"normal",this.textBox.style.fontStyle=c.textSettings.italic?"italic":"normal",this.textBox.style.border="2px solid "+this.themeColl[this.theme].primaryColor,this.textBox.value=c.keyHistory,this.textBox.style.overflow="hidden",this.textBox.style.height="auto",this.setTextBoxWidth(),this.setTextBoxHeight(),a%90==0&&a%180!=0&&0!==a?1===this.factor?this.textBox.style.height=c.activePoint.width/r.width+"px":this.textBox.style.height=c.activePoint.width+"px":1===this.factor?this.textBox.style.height=c.activePoint.height/r.height+"px":this.textBox.style.height=c.activePoint.height+"px"}else this.applyActObj()}},h.prototype.setTextBoxHeight=function(){var t,i,s=this.calcRatio(),a="",o=e.extend({},this.activeObj,{},!0);1!==this.factor&&(o=this.setCursorForZoomState(o,s,!0)),(i=0===o.shapeDegree?this.degree:this.degree-o.shapeDegree)<0&&(i=360+i),a=o.shapeFlip===this.currFlipState?"":this.currFlipState,0===i?"vertical"===a.toLowerCase()?this.textBox.style.maxHeight=(this.lowerCanvas.height-(this.lowerCanvas.height-o.activePoint.endY))/s.height+"px":(t=parseFloat(this.textBox.style.top)-parseFloat(this.lowerCanvas.style.top),this.textBox.style.maxHeight=this.lowerCanvas.height/s.height-t+"px"):90===i?"horizontal"===a.toLowerCase()?this.textBox.style.maxHeight=(this.lowerCanvas.width-o.activePoint.startX)/s.width+"px":this.textBox.style.maxHeight=(this.lowerCanvas.width-(this.lowerCanvas.width-o.activePoint.endX))/s.width+"px":180===i?"vertical"===a.toLowerCase()?this.textBox.style.maxHeight=(this.lowerCanvas.height-o.activePoint.startY)/s.height+"px":this.textBox.style.maxHeight=(this.lowerCanvas.height-(this.lowerCanvas.height-o.activePoint.endY))/s.height+"px":270===i&&("horizontal"===a.toLowerCase()?this.textBox.style.maxHeight=(this.lowerCanvas.width-(this.lowerCanvas.width-o.activePoint.endX))/s.width+"px":this.textBox.style.maxHeight=(this.lowerCanvas.width-o.activePoint.startX)/s.width+"px"),this.textBox.style.maxHeight=(parseFloat(this.textBox.style.maxHeight)-.5*parseFloat(this.textBox.style.fontSize))*this.factor+"px"},h.prototype.setTextBoxWidth=function(t){var i=this.calcRatio(),s=this.getMaxText(!0),a=this.upperContext.measureText(s).width+parseFloat(this.textBox.style.fontSize)/2,o=t?this.upperContext.measureText(String.fromCharCode(t.which)).width:0,r=e.extend({},this.activeObj,{},!0);1!==this.factor&&(r=this.setCursorForZoomState(r,i,!0));var n,h="";(n=0===r.shapeDegree?this.degree:this.degree-r.shapeDegree)<0&&(n=360+n),h=r.shapeFlip===this.currFlipState?"":this.currFlipState,(!e.isNullOrUndefined(t)&&parseFloat(this.textBox.style.width)<a+o||e.isNullOrUndefined(t))&&(0===n?"horizontal"===h.toLowerCase()?r.activePoint.endX-a-o>0&&(this.textBox.style.width=(a+o)/i.width+"px"):a+o+r.activePoint.startX<this.lowerCanvas.width&&(this.textBox.style.width=(a+o)/i.width+"px"):90===n?"vertical"===h.toLowerCase()?r.activePoint.endY-a-o>0&&(this.textBox.style.width=(a+o)/i.height+"px"):a+o+r.activePoint.startY<this.lowerCanvas.height&&(this.textBox.style.width=(a+o)/i.height+"px"):180===n?"horizontal"===h.toLowerCase()?a+o+r.activePoint.startX<this.lowerCanvas.width&&(this.textBox.style.width=(a+o)/i.width+"px"):r.activePoint.endX-a-o>0&&(this.textBox.style.width=(a+o)/i.width+"px"):270===n&&("vertical"===h.toLowerCase()?a+o+r.activePoint.startY<this.lowerCanvas.height&&(this.textBox.style.width=(a+o)/i.height+"px"):r.activePoint.endY-a-o>0&&(this.textBox.style.width=(a+o)/i.height+"px")),this.textBox.style.width=parseFloat(this.textBox.style.width)*this.factor+"px",e.isNullOrUndefined(t)&&(this.textBox.style.width=parseFloat(this.textBox.style.width)+parseFloat(this.textBox.style.fontSize)+"px"))},h.prototype.setActivePoint=function(t,i){if(!e.isNullOrUndefined(this.activeObj.activePoint))if(this.currObjType.isText){var s=t||0,a=i||this.activeObj.textSettings.fontSize;void 0===this.activeObj.textSettings.fontSize&&(this.activeObj.textSettings.fontSize=.1*Math.abs(this.baseImg.width-this.baseImg.height)),this.setTextSelection(s,a),this.mouseDownPoint.x=this.activeObj.activePoint.endX,this.mouseDownPoint.y=this.activeObj.activePoint.endY,void 0!==this.activeObj.horTopLine&&(this.activeObj.activePoint=e.extend({},this.activeObj.activePoint,{},!0)),this.drawObject("duplicate")}else if(t&&i)this.activeObj.activePoint.startX=this.mouseDownPoint.x=t,this.activeObj.activePoint.startY=this.mouseDownPoint.y=i,this.currObjType.isDragging=!0;else{var o=this.activeObj;this.activeObj.activePoint={startX:o.horTopLine.startX,startY:o.horTopLine.startY,endX:o.horTopLine.endX,endY:o.horTopLine.endY},this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}},h.prototype.updateActivePoint=function(t,e){var i=!1,s=this.lowerCanvas.getBoundingClientRect(),a=this.calcRatio();""!==this.dragElement&&(1===this.factor?(t=(t-s.left)*a.width,e=(e-s.top)*a.height):(t=(t-s.left)*a.width/this.factor+this.pannStart.startX,e=(e-s.top)*a.height/this.factor+this.pannStart.startY));var o=this.calcMaxDimension(this.activeObj.activePoint.width,this.activeObj.activePoint.height),r={action:"resize",previousShapeSettings:this.activeObj},n={action:"move",previousShapeSettings:this.activeObj};switch(this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(t,e,o);break;case"n-resize":this.updateNPoints(t,e);break;case"ne-resize":this.updateNEPoints(t,e,o);break;case"w-resize":this.updateWPoints(t,e);break;case"e-resize":this.updateEPoints(t,e);break;case"sw-resize":this.updateSWPoints(t,e,o);break;case"s-resize":this.updateSPoints(t,e);break;case"se-resize":this.updateSEPoints(t,e,o);break;default:if(this.dragPoint.startX){var h=this.dragPoint.endX-this.previousPoint.x,l=this.dragPoint.endY-this.previousPoint.y;1!==this.factor&&(h=h*a.width/this.factor,l=l*a.height/this.factor),this.activeObj.activePoint.startX+=h,this.activeObj.activePoint.endX+=h,this.activeObj.activePoint.startY+=l,this.activeObj.activePoint.endY+=l;var c={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};"text"===this.activeObj.shape||this.allowDrag||(this.factor>1&&(this.activeObj.activePoint.startX<this.pannStart.startX||this.activeObj.activePoint.endX>c.x)&&(this.activeObj.activePoint.startY<this.pannStart.startY||this.activeObj.activePoint.endY>c.y)?(this.activeObj.activePoint.startX-=h,this.activeObj.activePoint.endX-=h,this.activeObj.activePoint.startY-=l,this.activeObj.activePoint.endY-=l):this.factor>1&&(this.activeObj.activePoint.startX<this.pannStart.startX||this.activeObj.activePoint.endX>c.x)?(this.activeObj.activePoint.startX-=h,this.activeObj.activePoint.endX-=h):this.factor>1&&(this.activeObj.activePoint.startY<this.pannStart.startY||this.activeObj.activePoint.endY>c.y)&&(this.activeObj.activePoint.startY-=l,this.activeObj.activePoint.endY-=l)),this.activeObj.activePoint.startX>=this.pannStart.startX&&this.activeObj.activePoint.startY>=this.pannStart.startY&&this.activeObj.activePoint.endX<=c.x&&this.activeObj.activePoint.endY<=c.y&&(this.allowDrag=!1)}else this.activeObj.activePoint.startX=t<this.mouseDownPoint.x?t:this.mouseDownPoint.x,this.activeObj.activePoint.startY=e<this.mouseDownPoint.y?e:this.mouseDownPoint.y,1===this.factor?(this.activeObj.activePoint.startX=(this.activeObj.activePoint.startX-s.left)*a.width,this.activeObj.activePoint.startY=(this.activeObj.activePoint.startY-s.top)*a.height,i=!1):(this.activeObj.activePoint.startX=this.activeObj.activePoint.startX-s.left+this.pannStart.startX/a.width*this.factor,this.activeObj.activePoint.startY=this.activeObj.activePoint.startY-s.top+this.pannStart.startY/a.height*this.factor,i=!0),t=t<this.mouseDownPoint.x?this.mouseDownPoint.x:t,e=e<this.mouseDownPoint.y?this.mouseDownPoint.y:e,1===this.factor?(this.activeObj.activePoint.endX=(t-s.left)*a.width,this.activeObj.activePoint.endY=(e-s.top)*a.height,i=!1):(this.activeObj.activePoint.endX=t-s.left+this.pannStart.startX/a.width*this.factor,this.activeObj.activePoint.endY=e-s.top+this.pannStart.startY/a.height*this.factor,i=!0)}return r.currentShapeSettings=this.activeObj,n.currentShapeSettings=this.activeObj,this.trigger("shapeChanging",n),this.trigger("shapeChanging",r),this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,i},h.prototype.updateNWPoints=function(t,e,i){var s,a,o,r,n=this.diffPoint.x,h=this.diffPoint.y;if("text"===this.activeObj.shape){void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=this.activeObj.activePoint.startX-t,this.diffPoint.y=this.activeObj.activePoint.startY-e):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=this.oldPoint.y-e),this.oldPoint.x=t,this.oldPoint.y=e,r=(this.diffPoint.x<=n&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,this.activeObj.activePoint.startX-=i.width/100*r,this.activeObj.activePoint.startY-=i.height/100*r,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY;var l=void 0,c=this.getMaxText();l=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree,this.activeObj.textSettings.fontSize=0===l||180===l?this.activeObj.activePoint.width/c.length*2:this.activeObj.activePoint.height/c.length*2}else{var v=void 0;if(void 0!==this.activeObj.shape&&(v=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==v[0]){if(this.activeObj.activePoint.startX=t,this.activeObj.activePoint.startY=e,this.activeObj.activePoint.startX>this.activeObj.activePoint.endX){d=this.activeObj.activePoint.startX;this.activeObj.activePoint.startX=this.activeObj.activePoint.endX,this.activeObj.activePoint.endX=d,this.dragElement="ne-resize"}if(this.activeObj.activePoint.startY>this.activeObj.activePoint.endY){var d=this.activeObj.activePoint.startY;this.activeObj.activePoint.startY=this.activeObj.activePoint.endY,this.activeObj.activePoint.endY=d,this.dragElement="sw-resize"}}else if(this.activeObj.activePoint.startX<t&&this.activeObj.activePoint.startY<e){s=t-this.activeObj.activePoint.startX,a=e-this.activeObj.activePoint.startY,o=Math.min(s,a);p=this.getScaleRatio(o);this.activeObj.activePoint.startX+=p.x,this.activeObj.activePoint.startY+=p.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.startX-=p.x,this.activeObj.activePoint.startY-=p.y)}else{s=this.activeObj.activePoint.startX-t,a=e-this.activeObj.activePoint.endY,o=Math.max(s,a);var p=this.getScaleRatio(o);this.activeObj.activePoint.startX-=p.x,this.activeObj.activePoint.startY-=p.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.startX+=p.x,this.activeObj.activePoint.startY+=p.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}},h.prototype.updateNPoints=function(t,e){var i,s,a;if("text"!==this.activeObj.shape){var o=void 0;if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==o[0]){if(this.activeObj.activePoint.startY=e,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,this.activeObj.activePoint.startY>this.activeObj.activePoint.endY){var r=this.activeObj.activePoint.startY;this.activeObj.activePoint.startY=this.activeObj.activePoint.endY,this.activeObj.activePoint.endY=r,this.dragElement="s-resize"}}else{if(this.activeObj.activePoint.endX>t&&this.activeObj.activePoint.startY<e){i=this.activeObj.activePoint.endX-t,s=e-this.activeObj.activePoint.startY,a=Math.min(i,s);n=this.getScaleRatio(a);this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.startY+=n.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.startY-=n.y)}else{i=t-this.activeObj.activePoint.endX,s=this.activeObj.activePoint.startY-e,a=Math.max(i,s);var n=this.getScaleRatio(a);this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.startY-=n.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.startY+=n.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}}},h.prototype.updateNEPoints=function(t,e,i){var s,a,o,r,n=this.diffPoint.x,h=this.diffPoint.y;if("text"===this.activeObj.shape){void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-this.activeObj.activePoint.endX,this.diffPoint.y=this.activeObj.activePoint.startY-e):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=this.oldPoint.y-e),this.oldPoint.x=t,this.oldPoint.y=e,r=(this.diffPoint.x<=n&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,this.activeObj.activePoint.endX+=i.width/100*r,this.activeObj.activePoint.startY-=i.height/100*r,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY;var l=void 0,c=this.getMaxText();l=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree,this.activeObj.textSettings.fontSize=0===l||180===l?this.activeObj.activePoint.width/c.length*2:this.activeObj.activePoint.height/c.length*2}else{var v=void 0;if(void 0!==this.activeObj.shape&&(v=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==v[0]){if(this.activeObj.activePoint.endX=t,this.activeObj.activePoint.startY=e,this.activeObj.activePoint.endX<this.activeObj.activePoint.startX){d=this.activeObj.activePoint.endX;this.activeObj.activePoint.endX=this.activeObj.activePoint.startX,this.activeObj.activePoint.startX=d,this.dragElement="nw-resize"}if(this.activeObj.activePoint.startY>this.activeObj.activePoint.endY){var d=this.activeObj.activePoint.startY;this.activeObj.activePoint.startY=this.activeObj.activePoint.endY,this.activeObj.activePoint.endY=d,this.dragElement="se-resize"}}else if(this.activeObj.activePoint.endX>t&&this.activeObj.activePoint.startY<e){s=this.activeObj.activePoint.endX-t,a=e-this.activeObj.activePoint.startY,o=Math.min(s,a);p=this.getScaleRatio(o);this.activeObj.activePoint.endX-=p.x,this.activeObj.activePoint.startY+=p.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.endX+=p.x,this.activeObj.activePoint.startY-=p.y)}else{s=t-this.activeObj.activePoint.endX,a=this.activeObj.activePoint.startY-e,o=Math.max(s,a);var p=this.getScaleRatio(o);this.activeObj.activePoint.endX+=p.x,this.activeObj.activePoint.startY-=p.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.startY<0)&&(this.activeObj.activePoint.endX-=p.x,this.activeObj.activePoint.startY+=p.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}},h.prototype.updateWPoints=function(t,e){var i,s,a;if("text"!==this.activeObj.shape){var o=void 0;if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==o[0]){if(this.activeObj.activePoint.startX=t,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.startX>this.activeObj.activePoint.endX){var r=this.activeObj.activePoint.startX;this.activeObj.activePoint.startX=this.activeObj.activePoint.endX,this.activeObj.activePoint.endX=r,this.dragElement="e-resize"}}else{if(this.activeObj.activePoint.startX<t&&this.activeObj.activePoint.endY>e){i=t-this.activeObj.activePoint.startX,s=this.activeObj.activePoint.endY-e,a=Math.min(i,s);n=this.getScaleRatio(a);this.activeObj.activePoint.startX+=n.x,this.activeObj.activePoint.endY-=n.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.startX-=n.x,this.activeObj.activePoint.endY+=n.y)}else{i=this.activeObj.activePoint.startX-t,s=e-this.activeObj.activePoint.endY,a=Math.max(i,s);var n=this.getScaleRatio(a);this.activeObj.activePoint.startX-=n.x,this.activeObj.activePoint.endY+=n.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.startX+=n.x,this.activeObj.activePoint.endY-=n.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}}},h.prototype.updateEPoints=function(t,e){var i,s,a;if("text"!==this.activeObj.shape){var o=void 0;if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==o[0]){if(this.activeObj.activePoint.endX=t,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.endX<this.activeObj.activePoint.startX){var r=this.activeObj.activePoint.endX;this.activeObj.activePoint.endX=this.activeObj.activePoint.startX,this.activeObj.activePoint.startX=r,this.dragElement="w-resize"}}else{if(this.activeObj.activePoint.endX>t&&this.activeObj.activePoint.endY>e){i=this.activeObj.activePoint.endX-t,s=this.activeObj.activePoint.endY-e,a=Math.min(i,s);n=this.getScaleRatio(a);this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.endY-=n.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.endY+=n.y)}else{i=t-this.activeObj.activePoint.endX,s=e-this.activeObj.activePoint.endY,a=Math.max(i,s);var n=this.getScaleRatio(a);this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.endY+=n.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.endY-=n.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}}},h.prototype.updateSWPoints=function(t,e,i){var s,a,o,r,n=this.diffPoint.x,h=this.diffPoint.y;if("text"===this.activeObj.shape){void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=this.activeObj.activePoint.startX-t,this.diffPoint.y=e-this.activeObj.activePoint.endY):(this.diffPoint.x=this.oldPoint.x-t,this.diffPoint.y=e-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=e,r=(this.diffPoint.x<=n&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,this.activeObj.activePoint.startX-=i.width/100*r,this.activeObj.activePoint.endY+=i.height/100*r,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY;var l=void 0,c=this.getMaxText();l=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree,this.activeObj.textSettings.fontSize=0===l||180===l?this.activeObj.activePoint.width/c.length*2:this.activeObj.activePoint.height/c.length*2}else{var v=void 0;if(void 0!==this.activeObj.shape&&(v=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==v[0]){if(this.activeObj.activePoint.startX=t,this.activeObj.activePoint.endY=e,this.activeObj.activePoint.startX>this.activeObj.activePoint.endX){d=this.activeObj.activePoint.startX;this.activeObj.activePoint.startX=this.activeObj.activePoint.endX,this.activeObj.activePoint.endX=d,this.dragElement="se-resize"}if(this.activeObj.activePoint.endY<this.activeObj.activePoint.startY){var d=this.activeObj.activePoint.endY;this.activeObj.activePoint.endY=this.activeObj.activePoint.startY,this.activeObj.activePoint.startY=d,this.dragElement="nw-resize"}}else if(this.activeObj.activePoint.startX<t&&this.activeObj.activePoint.endY>e){s=t-this.activeObj.activePoint.startX,a=this.activeObj.activePoint.endY-e,o=Math.min(s,a);p=this.getScaleRatio(o);this.activeObj.activePoint.startX+=p.x,this.activeObj.activePoint.endY-=p.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.startX-=p.x,this.activeObj.activePoint.endY+=p.y)}else{s=this.activeObj.activePoint.startX-t,a=e-this.activeObj.activePoint.endY,o=Math.max(s,a);var p=this.getScaleRatio(o);this.activeObj.activePoint.startX-=p.x,this.activeObj.activePoint.endY+=p.y,(this.activeObj.activePoint.startX<0||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.startX+=p.x,this.activeObj.activePoint.endY-=p.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}},h.prototype.updateSPoints=function(t,e){var i,s,a;if("text"!==this.activeObj.shape){var o=void 0;if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==o[0]){if(this.activeObj.activePoint.endY=e,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,this.activeObj.activePoint.endY<this.activeObj.activePoint.startY){var r=this.activeObj.activePoint.endY;this.activeObj.activePoint.endY=this.activeObj.activePoint.startY,this.activeObj.activePoint.startY=r,this.dragElement="n-resize"}}else{if(this.activeObj.activePoint.endX>t&&this.activeObj.activePoint.endY>e){i=this.activeObj.activePoint.endX-t,s=this.activeObj.activePoint.endY-e,a=Math.min(i,s);n=this.getScaleRatio(a);this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.endY-=n.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.endY+=n.y)}else{i=t-this.activeObj.activePoint.endX,s=e-this.activeObj.activePoint.endY,a=Math.max(i,s);var n=this.getScaleRatio(a);this.activeObj.activePoint.endX+=n.x,this.activeObj.activePoint.endY+=n.x,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX-=n.x,this.activeObj.activePoint.endY-=n.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}}},h.prototype.updateSEPoints=function(t,e,i){var s,a,o,r,n=this.diffPoint.x,h=this.diffPoint.y;if("text"===this.activeObj.shape){void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=t-this.activeObj.activePoint.endX,this.diffPoint.y=e-this.activeObj.activePoint.endY):(this.diffPoint.x=t-this.oldPoint.x,this.diffPoint.y=e-this.oldPoint.y),this.oldPoint.x=t,this.oldPoint.y=e,r=(this.diffPoint.x>=n&&this.diffPoint.y>=h?Math.max(this.diffPoint.x,this.diffPoint.y):Math.min(this.diffPoint.x,this.diffPoint.y))/10,this.activeObj.activePoint.endX+=i.width/50*r,this.activeObj.activePoint.endY+=i.height/50*r,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY;var l=void 0,c=this.getMaxText();l=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree,this.activeObj.textSettings.fontSize=0===l||180===l?this.activeObj.activePoint.width/c.length*2:this.activeObj.activePoint.height/c.length*2}else{var v=void 0;if(void 0!==this.activeObj.shape&&(v=this.activeObj.shape.split("-")),this.currObjType.isCustomCrop||void 0!==this.activeObj.shape&&"crop"!==v[0]){if(this.activeObj.activePoint.endX=t,this.activeObj.activePoint.endY=e,this.activeObj.activePoint.endX<this.activeObj.activePoint.startX){d=this.activeObj.activePoint.endX;this.activeObj.activePoint.endX=this.activeObj.activePoint.startX,this.activeObj.activePoint.startX=d,this.dragElement="sw-resize"}if(this.activeObj.activePoint.endY<this.activeObj.activePoint.startY){var d=this.activeObj.activePoint.endY;this.activeObj.activePoint.endY=this.activeObj.activePoint.startY,this.activeObj.activePoint.startY=d,this.dragElement="ne-resize"}}else if(this.activeObj.activePoint.endX>t&&this.activeObj.activePoint.endY>e){s=this.activeObj.activePoint.endX-t,a=this.activeObj.activePoint.endY-e,o=Math.min(s,a);var p=this.activeObj.shape.split("-");p=p[1].split(":");b=this.getScaleRatio(o);this.activeObj.activePoint.endX-=b.x,this.activeObj.activePoint.endY-=b.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX+=b.x,this.activeObj.activePoint.endY+=b.y)}else{s=t-this.activeObj.activePoint.endX,a=e-this.activeObj.activePoint.endY,o=Math.max(s,a);var b=this.getScaleRatio(o);this.activeObj.activePoint.endX+=b.x,this.activeObj.activePoint.endY+=b.y,(this.activeObj.activePoint.endX>this.lowerCanvas.width||this.activeObj.activePoint.endY>this.lowerCanvas.height)&&(this.activeObj.activePoint.endX-=b.x,this.activeObj.activePoint.endY-=b.y)}this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY}},h.prototype.getScaleRatio=function(t){var e={x:t,y:t};if(!this.currObjType.isCustomCrop&&"crop-circle"!==this.activeObj.shape&&"crop-square"!==this.activeObj.shape){var i=this.activeObj.shape.split("-");i=i[1].split(":");var s=t/parseInt(i[1],10);e.x=s*parseInt(i[0],10),e.y=s*parseInt(i[1],10)}return e},h.prototype.getMaxText=function(t){for(var e,i=(t?this.textBox.value:this.activeObj.keyHistory).split("\n"),s=i[0].length,a=i[0],o=1;o<i.length;o++)(e=i[o].length)>s&&(a=i[o],s=e);return a},h.prototype.setDragLimit=function(){1===this.factor&&void 0!==this.activeObj.activePoint&&"text"!==this.activeObj.shape&&(this.activeObj.activePoint.startX<0?(this.activeObj.activePoint.startX=0,this.activeObj.activePoint.endX=this.activeObj.activePoint.width):this.activeObj.activePoint.endX>this.lowerCanvas.width&&(this.activeObj.activePoint.endX=this.lowerCanvas.width,this.activeObj.activePoint.startX=this.lowerCanvas.width-this.activeObj.activePoint.width),this.activeObj.activePoint.startY<0?(this.activeObj.activePoint.startY=0,this.activeObj.activePoint.endY=this.activeObj.activePoint.height):this.activeObj.activePoint.endY>this.lowerCanvas.height&&(this.activeObj.activePoint.endY=this.lowerCanvas.height,this.activeObj.activePoint.startY=this.lowerCanvas.height-this.activeObj.activePoint.height))},h.prototype.lineDraw=function(t){this.activeObj.activePoint.height<10*t.height?(this.activeObj.activePoint.startY-=10*t.height,this.activeObj.activePoint.endY+=10*t.height,this.activeObj.lineDraw="horizontal"):this.activeObj.activePoint.width<10*t.width?(this.activeObj.activePoint.startX-=10*t.width,this.activeObj.activePoint.endX+=10*t.width,this.activeObj.lineDraw="vertical"):this.currObjType.isInitialLine&&(this.activeObj.lineDraw="normal",this.currObjType.isInitialLine=!1),this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY},h.prototype.shapeCircle=function(t,e,i){var s=this.calcRatio();t.strokeStyle=this.themeColl[this.theme].primaryColor,t.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),t.fillStyle="rgb(0, 0, 0, 0.5)",t.fillRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height);var a=t.lineWidth;t.lineWidth=2*(s.width+s.height)/this.factor,t.beginPath(),t.ellipse(this.activeObj.horTopLine.startX+e/2,this.activeObj.horTopLine.startY+i/2,e/2,i/2,0,0,2*Math.PI,!1),t.stroke(),t.closePath(),t.save(),t.beginPath(),t.arc((this.activeObj.activePoint.endX-this.activeObj.activePoint.startX)/2+this.activeObj.activePoint.startX,(this.activeObj.activePoint.endY-this.activeObj.activePoint.startY)/2+this.activeObj.activePoint.startY,this.activeObj.activePoint.width/2,0,2*Math.PI),t.closePath(),t.clip(),t.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),t.restore(),t.lineWidth=a,this.drawOuterSelection(t,null,!0),this.currObjType.shape=""},h.prototype.drawOuterSelection=function(t,i,s){var a,o=this.calcRatio();t.lineWidth=.5*(o.width+o.height)/this.factor,void 0!==this.activeObj.shape&&(a=this.activeObj.shape.split("-"));var r=e.extend({},this.activeObj,{},!0);1!==this.factor&&i&&(r=this.getZoomShape(r,o)),void 0!==this.activeObj.shape&&(a=this.activeObj.shape.split("-")),(void 0===a||"crop"!==a[0])&&void 0!==this.activeObj.shape||s||(this.upperContext.fillStyle="rgb(0, 0, 0, 0.5)",this.upperContext.fillRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(this.activeObj.activePoint.startX,this.activeObj.activePoint.startY,this.activeObj.activePoint.width,this.activeObj.activePoint.height)),t.strokeStyle=this.themeColl[this.theme].primaryColor,t.fillStyle=this.themeColl[this.theme].secondaryColor,"rectangle"!==this.activeObj.shape&&(t.beginPath(),t.rect(r.activePoint.startX,r.activePoint.startY,r.activePoint.width,r.activePoint.height),t.stroke(),t.closePath()),t.lineWidth*=2,t.beginPath(),t.moveTo(r.topLeftCircle.startX,r.topLeftCircle.startY),t.arc(r.topLeftCircle.startX,r.topLeftCircle.startY,r.topLeftCircle.radius,0,2*Math.PI),t.moveTo(r.topRightCircle.startX,r.topRightCircle.startY),t.arc(r.topRightCircle.startX,r.topRightCircle.startY,r.topRightCircle.radius,0,2*Math.PI),t.moveTo(r.bottomLeftCircle.startX,r.bottomLeftCircle.startY),t.arc(r.bottomLeftCircle.startX,r.bottomLeftCircle.startY,r.bottomLeftCircle.radius,0,2*Math.PI),t.moveTo(r.bottomRightCircle.startX,r.bottomRightCircle.startY),t.arc(r.bottomRightCircle.startX,r.bottomRightCircle.startY,r.bottomRightCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),t.lineWidth/=2,void 0!==a&&"crop"===a[0]||"text"===this.activeObj.shape||this.drawCenterCircles(t),this.activeObj=e.extend({},r,{},!0)},h.prototype.getZoomShape=function(t,i){var s=e.extend({},t,{},!0);return s.activePoint.startX=s.activePoint.startX/this.factor*i.width,s.activePoint.startY=s.activePoint.startY/this.factor*i.height,s.activePoint.endX=s.activePoint.endX/this.factor*i.width,s.activePoint.endY=s.activePoint.endY/this.factor*i.height,s.activePoint.width=s.activePoint.endX-s.activePoint.startX,s.activePoint.height=s.activePoint.endY-s.activePoint.startY,this.updateActiveObject(i,s.activePoint,s),s},h.prototype.drawObject=function(t,i,s,a,o){var r;r="original"===t.toLowerCase()?this.lowerContext:this.upperContext,this.setDragLimit();var n=this.calcRatio();if(this.currObjType.isLine&&"original"!==t&&!i&&this.lineDraw(n),"crop"===this.currObjType.shape.split("-")[0].toLowerCase()&&a&&this.drawCropRatio(),o&&(this.activeObj.activePoint.startX=o.startX,this.activeObj.activePoint.startY=o.startY,this.activeObj.activePoint.endX=o.endX,this.activeObj.activePoint.endY=o.endY,this.activeObj.activePoint.width=o.width,this.activeObj.activePoint.height=o.height),e.isNullOrUndefined(this.activeObj.strokeSettings)&&(this.activeObj.strokeSettings=this.strokeSettings),e.isNullOrUndefined(this.activeObj.strokeSettings.strokeWidth)&&(this.activeObj.strokeSettings.strokeWidth=2*(n.width+n.height)/this.factor),i?(this.activeObj=e.extend({},i,{},!0),1!==this.factor&&this.updateActiveObject(n)):this.updateActiveObject(n),this.currObjType.isText&&(this.activeObj.keyHistory=this.keyHistory),"original"!==t.toLowerCase()){var h=!1;this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&(h=!0),h&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.5)",this.upperContext.fillRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(this.activeObj.activePoint.startX+n.width,this.activeObj.activePoint.startY+n.height,this.activeObj.activePoint.width-n.width,this.activeObj.activePoint.height-n.height)),this.drawOuterSelection(r,s)}this.currObjType.isActiveObj=!0,i?this.drawShapeObj(t,i.shape):""!==this.keyHistory&&this.currObjType.isText?this.drawShapeObj(t,"text"):this.activeObj.shape?this.drawShapeObj(t,this.activeObj.shape):this.drawShapeObj(t,void 0)},h.prototype.updateActiveObject=function(t,i,s,a){i=i||e.extend({},this.activeObj.activePoint,{},!0),s=s||e.extend({},this.activeObj,{},!0);var o=i.width/2,r=i.height/2;s.horTopLine={startX:i.startX,startY:i.startY,endX:i.endX,endY:i.endY},s.horBottomLine={startX:i.startX,startY:i.endY,endX:i.endX,endY:i.endY},s.verLeftLine={startX:i.startX,startY:i.startY,endX:i.startX,endY:i.endY},s.verRightLine={startX:i.endX,startY:i.startY,endX:i.endX,endY:i.endY},s.topLeftCircle={startX:i.startX,startY:i.startY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.topCenterCircle={startX:i.startX+o,startY:i.startY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.topRightCircle={startX:i.endX,startY:i.startY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.centerLeftCircle={startX:i.startX,startY:i.startY+r,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.centerRightCircle={startX:i.endX,startY:i.startY+r,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.bottomLeftCircle={startX:i.startX,startY:i.endY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.bottomCenterCircle={startX:i.startX+o,startY:i.endY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.bottomRightCircle={startX:i.endX,startY:i.endY,radius:s.horTopLine.endX?7.5*(t.width>t.height?t.width:t.height)/this.factor:0},s.activePoint=i,e.isNullOrUndefined(a)&&(this.activeObj=e.extend({},s,{},!0))},h.prototype.drawShapeObj=function(t,e){var i=void 0!==e?e:this.currObjType.shape;this.currObjType.shape=i;var s;s="original"===t.toLowerCase()?this.lowerContext:this.upperContext,"rectangle"!==this.currObjType.shape.toLowerCase()&&"ellipse"!==this.currObjType.shape.toLowerCase()&&"line"!==this.currObjType.shape.toLowerCase()||(this.activeObj.shape=this.currObjType.shape),s.strokeStyle=this.activeObj.strokeSettings.strokeColor,s.fillStyle="text"===e||"freehanddraw"===e?this.activeObj.strokeSettings.strokeColor:this.activeObj.strokeSettings.fillColor;var a=this.activeObj.activePoint.width/3,o=this.activeObj.activePoint.height/3,r=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,n=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY;switch(this.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(s),s===this.upperContext&&this.drawOuterSelection(s);break;case"ellipse":s.beginPath(),s.ellipse(this.activeObj.activePoint.startX+r/2,this.activeObj.activePoint.startY+n/2,r/2,n/2,0,0,2*Math.PI,!1),""!==this.activeObj.strokeSettings.fillColor&&(s.fillStyle=this.activeObj.strokeSettings.fillColor,s.fill()),s.ellipse(this.activeObj.activePoint.startX+r/2,this.activeObj.activePoint.startY+n/2,r/2-this.activeObj.strokeSettings.strokeWidth,n/2-this.activeObj.strokeSettings.strokeWidth,0,0,2*Math.PI,!1),s.fillStyle=this.activeObj.strokeSettings.strokeColor,s.fill("evenodd"),s.closePath(),s===this.upperContext&&this.drawOuterSelection(s);break;case"crop-circle":this.shapeCircle(s,r,n);break;case"line":this.shapeLine(s,r,n),s===this.upperContext&&this.drawOuterSelection(s);break;case"text":this.shapeText(s);break;case"crop-square":case"crop-3:4":case"crop-4:3":case"crop-6:9":case"crop-9:6":case"crop-9:16":case"crop-16:9":this.drawSelection(a,o),this.currObjType.shape="";break;default:this.drawSelection(a,o)}},h.prototype.shapeLine=function(t,e,i){var s,a,o,r,n;0===(n=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree)||n%180==0?(s=this.activeObj.activePoint.startX,a=this.activeObj.activePoint.startY+i/2,o=this.activeObj.activePoint.endX,r=this.activeObj.activePoint.startY+i/2):(s=this.activeObj.activePoint.startX+e/2,a=this.activeObj.activePoint.startY,o=this.activeObj.activePoint.startX+e/2,r=this.activeObj.activePoint.endY);var h=t.lineWidth;switch(t.lineWidth=this.activeObj.strokeSettings.strokeWidth/Math.abs(this.factor),t.beginPath(),this.activeObj.lineDraw.toLowerCase()){case"horizontal":case"vertical":t.moveTo(s,a),t.lineTo(o,r);break;case"normal":t.moveTo(this.activeObj.horTopLine.startX,this.activeObj.horTopLine.startY),t.lineTo(this.activeObj.horBottomLine.endX,this.activeObj.horBottomLine.endY)}t.stroke(),t.lineWidth=h},h.prototype.shapeText=function(t){for(var e=this.activeObj.keyHistory.split("\n"),i=((this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)*e.length-this.activeObj.textSettings.fontSize*e.length)/e.length,s=0;s<e.length;s++){var a=e[s],o=(s+1)*this.activeObj.textSettings.fontSize*.85+s*i;-360===this.degree&&(this.degree=0),0===this.degree||180===this.degree?this.activeObj.textSettings.fontSize>this.activeObj.activePoint.height&&(this.activeObj.textSettings.fontSize=this.activeObj.activePoint.height-.1*this.activeObj.activePoint.height):this.activeObj.textSettings.fontSize>this.activeObj.activePoint.width&&(this.activeObj.textSettings.fontSize=this.activeObj.activePoint.width-.1*this.activeObj.activePoint.width),t.strokeStyle=this.activeObj.strokeSettings.strokeColor,t.fillStyle=this.activeObj.strokeSettings.strokeColor;var r="";this.activeObj.textSettings.bold&&(r="bold "),this.activeObj.textSettings.italic&&(r="italic "),this.activeObj.textSettings.bold&&this.activeObj.textSettings.italic&&(r="italic bold "),t.font=r+this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,4===this.activeObj.flipObjColl.length&&(this.activeObj.flipObjColl=[]);for(var n=0;n<this.activeObj.flipObjColl.length;n++)"horizontal"===this.activeObj.flipObjColl[n].toLowerCase()?(this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1),this.updateActPoint("horizontal")):"vertical"===this.activeObj.flipObjColl[n].toLowerCase()&&(this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1),this.updateActPoint("vertical"));this.activeObj.shapeDegree!==this.degree?this.rotateText(t):t.fillText(a,this.activeObj.activePoint.startX+.1*this.activeObj.textSettings.fontSize,this.activeObj.activePoint.startY+o);for(var h=0;h<this.activeObj.flipObjColl.length;h++)"horizontal"===this.activeObj.flipObjColl[h].toLowerCase()?(this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1),this.updateActPoint("horizontal")):"vertical"===this.activeObj.flipObjColl[h].toLowerCase()&&(this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1),this.updateActPoint("vertical"))}this.currObjType.isText=!1},h.prototype.updateActPoint=function(t){var e=this.calcRatio();"horizontal"===t.toLowerCase()?this.activeObj.activePoint.startX<=this.lowerCanvas.width/2?(this.activeObj.activePoint.startX=this.lowerCanvas.width/2+(this.lowerCanvas.width/2-this.activeObj.activePoint.endX),this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+this.activeObj.activePoint.width,this.updateActiveObject(e,this.activeObj.activePoint,this.activeObj)):this.activeObj.activePoint.startX>=this.lowerCanvas.width/2&&(this.activeObj.activePoint.startX=this.lowerCanvas.width-this.activeObj.activePoint.endX,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+this.activeObj.activePoint.width,this.updateActiveObject(e,this.activeObj.activePoint,this.activeObj)):"vertical"===t.toLowerCase()&&(this.activeObj.activePoint.startY<=this.lowerCanvas.height/2?(this.activeObj.activePoint.startY=this.lowerCanvas.height/2+(this.lowerCanvas.height/2-this.activeObj.activePoint.endY),this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+this.activeObj.activePoint.height,this.updateActiveObject(e,this.activeObj.activePoint,this.activeObj)):this.activeObj.activePoint.startY>=this.lowerCanvas.height/2&&(this.activeObj.activePoint.startY=this.lowerCanvas.height-this.activeObj.activePoint.endY,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+this.activeObj.activePoint.height,this.updateActiveObject(e,this.activeObj.activePoint,this.activeObj)))},h.prototype.drawSquareLines=function(t){var e;void 0!==this.activeObj.shape&&(e=this.activeObj.shape.split("-")),"crop"===e[0]?t.strokeStyle="#fff":t.strokeStyle=this.activeObj.strokeSettings.strokeColor,t.beginPath(),t.rect(this.activeObj.activePoint.startX,this.activeObj.activePoint.startY,this.activeObj.activePoint.width,this.activeObj.activePoint.height),""!==this.activeObj.strokeSettings.fillColor&&(t.fillStyle=this.activeObj.strokeSettings.fillColor,t.fill()),t.rect(this.activeObj.activePoint.startX+this.activeObj.strokeSettings.strokeWidth,this.activeObj.activePoint.startY+this.activeObj.strokeSettings.strokeWidth,this.activeObj.activePoint.width-2*this.activeObj.strokeSettings.strokeWidth,this.activeObj.activePoint.height-2*this.activeObj.strokeSettings.strokeWidth),t.fillStyle=this.activeObj.strokeSettings.strokeColor,t.fill("evenodd"),t.closePath()},h.prototype.drawSelection=function(t,e){this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.beginPath(),this.activeObj.horTopInnerLine={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY+e,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY+e},this.activeObj.horBottomInnerLine={startX:this.activeObj.activePoint.startX,startY:this.activeObj.activePoint.startY+2*e,endX:this.activeObj.activePoint.endX,endY:this.activeObj.activePoint.endY+2*e},this.activeObj.verLeftInnerLine={startX:this.activeObj.activePoint.startX+t,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+t,endY:this.activeObj.activePoint.endY},this.activeObj.verRightInnerLine={startX:this.activeObj.activePoint.startX+2*t,startY:this.activeObj.activePoint.startY,endX:this.activeObj.activePoint.startX+2*t,endY:this.activeObj.activePoint.endY},this.upperContext.moveTo(this.activeObj.horTopInnerLine.startX,this.activeObj.horTopInnerLine.startY),this.upperContext.lineTo(this.activeObj.horTopInnerLine.endX,this.activeObj.horTopInnerLine.startY),this.upperContext.moveTo(this.activeObj.horBottomInnerLine.startX,this.activeObj.horBottomInnerLine.startY),this.upperContext.lineTo(this.activeObj.horBottomInnerLine.endX,this.activeObj.horBottomInnerLine.startY),this.upperContext.moveTo(this.activeObj.verLeftInnerLine.startX,this.activeObj.verLeftInnerLine.startY),this.upperContext.lineTo(this.activeObj.verLeftInnerLine.endX,this.activeObj.verLeftInnerLine.endY),this.upperContext.moveTo(this.activeObj.verRightInnerLine.startX,this.activeObj.verRightInnerLine.startY),this.upperContext.lineTo(this.activeObj.verRightInnerLine.endX,this.activeObj.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},h.prototype.drawCenterCircles=function(t){t.lineWidth*=2,t.beginPath(),t.moveTo(this.activeObj.topCenterCircle.startX,this.activeObj.topCenterCircle.startY),t.arc(this.activeObj.topCenterCircle.startX,this.activeObj.topCenterCircle.startY,this.activeObj.topCenterCircle.radius,0,2*Math.PI),t.moveTo(this.activeObj.centerLeftCircle.startX,this.activeObj.centerLeftCircle.startY),t.arc(this.activeObj.centerLeftCircle.startX,this.activeObj.centerLeftCircle.startY,this.activeObj.centerLeftCircle.radius,0,2*Math.PI),t.moveTo(this.activeObj.centerRightCircle.startX,this.activeObj.centerRightCircle.startY),t.arc(this.activeObj.centerRightCircle.startX,this.activeObj.centerRightCircle.startY,this.activeObj.centerRightCircle.radius,0,2*Math.PI),t.moveTo(this.activeObj.bottomCenterCircle.startX,this.activeObj.bottomCenterCircle.startY),t.arc(this.activeObj.bottomCenterCircle.startX,this.activeObj.bottomCenterCircle.startY,this.activeObj.bottomCenterCircle.radius,0,2*Math.PI),t.stroke(),t.fill(),t.closePath(),t.lineWidth/=2},h.prototype.findTarget=function(t,e,i){var s=this.upperCanvas.getBoundingClientRect(),a=this.calcRatio();if(1===this.factor?(t=(t-s.left)*a.width,e=(e-s.top)*a.height):(t=t-s.left+this.pannStart.startX/a.width*this.factor,e=e-s.top+this.pannStart.startY/a.height*this.factor),"mousedown"===i.toLowerCase()||"touchstart"===i.toLowerCase()){var o=!1;this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&(o=!0),this.findTargetObj(t,e,a,o),this.updateCursorStyles(t,e,a,i)}else switch(this.dragElement.toLowerCase()){case"nw-resize":this.activeObj.topLeftCircle.startX=t,this.activeObj.topLeftCircle.startY=e;break;case"n-resize":this.activeObj.topCenterCircle.startX=t,this.activeObj.topCenterCircle.startY=e;break;case"ne-resize":this.activeObj.topRightCircle.startX=t,this.activeObj.topRightCircle.startY=e;break;case"w-resize":this.activeObj.centerLeftCircle.startX=t,this.activeObj.centerLeftCircle.startY=e;break;case"e-resize":this.activeObj.centerRightCircle.startX=t,this.activeObj.centerRightCircle.startY=e;break;case"sw-resize":this.activeObj.bottomLeftCircle.startX=t,this.activeObj.bottomLeftCircle.startY=e;break;case"s-resize":this.activeObj.bottomCenterCircle.startX=t,this.activeObj.bottomCenterCircle.startY=e;break;case"se-resize":this.activeObj.bottomRightCircle.startX=t,this.activeObj.bottomRightCircle.startY=e;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=t,this.dragPoint.endY=e)}},h.prototype.findTargetObj=function(t,i,s,a){if(0!==this.objColl.length&&!this.currObjType.isCustomCrop&&!a){for(var o=0,r=void 0,n=0;n<this.objColl.length;n++){var h=e.extend({},this.objColl[n],{},!0);1!==this.factor&&(h=this.setCursorForZoomState(h,s)),t>=h.activePoint.startX-h.topLeftCircle.radius&&t<=h.activePoint.endX+h.topLeftCircle.radius&&i>=h.activePoint.startY-h.topLeftCircle.radius&&i<=h.activePoint.endY+h.topLeftCircle.radius&&(0===o||o>t-h.activePoint.startX)&&(o=t-this.objColl[n].activePoint.startX,r=n)}if(e.isNullOrUndefined(r))return void this.refreshActiveObj();this.currObjType.isCustomCrop=!1;var l=this.activeObj=e.extend({},this.objColl[r],{},!0);this.objColl.splice(r,1),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),0===this.degree?this.inMemoryContext.putImageData(this.imgDataColl[0].value,0,0):(this.inMemoryCanvas.width=this.currImgData.width,this.inMemoryCanvas.height=this.currImgData.height,this.inMemoryContext.putImageData(this.currImgData,0,0)),""!==this.flipState&&(this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),this.inMemoryCanvas.width=this.currImgData.width,this.inMemoryCanvas.height=this.currImgData.height,this.inMemoryContext.putImageData(this.currImgData,0,0)),this.setActivePoint(),this.upperContext.drawImage(this.inMemoryCanvas,0,0),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0),this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height);for(var c=0;c<this.objColl.length;c++)"text"===this.objColl[c].shape&&this.objColl[c].shapeFlip!==this.currFlipState&&(this.objColl[c].flippedText=!0),this.apply(this.objColl[c].shape,this.objColl[c]);this.activeObj=e.extend({},l,{},!0);var v={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};(1!==this.factor&&(this.activeObj.activePoint.startX<this.pannStart.startX||this.activeObj.activePoint.startY<this.pannStart.startY)||this.activeObj.activePoint.endX>v.x||this.activeObj.activePoint.endY>v.y)&&(this.allowDrag=!0),this.tempStrokeSettings=e.extend({},this.activeObj.strokeSettings,{},!0),this.tempTextSettings=e.extend({},this.activeObj.textSettings,{},!0),"text"===this.activeObj.shape&&this.activeObj.shapeFlip!==this.currFlipState&&(this.activeObj.flippedText=!0),this.activeObj.activePoint&&this.drawObject("duplicate",this.activeObj);var d={action:"select",previousShapeSettings:this.activeObj,currentShapeSettings:this.activeObj};this.trigger("shapeChanging",d)}},h.prototype.updateCursorStyles=function(t,i,s,a){var o=!1;""===this.activeObj.keyHistory||void 0!==this.activeObj.shape||this.currObjType.isCustomCrop||this.currObjType.isLine||!this.currObjType.isText||(this.activeObj.shape="text");var r=e.extend({},this.activeObj,{},!0);e.isNullOrUndefined(r.topLeftCircle)||(1!==this.factor&&(r=this.setCursorForZoomState(r,s,!0)),t>=r.topLeftCircle.startX-r.topLeftCircle.radius&&t<=r.topLeftCircle.startX+r.topLeftCircle.radius&&i>=r.topLeftCircle.startY-r.topLeftCircle.radius&&i<=r.topLeftCircle.startY+r.topLeftCircle.radius&&"nw-resize"!==this.dragElement?(r.topLeftCircle.startX=r.topLeftCircle.startY=0,this.upperCanvas.style.cursor="nw-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.topCenterCircle.startX-r.topLeftCircle.radius&&t<=r.topCenterCircle.startX+r.topLeftCircle.radius&&i>=r.topCenterCircle.startY-r.topLeftCircle.radius&&i<=r.topCenterCircle.startY+r.topLeftCircle.radius&&"n-resize"!==this.dragElement?(r.topCenterCircle.startX=r.topCenterCircle.startY=0,this.upperCanvas.style.cursor="n-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.topRightCircle.startX-r.topLeftCircle.radius&&t<=r.topRightCircle.startX+r.topLeftCircle.radius&&i>=r.topRightCircle.startY-r.topLeftCircle.radius&&i<=r.topRightCircle.startY+r.topLeftCircle.radius&&"ne-resize"!==this.dragElement?(r.topRightCircle.startX=r.topRightCircle.startY=0,this.upperCanvas.style.cursor="ne-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.centerLeftCircle.startX-r.topLeftCircle.radius&&t<=r.centerLeftCircle.startX+r.topLeftCircle.radius&&i>=r.centerLeftCircle.startY-r.topLeftCircle.radius&&i<=r.centerLeftCircle.startY+r.topLeftCircle.radius&&"w-resize"!==this.dragElement?(r.centerLeftCircle.startX=r.centerLeftCircle.startY=0,this.upperCanvas.style.cursor="w-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.centerRightCircle.startX-r.topLeftCircle.radius&&t<=r.centerRightCircle.startX+r.topLeftCircle.radius&&i>=r.centerRightCircle.startY-r.topLeftCircle.radius&&i<=r.centerRightCircle.startY+r.topLeftCircle.radius&&"e-resize"!==this.dragElement?(r.centerRightCircle.startX=r.centerRightCircle.startY=0,this.upperCanvas.style.cursor="e-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.bottomLeftCircle.startX-r.topLeftCircle.radius&&t<=r.bottomLeftCircle.startX+r.topLeftCircle.radius&&i>=r.bottomLeftCircle.startY-r.topLeftCircle.radius&&i<=r.bottomLeftCircle.startY+r.topLeftCircle.radius&&"sw-resize"!==this.dragElement?(r.bottomLeftCircle.startX=r.bottomLeftCircle.startY=0,this.upperCanvas.style.cursor="sw-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.bottomCenterCircle.startX-r.topLeftCircle.radius&&t<=r.bottomCenterCircle.startX+r.topLeftCircle.radius&&i>=r.bottomCenterCircle.startY-r.topLeftCircle.radius&&i<=r.bottomCenterCircle.startY+r.topLeftCircle.radius&&"s-resize"!==this.dragElement?(r.bottomCenterCircle.startX=r.bottomCenterCircle.startY=0,this.upperCanvas.style.cursor="s-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):t>=r.bottomRightCircle.startX-r.topLeftCircle.radius&&t<=r.bottomRightCircle.startX+r.topLeftCircle.radius&&i>=r.bottomRightCircle.startY-r.topLeftCircle.radius&&i<=r.bottomRightCircle.startY+r.topLeftCircle.radius&&"se-resize"!==this.dragElement?(r.bottomRightCircle.startX=r.bottomRightCircle.startY=0,this.upperCanvas.style.cursor="se-resize",o=!0,this.dragElement=this.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=t,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i),this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===a?(o||t>=r.activePoint.startX&&t<=r.activePoint.endX&&i>=r.activePoint.startY&&i<=r.activePoint.endY)&&(this.currObjType.isDragging=!0):this.currObjType.isDragging=!0)},h.prototype.drawCropRatio=function(){var t,e;switch(this.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":this.setDragDirection(),this.lowerCanvas.width>this.lowerCanvas.height?(this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,this.activeObj.activePoint.width=this.activeObj.activePoint.height,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+this.activeObj.activePoint.width):(this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.width,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+this.activeObj.activePoint.height);break;case"crop-3:2":t=3,e=2;break;case"crop-4:3":t=4,e=3;break;case"crop-5:4":t=5,e=4;break;case"crop-7:5":t=7,e=5;break;case"crop-16:9":t=16,e=9}void 0!==t&&void 0!==e&&this.calcShapeRatio(t,e)},h.prototype.setDragDirection=function(){var t=this.calcRatio(),e=7.5*(t.width>t.height?t.width:t.height)/this.factor;if(this.lowerCanvas.width>this.lowerCanvas.height)if(1===this.factor)this.activeObj.activePoint.startX=this.dragPoint.startX=this.lowerCanvas.width/2-this.lowerCanvas.height/2+e,this.activeObj.activePoint.startY=this.dragPoint.startY=this.lowerCanvas.height/2-this.lowerCanvas.height/2+e,this.activeObj.activePoint.endX=this.lowerCanvas.width/2+this.lowerCanvas.height/2-e,this.activeObj.activePoint.endY=this.lowerCanvas.height/2+this.lowerCanvas.height/2-e;else{var i=(r={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY}).x-this.pannStart.startX,s=r.y-this.pannStart.startY,a=(this.dragPoint.startX=i/2)+this.pannStart.startX,o=this.dragPoint.startY=s/2;this.activeObj.activePoint.startX=a-o+e,this.activeObj.activePoint.startY=this.pannStart.startY+e,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+s-e,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+s-2*e}else if(1===this.factor)this.activeObj.activePoint.startY=this.dragPoint.startX=this.lowerCanvas.height/2-this.lowerCanvas.width/2+e,this.activeObj.activePoint.endY=this.lowerCanvas.height/2+this.lowerCanvas.width/2-e,this.activeObj.activePoint.startX=this.dragPoint.startX=e,this.activeObj.activePoint.endX=this.lowerCanvas.width-e;else{var r={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY},i=r.x-this.pannStart.startX,s=r.y-this.pannStart.startY,a=this.dragPoint.startX=i/2,o=(this.dragPoint.startY=s/2)+this.pannStart.startY;this.activeObj.activePoint.startX=this.pannStart.startX+e,this.activeObj.activePoint.startY=o-a+e,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+i-e,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+i-e}},h.prototype.calcShapeRatio=function(t,e){for(var i=this.calcRatio(),s=7.5*(i.width>i.height?i.width:i.height)/this.factor,a=1===this.factor?this.lowerCanvas.width:this.lowerCanvas.width/this.factor,o=1===this.factor?this.lowerCanvas.height:this.lowerCanvas.height/this.factor,r=t/e,n=a>=o?a:o,h=n*r,l=n,c=this.getScale(h,a),v=[],d=0;d<2;d++)0===d?v.push(h*c):v.push(l*c);h=v[0],l=v[1];for(var p=this.getScale(l,o),b=[],d=0;d<2;d++)0===d?b.push(h*p):b.push(l*p);h=b[0],l=b[1],this.activeObj.activePoint.width=h,this.activeObj.activePoint.height=l,this.activeObj.activePoint.startX=(this.dragPoint.startX=(a-h)/2)+s,this.activeObj.activePoint.startY=(this.dragPoint.startY=(o-l)/2)+s,this.activeObj.activePoint.endX=(a-h)/2+h-s,this.activeObj.activePoint.endY=(o-l)/2+l-s,1!==this.factor&&(this.activeObj.activePoint.startX+=this.pannStart.startX,this.activeObj.activePoint.startY+=this.pannStart.startY,this.activeObj.activePoint.endX+=this.pannStart.startX,this.activeObj.activePoint.endY+=this.pannStart.startY),this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY},h.prototype.getScale=function(t,e){return t>e?e/t:1},h.prototype.calcRatio=function(){var t,e;return 0===this.degree||this.degree%180==0?(t=this.baseImg.width/parseInt(this.lowerCanvas.style.maxWidth,10),e=this.baseImg.height/parseInt(this.lowerCanvas.style.maxHeight,10)):(t=this.baseImg.height/parseInt(this.lowerCanvas.style.maxWidth,10),e=this.baseImg.width/parseInt(this.lowerCanvas.style.maxHeight,10)),{width:t,height:e}},h.prototype.calcMaxDimension=function(t,i){var s=this.element.clientWidth,a=this.element.clientHeight-this.toolbarHeight;a=e.Browser.isDevice?a-this.toolbarHeight:a;var o=(s-=30)/t,r=(a-=30)/i,n=Math.min(t,s),h=Math.min(i,a);return o<1&&o<r?(n=t*o,h=i*o):r<1&&r<o&&(n=t*r,h=i*r),{width:n,height:h}},h.prototype.setMaximumDimension=function(t){var e,i;t%90==0&&t%180!=0?(e=this.baseImg.height,i=this.baseImg.width):t%180!=0&&0!==t||(e=this.baseImg.width,i=this.baseImg.height),this.lowerCanvas.width=this.upperCanvas.width=e,this.lowerCanvas.height=this.upperCanvas.height=i;var s=this.calcMaxDimension(e,i);this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=s.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=s.height+"px"},h.prototype.setCursor=function(t,i){var s=this.upperCanvas.getBoundingClientRect(),a=this.calcRatio();if(1===this.factor?(t=(t-s.left)*a.width,i=(i-s.top)*a.height):(t=t-s.left+this.pannStart.startX/a.width*this.factor,i=i-s.top+this.pannStart.startY/a.height*this.factor),void 0!==this.activeObj.horTopLine)if(this.togglePan)this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="grab";else{var o=e.extend({},this.activeObj,{},!0);1!==this.factor&&(o=this.setCursorForZoomState(o,a,!0)),t>=o.topLeftCircle.startX-o.topLeftCircle.radius&&t<=o.topLeftCircle.startX+o.topLeftCircle.radius&&i>=o.topLeftCircle.startY-o.topLeftCircle.radius&&i<=o.topLeftCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="nw-resize":t>=o.topCenterCircle.startX-o.topLeftCircle.radius&&t<=o.topCenterCircle.startX+o.topLeftCircle.radius&&i>=o.topCenterCircle.startY-o.topLeftCircle.radius&&i<=o.topCenterCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="n-resize":t>=o.topRightCircle.startX-o.topLeftCircle.radius&&t<=o.topRightCircle.startX+o.topLeftCircle.radius&&i>=o.topRightCircle.startY-o.topLeftCircle.radius&&i<=o.topRightCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="ne-resize":t>=o.centerLeftCircle.startX-o.topLeftCircle.radius&&t<=o.centerLeftCircle.startX+o.topLeftCircle.radius&&i>=o.centerLeftCircle.startY-o.topLeftCircle.radius&&i<=o.centerLeftCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="w-resize":t>=o.centerRightCircle.startX-o.topLeftCircle.radius&&t<=o.centerRightCircle.startX+o.topLeftCircle.radius&&i>=o.centerRightCircle.startY-o.topLeftCircle.radius&&i<=o.centerRightCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="e-resize":t>=o.bottomLeftCircle.startX-o.topLeftCircle.radius&&t<=o.bottomLeftCircle.startX+o.topLeftCircle.radius&&i>=o.bottomLeftCircle.startY-o.topLeftCircle.radius&&i<=o.bottomLeftCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="sw-resize":t>=o.bottomCenterCircle.startX-o.topLeftCircle.radius&&t<=o.bottomCenterCircle.startX+o.topLeftCircle.radius&&i>=o.bottomCenterCircle.startY-o.topLeftCircle.radius&&i<=o.bottomCenterCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="s-resize":t>=o.bottomRightCircle.startX-o.topLeftCircle.radius&&t<=o.bottomRightCircle.startX+o.topLeftCircle.radius&&i>=o.bottomRightCircle.startY-o.topLeftCircle.radius&&i<=o.bottomRightCircle.startY+o.topLeftCircle.radius?this.upperCanvas.style.cursor="se-resize":t>=o.activePoint.startX&&t<=o.activePoint.endX&&i>=o.activePoint.startY&&i<=o.activePoint.endY?this.upperCanvas.style.cursor="move":(this.currObjType.isCustomCrop&&(this.upperCanvas.style.cursor="cross-hair"),this.upperCanvas.style.cursor="default")}else this.togglePan?this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="grab":this.currObjType.isCustomCrop||this.togglePen?this.upperCanvas.style.cursor="crosshair":this.upperCanvas.style.cursor="default";"default"===this.upperCanvas.style.cursor&&this.objColl.length>0&&this.setCursorFromObj(t,i,this.objColl,a)},h.prototype.setCursorFromObj=function(t,i,s,a){if(this.togglePan)this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="grab";else for(var o=0;o<s.length;o++){var r=e.extend({},s[o],{},!0);if(1!==this.factor&&(r=this.setCursorForZoomState(s[o],a,!0)),t>=r.topLeftCircle.startX-r.topLeftCircle.radius&&t<=r.topLeftCircle.startX+r.topLeftCircle.radius&&i>=r.topLeftCircle.startY-r.topLeftCircle.radius&&i<=r.topLeftCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="nw-resize";break}if(t>=r.topCenterCircle.startX-r.topLeftCircle.radius&&t<=r.topCenterCircle.startX+r.topLeftCircle.radius&&i>=r.topCenterCircle.startY-r.topLeftCircle.radius&&i<=r.topCenterCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="n-resize";break}if(t>=r.topRightCircle.startX-r.topLeftCircle.radius&&t<=r.topRightCircle.startX+r.topLeftCircle.radius&&i>=r.topRightCircle.startY-r.topLeftCircle.radius&&i<=r.topRightCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="ne-resize";break}if(t>=r.centerLeftCircle.startX-r.topLeftCircle.radius&&t<=r.centerLeftCircle.startX+r.topLeftCircle.radius&&i>=r.centerLeftCircle.startY-r.topLeftCircle.radius&&i<=r.centerLeftCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="w-resize";break}if(t>=r.centerRightCircle.startX-r.topLeftCircle.radius&&t<=r.centerRightCircle.startX+r.topLeftCircle.radius&&i>=r.centerRightCircle.startY-r.topLeftCircle.radius&&i<=r.centerRightCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="e-resize";break}if(t>=r.bottomLeftCircle.startX-r.topLeftCircle.radius&&t<=r.bottomLeftCircle.startX+r.topLeftCircle.radius&&i>=r.bottomLeftCircle.startY-r.topLeftCircle.radius&&i<=r.bottomLeftCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="sw-resize";break}if(t>=r.bottomCenterCircle.startX-r.topLeftCircle.radius&&t<=r.bottomCenterCircle.startX+r.topLeftCircle.radius&&i>=r.bottomCenterCircle.startY-r.topLeftCircle.radius&&i<=r.bottomCenterCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="s-resize";break}if(t>=r.bottomRightCircle.startX-r.topLeftCircle.radius&&t<=r.bottomRightCircle.startX+r.topLeftCircle.radius&&i>=r.bottomRightCircle.startY-r.topLeftCircle.radius&&i<=r.bottomRightCircle.startY+r.topLeftCircle.radius){this.upperCanvas.style.cursor="se-resize";break}if(t>=r.activePoint.startX&&t<=r.activePoint.endX&&i>=r.activePoint.startY&&i<=r.activePoint.endY){this.upperCanvas.style.cursor="move";break}this.currObjType.isCustomCrop&&(this.upperCanvas.style.cursor="cross-hair"),this.upperCanvas.style.cursor="default"}},h.prototype.setCursorForZoomState=function(t,i,s){var a=e.extend({},t,{},!0);return a.activePoint.startX=a.activePoint.startX/i.width*this.factor,a.activePoint.startY=a.activePoint.startY/i.width*this.factor,a.activePoint.endX=a.activePoint.endX/i.width*this.factor,a.activePoint.endY=a.activePoint.endY/i.width*this.factor,a.activePoint.width=a.activePoint.endX-a.activePoint.startX,a.activePoint.height=a.activePoint.endY-a.activePoint.startY,this.updateActiveObject(i,a.activePoint,a,s),a.topLeftCircle.radius=a.topLeftCircle.radius/i.width*this.factor,a},h.prototype.downloadImg=function(t,e){var i=document.createElement("a");i.href=t,i.target="_parent",i.download=e,(document.body||document.documentElement).appendChild(i),i.click(),i.parentNode.removeChild(i)},h.prototype.toSVGImg=function(t){var e=this.lowerCanvas.toDataURL(),i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",this.lowerCanvas.style.maxWidth),i.setAttribute("height",this.lowerCanvas.style.maxHeight);var s=document.createElementNS("http://www.w3.org/2000/svg","image");s.setAttributeNS(null,"height",this.lowerCanvas.height.toString()),s.setAttributeNS(null,"width",this.lowerCanvas.width.toString()),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e),i.appendChild(s);var a='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+this.lowerCanvas.width+'" height="'+this.lowerCanvas.height+'">'+i.innerHTML+"</svg>",o="data:image/svg+xml;base64,"+btoa(a);return null===t?o:(this.downloadImg(o,t+".svg"),null)},h.prototype.toBlobFn=function(t,e){var i=this;this.lowerCanvas.toBlob(function(s){var a=URL.createObjectURL(s);i.baseImg.src=a,i.downloadImg(a,t+"."+e)},"image/png")},h.prototype.addLetter=function(t){if("none"===this.textBox.style.display&&(this.currObjType.isText||"text"===this.activeObj.shape)){"Backspace"===t?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=t,this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.updateFontStyles();var e=this.upperContext.measureText(this.keyHistory+this.tempKeyHistory).width+.5*this.activeObj.textSettings.fontSize,i=this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize;this.upperContext.fillText(this.keyHistory+this.tempKeyHistory,this.activeObj.activePoint.startX,this.activeObj.activePoint.startY+this.activeObj.textSettings.fontSize),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.currObjType.isText=!0,this.setActivePoint(e,i)}},h.prototype.updateFontStyles=function(){this.upperContext.strokeStyle=this.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=this.activeObj.strokeSettings.strokeColor;var t="";this.activeObj.textSettings.bold&&(t="bold "),this.activeObj.textSettings.italic&&(t="italic "),this.activeObj.textSettings.bold&&this.activeObj.textSettings.italic&&(t="italic bold ");var e=this.activeObj.textSettings.fontSize,i="block"===this.textBox.style.display?this.textBox.style.fontFamily:this.activeObj.textSettings.fontFamily;this.upperContext.font=t+e+"px "+i},h.prototype.updateInMemoryCanvas=function(t){if(!this.disabled){var e=this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height);this.imgDataColl.push({operation:t,value:e}),this.inMemoryCanvas.width=e.width,this.inMemoryCanvas.height=e.height,this.inMemoryContext.putImageData(e,0,0)}},h.prototype.drawBaseImg=function(){this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.inMemoryCanvas.width=this.lowerCanvas.width=this.imgDataColl[0].value.width,this.inMemoryCanvas.height=this.lowerCanvas.height=this.imgDataColl[0].value.height,this.inMemoryContext.putImageData(this.imgDataColl[0].value,0,0);var t=this.calcMaxDimension(this.inMemoryCanvas.width,this.inMemoryCanvas.height);this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=t.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=t.height+"px",this.lowerCanvas.style.left=this.upperCanvas.style.left=(this.element.clientWidth-t.width)/2+1+"px",this.lowerCanvas.style.top=this.upperCanvas.style.top=(this.element.clientHeight-this.toolbarHeight-t.height)/2+1+"px",this.lowerContext.drawImage(this.inMemoryCanvas,0,0)},h.prototype.calcPrevRatio=function(){var t,e,i;return 0===this.degree||this.degree%180==0?(i=this.calcMaxDimension(this.baseImg.height,this.baseImg.width),t=this.baseImg.height/i.width,e=this.baseImg.width/i.height):(i=this.calcMaxDimension(this.baseImg.width,this.baseImg.height),t=this.baseImg.width/i.width,e=this.baseImg.height/i.height),{width:t,height:e}},h.prototype.textFlipDegree=function(t,e,i){for(var s=this.activeObj.keyHistory.split("\n"),a=(this.activeObj.textSettings.fontSize*s.length-this.activeObj.textSettings.fontSize*s.length)/s.length,o=.85*this.activeObj.textSettings.fontSize+a,r=0;r<s.length;r++){var n=s[r];r>0&&(1===r&&(o-=.85*this.activeObj.textSettings.fontSize),o+=this.activeObj.textSettings.fontSize+.15*this.activeObj.textSettings.fontSize),t.fillText(n,e+.15*this.activeObj.textSettings.fontSize,i+o+(r>0?.25*this.activeObj.textSettings.fontSize:.35*-this.activeObj.textSettings.fontSize))}},h.prototype.rotateText=function(t){var e,i=this.activeObj.activePoint.startX,s=this.activeObj.activePoint.startY;if((e=0===this.activeObj.shapeDegree?this.degree:this.degree-this.activeObj.shapeDegree)<0&&(e=360+e),e%360!=0||-360===this.degree&&""!==this.currFlipState)e%90==0&&e%180!=0?(t.translate(this.lowerCanvas.width/2,this.lowerCanvas.height/2),t.rotate(Math.PI/180*e),t.translate(-this.lowerCanvas.height/2,-this.lowerCanvas.width/2),e%90==0&&e%270!=0?(s=this.lowerCanvas.width-this.activeObj.activePoint.endX+.4*this.activeObj.textSettings.fontSize,i=this.activeObj.activePoint.startY):e%270==0&&(i=this.lowerCanvas.height-this.activeObj.activePoint.endY,s=this.activeObj.activePoint.startX+.4*this.activeObj.textSettings.fontSize),this.textFlipDegree(t,i,s),t.translate(this.lowerCanvas.height/2,this.lowerCanvas.width/2),t.rotate(Math.PI/180*-e),t.translate(-this.lowerCanvas.width/2,-this.lowerCanvas.height/2)):(t.translate(this.lowerCanvas.width/2,this.lowerCanvas.height/2),t.rotate(Math.PI/180*e),i=this.lowerCanvas.width-this.activeObj.activePoint.endX,s=this.lowerCanvas.height-this.activeObj.activePoint.endY+.4*this.activeObj.textSettings.fontSize,t.translate(-this.lowerCanvas.width/2,-this.lowerCanvas.height/2),this.textFlipDegree(t,i,s),t.translate(this.lowerCanvas.width/2,this.lowerCanvas.height/2),t.rotate(Math.PI/180*-e),t.translate(-this.lowerCanvas.width/2,-this.lowerCanvas.height/2));else{i=this.activeObj.activePoint.startX+.15*this.activeObj.textSettings.fontSize,s=this.activeObj.activePoint.startY+(this.activeObj.activePoint.endY-this.activeObj.activePoint.startY);for(var a=this.activeObj.keyHistory.split("\n"),o=0;o<a.length;o++)s=this.activeObj.activePoint.startY+(o*this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize),t.fillText(a[o],i,s)}360!==this.degree&&-360!==this.degree||(this.degree=0)},h.prototype.redrawSelection=function(t){var e=this.calcRatio();t?(this.activeObj.activePoint.startX=(this.lowerCanvas.width-this.zoomedImg.width)/2,this.activeObj.activePoint.startY=(this.lowerCanvas.height-this.zoomedImg.height)/2,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+this.zoomedImg.width,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+this.zoomedImg.height,this.activeObj.activePoint.width=this.zoomedImg.width,this.activeObj.activePoint.height=this.zoomedImg.height):(this.activeObj.activePoint.startX=0,this.activeObj.activePoint.startY=0,this.activeObj.activePoint.endX=this.lowerCanvas.width,this.activeObj.activePoint.endY=this.lowerCanvas.height,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY),this.updateActiveObject(e,this.activeObj.activePoint,this.activeObj),this.drawObject("duplicate",this.activeObj)},h.prototype.redrawObj=function(t){if(this.objColl.length>0)if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t)this.updateCurrentActiveObjPoint(t);else if(90===t||-90===t){this.updateCurrentActiveObjPoint(t);for(e=0;e<this.objColl.length;e++)this.apply(this.objColl[e].shape,this.objColl[e])}else{this.updateCurrentActiveObjPoint("zoom");for(var e=0;e<this.objColl.length;e++)this.apply(this.objColl[e].shape,this.objColl[e])}else if(0!==this.objColl.length||"horizontal"!==t&&"vertical"!==t&&"Horizontal"!==t&&"Vertical"!==t){if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t){var i=void 0;void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),void 0!==i&&"crop"===i[0]?this.select(i[1]):this.redrawSelection()}}else void 0!==this.activeObj.horTopLine&&void 0===this.activeObj.shape?this.redrawSelection():void 0!==this.activeObj.horTopLine&&void 0!==this.activeObj.shape&&"crop"===(i=this.activeObj.shape.split("-"))[0]&&this.select(i[1])},h.prototype.updateCurrentActiveObjPoint=function(t){for(var i,s=this.calcPrevRatio(),a=this.calcRatio(),o=0;o<this.objColl.length;o++)if(this.activeObj.shape===this.objColl[o].shape&&this.activeObj.activePoint.startX===this.objColl[o].activePoint.startX&&this.activeObj.activePoint.startY===this.objColl[o].activePoint.startY&&this.activeObj.activePoint.endX===this.objColl[o].activePoint.endX&&this.activeObj.activePoint.endY===this.objColl[o].activePoint.endY&&this.activeObj.currIndex===this.objColl[o].currIndex){i=o;break}if("horizontal"===t||"vertical"===t||"Horizontal"===t||"Vertical"===t){if("horizontal"===t||"Horizontal"===t)for(r=0;r<this.objColl.length;r++)this.objColl[r].activePoint.startX<=this.lowerCanvas.width/2?(this.objColl[r].activePoint.startX=this.lowerCanvas.width/2+(this.lowerCanvas.width/2-this.objColl[r].activePoint.endX),this.objColl[r].activePoint.endX=this.objColl[r].activePoint.startX+this.objColl[r].activePoint.width,this.updateActiveObject(a,this.objColl[r].activePoint,this.objColl[r])):this.objColl[r].activePoint.startX>=this.lowerCanvas.width/2&&(this.objColl[r].activePoint.startX=this.lowerCanvas.width-this.objColl[r].activePoint.endX,this.objColl[r].activePoint.endX=this.objColl[r].activePoint.startX+this.objColl[r].activePoint.width,this.updateActiveObject(a,this.objColl[r].activePoint,this.objColl[r]));else if("vertical"===t||"Vertical"===t)for(r=0;r<this.objColl.length;r++)this.objColl[r].activePoint.startY<=this.lowerCanvas.height/2?(this.objColl[r].activePoint.startY=this.lowerCanvas.height/2+(this.lowerCanvas.height/2-this.objColl[r].activePoint.endY),this.objColl[r].activePoint.endY=this.objColl[r].activePoint.startY+this.objColl[r].activePoint.height,this.updateActiveObject(a,this.objColl[r].activePoint,this.objColl[r])):this.objColl[r].activePoint.startY>=this.lowerCanvas.height/2&&(this.objColl[r].activePoint.startY=this.lowerCanvas.height-this.objColl[r].activePoint.endY,this.objColl[r].activePoint.endY=this.objColl[r].activePoint.startY+this.objColl[r].activePoint.height,this.updateActiveObject(a,this.objColl[r].activePoint,this.objColl[r]));void 0!==i&&(this.activeObj=e.extend({},this.objColl[i],{},!0))}else if(90===t||-90===t){for(r=0;r<this.objColl.length;r++)this.objColl[r].activePoint.startX/=s.width,this.objColl[r].activePoint.startY/=s.height,this.objColl[r].activePoint.endX/=s.width,this.objColl[r].activePoint.endY/=s.height,this.objColl[r].activePoint.height=this.objColl[r].activePoint.endX-this.objColl[r].activePoint.startX,this.objColl[r].activePoint.width=this.objColl[r].activePoint.endY-this.objColl[r].activePoint.startY,this.objColl[r].strokeSettings.strokeWidth/=s.width/this.factor,this.calcCurrPoints(t,this.objColl[r]),this.objColl[r].activePoint.endX=this.objColl[r].activePoint.startX+this.objColl[r].activePoint.width,this.objColl[r].activePoint.endY=this.objColl[r].activePoint.startY+this.objColl[r].activePoint.height,this.objColl[r].activePoint.width=this.objColl[r].activePoint.endX-this.objColl[r].activePoint.startX,this.objColl[r].activePoint.height=this.objColl[r].activePoint.endY-this.objColl[r].activePoint.startY;for(r=0;r<this.objColl.length;r++)this.objColl[r].activePoint.startX*=s.width,this.objColl[r].activePoint.startY*=s.height,this.objColl[r].activePoint.endX*=s.width,this.objColl[r].activePoint.endY*=s.height,this.objColl[r].activePoint.width=this.objColl[r].activePoint.endX-this.objColl[r].activePoint.startX,this.objColl[r].activePoint.height=this.objColl[r].activePoint.endY-this.objColl[r].activePoint.startY,this.objColl[r].strokeSettings.strokeWidth*=a.width;for(r=0;r<this.objColl.length;r++)this.updateActiveObject(a,this.objColl[r].activePoint,this.objColl[r])}else if("zoom"===t)for(var r=0;r<this.objColl.length;r++)this.objColl[r].activePoint.startX/=a.width,this.objColl[r].activePoint.startY/=a.height,this.objColl[r].activePoint.endX/=a.width,this.objColl[r].activePoint.endY/=a.height,this.objColl[r].activePoint.height=this.objColl[r].activePoint.endX-this.objColl[r].activePoint.startX,this.objColl[r].activePoint.width=this.objColl[r].activePoint.endY-this.objColl[r].activePoint.startY,this.objColl[r].activePoint.startX*=a.width,this.objColl[r].activePoint.startY*=a.height,this.objColl[r].activePoint.endX*=a.width,this.objColl[r].activePoint.endY*=a.height,this.objColl[r].activePoint.width=this.objColl[r].activePoint.endX-this.objColl[r].activePoint.startX,this.objColl[r].activePoint.height=this.objColl[r].activePoint.endY-this.objColl[r].activePoint.startY},h.prototype.calcCurrPoints=function(t,e){var i=this.calcPrevRatio();if(t>0){var s=e.activePoint.startX;e.activePoint.startX=this.lowerCanvas.width/i.width-(e.activePoint.startY+e.activePoint.width),e.activePoint.startY=s}else{var a=e.activePoint.startY;e.activePoint.startY=this.lowerCanvas.height/i.height-(e.activePoint.startX+e.activePoint.height),e.activePoint.startX=a}},h.prototype.redrawShape=function(t){for(var e=0;e<this.objColl.length;e++)if(JSON.stringify(t)===JSON.stringify(this.objColl[e])){this.objColl.splice(e,1);break}this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.drawObject("duplicate",t)},h.prototype.applyActObj=function(){var t=!1;if(void 0!==this.activeObj.shape&&"text"===this.activeObj.shape&&""===this.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);else{var i=void 0,s=!1;if(void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),void 0===i&&this.currObjType.isCustomCrop?s=!0:void 0!==i&&"crop"===i[0]&&(s=!0),0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height&&!s){for(r=0;r<this.objColl.length;r++)if(JSON.stringify(this.activeObj)===JSON.stringify(this.objColl[r])){t=!0;break}if(!t){e.isNullOrUndefined(this.activeObj.currIndex)&&(this.activeObj.currIndex="shape_"+(this.objColl.length+1));var a=this.activeObj.currIndex.split("_"),o=this.objColl.splice(0,parseInt(a[1],10)-1);o.push(e.extend({},this.activeObj,{},!0));for(r=0;r<this.objColl.length;r++)o.push(this.objColl[r]);this.objColl=o,o=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var r=0;r<this.objColl.length;r++)this.apply(this.objColl[r].shape,this.objColl[r]);this.activeObj.flippedText=!1,this.currObjType.shape="",this.refreshActiveObj()}}}},h.prototype.apply=function(t,i,s){if(!this.disabled){var a=this;this.togglePen&&!this.currObjType.isCustomCrop?(this.upperCanvas.toBlob(function(t){o.showSpinner(a.element),a.element.style.opacity="0.5",a.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.lowerContext.drawImage(a.inMemoryCanvas,0,0),a.baseImg.src=URL.createObjectURL(t),a.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.togglePen=!1,a.upperCanvas.style.cursor="default";for(var e=0,i=a.objColl.length;e<i;e++)a.apply(a.objColl[e].shape,a.objColl[e],"duplicate");a.togglePen=!0},"image/png"),this.isUndoRedo=!1,this.degree=0):(s=s||"original",this.currObjType.shape=void 0!==t?t:this.currObjType.shape,""!==this.currObjType.shape&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.drawObject(s,i),this.activeObj.shape=this.currObjType.shape.toLowerCase(),t||""===this.currObjType.shape||this.currObjType.isCustomCrop||this.objColl.push(e.extend({},this.activeObj,{},!0)),this.keyHistory=""),this.isUndoRedo=!1)}},h.prototype.setCenterPoints=function(t,e,i){var s,a;if(t&&e&&i?(s=e,a=i):(s=this.activeObj.activePoint.width,a=this.activeObj.activePoint.height),1===this.factor)this.activeObj.activePoint.startX=this.lowerCanvas.width/2-s/2,this.activeObj.activePoint.startY=this.lowerCanvas.height/2-a/2,this.activeObj.activePoint.endX=this.lowerCanvas.width/2+s/2,this.activeObj.activePoint.endY=this.lowerCanvas.height/2+a/2;else{var o={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY},r=o.x-this.pannStart.startX,n=o.y-this.pannStart.startY,h=(this.dragPoint.startX=r/2)+this.pannStart.startX,l=this.dragPoint.startY=n/2+this.pannStart.startY;this.activeObj.activePoint.startX=h-s/2,this.activeObj.activePoint.startY=l-a/2,this.activeObj.activePoint.endX=h+s/2,this.activeObj.activePoint.endY=l+a/2}t&&e&&i&&(this.textStartPoints.x=this.activeObj.activePoint.startX,this.textStartPoints.y=this.activeObj.activePoint.startY)},h.prototype.drawShape=function(t,i,s,a,o,r,n){if(!this.disabled&&this.imgDataColl.length>0){var h=this.calcRatio();if(this.redrawActObj(),this.togglePen=!1,this.keyHistory="",this.upperCanvas.style.display="block",this.refreshActiveObj(),this.currObjType.shape=t,"freehanddraw"!==this.currObjType.shape.toLowerCase()&&""!==this.currObjType.shape.toLowerCase()){this.activeObj.shape=this.currObjType.shape.toLowerCase(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),e.isNullOrUndefined(this.activeObj.strokeSettings)&&(this.activeObj.strokeSettings=this.strokeSettings),this.activeObj.strokeSettings.strokeWidth=i||this.activeObj.strokeSettings.strokeWidth,this.activeObj.strokeSettings.strokeColor=s||this.activeObj.strokeSettings.strokeColor,this.activeObj.strokeSettings.fillColor=a||this.activeObj.strokeSettings.fillColor;var l=100/this.factor,c=100/this.factor;this.activeObj.activePoint.width=l*h.width,this.activeObj.activePoint.height=c*h.height,"line"===this.currObjType.shape.toLowerCase()?(this.activeObj.lineDraw="horizontal",this.activeObj.activePoint.height/=2):"rectangle"===this.currObjType.shape.toLowerCase()&&(this.activeObj.activePoint.width+=this.activeObj.activePoint.width/2),"ellipse"===this.currObjType.shape.toLowerCase()&&r&&(this.activeObj.activePoint.width=2*r,this.activeObj.activePoint.height=2*n),r&&n&&(this.activeObj.activePoint.width=r,this.activeObj.activePoint.height=n),void 0!==o?(this.activeObj.activePoint.startX=o.x,this.activeObj.activePoint.startY=o.y,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+this.activeObj.activePoint.width,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+this.activeObj.activePoint.height):this.setCenterPoints(),this.currObjType.isDragging=this.currObjType.isCustomCrop=!1,this.activeObj.shapeDegree=this.degree,this.activeObj.flipObjColl=[],this.drawObject("duplicate"),this.refreshToolbar("shapes")}}},h.prototype.drawShapeText=function(t,i,s,a,o,r,n,h){if(!this.disabled&&this.imgDataColl.length>0){"freehanddraw"===this.currObjType.shape&&(this.apply(),this.upperCanvas.style.cursor="default",this.currObjType.shape="");var l=this.calcRatio();this.togglePen=!1,this.redrawActObj(),this.keyHistory="",this.refreshActiveObj();var c={action:"insert",previousShapeSettings:this.activeObj,currentShapeSettings:this.activeObj};this.trigger("shapeChanging",c),this.currObjType.isCustomCrop=!1,this.currObjType.isText=this.currObjType.isInitialText=!0,this.upperCanvas.style.display="block",this.currObjType.shape=this.activeObj.shape="text",e.isNullOrUndefined(this.activeObj.textSettings)&&(this.activeObj.textSettings=this.textSettings),e.isNullOrUndefined(this.activeObj.strokeSettings)&&(this.activeObj.strokeSettings=this.strokeSettings),this.activeObj.strokeSettings.strokeColor=r||this.activeObj.strokeSettings.strokeColor,this.activeObj.textSettings.text=t||this.activeObj.textSettings.text,this.activeObj.textSettings.fontFamily=i||this.activeObj.textSettings.fontFamily,this.activeObj.textSettings.text=t||this.activeObj.textSettings.text,this.activeObj.textSettings.fontFamily=i||this.activeObj.textSettings.fontFamily,this.activeObj.textSettings.fontSize=s||this.activeObj.textSettings.fontSize,this.activeObj.textSettings.bold=a||this.activeObj.textSettings.bold,this.activeObj.textSettings.italic=o||this.activeObj.textSettings.italic,e.isNullOrUndefined(this.activeObj.textSettings.fontSize)&&(this.lowerCanvas.width>this.lowerCanvas.height?this.activeObj.textSettings.fontSize=Math.floor(this.lowerCanvas.width/20):this.activeObj.textSettings.fontSize=Math.floor(this.lowerCanvas.height/20),this.activeObj.textSettings.fontSize<20*(l.width+l.height)&&(this.activeObj.textSettings.fontSize=20*(l.width+l.height))),this.activeObj.shapeDegree=this.degree,this.activeObj.shapeFlip=this.currFlipState,this.activeObj.flipObjColl=[],this.updateFontStyles();var v=this.upperContext.measureText(this.activeObj.textSettings.text).width+.5*this.activeObj.textSettings.fontSize,d=this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize;e.isNullOrUndefined(n)||e.isNullOrUndefined(h)?this.setCenterPoints(!0,v,d):(this.activeObj.activePoint.startX=n,this.activeObj.activePoint.startY=h,this.activeObj.activePoint.endX=this.activeObj.activePoint.startX+v,this.activeObj.activePoint.endY=this.activeObj.activePoint.startY+d),this.addLetter(this.activeObj.textSettings.text),this.refreshToolbar("text")}},h.prototype.drawPen=function(t){var i=this.calcRatio();t=t||this.upperContext,this.upperCanvas.style.display="block",this.canvasRatio=this.calcRatio(),e.isNullOrUndefined(this.activeObj.strokeSettings)&&(this.activeObj.strokeSettings=this.strokeSettings),e.isNullOrUndefined(this.activeObj.strokeSettings.strokeWidth)&&(this.activeObj.strokeSettings.strokeWidth=.4*(i.width+i.height)),t.strokeStyle=this.activeObj.strokeSettings.strokeColor,t.lineWidth=2*this.activeObj.strokeSettings.strokeWidth/this.factor,t.beginPath(),t.moveTo(this.prevX,this.prevY),t.lineTo(this.currX,this.currY),t.stroke(),t.closePath()},h.prototype.getObjDetails=function(t){var e={};return e.id=t.currIndex,e.type=t.shape,e.startX=t.activePoint.startX,e.startY=t.activePoint.startY,"rectangle"===t.shape?(e.width=t.activePoint.width,e.height=t.activePoint.height,e.strokeColor=t.strokeSettings.strokeColor,e.fillColor=t.strokeSettings.fillColor,e.strokeWidth=t.strokeSettings.strokeWidth):"ellipse"===t.shape?(e.radius=t.activePoint.width/2,e.strokeColor=t.strokeSettings.strokeColor,e.fillColor=t.strokeSettings.fillColor,e.strokeWidth=t.strokeSettings.strokeWidth):"line"===t.shape?(e.length=t.activePoint.width,e.strokeColor=t.strokeSettings.strokeColor,e.strokeWidth=t.strokeSettings.strokeWidth):"text"===t.shape&&(e.text=t.keyHistory,e.fontSize=t.textSettings.fontSize,e.color=t.strokeSettings.strokeColor,e.fontStyle=[],t.textSettings.bold&&e.fontStyle.push("bold"),t.textSettings.italic&&e.fontStyle.push("italic")),e},h.prototype.isPointsInRange=function(t,e){var i=!1;if(1===this.factor)t>=0&&e>=0&&t<=this.lowerCanvas.width&&e<=this.lowerCanvas.width&&(i=!0);else{var s={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};t>=this.pannStart.startX&&e>=this.pannStart.startY&&t<=s.x&&e<=s.y&&(i=!0)}return i},h.prototype.clearSelection=function(){!this.disabled&&this.imgDataColl.length>0&&(this.togglePen=!1,this.refreshActiveObj(),this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0,this.currObjType.shape="",this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.currObjType.isActiveObj=!0,this.currObjType.isCustomCrop=!1,this.upperCanvas.style.cursor="default")},h.prototype.crop=function(){var t,i=!1,s={startPoint:{x:this.activeObj.activePoint.startX,y:this.activeObj.activePoint.startY},endPoint:{x:this.activeObj.activePoint.endX,y:this.activeObj.activePoint.endY}};if(this.trigger("cropping",s),void 0!==this.activeObj.shape&&(t=this.activeObj.shape.split("-")),!this.disabled&&void 0!==this.activeObj.horTopLine&&(this.currObjType.isCustomCrop||"crop"===t[0])){var a=this;i=!0,this.upperCanvas.style.display="none";var r=void 0,n=void 0,h=void 0,l=!1;if(1===this.factor)h=this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height),r=this.lowerCanvas.width/parseInt(this.lowerCanvas.style.maxWidth,10),n=this.lowerCanvas.height/parseInt(this.lowerCanvas.style.maxHeight,10);else{if(this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),h=this.imgDataColl[0].value,r=this.lowerCanvas.width/parseInt(this.lowerCanvas.style.maxWidth,10),n=this.lowerCanvas.height/parseInt(this.lowerCanvas.style.maxHeight,10),0!==this.degree&&""!==this.flipState&&(this.degree=0),0!==this.degree){l=!0,this.lowerCanvas.width=this.upperCanvas.width=this.baseImg.width,this.lowerCanvas.height=this.upperCanvas.height=this.baseImg.height;c=e.extend({},this.activeObj,{},!0);this.factor=1,this.lowerContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),this.lowerContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),180===this.degree&&this.updateInMemoryContext(h);v=this.calcMaxDimension(c.activePoint.width,c.activePoint.height);this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=v.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=v.height+"px",this.lowerCanvas.width=this.upperCanvas.width=v.width*r,this.lowerCanvas.height=this.upperCanvas.height=v.height*n,180!==this.degree&&this.updateInMemoryContext(h),this.degree=0,this.lowerContext.drawImage(this.inMemoryCanvas,c.activePoint.startX,c.activePoint.startY,c.activePoint.width,c.activePoint.height,0,0,this.lowerCanvas.width,this.lowerCanvas.height)}if(""!==this.flipState){l=!0;var c=e.extend({},this.activeObj,{},!0);this.flipState="",this.lowerContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),this.lowerContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.updateInMemoryContext(h);v=this.calcMaxDimension(c.activePoint.width,c.activePoint.height);this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=v.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=v.height+"px",this.lowerCanvas.width=this.upperCanvas.width=v.width*r,this.lowerCanvas.height=this.upperCanvas.height=v.height*n,this.lowerContext.drawImage(this.inMemoryCanvas,c.activePoint.startX,c.activePoint.startY,c.activePoint.width,c.activePoint.height,0,0,this.lowerCanvas.width,this.lowerCanvas.height)}}if(!l){this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryCanvas.width=h.width,this.inMemoryCanvas.height=h.height,this.inMemoryContext.putImageData(h,0,0),this.updateInMemoryContext(h);var v=this.calcMaxDimension(this.activeObj.activePoint.width,this.activeObj.activePoint.height);this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth=v.width+"px",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight=v.height+"px",this.lowerCanvas.width=this.upperCanvas.width=v.width*r,this.lowerCanvas.height=this.upperCanvas.height=v.height*n;var d=window.getComputedStyle(this.lowerCanvas);this.lowerCanvas.style.left=this.upperCanvas.style.left=(this.element.clientWidth-parseInt(d.width,10)-18)/2+1+"px",this.lowerCanvas.style.top=this.upperCanvas.style.top=(this.element.clientHeight-this.toolbarHeight-parseInt(d.height,10))/2+1+"px",this.lowerContext.drawImage(this.inMemoryCanvas,this.activeObj.activePoint.startX,this.activeObj.activePoint.startY,this.activeObj.activePoint.width,this.activeObj.activePoint.height,0,0,this.lowerCanvas.width,this.lowerCanvas.height)}if("crop-circle"===this.activeObj.shape){var p=this.lowerContext.getImageData(0,0,this.baseImg.width,this.baseImg.height);this.inMemoryCanvas.width=p.width,this.inMemoryCanvas.height=p.height,this.inMemoryContext.putImageData(p,0,0),this.lowerContext.save(),this.lowerContext.drawImage(this.inMemoryCanvas,0,0,this.baseImg.width,this.baseImg.height),this.lowerContext.globalCompositeOperation="destination-in",this.lowerContext.beginPath(),this.lowerContext.arc(this.lowerCanvas.width/2,this.lowerCanvas.height/2,this.lowerCanvas.width/2,0,2*Math.PI),this.lowerContext.closePath(),this.lowerContext.fill(),this.lowerContext.restore(),this.currObjType.isActiveObj=!0}o.showSpinner(this.element),this.element.style.opacity="0.5";var b,C;this.lowerCanvas.toBlob(function(t){b=URL.createObjectURL(t),a.isUndoRedo=!1,a.baseImg.src=b,C=a.lowerContext.getImageData(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.imgDataColl=[],a.isUndoRedo||a.updateUndoRedoColl("crop",C,a.objColl),a.isUndoRedo=!1},"image/png"),this.objColl=[],this.refreshActiveObj(),this.degree=0,this.flipState="",this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.globalAlpha=0,this.lowerContext.fillRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.factor=1}return i},h.prototype.updateInMemoryContext=function(t){this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var i=e.extend({},this.activeObj,{},!0),s=0;s<this.objColl.length;s++)this.apply(this.objColl[s].shape,this.objColl[s]);this.activeObj=i,t=this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryCanvas.width=t.width,this.inMemoryCanvas.height=t.height,this.inMemoryContext.putImageData(t,0,0)},h.prototype.flip=function(t){if(!this.disabled&&this.imgDataColl.length>0){1!==this.factor&&(this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.factor=1,this.refreshToolbar("main"));var i={direction:t};this.trigger("flipping",i),this.lastAction="flip",this.flipMethod=!0;var s=[],a=void 0;if(e.isNullOrUndefined(this.activeObj.activePoint)||(void 0!==this.activeObj.shape&&(s=this.activeObj.shape.split("-")),(this.currObjType.isCustomCrop||"crop"===s[0])&&(a=this.currObjType.isCustomCrop?"custom":s[1])),this.redrawActObj(),this.lowerContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),"horizontal"===t.toLowerCase()?(this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1),this.flipDirection="horizontal",""!==this.flipState&&"vertical"!==this.flipState.toLowerCase()||(this.flipState="horizontal"),"horizontal"===this.currFlipState.toLowerCase()?this.currFlipState="":this.currFlipState="horizontal"):(this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1),this.flipDirection="vertical",""!==this.flipState.toLowerCase()&&"horizontal"!==this.flipState.toLowerCase()||(this.flipState="vertical"),"vertical"===this.currFlipState.toLowerCase()?this.currFlipState="":this.currFlipState="vertical"),this.lowerContext.drawImage(this.inMemoryCanvas,0,0),this.currImgData=this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryCanvas.width=this.currImgData.width,this.inMemoryCanvas.height=this.currImgData.height,this.inMemoryContext.putImageData(this.currImgData,0,0),"horizontal"===this.flipState.toLowerCase()){for(var o=0,r=this.objColl.length;o<r;o++)this.objColl[o].flippedText=!1,""!==this.objColl[o].shapeFlip&&(this.objColl[o].shapeFlip,this.currFlipState),this.apply(this.objColl[o].shape,this.objColl[o]);this.lowerContext.translate(this.lowerContext.canvas.width,0),this.lowerContext.scale(-1,1),this.upperContext.translate(this.upperContext.canvas.width,0),this.upperContext.scale(-1,1),this.flipDirection=""}else if("vertical"===this.flipState.toLowerCase()){for(var o=0,r=this.objColl.length;o<r;o++)this.objColl[o].flippedText=!1,""!==this.objColl[o].shapeFlip&&(this.objColl[o].shapeFlip,this.currFlipState),this.apply(this.objColl[o].shape,this.objColl[o]);this.lowerContext.translate(0,this.lowerContext.canvas.height),this.lowerContext.scale(1,-1),this.upperContext.translate(0,this.upperContext.canvas.height),this.upperContext.scale(1,-1),this.flipDirection=""}for(var o=0,r=this.objColl.length;o<r;o++)0===this.objColl[o].flipObjColl.length?this.objColl[o].flipObjColl.push(t):this.objColl[o].flipObjColl[this.objColl[o].flipObjColl.length-1]===t?this.objColl[o].flipObjColl.pop():this.objColl[o].flipObjColl.push(t);if(this.redrawObj(t.toLowerCase()),""===this.flipState)for(var o=0,r=this.objColl.length;o<r;o++)this.apply(this.objColl[o].shape,this.objColl[o]);this.refreshActiveObj(),this.isUndoRedo||this.updateUndoRedoColl("flip",t,this.objColl),this.isUndoRedo=this.flipMethod=!1,e.isNullOrUndefined(a)||("custom"===a?(this.activeObj.activePoint={startX:0,startY:0,endX:this.lowerCanvas.width,endY:this.lowerCanvas.height,width:this.lowerCanvas.width,height:this.lowerCanvas.height},this.updateActiveObject(this.calcRatio(),this.activeObj.activePoint,this.activeObj),this.drawObject("duplicate",this.activeObj)):this.select(a))}},h.prototype.getImageData=function(){return this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height)},h.prototype.open=function(t){if(!this.disabled){o.showSpinner(this.element),this.element.style.opacity="0.5";var i=document.querySelector("#"+this.element.id+"_currPos");i&&(i.style.display="none"),0===this.defToolbarItems.length&&e.isNullOrUndefined(document.getElementById(this.element.id+"_toolbar"))&&(this.toolbarHeight=0),this.update(),"string"===typeof t?this.imageOnLoad(t):(this.lowerCanvas=document.querySelector("#"+this.element.id+"_lowerCanvas"),this.upperCanvas=document.querySelector("#"+this.element.id+"_upperCanvas"),this.lowerContext=this.lowerCanvas.getContext("2d"),this.upperContext=this.upperCanvas.getContext("2d"),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.inMemoryCanvas.width=this.baseImg.width=t.width,this.inMemoryCanvas.height=this.baseImg.height=t.height,this.inMemoryContext.putImageData(t,0,0),this.imgDataColl.push({operation:"open",value:t}),this.lowerCanvas.width=this.upperCanvas.width=t.width,this.lowerCanvas.height=this.upperCanvas.height=t.height,this.lowerContext.drawImage(this.inMemoryCanvas,0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.updateCanvas(),o.hideSpinner(this.element),this.element.style.opacity="1")}},h.prototype.reset=function(){this.disabled||(this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.inMemoryContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),this.lowerContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.lowerContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),this.upperContext.clearRect(0,0,this.inMemoryCanvas.width,this.inMemoryCanvas.height),this.upperContext.clearRect(0,0,this.inMemoryCanvas.height,this.inMemoryCanvas.width),o.showSpinner(this.element),this.element.style.opacity="0.5",this.imgDataColl.length>0&&("freehanddraw"===this.imgDataColl[0].operation&&(this.imgDataColl.splice(0,1),this.imgDataColl.splice(1,1)),this.inMemoryCanvas.width=this.imgDataColl[0].value.width,this.inMemoryCanvas.height=this.imgDataColl[0].value.height,this.inMemoryContext.putImageData(this.imgDataColl[0].value,0,0),this.redrawImg()),this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.baseImg.src=this.baseImgSrc,this.factor=1,this.refreshToolbar("main"),e.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&e.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.objColl=[],this.imgDataColl=[],this.degree=0,this.flipState=this.keyHistory=this.currFlipState=this.flipDirection="",this.upperCanvas.style.display="none",this.upperCanvas.style.cursor=this.lowerCanvas.style.cursor="default",this.undoRedoColl=[],this.dragCanvas=this.dragged=this.isUndoRedo=this.activeObj.flippedText=this.flipMethod=!1,this.currImgData={},this.pannStart={startX:0,startY:0,width:0,height:0},this.pannEnd={startX:0,startY:0,width:0,height:0},this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.togglePan=this.togglePen=this.rotateMethod=!1,this.lastX=this.lastY=0,this.dragStart={x:0,y:0},this.touchEndPoint={},this.prevX=this.currX=this.prevY=this.currY=0,this.lastAction=this.tempKeyHistory="",this.isBoldbtn=this.isItalicbtn=!1,this.currentToolbar="main",this.textStartPoints={x:0,y:0},this.fontSizeColl=this.penDrawColl=[],this.textBox.value=this.textBox.textContent="",this.textBox.style.display="none",this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,bold:!1,italic:!1,underline:!1},this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.penStrokeWidth=void 0,this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,bold:!1,italic:!1,underline:!1},this.refreshActiveObj(),this.timer=void 0,this.isScreenOriented=!1,this.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1})},h.prototype.rotate=function(t){var i=!1;if(!this.disabled&&this.imgDataColl.length>0&&t%90==0){i=!0;var s={degree:t};this.trigger("rotating",s),this.rotateMethod=!0,this.lastAction="rotate";var a=[],o=void 0;if(e.isNullOrUndefined(this.activeObj.activePoint)||(void 0!==this.activeObj.shape&&(a=this.activeObj.shape.split("-")),(this.currObjType.isCustomCrop||"crop"===a[0])&&(o=this.currObjType.isCustomCrop?"custom":a[1])),this.redrawActObj(),1!==this.factor&&(this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.factor=1,this.refreshToolbar("main")),this.degree+=t,360===this.degree&&(this.degree=0),this.lowerContext.save(),this.setMaximumDimension(this.degree),this.lowerContext.translate(this.lowerCanvas.width/2,this.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*t),this.lowerCanvas.style.left=this.upperCanvas.style.left=(this.element.clientWidth-parseInt(this.lowerCanvas.style.maxWidth,10)-18)/2+1+"px",this.lowerCanvas.style.top=this.upperCanvas.style.top=(this.element.clientHeight-this.toolbarHeight-parseInt(this.lowerCanvas.style.maxHeight,10))/2+1+"px",this.lowerContext.drawImage(this.inMemoryCanvas,-this.lowerCanvas.height/2,-this.lowerCanvas.width/2),this.lowerContext.rotate(Math.PI/180*-t),this.lowerContext.translate(-this.lowerCanvas.width/2,-this.lowerCanvas.height/2),this.lowerContext.restore(),this.currImgData=this.lowerContext.getImageData(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryCanvas.width=this.currImgData.width,this.inMemoryCanvas.height=this.currImgData.height,this.inMemoryContext.putImageData(this.currImgData,0,0),this.redrawObj(t),!e.isNullOrUndefined(o)){if("custom"===o){var r={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};this.activeObj.activePoint={startX:this.pannStart.startX,startY:this.pannStart.startY,endX:r.x,endY:r.y,width:r.x-this.pannStart.startX,height:r.y-this.pannStart.startY},this.updateActiveObject(this.calcRatio(),this.activeObj.activePoint,this.activeObj),this.drawObject("duplicate",this.activeObj)}else this.select(o);this.refreshToolbar("main",!0,!0)}this.factor=1,this.isUndoRedo||this.updateUndoRedoColl("rotate",t,this.objColl),this.isUndoRedo=!1}return this.rotateMethod=!1,i},h.prototype.export=function(t,e){var i=this;if(!this.disabled&&this.imgDataColl.length>0){if(this.togglePen&&(this.currObjType.isZoomed=!0,this.applyPenDraw()),this.applyActObj(),1!==this.factor){this.lowerContext.setTransform(1,0,0,1,0,0),this.upperContext.setTransform(1,0,0,1,0,0),this.factor=1,this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var s=0;s<this.objColl.length;s++)this.apply(this.objColl[s].shape,this.objColl[s]),this.refreshActiveObj()}t=t||"Png",this.redrawActObj();var a={cancel:!1,fileName:"ImageEditor",fileType:t},o={fileName:"ImageEditor",fileType:t};this.trigger("beforeSave",a,function(s){s.cancel||(e=s.fileName?s.fileName:e,"svg"===t.toLowerCase()?(e=e||"ImageEditor",i.toSVGImg(e)):(t.toLowerCase(),e=e||"ImageEditor",i.toBlobFn(e,t.toLowerCase())),i.trigger("saved",o),i.refreshToolbar("main"))})}},h.prototype.select=function(t,i,s,a,o){if(!this.disabled&&this.imgDataColl.length>0){var r=this.calcRatio(),n=void 0;this.redrawActObj(),this.refreshActiveObj(),this.keyHistory="",this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.upperCanvas.style.display="block";var h="crop-"+t;if("crop-custom"===h.toLowerCase()){if(""===this.currObjType.shape&&(this.currObjType.isCustomCrop=!0,this.upperContext.fillStyle="rgb(0, 0, 0, 0.5)",this.upperContext.fillRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperCanvas.style.cursor="crosshair",e.Browser.isDevice)){var l=7.5*(r.width>r.height?r.width:r.height)/this.factor,c={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};this.activeObj.activePoint={startX:this.pannStart.startX+l,startY:this.pannStart.startY+l,endX:c.x-l,endY:c.y-l},this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,this.updateActiveObject(this.calcRatio(),this.activeObj.activePoint,this.activeObj),this.drawObject("duplicate",this.activeObj),this.upperCanvas.style.cursor="default"}i&&s&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.currObjType.shape=this.activeObj.shape=h.toLowerCase(),this.activeObj.activePoint.startX=i+r.width,this.activeObj.activePoint.startY=s+r.height,this.activeObj.activePoint.endX=this.baseImg.width-2*r.width,this.activeObj.activePoint.endY=this.baseImg.height-2*r.height,this.activeObj.activePoint.width=this.activeObj.activePoint.endX-this.activeObj.activePoint.startX,this.activeObj.activePoint.height=this.activeObj.activePoint.endY-this.activeObj.activePoint.startY,this.drawObject("duplicate"))}else"crop-canvas"===h.toLowerCase()?(this.upperCanvas.style.display="none",this.dragCanvas=!0):(this.currObjType.isCustomCrop=!1,this.currObjType.shape=h.toLowerCase(),a&&o?n={startX:i,startY:s,endX:i+a,endY:s+o,width:a,height:o}:a&&"crop-circle"===h&&(n={startX:i,startY:s,endX:i+a,endY:s+a,width:a,height:a}),this.activeObj.shape=h.toLowerCase(),this.drawObject("duplicate",null,null,!0,n))}},h.prototype.freeHandDraw=function(t){t?(this.togglePen=!0,this.upperCanvas.style.cursor="cross-hair",this.drawPen()):(this.upperCanvas.style.cursor="default",this.applyPenDraw()),this.refreshToolbar("pen")},h.prototype.pan=function(t){!this.disabled&&this.imgDataColl.length>0&&(t?(this.togglePan=!0,this.redrawActObj(),this.dragCanvas=!0,this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="grab"):(this.dragCanvas=this.togglePan=!1,this.refreshActiveObj(),this.lowerCanvas.style.cursor=this.upperCanvas.style.cursor="default"))},h.prototype.zoom=function(t){if(!this.disabled&&this.imgDataColl.length>0){if(1===this.factor&&t<0||this.factor>8&&t>0)return;var i=[],s=void 0;e.isNullOrUndefined(this.activeObj.activePoint)||(void 0!==this.activeObj.shape&&(i=this.activeObj.shape.split("-")),(this.currObjType.isCustomCrop||"crop"===i[0])&&(s=this.currObjType.isCustomCrop?"custom":i[1])),this.redrawActObj(),this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperCanvas.style.cursor="default";var a=void 0;if(a=3.75===t||1===t?.1:-3.75===t?-.1:t,0!==this.degree&&(this.inMemoryContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.inMemoryContext.clearRect(0,0,this.lowerCanvas.height,this.lowerCanvas.width),this.inMemoryCanvas.width=this.currImgData.width,this.inMemoryCanvas.height=this.currImgData.height,this.inMemoryContext.putImageData(this.currImgData,0,0)),.1!==t&&-.1!==t||(this.lastX=this.lowerCanvas.width/2,this.lastY=this.lowerCanvas.height/2),t>0?this.zoomImg(3.75):this.zoomImg(-3.75),this.refreshActiveObj(),!e.isNullOrUndefined(s)){if("custom"===s){var o={x:this.lowerCanvas.width-this.pannEnd.startX,y:this.lowerCanvas.height-this.pannEnd.startY};this.activeObj.activePoint={startX:this.pannStart.startX,startY:this.pannStart.startY,endX:o.x,endY:o.y,width:o.x-this.pannStart.startX,height:o.y-this.pannStart.startY},this.updateActiveObject(this.calcRatio(),this.activeObj.activePoint,this.activeObj),this.drawObject("duplicate",this.activeObj)}else this.select(s);this.refreshToolbar("main",!0,!0)}this.isUndoRedo||this.updateUndoRedoColl("zoom",a,this.objColl),this.isUndoRedo=!1;var r=document.querySelector("#"+this.element.id+"_zoomOut");e.isNullOrUndefined(r)||1!==this.factor?e.isNullOrUndefined(r)||r.classList.remove("e-disabled"):r.classList.add("e-disabled")}},h.prototype.drawEllipse=function(t,e,i,s,a,o,r){var n=!1,h=this.isPointsInRange(t,e);if(!this.disabled&&this.imgDataColl.length>0&&h){n=!0;var l={action:"insert",previousShapeSettings:this.activeObj,currentShapeSettings:this.activeObj};this.trigger("shapeChanging",l),"freehanddraw"===this.currObjType.shape&&(this.apply(),this.upperCanvas.style.cursor="default",this.currObjType.shape=""),this.currObjType.isCustomCrop=!1;var c={x:t,y:e};this.drawShape("circle",a,o,r,c,i,s)}return n},h.prototype.drawLine=function(t,e,i,s,a,o){var r=!1,n=this.isPointsInRange(t,e);if(!this.disabled&&this.imgDataColl.length>0&&n){r=!0;var h={action:"insert",previousShapeSettings:this.activeObj,currentShapeSettings:this.activeObj};this.trigger("shapeChanging",h),"freehanddraw"===this.currObjType.shape&&(this.apply(),this.upperCanvas.style.cursor="default",this.currObjType.shape=""),this.currObjType.isCustomCrop=!1;var l={x:t,y:e},c=i-t,v=s-e;this.drawShape("line",a,o,null,l,c,v)}return r},h.prototype.drawRectangle=function(t,e,i,s,a,o,r){var n=!1,h=this.isPointsInRange(t,e);if(!this.disabled&&this.imgDataColl.length>0&&h){n=!0;var l={action:"insert",previousShapeSettings:this.activeObj,currentShapeSettings:this.activeObj};this.trigger("shapeChanging",l),"freehanddraw"===this.currObjType.shape&&(this.apply(),this.upperCanvas.style.cursor="default",this.currObjType.shape=""),this.currObjType.isCustomCrop=!1;var c={x:t,y:e};this.drawShape("rectangle",a,o,r,c,i,s)}return n},h.prototype.drawText=function(t,e,i,s,a,o,r,n){var h=!1,l=this.isPointsInRange(t,e);return!this.disabled&&this.imgDataColl.length>0&&l&&(h=!0,this.drawShapeText(i,s,a,o,r,n,t,e)),h},h.prototype.selectShape=function(t){this.applyActObj();for(var i,s,a=0;a<this.objColl.length;a++)if(this.objColl[a].currIndex===t){i=e.extend({},this.objColl[a],{},!0);break}return e.isNullOrUndefined(i)?s=!1:(s=!0,this.activeObj=i,this.redrawShape(this.activeObj),this.refreshToolbar("shapes"),this.updateToolbarItems(this.calcRatio())),s},h.prototype.deleteShape=function(t){this.applyActObj();for(e=0;e<this.objColl.length;e++)if(this.objColl[e].currIndex===t){this.objColl.splice(e,1);break}this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.lowerContext.drawImage(this.inMemoryCanvas,0,0);for(var e=0;e<this.objColl.length;e++)this.apply(this.objColl[e].shape,this.objColl[e]),this.refreshActiveObj();this.refreshToolbar("main")},h.prototype.getShapeSetting=function(t){this.applyActObj();for(var i,s=0;s<this.objColl.length;s++)if(this.objColl[s].currIndex===t){i=e.extend({},this.objColl[s],{},!0);break}return this.getObjDetails(i)},h.prototype.getShapeSettings=function(){this.applyActObj();for(var t=[],e=0;e<this.objColl.length;e++){var i=this.getObjDetails(this.objColl[e]);t.push(i)}return t},h.prototype.update=function(){var t=document.querySelector("#"+this.element.id+"_canvasWrapper");t.style.width=this.element.offsetWidth+"px",this.lowerCanvas.width=this.upperCanvas.width=this.element.offsetWidth,e.Browser.isDevice?(t.style.height=this.element.offsetHeight-2*this.toolbarHeight-3+"px",this.lowerCanvas.height=this.upperCanvas.height=this.element.offsetHeight-2*this.toolbarHeight-3):(t.style.height=this.element.offsetHeight-this.toolbarHeight-1+"px",this.lowerCanvas.height=this.upperCanvas.height=this.element.offsetHeight-this.toolbarHeight-1),this.lowerContext.clearRect(0,0,this.lowerCanvas.width,this.lowerCanvas.height),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height)};var l;return n([e.Property("")],h.prototype,"cssClass",void 0),n([e.Property(!1)],h.prototype,"disabled",void 0),n([e.Property("100%")],h.prototype,"height",void 0),n([e.Property("Bootstrap5")],h.prototype,"theme",void 0),n([e.Property()],h.prototype,"toolbar",void 0),n([e.Property()],h.prototype,"toolbarTemplate",void 0),n([e.Property("100%")],h.prototype,"width",void 0),n([e.Event()],h.prototype,"beforeSave",void 0),n([e.Event()],h.prototype,"created",void 0),n([e.Event()],h.prototype,"destroyed",void 0),n([e.Event()],h.prototype,"zooming",void 0),n([e.Event()],h.prototype,"panning",void 0),n([e.Event()],h.prototype,"cropping",void 0),n([e.Event()],h.prototype,"rotating",void 0),n([e.Event()],h.prototype,"flipping",void 0),n([e.Event()],h.prototype,"shapeChanging",void 0),n([e.Event()],h.prototype,"fileOpened",void 0),n([e.Event()],h.prototype,"saved",void 0),n([e.Event()],h.prototype,"toolbarCreated",void 0),n([e.Event()],h.prototype,"toolbarUpdating",void 0),n([e.Event()],h.prototype,"toolbarItemClicked",void 0),h=l=n([e.NotifyPropertyChanges],h)}(i.SignatureBase);return t.ImageEditor=h,t}({},ej.base,ej.inputs,ej.navigations,ej.splitbuttons,ej.popups),this.ejs=ej;
|
|
11
|
+
//# sourceMappingURL=ej2-image-editor.min.js.map
|