(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["upload"],{"0639":function(t,e,i){},"2a21":function(t,e,i){"use strict";var a=i("0639"),n=i.n(a);n.a},6107:function(t,e,i){},7159:function(t,e,i){t.exports=i.p+"static/img/img.146655c9.jpg"},"95c3":function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=i("bab4"),n=o(a);function o(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var i={};for(var a in t)e.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(t,a)&&(i[a]=t[a]);return i}i("6107"),e.default={render:function(t){return t("div",{style:this.containerStyle},[t("img",{ref:"img",attrs:{src:this.src,alt:this.alt||"image",style:"max-width: 100%"},style:this.imgStyle})])},props:{containerStyle:Object,src:{type:String,default:""},alt:String,imgStyle:Object,viewMode:Number,dragMode:String,aspectRatio:Number,data:Object,preview:[String,Array,Element,NodeList],responsive:{type:Boolean,default:!0},restore:{type:Boolean,default:!0},checkCrossOrigin:{type:Boolean,default:!0},checkOrientation:{type:Boolean,default:!0},modal:{type:Boolean,default:!0},guides:{type:Boolean,default:!0},center:{type:Boolean,default:!0},highlight:{type:Boolean,default:!0},background:{type:Boolean,default:!0},autoCrop:{type:Boolean,default:!0},autoCropArea:Number,movable:{type:Boolean,default:!0},rotatable:{type:Boolean,default:!0},scalable:{type:Boolean,default:!0},zoomable:{type:Boolean,default:!0},zoomOnTouch:{type:Boolean,default:!0},zoomOnWheel:{type:Boolean,default:!0},wheelZoomRatio:Number,cropBoxMovable:{type:Boolean,default:!0},cropBoxResizable:{type:Boolean,default:!0},toggleDragModeOnDblclick:{type:Boolean,default:!0},minCanvasWidth:Number,minCanvasHeight:Number,minCropBoxWidth:Number,minCropBoxHeight:Number,minContainerWidth:Number,minContainerHeight:Number,ready:Function,cropstart:Function,cropmove:Function,cropend:Function,crop:Function,zoom:Function},mounted:function(){var t=this.$options.props,e=(t.containerStyle,t.src,t.alt,t.imgStyle,r(t,["containerStyle","src","alt","imgStyle"])),i={};for(var a in e)void 0!==this[a]&&(i[a]=this[a]);this.cropper=new n.default(this.$refs.img,i)},methods:{reset:function(){return this.cropper.reset()},clear:function(){return this.cropper.clear()},initCrop:function(){return this.cropper.crop()},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.cropper.replace(t,e)},enable:function(){return this.cropper.enable()},disable:function(){return this.cropper.disable()},destroy:function(){return this.cropper.destroy()},move:function(t,e){return this.cropper.move(t,e)},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return this.cropper.moveTo(t,e)},relativeZoom:function(t,e){return this.cropper.zoom(t,e)},zoomTo:function(t,e){return this.cropper.zoomTo(t,e)},rotate:function(t){return this.cropper.rotate(t)},rotateTo:function(t){return this.cropper.rotateTo(t)},scaleX:function(t){return this.cropper.scaleX(t)},scaleY:function(t){return this.cropper.scaleY(t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return this.cropper.scale(t,e)},getData:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.cropper.getData(t)},setData:function(t){return this.cropper.setData(t)},getContainerData:function(){return this.cropper.getContainerData()},getImageData:function(){return this.cropper.getImageData()},getCanvasData:function(){return this.cropper.getCanvasData()},setCanvasData:function(t){return this.cropper.setCanvasData(t)},getCropBoxData:function(){return this.cropper.getCropBoxData()},setCropBoxData:function(t){return this.cropper.setCropBoxData(t)},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cropper.getCroppedCanvas(t)},setAspectRatio:function(t){return this.cropper.setAspectRatio(t)},setDragMode:function(t){return this.cropper.setDragMode(t)}}}},a727:function(t,e,i){"use strict";i.r(e);var a=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",[i("div",{staticClass:"crumbs"},[i("el-breadcrumb",{attrs:{separator:"/"}},[i("el-breadcrumb-item",[i("i",{staticClass:"el-icon-lx-calendar"}),t._v(" 表单")]),i("el-breadcrumb-item",[t._v("图片上传")])],1)],1),i("div",{staticClass:"container"},[i("div",{staticClass:"content-title"},[t._v("支持拖拽")]),t._m(0),i("el-upload",{staticClass:"upload-demo",attrs:{drag:"",action:"http://jsonplaceholder.typicode.com/api/posts/",multiple:""}},[i("i",{staticClass:"el-icon-upload"}),i("div",{staticClass:"el-upload__text"},[t._v("将文件拖到此处,或"),i("em",[t._v("点击上传")])]),i("div",{staticClass:"el-upload__tip",attrs:{slot:"tip"},slot:"tip"},[t._v("只能上传jpg/png文件,且不超过500kb")])]),i("div",{staticClass:"content-title"},[t._v("支持裁剪")]),t._m(1),i("div",{staticClass:"crop-demo"},[i("img",{staticClass:"pre-img",attrs:{src:t.cropImg}}),i("div",{staticClass:"crop-demo-btn"},[t._v("选择图片 "),i("input",{staticClass:"crop-input",attrs:{type:"file",name:"image",accept:"image/*"},on:{change:t.setImage}})])]),i("el-dialog",{attrs:{title:"裁剪图片",visible:t.dialogVisible,width:"30%"},on:{"update:visible":function(e){t.dialogVisible=e}}},[i("vue-cropper",{ref:"cropper",staticStyle:{width:"100%",height:"300px"},attrs:{src:t.imgSrc,ready:t.cropImage,zoom:t.cropImage,cropmove:t.cropImage}}),i("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:t.cancelCrop}},[t._v("取 消")]),i("el-button",{attrs:{type:"primary"},on:{click:function(e){t.dialogVisible=!1}}},[t._v("确 定")])],1)],1)],1)])},n=[function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"plugins-tips"},[t._v(" Element UI自带上传组件。 访问地址:"),i("a",{attrs:{href:"http://element.eleme.io/#/zh-CN/component/upload",target:"_blank"}},[t._v("Element UI Upload")])])},function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"plugins-tips"},[t._v(" vue-cropperjs:一个封装了 cropperjs 的 Vue 组件。 访问地址:"),i("a",{attrs:{href:"https://github.com/Agontuk/vue-cropperjs",target:"_blank"}},[t._v("vue-cropperjs")])])}],o=(i("a481"),i("6762"),i("2fdb"),i("95c3")),r=i.n(o),s={name:"upload",data:function(){return{defaultSrc:i("7159"),fileList:[],imgSrc:"",cropImg:"",dialogVisible:!1}},components:{VueCropper:r.a},methods:{setImage:function(t){var e=this,i=t.target.files[0];if(i.type.includes("image/")){var a=new FileReader;a.onload=function(t){e.dialogVisible=!0,e.imgSrc=t.target.result,e.$refs.cropper&&e.$refs.cropper.replace(t.target.result)},a.readAsDataURL(i)}},cropImage:function(){this.cropImg=this.$refs.cropper.getCroppedCanvas().toDataURL()},cancelCrop:function(){this.dialogVisible=!1,this.cropImg=this.defaultSrc},imageuploaded:function(t){console.log(t)},handleError:function(){this.$notify.error({title:"上传失败",message:"图片上传接口上传失败,可更改为自己的服务器接口"})}},created:function(){this.cropImg=this.defaultSrc}},h=s,c=(i("2a21"),i("2877")),l=Object(c["a"])(h,a,n,!1,null,"13d8d42e",null);e["default"]=l.exports},bab4:function(t,e,i){ /*! * Cropper.js v1.5.6 * https://fengyuanchen.github.io/cropperjs * * Copyright 2015-present Chen Fengyuan * Released under the MIT license * * Date: 2019-10-04T04:33:48.372Z */ (function(e,i){t.exports=i()})(0,(function(){"use strict";function t(e){return t="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(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i
',lt=Number.isNaN||d.isNaN;function pt(t){return"number"===typeof t&&!lt(t)}var dt=function(t){return t>0&&t<1/0};function ut(t){return"undefined"===typeof t}function mt(e){return"object"===t(e)&&null!==e}var gt=Object.prototype.hasOwnProperty;function ft(t){if(!mt(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&>.call(i,"isPrototypeOf")}catch(a){return!1}}function vt(t){return"function"===typeof t}var bt=Array.prototype.slice;function wt(t){return Array.from?Array.from(t):bt.call(t)}function yt(t,e){return t&&vt(e)&&(Array.isArray(t)||pt(t.length)?wt(t).forEach((function(i,a){e.call(t,i,a,t)})):mt(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var xt=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a0&&i.forEach((function(e){mt(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},Ct=/\.\d*(?:0|9){12}\d*$/;function Mt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return Ct.test(t)?Math.round(t*e)/e:t}var Dt=/^width|height|left|top|marginLeft|marginTop$/;function Bt(t,e){var i=t.style;yt(e,(function(t,e){Dt.test(e)&&pt(t)&&(t="".concat(t,"px")),i[e]=t}))}function kt(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function Ot(t,e){if(e)if(pt(t.length))yt(t,(function(t){Ot(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function Tt(t,e){e&&(pt(t.length)?yt(t,(function(t){Tt(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function Nt(t,e,i){e&&(pt(t.length)?yt(t,(function(t){Nt(t,e,i)})):i?Ot(t,e):Tt(t,e))}var Et=/([a-z\d])([A-Z])/g;function Wt(t){return t.replace(Et,"$1-$2").toLowerCase()}function Ht(t,e){return mt(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(Wt(e)))}function zt(t,e,i){mt(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(Wt(e)),i)}function St(t,e){if(mt(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(Wt(e)))}var Lt=/\s\s*/,Rt=function(){var t=!1;if(p){var e=!1,i=function(){},a=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});d.addEventListener("test",i,a),d.removeEventListener("test",i,a)}return t}();function Yt(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Lt).forEach((function(e){if(!Rt){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)}))}function Xt(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Lt).forEach((function(e){if(a.once&&!Rt){var o=t.listeners,r=void 0===o?{}:o;n=function(){delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,s=new Array(o),h=0;h1&&void 0!==arguments[1]?arguments[1]:"contain",o=dt(a),r=dt(i);if(o&&r){var s=i*e;"contain"===n&&s>a||"cover"===n&&s90?{width:h,height:s}:{width:s,height:h}}function Kt(t,e,i,a){var n=e.aspectRatio,o=e.naturalWidth,r=e.naturalHeight,h=e.rotate,c=void 0===h?0:h,l=e.scaleX,p=void 0===l?1:l,d=e.scaleY,u=void 0===d?1:d,m=i.aspectRatio,g=i.naturalWidth,f=i.naturalHeight,v=a.fillColor,b=void 0===v?"transparent":v,w=a.imageSmoothingEnabled,y=void 0===w||w,x=a.imageSmoothingQuality,C=void 0===x?"low":x,M=a.maxWidth,D=void 0===M?1/0:M,B=a.maxHeight,k=void 0===B?1/0:B,O=a.minWidth,T=void 0===O?0:O,N=a.minHeight,E=void 0===N?0:N,W=document.createElement("canvas"),H=W.getContext("2d"),z=Zt({aspectRatio:m,width:D,height:k}),S=Zt({aspectRatio:m,width:T,height:E},"cover"),L=Math.min(z.width,Math.max(S.width,g)),R=Math.min(z.height,Math.max(S.height,f)),Y=Zt({aspectRatio:n,width:D,height:k}),X=Zt({aspectRatio:n,width:T,height:E},"cover"),j=Math.min(Y.width,Math.max(X.width,o)),A=Math.min(Y.height,Math.max(X.height,r)),I=[-j/2,-A/2,j,A];return W.width=Mt(L),W.height=Mt(R),H.fillStyle=b,H.fillRect(0,0,L,R),H.save(),H.translate(L/2,R/2),H.rotate(c*Math.PI/180),H.scale(p,u),H.imageSmoothingEnabled=y,H.imageSmoothingQuality=C,H.drawImage.apply(H,[t].concat(s(I.map((function(t){return Math.floor(Mt(t))}))))),H.restore(),W}var Jt=String.fromCharCode;function Gt(t,e,i){var a="";i+=e;for(var n=e;n0)i.push(Jt.apply(null,wt(n.subarray(0,a)))),n=n.subarray(a);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}function ae(t){var e,i=new DataView(t);try{var a,n,o;if(255===i.getUint8(0)&&216===i.getUint8(1)){var r=i.byteLength,s=2;while(s+1=8&&(o=c+p)}}}if(o){var d,u,m=i.getUint16(o,a);for(u=0;ut.width?3===i?s=t.height*r:h=t.width/r:3===i?h=t.width/r:s=t.height*r;var c={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:s,height:h};c.left=(t.width-s)/2,c.top=(t.height-h)/2,c.oldLeft=c.left,c.oldTop=c.top,this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),this.initialImageData=xt({},e),this.initialCanvasData=xt({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=i.viewMode,s=n.aspectRatio,h=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;r>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===r&&(l*s>c?c=l*s:l=c/s)):r>0&&(c?c=Math.max(c,h?o.width:0):l?l=Math.max(l,h?o.height:0):h&&(c=o.width,l=o.height,l*s>c?c=l*s:l=c/s));var p=Zt({aspectRatio:s,width:c,height:l});c=p.width,l=p.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(r>(h?0:1)){var d=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,d),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,d),n.maxTop=Math.max(0,u),h&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===r&&(n.width>=a.width&&(n.minLeft=Math.min(0,d),n.maxLeft=Math.max(0,d)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=Qt({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,r=n.height,s=i.width*(o/i.naturalWidth),h=i.height*(r/i.naturalHeight);i.left-=(s-i.width)/2,i.top-=(h-i.height)/2,i.width=s,i.height=h,i.aspectRatio=o/r,i.naturalWidth=o,i.naturalHeight=r,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.widthi.maxHeight||i.heighte.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=xt({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,s=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=r?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,p=r?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;h=Math.min(h,a.width),c=Math.min(c,a.height),s&&(h&&c?c*s>h?c=h/s:h=c*s:h?c=h/s:c&&(h=c*s),p*s>l?p=l/s:l=p*s),o.minWidth=Math.min(h,l),o.minHeight=Math.min(c,p),o.maxWidth=l,o.maxHeight=p}e&&(r?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.widthi.maxHeight||i.height=e.width&&i.height>=e.height?b:f),Bt(this.cropBox,xt({width:i.width,height:i.height},$t({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),jt(this.element,A,this.getData())}},re={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(e&&(o.crossOrigin=e),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,i){var r=i;"string"===typeof i?r=t.ownerDocument.querySelectorAll(i):i.querySelector&&(r=[i]),this.previews=r,yt(r,(function(t){var i=document.createElement("img");zt(t,R,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.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(i)}))}},resetPreview:function(){yt(this.previews,(function(t){var e=Ht(t,R);Bt(t,{width:e.width,height:e.height}),t.innerHTML=e.html,St(t,R)}))},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,r=t.height,s=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(Bt(this.viewBoxImage,xt({width:o,height:r},$t(xt({translateX:-s,translateY:-h},t)))),yt(this.previews,(function(e){var i=Ht(e,R),c=i.width,l=i.height,p=c,d=l,u=1;a&&(u=c/a,d=n*u),n&&d>l&&(u=l/n,p=a*u,d=l),Bt(e,{width:p,height:d}),Bt(e.getElementsByTagName("img")[0],xt({width:o*u,height:r*u},$t(xt({translateX:-s*u,translateY:-h*u},t))))})))}},se={bind:function(){var t=this.element,e=this.options,i=this.cropper;vt(e.cropstart)&&Xt(t,P,e.cropstart),vt(e.cropmove)&&Xt(t,_,e.cropmove),vt(e.cropend)&&Xt(t,I,e.cropend),vt(e.crop)&&Xt(t,A,e.crop),vt(e.zoom)&&Xt(t,tt,e.zoom),Xt(i,F,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&Xt(i,G,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Xt(i,U,this.onDblclick=this.dblclick.bind(this)),Xt(t.ownerDocument,Z,this.onCropMove=this.cropMove.bind(this)),Xt(t.ownerDocument,Q,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&Xt(window,J,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;vt(e.cropstart)&&Yt(t,P,e.cropstart),vt(e.cropmove)&&Yt(t,_,e.cropmove),vt(e.cropend)&&Yt(t,I,e.cropend),vt(e.crop)&&Yt(t,A,e.crop),vt(e.zoom)&&Yt(t,tt,e.zoom),Yt(i,F,this.onCropStart),e.zoomable&&e.zoomOnWheel&&Yt(i,G,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Yt(i,U,this.onDblclick),Yt(t.ownerDocument,Z,this.onCropMove),Yt(t.ownerDocument,Q,this.onCropEnd),e.responsive&&Yt(window,J,this.onResize)}},he={resize:function(){var t=this.options,e=this.container,i=this.containerData,a=Number(t.minContainerWidth)||rt,n=Number(t.minContainerHeight)||st;if(!(this.disabled||i.width<=a||i.height<=n)){var o,r,s=e.offsetWidth/i.width;if(1!==s||e.offsetHeight!==i.height)t.restore&&(o=this.getCanvasData(),r=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(yt(o,(function(t,e){o[e]=t*s}))),this.setCropBoxData(yt(r,(function(t,e){r[e]=t*s}))))}},dblclick:function(){this.disabled||this.options.dragMode===j||this.setDragMode(kt(this.dragBox,T)?X:Y)},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=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(pt(e)&&1!==e||pt(i)&&0!==i||t.ctrlKey))){var a,n=this.options,o=this.pointers;t.changedTouches?yt(t.changedTouches,(function(t){o[t.identifier]=Vt(t)})):o[t.pointerId||0]=Vt(t),a=Object.keys(o).length>1&&n.zoomable&&n.zoomOnTouch?w:Ht(t.target,L),it.test(a)&&!1!==jt(this.element,P,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===v&&(this.cropping=!0,Ot(this.dragBox,z)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==jt(this.element,_,{originalEvent:t,action:e})&&(t.changedTouches?yt(t.changedTouches,(function(t){xt(i[t.identifier]||{},Vt(t,!0))})):xt(i[t.pointerId||0]||{},Vt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?yt(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,Nt(this.dragBox,z,this.cropped&&this.options.modal)),jt(this.element,I,{originalEvent:t,action:e}))}}},ce={change:function(t){var e,i=this.options,a=this.canvasData,n=this.containerData,o=this.cropBoxData,r=this.pointers,s=this.action,h=i.aspectRatio,c=o.left,l=o.top,p=o.width,d=o.height,u=c+p,m=l+d,g=0,T=0,N=n.width,W=n.height,H=!0;!h&&t.shiftKey&&(h=p&&d?p/d:1),this.limited&&(g=o.minLeft,T=o.minTop,N=g+Math.min(n.width,a.width,a.left+a.width),W=T+Math.min(n.height,a.height,a.top+a.height));var z=r[Object.keys(r)[0]],S={x:z.endX-z.startX,y:z.endY-z.startY},L=function(t){switch(t){case y:u+S.x>N&&(S.x=N-u);break;case x:c+S.xW&&(S.y=W-m);break;default:}};switch(s){case f:c+=S.x,l+=S.y;break;case y:if(S.x>=0&&(u>=N||h&&(l<=T||m>=W))){H=!1;break}L(y),p+=S.x,p<0&&(s=x,p=-p,c-=p),h&&(d=p/h,l+=(o.height-d)/2);break;case M:if(S.y<=0&&(l<=T||h&&(c<=g||u>=N))){H=!1;break}L(M),d-=S.y,l+=S.y,d<0&&(s=C,d=-d,l-=d),h&&(p=d*h,c+=(o.width-p)/2);break;case x:if(S.x<=0&&(c<=g||h&&(l<=T||m>=W))){H=!1;break}L(x),p-=S.x,c+=S.x,p<0&&(s=y,p=-p,c-=p),h&&(d=p/h,l+=(o.height-d)/2);break;case C:if(S.y>=0&&(m>=W||h&&(c<=g||u>=N))){H=!1;break}L(C),d+=S.y,d<0&&(s=M,d=-d,l-=d),h&&(p=d*h,c+=(o.width-p)/2);break;case D:if(h){if(S.y<=0&&(l<=T||u>=N)){H=!1;break}L(M),d-=S.y,l+=S.y,p=d*h}else L(M),L(y),S.x>=0?uT&&(d-=S.y,l+=S.y):(d-=S.y,l+=S.y);p<0&&d<0?(s=O,d=-d,p=-p,l-=d,c-=p):p<0?(s=B,p=-p,c-=p):d<0&&(s=k,d=-d,l-=d);break;case B:if(h){if(S.y<=0&&(l<=T||c<=g)){H=!1;break}L(M),d-=S.y,l+=S.y,p=d*h,c+=o.width-p}else L(M),L(x),S.x<=0?c>g?(p-=S.x,c+=S.x):S.y<=0&&l<=T&&(H=!1):(p-=S.x,c+=S.x),S.y<=0?l>T&&(d-=S.y,l+=S.y):(d-=S.y,l+=S.y);p<0&&d<0?(s=k,d=-d,p=-p,l-=d,c-=p):p<0?(s=D,p=-p,c-=p):d<0&&(s=O,d=-d,l-=d);break;case O:if(h){if(S.x<=0&&(c<=g||m>=W)){H=!1;break}L(x),p-=S.x,c+=S.x,d=p/h}else L(C),L(x),S.x<=0?c>g?(p-=S.x,c+=S.x):S.y>=0&&m>=W&&(H=!1):(p-=S.x,c+=S.x),S.y>=0?m=0&&(u>=N||m>=W)){H=!1;break}L(y),p+=S.x,d=p/h}else L(C),L(y),S.x>=0?u=0&&m>=W&&(H=!1):p+=S.x,S.y>=0?m0?s=S.y>0?k:D:S.x<0&&(c-=p,s=S.y>0?O:B),S.y<0&&(l-=d),this.cropped||(Tt(this.cropBox,E),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break;default:}H&&(o.width=p,o.height=d,o.left=c,o.top=l,this.action=s,this.renderCropBox()),yt(r,(function(t){t.startX=t.endX,t.startY=t.endY}))}},le={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&Ot(this.dragBox,z),Tt(this.cropBox,E),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=xt({},this.initialImageData),this.canvasData=xt({},this.initialCanvasData),this.cropBoxData=xt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(xt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),Tt(this.dragBox,z),Ot(this.cropBox,E)),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,yt(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,Tt(this.cropper,N)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,Ot(this.cropper,N)),this},destroy:function(){var t=this.element;return t[g]?(t[g]=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,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(ut(t)?t:a+Number(t),ut(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&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&&(pt(t)&&(i.left=t,a=!0),pt(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=Number(t),t=t<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,r=n.height,s=n.naturalWidth,h=n.naturalHeight;if(t=Number(t),t>=0&&this.ready&&!this.disabled&&a.zoomable){var c=s*t,l=h*t;if(!1===jt(this.element,tt,{ratio:t,oldRatio:o/s,originalEvent:i}))return this;if(i){var p=this.pointers,d=At(this.cropper),u=p&&Object.keys(p).length?Ft(p):{pageX:i.pageX,pageY:i.pageY};n.left-=(c-o)*((u.pageX-d.left-n.left)/o),n.top-=(l-r)*((u.pageY-d.top-n.top)/r)}else ft(e)&&pt(e.x)&&pt(e.y)?(n.left-=(c-o)*((e.x-n.left)/o),n.top-=(l-r)*((e.y-n.top)/r)):(n.left-=(c-o)/2,n.top-=(l-r)/2);n.width=c,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),pt(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,pt(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(pt(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&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&&(pt(t)&&(i.scaleX=t,a=!0),pt(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,o=this.cropBoxData;if(this.ready&&this.cropped){t={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;if(yt(t,(function(e,i){t[i]=e/r})),e){var s=Math.round(t.y+t.height),h=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=h-t.x,t.height=s-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&ft(t)){var o=!1;e.rotatable&&pt(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(pt(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),pt(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var r=i.width/i.naturalWidth;pt(t.x)&&(n.left=t.x*r+a.left),pt(t.y)&&(n.top=t.y*r+a.top),pt(t.width)&&(n.width=t.width*r),pt(t.height)&&(n.height=t.height*r),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?xt({},this.containerData):{}},getImageData:function(){return this.sized?xt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&yt(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&ft(t)&&(pt(t.left)&&(e.left=t.left),pt(t.top)&&(e.top=t.top),pt(t.width)?(e.width=t.width,e.height=t.width/i):pt(t.height)&&(e.height=t.height,e.width=t.height*i),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,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&ft(t)&&(pt(t.left)&&(a.left=t.left),pt(t.top)&&(a.top=t.top),pt(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),pt(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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=Kt(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),n=a.x,o=a.y,r=a.width,h=a.height,c=i.width/Math.floor(e.naturalWidth);1!==c&&(n*=c,o*=c,r*=c,h*=c);var l=r/h,p=Zt({aspectRatio:l,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=Zt({aspectRatio:l,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=Zt({aspectRatio:l,width:t.width||(1!==c?i.width:r),height:t.height||(1!==c?i.height:h)}),m=u.width,g=u.height;m=Math.min(p.width,Math.max(d.width,m)),g=Math.min(p.height,Math.max(d.height,g));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=Mt(m),f.height=Mt(g),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,g);var b=t.imageSmoothingEnabled,w=void 0===b||b,y=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,y&&(v.imageSmoothingQuality=y);var x,C,M,D,B,k,O=i.width,T=i.height,N=n,E=o;N<=-r||N>O?(N=0,x=0,M=0,B=0):N<=0?(M=-N,N=0,x=Math.min(O,r+N),B=x):N<=O&&(M=0,x=Math.min(r,O-N),B=x),x<=0||E<=-h||E>T?(E=0,C=0,D=0,k=0):E<=0?(D=-E,E=0,C=Math.min(T,h+E),k=C):E<=T&&(D=0,C=Math.min(h,T-E),k=C);var W=[N,E,x,C];if(B>0&&k>0){var H=m/r;W.push(M*H,D*H,B*H,k*H)}return v.drawImage.apply(v,[i].concat(s(W.map((function(t){return Math.floor(Mt(t))}))))),f},setAspectRatio:function(t){var e=this.options;return this.disabled||ut(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=t===Y,o=e.movable&&t===X;t=n||o?t:j,e.dragMode=t,zt(i,L,t),Nt(i,T,n),Nt(i,S,o),e.cropBoxMovable||(zt(a,L,t),Nt(a,T,n),Nt(a,S,o))}return this}},pe=d.Cropper,de=function(){function t(i){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e(this,t),!i||!ot.test(i.tagName))throw new Error("The first argument is required and must be an or element.");this.element=i,this.options=xt({},ht,ft(a)&&a),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 a(t,[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[g]){if(e[g]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),a.checkOrientation&&window.ArrayBuffer)if(at.test(t))nt.test(t)?this.read(ee(t)):this.clone();else{var n=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=n,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){n.getResponseHeader("content-type")!==et&&n.abort()},n.onload=function(){e.read(n.response)},n.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&Pt(t)&&i.crossOrigin&&(t=Ut(t)),n.open("GET",t),n.responseType="arraybuffer",n.withCredentials="use-credentials"===i.crossOrigin,n.send()}else this.clone()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=ae(t),n=0,o=1,r=1;if(a>1){this.url=ie(t,et);var s=ne(a);n=s.rotate,o=s.scaleX,r=s.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&&Pt(e)&&(i||(i="anonymous"),a=Ut(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,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),Ot(n,W),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function(){var t=this,e=this.image;e.onload=null,e.onerror=null,this.sizing=!0;var i=d.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(d.navigator.userAgent),a=function(e,i){xt(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.sizing=!1,t.sized=!0,t.build()};if(!e.naturalWidth||i){var n=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=n,n.onload=function(){a(n.width,n.height),i||o.removeChild(n)},n.src=e.src,i||(n.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;",o.appendChild(n))}else a(e.naturalWidth,e.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(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,n=document.createElement("div");n.innerHTML=ct;var o=n.querySelector(".".concat(g,"-container")),r=o.querySelector(".".concat(g,"-canvas")),s=o.querySelector(".".concat(g,"-drag-box")),h=o.querySelector(".".concat(g,"-crop-box")),c=h.querySelector(".".concat(g,"-face"));this.container=a,this.cropper=o,this.canvas=r,this.dragBox=s,this.cropBox=h,this.viewBox=o.querySelector(".".concat(g,"-view-box")),this.face=c,r.appendChild(i),Ot(t,E),a.insertBefore(o,t.nextSibling),this.isImg||Tt(i,W),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,Ot(h,E),e.guides||Ot(h.getElementsByClassName("".concat(g,"-dashed")),E),e.center||Ot(h.getElementsByClassName("".concat(g,"-center")),E),e.background&&Ot(o,"".concat(g,"-bg")),e.highlight||Ot(c,H),e.cropBoxMovable&&(Ot(c,S),zt(c,L,f)),e.cropBoxResizable||(Ot(h.getElementsByClassName("".concat(g,"-line")),E),Ot(h.getElementsByClassName("".concat(g,"-point")),E)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),vt(e.ready)&&Xt(t,K,e.ready,{once:!0}),jt(t,K)}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),Tt(this.element,E))}},{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()}}],[{key:"noConflict",value:function(){return window.Cropper=pe,t}},{key:"setDefaults",value:function(t){xt(ht,ft(t)&&t)}}]),t}();return xt(de.prototype,oe,re,se,he,ce,le),de}))}}]);