apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-extension-files
  namespace: kube-infra
  labels:
    app.kubernetes.io/name: argocd-applicationset-extension
    app.kubernetes.io/component: ui-extension
    app.kubernetes.io/part-of: argocd
data:
  extension.js: |
    var modernArgocdAppsetExtension=function(e){"use strict";function t(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var n=t(e);!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&a.firstChild?a.insertBefore(i,a.firstChild):a.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}('.application-set-extension{background-color:transparent;color:#495763;font-family:Heebo,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;line-height:1.5;padding:0}.white-box{background-color:transparent;border-radius:0;box-shadow:none}.white-box__details{padding:0}.application-set-extension__header{border-bottom:1px solid #dee6eb;margin-bottom:1.25rem;padding-bottom:1rem}.application-set-extension__title{color:#495763;font-size:1.125rem;font-weight:600;letter-spacing:-.01em;margin:0}.application-set-extension__error{background-color:#f8fbfb;border:1px solid #e96d76;border-radius:4px;color:#e96d76;margin-bottom:1rem;padding:.5rem}.application-set-extension__stats{background-color:transparent;border:1px solid #dee6eb;border-radius:4px;display:grid;gap:0;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));margin-bottom:1.5rem;overflow:hidden;padding:0}.application-set-extension__stat{align-items:center;background-color:#fff;border-right:1px solid #dee6eb;display:flex;flex-direction:column;justify-content:center;min-height:75px;padding:1rem;transition:background-color .15s ease}.application-set-extension__stat:last-child{border-right:none}.application-set-extension__stat:hover{background-color:#f8fbfb}.application-set-extension__stat-label{color:#6d7f8b;font-size:.6875rem;font-weight:600;letter-spacing:.08em;margin-bottom:.375rem;text-transform:uppercase}.application-set-extension__stat-value{color:#495763;font-size:1.625rem;font-weight:600;line-height:1}.application-set-extension__stat-value--healthy{color:#18be94}.application-set-extension__stat-value--progressing{color:#1fbdd0}.application-set-extension__stat-value--degraded{color:#e96d76}.application-set-extension__stat-value--suspended,.application-set-extension__stat-value--unknown{color:#8fa4b1}.application-set-extension__filters{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:1rem}.application-set-extension__filter{background-color:#eff3f5;border:1px solid #ccd6dd;border-radius:4px;color:#495763;cursor:pointer;font-size:.85rem;padding:.25rem .75rem;transition:all .2s ease}.application-set-extension__filter:hover{background-color:#dee6eb}.application-set-extension__filter--active{background-color:#1fbdd0;border-color:#1fbdd0;color:#fff}.application-set-extension__table{background-color:#fff;border:1px solid #dee6eb;border-collapse:separate;border-radius:4px;border-spacing:0;overflow:hidden;width:100%}.application-set-extension__table td,.application-set-extension__table th{border-bottom:1px solid #dee6eb;padding:.875rem 1rem;text-align:left}.application-set-extension__table tbody tr:last-child td{border-bottom:none}.application-set-extension__table tbody tr{transition:background-color .15s ease}.application-set-extension__table tbody tr:hover{background-color:#f8fbfb}.application-set-extension__table th{background-color:#f8fbfb;border-bottom:2px solid #dee6eb;color:#495763;font-size:.75rem;font-weight:600;letter-spacing:.08em;text-transform:uppercase}.application-set-extension__table a{color:#1fbdd0;text-decoration:none}.application-set-extension__table a:hover{color:#00a2b3;text-decoration:underline}.application-set-extension__health{align-items:center;border-radius:3px;display:inline-flex;font-size:.6875rem;font-weight:600;letter-spacing:.05em;padding:.3125rem .625rem;text-transform:uppercase}.application-set-extension__health--healthy{background-color:rgba(24,190,148,.1);color:#18be94}.application-set-extension__health--progressing{background-color:rgba(31,189,208,.1);color:#1fbdd0}.application-set-extension__health--degraded{background-color:rgba(233,109,118,.1);color:#e96d76}.application-set-extension__health--suspended,.application-set-extension__health--unknown{background-color:rgba(143,164,177,.1);color:#8fa4b1}.application-set-extension__sync{align-items:center;border-radius:3px;display:inline-flex;font-size:.6875rem;font-weight:600;letter-spacing:.05em;padding:.3125rem .625rem;text-transform:uppercase}.application-set-extension__sync--synced{background-color:rgba(24,190,148,.1);color:#18be94}.application-set-extension__sync--out-of-sync{background-color:rgba(233,109,118,.1);color:#e96d76}.application-set-extension__sync--unknown{background-color:rgba(143,164,177,.1);color:#8fa4b1}.application-set-extension__actions{display:flex;gap:.5rem;justify-content:flex-end}.application-set-extension__action-button{background-color:#fff;border:1px solid #ccd6dd;border-radius:4px;color:#495763;cursor:pointer;font-size:.85rem;padding:.25rem .5rem;transition:all .2s ease}.application-set-extension__action-button:hover{background-color:#eff3f5}.application-set-extension__action-button--primary{background-color:#1fbdd0;border-color:#1fbdd0;color:#fff}.application-set-extension__action-button--primary:hover{background-color:#00a2b3}.application-set-extension__loading{align-items:center;color:#6d7f8b;display:flex;justify-content:center;padding:2rem}.application-set-extension__empty{color:#6d7f8b;padding:2rem;text-align:center}.application-set-extension__header{flex-wrap:wrap;justify-content:space-between;margin-bottom:1.5rem}.application-set-extension__header,.application-set-extension__header-actions{align-items:center;display:flex;gap:1rem}.application-set-extension__bulk-actions{align-items:center;display:flex;gap:.5rem}.application-set-extension__bulk-button{align-items:center;border:1px solid transparent;border-radius:3px;cursor:pointer;display:inline-flex;font-size:.8125rem;font-weight:500;gap:.375rem;height:34px;padding:.5rem 1rem;transition:all .15s ease}.application-set-extension__bulk-button:disabled{cursor:not-allowed;opacity:.5}.application-set-extension__bulk-button--sync{background-color:#1fbdd0;color:#fff}.application-set-extension__bulk-button--sync:hover:not(:disabled){background-color:#00a2b3}.application-set-extension__bulk-button--refresh{background-color:#8fa4b1;color:#fff}.application-set-extension__bulk-button--refresh:hover:not(:disabled){background-color:#6d7f8b}.application-set-extension__progress{align-items:center;display:flex;font-size:.875rem;gap:.5rem}.application-set-extension__progress-bar{background-color:#dee6eb;border-radius:2px;height:4px;overflow:hidden;width:100px}.application-set-extension__progress-fill{background-color:#1fbdd0;height:100%;transition:width .3s ease}.application-set-extension__controls{margin-bottom:1rem}.application-set-extension__search{max-width:400px;position:relative}.application-set-extension__search-input{background-color:#fff;border:1px solid #dee6eb;border-radius:3px;color:#495763;font-size:.875rem;height:38px;padding:.5625rem 2.5rem .5625rem 1rem;transition:all .15s ease;width:100%}.application-set-extension__search-input:focus{border-color:#1fbdd0;box-shadow:0 0 0 3px rgba(31,189,208,.1);outline:none}.application-set-extension__search-input::placeholder{color:#8fa4b1}.application-set-extension__search-clear{background:none;border:none;color:#8fa4b1;cursor:pointer;font-size:1rem;padding:.25rem;position:absolute;right:.5rem;top:50%;transform:translateY(-50%)}.application-set-extension__search-clear:hover{color:#6d7f8b}.application-set-extension__timeline{background-color:#f8fbfb;border:1px solid #dee6eb;border-radius:4px;margin-top:2rem;padding:1.5rem}.application-set-extension__timeline-title{color:#495763;font-size:.8125rem;font-weight:600;letter-spacing:.08em;margin:0 0 1.25rem;text-transform:uppercase}.application-set-extension__timeline-empty{color:#6d7f8b;padding:2rem;text-align:center}.application-set-extension__timeline-list{list-style:none;margin:0;padding:0}.application-set-extension__timeline-item{align-items:flex-start;display:flex;gap:1rem;padding:.75rem 0;position:relative}.application-set-extension__timeline-item:not(:last-child):before{background-color:#ccd6dd;bottom:-.75rem;content:"";left:5px;position:absolute;top:2rem;width:2px}.application-set-extension__timeline-marker{background-color:#1fbdd0;border-radius:50%;flex-shrink:0;height:12px;margin-top:.25rem;width:12px}.application-set-extension__timeline-content{flex:1}.application-set-extension__timeline-header{align-items:center;display:flex;justify-content:space-between;margin-bottom:.25rem}.application-set-extension__timeline-status{border-radius:12px;font-size:.75rem;font-weight:500;padding:.125rem .5rem}.application-set-extension__timeline-status--succeeded{background-color:rgba(24,190,148,.1);color:#18be94}.application-set-extension__timeline-status--failed{background-color:rgba(233,109,118,.1);color:#e96d76}.application-set-extension__timeline-status--running{background-color:rgba(31,189,208,.1);color:#1fbdd0}.application-set-extension__timeline-time{color:#6d7f8b;font-size:.875rem}.application-set-extension__timeline-message{color:#495763;font-size:.875rem;margin-top:.5rem}');const a=({onSearch:e,placeholder:t="Rechercher une application..."})=>{const[a,i]=n.useState("");return n.createElement("div",{className:"application-set-extension__search"},n.createElement("input",{type:"text",value:a,onChange:t=>{const n=t.target.value;i(n),e(n)},placeholder:t,className:"application-set-extension__search-input"}),a&&n.createElement("button",{onClick:()=>{i(""),e("")},className:"application-set-extension__search-clear","aria-label":"Effacer la recherche"},"✕"))},i=({applications:e,isLoading:t,error:i})=>{const[o,s]=n.useState(null),[r,l]=n.useState(""),c=n.useMemo((()=>{let t=e;return r&&(t=t.filter((e=>e.metadata.name.toLowerCase().includes(r.toLowerCase())||e.spec.destination.namespace.toLowerCase().includes(r.toLowerCase())||e.spec.destination.server&&e.spec.destination.server.toLowerCase().includes(r.toLowerCase())))),"healthy"===o?t=t.filter((e=>{var t,n;return"Healthy"===(null===(n=null===(t=e.status)||void 0===t?void 0:t.health)||void 0===n?void 0:n.status)})):"progressing"===o?t=t.filter((e=>{var t,n;return"Progressing"===(null===(n=null===(t=e.status)||void 0===t?void 0:t.health)||void 0===n?void 0:n.status)})):"degraded"===o?t=t.filter((e=>{var t,n;return"Degraded"===(null===(n=null===(t=e.status)||void 0===t?void 0:t.health)||void 0===n?void 0:n.status)})):"outOfSync"===o&&(t=t.filter((e=>{var t,n;return"OutOfSync"===(null===(n=null===(t=e.status)||void 0===t?void 0:t.sync)||void 0===n?void 0:n.status)}))),t}),[e,o,r]);return t?n.createElement("div",{className:"application-set-extension__loading"},"Chargement des applications..."):i?n.createElement("div",{className:"application-set-extension__error"},"Erreur lors du chargement des applications: ",i):0===e.length?n.createElement("div",{className:"application-set-extension__empty"},"Aucune application trouvée pour cet ApplicationSet."):n.createElement("div",null,n.createElement("div",{className:"application-set-extension__controls"},n.createElement(a,{onSearch:l,placeholder:"Rechercher par nom, namespace ou cluster..."})),n.createElement("div",{className:"application-set-extension__filters"},n.createElement("button",{className:"application-set-extension__filter "+(o?"":"application-set-extension__filter--active"),onClick:()=>s(null)},"Tous"),n.createElement("button",{className:"application-set-extension__filter "+("healthy"===o?"application-set-extension__filter--active":""),onClick:()=>s("healthy")},"Healthy"),n.createElement("button",{className:"application-set-extension__filter "+("progressing"===o?"application-set-extension__filter--active":""),onClick:()=>s("progressing")},"Progressing"),n.createElement("button",{className:"application-set-extension__filter "+("degraded"===o?"application-set-extension__filter--active":""),onClick:()=>s("degraded")},"Degraded"),n.createElement("button",{className:"application-set-extension__filter "+("outOfSync"===o?"application-set-extension__filter--active":""),onClick:()=>s("outOfSync")},"Out of Sync")),n.createElement("table",{className:"application-set-extension__table"},n.createElement("thead",null,n.createElement("tr",null,n.createElement("th",null,"Nom"),n.createElement("th",null,"Namespace"),n.createElement("th",null,"Cluster"),n.createElement("th",null,"Sync Status"),n.createElement("th",null,"Health Status"),n.createElement("th",null,"Actions"))),n.createElement("tbody",null,c.map((e=>{var t,a,i,o,s,r,l,c,p,d;return n.createElement("tr",{key:e.metadata.name},n.createElement("td",null,n.createElement("a",{href:`/applications/${e.metadata.name}`,target:"_blank",rel:"noopener noreferrer"},e.metadata.name)),n.createElement("td",null,e.spec.destination.namespace),n.createElement("td",null,e.spec.destination.name||e.spec.destination.server),n.createElement("td",null,n.createElement("div",{className:"application-set-extension__sync application-set-extension__sync--"+("Synced"===(null===(a=null===(t=e.status)||void 0===t?void 0:t.sync)||void 0===a?void 0:a.status)?"synced":"OutOfSync"===(null===(o=null===(i=e.status)||void 0===i?void 0:i.sync)||void 0===o?void 0:o.status)?"out-of-sync":"unknown")},(null===(r=null===(s=e.status)||void 0===s?void 0:s.sync)||void 0===r?void 0:r.status)||"Unknown")),n.createElement("td",null,n.createElement("div",{className:`application-set-extension__health application-set-extension__health--${((null===(c=null===(l=e.status)||void 0===l?void 0:l.health)||void 0===c?void 0:c.status)||"unknown").toLowerCase()}`},(null===(d=null===(p=e.status)||void 0===p?void 0:p.health)||void 0===d?void 0:d.status)||"Unknown")),n.createElement("td",null,n.createElement("div",{className:"application-set-extension__actions"},n.createElement("button",{className:"application-set-extension__action-button",onClick:()=>window.open(`/applications/${e.metadata.name}?view=tree`,"_blank")},"Voir"),n.createElement("button",{className:"application-set-extension__action-button application-set-extension__action-button--primary",onClick:()=>window.open(`/applications/${e.metadata.name}?operation=sync`,"_blank")},"Sync"))))})))))},o=({total:e,healthy:t,degraded:a,progressing:i,unknown:o})=>{if(0===e)return null;const s=t/e*100,r=a/e*100,l=i/e*100,c=o/e*100;return n.createElement("div",{style:{display:"flex",height:"8px",width:"100%",borderRadius:"4px",overflow:"hidden",marginBottom:"1.5rem"}},t>0&&n.createElement("div",{style:{width:`${s}%`,backgroundColor:"#18be94"}}),i>0&&n.createElement("div",{style:{width:`${l}%`,backgroundColor:"#1fbdd0"}}),a>0&&n.createElement("div",{style:{width:`${r}%`,backgroundColor:"#e96d76"}}),o>0&&n.createElement("div",{style:{width:`${c}%`,backgroundColor:"#8fa4b1"}}))},s="/api/v1",r=async(e,t={prune:!0,dryRun:!1})=>{try{const n=await fetch(`${s}/applications/${e}/sync`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:t.dryRun,prune:t.prune,strategy:{apply:{force:!1}}})});if(!n.ok)throw new Error(`Erreur lors de la synchronisation de l'application: ${n.statusText}`);return{success:!0,data:await n.json()}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Une erreur inconnue est survenue"}}},l=async(e,t=!1)=>{try{const n=await fetch(`${s}/applications/${e}/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hardRefresh:t})});if(!n.ok)throw new Error(`Erreur lors du rafraîchissement de l'application: ${n.statusText}`);return{success:!0,data:await n.json()}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Une erreur inconnue est survenue"}}},c=e=>{const[t,a]=n.useState([]),[i,o]=n.useState(!0),[r,l]=n.useState(null),c=n.useMemo((()=>t.reduce(((e,t)=>{var n,a,i,o;const s=(null===(a=null===(n=t.status)||void 0===n?void 0:n.health)||void 0===a?void 0:a.status)||"Unknown";e[s]=(e[s]||0)+1;const r=(null===(o=null===(i=t.status)||void 0===i?void 0:i.sync)||void 0===o?void 0:o.status)||"Unknown";return"Synced"===r?e.Synced=(e.Synced||0)+1:"OutOfSync"===r&&(e.OutOfSync=(e.OutOfSync||0)+1),e.total+=1,e}),{total:0,Healthy:0,Progressing:0,Degraded:0,Suspended:0,Missing:0,Unknown:0,Synced:0,OutOfSync:0})),[t]);return n.useEffect((()=>{const t=async()=>{try{o(!0),l(null);const t=await(async e=>{var t;try{const n=await fetch(`${s}/applicationsets/${e}`);if(!n.ok)throw new Error(`Erreur lors de la récupération de l'ApplicationSet: ${n.statusText}`);const a=((null===(t=(await n.json()).status)||void 0===t?void 0:t.resources)||[]).filter((e=>"Application"===e.kind)).map((e=>e.name));if(0===a.length)return{success:!0,data:[]};const i=await fetch(`${s}/applications`);if(!i.ok)throw new Error(`Erreur lors de la récupération des applications: ${i.statusText}`);return{success:!0,data:((await i.json()).items||[]).filter((e=>a.includes(e.metadata.name)))}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Une erreur inconnue est survenue"}}})(e);if(!t.success)throw new Error(t.error||"Erreur inconnue");a(t.data||[])}catch(e){console.error("Error fetching applications:",e),l(e instanceof Error?e.message:"Une erreur inconnue est survenue")}finally{o(!1)}};t();const n=setInterval(t,3e4);return()=>clearInterval(n)}),[e]),{applications:t,stats:c,isLoading:i,error:r}},p=({applications:e,onActionComplete:t})=>{const[a,i]=n.useState(!1),[o,s]=n.useState({current:0,total:0});return n.createElement("div",{className:"application-set-extension__bulk-actions"},n.createElement("button",{className:"application-set-extension__bulk-button application-set-extension__bulk-button--sync",onClick:async()=>{if(confirm(`Synchroniser ${e.length} applications ?`)){i(!0),s({current:0,total:e.length});for(let t=0;t<e.length;t++){const n=e[t];await r(n.metadata.name),s({current:t+1,total:e.length})}i(!1),t()}},disabled:a||0===e.length},"🔄 Sync All (",e.length,")"),n.createElement("button",{className:"application-set-extension__bulk-button application-set-extension__bulk-button--refresh",onClick:async()=>{if(confirm(`Rafraîchir ${e.length} applications ?`)){i(!0),s({current:0,total:e.length});for(let t=0;t<e.length;t++){const n=e[t];await l(n.metadata.name),s({current:t+1,total:e.length})}i(!1),t()}},disabled:a||0===e.length},"🔃 Refresh All (",e.length,")"),a&&n.createElement("div",{className:"application-set-extension__progress"},n.createElement("span",null,"Traitement: ",o.current,"/",o.total),n.createElement("div",{className:"application-set-extension__progress-bar"},n.createElement("div",{className:"application-set-extension__progress-fill",style:{width:o.current/o.total*100+"%"}}))))},d=({applications:e})=>{const t=n.useMemo((()=>[...e].filter((e=>{var t,n;return null===(n=null===(t=e.status)||void 0===t?void 0:t.operationState)||void 0===n?void 0:n.finishedAt})).sort(((e,t)=>{const n=new Date(e.status.operationState.finishedAt).getTime();return new Date(t.status.operationState.finishedAt).getTime()-n})).slice(0,10)),[e]);return 0===t.length?n.createElement("div",{className:"application-set-extension__timeline-empty"},"Aucune synchronisation récente"):n.createElement("div",{className:"application-set-extension__timeline"},n.createElement("h4",{className:"application-set-extension__timeline-title"},"📅 Dernières synchronisations"),n.createElement("ul",{className:"application-set-extension__timeline-list"},t.map(((e,t)=>{var a,i,o,s,r,l,c;return n.createElement("li",{key:`${e.metadata.name}-${t}`,className:"application-set-extension__timeline-item"},n.createElement("div",{className:"application-set-extension__timeline-marker"}),n.createElement("div",{className:"application-set-extension__timeline-content"},n.createElement("div",{className:"application-set-extension__timeline-header"},n.createElement("strong",null,e.metadata.name),n.createElement("span",{className:`application-set-extension__timeline-status application-set-extension__timeline-status--${null===(o=null===(i=null===(a=e.status)||void 0===a?void 0:a.operationState)||void 0===i?void 0:i.phase)||void 0===o?void 0:o.toLowerCase()}`},null===(r=null===(s=e.status)||void 0===s?void 0:s.operationState)||void 0===r?void 0:r.phase)),n.createElement("div",{className:"application-set-extension__timeline-time"},(e=>{const t=new Date(e),n=(new Date).getTime()-t.getTime(),a=Math.floor(n/6e4),i=Math.floor(n/36e5),o=Math.floor(n/864e5);return a<1?"À l'instant":a<60?`Il y a ${a} min`:i<24?`Il y a ${i}h`:`Il y a ${o}j`})(e.status.operationState.finishedAt)),(null===(c=null===(l=e.status)||void 0===l?void 0:l.operationState)||void 0===c?void 0:c.message)&&n.createElement("div",{className:"application-set-extension__timeline-message"},e.status.operationState.message)))}))))},m=({resource:e})=>{const{applications:t,stats:a,isLoading:s,error:r}=c(e.metadata.name),[l,m]=n.useState(0);return n.createElement("div",{className:"application-set-extension"},n.createElement("div",{className:"white-box"},n.createElement("div",{className:"white-box__details"},n.createElement("div",{className:"application-set-extension__header"},n.createElement("h3",{className:"application-set-extension__title"},"Applications générées par ",e.metadata.name),n.createElement("div",{className:"application-set-extension__header-actions"},n.createElement(p,{applications:t,onActionComplete:()=>{m((e=>e+1))}}))),!s&&!r&&n.createElement("div",{className:"application-set-extension__stats"},n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Total"),n.createElement("span",{className:"application-set-extension__stat-value"},a.total)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Healthy"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--healthy"},a.Healthy)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Progressing"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--progressing"},a.Progressing)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Degraded"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--degraded"},a.Degraded)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Unknown"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--unknown"},a.Unknown)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Synced"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--healthy"},a.Synced)),n.createElement("div",{className:"application-set-extension__stat"},n.createElement("span",{className:"application-set-extension__stat-label"},"Out of Sync"),n.createElement("span",{className:"application-set-extension__stat-value application-set-extension__stat-value--degraded"},a.OutOfSync))),n.createElement(o,{total:a.total,healthy:a.Healthy,degraded:a.Degraded,progressing:a.Progressing,unknown:a.Unknown}),n.createElement(i,{applications:t,isLoading:s,error:r}),!s&&!r&&t.length>0&&n.createElement(d,{applications:t}))))},u=()=>{const[e,t]=n.useState([]),[a,i]=n.useState(!0),[o,s]=n.useState(null);return n.useEffect((()=>{(async()=>{try{i(!0),s(null);const e=await(async()=>{try{const e=await fetch("/api/v1/applicationsets");if(!e.ok)throw new Error(`Erreur lors de la récupération des ApplicationSets: ${e.statusText}`);return{success:!0,data:(await e.json()).items||[]}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Une erreur inconnue est survenue"}}})();if(!e.success)throw new Error(e.error||"Erreur inconnue");t(e.data||[])}catch(e){console.error("Error fetching ApplicationSets:",e),s(e instanceof Error?e.message:"Erreur inconnue")}finally{i(!1)}})()}),[]),a?n.createElement("div",{className:"application-set-extension"},n.createElement("div",{className:"white-box"},n.createElement("div",{className:"white-box__details"},n.createElement("div",{className:"application-set-extension__loading"},"Chargement des ApplicationSets...")))):o?n.createElement("div",{className:"application-set-extension"},n.createElement("div",{className:"white-box"},n.createElement("div",{className:"white-box__details"},n.createElement("div",{className:"application-set-extension__error"},"Erreur: ",o)))):n.createElement("div",{className:"application-set-extension"},n.createElement("div",{className:"white-box"},n.createElement("div",{className:"white-box__details"},n.createElement("div",{className:"application-set-extension__header"},n.createElement("h3",{className:"application-set-extension__title"},"📋 ApplicationSets (",e.length,")")),0===e.length?n.createElement("div",{className:"application-set-extension__empty"},"Aucun ApplicationSet trouvé."):n.createElement("div",null,e.map((e=>n.createElement(_,{key:e.metadata.uid,applicationSet:e})))))))},_=({applicationSet:e})=>{var t;const[a,i]=n.useState(!1),o=((null===(t=e.spec)||void 0===t?void 0:t.generators)||[]).map((e=>Object.keys(e)[0])).join(", ");return n.createElement("div",{style:{marginBottom:"1rem",border:"1px solid #dee6eb",borderRadius:"8px"}},n.createElement("div",{style:{padding:"1rem",backgroundColor:"#eff3f5"}},n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},n.createElement("div",null,n.createElement("h4",{style:{margin:0,color:"#495763"}},e.metadata.name),n.createElement("p",{style:{margin:"0.5rem 0",color:"#6d7f8b",fontSize:"0.875rem"}},"Namespace: ",e.metadata.namespace," | Générateurs: ",o)),n.createElement("button",{className:"application-set-extension__action-button application-set-extension__action-button--primary",onClick:()=>i(!a)},a?"Masquer détails":"Voir détails"))),a&&n.createElement("div",{style:{padding:"1rem"}},n.createElement(m,{resource:e,tree:{}})))};return window.extensionsAPI?(window.extensionsAPI.registerSystemLevelExtension(u,"ApplicationSets","/applicationsets","fa-layer-group"),console.log("ApplicationSet system level extension registered"),window.extensionsAPI.registerResourceExtension("argoproj.io","ApplicationSet","v1alpha1",{component:m}),console.log("ApplicationSet resource extension registered successfully")):console.error("Failed to register ApplicationSet extension: extensionsAPI not available"),m}(React);
