import{N as I,R as P,i as S,P as $,J as A,Q as E,a5 as D,v as d}from"./Dk4AzF7j.js";const R=()=>{const{kapi:i}=I(),m=P(),u=S(),{pid:c,sid:v,plugin:f}=u.params,{tracker:w}=$(),{t:C}=A(),b=E(),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}`),b.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(v,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(v,a,{})),{transform:r=>{const p=d(!1),g=d({}),k=d([]),[{results:y}]=Object.values(r.results),h=Object.keys(y.checks).map(e=>{const{observedUnit:o,...j}=y.checks[e]||{},H={...j,observedUnit:o==="plugins"?"plugins":o};return{id:e,...H}});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),{}),k.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:k.value}}});return{healthData:n,healthStatus:s,healthError:t}},getIdentifier:l}};export{R as u};
