import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{n as r}from"./axios-v6FV69Ne.js";import{d as i}from"./ctiAxios-BIVP6fGU.js";import{t as a}from"./button-C7b7AmGo.js";import{$ as o,B as s,H as c,I as l,Q as u,_ as d,ht as f,z as p}from"./index-BqyXv5bE.js";import{t as m}from"./logs.queries-BiWc7Zaz.js";var h=e(t()),g=e(i()),_=e(r()),v=n(),y=({status:e,env:t,provider:n,module:r,duration:i,start:a,running:o})=>{let c=l().data,u=window.location,d=u.origin,f=u.pathname.replace(c?.environment?.ICTIDIR??``,`iCTI_${t.code}`),p=``,m=``;switch(e){case 0:p=`rgb(240, 255, 241)`,m=`3px solid rgb(124, 217, 146)`;break;case 1:p=`rgb(254, 255, 240)`,m=`3px solid rgb(247, 228, 99)`;break;case 2:p=`rgb(255, 242, 240)`,m=`3px solid rgb(235, 96, 96)`;break;case-1:p=`rgb(211,211,211)`,m=`3px solid rgb(122, 122, 122)`;break;default:break}return(0,v.jsx)(`a`,{href:d+f,target:`_blank`,rel:`noreferrer`,children:(0,v.jsxs)(`div`,{className:`exploit-env`,style:{backgroundColor:p,border:m},children:[(0,v.jsxs)(`div`,{className:`exploit-label`,children:[o===1&&(0,v.jsx)(s,{className:`exploit__icon`,spin:!0}),r??`${t.code} - ${t.trig&&t.trig!==``?t.trig+` - `:``}${t.comment}`]}),a&&(0,v.jsxs)(`div`,{className:`exploit-duration`,children:[`Débuté le `,(0,g.default)(a).format(`DD/MM/YYYY à HH:mm`)]}),i&&(0,v.jsxs)(`div`,{className:`exploit-duration`,children:[`Durée: `,i]}),(0,v.jsx)(`div`,{className:`exploit-provider`,children:n})]},r||t.code)})};y.propTypes={status:_.default.number,env:_.default.object,provider:_.default.string,module:_.default.string,duration:_.default.string,start:_.default.string,running:_.default.number};var b={iCTI_activite:`ADMPROVIDER`,iCTI_pmsi:`PMSIPROVIDER`,iCTI_pmsipsy:`PMSIPSYPROVIDER`,iCTI_pmsihad:`PMSIHADPROVIDER`,iCTI_pmsissr:`PMSISSRPROVIDER`,iCTI_rh:`RHPROVIDER`,iCTI_compta:`COMPTAPROVIDER`,iCTI_eco:`ECOPROVIDER`,iCTI_dpi:`DPIPROVIDER`},x=()=>{let e=m(),t=l(),n=e.data?.envs??[],r=e.data?.timestamp,i=t.data,[s,_]=(0,h.useState)([`Synthèse`]),[x,S]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(n.length){let e=[];n.forEach(t=>{t.jobs.forEach(t=>{let n=``;switch(t.job){case`iCTI_consolidation_pmsi`:n=`iCTI_pmsi`;break;case`iCTI_import_activite_consolidation`:n=`iCTI_activite`;break;default:n=t.job.replace(/iCTI_(import_)?/,``);break}d[n]&&!e.includes(n)&&e.push(n)})}),_(e)}},[n]);let C=()=>{e.refetch()},w=e=>n.filter(t=>t.jobs.some(t=>e===`rss_rsf_en_cours`&&t.job.includes(`pmsi`)?!0:t.job.includes(e))).sort((e,t)=>e.code.localeCompare(t.code)).map(t=>{let n=t.jobs.find(t=>e===`rss_rsf`?t.job.includes(e)&&!t.job.includes(`en_cours`):e===`rss_rsf_en_cours`&&t.job.includes(`pmsi`)?!0:t.job.includes(e));if(n){let r=n.status,i=n.running;return(0,v.jsx)(y,{status:r,running:i,env:t,provider:Object.keys(t.settings).length?t.settings[b[d[e].module]]:``,duration:n.duration,start:n.start},t.code)}else return null});return!e.isFetching&&!i?.environment?.ISEXPLOIT?(0,v.jsx)(o,{icon:(0,v.jsx)(p,{}),title:`Cette fonctionnalité n'est pas encore disponible sur votre serveur.`}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`component-header`,children:[(0,v.jsxs)(`div`,{className:`header-title`,children:[i?.environment?.ISEXPLOIT===`1`?`Résumé Exploitation Serveur `:`Résumé Exploitation `,`(dernière mise à jour: `,(0,g.default)(r).format(`HH:mm`),`)`]}),(0,v.jsxs)(`div`,{className:`header-actions`,children:[(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`actions-label`,children:`Afficher les jobs CTI:`}),(0,v.jsx)(u,{checked:x,onChange:e=>S(e)})]}),(0,v.jsx)(a,{onClick:C,type:`primary`,loading:e.isFetching,disabled:e.isFetching,icon:(0,v.jsx)(c,{}),children:`Rafraichir`})]})]}),(0,v.jsx)(`div`,{className:`component-content`,children:(0,v.jsx)(f,{items:[{label:`Synthèse`,key:`total`,children:(0,v.jsx)(`div`,{className:`exploit-module`,children:(e=>{if(e)return n.sort((e,t)=>e.code.localeCompare(t.code)).map(e=>(0,v.jsx)(y,{status:e.jobs.map(e=>e.status).includes(-1)?-1:e.jobs.reduce((e,t)=>(x||d[t.module])&&t.status>e?t.status:e,0),running:0,env:e,provider:``},e.code));{let e=n.find(e=>e.code===i?.environment?.ICTIDIR?.replace(`iCTI_`,``));if(e)return e.jobs.map(t=>{let n=t.module===t.job?t.job.replace(/iCTI_(import_)?/,``):t.module,r=Object.keys(e.settings).length&&d[t.module]?e.settings[b[d[t.module].module]]:null;return x||d[n]?(0,v.jsx)(y,{status:t.status,running:t.running,env:e,provider:r,duration:t.duration,start:t.start,module:d[n]?d[n].label:n},t.job):null})}})(i?.environment?.ISEXPLOIT===`1`)})},{tabsItems:()=>{let e=[];return i?.environment?.ISEXPLOIT===`1`&&(e=s.map(e=>({label:d[e]?.label??e,key:e,children:(0,v.jsx)(`div`,{className:`exploit-module`,children:w(e)})}))),e}}]})})]})};export{x as default};