=e.width&&n.height>=e.height?$:u),At(this.cropBox,pt({width:n.width,height:n.height},Lt({translateX:n.left,translateY:n.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),_t(this.element,M,this.getData())}},Zt={initPreview:function(){var t=this.element,e=this.crossOrigin,n=this.options.preview,a=e?this.crossOriginUrl:this.url,i=t.alt||"The image to preview",r=document.createElement("img");if(e&&(r.crossOrigin=e),r.src=a,r.alt=i,this.viewBox.appendChild(r),this.viewBoxImage=r,n){var o=n;"string"==typeof n?o=t.ownerDocument.querySelectorAll(n):n.querySelector&&(o=[n]),this.previews=o,ct(o,(function(t){var n=document.createElement("img");bt(t,k,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(n.crossOrigin=e),n.src=a,n.alt=i,n.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(n)}))}},resetPreview:function(){ct(this.previews,(function(t){var e=yt(t,k);At(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function(t,e){if(it(t[e]))try{delete t[e]}catch(n){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(n){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(Ct(e)))}(t,k)}))},preview:function(){var t=this.imageData,e=this.canvasData,n=this.cropBoxData,a=n.width,i=n.height,r=t.width,o=t.height,d=n.left-e.left-t.left,s=n.top-e.top-t.top;this.cropped&&!this.disabled&&(At(this.viewBoxImage,pt({width:r,height:o},Lt(pt({translateX:-d,translateY:-s},t)))),ct(this.previews,(function(e){var n=yt(e,k),l=n.width,c=n.height,p=l,u=c,h=1;a&&(u=i*(h=l/a)),i&&u>c&&(p=a*(h=c/i),u=c),At(e,{width:p,height:u}),At(e.getElementsByTagName("img")[0],pt({width:r*h,height:o*h},Lt(pt({translateX:-d*h,translateY:-s*h},t))))})))}},Ft={bind:function(){var t=this.element,e=this.options,n=this.cropper;dt(e.cropstart)&&It(t,R,e.cropstart),dt(e.cropmove)&&It(t,T,e.cropmove),dt(e.cropend)&&It(t,j,e.cropend),dt(e.crop)&&It(t,M,e.crop),dt(e.zoom)&&It(t,Y,e.zoom),It(n,F,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&It(n,G,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&It(n,Z,this.onDblclick=this.dblclick.bind(this)),It(t.ownerDocument,U,this.onCropMove=this.cropMove.bind(this)),It(t.ownerDocument,H,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&It(window,z,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,n=this.cropper;dt(e.cropstart)&&Et(t,R,e.cropstart),dt(e.cropmove)&&Et(t,T,e.cropmove),dt(e.cropend)&&Et(t,j,e.cropend),dt(e.crop)&&Et(t,M,e.crop),dt(e.zoom)&&Et(t,Y,e.zoom),Et(n,F,this.onCropStart),e.zoomable&&e.zoomOnWheel&&Et(n,G,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Et(n,Z,this.onDblclick),Et(t.ownerDocument,U,this.onCropMove),Et(t.ownerDocument,H,this.onCropEnd),e.responsive&&Et(window,z,this.onResize)}},Ut={resize:function(){if(!this.disabled){var t,e,n=this.options,a=this.container,i=this.containerData,r=a.offsetWidth/i.width,o=a.offsetHeight/i.height,d=Math.abs(r-1)>Math.abs(o-1)?r:o;1!==d&&(n.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),n.restore&&(this.setCanvasData(ct(t,(function(e,n){t[n]=e*d}))),this.setCropBoxData(ct(e,(function(t,n){e[n]=t*d})))))}},dblclick:function(){var t,e;this.disabled||this.options.dragMode===D||this.setDragMode((t=this.dragBox,e=w,(t.classList?t.classList.contains(e):t.className.indexOf(e)>-1)?N:L))},wheel:function(t){var e=this,n=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=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*n,t)))},cropStart:function(t){var e=t.buttons,n=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(et(e)&&1!==e||et(n)&&0!==n||t.ctrlKey))){var a,i=this.options,r=this.pointers;t.changedTouches?ct(t.changedTouches,(function(t){r[t.identifier]=Nt(t)})):r[t.pointerId||0]=Nt(t),a=Object.keys(r).length>1&&i.zoomable&&i.zoomOnTouch?A:yt(t.target,S),q.test(a)&&!1!==_t(this.element,R,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===h&&(this.cropping=!0,ft(this.dragBox,P)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var n=this.pointers;t.preventDefault(),!1!==_t(this.element,T,{originalEvent:t,action:e})&&(t.changedTouches?ct(t.changedTouches,(function(t){pt(n[t.identifier]||{},Nt(t,!0))})):pt(n[t.pointerId||0]||{},Nt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,n=this.pointers;t.changedTouches?ct(t.changedTouches,(function(t){delete n[t.identifier]})):delete n[t.pointerId||0],e&&(t.preventDefault(),Object.keys(n).length||(this.action=""),this.cropping&&(this.cropping=!1,gt(this.dragBox,P,this.cropped&&this.options.modal)),_t(this.element,j,{originalEvent:t,action:e}))}}},Ht={change:function(t){var n,a=this.options,i=this.canvasData,r=this.containerData,o=this.cropBoxData,d=this.pointers,s=this.action,l=a.aspectRatio,c=o.left,p=o.top,w=o.width,E=o.height,_=c+w,B=p+E,P=0,O=0,S=r.width,k=r.height,L=!0;!l&&t.shiftKey&&(l=w&&E?w/E:1),this.limited&&(P=o.minLeft,O=o.minTop,S=P+Math.min(r.width,i.width,i.left+i.width),k=O+Math.min(r.height,i.height,i.top+i.height));var N=d[Object.keys(d)[0]],D={x:N.endX-N.startX,y:N.endY-N.startY},M=function(t){switch(t){case f:_+D.x>S&&(D.x=S-_);break;case m:c+D.xk&&(D.y=k-B)}};switch(s){case u:c+=D.x,p+=D.y;break;case f:if(D.x>=0&&(_>=S||l&&(p<=O||B>=k))){L=!1;break}M(f),(w+=D.x)<0&&(s=m,c-=w=-w),l&&(E=w/l,p+=(o.height-E)/2);break;case v:if(D.y<=0&&(p<=O||l&&(c<=P||_>=S))){L=!1;break}M(v),E-=D.y,p+=D.y,E<0&&(s=g,p-=E=-E),l&&(w=E*l,c+=(o.width-w)/2);break;case m:if(D.x<=0&&(c<=P||l&&(p<=O||B>=k))){L=!1;break}M(m),w-=D.x,c+=D.x,w<0&&(s=f,c-=w=-w),l&&(E=w/l,p+=(o.height-E)/2);break;case g:if(D.y>=0&&(B>=k||l&&(c<=P||_>=S))){L=!1;break}M(g),(E+=D.y)<0&&(s=v,p-=E=-E),l&&(w=E*l,c+=(o.width-w)/2);break;case C:if(l){if(D.y<=0&&(p<=O||_>=S)){L=!1;break}M(v),E-=D.y,p+=D.y,w=E*l}else M(v),M(f),D.x>=0?_O&&(E-=D.y,p+=D.y):(E-=D.y,p+=D.y);w<0&&E<0?(s=x,p-=E=-E,c-=w=-w):w<0?(s=y,c-=w=-w):E<0&&(s=b,p-=E=-E);break;case y:if(l){if(D.y<=0&&(p<=O||c<=P)){L=!1;break}M(v),E-=D.y,p+=D.y,w=E*l,c+=o.width-w}else M(v),M(m),D.x<=0?c>P?(w-=D.x,c+=D.x):D.y<=0&&p<=O&&(L=!1):(w-=D.x,c+=D.x),D.y<=0?p>O&&(E-=D.y,p+=D.y):(E-=D.y,p+=D.y);w<0&&E<0?(s=b,p-=E=-E,c-=w=-w):w<0?(s=C,c-=w=-w):E<0&&(s=x,p-=E=-E);break;case x:if(l){if(D.x<=0&&(c<=P||B>=k)){L=!1;break}M(m),w-=D.x,c+=D.x,E=w/l}else M(g),M(m),D.x<=0?c>P?(w-=D.x,c+=D.x):D.y>=0&&B>=k&&(L=!1):(w-=D.x,c+=D.x),D.y>=0?B=0&&(_>=S||B>=k)){L=!1;break}M(f),E=(w+=D.x)/l}else M(g),M(f),D.x>=0?_=0&&B>=k&&(L=!1):w+=D.x,D.y>=0?BMath.abs(a)&&(a=s)}))})),a}(d),t),L=!1;break;case h:if(!D.x||!D.y){L=!1;break}n=Bt(this.cropper),c=N.startX-n.left,p=N.startY-n.top,w=o.minWidth,E=o.minHeight,D.x>0?s=D.y>0?b:C:D.x<0&&(c-=w,s=D.y>0?x:y),D.y<0&&(p-=E),this.cropped||(mt(this.cropBox,I),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}L&&(o.width=w,o.height=E,o.left=c,o.top=p,this.action=s,this.renderCropBox()),ct(d,(function(t){t.startX=t.endX,t.startY=t.endY}))}},Wt={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&ft(this.dragBox,P),mt(this.cropBox,I),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=pt({},this.initialImageData),this.canvasData=pt({},this.initialCanvasData),this.cropBoxData=pt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(pt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),mt(this.dragBox,P),ft(this.cropBox,I)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,ct(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,mt(this.cropper,E)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,ft(this.cropper,E)),this},destroy:function(){var t=this.element;return t[p]?(t[p]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=this.canvasData,a=n.left,i=n.top;return this.moveTo(at(t)?t:a+Number(t),at(e)?e:i+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(et(t)&&(n.left=t,a=!0),et(e)&&(n.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var n=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(n.width*t/n.naturalWidth,null,e)},zoomTo:function(t,e,n){var a=this.options,i=this.canvasData,r=i.width,o=i.height,d=i.naturalWidth,s=i.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var l=d*t,c=s*t;if(!1===_t(this.element,Y,{ratio:t,oldRatio:r/d,originalEvent:n}))return this;if(n){var p=this.pointers,u=Bt(this.cropper),h=p&&Object.keys(p).length?function(t){var e=0,n=0,a=0;return ct(t,(function(t){var i=t.startX,r=t.startY;e+=i,n+=r,a+=1})),{pageX:e/=a,pageY:n/=a}}(p):{pageX:n.pageX,pageY:n.pageY};i.left-=(l-r)*((h.pageX-u.left-i.left)/r),i.top-=(c-o)*((h.pageY-u.top-i.top)/o)}else ot(e)&&et(e.x)&&et(e.y)?(i.left-=(l-r)*((e.x-i.left)/r),i.top-=(c-o)*((e.y-i.top)/o)):(i.left-=(l-r)/2,i.top-=(c-o)/2);i.width=l,i.height=c,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return et(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,et(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(et(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(et(t)&&(n.scaleX=t,a=!0),et(e)&&(n.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.options,a=this.imageData,i=this.canvasData,r=this.cropBoxData;if(this.ready&&this.cropped){t={x:r.left-i.left,y:r.top-i.top,width:r.width,height:r.height};var o=a.width/a.naturalWidth;if(ct(t,(function(e,n){t[n]=e/o})),e){var d=Math.round(t.y+t.height),s=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=s-t.x,t.height=d-t.y}}else t={x:0,y:0,width:0,height:0};return n.rotatable&&(t.rotate=a.rotate||0),n.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,n=this.imageData,a=this.canvasData,i={};if(this.ready&&!this.disabled&&ot(t)){var r=!1;e.rotatable&&et(t.rotate)&&t.rotate!==n.rotate&&(n.rotate=t.rotate,r=!0),e.scalable&&(et(t.scaleX)&&t.scaleX!==n.scaleX&&(n.scaleX=t.scaleX,r=!0),et(t.scaleY)&&t.scaleY!==n.scaleY&&(n.scaleY=t.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var o=n.width/n.naturalWidth;et(t.x)&&(i.left=t.x*o+a.left),et(t.y)&&(i.top=t.y*o+a.top),et(t.width)&&(i.width=t.width*o),et(t.height)&&(i.height=t.height*o),this.setCropBoxData(i)}return this},getContainerData:function(){return this.ready?pt({},this.containerData):{}},getImageData:function(){return this.sized?pt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&ct(["left","top","width","height","naturalWidth","naturalHeight"],(function(n){e[n]=t[n]})),e},setCanvasData:function(t){var e=this.canvasData,n=e.aspectRatio;return this.ready&&!this.disabled&&ot(t)&&(et(t.left)&&(e.left=t.left),et(t.top)&&(e.top=t.top),et(t.width)?(e.width=t.width,e.height=t.width/n):et(t.height)&&(e.height=t.height,e.width=t.height*n),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(t){var e,n,a=this.cropBoxData,i=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&ot(t)&&(et(t.left)&&(a.left=t.left),et(t.top)&&(a.top=t.top),et(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),et(t.height)&&t.height!==a.height&&(n=!0,a.height=t.height),i&&(e?a.height=a.width/i:n&&(a.width=a.height*i)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,n=function(t,e,n,a){var r=e.aspectRatio,o=e.naturalWidth,d=e.naturalHeight,s=e.rotate,l=void 0===s?0:s,c=e.scaleX,p=void 0===c?1:c,u=e.scaleY,h=void 0===u?1:u,$=n.aspectRatio,A=n.naturalWidth,f=n.naturalHeight,m=a.fillColor,g=void 0===m?"transparent":m,v=a.imageSmoothingEnabled,C=void 0===v||v,y=a.imageSmoothingQuality,b=void 0===y?"low":y,x=a.maxWidth,w=void 0===x?1/0:x,E=a.maxHeight,I=void 0===E?1/0:E,_=a.minWidth,B=void 0===_?0:_,P=a.minHeight,O=void 0===P?0:P,S=document.createElement("canvas"),k=S.getContext("2d"),L=Dt({aspectRatio:$,width:w,height:I}),N=Dt({aspectRatio:$,width:B,height:O},"cover"),D=Math.min(L.width,Math.max(N.width,A)),M=Math.min(L.height,Math.max(N.height,f)),j=Dt({aspectRatio:r,width:w,height:I}),T=Dt({aspectRatio:r,width:B,height:O},"cover"),R=Math.min(j.width,Math.max(T.width,o)),Z=Math.min(j.height,Math.max(T.height,d)),F=[-R/2,-Z/2,R,Z];return S.width=ht(D),S.height=ht(M),k.fillStyle=g,k.fillRect(0,0,D,M),k.save(),k.translate(D/2,M/2),k.rotate(l*Math.PI/180),k.scale(p,h),k.imageSmoothingEnabled=C,k.imageSmoothingQuality=b,k.drawImage.apply(k,[t].concat(i(F.map((function(t){return Math.floor(ht(t))}))))),k.restore(),S}(this.image,this.imageData,e,t);if(!this.cropped)return n;var a=this.getData(t.rounded),r=a.x,o=a.y,d=a.width,s=a.height,l=n.width/Math.floor(e.naturalWidth);1!==l&&(r*=l,o*=l,d*=l,s*=l);var c=d/s,p=Dt({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),u=Dt({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),h=Dt({aspectRatio:c,width:t.width||(1!==l?n.width:d),height:t.height||(1!==l?n.height:s)}),$=h.width,A=h.height;$=Math.min(p.width,Math.max(u.width,$)),A=Math.min(p.height,Math.max(u.height,A));var f=document.createElement("canvas"),m=f.getContext("2d");f.width=ht($),f.height=ht(A),m.fillStyle=t.fillColor||"transparent",m.fillRect(0,0,$,A);var g=t.imageSmoothingEnabled,v=void 0===g||g,C=t.imageSmoothingQuality;m.imageSmoothingEnabled=v,C&&(m.imageSmoothingQuality=C);var y,b,x,w,E,I,_=n.width,B=n.height,P=r,O=o;P<=-d||P>_?(P=0,y=0,x=0,E=0):P<=0?(x=-P,P=0,E=y=Math.min(_,d+P)):P<=_&&(x=0,E=y=Math.min(d,_-P)),y<=0||O<=-s||O>B?(O=0,b=0,w=0,I=0):O<=0?(w=-O,O=0,I=b=Math.min(B,s+O)):O<=B&&(w=0,I=b=Math.min(s,B-O));var S=[P,O,y,b];if(E>0&&I>0){var k=$/d;S.push(x*k,w*k,E*k,I*k)}return m.drawImage.apply(m,[n].concat(i(S.map((function(t){return Math.floor(ht(t))}))))),f},setAspectRatio:function(t){var e=this.options;return this.disabled||at(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,n=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var i=t===L,r=e.movable&&t===N;t=i||r?t:D,e.dragMode=t,bt(n,S,t),gt(n,w,i),gt(n,O,r),e.cropBoxMovable||(bt(a,S,t),gt(a,w,i),gt(a,O,r))}return this}},zt=s.Cropper,Gt=function(){function t(e){var n=arguments.length>1&&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,t),!e||!Q.test(e.tagName))throw new Error("The first argument is required and must be an or