import{j as n,L as d,bM as u,a$ as h}from"./index-lOezWVmi.js";const o=({profile:a,project:s})=>{const t=`/ui/project/${encodeURIComponent(s)}/instances?profile=${encodeURIComponent(a)}`;return n.jsx(d,{className:"u-no-margin u-no-padding",to:t,children:"Go to instances"})},x=({profile:a,affectedProjects:s,headingClassName:t})=>n.jsx(n.Fragment,{children:s==null?void 0:s.map(e=>n.jsxs("tr",{className:"instances-by-project list-wrapper",children:[n.jsx("th",{className:t,children:n.jsxs("div",{className:"flexible-container",children:[n.jsx("div",{className:"u-truncate",title:`Project ${e.name}`,children:e.name}),n.jsxs("div",{className:"u-float-right",children:["(",e.instances.length,")"]})]})}),n.jsxs("td",{children:[e.instances.length===0&&n.jsx("i",{className:"u-text--muted no-instances",children:"No instances"}),e.instances.length>0&&n.jsx(o,{profile:a,project:e.name})]})]},e.name))}),j=({profile:a,project:s,usedByInstances:t})=>n.jsx(n.Fragment,{children:t.length>0&&n.jsx("tr",{children:n.jsx("td",{children:n.jsx(o,{profile:a,project:s})})})}),g=({profile:a,project:s,headingClassName:t})=>{const e=s==="default",r=u(s,e,a.used_by),l=e?[{name:s,instances:r.filter(c=>c.project===s)}]:void 0;if(e){const{data:c=[]}=h();c.filter(i=>i.config["features.profiles"]==="false").map(i=>i.name).forEach(i=>l==null?void 0:l.push({name:i,instances:r.filter(m=>m.project===i)}))}return e?n.jsx(x,{profile:a.name,affectedProjects:l,headingClassName:t}):n.jsx(j,{profile:a.name,project:s,usedByInstances:r})};export{g as P};
