@syncfusion/ej2-image-editor 23.1.41 → 23.1.43
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/CHANGELOG.md +8 -0
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +1 -1
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +1 -1
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +10 -10
- package/src/image-editor/renderer/toolbar.js +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: ej2-image-editor.umd.min.js
|
|
3
|
-
* version : 23.1.
|
|
3
|
+
* version : 23.1.43
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
7
|
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
8
8
|
* applicable laws.
|
|
9
9
|
*/
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-popups"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-navigations"),require("@syncfusion/ej2-splitbuttons")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-popups","@syncfusion/ej2-inputs","@syncfusion/ej2-navigations","@syncfusion/ej2-splitbuttons"],t):t(e.ej={},e.ej2Base,e.ej2Popups,e.ej2Inputs,e.ej2Navigations,e.ej2Splitbuttons)}(this,function(e,t,i,o,r,a){"use strict";var n=function(){function e(e){this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.isInitCrop=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("crop",this.cropping,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("crop",this.cropping),this.parent.off("destroyed",this.destroy)},e.prototype.cropping=function(e){switch(this.updateCropPvtVar(),e.prop){case"cropImg":this.cropImg(e.value.isRotateCrop);break;case"cropCircle":this.cropCircle(e.value.context,e.value.isSave,e.value.isFlip);break;case"setCurrSelPoints":this.setCurrSelPoints(e.value.isSetDimension);break;case"updateRotatePan":this.updateRotatePan();break;case"crop":this.crop(e.value.obj);break;case"calcRatio":this.calcRatio(e.value.obj,e.value.dimension);break;case"isObjInImage":this.isObjInImage(e.value.obj,e.value.object);break;case"getCurrFlipState":this.getCurrFlipState(e.value.panObj);break;case"setPreviousCropCurrentObj":this.prevCropCurrObj=e.value.obj;break;case"setCropDestPoints":this.cropDestPoints=e.value.point;break;case"getTempFlipPanPoint":e.value.obj.point=this.tempFlipPanPoint;break;case"setTempFlipPanPoint":t.isNullOrUndefined(e.value.isAdd)?this.tempFlipPanPoint=e.value.point:(this.tempFlipPanPoint.x+=e.value.point.x,this.tempFlipPanPoint.y+=e.value.point.y);break;case"getPreventScaling":e.value.obj.bool=this.isPreventScaling;break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"crop"},e.prototype.updateCropPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},e.prototype.reset=function(){this.prevCropCurrObj=null,this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.isInitCrop=!1},e.prototype.cropImg=function(e){for(var i=this.parent,o=t.isNullOrUndefined(e),r=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio"),a=i.activeObj.activePoint,n=!1,s=0;s<i.rotateFlipColl.length;s++)90!==i.rotateFlipColl[s]&&-90!==i.rotateFlipColl[s]||(n=!0);if(i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),(o||r)&&(this.croppedDegree=i.transform.degree),o&&0!==i.transform.degree||n){this.updateCropObj();var l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),this.rotateCrop()}else if(o&&""!==i.transform.currFlipState){this.updateCropObj();l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),this.flipCrop()}else{i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}});var p=this.calcRatio();if(o||!e){this.updateCropObj(),i.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1});l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),i.currSelectionPoint=t.extend({},i.activeObj,{},!0),this.cropDestPoints={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight}}var h={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:a.width*p.width,height:a.height*p.height,obj:h,isImgShape:null}});var c=h;this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.img.srcLeft=a.startX*p.width-i.img.destLeft*p.width,i.img.srcTop=a.startY*p.height-i.img.destTop*p.height,i.img.srcWidth=a.width*p.width,i.img.srcHeight=a.height*p.height,i.img.destLeft=(i.lowerCanvas.clientWidth-c.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-c.height)/2,i.img.destWidth=c.width,i.img.destHeight=c.height;var d=this.lowerContext.filter;i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none";var v=t.extend({},i.activeObj,{},!0);this.cropObjColl(),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}});s=0;for(var u=i.objColl.length;s<u;s++)this.isObjInImage(i.objColl[s])&&(i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:i.objColl[s].shape,obj:i.objColl[s],canvas:null}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}));i.activeObj=v,this.cropFreehandDrawColl(),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),null!=i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape?this.cropCircle(this.lowerContext):i.isCircleCrop=!1,this.lowerContext.filter=d,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currObjType.isCustomCrop=!1,i.pan(!1),i.transform.defaultZoomFactor=0}},e.prototype.updateCropObj=function(){this.parent.afterCropActions=[];var e={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:e}});var i=e.currObj;this.parent.cropObj=t.extend({},i,{},!0)},e.prototype.rotateCrop=function(){var e=this.parent,i=e.activeObj.shape||"";e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.currSelectionPoint=t.extend({},e.activeObj,{},!0),e.objColl.push(e.activeObj),e.activeObj=t.extend({},e.objColl[e.objColl.length-1],{},!0);var o=t.extend({},e.objColl[e.objColl.length-1],{},!0),r=t.extend({},e.currSelectionPoint,{},!0),a={bool:null};e.notify("transform",{prop:"getPreventSelect",onPropertyChange:!1,value:{obj:a}}),e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:!0}});var n=t.extend([],e.rotateFlipColl,[],!0);this.panToSelRangle(!0),this.resetZoom();var s=t.extend([],e.afterCropActions,[],!0);this.revertTransform("initial",n),o=t.extend({},e.objColl[e.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o}}),e.objColl.pop(),e.transform.degree=0,this.cropImg(!0),this.revertTransform("reverse",n),e.afterCropActions=s,e.currSelectionPoint=r,e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:a.bool}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i&&this.cropCircle(this.lowerContext),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})},e.prototype.revertTransform=function(e,t){var i=this.parent,o={isRotate:!1};if("initial"===e)for(var r=t.length-1;r>=0;r--)switch(t[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(t[r])}})}else{r=0;for(var a=i.objColl.length;r<a;r++)i.objColl[r].shapeFlip="";for(r=0;r<i.freehandCounter;r++)i.pointColl[r].shapeFlip="";for(r=0,a=t.length;r<a;r++)switch(t[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(t[r])}})}}},e.prototype.resetZoom=function(){var e=this.parent;if(e.transform.zoomFactor>0){for(var t=e.transform.zoomFactor,i=e.isUndoRedo,o=0;o<10*t;o++)e.isUndoRedo=!0,e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});e.isUndoRedo=i,e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})}},e.prototype.flipCrop=function(){var e=this.parent;e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),e.panPoint.totalPannedPoint.x+=this.tempFlipPanPoint.x,e.panPoint.totalPannedPoint.y+=this.tempFlipPanPoint.y;var i=e.transform.currFlipState,o={flipColl:null};e.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}});var r=o.flipColl;e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:[]}}),e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj),this.resetZoom(),e.currSelectionPoint=t.extend({},e.objColl[e.objColl.length-1],{},!0),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);var a=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1});for(var n=0,s=e.objColl.length;n<s;n++)e.objColl[n].shapeFlip="";for(n=0;n<e.freehandCounter;n++)e.pointColl[n].shapeFlip="";e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.activeObj=t.extend({},e.objColl[e.objColl.length-1],{},!0),e.objColl.pop(),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.cropImg(!0),e.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),e.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=a,e.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.transform.currFlipState=i,e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:r}}),this.lowerContext.filter="none";for(n=0,s=e.objColl.length;n<s;n++)e.objColl[n].shapeFlip="";for(n=0;n<e.freehandCounter;n++)e.pointColl[n].shapeFlip="";e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=a,(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&this.cropCircle(this.lowerContext),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}}),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),this.tempFlipPanPoint={x:0,y:0}},e.prototype.cropObjColl=function(){var e,t,i,o=this.parent;if(o.objColl.length>0)for(var r=0,a=o.objColl.length;r<a;r++){e=o.objColl[r].activePoint,t=o.activeObj.activePoint,i=o.objColl[r].shape,o.objColl[r].imageRatio={startX:(e.startX-t.startX)/t.width,startY:(e.startY-t.startY)/t.height,endX:(e.endX-t.startX)/t.width,endY:(e.endY-t.startY)/t.height,width:t.width/e.width,height:t.height/e.height};var n=void 0,s=void 0;switch(i){case"text":s=0===(n=0===o.objColl[r].shapeDegree?this.parent.transform.degree:this.parent.transform.degree-o.objColl[r].shapeDegree)||180===Math.abs(n)?e.width:e.height,o.objColl[r].textSettings.fontRatio=s/o.objColl[r].textSettings.fontSize;break;case"line":case"arrow":this.cropPointCollection(r),"arrow"===i&&o.notify("shape",{prop:"updateArrowRatio",onPropertyChange:!1,value:{obj:o.objColl[r]}});break;case"path":this.cropPointCollection(r)}}},e.prototype.cropPointCollection=function(e){var t,i,o,r,a=this.parent,n=a.objColl[e].shape,s=a.activeObj.activePoint;"path"===n?(t=s.startX,i=s.startY,o=s.width,r=s.height):(t=a.img.destLeft,i=a.img.destTop,o=a.img.destWidth,r=a.img.destHeight);for(var l=a.objColl[e],p=0,h=l.pointColl.length;p<h;p++)l.pointColl[p].ratioX=(l.pointColl[p].x-t)/o,l.pointColl[p].ratioY=(l.pointColl[p].y-i)/r},e.prototype.cropFreehandDrawColl=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){e.points=t.extend([],e.pointColl[i].points,[]),e.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var o=e.points.length,r=0;r<o;r++)e.points[r].ratioX=(e.points[r].x-e.activeObj.activePoint.startX)/e.activeObj.activePoint.width,e.points[r].ratioY=(e.points[r].y-e.activeObj.activePoint.startY)/e.activeObj.activePoint.height}e.notify("freehand-draw",{prop:"updateCropPtsForSel",onPropertyChange:!1})},e.prototype.setCurrSelPoints=function(e){var i=this.parent;i.allowDownScale=!1;var o=this.cropDestPoints,r=this.lowerContext.filter;i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImgCanvas.width,i.img.srcHeight=i.baseImgCanvas.height,i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),e&&i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),0===this.croppedDegree&&0===i.transform.degree&&i.currSelectionPoint&&"crop-circle"!==i.currSelectionPoint.shape&&"crop-square"!==i.currSelectionPoint.shape&&(i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height),0===i.transform.degree&&(i.img.destLeft+=i.panPoint.totalPannedInternalPoint.x,i.img.destTop+=i.panPoint.totalPannedInternalPoint.y),i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=r,i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:!0}});var a=t.extend([],i.objColl,null,!0),n=t.extend([],i.pointColl,null,!0);if(i.objColl=[],i.pointColl=[],i.freehandCounter=0,this.panToSelRangle(),i.objColl=a,i.pointColl=n,i.freehandCounter=i.pointColl.length,i.cropObj.activeObj.shape){var s={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.currSelectionPoint&&i.currSelectionPoint.activePoint&&(i.img.destLeft=i.currSelectionPoint.activePoint.startX,i.img.destTop=i.currSelectionPoint.activePoint.startY,i.img.destWidth=i.currSelectionPoint.activePoint.width,i.img.destHeight=i.currSelectionPoint.activePoint.height),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=s.startX,i.img.destTop=s.startY,i.img.destWidth=s.width,i.img.destHeight=s.height,i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),a=t.extend([],i.objColl,null,!0),n=t.extend([],i.pointColl,null,!0),i.objColl=[],i.pointColl=[],i.freehandCounter=0;var l={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}});var p=l.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.cropObj.filter=this.lowerContext.filter;var h=t.extend({},i.currSelectionPoint,null,!0);i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:null}}),i.activeObj=t.extend({},h,null,!0);var c=t.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currSelectionPoint=null,i.isCircleCrop=!1,0!==i.transform.degree&&(i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.panPoint.currentPannedPoint={x:0,y:0}),i.objColl=a,i.pointColl=n,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),0===i.transform.degree&&i.notify("transform",{prop:"drawPannImage",onPropertyChange:!1,value:{point:{x:0,y:0}}}),i.activeObj=c,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),this.isInitCrop||0!==i.transform.degree||""===i.cropObj.currFlipState||0===i.cropObj.cropZoom?this.isInitCrop=!1:(this.isInitCrop=!0,i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"croptransform",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}))}else{var d=this.lowerContext.filter;this.lowerContext.filter="none",i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=d,i.currSelectionPoint=null}},e.prototype.panToSelRangle=function(e){var t=this.parent,i=0!==t.transform.degree?e?-t.cropObj.totalPannedClientPoint.x:t.cropObj.totalPannedClientPoint.x:0,o=0!==t.transform.degree?e?-t.cropObj.totalPannedClientPoint.y:t.cropObj.totalPannedClientPoint.y:0;0!==t.transform.degree&&(t.panPoint.currentPannedPoint={x:i,y:o},t.notify("transform",{prop:"drawPannedImage",value:{xDiff:i,yDiff:o}}),t.panPoint.currentPannedPoint={x:0,y:0})},e.prototype.cropCircle=function(e,i,o){var r=this.parent;o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:r.transform.currFlipState,isReverse:null}});var a=e.filter;e.filter="none",e.globalCompositeOperation="destination-in",e.beginPath();var n=t.isNullOrUndefined(i)?r.img.destLeft+r.img.destWidth/2:e.canvas.width/2,s=t.isNullOrUndefined(i)?r.img.destTop+r.img.destHeight/2:e.canvas.height/2,l=i?e.canvas.width/2:r.img.destWidth/2;e.arc(n,s,l,0,2*Math.PI),e.closePath(),e.fill(),e.restore(),e.globalCompositeOperation="source-over",r.currObjType.isActiveObj=r.isCircleCrop=!0,e.filter=a,o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:r.transform.currFlipState,isReverse:null}})},e.prototype.getCurrCropState=function(e,t){var i=this.parent,o="",r=[],a={flipColl:null};if(i.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:a}}),"initial"===e)if(180===Math.abs(i.transform.degree))o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState;else{for(var n=0,s=i.rotateFlipColl.length;n<s;n++)"number"==typeof i.rotateFlipColl[n]?r.push("number"):"string"==typeof i.rotateFlipColl[n]&&r.push("string");r.length>1&&"string"===r[r.length-1]&&"number"===r[r.length-2]?"horizontal"===i.transform.currFlipState?o="vertical":"vertical"===i.transform.currFlipState&&(o="horizontal"):r.length>1&&"number"===r[r.length-1]&&"string"===r[r.length-2]&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState)}else o=this.getCurrFlipState(),!t&&this.isInitialRotate()||-90!==i.transform.degree&&-270!==i.transform.degree||("horizontal"===o?o="vertical":"vertical"===o&&(o="horizontal"));return""===o&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState),o},e.prototype.isInitialRotate=function(){var e=!1;return this.parent.rotateFlipColl.length>0&&"number"==typeof this.parent.rotateFlipColl[0]&&(e=!0),e},e.prototype.updateRotatePan=function(){var e=this.parent;if(!t.isNullOrUndefined(e.panPoint.currentPannedPoint)){var i="";i=e.rotateFlipColl.length>0&&"number"==typeof e.rotateFlipColl[0]&&e.transform.degree<0?this.getCurrCropState("reverse",!0):this.getCurrFlipState(),e.transform.degree%90==0&&e.transform.degree%180!=0?90===e.transform.degree||-90===e.transform.degree&&("horizontal"===i||"vertical"===i)||-270===e.transform.degree&&(""===i||"verticalHorizontal"===i||"horizontalVertical"===i)?("horizontal"===i||""===i?e.img.destLeft+=e.panPoint.currentPannedPoint.y:e.img.destLeft-=e.panPoint.currentPannedPoint.y,""===i||"vertical"===i?e.img.destTop-=e.panPoint.currentPannedPoint.x:e.img.destTop+=e.panPoint.currentPannedPoint.x):270!==e.transform.degree&&(-270!==e.transform.degree||"horizontal"!==i&&"vertical"!==i)&&(-90!==e.transform.degree||""!==i&&"verticalHorizontal"!==i&&"horizontalVertical"!==i)||(""===i||"horizontal"===i?e.img.destLeft-=e.panPoint.currentPannedPoint.y:e.img.destLeft+=e.panPoint.currentPannedPoint.y,""===i||"vertical"===i?e.img.destTop+=e.panPoint.currentPannedPoint.x:e.img.destTop-=e.panPoint.currentPannedPoint.x):180!==e.transform.degree&&-180!==e.transform.degree||(""===i||"vertical"===i?e.img.destLeft-=e.panPoint.currentPannedPoint.x:e.img.destLeft+=e.panPoint.currentPannedPoint.x,""===i||"horizontal"===i?e.img.destTop-=e.panPoint.currentPannedPoint.y:e.img.destTop+=e.panPoint.currentPannedPoint.y)}},e.prototype.crop=function(e){var i=this,o=this.parent;if(!o.disabled&&o.isImageLoaded){var r={isCropToolbar:o.isCropToolbar};o.currObjType.isUndoAction&&!r.isCropToolbar&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}});var a={cancel:!1,startPoint:{x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY},endPoint:{x:o.activeObj.activePoint.endX,y:o.activeObj.activePoint.endY},preventScaling:!1};!r.isCropToolbar&&t.isBlazor()&&o.events&&!0===o.events.cropping.hasDelegate?"resize-toolbar"==o.currentToolbar?(o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a),this.cropEvent(a,e,r)):o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a).then(function(t){i.cropEvent(t,e,r)}):(r.isCropToolbar||o.trigger("cropping",a),this.cropEvent(a,e,r))}},e.prototype.cropEvent=function(e,i,o){var r,a=this.parent;if(!e.cancel&&(r=a.activeObj.shape?a.activeObj.shape.split("-"):[],!a.disabled&&a.activeObj.horTopLine&&(a.currObjType.isCustomCrop||r.length>0&&"crop"===r[0]))){i.isCrop=!0;var n=t.extend({},a.cropObj,{},!0),s=t.extend({},this.prevCropCurrObj,{},!0);e.preventScaling?this.isPreventScaling=!0:this.isPreventScaling=!1,this.cropImg(),a.transform.zoomFactor=0,a.setProperties({zoomSettings:{zoomFactor:1}},!0),a.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:a.zoomSettings.zoomFactor}});var l={prevCurrSelectionPoint:this.parent.prevCurrSelectionPoint};s.currSelectionPoint=t.extend({},l.prevCurrSelectionPoint,{},!0),a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"crop",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:a.isCircleCrop}}),o.isCropToolbar||a.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),a.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:a.cropObj.destPoints.width,height:a.cropObj.destPoints.height}});var p=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),h=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio");!t.isBlazor()&&!o.isCropToolbar&&t.isNullOrUndefined(p)&&t.isNullOrUndefined(h)?a.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}):o.isCropToolbar||"resize-toolbar"===this.parent.currentToolbar||this.parent.updateToolbar(this.parent.element,"imageLoaded")}},e.prototype.calcRatio=function(e,t){var i,o,r=this.parent;return 0===r.transform.degree||r.transform.degree%180==0?(i=(t?t.width:r.baseImgCanvas.width)/r.img.destWidth,o=(t?t.height:r.baseImgCanvas.height)/r.img.destHeight):(i=(t?t.height:r.baseImgCanvas.height)/r.img.destWidth,o=(t?t.width:r.baseImgCanvas.width)/r.img.destHeight),e&&(e.width=i,e.height=o),{width:i,height:o}},e.prototype.isObjInImage=function(e,t){var i=this.parent,o=!1,r=e.activePoint.startX,a=e.activePoint.endX,n=e.activePoint.startY,s=e.activePoint.endY;return(r>=i.img.destLeft&&a<=i.img.destLeft+i.img.destWidth||r<=i.img.destLeft&&a>=i.img.destLeft||r<=i.img.destLeft+i.img.destWidth&&a>=i.img.destLeft+i.img.destWidth||n>=i.img.destTop&&s<=i.img.destTop+i.img.destHeight||n<=i.img.destTop&&s>=i.img.destTop||n<=i.img.destTop+i.img.destHeight&&s>=i.img.destTop+i.img.destHeight)&&(o=!0),t&&(t.isInside=o),o},e.prototype.getCurrFlipState=function(e){var t=this.parent,i={panRegion:""},o={collection:t.rotateFlipColl};t.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:t.rotateFlipColl,isRotateFlipCollection:!0,obj:o}}),t.rotateFlipColl=o.collection;for(var r=0,a=t.rotateFlipColl.length;r<a;r++)t.notify("transform",{prop:"setCurrPanRegion",onPropertyChange:!1,value:{region:i.panRegion,type:t.rotateFlipColl[r],obj:i}});return e&&(e.panRegion=i.panRegion),i.panRegion},e}(),s=function(){function e(e){this.isInitialLoading=!1,this.fileName="",this.isErrorImage=!1,this.isShapeTextInserted=!1,this.isRotateZoom=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempAdjValue="",this.tempFilter="",this.tempUndoRedoStep=0,this.tempFreehandCounter=0,this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.zoomCrop={width:0,height:0},this.isImageEdited=!1,this.isFileChanged=!1,this.isNewPath=!1,this.isResizeSelect=!1,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}},this.tempFrame="none",this.origDim={width:0,height:0},this.isImageApply=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("draw",this.draw),this.parent.off("destroyed",this.destroy)},e.prototype.draw=function(e){switch(this.updatePrivateVariables(),e.prop){case"drawObject":this.drawObject(e.value.canvas,e.value.obj,e.value.isCropRatio,e.value.points,e.value.isPreventDrag,e.value.saveContext,e.value.isPreventSelection);break;case"updateActiveObject":this.updateActiveObject(e.value.actPoint,e.value.obj,e.value.isMouseMove,e.value.x,e.value.y);break;case"clearOuterCanvas":this.clearOuterCanvas(e.value.context);break;case"setDestPoints":this.setDestPoints();break;case"updateCurrTransState":this.updateCurrTransState(e.value.type,e.value.isPreventDestination,e.value.isRotatePan);break;case"currTransState":this.currTransState(e.value.type,e.value.isPreventDestination,e.value.context,e.value.isPreventCircleCrop);break;case"setTransform":this.setTransform(e.value.context,e.value.value,e.value.isReverse);break;case"render-image":this.renderImage(e.value.isMouseWheel,e.value.isPreventClearRect,e.value.isFrame);break;case"draw-image-to-canvas":this.drawImgToCanvas(e.value.dimension);break;case"update-canvas":this.updateCanvas();break;case"performCancel":this.performCancel(e.value.isContextualToolbar);break;case"updateFlipPan":this.updateFlipPan(e.value.tempSelectionObj);break;case"select":this.select(e.value.type,e.value.startX,e.value.startY,e.value.width,e.value.height);break;case"callUpdateCurrTransState":this.callUpdateCurrTransState();break;case"resetPanPoints":this.resetPanPoints();break;case"setClientTransDim":this.setClientTransDim(e.value.isPreventDimension);break;case"redrawImgWithObj":this.redrawImgWithObj();break;case"setCurrentObj":this.setCurrentObj(e.value.obj);break;case"performPointZoom":this.performPointZoom(e.value.x,e.value.y,e.value.type);break;case"open":this.open(e.value.data);break;case"isInitialLoading":this.isInitialLoading=e.value.isInitialLoading;break;case"isInitialLoaded":this.getInitialLoaded(e.value.object);break;case"fileSelect":this.fileSelect(e.value.inputElement,e.value.args);break;case"getFileName":e.value.obj.fileName=this.fileName,e.value.obj.fileType=this.fileType;break;case"getErrorImage":e.value.obj.isErrorImage=this.isErrorImage;break;case"getInitialZoomValue":e.value.obj.initialZoomValue=this.initZoomValue;break;case"setShapeTextInsert":this.isShapeTextInserted=e.value.bool;break;case"resetCurrentSelectionPoint":this.currSelPoint=null;break;case"setRotateZoom":this.isRotateZoom=e.value.isRotateZoom;break;case"setTempStrokeSettings":this.tempStrokeSettings=e.value.tempStrokeSettings;break;case"setTempTextSettings":this.tempTextSettings=e.value.tempTextSettings;break;case"setTempAdjustmentValue":this.tempAdjValue=e.value.tempAdjustmentValue;break;case"getTempAdjustmentValue":e.value.obj.value=this.tempAdjValue;break;case"setTempFilter":this.tempFilter=e.value.tempFilter;break;case"setTempUndoRedoStep":this.tempUndoRedoStep=e.value.tempUndoRedoStep;break;case"setTempFreehandCounter":this.tempFreehandCounter=e.value.tempFreehandCounter;break;case"setTempCurrentFreehandDrawIndex":this.tempCurrFhdIndex=e.value.tempCurrentFreehandDrawIndex;break;case"setTempZoomFactor":this.tempZoomFactor=e.value.tempZoomFactor;break;case"setCancelAction":this.isCancelAction=e.value.bool;break;case"getRotatedFlipCropSelection":e.value.bool.isSelected=this.rotatedFlipCropSel;break;case"getPrevActObj":e.value.obj.prevActObj=this.prevActObj;break;case"setPrevActObj":this.prevActObj=e.value.prevActObj;break;case"setZoomCropWidth":this.zoomCrop.width=e.value.width,this.zoomCrop.height=e.value.height;break;case"setImageEdited":this.isImageEdited=!0;break;case"reset":this.reset();break;case"dlgBtnClick":this.dlgBtnClick();break;case"dlgCloseBtnClick":this.dlgCloseBtnClick();break;case"setNewPath":this.isNewPath=e.value.bool;break;case"getNewPath":e.value.obj.isNewPath=this.isNewPath;break;case"getArrowDimension":e.value.obj.arrowDimension=this.arrowDimension;break;case"setArrowDimension":this.arrowDimension=e.value.arrowDimension;break;case"moveToSelectionRange":this.moveToSelectionRange(e.value.type,e.value.activeObj);break;case"setResizeSelect":this.isResizeSelect=e.value.bool;break;case"applyFrame":this.applyFrame(e.value.ctx,e.value.frame,e.value.preventImg);break;case"getTempFrame":e.value.obj.tempFrame=this.tempFrame;break;case"drawImage":this.drawImage();break;case"setTempFrame":this.tempFrame=e.value.frame;break;case"downScaleImgCanvas":this.downScaleImgCanvas(e.value.ctx,e.value.isImgAnnotation,e.value.isHFlip,e.value.isVFlip);break;case"downScale":this.downScale(e.value.canvas,e.value.width,e.value.height);break;case"resetFrameZoom":this.resetFrameZoom();break;case"triggerFrameChange":e.value.obj.frameChangeEventArgs=this.triggerFrameChange(e.value.prevFrameSettings);break;case"setImageApply":this.isImageApply=e.value.bool}},e.prototype.getModuleName=function(){return"draw"},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),t.isNullOrUndefined(this.tempZoomFactor)&&(this.tempZoomFactor=e.transform.zoomFactor)},e.prototype.reset=function(){this.isInitialLoading=this.isErrorImage=this.isNewPath=this.isResizeSelect=!1,this.isShapeTextInserted=!1,this.tempFrame="none",this.isImageApply=!1,this.initZoomValue=null,this.tempFilter="",this.origDim={width:0,height:0},this.currSelPoint=null,this.isRotateZoom=!1,this.tempAdjValue="",this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempUndoRedoStep=this.tempFreehandCounter=this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.prevActObj=null,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}}},e.prototype.drawImage=function(){this.applyFrame(this.lowerContext,this.parent.frameObj.type)},e.prototype.drawObject=function(e,i,o,r,a,n,s){var l=this.parent,p=l.activeObj.activePoint;this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height);var h;if("original"===e.toLowerCase()?h=this.lowerContext:"duplicate"===e.toLowerCase()?h=this.upperContext:n&&(h=n),!a&&l.activeObj.shape&&this.setDragLimit(),l.currObjType.shape){"crop"===l.currObjType.shape.split("-")[0].toLowerCase()&&o&&this.drawCropRatio()}if(r&&(p.startX=r.startX,p.startY=r.startY,p.endX=r.endX,p.endY=r.endY,p.width=r.width,p.height=r.height),t.isNullOrUndefined(l.activeObj.strokeSettings)){var c={strokeSettings:{}};l.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:c}}),l.activeObj.strokeSettings=c.strokeSettings}if(t.isNullOrUndefined(l.activeObj.strokeSettings.strokeWidth)&&(l.activeObj.strokeSettings.strokeWidth=2),i&&(l.activeObj=t.extend({},i,{},!0)),this.updateActiveObject(),!t.isNullOrUndefined(l.activeObj.activePoint.startX)||!t.isNullOrUndefined(l.activeObj.activePoint.startY)){if(l.currObjType.isText){var d={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:d}}),l.activeObj.keyHistory=d.keyHistory}if("original"!==e.toLowerCase()){var v=!1;l.activeObj.shape&&"crop"===l.activeObj.shape.split("-")[0]&&(v=!0),v&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,l.lowerCanvas.width,l.lowerCanvas.height),this.upperContext.clearRect(p.startX,p.startY,p.width,p.height)),!t.isNullOrUndefined(s)||h!==this.lowerContext&&h!==this.upperContext||(this.rotateContext("initial",h),this.drawOuterSelection(h),this.rotateContext("reverse",h))}l.currObjType.isActiveObj=!0;var u={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:u}}),i?this.drawShapeObj(e,i.shape,n,s):""!==u.keyHistory&&l.currObjType.isText?this.drawShapeObj(e,"text",n,s):l.activeObj.shape?this.drawShapeObj(e,l.activeObj.shape,n,s):this.drawShapeObj(e,void 0,n,s)}},e.prototype.rotateContext=function(e,i){var o=this.parent,r=t.extend({},o.activeObj.activePoint,{},!0);if("line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape){var a="initial"===e?o.activeObj.rotatedAngle:-o.activeObj.rotatedAngle;i.translate(r.startX+r.width/2,r.startY+r.height/2),i.rotate(a),i.translate(-(r.startX+r.width/2),-(r.startY+r.height/2))}},e.prototype.setDragLimit=function(){var e=this.parent,t=e.activeObj.activePoint;t&&"image"!==e.activeObj.shape&&"line"!==e.activeObj.shape&&0===e.activeObj.rotatedAngle&&(t.startX<e.img.destLeft?(t.startX=e.img.destLeft,t.endX=t.startX+t.width):t.endX>e.img.destLeft+e.img.destWidth&&(t.endX=e.img.destLeft+e.img.destWidth,t.startX=t.endX-t.width),t.startY<e.img.destTop?t.startY=e.img.destTop:t.endY>e.img.destTop+e.img.destHeight&&(t.endY=e.img.destTop+e.img.destHeight,t.startY=t.endY-t.height),e.activeObj=this.updateWidthHeight(e.activeObj))},e.prototype.drawCropRatio=function(){var e,i,o,r,a=this.parent,n=a.activeObj.activePoint;if(a.transform.zoomFactor>0&&this.currSelPoint){var s=t.extend({},a.activeObj,{},!0);this.drawCustomSelection("crop-custom",null,null,null,null),a.transform.degree%90==0&&a.transform.degree%180!=0?r=o=a.activeObj.activePoint.width<a.activeObj.activePoint.height?a.activeObj.activePoint.width:a.activeObj.activePoint.height:(o=a.img.destLeft+a.img.destLeft+a.img.destWidth<=a.lowerCanvas.clientWidth?n.width:a.lowerCanvas.clientWidth-a.img.destLeft,r=a.img.destTop+a.img.destTop+a.img.destHeight<=a.lowerCanvas.clientHeight?n.height:a.lowerCanvas.clientHeight-a.img.destTop),a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a.activeObj=s,a.currObjType.shape=s.shape,this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.currObjType.isCustomCrop=!1}else o=a.img.destWidth,r=a.img.destHeight,a.img.destLeft<0&&(o+=a.img.destLeft),a.img.destTop<0&&(r+=a.img.destTop),"crop-square"!==a.currObjType.shape.toLowerCase()&&"crop-circle"!==a.currObjType.shape.toLowerCase()&&(a.img.destLeft+a.img.destWidth>a.lowerCanvas.width&&(o-=a.img.destLeft+a.img.destWidth-a.lowerCanvas.width),a.img.destTop+a.img.destHeight>a.lowerCanvas.height&&(r-=a.img.destTop+a.img.destHeight-a.lowerCanvas.height));switch(a.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":a.notify("selection",{prop:"setDragDirection",onPropertyChange:!1,value:{width:o,height:r}}),n=a.activeObj.activePoint,a.lowerCanvas.width<n.endX-n.startX&&(n.startX=7.5,n.endX=a.lowerCanvas.width-7.5),a.lowerCanvas.height<n.endY-n.startY&&(n.startY=7.5,n.endY=a.lowerCanvas.height-7.5),o===a.img.destWidth&&r===a.img.destHeight&&(n.startX+=a.img.destLeft,n.startY+=a.img.destTop,n.endX+=a.img.destLeft,n.endY+=a.img.destTop),a.lowerCanvas.width>a.lowerCanvas.height?(n.height=n.endY-n.startY,n.width=n.height,n.endX=n.startX+n.width):(n.width=n.endX-n.startX,n.height=n.width,n.endY=n.startY+n.height);break;case"crop-3:2":e=3,i=2;break;case"crop-4:3":e=4,i=3;break;case"crop-5:4":e=5,i=4;break;case"crop-7:5":e=7,i=5;break;case"crop-16:9":e=16,i=9}if(void 0!==e&&void 0!==i&&(a.notify("selection",{prop:"calcShapeRatio",onPropertyChange:!1,value:{x:e,y:i,imgWidth:o,imgHeight:r}}),o===a.img.destWidth&&r===a.img.destHeight&&this.updatePoints(),n=a.activeObj.activePoint),n.startX<a.img.destLeft){var l=a.img.destLeft-n.startX+7.5;n.startX+=l,n.endX+=l}if(n.startY<a.img.destTop){l=a.img.destTop-n.startY+7.5;n.startY+=l,n.endY+=l}a.activeObj=this.updateWidthHeight(a.activeObj),this.adjToCenter()},e.prototype.adjToCenter=function(){var e=this.parent,t=e.lowerCanvas.width/2-(e.activeObj.activePoint.endX-e.activeObj.activePoint.width/2),i=e.lowerCanvas.height/2-(e.activeObj.activePoint.endY-e.activeObj.activePoint.height/2);if(e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,e.activeObj.activePoint.startY+=i,e.activeObj.activePoint.endY+=i,e.activeObj.activePoint.startX<(e.img.destLeft>=7.5?e.img.destLeft:7.5)){var o=(e.img.destLeft>=7.5?e.img.destLeft:0)-e.activeObj.activePoint.startX;e.activeObj.activePoint.startX+=o,e.activeObj.activePoint.endX+=o}else if(e.activeObj.activePoint.endX>e.img.destLeft+e.img.destWidth){o=e.activeObj.activePoint.endX-(e.img.destLeft+e.img.destWidth);e.activeObj.activePoint.startX-=o,e.activeObj.activePoint.endX-=o}if(e.activeObj.activePoint.startY<(e.img.destTop>=7.5?e.img.destTop:7.5)){o=(e.img.destTop>=7.5?e.img.destTop:0)-e.activeObj.activePoint.startY;e.activeObj.activePoint.startY+=o,e.activeObj.activePoint.endY+=o}else if(e.activeObj.activePoint.endY>e.img.destTop+e.img.destHeight){o=e.activeObj.activePoint.endY-(e.img.destTop+e.img.destHeight);e.activeObj.activePoint.startY-=o,e.activeObj.activePoint.endY-=o}},e.prototype.updateActiveObject=function(e,i,o,r,a){e=e||t.extend({},this.parent.activeObj.activePoint,{},!0),i=i||t.extend({},this.parent.activeObj,{},!0),e.width=e.endX-e.startX,e.height=e.endY-e.startY,r=r||0,a=a||0;var n=e.width/2,s=e.height/2;i.horTopLine={startX:e.startX+r,startY:e.startY-a,endX:e.endX+r,endY:e.endY+a},i.horBottomLine={startX:e.startX-r,startY:e.endY-a,endX:e.endX-r,endY:e.endY+a},i.verLeftLine={startX:e.startX+r,startY:e.startY-a,endX:e.startX-a,endY:e.endY-a},i.verRightLine={startX:e.endX+r,startY:e.startY+a,endX:e.endX-r,endY:e.endY+a},i.topLeftCircle={startX:e.startX,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.topCenterCircle={startX:e.startX+n,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.topRightCircle={startX:e.endX,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.centerLeftCircle={startX:e.startX,startY:e.startY+s,radius:i.horTopLine.endX?7.5:0},i.centerRightCircle={startX:e.endX,startY:e.startY+s,radius:i.horTopLine.endX?7.5:0},i.bottomLeftCircle={startX:e.startX,startY:e.endY,radius:i.horTopLine.endX?7.5:0},i.bottomCenterCircle={startX:e.startX+n,startY:e.endY,radius:i.horTopLine.endX?7.5:0},i.bottomRightCircle={startX:e.endX,startY:e.endY,radius:i.horTopLine.endX?7.5:0},0===i.rotatedAngle&&(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+25},i.rotationCirclePoint.ratioX=(i.rotationCirclePoint.x-this.parent.img.destLeft)/this.parent.img.destWidth,i.rotationCirclePoint.ratioY=(i.rotationCirclePoint.y-this.parent.img.destTop)/this.parent.img.destHeight),i.activePoint=e,t.isNullOrUndefined(o)&&(this.parent.activeObj=t.extend({},i,{},!0))},e.prototype.drawOuterSelection=function(e,i){var o,r=this.parent,a=r.activeObj.activePoint;e.lineWidth=.5,void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-"));var n=t.extend({},r.activeObj,{},!0);void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),(void 0===o||"crop"!==o[0])&&void 0!==r.activeObj.shape||i||(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.upperContext.clearRect(a.startX,a.startY,a.width,a.height)),e.strokeStyle=r.themeColl[r.theme].primaryColor,e.fillStyle=r.themeColl[r.theme].secondaryColor;var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),"arrow"===r.activeObj.shape||"line"===r.activeObj.shape)e.beginPath(),e.moveTo(a.startX,a.startY),e.lineTo(a.endX,a.endY),e.stroke();else if("path"===r.activeObj.shape){e.beginPath();var l=t.extend({},r.activeObj,{},!0);if(e.moveTo(l.pointColl[0].x,l.pointColl[0].y),l.pointColl.length>1)for(var p=1,h=l.pointColl.length;p<h;p++)a.endX=l.pointColl[p].x,a.endY=l.pointColl[p].y,e.lineTo(a.endX,a.endY);var c={shape:null};r.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:c}}),"path"===c.shape&&(r.activeObj=l),e.lineTo(a.endX,a.endY),e.stroke()}else if(e.beginPath(),e.rect(n.activePoint.startX,n.activePoint.startY,n.activePoint.width,n.activePoint.height),e.stroke(),e.closePath(),r.selectionSettings.showCircle){var d=e.strokeStyle,v=e.fillStyle;e.strokeStyle=r.selectionSettings.strokeColor,e.fillStyle=r.selectionSettings.fillColor,e.lineWidth*=2,e.beginPath(),e.moveTo(n.topLeftCircle.startX,n.topLeftCircle.startY),e.arc(n.topLeftCircle.startX,n.topLeftCircle.startY,n.topLeftCircle.radius,0,2*Math.PI),e.moveTo(n.topRightCircle.startX,n.topRightCircle.startY),e.arc(n.topRightCircle.startX,n.topRightCircle.startY,n.topRightCircle.radius,0,2*Math.PI),e.moveTo(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY),e.arc(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY,n.bottomLeftCircle.radius,0,2*Math.PI),e.moveTo(n.bottomRightCircle.startX,n.bottomRightCircle.startY),e.arc(n.bottomRightCircle.startX,n.bottomRightCircle.startY,n.bottomRightCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),e.lineWidth/=2,e.strokeStyle=d,e.fillStyle=v}if(r.selectionSettings.showCircle&&(void 0===o||"crop"!==o[0])){d=e.strokeStyle,v=e.fillStyle;e.strokeStyle=r.selectionSettings.strokeColor,e.fillStyle=r.selectionSettings.fillColor,"text"===r.activeObj.shape||this.drawCenterCircles(e),e.strokeStyle=d,e.fillStyle=v}n.rotationCircleLine=r.activeObj.rotationCircleLine,r.activeObj=t.extend({},n,{},!0)},e.prototype.drawArrowHead=function(e,t){switch(t?this.parent.activeObj.start:this.parent.activeObj.end){case"arrowSolid":t?this.arrowSolid(e,!0):this.arrowSolid(e,!1);break;case"arrow":t?this.arrow(e,!0):this.arrow(e,!1);break;case"circleSolid":t?this.arrowCircleSolid(e,!0):this.arrowCircleSolid(e,!1);break;case"circle":t?this.arrowCircle(e,!0):this.arrowCircle(e,!1);break;case"bar":t?this.arrowBar(e,!0):this.arrowBar(e,!1);break;case"square":case"squareSolid":t?this.arrowSquareStart(e):this.arrowSquareEnd(e)}},e.prototype.drawShapeObj=function(e,i,o,r){var a=this.parent,n=a.activeObj.activePoint,s=void 0!==i?i:a.currObjType.shape;a.currObjType.shape=s;var l;"original"===e.toLowerCase()?l=this.lowerContext:"duplicate"===e.toLowerCase()?l=this.upperContext:o&&(l=o),"rectangle"!==a.currObjType.shape.toLowerCase()&&"ellipse"!==a.currObjType.shape.toLowerCase()&&"line"!==a.currObjType.shape.toLowerCase()&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&"image"!==a.activeObj.shape||(a.activeObj.shape=a.currObjType.shape),l.strokeStyle=a.activeObj.strokeSettings.strokeColor,l.fillStyle="text"===i||"freehanddraw"===i?a.activeObj.strokeSettings.strokeColor:a.activeObj.strokeSettings.fillColor;var p=n.width/3,h=n.height/3,c=n.endX-n.startX,d=n.endY-n.startY;this.rotateContext("initial",l);var v,u,g=l.fillStyle;switch(a.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(l),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"ellipse":c=Math.abs(c),d=Math.abs(d),l.beginPath(),l.ellipse(n.startX+c/2,n.startY+d/2,c/2,d/2,0,0,2*Math.PI,!1),""!==a.activeObj.strokeSettings.fillColor&&(l.fillStyle=a.activeObj.strokeSettings.fillColor,l.fill()),l.ellipse(n.startX+c/2,n.startY+d/2,Math.abs(c/2-a.activeObj.strokeSettings.strokeWidth),Math.abs(d/2-a.activeObj.strokeSettings.strokeWidth),0,0,2*Math.PI,!1),l.fillStyle=a.activeObj.strokeSettings.strokeColor,l.fill("evenodd"),l.closePath(),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"crop-circle":l===this.lowerContext&&(l=this.upperContext),this.shapeCircle(l,c,d);break;case"line":this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"arrow":(v=0===a.activeObj.shapeDegree?a.transform.degree:a.transform.degree-a.activeObj.shapeDegree)<0&&(v=360+v),l.fillStyle=l.strokeStyle,t.isNullOrUndefined(a.activeObj.triangleDirection)&&(a.activeObj.triangleDirection="right"),t.isNullOrUndefined(a.activeObj.start)&&(a.activeObj.start="none"),t.isNullOrUndefined(a.activeObj.end)&&(a.activeObj.end="arrowSolid"),this.drawArrowHead(l,!0),this.drawArrowHead(l,!1),"none"===a.activeObj.end&&this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),l.fillStyle=g,t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"path":if((u=t.extend({},a.activeObj,{},!0)).pointColl.length>1){var b={shape:null};if(a.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:b}}),"path"===b.shape)for(var f={x:0,y:0},m=0,C=u.pointColl.length;m<C;m++)t.isNullOrUndefined(u.pointColl[m+1])?(f.x=u.activePoint.endX,f.y=u.activePoint.endY):(f.x=u.pointColl[m+1].x,f.y=u.pointColl[m+1].y),n.startX=u.pointColl[m].x,n.startY=u.pointColl[m].y,n.endX=f.x,n.endY=f.y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);else for(m=1,C=u.pointColl.length;m<C;m++)n.startX=u.pointColl[m-1].x,n.startY=u.pointColl[m-1].y,n.endX=u.pointColl[m].x,n.endY=u.pointColl[m].y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);a.activeObj=u}else this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);l===this.upperContext&&this.drawOuterSelection(l);break;case"text":this.shapeText(l);break;case"image":this.shapeImage(l),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);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":l===this.lowerContext&&(l=this.upperContext),this.drawSelection(p,h),a.currObjType.shape="";break;default:this.drawSelection(p,h)}this.rotateContext("reverse",l)},e.prototype.updatePoints=function(){var e=this.parent;e.activeObj.activePoint.startX+=e.img.destLeft,e.activeObj.activePoint.startY+=e.img.destTop,e.activeObj.activePoint.endX+=e.img.destLeft,e.activeObj.activePoint.endY+=e.img.destTop,e.activeObj=this.updateWidthHeight(e.activeObj)},e.prototype.updateWidthHeight=function(e){return e.activePoint.width=e.activePoint.endX-e.activePoint.startX,e.activePoint.height=e.activePoint.endY-e.activePoint.startY,e},e.prototype.drawCenterCircles=function(e){var i=this.parent,o=i.activeObj.activePoint;if(e.lineWidth*=2,e.beginPath(),"arrow"===i.activeObj.shape||"line"===i.activeObj.shape)e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);else if("path"===i.activeObj.shape){var r=t.extend({},i.activeObj,{},!0);if(r.pointColl.length>1)for(var a=1,n=r.pointColl.length;a<n;a++)o.startX=r.pointColl[a-1].x,o.startY=r.pointColl[a-1].y,o.endX=r.pointColl[a].x,o.endY=r.pointColl[a].y,e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape&&(i.activeObj=r),e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI)}else this.drawRotationArcLine(e),e.lineTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y);e.stroke(),e.fill(),e.closePath(),"arrow"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&(e.beginPath(),e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y),e.arc(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath()),e.lineWidth/=2},e.prototype.drawRotationArcLine=function(e){var i=this.parent;t.isNullOrUndefined(i.activeObj.rotationCircleLine)&&(i.activeObj.rotationCircleLine=22.5);var o,r=!1,a=!1;if((o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o),i.activeObj.flipObjColl)for(var n=0,s=i.activeObj.flipObjColl.length;n<s;n++)"horizontal"===i.activeObj.flipObjColl[n].toLowerCase()?r=!0:"vertical"===i.activeObj.flipObjColl[n].toLowerCase()&&(a=!0);switch(o){case 0:case 360:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine));break;case 90:case-270:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y));break;case 180:case-180:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine));break;case 270:case-90:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y))}},e.prototype.drawSquareLines=function(e){var t,i=this.parent,o=i.activeObj.activePoint;void 0!==i.activeObj.shape&&(t=i.activeObj.shape.split("-")),"crop"===t[0]?e.strokeStyle="#fff":e.strokeStyle=i.activeObj.strokeSettings.strokeColor,e.beginPath(),e.rect(o.startX,o.startY,o.width,o.height),""!==i.activeObj.strokeSettings.fillColor&&(e.fillStyle=i.activeObj.strokeSettings.fillColor,e.fill()),e.rect(o.startX+i.activeObj.strokeSettings.strokeWidth,o.startY+i.activeObj.strokeSettings.strokeWidth,o.width-2*i.activeObj.strokeSettings.strokeWidth,o.height-2*i.activeObj.strokeSettings.strokeWidth),e.fillStyle=i.activeObj.strokeSettings.strokeColor,e.fill("evenodd"),e.closePath()},e.prototype.drawSelection=function(e,t){var i=this.parent,o=i.activeObj.activePoint;this.upperContext.strokeStyle=i.themeColl[i.theme].primaryColor,this.upperContext.beginPath(),i.activeObj.horTopInnerLine={startX:o.startX,startY:o.startY+t,endX:o.endX,endY:o.endY+t},i.activeObj.horBottomInnerLine={startX:o.startX,startY:o.startY+2*t,endX:o.endX,endY:o.endY+2*t},i.activeObj.verLeftInnerLine={startX:o.startX+e,startY:o.startY,endX:o.startX+e,endY:o.endY},i.activeObj.verRightInnerLine={startX:o.startX+2*e,startY:o.startY,endX:o.startX+2*e,endY:o.endY},this.upperContext.moveTo(i.activeObj.horTopInnerLine.startX,i.activeObj.horTopInnerLine.startY),this.upperContext.lineTo(i.activeObj.horTopInnerLine.endX,i.activeObj.horTopInnerLine.startY),this.upperContext.moveTo(i.activeObj.horBottomInnerLine.startX,i.activeObj.horBottomInnerLine.startY),this.upperContext.lineTo(i.activeObj.horBottomInnerLine.endX,i.activeObj.horBottomInnerLine.startY),this.upperContext.moveTo(i.activeObj.verLeftInnerLine.startX,i.activeObj.verLeftInnerLine.startY),this.upperContext.lineTo(i.activeObj.verLeftInnerLine.endX,i.activeObj.verLeftInnerLine.endY),this.upperContext.moveTo(i.activeObj.verRightInnerLine.startX,i.activeObj.verRightInnerLine.startY),this.upperContext.lineTo(i.activeObj.verRightInnerLine.endX,i.activeObj.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},e.prototype.shapeCircle=function(e,t,i){var o=this.parent,r=o.activeObj.activePoint;e.strokeStyle=o.themeColl[o.theme].primaryColor,e.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),e.fillStyle="rgb(0, 0, 0, 0.25)",e.fillRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var a=e.lineWidth;e.lineWidth=2,e.beginPath(),e.ellipse(o.activeObj.horTopLine.startX+t/2,o.activeObj.horTopLine.startY+i/2,t/2,i/2,0,0,2*Math.PI,!1),e.stroke(),e.closePath(),e.save(),e.beginPath(),e.arc((r.endX-r.startX)/2+r.startX,(r.endY-r.startY)/2+r.startY,r.width/2,0,2*Math.PI),e.closePath(),e.clip(),e.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),e.restore(),e.lineWidth=a,this.drawOuterSelection(e,!0),o.currObjType.shape=""},e.prototype.shapeLine=function(e,t,i,o,r){var a=e.lineWidth;e.lineWidth=this.parent.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.moveTo(t,i),e.lineTo(o,r),e.stroke(),e.lineWidth=a},e.prototype.manipulateSaveCtx=function(e,t,i){if(e!==this.lowerContext&&e!==this.upperContext){var o={width:0,height:0};this.parent.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:o,dimension:{width:e.canvas.width,height:e.canvas.height}}});t&&(t*=o.width),i&&(i*=o.height)}return{x:t,y:i}},e.prototype.arrow=function(e,t){var i=this.parent,o=i.activeObj.activePoint;e.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.arrow.width,a=this.arrowDimension.arrow.height,n=this.manipulateSaveCtx(e,r,a);r=n.x+i.activeObj.strokeSettings.strokeWidth,a=n.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.fillStyle=i.activeObj.strokeSettings.strokeColor;var s=Math.atan2(this.dy,this.dx);(t&&("left"===i.activeObj.triangleDirection||"right"===i.activeObj.triangleDirection)&&"arrow"===i.activeObj.start&&"none"===i.activeObj.end||"arrow"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("arrow"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY),t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection?(e.translate(o.endX,o.endY),e.rotate(s),this.shapeLine(e,0,0,-r,a/2),this.shapeLine(e,0,0,-r,-a/2),e.rotate(-s),e.translate(-o.endX,-o.endY)):(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection)&&(e.translate(o.startX,o.startY),e.rotate(s),this.shapeLine(e,0,0,r,a/2),this.shapeLine(e,0,0,r,-a/2),e.rotate(-s),e.translate(-o.startX,-o.startY))},e.prototype.arrowSolid=function(e,t){var i=this.parent,o=i.activeObj.activePoint,r=this.arrowDimension.arrowSolid.width,a=this.arrowDimension.arrowSolid.height,n=this.manipulateSaveCtx(e,r,a);r=n.x+i.activeObj.strokeSettings.strokeWidth,a=n.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var s=Math.atan2(this.dy,this.dx);(t&&"arrowSolid"===i.activeObj.start&&"none"===i.activeObj.end||"arrowSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("arrowSolid"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY),t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection?(e.translate(o.endX,o.endY),e.rotate(s),e.beginPath(),e.moveTo(i.activeObj.strokeSettings.strokeWidth,0),e.lineTo(a/2-r,a/2),e.lineTo(a/2-r,-a/2),e.closePath(),e.fill(),e.rotate(-s),e.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=s):(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection)&&(e.translate(o.startX,o.startY),e.rotate(s),e.beginPath(),e.moveTo(0-i.activeObj.strokeSettings.strokeWidth,0),e.lineTo(r-a/2,a/2),e.lineTo(r-a/2,-a/2),e.closePath(),e.fill(),e.rotate(-s),e.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=s)},e.prototype.arrowSquareStart=function(e){var t=this.parent,i=t.activeObj.activePoint;("square"===t.activeObj.start&&"none"===t.activeObj.end||"square"===t.activeObj.start&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.start||"squareSolid"===t.activeObj.start&&"circleSolid"===t.activeObj.end)&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.lineWidth=t.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=t.activeObj.strokeSettings.strokeColor;var o=this.arrowDimension.square.width,r=this.arrowDimension.square.height,a=this.manipulateSaveCtx(e,o,r);o=a.x+t.activeObj.strokeSettings.strokeWidth,r=a.y+t.activeObj.strokeSettings.strokeWidth,this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var n=Math.atan2(this.dy,this.dx);"left"===t.activeObj.triangleDirection?(e.translate(i.endX,i.endY),e.rotate(n),"squareSolid"===t.activeObj.start&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.endX,-i.endY),this.squareStartIntersectX1=i.endX-r/2*Math.cos(n),this.squareStartIntersectY1=i.endY-r/2*Math.sin(n),"square"===t.activeObj.start&&"square"!==t.activeObj.end&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===t.activeObj.start&&"circle"===t.activeObj.end&&this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1),"squareSolid"===t.activeObj.start&&"squareSolid"===t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY)):"right"===t.activeObj.triangleDirection&&(e.lineWidth=t.activeObj.strokeSettings.strokeWidth,e.fillStyle=t.activeObj.strokeSettings.strokeColor,"squareSolid"===t.activeObj.start&&"squareSolid"===t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.translate(i.startX,i.startY),e.rotate(n),"squareSolid"===t.activeObj.start&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.startX,-i.startY),t.activeObj.rotatedAngle=n,this.squareStartIntersectX1=i.startX+r/2*Math.cos(n),this.squareStartIntersectY1=i.startY+r/2*Math.sin(n),"square"===t.activeObj.start&&"square"!==t.activeObj.end&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.end&&this.shapeLine(e,i.endX,i.endY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===t.activeObj.start&&"circle"===t.activeObj.end&&this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},e.prototype.arrowSquareEnd=function(e){var t=this.parent,i=t.activeObj.activePoint,o=this.arrowDimension.square.width,r=this.arrowDimension.square.height,a=this.manipulateSaveCtx(e,o,r);o=a.x+t.activeObj.strokeSettings.strokeWidth,r=a.y+t.activeObj.strokeSettings.strokeWidth,this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var n=Math.atan2(this.dy,this.dx);e.lineWidth=t.activeObj.strokeSettings.strokeWidth,"right"===t.activeObj.triangleDirection?(e.fillStyle=t.activeObj.strokeSettings.strokeColor,"squareSolid"===t.activeObj.end&&"none"===t.activeObj.start&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.translate(i.endX,i.endY),e.rotate(n),"squareSolid"===t.activeObj.end&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.endX,-i.endY),t.activeObj.rotatedAngle=n,this.squareEndIntersectX1=i.endX-r/2*Math.cos(n),this.squareEndIntersectY1=i.endY-r/2*Math.sin(n),"square"===t.activeObj.end&&"square"!==t.activeObj.start&&"circle"!==t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,i.startX,i.startY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.activeObj.start&&"square"===t.activeObj.end&&this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1)):"left"===t.activeObj.triangleDirection&&(e.translate(i.startX,i.startY),e.rotate(n),"squareSolid"===t.activeObj.end&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.startX,-i.startY),t.activeObj.rotatedAngle=n,this.squareEndIntersectX1=i.startX+r/2*Math.cos(n),this.squareEndIntersectY1=i.startY+r/2*Math.sin(n),"square"===t.activeObj.end&&"square"!==t.activeObj.start&&"circle"!==t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,i.endX,i.endY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.activeObj.start&&"square"===t.activeObj.end&&this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},e.prototype.arrowCircle=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.arc(o.endX,o.endY,r,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var a=this.dx*this.dx+this.dy*this.dy;if((c=(h=2*(this.dx*(o.startX-o.endX)+this.dy*(o.startY-o.endY)))*h-4*a*((o.startX-o.endX)*(o.startX-o.endX)+(o.startY-o.endY)*(o.startY-o.endY)-r*r))>=0){e.fillStyle=i.activeObj.strokeSettings.strokeColor;var n=(-h-Math.sqrt(c))/(2*a),s=o.startX+this.dx*n,l=o.startY+this.dy*n;t?(this.startCircleIntersectX1=s,this.startCircleIntersectY1=l,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(e,this.startCircleIntersectX1,this.startCircleIntersectY1,this.endCircleIntersectX1,this.endCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(e,o.startX,o.startY,this.startCircleIntersectX1,this.startCircleIntersectY1),e.stroke(),e.closePath()):(this.endCircleIntersectX1=s,this.endCircleIntersectY1=l,"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(e,o.startX,o.startY,this.endCircleIntersectX1,this.endCircleIntersectY1))}var p=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=p}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth;r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.arc(o.startX,o.startY,r,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=o.startX-o.endX,this.dy=o.startY-o.endY;var h,c;a=this.dx*this.dx+this.dy*this.dy;if((c=(h=2*(this.dx*(o.endX-o.startX)+this.dy*(o.endY-o.startY)))*h-4*a*((o.endX-o.startX)*(o.endX-o.startX)+(o.endY-o.startY)*(o.endY-o.startY)-r*r))>=0){e.fillStyle=i.activeObj.strokeSettings.strokeColor;n=(-h-Math.sqrt(c))/(2*a),s=o.endX+this.dx*n,l=o.endY+this.dy*n;t?(this.startCircleIntersectX1=s,this.startCircleIntersectY1=l,"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(e,o.endX,o.endY,this.startCircleIntersectX1,this.startCircleIntersectY1)):(this.endCircleIntersectX1=s,this.endCircleIntersectY1=l,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(e,o.endX,o.endY,this.endCircleIntersectX1,this.endCircleIntersectY1))}p=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=p}},e.prototype.arrowCircleSolid=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.save(),e.beginPath(),e.arc(o.endX,o.endY,r,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.save(),e.beginPath(),e.arc(o.startX,o.startY,r,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}},e.prototype.arrowBar=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("bar"===i.activeObj.end&&"none"===i.activeObj.start||"bar"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width,a=this.arrowDimension.bar.height;r=(s=this.manipulateSaveCtx(e,r,a)).x+i.activeObj.strokeSettings.strokeWidth,a=s.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);e.translate(o.endX,o.endY),e.rotate(n),e.fillRect(a/4-r,-a/2,r,a),e.rotate(-n),e.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"bar"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var s;r=this.arrowDimension.bar.width,a=this.arrowDimension.bar.height;r=(s=this.manipulateSaveCtx(e,r,a)).x+i.activeObj.strokeSettings.strokeWidth,a=s.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;n=Math.atan2(this.dy,this.dx);e.translate(o.startX,o.startY),e.rotate(n),e.fillRect(a/4-r,-a/2,r,a),e.rotate(-n),e.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n}},e.prototype.shapeImage=function(e){var t=this.parent,i=t.activeObj.imageCanvas.getContext("2d");if(e===this.lowerContext&&this.isImageApply){var o={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.activeObj.imageElement.width,height:t.activeObj.imageElement.height,obj:o,isImgShape:null}}),(t.activeObj.activePoint.width<o.width/5||t.activeObj.activePoint.height<o.height/5)&&(i.clearRect(0,0,t.activeObj.imageCanvas.width,t.activeObj.imageCanvas.height),t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:i,isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("selection",{prop:"setImageClarity",onPropertyChange:!1,value:{bool:!1}}),this.isImageApply=!1)}var r={startX:0,startY:0,width:0,height:0};r.width=t.activeObj.activePoint.width,r.height=t.activeObj.activePoint.height,4===t.activeObj.flipObjColl.length&&(t.activeObj.flipObjColl=[],t.activeObj.shapeFlip="");for(var a=0,n=t.activeObj.flipObjColl.length;a<n;a++)"horizontal"===t.activeObj.flipObjColl[a].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),t.activeObj.activePoint=this.updateActPoint("horizontal",e)):"vertical"===t.activeObj.flipObjColl[a].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),t.activeObj.activePoint=this.updateActPoint("vertical",e));r.startX=(t.activeObj.activePoint.width-r.width)/2+t.activeObj.activePoint.startX,r.startY=(t.activeObj.activePoint.height-r.height)/2+t.activeObj.activePoint.startY;var s=e.globalAlpha;e.globalAlpha=t.activeObj.imageTransparency,t.activeObj.shapeDegree!==t.transform.degree?this.rotateImage(e):e.drawImage(t.activeObj.imageCanvas,r.startX,r.startY,r.width,r.height),e.globalAlpha=s;var l=0;for(n=t.activeObj.flipObjColl.length;l<n;l++)"horizontal"===t.activeObj.flipObjColl[l].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),t.activeObj.activePoint=this.updateActPoint("horizontal",e)):"vertical"===t.activeObj.flipObjColl[l].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),t.activeObj.activePoint=this.updateActPoint("vertical",e));t.currObjType.isText=!1},e.prototype.shapeText=function(e){var t=e.filter;e.filter="none";for(var i=this.parent,o=i.activeObj.activePoint,r=i.activeObj.keyHistory.split("\n"),a=((i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize)*r.length-i.activeObj.textSettings.fontSize*r.length)/r.length,n=0;n<r.length;n++){var s=r[n],l=(n+1)*i.activeObj.textSettings.fontSize*.85+n*a;-360===i.transform.degree&&(i.transform.degree=0),0===i.transform.degree||180===i.transform.degree?i.activeObj.textSettings.fontSize>o.height&&(i.activeObj.textSettings.fontSize=o.height-.1*o.height):i.activeObj.textSettings.fontSize>o.width&&(i.activeObj.textSettings.fontSize=o.width-.1*o.width),e.strokeStyle=i.activeObj.strokeSettings.strokeColor,e.fillStyle=i.activeObj.strokeSettings.strokeColor;var p="";i.activeObj.textSettings.bold&&(p="bold "),i.activeObj.textSettings.italic&&(p="italic "),i.activeObj.textSettings.bold&&i.activeObj.textSettings.italic&&(p="italic bold "),e.font=p+i.activeObj.textSettings.fontSize+"px "+i.activeObj.textSettings.fontFamily,4===i.activeObj.flipObjColl.length&&(i.activeObj.flipObjColl=[],i.activeObj.shapeFlip="");for(var h=0,c=i.activeObj.flipObjColl.length;h<c;h++)"horizontal"===i.activeObj.flipObjColl[h].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),o=this.updateActPoint("horizontal",e)):"vertical"===i.activeObj.flipObjColl[h].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),o=this.updateActPoint("vertical",e));i.activeObj.shapeDegree!==i.transform.degree?this.rotateText(e):e.fillText(s,o.startX+.1*i.activeObj.textSettings.fontSize,o.startY+l);var d=0;for(c=i.activeObj.flipObjColl.length;d<c;d++)"horizontal"===i.activeObj.flipObjColl[d].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),o=this.updateActPoint("horizontal",e)):"vertical"===i.activeObj.flipObjColl[d].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),o=this.updateActPoint("vertical",e))}e.filter=t,i.currObjType.isText=!1},e.prototype.updateActPoint=function(e,t){var i=this.parent,o=i.activeObj.activePoint;return"horizontal"===e.toLowerCase()?o.startX<=t.canvas.width/2?(o.startX=t.canvas.width/2+(t.canvas.width/2-o.endX),o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):o.startX>=t.canvas.width/2&&(o.startX=t.canvas.width-o.endX,o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):"vertical"===e.toLowerCase()&&(o.startY<=t.canvas.height/2?(o.startY=t.canvas.height/2+(t.canvas.height/2-o.endY),o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj)):o.startY>=t.canvas.height/2&&(o.startY=t.canvas.height-o.endY,o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj))),o},e.prototype.rotateImage=function(e){var t,i=this.parent;-450===(t=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)&&(t=-90),t<0&&(t=360+t);var o={startX:0,startY:0,width:0,height:0};o.width=t%90==0&&t%180!=0?i.activeObj.activePoint.height:i.activeObj.activePoint.width,o.height=t%90==0&&t%180!=0?i.activeObj.activePoint.width:i.activeObj.activePoint.height,o.startX=i.activeObj.activePoint.startX,o.startY=i.activeObj.activePoint.startY;var r=o.startX,a=o.startY;t%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState?t%90==0&&t%180!=0?(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),e.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),t%90==0&&t%270!=0?(a=i.lowerCanvas.width-(i.activeObj.activePoint.startX+i.activeObj.activePoint.width),a+=(i.activeObj.activePoint.width-o.height)/2,r=o.startY):t%270==0&&(r=i.lowerCanvas.height-(i.activeObj.activePoint.startY+i.activeObj.activePoint.height),r+=(i.activeObj.activePoint.height-o.width)/2,a=o.startX),e.drawImage(i.activeObj.imageCanvas,r,a,o.width,o.height),e.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),r=i.lowerCanvas.width-(o.startX+o.width),a=i.lowerCanvas.height-(o.startY+o.height),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),e.drawImage(i.activeObj.imageCanvas,r,a,o.width,o.height),e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):e.drawImage(i.activeObj.imageCanvas,o.startX,o.startY,o.width,o.height),360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},e.prototype.rotateText=function(e){var t,i=this.parent,o=i.activeObj.activePoint.startX,r=i.activeObj.activePoint.startY,a=i.activeObj.activePoint;if(-450===(t=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)&&(t=-90),t<0&&(t=360+t),t%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState)t%90==0&&t%180!=0?(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),e.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),t%90==0&&t%270!=0?(r=i.lowerCanvas.width-a.endX+.4*i.activeObj.textSettings.fontSize,o=a.startY):t%270==0&&(o=i.lowerCanvas.height-a.endY,r=a.startX+.4*i.activeObj.textSettings.fontSize),this.textFlipDegree(e,o,r),e.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),o=i.lowerCanvas.width-a.endX,r=i.lowerCanvas.height-a.endY+.4*i.activeObj.textSettings.fontSize,e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),this.textFlipDegree(e,o,r),e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2));else{o=a.startX+.15*i.activeObj.textSettings.fontSize,r=a.startY+(a.endY-a.startY);for(var n=i.activeObj.keyHistory.split("\n"),s=0;s<n.length;s++)r=a.startY+(s*i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize),e.fillText(n[s],o,r)}360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},e.prototype.textFlipDegree=function(e,t,i){for(var o=this.parent,r=o.activeObj.keyHistory.split("\n"),a=(o.activeObj.textSettings.fontSize*r.length-o.activeObj.textSettings.fontSize*r.length)/r.length,n=.85*o.activeObj.textSettings.fontSize+a,s=0;s<r.length;s++){var l=r[s];s>0&&(1===s&&(n-=.85*o.activeObj.textSettings.fontSize),n+=o.activeObj.textSettings.fontSize+.15*o.activeObj.textSettings.fontSize),e.fillText(l,t+.15*o.activeObj.textSettings.fontSize,i+n+(s>0?.25*o.activeObj.textSettings.fontSize:.35*-o.activeObj.textSettings.fontSize))}},e.prototype.clearOuterCanvas=function(e){var t=this.parent,i=t.img.destLeft,o=t.img.destTop;if(t.img.destWidth<t.lowerCanvas.width){var r=t.img.destLeft>0?t.img.destLeft:0;e.clearRect(0,0,r,t.lowerCanvas.height),e.clearRect(t.img.destLeft+t.img.destWidth,0,r,t.lowerCanvas.height)}if(t.img.destHeight<t.lowerCanvas.height){var a=t.img.destTop>0?t.img.destTop:0;e.clearRect(0,0,t.lowerCanvas.width,a),e.clearRect(0,t.img.destTop+t.img.destHeight,t.lowerCanvas.width,a)}""!==t.transform.currFlipState&&(t.img.destLeft=i,t.img.destTop=o)},e.prototype.setDestPoints=function(){var e,t=this.parent;if(t.transform.degree%90==0&&t.transform.degree%180!=0){var i={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcHeight,height:t.img.srcWidth,obj:i,isImgShape:null}}),e=i,this.isRotateZoom&&(e.width+=e.width*t.transform.zoomFactor,e.height+=e.height*t.transform.zoomFactor,t.img.destWidth=e.height,t.img.destHeight=e.width),t.img.destLeft=(t.lowerCanvas.clientWidth-e.height)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.width)/2,t.img.destWidth=e.height,t.img.destHeight=e.width}else{i={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:i,isImgShape:null}}),e=i,this.isRotateZoom&&(e.width+=e.width*t.transform.zoomFactor,e.height+=e.height*t.transform.zoomFactor,t.img.destWidth=e.width,t.img.destHeight=e.height),t.img.destLeft=(t.lowerCanvas.clientWidth-e.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.height)/2,t.img.destWidth=e.width,t.img.destHeight=e.height}},e.prototype.updateCurrTransState=function(e,i,o){var r=this.parent,a=r.img.destLeft,n=r.img.destTop;"initial"===e&&(this.lowerContext.setTransform(1,0,0,1,0,0),t.isNullOrUndefined(i)&&this.setDestPoints()),r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape?(this.currTransState(e,!0,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n),o&&(r.img.destLeft+=r.panPoint.totalPannedClientPoint.x,r.img.destTop+=r.panPoint.totalPannedClientPoint.y),r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o&&(r.img.destLeft-=r.panPoint.totalPannedClientPoint.x,r.img.destTop-=r.panPoint.totalPannedClientPoint.y)):(this.currTransState(e,null,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n))},e.prototype.currTransState=function(e,i,o,r){var a=this.parent;o=o||this.lowerContext,"initial"===e?this.setTransformColl(o,e):"reverse"===e&&(this.setTransformColl(o,e),this.setClientTransDim(i),(a.isCircleCrop||a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape&&t.isNullOrUndefined(r))&&(r&&(a.img.destLeft+=a.panPoint.totalPannedClientPoint.x,a.img.destTop+=a.panPoint.totalPannedClientPoint.y),a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r&&(a.img.destLeft-=a.panPoint.totalPannedClientPoint.x,a.img.destTop-=a.panPoint.totalPannedClientPoint.y)))},e.prototype.setTransformColl=function(e,t){var i=this.parent;if("initial"===t)for(var o=0,r=i.rotateFlipColl.length;o<r;o++)this.setTransform(e,i.rotateFlipColl[o]);else if("reverse"===t)for(o=i.rotateFlipColl.length-1;o>=0;o--)this.setTransform(e,i.rotateFlipColl[o],!0)},e.prototype.setTransform=function(e,i,o){var r=this.parent;switch(o&&90===i?i=-90:o&&-90===i&&(i=90),"horizontal"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0?i="vertical":"vertical"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0&&(i="horizontal"),r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),t.isNullOrUndefined(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height),i){case 90:case-90:e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*i),e.translate(-e.canvas.width/2,-e.canvas.height/2);break;case"horizontal":e.translate(e.canvas.width,0),e.scale(-1,1);break;case"vertical":e.translate(0,e.canvas.height),e.scale(1,-1)}r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}})},e.prototype.drawImgToCanvas=function(e){var t=this.parent;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.img.destWidth=e.width,t.img.destHeight=e.height,this.isInitialLoading&&(t.notify("filter",{prop:"initFilter",onPropertyChange:!1}),this.isInitialLoading=!1);var i=this.lowerContext.filter;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.drawImage(),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.lowerContext.filter=i},e.prototype.renderImage=function(e,i,o){var r=this.parent,a=this.lowerContext.filter;r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.isNullOrUndefined(i)&&(this.upperContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.lowerContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height)),e?this.setTransformColl(this.lowerContext,"initial"):(0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),this.updateCurrTransState("initial")),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),e?this.setTransformColl(this.lowerContext,"reverse"):(this.updateCurrTransState("reverse"),this.isRotateZoom=!1),this.lowerContext.filter="none",o?(r.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),r.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):(r.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),r.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})),this.lowerContext.filter=a,this.clearOuterCanvas(this.lowerContext),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.imageOnLoad=function(e){var o=this,r=this.parent,a=this;r.baseImg.src=e,r.baseImg.onload=function(){if(r.notify("filter",{prop:"update-finetunes",onPropertyChange:!1}),a.lowerContext.drawImage(r.baseImg,0,0,a.parent.lowerCanvas.width,a.parent.lowerCanvas.height),i.hideSpinner(r.element),r.element.style.opacity="1",a.updateBaseImgCanvas(),a.updateCanvas(),r.currObjType.isUndoZoom&&(r.currObjType.isUndoZoom=!1,a.parent.lowerCanvas.style.display="block"),r.isUndoRedo=o.isErrorImage=!1,t.isBlazor())r.updateToolbar(r.element,"imageLoaded","initial"),t.Browser.isDevice&&(r.element.querySelector(".e-bottom-toolbar-area").style.display="block",r.element.querySelector(".e-canvas-wrapper").style.height=r.element.offsetHeight-2*r.toolbarHeight-3+"px");else if(t.Browser.isDevice){r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),r.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1});var e={isApplyBtn:!1,isDevice:t.Browser.isDevice,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:e}),r.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})}else{r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1});e={isApplyBtn:!1,isDevice:!1,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:e})}},r.baseImg.onerror=function(){i.hideSpinner(r.element),a.isErrorImage=!0,a.errorLoading()}},e.prototype.errorLoading=function(){var e=this.parent,i={fileName:null,fileType:null,isValidImage:!1};t.isBlazor()&&e.events&&!0===e.events.fileOpened.hasDelegate?e.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):e.trigger("fileOpened",i)},e.prototype.updateBaseImgCanvas=function(){var e=this.parent;e.baseImgCanvas.width=e.baseImg.width,e.baseImgCanvas.height=e.baseImg.height,e.baseImgCanvas.getContext("2d").drawImage(e.baseImg,0,0)},e.prototype.updateCanvas=function(){var e=this.parent,i={fileName:this.fileName,fileType:this.fileType,isValidImage:!0};e.img.srcWidth=e.baseImgCanvas.width,e.img.srcHeight=e.baseImgCanvas.height;var o={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcWidth,height:e.img.srcHeight,obj:o,isImgShape:null}});var r=o;e.img.destLeft=(e.lowerCanvas.clientWidth-r.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-r.height)/2,this.drawImgToCanvas(r),this.origDim.width=e.img.destWidth,this.origDim.height=e.img.destHeight,this.zoomCrop.width=e.img.destWidth,this.zoomCrop.height=e.img.destHeight,e.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:e.img.destWidth,height:e.img.destHeight}});var a={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};e.notify("crop",{prop:"setCropDestPoints",onPropertyChange:!1,value:{point:a}});var n=this.lowerContext.filter;this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n,e.img.destWidth>0&&e.img.destHeight>0&&(e.isImageLoaded=!0),e.isUndoRedo&&""!==e.transform.currFlipState&&e.notify("transform",{prop:"flipImage",onPropertyChange:!1,value:{direction:e.toPascalCase(e.transform.currFlipState)}}),e.disabled&&e.element.setAttribute("class","e-disabled"),e.isImageLoaded&&"0.5"!==e.element.style.opacity&&(t.isBlazor()&&e.events&&!0===e.events.fileOpened.hasDelegate?e.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):e.trigger("fileOpened",i)),(1!==e.zoomSettings.zoomFactor||e.zoomSettings.zoomPoint)&&e.zoom(e.zoomSettings.zoomFactor,e.zoomSettings.zoomPoint),t.isNullOrUndefined(this.initZoomValue)&&(this.initZoomValue=e.zoomSettings.zoomFactor),this.isImageEdited=!1},e.prototype.resetFrameZoom=function(){var e=this.parent;if(!t.isNullOrUndefined(e.tempFrameZoomLevel)){var i=e.tempFrameZoomLevel;e.tempFrameZoomLevel=null,e.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:i,zoomPoint:null,isResize:!0}})}},e.prototype.performCancel=function(e){var i=this.parent;e=e||!1;var o={bool:!1};if(i.allowDownScale=!0,i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),JSON.stringify(i.frameObj)!==JSON.stringify(i.tempFrameObj)&&(t.extend(i.frameObj,i.tempFrameObj),this.renderImage(null,null,!0)),this.resetFrameZoom(),o.bool)i.notify("freehand-draw",{prop:"cancelFhd",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}});else if("block"===i.textArea.style.display)i.textArea.style.display="none",i.textArea.value="",i.textArea.style.transform="",this.prevActObj?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.activeObj.strokeSettings=this.tempStrokeSettings,i.activeObj.textSettings=this.tempTextSettings),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),this.isShapeTextInserted&&i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(!t.isBlazor()&&document.querySelector("#"+i.element.id+"_sliderWrapper")||t.isBlazor()&&!i.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||i.currObjType.isFiltered){this.lowerContext.filter=this.tempAdjValue,i.canvasFilter=this.tempAdjValue,i.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.tempAdjValue}}),i.initialAdjustmentValue=this.tempAdjValue,this.lowerContext.filter.split(" ").length>1&&"1"===this.lowerContext.filter.split(" ")[0].split("(")[1].split(")")[0]&&i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}}),i.currentFilter=this.tempFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.redrawImgWithObj(),i.currObjType.isFiltered=!1;var r={tempAdjustmentLevel:null};i.notify("filter",{prop:"getTempAdjustmentLevel",onPropertyChange:!1,value:{obj:r}}),i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:t.extend({},r.tempAdjustmentLevel,{},!0)}}),i.notify("undo-redo",{prop:"setUndoRedoStep",onPropertyChange:!1,value:{step:this.tempUndoRedoStep}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.clearOuterCanvas(this.lowerContext),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});var a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})}else if(e){a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})}else this.cancelItems(),i.transform.zoomFactor>0?(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(i.togglePan=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}));this.isShapeTextInserted=!1,this.isNewPath=!1,t.isBlazor()||(i.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}))},e.prototype.cancelItems=function(){var e,i=this.parent,o=!1,r=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),a=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio");if(void 0!==i.activeObj.shape&&(e=i.activeObj.shape.split("-")),void 0===e&&i.currObjType.isCustomCrop?o=!0:void 0!==e&&"crop"===e[0]&&(o=!0),o&&i.isCropTab&&(i.isCropTab=!1,i.transform.zoomFactor=i.transform.defaultZoomFactor),i.isResize&&(r||a||"resize-toolbar"==i.currentToolbar)){var n={width:null,height:null};i.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:n}});var s={x:n.width,y:n.height},l=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),p=this.parent.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");if(s&&s.x&&s.y&&!t.isNullOrUndefined(this.parent.aspectWidth))if(l||p&&!p.classList.contains("e-hidden"))i.notify("transform",{prop:"resizeImage",value:{width:i.aspectWidth,height:i.aspectHeight}});else{var h=i.currObjType.isUndoAction;i.currObjType.isUndoAction=!1,i.notify("transform",{prop:"resizeCrop",value:{width:i.aspectWidth,height:i.aspectHeight}}),i.currObjType.isUndoAction=h}var c={prevCropObj:i.prevCropObj},d={prevObj:i.prevObj};this.parent.notify("toolbar",{prop:"getPrevCropObj",onPropertyChange:!1,value:{obj:c}}),this.parent.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:d}}),c.prevCropObj&&d.prevObj&&(l||(i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.cropObj=t.extend({},c.prevCropObj,{},!0),this.setCurrentObj(d.prevObj),i.objColl=d.prevObj.objColl,i.pointColl=d.prevObj.pointColl,i.freehandCounter=i.pointColl.length,i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.parent.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.parent.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.parent.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:d.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),d.prevObj.zoomFactor&&i.setProperties({zoomSettings:{zoomFactor:d.prevObj.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:i.zoomSettings.zoomFactor}})),i.isResize=!1}i.togglePen?this.cancelPen():"text"===i.activeObj.shape?this.cancelText(o):-1!==["rectangle","ellipse","line","arrow","path","image"].indexOf(i.activeObj.shape)?this.cancelShape():o?this.cancelSelection():(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})),i.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})},e.prototype.cancelPen=function(){var e=this.parent;this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default";var i=t.extend([],e.pointColl,[],!0);e.pointColl={};for(var o=0;o<this.tempFreehandCounter;o++)e.pointColl[o]=i[o];e.freehandCounter=this.tempFreehandCounter,e.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.tempCurrFhdIndex}}),e.activeObj.strokeSettings=this.tempStrokeSettings,e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:e.activeObj.strokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},e.prototype.cancelText=function(e){var i=this.parent;if(i.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:this.tempTextSettings,fontFamily:null,fontSize:null}}),i.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.isNullOrUndefined(i.activeObj.currIndex))i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height);else{var o={appliedUndoRedoColl:[]};i.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}});var r=o.appliedUndoRedoColl.length;this.prevActObj&&o.appliedUndoRedoColl[r-1]&&o.appliedUndoRedoColl[r-1].currentObjColl[o.appliedUndoRedoColl[r-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height)),i.activeObj.shape&&"Enter Text"===i.activeObj.keyHistory?(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"draw-shape-text"}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):i.activeObj.shape&&(i.notify("shape",{prop:"redraw-text"}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.activeObj}}),e||void 0===i.activeObj.topLeftCircle||i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),i.clearSelection())}t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1}},e.prototype.cancelShape=function(){var e=this.parent;if(e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.isNullOrUndefined(e.activeObj.currIndex))e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);else if(this.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.renderImage();else{var i={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}});for(var o=void 0,r=0;r<i.appliedUndoRedoColl.length;r++)for(var a=0;a<i.appliedUndoRedoColl[r].currentObjColl.length;a++)if(this.prevActObj&&this.prevActObj.currIndex&&i.appliedUndoRedoColl[r].currentObjColl[a].currIndex===this.prevActObj.currIndex){o=i.appliedUndoRedoColl[r].currentObjColl[0];break}this.prevActObj&&o?(e.activeObj=this.prevActObj,this.prevActObj=null,e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height))}e.currObjType.isDragging=!1,t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})},e.prototype.cancelSelection=function(){var e=this.parent;e.cancelCropSelection&&(e.cropObj=t.extend({},e.cancelCropSelection.previousCropObj,{},!0),e.afterCropActions=e.cancelCropSelection.previousObj.afterCropActions,e.notify("undo-redo",{prop:"undoDefault",onPropertyChange:!1,value:{obj:e.cancelCropSelection}}),e.currSelectionPoint=t.extend({},e.cancelCropSelection.previousCropObj.activeObj,!0),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),this.clearOuterCanvas(this.lowerContext),(e.isCircleCrop||e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}))},e.prototype.updateFlipPan=function(e){var t=this.parent;if(""!==t.transform.currFlipState){var i=this.lowerContext.filter;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("transform",{prop:"rotatedFlip",onPropertyChange:!1}),this.lowerContext.filter="none",t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),e&&this.drawObject("duplicate",e)}},e.prototype.select=function(e,i,o,r,a){var n=this.parent;if(!n.disabled&&n.isImageLoaded){n.allowDownScale=!1;var s={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],n.objColl,[],!0),l.pointColl=t.extend([],n.pointColl,[],!0),l.afterCropActions=n.afterCropActions;var p={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),n.notify("crop",{prop:"setPreviousCropCurrentObj",onPropertyChange:!1,value:{obj:l}}),n.transform.zoomFactor>0&&n.activeObj.shape&&"crop"===n.activeObj.shape.split("-")[0]&&t.isNullOrUndefined(this.currSelPoint)&&(this.currSelPoint=t.extend({},n.activeObj,{},!0));var h=!1,c=void 0;void 0!==n.activeObj.shape&&(c=n.activeObj.shape.split("-")),void 0===c&&n.currObjType.isCustomCrop?h=!0:void 0!==c&&"crop"===c[0]&&(h=!0);var d={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;if(v.objColl=t.extend([],n.objColl,[],!0),v.pointColl=t.extend([],n.pointColl,[],!0),v.afterCropActions=t.extend([],n.afterCropActions,[],!0),n.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),n.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.upperCanvas.style.display="block",n.currSelectionPoint||0!==n.transform.defaultZoomFactor||0!==n.transform.degree&&0!==n.panPoint.totalPannedInternalPoint.x&&0!==n.panPoint.totalPannedInternalPoint.y&&!h){if(n.isCircleCrop=!1,0!==n.transform.defaultZoomFactor&&!this.isResizeSelect){var u=n.isCropTab;n.isCropTab=!1,n.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),n.isCropTab=u,this.resetPanPoints()}n.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),n.isCropTab=!0,n.isCircleCrop=!1,this.isResizeSelect||n.notify("crop",{prop:"setCurrSelPoints",onPropertyChange:!1,value:{isSetDimension:!0}}),n.transform.zoomFactor=n.transform.cropZoomFactor,t.isNullOrUndefined(n.cropObj.activeObj.shape)&&(n.currObjType.shape="crop-"+e.toLowerCase(),this.drawNewSelection(e,i,o,r,a))}else"custom"===e&&(n.currObjType.shape=""),this.drawNewSelection(e,i,o,r,a)}},e.prototype.drawNewSelection=function(e,t,i,o,r){var a,n=this.parent,s="crop-"+e;"crop-custom"===s.toLowerCase()?""!==n.currObjType.shape&&"crop-custom"!==n.currObjType.shape||this.drawCustomSelection("crop-custom",t,i,o,r):"crop-canvas"===s.toLowerCase()?(n.upperCanvas.style.display="block",n.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(n.currObjType.isCustomCrop=!1,n.currObjType.shape=s.toLowerCase(),o&&r?a={startX:t,startY:i,endX:t+o,endY:i+r,width:o,height:r}:o&&"crop-circle"===s&&(a={startX:t,startY:i,endX:t+o,endY:i+o,width:o,height:o}),n.activeObj.shape=s.toLowerCase(),this.updateSelectionInsert(a))},e.prototype.updateSelectionInsert=function(e){var i=this,o=this.parent,r=o.activeObj.activePoint,a={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n={type:o.getSelectionType(a.shapeSettingsObj.type),startX:a.shapeSettingsObj.startX,startY:a.shapeSettingsObj.startY,width:a.shapeSettingsObj.width,height:a.shapeSettingsObj.height},s={action:"insert",previousSelectionSettings:n,currentSelectionSettings:n};t.isBlazor()&&o.events&&!0===o.events.onSelectionResizeStart.hasDelegate?o.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(t){o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}}),"Custom"===t.currentSelectionSettings.type?i.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(e={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),i.drawObject("duplicate",null,!0,e))}):(o.trigger("selectionChanging",s),o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}),"Custom"===s.currentSelectionSettings.type?this.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(e={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),this.drawObject("duplicate",null,!0,e)))},e.prototype.drawCustomSelection=function(e,i,o,r,a){var n=this.parent,s=n.activeObj.activePoint;if(n.currObjType.isCustomCrop=!0,this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.currObjType.shape=n.activeObj.shape=e.toLowerCase(),t.isNullOrUndefined(i)||t.isNullOrUndefined(o)||t.isNullOrUndefined(r)||t.isNullOrUndefined(a)){if(t.isNullOrUndefined(n.transform.zoomFactor)||0===n.transform.zoomFactor){var l=n.img.destLeft,p=n.img.destTop,h=n.img.destWidth,c=n.img.destHeight,d=n.lowerCanvas.width,v=n.lowerCanvas.height,u=s;l>=0&&p>=0?(u.startX=l,u.startY=p,u.endX=l+h,u.endY=p+c):l>=0?(u.startX=l,u.startY=7.5,u.endX=l+h,u.endY=v-15):p>=0?(u.startX=7.5,u.startY=p,u.endX=d-15,u.endY=p+c):(u.startX=7.5,u.startY=7.5,u.endX=d-15,u.endY=v-15)}else{var g=n.img.destLeft,b=n.img.destTop,f=n.img.destWidth,m=n.img.destHeight,C=n.lowerCanvas.width,y=n.lowerCanvas.height,j=s;j.startX=Math.max(g>0?g:7.5,g),j.startY=Math.max(b>0?b:7.5,b),j.endX=Math.min(g+f+15<C?g+f-15:C-15,g+f),j.endY=Math.min(b+m+15<y?b+m-15:y-15,b+m)}var P=n.img.destLeft,O=n.img.destTop,x=n.img.destWidth,w=n.img.destHeight,S=n.lowerCanvas.clientWidth,T=n.lowerCanvas.clientHeight,k=s;k.startX=Math.max(k.startX,P),k.startY=Math.max(k.startY,O),k.endX=Math.min(k.endX,P+x),k.endY=Math.min(k.endY,O+w),k.startX===P&&P+x>S&&(k.endX=S-15),k.startY===O&&O+w>T&&(k.endY=T-15),n.activeObj=this.updateWidthHeight(n.activeObj),this.updateActiveObject(s,n.activeObj)}else s.startX=i,s.startY=o,s.endX=i+r,s.endY=o+a,s.width=r,s.height=a;this.updateSelectionInsert()},e.prototype.callUpdateCurrTransState=function(){var e=this.parent,i=t.extend([],e.objColl,[],!0),o=t.extend({},e.activeObj,{},!0);e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isRotateZoom=!0,this.updateCurrTransState("initial"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y;var r=this.lowerContext.filter;0===e.transform.degree&&e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),this.updateCurrTransState("reverse"),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),this.isRotateZoom=!1,e.objColl=i;var a=e.togglePen;e.togglePen=!1,this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y,e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),e.img.destLeft-=e.panPoint.totalPannedInternalPoint.x,e.img.destTop-=e.panPoint.totalPannedInternalPoint.y,e.togglePen=a,this.lowerContext.filter=r,e.activeObj=o},e.prototype.resetPanPoints=function(){this.parent.panPoint.totalPannedPoint={x:0,y:0},this.parent.panPoint.totalPannedClientPoint={x:0,y:0},this.parent.panPoint.totalPannedInternalPoint={x:0,y:0}},e.prototype.setClientTransDim=function(e){var i=this.parent;if(i.transform.degree%90==0&&i.transform.degree%180!=0){i.img.destLeft=(i.lowerCanvas.width-i.img.destHeight)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destWidth)/2;var o=i.img.destWidth;i.img.destWidth=i.img.destHeight,i.img.destHeight=o}else t.isNullOrUndefined(e)&&(i.img.destLeft=(i.lowerCanvas.width-i.img.destWidth)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destHeight)/2)},e.prototype.redrawImgWithObj=function(){var e=this.parent,i={canvasFilter:e.canvasFilter};if(this.lowerContext.filter=i.canvasFilter,0!==e.rotateFlipColl.length){var o=t.extend({},e.panPoint.totalPannedInternalPoint,{},!0),r={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.callUpdateCurrTransState(),e.panPoint.totalPannedInternalPoint=o,e.img.destLeft=r.startX,e.img.destTop=r.startY,e.img.destWidth=r.width,e.img.destHeight=r.height}else this.callUpdateCurrTransState();e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.setCurrentObj=function(e){var i=this.parent,o=!!e;o||(i.cropObj.aspectWidth=i.aspectWidth,i.cropObj.aspectHeight=i.aspectHeight,i.cropObj.frame=i.frameObj.type),e=e||i.cropObj,i.transform.cropZoomFactor=e.cropZoom,i.transform.defaultZoomFactor=e.defaultZoom,o?e.activeObj.shape&&"crop"===e.activeObj.shape.split("-")[0]?i.transform.zoomFactor=e.cropZoom:i.transform.zoomFactor=e.defaultZoom:i.transform.zoomFactor=e.cropZoom,i.setProperties({zoomSettings:{zoomFactor:e.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.previousZoomValue}}),i.panPoint.totalPannedPoint=t.extend({},e.totalPannedPoint,{},!0),i.panPoint.totalPannedClientPoint=t.extend({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=t.extend({},e.totalPannedInternalPoint,{},!0);var r=t.extend({},e.tempFlipPanPoint,{},!0);i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:r}}),i.rotateFlipColl=t.extend([],e.rotateFlipColl,[],!0),i.transform.degree=e.degree,i.frameObj.type=e.frame,i.transform.currFlipState=e.currFlipState,i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY,i.img.destWidth=e.destPoints.width,i.img.destHeight=e.destPoints.height,i.img.srcLeft=e.srcPoints.startX,i.img.srcTop=e.srcPoints.startY,i.img.srcWidth=e.srcPoints.width,i.img.srcHeight=e.srcPoints.height,i.aspectWidth=e.aspectWidth,i.aspectHeight=e.aspectHeight,e.afterCropActions&&(i.afterCropActions=e.afterCropActions),this.lowerContext.filter=e.filter,i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:e.isBrightAdjust}});var a,n=i.isCircleCrop;t.isNullOrUndefined(i.currSelectionPoint)?a=null:(a=t.extend({},i.currSelectionPoint,{},!0),i.currSelectionPoint=null),i.isCircleCrop=!1,this.drawCropSelectionImage(e,!1),0!==i.transform.degree&&(""===i.transform.currFlipState?i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}):i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY,i.panPoint.totalPannedClientPoint=t.extend({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=t.extend({},e.totalPannedInternalPoint,{},!0)),i.activeObj=t.extend({},e.activeObj,{},!0),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0);var s=t.extend({},e.activeObj,{},!0),l=!1;if(i.afterCropActions.length>0){var p={collection:i.afterCropActions};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.afterCropActions,isRotateFlipCollection:null,obj:p}}),i.afterCropActions=p.collection}var h=t.extend([],i.afterCropActions,[],!0);if(!o&&h.length>0){l=!0;for(var c=0;c<h.length;c++)"horizontalflip"!==h[c]&&"verticalflip"!==h[c]||(i.activeObj=t.extend({},a,{},!0),this.rotatedFlipCropSel=!0),i.notify("transform",{prop:"updateTransform",onPropertyChange:!1,value:{text:h[c]}});s=t.extend({},i.activeObj,{},!0),this.resetPanPoints(),i.activeObj=s,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0),e.degree!==i.transform.degree&&(i.transform.cropZoomFactor=null,i.transform.zoomFactor=0),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.rotatedFlipCropSel&&(this.rotatedFlipCropSel=!1)}i.afterCropActions=h,this.isCancelAction||l||(i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY),i.activeObj=s,i.isCircleCrop=n,t.isNullOrUndefined(a)?i.currSelectionPoint=null:(i.currSelectionPoint=t.extend({},a,{},!0),i.currSelectionPoint&&t.isNullOrUndefined(i.currSelectionPoint.shape)&&(i.currSelectionPoint=null))},e.prototype.drawCropSelectionImage=function(e,i){var o=this.parent,r=this.lowerContext.filter;o.clearContext(this.lowerContext),o.clearContext(this.upperContext),this.lowerContext.setTransform(1,0,0,1,0,0),i?this.updateCurrTransState("initial"):this.setTransformColl(this.lowerContext,"initial"),o.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),i?this.updateCurrTransState("reverse"):this.setTransformColl(this.lowerContext,"reverse"),o.img.destLeft=o.cropObj.destPoints.startX,o.img.destTop=o.cropObj.destPoints.startY;var a=t.extend({},e.activeObj,{},!0);if(this.lowerContext.filter="none",this.isCancelAction)o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}});else if(o.img.destLeft=e.destPoints.startX,o.img.destTop=e.destPoints.startY,o.img.destWidth=e.destPoints.width,o.img.destHeight=e.destPoints.height,o.img.srcLeft=e.srcPoints.startX,o.img.srcTop=e.srcPoints.startY,o.img.srcWidth=e.srcPoints.width,o.img.srcHeight=e.srcPoints.height,0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height){var n={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.img.destLeft=e.activeObj.activePoint.startX,o.img.destTop=e.activeObj.activePoint.startY,o.img.destWidth=e.activeObj.activePoint.width,o.img.destHeight=e.activeObj.activePoint.height,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.img.destLeft=n.startX,o.img.destTop=n.startY,o.img.destWidth=n.width,o.img.destHeight=n.height}o.activeObj=a,this.lowerContext.filter=r},e.prototype.performPointZoom=function(e,i,o){var r=this.parent,a=(e-r.img.destLeft)/r.img.destWidth,n=(i-r.img.destTop)/r.img.destHeight,s=r.isUndoRedo;if(r.isUndoRedo=!0,r.setProperties({zoomSettings:{zoomPoint:{x:e,y:i}}},!0),"zoomIn"===o?r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null}):"zoomOut"===o&&r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null}),r.isUndoRedo=s,r.transform.zoomFactor>0){var l=r.img.destLeft,p=r.img.destTop,h=t.extend({},r.activeObj,{},!0);if(0===r.transform.degree)r.img.destLeft=e-a*r.img.destWidth,r.img.destTop=i-n*r.img.destHeight,this.drawZoomPanImage(r.img.destLeft-l,r.img.destTop-p);else{var c=r.isCropTab;r.isCropTab=!0;var d=t.extend([],r.objColl,[],!0),v=t.extend([],r.pointColl,[],!0);r.objColl=[],r.pointColl=[],r.freehandCounter=0;var u={selPointColl:null};r.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}});var g=u.selPointColl;r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),r.panPoint.currentPannedPoint={x:e-a*r.img.destWidth-l,y:i-n*r.img.destHeight-p},r.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),r.isCropTab=c,r.objColl=d,r.pointColl=v,r.freehandCounter=r.pointColl.length,r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:g}}}),r.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}}),r.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}})}this.adjustPanning(h),r.activeObj=h,0!==r.activeObj.activePoint.width&&0!==r.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0)}},e.prototype.adjustPanning=function(e){var i=this.parent;if(0!==e.activePoint.width&&0!==e.activePoint.height){var o=i.img.destLeft,r=i.img.destTop,a={x:0,y:0};if(i.img.destLeft>e.activePoint.startX?a.x=i.img.destLeft-e.activePoint.startX:i.img.destLeft+i.img.destWidth<e.activePoint.startX+e.activePoint.width&&(a.x=i.img.destLeft+i.img.destWidth-(e.activePoint.startX+e.activePoint.width)),i.img.destTop>e.activePoint.startY?a.y=i.img.destTop-e.activePoint.startY:i.img.destTop+i.img.destHeight<e.activePoint.startY+e.activePoint.height&&(a.y=i.img.destTop+i.img.destHeight-(e.activePoint.startY+e.activePoint.height)),0===i.transform.degree)i.img.destLeft-=a.x,i.img.destTop-=a.y,this.drawZoomPanImage(i.img.destLeft-o,i.img.destTop-r);else{var n=i.isCropTab;i.isCropTab=!0;var s=t.extend([],i.objColl,[],!0),l=t.extend([],i.pointColl,[],!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0;var p={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}});var h=p.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.img.destLeft-=a.x,i.img.destTop-=a.y,i.panPoint.currentPannedPoint={x:i.img.destLeft-o,y:i.img.destTop-r},i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),i.isCropTab=n,i.objColl=s,i.pointColl=l,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:h}}}),i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}})}}},e.prototype.drawZoomPanImage=function(e,t){var i=this.parent;i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:e,yDiff:t,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:e,yDiff:t,panRegion:""}}),this.renderImage(!0);var o={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i.img.srcWidth,height:i.img.srcHeight,obj:o,isImgShape:null}});var r=o;r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.panPoint.totalPannedPoint.x+=e,i.panPoint.totalPannedPoint.y+=t,i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:{x:0,y:0}}})},e.prototype.openNewImage=function(){var e=this.parent,o=e.inMemoryCanvas.getContext("2d");i.showSpinner(e.element),e.element.style.opacity="0.5";var r=document.querySelector("#"+e.element.id+"_currPos");r&&(r.style.display="none");var a={defToolbarItems:null};if(t.isBlazor())e.element.querySelector("#"+e.element.id+"_toolbarArea")&&(e.toolbarHeight=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight);else if(e.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:a}}),0===a.defToolbarItems.length&&t.isNullOrUndefined(document.getElementById(e.element.id+"_toolbar"))){var n=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight;e.notify("toolbar",{prop:"setToolbarHeight",value:{height:n}})}e.reset(),e.update(),e.transform.degree=0,e.transform.zoomFactor=0,e.isImageLoaded=!1,e.currSelectionPoint=null;if("string"===typeof this.openURL){var s=this.openURL.split(".");if(s.length>1?(s=s[s.length-2].split("/"),this.fileName=s[s.length-1]):this.fileName="ImageEditor",this.fileType=this.getFileExtensionFromURL(this.openURL),this.fileType){this.fileType=e.toPascalCase(this.fileType);var l=this.fileType.toLowerCase();"jpg"!==l&&"jpeg"!==l||(this.fileType="Jpeg",l="jpeg"),"jpeg"!==l&&"png"!==l&&"svg"!==l&&(this.fileType=null)}this.imageOnLoad(this.openURL)}else this.fileName="ImageEditor",this.fileType=null,e.lowerCanvas=document.querySelector("#"+e.element.id+"_lowerCanvas"),e.upperCanvas=document.querySelector("#"+e.element.id+"_upperCanvas"),this.lowerContext=e.lowerCanvas.getContext("2d"),this.upperContext=e.upperCanvas.getContext("2d"),e.clearContext(this.lowerContext),e.clearContext(this.upperContext),e.clearContext(o),e.inMemoryCanvas.width=this.openURL.width,e.inMemoryCanvas.height=this.openURL.height,o.putImageData(this.openURL,0,0),e.baseImg.src=e.inMemoryCanvas.toDataURL()},e.prototype.dlgBtnClick=function(){var e=this.parent;e.export(),this.isFileChanged?(e.isImageLoaded=this.isFileChanged=!1,e.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),t.isBlazor()||t.getComponent(document.getElementById(e.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},e.prototype.dlgCloseBtnClick=function(){var e=this.parent;this.baseImgSrc=e.baseImg.src,this.isFileChanged?(e.isImageLoaded=this.isFileChanged=!1,e.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),t.isBlazor()||t.getComponent(document.getElementById(e.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},e.prototype.showDialogPopup=function(){var e={key:"ConfirmDialogHeader"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:e}});var t={key:"ConfirmDialogContent"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:t}});var o={key:"Yes"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var r={key:"No"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),this.parent.element.querySelector("#"+this.parent.element.id+"_dialog").style.display="block";new i.Dialog({header:e.value,closeOnEscape:!0,content:"<span>"+t.value+"</span>",target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:r.value,iconCss:"e-icons e-close"}},{click:this.dlgBtnClick.bind(this),buttonModel:{content:o.value,isPrimary:!0,iconCss:"e-icons e-check"}}]}).appendTo("#"+this.parent.element.id+"_dialog")},e.prototype.restoreOldImage=function(){this.parent.isImageLoaded?(this.reset(),this.openNewImage()):this.openNewImage()},e.prototype.open=function(e){document.getElementById(this.parent.element.id+"_dropArea").style.display="none",this.parent.disabled||(this.openURL=e,this.restoreOldImage())},e.prototype.getInitialLoaded=function(e){e.isInitialLoaded=this.isInitialLoading},e.prototype.getFileExtensionFromURL=function(e){var t=e.lastIndexOf(".");return-1!==t?e.slice(t+1).toLowerCase():null},e.prototype.fileSelect=function(e,o){var r=this.parent;if(document.getElementById(r.element.id+"_dropArea").style.display="none",!r.disabled){var a=void 0,n=void 0;o.target?n=a=o.target.files[0]:a=n=o.filesData[0].rawFile;var s=void 0;if(n.name){var l=n.name.split(".");s=l[l.length-1].toLowerCase()}if(s&&-1===["jpg","jpeg","png","svg"].indexOf(s))return void this.errorLoading();if(i.showSpinner(r.element),r.element.style.opacity="0.5",this.inputElem=e,s=n.name&&n.name.split(".")[1]){var p=r.toPascalCase(s);this.fileType="JPG"===p||"Jpg"===p?"Jpeg":p}else this.fileType=null;var h=window.URL.createObjectURL(a);this.openURL=h,r.isImageLoaded&&(this.isImageEdited||r.pointColl.length>0||r.objColl.length>0)?(this.isFileChanged=!0,t.isBlazor()?r.dotNetRef.invokeMethodAsync("UpdateDialog",!0):this.showDialogPopup()):this.checkToolbarTemplate(e,h)}},e.prototype.checkToolbarTemplate=function(e,i){var o=this.parent;t.isNullOrUndefined(o.toolbarTemplate)&&(o.reset(),o.update()),this.fileName=e.value.split("\\")[e.value.split("\\").length-1],this.fileName=this.fileName.split(".")[0],this.imageOnLoad(i.toString()),e.value=""},e.prototype.moveToSelectionRange=function(e,i){var o=this.parent;if(o.activeObj.shape){for(var r=!1,a=0;a<o.rotateFlipColl.length;a++)if(90===o.rotateFlipColl[a]||-90===o.rotateFlipColl[a]){r=!0;break}if(r){if(0===o.transform.degree)return;var n=o.transform.zoomFactor;if(o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),"rotateleft"===e||"rotateright"===e)if(o.transform.degree%90==0&&o.transform.degree%180!=0)if(o.objColl[o.objColl.length-1].activePoint.width<i.activePoint.height)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else if(o.objColl[o.objColl.length-1].activePoint.height<i.activePoint.width)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}var s=o.lowerCanvas.clientWidth/2-(o.objColl[o.objColl.length-1].activePoint.startX+o.objColl[o.objColl.length-1].activePoint.width/2),l=o.lowerCanvas.clientHeight/2-(o.objColl[o.objColl.length-1].activePoint.startY+o.objColl[o.objColl.length-1].activePoint.height/2);0===o.transform.degree?(o.img.destLeft+=s,o.img.destTop+=l,o.notify("transform",{prop:"drawPannImage",value:{point:{x:s,y:l}}})):(o.panPoint.currentPannedPoint={x:s,y:l},o.notify("transform",{prop:"drawPannedImage",value:{xDiff:s,yDiff:l}}),o.panPoint.currentPannedPoint={x:0,y:0}),o.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),o.activeObj=t.extend({},o.objColl[o.objColl.length-1]),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})}}},e.prototype.isSelectionBiggerThanCanvas=function(e){var t=!1;return(e.activePoint.startX<=this.parent.img.destLeft||e.activePoint.startY<=this.parent.img.destTop||e.activePoint.endX>=this.parent.img.destLeft+this.parent.img.destWidth||e.activePoint.endY>=this.parent.img.destTop+this.parent.img.destHeight)&&(t=!0),t},e.prototype.isSelectionOutsideCanvas=function(e){var t=!1;return(e.activePoint.height<this.parent.lowerCanvas.height-this.parent.toolbarHeight||e.activePoint.width<this.parent.lowerCanvas.width)&&(t=!0),t},e.prototype.downScaleImgCanvas=function(e,i,o,r){var a=this.parent,n=i?a.activeObj.imageCanvas:a.baseImgCanvas,s=i?a.activeObj.imageElement:a.baseImg,l=i?a.activeObj.activePoint.width:a.img.destWidth,p=i?a.activeObj.activePoint.height:a.img.destHeight,h={width:0,height:0};if(a.transform.degree%90==0&&a.transform.degree%180!=0?a.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:s.height,height:s.width,obj:h,isImgShape:i}}):a.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:s.width,height:s.height,obj:h,isImgShape:i}}),i||a.allowDownScale&&!a.isCropTab&&!a.isCropToolbar&&0!==s.width&&0!==s.height&&.75*h.width>l&&.75*h.height>p){var c=a.createElement("canvas",{id:a.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});c.width=i?s.width:this.parent.img.srcWidth,c.height=i?s.height:this.parent.img.srcHeight,i?c.getContext("2d").drawImage(s,0,0,c.width,c.height):c.getContext("2d").drawImage(n,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,0,0,c.width,c.height),this.downScale(c,l,p,i),i?(e.canvas.width=c.width,e.canvas.height=c.height,o&&r?(e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1),e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1)):o?(t.isNullOrUndefined(a.activeObj.isHorImageFlip)||!a.activeObj.isHorImageFlip?(a.activeObj.isHorImageFlip=!0,e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1)):a.activeObj.isHorImageFlip&&(a.activeObj.isHorImageFlip=!1),a.activeObj.isVerImageFlip&&(e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1))):r&&(t.isNullOrUndefined(a.activeObj.isVerImageFlip)||!a.activeObj.isVerImageFlip?(a.activeObj.isVerImageFlip=!0,e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1)):a.activeObj.isVerImageFlip&&(a.activeObj.isVerImageFlip=!1),a.activeObj.isHorImageFlip&&(e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1))),e.drawImage(c,0,0),e.setTransform(1,0,0,1,0,0)):e.drawImage(c,0,0,c.width,c.height,a.img.destLeft,a.img.destTop,c.width,c.height)}else!t.isNullOrUndefined(i)&&i||e.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight)},e.prototype.downScale=function(e,t,i,o){for(var r=e.width,a=e.height,n=r/(t=Math.round(t)),s=a/(i=Math.round(i)),l=Math.ceil(n/2),p=Math.ceil(s/2),h=e.getContext("2d"),c=h.getImageData(0,0,r,a),d=h.createImageData(t,i),v=c.data,u=d.data,g=0;g<i;g++)for(var b=0;b<t;b++){for(var f=4*(b+g*t),m=0,C=0,y=0,j=0,P=0,O=0,x=0,w=(g+.5)*s,S=Math.floor(g*s),T=Math.ceil((g+1)*s),k=S;k<T;k++)for(var F=Math.abs(w-(k+.5))/p,A=(b+.5)*n,z=F*F,L=Math.floor(b*n),I=Math.ceil((b+1)*n),X=L;X<I;X++){var Y=Math.abs(A-(X+.5))/l,D=Math.sqrt(z+Y*Y);if(!(D>=1)){var R=4*(X+k*r);x+=(m=2*D*D*D-3*D*D+1)*v[R+3],y+=m,j+=(m=m*v[R+3]/250)*v[R],P+=m*v[R+1],O+=m*v[R+2],C+=m}}u[f]=j/C,u[f+1]=P/C,u[f+2]=O/C,u[f+3]=x/y}e.width=o?this.parent.activeObj.activePoint.width:this.parent.lowerCanvas.width,e.height=o?this.parent.activeObj.activePoint.height:this.parent.lowerCanvas.height,h.putImageData(d,0,0)},e.prototype.drawImgToCtx=function(e,i){var o=this.parent;e.canvas.id!==o.element.id+"_tempCanvas"&&t.isNullOrUndefined(i)&&this.downScaleImgCanvas(e,null,null,null)},e.prototype.getFrameColor=function(e,t,i){var o=this.parent.frameObj.color;if(e.gradientColor){var r=t.createLinearGradient(i.startX,i.startY,i.startX+i.width,i.startY+i.height);r.addColorStop(0,e.color),r.addColorStop(1,e.gradientColor),o=r}else o=e.color;return o},e.prototype.applyFrame=function(e,i,o){var r=this.parent;r.frameObj.type=i;var a,n={width:1,height:1},s={startX:r.img.destLeft-e.lineWidth,startY:r.img.destTop-e.lineWidth,width:r.img.destWidth+2*e.lineWidth,height:r.img.destHeight+2*e.lineWidth},l={type:r.frameObj.type,color:r.frameObj.color,size:r.frameObj.size,inset:r.frameObj.inset,offset:r.frameObj.offset/2,radius:r.frameObj.radius,amount:r.frameObj.amount,border:r.frameObj.border,gradientColor:r.frameObj.gradientColor};if(e.canvas.id===r.element.id+"_tempCanvas"){var p=void 0,h=void 0;p=e.canvas.width,h=e.canvas.height;var c={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:c,dimension:{width:p,height:h}}}),n=c,l.size*=(n.width+n.height)/2,l.inset*=(n.width+n.height)/2,l.offset*=(n.width+n.height)/2,l.radius*=(n.width+n.height)/2,s={startX:0,startY:0,width:e.canvas.width,height:e.canvas.height}}else t.isNullOrUndefined(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height);var d=(n.width+n.height)/2*40,v=(n.width+n.height)/2*50;l.size+=l.size*r.transform.zoomFactor,l.inset+=l.inset*r.transform.zoomFactor,l.offset+=l.offset*r.transform.zoomFactor,l.radius+=l.radius*r.transform.zoomFactor,d+=d*r.transform.zoomFactor,v+=v*r.transform.zoomFactor;var u=e.filter;if(r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape||r.isCircleCrop)this.drawImgToCtx(e,o);else{switch(i){case"none":this.drawImgToCtx(e,o);break;case"mat":this.drawImgToCtx(e,o),e.filter="none",e.fillStyle=this.getFrameColor(l,e,s),e.beginPath(),e.rect(s.startX,s.startY,s.width,s.height),e.rect(s.startX+l.size,s.startY+l.size,s.width-2*l.size,s.height-2*l.size),e.fill("evenodd"),e.closePath();break;case"bevel":e.filter="none",e.fillStyle=this.getFrameColor(l,e,s),e.beginPath(),e.fillRect(s.startX,s.startY,s.width,s.height),e.closePath(),s.startX+=l.size,s.startY+=l.size,s.width-=2*l.size,s.height-=2*l.size,e.fillStyle=this.getFrameColor(l,e,s),e.save(),e.beginPath(),e.moveTo(s.startX+d,s.startY),e.lineTo(s.startX+s.width-d,s.startY),e.quadraticCurveTo(s.startX+s.width,s.startY,s.startX+s.width,s.startY+d),e.lineTo(s.startX+s.width,s.startY+s.height-d),e.quadraticCurveTo(s.startX+s.width,s.startY+s.height,s.startX+s.width-d,s.startY+s.height),e.lineTo(s.startX+d,s.startY+s.height),e.quadraticCurveTo(s.startX,s.startY+s.height,s.startX,s.startY+s.height-d),e.lineTo(s.startX,s.startY+d),e.quadraticCurveTo(s.startX,s.startY,s.startX+d,s.startY),e.closePath(),e.clip(),e.filter="none"===u?r.canvasFilter:u,e.canvas.id===r.element.id+"_tempCanvas"?o?(o=null,e.drawImage(r.baseImg,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,e.canvas.width,e.canvas.height),r.frameObj.type="none",e.filter="none",r.notify("export",{prop:"drawAnnotation",onPropertyChange:!1,value:{context:e,ratio:n}}),r.frameObj.type="bevel",e.filter="none"===u?r.canvasFilter:u):e.drawImage(r.baseImg,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,e.canvas.width,e.canvas.height):o?(o=null,0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),this.updateCurrTransState("initial"),this.drawImgToCtx(e,o),this.updateCurrTransState("reverse"),this.isRotateZoom=!1,r.frameObj.type="none",e.filter="none",r.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),r.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}}),r.frameObj.type="bevel",e.filter="none"===u?r.canvasFilter:u):this.drawImgToCtx(e,o),e.restore();break;case"line":this.drawImgToCtx(e,o),a=e.lineWidth,e.lineWidth=l.size/10;for(var g=0;g<r.frameObj.amount;g++){g>0&&(s.startX+=l.offset,s.startY+=l.offset,s.width-=2*l.offset,s.height-=2*l.offset);var b=s.startY+s.height-l.inset-l.radius,f=s.startY+l.inset+l.radius,m=s.startX+s.width-l.inset-l.radius,C=s.startX+l.inset+l.radius,y=s.startX+l.inset+l.radius,j=s.startX+s.width-l.inset-l.radius,P=s.startY+l.inset+l.radius,O=s.startY+s.height-l.inset-l.radius;b>=f&&m>=C&&y<=j&&P<=O&&(e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),"dashed"===l.border?e.setLineDash([2.5*e.lineWidth,1.5*e.lineWidth]):"dotted"===l.border&&e.setLineDash([e.lineWidth,e.lineWidth]),e.beginPath(),e.moveTo(s.startX+l.inset+l.radius,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset-l.radius,s.startY+l.inset),e.arcTo(s.startX+s.width-l.inset,s.startY+l.inset,s.startX+s.width-l.inset,s.startY+l.inset+l.radius,l.radius),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset-l.radius),e.arcTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset,s.startX+s.width-l.inset-l.radius,s.startY+s.height-l.inset,l.radius),e.lineTo(s.startX+l.inset+l.radius,s.startY+s.height-l.inset),e.arcTo(s.startX+l.inset,s.startY+s.height-l.inset,s.startX+l.inset,s.startY+s.height-l.inset-l.radius,l.radius),e.lineTo(s.startX+l.inset,s.startY+l.inset+l.radius),e.arcTo(s.startX+l.inset,s.startY+l.inset,s.startX+l.inset+l.radius,s.startY+l.inset,l.radius),e.closePath(),e.stroke(),e.setLineDash([]))}e.lineWidth=a;break;case"inset":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),a=e.lineWidth,e.lineWidth=l.size/10,e.beginPath(),e.moveTo(s.startX+l.offset,s.startY+l.inset),e.lineTo(s.startX+s.width-l.offset,s.startY+l.inset),e.moveTo(s.startX+s.width-l.inset,s.startY+l.offset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.offset),e.moveTo(s.startX+s.width-l.offset,s.startY+s.height-l.inset),e.lineTo(s.startX+l.offset,s.startY+s.height-l.inset),e.moveTo(s.startX+l.inset,s.startY+s.height-l.offset),e.lineTo(s.startX+l.inset,s.startY+l.offset),e.stroke(),e.closePath(),e.lineWidth=a;break;case"hook":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),a=e.lineWidth,e.lineWidth=l.size/10,e.beginPath(),e.moveTo(s.startX+l.inset+v,s.startY+l.inset),e.lineTo(s.startX+l.inset,s.startY+l.inset),e.lineTo(s.startX+l.inset,s.startY+l.inset+v),e.moveTo(s.startX+s.width-l.inset-v,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+l.inset+v),e.moveTo(s.startX+s.width-l.inset-v,s.startY+s.height-l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset-v),e.moveTo(s.startX+l.inset+v,s.startY+s.height-l.inset),e.lineTo(s.startX+l.inset,s.startY+s.height-l.inset),e.lineTo(s.startX+l.inset,s.startY+s.height-l.inset-v),e.stroke(),e.lineWidth=a}(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:e,isSave:e.canvas.id===r.element.id+"_tempCanvas"||null,isFlip:null}}),e.filter=u}},e.prototype.triggerFrameChange=function(e){var i=this,o=this.parent,r={cancel:!1,previousFrameSetting:e,currentFrameSetting:{type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,frameLineStyle:o.toPascalCase(o.frameObj.border),lineCount:o.frameObj.amount}};return t.isBlazor()?o.events&&!0===o.events.frameChanging.hasDelegate?o.dotNetRef.invokeMethodAsync("OnFrameChangingAsync",r).then(function(e){if(!e.cancel){i.setFrameObj(e.currentFrameSetting);var r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:r.currObj,previousObjColl:r.currObj.objColl,previousPointColl:r.currObj.pointColl,previousSelPointColl:r.currObj.selPointColl,previousCropObj:t.extend({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});o.element.querySelector(".e-ie-toolbar-e-frame-color")&&(o.element.querySelector(".e-ie-toolbar-e-frame-color"+o.DDBPREVIEW).style.background=o.frameObj.color);if(o.element.querySelector(".e-ie-toolbar-e-frame-gradient")){var a=document.querySelector(".e-dropdown-popup.e-frame-gradient-dd-btn");a&&a.querySelector(".e-nocolor-item").classList.remove("e-selected"),o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).classList.remove("e-nocolor-item"),""==o.frameObj.gradientColor?o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).classList.add("e-nocolor-item"):o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).style.background=o.frameObj.gradientColor}o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}})}}):r.cancel||this.setFrameObj(r.currentFrameSetting):(o.trigger("frameChange",r),r.cancel||this.setFrameObj(r.currentFrameSetting)),r},e.prototype.setFrameObj=function(e){var t=this.parent;t.frameObj.type=e.type.toLowerCase(),t.frameObj.color=e.color,t.frameObj.gradientColor=e.gradientColor,t.frameObj.size=e.size,t.frameObj.inset=e.inset,t.frameObj.offset=e.offset,t.frameObj.radius=e.borderRadius,t.frameObj.border=e.frameLineStyle.toLowerCase(),t.frameObj.amount=e.lineCount},e}(),l=function(){function e(e){this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("export",this.export,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("export",this.export),this.parent.off("destroyed",this.destroy)},e.prototype.export=function(e){if(t.isBlazor()){var i={shape:""};this.parent.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:i}}),""!==i.shape&&(this.parent.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),this.parent.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}else this.parent.notify("toolbar",{prop:"refreshShapeDrawing",onPropertyChange:!1});switch(this.updatePvtVar(),e.prop){case"export":this.exportImg(e.value.type,e.value.fileName);break;case"exportToCanvas":this.exportToCanvas(e.value.object);break;case"drawAnnotation":this.drawAnnotation(e.value.context,e.value.ratio)}},e.prototype.getModuleName=function(){return"export"},e.prototype.updatePvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.exportImg=function(e,i){var o=this,r=this.parent,a={fileName:""};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n=a.fileName;if(!r.disabled&&r.isImageLoaded){var s={bool:!1};r.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool&&r.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),r.togglePen&&(r.currObjType.isZoomed=!0,r.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}})),"block"===r.textArea.style.display&&r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});var l={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=l.canvasFilter,e=e||"Png",r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}});var p={cancel:!1,fileName:i||n,fileType:e};t.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",p).then(function(t){o.beforeSaveEvent(t,e,i,n)}):(r.trigger("beforeSave",p),this.beforeSaveEvent(p,e,i,n))}},e.prototype.beforeSaveEvent=function(e,i,o,r){var a=this.parent;if(!e.cancel){a.currObjType.isSave=!0,o=e.fileName?e.fileName:o;var n=i.toLowerCase();o=o||r,"svg"===n?this.toSVGImg(o):this.toBlobFn(o,n);var s={fileName:o||r,fileType:i};a.trigger("saved",s),t.isBlazor()||a.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),a.lowerCanvas.style.left=a.upperCanvas.style.left="",a.lowerCanvas.style.top=a.upperCanvas.style.top="",a.lowerCanvas.style.maxWidth=a.upperCanvas.style.maxWidth="",a.lowerCanvas.style.maxHeight=a.upperCanvas.style.maxHeight=""}},e.prototype.toSVGImg=function(e){var t=this.parent;i.showSpinner(t.element),t.element.style.opacity="0.5";var o=this.exportToCanvas(),r=o.toDataURL();i.hideSpinner(t.element),t.element.style.opacity="1";var a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width",o.style.maxWidth),a.setAttribute("height",o.style.maxHeight);var n=document.createElementNS("http://www.w3.org/2000/svg","image");n.setAttributeNS(null,"height",o.height.toString()),n.setAttributeNS(null,"width",o.width.toString()),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(n);var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o.width+'" height="'+o.height+'">'+a.innerHTML+"</svg>",l="data:image/svg+xml;base64,"+btoa(s);return null===e?l:(this.downloadImg(l,e+".svg"),null)},e.prototype.toBlobFn=function(e,t){var o=this,r=this.parent;i.showSpinner(r.element),r.element.style.opacity="0.5";this.exportToCanvas().toBlob(function(a){var n=URL.createObjectURL(a);o.downloadImg(n,e+"."+t),i.hideSpinner(r.element),r.element.style.opacity="1"},"image/png")},e.prototype.exportToCanvas=function(e){var i,o,r=this.parent;this.parent.aspectWidth?(t.isBlazor()?r.performResizeClick():r.notify("toolbar",{prop:"resizeClick",value:{bool:!1}}),r.currentToolbar="resize-toolbar",r.okBtn(),r.transform.degree%90==0&&r.transform.degree%180!=0?(i=this.parent.aspectHeight,o=this.parent.aspectWidth):(i=this.parent.aspectWidth,o=this.parent.aspectHeight)):r.currSelectionPoint?(i=r.img.srcWidth,o=r.img.srcHeight):(i=r.baseImgCanvas.width,o=r.baseImgCanvas.height);var a={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:a,dimension:{width:i,height:o}}});var n=a,s=this.lowerContext.filter;if("none"!==this.lowerContext.filter){var l=this.lowerContext.filter.split(" "),p=parseFloat(l[5].split("(")[1]);p*=(n.width+n.height)/2,l[5]="blur("+p+"px)",this.lowerContext.filter=l.join(" ")}var h=r.createElement("canvas",{id:r.element.id+"_tempCanvas",attrs:{name:"canvasImage"}}),c=h.getContext("2d");h.width=i,h.height=o;var d={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i,height:o,obj:d}});var v=d;h.style.maxWidth=v.width+"px",h.style.maxHeight=v.height+"px";var u=this.lowerContext.filter;return c.filter=this.lowerContext.filter,this.downScaleImgCanvas(c,i,o),this.updateFrame(c),this.lowerContext.filter=u,0===r.transform.degree&&""===r.transform.currFlipState||(this.updateSaveContext(c),this.exportTransformedImage(c)),this.drawAnnotation(c,n),r.isCircleCrop&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:c,isSave:!0,isFlip:null}}),this.updateFrame(c,!0),this.lowerContext.filter=s,r.canvasFilter=s,e&&(e.canvas=h),h},e.prototype.drawAnnotation=function(e,i){var o=this.parent;if(o.objColl.length>0){var r=e.filter;e.filter="none";for(var a=t.extend([],o.objColl,[],!0),n=0,s=o.objColl.length;n<s;n++){var l=o.objColl[n].activePoint;if(l.startX-=o.img.destLeft,l.startY-=o.img.destTop,l.endX-=o.img.destLeft,l.endY-=o.img.destTop,l.width=l.endX-l.startX,l.height=l.endY-l.startY,l.startX*=i.width,l.startY*=i.height,l.endX*=i.width,l.endY*=i.height,l.width=l.endX-l.startX,l.height=l.endY-l.startY,o.objColl[n].strokeSettings.strokeWidth*=(i.width+i.height)/2,"text"===o.objColl[n].shape)o.objColl[n].textSettings.fontSize*=(i.width+i.height)/2;else if("path"===o.objColl[n].shape)for(var p=0;p<o.objColl[n].pointColl.length;p++)o.objColl[n].pointColl[p].x=(o.objColl[n].pointColl[p].x-o.img.destLeft)*i.width,o.objColl[n].pointColl[p].y=(o.objColl[n].pointColl[p].y-o.img.destTop)*i.height;else"image"===o.objColl[n].shape&&(o.activeObj=t.extend({},o.objColl[n],{},!0),o.notify("selection",{prop:"upgradeImageQuality",onPropertyChange:!1}),o.objColl[n]=t.extend({},o.activeObj,{},!0));o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"saveContext",obj:o.objColl[n],isCropRatio:null,points:null,isPreventDrag:!0,saveContext:e,isPreventSelection:null}})}e.filter=r,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.objColl=a}if(o.freehandCounter>0){for(var h=t.extend({},o.pointColl,{},!0),c=0;c<o.freehandCounter;c++){o.points=t.extend([],o.pointColl[c].points,[]),o.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});s=o.points.length;o.pointColl[c].strokeWidth*=(i.width+i.height)/2;for(p=0;p<s;p++)o.points[p].x=(o.points[p].x-o.img.destLeft)*i.width,o.points[p].y=(o.points[p].y-o.img.destTop)*i.height}o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}}),o.pointColl=h}},e.prototype.downScaleImgCanvas=function(e,t,i){var o=this.parent,r=o.baseImgCanvas,a=o.baseImg,n={width:0,height:0};if(o.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:a.width,height:a.height,obj:n,isImgShape:null}}),n.width>t&&n.height>i){var s=o.createElement("canvas",{id:o.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});s.width=this.parent.img.srcWidth,s.height=this.parent.img.srcHeight,s.getContext("2d").drawImage(r,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,0,0,s.width,s.height),o.notify("draw",{prop:"downScale",value:{canvas:s,width:t,height:i}}),e.drawImage(s,0,0)}else e.drawImage(o.baseImgCanvas,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,0,0,t,i)},e.prototype.updateFrame=function(e,t){if("none"!==this.parent.frameObj.type){var i=e.filter;e.filter="none",this.parent.notify("draw",{prop:"applyFrame",value:{ctx:e,frame:this.parent.frameObj.type,preventImg:t}}),e.filter=i}},e.prototype.downloadImg=function(e,t){var i=document.createElement("a");i.href=e,i.target="_parent",i.download=t,(document.body||document.documentElement).appendChild(i),i.click(),i.parentNode.removeChild(i)},e.prototype.exportTransformedImage=function(e){for(var t=this.parent,i=t.transform.degree,o=0,r=t.rotateFlipColl.length;o<r;o++){var a=t.rotateFlipColl[o];"number"==typeof a?this.exportRotate(e,a):"horizontal"===a?this.exportFlip(e,!0,!1):"vertical"===a&&this.exportFlip(e,!1,!0)}t.transform.degree=i},e.prototype.exportRotate=function(e,t){var i=this.parent;this.setMaxDim(i.transform.degree,e.canvas),e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*t),e.drawImage(i.inMemoryCanvas,-e.canvas.height/2,-e.canvas.width/2,e.canvas.height,e.canvas.width),this.updateSaveContext(e)},e.prototype.exportFlip=function(e,t,i){t&&(e.translate(e.canvas.width,0),e.scale(-1,1)),i&&(e.translate(0,e.canvas.height),e.scale(1,-1)),e.drawImage(this.parent.inMemoryCanvas,0,0),this.updateSaveContext(e)},e.prototype.updateSaveContext=function(e){var t=this.parent.inMemoryCanvas.getContext("2d");e.setTransform(1,0,0,1,0,0);var i=e.getImageData(0,0,e.canvas.width,e.canvas.height);this.parent.inMemoryCanvas.width=i.width,this.parent.inMemoryCanvas.height=i.height,t.putImageData(i,0,0)},e.prototype.setMaxDim=function(e,i){var o,r;e%90==0&&e%180!=0?(o=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.height:this.parent.img.srcHeight,r=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.width:this.parent.img.srcWidth):e%180!=0&&0!==e||(o=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.width:this.parent.img.srcWidth,r=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.height:this.parent.img.srcHeight),t.isNullOrUndefined(this.parent.aspectWidth)||(o=this.parent.aspectWidth,r=this.parent.aspectHeight),i.width=o,i.height=r;var a={width:0,height:0};this.parent.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o,height:r,obj:a,isImgShape:null}});var n=a;i.style.maxWidth=n.width+"px",i.style.maxHeight=n.height+"px"},e}(),p=function(){function e(e){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue="",this.isBrightnessAdjusted=!1,this.appliedFilter="",this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("filter",this.filter,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("filter",this.filter),this.parent.off("destroyed",this.destroy)},e.prototype.filter=function(e){switch(this.updatePrivateVariables(),e.prop){case"finetuneImage":this.finetuneImage(e.value.option,e.value.value);break;case"applyImageFilter":this.setFilter(e.value.option);break;case"update-finetunes":this.updateFinetunes();break;case"set-adjustment":this.setAdjustment(e.value.operation);break;case"update-filter":this.updateFilter(e.value.operation,e.value.filter);break;case"initFilter":this.initFilter();break;case"setCurrAdjValue":this.setCurrAdjValue(e.value.type,e.value.value);break;case"updateAdj":this.updateAdj(e.value.type,e.value.value,e.value.isPreview,e.value.ctx);break;case"getCurrentObj":this.getCurrentObj(e.value.object);break;case"getAdjustmentLevel":t.isNullOrUndefined(this.parent.activeObj.imageTransparency)?this.adjustmentLevel.transparency=100:this.adjustmentLevel.transparency=100*this.parent.activeObj.imageTransparency,e.value.obj.adjustmentLevel=this.adjustmentLevel;break;case"setAdjustmentLevel":this.adjustmentLevel=e.value.adjustmentLevel;break;case"getTempAdjustmentLevel":e.value.obj.tempAdjustmentLevel=this.tempAdjustmentLevel;break;case"setTempAdjustmentLevel":this.tempAdjustmentLevel=e.value.tempAdjustmentLevel;break;case"setAdjustmentValue":this.adjustmentValue=e.value.adjustmentValue;break;case"getBrightnessAdjusted":e.value.obj.isBrightnessAdjusted=this.isBrightnessAdjusted;break;case"setBrightnessAdjusted":this.isBrightnessAdjusted=e.value.isBrightnessAdjusted,this.parent.currentFilter.split("_")&&"cold"===this.parent.currentFilter.split("_")[1]&&(this.isBrightnessAdjusted=!1);break;case"reset":this.reset()}},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.getModuleName=function(){return"filter"},e.prototype.reset=function(){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue=this.parent.getDefaultFilter(),this.isBrightnessAdjusted=!1,this.appliedFilter=""},e.prototype.updateFinetunes=function(){var e=this.parent,t=e.finetuneSettings;t&&(t.brightness&&(this.adjustmentLevel.brightness=t.brightness.defaultValue,this.tempAdjustmentLevel.brightness=t.brightness.defaultValue),t.contrast&&(this.adjustmentLevel.contrast=t.contrast.defaultValue,this.tempAdjustmentLevel.contrast=t.contrast.defaultValue),t.hue&&(this.adjustmentLevel.hue=t.hue.defaultValue,this.tempAdjustmentLevel.hue=t.hue.defaultValue),t.saturation&&(this.adjustmentLevel.saturation=t.saturation.defaultValue,this.tempAdjustmentLevel.saturation=t.saturation.defaultValue),t.exposure&&(this.adjustmentLevel.exposure=t.exposure.defaultValue,this.tempAdjustmentLevel.exposure=t.exposure.defaultValue),t.opacity&&(this.adjustmentLevel.opacity=t.opacity.defaultValue,this.tempAdjustmentLevel.opacity=t.opacity.defaultValue),t.blur&&(this.adjustmentLevel.blur=t.blur.defaultValue,this.tempAdjustmentLevel.blur=t.blur.defaultValue),e.notify("draw",{prop:"isInitialLoading",onPropertyChange:!1,value:{isInitialLoading:!0}}))},e.prototype.initFilter=function(){this.setFilterAdj("brightness",this.adjustmentLevel.brightness),this.setFilterAdj("contrast",this.adjustmentLevel.contrast),this.setFilterAdj("hue",this.adjustmentLevel.hue),this.setFilterAdj("saturation",this.adjustmentLevel.saturation),this.setFilterAdj("exposure",this.adjustmentLevel.exposure),this.setFilterAdj("opacity",this.adjustmentLevel.opacity),this.setFilterAdj("blur",this.adjustmentLevel.blur)},e.prototype.updateAdj=function(e,i,o,r){var a=this.parent;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height);var n=this.lowerContext.filter.split(" "),s=[];n[4]&&parseFloat(n[4].split("(")[1]),n[0]&&parseFloat(n[0].split("(")[1]);var l=this.getFilterValue(this.adjustmentLevel.brightness);if(-1===["brightness","contrast","hue","saturation","exposure","opacity","blur"].indexOf(e)&&t.isNullOrUndefined(o)&&(this.adjustmentLevel.sharpen||this.adjustmentLevel.bw)){a.isUndoRedo=!0;var p=this.lowerContext.filter;this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=p,a.isUndoRedo=!1}var h,c,d,v,u;switch(e){case"brightness":i=this.getFilterValue(this.adjustmentLevel.exposure)+.005*i,n[0]="brightness("+i+")",0!==this.adjustmentLevel.brightness?(i=this.adjustmentLevel.opacity/100-.3*this.adjustmentLevel.opacity/100,n[4]="opacity("+i+")"):(i=this.adjustmentLevel.opacity/100,n[4]="opacity("+i+")"),this.adjustmentValue=n.join(" ");break;case"contrast":n[1]="contrast("+i+"%)",this.adjustmentValue=n.join(" ");break;case"hue":n[2]="hue-rotate("+i+"deg)",this.adjustmentValue=n.join(" ");break;case"saturation":n[3]="saturate("+i+"%)",this.adjustmentValue=n.join(" ");break;case"opacity":1!==parseFloat(n[0].split("(")[1])&&(i-=.2),n[4]="opacity("+i+")",i,this.adjustmentValue=n.join(" ");break;case"blur":n[5]="blur("+i+"px)",this.adjustmentValue=n.join(" ");break;case"exposure":i>1?(i-=1,i+=l):i<1&&(i=l-(i=1-i)),n[0]="brightness("+i+")",this.adjustmentValue=n.join(" ");break;case"chrome":h=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(h*=100)+.4*h,n[3]="saturate("+i+"%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"cold":c=this.getFilterValue(this.adjustmentLevel.brightness),i=.9*(c*=100),i*=.01,n[0]="brightness("+i+")",v=this.getFilterValue(this.adjustmentLevel.contrast),i=(v*=100)+.5*v,n[1]="contrast("+i+"%)",u=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=u*=100,n[3]="saturate("+i+"%)",s=this.adjustmentValue.split(" "),n[2]=s[2],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"warm":d=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(d*=100)+.4*d,n[3]="saturate("+i+"%)",n[6]="sepia(25%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[4]=s[4],n[5]=s[5],n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"grayscale":n[7]="grayscale(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[8]="invert(0%)";break;case"sepia":n[6]="sepia(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"invert":n[8]="invert(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)"}if("sharpen"!==e&&"blackandwhite"!==e){t.isNullOrUndefined(o)&&("default"===e&&(n=this.getDefaultCurrentFilter(n)),this.lowerContext.filter=n.join(" ")),n=this.setTempFilterValue(l,o,n,e),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.appliedFilter=this.lowerContext.filter,a.notify("draw",{prop:"drawImage",onPropertyChange:!1}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),n=this.setTempFilterValue(l,o,n,e),t.isNullOrUndefined(o)&&(this.lowerContext.filter=n.join(" ")),a.initialAdjustmentValue=n.join(" ");var g=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=g,a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.isBrightnessAdjusted=1!==l}var b=n.join(" ");r&&(r.filter=b)},e.prototype.setTempFilterValue=function(e,t,i,o){if(t)if("default"===o)i=this.getDefaultCurrentFilter(i);else if(1!==e){var r=this.lowerContext.filter.split(" ");r[4]=i[4],this.lowerContext.filter=r.join(" ")}return i},e.prototype.getDefaultCurrentFilter=function(e){var t=this.adjustmentValue.split(" ");return[t[0],t[1],t[2],t[3],t[4],t[5],"sepia(0%)","grayscale(0%)","invert(0%)"]},e.prototype.getFilterValue=function(e){return 0===e?1:1+.5*e/100},e.prototype.getSaturationFilterValue=function(e){return 0===e?1:1+e/100},e.prototype.setFilterAdj=function(e,i){var o=this.parent;switch(o.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1}),this.adjustmentLevel[""+e]=i,e){case"contrast":case"exposure":i=this.getFilterValue(i),"contrast"===e&&(i*=100);break;case"hue":i*=3;break;case"saturation":i=100*this.getSaturationFilterValue(i);break;case"opacity":i>=50?i/=100:40===i?i=.45:30===i?i=.4:20===i?i=.35:10===i?i=.3:0===i&&(i=.25);break;case"blur":0!==i&&(i/=20,i+=.5)}var r=t.extend({},o.cropObj,{},!0),a=this.getCurrentObj();a.objColl=t.extend([],o.objColl,[],!0),a.pointColl=t.extend([],o.pointColl,[],!0),a.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.updateAdj(e,i),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})},e.prototype.setFilter=function(e){var i=this.parent;e=e.toLowerCase(),i.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1});var o={currentFilter:this.parent.currentFilter}.currentFilter,r=t.extend({},i.cropObj,{},!0),a=this.getCurrentObj();a.objColl=t.extend([],i.objColl,[],!0),a.pointColl=t.extend([],i.pointColl,[],!0),a.afterCropActions=t.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.updateAdj(e,null),i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:o,isCircleCrop:null}})},e.prototype.setAdjustment=function(e){var t,i,o=this.lowerContext.filter.split(" ");switch(e){case"brightness":i=o[0].split("("),t=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.brightness=this.setFilterValue(t);break;case"contrast":i=o[1].split("("),t=parseFloat(i[1].split(")")[0]),t/=100,this.adjustmentLevel.contrast=this.setFilterValue(t);break;case"hue":i=o[2].split("("),t=parseFloat(i[1].split(")")[0]),t/=3,this.adjustmentLevel.hue=t;break;case"saturation":i=o[3].split("("),t=parseFloat(i[1].split(")")[0]),t/=100,this.adjustmentLevel.saturation=this.setSaturationFilterValue(t);break;case"opacity":i=o[4].split("("),.45===(t=parseFloat(i[1].split(")")[0]))?t=40:.4===t?t=30:.35===t?t=20:.3===t?t=10:.25===t?t=0:t*=100,this.adjustmentLevel.opacity=t;break;case"blur":i=o[5].split("("),t=parseFloat(i[1].split(")")[0]),t*=20,this.adjustmentLevel.blur=t;break;case"exposure":i=o[0].split("("),t=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.exposure=this.setFilterValue(t)}},e.prototype.setFilterValue=function(e){return Math.round(1===e?0:100*(e-1)/.5)},e.prototype.setSaturationFilterValue=function(e){return Math.round(1===e?0:100*(e-1))},e.prototype.updateFilter=function(e,t){var i=this.parent;if(-1!==["default","chrome","cold","warm","grayscale","blackandwhite","sepia","invert","sharpen"].indexOf(e)){var o=i.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");o&&o.classList.remove("e-selected");var r=document.getElementById(i.element.id+"_"+e+"Canvas");r&&r.parentElement.classList.add("e-selected"),this.parent.currentFilter=t||i.element.id+"_"+e}},e.prototype.finetuneImage=function(e,t){var i=this.parent;if(!i.disabled&&i.isImageLoaded){switch(e.toLowerCase()){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}this.parent.canvasFilter=this.lowerContext.filter,i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},e.prototype.setCurrAdjValue=function(e,t){switch(this.parent.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),e){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}},e.prototype.getCurrentObj=function(e){var i=this.parent,o={point:null};i.notify("crop",{prop:"getTempFlipPanPoint",value:{obj:o}});var r={previousZoomValue:null};i.notify("transform",{prop:"getPreviousZoomValue",value:{obj:r}});var a={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:this.isBrightnessAdjusted,aspectWidth:null,aspectHeight:null};return a.cropZoom=i.transform.cropZoomFactor,a.defaultZoom=i.transform.defaultZoomFactor,a.zoomFactor=i.zoomSettings.zoomFactor,a.previousZoomValue=r.previousZoomValue,a.totalPannedPoint=t.extend({},i.panPoint.totalPannedPoint,{},!0),a.totalPannedClientPoint=t.extend({},i.panPoint.totalPannedClientPoint,{},!0),a.totalPannedInternalPoint=t.extend({},i.panPoint.totalPannedInternalPoint,{},!0),a.tempFlipPanPoint=t.extend({},o.point,{},!0),a.activeObj=t.extend({},i.activeObj,{},!0),a.rotateFlipColl=t.extend([],i.rotateFlipColl,[],!0),a.degree=i.transform.degree,a.currFlipState=i.transform.currFlipState,a.destPoints={startX:i.img.destLeft,startY:i.img.destTop,endX:0,endY:0,width:i.img.destWidth,height:i.img.destHeight},a.srcPoints={startX:i.img.srcLeft,startY:i.img.srcTop,endX:0,endY:0,width:i.img.srcWidth,height:i.img.srcHeight},a.filter=this.lowerContext.filter,a.aspectWidth=i.aspectWidth,a.aspectHeight=i.aspectHeight,a.frame=i.frameObj.type,a.frameObj=t.extend({},i.frameObj),e&&(e.currObj=a),a},e}(),h=function(){function i(e){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=!1,this.freehandDownPoint={x:0,y:0},this.isFreehandPointMoved=!1,this.pointCounter=0,this.selPointColl={},this.currFHDIdx=0,this.selPoints=[],this.dummyPoints=[],this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("freehand-draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("freehand-draw",this.draw),this.parent.off("destroyed",this.destroy)},i.prototype.draw=function(e){switch(this.updateFhdPvtVar(),e.prop){case"hoverFhd":this.hoverFhd(e.value.strokeColor,e.value.strokeWidth);break;case"freehandDownHandler":this.freehandDownHandler(e.value.e,e.value.canvas);break;case"freehandUpHandler":this.freehandUpHandler(e.value.e,e.value.canvas,e.value.context);break;case"handle-freehand-draw":var i=parseInt(e.value.id.split("_")[1],10)-1;this.isFHDIdx(i)&&this.deleteFhd(i,!0);break;case"freehandRedraw":this.freehandRedraw(e.value.context,e.value.points);break;case"deleteFhd":i=parseInt(e.value.id.split("_")[1],10)-1;this.deleteFhd(i,!0);break;case"selectFhd":i=null;e.value.id&&(i=parseInt(e.value.id.split("_")[1],10)-1),this.selectFhd(i);break;case"applyFhd":this.applyFhd();break;case"cancelFhd":this.cancelFhd();break;case"updateFHDCurPts":this.updateFHDCurPts();break;case"rotateFhdColl":this.rotateFhdColl();break;case"flipFHDColl":this.flipFHDColl(e.value.value);break;case"panFHDColl":this.panFHDColl(e.value.xDiff,e.value.yDiff,e.value.panRegion);break;case"updateFHDColl":this.updateFHDColl();break;case"zoomFHDColl":this.zoomFHDColl(e.value.isPreventApply);break;case"apply-pen-draw":this.applyPenDraw();break;case"freeHandDraw":this.freeHandDraw(e.value.value);break;case"isFHDIdx":this.isFHDIdx(e.value.index,e.value.obj);break;case"getSqPtFD":this.getSqPtFD(e.value.idx,e.value.obj);break;case"getSelPointColl":e.value.obj.selPointColl=t.extend([],this.selPointColl);break;case"setSelPointColl":this.selPointColl=t.extend([],e.value.obj.selPointColl);break;case"setFreehandDrawHoveredIndex":this.fhdHovIdx=e.value.index;break;case"getFreehandDrawHoveredIndex":e.value.obj.index=this.fhdHovIdx;break;case"setPointCounter":this.pointCounter=e.value.value;break;case"getPenStrokeWidth":e.value.obj.penStrokeWidth=this.penStrokeWidth;break;case"setPenStrokeWidth":this.penStrokeWidth=e.value.value;break;case"getCurrentFreehandDrawIndex":e.value.obj.currentFreehandDrawIndex=this.currFHDIdx;break;case"setCurrentFreehandDrawIndex":this.currFHDIdx=e.value.value;break;case"updateCropPtsForSel":this.updateCropPtsForSel();break;case"getFreehandDrawSelectedId":e.value.obj.freehandDrawSelectedId=this.fhdSelID;break;case"resetFreehandDrawSelectedId":this.fhdSelID=null;break;case"getTempFreeHandDrawEditingStyles":e.value.obj.tempFreeHandDrawEditingStyles=this.tempFHDStyles;break;case"setFreehandSelectedIndex":this.fhdSelIdx=e.value.index;break;case"getFreehandSelectedIndex":e.value.obj.freehandSelectedIndex=this.fhdSelIdx;break;case"reset":this.reset()}},i.prototype.updateFhdPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=this.isFreehandPointMoved=!1,this.selPoints=[],this.dummyPoints=[],this.freehandDownPoint={x:0,y:0},this.selPointColl={},this.fhdHovIdx=null,this.pointCounter=0,this.fhdSelID=null,this.penStrokeWidth=void 0,this.currFHDIdx=0,this.fhdSelIdx=null,this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null}},i.prototype.getModuleName=function(){return"freehand-draw"},i.prototype.hoverFhd=function(e,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=this.upperContext,a=-1;a=this.fhdHovIdx>-1?this.fhdHovIdx:this.fhdSelIdx,o.points=t.extend([],o.pointColl[a].points),this.pointCounter=0;var n,s,l,p,h=o.points.length,c=0,d=0;r.fillStyle=e||o.pointColl[a].strokeColor,r.strokeStyle=r.fillStyle,c=d=this.penStrokeWidth=i||o.pointColl[a].strokeWidth,1===h&&(n=s=l=p=o.points[0],this.startDraw(r,n,s,l,p,c,d));for(var v=0;v<h-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(n=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,s=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,l=0===v?o.points[v]:o.points[v+1],p=o.points[v+2],this.startDraw(r,n,s,l,p,c,d));r.closePath();var u=this.getSqPtFD(a),g=r.lineWidth;r.lineWidth=2,r.strokeStyle=o.themeColl[o.theme].primaryColor,r.beginPath(),r.rect(u.startX,u.startY,u.width,u.height),r.stroke(),r.closePath(),r.lineWidth=g},i.prototype.freehandDownHandler=function(i,o){this.parent.lowerCanvas=document.querySelector("#"+this.parent.element.id+"_lowerCanvas"),this.lowerContext=this.parent.lowerCanvas.getContext("2d"),this.parent.upperCanvas=document.querySelector("#"+this.parent.element.id+"_upperCanvas"),this.upperContext=this.parent.upperCanvas.getContext("2d"),this.fhdObj.time=(new Date).getTime(),this.isFreehandDrawing=!0,"mousedown"===i.type?this.freehandDownPoint={x:i.clientX,y:i.clientY}:this.freehandDownPoint={x:i.touches[0].clientX,y:i.touches[0].clientY},this.isFreehandPointMoved=!1,t.EventHandler.add(o,"mousemove touchmove",this.freehandMoveHandler,this);var r={id:"pen_"+(this.currFHDIdx+1),type:e.ShapeType.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:this.parent.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:null},a={action:"draw-start",previousShapeSettings:r,currentShapeSettings:r};this.triggerShapeChanging(a)},i.prototype.freehandUpHandler=function(i,o,r){var a=o.getBoundingClientRect(),n=this.parent;t.EventHandler.remove(o,"mousemove touchmove",this.freehandMoveHandler),0===n.points.length&&("mouseup"===i.type?this.processPoint(i.clientX-a.left,i.clientY-a.top,!0,r):"touchend"===i.type&&i.changedTouches?this.processPoint(i.changedTouches[0].clientX-a.left,i.changedTouches[0].clientY-a.top,!0,r):this.isFreehandPointMoved||this.processPoint(this.freehandDownPoint.x-a.left,this.freehandDownPoint.y-a.top,!0,r)),r.closePath();var s=t.extend({},n.cropObj,{},!0),l={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:l}});var p=l.currObj;p.objColl=t.extend([],n.objColl,[],!0),p.pointColl=t.extend([],n.pointColl,[],!0),p.afterCropActions=t.extend([],n.afterCropActions,[],!0);var h={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=t.extend([],h.selPointColl,[],!0);var c=n.freehandCounter;n.pointColl[c]={},n.pointColl[c].points=t.extend([],n.points),n.pointColl[c].strokeColor=n.activeObj.strokeSettings.strokeColor,n.pointColl[c].strokeWidth=this.penStrokeWidth,n.pointColl[c].flipState=n.transform.currFlipState,n.pointColl[c].id="pen_"+(this.currFHDIdx+1),n.points=[],this.dummyPoints=[],this.selPointColl[c]={},this.selPointColl[c].points=t.extend([],this.selPoints),this.selPoints=[],this.pointCounter=0,n.freehandCounter++,this.isFreehandDrawing=!1,n.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehand-draw",previousObj:p,previousObjColl:p.objColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:s,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});var d={id:"pen_"+(this.currFHDIdx+1),type:e.ShapeType.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:this.parent.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:this.parent.pointColl[this.currFHDIdx].points},v={action:"draw-end",previousShapeSettings:d,currentShapeSettings:d};this.triggerShapeChanging(v),this.currFHDIdx++},i.prototype.freehandMoveHandler=function(e){this.isFreehandPointMoved=!0;var t,i,o=this.parent.upperCanvas.getBoundingClientRect();"mousemove"===e.type?(t=e.clientX-o.left,i=e.clientY-o.top):(t=e.touches[0].clientX-o.left,i=e.touches[0].clientY-o.top),this.isFreehandDrawing&&(this.upperContext.fillStyle=this.parent.activeObj.strokeSettings.strokeColor,this.processPoint(t,i,!1,this.upperContext))},i.prototype.processPoint=function(e,i,o,r){var a,n,s,l,p=this.parent,h=this.point(e,i,(new Date).getTime()),c=!!(h=p.points.length>0&&p.points[p.points.length-1])&&this.distanceTo(h)<=5;if(this.selPoints.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),!h||!h||!c||o){if(this.fhdObj.time=(new Date).getTime(),p.points.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.length>2){3===this.dummyPoints.length&&this.dummyPoints.unshift(this.dummyPoints[0]);var d=this.dummyPoints[0],v=this.dummyPoints[1],u=this.dummyPoints[2],g=this.dummyPoints[3];a=this.calcCurveCP(d,v,u).controlPoint2,n=this.calcCurveCP(v,u,g).controlPoint1,s=this.dummyPoints[1],l=this.dummyPoints[2];var b=.5,f=5;t.isNullOrUndefined(this.penStrokeWidth)||(b=f=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,f),this.pointCounter++,this.dummyPoints.shift()}if(o){a=n=s=l={x:e,y:i,time:(new Date).getTime()};b=.5,f=5;t.isNullOrUndefined(this.penStrokeWidth)||(b=f=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,f)}}},i.prototype.calcCurveCP=function(e,t,i){t||(t=e),i||(i=t);var o=e.x-t.x,r=e.y-t.y,a=t.x-i.x,n=t.y-i.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,p=(t.x+i.x)/2,h=(t.y+i.y)/2,c=Math.sqrt(o*o+r*r),d=Math.sqrt(a*a+n*n),v=d/(c+d),u=p+(s-p)*v,g=h+(l-h)*v,b=t.x-u,f=t.y-g;return{controlPoint1:this.point(s+b,l+f,0),controlPoint2:this.point(p+b,h+f,0)}},i.prototype.point=function(e,t,i){return this.fhdObj.pointX=e,this.fhdObj.pointY=t,{x:this.fhdObj.pointX,y:this.fhdObj.pointY,time:i}},i.prototype.startDraw=function(e,t,i,o,r,a,n){var s;s=.7*(s=this.pointVelocity(o))+(1-.7)*this.fhdObj.lastVelocity;var l=Math.max(n/1.7,a);this.drawCurve(this.fhdObj.time,l,e,t,i,o,r,n),this.fhdObj.lastVelocity=s,this.fhdObj.time=l},i.prototype.pointVelocity=function(e){return this.fhdObj.time!==e.time?this.distanceTo(e)/(this.fhdObj.time-e.time):0},i.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.fhdObj.pointX-e.x,2)+Math.pow(this.fhdObj.pointY-e.y,2))},i.prototype.drawCurve=function(e,t,i,o,r,a,n,s){var l,p,h,c,d,v,u,g,b,f,m=t-e,C=this.bezierLength(o,r,a,n),y=2*Math.ceil(C);for(i.beginPath(),p=0;p<y;p++)d=(c=(h=p/y)*h)*h,b=(g=(u=(v=1-h)*v)*v)*a.x,b+=3*u*h*o.x,b+=3*v*c*r.x,b+=d*n.x,f=g*a.y,f+=3*u*h*o.y,f+=3*v*c*r.y,f+=d*n.y,l=Math.min(e+d*m,s),this.drawArc(b,f,l,i);i.closePath(),i.fill()},i.prototype.bezierLength=function(e,t,i,o){var r,a,n,s,l,p,h,c,d=0;for(r=0;r<=10;r++)a=r/10,n=this.bezierPoint(a,i.x,e.x,t.x,o.x),s=this.bezierPoint(a,i.y,e.y,t.y,o.y),r>0&&(h=n-l,c=s-p,d+=Math.sqrt(h*h+c*c)),l=n,p=s;return d},i.prototype.bezierPoint=function(e,t,i,o,r){return t*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*o*(1-e)*e*e+r*e*e*e},i.prototype.drawArc=function(e,t,i,o){(e>this.parent.img.destLeft&&t>this.parent.img.destTop&&e<this.parent.img.destLeft+this.parent.img.destWidth&&t<this.parent.img.destTop+this.parent.img.destHeight||o!==this.lowerContext&&o!==this.upperContext)&&(o.moveTo(e,t),o.arc(e,t,i,0,2*Math.PI,!1))},i.prototype.freehandRedraw=function(e,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=e.filter;if(e.filter="none",i&&(o.pointColl[o.freehandCounter]={},o.pointColl[o.freehandCounter].points=i,o.pointColl[o.freehandCounter].strokeColor=o.activeObj.strokeSettings.strokeColor,o.pointColl[o.freehandCounter].strokeWidth=this.penStrokeWidth,o.pointColl[o.freehandCounter].flipState=o.transform.currFlipState,o.freehandCounter++),o.freehandCounter>0){for(var a=0;a<o.freehandCounter;a++){o.points=t.extend([],o.pointColl[a].points),this.pointCounter=0;var n=o.points.length,s=void 0,l=void 0,p=void 0,h=void 0,c=void 0,d=void 0;n>0&&(e.fillStyle=o.pointColl[a].strokeColor,c=d=this.penStrokeWidth=o.pointColl[a].strokeWidth),1===n&&(s=l=p=h=o.points[0],this.startDraw(e,s,l,p,h,c,d));for(var v=0;v<n-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(s=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,l=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,p=0===v?o.points[v]:o.points[v+1],h=o.points[v+2],this.startDraw(e,s,l,p,h,c,d));e.closePath()}e!==this.upperContext&&(o.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:o.frameObj.type,preventImg:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height))}e.filter=r},i.prototype.getSqPtFD=function(e,i){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},r=t.extend([],this.selPointColl[e].points,[]);this.parent.points=t.extend([],this.parent.pointColl[e].points),this.pointCounter=0;for(var a=r.length,n=0;n<a;n++)0===o.startX&&0===o.startY&&0===o.endX&&0===o.endY?(o.startX=r[n].x,o.startY=r[n].y,o.endX=r[n].x,o.endY=r[n].y):(o.startX=Math.min(o.startX,r[n].x),o.startY=Math.min(o.startY,r[n].y),o.endX=Math.max(o.endX,r[n].x),o.endY=Math.max(o.endY,r[n].y));return o.startX-=this.penStrokeWidth,o.startY-=this.penStrokeWidth,o.endX+=this.penStrokeWidth,o.endY+=this.penStrokeWidth,o.width=o.endX-o.startX,o.height=o.endY-o.startY,i&&(i.activePoint=o),o},i.prototype.applyPenDraw=function(){var e=this.parent;"freehanddraw"===e.currObjType.shape&&(e.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),e.upperCanvas.style.cursor=e.cursor="default",e.currObjType.shape=""),e.notify("shape",{prop:"clearActObj"})},i.prototype.applyFhd=function(){var e=this.parent,i=e.pointColl[this.fhdSelIdx];"#42a5f5"===i.strokeColor&&(i.strokeColor=this.tempFHDStyles.strokeColor),t.isBlazor()||e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()||e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i&&(i.isSelected=!1),e.notify("selection",{prop:"resetFreehandDrawVariables"}),this.fhdHovIdx=this.fhdSelIdx=null},i.prototype.cancelFhd=function(){var e=this.parent;t.isBlazor()||e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.pointCounter=0,e.pointColl[this.fhdSelIdx]&&(e.pointColl[this.fhdSelIdx].strokeColor=this.tempFHDStyles.strokeColor,e.pointColl[this.fhdSelIdx].strokeWidth=this.tempFHDStyles.strokeWidth,e.pointColl[this.fhdSelIdx].isSelected=!1),this.fhdHovIdx=this.fhdSelIdx=this.fhdSelID=null,e.notify("selection",{prop:"resetFreehandDrawVariables"}),e.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor,e.activeObj.strokeSettings.strokeWidth=this.penStrokeWidth=this.tempFHDStyles.strokeWidth,this.tempFHDStyles={strokeColor:null,strokeWidth:null,fillColor:null},t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},i.prototype.selectFhd=function(t){var i=this.parent;if(i.notify("selection",{prop:"setFreehandDrawEditing",onPropertyChange:!1,value:{bool:!0}}),t||0===t){if(!this.isFHDIdx(t))return;this.fhdSelIdx=this.fhdHovIdx=t,this.hoverFhd(),i.upperCanvas.style.cursor=i.cursor="pointer"}this.fhdSelIdx=this.fhdHovIdx,i.pointColl[this.fhdSelIdx].isSelected=!0,this.fhdSelID=i.pointColl[this.fhdSelIdx].id,"#42a5f5"!==i.pointColl[this.fhdHovIdx].strokeColor&&(i.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor=i.pointColl[this.fhdHovIdx].strokeColor),i.activeObj.strokeSettings.strokeWidth=this.tempFHDStyles.strokeWidth=i.pointColl[this.fhdHovIdx].strokeWidth;var o={bool:!1};if(i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),o.bool){var r={id:"pen_"+(this.fhdSelIdx+1),type:e.ShapeType.FreehandDraw,startX:i.pointColl[this.fhdSelIdx].points[0].x,startY:i.pointColl[this.fhdSelIdx].points[0].y,strokeColor:i.pointColl[this.fhdSelIdx].strokeColor,strokeWidth:i.pointColl[this.fhdSelIdx].strokeWidth,points:i.pointColl[this.fhdSelIdx].points},a={action:"select",previousShapeSettings:r,currentShapeSettings:r};this.triggerShapeChanging(a)}else i.okBtn()},i.prototype.deleteFhd=function(e,i){var o=this.parent;if(this.isFHDIdx(e)){this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);var r=t.extend({},o.pointColl,{},!0),a=t.extend({},this.selPointColl,{},!0);o.pointColl={},this.selPointColl={};var n=0;if(t.isNullOrUndefined(i))for(var s=0;s<o.freehandCounter;s++)s!==e&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);else for(s=0;s<o.freehandCounter;s++)parseInt(r[s].id.split("_")[1],10)-1!==e&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);o.freehandCounter-=1,this.fhdHovIdx=this.fhdSelIdx=null,o.notify("selection",{prop:"resetFreehandDrawVariables"}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.zoomX=function(e){return e*this.parent.img.destWidth+this.parent.img.destLeft},i.prototype.zoomY=function(e){return e*this.parent.img.destHeight+this.parent.img.destTop},i.prototype.zoomFHDColl=function(e){for(var i=this.parent,o=0;o<i.freehandCounter;o++){i.points=t.extend([],i.pointColl[o].points,[]),this.pointCounter=0;for(var r=i.points.length,a=0;a<r;a++)i.points[a].x=this.zoomX(i.points[a].ratioX),i.points[a].y=this.zoomY(i.points[a].ratioY)}this.updateFHDCurPts(),t.isNullOrUndefined(e)&&this.freehandRedraw(this.lowerContext,null)},i.prototype.updateFHDCurPts=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x=this.zoomX(this.selPoints[r].ratioX),this.selPoints[r].y=this.zoomY(this.selPoints[r].ratioY)}},i.prototype.rotateFhdColl=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].y=e.img.destTop+e.img.destHeight*e.points[r].ratioX,e.points[r].x=e.img.destLeft+e.img.destWidth-e.img.destWidth*e.points[r].ratioY,e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y=e.img.destTop+e.img.destHeight*this.selPoints[r].ratioX,this.selPoints[r].x=e.img.destLeft+e.img.destWidth-e.img.destWidth*this.selPoints[r].ratioY,this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.flipFHDColl=function(e){var t=e.toLowerCase();if("horizontal"===t)this.pointsHorizontalFlip();else if("vertical"===t)this.pointsVerticalFlip();else{this.pointsHorizontalFlip();for(var i=0;i<this.parent.freehandCounter;i++)this.parent.pointColl[i].shapeFlip="";this.pointsVerticalFlip()}},i.prototype.pointsHorizontalFlip=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(e.pointColl[i].shapeFlip!==e.transform.currFlipState){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].x<=e.img.destLeft+e.img.destWidth/2?e.points[r].x=e.img.destLeft+e.img.destWidth-(e.points[r].x-e.img.destLeft):e.points[r].x>=e.img.destLeft+e.img.destWidth/2&&(e.points[r].x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-e.points[r].x)),e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight;e.pointColl[i].shapeFlip=e.transform.currFlipState}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==e.transform.currFlipState){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x<=e.img.destLeft+e.img.destWidth/2?this.selPoints[r].x=e.img.destLeft+e.img.destWidth-(this.selPoints[r].x-e.img.destLeft):this.selPoints[r].x>=e.img.destLeft+e.img.destWidth/2&&(this.selPoints[r].x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-this.selPoints[r].x)),this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.pointsVerticalFlip=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(e.pointColl[i].shapeFlip!==e.transform.currFlipState){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].y<=e.img.destTop+e.img.destHeight/2?e.points[r].y=e.img.destTop+e.img.destHeight-(e.points[r].y-e.img.destTop):e.points[r].y>=e.img.destTop+e.img.destHeight/2&&(e.points[r].y=e.img.destTop+(e.img.destTop+e.img.destHeight-e.points[r].y)),e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight;e.pointColl[i].shapeFlip=e.transform.currFlipState}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==e.transform.currFlipState){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y<=e.img.destTop+e.img.destHeight/2?this.selPoints[r].y=e.img.destTop+e.img.destHeight-(this.selPoints[r].y-e.img.destTop):this.selPoints[r].y>=e.img.destTop+e.img.destHeight/2&&(this.selPoints[r].y=e.img.destTop+(e.img.destTop+e.img.destHeight-this.selPoints[r].y)),this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.updateFHDColl=function(){for(var e=this.parent,i=0;i<e.objColl.length;i++){if(e.objColl[i].imageRatio={startX:(e.objColl[i].activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(e.objColl[i].activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(e.objColl[i].activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(e.objColl[i].activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/e.objColl[i].activePoint.width,height:e.img.destHeight/e.objColl[i].activePoint.height},"path"===e.objColl[i].shape)for(var o=0;o<e.objColl[i].pointColl.length;o++)e.objColl[i].pointColl[o].ratioX=(e.objColl[i].pointColl[o].x-e.img.destLeft)/e.img.destWidth,e.objColl[i].pointColl[o].ratioY=(e.objColl[i].pointColl[o].y-e.img.destTop)/e.img.destHeight;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})}for(var r=0;r<e.freehandCounter;r++){e.points=t.extend([],e.pointColl[r].points,[]),this.pointCounter=0;for(var a=e.points.length,n=0;n<a;n++)e.points[n].ratioX=(e.points[n].x-e.img.destLeft)/e.img.destWidth,e.points[n].ratioY=(e.points[n].y-e.img.destTop)/e.img.destHeight}for(r=0;r<e.freehandCounter;r++)if(this.selPointColl[r]){this.selPoints=t.extend([],this.selPointColl[r].points,[]),this.pointCounter=0;for(a=this.selPoints.length,n=0;n<a;n++)this.selPoints[n].ratioX=(this.selPoints[n].x-e.img.destLeft)/e.img.destWidth,this.selPoints[n].ratioY=(this.selPoints[n].y-e.img.destTop)/e.img.destHeight}},i.prototype.panFHDColl=function(e,i,o){for(var r=this.parent,a=0;a<r.freehandCounter;a++){r.points=t.extend([],r.pointColl[a].points,[]),this.pointCounter=0;for(var n=r.points.length,s=0;s<n;s++)""===o||"vertical"===o?r.points[s].x+=e:r.points[s].x-=e,""===o||"horizontal"===o?r.points[s].y+=i:r.points[s].y-=i}for(a=0;a<r.freehandCounter;a++)if(this.selPointColl[a]){this.selPoints=t.extend([],this.selPointColl[a].points,[]),this.pointCounter=0;for(n=this.selPoints.length,s=0;s<n;s++)""===o||"vertical"===o?this.selPoints[s].x+=e:this.selPoints[s].x-=e,""===o||"horizontal"===o?this.selPoints[s].y+=i:this.selPoints[s].y-=i}this.freehandRedraw(this.lowerContext,null)},i.prototype.freeHandDraw=function(e){var i=this.parent;if(e){if(i.points=[],this.dummyPoints=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.togglePen=!0,i.upperCanvas.style.cursor=i.cursor="crosshair",i.upperCanvas.style.display="block",t.isNullOrUndefined(i.activeObj.strokeSettings)){var o={strokeSettings:{}};i.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:o}}),i.activeObj.strokeSettings=o.strokeSettings}t.isNullOrUndefined(i.activeObj.strokeSettings.strokeWidth)&&(i.activeObj.strokeSettings.strokeWidth=4),t.isBlazor()?i.updateToolbar(i.element,"pen"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}else i.upperCanvas.style.cursor=i.cursor="default",i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}})),i.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},i.prototype.isFHDIdx=function(e,t){for(var i=!1,o=0;o<this.parent.freehandCounter;o++)if(this.parent.pointColl[o].id&&parseInt(this.parent.pointColl[o].id.split("_")[1],10)-1===e){i=!0;break}return t&&(t.isIndex=i),i},i.prototype.updateCropPtsForSel=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){var o={selPointColl:t.extend([],this.selPointColl)};if(o.selPointColl[i]){this.selPoints=t.extend([],o.selPointColl[i].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-e.activeObj.activePoint.startX)/e.activeObj.activePoint.width,this.selPoints[a].ratioY=(this.selPoints[a].y-e.activeObj.activePoint.startY)/e.activeObj.activePoint.height}}},i.prototype.triggerShapeChanging=function(e){var i=this,o=this.parent;t.isBlazor()&&o.events&&!0===o.events.shapeChanging.hasDelegate?o.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",e).then(function(e){o.activeObj.strokeSettings.strokeColor=e.currentShapeSettings.strokeColor,i.penStrokeWidth=e.currentShapeSettings.strokeWidth,i.fhdSelID&&(o.pointColl[i.fhdSelIdx].strokeColor=e.currentShapeSettings.strokeColor,o.pointColl[i.fhdSelIdx].strokeWidth=e.currentShapeSettings.strokeWidth,o.pointColl[i.fhdSelIdx].points=e.currentShapeSettings.points),"select"===e.action&&(i.freehandRedraw(i.upperContext),o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"pen"))}):(o.trigger("shapeChanging",e),o.activeObj.strokeSettings.strokeColor=e.currentShapeSettings.strokeColor,this.penStrokeWidth=e.currentShapeSettings.strokeWidth,this.fhdSelID&&(o.pointColl[this.fhdSelIdx].strokeColor=e.currentShapeSettings.strokeColor,o.pointColl[this.fhdSelIdx].strokeWidth=e.currentShapeSettings.strokeWidth,o.pointColl[this.fhdSelIdx].points=e.currentShapeSettings.points),"select"===e.action&&(this.freehandRedraw(this.upperContext),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})))},i}(),c=function(){function i(e){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=!1,this.isObjSelected=!1,this.isFhdPoint=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.isShapeInserted=!1,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.cursorTargetId="",this.isPreventDragging=!1,this.dragElement="",this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.isFhdEditing=!1,this.currentDrawingShape="",this.initialPrevObj={},this.touchTime=0,this.resizedElement="",this.isImageClarity=!0,this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("selection",this.selection,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("selection",this.selection),this.parent.off("destroyed",this.destroy)},i.prototype.selection=function(e){var t=this;switch(this.updatePrivateVariables(),e.prop){case"mouse-up":this.selMouseUpEvent();break;case"setCursor":this.setCursor(e.value.x,e.value.y);break;case"updateActivePoint":this.updateActivePoint(e.value.x,e.value.y,e.value.isCropSelection);break;case"updateCursorStyles":this.updateCursorStyles(e.value.x,e.value.y,e.value.type);break;case"setTextSelection":this.setTextSelection(e.value.width,e.value.height);break;case"setActivePoint":this.setActivePoint(e.value.startX,e.value.startY);break;case"clearSelection":this.clearSelection();break;case"calcShapeRatio":this.calcShapeRatio(e.value.x,e.value.y,e.value.imgWidth,e.value.imgHeight);break;case"applyCurrShape":this.applyCurrShape(e.value.isShapeClick);break;case"tab":this.performTabAction();break;case"setDragDirection":this.setDragDirection(e.value.width,e.value.height);break;case"clearUpperCanvas":this.isTouch&&setTimeout(function(){t.parent.upperCanvas.getContext("2d").clearRect(0,0,t.parent.upperCanvas.width,t.parent.upperCanvas.height)},550);break;case"resetFreehandDrawVariables":this.isFhdEditing=this.isFhdPoint=!1;break;case"isShapeInserted":this.isShapeInserted=e.value.bool;break;case"redrawShape":this.redrawShape(e.value.obj);break;case"setTextBoxStylesToActObj":this.setTextBoxStylesToActObj();break;case"mouseDownEventHandler":this.mouseDownEventHandler(e.value.e);break;case"mouseMoveEventHandler":this.mouseMoveEventHandler(e.value.e);break;case"mouseUpEventHandler":this.mouseUpEventHandler(e.value.e);break;case"canvasMouseDownHandler":this.canvasMouseDownHandler(e.value.e);break;case"canvasMouseMoveHandler":this.canvasMouseMoveHandler(e.value.e);break;case"canvasMouseUpHandler":this.canvasMouseUpHandler(e.value.e);break;case"touchStartHandler":this.touchStartHandler(e.value.e);break;case"keyDownEventHandler":this.keyDownEventHandler(e.value.e);break;case"handleScroll":this.handleScroll(e.value.e);break;case"textKeyDown":setTimeout(this.textKeyDown.bind(this),1,e.value.e);break;case"deleteItem":this.deleteItem();break;case"updatePrevShapeSettings":this.updatePrevShapeSettings(e.value.obj);break;case"getZoomType":e.value.obj.zoomType=this.zoomType;break;case"setZoomType":this.zoomType=e.value.zoomType;break;case"setInitialTextEdit":this.isInitialTextEdited=e.value.bool;break;case"setDragCanvas":this.dragCanvas=e.value.bool;break;case"setFreehandDrawCustomized":this.isFhdCustomized=e.value.isFreehandDrawCustomized;break;case"setTouchEndPoint":this.touchEndPoint.x=e.value.x,this.touchEndPoint.y=e.value.y;break;case"getPanDown":e.value.obj.panDown=this.panDown;break;case"setPanDown":this.panDown=e.value.panDown;break;case"getFreehandDrawEditing":e.value.obj.bool=this.isFhdEditing;break;case"setFreehandDrawEditing":this.isFhdEditing=e.value.bool;break;case"getTempActObj":e.value.obj.tempObj=this.tempActiveObj;break;case"setTempActObj":this.tempActiveObj=e.value.obj;break;case"isInside":this.isInside(e.value.x,e.value.y,e.value.z1,e.value.z2,e.value.z3,e.value.z4);break;case"setDragElement":this.dragElement=e.value.value;break;case"setObjSelected":this.isObjSelected=e.value.bool;break;case"adjustActObjForLineArrow":this.adjustActObjForLineArrow(e.value.obj);break;case"findTarget":this.findTarget(e.value.x,e.value.y,e.value.type);break;case"getCurrentFlipState":this.getCurrentFlipState();break;case"setDragWidth":this.setDragWidth(e.value.width);break;case"setDragHeight":this.setDragHeight(e.value.setDragHeight);break;case"annotate":this.currentDrawingShape=e.value.shape,"text"===e.value.shape?(this.parent.activeObj.textSettings.fontSize=100,this.parent.activeObj.keyHistory="Enter Text",this.parent.notify("shape",{prop:"initializeTextShape",onPropertyChange:!1,value:{text:null,fontFamily:null,fontSize:null,bold:null,italic:null,strokeColor:null}})):"path"===e.value.shape&&(this.parent.activeObj.pointColl=[]);break;case"getCurrentDrawingShape":e.value.obj.shape=this.currentDrawingShape;break;case"setCurrentDrawingShape":this.currentDrawingShape=e.value.value;break;case"getTransRotationPoint":this.getTransRotationPoint(e.value.obj,e.value.object);break;case"adjustNEPoints":this.adjustNEPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"adjustRotationPoints":this.adjustRotationPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"getResizeDirection":this.getResizeDirection(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"setResizedElement":this.resizedElement=e.value.value;break;case"reset":this.reset();break;case"unWireEvent":this.unwireEvent();break;case"updPtCollForShpRot":this.updPtCollForShpRot(e.value.obj);break;case"findImageRatio":this.findImageRatio(e.value.width,e.value.height,e.value.obj);break;case"getNumTextValue":this.getNumTextValue(e.value.obj);break;case"setImageClarity":this.isImageClarity=e.value.bool;break;case"upgradeImageQuality":this.upgradeImageQuality();break;case"triggerShapeChange":this.triggerShapeChange(e.value.shapeResizingArgs,e.value.shapeMovingArgs,e.value.type)}},i.prototype.getModuleName=function(){return"selection"},i.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=this.isObjSelected=this.isFhdPoint=this.isShapeInserted=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.cursorTargetId=this.dragElement="",this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.isPreventDragging=!1,this.timer=void 0,this.tempObjColl=void 0,this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.panDown=null,this.isFhdEditing=!1,this.pathAdjustedIndex=null,this.touchTime=0,this.isImageClarity=!0,this.currentDrawingShape="",this.initialPrevObj={},this.resizedElement=""},i.prototype.performTabAction=function(){if("block"===this.parent.textArea.style.display){var e=this.applyCurrShape(!1);this.parent.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e&&this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},i.prototype.selMouseUpEvent=function(){this.oldPoint.x=void 0,this.oldPoint.y=void 0},i.prototype.getMouseCursor=function(e,t,i,o,r){var a=this.getTransRotationPoint(e),n=r?0:2*e.topLeftCircle.radius;return t>=e.topLeftCircle.startX-n&&t<=e.topLeftCircle.startX+n&&i>=e.topLeftCircle.startY-n&&i<=e.topLeftCircle.startY+n?"nw-resize":t>=e.topLeftCircle.startX-n&&t<=e.topRightCircle.startX-n&&i>=e.topCenterCircle.startY-n&&i<=e.topCenterCircle.startY+n?"n-resize":t>=e.topRightCircle.startX-n&&t<=e.topRightCircle.startX+n&&i>=e.topRightCircle.startY-n&&i<=e.topRightCircle.startY+n?"ne-resize":t>=e.centerLeftCircle.startX-n&&t<=e.centerLeftCircle.startX+n&&i>=e.topLeftCircle.startY-n&&i<=e.bottomLeftCircle.startY-n?"w-resize":t>=e.centerRightCircle.startX-n&&t<=e.centerRightCircle.startX+n&&i>=e.topRightCircle.startY-n&&i<=e.bottomRightCircle.startY-n?"e-resize":t>=e.bottomLeftCircle.startX-n&&t<=e.bottomLeftCircle.startX+n&&i>=e.bottomLeftCircle.startY-n&&i<=e.bottomLeftCircle.startY+n?"sw-resize":t>=e.bottomLeftCircle.startX-n&&t<=e.bottomRightCircle.startX-n&&i>=e.bottomCenterCircle.startY-n&&i<=e.bottomCenterCircle.startY+n?"s-resize":t>=e.bottomRightCircle.startX-n&&t<=e.bottomRightCircle.startX+n&&i>=e.bottomRightCircle.startY-n&&i<=e.bottomRightCircle.startY+n?"se-resize":t>=e.activePoint.startX&&t<=e.activePoint.endX&&i>=e.activePoint.startY&&i<=e.activePoint.endY?o?"grab":"move":a&&!r&&t>=a.x-(e.bottomCenterCircle.radius+2)&&t<=a.x+(e.bottomCenterCircle.radius+2)&&i>=a.y-(e.bottomCenterCircle.radius+2)&&i<=a.y+(e.bottomCenterCircle.radius+2)?"grabbing":"default"},i.prototype.setCursor=function(e,i){var o=this.parent,r={bool:null};if(o.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:r}}),o.isResize||r.bool)o.upperCanvas.style.cursor="default";else{var a,n=document.querySelector("#"+o.element.id+"_lowerCanvas"),s=document.querySelector("#"+o.element.id+"_upperCanvas"),l=!1;if(""===this.currentDrawingShape)if(o.currObjType.isDragging)""===this.dragElement?s.style.cursor=o.cursor="move":s.style.cursor=o.cursor=this.dragElement;else{if(void 0!==o.activeObj.horTopLine){void 0!==o.activeObj.shape&&(a=o.activeObj.shape.split("-")),void 0===a&&o.currObjType.isCustomCrop?l=!0:void 0!==a&&"crop"===a[0]&&(l=!0),!l&&o.togglePan&&(n.style.cursor=s.style.cursor=o.cursor="grab");var p=s.style.cursor,h=t.extend({},o.activeObj,{},!0);this.cursorTargetId=h.currIndex;var c=void 0;(c=0===h.shapeDegree?o.transform.degree:o.transform.degree-h.shapeDegree)<0&&(c=360+c),"line"===h.shape||"arrow"===h.shape?this.setCursorForLineArrow(h,e,i,s):"path"===h.shape?this.setCursorForPath(h,e,i,s):t.isNullOrUndefined(h.rotatedAngle)||0===h.rotatedAngle?(s.style.cursor=o.cursor=this.getMouseCursor(h,e,i,l,!1),"text"!==h.shape||"n-resize"!==o.cursor&&"s-resize"!==o.cursor&&"e-resize"!==o.cursor&&"w-resize"!==o.cursor||(s.style.cursor=o.cursor="move")):this.setCursorForRotatedObject(h,e,i,s),"default"===p&&"default"===o.cursor&&l&&(s.style.cursor=o.cursor="grab"),"grab"===p&&"default"===o.cursor&&(s.style.cursor=o.cursor="grab")}else o.togglePan&&!o.togglePen?n.style.cursor=s.style.cursor=o.cursor="grab":o.currObjType.isCustomCrop||o.togglePen?s.style.cursor=o.cursor="crosshair":s.style.cursor=o.cursor="default";if("default"===o.cursor||"grab"===o.cursor){p=s.style.cursor;o.objColl.length>0&&("grab"!==o.cursor||!l)&&this.setCursorFromObj(e,i,o.objColl,s,l),"grab"===p&&"default"===o.cursor&&(s.style.cursor=o.cursor="grab")}"default"!==o.cursor&&"grab"!==o.cursor||!o.pointColl[0]||"grab"===o.cursor&&l||o.currObjType.isDragging||o.currObjType.isResize||this.setCursorForFreehandDrawing(e,i,s)}else s.style.cursor=o.cursor="crosshair"}},i.prototype.setCursorForPath=function(e,i,o,r){this.setCursorForLineArrow(e,i,o,r);var a=this.parent;if("default"===a.cursor)for(var n=t.extend({},e,null,!0),s=!1,l=1;l<e.pointColl.length&&!s;l++){n.activePoint.startX=e.pointColl[l-1].x,n.activePoint.startY=e.pointColl[l-1].y,n.activePoint.endX=e.pointColl[l].x,n.activePoint.endY=e.pointColl[l].y,a.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:n}});for(var p=0;p<n.pointColl.length;p++){var h=n.pointColl[p];if(!t.isNullOrUndefined(h.x-2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.x+2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.y-2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.y+2*e.topLeftCircle.radius)&&i>=h.x-2*e.topLeftCircle.radius&&i<=h.x+2*e.topLeftCircle.radius&&o>=h.y-2*e.topLeftCircle.radius&&o<=h.y+2*e.topLeftCircle.radius){r.style.cursor=a.cursor="move",s=!0;break}r.style.cursor=a.cursor="default"}}return a.cursor},i.prototype.setCursorForLineArrow=function(e,t,i,o){for(var r,a=0;a<e.pointColl.length;a++){var n=e.pointColl[a];if(t>=n.x-2*e.topLeftCircle.radius&&t<=n.x+2*e.topLeftCircle.radius&&i>=n.y-2*e.topLeftCircle.radius&&i<=n.y+2*e.topLeftCircle.radius){o.style.cursor=this.parent.cursor="move",r=a;break}o.style.cursor=this.parent.cursor="default"}return r},i.prototype.setCursorForRotatedObject=function(e,t,i,o){this.resizedElement="";var r=this.parent;if(t>=e.horTopLinePointColl[0].x-(e.bottomCenterCircle.radius+2)&&t<=e.horTopLinePointColl[0].x+(e.bottomCenterCircle.radius+2)&&i>=e.horTopLinePointColl[0].y-(e.bottomCenterCircle.radius+2)&&i<=e.horTopLinePointColl[0].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="nw-resize";else if(t>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].x-5&&t<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].x+5&&i>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].y-5&&i<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="n-resize";else if(t>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].x-(e.bottomCenterCircle.radius+2)&&t<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].x+(e.bottomCenterCircle.radius+2)&&i>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].y-(e.bottomCenterCircle.radius+2)&&i<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="ne-resize";else if(t>=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].x-5&&t<=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].x+5&&i>=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].y-5&&i<=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="w-resize";else if(t>=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].x-5&&t<=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].x+5&&i>=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].y-5&&i<=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="e-resize";else if(t>=e.horBottomLinePointColl[0].x-(e.bottomCenterCircle.radius+2)&&t<=e.horBottomLinePointColl[0].x+(e.bottomCenterCircle.radius+2)&&i>=e.horBottomLinePointColl[0].y-(e.bottomCenterCircle.radius+2)&&i<=e.horBottomLinePointColl[0].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="sw-resize";else if(t>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].x-5&&t<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].x+5&&i>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].y-5&&i<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="s-resize";else if(t>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].x-(e.bottomCenterCircle.radius+2)&&t<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].x+(e.bottomCenterCircle.radius+2)&&i>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].y-(e.bottomCenterCircle.radius+2)&&i<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="se-resize";else if(e.rotationCirclePointColl&&t>=e.rotationCirclePointColl.x-(e.bottomCenterCircle.radius+2)&&t<=e.rotationCirclePointColl.x+(e.bottomCenterCircle.radius+2)&&i>=e.rotationCirclePointColl.y-(e.bottomCenterCircle.radius+2)&&i<=e.rotationCirclePointColl.y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="grabbing";else{o.style.cursor=r.cursor="default";this.getRectanglePoints(e.activePoint.startX,e.activePoint.startY,e.activePoint.width,e.activePoint.height,e.rotatedAngle*(180/Math.PI),t,i)&&(o.style.cursor=r.cursor="move")}if("default"===r.cursor)for(var a=0,n=e.horTopLinePointColl.length;a<n;a++)if(t>=e.horTopLinePointColl[a].x-5&&t<=e.horTopLinePointColl[a].x+5&&i>=e.horTopLinePointColl[a].y-5&&i<=e.horTopLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="n-resize";break}if("default"===r.cursor)for(a=0,n=e.horBottomLinePointColl.length;a<n;a++)if(t>=e.horBottomLinePointColl[a].x-5&&t<=e.horBottomLinePointColl[a].x+5&&i>=e.horBottomLinePointColl[a].y-5&&i<=e.horBottomLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="s-resize";break}if("default"===r.cursor)for(a=0,n=e.verLeftLinePointColl.length;a<n;a++)if(t>=e.verLeftLinePointColl[a].x-5&&t<=e.verLeftLinePointColl[a].x+5&&i>=e.verLeftLinePointColl[a].y-5&&i<=e.verLeftLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="w-resize";break}if("default"===r.cursor)for(a=0,n=e.verRightLinePointColl.length;a<n;a++)if(t>=e.verRightLinePointColl[a].x-5&&t<=e.verRightLinePointColl[a].x+5&&i>=e.verRightLinePointColl[a].y-5&&i<=e.verRightLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="e-resize";break}return this.adjustCursorStylesForRotatedState(e),r.cursor},i.prototype.adjustCursorStylesForRotatedState=function(e){var t=this.parent,i=e.rotatedAngle*(180/Math.PI);if((i=i>0?Math.floor(i):Math.ceil(i))>=92&&i<=182||i>=-178&&i<=-88){var o={"nw-resize":"ne-resize","n-resize":"s-resize","ne-resize":"nw-resize","w-resize":"e-resize","e-resize":"w-resize","sw-resize":"se-resize","s-resize":"n-resize","se-resize":"sw-resize"};t.cursor in o&&(t.cursor=o[t.cursor])}return t.upperCanvas.style.cursor=this.getResizeElement(e.rotatedAngle*(180/Math.PI),t.cursor),t.cursor},i.prototype.getResizeElement=function(e,t){var i=[];"nw-resize"===t?i=[[337.5,22.5,"nw-resize"],[22.5,67.5,"n-resize"],[67.5,112.5,"ne-resize"],[112.5,157.5,"e-resize"],[157.5,202.5,"se-resize"],[202.5,247.5,"s-resize"],[247.5,292.5,"sw-resize"],[292.5,337.5,"w-resize"]]:"n-resize"===t?i=[[337.5,22.5,"n-resize"],[22.5,67.5,"ne-resize"],[67.5,112.5,"e-resize"],[112.5,157.5,"se-resize"],[157.5,202.5,"s-resize"],[202.5,247.5,"sw-resize"],[247.5,292.5,"w-resize"],[292.5,337.5,"nw-resize"]]:"ne-resize"===t?i=[[337.5,22.5,"ne-resize"],[22.5,67.5,"e-resize"],[67.5,112.5,"se-resize"],[112.5,157.5,"s-resize"],[157.5,202.5,"sw-resize"],[202.5,247.5,"w-resize"],[247.5,292.5,"nw-resize"],[292.5,337.5,"n-resize"]]:"e-resize"===t?i=[[337.5,22.5,"e-resize"],[22.5,67.5,"se-resize"],[67.5,112.5,"s-resize"],[112.5,157.5,"sw-resize"],[157.5,202.5,"w-resize"],[202.5,247.5,"nw-resize"],[247.5,292.5,"n-resize"],[292.5,337.5,"ne-resize"]]:"se-resize"===t?i=[[337.5,22.5,"se-resize"],[22.5,67.5,"s-resize"],[67.5,112.5,"sw-resize"],[112.5,157.5,"w-resize"],[157.5,202.5,"nw-resize"],[202.5,247.5,"n-resize"],[247.5,292.5,"ne-resize"],[292.5,337.5,"e-resize"]]:"s-resize"===t?i=[[337.5,22.5,"s-resize"],[22.5,67.5,"sw-resize"],[67.5,112.5,"w-resize"],[112.5,157.5,"nw-resize"],[157.5,202.5,"n-resize"],[202.5,247.5,"ne-resize"],[247.5,292.5,"e-resize"],[292.5,337.5,"se-resize"]]:"sw-resize"===t?i=[[337.5,22.5,"sw-resize"],[22.5,67.5,"w-resize"],[67.5,112.5,"nw-resize"],[112.5,157.5,"n-resize"],[157.5,202.5,"ne-resize"],[202.5,247.5,"e-resize"],[247.5,292.5,"se-resize"],[292.5,337.5,"s-resize"]]:"w-resize"===t&&(i=[[337.5,22.5,"w-resize"],[22.5,67.5,"nw-resize"],[67.5,112.5,"n-resize"],[112.5,157.5,"ne-resize"],[157.5,202.5,"e-resize"],[202.5,247.5,"se-resize"],[247.5,292.5,"s-resize"],[292.5,337.5,"sw-resize"]]);for(var o=e<0?360-Math.abs(e):e,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return t},i.prototype.setCursorForFreehandDrawing=function(e,i,o){var r=o.getContext("2d"),a=this.parent,n=document.querySelector("#"+a.element.id+"_textArea"),s=!1;a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:-1}});for(var l,p=0;p<a.freehandCounter;p++){var h={selPointColl:{}};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),l=t.extend([],h.selPointColl[p].points,[]),a.points=t.extend([],a.pointColl[p].points,[]),a.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var c=l.length,d=0;d<c;d++)if(0!==d){var v=!1;if(l[d-1]&&l[d]&&(v=this.isInside(e,i,l[d-1].x,l[d-1].y,l[d].x,l[d].y)),v){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){var u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}else a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:null}});this.isFhdPoint=!1}}else{if(e>a.points[d].x-a.pointColl[p].strokeWidth&&e<a.points[d].x+a.pointColl[p].strokeWidth&&i>a.points[d].y-a.pointColl[p].strokeWidth&&i<a.points[d].y+a.pointColl[p].strokeWidth){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}this.isFhdPoint=!1}}if(s)break}},i.prototype.setCursorFromObj=function(e,i,o,r,a){for(var n=this.parent,s=0,l=o.length;s<l;s++){if("move"===n.cursor)return;var p=t.extend({},o[s],{},!0);this.cursorTargetId=p.currIndex,"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,e,i,r):"path"===p.shape?this.setCursorForPath(p,e,i,r):t.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?r.style.cursor=n.cursor=this.getMouseCursor(p,e,i,a,!0):this.setCursorForRotatedObject(p,e,i,r)}},i.prototype.isInside=function(e,t,i,o,r,a){var n=Math.min(i,r),s=Math.max(i,r),l=Math.min(o,a),p=Math.max(o,a);return n<=e&&e<=s&&l<=t&&t<=p},i.prototype.updateActivePoint=function(e,i,o){var r=this.parent,a={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.activeObj.activePoint.width,height:r.activeObj.activePoint.height,obj:a,isImgShape:null}});var n=a,s=this.updatePrevShapeSettings(),l={action:"resize",previousShapeSettings:s},p={action:"move",previousShapeSettings:s};this.shapeResizingArgs=l,this.shapeMovingArgs=p,"text"===r.activeObj.shape&&""!==this.dragElement&&r.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:r.activeObj,isTextArea:null}}),""===this.currentDrawingShape||""!==this.dragElement&&"move"!==this.dragElement||("line"===r.activeObj.shape||"arrow"===r.activeObj.shape||"path"===r.activeObj.shape?this.dragElement="e-resize":e>r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="se-resize":e<r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="sw-resize":e>r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY?this.dragElement="ne-resize":e<r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY&&(this.dragElement="nw-resize")),"arrow"===r.activeObj.shape&&(Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)>0?r.activeObj.rotatedAngle=-Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2):r.activeObj.rotatedAngle=Math.abs(Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)));var h,c=!1,d=!1;switch(this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"n-resize":this.updateNPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"ne-resize":this.updateNEPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"w-resize":this.updateWPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"e-resize":this.updateEPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"sw-resize":this.updateSWPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"s-resize":this.updateSPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"se-resize":this.updateSEPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"grabbing":Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))>0?r.activeObj.rotatedAngle=-Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2)):r.activeObj.rotatedAngle=Math.abs(Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))),(h=0===r.activeObj.shapeDegree?r.transform.degree:r.transform.degree-r.activeObj.shapeDegree)<0&&(h=360+h);for(var v=0,u=r.activeObj.flipObjColl.length;v<u;v++)"horizontal"===r.activeObj.flipObjColl[v].toLowerCase()?c=!0:"vertical"===r.activeObj.flipObjColl[v].toLowerCase()&&(d=!0);r.activeObj.rotatedAngle-=h*(Math.PI/180),0===h||360===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):90===h||-270===h?c&&(r.activeObj.rotatedAngle-=Math.PI/180*180):180===h||-180===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):270!==h&&-90!==h||c&&(r.activeObj.rotatedAngle-=Math.PI/180*180);break;case"pathdrag":t.isNullOrUndefined(this.pathAdjustedIndex)||(r.activeObj.pointColl[this.pathAdjustedIndex].x=e,r.activeObj.pointColl[this.pathAdjustedIndex].y=i);break;default:if(!o&&!r.currObjType.isCustomCrop){if(this.dragPoint.startX){var g=this.dragPoint.endX-this.previousPoint.x,b=this.dragPoint.endY-this.previousPoint.y;if(r.activeObj.activePoint.startX+=g,r.activeObj.activePoint.endX+=g,r.activeObj.activePoint.startY+=b,r.activeObj.activePoint.endY+=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x+=g,r.activeObj.rotationCirclePointColl.y+=b,r.activeObj.rotationCirclePoint.x+=g,r.activeObj.rotationCirclePoint.y+=b),"path"===r.activeObj.shape)for(v=0,u=r.activeObj.pointColl.length;v<u;v++)r.activeObj.pointColl[v].x+=g,r.activeObj.pointColl[v].y+=b;!this.isPreventDragging&&"line"!==r.activeObj.shape&&0===r.activeObj.rotatedAngle&&(r.activeObj.activePoint.startX<r.img.destLeft||r.activeObj.activePoint.startY<r.img.destTop||r.activeObj.activePoint.endX>r.img.destLeft+r.img.destWidth||r.activeObj.activePoint.endY>r.img.destTop+r.img.destHeight)&&(r.activeObj.activePoint.startX-=g,r.activeObj.activePoint.endX-=g,r.activeObj.activePoint.startY-=b,r.activeObj.activePoint.endY-=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x-=g,r.activeObj.rotationCirclePointColl.y-=b,r.activeObj.rotationCirclePoint.x-=g,r.activeObj.rotationCirclePoint.y-=b),this.setDragWidth(g),this.setDragHeight(b))}else r.activeObj.activePoint.startX=e<this.mouseDownPoint.x?e:this.mouseDownPoint.x,r.activeObj.activePoint.startY=i<this.mouseDownPoint.y?i:this.mouseDownPoint.y,e=e<this.mouseDownPoint.x?this.mouseDownPoint.x:e,i=i<this.mouseDownPoint.y?this.mouseDownPoint.y:i,r.activeObj.activePoint.endX=e,r.activeObj.activePoint.endY=i;this.triggerShapeChange(l,p,"move")}}},i.prototype.triggerShapeChange=function(e,i,o){var r=this.parent;r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY;var a=this.updatePrevShapeSettings();if(t.isNullOrUndefined(this.shapeResizingArgs)||t.isNullOrUndefined(this.shapeMovingArgs)?(e.currentShapeSettings=a,i.currentShapeSettings=a):(e.currentShapeSettings=this.shapeResizingArgs.currentShapeSettings=a,i.currentShapeSettings=this.shapeMovingArgs.currentShapeSettings=a),"resize"===o){this.isCropSelection=!1;var n=void 0;if(void 0!==r.activeObj.shape&&(n=r.activeObj.shape.split("-")),void 0!==n&&"crop"===n[0]&&(this.isCropSelection=!0),!this.isCropSelection&&"resize"!==this.parent.eventType&&t.isBlazor()&&r.events&&!0===this.parent.events.onShapeResizeStart.hasDelegate)e.action=""!==this.currentDrawingShape?"drawing":"resize-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeStart",e).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})});else if(this.isCropSelection){var s={action:e.action,previousSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:e.previousShapeSettings.startX,startY:e.previousShapeSettings.startY,width:e.previousShapeSettings.width,height:e.previousShapeSettings.height},currentSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:e.currentShapeSettings.startX,startY:e.currentShapeSettings.startY,width:e.currentShapeSettings.width,height:e.currentShapeSettings.height}};this.selectionResizingArgs=s,t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onSelectionResizeStart.hasDelegate?(s.action="resize-start",r.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(e){r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}})})):(r.trigger("selectionChanging",s),r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}))}else""!==this.currentDrawingShape&&(e.action="drawing"),r.trigger("shapeChanging",e),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}else"mouse-down"===o||"mouse-up"===o?t.isBlazor()&&r.events&&!0===r.events.shapeChanging.hasDelegate?r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",e).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}):(r.trigger("shapeChanging",e),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})):t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onShapeDragStart.hasDelegate?(i.action="drag-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragStart",i).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})})):(r.trigger("shapeChanging",i),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:i.currentShapeSettings}}));this.parent.eventType=o},i.prototype.setDragWidth=function(e){var t=this.parent,i=e;if(i>=0)for(var o=0;o<i&&(e=i-o,t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,!(t.activeObj.activePoint.startX>=t.img.destLeft&&t.activeObj.activePoint.endX<=t.img.destLeft+t.img.destWidth));o++)t.activeObj.activePoint.startX-=e,t.activeObj.activePoint.endX-=e;else for(o=1;o<Math.abs(i)&&(e=i+o,t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,!(t.activeObj.activePoint.startX>=t.img.destLeft&&t.activeObj.activePoint.endX<=t.img.destLeft+t.img.destWidth));o++)t.activeObj.activePoint.startX-=e,t.activeObj.activePoint.endX-=e},i.prototype.setDragHeight=function(e){var t=this.parent,i=e;if(i>=0)for(var o=1;o<i&&(e=i-o,t.activeObj.activePoint.startY+=e,t.activeObj.activePoint.endY+=e,!(t.activeObj.activePoint.startY>=t.img.destTop&&t.activeObj.activePoint.endY<=t.img.destTop+t.img.destHeight));o++)t.activeObj.activePoint.startY-=e,t.activeObj.activePoint.endY-=e;else for(o=0;o<Math.abs(i)&&(e=i+o,t.activeObj.activePoint.startY+=e,t.activeObj.activePoint.endY+=e,!(t.activeObj.activePoint.startY>=t.img.destTop&&t.activeObj.activePoint.endY<=t.img.destTop+t.img.destHeight));o++)t.activeObj.activePoint.startY-=e,t.activeObj.activePoint.endY-=e},i.prototype.limitDrag=function(e){var t=this.parent,i=e?t.activeObj.activePoint.startX:t.activeObj.activePoint.endX,o=e?t.activeObj.activePoint.startY:t.activeObj.activePoint.endY,r=e?t.activeObj.activePoint.endX:t.activeObj.activePoint.startX,a=e?t.activeObj.activePoint.endY:t.activeObj.activePoint.startY;i<t.img.destLeft&&(i=t.img.destLeft),o<t.img.destTop&&(o=t.img.destTop),r>t.img.destLeft+t.img.destWidth&&(r=t.img.destLeft+t.img.destWidth),a>t.img.destTop+t.img.destHeight&&(a=t.img.destTop+t.img.destHeight),e?(t.activeObj.activePoint.startX=i,t.activeObj.activePoint.startY=o,t.activeObj.activePoint.endX=r,t.activeObj.activePoint.endY=a):(t.activeObj.activePoint.startX=r,t.activeObj.activePoint.startY=a,t.activeObj.activePoint.endX=i,t.activeObj.activePoint.endY=o)},i.prototype.preventDraggingInvertly=function(){var e=this.parent;"image"!==e.activeObj.shape&&(this.isPreventDragging||0!==e.activeObj.rotatedAngle||(this.limitDrag(!0),"line"!==e.activeObj.shape&&"arrow"!==e.activeObj.shape&&"path"!==e.activeObj.shape||this.limitDrag(!1)))},i.prototype.preventTextDraggingInvertly=function(){var e=this.parent,t=!1;return this.isPreventDragging||(e.activeObj.activePoint.startX<e.img.destLeft||e.activeObj.activePoint.startY<e.img.destTop||e.activeObj.activePoint.endX>e.img.destLeft+e.img.destWidth||e.activeObj.activePoint.endY>e.img.destTop+e.img.destHeight)&&(t=!0),t},i.prototype.preventInverseResize=function(e){var t=this.parent;t.activeObj.activePoint.width<0&&(t.activeObj.activePoint.width=0,t.activeObj.activePoint.startX=e.activePoint.startX,t.activeObj.activePoint.endX=e.activePoint.endX),t.activeObj.activePoint.height<0&&(t.activeObj.activePoint.height=0,t.activeObj.activePoint.startY=e.activePoint.startY,t.activeObj.activePoint.endY=e.activePoint.endY)},i.prototype.getScaleRatio=function(e){var t=this.parent,i={x:e,y:e};if(t.activeObj.shape&&"crop-custom"!==t.activeObj.shape&&"crop-circle"!==t.activeObj.shape&&"crop-square"!==t.activeObj.shape){var o="image"===t.activeObj.shape?this.findImageRatio(t.activeObj.activePoint.width,t.activeObj.activePoint.height).split("-"):t.activeObj.shape.split("-");if(o.length>1||"image"===t.activeObj.shape){o="image"===t.activeObj.shape?o[0].split(":"):o[1].split(":");var r=e/parseInt(o[1],10);i.x=r*parseInt(o[0],10),i.y=r*parseInt(o[1],10)}}return i},i.prototype.findImageRatio=function(e,t,i){var o=function(e,t){return 0===t?e:o(t,e%t)},r=o(e,t),a=e/r+":"+t/r;return i&&(i.ratio=a),a},i.prototype.updateNWPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=l.activeObj.activePoint.startX-e,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=this.oldPoint.x-e,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"nw-resize",c):this.adjustNWPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){var v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<e&&l.activeObj.activePoint.startY<i){r=e-l.activeObj.activePoint.startX,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.startY+=u.y;var g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.startY-=u.y)}else{r=l.activeObj.activePoint.startX-e,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.startY-=u.y;g=l.img.destLeft>0?l.img.destLeft:0;var f=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.startY<f)&&(l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.startY+=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateNPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.startY>a.activeObj.activePoint.endY){var s=a.activeObj.activePoint.startY;a.activeObj.activePoint.startY=a.activeObj.activePoint.endY,a.activeObj.activePoint.endY=s,this.dragElement=this.resizedElement="s-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.startY<t){i=a.activeObj.activePoint.endX-e,o=t-a.activeObj.activePoint.startY,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y)}else{i=e-a.activeObj.activePoint.endX,o=a.activeObj.activePoint.startY-t,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateNEPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=e-l.activeObj.activePoint.endX,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=e-this.oldPoint.x,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"ne-resize",c):this.adjustNEPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){var v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>e&&l.activeObj.activePoint.startY<i){r=l.activeObj.activePoint.endX-e,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.endX-=u.x,l.activeObj.activePoint.startY+=u.y;var g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.endX+=u.x,l.activeObj.activePoint.startY-=u.y)}else{r=e-l.activeObj.activePoint.endX,a=l.activeObj.activePoint.startY-i,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.endX+=u.x,l.activeObj.activePoint.startY-=u.y;g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.endX-=u.x,l.activeObj.activePoint.startY+=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateWPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startX=e,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.startY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="e-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.startX>a.activeObj.activePoint.endX){var s=a.activeObj.activePoint.startX;a.activeObj.activePoint.startX=a.activeObj.activePoint.endX,a.activeObj.activePoint.endX=s,this.dragElement=this.resizedElement="e-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.startX<e&&a.activeObj.activePoint.endY>t){i=e-a.activeObj.activePoint.startX,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=a.activeObj.activePoint.startX-e,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateEPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endX=e,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.endY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="w-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.endX<a.activeObj.activePoint.startX){var s=a.activeObj.activePoint.endX;a.activeObj.activePoint.endX=a.activeObj.activePoint.startX,a.activeObj.activePoint.startX=s,this.dragElement=this.resizedElement="w-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.endY>t){i=a.activeObj.activePoint.endX-e,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=e-a.activeObj.activePoint.endX,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSWPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)t.isNullOrUndefined(this.oldPoint.x)&&t.isNullOrUndefined(this.oldPoint.y)?(this.diffPoint.x=l.activeObj.activePoint.startX-e,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=this.oldPoint.x-e,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.endY+=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.endY-=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"sw-resize",c):this.adjustSWPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){var v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<e&&l.activeObj.activePoint.endY>i){r=e-l.activeObj.activePoint.startX,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.endY-=u.y;var g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.endY+=u.y)}else{r=l.activeObj.activePoint.startX-e,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.endY+=u.y;g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.endY-=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateSPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.endY<a.activeObj.activePoint.startY){var s=a.activeObj.activePoint.endY;a.activeObj.activePoint.endY=a.activeObj.activePoint.startY,a.activeObj.activePoint.startY=s,this.dragElement=this.resizedElement="n-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.endY>t){i=a.activeObj.activePoint.endX-e,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=e-a.activeObj.activePoint.endX,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.x,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSEPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=e-l.activeObj.activePoint.endX,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=e-this.oldPoint.x,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x>=p&&this.diffPoint.y>=h?Math.max(this.diffPoint.x,this.diffPoint.y):Math.min(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/50*s,l.activeObj.activePoint.endY+=o.height/50*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/50*s,l.activeObj.activePoint.endY-=o.height/50*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0,v=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"se-resize",c):this.adjustSEPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){var u=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=u,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){u=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=u,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>e&&l.activeObj.activePoint.endY>i){r=l.activeObj.activePoint.endX-e,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a),v=this.getScaleRatio(n),l.activeObj.activePoint.endX-=v.x,l.activeObj.activePoint.endY-=v.y;var g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.endX+=v.x,l.activeObj.activePoint.endY+=v.y)}else{r=e-l.activeObj.activePoint.endX,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a),v=this.getScaleRatio(n),l.activeObj.activePoint.endX+=v.x,l.activeObj.activePoint.endY+=v.y;g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.endX-=v.x,l.activeObj.activePoint.endY-=v.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.resizeImg=function(e,i,o,r){var a,n,s=this.parent;if(0!==this.previousPoint.x&&0!==this.previousPoint.y){switch(s.upperCanvas.style.cursor){case"se-resize":case"s-resize":this.previousPoint.x>e||this.previousPoint.y>i?(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"sw-resize":this.previousPoint.x<e||this.previousPoint.y>i?(a=(e-this.previousPoint.x+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(this.previousPoint.x-e+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"w-resize":case"nw-resize":this.previousPoint.x<e||this.previousPoint.y<i?(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"n-resize":case"ne-resize":this.previousPoint.x>e||this.previousPoint.y<i?(a=(this.previousPoint.x-e+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"e-resize":this.previousPoint.x>e||this.previousPoint.y>i?(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o))}s.activeObj.activePoint.width=s.activeObj.activePoint.endX-s.activeObj.activePoint.startX,s.activeObj.activePoint.height=s.activeObj.activePoint.endY-s.activeObj.activePoint.startY,(s.activeObj.activePoint.width<10||s.activeObj.activePoint.height<10)&&(s.activeObj=t.extend({},r,null,!0))}this.previousPoint={x:e,y:i}},i.prototype.adjustNWPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.endY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.endX=l[0],e.endY=l[1],e.startY=p[1],e.startX=p[0],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.adjustNEPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.endY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.startX=l[0],e.endY=l[1],e.width=p[0]-l[0],e.height=l[1]-p[1],e.endX=e.startX+e.width,e.startY=e.endY-e.height,e},i.prototype.adjustSWPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.startY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.endX=l[0],e.startY=l[1],e.startX=p[0],e.endY=p[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.adjustSEPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.startY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.startX=l[0],e.startY=l[1],e.width=p[0]-l[0],e.height=p[1]-l[1],e.endX=e.startX+e.width,e.endY=e.startY+e.height,e},i.prototype.adjustRotationPoints=function(e,t,i,o,r,a){var n=e.startX+e.width/2,s=e.startY+e.height/2;this.getResizeDirection(e,t,i,o,r,a);var l=this.rotatePoints(e.startX,e.startY,n,s,o),p=this.rotatePoints(e.endX,e.startY,n,s,o),h=this.rotatePoints(e.endX,e.endY,n,s,o),c=this.rotatePoints(e.startX,e.endY,n,s,o),d=[(l[0]+h[0])/2,(l[1]+h[1])/2],v=this.rotatePoints(l[0],l[1],d[0],d[1],-o),u=this.rotatePoints(c[0],c[1],d[0],d[1],-o),g=this.rotatePoints(p[0],p[1],d[0],d[1],-o);return e.startX=v[0],e.startY=v[1],e.endX=g[0],e.endY=u[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.rotatePoints=function(e,t,i,o,r){return[(e-i)*Math.cos(r)-(t-o)*Math.sin(r)+i,(e-i)*Math.sin(r)+(t-o)*Math.cos(r)+o]},i.prototype.setResizedValue=function(e,t,i,o){switch(e){case"x":t+=i;break;case"y":t+=o;break;case"abs-x":t+=i>0?-i:Math.abs(i);break;case"abs-y":t+=o>0?-o:Math.abs(o);break;case"y-abs-x":t+=o+(i>0?-i:Math.abs(i))/2;break;case"abs-x-abs-y":t+=(i>0?-i:Math.abs(i))+(o>0?-o:Math.abs(o))/2;break;case"abs-y-x":t+=(o>0?-o:Math.abs(o))+i/2;break;case"x-y":t+=i+o/2;break;case"img-resize-x":t+=i;break;case"img-resize-y":t+=o}return t},i.prototype.getResizeDirection=function(e,t,i,o,r,a){var n=o*(180/Math.PI),s=this.getResizedElement(n,this.resizedElement);"e-resize"===this.resizedElement?(e.width=this.setResizedValue(s,e.width,t,i),e.endX=e.width+e.startX):"n-resize"===this.resizedElement?(e.startY=this.setResizedValue(s,e.startY,t,i),e.height=e.endY-e.startY):"w-resize"===this.resizedElement?(e.startX=this.setResizedValue(s,e.startX,t,i),e.width=e.startX+e.endX):"s-resize"===this.resizedElement?(e.height=this.setResizedValue(s,e.height,t,i),e.endY=e.height+e.startY):r&&"img-resize"===r&&(e.width=this.setResizedValue("img-resize-x",e.width,t,i),e.height=this.setResizedValue("img-resize-y",e.height,t,i),"se-resize"===a?(e.endX=e.width+e.startX,e.endY=e.height+e.startY):"sw-resize"===a?(e.startX=e.endX-e.width,e.endY=e.height+e.startY):"ne-resize"===a?(e.endX=e.width+e.startX,e.startY=e.endY-e.height):"nw-resize"===a&&(e.startX=e.endX-e.width,e.startY=e.endY-e.height))},i.prototype.getResizedElement=function(e,t){var i=[];"n-resize"===t?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"e-resize"===t?i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]:"s-resize"===t?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"w-resize"===t&&(i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]);for(var o=e<0?360-Math.abs(e):e,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return t},i.prototype.updateCursorStyles=function(e,i,o){var r=this.parent,a=!1;""===r.activeObj.keyHistory||void 0!==r.activeObj.shape||r.currObjType.isCustomCrop||r.currObjType.isLine||!r.currObjType.isText||(r.activeObj.shape="text");var n=t.extend({},r.activeObj,{},!0);if(!t.isNullOrUndefined(n.topLeftCircle)){var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),this.isObjSelected)if("line"===n.shape||"arrow"===n.shape)a=this.updateCursorStylesForLineArrow(e,i,n);else if("path"===n.shape)a=this.updateCursorStylesForPath(e,i,n);else if(n.rotatedAngle)this.setCursorForRotatedObject(n,e,i,r.upperCanvas),"grabbing"===r.cursor?(r.upperCanvas.style.cursor=this.parent.cursor="grabbing",this.dragElement=r.cursor):"move"===r.cursor?(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i):"default"!==r.cursor&&(a=!0,this.dragElement=r.cursor,r.currObjType.isResize=!0);else{var l=this.getTransRotationPoint(n);e>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.topLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.topLeftCircle.startY+2*n.topLeftCircle.radius&&"nw-resize"!==this.dragElement?(n.topLeftCircle.startX=n.topLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="nw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.topRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.topCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.topCenterCircle.startY+2*n.topLeftCircle.radius&&"n-resize"!==this.dragElement?(n.topCenterCircle.startX=n.topCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="n-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.topRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.topRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.topRightCircle.startY+2*n.topLeftCircle.radius&&"ne-resize"!==this.dragElement?(n.topRightCircle.startX=n.topRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="ne-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.centerLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.centerLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&"w-resize"!==this.dragElement?(n.centerLeftCircle.startX=n.centerLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="w-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.centerRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.centerRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&"e-resize"!==this.dragElement?(n.centerRightCircle.startX=n.centerRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="e-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY+2*n.topLeftCircle.radius&&"sw-resize"!==this.dragElement?(n.bottomLeftCircle.startX=n.bottomLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="sw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.bottomCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomCenterCircle.startY+2*n.topLeftCircle.radius&&"s-resize"!==this.dragElement?(n.bottomCenterCircle.startX=n.bottomCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="s-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY+2*n.topLeftCircle.radius&&"se-resize"!==this.dragElement?(n.bottomRightCircle.startX=n.bottomRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="se-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):l&&e>=l.x-2*n.topLeftCircle.radius&&e<=l.x+2*n.topLeftCircle.radius&&i>=l.y-2*n.topLeftCircle.radius&&i<=l.y+2*n.topLeftCircle.radius&&"grabbing"!==this.dragElement?(r.upperCanvas.style.cursor=r.cursor="grabbing",this.dragElement=r.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i),"text"!==n.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(r.upperCanvas.style.cursor=r.cursor="move",this.dragElement="",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}else this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i;this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===o?a||e>=n.activePoint.startX&&e<=n.activePoint.endX&&i>=n.activePoint.startY&&i<=n.activePoint.endY||"grabbing"===this.dragElement?r.currObjType.isDragging=!0:"line"===n.shape||"arrow"===n.shape?(this.setCursorForLineArrow(n,e,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):"path"===n.shape&&(this.setCursorForPath(n,e,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):r.currObjType.isDragging=!0,0===n.rotatedAngle||"e-resize"!==this.dragElement&&"w-resize"!==this.dragElement&&"n-resize"!==this.dragElement&&"s-resize"!==this.dragElement||(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}},i.prototype.updateCursorStylesForLineArrow=function(e,t,i){for(var o,r=!1,a=this.parent,n=0;n<5;n++)if(o=i.pointColl[n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){i.centerLeftCircle.startX=i.centerLeftCircle.startY=0,this.dragElement="w-resize",r=!0;break}if(!r)for(n=1;n<6;n++)if(o=i.pointColl[i.pointColl.length-n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){i.centerRightCircle.startX=i.centerRightCircle.startY=0,this.dragElement="e-resize",r=!0;break}if(!r)for(n=0;n<i.pointColl.length;n++){if(o=i.pointColl[n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){a.upperCanvas.style.cursor=a.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t;break}a.upperCanvas.style.cursor=a.cursor="default"}return r},i.prototype.updateCursorStylesForPath=function(e,t,i){var o=!1;return this.pathAdjustedIndex=this.setCursorForLineArrow(i,e,t,this.parent.upperCanvas),"move"===this.parent.cursor&&(o=!0,this.dragElement="pathDrag"),o||(this.parent.upperCanvas.style.cursor=this.parent.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t),o},i.prototype.setTextSelection=function(e,t){var i=this.parent,o=i.transform.degree;(o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o);for(var r=0,a=i.activeObj.flipObjColl.length;r<a;r++){var n=i.activeObj.flipObjColl[r].toLowerCase();switch(o){case 0:switch(n){case"horizontal":i.activeObj.activePoint={startX:i.activeObj.activePoint.endX-e,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case"vertical":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.startY+(t||0)}}break;case 90:switch(n){case"horizontal":i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case"vertical":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-e,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)}}break;case 180:switch(n){case"horizontal":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+e,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+t,i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.startY};break;default:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.endY-(t||0)}}break;case 270:switch(n){case"horizontal":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+t,endY:i.activeObj.activePoint.startY+(e||0)};break;default:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}}}if(0===i.activeObj.flipObjColl.length)switch(o){case 0:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.startY+(t||0)};break;case 90:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case 180:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.endY-(t||0)};break;case 270:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}i.activeObj.activePoint.width=i.activeObj.activePoint.endX-i.activeObj.activePoint.startX,i.activeObj.activePoint.height=i.activeObj.activePoint.endY-i.activeObj.activePoint.startY,360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},i.prototype.setActivePoint=function(e,i){var o=this.parent;if(!t.isNullOrUndefined(o.activeObj.activePoint))if(o.currObjType.isText){var r=e||0,a=i||o.activeObj.textSettings.fontSize;void 0===o.activeObj.textSettings.fontSize&&(o.activeObj.textSettings.fontSize=.1*Math.abs(o.baseImgCanvas.width-o.baseImgCanvas.height)),this.setTextSelection(r,a),this.mouseDownPoint.x=o.activeObj.activePoint.endX,this.mouseDownPoint.y=o.activeObj.activePoint.endY,void 0!==o.activeObj.horTopLine&&(o.activeObj.activePoint=t.extend({},o.activeObj.activePoint,{},!0)),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}else if(e&&i)o.activeObj.activePoint.startX=this.mouseDownPoint.x=e,o.activeObj.activePoint.startY=this.mouseDownPoint.y=i,o.currObjType.isDragging=!0;else{var n=o.activeObj;o.activeObj.activePoint={startX:n.horTopLine.startX,startY:n.horTopLine.startY,endX:n.horTopLine.endX,endY:n.horTopLine.endY},o.activeObj.activePoint.width=o.activeObj.activePoint.endX-o.activeObj.activePoint.startX,o.activeObj.activePoint.height=o.activeObj.activePoint.endY-o.activeObj.activePoint.startY}},i.prototype.mouseDownEventHandler=function(e){var i=this,o=this.parent;if("touchstart"===e.type?this.isTouch=!0:this.isTouch=!1,"touchstart"!==e.type||e.currentTarget!==o.lowerCanvas||o.isImageLoaded){this.isCropSelection=!1,this.isPan=!0;var r;void 0!==o.activeObj.shape&&(r=o.activeObj.shape.split("-")),void 0!==r&&"crop"===r[0]&&(this.isCropSelection=!0),this.isCropSelection&&(this.dragCanvas=o.togglePan=!0);var a={point:this.setXYPoints(e)};t.isBlazor()&&o.events&&!0===o.events.clicked.hasDelegate?o.dotNetRef.invokeMethodAsync("ClickEventAsync","click",a).then(function(t){i.clickEvent(t,e)}):(o.trigger("click",a),this.clickEvent(a,e))}},i.prototype.getImagePoints=function(e,t){var i=this.parent;return e<i.img.destLeft?e=i.img.destLeft:e>i.img.destLeft+i.img.destWidth&&(e=i.img.destLeft+i.img.destWidth),t<i.img.destTop?t=i.img.destTop:t>i.img.destTop+i.img.destHeight&&(t=i.img.destTop+i.img.destHeight),{x:e,y:t}},i.prototype.clickEvent=function(e,i){var o=this.parent,r=e.point.x,a=e.point.y,n=o.activeObj.shape&&"text"===o.activeObj.shape?o.cursor:"default";if(o.isResize)this.performEnterAction();else{if(JSON.stringify(o.frameObj)!==JSON.stringify(o.tempFrameObj))o.okBtn();else if(""!==this.currentDrawingShape){var s={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),this.initialPrevObj=s.currObj,this.initialPrevObj.objColl=t.extend([],o.objColl,[],!0),this.initialPrevObj.pointColl=t.extend([],o.pointColl,[],!0),this.initialPrevObj.afterCropActions=t.extend([],o.afterCropActions,[],!0);var l={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),this.initialPrevObj.selPointColl=t.extend([],l.selPointColl,[],!0),this.setActivePoint(r,a),"path"===this.currentDrawingShape){var p=this.getImagePoints(r,a);o.activeObj.pointColl.push({x:p.x,y:p.y}),0!==o.activeObj.activePoint.width&&0!==o.activeObj.activePoint.height&&(o.activeObj.activePoint.width=0,o.activeObj.activePoint.height=0,o.activeObj.activePoint.startX=o.activeObj.pointColl[o.activeObj.pointColl.length-1].x,o.activeObj.activePoint.startY=o.activeObj.pointColl[o.activeObj.pointColl.length-1].y)}o.activeObj.activePoint.endX=o.activeObj.activePoint.startX,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY,o.currObjType.isDragging=!0;var h=this.updatePrevShapeSettings(),c={action:"draw-start",previousShapeSettings:h},d={action:"move",previousShapeSettings:h};return this.shapeResizingArgs=c,this.shapeMovingArgs=d,void this.triggerShapeChange(c,d,"mouse-down")}o.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1}),this.isCropSelection&&this.dragCanvas&&(this.setCursor(r,a),"move"!==o.cursor&&"crosshair"!==o.cursor&&"default"!==o.cursor&&"grab"!==o.cursor&&(this.isPan=!1)),o.activeObj.shape?this.isObjSelected=!0:this.isObjSelected=!1;var v={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj,g=t.extend({},o.activeObj,null,!0),b=this.isShapeTouch(i,this.isCropSelection),f=this.isFreehandDrawTouch(i,this.isCropSelection),m=b||this.isShapeClick(i,this.isCropSelection),C=this.applyCurrShape(m);if(this.isTouch&&!b&&g.shape&&!this.isCropSelection){this.applyObj(r,a)&&(o.okBtn(!0),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}));var y=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:u,previousObjColl:u.objColl,previousPointColl:u.pointColl,previousSelPointColl:u.selPointColl,previousCropObj:y,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}if(b||o.togglePen||this.isCropSelection||(t.isBlazor()?o.isImageLoaded&&o.updateToolbar(o.element,"imageLoaded","okBtnClick"):(o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}))),!this.dragCanvas||!this.isPan||"grab"!==o.cursor&&!this.isTouch||b||f||o.togglePen){var j=!1;!o.activeObj.shape||"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||(j=!0);var P=this.setXYPoints(i),O=P.x,x=P.y;this.applyObj(O,x)&&(o.okBtn(!0),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:O,y:x,isMouseDown:!0}});var w={index:null};o.notify("freehand-draw",{prop:"getFreehandDrawHoveredIndex",onPropertyChange:!1,value:{obj:w}});var S={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:S}}),this.isFhdPoint||this.isFhdCustomized&&!o.togglePen){if(!t.isNullOrUndefined(S.freehandSelectedIndex)&&S.freehandSelectedIndex!==w.index){var T=w.index;if(o.okBtn(),this.isFhdCustomized=!1,o.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:T}}),w.index>-1){var k=o.pointColl[w.index].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:k,strokeWidth:o.pointColl[w.index].strokeWidth}})}}if(S.freehandSelectedIndex=null,o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:S}}),!t.isNullOrUndefined(w.index)&&w.index>-1)o.notify("freehand-draw",{prop:"selectFhd",value:{type:"ok"}}),o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),t.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}});else if(S.freehandSelectedIndex){o.okBtn();k=o.pointColl[S.freehandSelectedIndex].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:k,strokeWidth:o.pointColl[S.freehandSelectedIndex].strokeWidth}})}else this.findTargetObj(O,x,!1)&&this.findTarget(O,x,i.type)}else{if(this.isFhdEditing&&(o.notify("freehand-draw",{prop:"cancelFhd",value:{type:"ok"}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none")),t.isBlazor()||o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),this.isFhdEditing=!1,j?this.setCursor(O,x):"default"!==n&&(o.upperCanvas.style.cursor=o.cursor=n),"crosshair"===o.cursor||t.Browser.isDevice&&o.togglePen){if(o.togglePen){if(t.isNullOrUndefined(o.activeObj.strokeSettings)){var F={strokeSettings:{}};o.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:F}}),o.activeObj.strokeSettings=F.strokeSettings}var A={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:A}}),t.isNullOrUndefined(A.penStrokeWidth)&&o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:2}}),this.upperContext.strokeStyle=o.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=o.activeObj.strokeSettings.strokeColor,o.notify("freehand-draw",{prop:"freehandDownHandler",onPropertyChange:!1,value:{e:i,canvas:o.upperCanvas}})}else o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);o.currObjType.isActiveObj=!1,this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0}"crosshair"!==o.cursor&&"touchstart"===i.type.toLowerCase()||o.currObjType.isActiveObj&&"default"!==o.cursor&&!o.togglePen?this.findTarget(O,x,i.type):""!==o.currObjType.shape&&!o.currObjType.isCustomCrop||o.togglePen||"default"===o.cursor||this.setActivePoint(O,x)}}else this.applyObj(r,a)&&(o.okBtn(!0),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),this.isFhdEditing&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.isFhdCustomized=!1,t.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),!o.activeObj.shape||"rectangle"!==o.activeObj.shape&&"ellipse"!==o.activeObj.shape&&"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape&&"path"!==o.activeObj.shape&&"text"!==o.activeObj.shape&&"image"!==o.activeObj.shape||(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()?o.updateToolbar(o.element,"imageLoaded"):(o.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))),this.canvasMouseDownHandler(i);this.isShapeInserted=!1,this.tempActiveObj=t.extend({},o.activeObj,{},!0)}},i.prototype.mouseMoveEventHandler=function(i){var o=this.parent,r=o.cursor,a=o.upperCanvas.style.cursor;i.preventDefault();var n=o.lowerCanvas.getBoundingClientRect();if("touchmove"!==i.type||2!==i.touches.length){var s,l;"mousemove"===i.type?(s=i.clientX,l=i.clientY):(this.touchEndPoint.x=s=i.touches[0].clientX,this.touchEndPoint.y=l=i.touches[0].clientY),s-=n.left,l-=n.top,this.canvasMouseMoveHandler(i);var p,h=!1;void 0!==o.activeObj.shape&&(p=o.activeObj.shape.split("-")),void 0!==p&&"crop"===p[0]&&(h=!0),h&&o.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),o.upperCanvas.style.cursor=a,o.cursor=r,(o.currObjType.isActiveObj&&(void 0!==o.activeObj.activePoint||o.objColl.length>0)&&!this.dragCanvas||void 0!==o.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(s,l),o.activeObj.activePoint&&(0===o.activeObj.activePoint.width||!t.isNullOrUndefined(o.activeObj.currIndex)&&this.cursorTargetId!==o.activeObj.currIndex)&&"default"!==o.cursor&&"move"!==o.cursor&&"crosshair"!==o.cursor&&"grab"!==o.cursor&&"pointer"!==o.cursor&&(o.upperCanvas.style.cursor=o.cursor="move"),this.findTarget(s,l,i.type)),o.currObjType.isDragging&&(this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.updateActivePoint(s,l,h),o.notify("shape",{prop:"updateTrianglePoints",onPropertyChange:!1,value:{obj:o.activeObj}}),this.isPreventDragging?(o.activeObj.activePoint.startX>o.img.destLeft&&o.activeObj.activePoint.endX<o.img.destLeft+o.img.destWidth&&o.activeObj.activePoint.startY>o.img.destTop&&o.activeObj.activePoint.endY<o.img.destTop+o.img.destHeight&&(this.isPreventDragging=!1),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:null,saveContext:null,isPreventSelection:null}}),h&&(this.dragCanvas=o.togglePan=!0))}else{if(this.isFirstMove)this.startTouches=this.targetTouches(i.touches),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft-n.left,y:(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top}),this.tempTouches.push({x:(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,y:(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top});else{var c=(i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft)-n.left,d=(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top,v=(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,u=(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top,g={x:c<v?v-(v-c)/2:c-(c-v)/2,y:d<u?u-(u-d)/2:d-(d-u)/2};if(this.currMousePoint.x!==g.x&&this.currMousePoint.y!==g.y){var b="";if("touchmove"===i.type&&(o.zoomSettings.zoomTrigger&e.ZoomTrigger.Pinch)===e.ZoomTrigger.Pinch){this.zoomType="Pinch";var f=this.calculateScale(this.startTouches,this.targetTouches(i.touches));this.startTouches=this.targetTouches(i.touches),f>1?b="zoomIn":f<1&&(b="zoomOut")}""!==b&&o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:g.x,y:g.y,type:b}}),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft,y:i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop}),this.tempTouches.push({x:i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft,y:i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop}),this.currMousePoint.x=g.x,this.currMousePoint.y=g.y}}this.isFirstMove=!1}},i.prototype.mouseUpEventHandler=function(e){var i=this,o=this.parent;"touchstart"===e.type?this.isTouch=!1:"touchend"===e.type&&e.stopImmediatePropagation(),e.preventDefault(),o.togglePan&&this.canvasMouseUpHandler(e);var r,a;"mouseup"===e.type?(r=e.clientX,a=e.clientY):(r=this.touchEndPoint.x,a=this.touchEndPoint.y);var n=o.lowerCanvas.getBoundingClientRect();r-=n.left,a-=n.top,"touchend"===e.type&&(this.startTouches=this.tempTouches=[],this.isFirstMove=!1,"none"===o.textArea.style.display&&(this.timer=0));var s,l=!1;if(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),t.isBlazor()&&this.parent.eventType){if("pan"===this.parent.eventType)o.events&&!0===o.events.onPanEnd.hasDelegate&&o.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanEnd",this.parent.panEventArgs);else if("resize"===this.parent.eventType){if(!this.isCropSelection&&this.parent.events&&!0===this.parent.events.onShapeResizeEnd.hasDelegate)this.shapeResizingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeResizingArgs.action=""!==this.currentDrawingShape?"drawing":"resize-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeEnd",this.shapeResizingArgs).then(function(e){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})});else if(this.shapeResizingArgs&&this.selectionResizingArgs&&this.parent.events&&!0===this.parent.events.onSelectionResizeEnd.hasDelegate){var p={type:this.parent.activeObj.shape,startX:this.shapeResizingArgs.currentShapeSettings.startX,startY:this.shapeResizingArgs.currentShapeSettings.startY,width:this.shapeResizingArgs.currentShapeSettings.width,height:this.shapeResizingArgs.currentShapeSettings.height};this.selectionResizingArgs.currentSelectionSettings=p,this.selectionResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeEnd",this.selectionResizingArgs).then(function(e){i.parent.notify("shape",{prop:"updateSelectionChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}})})}}else this.shapeMovingArgs&&this.parent.events&&!0===this.parent.events.onShapeDragEnd.hasDelegate&&(this.shapeMovingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeMovingArgs.action="drag-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragEnd",this.shapeMovingArgs).then(function(e){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}));this.shapeResizingArgs=null,this.shapeMovingArgs=null,this.parent.panEventArgs=null,this.parent.eventType=null}if("path"!==this.currentDrawingShape){if(e.currentTarget===o.upperCanvas&&!o.isResize){if(this.pathAdjustedIndex=null,""!==this.currentDrawingShape){if("text"===this.currentDrawingShape){var h=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.initialPrevObj,previousObjColl:this.initialPrevObj.objColl,previousPointColl:this.initialPrevObj.pointColl,previousSelPointColl:this.initialPrevObj.selPointColl,previousCropObj:h,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:this.initialPrevObj.objColl}});this.isShapeInserted=!0,this.currentDrawingShape="",0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&o.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});var c=this.updatePrevShapeSettings(),d={action:"draw-end",previousShapeSettings:c},v={action:"move",previousShapeSettings:c};this.shapeResizingArgs=d,this.shapeMovingArgs=v,this.triggerShapeChange(d,v,"mouse-up")}this.adjustActObjForLineArrow(),this.updPtCollForShpRot(),o.currObjType.shape=o.currObjType.shape.toLowerCase();var u=t.extend({},o.cropObj,{},!0),g={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:g}});var b=g.currObj;b.objColl=t.extend([],o.objColl,[],!0),b.pointColl=t.extend([],o.pointColl,[],!0),b.afterCropActions=t.extend([],o.afterCropActions,[],!0);var f={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:f}}),b.selPointColl=t.extend([],f.selPointColl,[],!0),o.togglePen||l||(this.tempObjColl&&0!==o.activeObj.activePoint.width&&(o.objColl.push(o.activeObj),JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(this.tempActiveObj.activePoint)&&o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:b,previousObjColl:this.tempObjColl,previousPointColl:b.pointColl,previousSelPointColl:b.selPointColl,previousCropObj:u,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.redrawShape(o.objColl[o.objColl.length-1],!0),this.tempObjColl=void 0),this.isFhdEditing||(this.applyCurrActObj(r,a),o.currObjType.isResize=!1,t.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),o.activeObj){var m,C=!1;if(void 0!==o.activeObj.shape&&(m=o.activeObj.shape.split("-")),void 0===m&&(o.currObjType.isCustomCrop||o.togglePen)?C=!0:void 0!==m&&"crop"===m[0]&&(C=!0),t.isBlazor())"rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape||"image"===o.activeObj.shape?o.updateToolbar(o.element,o.activeObj.shape):"text"===o.activeObj.shape&&"none"===o.textArea.style.display&&o.updateToolbar(o.element,"text");else{if("rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("text"===o.activeObj.shape)"none"===o.textArea.style.display&&o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(this.isFhdEditing)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(!C){o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})}o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})}}}void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),o.activeObj.shape&&!l&&e.currentTarget===o.upperCanvas&&"none"===o.textArea.style.display&&("text"===o.activeObj.shape?t.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):t.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),o.togglePen&&e.currentTarget===o.upperCanvas?o.notify("freehand-draw",{prop:"freehandUpHandler",onPropertyChange:!1,value:{e:e,canvas:o.upperCanvas,context:this.upperContext}}):o.currObjType.shape="",this.dragElement="",o.currObjType.isInitialLine=o.currObjType.isDragging=!1,this.selMouseUpEvent()}else{var y=e.srcElement;e.currentTarget!==o.upperCanvas&&e.currentTarget!==o.lowerCanvas&&o.activeObj.pointColl.length>0&&(y.classList.contains("e-upload-icon")||y.parentElement.id===o.element.id+"_zoomIn"||y.parentElement.id===o.element.id+"_zoomOut"||y.parentElement.id===o.element.id+"_annotationBtn"||y.parentElement.id===o.element.id+"_borderColorBtn"||y.parentElement.id===o.element.id+"_borderWidthBtn"||y.parentElement.id===o.element.id+"_saveBtn")&&(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:e,isApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}))}},i.prototype.adjustActObjForLineArrow=function(e){var t=!1,i=this.parent;if((e=e||i.activeObj).shape&&("line"===e.shape||"arrow"===i.activeObj.shape)){var o=void 0;if(("e-resize"===this.dragElement&&e.activePoint.endX<e.activePoint.startX||"w-resize"===this.dragElement&&e.activePoint.startX>e.activePoint.endX)&&(t=!0,o=e.activePoint.startX,e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=o,o=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=o),e.activePoint.width=Math.abs(e.activePoint.endX-e.activePoint.startX),e.activePoint.height=Math.abs(e.activePoint.endY-e.activePoint.startY),"path"!==i.activeObj.shape){i.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:e}});for(var r=0;r<e.pointColl.length;r++)e.pointColl[r].ratioX=(e.pointColl[r].x-i.img.destLeft)/i.img.destWidth,e.pointColl[r].ratioY=(e.pointColl[r].y-i.img.destTop)/i.img.destHeight}}return t},i.prototype.updPtCollForShpRot=function(e){var t=this.parent;if((e=e||t.activeObj).shape&&0!==e.rotatedAngle){t.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:e}});for(var i=0;i<e.horTopLinePointColl.length;i++)e.horTopLinePointColl[i].ratioX=(e.horTopLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.horTopLinePointColl[i].ratioY=(e.horTopLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.horBottomLinePointColl.length;i++)e.horBottomLinePointColl[i].ratioX=(e.horBottomLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.horBottomLinePointColl[i].ratioY=(e.horBottomLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.verLeftLinePointColl.length;i++)e.verLeftLinePointColl[i].ratioX=(e.verLeftLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.verLeftLinePointColl[i].ratioY=(e.verLeftLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.verRightLinePointColl.length;i++)e.verRightLinePointColl[i].ratioX=(e.verRightLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.verRightLinePointColl[i].ratioY=(e.verRightLinePointColl[i].y-t.img.destTop)/t.img.destHeight}},i.prototype.setXYPoints=function(e){e.preventDefault();var t,i;"mousedown"===e.type?(t=e.clientX,i=e.clientY):(this.touchEndPoint.x=t=e.touches[0].clientX,this.touchEndPoint.y=i=e.touches[0].clientY);var o=this.parent.lowerCanvas.getBoundingClientRect();return t-=o.left,i-=o.top,{x:t,y:i}},i.prototype.getCurrentIndex=function(){for(var e,t=this.parent,i=0;i<t.objColl.length;i++)if(t.activeObj.currIndex===t.objColl[i].currIndex){e=i;break}return e},i.prototype.isShapeClick=function(e,i){var o=this.parent,r=!1;if(o.togglePen)return r;if(o.activeObj.shape&&"text"===o.activeObj.shape&&this.isShapeInserted){var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),r&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}})),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;h=this.getCurrentIndex();t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1)}}return r},i.prototype.isShapeTouch=function(e,i){var o=this.parent,r=!1;if("touchstart"===e.type&&!o.togglePen){o.activeObj&&"text"===o.activeObj.shape&&(this.timer=setTimeout(this.setTimer.bind(this),1e3,e));var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;h=this.getCurrentIndex();i||(t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.isFreehandDrawTouch=function(e,i){var o=this.parent,r=!1;if("touchstart"===e.type&&!i&&!o.togglePen){var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(this.setCursor(l,p),this.isFhdPoint&&(r=!0),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(n.shape){o.activeObj=n;h=this.getCurrentIndex();i||(t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.applyObj=function(e,t){var i=this.parent,o=!1;return!i.activeObj.shape||"rectangle"!==i.activeObj.shape&&"ellipse"!==i.activeObj.shape&&"text"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&"image"!==i.activeObj.shape||(o=!(e>=i.activeObj.activePoint.startX-2*i.activeObj.topLeftCircle.radius&&e<=i.activeObj.activePoint.endX+2*i.activeObj.topLeftCircle.radius&&t>=i.activeObj.activePoint.startY-2*i.activeObj.topLeftCircle.radius&&t<=i.activeObj.activePoint.endY+2*i.activeObj.topLeftCircle.radius)&&("default"===i.upperCanvas.style.cursor||"grab"===i.upperCanvas.style.cursor||"crosshair"===i.upperCanvas.style.cursor||"pointer"===i.upperCanvas.style.cursor||"move"===i.upperCanvas.style.cursor)),o},i.prototype.applyCurrShape=function(e){var i=this.parent,o=!1;if(i.togglePen)return o;var r=t.extend({},i.activeObj,null,!0);if(this.isShapeInserted&&"text"===i.activeObj.shape&&e&&(this.isInitialTextEdited=!0,i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}})),"block"===i.textArea.style.display){var a=t.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r=t.extend({},i.objColl[i.objColl.length-1],null,!0),i.objColl.pop(),i.activeObj=t.extend({},a,null,!0),i.textArea.value=r.keyHistory,i.textArea.style.display="block";var n=r.strokeSettings&&r.strokeSettings.strokeColor?"rgb"===r.strokeSettings.strokeColor.split("(")[0]?this.rgbToHex(parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[0]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[1]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[2])):r.strokeSettings.strokeColor:null;n&&"#ffffff"===n&&(n="#fff"),this.tempActiveObj.strokeSettings&&this.tempActiveObj.strokeSettings.strokeColor&&"#ffffff"===this.tempActiveObj.strokeSettings.strokeColor&&(this.tempActiveObj.strokeSettings.strokeColor="#fff"),(r.keyHistory!==this.tempActiveObj.keyHistory||n&&n!==this.tempActiveObj.strokeSettings.strokeColor||r.textSettings&&r.textSettings.fontFamily!==this.tempActiveObj.textSettings.fontFamily||r.textSettings&&Math.round(r.textSettings.fontSize)!==Math.round(this.tempActiveObj.textSettings.fontSize)||r.textSettings&&Math.round(r.textSettings.fontRatio)!==Math.round(this.tempActiveObj.textSettings.fontRatio)||r.textSettings&&r.textSettings.bold!==this.tempActiveObj.textSettings.bold||r.textSettings&&r.textSettings.italic!==this.tempActiveObj.textSettings.italic||r.textSettings&&r.textSettings.underline!==this.tempActiveObj.textSettings.underline)&&(o=!0),this.isInitialTextEdited&&!o&&(o=!0,this.isInitialTextEdited=!1)}else this.tempActiveObj.activePoint.height=Math.abs(this.tempActiveObj.activePoint.height),o=JSON.stringify(r)!==JSON.stringify(this.tempActiveObj);return o},i.prototype.canvasMouseDownHandler=function(e){var i=this.parent;e.preventDefault();var o,r;"mousedown"===e.type?(o=e.offsetX||e.pageX-i.lowerCanvas.offsetLeft,r=e.offsetY||e.pageY-i.lowerCanvas.offsetTop):(o=e.touches[0].clientX||e.touches[0].pageX-i.lowerCanvas.offsetLeft,r=e.touches[0].clientY||e.touches[0].pageY-i.lowerCanvas.offsetTop);var a=i.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top,this.panDown={x:o,y:r};var n={tempPanMove:null};i.notify("transform",{prop:"getTempPanMove",onPropertyChange:!1,value:{obj:n}}),t.isNullOrUndefined(n.tempPanMove)&&i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}})},i.prototype.canvasMouseMoveHandler=function(e){var t=this.parent,i={bool:null};if(t.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:i}}),t.isResize||i.bool)t.upperCanvas.style.cursor="default";else{this.dragCanvas?t.lowerCanvas.style.cursor="grab":(this.dragCanvas=t.togglePan=!1,t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="default");var o,r;"mousemove"===e.type?(o=e.offsetX,r=e.offsetY):(o=e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft,r=e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop);var a=t.lowerCanvas.getBoundingClientRect(),n={x:o-=a.left,y:r-=a.top};t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}}),this.panDown&&n&&t.togglePan&&this.dragCanvas&&t.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:null,yDiff:null}})}},i.prototype.canvasMouseUpHandler=function(e){var t=this.parent;e.preventDefault();var i={panMove:null};t.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:i}}),t.togglePan&&this.panDown&&i.panMove&&t.togglePan&&this.dragCanvas&&(this.panDown=null,t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:null}}),t.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})),"path"!==this.currentDrawingShape&&(t.currObjType.isDragging=!1)},i.prototype.touchStartHandler=function(e){e.preventDefault(),0===this.touchTime?this.touchTime=(new Date).getTime():(new Date).getTime()-this.touchTime<400?(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:e,isApply:null}}),this.touchTime=0):this.touchTime=(new Date).getTime(),2===e.touches.length?this.isFirstMove=!0:this.mouseDownEventHandler(e),t.EventHandler.add(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler,this),t.EventHandler.add(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),t.EventHandler.add(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler,this),t.EventHandler.add(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},i.prototype.unwireEvent=function(){t.EventHandler.remove(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler),t.EventHandler.remove(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler),t.EventHandler.remove(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler),t.EventHandler.remove(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler)},i.prototype.keyDownEventHandler=function(i){var o=this,r=this.parent;!i.ctrlKey||"+"!==i.key&&"-"!==i.key||i.preventDefault();var a={fileName:"",fileType:null};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n={fileName:a.fileName,fileType:a.fileType,cancel:!1};switch(i.key){case i.ctrlKey&&"s":t.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",n).then(function(e){o.beforeSaveEvent(e,i)}):(r.trigger("beforeSave",n),this.beforeSaveEvent(n,i));break;case i.ctrlKey&&"z":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-undo"});break;case i.ctrlKey&&"y":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-redo"});break;case i.ctrlKey&&"+":(r.zoomSettings.zoomTrigger&e.ZoomTrigger.Commands)===e.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null}));break;case i.ctrlKey&&"-":(r.zoomSettings.zoomTrigger&e.ZoomTrigger.Commands)===e.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null}));break;case"Delete":this.deleteItem();break;case"Escape":r.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});break;case"Enter":this.performEnterAction(i);break;case"Tab":this.performTabAction();break;default:t.Browser.isDevice&&"block"===r.textArea.style.display&&setTimeout(this.textKeyDown.bind(this),1,i)}},i.prototype.performEnterAction=function(e){var t=this.parent;if(t.isResize){var i=this.getNumTextValue(),o=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),r=this.parent.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");i&&i.x&&i.y&&(o||r&&!r.classList.contains("e-hidden")?t.notify("transform",{prop:"resize",value:{width:i.x,height:null,isAspectRatio:!0}}):t.notify("transform",{prop:"resize",value:{width:i.x,height:i.y,isAspectRatio:!1}}))}else{var a=void 0;t.activeObj.shape&&(a=t.activeObj.shape.split("-")),e&&this.isKeyBoardCrop(e)&&t.activeObj.horTopLine&&t.activeObj.shape&&"crop"===a[0]&&t.crop()}},i.prototype.isKeyBoardCrop=function(e){var i=!1,o=e.target;return o.id!==this.parent.element.id+"_ok"&&""!==o.id||t.isBlazor()||(i=!0),i},i.prototype.beforeSaveEvent=function(e,t){var i=this.parent;e.cancel||i.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e.fileType,fileName:e.fileName}}),t.preventDefault(),t.stopImmediatePropagation()},i.prototype.handleScroll=function(i){var o,r,a=this.parent,n=!1;"mousewheel"===i.type&&(o=i.clientX,r=i.clientY);var s=a.lowerCanvas.getBoundingClientRect();if(o-=s.left,r-=s.top,o>a.img.destLeft&&o<a.img.destLeft+a.img.destWidth&&r>a.img.destTop&&r<a.img.destTop+a.img.destHeight&&(n=!0),i.stopPropagation(),!0===i.ctrlKey&&n){i.preventDefault(),!a.isCropTab&&a.activeObj.shape&&"crop"!==a.activeObj.shape.split("-")[0]&&(a.okBtn(),t.isBlazor()||a.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}));var l="";"mousewheel"===i.type&&(a.zoomSettings.zoomTrigger&e.ZoomTrigger.MouseWheel)===e.ZoomTrigger.MouseWheel&&(this.zoomType="MouseWheel",l=i.wheelDelta>0?"zoomIn":"zoomOut"),""!==l&&a.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:o,y:r,type:l}})}},i.prototype.textKeyDown=function(e){var i=this.parent;"\r"===String.fromCharCode(e.which)&&(this.textRow+=1),i.textArea.setAttribute("rows",this.textRow.toString()),i.textArea.style.height="auto",i.textArea.style.height=i.textArea.scrollHeight+"px",i.notify("shape",{prop:"setTextBoxWidth",onPropertyChange:!1,value:{e:e}}),t.Browser.isDevice&&(i.textArea.style.width=parseFloat(i.textArea.style.width)+i.textArea.style.fontSize+"px");var o=i.textArea.value.split("\n");this.textRow=o.length,i.textArea.setAttribute("rows",this.textRow.toString()),this.isInitialTextEdited=!1},i.prototype.clearSelection=function(){var e=this.parent;!e.disabled&&e.isImageLoaded&&(e.togglePen=!1,e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0,e.currObjType.shape="",this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.currObjType.isActiveObj=!0,e.currObjType.isCustomCrop=!1,e.upperCanvas.style.cursor=e.cursor="default")},i.prototype.setDragDirection=function(e,t){var i=this.parent;i.img.destWidth>i.img.destHeight?(i.activeObj.activePoint.startX=this.dragPoint.startX=e/2-t/2+7.5,i.activeObj.activePoint.startY=this.dragPoint.startY=t/2-t/2+7.5,i.activeObj.activePoint.endX=e/2+t/2-7.5,i.activeObj.activePoint.endY=t/2+t/2-7.5):(i.activeObj.activePoint.startY=this.dragPoint.startX=t/2-e/2+7.5,i.activeObj.activePoint.endY=t/2+e/2-7.5,i.activeObj.activePoint.startX=this.dragPoint.startX=7.5,i.activeObj.activePoint.endX=e-7.5)},i.prototype.calcShapeRatio=function(e,t,i,o){for(var r=this.parent,a=i,n=o,s=a>=n?a:n,l=s*(e/t),p=s,h=this.getScale(l,a),c=[],d=0;d<2;d++)0===d?c.push(l*h):c.push(p*h);l=c[0],p=c[1];var v=this.getScale(p,n),u=[];for(d=0;d<2;d++)0===d?u.push(l*v):u.push(p*v);l=u[0],p=u[1],r.activeObj.activePoint.width=l,r.activeObj.activePoint.height=p,r.activeObj.activePoint.startX=7.5+(this.dragPoint.startX=(a-l)/2),r.activeObj.activePoint.startY=7.5+(this.dragPoint.startY=(n-p)/2),r.activeObj.activePoint.endX=(a-l)/2+l-7.5,r.activeObj.activePoint.endY=(n-p)/2+p-7.5,r.activeObj.activePoint.startX<r.img.destLeft&&r.img.destLeft+r.img.destWidth>r.lowerCanvas.clientWidth&&(r.activeObj.activePoint.startX=r.img.destLeft,r.activeObj.activePoint.endX=r.activeObj.activePoint.startX+l-7.5),r.activeObj.activePoint.startY<r.img.destTop&&r.img.destTop+r.img.destHeight>r.lowerCanvas.clientHeight&&(r.activeObj.activePoint.startY=r.img.destTop,r.activeObj.activePoint.endY=r.activeObj.activePoint.startY+p-7.5),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY},i.prototype.getScale=function(e,t){return e>t?t/e:1},i.prototype.findTarget=function(e,t,i){var o=this.parent;if("mousedown"===i.toLowerCase()||"touchstart"===i.toLowerCase()){var r=!1;o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]&&(r=!0),this.findTargetObj(e,t,r),this.updateCursorStyles(e,t,i)}else switch(this.dragElement.toLowerCase()){case"nw-resize":o.activeObj.topLeftCircle.startX=e,o.activeObj.topLeftCircle.startY=t;break;case"n-resize":o.activeObj.topCenterCircle.startX=e,o.activeObj.topCenterCircle.startY=t;break;case"ne-resize":o.activeObj.topRightCircle.startX=e,o.activeObj.topRightCircle.startY=t;break;case"w-resize":o.activeObj.centerLeftCircle.startX=e,o.activeObj.centerLeftCircle.startY=t;break;case"e-resize":o.activeObj.centerRightCircle.startX=e,o.activeObj.centerRightCircle.startY=t;break;case"sw-resize":o.activeObj.bottomLeftCircle.startX=e,o.activeObj.bottomLeftCircle.startY=t;break;case"s-resize":o.activeObj.bottomCenterCircle.startX=e,o.activeObj.bottomCenterCircle.startY=t;break;case"se-resize":o.activeObj.bottomRightCircle.startX=e,o.activeObj.bottomRightCircle.startY=t;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t)}},i.prototype.findTargetObj=function(e,i,o){var r=this,a=this.parent,n=!1;if(0!==a.objColl.length&&!a.currObjType.isCustomCrop&&!o){for(var s=0,l=void 0,p=0;p<a.objColl.length;p++){var h=a.upperCanvas.style.cursor;this.setCursor(e,i);var c=t.extend({},a.objColl[p],{},!0);if("line"===c.shape||"arrow"===c.shape){for(var d=0;d<c.pointColl.length;d++)if(e>=c.pointColl[d].x-2*c.topLeftCircle.radius&&e<=c.pointColl[d].x+2*c.topLeftCircle.radius&&i>=c.pointColl[d].y-2*c.topLeftCircle.radius&&i<=c.pointColl[d].y+2*c.topLeftCircle.radius){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p);break}}else if("path"===c.shape){var v=this.setCursorForPath(c,e,i,a.upperCanvas);if("default"!==v&&"grab"!==v){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}else if(0!==c.rotatedAngle){var u=this.setCursorForRotatedObject(c,e,i,a.upperCanvas);if("default"!==u&&"grab"!==u){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}else{var g=this.getTransRotationPoint(c);if(e>=c.activePoint.startX-2*c.topLeftCircle.radius&&e<=c.activePoint.endX+2*c.topLeftCircle.radius&&i>=c.activePoint.startY-2*c.topLeftCircle.radius&&i<=c.activePoint.endY+2*c.topLeftCircle.radius||g&&e>=g.x-2*c.topLeftCircle.radius&&e<=g.x+2*c.topLeftCircle.radius&&i>=g.y-2*c.topLeftCircle.radius&&i<=g.y+2*c.topLeftCircle.radius){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===h||"grabbing"===h||this.isShapeInserted||"move"===a.cursor||"grabbing"===a.cursor?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}}if(t.isNullOrUndefined(l))a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n=!1;else{this.tempObjColl=t.extend([],a.objColl,[],!0),a.currObjType.isCustomCrop=!1,a.activeObj=t.extend({},a.objColl[l],{},!0);var b=t.extend({},a.objColl[l],{},!0);if(a.objColl.splice(l,1),0===a.transform.degree){var f=this.lowerContext.filter;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.activeObj=t.extend({},f,{},!0),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,this.getCurrentFlipState()}else a.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}});a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),a.activeObj=t.extend({},b,{},!0),this.setActivePoint(),a.activeObj=t.extend({},b,{},!0);var m=t.extend({},a.activeObj.strokeSettings,{},!0);a.notify("draw",{prop:"setTempStrokeSettings",onPropertyChange:!1,value:{tempStrokeSettings:m}});var C=t.extend({},a.activeObj.textSettings,{},!0);a.notify("draw",{prop:"setTempTextSettings",onPropertyChange:!1,value:{tempTextSettings:C}});var y=this.updatePrevShapeSettings(),j={action:"select",previousShapeSettings:y,currentShapeSettings:y};"line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape||(j.currentShapeSettings.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,j.currentShapeSettings.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),this.isCropSelection=!1;var P=void 0;if(void 0!==a.activeObj.shape&&(P=a.activeObj.shape.split("-")),void 0!==P&&"crop"===P[0]&&(this.isCropSelection=!0),!this.isCropSelection&&t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&a.events&&!0===a.events.shapeChanging.hasDelegate)a.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",j).then(function(e){r.shapeEvent(e)});else if(this.isCropSelection){var O={action:j.action,previousSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:j.previousShapeSettings.startX,startY:j.previousShapeSettings.startY,width:j.previousShapeSettings.width,height:j.previousShapeSettings.height},currentSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:j.currentShapeSettings.startX,startY:j.currentShapeSettings.startY,width:j.currentShapeSettings.width,height:j.currentShapeSettings.height}};t.isBlazor()&&a.events&&!0===a.events.onSelectionResizeStart.hasDelegate?a.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",O).then(function(e){j.currentShapeSettings.startX=e.currentSelectionSettings.startX,j.currentShapeSettings.startY=e.currentSelectionSettings.startY,j.currentShapeSettings.width=e.currentSelectionSettings.width,j.currentShapeSettings.height=e.currentSelectionSettings.height,r.shapeEvent(j)}):(a.trigger("selectionChanging",O),j.currentShapeSettings.startX=O.currentSelectionSettings.startX,j.currentShapeSettings.startY=O.currentSelectionSettings.startY,j.currentShapeSettings.width=O.currentSelectionSettings.width,j.currentShapeSettings.height=O.currentSelectionSettings.height,this.shapeEvent(j))}else a.trigger("shapeChanging",j),this.shapeEvent(j);n=!0}}return n},i.prototype.shapeEvent=function(e){var i=this.parent;if(i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}}),i.activeObj.activePoint){var o={prevActObj:null};i.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:o}}),t.isNullOrUndefined(o.prevActObj)&&i.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:t.extend({},i.activeObj,{},!0)}}),"image"!==i.activeObj.shape||this.isImageClarity||(this.upgradeImageQuality(),this.isImageClarity=!0),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}),this.isShapeInserted||(i.activeObj.activePoint.startX<i.img.destLeft?this.isPreventDragging=!0:i.activeObj.activePoint.endX>i.img.destLeft+i.img.destWidth?this.isPreventDragging=!0:i.activeObj.activePoint.startY<i.img.destTop?this.isPreventDragging=!0:i.activeObj.activePoint.endY>i.img.destTop+i.img.destHeight&&(this.isPreventDragging=!0))}},i.prototype.upgradeImageQuality=function(){var e=this.parent,i=t.extend({},e.activeObj,null,!0),o=e.activeObj.imageCanvas.getContext("2d"),r={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.activeObj.imageElement.width,height:e.activeObj.imageElement.height,obj:r,isImgShape:null}}),e.notify("shape",{prop:"updateObj",onPropertyChange:!1,value:{dimObj:r,x:null,y:null}}),o.clearRect(0,0,e.activeObj.imageCanvas.width,e.activeObj.imageCanvas.height),e.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:o,isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),e.activeObj=i},i.prototype.targetTouches=function(e){var t=this.parent.lowerCanvas.getBoundingClientRect();return[{x:e[0].pageX-t.left,y:e[0].pageY-t.top},{x:e[1].pageX-t.left,y:e[1].pageY-t.top}]},i.prototype.calculateScale=function(e,t){var i=this.getDistance(e[0],e[1]);return this.getDistance(t[0],t[1])/i},i.prototype.getDistance=function(e,t){var i=0,o=0;return e&&t&&(i=e.x-t.x,o=e.y-t.y),Math.sqrt(i*i+o*o)},i.prototype.redrawShape=function(e,t){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++)if(JSON.stringify(e)===JSON.stringify(i.objColl[o])){i.objColl.splice(o,1);break}this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.isPreventDragging?(i.activeObj.activePoint.startX>i.img.destLeft&&(this.isPreventDragging=!1),t&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):(t&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}))},i.prototype.setTimer=function(e){this.timer>10&&(clearTimeout(this.timer),this.timer=0,this.parent.notify("shape",{prop:"findTextTarget",onPropertyChange:!1,value:{e:e}}),t.Browser.isDevice&&this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height))},i.prototype.applyCurrActObj=function(e,i){var o=this.parent,r=!1,a=t.extend({},o.activeObj,{},!0);if(!t.isNullOrUndefined(a.activePoint)){var n=a.topLeftCircle?a.topLeftCircle.radius:0;if(e>=Math.floor(a.activePoint.startX)&&e<=Math.ceil(a.activePoint.endX)&&i>=Math.floor(a.activePoint.startY)&&i<=Math.ceil(a.activePoint.endY))r=!0;else if(0!==n&&e>=Math.floor(a.activePoint.startX)-n&&e<=Math.ceil(a.activePoint.endX)+n&&i>=Math.floor(a.activePoint.startY)-n&&i<=Math.ceil(a.activePoint.endY)+n)r=!0,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]};else if("text"!==a.shape&&"image"!==a.shape||""===this.dragElement)if("line"===a.shape||"arrow"===a.shape){var s={x:a.activePoint.startX<a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY<a.activePoint.endY?a.activePoint.startY:a.activePoint.endY},l={x:a.activePoint.startX>a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY>a.activePoint.endY?a.activePoint.startY:a.activePoint.endY};e>=Math.floor(s.x)-5&&e<=Math.ceil(l.x)+5&&i>=Math.floor(s.y)-5&&i<=Math.ceil(l.y)+5&&(r=!0)}else if("path"===a.shape){"move"===(p=this.setCursorForPath(a,e,i,o.upperCanvas))&&(r=!0)}else if("grabbing"===this.dragElement)r=!0;else if(0!==a.rotatedAngle){var p;("default"!==(p=this.setCursorForRotatedObject(a,e,i,o.upperCanvas))&&"grab"!==p||"n-resize"===this.dragElement||"e-resize"===this.dragElement||"s-resize"===this.dragElement||"w-resize"===this.dragElement)&&(r=!0)}else"block"===o.textArea.style.display&&(r=!0);else r=!0;if(!r){if(t.isNullOrUndefined(o.activeObj.currIndex)&&(o.activeObj.currIndex="shape_"+(o.objColl.length+1)),o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),void 0===o.activeObj.horTopLine||0===o.activeObj.horTopLine.startX||0===o.activeObj.horTopLine.endX||o.currObjType.isCustomCrop||""===o.currObjType.shape||o.objColl.push(t.extend({},o.activeObj,{},!0)),"text"===o.activeObj.shape||"ellipse"===o.currObjType.shape||"rectangle"===o.currObjType.shape||"line"===o.currObjType.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape||"image"===o.activeObj.shape){var h=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var c=0;c<o.objColl.length;c++){var d={isInside:!1};o.notify("crop",{prop:"isObjInImage",onPropertyChange:!1,value:{obj:o.objColl[c],object:d}}),d.isInside&&(o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:o.objColl[c].shape,obj:o.objColl[c],canvas:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=h,o.activeObj.shape&&o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}t.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}}},i.prototype.getCurrentFlipState=function(){var e=this.parent;if(0!==e.rotateFlipColl.length){var i=t.extend({},e.panPoint.totalPannedInternalPoint,{},!0);e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),e.panPoint.totalPannedInternalPoint=i}else e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1})},i.prototype.setTextBoxStylesToActObj=function(){var e=this.parent;e.activeObj.textSettings.fontFamily=e.textArea.style.fontFamily,e.activeObj.strokeSettings.strokeColor=""!==e.textArea.style.color&&e.textArea.style.color.split("(")[1]&&e.textArea.style.color.split("(")[1].split(",")[0]&&e.textArea.style.color.split("(")[1].split(",")[1]&&e.textArea.style.color.split("(")[1].split(",")[2]?this.rgbToHex(parseFloat(e.textArea.style.color.split("(")[1].split(",")[0]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[1]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[2])):e.textArea.style.color,"bold"===e.textArea.style.fontWeight?e.activeObj.textSettings.bold=!0:e.activeObj.textSettings.bold=!1,"italic"===e.textArea.style.fontStyle?e.activeObj.textSettings.italic=!0:e.activeObj.textSettings.italic=!1,e.activeObj.textSettings.fontSize=parseFloat(e.textArea.style.fontSize)},i.prototype.rgbToHex=function(e,t,i){return"#"+this.componentToHex(e)+this.componentToHex(t)+this.componentToHex(i)},i.prototype.componentToHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},i.prototype.deleteItem=function(){var e=this.parent,i={};if(this.isFhdEditing){this.updateFreehandDrawColorChange();var o=t.extend({},e.cropObj,{},!0),r={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});(h=r.currObj).objColl=t.extend([],e.objColl,[],!0),h.pointColl=t.extend([],e.pointColl,[],!0),h.afterCropActions=t.extend([],e.afterCropActions,[],!0);var a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),h.selPointColl=t.extend([],a.selPointColl,[],!0);var n={freehandDrawSelectedId:null};e.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:n}}),e.notify("freehand-draw",{prop:"deleteFhd",value:{id:n.freehandDrawSelectedId}}),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteFreehandDrawing",previousObj:h,previousObjColl:this.tempObjColl,previousPointColl:h.pointColl,previousSelPointColl:h.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),e.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId"})}else if("none"===e.textArea.style.display){n={prevActObj:null};if(e.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:n}}),n.prevActObj&&(n.prevActObj.activePoint.width=Math.abs(n.prevActObj.activePoint.width),n.prevActObj.activePoint.height=Math.abs(n.prevActObj.activePoint.height)),n.prevActObj&&JSON.stringify(n.prevActObj)!==JSON.stringify(e.activeObj)){var s=e.activeObj.currIndex;e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});for(var l=0;l<e.objColl.length;l++)if(e.objColl[l].currIndex===s){e.objColl.splice(l,1),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}});break}}r={isNewPath:null};if(e.notify("draw",{prop:"getNewPath",value:{obj:r}}),r.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(e.activeObj.shape){e.objColl.push(e.activeObj);o=t.extend({},e.cropObj,{},!0);var p={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:p}});var h;(h=p.currObj).objColl=t.extend([],e.objColl,[],!0),h.pointColl=t.extend([],e.pointColl,[],!0),h.afterCropActions=t.extend([],e.afterCropActions,[],!0);a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),h.selPointColl=t.extend([],a.selPointColl,[],!0),e.objColl.pop(),i={action:"delete",previousShapeSettings:this.updatePrevShapeSettings(),currentShapeSettings:null},e.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),e.clearSelection(),t.isBlazor()&&e.events&&!0===e.events.shapeChanging.hasDelegate?e.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",i):(e.trigger("shapeChanging",i),t.isBlazor()||e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),t.isNullOrUndefined(h.objColl[h.objColl.length-1].currIndex)||(e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteObj",previousObj:h,previousObjColl:this.tempObjColl,previousPointColl:h.pointColl,previousSelPointColl:h.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}e.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}document.getElementById(e.element.id+"_quickAccessToolbarArea")&&(document.getElementById(e.element.id+"_quickAccessToolbarArea").style.display="none")},i.prototype.updateFreehandDrawColorChange=function(){var e=this.parent,i={freehandSelectedIndex:null};if(e.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:i}}),!t.isNullOrUndefined(i.freehandSelectedIndex)&&!t.isNullOrUndefined(e.pointColl[i.freehandSelectedIndex])&&"#42a5f5"===e.pointColl[i.freehandSelectedIndex].strokeColor){var o={tempFreeHandDrawEditingStyles:null};e.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:o}}),e.pointColl[i.freehandSelectedIndex].strokeColor=o.tempFreeHandDrawEditingStyles.strokeColor}},i.prototype.updatePrevShapeSettings=function(e){var i=this.parent,o=[];"text"===i.activeObj.shape&&i.activeObj.textSettings&&(i.activeObj.textSettings.bold&&o.push("bold"),i.activeObj.textSettings.italic&&o.push("italic"),i.activeObj.textSettings.underline&&o.push("underline"));var r={id:t.isNullOrUndefined(i.activeObj.currIndex)?null:i.activeObj.currIndex,type:i.toPascalCase(i.activeObj.shape),startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,width:i.activeObj.activePoint.width,height:i.activeObj.activePoint.height,strokeColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,strokeWidth:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeWidth:null,fillColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.fillColor:null,radius:"ellipse"===i.activeObj.shape?i.activeObj.activePoint.width/2:null,length:"line"===i.activeObj.shape||"arrow"===i.activeObj.shape?i.activeObj.activePoint.width:null,text:"text"===i.activeObj.shape?i.activeObj.keyHistory?i.activeObj.keyHistory:i.activeObj.textSettings.text?i.activeObj.textSettings.text:null:null,fontSize:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontSize:null,fontFamily:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontFamily:null,fontStyle:"text"===i.activeObj.shape?o:null,color:"text"===i.activeObj.shape&&i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,degree:"ellipse"===i.activeObj.shape||"rectangle"===i.activeObj.shape||"image"===i.activeObj.shape?i.activeObj.rotatedAngle*(180/Math.PI):null,imageData:"image"===i.activeObj.shape?i.activeObj.imageElement.src:null};return e&&(e.shapeSettingsObj=r),r},i.prototype.getRectanglePoints=function(e,t,i,o,r,a,n){var s=e+i/2,l=t+o/2,p=r*(Math.PI/180),h=Math.cos(p),c=Math.sin(p),d=a-s,v=n-l,u=d*h+v*c,g=-d*c+v*h,b=i/2,f=o/2;return u>=-b&&u<=b&&g>=-f&&g<=f},i.prototype.getTransRotationPoint=function(e,t){var i,o,r=!1,a=!1;if((o=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(o=360+o),e.flipObjColl)for(var n=0;n<e.flipObjColl.length;n++)"horizontal"===e.flipObjColl[n].toLowerCase()?r=!0:"vertical"===e.flipObjColl[n].toLowerCase()&&(a=!0);return 0===o||360===o?i=a?{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:90===o||-270===o?i=r?{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:180===o||-180===o?i=a?{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:270!==o&&-90!==o||(i=r?{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}),t&&(t.rotationCirclePoint=i),i},i.prototype.getNumTextValue=function(e){var i,o,r,a;if(t.isBlazor()?(r=this.parent.element.querySelector(".e-ie-toolbar-e-resize-width-input .e-numerictextbox"),a=this.parent.element.querySelector(".e-ie-toolbar-e-resize-height-input .e-numerictextbox")):(r=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeWidth"),a=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeHeight")),r&&a){var n=a.value.replace(/,/g,""),s=r.value.replace(/,/g,"");i=parseFloat(n),o=parseFloat(s)}return e&&(e.width=o,e.height=i),{x:o,y:i}},i}(),d=function(){function i(e){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.keyHistory="",this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("shape",this.shape,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("shape",this.shape),this.parent.off("destroyed",this.destroy)},i.prototype.shape=function(e){this.initShapePvtProps();var i;switch(e.prop){case"drawEllipse":this.drawEllipse(e.value.x,e.value.y,e.value.radiusX,e.value.radiusY,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree);break;case"drawLine":this.drawLine(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor);break;case"drawArrow":this.drawArrow(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor,e.value.arrowStart,e.value.arrowEnd);break;case"drawPath":this.drawPath(e.value.pointColl,e.value.strokeWidth,e.value.strokeColor);break;case"drawRectangle":this.drawRectangle(e.value.x,e.value.y,e.value.width,e.value.height,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree);break;case"drawText":this.drawText(e.value.x,e.value.y,e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.color);break;case"redrawActObj":this.redrawActObj(e.value.x,e.value.y,e.value.isMouseDown);break;case"apply":this.apply(e.value.shape,e.value.obj,e.value.canvas);break;case"updateShapeChangeEventArgs":this.updateShapeChangeEventArgs(e.value.shapeSettings);break;case"updSelChangeEventArgs":this.updSelChangeEventArgs(e.value.selectionSettings);break;case"iterateObjColl":this.iterateObjColl();break;case"updImgRatioForActObj":this.updImgRatioForActObj();break;case"zoomObjColl":this.zoomObjColl(e.value.isPreventApply);break;case"redrawObj":this.redrawObj(e.value.degree);break;case"rotateObjColl":this.rotateObjColl();break;case"draw-shape-text":this.drawShapeText();break;case"redraw-text":this.redrawText();break;case"draw-shape":this.drawShape(e.value.obj,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.start,e.value.width,e.value.height);break;case"renderTextArea":this.renderTextArea(e.value.x,e.value.y,e.value.actObj);break;case"setTextBoxWidth":this.setTextBoxWidth(e.value.e);break;case"findTextTarget":this.findTextTarget(e.value.e);break;case"panObjColl":this.panObjColl(e.value.xDiff,e.value.yDiff,e.value.panRegion);break;case"updateFontStyles":this.updateFontStyles(e.value.isTextBox);break;case"applyFontStyle":this.applyFontStyle(e.value.item);break;case"updateFontRatio":this.updateFontRatio(e.value.obj,e.value.isTextArea);break;case"updateFontSize":this.updateFontSize(e.value.obj);break;case"updateObjColl":this.updateObjColl(e.value.item,e.value.objColl);break;case"pushActItemIntoObj":this.pushActItemIntoObj();break;case"clearActObj":this.clearActObj();break;case"refreshActiveObj":this.refreshActiveObj();break;case"applyActObj":this.applyActObj(e.value.isMouseDown);break;case"wireEvent":t.EventHandler.add(this.parent.upperCanvas,"dblclick",this.findTextTarget,this),t.EventHandler.add(this.parent.textArea,"mousedown",this.findTextTarget,this),(i=document.getElementById(this.parent.element.id+"_fileUpload"))&&t.EventHandler.add(i,"change",this.fileChanged,this);break;case"unWireEvent":t.EventHandler.remove(this.parent.upperCanvas,"dblclick",this.findTextTarget),t.EventHandler.remove(this.parent.textArea,"mousedown",this.findTextTarget),i=document.getElementById(this.parent.element.id+"_fileUpload"),t.EventHandler.remove(i,"change",this.fileChanged);break;case"getShapeSetting":this.getShapeSetting(e.value.id,e.value.obj);break;case"getShapeSettings":this.getShapeSettings(e.value.obj);break;case"isPointsInRange":this.isPointsInRange(e.value.x,e.value.y,e.value.obj);break;case"alignRotateFlipColl":this.alignRotateFlipColl(e.value.collection,e.value.isRotateFlipCollection,e.value.obj);break;case"selectShape":this.selectShape(e.value.id,e.value.obj);break;case"deleteShape":this.deleteShape(e.value.id);break;case"getMaxText":this.getMaxText(e.value.isTextBox,e.value.text,e.value.obj);break;case"setPointCollForLineArrow":e.value.obj.pointColl=this.getLinePoints(e.value.obj.activePoint.startX,e.value.obj.activePoint.startY,e.value.obj.activePoint.endX,e.value.obj.activePoint.endY);break;case"setPointCollForShapeRotation":this.setPointCollForShapeRotation(e.value.obj);break;case"setTextSettings":e.value.textSettings?this.textSettings=e.value.textSettings:e.value.fontFamily?this.textSettings.fontFamily=e.value.fontFamily:e.value.fontSize&&(this.textSettings.fontSize=e.value.fontSize);break;case"setStrokeSettings":e.value.strokeSettings?this.strokeSettings=e.value.strokeSettings:e.value.strokeColor?this.strokeSettings.strokeColor=e.value.strokeColor:e.value.fillColor?this.strokeSettings.fillColor=e.value.fillColor:e.value.strokeWidth&&(this.strokeSettings.strokeWidth=e.value.strokeWidth);break;case"getStrokeSettings":e.value.obj.strokeSettings=this.strokeSettings;break;case"setKeyHistory":this.keyHistory=e.value.keyHistory;break;case"getKeyHistory":e.value.obj.keyHistory=this.keyHistory;break;case"setTextBoxPos":this.setTextBoxPos(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"setTextBoxPoints":this.setTextBoxPoints(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"alignTextAreaIntoCanvas":this.alignTextAreaIntoCanvas();break;case"initializeTextShape":this.initializeTextShape(e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.strokeColor);break;case"stopPathDrawing":this.stopPathDrawing(e.value.e,e.value.isApply);break;case"updateArrowRatio":this.updateArrowRatio(e.value.obj);break;case"getSquarePointForRotatedShape":this.getSquarePointForRotatedShape(e.value.obj,e.value.object);break;case"drawImage":this.drawImage(e.value.x,e.value.y,e.value.width,e.value.height,e.value.src,e.value.degree,e.value.isAspectRatio);break;case"reset":this.reset();break;case"fileChanged":this.fileChanged(e.value.e);break;case"updateObj":this.updateObj(e.value.dimObj,e.value.x,e.value.y)}},i.prototype.getModuleName=function(){return"shape"},i.prototype.initShapePvtProps=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d")),t.isNullOrUndefined(this.shapeImg)&&(this.shapeImg=this.parent.createElement("img",{id:this.parent.element.id+"_shapeImg",attrs:{name:"Image",crossorigin:"anonymous"}}))},i.prototype.reset=function(){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null}},i.prototype.drawEllipse=function(e,t,i,o,r,a,n,s){this.initializeShape("ellipse");var l=e&&t?{x:e,y:t}:null;this.drawShape("ellipse",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawLine=function(e,t,i,o,r,a){this.initializeShape("line");var n=e&&t?{x:e,y:t}:null,s=i-e,l=o-t;this.drawShape("line",r,a,null,n,s,l)},i.prototype.drawPath=function(e,i,o){if(this.initializeShape("path"),e)this.drawShape("path",i,o,null,null,null,null,e);else{this.drawShape("line",i,o,null,null,null,null);var r=t.extend({},this.parent.objColl[this.parent.objColl.length-1],null,!0);r.shape="path",r.lineDraw=null,r.pointColl=[{x:r.activePoint.startX,y:r.activePoint.startY},{x:r.activePoint.endX,y:r.activePoint.endY}],this.parent.objColl[this.parent.objColl.length-1]=r}},i.prototype.drawArrow=function(e,t,i,o,r,a,n,s){this.initializeShape("arrow");var l=e&&t?{x:e,y:t}:null,p=i-e,h=o-t;this.drawShape("arrow",r,a,null,l,p,h,null,n,s)},i.prototype.drawRectangle=function(e,t,i,o,r,a,n,s){this.initializeShape("rectangle");var l=e&&t?{x:e,y:t}:null;this.drawShape("rectangle",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawText=function(e,t,i,o,r,a,n,s){this.drawShapeText(i,o,r,a,n,s,e,t)},i.prototype.initializeShape=function(e){this.redrawActObj(),this.parent.activeObj.shape=e,"freehanddraw"===this.parent.currObjType.shape&&(this.apply(),this.parent.upperCanvas.style.cursor=this.parent.cursor="default",this.parent.currObjType.shape=""),this.parent.currObjType.isCustomCrop=!1},i.prototype.updateWidthHeight=function(e){return e.activePoint.width=e.activePoint.endX-e.activePoint.startX,e.activePoint.height=e.activePoint.endY-e.activePoint.startY,e},i.prototype.setDimension=function(e,t){e&&t&&(this.parent.activeObj.activePoint.width=e,this.parent.activeObj.activePoint.height=t,"ellipse"===this.parent.currObjType.shape.toLowerCase()&&(this.parent.activeObj.activePoint.width=2*e,this.parent.activeObj.activePoint.height=2*t))},i.prototype.getArrowType=function(e){var t=e;if(e){t={None:"none",Arrow:"arrow",SolidArrow:"arrowSolid",Circle:"circle",SolidCircle:"circleSolid",Square:"square",SolidSquare:"squareSolid",Bar:"bar"}[""+e]}return t},i.prototype.drawShape=function(e,i,o,r,a,n,s,l,p,h,c){var d=this,v=this.parent;if(!v.disabled&&v.isImageLoaded){v.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.redrawActObj();var u=t.extend([],v.objColl,[],!0);if(v.togglePen=!1,this.keyHistory="",this.parent.upperCanvas.style.display="block",this.refreshActiveObj(),v.currObjType.shape=e,"path"===v.currObjType.shape.toLowerCase()&&t.isNullOrUndefined(l))v.activeObj.shape=v.currObjType.shape.toLowerCase(),v.activeObj.pointColl=[],v.upperCanvas.style.cursor=this.parent.cursor="crosshair",v.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:"path"}}),t.isBlazor()||(v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}));else if("freehanddraw"!==v.currObjType.shape.toLowerCase()&&""!==v.currObjType.shape.toLowerCase()){v.activeObj.shape=v.currObjType.shape.toLowerCase(),this.upperContext.clearRect(0,0,v.upperCanvas.width,v.upperCanvas.height),t.isNullOrUndefined(v.activeObj.strokeSettings)&&(v.activeObj.strokeSettings=this.strokeSettings),"path"===v.currObjType.shape.toLowerCase()&&l&&(v.activeObj.pointColl=l),v.activeObj.strokeSettings.strokeWidth=i||v.activeObj.strokeSettings.strokeWidth,v.activeObj.strokeSettings.strokeColor=o||v.activeObj.strokeSettings.strokeColor,v.activeObj.strokeSettings.fillColor=r||v.activeObj.strokeSettings.fillColor;var g=v.img.destWidth>100?100:v.img.destWidth/2,b=v.img.destHeight>100?100:v.img.destHeight/2;v.activeObj.activePoint.width=g,v.activeObj.activePoint.height=b,"line"===v.currObjType.shape.toLowerCase()||"arrow"===v.currObjType.shape.toLowerCase()?(v.activeObj.lineDraw="horizontal",v.activeObj.activePoint.height=0,"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=50,v.activeObj.start=this.getArrowType(p),v.activeObj.end=this.getArrowType(h))):"rectangle"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=v.activeObj.activePoint.width/2),this.setDimension(n,s),a?(v.activeObj.activePoint.startX=a.x,v.activeObj.activePoint.startY=a.y,v.activeObj.activePoint.endX=v.activeObj.activePoint.startX+v.activeObj.activePoint.width,v.activeObj.activePoint.endY=v.activeObj.activePoint.startY+v.activeObj.activePoint.height):this.setCenterPoints(),this.setPointCollForLineAndArrow(),"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.triangleDirection="right"),v.currObjType.isDragging=v.currObjType.isCustomCrop=!1,this.initShapeProps();var f={shapeSettingsObj:{}};v.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:f}});var m=f.shapeSettingsObj,C={action:"insert",previousShapeSettings:m,currentShapeSettings:m};t.isBlazor()&&v.events&&!0===v.events.shapeChanging.hasDelegate?this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",C).then(function(e){d.updateShapeChangeEventArgs(e.currentShapeSettings),d.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),v.updateToolbar(v.element,"quickAccessToolbar","shape"),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1}):(v.trigger("shapeChanging",C),this.updateShapeChangeEventArgs(C.currentShapeSettings),this.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),t.isBlazor()?v.updateToolbar(v.element,"quickAccessToolbar","shape"):v.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1)}}},i.prototype.initShapeProps=function(){var e=this.parent;e.activeObj.shapeDegree=e.transform.degree,e.activeObj.shapeFlip=e.transform.currFlipState,e.activeObj.textFlip=e.transform.currFlipState,e.activeObj.flipObjColl=[]},i.prototype.setPointCollForLineAndArrow=function(){var e=this.parent;if(("line"===e.activeObj.shape||"arrow"===e.activeObj.shape)&&(e.activeObj.pointColl=this.getLinePoints(e.activeObj.activePoint.startX,e.activeObj.activePoint.startY,e.activeObj.activePoint.endX,e.activeObj.activePoint.endY),e.activeObj.pointColl))for(var t=0,i=e.activeObj.pointColl.length;t<i;t++)e.activeObj.pointColl[t].ratioX=(e.activeObj.pointColl[t].x-e.img.destLeft)/e.img.destWidth,e.activeObj.pointColl[t].ratioY=(e.activeObj.pointColl[t].y-e.img.destTop)/e.img.destHeight},i.prototype.prevObjColl=function(){var e=this.parent,i={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),this.prevObj=i.currObj,this.prevObj.objColl=t.extend([],e.objColl,[],!0),this.prevObj.pointColl=t.extend([],e.pointColl,[],!0),this.prevObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),this.prevObj.selPointColl=t.extend([],o.selPointColl,[],!0)},i.prototype.drawShapeText=function(e,i,o,r,a,n,s,l){var p=this,h=this.parent;if(!h.disabled&&h.isImageLoaded){"freehanddraw"===h.currObjType.shape&&(this.apply(),h.upperCanvas.style.cursor=h.cursor="default",h.currObjType.shape=""),h.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),h.togglePen=!1,this.redrawActObj(),this.prevObjColl(),this.refreshActiveObj(),h.activeObj.shape=h.currObjType.shape="text",h.currObjType.isCustomCrop=!1,this.initializeTextShape(e,i,o,r,a,n),h.currObjType.isText=h.currObjType.isInitialText=!0,t.isNullOrUndefined(h.activeObj.textSettings.fontSize)&&(h.getFontSizes(),h.activeObj.textSettings.fontSize=parseInt(h.fontSizeColl[parseInt("3",10)-1].text,10)),h.img.destWidth<100?h.activeObj.textSettings.fontSize=Math.floor(h.img.destWidth/20):h.img.destHeight<100&&(h.activeObj.textSettings.fontSize=Math.floor(h.img.destHeight/20)),h.activeObj.shapeDegree=h.transform.degree,h.activeObj.shapeFlip=h.transform.currFlipState,h.activeObj.flipObjColl=[],this.updateFontStyles();var c=this.upperContext.measureText(h.activeObj.textSettings.text).width+.5*h.activeObj.textSettings.fontSize,d=h.activeObj.textSettings.fontSize+.25*h.activeObj.textSettings.fontSize;t.isNullOrUndefined(s)||t.isNullOrUndefined(l)?this.setCenterPoints(!0,c,d):(h.activeObj.activePoint.startX=s,h.activeObj.activePoint.startY=l,h.activeObj.activePoint.endX=h.activeObj.activePoint.startX+c,h.activeObj.activePoint.endY=h.activeObj.activePoint.startY+d);var v={shapeSettingsObj:{}};h.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:v}});var u=v.shapeSettingsObj,g={action:"insert",previousShapeSettings:u,currentShapeSettings:u};t.isBlazor()&&h.events&&!0===h.events.shapeChanging.hasDelegate?h.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",g).then(function(e){p.drawShapeTextEvent(e),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1}):(h.trigger("shapeChanging",g),this.drawShapeTextEvent(g),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1)}},i.prototype.drawShapeImageEvent=function(e,i){var o=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),o.objColl.push(o.activeObj);var r=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.objColl[o.objColl.length-1]}}),i?t.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):(o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})):o.okBtn(),o.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}})},i.prototype.drawShapeTextEvent=function(e){var i=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings),this.addLetter(i.activeObj.textSettings.text),i.activeObj.textFlip=i.transform.currFlipState,this.updateFontRatio(i.activeObj),i.objColl.push(i.activeObj);var o=t.extend({},i.cropObj,{},!0);i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}}),t.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar","text"):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),i.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),t.isBlazor()?i.updateToolbar(i.element,"text"):(i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))},i.prototype.initializeTextShape=function(e,i,o,r,a,n){var s=this.parent;this.keyHistory="",s.upperCanvas.style.display="block",t.isNullOrUndefined(s.activeObj.textSettings)&&(s.activeObj.textSettings=this.textSettings),t.isNullOrUndefined(s.activeObj.strokeSettings)&&(s.activeObj.strokeSettings=this.strokeSettings),s.activeObj.strokeSettings.strokeColor=n||s.activeObj.strokeSettings.strokeColor,s.activeObj.textSettings.text=e||s.activeObj.textSettings.text,s.activeObj.textSettings.fontFamily=i||s.activeObj.textSettings.fontFamily,s.activeObj.textSettings.fontSize=o||s.activeObj.textSettings.fontSize,s.activeObj.textSettings.bold=r||s.activeObj.textSettings.bold,s.activeObj.textSettings.italic=a||s.activeObj.textSettings.italic},i.prototype.drawImage=function(e,t,i,o,r,a,n){this.initializeShape("image"),this.onLoadImgShape(e,t,i,o,r,null,a,n)},i.prototype.redrawActObj=function(e,t,i){var o,r=this.parent;r.activeObj.shape&&(o=r.activeObj.shape.split("-")),r.activeObj.horTopLine&&r.activeObj.shape&&"crop"!==o[0]&&("block"===r.textArea.style.display?(r.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.updateFontRatio(r.activeObj,!0),e&&t?e!==r.activeObj.activePoint.startX&&t!==r.activeObj.activePoint.startY&&this.updateTextFromTextArea():(this.updateTextFromTextArea(),r.textArea.style.transform="",r.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),this.refreshActiveObj()):this.applyActObj(i))},i.prototype.apply=function(e,i,o){var r=this.parent;if(!r.disabled)if(r.togglePen&&!r.currObjType.isCustomCrop){var a=r.img.destLeft,n=r.img.destTop,s=r.img.destWidth,l=r.img.destHeight;r.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1});var p=this.lowerContext.filter;this.lowerContext.filter="none",r.togglePen=!1,this.iterateObjColl(),r.notify("freehandDraw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),r.togglePen=!1,(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r.img.destLeft=a,r.img.destTop=n,r.img.destWidth=s,r.img.destHeight=l,this.lowerContext.filter=p}else o=o||"original",t.isNullOrUndefined(r.activeObj.shape)&&t.isNullOrUndefined(e)?r.currObjType.shape="":r.currObjType.shape=e||r.currObjType.shape,""!==r.currObjType.shape&&(this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),"text"===r.activeObj.shape?(r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})):r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i}}),r.activeObj.shape=r.currObjType.shape.toLowerCase(),e||""===r.currObjType.shape||r.currObjType.isCustomCrop||r.objColl.push(t.extend({},r.activeObj,{},!0)),this.keyHistory="")},i.prototype.setCenterPoints=function(e,t,i){var o,r,a=this.parent;e&&t&&i?(o=t,r=i):(o=a.activeObj.activePoint.width,r=a.activeObj.activePoint.height),a.activeObj.activePoint.startX=a.lowerCanvas.width/2-o/2,a.activeObj.activePoint.startY=a.lowerCanvas.height/2-r/2,a.activeObj.activePoint.endX=a.lowerCanvas.width/2+o/2,a.activeObj.activePoint.endY=a.lowerCanvas.height/2+r/2},i.prototype.updSelChangeEventArgs=function(e){var t=this.parent;t.activeObj.activePoint.startX=e.startX,t.activeObj.activePoint.startY=e.startY,t.activeObj.activePoint.width=e.width,t.activeObj.activePoint.height=e.height,t.activeObj.activePoint.endX=t.activeObj.activePoint.startX+t.activeObj.activePoint.width,t.activeObj.activePoint.endY=t.activeObj.activePoint.startY+t.activeObj.activePoint.height},i.prototype.updateShapeChangeEventArgs=function(e){var i=this.parent;switch(i.activeObj.currIndex=e.id,i.activeObj.activePoint.startX=e.startX,i.activeObj.activePoint.startY=e.startY,i.activeObj.activePoint.width=e.width,i.activeObj.activePoint.height=e.height,i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+i.activeObj.activePoint.width,i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+i.activeObj.activePoint.height,i.activeObj.strokeSettings.strokeColor=e.strokeColor,i.activeObj.strokeSettings.fillColor=e.fillColor,t.isNullOrUndefined(e.degree)&&(e.degree=0),i.activeObj.shape){case"ellipse":i.activeObj.activePoint.width=2*e.radius,i.activeObj.rotatedAngle=e.degree*(Math.PI/180);break;case"line":case"arrow":i.activeObj.activePoint.width=e.length;break;case"text":i.activeObj.keyHistory=i.activeObj.textSettings.text=e.text,i.activeObj.textSettings.fontSize=e.fontSize,i.activeObj.strokeSettings.strokeColor=e.color,i.activeObj.textSettings.fontFamily=e.fontFamily;break;case"rectangle":case"image":e.degree&&(i.activeObj.rotatedAngle=e.degree*(Math.PI/180))}if("text"===i.activeObj.shape&&i.activeObj.textSettings)for(var o=0;o<e.fontStyle.length;o++)switch(e.fontStyle[o]){case"bold":i.activeObj.textSettings.bold=!0;break;case"italic":i.activeObj.textSettings.italic=!0;break;case"underline":i.activeObj.textSettings.underline=!0}},i.prototype.addLetter=function(e){var t=this.parent;if("none"===t.textArea.style.display&&(t.currObjType.isText||"text"===t.activeObj.shape)){"Backspace"===e?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=e,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.updateFontStyles();var i=this.upperContext.measureText(this.keyHistory).width+.5*t.activeObj.textSettings.fontSize,o=t.activeObj.textSettings.fontSize+.25*t.activeObj.textSettings.fontSize;this.upperContext.fillText(this.keyHistory,t.activeObj.activePoint.startX,t.activeObj.activePoint.startY+t.activeObj.textSettings.fontSize),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.currObjType.isText=!0,t.notify("selection",{prop:"setActivePoint",onPropertyChange:!1,value:{startX:i,startY:o}})}},i.prototype.redrawText=function(){var e=this.parent,t="";e.activeObj.textSettings.bold&&(t+="bold "),e.activeObj.textSettings.italic&&(t+="italic "),this.upperContext.font=t+e.activeObj.textSettings.fontSize+"px "+e.activeObj.textSettings.fontFamily;var i=e.activeObj.keyHistory.split("\n"),o="block"===e.textArea.style.display?this.getMaxText(!0):this.getMaxText(),r=this.upperContext.measureText(o).width+.5*e.activeObj.textSettings.fontSize,a=i.length*(e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize);e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:r,height:a}}),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}})},i.prototype.updateTextFromTextArea=function(){var e=this.parent,i=!1,o=t.extend({},e.cropObj,{},!0),r={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],e.objColl,[],!0),a.pointColl=t.extend([],e.pointColl,[],!0),a.afterCropActions=t.extend([],this.parent.afterCropActions,[],!0);var n={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),e.activeObj.keyHistory!==e.textArea.value&&(i=!0),e.activeObj.keyHistory=e.textArea.value,e.textArea.style.display="none",e.textArea.value="",this.updateFontStyles();var s=this.upperContext.measureText(e.activeObj.keyHistory).width+.5*e.activeObj.textSettings.fontSize,l=e.activeObj.textSettings.fontSize+.25*this.parent.activeObj.textSettings.fontSize,p=e.activeObj.keyHistory.split("\n");if(p.length>1){l*=p.length;for(var h=[],c=0,d=p.length;c<d;c++)h.push(this.upperContext.measureText(p[c]).width+.5*e.activeObj.textSettings.fontSize);s=Math.max.apply(Math,h)}e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:s,height:l}}),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),this.updImgRatioForActObj(),i?(this.apply(e.activeObj.shape,e.activeObj),e.objColl.push(t.extend({},e.activeObj,{},!0)),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"text",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:e.activeObj.keyHistory,currentText:e.textArea.value,previousFilter:null,isCircleCrop:null}})):(this.apply(e.activeObj.shape,e.activeObj),e.objColl.push(t.extend({},e.activeObj,{},!0)))},i.prototype.iterateObjColl=function(){var e=this.parent;if(e.objColl.length>0){for(var t=0,i=e.objColl.length;t<i;t++)this.apply(e.objColl[t].shape,e.objColl[t]),this.refreshActiveObj();e.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:e.frameObj.type,preventImg:!0}})}},i.prototype.updImgRatioForActObj=function(){var e=this.parent;e.activeObj.imageRatio={startX:(e.activeObj.activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(e.activeObj.activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(e.activeObj.activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(e.activeObj.activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/e.activeObj.activePoint.width,height:e.img.destHeight/e.activeObj.activePoint.height},e.activeObj.rotationCirclePointColl&&(e.activeObj.rotationCirclePointColl.ratioX=(e.activeObj.rotationCirclePointColl.x-e.img.destLeft)/e.img.destWidth,e.activeObj.rotationCirclePointColl.ratioY=(e.activeObj.rotationCirclePointColl.y-e.img.destTop)/e.img.destHeight),"path"===e.activeObj.shape?this.updatePathRatio(e.activeObj):"arrow"===e.activeObj.shape&&this.updateArrowRatio(e.activeObj)},i.prototype.zoomObjColl=function(e){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++){var a=i.objColl[o];if(a.activePoint.startX=a.imageRatio.startX*i.img.destWidth+i.img.destLeft,a.activePoint.startY=a.imageRatio.startY*i.img.destHeight+i.img.destTop,a.activePoint.endX=a.imageRatio.endX*i.img.destWidth+i.img.destLeft,a.activePoint.endY=a.imageRatio.endY*i.img.destHeight+i.img.destTop,"text"===(a=this.updateWidthHeight(a)).shape)this.updateFontSize(a);else if("line"===a.shape||"arrow"===a.shape){a.pointColl=this.getLinePoints(a.activePoint.startX,a.activePoint.startY,a.activePoint.endX,a.activePoint.endY);for(var n=0,s=a.pointColl.length;n<s;n++)a.pointColl[n].ratioX=(a.pointColl[n].x-i.img.destLeft)/i.img.destWidth,a.pointColl[n].ratioY=(a.pointColl[n].y-i.img.destTop)/i.img.destHeight;"arrow"===a.shape&&this.updateArrowSize(a)}else if("path"===a.shape){for(var l=0,p=a.pointColl.length;l<p;l++)a.pointColl[l].x=a.pointColl[l].ratioX*i.img.destWidth+i.img.destLeft,a.pointColl[l].y=a.pointColl[l].ratioY*i.img.destHeight+i.img.destTop;this.updatePathRatio(a)}if(i.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a.activePoint,obj:a}}),t.isNullOrUndefined(e)){var h=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(a.shape,a),this.refreshActiveObj(),this.lowerContext.filter=h,i.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:i.frameObj.type,preventImg:!0}})}"line"!==a.shape&&"arrow"!==a.shape&&"path"!==a.shape&&0!==a.rotatedAngle&&(this.setPointCollForShapeRotation(a),a.rotationCirclePoint.x=a.rotationCirclePoint.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePoint.y=a.rotationCirclePoint.ratioY*i.img.destHeight+i.img.destTop,a.rotationCirclePointColl.x=a.rotationCirclePointColl.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePointColl.y=a.rotationCirclePointColl.ratioY*i.img.destHeight+i.img.destTop)}},i.prototype.redrawObj=function(e){var t=this.parent,i=!1;if(this.parent.objColl.length>0)if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalVertical"===e||"verticalHorizontal"===e)this.updateCurrentActiveObjPoint(e.toLowerCase());else if("number"==typeof e){this.updateCurrentActiveObjPoint(e);var o=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var r=0,a=t.objColl.length;r<a;r++){"crop"!==t.objColl[r].shape.split("-")[0]&&(this.apply(t.objColl[r].shape,t.objColl[r]),i=!0)}i&&t.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:t.frameObj.type,preventImg:!0}}),this.lowerContext.filter=o}},i.prototype.updateCurrentActiveObjPoint=function(e){for(var i,o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(o.activeObj.shape===n.shape&&o.activeObj.activePoint.startX===n.activePoint.startX&&o.activeObj.activePoint.startY===n.activePoint.startY&&o.activeObj.activePoint.endX===n.activePoint.endX&&o.activeObj.activePoint.endY===n.activePoint.endY&&o.activeObj.currIndex===n.currIndex){i=r;break}}if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalvertical"===e||"verticalhorizontal"===e){if("horizontal"===e||"Horizontal"===e){var s=0;for(a=o.objColl.length;s<a;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"horizontal"):0!==n.rotatedAngle&&(n.rotatedAngle=n.rotatedAngle+2*(Math.PI-n.rotatedAngle),n.rotationCirclePointColl.x<=o.img.destLeft+o.img.destWidth/2?n.rotationCirclePointColl.x=o.img.destLeft+o.img.destWidth-(n.rotationCirclePointColl.x-o.img.destLeft):n.rotationCirclePointColl.x>=o.img.destLeft+o.img.destWidth/2&&(n.rotationCirclePointColl.x=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.rotationCirclePointColl.x)),n.rotationCirclePointColl.ratioX=(n.rotationCirclePointColl.x-o.img.destLeft)/o.img.destWidth),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}}else if("vertical"===e||"Vertical"===e)for(s=0;s<o.objColl.length;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"vertical"):0!==n.rotatedAngle&&(n.rotatedAngle=-n.rotatedAngle,n.rotationCirclePointColl.y<=o.img.destTop+o.img.destHeight/2?n.rotationCirclePointColl.y=o.img.destTop+o.img.destHeight-(n.rotationCirclePointColl.y-o.img.destTop):n.rotationCirclePointColl.y>=o.img.destTop+o.img.destHeight/2&&(n.rotationCirclePointColl.y=o.img.destTop+(o.img.destTop+o.img.destHeight-n.rotationCirclePointColl.y)),n.rotationCirclePointColl.ratioY=(n.rotationCirclePointColl.y-o.img.destTop)/o.img.destHeight),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}else if("verticalhorizontal"===e||"horizontalvertical"===e)for(s=0,a=o.objColl.length;s<a;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"!==n.shape&&"arrow"!==n.shape&&"path"!==n.shape||this.flipLineArrowObj(n,e),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}void 0!==i&&(o.activeObj=t.extend({},o.objColl[i],{},!0))}else if(90===e)this.rotateObjColl();else if(-90===e)for(s=0;s<3;s++)this.rotateObjColl();else if("number"==typeof e)if(e>0)this.rotateObjColl();else for(s=0;s<3;s++)this.rotateObjColl()},i.prototype.rotateObjColl=function(){for(var e=this.parent,t=0,i=e.objColl.length;t<i;t++){(o=e.objColl[t]).activePoint.startY=e.img.destTop+e.img.destHeight*o.imageRatio.startX,o.activePoint.endY=e.img.destTop+e.img.destHeight*o.imageRatio.endX,o.activePoint.startX=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.imageRatio.endY,o.activePoint.endX=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.imageRatio.startY,o=this.updateWidthHeight(e.objColl[t]),this.updateFontSize(o),"line"===o.shape||"arrow"===o.shape||"path"===o.shape?(this.rotateLineArrowObj(o),"arrow"===o.shape&&this.updateArrowSize(o)):0!==o.rotatedAngle&&(o.rotationCirclePointColl.y=e.img.destTop+e.img.destHeight*o.rotationCirclePointColl.ratioX,o.rotationCirclePointColl.x=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.rotationCirclePointColl.ratioY,o.rotationCirclePointColl.ratioX=(o.rotationCirclePointColl.x-e.img.destLeft)/e.img.destWidth,o.rotationCirclePointColl.ratioY=(o.rotationCirclePointColl.y-e.img.destTop)/e.img.destHeight)}for(t=0,i=e.objColl.length;t<i;t++)e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.objColl[t].activePoint,obj:e.objColl[t]}});for(t=0,i=e.objColl.length;t<i;t++){var o;(o=e.objColl[t]).imageRatio={startX:(o.activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(o.activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(o.activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(o.activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/o.activePoint.width,height:e.img.destHeight/o.activePoint.height}}},i.prototype.rotateLineArrowObj=function(e){if(!t.isNullOrUndefined(e.pointColl)){var i=this.parent;if(e.pointColl.length>0){for(var o=0;o<e.pointColl.length;o++)e.pointColl[o].y=i.img.destTop+i.img.destHeight*e.pointColl[o].ratioX,e.pointColl[o].x=i.img.destLeft+i.img.destWidth-i.img.destWidth*e.pointColl[o].ratioY;for(o=0;o<e.pointColl.length;o++)e.pointColl[o].ratioX=(e.pointColl[o].x-i.img.destLeft)/i.img.destWidth,e.pointColl[o].ratioY=(e.pointColl[o].y-i.img.destTop)/i.img.destHeight;var r=void 0;r=t.isNullOrUndefined(e.pointColl[e.pointColl.length-2])?{x:0,y:0}:{x:e.pointColl[e.pointColl.length-2].x,y:e.pointColl[e.pointColl.length-2].y};var a=e.pointColl[e.pointColl.length-1].x-r.x,n=e.pointColl[e.pointColl.length-1].y-r.y;e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x+a/2,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y+n/2,e=this.updateWidthHeight(e)}}},i.prototype.flipLineArrowObj=function(e,i){if(!t.isNullOrUndefined(e.pointColl)&&("horizontal"===i.toLowerCase()?this.lineArrowHorizontalFlip(e):"vertical"===i.toLowerCase()?this.lineArrowVerticalFlip(e):(this.lineArrowHorizontalFlip(e),e.shapeFlip="",this.lineArrowVerticalFlip(e)),e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y,e.activePoint.startX>e.activePoint.endX)){var o=e.activePoint.startX;e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=o,o=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=o}},i.prototype.lineArrowHorizontalFlip=function(e){var t=this.parent;if(e.shapeFlip!==t.transform.currFlipState){for(var i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.x<=t.img.destLeft+t.img.destWidth/2?r.x=t.img.destLeft+t.img.destWidth-(r.x-t.img.destLeft):r.x>=t.img.destLeft+t.img.destWidth/2&&(r.x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-r.x)),r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}if("arrow"===e.shape){var a=e.start;e.start=e.end,e.end=a}e.shapeFlip=t.transform.currFlipState}},i.prototype.lineArrowVerticalFlip=function(e){var t=this.parent;if(e.shapeFlip!==t.transform.currFlipState){for(var i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.y<=t.img.destTop+t.img.destHeight/2?r.y=t.img.destTop+t.img.destHeight-(r.y-t.img.destTop):r.y>=t.img.destTop+t.img.destHeight/2&&(r.y=t.img.destTop+(t.img.destTop+t.img.destHeight-r.y)),r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}e.shapeFlip=t.transform.currFlipState}},i.prototype.getRotDegOfShape=function(e){var t;return(t=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(t=360+t),t},i.prototype.renderTextArea=function(e,i,o){var r=this.parent,a=this.getRotDegOfShape(r.activeObj);this.transformTextArea(),t.isBlazor()?r.updateToolbar(r.element,"destroyQuickAccessToolbar"):r.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),r.element.querySelector("#"+r.element.id+"_duplicate")&&r.element.querySelector("#"+r.element.id+"_duplicate").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_remove")&&r.element.querySelector("#"+r.element.id+"_remove").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_editText")&&r.element.querySelector("#"+r.element.id+"_editText").classList.add("e-disabled"),r.textArea.style.display="block",r.textArea.style.left=e+"px",r.textArea.style.top=i+"px",r.textArea.style.fontFamily=o.textSettings.fontFamily,r.textArea.style.fontSize=o.textSettings.fontSize+"px",r.textArea.style.color=o.strokeSettings.strokeColor,r.textArea.style.fontWeight=o.textSettings.bold?"bold":"normal",r.textArea.style.fontStyle=o.textSettings.italic?"italic":"normal",r.textArea.style.border="2px solid "+r.themeColl[r.theme].primaryColor,r.textArea.value=o.keyHistory,r.textArea.style.overflow="hidden",r.textArea.style.width="auto",r.textArea.style.height="auto",r.textArea.focus();r.transform.zoomFactor;var n=o.activePoint,s=n.width,l=n.height;a%90==0&&a%180!=0&&0!==a?(r.textArea.style.width=l+"px",r.textArea.style.height=s+"px"):(r.textArea.style.width=s+"px",r.textArea.style.height=l+"px"),this.setTextBoxWidth();var p={flipColl:null};r.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:p}}),p.flipColl.length<=1&&this.setTextBoxHeight(),a%90==0&&a%180!=0?parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destTop+r.img.destHeight&&this.alignTextAreaIntoCanvas():parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destLeft+r.img.destWidth&&this.alignTextAreaIntoCanvas(),r.notify("selection",{prop:"clearUpperCanvas",onPropertyChange:!1})},i.prototype.setTextBoxWidth=function(e){var i=this.parent,o=this.getMaxText(!0);"block"===i.textArea.style.display?this.updateFontStyles(!0):this.updateFontStyles();var r=this.upperContext.measureText(o).width+parseFloat(i.textArea.style.fontSize)/2,a=e?this.upperContext.measureText(String.fromCharCode(e.which)).width:0,n=t.extend({},i.activeObj,{},!0),s="",l=this.getRotDegOfShape(n);if(s=n.shapeFlip!==i.transform.currFlipState?"":i.transform.currFlipState,e&&parseFloat(i.textArea.style.width)<r+a||t.isNullOrUndefined(e))if(0===l)"horizontal"===s.toLowerCase()?parseFloat(i.textArea.style.left)-i.img.destLeft-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)>r+a&&(i.textArea.style.width=r+a+"px");else if(90===l)"vertical"===s.toLowerCase()?parseFloat(i.textArea.style.top)-i.img.destTop-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destHeight-(parseFloat(i.textArea.style.top)-i.img.destTop)>r+a&&(i.textArea.style.width=r+a+"px");else if(180===l){var p=parseFloat(i.textArea.style.left),h=i.img.destLeft;if("horizontal"===s.toLowerCase()){i.img.destWidth-(p-h)>r+a&&(i.textArea.style.width=r+a+"px")}else{p-h-r-a>0&&(i.textArea.style.width=r+a+"px")}}else if(270===l){var c=parseFloat(i.textArea.style.top),d=i.img.destTop;if("vertical"===s.toLowerCase()){i.img.destHeight-(c-d)>r+a&&(i.textArea.style.width=r+a+"px")}else{c-d-r-a>0&&(i.textArea.style.width=r+a+"px")}}},i.prototype.setTextBoxHeight=function(){var e,i=this.parent,o=t.extend({},i.activeObj,{},!0),r="",a=this.getRotDegOfShape(o);switch(r=o.textFlip===i.transform.currFlipState?"":""===o.textFlip?i.transform.currFlipState:o.textFlip,a){case 0:"vertical"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destHeight-(i.img.destHeight-parseFloat(i.textArea.style.top))+"px":(e=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-e+"px");break;case 90:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px":i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px";break;case 180:"vertical"===r.toLowerCase()?(e=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-e+"px"):i.textArea.style.maxHeight=parseFloat(i.textArea.style.top)-i.img.destTop+"px";break;case 270:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px":i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px"}},i.prototype.updatePathRatio=function(e){for(var t=this.parent,i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}},i.prototype.stopPathDrawing=function(e,i){var o=this.parent;if("path"===o.activeObj.shape){var r={shape:null};if(o.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:r}}),"path"===r.shape){var a=t.extend({},this.parent.cropObj,{},!0),n={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.parent.objColl,[],!0),s.pointColl=t.extend([],this.parent.pointColl,[],!0),s.afterCropActions=t.extend([],this.parent.afterCropActions,[],!0);var l={selPointColl:null};this.parent.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),o.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),o.currObjType.isDragging=!1,e&&"touchstart"!==e.type&&t.isNullOrUndefined(i)&&o.activeObj.pointColl.pop(),this.updatePathRatio(o.activeObj),o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),e&&o.notify("selection",{prop:"mouseUpEventHandler",value:{e:e}}),o.notify("draw",{prop:"setNewPath",value:{bool:!0}}),o.objColl[o.objColl.length-1]&&o.selectShape(o.objColl[o.objColl.length-1].currIndex),t.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}});var p={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:p}});var h=p.shapeSettingsObj,c={action:"draw-end",previousShapeSettings:h},d={action:"move",previousShapeSettings:h};o.notify("selection",{prop:"triggerShapeChange",onPropertyChange:!1,value:{shapeResizingArgs:c,shapeMovingArgs:d,type:"mouse-up"}})}}},i.prototype.findTextTarget=function(e){var i=this.parent;if("text"===i.activeObj.shape){var o,r;if("dblclick"===e.type?(o=e.clientX,r=e.clientY):"touchstart"===e.type&&(o=e.touches[0].clientX,r=e.touches[0].clientY,i.notify("selection",{prop:"setTouchEndPoint",onPropertyChange:!1,value:{x:e.touches[0].clientX,y:e.touches[0].clientY}})),t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn","textAreaClicked"):(i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!0}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!1}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})),t.isNullOrUndefined(o)||t.isNullOrUndefined(r))if("block"===i.textArea.style.display&&""!==this.selectedText()&&"mousedown"===e.type){l=i.textArea.value;i.textArea.value+="a",i.textArea.value=l}else"none"===i.textArea.style.display&&(i.textArea.style.display="block");else{var a=this.parent.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top;var n="",s=this.getRotDegOfShape(i.activeObj);n=""===i.activeObj.textFlip?i.activeObj.textFlip===i.transform.currFlipState?"":i.transform.currFlipState:i.activeObj.textFlip===i.transform.currFlipState?"":""===i.transform.currFlipState?i.activeObj.textFlip:i.transform.currFlipState;var l=void 0;if("none"===i.textArea.style.display){l=t.extend({},i.activeObj,{},!0);for(var p=0;p<i.objColl.length;p++)JSON.stringify(i.activeObj)===JSON.stringify(i.objColl[p])&&i.objColl.splice(p,1);this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),this.lowerContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.activeObj=l,this.updateFontStyles();var h=t.extend({},i.activeObj,{},!0);if(o>=h.activePoint.startX-2*h.topLeftCircle.radius&&o<=h.activePoint.endX+2*h.topLeftCircle.radius&&r>=h.activePoint.startY-2*h.topLeftCircle.radius&&r<=h.activePoint.endY+2*h.topLeftCircle.radius){if(this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),4===h.flipObjColl.length&&(h.flipObjColl=[],n="",h.shapeFlip=""),""===n&&h.flipObjColl.length>1&&(n=h.flipObjColl[h.flipObjColl.length-1]),h.flipObjColl.length<=1){o=(c=this.setTextBoxPos(h,s,n,o,r)).x,r=c.y}else{var c;o=(c=this.setTextBoxPoints(h,s,n,o,r)).x,r=c.y}0!==i.activeObj.rotatedAngle&&(o=i.activeObj.horTopLinePointColl[0].x,r=i.activeObj.horTopLinePointColl[0].y),this.renderTextArea(o,r,h)}else this.applyActObj()}}}else this.stopPathDrawing(e,null)},i.prototype.fileChanged=function(e){var i=e.target.files[0],o=i.name&&i.name.split(".")[1].toLowerCase();if(o&&-1===["jpg","jpeg","png","svg"].indexOf(o))this.refreshActiveObj();else{var r=window.URL.createObjectURL(e.target.files[0]);this.onLoadImgShape(null,null,null,null,r.toString(),!0),t.isBlazor()||(document.getElementById(this.parent.element.id+"_fileUpload").value="")}},i.prototype.onLoadImgShape=function(e,t,i,o,r,a,n,s){var l=this;"string"==typeof r?this.shapeImg.src=r:(this.parent.inMemoryCanvas.width=r.width,this.parent.inMemoryCanvas.height=r.height,this.parent.inMemoryCanvas.getContext("2d").putImageData(r,0,0),this.shapeImg.src=this.parent.inMemoryCanvas.toDataURL()),this.prevObjColl(),this.parent.activeObj.shape="image",this.initShapeProps(),this.shapeImg.onload=function(){l.upperContext.drawImage(l.shapeImg,0,0,l.shapeImg.width,l.shapeImg.height),l.updateImgCanvas(a,e,t,i,o,n,s)}},i.prototype.updateImgCanvas=function(e,i,o,r,a,n,s){var l=this,p=this.parent;p.activeObj.imageElement=this.shapeImg,p.activeObj.imageCanvas=p.createElement("canvas");var h={width:0,height:0};if(p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:null}}),r&&a)if(s){var c={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:c}}),h=this.resizeImage(r,c.ratio)}else h={width:r,height:a};if(this.updateObj(h,i,o),p.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:p.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:!0}}),r&&a)if(s){var d={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:d}}),h=this.resizeImage(r,d.ratio)}else h={width:r,height:a};this.updateObj(h,i,o),p.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.shapeImg=null,n&&(p.activeObj.rotatedAngle=n*(Math.PI/180),p.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:p.activeObj}}));var v={shapeSettingsObj:{}};p.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:v}});var u=v.shapeSettingsObj,g={action:"insert",previousShapeSettings:u,currentShapeSettings:u};t.isBlazor()&&p.events&&!0===p.events.shapeChanging.hasDelegate?p.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",g).then(function(t){l.drawShapeImageEvent(t,e),p.isPublicMethod&&p.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),p.isPublicMethod=!1}):(p.trigger("shapeChanging",g),this.drawShapeImageEvent(g,e),p.isPublicMethod&&p.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),p.isPublicMethod=!1)},i.prototype.updateObj=function(e,t,i){var o=this.parent;o.activeObj.activePoint.width=e.width,o.activeObj.activePoint.height=e.height,o.activeObj.activePoint.startX=t||o.lowerCanvas.width/2-e.width/2,o.activeObj.activePoint.startY=i||o.lowerCanvas.height/2-e.height/2,o.activeObj.activePoint.endX=o.activeObj.activePoint.startX+e.width,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY+e.height},i.prototype.resizeImage=function(e,t){var i=t.split(":"),o=parseInt(i[0],10),r=parseInt(i[1],10);return{width:e,height:Math.round(e*r/o)}},i.prototype.setTextBoxPos=function(e,t,i,o,r){var a={x:o,y:r};switch(t){case 0:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):(a.x=e.activePoint.startX,a.y=e.activePoint.startY);break;case 90:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):(a.x=e.activePoint.endX,a.y=e.activePoint.startY);break;case 180:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):(a.x=e.activePoint.endX,a.y=e.activePoint.endY);break;case 270:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):(a.x=e.activePoint.startX,a.y=e.activePoint.endY)}return a},i.prototype.setTextBoxPoints=function(e,t,i,o,r){var a={x:o,y:r};switch(t){case 0:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.startY);break;case 90:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.startY);break;case 180:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.endY);break;case 270:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.endY)}return a},i.prototype.selectedText=function(){var e=this.parent.textArea.selectionStart,t=this.parent.textArea.selectionEnd;return this.parent.textArea.value.substring(e,t)},i.prototype.panObjColl=function(e,t,i){var o=this.parent;if(o.objColl.length>0){for(var r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(""===i||"vertical"===i){if(n.activePoint.startX+=e,n.activePoint.endX+=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x+=e),"path"===n.shape)for(var s=0,l=n.pointColl.length;s<l;s++)n.pointColl[s].x+=e}else if(n.activePoint.startX-=e,n.activePoint.endX-=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x-=e),"path"===n.shape){s=0;for(var p=n.pointColl.length;s<p;s++)n.pointColl[s].x-=e}if(""===i||"horizontal"===i){if(n.activePoint.startY+=t,n.activePoint.endY+=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y+=t),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y+=t}else if(n.activePoint.startY-=t,n.activePoint.endY-=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y-=t),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y-=t;if(n=this.updateWidthHeight(n),o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}}),"line"===n.shape||"arrow"===n.shape){n.pointColl=this.getLinePoints(n.activePoint.startX,n.activePoint.startY,n.activePoint.endX,n.activePoint.endY);for(var h=0,c=n.pointColl.length;h<c;h++)n.pointColl[h].ratioX=(n.pointColl[h].x-o.img.destLeft)/o.img.destWidth,n.pointColl[h].ratioY=(n.pointColl[h].y-o.img.destTop)/o.img.destHeight}var d=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(n.shape,n),this.lowerContext.filter=d,this.refreshActiveObj()}o.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:o.frameObj.type,preventImg:!0}})}},i.prototype.updateFontStyles=function(e){var t=this.parent;this.upperContext.strokeStyle=t.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=t.activeObj.strokeSettings.strokeColor;var i="";t.activeObj.textSettings.bold&&(i="bold "),t.activeObj.textSettings.italic&&(i="italic "),t.activeObj.textSettings.bold&&t.activeObj.textSettings.italic&&(i="italic bold ");var o=e?parseFloat(t.textArea.style.fontSize):t.activeObj.textSettings.fontSize,r="block"===t.textArea.style.display?t.textArea.style.fontFamily:t.activeObj.textSettings.fontFamily;this.upperContext.font=i+o+"px "+r},i.prototype.applyFontStyle=function(e){var i=this.parent,o={shapeSettingsObj:{}};i.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:o}});var r=o.shapeSettingsObj;this.pushActItemIntoObj();var a=t.extend([],i.objColl,[],!0);switch(i.objColl.pop(),"none"===i.textArea.style.display?this.updateFontRatio(i.activeObj):this.updateFontRatio(i.activeObj,!0),e){case"default":this.updateFontStyle(e,a,"normal","normal");break;case"bold":this.updateFontStyle(e,a,"bold","normal");break;case"italic":this.updateFontStyle(e,a,"normal","italic");break;case"bolditalic":this.updateFontStyle(e,a,"bold","italic")}var n={action:"font-style",previousShapeSettings:t.extend({},r,{},!0),currentShapeSettings:t.extend({},r,{},!0)};n.currentShapeSettings.fontStyle=[e],i.triggerShapeChanged(n)},i.prototype.updateFontStyle=function(e,t,i,o){var r=this.parent;if("block"===r.textArea.style.display){var a=this.getTextAreaWidth(e);r.textArea.style.width=a+"px",r.textArea.style.fontWeight=i,r.textArea.style.fontStyle=o,this.updateObjColl(e,t)}else this.textSettings.bold=r.activeObj.textSettings.bold="normal"!==i,this.textSettings.italic=r.activeObj.textSettings.italic="normal"!==o,this.redrawText(),r.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:t}})},i.prototype.updateArrowRatio=function(e){var t={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:t}});var i;i=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var o,r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=i/t.arrowDimension[o].width,s=i/t.arrowDimension[o].height;t.arrowDimension[o].ratioX=n,t.arrowDimension[o].ratioY=s}},i.prototype.updateArrowSize=function(e){var t={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:t}});var i;i=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var o,r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=t.arrowDimension[o].ratioX,s=t.arrowDimension[o].ratioY;t.arrowDimension[o].width=i/n,t.arrowDimension[o].height=i/s}},i.prototype.updateFontRatio=function(e,i){var o=this.parent,r=this.getMaxText(i),a=this.upperContext.measureText(r).width+.5*o.activeObj.textSettings.fontSize,n=o.activeObj.textSettings.fontSize+.25*o.activeObj.textSettings.fontSize,s=this.getRotDegOfShape(e);t.isNullOrUndefined(i)?0===s||180===Math.abs(s)?e.textSettings.fontRatio=a/e.textSettings.fontSize:e.textSettings.fontRatio=n/e.textSettings.fontSize:i&&(e.textSettings.fontRatio=a/parseFloat(o.textArea.style.fontSize))},i.prototype.updateFontSize=function(e){var t=this.getRotDegOfShape(e);0===t||180===Math.abs(t)?e.textSettings.fontSize=e.activePoint.width/e.textSettings.fontRatio:e.textSettings.fontSize=e.activePoint.height/e.textSettings.fontRatio},i.prototype.updateObjColl=function(e,i){var o=this.parent,r=t.extend({},o.cropObj,{},!0),a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=i,n.pointColl=t.extend([],o.pointColl,[],!0),n.afterCropActions=t.extend([],o.afterCropActions,[],!0);var s={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0);var l=o.activeObj.textSettings.bold,p=o.activeObj.textSettings.italic;switch(e){case"default":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!1;break;case"bold":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!1;break;case"italic":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!0;break;case"bolditalic":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!0}o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),o.activeObj.textSettings.bold=l,o.activeObj.textSettings.italic=p},i.prototype.pushActItemIntoObj=function(){if("none"===this.parent.textArea.style.display)this.parent.objColl.push(this.parent.activeObj);else{var e=t.extend({},this.parent.activeObj,{},!0);this.parent.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.parent.objColl.push(this.parent.activeObj),this.parent.activeObj=e}},i.prototype.clearActObj=function(){"none"===this.parent.textArea.style.display&&(this.refreshActiveObj(),this.applyActObj(),this.refreshActiveObj(),this.parent.currObjType.isCustomCrop=!1)},i.prototype.refreshActiveObj=function(){this.parent.activeObj={},this.parent.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},this.parent.activeObj.triangle=[],this.parent.activeObj.triangleRatio=[],this.parent.activeObj.flipObjColl=[],this.parent.activeObj.strokeSettings=this.strokeSettings,this.parent.activeObj.textSettings=this.textSettings,this.parent.activeObj.rotatedAngle=0},i.prototype.applyActObj=function(e){var i=!1;if(void 0!==this.parent.activeObj.shape&&"text"===this.parent.activeObj.shape&&""===this.parent.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height);else{var o=void 0,r=!1;if(void 0!==this.parent.activeObj.shape&&(o=this.parent.activeObj.shape.split("-")),void 0===o&&this.parent.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.parent.activeObj.shape&&!r&&"shape"!==this.parent.activeObj.shape){for(var a=0;a<this.parent.objColl.length;a++)if(JSON.stringify(this.parent.activeObj)===JSON.stringify(this.parent.objColl[a])){i=!0;break}if(!i){t.isNullOrUndefined(this.parent.activeObj.currIndex)&&(this.parent.activeObj.currIndex="shape_"+(this.parent.objColl.length+1)),this.updImgRatioForActObj();var n=this.parent.activeObj.currIndex.split("_"),s=this.parent.objColl.splice(0,parseInt(n[1],10)-1);s.push(t.extend({},this.parent.activeObj,{},!0));for(a=0;a<this.parent.objColl.length;a++)s.push(this.parent.objColl[a]);this.parent.objColl=s,s=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,this.parent.lowerCanvas.width,this.parent.lowerCanvas.height),this.parent.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.parent.currObjType.shape="",this.refreshActiveObj(),this.parent.isCircleCrop&&this.parent.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),t.isBlazor()?this.parent.updateToolbar(this.parent.element,"destroyQuickAccessToolbar"):this.parent.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),t.isNullOrUndefined(e)&&(this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.parent.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}))}}}},i.prototype.alignTextAreaIntoCanvas=function(){var e=this.parent,t=e.textArea.value;e.textArea.value="";for(var i=0,o=t.length;i<o;i++)e.textArea.value+=t[i],e.textArea.style.height="auto",e.textArea.style.height=e.textArea.scrollHeight+"px",this.setTextBoxWidth()},i.prototype.transformTextArea=function(){var e=this.parent;if("text"===e.activeObj.shape){e.textArea.style.transformOrigin="0 0";var t=e.activeObj.rotatedAngle*(180/Math.PI),i="",o=this.getRotDegOfShape(e.activeObj);if(e.activeObj.flipObjColl.length>0)for(var r=0;r<e.activeObj.flipObjColl.length;r++)i+=0!==o&&o%90==0&&180!==o?"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(-1, 1)":"scale(1, -1)",o+=t,"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?e.textArea.style.transform="rotate("+o+"deg)"+i:"vertical"===e.activeObj.flipObjColl[r].toLowerCase()&&(e.textArea.style.transform="rotate("+o+"deg)"+i);else o+=t,e.textArea.style.transform="rotate("+o+"deg)"}},i.prototype.getTextAreaWidth=function(e){var t=this.parent,i=t.activeObj.textSettings.bold,o=t.activeObj.textSettings.italic;switch(e){case"default":t.activeObj.textSettings.bold=!1,t.activeObj.textSettings.italic=!1;break;case"bold":t.activeObj.textSettings.bold=!0,t.activeObj.textSettings.italic=!1;break;case"italic":t.activeObj.textSettings.bold=!1,t.activeObj.textSettings.italic=!0;break;case"bolditalic":t.activeObj.textSettings.bold=!0,t.activeObj.textSettings.italic=!0}this.updateFontStyles();var r;return r="none"===t.textArea.style.display?this.upperContext.measureText(t.activeObj.keyHistory).width+.5*t.activeObj.textSettings.fontSize:this.upperContext.measureText(t.textArea.value).width+.5*t.activeObj.textSettings.fontSize,t.activeObj.textSettings.bold=i,t.activeObj.textSettings.italic=o,r},i.prototype.getObjDetails=function(e){var t=this.parent,i={};switch(i.id=e.currIndex,i.type=t.toPascalCase(e.shape),i.startX=e.activePoint.startX,i.startY=e.activePoint.startY,e.shape){case"rectangle":i.width=e.activePoint.width,i.height=e.activePoint.height,i.strokeColor=e.strokeSettings.strokeColor,i.fillColor=e.strokeSettings.fillColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"ellipse":i.radius=e.activePoint.width/2,i.strokeColor=e.strokeSettings.strokeColor,i.fillColor=e.strokeSettings.fillColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"line":case"arrow":i.length=e.activePoint.width,i.strokeColor=e.strokeSettings.strokeColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"text":i.text=e.keyHistory,i.fontSize=e.textSettings.fontSize,i.color=e.strokeSettings.strokeColor,i.fontStyle=[],e.textSettings.bold&&i.fontStyle.push("bold"),e.textSettings.italic&&i.fontStyle.push("italic");break;case"path":i.strokeColor=e.strokeSettings.strokeColor,i.strokeWidth=e.strokeSettings.strokeWidth}return i},i.prototype.getFreehandDrawDetails=function(i){var o=this.parent,r={};return r.id=o.pointColl[i].id,r.type=e.ShapeType.FreehandDraw,r.points=t.extend([],o.pointColl[i].points),r.strokeColor=o.pointColl[i].strokeColor,r.strokeWidth=o.pointColl[i].strokeWidth,r},i.prototype.getShapeSetting=function(e,i){var o,r=this.parent;if(!r.disabled&&r.isImageLoaded)if(this.applyActObj(),"shape"===e.split("_")[0]){for(var a,n=0,s=r.objColl.length;n<s;n++)if(r.objColl[n].currIndex===e){a=t.extend({},r.objColl[n],{},!0);break}o=this.getObjDetails(a)}else"pen"===e.split("_")[0]&&(o=this.getFreehandDrawDetails(parseInt(e.split("_")[1],10)-1));i.shapeDetails=o},i.prototype.getShapeSettings=function(e){var t=this.parent,i=[];if(!t.disabled&&t.isImageLoaded){this.applyActObj();for(var o=0,r=t.objColl.length;o<r;o++){var a=this.getObjDetails(t.objColl[o]);i.push(a)}for(o=0;o<t.freehandCounter;o++){a=this.getFreehandDrawDetails(o);i.push(a)}}e.shapeDetailsColl=i},i.prototype.isPointsInRange=function(e,i,o){var r=!1;!t.isNullOrUndefined(e)&&!t.isNullOrUndefined(i)&&e>=this.parent.img.destLeft&&i>=this.parent.img.destTop&&e<=this.parent.img.destLeft+this.parent.img.destWidth&&i<=this.parent.img.destTop+this.parent.img.destHeight&&(r=!0),o.inRange=r},i.prototype.alignRotateFlipColl=function(e,t,i){return e=this.popForDefaultTransformedState(e),e=this.popForDefaultFlipState(e),0===(e=this.popForDefaultRotateState(e)).length&&t&&(this.parent.transform.degree=0,this.parent.transform.currFlipState=""),i.collection=e,e},i.prototype.popForDefaultTransformedState=function(e){for(var t=0,i=0,o=0,r=0,a=0;a<e.length;a++)90===e[a]||"rotateRight"===e[a]?(i=0,o=0,r=0,4===++t&&(e.pop(),e.pop(),e.pop(),e.pop())):-90===e[a]||"rotateLeft"===e[a]?(t=0,o=0,r=0,4===++i&&(e.pop(),e.pop(),e.pop(),e.pop())):"horizontal"===e[a]||"Horizontal"===e[a]||"horizontalflip"===e[a]?(i=0,t=0,r=0,2===++o&&(e.pop(),e.pop())):"vertical"!==e[a]&&"Vertical"!==e[a]&&"verticalflip"!==e[a]||(o=0,i=0,t=0,2===++r&&(e.pop(),e.pop()));return e},i.prototype.popForDefaultFlipState=function(e){for(var i=0;i<e.length;i++)t.isNullOrUndefined(e[i+3])||("horizontal"!==e[i]&&"Horizontal"!==e[i]&&"horizontalFlip"!==e[i]||"vertical"!==e[i+1]&&"Vertical"!==e[i+1]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+2]&&"Horizontal"!==e[i+2]&&"horizontalFlip"!==e[i]||"vertical"!==e[i+3]&&"Vertical"!==e[i+3]&&"verticalFlip"!==e[i]?"vertical"!==e[i]&&"Vertical"!==e[i]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+1]&&"Horizontal"!==e[i+1]&&"horizontalFlip"!==e[i+1]||"vertical"!==e[i+2]&&"Vertical"!==e[i+2]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+3]&&"Horizontal"!==e[i+3]&&"horizontalFlip"!==e[i]||(e.pop(),e.pop(),e.pop(),e.pop()):(e.pop(),e.pop(),e.pop(),e.pop()));return e},i.prototype.popForDefaultRotateState=function(e){for(var i=0;i<e.length;i++)t.isNullOrUndefined(e[i+1])||(90!==e[i]&&"rotateRight"!==e[i]||-90!==e[i+1]&&"rotateLeft"!==e[i]?-90!==e[i]&&"rotateLeft"!==e[i]||90!==e[i+1]&&"rotateRight"!==e[i]||(e.pop(),e.pop()):(e.pop(),e.pop()));return e},i.prototype.selectShape=function(e,i){var o=this.parent,r=!1;if(!o.disabled&&o.isImageLoaded)if(this.applyActObj(),"shape"===e.split("_")[0]){for(var a,n=0,s=o.objColl.length;n<s;n++)if(o.objColl[n].currIndex===e){a=t.extend({},o.objColl[n],{},!0);break}if(t.isNullOrUndefined(a))r=!1;else{r=!0,o.activeObj=a;var l={canvasFilter:null};o.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:l}}),this.lowerContext.filter=l.canvasFilter,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.activeObj}}),t.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),"path"===o.activeObj.shape?o.updateToolbar(this.parent.element,"path","pathQuickAccessToolbar"):o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):("text"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):"pen"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}}else if("pen"===e.split("_")[0]){l={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:l}}),l.bool&&o.okBtn();var p={isIndex:!1};o.notify("freehand-draw",{prop:"isFHDIdx",value:{index:parseInt(e.split("_")[1],10)-1,obj:p}}),p.isIndex?(r=!0,o.notify("freehand-draw",{prop:"selectFhd",value:{id:e}}),t.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):(o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))):r=!1}i.isSelected=r},i.prototype.deleteShape=function(e){var i=this.parent;if(!i.disabled&&i.isImageLoaded){if(this.applyActObj(),"shape"===e.split("_")[0]){for(var o=0,r=i.objColl.length;o<r;o++)if(i.objColl[o].currIndex===e){i.objColl.splice(o,1);break}}else"pen"===e.split("_")[0]&&i.notify("freehand-draw",{prop:"handle-freehand-draw",value:{id:e}});var a={canvasFilter:null};i.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:a}}),this.lowerContext.filter=a.canvasFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.getMaxText=function(e,i,o){t.isNullOrUndefined(i)&&(i=e?this.parent.textArea.value:this.parent.activeObj.keyHistory);for(var r,a=i.split("\n"),n=a[0].length,s=a[0],l=1;l<a.length;l++)(r=a[l].length)>n&&(s=a[l],n=r);return o&&(o.maxText=s),s},i.prototype.getLinePoints=function(e,i,o,r){var a,n,s=[];if(e===o){i<r?(a=[e,i],n=[o,r]):(n=[e,i],a=[o,r]);for(var l=this.getSlope(a,n,!0),p=this.getIntercept(a,l),h=a[1];h<=n[1];h++){var c=l*h+p;s.push({x:c,y:h})}}else{e<o?(a=[e,i],n=[o,r]):(n=[e,i],a=[o,r]);for(l=this.getSlope(a,n,!1),p=this.getIntercept(a,l),c=a[0];c<=n[0];c++){h=l*c+p;s.push({x:c,y:h})}}if(Math.floor(e)===Math.floor(o)||s.length<10&&(r-i>10||i-r>10)){s=[];for(var d=Math.min(i,r),v=0;v<Math.abs(Math.floor(r)-Math.floor(i));v++)s.push({x:e,y:d+v});if(s.length>1){var u=void 0;u=t.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var g=s[s.length-1].x-u.x,b=s[s.length-1].y-u.y;s.push({x:s[s.length-1].x+g/2,y:s[s.length-1].y+b/2})}}else if(Math.floor(i)===Math.floor(r)||s.length<10&&(o-e>10||e-o>10)){s=[];for(var f=Math.min(e,o),m=0;m<Math.abs(Math.floor(o)-Math.floor(e));m++)s.push({x:f+m,y:i});if(s.length>1){u=void 0;u=t.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];g=s[s.length-1].x-u.x,b=s[s.length-1].y-u.y;s.push({x:s[s.length-1].x+g/2,y:s[s.length-1].y+b/2})}}return s},i.prototype.getSlope=function(e,t,i){var o;if(i){if(e[1]===t[1])return null;o=(t[0]-e[0])/(t[1]-e[1])}else{if(e[0]===t[0])return null;o=(t[1]-e[1])/(t[0]-e[0])}return o},i.prototype.getIntercept=function(e,t){return null===t?e[0]:e[1]-t*e[0]},i.prototype.setPointCollForShapeRotation=function(e){var t=e.activePoint.startX+e.activePoint.width/2,i=e.activePoint.startY+e.activePoint.height/2,o={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-i)+i},r={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-i)+i},a={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-i)+i},n={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-i)+i};e.horTopLinePointColl=this.getLinePoints(o.x,o.y,r.x,r.y),e.horBottomLinePointColl=this.getLinePoints(a.x,a.y,n.x,n.y),e.verLeftLinePointColl=this.getLinePoints(o.x,o.y,a.x,a.y),e.verRightLinePointColl=this.getLinePoints(r.x,r.y,n.x,n.y),e.verLeftLinePointColl.reverse(),e.verRightLinePointColl.reverse();for(var s=0;s<e.horTopLinePointColl.length;s++)e.horTopLinePointColl[s].ratioX=(e.horTopLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horTopLinePointColl[s].ratioY=(e.horTopLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.horBottomLinePointColl.length;s++)e.horBottomLinePointColl[s].ratioX=(e.horBottomLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horBottomLinePointColl[s].ratioY=(e.horBottomLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.verLeftLinePointColl.length;s++)e.verLeftLinePointColl[s].ratioX=(e.verLeftLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verLeftLinePointColl[s].ratioY=(e.verLeftLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.verRightLinePointColl.length;s++)e.verRightLinePointColl[s].ratioX=(e.verRightLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verRightLinePointColl[s].ratioY=(e.verRightLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;if("move"!==this.parent.upperCanvas.style.cursor){var l={rotationCirclePoint:null};this.parent.notify("selection",{prop:"getTransRotationPoint",value:{obj:e,object:l}});var p=l.rotationCirclePoint;p&&(e.rotationCirclePointColl={x:Math.cos(e.rotatedAngle)*(p.x-t)-Math.sin(e.rotatedAngle)*(p.y-i)+t,y:Math.sin(e.rotatedAngle)*(p.x-t)+Math.cos(e.rotatedAngle)*(p.y-i)+i},e.rotationCirclePointColl.ratioX=(e.rotationCirclePointColl.x-this.parent.img.destLeft)/this.parent.img.destWidth,e.rotationCirclePointColl.ratioY=(e.rotationCirclePointColl.y-this.parent.img.destTop)/this.parent.img.destHeight)}},i.prototype.getSquarePointForRotatedShape=function(e,t){var i={startX:0,startY:0,endX:0,endY:0,width:0,height:0},o=e.activePoint.startX+e.activePoint.width/2,r=e.activePoint.startY+e.activePoint.height/2,a={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-r)+r},n={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-r)+r},s={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-r)+r},l={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-r)+r};return i.startX=a.x,i.startY=a.y,i.endX=a.x,i.endY=a.y,i.startX>n.x&&(i.startX=n.x),i.startX>s.x&&(i.startX=s.x),i.startX>l.x&&(i.startX=l.x),i.startY>n.y&&(i.startY=n.y),i.startY>s.y&&(i.startY=s.y),i.startY>l.y&&(i.startY=l.y),i.endX<n.x&&(i.endX=n.x),i.endX<s.x&&(i.endX=s.x),i.endX<l.x&&(i.endX=l.x),i.endY<n.y&&(i.endY=n.y),i.endY<s.y&&(i.endY=s.y),i.endY<l.y&&(i.endY=l.y),i.width=i.endX-i.startX,i.height=i.endY-i.startY,t&&(t.activePoint=i),i},i}(),v=function(){function o(e){this.isReverseFlip=!1,this.disablePan=!1,this.isReverseRotate=!1,this.flipColl=[],this.prevZoomValue=1,this.cropDimension={width:0,height:0},this.isPreventSelect=!1,this.preventDownScale=!1,this.resizedImgAngle=null,this.parent=e,this.addEventListener()}return o.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},o.prototype.addEventListener=function(){this.parent.on("transform",this.transform,this),this.parent.on("destroyed",this.destroy,this)},o.prototype.removeEventListener=function(){this.parent.off("transform",this.transform),this.parent.off("destroyed",this.destroy)},o.prototype.transform=function(e){switch(this.initTransformPvtVar(),e.prop){case"rotateImage":this.rotateImage(e.value.degree);break;case"flipImage":this.flipImage(e.value.direction);break;case"setDestPointsForFlipState":this.setDestPointsForFlipState();break;case"zoomAction":this.zoomAction(e.value.zoomFactor,e.value.zoomPoint,e.value.isResize);break;case"disableZoomOutBtn":this.disableZoomOutBtn(e.value.isZoomOut);break;case"rotatedFlip":this.rotatedFlip();break;case"drawPannedImage":this.drawPannedImage(e.value.xDiff,e.value.yDiff);break;case"drawPannImage":this.drawPannImage(e.value.point);break;case"performTransformation":this.performTransformation(e.value.text);break;case"updateTransform":this.updateTransform(e.value.text);break;case"rotatePan":this.rotatePan(e.value.isCropSelection,e.value.isDefaultZoom);break;case"drawRotatedImage":this.drawRotatedImage(e.value.degree);break;case"limitPan":this.limitPan();break;case"updateFlipActiveObj":this.updateFlipActiveObj(e.value.panRegion);break;case"resetZoom":this.resetZoom();break;case"pan":this.pan(e.value.value);break;case"zoom":this.zoom(e.value.zoomFactor,e.value.zoomPoint);break;case"setCurrPanRegion":this.setCurrPanRegion(e.value.region,e.value.type,e.value.obj);break;case"rotate":this.rotate(e.value.degree,e.value.obj);break;case"flip":this.flip(e.value.direction);break;case"update":this.update();break;case"calcMaxDimension":this.calcMaxDimension(e.value.width,e.value.height,e.value.obj,e.value.isImgShape);break;case"updatePanPoints":this.updatePanPoints(e.value.panRegion,e.value.obj);break;case"getPanMove":e.value.obj.panMove=this.panMove;break;case"setPanMove":this.panMove=e.value.point;break;case"getTempPanMove":e.value.obj.tempPanMove=this.tempPanMove;break;case"setTempPanMove":this.tempPanMove=e.value.point;break;case"setReverseFlip":this.isReverseFlip=e.value.isReverseFlip;break;case"setDisablePan":this.disablePan=e.value.bool;break;case"setCurrDestinationPoint":this.currDestPoint=e.value.point,this.currDestPoint.startX-=this.parent.cropObj.totalPannedPoint.x,this.currDestPoint.startY-=this.parent.cropObj.totalPannedPoint.y;break;case"setReverseRotate":this.isReverseRotate=e.value.bool;break;case"getFlipColl":e.value.obj.flipColl=this.flipColl;break;case"setFlipColl":this.flipColl=e.value.flipColl;break;case"getPreviousZoomValue":e.value.obj.previousZoomValue=this.prevZoomValue;break;case"setPreviousZoomValue":this.prevZoomValue=e.value.previousZoomValue;break;case"getCropDimension":e.value.obj.cropDimension=this.cropDimension;break;case"setCropDimension":this.cropDimension.width=e.value.width,this.cropDimension.height=e.value.height;break;case"getPreventSelect":e.value.obj.bool=this.isPreventSelect;break;case"setPreventSelect":this.isPreventSelect=e.value.bool;break;case"resizeImage":this.resizeImage(e.value.width,e.value.height);break;case"resizeCrop":this.resizeCrop(e.value.width,e.value.height);break;case"setPreventDownScale":this.preventDownScale=e.value.bool;break;case"updateResize":this.updateResize();break;case"resize":this.resize(e.value.width,e.value.height,e.value.isAspectRatio);break;case"reset":this.reset()}},o.prototype.getModuleName=function(){return"transform"},o.prototype.initTransformPvtVar=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},o.prototype.reset=function(){this.zoomBtnHold=null,this.tempPanMove=null,this.panMove=null,this.disablePan=!1,this.currDestPoint=null,this.isReverseRotate=!1,this.flipColl=[],this.resizedImgAngle=null,this.transCurrObj=null,this.prevZoomValue=1,this.isPreventSelect=this.preventDownScale=!1},o.prototype.rotateImage=function(e){var i=this,o=this.parent,r={cancel:!1,previousDegree:o.transform.degree,currentDegree:360===Math.abs(o.transform.degree+e)?0:o.transform.degree+e};!this.isPreventSelect&&t.isBlazor()&&o.events&&!0===o.events.rotating.hasDelegate?o.dotNetRef.invokeMethodAsync("RotateEventAsync","OnRotate",r).then(function(t){i.rotateEvent(t,e)}):(this.isPreventSelect||o.trigger("rotating",r),this.rotateEvent(r,e))},o.prototype.rotateEvent=function(e,i){var o=this.parent;if(!e.cancel){var r=void 0;if(t.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],o.objColl,null,!0),r.pointColl=t.extend({},o.pointColl,null,!0),r.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0)}o.afterCropActions.push(90===i?"rotateRight":"rotateLeft");var s=[],l=void 0;o.activeObj.activePoint&&o.activeObj.shape&&(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===s[0])&&(l=o.currObjType.isCustomCrop?"custom":s[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.drawRotatedImage(i),o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),l&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})),o.isUndoRedo=!1;var p={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:p}}),o.rotateFlipColl=p.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.drawRotatedImage=function(e){var i=this.parent;0===e?i.transform.degree=0:i.transform.degree+=e,360===Math.abs(i.transform.degree)&&(i.transform.degree=0),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var o=t.extend([],i.objColl,[],!0),r=t.extend({},i.activeObj,{},!0);if(i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseRotate||i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.rotateDegree(e),this.isReverseRotate||(i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.rotateFlipColl.push(e)),i.objColl=t.extend([],o,[],!0),i.activeObj=t.extend({},r,{},!0),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e>0)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});else for(var a=0;a<3;a++)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.updateCurrSelectionPoint(e)},o.prototype.rotateDegree=function(e){var t=this.parent;this.lowerContext.save(),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2);var i=this.lowerContext.filter;t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=i,this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*-e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2),this.lowerContext.restore()},o.prototype.updateCurrSelectionPoint=function(e){var i=this.parent;if(i.currSelectionPoint&&this.currDestPoint){var o=t.extend({},i.activeObj,{},!0),r=t.extend([],i.objColl,[],!0),a={startX:i.img.srcLeft,startY:i.img.srcTop,width:i.img.srcWidth,height:i.img.srcHeight},n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.objColl=[],i.objColl.push(t.extend({},i.currSelectionPoint,{},!0)),t.isNullOrUndefined(i.objColl[0].imageRatio)&&(i.activeObj=i.objColl[0],i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),i.objColl[0]=i.activeObj),i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImgCanvas.width,i.img.srcHeight=i.baseImgCanvas.height,i.img.destLeft=this.currDestPoint.startX,i.img.destTop=this.currDestPoint.startY,i.img.destWidth=this.currDestPoint.width,i.img.destHeight=this.currDestPoint.height,"number"==typeof e&&(i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}})),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),i.currSelectionPoint=t.extend({},i.objColl[0],{},!0),this.currDestPoint={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight},i.objColl=r,i.activeObj=o,i.img.srcLeft=a.startX,i.img.srcTop=a.startY,i.img.srcWidth=a.width,i.img.srcHeight=a.height,i.img.destLeft=n.startX,i.img.destTop=n.startY,i.img.destWidth=n.width,i.img.destHeight=n.height}},o.prototype.flipImage=function(e){var i=this,o=this.parent,r={direction:e,cancel:!1,previousDirection:o.toPascalCase(o.transform.currFlipState||e)};!this.isPreventSelect&&t.isBlazor()&&o.events&&!0===o.events.flipping.hasDelegate?o.dotNetRef.invokeMethodAsync("FlipEventAsync","OnFlip",r).then(function(t){i.flipEvent(t,e)}):(this.isPreventSelect||o.trigger("flipping",r),this.flipEvent(r,e))},o.prototype.flipEvent=function(e,i){var o=this.parent;if(!e.cancel){var r;if(t.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],o.objColl,null,!0),r.pointColl=t.extend({},o.pointColl,null,!0),r.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0)}o.afterCropActions.push("horizontal"===i.toLowerCase()?"horizontalflip":"verticalflip");var s,l=[];o.activeObj.activePoint&&(void 0!==o.activeObj.shape&&(l=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===l[0])&&(s=o.currObjType.isCustomCrop?"custom":l[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.clearContext(this.lowerContext),o.clearContext(this.upperContext);var p=t.extend([],o.objColl,[],!0),h=t.extend({},o.activeObj,{},!0);o.objColl=[],o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseFlip||o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=i.toLowerCase();this.updateFlipState(c),o.transform.currFlipState="horizontal"===c?"horizontal"===o.transform.currFlipState.toLowerCase()?"":"horizontal":"vertical"===o.transform.currFlipState.toLowerCase()?"":"vertical";var d={isSelected:null};o.notify("draw",{prop:"getRotatedFlipCropSelection",onPropertyChange:!1,value:{bool:d}}),d.isSelected&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y);var v=this.lowerContext.filter;if(o.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=v,o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.updateFlipState(i.toLowerCase()),this.isReverseFlip||(o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),this.updateFlipColl(i.toLocaleLowerCase()),o.rotateFlipColl.push(i.toLowerCase())),1===o.rotateFlipColl.length){var u={panRegion:""};o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:u}}),""===u.panRegion?o.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}):this.setDestPointsForFlipState()}o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.objColl=t.extend([],p,[],!0),o.activeObj=t.extend({},h,{},!0);for(var g=0,b=o.objColl.length;g<b;g++){var f=o.objColl[g].flipObjColl;0===f.length?f.push(i):f[f.length-1]===i?f.pop():f.push(i)}o.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:i.toLowerCase()}});var m=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),"horizontal"===i.toLowerCase()||"vertical"===i.toLowerCase()?(o.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:i.toLowerCase()}}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})):o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=m,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.updateCurrSelectionPoint(i.toLowerCase()),o.isUndoRedo=!1,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),s&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}));var C={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:C}}),o.rotateFlipColl=C.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.updateFlipState=function(e){var t=this.parent.transform.degree;"horizontal"===e?t%90==0&&t%180!=0?this.verticalFlip():this.horizontalFlip():"vertical"===e&&(t%90==0&&t%180!=0?this.horizontalFlip():this.verticalFlip())},o.prototype.horizontalFlip=function(){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)},o.prototype.verticalFlip=function(){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)},o.prototype.updateFlipColl=function(e){if(!this.isPreventSelect&&(0===this.flipColl.length||this.flipColl[this.flipColl.length-1]!==e?this.flipColl.push(e):this.flipColl.pop(),this.flipColl.length>=4)){var t=this.flipColl.slice(-4);("horizontal"===t[0]&&"vertical"===t[1]&&"horizontal"===t[2]&&"vertical"===t[3]||"vertical"===t[0]&&"horizontal"===t[1]&&"vertical"===t[2]&&"horizontal"===t[3])&&this.flipColl.splice(-4)}},o.prototype.setDestPointsForFlipState=function(){var e=this.parent,t={panRegion:""};e.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:t}}),""!==t.panRegion&&("horizontal"===t.panRegion?e.img.destLeft=e.lowerCanvas.clientWidth-(e.img.destWidth+e.img.destLeft):"vertical"===t.panRegion?e.img.destTop=e.lowerCanvas.clientHeight-(e.img.destHeight+e.img.destTop):(e.img.destLeft=e.lowerCanvas.clientWidth-(e.img.destWidth+e.img.destLeft),e.img.destTop=e.lowerCanvas.clientHeight-(e.img.destHeight+e.img.destTop)))},o.prototype.zoomAction=function(e,i,o){var r=this,a=this.parent;if(!a.disabled&&a.isImageLoaded){if(t.isNullOrUndefined(o)&&(a.zoomSettings.zoomFactor>=a.zoomSettings.maxZoomFactor&&e>0||a.zoomSettings.zoomFactor>a.zoomSettings.minZoomFactor&&e<0&&this.disableZoomOutBtn(!0)||a.zoomSettings.zoomFactor<=a.zoomSettings.minZoomFactor&&e<0))return void(t.isBlazor()||a.notify("toolbar",{prop:"zoom-up-handler",onPropertyChange:!1}));a.notify("draw",{prop:"setImageEdited",onPropertyChange:!1});var n=e;e=n>0?.1:-.1;for(var s=0;s<Math.round(Math.abs(n/.1));s++)if(1===this.prevZoomValue)this.prevZoomValue+=e>0?10*e:10*e/10;else if(this.prevZoomValue>1)this.prevZoomValue+=10*e;else if(this.prevZoomValue<1){this.prevZoomValue+=10*e/10;var l=Math.pow(10,1);this.prevZoomValue=Math.round(this.prevZoomValue*l)/l}e=n,a.setProperties({zoomSettings:{zoomFactor:this.prevZoomValue}},!0);var p=void 0;this.tempActiveObj=null,this.isShape=!1,void 0!==a.activeObj.shape&&("shape"===a.activeObj.shape?a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}):p=a.activeObj.shape.split("-")),void 0!==p&&"crop"===p[0]?(this.tempActiveObj=t.extend({},a.activeObj,{},!0),a.isCropTab=!0):a.activeObj.shape&&"crop"!==p[0]&&(this.isShape=!0);var h={zoomType:null};a.notify("selection",{prop:"getZoomType",onPropertyChange:!1,value:{obj:h}}),t.isNullOrUndefined(i)&&(i=a.isCropTab&&this.tempActiveObj?{x:a.activeObj.activePoint.startX+a.activeObj.activePoint.width/2,y:a.activeObj.activePoint.startY+a.activeObj.activePoint.height/2}:{x:a.lowerCanvas.clientWidth/2,y:a.lowerCanvas.clientHeight/2},"MouseWheel"!==h.zoomType&&"Pinch"!==h.zoomType||(i={x:a.zoomSettings.zoomPoint.x,y:a.zoomSettings.zoomPoint.y}));var c={zoomPoint:i,cancel:!1,previousZoomFactor:a.zoomSettings.zoomFactor-10*e,currentZoomFactor:a.zoomSettings.zoomFactor,zoomTrigger:h.zoomType};!a.isCropToolbar&&t.isBlazor()&&a.events&&!0===a.events.zooming.hasDelegate?a.dotNetRef.invokeMethodAsync("ZoomEventAsync","OnZoom",c).then(function(t){r.zoomEvent(t,e)}):(a.isCropToolbar||a.trigger("zooming",c),this.zoomEvent(c,e))}},o.prototype.zoomEvent=function(e,i){var o=this.parent;if(!e.cancel){t.isBlazor()?"resize-toolbar"!==o.currentToolbar&&o.element.querySelector(".e-contextual-toolbar-wrapper")&&!o.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hidden")&&o.updateToolbar(o.element,"closeContextualToolbar"):o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var r={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=r.canvasFilter,o.upperCanvas.style.cursor=o.cursor="default";var a=t.extend([],o.objColl,[],!0);if(!o.isCropTab){if(0!==o.transform.degree){o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.panPoint.currentPannedPoint={x:0,y:0};var n=o.allowDownScale;o.allowDownScale=!1,this.rotatePan(!0,!0),o.allowDownScale=n}else""!==o.transform.currFlipState&&(o.panPoint.totalPannedPoint={x:0,y:0});o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}if(0===o.transform.degree){this.drawZoomImgToCanvas(i,this.tempActiveObj);var s={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:s}}),""!==s.panRegion){o.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:o.panPoint.totalPannedPoint,isAdd:!0}}),a=t.extend([],o.objColl,[],!0),o.objColl=[];var l=o.img.destLeft,p=o.img.destTop;this.setDestPointsForFlipState(),this.rotatedFlip(),o.img.destLeft=l,o.img.destTop=p,o.objColl=a,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&!o.isCropTab&&(o.panPoint.totalPannedPoint={x:0,y:0})}else{o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),o.panPoint.totalPannedClientPoint={x:0,y:0},o.panPoint.totalPannedInternalPoint={x:0,y:0},this.rotateZoom(i);var h={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:h}}),""!==h.panRegion){n=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n}}var c=Math.pow(10,1);(o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor||Math.round(o.transform.zoomFactor*c)/c==2)&&(clearInterval(this.zoomBtnHold),this.zoomBtnHold=0);var d={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:d}}),""===d.panRegion){n=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n}(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.tempActiveObj&&(o.activeObj=t.extend({},this.tempActiveObj,{},!0),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&(o.currSelectionPoint=null)),o.isUndoRedo=!1;var v;t.isBlazor()?(v=o.element.querySelector("#zoomout"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?v.classList.add("e-overlay"):v&&v.classList.remove("e-overlay"):(v=document.querySelector("#"+o.element.id+"_zoomOut"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?(v.classList.add("e-disabled"),v.parentElement.classList.add("e-overlay")):v&&(v.classList.remove("e-disabled"),v.parentElement.classList.remove("e-overlay")),this.autoEnablePan(),this.tempActiveObj&&(o.activeObj=t.extend({},this.tempActiveObj,{},!0)),"crop-custom"===o.activeObj.shape&&(o.currObjType.isCustomCrop=!0);var u=o.element.querySelector(".e-img-pan .e-btn");u&&o.togglePan?u.classList.add("e-selected-btn"):u&&u.classList.remove("e-selected-btn"),this.isShape&&(o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),t.isBlazor()||(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),t.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}),o.notify("selection",{prop:"setZoomType",onPropertyChange:!1,value:{zoomType:"Toolbar"}})}},o.prototype.disableZoomOutBtn=function(e){var i,o=this.parent,r=!1;t.isNullOrUndefined(e)||(o.transform.zoomFactor-=.1),i=t.isBlazor()?this.parent.element.querySelector("#zoomout"):document.querySelector("#"+o.element.id+"_zoomOut");var a=o.img.destLeft,n=o.img.destTop,s=o.img.destWidth,l=o.img.destHeight;return o.activeObj.shape?(this.setZoomDimension(-.1,o.activeObj),t.isNullOrUndefined(i)||(o.img.destLeft>o.activeObj.activePoint.startX||o.img.destTop>o.activeObj.activePoint.startY||o.img.destLeft+o.img.destWidth<o.activeObj.activePoint.endX||o.img.destTop+o.img.destHeight<o.activeObj.activePoint.endY||o.zoomSettings.zoomFactor===o.zoomSettings.minZoomFactor?(t.isBlazor()?i.classList.add("e-overlay"):(i.classList.add("e-disabled"),i.parentElement.classList.add("e-overlay")),r=!0):(t.isBlazor()?i.classList.remove("e-overlay"):(i.classList.remove("e-disabled"),i.parentElement.classList.remove("e-overlay")),r=!1))):this.setZoomDimension(-.1,null),t.isNullOrUndefined(e)||(o.transform.zoomFactor+=.1),o.img.destLeft=a,o.img.destTop=n,o.img.destWidth=s,o.img.destHeight=l,r},o.prototype.drawZoomImgToCanvas=function(e,t){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===e?i.transform.zoomFactor=0:i.transform.zoomFactor+=e,i.transform[i.isCropTab?"cropZoomFactor":"defaultZoomFactor"]=i.transform.zoomFactor;var r={width:0,height:0};i.isCropTab?r=this.cropZoom(e,t):((r=this.calcMaxDimension(i.img.srcWidth,i.img.srcHeight)).width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.img.destLeft=(i.lowerCanvas.clientWidth-r.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-r.height)/2),i.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:r}}),r.width=this.cropDimension.width,r.height=this.cropDimension.height,r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:r.width,height:r.height}})},o.prototype.rotatedFlip=function(){var e=this.parent;this.isReverseFlip=!0;var i=e.transform.currFlipState,o=this.flipColl,r=t.extend([],e.objColl,[],!0),a=t.extend({},e.activeObj,{},!0);this.flipColl=[],e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}});var n=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,context:null,isPreventCircleCrop:null}}),""===i&&""!==e.transform.currFlipState&&(i=e.transform.currFlipState),e.transform.currFlipState=i,this.flipColl=o,e.objColl=t.extend([],r,[],!0),this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=n,0!==a.activePoint.width&&(e.activeObj=t.extend({},a,{},!0)),this.isReverseFlip=!1},o.prototype.rotateZoom=function(e){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===e?i.transform.zoomFactor=0:i.transform.zoomFactor+=e,i.isCropTab?i.transform.cropZoomFactor=i.transform.zoomFactor:i.transform.defaultZoomFactor=i.transform.zoomFactor;var r=t.extend([],i.objColl,[],!0),a=t.extend({},i.activeObj,{},!0);i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var n=this.lowerContext.filter;i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.objColl=r,i.activeObj=a;var s={width:this.cropDimension.width,height:this.cropDimension.height};s.width+=s.width*i.transform.zoomFactor,s.height+=s.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:s.width,height:s.height}})},o.prototype.autoEnablePan=function(){this.parent.transform.zoomFactor<=0?(this.parent.togglePan=!1,this.parent.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),this.parent.pan(!1),this.disablePan=!1):this.parent.pan(!this.disablePan)},o.prototype.cropZoom=function(e,i){var o=this.parent,r=o.img.destLeft,a=o.img.destTop,n={width:0,height:0};return 0===o.img.srcLeft||0===o.img.srcTop?n=t.isNullOrUndefined(i)?this.setZoomDimension(e,null):this.setZoomDimension(e,i):((n=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).width+=n.width*o.transform.zoomFactor,n.height+=n.height*o.transform.zoomFactor),o.img.destLeft=r-(n.width-o.img.destWidth)/2,o.img.destTop=a-(n.height-o.img.destHeight)/2,r=o.img.destLeft,a=o.img.destTop,i&&(o.img.destLeft>i.activePoint.startX&&(o.img.destLeft=i.activePoint.startX,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop>i.activePoint.startY&&(o.img.destTop=i.activePoint.startY,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop)),o.img.destLeft+n.width<i.activePoint.endX&&(o.img.destLeft=i.activePoint.endX-n.width,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop+n.height<i.activePoint.endY&&(o.img.destTop=i.activePoint.endY-n.height,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop))),n},o.prototype.setZoomDimension=function(e,i){var o=this.parent,r={width:0,height:0};if(r=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight),r.width+=r.width*o.transform.zoomFactor,r.height+=r.height*o.transform.zoomFactor,o.img.destLeft+=(o.img.destWidth-r.width)/2,o.img.destTop+=(o.img.destHeight-r.height)/2,e<0&&i){var a=i.activePoint.startX,n=i.activePoint.startY,s=i.activePoint.width,l=i.activePoint.height,p=o.img.destLeft+r.width,h=o.img.destTop+r.height;o.img.destLeft>a&&(o.img.destLeft=a),o.img.destTop>n&&(o.img.destTop=n),p<a+s&&(o.img.destLeft=a+s-r.width),h<n+l&&(o.img.destTop=n+l-r.height)}else e<0&&t.isNullOrUndefined(i)&&(o.img.destLeft>0&&(o.img.destLeft=0),o.img.destTop>0&&(o.img.destTop=0),o.img.destLeft+r.width<o.lowerCanvas.width&&(o.img.destLeft=o.lowerCanvas.width-o.img.destWidth),o.img.destTop+r.height<o.lowerCanvas.height&&(o.img.destTop=o.lowerCanvas.height-o.img.destHeight));return r},o.prototype.drawPannedImage=function(e,i){var o=this,r=this.parent,a={panDown:null};r.notify("selection",{prop:"getPanDown",onPropertyChange:!1,value:{obj:a}});var n={startPoint:a.panDown,endPoint:this.panMove,cancel:!1};t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onPanStart.hasDelegate?(this.parent.eventType="pan",this.parent.panEventArgs=n,r.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanStart",n).then(function(t){o.panEvent(t,e,i)})):(r.trigger("panning",n),this.panEvent(n,e,i))},o.prototype.panEvent=function(e,i,o){if(!e.cancel){var r=this.parent,a=!1;if(r.activeObj.shape&&"shape"===r.activeObj.shape&&r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isNullOrUndefined(r.activeObj.shape)){a=!0,r.activeObj.activePoint={startX:r.img.destLeft,startY:r.img.destTop,endX:r.img.destLeft+r.img.destWidth,endY:r.img.destTop+r.img.destHeight};var n=r.activeObj.activePoint.startX,s=r.activeObj.activePoint.startY,l=r.activeObj.activePoint.endX,p=r.activeObj.activePoint.endY;n<0&&(r.activeObj.activePoint.startX=0),s<0&&(r.activeObj.activePoint.startY=0),l>r.lowerCanvas.width&&(r.activeObj.activePoint.endX=r.lowerCanvas.width),p>r.lowerCanvas.height&&(r.activeObj.activePoint.endY=r.lowerCanvas.height),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY,r.activeObj.shape="crop-custom";var h={strokeSettings:{}};r.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:h}}),r.activeObj.strokeSettings=h.strokeSettings,r.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:r.activeObj.activePoint,obj:r.activeObj,isMouseMove:null,x:null,y:null}}),r.isCropTab=!0}if(0===r.transform.degree){var c=void 0;c=t.isNullOrUndefined(i)&&t.isNullOrUndefined(o)?this.updatePanPoints(""):{x:i,y:o},r.panPoint.totalPannedPoint.x+=c.x,r.panPoint.totalPannedPoint.y+=c.y;var d=t.extend({},r.activeObj,{},!0),v=this.lowerContext.filter;this.drawPannImage(c),this.lowerContext.filter=v,this.tempPanMove=t.extend({},this.panMove,{},!0),r.activeObj=t.extend({},d,{},!0),this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.activeObj.shape&&r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj}})}else{var u=r.transform.currFlipState;r.isCropTab=!0,t.isNullOrUndefined(i)&&t.isNullOrUndefined(o)?r.panPoint.currentPannedPoint=this.updatePanPoints(""):r.panPoint.currentPannedPoint={x:i,y:o},r.transform.currFlipState=u,this.rotatePan(),r.isCropTab=!1,this.tempPanMove=t.extend({},this.panMove,{},!0)}a&&(r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.isCropTab=!1,this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height))}},o.prototype.drawPannImage=function(e){var t=this.parent,i=this.lowerContext.filter,o={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height,this.setDestPointsForFlipState(),t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}}),this.lowerContext.filter=i,t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height;var r=this.lowerContext.filter;this.lowerContext.filter="none",t.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:e.x,yDiff:e.y,panRegion:""}}),t.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:e.x,yDiff:e.y,panRegion:""}}),this.lowerContext.filter=r,t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}})},o.prototype.resetZoom=function(){var e=this.parent;if(0!==e.transform.defaultZoomFactor){var i=e.isUndoRedo,o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),this.transCurrObj=o.currObj,this.transCurrObj.objColl=t.extend([],e.objColl,null,!0),this.transCurrObj.pointColl=t.extend({},e.pointColl,null,!0),this.transCurrObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var r={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),this.transCurrObj.selPointColl=t.extend([],r.selPointColl,[],!0),e.isUndoRedo=e.isCropToolbar=!0,e.transform.defaultZoomFactor>0?this.zoomAction(-e.transform.defaultZoomFactor):this.zoomAction(Math.abs(e.transform.defaultZoomFactor)),e.isCropToolbar=!1,e.isUndoRedo=i}},o.prototype.performTransformation=function(e){var i=this.parent,o=i.transform.defaultZoomFactor,r=i.isUndoRedo,a=t.extend({},i.cropObj,{},!0);this.resetZoom(),this.updateTransform(e);for(var n=0,s=i.objColl.length;n<s;n++)if(i.objColl[n].flipObjColl.length>0){var l={collection:i.objColl[n].flipObjColl};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.objColl[n].flipObjColl,isRotateFlipCollection:null,obj:l}}),i.objColl[n].flipObjColl=l.collection,0===i.objColl[n].flipObjColl.length&&(i.objColl[n].shapeFlip="")}if(0!==o){i.isUndoRedo=!0,this.zoomAction(o),i.isUndoRedo=r;var p="";"rotateleft"===e||"rotateright"===e?p="rotate":"horizontalflip"!==e&&"verticalflip"!==e||(p="flip"),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:p,previousObj:this.transCurrObj,previousObjColl:this.transCurrObj.objColl,previousPointColl:this.transCurrObj.pointColl,previousSelPointColl:this.transCurrObj.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.transCurrObj=null}},o.prototype.updateTransform=function(t){switch(t.toLowerCase()){case"rotateleft":this.rotateImage(-90);break;case"rotateright":this.rotateImage(90);break;case"horizontalflip":this.flipImage(e.Direction.Horizontal);break;case"verticalflip":this.flipImage(e.Direction.Vertical)}},o.prototype.rotatePan=function(e,i){var o=this.parent;this.isReverseRotate=!0;var r,a=o.transform.degree,n={selPointColl:null};o.activeObj.activePoint&&o.activeObj.shape&&(r=t.extend({},o.activeObj,{},!0));var s=t.extend([],o.objColl,[],!0),l=t.extend([],o.pointColl,[],!0);o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});var p=n.selPointColl;o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=o.img.destLeft,c=o.img.destTop;o.isCropTab&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y),o.notify("crop",{prop:"updateRotatePan",onPropertyChange:!1}),o.isCropTab&&(o.panPoint.totalPannedInternalPoint.x=o.img.destLeft-h,o.panPoint.totalPannedInternalPoint.y=o.img.destTop-c);var d=this.lowerContext.filter;o.notify("draw",{prop:"drawImage",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,isRotatePan:!0}});var v=o.img.destLeft,u=o.img.destTop;o.img.destLeft+=o.panPoint.totalPannedClientPoint.x,o.img.destTop+=o.panPoint.totalPannedClientPoint.y,o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y,o.panPoint.totalPannedClientPoint.x=o.img.destLeft-v,o.panPoint.totalPannedClientPoint.y=o.img.destTop-u,o.objColl=s,o.pointColl=l,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),o.transform.degree=a,this.lowerContext.filter="none",e&&(i?(o.panPoint.totalPannedClientPoint.x=-o.panPoint.totalPannedClientPoint.x,o.panPoint.totalPannedClientPoint.y=-o.panPoint.totalPannedClientPoint.y,o.panPoint.currentPannedPoint=t.extend({},o.panPoint.totalPannedClientPoint,{},!0),o.panPoint.totalPannedClientPoint={x:0,y:0},o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y):o.panPoint.currentPannedPoint=t.extend({},o.panPoint.totalPannedClientPoint,{},!0)),o.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),o.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),this.lowerContext.filter=d,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},r,{},!0),o.activeObj.activePoint&&o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),this.isReverseRotate=!1},o.prototype.limitPan=function(){var e=this.parent;e.activeObj.activePoint&&(e.img.destLeft>e.activeObj.activePoint.startX&&(e.img.destLeft=e.activeObj.activePoint.startX),e.img.destTop>e.activeObj.activePoint.startY&&(e.img.destTop=e.activeObj.activePoint.startY),e.img.destLeft+e.img.destWidth<e.activeObj.activePoint.endX&&(e.img.destLeft=e.activeObj.activePoint.endX-e.img.destWidth),e.img.destTop+e.img.destHeight<e.activeObj.activePoint.endY&&(e.img.destTop=e.activeObj.activePoint.endY-e.img.destHeight))},o.prototype.updateFlipActiveObj=function(e){var t=this.parent;"horizontal"===e?(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?t.activeObj.activePoint.endX=t.lowerCanvas.width/2-(t.activeObj.activePoint.startX-t.lowerCanvas.width/2):t.activeObj.activePoint.endX=t.lowerCanvas.width/2+(t.lowerCanvas.width/2-t.activeObj.activePoint.startX),t.activeObj.activePoint.startX=t.activeObj.activePoint.endX-t.activeObj.activePoint.width):"vertical"===e?(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?t.activeObj.activePoint.endY=t.lowerCanvas.height/2-(t.activeObj.activePoint.startY-t.lowerCanvas.height/2):t.activeObj.activePoint.endY=t.lowerCanvas.height/2+(t.lowerCanvas.height/2-t.activeObj.activePoint.startY),t.activeObj.activePoint.startY=t.activeObj.activePoint.endY-t.activeObj.activePoint.height):"verticalHorizontal"!==e&&"horizontalVertical"!==e||(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?(t.activeObj.activePoint.endX=t.lowerCanvas.width/2-(t.activeObj.activePoint.startX-t.lowerCanvas.width/2),t.activeObj.activePoint.endY=t.lowerCanvas.height/2-(t.activeObj.activePoint.startY-t.lowerCanvas.height/2)):(t.activeObj.activePoint.endX=t.lowerCanvas.width/2+(t.lowerCanvas.width/2-t.activeObj.activePoint.startX),t.activeObj.activePoint.endY=t.lowerCanvas.height/2+(t.lowerCanvas.height/2-t.activeObj.activePoint.startY)),t.activeObj.activePoint.startX=t.activeObj.activePoint.endX-t.activeObj.activePoint.width,t.activeObj.activePoint.startY=t.activeObj.activePoint.endY-t.activeObj.activePoint.height),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}})},o.prototype.pan=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&(e?(t.togglePan=!0,t.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="grab",t.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}})):(t.togglePan=t.currObjType.isCustomCrop=!1,t.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="default"))},o.prototype.zoom=function(e,i){var o=this.parent;if(!o.disabled&&o.isImageLoaded){var r=this.getCurrentZoomFactor(e);if(t.isNullOrUndefined(i))this.zoomAction(r,i);else for(var a=r>0?"zoomIn":"zoomOut",n=0;n<10*Math.abs(r);n++)o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:i.x,y:i.y,type:a}})}},o.prototype.getCurrentZoomFactor=function(e){return.1*(e-this.prevZoomValue)},o.prototype.setCurrPanRegion=function(e,t,i){var o=e;""===e?"horizontal"===t?o="horizontal":"vertical"===t&&(o="vertical"):"horizontal"===e?"horizontal"===t?o="horizontalVertical":"vertical"===t?o="verticalHorizontal":90===t?o="vertical":-90===t&&(o="horizontal"):"vertical"===e?"horizontal"===t?o="horizontalVertical":"vertical"===t?o="verticalHorizontal":90===t?o="horizontal":-90===t&&(o="vertical"):"horizontal"===t?o="vertical":"vertical"===t&&(o="horizontal"),i.panRegion=o},o.prototype.rotate=function(e,t){var i=this.parent;!i.disabled&&i.isImageLoaded&&e%90==0&&this.rotateImage(e),t.isRotate=!1},o.prototype.flip=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&this.flipImage(e)},o.prototype.update=function(){var e=this.parent,o=0,r=!1,a=!1,n={bool:!1};if(e.isImageLoaded){var s={bool:null};e.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:s}}),(s.bool||t.isBlazor()&&"frame-toolbar"==e.currentToolbar)&&(r=!0),(e.element.querySelector("#"+e.element.id+"_contextualToolbar")&&!e.element.querySelector("#"+e.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||e.element.querySelector("#"+e.element.id+"_headWrapper")&&!e.element.querySelector("#"+e.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.okBtn(),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):(e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),e.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:n}}),n.bool&&(t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),void 0!==e.activeObj.shape&&(a=!0,"block"===e.textArea.style.display?(e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})):(e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj)),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}var l=this.lowerContext.filter,p=document.querySelector("#"+e.element.id+"_canvasWrapper");if(p&&(p.style.width=e.element.offsetWidth-2+"px"),e.lowerCanvas.width=e.upperCanvas.width=e.element.offsetWidth-2,e.toolbarTemplate?o=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight:e.element.querySelector("#"+e.element.id+"_toolbar")&&(o=e.element.querySelector("#"+e.element.id+"_toolbar").clientHeight),e.notify("toolbar",{prop:"setToolbarHeight",value:{height:o}}),t.Browser.isDevice?(p&&(p.style.height=e.element.offsetHeight-2*o-5+"px"),e.lowerCanvas.height=e.upperCanvas.height=e.element.offsetHeight-2*o-5):(p&&(p.style.height=e.element.offsetHeight-o-3+"px"),e.lowerCanvas.height=e.upperCanvas.height=e.element.offsetHeight-o-3),this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",e.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),e.canvasFilter=this.lowerContext.filter,this.parent.initialAdjustmentValue=this.lowerContext.filter,e.clearContext(this.lowerContext),this.parent.clearContext(this.upperContext),e.isImageLoaded){if(e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.filter=l,e.initialAdjustmentValue=l,e.canvasFilter=this.lowerContext.filter,e.isImageLoaded&&(i.showSpinner(e.element),e.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),p){p.style.width=e.element.offsetWidth-2+"px",p.style.height=e.element.offsetHeight+"px";var h={toolbarHeight:t.isBlazor()?e.toolbarHeight:0};t.isBlazor()||e.notify("toolbar",{prop:"getToolbarHeight",value:{obj:h}}),t.Browser.isDevice?p.style.height=parseFloat(p.style.height)-2*h.toolbarHeight-3+"px":p.style.height=parseFloat(p.style.height)-h.toolbarHeight-3+"px"}var c={width:0,height:0};this.calcMaxDimension(e.img.srcWidth,e.img.srcHeight,c);var d=c;if(e.transform.defaultZoomFactor>0&&(d.width+=d.width*e.transform.defaultZoomFactor,d.height+=d.height*e.transform.defaultZoomFactor),e.img.destLeft=(e.lowerCanvas.clientWidth-d.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-d.height)/2,0===e.transform.degree&&""===e.transform.currFlipState)e.transform.defaultZoomFactor>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:d}});else{e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:d}}),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var v=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=v,e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}})}e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.hideSpinner(e.element),e.element.style.opacity="1";var u={defToolbarItems:null};if(!t.isBlazor()&&(e.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:u}}),u.defToolbarItems&&u.defToolbarItems.length>0&&document.getElementById(e.element.id+"_toolbar"))){t.getComponent(e.element.id+"_toolbar","toolbar").refreshOverflow(),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")}if(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),a){var g=t.extend({},e.objColl[e.objColl.length-1],null,!0);e.objColl.pop(),0!==g.activePoint.width&&0!==g.activePoint.height&&(this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:g}}),"rectangle"!==e.activeObj.shape&&"ellipse"!==e.activeObj.shape&&"text"!==e.activeObj.shape&&"line"!==e.activeObj.shape&&"arrow"!==e.activeObj.shape&&"path"!==e.activeObj.shape&&"image"!==e.activeObj.shape||(t.isBlazor()?e.updateToolbar(e.element,"quickAccessToolbar",e.activeObj.shape):e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})))}if(n.bool&&(t.isBlazor()?e.updateToolbar(e.element,"quickAccessToolbar","pen"):e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}})),r?t.isBlazor()?e.updateToolbar(e.element,"frame"):e.notify("toolbar",{prop:"callFrameToolbar",onPropertyChange:!1}):e.isResize&&(e.aspectWidth=Math.ceil(e.img.destWidth),e.aspectHeight=Math.ceil(e.img.destHeight),t.isBlazor()?e.updateToolbar(e.element,"resize"):(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}))),(0!==e.transform.degree||""!==e.transform.currFlipState)&&e.transform.defaultZoomFactor>0){var b=t.extend({},e.panPoint.totalPannedPoint,null,!0),f=t.extend({},e.panPoint.totalPannedInternalPoint,null,!0),m=t.extend({},e.panPoint.totalPannedClientPoint,null,!0);this.zoomAction(.1),this.zoomAction(-.1),0===e.transform.degree?(e.img.destLeft+=b.x,e.img.destTop+=b.y,e.panPoint.totalPannedPoint=b,e.notify("draw",{prop:"updateFlipPan",value:{tempSelectionObj:null}})):(e.panPoint.totalPannedInternalPoint=f,e.panPoint.totalPannedClientPoint=m,e.panPoint.currentPannedPoint={x:0,y:0},e.isCropTab=!0,this.rotatePan(),e.isCropTab=!1)}else 0!==e.transform.degree&&e.transform.cropZoomFactor>0&&(e.transform.zoomFactor=0,e.transform.cropZoomFactor=null,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):e.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}))}},o.prototype.calcMaxDimension=function(e,i,o,r){var a={toolbarHeight:0};t.isBlazor()?a.toolbarHeight=this.parent.toolbarHeight:this.parent.notify("toolbar",{prop:"getToolbarHeight",value:{obj:a}});var n=r?this.parent.element.clientWidth/3:this.parent.element.clientWidth,s=r?(this.parent.element.clientHeight-a.toolbarHeight)/3:this.parent.element.clientHeight-a.toolbarHeight;s=t.Browser.isDevice?s-a.toolbarHeight:s,t.isNullOrUndefined(r)&&(n>30&&(n-=30),s>30&&(s-=30));var l=n/e,p=s/i,h=Math.min(e,n),c=Math.min(i,s);if(l<1&&l<p?(h=e*l,c=i*l):p<1&&p<l&&(h=e*p,c=i*p),t.isNullOrUndefined(r)){var d={bool:null};this.parent.notify("crop",{prop:"getPreventScaling",onPropertyChange:!1,value:{obj:d}}),d.bool&&this.parent.cropObj.activeObj.activePoint&&0!==this.parent.cropObj.activeObj.activePoint.width&&0!==this.parent.cropObj.activeObj.activePoint.height&&(h=this.parent.cropObj.activeObj.activePoint.width,c=this.parent.cropObj.activeObj.activePoint.height)}return o&&(o.width=h,o.height=c),{width:h,height:c}},o.prototype.updatePanPoints=function(e,i){var o=this.parent,r=t.extend({},o.activeObj,{},!0),a=o.img.destLeft,n=o.img.destTop;t.isNullOrUndefined(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y});var s=this.panMove.x-this.tempPanMove.x,l=this.panMove.y-this.tempPanMove.y;switch(e){case"":o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontal":this.updateFlipActiveObj(e),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop+=l;break;case"vertical":this.updateFlipActiveObj(e),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontalVertical":this.updateFlipActiveObj(e),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop-=l;break;case"verticalHorizontal":this.updateFlipActiveObj(e),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft-=s,o.img.destTop+=l}return this.limitPan(),o.activeObj=r,i&&(i.x=o.img.destLeft-a,i.y=o.img.destTop-n),{x:o.img.destLeft-a,y:o.img.destTop-n}},o.prototype.resizeImage=function(e,i){var o=this.parent,r=!0,a=!0;o.allowDownScale=!1,o.img.srcLeft=0,o.img.srcTop=0,o.isAspectRatio=!0;var n=[];for(o.img.srcWidth=o.baseImg.width,o.img.srcHeight=o.baseImg.height,o.resizeSrc&&0!=o.resizeSrc.width&&0!=o.resizeSrc.height&&(o.img.srcLeft=o.resizeSrc.startX,o.img.srcTop=o.resizeSrc.startY,o.img.srcWidth=o.resizeSrc.width,o.img.srcHeight=o.resizeSrc.height);(e<o.img.destWidth||i<o.img.destHeight)&&a;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),a=!1,n.push(o.img.destWidth);for(;(e>o.img.destWidth||i>o.img.destHeight)&&a&&r;)if(this.zoomAction(.1,null,!0),e<o.img.destWidth||i<o.img.destHeight)for(;e<o.img.destWidth;)this.zoomAction(-.0125,null,!0),r=!1,n.push(o.img.destWidth);for(var s=n[0],l=Math.abs(o.img.destWidth-s),p=0,h=n;p<h.length;p++){var c=h[p],d=Math.abs(e-c);d<l&&(s=c,l=d)}s<e&&r&&(this.zoomAction(-.0125,null,!0),r=!1),s>e&&!r&&(this.zoomAction(.0125,null,!0),r=!1),this.zoomAction(.0125,null,!0),o.allowDownScale=!0,this.zoomAction(-.0125,null,!0);var v=t.extend({},o.cropObj,{},!0),u=t.extend({},this.prevResizeCurrObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:u,previousObjColl:u.objColl,previousPointColl:u.pointColl,previousSelPointColl:u.selPointColl,previousCropObj:v,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},o.prototype.resizeCrop=function(e,i){var o=this.parent,r=!0,a={prevObj:o.prevObj};o.cropObj=t.extend({},o.prevCropObj,{},!0),o.allowDownScale=!1,o.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:a}});var n=t.extend({},a.prevObj.activeObj,{},!0);a.prevObj.activeObj=t.extend({},o.activeObj,{},!0),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a.prevObj}}),o.objColl=t.extend([],a.prevObj.objColl,[],!0),o.pointColl=t.extend([],a.prevObj.pointColl,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var s=e,l=i,p=!1;if(i>=e&&i<=Math.ceil(o.img.destHeight)){for(;i<=Math.ceil(o.img.destHeight)&&r;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),r=!1}else if(i<=e&&e<o.img.destWidth){for(;e<o.img.destWidth&&r;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),r=!1}else if(i>=e&&i>=o.img.destHeight)for(;i>=o.img.destHeight&&r;)this.zoomAction(.1,null,!0);else if(e>=i&&e>=o.img.destWidth){for(;e>=o.img.destWidth&&r;)this.zoomAction(.1,null,!0);if(e<o.img.destWidth&&i<o.img.destHeight){for(;e<o.img.destWidth&&i<o.img.destHeight;)this.zoomAction(-.0125,null,!0),r=!1;this.zoomAction(.0125,null,!0)}}else if(i>o.img.destHeight&&e>o.img.destWidth){for(;i>o.img.destHeight&&e>o.img.destWidth&&r;)this.zoomAction(.1,null,!0);if(e<o.img.destWidth&&i<o.img.destHeight){for(;e<o.img.destWidth&&i<o.img.destHeight;)this.zoomAction(-.0125,null,!0),r=!1;this.zoomAction(.0125,null,!0)}}if(this.resizeImg(n,e,i),e=s,(i=l)!==o.img.destHeight||e!==o.img.destWidth){for(;i>o.img.destHeight||e>o.img.destWidth;)this.zoomAction(.0125,null,!0),p=!0;p&&(this.zoomAction(-.0125,null,!0),p=!1)}if(i!==o.img.destHeight||e!==o.img.destWidth){for(;i<o.img.destHeight||e<o.img.destWidth;)this.zoomAction(-.0125,null,!0),p=!0;p&&(this.zoomAction(-.0125,null,!0),p=!1)}a.prevObj.activeObj=t.extend({},n,{},!0),this.zoomAction(.0125,null,!0),o.allowDownScale=!this.preventDownScale,o.isCropTab=!1,this.zoomAction(-.0125,null,!0),o.aspectWidth=e,o.aspectHeight=i},o.prototype.resizeImg=function(e,i,o){var r=this.parent,a=i/r.img.destWidth,n=o/r.img.destHeight;e.shape?r.currSelectionPoint=e:r.img.srcWidth===r.baseImgCanvas.width&&r.img.srcHeight===r.baseImgCanvas.height&&(r.currSelectionPoint=null,r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}})),t.isNullOrUndefined(r.currSelectionPoint)?r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:r.img.destLeft,startY:r.img.destTop,width:r.img.destWidth,height:r.img.destHeight}}):r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),i=r.activeObj.activePoint.width*a,o=r.activeObj.activePoint.height*n;var s=r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2-i/2,l=r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2-o/2;r.transform.defaultZoomFactor=0,r.notify("draw",{prop:"setResizeSelect",value:{bool:!0}}),r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:s,startY:l,width:i,height:o}}),r.notify("draw",{prop:"setResizeSelect",value:{bool:!1}}),r.isCropToolbar=!0,r.crop(),r.isCropToolbar=!1},o.prototype.updateResize=function(){var e=this.parent;e.prevCropObj=t.extend({},e.cropObj,{},!0);var i={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),e.prevObj=i.currObj,e.currSelectionPoint&&e.prevCropObj.activeObj.shape&&(e.prevObj.activeObj=t.extend({},e.prevCropObj.activeObj,{},!0)),e.prevObj.objColl=t.extend([],e.objColl,[],!0),e.prevObj.pointColl=t.extend([],e.pointColl,[],!0),e.prevObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),e.prevObj.selPointColl=t.extend([],o.selPointColl,[],!0),e.resizeSrc={startX:e.img.srcLeft,startY:e.img.srcTop,width:e.img.srcWidth,height:e.img.srcHeight}},o.prototype.resize=function(e,i,o){var r=this,a=this.parent;a.isResize=!0,t.isNullOrUndefined(a.prevCropObj)&&t.isNullOrUndefined(a.prevObj)&&a.notify("transform",{prop:"updateResize",value:{bool:!1}});var n=a.element.querySelector("#"+a.element.id+"_aspectratio"),s=a.element.querySelector("#"+a.element.id+"_nonaspectratio");t.isNullOrUndefined(n)||t.isNullOrUndefined(s)||(a.notify("toolbar",{prop:"initResizeToolbar"}),t.Browser.isDevice&&a.notify("toolbar",{prop:"init-main-toolbar",value:{isApplyBtn:!1,isDevice:!0,isOkBtn:!0,isResize:!0}}));var l={cancel:!1,previousWidth:Math.ceil(a.img.destWidth),previousHeight:Math.ceil(a.img.destHeight),width:Math.ceil(e),height:i&&0!==i?Math.ceil(i):a.aspectHeight?a.aspectHeight:Math.ceil(a.img.destHeight),isAspectRatio:o||!1};t.isBlazor()?t.isBlazor()&&a.events&&!0===a.events.imageResizing.hasDelegate?a.dotNetRef.invokeMethodAsync("OnImageResizingAsync",l).then(function(e){e.cancel||r.resizeEventHandler(e)}):this.resizeEventHandler(l):(a.trigger("resizing",l),l.cancel||this.resizeEventHandler(l))},o.prototype.resizeEventHandler=function(e){var i,o=this.parent,r=o.element.querySelector("#"+o.element.id+"_resizeHeight"),a=o.element.querySelector(".e-ie-toolbar-e-resize-height-input .e-numerictextbox");e.isAspectRatio?(null!=this.resizedImgAngle&&this.resizedImgAngle===o.transform.degree||(this.resizedImgAngle=o.transform.degree,i=!0),i?(o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:0}}),r?(t.getComponent(r,"numerictextbox").value=Math.floor(o.img.destHeight),r.value=Math.floor(o.img.destHeight).toString()+" px",o.aspectHeight=Math.floor(o.img.destHeight)):a&&(a.value=Math.floor(o.img.destHeight).toString(),o.aspectHeight=Math.floor(o.img.destHeight))):o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:null}})):(null!==this.resizedImgAngle&&this.resizedImgAngle!==o.transform.degree&&(this.resizedImgAngle=o.transform.degree,i=!0),i?(o.notify("transform",{prop:"setPreventDownScale",value:{bool:!0}}),o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}}),o.okBtn(),o.resizeSrc={startX:o.img.srcLeft,startY:o.img.srcTop,width:o.img.srcWidth,height:o.img.srcHeight},t.isBlazor()?o.updateToolbar(o.element,"resize"):(o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("transform",{prop:"setPreventDownScale",value:{bool:!1}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))):o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}})),this.resizedImgAngle=o.transform.degree},o}(),u=function(){function e(e){this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("undo-redo",this.undoRedo,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("undo-redo",this.undoRedo),this.parent.off("destroyed",this.destroy)},e.prototype.initializeUrPvtProp=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},e.prototype.undoRedo=function(e){switch(this.initializeUrPvtProp(),e.prop){case"updateUndoRedoColl":this.updateUrc(e.value.operation,e.value.previousObj,e.value.previousObjColl,e.value.previousPointColl,e.value.previousSelPointColl,e.value.previousCropObj,e.value.previousText,e.value.currentText,e.value.previousFilter,e.value.isCircleCrop);break;case"refreshUrc":this.refreshUrc(e.value.bool);break;case"updateCurrUrc":this.updateCurrUrc(e.value.type);break;case"call-undo":this.callUndo();break;case"call-redo":this.callRedo();break;case"undo":this.undo();break;case"redo":this.redo();break;case"updateUrObj":this.updateUrObj(e.value.objColl);break;case"updateUndoRedo":this.updateUndoRedo();break;case"getAppliedUndoRedoColl":e.value.obj.appliedUndoRedoColl=this.appliedUndoRedoColl;break;case"getUndoRedoStep":e.value.obj.undoRedoStep=this.undoRedoStep;break;case"setUndoRedoStep":this.undoRedoStep=e.value.step;break;case"undoDefault":this.undoDefault(e.value.obj);break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"undo-redo"},e.prototype.reset=function(){this.tempCurrSelPoint=null,this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempActObj=null,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0},e.prototype.refreshUrc=function(e){var i=this.parent;(e=e||!1)?(t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!0}}),this.tempUndoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0),this.tempUndoRedoStep=this.undoRedoStep):t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),this.undoRedoColl=this.undoRedoColl.slice(0,this.undoRedoStep),this.appliedUndoRedoColl=this.appliedUndoRedoColl.slice(0,this.undoRedoStep),i.isUndoRedo=i.currObjType.isUndoAction=!1,t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})},e.prototype.updateCurrUrc=function(e){var i=this.parent;if(!i.isResize){if(t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),"ok"===e){i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!1}});var o=this.tempUndoRedoColl.length>0?t.extend([],this.tempUndoRedoColl,[],!0):t.extend([],this.undoRedoColl,[],!0),r=this.undoRedoColl[this.undoRedoColl.length-1];if(t.isNullOrUndefined(this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1])?this.undoRedoColl[0]&&(r.previousCropObj=o[0].previousCropObj,r.previousObj=o[0].previousObj,r.previousObjColl=o[0].previousObjColl,r.previousPointColl=o[0].previousPointColl,r.previousText=o[0].previousText):"imageHFlip"!==r.operation&&"imageVFlip"!==r.operation&&(r.previousCropObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentCropObj,r.previousObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObj,r.previousObjColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObjColl,r.previousPointColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentPointColl,r.previousText=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentText),r){if("imageHFlip"!==r.operation&&"imageVFlip"!==r.operation){var a=this.getZeroZoomObjPointValue(r.currentObjColl,r.currentPointColl);r.currentObjColl=a.obj,r.currentPointColl=a.point}this.appliedUndoRedoColl.push(r)}this.tempUndoRedoColl=[],this.tempUndoRedoStep=0}else this.tempUndoRedoColl.length>0&&(this.appliedUndoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0);this.appliedUndoRedoColl.length>16&&this.appliedUndoRedoColl.splice(0,1),this.undoRedoColl=[],this.undoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0),"ok"===e&&(this.undoRedoStep=this.undoRedoColl.length,t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})),i.transform.zoomFactor>0&&(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}))}},e.prototype.cancelCropSelection=function(){var e,i=this.parent,o=!1;i.activeObj.shape&&(e=i.activeObj.shape.split("-")),(i.currObjType.isCustomCrop||e&&"crop"===e[0])&&(o=!0),o&&i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),0===this.tempUndoRedoColl.length&&0===this.tempUndoRedoStep||(this.appliedUndoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}))},e.prototype.refreshToolbarActions=function(){var e=this.parent;t.isBlazor()?t.isNullOrUndefined(e.activeObj.shape)&&e.updateToolbar(e.element,"imageLoaded"):e.activeObj.shape?(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},e.prototype.applyCurrentChanges=function(){var e=this.parent;e.currObjType.isFiltered=!1,0===e.transform.zoomFactor&&(e.togglePan=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}})),e.element.querySelector(".e-contextual-toolbar-wrapper")&&!t.isBlazor()&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.togglePen&&(e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default",this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height)),this.appliedUndoRedoColl.length>0&&(this.undoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0))},e.prototype.callUndo=function(){this.applyCurrentChanges(),this.undo()},e.prototype.callRedo=function(){this.applyCurrentChanges(),this.redo()},e.prototype.undo=function(){var e=this.parent;if(this.cancelCropSelection(),!e.disabled&&e.isImageLoaded&&this.undoRedoStep>0){this.refreshToolbarActions(),e.activeObj.activePoint&&0!==e.activeObj.activePoint.width&&(this.tempActObj=e.activeObj),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.undoRedoStep--,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):(e.notify("toolbar",{prop:"enable-disable-btns"}),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),e.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===e.textArea.style.display&&(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}});switch(e.cropObj=t.extend({},i.previousCropObj,{},!0),e.afterCropActions=i.previousObj.afterCropActions,this.lowerContext.filter=i.previousObj.filter,e.canvasFilter=this.lowerContext.filter,i.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":this.shapeTransform(i.previousObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.previousPointColl,i.previousSelPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.previousPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.previousObjColl,i.previousPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(void 0,i.previousObjColl);break;case"text":this.updateText(i.previousObjColl,!0);break;case"frame":e.transform.zoomFactor=e.transform.defaultZoomFactor=i.previousObj.defaultZoom,e.setProperties({zoomSettings:{zoomFactor:i.previousObj.zoomFactor}},!0),e.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.zoomSettings.zoomFactor}}),t.extend(e.frameObj,i.previousObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",i.previousObjColl);break;case"imageVFlip":this.imageFlip("vertical",i.previousObjColl);break;default:this.undoDefault(i),e.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:i.operation,filter:i.filter}})}"crop"===i.operation&&(i.previousObj.currSelectionPoint&&(e.currSelectionPoint=t.extend({},i.previousObj.currSelectionPoint,{},!0),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null)),e.updateCropTransformItems(),e.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),e.isCircleCrop&&(e.isCircleCrop=!1,this.tempCurrSelPoint=t.extend({},e.currSelectionPoint,{},!0),e.currSelectionPoint=null),e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),e.currObjType.isActiveObj=!1),this.undoRedoColl[this.undoRedoStep-1]&&this.undoRedoColl[this.undoRedoStep-1].isCircleCrop&&(e.isCircleCrop=!0,e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),this.endUndoRedo(i.operation,!0)}},e.prototype.redo=function(){var e=this.parent;if(this.cancelCropSelection(),!e.disabled&&e.isImageLoaded&&this.undoRedoStep<this.appliedUndoRedoColl.length){this.refreshToolbarActions(),this.undoRedoStep++,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):e.notify("toolbar",{prop:"enable-disable-btns"}),e.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep-1];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===e.textArea.style.display&&(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}}),e.cropObj=t.extend({},i.currentCropObj,{},!0),e.afterCropActions=i.currentObj.afterCropActions,this.lowerContext.filter=i.currentObj.filter,!t.isBlazor()&&e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.canvasFilter=this.lowerContext.filter;var o=void 0;switch(i.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":this.shapeTransform(i.currentObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.currentPointColl,i.currentSelPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.currentPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.currentObjColl,i.currentPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(o,i.currentObjColl);break;case"text":this.updateText(i.currentObjColl,!1);break;case"frame":t.extend(e.frameObj,i.currentObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",i.currentObjColl);break;case"imageVFlip":this.imageFlip("vertical",i.currentObjColl);break;default:e.objColl=[],e.pointColl=[],e.freehandCounter=0,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),e.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:i.currentObj}}),e.img.destLeft=i.currentObj.destPoints.startX,e.img.destTop=i.currentObj.destPoints.startY,o=t.extend({},e.activeObj,{},!0),e.objColl=t.extend([],i.currentObjColl,[],!0),e.pointColl=t.extend([],i.currentPointColl,[],!0),e.freehandCounter=e.pointColl.length,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],i.currentSelPointColl,[],!0)}}}),this.lowerContext.filter="none",e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=i.currentObj.filter,e.activeObj=o,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height&&e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),e.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:i.operation}})}"crop"===i.operation&&i.isCircleCrop&&(e.isCircleCrop=!0,e.currSelectionPoint=t.extend({},this.tempCurrSelPoint,{},!0),this.tempCurrSelPoint=null),"crop"!==i.operation||i.isCircleCrop||(e.isCircleCrop=!1),"crop"===i.operation&&i.currentObj.currSelectionPoint&&(e.currSelectionPoint=t.extend({},i.currentObj.currSelectionPoint,{},!0)),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),this.endUndoRedo(i.operation,!1)}},e.prototype.imageFlip=function(e,i){var o=this.parent;o.objColl=t.extend([],i,[],!0),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.activeObj.shape&&"image"===o.activeObj.shape?("horizontal"===e?t.isNullOrUndefined(o.activeObj.isHorImageFlip)&&o.activeObj.isVerImageFlip?(o.activeObj.isHorImageFlip=!0,o.activeObj.isVerImageFlip=null,o.horizontalFlip(this.upperContext,!0)):(t.isNullOrUndefined(o.activeObj.isHorImageFlip)||!o.activeObj.isHorImageFlip?o.activeObj.isHorImageFlip=!0:o.activeObj.isHorImageFlip=null,o.horizontalFlip(this.upperContext,!0)):"vertical"===e&&(t.isNullOrUndefined(o.activeObj.isVerImageFlip)&&o.activeObj.isHorImageFlip?(o.activeObj.isVerImageFlip=!0,o.activeObj.isHorImageFlip=null,o.verticalFlip(this.upperContext,!0)):(t.isNullOrUndefined(o.activeObj.isVerImageFlip)||!o.activeObj.isVerImageFlip?o.activeObj.isVerImageFlip=!0:o.activeObj.isVerImageFlip=null,o.verticalFlip(this.upperContext,!0))),o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}})},e.prototype.shapeTransform=function(e){var i=this.parent;i.objColl=t.extend([],e,[],!0),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},e.prototype.updateFreehandDraw=function(e,t){var i=this.parent;i.pointColl=e,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t}}}),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateFreehandDrawCustomized=function(e){var t=this.parent;t.pointColl=e,t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.isUndoRedo=!0,t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateDelete=function(e,t,i){var o=this.parent;"deleteFreehandDrawing"===e?(o.pointColl=i,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):"deleteObj"===e&&(o.objColl=t,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateTextAreaCustomization=function(e,i){var o=this.parent;o.objColl=t.extend([],i,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1});for(var r=0,a=i.length;r<a;r++){if(!this.tempActObj){e=t.extend({},i[i.length-1],{},!0),o.objColl.splice(r,1);break}if(this.tempActObj.currIndex===i[r].currIndex){e=t.extend({},i[r],{},!0),o.objColl.splice(r,1);break}}e&&this.updateTextBox(e),"block"===o.textArea.style.display&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}})},e.prototype.updateText=function(e,i){var o=this.parent;if(this.tempActObj&&(o.activeObj=t.extend({},this.tempActObj,{},!0)),0===e.length&&1===o.objColl.length)this.tempActObj=t.extend({},o.objColl[0],{},!0);else for(var r=0;r<o.objColl.length;r++){if(o.objColl[r]&&t.isNullOrUndefined(e[r])){this.tempActObj=t.extend({},o.objColl[r],{},!0);break}if(e[r].currIndex!==o.objColl[r].currIndex){this.tempActObj=t.extend({},o.objColl[r],{},!0);break}}i&&(o.activeObj=t.extend({},this.tempActObj,{},!0)),o.objColl=t.extend([],e,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},e.prototype.updateTextBox=function(e){var i=this.parent;this.upperContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.textArea.style.display="block",i.textArea.style.fontFamily=e.textSettings.fontFamily,i.textArea.style.fontSize=e.textSettings.fontSize+"px",i.textArea.style.color=e.strokeSettings.strokeColor,i.textArea.style.fontWeight=e.textSettings.bold?"bold":"normal",i.textArea.style.fontStyle=e.textSettings.italic?"italic":"normal",i.textArea.style.border="2px solid "+i.themeColl[i.theme].primaryColor,i.textArea.value=e.keyHistory,i.activeObj=t.extend({},e,{},!0),i.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}}),i.textArea.style.width=i.activeObj.activePoint.width+"px"},e.prototype.undoDefault=function(e){this.lowerContext.filter=e.previousObj.filter;var i=this.parent;i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:e.previousObj}}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.img.destLeft=e.previousObj.destPoints.startX,i.img.destTop=e.previousObj.destPoints.startY;var o=t.extend({},i.activeObj,{},!0);i.objColl=t.extend([],e.previousObjColl,[],!0),i.pointColl=t.extend([],e.previousPointColl,[],!0),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],e.previousSelPointColl,[],!0)}}}),this.lowerContext.filter="none",i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=e.previousObj.filter,i.activeObj=o,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})},e.prototype.endUndoRedo=function(e,i){var o=this.parent;(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&JSON.stringify(o.frameObj)!==JSON.stringify({type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""})&&o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&(i&&"crop"!==e||!i)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.transform.zoomFactor>0&&o.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),o.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!1}}),t.isBlazor()?(t.isNullOrUndefined(o.activeObj.shape)||"crop"!==o.activeObj.shape.split("-")[0])&&(o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"enableDisableToolbarBtn")):(o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!0,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"enable-disable-btns"})),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"),t.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns"}),0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),o.currObjType.isCustomCrop=!1},e.prototype.updateUrc=function(e,i,o,r,a,n,s,l,p,h){var c=this.parent;if(!c.isResize){var d={isInitialLoaded:!1};if(c.currObjType.isUndoAction&&this.refreshUrc(!0),c.notify("draw",{prop:"isInitialLoaded",onPropertyChange:!1,value:{object:d}}),!d.isInitialLoaded&&c.allowUndoRedo){var v={currObj:{}};c.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj;u.objColl=t.extend([],c.objColl,[],!0),u.pointColl=t.extend([],c.pointColl,[],!0),u.afterCropActions=t.extend([],c.afterCropActions,[],!0);var g={selPointColl:null};c.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:g}}),u.selPointColl=t.extend([],g.selPointColl,[],!0),"crop"===e?u.currSelectionPoint=t.extend({},c.currSelectionPoint,{},!0):"frame"===e&&(i.destPoints={startX:c.frameDestPoints.destLeft,startY:c.frameDestPoints.destTop,width:c.frameDestPoints.destWidth,height:c.frameDestPoints.destHeight},u.destPoints={startX:c.frameDestPoints.destLeft,startY:c.frameDestPoints.destTop,width:c.frameDestPoints.destWidth,height:c.frameDestPoints.destHeight}),this.undoRedoColl.push({operation:e,previousObj:i,currentObj:u,previousObjColl:o,currentObjColl:u.objColl,previousPointColl:r,currentPointColl:u.pointColl,previousSelPointColl:a,currentSelPointColl:u.selPointColl,previousCropObj:n,currentCropObj:t.extend({},c.cropObj,{},!0),previousText:s,currentText:l,filter:p,isCircleCrop:h}),t.isBlazor()?"pen-toolbar"!==c.currentToolbar&&c.updateToolbar(c.element,"enableDisableToolbarBtn"):c.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1})}}},e.prototype.updateUrObj=function(e){var i=this.parent;if(i.allowUndoRedo){i.currObjType.isUndoAction&&this.refreshUrc(!0),i.objColl.push(i.activeObj);var o=t.extend({},i.cropObj,{},!0),r={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],i.objColl,[],!0),a.pointColl=t.extend([],i.pointColl,[],!0),a.afterCropActions=t.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.undoRedoColl.push({operation:"shapeTransform",previousObj:a,currentObj:a,previousObjColl:e,currentObjColl:a.objColl,previousPointColl:a.pointColl,currentPointColl:a.pointColl,previousSelPointColl:a.selPointColl,currentSelPointColl:a.selPointColl,previousCropObj:o,currentCropObj:o}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}})}},e.prototype.updateUndoRedo=function(){var e=this.parent,i=t.extend({},e.cropObj,{},!0),o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=t.extend([],e.objColl,[],!0),r.pointColl=t.extend([],e.pointColl,[],!0),r.afterCropActions=t.extend([],e.afterCropActions,[],!0);var a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=t.extend([],a.selPointColl,[],!0),e.objColl.push(e.activeObj),this.updateUrc("shapeTransform",r,r.objColl,r.pointColl,r.selPointColl,i),e.objColl.pop(),e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))},e.prototype.getZeroZoomObjPointValue=function(e,i){var o=this.parent,r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],o.objColl,[],!0),a.pointColl=t.extend([],o.pointColl,[],!0),a.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0);var s={cropDimension:null};o.notify("transform",{prop:"getCropDimension",onPropertyChange:!1,value:{obj:s}});var l=t.extend([],o.objColl,[],!0),p=t.extend([],o.pointColl,[],!0),h={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:h}});var c=t.extend({},h.arrowDimension,{},!0);if(o.transform.zoomFactor>0&&(e.length>0||i.length>0)){o.objColl=e,o.pointColl=i;var d=o.isUndoRedo;if(0!==o.transform.zoomFactor){o.isUndoRedo=o.isCropTab=!0,o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var v=t.extend({},o.zoomSettings,null,!0);o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null,isResize:null}}):o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(o.transform.zoomFactor),zoomPoint:null,isResize:null}}),o.zoomSettings=v,o.isCropTab=!1,o.isUndoRedo=d,l=t.extend([],o.objColl,[],!0),p=t.extend([],o.pointColl,[],!0),o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:s.cropDimension.width,height:s.cropDimension.height}});var u={width:s.cropDimension.width,height:s.cropDimension.height};u.width+=u.width*a.defaultZoom,u.height+=u.height*a.defaultZoom,o.notify("draw",{prop:"setZoomCropWidth",value:{width:u.width,height:u.height}}),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a}}),o.img.destLeft=a.destPoints.startX,o.img.destTop=a.destPoints.startY,o.panPoint.totalPannedPoint=a.totalPannedPoint,o.panPoint.totalPannedClientPoint=a.totalPannedClientPoint,o.panPoint.totalPannedInternalPoint=a.totalPannedInternalPoint,o.objColl=t.extend([],a.objColl,[],!0),o.pointColl=t.extend([],a.pointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("draw",{prop:"setArrowDimension",onPropertyChange:!1,value:{arrowDimension:c}}),o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],a.selPointColl,[],!0)}}}),this.lowerContext.filter="none",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),o.notify("freehand-draw",{prop:"updateFHDCurPts",onPropertyChange:!1}),this.lowerContext.filter=a.filter,0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(o.isCircleCrop||o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}}return{obj:l,point:p}},e}(),g=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),b=function(e,t,i,o){var r,a=arguments.length,n=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(a<3?r(n):a>3?r(t,i,n):r(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n},f=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(null)],i.prototype,"brightness",void 0),b([t.Property(null)],i.prototype,"contrast",void 0),b([t.Property(null)],i.prototype,"hue",void 0),b([t.Property(null)],i.prototype,"saturation",void 0),b([t.Property(null)],i.prototype,"exposure",void 0),b([t.Property(null)],i.prototype,"opacity",void 0),b([t.Property(null)],i.prototype,"blur",void 0),i}(t.ChildProperty),m=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(null)],i.prototype,"zoomTrigger",void 0),b([t.Property(1)],i.prototype,"minZoomFactor",void 0),b([t.Property(10)],i.prototype,"maxZoomFactor",void 0),b([t.Property(1)],i.prototype,"zoomFactor",void 0),b([t.Property(null)],i.prototype,"zoomPoint",void 0),i}(t.ChildProperty),C=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(!0)],i.prototype,"showCircle",void 0),b([t.Property(null)],i.prototype,"strokeColor",void 0),b([t.Property(null)],i.prototype,"fillColor",void 0),i}(t.ChildProperty),y=function(r){function a(e,i){var o=r.call(this,e)||this;return o.isImageLoaded=!1,o.activeObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[],rotatedAngle:0},o.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},o.objColl=[],o.pointColl={},o.freehandCounter=0,o.points=[],o.togglePen=!1,o.togglePan=!1,o.img={destLeft:0,destTop:0,destWidth:0,destHeight:0,srcLeft:0,srcTop:0,srcWidth:0,srcHeight:0},o.rotateFlipColl=[],o.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,zoomFactor:0,previousZoomValue:0,aspectWidth:null,aspectHeight:null,frame:"none"},o.afterCropActions=[],o.transform={degree:0,currFlipState:"",zoomFactor:0,cropZoomFactor:null,defaultZoomFactor:0},o.panPoint={currentPannedPoint:{x:0,y:0},totalPannedPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0}},o.isUndoRedo=!1,o.isCropTab=!1,o.isCircleCrop=!1,o.fontSizeColl=[],o.initialAdjustmentValue="",o.currentFilter="",o.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.toolbarHeight=0,o.isPublicMethod=!1,o.isCropToolbar=!1,o.cursor="default",o.resizeSrc={startX:o.img.srcLeft,startY:o.img.srcTop,width:o.img.srcWidth,height:o.img.srcHeight},o.isResize=!1,o.isAspectRatio=!1,o.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},o.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},o.allowDownScale=!0,o.gradientColor="",o.size=20,o.inset=0,o.offset=0,o.borderRadius=0,o.lineCount=0,t.isBlazor()?(new n(o),new s(o),new p(o),new h(o),new c(o),new d(o),new v(o),new u(o),new l(o)):(y.Inject(n,s,c,v,l,j),y.Inject(u),y.Inject(p),y.Inject(d),y.Inject(h),i&&o.appendTo(i)),o}g(a,r),y=a,a.prototype.requiredModules=function(){var e=[];return e.push({member:"crop",args:[this]}),e.push({member:"draw",args:[this]}),e.push({member:"selection",args:[this]}),e.push({member:"transform",args:[this]}),e.push({member:"export",args:[this]}),e.push({member:"toolbar-module",args:[this]}),e.push({member:"undo-redo",args:[this]}),e.push({member:"filter",args:[this]}),e.push({member:"shape",args:[this]}),e.push({member:"freehand-draw",args:[this]}),e},a.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-image-editor"),t.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},a.prototype.render=function(){this.initialize()},a.prototype.getModuleName=function(){return"image-editor"},a.prototype.getPersistData=function(){return this.addOnPersist([])},a.prototype.onPropertyChanged=function(i,o){for(var r,a=0,n=Object.keys(i);a<n.length;a++){switch(n[a]){case"cssClass":o.cssClass&&t.removeClass([this.element],o.cssClass.replace(/\s+/g," ").trim().split(" ")),i.cssClass&&t.addClass([this.element],i.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"disabled":i.disabled?(this.element.classList.add("e-disabled"),this.unwireEvent()):(this.element.classList.remove("e-disabled"),this.wireEvent());break;case"height":this.element.style.height=i.height,this.update();break;case"width":this.element.style.width=i.width,this.update();break;case"theme":i.theme&&(this.theme&&""!==this.theme?this.theme=this.toPascalCase(this.theme):this.theme="Bootstrap5",this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.fillStyle=this.themeColl[this.theme].secondaryColor,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"finetuneSettings":i.finetuneSettings&&(this.finetuneSettings=i.finetuneSettings,this.notify("filter",{prop:"update-finetunes"}));break;case"locale":i.locale&&(this.notify("toolbar",{prop:"setLocale",onPropertyChange:!1,value:{locale:i.locale}}),t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"allowUndoRedo":i.allowUndoRedo?this.allowUndoRedo=!0:this.allowUndoRedo=!1,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"showQuickAccessToolbar":i.showQuickAccessToolbar?(this.showQuickAccessToolbar=!0,t.isBlazor()||this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),r={freehandSelectedIndex:null},this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:r}}),this.activeObj.shape?t.isBlazor()?this.updateToolbar(this.element,"quickAccessToolbar",this.activeObj.shape):this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}):r.freehandSelectedIndex&&(t.isBlazor()?this.updateToolbar(this.element,"quickAccessToolbar","pen"):this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}))):(this.showQuickAccessToolbar=!1,t.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));break;case"zoomSettings":i.zoomSettings&&(this.zoomSettings.zoomTrigger=i.zoomSettings.zoomTrigger),t.isNullOrUndefined(this.zoomSettings.zoomTrigger)?(this.zoomSettings.zoomTrigger=e.ZoomTrigger.MouseWheel|e.ZoomTrigger.Pinch|e.ZoomTrigger.Toolbar|e.ZoomTrigger.Commands,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):(i.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar&&(t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"selectionSettings":i.selectionSettings&&(this.selectionSettings=i.selectionSettings,this.activeObj.shape&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})));break;case"toolbar":i.toolbar&&(this.toolbar=i.toolbar,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"toolbarTemplate":i.toolbarTemplate&&(t.isBlazor()||(this.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()));break;case"quickAccessToolbarTemplate":i.quickAccessToolbarTemplate&&(t.isBlazor()||(this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.quickAccessToolbarTemplateFn()))}}},a.prototype.destroy=function(){var e=[];this.element.removeAttribute("tabindex"),this.cssClass&&(e=e.concat(this.cssClass.replace(/\s+/g," ").trim().split(" "))),t.removeClass([this.element],e),this.element.getAttribute("class")||this.element.removeAttribute("class"),t.isBlazor()?this.element.classList.remove("e-image-editor"):(this.notify("toolbar",{prop:"destroySubComponents",onPropertyChange:!1}),this.notify("destroyed",null),r.prototype.destroy.call(this)),this.unwireEvent(),this.element.innerHTML=""},a.prototype.initialize=function(){if(this.toolbarTemplate?(this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()):(this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1})),this.createCanvas(),this.element.offsetWidth>359&&this.element.querySelector(".e-ie-min-drop-content")&&this.element.querySelector(".e-ie-drop-content")&&(this.element.querySelector(".e-ie-min-drop-content").style.display="none",this.element.querySelector(".e-ie-drop-content").style.display="block"),this.createDropUploader(),this.showQuickAccessToolbar){document.querySelector("#"+this.element.id+"_canvasWrapper").appendChild(this.createElement("div",{id:this.element.id+"_quickAccessToolbarArea",className:"e-quick-access-toolbar-area"}));var e=document.getElementById(this.element.id+"_quickAccessToolbarArea");e.style.position="absolute",e.style.display="none",this.activeObj&&(e.style.left=this.activeObj.activePoint.startX+"px",e.style.top=this.activeObj.activePoint.startY+"px"),e.style.width="100%"}this.quickAccessToolbarTemplate?this.quickAccessToolbarTemplateFn():this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.wireEvent(),this.lowerContext=this.lowerCanvas.getContext("2d"),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.lowerContext.filter,this.notify("toolbar",{prop:"setInitialAdjustmentValue",onPropertyChange:!1,value:{value:this.lowerContext.filter}}),this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},a.prototype.createDropUploader=function(){var e=this;new o.Uploader({dropArea:document.getElementsByClassName("e-canvas-wrapper")[0],allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1,selected:function(t){if("change"===t.event.type||"drop"===t.event.type){var i=t.filesData[0].type,o="unsupported";"change"!==t.event.type&&("drop"!==t.event.type||1!==t.event.dataTransfer.files.length)||"png"!==i&&"jpg"!==i&&"jpeg"!==i&&"svg"!==i?("drop"===t.event.type&&t.event.dataTransfer.files.length>1&&(o="multi-select-image"),e.showDialogPopup(o)):e.notify("draw",{prop:"fileSelect",value:{inputElement:e.element.querySelector("#"+e.element.id+"_dropfileUpload"),args:t}})}}}).appendTo("#"+this.element.id+"_dropfileUpload")},a.prototype.dlgCloseBtnClick=function(){t.getComponent(document.getElementById(this.element.id+"_dialog"),"dialog").destroy()},a.prototype.showDialogPopup=function(e){var t="";this.element.querySelector("#"+this.element.id+"_dialog").style.display="block";var o,r={key:"OK"};if(this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),"multi-select-image"===e){o={key:"ImageErrorDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var a={key:"ImageErrorDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}}),t="<span>"+a.value+"</span>"}else{o={key:"AlertDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});a={key:"AlertDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}}),t="<span>"+a.value+" "+n.value+"<b> JPG, PNG, and SVG</b></span>"}new i.Dialog({header:o.value,closeOnEscape:!0,content:t,target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:r.value,iconCss:"e-icons e-close"}}]}).appendTo("#"+this.element.id+"_dialog")},a.prototype.wireEvent=function(){t.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),t.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),t.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),t.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),t.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),t.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),t.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),t.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),t.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),t.EventHandler.add(document,"mouseup",this.canvasMouseUpHandler,this),t.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),t.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),t.EventHandler.add(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),t.EventHandler.add(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),t.Browser.isIos||"safari"===t.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"wireEvent",onPropertyChange:!1})},a.prototype.unwireEvent=function(){t.EventHandler.remove(document,"keydown",this.keyDownEventHandler),t.EventHandler.remove(document,"keypress",this.keyUpEventHandler),t.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),t.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),t.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),t.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),t.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),t.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),t.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),t.EventHandler.remove(document,"mouseup",this.canvasMouseUpHandler),t.EventHandler.remove(this.upperCanvas,"touchstart",this.touchStartHandler),t.EventHandler.remove(this.lowerCanvas,"touchstart",this.touchStartHandler),t.EventHandler.remove(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll),t.EventHandler.remove(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll),window.removeEventListener("resize",this.windowResizeHandler.bind(this)),t.Browser.isIos||"safari"===t.Browser.info.name||screen.orientation.removeEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"unWireEvent",onPropertyChange:!1}),this.notify("selection",{prop:"unWireEvent",onPropertyChange:!1})},a.prototype.createCanvas=function(){var e=this;this.element.style.boxSizing="border-box";var t={toolbarHeight:0};this.notify("toolbar",{prop:"getToolbarHeight",value:{obj:t}});var i=t.toolbarHeight;this.element.style.width=this.width,this.element.style.height=this.height;var o=this.element.appendChild(this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper",attrs:{style:"height:"+(this.element.offsetHeight-i-2)+"px; width:"+(this.element.offsetWidth-2)+"px; position: relative; overflow: hidden; margin: 0 auto;"}})),r={key:"DragText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}});var a={key:"DropText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"BrowseText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}});var s={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:s}});var l=this.createElement("div",{id:this.element.id+"_dropArea",className:"e-ie-drop-area",attrs:{style:"position: relative;"}}),p=this.createElement("span",{className:"e-ie-drop-icon e-icons e-image",attrs:{style:"position: absolute;"}}),h=this.createElement("span",{className:"e-ie-drop-content",attrs:{style:"position: absolute; display: none;"}});h.textContent=r.value+" ";var c=this.createElement("span",{className:"e-ie-min-drop-content",attrs:{style:"position: absolute;"}});c.textContent=a.value+" ";var d=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});d.textContent=n.value;var v=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});v.textContent=n.value,h.appendChild(d),c.appendChild(v),d.href="",v.href="";var u=this.createElement("span",{className:"e-ie-drop-info",attrs:{position:"absolute"}});u.textContent=s.value+" SVG, PNG, and JPG";var g=l.appendChild(this.createElement("input",{id:this.element.id+"_dropfileUpload",className:"e-fileUpload e-image-upload"}));g.setAttribute("type","file"),g.setAttribute("accept","image/*"),l.appendChild(p),l.appendChild(h),l.appendChild(c),l.appendChild(u),o.appendChild(l),this.lowerCanvas=o.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.upperCanvas=o.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.baseImgCanvas=this.createElement("canvas",{id:this.element.id+"_baseImgCanvas",attrs:{name:"canvasImage"}}),this.textArea=o.appendChild(this.createElement("textarea",{id:this.element.id+"_textArea",className:"e-textarea",attrs:{name:"textArea"}}));this.element.appendChild(this.createElement("div",{id:this.element.id+"_dialog",className:"e-dialog"})).style.display="none";var b=this.element.appendChild(this.createElement("input",{id:this.element.id+"_fileUpload",className:"e-fileUpload"}));b.setAttribute("type","file"),b.setAttribute("accept","image/*"),b.style.display="none",this.textArea.setAttribute("spellcheck","false"),this.textArea.style.lineHeight="normal",this.lowerCanvas.style.width=this.upperCanvas.style.width=this.inMemoryCanvas.style.width="100%",this.lowerCanvas.style.height=this.upperCanvas.style.height=this.inMemoryCanvas.style.height="100%",this.upperCanvas.style.position=this.lowerCanvas.style.position=this.textArea.style.position="absolute",this.textArea.style.backgroundColor="transparent",this.textArea.style.display="none",this.textArea.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=this.cursor="default",this.upperCanvas.style.display="block",this.upperContext=this.upperCanvas.getContext("2d"),document.getElementById(this.element.id+"_dropBrowse").onclick=function(){return e.element.querySelector("#"+e.element.id+"_dropfileUpload").click(),!1}},a.prototype.touchStartHandler=function(e){this.notify("selection",{prop:"touchStartHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseDownEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseDownEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseMoveEventHandler=function(e){this.notify("selection",{prop:"mouseMoveEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseUpEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseUpEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.keyDownEventHandler=function(e){this.notify("selection",{prop:"keyDownEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.keyUpEventHandler=function(e){"block"===this.textArea.style.display&&e.target.id===this.element.id+"_textArea"&&this.notify("selection",{prop:"textKeyDown",value:{e:e}})},a.prototype.canvasMouseDownHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseDownHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.canvasMouseMoveHandler=function(e){this.notify("selection",{prop:"canvasMouseMoveHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.canvasMouseUpHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseUpHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.handleScroll=function(e){this.notify("selection",{prop:"handleScroll",onPropertyChange:!1,value:{e:e}})},a.prototype.adjustToScreen=function(){this.update()},a.prototype.screenOrientation=function(){t.Browser.isDevice&&setTimeout(this.adjustToScreen.bind(this),100)},a.prototype.windowResizeHandler=function(){!t.Browser.isDevice&&this.element.classList.contains("e-image-editor")&&this.adjustToScreen()},a.prototype.notifyResetForAllModules=function(){for(var e=this.requiredModules(),t=0;t<e.length;t++)this.notify(e[t].member,{prop:"reset",onPropertyChange:!1})},a.prototype.allowShape=function(e,t){this.isPublicMethod=!0;var i={inRange:!1};return this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e,y:t,obj:i}}),i.inRange},a.prototype.clearSelection=function(){this.notify("selection",{prop:"clearSelection",onPropertyChange:!1})},a.prototype.crop=function(){var e={isCrop:!1};return this.notify("crop",{prop:"crop",onPropertyChange:!1,value:{obj:e}}),e.isCrop},a.prototype.flip=function(e){this.notify("transform",{prop:"flip",value:{direction:e}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},a.prototype.getImageData=function(){var e={canvas:null};return this.notify("export",{prop:"exportToCanvas",value:{object:e}}),e.canvas.getContext("2d").getImageData(0,0,e.canvas.width,e.canvas.height)},a.prototype.open=function(e){document.getElementById(this.element.id+"_dropArea").style.display="none",this.notify("draw",{prop:"open",value:{data:e}})},a.prototype.reset=function(){var e={isErrorImage:!1};if(this.notify("draw",{prop:"getErrorImage",value:{obj:e}}),!this.disabled&&!e.isErrorImage){this.clearContext(this.inMemoryContext),this.clearContext(this.lowerContext),this.clearContext(this.upperContext),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),t.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&(t.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})));var i=this.isImageLoaded;this.currObjType.isUndoAction=this.isUndoRedo=this.togglePan=this.togglePen=this.isImageLoaded=!1,this.isCircleCrop=this.isCropTab=!1,this.objColl=[],this.transform.degree=0,this.upperCanvas.style.display="block",this.transform.currFlipState="",this.allowDownScale=!0,this.upperCanvas.style.cursor=this.cursor=this.lowerCanvas.style.cursor="default",this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.frameDestPoints=null,this.textArea.value=this.textArea.textContent="",this.textArea.style.display="none",this.lowerContext.filter=this.canvasFilter=this.getDefaultFilter(),this.img.destLeft=this.img.destTop=this.img.srcLeft=this.img.srcTop=0,this.img.destWidth=this.img.destHeight=this.img.srcWidth=this.img.srcHeight=null,this.currSelectionPoint=null,this.panPoint.currentPannedPoint={x:0,y:0},this.rotateFlipColl=[],this.points=[],this.pointColl={},this.freehandCounter=0,this.notify("draw",{prop:"resetPanPoints"}),this.lowerCanvas.style.left=this.upperCanvas.style.left="",this.fontSizeColl=[],this.lowerCanvas.style.top=this.upperCanvas.style.top="",this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth="",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight="",this.transform.defaultZoomFactor=this.transform.zoomFactor=0,this.transform.cropZoomFactor=null,this.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},this.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},this.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},this.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,aspectWidth:null,aspectHeight:null},this.afterCropActions=[],this.currentFilter="",this.tempFrameZoomLevel=null;var o={initialZoomValue:!1};this.notify("draw",{prop:"getInitialZoomValue",onPropertyChange:!1,value:{obj:o}}),o.initialZoomValue&&this.setProperties({zoomSettings:{zoomFactor:o.initialZoomValue}},!0),document.getElementById(this.element.id+"_quickAccessToolbarArea")&&(document.getElementById(this.element.id+"_quickAccessToolbarArea").style.display="none"),this.notifyResetForAllModules(),this.notify("filter",{prop:"update-finetunes"}),this.isImageLoaded=!1,this.notify("draw",{prop:"update-canvas",onPropertyChange:!1}),this.isImageLoaded=i,t.isBlazor()||(this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),this.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),this.notify("toolbar",{prop:"enable-disable-btns"}))}},a.prototype.rotate=function(e){var t={isRotate:!1};return this.notify("transform",{prop:"rotate",value:{degree:e,obj:t}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),t.isRotate},a.prototype.export=function(e,t){this.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e,fileName:t}})},a.prototype.select=function(e,t,i,o,r){this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:i,width:o,height:r}}),this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:i,width:o,height:r}})},a.prototype.freeHandDraw=function(e){this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:e}})},a.prototype.freehandDraw=function(e){!this.disabled&&this.isImageLoaded&&this.freeHandDraw(e)},a.prototype.pan=function(e){this.notify("transform",{prop:"pan",onPropertyChange:!1,value:{value:e}})},a.prototype.zoom=function(e,t){this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:e,zoomPoint:t}})},a.prototype.drawEllipse=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawEllipse",onPropertyChange:!1,value:{x:e,y:i,radiusX:o,radiusY:r,strokeWidth:a,strokeColor:n,fillColor:s,degree:l}})),p},a.prototype.drawLine=function(e,i,o,r,a,n){var s=!1,l=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(l||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(s=!0,this.notify("shape",{prop:"drawLine",onPropertyChange:!1,value:{startX:e,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n}})),s},a.prototype.drawArrow=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawArrow",onPropertyChange:!1,value:{startX:e,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n,arrowStart:s,arrowEnd:l}})),p},a.prototype.drawPath=function(e,i,o){this.isPublicMethod=!0;var r={inRange:!1},a=!1;if(e&&e.length>0)for(var n=0;n<e.length&&!r.inRange;n++)this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e[n].x,y:e[n].y,obj:r}});return!this.disabled&&this.isImageLoaded&&(r.inRange||t.isNullOrUndefined(e))&&(a=!0,this.notify("shape",{prop:"drawPath",onPropertyChange:!1,value:{pointColl:e,strokeWidth:i,strokeColor:o}})),a},a.prototype.drawRectangle=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawRectangle",onPropertyChange:!1,value:{x:e,y:i,width:o,height:r,strokeWidth:a,strokeColor:n,fillColor:s,degree:l}})),p},a.prototype.drawText=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawText",onPropertyChange:!1,value:{x:e,y:i,text:o,fontFamily:r,fontSize:a,bold:n,italic:s,color:l}})),p},a.prototype.drawImage=function(e,i,o,r,a,n,s){var l=!1,p=this.allowShape(i,o);if(!this.disabled&&this.isImageLoaded&&(p||t.isNullOrUndefined(i)&&t.isNullOrUndefined(o))){var h=this.objColl.length;this.notify("shape",{prop:"drawImage",onPropertyChange:!1,value:{x:i,y:o,width:r,height:a,src:e,degree:s,isAspectRatio:n}}),this.objColl.length>h&&(l=!0)}return l},a.prototype.selectShape=function(e){var t={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e,obj:t}}),t.isSelected},a.prototype.deleteShape=function(e){this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:e}})},a.prototype.getShapeSetting=function(e){var t={};return this.notify("shape",{prop:"getShapeSetting",onPropertyChange:!1,value:{id:e,obj:t}}),t},a.prototype.getShapeSettings=function(){var e={shapeDetailsColl:[]};return this.notify("shape",{prop:"getShapeSettings",onPropertyChange:!1,value:{obj:e}}),e.shapeDetailsColl},a.prototype.update=function(){this.notify("transform",{prop:"update"})},a.prototype.finetuneImage=function(e,t){!this.disabled&&this.isImageLoaded&&this.notify("filter",{prop:"finetuneImage",value:{value:t,option:e}})},a.prototype.applyImageFilter=function(e){!this.disabled&&this.isImageLoaded&&(this.notify("filter",{prop:"applyImageFilter",value:{option:e.toString()}}),this.canvasFilter=this.lowerContext.filter,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},a.prototype.undo=function(){this.notify("undo-redo",{prop:"undo",onPropertyChange:!1})},a.prototype.redo=function(){this.notify("undo-redo",{prop:"redo",onPropertyChange:!1})},a.prototype.getImageDimension=function(){return{x:this.img.destLeft,y:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight}},a.prototype.resize=function(e,i,o){var r=!1;if(e.toString().length<=4&&i.toString().length<=4){var a=this.img.destLeft,n=this.img.destTop,s=this.img.destWidth,l=this.img.destHeight;if(t.isBlazor())this.updateToolbar(this.element,"resize");else{o?(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}})):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}});var p=this.element.querySelector("#"+this.element.id+"_resizeWidth"),h=this.element.querySelector("#"+this.element.id+"_resizeHeight");p&&h&&(t.getComponent(p,"numerictextbox").value=Math.floor(e),p.value=Math.floor(e).toString()+" px",t.getComponent(h,"numerictextbox").value=Math.floor(i),h.value=Math.floor(i).toString()+" px")}this.notify("transform",{prop:"resize",value:{width:e,height:i,isAspectRatio:o}}),a!==this.img.destLeft||n!==this.img.destTop||s!==this.img.destWidth||l!==this.img.destHeight?(r=!0,this.okBtn()):this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})}return r},a.prototype.drawFrame=function(i,o,r,a,n,s,l,p,h){var c=!1,d={frameChangeEventArgs:null};o=o||"#fff",r=r||"",a=a||20,n=n||0,s=s||0,l=l||0,p=p||e.FrameLineStyle.Solid,h=h||0;var v={type:this.toPascalCase(this.frameObj.type),color:this.frameObj.color,gradientColor:this.frameObj.gradientColor,size:this.frameObj.size,inset:this.frameObj.inset,offset:this.frameObj.offset,borderRadius:this.frameObj.radius,frameLineStyle:this.toPascalCase(this.frameObj.border),lineCount:this.frameObj.amount};return t.extend(this.tempFrameObj,this.frameObj),this.tempFrameZoomLevel=this.transform.zoomFactor,this.frameDestPoints=t.extend({},this.img,{},!0),t.isBlazor()?this.performFrameClick():this.notify("toolbar",{prop:"frameToolbarClick"}),this.frameObj.type=i.toLowerCase(),this.frameObj.color=o,this.frameObj.gradientColor=r,this.frameObj.size=a,this.frameObj.inset=n,this.frameObj.offset=s,this.frameObj.radius=l,this.frameObj.border=p.toLowerCase(),this.frameObj.amount=h,this.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:v,obj:d}}),d.frameChangeEventArgs&&!d.frameChangeEventArgs.cancel?(this.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)?(c=!0,this.okBtn()):this.tempFrameZoomLevel=null):(this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),t.extend(this.frameObj,this.tempFrameObj),this.tempFrameZoomLevel=null),c},a.prototype.toolbarTemplateFn=function(){var e,t=this.element.id+"_toolbar",i=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var o=this.toolbarFn({type:"toolbar"},this,"Template",t);e=3===o[0].nodeType?o[1]:o[0]}else e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];i.appendChild(e),this.toolbarHeight=i.clientHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.renderReactTemplates()}},a.prototype.quickAccessToolbarTemplateFn=function(){var e,t=this.element.id+"_quickAccessToolbar",i=this.element.querySelector("#"+this.element.id+"_quickAccessToolbarArea");if(this.quickAccessToolbarTemplate){if(this.qatFn=this.templateParser(this.quickAccessToolbarTemplate),this.isReact)e=this.qatFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var o=this.qatFn({type:"toolbar"},this,"Template",t);e=3===o[0].nodeType?o[1]:o[0]}else e=this.qatFn({type:"toolbar"},this,"Template",t)[0];i.appendChild(e),this.renderReactTemplates()}},a.prototype.templateParser=function(e){if(e)try{return"function"!=typeof e&&document.querySelectorAll(e).length?t.compile(document.querySelector(e).innerHTML.trim()):t.compile(e)}catch(i){return t.compile(e)}},a.prototype.getTextFromId=function(e){return{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+e]},a.prototype.getFinetuneOption=function(t){return{brightness:e.ImageFinetuneOption.Brightness,contrast:e.ImageFinetuneOption.Contrast,hue:e.ImageFinetuneOption.Hue,saturation:e.ImageFinetuneOption.Saturation,opacity:e.ImageFinetuneOption.Opacity,blur:e.ImageFinetuneOption.Blur,exposure:e.ImageFinetuneOption.Exposure}[""+t]},a.prototype.setPenStroke=function(e){this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:parseInt(e,10)}})},a.prototype.updateFreehandDrawColorChange=function(){var e={tempFreeHandDrawEditingStyles:null};this.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:e}}),this.notify("freehand-draw",{prop:"color-change",value:{color:e.tempFreeHandDrawEditingStyles.strokeColor}})},a.prototype.updateImageTransformColl=function(e){var i;"rotateleft"===e?i=-90:"rotateright"===e?i=90:"horizontalflip"===e?i="horizontal":"verticalflip"===e&&(i="vertical");for(var o=0;o<this.objColl.length;o++)if("image"===this.objColl[o].shape){t.isNullOrUndefined(this.objColl[o].rotateFlipColl)&&(this.objColl[o].rotateFlipColl=[]),this.objColl[o].rotateFlipColl.push(i);var r={collection:this.objColl[o].rotateFlipColl};this.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:this.objColl[o].rotateFlipColl,isRotateFlipCollection:!1,obj:r}}),this.objColl[o].rotateFlipColl=r.collection}},a.prototype.setInitialZoomState=function(){this.objColl.push(this.activeObj),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var e=this.isUndoRedo;this.isCropTab=!1,this.isUndoRedo=!0,this.transform.cropZoomFactor&&this.transform.cropZoomFactor>0?this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.cropZoomFactor,zoomPoint:null,isResize:null}}):this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(this.transform.cropZoomFactor),zoomPoint:null,isResize:null}}),this.isUndoRedo=e,this.panPoint.totalPannedPoint={x:0,y:0},this.transform.cropZoomFactor=0,this.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.activeObj=t.extend({},this.objColl[this.objColl.length-1],{},!0),this.objColl.pop(),this.isCropTab=!0,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})},a.prototype.updateCropTransformItems=function(){this.prevCurrSelectionPoint=t.extend({},this.currSelectionPoint,{},!0);var e={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:e}});var i=e.currObj;i.objColl=t.extend([],this.objColl,[],!0),i.pointColl=t.extend([],this.pointColl,[],!0),i.afterCropActions=t.extend([],this.afterCropActions,[],!0);var o={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),i.selPointColl=t.extend([],o.selPointColl,[],!0),this.cancelCropSelection={operation:"cropTransform",previousObj:i,currentObj:i,previousObjColl:i.objColl,currentObjColl:i.objColl,previousPointColl:i.pointColl,currentPointColl:i.pointColl,previousSelPointColl:i.selPointColl,currentSelPointColl:i.selPointColl,previousCropObj:t.extend({},this.cropObj,{},!0),currentCropObj:t.extend({},this.cropObj,{},!0),previousText:null,currentText:null,filter:null,isCircleCrop:this.isCircleCrop}},a.prototype.toPascalCase=function(e,i){var o=[];t.isNullOrUndefined(e)||(o=e.toLowerCase().split("-"));for(var r=0;r<o.length;r++)o[r]=o[r].charAt(0).toUpperCase()+o[r].slice(1);return i&&(i.maxText=o.join("")),o.join("")},a.prototype.getFontSizes=function(){var e=[];this.fontSizeColl=[];var t;t=0===this.transform.degree||this.transform.degree%180==0?this.img.destWidth/25:this.img.destHeight/25;for(var i=1;i<=10;i++)this.fontSizeColl.push({text:(i*Math.round(t/2)).toString()}),e.push({text:i.toString()});return e},a.prototype.okBtn=function(i){this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-frame-wrapper");var o,r=!1,a=this.element.querySelector("#"+this.element.id+"_aspectratio"),n=this.element.querySelector("#"+this.element.id+"_nonaspectratio"),s=this.element.querySelector(".e-ie-toolbar-aspect-ratio-btn"),l=this.element.querySelector(".e-ie-toolbar-nonaspect-ratio-btn");if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),void 0===o&&this.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.allowDownScale=!0,(this.activeObj.shape&&"image"!==this.activeObj.shape||this.togglePen)&&!r){var p={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:p}});var h=p.shapeSettingsObj;this.togglePen&&(h.type=e.ShapeType.FreehandDraw);var c={action:"apply",previousShapeSettings:t.extend({},h,{},!0),currentShapeSettings:t.extend({},h,{},!0)};this.triggerShapeChanged(c)}if(a||n||t.isBlazor()&&"resize-toolbar"===this.currentToolbar){var d={width:null,height:null};this.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:d}});var v={x:d.width,y:d.height},u={prevCropObj:this.prevCropObj},g={prevObj:this.prevObj};v&&v.x&&v.y&&u.prevCropObj&&g.prevObj?(n||l&&!l.classList.contains("e-hidden")?this.notify("transform",{prop:"resize",value:{width:v.x,height:v.y,isAspectRatio:!1}}):(a||s&&!s.classList.contains("e-hidden"))&&this.notify("transform",{prop:"resize",value:{width:v.x,height:null,isAspectRatio:!0}}),this.isResize=!1,this.aspectWidth=v.x,this.aspectHeight=v.y,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:g.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),g.prevObj.zoomFactor&&this.setProperties({zoomSettings:{zoomFactor:g.prevObj.zoomFactor}},!0),this.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:this.zoomSettings.zoomFactor}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:g.prevObj,previousObjColl:g.prevObj.objColl,previousPointColl:g.prevObj.pointColl,previousSelPointColl:g.prevObj.selPointColl,previousCropObj:u.prevCropObj,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.isAspectRatio=!1}var b=this.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected"),f={bool:!1};this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:f}});if(this.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:{bool:null}}}),b&&(this.currentFilter=b.children[0].children[0].id.replace("Canvas","")),r)this.crop();else if(this.togglePen)this.freeHandDraw(!1),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if("block"===this.textArea.style.display)this.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.isNullOrUndefined(i)&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(!t.isBlazor()&&document.querySelector("#"+this.element.id+"_sliderWrapper")||t.isBlazor()&&!this.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||this.currObjType.isFiltered){this.initialAdjustmentValue=this.canvasFilter=this.lowerContext.filter,this.currObjType.isFiltered=!1;var m={value:null};this.notify("draw",{prop:"getTempAdjustmentValue",value:{obj:m}}),m.value!==this.lowerContext.filter&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)&&this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:i}})}else if(f.bool)this.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),t.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)"image"===this.activeObj.shape&&this.notify("draw",{prop:"setImageApply",onPropertyChange:!1,value:{bool:!0}}),this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:i}});else{if(JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)){var C={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:C}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:C.currObj,previousObjColl:C.currObj.objColl,previousPointColl:C.currObj.pointColl,previousSelPointColl:C.currObj.selPointColl,previousCropObj:t.extend({},this.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.tempFrameObj=t.extend({},this.frameObj,{},!0),this.notify("draw",{prop:"setTempFrame",onPropertyChange:!1,value:{frame:this.frameObj.type}})}this.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1})}t.isBlazor()||f.isCropToolbar?!t.isBlazor()||f.isCropToolbar||"resize-toolbar"!=this.currentToolbar&&"frame-toolbar"!=this.currentToolbar||this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}),this.notify("draw",{prop:"setNewPath",value:{bool:!1}}),this.isCropTab=!1,this.transform.zoomFactor=this.transform.defaultZoomFactor,this.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}})},a.prototype.setTempFilterProperties=function(){this.upperCanvas.style.display="block",this.cropSelectedState();var e={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:e}}),this.lowerContext.filter=this.initialAdjustmentValue,this.notify("draw",{prop:"setTempAdjustmentValue",value:{tempAdjustmentValue:this.lowerContext.filter}}),this.notify("filter",{prop:"setTempAdjustmentLevel",onPropertyChange:!1,value:{tempAdjustmentLevel:t.extend({},e.adjustmentLevel,{},!0)}}),this.notify("draw",{prop:"setTempFilter",value:{tempFilter:this.currentFilter}});var i={undoRedoStep:null};this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}}),this.notify("draw",{prop:"setTempUndoRedoStep",value:{tempUndoRedoStep:i.undoRedoStep}})},a.prototype.cropSelectedState=function(){this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&this.okBtn()},a.prototype.getCurrentCanvasData=function(){var e=t.extend({},this.frameObj,{},!0);this.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""};var i=this.lowerContext.filter;this.lowerContext.filter=this.canvasFilter="none";var o=t.extend([],this.objColl,null,!0),r=t.extend([],this.pointColl,null,!0);this.objColl=[],this.pointColl=[],this.freehandCounter=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide");var a=this.getImageData();return this.element.querySelector(".e-contextual-toolbar-wrapper")&&(this.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide"),t.isBlazor()&&(this.element.querySelector(".e-ie-toolbar-check-btn").classList.remove("e-hidden"),this.element.querySelector(".e-ie-toolbar-close-btn").classList.remove("e-hidden"))),t.isBlazor()||(t.Browser.isDevice||this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!1}}),this.element.querySelector("#"+this.element.id+"_contextualToolbarArea").classList.remove("e-hide")),this.objColl=o,this.pointColl=r,this.freehandCounter=r.length,this.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=this.canvasFilter=i,this.frameObj=e,a},a.prototype.setCurrAdjustmentValue=function(e,i){var o=this,r={finetune:this.getFinetuneOption(e),value:i,cancel:!1};if(t.isBlazor()&&this.events&&!0===this.events.finetuneValueChanging.hasDelegate)this.dotNetRef.invokeMethodAsync("OnFinetuneValueChangeAsync",r).then(function(t){t.cancel||o.notify("filter",{prop:"setCurrAdjValue",value:{type:e.toLowerCase(),value:i}})});else{if(this.trigger("finetuneValueChanging",r),r.cancel)return;this.notify("filter",{prop:"setCurrAdjValue",value:{type:e.toLowerCase(),value:i}})}},a.prototype.getSquarePointForPath=function(e){var t={startX:0,startY:0,endX:0,endY:0,width:0,height:0};if(e.pointColl.length>0){t={startX:e.pointColl[0].x,startY:e.pointColl[0].y,endX:e.pointColl[0].x,endY:e.pointColl[0].y};for(var i=1;i<e.pointColl.length;i++)e.pointColl[i].x<t.startX&&(t.startX=e.pointColl[i].x),e.pointColl[i].y<t.startY&&(t.startY=e.pointColl[i].y),e.pointColl[i].x>t.endX&&(t.endX=e.pointColl[i].x),e.pointColl[i].y>t.endY&&(t.endY=e.pointColl[i].y);t.width=t.endX-t.startX,t.height=t.endY-t.startY}return t},a.prototype.getSelectionType=function(e){return{CropCustom:"Custom",CropSquare:"Square",CropCircle:"Circle","Crop3:2":"3:2","Crop4:3":"4:3","Crop5:4":"5:4","Crop7:5":"7:5","Crop16:9":"16:9"}[""+e]},a.prototype.clearContext=function(e){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.clearRect(0,0,e.canvas.height,e.canvas.width)},a.prototype.updateArrow=function(e,i){this.notify("shape",{prop:"pushActItemIntoObj"});var o=t.extend({},this.cropObj,{},!0),r={currObj:{}},a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj;this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var s=r.currObj;if(s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0),this.objColl.pop(),"startArrow"===e?this.activeObj.start=this.getTextFromId(i):"endArrow"===e&&(this.activeObj.end=this.getTextFromId(i)),this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),!t.isBlazor())if(t.Browser.isDevice){if(document.getElementById(this.element.id+"_bottomToolbar")){t.getComponent(this.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(this.element.id+"_toolbar")){t.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow()}var l={action:e,previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};this.triggerShapeChanged(l)},a.prototype.updateFontFamily=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=t.extend([],this.objColl,[],!0),o=t.extend({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0);var l={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var p=this.activeObj.textSettings.fontFamily;this.activeObj.textSettings.fontFamily=this.toPascalCase(e),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var h=this.activeObj.activePoint.width+.25*this.activeObj.textSettings.fontSize;this.textArea.style.width=h+"px",this.textArea.style.fontFamily=this.toPascalCase(e),this.activeObj.textSettings.fontFamily=p,this.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}})}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var c=this.activeObj.textSettings.fontFamily=this.toPascalCase(e);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:c,fontSize:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:i,previousPointColl:t.extend([],this.pointColl,[],!0),previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var d={action:"font-family",previousShapeSettings:t.extend({},a,{},!0),currentShapeSettings:t.extend({},a,{},!0)};d.currentShapeSettings.fontFamily=this.textArea.style.fontFamily,this.triggerShapeChanged(d)},a.prototype.updateFontSize=function(e){var i=e;this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var o=t.extend({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0);var l={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var p=this.activeObj.textSettings.fontSize;this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop();var h="";"bold"===this.textArea.style.fontWeight&&(h="bold "),"italic"===this.textArea.style.fontStyle&&(h="italic "),"bold"===this.textArea.style.fontWeight&&"italic"===this.textArea.style.fontStyle&&(h="italic bold "),this.upperContext.font=h+this.activeObj.textSettings.fontSize+"px "+this.textArea.style.fontFamily;var c=this.textArea.value.split("\n"),d={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:!0,text:null,obj:d}});var v=d.maxText,u=this.upperContext.measureText(v).width+.5*this.activeObj.textSettings.fontSize;this.textArea.style.width=u+"px",this.textArea.style.height=c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)+"px",this.activeObj.textSettings.fontSize=p,this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,this.textArea.style.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10)+"px","georgia"===this.textArea.style.fontFamily&&(this.textArea.style.width=parseFloat(this.textArea.style.width)+parseFloat(this.textArea.style.fontSize)+"px")}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var g=this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:null,fontSize:g}}),this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;c=this.activeObj.keyHistory.split("\n"),d={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:null,text:null,obj:d}});var b=d.maxText,f=(u=this.upperContext.measureText(b).width+.5*this.activeObj.textSettings.fontSize,c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize));this.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:u,height:f}}),this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:this.activeObj.activePoint,obj:this.activeObj,isMouseMove:null,x:null,y:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var m={action:"font-size",previousShapeSettings:t.extend({},a,{},!0),currentShapeSettings:t.extend({},a,{},!0)};m.currentShapeSettings.fontSize=this.activeObj.textSettings.fontSize,this.triggerShapeChanged(m)},a.prototype.updateFontColor=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=t.extend({},this.cropObj,{},!0),o={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:o}});var r=o.shapeSettingsObj,a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),"none"===this.textArea.style.display)this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));else if("block"===this.textArea.style.display){this.textArea.style.color=e;var l=this.activeObj.strokeSettings.strokeColor;this.activeObj.strokeSettings.strokeColor=e,this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=l}else this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));var p={action:"font-color",previousShapeSettings:t.extend({},r,{},!0),currentShapeSettings:t.extend({},r,{},!0)};p.currentShapeSettings.fillColor=e,this.triggerShapeChanged(p)},a.prototype.updatePenStrokeWidth=function(i){var o=t.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var r=t.extend({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],this.objColl,[],!0),l.pointColl=t.extend([],this.pointColl,[],!0),l.afterCropActions=t.extend([],this.afterCropActions,[],!0);var p={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),this.pointColl=o,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.setPenStroke(i);var h={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:h}}),h.bool){var c={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:c}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:c.penStrokeWidth}});var d={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),this.pointColl[d.freehandSelectedIndex].strokeWidth=c.penStrokeWidth,this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}n.type=e.ShapeType.FreehandDraw;var v={action:"stroke-width",previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};v.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth,this.triggerShapeChanged(v)},a.prototype.updatePenStrokeColor=function(i){var o=t.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var r=t.extend({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],this.objColl,[],!0),l.pointColl=t.extend([],this.pointColl,[],!0),l.afterCropActions=t.extend([],this.afterCropActions,[],!0);var p={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),this.pointColl=o,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.activeObj.strokeSettings.strokeColor=i;var h={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:h}}),h.bool){var c={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:c}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.pointColl[c.freehandSelectedIndex].strokeColor=i,this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:i}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else this.togglePen||this.notify("selection",{prop:"redrawShape",value:{obj:this.activeObj}});n.type=e.ShapeType.FreehandDraw;var d={action:"stroke-color",previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};d.currentShapeSettings.strokeColor=i,this.triggerShapeChanged(d)},a.prototype.updateStrokeWidth=function(e){if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeWidth=parseInt(e,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var l={action:"stroke-width",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth,this.triggerShapeChanged(l)}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeWidth=parseInt(e,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}))},a.prototype.updateStrokeColor=function(e){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}));var l={action:"stroke-color",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.strokeColor=e,this.triggerShapeChanged(l)},a.prototype.updateFillColor=function(e){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.fillColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var l={action:"fill-color",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.fillColor=e,this.triggerShapeChanged(l)},a.prototype.horizontalFlip=function(e,i){var o,r;if(t.isNullOrUndefined(i)){this.notify("shape",{prop:"pushActItemIntoObj"}),o=t.extend({},this.cropObj,{},!0);var a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],this.objColl,[],!0),r.pointColl=t.extend([],this.pointColl,[],!0),r.afterCropActions=t.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0),this.objColl.pop()}t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height),this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isNullOrUndefined(i)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageHFlip",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},a.prototype.verticalFlip=function(e,i){var o,r;if(t.isNullOrUndefined(i)){this.notify("shape",{prop:"pushActItemIntoObj"}),o=t.extend({},this.cropObj,{},!0);var a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],this.objColl,[],!0),r.pointColl=t.extend([],this.pointColl,[],!0),r.afterCropActions=t.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0),this.objColl.pop()}t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height),this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isNullOrUndefined(i)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageVFlip",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},a.prototype.rotateImage=function(e){t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),"rotleft"===e?this.activeObj.rotatedAngle-=Math.PI/180*90:this.activeObj.rotatedAngle+=Math.PI/180*90,this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.activeObj}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isBlazor()?(this.updateToolbar(this.element,"destroyQuickAccessToolbar"),this.updateToolbar(this.element,"quickAccessToolbar","image")):(this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))},a.prototype.pascalToSplitWords=function(e){var i=(e=e.charAt(0).toUpperCase()+e.slice(1)).match(/[A-Z][a-z]+/g);return t.isNullOrUndefined(i)?e:i.map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ")},a.prototype.getCurrAdjustmentValue=function(e){var t={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:t}});return{brightness:t.adjustmentLevel.brightness,contrast:t.adjustmentLevel.contrast,hue:t.adjustmentLevel.hue,saturation:t.adjustmentLevel.saturation,opacity:t.adjustmentLevel.opacity,blur:t.adjustmentLevel.blur,exposure:t.adjustmentLevel.exposure,transparency:t.adjustmentLevel.transparency}[""+e]},a.prototype.transformSelect=function(e){this.isCropToolbar=!0,this.allowDownScale=!1,this.setInitialZoomState();var i=t.extend({},this.activeObj,{},!0);this.cropSelectedState(),this.notify("draw",{prop:"resetCurrentSelectionPoint"}),this.updateImageTransformColl(e),this.notify("transform",{prop:"performTransformation",value:{text:e}}),this.notify("draw",{prop:"moveToSelectionRange",value:{type:e,activeObj:i}}),this.isCropToolbar=!1},a.prototype.getDefaultFilter=function(){return"brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},a.prototype.initializeImageEditor=function(e,o){this.element=e,t.isBlazor()&&this.element.querySelector(".place-holder")&&this.element.querySelector(".place-holder").remove(),this.element.offsetWidth>359&&this.element.querySelector(".e-ie-min-drop-content")&&this.element.querySelector(".e-ie-drop-content")&&(this.element.querySelector(".e-ie-min-drop-content").style.display="none",this.element.querySelector(".e-ie-drop-content").style.display="block"),t.isBlazor()&&this.element.querySelector(".e-ie-drop-area")&&(this.element.querySelector(".e-ie-drop-area").style.display="block"),t.isBlazor()&&this.element.querySelector(".e-toolbar-area")&&(this.element.querySelector(".e-toolbar-area").style.display="block");var r=this.element.querySelector(".e-canvas-wrapper");this.element.querySelector("#"+this.element.id+"_toolbarArea")?this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbarArea").clientHeight:this.toolbarHeight=0,r.style.height=this.element.offsetHeight-this.toolbarHeight-2+"px",r.style.width=this.element.offsetWidth-2+"px",this.lowerCanvas=this.element.querySelector(".e-lower-canvas"),this.upperCanvas=this.element.querySelector(".e-upper-canvas"),this.lowerCanvas.id=this.element.id+"_lowerCanvas",this.upperCanvas.id=this.element.id+"_upperCanvas",this.textArea=this.element.querySelector(".e-textbox"),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.baseImgCanvas=this.createElement("canvas",{id:this.element.id+"_baseImgCanvas",attrs:{name:"canvasImage"}}),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.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),o&&(this.dotNetRef=o),this.prerender(),this.wireEvent(),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.initialAdjustmentValue=this.lowerContext.filter,this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},a.prototype.prerender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-image-editor"),t.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},a.prototype.initializeZoomSettings=function(){t.isNullOrUndefined(this.zoomSettings.zoomTrigger)&&(this.zoomSettings.zoomTrigger=e.ZoomTrigger.MouseWheel|e.ZoomTrigger.Pinch|e.ZoomTrigger.Toolbar|e.ZoomTrigger.Commands),t.isNullOrUndefined(this.selectionSettings.strokeColor)&&(this.selectionSettings.strokeColor=this.themeColl[this.theme].primaryColor),t.isNullOrUndefined(this.selectionSettings.fillColor)&&(this.selectionSettings.fillColor=this.themeColl[this.theme].secondaryColor)},a.prototype.initializeThemeColl=function(){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"},Material3:{primaryColor:"#6750a4",secondaryColor:"#fff"},Material3Dark:{primaryColor:"#d0bcff",secondaryColor:"#fff"}}},a.prototype.updateToolbar=function(e,t,i){},a.prototype.triggerShapeChanged=function(e){t.isBlazor()&&this.events&&!0===this.events.shapeChanged.hasDelegate&&this.dotNetRef.invokeMethodAsync("ShapeEventAsync","ShapeChanged",e)};var y;return b([t.Property("")],a.prototype,"cssClass",void 0),b([t.Property(!1)],a.prototype,"disabled",void 0),b([t.Property("100%")],a.prototype,"height",void 0),b([t.Property("Bootstrap5")],a.prototype,"theme",void 0),b([t.Property()],a.prototype,"toolbar",void 0),b([t.Property()],a.prototype,"toolbarTemplate",void 0),b([t.Property("100%")],a.prototype,"width",void 0),b([t.Property(!0)],a.prototype,"allowUndoRedo",void 0),b([t.Property(!0)],a.prototype,"showQuickAccessToolbar",void 0),b([t.Property()],a.prototype,"quickAccessToolbarTemplate",void 0),b([t.Property(!1)],a.prototype,"isReadOnly",void 0),b([t.Property(!1)],a.prototype,"enableRtl",void 0),b([t.Property(!1)],a.prototype,"enablePersistence",void 0),b([t.Complex({},f)],a.prototype,"finetuneSettings",void 0),b([t.Complex({},m)],a.prototype,"zoomSettings",void 0),b([t.Complex({},C)],a.prototype,"selectionSettings",void 0),b([t.Event()],a.prototype,"beforeSave",void 0),b([t.Event()],a.prototype,"created",void 0),b([t.Event()],a.prototype,"destroyed",void 0),b([t.Event()],a.prototype,"zooming",void 0),b([t.Event()],a.prototype,"panning",void 0),b([t.Event()],a.prototype,"cropping",void 0),b([t.Event()],a.prototype,"rotating",void 0),b([t.Event()],a.prototype,"flipping",void 0),b([t.Event()],a.prototype,"shapeChanging",void 0),b([t.Event()],a.prototype,"selectionChanging",void 0),b([t.Event()],a.prototype,"fileOpened",void 0),b([t.Event()],a.prototype,"saved",void 0),b([t.Event()],a.prototype,"toolbarCreated",void 0),b([t.Event()],a.prototype,"toolbarUpdating",void 0),b([t.Event()],a.prototype,"toolbarItemClicked",void 0),b([t.Event()],a.prototype,"imageFiltering",void 0),b([t.Event()],a.prototype,"finetuneValueChanging",void 0),b([t.Event()],a.prototype,"click",void 0),b([t.Event()],a.prototype,"quickAccessToolbarOpen",void 0),b([t.Event()],a.prototype,"resizing",void 0),b([t.Event()],a.prototype,"quickAccessToolbarItemClick",void 0),b([t.Event()],a.prototype,"frameChange",void 0),a=y=b([t.NotifyPropertyChanges],a)}(t.Component);!function(e){e.Png="Png",e.Jpeg="Jpeg",e.Svg="Svg"}(e.FileType||(e.FileType={})),function(e){e.Horizontal="Horizontal",e.Vertical="Vertical"}(e.Direction||(e.Direction={})),function(e){e.Rectangle="Rectangle",e.Ellipse="Ellipse",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Text="Text",e.FreehandDraw="FreehandDraw",e.Image="Image"}(e.ShapeType||(e.ShapeType={})),function(e){e[e.MouseWheel=1]="MouseWheel",e[e.Pinch=2]="Pinch",e[e.Commands=4]="Commands",e[e.Toolbar=8]="Toolbar"}(e.ZoomTrigger||(e.ZoomTrigger={})),function(e){e.Bootstrap5="Bootstrap5",e.Bootstrap5Dark="Bootstrap5Dark",e.Tailwind="Tailwind",e.TailwindDark="TailwindDark",e.Fluent="Fluent",e.FluentDark="FluentDark",e.Bootstrap4="Bootstrap4",e.Bootstrap="Bootstrap",e.BootstrapDark="BootstrapDark",e.Material="Material",e.MaterialDark="MaterialDark",e.Fabric="Fabric",e.FabricDark="FabricDark",e.Highcontrast="Highcontrast"}(e.Theme||(e.Theme={})),function(e){e.Crop="Crop",e.Transform="Transform",e.Annotate="Annotate",e.ZoomIn="ZoomIn",e.ZoomOut="ZoomOut",e.Open="Open",e.Reset="Reset",e.Save="Save",e.Pan="Pan",e.Move="Move",e.Pen="Pen",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Rectangle="Rectangle",e.Image="Image",e.Ellipse="Ellipse",e.Text="Text",e.CustomSelection="CustomSelection",e.CircleSelection="CircleSelection",e.SquareSelection="SquareSelection",e.RatioSelection="RatioSelection",e.RotateLeft="RotateLeft",e.RotateRight="RotateRight",e.FlipHorizontal="FlipHorizontal",e.FlipVertical="FlipVertical",e.Undo="Undo",e.Redo="Redo",e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Inset="Inset",e.Hook="Hook",e.Finetune="Finetune",e.Filter="Filter",e.Frame="Frame",e.Resize="Resize",e.HorizontalFlip="HorizontalFlip",e.VerticalFlip="VerticalFlip",e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Opacity="Opacity",e.Blur="Blur",e.Exposure="Exposure",e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert"}(e.ImageEditorCommand||(e.ImageEditorCommand={})),function(e){e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert"}(e.ImageFilterOption||(e.ImageFilterOption={})),function(e){e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Exposure="Exposure",e.Opacity="Opacity",e.Blur="Blur"}(e.ImageFinetuneOption||(e.ImageFinetuneOption={})),function(e){e.None="None",e.Arrow="Arrow",e.SolidArrow="SolidArrow",e.Circle="Circle",e.SolidCircle="SolidCircle",e.Square="Square",e.SolidSquare="SolidSquare",e.Bar="Bar"}(e.ArrowheadType||(e.ArrowheadType={})),function(e){e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Line="Line",e.Inset="Inset",e.Hook="Hook"}(e.FrameType||(e.FrameType={})),function(e){e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted"}(e.FrameLineStyle||(e.FrameLineStyle={}));var j=function(){function n(e){this.defToolbarItems=[],this.toolbarHeight=46,this.currToolbar="",this.preventZoomBtn=!1,this.currentToolbar="main",this.selFhdColor="#42a5f5",this.preventEnableDisableUr=!1,this.isAspectRatio=!0,this.isFrameToolbar=!1,this.parent=e,this.addEventListener(),this.initLocale()}return n.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},n.prototype.addEventListener=function(){this.parent.on("toolbar",this.toolbar,this),this.parent.on("destroyed",this.destroy,this)},n.prototype.removeEventListener=function(){this.parent.off("toolbar",this.toolbar),this.parent.off("destroyed",this.destroy)},n.prototype.initLocale=function(){this.defaultLocale={Crop:"Crop",ZoomIn:"Zoom In",ZoomOut:"Zoom Out",Undo:"Undo",Redo:"Redo",Transform:"Transform",Annotation:"Annotation",Finetune:"Finetune",Brightness:"Brightness",Contrast:"Contrast",Hue:"Hue",Saturation:"Saturation",Opacity:"Opacity",Blur:"Blur",Sharpen:"Sharpen",Exposure:"Exposure",Filter:"Filter",Default:"Default",Chrome:"Chrome",Cold:"Cold",Warm:"Warm",Grayscale:"Grayscale",BlackAndWhite:"Black and White",Sepia:"Sepia",Invert:"Invert",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",Arrow:"Arrow",Path:"Path",Bold:"Bold",Italic:"Italic",BoldItalic:"Bold Italic",XSmall:"X-Small",Small:"Small",Medium:"Medium",Large:"Large",XLarge:"X-Large",ABC:"ABC",Browse:"Browse",Duplicate:"Duplicate",Remove:"Remove",EditText:"Edit Text",Start:"Start",End:"End",Bar:"Bar",ArrowSolid:"Arrow Solid",CircleSolid:"Circle Solid",SquareSolid:"Square Solid",None:"None",CropAndTransform:"Crop and Transform",CropSelection:"Crop Selection",Image:"Add Image",Transparency:"Transparency",Height:"Height",Width:"Width",AspectRatio:"Maintain aspect ratio",W:"W",H:"H",DragText:"Drag and drop your image here or",DropText:"Drop your image here or",BrowseText:"Browse here...",SupportText:"Supports:",Frame:"Frame",Mat:"Mat",Bevel:"Bevel",Inset:"Inset",Hook:"Hook",Color:"Color",Size:"Size",Offset:"Offset",Radius:"Radius",Amount:"Amount",Resize:"Resize",0:"0%",20:"20%",40:"40%",60:"60%",80:"80%",100:"100%",1:"1",2:"2",3:"3",4:"4",5:"5",Border:"Border",Solid:"Solid",Dashed:"Dashed",Dotted:"Dotted",GradientColor:"Gradient Color",ConfirmDialogHeader:"Confirm Save Changes",ConfirmDialogContent:"Do you want to save the changes you made to the image?",AlertDialogHeader:"Unsupported file",AlertDialogContent:"The dropped file is unsupported.",Yes:"Yes",No:"No",ImageErrorDialogHeader:"Image Selection Error",ImageErrorDialogContent:"Please select only one image to open."},this.l10n=new t.L10n("image-editor",this.defaultLocale,this.parent.locale)},n.prototype.toolbar=function(e){var t=this.parent;switch(this.updatePrivateVariables(),e.prop){case"create-toolbar":this.createToolbar();break;case"create-contextual-toolbar":this.createContextualToolbar();break;case"update-toolbar-items":this.updateToolbarItems();break;case"refresh-toolbar":this.refreshToolbar(e.value.type,e.value.isApplyBtn,e.value.isCropping,e.value.isZooming,e.value.cType);break;case"renderQAT":this.renderQAT(e.value.isPenEdit);break;case"enable-disable-btns":this.enableDisableTbrBtn();break;case"init-main-toolbar":this.initMainToolbar(e.value.isApplyBtn,e.value.isDevice,e.value.isOkBtn,e.value.isResize);break;case"create-bottom-toolbar":this.createBottomToolbar();break;case"refresh-main-toolbar":this.refreshMainToolbar();break;case"create-qa-toolbar":this.createQuickAccessToolbar();break;case"destroy-qa-toolbar":this.destroyQuickAccessToolbar();break;case"zoom-up-handler":this.zoomBtnMouseUpHandler();break;case"refresh-dropdown-btn":this.refreshDropDownBtn(e.value.isDisabled);break;case"close-contextual-toolbar":this.closeContextualToolbar();break;case"destroy-bottom-toolbar":this.destroyBottomToolbar();break;case"destroy-top-toolbar":this.destroyTopToolbar();break;case"destroySubComponents":this.destroySubComponents();break;case"setLocale":this.l10n.setLocale(e.value.locale);break;case"setPreventZoomBtn":this.preventZoomBtn=e.value.isPrevent;break;case"getToolbarHeight":e.value.obj.toolbarHeight=this.toolbarHeight;break;case"setToolbarHeight":this.toolbarHeight=e.value.height;break;case"setCurrentToolbar":this.currentToolbar=e.value.type;break;case"setSelectedFreehandColor":this.selFhdColor=e.value.color;break;case"getCurrentFilter":e.value.obj.currentFilter=t.currentFilter;break;case"setCurrentFilter":t.currentFilter=e.value.filter;break;case"setInitialAdjustmentValue":t.initialAdjustmentValue=e.value.value;break;case"getCanvasFilter":e.value.obj.canvasFilter=t.canvasFilter;break;case"getDefToolbarItems":e.value.obj.defToolbarItems=this.defToolbarItems;break;case"getPenStroke":this.getPenStroke(e.value.value);break;case"performDefToolbarClickAction":this.performDefTbrClick(e.value.type,e.value.isContextualToolbar,e.value.isDisabledAdjustment,e.value.isDisabledFilter,e.value.isFilterFinetune);break;case"setTempFilterProperties":t.setTempFilterProperties();break;case"refreshSlider":this.refreshSlider();break;case"renderSlider":this.renderSlider(e.value.type);break;case"getCurrAdjustmentValue":t.getCurrAdjustmentValue(e.value.type);break;case"setCurrAdjustmentValue":t.setCurrAdjustmentValue(e.value.type,e.value.value);break;case"refreshShapeDrawing":this.refreshShapeDrawing();break;case"getCropToolbar":e.value.obj.isCropToolbar=t.isCropToolbar;break;case"getPrevCurrSelectionPoint":e.value.obj.prevCurrSelectionPoint=t.prevCurrSelectionPoint;break;case"setPrevCurrSelectionPoint":t.prevCurrSelectionPoint=e.value.point;break;case"updateCropTransformItems":t.updateCropTransformItems();break;case"setEnableDisableUndoRedo":this.preventEnableDisableUr=e.value.isPrevent;break;case"reset":this.reset();break;case"getLocaleText":e.value.obj.value=this.l10n.getConstant(e.value.obj.key);break;case"initResizeToolbar":this.initResizeToolbar();break;case"getFrameToolbar":e.value.obj.bool=this.isFrameToolbar;break;case"callFrameToolbar":this.callFrameToolbar();break;case"resizeClick":this.resizeClick();break;case"frameToolbarClick":this.frameToolbarClick()}},n.prototype.updatePrivateVariables=function(){var e=this.parent;this.inMemoryCanvas=e.inMemoryCanvas,e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),this.inMemoryCanvas&&(this.inMemoryContext=this.inMemoryCanvas.getContext("2d"))},n.prototype.reset=function(){var e=this.parent;this.defToolbarItems=[],this.toolbarHeight=46,e.prevCurrSelectionPoint=null,this.zoomBtnHold=null,this.currToolbar="",e.cxtTbarHeight=null,this.currentToolbar="main",this.selFhdColor="#42a5f5",e.currentFilter="",this.preventZoomBtn=e.isCropToolbar=this.preventEnableDisableUr=this.isFrameToolbar=!1,e.initialAdjustmentValue=e.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},n.prototype.destroyTopToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_toolbar");this.isToolbar()&&i&&i.classList.contains("e-control")&&t.getComponent(document.getElementById(e.element.id+"_toolbar"),"toolbar").destroy()},n.prototype.destroyBottomToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_bottomToolbar");i&&i.classList.contains("e-control")&&t.getComponent(document.getElementById(e.element.id+"_bottomToolbar"),"toolbar").destroy()},n.prototype.isToolbar=function(){var e=this.parent;return t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0||!t.isNullOrUndefined(e.toolbarTemplate)},n.prototype.createToolbar=function(){var e=this,i=this.parent;if(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){i.element.appendChild(i.createElement("div",{id:i.element.id+"_toolbarArea",className:"e-toolbar-area"}));var a={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})};t.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(a);var n=document.getElementById(i.element.id+"_toolbarArea"),s=i.createElement("div",{id:i.element.id+"_toolbar"});n.appendChild(s);var l=[{cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1,selected:function(){i.disabled||(t.Browser.isDevice?(e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&t.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(i.element.id+"_bottomToolbar")&&t.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar").destroy(),e.initMainToolbar(!1,t.Browser.isDevice,null),e.createBottomToolbar()):(e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&t.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),e.initMainToolbar(!1,!1,null)))}})}];new r.Toolbar({items:l,width:"100%",created:function(){i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_toolbar"),this.createLeftToolbarControls(),document.getElementById(i.element.id+"_toolbar")&&(this.toolbarHeight=document.getElementById(i.element.id+"_toolbar").clientHeight)}else this.toolbarHeight=0},n.prototype.createContextualToolbar=function(){var e=this.parent;if(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0){e.element.appendChild(e.createElement("div",{id:e.element.id+"_contextualToolbarArea",className:"e-contextual-toolbar-wrapper e-hide",attrs:{style:"position: absolute;"}}));var i=document.getElementById(e.element.id+"_contextualToolbarArea"),o=e.createElement("div",{id:e.element.id+"_contextualToolbar"});i.appendChild(o)}},n.prototype.createBottomToolbar=function(){var e=this.parent;if(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0){if(e.element.appendChild(e.createElement("div",{id:e.element.id+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!e.toolbarTemplate){document.getElementById(e.element.id+"_canvasWrapper").style.height=e.element.offsetHeight-2*this.toolbarHeight-3+"px";var i=document.getElementById(e.element.id+"_bottomToolbarArea"),o=e.createElement("div",{id:e.element.id+"_bottomToolbar"});i.appendChild(o)}this.initBottomToolbar()}},n.prototype.createQuickAccessToolbar=function(){var e=this.parent;if(e.showQuickAccessToolbar){var i={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})};t.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(i);var a=document.getElementById(e.element.id+"_quickAccessToolbarArea"),n=e.createElement("div",{id:e.element.id+"_quickAccessToolbar"});a.appendChild(n);new r.Toolbar({clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+e.element.id+"_quickAccessToolbar")}},n.prototype.initMainToolbar=function(e,i,o,a,n){var s=this,l=this.parent;if(this.isToolbar()){var p=this.getLeftToolbarItem(o,a),h=this.getRightToolbarItem(o),c=this.getMainToolbarItem(e,n),d=this.getZoomToolbarItem();this.defToolbarItems=i?n?c:p.concat(h):p.concat(c,h,d);var v=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i||s.renderAnnotationBtn(),s.wireZoomBtnEvents(),s.renderSaveBtn(),l.trigger("toolbarCreated",{toolbarType:"main"})}});if(i&&n?v.appendTo("#"+l.element.id+"_bottomToolbar"):v.appendTo("#"+l.element.id+"_toolbar"),this.createLeftToolbarControls(),this.enableDisableTbrBtn(),this.isToolbar()&&document.getElementById(l.element.id+"_toolbar")){t.getComponent(l.element.id+"_toolbar","toolbar").refreshOverflow()}}},n.prototype.initBottomToolbar=function(){var e=this,i=this.parent;if(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){var o=this.getMainToolbarItem();if(new r.Toolbar({items:o,width:"100%",created:function(){e.renderAnnotationBtn(),e.renderCropBtn(),e.renderTransformBtn(),i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_bottomToolbar"),this.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}},n.prototype.getLeftToolbarItem=function(i,r){var a=this.parent,n=[];i&&!r||(n.push({id:a.element.id+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})}),n.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"})),a.allowUndoRedo&&!r&&((t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("Undo")>-1)&&n.push({id:a.element.id+"_undo",prefixIcon:"e-icons e-undo",cssClass:"top-icon e-undo",tooltipText:this.l10n.getConstant("Undo"),align:"Left"}),(t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("Redo")>-1)&&n.push({id:a.element.id+"_redo",prefixIcon:"e-icons e-redo",cssClass:"top-icon e-redo",tooltipText:this.l10n.getConstant("Redo"),align:"Left"})),this.preventZoomBtn||(a.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)!==e.ZoomTrigger.Toolbar||r||((t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("ZoomOut")>-1)&&n.push({id:a.element.id+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),(t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("ZoomIn")>-1)&&n.push({id:a.element.id+"_zoomIn",prefixIcon:"e-icons e-zoom-in",cssClass:"top-icon e-inc-zoom",tooltipText:this.l10n.getConstant("ZoomIn"),align:"Left"}));for(var s=this.processToolbar("left"),l=0,p=s.length;l<p;l++)n.push(s[l]);return n},n.prototype.getRightToolbarItem=function(e){var i=this.parent,o=[];e&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Reset")>-1)&&o.push({id:i.element.id+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),e||(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Save")>-1)&&o.push({id:i.element.id+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right",template:'<button id="'+i.element.id+'_saveBtn"></button>'});for(var r=this.processToolbar("right"),a=0,n=r.length;a<n;a++)o.push(r[a]);return o},n.prototype.getMainToolbarItem=function(e,i){var o=this.parent,r=[];i?((t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("None")>-1)&&r.push({id:this.parent.element.id+"_none",prefixIcon:"e-icons e-frame-none",cssClass:"top-icon e-frame-none",tooltipText:this.l10n.getConstant("None"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Mat")>-1)&&r.push({id:this.parent.element.id+"_mat",prefixIcon:"e-icons e-frame-mat",cssClass:"top-icon e-frame-mat",tooltipText:this.l10n.getConstant("Mat"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Bevel")>-1)&&r.push({id:this.parent.element.id+"_bevel",prefixIcon:"e-icons e-frame-bevel",cssClass:"top-icon e-frame-bevel",tooltipText:this.l10n.getConstant("Bevel"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Line")>-1)&&r.push({id:this.parent.element.id+"_line",prefixIcon:"e-icons e-frame-line",cssClass:"top-icon e-frame-line",tooltipText:this.l10n.getConstant("Line"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Inset")>-1)&&r.push({id:this.parent.element.id+"_inset",prefixIcon:"e-icons e-frame-inset",cssClass:"top-icon e-frame-inset",tooltipText:this.l10n.getConstant("Inset"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Hook")>-1)&&r.push({id:this.parent.element.id+"_hook",prefixIcon:"e-icons e-frame-hook",cssClass:"top-icon e-frame-hook",tooltipText:this.l10n.getConstant("Hook"),align:"Center"})):((t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Crop")>-1)&&r.push({id:o.element.id+"_cropTransform",prefixIcon:"e-icons e-crop",cssClass:"top-icon e-crop",tooltipText:this.l10n.getConstant("CropAndTransform"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Annotate")>-1)&&r.push({id:o.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+o.element.id+'_annotationBtn"></button>'}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Finetune")>-1)&&r.push({id:o.element.id+"_adjustment",prefixIcon:"e-icons e-adjustment",cssClass:"top-icon e-adjustment",tooltipText:this.l10n.getConstant("Finetune"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Filter")>-1)&&r.push({id:o.element.id+"_filter",prefixIcon:"e-icons e-filters",cssClass:"top-icon e-filters",tooltipText:this.l10n.getConstant("Filter"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Frame")>-1)&&r.push({id:o.element.id+"_frame",prefixIcon:"e-icons e-border-frame",cssClass:"top-icon e-border-frame",tooltipText:this.l10n.getConstant("Frame"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Resize")>-1)&&r.push({id:o.element.id+"_resize",prefixIcon:"e-icons e-resize",cssClass:"top-icon e-resize",tooltipText:this.l10n.getConstant("Resize"),align:"Center"}));for(var a=this.processToolbar("center"),n=0,s=a.length;n<s;n++)r.push(a[n]);return e&&(r.push({id:o.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),r.push({id:o.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),r},n.prototype.getZoomToolbarItem=function(){return[]},n.prototype.updateContextualToolbar=function(e,i){var o=this.parent,r=o.element.querySelector("#"+o.element.id+"_toolbarArea"),a=o.element.querySelector("#"+o.element.id+"_contextualToolbarArea");if(a.classList.remove("e-hide"),a.style.left=r.offsetLeft+"px","filter"===e?(document.getElementById(o.element.id+"_toolbar")&&this.defToolbarItems.length>0&&t.getComponent(document.getElementById(o.element.id+"_toolbar"),"toolbar").destroy(),t.Browser.isDevice?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!0,null,null),this.refreshSlider(),this.initFilterToolbarItem()):(document.querySelector("#"+o.element.id+"_contextualToolbar").classList.contains("e-control")&&t.getComponent(document.getElementById(o.element.id+"_contextualToolbar"),"toolbar").destroy(),this.refreshSlider(),"frame"===e?this.initFrameToolbarItem():this.renderSlider(i)),t.Browser.isDevice){var n=a.offsetHeight;this.isFrameToolbar&&o.element.querySelector("#"+o.element.id+"_customizeWrapper")&&(n=o.element.querySelector("#"+o.element.id+"_customizeWrapper").offsetHeight);var s=o.element.querySelector("#"+o.element.id+"_canvasWrapper").offsetHeight;a.style.top=this.toolbarHeight+s-n+"px"}else a.style.top=this.toolbarHeight+"px"},n.prototype.processToolbar=function(e){var i=this.parent,o=[];if(i.toolbar)for(var r=0,a=i.toolbar.length;r<a;r++)"object"==typeof i.toolbar[r]&&(t.isNullOrUndefined(i.toolbar[r].align)?"left"===e&&o.push(i.toolbar[r]):i.toolbar[r].align.toLowerCase()===e&&o.push(i.toolbar[r]));return o},n.prototype.processSubToolbar=function(e){var t=[];if(e)for(var i=0,o=e.length;i<o;i++)"object"==typeof e[i]&&(e[i].align="Center",t.push(e[i]));return t},n.prototype.wireZoomBtnEvents=function(){var e=document.querySelector("#"+this.parent.element.id+"_zoomIn"),t=document.querySelector("#"+this.parent.element.id+"_zoomOut");e&&(e.addEventListener("mousedown",this.zoomInBtnMouseDownHandler.bind(this)),e.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),e.addEventListener("click",this.zoomInBtnClickHandler.bind(this)),e.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this))),t&&(t.addEventListener("mousedown",this.zoomOutBtnMouseDownHandler.bind(this)),t.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),t.addEventListener("click",this.zoomOutBtnClickHandler.bind(this)),e.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this)))},n.prototype.widthAspectRatio=function(e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+"_resizeHeight"),r=i.element.querySelector("#"+i.element.id+"_resizeWidth"),a=i.element.querySelector("#"+i.element.id+"_aspectratio"),n=i.img.destWidth,s=i.img.destHeight,l=parseFloat(o.value),p=Math.floor(l/(s/n));a&&(null==p||isNaN(p)?(t.getComponent(r,"numerictextbox").value=0,r.value="0 px"):(t.getComponent(r,"numerictextbox").value=p,r.value=p.toString()+" px"))},n.prototype.heightAspectRatio=function(e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+"_resizeHeight"),r=i.element.querySelector("#"+i.element.id+"_resizeWidth"),a=i.element.querySelector("#"+i.element.id+"_aspectratio"),n=i.img.destWidth,s=i.img.destHeight,l=parseFloat(r.value),p=Math.floor(l/(n/s));a&&!isNaN(p)?(t.getComponent(o,"numerictextbox").value=p,o.value=p.toString()+" px"):(t.getComponent(o,"numerictextbox").value=0,o.value="0 px")},n.prototype.getResizeToolbarItem=function(){var e=[],i=document.createElement("span");i.innerHTML=this.l10n.getConstant("W"),e.push({id:this.parent.element.id+"_width",cssClass:"e-ie-resize-width",template:i,align:"Center"}),e.push({id:this.parent.element.id+"_resizeWidth",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("Width"),align:"Center",type:"Input",template:new o.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:this.parent.aspectWidth&&this.parent.aspectHeight?this.parent.aspectWidth:Math.ceil(this.parent.img.destWidth),format:"###.## px"})});var r=document.createElement("span");return r.innerHTML=this.l10n.getConstant("H"),e.push({id:this.parent.element.id+"_height",cssClass:"e-ie-resize-height",template:r,align:"Center"}),e.push({id:this.parent.element.id+"_resizeHeight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("Height"),align:"Center",type:"Input",template:new o.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:this.parent.aspectWidth&&this.parent.aspectHeight?this.parent.aspectHeight:Math.ceil(this.parent.img.destHeight),format:"###.## px"})}),this.isAspectRatio?(e.push({id:this.parent.element.id+"_nonaspectratio",prefixIcon:"e-icons e-unlock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button"}),this.isAspectRatio=!1):(e.push({id:this.parent.element.id+"_aspectratio",prefixIcon:"e-icons e-lock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button"}),this.isAspectRatio=!0),t.Browser.isDevice||(e.push({id:this.parent.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),e.push({id:this.parent.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),e},n.prototype.initResizeToolbar=function(){var e=this,i=this.getLeftToolbarItem(!1,!0),o=this.getRightToolbarItem(),a=this.getResizeToolbarItem(),n=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=a:this.defToolbarItems=i.concat(n,a,o);var s=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireResizeBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),e.parent.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?e.defToolbarItems.length>0&&!t.isNullOrUndefined(document.getElementById(e.parent.element.id+"_bottomToolbar"))&&s.refreshOverflow():(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&!t.isNullOrUndefined(document.getElementById(e.parent.element.id+"_toolbar"))&&s.refreshOverflow())}});t.Browser.isDevice?s.appendTo("#"+this.parent.element.id+"_bottomToolbar"):s.appendTo("#"+this.parent.element.id+"_toolbar"),this.parent.isResize=!1,this.enableDisableTbrBtn(),this.parent.isResize=!0,this.parent.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.wireResizeBtnEvents=function(){var e=this.parent,i=e.element.querySelector("#"+e.element.id+"_resizeHeight"),o=e.element.querySelector("#"+e.element.id+"_resizeWidth");e.element.querySelector("#"+e.element.id+"_aspectratio")&&(t.isNullOrUndefined(i)||o.addEventListener("keyup",this.heightAspectRatio.bind(this)),t.isNullOrUndefined(o)||i.addEventListener("keyup",this.widthAspectRatio.bind(this)))},n.prototype.enableDisableTbrBtn=function(){var e=this.parent;if(!this.preventEnableDisableUr){var t={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:t}});var i={undoRedoStep:null};e.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}});var o=e.element.querySelector("#"+e.element.id+"_undo");o&&0===i.undoRedoStep?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):o&&i.undoRedoStep>0&&(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay"));var r=e.element.querySelector("#"+e.element.id+"_redo");r&&i.undoRedoStep===t.appliedUndoRedoColl.length?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):r&&0===i.undoRedoStep&&t.appliedUndoRedoColl.length>0?(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")):r&&i.undoRedoStep>0&&(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay"))}var a=document.querySelector("#"+e.element.id+"_zoomIn");a&&e.zoomSettings.zoomFactor>=e.zoomSettings.maxZoomFactor?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):a&&(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay"));var n=document.querySelector("#"+e.element.id+"_zoomOut");n&&e.zoomSettings.zoomFactor<=e.zoomSettings.minZoomFactor?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):n&&(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay"));var s=document.querySelector("#"+e.element.id+"_frame");s&&(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)?s.classList.add("e-disabled"):s&&s.classList.remove("e-disabled")},n.prototype.createLeftToolbarControls=function(){var e=this.parent;if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&document.getElementById(e.element.id+"_toolbar")){var t=document.getElementById(e.element.id+"_toolbar").querySelector(".e-image-upload");if(t){var i=t.getElementsByTagName("input")[0],o=t.getElementsByTagName("button")[0];o.className="e-tbar-btn e-tbtn-txt top-icon",o.innerHTML="",o.appendChild(e.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},n.prototype.fileSelect=function(e,t){var i=e.files[0].type.split("/")[1];"png"===i||"jpg"===i||"jpeg"===i||"svg"===i?this.parent.notify("draw",{prop:"fileSelect",value:{inputElement:e,args:t}}):this.parent.showDialogPopup()},n.prototype.renderAnnotationBtn=function(e){var i=this,o=this.parent,r=!1,n=[],s=["Ellipse","Arrow","Line","Rectangle","Pen","Path","Text"];if(o.toolbar)for(var l=0;l<s.length;l++)if(-1!==o.toolbar.indexOf(s[l])){r=!0;break}(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Pen")>-1)&&n.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Line")>-1)&&n.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Rectangle")>-1)&&n.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Ellipse")>-1)&&n.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Arrow")>-1)&&n.push({text:this.l10n.getConstant("Arrow"),id:"arrow",iconCss:"e-icons e-arrow-right-up"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Path")>-1)&&n.push({text:this.l10n.getConstant("Path"),id:"path",iconCss:"e-icons e-critical-path"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Text")>-1)&&n.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Image")>-1)&&n.push({text:this.l10n.getConstant("Image"),id:"image",iconCss:"e-icons e-image"});var p={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:p}});var h=document.querySelector("#"+o.element.id+"_duplicate"),c=document.querySelector("#"+o.element.id+"_remove"),d=document.querySelector("#"+o.element.id+"_editText");0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&(t.isNullOrUndefined(o.activeObj.pointColl)||o.activeObj.pointColl&&0===o.activeObj.pointColl.length)&&t.isNullOrUndefined(p.freehandDrawSelectedId)?(h&&h.classList.add("e-disabled"),c&&c.classList.add("e-disabled"),d&&d.classList.add("e-disabled")):(h&&h.classList.remove("e-disabled"),c&&c.classList.remove("e-disabled"),d&&d.classList.remove("e-disabled"));var v=e?this.getCurrentShapeIcon(o.activeObj.shape):"e-annotation",u=new a.DropDownButton({items:n,iconCss:"e-icons "+v,cssClass:"e-image-popup",open:function(e){o.currObjType.isFiltered&&(o.okBtn(),o.element.querySelector("#"+i.parent.element.id+"_annotationBtn").click()),t.Browser.isDevice&&(e.element.parentElement.style.top=u.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px"),o.activeObj.shape?document.getElementById(o.activeObj.shape).classList.add("e-selected"):o.togglePen&&document.getElementById("pen").classList.add("e-selected")},select:function(e){o.okBtn();var t,r=!1;void 0!==o.activeObj.shape&&(t=o.activeObj.shape.split("-")),void 0===t&&o.currObjType.isCustomCrop?r=!0:void 0!==t&&"crop"===t[0]&&(r=!0),o.currObjType.isCustomCrop=!1,(r||o.togglePan)&&(o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),i.refreshToolbar("main"));var a={currentFreehandDrawIndex:null};switch(o.notify("freehand-draw",{prop:"getCurrentFreehandDrawIndex",value:{obj:a}}),u.iconCss="e-icons "+i.getCurrentShapeIcon(e.item.id),e.item.id){case"pen":o.notify("draw",{prop:"setTempFreehandCounter",value:{tempFreehandCounter:o.freehandCounter}}),o.notify("draw",{prop:"setTempCurrentFreehandDrawIndex",value:{tempCurrentFreehandDrawIndex:a.currentFreehandDrawIndex}}),i.currentToolbar="pen",o.freeHandDraw(!0);break;case"text":i.currentToolbar="text",o.notify("shape",{prop:"draw-shape-text"});break;case"image":i.currentToolbar="shapes",o.element.querySelector("#"+i.parent.element.id+"_fileUpload").click();break;default:i.currentToolbar="shapes",i.setInitialShapeSettings(e),o.notify("selection",{prop:"annotate",value:{shape:e.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}i.updateToolbarItems()}});u.appendTo("#"+o.element.id+"_annotationBtn")},n.prototype.renderCropBtn=function(){var e=this,i=this.parent,o=[],r=!1,n=["CustomSelection","CircleSelection","SquareSelection","RatioSelection"];if(i.toolbar)for(var s=0;s<n.length;s++)if(-1!==i.toolbar.indexOf(n[s])){r=!0;break}(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("CustomSelection")>-1)&&o.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("CircleSelection")>-1)&&o.push({text:this.l10n.getConstant("Circle"),id:"circle",iconCss:"e-icons e-circle"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("SquareSelection")>-1)&&o.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("RatioSelection")>-1)&&(o.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),o.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),o.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),o.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),o.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"}));var l,p;i.activeObj.shape?(l=this.getCurrentShapeIcon(i.activeObj.shape),p=i.activeObj.shape):i.currSelectionPoint?(l=this.getCurrentShapeIcon(i.currSelectionPoint.shape),p=i.currSelectionPoint.shape):(l=o[0].iconCss,p=o[0].id);var h=new a.DropDownButton({open:function(o){i.togglePan&&e.cancelPan(),t.Browser.isDevice&&(o.element.parentElement.style.top=h.element.getBoundingClientRect().top-o.element.parentElement.offsetHeight+"px"),i.activeObj.shape&&i.activeObj.shape.split("-").length>1&&document.getElementById(i.activeObj.shape.split("-")[1]).classList.add("e-selected"),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},items:o,select:function(t){e.cropSelect(t),h.iconCss="e-icons "+e.getCurrentShapeIcon("crop-"+t.item.id),h.content=i.toPascalCase(t.item.id)},iconCss:"e-icons "+l,cssClass:"e-image-popup",content:i.toPascalCase(p.replace("crop-",""))});h.appendTo("#"+i.element.id+"_cropBtn")},n.prototype.renderTransformBtn=function(){var e=this.parent,i=[];(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("RotateLeft")>-1)&&i.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("RotateRight")>-1)&&i.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("FlipHorizontal")>-1)&&i.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("FlipVertical")>-1)&&i.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var o=new a.DropDownButton({open:function(e){if(t.Browser.isDevice){var i=e.element.parentElement.offsetHeight;e.element.parentElement.style.display="none",e.element.parentElement.style.top=o.element.getBoundingClientRect().top-i+"px",e.element.parentElement.style.display="block"}},items:i,select:e.transformSelect.bind(this),iconCss:"e-icons e-transform",cssClass:"e-image-popup"});o.appendTo("#"+e.element.id+"_transformBtn")},n.prototype.renderSaveBtn=function(){var e=this.parent;if(document.getElementById(e.element.id+"_saveBtn")){new a.DropDownButton({items:[{text:"JPEG",id:"jpeg"},{text:"PNG",id:"png"},{text:"SVG",id:"svg"}],cssClass:"e-caret-hide e-image-popup",iconCss:"e-icons e-save",select:function(t){e.export(t.item.text)}}).appendTo("#"+e.element.id+"_saveBtn")}},n.prototype.getCropTransformToolbarItem=function(){var e=this.parent,i=[];return i.push({id:e.element.id+"_crop",tooltipText:this.l10n.getConstant("CropSelection"),align:"Center",template:'<button id="'+e.element.id+'_cropBtn"></button>'}),i.push({align:"Center",type:"Separator"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateLeft")>-1))&&i.push({id:e.element.id+"_rotateLeft",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateRight")>-1))&&i.push({id:e.element.id+"_rotateRight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),i.length>2&&i.push({align:"Center",type:"Separator"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("HorizontalFlip")>-1))&&i.push({id:e.element.id+"_horizontalFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("VerticalFlip")>-1))&&i.push({id:e.element.id+"_verticalFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"}),t.Browser.isDevice||(i.push({id:e.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:e.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},n.prototype.getShapesToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("fillColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fillColorBtn"></button>'}),e.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&o.push({id:i.element.id+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:"Stroke Width",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderWidthBtn"></button>'}),e.indexOf("start")>-1&&o.push({id:i.element.id+"_start",cssClass:"top-icon e-size",tooltipText:"Start",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_startBtn"></button>'}),e.indexOf("end")>-1&&o.push({id:i.element.id+"_end",cssClass:"top-icon e-size",tooltipText:"End",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_endBtn"></button>'}),e.indexOf("flip")>-1&&(o.push({id:i.element.id+"_rotLeft",prefixIcon:"e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),o.push({id:i.element.id+"_rotRight",prefixIcon:"e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),o.push({id:i.element.id+"_hFlip",prefixIcon:"e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),o.push({id:i.element.id+"_vFlip",prefixIcon:"e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"})),o.push({align:"Center",type:"Separator"}),e.indexOf("transparency")>-1&&o.push({id:i.element.id+"_transparency",prefixIcon:"e-opacity",tooltipText:this.l10n.getConstant("Transparency"),align:"Center"}),o.push({align:"Center",type:"Separator"}),e.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),e.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);if(!t.Browser.isDevice){var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"!==s.shape&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"}))}return o},n.prototype.initCropTransformToolbar=function(){var e=this,i=this.parent,o=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getCropTransformToolbarItem(),s=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=o.concat(s,n,a);var l=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.renderCropBtn(),e.wireZoomBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(l.refreshOverflow(),l.refreshOverflow(),l.refreshOverflow()):(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow()),document.getElementById(i.element.id+"_cropBtn")&&i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:document.getElementById(i.element.id+"_cropBtn").textContent.toLowerCase(),startX:null,startY:null,width:null,height:null}})}});t.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.getCurrentShapeIcon=function(e){var t="";switch(e){case"rectangle":t="e-rectangle";break;case"ellipse":t="e-circle";break;case"line":t="e-line";break;case"arrow":t="e-arrow-right-up";break;case"path":t="e-critical-path";break;case"text":t="e-add-text";break;case"image":t="e-image";break;case"pen":t="e-free-pen";break;case"crop-custom":t="e-custom";break;case"crop-circle":t="e-circle";break;case"crop-square":t="e-square";break;case"crop-3:2":t="e-custom-a";break;case"crop-4:3":t="e-custom-b";break;case"crop-5:4":t="e-custom-c";break;case"crop-7:5":t="e-custom-d";break;case"crop-16:9":t="e-custom-e";break;default:t="e-free-pen"}return t},n.prototype.initShapesToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getShapesToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createShapeColor(e),i.createShapeBtn(e),"arrow"===o.activeObj.shape&&(i.createStartBtn(),i.createEndBtn()),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createShapeColor=function(e){var i=this.parent;if(e.indexOf("fillColor")>-1){i.element.querySelector(".e-template.e-fill").appendChild(i.createElement("input",{id:i.element.id+"_shape_fill"}));var r=new o.ColorPicker({modeSwitcher:!1,noColor:!0,value:"",showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",change:function(e){i.updateFillColor(e.currentValue.hex),""===e.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=e.currentValue.rgba),n.toggle()}},"#"+i.element.id+"_shape_fill"),n=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fillColorBtn");r.inline=!0,i.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(e.indexOf("strokeColor")>-1){i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_shape_stroke"}));var s=new o.ColorPicker({modeSwitcher:!1,noColor:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",change:function(e){i.updateStrokeColor(e.currentValue.hex),l.element.children[0].style.backgroundColor=e.currentValue.rgba,l.toggle()}},"#"+i.element.id+"_shape_stroke"),l=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_borderColorBtn");s.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createShapeBtn=function(e){var i=this.parent,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(e.indexOf("strokeWidth")>-1){var r=document.getElementById(i.element.id+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("XSmall"),n.className="e-shape-stroke-width",r.appendChild(n);var s=new a.DropDownButton({items:o,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=n.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){if(n.textContent=e.item.text,i.updateStrokeWidth(e.item.id),t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});s.appendTo("#"+i.element.id+"_borderWidthBtn")}},n.prototype.createStartBtn=function(){var e=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(e.element.id+"_startBtn"),r=document.createElement("span");t.isNullOrUndefined(e.activeObj.start)&&(e.activeObj.start="none"),r.innerHTML=e.pascalToSplitWords(e.activeObj.start),r.className="e-shape-start",o.appendChild(r);var n=new a.DropDownButton({items:i,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=r.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){r.textContent=t.item.text,e.updateArrow("startArrow",t.item.id)}});n.appendTo("#"+e.element.id+"_startBtn")},n.prototype.createEndBtn=function(){var e=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(e.element.id+"_endBtn"),r=document.createElement("span");t.isNullOrUndefined(e.activeObj.end)&&(e.activeObj.end="arrowSolid"),r.innerHTML=e.pascalToSplitWords(e.activeObj.end),r.className="e-shape-end",o.appendChild(r);var n=new a.DropDownButton({items:i,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=r.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){r.textContent=t.item.text,e.updateArrow("endArrow",t.item.id)}});n.appendTo("#"+e.element.id+"_endBtn")},n.prototype.getTextToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("fontFamily")>-1&&o.push({id:i.element.id+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+i.element.id+'_fontFamilyBtn"></button>'}),e.indexOf("fontSize")>-1&&o.push({id:i.element.id+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+i.element.id+'_fontSizeBtn"></button>'}),e.indexOf("fontColor")>-1&&o.push({cssClass:"top-icon e-text-font-color",id:i.element.id+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fontColorBtn"></button>'}),e.indexOf("bold")>-1&&o.push({id:i.element.id+"_bold",prefixIcon:"e-icons e-bold",cssClass:"top-icon e-bold",tooltipText:this.l10n.getConstant("Bold"),align:"Center"}),e.indexOf("italic")>-1&&o.push({id:i.element.id+"_italic",prefixIcon:"e-icons e-italic",cssClass:"top-icon e-italic",tooltipText:this.l10n.getConstant("Italic"),align:"Center"}),o.push({align:"Center",type:"Separator"}),e.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center",disabled:"block"===i.textArea.style.display}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center",disabled:"block"===i.textArea.style.display}),e.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center",disabled:"block"===i.textArea.style.display});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);return t.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getFontFamilyItems=function(){return t.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"}]},n.prototype.initTextToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getTextToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createTextColor(e),i.createTextBtn(e),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"text"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createTextColor=function(e){var i=this.parent;if(e.indexOf("fontColor")>-1&&i.element.querySelector(".e-template.e-text-font-color")){i.element.querySelector(".e-template.e-text-font-color").appendChild(i.createElement("input",{id:i.element.id+"_text_font"}));var r=new o.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",change:function(e){i.updateFontColor(e.currentValue.hex),n.element.children[0].style.backgroundColor=e.currentValue.rgba,n.toggle()}},"#"+i.element.id+"_text_font"),n=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fontColorBtn");r.inline=!0,i.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createTextBtn=function(e){var i=this.parent;if(e.indexOf("fontFamily")>-1){var o=document.getElementById(i.element.id+"_fontFamilyBtn"),r=document.createElement("span");t.Browser.isDevice?(r.innerHTML="ABC",r.setAttribute("style","font-family: arial")):r.innerHTML="Arial",r.className="e-text-font-family",o&&o.appendChild(r);var n=new a.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(e){e.element.setAttribute("style","font-family:"+e.element.id)},open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var o;o="block"===i.textArea.style.display?i.textArea.style.fontFamily:i.activeObj.textSettings.fontFamily,e.element.querySelector('[id *= "'+o.toLowerCase()+'"]').classList.add("e-selected-btn")},select:function(e){r.textContent=e.item.text,t.Browser.isDevice&&r.setAttribute("style","font-family:"+e.item.id),i.updateFontFamily(e.item.id)}});n.appendTo("#"+i.element.id+"_fontFamilyBtn")}if(e.indexOf("fontSize")>-1){var s=document.getElementById(i.element.id+"_fontSizeBtn"),l=document.createElement("span"),p=i.getFontSizes();l.innerHTML=p[0].text,l.className="e-text-font-size",s.appendChild(l);var h=new a.DropDownButton({cssClass:"e-font-size",items:p,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=h.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.innerHTML;e.element.querySelector('[aria-label *= "'+i+'"]').classList.add("e-selected-btn")},select:function(e){l.textContent=e.item.text,i.updateFontSize(e.item.text)}});h.appendTo("#"+i.element.id+"_fontSizeBtn")}},n.prototype.refreshToolbar=function(e,i,o,r,a){var n=this.parent;if(n.isImageLoaded&&!n.isCropToolbar){var s,l,p={toolbarType:"shapes"===e&&n.activeObj.shape?n.activeObj.shape:e};switch("filter"!==e&&"color"!==e&&(document.getElementById(n.element.id+"_customizeWrapper")&&t.getComponent(document.getElementById(n.element.id+"_customizeWrapper"),"toolbar")&&this.defToolbarItems.length>0&&(t.getComponent(document.getElementById(n.element.id+"_customizeWrapper"),"toolbar").destroy(),document.getElementById(n.element.id+"_customizeWrapper").innerHTML=""),document.getElementById(n.element.id+"_toolbar")&&this.defToolbarItems.length>0&&(t.getComponent(document.getElementById(n.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_toolbar").innerHTML=""),document.getElementById(n.element.id+"_bottomToolbar")&&this.defToolbarItems.length>0&&document.getElementById(n.element.id+"_bottomToolbar").className.indexOf("e-control")>-1&&(t.getComponent(document.getElementById(n.element.id+"_bottomToolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_bottomToolbar").innerHTML="")),this.refreshSlider(),this.isFrameToolbar=!1,n.isCropTab=!1,e){case"main":t.Browser.isDevice?o?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!1,!0,null):t.Browser.isDevice&&!r||this.initMainToolbar(i,t.Browser.isDevice,null),t.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),"line"===n.activeObj.shape||"path"===n.activeObj.shape?p.toolbarItems=["strokeColor","strokeWidth","duplicate","remove"]:"arrow"===n.activeObj.shape?p.toolbarItems=["strokeColor","strokeWidth","start","end","duplicate","remove"]:"image"===n.activeObj.shape?p.toolbarItems=["flip","duplicate","remove","transparency"]:p.toolbarItems=["fillColor","strokeColor","strokeWidth","duplicate","remove"],n.trigger("toolbarUpdating",p),this.initShapesToolbarItem(p.toolbarItems);break;case"text":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),p.toolbarItems=["fontFamily","fontSize","fontColor","bold","italic","duplicate","remove","text"],n.trigger("toolbarUpdating",p),this.initTextToolbarItem(p.toolbarItems);break;case"pen":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),p.toolbarItems=["strokeColor","strokeWidth","remove"],n.trigger("toolbarUpdating",p),this.initPenToolbarItem(p.toolbarItems);break;case"adjustment":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),this.initAdjustmentToolbarItem();break;case"filter":this.updateContextualToolbar(e);break;case"resize":this.initResizeToolbar(),t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0,!0),s=n.element.querySelector("#"+this.parent.element.id+"_aspectratio"),l=n.element.querySelector("#"+this.parent.element.id+"_nonaspectratio"),this.parent.aspectWidth&&this.parent.aspectHeight&&(l?n.notify("transform",{prop:"resize",value:{width:n.aspectWidth,height:n.aspectHeight,isAspectRatio:!1}}):s&&n.notify("transform",{prop:"resize",value:{width:n.aspectWidth,height:null,isAspectRatio:!0}}));break;case"color":this.updateContextualToolbar(e,a);break;case"croptransform":n.allowDownScale=!1,n.isCropTab=!0,t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),n.updateCropTransformItems(),this.initCropTransformToolbar();break;case"frame":this.isFrameToolbar=!0,t.Browser.isDevice?(this.initMainToolbar(!1,!0,!0),this.initMainToolbar(!1,!0,!0,!1,!0)):this.initMainToolbar(!0,null,null,!1,!0),n.element.querySelector("#"+n.element.id+"_"+n.frameObj.type)&&n.element.querySelector("#"+n.element.id+"_"+n.frameObj.type).classList.add("e-selected-btn"),"none"!==n.frameObj.type&&this.updateContextualToolbar(e,a),n.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}})}this.currToolbar=e,this.refreshDropDownBtn(o)}},n.prototype.getAdjustmentToolbarItem=function(){var e=[],i=this.parent,o=!1,r=["Brightness","Contrast","Hue","Saturation","Exposure","Opacity","Blur"];if(i.toolbar)for(var a=0;a<r.length;a++)if(-1!==i.toolbar.indexOf(r[a])){o=!0;break}(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Brightness")>-1)&&e.push({id:i.element.id+"_brightness",prefixIcon:"e-icons e-brightness",cssClass:"top-icon e-brightness",tooltipText:this.l10n.getConstant("Brightness"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Contrast")>-1)&&e.push({id:i.element.id+"_contrast",prefixIcon:"e-icons e-contrast",cssClass:"top-icon e-contrast",tooltipText:this.l10n.getConstant("Contrast"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Hue")>-1)&&e.push({id:i.element.id+"_hue",prefixIcon:"e-icons e-fade",cssClass:"top-icon e-fade",tooltipText:this.l10n.getConstant("Hue"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Saturation")>-1)&&e.push({id:i.element.id+"_saturation",prefixIcon:"e-icons e-saturation",cssClass:"top-icon e-saturation",tooltipText:this.l10n.getConstant("Saturation"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Exposure")>-1)&&e.push({id:i.element.id+"_exposure",prefixIcon:"e-icons e-grain",cssClass:"top-icon e-grain",tooltipText:this.l10n.getConstant("Exposure"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Opacity")>-1)&&e.push({id:i.element.id+"_opacity",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Blur")>-1)&&e.push({id:i.element.id+"_blur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-tint",tooltipText:this.l10n.getConstant("Blur"),align:"Center"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return t.Browser.isDevice||(e.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),e.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),e},n.prototype.getFrameToolbarItem=function(){var e=this.parent,t=[];return t.push({prefixIcon:"e-icons e-copy",id:e.element.id+"_frameColor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("Color"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Color")+'</span><button id="'+e.element.id+'_frameColorBtn"></button>'}),t.push({prefixIcon:"e-icons e-copy",id:e.element.id+"_frameGradient",cssClass:"top-icon e-frame-stroke",tooltipText:this.l10n.getConstant("GradientColor"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("GradientColor")+'</span><button id="'+e.element.id+'_frameGradientColorBtn"></button>'}),t.push({id:e.element.id+"_frameSize",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Size"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Size")+'</span><button id="'+e.element.id+'_frameSizeBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type&&"hook"!==e.frameObj.type||t.push({id:e.element.id+"_frameInset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Inset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Inset")+'</span><button id="'+e.element.id+'_frameInsetBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type||t.push({id:e.element.id+"_frameOffset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Offset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Offset")+'</span><button id="'+e.element.id+'_frameOffsetBtn"></button>'}),"line"===e.frameObj.type&&(t.push({id:e.element.id+"_frameRadius",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Radius"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Radius")+'</span><button id="'+e.element.id+'_frameRadiusBtn"></button>'}),t.push({id:e.element.id+"_frameAmount",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Amount"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Amount")+'</span><button id="'+e.element.id+'_frameAmountBtn"></button>'}),t.push({id:e.element.id+"_frameBorder",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Border"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Border")+'</span><button id="'+e.element.id+'_frameBorderBtn"></button>'})),t},n.prototype.getFilterToolbarItem=function(){var e=[],i=this.parent,o=!1,r=["Default","Chrome","Cold","Warm","Grayscale","Sepia","Invert"];if(i.toolbar)for(var a=0;a<r.length;a++)if(-1!==i.toolbar.indexOf(r[a])){o=!0;break}(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Default")>-1)&&e.push({id:i.element.id+"_default",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Default"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_defaultCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Default")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Chrome")>-1)&&e.push({id:i.element.id+"_chrome",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Chrome"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_chromeCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Chrome")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Cold")>-1)&&e.push({id:i.element.id+"_cold",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Cold"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_coldCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Cold")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Warm")>-1)&&e.push({id:i.element.id+"_warm",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Warm"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_warmCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Warm")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Grayscale")>-1)&&e.push({id:i.element.id+"_grayscale",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Grayscale"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_grayscaleCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Grayscale")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Sepia")>-1)&&e.push({id:i.element.id+"_sepia",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Sepia"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_sepiaCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Sepia")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Invert")>-1)&&e.push({id:i.element.id+"_invert",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Invert"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_invertCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Invert")+"</span></div></div>"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return e},n.prototype.getPenToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&o.push({prefixIcon:"e-icons e-copy",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penStrokeWidth"></button>'}),o.push({align:"Center",type:"Separator"}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);return t.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.initPenToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getPenToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createPenColor(e),i.createPenBtn(e),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"pen"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&(p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createPenColor=function(e){var i=this,r=this.parent;if(e.indexOf("strokeColor")>-1){r.element.querySelector(".e-template.e-pen-stroke-color").appendChild(r.createElement("input",{id:r.element.id+"_pen_stroke"}));var n=new o.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(e){r.updatePenStrokeColor(e.currentValue.hex),i.selFhdColor=e.currentValue.hex,s.element.children[0].style.backgroundColor=e.currentValue.rgba,s.toggle()}},"#"+r.element.id+"_pen_stroke"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=r.element.offsetLeft+"px")},target:".e-pen-color",iconCss:"e-dropdownbtn-preview"},"#"+r.element.id+"_penColorBtn");n.inline=!0;var l={tempFreeHandDrawEditingStyles:null};r.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:l}});var p={freehandSelectedIndex:null};r.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),!t.isNullOrUndefined(p.freehandSelectedIndex)&&p.freehandSelectedIndex>-1?r.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#42a5f5"===this.selFhdColor?l.tempFreeHandDrawEditingStyles.strokeColor:r.pointColl[p.freehandSelectedIndex].strokeColor:r.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createPenBtn=function(e){var i=this.parent,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(e.indexOf("strokeWidth")>-1){var r=document.getElementById(i.element.id+"_penStrokeWidth"),n=document.createElement("span"),s={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:s}}),!t.isNullOrUndefined(s.freehandSelectedIndex)&&s.freehandSelectedIndex>-1?n.innerHTML=this.getPenStroke(i.pointColl[s.freehandSelectedIndex].strokeWidth):n.innerHTML=this.l10n.getConstant("Small"),n.className="e-pen-stroke-width",r.appendChild(n);var l=new a.DropDownButton({items:o,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=n.innerHTML;e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){if(n.textContent=e.item.text,i.updatePenStrokeWidth(e.item.id),t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_penStrokeWidth")}},n.prototype.getPenStroke=function(e){var t="",i={1:this.l10n.getConstant("XSmall"),2:this.l10n.getConstant("Small"),3:this.l10n.getConstant("Medium"),4:this.l10n.getConstant("Large"),5:this.l10n.getConstant("XLarge")};return e>=1&&e<=5&&(t=i[e]),t},n.prototype.initAdjustmentToolbarItem=function(){var e=this,i=this.parent,o=this.getLeftToolbarItem(null),a=this.getRightToolbarItem(),n=this.getAdjustmentToolbarItem(),s=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=o.concat(s,n,a);var l=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireZoomBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow():(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow())}});t.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.initFrameToolbarItem=function(){var e=this,i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),a=document.querySelector("#"+i.element.id+"_frameWrapper");a?a.style.display="block":a=o.appendChild(i.createElement("div",{id:i.element.id+"_frameWrapper",className:"e-frame-wrapper",styles:"position: relative"})),a.appendChild(i.createElement("div",{id:i.element.id+"_customizeWrapper",styles:"position: absolute"}));var n=this.getFrameToolbarItem(),s=new r.Toolbar({width:"100%",items:n,clicked:this.defToolbarClicked.bind(this),created:function(){e.createFrameColor(),e.createFrameSize(),"line"===i.frameObj.type&&e.createFrameRadius(),"line"!==i.frameObj.type&&"inset"!==i.frameObj.type&&"hook"!==i.frameObj.type||e.createFrameInset(),"line"!==i.frameObj.type&&"inset"!==i.frameObj.type||e.createFrameOffset(),"line"===i.frameObj.type&&(e.createFrameAmount(),e.createFrameBorder()),e.createFrameGradientColor(),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(s.refreshOverflow(),s.refreshOverflow(),s.refreshOverflow()):(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&s.refreshOverflow()),i.element.querySelector("#"+i.element.id+"_"+i.frameObj.type).focus()}});s.appendTo("#"+this.parent.element.id+"_customizeWrapper")},n.prototype.createFrameGradientColor=function(){var e,i=this.parent,r={frameChangeEventArgs:null};i.element.querySelector(".e-template.e-frame-stroke").appendChild(i.createElement("input",{id:i.element.id+"_frame_gradient_fill"}));var n=new o.ColorPicker({modeSwitcher:!1,noColor:!0,value:i.frameObj.gradientColor,showButtons:!1,mode:"Palette",cssClass:"e-frame-gradient-fill-color",change:function(o){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.gradientColor,n={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.gradientColor=o.currentValue.hex,i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:r}}),r.frameChangeEventArgs&&!r.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),""===o.currentValue.rgba?s.element.children[0].classList.add("e-nocolor-item"):(s.element.children[0].classList.remove("e-nocolor-item"),s.element.children[0].style.backgroundColor=o.currentValue.rgba)):i.frameObj.gradientColor=a,s.toggle()}},"#"+i.element.id+"_frame_gradient_fill"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-frame-gradient-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_frameGradientColorBtn");n.inline=!0,""===i.frameObj.gradientColor?i.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item"):i.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").style.background=i.frameObj.gradientColor},n.prototype.createFrameColor=function(){var e,i=this.parent,r={frameChangeEventArgs:null};i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_frame_fill"}));var n=new o.ColorPicker({modeSwitcher:!1,value:i.frameObj.color,showButtons:!1,mode:"Palette",cssClass:"e-frame-fill-color",change:function(o){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.color,n={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.color=o.currentValue.hex,i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:r}}),r.frameChangeEventArgs&&!r.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),""===o.currentValue.rgba?s.element.children[0].classList.add("e-nocolor-item"):(s.element.children[0].classList.remove("e-nocolor-item"),s.element.children[0].style.backgroundColor=o.currentValue.rgba)):i.frameObj.color=a,s.toggle()}},"#"+i.element.id+"_frame_fill"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-frame-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_frameColorBtn");n.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background=i.frameObj.color},n.prototype.createFrameSize=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameSizeBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.size.toString()),s.className="e-frame-stroke-width",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.size,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.size=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.size=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameSizeBtn")},n.prototype.createFrameInset=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameInsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.inset.toString()),s.className="e-frame-inset",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.inset,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.inset=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.inset=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameInsetBtn")},n.prototype.createFrameOffset=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameOffsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.offset.toString()),s.className="e-frame-offset",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.offset,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.offset=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.offset=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameOffsetBtn")},n.prototype.createFrameRadius=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("0")},{id:"2",text:this.l10n.getConstant("20")},{id:"3",text:this.l10n.getConstant("40")},{id:"4",text:this.l10n.getConstant("60")},{id:"5",text:this.l10n.getConstant("80")},{id:"6",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameRadiusBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.radius.toString()),s.className="e-frame-radius",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.radius,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.radius=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.radius=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameRadiusBtn")},n.prototype.createFrameAmount=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("1")},{id:"2",text:this.l10n.getConstant("2")},{id:"3",text:this.l10n.getConstant("3")},{id:"4",text:this.l10n.getConstant("4")},{id:"5",text:this.l10n.getConstant("5")}],n=document.getElementById(i.element.id+"_frameAmountBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.amount.toString()),s.className="e-frame-amount",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.amount,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.amount=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.amount=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameAmountBtn")},n.prototype.createFrameBorder=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("Solid")},{id:"2",text:this.l10n.getConstant("Dashed")},{id:"3",text:this.l10n.getConstant("Dotted")}],n=document.getElementById(i.element.id+"_frameBorderBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.toPascalCase(i.frameObj.border)),s.className="e-frame-border",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.border,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.border=r.item.text.toLowerCase(),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.border=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameBorderBtn")},n.prototype.initFilterToolbarItem=function(){var e=this,i=this.parent,o=this.getFilterToolbarItem();document.querySelector("#"+i.element.id+"_contextualToolbar").classList.contains("e-control")&&t.getComponent(document.getElementById(i.element.id+"_contextualToolbar"),"toolbar").destroy();var a=new r.Toolbar({width:"100%",items:o,clicked:this.contextualToolbarClicked.bind(this),created:function(){e.updatePrivateVariables(),e.createCanvasFilter(),""===i.currentFilter&&(i.currentFilter=i.element.id+"_default");var t=document.querySelector("#"+i.element.id+"_headWrapper");t&&(t.style.display="none"),document.getElementById(i.currentFilter+"Canvas")&&document.getElementById(i.currentFilter+"Canvas").parentElement.parentElement.classList.add("e-selected"),e.enableDisableTbrBtn(),a.refreshOverflow()}});a.appendTo("#"+i.element.id+"_contextualToolbar")},n.prototype.drawDashedLine=function(e){e.beginPath(),e.setLineDash([5]),e.rect(10,10,280,130),e.stroke(),e.closePath()},n.prototype.createCanvasFilter=function(){var e=this.parent;i.showSpinner(e.element),e.element.style.opacity="0.5";var t=e.getCurrentCanvasData();this.inMemoryCanvas.width=t.width,this.inMemoryCanvas.height=t.height,this.inMemoryContext.putImageData(t,0,0),this.updateFilterCanvas("_defaultCanvas","default"),this.updateFilterCanvas("_chromeCanvas","chrome"),this.updateFilterCanvas("_coldCanvas","cold"),this.updateFilterCanvas("_warmCanvas","warm"),this.updateFilterCanvas("_grayscaleCanvas","grayscale"),this.updateFilterCanvas("_sepiaCanvas","sepia"),this.updateFilterCanvas("_invertCanvas","invert"),i.hideSpinner(e.element),e.element.style.opacity="1",e.initialAdjustmentValue=this.lowerContext.filter},n.prototype.updateFilterCanvas=function(e,t){var i=this.parent,o=i.element.querySelector("#"+i.element.id+e);if(o){var r=o.getContext("2d");r=o.getContext("2d"),o.style.width="100px",o.style.height="100px",i.notify("filter",{prop:"updateAdj",value:{type:t,value:null,isPreview:!0,ctx:r}}),r.drawImage(this.inMemoryCanvas,0,0,300,150)}},n.prototype.getQuickAccessToolbarItem=function(e){var i=this.parent,o={cancel:!1,toolbarItems:[]},r=[];t.isNullOrUndefined(e)?("image"===i.activeObj.shape&&r.push("Flip"),r.push("Clone"),r.push("Delete"),"text"===i.activeObj.shape&&r.push("EditText"),o.shape=i.toPascalCase(i.activeObj.shape)):e&&(r.push("Delete"),o.shape="Freehand draw"),o.toolbarItems=t.extend([],r,null,!0),i.trigger("quickAccessToolbarOpen",o);var a=[];if(o.cancel)a=[];else for(var n=0;n<o.toolbarItems.length;n++)switch(o.toolbarItems[n]){case"Clone":a.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Left"});break;case"Delete":a.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Left"});break;case"EditText":a.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Left"});break;case"Flip":a.push({id:i.element.id+"_hFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Left"}),a.push({id:i.element.id+"_vFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Left"});break;default:a.push(o.toolbarItems[n])}return a},n.prototype.renderQAT=function(e){var i=this.parent;if(i.activeObj&&i.showQuickAccessToolbar){var o=document.getElementById(i.element.id+"_quickAccessToolbarArea");o&&(this.destroyQuickAccessToolbar(),o.style.display="block");var a=this.getQuickAccessToolbarItem(e);if(0===a.length)return;if(t.isNullOrUndefined(i.quickAccessToolbarTemplate)){new r.Toolbar({items:a,clicked:this.quickAccessToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_quickAccessToolbar")}var n=this.toolbarHeight&&0!==this.toolbarHeight?this.toolbarHeight:o.clientHeight;if(t.isNullOrUndefined(e)){o.style.width="auto",i.activeObj.activePoint.width=Math.abs(i.activeObj.activePoint.width),i.activeObj.activePoint.height=Math.abs(i.activeObj.activePoint.height);var s=i.activeObj.activePoint.startX<i.activeObj.activePoint.endX?i.activeObj.activePoint.startX:i.activeObj.activePoint.endX,l=i.activeObj.activePoint.startY<i.activeObj.activePoint.endY?i.activeObj.activePoint.startY:i.activeObj.activePoint.endY,p=i.activeObj.activePoint.width;if(0!==i.activeObj.rotatedAngle&&"arrow"!==i.activeObj.shape){var h={activePoint:null};i.notify("shape",{prop:"getSquarePointForRotatedShape",onPropertyChange:!1,value:{obj:i.activeObj,object:h}});s=(g=h.activePoint).startX,l=g.startY,p=g.width}else if("path"===i.activeObj.shape){var c=i.getSquarePointForPath(i.activeObj);s=c.startX,l=c.startY,p=c.width}if(o.style.left=s+p/2-25*a.length+"px",parseFloat(o.style.left)+o.clientWidth/2!==s+p/2){var d=s+p/2-(parseFloat(o.style.left)+o.clientWidth/2);o.style.left=parseFloat(o.style.left)+d+"px"}l-(n+n/1.5)<i.img.destTop?o.style.top=i.img.destTop+"px":o.style.top=l-(n+n/1.5)+"px"}else if(e){var v={activePoint:null},u={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:u}}),i.notify("freehand-draw",{prop:"getSqPtFD",value:{idx:u.freehandSelectedIndex,obj:v}});var g=v.activePoint;o.style.width="auto",o.style.left=g.startX+g.width/2-27*a.length+"px",g.startY-(n+n/1.5)<i.img.destTop?o.style.top=i.img.destTop+"px":o.style.top=g.startY-(n+n/1.5)+"px"}}},n.prototype.refreshDropDownBtn=function(e){if(!t.isNullOrUndefined(e)){var i=this.parent,o=document.querySelector("#"+i.element.id+"_annotationBtn");o&&(e?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay")),t.getComponent(o,"dropdown-btn").disabled=e);var r=document.querySelector("#"+i.element.id+"_transformBtn");r&&(e?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")),t.getComponent(r,"dropdown-btn").disabled=e);var a=document.querySelector("#"+i.element.id+"_adjustment");a&&(e?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay")),t.getComponent(a,"btn").disabled=e);var n=document.querySelector("#"+i.element.id+"_filter");n&&(e?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay")),t.getComponent(n,"btn").disabled=e)}},n.prototype.cropSelect=function(e){var i=this.parent;i.isCropTab=!0,t.isNullOrUndefined(i.transform.cropZoomFactor)&&(i.transform.cropZoomFactor=i.transform.zoomFactor,i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}})),i.transform.zoomFactor=i.transform.cropZoomFactor;var o=e.item.id;this.currentToolbar="crop",i.currSelectionPoint=null,i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:o,startX:null,startY:null,width:null,height:null}}),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.quickAccessToolbarClicked=function(e,i){var o=this.parent,r={x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY};if(e.item){var a=void 0,n=void 0,s=null,l={prevActObj:null},p={tempObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:l}}),o.notify("selection",{prop:"getTempActObj",onPropertyChange:!1,value:{obj:p}}),p.tempObj.activePoint.height=Math.abs(p.tempObj.activePoint.height);var h={isNewPath:null},c=void 0;switch(o.notify("draw",{prop:"getNewPath",value:{obj:h}}),e.item.id.replace(o.element.id+"_","").toLowerCase()){case"duplicate":if(!o.element.querySelector("#"+o.element.id+"_duplicate").classList.contains("e-disabled")){if(this.refreshSlider(),h.isNewPath||JSON.stringify(p.tempObj)!==JSON.stringify(o.activeObj)||(s=!0),"image"===(a=t.extend({},o.activeObj,{},!0)).shape&&(n=t.extend([],o.objColl,[],!0),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}})),t.isNullOrUndefined(o.activeObj.currIndex)?o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}}):l.prevActObj?(o.activeObj.currIndex=null,a.currIndex=null,o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}})):o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),h.isNewPath&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),n=t.extend([],o.objColl,[],!0),a.activePoint.startX+=10,a.activePoint.startY-=10,a.activePoint.endX+=10,a.activePoint.endY-=10,"path"===a.shape)for(var d=0;d<a.pointColl.length;d++)a.pointColl[d].x+=10,a.pointColl[d].y-=10;else"image"===a.shape&&(a.imageCanvas=o.createElement("canvas"));o.activeObj=t.extend({},a,{},!0),"image"===o.activeObj.shape&&(o.activeObj.isHorImageFlip&&o.activeObj.isVerImageFlip?(o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:!0}}),o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!0):o.activeObj.isHorImageFlip?(o.activeObj.isHorImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),o.activeObj.isHorImageFlip=!0):o.activeObj.isVerImageFlip?(o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),o.activeObj.isVerImageFlip=!0):o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}})),"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||o.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:o.activeObj}}),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0}}),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}}),this.renderQAT()}break;case"remove":o.element.querySelector("#"+o.element.id+"_remove").classList.contains("e-disabled")||(this.refreshSlider(),o.notify("selection",{prop:"deleteItem",onPropertyChange:!1}));break;case"edittext":o.element.querySelector("#"+o.element.id+"_editText").classList.contains("e-disabled")||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:t.extend({},o.activeObj,{},!0)}}),o.notify("selection",{prop:"setInitialTextEdit",onPropertyChange:!1,value:{bool:!0}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:t.extend({},o.activeObj,{},!0)}}),0!==o.activeObj.rotatedAngle&&(r.x=o.activeObj.horTopLinePointColl[0].x,r.y=o.activeObj.horTopLinePointColl[0].y),o.notify("shape",{prop:"renderTextArea",onPropertyChange:!1,value:{x:r.x,y:r.y,actObj:o.activeObj}}),t.isNullOrUndefined(o.activeObj.currIndex)?o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}):l.prevActObj&&o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"));break;case"rotleft":case"rotright":o.element.querySelector("#"+o.element.id+"_rotLeft").classList.contains("e-disabled")&&o.element.querySelector("#"+o.element.id+"_rotRight").classList.contains("e-disabled")||o.rotateImage(e.item.id.replace(o.element.id+"_","").toLowerCase());break;case"hflip":o.element.querySelector("#"+o.element.id+"_hFlip").classList.contains("e-disabled")||(c=o.activeObj.imageCanvas.getContext("2d"),o.horizontalFlip(c));break;case"vflip":o.element.querySelector("#"+o.element.id+"_vFlip").classList.contains("e-disabled")||(c=o.activeObj.imageCanvas.getContext("2d"),o.verticalFlip(c))}}t.isNullOrUndefined(i)&&o.trigger("quickAccessToolbarItemClick",e)},n.prototype.defToolbarClicked=function(e){var t=this.parent,i=!1,o=!1;if(!this.isFrameToolbar&&t.element.querySelector(".e-contextual-toolbar-wrapper")&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(i=o=!0),t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),e.item){var r=e.item.id.replace(t.element.id+"_","").toLowerCase();if("duplicate"===r||"remove"===r||"edittext"===r||"hflip"===r||"vflip"===r||"rotleft"===r||"rotright"===r)this.quickAccessToolbarClicked(e,!0),t.trigger("toolbarItemClicked",e);else{var a=!1,n=!1,s=document.querySelector("#"+t.element.id+"_adjustment");s&&s.classList.contains("e-disabled")&&(n=!0);var l=document.querySelector("#"+t.element.id+"_filter");l&&l.classList.contains("e-disabled")&&(a=!0),this.enableDisableTbrBtn(),this.performDefTbrClick(r,i,n,a,o),t.trigger("toolbarItemClicked",e)}}},n.prototype.performDefTbrClick=function(e,o,r,a,n){var s,l,p=this.parent,h=p.element.querySelector("#"+p.element.id+"_zoomIn"),c=!1;if(void 0!==p.activeObj.shape&&(l=p.activeObj.shape.split("-")),void 0===l&&p.currObjType.isCustomCrop?c=!0:void 0!==l&&"crop"===l[0]&&(c=!0),!p.disabled)switch(e){case"pan":p.currObjType.isCustomCrop=p.currObjType.isFiltered=!1,p.currObjType.isUndoAction&&p.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),c&&(p.currObjType.isCustomCrop=!1,p.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,p.upperCanvas.width,p.upperCanvas.height),this.refreshToolbar("main")),p.togglePan?(this.cancelPan(),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!0}}),"pen"===this.currentToolbar&&p.freehandDraw(!0)):((s=p.element.querySelector(".e-img-pan .e-btn"))&&s.classList.add("e-selected-btn"),p.pan(!0),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!1}})),h&&p.zoomSettings.zoomFactor>=p.zoomSettings.maxZoomFactor?(h.classList.add("e-disabled"),h.parentElement.classList.add("e-overlay")):h&&(h.classList.remove("e-disabled"),h.parentElement.classList.remove("e-overlay")),this.refreshToolbar("main");break;case"cancel":p.notify("draw",{prop:"performCancel",value:{isContextualToolbar:o}});break;case"ok":p.okBtn(),this.refreshDropDownBtn(!1),this.currentToolbar="main";break;case"crop":p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"reset":p.reset(),this.imageHeight=null,this.imageWidth=null,this.parent.aspectHeight=null,this.parent.aspectWidth=null,this.isAspectRatio=!0,this.currentToolbar="main";break;case"undo":p.notify("undo-redo",{prop:"call-undo"});break;case"redo":p.notify("undo-redo",{prop:"call-redo"});break;case"aspectratio":(!p.isCircleCrop&&t.isNullOrUndefined(p.currSelectionPoint)||p.currSelectionPoint&&"crop-circle"!==p.currSelectionPoint.shape)&&(p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize"));break;case"nonaspectratio":p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize");break;case"resize":p.currObjType.isFiltered&&p.okBtn(),this.resizeClick();break;case"adjustment":r||(p.currObjType.isFiltered&&p.okBtn(),this.refreshToolbar("adjustment"),p.setTempFilterProperties(),this.openSlider("brightness"));break;case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":this.openSlider(e);break;case"filter":a||(i.showSpinner(p.element),this.refreshToolbar("filter"),p.setTempFilterProperties(),i.hideSpinner(p.element));break;case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":p.currObjType.isFiltered=!0,p.notify("filter",{prop:"applyImageFilter",value:{option:e}});break;case"upload":n&&p.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide");break;case"bold":p.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}):p.activeObj.textSettings.bold&&!p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):!p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):p.activeObj.textSettings.bold||p.activeObj.textSettings.italic||p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}),p.element.querySelector("#"+p.element.id+"_bold").classList.contains("e-selected-btn")?p.element.querySelector("#"+p.element.id+"_bold").classList.remove("e-selected-btn"):p.element.querySelector("#"+p.element.id+"_bold").classList.add("e-selected-btn");break;case"italic":p.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}):p.activeObj.textSettings.bold&&!p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):!p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):p.activeObj.textSettings.bold||p.activeObj.textSettings.italic||p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}),p.element.querySelector("#"+p.element.id+"_italic").classList.contains("e-selected-btn")?p.element.querySelector("#"+p.element.id+"_italic").classList.remove("e-selected-btn"):p.element.querySelector("#"+p.element.id+"_italic").classList.add("e-selected-btn");break;case"croptransform":p.currObjType.isFiltered&&p.okBtn(),this.refreshToolbar("croptransform");break;case"rotateleft":case"rotateright":case"horizontalflip":case"verticalflip":p.transformSelect(e),p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"save":if(p.element.querySelector("#"+p.element.id+"_saveBtn").classList.contains("e-hide")){p.element.querySelector("#"+p.element.id+"_saveBtn").classList.remove("e-hide");break}p.okBtn(),p.element.querySelector("#"+p.element.id+"_saveBtn").classList.add("e-hide"),p.element.querySelector("#"+p.element.id+"_saveBtn").click();break;case"transparency":this.updateContextualToolbar("transparency","transparency");break;case"frame":this.frameToolbarClick();break;case"none":case"mat":case"bevel":case"line":case"inset":case"hook":this.unselectFrameBtn(),p.element.querySelector("#"+p.element.id+"_"+e)&&p.element.querySelector("#"+p.element.id+"_"+e).classList.add("e-selected-btn"),p.frameObj.type=e,p.frameObj.size=20,p.frameObj.inset=20,p.frameObj.radius=0,p.frameObj.amount=1,p.frameObj.offset="inset"===e?60:20,this.refreshToolbar("frame"),p.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}})}},n.prototype.frameToolbarClick=function(){var e,i,o,r=this.parent,a=document.querySelector("#"+r.element.id+"_frame");r.currObjType.isFiltered&&r.okBtn(),a&&!a.classList.contains("e-disabled")&&(e=r.transform.zoomFactor,r.frameDestPoints=t.extend({},r.img,{},!0),t.isNullOrUndefined(r.cxtTbarHeight)&&(i=t.extend({},r.frameObj,{},!0),o=t.extend({},r.tempFrameObj,{},!0),this.callFrameToolbar(),r.frameObj.type="mat",this.callFrameToolbar(),r.cxtTbarHeight=r.element.querySelector("#"+r.element.id+"_customizeWrapper").clientHeight,r.frameObj=i,r.tempFrameObj=o),this.zoomToFrameRange(),r.tempFrameZoomLevel=e,t.Browser.isDevice?r.img.destTop-=r.cxtTbarHeight/2:r.img.destTop+=r.cxtTbarHeight/2,this.callFrameToolbar())},n.prototype.zoomToFrameRange=function(){var e=this.parent;for(this.isFrameToolbar=!1,e.notify("transform",{prop:"resetZoom",onPropertyChange:!1});!(this.toolbarHeight+e.img.destTop>=this.toolbarHeight+e.cxtTbarHeight);)e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:!0}});this.isFrameToolbar=!0},n.prototype.resizeClick=function(){this.parent.upperCanvas.style.cursor="default",this.parent.notify("transform",{prop:"updateResize",value:{bool:!1}}),this.isAspectRatio?this.isAspectRatio=!1:this.isAspectRatio=!0,this.parent.isResize=!0,this.refreshToolbar("resize")},n.prototype.callFrameToolbar=function(){var e=this.parent;e.notify("draw",{prop:"setTempFrame",value:{frame:e.frameObj.type}}),t.extend(e.tempFrameObj,e.frameObj);var i={appliedUndoRedoColl:[]};if(e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}}),0===i.appliedUndoRedoColl.length){var o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:o.currObj,previousObjColl:o.currObj.objColl,previousPointColl:o.currObj.pointColl,previousSelPointColl:o.currObj.selPointColl,previousCropObj:t.extend({},e.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}this.refreshToolbar("frame")},n.prototype.contextualToolbarClicked=function(e){var t=this.parent,i=t.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");i&&i.classList.remove("e-selected");var o=e.item.id.replace(t.element.id,"").split("_")[1],r={filter:t.toPascalCase(o),cancel:!1};t.trigger("imageFiltering",r),r.cancel||(document.getElementById(e.item.id+"Canvas").parentElement.parentElement.classList.add("e-selected"),t.currObjType.isFiltered=!0,t.notify("filter",{prop:"applyImageFilter",value:{option:o.toLowerCase()}}),t.currentFilter=e.item.id,this.enableDisableTbrBtn())},n.prototype.refreshShapeDrawing=function(){var e=this.parent,t={shape:""};e.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:t}}),""!==t.shape&&(e.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.refreshToolbar("main",!1))},n.prototype.zoomInBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar){if(o.currObjType.isFiltered&&o.okBtn(),this.refreshShapeDrawing(),t.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomIn");t.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}})}},n.prototype.zoomOutBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar){if(o.currObjType.isFiltered&&o.okBtn(),this.refreshShapeDrawing(),t.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomOut");t.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:null}})}},n.prototype.zoomInBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomInBtnClickHandler.bind(this),250)},n.prototype.zoomOutBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomOutBtnClickHandler.bind(this),250)},n.prototype.zoomBtnMouseUpHandler=function(){clearInterval(this.zoomBtnHold),this.zoomBtnHold=0},n.prototype.closeContextualToolbar=function(){var e=this.parent,t=!1;return(e.element.querySelector("#"+e.element.id+"_contextualToolbar")&&!e.element.querySelector("#"+e.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||e.element.querySelector("#"+e.element.id+"_headWrapper")&&!e.element.querySelector("#"+e.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.okBtn(),this.refreshMainToolbar(),t=!0),t},n.prototype.destroyQuickAccessToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_quickAccessToolbar");i&&i.classList.contains("e-control")&&t.getComponent(i,"toolbar").destroy();var o=document.getElementById(e.element.id+"_quickAccessToolbarArea");o&&(o.style.display="none")},n.prototype.renderSlider=function(e){var i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),r=document.querySelector("#"+i.element.id+"_headWrapper"),a=document.querySelector("#"+i.element.id+"_labelWrapper");r?r.style.display="block":(r=o.appendChild(i.createElement("div",{id:i.element.id+"_headWrapper",styles:"position: relative"})),a="transparency"===e?r.appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:t.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 175px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 250px); font-size: 15px; text-transform: capitalize; font-weight: 400;"})):r.appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:t.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;"}))),a.textContent=this.l10n.getConstant(i.toPascalCase(e));var n,s,l,p=r.appendChild(i.createElement("div",{id:i.element.id+"_sliderWrapper",styles:"position: absolute"})),h=i.getCurrAdjustmentValue(e);"brightness"===e||"contrast"===e||"saturation"===e||"exposure"===e?(i.finetuneSettings?"brightness"===e&&i.finetuneSettings.brightness?(n=i.finetuneSettings.brightness.min,s=i.finetuneSettings.brightness.max):"contrast"===e&&i.finetuneSettings.contrast?(n=i.finetuneSettings.contrast.min,s=i.finetuneSettings.contrast.max):"saturation"===e&&i.finetuneSettings.saturation?(n=i.finetuneSettings.saturation.min,s=i.finetuneSettings.saturation.max):"exposure"===e&&i.finetuneSettings.exposure?(n=i.finetuneSettings.exposure.min,s=i.finetuneSettings.exposure.max):(n=-100,s=100):(n=-100,s=100),l=this.createSlider(n,s,h,e)):"hue"===e||"blur"===e||"opacity"===e?(i.finetuneSettings?"hue"===e&&i.finetuneSettings.hue?(n=i.finetuneSettings.hue.min,s=i.finetuneSettings.hue.max):"blur"===e&&i.finetuneSettings.blur?(n=i.finetuneSettings.blur.min,s=i.finetuneSettings.blur.max):"opacity"===e&&i.finetuneSettings.opacity?(n=i.finetuneSettings.opacity.min,s=i.finetuneSettings.opacity.max):(n=0,s=100):(n=0,s=100),l=this.createSlider(n,s,h,e)):"transparency"===e&&(n=0,s=100,l=this.createSlider(n,s,h,e)),l.appendTo("#"+i.element.id+"_sliderWrapper"),p.style.left=(parseFloat(o.style.width)-parseFloat(l.width))/2+"px"},n.prototype.createSlider=function(e,i,r,a){var n=this,s=this.parent;return new o.Slider({value:r,tooltip:{isVisible:!0,placement:"Before",showOn:"Always"},type:"MinRange",min:e,max:i,step:10,width:t.Browser.isDevice?"200px":"300px",cssClass:"e-slider",change:function(e){"transparency"===a?(s.activeObj.imageTransparency=e.value/100,n.upperContext.clearRect(0,0,s.upperCanvas.width,s.upperCanvas.height),s.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})):(s.setCurrAdjustmentValue(a,e.value),n.enableDisableTbrBtn())}})},n.prototype.applyPreviewFilter=function(){var e=this.parent;(document.querySelector("#"+e.element.id+"_sliderWrapper")||e.currObjType.isFiltered)&&(e.initialAdjustmentValue=this.lowerContext.filter,e.canvasFilter=this.lowerContext.filter,e.currObjType.isFiltered=!1)},n.prototype.unselectBtn=function(){for(var e=this.parent,t=0,i=["#"+e.element.id+"_brightness","#"+e.element.id+"_contrast","#"+e.element.id+"_hue","#"+e.element.id+"_saturation","#"+e.element.id+"_opacity","#"+e.element.id+"_blur","#"+e.element.id+"_exposure"];t<i.length;t++){var o=i[t],r=document.querySelector(o);if(r&&r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.openSlider=function(e){this.unselectBtn(),this.parent.currObjType.isFiltered=!0,this.refreshToolbar("color",null,null,null,e),document.getElementById(this.parent.element.id+"_"+e).classList.add("e-selected-btn")},n.prototype.refreshSlider=function(){var e=document.querySelector("#"+this.parent.element.id+"_sliderWrapper"),t=document.querySelector(".e-slider"),i=document.querySelector("#"+this.parent.element.id+"_headWrapper");i&&(i.style.display="none"),e&&t&&(t.ej2_instances[0].destroy(),e.remove())},n.prototype.unselectFrameBtn=function(){for(var e=this.parent,t=0,i=["#"+e.element.id+"_none","#"+e.element.id+"_mat","#"+e.element.id+"_line","#"+e.element.id+"_inset","#"+e.element.id+"_bevel","#"+e.element.id+"_hook"];t<i.length;t++){var o=i[t],r=document.querySelector(o);if(r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.updateToolbarItems=function(){var e=this.parent;if(e.isImageLoaded){var i=e.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),o=e.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),r=e.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),a=e.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),n=e.element.querySelector(".e-shape-stroke-width"),s=e.element.querySelector(".e-text-font-family"),l=e.element.querySelector(".e-text-font-size"),p=e.element.querySelector("#"+e.element.id+"_bold"),h=e.element.querySelector("#"+e.element.id+"_italic");if(t.isNullOrUndefined(e.activeObj.strokeSettings.strokeWidth)&&(e.activeObj.strokeSettings.strokeWidth=2),i&&(""===e.activeObj.strokeSettings.fillColor?i.classList.add("e-nocolor-item"):(i.classList.remove("e-nocolor-item"),i.style.background=e.activeObj.strokeSettings.fillColor),t.getComponent(e.element.id+"_shape_fill","colorpicker").value=e.activeObj.strokeSettings.fillColor+"ff"),o&&(o.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_shape_stroke","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),r&&(r.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_text_font","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),a&&(a.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_pen_stroke","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),s&&(t.Browser.isDevice?s.setAttribute("style","font-family:"+e.activeObj.textSettings.fontFamily.toLowerCase()):s.textContent=e.activeObj.textSettings.fontFamily),l)for(var c=0;c<e.fontSizeColl.length;c++)if(parseInt(e.fontSizeColl[c].text,10)>=Math.round(e.activeObj.textSettings.fontSize)){l.textContent=(c+1).toString();break}if(p&&(e.activeObj.textSettings.bold?p.classList.add("e-selected-btn"):p.classList.remove("e-selected-btn")),h&&(e.activeObj.textSettings.italic?h.classList.add("e-selected-btn"):h.classList.remove("e-selected-btn")),n){var d=Math.round(e.activeObj.strokeSettings.strokeWidth).toString();n.textContent=this.getStrokeWidth(d)}}},n.prototype.getStrokeWidth=function(e){var t;switch(parseInt(e,10)/2){case 1:t=this.l10n.getConstant("XSmall");break;case 2:t=this.l10n.getConstant("Small");break;case 3:t=this.l10n.getConstant("Medium");break;case 4:t=this.l10n.getConstant("Large");break;case 5:t=this.l10n.getConstant("XLarge")}return t},n.prototype.cancelPan=function(){var e=this.parent;e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var t=e.element.querySelector(".e-img-pan .e-btn");t&&t.classList.remove("e-selected-btn"),e.pan(!1)},n.prototype.refreshMainToolbar=function(){"main"!==this.currToolbar&&this.refreshToolbar("main")},n.prototype.destroySubComponents=function(){for(var e=this.parent,i=e.element.querySelectorAll("input.e-control"),o=e.element.querySelectorAll("button.e-control"),r=0,a=i.length;r<a;r++)i[r].classList.contains("e-color-picker")&&(t.getComponent(i[r],"color-picker").destroy(),t.detach(t.select("input#"+i[r].id,e.element)));for(r=0,a=o.length;r<a;r++)o[r].classList.contains("e-dropdown-btn")?(t.getComponent(o[r],"dropdown-btn").destroy(),t.detach(t.select("button#"+o[r].id,e.element))):o[r].classList.contains("e-btn")&&(t.getComponent(o[r],"btn").destroy(),t.detach(t.select("button#"+o[r].id,e.element)))},n.prototype.setInitialShapeSettings=function(e){var t=this.parent;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.currObjType.shape=e.item.id,t.activeObj.shape=t.currObjType.shape.toLowerCase(),t.currObjType.isDragging=t.currObjType.isCustomCrop=!1,t.activeObj.shapeDegree=t.transform.degree,t.activeObj.shapeFlip=t.transform.currFlipState,t.activeObj.textFlip=t.transform.currFlipState,t.activeObj.flipObjColl=[]},n.prototype.getModuleName=function(){return"toolbar-module"},n}();e.Crop=n,e.Draw=s,e.Export=l,e.Filter=p,e.FreehandDrawing=h,e.Selection=c,e.Shape=d,e.Transform=v,e.UndoRedo=u,e.FinetuneSettings=f,e.ZoomSettings=m,e.SelectionSettings=C,e.ImageEditor=y,e.ToolbarModule=j,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-popups"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-navigations"),require("@syncfusion/ej2-splitbuttons")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-popups","@syncfusion/ej2-inputs","@syncfusion/ej2-navigations","@syncfusion/ej2-splitbuttons"],t):t(e.ej={},e.ej2Base,e.ej2Popups,e.ej2Inputs,e.ej2Navigations,e.ej2Splitbuttons)}(this,function(e,t,i,o,r,a){"use strict";var n=function(){function e(e){this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.isInitCrop=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("crop",this.cropping,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("crop",this.cropping),this.parent.off("destroyed",this.destroy)},e.prototype.cropping=function(e){switch(this.updateCropPvtVar(),e.prop){case"cropImg":this.cropImg(e.value.isRotateCrop);break;case"cropCircle":this.cropCircle(e.value.context,e.value.isSave,e.value.isFlip);break;case"setCurrSelPoints":this.setCurrSelPoints(e.value.isSetDimension);break;case"updateRotatePan":this.updateRotatePan();break;case"crop":this.crop(e.value.obj);break;case"calcRatio":this.calcRatio(e.value.obj,e.value.dimension);break;case"isObjInImage":this.isObjInImage(e.value.obj,e.value.object);break;case"getCurrFlipState":this.getCurrFlipState(e.value.panObj);break;case"setPreviousCropCurrentObj":this.prevCropCurrObj=e.value.obj;break;case"setCropDestPoints":this.cropDestPoints=e.value.point;break;case"getTempFlipPanPoint":e.value.obj.point=this.tempFlipPanPoint;break;case"setTempFlipPanPoint":t.isNullOrUndefined(e.value.isAdd)?this.tempFlipPanPoint=e.value.point:(this.tempFlipPanPoint.x+=e.value.point.x,this.tempFlipPanPoint.y+=e.value.point.y);break;case"getPreventScaling":e.value.obj.bool=this.isPreventScaling;break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"crop"},e.prototype.updateCropPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},e.prototype.reset=function(){this.prevCropCurrObj=null,this.croppedDegree=0,this.cropDestPoints={startX:0,startY:0,width:0,height:0},this.tempFlipPanPoint={x:0,y:0},this.isPreventScaling=!1,this.isInitCrop=!1},e.prototype.cropImg=function(e){for(var i=this.parent,o=t.isNullOrUndefined(e),r=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio"),a=i.activeObj.activePoint,n=!1,s=0;s<i.rotateFlipColl.length;s++)90!==i.rotateFlipColl[s]&&-90!==i.rotateFlipColl[s]||(n=!0);if(i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),(o||r)&&(this.croppedDegree=i.transform.degree),o&&0!==i.transform.degree||n){this.updateCropObj();var l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),this.rotateCrop()}else if(o&&""!==i.transform.currFlipState){this.updateCropObj();l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),this.flipCrop()}else{i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}});var p=this.calcRatio();if(o||!e){this.updateCropObj(),i.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1});l={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.notify("transform",{prop:"setCurrDestinationPoint",onPropertyChange:!1,value:{point:l}}),i.currSelectionPoint=t.extend({},i.activeObj,{},!0),this.cropDestPoints={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight}}var h={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:a.width*p.width,height:a.height*p.height,obj:h,isImgShape:null}});var c=h;this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.img.srcLeft=a.startX*p.width-i.img.destLeft*p.width,i.img.srcTop=a.startY*p.height-i.img.destTop*p.height,i.img.srcWidth=a.width*p.width,i.img.srcHeight=a.height*p.height,i.img.destLeft=(i.lowerCanvas.clientWidth-c.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-c.height)/2,i.img.destWidth=c.width,i.img.destHeight=c.height;var d=this.lowerContext.filter;i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none";var v=t.extend({},i.activeObj,{},!0);this.cropObjColl(),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}});s=0;for(var u=i.objColl.length;s<u;s++)this.isObjInImage(i.objColl[s])&&(i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:i.objColl[s].shape,obj:i.objColl[s],canvas:null}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}));i.activeObj=v,this.cropFreehandDrawColl(),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),i.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),null!=i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape?this.cropCircle(this.lowerContext):i.isCircleCrop=!1,this.lowerContext.filter=d,i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currObjType.isCustomCrop=!1,i.pan(!1),i.transform.defaultZoomFactor=0}},e.prototype.updateCropObj=function(){this.parent.afterCropActions=[];var e={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:e}});var i=e.currObj;this.parent.cropObj=t.extend({},i,{},!0)},e.prototype.rotateCrop=function(){var e=this.parent,i=e.activeObj.shape||"";e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.currSelectionPoint=t.extend({},e.activeObj,{},!0),e.objColl.push(e.activeObj),e.activeObj=t.extend({},e.objColl[e.objColl.length-1],{},!0);var o=t.extend({},e.objColl[e.objColl.length-1],{},!0),r=t.extend({},e.currSelectionPoint,{},!0),a={bool:null};e.notify("transform",{prop:"getPreventSelect",onPropertyChange:!1,value:{obj:a}}),e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:!0}});var n=t.extend([],e.rotateFlipColl,[],!0);this.panToSelRangle(!0),this.resetZoom();var s=t.extend([],e.afterCropActions,[],!0);this.revertTransform("initial",n),o=t.extend({},e.objColl[e.objColl.length-1],{},!0),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o}}),e.objColl.pop(),e.transform.degree=0,this.cropImg(!0),this.revertTransform("reverse",n),e.afterCropActions=s,e.currSelectionPoint=r,e.notify("transform",{prop:"setPreventSelect",onPropertyChange:!1,value:{bool:a.bool}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),"crop-circle"===i&&this.cropCircle(this.lowerContext),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})},e.prototype.revertTransform=function(e,t){var i=this.parent,o={isRotate:!1};if("initial"===e)for(var r=t.length-1;r>=0;r--)switch(t[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(t[r])}})}else{r=0;for(var a=i.objColl.length;r<a;r++)i.objColl[r].shapeFlip="";for(r=0;r<i.freehandCounter;r++)i.pointColl[r].shapeFlip="";for(r=0,a=t.length;r<a;r++)switch(t[r]){case 90:i.notify("transform",{prop:"rotate",value:{degree:90,obj:o}});break;case-90:i.notify("transform",{prop:"rotate",value:{degree:-90,obj:o}});break;default:i.notify("transform",{prop:"flipImage",value:{direction:i.toPascalCase(t[r])}})}}},e.prototype.resetZoom=function(){var e=this.parent;if(e.transform.zoomFactor>0){for(var t=e.transform.zoomFactor,i=e.isUndoRedo,o=0;o<10*t;o++)e.isUndoRedo=!0,e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});e.isUndoRedo=i,e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1})}},e.prototype.flipCrop=function(){var e=this.parent;e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),e.panPoint.totalPannedPoint.x+=this.tempFlipPanPoint.x,e.panPoint.totalPannedPoint.y+=this.tempFlipPanPoint.y;var i=e.transform.currFlipState,o={flipColl:null};e.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:o}});var r=o.flipColl;e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:[]}}),e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj),this.resetZoom(),e.currSelectionPoint=t.extend({},e.objColl[e.objColl.length-1],{},!0),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);var a=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1});for(var n=0,s=e.objColl.length;n<s;n++)e.objColl[n].shapeFlip="";for(n=0;n<e.freehandCounter;n++)e.pointColl[n].shapeFlip="";e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.activeObj=t.extend({},e.objColl[e.objColl.length-1],{},!0),e.objColl.pop(),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.cropImg(!0),e.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),this.lowerContext.setTransform(1,0,0,1,0,0),e.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=a,e.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),e.transform.currFlipState=i,e.notify("transform",{prop:"setFlipColl",onPropertyChange:!1,value:{flipColl:r}}),this.lowerContext.filter="none";for(n=0,s=e.objColl.length;n<s;n++)e.objColl[n].shapeFlip="";for(n=0;n<e.freehandCounter;n++)e.pointColl[n].shapeFlip="";e.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:this.getCurrFlipState()}}),e.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:this.getCurrFlipState()}}),e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=a,(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)&&this.cropCircle(this.lowerContext),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),e.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}}),e.notify("draw",{prop:"resetPanPoints",onPropertyChange:!1}),this.tempFlipPanPoint={x:0,y:0}},e.prototype.cropObjColl=function(){var e,t,i,o=this.parent;if(o.objColl.length>0)for(var r=0,a=o.objColl.length;r<a;r++){e=o.objColl[r].activePoint,t=o.activeObj.activePoint,i=o.objColl[r].shape,o.objColl[r].imageRatio={startX:(e.startX-t.startX)/t.width,startY:(e.startY-t.startY)/t.height,endX:(e.endX-t.startX)/t.width,endY:(e.endY-t.startY)/t.height,width:t.width/e.width,height:t.height/e.height};var n=void 0,s=void 0;switch(i){case"text":s=0===(n=0===o.objColl[r].shapeDegree?this.parent.transform.degree:this.parent.transform.degree-o.objColl[r].shapeDegree)||180===Math.abs(n)?e.width:e.height,o.objColl[r].textSettings.fontRatio=s/o.objColl[r].textSettings.fontSize;break;case"line":case"arrow":this.cropPointCollection(r),"arrow"===i&&o.notify("shape",{prop:"updateArrowRatio",onPropertyChange:!1,value:{obj:o.objColl[r]}});break;case"path":this.cropPointCollection(r)}}},e.prototype.cropPointCollection=function(e){var t,i,o,r,a=this.parent,n=a.objColl[e].shape,s=a.activeObj.activePoint;"path"===n?(t=s.startX,i=s.startY,o=s.width,r=s.height):(t=a.img.destLeft,i=a.img.destTop,o=a.img.destWidth,r=a.img.destHeight);for(var l=a.objColl[e],p=0,h=l.pointColl.length;p<h;p++)l.pointColl[p].ratioX=(l.pointColl[p].x-t)/o,l.pointColl[p].ratioY=(l.pointColl[p].y-i)/r},e.prototype.cropFreehandDrawColl=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){e.points=t.extend([],e.pointColl[i].points,[]),e.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var o=e.points.length,r=0;r<o;r++)e.points[r].ratioX=(e.points[r].x-e.activeObj.activePoint.startX)/e.activeObj.activePoint.width,e.points[r].ratioY=(e.points[r].y-e.activeObj.activePoint.startY)/e.activeObj.activePoint.height}e.notify("freehand-draw",{prop:"updateCropPtsForSel",onPropertyChange:!1})},e.prototype.setCurrSelPoints=function(e){var i=this.parent;i.allowDownScale=!1;var o=this.cropDestPoints,r=this.lowerContext.filter;i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImgCanvas.width,i.img.srcHeight=i.baseImgCanvas.height,i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),e&&i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}}),0===this.croppedDegree&&0===i.transform.degree&&i.currSelectionPoint&&"crop-circle"!==i.currSelectionPoint.shape&&"crop-square"!==i.currSelectionPoint.shape&&(i.img.destLeft=o.startX,i.img.destTop=o.startY,i.img.destWidth=o.width,i.img.destHeight=o.height),0===i.transform.degree&&(i.img.destLeft+=i.panPoint.totalPannedInternalPoint.x,i.img.destTop+=i.panPoint.totalPannedInternalPoint.y),i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=r,i.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,context:null,isPreventCircleCrop:!0}});var a=t.extend([],i.objColl,null,!0),n=t.extend([],i.pointColl,null,!0);if(i.objColl=[],i.pointColl=[],i.freehandCounter=0,this.panToSelRangle(),i.objColl=a,i.pointColl=n,i.freehandCounter=i.pointColl.length,i.cropObj.activeObj.shape){var s={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.currSelectionPoint&&i.currSelectionPoint.activePoint&&(i.img.destLeft=i.currSelectionPoint.activePoint.startX,i.img.destTop=i.currSelectionPoint.activePoint.startY,i.img.destWidth=i.currSelectionPoint.activePoint.width,i.img.destHeight=i.currSelectionPoint.activePoint.height),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=s.startX,i.img.destTop=s.startY,i.img.destWidth=s.width,i.img.destHeight=s.height,i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),a=t.extend([],i.objColl,null,!0),n=t.extend([],i.pointColl,null,!0),i.objColl=[],i.pointColl=[],i.freehandCounter=0;var l={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}});var p=l.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.cropObj.filter=this.lowerContext.filter;var h=t.extend({},i.currSelectionPoint,null,!0);i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:null}}),i.activeObj=t.extend({},h,null,!0);var c=t.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.currSelectionPoint=null,i.isCircleCrop=!1,0!==i.transform.degree&&(i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.panPoint.currentPannedPoint={x:0,y:0}),i.objColl=a,i.pointColl=n,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),0===i.transform.degree&&i.notify("transform",{prop:"drawPannImage",onPropertyChange:!1,value:{point:{x:0,y:0}}}),i.activeObj=c,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),this.isInitCrop||0!==i.transform.degree||""===i.cropObj.currFlipState||0===i.cropObj.cropZoom?this.isInitCrop=!1:(this.isInitCrop=!0,i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"croptransform",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}))}else{var d=this.lowerContext.filter;this.lowerContext.filter="none",i.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=d,i.currSelectionPoint=null}},e.prototype.panToSelRangle=function(e){var t=this.parent,i=0!==t.transform.degree?e?-t.cropObj.totalPannedClientPoint.x:t.cropObj.totalPannedClientPoint.x:0,o=0!==t.transform.degree?e?-t.cropObj.totalPannedClientPoint.y:t.cropObj.totalPannedClientPoint.y:0;0!==t.transform.degree&&(t.panPoint.currentPannedPoint={x:i,y:o},t.notify("transform",{prop:"drawPannedImage",value:{xDiff:i,yDiff:o}}),t.panPoint.currentPannedPoint={x:0,y:0})},e.prototype.cropCircle=function(e,i,o){var r=this.parent;o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:r.transform.currFlipState,isReverse:null}});var a=e.filter;e.filter="none",e.globalCompositeOperation="destination-in",e.beginPath();var n=t.isNullOrUndefined(i)?r.img.destLeft+r.img.destWidth/2:e.canvas.width/2,s=t.isNullOrUndefined(i)?r.img.destTop+r.img.destHeight/2:e.canvas.height/2,l=i?e.canvas.width/2:r.img.destWidth/2;e.arc(n,s,l,0,2*Math.PI),e.closePath(),e.fill(),e.restore(),e.globalCompositeOperation="source-over",r.currObjType.isActiveObj=r.isCircleCrop=!0,e.filter=a,o&&""!==r.transform.currFlipState&&r.notify("draw",{prop:"setTransform",onPropertyChange:!1,value:{context:e,value:r.transform.currFlipState,isReverse:null}})},e.prototype.getCurrCropState=function(e,t){var i=this.parent,o="",r=[],a={flipColl:null};if(i.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:a}}),"initial"===e)if(180===Math.abs(i.transform.degree))o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState;else{for(var n=0,s=i.rotateFlipColl.length;n<s;n++)"number"==typeof i.rotateFlipColl[n]?r.push("number"):"string"==typeof i.rotateFlipColl[n]&&r.push("string");r.length>1&&"string"===r[r.length-1]&&"number"===r[r.length-2]?"horizontal"===i.transform.currFlipState?o="vertical":"vertical"===i.transform.currFlipState&&(o="horizontal"):r.length>1&&"number"===r[r.length-1]&&"string"===r[r.length-2]&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState)}else o=this.getCurrFlipState(),!t&&this.isInitialRotate()||-90!==i.transform.degree&&-270!==i.transform.degree||("horizontal"===o?o="vertical":"vertical"===o&&(o="horizontal"));return""===o&&(o=a.flipColl.length>1?this.getCurrFlipState():i.transform.currFlipState),o},e.prototype.isInitialRotate=function(){var e=!1;return this.parent.rotateFlipColl.length>0&&"number"==typeof this.parent.rotateFlipColl[0]&&(e=!0),e},e.prototype.updateRotatePan=function(){var e=this.parent;if(!t.isNullOrUndefined(e.panPoint.currentPannedPoint)){var i="";i=e.rotateFlipColl.length>0&&"number"==typeof e.rotateFlipColl[0]&&e.transform.degree<0?this.getCurrCropState("reverse",!0):this.getCurrFlipState(),e.transform.degree%90==0&&e.transform.degree%180!=0?90===e.transform.degree||-90===e.transform.degree&&("horizontal"===i||"vertical"===i)||-270===e.transform.degree&&(""===i||"verticalHorizontal"===i||"horizontalVertical"===i)?("horizontal"===i||""===i?e.img.destLeft+=e.panPoint.currentPannedPoint.y:e.img.destLeft-=e.panPoint.currentPannedPoint.y,""===i||"vertical"===i?e.img.destTop-=e.panPoint.currentPannedPoint.x:e.img.destTop+=e.panPoint.currentPannedPoint.x):270!==e.transform.degree&&(-270!==e.transform.degree||"horizontal"!==i&&"vertical"!==i)&&(-90!==e.transform.degree||""!==i&&"verticalHorizontal"!==i&&"horizontalVertical"!==i)||(""===i||"horizontal"===i?e.img.destLeft-=e.panPoint.currentPannedPoint.y:e.img.destLeft+=e.panPoint.currentPannedPoint.y,""===i||"vertical"===i?e.img.destTop+=e.panPoint.currentPannedPoint.x:e.img.destTop-=e.panPoint.currentPannedPoint.x):180!==e.transform.degree&&-180!==e.transform.degree||(""===i||"vertical"===i?e.img.destLeft-=e.panPoint.currentPannedPoint.x:e.img.destLeft+=e.panPoint.currentPannedPoint.x,""===i||"horizontal"===i?e.img.destTop-=e.panPoint.currentPannedPoint.y:e.img.destTop+=e.panPoint.currentPannedPoint.y)}},e.prototype.crop=function(e){var i=this,o=this.parent;if(!o.disabled&&o.isImageLoaded){var r={isCropToolbar:o.isCropToolbar};o.currObjType.isUndoAction&&!r.isCropToolbar&&o.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}});var a={cancel:!1,startPoint:{x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY},endPoint:{x:o.activeObj.activePoint.endX,y:o.activeObj.activePoint.endY},preventScaling:!1};!r.isCropToolbar&&t.isBlazor()&&o.events&&!0===o.events.cropping.hasDelegate?"resize-toolbar"==o.currentToolbar?(o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a),this.cropEvent(a,e,r)):o.dotNetRef.invokeMethodAsync("CropEventAsync","OnCrop",a).then(function(t){i.cropEvent(t,e,r)}):(r.isCropToolbar||o.trigger("cropping",a),this.cropEvent(a,e,r))}},e.prototype.cropEvent=function(e,i,o){var r,a=this.parent;if(!e.cancel&&(r=a.activeObj.shape?a.activeObj.shape.split("-"):[],!a.disabled&&a.activeObj.horTopLine&&(a.currObjType.isCustomCrop||r.length>0&&"crop"===r[0]))){i.isCrop=!0;var n=t.extend({},a.cropObj,{},!0),s=t.extend({},this.prevCropCurrObj,{},!0);e.preventScaling?this.isPreventScaling=!0:this.isPreventScaling=!1,this.cropImg(),a.transform.zoomFactor=0,a.setProperties({zoomSettings:{zoomFactor:1}},!0),a.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:a.zoomSettings.zoomFactor}});var l={prevCurrSelectionPoint:this.parent.prevCurrSelectionPoint};s.currSelectionPoint=t.extend({},l.prevCurrSelectionPoint,{},!0),a.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"crop",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:n,previousText:null,currentText:null,previousFilter:null,isCircleCrop:a.isCircleCrop}}),o.isCropToolbar||a.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),a.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:a.cropObj.destPoints.width,height:a.cropObj.destPoints.height}});var p=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),h=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio");!t.isBlazor()&&!o.isCropToolbar&&t.isNullOrUndefined(p)&&t.isNullOrUndefined(h)?a.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}):o.isCropToolbar||"resize-toolbar"===this.parent.currentToolbar||this.parent.updateToolbar(this.parent.element,"imageLoaded")}},e.prototype.calcRatio=function(e,t){var i,o,r=this.parent;return 0===r.transform.degree||r.transform.degree%180==0?(i=(t?t.width:r.baseImgCanvas.width)/r.img.destWidth,o=(t?t.height:r.baseImgCanvas.height)/r.img.destHeight):(i=(t?t.height:r.baseImgCanvas.height)/r.img.destWidth,o=(t?t.width:r.baseImgCanvas.width)/r.img.destHeight),e&&(e.width=i,e.height=o),{width:i,height:o}},e.prototype.isObjInImage=function(e,t){var i=this.parent,o=!1,r=e.activePoint.startX,a=e.activePoint.endX,n=e.activePoint.startY,s=e.activePoint.endY;return(r>=i.img.destLeft&&a<=i.img.destLeft+i.img.destWidth||r<=i.img.destLeft&&a>=i.img.destLeft||r<=i.img.destLeft+i.img.destWidth&&a>=i.img.destLeft+i.img.destWidth||n>=i.img.destTop&&s<=i.img.destTop+i.img.destHeight||n<=i.img.destTop&&s>=i.img.destTop||n<=i.img.destTop+i.img.destHeight&&s>=i.img.destTop+i.img.destHeight)&&(o=!0),t&&(t.isInside=o),o},e.prototype.getCurrFlipState=function(e){var t=this.parent,i={panRegion:""},o={collection:t.rotateFlipColl};t.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:t.rotateFlipColl,isRotateFlipCollection:!0,obj:o}}),t.rotateFlipColl=o.collection;for(var r=0,a=t.rotateFlipColl.length;r<a;r++)t.notify("transform",{prop:"setCurrPanRegion",onPropertyChange:!1,value:{region:i.panRegion,type:t.rotateFlipColl[r],obj:i}});return e&&(e.panRegion=i.panRegion),i.panRegion},e}(),s=function(){function e(e){this.isInitialLoading=!1,this.fileName="",this.isErrorImage=!1,this.isShapeTextInserted=!1,this.isRotateZoom=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempAdjValue="",this.tempFilter="",this.tempUndoRedoStep=0,this.tempFreehandCounter=0,this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.zoomCrop={width:0,height:0},this.isImageEdited=!1,this.isFileChanged=!1,this.isNewPath=!1,this.isResizeSelect=!1,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}},this.tempFrame="none",this.origDim={width:0,height:0},this.isImageApply=!1,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("draw",this.draw),this.parent.off("destroyed",this.destroy)},e.prototype.draw=function(e){switch(this.updatePrivateVariables(),e.prop){case"drawObject":this.drawObject(e.value.canvas,e.value.obj,e.value.isCropRatio,e.value.points,e.value.isPreventDrag,e.value.saveContext,e.value.isPreventSelection);break;case"updateActiveObject":this.updateActiveObject(e.value.actPoint,e.value.obj,e.value.isMouseMove,e.value.x,e.value.y);break;case"clearOuterCanvas":this.clearOuterCanvas(e.value.context);break;case"setDestPoints":this.setDestPoints();break;case"updateCurrTransState":this.updateCurrTransState(e.value.type,e.value.isPreventDestination,e.value.isRotatePan);break;case"currTransState":this.currTransState(e.value.type,e.value.isPreventDestination,e.value.context,e.value.isPreventCircleCrop);break;case"setTransform":this.setTransform(e.value.context,e.value.value,e.value.isReverse);break;case"render-image":this.renderImage(e.value.isMouseWheel,e.value.isPreventClearRect,e.value.isFrame);break;case"draw-image-to-canvas":this.drawImgToCanvas(e.value.dimension);break;case"update-canvas":this.updateCanvas();break;case"performCancel":this.performCancel(e.value.isContextualToolbar);break;case"updateFlipPan":this.updateFlipPan(e.value.tempSelectionObj);break;case"select":this.select(e.value.type,e.value.startX,e.value.startY,e.value.width,e.value.height);break;case"callUpdateCurrTransState":this.callUpdateCurrTransState();break;case"resetPanPoints":this.resetPanPoints();break;case"setClientTransDim":this.setClientTransDim(e.value.isPreventDimension);break;case"redrawImgWithObj":this.redrawImgWithObj();break;case"setCurrentObj":this.setCurrentObj(e.value.obj);break;case"performPointZoom":this.performPointZoom(e.value.x,e.value.y,e.value.type);break;case"open":this.open(e.value.data);break;case"isInitialLoading":this.isInitialLoading=e.value.isInitialLoading;break;case"isInitialLoaded":this.getInitialLoaded(e.value.object);break;case"fileSelect":this.fileSelect(e.value.inputElement,e.value.args);break;case"getFileName":e.value.obj.fileName=this.fileName,e.value.obj.fileType=this.fileType;break;case"getErrorImage":e.value.obj.isErrorImage=this.isErrorImage;break;case"getInitialZoomValue":e.value.obj.initialZoomValue=this.initZoomValue;break;case"setShapeTextInsert":this.isShapeTextInserted=e.value.bool;break;case"resetCurrentSelectionPoint":this.currSelPoint=null;break;case"setRotateZoom":this.isRotateZoom=e.value.isRotateZoom;break;case"setTempStrokeSettings":this.tempStrokeSettings=e.value.tempStrokeSettings;break;case"setTempTextSettings":this.tempTextSettings=e.value.tempTextSettings;break;case"setTempAdjustmentValue":this.tempAdjValue=e.value.tempAdjustmentValue;break;case"getTempAdjustmentValue":e.value.obj.value=this.tempAdjValue;break;case"setTempFilter":this.tempFilter=e.value.tempFilter;break;case"setTempUndoRedoStep":this.tempUndoRedoStep=e.value.tempUndoRedoStep;break;case"setTempFreehandCounter":this.tempFreehandCounter=e.value.tempFreehandCounter;break;case"setTempCurrentFreehandDrawIndex":this.tempCurrFhdIndex=e.value.tempCurrentFreehandDrawIndex;break;case"setTempZoomFactor":this.tempZoomFactor=e.value.tempZoomFactor;break;case"setCancelAction":this.isCancelAction=e.value.bool;break;case"getRotatedFlipCropSelection":e.value.bool.isSelected=this.rotatedFlipCropSel;break;case"getPrevActObj":e.value.obj.prevActObj=this.prevActObj;break;case"setPrevActObj":this.prevActObj=e.value.prevActObj;break;case"setZoomCropWidth":this.zoomCrop.width=e.value.width,this.zoomCrop.height=e.value.height;break;case"setImageEdited":this.isImageEdited=!0;break;case"reset":this.reset();break;case"dlgBtnClick":this.dlgBtnClick();break;case"dlgCloseBtnClick":this.dlgCloseBtnClick();break;case"setNewPath":this.isNewPath=e.value.bool;break;case"getNewPath":e.value.obj.isNewPath=this.isNewPath;break;case"getArrowDimension":e.value.obj.arrowDimension=this.arrowDimension;break;case"setArrowDimension":this.arrowDimension=e.value.arrowDimension;break;case"moveToSelectionRange":this.moveToSelectionRange(e.value.type,e.value.activeObj);break;case"setResizeSelect":this.isResizeSelect=e.value.bool;break;case"applyFrame":this.applyFrame(e.value.ctx,e.value.frame,e.value.preventImg);break;case"getTempFrame":e.value.obj.tempFrame=this.tempFrame;break;case"drawImage":this.drawImage();break;case"setTempFrame":this.tempFrame=e.value.frame;break;case"downScaleImgCanvas":this.downScaleImgCanvas(e.value.ctx,e.value.isImgAnnotation,e.value.isHFlip,e.value.isVFlip);break;case"downScale":this.downScale(e.value.canvas,e.value.width,e.value.height);break;case"resetFrameZoom":this.resetFrameZoom();break;case"triggerFrameChange":e.value.obj.frameChangeEventArgs=this.triggerFrameChange(e.value.prevFrameSettings);break;case"setImageApply":this.isImageApply=e.value.bool}},e.prototype.getModuleName=function(){return"draw"},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),t.isNullOrUndefined(this.tempZoomFactor)&&(this.tempZoomFactor=e.transform.zoomFactor)},e.prototype.reset=function(){this.isInitialLoading=this.isErrorImage=this.isNewPath=this.isResizeSelect=!1,this.isShapeTextInserted=!1,this.tempFrame="none",this.isImageApply=!1,this.initZoomValue=null,this.tempFilter="",this.origDim={width:0,height:0},this.currSelPoint=null,this.isRotateZoom=!1,this.tempAdjValue="",this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.tempUndoRedoStep=this.tempFreehandCounter=this.tempCurrFhdIndex=0,this.tempZoomFactor=null,this.isCancelAction=!1,this.rotatedFlipCropSel=!1,this.prevActObj=null,this.arrowDimension={bar:{width:10,height:32,ratioX:null,ratioY:null},arrow:{width:24,height:24,ratioX:null,ratioY:null},arrowSolid:{width:32,height:32,ratioX:null,ratioY:null},circle:{width:10,height:10,ratioX:null,ratioY:null},square:{width:20,height:20,ratioX:null,ratioY:null}}},e.prototype.drawImage=function(){this.applyFrame(this.lowerContext,this.parent.frameObj.type)},e.prototype.drawObject=function(e,i,o,r,a,n,s){var l=this.parent,p=l.activeObj.activePoint;this.upperContext.clearRect(0,0,l.upperCanvas.width,l.upperCanvas.height);var h;if("original"===e.toLowerCase()?h=this.lowerContext:"duplicate"===e.toLowerCase()?h=this.upperContext:n&&(h=n),!a&&l.activeObj.shape&&this.setDragLimit(),l.currObjType.shape){"crop"===l.currObjType.shape.split("-")[0].toLowerCase()&&o&&this.drawCropRatio()}if(r&&(p.startX=r.startX,p.startY=r.startY,p.endX=r.endX,p.endY=r.endY,p.width=r.width,p.height=r.height),t.isNullOrUndefined(l.activeObj.strokeSettings)){var c={strokeSettings:{}};l.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:c}}),l.activeObj.strokeSettings=c.strokeSettings}if(t.isNullOrUndefined(l.activeObj.strokeSettings.strokeWidth)&&(l.activeObj.strokeSettings.strokeWidth=2),i&&(l.activeObj=t.extend({},i,{},!0)),this.updateActiveObject(),!t.isNullOrUndefined(l.activeObj.activePoint.startX)||!t.isNullOrUndefined(l.activeObj.activePoint.startY)){if(l.currObjType.isText){var d={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:d}}),l.activeObj.keyHistory=d.keyHistory}if("original"!==e.toLowerCase()){var v=!1;l.activeObj.shape&&"crop"===l.activeObj.shape.split("-")[0]&&(v=!0),v&&(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,l.lowerCanvas.width,l.lowerCanvas.height),this.upperContext.clearRect(p.startX,p.startY,p.width,p.height)),!t.isNullOrUndefined(s)||h!==this.lowerContext&&h!==this.upperContext||(this.rotateContext("initial",h),this.drawOuterSelection(h),this.rotateContext("reverse",h))}l.currObjType.isActiveObj=!0;var u={keyHistory:""};l.notify("shape",{prop:"getKeyHistory",onPropertyChange:!1,value:{obj:u}}),i?this.drawShapeObj(e,i.shape,n,s):""!==u.keyHistory&&l.currObjType.isText?this.drawShapeObj(e,"text",n,s):l.activeObj.shape?this.drawShapeObj(e,l.activeObj.shape,n,s):this.drawShapeObj(e,void 0,n,s)}},e.prototype.rotateContext=function(e,i){var o=this.parent,r=t.extend({},o.activeObj.activePoint,{},!0);if("line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape){var a="initial"===e?o.activeObj.rotatedAngle:-o.activeObj.rotatedAngle;i.translate(r.startX+r.width/2,r.startY+r.height/2),i.rotate(a),i.translate(-(r.startX+r.width/2),-(r.startY+r.height/2))}},e.prototype.setDragLimit=function(){var e=this.parent,t=e.activeObj.activePoint;t&&"image"!==e.activeObj.shape&&"line"!==e.activeObj.shape&&0===e.activeObj.rotatedAngle&&(t.startX<e.img.destLeft?(t.startX=e.img.destLeft,t.endX=t.startX+t.width):t.endX>e.img.destLeft+e.img.destWidth&&(t.endX=e.img.destLeft+e.img.destWidth,t.startX=t.endX-t.width),t.startY<e.img.destTop?t.startY=e.img.destTop:t.endY>e.img.destTop+e.img.destHeight&&(t.endY=e.img.destTop+e.img.destHeight,t.startY=t.endY-t.height),e.activeObj=this.updateWidthHeight(e.activeObj))},e.prototype.drawCropRatio=function(){var e,i,o,r,a=this.parent,n=a.activeObj.activePoint;if(a.transform.zoomFactor>0&&this.currSelPoint){var s=t.extend({},a.activeObj,{},!0);this.drawCustomSelection("crop-custom",null,null,null,null),a.transform.degree%90==0&&a.transform.degree%180!=0?r=o=a.activeObj.activePoint.width<a.activeObj.activePoint.height?a.activeObj.activePoint.width:a.activeObj.activePoint.height:(o=a.img.destLeft+a.img.destLeft+a.img.destWidth<=a.lowerCanvas.clientWidth?n.width:a.lowerCanvas.clientWidth-a.img.destLeft,r=a.img.destTop+a.img.destTop+a.img.destHeight<=a.lowerCanvas.clientHeight?n.height:a.lowerCanvas.clientHeight-a.img.destTop),a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),a.activeObj=s,a.currObjType.shape=s.shape,this.upperContext.clearRect(0,0,a.upperCanvas.width,a.upperCanvas.height),a.currObjType.isCustomCrop=!1}else o=a.img.destWidth,r=a.img.destHeight,a.img.destLeft<0&&(o+=a.img.destLeft),a.img.destTop<0&&(r+=a.img.destTop),"crop-square"!==a.currObjType.shape.toLowerCase()&&"crop-circle"!==a.currObjType.shape.toLowerCase()&&(a.img.destLeft+a.img.destWidth>a.lowerCanvas.width&&(o-=a.img.destLeft+a.img.destWidth-a.lowerCanvas.width),a.img.destTop+a.img.destHeight>a.lowerCanvas.height&&(r-=a.img.destTop+a.img.destHeight-a.lowerCanvas.height));switch(a.currObjType.shape.toLowerCase()){case"crop-square":case"crop-circle":a.notify("selection",{prop:"setDragDirection",onPropertyChange:!1,value:{width:o,height:r}}),n=a.activeObj.activePoint,a.lowerCanvas.width<n.endX-n.startX&&(n.startX=7.5,n.endX=a.lowerCanvas.width-7.5),a.lowerCanvas.height<n.endY-n.startY&&(n.startY=7.5,n.endY=a.lowerCanvas.height-7.5),o===a.img.destWidth&&r===a.img.destHeight&&(n.startX+=a.img.destLeft,n.startY+=a.img.destTop,n.endX+=a.img.destLeft,n.endY+=a.img.destTop),a.lowerCanvas.width>a.lowerCanvas.height?(n.height=n.endY-n.startY,n.width=n.height,n.endX=n.startX+n.width):(n.width=n.endX-n.startX,n.height=n.width,n.endY=n.startY+n.height);break;case"crop-3:2":e=3,i=2;break;case"crop-4:3":e=4,i=3;break;case"crop-5:4":e=5,i=4;break;case"crop-7:5":e=7,i=5;break;case"crop-16:9":e=16,i=9}if(void 0!==e&&void 0!==i&&(a.notify("selection",{prop:"calcShapeRatio",onPropertyChange:!1,value:{x:e,y:i,imgWidth:o,imgHeight:r}}),o===a.img.destWidth&&r===a.img.destHeight&&this.updatePoints(),n=a.activeObj.activePoint),n.startX<a.img.destLeft){var l=a.img.destLeft-n.startX+7.5;n.startX+=l,n.endX+=l}if(n.startY<a.img.destTop){l=a.img.destTop-n.startY+7.5;n.startY+=l,n.endY+=l}a.activeObj=this.updateWidthHeight(a.activeObj),this.adjToCenter()},e.prototype.adjToCenter=function(){var e=this.parent,t=e.lowerCanvas.width/2-(e.activeObj.activePoint.endX-e.activeObj.activePoint.width/2),i=e.lowerCanvas.height/2-(e.activeObj.activePoint.endY-e.activeObj.activePoint.height/2);if(e.activeObj.activePoint.startX+=t,e.activeObj.activePoint.endX+=t,e.activeObj.activePoint.startY+=i,e.activeObj.activePoint.endY+=i,e.activeObj.activePoint.startX<(e.img.destLeft>=7.5?e.img.destLeft:7.5)){var o=(e.img.destLeft>=7.5?e.img.destLeft:0)-e.activeObj.activePoint.startX;e.activeObj.activePoint.startX+=o,e.activeObj.activePoint.endX+=o}else if(e.activeObj.activePoint.endX>e.img.destLeft+e.img.destWidth){o=e.activeObj.activePoint.endX-(e.img.destLeft+e.img.destWidth);e.activeObj.activePoint.startX-=o,e.activeObj.activePoint.endX-=o}if(e.activeObj.activePoint.startY<(e.img.destTop>=7.5?e.img.destTop:7.5)){o=(e.img.destTop>=7.5?e.img.destTop:0)-e.activeObj.activePoint.startY;e.activeObj.activePoint.startY+=o,e.activeObj.activePoint.endY+=o}else if(e.activeObj.activePoint.endY>e.img.destTop+e.img.destHeight){o=e.activeObj.activePoint.endY-(e.img.destTop+e.img.destHeight);e.activeObj.activePoint.startY-=o,e.activeObj.activePoint.endY-=o}},e.prototype.updateActiveObject=function(e,i,o,r,a){e=e||t.extend({},this.parent.activeObj.activePoint,{},!0),i=i||t.extend({},this.parent.activeObj,{},!0),e.width=e.endX-e.startX,e.height=e.endY-e.startY,r=r||0,a=a||0;var n=e.width/2,s=e.height/2;i.horTopLine={startX:e.startX+r,startY:e.startY-a,endX:e.endX+r,endY:e.endY+a},i.horBottomLine={startX:e.startX-r,startY:e.endY-a,endX:e.endX-r,endY:e.endY+a},i.verLeftLine={startX:e.startX+r,startY:e.startY-a,endX:e.startX-a,endY:e.endY-a},i.verRightLine={startX:e.endX+r,startY:e.startY+a,endX:e.endX-r,endY:e.endY+a},i.topLeftCircle={startX:e.startX,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.topCenterCircle={startX:e.startX+n,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.topRightCircle={startX:e.endX,startY:e.startY,radius:i.horTopLine.endX?7.5:0},i.centerLeftCircle={startX:e.startX,startY:e.startY+s,radius:i.horTopLine.endX?7.5:0},i.centerRightCircle={startX:e.endX,startY:e.startY+s,radius:i.horTopLine.endX?7.5:0},i.bottomLeftCircle={startX:e.startX,startY:e.endY,radius:i.horTopLine.endX?7.5:0},i.bottomCenterCircle={startX:e.startX+n,startY:e.endY,radius:i.horTopLine.endX?7.5:0},i.bottomRightCircle={startX:e.endX,startY:e.endY,radius:i.horTopLine.endX?7.5:0},0===i.rotatedAngle&&(i.rotationCirclePoint={x:i.bottomCenterCircle.startX,y:i.bottomCenterCircle.startY+25},i.rotationCirclePoint.ratioX=(i.rotationCirclePoint.x-this.parent.img.destLeft)/this.parent.img.destWidth,i.rotationCirclePoint.ratioY=(i.rotationCirclePoint.y-this.parent.img.destTop)/this.parent.img.destHeight),i.activePoint=e,t.isNullOrUndefined(o)&&(this.parent.activeObj=t.extend({},i,{},!0))},e.prototype.drawOuterSelection=function(e,i){var o,r=this.parent,a=r.activeObj.activePoint;e.lineWidth=.5,void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-"));var n=t.extend({},r.activeObj,{},!0);void 0!==r.activeObj.shape&&(o=r.activeObj.shape.split("-")),(void 0===o||"crop"!==o[0])&&void 0!==r.activeObj.shape||i||(this.upperContext.fillStyle="rgb(0, 0, 0, 0.25)",this.upperContext.fillRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.upperContext.clearRect(a.startX,a.startY,a.width,a.height)),e.strokeStyle=r.themeColl[r.theme].primaryColor,e.fillStyle=r.themeColl[r.theme].secondaryColor;var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),"arrow"===r.activeObj.shape||"line"===r.activeObj.shape)e.beginPath(),e.moveTo(a.startX,a.startY),e.lineTo(a.endX,a.endY),e.stroke();else if("path"===r.activeObj.shape){e.beginPath();var l=t.extend({},r.activeObj,{},!0);if(e.moveTo(l.pointColl[0].x,l.pointColl[0].y),l.pointColl.length>1)for(var p=1,h=l.pointColl.length;p<h;p++)a.endX=l.pointColl[p].x,a.endY=l.pointColl[p].y,e.lineTo(a.endX,a.endY);var c={shape:null};r.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:c}}),"path"===c.shape&&(r.activeObj=l),e.lineTo(a.endX,a.endY),e.stroke()}else if(e.beginPath(),e.rect(n.activePoint.startX,n.activePoint.startY,n.activePoint.width,n.activePoint.height),e.stroke(),e.closePath(),r.selectionSettings.showCircle){var d=e.strokeStyle,v=e.fillStyle;e.strokeStyle=r.selectionSettings.strokeColor,e.fillStyle=r.selectionSettings.fillColor,e.lineWidth*=2,e.beginPath(),e.moveTo(n.topLeftCircle.startX,n.topLeftCircle.startY),e.arc(n.topLeftCircle.startX,n.topLeftCircle.startY,n.topLeftCircle.radius,0,2*Math.PI),e.moveTo(n.topRightCircle.startX,n.topRightCircle.startY),e.arc(n.topRightCircle.startX,n.topRightCircle.startY,n.topRightCircle.radius,0,2*Math.PI),e.moveTo(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY),e.arc(n.bottomLeftCircle.startX,n.bottomLeftCircle.startY,n.bottomLeftCircle.radius,0,2*Math.PI),e.moveTo(n.bottomRightCircle.startX,n.bottomRightCircle.startY),e.arc(n.bottomRightCircle.startX,n.bottomRightCircle.startY,n.bottomRightCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),e.lineWidth/=2,e.strokeStyle=d,e.fillStyle=v}if(r.selectionSettings.showCircle&&(void 0===o||"crop"!==o[0])){d=e.strokeStyle,v=e.fillStyle;e.strokeStyle=r.selectionSettings.strokeColor,e.fillStyle=r.selectionSettings.fillColor,"text"===r.activeObj.shape||this.drawCenterCircles(e),e.strokeStyle=d,e.fillStyle=v}n.rotationCircleLine=r.activeObj.rotationCircleLine,r.activeObj=t.extend({},n,{},!0)},e.prototype.drawArrowHead=function(e,t){switch(t?this.parent.activeObj.start:this.parent.activeObj.end){case"arrowSolid":t?this.arrowSolid(e,!0):this.arrowSolid(e,!1);break;case"arrow":t?this.arrow(e,!0):this.arrow(e,!1);break;case"circleSolid":t?this.arrowCircleSolid(e,!0):this.arrowCircleSolid(e,!1);break;case"circle":t?this.arrowCircle(e,!0):this.arrowCircle(e,!1);break;case"bar":t?this.arrowBar(e,!0):this.arrowBar(e,!1);break;case"square":case"squareSolid":t?this.arrowSquareStart(e):this.arrowSquareEnd(e)}},e.prototype.drawShapeObj=function(e,i,o,r){var a=this.parent,n=a.activeObj.activePoint,s=void 0!==i?i:a.currObjType.shape;a.currObjType.shape=s;var l;"original"===e.toLowerCase()?l=this.lowerContext:"duplicate"===e.toLowerCase()?l=this.upperContext:o&&(l=o),"rectangle"!==a.currObjType.shape.toLowerCase()&&"ellipse"!==a.currObjType.shape.toLowerCase()&&"line"!==a.currObjType.shape.toLowerCase()&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&"image"!==a.activeObj.shape||(a.activeObj.shape=a.currObjType.shape),l.strokeStyle=a.activeObj.strokeSettings.strokeColor,l.fillStyle="text"===i||"freehanddraw"===i?a.activeObj.strokeSettings.strokeColor:a.activeObj.strokeSettings.fillColor;var p=n.width/3,h=n.height/3,c=n.endX-n.startX,d=n.endY-n.startY;this.rotateContext("initial",l);var v,u,g=l.fillStyle;switch(a.currObjType.shape.toLowerCase()){case"rectangle":this.drawSquareLines(l),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"ellipse":c=Math.abs(c),d=Math.abs(d),l.beginPath(),l.ellipse(n.startX+c/2,n.startY+d/2,c/2,d/2,0,0,2*Math.PI,!1),""!==a.activeObj.strokeSettings.fillColor&&(l.fillStyle=a.activeObj.strokeSettings.fillColor,l.fill()),l.ellipse(n.startX+c/2,n.startY+d/2,Math.abs(c/2-a.activeObj.strokeSettings.strokeWidth),Math.abs(d/2-a.activeObj.strokeSettings.strokeWidth),0,0,2*Math.PI,!1),l.fillStyle=a.activeObj.strokeSettings.strokeColor,l.fill("evenodd"),l.closePath(),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"crop-circle":l===this.lowerContext&&(l=this.upperContext),this.shapeCircle(l,c,d);break;case"line":this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"arrow":(v=0===a.activeObj.shapeDegree?a.transform.degree:a.transform.degree-a.activeObj.shapeDegree)<0&&(v=360+v),l.fillStyle=l.strokeStyle,t.isNullOrUndefined(a.activeObj.triangleDirection)&&(a.activeObj.triangleDirection="right"),t.isNullOrUndefined(a.activeObj.start)&&(a.activeObj.start="none"),t.isNullOrUndefined(a.activeObj.end)&&(a.activeObj.end="arrowSolid"),this.drawArrowHead(l,!0),this.drawArrowHead(l,!1),"none"===a.activeObj.end&&this.shapeLine(l,n.startX,n.startY,n.endX,n.endY),l.fillStyle=g,t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);break;case"path":if((u=t.extend({},a.activeObj,{},!0)).pointColl.length>1){var b={shape:null};if(a.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:b}}),"path"===b.shape)for(var f={x:0,y:0},m=0,C=u.pointColl.length;m<C;m++)t.isNullOrUndefined(u.pointColl[m+1])?(f.x=u.activePoint.endX,f.y=u.activePoint.endY):(f.x=u.pointColl[m+1].x,f.y=u.pointColl[m+1].y),n.startX=u.pointColl[m].x,n.startY=u.pointColl[m].y,n.endX=f.x,n.endY=f.y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);else for(m=1,C=u.pointColl.length;m<C;m++)n.startX=u.pointColl[m-1].x,n.startY=u.pointColl[m-1].y,n.endX=u.pointColl[m].x,n.endY=u.pointColl[m].y,a.activeObj=this.updateWidthHeight(a.activeObj),this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);a.activeObj=u}else this.shapeLine(l,n.startX,n.startY,n.endX,n.endY);l===this.upperContext&&this.drawOuterSelection(l);break;case"text":this.shapeText(l);break;case"image":this.shapeImage(l),t.isNullOrUndefined(r)&&l===this.upperContext&&this.drawOuterSelection(l);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":l===this.lowerContext&&(l=this.upperContext),this.drawSelection(p,h),a.currObjType.shape="";break;default:this.drawSelection(p,h)}this.rotateContext("reverse",l)},e.prototype.updatePoints=function(){var e=this.parent;e.activeObj.activePoint.startX+=e.img.destLeft,e.activeObj.activePoint.startY+=e.img.destTop,e.activeObj.activePoint.endX+=e.img.destLeft,e.activeObj.activePoint.endY+=e.img.destTop,e.activeObj=this.updateWidthHeight(e.activeObj)},e.prototype.updateWidthHeight=function(e){return e.activePoint.width=e.activePoint.endX-e.activePoint.startX,e.activePoint.height=e.activePoint.endY-e.activePoint.startY,e},e.prototype.drawCenterCircles=function(e){var i=this.parent,o=i.activeObj.activePoint;if(e.lineWidth*=2,e.beginPath(),"arrow"===i.activeObj.shape||"line"===i.activeObj.shape)e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);else if("path"===i.activeObj.shape){var r=t.extend({},i.activeObj,{},!0);if(r.pointColl.length>1)for(var a=1,n=r.pointColl.length;a<n;a++)o.startX=r.pointColl[a-1].x,o.startY=r.pointColl[a-1].y,o.endX=r.pointColl[a].x,o.endY=r.pointColl[a].y,e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI);var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"===s.shape&&(i.activeObj=r),e.moveTo(o.startX,o.startY),e.arc(o.startX,o.startY,i.activeObj.topCenterCircle.radius,0,2*Math.PI),e.moveTo(o.endX,o.endY),e.arc(o.endX,o.endY,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI)}else this.drawRotationArcLine(e),e.lineTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y);e.stroke(),e.fill(),e.closePath(),"arrow"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&(e.beginPath(),e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y),e.arc(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y,i.activeObj.bottomCenterCircle.radius,0,2*Math.PI),e.stroke(),e.fill(),e.closePath()),e.lineWidth/=2},e.prototype.drawRotationArcLine=function(e){var i=this.parent;t.isNullOrUndefined(i.activeObj.rotationCircleLine)&&(i.activeObj.rotationCircleLine=22.5);var o,r=!1,a=!1;if((o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o),i.activeObj.flipObjColl)for(var n=0,s=i.activeObj.flipObjColl.length;n<s;n++)"horizontal"===i.activeObj.flipObjColl[n].toLowerCase()?r=!0:"vertical"===i.activeObj.flipObjColl[n].toLowerCase()&&(a=!0);switch(o){case 0:case 360:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine));break;case 90:case-270:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y));break;case 180:case-180:a?(i.activeObj.rotationCirclePoint={x:i.activeObj.bottomCenterCircle.startX,y:i.activeObj.bottomCenterCircle.startY+i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y-i.activeObj.rotationCircleLine)):(i.activeObj.rotationCirclePoint={x:i.activeObj.topCenterCircle.startX,y:i.activeObj.topCenterCircle.startY-i.activeObj.rotationCircleLine},e.moveTo(i.activeObj.rotationCirclePoint.x,i.activeObj.rotationCirclePoint.y+i.activeObj.rotationCircleLine));break;case 270:case-90:r?(i.activeObj.rotationCirclePoint={x:i.activeObj.centerLeftCircle.startX-i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x+i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y)):(i.activeObj.rotationCirclePoint={x:i.activeObj.centerRightCircle.startX+i.activeObj.rotationCircleLine,y:i.activeObj.centerLeftCircle.startY},e.moveTo(i.activeObj.rotationCirclePoint.x-i.activeObj.rotationCircleLine,i.activeObj.rotationCirclePoint.y))}},e.prototype.drawSquareLines=function(e){var t,i=this.parent,o=i.activeObj.activePoint;void 0!==i.activeObj.shape&&(t=i.activeObj.shape.split("-")),"crop"===t[0]?e.strokeStyle="#fff":e.strokeStyle=i.activeObj.strokeSettings.strokeColor,e.beginPath(),e.rect(o.startX,o.startY,o.width,o.height),""!==i.activeObj.strokeSettings.fillColor&&(e.fillStyle=i.activeObj.strokeSettings.fillColor,e.fill()),e.rect(o.startX+i.activeObj.strokeSettings.strokeWidth,o.startY+i.activeObj.strokeSettings.strokeWidth,o.width-2*i.activeObj.strokeSettings.strokeWidth,o.height-2*i.activeObj.strokeSettings.strokeWidth),e.fillStyle=i.activeObj.strokeSettings.strokeColor,e.fill("evenodd"),e.closePath()},e.prototype.drawSelection=function(e,t){var i=this.parent,o=i.activeObj.activePoint;this.upperContext.strokeStyle=i.themeColl[i.theme].primaryColor,this.upperContext.beginPath(),i.activeObj.horTopInnerLine={startX:o.startX,startY:o.startY+t,endX:o.endX,endY:o.endY+t},i.activeObj.horBottomInnerLine={startX:o.startX,startY:o.startY+2*t,endX:o.endX,endY:o.endY+2*t},i.activeObj.verLeftInnerLine={startX:o.startX+e,startY:o.startY,endX:o.startX+e,endY:o.endY},i.activeObj.verRightInnerLine={startX:o.startX+2*e,startY:o.startY,endX:o.startX+2*e,endY:o.endY},this.upperContext.moveTo(i.activeObj.horTopInnerLine.startX,i.activeObj.horTopInnerLine.startY),this.upperContext.lineTo(i.activeObj.horTopInnerLine.endX,i.activeObj.horTopInnerLine.startY),this.upperContext.moveTo(i.activeObj.horBottomInnerLine.startX,i.activeObj.horBottomInnerLine.startY),this.upperContext.lineTo(i.activeObj.horBottomInnerLine.endX,i.activeObj.horBottomInnerLine.startY),this.upperContext.moveTo(i.activeObj.verLeftInnerLine.startX,i.activeObj.verLeftInnerLine.startY),this.upperContext.lineTo(i.activeObj.verLeftInnerLine.endX,i.activeObj.verLeftInnerLine.endY),this.upperContext.moveTo(i.activeObj.verRightInnerLine.startX,i.activeObj.verRightInnerLine.startY),this.upperContext.lineTo(i.activeObj.verRightInnerLine.endX,i.activeObj.verRightInnerLine.endY),this.upperContext.stroke(),this.upperContext.closePath()},e.prototype.shapeCircle=function(e,t,i){var o=this.parent,r=o.activeObj.activePoint;e.strokeStyle=o.themeColl[o.theme].primaryColor,e.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),e.fillStyle="rgb(0, 0, 0, 0.25)",e.fillRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var a=e.lineWidth;e.lineWidth=2,e.beginPath(),e.ellipse(o.activeObj.horTopLine.startX+t/2,o.activeObj.horTopLine.startY+i/2,t/2,i/2,0,0,2*Math.PI,!1),e.stroke(),e.closePath(),e.save(),e.beginPath(),e.arc((r.endX-r.startX)/2+r.startX,(r.endY-r.startY)/2+r.startY,r.width/2,0,2*Math.PI),e.closePath(),e.clip(),e.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),e.restore(),e.lineWidth=a,this.drawOuterSelection(e,!0),o.currObjType.shape=""},e.prototype.shapeLine=function(e,t,i,o,r){var a=e.lineWidth;e.lineWidth=this.parent.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.moveTo(t,i),e.lineTo(o,r),e.stroke(),e.lineWidth=a},e.prototype.manipulateSaveCtx=function(e,t,i){if(e!==this.lowerContext&&e!==this.upperContext){var o={width:0,height:0};this.parent.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:o,dimension:{width:e.canvas.width,height:e.canvas.height}}});t&&(t*=o.width),i&&(i*=o.height)}return{x:t,y:i}},e.prototype.arrow=function(e,t){var i=this.parent,o=i.activeObj.activePoint;e.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.arrow.width,a=this.arrowDimension.arrow.height,n=this.manipulateSaveCtx(e,r,a);r=n.x+i.activeObj.strokeSettings.strokeWidth,a=n.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.fillStyle=i.activeObj.strokeSettings.strokeColor;var s=Math.atan2(this.dy,this.dx);(t&&("left"===i.activeObj.triangleDirection||"right"===i.activeObj.triangleDirection)&&"arrow"===i.activeObj.start&&"none"===i.activeObj.end||"arrow"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("arrow"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY),t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection?(e.translate(o.endX,o.endY),e.rotate(s),this.shapeLine(e,0,0,-r,a/2),this.shapeLine(e,0,0,-r,-a/2),e.rotate(-s),e.translate(-o.endX,-o.endY)):(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection)&&(e.translate(o.startX,o.startY),e.rotate(s),this.shapeLine(e,0,0,r,a/2),this.shapeLine(e,0,0,r,-a/2),e.rotate(-s),e.translate(-o.startX,-o.startY))},e.prototype.arrowSolid=function(e,t){var i=this.parent,o=i.activeObj.activePoint,r=this.arrowDimension.arrowSolid.width,a=this.arrowDimension.arrowSolid.height,n=this.manipulateSaveCtx(e,r,a);r=n.x+i.activeObj.strokeSettings.strokeWidth,a=n.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var s=Math.atan2(this.dy,this.dx);(t&&"arrowSolid"===i.activeObj.start&&"none"===i.activeObj.end||"arrowSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("arrowSolid"===i.activeObj.end&&"none"===i.activeObj.start||"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY),t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection?(e.translate(o.endX,o.endY),e.rotate(s),e.beginPath(),e.moveTo(i.activeObj.strokeSettings.strokeWidth,0),e.lineTo(a/2-r,a/2),e.lineTo(a/2-r,-a/2),e.closePath(),e.fill(),e.rotate(-s),e.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=s):(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection)&&(e.translate(o.startX,o.startY),e.rotate(s),e.beginPath(),e.moveTo(0-i.activeObj.strokeSettings.strokeWidth,0),e.lineTo(r-a/2,a/2),e.lineTo(r-a/2,-a/2),e.closePath(),e.fill(),e.rotate(-s),e.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=s)},e.prototype.arrowSquareStart=function(e){var t=this.parent,i=t.activeObj.activePoint;("square"===t.activeObj.start&&"none"===t.activeObj.end||"square"===t.activeObj.start&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.start||"squareSolid"===t.activeObj.start&&"circleSolid"===t.activeObj.end)&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.lineWidth=t.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=t.activeObj.strokeSettings.strokeColor;var o=this.arrowDimension.square.width,r=this.arrowDimension.square.height,a=this.manipulateSaveCtx(e,o,r);o=a.x+t.activeObj.strokeSettings.strokeWidth,r=a.y+t.activeObj.strokeSettings.strokeWidth,this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var n=Math.atan2(this.dy,this.dx);"left"===t.activeObj.triangleDirection?(e.translate(i.endX,i.endY),e.rotate(n),"squareSolid"===t.activeObj.start&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.endX,-i.endY),this.squareStartIntersectX1=i.endX-r/2*Math.cos(n),this.squareStartIntersectY1=i.endY-r/2*Math.sin(n),"square"===t.activeObj.start&&"square"!==t.activeObj.end&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===t.activeObj.start&&"circle"===t.activeObj.end&&this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1),"squareSolid"===t.activeObj.start&&"squareSolid"===t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY)):"right"===t.activeObj.triangleDirection&&(e.lineWidth=t.activeObj.strokeSettings.strokeWidth,e.fillStyle=t.activeObj.strokeSettings.strokeColor,"squareSolid"===t.activeObj.start&&"squareSolid"===t.activeObj.end&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.translate(i.startX,i.startY),e.rotate(n),"squareSolid"===t.activeObj.start&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.startX,-i.startY),t.activeObj.rotatedAngle=n,this.squareStartIntersectX1=i.startX+r/2*Math.cos(n),this.squareStartIntersectY1=i.startY+r/2*Math.sin(n),"square"===t.activeObj.start&&"square"!==t.activeObj.end&&"circle"!==t.activeObj.end&&"square"!==t.activeObj.end&&this.shapeLine(e,i.endX,i.endY,this.squareStartIntersectX1,this.squareStartIntersectY1),"square"===t.activeObj.start&&"circle"===t.activeObj.end&&this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},e.prototype.arrowSquareEnd=function(e){var t=this.parent,i=t.activeObj.activePoint,o=this.arrowDimension.square.width,r=this.arrowDimension.square.height,a=this.manipulateSaveCtx(e,o,r);o=a.x+t.activeObj.strokeSettings.strokeWidth,r=a.y+t.activeObj.strokeSettings.strokeWidth,this.dx=i.endX-i.startX,this.dy=i.endY-i.startY;var n=Math.atan2(this.dy,this.dx);e.lineWidth=t.activeObj.strokeSettings.strokeWidth,"right"===t.activeObj.triangleDirection?(e.fillStyle=t.activeObj.strokeSettings.strokeColor,"squareSolid"===t.activeObj.end&&"none"===t.activeObj.start&&this.shapeLine(e,i.startX,i.startY,i.endX,i.endY),e.translate(i.endX,i.endY),e.rotate(n),"squareSolid"===t.activeObj.end&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.endX,-i.endY),t.activeObj.rotatedAngle=n,this.squareEndIntersectX1=i.endX-r/2*Math.cos(n),this.squareEndIntersectY1=i.endY-r/2*Math.sin(n),"square"===t.activeObj.end&&"square"!==t.activeObj.start&&"circle"!==t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,i.startX,i.startY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.activeObj.start&&"square"===t.activeObj.end&&this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1)):"left"===t.activeObj.triangleDirection&&(e.translate(i.startX,i.startY),e.rotate(n),"squareSolid"===t.activeObj.end&&e.fillRect(r/2-o,-r/2,o,r),e.strokeRect(r/2-o,-r/2,o,r),e.rotate(-n),e.translate(-i.startX,-i.startY),t.activeObj.rotatedAngle=n,this.squareEndIntersectX1=i.startX+r/2*Math.cos(n),this.squareEndIntersectY1=i.startY+r/2*Math.sin(n),"square"===t.activeObj.end&&"square"!==t.activeObj.start&&"circle"!==t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,i.endX,i.endY,this.squareEndIntersectX1,this.squareEndIntersectY1):"circle"===t.activeObj.start&&"square"===t.activeObj.end?this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"square"===t.activeObj.start&&"square"===t.activeObj.end&&this.shapeLine(e,this.squareEndIntersectX1,this.squareEndIntersectY1,this.squareStartIntersectX1,this.squareStartIntersectY1))},e.prototype.arrowCircle=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth;var r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.arc(o.endX,o.endY,r,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var a=this.dx*this.dx+this.dy*this.dy;if((c=(h=2*(this.dx*(o.startX-o.endX)+this.dy*(o.startY-o.endY)))*h-4*a*((o.startX-o.endX)*(o.startX-o.endX)+(o.startY-o.endY)*(o.startY-o.endY)-r*r))>=0){e.fillStyle=i.activeObj.strokeSettings.strokeColor;var n=(-h-Math.sqrt(c))/(2*a),s=o.startX+this.dx*n,l=o.startY+this.dy*n;t?(this.startCircleIntersectX1=s,this.startCircleIntersectY1=l,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(e,this.startCircleIntersectX1,this.startCircleIntersectY1,this.endCircleIntersectX1,this.endCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(e,o.startX,o.startY,this.startCircleIntersectX1,this.startCircleIntersectY1),e.stroke(),e.closePath()):(this.endCircleIntersectX1=s,this.endCircleIntersectY1=l,"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(e,o.startX,o.startY,this.endCircleIntersectX1,this.endCircleIntersectY1))}var p=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=p}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth;r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.arc(o.startX,o.startY,r,0,2*Math.PI),e.stroke(),e.closePath(),this.dx=o.startX-o.endX,this.dy=o.startY-o.endY;var h,c;a=this.dx*this.dx+this.dy*this.dy;if((c=(h=2*(this.dx*(o.endX-o.startX)+this.dy*(o.endY-o.startY)))*h-4*a*((o.endX-o.startX)*(o.endX-o.startX)+(o.endY-o.startY)*(o.endY-o.startY)-r*r))>=0){e.fillStyle=i.activeObj.strokeSettings.strokeColor;n=(-h-Math.sqrt(c))/(2*a),s=o.endX+this.dx*n,l=o.endY+this.dy*n;t?(this.startCircleIntersectX1=s,this.startCircleIntersectY1=l,"circle"===i.activeObj.start&&"circle"===i.activeObj.end?this.shapeLine(e,this.endCircleIntersectX1,this.endCircleIntersectY1,this.startCircleIntersectX1,this.startCircleIntersectY1):"circle"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end&&this.shapeLine(e,o.endX,o.endY,this.startCircleIntersectX1,this.startCircleIntersectY1)):(this.endCircleIntersectX1=s,this.endCircleIntersectY1=l,e.beginPath(),e.fill(),e.beginPath(),"circle"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start&&this.shapeLine(e,o.endX,o.endY,this.endCircleIntersectX1,this.endCircleIntersectY1))}p=Math.atan2(this.dy,this.dx);i.activeObj.rotatedAngle=p}},e.prototype.arrowCircleSolid=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.save(),e.beginPath(),e.arc(o.endX,o.endY,r,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"circleSolid"===i.activeObj.start&&"none"===i.activeObj.end||"circleSolid"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"circleSolid"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);r=this.arrowDimension.circle.width;r=this.manipulateSaveCtx(e,r,null).x+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY,e.save(),e.beginPath(),e.arc(o.startX,o.startY,r,0,2*Math.PI),e.stroke(),e.fill(),e.closePath(),i.activeObj.rotatedAngle=Math.atan2(this.dy,this.dx)}},e.prototype.arrowBar=function(e,t){var i=this.parent,o=i.activeObj.activePoint;if(t&&"left"===i.activeObj.triangleDirection||!t&&"right"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&("bar"===i.activeObj.end&&"none"===i.activeObj.start||"bar"===i.activeObj.end&&"circle"!==i.activeObj.start&&"square"!==i.activeObj.start))&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var r=this.arrowDimension.bar.width,a=this.arrowDimension.bar.height;r=(s=this.manipulateSaveCtx(e,r,a)).x+i.activeObj.strokeSettings.strokeWidth,a=s.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;var n=Math.atan2(this.dy,this.dx);e.translate(o.endX,o.endY),e.rotate(n),e.fillRect(a/4-r,-a/2,r,a),e.rotate(-n),e.translate(-o.endX,-o.endY),i.activeObj.rotatedAngle=n}else if(t&&"right"===i.activeObj.triangleDirection||!t&&"left"===i.activeObj.triangleDirection){e.lineWidth=i.activeObj.strokeSettings.strokeWidth,e.beginPath(),e.fillStyle=i.activeObj.strokeSettings.strokeColor,(t&&"bar"===i.activeObj.start&&"none"===i.activeObj.end||"bar"===i.activeObj.start&&"circle"!==i.activeObj.end&&"square"!==i.activeObj.end||!t&&"bar"===i.activeObj.end&&"none"===i.activeObj.start)&&this.shapeLine(e,o.startX,o.startY,o.endX,o.endY);var s;r=this.arrowDimension.bar.width,a=this.arrowDimension.bar.height;r=(s=this.manipulateSaveCtx(e,r,a)).x+i.activeObj.strokeSettings.strokeWidth,a=s.y+i.activeObj.strokeSettings.strokeWidth,this.dx=o.endX-o.startX,this.dy=o.endY-o.startY;n=Math.atan2(this.dy,this.dx);e.translate(o.startX,o.startY),e.rotate(n),e.fillRect(a/4-r,-a/2,r,a),e.rotate(-n),e.translate(-o.startX,-o.startY),i.activeObj.rotatedAngle=n}},e.prototype.shapeImage=function(e){var t=this.parent,i=t.activeObj.imageCanvas.getContext("2d");if(e===this.lowerContext&&this.isImageApply){var o={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.activeObj.imageElement.width,height:t.activeObj.imageElement.height,obj:o,isImgShape:null}}),(t.activeObj.activePoint.width<o.width/5||t.activeObj.activePoint.height<o.height/5)&&(i.clearRect(0,0,t.activeObj.imageCanvas.width,t.activeObj.imageCanvas.height),t.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:i,isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),t.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.notify("selection",{prop:"setImageClarity",onPropertyChange:!1,value:{bool:!1}}),this.isImageApply=!1)}var r={startX:0,startY:0,width:0,height:0};r.width=t.activeObj.activePoint.width,r.height=t.activeObj.activePoint.height,4===t.activeObj.flipObjColl.length&&(t.activeObj.flipObjColl=[],t.activeObj.shapeFlip="");for(var a=0,n=t.activeObj.flipObjColl.length;a<n;a++)"horizontal"===t.activeObj.flipObjColl[a].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),t.activeObj.activePoint=this.updateActPoint("horizontal",e)):"vertical"===t.activeObj.flipObjColl[a].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),t.activeObj.activePoint=this.updateActPoint("vertical",e));r.startX=(t.activeObj.activePoint.width-r.width)/2+t.activeObj.activePoint.startX,r.startY=(t.activeObj.activePoint.height-r.height)/2+t.activeObj.activePoint.startY;var s=e.globalAlpha;e.globalAlpha=t.activeObj.imageTransparency,t.activeObj.shapeDegree!==t.transform.degree?this.rotateImage(e):e.drawImage(t.activeObj.imageCanvas,r.startX,r.startY,r.width,r.height),e.globalAlpha=s;var l=0;for(n=t.activeObj.flipObjColl.length;l<n;l++)"horizontal"===t.activeObj.flipObjColl[l].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),t.activeObj.activePoint=this.updateActPoint("horizontal",e)):"vertical"===t.activeObj.flipObjColl[l].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),t.activeObj.activePoint=this.updateActPoint("vertical",e));t.currObjType.isText=!1},e.prototype.shapeText=function(e){var t=e.filter;e.filter="none";for(var i=this.parent,o=i.activeObj.activePoint,r=i.activeObj.keyHistory.split("\n"),a=((i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize)*r.length-i.activeObj.textSettings.fontSize*r.length)/r.length,n=0;n<r.length;n++){var s=r[n],l=(n+1)*i.activeObj.textSettings.fontSize*.85+n*a;-360===i.transform.degree&&(i.transform.degree=0),0===i.transform.degree||180===i.transform.degree?i.activeObj.textSettings.fontSize>o.height&&(i.activeObj.textSettings.fontSize=o.height-.1*o.height):i.activeObj.textSettings.fontSize>o.width&&(i.activeObj.textSettings.fontSize=o.width-.1*o.width),e.strokeStyle=i.activeObj.strokeSettings.strokeColor,e.fillStyle=i.activeObj.strokeSettings.strokeColor;var p="";i.activeObj.textSettings.bold&&(p="bold "),i.activeObj.textSettings.italic&&(p="italic "),i.activeObj.textSettings.bold&&i.activeObj.textSettings.italic&&(p="italic bold "),e.font=p+i.activeObj.textSettings.fontSize+"px "+i.activeObj.textSettings.fontFamily,4===i.activeObj.flipObjColl.length&&(i.activeObj.flipObjColl=[],i.activeObj.shapeFlip="");for(var h=0,c=i.activeObj.flipObjColl.length;h<c;h++)"horizontal"===i.activeObj.flipObjColl[h].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),o=this.updateActPoint("horizontal",e)):"vertical"===i.activeObj.flipObjColl[h].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),o=this.updateActPoint("vertical",e));i.activeObj.shapeDegree!==i.transform.degree?this.rotateText(e):e.fillText(s,o.startX+.1*i.activeObj.textSettings.fontSize,o.startY+l);var d=0;for(c=i.activeObj.flipObjColl.length;d<c;d++)"horizontal"===i.activeObj.flipObjColl[d].toLowerCase()?(e.translate(e.canvas.width,0),e.scale(-1,1),o=this.updateActPoint("horizontal",e)):"vertical"===i.activeObj.flipObjColl[d].toLowerCase()&&(e.translate(0,e.canvas.height),e.scale(1,-1),o=this.updateActPoint("vertical",e))}e.filter=t,i.currObjType.isText=!1},e.prototype.updateActPoint=function(e,t){var i=this.parent,o=i.activeObj.activePoint;return"horizontal"===e.toLowerCase()?o.startX<=t.canvas.width/2?(o.startX=t.canvas.width/2+(t.canvas.width/2-o.endX),o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):o.startX>=t.canvas.width/2&&(o.startX=t.canvas.width-o.endX,o.endX=o.startX+o.width,this.updateActiveObject(o,i.activeObj)):"vertical"===e.toLowerCase()&&(o.startY<=t.canvas.height/2?(o.startY=t.canvas.height/2+(t.canvas.height/2-o.endY),o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj)):o.startY>=t.canvas.height/2&&(o.startY=t.canvas.height-o.endY,o.endY=o.startY+o.height,this.updateActiveObject(o,i.activeObj))),o},e.prototype.rotateImage=function(e){var t,i=this.parent;-450===(t=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)&&(t=-90),t<0&&(t=360+t);var o={startX:0,startY:0,width:0,height:0};o.width=t%90==0&&t%180!=0?i.activeObj.activePoint.height:i.activeObj.activePoint.width,o.height=t%90==0&&t%180!=0?i.activeObj.activePoint.width:i.activeObj.activePoint.height,o.startX=i.activeObj.activePoint.startX,o.startY=i.activeObj.activePoint.startY;var r=o.startX,a=o.startY;t%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState?t%90==0&&t%180!=0?(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),e.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),t%90==0&&t%270!=0?(a=i.lowerCanvas.width-(i.activeObj.activePoint.startX+i.activeObj.activePoint.width),a+=(i.activeObj.activePoint.width-o.height)/2,r=o.startY):t%270==0&&(r=i.lowerCanvas.height-(i.activeObj.activePoint.startY+i.activeObj.activePoint.height),r+=(i.activeObj.activePoint.height-o.width)/2,a=o.startX),e.drawImage(i.activeObj.imageCanvas,r,a,o.width,o.height),e.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),r=i.lowerCanvas.width-(o.startX+o.width),a=i.lowerCanvas.height-(o.startY+o.height),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),e.drawImage(i.activeObj.imageCanvas,r,a,o.width,o.height),e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):e.drawImage(i.activeObj.imageCanvas,o.startX,o.startY,o.width,o.height),360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},e.prototype.rotateText=function(e){var t,i=this.parent,o=i.activeObj.activePoint.startX,r=i.activeObj.activePoint.startY,a=i.activeObj.activePoint;if(-450===(t=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)&&(t=-90),t<0&&(t=360+t),t%360!=0||-360===i.transform.degree&&""!==i.transform.currFlipState)t%90==0&&t%180!=0?(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),e.translate(-i.lowerCanvas.height/2,-i.lowerCanvas.width/2),t%90==0&&t%270!=0?(r=i.lowerCanvas.width-a.endX+.4*i.activeObj.textSettings.fontSize,o=a.startY):t%270==0&&(o=i.lowerCanvas.height-a.endY,r=a.startX+.4*i.activeObj.textSettings.fontSize),this.textFlipDegree(e,o,r),e.translate(i.lowerCanvas.height/2,i.lowerCanvas.width/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2)):(e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*t),o=i.lowerCanvas.width-a.endX,r=i.lowerCanvas.height-a.endY+.4*i.activeObj.textSettings.fontSize,e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2),this.textFlipDegree(e,o,r),e.translate(i.lowerCanvas.width/2,i.lowerCanvas.height/2),e.rotate(Math.PI/180*-t),e.translate(-i.lowerCanvas.width/2,-i.lowerCanvas.height/2));else{o=a.startX+.15*i.activeObj.textSettings.fontSize,r=a.startY+(a.endY-a.startY);for(var n=i.activeObj.keyHistory.split("\n"),s=0;s<n.length;s++)r=a.startY+(s*i.activeObj.textSettings.fontSize+.25*i.activeObj.textSettings.fontSize),e.fillText(n[s],o,r)}360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},e.prototype.textFlipDegree=function(e,t,i){for(var o=this.parent,r=o.activeObj.keyHistory.split("\n"),a=(o.activeObj.textSettings.fontSize*r.length-o.activeObj.textSettings.fontSize*r.length)/r.length,n=.85*o.activeObj.textSettings.fontSize+a,s=0;s<r.length;s++){var l=r[s];s>0&&(1===s&&(n-=.85*o.activeObj.textSettings.fontSize),n+=o.activeObj.textSettings.fontSize+.15*o.activeObj.textSettings.fontSize),e.fillText(l,t+.15*o.activeObj.textSettings.fontSize,i+n+(s>0?.25*o.activeObj.textSettings.fontSize:.35*-o.activeObj.textSettings.fontSize))}},e.prototype.clearOuterCanvas=function(e){var t=this.parent,i=t.img.destLeft,o=t.img.destTop;if(t.img.destWidth<t.lowerCanvas.width){var r=t.img.destLeft>0?t.img.destLeft:0;e.clearRect(0,0,r,t.lowerCanvas.height),e.clearRect(t.img.destLeft+t.img.destWidth,0,r,t.lowerCanvas.height)}if(t.img.destHeight<t.lowerCanvas.height){var a=t.img.destTop>0?t.img.destTop:0;e.clearRect(0,0,t.lowerCanvas.width,a),e.clearRect(0,t.img.destTop+t.img.destHeight,t.lowerCanvas.width,a)}""!==t.transform.currFlipState&&(t.img.destLeft=i,t.img.destTop=o)},e.prototype.setDestPoints=function(){var e,t=this.parent;if(t.transform.degree%90==0&&t.transform.degree%180!=0){var i={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcHeight,height:t.img.srcWidth,obj:i,isImgShape:null}}),e=i,this.isRotateZoom&&(e.width+=e.width*t.transform.zoomFactor,e.height+=e.height*t.transform.zoomFactor,t.img.destWidth=e.height,t.img.destHeight=e.width),t.img.destLeft=(t.lowerCanvas.clientWidth-e.height)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.width)/2,t.img.destWidth=e.height,t.img.destHeight=e.width}else{i={width:0,height:0};t.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:t.img.srcWidth,height:t.img.srcHeight,obj:i,isImgShape:null}}),e=i,this.isRotateZoom&&(e.width+=e.width*t.transform.zoomFactor,e.height+=e.height*t.transform.zoomFactor,t.img.destWidth=e.width,t.img.destHeight=e.height),t.img.destLeft=(t.lowerCanvas.clientWidth-e.width)/2,t.img.destTop=(t.lowerCanvas.clientHeight-e.height)/2,t.img.destWidth=e.width,t.img.destHeight=e.height}},e.prototype.updateCurrTransState=function(e,i,o){var r=this.parent,a=r.img.destLeft,n=r.img.destTop;"initial"===e&&(this.lowerContext.setTransform(1,0,0,1,0,0),t.isNullOrUndefined(i)&&this.setDestPoints()),r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape?(this.currTransState(e,!0,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n),o&&(r.img.destLeft+=r.panPoint.totalPannedClientPoint.x,r.img.destTop+=r.panPoint.totalPannedClientPoint.y),r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o&&(r.img.destLeft-=r.panPoint.totalPannedClientPoint.x,r.img.destTop-=r.panPoint.totalPannedClientPoint.y)):(this.currTransState(e,null,null,o),0===r.transform.degree&&""===r.transform.currFlipState&&(r.img.destLeft=a,r.img.destTop=n))},e.prototype.currTransState=function(e,i,o,r){var a=this.parent;o=o||this.lowerContext,"initial"===e?this.setTransformColl(o,e):"reverse"===e&&(this.setTransformColl(o,e),this.setClientTransDim(i),(a.isCircleCrop||a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape&&t.isNullOrUndefined(r))&&(r&&(a.img.destLeft+=a.panPoint.totalPannedClientPoint.x,a.img.destTop+=a.panPoint.totalPannedClientPoint.y),a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r&&(a.img.destLeft-=a.panPoint.totalPannedClientPoint.x,a.img.destTop-=a.panPoint.totalPannedClientPoint.y)))},e.prototype.setTransformColl=function(e,t){var i=this.parent;if("initial"===t)for(var o=0,r=i.rotateFlipColl.length;o<r;o++)this.setTransform(e,i.rotateFlipColl[o]);else if("reverse"===t)for(o=i.rotateFlipColl.length-1;o>=0;o--)this.setTransform(e,i.rotateFlipColl[o],!0)},e.prototype.setTransform=function(e,i,o){var r=this.parent;switch(o&&90===i?i=-90:o&&-90===i&&(i=90),"horizontal"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0?i="vertical":"vertical"===i&&r.transform.degree%90==0&&r.transform.degree%180!=0&&(i="horizontal"),r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!0}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!0}}),t.isNullOrUndefined(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height),i){case 90:case-90:e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*i),e.translate(-e.canvas.width/2,-e.canvas.height/2);break;case"horizontal":e.translate(e.canvas.width,0),e.scale(-1,1);break;case"vertical":e.translate(0,e.canvas.height),e.scale(1,-1)}r.notify("transform",{prop:"setReverseRotate",onPropertyChange:!1,value:{bool:!1}}),r.notify("transform",{prop:"setReverseFlip",onPropertyChange:!1,value:{isReverseFlip:!1}})},e.prototype.drawImgToCanvas=function(e){var t=this.parent;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.img.destWidth=e.width,t.img.destHeight=e.height,this.isInitialLoading&&(t.notify("filter",{prop:"initFilter",onPropertyChange:!1}),this.isInitialLoading=!1);var i=this.lowerContext.filter;this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.drawImage(),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.lowerContext.filter=i},e.prototype.renderImage=function(e,i,o){var r=this.parent,a=this.lowerContext.filter;r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),t.isNullOrUndefined(i)&&(this.upperContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height),this.lowerContext.clearRect(0,0,r.lowerCanvas.width,r.lowerCanvas.height)),e?this.setTransformColl(this.lowerContext,"initial"):(0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),this.updateCurrTransState("initial")),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),r.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),e?this.setTransformColl(this.lowerContext,"reverse"):(this.updateCurrTransState("reverse"),this.isRotateZoom=!1),this.lowerContext.filter="none",o?(r.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),r.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):(r.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),r.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})),this.lowerContext.filter=a,this.clearOuterCanvas(this.lowerContext),(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.imageOnLoad=function(e){var o=this,r=this.parent,a=this;r.baseImg.src=e,r.baseImg.onload=function(){if(r.notify("filter",{prop:"update-finetunes",onPropertyChange:!1}),a.lowerContext.drawImage(r.baseImg,0,0,a.parent.lowerCanvas.width,a.parent.lowerCanvas.height),i.hideSpinner(r.element),r.element.style.opacity="1",a.updateBaseImgCanvas(),a.updateCanvas(),r.currObjType.isUndoZoom&&(r.currObjType.isUndoZoom=!1,a.parent.lowerCanvas.style.display="block"),r.isUndoRedo=o.isErrorImage=!1,t.isBlazor())r.updateToolbar(r.element,"imageLoaded","initial"),t.Browser.isDevice&&(r.element.querySelector(".e-bottom-toolbar-area").style.display="block",r.element.querySelector(".e-canvas-wrapper").style.height=r.element.offsetHeight-2*r.toolbarHeight-3+"px");else if(t.Browser.isDevice){r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),r.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1});var e={isApplyBtn:!1,isDevice:t.Browser.isDevice,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:e}),r.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})}else{r.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1});e={isApplyBtn:!1,isDevice:!1,isOkBtn:null};r.notify("toolbar",{prop:"init-main-toolbar",onPropertyChange:!1,value:e})}},r.baseImg.onerror=function(){i.hideSpinner(r.element),a.isErrorImage=!0,a.errorLoading()}},e.prototype.errorLoading=function(){var e=this.parent,i={fileName:null,fileType:null,isValidImage:!1};t.isBlazor()&&e.events&&!0===e.events.fileOpened.hasDelegate?e.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):e.trigger("fileOpened",i)},e.prototype.updateBaseImgCanvas=function(){var e=this.parent;e.baseImgCanvas.width=e.baseImg.width,e.baseImgCanvas.height=e.baseImg.height,e.baseImgCanvas.getContext("2d").drawImage(e.baseImg,0,0)},e.prototype.updateCanvas=function(){var e=this.parent,i={fileName:this.fileName,fileType:this.fileType,isValidImage:!0};e.img.srcWidth=e.baseImgCanvas.width,e.img.srcHeight=e.baseImgCanvas.height;var o={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.img.srcWidth,height:e.img.srcHeight,obj:o,isImgShape:null}});var r=o;e.img.destLeft=(e.lowerCanvas.clientWidth-r.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-r.height)/2,this.drawImgToCanvas(r),this.origDim.width=e.img.destWidth,this.origDim.height=e.img.destHeight,this.zoomCrop.width=e.img.destWidth,this.zoomCrop.height=e.img.destHeight,e.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:e.img.destWidth,height:e.img.destHeight}});var a={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};e.notify("crop",{prop:"setCropDestPoints",onPropertyChange:!1,value:{point:a}});var n=this.lowerContext.filter;this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n,e.img.destWidth>0&&e.img.destHeight>0&&(e.isImageLoaded=!0),e.isUndoRedo&&""!==e.transform.currFlipState&&e.notify("transform",{prop:"flipImage",onPropertyChange:!1,value:{direction:e.toPascalCase(e.transform.currFlipState)}}),e.disabled&&e.element.setAttribute("class","e-disabled"),e.isImageLoaded&&"0.5"!==e.element.style.opacity&&(t.isBlazor()&&e.events&&!0===e.events.fileOpened.hasDelegate?e.dotNetRef.invokeMethodAsync("FileOpenEventAsync","FileOpened",i):e.trigger("fileOpened",i)),(1!==e.zoomSettings.zoomFactor||e.zoomSettings.zoomPoint)&&e.zoom(e.zoomSettings.zoomFactor,e.zoomSettings.zoomPoint),t.isNullOrUndefined(this.initZoomValue)&&(this.initZoomValue=e.zoomSettings.zoomFactor),this.isImageEdited=!1},e.prototype.resetFrameZoom=function(){var e=this.parent;if(!t.isNullOrUndefined(e.tempFrameZoomLevel)){var i=e.tempFrameZoomLevel;e.tempFrameZoomLevel=null,e.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:i,zoomPoint:null,isResize:!0}})}},e.prototype.performCancel=function(e){var i=this.parent;e=e||!1;var o={bool:!1};if(i.allowDownScale=!0,i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),JSON.stringify(i.frameObj)!==JSON.stringify(i.tempFrameObj)&&(t.extend(i.frameObj,i.tempFrameObj),this.renderImage(null,null,!0)),this.resetFrameZoom(),o.bool)i.notify("freehand-draw",{prop:"cancelFhd",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}});else if("block"===i.textArea.style.display)i.textArea.style.display="none",i.textArea.value="",i.textArea.style.transform="",this.prevActObj?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.activeObj.strokeSettings=this.tempStrokeSettings,i.activeObj.textSettings=this.tempTextSettings),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),this.isShapeTextInserted&&i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(!t.isBlazor()&&document.querySelector("#"+i.element.id+"_sliderWrapper")||t.isBlazor()&&!i.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||i.currObjType.isFiltered){this.lowerContext.filter=this.tempAdjValue,i.canvasFilter=this.tempAdjValue,i.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.tempAdjValue}}),i.initialAdjustmentValue=this.tempAdjValue,this.lowerContext.filter.split(" ").length>1&&"1"===this.lowerContext.filter.split(" ")[0].split("(")[1].split(")")[0]&&i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:!1}}),i.currentFilter=this.tempFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.redrawImgWithObj(),i.currObjType.isFiltered=!1;var r={tempAdjustmentLevel:null};i.notify("filter",{prop:"getTempAdjustmentLevel",onPropertyChange:!1,value:{obj:r}}),i.notify("filter",{prop:"setAdjustmentLevel",onPropertyChange:!1,value:{adjustmentLevel:t.extend({},r.tempAdjustmentLevel,{},!0)}}),i.notify("undo-redo",{prop:"setUndoRedoStep",onPropertyChange:!1,value:{step:this.tempUndoRedoStep}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.clearOuterCanvas(this.lowerContext),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}});var a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})}else if(e){a={type:"main",isApplyBtn:null,isCropping:null,isZooming:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:a})}else this.cancelItems(),i.transform.zoomFactor>0?(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(i.togglePan=!1,i.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}));this.isShapeTextInserted=!1,this.isNewPath=!1,t.isBlazor()||(i.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}))},e.prototype.cancelItems=function(){var e,i=this.parent,o=!1,r=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),a=this.parent.element.querySelector("#"+this.parent.element.id+"_nonaspectratio");if(void 0!==i.activeObj.shape&&(e=i.activeObj.shape.split("-")),void 0===e&&i.currObjType.isCustomCrop?o=!0:void 0!==e&&"crop"===e[0]&&(o=!0),o&&i.isCropTab&&(i.isCropTab=!1,i.transform.zoomFactor=i.transform.defaultZoomFactor),i.isResize&&(r||a||"resize-toolbar"==i.currentToolbar)){var n={width:null,height:null};i.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:n}});var s={x:n.width,y:n.height},l=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),p=this.parent.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");if(s&&s.x&&s.y&&!t.isNullOrUndefined(this.parent.aspectWidth))if(l||p&&!p.classList.contains("e-hidden"))i.notify("transform",{prop:"resizeImage",value:{width:i.aspectWidth,height:i.aspectHeight}});else{var h=i.currObjType.isUndoAction;i.currObjType.isUndoAction=!1,i.notify("transform",{prop:"resizeCrop",value:{width:i.aspectWidth,height:i.aspectHeight}}),i.currObjType.isUndoAction=h}var c={prevCropObj:i.prevCropObj},d={prevObj:i.prevObj};this.parent.notify("toolbar",{prop:"getPrevCropObj",onPropertyChange:!1,value:{obj:c}}),this.parent.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:d}}),c.prevCropObj&&d.prevObj&&(l||(i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.cropObj=t.extend({},c.prevCropObj,{},!0),this.setCurrentObj(d.prevObj),i.objColl=d.prevObj.objColl,i.pointColl=d.prevObj.pointColl,i.freehandCounter=i.pointColl.length,i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.parent.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.parent.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.parent.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:d.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),d.prevObj.zoomFactor&&i.setProperties({zoomSettings:{zoomFactor:d.prevObj.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:i.zoomSettings.zoomFactor}})),i.isResize=!1}i.togglePen?this.cancelPen():"text"===i.activeObj.shape?this.cancelText(o):-1!==["rectangle","ellipse","line","arrow","path","image"].indexOf(i.activeObj.shape)?this.cancelShape():o?this.cancelSelection():(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}})),i.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),i.upperCanvas.style.cursor=i.cursor="default",i.currObjType.isCustomCrop=!1,this.tempStrokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null};t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})},e.prototype.cancelPen=function(){var e=this.parent;this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default";var i=t.extend([],e.pointColl,[],!0);e.pointColl={};for(var o=0;o<this.tempFreehandCounter;o++)e.pointColl[o]=i[o];e.freehandCounter=this.tempFreehandCounter,e.notify("freehand-draw",{prop:"setCurrentFreehandDrawIndex",value:{value:this.tempCurrFhdIndex}}),e.activeObj.strokeSettings=this.tempStrokeSettings,e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:e.activeObj.strokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},e.prototype.cancelText=function(e){var i=this.parent;if(i.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:this.tempTextSettings,fontFamily:null,fontSize:null}}),i.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.isNullOrUndefined(i.activeObj.currIndex))i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height);else{var o={appliedUndoRedoColl:[]};i.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:o}});var r=o.appliedUndoRedoColl.length;this.prevActObj&&o.appliedUndoRedoColl[r-1]&&o.appliedUndoRedoColl[r-1].currentObjColl[o.appliedUndoRedoColl[r-1].currentObjColl.length-1].currIndex===this.prevActObj.currIndex?(i.activeObj=this.prevActObj,this.prevActObj=null):(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height)),i.activeObj.shape&&"Enter Text"===i.activeObj.keyHistory?(i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"draw-shape-text"}),i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):i.activeObj.shape&&(i.notify("shape",{prop:"redraw-text"}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.activeObj}}),e||void 0===i.activeObj.topLeftCircle||i.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),i.clearSelection())}t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.tempTextSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1}},e.prototype.cancelShape=function(){var e=this.parent;if(e.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:this.tempStrokeSettings,strokeColor:null,fillColor:null,strokeWidth:null}}),t.isNullOrUndefined(e.activeObj.currIndex))e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height);else if(this.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.renderImage();else{var i={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}});for(var o=void 0,r=0;r<i.appliedUndoRedoColl.length;r++)for(var a=0;a<i.appliedUndoRedoColl[r].currentObjColl.length;a++)if(this.prevActObj&&this.prevActObj.currIndex&&i.appliedUndoRedoColl[r].currentObjColl[a].currIndex===this.prevActObj.currIndex){o=i.appliedUndoRedoColl[r].currentObjColl[0];break}this.prevActObj&&o?(e.activeObj=this.prevActObj,this.prevActObj=null,e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"cancel"}}),e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height))}e.currObjType.isDragging=!1,t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})},e.prototype.cancelSelection=function(){var e=this.parent;e.cancelCropSelection&&(e.cropObj=t.extend({},e.cancelCropSelection.previousCropObj,{},!0),e.afterCropActions=e.cancelCropSelection.previousObj.afterCropActions,e.notify("undo-redo",{prop:"undoDefault",onPropertyChange:!1,value:{obj:e.cancelCropSelection}}),e.currSelectionPoint=t.extend({},e.cancelCropSelection.previousCropObj.activeObj,!0),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),this.clearOuterCanvas(this.lowerContext),(e.isCircleCrop||e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape)&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}))},e.prototype.updateFlipPan=function(e){var t=this.parent;if(""!==t.transform.currFlipState){var i=this.lowerContext.filter;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.notify("transform",{prop:"rotatedFlip",onPropertyChange:!1}),this.lowerContext.filter="none",t.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=i,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),e&&this.drawObject("duplicate",e)}},e.prototype.select=function(e,i,o,r,a){var n=this.parent;if(!n.disabled&&n.isImageLoaded){n.allowDownScale=!1;var s={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],n.objColl,[],!0),l.pointColl=t.extend([],n.pointColl,[],!0),l.afterCropActions=n.afterCropActions;var p={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),n.notify("crop",{prop:"setPreviousCropCurrentObj",onPropertyChange:!1,value:{obj:l}}),n.transform.zoomFactor>0&&n.activeObj.shape&&"crop"===n.activeObj.shape.split("-")[0]&&t.isNullOrUndefined(this.currSelPoint)&&(this.currSelPoint=t.extend({},n.activeObj,{},!0));var h=!1,c=void 0;void 0!==n.activeObj.shape&&(c=n.activeObj.shape.split("-")),void 0===c&&n.currObjType.isCustomCrop?h=!0:void 0!==c&&"crop"===c[0]&&(h=!0);var d={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:d}});var v=d.currObj;if(v.objColl=t.extend([],n.objColl,[],!0),v.pointColl=t.extend([],n.pointColl,[],!0),v.afterCropActions=t.extend([],n.afterCropActions,[],!0),n.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),n.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.upperCanvas.style.display="block",n.currSelectionPoint||0!==n.transform.defaultZoomFactor||0!==n.transform.degree&&0!==n.panPoint.totalPannedInternalPoint.x&&0!==n.panPoint.totalPannedInternalPoint.y&&!h){if(n.isCircleCrop=!1,0!==n.transform.defaultZoomFactor&&!this.isResizeSelect){var u=n.isCropTab;n.isCropTab=!1,n.notify("transform",{prop:"resetZoom",onPropertyChange:!1}),n.isCropTab=u,this.resetPanPoints()}n.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),n.isCropTab=!0,n.isCircleCrop=!1,this.isResizeSelect||n.notify("crop",{prop:"setCurrSelPoints",onPropertyChange:!1,value:{isSetDimension:!0}}),n.transform.zoomFactor=n.transform.cropZoomFactor,t.isNullOrUndefined(n.cropObj.activeObj.shape)&&(n.currObjType.shape="crop-"+e.toLowerCase(),this.drawNewSelection(e,i,o,r,a))}else"custom"===e&&(n.currObjType.shape=""),this.drawNewSelection(e,i,o,r,a)}},e.prototype.drawNewSelection=function(e,t,i,o,r){var a,n=this.parent,s="crop-"+e;"crop-custom"===s.toLowerCase()?""!==n.currObjType.shape&&"crop-custom"!==n.currObjType.shape||this.drawCustomSelection("crop-custom",t,i,o,r):"crop-canvas"===s.toLowerCase()?(n.upperCanvas.style.display="block",n.notify("selection",{prop:"setDragCanvas",value:{bool:!0}})):(n.currObjType.isCustomCrop=!1,n.currObjType.shape=s.toLowerCase(),o&&r?a={startX:t,startY:i,endX:t+o,endY:i+r,width:o,height:r}:o&&"crop-circle"===s&&(a={startX:t,startY:i,endX:t+o,endY:i+o,width:o,height:o}),n.activeObj.shape=s.toLowerCase(),this.updateSelectionInsert(a))},e.prototype.updateSelectionInsert=function(e){var i=this,o=this.parent,r=o.activeObj.activePoint,a={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n={type:o.getSelectionType(a.shapeSettingsObj.type),startX:a.shapeSettingsObj.startX,startY:a.shapeSettingsObj.startY,width:a.shapeSettingsObj.width,height:a.shapeSettingsObj.height},s={action:"insert",previousSelectionSettings:n,currentSelectionSettings:n};t.isBlazor()&&o.events&&!0===o.events.onSelectionResizeStart.hasDelegate?o.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(t){o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:t.currentSelectionSettings}}),"Custom"===t.currentSelectionSettings.type?i.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(e={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),i.drawObject("duplicate",null,!0,e))}):(o.trigger("selectionChanging",s),o.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}),"Custom"===s.currentSelectionSettings.type?this.drawObject("duplicate",o.activeObj,null,null,!0):(0===r.startX&&0===r.startY&&0===r.width&&0===r.height||(e={startX:r.startX,startY:r.startY,endX:r.endX,endY:r.endY,width:r.width,height:r.height}),this.drawObject("duplicate",null,!0,e)))},e.prototype.drawCustomSelection=function(e,i,o,r,a){var n=this.parent,s=n.activeObj.activePoint;if(n.currObjType.isCustomCrop=!0,this.upperContext.clearRect(0,0,n.upperCanvas.width,n.upperCanvas.height),n.currObjType.shape=n.activeObj.shape=e.toLowerCase(),t.isNullOrUndefined(i)||t.isNullOrUndefined(o)||t.isNullOrUndefined(r)||t.isNullOrUndefined(a)){if(t.isNullOrUndefined(n.transform.zoomFactor)||0===n.transform.zoomFactor){var l=n.img.destLeft,p=n.img.destTop,h=n.img.destWidth,c=n.img.destHeight,d=n.lowerCanvas.width,v=n.lowerCanvas.height,u=s;l>=0&&p>=0?(u.startX=l,u.startY=p,u.endX=l+h,u.endY=p+c):l>=0?(u.startX=l,u.startY=7.5,u.endX=l+h,u.endY=v-15):p>=0?(u.startX=7.5,u.startY=p,u.endX=d-15,u.endY=p+c):(u.startX=7.5,u.startY=7.5,u.endX=d-15,u.endY=v-15)}else{var g=n.img.destLeft,b=n.img.destTop,f=n.img.destWidth,m=n.img.destHeight,C=n.lowerCanvas.width,y=n.lowerCanvas.height,j=s;j.startX=Math.max(g>0?g:7.5,g),j.startY=Math.max(b>0?b:7.5,b),j.endX=Math.min(g+f+15<C?g+f-15:C-15,g+f),j.endY=Math.min(b+m+15<y?b+m-15:y-15,b+m)}var P=n.img.destLeft,O=n.img.destTop,x=n.img.destWidth,w=n.img.destHeight,S=n.lowerCanvas.clientWidth,T=n.lowerCanvas.clientHeight,k=s;k.startX=Math.max(k.startX,P),k.startY=Math.max(k.startY,O),k.endX=Math.min(k.endX,P+x),k.endY=Math.min(k.endY,O+w),k.startX===P&&P+x>S&&(k.endX=S-15),k.startY===O&&O+w>T&&(k.endY=T-15),n.activeObj=this.updateWidthHeight(n.activeObj),this.updateActiveObject(s,n.activeObj)}else s.startX=i,s.startY=o,s.endX=i+r,s.endY=o+a,s.width=r,s.height=a;this.updateSelectionInsert()},e.prototype.callUpdateCurrTransState=function(){var e=this.parent,i=t.extend([],e.objColl,[],!0),o=t.extend({},e.activeObj,{},!0);e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isRotateZoom=!0,this.updateCurrTransState("initial"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y;var r=this.lowerContext.filter;0===e.transform.degree&&e.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),this.updateCurrTransState("reverse"),0===e.transform.degree&&e.rotateFlipColl.length>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),this.isRotateZoom=!1,e.objColl=i;var a=e.togglePen;e.togglePen=!1,this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),e.img.destLeft+=e.panPoint.totalPannedInternalPoint.x,e.img.destTop+=e.panPoint.totalPannedInternalPoint.y,e.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),e.img.destLeft-=e.panPoint.totalPannedInternalPoint.x,e.img.destTop-=e.panPoint.totalPannedInternalPoint.y,e.togglePen=a,this.lowerContext.filter=r,e.activeObj=o},e.prototype.resetPanPoints=function(){this.parent.panPoint.totalPannedPoint={x:0,y:0},this.parent.panPoint.totalPannedClientPoint={x:0,y:0},this.parent.panPoint.totalPannedInternalPoint={x:0,y:0}},e.prototype.setClientTransDim=function(e){var i=this.parent;if(i.transform.degree%90==0&&i.transform.degree%180!=0){i.img.destLeft=(i.lowerCanvas.width-i.img.destHeight)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destWidth)/2;var o=i.img.destWidth;i.img.destWidth=i.img.destHeight,i.img.destHeight=o}else t.isNullOrUndefined(e)&&(i.img.destLeft=(i.lowerCanvas.width-i.img.destWidth)/2,i.img.destTop=(i.lowerCanvas.height-i.img.destHeight)/2)},e.prototype.redrawImgWithObj=function(){var e=this.parent,i={canvasFilter:e.canvasFilter};if(this.lowerContext.filter=i.canvasFilter,0!==e.rotateFlipColl.length){var o=t.extend({},e.panPoint.totalPannedInternalPoint,{},!0),r={startX:e.img.destLeft,startY:e.img.destTop,width:e.img.destWidth,height:e.img.destHeight};this.callUpdateCurrTransState(),e.panPoint.totalPannedInternalPoint=o,e.img.destLeft=r.startX,e.img.destTop=r.startY,e.img.destWidth=r.width,e.img.destHeight=r.height}else this.callUpdateCurrTransState();e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})},e.prototype.setCurrentObj=function(e){var i=this.parent,o=!!e;o||(i.cropObj.aspectWidth=i.aspectWidth,i.cropObj.aspectHeight=i.aspectHeight,i.cropObj.frame=i.frameObj.type),e=e||i.cropObj,i.transform.cropZoomFactor=e.cropZoom,i.transform.defaultZoomFactor=e.defaultZoom,o?e.activeObj.shape&&"crop"===e.activeObj.shape.split("-")[0]?i.transform.zoomFactor=e.cropZoom:i.transform.zoomFactor=e.defaultZoom:i.transform.zoomFactor=e.cropZoom,i.setProperties({zoomSettings:{zoomFactor:e.zoomFactor}},!0),i.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.previousZoomValue}}),i.panPoint.totalPannedPoint=t.extend({},e.totalPannedPoint,{},!0),i.panPoint.totalPannedClientPoint=t.extend({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=t.extend({},e.totalPannedInternalPoint,{},!0);var r=t.extend({},e.tempFlipPanPoint,{},!0);i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:r}}),i.rotateFlipColl=t.extend([],e.rotateFlipColl,[],!0),i.transform.degree=e.degree,i.frameObj.type=e.frame,i.transform.currFlipState=e.currFlipState,i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY,i.img.destWidth=e.destPoints.width,i.img.destHeight=e.destPoints.height,i.img.srcLeft=e.srcPoints.startX,i.img.srcTop=e.srcPoints.startY,i.img.srcWidth=e.srcPoints.width,i.img.srcHeight=e.srcPoints.height,i.aspectWidth=e.aspectWidth,i.aspectHeight=e.aspectHeight,e.afterCropActions&&(i.afterCropActions=e.afterCropActions),this.lowerContext.filter=e.filter,i.notify("filter",{prop:"setBrightnessAdjusted",onPropertyChange:!1,value:{isBrightnessAdjusted:e.isBrightAdjust}});var a,n=i.isCircleCrop;t.isNullOrUndefined(i.currSelectionPoint)?a=null:(a=t.extend({},i.currSelectionPoint,{},!0),i.currSelectionPoint=null),i.isCircleCrop=!1,this.drawCropSelectionImage(e,!1),0!==i.transform.degree&&(""===i.transform.currFlipState?i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}):i.notify("transform",{prop:"drawPannedImage",value:{xDiff:0,yDiff:0}}),i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY,i.panPoint.totalPannedClientPoint=t.extend({},e.totalPannedClientPoint,{},!0),i.panPoint.totalPannedInternalPoint=t.extend({},e.totalPannedInternalPoint,{},!0)),i.activeObj=t.extend({},e.activeObj,{},!0),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0);var s=t.extend({},e.activeObj,{},!0),l=!1;if(i.afterCropActions.length>0){var p={collection:i.afterCropActions};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.afterCropActions,isRotateFlipCollection:null,obj:p}}),i.afterCropActions=p.collection}var h=t.extend([],i.afterCropActions,[],!0);if(!o&&h.length>0){l=!0;for(var c=0;c<h.length;c++)"horizontalflip"!==h[c]&&"verticalflip"!==h[c]||(i.activeObj=t.extend({},a,{},!0),this.rotatedFlipCropSel=!0),i.notify("transform",{prop:"updateTransform",onPropertyChange:!1,value:{text:h[c]}});s=t.extend({},i.activeObj,{},!0),this.resetPanPoints(),i.activeObj=s,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0),e.degree!==i.transform.degree&&(i.transform.cropZoomFactor=null,i.transform.zoomFactor=0),i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.rotatedFlipCropSel&&(this.rotatedFlipCropSel=!1)}i.afterCropActions=h,this.isCancelAction||l||(i.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.img.destLeft=e.destPoints.startX,i.img.destTop=e.destPoints.startY),i.activeObj=s,i.isCircleCrop=n,t.isNullOrUndefined(a)?i.currSelectionPoint=null:(i.currSelectionPoint=t.extend({},a,{},!0),i.currSelectionPoint&&t.isNullOrUndefined(i.currSelectionPoint.shape)&&(i.currSelectionPoint=null))},e.prototype.drawCropSelectionImage=function(e,i){var o=this.parent,r=this.lowerContext.filter;o.clearContext(this.lowerContext),o.clearContext(this.upperContext),this.lowerContext.setTransform(1,0,0,1,0,0),i?this.updateCurrTransState("initial"):this.setTransformColl(this.lowerContext,"initial"),o.notify("transform",{prop:"setDestPointsForFlipState",onPropertyChange:!1}),this.drawImage(),i?this.updateCurrTransState("reverse"):this.setTransformColl(this.lowerContext,"reverse"),o.img.destLeft=o.cropObj.destPoints.startX,o.img.destTop=o.cropObj.destPoints.startY;var a=t.extend({},e.activeObj,{},!0);if(this.lowerContext.filter="none",this.isCancelAction)o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}});else if(o.img.destLeft=e.destPoints.startX,o.img.destTop=e.destPoints.startY,o.img.destWidth=e.destPoints.width,o.img.destHeight=e.destPoints.height,o.img.srcLeft=e.srcPoints.startX,o.img.srcTop=e.srcPoints.startY,o.img.srcWidth=e.srcPoints.width,o.img.srcHeight=e.srcPoints.height,0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height){var n={startX:o.img.destLeft,startY:o.img.destTop,width:o.img.destWidth,height:o.img.destHeight};o.img.destLeft=e.activeObj.activePoint.startX,o.img.destTop=e.activeObj.activePoint.startY,o.img.destWidth=e.activeObj.activePoint.width,o.img.destHeight=e.activeObj.activePoint.height,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.img.destLeft=n.startX,o.img.destTop=n.startY,o.img.destWidth=n.width,o.img.destHeight=n.height}o.activeObj=a,this.lowerContext.filter=r},e.prototype.performPointZoom=function(e,i,o){var r=this.parent,a=(e-r.img.destLeft)/r.img.destWidth,n=(i-r.img.destTop)/r.img.destHeight,s=r.isUndoRedo;if(r.isUndoRedo=!0,r.setProperties({zoomSettings:{zoomPoint:{x:e,y:i}}},!0),"zoomIn"===o?r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null}):"zoomOut"===o&&r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null}),r.isUndoRedo=s,r.transform.zoomFactor>0){var l=r.img.destLeft,p=r.img.destTop,h=t.extend({},r.activeObj,{},!0);if(0===r.transform.degree)r.img.destLeft=e-a*r.img.destWidth,r.img.destTop=i-n*r.img.destHeight,this.drawZoomPanImage(r.img.destLeft-l,r.img.destTop-p);else{var c=r.isCropTab;r.isCropTab=!0;var d=t.extend([],r.objColl,[],!0),v=t.extend([],r.pointColl,[],!0);r.objColl=[],r.pointColl=[],r.freehandCounter=0;var u={selPointColl:null};r.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:u}});var g=u.selPointColl;r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),r.panPoint.currentPannedPoint={x:e-a*r.img.destWidth-l,y:i-n*r.img.destHeight-p},r.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),r.isCropTab=c,r.objColl=d,r.pointColl=v,r.freehandCounter=r.pointColl.length,r.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:g}}}),r.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}}),r.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:r.panPoint.currentPannedPoint.x,yDiff:r.panPoint.currentPannedPoint.y,panRegion:""}})}this.adjustPanning(h),r.activeObj=h,0!==r.activeObj.activePoint.width&&0!==r.activeObj.activePoint.height&&this.drawObject("duplicate",null,null,null,!0)}},e.prototype.adjustPanning=function(e){var i=this.parent;if(0!==e.activePoint.width&&0!==e.activePoint.height){var o=i.img.destLeft,r=i.img.destTop,a={x:0,y:0};if(i.img.destLeft>e.activePoint.startX?a.x=i.img.destLeft-e.activePoint.startX:i.img.destLeft+i.img.destWidth<e.activePoint.startX+e.activePoint.width&&(a.x=i.img.destLeft+i.img.destWidth-(e.activePoint.startX+e.activePoint.width)),i.img.destTop>e.activePoint.startY?a.y=i.img.destTop-e.activePoint.startY:i.img.destTop+i.img.destHeight<e.activePoint.startY+e.activePoint.height&&(a.y=i.img.destTop+i.img.destHeight-(e.activePoint.startY+e.activePoint.height)),0===i.transform.degree)i.img.destLeft-=a.x,i.img.destTop-=a.y,this.drawZoomPanImage(i.img.destLeft-o,i.img.destTop-r);else{var n=i.isCropTab;i.isCropTab=!0;var s=t.extend([],i.objColl,[],!0),l=t.extend([],i.pointColl,[],!0);i.objColl=[],i.pointColl=[],i.freehandCounter=0;var p={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}});var h=p.selPointColl;i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.img.destLeft-=a.x,i.img.destTop-=a.y,i.panPoint.currentPannedPoint={x:i.img.destLeft-o,y:i.img.destTop-r},i.notify("transform",{prop:"rotatePan",onPropertyChange:!1,value:{isCropSelection:null,isDefaultZoom:null}}),i.isCropTab=n,i.objColl=s,i.pointColl=l,i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:h}}}),i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:i.panPoint.currentPannedPoint.x,yDiff:i.panPoint.currentPannedPoint.y,panRegion:""}})}}},e.prototype.drawZoomPanImage=function(e,t){var i=this.parent;i.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:e,yDiff:t,panRegion:""}}),i.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:e,yDiff:t,panRegion:""}}),this.renderImage(!0);var o={width:0,height:0};i.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i.img.srcWidth,height:i.img.srcHeight,obj:o,isImgShape:null}});var r=o;r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.panPoint.totalPannedPoint.x+=e,i.panPoint.totalPannedPoint.y+=t,i.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:{x:0,y:0}}})},e.prototype.openNewImage=function(){var e=this.parent,o=e.inMemoryCanvas.getContext("2d");i.showSpinner(e.element),e.element.style.opacity="0.5";var r=document.querySelector("#"+e.element.id+"_currPos");r&&(r.style.display="none");var a={defToolbarItems:null};if(t.isBlazor())e.element.querySelector("#"+e.element.id+"_toolbarArea")&&(e.toolbarHeight=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight);else if(e.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:a}}),0===a.defToolbarItems.length&&t.isNullOrUndefined(document.getElementById(e.element.id+"_toolbar"))){var n=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight;e.notify("toolbar",{prop:"setToolbarHeight",value:{height:n}})}e.reset(),e.update(),e.transform.degree=0,e.transform.zoomFactor=0,e.isImageLoaded=!1,e.currSelectionPoint=null;if("string"===typeof this.openURL){var s=this.openURL.split(".");if(s.length>1?(s=s[s.length-2].split("/"),this.fileName=s[s.length-1]):this.fileName="ImageEditor",this.fileType=this.getFileExtensionFromURL(this.openURL),this.fileType){this.fileType=e.toPascalCase(this.fileType);var l=this.fileType.toLowerCase();"jpg"!==l&&"jpeg"!==l||(this.fileType="Jpeg",l="jpeg"),"jpeg"!==l&&"png"!==l&&"svg"!==l&&(this.fileType=null)}this.imageOnLoad(this.openURL)}else this.fileName="ImageEditor",this.fileType=null,e.lowerCanvas=document.querySelector("#"+e.element.id+"_lowerCanvas"),e.upperCanvas=document.querySelector("#"+e.element.id+"_upperCanvas"),this.lowerContext=e.lowerCanvas.getContext("2d"),this.upperContext=e.upperCanvas.getContext("2d"),e.clearContext(this.lowerContext),e.clearContext(this.upperContext),e.clearContext(o),e.inMemoryCanvas.width=this.openURL.width,e.inMemoryCanvas.height=this.openURL.height,o.putImageData(this.openURL,0,0),e.baseImg.src=e.inMemoryCanvas.toDataURL()},e.prototype.dlgBtnClick=function(){var e=this.parent;e.export(),this.isFileChanged?(e.isImageLoaded=this.isFileChanged=!1,e.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),t.isBlazor()||t.getComponent(document.getElementById(e.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},e.prototype.dlgCloseBtnClick=function(){var e=this.parent;this.baseImgSrc=e.baseImg.src,this.isFileChanged?(e.isImageLoaded=this.isFileChanged=!1,e.reset(),this.checkToolbarTemplate(this.inputElem,this.openURL)):(this.reset(),this.openNewImage()),t.isBlazor()||t.getComponent(document.getElementById(e.element.id+"_dialog"),"dialog").destroy(),this.isImageEdited=!1},e.prototype.showDialogPopup=function(){var e={key:"ConfirmDialogHeader"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:e}});var t={key:"ConfirmDialogContent"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:t}});var o={key:"Yes"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var r={key:"No"};this.parent.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),this.parent.element.querySelector("#"+this.parent.element.id+"_dialog").style.display="block";new i.Dialog({header:e.value,closeOnEscape:!0,content:"<span>"+t.value+"</span>",target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:r.value,iconCss:"e-icons e-close"}},{click:this.dlgBtnClick.bind(this),buttonModel:{content:o.value,isPrimary:!0,iconCss:"e-icons e-check"}}]}).appendTo("#"+this.parent.element.id+"_dialog")},e.prototype.restoreOldImage=function(){this.parent.isImageLoaded?(this.reset(),this.openNewImage()):this.openNewImage()},e.prototype.open=function(e){document.getElementById(this.parent.element.id+"_dropArea").style.display="none",this.parent.disabled||(this.openURL=e,this.restoreOldImage())},e.prototype.getInitialLoaded=function(e){e.isInitialLoaded=this.isInitialLoading},e.prototype.getFileExtensionFromURL=function(e){var t=e.lastIndexOf(".");return-1!==t?e.slice(t+1).toLowerCase():null},e.prototype.fileSelect=function(e,o){var r=this.parent;if(document.getElementById(r.element.id+"_dropArea").style.display="none",!r.disabled){var a=void 0,n=void 0;o.target?n=a=o.target.files[0]:a=n=o.filesData[0].rawFile;var s=void 0;if(n.name){var l=n.name.split(".");s=l[l.length-1].toLowerCase()}if(s&&-1===["jpg","jpeg","png","svg"].indexOf(s))return void this.errorLoading();if(i.showSpinner(r.element),r.element.style.opacity="0.5",this.inputElem=e,s=n.name&&n.name.split(".")[1]){var p=r.toPascalCase(s);this.fileType="JPG"===p||"Jpg"===p?"Jpeg":p}else this.fileType=null;var h=window.URL.createObjectURL(a);this.openURL=h,r.isImageLoaded&&(this.isImageEdited||r.pointColl.length>0||r.objColl.length>0)?(this.isFileChanged=!0,t.isBlazor()?r.dotNetRef.invokeMethodAsync("UpdateDialog",!0):this.showDialogPopup()):this.checkToolbarTemplate(e,h)}},e.prototype.checkToolbarTemplate=function(e,i){var o=this.parent;t.isNullOrUndefined(o.toolbarTemplate)&&(o.reset(),o.update()),this.fileName=e.value.split("\\")[e.value.split("\\").length-1],this.fileName=this.fileName.split(".")[0],this.imageOnLoad(i.toString()),e.value=""},e.prototype.moveToSelectionRange=function(e,i){var o=this.parent;if(o.activeObj.shape){for(var r=!1,a=0;a<o.rotateFlipColl.length;a++)if(90===o.rotateFlipColl[a]||-90===o.rotateFlipColl[a]){r=!0;break}if(r){if(0===o.transform.degree)return;var n=o.transform.zoomFactor;if(o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),"rotateleft"===e||"rotateright"===e)if(o.transform.degree%90==0&&o.transform.degree%180!=0)if(o.objColl[o.objColl.length-1].activePoint.width<i.activePoint.height)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.width>=i.activePoint.height||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else if(o.objColl[o.objColl.length-1].activePoint.height<i.activePoint.width)for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null});break}n+=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}else for(a=2;a<o.zoomSettings.maxZoomFactor;a++){if(o.objColl[o.objColl.length-1].activePoint.height>=i.activePoint.width||this.isSelectionBiggerThanCanvas(o.objColl[o.objColl.length-1])||this.isSelectionOutsideCanvas(o.objColl[o.objColl.length-1])){t.isNullOrUndefined(n)||o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null});break}n-=.1,o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:n,zoomPoint:null},isResize:null})}var s=o.lowerCanvas.clientWidth/2-(o.objColl[o.objColl.length-1].activePoint.startX+o.objColl[o.objColl.length-1].activePoint.width/2),l=o.lowerCanvas.clientHeight/2-(o.objColl[o.objColl.length-1].activePoint.startY+o.objColl[o.objColl.length-1].activePoint.height/2);0===o.transform.degree?(o.img.destLeft+=s,o.img.destTop+=l,o.notify("transform",{prop:"drawPannImage",value:{point:{x:s,y:l}}})):(o.panPoint.currentPannedPoint={x:s,y:l},o.notify("transform",{prop:"drawPannedImage",value:{xDiff:s,yDiff:l}}),o.panPoint.currentPannedPoint={x:0,y:0}),o.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}}),o.activeObj=t.extend({},o.objColl[o.objColl.length-1]),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})}}},e.prototype.isSelectionBiggerThanCanvas=function(e){var t=!1;return(e.activePoint.startX<=this.parent.img.destLeft||e.activePoint.startY<=this.parent.img.destTop||e.activePoint.endX>=this.parent.img.destLeft+this.parent.img.destWidth||e.activePoint.endY>=this.parent.img.destTop+this.parent.img.destHeight)&&(t=!0),t},e.prototype.isSelectionOutsideCanvas=function(e){var t=!1;return(e.activePoint.height<this.parent.lowerCanvas.height-this.parent.toolbarHeight||e.activePoint.width<this.parent.lowerCanvas.width)&&(t=!0),t},e.prototype.downScaleImgCanvas=function(e,i,o,r){var a=this.parent,n=i?a.activeObj.imageCanvas:a.baseImgCanvas,s=i?a.activeObj.imageElement:a.baseImg,l=i?a.activeObj.activePoint.width:a.img.destWidth,p=i?a.activeObj.activePoint.height:a.img.destHeight,h={width:0,height:0};if(a.transform.degree%90==0&&a.transform.degree%180!=0?a.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:s.height,height:s.width,obj:h,isImgShape:i}}):a.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:s.width,height:s.height,obj:h,isImgShape:i}}),i||a.allowDownScale&&!a.isCropTab&&!a.isCropToolbar&&0!==s.width&&0!==s.height&&.75*h.width>l&&.75*h.height>p){var c=a.createElement("canvas",{id:a.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});c.width=i?s.width:this.parent.img.srcWidth,c.height=i?s.height:this.parent.img.srcHeight,i?c.getContext("2d").drawImage(s,0,0,c.width,c.height):c.getContext("2d").drawImage(n,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,0,0,c.width,c.height),this.downScale(c,l,p,i),i?(e.canvas.width=c.width,e.canvas.height=c.height,o&&r?(e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1),e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1)):o?(t.isNullOrUndefined(a.activeObj.isHorImageFlip)||!a.activeObj.isHorImageFlip?(a.activeObj.isHorImageFlip=!0,e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1)):a.activeObj.isHorImageFlip&&(a.activeObj.isHorImageFlip=!1),a.activeObj.isVerImageFlip&&(e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1))):r&&(t.isNullOrUndefined(a.activeObj.isVerImageFlip)||!a.activeObj.isVerImageFlip?(a.activeObj.isVerImageFlip=!0,e.translate(0,a.activeObj.imageCanvas.height),e.scale(1,-1)):a.activeObj.isVerImageFlip&&(a.activeObj.isVerImageFlip=!1),a.activeObj.isHorImageFlip&&(e.translate(a.activeObj.imageCanvas.width,0),e.scale(-1,1))),e.drawImage(c,0,0),e.setTransform(1,0,0,1,0,0)):e.drawImage(c,0,0,c.width,c.height,a.img.destLeft,a.img.destTop,c.width,c.height)}else!t.isNullOrUndefined(i)&&i||e.drawImage(a.baseImg,a.img.srcLeft,a.img.srcTop,a.img.srcWidth,a.img.srcHeight,a.img.destLeft,a.img.destTop,a.img.destWidth,a.img.destHeight)},e.prototype.downScale=function(e,t,i,o){for(var r=e.width,a=e.height,n=r/(t=Math.round(t)),s=a/(i=Math.round(i)),l=Math.ceil(n/2),p=Math.ceil(s/2),h=e.getContext("2d"),c=h.getImageData(0,0,r,a),d=h.createImageData(t,i),v=c.data,u=d.data,g=0;g<i;g++)for(var b=0;b<t;b++){for(var f=4*(b+g*t),m=0,C=0,y=0,j=0,P=0,O=0,x=0,w=(g+.5)*s,S=Math.floor(g*s),T=Math.ceil((g+1)*s),k=S;k<T;k++)for(var F=Math.abs(w-(k+.5))/p,A=(b+.5)*n,z=F*F,L=Math.floor(b*n),I=Math.ceil((b+1)*n),X=L;X<I;X++){var Y=Math.abs(A-(X+.5))/l,D=Math.sqrt(z+Y*Y);if(!(D>=1)){var R=4*(X+k*r);x+=(m=2*D*D*D-3*D*D+1)*v[R+3],y+=m,j+=(m=m*v[R+3]/250)*v[R],P+=m*v[R+1],O+=m*v[R+2],C+=m}}u[f]=j/C,u[f+1]=P/C,u[f+2]=O/C,u[f+3]=x/y}e.width=o?this.parent.activeObj.activePoint.width:this.parent.lowerCanvas.width,e.height=o?this.parent.activeObj.activePoint.height:this.parent.lowerCanvas.height,h.putImageData(d,0,0)},e.prototype.drawImgToCtx=function(e,i){var o=this.parent;e.canvas.id!==o.element.id+"_tempCanvas"&&t.isNullOrUndefined(i)&&this.downScaleImgCanvas(e,null,null,null)},e.prototype.getFrameColor=function(e,t,i){var o=this.parent.frameObj.color;if(e.gradientColor){var r=t.createLinearGradient(i.startX,i.startY,i.startX+i.width,i.startY+i.height);r.addColorStop(0,e.color),r.addColorStop(1,e.gradientColor),o=r}else o=e.color;return o},e.prototype.applyFrame=function(e,i,o){var r=this.parent;r.frameObj.type=i;var a,n={width:1,height:1},s={startX:r.img.destLeft-e.lineWidth,startY:r.img.destTop-e.lineWidth,width:r.img.destWidth+2*e.lineWidth,height:r.img.destHeight+2*e.lineWidth},l={type:r.frameObj.type,color:r.frameObj.color,size:r.frameObj.size,inset:r.frameObj.inset,offset:r.frameObj.offset/2,radius:r.frameObj.radius,amount:r.frameObj.amount,border:r.frameObj.border,gradientColor:r.frameObj.gradientColor};if(e.canvas.id===r.element.id+"_tempCanvas"){var p=void 0,h=void 0;p=e.canvas.width,h=e.canvas.height;var c={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:c,dimension:{width:p,height:h}}}),n=c,l.size*=(n.width+n.height)/2,l.inset*=(n.width+n.height)/2,l.offset*=(n.width+n.height)/2,l.radius*=(n.width+n.height)/2,s={startX:0,startY:0,width:e.canvas.width,height:e.canvas.height}}else t.isNullOrUndefined(o)&&e.clearRect(0,0,e.canvas.width,e.canvas.height);var d=(n.width+n.height)/2*40,v=(n.width+n.height)/2*50;l.size+=l.size*r.transform.zoomFactor,l.inset+=l.inset*r.transform.zoomFactor,l.offset+=l.offset*r.transform.zoomFactor,l.radius+=l.radius*r.transform.zoomFactor,d+=d*r.transform.zoomFactor,v+=v*r.transform.zoomFactor;var u=e.filter;if(r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape||r.isCircleCrop)this.drawImgToCtx(e,o);else{switch(i){case"none":this.drawImgToCtx(e,o);break;case"mat":this.drawImgToCtx(e,o),e.filter="none",e.fillStyle=this.getFrameColor(l,e,s),e.beginPath(),e.rect(s.startX,s.startY,s.width,s.height),e.rect(s.startX+l.size,s.startY+l.size,s.width-2*l.size,s.height-2*l.size),e.fill("evenodd"),e.closePath();break;case"bevel":e.filter="none",e.fillStyle=this.getFrameColor(l,e,s),e.beginPath(),e.fillRect(s.startX,s.startY,s.width,s.height),e.closePath(),s.startX+=l.size,s.startY+=l.size,s.width-=2*l.size,s.height-=2*l.size,e.fillStyle=this.getFrameColor(l,e,s),e.save(),e.beginPath(),e.moveTo(s.startX+d,s.startY),e.lineTo(s.startX+s.width-d,s.startY),e.quadraticCurveTo(s.startX+s.width,s.startY,s.startX+s.width,s.startY+d),e.lineTo(s.startX+s.width,s.startY+s.height-d),e.quadraticCurveTo(s.startX+s.width,s.startY+s.height,s.startX+s.width-d,s.startY+s.height),e.lineTo(s.startX+d,s.startY+s.height),e.quadraticCurveTo(s.startX,s.startY+s.height,s.startX,s.startY+s.height-d),e.lineTo(s.startX,s.startY+d),e.quadraticCurveTo(s.startX,s.startY,s.startX+d,s.startY),e.closePath(),e.clip(),e.filter="none"===u?r.canvasFilter:u,e.canvas.id===r.element.id+"_tempCanvas"?o?(o=null,e.drawImage(r.baseImg,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,e.canvas.width,e.canvas.height),r.frameObj.type="none",e.filter="none",r.notify("export",{prop:"drawAnnotation",onPropertyChange:!1,value:{context:e,ratio:n}}),r.frameObj.type="bevel",e.filter="none"===u?r.canvasFilter:u):e.drawImage(r.baseImg,r.img.srcLeft,r.img.srcTop,r.img.srcWidth,r.img.srcHeight,0,0,e.canvas.width,e.canvas.height):o?(o=null,0!==r.transform.zoomFactor&&(this.isRotateZoom=!0),this.updateCurrTransState("initial"),this.drawImgToCtx(e,o),this.updateCurrTransState("reverse"),this.isRotateZoom=!1,r.frameObj.type="none",e.filter="none",r.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),r.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}}),r.frameObj.type="bevel",e.filter="none"===u?r.canvasFilter:u):this.drawImgToCtx(e,o),e.restore();break;case"line":this.drawImgToCtx(e,o),a=e.lineWidth,e.lineWidth=l.size/10;for(var g=0;g<r.frameObj.amount;g++){g>0&&(s.startX+=l.offset,s.startY+=l.offset,s.width-=2*l.offset,s.height-=2*l.offset);var b=s.startY+s.height-l.inset-l.radius,f=s.startY+l.inset+l.radius,m=s.startX+s.width-l.inset-l.radius,C=s.startX+l.inset+l.radius,y=s.startX+l.inset+l.radius,j=s.startX+s.width-l.inset-l.radius,P=s.startY+l.inset+l.radius,O=s.startY+s.height-l.inset-l.radius;b>=f&&m>=C&&y<=j&&P<=O&&(e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),"dashed"===l.border?e.setLineDash([2.5*e.lineWidth,1.5*e.lineWidth]):"dotted"===l.border&&e.setLineDash([e.lineWidth,e.lineWidth]),e.beginPath(),e.moveTo(s.startX+l.inset+l.radius,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset-l.radius,s.startY+l.inset),e.arcTo(s.startX+s.width-l.inset,s.startY+l.inset,s.startX+s.width-l.inset,s.startY+l.inset+l.radius,l.radius),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset-l.radius),e.arcTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset,s.startX+s.width-l.inset-l.radius,s.startY+s.height-l.inset,l.radius),e.lineTo(s.startX+l.inset+l.radius,s.startY+s.height-l.inset),e.arcTo(s.startX+l.inset,s.startY+s.height-l.inset,s.startX+l.inset,s.startY+s.height-l.inset-l.radius,l.radius),e.lineTo(s.startX+l.inset,s.startY+l.inset+l.radius),e.arcTo(s.startX+l.inset,s.startY+l.inset,s.startX+l.inset+l.radius,s.startY+l.inset,l.radius),e.closePath(),e.stroke(),e.setLineDash([]))}e.lineWidth=a;break;case"inset":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),a=e.lineWidth,e.lineWidth=l.size/10,e.beginPath(),e.moveTo(s.startX+l.offset,s.startY+l.inset),e.lineTo(s.startX+s.width-l.offset,s.startY+l.inset),e.moveTo(s.startX+s.width-l.inset,s.startY+l.offset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.offset),e.moveTo(s.startX+s.width-l.offset,s.startY+s.height-l.inset),e.lineTo(s.startX+l.offset,s.startY+s.height-l.inset),e.moveTo(s.startX+l.inset,s.startY+s.height-l.offset),e.lineTo(s.startX+l.inset,s.startY+l.offset),e.stroke(),e.closePath(),e.lineWidth=a;break;case"hook":this.drawImgToCtx(e,o),e.filter="none",e.strokeStyle=this.getFrameColor(l,e,s),a=e.lineWidth,e.lineWidth=l.size/10,e.beginPath(),e.moveTo(s.startX+l.inset+v,s.startY+l.inset),e.lineTo(s.startX+l.inset,s.startY+l.inset),e.lineTo(s.startX+l.inset,s.startY+l.inset+v),e.moveTo(s.startX+s.width-l.inset-v,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+l.inset+v),e.moveTo(s.startX+s.width-l.inset-v,s.startY+s.height-l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset),e.lineTo(s.startX+s.width-l.inset,s.startY+s.height-l.inset-v),e.moveTo(s.startX+l.inset+v,s.startY+s.height-l.inset),e.lineTo(s.startX+l.inset,s.startY+s.height-l.inset),e.lineTo(s.startX+l.inset,s.startY+s.height-l.inset-v),e.stroke(),e.lineWidth=a}(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:e,isSave:e.canvas.id===r.element.id+"_tempCanvas"||null,isFlip:null}}),e.filter=u}},e.prototype.triggerFrameChange=function(e){var i=this,o=this.parent,r={cancel:!1,previousFrameSetting:e,currentFrameSetting:{type:o.toPascalCase(o.frameObj.type),color:o.frameObj.color,gradientColor:o.frameObj.gradientColor,size:o.frameObj.size,inset:o.frameObj.inset,offset:o.frameObj.offset,borderRadius:o.frameObj.radius,frameLineStyle:o.toPascalCase(o.frameObj.border),lineCount:o.frameObj.amount}};return t.isBlazor()?o.events&&!0===o.events.frameChanging.hasDelegate?o.dotNetRef.invokeMethodAsync("OnFrameChangingAsync",r).then(function(e){if(!e.cancel){i.setFrameObj(e.currentFrameSetting);var r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}}),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:r.currObj,previousObjColl:r.currObj.objColl,previousPointColl:r.currObj.pointColl,previousSelPointColl:r.currObj.selPointColl,previousCropObj:t.extend({},o.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});o.element.querySelector(".e-ie-toolbar-e-frame-color")&&(o.element.querySelector(".e-ie-toolbar-e-frame-color"+o.DDBPREVIEW).style.background=o.frameObj.color);if(o.element.querySelector(".e-ie-toolbar-e-frame-gradient")){var a=document.querySelector(".e-dropdown-popup.e-frame-gradient-dd-btn");a&&a.querySelector(".e-nocolor-item").classList.remove("e-selected"),o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).classList.remove("e-nocolor-item"),""==o.frameObj.gradientColor?o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).classList.add("e-nocolor-item"):o.element.querySelector(".e-ie-toolbar-e-frame-gradient"+o.DDBPREVIEW).style.background=o.frameObj.gradientColor}o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}})}}):r.cancel||this.setFrameObj(r.currentFrameSetting):(o.trigger("frameChange",r),r.cancel||this.setFrameObj(r.currentFrameSetting)),r},e.prototype.setFrameObj=function(e){var t=this.parent;t.frameObj.type=e.type.toLowerCase(),t.frameObj.color=e.color,t.frameObj.gradientColor=e.gradientColor,t.frameObj.size=e.size,t.frameObj.inset=e.inset,t.frameObj.offset=e.offset,t.frameObj.radius=e.borderRadius,t.frameObj.border=e.frameLineStyle.toLowerCase(),t.frameObj.amount=e.lineCount},e}(),l=function(){function e(e){this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("export",this.export,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("export",this.export),this.parent.off("destroyed",this.destroy)},e.prototype.export=function(e){if(t.isBlazor()){var i={shape:""};this.parent.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:i}}),""!==i.shape&&(this.parent.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),this.parent.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}else this.parent.notify("toolbar",{prop:"refreshShapeDrawing",onPropertyChange:!1});switch(this.updatePvtVar(),e.prop){case"export":this.exportImg(e.value.type,e.value.fileName);break;case"exportToCanvas":this.exportToCanvas(e.value.object);break;case"drawAnnotation":this.drawAnnotation(e.value.context,e.value.ratio)}},e.prototype.getModuleName=function(){return"export"},e.prototype.updatePvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.exportImg=function(e,i){var o=this,r=this.parent,a={fileName:""};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n=a.fileName;if(!r.disabled&&r.isImageLoaded){var s={bool:!1};r.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:s}}),s.bool&&r.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),r.togglePen&&(r.currObjType.isZoomed=!0,r.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}})),"block"===r.textArea.style.display&&r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}});var l={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=l.canvasFilter,e=e||"Png",r.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}});var p={cancel:!1,fileName:i||n,fileType:e};t.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",p).then(function(t){o.beforeSaveEvent(t,e,i,n)}):(r.trigger("beforeSave",p),this.beforeSaveEvent(p,e,i,n))}},e.prototype.beforeSaveEvent=function(e,i,o,r){var a=this.parent;if(!e.cancel){a.currObjType.isSave=!0,o=e.fileName?e.fileName:o;var n=i.toLowerCase();o=o||r,"svg"===n?this.toSVGImg(o):this.toBlobFn(o,n);var s={fileName:o||r,fileType:i};a.trigger("saved",s),t.isBlazor()||a.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),a.lowerCanvas.style.left=a.upperCanvas.style.left="",a.lowerCanvas.style.top=a.upperCanvas.style.top="",a.lowerCanvas.style.maxWidth=a.upperCanvas.style.maxWidth="",a.lowerCanvas.style.maxHeight=a.upperCanvas.style.maxHeight=""}},e.prototype.toSVGImg=function(e){var t=this.parent;i.showSpinner(t.element),t.element.style.opacity="0.5";var o=this.exportToCanvas(),r=o.toDataURL();i.hideSpinner(t.element),t.element.style.opacity="1";var a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width",o.style.maxWidth),a.setAttribute("height",o.style.maxHeight);var n=document.createElementNS("http://www.w3.org/2000/svg","image");n.setAttributeNS(null,"height",o.height.toString()),n.setAttributeNS(null,"width",o.width.toString()),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(n);var s='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'+o.width+'" height="'+o.height+'">'+a.innerHTML+"</svg>",l="data:image/svg+xml;base64,"+btoa(s);return null===e?l:(this.downloadImg(l,e+".svg"),null)},e.prototype.toBlobFn=function(e,t){var o=this,r=this.parent;i.showSpinner(r.element),r.element.style.opacity="0.5";this.exportToCanvas().toBlob(function(a){var n=URL.createObjectURL(a);o.downloadImg(n,e+"."+t),i.hideSpinner(r.element),r.element.style.opacity="1"},"image/png")},e.prototype.exportToCanvas=function(e){var i,o,r=this.parent;this.parent.aspectWidth?(t.isBlazor()?r.performResizeClick():r.notify("toolbar",{prop:"resizeClick",value:{bool:!1}}),r.currentToolbar="resize-toolbar",r.okBtn(),r.transform.degree%90==0&&r.transform.degree%180!=0?(i=this.parent.aspectHeight,o=this.parent.aspectWidth):(i=this.parent.aspectWidth,o=this.parent.aspectHeight)):r.currSelectionPoint?(i=r.img.srcWidth,o=r.img.srcHeight):(i=r.baseImgCanvas.width,o=r.baseImgCanvas.height);var a={width:0,height:0};r.notify("crop",{prop:"calcRatio",onPropertyChange:!1,value:{obj:a,dimension:{width:i,height:o}}});var n=a,s=this.lowerContext.filter;if("none"!==this.lowerContext.filter){var l=this.lowerContext.filter.split(" "),p=parseFloat(l[5].split("(")[1]);p*=(n.width+n.height)/2,l[5]="blur("+p+"px)",this.lowerContext.filter=l.join(" ")}var h=r.createElement("canvas",{id:r.element.id+"_tempCanvas",attrs:{name:"canvasImage"}}),c=h.getContext("2d");h.width=i,h.height=o;var d={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:i,height:o,obj:d}});var v=d;h.style.maxWidth=v.width+"px",h.style.maxHeight=v.height+"px";var u=this.lowerContext.filter;return c.filter=this.lowerContext.filter,this.downScaleImgCanvas(c,i,o),this.updateFrame(c),this.lowerContext.filter=u,0===r.transform.degree&&""===r.transform.currFlipState||(this.updateSaveContext(c),this.exportTransformedImage(c)),this.drawAnnotation(c,n),r.isCircleCrop&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:c,isSave:!0,isFlip:null}}),this.updateFrame(c,!0),this.lowerContext.filter=s,r.canvasFilter=s,e&&(e.canvas=h),h},e.prototype.drawAnnotation=function(e,i){var o=this.parent;if(o.objColl.length>0){var r=e.filter;e.filter="none";for(var a=t.extend([],o.objColl,[],!0),n=0,s=o.objColl.length;n<s;n++){var l=o.objColl[n].activePoint;if(l.startX-=o.img.destLeft,l.startY-=o.img.destTop,l.endX-=o.img.destLeft,l.endY-=o.img.destTop,l.width=l.endX-l.startX,l.height=l.endY-l.startY,l.startX*=i.width,l.startY*=i.height,l.endX*=i.width,l.endY*=i.height,l.width=l.endX-l.startX,l.height=l.endY-l.startY,o.objColl[n].strokeSettings.strokeWidth*=(i.width+i.height)/2,"text"===o.objColl[n].shape)o.objColl[n].textSettings.fontSize*=(i.width+i.height)/2;else if("path"===o.objColl[n].shape)for(var p=0;p<o.objColl[n].pointColl.length;p++)o.objColl[n].pointColl[p].x=(o.objColl[n].pointColl[p].x-o.img.destLeft)*i.width,o.objColl[n].pointColl[p].y=(o.objColl[n].pointColl[p].y-o.img.destTop)*i.height;else"image"===o.objColl[n].shape&&(o.activeObj=t.extend({},o.objColl[n],{},!0),o.notify("selection",{prop:"upgradeImageQuality",onPropertyChange:!1}),o.objColl[n]=t.extend({},o.activeObj,{},!0));o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"saveContext",obj:o.objColl[n],isCropRatio:null,points:null,isPreventDrag:!0,saveContext:e,isPreventSelection:null}})}e.filter=r,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.objColl=a}if(o.freehandCounter>0){for(var h=t.extend({},o.pointColl,{},!0),c=0;c<o.freehandCounter;c++){o.points=t.extend([],o.pointColl[c].points,[]),o.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});s=o.points.length;o.pointColl[c].strokeWidth*=(i.width+i.height)/2;for(p=0;p<s;p++)o.points[p].x=(o.points[p].x-o.img.destLeft)*i.width,o.points[p].y=(o.points[p].y-o.img.destTop)*i.height}o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:e,points:null}}),o.pointColl=h}},e.prototype.downScaleImgCanvas=function(e,t,i){var o=this.parent,r=o.baseImgCanvas,a=o.baseImg,n={width:0,height:0};if(o.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:a.width,height:a.height,obj:n,isImgShape:null}}),n.width>t&&n.height>i){var s=o.createElement("canvas",{id:o.element.id+"_downScaleCanvas",attrs:{name:"canvasImage"}});s.width=this.parent.img.srcWidth,s.height=this.parent.img.srcHeight,s.getContext("2d").drawImage(r,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,0,0,s.width,s.height),o.notify("draw",{prop:"downScale",value:{canvas:s,width:t,height:i}}),e.drawImage(s,0,0)}else e.drawImage(o.baseImgCanvas,o.img.srcLeft,o.img.srcTop,o.img.srcWidth,o.img.srcHeight,0,0,t,i)},e.prototype.updateFrame=function(e,t){if("none"!==this.parent.frameObj.type){var i=e.filter;e.filter="none",this.parent.notify("draw",{prop:"applyFrame",value:{ctx:e,frame:this.parent.frameObj.type,preventImg:t}}),e.filter=i}},e.prototype.downloadImg=function(e,t){var i=document.createElement("a");i.href=e,i.target="_parent",i.download=t,(document.body||document.documentElement).appendChild(i),i.click(),i.parentNode.removeChild(i)},e.prototype.exportTransformedImage=function(e){for(var t=this.parent,i=t.transform.degree,o=0,r=t.rotateFlipColl.length;o<r;o++){var a=t.rotateFlipColl[o];"number"==typeof a?this.exportRotate(e,a):"horizontal"===a?this.exportFlip(e,!0,!1):"vertical"===a&&this.exportFlip(e,!1,!0)}t.transform.degree=i},e.prototype.exportRotate=function(e,t){var i=this.parent;this.setMaxDim(i.transform.degree,e.canvas),e.translate(e.canvas.width/2,e.canvas.height/2),e.rotate(Math.PI/180*t),e.drawImage(i.inMemoryCanvas,-e.canvas.height/2,-e.canvas.width/2,e.canvas.height,e.canvas.width),this.updateSaveContext(e)},e.prototype.exportFlip=function(e,t,i){t&&(e.translate(e.canvas.width,0),e.scale(-1,1)),i&&(e.translate(0,e.canvas.height),e.scale(1,-1)),e.drawImage(this.parent.inMemoryCanvas,0,0),this.updateSaveContext(e)},e.prototype.updateSaveContext=function(e){var t=this.parent.inMemoryCanvas.getContext("2d");e.setTransform(1,0,0,1,0,0);var i=e.getImageData(0,0,e.canvas.width,e.canvas.height);this.parent.inMemoryCanvas.width=i.width,this.parent.inMemoryCanvas.height=i.height,t.putImageData(i,0,0)},e.prototype.setMaxDim=function(e,i){var o,r;e%90==0&&e%180!=0?(o=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.height:this.parent.img.srcHeight,r=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.width:this.parent.img.srcWidth):e%180!=0&&0!==e||(o=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.width:this.parent.img.srcWidth,r=t.isNullOrUndefined(this.parent.currSelectionPoint)?this.parent.baseImgCanvas.height:this.parent.img.srcHeight),t.isNullOrUndefined(this.parent.aspectWidth)||(o=this.parent.aspectWidth,r=this.parent.aspectHeight),i.width=o,i.height=r;var a={width:0,height:0};this.parent.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:o,height:r,obj:a,isImgShape:null}});var n=a;i.style.maxWidth=n.width+"px",i.style.maxHeight=n.height+"px"},e}(),p=function(){function e(e){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue="",this.isBrightnessAdjusted=!1,this.appliedFilter="",this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("filter",this.filter,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("filter",this.filter),this.parent.off("destroyed",this.destroy)},e.prototype.filter=function(e){switch(this.updatePrivateVariables(),e.prop){case"finetuneImage":this.finetuneImage(e.value.option,e.value.value);break;case"applyImageFilter":this.setFilter(e.value.option);break;case"update-finetunes":this.updateFinetunes();break;case"set-adjustment":this.setAdjustment(e.value.operation);break;case"update-filter":this.updateFilter(e.value.operation,e.value.filter);break;case"initFilter":this.initFilter();break;case"setCurrAdjValue":this.setCurrAdjValue(e.value.type,e.value.value);break;case"updateAdj":this.updateAdj(e.value.type,e.value.value,e.value.isPreview,e.value.ctx);break;case"getCurrentObj":this.getCurrentObj(e.value.object);break;case"getAdjustmentLevel":t.isNullOrUndefined(this.parent.activeObj.imageTransparency)?this.adjustmentLevel.transparency=100:this.adjustmentLevel.transparency=100*this.parent.activeObj.imageTransparency,e.value.obj.adjustmentLevel=this.adjustmentLevel;break;case"setAdjustmentLevel":this.adjustmentLevel=e.value.adjustmentLevel;break;case"getTempAdjustmentLevel":e.value.obj.tempAdjustmentLevel=this.tempAdjustmentLevel;break;case"setTempAdjustmentLevel":this.tempAdjustmentLevel=e.value.tempAdjustmentLevel;break;case"setAdjustmentValue":this.adjustmentValue=e.value.adjustmentValue;break;case"getBrightnessAdjusted":e.value.obj.isBrightnessAdjusted=this.isBrightnessAdjusted;break;case"setBrightnessAdjusted":this.isBrightnessAdjusted=e.value.isBrightnessAdjusted,this.parent.currentFilter.split("_")&&"cold"===this.parent.currentFilter.split("_")[1]&&(this.isBrightnessAdjusted=!1);break;case"reset":this.reset()}},e.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d"))},e.prototype.getModuleName=function(){return"filter"},e.prototype.reset=function(){this.adjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.tempAdjustmentLevel={brightness:0,contrast:0,hue:0,opacity:100,saturation:0,blur:0,exposure:0,transparency:100,sharpen:!1,bw:!1},this.adjustmentValue=this.parent.getDefaultFilter(),this.isBrightnessAdjusted=!1,this.appliedFilter=""},e.prototype.updateFinetunes=function(){var e=this.parent,t=e.finetuneSettings;t&&(t.brightness&&(this.adjustmentLevel.brightness=t.brightness.defaultValue,this.tempAdjustmentLevel.brightness=t.brightness.defaultValue),t.contrast&&(this.adjustmentLevel.contrast=t.contrast.defaultValue,this.tempAdjustmentLevel.contrast=t.contrast.defaultValue),t.hue&&(this.adjustmentLevel.hue=t.hue.defaultValue,this.tempAdjustmentLevel.hue=t.hue.defaultValue),t.saturation&&(this.adjustmentLevel.saturation=t.saturation.defaultValue,this.tempAdjustmentLevel.saturation=t.saturation.defaultValue),t.exposure&&(this.adjustmentLevel.exposure=t.exposure.defaultValue,this.tempAdjustmentLevel.exposure=t.exposure.defaultValue),t.opacity&&(this.adjustmentLevel.opacity=t.opacity.defaultValue,this.tempAdjustmentLevel.opacity=t.opacity.defaultValue),t.blur&&(this.adjustmentLevel.blur=t.blur.defaultValue,this.tempAdjustmentLevel.blur=t.blur.defaultValue),e.notify("draw",{prop:"isInitialLoading",onPropertyChange:!1,value:{isInitialLoading:!0}}))},e.prototype.initFilter=function(){this.setFilterAdj("brightness",this.adjustmentLevel.brightness),this.setFilterAdj("contrast",this.adjustmentLevel.contrast),this.setFilterAdj("hue",this.adjustmentLevel.hue),this.setFilterAdj("saturation",this.adjustmentLevel.saturation),this.setFilterAdj("exposure",this.adjustmentLevel.exposure),this.setFilterAdj("opacity",this.adjustmentLevel.opacity),this.setFilterAdj("blur",this.adjustmentLevel.blur)},e.prototype.updateAdj=function(e,i,o,r){var a=this.parent;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height);var n=this.lowerContext.filter.split(" "),s=[];n[4]&&parseFloat(n[4].split("(")[1]),n[0]&&parseFloat(n[0].split("(")[1]);var l=this.getFilterValue(this.adjustmentLevel.brightness);if(-1===["brightness","contrast","hue","saturation","exposure","opacity","blur"].indexOf(e)&&t.isNullOrUndefined(o)&&(this.adjustmentLevel.sharpen||this.adjustmentLevel.bw)){a.isUndoRedo=!0;var p=this.lowerContext.filter;this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=p,a.isUndoRedo=!1}var h,c,d,v,u;switch(e){case"brightness":i=this.getFilterValue(this.adjustmentLevel.exposure)+.005*i,n[0]="brightness("+i+")",0!==this.adjustmentLevel.brightness?(i=this.adjustmentLevel.opacity/100-.3*this.adjustmentLevel.opacity/100,n[4]="opacity("+i+")"):(i=this.adjustmentLevel.opacity/100,n[4]="opacity("+i+")"),this.adjustmentValue=n.join(" ");break;case"contrast":n[1]="contrast("+i+"%)",this.adjustmentValue=n.join(" ");break;case"hue":n[2]="hue-rotate("+i+"deg)",this.adjustmentValue=n.join(" ");break;case"saturation":n[3]="saturate("+i+"%)",this.adjustmentValue=n.join(" ");break;case"opacity":1!==parseFloat(n[0].split("(")[1])&&(i-=.2),n[4]="opacity("+i+")",i,this.adjustmentValue=n.join(" ");break;case"blur":n[5]="blur("+i+"px)",this.adjustmentValue=n.join(" ");break;case"exposure":i>1?(i-=1,i+=l):i<1&&(i=l-(i=1-i)),n[0]="brightness("+i+")",this.adjustmentValue=n.join(" ");break;case"chrome":h=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(h*=100)+.4*h,n[3]="saturate("+i+"%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"cold":c=this.getFilterValue(this.adjustmentLevel.brightness),i=.9*(c*=100),i*=.01,n[0]="brightness("+i+")",v=this.getFilterValue(this.adjustmentLevel.contrast),i=(v*=100)+.5*v,n[1]="contrast("+i+"%)",u=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=u*=100,n[3]="saturate("+i+"%)",s=this.adjustmentValue.split(" "),n[2]=s[2],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"warm":d=this.getSaturationFilterValue(this.adjustmentLevel.saturation),i=(d*=100)+.4*d,n[3]="saturate("+i+"%)",n[6]="sepia(25%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[4]=s[4],n[5]=s[5],n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"grayscale":n[7]="grayscale(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[8]="invert(0%)";break;case"sepia":n[6]="sepia(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[7]="grayscale(0%)",n[8]="invert(0%)";break;case"invert":n[8]="invert(100%)",s=this.adjustmentValue.split(" "),n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]="sepia(0%)",n[7]="grayscale(0%)"}if("sharpen"!==e&&"blackandwhite"!==e){t.isNullOrUndefined(o)&&("default"===e&&(n=this.getDefaultCurrentFilter(n)),this.lowerContext.filter=n.join(" ")),n=this.setTempFilterValue(l,o,n,e),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.appliedFilter=this.lowerContext.filter,a.notify("draw",{prop:"drawImage",onPropertyChange:!1}),a.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),a.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),n=this.setTempFilterValue(l,o,n,e),t.isNullOrUndefined(o)&&(this.lowerContext.filter=n.join(" ")),a.initialAdjustmentValue=n.join(" ");var g=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=g,a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),this.isBrightnessAdjusted=1!==l}var b=n.join(" ");r&&(r.filter=b)},e.prototype.setTempFilterValue=function(e,t,i,o){if(t)if("default"===o)i=this.getDefaultCurrentFilter(i);else if(1!==e){var r=this.lowerContext.filter.split(" ");r[4]=i[4],this.lowerContext.filter=r.join(" ")}return i},e.prototype.getDefaultCurrentFilter=function(e){var t=this.adjustmentValue.split(" ");return[t[0],t[1],t[2],t[3],t[4],t[5],"sepia(0%)","grayscale(0%)","invert(0%)"]},e.prototype.getFilterValue=function(e){return 0===e?1:1+.5*e/100},e.prototype.getSaturationFilterValue=function(e){return 0===e?1:1+e/100},e.prototype.setFilterAdj=function(e,i){var o=this.parent;switch(o.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1}),this.adjustmentLevel[""+e]=i,e){case"contrast":case"exposure":i=this.getFilterValue(i),"contrast"===e&&(i*=100);break;case"hue":i*=3;break;case"saturation":i=100*this.getSaturationFilterValue(i);break;case"opacity":i>=50?i/=100:40===i?i=.45:30===i?i=.4:20===i?i=.35:10===i?i=.3:0===i&&(i=.25);break;case"blur":0!==i&&(i/=20,i+=.5)}var r=t.extend({},o.cropObj,{},!0),a=this.getCurrentObj();a.objColl=t.extend([],o.objColl,[],!0),a.pointColl=t.extend([],o.pointColl,[],!0),a.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.updateAdj(e,i),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})},e.prototype.setFilter=function(e){var i=this.parent;e=e.toLowerCase(),i.notify("freehand-draw",{prop:"apply-pen-draw",onPropertyChange:!1});var o={currentFilter:this.parent.currentFilter}.currentFilter,r=t.extend({},i.cropObj,{},!0),a=this.getCurrentObj();a.objColl=t.extend([],i.objColl,[],!0),a.pointColl=t.extend([],i.pointColl,[],!0),a.afterCropActions=t.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.updateAdj(e,null),i.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:e,previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:o,isCircleCrop:null}})},e.prototype.setAdjustment=function(e){var t,i,o=this.lowerContext.filter.split(" ");switch(e){case"brightness":i=o[0].split("("),t=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.brightness=this.setFilterValue(t);break;case"contrast":i=o[1].split("("),t=parseFloat(i[1].split(")")[0]),t/=100,this.adjustmentLevel.contrast=this.setFilterValue(t);break;case"hue":i=o[2].split("("),t=parseFloat(i[1].split(")")[0]),t/=3,this.adjustmentLevel.hue=t;break;case"saturation":i=o[3].split("("),t=parseFloat(i[1].split(")")[0]),t/=100,this.adjustmentLevel.saturation=this.setSaturationFilterValue(t);break;case"opacity":i=o[4].split("("),.45===(t=parseFloat(i[1].split(")")[0]))?t=40:.4===t?t=30:.35===t?t=20:.3===t?t=10:.25===t?t=0:t*=100,this.adjustmentLevel.opacity=t;break;case"blur":i=o[5].split("("),t=parseFloat(i[1].split(")")[0]),t*=20,this.adjustmentLevel.blur=t;break;case"exposure":i=o[0].split("("),t=parseFloat(i[1].split(")")[0]),this.adjustmentLevel.exposure=this.setFilterValue(t)}},e.prototype.setFilterValue=function(e){return Math.round(1===e?0:100*(e-1)/.5)},e.prototype.setSaturationFilterValue=function(e){return Math.round(1===e?0:100*(e-1))},e.prototype.updateFilter=function(e,t){var i=this.parent;if(-1!==["default","chrome","cold","warm","grayscale","blackandwhite","sepia","invert","sharpen"].indexOf(e)){var o=i.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");o&&o.classList.remove("e-selected");var r=document.getElementById(i.element.id+"_"+e+"Canvas");r&&r.parentElement.classList.add("e-selected"),this.parent.currentFilter=t||i.element.id+"_"+e}},e.prototype.finetuneImage=function(e,t){var i=this.parent;if(!i.disabled&&i.isImageLoaded){switch(e.toLowerCase()){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}this.parent.canvasFilter=this.lowerContext.filter,i.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},e.prototype.setCurrAdjValue=function(e,t){switch(this.parent.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),e){case"brightness":this.setFilterAdj("brightness",t);break;case"contrast":this.setFilterAdj("contrast",t);break;case"hue":this.setFilterAdj("hue",t);break;case"saturation":this.setFilterAdj("saturation",t);break;case"opacity":this.setFilterAdj("opacity",t);break;case"blur":this.setFilterAdj("blur",t);break;case"exposure":this.setFilterAdj("exposure",t)}},e.prototype.getCurrentObj=function(e){var i=this.parent,o={point:null};i.notify("crop",{prop:"getTempFlipPanPoint",value:{obj:o}});var r={previousZoomValue:null};i.notify("transform",{prop:"getPreviousZoomValue",value:{obj:r}});var a={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:this.isBrightnessAdjusted,aspectWidth:null,aspectHeight:null};return a.cropZoom=i.transform.cropZoomFactor,a.defaultZoom=i.transform.defaultZoomFactor,a.zoomFactor=i.zoomSettings.zoomFactor,a.previousZoomValue=r.previousZoomValue,a.totalPannedPoint=t.extend({},i.panPoint.totalPannedPoint,{},!0),a.totalPannedClientPoint=t.extend({},i.panPoint.totalPannedClientPoint,{},!0),a.totalPannedInternalPoint=t.extend({},i.panPoint.totalPannedInternalPoint,{},!0),a.tempFlipPanPoint=t.extend({},o.point,{},!0),a.activeObj=t.extend({},i.activeObj,{},!0),a.rotateFlipColl=t.extend([],i.rotateFlipColl,[],!0),a.degree=i.transform.degree,a.currFlipState=i.transform.currFlipState,a.destPoints={startX:i.img.destLeft,startY:i.img.destTop,endX:0,endY:0,width:i.img.destWidth,height:i.img.destHeight},a.srcPoints={startX:i.img.srcLeft,startY:i.img.srcTop,endX:0,endY:0,width:i.img.srcWidth,height:i.img.srcHeight},a.filter=this.lowerContext.filter,a.aspectWidth=i.aspectWidth,a.aspectHeight=i.aspectHeight,a.frame=i.frameObj.type,a.frameObj=t.extend({},i.frameObj),e&&(e.currObj=a),a},e}(),h=function(){function i(e){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=!1,this.freehandDownPoint={x:0,y:0},this.isFreehandPointMoved=!1,this.pointCounter=0,this.selPointColl={},this.currFHDIdx=0,this.selPoints=[],this.dummyPoints=[],this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null},this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("freehand-draw",this.draw,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("freehand-draw",this.draw),this.parent.off("destroyed",this.destroy)},i.prototype.draw=function(e){switch(this.updateFhdPvtVar(),e.prop){case"hoverFhd":this.hoverFhd(e.value.strokeColor,e.value.strokeWidth);break;case"freehandDownHandler":this.freehandDownHandler(e.value.e,e.value.canvas);break;case"freehandUpHandler":this.freehandUpHandler(e.value.e,e.value.canvas,e.value.context);break;case"handle-freehand-draw":var i=parseInt(e.value.id.split("_")[1],10)-1;this.isFHDIdx(i)&&this.deleteFhd(i,!0);break;case"freehandRedraw":this.freehandRedraw(e.value.context,e.value.points);break;case"deleteFhd":i=parseInt(e.value.id.split("_")[1],10)-1;this.deleteFhd(i,!0);break;case"selectFhd":i=null;e.value.id&&(i=parseInt(e.value.id.split("_")[1],10)-1),this.selectFhd(i);break;case"applyFhd":this.applyFhd();break;case"cancelFhd":this.cancelFhd();break;case"updateFHDCurPts":this.updateFHDCurPts();break;case"rotateFhdColl":this.rotateFhdColl();break;case"flipFHDColl":this.flipFHDColl(e.value.value);break;case"panFHDColl":this.panFHDColl(e.value.xDiff,e.value.yDiff,e.value.panRegion);break;case"updateFHDColl":this.updateFHDColl();break;case"zoomFHDColl":this.zoomFHDColl(e.value.isPreventApply);break;case"apply-pen-draw":this.applyPenDraw();break;case"freeHandDraw":this.freeHandDraw(e.value.value);break;case"isFHDIdx":this.isFHDIdx(e.value.index,e.value.obj);break;case"getSqPtFD":this.getSqPtFD(e.value.idx,e.value.obj);break;case"getSelPointColl":e.value.obj.selPointColl=t.extend([],this.selPointColl);break;case"setSelPointColl":this.selPointColl=t.extend([],e.value.obj.selPointColl);break;case"setFreehandDrawHoveredIndex":this.fhdHovIdx=e.value.index;break;case"getFreehandDrawHoveredIndex":e.value.obj.index=this.fhdHovIdx;break;case"setPointCounter":this.pointCounter=e.value.value;break;case"getPenStrokeWidth":e.value.obj.penStrokeWidth=this.penStrokeWidth;break;case"setPenStrokeWidth":this.penStrokeWidth=e.value.value;break;case"getCurrentFreehandDrawIndex":e.value.obj.currentFreehandDrawIndex=this.currFHDIdx;break;case"setCurrentFreehandDrawIndex":this.currFHDIdx=e.value.value;break;case"updateCropPtsForSel":this.updateCropPtsForSel();break;case"getFreehandDrawSelectedId":e.value.obj.freehandDrawSelectedId=this.fhdSelID;break;case"resetFreehandDrawSelectedId":this.fhdSelID=null;break;case"getTempFreeHandDrawEditingStyles":e.value.obj.tempFreeHandDrawEditingStyles=this.tempFHDStyles;break;case"setFreehandSelectedIndex":this.fhdSelIdx=e.value.index;break;case"getFreehandSelectedIndex":e.value.obj.freehandSelectedIndex=this.fhdSelIdx;break;case"reset":this.reset()}},i.prototype.updateFhdPvtVar=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.fhdObj={lastWidth:0,lastVelocity:0,time:0,pointX:0,pointY:0},this.isFreehandDrawing=this.isFreehandPointMoved=!1,this.selPoints=[],this.dummyPoints=[],this.freehandDownPoint={x:0,y:0},this.selPointColl={},this.fhdHovIdx=null,this.pointCounter=0,this.fhdSelID=null,this.penStrokeWidth=void 0,this.currFHDIdx=0,this.fhdSelIdx=null,this.tempFHDStyles={strokeColor:null,fillColor:null,strokeWidth:null}},i.prototype.getModuleName=function(){return"freehand-draw"},i.prototype.hoverFhd=function(e,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=this.upperContext,a=-1;a=this.fhdHovIdx>-1?this.fhdHovIdx:this.fhdSelIdx,o.points=t.extend([],o.pointColl[a].points),this.pointCounter=0;var n,s,l,p,h=o.points.length,c=0,d=0;r.fillStyle=e||o.pointColl[a].strokeColor,r.strokeStyle=r.fillStyle,c=d=this.penStrokeWidth=i||o.pointColl[a].strokeWidth,1===h&&(n=s=l=p=o.points[0],this.startDraw(r,n,s,l,p,c,d));for(var v=0;v<h-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(n=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,s=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,l=0===v?o.points[v]:o.points[v+1],p=o.points[v+2],this.startDraw(r,n,s,l,p,c,d));r.closePath();var u=this.getSqPtFD(a),g=r.lineWidth;r.lineWidth=2,r.strokeStyle=o.themeColl[o.theme].primaryColor,r.beginPath(),r.rect(u.startX,u.startY,u.width,u.height),r.stroke(),r.closePath(),r.lineWidth=g},i.prototype.freehandDownHandler=function(i,o){this.parent.lowerCanvas=document.querySelector("#"+this.parent.element.id+"_lowerCanvas"),this.lowerContext=this.parent.lowerCanvas.getContext("2d"),this.parent.upperCanvas=document.querySelector("#"+this.parent.element.id+"_upperCanvas"),this.upperContext=this.parent.upperCanvas.getContext("2d"),this.fhdObj.time=(new Date).getTime(),this.isFreehandDrawing=!0,"mousedown"===i.type?this.freehandDownPoint={x:i.clientX,y:i.clientY}:this.freehandDownPoint={x:i.touches[0].clientX,y:i.touches[0].clientY},this.isFreehandPointMoved=!1,t.EventHandler.add(o,"mousemove touchmove",this.freehandMoveHandler,this);var r={id:"pen_"+(this.currFHDIdx+1),type:e.ShapeType.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:this.parent.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:null},a={action:"draw-start",previousShapeSettings:r,currentShapeSettings:r};this.triggerShapeChanging(a)},i.prototype.freehandUpHandler=function(i,o,r){var a=o.getBoundingClientRect(),n=this.parent;t.EventHandler.remove(o,"mousemove touchmove",this.freehandMoveHandler),0===n.points.length&&("mouseup"===i.type?this.processPoint(i.clientX-a.left,i.clientY-a.top,!0,r):"touchend"===i.type&&i.changedTouches?this.processPoint(i.changedTouches[0].clientX-a.left,i.changedTouches[0].clientY-a.top,!0,r):this.isFreehandPointMoved||this.processPoint(this.freehandDownPoint.x-a.left,this.freehandDownPoint.y-a.top,!0,r)),r.closePath();var s=t.extend({},n.cropObj,{},!0),l={currObj:{}};n.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:l}});var p=l.currObj;p.objColl=t.extend([],n.objColl,[],!0),p.pointColl=t.extend([],n.pointColl,[],!0),p.afterCropActions=t.extend([],n.afterCropActions,[],!0);var h={selPointColl:null};n.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),p.selPointColl=t.extend([],h.selPointColl,[],!0);var c=n.freehandCounter;n.pointColl[c]={},n.pointColl[c].points=t.extend([],n.points),n.pointColl[c].strokeColor=n.activeObj.strokeSettings.strokeColor,n.pointColl[c].strokeWidth=this.penStrokeWidth,n.pointColl[c].flipState=n.transform.currFlipState,n.pointColl[c].id="pen_"+(this.currFHDIdx+1),n.points=[],this.dummyPoints=[],this.selPointColl[c]={},this.selPointColl[c].points=t.extend([],this.selPoints),this.selPoints=[],this.pointCounter=0,n.freehandCounter++,this.isFreehandDrawing=!1,n.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehand-draw",previousObj:p,previousObjColl:p.objColl,previousPointColl:p.pointColl,previousSelPointColl:p.selPointColl,previousCropObj:s,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}});var d={id:"pen_"+(this.currFHDIdx+1),type:e.ShapeType.FreehandDraw,startX:this.freehandDownPoint.x,startY:this.freehandDownPoint.y,strokeColor:this.parent.activeObj.strokeSettings.strokeColor,strokeWidth:this.penStrokeWidth,points:this.parent.pointColl[this.currFHDIdx].points},v={action:"draw-end",previousShapeSettings:d,currentShapeSettings:d};this.triggerShapeChanging(v),this.currFHDIdx++},i.prototype.freehandMoveHandler=function(e){this.isFreehandPointMoved=!0;var t,i,o=this.parent.upperCanvas.getBoundingClientRect();"mousemove"===e.type?(t=e.clientX-o.left,i=e.clientY-o.top):(t=e.touches[0].clientX-o.left,i=e.touches[0].clientY-o.top),this.isFreehandDrawing&&(this.upperContext.fillStyle=this.parent.activeObj.strokeSettings.strokeColor,this.processPoint(t,i,!1,this.upperContext))},i.prototype.processPoint=function(e,i,o,r){var a,n,s,l,p=this.parent,h=this.point(e,i,(new Date).getTime()),c=!!(h=p.points.length>0&&p.points[p.points.length-1])&&this.distanceTo(h)<=5;if(this.selPoints.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),!h||!h||!c||o){if(this.fhdObj.time=(new Date).getTime(),p.points.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.push({x:e,y:i,ratioX:(e-p.img.destLeft)/p.img.destWidth,ratioY:(i-p.img.destTop)/p.img.destHeight,time:this.fhdObj.time}),this.dummyPoints.length>2){3===this.dummyPoints.length&&this.dummyPoints.unshift(this.dummyPoints[0]);var d=this.dummyPoints[0],v=this.dummyPoints[1],u=this.dummyPoints[2],g=this.dummyPoints[3];a=this.calcCurveCP(d,v,u).controlPoint2,n=this.calcCurveCP(v,u,g).controlPoint1,s=this.dummyPoints[1],l=this.dummyPoints[2];var b=.5,f=5;t.isNullOrUndefined(this.penStrokeWidth)||(b=f=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,f),this.pointCounter++,this.dummyPoints.shift()}if(o){a=n=s=l={x:e,y:i,time:(new Date).getTime()};b=.5,f=5;t.isNullOrUndefined(this.penStrokeWidth)||(b=f=this.penStrokeWidth),this.startDraw(r,a,n,s,l,b,f)}}},i.prototype.calcCurveCP=function(e,t,i){t||(t=e),i||(i=t);var o=e.x-t.x,r=e.y-t.y,a=t.x-i.x,n=t.y-i.y,s=(e.x+t.x)/2,l=(e.y+t.y)/2,p=(t.x+i.x)/2,h=(t.y+i.y)/2,c=Math.sqrt(o*o+r*r),d=Math.sqrt(a*a+n*n),v=d/(c+d),u=p+(s-p)*v,g=h+(l-h)*v,b=t.x-u,f=t.y-g;return{controlPoint1:this.point(s+b,l+f,0),controlPoint2:this.point(p+b,h+f,0)}},i.prototype.point=function(e,t,i){return this.fhdObj.pointX=e,this.fhdObj.pointY=t,{x:this.fhdObj.pointX,y:this.fhdObj.pointY,time:i}},i.prototype.startDraw=function(e,t,i,o,r,a,n){var s;s=.7*(s=this.pointVelocity(o))+(1-.7)*this.fhdObj.lastVelocity;var l=Math.max(n/1.7,a);this.drawCurve(this.fhdObj.time,l,e,t,i,o,r,n),this.fhdObj.lastVelocity=s,this.fhdObj.time=l},i.prototype.pointVelocity=function(e){return this.fhdObj.time!==e.time?this.distanceTo(e)/(this.fhdObj.time-e.time):0},i.prototype.distanceTo=function(e){return Math.sqrt(Math.pow(this.fhdObj.pointX-e.x,2)+Math.pow(this.fhdObj.pointY-e.y,2))},i.prototype.drawCurve=function(e,t,i,o,r,a,n,s){var l,p,h,c,d,v,u,g,b,f,m=t-e,C=this.bezierLength(o,r,a,n),y=2*Math.ceil(C);for(i.beginPath(),p=0;p<y;p++)d=(c=(h=p/y)*h)*h,b=(g=(u=(v=1-h)*v)*v)*a.x,b+=3*u*h*o.x,b+=3*v*c*r.x,b+=d*n.x,f=g*a.y,f+=3*u*h*o.y,f+=3*v*c*r.y,f+=d*n.y,l=Math.min(e+d*m,s),this.drawArc(b,f,l,i);i.closePath(),i.fill()},i.prototype.bezierLength=function(e,t,i,o){var r,a,n,s,l,p,h,c,d=0;for(r=0;r<=10;r++)a=r/10,n=this.bezierPoint(a,i.x,e.x,t.x,o.x),s=this.bezierPoint(a,i.y,e.y,t.y,o.y),r>0&&(h=n-l,c=s-p,d+=Math.sqrt(h*h+c*c)),l=n,p=s;return d},i.prototype.bezierPoint=function(e,t,i,o,r){return t*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*o*(1-e)*e*e+r*e*e*e},i.prototype.drawArc=function(e,t,i,o){(e>this.parent.img.destLeft&&t>this.parent.img.destTop&&e<this.parent.img.destLeft+this.parent.img.destWidth&&t<this.parent.img.destTop+this.parent.img.destHeight||o!==this.lowerContext&&o!==this.upperContext)&&(o.moveTo(e,t),o.arc(e,t,i,0,2*Math.PI,!1))},i.prototype.freehandRedraw=function(e,i){var o=this.parent;o.lowerCanvas=document.querySelector("#"+o.element.id+"_lowerCanvas"),this.lowerContext=o.lowerCanvas.getContext("2d"),o.upperCanvas=document.querySelector("#"+o.element.id+"_upperCanvas"),this.upperContext=o.upperCanvas.getContext("2d");var r=e.filter;if(e.filter="none",i&&(o.pointColl[o.freehandCounter]={},o.pointColl[o.freehandCounter].points=i,o.pointColl[o.freehandCounter].strokeColor=o.activeObj.strokeSettings.strokeColor,o.pointColl[o.freehandCounter].strokeWidth=this.penStrokeWidth,o.pointColl[o.freehandCounter].flipState=o.transform.currFlipState,o.freehandCounter++),o.freehandCounter>0){for(var a=0;a<o.freehandCounter;a++){o.points=t.extend([],o.pointColl[a].points),this.pointCounter=0;var n=o.points.length,s=void 0,l=void 0,p=void 0,h=void 0,c=void 0,d=void 0;n>0&&(e.fillStyle=o.pointColl[a].strokeColor,c=d=this.penStrokeWidth=o.pointColl[a].strokeWidth),1===n&&(s=l=p=h=o.points[0],this.startDraw(e,s,l,p,h,c,d));for(var v=0;v<n-3;v++)o.points[v+1]&&o.points[v+2]&&o.points[v+2]&&(s=this.calcCurveCP(o.points[v+0],o.points[v+1],o.points[v+2]).controlPoint2,l=this.calcCurveCP(o.points[v+1],o.points[v+2],o.points[v+3]).controlPoint1,p=0===v?o.points[v]:o.points[v+1],h=o.points[v+2],this.startDraw(e,s,l,p,h,c,d));e.closePath()}e!==this.upperContext&&(o.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:o.frameObj.type,preventImg:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height))}e.filter=r},i.prototype.getSqPtFD=function(e,i){var o={startX:0,startY:0,endX:0,endY:0,width:0,height:0},r=t.extend([],this.selPointColl[e].points,[]);this.parent.points=t.extend([],this.parent.pointColl[e].points),this.pointCounter=0;for(var a=r.length,n=0;n<a;n++)0===o.startX&&0===o.startY&&0===o.endX&&0===o.endY?(o.startX=r[n].x,o.startY=r[n].y,o.endX=r[n].x,o.endY=r[n].y):(o.startX=Math.min(o.startX,r[n].x),o.startY=Math.min(o.startY,r[n].y),o.endX=Math.max(o.endX,r[n].x),o.endY=Math.max(o.endY,r[n].y));return o.startX-=this.penStrokeWidth,o.startY-=this.penStrokeWidth,o.endX+=this.penStrokeWidth,o.endY+=this.penStrokeWidth,o.width=o.endX-o.startX,o.height=o.endY-o.startY,i&&(i.activePoint=o),o},i.prototype.applyPenDraw=function(){var e=this.parent;"freehanddraw"===e.currObjType.shape&&(e.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),e.upperCanvas.style.cursor=e.cursor="default",e.currObjType.shape=""),e.notify("shape",{prop:"clearActObj"})},i.prototype.applyFhd=function(){var e=this.parent,i=e.pointColl[this.fhdSelIdx];"#42a5f5"===i.strokeColor&&(i.strokeColor=this.tempFHDStyles.strokeColor),t.isBlazor()||e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()||e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i&&(i.isSelected=!1),e.notify("selection",{prop:"resetFreehandDrawVariables"}),this.fhdHovIdx=this.fhdSelIdx=null},i.prototype.cancelFhd=function(){var e=this.parent;t.isBlazor()||e.notify("toolbar",{prop:"setSelectedFreehandColor",value:{color:"#42a5f5"}}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),this.pointCounter=0,e.pointColl[this.fhdSelIdx]&&(e.pointColl[this.fhdSelIdx].strokeColor=this.tempFHDStyles.strokeColor,e.pointColl[this.fhdSelIdx].strokeWidth=this.tempFHDStyles.strokeWidth,e.pointColl[this.fhdSelIdx].isSelected=!1),this.fhdHovIdx=this.fhdSelIdx=this.fhdSelID=null,e.notify("selection",{prop:"resetFreehandDrawVariables"}),e.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor,e.activeObj.strokeSettings.strokeWidth=this.penStrokeWidth=this.tempFHDStyles.strokeWidth,this.tempFHDStyles={strokeColor:null,strokeWidth:null,fillColor:null},t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},i.prototype.selectFhd=function(t){var i=this.parent;if(i.notify("selection",{prop:"setFreehandDrawEditing",onPropertyChange:!1,value:{bool:!0}}),t||0===t){if(!this.isFHDIdx(t))return;this.fhdSelIdx=this.fhdHovIdx=t,this.hoverFhd(),i.upperCanvas.style.cursor=i.cursor="pointer"}this.fhdSelIdx=this.fhdHovIdx,i.pointColl[this.fhdSelIdx].isSelected=!0,this.fhdSelID=i.pointColl[this.fhdSelIdx].id,"#42a5f5"!==i.pointColl[this.fhdHovIdx].strokeColor&&(i.activeObj.strokeSettings.strokeColor=this.tempFHDStyles.strokeColor=i.pointColl[this.fhdHovIdx].strokeColor),i.activeObj.strokeSettings.strokeWidth=this.tempFHDStyles.strokeWidth=i.pointColl[this.fhdHovIdx].strokeWidth;var o={bool:!1};if(i.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:o}}),o.bool){var r={id:"pen_"+(this.fhdSelIdx+1),type:e.ShapeType.FreehandDraw,startX:i.pointColl[this.fhdSelIdx].points[0].x,startY:i.pointColl[this.fhdSelIdx].points[0].y,strokeColor:i.pointColl[this.fhdSelIdx].strokeColor,strokeWidth:i.pointColl[this.fhdSelIdx].strokeWidth,points:i.pointColl[this.fhdSelIdx].points},a={action:"select",previousShapeSettings:r,currentShapeSettings:r};this.triggerShapeChanging(a)}else i.okBtn()},i.prototype.deleteFhd=function(e,i){var o=this.parent;if(this.isFHDIdx(e)){this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);var r=t.extend({},o.pointColl,{},!0),a=t.extend({},this.selPointColl,{},!0);o.pointColl={},this.selPointColl={};var n=0;if(t.isNullOrUndefined(i))for(var s=0;s<o.freehandCounter;s++)s!==e&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);else for(s=0;s<o.freehandCounter;s++)parseInt(r[s].id.split("_")[1],10)-1!==e&&(o.pointColl[n]=r[s],this.selPointColl[n]=a[s],n++);o.freehandCounter-=1,this.fhdHovIdx=this.fhdSelIdx=null,o.notify("selection",{prop:"resetFreehandDrawVariables"}),o.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.zoomX=function(e){return e*this.parent.img.destWidth+this.parent.img.destLeft},i.prototype.zoomY=function(e){return e*this.parent.img.destHeight+this.parent.img.destTop},i.prototype.zoomFHDColl=function(e){for(var i=this.parent,o=0;o<i.freehandCounter;o++){i.points=t.extend([],i.pointColl[o].points,[]),this.pointCounter=0;for(var r=i.points.length,a=0;a<r;a++)i.points[a].x=this.zoomX(i.points[a].ratioX),i.points[a].y=this.zoomY(i.points[a].ratioY)}this.updateFHDCurPts(),t.isNullOrUndefined(e)&&this.freehandRedraw(this.lowerContext,null)},i.prototype.updateFHDCurPts=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(var o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x=this.zoomX(this.selPoints[r].ratioX),this.selPoints[r].y=this.zoomY(this.selPoints[r].ratioY)}},i.prototype.rotateFhdColl=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].y=e.img.destTop+e.img.destHeight*e.points[r].ratioX,e.points[r].x=e.img.destLeft+e.img.destWidth-e.img.destWidth*e.points[r].ratioY,e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y=e.img.destTop+e.img.destHeight*this.selPoints[r].ratioX,this.selPoints[r].x=e.img.destLeft+e.img.destWidth-e.img.destWidth*this.selPoints[r].ratioY,this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.flipFHDColl=function(e){var t=e.toLowerCase();if("horizontal"===t)this.pointsHorizontalFlip();else if("vertical"===t)this.pointsVerticalFlip();else{this.pointsHorizontalFlip();for(var i=0;i<this.parent.freehandCounter;i++)this.parent.pointColl[i].shapeFlip="";this.pointsVerticalFlip()}},i.prototype.pointsHorizontalFlip=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(e.pointColl[i].shapeFlip!==e.transform.currFlipState){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].x<=e.img.destLeft+e.img.destWidth/2?e.points[r].x=e.img.destLeft+e.img.destWidth-(e.points[r].x-e.img.destLeft):e.points[r].x>=e.img.destLeft+e.img.destWidth/2&&(e.points[r].x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-e.points[r].x)),e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight;e.pointColl[i].shapeFlip=e.transform.currFlipState}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==e.transform.currFlipState){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].x<=e.img.destLeft+e.img.destWidth/2?this.selPoints[r].x=e.img.destLeft+e.img.destWidth-(this.selPoints[r].x-e.img.destLeft):this.selPoints[r].x>=e.img.destLeft+e.img.destWidth/2&&(this.selPoints[r].x=e.img.destLeft+(e.img.destLeft+e.img.destWidth-this.selPoints[r].x)),this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.pointsVerticalFlip=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++)if(e.pointColl[i].shapeFlip!==e.transform.currFlipState){e.points=t.extend([],e.pointColl[i].points,[]),this.pointCounter=0;for(var o=e.points.length,r=0;r<o;r++)e.points[r].y<=e.img.destTop+e.img.destHeight/2?e.points[r].y=e.img.destTop+e.img.destHeight-(e.points[r].y-e.img.destTop):e.points[r].y>=e.img.destTop+e.img.destHeight/2&&(e.points[r].y=e.img.destTop+(e.img.destTop+e.img.destHeight-e.points[r].y)),e.points[r].ratioX=(e.points[r].x-e.img.destLeft)/e.img.destWidth,e.points[r].ratioY=(e.points[r].y-e.img.destTop)/e.img.destHeight;e.pointColl[i].shapeFlip=e.transform.currFlipState}for(i=0;i<e.freehandCounter;i++)if(this.selPointColl[i]&&this.selPointColl[i].shapeFlip!==e.transform.currFlipState){this.selPoints=t.extend([],this.selPointColl[i].points,[]),this.pointCounter=0;for(o=this.selPoints.length,r=0;r<o;r++)this.selPoints[r].y<=e.img.destTop+e.img.destHeight/2?this.selPoints[r].y=e.img.destTop+e.img.destHeight-(this.selPoints[r].y-e.img.destTop):this.selPoints[r].y>=e.img.destTop+e.img.destHeight/2&&(this.selPoints[r].y=e.img.destTop+(e.img.destTop+e.img.destHeight-this.selPoints[r].y)),this.selPoints[r].ratioX=(this.selPoints[r].x-e.img.destLeft)/e.img.destWidth,this.selPoints[r].ratioY=(this.selPoints[r].y-e.img.destTop)/e.img.destHeight}this.updateFHDCurPts()},i.prototype.updateFHDColl=function(){for(var e=this.parent,i=0;i<e.objColl.length;i++){if(e.objColl[i].imageRatio={startX:(e.objColl[i].activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(e.objColl[i].activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(e.objColl[i].activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(e.objColl[i].activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/e.objColl[i].activePoint.width,height:e.img.destHeight/e.objColl[i].activePoint.height},"path"===e.objColl[i].shape)for(var o=0;o<e.objColl[i].pointColl.length;o++)e.objColl[i].pointColl[o].ratioX=(e.objColl[i].pointColl[o].x-e.img.destLeft)/e.img.destWidth,e.objColl[i].pointColl[o].ratioY=(e.objColl[i].pointColl[o].y-e.img.destTop)/e.img.destHeight;e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})}for(var r=0;r<e.freehandCounter;r++){e.points=t.extend([],e.pointColl[r].points,[]),this.pointCounter=0;for(var a=e.points.length,n=0;n<a;n++)e.points[n].ratioX=(e.points[n].x-e.img.destLeft)/e.img.destWidth,e.points[n].ratioY=(e.points[n].y-e.img.destTop)/e.img.destHeight}for(r=0;r<e.freehandCounter;r++)if(this.selPointColl[r]){this.selPoints=t.extend([],this.selPointColl[r].points,[]),this.pointCounter=0;for(a=this.selPoints.length,n=0;n<a;n++)this.selPoints[n].ratioX=(this.selPoints[n].x-e.img.destLeft)/e.img.destWidth,this.selPoints[n].ratioY=(this.selPoints[n].y-e.img.destTop)/e.img.destHeight}},i.prototype.panFHDColl=function(e,i,o){for(var r=this.parent,a=0;a<r.freehandCounter;a++){r.points=t.extend([],r.pointColl[a].points,[]),this.pointCounter=0;for(var n=r.points.length,s=0;s<n;s++)""===o||"vertical"===o?r.points[s].x+=e:r.points[s].x-=e,""===o||"horizontal"===o?r.points[s].y+=i:r.points[s].y-=i}for(a=0;a<r.freehandCounter;a++)if(this.selPointColl[a]){this.selPoints=t.extend([],this.selPointColl[a].points,[]),this.pointCounter=0;for(n=this.selPoints.length,s=0;s<n;s++)""===o||"vertical"===o?this.selPoints[s].x+=e:this.selPoints[s].x-=e,""===o||"horizontal"===o?this.selPoints[s].y+=i:this.selPoints[s].y-=i}this.freehandRedraw(this.lowerContext,null)},i.prototype.freeHandDraw=function(e){var i=this.parent;if(e){if(i.points=[],this.dummyPoints=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.togglePen=!0,i.upperCanvas.style.cursor=i.cursor="crosshair",i.upperCanvas.style.display="block",t.isNullOrUndefined(i.activeObj.strokeSettings)){var o={strokeSettings:{}};i.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:o}}),i.activeObj.strokeSettings=o.strokeSettings}t.isNullOrUndefined(i.activeObj.strokeSettings.strokeWidth)&&(i.activeObj.strokeSettings.strokeWidth=4),t.isBlazor()?i.updateToolbar(i.element,"pen"):i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}else i.upperCanvas.style.cursor=i.cursor="default",i.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):(i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),i.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}})),i.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}})},i.prototype.isFHDIdx=function(e,t){for(var i=!1,o=0;o<this.parent.freehandCounter;o++)if(this.parent.pointColl[o].id&&parseInt(this.parent.pointColl[o].id.split("_")[1],10)-1===e){i=!0;break}return t&&(t.isIndex=i),i},i.prototype.updateCropPtsForSel=function(){for(var e=this.parent,i=0;i<e.freehandCounter;i++){var o={selPointColl:t.extend([],this.selPointColl)};if(o.selPointColl[i]){this.selPoints=t.extend([],o.selPointColl[i].points,[]),this.pointCounter=0;for(var r=this.selPoints.length,a=0;a<r;a++)this.selPoints[a].ratioX=(this.selPoints[a].x-e.activeObj.activePoint.startX)/e.activeObj.activePoint.width,this.selPoints[a].ratioY=(this.selPoints[a].y-e.activeObj.activePoint.startY)/e.activeObj.activePoint.height}}},i.prototype.triggerShapeChanging=function(e){var i=this,o=this.parent;t.isBlazor()&&o.events&&!0===o.events.shapeChanging.hasDelegate?o.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",e).then(function(e){o.activeObj.strokeSettings.strokeColor=e.currentShapeSettings.strokeColor,i.penStrokeWidth=e.currentShapeSettings.strokeWidth,i.fhdSelID&&(o.pointColl[i.fhdSelIdx].strokeColor=e.currentShapeSettings.strokeColor,o.pointColl[i.fhdSelIdx].strokeWidth=e.currentShapeSettings.strokeWidth,o.pointColl[i.fhdSelIdx].points=e.currentShapeSettings.points),"select"===e.action&&(i.freehandRedraw(i.upperContext),o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"pen"))}):(o.trigger("shapeChanging",e),o.activeObj.strokeSettings.strokeColor=e.currentShapeSettings.strokeColor,this.penStrokeWidth=e.currentShapeSettings.strokeWidth,this.fhdSelID&&(o.pointColl[this.fhdSelIdx].strokeColor=e.currentShapeSettings.strokeColor,o.pointColl[this.fhdSelIdx].strokeWidth=e.currentShapeSettings.strokeWidth,o.pointColl[this.fhdSelIdx].points=e.currentShapeSettings.points),"select"===e.action&&(this.freehandRedraw(this.upperContext),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})))},i}(),c=function(){function i(e){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=!1,this.isObjSelected=!1,this.isFhdPoint=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.isShapeInserted=!1,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.cursorTargetId="",this.isPreventDragging=!1,this.dragElement="",this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.isFhdEditing=!1,this.currentDrawingShape="",this.initialPrevObj={},this.touchTime=0,this.resizedElement="",this.isImageClarity=!0,this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("selection",this.selection,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("selection",this.selection),this.parent.off("destroyed",this.destroy)},i.prototype.selection=function(e){var t=this;switch(this.updatePrivateVariables(),e.prop){case"mouse-up":this.selMouseUpEvent();break;case"setCursor":this.setCursor(e.value.x,e.value.y);break;case"updateActivePoint":this.updateActivePoint(e.value.x,e.value.y,e.value.isCropSelection);break;case"updateCursorStyles":this.updateCursorStyles(e.value.x,e.value.y,e.value.type);break;case"setTextSelection":this.setTextSelection(e.value.width,e.value.height);break;case"setActivePoint":this.setActivePoint(e.value.startX,e.value.startY);break;case"clearSelection":this.clearSelection();break;case"calcShapeRatio":this.calcShapeRatio(e.value.x,e.value.y,e.value.imgWidth,e.value.imgHeight);break;case"applyCurrShape":this.applyCurrShape(e.value.isShapeClick);break;case"tab":this.performTabAction();break;case"setDragDirection":this.setDragDirection(e.value.width,e.value.height);break;case"clearUpperCanvas":this.isTouch&&setTimeout(function(){t.parent.upperCanvas.getContext("2d").clearRect(0,0,t.parent.upperCanvas.width,t.parent.upperCanvas.height)},550);break;case"resetFreehandDrawVariables":this.isFhdEditing=this.isFhdPoint=!1;break;case"isShapeInserted":this.isShapeInserted=e.value.bool;break;case"redrawShape":this.redrawShape(e.value.obj);break;case"setTextBoxStylesToActObj":this.setTextBoxStylesToActObj();break;case"mouseDownEventHandler":this.mouseDownEventHandler(e.value.e);break;case"mouseMoveEventHandler":this.mouseMoveEventHandler(e.value.e);break;case"mouseUpEventHandler":this.mouseUpEventHandler(e.value.e);break;case"canvasMouseDownHandler":this.canvasMouseDownHandler(e.value.e);break;case"canvasMouseMoveHandler":this.canvasMouseMoveHandler(e.value.e);break;case"canvasMouseUpHandler":this.canvasMouseUpHandler(e.value.e);break;case"touchStartHandler":this.touchStartHandler(e.value.e);break;case"keyDownEventHandler":this.keyDownEventHandler(e.value.e);break;case"handleScroll":this.handleScroll(e.value.e);break;case"textKeyDown":setTimeout(this.textKeyDown.bind(this),1,e.value.e);break;case"deleteItem":this.deleteItem();break;case"updatePrevShapeSettings":this.updatePrevShapeSettings(e.value.obj);break;case"getZoomType":e.value.obj.zoomType=this.zoomType;break;case"setZoomType":this.zoomType=e.value.zoomType;break;case"setInitialTextEdit":this.isInitialTextEdited=e.value.bool;break;case"setDragCanvas":this.dragCanvas=e.value.bool;break;case"setFreehandDrawCustomized":this.isFhdCustomized=e.value.isFreehandDrawCustomized;break;case"setTouchEndPoint":this.touchEndPoint.x=e.value.x,this.touchEndPoint.y=e.value.y;break;case"getPanDown":e.value.obj.panDown=this.panDown;break;case"setPanDown":this.panDown=e.value.panDown;break;case"getFreehandDrawEditing":e.value.obj.bool=this.isFhdEditing;break;case"setFreehandDrawEditing":this.isFhdEditing=e.value.bool;break;case"getTempActObj":e.value.obj.tempObj=this.tempActiveObj;break;case"setTempActObj":this.tempActiveObj=e.value.obj;break;case"isInside":this.isInside(e.value.x,e.value.y,e.value.z1,e.value.z2,e.value.z3,e.value.z4);break;case"setDragElement":this.dragElement=e.value.value;break;case"setObjSelected":this.isObjSelected=e.value.bool;break;case"adjustActObjForLineArrow":this.adjustActObjForLineArrow(e.value.obj);break;case"findTarget":this.findTarget(e.value.x,e.value.y,e.value.type);break;case"getCurrentFlipState":this.getCurrentFlipState();break;case"setDragWidth":this.setDragWidth(e.value.width);break;case"setDragHeight":this.setDragHeight(e.value.setDragHeight);break;case"annotate":this.currentDrawingShape=e.value.shape,"text"===e.value.shape?(this.parent.activeObj.textSettings.fontSize=100,this.parent.activeObj.keyHistory="Enter Text",this.parent.notify("shape",{prop:"initializeTextShape",onPropertyChange:!1,value:{text:null,fontFamily:null,fontSize:null,bold:null,italic:null,strokeColor:null}})):"path"===e.value.shape&&(this.parent.activeObj.pointColl=[]);break;case"getCurrentDrawingShape":e.value.obj.shape=this.currentDrawingShape;break;case"setCurrentDrawingShape":this.currentDrawingShape=e.value.value;break;case"getTransRotationPoint":this.getTransRotationPoint(e.value.obj,e.value.object);break;case"adjustNEPoints":this.adjustNEPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"adjustRotationPoints":this.adjustRotationPoints(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"getResizeDirection":this.getResizeDirection(e.value.rectangle,e.value.x,e.value.y,e.value.angle);break;case"setResizedElement":this.resizedElement=e.value.value;break;case"reset":this.reset();break;case"unWireEvent":this.unwireEvent();break;case"updPtCollForShpRot":this.updPtCollForShpRot(e.value.obj);break;case"findImageRatio":this.findImageRatio(e.value.width,e.value.height,e.value.obj);break;case"getNumTextValue":this.getNumTextValue(e.value.obj);break;case"setImageClarity":this.isImageClarity=e.value.bool;break;case"upgradeImageQuality":this.upgradeImageQuality();break;case"triggerShapeChange":this.triggerShapeChange(e.value.shapeResizingArgs,e.value.shapeMovingArgs,e.value.type)}},i.prototype.getModuleName=function(){return"selection"},i.prototype.updatePrivateVariables=function(){var e=this.parent;e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d"))},i.prototype.reset=function(){this.diffPoint={x:0,y:0},this.oldPoint={},this.isTouch=this.isObjSelected=this.isFhdPoint=this.isShapeInserted=!1,this.dragPoint={startX:0,startY:0,endX:0,endY:0},this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]},this.isFirstMove=!1,this.cursorTargetId=this.dragElement="",this.startTouches=[],this.tempTouches=[],this.currMousePoint={x:0,y:0},this.isPreventDragging=!1,this.timer=void 0,this.tempObjColl=void 0,this.textRow=1,this.mouseDownPoint={x:0,y:0},this.previousPoint={x:0,y:0},this.zoomType="Toolbar",this.isInitialTextEdited=!1,this.dragCanvas=!1,this.isFhdCustomized=!1,this.touchEndPoint={},this.panDown=null,this.isFhdEditing=!1,this.pathAdjustedIndex=null,this.touchTime=0,this.isImageClarity=!0,this.currentDrawingShape="",this.initialPrevObj={},this.resizedElement=""},i.prototype.performTabAction=function(){if("block"===this.parent.textArea.style.display){var e=this.applyCurrShape(!1);this.parent.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),e&&this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}},i.prototype.selMouseUpEvent=function(){this.oldPoint.x=void 0,this.oldPoint.y=void 0},i.prototype.getMouseCursor=function(e,t,i,o,r){var a=this.getTransRotationPoint(e),n=r?0:2*e.topLeftCircle.radius;return t>=e.topLeftCircle.startX-n&&t<=e.topLeftCircle.startX+n&&i>=e.topLeftCircle.startY-n&&i<=e.topLeftCircle.startY+n?"nw-resize":t>=e.topLeftCircle.startX-n&&t<=e.topRightCircle.startX-n&&i>=e.topCenterCircle.startY-n&&i<=e.topCenterCircle.startY+n?"n-resize":t>=e.topRightCircle.startX-n&&t<=e.topRightCircle.startX+n&&i>=e.topRightCircle.startY-n&&i<=e.topRightCircle.startY+n?"ne-resize":t>=e.centerLeftCircle.startX-n&&t<=e.centerLeftCircle.startX+n&&i>=e.topLeftCircle.startY-n&&i<=e.bottomLeftCircle.startY-n?"w-resize":t>=e.centerRightCircle.startX-n&&t<=e.centerRightCircle.startX+n&&i>=e.topRightCircle.startY-n&&i<=e.bottomRightCircle.startY-n?"e-resize":t>=e.bottomLeftCircle.startX-n&&t<=e.bottomLeftCircle.startX+n&&i>=e.bottomLeftCircle.startY-n&&i<=e.bottomLeftCircle.startY+n?"sw-resize":t>=e.bottomLeftCircle.startX-n&&t<=e.bottomRightCircle.startX-n&&i>=e.bottomCenterCircle.startY-n&&i<=e.bottomCenterCircle.startY+n?"s-resize":t>=e.bottomRightCircle.startX-n&&t<=e.bottomRightCircle.startX+n&&i>=e.bottomRightCircle.startY-n&&i<=e.bottomRightCircle.startY+n?"se-resize":t>=e.activePoint.startX&&t<=e.activePoint.endX&&i>=e.activePoint.startY&&i<=e.activePoint.endY?o?"grab":"move":a&&!r&&t>=a.x-(e.bottomCenterCircle.radius+2)&&t<=a.x+(e.bottomCenterCircle.radius+2)&&i>=a.y-(e.bottomCenterCircle.radius+2)&&i<=a.y+(e.bottomCenterCircle.radius+2)?"grabbing":"default"},i.prototype.setCursor=function(e,i){var o=this.parent,r={bool:null};if(o.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:r}}),o.isResize||r.bool)o.upperCanvas.style.cursor="default";else{var a,n=document.querySelector("#"+o.element.id+"_lowerCanvas"),s=document.querySelector("#"+o.element.id+"_upperCanvas"),l=!1;if(""===this.currentDrawingShape)if(o.currObjType.isDragging)""===this.dragElement?s.style.cursor=o.cursor="move":s.style.cursor=o.cursor=this.dragElement;else{if(void 0!==o.activeObj.horTopLine){void 0!==o.activeObj.shape&&(a=o.activeObj.shape.split("-")),void 0===a&&o.currObjType.isCustomCrop?l=!0:void 0!==a&&"crop"===a[0]&&(l=!0),!l&&o.togglePan&&(n.style.cursor=s.style.cursor=o.cursor="grab");var p=s.style.cursor,h=t.extend({},o.activeObj,{},!0);this.cursorTargetId=h.currIndex;var c=void 0;(c=0===h.shapeDegree?o.transform.degree:o.transform.degree-h.shapeDegree)<0&&(c=360+c),"line"===h.shape||"arrow"===h.shape?this.setCursorForLineArrow(h,e,i,s):"path"===h.shape?this.setCursorForPath(h,e,i,s):t.isNullOrUndefined(h.rotatedAngle)||0===h.rotatedAngle?(s.style.cursor=o.cursor=this.getMouseCursor(h,e,i,l,!1),"text"!==h.shape||"n-resize"!==o.cursor&&"s-resize"!==o.cursor&&"e-resize"!==o.cursor&&"w-resize"!==o.cursor||(s.style.cursor=o.cursor="move")):this.setCursorForRotatedObject(h,e,i,s),"default"===p&&"default"===o.cursor&&l&&(s.style.cursor=o.cursor="grab"),"grab"===p&&"default"===o.cursor&&(s.style.cursor=o.cursor="grab")}else o.togglePan&&!o.togglePen?n.style.cursor=s.style.cursor=o.cursor="grab":o.currObjType.isCustomCrop||o.togglePen?s.style.cursor=o.cursor="crosshair":s.style.cursor=o.cursor="default";if("default"===o.cursor||"grab"===o.cursor){p=s.style.cursor;o.objColl.length>0&&("grab"!==o.cursor||!l)&&this.setCursorFromObj(e,i,o.objColl,s,l),"grab"===p&&"default"===o.cursor&&(s.style.cursor=o.cursor="grab")}"default"!==o.cursor&&"grab"!==o.cursor||!o.pointColl[0]||"grab"===o.cursor&&l||o.currObjType.isDragging||o.currObjType.isResize||this.setCursorForFreehandDrawing(e,i,s)}else s.style.cursor=o.cursor="crosshair"}},i.prototype.setCursorForPath=function(e,i,o,r){this.setCursorForLineArrow(e,i,o,r);var a=this.parent;if("default"===a.cursor)for(var n=t.extend({},e,null,!0),s=!1,l=1;l<e.pointColl.length&&!s;l++){n.activePoint.startX=e.pointColl[l-1].x,n.activePoint.startY=e.pointColl[l-1].y,n.activePoint.endX=e.pointColl[l].x,n.activePoint.endY=e.pointColl[l].y,a.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:n}});for(var p=0;p<n.pointColl.length;p++){var h=n.pointColl[p];if(!t.isNullOrUndefined(h.x-2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.x+2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.y-2*e.topLeftCircle.radius)&&!t.isNullOrUndefined(h.y+2*e.topLeftCircle.radius)&&i>=h.x-2*e.topLeftCircle.radius&&i<=h.x+2*e.topLeftCircle.radius&&o>=h.y-2*e.topLeftCircle.radius&&o<=h.y+2*e.topLeftCircle.radius){r.style.cursor=a.cursor="move",s=!0;break}r.style.cursor=a.cursor="default"}}return a.cursor},i.prototype.setCursorForLineArrow=function(e,t,i,o){for(var r,a=0;a<e.pointColl.length;a++){var n=e.pointColl[a];if(t>=n.x-2*e.topLeftCircle.radius&&t<=n.x+2*e.topLeftCircle.radius&&i>=n.y-2*e.topLeftCircle.radius&&i<=n.y+2*e.topLeftCircle.radius){o.style.cursor=this.parent.cursor="move",r=a;break}o.style.cursor=this.parent.cursor="default"}return r},i.prototype.setCursorForRotatedObject=function(e,t,i,o){this.resizedElement="";var r=this.parent;if(t>=e.horTopLinePointColl[0].x-(e.bottomCenterCircle.radius+2)&&t<=e.horTopLinePointColl[0].x+(e.bottomCenterCircle.radius+2)&&i>=e.horTopLinePointColl[0].y-(e.bottomCenterCircle.radius+2)&&i<=e.horTopLinePointColl[0].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="nw-resize";else if(t>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].x-5&&t<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].x+5&&i>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].y-5&&i<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="n-resize";else if(t>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].x-(e.bottomCenterCircle.radius+2)&&t<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].x+(e.bottomCenterCircle.radius+2)&&i>=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].y-(e.bottomCenterCircle.radius+2)&&i<=e.horTopLinePointColl[Math.round(e.horTopLinePointColl.length-1)].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="ne-resize";else if(t>=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].x-5&&t<=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].x+5&&i>=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].y-5&&i<=e.verLeftLinePointColl[Math.round(e.verLeftLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="w-resize";else if(t>=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].x-5&&t<=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].x+5&&i>=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].y-5&&i<=e.verRightLinePointColl[Math.round(e.verRightLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="e-resize";else if(t>=e.horBottomLinePointColl[0].x-(e.bottomCenterCircle.radius+2)&&t<=e.horBottomLinePointColl[0].x+(e.bottomCenterCircle.radius+2)&&i>=e.horBottomLinePointColl[0].y-(e.bottomCenterCircle.radius+2)&&i<=e.horBottomLinePointColl[0].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="sw-resize";else if(t>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].x-5&&t<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].x+5&&i>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].y-5&&i<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length/2)].y+5)o.style.cursor=r.cursor=this.resizedElement="s-resize";else if(t>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].x-(e.bottomCenterCircle.radius+2)&&t<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].x+(e.bottomCenterCircle.radius+2)&&i>=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].y-(e.bottomCenterCircle.radius+2)&&i<=e.horBottomLinePointColl[Math.round(e.horBottomLinePointColl.length-1)].y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="se-resize";else if(e.rotationCirclePointColl&&t>=e.rotationCirclePointColl.x-(e.bottomCenterCircle.radius+2)&&t<=e.rotationCirclePointColl.x+(e.bottomCenterCircle.radius+2)&&i>=e.rotationCirclePointColl.y-(e.bottomCenterCircle.radius+2)&&i<=e.rotationCirclePointColl.y+(e.bottomCenterCircle.radius+2))o.style.cursor=r.cursor="grabbing";else{o.style.cursor=r.cursor="default";this.getRectanglePoints(e.activePoint.startX,e.activePoint.startY,e.activePoint.width,e.activePoint.height,e.rotatedAngle*(180/Math.PI),t,i)&&(o.style.cursor=r.cursor="move")}if("default"===r.cursor)for(var a=0,n=e.horTopLinePointColl.length;a<n;a++)if(t>=e.horTopLinePointColl[a].x-5&&t<=e.horTopLinePointColl[a].x+5&&i>=e.horTopLinePointColl[a].y-5&&i<=e.horTopLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="n-resize";break}if("default"===r.cursor)for(a=0,n=e.horBottomLinePointColl.length;a<n;a++)if(t>=e.horBottomLinePointColl[a].x-5&&t<=e.horBottomLinePointColl[a].x+5&&i>=e.horBottomLinePointColl[a].y-5&&i<=e.horBottomLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="s-resize";break}if("default"===r.cursor)for(a=0,n=e.verLeftLinePointColl.length;a<n;a++)if(t>=e.verLeftLinePointColl[a].x-5&&t<=e.verLeftLinePointColl[a].x+5&&i>=e.verLeftLinePointColl[a].y-5&&i<=e.verLeftLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="w-resize";break}if("default"===r.cursor)for(a=0,n=e.verRightLinePointColl.length;a<n;a++)if(t>=e.verRightLinePointColl[a].x-5&&t<=e.verRightLinePointColl[a].x+5&&i>=e.verRightLinePointColl[a].y-5&&i<=e.verRightLinePointColl[a].y+5){o.style.cursor=r.cursor=this.resizedElement="e-resize";break}return this.adjustCursorStylesForRotatedState(e),r.cursor},i.prototype.adjustCursorStylesForRotatedState=function(e){var t=this.parent,i=e.rotatedAngle*(180/Math.PI);if((i=i>0?Math.floor(i):Math.ceil(i))>=92&&i<=182||i>=-178&&i<=-88){var o={"nw-resize":"ne-resize","n-resize":"s-resize","ne-resize":"nw-resize","w-resize":"e-resize","e-resize":"w-resize","sw-resize":"se-resize","s-resize":"n-resize","se-resize":"sw-resize"};t.cursor in o&&(t.cursor=o[t.cursor])}return t.upperCanvas.style.cursor=this.getResizeElement(e.rotatedAngle*(180/Math.PI),t.cursor),t.cursor},i.prototype.getResizeElement=function(e,t){var i=[];"nw-resize"===t?i=[[337.5,22.5,"nw-resize"],[22.5,67.5,"n-resize"],[67.5,112.5,"ne-resize"],[112.5,157.5,"e-resize"],[157.5,202.5,"se-resize"],[202.5,247.5,"s-resize"],[247.5,292.5,"sw-resize"],[292.5,337.5,"w-resize"]]:"n-resize"===t?i=[[337.5,22.5,"n-resize"],[22.5,67.5,"ne-resize"],[67.5,112.5,"e-resize"],[112.5,157.5,"se-resize"],[157.5,202.5,"s-resize"],[202.5,247.5,"sw-resize"],[247.5,292.5,"w-resize"],[292.5,337.5,"nw-resize"]]:"ne-resize"===t?i=[[337.5,22.5,"ne-resize"],[22.5,67.5,"e-resize"],[67.5,112.5,"se-resize"],[112.5,157.5,"s-resize"],[157.5,202.5,"sw-resize"],[202.5,247.5,"w-resize"],[247.5,292.5,"nw-resize"],[292.5,337.5,"n-resize"]]:"e-resize"===t?i=[[337.5,22.5,"e-resize"],[22.5,67.5,"se-resize"],[67.5,112.5,"s-resize"],[112.5,157.5,"sw-resize"],[157.5,202.5,"w-resize"],[202.5,247.5,"nw-resize"],[247.5,292.5,"n-resize"],[292.5,337.5,"ne-resize"]]:"se-resize"===t?i=[[337.5,22.5,"se-resize"],[22.5,67.5,"s-resize"],[67.5,112.5,"sw-resize"],[112.5,157.5,"w-resize"],[157.5,202.5,"nw-resize"],[202.5,247.5,"n-resize"],[247.5,292.5,"ne-resize"],[292.5,337.5,"e-resize"]]:"s-resize"===t?i=[[337.5,22.5,"s-resize"],[22.5,67.5,"sw-resize"],[67.5,112.5,"w-resize"],[112.5,157.5,"nw-resize"],[157.5,202.5,"n-resize"],[202.5,247.5,"ne-resize"],[247.5,292.5,"e-resize"],[292.5,337.5,"se-resize"]]:"sw-resize"===t?i=[[337.5,22.5,"sw-resize"],[22.5,67.5,"w-resize"],[67.5,112.5,"nw-resize"],[112.5,157.5,"n-resize"],[157.5,202.5,"ne-resize"],[202.5,247.5,"e-resize"],[247.5,292.5,"se-resize"],[292.5,337.5,"s-resize"]]:"w-resize"===t&&(i=[[337.5,22.5,"w-resize"],[22.5,67.5,"nw-resize"],[67.5,112.5,"n-resize"],[112.5,157.5,"ne-resize"],[157.5,202.5,"e-resize"],[202.5,247.5,"se-resize"],[247.5,292.5,"s-resize"],[292.5,337.5,"sw-resize"]]);for(var o=e<0?360-Math.abs(e):e,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return t},i.prototype.setCursorForFreehandDrawing=function(e,i,o){var r=o.getContext("2d"),a=this.parent,n=document.querySelector("#"+a.element.id+"_textArea"),s=!1;a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:-1}});for(var l,p=0;p<a.freehandCounter;p++){var h={selPointColl:{}};a.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:h}}),l=t.extend([],h.selPointColl[p].points,[]),a.points=t.extend([],a.pointColl[p].points,[]),a.notify("freehand-draw",{prop:"setPointCounter",onPropertyChange:!1,value:{value:0}});for(var c=l.length,d=0;d<c;d++)if(0!==d){var v=!1;if(l[d-1]&&l[d]&&(v=this.isInside(e,i,l[d-1].x,l[d-1].y,l[d].x,l[d].y)),v){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){var u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}else a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:null}});this.isFhdPoint=!1}}else{if(e>a.points[d].x-a.pointColl[p].strokeWidth&&e<a.points[d].x+a.pointColl[p].strokeWidth&&i>a.points[d].y-a.pointColl[p].strokeWidth&&i<a.points[d].y+a.pointColl[p].strokeWidth){this.isFhdPoint=!0,a.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:p}}),a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),o.style.cursor=a.cursor="pointer",s=!0;break}if(!this.isFhdEditing||a.pointColl[p].isSelected){if((this.isFhdPoint||this.isFhdEditing)&&(r.clearRect(0,0,o.width,o.height),a.activeObj.shape&&"none"===n.style.display&&a.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:a.activeObj}})),this.isFhdEditing){u=a.pointColl[p].strokeColor;a.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:u,strokeWidth:a.pointColl[p].strokeWidth}})}this.isFhdPoint=!1}}if(s)break}},i.prototype.setCursorFromObj=function(e,i,o,r,a){for(var n=this.parent,s=0,l=o.length;s<l;s++){if("move"===n.cursor)return;var p=t.extend({},o[s],{},!0);this.cursorTargetId=p.currIndex,"line"===p.shape||"arrow"===p.shape?this.setCursorForLineArrow(p,e,i,r):"path"===p.shape?this.setCursorForPath(p,e,i,r):t.isNullOrUndefined(p.rotatedAngle)||0===p.rotatedAngle?r.style.cursor=n.cursor=this.getMouseCursor(p,e,i,a,!0):this.setCursorForRotatedObject(p,e,i,r)}},i.prototype.isInside=function(e,t,i,o,r,a){var n=Math.min(i,r),s=Math.max(i,r),l=Math.min(o,a),p=Math.max(o,a);return n<=e&&e<=s&&l<=t&&t<=p},i.prototype.updateActivePoint=function(e,i,o){var r=this.parent,a={width:0,height:0};r.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:r.activeObj.activePoint.width,height:r.activeObj.activePoint.height,obj:a,isImgShape:null}});var n=a,s=this.updatePrevShapeSettings(),l={action:"resize",previousShapeSettings:s},p={action:"move",previousShapeSettings:s};this.shapeResizingArgs=l,this.shapeMovingArgs=p,"text"===r.activeObj.shape&&""!==this.dragElement&&r.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:r.activeObj,isTextArea:null}}),""===this.currentDrawingShape||""!==this.dragElement&&"move"!==this.dragElement||("line"===r.activeObj.shape||"arrow"===r.activeObj.shape||"path"===r.activeObj.shape?this.dragElement="e-resize":e>r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="se-resize":e<r.activeObj.activePoint.startX&&i>r.activeObj.activePoint.startY?this.dragElement="sw-resize":e>r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY?this.dragElement="ne-resize":e<r.activeObj.activePoint.startX&&i<r.activeObj.activePoint.startY&&(this.dragElement="nw-resize")),"arrow"===r.activeObj.shape&&(Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)>0?r.activeObj.rotatedAngle=-Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2):r.activeObj.rotatedAngle=Math.abs(Math.atan2(e-r.lowerCanvas.width/2,i-r.lowerCanvas.height/2)));var h,c=!1,d=!1;switch(this.dragElement.toLowerCase()){case"nw-resize":this.updateNWPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"n-resize":this.updateNPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"ne-resize":this.updateNEPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"w-resize":this.updateWPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"e-resize":this.updateEPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"sw-resize":this.updateSWPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"s-resize":this.updateSPoints(e,i),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"se-resize":this.updateSEPoints(e,i,n),r.notify("shape",{prop:"updateArrowDirection",onPropertyChange:!1,value:{obj:r.activeObj,flip:null,rotatedDegree:null}}),this.triggerShapeChange(l,p,"resize");break;case"grabbing":Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))>0?r.activeObj.rotatedAngle=-Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2)):r.activeObj.rotatedAngle=Math.abs(Math.atan2(e-(r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2),i-(r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2))),(h=0===r.activeObj.shapeDegree?r.transform.degree:r.transform.degree-r.activeObj.shapeDegree)<0&&(h=360+h);for(var v=0,u=r.activeObj.flipObjColl.length;v<u;v++)"horizontal"===r.activeObj.flipObjColl[v].toLowerCase()?c=!0:"vertical"===r.activeObj.flipObjColl[v].toLowerCase()&&(d=!0);r.activeObj.rotatedAngle-=h*(Math.PI/180),0===h||360===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):90===h||-270===h?c&&(r.activeObj.rotatedAngle-=Math.PI/180*180):180===h||-180===h?d&&(r.activeObj.rotatedAngle-=Math.PI/180*180):270!==h&&-90!==h||c&&(r.activeObj.rotatedAngle-=Math.PI/180*180);break;case"pathdrag":t.isNullOrUndefined(this.pathAdjustedIndex)||(r.activeObj.pointColl[this.pathAdjustedIndex].x=e,r.activeObj.pointColl[this.pathAdjustedIndex].y=i);break;default:if(!o&&!r.currObjType.isCustomCrop){if(this.dragPoint.startX){var g=this.dragPoint.endX-this.previousPoint.x,b=this.dragPoint.endY-this.previousPoint.y;if(r.activeObj.activePoint.startX+=g,r.activeObj.activePoint.endX+=g,r.activeObj.activePoint.startY+=b,r.activeObj.activePoint.endY+=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x+=g,r.activeObj.rotationCirclePointColl.y+=b,r.activeObj.rotationCirclePoint.x+=g,r.activeObj.rotationCirclePoint.y+=b),"path"===r.activeObj.shape)for(v=0,u=r.activeObj.pointColl.length;v<u;v++)r.activeObj.pointColl[v].x+=g,r.activeObj.pointColl[v].y+=b;!this.isPreventDragging&&"line"!==r.activeObj.shape&&0===r.activeObj.rotatedAngle&&(r.activeObj.activePoint.startX<r.img.destLeft||r.activeObj.activePoint.startY<r.img.destTop||r.activeObj.activePoint.endX>r.img.destLeft+r.img.destWidth||r.activeObj.activePoint.endY>r.img.destTop+r.img.destHeight)&&(r.activeObj.activePoint.startX-=g,r.activeObj.activePoint.endX-=g,r.activeObj.activePoint.startY-=b,r.activeObj.activePoint.endY-=b,"line"!==r.activeObj.shape&&"arrow"!==r.activeObj.shape&&r.activeObj.rotationCirclePointColl&&(r.activeObj.rotationCirclePointColl.x-=g,r.activeObj.rotationCirclePointColl.y-=b,r.activeObj.rotationCirclePoint.x-=g,r.activeObj.rotationCirclePoint.y-=b),this.setDragWidth(g),this.setDragHeight(b))}else r.activeObj.activePoint.startX=e<this.mouseDownPoint.x?e:this.mouseDownPoint.x,r.activeObj.activePoint.startY=i<this.mouseDownPoint.y?i:this.mouseDownPoint.y,e=e<this.mouseDownPoint.x?this.mouseDownPoint.x:e,i=i<this.mouseDownPoint.y?this.mouseDownPoint.y:i,r.activeObj.activePoint.endX=e,r.activeObj.activePoint.endY=i;this.triggerShapeChange(l,p,"move")}}},i.prototype.triggerShapeChange=function(e,i,o){var r=this.parent;r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY;var a=this.updatePrevShapeSettings();if(t.isNullOrUndefined(this.shapeResizingArgs)||t.isNullOrUndefined(this.shapeMovingArgs)?(e.currentShapeSettings=a,i.currentShapeSettings=a):(e.currentShapeSettings=this.shapeResizingArgs.currentShapeSettings=a,i.currentShapeSettings=this.shapeMovingArgs.currentShapeSettings=a),"resize"===o){this.isCropSelection=!1;var n=void 0;if(void 0!==r.activeObj.shape&&(n=r.activeObj.shape.split("-")),void 0!==n&&"crop"===n[0]&&(this.isCropSelection=!0),!this.isCropSelection&&"resize"!==this.parent.eventType&&t.isBlazor()&&r.events&&!0===this.parent.events.onShapeResizeStart.hasDelegate)e.action=""!==this.currentDrawingShape?"drawing":"resize-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeStart",e).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})});else if(this.isCropSelection){var s={action:e.action,previousSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:e.previousShapeSettings.startX,startY:e.previousShapeSettings.startY,width:e.previousShapeSettings.width,height:e.previousShapeSettings.height},currentSelectionSettings:{type:r.getSelectionType(r.activeObj.shape),startX:e.currentShapeSettings.startX,startY:e.currentShapeSettings.startY,width:e.currentShapeSettings.width,height:e.currentShapeSettings.height}};this.selectionResizingArgs=s,t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onSelectionResizeStart.hasDelegate?(s.action="resize-start",r.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",s).then(function(e){r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}})})):(r.trigger("selectionChanging",s),r.notify("shape",{prop:"updSelChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:s.currentSelectionSettings}}))}else""!==this.currentDrawingShape&&(e.action="drawing"),r.trigger("shapeChanging",e),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}else"mouse-down"===o||"mouse-up"===o?t.isBlazor()&&r.events&&!0===r.events.shapeChanging.hasDelegate?r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",e).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}):(r.trigger("shapeChanging",e),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})):t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onShapeDragStart.hasDelegate?(i.action="drag-start",r.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragStart",i).then(function(e){r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})})):(r.trigger("shapeChanging",i),r.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:i.currentShapeSettings}}));this.parent.eventType=o},i.prototype.setDragWidth=function(e){var t=this.parent,i=e;if(i>=0)for(var o=0;o<i&&(e=i-o,t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,!(t.activeObj.activePoint.startX>=t.img.destLeft&&t.activeObj.activePoint.endX<=t.img.destLeft+t.img.destWidth));o++)t.activeObj.activePoint.startX-=e,t.activeObj.activePoint.endX-=e;else for(o=1;o<Math.abs(i)&&(e=i+o,t.activeObj.activePoint.startX+=e,t.activeObj.activePoint.endX+=e,!(t.activeObj.activePoint.startX>=t.img.destLeft&&t.activeObj.activePoint.endX<=t.img.destLeft+t.img.destWidth));o++)t.activeObj.activePoint.startX-=e,t.activeObj.activePoint.endX-=e},i.prototype.setDragHeight=function(e){var t=this.parent,i=e;if(i>=0)for(var o=1;o<i&&(e=i-o,t.activeObj.activePoint.startY+=e,t.activeObj.activePoint.endY+=e,!(t.activeObj.activePoint.startY>=t.img.destTop&&t.activeObj.activePoint.endY<=t.img.destTop+t.img.destHeight));o++)t.activeObj.activePoint.startY-=e,t.activeObj.activePoint.endY-=e;else for(o=0;o<Math.abs(i)&&(e=i+o,t.activeObj.activePoint.startY+=e,t.activeObj.activePoint.endY+=e,!(t.activeObj.activePoint.startY>=t.img.destTop&&t.activeObj.activePoint.endY<=t.img.destTop+t.img.destHeight));o++)t.activeObj.activePoint.startY-=e,t.activeObj.activePoint.endY-=e},i.prototype.limitDrag=function(e){var t=this.parent,i=e?t.activeObj.activePoint.startX:t.activeObj.activePoint.endX,o=e?t.activeObj.activePoint.startY:t.activeObj.activePoint.endY,r=e?t.activeObj.activePoint.endX:t.activeObj.activePoint.startX,a=e?t.activeObj.activePoint.endY:t.activeObj.activePoint.startY;i<t.img.destLeft&&(i=t.img.destLeft),o<t.img.destTop&&(o=t.img.destTop),r>t.img.destLeft+t.img.destWidth&&(r=t.img.destLeft+t.img.destWidth),a>t.img.destTop+t.img.destHeight&&(a=t.img.destTop+t.img.destHeight),e?(t.activeObj.activePoint.startX=i,t.activeObj.activePoint.startY=o,t.activeObj.activePoint.endX=r,t.activeObj.activePoint.endY=a):(t.activeObj.activePoint.startX=r,t.activeObj.activePoint.startY=a,t.activeObj.activePoint.endX=i,t.activeObj.activePoint.endY=o)},i.prototype.preventDraggingInvertly=function(){var e=this.parent;"image"!==e.activeObj.shape&&(this.isPreventDragging||0!==e.activeObj.rotatedAngle||(this.limitDrag(!0),"line"!==e.activeObj.shape&&"arrow"!==e.activeObj.shape&&"path"!==e.activeObj.shape||this.limitDrag(!1)))},i.prototype.preventTextDraggingInvertly=function(){var e=this.parent,t=!1;return this.isPreventDragging||(e.activeObj.activePoint.startX<e.img.destLeft||e.activeObj.activePoint.startY<e.img.destTop||e.activeObj.activePoint.endX>e.img.destLeft+e.img.destWidth||e.activeObj.activePoint.endY>e.img.destTop+e.img.destHeight)&&(t=!0),t},i.prototype.preventInverseResize=function(e){var t=this.parent;t.activeObj.activePoint.width<0&&(t.activeObj.activePoint.width=0,t.activeObj.activePoint.startX=e.activePoint.startX,t.activeObj.activePoint.endX=e.activePoint.endX),t.activeObj.activePoint.height<0&&(t.activeObj.activePoint.height=0,t.activeObj.activePoint.startY=e.activePoint.startY,t.activeObj.activePoint.endY=e.activePoint.endY)},i.prototype.getScaleRatio=function(e){var t=this.parent,i={x:e,y:e};if(t.activeObj.shape&&"crop-custom"!==t.activeObj.shape&&"crop-circle"!==t.activeObj.shape&&"crop-square"!==t.activeObj.shape){var o="image"===t.activeObj.shape?this.findImageRatio(t.activeObj.activePoint.width,t.activeObj.activePoint.height).split("-"):t.activeObj.shape.split("-");if(o.length>1||"image"===t.activeObj.shape){o="image"===t.activeObj.shape?o[0].split(":"):o[1].split(":");var r=e/parseInt(o[1],10);i.x=r*parseInt(o[0],10),i.y=r*parseInt(o[1],10)}}return i},i.prototype.findImageRatio=function(e,t,i){var o=function(e,t){return 0===t?e:o(t,e%t)},r=o(e,t),a=e/r+":"+t/r;return i&&(i.ratio=a),a},i.prototype.updateNWPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=l.activeObj.activePoint.startX-e,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=this.oldPoint.x-e,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"nw-resize",c):this.adjustNWPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){var v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<e&&l.activeObj.activePoint.startY<i){r=e-l.activeObj.activePoint.startX,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.startY+=u.y;var g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.startY-=u.y)}else{r=l.activeObj.activePoint.startX-e,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.startY-=u.y;g=l.img.destLeft>0?l.img.destLeft:0;var f=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.startY<f)&&(l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.startY+=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateNPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.startY>a.activeObj.activePoint.endY){var s=a.activeObj.activePoint.startY;a.activeObj.activePoint.startY=a.activeObj.activePoint.endY,a.activeObj.activePoint.endY=s,this.dragElement=this.resizedElement="s-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.startY<t){i=a.activeObj.activePoint.endX-e,o=t-a.activeObj.activePoint.startY,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y)}else{i=e-a.activeObj.activePoint.endX,o=a.activeObj.activePoint.startY-t,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.startY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.startY<a.img.destTop)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.startY+=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateNEPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=e-l.activeObj.activePoint.endX,this.diffPoint.y=l.activeObj.activePoint.startY-i):(this.diffPoint.x=e-this.oldPoint.x,this.diffPoint.y=this.oldPoint.y-i),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/100*s,l.activeObj.activePoint.startY-=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/100*s,l.activeObj.activePoint.startY+=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"ne-resize",c):this.adjustNEPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){var v=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}if(l.activeObj.activePoint.startY>l.activeObj.activePoint.endY){v=l.activeObj.activePoint.startY;l.activeObj.activePoint.startY=l.activeObj.activePoint.endY,l.activeObj.activePoint.endY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>e&&l.activeObj.activePoint.startY<i){r=l.activeObj.activePoint.endX-e,a=i-l.activeObj.activePoint.startY,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.endX-=u.x,l.activeObj.activePoint.startY+=u.y;var g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.endX+=u.x,l.activeObj.activePoint.startY-=u.y)}else{r=e-l.activeObj.activePoint.endX,a=l.activeObj.activePoint.startY-i,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.endX+=u.x,l.activeObj.activePoint.startY-=u.y;g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop>0?l.img.destTop:0;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.startY<b)&&(l.activeObj.activePoint.endX-=u.x,l.activeObj.activePoint.startY+=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateWPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.startX=e,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.startY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="e-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.startX>a.activeObj.activePoint.endX){var s=a.activeObj.activePoint.startX;a.activeObj.activePoint.startX=a.activeObj.activePoint.endX,a.activeObj.activePoint.endX=s,this.dragElement=this.resizedElement="e-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.startX<e&&a.activeObj.activePoint.endY>t){i=e-a.activeObj.activePoint.startX,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=a.activeObj.activePoint.startX-e,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.startX-=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.startX<a.img.destLeft||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.startX+=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateEPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endX=e,a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX),"line"===a.activeObj.shape||"arrow"===a.activeObj.shape||"path"===a.activeObj.shape)a.activeObj.activePoint.endY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY,this.adjustActObjForLineArrow()&&(this.dragElement="w-resize","right"===a.activeObj.triangleDirection?a.activeObj.triangleDirection="left":"left"===a.activeObj.triangleDirection&&(a.activeObj.triangleDirection="right"));else if(a.activeObj.activePoint.endX<a.activeObj.activePoint.startX){var s=a.activeObj.activePoint.endX;a.activeObj.activePoint.endX=a.activeObj.activePoint.startX,a.activeObj.activePoint.startX=s,this.dragElement=this.resizedElement="w-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.endY>t){i=a.activeObj.activePoint.endX-e,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=e-a.activeObj.activePoint.endX,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSWPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)t.isNullOrUndefined(this.oldPoint.x)&&t.isNullOrUndefined(this.oldPoint.y)?(this.diffPoint.x=l.activeObj.activePoint.startX-e,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=this.oldPoint.x-e,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x<=p&&this.diffPoint.y>=h?Math.min(this.diffPoint.x,this.diffPoint.y):Math.max(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.startX-=o.width/100*s,l.activeObj.activePoint.endY+=o.height/100*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.startX+=o.width/100*s,l.activeObj.activePoint.endY-=o.height/100*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"sw-resize",c):this.adjustSWPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.startX>l.activeObj.activePoint.endX){var v=l.activeObj.activePoint.startX;l.activeObj.activePoint.startX=l.activeObj.activePoint.endX,l.activeObj.activePoint.endX=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="se-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){v=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=v,this.dragElement=l.upperCanvas.style.cursor=l.cursor="nw-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.startX<e&&l.activeObj.activePoint.endY>i){r=e-l.activeObj.activePoint.startX,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a);var u=this.getScaleRatio(n);l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.endY-=u.y;var g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.endY+=u.y)}else{r=l.activeObj.activePoint.startX-e,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a);u=this.getScaleRatio(n);l.activeObj.activePoint.startX-=u.x,l.activeObj.activePoint.endY+=u.y;g=l.img.destLeft>0?l.img.destLeft:0,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.startX<g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.startX+=u.x,l.activeObj.activePoint.endY-=u.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.updateSPoints=function(e,t){var i,o,r,a=this.parent;if("text"!==a.activeObj.shape){var n=void 0;if(a.activeObj.shape&&(n=a.activeObj.shape.split("-")),"crop-custom"===a.activeObj.shape||a.activeObj.shape&&"crop"!==n[0]){if("line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape&&"path"!==a.activeObj.shape&&0!==a.activeObj.rotatedAngle&&this.dragPoint.startX?(this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t),i=this.dragPoint.endX-this.previousPoint.x,o=this.dragPoint.endY-this.previousPoint.y,this.adjustRotationPoints(a.activeObj.activePoint,i,o,a.activeObj.rotatedAngle)):(a.activeObj.activePoint.endY=t,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),a.activeObj.activePoint.endY<a.activeObj.activePoint.startY){var s=a.activeObj.activePoint.endY;a.activeObj.activePoint.endY=a.activeObj.activePoint.startY,a.activeObj.activePoint.startY=s,this.dragElement=this.resizedElement="n-resize"}this.preventDraggingInvertly()}else{if(a.activeObj.activePoint.endX>e&&a.activeObj.activePoint.endY>t){i=a.activeObj.activePoint.endX-e,o=a.activeObj.activePoint.endY-t,r=Math.min(i,o);var l=this.getScaleRatio(r);a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.y)}else{i=e-a.activeObj.activePoint.endX,o=t-a.activeObj.activePoint.endY,r=Math.max(i,o);l=this.getScaleRatio(r);a.activeObj.activePoint.endX+=l.x,a.activeObj.activePoint.endY+=l.x,(a.activeObj.activePoint.endX>a.img.destLeft+a.img.destWidth||a.activeObj.activePoint.endY>a.img.destTop+a.img.destHeight)&&(a.activeObj.activePoint.endX-=l.x,a.activeObj.activePoint.endY-=l.y)}a.activeObj.activePoint.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,a.activeObj.activePoint.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY}}},i.prototype.updateSEPoints=function(e,i,o){var r,a,n,s,l=this.parent,p=this.diffPoint.x,h=this.diffPoint.y,c=t.extend({},l.activeObj,null,!0);if("text"===l.activeObj.shape)void 0===this.oldPoint.x&&void 0===this.oldPoint.y?(this.diffPoint.x=e-l.activeObj.activePoint.endX,this.diffPoint.y=i-l.activeObj.activePoint.endY):(this.diffPoint.x=e-this.oldPoint.x,this.diffPoint.y=i-this.oldPoint.y),this.oldPoint.x=e,this.oldPoint.y=i,s=(this.diffPoint.x>=p&&this.diffPoint.y>=h?Math.max(this.diffPoint.x,this.diffPoint.y):Math.min(this.diffPoint.x,this.diffPoint.y))/10,l.activeObj.activePoint.endX+=o.width/50*s,l.activeObj.activePoint.endY+=o.height/50*s,this.preventTextDraggingInvertly()&&(l.activeObj.activePoint.endX-=o.width/50*s,l.activeObj.activePoint.endY-=o.height/50*s),l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,l.notify("shape",{prop:"updateFontSize",onPropertyChange:!1,value:{obj:l.activeObj}});else{var d=void 0,v=void 0;if(void 0!==l.activeObj.shape&&(d=l.activeObj.shape.split("-")),"crop-custom"===l.activeObj.shape||void 0!==l.activeObj.shape&&"crop"!==d[0]){if("image"===l.activeObj.shape?this.resizeImg(e,i,"se-resize",c):this.adjustSEPoints(l.activeObj.activePoint,e,i,l.activeObj.rotatedAngle),l.activeObj.activePoint.endX<l.activeObj.activePoint.startX){var u=l.activeObj.activePoint.endX;l.activeObj.activePoint.endX=l.activeObj.activePoint.startX,l.activeObj.activePoint.startX=u,this.dragElement=l.upperCanvas.style.cursor=l.cursor="sw-resize"}if(l.activeObj.activePoint.endY<l.activeObj.activePoint.startY){u=l.activeObj.activePoint.endY;l.activeObj.activePoint.endY=l.activeObj.activePoint.startY,l.activeObj.activePoint.startY=u,this.dragElement=l.upperCanvas.style.cursor=l.cursor="ne-resize"}this.preventDraggingInvertly()}else if(l.activeObj.activePoint.endX>e&&l.activeObj.activePoint.endY>i){r=l.activeObj.activePoint.endX-e,a=l.activeObj.activePoint.endY-i,n=Math.min(r,a),v=this.getScaleRatio(n),l.activeObj.activePoint.endX-=v.x,l.activeObj.activePoint.endY-=v.y;var g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.endX+=v.x,l.activeObj.activePoint.endY+=v.y)}else{r=e-l.activeObj.activePoint.endX,a=i-l.activeObj.activePoint.endY,n=Math.max(r,a),v=this.getScaleRatio(n),l.activeObj.activePoint.endX+=v.x,l.activeObj.activePoint.endY+=v.y;g=l.img.destLeft+l.img.destWidth<l.lowerCanvas.width?l.img.destLeft+l.img.destWidth:l.lowerCanvas.width,b=l.img.destTop+l.img.destHeight<l.lowerCanvas.height?l.img.destTop+l.img.destHeight:l.lowerCanvas.height;(l.activeObj.activePoint.endX>g||l.activeObj.activePoint.endY>b)&&(l.activeObj.activePoint.endX-=v.x,l.activeObj.activePoint.endY-=v.y)}l.activeObj.activePoint.width=l.activeObj.activePoint.endX-l.activeObj.activePoint.startX,l.activeObj.activePoint.height=l.activeObj.activePoint.endY-l.activeObj.activePoint.startY,this.preventInverseResize(c)}},i.prototype.resizeImg=function(e,i,o,r){var a,n,s=this.parent;if(0!==this.previousPoint.x&&0!==this.previousPoint.y){switch(s.upperCanvas.style.cursor){case"se-resize":case"s-resize":this.previousPoint.x>e||this.previousPoint.y>i?(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"sw-resize":this.previousPoint.x<e||this.previousPoint.y>i?(a=(e-this.previousPoint.x+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(this.previousPoint.x-e+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"w-resize":case"nw-resize":this.previousPoint.x<e||this.previousPoint.y<i?(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"n-resize":case"ne-resize":this.previousPoint.x>e||this.previousPoint.y<i?(a=(this.previousPoint.x-e+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o));break;case"e-resize":this.previousPoint.x>e||this.previousPoint.y>i?(a=(this.previousPoint.x-e+(this.previousPoint.y-i))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,-Math.abs(n.x),-Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o)):0!==this.previousPoint.x&&0!==this.previousPoint.y&&(a=(e-this.previousPoint.x+(i-this.previousPoint.y))/2,n=this.getScaleRatio(a),this.adjustRotationPoints(s.activeObj.activePoint,Math.abs(n.x),Math.abs(n.y),s.activeObj.rotatedAngle,"img-resize",o))}s.activeObj.activePoint.width=s.activeObj.activePoint.endX-s.activeObj.activePoint.startX,s.activeObj.activePoint.height=s.activeObj.activePoint.endY-s.activeObj.activePoint.startY,(s.activeObj.activePoint.width<10||s.activeObj.activePoint.height<10)&&(s.activeObj=t.extend({},r,null,!0))}this.previousPoint={x:e,y:i}},i.prototype.adjustNWPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.endY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.endX=l[0],e.endY=l[1],e.startY=p[1],e.startX=p[0],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.adjustNEPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.endY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.startX=l[0],e.endY=l[1],e.width=p[0]-l[0],e.height=l[1]-p[1],e.endX=e.startX+e.width,e.startY=e.endY-e.height,e},i.prototype.adjustSWPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.endX,e.startY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.endX=l[0],e.startY=l[1],e.startX=p[0],e.endY=p[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.adjustSEPoints=function(e,t,i,o){var r=e.startX+e.width/2,a=e.startY+e.height/2,n=this.rotatePoints(e.startX,e.startY,r,a,o),s=[(n[0]+t)/2,(n[1]+i)/2],l=this.rotatePoints(n[0],n[1],s[0],s[1],-o),p=this.rotatePoints(t,i,s[0],s[1],-o);return e.startX=l[0],e.startY=l[1],e.width=p[0]-l[0],e.height=p[1]-l[1],e.endX=e.startX+e.width,e.endY=e.startY+e.height,e},i.prototype.adjustRotationPoints=function(e,t,i,o,r,a){var n=e.startX+e.width/2,s=e.startY+e.height/2;this.getResizeDirection(e,t,i,o,r,a);var l=this.rotatePoints(e.startX,e.startY,n,s,o),p=this.rotatePoints(e.endX,e.startY,n,s,o),h=this.rotatePoints(e.endX,e.endY,n,s,o),c=this.rotatePoints(e.startX,e.endY,n,s,o),d=[(l[0]+h[0])/2,(l[1]+h[1])/2],v=this.rotatePoints(l[0],l[1],d[0],d[1],-o),u=this.rotatePoints(c[0],c[1],d[0],d[1],-o),g=this.rotatePoints(p[0],p[1],d[0],d[1],-o);return e.startX=v[0],e.startY=v[1],e.endX=g[0],e.endY=u[1],e.width=e.endX-e.startX,e.height=e.endY-e.startY,e},i.prototype.rotatePoints=function(e,t,i,o,r){return[(e-i)*Math.cos(r)-(t-o)*Math.sin(r)+i,(e-i)*Math.sin(r)+(t-o)*Math.cos(r)+o]},i.prototype.setResizedValue=function(e,t,i,o){switch(e){case"x":t+=i;break;case"y":t+=o;break;case"abs-x":t+=i>0?-i:Math.abs(i);break;case"abs-y":t+=o>0?-o:Math.abs(o);break;case"y-abs-x":t+=o+(i>0?-i:Math.abs(i))/2;break;case"abs-x-abs-y":t+=(i>0?-i:Math.abs(i))+(o>0?-o:Math.abs(o))/2;break;case"abs-y-x":t+=(o>0?-o:Math.abs(o))+i/2;break;case"x-y":t+=i+o/2;break;case"img-resize-x":t+=i;break;case"img-resize-y":t+=o}return t},i.prototype.getResizeDirection=function(e,t,i,o,r,a){var n=o*(180/Math.PI),s=this.getResizedElement(n,this.resizedElement);"e-resize"===this.resizedElement?(e.width=this.setResizedValue(s,e.width,t,i),e.endX=e.width+e.startX):"n-resize"===this.resizedElement?(e.startY=this.setResizedValue(s,e.startY,t,i),e.height=e.endY-e.startY):"w-resize"===this.resizedElement?(e.startX=this.setResizedValue(s,e.startX,t,i),e.width=e.startX+e.endX):"s-resize"===this.resizedElement?(e.height=this.setResizedValue(s,e.height,t,i),e.endY=e.height+e.startY):r&&"img-resize"===r&&(e.width=this.setResizedValue("img-resize-x",e.width,t,i),e.height=this.setResizedValue("img-resize-y",e.height,t,i),"se-resize"===a?(e.endX=e.width+e.startX,e.endY=e.height+e.startY):"sw-resize"===a?(e.startX=e.endX-e.width,e.endY=e.height+e.startY):"ne-resize"===a?(e.endX=e.width+e.startX,e.startY=e.endY-e.height):"nw-resize"===a&&(e.startX=e.endX-e.width,e.startY=e.endY-e.height))},i.prototype.getResizedElement=function(e,t){var i=[];"n-resize"===t?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"e-resize"===t?i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]:"s-resize"===t?i=[[337.5,360,"y"],[0,22.5,"y"],[22.5,67.5,"y-abs-x"],[67.5,112.5,"abs-x"],[112.5,157.5,"abs-x-abs-y"],[157.5,202.5,"abs-y"],[202.5,247.5,"abs-y-x"],[247.5,292.5,"x"],[292.5,337.5,"x-y"]]:"w-resize"===t&&(i=[[337.5,360,"x"],[0,22.5,"x"],[22.5,67.5,"x-y"],[67.5,112.5,"y"],[112.5,157.5,"y-abs-x"],[157.5,202.5,"abs-x"],[202.5,247.5,"abs-x-abs-y"],[247.5,292.5,"abs-y"],[292.5,337.5,"abs-y-x"]]);for(var o=e<0?360-Math.abs(e):e,r=0,a=i;r<a.length;r++){var n=a[r],s=n[0],l=n[1],p=n[2];if(o>s&&o<=l||o+360>s&&o+360<=l)return p}return t},i.prototype.updateCursorStyles=function(e,i,o){var r=this.parent,a=!1;""===r.activeObj.keyHistory||void 0!==r.activeObj.shape||r.currObjType.isCustomCrop||r.currObjType.isLine||!r.currObjType.isText||(r.activeObj.shape="text");var n=t.extend({},r.activeObj,{},!0);if(!t.isNullOrUndefined(n.topLeftCircle)){var s;if((s=0===n.shapeDegree?r.transform.degree:r.transform.degree-n.shapeDegree)<0&&(s=360+s),this.isObjSelected)if("line"===n.shape||"arrow"===n.shape)a=this.updateCursorStylesForLineArrow(e,i,n);else if("path"===n.shape)a=this.updateCursorStylesForPath(e,i,n);else if(n.rotatedAngle)this.setCursorForRotatedObject(n,e,i,r.upperCanvas),"grabbing"===r.cursor?(r.upperCanvas.style.cursor=this.parent.cursor="grabbing",this.dragElement=r.cursor):"move"===r.cursor?(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i):"default"!==r.cursor&&(a=!0,this.dragElement=r.cursor,r.currObjType.isResize=!0);else{var l=this.getTransRotationPoint(n);e>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.topLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.topLeftCircle.startY+2*n.topLeftCircle.radius&&"nw-resize"!==this.dragElement?(n.topLeftCircle.startX=n.topLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="nw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.topLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.topRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.topCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.topCenterCircle.startY+2*n.topLeftCircle.radius&&"n-resize"!==this.dragElement?(n.topCenterCircle.startX=n.topCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="n-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.topRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.topRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.topRightCircle.startY+2*n.topLeftCircle.radius&&"ne-resize"!==this.dragElement?(n.topRightCircle.startX=n.topRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="ne-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.centerLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.centerLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.topLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&"w-resize"!==this.dragElement?(n.centerLeftCircle.startX=n.centerLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="w-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.centerRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.centerRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.topRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&"e-resize"!==this.dragElement?(n.centerRightCircle.startX=n.centerRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="e-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomLeftCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomLeftCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomLeftCircle.startY+2*n.topLeftCircle.radius&&"sw-resize"!==this.dragElement?(n.bottomLeftCircle.startX=n.bottomLeftCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="sw-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomLeftCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&i>=n.bottomCenterCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomCenterCircle.startY+2*n.topLeftCircle.radius&&"s-resize"!==this.dragElement?(n.bottomCenterCircle.startX=n.bottomCenterCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="s-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):e>=n.bottomRightCircle.startX-2*n.topLeftCircle.radius&&e<=n.bottomRightCircle.startX+2*n.topLeftCircle.radius&&i>=n.bottomRightCircle.startY-2*n.topLeftCircle.radius&&i<=n.bottomRightCircle.startY+2*n.topLeftCircle.radius&&"se-resize"!==this.dragElement?(n.bottomRightCircle.startX=n.bottomRightCircle.startY=0,r.upperCanvas.style.cursor=r.cursor="se-resize",a=!0,this.dragElement=r.upperCanvas.style.cursor):l&&e>=l.x-2*n.topLeftCircle.radius&&e<=l.x+2*n.topLeftCircle.radius&&i>=l.y-2*n.topLeftCircle.radius&&i<=l.y+2*n.topLeftCircle.radius&&"grabbing"!==this.dragElement?(r.upperCanvas.style.cursor=r.cursor="grabbing",this.dragElement=r.upperCanvas.style.cursor):(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i),"text"!==n.shape||"n-resize"!==r.cursor&&"s-resize"!==r.cursor&&"e-resize"!==r.cursor&&"w-resize"!==r.cursor||(r.upperCanvas.style.cursor=r.cursor="move",this.dragElement="",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}else this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i;this.previousPoint.x=this.previousPoint.y=this.diffPoint.x=this.diffPoint.y=0,"touchstart"===o?a||e>=n.activePoint.startX&&e<=n.activePoint.endX&&i>=n.activePoint.startY&&i<=n.activePoint.endY||"grabbing"===this.dragElement?r.currObjType.isDragging=!0:"line"===n.shape||"arrow"===n.shape?(this.setCursorForLineArrow(n,e,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):"path"===n.shape&&(this.setCursorForPath(n,e,i,r.upperCanvas),"move"===r.cursor&&(r.currObjType.isDragging=!0)):r.currObjType.isDragging=!0,0===n.rotatedAngle||"e-resize"!==this.dragElement&&"w-resize"!==this.dragElement&&"n-resize"!==this.dragElement&&"s-resize"!==this.dragElement||(this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=i)}},i.prototype.updateCursorStylesForLineArrow=function(e,t,i){for(var o,r=!1,a=this.parent,n=0;n<5;n++)if(o=i.pointColl[n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){i.centerLeftCircle.startX=i.centerLeftCircle.startY=0,this.dragElement="w-resize",r=!0;break}if(!r)for(n=1;n<6;n++)if(o=i.pointColl[i.pointColl.length-n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){i.centerRightCircle.startX=i.centerRightCircle.startY=0,this.dragElement="e-resize",r=!0;break}if(!r)for(n=0;n<i.pointColl.length;n++){if(o=i.pointColl[n],e>=o.x-2*i.topLeftCircle.radius&&e<=o.x+2*i.topLeftCircle.radius&&t>=o.y-2*i.topLeftCircle.radius&&t<=o.y+2*i.topLeftCircle.radius){a.upperCanvas.style.cursor=a.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t;break}a.upperCanvas.style.cursor=a.cursor="default"}return r},i.prototype.updateCursorStylesForPath=function(e,t,i){var o=!1;return this.pathAdjustedIndex=this.setCursorForLineArrow(i,e,t,this.parent.upperCanvas),"move"===this.parent.cursor&&(o=!0,this.dragElement="pathDrag"),o||(this.parent.upperCanvas.style.cursor=this.parent.cursor="move",this.dragPoint.startX=this.previousPoint.x=this.dragPoint.endX=e,this.dragPoint.startY=this.previousPoint.y=this.dragPoint.endY=t),o},i.prototype.setTextSelection=function(e,t){var i=this.parent,o=i.transform.degree;(o=0===i.activeObj.shapeDegree?i.transform.degree:i.transform.degree-i.activeObj.shapeDegree)<0&&(o=360+o);for(var r=0,a=i.activeObj.flipObjColl.length;r<a;r++){var n=i.activeObj.flipObjColl[r].toLowerCase();switch(o){case 0:switch(n){case"horizontal":i.activeObj.activePoint={startX:i.activeObj.activePoint.endX-e,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(t||0)};break;case"vertical":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.startY+(t||0)}}break;case 90:switch(n){case"horizontal":i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case"vertical":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-e,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;default:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)}}break;case 180:switch(n){case"horizontal":i.activeObj.activePoint.startY=i.activeObj.activePoint.endY-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+e,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+t,i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.startY};break;default:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.endY-(t||0)}}break;case 270:switch(n){case"horizontal":i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY};break;case"vertical":i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+t,endY:i.activeObj.activePoint.startY+(e||0)};break;default:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}}}if(0===i.activeObj.flipObjColl.length)switch(o){case 0:i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.startX+(e||0),endY:i.activeObj.activePoint.startY+(t||0)};break;case 90:i.activeObj.activePoint.startX=i.activeObj.activePoint.endX-t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.startY+(e||0)};break;case 180:i.activeObj.activePoint={endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY,startX:i.activeObj.activePoint.endX-(e||0),startY:i.activeObj.activePoint.endY-(t||0)};break;case 270:i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+t,i.activeObj.activePoint={startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.endY-(e||0),endX:i.activeObj.activePoint.endX,endY:i.activeObj.activePoint.endY}}i.activeObj.activePoint.width=i.activeObj.activePoint.endX-i.activeObj.activePoint.startX,i.activeObj.activePoint.height=i.activeObj.activePoint.endY-i.activeObj.activePoint.startY,360!==i.transform.degree&&-360!==i.transform.degree||(i.transform.degree=0)},i.prototype.setActivePoint=function(e,i){var o=this.parent;if(!t.isNullOrUndefined(o.activeObj.activePoint))if(o.currObjType.isText){var r=e||0,a=i||o.activeObj.textSettings.fontSize;void 0===o.activeObj.textSettings.fontSize&&(o.activeObj.textSettings.fontSize=.1*Math.abs(o.baseImgCanvas.width-o.baseImgCanvas.height)),this.setTextSelection(r,a),this.mouseDownPoint.x=o.activeObj.activePoint.endX,this.mouseDownPoint.y=o.activeObj.activePoint.endY,void 0!==o.activeObj.horTopLine&&(o.activeObj.activePoint=t.extend({},o.activeObj.activePoint,{},!0)),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})}else if(e&&i)o.activeObj.activePoint.startX=this.mouseDownPoint.x=e,o.activeObj.activePoint.startY=this.mouseDownPoint.y=i,o.currObjType.isDragging=!0;else{var n=o.activeObj;o.activeObj.activePoint={startX:n.horTopLine.startX,startY:n.horTopLine.startY,endX:n.horTopLine.endX,endY:n.horTopLine.endY},o.activeObj.activePoint.width=o.activeObj.activePoint.endX-o.activeObj.activePoint.startX,o.activeObj.activePoint.height=o.activeObj.activePoint.endY-o.activeObj.activePoint.startY}},i.prototype.mouseDownEventHandler=function(e){var i=this,o=this.parent;if("touchstart"===e.type?this.isTouch=!0:this.isTouch=!1,"touchstart"!==e.type||e.currentTarget!==o.lowerCanvas||o.isImageLoaded){this.isCropSelection=!1,this.isPan=!0;var r;void 0!==o.activeObj.shape&&(r=o.activeObj.shape.split("-")),void 0!==r&&"crop"===r[0]&&(this.isCropSelection=!0),this.isCropSelection&&(this.dragCanvas=o.togglePan=!0);var a={point:this.setXYPoints(e)};t.isBlazor()&&o.events&&!0===o.events.clicked.hasDelegate?o.dotNetRef.invokeMethodAsync("ClickEventAsync","click",a).then(function(t){i.clickEvent(t,e)}):(o.trigger("click",a),this.clickEvent(a,e))}},i.prototype.getImagePoints=function(e,t){var i=this.parent;return e<i.img.destLeft?e=i.img.destLeft:e>i.img.destLeft+i.img.destWidth&&(e=i.img.destLeft+i.img.destWidth),t<i.img.destTop?t=i.img.destTop:t>i.img.destTop+i.img.destHeight&&(t=i.img.destTop+i.img.destHeight),{x:e,y:t}},i.prototype.clickEvent=function(e,i){var o=this.parent,r=e.point.x,a=e.point.y,n=o.activeObj.shape&&"text"===o.activeObj.shape?o.cursor:"default";if(o.isResize)this.performEnterAction();else{if(JSON.stringify(o.frameObj)!==JSON.stringify(o.tempFrameObj))o.okBtn();else if(""!==this.currentDrawingShape){var s={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}}),this.initialPrevObj=s.currObj,this.initialPrevObj.objColl=t.extend([],o.objColl,[],!0),this.initialPrevObj.pointColl=t.extend([],o.pointColl,[],!0),this.initialPrevObj.afterCropActions=t.extend([],o.afterCropActions,[],!0);var l={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),this.initialPrevObj.selPointColl=t.extend([],l.selPointColl,[],!0),this.setActivePoint(r,a),"path"===this.currentDrawingShape){var p=this.getImagePoints(r,a);o.activeObj.pointColl.push({x:p.x,y:p.y}),0!==o.activeObj.activePoint.width&&0!==o.activeObj.activePoint.height&&(o.activeObj.activePoint.width=0,o.activeObj.activePoint.height=0,o.activeObj.activePoint.startX=o.activeObj.pointColl[o.activeObj.pointColl.length-1].x,o.activeObj.activePoint.startY=o.activeObj.pointColl[o.activeObj.pointColl.length-1].y)}o.activeObj.activePoint.endX=o.activeObj.activePoint.startX,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY,o.currObjType.isDragging=!0;var h=this.updatePrevShapeSettings(),c={action:"draw-start",previousShapeSettings:h},d={action:"move",previousShapeSettings:h};return this.shapeResizingArgs=c,this.shapeMovingArgs=d,void this.triggerShapeChange(c,d,"mouse-down")}o.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1}),this.isCropSelection&&this.dragCanvas&&(this.setCursor(r,a),"move"!==o.cursor&&"crosshair"!==o.cursor&&"default"!==o.cursor&&"grab"!==o.cursor&&(this.isPan=!1)),o.activeObj.shape?this.isObjSelected=!0:this.isObjSelected=!1;var v={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj,g=t.extend({},o.activeObj,null,!0),b=this.isShapeTouch(i,this.isCropSelection),f=this.isFreehandDrawTouch(i,this.isCropSelection),m=b||this.isShapeClick(i,this.isCropSelection),C=this.applyCurrShape(m);if(this.isTouch&&!b&&g.shape&&!this.isCropSelection){this.applyObj(r,a)&&(o.okBtn(!0),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}));var y=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:u,previousObjColl:u.objColl,previousPointColl:u.pointColl,previousSelPointColl:u.selPointColl,previousCropObj:y,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})}if(b||o.togglePen||this.isCropSelection||(t.isBlazor()?o.isImageLoaded&&o.updateToolbar(o.element,"imageLoaded","okBtnClick"):(o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}))),!this.dragCanvas||!this.isPan||"grab"!==o.cursor&&!this.isTouch||b||f||o.togglePen){var j=!1;!o.activeObj.shape||"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||(j=!0);var P=this.setXYPoints(i),O=P.x,x=P.y;this.applyObj(O,x)&&(o.okBtn(!0),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:O,y:x,isMouseDown:!0}});var w={index:null};o.notify("freehand-draw",{prop:"getFreehandDrawHoveredIndex",onPropertyChange:!1,value:{obj:w}});var S={freehandSelectedIndex:null};if(o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:S}}),this.isFhdPoint||this.isFhdCustomized&&!o.togglePen){if(!t.isNullOrUndefined(S.freehandSelectedIndex)&&S.freehandSelectedIndex!==w.index){var T=w.index;if(o.okBtn(),this.isFhdCustomized=!1,o.notify("freehand-draw",{prop:"setFreehandDrawHoveredIndex",onPropertyChange:!1,value:{index:T}}),w.index>-1){var k=o.pointColl[w.index].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:k,strokeWidth:o.pointColl[w.index].strokeWidth}})}}if(S.freehandSelectedIndex=null,o.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:S}}),!t.isNullOrUndefined(w.index)&&w.index>-1)o.notify("freehand-draw",{prop:"selectFhd",value:{type:"ok"}}),o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:null}}),t.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}});else if(S.freehandSelectedIndex){o.okBtn();k=o.pointColl[S.freehandSelectedIndex].strokeColor;o.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:k,strokeWidth:o.pointColl[S.freehandSelectedIndex].strokeWidth}})}else this.findTargetObj(O,x,!1)&&this.findTarget(O,x,i.type)}else{if(this.isFhdEditing&&(o.notify("freehand-draw",{prop:"cancelFhd",value:{type:"ok"}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none")),t.isBlazor()||o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),this.isFhdEditing=!1,j?this.setCursor(O,x):"default"!==n&&(o.upperCanvas.style.cursor=o.cursor=n),"crosshair"===o.cursor||t.Browser.isDevice&&o.togglePen){if(o.togglePen){if(t.isNullOrUndefined(o.activeObj.strokeSettings)){var F={strokeSettings:{}};o.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:F}}),o.activeObj.strokeSettings=F.strokeSettings}var A={penStrokeWidth:null};o.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:A}}),t.isNullOrUndefined(A.penStrokeWidth)&&o.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:2}}),this.upperContext.strokeStyle=o.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=o.activeObj.strokeSettings.strokeColor,o.notify("freehand-draw",{prop:"freehandDownHandler",onPropertyChange:!1,value:{e:i,canvas:o.upperCanvas}})}else o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height);o.currObjType.isActiveObj=!1,this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0}"crosshair"!==o.cursor&&"touchstart"===i.type.toLowerCase()||o.currObjType.isActiveObj&&"default"!==o.cursor&&!o.togglePen?this.findTarget(O,x,i.type):""!==o.currObjType.shape&&!o.currObjType.isCustomCrop||o.togglePen||"default"===o.cursor||this.setActivePoint(O,x)}}else this.applyObj(r,a)&&(o.okBtn(!0),C&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})),this.isFhdEditing&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.isFhdCustomized=!1,t.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),!o.activeObj.shape||"rectangle"!==o.activeObj.shape&&"ellipse"!==o.activeObj.shape&&"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape&&"path"!==o.activeObj.shape&&"text"!==o.activeObj.shape&&"image"!==o.activeObj.shape||(o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()?o.updateToolbar(o.element,"imageLoaded"):(o.notify("toolbar",{prop:"setCurrentToolbar",value:{type:"main"}}),o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}))),this.canvasMouseDownHandler(i);this.isShapeInserted=!1,this.tempActiveObj=t.extend({},o.activeObj,{},!0)}},i.prototype.mouseMoveEventHandler=function(i){var o=this.parent,r=o.cursor,a=o.upperCanvas.style.cursor;i.preventDefault();var n=o.lowerCanvas.getBoundingClientRect();if("touchmove"!==i.type||2!==i.touches.length){var s,l;"mousemove"===i.type?(s=i.clientX,l=i.clientY):(this.touchEndPoint.x=s=i.touches[0].clientX,this.touchEndPoint.y=l=i.touches[0].clientY),s-=n.left,l-=n.top,this.canvasMouseMoveHandler(i);var p,h=!1;void 0!==o.activeObj.shape&&(p=o.activeObj.shape.split("-")),void 0!==p&&"crop"===p[0]&&(h=!0),h&&o.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}}),o.upperCanvas.style.cursor=a,o.cursor=r,(o.currObjType.isActiveObj&&(void 0!==o.activeObj.activePoint||o.objColl.length>0)&&!this.dragCanvas||void 0!==o.activeObj.activePoint)&&""===this.dragElement&&(this.setCursor(s,l),o.activeObj.activePoint&&(0===o.activeObj.activePoint.width||!t.isNullOrUndefined(o.activeObj.currIndex)&&this.cursorTargetId!==o.activeObj.currIndex)&&"default"!==o.cursor&&"move"!==o.cursor&&"crosshair"!==o.cursor&&"grab"!==o.cursor&&"pointer"!==o.cursor&&(o.upperCanvas.style.cursor=o.cursor="move"),this.findTarget(s,l,i.type)),o.currObjType.isDragging&&(this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.updateActivePoint(s,l,h),o.notify("shape",{prop:"updateTrianglePoints",onPropertyChange:!1,value:{obj:o.activeObj}}),this.isPreventDragging?(o.activeObj.activePoint.startX>o.img.destLeft&&o.activeObj.activePoint.endX<o.img.destLeft+o.img.destWidth&&o.activeObj.activePoint.startY>o.img.destTop&&o.activeObj.activePoint.endY<o.img.destTop+o.img.destHeight&&(this.isPreventDragging=!1),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:null,saveContext:null,isPreventSelection:null}}),h&&(this.dragCanvas=o.togglePan=!0))}else{if(this.isFirstMove)this.startTouches=this.targetTouches(i.touches),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft-n.left,y:(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top}),this.tempTouches.push({x:(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,y:(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top});else{var c=(i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft)-n.left,d=(i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop)-n.top,v=(i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft)-n.left,u=(i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop)-n.top,g={x:c<v?v-(v-c)/2:c-(c-v)/2,y:d<u?u-(u-d)/2:d-(d-u)/2};if(this.currMousePoint.x!==g.x&&this.currMousePoint.y!==g.y){var b="";if("touchmove"===i.type&&(o.zoomSettings.zoomTrigger&e.ZoomTrigger.Pinch)===e.ZoomTrigger.Pinch){this.zoomType="Pinch";var f=this.calculateScale(this.startTouches,this.targetTouches(i.touches));this.startTouches=this.targetTouches(i.touches),f>1?b="zoomIn":f<1&&(b="zoomOut")}""!==b&&o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:g.x,y:g.y,type:b}}),this.tempTouches=[],this.tempTouches.push({x:i.touches[0].clientX||i.touches[0].pageX-o.lowerCanvas.offsetLeft,y:i.touches[0].clientY||i.touches[0].pageY-o.lowerCanvas.offsetTop}),this.tempTouches.push({x:i.touches[1].clientX||i.touches[1].pageX-o.lowerCanvas.offsetLeft,y:i.touches[1].clientY||i.touches[1].pageY-o.lowerCanvas.offsetTop}),this.currMousePoint.x=g.x,this.currMousePoint.y=g.y}}this.isFirstMove=!1}},i.prototype.mouseUpEventHandler=function(e){var i=this,o=this.parent;"touchstart"===e.type?this.isTouch=!1:"touchend"===e.type&&e.stopImmediatePropagation(),e.preventDefault(),o.togglePan&&this.canvasMouseUpHandler(e);var r,a;"mouseup"===e.type?(r=e.clientX,a=e.clientY):(r=this.touchEndPoint.x,a=this.touchEndPoint.y);var n=o.lowerCanvas.getBoundingClientRect();r-=n.left,a-=n.top,"touchend"===e.type&&(this.startTouches=this.tempTouches=[],this.isFirstMove=!1,"none"===o.textArea.style.display&&(this.timer=0));var s,l=!1;if(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),t.isBlazor()&&this.parent.eventType){if("pan"===this.parent.eventType)o.events&&!0===o.events.onPanEnd.hasDelegate&&o.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanEnd",this.parent.panEventArgs);else if("resize"===this.parent.eventType){if(!this.isCropSelection&&this.parent.events&&!0===this.parent.events.onShapeResizeEnd.hasDelegate)this.shapeResizingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeResizingArgs.action=""!==this.currentDrawingShape?"drawing":"resize-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeResizeEnd",this.shapeResizingArgs).then(function(e){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})});else if(this.shapeResizingArgs&&this.selectionResizingArgs&&this.parent.events&&!0===this.parent.events.onSelectionResizeEnd.hasDelegate){var p={type:this.parent.activeObj.shape,startX:this.shapeResizingArgs.currentShapeSettings.startX,startY:this.shapeResizingArgs.currentShapeSettings.startY,width:this.shapeResizingArgs.currentShapeSettings.width,height:this.shapeResizingArgs.currentShapeSettings.height};this.selectionResizingArgs.currentSelectionSettings=p,this.selectionResizingArgs.action="resize-end",this.parent.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeEnd",this.selectionResizingArgs).then(function(e){i.parent.notify("shape",{prop:"updateSelectionChangeEventArgs",onPropertyChange:!1,value:{selectionSettings:e.currentSelectionSettings}})})}}else this.shapeMovingArgs&&this.parent.events&&!0===this.parent.events.onShapeDragEnd.hasDelegate&&(this.shapeMovingArgs.currentShapeSettings=this.updatePrevShapeSettings(),this.shapeMovingArgs.action="drag-end",this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShapeDragEnd",this.shapeMovingArgs).then(function(e){i.parent.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}})}));this.shapeResizingArgs=null,this.shapeMovingArgs=null,this.parent.panEventArgs=null,this.parent.eventType=null}if("path"!==this.currentDrawingShape){if(e.currentTarget===o.upperCanvas&&!o.isResize){if(this.pathAdjustedIndex=null,""!==this.currentDrawingShape){if("text"===this.currentDrawingShape){var h=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.initialPrevObj,previousObjColl:this.initialPrevObj.objColl,previousPointColl:this.initialPrevObj.pointColl,previousSelPointColl:this.initialPrevObj.selPointColl,previousCropObj:h,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:this.initialPrevObj.objColl}});this.isShapeInserted=!0,this.currentDrawingShape="",0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&o.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});var c=this.updatePrevShapeSettings(),d={action:"draw-end",previousShapeSettings:c},v={action:"move",previousShapeSettings:c};this.shapeResizingArgs=d,this.shapeMovingArgs=v,this.triggerShapeChange(d,v,"mouse-up")}this.adjustActObjForLineArrow(),this.updPtCollForShpRot(),o.currObjType.shape=o.currObjType.shape.toLowerCase();var u=t.extend({},o.cropObj,{},!0),g={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:g}});var b=g.currObj;b.objColl=t.extend([],o.objColl,[],!0),b.pointColl=t.extend([],o.pointColl,[],!0),b.afterCropActions=t.extend([],o.afterCropActions,[],!0);var f={selPointColl:null};if(o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:f}}),b.selPointColl=t.extend([],f.selPointColl,[],!0),o.togglePen||l||(this.tempObjColl&&0!==o.activeObj.activePoint.width&&(o.objColl.push(o.activeObj),JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(this.tempActiveObj.activePoint)&&o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:b,previousObjColl:this.tempObjColl,previousPointColl:b.pointColl,previousSelPointColl:b.selPointColl,previousCropObj:u,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.redrawShape(o.objColl[o.objColl.length-1],!0),this.tempObjColl=void 0),this.isFhdEditing||(this.applyCurrActObj(r,a),o.currObjType.isResize=!1,t.isBlazor()||o.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),o.activeObj){var m,C=!1;if(void 0!==o.activeObj.shape&&(m=o.activeObj.shape.split("-")),void 0===m&&(o.currObjType.isCustomCrop||o.togglePen)?C=!0:void 0!==m&&"crop"===m[0]&&(C=!0),t.isBlazor())"rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape||"image"===o.activeObj.shape?o.updateToolbar(o.element,o.activeObj.shape):"text"===o.activeObj.shape&&"none"===o.textArea.style.display&&o.updateToolbar(o.element,"text");else{if("rectangle"===o.activeObj.shape||"ellipse"===o.activeObj.shape||"line"===o.activeObj.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if("text"===o.activeObj.shape)"none"===o.textArea.style.display&&o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(this.isFhdEditing)o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});else if(!C){o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:!1,isZooming:null}})}o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})}}}void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),void 0!==s&&"crop"===s[0]&&(l=!0),o.activeObj.shape&&!l&&e.currentTarget===o.upperCanvas&&"none"===o.textArea.style.display&&("text"===o.activeObj.shape?t.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):t.isBlazor()||o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),t.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),o.togglePen&&e.currentTarget===o.upperCanvas?o.notify("freehand-draw",{prop:"freehandUpHandler",onPropertyChange:!1,value:{e:e,canvas:o.upperCanvas,context:this.upperContext}}):o.currObjType.shape="",this.dragElement="",o.currObjType.isInitialLine=o.currObjType.isDragging=!1,this.selMouseUpEvent()}else{var y=e.srcElement;e.currentTarget!==o.upperCanvas&&e.currentTarget!==o.lowerCanvas&&o.activeObj.pointColl.length>0&&(y.classList.contains("e-upload-icon")||y.parentElement.id===o.element.id+"_zoomIn"||y.parentElement.id===o.element.id+"_zoomOut"||y.parentElement.id===o.element.id+"_annotationBtn"||y.parentElement.id===o.element.id+"_borderColorBtn"||y.parentElement.id===o.element.id+"_borderWidthBtn"||y.parentElement.id===o.element.id+"_saveBtn")&&(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:e,isApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}))}},i.prototype.adjustActObjForLineArrow=function(e){var t=!1,i=this.parent;if((e=e||i.activeObj).shape&&("line"===e.shape||"arrow"===i.activeObj.shape)){var o=void 0;if(("e-resize"===this.dragElement&&e.activePoint.endX<e.activePoint.startX||"w-resize"===this.dragElement&&e.activePoint.startX>e.activePoint.endX)&&(t=!0,o=e.activePoint.startX,e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=o,o=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=o),e.activePoint.width=Math.abs(e.activePoint.endX-e.activePoint.startX),e.activePoint.height=Math.abs(e.activePoint.endY-e.activePoint.startY),"path"!==i.activeObj.shape){i.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:e}});for(var r=0;r<e.pointColl.length;r++)e.pointColl[r].ratioX=(e.pointColl[r].x-i.img.destLeft)/i.img.destWidth,e.pointColl[r].ratioY=(e.pointColl[r].y-i.img.destTop)/i.img.destHeight}}return t},i.prototype.updPtCollForShpRot=function(e){var t=this.parent;if((e=e||t.activeObj).shape&&0!==e.rotatedAngle){t.notify("shape",{prop:"setPointCollForShapeRotation",onPropertyChange:!1,value:{obj:e}});for(var i=0;i<e.horTopLinePointColl.length;i++)e.horTopLinePointColl[i].ratioX=(e.horTopLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.horTopLinePointColl[i].ratioY=(e.horTopLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.horBottomLinePointColl.length;i++)e.horBottomLinePointColl[i].ratioX=(e.horBottomLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.horBottomLinePointColl[i].ratioY=(e.horBottomLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.verLeftLinePointColl.length;i++)e.verLeftLinePointColl[i].ratioX=(e.verLeftLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.verLeftLinePointColl[i].ratioY=(e.verLeftLinePointColl[i].y-t.img.destTop)/t.img.destHeight;for(i=0;i<e.verRightLinePointColl.length;i++)e.verRightLinePointColl[i].ratioX=(e.verRightLinePointColl[i].x-t.img.destLeft)/t.img.destWidth,e.verRightLinePointColl[i].ratioY=(e.verRightLinePointColl[i].y-t.img.destTop)/t.img.destHeight}},i.prototype.setXYPoints=function(e){e.preventDefault();var t,i;"mousedown"===e.type?(t=e.clientX,i=e.clientY):(this.touchEndPoint.x=t=e.touches[0].clientX,this.touchEndPoint.y=i=e.touches[0].clientY);var o=this.parent.lowerCanvas.getBoundingClientRect();return t-=o.left,i-=o.top,{x:t,y:i}},i.prototype.getCurrentIndex=function(){for(var e,t=this.parent,i=0;i<t.objColl.length;i++)if(t.activeObj.currIndex===t.objColl[i].currIndex){e=i;break}return e},i.prototype.isShapeClick=function(e,i){var o=this.parent,r=!1;if(o.togglePen)return r;if(o.activeObj.shape&&"text"===o.activeObj.shape&&this.isShapeInserted){var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),r&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}})),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;h=this.getCurrentIndex();t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1)}}return r},i.prototype.isShapeTouch=function(e,i){var o=this.parent,r=!1;if("touchstart"===e.type&&!o.togglePen){o.activeObj&&"text"===o.activeObj.shape&&(this.timer=setTimeout(this.setTimer.bind(this),1e3,e));var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(r=this.findTargetObj(l,p,i),i||this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(!r&&n.shape){o.activeObj=n;h=this.getCurrentIndex();i||(t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.isFreehandDrawTouch=function(e,i){var o=this.parent,r=!1;if("touchstart"===e.type&&!i&&!o.togglePen){var a="block"===o.textArea.style.display,n=t.extend({},o.activeObj,null,!0);o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}});var s=this.setXYPoints(e),l=s.x,p=s.y;if(this.setCursor(l,p),this.isFhdPoint&&(r=!0),a){o.textArea.value=o.objColl[o.objColl.length-1].keyHistory,o.textArea.style.display="block",o.activeObj=n;var h=this.getCurrentIndex();t.isNullOrUndefined(h)?o.objColl.pop():o.objColl.splice(h,1)}else if(n.shape){o.activeObj=n;h=this.getCurrentIndex();i||(t.isNullOrUndefined(h)||JSON.stringify(o.activeObj.activePoint)!==JSON.stringify(o.objColl[h].activePoint)?t.isNullOrUndefined(o.activeObj.currIndex)&&o.objColl.pop():o.objColl.splice(h,1))}}return r},i.prototype.applyObj=function(e,t){var i=this.parent,o=!1;return!i.activeObj.shape||"rectangle"!==i.activeObj.shape&&"ellipse"!==i.activeObj.shape&&"text"!==i.activeObj.shape&&"line"!==i.activeObj.shape&&"arrow"!==i.activeObj.shape&&"path"!==i.activeObj.shape&&"image"!==i.activeObj.shape||(o=!(e>=i.activeObj.activePoint.startX-2*i.activeObj.topLeftCircle.radius&&e<=i.activeObj.activePoint.endX+2*i.activeObj.topLeftCircle.radius&&t>=i.activeObj.activePoint.startY-2*i.activeObj.topLeftCircle.radius&&t<=i.activeObj.activePoint.endY+2*i.activeObj.topLeftCircle.radius)&&("default"===i.upperCanvas.style.cursor||"grab"===i.upperCanvas.style.cursor||"crosshair"===i.upperCanvas.style.cursor||"pointer"===i.upperCanvas.style.cursor||"move"===i.upperCanvas.style.cursor)),o},i.prototype.applyCurrShape=function(e){var i=this.parent,o=!1;if(i.togglePen)return o;var r=t.extend({},i.activeObj,null,!0);if(this.isShapeInserted&&"text"===i.activeObj.shape&&e&&(this.isInitialTextEdited=!0,i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}})),"block"===i.textArea.style.display){var a=t.extend({},i.activeObj,null,!0);i.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),r=t.extend({},i.objColl[i.objColl.length-1],null,!0),i.objColl.pop(),i.activeObj=t.extend({},a,null,!0),i.textArea.value=r.keyHistory,i.textArea.style.display="block";var n=r.strokeSettings&&r.strokeSettings.strokeColor?"rgb"===r.strokeSettings.strokeColor.split("(")[0]?this.rgbToHex(parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[0]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[1]),parseFloat(r.strokeSettings.strokeColor.split("(")[1].split(",")[2])):r.strokeSettings.strokeColor:null;n&&"#ffffff"===n&&(n="#fff"),this.tempActiveObj.strokeSettings&&this.tempActiveObj.strokeSettings.strokeColor&&"#ffffff"===this.tempActiveObj.strokeSettings.strokeColor&&(this.tempActiveObj.strokeSettings.strokeColor="#fff"),(r.keyHistory!==this.tempActiveObj.keyHistory||n&&n!==this.tempActiveObj.strokeSettings.strokeColor||r.textSettings&&r.textSettings.fontFamily!==this.tempActiveObj.textSettings.fontFamily||r.textSettings&&Math.round(r.textSettings.fontSize)!==Math.round(this.tempActiveObj.textSettings.fontSize)||r.textSettings&&Math.round(r.textSettings.fontRatio)!==Math.round(this.tempActiveObj.textSettings.fontRatio)||r.textSettings&&r.textSettings.bold!==this.tempActiveObj.textSettings.bold||r.textSettings&&r.textSettings.italic!==this.tempActiveObj.textSettings.italic||r.textSettings&&r.textSettings.underline!==this.tempActiveObj.textSettings.underline)&&(o=!0),this.isInitialTextEdited&&!o&&(o=!0,this.isInitialTextEdited=!1)}else this.tempActiveObj.activePoint.height=Math.abs(this.tempActiveObj.activePoint.height),o=JSON.stringify(r)!==JSON.stringify(this.tempActiveObj);return o},i.prototype.canvasMouseDownHandler=function(e){var i=this.parent;e.preventDefault();var o,r;"mousedown"===e.type?(o=e.offsetX||e.pageX-i.lowerCanvas.offsetLeft,r=e.offsetY||e.pageY-i.lowerCanvas.offsetTop):(o=e.touches[0].clientX||e.touches[0].pageX-i.lowerCanvas.offsetLeft,r=e.touches[0].clientY||e.touches[0].pageY-i.lowerCanvas.offsetTop);var a=i.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top,this.panDown={x:o,y:r};var n={tempPanMove:null};i.notify("transform",{prop:"getTempPanMove",onPropertyChange:!1,value:{obj:n}}),t.isNullOrUndefined(n.tempPanMove)&&i.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}})},i.prototype.canvasMouseMoveHandler=function(e){var t=this.parent,i={bool:null};if(t.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:i}}),t.isResize||i.bool)t.upperCanvas.style.cursor="default";else{this.dragCanvas?t.lowerCanvas.style.cursor="grab":(this.dragCanvas=t.togglePan=!1,t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="default");var o,r;"mousemove"===e.type?(o=e.offsetX,r=e.offsetY):(o=e.touches[0].clientX||e.touches[0].pageX-t.lowerCanvas.offsetLeft,r=e.touches[0].clientY||e.touches[0].pageY-t.lowerCanvas.offsetTop);var a=t.lowerCanvas.getBoundingClientRect(),n={x:o-=a.left,y:r-=a.top};t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:{x:o,y:r}}}),this.panDown&&n&&t.togglePan&&this.dragCanvas&&t.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:null,yDiff:null}})}},i.prototype.canvasMouseUpHandler=function(e){var t=this.parent;e.preventDefault();var i={panMove:null};t.notify("transform",{prop:"getPanMove",onPropertyChange:!1,value:{obj:i}}),t.togglePan&&this.panDown&&i.panMove&&t.togglePan&&this.dragCanvas&&(this.panDown=null,t.notify("transform",{prop:"setPanMove",onPropertyChange:!1,value:{point:null}}),t.notify("transform",{prop:"setTempPanMove",onPropertyChange:!1,value:{point:null}})),"path"!==this.currentDrawingShape&&(t.currObjType.isDragging=!1)},i.prototype.touchStartHandler=function(e){e.preventDefault(),0===this.touchTime?this.touchTime=(new Date).getTime():(new Date).getTime()-this.touchTime<400?(this.parent.notify("shape",{prop:"stopPathDrawing",onPropertyChange:!1,value:{e:e,isApply:null}}),this.touchTime=0):this.touchTime=(new Date).getTime(),2===e.touches.length?this.isFirstMove=!0:this.mouseDownEventHandler(e),t.EventHandler.add(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler,this),t.EventHandler.add(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler,this),t.EventHandler.add(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler,this),t.EventHandler.add(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler,this)},i.prototype.unwireEvent=function(){t.EventHandler.remove(this.parent.lowerCanvas,"touchend",this.mouseUpEventHandler),t.EventHandler.remove(this.parent.lowerCanvas,"touchmove",this.mouseMoveEventHandler),t.EventHandler.remove(this.parent.upperCanvas,"touchend",this.mouseUpEventHandler),t.EventHandler.remove(this.parent.upperCanvas,"touchmove",this.mouseMoveEventHandler)},i.prototype.keyDownEventHandler=function(i){var o=this,r=this.parent;!i.ctrlKey||"+"!==i.key&&"-"!==i.key||i.preventDefault();var a={fileName:"",fileType:null};r.notify("draw",{prop:"getFileName",onPropertyChange:!1,value:{obj:a}});var n={fileName:a.fileName,fileType:a.fileType,cancel:!1};switch(i.key){case i.ctrlKey&&"s":t.isBlazor()&&r.events&&!0===r.events.saving.hasDelegate?r.dotNetRef.invokeMethodAsync("BeforeSaveEventAsync","BeforeSave",n).then(function(e){o.beforeSaveEvent(e,i)}):(r.trigger("beforeSave",n),this.beforeSaveEvent(n,i));break;case i.ctrlKey&&"z":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-undo"});break;case i.ctrlKey&&"y":r.allowUndoRedo&&r.notify("undo-redo",{prop:"call-redo"});break;case i.ctrlKey&&"+":(r.zoomSettings.zoomTrigger&e.ZoomTrigger.Commands)===e.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null},isResize:null}));break;case i.ctrlKey&&"-":(r.zoomSettings.zoomTrigger&e.ZoomTrigger.Commands)===e.ZoomTrigger.Commands&&(this.zoomType="Commands",r.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null},isResize:null}));break;case"Delete":this.deleteItem();break;case"Escape":r.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});break;case"Enter":this.performEnterAction(i);break;case"Tab":this.performTabAction();break;default:t.Browser.isDevice&&"block"===r.textArea.style.display&&setTimeout(this.textKeyDown.bind(this),1,i)}},i.prototype.performEnterAction=function(e){var t=this.parent;if(t.isResize){var i=this.getNumTextValue(),o=this.parent.element.querySelector("#"+this.parent.element.id+"_aspectratio"),r=this.parent.element.querySelector(".e-ie-toolbar-aspect-ratio-btn");i&&i.x&&i.y&&(o||r&&!r.classList.contains("e-hidden")?t.notify("transform",{prop:"resize",value:{width:i.x,height:null,isAspectRatio:!0}}):t.notify("transform",{prop:"resize",value:{width:i.x,height:i.y,isAspectRatio:!1}}))}else{var a=void 0;t.activeObj.shape&&(a=t.activeObj.shape.split("-")),e&&this.isKeyBoardCrop(e)&&t.activeObj.horTopLine&&t.activeObj.shape&&"crop"===a[0]&&t.crop()}},i.prototype.isKeyBoardCrop=function(e){var i=!1,o=e.target;return o.id!==this.parent.element.id+"_ok"&&""!==o.id||t.isBlazor()||(i=!0),i},i.prototype.beforeSaveEvent=function(e,t){var i=this.parent;e.cancel||i.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e.fileType,fileName:e.fileName}}),t.preventDefault(),t.stopImmediatePropagation()},i.prototype.handleScroll=function(i){var o,r,a=this.parent,n=!1;"mousewheel"===i.type&&(o=i.clientX,r=i.clientY);var s=a.lowerCanvas.getBoundingClientRect();if(o-=s.left,r-=s.top,o>a.img.destLeft&&o<a.img.destLeft+a.img.destWidth&&r>a.img.destTop&&r<a.img.destTop+a.img.destHeight&&(n=!0),i.stopPropagation(),!0===i.ctrlKey&&n){i.preventDefault(),!a.isCropTab&&a.activeObj.shape&&"crop"!==a.activeObj.shape.split("-")[0]&&(a.okBtn(),t.isBlazor()||a.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}));var l="";"mousewheel"===i.type&&(a.zoomSettings.zoomTrigger&e.ZoomTrigger.MouseWheel)===e.ZoomTrigger.MouseWheel&&(this.zoomType="MouseWheel",l=i.wheelDelta>0?"zoomIn":"zoomOut"),""!==l&&a.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:o,y:r,type:l}})}},i.prototype.textKeyDown=function(e){var i=this.parent;"\r"===String.fromCharCode(e.which)&&(this.textRow+=1),i.textArea.setAttribute("rows",this.textRow.toString()),i.textArea.style.height="auto",i.textArea.style.height=i.textArea.scrollHeight+"px",i.notify("shape",{prop:"setTextBoxWidth",onPropertyChange:!1,value:{e:e}}),t.Browser.isDevice&&(i.textArea.style.width=parseFloat(i.textArea.style.width)+i.textArea.style.fontSize+"px");var o=i.textArea.value.split("\n");this.textRow=o.length,i.textArea.setAttribute("rows",this.textRow.toString()),this.isInitialTextEdited=!1},i.prototype.clearSelection=function(){var e=this.parent;!e.disabled&&e.isImageLoaded&&(e.togglePen=!1,e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.dragElement="",this.dragPoint.startX=this.dragPoint.startY=this.dragPoint.endX=this.dragPoint.endY=0,e.currObjType.shape="",this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.currObjType.isActiveObj=!0,e.currObjType.isCustomCrop=!1,e.upperCanvas.style.cursor=e.cursor="default")},i.prototype.setDragDirection=function(e,t){var i=this.parent;i.img.destWidth>i.img.destHeight?(i.activeObj.activePoint.startX=this.dragPoint.startX=e/2-t/2+7.5,i.activeObj.activePoint.startY=this.dragPoint.startY=t/2-t/2+7.5,i.activeObj.activePoint.endX=e/2+t/2-7.5,i.activeObj.activePoint.endY=t/2+t/2-7.5):(i.activeObj.activePoint.startY=this.dragPoint.startX=t/2-e/2+7.5,i.activeObj.activePoint.endY=t/2+e/2-7.5,i.activeObj.activePoint.startX=this.dragPoint.startX=7.5,i.activeObj.activePoint.endX=e-7.5)},i.prototype.calcShapeRatio=function(e,t,i,o){for(var r=this.parent,a=i,n=o,s=a>=n?a:n,l=s*(e/t),p=s,h=this.getScale(l,a),c=[],d=0;d<2;d++)0===d?c.push(l*h):c.push(p*h);l=c[0],p=c[1];var v=this.getScale(p,n),u=[];for(d=0;d<2;d++)0===d?u.push(l*v):u.push(p*v);l=u[0],p=u[1],r.activeObj.activePoint.width=l,r.activeObj.activePoint.height=p,r.activeObj.activePoint.startX=7.5+(this.dragPoint.startX=(a-l)/2),r.activeObj.activePoint.startY=7.5+(this.dragPoint.startY=(n-p)/2),r.activeObj.activePoint.endX=(a-l)/2+l-7.5,r.activeObj.activePoint.endY=(n-p)/2+p-7.5,r.activeObj.activePoint.startX<r.img.destLeft&&r.img.destLeft+r.img.destWidth>r.lowerCanvas.clientWidth&&(r.activeObj.activePoint.startX=r.img.destLeft,r.activeObj.activePoint.endX=r.activeObj.activePoint.startX+l-7.5),r.activeObj.activePoint.startY<r.img.destTop&&r.img.destTop+r.img.destHeight>r.lowerCanvas.clientHeight&&(r.activeObj.activePoint.startY=r.img.destTop,r.activeObj.activePoint.endY=r.activeObj.activePoint.startY+p-7.5),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY},i.prototype.getScale=function(e,t){return e>t?t/e:1},i.prototype.findTarget=function(e,t,i){var o=this.parent;if("mousedown"===i.toLowerCase()||"touchstart"===i.toLowerCase()){var r=!1;o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]&&(r=!0),this.findTargetObj(e,t,r),this.updateCursorStyles(e,t,i)}else switch(this.dragElement.toLowerCase()){case"nw-resize":o.activeObj.topLeftCircle.startX=e,o.activeObj.topLeftCircle.startY=t;break;case"n-resize":o.activeObj.topCenterCircle.startX=e,o.activeObj.topCenterCircle.startY=t;break;case"ne-resize":o.activeObj.topRightCircle.startX=e,o.activeObj.topRightCircle.startY=t;break;case"w-resize":o.activeObj.centerLeftCircle.startX=e,o.activeObj.centerLeftCircle.startY=t;break;case"e-resize":o.activeObj.centerRightCircle.startX=e,o.activeObj.centerRightCircle.startY=t;break;case"sw-resize":o.activeObj.bottomLeftCircle.startX=e,o.activeObj.bottomLeftCircle.startY=t;break;case"s-resize":o.activeObj.bottomCenterCircle.startX=e,o.activeObj.bottomCenterCircle.startY=t;break;case"se-resize":o.activeObj.bottomRightCircle.startX=e,o.activeObj.bottomRightCircle.startY=t;break;default:this.dragPoint.startX&&this.dragPoint.startY&&(this.previousPoint.x=this.dragPoint.endX,this.previousPoint.y=this.dragPoint.endY,this.dragPoint.endX=e,this.dragPoint.endY=t)}},i.prototype.findTargetObj=function(e,i,o){var r=this,a=this.parent,n=!1;if(0!==a.objColl.length&&!a.currObjType.isCustomCrop&&!o){for(var s=0,l=void 0,p=0;p<a.objColl.length;p++){var h=a.upperCanvas.style.cursor;this.setCursor(e,i);var c=t.extend({},a.objColl[p],{},!0);if("line"===c.shape||"arrow"===c.shape){for(var d=0;d<c.pointColl.length;d++)if(e>=c.pointColl[d].x-2*c.topLeftCircle.radius&&e<=c.pointColl[d].x+2*c.topLeftCircle.radius&&i>=c.pointColl[d].y-2*c.topLeftCircle.radius&&i<=c.pointColl[d].y+2*c.topLeftCircle.radius){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p);break}}else if("path"===c.shape){var v=this.setCursorForPath(c,e,i,a.upperCanvas);if("default"!==v&&"grab"!==v){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}else if(0!==c.rotatedAngle){var u=this.setCursorForRotatedObject(c,e,i,a.upperCanvas);if("default"!==u&&"grab"!==u){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===a.cursor||"grab"===a.cursor||this.isShapeInserted?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}else{var g=this.getTransRotationPoint(c);if(e>=c.activePoint.startX-2*c.topLeftCircle.radius&&e<=c.activePoint.endX+2*c.topLeftCircle.radius&&i>=c.activePoint.startY-2*c.topLeftCircle.radius&&i<=c.activePoint.endY+2*c.topLeftCircle.radius||g&&e>=g.x-2*c.topLeftCircle.radius&&e<=g.x+2*c.topLeftCircle.radius&&i>=g.y-2*c.topLeftCircle.radius&&i<=g.y+2*c.topLeftCircle.radius){if(this.tempActiveObj&&this.tempActiveObj.activePoint&&JSON.stringify(this.tempActiveObj.activePoint)===JSON.stringify(c.activePoint)){l=p;break}this.isTouch||"move"===h||"grabbing"===h||this.isShapeInserted||"move"===a.cursor||"grabbing"===a.cursor?(0===s||s>e-c.activePoint.startX)&&(s=e-a.objColl[p].activePoint.startX,l=p):a.objColl[p].currIndex===this.tempActiveObj.currIndex&&(l=p)}}}if(t.isNullOrUndefined(l))a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),n=!1;else{this.tempObjColl=t.extend([],a.objColl,[],!0),a.currObjType.isCustomCrop=!1,a.activeObj=t.extend({},a.objColl[l],{},!0);var b=t.extend({},a.objColl[l],{},!0);if(a.objColl.splice(l,1),0===a.transform.degree){var f=this.lowerContext.filter;this.lowerContext.clearRect(0,0,a.lowerCanvas.width,a.lowerCanvas.height),a.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter="none",a.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),a.activeObj=t.extend({},f,{},!0),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=f,this.getCurrentFlipState()}else a.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),a.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}});a.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(a.currSelectionPoint&&"crop-circle"===a.currSelectionPoint.shape||a.isCircleCrop)&&a.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),a.activeObj=t.extend({},b,{},!0),this.setActivePoint(),a.activeObj=t.extend({},b,{},!0);var m=t.extend({},a.activeObj.strokeSettings,{},!0);a.notify("draw",{prop:"setTempStrokeSettings",onPropertyChange:!1,value:{tempStrokeSettings:m}});var C=t.extend({},a.activeObj.textSettings,{},!0);a.notify("draw",{prop:"setTempTextSettings",onPropertyChange:!1,value:{tempTextSettings:C}});var y=this.updatePrevShapeSettings(),j={action:"select",previousShapeSettings:y,currentShapeSettings:y};"line"!==a.activeObj.shape&&"arrow"!==a.activeObj.shape||(j.currentShapeSettings.width=a.activeObj.activePoint.endX-a.activeObj.activePoint.startX,j.currentShapeSettings.height=a.activeObj.activePoint.endY-a.activeObj.activePoint.startY),this.isCropSelection=!1;var P=void 0;if(void 0!==a.activeObj.shape&&(P=a.activeObj.shape.split("-")),void 0!==P&&"crop"===P[0]&&(this.isCropSelection=!0),!this.isCropSelection&&t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&a.events&&!0===a.events.shapeChanging.hasDelegate)a.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",j).then(function(e){r.shapeEvent(e)});else if(this.isCropSelection){var O={action:j.action,previousSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:j.previousShapeSettings.startX,startY:j.previousShapeSettings.startY,width:j.previousShapeSettings.width,height:j.previousShapeSettings.height},currentSelectionSettings:{type:a.getSelectionType(a.activeObj.shape),startX:j.currentShapeSettings.startX,startY:j.currentShapeSettings.startY,width:j.currentShapeSettings.width,height:j.currentShapeSettings.height}};t.isBlazor()&&a.events&&!0===a.events.onSelectionResizeStart.hasDelegate?a.dotNetRef.invokeMethodAsync("SelectionEventAsync","OnSelectionResizeStart",O).then(function(e){j.currentShapeSettings.startX=e.currentSelectionSettings.startX,j.currentShapeSettings.startY=e.currentSelectionSettings.startY,j.currentShapeSettings.width=e.currentSelectionSettings.width,j.currentShapeSettings.height=e.currentSelectionSettings.height,r.shapeEvent(j)}):(a.trigger("selectionChanging",O),j.currentShapeSettings.startX=O.currentSelectionSettings.startX,j.currentShapeSettings.startY=O.currentSelectionSettings.startY,j.currentShapeSettings.width=O.currentSelectionSettings.width,j.currentShapeSettings.height=O.currentSelectionSettings.height,this.shapeEvent(j))}else a.trigger("shapeChanging",j),this.shapeEvent(j);n=!0}}return n},i.prototype.shapeEvent=function(e){var i=this.parent;if(i.notify("shape",{prop:"updateShapeChangeEventArgs",onPropertyChange:!1,value:{shapeSettings:e.currentShapeSettings}}),i.activeObj.activePoint){var o={prevActObj:null};i.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:o}}),t.isNullOrUndefined(o.prevActObj)&&i.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:t.extend({},i.activeObj,{},!0)}}),"image"!==i.activeObj.shape||this.isImageClarity||(this.upgradeImageQuality(),this.isImageClarity=!0),i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:i.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:!0}}),this.isShapeInserted||(i.activeObj.activePoint.startX<i.img.destLeft?this.isPreventDragging=!0:i.activeObj.activePoint.endX>i.img.destLeft+i.img.destWidth?this.isPreventDragging=!0:i.activeObj.activePoint.startY<i.img.destTop?this.isPreventDragging=!0:i.activeObj.activePoint.endY>i.img.destTop+i.img.destHeight&&(this.isPreventDragging=!0))}},i.prototype.upgradeImageQuality=function(){var e=this.parent,i=t.extend({},e.activeObj,null,!0),o=e.activeObj.imageCanvas.getContext("2d"),r={width:0,height:0};e.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:e.activeObj.imageElement.width,height:e.activeObj.imageElement.height,obj:r,isImgShape:null}}),e.notify("shape",{prop:"updateObj",onPropertyChange:!1,value:{dimObj:r,x:null,y:null}}),o.clearRect(0,0,e.activeObj.imageCanvas.width,e.activeObj.imageCanvas.height),e.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:o,isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),e.activeObj=i},i.prototype.targetTouches=function(e){var t=this.parent.lowerCanvas.getBoundingClientRect();return[{x:e[0].pageX-t.left,y:e[0].pageY-t.top},{x:e[1].pageX-t.left,y:e[1].pageY-t.top}]},i.prototype.calculateScale=function(e,t){var i=this.getDistance(e[0],e[1]);return this.getDistance(t[0],t[1])/i},i.prototype.getDistance=function(e,t){var i=0,o=0;return e&&t&&(i=e.x-t.x,o=e.y-t.y),Math.sqrt(i*i+o*o)},i.prototype.redrawShape=function(e,t){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++)if(JSON.stringify(e)===JSON.stringify(i.objColl[o])){i.objColl.splice(o,1);break}this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),this.isPreventDragging?(i.activeObj.activePoint.startX>i.img.destLeft&&(this.isPreventDragging=!1),t&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}})):(t&&i.activeObj.rotatedAngle,i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:null,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}))},i.prototype.setTimer=function(e){this.timer>10&&(clearTimeout(this.timer),this.timer=0,this.parent.notify("shape",{prop:"findTextTarget",onPropertyChange:!1,value:{e:e}}),t.Browser.isDevice&&this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height))},i.prototype.applyCurrActObj=function(e,i){var o=this.parent,r=!1,a=t.extend({},o.activeObj,{},!0);if(!t.isNullOrUndefined(a.activePoint)){var n=a.topLeftCircle?a.topLeftCircle.radius:0;if(e>=Math.floor(a.activePoint.startX)&&e<=Math.ceil(a.activePoint.endX)&&i>=Math.floor(a.activePoint.startY)&&i<=Math.ceil(a.activePoint.endY))r=!0;else if(0!==n&&e>=Math.floor(a.activePoint.startX)-n&&e<=Math.ceil(a.activePoint.endX)+n&&i>=Math.floor(a.activePoint.startY)-n&&i<=Math.ceil(a.activePoint.endY)+n)r=!0,this.tempActiveObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[]};else if("text"!==a.shape&&"image"!==a.shape||""===this.dragElement)if("line"===a.shape||"arrow"===a.shape){var s={x:a.activePoint.startX<a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY<a.activePoint.endY?a.activePoint.startY:a.activePoint.endY},l={x:a.activePoint.startX>a.activePoint.endX?a.activePoint.startX:a.activePoint.endX,y:a.activePoint.startY>a.activePoint.endY?a.activePoint.startY:a.activePoint.endY};e>=Math.floor(s.x)-5&&e<=Math.ceil(l.x)+5&&i>=Math.floor(s.y)-5&&i<=Math.ceil(l.y)+5&&(r=!0)}else if("path"===a.shape){"move"===(p=this.setCursorForPath(a,e,i,o.upperCanvas))&&(r=!0)}else if("grabbing"===this.dragElement)r=!0;else if(0!==a.rotatedAngle){var p;("default"!==(p=this.setCursorForRotatedObject(a,e,i,o.upperCanvas))&&"grab"!==p||"n-resize"===this.dragElement||"e-resize"===this.dragElement||"s-resize"===this.dragElement||"w-resize"===this.dragElement)&&(r=!0)}else"block"===o.textArea.style.display&&(r=!0);else r=!0;if(!r){if(t.isNullOrUndefined(o.activeObj.currIndex)&&(o.activeObj.currIndex="shape_"+(o.objColl.length+1)),o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),void 0===o.activeObj.horTopLine||0===o.activeObj.horTopLine.startX||0===o.activeObj.horTopLine.endX||o.currObjType.isCustomCrop||""===o.currObjType.shape||o.objColl.push(t.extend({},o.activeObj,{},!0)),"text"===o.activeObj.shape||"ellipse"===o.currObjType.shape||"rectangle"===o.currObjType.shape||"line"===o.currObjType.shape||"arrow"===o.activeObj.shape||"path"===o.activeObj.shape||"image"===o.activeObj.shape){var h=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var c=0;c<o.objColl.length;c++){var d={isInside:!1};o.notify("crop",{prop:"isObjInImage",onPropertyChange:!1,value:{obj:o.objColl[c],object:d}}),d.isInside&&(o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:o.objColl[c].shape,obj:o.objColl[c],canvas:null}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=h,o.activeObj.shape&&o.notify("shape",{prop:"apply",onPropertyChange:!1,value:{shape:null,obj:null,canvas:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}t.isBlazor()||o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}}},i.prototype.getCurrentFlipState=function(){var e=this.parent;if(0!==e.rotateFlipColl.length){var i=t.extend({},e.panPoint.totalPannedInternalPoint,{},!0);e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1}),e.panPoint.totalPannedInternalPoint=i}else e.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1})},i.prototype.setTextBoxStylesToActObj=function(){var e=this.parent;e.activeObj.textSettings.fontFamily=e.textArea.style.fontFamily,e.activeObj.strokeSettings.strokeColor=""!==e.textArea.style.color&&e.textArea.style.color.split("(")[1]&&e.textArea.style.color.split("(")[1].split(",")[0]&&e.textArea.style.color.split("(")[1].split(",")[1]&&e.textArea.style.color.split("(")[1].split(",")[2]?this.rgbToHex(parseFloat(e.textArea.style.color.split("(")[1].split(",")[0]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[1]),parseFloat(e.textArea.style.color.split("(")[1].split(",")[2])):e.textArea.style.color,"bold"===e.textArea.style.fontWeight?e.activeObj.textSettings.bold=!0:e.activeObj.textSettings.bold=!1,"italic"===e.textArea.style.fontStyle?e.activeObj.textSettings.italic=!0:e.activeObj.textSettings.italic=!1,e.activeObj.textSettings.fontSize=parseFloat(e.textArea.style.fontSize)},i.prototype.rgbToHex=function(e,t,i){return"#"+this.componentToHex(e)+this.componentToHex(t)+this.componentToHex(i)},i.prototype.componentToHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},i.prototype.deleteItem=function(){var e=this.parent,i={};if(this.isFhdEditing){this.updateFreehandDrawColorChange();var o=t.extend({},e.cropObj,{},!0),r={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});(h=r.currObj).objColl=t.extend([],e.objColl,[],!0),h.pointColl=t.extend([],e.pointColl,[],!0),h.afterCropActions=t.extend([],e.afterCropActions,[],!0);var a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),h.selPointColl=t.extend([],a.selPointColl,[],!0);var n={freehandDrawSelectedId:null};e.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:n}}),e.notify("freehand-draw",{prop:"deleteFhd",value:{id:n.freehandDrawSelectedId}}),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteFreehandDrawing",previousObj:h,previousObjColl:this.tempObjColl,previousPointColl:h.pointColl,previousSelPointColl:h.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),e.notify("freehand-draw",{prop:"resetFreehandDrawSelectedId"})}else if("none"===e.textArea.style.display){n={prevActObj:null};if(e.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:n}}),n.prevActObj&&(n.prevActObj.activePoint.width=Math.abs(n.prevActObj.activePoint.width),n.prevActObj.activePoint.height=Math.abs(n.prevActObj.activePoint.height)),n.prevActObj&&JSON.stringify(n.prevActObj)!==JSON.stringify(e.activeObj)){var s=e.activeObj.currIndex;e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}});for(var l=0;l<e.objColl.length;l++)if(e.objColl[l].currIndex===s){e.objColl.splice(l,1),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}});break}}r={isNewPath:null};if(e.notify("draw",{prop:"getNewPath",value:{obj:r}}),r.isNewPath)e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1});else if(e.activeObj.shape){e.objColl.push(e.activeObj);o=t.extend({},e.cropObj,{},!0);var p={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:p}});var h;(h=p.currObj).objColl=t.extend([],e.objColl,[],!0),h.pointColl=t.extend([],e.pointColl,[],!0),h.afterCropActions=t.extend([],e.afterCropActions,[],!0);a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),h.selPointColl=t.extend([],a.selPointColl,[],!0),e.objColl.pop(),i={action:"delete",previousShapeSettings:this.updatePrevShapeSettings(),currentShapeSettings:null},e.notify("shape",{prop:"setKeyHistory",onPropertyChange:!1,value:{keyHistory:""}}),e.clearSelection(),t.isBlazor()&&e.events&&!0===e.events.shapeChanging.hasDelegate?e.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",i):(e.trigger("shapeChanging",i),t.isBlazor()||e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),t.isNullOrUndefined(h.objColl[h.objColl.length-1].currIndex)||(e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"deleteObj",previousObj:h,previousObjColl:this.tempObjColl,previousPointColl:h.pointColl,previousSelPointColl:h.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),e.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))}e.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}})}document.getElementById(e.element.id+"_quickAccessToolbarArea")&&(document.getElementById(e.element.id+"_quickAccessToolbarArea").style.display="none")},i.prototype.updateFreehandDrawColorChange=function(){var e=this.parent,i={freehandSelectedIndex:null};if(e.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:i}}),!t.isNullOrUndefined(i.freehandSelectedIndex)&&!t.isNullOrUndefined(e.pointColl[i.freehandSelectedIndex])&&"#42a5f5"===e.pointColl[i.freehandSelectedIndex].strokeColor){var o={tempFreeHandDrawEditingStyles:null};e.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:o}}),e.pointColl[i.freehandSelectedIndex].strokeColor=o.tempFreeHandDrawEditingStyles.strokeColor}},i.prototype.updatePrevShapeSettings=function(e){var i=this.parent,o=[];"text"===i.activeObj.shape&&i.activeObj.textSettings&&(i.activeObj.textSettings.bold&&o.push("bold"),i.activeObj.textSettings.italic&&o.push("italic"),i.activeObj.textSettings.underline&&o.push("underline"));var r={id:t.isNullOrUndefined(i.activeObj.currIndex)?null:i.activeObj.currIndex,type:i.toPascalCase(i.activeObj.shape),startX:i.activeObj.activePoint.startX,startY:i.activeObj.activePoint.startY,width:i.activeObj.activePoint.width,height:i.activeObj.activePoint.height,strokeColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,strokeWidth:i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeWidth:null,fillColor:i.activeObj.strokeSettings?i.activeObj.strokeSettings.fillColor:null,radius:"ellipse"===i.activeObj.shape?i.activeObj.activePoint.width/2:null,length:"line"===i.activeObj.shape||"arrow"===i.activeObj.shape?i.activeObj.activePoint.width:null,text:"text"===i.activeObj.shape?i.activeObj.keyHistory?i.activeObj.keyHistory:i.activeObj.textSettings.text?i.activeObj.textSettings.text:null:null,fontSize:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontSize:null,fontFamily:"text"===i.activeObj.shape&&i.activeObj.textSettings?i.activeObj.textSettings.fontFamily:null,fontStyle:"text"===i.activeObj.shape?o:null,color:"text"===i.activeObj.shape&&i.activeObj.strokeSettings?i.activeObj.strokeSettings.strokeColor:null,degree:"ellipse"===i.activeObj.shape||"rectangle"===i.activeObj.shape||"image"===i.activeObj.shape?i.activeObj.rotatedAngle*(180/Math.PI):null,imageData:"image"===i.activeObj.shape?i.activeObj.imageElement.src:null};return e&&(e.shapeSettingsObj=r),r},i.prototype.getRectanglePoints=function(e,t,i,o,r,a,n){var s=e+i/2,l=t+o/2,p=r*(Math.PI/180),h=Math.cos(p),c=Math.sin(p),d=a-s,v=n-l,u=d*h+v*c,g=-d*c+v*h,b=i/2,f=o/2;return u>=-b&&u<=b&&g>=-f&&g<=f},i.prototype.getTransRotationPoint=function(e,t){var i,o,r=!1,a=!1;if((o=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(o=360+o),e.flipObjColl)for(var n=0;n<e.flipObjColl.length;n++)"horizontal"===e.flipObjColl[n].toLowerCase()?r=!0:"vertical"===e.flipObjColl[n].toLowerCase()&&(a=!0);return 0===o||360===o?i=a?{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:90===o||-270===o?i=r?{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:180===o||-180===o?i=a?{x:e.bottomCenterCircle.startX,y:e.bottomCenterCircle.startY+e.rotationCircleLine}:{x:e.topCenterCircle.startX,y:e.topCenterCircle.startY-e.rotationCircleLine}:270!==o&&-90!==o||(i=r?{x:e.centerLeftCircle.startX-e.rotationCircleLine,y:e.centerLeftCircle.startY}:{x:e.centerRightCircle.startX+e.rotationCircleLine,y:e.centerLeftCircle.startY}),t&&(t.rotationCirclePoint=i),i},i.prototype.getNumTextValue=function(e){var i,o,r,a;if(t.isBlazor()?(r=this.parent.element.querySelector(".e-ie-toolbar-e-resize-width-input .e-numerictextbox"),a=this.parent.element.querySelector(".e-ie-toolbar-e-resize-height-input .e-numerictextbox")):(r=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeWidth"),a=this.parent.element.querySelector("#"+this.parent.element.id+"_resizeHeight")),r&&a){var n=a.value.replace(/,/g,""),s=r.value.replace(/,/g,"");i=parseFloat(n),o=parseFloat(s)}return e&&(e.width=o,e.height=i),{x:o,y:i}},i}(),d=function(){function i(e){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null},this.keyHistory="",this.parent=e,this.addEventListener()}return i.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},i.prototype.addEventListener=function(){this.parent.on("shape",this.shape,this),this.parent.on("destroyed",this.destroy,this)},i.prototype.removeEventListener=function(){this.parent.off("shape",this.shape),this.parent.off("destroyed",this.destroy)},i.prototype.shape=function(e){this.initShapePvtProps();var i;switch(e.prop){case"drawEllipse":this.drawEllipse(e.value.x,e.value.y,e.value.radiusX,e.value.radiusY,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree);break;case"drawLine":this.drawLine(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor);break;case"drawArrow":this.drawArrow(e.value.startX,e.value.startY,e.value.endX,e.value.endY,e.value.strokeWidth,e.value.strokeColor,e.value.arrowStart,e.value.arrowEnd);break;case"drawPath":this.drawPath(e.value.pointColl,e.value.strokeWidth,e.value.strokeColor);break;case"drawRectangle":this.drawRectangle(e.value.x,e.value.y,e.value.width,e.value.height,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.degree);break;case"drawText":this.drawText(e.value.x,e.value.y,e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.color);break;case"redrawActObj":this.redrawActObj(e.value.x,e.value.y,e.value.isMouseDown);break;case"apply":this.apply(e.value.shape,e.value.obj,e.value.canvas);break;case"updateShapeChangeEventArgs":this.updateShapeChangeEventArgs(e.value.shapeSettings);break;case"updSelChangeEventArgs":this.updSelChangeEventArgs(e.value.selectionSettings);break;case"iterateObjColl":this.iterateObjColl();break;case"updImgRatioForActObj":this.updImgRatioForActObj();break;case"zoomObjColl":this.zoomObjColl(e.value.isPreventApply);break;case"redrawObj":this.redrawObj(e.value.degree);break;case"rotateObjColl":this.rotateObjColl();break;case"draw-shape-text":this.drawShapeText();break;case"redraw-text":this.redrawText();break;case"draw-shape":this.drawShape(e.value.obj,e.value.strokeWidth,e.value.strokeColor,e.value.fillColor,e.value.start,e.value.width,e.value.height);break;case"renderTextArea":this.renderTextArea(e.value.x,e.value.y,e.value.actObj);break;case"setTextBoxWidth":this.setTextBoxWidth(e.value.e);break;case"findTextTarget":this.findTextTarget(e.value.e);break;case"panObjColl":this.panObjColl(e.value.xDiff,e.value.yDiff,e.value.panRegion);break;case"updateFontStyles":this.updateFontStyles(e.value.isTextBox);break;case"applyFontStyle":this.applyFontStyle(e.value.item);break;case"updateFontRatio":this.updateFontRatio(e.value.obj,e.value.isTextArea);break;case"updateFontSize":this.updateFontSize(e.value.obj);break;case"updateObjColl":this.updateObjColl(e.value.item,e.value.objColl);break;case"pushActItemIntoObj":this.pushActItemIntoObj();break;case"clearActObj":this.clearActObj();break;case"refreshActiveObj":this.refreshActiveObj();break;case"applyActObj":this.applyActObj(e.value.isMouseDown);break;case"wireEvent":t.EventHandler.add(this.parent.upperCanvas,"dblclick",this.findTextTarget,this),t.EventHandler.add(this.parent.textArea,"mousedown",this.findTextTarget,this),(i=document.getElementById(this.parent.element.id+"_fileUpload"))&&t.EventHandler.add(i,"change",this.fileChanged,this);break;case"unWireEvent":t.EventHandler.remove(this.parent.upperCanvas,"dblclick",this.findTextTarget),t.EventHandler.remove(this.parent.textArea,"mousedown",this.findTextTarget),i=document.getElementById(this.parent.element.id+"_fileUpload"),t.EventHandler.remove(i,"change",this.fileChanged);break;case"getShapeSetting":this.getShapeSetting(e.value.id,e.value.obj);break;case"getShapeSettings":this.getShapeSettings(e.value.obj);break;case"isPointsInRange":this.isPointsInRange(e.value.x,e.value.y,e.value.obj);break;case"alignRotateFlipColl":this.alignRotateFlipColl(e.value.collection,e.value.isRotateFlipCollection,e.value.obj);break;case"selectShape":this.selectShape(e.value.id,e.value.obj);break;case"deleteShape":this.deleteShape(e.value.id);break;case"getMaxText":this.getMaxText(e.value.isTextBox,e.value.text,e.value.obj);break;case"setPointCollForLineArrow":e.value.obj.pointColl=this.getLinePoints(e.value.obj.activePoint.startX,e.value.obj.activePoint.startY,e.value.obj.activePoint.endX,e.value.obj.activePoint.endY);break;case"setPointCollForShapeRotation":this.setPointCollForShapeRotation(e.value.obj);break;case"setTextSettings":e.value.textSettings?this.textSettings=e.value.textSettings:e.value.fontFamily?this.textSettings.fontFamily=e.value.fontFamily:e.value.fontSize&&(this.textSettings.fontSize=e.value.fontSize);break;case"setStrokeSettings":e.value.strokeSettings?this.strokeSettings=e.value.strokeSettings:e.value.strokeColor?this.strokeSettings.strokeColor=e.value.strokeColor:e.value.fillColor?this.strokeSettings.fillColor=e.value.fillColor:e.value.strokeWidth&&(this.strokeSettings.strokeWidth=e.value.strokeWidth);break;case"getStrokeSettings":e.value.obj.strokeSettings=this.strokeSettings;break;case"setKeyHistory":this.keyHistory=e.value.keyHistory;break;case"getKeyHistory":e.value.obj.keyHistory=this.keyHistory;break;case"setTextBoxPos":this.setTextBoxPos(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"setTextBoxPoints":this.setTextBoxPoints(e.value.actObj,e.value.degree,e.value.flip,e.value.x,e.value.y);break;case"alignTextAreaIntoCanvas":this.alignTextAreaIntoCanvas();break;case"initializeTextShape":this.initializeTextShape(e.value.text,e.value.fontFamily,e.value.fontSize,e.value.bold,e.value.italic,e.value.strokeColor);break;case"stopPathDrawing":this.stopPathDrawing(e.value.e,e.value.isApply);break;case"updateArrowRatio":this.updateArrowRatio(e.value.obj);break;case"getSquarePointForRotatedShape":this.getSquarePointForRotatedShape(e.value.obj,e.value.object);break;case"drawImage":this.drawImage(e.value.x,e.value.y,e.value.width,e.value.height,e.value.src,e.value.degree,e.value.isAspectRatio);break;case"reset":this.reset();break;case"fileChanged":this.fileChanged(e.value.e);break;case"updateObj":this.updateObj(e.value.dimObj,e.value.x,e.value.y)}},i.prototype.getModuleName=function(){return"shape"},i.prototype.initShapePvtProps=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d")),t.isNullOrUndefined(this.shapeImg)&&(this.shapeImg=this.parent.createElement("img",{id:this.parent.element.id+"_shapeImg",attrs:{name:"Image",crossorigin:"anonymous"}}))},i.prototype.reset=function(){this.textSettings={text:"Enter Text",fontFamily:"Arial",fontSize:null,fontRatio:null,bold:!1,italic:!1,underline:!1},this.strokeSettings={strokeColor:"#fff",fillColor:"",strokeWidth:null}},i.prototype.drawEllipse=function(e,t,i,o,r,a,n,s){this.initializeShape("ellipse");var l=e&&t?{x:e,y:t}:null;this.drawShape("ellipse",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawLine=function(e,t,i,o,r,a){this.initializeShape("line");var n=e&&t?{x:e,y:t}:null,s=i-e,l=o-t;this.drawShape("line",r,a,null,n,s,l)},i.prototype.drawPath=function(e,i,o){if(this.initializeShape("path"),e)this.drawShape("path",i,o,null,null,null,null,e);else{this.drawShape("line",i,o,null,null,null,null);var r=t.extend({},this.parent.objColl[this.parent.objColl.length-1],null,!0);r.shape="path",r.lineDraw=null,r.pointColl=[{x:r.activePoint.startX,y:r.activePoint.startY},{x:r.activePoint.endX,y:r.activePoint.endY}],this.parent.objColl[this.parent.objColl.length-1]=r}},i.prototype.drawArrow=function(e,t,i,o,r,a,n,s){this.initializeShape("arrow");var l=e&&t?{x:e,y:t}:null,p=i-e,h=o-t;this.drawShape("arrow",r,a,null,l,p,h,null,n,s)},i.prototype.drawRectangle=function(e,t,i,o,r,a,n,s){this.initializeShape("rectangle");var l=e&&t?{x:e,y:t}:null;this.drawShape("rectangle",r,a,n,l,i,o,null,null,null,s)},i.prototype.drawText=function(e,t,i,o,r,a,n,s){this.drawShapeText(i,o,r,a,n,s,e,t)},i.prototype.initializeShape=function(e){this.redrawActObj(),this.parent.activeObj.shape=e,"freehanddraw"===this.parent.currObjType.shape&&(this.apply(),this.parent.upperCanvas.style.cursor=this.parent.cursor="default",this.parent.currObjType.shape=""),this.parent.currObjType.isCustomCrop=!1},i.prototype.updateWidthHeight=function(e){return e.activePoint.width=e.activePoint.endX-e.activePoint.startX,e.activePoint.height=e.activePoint.endY-e.activePoint.startY,e},i.prototype.setDimension=function(e,t){e&&t&&(this.parent.activeObj.activePoint.width=e,this.parent.activeObj.activePoint.height=t,"ellipse"===this.parent.currObjType.shape.toLowerCase()&&(this.parent.activeObj.activePoint.width=2*e,this.parent.activeObj.activePoint.height=2*t))},i.prototype.getArrowType=function(e){var t=e;if(e){t={None:"none",Arrow:"arrow",SolidArrow:"arrowSolid",Circle:"circle",SolidCircle:"circleSolid",Square:"square",SolidSquare:"squareSolid",Bar:"bar"}[""+e]}return t},i.prototype.drawShape=function(e,i,o,r,a,n,s,l,p,h,c){var d=this,v=this.parent;if(!v.disabled&&v.isImageLoaded){v.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.redrawActObj();var u=t.extend([],v.objColl,[],!0);if(v.togglePen=!1,this.keyHistory="",this.parent.upperCanvas.style.display="block",this.refreshActiveObj(),v.currObjType.shape=e,"path"===v.currObjType.shape.toLowerCase()&&t.isNullOrUndefined(l))v.activeObj.shape=v.currObjType.shape.toLowerCase(),v.activeObj.pointColl=[],v.upperCanvas.style.cursor=this.parent.cursor="crosshair",v.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:"path"}}),t.isBlazor()||(v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}));else if("freehanddraw"!==v.currObjType.shape.toLowerCase()&&""!==v.currObjType.shape.toLowerCase()){v.activeObj.shape=v.currObjType.shape.toLowerCase(),this.upperContext.clearRect(0,0,v.upperCanvas.width,v.upperCanvas.height),t.isNullOrUndefined(v.activeObj.strokeSettings)&&(v.activeObj.strokeSettings=this.strokeSettings),"path"===v.currObjType.shape.toLowerCase()&&l&&(v.activeObj.pointColl=l),v.activeObj.strokeSettings.strokeWidth=i||v.activeObj.strokeSettings.strokeWidth,v.activeObj.strokeSettings.strokeColor=o||v.activeObj.strokeSettings.strokeColor,v.activeObj.strokeSettings.fillColor=r||v.activeObj.strokeSettings.fillColor;var g=v.img.destWidth>100?100:v.img.destWidth/2,b=v.img.destHeight>100?100:v.img.destHeight/2;v.activeObj.activePoint.width=g,v.activeObj.activePoint.height=b,"line"===v.currObjType.shape.toLowerCase()||"arrow"===v.currObjType.shape.toLowerCase()?(v.activeObj.lineDraw="horizontal",v.activeObj.activePoint.height=0,"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=50,v.activeObj.start=this.getArrowType(p),v.activeObj.end=this.getArrowType(h))):"rectangle"===v.currObjType.shape.toLowerCase()&&(v.activeObj.activePoint.width+=v.activeObj.activePoint.width/2),this.setDimension(n,s),a?(v.activeObj.activePoint.startX=a.x,v.activeObj.activePoint.startY=a.y,v.activeObj.activePoint.endX=v.activeObj.activePoint.startX+v.activeObj.activePoint.width,v.activeObj.activePoint.endY=v.activeObj.activePoint.startY+v.activeObj.activePoint.height):this.setCenterPoints(),this.setPointCollForLineAndArrow(),"arrow"===v.currObjType.shape.toLowerCase()&&(v.activeObj.triangleDirection="right"),v.currObjType.isDragging=v.currObjType.isCustomCrop=!1,this.initShapeProps();var f={shapeSettingsObj:{}};v.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:f}});var m=f.shapeSettingsObj,C={action:"insert",previousShapeSettings:m,currentShapeSettings:m};t.isBlazor()&&v.events&&!0===v.events.shapeChanging.hasDelegate?this.parent.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",C).then(function(e){d.updateShapeChangeEventArgs(e.currentShapeSettings),d.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),v.updateToolbar(v.element,"quickAccessToolbar","shape"),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1}):(v.trigger("shapeChanging",C),this.updateShapeChangeEventArgs(C.currentShapeSettings),this.setDimension(n,s),v.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),c&&(v.activeObj.rotatedAngle=c*(Math.PI/180),v.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:v.activeObj}})),t.isBlazor()?v.updateToolbar(v.element,"quickAccessToolbar","shape"):v.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),v.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),v.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:u}}),v.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),v.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),v.isPublicMethod&&v.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),v.isPublicMethod=!1)}}},i.prototype.initShapeProps=function(){var e=this.parent;e.activeObj.shapeDegree=e.transform.degree,e.activeObj.shapeFlip=e.transform.currFlipState,e.activeObj.textFlip=e.transform.currFlipState,e.activeObj.flipObjColl=[]},i.prototype.setPointCollForLineAndArrow=function(){var e=this.parent;if(("line"===e.activeObj.shape||"arrow"===e.activeObj.shape)&&(e.activeObj.pointColl=this.getLinePoints(e.activeObj.activePoint.startX,e.activeObj.activePoint.startY,e.activeObj.activePoint.endX,e.activeObj.activePoint.endY),e.activeObj.pointColl))for(var t=0,i=e.activeObj.pointColl.length;t<i;t++)e.activeObj.pointColl[t].ratioX=(e.activeObj.pointColl[t].x-e.img.destLeft)/e.img.destWidth,e.activeObj.pointColl[t].ratioY=(e.activeObj.pointColl[t].y-e.img.destTop)/e.img.destHeight},i.prototype.prevObjColl=function(){var e=this.parent,i={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),this.prevObj=i.currObj,this.prevObj.objColl=t.extend([],e.objColl,[],!0),this.prevObj.pointColl=t.extend([],e.pointColl,[],!0),this.prevObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),this.prevObj.selPointColl=t.extend([],o.selPointColl,[],!0)},i.prototype.drawShapeText=function(e,i,o,r,a,n,s,l){var p=this,h=this.parent;if(!h.disabled&&h.isImageLoaded){"freehanddraw"===h.currObjType.shape&&(this.apply(),h.upperCanvas.style.cursor=h.cursor="default",h.currObjType.shape=""),h.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),h.togglePen=!1,this.redrawActObj(),this.prevObjColl(),this.refreshActiveObj(),h.activeObj.shape=h.currObjType.shape="text",h.currObjType.isCustomCrop=!1,this.initializeTextShape(e,i,o,r,a,n),h.currObjType.isText=h.currObjType.isInitialText=!0,t.isNullOrUndefined(h.activeObj.textSettings.fontSize)&&(h.getFontSizes(),h.activeObj.textSettings.fontSize=parseInt(h.fontSizeColl[parseInt("3",10)-1].text,10)),h.img.destWidth<100?h.activeObj.textSettings.fontSize=Math.floor(h.img.destWidth/20):h.img.destHeight<100&&(h.activeObj.textSettings.fontSize=Math.floor(h.img.destHeight/20)),h.activeObj.shapeDegree=h.transform.degree,h.activeObj.shapeFlip=h.transform.currFlipState,h.activeObj.flipObjColl=[],this.updateFontStyles();var c=this.upperContext.measureText(h.activeObj.textSettings.text).width+.5*h.activeObj.textSettings.fontSize,d=h.activeObj.textSettings.fontSize+.25*h.activeObj.textSettings.fontSize;t.isNullOrUndefined(s)||t.isNullOrUndefined(l)?this.setCenterPoints(!0,c,d):(h.activeObj.activePoint.startX=s,h.activeObj.activePoint.startY=l,h.activeObj.activePoint.endX=h.activeObj.activePoint.startX+c,h.activeObj.activePoint.endY=h.activeObj.activePoint.startY+d);var v={shapeSettingsObj:{}};h.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:v}});var u=v.shapeSettingsObj,g={action:"insert",previousShapeSettings:u,currentShapeSettings:u};t.isBlazor()&&h.events&&!0===h.events.shapeChanging.hasDelegate?h.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",g).then(function(e){p.drawShapeTextEvent(e),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1}):(h.trigger("shapeChanging",g),this.drawShapeTextEvent(g),h.isPublicMethod&&h.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),h.isPublicMethod=!1)}},i.prototype.drawShapeImageEvent=function(e,i){var o=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),o.objColl.push(o.activeObj);var r=t.extend({},o.cropObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.objColl[o.objColl.length-1]}}),i?t.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):(o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})):o.okBtn(),o.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}})},i.prototype.drawShapeTextEvent=function(e){var i=this.parent;this.updateShapeChangeEventArgs(e.currentShapeSettings),this.addLetter(i.activeObj.textSettings.text),i.activeObj.textFlip=i.transform.currFlipState,this.updateFontRatio(i.activeObj),i.objColl.push(i.activeObj);var o=t.extend({},i.cropObj,{},!0);i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:this.prevObj,previousObjColl:this.prevObj.objColl,previousPointColl:this.prevObj.pointColl,previousSelPointColl:this.prevObj.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}}),t.isBlazor()?i.updateToolbar(i.element,"quickAccessToolbar","text"):i.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}),i.notify("selection",{prop:"isShapeInserted",onPropertyChange:!1,value:{bool:!0}}),t.isBlazor()?i.updateToolbar(i.element,"text"):(i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))},i.prototype.initializeTextShape=function(e,i,o,r,a,n){var s=this.parent;this.keyHistory="",s.upperCanvas.style.display="block",t.isNullOrUndefined(s.activeObj.textSettings)&&(s.activeObj.textSettings=this.textSettings),t.isNullOrUndefined(s.activeObj.strokeSettings)&&(s.activeObj.strokeSettings=this.strokeSettings),s.activeObj.strokeSettings.strokeColor=n||s.activeObj.strokeSettings.strokeColor,s.activeObj.textSettings.text=e||s.activeObj.textSettings.text,s.activeObj.textSettings.fontFamily=i||s.activeObj.textSettings.fontFamily,s.activeObj.textSettings.fontSize=o||s.activeObj.textSettings.fontSize,s.activeObj.textSettings.bold=r||s.activeObj.textSettings.bold,s.activeObj.textSettings.italic=a||s.activeObj.textSettings.italic},i.prototype.drawImage=function(e,t,i,o,r,a,n){this.initializeShape("image"),this.onLoadImgShape(e,t,i,o,r,null,a,n)},i.prototype.redrawActObj=function(e,t,i){var o,r=this.parent;r.activeObj.shape&&(o=r.activeObj.shape.split("-")),r.activeObj.horTopLine&&r.activeObj.shape&&"crop"!==o[0]&&("block"===r.textArea.style.display?(r.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.updateFontRatio(r.activeObj,!0),e&&t?e!==r.activeObj.activePoint.startX&&t!==r.activeObj.activePoint.startY&&this.updateTextFromTextArea():(this.updateTextFromTextArea(),r.textArea.style.transform="",r.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})),this.refreshActiveObj()):this.applyActObj(i))},i.prototype.apply=function(e,i,o){var r=this.parent;if(!r.disabled)if(r.togglePen&&!r.currObjType.isCustomCrop){var a=r.img.destLeft,n=r.img.destTop,s=r.img.destWidth,l=r.img.destHeight;r.notify("draw",{prop:"callUpdateCurrTransState",onPropertyChange:!1});var p=this.lowerContext.filter;this.lowerContext.filter="none",r.togglePen=!1,this.iterateObjColl(),r.notify("freehandDraw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),r.togglePen=!1,(r.isCircleCrop||r.currSelectionPoint&&"crop-circle"===r.currSelectionPoint.shape)&&r.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),r.img.destLeft=a,r.img.destTop=n,r.img.destWidth=s,r.img.destHeight=l,this.lowerContext.filter=p}else o=o||"original",t.isNullOrUndefined(r.activeObj.shape)&&t.isNullOrUndefined(e)?r.currObjType.shape="":r.currObjType.shape=e||r.currObjType.shape,""!==r.currObjType.shape&&(this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),"text"===r.activeObj.shape?(r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),r.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}})):r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:o,obj:i}}),r.activeObj.shape=r.currObjType.shape.toLowerCase(),e||""===r.currObjType.shape||r.currObjType.isCustomCrop||r.objColl.push(t.extend({},r.activeObj,{},!0)),this.keyHistory="")},i.prototype.setCenterPoints=function(e,t,i){var o,r,a=this.parent;e&&t&&i?(o=t,r=i):(o=a.activeObj.activePoint.width,r=a.activeObj.activePoint.height),a.activeObj.activePoint.startX=a.lowerCanvas.width/2-o/2,a.activeObj.activePoint.startY=a.lowerCanvas.height/2-r/2,a.activeObj.activePoint.endX=a.lowerCanvas.width/2+o/2,a.activeObj.activePoint.endY=a.lowerCanvas.height/2+r/2},i.prototype.updSelChangeEventArgs=function(e){var t=this.parent;t.activeObj.activePoint.startX=e.startX,t.activeObj.activePoint.startY=e.startY,t.activeObj.activePoint.width=e.width,t.activeObj.activePoint.height=e.height,t.activeObj.activePoint.endX=t.activeObj.activePoint.startX+t.activeObj.activePoint.width,t.activeObj.activePoint.endY=t.activeObj.activePoint.startY+t.activeObj.activePoint.height},i.prototype.updateShapeChangeEventArgs=function(e){var i=this.parent;switch(i.activeObj.currIndex=e.id,i.activeObj.activePoint.startX=e.startX,i.activeObj.activePoint.startY=e.startY,i.activeObj.activePoint.width=e.width,i.activeObj.activePoint.height=e.height,i.activeObj.activePoint.endX=i.activeObj.activePoint.startX+i.activeObj.activePoint.width,i.activeObj.activePoint.endY=i.activeObj.activePoint.startY+i.activeObj.activePoint.height,i.activeObj.strokeSettings.strokeColor=e.strokeColor,i.activeObj.strokeSettings.fillColor=e.fillColor,t.isNullOrUndefined(e.degree)&&(e.degree=0),i.activeObj.shape){case"ellipse":i.activeObj.activePoint.width=2*e.radius,i.activeObj.rotatedAngle=e.degree*(Math.PI/180);break;case"line":case"arrow":i.activeObj.activePoint.width=e.length;break;case"text":i.activeObj.keyHistory=i.activeObj.textSettings.text=e.text,i.activeObj.textSettings.fontSize=e.fontSize,i.activeObj.strokeSettings.strokeColor=e.color,i.activeObj.textSettings.fontFamily=e.fontFamily;break;case"rectangle":case"image":e.degree&&(i.activeObj.rotatedAngle=e.degree*(Math.PI/180))}if("text"===i.activeObj.shape&&i.activeObj.textSettings)for(var o=0;o<e.fontStyle.length;o++)switch(e.fontStyle[o]){case"bold":i.activeObj.textSettings.bold=!0;break;case"italic":i.activeObj.textSettings.italic=!0;break;case"underline":i.activeObj.textSettings.underline=!0}},i.prototype.addLetter=function(e){var t=this.parent;if("none"===t.textArea.style.display&&(t.currObjType.isText||"text"===t.activeObj.shape)){"Backspace"===e?this.keyHistory=this.keyHistory.slice(0,-1):this.keyHistory+=e,this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),this.updateFontStyles();var i=this.upperContext.measureText(this.keyHistory).width+.5*t.activeObj.textSettings.fontSize,o=t.activeObj.textSettings.fontSize+.25*t.activeObj.textSettings.fontSize;this.upperContext.fillText(this.keyHistory,t.activeObj.activePoint.startX,t.activeObj.activePoint.startY+t.activeObj.textSettings.fontSize),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.currObjType.isText=!0,t.notify("selection",{prop:"setActivePoint",onPropertyChange:!1,value:{startX:i,startY:o}})}},i.prototype.redrawText=function(){var e=this.parent,t="";e.activeObj.textSettings.bold&&(t+="bold "),e.activeObj.textSettings.italic&&(t+="italic "),this.upperContext.font=t+e.activeObj.textSettings.fontSize+"px "+e.activeObj.textSettings.fontFamily;var i=e.activeObj.keyHistory.split("\n"),o="block"===e.textArea.style.display?this.getMaxText(!0):this.getMaxText(),r=this.upperContext.measureText(o).width+.5*e.activeObj.textSettings.fontSize,a=i.length*(e.activeObj.textSettings.fontSize+.25*e.activeObj.textSettings.fontSize);e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:r,height:a}}),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),e.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:e.activeObj}})},i.prototype.updateTextFromTextArea=function(){var e=this.parent,i=!1,o=t.extend({},e.cropObj,{},!0),r={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],e.objColl,[],!0),a.pointColl=t.extend([],e.pointColl,[],!0),a.afterCropActions=t.extend([],this.parent.afterCropActions,[],!0);var n={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),e.activeObj.keyHistory!==e.textArea.value&&(i=!0),e.activeObj.keyHistory=e.textArea.value,e.textArea.style.display="none",e.textArea.value="",this.updateFontStyles();var s=this.upperContext.measureText(e.activeObj.keyHistory).width+.5*e.activeObj.textSettings.fontSize,l=e.activeObj.textSettings.fontSize+.25*this.parent.activeObj.textSettings.fontSize,p=e.activeObj.keyHistory.split("\n");if(p.length>1){l*=p.length;for(var h=[],c=0,d=p.length;c<d;c++)h.push(this.upperContext.measureText(p[c]).width+.5*e.activeObj.textSettings.fontSize);s=Math.max.apply(Math,h)}e.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:s,height:l}}),e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.activeObj.activePoint,obj:e.activeObj,isMouseMove:null,x:null,y:null}}),this.updImgRatioForActObj(),i?(this.apply(e.activeObj.shape,e.activeObj),e.objColl.push(t.extend({},e.activeObj,{},!0)),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"text",previousObj:a,previousObjColl:a.objColl,previousPointColl:a.pointColl,previousSelPointColl:a.selPointColl,previousCropObj:o,previousText:e.activeObj.keyHistory,currentText:e.textArea.value,previousFilter:null,isCircleCrop:null}})):(this.apply(e.activeObj.shape,e.activeObj),e.objColl.push(t.extend({},e.activeObj,{},!0)))},i.prototype.iterateObjColl=function(){var e=this.parent;if(e.objColl.length>0){for(var t=0,i=e.objColl.length;t<i;t++)this.apply(e.objColl[t].shape,e.objColl[t]),this.refreshActiveObj();e.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:e.frameObj.type,preventImg:!0}})}},i.prototype.updImgRatioForActObj=function(){var e=this.parent;e.activeObj.imageRatio={startX:(e.activeObj.activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(e.activeObj.activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(e.activeObj.activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(e.activeObj.activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/e.activeObj.activePoint.width,height:e.img.destHeight/e.activeObj.activePoint.height},e.activeObj.rotationCirclePointColl&&(e.activeObj.rotationCirclePointColl.ratioX=(e.activeObj.rotationCirclePointColl.x-e.img.destLeft)/e.img.destWidth,e.activeObj.rotationCirclePointColl.ratioY=(e.activeObj.rotationCirclePointColl.y-e.img.destTop)/e.img.destHeight),"path"===e.activeObj.shape?this.updatePathRatio(e.activeObj):"arrow"===e.activeObj.shape&&this.updateArrowRatio(e.activeObj)},i.prototype.zoomObjColl=function(e){for(var i=this.parent,o=0,r=i.objColl.length;o<r;o++){var a=i.objColl[o];if(a.activePoint.startX=a.imageRatio.startX*i.img.destWidth+i.img.destLeft,a.activePoint.startY=a.imageRatio.startY*i.img.destHeight+i.img.destTop,a.activePoint.endX=a.imageRatio.endX*i.img.destWidth+i.img.destLeft,a.activePoint.endY=a.imageRatio.endY*i.img.destHeight+i.img.destTop,"text"===(a=this.updateWidthHeight(a)).shape)this.updateFontSize(a);else if("line"===a.shape||"arrow"===a.shape){a.pointColl=this.getLinePoints(a.activePoint.startX,a.activePoint.startY,a.activePoint.endX,a.activePoint.endY);for(var n=0,s=a.pointColl.length;n<s;n++)a.pointColl[n].ratioX=(a.pointColl[n].x-i.img.destLeft)/i.img.destWidth,a.pointColl[n].ratioY=(a.pointColl[n].y-i.img.destTop)/i.img.destHeight;"arrow"===a.shape&&this.updateArrowSize(a)}else if("path"===a.shape){for(var l=0,p=a.pointColl.length;l<p;l++)a.pointColl[l].x=a.pointColl[l].ratioX*i.img.destWidth+i.img.destLeft,a.pointColl[l].y=a.pointColl[l].ratioY*i.img.destHeight+i.img.destTop;this.updatePathRatio(a)}if(i.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:a.activePoint,obj:a}}),t.isNullOrUndefined(e)){var h=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(a.shape,a),this.refreshActiveObj(),this.lowerContext.filter=h,i.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:i.frameObj.type,preventImg:!0}})}"line"!==a.shape&&"arrow"!==a.shape&&"path"!==a.shape&&0!==a.rotatedAngle&&(this.setPointCollForShapeRotation(a),a.rotationCirclePoint.x=a.rotationCirclePoint.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePoint.y=a.rotationCirclePoint.ratioY*i.img.destHeight+i.img.destTop,a.rotationCirclePointColl.x=a.rotationCirclePointColl.ratioX*i.img.destWidth+i.img.destLeft,a.rotationCirclePointColl.y=a.rotationCirclePointColl.ratioY*i.img.destHeight+i.img.destTop)}},i.prototype.redrawObj=function(e){var t=this.parent,i=!1;if(this.parent.objColl.length>0)if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalVertical"===e||"verticalHorizontal"===e)this.updateCurrentActiveObjPoint(e.toLowerCase());else if("number"==typeof e){this.updateCurrentActiveObjPoint(e);var o=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)";for(var r=0,a=t.objColl.length;r<a;r++){"crop"!==t.objColl[r].shape.split("-")[0]&&(this.apply(t.objColl[r].shape,t.objColl[r]),i=!0)}i&&t.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:t.frameObj.type,preventImg:!0}}),this.lowerContext.filter=o}},i.prototype.updateCurrentActiveObjPoint=function(e){for(var i,o=this.parent,r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(o.activeObj.shape===n.shape&&o.activeObj.activePoint.startX===n.activePoint.startX&&o.activeObj.activePoint.startY===n.activePoint.startY&&o.activeObj.activePoint.endX===n.activePoint.endX&&o.activeObj.activePoint.endY===n.activePoint.endY&&o.activeObj.currIndex===n.currIndex){i=r;break}}if("horizontal"===e||"vertical"===e||"Horizontal"===e||"Vertical"===e||"horizontalvertical"===e||"verticalhorizontal"===e){if("horizontal"===e||"Horizontal"===e){var s=0;for(a=o.objColl.length;s<a;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"horizontal"):0!==n.rotatedAngle&&(n.rotatedAngle=n.rotatedAngle+2*(Math.PI-n.rotatedAngle),n.rotationCirclePointColl.x<=o.img.destLeft+o.img.destWidth/2?n.rotationCirclePointColl.x=o.img.destLeft+o.img.destWidth-(n.rotationCirclePointColl.x-o.img.destLeft):n.rotationCirclePointColl.x>=o.img.destLeft+o.img.destWidth/2&&(n.rotationCirclePointColl.x=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.rotationCirclePointColl.x)),n.rotationCirclePointColl.ratioX=(n.rotationCirclePointColl.x-o.img.destLeft)/o.img.destWidth),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}}else if("vertical"===e||"Vertical"===e)for(s=0;s<o.objColl.length;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"===n.shape||"arrow"===n.shape||"path"===n.shape?this.flipLineArrowObj(n,"vertical"):0!==n.rotatedAngle&&(n.rotatedAngle=-n.rotatedAngle,n.rotationCirclePointColl.y<=o.img.destTop+o.img.destHeight/2?n.rotationCirclePointColl.y=o.img.destTop+o.img.destHeight-(n.rotationCirclePointColl.y-o.img.destTop):n.rotationCirclePointColl.y>=o.img.destTop+o.img.destHeight/2&&(n.rotationCirclePointColl.y=o.img.destTop+(o.img.destTop+o.img.destHeight-n.rotationCirclePointColl.y)),n.rotationCirclePointColl.ratioY=(n.rotationCirclePointColl.y-o.img.destTop)/o.img.destHeight),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}else if("verticalhorizontal"===e||"horizontalvertical"===e)for(s=0,a=o.objColl.length;s<a;s++){(n=o.objColl[s]).shapeFlip!==o.transform.currFlipState&&(n.activePoint.startX<=o.img.destLeft+o.img.destWidth/2?(n.activePoint.endX=o.img.destLeft+o.img.destWidth-(n.activePoint.startX-o.img.destLeft),n.activePoint.startX=n.activePoint.endX-n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startX>=o.img.destLeft+o.img.destWidth/2&&(n.activePoint.startX=o.img.destLeft+(o.img.destLeft+o.img.destWidth-n.activePoint.endX),n.activePoint.endX=n.activePoint.startX+n.activePoint.width,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),n.activePoint.startY<=o.img.destTop+o.img.destHeight/2?(n.activePoint.endY=o.img.destTop+o.img.destHeight-(n.activePoint.startY-o.img.destTop),n.activePoint.startY=n.activePoint.endY-n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})):n.activePoint.startY>=this.parent.lowerCanvas.height/2&&(n.activePoint.startY=o.img.destTop+(o.img.destTop+o.img.destHeight-n.activePoint.endY),n.activePoint.endY=n.activePoint.startY+n.activePoint.height,o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}})),"line"!==n.shape&&"arrow"!==n.shape&&"path"!==n.shape||this.flipLineArrowObj(n,e),n.shapeFlip=o.transform.currFlipState,n.imageRatio={startX:(n.activePoint.startX-o.img.destLeft)/o.img.destWidth,startY:(n.activePoint.startY-o.img.destTop)/o.img.destHeight,endX:(n.activePoint.endX-o.img.destLeft)/o.img.destWidth,endY:(n.activePoint.endY-o.img.destTop)/o.img.destHeight,width:o.img.destWidth/n.activePoint.width,height:o.img.destHeight/n.activePoint.height})}void 0!==i&&(o.activeObj=t.extend({},o.objColl[i],{},!0))}else if(90===e)this.rotateObjColl();else if(-90===e)for(s=0;s<3;s++)this.rotateObjColl();else if("number"==typeof e)if(e>0)this.rotateObjColl();else for(s=0;s<3;s++)this.rotateObjColl()},i.prototype.rotateObjColl=function(){for(var e=this.parent,t=0,i=e.objColl.length;t<i;t++){(o=e.objColl[t]).activePoint.startY=e.img.destTop+e.img.destHeight*o.imageRatio.startX,o.activePoint.endY=e.img.destTop+e.img.destHeight*o.imageRatio.endX,o.activePoint.startX=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.imageRatio.endY,o.activePoint.endX=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.imageRatio.startY,o=this.updateWidthHeight(e.objColl[t]),this.updateFontSize(o),"line"===o.shape||"arrow"===o.shape||"path"===o.shape?(this.rotateLineArrowObj(o),"arrow"===o.shape&&this.updateArrowSize(o)):0!==o.rotatedAngle&&(o.rotationCirclePointColl.y=e.img.destTop+e.img.destHeight*o.rotationCirclePointColl.ratioX,o.rotationCirclePointColl.x=e.img.destLeft+e.img.destWidth-e.img.destWidth*o.rotationCirclePointColl.ratioY,o.rotationCirclePointColl.ratioX=(o.rotationCirclePointColl.x-e.img.destLeft)/e.img.destWidth,o.rotationCirclePointColl.ratioY=(o.rotationCirclePointColl.y-e.img.destTop)/e.img.destHeight)}for(t=0,i=e.objColl.length;t<i;t++)e.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:e.objColl[t].activePoint,obj:e.objColl[t]}});for(t=0,i=e.objColl.length;t<i;t++){var o;(o=e.objColl[t]).imageRatio={startX:(o.activePoint.startX-e.img.destLeft)/e.img.destWidth,startY:(o.activePoint.startY-e.img.destTop)/e.img.destHeight,endX:(o.activePoint.endX-e.img.destLeft)/e.img.destWidth,endY:(o.activePoint.endY-e.img.destTop)/e.img.destHeight,width:e.img.destWidth/o.activePoint.width,height:e.img.destHeight/o.activePoint.height}}},i.prototype.rotateLineArrowObj=function(e){if(!t.isNullOrUndefined(e.pointColl)){var i=this.parent;if(e.pointColl.length>0){for(var o=0;o<e.pointColl.length;o++)e.pointColl[o].y=i.img.destTop+i.img.destHeight*e.pointColl[o].ratioX,e.pointColl[o].x=i.img.destLeft+i.img.destWidth-i.img.destWidth*e.pointColl[o].ratioY;for(o=0;o<e.pointColl.length;o++)e.pointColl[o].ratioX=(e.pointColl[o].x-i.img.destLeft)/i.img.destWidth,e.pointColl[o].ratioY=(e.pointColl[o].y-i.img.destTop)/i.img.destHeight;var r=void 0;r=t.isNullOrUndefined(e.pointColl[e.pointColl.length-2])?{x:0,y:0}:{x:e.pointColl[e.pointColl.length-2].x,y:e.pointColl[e.pointColl.length-2].y};var a=e.pointColl[e.pointColl.length-1].x-r.x,n=e.pointColl[e.pointColl.length-1].y-r.y;e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x+a/2,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y+n/2,e=this.updateWidthHeight(e)}}},i.prototype.flipLineArrowObj=function(e,i){if(!t.isNullOrUndefined(e.pointColl)&&("horizontal"===i.toLowerCase()?this.lineArrowHorizontalFlip(e):"vertical"===i.toLowerCase()?this.lineArrowVerticalFlip(e):(this.lineArrowHorizontalFlip(e),e.shapeFlip="",this.lineArrowVerticalFlip(e)),e.activePoint.startX=e.pointColl[0].x,e.activePoint.startY=e.pointColl[0].y,e.activePoint.endX=e.pointColl[e.pointColl.length-1].x,e.activePoint.endY=e.pointColl[e.pointColl.length-1].y,e.activePoint.startX>e.activePoint.endX)){var o=e.activePoint.startX;e.activePoint.startX=e.activePoint.endX,e.activePoint.endX=o,o=e.activePoint.startY,e.activePoint.startY=e.activePoint.endY,e.activePoint.endY=o}},i.prototype.lineArrowHorizontalFlip=function(e){var t=this.parent;if(e.shapeFlip!==t.transform.currFlipState){for(var i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.x<=t.img.destLeft+t.img.destWidth/2?r.x=t.img.destLeft+t.img.destWidth-(r.x-t.img.destLeft):r.x>=t.img.destLeft+t.img.destWidth/2&&(r.x=t.img.destLeft+(t.img.destLeft+t.img.destWidth-r.x)),r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}if("arrow"===e.shape){var a=e.start;e.start=e.end,e.end=a}e.shapeFlip=t.transform.currFlipState}},i.prototype.lineArrowVerticalFlip=function(e){var t=this.parent;if(e.shapeFlip!==t.transform.currFlipState){for(var i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.y<=t.img.destTop+t.img.destHeight/2?r.y=t.img.destTop+t.img.destHeight-(r.y-t.img.destTop):r.y>=t.img.destTop+t.img.destHeight/2&&(r.y=t.img.destTop+(t.img.destTop+t.img.destHeight-r.y)),r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}e.shapeFlip=t.transform.currFlipState}},i.prototype.getRotDegOfShape=function(e){var t;return(t=0===e.shapeDegree?this.parent.transform.degree:this.parent.transform.degree-e.shapeDegree)<0&&(t=360+t),t},i.prototype.renderTextArea=function(e,i,o){var r=this.parent,a=this.getRotDegOfShape(r.activeObj);this.transformTextArea(),t.isBlazor()?r.updateToolbar(r.element,"destroyQuickAccessToolbar"):r.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),r.element.querySelector("#"+r.element.id+"_duplicate")&&r.element.querySelector("#"+r.element.id+"_duplicate").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_remove")&&r.element.querySelector("#"+r.element.id+"_remove").classList.add("e-disabled"),r.element.querySelector("#"+r.element.id+"_editText")&&r.element.querySelector("#"+r.element.id+"_editText").classList.add("e-disabled"),r.textArea.style.display="block",r.textArea.style.left=e+"px",r.textArea.style.top=i+"px",r.textArea.style.fontFamily=o.textSettings.fontFamily,r.textArea.style.fontSize=o.textSettings.fontSize+"px",r.textArea.style.color=o.strokeSettings.strokeColor,r.textArea.style.fontWeight=o.textSettings.bold?"bold":"normal",r.textArea.style.fontStyle=o.textSettings.italic?"italic":"normal",r.textArea.style.border="2px solid "+r.themeColl[r.theme].primaryColor,r.textArea.value=o.keyHistory,r.textArea.style.overflow="hidden",r.textArea.style.width="auto",r.textArea.style.height="auto",r.textArea.focus();r.transform.zoomFactor;var n=o.activePoint,s=n.width,l=n.height;a%90==0&&a%180!=0&&0!==a?(r.textArea.style.width=l+"px",r.textArea.style.height=s+"px"):(r.textArea.style.width=s+"px",r.textArea.style.height=l+"px"),this.setTextBoxWidth();var p={flipColl:null};r.notify("transform",{prop:"getFlipColl",onPropertyChange:!1,value:{obj:p}}),p.flipColl.length<=1&&this.setTextBoxHeight(),a%90==0&&a%180!=0?parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destTop+r.img.destHeight&&this.alignTextAreaIntoCanvas():parseFloat(r.textArea.style.left)+parseFloat(r.textArea.style.width)>r.img.destLeft+r.img.destWidth&&this.alignTextAreaIntoCanvas(),r.notify("selection",{prop:"clearUpperCanvas",onPropertyChange:!1})},i.prototype.setTextBoxWidth=function(e){var i=this.parent,o=this.getMaxText(!0);"block"===i.textArea.style.display?this.updateFontStyles(!0):this.updateFontStyles();var r=this.upperContext.measureText(o).width+parseFloat(i.textArea.style.fontSize)/2,a=e?this.upperContext.measureText(String.fromCharCode(e.which)).width:0,n=t.extend({},i.activeObj,{},!0),s="",l=this.getRotDegOfShape(n);if(s=n.shapeFlip!==i.transform.currFlipState?"":i.transform.currFlipState,e&&parseFloat(i.textArea.style.width)<r+a||t.isNullOrUndefined(e))if(0===l)"horizontal"===s.toLowerCase()?parseFloat(i.textArea.style.left)-i.img.destLeft-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)>r+a&&(i.textArea.style.width=r+a+"px");else if(90===l)"vertical"===s.toLowerCase()?parseFloat(i.textArea.style.top)-i.img.destTop-r-a>0&&(i.textArea.style.width=r+a+"px"):i.img.destHeight-(parseFloat(i.textArea.style.top)-i.img.destTop)>r+a&&(i.textArea.style.width=r+a+"px");else if(180===l){var p=parseFloat(i.textArea.style.left),h=i.img.destLeft;if("horizontal"===s.toLowerCase()){i.img.destWidth-(p-h)>r+a&&(i.textArea.style.width=r+a+"px")}else{p-h-r-a>0&&(i.textArea.style.width=r+a+"px")}}else if(270===l){var c=parseFloat(i.textArea.style.top),d=i.img.destTop;if("vertical"===s.toLowerCase()){i.img.destHeight-(c-d)>r+a&&(i.textArea.style.width=r+a+"px")}else{c-d-r-a>0&&(i.textArea.style.width=r+a+"px")}}},i.prototype.setTextBoxHeight=function(){var e,i=this.parent,o=t.extend({},i.activeObj,{},!0),r="",a=this.getRotDegOfShape(o);switch(r=o.textFlip===i.transform.currFlipState?"":""===o.textFlip?i.transform.currFlipState:o.textFlip,a){case 0:"vertical"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destHeight-(i.img.destHeight-parseFloat(i.textArea.style.top))+"px":(e=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-e+"px");break;case 90:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px":i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px";break;case 180:"vertical"===r.toLowerCase()?(e=parseFloat(i.textArea.style.top)-i.img.destTop,i.textArea.style.maxHeight=i.img.destHeight-e+"px"):i.textArea.style.maxHeight=parseFloat(i.textArea.style.top)-i.img.destTop+"px";break;case 270:"horizontal"===r.toLowerCase()?i.textArea.style.maxHeight=parseFloat(i.textArea.style.left)-i.img.destLeft+"px":i.textArea.style.maxHeight=i.img.destWidth-(parseFloat(i.textArea.style.left)-i.img.destLeft)+"px"}},i.prototype.updatePathRatio=function(e){for(var t=this.parent,i=0,o=e.pointColl.length;i<o;i++){var r=e.pointColl[i];r.ratioX=(r.x-t.img.destLeft)/t.img.destWidth,r.ratioY=(r.y-t.img.destTop)/t.img.destHeight}},i.prototype.stopPathDrawing=function(e,i){var o=this.parent;if("path"===o.activeObj.shape){var r={shape:null};if(o.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:r}}),"path"===r.shape){var a=t.extend({},this.parent.cropObj,{},!0),n={currObj:{}};this.parent.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.parent.objColl,[],!0),s.pointColl=t.extend([],this.parent.pointColl,[],!0),s.afterCropActions=t.extend([],this.parent.afterCropActions,[],!0);var l={selPointColl:null};this.parent.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),o.notify("selection",{prop:"setCurrentDrawingShape",value:{value:""}}),o.currObjType.isDragging=!1,e&&"touchstart"!==e.type&&t.isNullOrUndefined(i)&&o.activeObj.pointColl.pop(),this.updatePathRatio(o.activeObj),o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),e&&o.notify("selection",{prop:"mouseUpEventHandler",value:{e:e}}),o.notify("draw",{prop:"setNewPath",value:{bool:!0}}),o.objColl[o.objColl.length-1]&&o.selectShape(o.objColl[o.objColl.length-1].currIndex),t.isBlazor()?o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape):o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}});var p={shapeSettingsObj:{}};o.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:p}});var h=p.shapeSettingsObj,c={action:"draw-end",previousShapeSettings:h},d={action:"move",previousShapeSettings:h};o.notify("selection",{prop:"triggerShapeChange",onPropertyChange:!1,value:{shapeResizingArgs:c,shapeMovingArgs:d,type:"mouse-up"}})}}},i.prototype.findTextTarget=function(e){var i=this.parent;if("text"===i.activeObj.shape){var o,r;if("dblclick"===e.type?(o=e.clientX,r=e.clientY):"touchstart"===e.type&&(o=e.touches[0].clientX,r=e.touches[0].clientY,i.notify("selection",{prop:"setTouchEndPoint",onPropertyChange:!1,value:{x:e.touches[0].clientX,y:e.touches[0].clientY}})),t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn","textAreaClicked"):(i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!0}}),i.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),i.notify("toolbar",{prop:"setPreventZoomBtn",onPropertyChange:!1,value:{isPrevent:!1}}),i.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})),t.isNullOrUndefined(o)||t.isNullOrUndefined(r))if("block"===i.textArea.style.display&&""!==this.selectedText()&&"mousedown"===e.type){l=i.textArea.value;i.textArea.value+="a",i.textArea.value=l}else"none"===i.textArea.style.display&&(i.textArea.style.display="block");else{var a=this.parent.lowerCanvas.getBoundingClientRect();o-=a.left,r-=a.top;var n="",s=this.getRotDegOfShape(i.activeObj);n=""===i.activeObj.textFlip?i.activeObj.textFlip===i.transform.currFlipState?"":i.transform.currFlipState:i.activeObj.textFlip===i.transform.currFlipState?"":""===i.transform.currFlipState?i.activeObj.textFlip:i.transform.currFlipState;var l=void 0;if("none"===i.textArea.style.display){l=t.extend({},i.activeObj,{},!0);for(var p=0;p<i.objColl.length;p++)JSON.stringify(i.activeObj)===JSON.stringify(i.objColl[p])&&i.objColl.splice(p,1);this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),this.lowerContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),(i.currSelectionPoint&&"crop-circle"===i.currSelectionPoint.shape||i.isCircleCrop)&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.activeObj=l,this.updateFontStyles();var h=t.extend({},i.activeObj,{},!0);if(o>=h.activePoint.startX-2*h.topLeftCircle.radius&&o<=h.activePoint.endX+2*h.topLeftCircle.radius&&r>=h.activePoint.startY-2*h.topLeftCircle.radius&&r<=h.activePoint.endY+2*h.topLeftCircle.radius){if(this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height),4===h.flipObjColl.length&&(h.flipObjColl=[],n="",h.shapeFlip=""),""===n&&h.flipObjColl.length>1&&(n=h.flipObjColl[h.flipObjColl.length-1]),h.flipObjColl.length<=1){o=(c=this.setTextBoxPos(h,s,n,o,r)).x,r=c.y}else{var c;o=(c=this.setTextBoxPoints(h,s,n,o,r)).x,r=c.y}0!==i.activeObj.rotatedAngle&&(o=i.activeObj.horTopLinePointColl[0].x,r=i.activeObj.horTopLinePointColl[0].y),this.renderTextArea(o,r,h)}else this.applyActObj()}}}else this.stopPathDrawing(e,null)},i.prototype.fileChanged=function(e){var i=e.target.files[0],o=i.name&&i.name.split(".")[1].toLowerCase();if(o&&-1===["jpg","jpeg","png","svg"].indexOf(o))this.refreshActiveObj();else{var r=window.URL.createObjectURL(e.target.files[0]);this.onLoadImgShape(null,null,null,null,r.toString(),!0),t.isBlazor()||(document.getElementById(this.parent.element.id+"_fileUpload").value="")}},i.prototype.onLoadImgShape=function(e,t,i,o,r,a,n,s){var l=this;"string"==typeof r?this.shapeImg.src=r:(this.parent.inMemoryCanvas.width=r.width,this.parent.inMemoryCanvas.height=r.height,this.parent.inMemoryCanvas.getContext("2d").putImageData(r,0,0),this.shapeImg.src=this.parent.inMemoryCanvas.toDataURL()),this.prevObjColl(),this.parent.activeObj.shape="image",this.initShapeProps(),this.shapeImg.onload=function(){l.upperContext.drawImage(l.shapeImg,0,0,l.shapeImg.width,l.shapeImg.height),l.updateImgCanvas(a,e,t,i,o,n,s)}},i.prototype.updateImgCanvas=function(e,i,o,r,a,n,s){var l=this,p=this.parent;p.activeObj.imageElement=this.shapeImg,p.activeObj.imageCanvas=p.createElement("canvas");var h={width:0,height:0};if(p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:null}}),r&&a)if(s){var c={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:c}}),h=this.resizeImage(r,c.ratio)}else h={width:r,height:a};if(this.updateObj(h,i,o),p.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:p.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}}),p.notify("transform",{prop:"calcMaxDimension",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:h,isImgShape:!0}}),r&&a)if(s){var d={ratio:null};p.notify("selection",{prop:"findImageRatio",onPropertyChange:!1,value:{width:this.shapeImg.width,height:this.shapeImg.height,obj:d}}),h=this.resizeImage(r,d.ratio)}else h={width:r,height:a};this.updateObj(h,i,o),p.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),this.shapeImg=null,n&&(p.activeObj.rotatedAngle=n*(Math.PI/180),p.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:p.activeObj}}));var v={shapeSettingsObj:{}};p.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:v}});var u=v.shapeSettingsObj,g={action:"insert",previousShapeSettings:u,currentShapeSettings:u};t.isBlazor()&&p.events&&!0===p.events.shapeChanging.hasDelegate?p.dotNetRef.invokeMethodAsync("ShapeEventAsync","OnShape",g).then(function(t){l.drawShapeImageEvent(t,e),p.isPublicMethod&&p.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),p.isPublicMethod=!1}):(p.trigger("shapeChanging",g),this.drawShapeImageEvent(g,e),p.isPublicMethod&&p.notify("undo-redo",{prop:"updateUndoRedo",onPropertyChange:!1}),p.isPublicMethod=!1)},i.prototype.updateObj=function(e,t,i){var o=this.parent;o.activeObj.activePoint.width=e.width,o.activeObj.activePoint.height=e.height,o.activeObj.activePoint.startX=t||o.lowerCanvas.width/2-e.width/2,o.activeObj.activePoint.startY=i||o.lowerCanvas.height/2-e.height/2,o.activeObj.activePoint.endX=o.activeObj.activePoint.startX+e.width,o.activeObj.activePoint.endY=o.activeObj.activePoint.startY+e.height},i.prototype.resizeImage=function(e,t){var i=t.split(":"),o=parseInt(i[0],10),r=parseInt(i[1],10);return{width:e,height:Math.round(e*r/o)}},i.prototype.setTextBoxPos=function(e,t,i,o,r){var a={x:o,y:r};switch(t){case 0:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):(a.x=e.activePoint.startX,a.y=e.activePoint.startY);break;case 90:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):(a.x=e.activePoint.endX,a.y=e.activePoint.startY);break;case 180:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):(a.x=e.activePoint.endX,a.y=e.activePoint.endY);break;case 270:"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):(a.x=e.activePoint.startX,a.y=e.activePoint.endY)}return a},i.prototype.setTextBoxPoints=function(e,t,i,o,r){var a={x:o,y:r};switch(t){case 0:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.startY);break;case 90:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.endY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.startY);break;case 180:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.startX,a.y=e.activePoint.endY);break;case 270:e.flipObjColl[0]&&"horizontal"===e.flipObjColl[0].toLowerCase()?"horizontal"===i.toLowerCase()?(a.x=e.activePoint.startX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"horizontal"===i.toLowerCase()?(a.x=e.activePoint.endX,a.y=e.activePoint.startY):"vertical"===i.toLowerCase()&&(a.x=e.activePoint.endX,a.y=e.activePoint.endY)}return a},i.prototype.selectedText=function(){var e=this.parent.textArea.selectionStart,t=this.parent.textArea.selectionEnd;return this.parent.textArea.value.substring(e,t)},i.prototype.panObjColl=function(e,t,i){var o=this.parent;if(o.objColl.length>0){for(var r=0,a=o.objColl.length;r<a;r++){var n=o.objColl[r];if(""===i||"vertical"===i){if(n.activePoint.startX+=e,n.activePoint.endX+=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x+=e),"path"===n.shape)for(var s=0,l=n.pointColl.length;s<l;s++)n.pointColl[s].x+=e}else if(n.activePoint.startX-=e,n.activePoint.endX-=e,n.rotationCirclePointColl&&(n.rotationCirclePointColl.x-=e),"path"===n.shape){s=0;for(var p=n.pointColl.length;s<p;s++)n.pointColl[s].x-=e}if(""===i||"horizontal"===i){if(n.activePoint.startY+=t,n.activePoint.endY+=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y+=t),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y+=t}else if(n.activePoint.startY-=t,n.activePoint.endY-=t,n.rotationCirclePointColl&&(n.rotationCirclePointColl.y-=t),"path"===n.shape)for(s=0;s<n.pointColl.length;s++)n.pointColl[s].y-=t;if(n=this.updateWidthHeight(n),o.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:n.activePoint,obj:n}}),"line"===n.shape||"arrow"===n.shape){n.pointColl=this.getLinePoints(n.activePoint.startX,n.activePoint.startY,n.activePoint.endX,n.activePoint.endY);for(var h=0,c=n.pointColl.length;h<c;h++)n.pointColl[h].ratioX=(n.pointColl[h].x-o.img.destLeft)/o.img.destWidth,n.pointColl[h].ratioY=(n.pointColl[h].y-o.img.destTop)/o.img.destHeight}var d=this.lowerContext.filter;this.lowerContext.filter="none",this.apply(n.shape,n),this.lowerContext.filter=d,this.refreshActiveObj()}o.notify("draw",{prop:"applyFrame",value:{ctx:this.lowerContext,frame:o.frameObj.type,preventImg:!0}})}},i.prototype.updateFontStyles=function(e){var t=this.parent;this.upperContext.strokeStyle=t.activeObj.strokeSettings.strokeColor,this.upperContext.fillStyle=t.activeObj.strokeSettings.strokeColor;var i="";t.activeObj.textSettings.bold&&(i="bold "),t.activeObj.textSettings.italic&&(i="italic "),t.activeObj.textSettings.bold&&t.activeObj.textSettings.italic&&(i="italic bold ");var o=e?parseFloat(t.textArea.style.fontSize):t.activeObj.textSettings.fontSize,r="block"===t.textArea.style.display?t.textArea.style.fontFamily:t.activeObj.textSettings.fontFamily;this.upperContext.font=i+o+"px "+r},i.prototype.applyFontStyle=function(e){var i=this.parent,o={shapeSettingsObj:{}};i.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:o}});var r=o.shapeSettingsObj;this.pushActItemIntoObj();var a=t.extend([],i.objColl,[],!0);switch(i.objColl.pop(),"none"===i.textArea.style.display?this.updateFontRatio(i.activeObj):this.updateFontRatio(i.activeObj,!0),e){case"default":this.updateFontStyle(e,a,"normal","normal");break;case"bold":this.updateFontStyle(e,a,"bold","normal");break;case"italic":this.updateFontStyle(e,a,"normal","italic");break;case"bolditalic":this.updateFontStyle(e,a,"bold","italic")}var n={action:"font-style",previousShapeSettings:t.extend({},r,{},!0),currentShapeSettings:t.extend({},r,{},!0)};n.currentShapeSettings.fontStyle=[e],i.triggerShapeChanged(n)},i.prototype.updateFontStyle=function(e,t,i,o){var r=this.parent;if("block"===r.textArea.style.display){var a=this.getTextAreaWidth(e);r.textArea.style.width=a+"px",r.textArea.style.fontWeight=i,r.textArea.style.fontStyle=o,this.updateObjColl(e,t)}else this.textSettings.bold=r.activeObj.textSettings.bold="normal"!==i,this.textSettings.italic=r.activeObj.textSettings.italic="normal"!==o,this.redrawText(),r.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:t}})},i.prototype.updateArrowRatio=function(e){var t={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:t}});var i;i=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var o,r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=i/t.arrowDimension[o].width,s=i/t.arrowDimension[o].height;t.arrowDimension[o].ratioX=n,t.arrowDimension[o].ratioY=s}},i.prototype.updateArrowSize=function(e){var t={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:t}});var i;i=Math.abs(e.activePoint.width)>Math.abs(e.activePoint.height)?Math.abs(e.activePoint.width):Math.abs(e.activePoint.height);for(var o,r=0,a=["bar","arrow","arrowSolid","circle","square"];r<a.length;r++){o=a[r];var n=t.arrowDimension[o].ratioX,s=t.arrowDimension[o].ratioY;t.arrowDimension[o].width=i/n,t.arrowDimension[o].height=i/s}},i.prototype.updateFontRatio=function(e,i){var o=this.parent,r=this.getMaxText(i),a=this.upperContext.measureText(r).width+.5*o.activeObj.textSettings.fontSize,n=o.activeObj.textSettings.fontSize+.25*o.activeObj.textSettings.fontSize,s=this.getRotDegOfShape(e);t.isNullOrUndefined(i)?0===s||180===Math.abs(s)?e.textSettings.fontRatio=a/e.textSettings.fontSize:e.textSettings.fontRatio=n/e.textSettings.fontSize:i&&(e.textSettings.fontRatio=a/parseFloat(o.textArea.style.fontSize))},i.prototype.updateFontSize=function(e){var t=this.getRotDegOfShape(e);0===t||180===Math.abs(t)?e.textSettings.fontSize=e.activePoint.width/e.textSettings.fontRatio:e.textSettings.fontSize=e.activePoint.height/e.textSettings.fontRatio},i.prototype.updateObjColl=function(e,i){var o=this.parent,r=t.extend({},o.cropObj,{},!0),a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=i,n.pointColl=t.extend([],o.pointColl,[],!0),n.afterCropActions=t.extend([],o.afterCropActions,[],!0);var s={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0);var l=o.activeObj.textSettings.bold,p=o.activeObj.textSettings.italic;switch(e){case"default":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!1;break;case"bold":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!1;break;case"italic":o.activeObj.textSettings.bold=!1,o.activeObj.textSettings.italic=!0;break;case"bolditalic":o.activeObj.textSettings.bold=!0,o.activeObj.textSettings.italic=!0}o.objColl.push(o.activeObj),o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),o.objColl.pop(),o.activeObj.textSettings.bold=l,o.activeObj.textSettings.italic=p},i.prototype.pushActItemIntoObj=function(){if("none"===this.parent.textArea.style.display)this.parent.objColl.push(this.parent.activeObj);else{var e=t.extend({},this.parent.activeObj,{},!0);this.parent.notify("selection",{prop:"setTextBoxStylesToActObj",onPropertyChange:!1}),this.parent.objColl.push(this.parent.activeObj),this.parent.activeObj=e}},i.prototype.clearActObj=function(){"none"===this.parent.textArea.style.display&&(this.refreshActiveObj(),this.applyActObj(),this.refreshActiveObj(),this.parent.currObjType.isCustomCrop=!1)},i.prototype.refreshActiveObj=function(){this.parent.activeObj={},this.parent.activeObj.activePoint={startX:0,startY:0,endX:0,endY:0,width:0,height:0},this.parent.activeObj.triangle=[],this.parent.activeObj.triangleRatio=[],this.parent.activeObj.flipObjColl=[],this.parent.activeObj.strokeSettings=this.strokeSettings,this.parent.activeObj.textSettings=this.textSettings,this.parent.activeObj.rotatedAngle=0},i.prototype.applyActObj=function(e){var i=!1;if(void 0!==this.parent.activeObj.shape&&"text"===this.parent.activeObj.shape&&""===this.parent.activeObj.keyHistory)this.refreshActiveObj(),this.upperContext.clearRect(0,0,this.parent.upperCanvas.width,this.parent.upperCanvas.height);else{var o=void 0,r=!1;if(void 0!==this.parent.activeObj.shape&&(o=this.parent.activeObj.shape.split("-")),void 0===o&&this.parent.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.parent.activeObj.shape&&!r&&"shape"!==this.parent.activeObj.shape){for(var a=0;a<this.parent.objColl.length;a++)if(JSON.stringify(this.parent.activeObj)===JSON.stringify(this.parent.objColl[a])){i=!0;break}if(!i){t.isNullOrUndefined(this.parent.activeObj.currIndex)&&(this.parent.activeObj.currIndex="shape_"+(this.parent.objColl.length+1)),this.updImgRatioForActObj();var n=this.parent.activeObj.currIndex.split("_"),s=this.parent.objColl.splice(0,parseInt(n[1],10)-1);s.push(t.extend({},this.parent.activeObj,{},!0));for(a=0;a<this.parent.objColl.length;a++)s.push(this.parent.objColl[a]);this.parent.objColl=s,s=[],this.refreshActiveObj(),this.lowerContext.clearRect(0,0,this.parent.lowerCanvas.width,this.parent.lowerCanvas.height),this.parent.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.parent.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),this.parent.currObjType.shape="",this.refreshActiveObj(),this.parent.isCircleCrop&&this.parent.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),t.isBlazor()?this.parent.updateToolbar(this.parent.element,"destroyQuickAccessToolbar"):this.parent.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),t.isNullOrUndefined(e)&&(this.parent.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.parent.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:null}}))}}}},i.prototype.alignTextAreaIntoCanvas=function(){var e=this.parent,t=e.textArea.value;e.textArea.value="";for(var i=0,o=t.length;i<o;i++)e.textArea.value+=t[i],e.textArea.style.height="auto",e.textArea.style.height=e.textArea.scrollHeight+"px",this.setTextBoxWidth()},i.prototype.transformTextArea=function(){var e=this.parent;if("text"===e.activeObj.shape){e.textArea.style.transformOrigin="0 0";var t=e.activeObj.rotatedAngle*(180/Math.PI),i="",o=this.getRotDegOfShape(e.activeObj);if(e.activeObj.flipObjColl.length>0)for(var r=0;r<e.activeObj.flipObjColl.length;r++)i+=0!==o&&o%90==0&&180!==o?"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(1, -1)":"scale(-1, 1)":"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?"scale(-1, 1)":"scale(1, -1)",o+=t,"horizontal"===e.activeObj.flipObjColl[r].toLowerCase()?e.textArea.style.transform="rotate("+o+"deg)"+i:"vertical"===e.activeObj.flipObjColl[r].toLowerCase()&&(e.textArea.style.transform="rotate("+o+"deg)"+i);else o+=t,e.textArea.style.transform="rotate("+o+"deg)"}},i.prototype.getTextAreaWidth=function(e){var t=this.parent,i=t.activeObj.textSettings.bold,o=t.activeObj.textSettings.italic;switch(e){case"default":t.activeObj.textSettings.bold=!1,t.activeObj.textSettings.italic=!1;break;case"bold":t.activeObj.textSettings.bold=!0,t.activeObj.textSettings.italic=!1;break;case"italic":t.activeObj.textSettings.bold=!1,t.activeObj.textSettings.italic=!0;break;case"bolditalic":t.activeObj.textSettings.bold=!0,t.activeObj.textSettings.italic=!0}this.updateFontStyles();var r;return r="none"===t.textArea.style.display?this.upperContext.measureText(t.activeObj.keyHistory).width+.5*t.activeObj.textSettings.fontSize:this.upperContext.measureText(t.textArea.value).width+.5*t.activeObj.textSettings.fontSize,t.activeObj.textSettings.bold=i,t.activeObj.textSettings.italic=o,r},i.prototype.getObjDetails=function(e){var t=this.parent,i={};switch(i.id=e.currIndex,i.type=t.toPascalCase(e.shape),i.startX=e.activePoint.startX,i.startY=e.activePoint.startY,e.shape){case"rectangle":i.width=e.activePoint.width,i.height=e.activePoint.height,i.strokeColor=e.strokeSettings.strokeColor,i.fillColor=e.strokeSettings.fillColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"ellipse":i.radius=e.activePoint.width/2,i.strokeColor=e.strokeSettings.strokeColor,i.fillColor=e.strokeSettings.fillColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"line":case"arrow":i.length=e.activePoint.width,i.strokeColor=e.strokeSettings.strokeColor,i.strokeWidth=e.strokeSettings.strokeWidth;break;case"text":i.text=e.keyHistory,i.fontSize=e.textSettings.fontSize,i.color=e.strokeSettings.strokeColor,i.fontStyle=[],e.textSettings.bold&&i.fontStyle.push("bold"),e.textSettings.italic&&i.fontStyle.push("italic");break;case"path":i.strokeColor=e.strokeSettings.strokeColor,i.strokeWidth=e.strokeSettings.strokeWidth}return i},i.prototype.getFreehandDrawDetails=function(i){var o=this.parent,r={};return r.id=o.pointColl[i].id,r.type=e.ShapeType.FreehandDraw,r.points=t.extend([],o.pointColl[i].points),r.strokeColor=o.pointColl[i].strokeColor,r.strokeWidth=o.pointColl[i].strokeWidth,r},i.prototype.getShapeSetting=function(e,i){var o,r=this.parent;if(!r.disabled&&r.isImageLoaded)if(this.applyActObj(),"shape"===e.split("_")[0]){for(var a,n=0,s=r.objColl.length;n<s;n++)if(r.objColl[n].currIndex===e){a=t.extend({},r.objColl[n],{},!0);break}o=this.getObjDetails(a)}else"pen"===e.split("_")[0]&&(o=this.getFreehandDrawDetails(parseInt(e.split("_")[1],10)-1));i.shapeDetails=o},i.prototype.getShapeSettings=function(e){var t=this.parent,i=[];if(!t.disabled&&t.isImageLoaded){this.applyActObj();for(var o=0,r=t.objColl.length;o<r;o++){var a=this.getObjDetails(t.objColl[o]);i.push(a)}for(o=0;o<t.freehandCounter;o++){a=this.getFreehandDrawDetails(o);i.push(a)}}e.shapeDetailsColl=i},i.prototype.isPointsInRange=function(e,i,o){var r=!1;!t.isNullOrUndefined(e)&&!t.isNullOrUndefined(i)&&e>=this.parent.img.destLeft&&i>=this.parent.img.destTop&&e<=this.parent.img.destLeft+this.parent.img.destWidth&&i<=this.parent.img.destTop+this.parent.img.destHeight&&(r=!0),o.inRange=r},i.prototype.alignRotateFlipColl=function(e,t,i){return e=this.popForDefaultTransformedState(e),e=this.popForDefaultFlipState(e),0===(e=this.popForDefaultRotateState(e)).length&&t&&(this.parent.transform.degree=0,this.parent.transform.currFlipState=""),i.collection=e,e},i.prototype.popForDefaultTransformedState=function(e){for(var t=0,i=0,o=0,r=0,a=0;a<e.length;a++)90===e[a]||"rotateRight"===e[a]?(i=0,o=0,r=0,4===++t&&(e.pop(),e.pop(),e.pop(),e.pop())):-90===e[a]||"rotateLeft"===e[a]?(t=0,o=0,r=0,4===++i&&(e.pop(),e.pop(),e.pop(),e.pop())):"horizontal"===e[a]||"Horizontal"===e[a]||"horizontalflip"===e[a]?(i=0,t=0,r=0,2===++o&&(e.pop(),e.pop())):"vertical"!==e[a]&&"Vertical"!==e[a]&&"verticalflip"!==e[a]||(o=0,i=0,t=0,2===++r&&(e.pop(),e.pop()));return e},i.prototype.popForDefaultFlipState=function(e){for(var i=0;i<e.length;i++)t.isNullOrUndefined(e[i+3])||("horizontal"!==e[i]&&"Horizontal"!==e[i]&&"horizontalFlip"!==e[i]||"vertical"!==e[i+1]&&"Vertical"!==e[i+1]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+2]&&"Horizontal"!==e[i+2]&&"horizontalFlip"!==e[i]||"vertical"!==e[i+3]&&"Vertical"!==e[i+3]&&"verticalFlip"!==e[i]?"vertical"!==e[i]&&"Vertical"!==e[i]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+1]&&"Horizontal"!==e[i+1]&&"horizontalFlip"!==e[i+1]||"vertical"!==e[i+2]&&"Vertical"!==e[i+2]&&"verticalFlip"!==e[i]||"horizontal"!==e[i+3]&&"Horizontal"!==e[i+3]&&"horizontalFlip"!==e[i]||(e.pop(),e.pop(),e.pop(),e.pop()):(e.pop(),e.pop(),e.pop(),e.pop()));return e},i.prototype.popForDefaultRotateState=function(e){for(var i=0;i<e.length;i++)t.isNullOrUndefined(e[i+1])||(90!==e[i]&&"rotateRight"!==e[i]||-90!==e[i+1]&&"rotateLeft"!==e[i]?-90!==e[i]&&"rotateLeft"!==e[i]||90!==e[i+1]&&"rotateRight"!==e[i]||(e.pop(),e.pop()):(e.pop(),e.pop()));return e},i.prototype.selectShape=function(e,i){var o=this.parent,r=!1;if(!o.disabled&&o.isImageLoaded)if(this.applyActObj(),"shape"===e.split("_")[0]){for(var a,n=0,s=o.objColl.length;n<s;n++)if(o.objColl[n].currIndex===e){a=t.extend({},o.objColl[n],{},!0);break}if(t.isNullOrUndefined(a))r=!1;else{r=!0,o.activeObj=a;var l={canvasFilter:null};o.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:l}}),this.lowerContext.filter=l.canvasFilter,o.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:o.activeObj}}),t.isBlazor()?(o.updateToolbar(o.element,o.activeObj.shape),"path"===o.activeObj.shape?o.updateToolbar(this.parent.element,"path","pathQuickAccessToolbar"):o.updateToolbar(o.element,"quickAccessToolbar",o.activeObj.shape)):("text"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"text",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):"pen"===o.activeObj.shape?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"pen",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))}}else if("pen"===e.split("_")[0]){l={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:l}}),l.bool&&o.okBtn();var p={isIndex:!1};o.notify("freehand-draw",{prop:"isFHDIdx",value:{index:parseInt(e.split("_")[1],10)-1,obj:p}}),p.isIndex?(r=!0,o.notify("freehand-draw",{prop:"selectFhd",value:{id:e}}),t.isBlazor()?(o.updateToolbar(o.element,"pen"),o.updateToolbar(o.element,"quickAccessToolbar","pen")):(o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}),o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}))):r=!1}i.isSelected=r},i.prototype.deleteShape=function(e){var i=this.parent;if(!i.disabled&&i.isImageLoaded){if(this.applyActObj(),"shape"===e.split("_")[0]){for(var o=0,r=i.objColl.length;o<r;o++)if(i.objColl[o].currIndex===e){i.objColl.splice(o,1);break}}else"pen"===e.split("_")[0]&&i.notify("freehand-draw",{prop:"handle-freehand-draw",value:{id:e}});var a={canvasFilter:null};i.notify("toolbar",{prop:"getCanvasFilter",onPropertyChange:!1,value:{obj:a}}),this.lowerContext.filter=a.canvasFilter,this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"imageLoaded"):i.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})}},i.prototype.getMaxText=function(e,i,o){t.isNullOrUndefined(i)&&(i=e?this.parent.textArea.value:this.parent.activeObj.keyHistory);for(var r,a=i.split("\n"),n=a[0].length,s=a[0],l=1;l<a.length;l++)(r=a[l].length)>n&&(s=a[l],n=r);return o&&(o.maxText=s),s},i.prototype.getLinePoints=function(e,i,o,r){var a,n,s=[];if(e===o){i<r?(a=[e,i],n=[o,r]):(n=[e,i],a=[o,r]);for(var l=this.getSlope(a,n,!0),p=this.getIntercept(a,l),h=a[1];h<=n[1];h++){var c=l*h+p;s.push({x:c,y:h})}}else{e<o?(a=[e,i],n=[o,r]):(n=[e,i],a=[o,r]);for(l=this.getSlope(a,n,!1),p=this.getIntercept(a,l),c=a[0];c<=n[0];c++){h=l*c+p;s.push({x:c,y:h})}}if(Math.floor(e)===Math.floor(o)||s.length<10&&(r-i>10||i-r>10)){s=[];for(var d=Math.min(i,r),v=0;v<Math.abs(Math.floor(r)-Math.floor(i));v++)s.push({x:e,y:d+v});if(s.length>1){var u=void 0;u=t.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];var g=s[s.length-1].x-u.x,b=s[s.length-1].y-u.y;s.push({x:s[s.length-1].x+g/2,y:s[s.length-1].y+b/2})}}else if(Math.floor(i)===Math.floor(r)||s.length<10&&(o-e>10||e-o>10)){s=[];for(var f=Math.min(e,o),m=0;m<Math.abs(Math.floor(o)-Math.floor(e));m++)s.push({x:f+m,y:i});if(s.length>1){u=void 0;u=t.isNullOrUndefined(s[s.length-2])?{x:0,y:0}:s[s.length-2];g=s[s.length-1].x-u.x,b=s[s.length-1].y-u.y;s.push({x:s[s.length-1].x+g/2,y:s[s.length-1].y+b/2})}}return s},i.prototype.getSlope=function(e,t,i){var o;if(i){if(e[1]===t[1])return null;o=(t[0]-e[0])/(t[1]-e[1])}else{if(e[0]===t[0])return null;o=(t[1]-e[1])/(t[0]-e[0])}return o},i.prototype.getIntercept=function(e,t){return null===t?e[0]:e[1]-t*e[0]},i.prototype.setPointCollForShapeRotation=function(e){var t=e.activePoint.startX+e.activePoint.width/2,i=e.activePoint.startY+e.activePoint.height/2,o={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-i)+i},r={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-i)+i},a={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-i)+i},n={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-t)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-i)+t,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-t)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-i)+i};e.horTopLinePointColl=this.getLinePoints(o.x,o.y,r.x,r.y),e.horBottomLinePointColl=this.getLinePoints(a.x,a.y,n.x,n.y),e.verLeftLinePointColl=this.getLinePoints(o.x,o.y,a.x,a.y),e.verRightLinePointColl=this.getLinePoints(r.x,r.y,n.x,n.y),e.verLeftLinePointColl.reverse(),e.verRightLinePointColl.reverse();for(var s=0;s<e.horTopLinePointColl.length;s++)e.horTopLinePointColl[s].ratioX=(e.horTopLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horTopLinePointColl[s].ratioY=(e.horTopLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.horBottomLinePointColl.length;s++)e.horBottomLinePointColl[s].ratioX=(e.horBottomLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.horBottomLinePointColl[s].ratioY=(e.horBottomLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.verLeftLinePointColl.length;s++)e.verLeftLinePointColl[s].ratioX=(e.verLeftLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verLeftLinePointColl[s].ratioY=(e.verLeftLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;for(s=0;s<e.verRightLinePointColl.length;s++)e.verRightLinePointColl[s].ratioX=(e.verRightLinePointColl[s].x-this.parent.img.destLeft)/this.parent.img.destWidth,e.verRightLinePointColl[s].ratioY=(e.verRightLinePointColl[s].y-this.parent.img.destTop)/this.parent.img.destHeight;if("move"!==this.parent.upperCanvas.style.cursor){var l={rotationCirclePoint:null};this.parent.notify("selection",{prop:"getTransRotationPoint",value:{obj:e,object:l}});var p=l.rotationCirclePoint;p&&(e.rotationCirclePointColl={x:Math.cos(e.rotatedAngle)*(p.x-t)-Math.sin(e.rotatedAngle)*(p.y-i)+t,y:Math.sin(e.rotatedAngle)*(p.x-t)+Math.cos(e.rotatedAngle)*(p.y-i)+i},e.rotationCirclePointColl.ratioX=(e.rotationCirclePointColl.x-this.parent.img.destLeft)/this.parent.img.destWidth,e.rotationCirclePointColl.ratioY=(e.rotationCirclePointColl.y-this.parent.img.destTop)/this.parent.img.destHeight)}},i.prototype.getSquarePointForRotatedShape=function(e,t){var i={startX:0,startY:0,endX:0,endY:0,width:0,height:0},o=e.activePoint.startX+e.activePoint.width/2,r=e.activePoint.startY+e.activePoint.height/2,a={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-r)+r},n={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.startY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.startY-r)+r},s={x:Math.cos(e.rotatedAngle)*(e.activePoint.startX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.startX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-r)+r},l={x:Math.cos(e.rotatedAngle)*(e.activePoint.endX-o)-Math.sin(e.rotatedAngle)*(e.activePoint.endY-r)+o,y:Math.sin(e.rotatedAngle)*(e.activePoint.endX-o)+Math.cos(e.rotatedAngle)*(e.activePoint.endY-r)+r};return i.startX=a.x,i.startY=a.y,i.endX=a.x,i.endY=a.y,i.startX>n.x&&(i.startX=n.x),i.startX>s.x&&(i.startX=s.x),i.startX>l.x&&(i.startX=l.x),i.startY>n.y&&(i.startY=n.y),i.startY>s.y&&(i.startY=s.y),i.startY>l.y&&(i.startY=l.y),i.endX<n.x&&(i.endX=n.x),i.endX<s.x&&(i.endX=s.x),i.endX<l.x&&(i.endX=l.x),i.endY<n.y&&(i.endY=n.y),i.endY<s.y&&(i.endY=s.y),i.endY<l.y&&(i.endY=l.y),i.width=i.endX-i.startX,i.height=i.endY-i.startY,t&&(t.activePoint=i),i},i}(),v=function(){function o(e){this.isReverseFlip=!1,this.disablePan=!1,this.isReverseRotate=!1,this.flipColl=[],this.prevZoomValue=1,this.cropDimension={width:0,height:0},this.isPreventSelect=!1,this.preventDownScale=!1,this.resizedImgAngle=null,this.parent=e,this.addEventListener()}return o.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},o.prototype.addEventListener=function(){this.parent.on("transform",this.transform,this),this.parent.on("destroyed",this.destroy,this)},o.prototype.removeEventListener=function(){this.parent.off("transform",this.transform),this.parent.off("destroyed",this.destroy)},o.prototype.transform=function(e){switch(this.initTransformPvtVar(),e.prop){case"rotateImage":this.rotateImage(e.value.degree);break;case"flipImage":this.flipImage(e.value.direction);break;case"setDestPointsForFlipState":this.setDestPointsForFlipState();break;case"zoomAction":this.zoomAction(e.value.zoomFactor,e.value.zoomPoint,e.value.isResize);break;case"disableZoomOutBtn":this.disableZoomOutBtn(e.value.isZoomOut);break;case"rotatedFlip":this.rotatedFlip();break;case"drawPannedImage":this.drawPannedImage(e.value.xDiff,e.value.yDiff);break;case"drawPannImage":this.drawPannImage(e.value.point);break;case"performTransformation":this.performTransformation(e.value.text);break;case"updateTransform":this.updateTransform(e.value.text);break;case"rotatePan":this.rotatePan(e.value.isCropSelection,e.value.isDefaultZoom);break;case"drawRotatedImage":this.drawRotatedImage(e.value.degree);break;case"limitPan":this.limitPan();break;case"updateFlipActiveObj":this.updateFlipActiveObj(e.value.panRegion);break;case"resetZoom":this.resetZoom();break;case"pan":this.pan(e.value.value);break;case"zoom":this.zoom(e.value.zoomFactor,e.value.zoomPoint);break;case"setCurrPanRegion":this.setCurrPanRegion(e.value.region,e.value.type,e.value.obj);break;case"rotate":this.rotate(e.value.degree,e.value.obj);break;case"flip":this.flip(e.value.direction);break;case"update":this.update();break;case"calcMaxDimension":this.calcMaxDimension(e.value.width,e.value.height,e.value.obj,e.value.isImgShape);break;case"updatePanPoints":this.updatePanPoints(e.value.panRegion,e.value.obj);break;case"getPanMove":e.value.obj.panMove=this.panMove;break;case"setPanMove":this.panMove=e.value.point;break;case"getTempPanMove":e.value.obj.tempPanMove=this.tempPanMove;break;case"setTempPanMove":this.tempPanMove=e.value.point;break;case"setReverseFlip":this.isReverseFlip=e.value.isReverseFlip;break;case"setDisablePan":this.disablePan=e.value.bool;break;case"setCurrDestinationPoint":this.currDestPoint=e.value.point,this.currDestPoint.startX-=this.parent.cropObj.totalPannedPoint.x,this.currDestPoint.startY-=this.parent.cropObj.totalPannedPoint.y;break;case"setReverseRotate":this.isReverseRotate=e.value.bool;break;case"getFlipColl":e.value.obj.flipColl=this.flipColl;break;case"setFlipColl":this.flipColl=e.value.flipColl;break;case"getPreviousZoomValue":e.value.obj.previousZoomValue=this.prevZoomValue;break;case"setPreviousZoomValue":this.prevZoomValue=e.value.previousZoomValue;break;case"getCropDimension":e.value.obj.cropDimension=this.cropDimension;break;case"setCropDimension":this.cropDimension.width=e.value.width,this.cropDimension.height=e.value.height;break;case"getPreventSelect":e.value.obj.bool=this.isPreventSelect;break;case"setPreventSelect":this.isPreventSelect=e.value.bool;break;case"resizeImage":this.resizeImage(e.value.width,e.value.height);break;case"resizeCrop":this.resizeCrop(e.value.width,e.value.height);break;case"setPreventDownScale":this.preventDownScale=e.value.bool;break;case"updateResize":this.updateResize();break;case"resize":this.resize(e.value.width,e.value.height,e.value.isAspectRatio);break;case"reset":this.reset()}},o.prototype.getModuleName=function(){return"transform"},o.prototype.initTransformPvtVar=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},o.prototype.reset=function(){this.zoomBtnHold=null,this.tempPanMove=null,this.panMove=null,this.disablePan=!1,this.currDestPoint=null,this.isReverseRotate=!1,this.flipColl=[],this.resizedImgAngle=null,this.transCurrObj=null,this.prevZoomValue=1,this.isPreventSelect=this.preventDownScale=!1},o.prototype.rotateImage=function(e){var i=this,o=this.parent,r={cancel:!1,previousDegree:o.transform.degree,currentDegree:360===Math.abs(o.transform.degree+e)?0:o.transform.degree+e};!this.isPreventSelect&&t.isBlazor()&&o.events&&!0===o.events.rotating.hasDelegate?o.dotNetRef.invokeMethodAsync("RotateEventAsync","OnRotate",r).then(function(t){i.rotateEvent(t,e)}):(this.isPreventSelect||o.trigger("rotating",r),this.rotateEvent(r,e))},o.prototype.rotateEvent=function(e,i){var o=this.parent;if(!e.cancel){var r=void 0;if(t.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],o.objColl,null,!0),r.pointColl=t.extend({},o.pointColl,null,!0),r.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0)}o.afterCropActions.push(90===i?"rotateRight":"rotateLeft");var s=[],l=void 0;o.activeObj.activePoint&&o.activeObj.shape&&(void 0!==o.activeObj.shape&&(s=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===s[0])&&(l=o.currObjType.isCustomCrop?"custom":s[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.drawRotatedImage(i),o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),l&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}})),o.isUndoRedo=!1;var p={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:p}}),o.rotateFlipColl=p.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.drawRotatedImage=function(e){var i=this.parent;0===e?i.transform.degree=0:i.transform.degree+=e,360===Math.abs(i.transform.degree)&&(i.transform.degree=0),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var o=t.extend([],i.objColl,[],!0),r=t.extend({},i.activeObj,{},!0);if(i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseRotate||i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),this.rotateDegree(e),this.isReverseRotate||(i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.rotateFlipColl.push(e)),i.objColl=t.extend([],o,[],!0),i.activeObj=t.extend({},r,{},!0),i.isCircleCrop&&i.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e>0)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});else for(var a=0;a<3;a++)i.notify("freehand-draw",{prop:"rotateFhdColl",onPropertyChange:!1});i.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.updateCurrSelectionPoint(e)},o.prototype.rotateDegree=function(e){var t=this.parent;this.lowerContext.save(),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2);var i=this.lowerContext.filter;t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=i,this.lowerContext.translate(t.lowerCanvas.width/2,t.lowerCanvas.height/2),this.lowerContext.rotate(Math.PI/180*-e),this.lowerContext.translate(-t.lowerCanvas.width/2,-t.lowerCanvas.height/2),this.lowerContext.restore()},o.prototype.updateCurrSelectionPoint=function(e){var i=this.parent;if(i.currSelectionPoint&&this.currDestPoint){var o=t.extend({},i.activeObj,{},!0),r=t.extend([],i.objColl,[],!0),a={startX:i.img.srcLeft,startY:i.img.srcTop,width:i.img.srcWidth,height:i.img.srcHeight},n={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight};i.objColl=[],i.objColl.push(t.extend({},i.currSelectionPoint,{},!0)),t.isNullOrUndefined(i.objColl[0].imageRatio)&&(i.activeObj=i.objColl[0],i.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),i.objColl[0]=i.activeObj),i.img.srcLeft=0,i.img.srcTop=0,i.img.srcWidth=i.baseImgCanvas.width,i.img.srcHeight=i.baseImgCanvas.height,i.img.destLeft=this.currDestPoint.startX,i.img.destTop=this.currDestPoint.startY,i.img.destWidth=this.currDestPoint.width,i.img.destHeight=this.currDestPoint.height,"number"==typeof e&&(i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1}),i.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}})),i.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:e}}),i.currSelectionPoint=t.extend({},i.objColl[0],{},!0),this.currDestPoint={startX:i.img.destLeft,startY:i.img.destTop,width:i.img.destWidth,height:i.img.destHeight},i.objColl=r,i.activeObj=o,i.img.srcLeft=a.startX,i.img.srcTop=a.startY,i.img.srcWidth=a.width,i.img.srcHeight=a.height,i.img.destLeft=n.startX,i.img.destTop=n.startY,i.img.destWidth=n.width,i.img.destHeight=n.height}},o.prototype.flipImage=function(e){var i=this,o=this.parent,r={direction:e,cancel:!1,previousDirection:o.toPascalCase(o.transform.currFlipState||e)};!this.isPreventSelect&&t.isBlazor()&&o.events&&!0===o.events.flipping.hasDelegate?o.dotNetRef.invokeMethodAsync("FlipEventAsync","OnFlip",r).then(function(t){i.flipEvent(t,e)}):(this.isPreventSelect||o.trigger("flipping",r),this.flipEvent(r,e))},o.prototype.flipEvent=function(e,i){var o=this.parent;if(!e.cancel){var r;if(t.isNullOrUndefined(this.transCurrObj)){var a={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],o.objColl,null,!0),r.pointColl=t.extend({},o.pointColl,null,!0),r.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0)}o.afterCropActions.push("horizontal"===i.toLowerCase()?"horizontalflip":"verticalflip");var s,l=[];o.activeObj.activePoint&&(void 0!==o.activeObj.shape&&(l=o.activeObj.shape.split("-")),(o.currObjType.isCustomCrop||"crop"===l[0])&&(s=o.currObjType.isCustomCrop?"custom":l[1],o.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),o.objColl.push(o.activeObj),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.clearContext(this.lowerContext),o.clearContext(this.upperContext);var p=t.extend([],o.objColl,[],!0),h=t.extend({},o.activeObj,{},!0);o.objColl=[],o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.isReverseFlip||o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var c=i.toLowerCase();this.updateFlipState(c),o.transform.currFlipState="horizontal"===c?"horizontal"===o.transform.currFlipState.toLowerCase()?"":"horizontal":"vertical"===o.transform.currFlipState.toLowerCase()?"":"vertical";var d={isSelected:null};o.notify("draw",{prop:"getRotatedFlipCropSelection",onPropertyChange:!1,value:{bool:d}}),d.isSelected&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y);var v=this.lowerContext.filter;if(o.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=v,o.notify("draw",{prop:"setImageEdited",onPropertyChange:!1}),this.updateFlipState(i.toLowerCase()),this.isReverseFlip||(o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),this.updateFlipColl(i.toLocaleLowerCase()),o.rotateFlipColl.push(i.toLowerCase())),1===o.rotateFlipColl.length){var u={panRegion:""};o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:u}}),""===u.panRegion?o.notify("draw",{prop:"setClientTransDim",onPropertyChange:!1,value:{isPreventDimension:null}}):this.setDestPointsForFlipState()}o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.objColl=t.extend([],p,[],!0),o.activeObj=t.extend({},h,{},!0);for(var g=0,b=o.objColl.length;g<b;g++){var f=o.objColl[g].flipObjColl;0===f.length?f.push(i):f[f.length-1]===i?f.pop():f.push(i)}o.notify("shape",{prop:"redrawObj",onPropertyChange:!1,value:{degree:i.toLowerCase()}});var m=this.lowerContext.filter;this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),"horizontal"===i.toLowerCase()||"vertical"===i.toLowerCase()?(o.notify("freehand-draw",{prop:"flipFHDColl",onPropertyChange:!1,value:{value:i.toLowerCase()}}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}})):o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),this.lowerContext.filter=m,o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.updateCurrSelectionPoint(i.toLowerCase()),o.isUndoRedo=!1,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.upperContext}}),o.isCircleCrop&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),s&&(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}));var C={collection:o.rotateFlipColl};o.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:o.rotateFlipColl,isRotateFlipCollection:!0,obj:C}}),o.rotateFlipColl=C.collection,o.cropObj.activeObj.shape&&!this.isPreventSelect&&(this.isPreventSelect=!0,o.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),this.isPreventSelect=!1,o.setProperties({zoomSettings:{zoomFactor:1}},!0),this.prevZoomValue=o.zoomSettings.zoomFactor)}},o.prototype.updateFlipState=function(e){var t=this.parent.transform.degree;"horizontal"===e?t%90==0&&t%180!=0?this.verticalFlip():this.horizontalFlip():"vertical"===e&&(t%90==0&&t%180!=0?this.horizontalFlip():this.verticalFlip())},o.prototype.horizontalFlip=function(){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)},o.prototype.verticalFlip=function(){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)},o.prototype.updateFlipColl=function(e){if(!this.isPreventSelect&&(0===this.flipColl.length||this.flipColl[this.flipColl.length-1]!==e?this.flipColl.push(e):this.flipColl.pop(),this.flipColl.length>=4)){var t=this.flipColl.slice(-4);("horizontal"===t[0]&&"vertical"===t[1]&&"horizontal"===t[2]&&"vertical"===t[3]||"vertical"===t[0]&&"horizontal"===t[1]&&"vertical"===t[2]&&"horizontal"===t[3])&&this.flipColl.splice(-4)}},o.prototype.setDestPointsForFlipState=function(){var e=this.parent,t={panRegion:""};e.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:t}}),""!==t.panRegion&&("horizontal"===t.panRegion?e.img.destLeft=e.lowerCanvas.clientWidth-(e.img.destWidth+e.img.destLeft):"vertical"===t.panRegion?e.img.destTop=e.lowerCanvas.clientHeight-(e.img.destHeight+e.img.destTop):(e.img.destLeft=e.lowerCanvas.clientWidth-(e.img.destWidth+e.img.destLeft),e.img.destTop=e.lowerCanvas.clientHeight-(e.img.destHeight+e.img.destTop)))},o.prototype.zoomAction=function(e,i,o){var r=this,a=this.parent;if(!a.disabled&&a.isImageLoaded){if(t.isNullOrUndefined(o)&&(a.zoomSettings.zoomFactor>=a.zoomSettings.maxZoomFactor&&e>0||a.zoomSettings.zoomFactor>a.zoomSettings.minZoomFactor&&e<0&&this.disableZoomOutBtn(!0)||a.zoomSettings.zoomFactor<=a.zoomSettings.minZoomFactor&&e<0))return void(t.isBlazor()||a.notify("toolbar",{prop:"zoom-up-handler",onPropertyChange:!1}));a.notify("draw",{prop:"setImageEdited",onPropertyChange:!1});var n=e;e=n>0?.1:-.1;for(var s=0;s<Math.round(Math.abs(n/.1));s++)if(1===this.prevZoomValue)this.prevZoomValue+=e>0?10*e:10*e/10;else if(this.prevZoomValue>1)this.prevZoomValue+=10*e;else if(this.prevZoomValue<1){this.prevZoomValue+=10*e/10;var l=Math.pow(10,1);this.prevZoomValue=Math.round(this.prevZoomValue*l)/l}e=n,a.setProperties({zoomSettings:{zoomFactor:this.prevZoomValue}},!0);var p=void 0;this.tempActiveObj=null,this.isShape=!1,void 0!==a.activeObj.shape&&("shape"===a.activeObj.shape?a.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}):p=a.activeObj.shape.split("-")),void 0!==p&&"crop"===p[0]?(this.tempActiveObj=t.extend({},a.activeObj,{},!0),a.isCropTab=!0):a.activeObj.shape&&"crop"!==p[0]&&(this.isShape=!0);var h={zoomType:null};a.notify("selection",{prop:"getZoomType",onPropertyChange:!1,value:{obj:h}}),t.isNullOrUndefined(i)&&(i=a.isCropTab&&this.tempActiveObj?{x:a.activeObj.activePoint.startX+a.activeObj.activePoint.width/2,y:a.activeObj.activePoint.startY+a.activeObj.activePoint.height/2}:{x:a.lowerCanvas.clientWidth/2,y:a.lowerCanvas.clientHeight/2},"MouseWheel"!==h.zoomType&&"Pinch"!==h.zoomType||(i={x:a.zoomSettings.zoomPoint.x,y:a.zoomSettings.zoomPoint.y}));var c={zoomPoint:i,cancel:!1,previousZoomFactor:a.zoomSettings.zoomFactor-10*e,currentZoomFactor:a.zoomSettings.zoomFactor,zoomTrigger:h.zoomType};!a.isCropToolbar&&t.isBlazor()&&a.events&&!0===a.events.zooming.hasDelegate?a.dotNetRef.invokeMethodAsync("ZoomEventAsync","OnZoom",c).then(function(t){r.zoomEvent(t,e)}):(a.isCropToolbar||a.trigger("zooming",c),this.zoomEvent(c,e))}},o.prototype.zoomEvent=function(e,i){var o=this.parent;if(!e.cancel){t.isBlazor()?"resize-toolbar"!==o.currentToolbar&&o.element.querySelector(".e-contextual-toolbar-wrapper")&&!o.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hidden")&&o.updateToolbar(o.element,"closeContextualToolbar"):o.notify("toolbar",{prop:"close-contextual-toolbar",onPropertyChange:!1}),o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:!0}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height);var r={canvasFilter:this.parent.canvasFilter};this.lowerContext.filter=r.canvasFilter,o.upperCanvas.style.cursor=o.cursor="default";var a=t.extend([],o.objColl,[],!0);if(!o.isCropTab){if(0!==o.transform.degree){o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),o.panPoint.currentPannedPoint={x:0,y:0};var n=o.allowDownScale;o.allowDownScale=!1,this.rotatePan(!0,!0),o.allowDownScale=n}else""!==o.transform.currFlipState&&(o.panPoint.totalPannedPoint={x:0,y:0});o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}if(0===o.transform.degree){this.drawZoomImgToCanvas(i,this.tempActiveObj);var s={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:s}}),""!==s.panRegion){o.notify("crop",{prop:"setTempFlipPanPoint",onPropertyChange:!1,value:{point:o.panPoint.totalPannedPoint,isAdd:!0}}),a=t.extend([],o.objColl,[],!0),o.objColl=[];var l=o.img.destLeft,p=o.img.destTop;this.setDestPointsForFlipState(),this.rotatedFlip(),o.img.destLeft=l,o.img.destTop=p,o.objColl=a,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1})}o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&!o.isCropTab&&(o.panPoint.totalPannedPoint={x:0,y:0})}else{o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),o.panPoint.totalPannedClientPoint={x:0,y:0},o.panPoint.totalPannedInternalPoint={x:0,y:0},this.rotateZoom(i);var h={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:h}}),""!==h.panRegion){n=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n}}var c=Math.pow(10,1);(o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor||Math.round(o.transform.zoomFactor*c)/c==2)&&(clearInterval(this.zoomBtnHold),this.zoomBtnHold=0);var d={panRegion:""};if(o.notify("crop",{prop:"getCurrFlipState",onPropertyChange:!1,value:{panObj:d}}),""===d.panRegion){n=this.lowerContext.filter;this.lowerContext.filter="none",o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=n}(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.tempActiveObj&&(o.activeObj=t.extend({},this.tempActiveObj,{},!0),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj}}),o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor&&(o.currSelectionPoint=null)),o.isUndoRedo=!1;var v;t.isBlazor()?(v=o.element.querySelector("#zoomout"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?v.classList.add("e-overlay"):v&&v.classList.remove("e-overlay"):(v=document.querySelector("#"+o.element.id+"_zoomOut"))&&o.zoomSettings.zoomFactor<=o.zoomSettings.minZoomFactor?(v.classList.add("e-disabled"),v.parentElement.classList.add("e-overlay")):v&&(v.classList.remove("e-disabled"),v.parentElement.classList.remove("e-overlay")),this.autoEnablePan(),this.tempActiveObj&&(o.activeObj=t.extend({},this.tempActiveObj,{},!0)),"crop-custom"===o.activeObj.shape&&(o.currObjType.isCustomCrop=!0);var u=o.element.querySelector(".e-img-pan .e-btn");u&&o.togglePan?u.classList.add("e-selected-btn"):u&&u.classList.remove("e-selected-btn"),this.isShape&&(o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),t.isBlazor()||(o.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1}),o.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))),t.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}),o.notify("selection",{prop:"setZoomType",onPropertyChange:!1,value:{zoomType:"Toolbar"}})}},o.prototype.disableZoomOutBtn=function(e){var i,o=this.parent,r=!1;t.isNullOrUndefined(e)||(o.transform.zoomFactor-=.1),i=t.isBlazor()?this.parent.element.querySelector("#zoomout"):document.querySelector("#"+o.element.id+"_zoomOut");var a=o.img.destLeft,n=o.img.destTop,s=o.img.destWidth,l=o.img.destHeight;return o.activeObj.shape?(this.setZoomDimension(-.1,o.activeObj),t.isNullOrUndefined(i)||(o.img.destLeft>o.activeObj.activePoint.startX||o.img.destTop>o.activeObj.activePoint.startY||o.img.destLeft+o.img.destWidth<o.activeObj.activePoint.endX||o.img.destTop+o.img.destHeight<o.activeObj.activePoint.endY||o.zoomSettings.zoomFactor===o.zoomSettings.minZoomFactor?(t.isBlazor()?i.classList.add("e-overlay"):(i.classList.add("e-disabled"),i.parentElement.classList.add("e-overlay")),r=!0):(t.isBlazor()?i.classList.remove("e-overlay"):(i.classList.remove("e-disabled"),i.parentElement.classList.remove("e-overlay")),r=!1))):this.setZoomDimension(-.1,null),t.isNullOrUndefined(e)||(o.transform.zoomFactor+=.1),o.img.destLeft=a,o.img.destTop=n,o.img.destWidth=s,o.img.destHeight=l,r},o.prototype.drawZoomImgToCanvas=function(e,t){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===e?i.transform.zoomFactor=0:i.transform.zoomFactor+=e,i.transform[i.isCropTab?"cropZoomFactor":"defaultZoomFactor"]=i.transform.zoomFactor;var r={width:0,height:0};i.isCropTab?r=this.cropZoom(e,t):((r=this.calcMaxDimension(i.img.srcWidth,i.img.srcHeight)).width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.img.destLeft=(i.lowerCanvas.clientWidth-r.width)/2,i.img.destTop=(i.lowerCanvas.clientHeight-r.height)/2),i.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:r}}),r.width=this.cropDimension.width,r.height=this.cropDimension.height,r.width+=r.width*i.transform.zoomFactor,r.height+=r.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:r.width,height:r.height}})},o.prototype.rotatedFlip=function(){var e=this.parent;this.isReverseFlip=!0;var i=e.transform.currFlipState,o=this.flipColl,r=t.extend([],e.objColl,[],!0),a=t.extend({},e.activeObj,{},!0);this.flipColl=[],e.objColl=[],e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,context:null,isPreventCircleCrop:null}});var n=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,e.notify("draw",{prop:"currTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,context:null,isPreventCircleCrop:null}}),""===i&&""!==e.transform.currFlipState&&(i=e.transform.currFlipState),e.transform.currFlipState=i,this.flipColl=o,e.objColl=t.extend([],r,[],!0),this.lowerContext.filter="none",e.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=n,0!==a.activePoint.width&&(e.activeObj=t.extend({},a,{},!0)),this.isReverseFlip=!1},o.prototype.rotateZoom=function(e){var i=this.parent,o=Math.pow(10,1);Math.round(i.transform.zoomFactor*o)/o==.1&&-.1===e?i.transform.zoomFactor=0:i.transform.zoomFactor+=e,i.isCropTab?i.transform.cropZoomFactor=i.transform.zoomFactor:i.transform.defaultZoomFactor=i.transform.zoomFactor;var r=t.extend([],i.objColl,[],!0),a=t.extend({},i.activeObj,{},!0);i.objColl=[],i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),i.notify("draw",{prop:"setDestPoints",onPropertyChange:!1});var n=this.lowerContext.filter;i.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=n,i.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),i.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),i.objColl=r,i.activeObj=a;var s={width:this.cropDimension.width,height:this.cropDimension.height};s.width+=s.width*i.transform.zoomFactor,s.height+=s.height*i.transform.zoomFactor,i.notify("draw",{prop:"setZoomCropWidth",value:{width:s.width,height:s.height}})},o.prototype.autoEnablePan=function(){this.parent.transform.zoomFactor<=0?(this.parent.togglePan=!1,this.parent.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),this.parent.pan(!1),this.disablePan=!1):this.parent.pan(!this.disablePan)},o.prototype.cropZoom=function(e,i){var o=this.parent,r=o.img.destLeft,a=o.img.destTop,n={width:0,height:0};return 0===o.img.srcLeft||0===o.img.srcTop?n=t.isNullOrUndefined(i)?this.setZoomDimension(e,null):this.setZoomDimension(e,i):((n=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight)).width+=n.width*o.transform.zoomFactor,n.height+=n.height*o.transform.zoomFactor),o.img.destLeft=r-(n.width-o.img.destWidth)/2,o.img.destTop=a-(n.height-o.img.destHeight)/2,r=o.img.destLeft,a=o.img.destTop,i&&(o.img.destLeft>i.activePoint.startX&&(o.img.destLeft=i.activePoint.startX,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop>i.activePoint.startY&&(o.img.destTop=i.activePoint.startY,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop)),o.img.destLeft+n.width<i.activePoint.endX&&(o.img.destLeft=i.activePoint.endX-n.width,0===o.transform.degree&&(o.panPoint.totalPannedPoint.x-=r-o.img.destLeft)),o.img.destTop+n.height<i.activePoint.endY&&(o.img.destTop=i.activePoint.endY-n.height,0===o.transform.degree&&(o.panPoint.totalPannedPoint.y-=a-o.img.destTop))),n},o.prototype.setZoomDimension=function(e,i){var o=this.parent,r={width:0,height:0};if(r=o.transform.degree%90==0&&o.transform.degree%180!=0?this.calcMaxDimension(o.img.srcHeight,o.img.srcWidth):this.calcMaxDimension(o.img.srcWidth,o.img.srcHeight),r.width+=r.width*o.transform.zoomFactor,r.height+=r.height*o.transform.zoomFactor,o.img.destLeft+=(o.img.destWidth-r.width)/2,o.img.destTop+=(o.img.destHeight-r.height)/2,e<0&&i){var a=i.activePoint.startX,n=i.activePoint.startY,s=i.activePoint.width,l=i.activePoint.height,p=o.img.destLeft+r.width,h=o.img.destTop+r.height;o.img.destLeft>a&&(o.img.destLeft=a),o.img.destTop>n&&(o.img.destTop=n),p<a+s&&(o.img.destLeft=a+s-r.width),h<n+l&&(o.img.destTop=n+l-r.height)}else e<0&&t.isNullOrUndefined(i)&&(o.img.destLeft>0&&(o.img.destLeft=0),o.img.destTop>0&&(o.img.destTop=0),o.img.destLeft+r.width<o.lowerCanvas.width&&(o.img.destLeft=o.lowerCanvas.width-o.img.destWidth),o.img.destTop+r.height<o.lowerCanvas.height&&(o.img.destTop=o.lowerCanvas.height-o.img.destHeight));return r},o.prototype.drawPannedImage=function(e,i){var o=this,r=this.parent,a={panDown:null};r.notify("selection",{prop:"getPanDown",onPropertyChange:!1,value:{obj:a}});var n={startPoint:a.panDown,endPoint:this.panMove,cancel:!1};t.isBlazor()&&t.isNullOrUndefined(this.parent.eventType)&&r.events&&!0===r.events.onPanStart.hasDelegate?(this.parent.eventType="pan",this.parent.panEventArgs=n,r.dotNetRef.invokeMethodAsync("PanEventAsync","OnPanStart",n).then(function(t){o.panEvent(t,e,i)})):(r.trigger("panning",n),this.panEvent(n,e,i))},o.prototype.panEvent=function(e,i,o){if(!e.cancel){var r=this.parent,a=!1;if(r.activeObj.shape&&"shape"===r.activeObj.shape&&r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isNullOrUndefined(r.activeObj.shape)){a=!0,r.activeObj.activePoint={startX:r.img.destLeft,startY:r.img.destTop,endX:r.img.destLeft+r.img.destWidth,endY:r.img.destTop+r.img.destHeight};var n=r.activeObj.activePoint.startX,s=r.activeObj.activePoint.startY,l=r.activeObj.activePoint.endX,p=r.activeObj.activePoint.endY;n<0&&(r.activeObj.activePoint.startX=0),s<0&&(r.activeObj.activePoint.startY=0),l>r.lowerCanvas.width&&(r.activeObj.activePoint.endX=r.lowerCanvas.width),p>r.lowerCanvas.height&&(r.activeObj.activePoint.endY=r.lowerCanvas.height),r.activeObj.activePoint.width=r.activeObj.activePoint.endX-r.activeObj.activePoint.startX,r.activeObj.activePoint.height=r.activeObj.activePoint.endY-r.activeObj.activePoint.startY,r.activeObj.shape="crop-custom";var h={strokeSettings:{}};r.notify("shape",{prop:"getStrokeSettings",onPropertyChange:!1,value:{obj:h}}),r.activeObj.strokeSettings=h.strokeSettings,r.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:r.activeObj.activePoint,obj:r.activeObj,isMouseMove:null,x:null,y:null}}),r.isCropTab=!0}if(0===r.transform.degree){var c=void 0;c=t.isNullOrUndefined(i)&&t.isNullOrUndefined(o)?this.updatePanPoints(""):{x:i,y:o},r.panPoint.totalPannedPoint.x+=c.x,r.panPoint.totalPannedPoint.y+=c.y;var d=t.extend({},r.activeObj,{},!0),v=this.lowerContext.filter;this.drawPannImage(c),this.lowerContext.filter=v,this.tempPanMove=t.extend({},this.panMove,{},!0),r.activeObj=t.extend({},d,{},!0),this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height),r.activeObj.shape&&r.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:r.activeObj}})}else{var u=r.transform.currFlipState;r.isCropTab=!0,t.isNullOrUndefined(i)&&t.isNullOrUndefined(o)?r.panPoint.currentPannedPoint=this.updatePanPoints(""):r.panPoint.currentPannedPoint={x:i,y:o},r.transform.currFlipState=u,this.rotatePan(),r.isCropTab=!1,this.tempPanMove=t.extend({},this.panMove,{},!0)}a&&(r.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),r.isCropTab=!1,this.upperContext.clearRect(0,0,r.upperCanvas.width,r.upperCanvas.height))}},o.prototype.drawPannImage=function(e){var t=this.parent,i=this.lowerContext.filter,o={startX:t.img.destLeft,startY:t.img.destTop,width:t.img.destWidth,height:t.img.destHeight};this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}}),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height,this.setDestPointsForFlipState(),t.notify("draw",{prop:"drawImage",onPropertyChange:!1}),(t.currSelectionPoint&&"crop-circle"===t.currSelectionPoint.shape||t.isCircleCrop)&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}}),this.lowerContext.filter=i,t.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}}),t.img.destLeft=o.startX,t.img.destTop=o.startY,t.img.destWidth=o.width,t.img.destHeight=o.height;var r=this.lowerContext.filter;this.lowerContext.filter="none",t.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:e.x,yDiff:e.y,panRegion:""}}),t.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:e.x,yDiff:e.y,panRegion:""}}),this.lowerContext.filter=r,t.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),t.isCircleCrop&&t.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:!0}})},o.prototype.resetZoom=function(){var e=this.parent;if(0!==e.transform.defaultZoomFactor){var i=e.isUndoRedo,o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),this.transCurrObj=o.currObj,this.transCurrObj.objColl=t.extend([],e.objColl,null,!0),this.transCurrObj.pointColl=t.extend({},e.pointColl,null,!0),this.transCurrObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var r={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:r}}),this.transCurrObj.selPointColl=t.extend([],r.selPointColl,[],!0),e.isUndoRedo=e.isCropToolbar=!0,e.transform.defaultZoomFactor>0?this.zoomAction(-e.transform.defaultZoomFactor):this.zoomAction(Math.abs(e.transform.defaultZoomFactor)),e.isCropToolbar=!1,e.isUndoRedo=i}},o.prototype.performTransformation=function(e){var i=this.parent,o=i.transform.defaultZoomFactor,r=i.isUndoRedo,a=t.extend({},i.cropObj,{},!0);this.resetZoom(),this.updateTransform(e);for(var n=0,s=i.objColl.length;n<s;n++)if(i.objColl[n].flipObjColl.length>0){var l={collection:i.objColl[n].flipObjColl};i.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:i.objColl[n].flipObjColl,isRotateFlipCollection:null,obj:l}}),i.objColl[n].flipObjColl=l.collection,0===i.objColl[n].flipObjColl.length&&(i.objColl[n].shapeFlip="")}if(0!==o){i.isUndoRedo=!0,this.zoomAction(o),i.isUndoRedo=r;var p="";"rotateleft"===e||"rotateright"===e?p="rotate":"horizontalflip"!==e&&"verticalflip"!==e||(p="flip"),i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:p,previousObj:this.transCurrObj,previousObjColl:this.transCurrObj.objColl,previousPointColl:this.transCurrObj.pointColl,previousSelPointColl:this.transCurrObj.selPointColl,previousCropObj:a,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.transCurrObj=null}},o.prototype.updateTransform=function(t){switch(t.toLowerCase()){case"rotateleft":this.rotateImage(-90);break;case"rotateright":this.rotateImage(90);break;case"horizontalflip":this.flipImage(e.Direction.Horizontal);break;case"verticalflip":this.flipImage(e.Direction.Vertical)}},o.prototype.rotatePan=function(e,i){var o=this.parent;this.isReverseRotate=!0;var r,a=o.transform.degree,n={selPointColl:null};o.activeObj.activePoint&&o.activeObj.shape&&(r=t.extend({},o.activeObj,{},!0));var s=t.extend([],o.objColl,[],!0),l=t.extend([],o.pointColl,[],!0);o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}});var p=n.selPointColl;o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!0}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var h=o.img.destLeft,c=o.img.destTop;o.isCropTab&&(o.img.destLeft+=o.panPoint.totalPannedInternalPoint.x,o.img.destTop+=o.panPoint.totalPannedInternalPoint.y),o.notify("crop",{prop:"updateRotatePan",onPropertyChange:!1}),o.isCropTab&&(o.panPoint.totalPannedInternalPoint.x=o.img.destLeft-h,o.panPoint.totalPannedInternalPoint.y=o.img.destTop-c);var d=this.lowerContext.filter;o.notify("draw",{prop:"drawImage",onPropertyChange:!1}),o.notify("draw",{prop:"setRotateZoom",onPropertyChange:!1,value:{isRotateZoom:!1}}),o.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:!0,isRotatePan:!0}});var v=o.img.destLeft,u=o.img.destTop;o.img.destLeft+=o.panPoint.totalPannedClientPoint.x,o.img.destTop+=o.panPoint.totalPannedClientPoint.y,o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y,o.panPoint.totalPannedClientPoint.x=o.img.destLeft-v,o.panPoint.totalPannedClientPoint.y=o.img.destTop-u,o.objColl=s,o.pointColl=l,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:p}}}),o.transform.degree=a,this.lowerContext.filter="none",e&&(i?(o.panPoint.totalPannedClientPoint.x=-o.panPoint.totalPannedClientPoint.x,o.panPoint.totalPannedClientPoint.y=-o.panPoint.totalPannedClientPoint.y,o.panPoint.currentPannedPoint=t.extend({},o.panPoint.totalPannedClientPoint,{},!0),o.panPoint.totalPannedClientPoint={x:0,y:0},o.img.destLeft+=o.panPoint.currentPannedPoint.x,o.img.destTop+=o.panPoint.currentPannedPoint.y):o.panPoint.currentPannedPoint=t.extend({},o.panPoint.totalPannedClientPoint,{},!0)),o.notify("shape",{prop:"panObjColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),o.notify("freehand-draw",{prop:"panFHDColl",onPropertyChange:!1,value:{xDiff:o.panPoint.currentPannedPoint.x,yDiff:o.panPoint.currentPannedPoint.y,panRegion:""}}),this.lowerContext.filter=d,o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.activeObj=t.extend({},r,{},!0),o.activeObj.activePoint&&o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0,saveContext:null,isPreventSelection:null}}),this.isReverseRotate=!1},o.prototype.limitPan=function(){var e=this.parent;e.activeObj.activePoint&&(e.img.destLeft>e.activeObj.activePoint.startX&&(e.img.destLeft=e.activeObj.activePoint.startX),e.img.destTop>e.activeObj.activePoint.startY&&(e.img.destTop=e.activeObj.activePoint.startY),e.img.destLeft+e.img.destWidth<e.activeObj.activePoint.endX&&(e.img.destLeft=e.activeObj.activePoint.endX-e.img.destWidth),e.img.destTop+e.img.destHeight<e.activeObj.activePoint.endY&&(e.img.destTop=e.activeObj.activePoint.endY-e.img.destHeight))},o.prototype.updateFlipActiveObj=function(e){var t=this.parent;"horizontal"===e?(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?t.activeObj.activePoint.endX=t.lowerCanvas.width/2-(t.activeObj.activePoint.startX-t.lowerCanvas.width/2):t.activeObj.activePoint.endX=t.lowerCanvas.width/2+(t.lowerCanvas.width/2-t.activeObj.activePoint.startX),t.activeObj.activePoint.startX=t.activeObj.activePoint.endX-t.activeObj.activePoint.width):"vertical"===e?(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?t.activeObj.activePoint.endY=t.lowerCanvas.height/2-(t.activeObj.activePoint.startY-t.lowerCanvas.height/2):t.activeObj.activePoint.endY=t.lowerCanvas.height/2+(t.lowerCanvas.height/2-t.activeObj.activePoint.startY),t.activeObj.activePoint.startY=t.activeObj.activePoint.endY-t.activeObj.activePoint.height):"verticalHorizontal"!==e&&"horizontalVertical"!==e||(t.activeObj.activePoint.startX>t.lowerCanvas.width/2?(t.activeObj.activePoint.endX=t.lowerCanvas.width/2-(t.activeObj.activePoint.startX-t.lowerCanvas.width/2),t.activeObj.activePoint.endY=t.lowerCanvas.height/2-(t.activeObj.activePoint.startY-t.lowerCanvas.height/2)):(t.activeObj.activePoint.endX=t.lowerCanvas.width/2+(t.lowerCanvas.width/2-t.activeObj.activePoint.startX),t.activeObj.activePoint.endY=t.lowerCanvas.height/2+(t.lowerCanvas.height/2-t.activeObj.activePoint.startY)),t.activeObj.activePoint.startX=t.activeObj.activePoint.endX-t.activeObj.activePoint.width,t.activeObj.activePoint.startY=t.activeObj.activePoint.endY-t.activeObj.activePoint.height),t.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:t.activeObj.activePoint,obj:t.activeObj,isMouseMove:null,x:null,y:null}})},o.prototype.pan=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&(e?(t.togglePan=!0,t.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="grab",t.notify("selection",{prop:"setPanDown",onPropertyChange:!1,value:{panDown:null}})):(t.togglePan=t.currObjType.isCustomCrop=!1,t.notify("selection",{prop:"setDragCanvas",value:{bool:!1}}),t.lowerCanvas.style.cursor=t.upperCanvas.style.cursor=t.cursor="default"))},o.prototype.zoom=function(e,i){var o=this.parent;if(!o.disabled&&o.isImageLoaded){var r=this.getCurrentZoomFactor(e);if(t.isNullOrUndefined(i))this.zoomAction(r,i);else for(var a=r>0?"zoomIn":"zoomOut",n=0;n<10*Math.abs(r);n++)o.notify("draw",{prop:"performPointZoom",onPropertyChange:!1,value:{x:i.x,y:i.y,type:a}})}},o.prototype.getCurrentZoomFactor=function(e){return.1*(e-this.prevZoomValue)},o.prototype.setCurrPanRegion=function(e,t,i){var o=e;""===e?"horizontal"===t?o="horizontal":"vertical"===t&&(o="vertical"):"horizontal"===e?"horizontal"===t?o="horizontalVertical":"vertical"===t?o="verticalHorizontal":90===t?o="vertical":-90===t&&(o="horizontal"):"vertical"===e?"horizontal"===t?o="horizontalVertical":"vertical"===t?o="verticalHorizontal":90===t?o="horizontal":-90===t&&(o="vertical"):"horizontal"===t?o="vertical":"vertical"===t&&(o="horizontal"),i.panRegion=o},o.prototype.rotate=function(e,t){var i=this.parent;!i.disabled&&i.isImageLoaded&&e%90==0&&this.rotateImage(e),t.isRotate=!1},o.prototype.flip=function(e){var t=this.parent;!t.disabled&&t.isImageLoaded&&this.flipImage(e)},o.prototype.update=function(){var e=this.parent,o=0,r=!1,a=!1,n={bool:!1};if(e.isImageLoaded){var s={bool:null};e.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:s}}),(s.bool||t.isBlazor()&&"frame-toolbar"==e.currentToolbar)&&(r=!0),(e.element.querySelector("#"+e.element.id+"_contextualToolbar")&&!e.element.querySelector("#"+e.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||e.element.querySelector("#"+e.element.id+"_headWrapper")&&!e.element.querySelector("#"+e.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.okBtn(),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):(e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}))),e.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:n}}),n.bool&&(t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})),void 0!==e.activeObj.shape&&(a=!0,"block"===e.textArea.style.display?(e.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.isBlazor()?e.updateToolbar(e.element,"destroyQuickAccessToolbar"):e.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1})):(e.notify("shape",{prop:"updImgRatioForActObj",onPropertyChange:!1}),e.objColl.push(e.activeObj)),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}))}var l=this.lowerContext.filter,p=document.querySelector("#"+e.element.id+"_canvasWrapper");if(p&&(p.style.width=e.element.offsetWidth-2+"px"),e.lowerCanvas.width=e.upperCanvas.width=e.element.offsetWidth-2,e.toolbarTemplate?o=e.element.querySelector("#"+e.element.id+"_toolbarArea").clientHeight:e.element.querySelector("#"+e.element.id+"_toolbar")&&(o=e.element.querySelector("#"+e.element.id+"_toolbar").clientHeight),e.notify("toolbar",{prop:"setToolbarHeight",value:{height:o}}),t.Browser.isDevice?(p&&(p.style.height=e.element.offsetHeight-2*o-5+"px"),e.lowerCanvas.height=e.upperCanvas.height=e.element.offsetHeight-2*o-5):(p&&(p.style.height=e.element.offsetHeight-o-3+"px"),e.lowerCanvas.height=e.upperCanvas.height=e.element.offsetHeight-o-3),this.lowerContext.filter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",e.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),e.canvasFilter=this.lowerContext.filter,this.parent.initialAdjustmentValue=this.lowerContext.filter,e.clearContext(this.lowerContext),this.parent.clearContext(this.upperContext),e.isImageLoaded){if(e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.lowerContext.filter=l,e.initialAdjustmentValue=l,e.canvasFilter=this.lowerContext.filter,e.isImageLoaded&&(i.showSpinner(e.element),e.element.style.opacity="0.5"),this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),p){p.style.width=e.element.offsetWidth-2+"px",p.style.height=e.element.offsetHeight+"px";var h={toolbarHeight:t.isBlazor()?e.toolbarHeight:0};t.isBlazor()||e.notify("toolbar",{prop:"getToolbarHeight",value:{obj:h}}),t.Browser.isDevice?p.style.height=parseFloat(p.style.height)-2*h.toolbarHeight-3+"px":p.style.height=parseFloat(p.style.height)-h.toolbarHeight-3+"px"}var c={width:0,height:0};this.calcMaxDimension(e.img.srcWidth,e.img.srcHeight,c);var d=c;if(e.transform.defaultZoomFactor>0&&(d.width+=d.width*e.transform.defaultZoomFactor,d.height+=d.height*e.transform.defaultZoomFactor),e.img.destLeft=(e.lowerCanvas.clientWidth-d.width)/2,e.img.destTop=(e.lowerCanvas.clientHeight-d.height)/2,0===e.transform.degree&&""===e.transform.currFlipState)e.transform.defaultZoomFactor>0&&(e.img.destLeft+=e.panPoint.totalPannedPoint.x,e.img.destTop+=e.panPoint.totalPannedPoint.y),e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:d}});else{e.notify("draw",{prop:"draw-image-to-canvas",value:{dimension:d}}),e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"initial",isPreventDestination:null,isRotatePan:null}});var v=this.lowerContext.filter;e.notify("draw",{prop:"drawImage",onPropertyChange:!1}),this.lowerContext.filter=v,e.notify("draw",{prop:"updateCurrTransState",onPropertyChange:!1,value:{type:"reverse",isPreventDestination:null,isRotatePan:null}})}e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.isCircleCrop&&e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),i.hideSpinner(e.element),e.element.style.opacity="1";var u={defToolbarItems:null};if(!t.isBlazor()&&(e.notify("toolbar",{prop:"getDefToolbarItems",value:{obj:u}}),u.defToolbarItems&&u.defToolbarItems.length>0&&document.getElementById(e.element.id+"_toolbar"))){t.getComponent(e.element.id+"_toolbar","toolbar").refreshOverflow(),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")}if(e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),a){var g=t.extend({},e.objColl[e.objColl.length-1],null,!0);e.objColl.pop(),0!==g.activePoint.width&&0!==g.activePoint.height&&(this.lowerContext.clearRect(0,0,e.lowerCanvas.width,e.lowerCanvas.height),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:g}}),"rectangle"!==e.activeObj.shape&&"ellipse"!==e.activeObj.shape&&"text"!==e.activeObj.shape&&"line"!==e.activeObj.shape&&"arrow"!==e.activeObj.shape&&"path"!==e.activeObj.shape&&"image"!==e.activeObj.shape||(t.isBlazor()?e.updateToolbar(e.element,"quickAccessToolbar",e.activeObj.shape):e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}})))}if(n.bool&&(t.isBlazor()?e.updateToolbar(e.element,"quickAccessToolbar","pen"):e.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}})),r?t.isBlazor()?e.updateToolbar(e.element,"frame"):e.notify("toolbar",{prop:"callFrameToolbar",onPropertyChange:!1}):e.isResize&&(e.aspectWidth=Math.ceil(e.img.destWidth),e.aspectHeight=Math.ceil(e.img.destHeight),t.isBlazor()?e.updateToolbar(e.element,"resize"):(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}))),(0!==e.transform.degree||""!==e.transform.currFlipState)&&e.transform.defaultZoomFactor>0){var b=t.extend({},e.panPoint.totalPannedPoint,null,!0),f=t.extend({},e.panPoint.totalPannedInternalPoint,null,!0),m=t.extend({},e.panPoint.totalPannedClientPoint,null,!0);this.zoomAction(.1),this.zoomAction(-.1),0===e.transform.degree?(e.img.destLeft+=b.x,e.img.destTop+=b.y,e.panPoint.totalPannedPoint=b,e.notify("draw",{prop:"updateFlipPan",value:{tempSelectionObj:null}})):(e.panPoint.totalPannedInternalPoint=f,e.panPoint.totalPannedClientPoint=m,e.panPoint.currentPannedPoint={x:0,y:0},e.isCropTab=!0,this.rotatePan(),e.isCropTab=!1)}else 0!==e.transform.degree&&e.transform.cropZoomFactor>0&&(e.transform.zoomFactor=0,e.transform.cropZoomFactor=null,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):e.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1}))}},o.prototype.calcMaxDimension=function(e,i,o,r){var a={toolbarHeight:0};t.isBlazor()?a.toolbarHeight=this.parent.toolbarHeight:this.parent.notify("toolbar",{prop:"getToolbarHeight",value:{obj:a}});var n=r?this.parent.element.clientWidth/3:this.parent.element.clientWidth,s=r?(this.parent.element.clientHeight-a.toolbarHeight)/3:this.parent.element.clientHeight-a.toolbarHeight;s=t.Browser.isDevice?s-a.toolbarHeight:s,t.isNullOrUndefined(r)&&(n>30&&(n-=30),s>30&&(s-=30));var l=n/e,p=s/i,h=Math.min(e,n),c=Math.min(i,s);if(l<1&&l<p?(h=e*l,c=i*l):p<1&&p<l&&(h=e*p,c=i*p),t.isNullOrUndefined(r)){var d={bool:null};this.parent.notify("crop",{prop:"getPreventScaling",onPropertyChange:!1,value:{obj:d}}),d.bool&&this.parent.cropObj.activeObj.activePoint&&0!==this.parent.cropObj.activeObj.activePoint.width&&0!==this.parent.cropObj.activeObj.activePoint.height&&(h=this.parent.cropObj.activeObj.activePoint.width,c=this.parent.cropObj.activeObj.activePoint.height)}return o&&(o.width=h,o.height=c),{width:h,height:c}},o.prototype.updatePanPoints=function(e,i){var o=this.parent,r=t.extend({},o.activeObj,{},!0),a=o.img.destLeft,n=o.img.destTop;t.isNullOrUndefined(this.tempPanMove)&&(this.tempPanMove={x:this.panMove.x,y:this.panMove.y});var s=this.panMove.x-this.tempPanMove.x,l=this.panMove.y-this.tempPanMove.y;switch(e){case"":o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontal":this.updateFlipActiveObj(e),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop+=l;break;case"vertical":this.updateFlipActiveObj(e),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft+=s,o.img.destTop+=l;break;case"horizontalVertical":this.updateFlipActiveObj(e),s=this.tempPanMove.x-this.panMove.x,o.img.destLeft+=s,o.img.destTop-=l;break;case"verticalHorizontal":this.updateFlipActiveObj(e),l=this.tempPanMove.y-this.panMove.y,o.img.destLeft-=s,o.img.destTop+=l}return this.limitPan(),o.activeObj=r,i&&(i.x=o.img.destLeft-a,i.y=o.img.destTop-n),{x:o.img.destLeft-a,y:o.img.destTop-n}},o.prototype.resizeImage=function(e,i){var o=this.parent,r=!0,a=!0;o.allowDownScale=!1,o.img.srcLeft=0,o.img.srcTop=0,o.isAspectRatio=!0;var n=[];for(o.img.srcWidth=o.baseImg.width,o.img.srcHeight=o.baseImg.height,o.resizeSrc&&0!=o.resizeSrc.width&&0!=o.resizeSrc.height&&(o.img.srcLeft=o.resizeSrc.startX,o.img.srcTop=o.resizeSrc.startY,o.img.srcWidth=o.resizeSrc.width,o.img.srcHeight=o.resizeSrc.height);(e<o.img.destWidth||i<o.img.destHeight)&&a;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),a=!1,n.push(o.img.destWidth);for(;(e>o.img.destWidth||i>o.img.destHeight)&&a&&r;)if(this.zoomAction(.1,null,!0),e<o.img.destWidth||i<o.img.destHeight)for(;e<o.img.destWidth;)this.zoomAction(-.0125,null,!0),r=!1,n.push(o.img.destWidth);for(var s=n[0],l=Math.abs(o.img.destWidth-s),p=0,h=n;p<h.length;p++){var c=h[p],d=Math.abs(e-c);d<l&&(s=c,l=d)}s<e&&r&&(this.zoomAction(-.0125,null,!0),r=!1),s>e&&!r&&(this.zoomAction(.0125,null,!0),r=!1),this.zoomAction(.0125,null,!0),o.allowDownScale=!0,this.zoomAction(-.0125,null,!0);var v=t.extend({},o.cropObj,{},!0),u=t.extend({},this.prevResizeCurrObj,{},!0);o.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:u,previousObjColl:u.objColl,previousPointColl:u.pointColl,previousSelPointColl:u.selPointColl,previousCropObj:v,previousText:null,currentText:null,previousFilter:null,isCircleCrop:o.isCircleCrop}}),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},o.prototype.resizeCrop=function(e,i){var o=this.parent,r=!0,a={prevObj:o.prevObj};o.cropObj=t.extend({},o.prevCropObj,{},!0),o.allowDownScale=!1,o.notify("toolbar",{prop:"getPrevObj",onPropertyChange:!1,value:{obj:a}});var n=t.extend({},a.prevObj.activeObj,{},!0);a.prevObj.activeObj=t.extend({},o.activeObj,{},!0),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a.prevObj}}),o.objColl=t.extend([],a.prevObj.objColl,[],!0),o.pointColl=t.extend([],a.prevObj.pointColl,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var s=e,l=i,p=!1;if(i>=e&&i<=Math.ceil(o.img.destHeight)){for(;i<=Math.ceil(o.img.destHeight)&&r;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),r=!1}else if(i<=e&&e<o.img.destWidth){for(;e<o.img.destWidth&&r;)if(this.zoomAction(-.1,null,!0),e>o.img.destWidth||i>o.img.destHeight)for(;e>o.img.destWidth||i>o.img.destHeight;)this.zoomAction(.0125,null,!0),r=!1}else if(i>=e&&i>=o.img.destHeight)for(;i>=o.img.destHeight&&r;)this.zoomAction(.1,null,!0);else if(e>=i&&e>=o.img.destWidth){for(;e>=o.img.destWidth&&r;)this.zoomAction(.1,null,!0);if(e<o.img.destWidth&&i<o.img.destHeight){for(;e<o.img.destWidth&&i<o.img.destHeight;)this.zoomAction(-.0125,null,!0),r=!1;this.zoomAction(.0125,null,!0)}}else if(i>o.img.destHeight&&e>o.img.destWidth){for(;i>o.img.destHeight&&e>o.img.destWidth&&r;)this.zoomAction(.1,null,!0);if(e<o.img.destWidth&&i<o.img.destHeight){for(;e<o.img.destWidth&&i<o.img.destHeight;)this.zoomAction(-.0125,null,!0),r=!1;this.zoomAction(.0125,null,!0)}}if(this.resizeImg(n,e,i),e=s,(i=l)!==o.img.destHeight||e!==o.img.destWidth){for(;i>o.img.destHeight||e>o.img.destWidth;)this.zoomAction(.0125,null,!0),p=!0;p&&(this.zoomAction(-.0125,null,!0),p=!1)}if(i!==o.img.destHeight||e!==o.img.destWidth){for(;i<o.img.destHeight||e<o.img.destWidth;)this.zoomAction(-.0125,null,!0),p=!0;p&&(this.zoomAction(-.0125,null,!0),p=!1)}a.prevObj.activeObj=t.extend({},n,{},!0),this.zoomAction(.0125,null,!0),o.allowDownScale=!this.preventDownScale,o.isCropTab=!1,this.zoomAction(-.0125,null,!0),o.aspectWidth=e,o.aspectHeight=i},o.prototype.resizeImg=function(e,i,o){var r=this.parent,a=i/r.img.destWidth,n=o/r.img.destHeight;e.shape?r.currSelectionPoint=e:r.img.srcWidth===r.baseImgCanvas.width&&r.img.srcHeight===r.baseImgCanvas.height&&(r.currSelectionPoint=null,r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}})),t.isNullOrUndefined(r.currSelectionPoint)?r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:r.img.destLeft,startY:r.img.destTop,width:r.img.destWidth,height:r.img.destHeight}}):r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),i=r.activeObj.activePoint.width*a,o=r.activeObj.activePoint.height*n;var s=r.activeObj.activePoint.startX+r.activeObj.activePoint.width/2-i/2,l=r.activeObj.activePoint.startY+r.activeObj.activePoint.height/2-o/2;r.transform.defaultZoomFactor=0,r.notify("draw",{prop:"setResizeSelect",value:{bool:!0}}),r.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:s,startY:l,width:i,height:o}}),r.notify("draw",{prop:"setResizeSelect",value:{bool:!1}}),r.isCropToolbar=!0,r.crop(),r.isCropToolbar=!1},o.prototype.updateResize=function(){var e=this.parent;e.prevCropObj=t.extend({},e.cropObj,{},!0);var i={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:i}}),e.prevObj=i.currObj,e.currSelectionPoint&&e.prevCropObj.activeObj.shape&&(e.prevObj.activeObj=t.extend({},e.prevCropObj.activeObj,{},!0)),e.prevObj.objColl=t.extend([],e.objColl,[],!0),e.prevObj.pointColl=t.extend([],e.pointColl,[],!0),e.prevObj.afterCropActions=t.extend([],e.afterCropActions,[],!0);var o={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),e.prevObj.selPointColl=t.extend([],o.selPointColl,[],!0),e.resizeSrc={startX:e.img.srcLeft,startY:e.img.srcTop,width:e.img.srcWidth,height:e.img.srcHeight}},o.prototype.resize=function(e,i,o){var r=this,a=this.parent;a.isResize=!0,t.isNullOrUndefined(a.prevCropObj)&&t.isNullOrUndefined(a.prevObj)&&a.notify("transform",{prop:"updateResize",value:{bool:!1}});var n=a.element.querySelector("#"+a.element.id+"_aspectratio"),s=a.element.querySelector("#"+a.element.id+"_nonaspectratio");t.isNullOrUndefined(n)||t.isNullOrUndefined(s)||(a.notify("toolbar",{prop:"initResizeToolbar"}),t.Browser.isDevice&&a.notify("toolbar",{prop:"init-main-toolbar",value:{isApplyBtn:!1,isDevice:!0,isOkBtn:!0,isResize:!0}}));var l={cancel:!1,previousWidth:Math.ceil(a.img.destWidth),previousHeight:Math.ceil(a.img.destHeight),width:Math.ceil(e),height:i&&0!==i?Math.ceil(i):a.aspectHeight?a.aspectHeight:Math.ceil(a.img.destHeight),isAspectRatio:o||!1};t.isBlazor()?t.isBlazor()&&a.events&&!0===a.events.imageResizing.hasDelegate?a.dotNetRef.invokeMethodAsync("OnImageResizingAsync",l).then(function(e){e.cancel||r.resizeEventHandler(e)}):this.resizeEventHandler(l):(a.trigger("resizing",l),l.cancel||this.resizeEventHandler(l))},o.prototype.resizeEventHandler=function(e){var i,o=this.parent,r=o.element.querySelector("#"+o.element.id+"_resizeHeight"),a=o.element.querySelector(".e-ie-toolbar-e-resize-height-input .e-numerictextbox");e.isAspectRatio?(null!=this.resizedImgAngle&&this.resizedImgAngle===o.transform.degree||(this.resizedImgAngle=o.transform.degree,i=!0),i?(o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:0}}),r?(t.getComponent(r,"numerictextbox").value=Math.floor(o.img.destHeight),r.value=Math.floor(o.img.destHeight).toString()+" px",o.aspectHeight=Math.floor(o.img.destHeight)):a&&(a.value=Math.floor(o.img.destHeight).toString(),o.aspectHeight=Math.floor(o.img.destHeight))):o.notify("transform",{prop:"resizeImage",value:{width:e.width,height:null}})):(null!==this.resizedImgAngle&&this.resizedImgAngle!==o.transform.degree&&(this.resizedImgAngle=o.transform.degree,i=!0),i?(o.notify("transform",{prop:"setPreventDownScale",value:{bool:!0}}),o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}}),o.okBtn(),o.resizeSrc={startX:o.img.srcLeft,startY:o.img.srcTop,width:o.img.srcWidth,height:o.img.srcHeight},t.isBlazor()?o.updateToolbar(o.element,"resize"):(o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),o.notify("transform",{prop:"setPreventDownScale",value:{bool:!1}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))):o.notify("transform",{prop:"resizeCrop",value:{width:e.width,height:e.height}})),this.resizedImgAngle=o.transform.degree},o}(),u=function(){function e(e){this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.on("undo-redo",this.undoRedo,this),this.parent.on("destroyed",this.destroy,this)},e.prototype.removeEventListener=function(){this.parent.off("undo-redo",this.undoRedo),this.parent.off("destroyed",this.destroy)},e.prototype.initializeUrPvtProp=function(){this.parent.lowerCanvas&&(this.lowerContext=this.parent.lowerCanvas.getContext("2d")),this.parent.upperCanvas&&(this.upperContext=this.parent.upperCanvas.getContext("2d"))},e.prototype.undoRedo=function(e){switch(this.initializeUrPvtProp(),e.prop){case"updateUndoRedoColl":this.updateUrc(e.value.operation,e.value.previousObj,e.value.previousObjColl,e.value.previousPointColl,e.value.previousSelPointColl,e.value.previousCropObj,e.value.previousText,e.value.currentText,e.value.previousFilter,e.value.isCircleCrop);break;case"refreshUrc":this.refreshUrc(e.value.bool);break;case"updateCurrUrc":this.updateCurrUrc(e.value.type);break;case"call-undo":this.callUndo();break;case"call-redo":this.callRedo();break;case"undo":this.undo();break;case"redo":this.redo();break;case"updateUrObj":this.updateUrObj(e.value.objColl);break;case"updateUndoRedo":this.updateUndoRedo();break;case"getAppliedUndoRedoColl":e.value.obj.appliedUndoRedoColl=this.appliedUndoRedoColl;break;case"getUndoRedoStep":e.value.obj.undoRedoStep=this.undoRedoStep;break;case"setUndoRedoStep":this.undoRedoStep=e.value.step;break;case"undoDefault":this.undoDefault(e.value.obj);break;case"reset":this.reset()}},e.prototype.getModuleName=function(){return"undo-redo"},e.prototype.reset=function(){this.tempCurrSelPoint=null,this.undoRedoStep=0,this.undoRedoColl=[],this.appliedUndoRedoColl=[],this.tempActObj=null,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0},e.prototype.refreshUrc=function(e){var i=this.parent;(e=e||!1)?(t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!0}}),this.tempUndoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0),this.tempUndoRedoStep=this.undoRedoStep):t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),this.undoRedoColl=this.undoRedoColl.slice(0,this.undoRedoStep),this.appliedUndoRedoColl=this.appliedUndoRedoColl.slice(0,this.undoRedoStep),i.isUndoRedo=i.currObjType.isUndoAction=!1,t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})},e.prototype.updateCurrUrc=function(e){var i=this.parent;if(!i.isResize){if(t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}),"ok"===e){i.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!1}});var o=this.tempUndoRedoColl.length>0?t.extend([],this.tempUndoRedoColl,[],!0):t.extend([],this.undoRedoColl,[],!0),r=this.undoRedoColl[this.undoRedoColl.length-1];if(t.isNullOrUndefined(this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1])?this.undoRedoColl[0]&&(r.previousCropObj=o[0].previousCropObj,r.previousObj=o[0].previousObj,r.previousObjColl=o[0].previousObjColl,r.previousPointColl=o[0].previousPointColl,r.previousText=o[0].previousText):"imageHFlip"!==r.operation&&"imageVFlip"!==r.operation&&(r.previousCropObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentCropObj,r.previousObj=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObj,r.previousObjColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentObjColl,r.previousPointColl=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentPointColl,r.previousText=this.appliedUndoRedoColl[this.appliedUndoRedoColl.length-1].currentText),r){if("imageHFlip"!==r.operation&&"imageVFlip"!==r.operation){var a=this.getZeroZoomObjPointValue(r.currentObjColl,r.currentPointColl);r.currentObjColl=a.obj,r.currentPointColl=a.point}this.appliedUndoRedoColl.push(r)}this.tempUndoRedoColl=[],this.tempUndoRedoStep=0}else this.tempUndoRedoColl.length>0&&(this.appliedUndoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0);this.appliedUndoRedoColl.length>16&&this.appliedUndoRedoColl.splice(0,1),this.undoRedoColl=[],this.undoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0),"ok"===e&&(this.undoRedoStep=this.undoRedoColl.length,t.isBlazor()?i.updateToolbar(i.element,"enableDisableToolbarBtn"):i.notify("toolbar",{prop:"enable-disable-btns"})),i.transform.zoomFactor>0&&(i.togglePan=!0,i.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}))}},e.prototype.cancelCropSelection=function(){var e,i=this.parent,o=!1;i.activeObj.shape&&(e=i.activeObj.shape.split("-")),(i.currObjType.isCustomCrop||e&&"crop"===e[0])&&(o=!0),o&&i.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),0===this.tempUndoRedoColl.length&&0===this.tempUndoRedoStep||(this.appliedUndoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoColl=t.extend([],this.tempUndoRedoColl,[],!0),this.undoRedoStep=this.tempUndoRedoStep,this.tempUndoRedoColl=[],this.tempUndoRedoStep=0,t.isBlazor()||i.notify("toolbar",{prop:"setEnableDisableUndoRedo",value:{isPrevent:!1}}))},e.prototype.refreshToolbarActions=function(){var e=this.parent;t.isBlazor()?t.isNullOrUndefined(e.activeObj.shape)&&e.updateToolbar(e.element,"imageLoaded"):e.activeObj.shape?(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.notify("toolbar",{prop:"update-toolbar-items",onPropertyChange:!1})):e.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1})},e.prototype.applyCurrentChanges=function(){var e=this.parent;e.currObjType.isFiltered=!1,0===e.transform.zoomFactor&&(e.togglePan=!1,e.notify("selection",{prop:"setDragCanvas",value:{bool:!1}})),e.element.querySelector(".e-contextual-toolbar-wrapper")&&!t.isBlazor()&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.togglePen&&(e.togglePen=!1,e.upperCanvas.style.cursor=e.cursor="default",this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height)),this.appliedUndoRedoColl.length>0&&(this.undoRedoColl=t.extend([],this.appliedUndoRedoColl,[],!0))},e.prototype.callUndo=function(){this.applyCurrentChanges(),this.undo()},e.prototype.callRedo=function(){this.applyCurrentChanges(),this.redo()},e.prototype.undo=function(){var e=this.parent;if(this.cancelCropSelection(),!e.disabled&&e.isImageLoaded&&this.undoRedoStep>0){this.refreshToolbarActions(),e.activeObj.activePoint&&0!==e.activeObj.activePoint.width&&(this.tempActObj=e.activeObj),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.undoRedoStep--,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):(e.notify("toolbar",{prop:"enable-disable-btns"}),e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),e.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===e.textArea.style.display&&(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}});switch(e.cropObj=t.extend({},i.previousCropObj,{},!0),e.afterCropActions=i.previousObj.afterCropActions,this.lowerContext.filter=i.previousObj.filter,e.canvasFilter=this.lowerContext.filter,i.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":this.shapeTransform(i.previousObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.previousPointColl,i.previousSelPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.previousPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.previousObjColl,i.previousPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(void 0,i.previousObjColl);break;case"text":this.updateText(i.previousObjColl,!0);break;case"frame":e.transform.zoomFactor=e.transform.defaultZoomFactor=i.previousObj.defaultZoom,e.setProperties({zoomSettings:{zoomFactor:i.previousObj.zoomFactor}},!0),e.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:e.zoomSettings.zoomFactor}}),t.extend(e.frameObj,i.previousObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",i.previousObjColl);break;case"imageVFlip":this.imageFlip("vertical",i.previousObjColl);break;default:this.undoDefault(i),e.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:i.operation,filter:i.filter}})}"crop"===i.operation&&(i.previousObj.currSelectionPoint&&(e.currSelectionPoint=t.extend({},i.previousObj.currSelectionPoint,{},!0),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null)),e.updateCropTransformItems(),e.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:"custom",startX:null,startY:null,width:null,height:null}}),e.isCircleCrop&&(e.isCircleCrop=!1,this.tempCurrSelPoint=t.extend({},e.currSelectionPoint,{},!0),e.currSelectionPoint=null),e.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),e.currObjType.isActiveObj=!1),this.undoRedoColl[this.undoRedoStep-1]&&this.undoRedoColl[this.undoRedoStep-1].isCircleCrop&&(e.isCircleCrop=!0,e.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})),this.endUndoRedo(i.operation,!0)}},e.prototype.redo=function(){var e=this.parent;if(this.cancelCropSelection(),!e.disabled&&e.isImageLoaded&&this.undoRedoStep<this.appliedUndoRedoColl.length){this.refreshToolbarActions(),this.undoRedoStep++,t.isBlazor()?e.updateToolbar(e.element,"enableDisableToolbarBtn"):e.notify("toolbar",{prop:"enable-disable-btns"}),e.isUndoRedo=!0;var i=this.undoRedoColl[this.undoRedoStep-1];this.undoRedoColl.length===this.undoRedoStep?e.currObjType.isUndoAction=!1:e.currObjType.isUndoAction=!0,"textAreaCustomization"!==i.operation&&"block"===e.textArea.style.display&&(e.textArea.style.display="none"),e.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!0}}),e.cropObj=t.extend({},i.currentCropObj,{},!0),e.afterCropActions=i.currentObj.afterCropActions,this.lowerContext.filter=i.currentObj.filter,!t.isBlazor()&&e.element.querySelector(".e-contextual-toolbar-wrapper")&&e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.canvasFilter=this.lowerContext.filter;var o=void 0;switch(i.operation){case"shapeTransform":case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":this.shapeTransform(i.currentObjColl);break;case"freehanddraw":case"freehand-draw":this.updateFreehandDraw(i.currentPointColl,i.currentSelPointColl);break;case"freehanddrawCustomized":this.updateFreehandDrawCustomized(i.currentPointColl);break;case"deleteFreehandDrawing":case"deleteObj":this.updateDelete(i.operation,i.currentObjColl,i.currentPointColl);break;case"textAreaCustomization":this.updateTextAreaCustomization(o,i.currentObjColl);break;case"text":this.updateText(i.currentObjColl,!1);break;case"frame":t.extend(e.frameObj,i.currentObj.frameObj),e.notify("draw",{prop:"render-image",value:{isMouseWheel:!0,isPreventClearRect:null,isFrame:!0}});break;case"imageHFlip":this.imageFlip("horizontal",i.currentObjColl);break;case"imageVFlip":this.imageFlip("vertical",i.currentObjColl);break;default:e.objColl=[],e.pointColl=[],e.freehandCounter=0,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),e.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:i.currentObj}}),e.img.destLeft=i.currentObj.destPoints.startX,e.img.destTop=i.currentObj.destPoints.startY,o=t.extend({},e.activeObj,{},!0),e.objColl=t.extend([],i.currentObjColl,[],!0),e.pointColl=t.extend([],i.currentPointColl,[],!0),e.freehandCounter=e.pointColl.length,e.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],i.currentSelPointColl,[],!0)}}}),this.lowerContext.filter="none",e.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),e.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=i.currentObj.filter,e.activeObj=o,this.upperContext.clearRect(0,0,e.upperCanvas.width,e.upperCanvas.height),0!==e.activeObj.activePoint.width&&0!==e.activeObj.activePoint.height&&e.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),e.notify("filter",{prop:"set-adjustment",value:{operation:i.operation}}),e.notify("filter",{prop:"update-filter",value:{operation:i.operation}})}"crop"===i.operation&&i.isCircleCrop&&(e.isCircleCrop=!0,e.currSelectionPoint=t.extend({},this.tempCurrSelPoint,{},!0),this.tempCurrSelPoint=null),"crop"!==i.operation||i.isCircleCrop||(e.isCircleCrop=!1),"crop"===i.operation&&i.currentObj.currSelectionPoint&&(e.currSelectionPoint=t.extend({},i.currentObj.currSelectionPoint,{},!0)),e.currSelectionPoint&&t.isNullOrUndefined(e.currSelectionPoint.shape)&&(e.currSelectionPoint=null),this.endUndoRedo(i.operation,!1)}},e.prototype.imageFlip=function(e,i){var o=this.parent;o.objColl=t.extend([],i,[],!0),o.activeObj=t.extend({},o.objColl[o.objColl.length-1],{},!0),o.objColl.pop(),o.activeObj.shape&&"image"===o.activeObj.shape?("horizontal"===e?t.isNullOrUndefined(o.activeObj.isHorImageFlip)&&o.activeObj.isVerImageFlip?(o.activeObj.isHorImageFlip=!0,o.activeObj.isVerImageFlip=null,o.horizontalFlip(this.upperContext,!0)):(t.isNullOrUndefined(o.activeObj.isHorImageFlip)||!o.activeObj.isHorImageFlip?o.activeObj.isHorImageFlip=!0:o.activeObj.isHorImageFlip=null,o.horizontalFlip(this.upperContext,!0)):"vertical"===e&&(t.isNullOrUndefined(o.activeObj.isVerImageFlip)&&o.activeObj.isHorImageFlip?(o.activeObj.isVerImageFlip=!0,o.activeObj.isHorImageFlip=null,o.verticalFlip(this.upperContext,!0)):(t.isNullOrUndefined(o.activeObj.isVerImageFlip)||!o.activeObj.isVerImageFlip?o.activeObj.isVerImageFlip=!0:o.activeObj.isVerImageFlip=null,o.verticalFlip(this.upperContext,!0))),o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}})):o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}})},e.prototype.shapeTransform=function(e){var i=this.parent;i.objColl=t.extend([],e,[],!0),i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},e.prototype.updateFreehandDraw=function(e,t){var i=this.parent;i.pointColl=e,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t}}}),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.isUndoRedo=!0,i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateFreehandDrawCustomized=function(e){var t=this.parent;t.pointColl=e,t.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.clearRect(0,0,t.lowerCanvas.width,t.lowerCanvas.height),this.upperContext.clearRect(0,0,t.upperCanvas.width,t.upperCanvas.height),t.isUndoRedo=!0,t.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateDelete=function(e,t,i){var o=this.parent;"deleteFreehandDrawing"===e?(o.pointColl=i,o.freehandCounter=o.pointColl.length,o.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}})):"deleteObj"===e&&(o.objColl=t,o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}})),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1})},e.prototype.updateTextAreaCustomization=function(e,i){var o=this.parent;o.objColl=t.extend([],i,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1});for(var r=0,a=i.length;r<a;r++){if(!this.tempActObj){e=t.extend({},i[i.length-1],{},!0),o.objColl.splice(r,1);break}if(this.tempActObj.currIndex===i[r].currIndex){e=t.extend({},i[r],{},!0),o.objColl.splice(r,1);break}}e&&this.updateTextBox(e),"block"===o.textArea.style.display&&o.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}})},e.prototype.updateText=function(e,i){var o=this.parent;if(this.tempActObj&&(o.activeObj=t.extend({},this.tempActObj,{},!0)),0===e.length&&1===o.objColl.length)this.tempActObj=t.extend({},o.objColl[0],{},!0);else for(var r=0;r<o.objColl.length;r++){if(o.objColl[r]&&t.isNullOrUndefined(e[r])){this.tempActObj=t.extend({},o.objColl[r],{},!0);break}if(e[r].currIndex!==o.objColl[r].currIndex){this.tempActObj=t.extend({},o.objColl[r],{},!0);break}}i&&(o.activeObj=t.extend({},this.tempActObj,{},!0)),o.objColl=t.extend([],e,[],!0),o.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:!0}}),this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),this.lowerContext.clearRect(0,0,o.lowerCanvas.width,o.lowerCanvas.height),o.isUndoRedo=!0,o.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1})},e.prototype.updateTextBox=function(e){var i=this.parent;this.upperContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),this.lowerContext.clearRect(0,0,i.lowerCanvas.width,i.lowerCanvas.height),i.notify("draw",{prop:"redrawImgWithObj",onPropertyChange:!1}),t.isBlazor()?i.updateToolbar(i.element,"destroyQuickAccessToolbar"):i.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),i.textArea.style.display="block",i.textArea.style.fontFamily=e.textSettings.fontFamily,i.textArea.style.fontSize=e.textSettings.fontSize+"px",i.textArea.style.color=e.strokeSettings.strokeColor,i.textArea.style.fontWeight=e.textSettings.bold?"bold":"normal",i.textArea.style.fontStyle=e.textSettings.italic?"italic":"normal",i.textArea.style.border="2px solid "+i.themeColl[i.theme].primaryColor,i.textArea.value=e.keyHistory,i.activeObj=t.extend({},e,{},!0),i.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}}),i.textArea.style.width=i.activeObj.activePoint.width+"px"},e.prototype.undoDefault=function(e){this.lowerContext.filter=e.previousObj.filter;var i=this.parent;i.objColl=[],i.pointColl=[],i.freehandCounter=0,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),i.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:e.previousObj}}),this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),i.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.img.destLeft=e.previousObj.destPoints.startX,i.img.destTop=e.previousObj.destPoints.startY;var o=t.extend({},i.activeObj,{},!0);i.objColl=t.extend([],e.previousObjColl,[],!0),i.pointColl=t.extend([],e.previousPointColl,[],!0),i.freehandCounter=i.pointColl.length,i.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],e.previousSelPointColl,[],!0)}}}),this.lowerContext.filter="none",i.notify("shape",{prop:"zoomObjColl",onPropertyChange:!1,value:{isPreventApply:null}}),i.notify("freehand-draw",{prop:"zoomFHDColl",onPropertyChange:!1,value:{isPreventApply:null}}),this.lowerContext.filter=e.previousObj.filter,i.activeObj=o,this.upperContext.clearRect(0,0,i.upperCanvas.width,i.upperCanvas.height),0!==i.activeObj.activePoint.width&&0!==i.activeObj.activePoint.height&&i.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})},e.prototype.endUndoRedo=function(e,i){var o=this.parent;(o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape||o.isCircleCrop)&&JSON.stringify(o.frameObj)!==JSON.stringify({type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""})&&o.notify("draw",{prop:"render-image",value:{isMouseWheel:!0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),o.isCircleCrop&&(i&&"crop"!==e||!i)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}}),o.transform.zoomFactor>0&&o.notify("selection",{prop:"setDragCanvas",value:{bool:!0}}),o.notify("draw",{prop:"setCancelAction",onPropertyChange:!1,value:{bool:!1}}),t.isBlazor()?(t.isNullOrUndefined(o.activeObj.shape)||"crop"!==o.activeObj.shape.split("-")[0])&&(o.updateToolbar(o.element,"imageLoaded"),o.updateToolbar(o.element,"enableDisableToolbarBtn")):(o.activeObj.shape&&"crop"===o.activeObj.shape.split("-")[0]?o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!0,isZooming:null,cType:null}}):o.notify("toolbar",{prop:"refresh-main-toolbar",onPropertyChange:!1}),o.notify("toolbar",{prop:"enable-disable-btns"})),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"),t.isBlazor()?o.updateToolbar(o.element,"enableDisableToolbarBtn"):o.notify("toolbar",{prop:"enable-disable-btns"}),0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),o.currObjType.isCustomCrop=!1},e.prototype.updateUrc=function(e,i,o,r,a,n,s,l,p,h){var c=this.parent;if(!c.isResize){var d={isInitialLoaded:!1};if(c.currObjType.isUndoAction&&this.refreshUrc(!0),c.notify("draw",{prop:"isInitialLoaded",onPropertyChange:!1,value:{object:d}}),!d.isInitialLoaded&&c.allowUndoRedo){var v={currObj:{}};c.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:v}});var u=v.currObj;u.objColl=t.extend([],c.objColl,[],!0),u.pointColl=t.extend([],c.pointColl,[],!0),u.afterCropActions=t.extend([],c.afterCropActions,[],!0);var g={selPointColl:null};c.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:g}}),u.selPointColl=t.extend([],g.selPointColl,[],!0),"crop"===e?u.currSelectionPoint=t.extend({},c.currSelectionPoint,{},!0):"frame"===e&&(i.destPoints={startX:c.frameDestPoints.destLeft,startY:c.frameDestPoints.destTop,width:c.frameDestPoints.destWidth,height:c.frameDestPoints.destHeight},u.destPoints={startX:c.frameDestPoints.destLeft,startY:c.frameDestPoints.destTop,width:c.frameDestPoints.destWidth,height:c.frameDestPoints.destHeight}),this.undoRedoColl.push({operation:e,previousObj:i,currentObj:u,previousObjColl:o,currentObjColl:u.objColl,previousPointColl:r,currentPointColl:u.pointColl,previousSelPointColl:a,currentSelPointColl:u.selPointColl,previousCropObj:n,currentCropObj:t.extend({},c.cropObj,{},!0),previousText:s,currentText:l,filter:p,isCircleCrop:h}),t.isBlazor()?"pen-toolbar"!==c.currentToolbar&&c.updateToolbar(c.element,"enableDisableToolbarBtn"):c.notify("toolbar",{prop:"enable-disable-btns",onPropertyChange:!1})}}},e.prototype.updateUrObj=function(e){var i=this.parent;if(i.allowUndoRedo){i.currObjType.isUndoAction&&this.refreshUrc(!0),i.objColl.push(i.activeObj);var o=t.extend({},i.cropObj,{},!0),r={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],i.objColl,[],!0),a.pointColl=t.extend([],i.pointColl,[],!0),a.afterCropActions=t.extend([],i.afterCropActions,[],!0);var n={selPointColl:null};i.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0),this.undoRedoColl.push({operation:"shapeTransform",previousObj:a,currentObj:a,previousObjColl:e,currentObjColl:a.objColl,previousPointColl:a.pointColl,currentPointColl:a.pointColl,previousSelPointColl:a.selPointColl,currentSelPointColl:a.selPointColl,previousCropObj:o,currentCropObj:o}),i.notify("selection",{prop:"redrawShape",onPropertyChange:!1,value:{obj:i.objColl[i.objColl.length-1]}})}},e.prototype.updateUndoRedo=function(){var e=this.parent,i=t.extend({},e.cropObj,{},!0),o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}});var r=o.currObj;r.objColl=t.extend([],e.objColl,[],!0),r.pointColl=t.extend([],e.pointColl,[],!0),r.afterCropActions=t.extend([],e.afterCropActions,[],!0);var a={selPointColl:null};e.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:a}}),r.selPointColl=t.extend([],a.selPointColl,[],!0),e.objColl.push(e.activeObj),this.updateUrc("shapeTransform",r,r.objColl,r.pointColl,r.selPointColl,i),e.objColl.pop(),e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:null}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()?e.updateToolbar(e.element,"imageLoaded"):(e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}),e.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}))},e.prototype.getZeroZoomObjPointValue=function(e,i){var o=this.parent,r={currObj:{}};o.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var a=r.currObj;a.objColl=t.extend([],o.objColl,[],!0),a.pointColl=t.extend([],o.pointColl,[],!0),a.afterCropActions=t.extend([],o.afterCropActions,[],!0);var n={selPointColl:null};o.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),a.selPointColl=t.extend([],n.selPointColl,[],!0);var s={cropDimension:null};o.notify("transform",{prop:"getCropDimension",onPropertyChange:!1,value:{obj:s}});var l=t.extend([],o.objColl,[],!0),p=t.extend([],o.pointColl,[],!0),h={arrowDimension:null};this.parent.notify("draw",{prop:"getArrowDimension",onPropertyChange:!1,value:{obj:h}});var c=t.extend({},h.arrowDimension,{},!0);if(o.transform.zoomFactor>0&&(e.length>0||i.length>0)){o.objColl=e,o.pointColl=i;var d=o.isUndoRedo;if(0!==o.transform.zoomFactor){o.isUndoRedo=o.isCropTab=!0,o.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1});var v=t.extend({},o.zoomSettings,null,!0);o.transform.zoomFactor>0?o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-o.transform.zoomFactor,zoomPoint:null,isResize:null}}):o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(o.transform.zoomFactor),zoomPoint:null,isResize:null}}),o.zoomSettings=v,o.isCropTab=!1,o.isUndoRedo=d,l=t.extend([],o.objColl,[],!0),p=t.extend([],o.pointColl,[],!0),o.objColl=[],o.pointColl=[],o.freehandCounter=0,o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:[]}}}),o.notify("transform",{prop:"setCropDimension",onPropertyChange:!1,value:{width:s.cropDimension.width,height:s.cropDimension.height}});var u={width:s.cropDimension.width,height:s.cropDimension.height};u.width+=u.width*a.defaultZoom,u.height+=u.height*a.defaultZoom,o.notify("draw",{prop:"setZoomCropWidth",value:{width:u.width,height:u.height}}),o.notify("draw",{prop:"setCurrentObj",onPropertyChange:!1,value:{obj:a}}),o.img.destLeft=a.destPoints.startX,o.img.destTop=a.destPoints.startY,o.panPoint.totalPannedPoint=a.totalPannedPoint,o.panPoint.totalPannedClientPoint=a.totalPannedClientPoint,o.panPoint.totalPannedInternalPoint=a.totalPannedInternalPoint,o.objColl=t.extend([],a.objColl,[],!0),o.pointColl=t.extend([],a.pointColl,[],!0),o.freehandCounter=o.pointColl.length,o.notify("draw",{prop:"setArrowDimension",onPropertyChange:!1,value:{arrowDimension:c}}),o.notify("freehand-draw",{prop:"setSelPointColl",onPropertyChange:!1,value:{obj:{selPointColl:t.extend([],a.selPointColl,[],!0)}}}),this.lowerContext.filter="none",o.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),o.notify("freehand-draw",{prop:"freehandRedraw",onPropertyChange:!1,value:{context:this.lowerContext,points:null}}),o.notify("freehand-draw",{prop:"updateFHDCurPts",onPropertyChange:!1}),this.lowerContext.filter=a.filter,0!==o.transform.degree&&o.notify("transform",{prop:"drawPannedImage",onPropertyChange:!1,value:{xDiff:0,yDiff:0}}),o.notify("draw",{prop:"clearOuterCanvas",onPropertyChange:!1,value:{context:this.lowerContext}}),(o.isCircleCrop||o.currSelectionPoint&&"crop-circle"===o.currSelectionPoint.shape)&&o.notify("crop",{prop:"cropCircle",onPropertyChange:!1,value:{context:this.lowerContext,isSave:null,isFlip:null}})}}return{obj:l,point:p}},e}(),g=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),b=function(e,t,i,o){var r,a=arguments.length,n=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(a<3?r(n):a>3?r(t,i,n):r(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n},f=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(null)],i.prototype,"brightness",void 0),b([t.Property(null)],i.prototype,"contrast",void 0),b([t.Property(null)],i.prototype,"hue",void 0),b([t.Property(null)],i.prototype,"saturation",void 0),b([t.Property(null)],i.prototype,"exposure",void 0),b([t.Property(null)],i.prototype,"opacity",void 0),b([t.Property(null)],i.prototype,"blur",void 0),i}(t.ChildProperty),m=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(null)],i.prototype,"zoomTrigger",void 0),b([t.Property(1)],i.prototype,"minZoomFactor",void 0),b([t.Property(10)],i.prototype,"maxZoomFactor",void 0),b([t.Property(1)],i.prototype,"zoomFactor",void 0),b([t.Property(null)],i.prototype,"zoomPoint",void 0),i}(t.ChildProperty),C=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return g(i,e),b([t.Property(!0)],i.prototype,"showCircle",void 0),b([t.Property(null)],i.prototype,"strokeColor",void 0),b([t.Property(null)],i.prototype,"fillColor",void 0),i}(t.ChildProperty),y=function(r){function a(e,i){var o=r.call(this,e)||this;return o.isImageLoaded=!1,o.activeObj={activePoint:{startX:0,startY:0,endX:0,endY:0,width:0,height:0},flipObjColl:[],triangle:[],triangleRatio:[],rotatedAngle:0},o.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},o.objColl=[],o.pointColl={},o.freehandCounter=0,o.points=[],o.togglePen=!1,o.togglePan=!1,o.img={destLeft:0,destTop:0,destWidth:0,destHeight:0,srcLeft:0,srcTop:0,srcWidth:0,srcHeight:0},o.rotateFlipColl=[],o.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",destPoints:{startX:0,startY:0,width:0,height:0},srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,zoomFactor:0,previousZoomValue:0,aspectWidth:null,aspectHeight:null,frame:"none"},o.afterCropActions=[],o.transform={degree:0,currFlipState:"",zoomFactor:0,cropZoomFactor:null,defaultZoomFactor:0},o.panPoint={currentPannedPoint:{x:0,y:0},totalPannedPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0}},o.isUndoRedo=!1,o.isCropTab=!1,o.isCircleCrop=!1,o.fontSizeColl=[],o.initialAdjustmentValue="",o.currentFilter="",o.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)",o.toolbarHeight=0,o.isPublicMethod=!1,o.isCropToolbar=!1,o.cursor="default",o.resizeSrc={startX:o.img.srcLeft,startY:o.img.srcTop,width:o.img.srcWidth,height:o.img.srcHeight},o.isResize=!1,o.isAspectRatio=!1,o.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},o.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},o.allowDownScale=!0,o.gradientColor="",o.size=20,o.inset=0,o.offset=0,o.borderRadius=0,o.lineCount=0,t.isBlazor()?(new n(o),new s(o),new p(o),new h(o),new c(o),new d(o),new v(o),new u(o),new l(o)):(y.Inject(n,s,c,v,l,j),y.Inject(u),y.Inject(p),y.Inject(d),y.Inject(h),i&&o.appendTo(i)),o}g(a,r),y=a,a.prototype.requiredModules=function(){var e=[];return e.push({member:"crop",args:[this]}),e.push({member:"draw",args:[this]}),e.push({member:"selection",args:[this]}),e.push({member:"transform",args:[this]}),e.push({member:"export",args:[this]}),e.push({member:"toolbar-module",args:[this]}),e.push({member:"undo-redo",args:[this]}),e.push({member:"filter",args:[this]}),e.push({member:"shape",args:[this]}),e.push({member:"freehand-draw",args:[this]}),e},a.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-image-editor"),t.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},a.prototype.render=function(){this.initialize()},a.prototype.getModuleName=function(){return"image-editor"},a.prototype.getPersistData=function(){return this.addOnPersist([])},a.prototype.onPropertyChanged=function(i,o){for(var r,a=0,n=Object.keys(i);a<n.length;a++){switch(n[a]){case"cssClass":o.cssClass&&t.removeClass([this.element],o.cssClass.replace(/\s+/g," ").trim().split(" ")),i.cssClass&&t.addClass([this.element],i.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"disabled":i.disabled?(this.element.classList.add("e-disabled"),this.unwireEvent()):(this.element.classList.remove("e-disabled"),this.wireEvent());break;case"height":this.element.style.height=i.height,this.update();break;case"width":this.element.style.width=i.width,this.update();break;case"theme":i.theme&&(this.theme&&""!==this.theme?this.theme=this.toPascalCase(this.theme):this.theme="Bootstrap5",this.upperContext.strokeStyle=this.themeColl[this.theme].primaryColor,this.upperContext.fillStyle=this.themeColl[this.theme].secondaryColor,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"finetuneSettings":i.finetuneSettings&&(this.finetuneSettings=i.finetuneSettings,this.notify("filter",{prop:"update-finetunes"}));break;case"locale":i.locale&&(this.notify("toolbar",{prop:"setLocale",onPropertyChange:!1,value:{locale:i.locale}}),t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"allowUndoRedo":i.allowUndoRedo?this.allowUndoRedo=!0:this.allowUndoRedo=!1,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}});break;case"showQuickAccessToolbar":i.showQuickAccessToolbar?(this.showQuickAccessToolbar=!0,t.isBlazor()||this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),r={freehandSelectedIndex:null},this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:r}}),this.activeObj.shape?t.isBlazor()?this.updateToolbar(this.element,"quickAccessToolbar",this.activeObj.shape):this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}):r.freehandSelectedIndex&&(t.isBlazor()?this.updateToolbar(this.element,"quickAccessToolbar","pen"):this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:!0}}))):(this.showQuickAccessToolbar=!1,t.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}));break;case"zoomSettings":i.zoomSettings&&(this.zoomSettings.zoomTrigger=i.zoomSettings.zoomTrigger),t.isNullOrUndefined(this.zoomSettings.zoomTrigger)?(this.zoomSettings.zoomTrigger=e.ZoomTrigger.MouseWheel|e.ZoomTrigger.Pinch|e.ZoomTrigger.Toolbar|e.ZoomTrigger.Commands,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})):(i.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar&&(t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"selectionSettings":i.selectionSettings&&(this.selectionSettings=i.selectionSettings,this.activeObj.shape&&(this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})));break;case"toolbar":i.toolbar&&(this.toolbar=i.toolbar,t.isBlazor()?this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}}));break;case"toolbarTemplate":i.toolbarTemplate&&(t.isBlazor()||(this.notify("toolbar",{prop:"destroy-bottom-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"destroy-top-toolbar",onPropertyChange:!1}),this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()));break;case"quickAccessToolbarTemplate":i.quickAccessToolbarTemplate&&(t.isBlazor()||(this.notify("toolbar",{prop:"destroy-qa-toolbar",onPropertyChange:!1}),this.quickAccessToolbarTemplateFn()))}}},a.prototype.destroy=function(){var e=[];this.element.removeAttribute("tabindex"),this.cssClass&&(e=e.concat(this.cssClass.replace(/\s+/g," ").trim().split(" "))),t.removeClass([this.element],e),this.element.getAttribute("class")||this.element.removeAttribute("class"),t.isBlazor()?this.element.classList.remove("e-image-editor"):(this.notify("toolbar",{prop:"destroySubComponents",onPropertyChange:!1}),this.notify("destroyed",null),r.prototype.destroy.call(this)),this.unwireEvent(),this.element.innerHTML=""},a.prototype.initialize=function(){if(this.toolbarTemplate?(this.element.appendChild(this.createElement("div",{id:this.element.id+"_toolbarArea",className:"e-toolbar-area"})),this.toolbarTemplateFn()):(this.notify("toolbar",{prop:"create-toolbar",onPropertyChange:!1}),this.notify("toolbar",{prop:"create-contextual-toolbar",onPropertyChange:!1})),this.createCanvas(),this.element.offsetWidth>359&&this.element.querySelector(".e-ie-min-drop-content")&&this.element.querySelector(".e-ie-drop-content")&&(this.element.querySelector(".e-ie-min-drop-content").style.display="none",this.element.querySelector(".e-ie-drop-content").style.display="block"),this.createDropUploader(),this.showQuickAccessToolbar){document.querySelector("#"+this.element.id+"_canvasWrapper").appendChild(this.createElement("div",{id:this.element.id+"_quickAccessToolbarArea",className:"e-quick-access-toolbar-area"}));var e=document.getElementById(this.element.id+"_quickAccessToolbarArea");e.style.position="absolute",e.style.display="none",this.activeObj&&(e.style.left=this.activeObj.activePoint.startX+"px",e.style.top=this.activeObj.activePoint.startY+"px"),e.style.width="100%"}this.quickAccessToolbarTemplate?this.quickAccessToolbarTemplateFn():this.notify("toolbar",{prop:"create-qa-toolbar",onPropertyChange:!1}),this.wireEvent(),this.lowerContext=this.lowerCanvas.getContext("2d"),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.lowerContext.filter,this.notify("toolbar",{prop:"setInitialAdjustmentValue",onPropertyChange:!1,value:{value:this.lowerContext.filter}}),this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},a.prototype.createDropUploader=function(){var e=this;new o.Uploader({dropArea:document.getElementsByClassName("e-canvas-wrapper")[0],allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1,selected:function(t){if("change"===t.event.type||"drop"===t.event.type){var i=t.filesData[0].type,o="unsupported";"change"!==t.event.type&&("drop"!==t.event.type||1!==t.event.dataTransfer.files.length)||"png"!==i&&"jpg"!==i&&"jpeg"!==i&&"svg"!==i?("drop"===t.event.type&&t.event.dataTransfer.files.length>1&&(o="multi-select-image"),e.showDialogPopup(o)):e.notify("draw",{prop:"fileSelect",value:{inputElement:e.element.querySelector("#"+e.element.id+"_dropfileUpload"),args:t}})}}}).appendTo("#"+this.element.id+"_dropfileUpload")},a.prototype.dlgCloseBtnClick=function(){t.getComponent(document.getElementById(this.element.id+"_dialog"),"dialog").destroy()},a.prototype.showDialogPopup=function(e){var t="";this.element.querySelector("#"+this.element.id+"_dialog").style.display="block";var o,r={key:"OK"};if(this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}}),"multi-select-image"===e){o={key:"ImageErrorDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});var a={key:"ImageErrorDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}}),t="<span>"+a.value+"</span>"}else{o={key:"AlertDialogHeader"},this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:o}});a={key:"AlertDialogContent"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}}),t="<span>"+a.value+" "+n.value+"<b> JPG, PNG, and SVG</b></span>"}new i.Dialog({header:o.value,closeOnEscape:!0,content:t,target:document.getElementById("target"),width:"285px",isModal:!0,animationSettings:{effect:"Zoom"},close:this.dlgCloseBtnClick.bind(this),buttons:[{click:this.dlgCloseBtnClick.bind(this),buttonModel:{content:r.value,iconCss:"e-icons e-close"}}]}).appendTo("#"+this.element.id+"_dialog")},a.prototype.wireEvent=function(){t.EventHandler.add(document,"keydown",this.keyDownEventHandler,this),t.EventHandler.add(document,"keypress",this.keyUpEventHandler,this),t.EventHandler.add(this.upperCanvas,"mousedown",this.mouseDownEventHandler,this),t.EventHandler.add(this.upperCanvas,"mousemove",this.mouseMoveEventHandler,this),t.EventHandler.add(this.upperCanvas,"mouseup",this.mouseUpEventHandler,this),t.EventHandler.add(document,"mouseup",this.mouseUpEventHandler,this),t.EventHandler.add(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler,this),t.EventHandler.add(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler,this),t.EventHandler.add(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler,this),t.EventHandler.add(document,"mouseup",this.canvasMouseUpHandler,this),t.EventHandler.add(this.upperCanvas,"touchstart",this.touchStartHandler,this),t.EventHandler.add(this.lowerCanvas,"touchstart",this.touchStartHandler,this),t.EventHandler.add(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),t.EventHandler.add(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll,this),window.addEventListener("resize",this.windowResizeHandler.bind(this)),t.Browser.isIos||"safari"===t.Browser.info.name||screen.orientation.addEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"wireEvent",onPropertyChange:!1})},a.prototype.unwireEvent=function(){t.EventHandler.remove(document,"keydown",this.keyDownEventHandler),t.EventHandler.remove(document,"keypress",this.keyUpEventHandler),t.EventHandler.remove(this.upperCanvas,"mousedown",this.mouseDownEventHandler),t.EventHandler.remove(this.upperCanvas,"mousemove",this.mouseMoveEventHandler),t.EventHandler.remove(this.upperCanvas,"mouseup",this.mouseUpEventHandler),t.EventHandler.remove(document,"mouseup",this.mouseUpEventHandler),t.EventHandler.remove(this.lowerCanvas,"mousedown",this.canvasMouseDownHandler),t.EventHandler.remove(this.lowerCanvas,"mousemove",this.canvasMouseMoveHandler),t.EventHandler.remove(this.lowerCanvas,"mouseup",this.canvasMouseUpHandler),t.EventHandler.remove(document,"mouseup",this.canvasMouseUpHandler),t.EventHandler.remove(this.upperCanvas,"touchstart",this.touchStartHandler),t.EventHandler.remove(this.lowerCanvas,"touchstart",this.touchStartHandler),t.EventHandler.remove(this.lowerCanvas,"mousewheel DOMMouseScroll",this.handleScroll),t.EventHandler.remove(this.upperCanvas,"mousewheel DOMMouseScroll",this.handleScroll),window.removeEventListener("resize",this.windowResizeHandler.bind(this)),t.Browser.isIos||"safari"===t.Browser.info.name||screen.orientation.removeEventListener("change",this.screenOrientation.bind(this)),this.notify("shape",{prop:"unWireEvent",onPropertyChange:!1}),this.notify("selection",{prop:"unWireEvent",onPropertyChange:!1})},a.prototype.createCanvas=function(){var e=this;this.element.style.boxSizing="border-box";var t={toolbarHeight:0};this.notify("toolbar",{prop:"getToolbarHeight",value:{obj:t}});var i=t.toolbarHeight;this.element.style.width=this.width,this.element.style.height=this.height;var o=this.element.appendChild(this.createElement("div",{id:this.element.id+"_canvasWrapper",className:"e-canvas-wrapper",attrs:{style:"height:"+(this.element.offsetHeight-i-2)+"px; width:"+(this.element.offsetWidth-2)+"px; position: relative; overflow: hidden; margin: 0 auto;"}})),r={key:"DragText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:r}});var a={key:"DropText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:a}});var n={key:"BrowseText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:n}});var s={key:"SupportText"};this.notify("toolbar",{prop:"getLocaleText",onPropertyChange:!1,value:{obj:s}});var l=this.createElement("div",{id:this.element.id+"_dropArea",className:"e-ie-drop-area",attrs:{style:"position: relative;"}}),p=this.createElement("span",{className:"e-ie-drop-icon e-icons e-image",attrs:{style:"position: absolute;"}}),h=this.createElement("span",{className:"e-ie-drop-content",attrs:{style:"position: absolute; display: none;"}});h.textContent=r.value+" ";var c=this.createElement("span",{className:"e-ie-min-drop-content",attrs:{style:"position: absolute;"}});c.textContent=a.value+" ";var d=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});d.textContent=n.value;var v=this.createElement("a",{id:this.element.id+"_dropBrowse",className:"e-ie-drop-browse"});v.textContent=n.value,h.appendChild(d),c.appendChild(v),d.href="",v.href="";var u=this.createElement("span",{className:"e-ie-drop-info",attrs:{position:"absolute"}});u.textContent=s.value+" SVG, PNG, and JPG";var g=l.appendChild(this.createElement("input",{id:this.element.id+"_dropfileUpload",className:"e-fileUpload e-image-upload"}));g.setAttribute("type","file"),g.setAttribute("accept","image/*"),l.appendChild(p),l.appendChild(h),l.appendChild(c),l.appendChild(u),o.appendChild(l),this.lowerCanvas=o.appendChild(this.createElement("canvas",{id:this.element.id+"_lowerCanvas",attrs:{name:"canvasImage"}})),this.upperCanvas=o.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.baseImgCanvas=this.createElement("canvas",{id:this.element.id+"_baseImgCanvas",attrs:{name:"canvasImage"}}),this.textArea=o.appendChild(this.createElement("textarea",{id:this.element.id+"_textArea",className:"e-textarea",attrs:{name:"textArea"}}));this.element.appendChild(this.createElement("div",{id:this.element.id+"_dialog",className:"e-dialog"})).style.display="none";var b=this.element.appendChild(this.createElement("input",{id:this.element.id+"_fileUpload",className:"e-fileUpload"}));b.setAttribute("type","file"),b.setAttribute("accept","image/*"),b.style.display="none",this.textArea.setAttribute("spellcheck","false"),this.textArea.style.lineHeight="normal",this.lowerCanvas.style.width=this.upperCanvas.style.width=this.inMemoryCanvas.style.width="100%",this.lowerCanvas.style.height=this.upperCanvas.style.height=this.inMemoryCanvas.style.height="100%",this.upperCanvas.style.position=this.lowerCanvas.style.position=this.textArea.style.position="absolute",this.textArea.style.backgroundColor="transparent",this.textArea.style.display="none",this.textArea.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=this.cursor="default",this.upperCanvas.style.display="block",this.upperContext=this.upperCanvas.getContext("2d"),document.getElementById(this.element.id+"_dropBrowse").onclick=function(){return e.element.querySelector("#"+e.element.id+"_dropfileUpload").click(),!1}},a.prototype.touchStartHandler=function(e){this.notify("selection",{prop:"touchStartHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseDownEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseDownEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseMoveEventHandler=function(e){this.notify("selection",{prop:"mouseMoveEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.mouseUpEventHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"mouseUpEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.keyDownEventHandler=function(e){this.notify("selection",{prop:"keyDownEventHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.keyUpEventHandler=function(e){"block"===this.textArea.style.display&&e.target.id===this.element.id+"_textArea"&&this.notify("selection",{prop:"textKeyDown",value:{e:e}})},a.prototype.canvasMouseDownHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseDownHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.canvasMouseMoveHandler=function(e){this.notify("selection",{prop:"canvasMouseMoveHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.canvasMouseUpHandler=function(e){"e-ie-drop-browse"!==e.target.className&&this.notify("selection",{prop:"canvasMouseUpHandler",onPropertyChange:!1,value:{e:e}})},a.prototype.handleScroll=function(e){this.notify("selection",{prop:"handleScroll",onPropertyChange:!1,value:{e:e}})},a.prototype.adjustToScreen=function(){this.update()},a.prototype.screenOrientation=function(){t.Browser.isDevice&&setTimeout(this.adjustToScreen.bind(this),100)},a.prototype.windowResizeHandler=function(){!t.Browser.isDevice&&this.element.classList.contains("e-image-editor")&&this.adjustToScreen()},a.prototype.notifyResetForAllModules=function(){for(var e=this.requiredModules(),t=0;t<e.length;t++)this.notify(e[t].member,{prop:"reset",onPropertyChange:!1})},a.prototype.allowShape=function(e,t){this.isPublicMethod=!0;var i={inRange:!1};return this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e,y:t,obj:i}}),i.inRange},a.prototype.clearSelection=function(){this.notify("selection",{prop:"clearSelection",onPropertyChange:!1})},a.prototype.crop=function(){var e={isCrop:!1};return this.notify("crop",{prop:"crop",onPropertyChange:!1,value:{obj:e}}),e.isCrop},a.prototype.flip=function(e){this.notify("transform",{prop:"flip",value:{direction:e}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})},a.prototype.getImageData=function(){var e={canvas:null};return this.notify("export",{prop:"exportToCanvas",value:{object:e}}),e.canvas.getContext("2d").getImageData(0,0,e.canvas.width,e.canvas.height)},a.prototype.open=function(e){document.getElementById(this.element.id+"_dropArea").style.display="none",this.notify("draw",{prop:"open",value:{data:e}})},a.prototype.reset=function(){var e={isErrorImage:!1};if(this.notify("draw",{prop:"getErrorImage",value:{obj:e}}),!this.disabled&&!e.isErrorImage){this.clearContext(this.inMemoryContext),this.clearContext(this.lowerContext),this.clearContext(this.upperContext),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.isBlazor()||(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),t.Browser.isDevice&&document.getElementById(this.element.id+"_bottomToolbar")&&(t.getComponent(document.getElementById(this.element.id+"_bottomToolbar"),"toolbar").destroy(),this.notify("toolbar",{prop:"create-bottom-toolbar",onPropertyChange:!1})));var i=this.isImageLoaded;this.currObjType.isUndoAction=this.isUndoRedo=this.togglePan=this.togglePen=this.isImageLoaded=!1,this.isCircleCrop=this.isCropTab=!1,this.objColl=[],this.transform.degree=0,this.upperCanvas.style.display="block",this.transform.currFlipState="",this.allowDownScale=!0,this.upperCanvas.style.cursor=this.cursor=this.lowerCanvas.style.cursor="default",this.lowerContext.lineWidth=this.upperContext.lineWidth=void 0,this.frameDestPoints=null,this.textArea.value=this.textArea.textContent="",this.textArea.style.display="none",this.lowerContext.filter=this.canvasFilter=this.getDefaultFilter(),this.img.destLeft=this.img.destTop=this.img.srcLeft=this.img.srcTop=0,this.img.destWidth=this.img.destHeight=this.img.srcWidth=this.img.srcHeight=null,this.currSelectionPoint=null,this.panPoint.currentPannedPoint={x:0,y:0},this.rotateFlipColl=[],this.points=[],this.pointColl={},this.freehandCounter=0,this.notify("draw",{prop:"resetPanPoints"}),this.lowerCanvas.style.left=this.upperCanvas.style.left="",this.fontSizeColl=[],this.lowerCanvas.style.top=this.upperCanvas.style.top="",this.lowerCanvas.style.maxWidth=this.upperCanvas.style.maxWidth="",this.lowerCanvas.style.maxHeight=this.upperCanvas.style.maxHeight="",this.transform.defaultZoomFactor=this.transform.zoomFactor=0,this.transform.cropZoomFactor=null,this.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},this.tempFrameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""},this.currObjType={shape:"",isDragging:!1,isActiveObj:!1,isText:!1,isInitialText:!1,isLine:!1,isInitialLine:!1,isCustomCrop:!1,isZoomed:!1,isUndoZoom:!1,isUndoAction:!1,isFiltered:!1,isSave:!1,isResize:!1},this.cropObj={cropZoom:0,defaultZoom:0,totalPannedPoint:{x:0,y:0},totalPannedClientPoint:{x:0,y:0},totalPannedInternalPoint:{x:0,y:0},tempFlipPanPoint:{x:0,y:0},activeObj:{},rotateFlipColl:[],degree:0,currFlipState:"",zoomFactor:0,previousZoomValue:0,destPoints:{startX:0,startY:0,width:0,height:0},frame:"none",srcPoints:{startX:0,startY:0,width:0,height:0},filter:"",isBrightAdjust:!1,aspectWidth:null,aspectHeight:null},this.afterCropActions=[],this.currentFilter="",this.tempFrameZoomLevel=null;var o={initialZoomValue:!1};this.notify("draw",{prop:"getInitialZoomValue",onPropertyChange:!1,value:{obj:o}}),o.initialZoomValue&&this.setProperties({zoomSettings:{zoomFactor:o.initialZoomValue}},!0),document.getElementById(this.element.id+"_quickAccessToolbarArea")&&(document.getElementById(this.element.id+"_quickAccessToolbarArea").style.display="none"),this.notifyResetForAllModules(),this.notify("filter",{prop:"update-finetunes"}),this.isImageLoaded=!1,this.notify("draw",{prop:"update-canvas",onPropertyChange:!1}),this.isImageLoaded=i,t.isBlazor()||(this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),this.notify("toolbar",{prop:"refresh-dropdown-btn",value:{isDisabled:!1}}),this.notify("toolbar",{prop:"enable-disable-btns"}))}},a.prototype.rotate=function(e){var t={isRotate:!1};return this.notify("transform",{prop:"rotate",value:{degree:e,obj:t}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),t.isRotate},a.prototype.export=function(e,t){this.notify("export",{prop:"export",onPropertyChange:!1,value:{type:e,fileName:t}})},a.prototype.select=function(e,t,i,o,r){this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:i,width:o,height:r}}),this.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:e,startX:t,startY:i,width:o,height:r}})},a.prototype.freeHandDraw=function(e){this.notify("freehand-draw",{prop:"freeHandDraw",onPropertyChange:!1,value:{value:e}})},a.prototype.freehandDraw=function(e){!this.disabled&&this.isImageLoaded&&this.freeHandDraw(e)},a.prototype.pan=function(e){this.notify("transform",{prop:"pan",onPropertyChange:!1,value:{value:e}})},a.prototype.zoom=function(e,t){this.notify("transform",{prop:"zoom",onPropertyChange:!1,value:{zoomFactor:e,zoomPoint:t}})},a.prototype.drawEllipse=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawEllipse",onPropertyChange:!1,value:{x:e,y:i,radiusX:o,radiusY:r,strokeWidth:a,strokeColor:n,fillColor:s,degree:l}})),p},a.prototype.drawLine=function(e,i,o,r,a,n){var s=!1,l=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(l||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(s=!0,this.notify("shape",{prop:"drawLine",onPropertyChange:!1,value:{startX:e,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n}})),s},a.prototype.drawArrow=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawArrow",onPropertyChange:!1,value:{startX:e,startY:i,endX:o,endY:r,strokeWidth:a,strokeColor:n,arrowStart:s,arrowEnd:l}})),p},a.prototype.drawPath=function(e,i,o){this.isPublicMethod=!0;var r={inRange:!1},a=!1;if(e&&e.length>0)for(var n=0;n<e.length&&!r.inRange;n++)this.notify("shape",{prop:"isPointsInRange",onPropertyChange:!1,value:{x:e[n].x,y:e[n].y,obj:r}});return!this.disabled&&this.isImageLoaded&&(r.inRange||t.isNullOrUndefined(e))&&(a=!0,this.notify("shape",{prop:"drawPath",onPropertyChange:!1,value:{pointColl:e,strokeWidth:i,strokeColor:o}})),a},a.prototype.drawRectangle=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawRectangle",onPropertyChange:!1,value:{x:e,y:i,width:o,height:r,strokeWidth:a,strokeColor:n,fillColor:s,degree:l}})),p},a.prototype.drawText=function(e,i,o,r,a,n,s,l){var p=!1,h=this.allowShape(e,i);return!this.disabled&&this.isImageLoaded&&(h||t.isNullOrUndefined(e)&&t.isNullOrUndefined(i))&&(p=!0,this.notify("shape",{prop:"drawText",onPropertyChange:!1,value:{x:e,y:i,text:o,fontFamily:r,fontSize:a,bold:n,italic:s,color:l}})),p},a.prototype.drawImage=function(e,i,o,r,a,n,s){var l=!1,p=this.allowShape(i,o);if(!this.disabled&&this.isImageLoaded&&(p||t.isNullOrUndefined(i)&&t.isNullOrUndefined(o))){var h=this.objColl.length;this.notify("shape",{prop:"drawImage",onPropertyChange:!1,value:{x:i,y:o,width:r,height:a,src:e,degree:s,isAspectRatio:n}}),this.objColl.length>h&&(l=!0)}return l},a.prototype.selectShape=function(e){var t={isSelected:!1};return this.notify("shape",{prop:"selectShape",onPropertyChange:!1,value:{id:e,obj:t}}),t.isSelected},a.prototype.deleteShape=function(e){this.notify("shape",{prop:"deleteShape",onPropertyChange:!1,value:{id:e}})},a.prototype.getShapeSetting=function(e){var t={};return this.notify("shape",{prop:"getShapeSetting",onPropertyChange:!1,value:{id:e,obj:t}}),t},a.prototype.getShapeSettings=function(){var e={shapeDetailsColl:[]};return this.notify("shape",{prop:"getShapeSettings",onPropertyChange:!1,value:{obj:e}}),e.shapeDetailsColl},a.prototype.update=function(){this.notify("transform",{prop:"update"})},a.prototype.finetuneImage=function(e,t){!this.disabled&&this.isImageLoaded&&this.notify("filter",{prop:"finetuneImage",value:{value:t,option:e}})},a.prototype.applyImageFilter=function(e){!this.disabled&&this.isImageLoaded&&(this.notify("filter",{prop:"applyImageFilter",value:{option:e.toString()}}),this.canvasFilter=this.lowerContext.filter,this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}))},a.prototype.undo=function(){this.notify("undo-redo",{prop:"undo",onPropertyChange:!1})},a.prototype.redo=function(){this.notify("undo-redo",{prop:"redo",onPropertyChange:!1})},a.prototype.getImageDimension=function(){return{x:this.img.destLeft,y:this.img.destTop,width:this.img.destWidth,height:this.img.destHeight}},a.prototype.resize=function(e,i,o){var r=!1;if(e.toString().length<=4&&i.toString().length<=4){var a=this.img.destLeft,n=this.img.destTop,s=this.img.destWidth,l=this.img.destHeight;if(t.isBlazor())this.updateToolbar(this.element,"resize");else{o?(this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}}),this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}})):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"resize",isApplyBtn:!1,isCropping:!1}});var p=this.element.querySelector("#"+this.element.id+"_resizeWidth"),h=this.element.querySelector("#"+this.element.id+"_resizeHeight");p&&h&&(t.getComponent(p,"numerictextbox").value=Math.floor(e),p.value=Math.floor(e).toString()+" px",t.getComponent(h,"numerictextbox").value=Math.floor(i),h.value=Math.floor(i).toString()+" px")}this.notify("transform",{prop:"resize",value:{width:e,height:i,isAspectRatio:o}}),a!==this.img.destLeft||n!==this.img.destTop||s!==this.img.destWidth||l!==this.img.destHeight?(r=!0,this.okBtn()):this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}})}return r},a.prototype.drawFrame=function(i,o,r,a,n,s,l,p,h){var c=!1,d={frameChangeEventArgs:null};o=o||"#fff",r=r||"",a=a||20,n=n||0,s=s||0,l=l||0,p=p||e.FrameLineStyle.Solid,h=h||0;var v={type:this.toPascalCase(this.frameObj.type),color:this.frameObj.color,gradientColor:this.frameObj.gradientColor,size:this.frameObj.size,inset:this.frameObj.inset,offset:this.frameObj.offset,borderRadius:this.frameObj.radius,frameLineStyle:this.toPascalCase(this.frameObj.border),lineCount:this.frameObj.amount};return t.extend(this.tempFrameObj,this.frameObj),this.tempFrameZoomLevel=this.transform.zoomFactor,this.frameDestPoints=t.extend({},this.img,{},!0),t.isBlazor()?this.performFrameClick():this.notify("toolbar",{prop:"frameToolbarClick"}),this.frameObj.type=i.toLowerCase(),this.frameObj.color=o,this.frameObj.gradientColor=r,this.frameObj.size=a,this.frameObj.inset=n,this.frameObj.offset=s,this.frameObj.radius=l,this.frameObj.border=p.toLowerCase(),this.frameObj.amount=h,this.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:v,obj:d}}),d.frameChangeEventArgs&&!d.frameChangeEventArgs.cancel?(this.notify("draw",{prop:"render-image",value:{isMouseWheel:null}}),JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)?(c=!0,this.okBtn()):this.tempFrameZoomLevel=null):(this.notify("draw",{prop:"performCancel",value:{isContextualToolbar:null}}),t.extend(this.frameObj,this.tempFrameObj),this.tempFrameZoomLevel=null),c},a.prototype.toolbarTemplateFn=function(){var e,t=this.element.id+"_toolbar",i=this.element.querySelector("#"+this.element.id+"_toolbarArea");if(this.toolbarTemplate){if(this.toolbarFn=this.templateParser(this.toolbarTemplate),this.isReact)e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var o=this.toolbarFn({type:"toolbar"},this,"Template",t);e=3===o[0].nodeType?o[1]:o[0]}else e=this.toolbarFn({type:"toolbar"},this,"Template",t)[0];i.appendChild(e),this.toolbarHeight=i.clientHeight,this.notify("toolbar",{prop:"setToolbarHeight",value:{height:this.toolbarHeight}}),this.renderReactTemplates()}},a.prototype.quickAccessToolbarTemplateFn=function(){var e,t=this.element.id+"_quickAccessToolbar",i=this.element.querySelector("#"+this.element.id+"_quickAccessToolbarArea");if(this.quickAccessToolbarTemplate){if(this.qatFn=this.templateParser(this.quickAccessToolbarTemplate),this.isReact)e=this.qatFn({type:"toolbar"},this,"Template",t)[0];else if(this.isAngular){var o=this.qatFn({type:"toolbar"},this,"Template",t);e=3===o[0].nodeType?o[1]:o[0]}else e=this.qatFn({type:"toolbar"},this,"Template",t)[0];i.appendChild(e),this.renderReactTemplates()}},a.prototype.templateParser=function(e){if(e)try{return"function"!=typeof e&&document.querySelectorAll(e).length?t.compile(document.querySelector(e).innerHTML.trim()):t.compile(e)}catch(i){return t.compile(e)}},a.prototype.getTextFromId=function(e){return{1:"none",2:"bar",3:"arrow",4:"arrowSolid",5:"circle",6:"circleSolid",7:"square",8:"squareSolid"}[""+e]},a.prototype.getFinetuneOption=function(t){return{brightness:e.ImageFinetuneOption.Brightness,contrast:e.ImageFinetuneOption.Contrast,hue:e.ImageFinetuneOption.Hue,saturation:e.ImageFinetuneOption.Saturation,opacity:e.ImageFinetuneOption.Opacity,blur:e.ImageFinetuneOption.Blur,exposure:e.ImageFinetuneOption.Exposure}[""+t]},a.prototype.setPenStroke=function(e){this.notify("freehand-draw",{prop:"setPenStrokeWidth",onPropertyChange:!1,value:{value:parseInt(e,10)}})},a.prototype.updateFreehandDrawColorChange=function(){var e={tempFreeHandDrawEditingStyles:null};this.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:e}}),this.notify("freehand-draw",{prop:"color-change",value:{color:e.tempFreeHandDrawEditingStyles.strokeColor}})},a.prototype.updateImageTransformColl=function(e){var i;"rotateleft"===e?i=-90:"rotateright"===e?i=90:"horizontalflip"===e?i="horizontal":"verticalflip"===e&&(i="vertical");for(var o=0;o<this.objColl.length;o++)if("image"===this.objColl[o].shape){t.isNullOrUndefined(this.objColl[o].rotateFlipColl)&&(this.objColl[o].rotateFlipColl=[]),this.objColl[o].rotateFlipColl.push(i);var r={collection:this.objColl[o].rotateFlipColl};this.notify("shape",{prop:"alignRotateFlipColl",onPropertyChange:!1,value:{collection:this.objColl[o].rotateFlipColl,isRotateFlipCollection:!1,obj:r}}),this.objColl[o].rotateFlipColl=r.collection}},a.prototype.setInitialZoomState=function(){this.objColl.push(this.activeObj),this.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1});var e=this.isUndoRedo;this.isCropTab=!1,this.isUndoRedo=!0,this.transform.cropZoomFactor&&this.transform.cropZoomFactor>0?this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.cropZoomFactor,zoomPoint:null,isResize:null}}):this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:Math.abs(this.transform.cropZoomFactor),zoomPoint:null,isResize:null}}),this.isUndoRedo=e,this.panPoint.totalPannedPoint={x:0,y:0},this.transform.cropZoomFactor=0,this.notify("freehand-draw",{prop:"updateFHDColl",onPropertyChange:!1}),this.activeObj=t.extend({},this.objColl[this.objColl.length-1],{},!0),this.objColl.pop(),this.isCropTab=!0,this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:this.activeObj}})},a.prototype.updateCropTransformItems=function(){this.prevCurrSelectionPoint=t.extend({},this.currSelectionPoint,{},!0);var e={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:e}});var i=e.currObj;i.objColl=t.extend([],this.objColl,[],!0),i.pointColl=t.extend([],this.pointColl,[],!0),i.afterCropActions=t.extend([],this.afterCropActions,[],!0);var o={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:o}}),i.selPointColl=t.extend([],o.selPointColl,[],!0),this.cancelCropSelection={operation:"cropTransform",previousObj:i,currentObj:i,previousObjColl:i.objColl,currentObjColl:i.objColl,previousPointColl:i.pointColl,currentPointColl:i.pointColl,previousSelPointColl:i.selPointColl,currentSelPointColl:i.selPointColl,previousCropObj:t.extend({},this.cropObj,{},!0),currentCropObj:t.extend({},this.cropObj,{},!0),previousText:null,currentText:null,filter:null,isCircleCrop:this.isCircleCrop}},a.prototype.toPascalCase=function(e,i){var o=[];t.isNullOrUndefined(e)||(o=e.toLowerCase().split("-"));for(var r=0;r<o.length;r++)o[r]=o[r].charAt(0).toUpperCase()+o[r].slice(1);return i&&(i.maxText=o.join("")),o.join("")},a.prototype.getFontSizes=function(){var e=[];this.fontSizeColl=[];var t;t=0===this.transform.degree||this.transform.degree%180==0?this.img.destWidth/25:this.img.destHeight/25;for(var i=1;i<=10;i++)this.fontSizeColl.push({text:(i*Math.round(t/2)).toString()}),e.push({text:i.toString()});return e},a.prototype.okBtn=function(i){this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-frame-wrapper");var o,r=!1,a=this.element.querySelector("#"+this.element.id+"_aspectratio"),n=this.element.querySelector("#"+this.element.id+"_nonaspectratio"),s=this.element.querySelector(".e-ie-toolbar-aspect-ratio-btn"),l=this.element.querySelector(".e-ie-toolbar-nonaspect-ratio-btn");if(void 0!==this.activeObj.shape&&(o=this.activeObj.shape.split("-")),void 0===o&&this.currObjType.isCustomCrop?r=!0:void 0!==o&&"crop"===o[0]&&(r=!0),this.allowDownScale=!0,(this.activeObj.shape&&"image"!==this.activeObj.shape||this.togglePen)&&!r){var p={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:p}});var h=p.shapeSettingsObj;this.togglePen&&(h.type=e.ShapeType.FreehandDraw);var c={action:"apply",previousShapeSettings:t.extend({},h,{},!0),currentShapeSettings:t.extend({},h,{},!0)};this.triggerShapeChanged(c)}if(a||n||t.isBlazor()&&"resize-toolbar"===this.currentToolbar){var d={width:null,height:null};this.notify("selection",{prop:"getNumTextValue",onPropertyChange:!1,value:{obj:d}});var v={x:d.width,y:d.height},u={prevCropObj:this.prevCropObj},g={prevObj:this.prevObj};v&&v.x&&v.y&&u.prevCropObj&&g.prevObj?(n||l&&!l.classList.contains("e-hidden")?this.notify("transform",{prop:"resize",value:{width:v.x,height:v.y,isAspectRatio:!1}}):(a||s&&!s.classList.contains("e-hidden"))&&this.notify("transform",{prop:"resize",value:{width:v.x,height:null,isAspectRatio:!0}}),this.isResize=!1,this.aspectWidth=v.x,this.aspectHeight=v.y,this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-this.transform.zoomFactor,zoomPoint:null,isResize:!0}}),this.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:g.prevObj.defaultZoom,zoomPoint:null,isResize:!0}}),g.prevObj.zoomFactor&&this.setProperties({zoomSettings:{zoomFactor:g.prevObj.zoomFactor}},!0),this.notify("transform",{prop:"setPreviousZoomValue",onPropertyChange:!1,value:{previousZoomValue:this.zoomSettings.zoomFactor}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"resize",previousObj:g.prevObj,previousObjColl:g.prevObj.objColl,previousPointColl:g.prevObj.pointColl,previousSelPointColl:g.prevObj.selPointColl,previousCropObj:u.prevCropObj,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:!1,isZooming:null,cType:null}}),this.isAspectRatio=!1}var b=this.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected"),f={bool:!1};this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:f}});if(this.notify("toolbar",{prop:"getFrameToolbar",onPropertyChange:!1,value:{obj:{bool:null}}}),b&&(this.currentFilter=b.children[0].children[0].id.replace("Canvas","")),r)this.crop();else if(this.togglePen)this.freeHandDraw(!1),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if("block"===this.textArea.style.display)this.notify("shape",{prop:"redrawActObj",onPropertyChange:!1,value:{x:null,y:null,isMouseDown:null}}),t.isNullOrUndefined(i)&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(!t.isBlazor()&&document.querySelector("#"+this.element.id+"_sliderWrapper")||t.isBlazor()&&!this.element.querySelector(".e-ie-contextual-slider").classList.contains("e-hidden")||this.currObjType.isFiltered){this.initialAdjustmentValue=this.canvasFilter=this.lowerContext.filter,this.currObjType.isFiltered=!1;var m={value:null};this.notify("draw",{prop:"getTempAdjustmentValue",value:{obj:m}}),m.value!==this.lowerContext.filter&&this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)&&this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:i}})}else if(f.bool)this.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!1}}),t.isBlazor()?this.updateToolbar(this.element,"destroyQuickAccessToolbar"):this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}});else if(0!==this.activeObj.activePoint.width&&0!==this.activeObj.activePoint.height||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)"image"===this.activeObj.shape&&this.notify("draw",{prop:"setImageApply",onPropertyChange:!1,value:{bool:!0}}),this.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:i}});else{if(JSON.stringify(this.frameObj)!==JSON.stringify(this.tempFrameObj)){var C={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:C}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:C.currObj,previousObjColl:C.currObj.objColl,previousPointColl:C.currObj.pointColl,previousSelPointColl:C.currObj.selPointColl,previousCropObj:t.extend({},this.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),this.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),this.tempFrameObj=t.extend({},this.frameObj,{},!0),this.notify("draw",{prop:"setTempFrame",onPropertyChange:!1,value:{frame:this.frameObj.type}})}this.notify("draw",{prop:"resetFrameZoom",onPropertyChange:!1})}t.isBlazor()||f.isCropToolbar?!t.isBlazor()||f.isCropToolbar||"resize-toolbar"!=this.currentToolbar&&"frame-toolbar"!=this.currentToolbar||this.updateToolbar(this.element,"imageLoaded"):this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!1,isCropping:null,isZooming:null,cType:null}}),this.notify("draw",{prop:"setNewPath",value:{bool:!1}}),this.isCropTab=!1,this.transform.zoomFactor=this.transform.defaultZoomFactor,this.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}})},a.prototype.setTempFilterProperties=function(){this.upperCanvas.style.display="block",this.cropSelectedState();var e={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:e}}),this.lowerContext.filter=this.initialAdjustmentValue,this.notify("draw",{prop:"setTempAdjustmentValue",value:{tempAdjustmentValue:this.lowerContext.filter}}),this.notify("filter",{prop:"setTempAdjustmentLevel",onPropertyChange:!1,value:{tempAdjustmentLevel:t.extend({},e.adjustmentLevel,{},!0)}}),this.notify("draw",{prop:"setTempFilter",value:{tempFilter:this.currentFilter}});var i={undoRedoStep:null};this.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}}),this.notify("draw",{prop:"setTempUndoRedoStep",value:{tempUndoRedoStep:i.undoRedoStep}})},a.prototype.cropSelectedState=function(){this.activeObj.shape&&"crop"===this.activeObj.shape.split("-")[0]&&this.okBtn()},a.prototype.getCurrentCanvasData=function(){var e=t.extend({},this.frameObj,{},!0);this.frameObj={type:"none",color:"#fff",size:20,inset:20,offset:20,radius:0,amount:1,border:"solid",gradientColor:""};var i=this.lowerContext.filter;this.lowerContext.filter=this.canvasFilter="none";var o=t.extend([],this.objColl,null,!0),r=t.extend([],this.pointColl,null,!0);this.objColl=[],this.pointColl=[],this.freehandCounter=0,this.notify("draw",{prop:"render-image",value:{isMouseWheel:!1}}),this.element.querySelector(".e-contextual-toolbar-wrapper")&&this.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide");var a=this.getImageData();return this.element.querySelector(".e-contextual-toolbar-wrapper")&&(this.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide"),t.isBlazor()&&(this.element.querySelector(".e-ie-toolbar-check-btn").classList.remove("e-hidden"),this.element.querySelector(".e-ie-toolbar-close-btn").classList.remove("e-hidden"))),t.isBlazor()||(t.Browser.isDevice||this.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"main",isApplyBtn:!0,isCropping:!1}}),this.element.querySelector("#"+this.element.id+"_contextualToolbarArea").classList.remove("e-hide")),this.objColl=o,this.pointColl=r,this.freehandCounter=r.length,this.notify("shape",{prop:"iterateObjColl",onPropertyChange:!1}),this.lowerContext.filter=this.canvasFilter=i,this.frameObj=e,a},a.prototype.setCurrAdjustmentValue=function(e,i){var o=this,r={finetune:this.getFinetuneOption(e),value:i,cancel:!1};if(t.isBlazor()&&this.events&&!0===this.events.finetuneValueChanging.hasDelegate)this.dotNetRef.invokeMethodAsync("OnFinetuneValueChangeAsync",r).then(function(t){t.cancel||o.notify("filter",{prop:"setCurrAdjValue",value:{type:e.toLowerCase(),value:i}})});else{if(this.trigger("finetuneValueChanging",r),r.cancel)return;this.notify("filter",{prop:"setCurrAdjValue",value:{type:e.toLowerCase(),value:i}})}},a.prototype.getSquarePointForPath=function(e){var t={startX:0,startY:0,endX:0,endY:0,width:0,height:0};if(e.pointColl.length>0){t={startX:e.pointColl[0].x,startY:e.pointColl[0].y,endX:e.pointColl[0].x,endY:e.pointColl[0].y};for(var i=1;i<e.pointColl.length;i++)e.pointColl[i].x<t.startX&&(t.startX=e.pointColl[i].x),e.pointColl[i].y<t.startY&&(t.startY=e.pointColl[i].y),e.pointColl[i].x>t.endX&&(t.endX=e.pointColl[i].x),e.pointColl[i].y>t.endY&&(t.endY=e.pointColl[i].y);t.width=t.endX-t.startX,t.height=t.endY-t.startY}return t},a.prototype.getSelectionType=function(e){return{CropCustom:"Custom",CropSquare:"Square",CropCircle:"Circle","Crop3:2":"3:2","Crop4:3":"4:3","Crop5:4":"5:4","Crop7:5":"7:5","Crop16:9":"16:9"}[""+e]},a.prototype.clearContext=function(e){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.clearRect(0,0,e.canvas.height,e.canvas.width)},a.prototype.updateArrow=function(e,i){this.notify("shape",{prop:"pushActItemIntoObj"});var o=t.extend({},this.cropObj,{},!0),r={currObj:{}},a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj;this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:r}});var s=r.currObj;if(s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0),this.objColl.pop(),"startArrow"===e?this.activeObj.start=this.getTextFromId(i):"endArrow"===e&&(this.activeObj.end=this.getTextFromId(i)),this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}),!t.isBlazor())if(t.Browser.isDevice){if(document.getElementById(this.element.id+"_bottomToolbar")){t.getComponent(this.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(this.element.id+"_toolbar")){t.getComponent(this.element.id+"_toolbar","toolbar").refreshOverflow()}var l={action:e,previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};this.triggerShapeChanged(l)},a.prototype.updateFontFamily=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=t.extend([],this.objColl,[],!0),o=t.extend({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0);var l={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var p=this.activeObj.textSettings.fontFamily;this.activeObj.textSettings.fontFamily=this.toPascalCase(e),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height);var h=this.activeObj.activePoint.width+.25*this.activeObj.textSettings.fontSize;this.textArea.style.width=h+"px",this.textArea.style.fontFamily=this.toPascalCase(e),this.activeObj.textSettings.fontFamily=p,this.notify("shape",{prop:"updateFontStyles",onPropertyChange:!1,value:{isTextBox:null}})}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var c=this.activeObj.textSettings.fontFamily=this.toPascalCase(e);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:c,fontSize:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:i,previousPointColl:t.extend([],this.pointColl,[],!0),previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var d={action:"font-family",previousShapeSettings:t.extend({},a,{},!0),currentShapeSettings:t.extend({},a,{},!0)};d.currentShapeSettings.fontFamily=this.textArea.style.fontFamily,this.triggerShapeChanged(d)},a.prototype.updateFontSize=function(e){var i=e;this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var o=t.extend({},this.cropObj,{},!0),r={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:r}});var a=r.shapeSettingsObj,n={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}});var s=n.currObj;s.objColl=t.extend([],this.objColl,[],!0),s.pointColl=t.extend([],this.pointColl,[],!0),s.afterCropActions=t.extend([],this.afterCropActions,[],!0);var l={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:l}}),s.selPointColl=t.extend([],l.selPointColl,[],!0),this.objColl.pop(),"block"===this.textArea.style.display){this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:!0}});var p=this.activeObj.textSettings.fontSize;this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop();var h="";"bold"===this.textArea.style.fontWeight&&(h="bold "),"italic"===this.textArea.style.fontStyle&&(h="italic "),"bold"===this.textArea.style.fontWeight&&"italic"===this.textArea.style.fontStyle&&(h="italic bold "),this.upperContext.font=h+this.activeObj.textSettings.fontSize+"px "+this.textArea.style.fontFamily;var c=this.textArea.value.split("\n"),d={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:!0,text:null,obj:d}});var v=d.maxText,u=this.upperContext.measureText(v).width+.5*this.activeObj.textSettings.fontSize;this.textArea.style.width=u+"px",this.textArea.style.height=c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize)+"px",this.activeObj.textSettings.fontSize=p,this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily,this.textArea.style.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10)+"px","georgia"===this.textArea.style.fontFamily&&(this.textArea.style.width=parseFloat(this.textArea.style.width)+parseFloat(this.textArea.style.fontSize)+"px")}else{this.notify("shape",{prop:"updateFontRatio",onPropertyChange:!1,value:{obj:this.activeObj,isTextArea:null}});var g=this.activeObj.textSettings.fontSize=parseInt(this.fontSizeColl[parseInt(i,10)-1].text,10);this.notify("shape",{prop:"setTextSettings",onPropertyChange:!1,value:{textSettings:null,fontFamily:null,fontSize:g}}),this.upperContext.font=this.activeObj.textSettings.fontSize+"px "+this.activeObj.textSettings.fontFamily;c=this.activeObj.keyHistory.split("\n"),d={maxText:""};this.notify("shape",{prop:"getMaxText",onPropertyChange:!1,value:{isTextBox:null,text:null,obj:d}});var b=d.maxText,f=(u=this.upperContext.measureText(b).width+.5*this.activeObj.textSettings.fontSize,c.length*(this.activeObj.textSettings.fontSize+.25*this.activeObj.textSettings.fontSize));this.notify("selection",{prop:"setTextSelection",onPropertyChange:!1,value:{width:u,height:f}}),this.notify("draw",{prop:"updateActiveObject",onPropertyChange:!1,value:{actPoint:this.activeObj.activePoint,obj:this.activeObj,isMouseMove:null,x:null,y:null}}),this.notify("shape",{prop:"redraw-text"}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:s,previousObjColl:s.objColl,previousPointColl:s.pointColl,previousSelPointColl:s.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}})}var m={action:"font-size",previousShapeSettings:t.extend({},a,{},!0),currentShapeSettings:t.extend({},a,{},!0)};m.currentShapeSettings.fontSize=this.activeObj.textSettings.fontSize,this.triggerShapeChanged(m)},a.prototype.updateFontColor=function(e){this.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),this.notify("shape",{prop:"pushActItemIntoObj"});var i=t.extend({},this.cropObj,{},!0),o={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:o}});var r=o.shapeSettingsObj,a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};if(this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),"none"===this.textArea.style.display)this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));else if("block"===this.textArea.style.display){this.textArea.style.color=e;var l=this.activeObj.strokeSettings.strokeColor;this.activeObj.strokeSettings.strokeColor=e,this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"textAreaCustomization",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=l}else this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:i,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}));var p={action:"font-color",previousShapeSettings:t.extend({},r,{},!0),currentShapeSettings:t.extend({},r,{},!0)};p.currentShapeSettings.fillColor=e,this.triggerShapeChanged(p)},a.prototype.updatePenStrokeWidth=function(i){var o=t.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var r=t.extend({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],this.objColl,[],!0),l.pointColl=t.extend([],this.pointColl,[],!0),l.afterCropActions=t.extend([],this.afterCropActions,[],!0);var p={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),this.pointColl=o,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.setPenStroke(i);var h={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:h}}),h.bool){var c={penStrokeWidth:null};this.notify("freehand-draw",{prop:"getPenStrokeWidth",onPropertyChange:!1,value:{obj:c}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:null,strokeWidth:c.penStrokeWidth}});var d={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:d}}),this.pointColl[d.freehandSelectedIndex].strokeWidth=c.penStrokeWidth,this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}n.type=e.ShapeType.FreehandDraw;var v={action:"stroke-width",previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};v.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth,this.triggerShapeChanged(v)},a.prototype.updatePenStrokeColor=function(i){var o=t.extend([],this.pointColl,[],!0);this.updateFreehandDrawColorChange();var r=t.extend({},this.cropObj,{},!0),a={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:a}});var n=a.shapeSettingsObj,s={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:s}});var l=s.currObj;l.objColl=t.extend([],this.objColl,[],!0),l.pointColl=t.extend([],this.pointColl,[],!0),l.afterCropActions=t.extend([],this.afterCropActions,[],!0);var p={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:p}}),l.selPointColl=t.extend([],p.selPointColl,[],!0),this.pointColl=o,this.notify("selection",{prop:"setFreehandDrawCustomized",value:{isFreehandDrawCustomized:!0}}),this.activeObj.strokeSettings.strokeColor=i;var h={bool:!1};if(this.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:h}}),h.bool){var c={freehandSelectedIndex:null};this.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:c}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.pointColl[c.freehandSelectedIndex].strokeColor=i,this.notify("freehand-draw",{prop:"hoverFhd",onPropertyChange:!1,value:{strokeColor:i}}),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"freehanddrawCustomized",previousObj:l,previousObjColl:l.objColl,previousPointColl:l.pointColl,previousSelPointColl:l.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}else this.togglePen||this.notify("selection",{prop:"redrawShape",value:{obj:this.activeObj}});n.type=e.ShapeType.FreehandDraw;var d={action:"stroke-color",previousShapeSettings:t.extend({},n,{},!0),currentShapeSettings:t.extend({},n,{},!0)};d.currentShapeSettings.strokeColor=i,this.triggerShapeChanged(d)},a.prototype.updateStrokeWidth=function(e){if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeWidth=parseInt(e,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var l={action:"stroke-width",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.strokeWidth=this.activeObj.strokeSettings.strokeWidth,this.triggerShapeChanged(l)}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeWidth=parseInt(e,10),this.activeObj.strokeSettings.strokeWidth*=2,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:null,strokeWidth:this.activeObj.strokeSettings.strokeWidth}}))},a.prototype.updateStrokeColor=function(e){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;if(this.activeObj.shape&&("path"!==this.activeObj.shape||"path"===this.activeObj.shape&&this.activeObj.pointColl.length>0)){this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}),this.togglePen||(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))}else this.activeObj.shape&&"path"===this.activeObj.shape&&0===this.activeObj.pointColl.length&&(this.activeObj.strokeSettings.strokeColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:this.activeObj.strokeSettings.strokeColor,fillColor:null,strokeWidth:null}}));var l={action:"stroke-color",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.strokeColor=e,this.triggerShapeChanged(l)},a.prototype.updateFillColor=function(e){var i={shapeSettingsObj:{}};this.notify("selection",{prop:"updatePrevShapeSettings",onPropertyChange:!1,value:{obj:i}});var o=i.shapeSettingsObj;this.notify("shape",{prop:"pushActItemIntoObj"});var r=t.extend({},this.cropObj,{},!0),a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}});var n=a.currObj;n.objColl=t.extend([],this.objColl,[],!0),n.pointColl=t.extend([],this.pointColl,[],!0),n.afterCropActions=t.extend([],this.afterCropActions,[],!0);var s={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:s}}),n.selPointColl=t.extend([],s.selPointColl,[],!0),this.objColl.pop(),this.activeObj.strokeSettings.fillColor=e,this.notify("shape",{prop:"setStrokeSettings",value:{strokeSettings:null,strokeColor:null,fillColor:this.activeObj.strokeSettings.fillColor,strokeWidth:null}}),this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"shapeTransform",previousObj:n,previousObjColl:n.objColl,previousPointColl:n.pointColl,previousSelPointColl:n.selPointColl,previousCropObj:r,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}});var l={action:"fill-color",previousShapeSettings:t.extend({},o,{},!0),currentShapeSettings:t.extend({},o,{},!0)};l.currentShapeSettings.fillColor=e,this.triggerShapeChanged(l)},a.prototype.horizontalFlip=function(e,i){var o,r;if(t.isNullOrUndefined(i)){this.notify("shape",{prop:"pushActItemIntoObj"}),o=t.extend({},this.cropObj,{},!0);var a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],this.objColl,[],!0),r.pointColl=t.extend([],this.pointColl,[],!0),r.afterCropActions=t.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0),this.objColl.pop()}t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height),this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isNullOrUndefined(i)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageHFlip",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},a.prototype.verticalFlip=function(e,i){var o,r;if(t.isNullOrUndefined(i)){this.notify("shape",{prop:"pushActItemIntoObj"}),o=t.extend({},this.cropObj,{},!0);var a={currObj:{}};this.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:a}}),(r=a.currObj).objColl=t.extend([],this.objColl,[],!0),r.pointColl=t.extend([],this.pointColl,[],!0),r.afterCropActions=t.extend([],this.afterCropActions,[],!0);var n={selPointColl:null};this.notify("freehand-draw",{prop:"getSelPointColl",onPropertyChange:!1,value:{obj:n}}),r.selPointColl=t.extend([],n.selPointColl,[],!0),this.objColl.pop()}t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),e.clearRect(0,0,this.activeObj.imageCanvas.width,this.activeObj.imageCanvas.height),this.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:this.activeObj.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isNullOrUndefined(i)&&(this.objColl.push(this.activeObj),this.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"imageVFlip",previousObj:r,previousObjColl:r.objColl,previousPointColl:r.pointColl,previousSelPointColl:r.selPointColl,previousCropObj:o,previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),this.notify("selection",{prop:"redrawShape",value:{obj:this.objColl[this.objColl.length-1]}}))},a.prototype.rotateImage=function(e){t.isBlazor()||this.notify("toolbar",{prop:"refreshSlider"}),"rotleft"===e?this.activeObj.rotatedAngle-=Math.PI/180*90:this.activeObj.rotatedAngle+=Math.PI/180*90,this.notify("selection",{prop:"updPtCollForShpRot",onPropertyChange:!1,value:{obj:this.activeObj}}),this.upperContext.clearRect(0,0,this.upperCanvas.width,this.upperCanvas.height),this.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}}),t.isBlazor()?(this.updateToolbar(this.element,"destroyQuickAccessToolbar"),this.updateToolbar(this.element,"quickAccessToolbar","image")):(this.notify("toolbar",{prop:"destroy-qa-toolbar"}),this.notify("toolbar",{prop:"renderQAT",onPropertyChange:!1,value:{isPenEdit:null}}))},a.prototype.pascalToSplitWords=function(e){var i=(e=e.charAt(0).toUpperCase()+e.slice(1)).match(/[A-Z][a-z]+/g);return t.isNullOrUndefined(i)?e:i.map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ")},a.prototype.getCurrAdjustmentValue=function(e){var t={adjustmentLevel:null};this.notify("filter",{prop:"getAdjustmentLevel",onPropertyChange:!1,value:{obj:t}});return{brightness:t.adjustmentLevel.brightness,contrast:t.adjustmentLevel.contrast,hue:t.adjustmentLevel.hue,saturation:t.adjustmentLevel.saturation,opacity:t.adjustmentLevel.opacity,blur:t.adjustmentLevel.blur,exposure:t.adjustmentLevel.exposure,transparency:t.adjustmentLevel.transparency}[""+e]},a.prototype.transformSelect=function(e){this.isCropToolbar=!0,this.allowDownScale=!1,this.setInitialZoomState();var i=t.extend({},this.activeObj,{},!0);this.cropSelectedState(),this.notify("draw",{prop:"resetCurrentSelectionPoint"}),this.updateImageTransformColl(e),this.notify("transform",{prop:"performTransformation",value:{text:e}}),this.notify("draw",{prop:"moveToSelectionRange",value:{type:e,activeObj:i}}),this.isCropToolbar=!1},a.prototype.getDefaultFilter=function(){return"brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},a.prototype.initializeImageEditor=function(e,o){this.element=e,t.isBlazor()&&this.element.querySelector(".place-holder")&&this.element.querySelector(".place-holder").remove(),this.element.offsetWidth>359&&this.element.querySelector(".e-ie-min-drop-content")&&this.element.querySelector(".e-ie-drop-content")&&(this.element.querySelector(".e-ie-min-drop-content").style.display="none",this.element.querySelector(".e-ie-drop-content").style.display="block"),t.isBlazor()&&this.element.querySelector(".e-ie-drop-area")&&(this.element.querySelector(".e-ie-drop-area").style.display="block"),t.isBlazor()&&this.element.querySelector(".e-toolbar-area")&&(this.element.querySelector(".e-toolbar-area").style.display="block");var r=this.element.querySelector(".e-canvas-wrapper");this.element.querySelector("#"+this.element.id+"_toolbarArea")?this.toolbarHeight=this.element.querySelector("#"+this.element.id+"_toolbarArea").clientHeight:this.toolbarHeight=0,r.style.height=this.element.offsetHeight-this.toolbarHeight-2+"px",r.style.width=this.element.offsetWidth-2+"px",this.lowerCanvas=this.element.querySelector(".e-lower-canvas"),this.upperCanvas=this.element.querySelector(".e-upper-canvas"),this.lowerCanvas.id=this.element.id+"_lowerCanvas",this.upperCanvas.id=this.element.id+"_upperCanvas",this.textArea=this.element.querySelector(".e-textbox"),this.inMemoryCanvas=this.createElement("canvas",{id:this.element.id+"_inMemoryCanvas",attrs:{name:"canvasImage"}}),this.baseImgCanvas=this.createElement("canvas",{id:this.element.id+"_baseImgCanvas",attrs:{name:"canvasImage"}}),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.lowerContext=this.lowerCanvas.getContext("2d"),this.baseImg=this.createElement("img",{id:this.element.id+"_orgImg",attrs:{name:"Image",crossorigin:"anonymous"}}),this.upperContext=this.upperCanvas.getContext("2d"),this.inMemoryContext=this.inMemoryCanvas.getContext("2d"),o&&(this.dotNetRef=o),this.prerender(),this.wireEvent(),this.lowerContext.filter=this.getDefaultFilter(),this.notify("filter",{prop:"setAdjustmentValue",onPropertyChange:!1,value:{adjustmentValue:this.lowerContext.filter}}),this.canvasFilter=this.initialAdjustmentValue=this.lowerContext.filter,this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.element&&i.createSpinner({target:this.element}),this.initializeZoomSettings()},a.prototype.prerender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-image-editor"),t.Browser.isDevice&&this.element.classList.add("e-device"),this.initializeThemeColl()},a.prototype.initializeZoomSettings=function(){t.isNullOrUndefined(this.zoomSettings.zoomTrigger)&&(this.zoomSettings.zoomTrigger=e.ZoomTrigger.MouseWheel|e.ZoomTrigger.Pinch|e.ZoomTrigger.Toolbar|e.ZoomTrigger.Commands),t.isNullOrUndefined(this.selectionSettings.strokeColor)&&(this.selectionSettings.strokeColor=this.themeColl[this.theme].primaryColor),t.isNullOrUndefined(this.selectionSettings.fillColor)&&(this.selectionSettings.fillColor=this.themeColl[this.theme].secondaryColor)},a.prototype.initializeThemeColl=function(){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"},Material3:{primaryColor:"#6750a4",secondaryColor:"#fff"},Material3Dark:{primaryColor:"#d0bcff",secondaryColor:"#fff"}}},a.prototype.updateToolbar=function(e,t,i){},a.prototype.triggerShapeChanged=function(e){t.isBlazor()&&this.events&&!0===this.events.shapeChanged.hasDelegate&&this.dotNetRef.invokeMethodAsync("ShapeEventAsync","ShapeChanged",e)};var y;return b([t.Property("")],a.prototype,"cssClass",void 0),b([t.Property(!1)],a.prototype,"disabled",void 0),b([t.Property("100%")],a.prototype,"height",void 0),b([t.Property("Bootstrap5")],a.prototype,"theme",void 0),b([t.Property()],a.prototype,"toolbar",void 0),b([t.Property()],a.prototype,"toolbarTemplate",void 0),b([t.Property("100%")],a.prototype,"width",void 0),b([t.Property(!0)],a.prototype,"allowUndoRedo",void 0),b([t.Property(!0)],a.prototype,"showQuickAccessToolbar",void 0),b([t.Property()],a.prototype,"quickAccessToolbarTemplate",void 0),b([t.Property(!1)],a.prototype,"isReadOnly",void 0),b([t.Property(!1)],a.prototype,"enableRtl",void 0),b([t.Property(!1)],a.prototype,"enablePersistence",void 0),b([t.Complex({},f)],a.prototype,"finetuneSettings",void 0),b([t.Complex({},m)],a.prototype,"zoomSettings",void 0),b([t.Complex({},C)],a.prototype,"selectionSettings",void 0),b([t.Event()],a.prototype,"beforeSave",void 0),b([t.Event()],a.prototype,"created",void 0),b([t.Event()],a.prototype,"destroyed",void 0),b([t.Event()],a.prototype,"zooming",void 0),b([t.Event()],a.prototype,"panning",void 0),b([t.Event()],a.prototype,"cropping",void 0),b([t.Event()],a.prototype,"rotating",void 0),b([t.Event()],a.prototype,"flipping",void 0),b([t.Event()],a.prototype,"shapeChanging",void 0),b([t.Event()],a.prototype,"selectionChanging",void 0),b([t.Event()],a.prototype,"fileOpened",void 0),b([t.Event()],a.prototype,"saved",void 0),b([t.Event()],a.prototype,"toolbarCreated",void 0),b([t.Event()],a.prototype,"toolbarUpdating",void 0),b([t.Event()],a.prototype,"toolbarItemClicked",void 0),b([t.Event()],a.prototype,"imageFiltering",void 0),b([t.Event()],a.prototype,"finetuneValueChanging",void 0),b([t.Event()],a.prototype,"click",void 0),b([t.Event()],a.prototype,"quickAccessToolbarOpen",void 0),b([t.Event()],a.prototype,"resizing",void 0),b([t.Event()],a.prototype,"quickAccessToolbarItemClick",void 0),b([t.Event()],a.prototype,"frameChange",void 0),a=y=b([t.NotifyPropertyChanges],a)}(t.Component);!function(e){e.Png="Png",e.Jpeg="Jpeg",e.Svg="Svg"}(e.FileType||(e.FileType={})),function(e){e.Horizontal="Horizontal",e.Vertical="Vertical"}(e.Direction||(e.Direction={})),function(e){e.Rectangle="Rectangle",e.Ellipse="Ellipse",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Text="Text",e.FreehandDraw="FreehandDraw",e.Image="Image"}(e.ShapeType||(e.ShapeType={})),function(e){e[e.MouseWheel=1]="MouseWheel",e[e.Pinch=2]="Pinch",e[e.Commands=4]="Commands",e[e.Toolbar=8]="Toolbar"}(e.ZoomTrigger||(e.ZoomTrigger={})),function(e){e.Bootstrap5="Bootstrap5",e.Bootstrap5Dark="Bootstrap5Dark",e.Tailwind="Tailwind",e.TailwindDark="TailwindDark",e.Fluent="Fluent",e.FluentDark="FluentDark",e.Bootstrap4="Bootstrap4",e.Bootstrap="Bootstrap",e.BootstrapDark="BootstrapDark",e.Material="Material",e.MaterialDark="MaterialDark",e.Fabric="Fabric",e.FabricDark="FabricDark",e.Highcontrast="Highcontrast"}(e.Theme||(e.Theme={})),function(e){e.Crop="Crop",e.Transform="Transform",e.Annotate="Annotate",e.ZoomIn="ZoomIn",e.ZoomOut="ZoomOut",e.Open="Open",e.Reset="Reset",e.Save="Save",e.Pan="Pan",e.Move="Move",e.Pen="Pen",e.Line="Line",e.Arrow="Arrow",e.Path="Path",e.Rectangle="Rectangle",e.Image="Image",e.Ellipse="Ellipse",e.Text="Text",e.CustomSelection="CustomSelection",e.CircleSelection="CircleSelection",e.SquareSelection="SquareSelection",e.RatioSelection="RatioSelection",e.RotateLeft="RotateLeft",e.RotateRight="RotateRight",e.FlipHorizontal="FlipHorizontal",e.FlipVertical="FlipVertical",e.Undo="Undo",e.Redo="Redo",e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Inset="Inset",e.Hook="Hook",e.Finetune="Finetune",e.Filter="Filter",e.Frame="Frame",e.Resize="Resize",e.HorizontalFlip="HorizontalFlip",e.VerticalFlip="VerticalFlip",e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Opacity="Opacity",e.Blur="Blur",e.Exposure="Exposure",e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert"}(e.ImageEditorCommand||(e.ImageEditorCommand={})),function(e){e.Default="Default",e.Chrome="Chrome",e.Cold="Cold",e.Warm="Warm",e.Grayscale="Grayscale",e.Sepia="Sepia",e.Invert="Invert"}(e.ImageFilterOption||(e.ImageFilterOption={})),function(e){e.Brightness="Brightness",e.Contrast="Contrast",e.Hue="Hue",e.Saturation="Saturation",e.Exposure="Exposure",e.Opacity="Opacity",e.Blur="Blur"}(e.ImageFinetuneOption||(e.ImageFinetuneOption={})),function(e){e.None="None",e.Arrow="Arrow",e.SolidArrow="SolidArrow",e.Circle="Circle",e.SolidCircle="SolidCircle",e.Square="Square",e.SolidSquare="SolidSquare",e.Bar="Bar"}(e.ArrowheadType||(e.ArrowheadType={})),function(e){e.None="None",e.Mat="Mat",e.Bevel="Bevel",e.Line="Line",e.Inset="Inset",e.Hook="Hook"}(e.FrameType||(e.FrameType={})),function(e){e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted"}(e.FrameLineStyle||(e.FrameLineStyle={}));var j=function(){function n(e){this.defToolbarItems=[],this.toolbarHeight=46,this.currToolbar="",this.preventZoomBtn=!1,this.currentToolbar="main",this.selFhdColor="#42a5f5",this.preventEnableDisableUr=!1,this.isAspectRatio=!0,this.isFrameToolbar=!1,this.parent=e,this.addEventListener(),this.initLocale()}return n.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},n.prototype.addEventListener=function(){this.parent.on("toolbar",this.toolbar,this),this.parent.on("destroyed",this.destroy,this)},n.prototype.removeEventListener=function(){this.parent.off("toolbar",this.toolbar),this.parent.off("destroyed",this.destroy)},n.prototype.initLocale=function(){this.defaultLocale={Crop:"Crop",ZoomIn:"Zoom In",ZoomOut:"Zoom Out",Undo:"Undo",Redo:"Redo",Transform:"Transform",Annotation:"Annotation",Finetune:"Finetune",Brightness:"Brightness",Contrast:"Contrast",Hue:"Hue",Saturation:"Saturation",Opacity:"Opacity",Blur:"Blur",Sharpen:"Sharpen",Exposure:"Exposure",Filter:"Filter",Default:"Default",Chrome:"Chrome",Cold:"Cold",Warm:"Warm",Grayscale:"Grayscale",BlackAndWhite:"Black and White",Sepia:"Sepia",Invert:"Invert",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",Arrow:"Arrow",Path:"Path",Bold:"Bold",Italic:"Italic",BoldItalic:"Bold Italic",XSmall:"X-Small",Small:"Small",Medium:"Medium",Large:"Large",XLarge:"X-Large",ABC:"ABC",Browse:"Browse",Duplicate:"Duplicate",Remove:"Remove",EditText:"Edit Text",Start:"Start",End:"End",Bar:"Bar",ArrowSolid:"Arrow Solid",CircleSolid:"Circle Solid",SquareSolid:"Square Solid",None:"None",CropAndTransform:"Crop and Transform",CropSelection:"Crop Selection",Image:"Add Image",Transparency:"Transparency",Height:"Height",Width:"Width",AspectRatio:"Maintain aspect ratio",W:"W",H:"H",DragText:"Drag and drop your image here or",DropText:"Drop your image here or",BrowseText:"Browse here...",SupportText:"Supports:",Frame:"Frame",Mat:"Mat",Bevel:"Bevel",Inset:"Inset",Hook:"Hook",Color:"Color",Size:"Size",Offset:"Offset",Radius:"Radius",Amount:"Amount",Resize:"Resize",0:"0%",20:"20%",40:"40%",60:"60%",80:"80%",100:"100%",1:"1",2:"2",3:"3",4:"4",5:"5",Border:"Border",Solid:"Solid",Dashed:"Dashed",Dotted:"Dotted",GradientColor:"Gradient Color",ConfirmDialogHeader:"Confirm Save Changes",ConfirmDialogContent:"Do you want to save the changes you made to the image?",AlertDialogHeader:"Unsupported file",AlertDialogContent:"The dropped file is unsupported.",Yes:"Yes",No:"No",ImageErrorDialogHeader:"Image Selection Error",ImageErrorDialogContent:"Please select only one image to open."},this.l10n=new t.L10n("image-editor",this.defaultLocale,this.parent.locale)},n.prototype.toolbar=function(e){var t=this.parent;switch(this.updatePrivateVariables(),e.prop){case"create-toolbar":this.createToolbar();break;case"create-contextual-toolbar":this.createContextualToolbar();break;case"update-toolbar-items":this.updateToolbarItems();break;case"refresh-toolbar":this.refreshToolbar(e.value.type,e.value.isApplyBtn,e.value.isCropping,e.value.isZooming,e.value.cType);break;case"renderQAT":this.renderQAT(e.value.isPenEdit);break;case"enable-disable-btns":this.enableDisableTbrBtn();break;case"init-main-toolbar":this.initMainToolbar(e.value.isApplyBtn,e.value.isDevice,e.value.isOkBtn,e.value.isResize);break;case"create-bottom-toolbar":this.createBottomToolbar();break;case"refresh-main-toolbar":this.refreshMainToolbar();break;case"create-qa-toolbar":this.createQuickAccessToolbar();break;case"destroy-qa-toolbar":this.destroyQuickAccessToolbar();break;case"zoom-up-handler":this.zoomBtnMouseUpHandler();break;case"refresh-dropdown-btn":this.refreshDropDownBtn(e.value.isDisabled);break;case"close-contextual-toolbar":this.closeContextualToolbar();break;case"destroy-bottom-toolbar":this.destroyBottomToolbar();break;case"destroy-top-toolbar":this.destroyTopToolbar();break;case"destroySubComponents":this.destroySubComponents();break;case"setLocale":this.l10n.setLocale(e.value.locale);break;case"setPreventZoomBtn":this.preventZoomBtn=e.value.isPrevent;break;case"getToolbarHeight":e.value.obj.toolbarHeight=this.toolbarHeight;break;case"setToolbarHeight":this.toolbarHeight=e.value.height;break;case"setCurrentToolbar":this.currentToolbar=e.value.type;break;case"setSelectedFreehandColor":this.selFhdColor=e.value.color;break;case"getCurrentFilter":e.value.obj.currentFilter=t.currentFilter;break;case"setCurrentFilter":t.currentFilter=e.value.filter;break;case"setInitialAdjustmentValue":t.initialAdjustmentValue=e.value.value;break;case"getCanvasFilter":e.value.obj.canvasFilter=t.canvasFilter;break;case"getDefToolbarItems":e.value.obj.defToolbarItems=this.defToolbarItems;break;case"getPenStroke":this.getPenStroke(e.value.value);break;case"performDefToolbarClickAction":this.performDefTbrClick(e.value.type,e.value.isContextualToolbar,e.value.isDisabledAdjustment,e.value.isDisabledFilter,e.value.isFilterFinetune);break;case"setTempFilterProperties":t.setTempFilterProperties();break;case"refreshSlider":this.refreshSlider();break;case"renderSlider":this.renderSlider(e.value.type);break;case"getCurrAdjustmentValue":t.getCurrAdjustmentValue(e.value.type);break;case"setCurrAdjustmentValue":t.setCurrAdjustmentValue(e.value.type,e.value.value);break;case"refreshShapeDrawing":this.refreshShapeDrawing();break;case"getCropToolbar":e.value.obj.isCropToolbar=t.isCropToolbar;break;case"getPrevCurrSelectionPoint":e.value.obj.prevCurrSelectionPoint=t.prevCurrSelectionPoint;break;case"setPrevCurrSelectionPoint":t.prevCurrSelectionPoint=e.value.point;break;case"updateCropTransformItems":t.updateCropTransformItems();break;case"setEnableDisableUndoRedo":this.preventEnableDisableUr=e.value.isPrevent;break;case"reset":this.reset();break;case"getLocaleText":e.value.obj.value=this.l10n.getConstant(e.value.obj.key);break;case"initResizeToolbar":this.initResizeToolbar();break;case"getFrameToolbar":e.value.obj.bool=this.isFrameToolbar;break;case"callFrameToolbar":this.callFrameToolbar();break;case"resizeClick":this.resizeClick();break;case"frameToolbarClick":this.frameToolbarClick()}},n.prototype.updatePrivateVariables=function(){var e=this.parent;this.inMemoryCanvas=e.inMemoryCanvas,e.lowerCanvas&&(this.lowerContext=e.lowerCanvas.getContext("2d")),e.upperCanvas&&(this.upperContext=e.upperCanvas.getContext("2d")),this.inMemoryCanvas&&(this.inMemoryContext=this.inMemoryCanvas.getContext("2d"))},n.prototype.reset=function(){var e=this.parent;this.defToolbarItems=[],this.toolbarHeight=46,e.prevCurrSelectionPoint=null,this.zoomBtnHold=null,this.currToolbar="",e.cxtTbarHeight=null,this.currentToolbar="main",this.selFhdColor="#42a5f5",e.currentFilter="",this.preventZoomBtn=e.isCropToolbar=this.preventEnableDisableUr=this.isFrameToolbar=!1,e.initialAdjustmentValue=e.canvasFilter="brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)"},n.prototype.destroyTopToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_toolbar");this.isToolbar()&&i&&i.classList.contains("e-control")&&t.getComponent(document.getElementById(e.element.id+"_toolbar"),"toolbar").destroy()},n.prototype.destroyBottomToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_bottomToolbar");i&&i.classList.contains("e-control")&&t.getComponent(document.getElementById(e.element.id+"_bottomToolbar"),"toolbar").destroy()},n.prototype.isToolbar=function(){var e=this.parent;return t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0||!t.isNullOrUndefined(e.toolbarTemplate)},n.prototype.createToolbar=function(){var e=this,i=this.parent;if(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){i.element.appendChild(i.createElement("div",{id:i.element.id+"_toolbarArea",className:"e-toolbar-area"}));var a={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})};t.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(a);var n=document.getElementById(i.element.id+"_toolbarArea"),s=i.createElement("div",{id:i.element.id+"_toolbar"});n.appendChild(s);var l=[{cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1,selected:function(){i.disabled||(t.Browser.isDevice?(e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&t.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(i.element.id+"_bottomToolbar")&&t.getComponent(document.getElementById(i.element.id+"_bottomToolbar"),"toolbar").destroy(),e.initMainToolbar(!1,t.Browser.isDevice,null),e.createBottomToolbar()):(e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&t.getComponent(document.getElementById(i.element.id+"_toolbar"),"toolbar").destroy(),e.initMainToolbar(!1,!1,null)))}})}];new r.Toolbar({items:l,width:"100%",created:function(){i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_toolbar"),this.createLeftToolbarControls(),document.getElementById(i.element.id+"_toolbar")&&(this.toolbarHeight=document.getElementById(i.element.id+"_toolbar").clientHeight)}else this.toolbarHeight=0},n.prototype.createContextualToolbar=function(){var e=this.parent;if(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0){e.element.appendChild(e.createElement("div",{id:e.element.id+"_contextualToolbarArea",className:"e-contextual-toolbar-wrapper e-hide",attrs:{style:"position: absolute;"}}));var i=document.getElementById(e.element.id+"_contextualToolbarArea"),o=e.createElement("div",{id:e.element.id+"_contextualToolbar"});i.appendChild(o)}},n.prototype.createBottomToolbar=function(){var e=this.parent;if(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.length>0){if(e.element.appendChild(e.createElement("div",{id:e.element.id+"_bottomToolbarArea",className:"e-bottom-toolbar"})),!e.toolbarTemplate){document.getElementById(e.element.id+"_canvasWrapper").style.height=e.element.offsetHeight-2*this.toolbarHeight-3+"px";var i=document.getElementById(e.element.id+"_bottomToolbarArea"),o=e.createElement("div",{id:e.element.id+"_bottomToolbar"});i.appendChild(o)}this.initBottomToolbar()}},n.prototype.createQuickAccessToolbar=function(){var e=this.parent;if(e.showQuickAccessToolbar){var i={cssClass:"e-image-upload",align:"Left",type:"Input",tooltipText:this.l10n.getConstant("Browse"),template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})};t.isNullOrUndefined(this.defToolbarItems)&&(this.defToolbarItems=[]),this.defToolbarItems.push(i);var a=document.getElementById(e.element.id+"_quickAccessToolbarArea"),n=e.createElement("div",{id:e.element.id+"_quickAccessToolbar"});a.appendChild(n);new r.Toolbar({clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+e.element.id+"_quickAccessToolbar")}},n.prototype.initMainToolbar=function(e,i,o,a,n){var s=this,l=this.parent;if(this.isToolbar()){var p=this.getLeftToolbarItem(o,a),h=this.getRightToolbarItem(o),c=this.getMainToolbarItem(e,n),d=this.getZoomToolbarItem();this.defToolbarItems=i?n?c:p.concat(h):p.concat(c,h,d);var v=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i||s.renderAnnotationBtn(),s.wireZoomBtnEvents(),s.renderSaveBtn(),l.trigger("toolbarCreated",{toolbarType:"main"})}});if(i&&n?v.appendTo("#"+l.element.id+"_bottomToolbar"):v.appendTo("#"+l.element.id+"_toolbar"),this.createLeftToolbarControls(),this.enableDisableTbrBtn(),this.isToolbar()&&document.getElementById(l.element.id+"_toolbar")){t.getComponent(l.element.id+"_toolbar","toolbar").refreshOverflow()}}},n.prototype.initBottomToolbar=function(){var e=this,i=this.parent;if(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.length>0){var o=this.getMainToolbarItem();if(new r.Toolbar({items:o,width:"100%",created:function(){e.renderAnnotationBtn(),e.renderCropBtn(),e.renderTransformBtn(),i.trigger("toolbarCreated",{toolbarType:"main"})},clicked:this.defToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_bottomToolbar"),this.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}},n.prototype.getLeftToolbarItem=function(i,r){var a=this.parent,n=[];i&&!r||(n.push({id:a.element.id+"_upload",cssClass:"e-image-upload",align:"Left",type:"Input",template:new o.Uploader({allowedExtensions:".jpg, .jpeg, .png,.svg",multiple:!1})}),n.push({visible:!1,cssClass:"e-image-position e-btn e-flat",tooltipText:this.l10n.getConstant("Browse"),align:"Left"})),a.allowUndoRedo&&!r&&((t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("Undo")>-1)&&n.push({id:a.element.id+"_undo",prefixIcon:"e-icons e-undo",cssClass:"top-icon e-undo",tooltipText:this.l10n.getConstant("Undo"),align:"Left"}),(t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("Redo")>-1)&&n.push({id:a.element.id+"_redo",prefixIcon:"e-icons e-redo",cssClass:"top-icon e-redo",tooltipText:this.l10n.getConstant("Redo"),align:"Left"})),this.preventZoomBtn||(a.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)!==e.ZoomTrigger.Toolbar||r||((t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("ZoomOut")>-1)&&n.push({id:a.element.id+"_zoomOut",prefixIcon:"e-icons e-zoom-out",cssClass:"top-icon e-dec-zoom",tooltipText:this.l10n.getConstant("ZoomOut"),align:"Left"}),(t.isNullOrUndefined(a.toolbar)||a.toolbar&&a.toolbar.indexOf("ZoomIn")>-1)&&n.push({id:a.element.id+"_zoomIn",prefixIcon:"e-icons e-zoom-in",cssClass:"top-icon e-inc-zoom",tooltipText:this.l10n.getConstant("ZoomIn"),align:"Left"}));for(var s=this.processToolbar("left"),l=0,p=s.length;l<p;l++)n.push(s[l]);return n},n.prototype.getRightToolbarItem=function(e){var i=this.parent,o=[];e&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Reset")>-1)&&o.push({id:i.element.id+"_reset",prefixIcon:"e-icons e-btn-reset",cssClass:"top-icon e-img-reset",tooltipText:this.l10n.getConstant("Reset"),align:"Right"}),e||(t.isNullOrUndefined(i.toolbar)||i.toolbar&&i.toolbar.indexOf("Save")>-1)&&o.push({id:i.element.id+"_save",prefixIcon:"e-icons e-btn-save",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Save"),align:"Right",template:'<button id="'+i.element.id+'_saveBtn"></button>'});for(var r=this.processToolbar("right"),a=0,n=r.length;a<n;a++)o.push(r[a]);return o},n.prototype.getMainToolbarItem=function(e,i){var o=this.parent,r=[];i?((t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("None")>-1)&&r.push({id:this.parent.element.id+"_none",prefixIcon:"e-icons e-frame-none",cssClass:"top-icon e-frame-none",tooltipText:this.l10n.getConstant("None"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Mat")>-1)&&r.push({id:this.parent.element.id+"_mat",prefixIcon:"e-icons e-frame-mat",cssClass:"top-icon e-frame-mat",tooltipText:this.l10n.getConstant("Mat"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Bevel")>-1)&&r.push({id:this.parent.element.id+"_bevel",prefixIcon:"e-icons e-frame-bevel",cssClass:"top-icon e-frame-bevel",tooltipText:this.l10n.getConstant("Bevel"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Line")>-1)&&r.push({id:this.parent.element.id+"_line",prefixIcon:"e-icons e-frame-line",cssClass:"top-icon e-frame-line",tooltipText:this.l10n.getConstant("Line"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Inset")>-1)&&r.push({id:this.parent.element.id+"_inset",prefixIcon:"e-icons e-frame-inset",cssClass:"top-icon e-frame-inset",tooltipText:this.l10n.getConstant("Inset"),align:"Center"}),(t.isNullOrUndefined(this.parent.toolbar)||!t.isNullOrUndefined(this.parent.toolbar)&&this.parent.toolbar.indexOf("Hook")>-1)&&r.push({id:this.parent.element.id+"_hook",prefixIcon:"e-icons e-frame-hook",cssClass:"top-icon e-frame-hook",tooltipText:this.l10n.getConstant("Hook"),align:"Center"})):((t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Crop")>-1)&&r.push({id:o.element.id+"_cropTransform",prefixIcon:"e-icons e-crop",cssClass:"top-icon e-crop",tooltipText:this.l10n.getConstant("CropAndTransform"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Annotate")>-1)&&r.push({id:o.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+o.element.id+'_annotationBtn"></button>'}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Finetune")>-1)&&r.push({id:o.element.id+"_adjustment",prefixIcon:"e-icons e-adjustment",cssClass:"top-icon e-adjustment",tooltipText:this.l10n.getConstant("Finetune"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||o.toolbar&&o.toolbar.indexOf("Filter")>-1)&&r.push({id:o.element.id+"_filter",prefixIcon:"e-icons e-filters",cssClass:"top-icon e-filters",tooltipText:this.l10n.getConstant("Filter"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Frame")>-1)&&r.push({id:o.element.id+"_frame",prefixIcon:"e-icons e-border-frame",cssClass:"top-icon e-border-frame",tooltipText:this.l10n.getConstant("Frame"),align:"Center"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Resize")>-1)&&r.push({id:o.element.id+"_resize",prefixIcon:"e-icons e-resize",cssClass:"top-icon e-resize",tooltipText:this.l10n.getConstant("Resize"),align:"Center"}));for(var a=this.processToolbar("center"),n=0,s=a.length;n<s;n++)r.push(a[n]);return e&&(r.push({id:o.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),r.push({id:o.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),r},n.prototype.getZoomToolbarItem=function(){return[]},n.prototype.updateContextualToolbar=function(e,i){var o=this.parent,r=o.element.querySelector("#"+o.element.id+"_toolbarArea"),a=o.element.querySelector("#"+o.element.id+"_contextualToolbarArea");if(a.classList.remove("e-hide"),a.style.left=r.offsetLeft+"px","filter"===e?(document.getElementById(o.element.id+"_toolbar")&&this.defToolbarItems.length>0&&t.getComponent(document.getElementById(o.element.id+"_toolbar"),"toolbar").destroy(),t.Browser.isDevice?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!0,null,null),this.refreshSlider(),this.initFilterToolbarItem()):(document.querySelector("#"+o.element.id+"_contextualToolbar").classList.contains("e-control")&&t.getComponent(document.getElementById(o.element.id+"_contextualToolbar"),"toolbar").destroy(),this.refreshSlider(),"frame"===e?this.initFrameToolbarItem():this.renderSlider(i)),t.Browser.isDevice){var n=a.offsetHeight;this.isFrameToolbar&&o.element.querySelector("#"+o.element.id+"_customizeWrapper")&&(n=o.element.querySelector("#"+o.element.id+"_customizeWrapper").offsetHeight);var s=o.element.querySelector("#"+o.element.id+"_canvasWrapper").offsetHeight;a.style.top=this.toolbarHeight+s-n+"px"}else a.style.top=this.toolbarHeight+"px"},n.prototype.processToolbar=function(e){var i=this.parent,o=[];if(i.toolbar)for(var r=0,a=i.toolbar.length;r<a;r++)"object"==typeof i.toolbar[r]&&(t.isNullOrUndefined(i.toolbar[r].align)?"left"===e&&o.push(i.toolbar[r]):i.toolbar[r].align.toLowerCase()===e&&o.push(i.toolbar[r]));return o},n.prototype.processSubToolbar=function(e){var t=[];if(e)for(var i=0,o=e.length;i<o;i++)"object"==typeof e[i]&&(e[i].align="Center",t.push(e[i]));return t},n.prototype.wireZoomBtnEvents=function(){var e=document.querySelector("#"+this.parent.element.id+"_zoomIn"),t=document.querySelector("#"+this.parent.element.id+"_zoomOut");e&&(e.addEventListener("mousedown",this.zoomInBtnMouseDownHandler.bind(this)),e.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),e.addEventListener("click",this.zoomInBtnClickHandler.bind(this)),e.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this))),t&&(t.addEventListener("mousedown",this.zoomOutBtnMouseDownHandler.bind(this)),t.addEventListener("mouseup",this.zoomBtnMouseUpHandler.bind(this)),t.addEventListener("click",this.zoomOutBtnClickHandler.bind(this)),e.addEventListener("touchstart",this.zoomInBtnClickHandler.bind(this)))},n.prototype.widthAspectRatio=function(e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+"_resizeHeight"),r=i.element.querySelector("#"+i.element.id+"_resizeWidth"),a=i.element.querySelector("#"+i.element.id+"_aspectratio"),n=i.img.destWidth,s=i.img.destHeight,l=parseFloat(o.value),p=Math.floor(l/(s/n));a&&(null==p||isNaN(p)?(t.getComponent(r,"numerictextbox").value=0,r.value="0 px"):(t.getComponent(r,"numerictextbox").value=p,r.value=p.toString()+" px"))},n.prototype.heightAspectRatio=function(e){var i=this.parent,o=i.element.querySelector("#"+i.element.id+"_resizeHeight"),r=i.element.querySelector("#"+i.element.id+"_resizeWidth"),a=i.element.querySelector("#"+i.element.id+"_aspectratio"),n=i.img.destWidth,s=i.img.destHeight,l=parseFloat(r.value),p=Math.floor(l/(n/s));a&&!isNaN(p)?(t.getComponent(o,"numerictextbox").value=p,o.value=p.toString()+" px"):(t.getComponent(o,"numerictextbox").value=0,o.value="0 px")},n.prototype.getResizeToolbarItem=function(){var e=[],i=document.createElement("span");i.innerHTML=this.l10n.getConstant("W"),e.push({id:this.parent.element.id+"_width",cssClass:"e-ie-resize-width",template:i,align:"Center"}),e.push({id:this.parent.element.id+"_resizeWidth",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("Width"),align:"Center",type:"Input",template:new o.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:this.parent.aspectWidth&&this.parent.aspectHeight?this.parent.aspectWidth:Math.ceil(this.parent.img.destWidth),format:"###.## px"})});var r=document.createElement("span");return r.innerHTML=this.l10n.getConstant("H"),e.push({id:this.parent.element.id+"_height",cssClass:"e-ie-resize-height",template:r,align:"Center"}),e.push({id:this.parent.element.id+"_resizeHeight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("Height"),align:"Center",type:"Input",template:new o.NumericTextBox({width:75,htmlAttributes:{maxLength:"4"},showSpinButton:!1,value:this.parent.aspectWidth&&this.parent.aspectHeight?this.parent.aspectHeight:Math.ceil(this.parent.img.destHeight),format:"###.## px"})}),this.isAspectRatio?(e.push({id:this.parent.element.id+"_nonaspectratio",prefixIcon:"e-icons e-unlock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button"}),this.isAspectRatio=!1):(e.push({id:this.parent.element.id+"_aspectratio",prefixIcon:"e-icons e-lock",align:"Center",tooltipText:this.l10n.getConstant("AspectRatio"),type:"Button"}),this.isAspectRatio=!0),t.Browser.isDevice||(e.push({id:this.parent.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),e.push({id:this.parent.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),e},n.prototype.initResizeToolbar=function(){var e=this,i=this.getLeftToolbarItem(!1,!0),o=this.getRightToolbarItem(),a=this.getResizeToolbarItem(),n=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=a:this.defToolbarItems=i.concat(n,a,o);var s=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireResizeBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),e.parent.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?e.defToolbarItems.length>0&&!t.isNullOrUndefined(document.getElementById(e.parent.element.id+"_bottomToolbar"))&&s.refreshOverflow():(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&!t.isNullOrUndefined(document.getElementById(e.parent.element.id+"_toolbar"))&&s.refreshOverflow())}});t.Browser.isDevice?s.appendTo("#"+this.parent.element.id+"_bottomToolbar"):s.appendTo("#"+this.parent.element.id+"_toolbar"),this.parent.isResize=!1,this.enableDisableTbrBtn(),this.parent.isResize=!0,this.parent.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.wireResizeBtnEvents=function(){var e=this.parent,i=e.element.querySelector("#"+e.element.id+"_resizeHeight"),o=e.element.querySelector("#"+e.element.id+"_resizeWidth");e.element.querySelector("#"+e.element.id+"_aspectratio")&&(t.isNullOrUndefined(i)||o.addEventListener("keyup",this.heightAspectRatio.bind(this)),t.isNullOrUndefined(o)||i.addEventListener("keyup",this.widthAspectRatio.bind(this)))},n.prototype.enableDisableTbrBtn=function(){var e=this.parent;if(!this.preventEnableDisableUr){var t={appliedUndoRedoColl:[]};e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:t}});var i={undoRedoStep:null};e.notify("undo-redo",{prop:"getUndoRedoStep",value:{obj:i}});var o=e.element.querySelector("#"+e.element.id+"_undo");o&&0===i.undoRedoStep?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):o&&i.undoRedoStep>0&&(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay"));var r=e.element.querySelector("#"+e.element.id+"_redo");r&&i.undoRedoStep===t.appliedUndoRedoColl.length?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):r&&0===i.undoRedoStep&&t.appliedUndoRedoColl.length>0?(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")):r&&i.undoRedoStep>0&&(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay"))}var a=document.querySelector("#"+e.element.id+"_zoomIn");a&&e.zoomSettings.zoomFactor>=e.zoomSettings.maxZoomFactor?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):a&&(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay"));var n=document.querySelector("#"+e.element.id+"_zoomOut");n&&e.zoomSettings.zoomFactor<=e.zoomSettings.minZoomFactor?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):n&&(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay"));var s=document.querySelector("#"+e.element.id+"_frame");s&&(e.currSelectionPoint&&"crop-circle"===e.currSelectionPoint.shape||e.isCircleCrop)?s.classList.add("e-disabled"):s&&s.classList.remove("e-disabled")},n.prototype.createLeftToolbarControls=function(){var e=this.parent;if(void 0!==this.defToolbarItems&&this.defToolbarItems.length>0&&document.getElementById(e.element.id+"_toolbar")){var t=document.getElementById(e.element.id+"_toolbar").querySelector(".e-image-upload");if(t){var i=t.getElementsByTagName("input")[0],o=t.getElementsByTagName("button")[0];o.className="e-tbar-btn e-tbtn-txt top-icon",o.innerHTML="",o.appendChild(e.createElement("span",{className:"e-btn-icon e-icons e-upload-icon e-icon-left"})),i.onchange=this.fileSelect.bind(this,i)}}},n.prototype.fileSelect=function(e,t){var i=e.files[0].type.split("/")[1];"png"===i||"jpg"===i||"jpeg"===i||"svg"===i||"svg+xml"===i?this.parent.notify("draw",{prop:"fileSelect",value:{inputElement:e,args:t}}):this.parent.showDialogPopup()},n.prototype.renderAnnotationBtn=function(e){var i=this,o=this.parent,r=!1,n=[],s=["Ellipse","Arrow","Line","Rectangle","Pen","Path","Text"];if(o.toolbar)for(var l=0;l<s.length;l++)if(-1!==o.toolbar.indexOf(s[l])){r=!0;break}(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Pen")>-1)&&n.push({text:this.l10n.getConstant("Pen"),id:"pen",iconCss:"e-icons e-free-pen"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Line")>-1)&&n.push({text:this.l10n.getConstant("Line"),id:"line",iconCss:"e-icons e-line"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Rectangle")>-1)&&n.push({text:this.l10n.getConstant("Rectangle"),id:"rectangle",iconCss:"e-icons e-rectangle"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Ellipse")>-1)&&n.push({text:this.l10n.getConstant("Ellipse"),id:"ellipse",iconCss:"e-icons e-circle"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Arrow")>-1)&&n.push({text:this.l10n.getConstant("Arrow"),id:"arrow",iconCss:"e-icons e-arrow-right-up"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Path")>-1)&&n.push({text:this.l10n.getConstant("Path"),id:"path",iconCss:"e-icons e-critical-path"}),(t.isNullOrUndefined(o.toolbar)||!r||o.toolbar&&o.toolbar.indexOf("Text")>-1)&&n.push({text:this.l10n.getConstant("Text"),id:"text",iconCss:"e-icons e-add-text"}),(t.isNullOrUndefined(o.toolbar)||!t.isNullOrUndefined(o.toolbar)&&o.toolbar.indexOf("Image")>-1)&&n.push({text:this.l10n.getConstant("Image"),id:"image",iconCss:"e-icons e-image"});var p={freehandDrawSelectedId:null};o.notify("freehand-draw",{prop:"getFreehandDrawSelectedId",onPropertyChange:!1,value:{obj:p}});var h=document.querySelector("#"+o.element.id+"_duplicate"),c=document.querySelector("#"+o.element.id+"_remove"),d=document.querySelector("#"+o.element.id+"_editText");0===o.activeObj.activePoint.width&&0===o.activeObj.activePoint.height&&(t.isNullOrUndefined(o.activeObj.pointColl)||o.activeObj.pointColl&&0===o.activeObj.pointColl.length)&&t.isNullOrUndefined(p.freehandDrawSelectedId)?(h&&h.classList.add("e-disabled"),c&&c.classList.add("e-disabled"),d&&d.classList.add("e-disabled")):(h&&h.classList.remove("e-disabled"),c&&c.classList.remove("e-disabled"),d&&d.classList.remove("e-disabled"));var v=e?this.getCurrentShapeIcon(o.activeObj.shape):"e-annotation",u=new a.DropDownButton({items:n,iconCss:"e-icons "+v,cssClass:"e-image-popup",open:function(e){o.currObjType.isFiltered&&(o.okBtn(),o.element.querySelector("#"+i.parent.element.id+"_annotationBtn").click()),t.Browser.isDevice&&(e.element.parentElement.style.top=u.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px"),o.activeObj.shape?document.getElementById(o.activeObj.shape).classList.add("e-selected"):o.togglePen&&document.getElementById("pen").classList.add("e-selected")},select:function(e){o.okBtn();var t,r=!1;void 0!==o.activeObj.shape&&(t=o.activeObj.shape.split("-")),void 0===t&&o.currObjType.isCustomCrop?r=!0:void 0!==t&&"crop"===t[0]&&(r=!0),o.currObjType.isCustomCrop=!1,(r||o.togglePan)&&(o.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),i.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),i.refreshToolbar("main"));var a={currentFreehandDrawIndex:null};switch(o.notify("freehand-draw",{prop:"getCurrentFreehandDrawIndex",value:{obj:a}}),u.iconCss="e-icons "+i.getCurrentShapeIcon(e.item.id),e.item.id){case"pen":o.notify("draw",{prop:"setTempFreehandCounter",value:{tempFreehandCounter:o.freehandCounter}}),o.notify("draw",{prop:"setTempCurrentFreehandDrawIndex",value:{tempCurrentFreehandDrawIndex:a.currentFreehandDrawIndex}}),i.currentToolbar="pen",o.freeHandDraw(!0);break;case"text":i.currentToolbar="text",o.notify("shape",{prop:"draw-shape-text"});break;case"image":i.currentToolbar="shapes",o.element.querySelector("#"+i.parent.element.id+"_fileUpload").click();break;default:i.currentToolbar="shapes",i.setInitialShapeSettings(e),o.notify("selection",{prop:"annotate",value:{shape:e.item.id}}),o.notify("toolbar",{prop:"refresh-toolbar",onPropertyChange:!1,value:{type:"shapes",isApplyBtn:null,isCropping:null,isZooming:null,cType:null}})}i.updateToolbarItems()}});u.appendTo("#"+o.element.id+"_annotationBtn")},n.prototype.renderCropBtn=function(){var e=this,i=this.parent,o=[],r=!1,n=["CustomSelection","CircleSelection","SquareSelection","RatioSelection"];if(i.toolbar)for(var s=0;s<n.length;s++)if(-1!==i.toolbar.indexOf(n[s])){r=!0;break}(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("CustomSelection")>-1)&&o.push({text:this.l10n.getConstant("Custom"),id:"custom",iconCss:"e-icons e-custom"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("CircleSelection")>-1)&&o.push({text:this.l10n.getConstant("Circle"),id:"circle",iconCss:"e-icons e-circle"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("SquareSelection")>-1)&&o.push({text:this.l10n.getConstant("Square"),id:"square",iconCss:"e-icons e-square"}),(t.isNullOrUndefined(i.toolbar)||!r||i.toolbar&&i.toolbar.indexOf("RatioSelection")>-1)&&(o.push({text:"3:2",id:"3:2",iconCss:"e-icons e-custom-a"}),o.push({text:"4:3",id:"4:3",iconCss:"e-icons e-custom-b"}),o.push({text:"5:4",id:"5:4",iconCss:"e-icons e-custom-c"}),o.push({text:"7:5",id:"7:5",iconCss:"e-icons e-custom-d"}),o.push({text:"16:9",id:"16:9",iconCss:"e-icons e-custom-e"}));var l,p;i.activeObj.shape?(l=this.getCurrentShapeIcon(i.activeObj.shape),p=i.activeObj.shape):i.currSelectionPoint?(l=this.getCurrentShapeIcon(i.currSelectionPoint.shape),p=i.currSelectionPoint.shape):(l=o[0].iconCss,p=o[0].id);var h=new a.DropDownButton({open:function(o){i.togglePan&&e.cancelPan(),t.Browser.isDevice&&(o.element.parentElement.style.top=h.element.getBoundingClientRect().top-o.element.parentElement.offsetHeight+"px"),i.activeObj.shape&&i.activeObj.shape.split("-").length>1&&document.getElementById(i.activeObj.shape.split("-")[1]).classList.add("e-selected"),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},items:o,select:function(t){e.cropSelect(t),h.iconCss="e-icons "+e.getCurrentShapeIcon("crop-"+t.item.id),h.content=i.toPascalCase(t.item.id)},iconCss:"e-icons "+l,cssClass:"e-image-popup",content:i.toPascalCase(p.replace("crop-",""))});h.appendTo("#"+i.element.id+"_cropBtn")},n.prototype.renderTransformBtn=function(){var e=this.parent,i=[];(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("RotateLeft")>-1)&&i.push({text:this.l10n.getConstant("RotateLeft"),id:"rotateleft",iconCss:"e-icons e-anti-clock-wise"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("RotateRight")>-1)&&i.push({text:this.l10n.getConstant("RotateRight"),id:"rotateright",iconCss:"e-icons e-clock-wise"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("FlipHorizontal")>-1)&&i.push({text:this.l10n.getConstant("HorizontalFlip"),id:"horizontalflip",iconCss:"e-icons e-horizontal-flip"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&e.toolbar.indexOf("FlipVertical")>-1)&&i.push({text:this.l10n.getConstant("VerticalFlip"),id:"verticalflip",iconCss:"e-icons e-vertical-flip"});var o=new a.DropDownButton({open:function(e){if(t.Browser.isDevice){var i=e.element.parentElement.offsetHeight;e.element.parentElement.style.display="none",e.element.parentElement.style.top=o.element.getBoundingClientRect().top-i+"px",e.element.parentElement.style.display="block"}},items:i,select:e.transformSelect.bind(this),iconCss:"e-icons e-transform",cssClass:"e-image-popup"});o.appendTo("#"+e.element.id+"_transformBtn")},n.prototype.renderSaveBtn=function(){var e=this.parent;if(document.getElementById(e.element.id+"_saveBtn")){new a.DropDownButton({items:[{text:"JPEG",id:"jpeg"},{text:"PNG",id:"png"},{text:"SVG",id:"svg"}],cssClass:"e-caret-hide e-image-popup",iconCss:"e-icons e-save",select:function(t){e.export(t.item.text)}}).appendTo("#"+e.element.id+"_saveBtn")}},n.prototype.getCropTransformToolbarItem=function(){var e=this.parent,i=[];return i.push({id:e.element.id+"_crop",tooltipText:this.l10n.getConstant("CropSelection"),align:"Center",template:'<button id="'+e.element.id+'_cropBtn"></button>'}),i.push({align:"Center",type:"Separator"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateLeft")>-1))&&i.push({id:e.element.id+"_rotateLeft",prefixIcon:"e-icons e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("RotateRight")>-1))&&i.push({id:e.element.id+"_rotateRight",prefixIcon:"e-icons e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),i.length>2&&i.push({align:"Center",type:"Separator"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("HorizontalFlip")>-1))&&i.push({id:e.element.id+"_horizontalFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),(t.isNullOrUndefined(e.toolbar)||e.toolbar&&(e.toolbar.indexOf("Transform")>-1||e.toolbar.indexOf("VerticalFlip")>-1))&&i.push({id:e.element.id+"_verticalFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"}),t.Browser.isDevice||(i.push({id:e.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),i.push({id:e.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),i},n.prototype.getShapesToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("fillColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_fillcolor",cssClass:"top-icon e-fill",tooltipText:this.l10n.getConstant("FillColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fillColorBtn"></button>'}),e.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_strokecolor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&o.push({id:i.element.id+"_strokeWidth",cssClass:"top-icon e-size",tooltipText:"Stroke Width",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_borderWidthBtn"></button>'}),e.indexOf("start")>-1&&o.push({id:i.element.id+"_start",cssClass:"top-icon e-size",tooltipText:"Start",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_startBtn"></button>'}),e.indexOf("end")>-1&&o.push({id:i.element.id+"_end",cssClass:"top-icon e-size",tooltipText:"End",align:"Center",type:"Input",template:'<button id="'+i.element.id+'_endBtn"></button>'}),e.indexOf("flip")>-1&&(o.push({id:i.element.id+"_rotLeft",prefixIcon:"e-anti-clock-wise",tooltipText:this.l10n.getConstant("RotateLeft"),align:"Center"}),o.push({id:i.element.id+"_rotRight",prefixIcon:"e-clock-wise",tooltipText:this.l10n.getConstant("RotateRight"),align:"Center"}),o.push({id:i.element.id+"_hFlip",prefixIcon:"e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Center"}),o.push({id:i.element.id+"_vFlip",prefixIcon:"e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Center"})),o.push({align:"Center",type:"Separator"}),e.indexOf("transparency")>-1&&o.push({id:i.element.id+"_transparency",prefixIcon:"e-opacity",tooltipText:this.l10n.getConstant("Transparency"),align:"Center"}),o.push({align:"Center",type:"Separator"}),e.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center"}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"}),e.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center"});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);if(!t.Browser.isDevice){var s={shape:null};i.notify("selection",{prop:"getCurrentDrawingShape",value:{obj:s}}),"path"!==s.shape&&(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"}))}return o},n.prototype.initCropTransformToolbar=function(){var e=this,i=this.parent,o=this.getLeftToolbarItem(),a=this.getRightToolbarItem(),n=this.getCropTransformToolbarItem(),s=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=o.concat(s,n,a);var l=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.renderCropBtn(),e.wireZoomBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),i.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(l.refreshOverflow(),l.refreshOverflow(),l.refreshOverflow()):(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow()),document.getElementById(i.element.id+"_cropBtn")&&i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:document.getElementById(i.element.id+"_cropBtn").textContent.toLowerCase(),startX:null,startY:null,width:null,height:null}})}});t.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.getCurrentShapeIcon=function(e){var t="";switch(e){case"rectangle":t="e-rectangle";break;case"ellipse":t="e-circle";break;case"line":t="e-line";break;case"arrow":t="e-arrow-right-up";break;case"path":t="e-critical-path";break;case"text":t="e-add-text";break;case"image":t="e-image";break;case"pen":t="e-free-pen";break;case"crop-custom":t="e-custom";break;case"crop-circle":t="e-circle";break;case"crop-square":t="e-square";break;case"crop-3:2":t="e-custom-a";break;case"crop-4:3":t="e-custom-b";break;case"crop-5:4":t="e-custom-c";break;case"crop-7:5":t="e-custom-d";break;case"crop-16:9":t="e-custom-e";break;default:t="e-free-pen"}return t},n.prototype.initShapesToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getShapesToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createShapeColor(e),i.createShapeBtn(e),"arrow"===o.activeObj.shape&&(i.createStartBtn(),i.createEndBtn()),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"shapes"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createShapeColor=function(e){var i=this.parent;if(e.indexOf("fillColor")>-1){i.element.querySelector(".e-template.e-fill").appendChild(i.createElement("input",{id:i.element.id+"_shape_fill"}));var r=new o.ColorPicker({modeSwitcher:!1,noColor:!0,value:"",showButtons:!1,mode:"Palette",cssClass:"e-shape-fill-color",change:function(e){i.updateFillColor(e.currentValue.hex),""===e.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=e.currentValue.rgba),n.toggle()}},"#"+i.element.id+"_shape_fill"),n=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fillColorBtn");r.inline=!0,i.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item")}if(e.indexOf("strokeColor")>-1){i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_shape_stroke"}));var s=new o.ColorPicker({modeSwitcher:!1,noColor:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-shape-stroke-color",change:function(e){i.updateStrokeColor(e.currentValue.hex),l.element.children[0].style.backgroundColor=e.currentValue.rgba,l.toggle()}},"#"+i.element.id+"_shape_stroke"),l=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-shape-stroke-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_borderColorBtn");s.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createShapeBtn=function(e){var i=this.parent,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(e.indexOf("strokeWidth")>-1){var r=document.getElementById(i.element.id+"_borderWidthBtn"),n=document.createElement("span");n.innerHTML=this.l10n.getConstant("XSmall"),n.className="e-shape-stroke-width",r.appendChild(n);var s=new a.DropDownButton({items:o,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=n.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){if(n.textContent=e.item.text,i.updateStrokeWidth(e.item.id),t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});s.appendTo("#"+i.element.id+"_borderWidthBtn")}},n.prototype.createStartBtn=function(){var e=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(e.element.id+"_startBtn"),r=document.createElement("span");t.isNullOrUndefined(e.activeObj.start)&&(e.activeObj.start="none"),r.innerHTML=e.pascalToSplitWords(e.activeObj.start),r.className="e-shape-start",o.appendChild(r);var n=new a.DropDownButton({items:i,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=r.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){r.textContent=t.item.text,e.updateArrow("startArrow",t.item.id)}});n.appendTo("#"+e.element.id+"_startBtn")},n.prototype.createEndBtn=function(){var e=this.parent,i=[{id:"1",text:this.l10n.getConstant("None")},{id:"2",text:this.l10n.getConstant("Bar")},{id:"3",text:this.l10n.getConstant("Arrow")},{id:"4",text:this.l10n.getConstant("ArrowSolid")},{id:"5",text:this.l10n.getConstant("Circle")},{id:"6",text:this.l10n.getConstant("CircleSolid")},{id:"7",text:this.l10n.getConstant("Square")},{id:"8",text:this.l10n.getConstant("SquareSolid")}],o=document.getElementById(e.element.id+"_endBtn"),r=document.createElement("span");t.isNullOrUndefined(e.activeObj.end)&&(e.activeObj.end="arrowSolid"),r.innerHTML=e.pascalToSplitWords(e.activeObj.end),r.className="e-shape-end",o.appendChild(r);var n=new a.DropDownButton({items:i,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=r.innerHTML;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(t){r.textContent=t.item.text,e.updateArrow("endArrow",t.item.id)}});n.appendTo("#"+e.element.id+"_endBtn")},n.prototype.getTextToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("fontFamily")>-1&&o.push({id:i.element.id+"_fontFamily",cssClass:"top-icon e-img-font-family",tooltipText:this.l10n.getConstant("FontFamily"),align:"Center",template:'<button id="'+i.element.id+'_fontFamilyBtn"></button>'}),e.indexOf("fontSize")>-1&&o.push({id:i.element.id+"_fontSize",cssClass:"top-icon e-img-font-size",tooltipText:this.l10n.getConstant("FontSize"),align:"Center",template:'<button id="'+i.element.id+'_fontSizeBtn"></button>'}),e.indexOf("fontColor")>-1&&o.push({cssClass:"top-icon e-text-font-color",id:i.element.id+"_text_strokecolor",tooltipText:this.l10n.getConstant("FontColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_fontColorBtn"></button>'}),e.indexOf("bold")>-1&&o.push({id:i.element.id+"_bold",prefixIcon:"e-icons e-bold",cssClass:"top-icon e-bold",tooltipText:this.l10n.getConstant("Bold"),align:"Center"}),e.indexOf("italic")>-1&&o.push({id:i.element.id+"_italic",prefixIcon:"e-icons e-italic",cssClass:"top-icon e-italic",tooltipText:this.l10n.getConstant("Italic"),align:"Center"}),o.push({align:"Center",type:"Separator"}),e.indexOf("duplicate")>-1&&o.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Center",disabled:"block"===i.textArea.style.display}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center",disabled:"block"===i.textArea.style.display}),e.indexOf("text")>-1&&o.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Center",disabled:"block"===i.textArea.style.display});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);return t.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.getFontFamilyItems=function(){return t.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"}]},n.prototype.initTextToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getTextToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createTextColor(e),i.createTextBtn(e),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"text"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_bottomToolbar")&&(p.refreshOverflow(),p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createTextColor=function(e){var i=this.parent;if(e.indexOf("fontColor")>-1&&i.element.querySelector(".e-template.e-text-font-color")){i.element.querySelector(".e-template.e-text-font-color").appendChild(i.createElement("input",{id:i.element.id+"_text_font"}));var r=new o.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-text-fontt-color",change:function(e){i.updateFontColor(e.currentValue.hex),n.element.children[0].style.backgroundColor=e.currentValue.rgba,n.toggle()}},"#"+i.element.id+"_text_font"),n=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-text-fontt-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_fontColorBtn");r.inline=!0,i.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createTextBtn=function(e){var i=this.parent;if(e.indexOf("fontFamily")>-1){var o=document.getElementById(i.element.id+"_fontFamilyBtn"),r=document.createElement("span");t.Browser.isDevice?(r.innerHTML="ABC",r.setAttribute("style","font-family: arial")):r.innerHTML="Arial",r.className="e-text-font-family",o&&o.appendChild(r);var n=new a.DropDownButton({items:this.getFontFamilyItems(),cssClass:"e-font-family",createPopupOnClick:!0,beforeItemRender:function(e){e.element.setAttribute("style","font-family:"+e.element.id)},open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=n.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var o;o="block"===i.textArea.style.display?i.textArea.style.fontFamily:i.activeObj.textSettings.fontFamily,e.element.querySelector('[id *= "'+o.toLowerCase()+'"]').classList.add("e-selected-btn")},select:function(e){r.textContent=e.item.text,t.Browser.isDevice&&r.setAttribute("style","font-family:"+e.item.id),i.updateFontFamily(e.item.id)}});n.appendTo("#"+i.element.id+"_fontFamilyBtn")}if(e.indexOf("fontSize")>-1){var s=document.getElementById(i.element.id+"_fontSizeBtn"),l=document.createElement("span"),p=i.getFontSizes();l.innerHTML=p[0].text,l.className="e-text-font-size",s.appendChild(l);var h=new a.DropDownButton({cssClass:"e-font-size",items:p,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=h.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.innerHTML;e.element.querySelector('[aria-label *= "'+i+'"]').classList.add("e-selected-btn")},select:function(e){l.textContent=e.item.text,i.updateFontSize(e.item.text)}});h.appendTo("#"+i.element.id+"_fontSizeBtn")}},n.prototype.refreshToolbar=function(e,i,o,r,a){var n=this.parent;if(n.isImageLoaded&&!n.isCropToolbar){var s,l,p={toolbarType:"shapes"===e&&n.activeObj.shape?n.activeObj.shape:e};switch("filter"!==e&&"color"!==e&&(document.getElementById(n.element.id+"_customizeWrapper")&&t.getComponent(document.getElementById(n.element.id+"_customizeWrapper"),"toolbar")&&this.defToolbarItems.length>0&&(t.getComponent(document.getElementById(n.element.id+"_customizeWrapper"),"toolbar").destroy(),document.getElementById(n.element.id+"_customizeWrapper").innerHTML=""),document.getElementById(n.element.id+"_toolbar")&&this.defToolbarItems.length>0&&(t.getComponent(document.getElementById(n.element.id+"_toolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_toolbar").innerHTML=""),document.getElementById(n.element.id+"_bottomToolbar")&&this.defToolbarItems.length>0&&document.getElementById(n.element.id+"_bottomToolbar").className.indexOf("e-control")>-1&&(t.getComponent(document.getElementById(n.element.id+"_bottomToolbar"),"toolbar").destroy(),document.getElementById(n.element.id+"_bottomToolbar").innerHTML="")),this.refreshSlider(),this.isFrameToolbar=!1,n.isCropTab=!1,e){case"main":t.Browser.isDevice?o?this.initMainToolbar(!1,!0,!0):this.initMainToolbar(!1,!0,null):t.Browser.isDevice&&!r||this.initMainToolbar(i,t.Browser.isDevice,null),t.Browser.isDevice&&this.initBottomToolbar();break;case"shapes":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),"line"===n.activeObj.shape||"path"===n.activeObj.shape?p.toolbarItems=["strokeColor","strokeWidth","duplicate","remove"]:"arrow"===n.activeObj.shape?p.toolbarItems=["strokeColor","strokeWidth","start","end","duplicate","remove"]:"image"===n.activeObj.shape?p.toolbarItems=["flip","duplicate","remove","transparency"]:p.toolbarItems=["fillColor","strokeColor","strokeWidth","duplicate","remove"],n.trigger("toolbarUpdating",p),this.initShapesToolbarItem(p.toolbarItems);break;case"text":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),p.toolbarItems=["fontFamily","fontSize","fontColor","bold","italic","duplicate","remove","text"],n.trigger("toolbarUpdating",p),this.initTextToolbarItem(p.toolbarItems);break;case"pen":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),p.toolbarItems=["strokeColor","strokeWidth","remove"],n.trigger("toolbarUpdating",p),this.initPenToolbarItem(p.toolbarItems);break;case"adjustment":t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),this.initAdjustmentToolbarItem();break;case"filter":this.updateContextualToolbar(e);break;case"resize":this.initResizeToolbar(),t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0,!0),s=n.element.querySelector("#"+this.parent.element.id+"_aspectratio"),l=n.element.querySelector("#"+this.parent.element.id+"_nonaspectratio"),this.parent.aspectWidth&&this.parent.aspectHeight&&(l?n.notify("transform",{prop:"resize",value:{width:n.aspectWidth,height:n.aspectHeight,isAspectRatio:!1}}):s&&n.notify("transform",{prop:"resize",value:{width:n.aspectWidth,height:null,isAspectRatio:!0}}));break;case"color":this.updateContextualToolbar(e,a);break;case"croptransform":n.allowDownScale=!1,n.isCropTab=!0,t.Browser.isDevice&&this.initMainToolbar(!1,!0,!0),n.updateCropTransformItems(),this.initCropTransformToolbar();break;case"frame":this.isFrameToolbar=!0,t.Browser.isDevice?(this.initMainToolbar(!1,!0,!0),this.initMainToolbar(!1,!0,!0,!1,!0)):this.initMainToolbar(!0,null,null,!1,!0),n.element.querySelector("#"+n.element.id+"_"+n.frameObj.type)&&n.element.querySelector("#"+n.element.id+"_"+n.frameObj.type).classList.add("e-selected-btn"),"none"!==n.frameObj.type&&this.updateContextualToolbar(e,a),n.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}})}this.currToolbar=e,this.refreshDropDownBtn(o)}},n.prototype.getAdjustmentToolbarItem=function(){var e=[],i=this.parent,o=!1,r=["Brightness","Contrast","Hue","Saturation","Exposure","Opacity","Blur"];if(i.toolbar)for(var a=0;a<r.length;a++)if(-1!==i.toolbar.indexOf(r[a])){o=!0;break}(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Brightness")>-1)&&e.push({id:i.element.id+"_brightness",prefixIcon:"e-icons e-brightness",cssClass:"top-icon e-brightness",tooltipText:this.l10n.getConstant("Brightness"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Contrast")>-1)&&e.push({id:i.element.id+"_contrast",prefixIcon:"e-icons e-contrast",cssClass:"top-icon e-contrast",tooltipText:this.l10n.getConstant("Contrast"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Hue")>-1)&&e.push({id:i.element.id+"_hue",prefixIcon:"e-icons e-fade",cssClass:"top-icon e-fade",tooltipText:this.l10n.getConstant("Hue"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Saturation")>-1)&&e.push({id:i.element.id+"_saturation",prefixIcon:"e-icons e-saturation",cssClass:"top-icon e-saturation",tooltipText:this.l10n.getConstant("Saturation"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Exposure")>-1)&&e.push({id:i.element.id+"_exposure",prefixIcon:"e-icons e-grain",cssClass:"top-icon e-grain",tooltipText:this.l10n.getConstant("Exposure"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Opacity")>-1)&&e.push({id:i.element.id+"_opacity",prefixIcon:"e-icons e-opacity",cssClass:"top-icon e-opacity",tooltipText:this.l10n.getConstant("Opacity"),align:"Center"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Blur")>-1)&&e.push({id:i.element.id+"_blur",prefixIcon:"e-icons e-tint",cssClass:"top-icon e-tint",tooltipText:this.l10n.getConstant("Blur"),align:"Center"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return t.Browser.isDevice||(e.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),e.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),e},n.prototype.getFrameToolbarItem=function(){var e=this.parent,t=[];return t.push({prefixIcon:"e-icons e-copy",id:e.element.id+"_frameColor",cssClass:"top-icon e-stroke",tooltipText:this.l10n.getConstant("Color"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Color")+'</span><button id="'+e.element.id+'_frameColorBtn"></button>'}),t.push({prefixIcon:"e-icons e-copy",id:e.element.id+"_frameGradient",cssClass:"top-icon e-frame-stroke",tooltipText:this.l10n.getConstant("GradientColor"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("GradientColor")+'</span><button id="'+e.element.id+'_frameGradientColorBtn"></button>'}),t.push({id:e.element.id+"_frameSize",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Size"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Size")+'</span><button id="'+e.element.id+'_frameSizeBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type&&"hook"!==e.frameObj.type||t.push({id:e.element.id+"_frameInset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Inset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Inset")+'</span><button id="'+e.element.id+'_frameInsetBtn"></button>'}),"line"!==e.frameObj.type&&"inset"!==e.frameObj.type||t.push({id:e.element.id+"_frameOffset",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Offset"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Offset")+'</span><button id="'+e.element.id+'_frameOffsetBtn"></button>'}),"line"===e.frameObj.type&&(t.push({id:e.element.id+"_frameRadius",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Radius"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Radius")+'</span><button id="'+e.element.id+'_frameRadiusBtn"></button>'}),t.push({id:e.element.id+"_frameAmount",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Amount"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Amount")+'</span><button id="'+e.element.id+'_frameAmountBtn"></button>'}),t.push({id:e.element.id+"_frameBorder",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("Border"),align:"Center",type:"Input",template:"<span>"+this.l10n.getConstant("Border")+'</span><button id="'+e.element.id+'_frameBorderBtn"></button>'})),t},n.prototype.getFilterToolbarItem=function(){var e=[],i=this.parent,o=!1,r=["Default","Chrome","Cold","Warm","Grayscale","Sepia","Invert"];if(i.toolbar)for(var a=0;a<r.length;a++)if(-1!==i.toolbar.indexOf(r[a])){o=!0;break}(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Default")>-1)&&e.push({id:i.element.id+"_default",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Default"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_defaultCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Default")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Chrome")>-1)&&e.push({id:i.element.id+"_chrome",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Chrome"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_chromeCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Chrome")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Cold")>-1)&&e.push({id:i.element.id+"_cold",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Cold"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_coldCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Cold")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Warm")>-1)&&e.push({id:i.element.id+"_warm",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Warm"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_warmCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Warm")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Grayscale")>-1)&&e.push({id:i.element.id+"_grayscale",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Grayscale"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_grayscaleCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Grayscale")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Sepia")>-1)&&e.push({id:i.element.id+"_sepia",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Sepia"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_sepiaCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Sepia")+"</span></div></div>"}),(t.isNullOrUndefined(i.toolbar)||!o||i.toolbar&&i.toolbar.indexOf("Invert")>-1)&&e.push({id:i.element.id+"_invert",prefixIcon:"e-icons e-none",cssClass:"top-icon e-none",tooltipText:this.l10n.getConstant("Invert"),align:"Center",template:'<div class="filter-wrapper" style="box-sizing: content-box;"><canvas id='+i.element.id+'_invertCanvas></canvas><div style="text-align:center;"><span>'+this.l10n.getConstant("Invert")+"</span></div></div>"});for(var n=this.processToolbar("center"),s=(a=0,n.length);a<s;a++)e.push(n[a]);return e},n.prototype.getPenToolbarItem=function(e){var i=this.parent,o=[];(t.isNullOrUndefined(i.toolbar)||i.toolbar)&&o.push({id:i.element.id+"_annotation",tooltipText:this.l10n.getConstant("Annotation"),align:"Center",template:'<button id="'+i.element.id+'_annotationBtn"></button>'}),e.indexOf("strokeColor")>-1&&o.push({prefixIcon:"e-icons e-copy",id:i.element.id+"_pen_strokecolor",cssClass:"top-icon e-pen-stroke-color",tooltipText:this.l10n.getConstant("StrokeColor"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penColorBtn"></button>'}),e.indexOf("strokeWidth")>-1&&o.push({prefixIcon:"e-icons e-copy",cssClass:"top-icon e-size",tooltipText:this.l10n.getConstant("StrokeWidth"),align:"Center",type:"Input",template:'<button id="'+i.element.id+'_penStrokeWidth"></button>'}),o.push({align:"Center",type:"Separator"}),e.indexOf("remove")>-1&&o.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Center"});for(var r=this.processSubToolbar(e),a=0,n=r.length;a<n;a++)o.push(r[a]);return t.Browser.isDevice||(o.push({id:i.element.id+"_ok",prefixIcon:"e-icons e-check",cssClass:"top-icon e-tick",tooltipText:this.l10n.getConstant("OK"),align:"Right"}),o.push({id:i.element.id+"_cancel",prefixIcon:"e-icons e-close",cssClass:"top-icon e-save",tooltipText:this.l10n.getConstant("Cancel"),align:"Right"})),o},n.prototype.initPenToolbarItem=function(e){var i=this,o=this.parent,a=this.getLeftToolbarItem(),n=this.getRightToolbarItem(),s=this.getPenToolbarItem(e),l=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=s:this.defToolbarItems=a.concat(l,s,n);var p=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){i.renderAnnotationBtn(!0),i.createPenColor(e),i.createPenBtn(e),i.wireZoomBtnEvents(),t.Browser.isDevice||i.renderSaveBtn(),o.trigger("toolbarCreated",{toolbarType:"pen"}),t.Browser.isDevice?i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&(p.refreshOverflow(),p.refreshOverflow()):(i.createLeftToolbarControls(),i.defToolbarItems.length>0&&document.getElementById(o.element.id+"_toolbar")&&p.refreshOverflow())}});t.Browser.isDevice?p.appendTo("#"+o.element.id+"_bottomToolbar"):p.appendTo("#"+o.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.createPenColor=function(e){var i=this,r=this.parent;if(e.indexOf("strokeColor")>-1){r.element.querySelector(".e-template.e-pen-stroke-color").appendChild(r.createElement("input",{id:r.element.id+"_pen_stroke"}));var n=new o.ColorPicker({modeSwitcher:!1,value:"#fff",showButtons:!1,mode:"Palette",cssClass:"e-pen-color",change:function(e){r.updatePenStrokeColor(e.currentValue.hex),i.selFhdColor=e.currentValue.hex,s.element.children[0].style.backgroundColor=e.currentValue.rgba,s.toggle()}},"#"+r.element.id+"_pen_stroke"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=r.element.offsetLeft+"px")},target:".e-pen-color",iconCss:"e-dropdownbtn-preview"},"#"+r.element.id+"_penColorBtn");n.inline=!0;var l={tempFreeHandDrawEditingStyles:null};r.notify("freehand-draw",{prop:"getTempFreeHandDrawEditingStyles",value:{obj:l}});var p={freehandSelectedIndex:null};r.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:p}}),!t.isNullOrUndefined(p.freehandSelectedIndex)&&p.freehandSelectedIndex>-1?r.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#42a5f5"===this.selFhdColor?l.tempFreeHandDrawEditingStyles.strokeColor:r.pointColl[p.freehandSelectedIndex].strokeColor:r.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview").style.background="#fff"}},n.prototype.createPenBtn=function(e){var i=this.parent,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(e.indexOf("strokeWidth")>-1){var r=document.getElementById(i.element.id+"_penStrokeWidth"),n=document.createElement("span"),s={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:s}}),!t.isNullOrUndefined(s.freehandSelectedIndex)&&s.freehandSelectedIndex>-1?n.innerHTML=this.getPenStroke(i.pointColl[s.freehandSelectedIndex].strokeWidth):n.innerHTML=this.l10n.getConstant("Small"),n.className="e-pen-stroke-width",r.appendChild(n);var l=new a.DropDownButton({items:o,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=n.innerHTML;e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(e){if(n.textContent=e.item.text,i.updatePenStrokeWidth(e.item.id),t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_penStrokeWidth")}},n.prototype.getPenStroke=function(e){var t="",i={1:this.l10n.getConstant("XSmall"),2:this.l10n.getConstant("Small"),3:this.l10n.getConstant("Medium"),4:this.l10n.getConstant("Large"),5:this.l10n.getConstant("XLarge")};return e>=1&&e<=5&&(t=i[e]),t},n.prototype.initAdjustmentToolbarItem=function(){var e=this,i=this.parent,o=this.getLeftToolbarItem(null),a=this.getRightToolbarItem(),n=this.getAdjustmentToolbarItem(),s=this.getZoomToolbarItem();t.Browser.isDevice?this.defToolbarItems=n:this.defToolbarItems=o.concat(s,n,a);var l=new r.Toolbar({width:"100%",items:this.defToolbarItems,clicked:this.defToolbarClicked.bind(this),created:function(){e.wireZoomBtnEvents(),t.Browser.isDevice||e.renderSaveBtn(),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow():(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&l.refreshOverflow())}});t.Browser.isDevice?l.appendTo("#"+i.element.id+"_bottomToolbar"):l.appendTo("#"+i.element.id+"_toolbar"),this.enableDisableTbrBtn()},n.prototype.initFrameToolbarItem=function(){var e=this,i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),a=document.querySelector("#"+i.element.id+"_frameWrapper");a?a.style.display="block":a=o.appendChild(i.createElement("div",{id:i.element.id+"_frameWrapper",className:"e-frame-wrapper",styles:"position: relative"})),a.appendChild(i.createElement("div",{id:i.element.id+"_customizeWrapper",styles:"position: absolute"}));var n=this.getFrameToolbarItem(),s=new r.Toolbar({width:"100%",items:n,clicked:this.defToolbarClicked.bind(this),created:function(){e.createFrameColor(),e.createFrameSize(),"line"===i.frameObj.type&&e.createFrameRadius(),"line"!==i.frameObj.type&&"inset"!==i.frameObj.type&&"hook"!==i.frameObj.type||e.createFrameInset(),"line"!==i.frameObj.type&&"inset"!==i.frameObj.type||e.createFrameOffset(),"line"===i.frameObj.type&&(e.createFrameAmount(),e.createFrameBorder()),e.createFrameGradientColor(),t.Browser.isDevice?e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_bottomToolbar")&&(s.refreshOverflow(),s.refreshOverflow(),s.refreshOverflow()):(e.createLeftToolbarControls(),e.defToolbarItems.length>0&&document.getElementById(i.element.id+"_toolbar")&&s.refreshOverflow()),i.element.querySelector("#"+i.element.id+"_"+i.frameObj.type).focus()}});s.appendTo("#"+this.parent.element.id+"_customizeWrapper")},n.prototype.createFrameGradientColor=function(){var e,i=this.parent,r={frameChangeEventArgs:null};i.element.querySelector(".e-template.e-frame-stroke").appendChild(i.createElement("input",{id:i.element.id+"_frame_gradient_fill"}));var n=new o.ColorPicker({modeSwitcher:!1,noColor:!0,value:i.frameObj.gradientColor,showButtons:!1,mode:"Palette",cssClass:"e-frame-gradient-fill-color",change:function(o){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.gradientColor,n={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.gradientColor=o.currentValue.hex,i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:r}}),r.frameChangeEventArgs&&!r.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),""===o.currentValue.rgba?s.element.children[0].classList.add("e-nocolor-item"):(s.element.children[0].classList.remove("e-nocolor-item"),s.element.children[0].style.backgroundColor=o.currentValue.rgba)):i.frameObj.gradientColor=a,s.toggle()}},"#"+i.element.id+"_frame_gradient_fill"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-frame-gradient-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_frameGradientColorBtn");n.inline=!0,""===i.frameObj.gradientColor?i.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").classList.add("e-nocolor-item"):i.element.querySelector(".e-frame-stroke.e-template .e-dropdownbtn-preview").style.background=i.frameObj.gradientColor},n.prototype.createFrameColor=function(){var e,i=this.parent,r={frameChangeEventArgs:null};i.element.querySelector(".e-template.e-stroke").appendChild(i.createElement("input",{id:i.element.id+"_frame_fill"}));var n=new o.ColorPicker({modeSwitcher:!1,value:i.frameObj.color,showButtons:!1,mode:"Palette",cssClass:"e-frame-fill-color",change:function(o){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.color,n={currObj:{}};i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.color=o.currentValue.hex,i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:r}}),r.frameChangeEventArgs&&!r.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),""===o.currentValue.rgba?s.element.children[0].classList.add("e-nocolor-item"):(s.element.children[0].classList.remove("e-nocolor-item"),s.element.children[0].style.backgroundColor=o.currentValue.rgba)):i.frameObj.color=a,s.toggle()}},"#"+i.element.id+"_frame_fill"),s=new a.DropDownButton({open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=s.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px",e.element.parentElement.style.left=i.element.offsetLeft+"px")},target:".e-frame-fill-color",iconCss:"e-dropdownbtn-preview"},"#"+i.element.id+"_frameColorBtn");n.inline=!0,i.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview").style.background=i.frameObj.color},n.prototype.createFrameSize=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameSizeBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.size.toString()),s.className="e-frame-stroke-width",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.size,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.size=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.size=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameSizeBtn")},n.prototype.createFrameInset=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameInsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.inset.toString()),s.className="e-frame-inset",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.inset,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.inset=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.inset=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameInsetBtn")},n.prototype.createFrameOffset=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("20")},{id:"2",text:this.l10n.getConstant("40")},{id:"3",text:this.l10n.getConstant("60")},{id:"4",text:this.l10n.getConstant("80")},{id:"5",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameOffsetBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.offset.toString()),s.className="e-frame-offset",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.offset,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.offset=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.offset=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameOffsetBtn")},n.prototype.createFrameRadius=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("0")},{id:"2",text:this.l10n.getConstant("20")},{id:"3",text:this.l10n.getConstant("40")},{id:"4",text:this.l10n.getConstant("60")},{id:"5",text:this.l10n.getConstant("80")},{id:"6",text:this.l10n.getConstant("100")}],n=document.getElementById(i.element.id+"_frameRadiusBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.radius.toString()),s.className="e-frame-radius",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.radius,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.radius=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.radius=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameRadiusBtn")},n.prototype.createFrameAmount=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("1")},{id:"2",text:this.l10n.getConstant("2")},{id:"3",text:this.l10n.getConstant("3")},{id:"4",text:this.l10n.getConstant("4")},{id:"5",text:this.l10n.getConstant("5")}],n=document.getElementById(i.element.id+"_frameAmountBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.frameObj.amount.toString()),s.className="e-frame-amount",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.amount,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.amount=parseInt(r.item.text,10),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.amount=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameAmountBtn")},n.prototype.createFrameBorder=function(){var e,i=this.parent,o={frameChangeEventArgs:null},r=[{id:"1",text:this.l10n.getConstant("Solid")},{id:"2",text:this.l10n.getConstant("Dashed")},{id:"3",text:this.l10n.getConstant("Dotted")}],n=document.getElementById(i.element.id+"_frameBorderBtn"),s=document.createElement("span");s.innerHTML=this.l10n.getConstant(i.toPascalCase(i.frameObj.border)),s.className="e-frame-border",n.appendChild(s);var l=new a.DropDownButton({items:r,open:function(e){t.Browser.isDevice&&(e.element.parentElement.style.top=l.element.getBoundingClientRect().top-e.element.parentElement.offsetHeight+"px");var i=l.element.childNodes[0].textContent;""!==i&&e.element.querySelector('[aria-label = "'+i+'"]').classList.add("e-selected-btn")},select:function(r){e={type:i.toPascalCase(i.frameObj.type),color:i.frameObj.color,gradientColor:i.frameObj.gradientColor,size:i.frameObj.size,inset:i.frameObj.inset,offset:i.frameObj.offset,borderRadius:i.frameObj.radius,frameLineStyle:i.toPascalCase(i.frameObj.border),lineCount:i.frameObj.amount};var a=i.frameObj.border,n={currObj:{}};if(i.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:n}}),i.frameObj.border=r.item.text.toLowerCase(),i.notify("draw",{prop:"triggerFrameChange",value:{prevFrameSettings:e,obj:o}}),o.frameChangeEventArgs&&!o.frameChangeEventArgs.cancel?(i.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:n.currObj,previousObjColl:n.currObj.objColl,previousPointColl:n.currObj.pointColl,previousSelPointColl:n.currObj.selPointColl,previousCropObj:t.extend({},i.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}}),i.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}}),l.content=r.item.text):i.frameObj.border=a,t.Browser.isDevice){if(document.getElementById(i.element.id+"_bottomToolbar")){t.getComponent(i.element.id+"_bottomToolbar","toolbar").refreshOverflow()}}else if(document.getElementById(i.element.id+"_toolbar")){t.getComponent(i.element.id+"_toolbar","toolbar").refreshOverflow()}}});l.appendTo("#"+i.element.id+"_frameBorderBtn")},n.prototype.initFilterToolbarItem=function(){var e=this,i=this.parent,o=this.getFilterToolbarItem();document.querySelector("#"+i.element.id+"_contextualToolbar").classList.contains("e-control")&&t.getComponent(document.getElementById(i.element.id+"_contextualToolbar"),"toolbar").destroy();var a=new r.Toolbar({width:"100%",items:o,clicked:this.contextualToolbarClicked.bind(this),created:function(){e.updatePrivateVariables(),e.createCanvasFilter(),""===i.currentFilter&&(i.currentFilter=i.element.id+"_default");var t=document.querySelector("#"+i.element.id+"_headWrapper");t&&(t.style.display="none"),document.getElementById(i.currentFilter+"Canvas")&&document.getElementById(i.currentFilter+"Canvas").parentElement.parentElement.classList.add("e-selected"),e.enableDisableTbrBtn(),a.refreshOverflow()}});a.appendTo("#"+i.element.id+"_contextualToolbar")},n.prototype.drawDashedLine=function(e){e.beginPath(),e.setLineDash([5]),e.rect(10,10,280,130),e.stroke(),e.closePath()},n.prototype.createCanvasFilter=function(){var e=this.parent;i.showSpinner(e.element),e.element.style.opacity="0.5";var t=e.getCurrentCanvasData();this.inMemoryCanvas.width=t.width,this.inMemoryCanvas.height=t.height,this.inMemoryContext.putImageData(t,0,0),this.updateFilterCanvas("_defaultCanvas","default"),this.updateFilterCanvas("_chromeCanvas","chrome"),this.updateFilterCanvas("_coldCanvas","cold"),this.updateFilterCanvas("_warmCanvas","warm"),this.updateFilterCanvas("_grayscaleCanvas","grayscale"),this.updateFilterCanvas("_sepiaCanvas","sepia"),this.updateFilterCanvas("_invertCanvas","invert"),i.hideSpinner(e.element),e.element.style.opacity="1",e.initialAdjustmentValue=this.lowerContext.filter},n.prototype.updateFilterCanvas=function(e,t){var i=this.parent,o=i.element.querySelector("#"+i.element.id+e);if(o){var r=o.getContext("2d");r=o.getContext("2d"),o.style.width="100px",o.style.height="100px",i.notify("filter",{prop:"updateAdj",value:{type:t,value:null,isPreview:!0,ctx:r}}),r.drawImage(this.inMemoryCanvas,0,0,300,150)}},n.prototype.getQuickAccessToolbarItem=function(e){var i=this.parent,o={cancel:!1,toolbarItems:[]},r=[];t.isNullOrUndefined(e)?("image"===i.activeObj.shape&&r.push("Flip"),r.push("Clone"),r.push("Delete"),"text"===i.activeObj.shape&&r.push("EditText"),o.shape=i.toPascalCase(i.activeObj.shape)):e&&(r.push("Delete"),o.shape="Freehand draw"),o.toolbarItems=t.extend([],r,null,!0),i.trigger("quickAccessToolbarOpen",o);var a=[];if(o.cancel)a=[];else for(var n=0;n<o.toolbarItems.length;n++)switch(o.toolbarItems[n]){case"Clone":a.push({id:i.element.id+"_duplicate",prefixIcon:"e-icons e-order",cssClass:"top-icon e-order",tooltipText:this.l10n.getConstant("Duplicate"),align:"Left"});break;case"Delete":a.push({id:i.element.id+"_remove",prefixIcon:"e-icons e-trash",cssClass:"top-icon e-trash",tooltipText:this.l10n.getConstant("Remove"),align:"Left"});break;case"EditText":a.push({id:i.element.id+"_editText",prefixIcon:"e-icons e-annotation-edit",cssClass:"top-icon e-annotation-edit",tooltipText:this.l10n.getConstant("EditText"),align:"Left"});break;case"Flip":a.push({id:i.element.id+"_hFlip",prefixIcon:"e-icons e-horizontal-flip",tooltipText:this.l10n.getConstant("HorizontalFlip"),align:"Left"}),a.push({id:i.element.id+"_vFlip",prefixIcon:"e-icons e-vertical-flip",tooltipText:this.l10n.getConstant("VerticalFlip"),align:"Left"});break;default:a.push(o.toolbarItems[n])}return a},n.prototype.renderQAT=function(e){var i=this.parent;if(i.activeObj&&i.showQuickAccessToolbar){var o=document.getElementById(i.element.id+"_quickAccessToolbarArea");o&&(this.destroyQuickAccessToolbar(),o.style.display="block");var a=this.getQuickAccessToolbarItem(e);if(0===a.length)return;if(t.isNullOrUndefined(i.quickAccessToolbarTemplate)){new r.Toolbar({items:a,clicked:this.quickAccessToolbarClicked.bind(this)}).appendTo("#"+i.element.id+"_quickAccessToolbar")}var n=this.toolbarHeight&&0!==this.toolbarHeight?this.toolbarHeight:o.clientHeight;if(t.isNullOrUndefined(e)){o.style.width="auto",i.activeObj.activePoint.width=Math.abs(i.activeObj.activePoint.width),i.activeObj.activePoint.height=Math.abs(i.activeObj.activePoint.height);var s=i.activeObj.activePoint.startX<i.activeObj.activePoint.endX?i.activeObj.activePoint.startX:i.activeObj.activePoint.endX,l=i.activeObj.activePoint.startY<i.activeObj.activePoint.endY?i.activeObj.activePoint.startY:i.activeObj.activePoint.endY,p=i.activeObj.activePoint.width;if(0!==i.activeObj.rotatedAngle&&"arrow"!==i.activeObj.shape){var h={activePoint:null};i.notify("shape",{prop:"getSquarePointForRotatedShape",onPropertyChange:!1,value:{obj:i.activeObj,object:h}});s=(g=h.activePoint).startX,l=g.startY,p=g.width}else if("path"===i.activeObj.shape){var c=i.getSquarePointForPath(i.activeObj);s=c.startX,l=c.startY,p=c.width}if(o.style.left=s+p/2-25*a.length+"px",parseFloat(o.style.left)+o.clientWidth/2!==s+p/2){var d=s+p/2-(parseFloat(o.style.left)+o.clientWidth/2);o.style.left=parseFloat(o.style.left)+d+"px"}l-(n+n/1.5)<i.img.destTop?o.style.top=i.img.destTop+"px":o.style.top=l-(n+n/1.5)+"px"}else if(e){var v={activePoint:null},u={freehandSelectedIndex:null};i.notify("freehand-draw",{prop:"getFreehandSelectedIndex",onPropertyChange:!1,value:{obj:u}}),i.notify("freehand-draw",{prop:"getSqPtFD",value:{idx:u.freehandSelectedIndex,obj:v}});var g=v.activePoint;o.style.width="auto",o.style.left=g.startX+g.width/2-27*a.length+"px",g.startY-(n+n/1.5)<i.img.destTop?o.style.top=i.img.destTop+"px":o.style.top=g.startY-(n+n/1.5)+"px"}}},n.prototype.refreshDropDownBtn=function(e){if(!t.isNullOrUndefined(e)){var i=this.parent,o=document.querySelector("#"+i.element.id+"_annotationBtn");o&&(e?(o.classList.add("e-disabled"),o.parentElement.classList.add("e-overlay")):(o.classList.remove("e-disabled"),o.parentElement.classList.remove("e-overlay")),t.getComponent(o,"dropdown-btn").disabled=e);var r=document.querySelector("#"+i.element.id+"_transformBtn");r&&(e?(r.classList.add("e-disabled"),r.parentElement.classList.add("e-overlay")):(r.classList.remove("e-disabled"),r.parentElement.classList.remove("e-overlay")),t.getComponent(r,"dropdown-btn").disabled=e);var a=document.querySelector("#"+i.element.id+"_adjustment");a&&(e?(a.classList.add("e-disabled"),a.parentElement.classList.add("e-overlay")):(a.classList.remove("e-disabled"),a.parentElement.classList.remove("e-overlay")),t.getComponent(a,"btn").disabled=e);var n=document.querySelector("#"+i.element.id+"_filter");n&&(e?(n.classList.add("e-disabled"),n.parentElement.classList.add("e-overlay")):(n.classList.remove("e-disabled"),n.parentElement.classList.remove("e-overlay")),t.getComponent(n,"btn").disabled=e)}},n.prototype.cropSelect=function(e){var i=this.parent;i.isCropTab=!0,t.isNullOrUndefined(i.transform.cropZoomFactor)&&(i.transform.cropZoomFactor=i.transform.zoomFactor,i.notify("draw",{prop:"setTempZoomFactor",onPropertyChange:!1,value:{tempZoomFactor:i.transform.zoomFactor}})),i.transform.zoomFactor=i.transform.cropZoomFactor;var o=e.item.id;this.currentToolbar="crop",i.currSelectionPoint=null,i.notify("draw",{prop:"select",onPropertyChange:!1,value:{type:o,startX:null,startY:null,width:null,height:null}}),this.enableDisableTbrBtn(),i.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}})},n.prototype.quickAccessToolbarClicked=function(e,i){var o=this.parent,r={x:o.activeObj.activePoint.startX,y:o.activeObj.activePoint.startY};if(e.item){var a=void 0,n=void 0,s=null,l={prevActObj:null},p={tempObj:null};o.notify("draw",{prop:"getPrevActObj",onPropertyChange:!1,value:{obj:l}}),o.notify("selection",{prop:"getTempActObj",onPropertyChange:!1,value:{obj:p}}),p.tempObj.activePoint.height=Math.abs(p.tempObj.activePoint.height);var h={isNewPath:null},c=void 0;switch(o.notify("draw",{prop:"getNewPath",value:{obj:h}}),e.item.id.replace(o.element.id+"_","").toLowerCase()){case"duplicate":if(!o.element.querySelector("#"+o.element.id+"_duplicate").classList.contains("e-disabled")){if(this.refreshSlider(),h.isNewPath||JSON.stringify(p.tempObj)!==JSON.stringify(o.activeObj)||(s=!0),"image"===(a=t.extend({},o.activeObj,{},!0)).shape&&(n=t.extend([],o.objColl,[],!0),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}})),t.isNullOrUndefined(o.activeObj.currIndex)?o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}}):l.prevActObj?(o.activeObj.currIndex=null,a.currIndex=null,o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:s}})):o.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}}),h.isNewPath&&o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}}),n=t.extend([],o.objColl,[],!0),a.activePoint.startX+=10,a.activePoint.startY-=10,a.activePoint.endX+=10,a.activePoint.endY-=10,"path"===a.shape)for(var d=0;d<a.pointColl.length;d++)a.pointColl[d].x+=10,a.pointColl[d].y-=10;else"image"===a.shape&&(a.imageCanvas=o.createElement("canvas"));o.activeObj=t.extend({},a,{},!0),"image"===o.activeObj.shape&&(o.activeObj.isHorImageFlip&&o.activeObj.isVerImageFlip?(o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:!0}}),o.activeObj.isHorImageFlip=o.activeObj.isVerImageFlip=!0):o.activeObj.isHorImageFlip?(o.activeObj.isHorImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:!0,isVFlip:null}}),o.activeObj.isHorImageFlip=!0):o.activeObj.isVerImageFlip?(o.activeObj.isVerImageFlip=!1,o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:!0}}),o.activeObj.isVerImageFlip=!0):o.notify("draw",{prop:"downScaleImgCanvas",onPropertyChange:!1,value:{ctx:a.imageCanvas.getContext("2d"),isImgAnnotation:!0,isHFlip:null,isVFlip:null}})),"line"!==o.activeObj.shape&&"arrow"!==o.activeObj.shape||o.notify("shape",{prop:"setPointCollForLineArrow",onPropertyChange:!1,value:{obj:o.activeObj}}),o.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate",obj:o.activeObj,isCropRatio:null,points:null,isPreventDrag:!0}}),o.notify("undo-redo",{prop:"updateUrObj",onPropertyChange:!1,value:{objColl:n}}),this.renderQAT()}break;case"remove":o.element.querySelector("#"+o.element.id+"_remove").classList.contains("e-disabled")||(this.refreshSlider(),o.notify("selection",{prop:"deleteItem",onPropertyChange:!1}));break;case"edittext":o.element.querySelector("#"+o.element.id+"_editText").classList.contains("e-disabled")||(this.upperContext.clearRect(0,0,o.upperCanvas.width,o.upperCanvas.height),o.notify("selection",{prop:"setTempActObj",onPropertyChange:!1,value:{obj:t.extend({},o.activeObj,{},!0)}}),o.notify("selection",{prop:"setInitialTextEdit",onPropertyChange:!1,value:{bool:!0}}),o.notify("draw",{prop:"setPrevActObj",onPropertyChange:!1,value:{prevActObj:t.extend({},o.activeObj,{},!0)}}),0!==o.activeObj.rotatedAngle&&(r.x=o.activeObj.horTopLinePointColl[0].x,r.y=o.activeObj.horTopLinePointColl[0].y),o.notify("shape",{prop:"renderTextArea",onPropertyChange:!1,value:{x:r.x,y:r.y,actObj:o.activeObj}}),t.isNullOrUndefined(o.activeObj.currIndex)?o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}):l.prevActObj&&o.notify("draw",{prop:"setShapeTextInsert",onPropertyChange:!1,value:{bool:!0}}),document.getElementById(o.element.id+"_quickAccessToolbarArea")&&(document.getElementById(o.element.id+"_quickAccessToolbarArea").style.display="none"));break;case"rotleft":case"rotright":o.element.querySelector("#"+o.element.id+"_rotLeft").classList.contains("e-disabled")&&o.element.querySelector("#"+o.element.id+"_rotRight").classList.contains("e-disabled")||o.rotateImage(e.item.id.replace(o.element.id+"_","").toLowerCase());break;case"hflip":o.element.querySelector("#"+o.element.id+"_hFlip").classList.contains("e-disabled")||(c=o.activeObj.imageCanvas.getContext("2d"),o.horizontalFlip(c));break;case"vflip":o.element.querySelector("#"+o.element.id+"_vFlip").classList.contains("e-disabled")||(c=o.activeObj.imageCanvas.getContext("2d"),o.verticalFlip(c))}}t.isNullOrUndefined(i)&&o.trigger("quickAccessToolbarItemClick",e)},n.prototype.defToolbarClicked=function(e){var t=this.parent,i=!1,o=!1;if(!this.isFrameToolbar&&t.element.querySelector(".e-contextual-toolbar-wrapper")&&(t.element.querySelector(".e-contextual-toolbar-wrapper").classList.contains("e-hide")||(i=o=!0),t.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide")),e.item){var r=e.item.id.replace(t.element.id+"_","").toLowerCase();if("duplicate"===r||"remove"===r||"edittext"===r||"hflip"===r||"vflip"===r||"rotleft"===r||"rotright"===r)this.quickAccessToolbarClicked(e,!0),t.trigger("toolbarItemClicked",e);else{var a=!1,n=!1,s=document.querySelector("#"+t.element.id+"_adjustment");s&&s.classList.contains("e-disabled")&&(n=!0);var l=document.querySelector("#"+t.element.id+"_filter");l&&l.classList.contains("e-disabled")&&(a=!0),this.enableDisableTbrBtn(),this.performDefTbrClick(r,i,n,a,o),t.trigger("toolbarItemClicked",e)}}},n.prototype.performDefTbrClick=function(e,o,r,a,n){var s,l,p=this.parent,h=p.element.querySelector("#"+p.element.id+"_zoomIn"),c=!1;if(void 0!==p.activeObj.shape&&(l=p.activeObj.shape.split("-")),void 0===l&&p.currObjType.isCustomCrop?c=!0:void 0!==l&&"crop"===l[0]&&(c=!0),!p.disabled)switch(e){case"pan":p.currObjType.isCustomCrop=p.currObjType.isFiltered=!1,p.currObjType.isUndoAction&&p.notify("undo-redo",{prop:"refreshUrc",value:{bool:null}}),c&&(p.currObjType.isCustomCrop=!1,p.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.upperContext.clearRect(0,0,p.upperCanvas.width,p.upperCanvas.height),this.refreshToolbar("main")),p.togglePan?(this.cancelPan(),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!0}}),"pen"===this.currentToolbar&&p.freehandDraw(!0)):((s=p.element.querySelector(".e-img-pan .e-btn"))&&s.classList.add("e-selected-btn"),p.pan(!0),p.notify("transform",{prop:"setDisablePan",onPropertyChange:!1,value:{bool:!1}})),h&&p.zoomSettings.zoomFactor>=p.zoomSettings.maxZoomFactor?(h.classList.add("e-disabled"),h.parentElement.classList.add("e-overlay")):h&&(h.classList.remove("e-disabled"),h.parentElement.classList.remove("e-overlay")),this.refreshToolbar("main");break;case"cancel":p.notify("draw",{prop:"performCancel",value:{isContextualToolbar:o}});break;case"ok":p.okBtn(),this.refreshDropDownBtn(!1),this.currentToolbar="main";break;case"crop":p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"reset":p.reset(),this.imageHeight=null,this.imageWidth=null,this.parent.aspectHeight=null,this.parent.aspectWidth=null,this.isAspectRatio=!0,this.currentToolbar="main";break;case"undo":p.notify("undo-redo",{prop:"call-undo"});break;case"redo":p.notify("undo-redo",{prop:"call-redo"});break;case"aspectratio":(!p.isCircleCrop&&t.isNullOrUndefined(p.currSelectionPoint)||p.currSelectionPoint&&"crop-circle"!==p.currSelectionPoint.shape)&&(p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize"));break;case"nonaspectratio":p.resizeSrc={startX:p.img.srcLeft,startY:p.img.srcTop,width:p.img.srcWidth,height:p.img.srcHeight},this.refreshToolbar("resize");break;case"resize":p.currObjType.isFiltered&&p.okBtn(),this.resizeClick();break;case"adjustment":r||(p.currObjType.isFiltered&&p.okBtn(),this.refreshToolbar("adjustment"),p.setTempFilterProperties(),this.openSlider("brightness"));break;case"brightness":case"contrast":case"hue":case"saturation":case"opacity":case"blur":case"exposure":this.openSlider(e);break;case"filter":a||(i.showSpinner(p.element),this.refreshToolbar("filter"),p.setTempFilterProperties(),i.hideSpinner(p.element));break;case"default":case"chrome":case"cold":case"warm":case"grayscale":case"blackandwhite":case"sepia":case"invert":case"sharpen":p.currObjType.isFiltered=!0,p.notify("filter",{prop:"applyImageFilter",value:{option:e}});break;case"upload":n&&p.element.querySelector(".e-contextual-toolbar-wrapper").classList.remove("e-hide");break;case"bold":p.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}):p.activeObj.textSettings.bold&&!p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):!p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):p.activeObj.textSettings.bold||p.activeObj.textSettings.italic||p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}),p.element.querySelector("#"+p.element.id+"_bold").classList.contains("e-selected-btn")?p.element.querySelector("#"+p.element.id+"_bold").classList.remove("e-selected-btn"):p.element.querySelector("#"+p.element.id+"_bold").classList.add("e-selected-btn");break;case"italic":p.notify("selection",{prop:"setInitialTextEdit",value:{bool:!1}}),p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bold"}}):p.activeObj.textSettings.bold&&!p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"bolditalic"}}):!p.activeObj.textSettings.bold&&p.activeObj.textSettings.italic?p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"default"}}):p.activeObj.textSettings.bold||p.activeObj.textSettings.italic||p.notify("shape",{prop:"applyFontStyle",onPropertyChange:!1,value:{item:"italic"}}),p.element.querySelector("#"+p.element.id+"_italic").classList.contains("e-selected-btn")?p.element.querySelector("#"+p.element.id+"_italic").classList.remove("e-selected-btn"):p.element.querySelector("#"+p.element.id+"_italic").classList.add("e-selected-btn");break;case"croptransform":p.currObjType.isFiltered&&p.okBtn(),this.refreshToolbar("croptransform");break;case"rotateleft":case"rotateright":case"horizontalflip":case"verticalflip":p.transformSelect(e),p.notify("transform",{prop:"disableZoomOutBtn",value:{isZoomOut:!0}});break;case"save":if(p.element.querySelector("#"+p.element.id+"_saveBtn").classList.contains("e-hide")){p.element.querySelector("#"+p.element.id+"_saveBtn").classList.remove("e-hide");break}p.okBtn(),p.element.querySelector("#"+p.element.id+"_saveBtn").classList.add("e-hide"),p.element.querySelector("#"+p.element.id+"_saveBtn").click();break;case"transparency":this.updateContextualToolbar("transparency","transparency");break;case"frame":this.frameToolbarClick();break;case"none":case"mat":case"bevel":case"line":case"inset":case"hook":this.unselectFrameBtn(),p.element.querySelector("#"+p.element.id+"_"+e)&&p.element.querySelector("#"+p.element.id+"_"+e).classList.add("e-selected-btn"),p.frameObj.type=e,p.frameObj.size=20,p.frameObj.inset=20,p.frameObj.radius=0,p.frameObj.amount=1,p.frameObj.offset="inset"===e?60:20,this.refreshToolbar("frame"),p.notify("draw",{prop:"render-image",value:{isMouseWheel:null,isPreventClearRect:null,isFrame:!0}})}},n.prototype.frameToolbarClick=function(){var e,i,o,r=this.parent,a=document.querySelector("#"+r.element.id+"_frame");r.currObjType.isFiltered&&r.okBtn(),a&&!a.classList.contains("e-disabled")&&(e=r.transform.zoomFactor,r.frameDestPoints=t.extend({},r.img,{},!0),t.isNullOrUndefined(r.cxtTbarHeight)&&(i=t.extend({},r.frameObj,{},!0),o=t.extend({},r.tempFrameObj,{},!0),this.callFrameToolbar(),r.frameObj.type="mat",this.callFrameToolbar(),r.cxtTbarHeight=r.element.querySelector("#"+r.element.id+"_customizeWrapper").clientHeight,r.frameObj=i,r.tempFrameObj=o),this.zoomToFrameRange(),r.tempFrameZoomLevel=e,t.Browser.isDevice?r.img.destTop-=r.cxtTbarHeight/2:r.img.destTop+=r.cxtTbarHeight/2,this.callFrameToolbar())},n.prototype.zoomToFrameRange=function(){var e=this.parent;for(this.isFrameToolbar=!1,e.notify("transform",{prop:"resetZoom",onPropertyChange:!1});!(this.toolbarHeight+e.img.destTop>=this.toolbarHeight+e.cxtTbarHeight);)e.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:!0}});this.isFrameToolbar=!0},n.prototype.resizeClick=function(){this.parent.upperCanvas.style.cursor="default",this.parent.notify("transform",{prop:"updateResize",value:{bool:!1}}),this.isAspectRatio?this.isAspectRatio=!1:this.isAspectRatio=!0,this.parent.isResize=!0,this.refreshToolbar("resize")},n.prototype.callFrameToolbar=function(){var e=this.parent;e.notify("draw",{prop:"setTempFrame",value:{frame:e.frameObj.type}}),t.extend(e.tempFrameObj,e.frameObj);var i={appliedUndoRedoColl:[]};if(e.notify("undo-redo",{prop:"getAppliedUndoRedoColl",value:{obj:i}}),0===i.appliedUndoRedoColl.length){var o={currObj:{}};e.notify("filter",{prop:"getCurrentObj",onPropertyChange:!1,value:{object:o}}),e.notify("undo-redo",{prop:"updateUndoRedoColl",onPropertyChange:!1,value:{operation:"frame",previousObj:o.currObj,previousObjColl:o.currObj.objColl,previousPointColl:o.currObj.pointColl,previousSelPointColl:o.currObj.selPointColl,previousCropObj:t.extend({},e.cropObj,{},!0),previousText:null,currentText:null,previousFilter:null,isCircleCrop:null}})}this.refreshToolbar("frame")},n.prototype.contextualToolbarClicked=function(e){var t=this.parent,i=t.element.querySelector(".e-contextual-toolbar-wrapper .e-toolbar-item.e-selected");i&&i.classList.remove("e-selected");var o=e.item.id.replace(t.element.id,"").split("_")[1],r={filter:t.toPascalCase(o),cancel:!1};t.trigger("imageFiltering",r),r.cancel||(document.getElementById(e.item.id+"Canvas").parentElement.parentElement.classList.add("e-selected"),t.currObjType.isFiltered=!0,t.notify("filter",{prop:"applyImageFilter",value:{option:o.toLowerCase()}}),t.currentFilter=e.item.id,this.enableDisableTbrBtn())},n.prototype.refreshShapeDrawing=function(){var e=this.parent,t={shape:""};e.notify("selection",{prop:"getCurrentDrawingShape",onPropertyChange:!1,value:{obj:t}}),""!==t.shape&&(e.notify("selection",{prop:"setCurrentDrawingShape",onPropertyChange:!1,value:{value:""}}),e.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),this.refreshToolbar("main",!1))},n.prototype.zoomInBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar){if(o.currObjType.isFiltered&&o.okBtn(),this.refreshShapeDrawing(),t.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomIn");t.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:.1,zoomPoint:null,isResize:null}})}},n.prototype.zoomOutBtnClickHandler=function(i){var o=this.parent;if((o.zoomSettings.zoomTrigger&e.ZoomTrigger.Toolbar)===e.ZoomTrigger.Toolbar){if(o.currObjType.isFiltered&&o.okBtn(),this.refreshShapeDrawing(),t.Browser.isDevice&&"touchstart"===i.type){if(!i.returnValue)return;i.preventDefault()}var r=document.querySelector("#"+o.element.id+"_zoomOut");t.EventHandler.trigger(r,"click");var a={bool:!1};o.notify("selection",{prop:"getFreehandDrawEditing",onPropertyChange:!1,value:{obj:a}}),a.bool&&(o.notify("freehand-draw",{prop:"applyFhd",onPropertyChange:!1}),this.destroyQuickAccessToolbar()),this.applyPreviewFilter(),o.currObjType.isFiltered=!1,o.togglePen&&(o.currObjType.isZoomed=!0,o.freeHandDraw(!1),o.notify("undo-redo",{prop:"updateCurrUrc",value:{type:"ok"}})),o.notify("draw",{prop:"resetCurrentSelectionPoint"}),o.notify("transform",{prop:"zoomAction",onPropertyChange:!1,value:{zoomFactor:-.1,zoomPoint:null,isResize:null}})}},n.prototype.zoomInBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomInBtnClickHandler.bind(this),250)},n.prototype.zoomOutBtnMouseDownHandler=function(e){e.preventDefault(),this.zoomBtnHold=setInterval(this.zoomOutBtnClickHandler.bind(this),250)},n.prototype.zoomBtnMouseUpHandler=function(){clearInterval(this.zoomBtnHold),this.zoomBtnHold=0},n.prototype.closeContextualToolbar=function(){var e=this.parent,t=!1;return(e.element.querySelector("#"+e.element.id+"_contextualToolbar")&&!e.element.querySelector("#"+e.element.id+"_contextualToolbar").parentElement.classList.contains("e-hide")||e.element.querySelector("#"+e.element.id+"_headWrapper")&&!e.element.querySelector("#"+e.element.id+"_headWrapper").parentElement.classList.contains("e-hide"))&&(e.element.querySelector(".e-contextual-toolbar-wrapper").classList.add("e-hide"),e.okBtn(),this.refreshMainToolbar(),t=!0),t},n.prototype.destroyQuickAccessToolbar=function(){var e=this.parent,i=document.getElementById(e.element.id+"_quickAccessToolbar");i&&i.classList.contains("e-control")&&t.getComponent(i,"toolbar").destroy();var o=document.getElementById(e.element.id+"_quickAccessToolbarArea");o&&(o.style.display="none")},n.prototype.renderSlider=function(e){var i=this.parent,o=document.querySelector("#"+i.element.id+"_contextualToolbarArea"),r=document.querySelector("#"+i.element.id+"_headWrapper"),a=document.querySelector("#"+i.element.id+"_labelWrapper");r?r.style.display="block":(r=o.appendChild(i.createElement("div",{id:i.element.id+"_headWrapper",styles:"position: relative"})),a="transparency"===e?r.appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:t.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 175px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 250px); font-size: 15px; text-transform: capitalize; font-weight: 400;"})):r.appendChild(i.createElement("label",{id:i.element.id+"_labelWrapper",styles:t.Browser.isDevice?"position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;":"position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;"}))),a.textContent=this.l10n.getConstant(i.toPascalCase(e));var n,s,l,p=r.appendChild(i.createElement("div",{id:i.element.id+"_sliderWrapper",styles:"position: absolute"})),h=i.getCurrAdjustmentValue(e);"brightness"===e||"contrast"===e||"saturation"===e||"exposure"===e?(i.finetuneSettings?"brightness"===e&&i.finetuneSettings.brightness?(n=i.finetuneSettings.brightness.min,s=i.finetuneSettings.brightness.max):"contrast"===e&&i.finetuneSettings.contrast?(n=i.finetuneSettings.contrast.min,s=i.finetuneSettings.contrast.max):"saturation"===e&&i.finetuneSettings.saturation?(n=i.finetuneSettings.saturation.min,s=i.finetuneSettings.saturation.max):"exposure"===e&&i.finetuneSettings.exposure?(n=i.finetuneSettings.exposure.min,s=i.finetuneSettings.exposure.max):(n=-100,s=100):(n=-100,s=100),l=this.createSlider(n,s,h,e)):"hue"===e||"blur"===e||"opacity"===e?(i.finetuneSettings?"hue"===e&&i.finetuneSettings.hue?(n=i.finetuneSettings.hue.min,s=i.finetuneSettings.hue.max):"blur"===e&&i.finetuneSettings.blur?(n=i.finetuneSettings.blur.min,s=i.finetuneSettings.blur.max):"opacity"===e&&i.finetuneSettings.opacity?(n=i.finetuneSettings.opacity.min,s=i.finetuneSettings.opacity.max):(n=0,s=100):(n=0,s=100),l=this.createSlider(n,s,h,e)):"transparency"===e&&(n=0,s=100,l=this.createSlider(n,s,h,e)),l.appendTo("#"+i.element.id+"_sliderWrapper"),p.style.left=(parseFloat(o.style.width)-parseFloat(l.width))/2+"px"},n.prototype.createSlider=function(e,i,r,a){var n=this,s=this.parent;return new o.Slider({value:r,tooltip:{isVisible:!0,placement:"Before",showOn:"Always"},type:"MinRange",min:e,max:i,step:10,width:t.Browser.isDevice?"200px":"300px",cssClass:"e-slider",change:function(e){"transparency"===a?(s.activeObj.imageTransparency=e.value/100,n.upperContext.clearRect(0,0,s.upperCanvas.width,s.upperCanvas.height),s.notify("draw",{prop:"drawObject",onPropertyChange:!1,value:{canvas:"duplicate"}})):(s.setCurrAdjustmentValue(a,e.value),n.enableDisableTbrBtn())}})},n.prototype.applyPreviewFilter=function(){var e=this.parent;(document.querySelector("#"+e.element.id+"_sliderWrapper")||e.currObjType.isFiltered)&&(e.initialAdjustmentValue=this.lowerContext.filter,e.canvasFilter=this.lowerContext.filter,e.currObjType.isFiltered=!1)},n.prototype.unselectBtn=function(){for(var e=this.parent,t=0,i=["#"+e.element.id+"_brightness","#"+e.element.id+"_contrast","#"+e.element.id+"_hue","#"+e.element.id+"_saturation","#"+e.element.id+"_opacity","#"+e.element.id+"_blur","#"+e.element.id+"_exposure"];t<i.length;t++){var o=i[t],r=document.querySelector(o);if(r&&r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.openSlider=function(e){this.unselectBtn(),this.parent.currObjType.isFiltered=!0,this.refreshToolbar("color",null,null,null,e),document.getElementById(this.parent.element.id+"_"+e).classList.add("e-selected-btn")},n.prototype.refreshSlider=function(){var e=document.querySelector("#"+this.parent.element.id+"_sliderWrapper"),t=document.querySelector(".e-slider"),i=document.querySelector("#"+this.parent.element.id+"_headWrapper");i&&(i.style.display="none"),e&&t&&(t.ej2_instances[0].destroy(),e.remove())},n.prototype.unselectFrameBtn=function(){for(var e=this.parent,t=0,i=["#"+e.element.id+"_none","#"+e.element.id+"_mat","#"+e.element.id+"_line","#"+e.element.id+"_inset","#"+e.element.id+"_bevel","#"+e.element.id+"_hook"];t<i.length;t++){var o=i[t],r=document.querySelector(o);if(r.classList.contains("e-selected-btn")){r.classList.remove("e-selected-btn");break}}},n.prototype.updateToolbarItems=function(){var e=this.parent;if(e.isImageLoaded){var i=e.element.querySelector(".e-fill.e-template .e-dropdownbtn-preview"),o=e.element.querySelector(".e-stroke.e-template .e-dropdownbtn-preview"),r=e.element.querySelector(".e-text-font-color.e-template .e-dropdownbtn-preview"),a=e.element.querySelector(".e-pen-stroke-color.e-template .e-dropdownbtn-preview"),n=e.element.querySelector(".e-shape-stroke-width"),s=e.element.querySelector(".e-text-font-family"),l=e.element.querySelector(".e-text-font-size"),p=e.element.querySelector("#"+e.element.id+"_bold"),h=e.element.querySelector("#"+e.element.id+"_italic");if(t.isNullOrUndefined(e.activeObj.strokeSettings.strokeWidth)&&(e.activeObj.strokeSettings.strokeWidth=2),i&&(""===e.activeObj.strokeSettings.fillColor?i.classList.add("e-nocolor-item"):(i.classList.remove("e-nocolor-item"),i.style.background=e.activeObj.strokeSettings.fillColor),t.getComponent(e.element.id+"_shape_fill","colorpicker").value=e.activeObj.strokeSettings.fillColor+"ff"),o&&(o.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_shape_stroke","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),r&&(r.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_text_font","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),a&&(a.style.background=e.activeObj.strokeSettings.strokeColor,t.getComponent(e.element.id+"_pen_stroke","colorpicker").value=e.activeObj.strokeSettings.strokeColor+"ff"),s&&(t.Browser.isDevice?s.setAttribute("style","font-family:"+e.activeObj.textSettings.fontFamily.toLowerCase()):s.textContent=e.activeObj.textSettings.fontFamily),l)for(var c=0;c<e.fontSizeColl.length;c++)if(parseInt(e.fontSizeColl[c].text,10)>=Math.round(e.activeObj.textSettings.fontSize)){l.textContent=(c+1).toString();break}if(p&&(e.activeObj.textSettings.bold?p.classList.add("e-selected-btn"):p.classList.remove("e-selected-btn")),h&&(e.activeObj.textSettings.italic?h.classList.add("e-selected-btn"):h.classList.remove("e-selected-btn")),n){var d=Math.round(e.activeObj.strokeSettings.strokeWidth).toString();n.textContent=this.getStrokeWidth(d)}}},n.prototype.getStrokeWidth=function(e){var t;switch(parseInt(e,10)/2){case 1:t=this.l10n.getConstant("XSmall");break;case 2:t=this.l10n.getConstant("Small");break;case 3:t=this.l10n.getConstant("Medium");break;case 4:t=this.l10n.getConstant("Large");break;case 5:t=this.l10n.getConstant("XLarge")}return t},n.prototype.cancelPan=function(){var e=this.parent;e.notify("shape",{prop:"applyActObj",onPropertyChange:!1,value:{isMouseDown:!0}});var t=e.element.querySelector(".e-img-pan .e-btn");t&&t.classList.remove("e-selected-btn"),e.pan(!1)},n.prototype.refreshMainToolbar=function(){"main"!==this.currToolbar&&this.refreshToolbar("main")},n.prototype.destroySubComponents=function(){for(var e=this.parent,i=e.element.querySelectorAll("input.e-control"),o=e.element.querySelectorAll("button.e-control"),r=0,a=i.length;r<a;r++)i[r].classList.contains("e-color-picker")&&(t.getComponent(i[r],"color-picker").destroy(),t.detach(t.select("input#"+i[r].id,e.element)));for(r=0,a=o.length;r<a;r++)o[r].classList.contains("e-dropdown-btn")?(t.getComponent(o[r],"dropdown-btn").destroy(),t.detach(t.select("button#"+o[r].id,e.element))):o[r].classList.contains("e-btn")&&(t.getComponent(o[r],"btn").destroy(),t.detach(t.select("button#"+o[r].id,e.element)))},n.prototype.setInitialShapeSettings=function(e){var t=this.parent;t.notify("shape",{prop:"refreshActiveObj",onPropertyChange:!1}),t.currObjType.shape=e.item.id,t.activeObj.shape=t.currObjType.shape.toLowerCase(),t.currObjType.isDragging=t.currObjType.isCustomCrop=!1,t.activeObj.shapeDegree=t.transform.degree,t.activeObj.shapeFlip=t.transform.currFlipState,t.activeObj.textFlip=t.transform.currFlipState,t.activeObj.flipObjColl=[]},n.prototype.getModuleName=function(){return"toolbar-module"},n}();e.Crop=n,e.Draw=s,e.Export=l,e.Filter=p,e.FreehandDrawing=h,e.Selection=c,e.Shape=d,e.Transform=v,e.UndoRedo=u,e.FinetuneSettings=f,e.ZoomSettings=m,e.SelectionSettings=C,e.ImageEditor=y,e.ToolbarModule=j,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
11
11
|
//# sourceMappingURL=ej2-image-editor.umd.min.js.map
|