!function(){function e(e,t,o,i,r,n,a){try{var s=e[n](a),c=s.value}catch(l){return void o(l)}s.done?t(c):Promise.resolve(c).then(i,r)}function t(t){return function(){var o=this,i=arguments;return new Promise((function(r,n){var a=t.apply(o,i);function s(t){e(a,r,n,s,c,"next",t)}function c(t){e(a,r,n,s,c,"throw",t)}s(void 0)}))}}function o(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||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 i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var i,r,n=[],a=!0,s=!1;try{for(o=o.call(e);!(a=(i=o.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(c){s=!0,r=c}finally{try{a||null==o.return||o.return()}finally{if(s)throw r}}return n}(e,t)||r(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){if(e){if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(e,t):void 0}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,i=new Array(t);ot)}))}var ee=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;function te(e){return!!e.isImage||(e.file&&e.file.type?0===e.file.type.indexOf("image"):e.url?(t=e.url,ee.test(t)):"string"==typeof e.content&&0===e.content.indexOf("data:image"));var t}var oe=s({props:{name:c,item:l(Object),index:Number,imageFit:String,lazyLoad:Boolean,deletable:Boolean,previewSize:c,beforeDelete:Function},emits:["delete","preview"],setup:function(e,t){var o=t.emit,i=t.slots,r=function(){var t=e.item,o=t.status,i=t.message;if("uploading"===o||"failed"===o){var r="failed"===o?u(p,{name:"close",class:K("mask-icon")},null):u(d,{class:K("loading")},null),n=f(i)&&""!==i;return u("div",{class:K("mask")},[r,n&&u("div",{class:K("mask-message")},[i])])}},n=function(t){var i=e.name,r=e.item,n=e.index,a=e.beforeDelete;t.stopPropagation(),g(a,{args:[r,{name:i,index:n}],done:function(){return o("delete")}})},a=function(){return o("preview")},s=function(){if(e.deletable&&"uploading"!==e.item.status)return u("div",{role:"button",class:K("preview-delete"),tabindex:0,"aria-label":q("delete"),onClick:n},[u(p,{name:"cross",class:K("preview-delete-icon")},null)])},c=function(){if(i["preview-cover"]){var t=e.index,o=e.item;return u("div",{class:K("preview-cover")},[i["preview-cover"](v({index:t},o))])}};return function(){return u("div",{class:K("preview")},[(t=e.item,te(t)?u(U,{fit:e.imageFit,src:t.content||t.url,class:K("preview-image"),width:e.previewSize,height:e.previewSize,lazyLoad:e.lazyLoad,onClick:a},{default:c}):u("div",{class:K("file"),style:h(e.previewSize)},[u(p,{class:K("file-icon"),name:"description"},null),u("div",{class:[K("file-name"),"van-ellipsis"]},[t.file?t.file.name:t.url]),c()])),r(),s()]);var t}}}),ie={name:m(""),accept:w("image/*"),capture:String,multiple:Boolean,disabled:Boolean,readonly:Boolean,lazyLoad:Boolean,maxCount:m(1/0),imageFit:w("cover"),resultType:w("dataUrl"),uploadIcon:w("photograph"),uploadText:String,deletable:y,afterRead:Function,showUpload:y,modelValue:b(),beforeRead:Function,beforeDelete:Function,previewSize:c,previewImage:y,previewOptions:Object,previewFullImage:y,maxSize:{type:[Number,String,Function],default:1/0}},re=s({name:_,props:ie,emits:["delete","oversize","click-upload","close-preview","click-preview","update:modelValue"],setup:function(e,t){var i,r=t.emit,n=t.slots,a=x(),s=[],c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.modelValue.length;return{name:e.name,index:t}},l=function(){a.value&&(a.value.value="")},d=function(t){if(l(),$(t,e.maxSize)){if(!Array.isArray(t))return void r("oversize",t,c());var i=function(e,t){var o=[],i=[];return e.forEach((function(e){$(e,t)?i.push(e):o.push(e)})),{valid:o,invalid:i}}(t,e.maxSize);if(t=i.valid,r("oversize",i.invalid,c()),!t.length)return}t=B(t),r("update:modelValue",[].concat(o(e.modelValue),o(G(t)))),e.afterRead&&e.afterRead(t,c())},f=function(t){var o=e.maxCount,i=e.modelValue,r=e.resultType;if(Array.isArray(t)){var n=+o-i.length;t.length>n&&(t=t.slice(0,n)),Promise.all(t.map((function(e){return Z(e,r)}))).then((function(e){var o=t.map((function(t,o){var i={file:t,status:"",message:""};return e[o]&&(i.content=e[o]),i}));d(o)}))}else Z(t,r).then((function(e){var o={file:t,status:"",message:""};e&&(o.content=e),d(o)}))},g=function(t){var o=t.target.files;if(!e.disabled&&o&&o.length){var i=1===o.length?o[0]:[].slice.call(o);if(e.beforeRead){var r=e.beforeRead(i,c());if(!r)return void l();if(S(r))return void r.then((function(e){f(e||i)})).catch(l)}f(i)}},m=function(){return r("close-preview")},w=function(t,o){var a=["imageFit","deletable","previewSize","beforeDelete"],l=v(I(e,a),I(t,a,!0));return u(oe,O({item:t,index:o,onClick:function(){return r("click-preview",t,c(o))},onDelete:function(){return function(t,o){var i=e.modelValue.slice(0);i.splice(o,1),r("update:modelValue",i),r("delete",t,c(o))}(t,o)},onPreview:function(){return function(t){if(e.previewFullImage){var o=e.modelValue.filter(te),r=o.map((function(e){return e.file&&!e.url&&(e.url=URL.createObjectURL(e.file),s.push(e.url)),e.url})).filter(Boolean);i=V(v({images:r,startPosition:o.indexOf(t),onClose:m},e.previewOptions))}}(t)}},I(e,["name","lazyLoad"]),l),{"preview-cover":n["preview-cover"]})},y=function(){if(e.previewImage)return e.modelValue.map(w)},b=function(e){return r("click-upload",e)},z=function(){if(!(e.modelValue.length>=e.maxCount)&&e.showUpload){var t=e.readonly?null:u("input",{ref:a,type:"file",class:K("input"),accept:e.accept,capture:e.capture,multiple:e.multiple,disabled:e.disabled,onChange:g},null);return n.default?u("div",{class:K("input-wrapper"),onClick:b},[n.default(),t]):u("div",{class:K("upload",{readonly:e.readonly}),style:h(e.previewSize),onClick:b},[u(p,{name:e.uploadIcon,class:K("upload-icon")},null),e.uploadText&&u("span",{class:K("upload-text")},[e.uploadText]),t])}};return C((function(){s.forEach((function(e){return URL.revokeObjectURL(e)}))})),A({chooseFile:function(){a.value&&!e.disabled&&a.value.click()},closeImagePreview:function(){i&&i.close()}}),k((function(){return e.modelValue})),function(){return u("div",{class:K()},[u("div",{class:K("wrapper",{disabled:e.disabled})},[y(),z()])])}}}),ne=e("U",z(re)),ae="_uploader-section_jyku5_1",se="_img-close_jyku5_9",ce="_col-uploader_jyku5_24",le="_uploader_jyku5_1",ue="_uploaderText_jyku5_52",pe="_uploadImg_jyku5_57",de={};de.getData=function(e){return new Promise((function(t,o){var i={};(function(e){var t=null;return new Promise((function(o,i){if(e.src)if(/^data\:/i.test(e.src))t=function(e){e=e.replace(/^data\:([^\;]+)\;base64,/gim,"");for(var t=atob(e),o=t.length,i=new ArrayBuffer(o),r=new Uint8Array(i),n=0;n=8&&(s=o+i));if(s)for(p=u.getUint16(s,r),l=0;l=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==o.return||o.return()}finally{if(c)throw a}}}}(t);try{for(a.s();!(o=a.n()).done;){var s=i(o.value,2),c=s[0],l=s[1];n[c]=l}}catch(u){a.e(u)}finally{a.f()}return n},fe=s({data:function(){return{w:0,h:0,scale:1,x:0,y:0,loading:!0,trueWidth:0,trueHeight:0,move:!0,moveX:0,moveY:0,crop:!1,cropping:!1,cropW:0,cropH:0,cropOldW:0,cropOldH:0,canChangeX:!1,canChangeY:!1,changeCropTypeX:1,changeCropTypeY:1,cropX:0,cropY:0,cropChangeX:0,cropChangeY:0,cropOffsertX:0,cropOffsertY:0,support:"",touches:[],touchNow:!1,rotate:0,isIos:!1,orientation:0,imgs:"",coe:.2,scaling:!1,scalingSet:"",coeStatus:"",isCanShow:!0}},props:{img:{type:[String,Blob,null,File],default:""},outputSize:{type:Number,default:1},outputType:{type:String,default:"jpeg"},info:{type:Boolean,default:!0},canScale:{type:Boolean,default:!0},autoCrop:{type:Boolean,default:!1},autoCropWidth:{type:[Number,String],default:0},autoCropHeight:{type:[Number,String],default:0},fixed:{type:Boolean,default:!1},fixedNumber:{type:Array,default:function(){return[1,1]}},fixedBox:{type:Boolean,default:!1},full:{type:Boolean,default:!1},canMove:{type:Boolean,default:!0},canMoveBox:{type:Boolean,default:!0},original:{type:Boolean,default:!1},centerBox:{type:Boolean,default:!1},high:{type:Boolean,default:!0},infoTrue:{type:Boolean,default:!1},maxImgSize:{type:[Number,String],default:2e3},enlarge:{type:[Number,String],default:1},preW:{type:[Number,String],default:0},mode:{type:String,default:"contain"},limitMinSize:{type:[Number,Array,String],default:function(){return 10}}},computed:{cropInfo:function(){var e={};if(e.top=this.cropOffsertY>21?"-21px":"0px",e.width=this.cropW>0?this.cropW:0,e.height=this.cropH>0?this.cropH:0,this.infoTrue){var t=1;this.high&&!this.full&&(t=window.devicePixelRatio),1!==this.enlarge&!this.full&&(t=Math.abs(Number(this.enlarge))),e.width=e.width*t,e.height=e.height*t,this.full&&(e.width=e.width/this.scale,e.height=e.height/this.scale)}return e.width=e.width.toFixed(0),e.height=e.height.toFixed(0),e},isIE:function(){var e=!!window.ActiveXObject||"ActiveXObject"in window;return e},passive:function(){return this.isIE?null:{passive:!1}}},watch:{img:function(){this.checkedImg()},imgs:function(e){""!==e&&this.reload()},cropW:function(){this.showPreview()},cropH:function(){this.showPreview()},cropOffsertX:function(){this.showPreview()},cropOffsertY:function(){this.showPreview()},scale:function(e,t){this.showPreview()},x:function(){this.showPreview()},y:function(){this.showPreview()},autoCrop:function(e){e&&this.goAutoCrop()},autoCropWidth:function(){this.autoCrop&&this.goAutoCrop()},autoCropHeight:function(){this.autoCrop&&this.goAutoCrop()},mode:function(){this.checkedImg()},rotate:function(){this.showPreview(),(this.autoCrop||this.cropW>0||this.cropH>0)&&this.goAutoCrop(this.cropW,this.cropH)}},methods:{getVersion:function(e){for(var t=navigator.userAgent.split(" "),o="",i=new RegExp(e,"i"),r=0;r=81)t=-1;else if(this.getVersion("safari")[0]>=605){var n=this.getVersion("version");n[0]>13&&n[1]>1&&(t=-1)}else{var a=navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);if(a){var s=a[1];((s=s.split("_"))[0]>13||s[0]>=13&&s[1]>=4)&&(t=-1)}}var c=document.createElement("canvas"),l=c.getContext("2d");switch(l.save(),t){case 2:c.width=o,c.height=i,l.translate(o,0),l.scale(-1,1);break;case 3:c.width=o,c.height=i,l.translate(o/2,i/2),l.rotate(180*Math.PI/180),l.translate(-o/2,-i/2);break;case 4:c.width=o,c.height=i,l.translate(0,i),l.scale(1,-1);break;case 5:c.height=o,c.width=i,l.rotate(.5*Math.PI),l.scale(1,-1);break;case 6:c.width=i,c.height=o,l.translate(i/2,o/2),l.rotate(90*Math.PI/180),l.translate(-o/2,-i/2);break;case 7:c.height=o,c.width=i,l.rotate(.5*Math.PI),l.translate(o,-i),l.scale(-1,1);break;case 8:c.height=o,c.width=i,l.translate(i/2,o/2),l.rotate(-90*Math.PI/180),l.translate(-o/2,-i/2);break;default:c.width=o,c.height=i}l.drawImage(e,0,0,o,i),l.restore(),c.toBlob((function(e){var t=URL.createObjectURL(e);URL.revokeObjectURL(r.imgs),r.imgs=t}),"image/"+this.outputType,1)},checkedImg:function(){var e=this;if(null===this.img||""===this.img)return this.imgs="",void this.clearCrop();this.loading=!0,this.scale=1,this.rotate=0,this.clearCrop();var t=new Image;if(t.onload=function(){if(""===e.img)return e.$emit("img-load","error"),!1;var o=t.width,i=t.height;de.getData(t).then((function(r){e.orientation=r.orientation||1;var n=Number(e.maxImgSize);!e.orientation&&on&&(i=i/o*n,o=n),i>n&&(o=o/i*n,i=n),e.checkOrientationImage(t,e.orientation,o,i))}))},t.onerror=function(){e.$emit("img-load","error")},"data"!==this.img.substr(0,4)&&(t.crossOrigin=""),this.isIE){var o=new XMLHttpRequest;o.onload=function(){var e=URL.createObjectURL(this.response);t.src=e},o.open("GET",this.img,!0),o.responseType="blob",o.send()}else t.src=this.img},startMove:function(e){if(e.preventDefault(),this.move&&!this.crop){if(!this.canMove)return!1;this.moveX=("clientX"in e?e.clientX:e.touches[0].clientX)-this.x,this.moveY=("clientY"in e?e.clientY:e.touches[0].clientY)-this.y,e.touches?(window.addEventListener("touchmove",this.moveImg),window.addEventListener("touchend",this.leaveImg),2==e.touches.length&&(this.touches=e.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale))):(window.addEventListener("mousemove",this.moveImg),window.addEventListener("mouseup",this.leaveImg)),this.$emit("imgMoving",{moving:!0,axis:this.getImgAxis()}),this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})}else this.cropping=!0,window.addEventListener("mousemove",this.createCrop),window.addEventListener("mouseup",this.endCrop),window.addEventListener("touchmove",this.createCrop),window.addEventListener("touchend",this.endCrop),this.cropOffsertX=e.offsetX?e.offsetX:e.touches[0].pageX-this.$refs.cropper.offsetLeft,this.cropOffsertY=e.offsetY?e.offsetY:e.touches[0].pageY-this.$refs.cropper.offsetTop,this.cropX="clientX"in e?e.clientX:e.touches[0].clientX,this.cropY="clientY"in e?e.clientY:e.touches[0].clientY,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.cropW=0,this.cropH=0},touchScale:function(e){var t=this;e.preventDefault();var o=this.scale,i=this.touches[0].clientX,r=this.touches[0].clientY,n=e.touches[0].clientX,a=e.touches[0].clientY,s=this.touches[1].clientX,c=this.touches[1].clientY,l=e.touches[1].clientX,u=e.touches[1].clientY,p=Math.sqrt(Math.pow(i-s,2)+Math.pow(r-c,2)),d=Math.sqrt(Math.pow(n-l,2)+Math.pow(a-u,2))-p,h=1,f=(h=(h=h/this.trueWidth>h/this.trueHeight?h/this.trueHeight:h/this.trueWidth)>.1?.1:h)*d;if(!this.touchNow){if(this.touchNow=!0,d>0?o+=Math.abs(f):d<0&&o>Math.abs(f)&&(o-=Math.abs(f)),this.touches=e.touches,setTimeout((function(){t.touchNow=!1}),8),!this.checkoutImgAxis(this.x,this.y,o))return!1;this.scale=o}},cancelTouchScale:function(e){window.removeEventListener("touchmove",this.touchScale)},moveImg:function(e){var t=this;if(e.preventDefault(),e.touches&&2===e.touches.length)return this.touches=e.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale),window.removeEventListener("touchmove",this.moveImg),!1;var o,i,r="clientX"in e?e.clientX:e.touches[0].clientX,n="clientY"in e?e.clientY:e.touches[0].clientY;o=r-this.moveX,i=n-this.moveY,this.$nextTick((function(){if(t.centerBox){var e,r,n,a,s=t.getImgAxis(o,i,t.scale),c=t.getCropAxis(),l=t.trueHeight*t.scale,u=t.trueWidth*t.scale;switch(t.rotate){case 1:case-1:case 3:case-3:e=t.cropOffsertX-t.trueWidth*(1-t.scale)/2+(l-u)/2,r=t.cropOffsertY-t.trueHeight*(1-t.scale)/2+(u-l)/2,n=e-l+t.cropW,a=r-u+t.cropH;break;default:e=t.cropOffsertX-t.trueWidth*(1-t.scale)/2,r=t.cropOffsertY-t.trueHeight*(1-t.scale)/2,n=e-u+t.cropW,a=r-l+t.cropH}s.x1>=c.x1&&(o=e),s.y1>=c.y1&&(i=r),s.x2<=c.x2&&(o=n),s.y2<=c.y2&&(i=a)}t.x=o,t.y=i,t.$emit("imgMoving",{moving:!0,axis:t.getImgAxis()}),t.$emit("img-moving",{moving:!0,axis:t.getImgAxis()})}))},leaveImg:function(e){window.removeEventListener("mousemove",this.moveImg),window.removeEventListener("touchmove",this.moveImg),window.removeEventListener("mouseup",this.leaveImg),window.removeEventListener("touchend",this.leaveImg),this.$emit("imgMoving",{moving:!1,axis:this.getImgAxis()}),this.$emit("img-moving",{moving:!1,axis:this.getImgAxis()})},scaleImg:function(){this.canScale&&window.addEventListener(this.support,this.changeSize,this.passive)},cancelScale:function(){this.canScale&&window.removeEventListener(this.support,this.changeSize)},changeSize:function(e){var t=this;e.preventDefault();var o=this.scale,i=e.deltaY||e.wheelDelta;i=navigator.userAgent.indexOf("Firefox")>0?30*i:i,this.isIE&&(i=-i);var r=this.coe,n=(r=r/this.trueWidth>r/this.trueHeight?r/this.trueHeight:r/this.trueWidth)*i;n<0?o+=Math.abs(n):o>Math.abs(n)&&(o-=Math.abs(n));var a=n<0?"add":"reduce";if(a!==this.coeStatus&&(this.coeStatus=a,this.coe=.2),this.scaling||(this.scalingSet=setTimeout((function(){t.scaling=!1,t.coe=t.coe+=.01}),50)),this.scaling=!0,!this.checkoutImgAxis(this.x,this.y,o))return!1;this.scale=o},changeScale:function(e){var t=this.scale;e=e||1;var o=20;if((e*=o=o/this.trueWidth>o/this.trueHeight?o/this.trueHeight:o/this.trueWidth)>0?t+=Math.abs(e):t>Math.abs(e)&&(t-=Math.abs(e)),!this.checkoutImgAxis(this.x,this.y,t))return!1;this.scale=t},createCrop:function(e){var t=this;e.preventDefault();var o="clientX"in e?e.clientX:e.touches?e.touches[0].clientX:0,i="clientY"in e?e.clientY:e.touches?e.touches[0].clientY:0;this.$nextTick((function(){var e=o-t.cropX,r=i-t.cropY;if(e>0?(t.cropW=e+t.cropChangeX>t.w?t.w-t.cropChangeX:e,t.cropOffsertX=t.cropChangeX):(t.cropW=t.w-t.cropChangeX+Math.abs(e)>t.w?t.cropChangeX:Math.abs(e),t.cropOffsertX=t.cropChangeX+e>0?t.cropChangeX+e:0),t.fixed){var n=t.cropW/t.fixedNumber[0]*t.fixedNumber[1];n+t.cropOffsertY>t.h?(t.cropH=t.h-t.cropOffsertY,t.cropW=t.cropH/t.fixedNumber[1]*t.fixedNumber[0],t.cropOffsertX=e>0?t.cropChangeX:t.cropChangeX-t.cropW):t.cropH=n,t.cropOffsertY=t.cropOffsertY}else r>0?(t.cropH=r+t.cropChangeY>t.h?t.h-t.cropChangeY:r,t.cropOffsertY=t.cropChangeY):(t.cropH=t.h-t.cropChangeY+Math.abs(r)>t.h?t.cropChangeY:Math.abs(r),t.cropOffsertY=t.cropChangeY+r>0?t.cropChangeY+r:0)}))},changeCropSize:function(e,t,o,i,r){e.preventDefault(),window.addEventListener("mousemove",this.changeCropNow),window.addEventListener("mouseup",this.changeCropEnd),window.addEventListener("touchmove",this.changeCropNow),window.addEventListener("touchend",this.changeCropEnd),this.canChangeX=t,this.canChangeY=o,this.changeCropTypeX=i,this.changeCropTypeY=r,this.cropX="clientX"in e?e.clientX:e.touches[0].clientX,this.cropY="clientY"in e?e.clientY:e.touches[0].clientY,this.cropOldW=this.cropW,this.cropOldH=this.cropH,this.cropChangeX=this.cropOffsertX,this.cropChangeY=this.cropOffsertY,this.fixed&&this.canChangeX&&this.canChangeY&&(this.canChangeY=0),this.$emit("change-crop-size",{width:this.cropW,height:this.cropH})},changeCropNow:function(e){var t=this;e.preventDefault();var o="clientX"in e?e.clientX:e.touches?e.touches[0].clientX:0,i="clientY"in e?e.clientY:e.touches?e.touches[0].clientY:0,r=this.w,n=this.h,a=0,s=0;if(this.centerBox){var c=this.getImgAxis(),l=c.x2,u=c.y2;a=c.x1>0?c.x1:0,s=c.y1>0?c.y1:0,r>l&&(r=l),n>u&&(n=u)}this.$nextTick((function(){var e=o-t.cropX,c=i-t.cropY;if(t.canChangeX&&(1===t.changeCropTypeX?t.cropOldW-e>0?(t.cropW=r-t.cropChangeX-e<=r-a?t.cropOldW-e:t.cropOldW+t.cropChangeX-a,t.cropOffsertX=r-t.cropChangeX-e<=r-a?t.cropChangeX+e:a):(t.cropW=Math.abs(e)+t.cropChangeX<=r?Math.abs(e)-t.cropOldW:r-t.cropOldW-t.cropChangeX,t.cropOffsertX=t.cropChangeX+t.cropOldW):2===t.changeCropTypeX&&(t.cropOldW+e>0?(t.cropW=t.cropOldW+e+t.cropOffsertX<=r?t.cropOldW+e:r-t.cropOffsertX,t.cropOffsertX=t.cropChangeX):(t.cropW=r-t.cropChangeX+Math.abs(e+t.cropOldW)<=r-a?Math.abs(e+t.cropOldW):t.cropChangeX-a,t.cropOffsertX=r-t.cropChangeX+Math.abs(e+t.cropOldW)<=r-a?t.cropChangeX-Math.abs(e+t.cropOldW):a))),t.canChangeY&&(1===t.changeCropTypeY?t.cropOldH-c>0?(t.cropH=n-t.cropChangeY-c<=n-s?t.cropOldH-c:t.cropOldH+t.cropChangeY-s,t.cropOffsertY=n-t.cropChangeY-c<=n-s?t.cropChangeY+c:s):(t.cropH=Math.abs(c)+t.cropChangeY<=n?Math.abs(c)-t.cropOldH:n-t.cropOldH-t.cropChangeY,t.cropOffsertY=t.cropChangeY+t.cropOldH):2===t.changeCropTypeY&&(t.cropOldH+c>0?(t.cropH=t.cropOldH+c+t.cropOffsertY<=n?t.cropOldH+c:n-t.cropOffsertY,t.cropOffsertY=t.cropChangeY):(t.cropH=n-t.cropChangeY+Math.abs(c+t.cropOldH)<=n-s?Math.abs(c+t.cropOldH):t.cropChangeY-s,t.cropOffsertY=n-t.cropChangeY+Math.abs(c+t.cropOldH)<=n-s?t.cropChangeY-Math.abs(c+t.cropOldH):s))),t.canChangeX&&t.fixed){var l=t.cropW/t.fixedNumber[0]*t.fixedNumber[1];l+t.cropOffsertY>n?(t.cropH=n-t.cropOffsertY,t.cropW=t.cropH/t.fixedNumber[1]*t.fixedNumber[0]):t.cropH=l}if(t.canChangeY&&t.fixed){var u=t.cropH/t.fixedNumber[1]*t.fixedNumber[0];u+t.cropOffsertX>r?(t.cropW=r-t.cropOffsertX,t.cropH=t.cropW/t.fixedNumber[0]*t.fixedNumber[1]):t.cropW=u}}))},checkCropLimitSize:function(){this.cropW,this.cropH;var e=this.limitMinSize,t=new Array;return t=Array.isArray[e]?e:[e,e],[parseFloat(t[0]),parseFloat(t[1])]},changeCropEnd:function(e){window.removeEventListener("mousemove",this.changeCropNow),window.removeEventListener("mouseup",this.changeCropEnd),window.removeEventListener("touchmove",this.changeCropNow),window.removeEventListener("touchend",this.changeCropEnd)},endCrop:function(){0===this.cropW&&0===this.cropH&&(this.cropping=!1),window.removeEventListener("mousemove",this.createCrop),window.removeEventListener("mouseup",this.endCrop),window.removeEventListener("touchmove",this.createCrop),window.removeEventListener("touchend",this.endCrop)},startCrop:function(){this.crop=!0},stopCrop:function(){this.crop=!1},clearCrop:function(){this.cropping=!1,this.cropW=0,this.cropH=0},cropMove:function(e){if(e.preventDefault(),!this.canMoveBox)return this.crop=!1,this.startMove(e),!1;if(e.touches&&2===e.touches.length)return this.crop=!1,this.startMove(e),this.leaveCrop(),!1;window.addEventListener("mousemove",this.moveCrop),window.addEventListener("mouseup",this.leaveCrop),window.addEventListener("touchmove",this.moveCrop),window.addEventListener("touchend",this.leaveCrop);var t,o,i="clientX"in e?e.clientX:e.touches[0].clientX,r="clientY"in e?e.clientY:e.touches[0].clientY;t=i-this.cropOffsertX,o=r-this.cropOffsertY,this.cropX=t,this.cropY=o,this.$emit("cropMoving",{moving:!0,axis:this.getCropAxis()}),this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})},moveCrop:function(e,t){var o=this,i=0,r=0;e&&(e.preventDefault(),i="clientX"in e?e.clientX:e.touches[0].clientX,r="clientY"in e?e.clientY:e.touches[0].clientY),this.$nextTick((function(){var e,n,a=i-o.cropX,s=r-o.cropY;if(t&&(a=o.cropOffsertX,s=o.cropOffsertY),e=a<=0?0:a+o.cropW>o.w?o.w-o.cropW:a,n=s<=0?0:s+o.cropH>o.h?o.h-o.cropH:s,o.centerBox){var c=o.getImgAxis();e<=c.x1&&(e=c.x1),e+o.cropW>c.x2&&(e=c.x2-o.cropW),n<=c.y1&&(n=c.y1),n+o.cropH>c.y2&&(n=c.y2-o.cropH)}o.cropOffsertX=e,o.cropOffsertY=n,o.$emit("cropMoving",{moving:!0,axis:o.getCropAxis()}),o.$emit("crop-moving",{moving:!0,axis:o.getCropAxis()})}))},getImgAxis:function(e,t,o){e=e||this.x,t=t||this.y,o=o||this.scale;var i={x1:0,x2:0,y1:0,y2:0},r=this.trueWidth*o,n=this.trueHeight*o;switch(this.rotate){case 0:i.x1=e+this.trueWidth*(1-o)/2,i.x2=i.x1+this.trueWidth*o,i.y1=t+this.trueHeight*(1-o)/2,i.y2=i.y1+this.trueHeight*o;break;case 1:case-1:case 3:case-3:i.x1=e+this.trueWidth*(1-o)/2+(r-n)/2,i.x2=i.x1+this.trueHeight*o,i.y1=t+this.trueHeight*(1-o)/2+(n-r)/2,i.y2=i.y1+this.trueWidth*o;break;default:i.x1=e+this.trueWidth*(1-o)/2,i.x2=i.x1+this.trueWidth*o,i.y1=t+this.trueHeight*(1-o)/2,i.y2=i.y1+this.trueHeight*o}return i},getCropAxis:function(){var e={x1:0,x2:0,y1:0,y2:0};return e.x1=this.cropOffsertX,e.x2=e.x1+this.cropW,e.y1=this.cropOffsertY,e.y2=e.y1+this.cropH,e},leaveCrop:function(e){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.$emit("cropMoving",{moving:!1,axis:this.getCropAxis()}),this.$emit("crop-moving",{moving:!1,axis:this.getCropAxis()})},getCropChecked:function(e){var t=this,o=document.createElement("canvas"),i=new Image,r=this.rotate,n=this.trueWidth,a=this.trueHeight,s=this.cropOffsertX,c=this.cropOffsertY;function l(e,t){o.width=Math.round(e),o.height=Math.round(t)}i.onload=function(){if(0!==t.cropW){var u=o.getContext("2d"),p=1;t.high&!t.full&&(p=window.devicePixelRatio),1!==t.enlarge&!t.full&&(p=Math.abs(Number(t.enlarge)));var d=t.cropW*p,h=t.cropH*p,f=n*t.scale*p,g=a*t.scale*p,v=(t.x-s+t.trueWidth*(1-t.scale)/2)*p,m=(t.y-c+t.trueHeight*(1-t.scale)/2)*p;switch(l(d,h),u.save(),r){case 0:t.full?(l(d/t.scale,h/t.scale),u.drawImage(i,v/t.scale,m/t.scale,f/t.scale,g/t.scale)):u.drawImage(i,v,m,f,g);break;case 1:case-3:t.full?(l(d/t.scale,h/t.scale),v=v/t.scale+(f/t.scale-g/t.scale)/2,m=m/t.scale+(g/t.scale-f/t.scale)/2,u.rotate(90*r*Math.PI/180),u.drawImage(i,m,-v-g/t.scale,f/t.scale,g/t.scale)):(v+=(f-g)/2,m+=(g-f)/2,u.rotate(90*r*Math.PI/180),u.drawImage(i,m,-v-g,f,g));break;case 2:case-2:t.full?(l(d/t.scale,h/t.scale),u.rotate(90*r*Math.PI/180),v/=t.scale,m/=t.scale,u.drawImage(i,-v-f/t.scale,-m-g/t.scale,f/t.scale,g/t.scale)):(u.rotate(90*r*Math.PI/180),u.drawImage(i,-v-f,-m-g,f,g));break;case 3:case-1:t.full?(l(d/t.scale,h/t.scale),v=v/t.scale+(f/t.scale-g/t.scale)/2,m=m/t.scale+(g/t.scale-f/t.scale)/2,u.rotate(90*r*Math.PI/180),u.drawImage(i,-m-f/t.scale,v,f/t.scale,g/t.scale)):(v+=(f-g)/2,m+=(g-f)/2,u.rotate(90*r*Math.PI/180),u.drawImage(i,-m-f,v,f,g));break;default:t.full?(l(d/t.scale,h/t.scale),u.drawImage(i,v/t.scale,m/t.scale,f/t.scale,g/t.scale)):u.drawImage(i,v,m,f,g)}u.restore()}else{var w=n*t.scale,y=a*t.scale,b=o.getContext("2d");switch(b.save(),r){case 0:l(w,y),b.drawImage(i,0,0,w,y);break;case 1:case-3:l(y,w),b.rotate(90*r*Math.PI/180),b.drawImage(i,0,-y,w,y);break;case 2:case-2:l(w,y),b.rotate(90*r*Math.PI/180),b.drawImage(i,-w,-y,w,y);break;case 3:case-1:l(y,w),b.rotate(90*r*Math.PI/180),b.drawImage(i,-w,0,w,y);break;default:l(w,y),b.drawImage(i,0,0,w,y)}b.restore()}e(o)},"data"!==this.img.substr(0,4)&&(i.crossOrigin="Anonymous"),i.src=this.imgs},getCropData:function(e){var t=this;this.getCropChecked((function(o){e(o.toDataURL("image/"+t.outputType,t.outputSize))}))},getCropBlob:function(e){var t=this;this.getCropChecked((function(o){o.toBlob((function(t){return e(t)}),"image/"+t.outputType,t.outputSize)}))},showPreview:function(){var e=this;if(!this.isCanShow)return!1;this.isCanShow=!1,setTimeout((function(){e.isCanShow=!0}),16);var t=this.cropW,o=this.cropH,i=this.scale,r={};r.div={width:"".concat(t,"px"),height:"".concat(o,"px")};var n=(this.x-this.cropOffsertX)/i,a=(this.y-this.cropOffsertY)/i;r.w=t,r.h=o,r.url=this.imgs,r.img={width:"".concat(this.trueWidth,"px"),height:"".concat(this.trueHeight,"px"),transform:"scale(".concat(i,")translate3d(").concat(n,"px, ").concat(a,"px, ").concat(0,"px)rotateZ(").concat(90*this.rotate,"deg)")},r.html='\n
\n
\n \n
\n
'),this.$emit("realTime",r),this.$emit("real-time",r)},reload:function(){var e=this,t=new Image;t.onload=function(){e.w=parseFloat(window.getComputedStyle(e.$refs.cropper).width),e.h=parseFloat(window.getComputedStyle(e.$refs.cropper).height),e.trueWidth=t.width,e.trueHeight=t.height,e.original?e.scale=1:e.scale=e.checkedMode(),e.$nextTick((function(){e.x=-(e.trueWidth-e.trueWidth*e.scale)/2+(e.w-e.trueWidth*e.scale)/2,e.y=-(e.trueHeight-e.trueHeight*e.scale)/2+(e.h-e.trueHeight*e.scale)/2,e.loading=!1,e.autoCrop&&e.goAutoCrop(),e.$emit("img-load","success"),e.$emit("imgLoad","success"),setTimeout((function(){e.showPreview()}),20)}))},t.onerror=function(){e.$emit("imgLoad","error"),e.$emit("img-load","error")},t.src=this.imgs},checkedMode:function(){var e=1,t=(this.trueWidth,this.trueHeight),o=this.mode.split(" ");switch(o[0]){case"contain":this.trueWidth>this.w&&(e=this.w/this.trueWidth),this.trueHeight*e>this.h&&(e=this.h/this.trueHeight);break;case"cover":(t*=e=this.w/this.trueWidth)0,n=(r?this.trueHeight:this.trueWidth)*this.scale,a=(r?this.trueWidth:this.trueHeight)*this.scale;o=no?o:s,c=c>i?i:c,this.fixed&&(c=s/this.fixedNumber[0]*this.fixedNumber[1]),c>this.h&&(s=(c=this.h)/this.fixedNumber[1]*this.fixedNumber[0]),this.changeCrop(s,c)}},changeCrop:function(e,t){var o=this;if(this.centerBox){var i=this.getImgAxis();e>i.x2-i.x1&&(t=(e=i.x2-i.x1)/this.fixedNumber[0]*this.fixedNumber[1]),t>i.y2-i.y1&&(e=(t=i.y2-i.y1)/this.fixedNumber[1]*this.fixedNumber[0])}this.cropW=e,this.cropH=t,this.checkCropLimitSize(),this.$nextTick((function(){o.cropOffsertX=(o.w-o.cropW)/2,o.cropOffsertY=(o.h-o.cropH)/2,o.centerBox&&o.moveCrop(null,!0)}))},refresh:function(){var e=this;this.img,this.imgs="",this.scale=1,this.crop=!1,this.rotate=0,this.w=0,this.h=0,this.trueWidth=0,this.trueHeight=0,this.clearCrop(),this.$nextTick((function(){e.checkedImg()}))},rotateLeft:function(){this.rotate=this.rotate<=-3?0:this.rotate-1},rotateRight:function(){this.rotate=this.rotate>=3?0:this.rotate+1},rotateClear:function(){this.rotate=0},checkoutImgAxis:function(e,t,o){e=e||this.x,t=t||this.y,o=o||this.scale;var i=!0;if(this.centerBox){var r=this.getImgAxis(e,t,o),n=this.getCropAxis();r.x1>=n.x1&&(i=!1),r.x2<=n.x2&&(i=!1),r.y1>=n.y1&&(i=!1),r.y2<=n.y2&&(i=!1)}return i}},mounted:function(){this.support="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";var e=this,t=navigator.userAgent;this.isIOS=!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,o,i){for(var r=atob(this.toDataURL(o,i).split(",")[1]),n=r.length,a=new Uint8Array(n),s=0;s