!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e()}(this,function(){"use strict";function e(e,t){var i,a=Object.keys(e);return Object.getOwnPropertySymbols&&(i=Object.getOwnPropertySymbols(e),t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,i)),a}function B(a){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),!0).forEach(function(t){var e,i;e=a,t=n[i=t],(i=o(i))in e?Object.defineProperty(e,i,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[i]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach(function(t){Object.defineProperty(a,t,Object.getOwnPropertyDescriptor(n,t))})}return a}function o(t){t=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0===i)return("string"===e?String:Number)(t);if("object"!=typeof(e=i.call(t,e||"default")))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:t+""}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,o(a.key),a)}}function T(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(i="Object"===i&&t.constructor?t.constructor.name:i)||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i<e;i++)a[i]=t[i];return a}var t="undefined"!=typeof window&&void 0!==window.document,r=t?window:{},h=!(!t||!r.document.documentElement)&&"ontouchstart"in r.document.documentElement,s=t&&"PointerEvent"in r,c="cropper",k="all",O="crop",E="move",W="zoom",H="e",N="w",L="s",z="n",Y="ne",X="nw",R="se",S="sw",d="".concat(c,"-crop"),l="".concat(c,"-disabled"),j="".concat(c,"-hidden"),p="".concat(c,"-hide"),m="".concat(c,"-invisible"),u="".concat(c,"-modal"),g="".concat(c,"-move"),f="".concat(c,"Action"),v="".concat(c,"Preview"),w="crop",b="move",y="none",x="crop",M="cropend",C="cropmove",D="cropstart",A="dblclick",P=s?"pointerdown":h?"touchstart":"mousedown",I=s?"pointermove":h?"touchmove":"mousemove",U=s?"pointerup pointercancel":h?"touchend touchcancel":"mouseup",q="zoom",$="image/jpeg",Q=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,K=/^data:/,Z=/^data:image\/jpeg;base64,/,G=/^img|canvas$/i,V={viewMode:0,dragMode:w,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},F=Number.isNaN||r.isNaN;function J(t){return"number"==typeof t&&!F(t)}function _(t){return 0<t&&t<1/0}function tt(t){return void 0===t}function et(t){return"object"===i(t)&&null!==t}var it=Object.prototype.hasOwnProperty;function at(t){if(!et(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&it.call(i,"isPrototypeOf")}catch(t){return!1}}function nt(t){return"function"==typeof t}var ot=Array.prototype.slice;function rt(t){return Array.from?Array.from(t):ot.call(t)}function ht(i,a){return i&&nt(a)&&(Array.isArray(i)||J(i.length)?rt(i).forEach(function(t,e){a.call(i,t,e,i)}):et(i)&&Object.keys(i).forEach(function(t){a.call(i,i[t],t,i)})),i}var st=Object.assign||function(i){for(var t=arguments.length,e=new Array(1<t?t-1:0),a=1;a<t;a++)e[a-1]=arguments[a];return et(i)&&0<e.length&&e.forEach(function(e){et(e)&&Object.keys(e).forEach(function(t){i[t]=e[t]})}),i},ct=/\.\d*(?:0|9){12}\d*$/;function dt(t,e){e=1<arguments.length&&void 0!==e?e:1e11;return ct.test(t)?Math.round(t*e)/e:t}var lt=/^width|height|left|top|marginLeft|marginTop$/;function pt(t,e){var i=t.style;ht(e,function(t,e){lt.test(e)&&J(t)&&(t="".concat(t,"px")),i[e]=t})}function mt(t,e){var i;e&&(J(t.length)?ht(t,function(t){mt(t,e)}):t.classList?t.classList.add(e):(i=t.className.trim())?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e)}function ut(t,e){e&&(J(t.length)?ht(t,function(t){ut(t,e)}):t.classList?t.classList.remove(e):0<=t.className.indexOf(e)&&(t.className=t.className.replace(e,"")))}function gt(t,e,i){e&&(J(t.length)?ht(t,function(t){gt(t,e,i)}):(i?mt:ut)(t,e))}var ft=/([a-z\d])([A-Z])/g;function vt(t){return t.replace(ft,"$1-$2").toLowerCase()}function wt(t,e){return et(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(vt(e)))}function bt(t,e,i){et(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(vt(e)),i)}var yt,xt,Mt=/\s\s*/,Ct=(xt=!1,t&&(yt=!1,At=function(){},It=Object.defineProperty({},"once",{get:function(){return xt=!0,yt},set:function(t){yt=t}}),r.addEventListener("test",At,It),r.removeEventListener("test",At,It)),xt);function Dt(i,t,a,e){var n=3<arguments.length&&void 0!==e?e:{},o=a;t.trim().split(Mt).forEach(function(t){var e;Ct||(e=i.listeners)&&e[t]&&e[t][a]&&(o=e[t][a],delete e[t][a],0===Object.keys(e[t]).length&&delete e[t],0===Object.keys(e).length&&delete i.listeners),i.removeEventListener(t,o,n)})}function Bt(o,t,r,e){var h=3<arguments.length&&void 0!==e?e:{},s=r;t.trim().split(Mt).forEach(function(a){var t,n;h.once&&!Ct&&(t=o.listeners,s=function(){delete n[a][r],o.removeEventListener(a,s,h);for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];r.apply(o,e)},(n=void 0===t?{}:t)[a]||(n[a]={}),n[a][r]&&o.removeEventListener(a,n[a][r],h),n[a][r]=s,o.listeners=n),o.addEventListener(a,s,h)})}function kt(t,e,i){var a;return nt(Event)&&nt(CustomEvent)?a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(a=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(a)}function Ot(t){t=t.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}var Tt=r.location,Et=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function Wt(t){t=t.match(Et);return null!==t&&(t[1]!==Tt.protocol||t[2]!==Tt.hostname||t[3]!==Tt.port)}function Ht(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function Nt(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,t=[];J(n)&&0!==n&&t.push("translateX(".concat(n,"px)")),J(o)&&0!==o&&t.push("translateY(".concat(o,"px)")),J(e)&&0!==e&&t.push("rotate(".concat(e,"deg)")),J(i)&&1!==i&&t.push("scaleX(".concat(i,")")),J(a)&&1!==a&&t.push("scaleY(".concat(a,")"));t=t.length?t.join(" "):"none";return{WebkitTransform:t,msTransform:t,transform:t}}function Lt(t,e){var i=t.pageX,a=t.pageY,t={endX:i,endY:a};return e?t:B({startX:i,startY:a},t)}function zt(t,e){var i=t.aspectRatio,a=t.height,n=t.width,o=1<arguments.length&&void 0!==e?e:"contain",r=_(n),t=_(a);return r&&t?(e=a*i,"contain"===o&&n<e||"cover"===o&&e<n?a=n/i:n=a*i):r?a=n/i:t&&(n=a*i),{width:n,height:a}}var Yt=String.fromCharCode;var Xt=/^data:.*,/;function Rt(t){var e,i,a,n,o,r,h,s=new DataView(t);try{if(255===s.getUint8(0)&&216===s.getUint8(1))for(var c=s.byteLength,d=2;d+1<c;){if(255===s.getUint8(d)&&225===s.getUint8(d+1)){i=d;break}d+=1}if(i&&(n=i+10,"Exif"===function(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=Yt(t.getUint8(n));return a}(s,i+4,4)&&(!(h=18761===(o=s.getUint16(n)))&&19789!==o||42!==s.getUint16(n+2,h)||8<=(r=s.getUint32(n+4,h))&&(a=n+r))),a)for(var l,p=s.getUint16(a,h),m=0;m<p;m+=1)if(l=a+12*m+2,274===s.getUint16(l,h)){l+=8,e=s.getUint16(l,h),s.setUint16(l,1,h);break}}catch(t){e=1}return e}var St={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,a=this.cropper,n=Number(e.minContainerWidth),e=Number(e.minContainerHeight);mt(a,j),ut(t,j);e={width:Math.max(i.offsetWidth,0<=n?n:200),height:Math.max(i.offsetHeight,0<=e?e:100)};pt(a,{width:(this.containerData=e).width,height:e.height}),mt(t,j),ut(a,j)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180==90,n=a?e.naturalHeight:e.naturalWidth,o=a?e.naturalWidth:e.naturalHeight,r=n/o,a=t.width,e=t.height;t.height*r>t.width?3===i?a=t.height*r:e=t.width/r:3===i?e=t.width/r:a=t.height*r;e={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:a,height:e};this.canvasData=e,this.limited=1===i||2===i,this.limitCanvas(!0,!0),e.width=Math.min(Math.max(e.width,e.minWidth),e.maxWidth),e.height=Math.min(Math.max(e.height,e.minHeight),e.maxHeight),e.left=(t.width-e.width)/2,e.top=(t.height-e.height)/2,e.oldLeft=e.left,e.oldTop=e.top,this.initialCanvasData=st({},e)},limitCanvas:function(t,e){var i,a=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,h=a.viewMode,s=o.aspectRatio,c=this.cropped&&r;t&&(t=Number(a.minCanvasWidth)||0,i=Number(a.minCanvasHeight)||0,1<h?(t=Math.max(t,n.width),i=Math.max(i,n.height),3===h&&(t<i*s?t=i*s:i=t/s)):0<h&&(t?t=Math.max(t,c?r.width:0):i?i=Math.max(i,c?r.height:0):c&&((t=r.width)<(i=r.height)*s?t=i*s:i=t/s)),t=(s=zt({aspectRatio:s,width:t,height:i})).width,i=s.height,o.minWidth=t,o.minHeight=i,o.maxWidth=1/0,o.maxHeight=1/0),e&&((c?0:1)<h?(i=n.width-o.width,e=n.height-o.height,o.minLeft=Math.min(0,i),o.minTop=Math.min(0,e),o.maxLeft=Math.max(0,i),o.maxTop=Math.max(0,e),c&&this.limited&&(o.minLeft=Math.min(r.left,r.left+(r.width-o.width)),o.minTop=Math.min(r.top,r.top+(r.height-o.height)),o.maxLeft=r.left,o.maxTop=r.top,2===h&&(o.width>=n.width&&(o.minLeft=Math.min(0,i),o.maxLeft=Math.max(0,i)),o.height>=n.height&&(o.minTop=Math.min(0,e),o.maxTop=Math.max(0,e))))):(o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=n.width,o.maxTop=n.height))},renderCanvas:function(t,e){var i,a,n=this.canvasData,o=this.imageData;e&&(i=(a=function(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),t=Math.cos(n),n=e*t+i*o,t=e*o+i*t;return 90<a?{width:t,height:n}:{width:n,height:t}}({width:o.naturalWidth*Math.abs(o.scaleX||1),height:o.naturalHeight*Math.abs(o.scaleY||1),degree:o.rotate||0})).width,e=a.height,o=n.width*(i/n.naturalWidth),a=n.height*(e/n.naturalHeight),n.left-=(o-n.width)/2,n.top-=(a-n.height)/2,n.width=o,n.height=a,n.aspectRatio=i/e,n.naturalWidth=i,n.naturalHeight=e,this.limitCanvas(!0,!1)),(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCanvas(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,pt(this.canvas,st({width:n.width,height:n.height},Nt({translateX:n.left,translateY:n.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);st(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),pt(this.image,st({width:i.width,height:i.height},Nt(st({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,t={width:e.width,height:e.height};i&&(e.height*i>e.width?t.height=t.width/i:t.width=t.height*i),this.cropBoxData=t,this.limitCropBox(!0,!0),t.width=Math.min(Math.max(t.width,t.minWidth),t.maxWidth),t.height=Math.min(Math.max(t.height,t.minHeight),t.maxHeight),t.width=Math.max(t.minWidth,t.width*a),t.height=Math.max(t.minHeight,t.height*a),t.left=e.left+(e.width-t.width)/2,t.top=e.top+(e.height-t.height)/2,t.oldLeft=t.left,t.oldTop=t.top,this.initialCropBoxData=st({},t)},limitCropBox:function(t,e){var i,a,n=this.options,o=this.containerData,r=this.canvasData,h=this.cropBoxData,s=this.limited,c=n.aspectRatio;t&&(i=Number(n.minCropBoxWidth)||0,a=Number(n.minCropBoxHeight)||0,t=s?Math.min(o.width,r.width,r.width+r.left,o.width-r.left):o.width,n=s?Math.min(o.height,r.height,r.height+r.top,o.height-r.top):o.height,i=Math.min(i,o.width),a=Math.min(a,o.height),c&&(i&&a?i<a*c?a=i/c:i=a*c:i?a=i/c:a&&(i=a*c),t<n*c?n=t/c:t=n*c),h.minWidth=Math.min(i,t),h.minHeight=Math.min(a,n),h.maxWidth=t,h.maxHeight=n),e&&(s?(h.minLeft=Math.max(0,r.left),h.minTop=Math.max(0,r.top),h.maxLeft=Math.min(o.width,r.left+r.width)-h.width,h.maxTop=Math.min(o.height,r.top+r.height)-h.height):(h.minLeft=0,h.minTop=0,h.maxLeft=o.width-h.width,h.maxTop=o.height-h.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&bt(this.face,f,i.width>=e.width&&i.height>=e.height?E:k),pt(this.cropBox,st({width:i.width,height:i.height},Nt({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),kt(this.element,x,this.getData())}},jt={initPreview:function(){var t=this.element,i=this.crossOrigin,e=this.options.preview,a=i?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");i&&(o.crossOrigin=i),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,e&&("string"==typeof(o=e)?o=t.ownerDocument.querySelectorAll(e):e.querySelector&&(o=[e]),ht(this.previews=o,function(t){var e=document.createElement("img");bt(t,v,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),i&&(e.crossOrigin=i),e.src=a,e.alt=n,e.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(e)}))},resetPreview:function(){ht(this.previews,function(t){var e=wt(t,v);pt(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function(e,i){if(et(e[i]))try{delete e[i]}catch(t){e[i]=void 0}else if(e.dataset)try{delete e.dataset[i]}catch(t){e.dataset[i]=void 0}else e.removeAttribute("data-".concat(vt(i)))}(t,v)})},preview:function(){var r=this.imageData,t=this.canvasData,e=this.cropBoxData,h=e.width,s=e.height,c=r.width,d=r.height,l=e.left-t.left-r.left,p=e.top-t.top-r.top;this.cropped&&!this.disabled&&(pt(this.viewBoxImage,st({width:c,height:d},Nt(st({translateX:-l,translateY:-p},r)))),ht(this.previews,function(t){var e=wt(t,v),i=e.width,a=e.height,n=i,o=a,e=1;h&&(o=s*(e=i/h)),s&&a<o&&(n=h*(e=a/s),o=a),pt(t,{width:n,height:o}),pt(t.getElementsByTagName("img")[0],st({width:c*e,height:d*e},Nt(st({translateX:-l*e,translateY:-p*e},r))))}))}},s={bind:function(){var t=this.element,e=this.options,i=this.cropper;nt(e.cropstart)&&Bt(t,D,e.cropstart),nt(e.cropmove)&&Bt(t,C,e.cropmove),nt(e.cropend)&&Bt(t,M,e.cropend),nt(e.crop)&&Bt(t,x,e.crop),nt(e.zoom)&&Bt(t,q,e.zoom),Bt(i,P,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&Bt(i,"wheel",this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Bt(i,A,this.onDblclick=this.dblclick.bind(this)),Bt(t.ownerDocument,I,this.onCropMove=this.cropMove.bind(this)),Bt(t.ownerDocument,U,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&Bt(window,"resize",this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;nt(e.cropstart)&&Dt(t,D,e.cropstart),nt(e.cropmove)&&Dt(t,C,e.cropmove),nt(e.cropend)&&Dt(t,M,e.cropend),nt(e.crop)&&Dt(t,x,e.crop),nt(e.zoom)&&Dt(t,q,e.zoom),Dt(i,P,this.onCropStart),e.zoomable&&e.zoomOnWheel&&Dt(i,"wheel",this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Dt(i,A,this.onDblclick),Dt(t.ownerDocument,I,this.onCropMove),Dt(t.ownerDocument,U,this.onCropEnd),e.responsive&&Dt(window,"resize",this.onResize)}},h={resize:function(){var t,e,i,a,n,o,r;this.disabled||(t=this.options,e=this.container,a=this.containerData,i=e.offsetWidth/a.width,a=e.offsetHeight/a.height,1!=(n=Math.abs(i-1)>Math.abs(a-1)?i:a)&&(t.restore&&(o=this.getCanvasData(),r=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(ht(o,function(t,e){o[e]=t*n})),this.setCropBoxData(ht(r,function(t,e){r[e]=t*n})))))},dblclick:function(){var t,e;this.disabled||this.options.dragMode===y||this.setDragMode((t=this.dragBox,e=d,(t.classList?t.classList.contains(e):-1<t.className.indexOf(e))?b:w))},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?a=0<t.deltaY?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=0<t.detail?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){var e,i=t.buttons,a=t.button;this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(J(i)&&1!==i||J(a)&&0!==a||t.ctrlKey)||(a=this.options,e=this.pointers,t.changedTouches?ht(t.changedTouches,function(t){e[t.identifier]=Lt(t)}):e[t.pointerId||0]=Lt(t),a=1<Object.keys(e).length&&a.zoomable&&a.zoomOnTouch?W:wt(t.target,f),Q.test(a)&&!1!==kt(this.element,D,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===O&&(this.cropping=!0,mt(this.dragBox,u))))},cropMove:function(t){var e,i=this.action;!this.disabled&&i&&(e=this.pointers,t.preventDefault(),!1!==kt(this.element,C,{originalEvent:t,action:i})&&(t.changedTouches?ht(t.changedTouches,function(t){st(e[t.identifier]||{},Lt(t,!0))}):st(e[t.pointerId||0]||{},Lt(t,!0)),this.change(t)))},cropEnd:function(t){var e,i;this.disabled||(e=this.action,i=this.pointers,t.changedTouches?ht(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,gt(this.dragBox,u,this.cropped&&this.options.modal)),kt(this.element,M,{originalEvent:t,action:e})))}},t={change:function(t){var e=this.options,i=this.canvasData,a=this.containerData,n=this.cropBoxData,o=this.pointers,r=this.action,h=e.aspectRatio,s=n.left,c=n.top,d=n.width,l=n.height,p=s+d,m=c+l,u=0,g=0,f=a.width,v=a.height,w=!0;!h&&t.shiftKey&&(h=d&&l?d/l:1),this.limited&&(u=n.minLeft,g=n.minTop,f=u+Math.min(a.width,i.width,i.left+i.width),v=g+Math.min(a.height,i.height,i.top+i.height));function b(t){switch(t){case H:p+D.x>f&&(D.x=f-p);break;case N:s+D.x<u&&(D.x=u-s);break;case z:c+D.y<g&&(D.y=g-c);break;case L:m+D.y>v&&(D.y=v-m)}}var y,x,M,C=o[Object.keys(o)[0]],D={x:C.endX-C.startX,y:C.endY-C.startY};switch(r){case k:s+=D.x,c+=D.y;break;case H:if(0<=D.x&&(f<=p||h&&(c<=g||v<=m))){w=!1;break}b(H),(d+=D.x)<0&&(r=N,s-=d=-d),h&&(c+=(n.height-(l=d/h))/2);break;case z:if(D.y<=0&&(c<=g||h&&(s<=u||f<=p))){w=!1;break}b(z),l-=D.y,c+=D.y,l<0&&(r=L,c-=l=-l),h&&(s+=(n.width-(d=l*h))/2);break;case N:if(D.x<=0&&(s<=u||h&&(c<=g||v<=m))){w=!1;break}b(N),d-=D.x,s+=D.x,d<0&&(r=H,s-=d=-d),h&&(c+=(n.height-(l=d/h))/2);break;case L:if(0<=D.y&&(v<=m||h&&(s<=u||f<=p))){w=!1;break}b(L),(l+=D.y)<0&&(r=z,c-=l=-l),h&&(s+=(n.width-(d=l*h))/2);break;case Y:if(h){if(D.y<=0&&(c<=g||f<=p)){w=!1;break}b(z),l-=D.y,c+=D.y,d=l*h}else b(z),b(H),!(0<=D.x)||p<f?d+=D.x:D.y<=0&&c<=g&&(w=!1),D.y<=0&&!(g<c)||(l-=D.y,c+=D.y);d<0&&l<0?(r=S,c-=l=-l,s-=d=-d):d<0?(r=X,s-=d=-d):l<0&&(r=R,c-=l=-l);break;case X:if(h){if(D.y<=0&&(c<=g||s<=u)){w=!1;break}b(z),l-=D.y,c+=D.y,s+=n.width-(d=l*h)}else b(z),b(N),!(D.x<=0)||u<s?(d-=D.x,s+=D.x):D.y<=0&&c<=g&&(w=!1),D.y<=0&&!(g<c)||(l-=D.y,c+=D.y);d<0&&l<0?(r=R,c-=l=-l,s-=d=-d):d<0?(r=Y,s-=d=-d):l<0&&(r=S,c-=l=-l);break;case S:if(h){if(D.x<=0&&(s<=u||v<=m)){w=!1;break}b(N),d-=D.x,s+=D.x,l=d/h}else b(L),b(N),!(D.x<=0)||u<s?(d-=D.x,s+=D.x):0<=D.y&&v<=m&&(w=!1),0<=D.y&&!(m<v)||(l+=D.y);d<0&&l<0?(r=Y,c-=l=-l,s-=d=-d):d<0?(r=R,s-=d=-d):l<0&&(r=X,c-=l=-l);break;case R:if(h){if(0<=D.x&&(f<=p||v<=m)){w=!1;break}b(H),l=(d+=D.x)/h}else b(L),b(H),!(0<=D.x)||p<f?d+=D.x:0<=D.y&&v<=m&&(w=!1),0<=D.y&&!(m<v)||(l+=D.y);d<0&&l<0?(r=X,c-=l=-l,s-=d=-d):d<0?(r=S,s-=d=-d):l<0&&(r=Y,c-=l=-l);break;case E:this.move(D.x,D.y),w=!1;break;case W:this.zoom((x=B({},y=o),M=0,ht(y,function(n,t){delete x[t],ht(x,function(t){var e=Math.abs(n.startX-t.startX),i=Math.abs(n.startY-t.startY),a=Math.abs(n.endX-t.endX),t=Math.abs(n.endY-t.endY),i=Math.sqrt(e*e+i*i),i=(Math.sqrt(a*a+t*t)-i)/i;Math.abs(i)>Math.abs(M)&&(M=i)})}),M),t),w=!1;break;case O:if(!D.x||!D.y){w=!1;break}y=Ot(this.cropper),s=C.startX-y.left,c=C.startY-y.top,d=n.minWidth,l=n.minHeight,0<D.x?r=0<D.y?R:Y:D.x<0&&(s-=d,r=0<D.y?S:X),D.y<0&&(c-=l),this.cropped||(ut(this.cropBox,j),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}w&&(n.width=d,n.height=l,n.left=s,n.top=c,this.action=r,this.renderCropBox()),ht(o,function(t){t.startX=t.endX,t.startY=t.endY})}},At={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&mt(this.dragBox,u),ut(this.cropBox,j),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=st({},this.initialImageData),this.canvasData=st({},this.initialCanvasData),this.cropBoxData=st({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(st(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),ut(this.dragBox,u),mt(this.cropBox,j)),this},replace:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&e&&(this.isImg&&(this.element.src=e),t?(this.url=e,this.image.src=e,this.ready&&(this.viewBoxImage.src=e,ht(this.previews,function(t){t.getElementsByTagName("img")[0].src=e}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(e))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,ut(this.cropper,l)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,mt(this.cropper,l)),this},destroy:function(){var t=this.element;return t[c]&&(t[c]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate()),this},move:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,i=i.top;return this.moveTo(tt(t)?t:a+Number(t),tt(e)?e:i+Number(e))},moveTo:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(J(t)&&(i.left=t,a=!0),J(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=Number(t),this.zoomTo(i.width*(t=t<0?1/(1-t):1+t)/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a,n,o,r=this.options,h=this.canvasData,s=h.width,c=h.height,d=h.naturalWidth,l=h.naturalHeight;if(0<=(t=Number(t))&&this.ready&&!this.disabled&&r.zoomable){r=d*t,l=l*t;if(!1===kt(this.element,q,{ratio:t,oldRatio:s/d,originalEvent:i}))return this;i?(t=this.pointers,d=Ot(this.cropper),i=t&&Object.keys(t).length?(o=n=a=0,ht(t,function(t){var e=t.startX,t=t.startY;a+=e,n+=t,o+=1}),{pageX:a/=o,pageY:n/=o}):{pageX:i.pageX,pageY:i.pageY},h.left-=(r-s)*((i.pageX-d.left-h.left)/s),h.top-=(l-c)*((i.pageY-d.top-h.top)/c)):at(e)&&J(e.x)&&J(e.y)?(h.left-=(r-s)*((e.x-h.left)/s),h.top-=(l-c)*((e.y-h.top)/c)):(h.left-=(r-s)/2,h.top-=(l-c)/2),h.width=r,h.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return J(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,J(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(J(e)?e:1,t)},scale:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(J(t)&&(i.scaleX=t,a=!0),J(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var i,a,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.options,n=this.imageData,o=this.canvasData,r=this.cropBoxData;return this.ready&&this.cropped?(i={x:r.left-o.left,y:r.top-o.top,width:r.width,height:r.height},a=n.width/n.naturalWidth,ht(i,function(t,e){i[e]=t/a}),t&&(r=Math.round(i.y+i.height),t=Math.round(i.x+i.width),i.x=Math.round(i.x),i.y=Math.round(i.y),i.width=t-i.x,i.height=r-i.y)):i={x:0,y:0,width:0,height:0},e.rotatable&&(i.rotate=n.rotate||0),e.scalable&&(i.scaleX=n.scaleX||1,i.scaleY=n.scaleY||1),i},setData:function(t){var e,i=this.options,a=this.imageData,n=this.canvasData,o={};return this.ready&&!this.disabled&&at(t)&&(e=!1,i.rotatable&&J(t.rotate)&&t.rotate!==a.rotate&&(a.rotate=t.rotate,e=!0),i.scalable&&(J(t.scaleX)&&t.scaleX!==a.scaleX&&(a.scaleX=t.scaleX,e=!0),J(t.scaleY)&&t.scaleY!==a.scaleY&&(a.scaleY=t.scaleY,e=!0)),e&&this.renderCanvas(!0,!0),a=a.width/a.naturalWidth,J(t.x)&&(o.left=t.x*a+n.left),J(t.y)&&(o.top=t.y*a+n.top),J(t.width)&&(o.width=t.width*a),J(t.height)&&(o.height=t.height*a),this.setCropBoxData(o)),this},getContainerData:function(){return this.ready?st({},this.containerData):{}},getImageData:function(){return this.sized?st({},this.imageData):{}},getCanvasData:function(){var e=this.canvasData,i={};return this.ready&&ht(["left","top","width","height","naturalWidth","naturalHeight"],function(t){i[t]=e[t]}),i},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&at(t)&&(J(t.left)&&(e.left=t.left),J(t.top)&&(e.top=t.top),J(t.width)?(e.width=t.width,e.height=t.width/i):J(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return(t=this.ready&&this.cropped?{left:e.left,top:e.top,width:e.width,height:e.height}:t)||{}},setCropBoxData:function(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&at(t)&&(J(t.left)&&(a.left=t.left),J(t.top)&&(a.top=t.top),J(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),J(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e,i,a,n,o,r,h,s,c,d,l,p,m=this.canvasData,u=(w=this.image,e=this.imageData,i=m,y=t,a=e.aspectRatio,n=e.naturalWidth,b=e.naturalHeight,o=void 0===(p=e.rotate)?0:p,u=void 0===(v=e.scaleX)?1:v,g=void 0===(d=e.scaleY)?1:d,r=i.aspectRatio,h=i.naturalWidth,s=i.naturalHeight,c=void 0===(l=y.fillColor)?"transparent":l,x=y.imageSmoothingEnabled,f=void 0===x||x,v=void 0===(p=y.imageSmoothingQuality)?"low":p,d=void 0===(e=y.maxWidth)?1/0:e,l=void 0===(i=y.maxHeight)?1/0:i,p=void 0===(x=y.minWidth)?0:x,i=void 0===(e=y.minHeight)?0:e,y=(x=document.createElement("canvas")).getContext("2d"),e=zt({aspectRatio:r,width:d,height:l}),r=zt({aspectRatio:r,width:p,height:i},"cover"),h=Math.min(e.width,Math.max(r.width,h)),s=Math.min(e.height,Math.max(r.height,s)),l=zt({aspectRatio:a,width:d,height:l}),i=zt({aspectRatio:a,width:p,height:i},"cover"),n=Math.min(l.width,Math.max(i.width,n)),b=Math.min(l.height,Math.max(i.height,b)),b=[-n/2,-b/2,n,b],x.width=dt(h),x.height=dt(s),y.fillStyle=c,y.fillRect(0,0,h,s),y.save(),y.translate(h/2,s/2),y.rotate(o*Math.PI/180),y.scale(u,g),y.imageSmoothingEnabled=f,y.imageSmoothingQuality=v,y.drawImage.apply(y,[w].concat(T(b.map(function(t){return Math.floor(dt(t))})))),y.restore(),x);if(!this.cropped)return u;var g=this.getData(t.rounded),f=g.x,v=g.y,w=g.width,b=g.height,y=u.width/Math.floor(m.naturalWidth);1!=y&&(f*=y,v*=y,w*=y,b*=y);var x=w/b,g=zt({aspectRatio:x,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),m=zt({aspectRatio:x,width:t.minWidth||0,height:t.minHeight||0},"cover"),x=zt({aspectRatio:x,width:t.width||(1!=y?u.width:w),height:t.height||(1!=y?u.height:b)}),y=x.width,x=x.height,y=Math.min(g.width,Math.max(m.width,y)),x=Math.min(g.height,Math.max(m.height,x)),g=document.createElement("canvas"),m=g.getContext("2d");g.width=dt(y),g.height=dt(x),m.fillStyle=t.fillColor||"transparent",m.fillRect(0,0,y,x);x=t.imageSmoothingEnabled,t=t.imageSmoothingQuality;m.imageSmoothingEnabled=void 0===x||x,t&&(m.imageSmoothingQuality=t);var M,C,D,B,k,x=u.width,t=u.height,f=f,v=v;f<=-w||x<f?B=C=M=f=0:f<=0?(C=-f,f=0,B=M=Math.min(x,w+f)):f<=x&&(C=0,B=M=Math.min(w,x-f)),M<=0||v<=-b||t<v?k=D=O=v=0:v<=0?(D=-v,v=0,k=O=Math.min(t,b+v)):v<=t&&(D=0,k=O=Math.min(b,t-v));var O=[f,v,M,O];return 0<B&&0<k&&O.push(C*(w=y/w),D*w,B*w,k*w),m.drawImage.apply(m,[u].concat(T(O.map(function(t){return Math.floor(dt(t))})))),g},setAspectRatio:function(t){var e=this.options;return this.disabled||tt(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e,i,a=this.options,n=this.dragBox,o=this.face;return this.ready&&!this.disabled&&(i=a.movable&&t===b,a.dragMode=t=(e=t===w)||i?t:y,bt(n,f,t),gt(n,d,e),gt(n,g,i),a.cropBoxMovable||(bt(o,f,t),gt(o,d,e),gt(o,g,i))),this}},Pt=r.Cropper,It=function(){function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),!t||!G.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=st({},V,at(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return t=i,a=[{key:"noConflict",value:function(){return window.Cropper=Pt,i}},{key:"setDefaults",value:function(t){st(V,at(t)&&t)}}],(e=[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[c]){if(e[c]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",!(this.originalUrl=t))return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e,i,a,n,o,r,h=this;t&&(this.url=t,this.imageData={},e=this.element,(i=this.options).rotatable||i.scalable||(i.checkOrientation=!1),i.checkOrientation&&window.ArrayBuffer?K.test(t)?Z.test(t)?this.read((r=(r=t).replace(Xt,""),a=atob(r),r=new ArrayBuffer(a.length),ht(n=new Uint8Array(r),function(t,e){n[e]=a.charCodeAt(e)}),r)):this.clone():(o=new XMLHttpRequest,r=this.clone.bind(this),this.reloading=!0,(this.xhr=o).onabort=r,o.onerror=r,o.ontimeout=r,o.onprogress=function(){o.getResponseHeader("content-type")!==$&&o.abort()},o.onload=function(){h.read(o.response)},o.onloadend=function(){h.reloading=!1,h.xhr=null},i.checkCrossOrigin&&Wt(t)&&e.crossOrigin&&(t=Ht(t)),o.open("GET",t,!0),o.responseType="arraybuffer",o.withCredentials="use-credentials"===e.crossOrigin,o.send()):this.clone())}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=Rt(t),n=0,o=1,r=1;1<a&&(this.url=function(t,e){for(var i=[],a=new Uint8Array(t);0<a.length;)i.push(Yt.apply(null,rt(a.subarray(0,8192)))),a=a.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,$),n=(a=function(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}(a)).rotate,o=a.scaleX,r=a.scaleY),e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=r),this.clone()}},{key:"clone",value:function(){var t=this.element,e=this.url,i=t.crossOrigin,a=e;this.options.checkCrossOrigin&&Wt(e)&&(i=i||"anonymous",a=Ht(e)),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e,n.alt=t.alt||"The image to crop",(this.image=n).onload=this.start.bind(this),n.onerror=this.stop.bind(this),mt(n,p),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function(){var i=this,t=this.image;t.onload=null,t.onerror=null,this.sizing=!0;function e(t,e){st(i.imageData,{naturalWidth:t,naturalHeight:e,aspectRatio:t/e}),i.initialImageData=st({},i.imageData),i.sizing=!1,i.sized=!0,i.build()}var a,n,o=r.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(r.navigator.userAgent);!t.naturalWidth||o?(a=document.createElement("img"),n=document.body||document.documentElement,(this.sizingImage=a).onload=function(){e(a.width,a.height),o||n.removeChild(a)},a.src=t.src,o||(a.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",n.appendChild(a))):e(t.naturalWidth,t.naturalHeight)}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){var t,e,i,a,n,o,r,h,s;this.sized&&!this.ready&&(t=this.element,e=this.options,i=this.image,a=t.parentNode,(s=document.createElement("div")).innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',o=(n=s.querySelector(".".concat(c,"-container"))).querySelector(".".concat(c,"-canvas")),r=n.querySelector(".".concat(c,"-drag-box")),s=(h=n.querySelector(".".concat(c,"-crop-box"))).querySelector(".".concat(c,"-face")),this.container=a,this.cropper=n,this.canvas=o,this.dragBox=r,this.cropBox=h,this.viewBox=n.querySelector(".".concat(c,"-view-box")),this.face=s,o.appendChild(i),mt(t,j),a.insertBefore(n,t.nextSibling),ut(i,p),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,mt(h,j),e.guides||mt(h.getElementsByClassName("".concat(c,"-dashed")),j),e.center||mt(h.getElementsByClassName("".concat(c,"-center")),j),e.background&&mt(n,"".concat(c,"-bg")),e.highlight||mt(s,m),e.cropBoxMovable&&(mt(s,g),bt(s,f,k)),e.cropBoxResizable||(mt(h.getElementsByClassName("".concat(c,"-line")),j),mt(h.getElementsByClassName("".concat(c,"-point")),j)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),nt(e.ready)&&Bt(t,"ready",e.ready,{once:!0}),kt(t,"ready"))}},{key:"unbuild",value:function(){var t;this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),(t=this.cropper.parentNode)&&t.removeChild(this.cropper),ut(this.element,j))}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}])&&n(t.prototype,e),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,a}();return st(It.prototype,St,jt,s,h,t,At),It});