1import{r as s,j as e}from"./vendor-motion-CWthwBHV.js";import{l as F,u as I,f as $,ao as u,an as B,bP as k,ap as D,aZ as W}from"./session-card-DfDogMnt.js";import{A as P,R as U}from"./App-DucJjLMU.js";import{P as H}from"./page-footer-DgQVBoUK.js";import"./index-UQ4Qr5Bx.js";import"./vendor-radix-XKDS9LlS.js";import"./api-base-B8hCG6H6.js";import"./vendor-query-CIlvkMVG.js";import"./vendor-charts-DVgyNbFy.js";import"./clerk-preview-Xs8fmqyU.js";import"./zap-DKaaT3bk.js";const m="/".replace(/\/$/,"");async function O(i){const r=await fetch(`${m}/api/admin${i}`,{credentials:"include"});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function _(i){const r=await fetch(`${m}/api/admin${i}`,{method:"DELETE",credentials:"include"});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}const z={cta:"Close section",footer:"Footer"},C={cta:{bg:"rgba(180,83,9,0.07)",text:"#92400e",border:"rgba(180,83,9,0.18)"},footer:{bg:"rgba(3,105,161,0.07)",text:"#075985",border:"rgba(3,105,161,0.18)"}};function M(i){return new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function te(){const[,i]=F(),{isLoaded:r}=I(),{data:p,isLoading:x}=$(),l=!!p?.isAdmin,[o,b]=s.useState([]),[w,h]=s.useState(!0),[y,j]=s.useState(""),[n,E]=s.useState("all"),[g,S]=s.useState(null);s.useEffect(()=>{!r||x||p!==void 0&&!l&&i("/")},[r,x,p,l,i]);const v=async()=>{h(!0),j("");try{const t=n!=="all"?`?source=${n}`:"",d=await O(`/email-signups${t}`);b(d.signups)}catch{j("Failed to load signups.")}finally{h(!1)}};s.useEffect(()=>{l&&v()},[l,n]);const R=async t=>{if(confirm("Remove this email from the list?")){S(t);try{await _(`/email-signups/${t}`),b(d=>d.filter(c=>c.id!==t))}catch{alert("Failed to delete. Try again.")}finally{S(null)}}},A=()=>{window.open(`${m}/api/admin/email-signups/export.csv`,"_blank")};if(!r||x)return e.jsxs("div",{style:{minHeight:"100vh",background:"#FCF6F0",display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(u,{size:28,style:{color:"rgba(58,28,0,0.3)",animation:"spin 0.8s linear infinite"}}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]});if(!l)return null;const a=n==="all"?o:o.filter(t=>t.source===n),L=o.filter(t=>t.source==="cta").length,T=o.filter(t=>t.source==="footer").length;return e.jsxs("div",{style:{minHeight:"100vh",background:"#FCF6F0"},children:[e.jsx(P,{}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),e.jsxs("div",{style:{maxWidth:860,margin:"0 auto",padding:"48px 20px 100px"},children:[e.jsxs("button",{onClick:()=>i("/admin"),style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:13,color:"rgba(58,28,0,0.45)",background:"none",border:"none",cursor:"pointer",padding:"0 0 20px"},children:[e.jsx(B,{size:14})," Admin"]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16,marginBottom:32,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:"50%",background:"rgba(58,28,0,0.07)",border:"1px solid rgba(58,28,0,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(k,{size:18,color:"#2e1505"})}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:26,fontWeight:400,color:"#2e1505",margin:0,letterSpacing:"-0.02em"},children:"Email signups"}),e.jsxs("p",{style:{fontSize:13,color:"rgba(58,28,0,0.45)",margin:"3px 0 0"},children:[o.length," total address",o.length!==1?"es":""]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("button",{onClick:v,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",borderRadius:10,border:"1px solid rgba(58,28,0,0.12)",background:"#fff",color:"rgba(58,28,0,0.6)",fontSize:13,cursor:"pointer"},children:[e.jsx(U,{size:13})," Refresh"]}),e.jsxs("button",{onClick:A,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 14px",borderRadius:10,border:"1px solid rgba(21,128,61,0.25)",background:"rgba(21,128,61,0.06)",color:"#15803d",fontSize:13,fontWeight:600,cursor:"pointer"},children:[e.jsx(D,{size:13})," Export CSV"]})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10,marginBottom:24},children:[{label:"Total",value:o.length,color:"#2e1505"},{label:"Close section",value:L,color:"#92400e"},{label:"Footer",value:T,color:"#075985"}
1].map(t=>e.jsxs("div",{style:{background:"#fff",borderRadius:14,border:"1px solid rgba(58,28,0,0.09)",padding:"16px 20px"},children:[e.jsx("div",{style:{fontSize:24,fontWeight:300,color:t.color,letterSpacing:"-0.03em"},children:t.value}),e.jsx("div",{style:{fontSize:12,color:"rgba(58,28,0,0.45)",marginTop:2},children:t.label})]},t.label))}),e.jsx("div",{style:{display:"flex",gap:6,marginBottom:16},children:["all","cta","footer"].map(t=>e.jsx("button",{onClick:()=>E(t),style:{padding:"6px 14px",borderRadius:8,fontSize:12,fontWeight:500,border:n===t?"1px solid rgba(58,28,0,0.2)":"1px solid rgba(58,28,0,0.1)",background:n===t?"#2e1505":"#fff",color:n===t?"#fff":"rgba(58,28,0,0.55)",cursor:"pointer",transition:"all 0.1s",textTransform:"capitalize"},children:t==="all"?"All":z[t]??t},t))}),e.jsx("div",{style:{background:"#fff",borderRadius:16,border:"1px solid rgba(58,28,0,0.09)",overflow:"hidden"},children:w?e.jsxs("div",{style:{padding:40,display:"flex",alignItems:"center",justifyContent:"center",gap:10},children:[e.jsx(u,{size:18,style:{color:"rgba(58,28,0,0.3)",animation:"spin 0.8s linear infinite"}}),e.jsx("span",{style:{fontSize:13,color:"rgba(58,28,0,0.4)"},children:"Loadingâ¦"})]}):y?e.jsx("div",{style:{padding:40,textAlign:"center",fontSize:14,color:"#b91c1c"},children:y}):a.length===0?e.jsxs("div",{style:{padding:60,textAlign:"center"},children:[e.jsx(k,{size:28,style:{color:"rgba(58,28,0,0.2)",marginBottom:10}}),e.jsx("p",{style:{fontSize:14,color:"rgba(58,28,0,0.4)",margin:0},children:"No signups yet."})]}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(58,28,0,0.07)"},children:["Email","Source","Signed up",""].map(t=>e.jsx("th",{style:{textAlign:"left",padding:"12px 18px",fontSize:11,fontWeight:500,letterSpacing:"0.06em",textTransform:"uppercase",color:"rgba(58,28,0,0.38)"},children:t},t))})}),e.jsx("tbody",{children:a.map((t,d)=>{const c=C[t.source]??C.footer;return e.jsxs("tr",{style:{borderBottom:d<a.length-1?"1px solid rgba(58,28,0,0.05)":"none",background:"transparent",transition:"background 0.1s"},onMouseEnter:f=>f.currentTarget.style.background="rgba(58,28,0,0.02)",onMouseLeave:f=>f.currentTarget.style.background="transparent",children:[e.jsx("td",{style:{padding:"13px 18px",fontSize:14,color:"#2e1505",fontFamily:"monospace"},children:t.email}),e.jsx("td",{style:{padding:"13px 18px"},children:e.jsx("span",{style:{display:"inline-block",padding:"3px 10px",borderRadius:6,fontSize:11,fontWeight:500,background:c.bg,color:c.text,border:`1px solid ${c.border}`},children:z[t.source]??t.source})}),e.jsx("td",{style:{padding:"13px 18px",fontSize:12,color:"rgba(58,28,0,0.45)",whiteSpace:"nowrap"},children:M(t.createdAt)}),e.jsx("td",{style:{padding:"13px 18px",textAlign:"right"},children:e.jsx("button",{onClick:()=>R(t.id),disabled:g===t.id,style:{padding:"5px 8px",borderRadius:7,border:"1px solid rgba(185,28,28,0.15)",background:"rgba(185,28,28,0.04)",color:"rgba(185,28,28,0.55)",cursor:g===t.id?"default":"pointer",opacity:g===t.id?.5:1,display:"flex",alignItems:"center"},title:"Remove from list",children:g===t.id?e.jsx(u,{size:13,style:{animation:"spin 0.8s linear infinite"}}):e.jsx(W,{size:13})})})]},t.id)})})]})}),a.length>0&&e.jsxs("p",{style:{fontSize:12,color:"rgba(58,28,0,0.3)",textAlign:"center",marginTop:12},children:["Showing ",a.length," address",a.length!==1?"es":""]})]}),e.jsx(H,{})]})}export{te 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.