1import{$ as g,D as V,r,E as w,h as R,w as o,V as _,o as C,a as i,b as P,H as h,j as y,k as d,g as u,s as D,d as T,e as v,x as A,aa as k}from"./index-4ZVuW2C5.js";import{V as B}from"./VAlert-DRe0XMqX.js";async function E(){const{data:n}=await g.get("/admin/notifications/retention");return n}async function j(n){const{data:s}=await g.put("/admin/notifications/retention",{retentionDays:n});return s}async function $(){const{data:n}=await g.post("/admin/notifications/purge/all");return n}function m(n,s){var a,l;return typeof((l=(a=n==null?void 0:n.response)==null?void 0:a.data)==null?void 0:l.message)=="string"?n.response.data.message:typeof(n==null?void 0:n.message)=="string"?n.message:s}const M={class:"d-flex justify-end"},H={__name:"AdminNotificationRetentionPage",setup(n){const s=V(),a=r(360),l=r(360),c=r(!1),f=r(!1);async function p(){try{const t=await E();a.value=Number((t==null?void 0:t.retentionDays)||360),l.value=Number((t==null?void 0:t.maxRetentionDays)||360)}catch(t){s.error(m(t,"Error loading notification retention settings."))}}async function b(){if(!Number.isInteger(a.value)||a.value<1||a.value>l.value){s.error(`Retention must be a whole number between 1 and ${l.value}.`);return}c.value=!0;try{const t=await j(a.value);a.value=Number((t==null?void 0:t.retentionDays)||a.value),l.value=Number((t==null?void 0:t.maxRetentionDays)||l.value),s.success("Notification retention saved.")}catch(t){s.error(m(t,"Error saving notification retention settings."))}finally{c.value=!1}}async function N(){if(window.confirm("Purge all notifications from the database? This action cannot be undone.")){f.value=!0;try{const e=await $();s.success(`Purged ${Number((e==null?void 0:e.deletedCount)||0)} notifications from the system.`)}catch(e){s.error(m(e,"Error purging notifications."))}finally{f.value=!1}}}return w(async()=>{await p()}),(t,e)=>(C(),R(_,null,{default:o(()=>[i(P,null,{default:o(()=>[i(h,{class:"d-flex align-center justify-space-between"},{default:o(()=>[e[2]||(e[2]=y("span",{class:"text-h5"},"Notification Retention Settings",-1)),i(d,{variant:"text",to:{name:"admin_notifications"}},{default:o(()=>[...e[1]||(e[1]=[u(" Back To Notifications ",-1)])]),_:1})]),_:1}),i(D,null,{default:o(()=>[i(T,{dense:""},{default:o(()=>[i(v,{cols:"12",md:"6"},{default:o(()=>[i(A,{modelValue:a.value,"onUpdate:modelValue":e[0]||(e[0]=x=>a.value=x),modelModifiers:{number:!0},type:"number",min:1,max:l.value,label:"Retention (days)",hint:"Notifications older than this value are physically deleted by retention cleanup.","persistent-hint":""},null,8,["modelValue","max"])]),_:1}),i(v,{cols:"12",md:"6",class:"d-flex align-center justify-end ga-2"},{default:o(()=>[i(d,{color:"primary",loading:c.value,onClick:b},{default:o(()=>[...e[3]||(e[3]=[u(" Save Retention ",-1)])]),_:1},8,["loading"])]),_:1})]),_:1}),i(k,{class:"my-6"}),i(B,{type:"warning",variant:"tonal",class:"mb-4"},{default:o(()=>[...e[4]||(e[4]=[u(" Purging physically deletes rows from the notifications table. This cannot be undone. ",-1)])]),_:1}),y("div",M,[i(d,{color:"error",variant:"outlined",loading:f.value,onClick:N},{default:o(()=>[...e[5]||(e[5]=[u(" Purge All Notifications ",-1)])]),_:1},8,["loading"])])]),_:1})]),_:1})]),_:1}))}};export{H as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.