import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{n as r,r as i}from"./axios-v6FV69Ne.js";import{t as a}from"./UndoOutlined-2WspCEN7.js";import{N as o}from"./index-BqyXv5bE.js";import{t as s}from"./BaseActionButton-BmPZtLSb.js";var c=async()=>(await o.get(`/api/rh/paie/ventilations/eligible-salaries`)).data,l=async e=>(await o.get(`/api/rh/paie/ventilations/${e}/settings`)).data,u=async(e,t)=>(await o.put(`/api/rh/paie/ventilations/${e}/settings`,t)).data,d={all:[`salarieVentilation`],list:()=>[...d.all,`list`],detail:e=>[...d.all,e]},f=[`janvier`,`fevrier`,`mars`,`avril`,`mai`,`juin`,`juillet`,`aout`,`septembre`,`octobre`,`novembre`,`decembre`];function p(e,t){return e.filter(e=>{for(let n in t)if(t[n]?.length>0&&!t[n].includes(e[n]))return!1;return!0})}function m(e,t){return p(e,t).map(e=>e.salarie_id)}var h=e=>{let t=e?.ventilations??[],n=e=>`Etablissement ${e}`,r=t.reduce((e,t)=>{let{yearNumber:r,etablissementId:i,monthName:a,ratio:o,etablissementVentilation:s}=t;return e[r]||(e[r]={}),e[r][i]||(e[r][i]={key:i,etablissement_id:i,label:s||n(i)},f.forEach(t=>{e[r][i][`ratio_${t}`]=null})),e[r][i][`ratio_${a}`]=o,e},{}),i={};for(let e in r)i[e]=Object.values(r[e]);return i};function g(e,t){return Number(e)!==Number(t)}function _(e,t){for(let[n,r]of Object.entries(e)){if(!n.startsWith(`ratio_`))continue;let e=t?.[n]??null;if(!(r==null&&e==null)&&g(r,e))return!0}return!1}var v=(e,t)=>{let n=[],r=t.salarie_id;for(let[t,i]of Object.entries(e))i.forEach(e=>{f.forEach(i=>{let a=`ratio_${i}`;e.hasOwnProperty(a)&&(n=[...n,{yearNumber:Number(t),monthName:i,salarieId:r,etablissementId:e.etablissement_id,etablissementVentilation:e.label??`Non renseigné`,ratio:e[a]??0}])})});return{infos:t,ventilations:n}},y=(e=[])=>i({queryKey:d.list(),queryFn:c,select:t=>e.length>0?t.filter(({salarie_id:t})=>e.includes(t)):t}),b=e=>i({queryKey:d.detail(e),queryFn:()=>l(e),select:e=>({ventilationByYear:h(e),salarieInfo:e.infos})});t();var x=e(r()),S=n(),C=({children:e=`Réinitialiser`,...t})=>(0,S.jsx)(s,{icon:(0,S.jsx)(a,{}),confirmTitle:`Confirmez-vous la réinitialisation ?`,okText:`Réinitialiser`,...t,children:e});C.propTypes={children:x.default.node};export{p as a,g as c,u as d,f as i,v as l,b as n,m as o,y as r,_ as s,C as t,d as u};