index.f264094d.js 48 KB

1234567
  1. import{A as he,aK as ne,d as W,E as U,aw as ce,j as d,M,aS as le,bc as K,L as pe,aB as de,I as P,aa as j,$ as H,G as T,aX as ue,S as ge,a4 as fe,aj as me,a_ as J,aJ as ve,aA as N,a7 as we,Q as ye,N as xe,o as B,bh as Y,a5 as V,aE as _,bi as x,bj as z,bk as F,bl as Ce,bm as Q,n as be,T as L,bn as Oe}from"./index.394decd7.js";import{I as E}from"./index.ae2dd816.js";import"./index.f1b52763.js";import{I as Ie}from"./index.ad0a7ec4.js";import{g as ke,o as Se}from"./oss-file-upload.bb3abddd.js";const[Ae,C,Me]=he("uploader"),Z=e=>Array.isArray(e)?e:[e];function G(e,t){return new Promise(i=>{if(t==="file"){i();return}const s=new FileReader;s.onload=o=>{i(o.target.result)},t==="dataUrl"?s.readAsDataURL(e):t==="text"&&s.readAsText(e)})}function ee(e,t){return Z(e).some(i=>i.file?ne(t)?t(i.file):i.file.size>t:!1)}function Xe(e,t){const i=[],s=[];return e.forEach(o=>{ee(o,t)?s.push(o):i.push(o)}),{valid:i,invalid:s}}const We=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i,He=e=>We.test(e);function te(e){return e.isImage?!0:e.file&&e.file.type?e.file.type.indexOf("image")===0:e.url?He(e.url):typeof e.content=="string"?e.content.indexOf("data:image")===0:!1}var Te=W({props:{name:U,item:ce(Object),index:Number,imageFit:String,lazyLoad:Boolean,deletable:Boolean,previewSize:U,beforeDelete:Function},emits:["delete","preview"],setup(e,{emit:t,slots:i}){const s=()=>{const{status:n,message:h}=e.item;if(n==="uploading"||n==="failed"){const p=n==="failed"?d(M,{name:"close",class:C("mask-icon")},null):d(le,{class:C("loading")},null),u=pe(h)&&h!=="";return d("div",{class:C("mask")},[p,u&&d("div",{class:C("mask-message")},[h])])}},o=n=>{const{name:h,item:p,index:u,beforeDelete:S}=e;n.stopPropagation(),de(S,{args:[p,{name:h,index:u}],done:()=>t("delete")})},r=()=>t("preview"),a=()=>{if(e.deletable&&e.item.status!=="uploading")return d("div",{role:"button",class:C("preview-delete"),tabindex:0,"aria-label":Me("delete"),onClick:o},[d(M,{name:"cross",class:C("preview-delete-icon")},null)])},c=()=>{if(i["preview-cover"]){const{index:n,item:h}=e;return d("div",{class:C("preview-cover")},[i["preview-cover"](P({index:n},h))])}},l=()=>{const{item:n}=e;return te(n)?d(E,{fit:e.imageFit,src:n.content||n.url,class:C("preview-image"),width:e.previewSize,height:e.previewSize,lazyLoad:e.lazyLoad,onClick:r},{default:c}):d("div",{class:C("file"),style:K(e.previewSize)},[d(M,{class:C("file-icon"),name:"description"},null),d("div",{class:[C("file-name"),"van-ellipsis"]},[n.file?n.file.name:n.url]),c()])};return()=>d("div",{class:C("preview")},[l(),s(),a()])}});const Be={name:j(""),accept:H("image/*"),capture:String,multiple:Boolean,disabled:Boolean,readonly:Boolean,lazyLoad:Boolean,maxCount:j(1/0),imageFit:H("cover"),resultType:H("dataUrl"),uploadIcon:H("photograph"),uploadText:String,deletable:T,afterRead:Function,showUpload:T,modelValue:ue(),beforeRead:Function,beforeDelete:Function,previewSize:U,previewImage:T,previewOptions:Object,previewFullImage:T,maxSize:{type:[Number,String,Function],default:1/0}};var Ye=W({name:Ae,props:Be,emits:["delete","oversize","click-upload","close-preview","click-preview","update:modelValue"],setup(e,{emit:t,slots:i}){const s=ge(),o=[],r=(g=e.modelValue.length)=>({name:e.name,index:g}),a=()=>{s.value&&(s.value.value="")},c=g=>{if(a(),ee(g,e.maxSize))if(Array.isArray(g)){const y=Xe(g,e.maxSize);if(g=y.valid,t("oversize",y.invalid,r()),!g.length)return}else{t("oversize",g,r());return}g=ye(g),t("update:modelValue",[...e.modelValue,...Z(g)]),e.afterRead&&e.afterRead(g,r())},l=g=>{const{maxCount:y,modelValue:O,resultType:b}=e;if(Array.isArray(g)){const A=+y-O.length;g.length>A&&(g=g.slice(0,A)),Promise.all(g.map(X=>G(X,b))).then(X=>{const re=g.map((ae,R)=>{const $={file:ae,status:"",message:""};return X[R]&&($.content=X[R]),$});c(re)})}else G(g,b).then(A=>{const X={file:g,status:"",message:""};A&&(X.content=A),c(X)})},n=g=>{const{files:y}=g.target;if(e.disabled||!y||!y.length)return;const O=y.length===1?y[0]:[].slice.call(y);if(e.beforeRead){const b=e.beforeRead(O,r());if(!b){a();return}if(ve(b)){b.then(A=>{l(A||O)}).catch(a);return}}l(O)};let h;const p=()=>t("close-preview"),u=g=>{if(e.previewFullImage){const y=e.modelValue.filter(te),O=y.map(b=>(b.file&&!b.url&&(b.url=URL.createObjectURL(b.file),o.push(b.url)),b.url)).filter(Boolean);h=Ie(P({images:O,startPosition:y.indexOf(g),onClose:p},e.previewOptions))}},S=()=>{h&&h.close()},f=(g,y)=>{const O=e.modelValue.slice(0);O.splice(y,1),t("update:modelValue",O),t("delete",g,r(y))},m=(g,y)=>{const O=["imageFit","deletable","previewSize","beforeDelete"],b=P(N(e,O),N(g,O,!0));return d(Te,we({item:g,index:y,onClick:()=>t("click-preview",g,r(y)),onDelete:()=>f(g,y),onPreview:()=>u(g)},N(e,["name","lazyLoad"]),b),{"preview-cover":i["preview-cover"]})},w=()=>{if(e.previewImage)return e.modelValue.map(m)},v=g=>t("click-upload",g),se=()=>{if(e.modelValue.length>=e.maxCount||!e.showUpload)return;const g=e.readonly?null:d("input",{ref:s,type:"file",class:C("input"),accept:e.accept,capture:e.capture,multiple:e.multiple,disabled:e.disabled,onChange:n},null);return i.default?d("div",{class:C("input-wrapper"),onClick:v},[i.default(),g]):d("div",{class:C("upload",{readonly:e.readonly}),style:K(e.previewSize),onClick:v},[d(M,{name:e.uploadIcon,class:C("upload-icon")},null),e.uploadText&&d("span",{class:C("upload-text")},[e.uploadText]),g])},oe=()=>{s.value&&!e.disabled&&s.value.click()};return fe(()=>{o.forEach(g=>URL.revokeObjectURL(g))}),me({chooseFile:oe,closeImagePreview:S}),J(()=>e.modelValue),()=>d("div",{class:C()},[d("div",{class:C("wrapper",{disabled:e.disabled})},[w(),se()])])}});const ze=xe(Ye);const Le="_uploader_jyku5_1",Ee="_uploaderText_jyku5_52",Ne="_uploadImg_jyku5_57";var k={"uploader-section":"_uploader-section_jyku5_1","img-close":"_img-close_jyku5_9","col-uploader":"_col-uploader_jyku5_24",uploader:Le,uploaderText:Ee,uploadImg:Ne};const ie={};ie.getData=e=>new Promise((t,i)=>{let s={};Fe(e).then(o=>{s.arrayBuffer=o;try{s.orientation=Re(o)}catch{s.orientation=-1}t(s)}).catch(o=>{i(o)})});function Fe(e){let t=null;return new Promise((i,s)=>{if(e.src)if(/^data\:/i.test(e.src))t=Ue(e.src),i(t);else if(/^blob\:/i.test(e.src)){var o=new FileReader;o.onload=function(a){t=a.target.result,i(t)},De(e.src,function(a){o.readAsArrayBuffer(a)})}else{var r=new XMLHttpRequest;r.onload=function(){if(this.status==200||this.status===0)t=r.response,i(t);else throw"Could not load image";r=null},r.open("GET",e.src,!0),r.responseType="arraybuffer",r.send(null)}else s("img error")})}function De(e,t){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="blob",i.onload=function(s){(this.status==200||this.status===0)&&t(this.response)},i.send()}function Ue(e,t){t=t||e.match(/^data\:([^\;]+)\;base64,/mi)[1]||"",e=e.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var i=atob(e),s=i.length%2==0?i.length:i.length+1,o=new ArrayBuffer(s),r=new Uint16Array(o),a=0;a<s;a++)r[a]=i.charCodeAt(a);return o}function Pe(e,t,i){var s="",o;for(o=t,i+=t;o<i;o++)s+=String.fromCharCode(e.getUint8(o));return s}function Re(e){var t=new DataView(e),i=t.byteLength,s,o,r,a,c,l,n,h,p,u;if(t.getUint8(0)===255&&t.getUint8(1)===216)for(p=2;p<i;){if(t.getUint8(p)===255&&t.getUint8(p+1)===225){n=p;break}p++}if(n&&(o=n+4,r=n+10,Pe(t,o,4)==="Exif"&&(l=t.getUint16(r),c=l===18761,(c||l===19789)&&t.getUint16(r+2,c)===42&&(a=t.getUint32(r+4,c),a>=8&&(h=r+a)))),h){for(i=t.getUint16(h,c),u=0;u<i;u++)if(p=h+u*12+2,t.getUint16(p,c)===274){p+=8,s=t.getUint16(p,c);break}}return s}const $e=(e,t)=>{const i=e.__vccOpts||e;for(const[s,o]of t)i[s]=o;return i},je=W({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:()=>[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:()=>10,validator:function(e){return Array.isArray(e)?Number(e[0])>=0&&Number(e[1])>=0:Number(e)>=0}},fillColor:{type:String,default:""}},computed:{cropInfo(){let 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){let t=1;this.high&&!this.full&&(t=window.devicePixelRatio),this.enlarge!==1&!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(){return!!window.ActiveXObject||"ActiveXObject"in window},passive(){return this.isIE?null:{passive:!1}}},watch:{img(){this.checkedImg()},imgs(e){e!==""&&this.reload()},cropW(){this.showPreview()},cropH(){this.showPreview()},cropOffsertX(){this.showPreview()},cropOffsertY(){this.showPreview()},scale(e,t){this.showPreview()},x(){this.showPreview()},y(){this.showPreview()},autoCrop(e){e&&this.goAutoCrop()},autoCropWidth(){this.autoCrop&&this.goAutoCrop()},autoCropHeight(){this.autoCrop&&this.goAutoCrop()},mode(){this.checkedImg()},rotate(){this.showPreview(),this.autoCrop?this.goAutoCrop(this.cropW,this.cropH):(this.cropW>0||this.cropH>0)&&this.goAutoCrop(this.cropW,this.cropH)}},methods:{getVersion(e){var t=navigator.userAgent.split(" "),i="";let s=0;const o=new RegExp(e,"i");for(var r=0;r<t.length;r++)o.test(t[r])&&(i=t[r]);return i?s=i.split("/")[1].split("."):s=["0","0","0"],s},checkOrientationImage(e,t,i,s){if(this.getVersion("chrome")[0]>=81)t=-1;else if(this.getVersion("safari")[0]>=605){const a=this.getVersion("version");a[0]>13&&a[1]>1&&(t=-1)}else{const a=navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/);if(a){let c=a[1];c=c.split("_"),(c[0]>13||c[0]>=13&&c[1]>=4)&&(t=-1)}}let o=document.createElement("canvas"),r=o.getContext("2d");switch(r.save(),t){case 2:o.width=i,o.height=s,r.translate(i,0),r.scale(-1,1);break;case 3:o.width=i,o.height=s,r.translate(i/2,s/2),r.rotate(180*Math.PI/180),r.translate(-i/2,-s/2);break;case 4:o.width=i,o.height=s,r.translate(0,s),r.scale(1,-1);break;case 5:o.height=i,o.width=s,r.rotate(.5*Math.PI),r.scale(1,-1);break;case 6:o.width=s,o.height=i,r.translate(s/2,i/2),r.rotate(90*Math.PI/180),r.translate(-i/2,-s/2);break;case 7:o.height=i,o.width=s,r.rotate(.5*Math.PI),r.translate(i,-s),r.scale(-1,1);break;case 8:o.height=i,o.width=s,r.translate(s/2,i/2),r.rotate(-90*Math.PI/180),r.translate(-i/2,-s/2);break;default:o.width=i,o.height=s}r.drawImage(e,0,0,i,s),r.restore(),o.toBlob(a=>{let c=URL.createObjectURL(a);URL.revokeObjectURL(this.imgs),this.imgs=c},"image/"+this.outputType,1)},checkedImg(){if(this.img===null||this.img===""){this.imgs="",this.clearCrop();return}this.loading=!0,this.scale=1,this.rotate=0,this.clearCrop();let e=new Image;if(e.onload=()=>{if(this.img==="")return this.$emit("img-load",new Error("\u56FE\u7247\u4E0D\u80FD\u4E3A\u7A7A")),!1;let i=e.width,s=e.height;ie.getData(e).then(o=>{this.orientation=o.orientation||1;let r=Number(this.maxImgSize);if(!this.orientation&&i<r&s<r){this.imgs=this.img;return}i>r&&(s=s/i*r,i=r),s>r&&(i=i/s*r,s=r),this.checkOrientationImage(e,this.orientation,i,s)}).catch(o=>{this.$emit("img-load","error"),this.$emit("img-load-error",o)})},e.onerror=i=>{this.$emit("img-load","error"),this.$emit("img-load-error",i)},this.img.substr(0,4)!=="data"&&(e.crossOrigin=""),this.isIE){var t=new XMLHttpRequest;t.onload=function(){var i=URL.createObjectURL(this.response);e.src=i},t.open("GET",this.img,!0),t.responseType="blob",t.send()}else e.src=this.img},startMove(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),e.touches.length==2&&(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("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(e){e.preventDefault();let t=this.scale;var i={x:this.touches[0].clientX,y:this.touches[0].clientY},s={x:e.touches[0].clientX,y:e.touches[0].clientY},o={x:this.touches[1].clientX,y:this.touches[1].clientY},r={x:e.touches[1].clientX,y:e.touches[1].clientY},a=Math.sqrt(Math.pow(i.x-o.x,2)+Math.pow(i.y-o.y,2)),c=Math.sqrt(Math.pow(s.x-r.x,2)+Math.pow(s.y-r.y,2)),l=c-a,n=1;n=n/this.trueWidth>n/this.trueHeight?n/this.trueHeight:n/this.trueWidth,n=n>.1?.1:n;var h=n*l;if(!this.touchNow){if(this.touchNow=!0,l>0?t+=Math.abs(h):l<0&&t>Math.abs(h)&&(t-=Math.abs(h)),this.touches=e.touches,setTimeout(()=>{this.touchNow=!1},8),!this.checkoutImgAxis(this.x,this.y,t))return!1;this.scale=t}},cancelTouchScale(e){window.removeEventListener("touchmove",this.touchScale)},moveImg(e){if(e.preventDefault(),e.touches&&e.touches.length===2)return this.touches=e.touches,window.addEventListener("touchmove",this.touchScale),window.addEventListener("touchend",this.cancelTouchScale),window.removeEventListener("touchmove",this.moveImg),!1;let t="clientX"in e?e.clientX:e.touches[0].clientX,i="clientY"in e?e.clientY:e.touches[0].clientY,s,o;s=t-this.moveX,o=i-this.moveY,this.$nextTick(()=>{if(this.centerBox){let r=this.getImgAxis(s,o,this.scale),a=this.getCropAxis(),c=this.trueHeight*this.scale,l=this.trueWidth*this.scale,n,h,p,u;switch(this.rotate){case 1:case-1:case 3:case-3:n=this.cropOffsertX-this.trueWidth*(1-this.scale)/2+(c-l)/2,h=this.cropOffsertY-this.trueHeight*(1-this.scale)/2+(l-c)/2,p=n-c+this.cropW,u=h-l+this.cropH;break;default:n=this.cropOffsertX-this.trueWidth*(1-this.scale)/2,h=this.cropOffsertY-this.trueHeight*(1-this.scale)/2,p=n-l+this.cropW,u=h-c+this.cropH;break}r.x1>=a.x1&&(s=n),r.y1>=a.y1&&(o=h),r.x2<=a.x2&&(s=p),r.y2<=a.y2&&(o=u)}this.x=s,this.y=o,this.$emit("img-moving",{moving:!0,axis:this.getImgAxis()})})},leaveImg(e){window.removeEventListener("mousemove",this.moveImg),window.removeEventListener("touchmove",this.moveImg),window.removeEventListener("mouseup",this.leaveImg),window.removeEventListener("touchend",this.leaveImg),this.$emit("img-moving",{moving:!1,axis:this.getImgAxis()})},scaleImg(){this.canScale&&window.addEventListener(this.support,this.changeSize,this.passive)},cancelScale(){this.canScale&&window.removeEventListener(this.support,this.changeSize)},changeSize(e){e.preventDefault();let t=this.scale;var i=e.deltaY||e.wheelDelta,s=navigator.userAgent.indexOf("Firefox");i=s>0?i*30:i,this.isIE&&(i=-i);var o=this.coe;o=o/this.trueWidth>o/this.trueHeight?o/this.trueHeight:o/this.trueWidth;var r=o*i;r<0?t+=Math.abs(r):t>Math.abs(r)&&(t-=Math.abs(r));let a=r<0?"add":"reduce";if(a!==this.coeStatus&&(this.coeStatus=a,this.coe=.2),this.scaling||(this.scalingSet=setTimeout(()=>{this.scaling=!1,this.coe=this.coe+=.01},50)),this.scaling=!0,!this.checkoutImgAxis(this.x,this.y,t))return!1;this.scale=t},changeScale(e){let t=this.scale;e=e||1;var i=20;if(i=i/this.trueWidth>i/this.trueHeight?i/this.trueHeight:i/this.trueWidth,e=e*i,e>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(e){e.preventDefault();var t="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(()=>{var s=t-this.cropX,o=i-this.cropY;if(s>0?(this.cropW=s+this.cropChangeX>this.w?this.w-this.cropChangeX:s,this.cropOffsertX=this.cropChangeX):(this.cropW=this.w-this.cropChangeX+Math.abs(s)>this.w?this.cropChangeX:Math.abs(s),this.cropOffsertX=this.cropChangeX+s>0?this.cropChangeX+s:0),!this.fixed)o>0?(this.cropH=o+this.cropChangeY>this.h?this.h-this.cropChangeY:o,this.cropOffsertY=this.cropChangeY):(this.cropH=this.h-this.cropChangeY+Math.abs(o)>this.h?this.cropChangeY:Math.abs(o),this.cropOffsertY=this.cropChangeY+o>0?this.cropChangeY+o:0);else{var r=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];r+this.cropOffsertY>this.h?(this.cropH=this.h-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0],s>0?this.cropOffsertX=this.cropChangeX:this.cropOffsertX=this.cropChangeX-this.cropW):this.cropH=r,this.cropOffsertY=this.cropOffsertY}})},changeCropSize(e,t,i,s,o){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=i,this.changeCropTypeX=s,this.changeCropTypeY=o,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(e){e.preventDefault();var t="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;let s=this.w,o=this.h,r=0,a=0;if(this.centerBox){let n=this.getImgAxis(),h=n.x2,p=n.y2;r=n.x1>0?n.x1:0,a=n.y1>0?n.y1:0,s>h&&(s=h),o>p&&(o=p)}const[c,l]=this.checkCropLimitSize();this.$nextTick(()=>{var n=t-this.cropX,h=i-this.cropY;if(this.canChangeX&&(this.changeCropTypeX===1?this.cropOldW-n<c?(this.cropW=c,this.cropOffsertX=this.cropOldW+this.cropChangeX-r-c):this.cropOldW-n>0?(this.cropW=s-this.cropChangeX-n<=s-r?this.cropOldW-n:this.cropOldW+this.cropChangeX-r,this.cropOffsertX=s-this.cropChangeX-n<=s-r?this.cropChangeX+n:r):(this.cropW=Math.abs(n)+this.cropChangeX<=s?Math.abs(n)-this.cropOldW:s-this.cropOldW-this.cropChangeX,this.cropOffsertX=this.cropChangeX+this.cropOldW):this.changeCropTypeX===2&&(this.cropOldW+n<c?this.cropW=c:this.cropOldW+n>0?(this.cropW=this.cropOldW+n+this.cropOffsertX<=s?this.cropOldW+n:s-this.cropOffsertX,this.cropOffsertX=this.cropChangeX):(this.cropW=s-this.cropChangeX+Math.abs(n+this.cropOldW)<=s-r?Math.abs(n+this.cropOldW):this.cropChangeX-r,this.cropOffsertX=s-this.cropChangeX+Math.abs(n+this.cropOldW)<=s-r?this.cropChangeX-Math.abs(n+this.cropOldW):r))),this.canChangeY&&(this.changeCropTypeY===1?this.cropOldH-h<l?(this.cropH=l,this.cropOffsertY=this.cropOldH+this.cropChangeY-a-l):this.cropOldH-h>0?(this.cropH=o-this.cropChangeY-h<=o-a?this.cropOldH-h:this.cropOldH+this.cropChangeY-a,this.cropOffsertY=o-this.cropChangeY-h<=o-a?this.cropChangeY+h:a):(this.cropH=Math.abs(h)+this.cropChangeY<=o?Math.abs(h)-this.cropOldH:o-this.cropOldH-this.cropChangeY,this.cropOffsertY=this.cropChangeY+this.cropOldH):this.changeCropTypeY===2&&(this.cropOldH+h<l?this.cropH=l:this.cropOldH+h>0?(this.cropH=this.cropOldH+h+this.cropOffsertY<=o?this.cropOldH+h:o-this.cropOffsertY,this.cropOffsertY=this.cropChangeY):(this.cropH=o-this.cropChangeY+Math.abs(h+this.cropOldH)<=o-a?Math.abs(h+this.cropOldH):this.cropChangeY-a,this.cropOffsertY=o-this.cropChangeY+Math.abs(h+this.cropOldH)<=o-a?this.cropChangeY-Math.abs(h+this.cropOldH):a))),this.canChangeX&&this.fixed){var p=this.cropW/this.fixedNumber[0]*this.fixedNumber[1];p<l?(this.cropH=l,this.cropW=this.fixedNumber[0]*l/this.fixedNumber[1],this.changeCropTypeX===1&&(this.cropOffsertX=this.cropChangeX+(this.cropOldW-this.cropW))):p+this.cropOffsertY>o?(this.cropH=o-this.cropOffsertY,this.cropW=this.cropH/this.fixedNumber[1]*this.fixedNumber[0],this.changeCropTypeX===1&&(this.cropOffsertX=this.cropChangeX+(this.cropOldW-this.cropW))):this.cropH=p}if(this.canChangeY&&this.fixed){var u=this.cropH/this.fixedNumber[1]*this.fixedNumber[0];u<c?(this.cropW=c,this.cropH=this.fixedNumber[1]*c/this.fixedNumber[0],this.cropOffsertY=this.cropOldH+this.cropChangeY-this.cropH):u+this.cropOffsertX>s?(this.cropW=s-this.cropOffsertX,this.cropH=this.cropW/this.fixedNumber[0]*this.fixedNumber[1]):this.cropW=u}})},checkCropLimitSize(){let{cropW:e,cropH:t,limitMinSize:i}=this,s=new Array;return Array.isArray(i)?s=i:s=[i,i],e=parseFloat(s[0]),t=parseFloat(s[1]),[e,t]},changeCropEnd(e){window.removeEventListener("mousemove",this.changeCropNow),window.removeEventListener("mouseup",this.changeCropEnd),window.removeEventListener("touchmove",this.changeCropNow),window.removeEventListener("touchend",this.changeCropEnd)},calculateSize(e,t,i,s,o,r){const a=e/t;let c=o,l=r;return c<i&&(c=i,l=Math.ceil(c/a)),l<s&&(l=s,c=Math.ceil(l*a),c<i&&(c=i,l=Math.ceil(c/a))),c<o&&(c=o,l=Math.ceil(c/a)),l<r&&(l=r,c=Math.ceil(l*a)),{width:c,height:l}},endCrop(){this.cropW===0&&this.cropH===0&&(this.cropping=!1);let[e,t]=this.checkCropLimitSize();const{width:i,height:s}=this.fixed?this.calculateSize(this.fixedNumber[0],this.fixedNumber[1],e,t,this.cropW,this.cropH):{width:e,height:t};i>this.cropW&&(this.cropW=i,this.cropOffsertX+i>this.w&&(this.cropOffsertX=this.w-i)),s>this.cropH&&(this.cropH=s,this.cropOffsertY+s>this.h&&(this.cropOffsertY=this.h-s)),window.removeEventListener("mousemove",this.createCrop),window.removeEventListener("mouseup",this.endCrop),window.removeEventListener("touchmove",this.createCrop),window.removeEventListener("touchend",this.endCrop)},startCrop(){this.crop=!0},stopCrop(){this.crop=!1},clearCrop(){this.cropping=!1,this.cropW=0,this.cropH=0},cropMove(e){if(e.preventDefault(),!this.canMoveBox)return this.crop=!1,this.startMove(e),!1;if(e.touches&&e.touches.length===2)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);let t="clientX"in e?e.clientX:e.touches[0].clientX,i="clientY"in e?e.clientY:e.touches[0].clientY,s,o;s=t-this.cropOffsertX,o=i-this.cropOffsertY,this.cropX=s,this.cropY=o,this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})},moveCrop(e,t){let i=0,s=0;e&&(e.preventDefault(),i="clientX"in e?e.clientX:e.touches[0].clientX,s="clientY"in e?e.clientY:e.touches[0].clientY),this.$nextTick(()=>{let o,r,a=i-this.cropX,c=s-this.cropY;if(t&&(a=this.cropOffsertX,c=this.cropOffsertY),a<=0?o=0:a+this.cropW>this.w?o=this.w-this.cropW:o=a,c<=0?r=0:c+this.cropH>this.h?r=this.h-this.cropH:r=c,this.centerBox){let l=this.getImgAxis();o<=l.x1&&(o=l.x1),o+this.cropW>l.x2&&(o=l.x2-this.cropW),r<=l.y1&&(r=l.y1),r+this.cropH>l.y2&&(r=l.y2-this.cropH)}this.cropOffsertX=o,this.cropOffsertY=r,this.$emit("crop-moving",{moving:!0,axis:this.getCropAxis()})})},getImgAxis(e,t,i){e=e||this.x,t=t||this.y,i=i||this.scale;let s={x1:0,x2:0,y1:0,y2:0},o=this.trueWidth*i,r=this.trueHeight*i;switch(this.rotate){case 0:s.x1=e+this.trueWidth*(1-i)/2,s.x2=s.x1+this.trueWidth*i,s.y1=t+this.trueHeight*(1-i)/2,s.y2=s.y1+this.trueHeight*i;break;case 1:case-1:case 3:case-3:s.x1=e+this.trueWidth*(1-i)/2+(o-r)/2,s.x2=s.x1+this.trueHeight*i,s.y1=t+this.trueHeight*(1-i)/2+(r-o)/2,s.y2=s.y1+this.trueWidth*i;break;default:s.x1=e+this.trueWidth*(1-i)/2,s.x2=s.x1+this.trueWidth*i,s.y1=t+this.trueHeight*(1-i)/2,s.y2=s.y1+this.trueHeight*i;break}return s},getCropAxis(){let 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(e){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.$emit("crop-moving",{moving:!1,axis:this.getCropAxis()})},getCropChecked(e){let t=document.createElement("canvas"),i=new Image,s=this.rotate,o=this.trueWidth,r=this.trueHeight,a=this.cropOffsertX,c=this.cropOffsertY;i.onload=()=>{if(this.cropW!==0){let h=t.getContext("2d"),p=1;this.high&!this.full&&(p=window.devicePixelRatio),this.enlarge!==1&!this.full&&(p=Math.abs(Number(this.enlarge)));let u=this.cropW*p,S=this.cropH*p,f=o*this.scale*p,m=r*this.scale*p,w=(this.x-a+this.trueWidth*(1-this.scale)/2)*p,v=(this.y-c+this.trueHeight*(1-this.scale)/2)*p;switch(n(u,S),h.save(),this.fillColor&&(h.fillStyle=this.fillColor,h.fillRect(0,0,t.width,t.height)),s){case 0:this.full?(n(u/this.scale,S/this.scale),h.drawImage(i,w/this.scale,v/this.scale,f/this.scale,m/this.scale)):h.drawImage(i,w,v,f,m);break;case 1:case-3:this.full?(n(u/this.scale,S/this.scale),w=w/this.scale+(f/this.scale-m/this.scale)/2,v=v/this.scale+(m/this.scale-f/this.scale)/2,h.rotate(s*90*Math.PI/180),h.drawImage(i,v,-w-m/this.scale,f/this.scale,m/this.scale)):(w=w+(f-m)/2,v=v+(m-f)/2,h.rotate(s*90*Math.PI/180),h.drawImage(i,v,-w-m,f,m));break;case 2:case-2:this.full?(n(u/this.scale,S/this.scale),h.rotate(s*90*Math.PI/180),w=w/this.scale,v=v/this.scale,h.drawImage(i,-w-f/this.scale,-v-m/this.scale,f/this.scale,m/this.scale)):(h.rotate(s*90*Math.PI/180),h.drawImage(i,-w-f,-v-m,f,m));break;case 3:case-1:this.full?(n(u/this.scale,S/this.scale),w=w/this.scale+(f/this.scale-m/this.scale)/2,v=v/this.scale+(m/this.scale-f/this.scale)/2,h.rotate(s*90*Math.PI/180),h.drawImage(i,-v-f/this.scale,w,f/this.scale,m/this.scale)):(w=w+(f-m)/2,v=v+(m-f)/2,h.rotate(s*90*Math.PI/180),h.drawImage(i,-v-f,w,f,m));break;default:this.full?(n(u/this.scale,S/this.scale),h.drawImage(i,w/this.scale,v/this.scale,f/this.scale,m/this.scale)):h.drawImage(i,w,v,f,m)}h.restore()}else{let h=o*this.scale,p=r*this.scale,u=t.getContext("2d");switch(u.save(),this.fillColor&&(u.fillStyle=this.fillColor,u.fillRect(0,0,t.width,t.height)),s){case 0:n(h,p),u.drawImage(i,0,0,h,p);break;case 1:case-3:n(p,h),u.rotate(s*90*Math.PI/180),u.drawImage(i,0,-p,h,p);break;case 2:case-2:n(h,p),u.rotate(s*90*Math.PI/180),u.drawImage(i,-h,-p,h,p);break;case 3:case-1:n(p,h),u.rotate(s*90*Math.PI/180),u.drawImage(i,-h,0,h,p);break;default:n(h,p),u.drawImage(i,0,0,h,p)}u.restore()}e(t)};var l=this.img.substr(0,4);l!=="data"&&(i.crossOrigin="Anonymous"),i.src=this.imgs;function n(h,p){t.width=Math.round(h),t.height=Math.round(p)}},getCropData(e){this.getCropChecked(t=>{e(t.toDataURL("image/"+this.outputType,this.outputSize))})},getCropBlob(e){this.getCropChecked(t=>{t.toBlob(i=>e(i),"image/"+this.outputType,this.outputSize)})},showPreview(){if(this.isCanShow)this.isCanShow=!1,setTimeout(()=>{this.isCanShow=!0},16);else return!1;let e=this.cropW,t=this.cropH,i=this.scale;var s={};s.div={width:`${e}px`,height:`${t}px`};let o=(this.x-this.cropOffsertX)/i,r=(this.y-this.cropOffsertY)/i,a=0;s.w=e,s.h=t,s.url=this.imgs,s.img={width:`${this.trueWidth}px`,height:`${this.trueHeight}px`,transform:`scale(${i})translate3d(${o}px, ${r}px, ${a}px)rotateZ(${this.rotate*90}deg)`},s.html=`
  2. <div class="show-preview" style="width: ${s.w}px; height: ${s.h}px,; overflow: hidden">
  3. <div style="width: ${e}px; height: ${t}px">
  4. <img src=${s.url} style="width: ${this.trueWidth}px; height: ${this.trueHeight}px; transform:
  5. scale(${i})translate3d(${o}px, ${r}px, ${a}px)rotateZ(${this.rotate*90}deg)">
  6. </div>
  7. </div>`,this.$emit("real-time",s)},reload(){let e=new Image;e.onload=()=>{this.w=parseFloat(window.getComputedStyle(this.$refs.cropper).width),this.h=parseFloat(window.getComputedStyle(this.$refs.cropper).height),this.trueWidth=e.width,this.trueHeight=e.height,this.original?this.scale=1:this.scale=this.checkedMode(),this.$nextTick(()=>{this.x=-(this.trueWidth-this.trueWidth*this.scale)/2+(this.w-this.trueWidth*this.scale)/2,this.y=-(this.trueHeight-this.trueHeight*this.scale)/2+(this.h-this.trueHeight*this.scale)/2,this.loading=!1,this.autoCrop&&this.goAutoCrop(),this.$emit("img-load","success"),setTimeout(()=>{this.showPreview()},20)})},e.onerror=()=>{this.$emit("img-load","error")},e.src=this.imgs},checkedMode(){let e=1,t=this.trueWidth,i=this.trueHeight;const s=this.mode.split(" ");switch(s[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=this.w,e=t/this.trueWidth,i=i*e,i<this.h&&(i=this.h,e=i/this.trueHeight);break;default:try{let o=s[0];if(o.search("px")!==-1){o=o.replace("px",""),t=parseFloat(o);const r=t/this.trueWidth;let a=1,c=s[1];c.search("px")!==-1&&(c=c.replace("px",""),i=parseFloat(c),a=i/this.trueHeight),e=Math.min(r,a)}if(o.search("%")!==-1&&(o=o.replace("%",""),t=parseFloat(o)/100*this.w,e=t/this.trueWidth),s.length===2&&o==="auto"){let r=s[1];r.search("px")!==-1&&(r=r.replace("px",""),i=parseFloat(r),e=i/this.trueHeight),r.search("%")!==-1&&(r=r.replace("%",""),i=parseFloat(r)/100*this.h,e=i/this.trueHeight)}}catch{e=1}}return e},goAutoCrop(e,t){if(this.imgs===""||this.imgs===null)return;this.clearCrop(),this.cropping=!0;let i=this.w,s=this.h;if(this.centerBox){const a=Math.abs(this.rotate)%2>0;let c=(a?this.trueHeight:this.trueWidth)*this.scale,l=(a?this.trueWidth:this.trueHeight)*this.scale;i=c<i?c:i,s=l<s?l:s}var o=e||parseFloat(this.autoCropWidth),r=t||parseFloat(this.autoCropHeight);(o===0||r===0)&&(o=i*.8,r=s*.8),o=o>i?i:o,r=r>s?s:r,this.fixed&&(r=o/this.fixedNumber[0]*this.fixedNumber[1]),r>this.h&&(r=this.h,o=r/this.fixedNumber[1]*this.fixedNumber[0]),this.changeCrop(o,r)},changeCrop(e,t){if(this.centerBox){let i=this.getImgAxis();e>i.x2-i.x1&&(e=i.x2-i.x1,t=e/this.fixedNumber[0]*this.fixedNumber[1]),t>i.y2-i.y1&&(t=i.y2-i.y1,e=t/this.fixedNumber[1]*this.fixedNumber[0])}this.cropW=e,this.cropH=t,this.checkCropLimitSize(),this.$nextTick(()=>{this.cropOffsertX=(this.w-this.cropW)/2,this.cropOffsertY=(this.h-this.cropH)/2,this.centerBox&&this.moveCrop(null,!0)})},refresh(){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(()=>{this.checkedImg()})},rotateLeft(){this.rotate=this.rotate<=-3?0:this.rotate-1},rotateRight(){this.rotate=this.rotate>=3?0:this.rotate+1},rotateClear(){this.rotate=0},checkoutImgAxis(e,t,i){e=e||this.x,t=t||this.y,i=i||this.scale;let s=!0;if(this.centerBox){let o=this.getImgAxis(e,t,i),r=this.getCropAxis();o.x1>=r.x1&&(s=!1),o.x2<=r.x2&&(s=!1),o.y1>=r.y1&&(s=!1),o.y2<=r.y2&&(s=!1)}return s}},mounted(){this.support="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let e=this;var t=navigator.userAgent;this.isIOS=!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(i,s,o){for(var r=atob(this.toDataURL(s,o).split(",")[1]),a=r.length,c=new Uint8Array(a),l=0;l<a;l++)c[l]=r.charCodeAt(l);i(new Blob([c],{type:e.type||"image/png"}))}}),this.showPreview(),this.checkedImg()},unmounted(){window.removeEventListener("mousemove",this.moveCrop),window.removeEventListener("mouseup",this.leaveCrop),window.removeEventListener("touchmove",this.moveCrop),window.removeEventListener("touchend",this.leaveCrop),this.cancelScale()}}),Ve={key:0,class:"cropper-box"},_e=["src"],Qe={class:"cropper-view-box"},Ge=["src"],qe={key:1};function Ke(e,t,i,s,o,r){return B(),Y("div",{class:"vue-cropper",ref:"cropper",onMouseover:t[28]||(t[28]=(...a)=>e.scaleImg&&e.scaleImg(...a)),onMouseout:t[29]||(t[29]=(...a)=>e.cancelScale&&e.cancelScale(...a))},[e.imgs?(B(),Y("div",Ve,[V(x("div",{class:"cropper-box-canvas",style:z({width:e.trueWidth+"px",height:e.trueHeight+"px",transform:"scale("+e.scale+","+e.scale+") translate3d("+e.x/e.scale+"px,"+e.y/e.scale+"px,0)rotateZ("+e.rotate*90+"deg)"})},[x("img",{src:e.imgs,alt:"cropper-img",ref:"cropperImg"},null,8,_e)],4),[[_,!e.loading]])])):F("",!0),x("div",{class:Ce(["cropper-drag-box",{"cropper-move":e.move&&!e.crop,"cropper-crop":e.crop,"cropper-modal":e.cropping}]),onMousedown:t[0]||(t[0]=(...a)=>e.startMove&&e.startMove(...a)),onTouchstart:t[1]||(t[1]=(...a)=>e.startMove&&e.startMove(...a))},null,34),V(x("div",{class:"cropper-crop-box",style:z({width:e.cropW+"px",height:e.cropH+"px",transform:"translate3d("+e.cropOffsertX+"px,"+e.cropOffsertY+"px,0)"})},[x("span",Qe,[x("img",{style:z({width:e.trueWidth+"px",height:e.trueHeight+"px",transform:"scale("+e.scale+","+e.scale+") translate3d("+(e.x-e.cropOffsertX)/e.scale+"px,"+(e.y-e.cropOffsertY)/e.scale+"px,0)rotateZ("+e.rotate*90+"deg)"}),src:e.imgs,alt:"cropper-img"},null,12,Ge)]),x("span",{class:"cropper-face cropper-move",onMousedown:t[2]||(t[2]=(...a)=>e.cropMove&&e.cropMove(...a)),onTouchstart:t[3]||(t[3]=(...a)=>e.cropMove&&e.cropMove(...a))},null,32),e.info?(B(),Y("span",{key:0,class:"crop-info",style:z({top:e.cropInfo.top})},Q(e.cropInfo.width)+" \xD7 "+Q(e.cropInfo.height),5)):F("",!0),e.fixedBox?F("",!0):(B(),Y("span",qe,[x("span",{class:"crop-line line-w",onMousedown:t[4]||(t[4]=a=>e.changeCropSize(a,!1,!0,0,1)),onTouchstart:t[5]||(t[5]=a=>e.changeCropSize(a,!1,!0,0,1))},null,32),x("span",{class:"crop-line line-a",onMousedown:t[6]||(t[6]=a=>e.changeCropSize(a,!0,!1,1,0)),onTouchstart:t[7]||(t[7]=a=>e.changeCropSize(a,!0,!1,1,0))},null,32),x("span",{class:"crop-line line-s",onMousedown:t[8]||(t[8]=a=>e.changeCropSize(a,!1,!0,0,2)),onTouchstart:t[9]||(t[9]=a=>e.changeCropSize(a,!1,!0,0,2))},null,32),x("span",{class:"crop-line line-d",onMousedown:t[10]||(t[10]=a=>e.changeCropSize(a,!0,!1,2,0)),onTouchstart:t[11]||(t[11]=a=>e.changeCropSize(a,!0,!1,2,0))},null,32),x("span",{class:"crop-point point1",onMousedown:t[12]||(t[12]=a=>e.changeCropSize(a,!0,!0,1,1)),onTouchstart:t[13]||(t[13]=a=>e.changeCropSize(a,!0,!0,1,1))},null,32),x("span",{class:"crop-point point2",onMousedown:t[14]||(t[14]=a=>e.changeCropSize(a,!1,!0,0,1)),onTouchstart:t[15]||(t[15]=a=>e.changeCropSize(a,!1,!0,0,1))},null,32),x("span",{class:"crop-point point3",onMousedown:t[16]||(t[16]=a=>e.changeCropSize(a,!0,!0,2,1)),onTouchstart:t[17]||(t[17]=a=>e.changeCropSize(a,!0,!0,2,1))},null,32),x("span",{class:"crop-point point4",onMousedown:t[18]||(t[18]=a=>e.changeCropSize(a,!0,!1,1,0)),onTouchstart:t[19]||(t[19]=a=>e.changeCropSize(a,!0,!1,1,0))},null,32),x("span",{class:"crop-point point5",onMousedown:t[20]||(t[20]=a=>e.changeCropSize(a,!0,!1,2,0)),onTouchstart:t[21]||(t[21]=a=>e.changeCropSize(a,!0,!1,2,0))},null,32),x("span",{class:"crop-point point6",onMousedown:t[22]||(t[22]=a=>e.changeCropSize(a,!0,!0,1,2)),onTouchstart:t[23]||(t[23]=a=>e.changeCropSize(a,!0,!0,1,2))},null,32),x("span",{class:"crop-point point7",onMousedown:t[24]||(t[24]=a=>e.changeCropSize(a,!1,!0,0,2)),onTouchstart:t[25]||(t[25]=a=>e.changeCropSize(a,!1,!0,0,2))},null,32),x("span",{class:"crop-point point8",onMousedown:t[26]||(t[26]=a=>e.changeCropSize(a,!0,!0,2,2)),onTouchstart:t[27]||(t[27]=a=>e.changeCropSize(a,!0,!0,2,2))},null,32)]))],4),[[_,e.cropping]])],544)}const q=$e(je,[["render",Ke],["__scopeId","data-v-69939069"]]),Je="_upbtn_15vje_1",Ze="_uploadWarper_15vje_5",et="_bg_15vje_12",tt="_btn_15vje_21",it="_btn1_15vje_33",st="_img_15vje_44",ot="_btndiv_15vje_53",rt="_wrapper_15vje_64";var I={upbtn:Je,uploadWarper:Ze,bg:et,btn:tt,btn1:it,img:st,btndiv:ot,wrapper:rt},at=W({name:"col-cropper",components:{VueCropper:q},props:{hideInput:{type:Boolean,default:!1},option:{type:Object},onCancelTailor:{type:Function,default:()=>{}},getBase64Data:{type:Function,default:()=>{}},getBlob:{type:Function,default:()=>{}},getFile:{type:Function,default:()=>{}},imgOriginF:{type:Function,default:()=>{}}},data(){return{img:"",config:{ceilbutton:!1,outputSize:1,outputType:"png",info:!1,canScale:!0,autoCrop:!1,autoCropWidth:0,autoCropHeight:0,fixed:!0,fixedNumber:[1,1],full:!1,fixedBox:!0,canMove:!0,canMoveBox:!1,original:!1,centerBox:!0,high:!0,infoTrue:!1,maxImgSize:2e3,enlarge:1,mode:"100%",cancelButtonText:"\u53D6\u6D88",confirmButtonText:"\u786E\u5B9A",cancelButtonBackgroundColor:"#606266",confirmButtonBackgroundColor:"#ed594c",cancelButtonTextColor:"#ffffff",confirmButtonTextColor:"#ffffff"}}},mounted(){this.config=Object.assign(this.config,this.option)},methods:{addSlide(){if(document.getElementById("vertical")==null){const e=document.getElementsByClassName("cropper-crop-box")[0],t=document.createElement("div");t.id="vertical",t.style.width="1px",t.style.height="100%",t.style.top="0px",t.style.left="33%",t.style.position="absolute",t.style.backgroundColor="#fff",t.style.zIndex="522",t.style.opacity="0.5";const i=document.createElement("div");i.style.width="1px",i.style.height="100%",i.style.top="0px",i.style.right="33%",i.style.position="absolute",i.style.backgroundColor="#fff",i.style.zIndex="522",i.style.opacity="0.5";const s=document.createElement("div");s.style.width="100%",s.style.height="1px",s.style.top="33%",s.style.left="0px",s.style.position="absolute",s.style.backgroundColor="#fff",s.style.zIndex="522",s.style.opacity="0.5";const o=document.createElement("div");o.style.width="100%",o.style.height="1px",o.style.bottom="33%",o.style.left="0px",o.style.position="absolute",o.style.backgroundColor="#fff",o.style.zIndex="522",o.style.opacity="0.5";const r=document.createElement("div");r.style.width="30px",r.style.height="4px",r.style.top="-4px",r.style.left="-4px",r.style.position="absolute",r.style.backgroundColor="#fff",r.style.zIndex="522",r.style.opacity="1";const a=document.createElement("div");a.style.width="4px",a.style.height="30px",a.style.top="-4px",a.style.left="-4px",a.style.position="absolute",a.style.backgroundColor="#fff",a.style.zIndex="522",a.style.opacity="1";const c=document.createElement("div");c.style.width="30px",c.style.height="4px",c.style.top="-4px",c.style.right="-4px",c.style.position="absolute",c.style.backgroundColor="#fff",c.style.zIndex="522",c.style.opacity="1";const l=document.createElement("div");l.style.width="4px",l.style.height="30px",l.style.top="-4px",l.style.right="-4px",l.style.position="absolute",l.style.backgroundColor="#fff",l.style.zIndex="522",l.style.opacity="1";const n=document.createElement("div");n.style.width="30px",n.style.height="4px",n.style.bottom="-4px",n.style.left="-4px",n.style.position="absolute",n.style.backgroundColor="#fff",n.style.zIndex="522",n.style.opacity="1";const h=document.createElement("div");h.style.width="4px",h.style.height="30px",h.style.bottom="-4px",h.style.left="-4px",h.style.position="absolute",h.style.backgroundColor="#fff",h.style.zIndex="522",h.style.opacity="1";const p=document.createElement("div");p.style.width="30px",p.style.height="4px",p.style.bottom="-4px",p.style.right="-4px",p.style.position="absolute",p.style.backgroundColor="#fff",p.style.zIndex="522",p.style.opacity="1";const u=document.createElement("div");u.style.width="4px",u.style.height="30px",u.style.bottom="-4px",u.style.right="-4px",u.style.position="absolute",u.style.backgroundColor="#fff",u.style.zIndex="522",u.style.opacity="1",e.appendChild(t),e.appendChild(i),e.appendChild(s),e.appendChild(o),e.appendChild(r),e.appendChild(a),e.appendChild(c),e.appendChild(l),e.appendChild(n),e.appendChild(h),e.appendChild(p),e.appendChild(u)}},onLoadImg(e){return new Promise(function(t,i){const s=new FileReader;s.readAsDataURL(e),s.onload=o=>{t(o.target.result)}})},loadFile(e){if(e instanceof File)this.onLoadImg(e).then(t=>{this.img=t,setTimeout(()=>{this.config.autoCrop=!0,this.addSlide()},10)});else throw new Error("Arguments file is not File")},loadBase64(e){if(typeof e!="string")throw new Error("Arguments base64 is not string");const t=e.split(",");if(!/^data:image\/(.*?);base64$/.test(t[0]))throw new Error("Arguments base64 MIME is not image/*");if(!/^[\/]?([\da-zA-Z]+[\/+]+)*[\da-zA-Z]+([+=]{1,2}|[\/])?$/.test(t[1]))throw new Error("Not standard base64");this.img=e,setTimeout(()=>{this.config.autoCrop=!0,this.addSlide()},10)},rotating(e){this.$refs.cropper.rotateRight()},canceltailor(){this.img="",this.onCancelTailor()},tailoring(){this.$refs.cropper.getCropData(e=>{this.getBase64Data(e),this.getBlob(e),this.img="",this.config.autoCrop=!1}),this.$refs.cropper.getCropBlob(e=>{this.getBase64Data(e),this.getBlob(e);const t={jpeg:"jpg",png:"png",webp:"webp"}[this.config.outputType],i=new Date().getTime(),s=new File([e],`${i}.${t}`,{type:`image/${this.config.outputType}`});this.getFile(s),this.img="",this.config.autoCrop=!1})},async upPhoto(e){console.log(e,"upload");const t=e.target.files[0];this.$refs.headInput.value=null,t!=null&&(this.imgOriginF(t),this.img=await this.onLoadImg(t),this.config.autoCrop=!0,setTimeout(()=>{this.addSlide()},20))},onCropMoving(e){},onImgMoving(e){}},render(){return d("div",{class:[I.upbtn,I.uploadWarper]},[this.hideInput,this.hideInput?null:d("input",{style:"opacity: 0;",class:I.upbtn,type:"file",accept:"image/*",onChange:this.upPhoto,ref:"headInput"},null),this.img!=""?d("div",{class:I.bg},[this.config.ceilbutton?d("div",{class:I.btndiv},[d("div",{class:I.btn,onClick:this.canceltailor,style:{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),d("div",{class:I.img,onClick:this.rotating},null),d("div",{class:I.btn,onClick:this.tailoring,style:{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])]):null,d("div",{class:I.wrapper},[d(q,{ref:"cropper",img:this.img,outputSize:this.config.outputSize,outputType:this.config.outputType,info:this.config.info,canScale:this.config.canScale,autoCrop:this.config.autoCrop,autoCropWidth:this.config.autoCropWidth,autoCropHeight:this.config.autoCropHeight,fixedBox:this.config.fixedBox,fixed:this.config.fixed,fixedNumber:this.config.fixedNumber,full:this.config.full,canMove:this.config.canMove,canMoveBox:this.config.canMoveBox,original:this.config.original,centerBox:this.config.centerBox,high:this.config.high,infoTrue:this.config.infoTrue,maxImgSize:this.config.maxImgSize,enlarge:this.config.enlarge,mode:this.config.mode,onCropMoving:this.onCropMoving,onImgMoving:this.onImgMoving},null)]),this.config.ceilbutton?null:d("div",{class:I.btndiv},[d("div",{class:I.btn,onClick:this.canceltailor,style:{backgroundColor:this.config.cancelButtonBackgroundColor,color:this.config.cancelButtonTextColor}},[this.config.cancelButtonText]),d("div",{class:I.img,onClick:this.rotating},null),d("div",{class:I.btn,onClick:this.tailoring,style:{backgroundColor:this.config.confirmButtonBackgroundColor,color:this.config.confirmButtonTextColor}},[this.config.confirmButtonText])])]):null])}}),D="data:image/png;base64,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",dt=W({name:"col-upload",props:{modelValue:String,tips:{type:String,default:"\u70B9\u51FB\u4E0A\u4F20"},deletable:{type:Boolean,default:!0},native:{type:Boolean,default:!1},cropper:{type:Boolean,default:!1},options:{type:Object,default:{}},uploadSize:{type:Number,default:5},onUploadChange:{type:Function,default:e=>{}},bucket:{type:String,default:"daya"}},methods:{nativeUpload(){be({api:"chooseFile",content:{type:"img",max:1,bucket:this.bucket}},e=>{console.log(e,"fileUrl"),this.$emit("update:modelValue",e.fileUrl)})},beforeRead(e){return console.log(e,"beforeRead"),e.size/1024/1024<this.uploadSize?!0:(L(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.uploadSize}MB`),!1)},beforeDelete(e,t){return!0},async afterRead(e,t){try{e.status="uploading",e.message="\u4E0A\u4F20\u4E2D...",await this.uploadFile(e.file)}catch(i){console.log(i,"2323"),L.clear()}},onClose(e){this.$emit("update:modelValue",null),this.onUploadChange(),e.stopPropagation()},async getFile(e){try{await this.uploadFile(e)}catch{}},async uploadFile(e){try{const t=e.name||"",i=t&&t.replace(/ /gi,"_"),s=new Date().getTime()+i;console.log(e);const{data:o}=await ke({filename:s,bucketName:this.bucket,postData:{filename:s,acl:"public-read",key:s}});L.loading({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const r={policy:o.policy,signature:o.signature,key:s,KSSAccessKeyId:o.kssAccessKeyId,acl:"public-read",name:s,file:e};console.log(r,"obj");const a=await Se(Oe(this.bucket),r);L.clear(),this.$emit("update:modelValue",a),this.onUploadChange(a)}catch(t){console.log(t,"uploadFile")}}},render(){return J(()=>this.modelValue),d("div",{class:k["uploader-section"]},[this.modelValue&&this.deletable?d(M,{name:"cross",onClick:this.onClose,class:k["img-close"]},null):null,this.cropper&&!this.native?d("div",{class:k["col-uploader"]},[this.modelValue?d(E,{fit:"cover",position:"center",class:k.uploadImg,src:this.modelValue},null):d("div",{class:k.uploader},[d(M,{name:D,size:"32"},null),this.tips&&d("p",{class:k.uploaderText},[this.tips])]),d(at,{option:this.options,getFile:this.getFile},null)]):this.native?d("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},onClick:this.nativeUpload},[this.modelValue?d(E,{fit:"cover",position:"center",class:k.uploadImg,src:this.modelValue},null):d("div",{class:k.uploader},[d(M,{name:D,size:"32"},null),this.tips&&d("p",{class:k.uploaderText},[this.tips])])]):d(ze,{afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete},{default:()=>this.modelValue?d(E,{fit:"cover",position:"center",class:k.uploadImg,src:this.modelValue},null):d("div",{class:k.uploader},[d(M,{name:D,size:"32"},null),this.tips&&d("p",{class:k.uploaderText},[this.tips])])})])}});export{dt as C,ze as U};