import{M as H,P,k as S,N as M,I as O,O as $,a3 as D,r as d}from"./B2UyoCas.js";const x=()=>{const{kapi:i}=H(),m=P(),u=S(),{pid:c,sid:k,plugin:f}=u.params,{tracker:w}=M(),{t:C}=O(),I=$(),l=a=>{const t=a.replace("p-integrations-","").replace("-pid-sid",""),r={healthCheck:"ietf_health_check",woocommerce:"woocommerce_4_leankoala"};if(!Object.prototype.hasOwnProperty.call(r,t))throw new Error("No plugin found for "+t);return r[t]};return{integrationAction:async(a,n)=>{if(!m.getCompanyId||!c)throw new Error("Company ID or Project ID is not set");const s=m.getCompanyId;try{return await i("Marketplace").then(t=>a==="activate"?t.activateFeature(s,n,{projects:[c]}):t.deactivateFeature(s,n,{projects:[c]})),w("integration_page","click",`Clicked on ${a} button for plugin ${n}`),I.add({title:C(a==="activate"?"integrationActivated":"integrationDeactivated"),icon:a==="activate"?"i-heroicons-check-circle":"i-heroicons-x-circle",color:"success"}),null}catch(t){return t}},getComponentData:()=>{const a=l(u.params.plugin),{data:n,status:s,error:t}=D(`getComponentData-${c}-${f}`,async()=>await i("Marketplace").then(r=>r.getComponents(k,a)),{transform:r=>r});return{componentData:n,componentStatus:s,componentError:t}},getHealthData:()=>{const a=l(u.params.plugin),{data:n,status:s,error:t}=D(`getHealthData-${c}-${f}`,async()=>await i("Marketplace").then(r=>r.getHealthStatus(k,a,{})),{transform:r=>{const p=d(!1),g=d({}),v=d([]),[{results:y}]=Object.values(r.results),h=Object.keys(y.checks).map(e=>{const{observedUnit:o,...b}=y.checks[e]||{},j={...b,observedUnit:o==="plugins"?"plugins":o};return{id:e,...j}});return p.value=!!h.find(e=>e.group),p.value&&(g.value=h.reduce((e,o)=>(e[o.group||"general"]=[...e[o.group]||[],o],e),{}),v.value=Object.entries(g.value).map(e=>({name:e[0],notifications:e[1].filter(o=>o.status==="fail").length}))),{healthDataResults:h,isGrouped:p.value,groupedStats:g.value,getGroups:v.value}}});return{healthData:n,healthStatus:s,healthError:t}},getIdentifier:l}};export{x as u};
