1import{u as N,b as y,w as v,r as w,f as L,j as e,L as b,B as h,G as k,F as U}from"./index-QiiZ-xPT.js";import{N as f}from"./Navigation-r93ZBuy6.js";import{F as g}from"./Footer-3JNsJayo.js";import{B as A}from"./building-2-Bz-h5bHH.js";import{T as S}from"./trending-up-BLnfQQLk.js";import{U as E}from"./users-JkJLChox.js";import{M as F}from"./mic-Dyg9iBEC.js";import{A as $}from"./arrow-left-B-CeY16K.js";import{D as B}from"./download-D-fGOqS3.js";import"./label-BA9Xin3m.js";import"./checkbox-CrGTwbPu.js";import"./index-DqZlRfV5.js";import"./check-KTa2Xihg.js";import"./select-B1P2Vx_w.js";import"./index-BMyKsIJE.js";import"./Combination-TP2Egp2x.js";import"./chevron-down-BWOHa16b.js";import"./dialog-D2VXyQJN.js";import"./save-BsB7cS8F.js";import"./dropdown-menu-D4zjGRmc.js";import"./index-Bj3iuRQR.js";import"./chevron-right-f4G5e4zR.js";import"./circle-2nw1jhuN.js";import"./useTranslation-XedzLvcK.js";import"./globe-3tsuvpPT.js";import"./log-out-CqAuLeet.js";import"./BrandSponsor-DEW6i_On.js";import"./card-DkXabqFf.js";import"./mail-Cr62Xklx.js";import"./twitter-BzZd48jL.js";const C={articles:{label:"Articles",icon:U,color:"text-primary"},podcasts:{label:"Podcasts",icon:F,color:"text-accent"},modules:{label:"Learning Modules",icon:k,color:"text-green-500"},users:{label:"All Users",icon:E,color:"text-blue-500"},"paid-users":{label:"Paid Users",icon:S,color:"text-purple-500"},enterprise:{label:"Enterprise Users",icon:A,color:"text-orange-500"}};function O(n,l){if(!n.length)return;const a=Object.keys(n[0]),d=[a.join(","),...n.map(p=>a.map(c=>{const r=String(p[c]??"").replace(/"/g,'""');return r.includes(",")||r.includes('"')||r.includes(` 2`)?`"${r}"`:r}).join(","))].join(` 3`),x=new Blob([d],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(x),t=document.createElement("a");t.href=s,t.download=`${l}-${new Date().toISOString().slice(0,10)}.csv`,t.click(),URL.revokeObjectURL(s)}function me(){const{user:n,isLoading:l,isAuthenticated:a}=N(),[,d]=y(),[,x]=v("/admin/list/:type"),s=x?.type||"",t=C[s];w.useEffect(()=>{!l&&(!a||n?.membershipTier!=="admin")&&d("/")},[l,a,n,d]);const{data:p,isLoading:c}=L({queryKey:["/api/admin/list",s],queryFn:async()=>{const o=await fetch(`/api/admin/list/${s}`,{credentials:"include"});if(!o.ok)throw new Error("Failed to fetch");return o.json()},enabled:!!s&&!!t});if(!t)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(f,{}),e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-12 text-center",children:[e.jsx("p",{children:"Invalid list type."}),e.jsx(b,{href:"/admin",children:e.jsx(h,{className:"mt-4",children:"Back to Admin"})})]}),e.jsx(g,{})]});const r=t.icon,i=p||[],m=i.length>0?Object.keys(i[0]):[];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(f,{}),e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{href:"/admin",children:e.jsx(h,{variant:"ghost",size:"sm","data-testid":"button-back-admin",children:e.jsx($,{size:18})})}),e.jsx(r,{size:28,className:t.color}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-list-title",children:t.label}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-list-count",children:c?"Loading...":`${i.length} items`})]})]}),e.jsxs(h,{onClick:()=>O(i,s),disabled:c||i.length===0,className:"gap-2","data-testid":"button-export-csv",children:[e.jsx(B,{size:18}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-xl border border-border overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm","data-testid":"table-admin-list",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/50 border-b border-border",children:[e.jsx("th",{className:"px-4 py-3 text-left font-medium text-muted-foreground w-12",children:"#"}),m.map(o=>e.jsx("th",{className:"px-4 py-3 text-left font-medium text-muted-foreground capitalize",children:o.replace(/([A-Z])/g," $1").trim()},o))]})}),e.jsx("tbody",{children:c?e.jsx("tr",{children:e.jsx("td",{colSpan:m.length+1,className:"px-4 py-12 text-center text-muted-foreground",children:"Loading..."})}):i.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:m.length+1,className:"px-4 py-12 text-center text-muted-foreground",children:"No items found."})}):i.map((o,u)=>e.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30 transition-colors","data-testid":`row-item-${u}`,children:[e.jsx("td",{className:"px-4 py-2.5 text-muted-foreground",children:u+1}),m.map(j=>e.jsx("td",{className:"px-4 py-2.5 max-w-xs truncate",children:String(o[j]??"")},j))]},u))})]})})})]}),e.jsx(g,{})]})}
3export{me as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.