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{i as a}from"./ctiAxios-BIVP6fGU.js";import{H as o}from"./notification-C7Dk1wtU.js";import{t as s}from"./button-C7b7AmGo.js";import{i as c}from"./select-CfH7keFL.js";import{t as l}from"./CopyOutlined-CPvzHTe5.js";import{t as u}from"./queryOptions-Cg9orY1Y.js";import{F as d}from"./index-BqyXv5bE.js";import{b as f}from"./CancelButton-n0hR8wBD.js";var p=async e=>f(await a(`modules/base/php/getIndicateurs.php`,{softCode:e}));async function m(e,t){await a(`modules/base/php/setIndicateur.php`,{action:`save`,softCode:e,...t})}async function h(e,t){await a(`modules/base/php/setIndicateur.php`,{action:`delete`,softCode:e,oid:t})}async function g(e,t){await a(`modules/base/php/setIndicateur.php`,{action:`copy`,softCode:e,oid:t})}var _={all:[`indicators`],list:e=>[..._.all,`list`,e]},v={indicators:[],tables:[],themesSearch:[],themes:[]},y=e=>u({queryKey:_.list(e),queryFn:()=>p(e),enabled:!!e}),b=e=>i(y(e)),x=e=>{let t=[{value:`*LIST`,title:`Pas de fonction total`},{value:`Sommes`,title:`Sommes`,disabled:!0,children:[{title:`Somme`,value:`SUM`},{title:`Somme du dernier mois`,value:`SUMLASTMONTH`},{title:`Somme du premier mois`,value:`SUMFIRSTMONTH`},{title:`Somme distincte`,value:`base.cti_sum_distinct_on`}]},{value:`Bornes`,title:`Bornes`,disabled:!0,children:[{title:`Minimum`,value:`MIN`},{title:`Maximum`,value:`MAX`}]},{value:`Moyennes`,title:`Moyennes`,disabled:!0,children:[{title:`Moyenne`,value:`AVG`},{title:`Moyenne sur 12 mois`,value:`AVG12M`}]},{value:`Comptage`,title:`Comptage`,disabled:!0,children:[{title:`Comptage`,value:`COUNT`},{title:`Comptage du dernier mois`,value:`COUNTLASTMONTH`}]},{value:`Texte`,title:`Texte`,disabled:!0,children:[{title:`Aggrégation des valeurs`,value:`LISTACUM`}]}];return e===`eis`&&t.filter(e=>e.value===`Texte`)[0].children.push({title:`AGGVAL`,data:`AGGVAL`}),t},S=[{title:`Pas de fonction total`,value:`AGGVAL`},{title:`Pas de fonction total`,value:`*LIST`},{title:`Somme`,value:`SUM`},{title:`Somme du dernier mois`,value:`SUMLASTMONTH`},{title:`Somme du premier mois`,value:`SUMFIRSTMONTH`},{title:`Somme distincte`,value:`base.cti_sum_distinct_on`},{title:`Minimum`,value:`MIN`},{title:`Maximum`,value:`MAX`},{title:`Moyenne`,value:`AVG`},{title:`Moyenne sur 12 mois`,value:`AVG12M`},{title:`Comptage`,value:`COUNT`},{title:`Comptage du dernier mois`,value:`COUNTLASTMONTH`},{title:`Aggrégation des valeurs`,value:`LISTACUM`},{title:`Calcul entre indicateurs`,value:`*CALC`}],C=(e,t)=>{let n={},r=[];for(let[t,r]of Object.entries(e))/indicateur_associe_[\d]*_id/.test(t)&&r!==`0`&&(n[t]=r);if(n){let e=Object.values(n).map(e=>t?.indicators.find(t=>t.oid===e));e.forEach(e=>{for(let[t,r]of Object.entries(n))if(r===e?.oid){let n=t.match(/\d+/g);e.associatedIndicatorIndex=Number(n[0])}}),r=e}return r},w=e(r()),T=e(t()),E=n(),D=({copiedText:e,size:t=`default`,type:n=`primary`,tooltip:r=`Copier`,style:i})=>{let[a,u]=(0,T.useState)(!1);return(0,E.jsx)(E.Fragment,{children:(0,E.jsx)(d,{title:`Copier`,children:(0,E.jsx)(s,{style:i,size:t,type:n,icon:a?(0,E.jsx)(c,{style:{color:o.green}}):(0,E.jsx)(l,{}),onClick:()=>{u(!a),navigator.clipboard.writeText(e)}})})})};D.propTypes={copiedText:w.default.string,size:w.default.string,type:w.default.string,tooltip:w.default.string};export{v as a,g as c,x as i,h as l,C as n,b as o,S as r,_ as s,D as t,m as u};