import{b as o,s as a}from"./index-BxIwIJfy.js";import{a as i}from"./vue-core-Di3IuVqe.js";function h(){const s=i({societes:[],lignes:{},totaux:{}}),n=i([]),r=i(!1);async function l(){const e=await o.get(`${a.lienApi}/cockpit/config/${a.state.dbCommun6}`);return n.value=(e.data||[]).map(t=>t.code_kpi),n.value}async function f(e){await o.post(`${a.lienApi}/cockpit/config/${a.state.dbCommun6}`,{codes:e}),n.value=[...e]}const u=i({societes:[],totaux:{reel:0,theorique:0,previsionnel:0,previsionnel_horizon:0}}),c=i(!1);async function p(e=0){c.value=!0;try{const t=await o.post(`${a.lienApi}/cockpit/situation-bancaire/${a.state.dbCommun6}`,{horizon:e});u.value=t.data||{societes:[],totaux:{reel:0,theorique:0,previsionnel:0,previsionnel_horizon:0}}}finally{c.value=!1}}async function m(e,t){if(!Array.isArray(e)||e.length===0){s.value={societes:[],lignes:{},totaux:{}};return}r.value=!0;try{const g=await o.post(`${a.lienApi}/cockpit/matrice/${a.state.dbCommun6}`,{codes:e,params:{annee_fiscale:t||a.state.annee_fiscale}});s.value=g.data||{societes:[],lignes:{},totaux:{}}}finally{r.value=!1}}return{matrice:s,config:n,loading:r,chargerConfig:l,sauverConfig:f,chargerMatrice:m,situationBancaire:u,loadingBanques:c,chargerSituationBancaire:p}}export{h as u};
