PageSourceSearch

https://aichecklist.io/assets/AdminContent-D9Dwz9RX.js

js aichecklist.io collected 2026-09-24 15:04:11 UTC 29,405 bytes, 3 lines download raw bytes

1import{a as p,j as e}from"./vendor-react-BieOFGTO.js";import{c as Z,u as _,b as A}from"./vendor-query-Bf7VLrsv.js";import{x as S,a as T,o as g,p as N,r as w,t as y,B as j,s as L,j as V,ac as Y,u as ee,k as C,I as M,Q as q,R as B,a4 as ne,i as ie,q as z,L as Q,C as se,a3 as le,X as ce,V as oe,ab as $,G as de,M as me}from"./index-Bca1piM7.js";import{B as O}from"./badge-DRB4Qwvn.js";import{R as b}from"./refresh-cw-RA94r4Vd.js";import{T as W}from"./triangle-alert-B9y4pClh.js";import{T as te}from"./trash-2-CX_3qZbS.js";import{C as xe}from"./circle-x-De_BLF5_.js";import{T as ae,a as re,b as E,c as k}from"./tabs-DWJBHqGN.js";import{S as H}from"./save-Cht66RKy.js";import{F as ue,P as he,M as pe}from"./FireworksEffect-BtTiSy1T.js";import{D as X}from"./diamond-CGnKAEl8.js";import{C as je}from"./crown-tmjohLUa.js";import{A as fe,m as v}from"./vendor-motion-B4SuNsHa.js";import{G as F}from"./gift-DmBX6jN5.js";import{S as G}from"./sparkles-BmRHc6Ak.js";import{f as U,F as ge,G as ye}from"./vendor-utils-Uev4__JX.js";import{T as ve}from"./textarea-DwgfvJTR.js";import{M as be}from"./map-pin-gREj8jkw.js";import"./vendor-radix-Cx3Dvb0S.js";function Ne(){const[n,i]=p.useState(0),d=Z(),{data:o,isLoading:m,error:x}=_({queryKey:["/api/logs/errors",n],refetchInterval:document.hasFocus()?3e4:!1,refetchIntervalInBackground:!1}),{data:u,isLoading:l}=_({queryKey:["/api/logs",n],refetchInterval:document.hasFocus()?3e4:!1,refetchIntervalInBackground:!1}),f=()=>{i(s=>s+1),S({title:"Status Refreshed",description:"Latest system status has been loaded."})},t=A({mutationFn:async()=>await T("POST","/api/logs/flush-all",{}),onSuccess:()=>{d.invalidateQueries({queryKey:["/api/logs/errors"]}),d.invalidateQueries({queryKey:["/api/logs"]}),i(s=>s+1),S({title:"Logs Cleared",description:"All system logs have been cleared. Status reset to clean.",duration:3e3})},onError:()=>{S({title:"Clear Failed",description:"Failed to clear logs. Please try again.",variant:"destructive",duration:3e3})}}),a=()=>o?.logs&&(()=>{const h=new Date(Date.now()-36e5);return o.logs.split(`
2`).filter(P=>{if(!P.trim())return!1;const R=P.match(/\[(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})\]/);return R?new Date(`${R[1]}T${R[2]}`)>h:!1}).length>0})()?{status:"error",color:"text-red-500",bgColor:"bg-red-50 border-red-200",icon:e.jsx(xe,{className:"w-6 h-6 text-red-500"}),title:"System Issues Detected",message:"Recent errors found - technical support needed"}:{status:"healthy",color:"text-green-500",bgColor:"bg-green-50 border-green-200",icon:e.jsx(Y,{className:"w-6 h-6 text-green-500"}),title:"100% System Working - All Green",message:"All systems operational and clean"},c=()=>{if(!u?.logs)return 0;const s=new Date(Date.now()-600*1e3);return u.logs.split(`
3`).filter(I=>{const P=I.match(/\[(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})\]/);return P?new Date(`${P[1]}T${P[2]}`)>s:!1}).length};if(l||m)return e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 animate-spin"}),"Checking System Status..."]})}),e.jsx(y,{children:e.jsx("div",{className:"flex justify-center items-center h-32",children:e.jsx(b,{className:"w-8 h-8 animate-spin text-muted-foreground"})})})]});if(x)return e.jsxs(g,{children:[e.jsx(N,{children:e.jsxs(w,{className:"flex items-center gap-2 text-orange-600",children:[e.jsx(W,{className:"w-5 h-5"}),"Status Check Failed"]})}),e.jsx(y,{children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Unable to check system status at this time."}),e.jsxs(j,{onClick:f,className:"mt-4",children:[e.jsx(b,{className:"w-4 h-4 mr-2"}),"Try Again"]})]})})]});const r=a(),D=c();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"System Status"}),e.jsx("p",{className:"text-muted-foreground",children:"Monitor system health and activity"})]}),e.jsxs(j,{onClick:f,variant:"outline",children:[e.jsx(b,{className:"w-4 h-4 mr-2"}),"Refresh Status"]})]}),e.jsxs(g,{className:`border-2 ${r.bgColor}`,children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[r.icon,e.jsxs("div",{children:[e.jsx(w,{className:r.color,children:r.title}),e.jsx(L,{className:"text-base",children:r.message})]})]}),e.jsx(O,{variant:r.status==="error"?"destructive":"default",children:r.status==="error"?"Issues Found":"All Good"})]})}),r.status==="error"&&e.jsx(y,{children:e.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-red-100 rounded-lg border border-red-200",children:[e.jsx(V,{className:"w-5 h-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-red-800",children:"Support Contact Required"}),e.jsx("p",{className:"text-sm text-red-600",children:"Technical issues detected. Please contact support with log access request."})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(g,{children:e.jsx(y,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Y,{className:"w-5 h-5 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-green-600",children:r.status==="healthy"?"OK":"--"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System Health"})]})]})})}),e.jsx(g,{children:e.jsx(y,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(W,{className:"w-5 h-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:r.status==="error"?"YES":"NO"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Issues Present"})]})]})})}),e.jsx(g,{children:e.jsx(y,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(b,{className:"w-5 h-5 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:D}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Recent Activity"})]})]})})})]}
3),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Quick Actions"}),e.jsx(L,{children:"System monitoring and maintenance options"})]}),e.jsx(y,{children:e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs(j,{onClick:f,variant:"outline",className:"flex items-center space-x-2",children:[e.jsx(b,{className:"w-4 h-4"}),e.jsx("span",{children:"Check Status"})]}),e.jsxs(j,{onClick:()=>t.mutate(),variant:"outline",disabled:t.isPending,className:"flex items-center space-x-2",children:[e.jsx(te,{className:"w-4 h-4"}),e.jsx("span",{children:t.isPending?"Clearing...":"Clear Logs"})]}),r.status==="error"&&e.jsxs(j,{variant:"default",className:"flex items-center space-x-2 bg-red-600 hover:bg-red-700",onClick:()=>{S({title:"Support Request",description:"Please contact aichecklist.io support for log analysis.",duration:5e3})},children:[e.jsx(V,{className:"w-4 h-4"}),e.jsx("span",{children:"Request Support"})]})]})})]})]})}function we(){const[n,i]=p.useState([]),[d,o]=p.useState(!0),[m,x]=p.useState({}),{toast:u}=ee();p.useEffect(()=>{(async()=>{try{o(!0);const c=await(await T("GET","/api/admin/keys")).json();i(c.keys)}catch(a){console.error("Failed to fetch API keys:",a),u({title:"Error",description:"Failed to load API keys. Please try again.",variant:"destructive"})}finally{o(!1)}})()},[]);const l=async(t,a)=>{try{o(!0),console.log("Saving API key:",{name:t,valueLength:a?.length||0});const c=await T("POST","/api/admin/keys",{name:t,value:a});console.log("Save response:",c),u({title:"Success",description:`${t} has been saved successfully.`}),i(n.map(r=>r.name===t?{...r,value:a}:r))}catch(c){console.error("Failed to save API key:",c);const r=c instanceof Error?c.message:"Failed to save API key. Please try again.";u({title:"Error",description:r,variant:"destructive"})}finally{o(!1)}},f=t=>{x({...m,[t]:!m[t]})};return p.useEffect(()=>{n.length===0&&!d&&i([{name:"STRIPE_SECRET_KEY",value:"",isSecret:!0},{name:"VITE_STRIPE_PUBLIC_KEY",value:"",isSecret:!1}])},[n,d]),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"API Keys Management"}),e.jsx(L,{children:"Manage API keys for various integrations. Secret keys are stored securely and never exposed in client code."})]}),e.jsx(y,{children:e.jsxs(ae,{defaultValue:"stripe",className:"w-full",children:[e.jsxs(re,{className:"mb-4",children:[e.jsx(E,{value:"stripe",children:"Stripe"}),e.jsx(E,{value:"other",children:"Other"})]}),e.jsx(k,{value:"stripe",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid w-full gap-1.5",children:[e.jsx(C,{htmlFor:"stripe-secret-key",children:"Secret Key (Server-only)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(M,{id:"stripe-secret-key",type:m.STRIPE_SECRET_KEY?"text":"password",placeholder:"sk_test_...",value:n.find(t=>t.name==="STRIPE_SECRET_KEY")?.value||"",onChange:t=>{const a=t.target.value;i(n.map(c=>c.name==="STRIPE_SECRET_KEY"?{...c,value:a}:c))}}),e.jsx(j,{variant:"outline",size:"icon",onClick:()=>f("STRIPE_SECRET_KEY"),children:m.STRIPE_SECRET_KEY?e.jsx(q,{size:16}):e.jsx(B,{size:16})}),e.jsxs(j,{variant:"secondary",onClick:()=>l("STRIPE_SECRET_KEY",n.find(t=>t.name==="STRIPE_SECRET_KEY")?.value||""),disabled:d,children:[d?e.jsx(b,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(H,{className:"mr-2 h-4 w-4"}),"Save"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This key is stored securely on the server and used for backend operations."})]}),e.jsxs("div",{className:"grid w-full gap-1.5",children:[e.jsx(C,{htmlFor:"stripe-public-key",children:"Public Key (Client-side)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(M,{id:"stripe-public-key",type:m.VITE_STRIPE_PUBLIC_KEY?"text":"password",placeholder:"pk_test_...",value:n.find(t=>t.name==="VITE_STRIPE_PUBLIC_KEY")?.value||"",onChange:t=>{const a=t.target.value;i(n.map(c=>c.name==="VITE_STRIPE_PUBLIC_KEY"?{...c,value:a}:c))}}),e.jsx(j,{variant:"outline",size:"icon",onClick:()=>f("VITE_STRIPE_PUBLIC_KEY"),children:m.VITE_STRIPE_PUBLIC_KEY?e.jsx(q,{size:16}):e.jsx(B,{size:16})}),e.jsxs(j,{variant:"secondary",onClick:()=>l("VITE_STRIPE_PUBLIC_KEY",n.find(t=>t.name==="VITE_STRIPE_PUBLIC_KEY")?.value||""),disabled:d,children:[d?e.jsx(b,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(H,{className:"mr-2 h-4 w-4"}),"Save"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This key is used in the browser for Stripe Elements and checkout processes."})]})]})}),e.jsx(k,{value:"other",children:e.jsx("div",{className:"py-4 text-center text-muted-foreground",children:"No other API integrations configured yet."})})]})}),e.jsx(ne,{className:"flex justify-between",children:e.jsxs("div",{className:"text-sm text-muted-foreground",children:["API keys last updated: ",new Date().toLocaleStr
3ing()]})})]})}const Se={"3month":{label:"3 Months Free",sublabel:"Complimentary Access",gradient:"from-indigo-900 via-purple-900 to-violet-900",glow:"from-violet-400 to-purple-500",Icon:X,emoji:"💎",iconColor:"#c084fc",iconGlow:"0 0 18px 4px rgba(192,132,252,0.7)"},"6month":{label:"6 Months Free",sublabel:"Premium Access",gradient:"from-sky-500 to-blue-600",glow:"from-sky-400 to-blue-400",Icon:je,emoji:"🎉"},"1year":{label:"1 Year Free",sublabel:"Full Year — Legendary Access",gradient:"from-yellow-400 to-amber-500",glow:"from-yellow-300 to-amber-400",Icon:X,emoji:"👑"}};function Ee({isVisible:n,username:i,duration:d,expiresAt:o,onClose:m}){const[x,u]=p.useState(!1),l=Se[d];p.useEffect(()=>{if(n){u(!0);const t=setTimeout(m,5e3);return()=>clearTimeout(t)}},[n,m]);const f=l.Icon;return e.jsxs(e.Fragment,{children:[e.jsx(ue,{isActive:x,onComplete:()=>u(!1)}),e.jsx(fe,{children:n&&e.jsx(v.div,{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:m,children:e.jsxs(v.div,{className:`relative bg-gradient-to-br ${l.gradient} rounded-2xl p-7 max-w-sm w-full text-white shadow-2xl`,initial:{scale:.5,y:60},animate:{scale:1,y:0},exit:{scale:.5,y:60},transition:{type:"spring",duration:.5},onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:`absolute -inset-1 bg-gradient-to-r ${l.glow} rounded-2xl blur-md opacity-50`}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx(v.div,{className:"inline-block mb-3",animate:{rotate:[0,12,-12,0],scale:[1,1.15,1]},transition:{duration:.7,repeat:2,ease:"easeInOut"},children:e.jsx(f,{className:"h-16 w-16 mx-auto drop-shadow-lg",style:{color:l.iconColor??"#ffffff",filter:l.iconGlow?`drop-shadow(${l.iconGlow})`:void 0}})}),e.jsx(v.div,{className:"flex justify-center gap-1 mb-3 text-2xl",initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.15},children:[...Array(5)].map((t,a)=>e.jsx(v.span,{animate:{y:[0,-6,0]},transition:{delay:a*.1,duration:.6,repeat:3},children:l.emoji},a))}),e.jsx(v.h2,{className:"text-2xl font-bold mb-1",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:"Free Service Granted!"}),e.jsx(v.div,{className:"text-sm uppercase tracking-widest opacity-80 mb-1",initial:{opacity:0}
3,animate:{opacity:1},transition:{delay:.3},children:l.sublabel})]}),e.jsxs(v.div,{className:"bg-white/20 rounded-xl p-4 text-center space-y-2 mb-4",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 opacity-80"}),e.jsx("span",{className:"text-lg font-bold",children:l.label})]}),e.jsxs("div",{className:"text-white/90 font-semibold text-base",children:["@",i]}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-white/75 text-sm",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Expires ",U(new Date(o),"MMMM d, yyyy")]})]})]}),e.jsxs(v.div,{className:"flex justify-center gap-2 text-white/60 text-xs tracking-widest uppercase",initial:{opacity:0},animate:{opacity:1},transition:{delay:.55},children:[e.jsx(G,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Full enterprise access unlocked"}),e.jsx(G,{className:"w-3.5 h-3.5"})]}),e.jsx(v.button,{onClick:m,className:"absolute top-0 right-0 text-white/60 hover:text-white transition-colors p-1",whileHover:{scale:1.1},whileTap:{scale:.9},children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})})})]})}const J=[{value:"3month",label:"3 Months"},{value:"6month",label:"6 Months"},{value:"1year",label:"1 Year"}];function ke(){const{toast:n}=ee(),[i,d]=p.useState(""),[o,m]=p.useState("1year"),[x,u]=p.useState(null),{data:l=[],isLoading:f}=_({queryKey:["/api/admin/testers"]}),t=A({mutationFn:()=>T("POST","/api/admin/grant-tester",{identifier:i.trim(),duration:o}).then(s=>s.json()),onSuccess:s=>{const h=i.trim().includes("@")?s.message.match(/@?([^\s(]+)/)?.[1]??i.trim():i.trim();u({username:h,duration:o,expiresAt:s.expiresAt}),d(""),z.invalidateQueries({queryKey:["/api/admin/testers"]})},onError:async s=>{let h="Failed to grant access";try{h=(await s.response?.json())?.message??h}catch{}n({title:"Error",description:h,variant:"destructive"})}}),a=A({mutationFn:s=>T("DELETE",`/api/admin/testers/${s}`).then(h=>h.json()),onSuccess:()=>{n({title:"Free service revoked"}),z.invalidateQueries({queryKey:["/api/admin/testers"]})},onError:()=>{n({title:"Error",description:"Could not revoke access.",variant:"destructive"})}}),c=s=>s?ge(new Date(s)):!1,r=s=>{if(!s)return null;const h=ye(new Date(s),new Date);return h<0?0:h},D=s=>s.first_name||s.last_name?`${s.first_name??""} ${s.last_name??""}`.trim():s.username||s.email;return e.jsxs(e.Fragment,{children:[x&&e.jsx(Ee,{isVisible:!!x,username:x.username,duration:x.duration,expiresAt:x.expiresAt,onClose:()=>u(null)}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-5 h-5 text-primary"}),"Grant Free Service"]}),e.jsx(L,{children:"Give any user free enterprise access. Type their username or email, pick a duration, and hit Grant."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"free-identifier",children:"Username or email"}),e.jsx(M,{id:"free-identifier",placeholder:"e.g. fredirc or [email protected]",value:i,onChange:s=>d(s.target.value),onKeyDown:s=>s.key==="Enter"&&i.trim()&&t.mutate()})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Duration"}),e.jsx("div",{className:"flex gap-2",children:J.map(s=>e.jsx("button",{type:"button",onClick:()=>m(s.value),className:`flex-1 rounded-xl border-2 py-3 text-sm font-medium transition-all ${o===s.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-muted-foreground/40"}`,children:s.label},s.value))})]}),e.jsx(j,{className:"w-full",disabled:!i.trim()||t.isPending,onClick:()=>t.mutate(),children:t.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4 mr-2 animate-spin"})," Granting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 mr-2"})," Grant ",J.find(s=>
3s.value===o)?.label," Free"]})})]})]}),e.jsxs(g,{children:[e.jsxs(N,{children:[e.jsxs(w,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-5 h-5 text-primary"}),"Active Free Accounts",l.length>0&&e.jsx(O,{variant:"secondary",className:"ml-1",children:l.length})]}),e.jsx(L,{children:"Users currently on complimentary access."})]}),e.jsx(y,{children:f?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Q,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):l.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(F,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No active free accounts yet."})]}):e.jsx("div",{className:"space-y-2",children:l.map(s=>{const h=c(s.subscription_ends_at),I=r(s.subscription_ends_at);return e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-xl border ${h?"border-red-200 bg-red-50/50 dark:bg-red-950/10":"border-border bg-muted/30"}`,children:[e.jsx("div",{className:"flex-shrink-0",children:h?e.jsx(le,{className:"w-5 h-5 text-red-500"}):e.jsx(Y,{className:"w-5 h-5 text-emerald-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:D(s)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.email}),e.jsx("p",{className:`text-xs mt-0.5 ${h?"text-red-500":"text-muted-foreground"}`,children:s.subscription_ends_at?h?`Expired ${U(new Date(s.subscription_ends_at),"MMM d, yyyy")}`:`${I} day${I===1?"":"s"} left — expires ${U(new Date(s.subscription_ends_at),"MMM d, yyyy")}`:"No expiry set"})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-8 w-8 text-muted-foreground hover:text-red-500 hover:bg-red-50",disabled:a.isPending,onClick:()=>a.mutate(s.id),children:e.jsx(te,{className:"w-4 h-4"})})]},s.id)})})})]})]})]})}const K=[{id:"welcome",name:"Welcome",icon:e.jsx(he,{className:"h-5 w-5"}),description:"Warm greeting banner with a friendly tone",preview:"bg-gradient-to-r from-emerald-500 to-teal-600 text-white",borderClass:"border-emerald-400"},{id:"announcement",name:"Announcement",icon:e.jsx(pe,{className:"h-5 w-5"}),description:"Important info banner for updates and news",preview:"bg-gradient-to-r from-blue-500 to-indigo-600 text-white",borderClass:"border-blue-400"},{id:"promo",name:"Promotional",icon:e.jsx(G,{className:"h-5 w-5"}),description:"Eye-catching banner for features and offers",preview:"bg-gradient-to-r from-purple-500 via-pink-500 to-orange-400 text-white",borderClass:"border-purple-400"}];function Ce(){const n=Z(),[i,d]=p.useState("welcome"),[o,m]=p.useState(""),[x,u]=p.useState(""),{data:l,isLoading:f}=_({queryKey:["/api/admin/banner"]}),t=A({mutationFn:async()=>await T("POST","/api/admin/banner",{style:i,title:x.trim(),message:o.trim()}),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/admin/banner"]}),n.invalidateQueries({queryKey:["/api/banner"]}),S({title:"Banner Activated",description:"The banner is now live for all users."})},onError:()=>{S({title:"Failed",description:"Could not activate banner.",variant:"destructive"})}}),a=A({mutationFn:async()=>await T("DELETE","/api/admin/banner"),onSuccess:()=>{n.invalidateQueries({queryKey:["/api/admin/banner"]}),n.invalidateQueries({queryKey:["/api/banner"]}),S({title:"Banner Removed",description:"The banner has been taken down."})},onError:()=>{S({title:"Failed",description:"Could not remove banner.",variant:"destructive"})}}),c=K.find(r=>r.id===i);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Entrance Banners"}),e.jsx("p",{className:"text-muted-foreground",children:"Push a banner to all users on the site"})]}),l?.active&&e.jsxs(O,{variant:"default",className:"bg-green-600 text-white",children:[e.jsx(B,{className:"h-3 w-3 mr-1"})," Live"]})]}),l?.active&&e.jsxs(g,{className:"border-2 border-green-300 bg-green-50 dark:bg-green-950/20",children:[e.jsx(N,{className:"pb-3",children:e.jsxs(w,{className:"text-base flex items-center gap-2",children:[e.jsx(B,{className:"h-4 w-4 text-green-600"}),"Currently Active Banner"]})}),e.jsxs(y,{children:[e.jsxs("div",{className:`rounded-lg p-4 mb-4 ${K.find(r=>r.id===l.style)?.preview||K[0].preview}`,children:[e.jsx("p",{className:"font-bold text-sm",children:l.title||"Banner"}),e.jsx("p",{className:"text-sm opacity-90",children:l.message})]}),e.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>a.mutate(),disabled:a.isPending,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),a.isPending?"Removing...":"Take Down Banner"]})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-sm font-semibold mb-3 block",children:"Choose a Banner Style"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:K.map(r=>
3e.jsx(g,{className:`cursor-pointer transition-all duration-200 hover:scale-[1.02] ${i===r.id?`border-2 ${r.borderClass} shadow-md`:"border border-border hover:border-foreground/20"}`,onClick:()=>d(r.id),children:e.jsxs(y,{className:"pt-4 pb-3 text-center",children:[e.jsx("div",{className:`inline-flex items-center justify-center h-10 w-10 rounded-full mb-2 ${r.preview}`,children:r.icon}),e.jsx("p",{className:"font-semibold text-sm",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r.description})]})},r.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(C,{htmlFor:"banner-title",className:"text-sm font-semibold",children:"Banner Title"}),e.jsx(M,{id:"banner-title",placeholder:"e.g. Welcome to AIChecklist!",value:x,onChange:r=>u(r.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(C,{htmlFor:"banner-message",className:"text-sm font-semibold",children:"Banner Message"}),e.jsx(ve,{id:"banner-message",placeholder:"e.g. We've just launched new AI-powered features. Check them out!",value:o,onChange:r=>m(r.target.value),className:"mt-1",rows:3})]})]}),e.jsxs(g,{className:"border-dashed",children:[e.jsx(N,{className:"pb-2",children:e.jsx(w,{className:"text-sm",children:"Preview"})}),e.jsx(y,{children:e.jsx("div",{className:`rounded-lg p-4 ${c.preview}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c.icon,e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-sm",children:x||"Your Title Here"}),e.jsx("p",{className:"text-sm opacity-90",children:o||"Your message will appear here..."})]})]}),e.jsx(ce,{className:"h-4 w-4 opacity-60"})]})})})]}),e.jsxs(j,{onClick:()=>t.mutate(),disabled:!o.trim()||!x.trim()||t.isPending,className:"w-full",size:"lg",children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),t.isPending?"Activating...":"Push Banner Live"]})]})}function Te(n){return new Date(n).toLocaleString()}function Pe({reason:n}){const i=n.toLowerCase().includes("domain");return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold ${i?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400":"bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-400"}`,children:[i?e.jsx(de,{className:"h-2.5 w-2.5"}):e.jsx(me,{className:"h-2.5 w-2.5"}),n]})}function Ie(){const[n,i]=p.useState(""),[d,o]=p.useState(!1),[m,x]=p.useState(""),{data:u=[],isLoading:l,refetch:f}=_({queryKey:["/api/admin/blocked-access"],enabled:d,refetchInterval:d?3e4:!1}),t=async()=>{(await fetch("/api/admin/verify-access",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({adminPassword:n})})).ok?(o(!0),x("")):x("Incorrect admin password.")};return d?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5 text-red-500"}),"Blocked Access Attempts"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[u.length," records — auto-refreshes every 30 seconds"]})]}),e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>f(),className:"gap-1.5",children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"Refresh"]})]}),l?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:"Loading…"}):u.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground text-sm",children:[e.jsx($,{className:"h-8 w-8 mx-auto mb-2 opacity-30"}),"No blocked attempts recorded yet."]}):e.jsx("div",{className:"rounded-xl border border-border overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-muted/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Time"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"IP Address"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Reason"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Path"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"User Agent"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Origin / Referer"})]})}),e.jsx("tbody",{children:u.map((a,c)=>e.jsxs("tr",{className:`border-t border-border/50 ${c%2===0?"":"bg-muted/20"}`,children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{className:"h-3 w-3"}),Te(a.createdAt)]})}),e.jsx("td",{className:"px-4 py-3 font-mono font-bold text-foreground whitespace-nowrap",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(be,{className:"h-3 w-3 text-red-500"}),a.ip]})}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsx(Pe,{reason:a.reason})}),e.jsxs("td",{className:"px-4 py-3 text-muted-foreground max-w-[120px] truncate",children:[a.method&&e.jsxs("span",{className:"font-semibold text-foreground",children:[a.method," "]}),a.path||"—"]}
3),e.jsx("td",{className:"px-4 py-3 text-muted-foreground max-w-[200px] truncate",title:a.userAgent||"",children:a.userAgent||"—"}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground max-w-[180px] truncate",title:a.origin||a.referer||"",children:a.origin||a.referer||"—"})]},a.id))})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsx($,{className:"h-10 w-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter admin password to view blocked access logs"}),e.jsxs("div",{className:"flex gap-2 w-72",children:[e.jsx("input",{type:"password",value:n,onChange:a=>i(a.target.value),onKeyDown:a=>a.key==="Enter"&&t(),placeholder:"Admin password",className:"flex-1 px-3 py-2 text-sm border border-border rounded-md bg-background outline-none"}),e.jsx(j,{size:"sm",onClick:t,children:"Unlock"})]}),m&&e.jsx("p",{className:"text-xs text-destructive",children:m})]})}function Je(){return e.jsx("div",{className:"w-full",children:e.jsxs(ae,{defaultValue:"testers",className:"w-full",children:[e.jsxs(re,{className:"mb-6",children:[e.jsx(E,{value:"testers",children:"Testers"}),e.jsx(E,{value:"banners",children:"Banners"}),e.jsx(E,{value:"api-keys",children:"API Keys"}),e.jsx(E,{value:"logs",children:"System Logs"}),e.jsx(E,{value:"blocked",children:"Blocked Access"})]}),e.jsx(k,{value:"testers",children:e.jsx(ke,{})}),e.jsx(k,{value:"banners",children:e.jsx(Ce,{})}),e.jsx(k,{value:"api-keys",children:e.jsx(we,{})}),e.jsx(k,{value:"logs",children:e.jsx(Ne,{})}),e.jsx(k,{value:"blocked",children:e.jsx(Ie,{})})]})})}export{Je as AdminContent,Je 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.