import{_ as v,a as _,c as p,o as i,e as d,b as t,f as c,t as l,G as r,I as n,F as k,d as h,E as U,D,h as g,w as V}from"./Bgmy51Qv.js";import{_ as f}from"./D_7E8SMU.js";import{A as w}from"./AmaTRG5a.js";import{u as C}from"./7pZkuj9N.js";import{_ as x}from"./CNIrc0EA.js";import{u as B}from"./BHvLfWtM.js";import{_ as E}from"./DIkWVjrx.js";import"./DuhDFJjj.js";const M={setup(){const{setRequest:e,getRequest:a}=C();return{setRequest:e,getRequest:a}},name:"MediaStorageSetting",data(){return{gettingData:!1,updating:!1,loading:!1,hasError:!1,result:{mediaStorage:null}}},props:{},mixins:[B],components:{Dropdown:f,AjaxButton:w,Spinner:_,ErrorFormatter:x},computed:{},methods:{changeMediaStorage(e){this.result.mediaStorage=e.key},async fetchingData(){try{this.loading=!0;const e=await this.getRequest({params:{},api:"mediaStorageFind"});e&&(this.result=e),this.loading=!1}catch(e){g({statusCode:400,message:e.message})}},async updateData(){if(this.result.mediaStorage){this.updating=!0;try{const e=await this.setRequest({params:this.result,api:"mediaStorageAction"});e&&(this.result=e,setTimeout(()=>{window.location.reload()},1e3))}catch(e){g({statusCode:400,message:e.message})}this.updating=!1}else this.hasError=!0}},async mounted(){await this.fetchingData()}},I={key:0,class:"spinner-wrapper"},R={class:""},j={class:"input-wrapper single-line"},q={class:"input-wrapper single-line"},A={class:"input-wrapper single-line"},F={key:0,class:"input-wrapper single-line"},N=["placeholder"],G={class:"input-wrapper single-line"},L=["placeholder"],T={class:"input-wrapper single-line"},z=["placeholder"],H={class:"input-wrapper single-line"},J=["placeholder"],K={class:"input-wrapper single-line"},O=["placeholder"],Q={class:"oflow-hidden"};function W(e,a,S,m,s,u){const y=_,b=f,P=w;return i(),p("form",{class:D({"has-error":s.hasError}),onSubmit:a[7]||(a[7]=U((...o)=>u.updateData&&u.updateData(...o),["prevent"]))},[s.loading?(i(),p("div",I,[c(y,{radius:60,color:"primary",class:"mr-15"})])):d("",!0),t("div",R,[t("div",j,[t("label",null,l(e.$t("list.ms")),1),c(b,{options:e.mediaStorages,"selected-key":s.result.mediaStorage,onClicked:u.changeMediaStorage},null,8,["options","selected-key","onClicked"])]),t("div",q,[t("label",null,l(e.$t("list.tp")),1),r(t("input",{type:"text",placeholder:"eg. thumb-","onUpdate:modelValue":a[0]||(a[0]=o=>s.result.thumbPrefix=o)},null,512),[[n,s.result.thumbPrefix]])]),t("div",A,[t("label",null,l(e.$t("list.di")),1),r(t("input",{type:"text",placeholder:"eg. default-image.webp","onUpdate:modelValue":a[1]||(a[1]=o=>s.result.defaultImage=o)},null,512),[[n,s.result.defaultImage]])]),s.result.mediaStorage==="URL"?(i(),p("div",F,[t("label",null,l(e.$t("list.cu")),1),r(t("input",{type:"text",placeholder:e.$t("list.cu"),"onUpdate:modelValue":a[2]||(a[2]=o=>s.result.cdnUrl=o)},null,8,N),[[n,s.result.cdnUrl]])])):s.result.mediaStorage==="GCS"?(i(),p(k,{key:1},[t("div",G,[t("label",null,l(e.$t("list.cu")),1),r(t("input",{type:"text",placeholder:e.$t("list.cu"),"onUpdate:modelValue":a[3]||(a[3]=o=>s.result.cdnUrl=o)},null,8,L),[[n,s.result.cdnUrl]])]),t("div",T,[t("label",null,l(e.$t("dataPage.gcpi")),1),r(t("input",{type:"password",placeholder:e.$t("dataPage.gcpi"),"onUpdate:modelValue":a[4]||(a[4]=o=>s.result.gcProjectId=o)},null,8,z),[[n,s.result.gcProjectId]])]),t("div",H,[t("label",null,l(e.$t("dataPage.gcsb")),1),r(t("input",{type:"password",placeholder:e.$t("dataPage.gcsb"),"onUpdate:modelValue":a[5]||(a[5]=o=>s.result.gcStorageBucket=o)},null,8,J),[[n,s.result.gcStorageBucket]])]),t("div",K,[t("label",null,l(e.$t("dataPage.gcspp")),1),r(t("input",{type:"password",placeholder:e.$t("dataPage.gcspp"),"onUpdate:modelValue":a[6]||(a[6]=o=>s.result.gcStoragePathPrefix=o)},null,8,O),[[n,s.result.gcStoragePathPrefix]])])],64)):d("",!0)]),t("div",Q,[e.$can("setting","edit")?(i(),h(P,{key:0,class:"primary-btn","fetching-data":s.updating},null,8,["fetching-data"])):d("",!0)])],34)}const X=v(M,[["render",W]]),le={__name:"media-storage",setup(e){return(a,S)=>{const m=X,s=E;return i(),h(s,{"active-route":"media-storage",class:"mb-5"},{rightArea:V(()=>[c(m)]),_:1})}}};export{le as default};
