import{p as _,c as z,e as o,z as t,f as s,g as a,h as i,F as h,A as f,o as l,n as c,k as B,N as T}from"./vue-CSzJdJby.js";import{_ as S}from"./ring-alt-BtllWDs8.js";import{$ as F}from"./jquery-BALIvAru.js";import{_ as N}from"./lodash-uc_7-CSk.js";import{_ as C}from"./SizeDistributionBar-CUwS4Z3x.js";import"./highlight.js-CWp04Ajj.js";const I={class:"row"},$={key:0,class:"col text-end"},D={key:0,class:"text-center"},V=t("img",{src:S,class:"fa-fw fa-2x"},null,-1),A=[V],E={key:1},j={class:"d-flex"},U={class:"text-body-secondary small"},L={class:"ms-auto"},O={class:"btn btn-sm btn-outline-secondary dropdown-toggle",type:"button","data-bs-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false"},P={class:"dropdown-menu"},q=t("h6",{class:"dropdown-header"},"Sort by:",-1),G=["onClick"],H={key:2,class:"table table-sm"},J=t("thead",null,[t("tr",null,[t("th"),s(),t("th"),s(),t("th",{class:"text-center border-start"},[s(`
            Tables
            `),t("div",{class:"d-inline-block"},[t("div",{class:"progress border rounded-0",style:{height:"7px",width:"10px"}},[t("div",{class:"progress-bar bg-cat1",role:"progressbar",style:{width:"100%"}})])])]),s(),t("th",{class:"text-center border-start"},[s(`
            Indexes
            `),t("div",{class:"d-inline-block"},[t("div",{class:"progress border rounded-0",style:{height:"7px",width:"10px"}},[t("div",{class:"progress-bar bg-cat2",role:"progressbar",style:{width:"100%"}})])])]),s(),t("th",{class:"text-center border-start"},[s(`
            Toast
            `),t("div",{class:"d-inline-block"},[t("div",{class:"progress border rounded-0",style:{height:"7px",width:"10px"}},[t("div",{class:"progress-bar bg-secondary",role:"progressbar",style:{width:"100%"}})])])])])],-1),K={class:"database fw-bold"},M=["href"],Q={key:0,class:"temboard-tables text-end border-start"},R={class:"badge text-bg-secondary"},W={class:"d-inline-block",style:{"min-width":"80px"}},X={key:1,class:"temboard-tables text-center text-body-secondary border-start small"},Y=t("em",null," No table ",-1),Z=[Y],tt={key:2,class:"indexes text-end border-start"},et={class:"badge text-bg-secondary"},st={class:"d-inline-block",style:{"min-width":"80px"}},ot={key:3,class:"indexes text-center text-body-secondary border-start small"},lt=t("em",null," No index ",-1),at=[lt],nt={class:"temboard-toast text-end border-start"},rt={colspan:"5",class:"border-top-0"},it={__name:"Index",props:["apiUrl","instance"],setup(x){const g=x,m=_(0),v=_(0),y=_([]),n=_("total_bytes"),p=_({name:["Name","asc"],total_bytes:["Database Size","desc"],tables_bytes:["Tables Size","desc"],tables_bloat_ratio:["Tables Bloat","desc"],indexes_bytes:["Indexes Size","desc"],indexes_bloat_ratio:["Indexes Bloat","desc"],toast_bytes:["Toast Size","desc"]}),b=_(!0),w=z(()=>{const d=p.value[n.value][1];return N.orderBy(y.value,n.value,d)});function k(){F.ajax({url:g.apiUrl,contentType:"application/json",success:function(d){m.value=d.instance.total_bytes,v.value=d.instance.total_size,y.value=d.databases,y.value.forEach(function(r){r.tables_bloat_ratio=0,r.tables_bytes&&(r.tables_bloat_ratio=parseFloat((100*(r.tables_bloat_bytes/r.tables_bytes)).toFixed(1))),r.indexes_bloat_ratio=0,r.indexes_bytes&&(r.indexes_bloat_ratio=parseFloat((100*(r.indexes_bloat_bytes/r.indexes_bytes)).toFixed(1)))})},error:showError,complete:function(){b.value=!1}})}return k(),(d,r)=>(l(),o("div",null,[t("h3",I,[b.value?i("",!0):(l(),o("div",$,[s(`
        Size: `),t("strong",null,a(v.value),1)]))]),s(),b.value?(l(),o("div",D,A)):i("",!0),s(),b.value?i("",!0):(l(),o("div",E,[t("div",j,[t("h4",null,[s(`
          Databases `),t("span",U,"("+a(y.value.length)+")",1)]),s(),t("div",L,[t("button",O,`
            Sort by `+a(p.value[n.value][0]),1),s(),t("div",P,[q,s(),(l(!0),o(h,null,f(p.value,(e,u)=>(l(),o("a",{class:"dropdown-item",href:"#",onClick:ct=>n.value=u},[t("i",{class:c(["fa fa-fw",{"fa-check":n.value==u}])},null,2),s(" "+a(e[0]),1)],8,G))),256))])])])])),s(),b.value?i("",!0):(l(),o("table",H,[J,s(),t("tbody",null,[(l(!0),o(h,null,f(w.value,(e,u)=>(l(),o(h,null,[t("tr",{class:c({"bg-light2":u%2==0})},[t("td",K,[t("a",{href:`/server/${x.instance.agentAddress}/${x.instance.agentPort}/maintenance/${e.datname}`},a(e.datname),9,M)]),s(),t("td",{class:c(["database-size","text-end",n.value=="total_bytes"?"fw-bold":""])},a(e.total_size),3),s(),e.n_tables>0?(l(),o("td",Q,[t("span",R,a(e.n_tables),1),s(),t("span",W,[e.tables_bytes?(l(),o("span",{key:0,class:c([n.value=="tables_bytes"?"fw-bold":""])},a(e.tables_size),3)):i("",!0)]),s(),t("small",{style:{"min-width":"70px"},class:c(["table-bloat","d-inline-block",n.value=="tables_bloat_ratio"?"fw-bold":"text-body-secondary"])},[e.tables_bloat_bytes&&e.tables_bytes?(l(),o(h,{key:0},[s(`
                    Bloat: `+a(e.tables_bloat_ratio.toFixed(1))+`%
                  `,1)],64)):i("",!0)],2)])):(l(),o("td",X,Z)),s(),e.n_indexes>0?(l(),o("td",tt,[t("span",et,a(e.n_indexes),1),s(),t("span",st,[e.indexes_bytes?(l(),o("span",{key:0,class:c([n.value=="indexes_bytes"?"fw-bold":""])},a(e.indexes_size),3)):i("",!0)]),s(),t("small",{style:{"min-width":"70px"},class:c(["index-bloat","d-inline-block",n.value=="indexes_bloat_ratio"?"fw-bold":"text-body-secondary"])},[e.indexes_bloat_bytes&&e.indexes_bytes?(l(),o(h,{key:0},[s(`
                  Bloat: `+a(e.indexes_bloat_ratio.toFixed(1))+`%
                `,1)],64)):i("",!0)],2)])):(l(),o("td",ot,at)),s(),t("td",nt,[e.toast_bytes?(l(),o("span",{key:0,class:c([n.value=="toast_bytes"?"fw-bold":""])},a(e.toast_size),3)):i("",!0)])],2),s(),t("tr",{class:c({"bg-light2":u%2==0})},[t("td",rt,[B(C,{height:"7",total:m.value,cat1:e.tables_size,cat1raw:e.tables_bytes,cat1label:"Tables",cat1bis:e.tables_bloat_size,cat1bisraw:e.tables_bloat_bytes,cat1bislabel:"Tables Bloat",cat2:e.indexes_size,cat2raw:e.indexes_bytes,cat2label:"Indexes",cat2bis:e.indexes_bloat_size,cat2bisraw:e.indexes_bloat_bytes,cat2bislabel:"Indexes Bloat",cat3:e.toast_size,cat3raw:e.toast_bytes,cat3label:"Toast"},null,8,["total","cat1","cat1raw","cat1bis","cat1bisraw","cat2","cat2raw","cat2bis","cat2bisraw","cat3","cat3raw"])])],2)],64))),256))])]))]))}};T({components:{maintenanceindex:it}}).mount("#app");
