import{H as k,M as y,i as w,r as B,aM as C,f as v,bK as b,n as M}from"./app-JmgyQoR0.js";import{b as V}from"./bytes-7YLXyrly.js";import{n as $}from"./number-rE36t967.js";import{b as I,D as d,h as a,i as c,j as s,H as r,x as K,E as o,u as n,X as L,q as E,K as u,l as p,t as h,I as D,J as S}from"./vue-y3KLWBaS.js";const q=I({components:{MkModal:k,MkButton:y},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:w}},computed:{remainingLength(){var t;const e=(t=B.maxCaptionTextLength)!=null?t:512;return typeof this.inputValue!="string"?e:e-C(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");v("drive/files/caption-image",{url:e.src}).then(m=>{b(t,m.slice(0,512-t.value.length))})}}}),N=e=>(D("data-v-39270222"),e=e(),S(),e),O={class:"container"},T={class:"fullwidth top-caption"},j={class:"mk-dialog"},z=N(()=>n("br",null,null,-1)),H=["placeholder"],U={key:0,class:"buttons"},J={class:"hdrwpsaf fullwidth"},P=["src","alt","title"],X={key:0};function A(e,t,m,F,G,Q){const f=d("Mfm"),l=d("MkButton"),g=d("MkModal");return a(),c(g,{ref:"modal",onClick:t[3]||(t[3]=i=>e.done(!0)),onClosed:t[4]||(t[4]=i=>e.$emit("closed"))},{default:s(()=>[n("div",O,[n("div",T,[n("div",j,[n("header",null,[e.title?(a(),c(f,{key:0,class:"title",text:e.title},null,8,["text"])):r("",!0),n("span",{class:K(["text-count",{over:e.remainingLength<0}])},o(e.remainingLength),3),z]),E(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,H),[[L,e.inputValue]]),e.showOkButton||e.showCaptionButton||e.showCancelButton?(a(),h("div",U,[p(l,{inline:"",primary:"",disabled:e.remainingLength<0,onClick:e.ok},{default:s(()=>[u(o(e.i18n.ts.ok),1)]),_:1},8,["disabled","onClick"]),p(l,{inline:"",onClick:e.caption},{default:s(()=>[u(o(e.i18n.ts.caption),1)]),_:1},8,["onClick"]),p(l,{inline:"",onClick:e.cancel},{default:s(()=>[u(o(e.i18n.ts.cancel),1)]),_:1},8,["onClick"])])):r("",!0)])]),n("div",J,[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,P),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?(a(),h("span",X,o(e.number(e.image.properties.width))+"px × "+o(e.number(e.image.properties.height))+"px",1)):r("",!0)])])])]),_:1},512)}const _=M(q,[["render",A],["__scopeId","data-v-39270222"]]);export{_ as default};
