import{w as D,h as L,r,j as e}from"./main.js";import{s as A}from"./service-Cm5JamJJ.js";import{d as H,B as d}from"./button-D4VgS8ri.js";import{I as k}from"./input-CbL6Bfs6.js";import{C as I,a as P}from"./card-D6OLc_JP.js";import{S as K}from"./skeleton-huerLprc.js";import{T as M,a as V,b as R,c as l,d as G,e as i}from"./table-DdrD6bHN.js";import{S as _,a as q,b as F,c as J,d as x}from"./select-BNSL7nj6.js";import{S as O}from"./search-DZkcyG-F.js";import{R as Q}from"./rotate-ccw-D-CXQ6oj.js";import{C as U}from"./chevron-left-DmTTd18v.js";import{C as W}from"./chevron-right-CtzGSiAK.js";import"./Combination-B6GbgrNn.js";import"./index-DArTFRYQ.js";import"./check-VUVUvqaV.js";function de(){const{t:a}=H(),[f]=D(),{currentNamespace:z}=L(),[n,g]=r.useState(f.get("serviceName")||""),[v,b]=r.useState(f.get("groupName")||""),[h,u]=r.useState([]),[S,C]=r.useState(!1),[p,j]=r.useState(0),[t,c]=r.useState(1),[o,E]=r.useState(10),w=async()=>{if(n.trim()){C(!0);try{const T=(await A.listSubscribers({namespaceId:z,serviceName:n.trim(),groupName:v.trim()||void 0,pageNo:t,pageSize:o})).data;u(T.pageItems||[]),j(T.totalCount||0)}catch{u([]),j(0)}finally{C(!1)}}};r.useEffect(()=>{n.trim()&&w()},[t,o]);const N=()=>{c(1),w()},B=()=>{g(""),b(""),u([]),j(0),c(1)},y=Math.max(1,Math.ceil(p/o));return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:a("service.subscriberTitle")}),e.jsx(I,{className:"py-0",children:e.jsx(P,{className:"py-4",children:e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:a("service.serviceName")}),e.jsx(k,{placeholder:a("service.serviceName"),value:n,onChange:s=>g(s.target.value),className:"w-[200px]",onKeyDown:s=>s.key==="Enter"&&N()})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:a("service.groupName")}),e.jsx(k,{placeholder:a("service.groupName"),value:v,onChange:s=>b(s.target.value),className:"w-[200px]",onKeyDown:s=>s.key==="Enter"&&N()})]}),e.jsxs(d,{onClick:N,className:"gap-2",children:[e.jsx(O,{className:"h-4 w-4"}),a("common.search")]}),e.jsxs(d,{variant:"outline",onClick:B,className:"gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),a("common.reset")]})]})})}),e.jsx(I,{className:"py-0",children:e.jsx(P,{className:"p-0",children:S&&h.length===0?e.jsx("div",{className:"p-6 space-y-4",children:Array.from({length:5}).map((s,m)=>e.jsx(K,{className:"h-12 w-full"},m))}):h.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:e.jsx("p",{className:"text-lg",children:a("common.noData")})}):e.jsxs(M,{className:S?"opacity-50 pointer-events-none":"",children:[e.jsx(V,{children:e.jsxs(R,{children:[e.jsx(l,{className:"pl-6",children:a("service.groupName")}),e.jsx(l,{children:a("service.serviceName")}),e.jsx(l,{children:a("service.subscriberName")}),e.jsx(l,{children:a("service.subscribeCount")}),e.jsx(l,{className:"pr-6",children:a("service.clusters")})]})}),e.jsx(G,{children:h.map((s,m)=>e.jsxs(R,{children:[e.jsx(i,{className:"pl-6",children:s.groupName}),e.jsx(i,{children:s.serviceName}),e.jsx(i,{className:"font-medium",children:s.subscriberName}),e.jsx(i,{children:s.subscribeCount}),e.jsx(i,{className:"pr-6",children:s.clusters||"-"})]},m))})]})})}),p>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:a("service.totalSubscribers",{total:p})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:a("common.pageSize")}),e.jsxs(_,{value:o.toString(),onValueChange:s=>{E(parseInt(s,10)),c(1)},children:[e.jsx(q,{className:"w-[80px]",children:e.jsx(F,{})}),e.jsxs(J,{children:[e.jsx(x,{value:"10",children:"10"}),e.jsx(x,{value:"20",children:"20"}),e.jsx(x,{value:"50",children:"50"}),e.jsx(x,{value:"100",children:"100"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(t-1),disabled:t<=1,children:e.jsx(U,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-muted-foreground min-w-[80px] text-center",children:[t," / ",y]}),e.jsx(d,{variant:"outline",size:"sm",onClick:()=>c(t+1),disabled:t>=y,children:e.jsx(W,{className:"h-4 w-4"})})]})]})]})]})}export{de as default};
