1import{aP as u,aH as a}from"./index-CpeGhXo5.js";const d=u((c,r)=>({subscriptions:[],fetchSubscriptions:async()=>{try{const i=await a.get("/sysadmin/subscriptions");c({subscriptions:i.data||[]})}catch(i){console.error(i)}},addSubscription:async i=>{try{const s=await a.post("/sysadmin/subscriptions",i);c({subscriptions:[s.data,...r().subscriptions]})}catch(s){console.error("API failed, falling back to local state",s),c({subscriptions:[i,...r().subscriptions]})}},updateSubscription:async(i,s)=>{try{const n=await a.patch(`/sysadmin/subscriptions/${i}`,s);c({subscriptions:r().subscriptions.map(t=>t.id===i?n.data:t)})}catch(n){console.error("API failed, falling back to local state",n),c({subscriptions:r().subscriptions.map(t=>t.id===i?{...t,...s}:t)})}},renewSubscription:async(i,s)=>{try{const n=await a.post(`/sysadmin/subscriptions/${i}/renew`,s);c({subscriptions:r().subscriptions.map(t=>t.id===i?n.data:t)})}catch(n){console.error("Renew API failed, falling back to local state",n);const t=r().subscriptions.find(o=>o.id===i);if(t){const o=new Date().toISOString().split("T")[0],p=[{id:`REN-${Date.now()}`,renewedAt:o,renewedBy:s.renewedBy||"System Admin",cost:s.cost!==void 0?s.cost:t.cost,currency:s.currency||t.currency,billingCycle:s.billingCycle||t.billingCycle,previousRenewalDate:t.renew
1alDate,newRenewalDate:s.renewalDate,notes:s.notes||"Renewed subscription"},...t.renewalHistory||[]],l={...t,renewalCount:(t.renewalCount||0)+1,renewalHistory:p,renewalDate:s.renewalDate,status:"Active",lastUpdated:o,cost:s.cost!==void 0?s.cost:t.cost};c({subscriptions:r().subscriptions.map(e=>e.id===i?l:e)})}}},deleteSubscription:async i=>{try{await a.delete(`/sysadmin/subscriptions/${i}`),c({subscriptions:r().subscriptions.filter(s=>s.id!==i)})}catch(s){console.error("API failed, falling back to local state",s),c({subscriptions:r().subscriptions.filter(n=>n.id!==i)})}}}));export{d as u};
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.