import{I as x}from"./iconify-56cbf3ff.js";import{d as U,a3 as B,u as D,r as v,e as m,h as c,w as n,j as r,n as _,q as k,a6 as w,s as d,g as s,M as b,a0 as I,f as a,k as h,S as V,K as N,a7 as P}from"./index-a0da86f0.js";import{_ as F}from"./_plugin-vue_export-helper-c27b6911.js";const S={class:"package-toolbar"},K={class:"package-resources"},$={class:"summary-stats"},q={key:0,class:"modules-section"},A={class:"item-list"},E={key:1,class:"pagetypes-section"},G={class:"item-list"},O={key:2,class:"releases-section"},z={class:"item-list"},H=U({__name:"package_toolbar",props:{context:{}},setup(C){const l=C,j=B(),p=D(),f=v(!1),g=v(!1),t=v({}),T=()=>{const e=l.context.record.name;j.warning({title:l.context.t("Uninstall Package"),content:l.context.t("Are you sure you want to uninstall this package? This will remove all associated modules and pagetypes. This action cannot be undone."),positiveText:l.context.t("Uninstall"),negativeText:l.context.t("Cancel"),onPositiveClick:async()=>{await M(e)}})},M=async e=>{var i,o;try{f.value=!0,(await N.post(`/jingrow/uninstall-extension/${e}`,{},{headers:P()})).data.success?(p.success(l.context.t("Package '{0}' uninstalled successfully").replace("{0}",e)),l.context.router.push("/app/package")):p.error(l.context.t("Failed to uninstall package"))}catch(u){console.error("Uninstall package error:",u),p.error(((o=(i=u.response)==null?void 0:i.data)==null?void 0:o.message)||l.context.t("Failed to uninstall package"))}finally{f.value=!1}},R=async()=>{var e,i;try{const o=l.context.record.name,u=await N.post("/jingrow/get-package-dependencies",{package_name:o},{headers:P()});u.data.message.status==="success"?(t.value=u.data.message,g.value=!0):p.error(u.data.message.message)}catch(o){console.error("Get package resources error:",o),p.error(((i=(e=o.response)==null?void 0:e.data)==null?void 0:i.message)||l.context.t("Failed to get package resources"))}};return(e,i)=>(_(),m("div",S,[c(r(b),null,{default:n(()=>[c(r(k),{type:"error",onClick:T,disabled:e.context.loading,class:"uninstall-btn"},{icon:n(()=>[c(r(w),null,{default:n(()=>[c(r(x),{icon:"tabler:trash"})]),_:1})]),default:n(()=>[d(" "+s(e.context.t("Uninstall Package")),1)]),_:1},8,["disabled"]),c(r(k),{type:"default",onClick:R,disabled:e.context.loading},{icon:n(()=>[c(r(w),null,{default:n(()=>[c(r(x),{icon:"tabler:info-circle"})]),_:1})]),default:n(()=>[d(" "+s(e.context.t("Package Resources")),1)]),_:1},8,["disabled"])]),_:1}),c(r(V),{show:g.value,"onUpdate:show":i[1]||(i[1]=o=>g.value=o)},{default:n(()=>[c(r(I),{style:{width:"500px"},title:e.context.t("Package Resources")},{footer:n(()=>[c(r(b),{justify:"end"},{default:n(()=>[c(r(k),{onClick:i[0]||(i[0]=o=>g.value=!1)},{default:n(()=>[d(s(e.context.t("OK")),1)]),_:1})]),_:1})]),default:n(()=>{var o,u,y;return[a("div",K,[a("h4",null,s(e.context.t("Package"))+": "+s(t.value.package_name),1),a("div",$,[a("p",null,[a("strong",null,s(e.context.t("Modules"))+":",1),d(" "+s(((o=t.value.summary)==null?void 0:o.modules_count)||0),1)]),a("p",null,[a("strong",null,s(e.context.t("PageTypes"))+":",1),d(" "+s(((u=t.value.summary)==null?void 0:u.pagetypes_count)||0),1)]),a("p",null,[a("strong",null,s(e.context.t("Releases"))+":",1),d(" "+s(((y=t.value.summary)==null?void 0:y.releases_count)||0),1)])]),t.value.modules&&t.value.modules.length>0?(_(),m("div",q,[a("h5",null,s(e.context.t("Modules"))+":",1),a("div",A,s(t.value.modules.join(", ")),1)])):h("",!0),t.value.pagetypes&&t.value.pagetypes.length>0?(_(),m("div",E,[a("h5",null,s(e.context.t("PageTypes"))+":",1),a("div",G,s(t.value.pagetypes.join(", ")),1)])):h("",!0),t.value.releases&&t.value.releases.length>0?(_(),m("div",O,[a("h5",null,s(e.context.t("Releases"))+":",1),a("div",z,s(t.value.releases.join(", ")),1)])):h("",!0)])]}),_:1},8,["title"])]),_:1},8,["show"])]))}});const W=F(H,[["__scopeId","data-v-c1a01635"]]);export{W as default};
