import{l as c,v as w,s as f,d as g,p as x,E as L,q as S,w as y,x as o,G as D,o as v,y as s,i as d,A as n,z as T,t as F,C as m,h as N,H as V}from"./index-hZPKu-D6-Bm8qo_pT.chunk.mjs";import{d as h,t as l,l as C}from"./logger-DsWSbSNC.chunk.mjs";async function r(i){try{return await c.put(w("/apps/files_downloadlimit/api/v1/limit"),{limit:i}),!0}catch(t){h.error("Failed to set default download limit",{error:t}),f(l("files_downloadlimit","Failed to set default download limit"))}return!1}async function k(){try{return await c.delete(w("/apps/files_downloadlimit/api/v1/limit")),!0}catch(i){h.error("Failed to remove default download limit",{error:i}),f(l("files_downloadlimit","Failed to remove default download limit"))}return!1}const u=C("files_downloadlimit","default-download-limit",-1),A=g({name:"AdminSettings",components:{NcCheckboxRadioSwitch:S,NcSettingsSection:L,NcTextField:x},data(){return{limit:Math.max(u,10),enableDefaultLimit:u!==-1,showLoading:!1,showSuccess:!1}},computed:{helperText(){return typeof this.limit=="number"&&this.limit<=0?l("files_downloadlimit","The minimum limit is 1"):""}},watch:{async limit(i){await r(i)&&(this.showSuccess=!0,window.setTimeout(()=>{this.showSuccess=!1},1e3))},async enableDefaultLimit(i,t){this.showLoading=!0;let e;i?e=await r(10):e=await k(),e||(this.enableDefaultLimit=t),this.showLoading=!1}},methods:{t:l}}),R={class:"settings__placeholder"};function U(i,t,e,z,E,G){const p=o("NcCheckboxRadioSwitch"),_=o("NcTextField"),b=o("NcSettingsSection");return v(),D(b,{name:i.t("files_downloadlimit","Download limit"),description:i.t("files_downloadlimit","Configure the default download limit for external shares.")},{default:s(()=>[d(p,{modelValue:i.enableDefaultLimit,"onUpdate:modelValue":t[0]||(t[0]=a=>i.enableDefaultLimit=a),loading:i.showLoading,type:"switch"},{default:s(()=>[T(F(i.t("files_downloadlimit","Default download limit for external shares")),1)]),_:1},8,["modelValue","loading"]),n(d(_,{modelValue:i.limit,"onUpdate:modelValue":t[1]||(t[1]=a=>i.limit=a),class:"settings__field",disabled:!i.enableDefaultLimit||i.showLoading,label:i.t("files_downloadlimit","Set default download limit"),type:"number",min:"1","helper-text":i.helperText,error:!!i.helperText,success:i.showSuccess},null,8,["modelValue","disabled","label","helper-text","error","success"]),[[m,i.enableDefaultLimit]]),n(N("div",R,null,512),[[m,!i.enableDefaultLimit]])]),_:1},8,["name","description"])}const q=y(A,[["render",U],["__scopeId","data-v-e84629db"]]);V(q).mount("#admin-download-limit");
//# sourceMappingURL=files_downloadlimit-admin.mjs.map
