import{b,c as D,E,j as C,g as I,i as p,q as d,t as T,k as $,T as B,u as v,p as M,H as R,J as V,D as L,a as m}from"./vue-Cm77DuTi.js";import{C as N}from"./media-DuCIZ-3n.js";import{aq as q,aT as F,S as P,b as j,a5 as z,v as k,aa as H,$ as O,au as U,_ as A}from"./app-QjDgb7aF.js";import"./charts-3gEHPHRq.js";const J={key:0,class:"loading"},W={class:"container"},X=b({__name:"MkCropperDialog",props:{file:{},aspectRatio:{}},emits:["ok","cancel","closed"],setup(y,{emit:w}){const u=w,s=y,_=`${q}/proxy/image.webp?${F({url:s.file.url})}`,r=m(),g=m();let o=null,f=m(!0);const S=async()=>{const t=new Promise(async i=>{(await o?.getCropperSelection()?.$toCanvas()).toBlob(n=>{const l=new FormData;l.append("file",n),k.state.uploadFolder&&l.append("folderId",k.state.uploadFolder),fetch(H+"/drive/files/create",{method:"POST",body:l,headers:{authorization:`Bearer ${O.token}`}}).then(c=>c.json()).then(c=>{i(c)})})});U(t);const e=await t;u("ok",e),r.value.close()},h=()=>{u("cancel"),r.value.close()},x=()=>{f.value=!1,o&&(o.getCropperImage().$center("contain"),o.getCropperSelection().$center())};return D(()=>{o=new N(g.value,{});const t=getComputedStyle(document.documentElement),e=o.getCropperSelection();e.themeColor=P(t.getPropertyValue("--accent")).toHexString(),e.aspectRatio=s.aspectRatio,e.initialAspectRatio=s.aspectRatio,e.outlined=!0,window.setTimeout(()=>{o.getCropperImage().$center("contain"),e.$center()},100),window.setTimeout(()=>{o.getCropperImage().$center("contain"),e.$center()},500)}),(t,e)=>{const i=E("MkLoading");return C(),I(z,{ref_key:"dialogEl",ref:r,width:800,height:500,scroll:!1,"with-ok-button":!0,onClose:e[0]||(e[0]=a=>h()),onOk:e[1]||(e[1]=a=>S()),onClosed:e[2]||(e[2]=a=>t.$emit("closed"))},{header:p(()=>[V(L(v(j).ts.cropImage),1)]),default:p(({width:a,height:n})=>[d("div",{class:"mk-cropper-dialog",style:T(`--vw: ${a?`${a}px`:"100%"}; --vh: ${n?`${n}px`:"100%"};`)},[$(B,{name:"fade"},{default:p(()=>[v(f)?(C(),M("div",J,[$(i)])):R("",!0)]),_:1}),d("div",W,[d("img",{ref_key:"imgEl",ref:g,src:_,style:{display:"none"},onLoad:x},null,544)])],4)]),_:1},512)}}}),Z=A(X,[["__scopeId","data-v-6057db42"]]);export{Z as default};
//# sourceMappingURL=MkCropperDialog-C2NnkZ00.js.map
