import{M as k,H as y,d as w,bE as B,c as C,aI as b,b as v,_ as M}from"./app-QjDgb7aF.js";import{b as V}from"./bytes-C39hD0JB.js";import{n as $}from"./number-BJeYzK3l.js";import{b as E,E as r,j as s,g as c,i as a,q as n,H as d,x as K,D as o,l as L,W as I,p as h,k as u,J as p}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const q=E({components:{MkModal:y,MkButton:k},props:{image:{type:Object,required:!0},title:{type:String,required:!1},input:{required:!0},showOkButton:{type:Boolean,default:!0},showCaptionButton:{type:Boolean,default:!0},showCancelButton:{type:Boolean,default:!0},cancelableByBgClick:{type:Boolean,default:!0}},emits:["done","closed"],data(){return{inputValue:this.input.default?this.input.default:null,i18n:v}},computed:{remainingLength(){const e=C.maxCaptionTextLength??512;return typeof this.inputValue!="string"?e:e-b.length(this.inputValue)}},mounted(){document.addEventListener("keydown",this.onKeydown)},beforeUnmount(){document.removeEventListener("keydown",this.onKeydown)},methods:{bytes:V,number:$,done(e,t){this.$emit("done",{canceled:e,result:t}),this.$refs.modal.close()},async ok(){if(!this.showOkButton)return;const e=this.inputValue;this.done(!1,e)},cancel(){this.done(!0)},onBgClick(){this.cancelableByBgClick&&this.cancel()},onKeydown(e){e.which===27&&this.cancel()},onInputKeydown(e){e.which===13&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),this.ok())},caption(){const e=document.getElementById("imgtocaption"),t=document.getElementById("captioninput");w("drive/files/caption-image",{url:e.src}).then(m=>{B(t,m.slice(0,512-t.value.length))})}}}),D={class:"container"},N={class:"fullwidth top-caption"},O={class:"mk-dialog"},T=["placeholder"],j={key:0,class:"buttons"},z={class:"hdrwpsaf fullwidth"},H=["src","alt","title"],S={key:0};function U(e,t,m,J,P,W){const f=r("Mfm"),l=r("MkButton"),g=r("MkModal");return s(),c(g,{ref:"modal",onClick:t[3]||(t[3]=i=>e.done(!0)),onClosed:t[4]||(t[4]=i=>e.$emit("closed"))},{default:a(()=>[n("div",D,[n("div",N,[n("div",O,[n("header",null,[e.title?(s(),c(f,{key:0,class:"title",text:e.title},null,8,["text"])):d("",!0),n("span",{class:K(["text-count",{over:e.remainingLength<0}])},o(e.remainingLength),3),t[5]||(t[5]=n("br",null,null,-1))]),L(n("textarea",{id:"captioninput","onUpdate:modelValue":t[0]||(t[0]=i=>e.inputValue=i),autofocus:"",placeholder:e.input.placeholder,onKeydown:t[1]||(t[1]=(...i)=>e.onInputKeydown&&e.onInputKeydown(...i))},null,40,T),[[I,e.inputValue]]),e.showOkButton||e.showCaptionButton||e.showCancelButton?(s(),h("div",j,[u(l,{inline:"",primary:"",disabled:e.remainingLength<0,onClick:e.ok},{default:a(()=>[p(o(e.i18n.ts.ok),1)]),_:1},8,["disabled","onClick"]),u(l,{inline:"",onClick:e.caption},{default:a(()=>[p(o(e.i18n.ts.caption),1)]),_:1},8,["onClick"]),u(l,{inline:"",onClick:e.cancel},{default:a(()=>[p(o(e.i18n.ts.cancel),1)]),_:1},8,["onClick"])])):d("",!0)])]),n("div",z,[n("header",null,o(e.image.name),1),n("img",{id:"imgtocaption",src:e.image.url,alt:e.image.comment,title:e.image.comment,onClick:t[2]||(t[2]=i=>e.$refs.modal.close())},null,8,H),n("footer",null,[n("span",null,o(e.image.type),1),n("span",null,o(e.bytes(e.image.size)),1),e.image.properties&&e.image.properties.width?(s(),h("span",S,o(e.number(e.image.properties.width))+"px × "+o(e.number(e.image.properties.height))+"px",1)):d("",!0)])])])]),_:1},512)}const Y=M(q,[["render",U],["__scopeId","data-v-39270222"]]);export{Y as default};
//# sourceMappingURL=MkMediaCaption-D-5GP3mq.js.map
